@types/node 20.19.25 → 24.10.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. {node v20.19 → node v24.10}/README.md +3 -3
  2. node v24.10/assert/strict.d.ts +111 -0
  3. {node v20.19 → node v24.10}/assert.d.ts +150 -97
  4. {node v20.19 → node v24.10}/async_hooks.d.ts +27 -9
  5. {node v20.19 → node v24.10}/buffer.buffer.d.ts +2 -1
  6. {node v20.19 → node v24.10}/buffer.d.ts +6 -8
  7. {node v20.19 → node v24.10}/child_process.d.ts +11 -10
  8. {node v20.19 → node v24.10}/cluster.d.ts +16 -15
  9. {node v20.19 → node v24.10}/console.d.ts +19 -18
  10. {node v20.19 → node v24.10}/crypto.d.ts +1120 -293
  11. {node v20.19 → node v24.10}/dgram.d.ts +5 -2
  12. {node v20.19 → node v24.10}/diagnostics_channel.d.ts +1 -3
  13. {node v20.19 → node v24.10}/dns/promises.d.ts +30 -6
  14. {node v20.19 → node v24.10}/dns.d.ts +69 -17
  15. {node v20.19 → node v24.10}/domain.d.ts +1 -1
  16. {node v20.19 → node v24.10}/events.d.ts +1 -2
  17. {node v20.19 → node v24.10}/fs/promises.d.ts +85 -38
  18. {node v20.19 → node v24.10}/fs.d.ts +387 -48
  19. {node v20.19 → node v24.10}/globals.d.ts +2 -4
  20. {node v20.19 → node v24.10}/globals.typedarray.d.ts +3 -0
  21. {node v20.19 → node v24.10}/http.d.ts +90 -5
  22. {node v20.19 → node v24.10}/http2.d.ts +166 -41
  23. {node v20.19 → node v24.10}/https.d.ts +4 -3
  24. {node v20.19 → node v24.10}/index.d.ts +13 -5
  25. node v24.10/inspector.d.ts +277 -0
  26. {node v20.19 → node v24.10}/inspector.generated.d.ts +1096 -829
  27. {node v20.19 → node v24.10}/module.d.ts +403 -48
  28. {node v20.19 → node v24.10}/net.d.ts +62 -20
  29. {node v20.19 → node v24.10}/os.d.ts +8 -7
  30. {node v20.19 → node v24.10}/package.json +18 -3
  31. {node v20.19 → node v24.10}/path.d.ts +3 -3
  32. {node v20.19 → node v24.10}/perf_hooks.d.ts +37 -16
  33. {node v20.19 → node v24.10}/process.d.ts +138 -16
  34. {node v20.19 → node v24.10}/punycode.d.ts +1 -1
  35. {node v20.19 → node v24.10}/querystring.d.ts +1 -1
  36. {node v20.19 → node v24.10}/readline/promises.d.ts +0 -1
  37. {node v20.19 → node v24.10}/readline.d.ts +19 -14
  38. {node v20.19 → node v24.10}/repl.d.ts +25 -17
  39. {node v20.19 → node v24.10}/sea.d.ts +11 -2
  40. node v24.10/sqlite.d.ts +937 -0
  41. {node v20.19 → node v24.10}/stream/web.d.ts +85 -45
  42. {node v20.19 → node v24.10}/stream.d.ts +36 -28
  43. {node v20.19 → node v24.10}/string_decoder.d.ts +1 -1
  44. {node v20.19 → node v24.10}/test.d.ts +587 -35
  45. {node v20.19 → node v24.10}/timers/promises.d.ts +1 -1
  46. {node v20.19 → node v24.10}/timers.d.ts +4 -5
  47. {node v20.19 → node v24.10}/tls.d.ts +62 -48
  48. {node v20.19 → node v24.10}/trace_events.d.ts +6 -6
  49. node v24.10/ts5.6/compatibility/float16array.d.ts +71 -0
  50. {node v20.19 → node v24.10}/ts5.6/globals.typedarray.d.ts +2 -0
  51. {node v20.19 → node v24.10}/ts5.6/index.d.ts +15 -5
  52. node v24.10/ts5.7/compatibility/float16array.d.ts +72 -0
  53. node v24.10/ts5.7/index.d.ts +103 -0
  54. {node v20.19 → node v24.10}/tty.d.ts +1 -1
  55. {node v20.19 → node v24.10}/url.d.ts +128 -35
  56. {node v20.19 → node v24.10}/util.d.ts +384 -390
  57. {node v20.19 → node v24.10}/v8.d.ts +175 -32
  58. {node v20.19 → node v24.10}/vm.d.ts +246 -67
  59. {node v20.19 → node v24.10}/wasi.d.ts +23 -2
  60. node v24.10/web-globals/crypto.d.ts +32 -0
  61. {node v20.19 → node v24.10}/web-globals/fetch.d.ts +4 -0
  62. node v24.10/web-globals/navigator.d.ts +25 -0
  63. node v24.10/web-globals/storage.d.ts +24 -0
  64. node v24.10/web-globals/streams.d.ts +22 -0
  65. {node v20.19 → node v24.10}/worker_threads.d.ts +205 -24
  66. {node v20.19 → node v24.10}/zlib.d.ts +185 -44
  67. node v20.19/assert/strict.d.ts +0 -8
  68. node v20.19/compatibility/disposable.d.ts +0 -16
  69. node v20.19/compatibility/index.d.ts +0 -9
  70. node v20.19/compatibility/indexable.d.ts +0 -20
  71. {node v20.19 → node v24.10}/LICENSE +0 -0
  72. {node v20.19 → node v24.10}/compatibility/iterators.d.ts +0 -0
  73. {node v20.19 → node v24.10}/constants.d.ts +0 -0
  74. {node v20.19 → node v24.10}/stream/consumers.d.ts +0 -0
  75. {node v20.19 → node v24.10}/stream/promises.d.ts +0 -0
  76. {node v20.19 → node v24.10}/ts5.6/buffer.buffer.d.ts +0 -0
  77. {node v20.19 → node v24.10}/web-globals/abortcontroller.d.ts +0 -0
  78. {node v20.19 → node v24.10}/web-globals/domexception.d.ts +0 -0
  79. {node v20.19 → node v24.10}/web-globals/events.d.ts +0 -0
@@ -14,7 +14,7 @@
14
14
  * // Prints:
15
15
  * // c0fa1bc00531bd78ef38c628449c5102aeabd49b5dc3a2a516ea6ea959d6658e
16
16
  * ```
17
- * @see [source](https://github.com/nodejs/node/blob/v20.13.1/lib/crypto.js)
17
+ * @see [source](https://github.com/nodejs/node/blob/v24.x/lib/crypto.js)
18
18
  */
19
19
  declare module "crypto" {
20
20
  import { NonSharedBuffer } from "node:buffer";
@@ -97,7 +97,7 @@ declare module "crypto" {
97
97
  verifySpkac(spkac: NodeJS.ArrayBufferView): boolean;
98
98
  }
99
99
  namespace constants {
100
- // https://nodejs.org/dist/latest-v20.x/docs/api/crypto.html#crypto-constants
100
+ // https://nodejs.org/dist/latest-v24.x/docs/api/crypto.html#crypto-constants
101
101
  const OPENSSL_VERSION_NUMBER: number;
102
102
  /** Applies multiple bug workarounds within OpenSSL. See https://www.openssl.org/docs/man1.0.2/ssl/SSL_CTX_set_options.html for detail. */
103
103
  const SSL_OP_ALL: number;
@@ -592,18 +592,8 @@ declare module "crypto" {
592
592
  */
593
593
  static from(key: webcrypto.CryptoKey): KeyObject;
594
594
  /**
595
- * For asymmetric keys, this property represents the type of the key. Supported key
596
- * types are:
597
- *
598
- * * `'rsa'` (OID 1.2.840.113549.1.1.1)
599
- * * `'rsa-pss'` (OID 1.2.840.113549.1.1.10)
600
- * * `'dsa'` (OID 1.2.840.10040.4.1)
601
- * * `'ec'` (OID 1.2.840.10045.2.1)
602
- * * `'x25519'` (OID 1.3.101.110)
603
- * * `'x448'` (OID 1.3.101.111)
604
- * * `'ed25519'` (OID 1.3.101.112)
605
- * * `'ed448'` (OID 1.3.101.113)
606
- * * `'dh'` (OID 1.2.840.113549.1.3.1)
595
+ * For asymmetric keys, this property represents the type of the key. See the
596
+ * supported [asymmetric key types](https://nodejs.org/docs/latest-v24.x/api/crypto.html#asymmetric-key-types).
607
597
  *
608
598
  * This property is `undefined` for unrecognized `KeyObject` types and symmetric
609
599
  * keys.
@@ -663,6 +653,19 @@ declare module "crypto" {
663
653
  * @since v11.6.0
664
654
  */
665
655
  symmetricKeySize?: number;
656
+ /**
657
+ * Converts a `KeyObject` instance to a `CryptoKey`.
658
+ * @since 22.10.0
659
+ */
660
+ toCryptoKey(
661
+ algorithm:
662
+ | webcrypto.AlgorithmIdentifier
663
+ | webcrypto.RsaHashedImportParams
664
+ | webcrypto.EcKeyImportParams
665
+ | webcrypto.HmacImportParams,
666
+ extractable: boolean,
667
+ keyUsages: readonly webcrypto.KeyUsage[],
668
+ ): webcrypto.CryptoKey;
666
669
  /**
667
670
  * Depending on the type of this `KeyObject`, this property is either`'secret'` for secret (symmetric) keys, `'public'` for public (asymmetric) keys
668
671
  * or `'private'` for private (asymmetric) keys.
@@ -689,56 +692,6 @@ declare module "crypto" {
689
692
  /** @default 16 */
690
693
  authTagLength?: number | undefined;
691
694
  }
692
- /**
693
- * Creates and returns a `Cipher` object that uses the given `algorithm` and `password`.
694
- *
695
- * The `options` argument controls stream behavior and is optional except when a
696
- * cipher in CCM or OCB mode (e.g. `'aes-128-ccm'`) is used. In that case, the`authTagLength` option is required and specifies the length of the
697
- * authentication tag in bytes, see `CCM mode`. In GCM mode, the `authTagLength`option is not required but can be used to set the length of the authentication
698
- * tag that will be returned by `getAuthTag()` and defaults to 16 bytes.
699
- * For `chacha20-poly1305`, the `authTagLength` option defaults to 16 bytes.
700
- *
701
- * The `algorithm` is dependent on OpenSSL, examples are `'aes192'`, etc. On
702
- * recent OpenSSL releases, `openssl list -cipher-algorithms` will
703
- * display the available cipher algorithms.
704
- *
705
- * The `password` is used to derive the cipher key and initialization vector (IV).
706
- * The value must be either a `'latin1'` encoded string, a `Buffer`, a`TypedArray`, or a `DataView`.
707
- *
708
- * **This function is semantically insecure for all**
709
- * **supported ciphers and fatally flawed for ciphers in counter mode (such as CTR,**
710
- * **GCM, or CCM).**
711
- *
712
- * The implementation of `crypto.createCipher()` derives keys using the OpenSSL
713
- * function [`EVP_BytesToKey`](https://www.openssl.org/docs/man3.0/man3/EVP_BytesToKey.html) with the digest algorithm set to MD5, one
714
- * iteration, and no salt. The lack of salt allows dictionary attacks as the same
715
- * password always creates the same key. The low iteration count and
716
- * non-cryptographically secure hash algorithm allow passwords to be tested very
717
- * rapidly.
718
- *
719
- * In line with OpenSSL's recommendation to use a more modern algorithm instead of [`EVP_BytesToKey`](https://www.openssl.org/docs/man3.0/man3/EVP_BytesToKey.html) it is recommended that
720
- * developers derive a key and IV on
721
- * their own using {@link scrypt} and to use {@link createCipheriv} to create the `Cipher` object. Users should not use ciphers with counter mode
722
- * (e.g. CTR, GCM, or CCM) in `crypto.createCipher()`. A warning is emitted when
723
- * they are used in order to avoid the risk of IV reuse that causes
724
- * vulnerabilities. For the case when IV is reused in GCM, see [Nonce-Disrespecting Adversaries](https://github.com/nonce-disrespect/nonce-disrespect) for details.
725
- * @since v0.1.94
726
- * @deprecated Since v10.0.0 - Use {@link createCipheriv} instead.
727
- * @param options `stream.transform` options
728
- */
729
- function createCipher(algorithm: CipherCCMTypes, password: BinaryLike, options: CipherCCMOptions): CipherCCM;
730
- /** @deprecated since v10.0.0 use `createCipheriv()` */
731
- function createCipher(algorithm: CipherGCMTypes, password: BinaryLike, options?: CipherGCMOptions): CipherGCM;
732
- /** @deprecated since v10.0.0 use `createCipheriv()` */
733
- function createCipher(algorithm: CipherOCBTypes, password: BinaryLike, options: CipherOCBOptions): CipherOCB;
734
- /** @deprecated since v10.0.0 use `createCipheriv()` */
735
- function createCipher(
736
- algorithm: CipherChaCha20Poly1305Types,
737
- password: BinaryLike,
738
- options?: CipherChaCha20Poly1305Options,
739
- ): CipherChaCha20Poly1305;
740
- /** @deprecated since v10.0.0 use `createCipheriv()` */
741
- function createCipher(algorithm: string, password: BinaryLike, options?: stream.TransformOptions): Cipher;
742
695
  /**
743
696
  * Creates and returns a `Cipher` object, with the given `algorithm`, `key` and
744
697
  * initialization vector (`iv`).
@@ -798,9 +751,9 @@ declare module "crypto" {
798
751
  key: CipherKey,
799
752
  iv: BinaryLike | null,
800
753
  options?: stream.TransformOptions,
801
- ): Cipher;
754
+ ): Cipheriv;
802
755
  /**
803
- * Instances of the `Cipher` class are used to encrypt data. The class can be
756
+ * Instances of the `Cipheriv` class are used to encrypt data. The class can be
804
757
  * used in one of two ways:
805
758
  *
806
759
  * * As a `stream` that is both readable and writable, where plain unencrypted
@@ -808,11 +761,11 @@ declare module "crypto" {
808
761
  * * Using the `cipher.update()` and `cipher.final()` methods to produce
809
762
  * the encrypted data.
810
763
  *
811
- * The {@link createCipher} or {@link createCipheriv} methods are
812
- * used to create `Cipher` instances. `Cipher` objects are not to be created
764
+ * The {@link createCipheriv} method is
765
+ * used to create `Cipheriv` instances. `Cipheriv` objects are not to be created
813
766
  * directly using the `new` keyword.
814
767
  *
815
- * Example: Using `Cipher` objects as streams:
768
+ * Example: Using `Cipheriv` objects as streams:
816
769
  *
817
770
  * ```js
