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 hmac constructor #52071

Merged
merged 1 commit into from
Mar 20, 2024
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 @@ -3595,12 +3595,15 @@ deprecated due to being internals, not intended for public use.

<!-- YAML
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/52071
description: Runtime deprecation.
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/51881
description: Documentation-only deprecation.
-->

Type: Documentation-only
Type: Runtime

Calling `Hmac` class directly with `Hmac()` or `new Hmac()` 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 @@ -232,7 +232,7 @@ module.exports = {
DiffieHellmanGroup,
ECDH,
Hash: deprecate(Hash, 'crypto.Hash constructor is deprecated.', 'DEP0179'),
Hmac,
Hmac: deprecate(Hmac, 'crypto.Hmac constructor is deprecated.', 'DEP0181'),
KeyObject,
Sign,
Verify,
Expand Down
10 changes: 10 additions & 0 deletions test/parallel/test-crypto-hmac.js
Original file line number Diff line number Diff line change
Expand Up @@ -459,3 +459,13 @@ assert.strictEqual(
crypto.createHmac('sha256', keyObject).update('foo').digest(),
);
}

{
crypto.Hmac('sha256', 'Node');
common.expectWarning({
DeprecationWarning: [
['crypto.Hmac constructor is deprecated.',
'DEP0181'],
]
});
}