summaryrefslogtreecommitdiff
path: root/ext/node/polyfills
diff options
context:
space:
mode:
Diffstat (limited to 'ext/node/polyfills')
-rw-r--r--ext/node/polyfills/internal/crypto/random.ts19
1 files changed, 15 insertions, 4 deletions
diff --git a/ext/node/polyfills/internal/crypto/random.ts b/ext/node/polyfills/internal/crypto/random.ts
index 32256b13b..4890e158a 100644
--- a/ext/node/polyfills/internal/crypto/random.ts
+++ b/ext/node/polyfills/internal/crypto/random.ts
@@ -1,6 +1,8 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
// Copyright Joyent, Inc. and Node.js contributors. All rights reserved. MIT license.
+// deno-lint-ignore-file camelcase
+
import { notImplemented } from "ext:deno_node/_utils.ts";
import randomBytes from "ext:deno_node/internal/crypto/_randomBytes.ts";
import randomFill, {
@@ -31,6 +33,15 @@ export { default as randomInt } from "ext:deno_node/internal/crypto/_randomInt.t
const { core } = globalThis.__bootstrap;
const { ops } = core;
+const {
+ op_node_gen_prime_async,
+ op_node_check_prime_bytes_async,
+ op_node_check_prime_async,
+} = Deno.core.generateAsyncOpHandler(
+ "op_node_gen_prime_async",
+ "op_node_check_prime_bytes_async",
+ "op_node_check_prime_async",
+);
export type LargeNumberLike =
| ArrayBufferView
@@ -79,9 +90,9 @@ export function checkPrime(
validateInt32(checks, "options.checks", 0);
- let op = "op_node_check_prime_bytes_async";
+ let op = op_node_check_prime_bytes_async;
if (typeof candidate === "bigint") {
- op = "op_node_check_prime_async";
+ op = op_node_check_prime_async;
} else if (!isAnyArrayBuffer(candidate) && !isArrayBufferView(candidate)) {
throw new ERR_INVALID_ARG_TYPE(
"candidate",
@@ -96,7 +107,7 @@ export function checkPrime(
);
}
- core.opAsync2(op, candidate, checks).then(
+ op(candidate, checks).then(
(result) => {
callback?.(null, result);
},
@@ -160,7 +171,7 @@ export function generatePrime(
const {
bigint,
} = validateRandomPrimeJob(size, options);
- core.opAsync2("op_node_gen_prime_async", size).then((prime: Uint8Array) =>
+ op_node_gen_prime_async(size).then((prime: Uint8Array) =>
bigint ? arrayBufferToUnsignedBigInt(prime.buffer) : prime.buffer
).then((prime: ArrayBuffer | bigint) => {
callback?.(null, prime);