refactor: cleanup crypto import
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Wed, 29 Nov 2023 19:30:38 +0000 (20:30 +0100)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Wed, 29 Nov 2023 19:30:38 +0000 (20:30 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
.eslintrc.js
src/utils.ts

index 9d0d7ce4cea3efda4777c7004a459cd307f8df57..8af594dfe56ce4605af1dcca6e5ee12477fd778f 100644 (file)
@@ -97,7 +97,6 @@ module.exports = defineConfig({
           'unlink',
           'unref',
           'utf8',
-          'webcrypto',
           'workerpool',
           'ws',
           'wss',
index a0a9e530131cbe78df7401dff80452eef16e8634..5a685439ed7725c0bc305df5d86af2f670a5a9a3 100644 (file)
@@ -1,5 +1,5 @@
 import * as os from 'node:os'
-import { webcrypto } from 'node:crypto'
+import { getRandomValues } from 'node:crypto'
 import { Worker as ClusterWorker } from 'node:cluster'
 import { Worker as ThreadWorker } from 'node:worker_threads'
 import type {
@@ -226,7 +226,7 @@ export const isAsyncFunction = (
  * @internal
  */
 export const secureRandom = (): number => {
-  return webcrypto.getRandomValues(new Uint32Array(1))[0] / 0x100000000
+  return getRandomValues(new Uint32Array(1))[0] / 0x100000000
 }
 
 /**