Skip to content

Conversation

@robhogan
Copy link
Contributor

Summary:
This is an AI-assisted change to align the Flow definitions for the crypto module with the Node.js docs as at v24.

New v24 APIs:

  1. hash(algorithm, data, [outputEncoding]) - One-shot hashing convenience function

  2. X509Certificate new properties (added in v22.10.0):

New Classes:

  1. KeyObject - Represents cryptographic keys (symmetric/asymmetric)

  2. X509Certificate - X.509 certificate handling

  3. Certificate - Legacy SPKAC (Signed Public Key and Challenge) support

Key Management Functions:

  1. Key Creation:

  2. Key Generation:

  3. Primality Testing:

Other Improvements:

  1. Hash.copy() - Create deep copy of Hash object

  2. webcrypto property - References web Crypto type

Type Safety:

  • All options objects use modern Readonly<{...}> syntax for inputs
  • Exact-by-default types throughout
  • Proper overloading for functions with optional parameters

References:

Changelog: [Internal]

Generated by Confucius Code Assist (CCA)
Confucius Session, Trace

Reviewed By: vzaidman

Differential Revision: D89934145

Summary:
This is an AI-assisted change to align the Flow definitions for the `crypto` module with the Node.js docs as at v24.

**New v24 APIs:**

1. **`hash(algorithm, data, [outputEncoding])`** - One-shot hashing convenience function
   - Added in Node.js v21.7.0, v20.12.0
   - https://nodejs.org/api/crypto.html#cryptohashalgorithm-data-outputencoding

2. **X509Certificate new properties** (added in v22.10.0):
   - `validFromDate` - Certificate valid-from as Date object
   - `validToDate` - Certificate valid-to as Date object
   - https://nodejs.org/api/crypto.html#x509certificatevalidfromdate
   - https://nodejs.org/api/crypto.html#x509certificatevalidtodate

**New Classes:**

3. **KeyObject** - Represents cryptographic keys (symmetric/asymmetric)
   - Properties: `type`, `asymmetricKeyType`, `asymmetricKeySize`, `symmetricKeySize`
   - Methods: `export()`, `equals()`
   - https://nodejs.org/api/crypto.html#class-keyobject

4. **X509Certificate** - X.509 certificate handling
   - Properties: `ca`, `fingerprint*`, `issuer`, `subject`, `publicKey`, `raw`, etc.
   - Methods: `checkEmail()`, `checkHost()`, `checkIP()`, `verify()`, etc.
   - https://nodejs.org/api/crypto.html#class-x509certificate

5. **Certificate** - Legacy SPKAC (Signed Public Key and Challenge) support
   - Static methods: `exportChallenge()`, `exportPublicKey()`, `verifySpkac()`
   - https://nodejs.org/api/crypto.html#class-certificate

**Key Management Functions:**

6. **Key Creation:**
   - `createSecretKey(key, [encoding])` - Create symmetric KeyObject
   - `createPublicKey(key)` - Create public KeyObject
   - `createPrivateKey(key)` - Create private KeyObject
   - https://nodejs.org/api/crypto.html#cryptocreatesecretkeykey-encoding
   - https://nodejs.org/api/crypto.html#cryptocreatepublickeykey
   - https://nodejs.org/api/crypto.html#cryptocreateprivatekeykey

7. **Key Generation:**
   - `generateKeyPair()` / `generateKeyPairSync()` - Generate asymmetric key pairs
   - `generateKey()` / `generateKeySync()` - Generate symmetric keys
   - Supports: RSA, RSA-PSS, DSA, EC, Ed25519, Ed448, X25519, X448
   - https://nodejs.org/api/crypto.html#cryptogeneratekeypairtype-options-callback
   - https://nodejs.org/api/crypto.html#cryptogeneratekeytype-options-callback

8. **Primality Testing:**
   - `checkPrime()` / `checkPrimeSync()` - Test if candidate is prime
   - https://nodejs.org/api/crypto.html#cryptocheckprimecandidate-options-callback

**Other Improvements:**

9. **Hash.copy()** - Create deep copy of Hash object
   - https://nodejs.org/api/crypto.html#hashcopyoptions

10. **webcrypto property** - References web Crypto type
    - Web Crypto API types are NOT redefined (use existing definitions where available)
    - https://nodejs.org/api/webcrypto.html

**Type Safety:**
- All options objects use modern `Readonly<{...}>` syntax for inputs
- Exact-by-default types throughout
- Proper overloading for functions with optional parameters

**References:**
- Node.js crypto module docs: https://nodejs.org/api/crypto.html
- Node.js Web Crypto API: https://nodejs.org/api/webcrypto.html

