diff options
Diffstat (limited to 'background/nonce_store.js')
-rw-r--r-- | background/nonce_store.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/background/nonce_store.js b/background/nonce_store.js new file mode 100644 index 0000000..9370876 --- /dev/null +++ b/background/nonce_store.js @@ -0,0 +1,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 + */ |