From 8964c9df636bcc3f1a450774a140837096ab8010 Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Tue, 31 Mar 2026 03:16:14 -0700 Subject: [PATCH] Align tsc libs with esbuild targets and remove unsupported functions. --- src/lib/convert.ts | 8 ++++---- src/lib/crypto/bip39.ts | 4 ++-- src/lib/vault/passkey.ts | 2 +- src/lib/vault/vault-worker.ts | 4 ++-- src/lib/wallet/index.ts | 4 ++-- tsconfig.json | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/lib/convert.ts b/src/lib/convert.ts index af1c3d7..cd1db65 100644 --- a/src/lib/convert.ts +++ b/src/lib/convert.ts @@ -81,10 +81,10 @@ export class bytes { */ static erase (bytes?: ArrayBuffer | Uint8Array | null): void { if (bytes == null) return - if (bytes instanceof ArrayBuffer && bytes.detached) return - if (bytes instanceof Uint8Array && bytes.buffer.detached) return + if (bytes instanceof ArrayBuffer && bytes.byteLength === 0) return + if (bytes instanceof Uint8Array && bytes.buffer.byteLength === 0) return bytes = bytes instanceof ArrayBuffer ? new Uint8Array(bytes) : bytes - bytes.fill(0).buffer.transfer?.() + bytes.fill(0) } /** @@ -153,7 +153,7 @@ export class bytes { */ static toHex (bytes: ArrayBuffer | Uint8Array): string { if (bytes instanceof ArrayBuffer) bytes = new Uint8Array(bytes) - if (bytes.buffer instanceof ArrayBuffer && bytes.buffer.detached) return '' + if (bytes.buffer instanceof ArrayBuffer && bytes.buffer.byteLength === 0) return '' return [...bytes] .map(byte => byte.toString(16).padStart(2, '0')) .join('') diff --git a/src/lib/crypto/bip39.ts b/src/lib/crypto/bip39.ts index 2843821..ba10bf1 100644 --- a/src/lib/crypto/bip39.ts +++ b/src/lib/crypto/bip39.ts @@ -157,8 +157,8 @@ export class Bip39 { * Erases seed bytes and releases variable references. */ destroy () { - this.#bip39Seed?.fill(0).buffer.transfer?.() - this.#blake2bSeed?.fill(0).buffer.transfer?.() + this.#bip39Seed?.fill(0) + this.#blake2bSeed?.fill(0) this.#bip39Seed = undefined this.#blake2bSeed = undefined this.#phrase = undefined diff --git a/src/lib/vault/passkey.ts b/src/lib/vault/passkey.ts index 97d9e98..90a70b8 100644 --- a/src/lib/vault/passkey.ts +++ b/src/lib/vault/passkey.ts @@ -22,7 +22,7 @@ export class Passkey { return crypto.subtle .importKey('raw', password, 'PBKDF2', false, ['deriveKey']) .then(derivationKey => { - new Uint8Array(password).fill(0).buffer.transfer?.() + new Uint8Array(password).fill(0) const derivationAlgorithm: Pbkdf2Params = { name: 'PBKDF2', hash: 'SHA-512', diff --git a/src/lib/vault/vault-worker.ts b/src/lib/vault/vault-worker.ts index b740c52..c980c2d 100644 --- a/src/lib/vault/vault-worker.ts +++ b/src/lib/vault/vault-worker.ts @@ -87,8 +87,8 @@ const listener = (event: MessageEvent): void => { }) .catch((err: any) => { for (let data of Object.values(event.data)) { - if (data instanceof ArrayBuffer && !data.detached) { - new Uint8Array(data).fill(0).buffer.transfer?.() + if (data instanceof ArrayBuffer && data.byteLength !== 0) { + new Uint8Array(data).fill(0) } data = undefined } diff --git a/src/lib/wallet/index.ts b/src/lib/wallet/index.ts index fce75ba..877433f 100644 --- a/src/lib/wallet/index.ts +++ b/src/lib/wallet/index.ts @@ -192,7 +192,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) return m } catch { this.#mnemonic = undefined @@ -210,7 +210,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) return s } catch { this.#seed = undefined diff --git a/tsconfig.json b/tsconfig.json index 38369a7..9839a27 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -16,7 +16,7 @@ "target": "es2024", "lib": [ "DOM", - "ES2024" + "ES2022" ], "types": [ "node", -- 2.47.3