Changelog: [Internal]
---
> Generated by [Confucius Code Assist (CCA)](https://www.internalfb.com/wiki/Confucius/Analect/Shared_Analects/Confucius_Code_Assist_(CCA)/)
[Confucius Session](https://www.internalfb.com/confucius?host=devvm45708.cln0.facebook.com&port=8086&tab=Chat&session_id=1a3aa26e-e5a9-11f0-8d47-71a4a90f0494&entry_name=Code+Assist), [Trace](https://www.internalfb.com/confucius?session_id=1a3aa26e-e5a9-11f0-8d47-71a4a90f0494&tab=Trace)

Reviewed By: vzaidman

Differential Revision: D89934145
@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Dec 31, 2025
@meta-codesync
Copy link

meta-codesync bot commented Dec 31, 2025

@robhogan has exported this pull request. If you are a Meta employee, you can view the originating Diff in D89934145.

meta-codesync bot pushed a commit to facebook/metro that referenced this pull request Jan 2, 2026
Summary:
X-link: facebook/react-native#55009

This is an AI-assisted change to align the Flow definitions for the `crypto` module with the Node.js docs as at v24.

**New v24 APIs:**

1. **`hash(algorithm, data, [outputEncoding])`** - One-shot hashing convenience function
   - Added in Node.js v21.7.0, v20.12.0
   - https://nodejs.org/api/crypto.html#cryptohashalgorithm-data-outputencoding

2. **X509Certificate new properties** (added in v22.10.0):
   - `validFromDate` - Certificate valid-from as Date object
   - `validToDate` - Certificate valid-to as Date object
   - https://nodejs.org/api/crypto.html#x509certificatevalidfromdate
   - https://nodejs.org/api/crypto.html#x509certificatevalidtodate

**New Classes:**

3. **KeyObject** - Represents cryptographic keys (symmetric/asymmetric)
   - Properties: `type`, `asymmetricKeyType`, `asymmetricKeySize`, `symmetricKeySize`
   - Methods: `export()`, `equals()`
   - https://nodejs.org/api/crypto.html#class-keyobject

4. **X509Certificate** - X.509 certificate handling
   - Properties: `ca`, `fingerprint*`, `issuer`, `subject`, `publicKey`, `raw`, etc.
   - Methods: `checkEmail()`, `checkHost()`, `checkIP()`, `verify()`, etc.
   - https://nodejs.org/api/crypto.html#class-x509certificate

5. **Certificate** - Legacy SPKAC (Signed Public Key and Challenge) support
   - Static methods: `exportChallenge()`, `exportPublicKey()`, `verifySpkac()`
   - https://nodejs.org/api/crypto.html#class-certificate

**Key Management Functions:**

6. **Key Creation:**
   - `createSecretKey(key, [encoding])` - Create symmetric KeyObject
   - `createPublicKey(key)` - Create public KeyObject
   - `createPrivateKey(key)` - Create private KeyObject
   - https://nodejs.org/api/crypto.html#cryptocreatesecretkeykey-encoding
   - https://nodejs.org/api/crypto.html#cryptocreatepublickeykey
   - https://nodejs.org/api/crypto.html#cryptocreateprivatekeykey

7. **Key Generation:**
   - `generateKeyPair()` / `generateKeyPairSync()` - Generate asymmetric key pairs
   - `generateKey()` / `generateKeySync()` - Generate symmetric keys
   - Supports: RSA, RSA-PSS, DSA, EC, Ed25519, Ed448, X25519, X448
   - https://nodejs.org/api/crypto.html#cryptogeneratekeypairtype-options-callback
   - https://nodejs.org/api/crypto.html#cryptogeneratekeytype-options-callback

8. **Primality Testing:**
   - `checkPrime()` / `checkPrimeSync()` - Test if candidate is prime
   - https://nodejs.org/api/crypto.html#cryptocheckprimecandidate-options-callback

**Other Improvements:**

9. **Hash.copy()** - Create deep copy of Hash object
   - https://nodejs.org/api/crypto.html#hashcopyoptions

10. **webcrypto property** - References web Crypto type
    - Web Crypto API types are NOT redefined (use existing definitions where available)
    - https://nodejs.org/api/webcrypto.html

**Type Safety:**
- All options objects use modern `Readonly<{...}>` syntax for inputs
- Exact-by-default types throughout
- Proper overloading for functions with optional parameters

**References:**
- Node.js crypto module docs: https://nodejs.org/api/crypto.html
- Node.js Web Crypto API: https://nodejs.org/api/webcrypto.html

Changelog: [Internal]
 ---
> Generated by [Confucius Code Assist (CCA)](https://www.internalfb.com/wiki/Confucius/Analect/Shared_Analects/Confucius_Code_Assist_(CCA)/)
[Confucius Session](https://www.internalfb.com/confucius?host=devvm45708.cln0.facebook.com&port=8086&tab=Chat&session_id=1a3aa26e-e5a9-11f0-8d47-71a4a90f0494&entry_name=Code+Assist), [Trace](https://www.internalfb.com/confucius?session_id=1a3aa26e-e5a9-11f0-8d47-71a4a90f0494&tab=Trace)

Reviewed By: vzaidman

Differential Revision: D89934145

fbshipit-source-id: 021fed306823469bad5be9e7bbab73da2477c42f
@meta-codesync meta-codesync bot closed this in 83b21bb Jan 2, 2026
@meta-codesync
Copy link

meta-codesync bot commented Jan 2, 2026

This pull request has been merged in 83b21bb.

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Jan 2, 2026
@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @robhogan in 83b21bb

When will my fix make it into a release? | How to file a pick request?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged This PR has been merged. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants