From: Chris Duncan Date: Fri, 8 Aug 2025 18:43:33 +0000 (-0700) Subject: Avoid trying to transfer buffers if unsupported. X-Git-Tag: v0.10.5~43^2~14 X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=3940d5afa77eec8fbc71e3e5ad8c0250c1f15934;p=libnemo.git Avoid trying to transfer buffers if unsupported. --- diff --git a/src/lib/convert.ts b/src/lib/convert.ts index 38dd256..5b20a05 100644 --- a/src/lib/convert.ts +++ b/src/lib/convert.ts @@ -71,8 +71,7 @@ export class bytes { bytes = new Uint8Array(bytes) } if (bytes.buffer.detached) return - bytes.fill(0) - bytes.buffer.transfer() + bytes.fill(0).buffer.transfer?.() } /** diff --git a/src/lib/safe.ts b/src/lib/safe.ts index 147a50f..80290d7 100644 --- a/src/lib/safe.ts +++ b/src/lib/safe.ts @@ -305,7 +305,7 @@ export class Safe { static async #createAesKey (purpose: 'encrypt' | 'decrypt', password: ArrayBuffer, keySalt: ArrayBuffer): Promise { const derivationKey = await crypto.subtle.importKey('raw', password, 'PBKDF2', false, ['deriveBits', 'deriveKey']) - new Uint8Array(password).fill(0).buffer.transfer() + new Uint8Array(password).fill(0).buffer.transfer?.() const derivationAlgorithm: Pbkdf2Params = { name: 'PBKDF2', hash: 'SHA-512', diff --git a/src/lib/wallet.ts b/src/lib/wallet.ts index 78648ff..79d9474 100644 --- a/src/lib/wallet.ts +++ b/src/lib/wallet.ts @@ -177,7 +177,7 @@ export class Wallet { const b = new Uint8Array(this.#mnemonic) this.#mnemonic = undefined const m = bytes.toUtf8(b) - b.fill(0).buffer.transfer() + b.fill(0).buffer.transfer?.() return m } catch { this.#mnemonic = undefined @@ -191,7 +191,7 @@ export class Wallet { const b = new Uint8Array(this.#seed) this.#seed = undefined const s = bytes.toHex(b) - b.fill(0).buffer.transfer() + b.fill(0).buffer.transfer?.() return s } catch { this.#seed = undefined