aboutsummaryrefslogtreecommitdiff
path: root/background/nonce_store.js
blob: 9370876e0a58f547a0c4660135f3025007421890 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/**
 * Central management of HTTP(S) nonces
 *
 * Copyright (C) 2021 jahoti
 * Redistribution terms are gathered in the `copyright' file.
 */

/*
 * IMPORTS_START
 * IMPORT gen_nonce
 * IMPORTS_END
 */

var nonces = {};

function retrieve_nonce(tabId, frameId, update)
{
    let code = tabId + '.' + frameId;
    console.log('Nonce for ' + code + ' ' + (update ? 'created/updated' : 'requested'));
    if (update)
        nonces[code] = gen_nonce();
    
    return nonces[code];
}

/*
 * EXPORTS_START
 * EXPORT retrieve_nonce
 * EXPORTS_END
 */