Skip to content

Commit

Permalink
crypto: runtime deprecate hmac constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
marco-ippolito committed Mar 13, 2024
1 parent 84de97a commit cb97adb
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 @@ -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/99999999
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 cb97adb

Please sign in to comment.