diff --git a/lib/crypto.js b/lib/crypto.js index f6c5b7313b69af..cce9bfea86f61a 100644 --- a/lib/crypto.js +++ b/lib/crypto.js @@ -247,12 +247,16 @@ Object.defineProperties(exports, { // The ecosystem needs those to exist for backwards compatibility. prng: { enumerable: false, + configurable: true, + writable: true, value: pendingDeprecation ? deprecate(randomBytes, 'crypto.prng is deprecated.', 'DEP0115') : randomBytes }, pseudoRandomBytes: { enumerable: false, + configurable: true, + writable: true, value: pendingDeprecation ? deprecate(randomBytes, 'crypto.pseudoRandomBytes is deprecated.', 'DEP0115') : @@ -260,6 +264,8 @@ Object.defineProperties(exports, { }, rng: { enumerable: false, + configurable: true, + writable: true, value: pendingDeprecation ? deprecate(randomBytes, 'crypto.rng is deprecated.', 'DEP0115') : randomBytes diff --git a/test/parallel/test-crypto-random.js b/test/parallel/test-crypto-random.js index df06134e4326f9..4c85545b4e40b1 100644 --- a/test/parallel/test-crypto-random.js +++ b/test/parallel/test-crypto-random.js @@ -306,3 +306,12 @@ assert.throws( } ); }); + + +['pseudoRandomBytes', 'prng', 'rng'].forEach((f) => { + const desc = Object.getOwnPropertyDescriptor(crypto, f); + assert.ok(desc); + assert.strictEqual(desc.configurable, true); + assert.strictEqual(desc.writable, true); + assert.strictEqual(desc.enumerable, false); +});