818
771
  * const {
@@ -847,7 +800,7 @@ declare module "crypto" {
847
800
  * });
848
801
  * ```
849
802
  *
850
- * Example: Using `Cipher` and piped streams:
803
+ * Example: Using `Cipheriv` and piped streams:
851
804
  *
852
805
  * ```js
853
806
  * import {
@@ -918,7 +871,7 @@ declare module "crypto" {
918
871
  * ```
919
872
  * @since v0.1.94
920
873
  */
921
- class Cipher extends stream.Transform {
874
+ class Cipheriv extends stream.Transform {
922
875
  private constructor();
923
876
  /**
924
877
  * Updates the cipher with `data`. If the `inputEncoding` argument is given,
@@ -939,7 +892,7 @@ declare module "crypto" {
939
892
  update(data: NodeJS.ArrayBufferView, inputEncoding: undefined, outputEncoding: Encoding): string;
940
893
  update(data: string, inputEncoding: Encoding | undefined, outputEncoding: Encoding): string;
941
894
  /**
942
- * Once the `cipher.final()` method has been called, the `Cipher` object can no
895
+ * Once the `cipher.final()` method has been called, the `Cipheriv` object can no
943
896
  * longer be used to encrypt data. Attempts to call `cipher.final()` more than
944
897
  * once will result in an error being thrown.
945
898
  * @since v0.1.94
@@ -949,7 +902,7 @@ declare module "crypto" {
949
902
  final(): NonSharedBuffer;
950
903
  final(outputEncoding: BufferEncoding): string;
951
904
  /**
952
- * When using block encryption algorithms, the `Cipher` class will automatically
905
+ * When using block encryption algorithms, the `Cipheriv` class will automatically
953
906
  * add padding to the input data to the appropriate block size. To disable the
954
907
  * default padding call `cipher.setAutoPadding(false)`.
955
908
  *
@@ -965,7 +918,7 @@ declare module "crypto" {
965
918
  */
966
919
  setAutoPadding(autoPadding?: boolean): this;
967
920
  }
968
- interface CipherCCM extends Cipher {
921
+ interface CipherCCM extends Cipheriv {
969
922
  setAAD(
970
923
  buffer: NodeJS.ArrayBufferView,
971
924
  options: {
@@ -974,7 +927,7 @@ declare module "crypto" {
974
927
  ): this;
975
928
  getAuthTag(): NonSharedBuffer;
976
929
  }
977
- interface CipherGCM extends Cipher {
930
+ interface CipherGCM extends Cipheriv {
978
931
  setAAD(
979
932
  buffer: NodeJS.ArrayBufferView,
980
933
  options?: {
@@ -983,7 +936,7 @@ declare module "crypto" {
983
936
  ): this;
984
937
  getAuthTag(): NonSharedBuffer;
985
938
  }
986
- interface CipherOCB extends Cipher {
939
+ interface CipherOCB extends Cipheriv {
987
940
  setAAD(
988
941
  buffer: NodeJS.ArrayBufferView,
989
942
  options?: {
@@ -992,7 +945,7 @@ declare module "crypto" {
992
945
  ): this;
993
946
  getAuthTag(): NonSharedBuffer;
994
947
  }
995
- interface CipherChaCha20Poly1305 extends Cipher {
948
+ interface CipherChaCha20Poly1305 extends Cipheriv {
996
949
  setAAD(
997
950
  buffer: NodeJS.ArrayBufferView,
998
951
  options: {
@@ -1002,46 +955,7 @@ declare module "crypto" {
1002
955
  getAuthTag(): NonSharedBuffer;
1003
956
  }
1004
957
  /**
1005
- * Creates and returns a `Decipher` object that uses the given `algorithm` and `password` (key).
1006
- *
1007
- * The `options` argument controls stream behavior and is optional except when a
1008
- * cipher in CCM or OCB mode (e.g. `'aes-128-ccm'`) is used. In that case, the `authTagLength` option is required and specifies the length of the
1009
- * authentication tag in bytes, see `CCM mode`.
1010
- * For `chacha20-poly1305`, the `authTagLength` option defaults to 16 bytes.
1011
- *
1012
- * **This function is semantically insecure for all**
1013
- * **supported ciphers and fatally flawed for ciphers in counter mode (such as CTR,**
1014
- * **GCM, or CCM).**
1015
- *
1016
- * The implementation of `crypto.createDecipher()` derives keys using the OpenSSL
1017
- * function [`EVP_BytesToKey`](https://www.openssl.org/docs/man3.0/man3/EVP_BytesToKey.html) with the digest algorithm set to MD5, one
1018
- * iteration, and no salt. The lack of salt allows dictionary attacks as the same
1019
- * password always creates the same key. The low iteration count and
1020
- * non-cryptographically secure hash algorithm allow passwords to be tested very
1021
- * rapidly.
1022
- *
1023
- * In line with OpenSSL's recommendation to use a more modern algorithm instead of [`EVP_BytesToKey`](https://www.openssl.org/docs/man3.0/man3/EVP_BytesToKey.html) it is recommended that
1024
- * developers derive a key and IV on
1025
- * their own using {@link scrypt} and to use {@link createDecipheriv} to create the `Decipher` object.
1026
- * @since v0.1.94
1027
- * @deprecated Since v10.0.0 - Use {@link createDecipheriv} instead.
1028
- * @param options `stream.transform` options
1029
- */
1030
- function createDecipher(algorithm: CipherCCMTypes, password: BinaryLike, options: CipherCCMOptions): DecipherCCM;
1031
- /** @deprecated since v10.0.0 use `createDecipheriv()` */
1032
- function createDecipher(algorithm: CipherGCMTypes, password: BinaryLike, options?: CipherGCMOptions): DecipherGCM;
1033
- /** @deprecated since v10.0.0 use `createDecipheriv()` */
1034
- function createDecipher(algorithm: CipherOCBTypes, password: BinaryLike, options: CipherOCBOptions): DecipherOCB;
1035
- /** @deprecated since v10.0.0 use `createDecipheriv()` */
1036
- function createDecipher(
1037
- algorithm: CipherChaCha20Poly1305Types,
1038
- password: BinaryLike,
1039
- options?: CipherChaCha20Poly1305Options,
1040
- ): DecipherChaCha20Poly1305;
1041
- /** @deprecated since v10.0.0 use `createDecipheriv()` */
1042
- function createDecipher(algorithm: string, password: BinaryLike, options?: stream.TransformOptions): Decipher;
1043
- /**
1044
- * Creates and returns a `Decipher` object that uses the given `algorithm`, `key` and initialization vector (`iv`).
958
+ * Creates and returns a `Decipheriv` object that uses the given `algorithm`, `key` and initialization vector (`iv`).
1045
959
  *
1046
960
  * The `options` argument controls stream behavior and is optional except when a
1047
961
  * cipher in CCM or OCB mode (e.g. `'aes-128-ccm'`) is used. In that case, the `authTagLength` option is required and specifies the length of the
@@ -1098,9 +1012,9 @@ declare module "crypto" {
1098
1012
  key: CipherKey,
1099
1013
  iv: BinaryLike | null,
1100
1014
  options?: stream.TransformOptions,
1101
- ): Decipher;
1015
+ ): Decipheriv;
1102
1016
  /**
1103
- * Instances of the `Decipher` class are used to decrypt data. The class can be
1017
+ * Instances of the `Decipheriv` class are used to decrypt data. The class can be
1104
1018
  * used in one of two ways:
1105
1019
  *
1106
1020
  * * As a `stream` that is both readable and writable, where plain encrypted
@@ -1108,11 +1022,11 @@ declare module "crypto" {
1108
1022
  * * Using the `decipher.update()` and `decipher.final()` methods to
1109
1023
  * produce the unencrypted data.
1110
1024
  *
1111
- * The {@link createDecipher} or {@link createDecipheriv} methods are
1112
- * used to create `Decipher` instances. `Decipher` objects are not to be created
1025
+ * The {@link createDecipheriv} method is
1026
+ * used to create `Decipheriv` instances. `Decipheriv` objects are not to be created
1113
1027
  * directly using the `new` keyword.
1114
1028
  *
1115
- * Example: Using `Decipher` objects as streams:
1029
+ * Example: Using `Decipheriv` objects as streams:
1116
1030
  *
1117
1031
  * ```js
1118
1032
  * import { Buffer } from 'node:buffer';
@@ -1151,7 +1065,7 @@ declare module "crypto" {
1151
1065
  * decipher.end();
1152
1066
  * ```
1153
1067
  *
1154
- * Example: Using `Decipher` and piped streams:
1068
+ * Example: Using `Decipheriv` and piped streams:
1155
1069
  *
1156
1070
  * ```js
1157
1071
  * import {
@@ -1207,7 +1121,7 @@ declare module "crypto" {
1207
1121
  * ```
1208
1122
  * @since v0.1.94
1209
1123
  */
1210
- class Decipher extends stream.Transform {
1124
+ class Decipheriv extends stream.Transform {
1211
1125
  private constructor();
1212
1126
  /**
1213
1127
  * Updates the decipher with `data`. If the `inputEncoding` argument is given,
@@ -1228,7 +1142,7 @@ declare module "crypto" {
1228
1142
  update(data: NodeJS.ArrayBufferView, inputEncoding: undefined, outputEncoding: Encoding): string;
1229
1143
  update(data: string, inputEncoding: Encoding | undefined, outputEncoding: Encoding): string;
1230
1144
  /**
1231
- * Once the `decipher.final()` method has been called, the `Decipher` object can
1145
+ * Once the `decipher.final()` method has been called, the `Decipheriv` object can
1232
1146
  * no longer be used to decrypt data. Attempts to call `decipher.final()` more
1233
1147
  * than once will result in an error being thrown.
1234
1148
  * @since v0.1.94
@@ -1251,7 +1165,7 @@ declare module "crypto" {
1251
1165
  */
1252
1166
  setAutoPadding(auto_padding?: boolean): this;
1253
1167
  }
1254
- interface DecipherCCM extends Decipher {
1168
+ interface DecipherCCM extends Decipheriv {
1255
1169
  setAuthTag(buffer: NodeJS.ArrayBufferView): this;
1256
1170
  setAAD(
1257
1171
  buffer: NodeJS.ArrayBufferView,
@@ -1260,7 +1174,7 @@ declare module "crypto" {
1260
1174
  },
1261
1175
  ): this;
1262
1176
  }
1263
- interface DecipherGCM extends Decipher {
1177
+ interface DecipherGCM extends Decipheriv {
1264
1178
  setAuthTag(buffer: NodeJS.ArrayBufferView): this;
1265
1179
  setAAD(
1266
1180
  buffer: NodeJS.ArrayBufferView,
@@ -1269,7 +1183,7 @@ declare module "crypto" {
1269
1183
  },
1270
1184
  ): this;
1271
1185
  }
1272
- interface DecipherOCB extends Decipher {
1186
+ interface DecipherOCB extends Decipheriv {
1273
1187
  setAuthTag(buffer: NodeJS.ArrayBufferView): this;
1274
1188
  setAAD(
1275
1189
  buffer: NodeJS.ArrayBufferView,
@@ -1278,7 +1192,7 @@ declare module "crypto" {
1278
1192
  },
1279
1193
  ): this;
1280
1194
  }
1281
- interface DecipherChaCha20Poly1305 extends Decipher {
1195
+ interface DecipherChaCha20Poly1305 extends Decipheriv {
1282
1196
  setAuthTag(buffer: NodeJS.ArrayBufferView): this;
1283
1197
  setAAD(
1284
1198
  buffer: NodeJS.ArrayBufferView,
@@ -1397,6 +1311,7 @@ declare module "crypto" {
1397
1311
  * @since v0.1.92
1398
1312
  * @param options `stream.Writable` options
1399
1313
  */
1314
+ // TODO: signing algorithm type
1400
1315
  function createSign(algorithm: string, options?: stream.WritableOptions): Sign;
1401
1316
  type DSAEncoding = "der" | "ieee-p1363";
1402
1317
  interface SigningOptions {
@@ -1406,6 +1321,7 @@ declare module "crypto" {
1406
1321
  padding?: number | undefined;
1407
1322
  saltLength?: number | undefined;
1408
1323
  dsaEncoding?: DSAEncoding | undefined;
1324
+ context?: ArrayBuffer | NodeJS.ArrayBufferView | undefined;
1409
1325
  }
1410
1326
  interface SignPrivateKeyInput extends PrivateKeyInput, SigningOptions {}
1411
1327
  interface SignKeyObjectInput extends SigningOptions {
@@ -2274,7 +2190,7 @@ declare module "crypto" {
2274
2190
  */
2275
2191
  function publicEncrypt(
2276
2192
  key: RsaPublicKey | RsaPrivateKey | KeyLike,
2277
- buffer: NodeJS.ArrayBufferView,
2193
+ buffer: NodeJS.ArrayBufferView | string,
2278
2194
  ): NonSharedBuffer;
2279
2195
  /**
2280
2196
  * Decrypts `buffer` with `key`.`buffer` was previously encrypted using
@@ -2289,7 +2205,7 @@ declare module "crypto" {
2289
2205
  */
2290
2206
  function publicDecrypt(
2291
2207
  key: RsaPublicKey | RsaPrivateKey | KeyLike,
2292
- buffer: NodeJS.ArrayBufferView,
2208
+ buffer: NodeJS.ArrayBufferView | string,
2293
2209
  ): NonSharedBuffer;
2294
2210
  /**
2295
2211
  * Decrypts `buffer` with `privateKey`. `buffer` was previously encrypted using
@@ -2299,7 +2215,10 @@ declare module "crypto" {
2299
2215
  * object, the `padding` property can be passed. Otherwise, this function uses `RSA_PKCS1_OAEP_PADDING`.
2300
2216
  * @since v0.11.14
2301
2217
  */
2302
- function privateDecrypt(privateKey: RsaPrivateKey | KeyLike, buffer: NodeJS.ArrayBufferView): NonSharedBuffer;
2218
+ function privateDecrypt(
2219
+ privateKey: RsaPrivateKey | KeyLike,
2220
+ buffer: NodeJS.ArrayBufferView | string,
2221
+ ): NonSharedBuffer;
2303
2222
  /**
2304
2223
  * Encrypts `buffer` with `privateKey`. The returned data can be decrypted using
2305
2224
  * the corresponding public key, for example using {@link publicDecrypt}.
@@ -2308,7 +2227,10 @@ declare module "crypto" {
2308
2227
  * object, the `padding` property can be passed. Otherwise, this function uses `RSA_PKCS1_PADDING`.
2309
2228
  * @since v1.1.0
2310
2229
  */
2311
- function privateEncrypt(privateKey: RsaPrivateKey | KeyLike, buffer: NodeJS.ArrayBufferView): NonSharedBuffer;
2230
+ function privateEncrypt(
2231
+ privateKey: RsaPrivateKey | KeyLike,
2232
+ buffer: NodeJS.ArrayBufferView | string,
2233
+ ): NonSharedBuffer;
2312
2234
  /**
2313
2235
  * ```js
2314
2236
  * const {
@@ -2546,7 +2468,34 @@ declare module "crypto" {
2546
2468
  * @since v6.6.0
2547
2469
  */
2548
2470
  function timingSafeEqual(a: NodeJS.ArrayBufferView, b: NodeJS.ArrayBufferView): boolean;
2549
- type KeyType = "rsa" | "rsa-pss" | "dsa" | "ec" | "ed25519" | "ed448" | "x25519" | "x448";
2471
+ type KeyType =
2472
+ | "dh"
2473
+ | "dsa"
2474
+ | "ec"
2475
+ | "ed25519"
2476
+ | "ed448"
2477
+ | "ml-dsa-44"
2478
+ | "ml-dsa-65"
2479
+ | "ml-dsa-87"
2480
+ | "ml-kem-1024"
2481
+ | "ml-kem-512"
2482
+ | "ml-kem-768"
2483
+ | "rsa-pss"
2484
+ | "rsa"
2485
+ | "slh-dsa-sha2-128f"
2486
+ | "slh-dsa-sha2-128s"
2487
+ | "slh-dsa-sha2-192f"
2488
+ | "slh-dsa-sha2-192s"
2489
+ | "slh-dsa-sha2-256f"
2490
+ | "slh-dsa-sha2-256s"
2491
+ | "slh-dsa-shake-128f"
2492
+ | "slh-dsa-shake-128s"
2493
+ | "slh-dsa-shake-192f"
2494
+ | "slh-dsa-shake-192s"
2495
+ | "slh-dsa-shake-256f"
2496
+ | "slh-dsa-shake-256s"
2497
+ | "x25519"
2498
+ | "x448";
2550
2499
  type KeyFormat = "pem" | "der" | "jwk";
2551
2500
  interface BasePrivateKeyEncodingOptions<T extends KeyFormat> {
2552
2501
  format: T;
@@ -2561,6 +2510,9 @@ declare module "crypto" {
2561
2510
  interface ED448KeyPairKeyObjectOptions {}
2562
2511
  interface X25519KeyPairKeyObjectOptions {}
2563
2512
  interface X448KeyPairKeyObjectOptions {}
2513
+ interface MLDSAKeyPairKeyObjectOptions {}
2514
+ interface MLKEMKeyPairKeyObjectOptions {}
2515
+ interface SLHDSAKeyPairKeyObjectOptions {}
2564
2516
  interface ECKeyPairKeyObjectOptions {
2565
2517
  /**
2566
2518
  * Name of the curve to use
@@ -2725,13 +2677,40 @@ declare module "crypto" {
2725
2677
  type: "pkcs8";
2726
2678
  };
2727
2679
  }
2680
+ interface MLDSAKeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
2681
+ publicKeyEncoding: {
2682
+ type: "spki";
2683
+ format: PubF;
2684
+ };
2685
+ privateKeyEncoding: BasePrivateKeyEncodingOptions<PrivF> & {
2686
+ type: "pkcs8";
2687
+ };
2688
+ }
2689
+ interface MLKEMKeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
2690
+ publicKeyEncoding: {
2691
+ type: "spki";
2692
+ format: PubF;
2693
+ };
2694
+ privateKeyEncoding: BasePrivateKeyEncodingOptions<PrivF> & {
2695
+ type: "pkcs8";
2696
+ };
2697
+ }
2698
+ interface SLHDSAKeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
2699
+ publicKeyEncoding: {
2700
+ type: "spki";
2701
+ format: PubF;
2702
+ };
2703
+ privateKeyEncoding: BasePrivateKeyEncodingOptions<PrivF> & {
2704
+ type: "pkcs8";
2705
+ };
2706
+ }
2728
2707
  interface KeyPairSyncResult<T1 extends string | Buffer, T2 extends string | Buffer> {
2729
2708
  publicKey: T1;
2730
2709
  privateKey: T2;
2731
2710
  }
2732
2711
  /**
2733
2712
  * Generates a new asymmetric key pair of the given `type`. RSA, RSA-PSS, DSA, EC,
2734
- * Ed25519, Ed448, X25519, X448, and DH are currently supported.
2713
+ * Ed25519, Ed448, X25519, X448, DH, and ML-DSA are currently supported.
2735
2714
  *
2736
2715
  * If a `publicKeyEncoding` or `privateKeyEncoding` was specified, this function
2737
2716
  * behaves as if `keyObject.export()` had been called on its result. Otherwise,
@@ -2768,7 +2747,8 @@ declare module "crypto" {
2768
2747
  * When PEM encoding was selected, the respective key will be a string, otherwise
2769
2748
  * it will be a buffer containing the data encoded as DER.
2770
2749
  * @since v10.12.0
2771
- * @param type Must be `'rsa'`, `'rsa-pss'`, `'dsa'`, `'ec'`, `'ed25519'`, `'ed448'`, `'x25519'`, `'x448'`, or `'dh'`.
2750
+ * @param type The asymmetric key type to generate. See the
2751
+ * supported [asymmetric key types](https://nodejs.org/docs/latest-v24.x/api/crypto.html#asymmetric-key-types).
2772
2752
  */
2773
2753
  function generateKeyPairSync(
2774
2754
  type: "rsa",
@@ -2906,6 +2886,126 @@ declare module "crypto" {
2906
2886
  options: X448KeyPairOptions<"der", "der">,
2907
2887
  ): KeyPairSyncResult<NonSharedBuffer, NonSharedBuffer>;
2908
2888
  function generateKeyPairSync(type: "x448", options?: X448KeyPairKeyObjectOptions): KeyPairKeyObjectResult;
2889
+ function generateKeyPairSync(
2890
+ type: "ml-dsa-44" | "ml-dsa-65" | "ml-dsa-87",
2891
+ options: MLDSAKeyPairOptions<"pem", "pem">,
2892
+ ): KeyPairSyncResult<string, string>;
2893
+ function generateKeyPairSync(
2894
+ type: "ml-dsa-44" | "ml-dsa-65" | "ml-dsa-87",
2895
+ options: MLDSAKeyPairOptions<"pem", "der">,
2896
+ ): KeyPairSyncResult<string, NonSharedBuffer>;
2897
+ function generateKeyPairSync(
2898
+ type: "ml-dsa-44" | "ml-dsa-65" | "ml-dsa-87",
2899
+ options: MLDSAKeyPairOptions<"der", "pem">,
2900
+ ): KeyPairSyncResult<NonSharedBuffer, string>;
2901
+ function generateKeyPairSync(
2902
+ type: "ml-dsa-44" | "ml-dsa-65" | "ml-dsa-87",
2903
+ options: MLDSAKeyPairOptions<"der", "der">,
2904
+ ): KeyPairSyncResult<NonSharedBuffer, NonSharedBuffer>;
2905
+ function generateKeyPairSync(
2906
+ type: "ml-dsa-44" | "ml-dsa-65" | "ml-dsa-87",
2907
+ options?: MLDSAKeyPairKeyObjectOptions,
2908
+ ): KeyPairKeyObjectResult;
2909
+ function generateKeyPairSync(
2910
+ type: "ml-kem-1024" | "ml-kem-512" | "ml-kem-768",
2911
+ options: MLKEMKeyPairOptions<"pem", "pem">,
2912
+ ): KeyPairSyncResult<string, string>;
2913
+ function generateKeyPairSync(
2914
+ type: "ml-kem-1024" | "ml-kem-512" | "ml-kem-768",
2915
+ options: MLKEMKeyPairOptions<"pem", "der">,
2916
+ ): KeyPairSyncResult<string, NonSharedBuffer>;
2917
+ function generateKeyPairSync(
2918
+ type: "ml-kem-1024" | "ml-kem-512" | "ml-kem-768",
2919
+ options: MLKEMKeyPairOptions<"der", "pem">,
2920
+ ): KeyPairSyncResult<NonSharedBuffer, string>;
2921
+ function generateKeyPairSync(
2922
+ type: "ml-kem-1024" | "ml-kem-512" | "ml-kem-768",
2923
+ options: MLKEMKeyPairOptions<"der", "der">,
2924
+ ): KeyPairSyncResult<NonSharedBuffer, NonSharedBuffer>;
2925
+ function generateKeyPairSync(
2926
+ type: "ml-kem-1024" | "ml-kem-512" | "ml-kem-768",
2927
+ options?: MLKEMKeyPairKeyObjectOptions,
2928
+ ): KeyPairKeyObjectResult;
2929
+ function generateKeyPairSync(
2930
+ type:
2931
+ | "slh-dsa-sha2-128f"
2932
+ | "slh-dsa-sha2-128s"
2933
+ | "slh-dsa-sha2-192f"
2934
+ | "slh-dsa-sha2-192s"
2935
+ | "slh-dsa-sha2-256f"
2936
+ | "slh-dsa-sha2-256s"
2937
+ | "slh-dsa-shake-128f"
2938
+ | "slh-dsa-shake-128s"
2939
+ | "slh-dsa-shake-192f"
2940
+ | "slh-dsa-shake-192s"
2941
+ | "slh-dsa-shake-256f"
2942
+ | "slh-dsa-shake-256s",
2943
+ options: SLHDSAKeyPairOptions<"pem", "pem">,
2944
+ ): KeyPairSyncResult<string, string>;
2945
+ function generateKeyPairSync(
2946
+ type:
2947
+ | "slh-dsa-sha2-128f"
2948
+ | "slh-dsa-sha2-128s"
2949
+ | "slh-dsa-sha2-192f"
2950
+ | "slh-dsa-sha2-192s"
2951
+ | "slh-dsa-sha2-256f"
2952
+ | "slh-dsa-sha2-256s"
2953
+ | "slh-dsa-shake-128f"
2954
+ | "slh-dsa-shake-128s"
2955
+ | "slh-dsa-shake-192f"
2956
+ | "slh-dsa-shake-192s"
2957
+ | "slh-dsa-shake-256f"
2958
+ | "slh-dsa-shake-256s",
2959
+ options: SLHDSAKeyPairOptions<"pem", "der">,
2960
+ ): KeyPairSyncResult<string, Buffer>;
2961
+ function generateKeyPairSync(
2962
+ type:
2963
+ | "slh-dsa-sha2-128f"
2964
+ | "slh-dsa-sha2-128s"
2965
+ | "slh-dsa-sha2-192f"
2966
+ | "slh-dsa-sha2-192s"
2967
+ | "slh-dsa-sha2-256f"
2968
+ | "slh-dsa-sha2-256s"
2969
+ | "slh-dsa-shake-128f"
2970
+ | "slh-dsa-shake-128s"
2971
+ | "slh-dsa-shake-192f"
2972
+ | "slh-dsa-shake-192s"
2973
+ | "slh-dsa-shake-256f"
2974
+ | "slh-dsa-shake-256s",
2975
+ options: SLHDSAKeyPairOptions<"der", "pem">,
2976
+ ): KeyPairSyncResult<Buffer, string>;
2977
+ function generateKeyPairSync(
2978
+ type:
2979
+ | "slh-dsa-sha2-128f"
2980
+ | "slh-dsa-sha2-128s"
2981
+ | "slh-dsa-sha2-192f"
2982
+ | "slh-dsa-sha2-192s"
2983
+ | "slh-dsa-sha2-256f"
2984
+ | "slh-dsa-sha2-256s"
2985
+ | "slh-dsa-shake-128f"
2986
+ | "slh-dsa-shake-128s"
2987
+ | "slh-dsa-shake-192f"
2988
+ | "slh-dsa-shake-192s"
2989
+ | "slh-dsa-shake-256f"
2990
+ | "slh-dsa-shake-256s",
2991
+ options: SLHDSAKeyPairOptions<"der", "der">,
2992
+ ): KeyPairSyncResult<Buffer, Buffer>;
2993
+ function generateKeyPairSync(
2994
+ type:
2995
+ | "slh-dsa-sha2-128f"
2996
+ | "slh-dsa-sha2-128s"
2997
+ | "slh-dsa-sha2-192f"
2998
+ | "slh-dsa-sha2-192s"
2999
+ | "slh-dsa-sha2-256f"
3000
+ | "slh-dsa-sha2-256s"
3001
+ | "slh-dsa-shake-128f"
3002
+ | "slh-dsa-shake-128s"
3003
+ | "slh-dsa-shake-192f"
3004
+ | "slh-dsa-shake-192s"
3005
+ | "slh-dsa-shake-256f"
3006
+ | "slh-dsa-shake-256s",
3007
+ options?: SLHDSAKeyPairKeyObjectOptions,
3008
+ ): KeyPairKeyObjectResult;
2909
3009
  /**
2910
3010
  * Generates a new asymmetric key pair of the given `type`. RSA, RSA-PSS, DSA, EC,
2911
3011
  * Ed25519, Ed448, X25519, X448, and DH are currently supported.
@@ -2943,7 +3043,8 @@ declare module "crypto" {
2943
3043
  * If this method is invoked as its `util.promisify()` ed version, it returns
2944
3044
  * a `Promise` for an `Object` with `publicKey` and `privateKey` properties.
2945
3045
  * @since v10.12.0
2946
- * @param type Must be `'rsa'`, `'rsa-pss'`, `'dsa'`, `'ec'`, `'ed25519'`, `'ed448'`, `'x25519'`, `'x448'`, or `'dh'`.
3046
+ * @param type The asymmetric key type to generate. See the
3047
+ * supported [asymmetric key types](https://nodejs.org/docs/latest-v24.x/api/crypto.html#asymmetric-key-types).
2947
3048
  */
2948
3049
  function generateKeyPair(
2949
3050
  type: "rsa",
@@ -3145,6 +3246,141 @@ declare module "crypto" {
3145
3246
  options: X448KeyPairKeyObjectOptions | undefined,
3146
3247
  callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void,
3147
3248
  ): void;
3249
+ function generateKeyPair(
3250
+ type: "ml-dsa-44" | "ml-dsa-65" | "ml-dsa-87",
3251
+ options: MLDSAKeyPairOptions<"pem", "pem">,
3252
+ callback: (err: Error | null, publicKey: string, privateKey: string) => void,
3253
+ ): void;
3254
+ function generateKeyPair(
3255
+ type: "ml-dsa-44" | "ml-dsa-65" | "ml-dsa-87",
3256
+ options: MLDSAKeyPairOptions<"pem", "der">,
3257
+ callback: (err: Error | null, publicKey: string, privateKey: NonSharedBuffer) => void,
3258
+ ): void;
3259
+ function generateKeyPair(
3260
+ type: "ml-dsa-44" | "ml-dsa-65" | "ml-dsa-87",
3261
+ options: MLDSAKeyPairOptions<"der", "pem">,
3262
+ callback: (err: Error | null, publicKey: NonSharedBuffer, privateKey: string) => void,
3263
+ ): void;
3264
+ function generateKeyPair(
3265
+ type: "ml-dsa-44" | "ml-dsa-65" | "ml-dsa-87",
3266
+ options: MLDSAKeyPairOptions<"der", "der">,
3267
+ callback: (err: Error | null, publicKey: NonSharedBuffer, privateKey: NonSharedBuffer) => void,
3268
+ ): void;
3269
+ function generateKeyPair(
3270
+ type: "ml-dsa-44" | "ml-dsa-65" | "ml-dsa-87",
3271
+ options: MLDSAKeyPairKeyObjectOptions | undefined,
3272
+ callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void,
3273
+ ): void;
3274
+ function generateKeyPair(
3275
+ type: "ml-kem-1024" | "ml-kem-512" | "ml-kem-768",
3276
+ options: MLKEMKeyPairOptions<"pem", "pem">,
3277
+ callback: (err: Error | null, publicKey: string, privateKey: string) => void,
3278
+ ): void;
3279
+ function generateKeyPair(
3280
+ type: "ml-kem-1024" | "ml-kem-512" | "ml-kem-768",
3281
+ options: MLKEMKeyPairOptions<"pem", "der">,
3282
+ callback: (err: Error | null, publicKey: string, privateKey: NonSharedBuffer) => void,
3283
+ ): void;
3284
+ function generateKeyPair(
3285
+ type: "ml-kem-1024" | "ml-kem-512" | "ml-kem-768",
3286
+ options: MLKEMKeyPairOptions<"der", "pem">,
3287
+ callback: (err: Error | null, publicKey: NonSharedBuffer, privateKey: string) => void,
3288
+ ): void;
3289
+ function generateKeyPair(
3290
+ type: "ml-kem-1024" | "ml-kem-512" | "ml-kem-768",
3291
+ options: MLKEMKeyPairOptions<"der", "der">,
3292
+ callback: (err: Error | null, publicKey: NonSharedBuffer, privateKey: NonSharedBuffer) => void,
3293
+ ): void;
3294
+ function generateKeyPair(
3295
+ type: "ml-kem-1024" | "ml-kem-512" | "ml-kem-768",
3296
+ options: MLKEMKeyPairKeyObjectOptions | undefined,
3297
+ callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void,
3298
+ ): void;
3299
+ function generateKeyPair(
3300
+ type:
3301
+ | "slh-dsa-sha2-128f"
3302
+ | "slh-dsa-sha2-128s"
3303
+ | "slh-dsa-sha2-192f"
3304
+ | "slh-dsa-sha2-192s"
3305
+ | "slh-dsa-sha2-256f"
3306
+ | "slh-dsa-sha2-256s"
3307
+ | "slh-dsa-shake-128f"
3308
+ | "slh-dsa-shake-128s"
3309
+ | "slh-dsa-shake-192f"
3310
+ | "slh-dsa-shake-192s"
3311
+ | "slh-dsa-shake-256f"
3312
+ | "slh-dsa-shake-256s",
3313
+ options: SLHDSAKeyPairOptions<"pem", "pem">,
3314
+ callback: (err: Error | null, publicKey: string, privateKey: string) => void,
3315
+ ): void;
3316
+ function generateKeyPair(
3317
+ type:
3318
+ | "slh-dsa-sha2-128f"
3319
+ | "slh-dsa-sha2-128s"
3320
+ | "slh-dsa-sha2-192f"
3321
+ | "slh-dsa-sha2-192s"
3322
+ | "slh-dsa-sha2-256f"
3323
+ | "slh-dsa-sha2-256s"
3324
+ | "slh-dsa-shake-128f"
3325
+ | "slh-dsa-shake-128s"
3326
+ | "slh-dsa-shake-192f"
3327
+ | "slh-dsa-shake-192s"
3328
+ | "slh-dsa-shake-256f"
3329
+ | "slh-dsa-shake-256s",
3330
+ options: SLHDSAKeyPairOptions<"pem", "der">,
3331
+ callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void,
3332
+ ): void;
3333
+ function generateKeyPair(
3334
+ type:
3335
+ | "slh-dsa-sha2-128f"
3336
+ | "slh-dsa-sha2-128s"
3337
+ | "slh-dsa-sha2-192f"
3338
+ | "slh-dsa-sha2-192s"
3339
+ | "slh-dsa-sha2-256f"
3340
+ | "slh-dsa-sha2-256s"
3341
+ | "slh-dsa-shake-128f"
3342
+ | "slh-dsa-shake-128s"
3343
+ | "slh-dsa-shake-192f"
3344
+ | "slh-dsa-shake-192s"
3345
+ | "slh-dsa-shake-256f"
3346
+ | "slh-dsa-shake-256s",
3347
+ options: SLHDSAKeyPairOptions<"der", "pem">,
3348
+ callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void,
3349
+ ): void;
3350
+ function generateKeyPair(
3351
+ type:
3352
+ | "slh-dsa-sha2-128f"
3353
+ | "slh-dsa-sha2-128s"
3354
+ | "slh-dsa-sha2-192f"
3355
+ | "slh-dsa-sha2-192s"
3356
+ | "slh-dsa-sha2-256f"
3357
+ | "slh-dsa-sha2-256s"
3358
+ | "slh-dsa-shake-128f"
3359
+ | "slh-dsa-shake-128s"
3360
+ | "slh-dsa-shake-192f"
3361
+ | "slh-dsa-shake-192s"
3362
+ | "slh-dsa-shake-256f"
3363
+ | "slh-dsa-shake-256s",
3364
+ options: SLHDSAKeyPairOptions<"der", "der">,
3365
+ callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void,
3366
+ ): void;
3367
+ function generateKeyPair(
3368
+ type:
3369
+ | "slh-dsa-sha2-128f"
3370
+ | "slh-dsa-sha2-128s"
3371
+ | "slh-dsa-sha2-192f"
3372
+ | "slh-dsa-sha2-192s"
3373
+ | "slh-dsa-sha2-256f"
3374
+ | "slh-dsa-sha2-256s"
3375
+ | "slh-dsa-shake-128f"
3376
+ | "slh-dsa-shake-128s"
3377
+ | "slh-dsa-shake-192f"
3378
+ | "slh-dsa-shake-192s"
3379
+ | "slh-dsa-shake-256f"
3380
+ | "slh-dsa-shake-256s",
3381
+ options: SLHDSAKeyPairKeyObjectOptions | undefined,
3382
+ callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void,
3383
+ ): void;
3148
3384
  namespace generateKeyPair {
3149
3385
  function __promisify__(
3150
3386
  type: "rsa",
@@ -3387,11 +3623,170 @@ declare module "crypto" {
3387
3623
  privateKey: NonSharedBuffer;
3388
3624
  }>;
3389
3625
  function __promisify__(type: "x448", options?: X448KeyPairKeyObjectOptions): Promise<KeyPairKeyObjectResult>;
3626
+ function __promisify__(
3627
+ type: "ml-dsa-44" | "ml-dsa-65" | "ml-dsa-87",
3628
+ options: MLDSAKeyPairOptions<"pem", "pem">,
3629
+ ): Promise<{
3630
+ publicKey: string;
3631
+ privateKey: string;
3632
+ }>;
3633
+ function __promisify__(
3634
+ type: "ml-dsa-44" | "ml-dsa-65" | "ml-dsa-87",
3635
+ options: MLDSAKeyPairOptions<"pem", "der">,
3636
+ ): Promise<{
3637
+ publicKey: string;
3638
+ privateKey: NonSharedBuffer;
3639
+ }>;
3640
+ function __promisify__(
3641
+ type: "ml-dsa-44" | "ml-dsa-65" | "ml-dsa-87",
3642
+ options: MLDSAKeyPairOptions<"der", "pem">,
3643
+ ): Promise<{
3644
+ publicKey: NonSharedBuffer;
3645
+ privateKey: string;
3646
+ }>;
3647
+ function __promisify__(
3648
+ type: "ml-dsa-44" | "ml-dsa-65" | "ml-dsa-87",
3649
+ options: MLDSAKeyPairOptions<"der", "der">,
3650
+ ): Promise<{
3651
+ publicKey: NonSharedBuffer;
3652
+ privateKey: NonSharedBuffer;
3653
+ }>;
3654
+ function __promisify__(
3655
+ type: "ml-dsa-44" | "ml-dsa-65" | "ml-dsa-87",
3656
+ options?: MLDSAKeyPairKeyObjectOptions,
3657
+ ): Promise<KeyPairKeyObjectResult>;
3658
+ function __promisify__(
3659
+ type: "ml-kem-1024" | "ml-kem-512" | "ml-kem-768",
3660
+ options: MLKEMKeyPairOptions<"pem", "pem">,
3661
+ ): Promise<{
3662
+ publicKey: string;
3663
+ privateKey: string;
3664
+ }>;
3665
+ function __promisify__(
3666
+ type: "ml-kem-1024" | "ml-kem-512" | "ml-kem-768",
3667
+ options: MLKEMKeyPairOptions<"pem", "der">,
3668
+ ): Promise<{
3669
+ publicKey: string;
3670
+ privateKey: NonSharedBuffer;
3671
+ }>;
3672
+ function __promisify__(
3673
+ type: "ml-kem-1024" | "ml-kem-512" | "ml-kem-768",
3674
+ options: MLKEMKeyPairOptions<"der", "pem">,
3675
+ ): Promise<{
3676
+ publicKey: NonSharedBuffer;
3677
+ privateKey: string;
3678
+ }>;
3679
+ function __promisify__(
3680
+ type: "ml-kem-1024" | "ml-kem-512" | "ml-kem-768",
3681
+ options: MLKEMKeyPairOptions<"der", "der">,
3682
+ ): Promise<{
3683
+ publicKey: NonSharedBuffer;
3684
+ privateKey: NonSharedBuffer;
3685
+ }>;
3686
+ function __promisify__(
3687
+ type: "ml-kem-1024" | "ml-kem-512" | "ml-kem-768",
3688
+ options?: MLKEMKeyPairKeyObjectOptions,
3689
+ ): Promise<KeyPairKeyObjectResult>;
3690
+ function __promisify__(
3691
+ type:
3692
+ | "slh-dsa-sha2-128f"
3693
+ | "slh-dsa-sha2-128s"
3694
+ | "slh-dsa-sha2-192f"
3695
+ | "slh-dsa-sha2-192s"
3696
+ | "slh-dsa-sha2-256f"
3697
+ | "slh-dsa-sha2-256s"
3698
+ | "slh-dsa-shake-128f"
3699
+ | "slh-dsa-shake-128s"
3700
+ | "slh-dsa-shake-192f"
3701
+ | "slh-dsa-shake-192s"
3702
+ | "slh-dsa-shake-256f"
3703
+ | "slh-dsa-shake-256s",
3704
+ options: SLHDSAKeyPairOptions<"pem", "pem">,
3705
+ ): Promise<{
3706
+ publicKey: string;
3707
+ privateKey: string;
3708
+ }>;
3709
+ function __promisify__(
3710
+ type:
3711
+ | "slh-dsa-sha2-128f"
3712
+ | "slh-dsa-sha2-128s"
3713
+ | "slh-dsa-sha2-192f"
3714
+ | "slh-dsa-sha2-192s"
3715
+ | "slh-dsa-sha2-256f"
3716
+ | "slh-dsa-sha2-256s"
3717
+ | "slh-dsa-shake-128f"
3718
+ | "slh-dsa-shake-128s"
3719
+ | "slh-dsa-shake-192f"
3720
+ | "slh-dsa-shake-192s"
3721
+ | "slh-dsa-shake-256f"
3722
+ | "slh-dsa-shake-256s",
3723
+ options: SLHDSAKeyPairOptions<"pem", "der">,
3724
+ ): Promise<{
3725
+ publicKey: string;
3726
+ privateKey: Buffer;
3727
+ }>;
3728
+ function __promisify__(
3729
+ type:
3730
+ | "slh-dsa-sha2-128f"
3731
+ | "slh-dsa-sha2-128s"
3732
+ | "slh-dsa-sha2-192f"
3733
+ | "slh-dsa-sha2-192s"
3734
+ | "slh-dsa-sha2-256f"
3735
+ | "slh-dsa-sha2-256s"
3736
+ | "slh-dsa-shake-128f"
3737
+ | "slh-dsa-shake-128s"
3738
+ | "slh-dsa-shake-192f"
3739
+ | "slh-dsa-shake-192s"
3740
+ | "slh-dsa-shake-256f"
3741
+ | "slh-dsa-shake-256s",
3742
+ options: SLHDSAKeyPairOptions<"der", "pem">,
3743
+ ): Promise<{
3744
+ publicKey: Buffer;
3745
+ privateKey: string;
3746
+ }>;
3747
+ function __promisify__(
3748
+ type:
3749
+ | "slh-dsa-sha2-128f"
3750
+ | "slh-dsa-sha2-128s"
3751
+ | "slh-dsa-sha2-192f"
3752
+ | "slh-dsa-sha2-192s"
3753
+ | "slh-dsa-sha2-256f"
3754
+ | "slh-dsa-sha2-256s"
3755
+ | "slh-dsa-shake-128f"
3756
+ | "slh-dsa-shake-128s"
3757
+ | "slh-dsa-shake-192f"
3758
+ | "slh-dsa-shake-192s"
3759
+ | "slh-dsa-shake-256f"
3760
+ | "slh-dsa-shake-256s",
3761
+ options: SLHDSAKeyPairOptions<"der", "der">,
3762
+ ): Promise<{
3763
+ publicKey: Buffer;
3764
+ privateKey: Buffer;
3765
+ }>;
3766
+ function __promisify__(
3767
+ type:
3768
+ | "slh-dsa-sha2-128f"
3769
+ | "slh-dsa-sha2-128s"
3770
+ | "slh-dsa-sha2-192f"
3771
+ | "slh-dsa-sha2-192s"
3772
+ | "slh-dsa-sha2-256f"
3773
+ | "slh-dsa-sha2-256s"
3774
+ | "slh-dsa-shake-128f"
3775
+ | "slh-dsa-shake-128s"
3776
+ | "slh-dsa-shake-192f"
3777
+ | "slh-dsa-shake-192s"
3778
+ | "slh-dsa-shake-256f"
3779
+ | "slh-dsa-shake-256s",
3780
+ options?: SLHDSAKeyPairKeyObjectOptions,
3781
+ ): Promise<KeyPairKeyObjectResult>;
3390
3782
  }
3391
3783
  /**
3392
3784
  * Calculates and returns the signature for `data` using the given private key and
3393
3785
  * algorithm. If `algorithm` is `null` or `undefined`, then the algorithm is
3394
- * dependent upon the key type (especially Ed25519 and Ed448).
3786
+ * dependent upon the key type.
3787
+ *
3788
+ * `algorithm` is required to be `null` or `undefined` for Ed25519, Ed448, and
3789
+ * ML-DSA.
3395
3790
  *
3396
3791
  * If `key` is not a `KeyObject`, this function behaves as if `key` had been
3397
3792
  * passed to {@link createPrivateKey}. If it is an object, the following
@@ -3412,8 +3807,12 @@ declare module "crypto" {
3412
3807
  callback: (error: Error | null, data: NonSharedBuffer) => void,
3413
3808
  ): void;
3414
3809
  /**
3415
- * Verifies the given signature for `data` using the given key and algorithm. If `algorithm` is `null` or `undefined`, then the algorithm is dependent upon the
3416
- * key type (especially Ed25519 and Ed448).
3810
+ * Verifies the given signature for `data` using the given key and algorithm. If
3811
+ * `algorithm` is `null` or `undefined`, then the algorithm is dependent upon the
3812
+ * key type.
3813
+ *
3814
+ * `algorithm` is required to be `null` or `undefined` for Ed25519, Ed448, and
3815
+ * ML-DSA.
3417
3816
  *
3418
3817
  * If `key` is not a `KeyObject`, this function behaves as if `key` had been
3419
3818
  * passed to {@link createPublicKey}. If it is an object, the following
@@ -3441,16 +3840,102 @@ declare module "crypto" {
3441
3840
  callback: (error: Error | null, result: boolean) => void,
3442
3841
  ): void;
3443
3842
  /**
3444
- * Computes the Diffie-Hellman secret based on a `privateKey` and a `publicKey`.
3445
- * Both keys must have the same `asymmetricKeyType`, which must be one of `'dh'` (for Diffie-Hellman), `'ec'` (for ECDH), `'x448'`, or `'x25519'` (for ECDH-ES).
3843
+ * Key decapsulation using a KEM algorithm with a private key.
3844
+ *
3845
+ * Supported key types and their KEM algorithms are:
3846
+ *
3847
+ * * `'rsa'` RSA Secret Value Encapsulation
3848
+ * * `'ec'` DHKEM(P-256, HKDF-SHA256), DHKEM(P-384, HKDF-SHA256), DHKEM(P-521, HKDF-SHA256)
3849
+ * * `'x25519'` DHKEM(X25519, HKDF-SHA256)
3850
+ * * `'x448'` DHKEM(X448, HKDF-SHA512)
3851
+ * * `'ml-kem-512'` ML-KEM
3852
+ * * `'ml-kem-768'` ML-KEM
3853
+ * * `'ml-kem-1024'` ML-KEM
3854
+ *
3855
+ * If `key` is not a {@link KeyObject}, this function behaves as if `key` had been
3856
+ * passed to `crypto.createPrivateKey()`.
3857
+ *
3858
+ * If the `callback` function is provided this function uses libuv's threadpool.
3859
+ * @since v24.7.0
3860
+ */
3861
+ function decapsulate(
3862
+ key: KeyLike | PrivateKeyInput | JsonWebKeyInput,
3863
+ ciphertext: ArrayBuffer | NodeJS.ArrayBufferView,
3864
+ ): NonSharedBuffer;
3865
+ function decapsulate(
3866
+ key: KeyLike | PrivateKeyInput | JsonWebKeyInput,
3867
+ ciphertext: ArrayBuffer | NodeJS.ArrayBufferView,
3868
+ callback: (err: Error, sharedKey: NonSharedBuffer) => void,
3869
+ ): void;
3870
+ /**
3871
+ * Computes the Diffie-Hellman shared secret based on a `privateKey` and a `publicKey`.
3872
+ * Both keys must have the same `asymmetricKeyType` and must support either the DH or
3873
+ * ECDH operation.
3874
+ *
3875
+ * If the `callback` function is provided this function uses libuv's threadpool.
3446
3876
  * @since v13.9.0, v12.17.0
3447
3877
  */
3448
3878
  function diffieHellman(options: { privateKey: KeyObject; publicKey: KeyObject }): NonSharedBuffer;
3879
+ function diffieHellman(
3880
+ options: { privateKey: KeyObject; publicKey: KeyObject },
3881
+ callback: (err: Error | null, secret: NonSharedBuffer) => void,
3882
+ ): void;
3883
+ /**
3884
+ * Key encapsulation using a KEM algorithm with a public key.
3885
+ *
3886
+ * Supported key types and their KEM algorithms are:
3887
+ *
3888
+ * * `'rsa'` RSA Secret Value Encapsulation
3889
+ * * `'ec'` DHKEM(P-256, HKDF-SHA256), DHKEM(P-384, HKDF-SHA256), DHKEM(P-521, HKDF-SHA256)
3890
+ * * `'x25519'` DHKEM(X25519, HKDF-SHA256)
3891
+ * * `'x448'` DHKEM(X448, HKDF-SHA512)
3892
+ * * `'ml-kem-512'` ML-KEM
3893
+ * * `'ml-kem-768'` ML-KEM
3894
+ * * `'ml-kem-1024'` ML-KEM
3895
+ *
3896
+ * If `key` is not a {@link KeyObject}, this function behaves as if `key` had been
3897
+ * passed to `crypto.createPublicKey()`.
3898
+ *
3899
+ * If the `callback` function is provided this function uses libuv's threadpool.
3900
+ * @since v24.7.0
3901
+ */
3902
+ function encapsulate(
3903
+ key: KeyLike | PublicKeyInput | JsonWebKeyInput,
3904
+ ): { sharedKey: NonSharedBuffer; ciphertext: NonSharedBuffer };
3905
+ function encapsulate(
3906
+ key: KeyLike | PublicKeyInput | JsonWebKeyInput,
3907
+ callback: (err: Error, result: { sharedKey: NonSharedBuffer; ciphertext: NonSharedBuffer }) => void,
3908
+ ): void;
3909
+ interface OneShotDigestOptions {
3910
+ /**
3911
+ * Encoding used to encode the returned digest.
3912
+ * @default 'hex'
3913
+ */
3914
+ outputEncoding?: BinaryToTextEncoding | "buffer" | undefined;
3915
+ /**
3916
+ * For XOF hash functions such as 'shake256', the outputLength option
3917
+ * can be used to specify the desired output length in bytes.
3918
+ */
3919
+ outputLength?: number | undefined;
3920
+ }
3921
+ interface OneShotDigestOptionsWithStringEncoding extends OneShotDigestOptions {
3922
+ outputEncoding?: BinaryToTextEncoding | undefined;
3923
+ }
3924
+ interface OneShotDigestOptionsWithBufferEncoding extends OneShotDigestOptions {
3925
+ outputEncoding: "buffer";
3926
+ }
3449
3927
  /**
3450
- * A utility for creating one-shot hash digests of data. It can be faster than the object-based `crypto.createHash()` when hashing a smaller amount of data
3451
- * (<= 5MB) that's readily available. If the data can be big or if it is streamed, it's still recommended to use `crypto.createHash()` instead. The `algorithm`
3452
- * is dependent on the available algorithms supported by the version of OpenSSL on the platform. Examples are `'sha256'`, `'sha512'`, etc. On recent releases
3453
- * of OpenSSL, `openssl list -digest-algorithms` will display the available digest algorithms.
3928
+ * A utility for creating one-shot hash digests of data. It can be faster than
3929
+ * the object-based `crypto.createHash()` when hashing a smaller amount of data
3930
+ * (<= 5MB) that's readily available. If the data can be big or if it is streamed,
3931
+ * it's still recommended to use `crypto.createHash()` instead.
3932
+ *
3933
+ * The `algorithm` is dependent on the available algorithms supported by the
3934
+ * version of OpenSSL on the platform. Examples are `'sha256'`, `'sha512'`, etc.
3935
+ * On recent releases of OpenSSL, `openssl list -digest-algorithms` will
3936
+ * display the available digest algorithms.
3937
+ *
3938
+ * If `options` is a string, then it specifies the `outputEncoding`.
3454
3939
  *
3455
3940
  * Example:
3456
3941
  *
@@ -3470,16 +3955,25 @@ declare module "crypto" {
3470
3955
  * console.log(crypto.hash('sha1', Buffer.from(base64, 'base64'), 'buffer'));
3471
3956
  * ```
3472
3957
  * @since v21.7.0, v20.12.0
3473
- * @param data When `data` is a string, it will be encoded as UTF-8 before being hashed. If a different input encoding is desired for a string input, user
3474
- * could encode the string into a `TypedArray` using either `TextEncoder` or `Buffer.from()` and passing the encoded `TypedArray` into this API instead.
3475
- * @param [outputEncoding='hex'] [Encoding](https://nodejs.org/docs/latest-v20.x/api/buffer.html#buffers-and-character-encodings) used to encode the returned digest.
3958
+ * @param data When `data` is a string, it will be encoded as UTF-8 before being hashed. If a different
3959
+ * input encoding is desired for a string input, user could encode the string
3960
+ * into a `TypedArray` using either `TextEncoder` or `Buffer.from()` and passing
3961
+ * the encoded `TypedArray` into this API instead.
3476
3962
  */
3477
- function hash(algorithm: string, data: BinaryLike, outputEncoding?: BinaryToTextEncoding): string;
3478
- function hash(algorithm: string, data: BinaryLike, outputEncoding: "buffer"): NonSharedBuffer;
3479
3963
  function hash(
3480
3964
  algorithm: string,
3481
3965
  data: BinaryLike,
3482
- outputEncoding?: BinaryToTextEncoding | "buffer",
3966
+ options?: OneShotDigestOptionsWithStringEncoding | BinaryToTextEncoding,
3967
+ ): string;
3968
+ function hash(
3969
+ algorithm: string,
3970
+ data: BinaryLike,
3971
+ options: OneShotDigestOptionsWithBufferEncoding | "buffer",
3972
+ ): NonSharedBuffer;
3973
+ function hash(
3974
+ algorithm: string,
3975
+ data: BinaryLike,
3976
+ options: OneShotDigestOptions | BinaryToTextEncoding | "buffer",
3483
3977
  ): string | NonSharedBuffer;
3484
3978
  type CipherMode = "cbc" | "ccm" | "cfb" | "ctr" | "ecb" | "gcm" | "ocb" | "ofb" | "stream" | "wrap" | "xts";
3485
3979
  interface CipherInfoOptions {
@@ -3782,16 +4276,36 @@ declare module "crypto" {
3782
4276
  * @since v15.6.0
3783
4277
  */
3784
4278
  readonly serialNumber: string;
4279
+ /**
4280
+ * The algorithm used to sign the certificate or `undefined` if the signature algorithm is unknown by OpenSSL.
4281
+ * @since v24.9.0
4282
+ */
4283
+ readonly signatureAlgorithm: string | undefined;
4284
+ /**
4285
+ * The OID of the algorithm used to sign the certificate.
4286
+ * @since v24.9.0
4287
+ */
4288
+ readonly signatureAlgorithmOid: string;
3785
4289
  /**
3786
4290
  * The date/time from which this certificate is considered valid.
3787
4291
  * @since v15.6.0
3788
4292
  */
3789
4293
  readonly validFrom: string;
4294
+ /**
4295
+ * The date/time from which this certificate is valid, encapsulated in a `Date` object.
4296
+ * @since v22.10.0
4297
+ */
4298
+ readonly validFromDate: Date;
3790
4299
  /**
3791
4300
  * The date/time until which this certificate is considered valid.
3792
4301
  * @since v15.6.0
3793
4302
  */
3794
4303
  readonly validTo: string;
4304
+ /**
4305
+ * The date/time until which this certificate is valid, encapsulated in a `Date` object.
4306
+ * @since v22.10.0
4307
+ */
4308
+ readonly validToDate: Date;
3795
4309
  constructor(buffer: BinaryLike);
3796
4310
  /**
3797
4311
  * Checks whether the certificate matches the given email address.
@@ -3844,7 +4358,23 @@ declare module "crypto" {
3844
4358
  */
3845
4359
  checkIP(ip: string): string | undefined;
3846
4360
  /**
3847
- * Checks whether this certificate was issued by the given `otherCert`.
4361
+ * Checks whether this certificate was potentially issued by the given `otherCert`
4362
+ * by comparing the certificate metadata.
4363
+ *
4364
+ * This is useful for pruning a list of possible issuer certificates which have been
4365
+ * selected using a more rudimentary filtering routine, i.e. just based on subject
4366
+ * and issuer names.
4367
+ *
4368
+ * Finally, to verify that this certificate's signature was produced by a private key
4369
+ * corresponding to `otherCert`'s public key use `x509.verify(publicKey)`
4370
+ * with `otherCert`'s public key represented as a `KeyObject`
4371
+ * like so
4372
+ *
4373
+ * ```js
4374
+ * if (!x509.verify(otherCert.publicKey)) {
4375
+ * throw new Error('otherCert did not issue x509');
4376
+ * }
4377
+ * ```
3848
4378
  * @since v15.6.0
3849
4379
  */
3850
4380
  checkIssued(otherCert: X509Certificate): boolean;
@@ -4028,6 +4558,130 @@ declare module "crypto" {
4028
4558
  * @return Returns `typedArray`.
4029
4559
  */
4030
4560
  function getRandomValues<T extends webcrypto.BufferSource>(typedArray: T): T;
4561
+ type Argon2Algorithm = "argon2d" | "argon2i" | "argon2id";
4562
+ interface Argon2Parameters {
4563
+ /**
4564
+ * REQUIRED, this is the password for password hashing applications of Argon2.
4565
+ */
4566
+ message: string | ArrayBuffer | NodeJS.ArrayBufferView;
4567
+ /**
4568
+ * REQUIRED, must be at least 8 bytes long. This is the salt for password hashing applications of Argon2.
4569
+ */
4570
+ nonce: string | ArrayBuffer | NodeJS.ArrayBufferView;
4571
+ /**
4572
+ * REQUIRED, degree of parallelism determines how many computational chains (lanes)
4573
+ * can be run. Must be greater than 1 and less than `2**24-1`.
4574
+ */
4575
+ parallelism: number;
4576
+ /**
4577
+ * REQUIRED, the length of the key to generate. Must be greater than 4 and
4578
+ * less than `2**32-1`.
4579
+ */
4580
+ tagLength: number;
4581
+ /**
4582
+ * REQUIRED, memory cost in 1KiB blocks. Must be greater than
4583
+ * `8 * parallelism` and less than `2**32-1`. The actual number of blocks is rounded
4584
+ * down to the nearest multiple of `4 * parallelism`.
4585
+ */
4586
+ memory: number;
4587
+ /**
4588
+ * REQUIRED, number of passes (iterations). Must be greater than 1 and less
4589
+ * than `2**32-1`.
4590
+ */
4591
+ passes: number;
4592
+ /**
4593
+ * OPTIONAL, Random additional input,
4594
+ * similar to the salt, that should **NOT** be stored with the derived key. This is known as pepper in
4595
+ * password hashing applications. If used, must have a length not greater than `2**32-1` bytes.
4596
+ */
4597
+ secret?: string | ArrayBuffer | NodeJS.ArrayBufferView | undefined;
4598
+ /**
4599
+ * OPTIONAL, Additional data to
4600
+ * be added to the hash, functionally equivalent to salt or secret, but meant for
4601
+ * non-random data. If used, must have a length not greater than `2**32-1` bytes.
4602
+ */
4603
+ associatedData?: string | ArrayBuffer | NodeJS.ArrayBufferView | undefined;
4604
+ }
4605
+ /**
4606
+ * Provides an asynchronous [Argon2](https://www.rfc-editor.org/rfc/rfc9106.html) implementation. Argon2 is a password-based
4607
+ * key derivation function that is designed to be expensive computationally and
4608
+ * memory-wise in order to make brute-force attacks unrewarding.
4609
+ *
4610
+ * The `nonce` should be as unique as possible. It is recommended that a nonce is
4611
+ * random and at least 16 bytes long. See [NIST SP 800-132](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf) for details.
4612
+ *
4613
+ * When passing strings for `message`, `nonce`, `secret` or `associatedData`, please
4614
+ * consider [caveats when using strings as inputs to cryptographic APIs](https://nodejs.org/docs/latest-v24.x/api/crypto.html#using-strings-as-inputs-to-cryptographic-apis).
4615
+ *
4616
+ * The `callback` function is called with two arguments: `err` and `derivedKey`.
4617
+ * `err` is an exception object when key derivation fails, otherwise `err` is
4618
+ * `null`. `derivedKey` is passed to the callback as a `Buffer`.
4619
+ *
4620
+ * An exception is thrown when any of the input arguments specify invalid values
4621
+ * or types.
4622
+ *
4623
+ * ```js
4624
+ * const { argon2, randomBytes } = await import('node:crypto');
4625
+ *
4626
+ * const parameters = {
4627
+ * message: 'password',
4628
+ * nonce: randomBytes(16),
4629
+ * parallelism: 4,
4630
+ * tagLength: 64,
4631
+ * memory: 65536,
4632
+ * passes: 3,
4633
+ * };
4634
+ *
4635
+ * argon2('argon2id', parameters, (err, derivedKey) => {
4636
+ * if (err) throw err;
4637
+ * console.log(derivedKey.toString('hex')); // 'af91dad...9520f15'
4638
+ * });
4639
+ * ```
4640
+ * @since v24.7.0
4641
+ * @param algorithm Variant of Argon2, one of `"argon2d"`, `"argon2i"` or `"argon2id"`.
4642
+ * @experimental
4643
+ */
4644
+ function argon2(
4645
+ algorithm: Argon2Algorithm,
4646
+ parameters: Argon2Parameters,
4647
+ callback: (err: Error | null, derivedKey: NonSharedBuffer) => void,
4648
+ ): void;
4649
+ /**
4650
+ * Provides a synchronous [Argon2][] implementation. Argon2 is a password-based
4651
+ * key derivation function that is designed to be expensive computationally and
4652
+ * memory-wise in order to make brute-force attacks unrewarding.
4653
+ *
4654
+ * The `nonce` should be as unique as possible. It is recommended that a nonce is
4655
+ * random and at least 16 bytes long. See [NIST SP 800-132](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf) for details.
4656
+ *
4657
+ * When passing strings for `message`, `nonce`, `secret` or `associatedData`, please
4658
+ * consider [caveats when using strings as inputs to cryptographic APIs](https://nodejs.org/docs/latest-v24.x/api/crypto.html#using-strings-as-inputs-to-cryptographic-apis).
4659
+ *
4660
+ * An exception is thrown when key derivation fails, otherwise the derived key is
4661
+ * returned as a `Buffer`.
4662
+ *
4663
+ * An exception is thrown when any of the input arguments specify invalid values
4664
+ * or types.
4665
+ *
4666
+ * ```js
4667
+ * const { argon2Sync, randomBytes } = await import('node:crypto');
4668
+ *
4669
+ * const parameters = {
4670
+ * message: 'password',
4671
+ * nonce: randomBytes(16),
4672
+ * parallelism: 4,
4673
+ * tagLength: 64,
4674
+ * memory: 65536,
4675
+ * passes: 3,
4676
+ * };
4677
+ *
4678
+ * const derivedKey = argon2Sync('argon2id', parameters);
4679
+ * console.log(derivedKey.toString('hex')); // 'af91dad...9520f15'
4680
+ * ```
4681
+ * @since v24.7.0
4682
+ * @experimental
4683
+ */
4684
+ function argon2Sync(algorithm: Argon2Algorithm, parameters: Argon2Parameters): NonSharedBuffer;
4031
4685
  /**
4032
4686
  * A convenient alias for `crypto.webcrypto.subtle`.
4033
4687
  * @since v17.4.0
@@ -4042,21 +4696,30 @@ declare module "crypto" {
4042
4696
  const webcrypto: webcrypto.Crypto;
4043
4697
  namespace webcrypto {
4044
4698
  type BufferSource = ArrayBufferView | ArrayBuffer;
4045
- type KeyFormat = "jwk" | "pkcs8" | "raw" | "spki";
4699
+ type KeyFormat = "jwk" | "pkcs8" | "raw" | "raw-public" | "raw-secret" | "raw-seed" | "spki";
4046
4700
  type KeyType = "private" | "public" | "secret";
4047
4701
  type KeyUsage =
4048
- | "decrypt"
4049
- | "deriveBits"
4050
- | "deriveKey"
4051
4702
  | "encrypt"
4703
+ | "decrypt"
4052
4704
  | "sign"
4053
- | "unwrapKey"
4054
4705
  | "verify"
4055
- | "wrapKey";
4706
+ | "deriveKey"
4707
+ | "deriveBits"
4708
+ | "encapsulateBits"
4709
+ | "decapsulateBits"
4710
+ | "encapsulateKey"
4711
+ | "decapsulateKey"
4712
+ | "wrapKey"
4713
+ | "unwrapKey";
4056
4714
  type AlgorithmIdentifier = Algorithm | string;
4057
4715
  type HashAlgorithmIdentifier = AlgorithmIdentifier;
4058
4716
  type NamedCurve = string;
4059
4717
  type BigInteger = Uint8Array;
4718
+ interface AeadParams extends Algorithm {
4719
+ additionalData?: BufferSource;
4720
+ iv: BufferSource;
4721
+ tagLength: number;
4722
+ }
4060
4723
  interface AesCbcParams extends Algorithm {
4061
4724
  iv: BufferSource;
4062
4725
  }
@@ -4067,6 +4730,8 @@ declare module "crypto" {
4067
4730
  interface AesDerivedKeyParams extends Algorithm {
4068
4731
  length: number;
4069
4732
  }
4733
+ // TODO: remove in next major
4734
+ /** @deprecated Replaced by `AeadParams`. */
4070
4735
  interface AesGcmParams extends Algorithm {
4071
4736
  additionalData?: BufferSource;
4072
4737
  iv: BufferSource;
@@ -4081,6 +4746,23 @@ declare module "crypto" {
4081
4746
  interface Algorithm {
4082
4747
  name: string;
4083
4748
  }
4749
+ interface Argon2Params extends Algorithm {
4750
+ associatedData?: BufferSource;
4751
+ memory: number;
4752
+ nonce: BufferSource;
4753
+ parallelism: number;
4754
+ passes: number;
4755
+ secretValue?: BufferSource;
4756
+ version?: number;
4757
+ }
4758
+ interface CShakeParams extends Algorithm {
4759
+ customization?: BufferSource;
4760
+ functionName?: BufferSource;
4761
+ length: number;
4762
+ }
4763
+ interface ContextParams extends Algorithm {
4764
+ context?: BufferSource;
4765
+ }
4084
4766
  interface EcKeyAlgorithm extends KeyAlgorithm {
4085
4767
  namedCurve: NamedCurve;
4086
4768
  }
@@ -4096,9 +4778,6 @@ declare module "crypto" {
4096
4778
  interface EcdsaParams extends Algorithm {
4097
4779
  hash: HashAlgorithmIdentifier;
4098
4780
  }
4099
- interface Ed448Params extends Algorithm {
4100
- context?: BufferSource;
4101
- }
4102
4781
  interface HkdfParams extends Algorithm {
4103
4782
  hash: HashAlgorithmIdentifier;
4104
4783
  info: BufferSource;
@@ -4139,6 +4818,19 @@ declare module "crypto" {
4139
4818
  interface KeyAlgorithm {
4140
4819
  name: string;
4141
4820
  }
4821
+ interface KmacImportParams extends Algorithm {
4822
+ length?: number;
4823
+ }
4824
+ interface KmacKeyAlgorithm extends KeyAlgorithm {
4825
+ length: number;
4826
+ }
4827
+ interface KmacKeyGenParams extends Algorithm {
4828
+ length?: number;
4829
+ }
4830
+ interface KmacParams extends Algorithm {
4831
+ customization?: BufferSource;
4832
+ length: number;
4833
+ }
4142
4834
  interface Pbkdf2Params extends Algorithm {
4143
4835
  hash: HashAlgorithmIdentifier;
4144
4836
  iterations: number;
@@ -4192,22 +4884,15 @@ declare module "crypto" {
4192
4884
  * An error will be thrown if the given `typedArray` is larger than 65,536 bytes.
4193
4885
  * @since v15.0.0
4194
4886
  */
4195
- getRandomValues<T extends Exclude<NodeJS.TypedArray, Float32Array | Float64Array>>(typedArray: T): T;
4887
+ getRandomValues<T extends Exclude<NodeJS.TypedArray, Float16Array | Float32Array | Float64Array>>(
4888
+ typedArray: T,
4889
+ ): T;
4196
4890
  /**
4197
4891
  * Generates a random {@link https://www.rfc-editor.org/rfc/rfc4122.txt RFC 4122} version 4 UUID.
4198
4892
  * The UUID is generated using a cryptographic pseudorandom number generator.
4199
4893
  * @since v16.7.0
4200
4894
  */
4201
4895
  randomUUID(): UUID;
4202
- CryptoKey: CryptoKeyConstructor;
4203
- }
4204
- // This constructor throws ILLEGAL_CONSTRUCTOR so it should not be newable.
4205
- interface CryptoKeyConstructor {
4206
- /** Illegal constructor */
4207
- (_: { readonly _: unique symbol }): never; // Allows instanceof to work but not be callable by the user.
4208
- readonly length: 0;
4209
- readonly name: "CryptoKey";
4210
- readonly prototype: CryptoKey;
4211
4896
  }
4212
4897
  /**
4213
4898
  * @since v15.0.0
@@ -4262,31 +4947,81 @@ declare module "crypto" {
4262
4947
  */
4263
4948
  publicKey: CryptoKey;
4264
4949
  }
4950
+ interface EncapsulatedBits {
4951
+ sharedKey: ArrayBuffer;
4952
+ ciphertext: ArrayBuffer;
4953
+ }
4954
+ interface EncapsulatedKey {
4955
+ sharedKey: CryptoKey;
4956
+ ciphertext: ArrayBuffer;
4957
+ }
4265
4958
  /**
4266
4959
  * @since v15.0.0
4267
4960
  */
4268
4961
  interface SubtleCrypto {
4962
+ /**
4963
+ * A message recipient uses their asymmetric private key to decrypt an
4964
+ * "encapsulated key" (ciphertext), thereby recovering a temporary symmetric
4965
+ * key (represented as `ArrayBuffer`) which is then used to decrypt a message.
4966
+ *
4967
+ * The algorithms currently supported include:
4968
+ *
4969
+ * * `'ML-KEM-512'`
4970
+ * * `'ML-KEM-768'`
4971
+ * * `'ML-KEM-1024'`
4972
+ * @since v24.7.0
4973
+ * @returns Fulfills with `ArrayBuffer` upon success.
4974
+ */
4975
+ decapsulateBits(
4976
+ decapsulationAlgorithm: AlgorithmIdentifier,
4977
+ decapsulationKey: CryptoKey,
4978
+ ciphertext: BufferSource,
4979
+ ): Promise<ArrayBuffer>;
4980
+ /**
4981
+ * A message recipient uses their asymmetric private key to decrypt an
4982
+ * "encapsulated key" (ciphertext), thereby recovering a temporary symmetric
4983
+ * key (represented as `CryptoKey`) which is then used to decrypt a message.
4984
+ *
4985
+ * The algorithms currently supported include:
4986
+ *
4987
+ * * `'ML-KEM-512'`
4988
+ * * `'ML-KEM-768'`
4989
+ * * `'ML-KEM-1024'`
4990
+ * @since v24.7.0
4991
+ * @param usages See [Key usages](https://nodejs.org/docs/latest-v24.x/api/webcrypto.html#cryptokeyusages).
4992
+ * @returns Fulfills with `CryptoKey` upon success.
4993
+ */
4994
+ decapsulateKey(
4995
+ decapsulationAlgorithm: AlgorithmIdentifier,
4996
+ decapsulationKey: CryptoKey,
4997
+ ciphertext: BufferSource,
4998
+ sharedKeyAlgorithm: AlgorithmIdentifier | HmacImportParams | AesDerivedKeyParams | KmacImportParams,
4999
+ extractable: boolean,
5000
+ usages: KeyUsage[],
5001
+ ): Promise<CryptoKey>;
4269
5002
  /**
4270
5003
  * Using the method and parameters specified in `algorithm` and the keying material provided by `key`,
4271
- * `subtle.decrypt()` attempts to decipher the provided `data`. If successful,
5004
+ * this method attempts to decipher the provided `data`. If successful,
4272
5005
  * the returned promise will be resolved with an `<ArrayBuffer>` containing the plaintext result.
4273
5006
  *
4274
5007
  * The algorithms currently supported include:
4275
5008
  *
4276
- * - `'RSA-OAEP'`
4277
- * - `'AES-CTR'`
4278
- * - `'AES-CBC'`
4279
- * - `'AES-GCM'`
5009
+ * * `'AES-CBC'`
5010
+ * * `'AES-CTR'`
5011
+ * * `'AES-GCM'`
5012
+ * * `'AES-OCB'`
5013
+ * * `'ChaCha20-Poly1305'`
5014
+ * * `'RSA-OAEP'`
4280
5015
  * @since v15.0.0
4281
5016
  */
4282
5017
  decrypt(
4283
- algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams,
5018
+ algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AeadParams,
4284
5019
  key: CryptoKey,
4285
5020
  data: BufferSource,
4286
5021
  ): Promise<ArrayBuffer>;
4287
5022
  /**
4288
5023
  * Using the method and parameters specified in `algorithm` and the keying material provided by `baseKey`,
4289
- * `subtle.deriveBits()` attempts to generate `length` bits.
5024
+ * this method attempts to generate `length` bits.
4290
5025
  * The Node.js implementation requires that when `length` is a number it must be multiple of `8`.
4291
5026
  * When `length` is `null` the maximum number of bits for a given algorithm is generated. This is allowed
4292
5027
  * for the `'ECDH'`, `'X25519'`, and `'X448'` algorithms.
@@ -4294,45 +5029,50 @@ declare module "crypto" {
4294
5029
  *
4295
5030
  * The algorithms currently supported include:
4296
5031
  *
4297
- * - `'ECDH'`
4298
- * - `'X25519'`
4299
- * - `'X448'`
4300
- * - `'HKDF'`
4301
- * - `'PBKDF2'`
5032
+ * * `'Argon2d'`
5033
+ * * `'Argon2i'`
5034
+ * * `'Argon2id'`
5035
+ * * `'ECDH'`
5036
+ * * `'HKDF'`
5037
+ * * `'PBKDF2'`
5038
+ * * `'X25519'`
5039
+ * * `'X448'`
4302
5040
  * @since v15.0.0
4303
5041
  */
4304
- deriveBits(algorithm: EcdhKeyDeriveParams, baseKey: CryptoKey, length: number | null): Promise<ArrayBuffer>;
4305
5042
  deriveBits(
4306
- algorithm: AlgorithmIdentifier | HkdfParams | Pbkdf2Params,
5043
+ algorithm: EcdhKeyDeriveParams,
5044
+ baseKey: CryptoKey,
5045
+ length?: number | null,
5046
+ ): Promise<ArrayBuffer>;
5047
+ deriveBits(
5048
+ algorithm: EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params | Argon2Params,
4307
5049
  baseKey: CryptoKey,
4308
5050
  length: number,
4309
5051
  ): Promise<ArrayBuffer>;
4310
5052
  /**
4311
5053
  * Using the method and parameters specified in `algorithm`, and the keying material provided by `baseKey`,
4312
- * `subtle.deriveKey()` attempts to generate a new <CryptoKey>` based on the method and parameters in `derivedKeyAlgorithm`.
5054
+ * this method attempts to generate a new <CryptoKey>` based on the method and parameters in `derivedKeyAlgorithm`.
4313
5055
  *
4314
5056
  * Calling `subtle.deriveKey()` is equivalent to calling `subtle.deriveBits()` to generate raw keying material,
4315
5057
  * then passing the result into the `subtle.importKey()` method using the `deriveKeyAlgorithm`, `extractable`, and `keyUsages` parameters as input.
4316
5058
  *
4317
5059
  * The algorithms currently supported include:
4318
5060
  *
4319
- * - `'ECDH'`
4320
- * - `'X25519'`
4321
- * - `'X448'`
4322
- * - `'HKDF'`
4323
- * - `'PBKDF2'`
5061
+ * * `'Argon2d'`
5062
+ * * `'Argon2i'`
5063
+ * * `'Argon2id'`
5064
+ * * `'ECDH'`
5065
+ * * `'HKDF'`
5066
+ * * `'PBKDF2'`
5067
+ * * `'X25519'`
5068
+ * * `'X448'`
4324
5069
  * @param keyUsages See {@link https://nodejs.org/docs/latest/api/webcrypto.html#cryptokeyusages Key usages}.
4325
5070
  * @since v15.0.0
4326
5071
  */
4327
5072
  deriveKey(
4328
- algorithm: AlgorithmIdentifier | EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params,
5073
+ algorithm: EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params | Argon2Params,
4329
5074
  baseKey: CryptoKey,
4330
- derivedKeyAlgorithm:
4331
- | AlgorithmIdentifier
4332
- | AesDerivedKeyParams
4333
- | HmacImportParams
4334
- | HkdfParams
4335
- | Pbkdf2Params,
5075
+ derivedKeyAlgorithm: AlgorithmIdentifier | HmacImportParams | AesDerivedKeyParams | KmacImportParams,
4336
5076
  extractable: boolean,
4337
5077
  keyUsages: readonly KeyUsage[],
4338
5078
  ): Promise<CryptoKey>;
@@ -4342,30 +5082,73 @@ declare module "crypto" {
4342
5082
  *
4343
5083
  * If `algorithm` is provided as a `<string>`, it must be one of:
4344
5084
  *
4345
- * - `'SHA-1'`
4346
- * - `'SHA-256'`
4347
- * - `'SHA-384'`
4348
- * - `'SHA-512'`
5085
+ * * `'cSHAKE128'`
5086
+ * * `'cSHAKE256'`
5087
+ * * `'SHA-1'`
5088
+ * * `'SHA-256'`
5089
+ * * `'SHA-384'`
5090
+ * * `'SHA-512'`
5091
+ * * `'SHA3-256'`
5092
+ * * `'SHA3-384'`
5093
+ * * `'SHA3-512'`
4349
5094
  *
4350
5095
  * If `algorithm` is provided as an `<Object>`, it must have a `name` property whose value is one of the above.
4351
5096
  * @since v15.0.0
4352
5097
  */
4353
- digest(algorithm: AlgorithmIdentifier, data: BufferSource): Promise<ArrayBuffer>;
5098
+ digest(algorithm: AlgorithmIdentifier | CShakeParams, data: BufferSource): Promise<ArrayBuffer>;
5099
+ /**
5100
+ * Uses a message recipient's asymmetric public key to encrypt a temporary symmetric key.
5101
+ * This encrypted key is the "encapsulated key" represented as `EncapsulatedBits`.
5102
+ *
5103
+ * The algorithms currently supported include:
5104
+ *
5105
+ * * `'ML-KEM-512'`
5106
+ * * `'ML-KEM-768'`
5107
+ * * `'ML-KEM-1024'`
5108
+ * @since v24.7.0
5109
+ * @returns Fulfills with `EncapsulatedBits` upon success.
5110
+ */
5111
+ encapsulateBits(
5112
+ encapsulationAlgorithm: AlgorithmIdentifier,
5113
+ encapsulationKey: CryptoKey,
5114
+ ): Promise<EncapsulatedBits>;
5115
+ /**
5116
+ * Uses a message recipient's asymmetric public key to encrypt a temporary symmetric key.
5117
+ * This encrypted key is the "encapsulated key" represented as `EncapsulatedKey`.
5118
+ *
5119
+ * The algorithms currently supported include:
5120
+ *
5121
+ * * `'ML-KEM-512'`
5122
+ * * `'ML-KEM-768'`
5123
+ * * `'ML-KEM-1024'`
5124
+ * @since v24.7.0
5125
+ * @param usages See [Key usages](https://nodejs.org/docs/latest-v24.x/api/webcrypto.html#cryptokeyusages).
5126
+ * @returns Fulfills with `EncapsulatedKey` upon success.
5127
+ */
5128
+ encapsulateKey(
5129
+ encapsulationAlgorithm: AlgorithmIdentifier,
5130
+ encapsulationKey: CryptoKey,
5131
+ sharedKeyAlgorithm: AlgorithmIdentifier | HmacImportParams | AesDerivedKeyParams | KmacImportParams,
5132
+ extractable: boolean,
5133
+ usages: KeyUsage[],
5134
+ ): Promise<EncapsulatedKey>;
4354
5135
  /**
4355
5136
  * Using the method and parameters specified by `algorithm` and the keying material provided by `key`,
4356
- * `subtle.encrypt()` attempts to encipher `data`. If successful,
5137
+ * this method attempts to encipher `data`. If successful,
4357
5138
  * the returned promise is resolved with an `<ArrayBuffer>` containing the encrypted result.
4358
5139
  *
4359
5140
  * The algorithms currently supported include:
4360
5141
  *
4361
- * - `'RSA-OAEP'`
4362
- * - `'AES-CTR'`
4363
- * - `'AES-CBC'`
4364
- * - `'AES-GCM'`
5142
+ * * `'AES-CBC'`
5143
+ * * `'AES-CTR'`
5144
+ * * `'AES-GCM'`
5145
+ * * `'AES-OCB'`
5146
+ * * `'ChaCha20-Poly1305'`
5147
+ * * `'RSA-OAEP'`
4365
5148
  * @since v15.0.0
4366
5149
  */
4367
5150
  encrypt(
4368
- algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams,
5151
+ algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AeadParams,
4369
5152
  key: CryptoKey,
4370
5153
  data: BufferSource,
4371
5154
  ): Promise<ArrayBuffer>;
@@ -4379,35 +5162,47 @@ declare module "crypto" {
4379
5162
  *
4380
5163
  * When `format` is `'jwk'` and the export is successful, the returned promise will be resolved with a
4381
5164
  * JavaScript object conforming to the {@link https://tools.ietf.org/html/rfc7517 JSON Web Key} specification.
4382
- * @param format Must be one of `'raw'`, `'pkcs8'`, `'spki'`, or `'jwk'`.
5165
+ * @param format Must be one of `'raw'`, `'pkcs8'`, `'spki'`, `'jwk'`, `'raw-secret'`,
5166
+ * `'raw-public'`, or `'raw-seed'`.
4383
5167
  * @returns `<Promise>` containing `<ArrayBuffer>`.
4384
5168
  * @since v15.0.0
4385
5169
  */
4386
5170
  exportKey(format: "jwk", key: CryptoKey): Promise<JsonWebKey>;
4387
5171
  exportKey(format: Exclude<KeyFormat, "jwk">, key: CryptoKey): Promise<ArrayBuffer>;
4388
5172
  /**
4389
- * Using the method and parameters provided in `algorithm`,
4390
- * `subtle.generateKey()` attempts to generate new keying material.
4391
- * Depending the method used, the method may generate either a single `<CryptoKey>` or a `<CryptoKeyPair>`.
5173
+ * Using the parameters provided in `algorithm`, this method
5174
+ * attempts to generate new keying material. Depending on the algorithm used
5175
+ * either a single `CryptoKey` or a `CryptoKeyPair` is generated.
4392
5176
  *
4393
- * The `<CryptoKeyPair>` (public and private key) generating algorithms supported include:
5177
+ * The `CryptoKeyPair` (public and private key) generating algorithms supported
5178
+ * include:
4394
5179
  *
4395
- * - `'RSASSA-PKCS1-v1_5'`
4396
- * - `'RSA-PSS'`
4397
- * - `'RSA-OAEP'`
4398
- * - `'ECDSA'`
4399
- * - `'Ed25519'`
4400
- * - `'Ed448'`
4401
- * - `'ECDH'`
4402
- * - `'X25519'`
4403
- * - `'X448'`
4404
- * The `<CryptoKey>` (secret key) generating algorithms supported include:
5180
+ * * `'ECDH'`
5181
+ * * `'ECDSA'`
5182
+ * * `'Ed25519'`
5183
+ * * `'Ed448'`
5184
+ * * `'ML-DSA-44'`
5185
+ * * `'ML-DSA-65'`
5186
+ * * `'ML-DSA-87'`
5187
+ * * `'ML-KEM-512'`
5188
+ * * `'ML-KEM-768'`
5189
+ * * `'ML-KEM-1024'`
5190
+ * * `'RSA-OAEP'`
5191
+ * * `'RSA-PSS'`
5192
+ * * `'RSASSA-PKCS1-v1_5'`
5193
+ * * `'X25519'`
5194
+ * * `'X448'`
4405
5195
  *
4406
- * - `'HMAC'`
4407
- * - `'AES-CTR'`
4408
- * - `'AES-CBC'`
4409
- * - `'AES-GCM'`
4410
- * - `'AES-KW'`
5196
+ * The `CryptoKey` (secret key) generating algorithms supported include:
5197
+ * * `'AES-CBC'`
5198
+ * * `'AES-CTR'`
5199
+ * * `'AES-GCM'`
5200
+ * * `'AES-KW'`
5201
+ * * `'AES-OCB'`
5202
+ * * `'ChaCha20-Poly1305'`
5203
+ * * `'HMAC'`
5204
+ * * `'KMAC128'`
5205
+ * * `'KMAC256'`
4411
5206
  * @param keyUsages See {@link https://nodejs.org/docs/latest/api/webcrypto.html#cryptokeyusages Key usages}.
4412
5207
  * @since v15.0.0
4413
5208
  */
@@ -4417,7 +5212,7 @@ declare module "crypto" {
4417
5212
  keyUsages: readonly KeyUsage[],
4418
5213
  ): Promise<CryptoKeyPair>;
4419
5214
  generateKey(
4420
- algorithm: AesKeyGenParams | HmacKeyGenParams | Pbkdf2Params,
5215
+ algorithm: AesKeyGenParams | HmacKeyGenParams | Pbkdf2Params | KmacKeyGenParams,
4421
5216
  extractable: boolean,
4422
5217
  keyUsages: readonly KeyUsage[],
4423
5218
  ): Promise<CryptoKey>;
@@ -4427,12 +5222,23 @@ declare module "crypto" {
4427
5222
  keyUsages: KeyUsage[],
4428
5223
  ): Promise<CryptoKeyPair | CryptoKey>;
4429
5224
  /**
4430
- * The `subtle.importKey()` method attempts to interpret the provided `keyData` as the given `format`
4431
- * to create a `<CryptoKey>` instance using the provided `algorithm`, `extractable`, and `keyUsages` arguments.
4432
- * If the import is successful, the returned promise will be resolved with the created `<CryptoKey>`.
5225
+ * Derives the public key from a given private key.
5226
+ * @since v24.7.0
5227
+ * @param key A private key from which to derive the corresponding public key.
5228
+ * @param keyUsages See [Key usages](https://nodejs.org/docs/latest-v24.x/api/webcrypto.html#cryptokeyusages).
5229
+ * @returns Fulfills with a `CryptoKey` upon success.
5230
+ */
5231
+ getPublicKey(key: CryptoKey, keyUsages: KeyUsage[]): Promise<CryptoKey>;
5232
+ /**
5233
+ * This method attempts to interpret the provided `keyData`
5234
+ * as the given `format` to create a `CryptoKey` instance using the provided
5235
+ * `algorithm`, `extractable`, and `keyUsages` arguments. If the import is
5236
+ * successful, the returned promise will be resolved with a {CryptoKey}
5237
+ * representation of the key material.
4433
5238
  *
4434
- * If importing a `'PBKDF2'` key, `extractable` must be `false`.
4435
- * @param format Must be one of `'raw'`, `'pkcs8'`, `'spki'`, or `'jwk'`.
5239
+ * If importing KDF algorithm keys, `extractable` must be `false`.
5240
+ * @param format Must be one of `'raw'`, `'pkcs8'`, `'spki'`, `'jwk'`, `'raw-secret'`,
5241
+ * `'raw-public'`, or `'raw-seed'`.
4436
5242
  * @param keyUsages See {@link https://nodejs.org/docs/latest/api/webcrypto.html#cryptokeyusages Key usages}.
4437
5243
  * @since v15.0.0
4438
5244
  */
@@ -4444,7 +5250,8 @@ declare module "crypto" {
4444
5250
  | RsaHashedImportParams
4445
5251
  | EcKeyImportParams
4446
5252
  | HmacImportParams
4447
- | AesKeyAlgorithm,
5253
+ | AesKeyAlgorithm
5254
+ | KmacImportParams,
4448
5255
  extractable: boolean,
4449
5256
  keyUsages: readonly KeyUsage[],
4450
5257
  ): Promise<CryptoKey>;
@@ -4456,62 +5263,81 @@ declare module "crypto" {
4456
5263
  | RsaHashedImportParams
4457
5264
  | EcKeyImportParams
4458
5265
  | HmacImportParams
4459
- | AesKeyAlgorithm,
5266
+ | AesKeyAlgorithm
5267
+ | KmacImportParams,
4460
5268
  extractable: boolean,
4461
5269
  keyUsages: KeyUsage[],
4462
5270
  ): Promise<CryptoKey>;
4463
5271
  /**
4464
5272
  * Using the method and parameters given by `algorithm` and the keying material provided by `key`,
4465
- * `subtle.sign()` attempts to generate a cryptographic signature of `data`. If successful,
5273
+ * this method attempts to generate a cryptographic signature of `data`. If successful,
4466
5274
  * the returned promise is resolved with an `<ArrayBuffer>` containing the generated signature.
4467
5275
  *
4468
5276
  * The algorithms currently supported include:
4469
5277
  *
4470
- * - `'RSASSA-PKCS1-v1_5'`
4471
- * - `'RSA-PSS'`
4472
- * - `'ECDSA'`
4473
- * - `'Ed25519'`
4474
- * - `'Ed448'`
4475
- * - `'HMAC'`
5278
+ * * `'ECDSA'`
5279
+ * * `'Ed25519'`
5280
+ * * `'Ed448'`
5281
+ * * `'HMAC'`
5282
+ * * `'KMAC128'`
5283
+ * * `'KMAC256'`
5284
+ * * `'ML-DSA-44'`
5285
+ * * `'ML-DSA-65'`
5286
+ * * `'ML-DSA-87'`
5287
+ * * `'RSA-PSS'`
5288
+ * * `'RSASSA-PKCS1-v1_5'`
4476
5289
  * @since v15.0.0
4477
5290
  */
4478
5291
  sign(
4479
- algorithm: AlgorithmIdentifier | RsaPssParams | EcdsaParams | Ed448Params,
5292
+ algorithm: AlgorithmIdentifier | RsaPssParams | EcdsaParams | ContextParams | KmacParams,
4480
5293
  key: CryptoKey,
4481
5294
  data: BufferSource,
4482
5295
  ): Promise<ArrayBuffer>;
4483
5296
  /**
4484
5297
  * In cryptography, "wrapping a key" refers to exporting and then encrypting the keying material.
4485
- * The `subtle.unwrapKey()` method attempts to decrypt a wrapped key and create a `<CryptoKey>` instance.
5298
+ * This method attempts to decrypt a wrapped key and create a `<CryptoKey>` instance.
4486
5299
  * It is equivalent to calling `subtle.decrypt()` first on the encrypted key data (using the `wrappedKey`, `unwrapAlgo`, and `unwrappingKey` arguments as input)
4487
5300
  * then passing the results in to the `subtle.importKey()` method using the `unwrappedKeyAlgo`, `extractable`, and `keyUsages` arguments as inputs.
4488
5301
  * If successful, the returned promise is resolved with a `<CryptoKey>` object.
4489
5302
  *
4490
5303
  * The wrapping algorithms currently supported include:
4491
5304
  *
4492
- * - `'RSA-OAEP'`
4493
- * - `'AES-CTR'`
4494
- * - `'AES-CBC'`
4495
- * - `'AES-GCM'`
4496
- * - `'AES-KW'`
5305
+ * * `'AES-CBC'`
5306
+ * * `'AES-CTR'`
5307
+ * * `'AES-GCM'`
5308
+ * * `'AES-KW'`
5309
+ * * `'AES-OCB'`
5310
+ * * `'ChaCha20-Poly1305'`
5311
+ * * `'RSA-OAEP'`
4497
5312
  *
4498
5313
  * The unwrapped key algorithms supported include:
4499
5314
  *
4500
- * - `'RSASSA-PKCS1-v1_5'`
4501
- * - `'RSA-PSS'`
4502
- * - `'RSA-OAEP'`
4503
- * - `'ECDSA'`
4504
- * - `'Ed25519'`
4505
- * - `'Ed448'`
4506
- * - `'ECDH'`
4507
- * - `'X25519'`
4508
- * - `'X448'`
4509
- * - `'HMAC'`
4510
- * - `'AES-CTR'`
4511
- * - `'AES-CBC'`
4512
- * - `'AES-GCM'`
4513
- * - `'AES-KW'`
4514
- * @param format Must be one of `'raw'`, `'pkcs8'`, `'spki'`, or `'jwk'`.
5315
+ * * `'AES-CBC'`
5316
+ * * `'AES-CTR'`
5317
+ * * `'AES-GCM'`
5318
+ * * `'AES-KW'`
5319
+ * * `'AES-OCB'`
5320
+ * * `'ChaCha20-Poly1305'`
5321
+ * * `'ECDH'`
5322
+ * * `'ECDSA'`
5323
+ * * `'Ed25519'`
5324
+ * * `'Ed448'`
5325
+ * * `'HMAC'`
5326
+ * * `'KMAC128'`
5327
+ * * `'KMAC256'`
5328
+ * * `'ML-DSA-44'`
5329
+ * * `'ML-DSA-65'`
5330
+ * * `'ML-DSA-87'`
5331
+ * * `'ML-KEM-512'`
5332
+ * * `'ML-KEM-768'`
5333
+ * * `'ML-KEM-1024'`
5334
+ * * `'RSA-OAEP'`
5335
+ * * `'RSA-PSS'`
5336
+ * * `'RSASSA-PKCS1-v1_5'`
5337
+ * * `'X25519'`
5338
+ * * `'X448'`
5339
+ * @param format Must be one of `'raw'`, `'pkcs8'`, `'spki'`, `'jwk'`, `'raw-secret'`,
5340
+ * `'raw-public'`, or `'raw-seed'`.
4515
5341
  * @param keyUsages See {@link https://nodejs.org/docs/latest/api/webcrypto.html#cryptokeyusages Key usages}.
4516
5342
  * @since v15.0.0
4517
5343
  */
@@ -4519,40 +5345,46 @@ declare module "crypto" {
4519
5345
  format: KeyFormat,
4520
5346
  wrappedKey: BufferSource,
4521
5347
  unwrappingKey: CryptoKey,
4522
- unwrapAlgorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams,
5348
+ unwrapAlgorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AeadParams,
4523
5349
  unwrappedKeyAlgorithm:
4524
5350
  | AlgorithmIdentifier
4525
5351
  | RsaHashedImportParams
4526
5352
  | EcKeyImportParams
4527
5353
  | HmacImportParams
4528
- | AesKeyAlgorithm,
5354
+ | AesKeyAlgorithm
5355
+ | KmacImportParams,
4529
5356
  extractable: boolean,
4530
5357
  keyUsages: KeyUsage[],
4531
5358
  ): Promise<CryptoKey>;
4532
5359
  /**
4533
5360
  * Using the method and parameters given in `algorithm` and the keying material provided by `key`,
4534
- * `subtle.verify()` attempts to verify that `signature` is a valid cryptographic signature of `data`.
5361
+ * This method attempts to verify that `signature` is a valid cryptographic signature of `data`.
4535
5362
  * The returned promise is resolved with either `true` or `false`.
4536
5363
  *
4537
5364
  * The algorithms currently supported include:
4538
5365
  *
4539
- * - `'RSASSA-PKCS1-v1_5'`
4540
- * - `'RSA-PSS'`
4541
- * - `'ECDSA'`
4542
- * - `'Ed25519'`
4543
- * - `'Ed448'`
4544
- * - `'HMAC'`
5366
+ * * `'ECDSA'`
5367
+ * * `'Ed25519'`
5368
+ * * `'Ed448'`
5369
+ * * `'HMAC'`
5370
+ * * `'KMAC128'`
5371
+ * * `'KMAC256'`
5372
+ * * `'ML-DSA-44'`
5373
+ * * `'ML-DSA-65'`
5374
+ * * `'ML-DSA-87'`
5375
+ * * `'RSA-PSS'`
5376
+ * * `'RSASSA-PKCS1-v1_5'`
4545
5377
  * @since v15.0.0
4546
5378
  */
4547
5379
  verify(
4548
- algorithm: AlgorithmIdentifier | RsaPssParams | EcdsaParams | Ed448Params,
5380
+ algorithm: AlgorithmIdentifier | RsaPssParams | EcdsaParams | ContextParams | KmacParams,
4549
5381
  key: CryptoKey,
4550
5382
  signature: BufferSource,
4551
5383
  data: BufferSource,
4552
5384
  ): Promise<boolean>;
4553
5385
  /**
4554
5386
  * In cryptography, "wrapping a key" refers to exporting and then encrypting the keying material.
4555
- * The `subtle.wrapKey()` method exports the keying material into the format identified by `format`,
5387
+ * This method exports the keying material into the format identified by `format`,
4556
5388
  * then encrypts it using the method and parameters specified by `wrapAlgo` and the keying material provided by `wrappingKey`.
4557
5389
  * It is the equivalent to calling `subtle.exportKey()` using `format` and `key` as the arguments,
4558
5390
  * then passing the result to the `subtle.encrypt()` method using `wrappingKey` and `wrapAlgo` as inputs.
@@ -4560,30 +5392,25 @@ declare module "crypto" {
4560
5392
  *
4561
5393
  * The wrapping algorithms currently supported include:
4562
5394
  *
4563
- * - `'RSA-OAEP'`
4564
- * - `'AES-CTR'`
4565
- * - `'AES-CBC'`
4566
- * - `'AES-GCM'`
4567
- * - `'AES-KW'`
4568
- * @param format Must be one of `'raw'`, `'pkcs8'`, `'spki'`, or `'jwk'`.
5395
+ * * `'AES-CBC'`
5396
+ * * `'AES-CTR'`
5397
+ * * `'AES-GCM'`
5398
+ * * `'AES-KW'`
5399
+ * * `'AES-OCB'`
5400
+ * * `'ChaCha20-Poly1305'`
5401
+ * * `'RSA-OAEP'`
5402
+ * @param format Must be one of `'raw'`, `'pkcs8'`, `'spki'`, `'jwk'`, `'raw-secret'`,
5403
+ * `'raw-public'`, or `'raw-seed'`.
4569
5404
  * @since v15.0.0
4570
5405
  */
4571
5406
  wrapKey(
4572
5407
  format: KeyFormat,
4573
5408
  key: CryptoKey,
4574
5409
  wrappingKey: CryptoKey,
4575
- wrapAlgorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams,
5410
+ wrapAlgorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AeadParams,
4576
5411
  ): Promise<ArrayBuffer>;
4577
5412
  }
4578
5413
  }
4579
-
4580
- global {
4581
- var crypto: typeof globalThis extends {
4582
- crypto: infer T;
4583
- onmessage: any;
4584
- } ? T
4585
- : webcrypto.Crypto;
4586
- }
4587
5414
  }
4588
5415
  declare module "node:crypto" {
4589
5416
  export * from "crypto";