]> git.codecow.com Git - libnemo.git/commitdiff
Fix internal vault worker variable references.
authorChris Duncan <chris@zoso.dev>
Tue, 31 Mar 2026 09:06:55 +0000 (02:06 -0700)
committerChris Duncan <chris@zoso.dev>
Tue, 31 Mar 2026 09:06:55 +0000 (02:06 -0700)
src/lib/vault/vault-worker.ts

index 57aa1f968ec53ebd834e93e177c2524432cb6275..599dd2a057b8c78397db748f4bce5bb3bd9ea58b 100644 (file)
@@ -116,8 +116,8 @@ async function config (timeout?: number): Promise<void> {
                        if (timeout > 600) {
                                throw new RangeError('Timeout must be at most 10 minutes')
                        }
-                       timeout = timeout * 1000
-                       _timer = new VaultTimer(() => lock(), timeout)
+                       _timeout = timeout * 1000
+                       _timer = new VaultTimer(() => lock(), _timeout)
                }
                return Promise.resolve()
        } catch (err) {
@@ -291,9 +291,9 @@ async function unlock (type?: WalletType, key?: CryptoKey, iv?: ArrayBuffer, enc
                        if (mnemonic != null && !(mnemonic instanceof ArrayBuffer)) {
                                throw new TypeError('Invalid mnemonic')
                        }
-                       type = type
-                       seed = seed
-                       mnemonic = mnemonic
+                       _type = type
+                       _seed = seed
+                       _mnemonic = mnemonic
                        _locked = false
                        _timer = new VaultTimer(lock, _timeout)
                        BROWSER: postMessage('unlocked')
@@ -345,7 +345,7 @@ function verify (seed?: ArrayBuffer, mnemonicPhrase?: string): Record<string, bo
                if (_locked) {
                        throw new Error('Wallet is locked')
                }
-               if (seed == null) {
+               if (_seed == null) {
                        throw new Error('Wallet seed not found')
                }
                if (seed == null && mnemonicPhrase == null) {
@@ -358,7 +358,7 @@ function verify (seed?: ArrayBuffer, mnemonicPhrase?: string): Record<string, bo
                if (seed != null) {
                        let diff = 0
                        const userSeed = new Uint8Array(seed)
-                       const thisSeed = new Uint8Array(seed)
+                       const thisSeed = new Uint8Array(_seed)
                        for (let i = 0; i < userSeed.byteLength; i++) {
                                diff |= userSeed[i] ^ thisSeed[i]
                        }
@@ -546,7 +546,8 @@ function _load (type?: 'BIP-44' | 'BLAKE2b' | 'Exodus', key?: CryptoKey, keySalt
                }
                return seed.then(seed => {
                        _seed = seed
-                       return WalletAesGcm.encrypt(type, key, _seed, _mnemonic)
+                       return WalletAesGcm
+                               .encrypt(type, key, _seed, _mnemonic)
                                .then(({ iv, encrypted }) => ({ iv, salt: keySalt, encrypted }))
                })
        } catch (err) {