Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib: runtime deprecate calling Cipheriv(...) and Decipheriv(...) without new #57268

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

jasnell
Copy link
Member

@jasnell jasnell commented Mar 2, 2025

The first commit here is from #57266 which is expected to land first. This PR is about the second commit... deprecating calling Cipheriv(...) and Decipheriv(...) without the new keyword. Technically we should probably also deprecate creating these directly even with the new keyword since we tell people to use createCipheriv(...) and createDecipheriv(...) to create these (both of which simply defer to calling new ... but still).

I did do a github code search trying to find any examples of folks calling these directly without the new keyword and there were zero hits suggesting that going straight to a runtime deprecation is quite safe.

/cc @nodejs/tsc

jasnell added 2 commits March 1, 2025 16:41
Cipher was removed from the public API a while ago but we were still
defining it and exporting `require('crypto').Cipher` as `undefined`.
Silly us.
@jasnell jasnell added crypto Issues and PRs related to the crypto subsystem. semver-major PRs that contain breaking changes and should be released in the next major version. deprecations Issues and PRs related to deprecations. labels Mar 2, 2025
@jasnell jasnell requested review from mcollina and anonrig March 2, 2025 01:08
@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/crypto
  • @nodejs/web-infra

@nodejs-github-bot nodejs-github-bot added doc Issues and PRs related to the documentations. needs-ci PRs that need a full CI run. tools Issues and PRs related to the tools directory. labels Mar 2, 2025
Copy link

codecov bot commented Mar 2, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.24%. Comparing base (6b0af17) to head (1bb34d4).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #57268      +/-   ##
==========================================
- Coverage   90.24%   90.24%   -0.01%     
==========================================
  Files         630      630              
  Lines      184908   184883      -25     
  Branches    36181    36175       -6     
==========================================
- Hits       166874   166848      -26     
+ Misses      11061    11055       -6     
- Partials     6973     6980       +7     
Files with missing lines Coverage Δ
lib/crypto.js 92.74% <ø> (-0.08%) ⬇️
lib/internal/crypto/cipher.js 97.65% <100.00%> (+2.34%) ⬆️

... and 33 files with indirect coverage changes

Comment on lines +3843 to +3855
### DEP0190: Instantiating `node:crypto` `Cipheriv` and `Decipheriv` classes without `new`

<!-- YAML
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/57268
description: Runtime deprecation.
-->

Type: Runtime

Instantiating the [`Cipheriv`][] and [`Decipheriv`][] classes exported by the `node:crypto`
module is deprecated.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you do a first PR that doc-deprecates it, so that can be backported to existing release lines?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been unable to find any examples anywhere of anyone actually calling these (at least in any open source code). I'm not sure there's an actual value in backporting a doc-only deprecation to older lines.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It simplifies backporting of other deprecations, as it's otherwise likely we would get conflicts. I'm happy to open the doc-only PR myself if you prefer

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crypto Issues and PRs related to the crypto subsystem. deprecations Issues and PRs related to deprecations. doc Issues and PRs related to the documentations. needs-ci PRs that need a full CI run. semver-major PRs that contain breaking changes and should be released in the next major version. tools Issues and PRs related to the tools directory.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants