From 7cd0a6218a4110e12fe8bc408492913da7259f8b Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Wed, 29 Nov 2023 20:26:01 +0100 Subject: [PATCH] refactor: cleanup crypto import MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/utils/Utils.ts | 4 ++-- src/worker/WorkerUtils.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/utils/Utils.ts b/src/utils/Utils.ts index efdffc2f..c37f48cf 100644 --- a/src/utils/Utils.ts +++ b/src/utils/Utils.ts @@ -1,4 +1,4 @@ -import { randomBytes, randomInt, randomUUID, webcrypto } from 'node:crypto'; +import { getRandomValues, randomBytes, randomInt, randomUUID } from 'node:crypto'; import { env, nextTick } from 'node:process'; import { @@ -336,7 +336,7 @@ export const exponentialDelay = (retryNumber = 0, delayFactor = 100): number => * @returns A number in the [0,1[ range */ export const secureRandom = (): number => { - return webcrypto.getRandomValues(new Uint32Array(1))[0] / 0x100000000; + return getRandomValues(new Uint32Array(1))[0] / 0x100000000; }; export const JSONStringifyWithMapSupport = ( diff --git a/src/worker/WorkerUtils.ts b/src/worker/WorkerUtils.ts index 18747673..776d7174 100644 --- a/src/worker/WorkerUtils.ts +++ b/src/worker/WorkerUtils.ts @@ -1,4 +1,4 @@ -import { webcrypto } from 'node:crypto'; +import { getRandomValues } from 'node:crypto'; import chalk from 'chalk'; @@ -34,5 +34,5 @@ export const randomizeDelay = (delay: number): number => { * @internal */ const secureRandom = (): number => { - return webcrypto.getRandomValues(new Uint32Array(1))[0] / 0x100000000; + return getRandomValues(new Uint32Array(1))[0] / 0x100000000; }; -- 2.34.1