From: Jérôme Benoit Date: Wed, 29 Nov 2023 19:26:01 +0000 (+0100) Subject: refactor: cleanup crypto import X-Git-Tag: v1.2.28~7 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=7cd0a6218a4110e12fe8bc408492913da7259f8b;p=e-mobility-charging-stations-simulator.git refactor: cleanup crypto import Signed-off-by: Jérôme Benoit --- 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; };