1
|
/**
|
2
|
* Central management of HTTP(S) nonces
|
3
|
*
|
4
|
* Copyright (C) 2021 jahoti
|
5
|
* Redistribution terms are gathered in the `copyright' file.
|
6
|
*/
|
7
|
|
8
|
/*
|
9
|
* IMPORTS_START
|
10
|
* IMPORT gen_nonce
|
11
|
* IMPORTS_END
|
12
|
*/
|
13
|
|
14
|
var nonces = {};
|
15
|
|
16
|
function retrieve_nonce(tabId, frameId, update)
|
17
|
{
|
18
|
let code = tabId + '.' + frameId;
|
19
|
console.log('Nonce for ' + code + ' ' + (update ? 'created/updated' : 'requested'));
|
20
|
if (update)
|
21
|
nonces[code] = gen_nonce();
|
22
|
|
23
|
return nonces[code];
|
24
|
}
|
25
|
|
26
|
/*
|
27
|
* EXPORTS_START
|
28
|
* EXPORT retrieve_nonce
|
29
|
* EXPORTS_END
|
30
|
*/
|