feat(DEP0203): migrate extractable `CryptoKey` arguments to `KeyObject`

Aperta
#555 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
node.js, typescript
Ambito
tooling

Direzione di ricerca

Start by reading the codemod implementations and tests in the repository that handle import resolution, aliases, and collision-free bindings; the issue does not name specific files. Then locate how migrations analyze call arguments and write tests for extractable keys used with the listed node:crypto APIs and { key: ... } overloads. Done means only safely established extractable keys are wrapped, while existing KeyObject and Web Crypto uses remain unchanged and uncertain cases are skipped with guidance.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

good first issue human help wanted

Description

Node.js 27.0.0-alpha.0.0.0 moves DEP0203 and DEP0204 to End-of-Life. Legacy node:crypto APIs reject CryptoKey arguments, and KeyObject.from() rejects non-extractable CryptoKey objects.

Add a conservative codemod that wraps a CryptoKey argument with KeyObject.from() when its identity and extractability can be established from the source code.

Cover affected key arguments in APIs such as createHmac(), createCipheriv(), createDecipheriv(), sign(), and verify(), including supported { key: ... } overloads. Resolve imports and aliases and add a collision-free KeyObject binding.

Additional Information

  • Start with local key creation/import patterns whose extractable argument is statically true and whose resulting binding is not reassigned or passed through unknown code.
  • Preserve the key position and any surrounding options, such as signature padding or encoding.
  • Leave existing KeyObject arguments and Web Crypto operations unchanged.
  • Skip non-extractable keys and keys with unknown extractability, and explain that they need manual migration.
  • Never change extractable: false to true automatically. Migrating operations to Web Crypto can require API and asynchronous control-flow changes and is outside the initial scope.

Examples

-import { createHmac, webcrypto } from 'node:crypto';
+import { createHmac, KeyObject, webcrypto } from 'node:crypto';

 const key = await webcrypto.subtle.importKey(
   'raw',
   new Uint8Array(32),
   { name: 'HMAC', hash: 'SHA-256' },
   true,
   ['sign'],
 );

-const digest = createHmac('sha256', key).update('hello').digest('hex');
+const digest = createHmac('sha256', KeyObject.from(key)).update('hello').digest('hex');

Refs

Lingua principale
TypeScript
Stelle
85
Fork
58
Merge medio
1g 21h
PR unite (30g)
8

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di nodejs/userland-migrations

Tutte le issue di nodejs/userland-migrations

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.