diff options
author | Florian Dold <florian.dold@gmail.com> | 2017-02-13 09:53:34 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2017-02-13 09:53:34 +0100 |
commit | 3a074443b764bf38b24e5ff4ef7e81d6ba351a55 (patch) | |
tree | ca446bd585b1938c8258cbee074d6a2bb66a5808 /src/content_scripts/notify.ts | |
parent | e2738c58233038895611a67f127ee605112c5e11 (diff) |
use EdDSA public key as nonce, store private key in DB
Diffstat (limited to 'src/content_scripts/notify.ts')
-rw-r--r-- | src/content_scripts/notify.ts | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/content_scripts/notify.ts b/src/content_scripts/notify.ts index 6a0d9d298..582375e1d 100644 --- a/src/content_scripts/notify.ts +++ b/src/content_scripts/notify.ts @@ -173,6 +173,17 @@ namespace TalerNotify { (detail: any, sendResponse: (msg: any) => void): void; } + function generateNonce(): Promise<string> { + const walletMsg = { + type: "generate-nonce", + }; + return new Promise((resolve, reject) => { + chrome.runtime.sendMessage(walletMsg, (resp: any) => { + resolve(resp); + }); + }); + } + function downloadContract(url: string, nonce: string): Promise<any> { let parsed_url = URI(url); url = parsed_url.setQuery({nonce}).href(); @@ -358,7 +369,7 @@ namespace TalerNotify { return; } if (msg.contract_url) { - let nonce = Math.round(Math.random() * 0xFFFF).toString() + let nonce = await generateNonce(); let proposal = await downloadContract(msg.contract_url, nonce); if (proposal.data.nonce != nonce) { console.error("stale contract"); |