Commit bfd4900
Align Flow lib defs for Node.js crypto with v24
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: D899341451 parent 07d2255 commit bfd4900
1 file changed
Lines changed: 151 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
603 | 603 | | |
604 | 604 | | |
605 | 605 | | |
| 606 | + | |
606 | 607 | | |
607 | 608 | | |
608 | 609 | | |
| |||
661 | 662 | | |
662 | 663 | | |
663 | 664 | | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
664 | 742 | | |
665 | 743 | | |
666 | 744 | | |
| |||
820 | 898 | | |
821 | 899 | | |
822 | 900 | | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
823 | 974 | | |
824 | 975 | | |
825 | 976 | | |
| |||
0 commit comments