Skip to content

Commit

Permalink
crypto: runtime deprecate hmac constructor
Browse files Browse the repository at this point in the history
PR-URL: #52071
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
  • Loading branch information
marco-ippolito committed Mar 20, 2024
1 parent 8bc7459 commit d62ab3a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
5 changes: 4 additions & 1 deletion doc/api/deprecations.md
Original file line number Diff line number Diff line change
Expand Up @@ -3598,12 +3598,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'],
]
});
}

0 comments on commit d62ab3a

Please sign in to comment.