crypto: runtime deprecate Hash constructor

PR-URL: https://github.com/nodejs/node/pull/51880
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
This commit is contained in:
Marco Ippolito 2024-03-12 08:58:03 +01:00 committed by GitHub
parent 0b4cdb4b42
commit de0602d190
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 15 additions and 2 deletions

View File

@ -3563,12 +3563,15 @@ release lines. Please use [`dirent.parentPath`][] instead.
<!-- YAML
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/51880
description: Runtime deprecation.
- version: v21.5.0
pr-url: https://github.com/nodejs/node/pull/51077
description: Documentation-only deprecation.
-->
Type: Documentation-only
Type: Runtime
Calling `Hash` class directly with `Hash()` or `new Hash()` is
deprecated due to being internals, not intended for public use.

View File

@ -231,7 +231,7 @@ module.exports = {
DiffieHellman,
DiffieHellmanGroup,
ECDH,
Hash,
Hash: deprecate(Hash, 'crypto.Hash constructor is deprecated.', 'DEP0179'),
Hmac,
KeyObject,
Sign,

View File

@ -276,3 +276,13 @@ assert.throws(
assert.strictEqual(a.digest('hex'), b.digest('hex'));
assert.strictEqual(c.digest('hex'), d.digest('hex'));
}
{
crypto.Hash('sha256');
common.expectWarning({
DeprecationWarning: [
['crypto.Hash constructor is deprecated.',
'DEP0179'],
]
});
}