*/\r
static erase (bytes?: ArrayBuffer | Uint8Array<ArrayBuffer> | null): void {\r
if (bytes == null) return\r
- if (bytes instanceof ArrayBuffer && bytes.detached) return\r
- if (bytes instanceof Uint8Array && bytes.buffer.detached) return\r
+ if (bytes instanceof ArrayBuffer && bytes.byteLength === 0) return\r
+ if (bytes instanceof Uint8Array && bytes.buffer.byteLength === 0) return\r
bytes = bytes instanceof ArrayBuffer ? new Uint8Array(bytes) : bytes\r
- bytes.fill(0).buffer.transfer?.()\r
+ bytes.fill(0)\r
}\r
\r
/**\r
*/\r
static toHex (bytes: ArrayBuffer | Uint8Array): string {\r
if (bytes instanceof ArrayBuffer) bytes = new Uint8Array(bytes)\r
- if (bytes.buffer instanceof ArrayBuffer && bytes.buffer.detached) return ''\r
+ if (bytes.buffer instanceof ArrayBuffer && bytes.buffer.byteLength === 0) return ''\r
return [...bytes]\r
.map(byte => byte.toString(16).padStart(2, '0'))\r
.join('')\r
* Erases seed bytes and releases variable references.\r
*/\r
destroy () {\r
- this.#bip39Seed?.fill(0).buffer.transfer?.()\r
- this.#blake2bSeed?.fill(0).buffer.transfer?.()\r
+ this.#bip39Seed?.fill(0)\r
+ this.#blake2bSeed?.fill(0)\r
this.#bip39Seed = undefined\r
this.#blake2bSeed = undefined\r
this.#phrase = undefined\r
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',
})
.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
}
const b = new Uint8Array(this.#mnemonic)\r
this.#mnemonic = undefined\r
const m = bytes.toUtf8(b)\r
- b.fill(0).buffer.transfer?.()\r
+ b.fill(0)\r
return m\r
} catch {\r
this.#mnemonic = undefined\r
const b = new Uint8Array(this.#seed)\r
this.#seed = undefined\r
const s = bytes.toHex(b)\r
- b.fill(0).buffer.transfer?.()\r
+ b.fill(0)\r
return s\r
} catch {\r
this.#seed = undefined\r
"target": "es2024",
"lib": [
"DOM",
- "ES2024"
+ "ES2022"
],
"types": [
"node",