From 9d7f4bfca10fa8573b43c8dfb30ded57355697a4 Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Thu, 5 Dec 2024 23:04:37 -0800 Subject: [PATCH] Delete unused node polyfills. --- src/lib/bip44-ckd.ts | 6 +----- src/lib/nano-nacl.ts | 15 --------------- src/lib/pow.ts | 15 --------------- src/lib/workers/passkey.ts | 11 ----------- 4 files changed, 1 insertion(+), 46 deletions(-) diff --git a/src/lib/bip44-ckd.ts b/src/lib/bip44-ckd.ts index 97777c3..c768e8b 100644 --- a/src/lib/bip44-ckd.ts +++ b/src/lib/bip44-ckd.ts @@ -119,8 +119,4 @@ export const Bip44Ckd = b() const start = b.toString().indexOf('{') + 1 const end = b.toString().lastIndexOf('return') -let worker_threads = '' -if (typeof window === 'undefined' && typeof self === 'undefined') { - worker_threads += `import { isMainThread, parentPort } from 'node:worker_threads'\n` -} -export const worker = worker_threads + b.toString().substring(start, end) +export const worker = b.toString().substring(start, end) diff --git a/src/lib/nano-nacl.ts b/src/lib/nano-nacl.ts index dffd50e..27cba26 100644 --- a/src/lib/nano-nacl.ts +++ b/src/lib/nano-nacl.ts @@ -18,21 +18,6 @@ import { Blake2b } from './blake2b.js' // Original source commit: https://github.com/dchest/tweetnacl-js/blob/71df1d6a1d78236ca3e9f6c788786e21f5a651a6/nacl-fast.js const n = () => { - /** - * Polyfill for window methods which do not exist when executing Node.js tests. - */ - if (typeof window === 'undefined' && typeof self === 'undefined') { - try { - import('node:worker_threads').then(worker_threads => { - const { isMainThread, parentPort } = worker_threads - if (!isMainThread && parentPort) { - var addEventListener = Object.getPrototypeOf(parentPort).addListener.bind(parentPort) - var postMessage = Object.getPrototypeOf(parentPort).postMessage.bind(parentPort) - } - }) - } catch { } - } - /** * Listens for messages from a calling function. */ diff --git a/src/lib/pow.ts b/src/lib/pow.ts index eb55711..1bfe34b 100644 --- a/src/lib/pow.ts +++ b/src/lib/pow.ts @@ -2,21 +2,6 @@ // SPDX-License-Identifier: GPL-3.0-or-later const p = async () => { - /** - * Polyfill for window methods which do not exist when executing Node.js tests. - */ - if (typeof window === 'undefined' && typeof self === 'undefined') { - try { - import('node:worker_threads').then(worker_threads => { - const { isMainThread, parentPort } = worker_threads - if (!isMainThread && parentPort) { - var addEventListener = Object.getPrototypeOf(parentPort).addListener.bind(parentPort) - var postMessage = Object.getPrototypeOf(parentPort).postMessage.bind(parentPort) - } - }) - } catch (err) { } - } - const SEND_THRESHOLD = '0xfffffff8' /** * Listens for messages from a calling function. diff --git a/src/lib/workers/passkey.ts b/src/lib/workers/passkey.ts index c660e4a..648f1bd 100644 --- a/src/lib/workers/passkey.ts +++ b/src/lib/workers/passkey.ts @@ -10,17 +10,6 @@ * using the `importKey()` method of the SubtleCrypto interface. */ async function passkey () { - /** - * Polyfill for window methods which do not exist when executing Node.js tests. - */ - if (globalThis.addEventListener == null || globalThis.postMessage == null) { - const { isMainThread, parentPort } = await import('node:worker_threads') - if (!isMainThread && parentPort) { - var addEventListener = Object.getPrototypeOf(parentPort).addListener.bind(parentPort) - var postMessage = Object.getPrototypeOf(parentPort).postMessage.bind(parentPort) - } - } - /** * Message listener for this Web Worker thread. */ -- 2.34.1