forro

Forro is a end-to-end encrypted contract form based on PGP.
git clone git://git.defalsify.org/forro.git
Log | Files | Refs | LICENSE

commit 2545860578ec2d63cbddc6544d2991147be5d1c4
parent bee2a278b5f06609408d9dfcb736f8b116e2dc74
Author: lash <dev@holbrook.no>
Date:   Mon, 19 Sep 2022 22:12:23 +0000

Feedback on wrong passphrase

Diffstat:
Mindex.html | 27+++++++++++++++------------
Mkey.js | 5-----
2 files changed, 15 insertions(+), 17 deletions(-)

diff --git a/index.html b/index.html @@ -56,17 +56,16 @@ let g_counter = undefined; } async function unlockLocalKey(pwd) { - return new Promise(async (whohoo, doh) => { - try { - stateChange('check existing key'); - g_local_key = await getKey(pwd); - } catch(e) { - doh(e); - } - const decrypted = g_local_key.isDecrypted() - stateChange('found key ' + g_local_key.getKeyID().toHex() + ' (decrypted: ' + decrypted + ')'); - whohoo(decrypted); - }); + try { + stateChange('check existing key'); + g_local_key = await getKey(pwd); + } catch(e) { + console.error(e); + return false; + } + const decrypted = g_local_key.isDecrypted() + stateChange('found key ' + g_local_key.getKeyID().toHex() + ' (decrypted: ' + decrypted + ')'); + return decrypted; } async function applyLocalKey() { @@ -328,7 +327,11 @@ let g_counter = undefined; x-show='!have_passphrase'> <input name="pwd" type="password" x-model='passphrase_cache' x-bind:placeholder='passphrase_status' /> - <button @click='have_passphrase = await setPwd(passphrase_cache); if (!have_passphrase) { passphrase_status = "wrong passphrase"; passphrase_cache = ""; };' >go</button> + <button x-data="{ + go_label: 'go', + }" + x-text='go_label' + @click='have_passphrase = await setPwd(passphrase_cache); if (!have_passphrase) { passphrase_status = "wrong passphrase"; go_label = "go again"; passphrase_cache = ""; };' ></button> <button x-show='!key' @click='have_passphrase = true; await setPwd();' >without passphrase</button> </div> <div x-show='have_passphrase' x-init="await setUp();" x-data="{ diff --git a/key.js b/key.js @@ -36,11 +36,6 @@ async function getKey(pwd) { let pk = await openpgp.readKey({ armoredKey: pk_armor, }); -// let k = await openpgp.decryptKey({ -// privateKey: pk, -// passphrase: pwd, -// }); - //console.debug('pk ' + k.armor()); console.debug('our public key', pk.toPublic().armor()); if (pwd !== undefined) {