Skip to content

Commit d62ab3a

Browse files
crypto: runtime deprecate hmac constructor
PR-URL: #52071 Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io> Reviewed-By: Paolo Insogna <paolo@cowtech.it>
1 parent 8bc7459 commit d62ab3a

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

doc/api/deprecations.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -3598,12 +3598,15 @@ deprecated due to being internals, not intended for public use.
35983598

35993599
<!-- YAML
36003600
changes:
3601+
- version: REPLACEME
3602+
pr-url: https://github.com/nodejs/node/pull/52071
3603+
description: Runtime deprecation.
36013604
- version: REPLACEME
36023605
pr-url: https://github.com/nodejs/node/pull/51881
36033606
description: Documentation-only deprecation.
36043607
-->
36053608

3606-
Type: Documentation-only
3609+
Type: Runtime
36073610

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

lib/crypto.js

+1-1
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

+10
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)