Skip to content

crypto: downgrade DEP0115 to --pending-deprecation only #23017

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions doc/api/deprecations.md
Original file line number Diff line number Diff line change
Expand Up @@ -2164,16 +2164,19 @@ of Node.js core and will be removed in the future.
<!-- YAML
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/22519
description: Runtime deprecation.
pr-url:
- https://github.com/nodejs/node/pull/22519
- https://github.com/nodejs/node/pull/23017
description: Added documentation-only deprecation
with `--pending-deprecation` support.
-->

Type: Runtime
Type: Documentation-only (supports [`--pending-deprecation`][])

In recent versions of Node.js, there is no difference between
[`crypto.randomBytes()`][] and `crypto.pseudoRandomBytes()`. The latter is
deprecated along with the undocumented aliases `crypto.prng()` and
`crypto.rng()` in favor of [`crypto.randomBytes()`][] and will be removed in a
`crypto.rng()` in favor of [`crypto.randomBytes()`][] and may be removed in a
future release.

<a id="DEP0116"></a>
Expand Down
18 changes: 12 additions & 6 deletions lib/crypto.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const {
ERR_CRYPTO_FIPS_UNAVAILABLE
} = require('internal/errors').codes;
const constants = process.binding('constants').crypto;
const { pendingDeprecation } = process.binding('config');
const {
fipsMode,
fipsForced
Expand Down Expand Up @@ -243,19 +244,24 @@ Object.defineProperties(exports, {
},

// Aliases for randomBytes are deprecated.
// The ecosystem needs those to exist for backwards compatibility with
// ancient Node.js runtimes (0.10, 0.12).
// The ecosystem needs those to exist for backwards compatibility.
prng: {
enumerable: false,
value: deprecate(randomBytes, 'crypto.prng is deprecated.', 'DEP0115')
value: pendingDeprecation ?
deprecate(randomBytes, 'crypto.prng is deprecated.', 'DEP0115') :
randomBytes
},
pseudoRandomBytes: {
enumerable: false,
value: deprecate(randomBytes,
'crypto.pseudoRandomBytes is deprecated.', 'DEP0115')
value: pendingDeprecation ?
deprecate(randomBytes,
'crypto.pseudoRandomBytes is deprecated.', 'DEP0115') :
randomBytes
},
rng: {
enumerable: false,
value: deprecate(randomBytes, 'crypto.rng is deprecated.', 'DEP0115')
value: pendingDeprecation ?
deprecate(randomBytes, 'crypto.rng is deprecated.', 'DEP0115') :
randomBytes
}
});
1 change: 1 addition & 0 deletions test/parallel/test-crypto-random.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.

// Flags: --pending-deprecation
'use strict';
const common = require('../common');

Expand Down