]> git.codecow.com Git - libnemo.git/commitdiff
Set default vault timer and simplify promise chain.
authorChris Duncan <chris@zoso.dev>
Sat, 30 Aug 2025 08:04:22 +0000 (01:04 -0700)
committerChris Duncan <chris@zoso.dev>
Sat, 30 Aug 2025 08:04:22 +0000 (01:04 -0700)
src/lib/vault/vault-worker.ts

index f7ba7242e9d70a9c9ec0db50f79bd3ebc07a280a..9be024a689af8b76dde2dc32718d2d19e6c40707 100644 (file)
@@ -13,7 +13,7 @@ import { VaultTimer } from './vault-timer'
 */
 export class VaultWorker {
        static locked: boolean = true
-       static timeout: VaultTimer
+       static timeout: VaultTimer = new VaultTimer(() => { }, 0)
        static type?: 'BIP-44' | 'BLAKE2b'
        static seed?: ArrayBuffer
        static mnemonic?: ArrayBuffer
@@ -118,14 +118,12 @@ export class VaultWorker {
                try {
                        const entropy = crypto.getRandomValues(new Uint8Array(32))
                        return Bip39.fromEntropy(entropy)
-                               .then(bip39 => {
-                                       return this._load(type, key, keySalt, bip39.phrase, mnemonicSalt)
-                                               .then(record => {
-                                                       if (this.seed == null || this.mnemonic == null) {
-                                                               throw new Error('Failed to generate seed and mnemonic')
-                                                       }
-                                                       return { ...record, seed: this.seed.slice(), mnemonic: this.mnemonic.slice() }
-                                               })
+                               .then(bip39 => this._load(type, key, keySalt, bip39.phrase, mnemonicSalt))
+                               .then(record => {
+                                       if (this.seed == null || this.mnemonic == null) {
+                                               throw new Error('Failed to generate seed and mnemonic')
+                                       }
+                                       return { ...record, seed: this.seed.slice(), mnemonic: this.mnemonic.slice() }
                                })
                } catch (err) {
                        console.error(err)