crypto: runtime deprecate hmac constructor

PR-URL: https://github.com/nodejs/node/pull/52071
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
This commit is contained in:
Marco Ippolito 2024-03-20 17:20:05 +01:00 committed by GitHub
parent 8bc745944e
commit d62ab3a1ef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 15 additions and 2 deletions

View File

@ -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.

View File

@ -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,

View File

@ -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'],
]
});
}