]> git.codecow.com Git - libnemo.git/commitdiff
Fix errors thrown and not caught.
authorChris Duncan <chris@zoso.dev>
Mon, 18 Aug 2025 19:40:25 +0000 (12:40 -0700)
committerChris Duncan <chris@zoso.dev>
Mon, 18 Aug 2025 19:40:25 +0000 (12:40 -0700)
src/lib/wallet/create.ts
src/lib/wallet/load.ts

index 706b18c9284b92972730c0090604360e683fd6a5..a9c65be76a893d069377191d6dcc284bc7922d2b 100644 (file)
@@ -10,13 +10,13 @@ import { NamedData } from '#types'
 
 export async function _create (wallet: Wallet, vault: Vault, password: string, mnemonicSalt?: string): Promise<NamedData<ArrayBuffer>>
 export async function _create (wallet: Wallet, vault: Vault, password: unknown, mnemonicSalt?: unknown): Promise<NamedData<ArrayBuffer>> {
-       if (typeof password !== 'string') {
-               throw new TypeError('Invalid password', { cause: typeof password })
-       }
-       if (mnemonicSalt !== undefined && typeof mnemonicSalt !== 'string') {
-               throw new TypeError('Mnemonic salt must be a string')
-       }
        try {
+               if (typeof password !== 'string') {
+                       throw new TypeError('Invalid password', { cause: typeof password })
+               }
+               if (mnemonicSalt !== undefined && typeof mnemonicSalt !== 'string') {
+                       throw new TypeError('Mnemonic salt must be a string')
+               }
                const { iv, salt, encrypted, seed, mnemonic } = await vault.request<ArrayBuffer>({
                        action: 'create',
                        type: wallet.type,
index bd0f77f4203ee89fd1b2c01634bea30fe37e8c74..684783a8b292ae2ee2d447510b5c4b4f1aad27d9 100644 (file)
@@ -10,16 +10,16 @@ import { Vault } from '../vault'
 
 export async function _load (wallet: Wallet, vault: Vault, password: string, secret: string, mnemonicSalt?: string): Promise<void>
 export async function _load (wallet: Wallet, vault: Vault, password: unknown, secret: unknown, mnemonicSalt?: unknown): Promise<void> {
-       if (typeof password !== 'string') {
-               throw new TypeError('Password must be a string')
-       }
-       if (typeof secret !== 'string') {
-               throw new TypeError('Wallet secret must be a string')
-       }
-       if (mnemonicSalt !== undefined && typeof mnemonicSalt !== 'string') {
-               throw new TypeError('Mnemonic salt must be a string')
-       }
        try {
+               if (typeof password !== 'string') {
+                       throw new TypeError('Password must be a string')
+               }
+               if (typeof secret !== 'string') {
+                       throw new TypeError('Wallet secret must be a string')
+               }
+               if (mnemonicSalt !== undefined && typeof mnemonicSalt !== 'string') {
+                       throw new TypeError('Mnemonic salt must be a string')
+               }
                const data: NamedData = {
                        action: 'load',
                        type: wallet.type,