crypto: downgrade DEP0115 to --pending-deprecation
only
Aliases are very cheap to maintain, so an unconditional runtime deprecation that affects existing ecosystem code is not a good idea. This commit turns the runtime deprecation into a `--pending-deprecation` one. Fixes: https://github.com/nodejs/node/issues/23013 PR-URL: https://github.com/nodejs/node/pull/23017 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
This commit is contained in:
parent
eccc65919a
commit
709b3b1e1c
@ -2167,16 +2167,19 @@ of Node.js core and will be removed in the future.
|
|||||||
<!-- YAML
|
<!-- YAML
|
||||||
changes:
|
changes:
|
||||||
- version: REPLACEME
|
- version: REPLACEME
|
||||||
pr-url: https://github.com/nodejs/node/pull/22519
|
pr-url:
|
||||||
description: Runtime deprecation.
|
- 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
|
In recent versions of Node.js, there is no difference between
|
||||||
[`crypto.randomBytes()`][] and `crypto.pseudoRandomBytes()`. The latter is
|
[`crypto.randomBytes()`][] and `crypto.pseudoRandomBytes()`. The latter is
|
||||||
deprecated along with the undocumented aliases `crypto.prng()` and
|
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.
|
future release.
|
||||||
|
|
||||||
<a id="DEP0116"></a>
|
<a id="DEP0116"></a>
|
||||||
|
@ -36,6 +36,7 @@ const {
|
|||||||
ERR_CRYPTO_FIPS_UNAVAILABLE
|
ERR_CRYPTO_FIPS_UNAVAILABLE
|
||||||
} = require('internal/errors').codes;
|
} = require('internal/errors').codes;
|
||||||
const constants = process.binding('constants').crypto;
|
const constants = process.binding('constants').crypto;
|
||||||
|
const { pendingDeprecation } = process.binding('config');
|
||||||
const {
|
const {
|
||||||
fipsMode,
|
fipsMode,
|
||||||
fipsForced
|
fipsForced
|
||||||
@ -243,19 +244,24 @@ Object.defineProperties(exports, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
// Aliases for randomBytes are deprecated.
|
// Aliases for randomBytes are deprecated.
|
||||||
// The ecosystem needs those to exist for backwards compatibility with
|
// The ecosystem needs those to exist for backwards compatibility.
|
||||||
// ancient Node.js runtimes (0.10, 0.12).
|
|
||||||
prng: {
|
prng: {
|
||||||
enumerable: false,
|
enumerable: false,
|
||||||
value: deprecate(randomBytes, 'crypto.prng is deprecated.', 'DEP0115')
|
value: pendingDeprecation ?
|
||||||
|
deprecate(randomBytes, 'crypto.prng is deprecated.', 'DEP0115') :
|
||||||
|
randomBytes
|
||||||
},
|
},
|
||||||
pseudoRandomBytes: {
|
pseudoRandomBytes: {
|
||||||
enumerable: false,
|
enumerable: false,
|
||||||
value: deprecate(randomBytes,
|
value: pendingDeprecation ?
|
||||||
'crypto.pseudoRandomBytes is deprecated.', 'DEP0115')
|
deprecate(randomBytes,
|
||||||
|
'crypto.pseudoRandomBytes is deprecated.', 'DEP0115') :
|
||||||
|
randomBytes
|
||||||
},
|
},
|
||||||
rng: {
|
rng: {
|
||||||
enumerable: false,
|
enumerable: false,
|
||||||
value: deprecate(randomBytes, 'crypto.rng is deprecated.', 'DEP0115')
|
value: pendingDeprecation ?
|
||||||
|
deprecate(randomBytes, 'crypto.rng is deprecated.', 'DEP0115') :
|
||||||
|
randomBytes
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
// Flags: --pending-deprecation
|
||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user