Skip to content

Commit 2129617

Browse files
crypto: runtime deprecate hmac constructor
1 parent 84de97a commit 2129617

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

doc/api/deprecations.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3595,12 +3595,15 @@ deprecated due to being internals, not intended for public use.
35953595

35963596
<!-- YAML
35973597
changes:
3598+
- version: REPLACEME
3599+
pr-url: https://github.com/nodejs/node/pull/52071
3600+
description: Runtime deprecation.
35983601
- version: REPLACEME
35993602
pr-url: https://github.com/nodejs/node/pull/51881
36003603
description: Documentation-only deprecation.
36013604
-->
36023605

3603-
Type: Documentation-only
3606+
Type: Runtime
36043607

36053608
Calling `Hmac` class directly with `Hmac()` or `new Hmac()` is
36063609
deprecated due to being internals, not intended for public use.

lib/crypto.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ module.exports = {
232232
DiffieHellmanGroup,
233233
ECDH,
234234
Hash: deprecate(Hash, 'crypto.Hash constructor is deprecated.', 'DEP0179'),
235-
Hmac,
235+
Hmac: deprecate(Hmac, 'crypto.Hmac constructor is deprecated.', 'DEP0181'),
236236
KeyObject,
237237
Sign,
238238
Verify,

test/parallel/test-crypto-hmac.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,3 +459,13 @@ assert.strictEqual(
459459
crypto.createHmac('sha256', keyObject).update('foo').digest(),
460460
);
461461
}
462+
463+
{
464+
crypto.Hmac('sha256', 'Node');
465+
common.expectWarning({
466+
DeprecationWarning: [
467+
['crypto.Hmac constructor is deprecated.',
468+
'DEP0181'],
469+
]
470+
});
471+
}

0 commit comments

Comments
 (0)