diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md index 2f3f420d0d36a4..dfb9648d364939 100644 --- a/doc/api/deprecations.md +++ b/doc/api/deprecations.md @@ -3595,12 +3595,15 @@ deprecated due to being internals, not intended for public use. -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. diff --git a/lib/crypto.js b/lib/crypto.js index c7cfdc841be2dc..a954a2736e7b82 100644 --- a/lib/crypto.js +++ b/lib/crypto.js @@ -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, diff --git a/test/parallel/test-crypto-hmac.js b/test/parallel/test-crypto-hmac.js index 0edea0dfb0fdcc..8128dea658bda5 100644 --- a/test/parallel/test-crypto-hmac.js +++ b/test/parallel/test-crypto-hmac.js @@ -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'], + ] + }); +}