-
-
Notifications
You must be signed in to change notification settings - Fork 18
feat(crypto): add RSA-PSS codemod for DEP0154 #164
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
Open
nievasdev
wants to merge
39
commits into
nodejs:main
Choose a base branch
from
nievasdev:feat/crypto-rsa-pss-update
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 28 commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
4c3aefa
feat(crypto): add RSA-PSS codemod for DEP0154
nievasdev 90bb8ba
chore: update author from Claude Code to Mauro Nievas
nievasdev 2998555
chore: update package-lock.json to register crypto-rsa-pss-update wor…
nievasdev 3ba20fe
Merge remote-tracking branch 'upstream/main' into feat/crypto-rsa-pss…
nievasdev 1492821
feat(crypto): enhance RSA-PSS codemod to handle all import patterns
nievasdev c89dc4b
Merge remote-tracking branch 'upstream/main' into feat/crypto-rsa-pss…
nievasdev df65682
refactor(crypto): simplify namespace import handling using resolveBin…
nievasdev ab88911
fix(crypto): handle variable values in property transformations
nievasdev 4ee7879
Merge branch 'main' into feat/crypto-rsa-pss-update
nievasdev 50086cd
refactor(crypto): simplify getCryptoBindings using resolveBindingPath…
nievasdev 6c0a199
feat(crypto-rsa-pss): add template literal support and optimize test …
nievasdev c6b7d75
refactor(crypto-rsa-pss):
nievasdev 2993107
test(crypto-rsa-pss): consolidate import pattern tests
nievasdev 3fa7277
test(crypto-rsa-pss): remove redundant destructured-renamed test case
nievasdev 2e93c36
test(crypto-rsa-pss): add comprehensive edge case test coverage
nievasdev f101d13
docs(crypto-rsa-pss): update documentation and metadata
nievasdev 098c35b
feat(crypto-rsa-pss): support variable type detection for 'rsa-pss'
nievasdev 29a500d
feat(crypto-rsa-pss): add promisified wrapper support
nievasdev a7c6048
feat: improve promisify detection using resolveBindingPath
nievasdev 76bd8f7
fix: resolve yamllint errors in crypto-rsa-pss YAML files
nievasdev 05dcd05
Merge branch 'main' into feat/crypto-rsa-pss-update
nievasdev 77da176
feat(crypto-rsa-pss): add this.property support and refactor codebase
nievasdev ae2b431
refactor(crypto-rsa-pss): consolidate modular architecture into singl…
nievasdev 6831416
deps: bump @biomejs/biome from 2.1.2 to 2.1.3 (#163)
dependabot[bot] 73143b4
deps: bump @types/node from 24.1.0 to 24.2.0 (#160)
dependabot[bot] 3551f66
deps: bump @types/node from 24.2.0 to 24.2.1 (#170)
dependabot[bot] a39aa02
chore: remove `@next` and clean (#176)
AugustinMauroy 129294d
refactor(crypto-rsa-pss): remove type wrappers, consolidate tests, ad…
nievasdev ae8161b
fix: regenerate package-lock.json to resolve npm ci compatibility
nievasdev ba5b05e
fix(crypto-rsa-pss): resolve TypeScript type compatibility issues
nievasdev 9e6cdf5
fix: remove unnecessary type assertions and update test snapshot
nievasdev f101067
Merge branch 'main' into feat/crypto-rsa-pss-update
nievasdev 1e9e147
fix: resolve TypeScript type compatibility issues
nievasdev 366a99c
fix(deps): restore Darwin binaries in package-lock for macOS CI compa…
nievasdev 493b355
Merge branch 'main' into feat/crypto-rsa-pss-update
nievasdev 61904af
Merge branch 'main' into feat/crypto-rsa-pss-update
nievasdev 259d497
Merge branch 'main' into feat/crypto-rsa-pss-update
nievasdev 6ce24b4
Merge branch 'main' into feat/crypto-rsa-pss-update
nievasdev f1fe1ac
Merge branch 'main' into feat/crypto-rsa-pss-update
nievasdev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# crypto-rsa-pss-update | ||
|
||
Codemod to handle Node.js crypto deprecation DEP0154 by transforming deprecated RSA-PSS key generation options. | ||
|
||
## What it does | ||
|
||
This codemod transforms deprecated RSA-PSS crypto options in `crypto.generateKeyPair()` and `crypto.generateKeyPairSync()` calls: | ||
|
||
- `hash` → `hashAlgorithm` | ||
- `mgf1Hash` → `mgf1HashAlgorithm` | ||
|
||
The transformation only applies to calls with `'rsa-pss'` as the key type. | ||
|
||
## Examples | ||
|
||
**Before** | ||
|
||
```js | ||
const crypto = require("node:crypto"); | ||
|
||
crypto.generateKeyPair( | ||
"rsa-pss", | ||
{ | ||
modulusLength: 2048, | ||
hash: "sha256", | ||
mgf1Hash: "sha1", | ||
saltLength: 32, | ||
}, | ||
(err, publicKey, privateKey) => { | ||
// callback | ||
}, | ||
); | ||
|
||
crypto.generateKeyPairSync("rsa-pss", { | ||
modulusLength: 2048, | ||
hash: "sha256", | ||
}); | ||
``` | ||
|
||
**After** | ||
|
||
nievasdev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
```js | ||
const crypto = require("crypto"); | ||
nievasdev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
crypto.generateKeyPair( | ||
"rsa-pss", | ||
{ | ||
modulusLength: 2048, | ||
hashAlgorithm: "sha256", | ||
mgf1HashAlgorithm: "sha1", | ||
saltLength: 32, | ||
}, | ||
(err, publicKey, privateKey) => { | ||
// callback | ||
}, | ||
); | ||
|
||
crypto.generateKeyPairSync("rsa-pss", { | ||
modulusLength: 2048, | ||
hashAlgorithm: "sha256", | ||
}); | ||
``` | ||
|
||
## Usage | ||
|
||
```bash | ||
npx codemod @nodejs/crypto-rsa-pss-update | ||
``` | ||
|
||
## Supports | ||
|
||
- Both `crypto.generateKeyPair()` and `crypto.generateKeyPairSync()` | ||
- Destructured imports: `const { generateKeyPair } = require('crypto')` | ||
- Variable references: `const options = { hash: 'sha256' }` | ||
- Function calls: `getKeyOptions()` returning crypto options | ||
- This property patterns: `this.options = { hash: 'sha256' }` | ||
- Only transforms `'rsa-pss'` key type calls | ||
- Preserves all other options and call structure |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
schema_version: "1.0" | ||
name: "@nodejs/crypto-rsa-pss-update" | ||
version: 1.0.0 | ||
description: >- | ||
Handle DEP0154 via transforming deprecated RSA-PSS crypto options `hash` to | ||
`hashAlgorithm` and `mgf1Hash` to `mgf1HashAlgorithm` | ||
author: Mauro Nievas | ||
license: MIT | ||
workflow: workflow.yaml | ||
category: migration | ||
|
||
targets: | ||
languages: | ||
- javascript | ||
- typescript | ||
|
||
keywords: | ||
- transformation | ||
- migration | ||
- crypto | ||
- rsa-pss | ||
|
||
registry: | ||
access: public | ||
visibility: public |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"name": "@nodejs/crypto-rsa-pss-update", | ||
"version": "1.0.0", | ||
"description": "Handle DEP0154 via transforming deprecated RSA-PSS crypto options `hash` to `hashAlgorithm` and `mgf1Hash` to `mgf1HashAlgorithm`.", | ||
"type": "module", | ||
"scripts": { | ||
"test": "npx codemod jssg test -l typescript ./src/workflow.ts ./" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/nodejs/userland-migrations.git", | ||
"directory": "recipes/crypto-rsa-pss-update", | ||
"bugs": "https://github.com/nodejs/userland-migrations/issues" | ||
}, | ||
"author": "Mauro Nievas", | ||
"license": "MIT", | ||
"homepage": "https://github.com/nodejs/userland-migrations/blob/main/recipes/crypto-rsa-pss-update/README.md", | ||
"devDependencies": { | ||
"@codemod.com/jssg-types": "^1.0.3" | ||
}, | ||
"dependencies": { | ||
"@nodejs/codemod-utils": "*" | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.