]> git.codecow.com Git - libnemo.git/commitdiff
Ensure password bytes exist when locking or unlocking.
authorChris Duncan <chris@zoso.dev>
Thu, 3 Jul 2025 21:02:45 +0000 (14:02 -0700)
committerChris Duncan <chris@zoso.dev>
Thu, 3 Jul 2025 21:02:45 +0000 (14:02 -0700)
src/lib/account.ts
src/lib/wallets/wallet.ts

index 2bc5c1d62aaeebf2d9c2614c6afa81cda636e19b..01bd615bfd9d45d8c760b6d5a69dec98c5eae0db 100644 (file)
@@ -137,6 +137,9 @@ export class Account {
                if (typeof password === 'string') {\r
                        password = utf8.toBytes(password)\r
                }\r
+               if (password == null || password.constructor.name !== 'Uint8Array') {\r
+                       throw new Error('Failed to unlock wallet')\r
+               }\r
                try {\r
                        if (this.#prv != null) {\r
                                await Account.#poolSafe.assign({\r
@@ -157,6 +160,9 @@ export class Account {
                if (typeof password === 'string') {\r
                        password = utf8.toBytes(password)\r
                }\r
+               if (password == null || password.constructor.name !== 'Uint8Array') {\r
+                       throw new Error('Failed to unlock wallet')\r
+               }\r
                try {\r
                        this.#prv = await Account.#poolSafe.assign({\r
                                method: 'get',\r
index a88356361fee3d52252fd95752986d7c57f8a545..474a8bab11957ff6dffa2c812f291abb4cc71c34 100644 (file)
@@ -229,6 +229,9 @@ export abstract class Wallet {
                if (typeof password === 'string') {\r
                        password = utf8.toBytes(password)\r
                }\r
+               if (password == null || password.constructor.name !== 'Uint8Array') {\r
+                       throw new Error('Failed to unlock wallet')\r
+               }\r
                let success = true\r
                try {\r
                        const data: { id: string, mnemonic: string | null, seed: string | null } = {\r
@@ -276,6 +279,9 @@ export abstract class Wallet {
                if (typeof password === 'string') {\r
                        password = utf8.toBytes(password)\r
                }\r
+               if (password == null || password.constructor.name !== 'Uint8Array') {\r
+                       throw new Error('Failed to unlock wallet')\r
+               }\r
                try {\r
                        const data = await this.#poolSafe.assign({\r
                                method: 'get',\r