]> git.codecow.com Git - libnemo.git/commitdiff
Resume vault autolock timer when catching async errors.
authorChris Duncan <chris@codecow.com>
Sat, 8 Aug 2026 09:19:03 +0000 (02:19 -0700)
committerChris Duncan <chris@codecow.com>
Sat, 8 Aug 2026 09:19:03 +0000 (02:19 -0700)
src/lib/vault/vault-worker.ts

index 8f166a253b8e524f6dac897c689468e884275836..53162f16dd711b7856bcb5b5d8442a8d20dbb8b5 100644 (file)
@@ -267,17 +267,23 @@ function sign (index?: Uint32Array, data?: ArrayBuffer): Promise<Record<string,
                if (data == null) {
                        throw new Error('Data to sign not found')
                }
-               return _ckd(index[0]).then(result => {
-                       const prv = new Uint8Array(result)
-                       const pub = nano25519_derive(prv)
-                       const sk = new Uint8Array([...prv, ...pub])
-                       prv.fill(0)
-                       pub.fill(0)
-                       const sig = nano25519_sign(new Uint8Array(data), sk)
-                       sk.fill(0)
-                       _timer = new VaultTimer(_autolock, _timeout)
-                       return { signature: sig.buffer }
-               })
+               return _ckd(index[0])
+                       .then(result => {
+                               const prv = new Uint8Array(result)
+                               const pub = nano25519_derive(prv)
+                               const sk = new Uint8Array([...prv, ...pub])
+                               prv.fill(0)
+                               pub.fill(0)
+                               const sig = nano25519_sign(new Uint8Array(data), sk)
+                               sk.fill(0)
+                               _timer = new VaultTimer(_autolock, _timeout)
+                               return { signature: sig.buffer }
+                       })
+                       .catch(err => {
+                               console.error(err)
+                               _timer.resume()
+                               throw new Error('Failed to sign message', { cause: err })
+                       })
        } catch (err) {
                console.error(err)
                _timer.resume()
@@ -357,6 +363,11 @@ function update (key?: CryptoKey, salt?: ArrayBuffer): Promise<Record<string, Ar
                                _timer = new VaultTimer(_autolock, _timeout)
                                return { iv, salt, encrypted }
                        })
+                       .catch(err => {
+                               console.error(err)
+                               _timer.resume()
+                               throw new Error('Failed to update wallet password', { cause: err })
+                       })
        } catch (err) {
                console.error(err)
                _timer.resume()