Skip to content
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

crypto: runtime deprecate Hash constructor #51880

Merged
Merged
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
5 changes: 4 additions & 1 deletion doc/api/deprecations.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion lib/crypto.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ module.exports = {
DiffieHellman,
DiffieHellmanGroup,
ECDH,
Hash,
marco-ippolito marked this conversation as resolved.
Show resolved Hide resolved
Hash: deprecate(Hash, 'crypto.Hash constructor is deprecated.', 'DEP0179'),
Hmac,
KeyObject,
Sign,
Expand Down
10 changes: 10 additions & 0 deletions test/parallel/test-crypto-hash.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
]
});
}