From: Chris Duncan Date: Wed, 12 Aug 2026 09:21:29 +0000 (-0700) Subject: Remove extraneous error logging, X-Git-Tag: v1.0.8~2 X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=381b265eb6c642613455d069e0ddae39b24d2f17;p=nano25519.git Remove extraneous error logging, --- diff --git a/src/lib/nano25519.ts b/src/lib/nano25519.ts index 3c99075..3087283 100644 --- a/src/lib/nano25519.ts +++ b/src/lib/nano25519.ts @@ -151,15 +151,18 @@ const nano25519_init = (bytes: number[]): { derive: typeof derive, sign: typeof if (typeof name !== 'string') { throw new TypeError(`Invalid name ${name}`) } - if (typeof byteLengthMin !== 'number' || typeof byteLengthMax !== 'number') { - throw new TypeError(`Invalid byte length for ${name}`) + if (typeof byteLengthMin !== 'number') { + throw new TypeError(`Invalid minimum byte length for ${name}`) + } + if (typeof byteLengthMax !== 'number') { + throw new TypeError(`Invalid maximum byte length for ${name}`) } if (typeof value === 'string') { if (/[^0-9a-f]/i.test(value)) { - throw new TypeError(`Invalid hexadecimal characters in ${name} ${value}`) + throw new TypeError(`Invalid hexadecimal characters in ${name}`) } if (value.length & 1 || value.length < (byteLengthMin << 1) || value.length > (byteLengthMax << 1)) { - throw new TypeError(`Invalid hexadecimal length ${value.length} for ${name} ${value}`) + throw new TypeError(`Invalid hexadecimal length ${value.length} for ${name}`) } value = new Uint8Array(value.match(/[0-9a-f]{2}/gi)?.map(b => parseInt(b, 16)) || []) } @@ -308,7 +311,7 @@ function init (): void { isWorkerReady = true } catch (err: any) { isWorkerReady = false - throw new Error('nano25519 initialization failed.', { cause: err }) + throw new Error('nano25519 initialization failed') } } @@ -372,13 +375,13 @@ async function dispatch (data: { [key: string]: string | ArrayBuffer | Uint8Arra if (data.url !== url) return if (data.id !== id) return const { result } = data - console.log(`received result from worker: `, result) + console.log('received result from worker') if (typeof result !== 'boolean' && typeof result !== 'string' && !isBytes(result)) { return reject('Invalid return type') } resolve(result) } - console.log(`sending data to worker: `, data) + console.log('sending data to worker') data.url = url data.id = id BROWSER: { @@ -435,25 +438,22 @@ export async function run (data: Record try { await start() } catch (err: any) { - console.error(err?.stack ?? err) throw new Error('Error initializing worker') } try { const result = await dispatch(data) if (typeof result === 'string' && !/^([0-9a-f]{64}|[0-9a-f]{128})$/i.test(result)) { - throw new Error(result) + throw new Error('Invalid result') } return result } catch (err: any) { - console.error(err) - console.error(data) try { await stop() } catch (e: any) { - console.error('failed to stop worker', err?.message ?? err ?? 'unknown reason') + console.error('failed to stop worker') reset() } finally { - throw new Error(err?.message ?? err ?? 'unknown error') + throw new Error('Error dispatching async request') } } }