diff --git a/lib/internal/crypto/keygen.js b/lib/internal/crypto/keygen.js index b6c3d966712cda..8f8fbfb1c0893d 100644 --- a/lib/internal/crypto/keygen.js +++ b/lib/internal/crypto/keygen.js @@ -38,7 +38,10 @@ const { kAesKeyLengths, } = require('internal/crypto/util'); -const { customPromisifyArgs } = require('internal/util'); +const { + customPromisifyArgs, + kEmptyObject, +} = require('internal/util'); const { validateFunction, @@ -119,7 +122,7 @@ function handleError(ret) { }; } -function parseKeyEncoding(keyType, options = {}) { +function parseKeyEncoding(keyType, options = kEmptyObject) { const { publicKeyEncoding, privateKeyEncoding } = options; let publicFormat, publicType; diff --git a/lib/internal/crypto/random.js b/lib/internal/crypto/random.js index 0a889cbebf6a7d..6705bcd2e7d592 100644 --- a/lib/internal/crypto/random.js +++ b/lib/internal/crypto/random.js @@ -26,6 +26,7 @@ const { } = internalBinding('crypto'); const { + kEmptyObject, lazyDOMException, } = require('internal/util'); @@ -399,7 +400,7 @@ function randomUUID(options) { validateObject(options, 'options'); const { disableEntropyCache = false, - } = options || {}; + } = options || kEmptyObject; validateBoolean(disableEntropyCache, 'options.disableEntropyCache'); @@ -464,7 +465,7 @@ function generatePrime(size, options, callback) { validateInt32(size, 'size', 1); if (typeof options === 'function') { callback = options; - options = {}; + options = kEmptyObject; } validateFunction(callback, 'callback'); @@ -482,7 +483,7 @@ function generatePrime(size, options, callback) { job.run(); } -function generatePrimeSync(size, options = {}) { +function generatePrimeSync(size, options = kEmptyObject) { validateInt32(size, 'size', 1); const job = createRandomPrimeJob(kCryptoJobSync, size, options); @@ -506,7 +507,7 @@ function unsignedBigIntToBuffer(bigint, name) { return Buffer.from(padded, 'hex'); } -function checkPrime(candidate, options = {}, callback) { +function checkPrime(candidate, options = kEmptyObject, callback) { if (typeof candidate === 'bigint') candidate = unsignedBigIntToBuffer(candidate, 'candidate'); if (!isAnyArrayBuffer(candidate) && !isArrayBufferView(candidate)) { @@ -524,7 +525,7 @@ function checkPrime(candidate, options = {}, callback) { } if (typeof options === 'function') { callback = options; - options = {}; + options = kEmptyObject; } validateFunction(callback, 'callback'); validateObject(options, 'options'); @@ -539,7 +540,7 @@ function checkPrime(candidate, options = {}, callback) { job.run(); } -function checkPrimeSync(candidate, options = {}) { +function checkPrimeSync(candidate, options = kEmptyObject) { if (typeof candidate === 'bigint') candidate = unsignedBigIntToBuffer(candidate, 'candidate'); if (!isAnyArrayBuffer(candidate) && !isArrayBufferView(candidate)) { diff --git a/lib/internal/crypto/x509.js b/lib/internal/crypto/x509.js index 386b41f3e4a42f..d08893d959f73a 100644 --- a/lib/internal/crypto/x509.js +++ b/lib/internal/crypto/x509.js @@ -23,6 +23,7 @@ const { const { customInspectSymbol: kInspect, + kEmptyObject, } = require('internal/util'); const { @@ -64,7 +65,7 @@ function isX509Certificate(value) { return value[kInternalState] !== undefined; } -function getFlags(options = {}) { +function getFlags(options = kEmptyObject) { validateObject(options, 'options'); const { subject = 'default', // Can be 'default', 'always', or 'never'