From 4868e215b67efb09b59be835d9a8683243689b38 Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Tue, 3 Dec 2024 14:55:09 -0800 Subject: [PATCH] Fix hexification. --- src/lib/nano-nacl.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lib/nano-nacl.ts b/src/lib/nano-nacl.ts index 62d2732..9a38cf8 100644 --- a/src/lib/nano-nacl.ts +++ b/src/lib/nano-nacl.ts @@ -24,7 +24,7 @@ const n = () => { addEventListener('message', message => { const data = JSON.parse(new TextDecoder().decode(message.data ?? message)) for (const d of data) { - d.publicKey = hexify(convert(d.privateKey).publicKey) + d.publicKey = convert(d.privateKey) } const buf = new TextEncoder().encode(JSON.stringify(data)).buffer postMessage(buf, [buf]) @@ -759,10 +759,10 @@ const n = () => { function hexify (buf: Uint8Array): string { let str = '' for (let i = 0; i < buf.length; i++) { - if (typeof next !== 'number') - throw new TypeError(`expected number to convert to hex; received ${typeof next}`) - if (next < 0 || next > 255) - throw new RangeError(`expected byte value 0-255; received ${next}`) + if (typeof buf[i] !== 'number') + throw new TypeError(`expected number to convert to hex; received ${typeof buf[i]}`) + if (buf[i] < 0 || buf[i] > 255) + throw new RangeError(`expected byte value 0-255; received ${buf[i]}`) str += buf[i].toString(16).padStart(2, '0') } return str -- 2.34.1