@types/node 16.11.39 → 18.11.2

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 (111) hide show
  1. {node v16.11 → node}/LICENSE +0 -0
  2. node v16.11/README.md → node/README.md +4 -4
  3. {node v16.11 → node}/assert/strict.d.ts +0 -0
  4. node v16.11/assert.d.ts → node/assert.d.ts +7 -8
  5. node v16.11/async_hooks.d.ts → node/async_hooks.d.ts +8 -4
  6. node/buffer.d.ts +2258 -0
  7. node v16.11/child_process.d.ts → node/child_process.d.ts +6 -3
  8. node v16.11/cluster.d.ts → node/cluster.d.ts +14 -18
  9. node v16.11/console.d.ts → node/console.d.ts +1 -1
  10. {node v16.11 → node}/constants.d.ts +0 -0
  11. node v16.11/crypto.d.ts → node/crypto.d.ts +679 -53
  12. node v16.11/dgram.d.ts → node/dgram.d.ts +3 -3
  13. node v16.11/diagnostics_channel.d.ts → node/diagnostics_channel.d.ts +2 -1
  14. node v16.11/dns/promises.d.ts → node/dns/promises.d.ts +10 -8
  15. node v16.11/dns.d.ts → node/dns.d.ts +16 -11
  16. node/dom-events.d.ts +126 -0
  17. node v16.11/domain.d.ts → node/domain.d.ts +3 -2
  18. node v16.11/events.d.ts → node/events.d.ts +65 -10
  19. node v16.11/fs/promises.d.ts → node/fs/promises.d.ts +86 -39
  20. node v16.11/fs.d.ts → node/fs.d.ts +149 -67
  21. node/globals.d.ts +300 -0
  22. {node v16.11 → node}/globals.global.d.ts +0 -0
  23. node v16.11/http.d.ts → node/http.d.ts +305 -77
  24. node v16.11/http2.d.ts → node/http2.d.ts +38 -5
  25. node v16.11/https.d.ts → node/https.d.ts +209 -59
  26. node v16.11/index.d.ts → node/index.d.ts +6 -3
  27. node v16.11/inspector.d.ts → node/inspector.d.ts +11 -15
  28. {node v16.11 → node}/module.d.ts +0 -0
  29. node v16.11/net.d.ts → node/net.d.ts +94 -21
  30. node v16.11/os.d.ts → node/os.d.ts +15 -4
  31. node v16.11/package.json → node/package.json +15 -8
  32. node v16.11/path.d.ts → node/path.d.ts +34 -23
  33. node v16.11/perf_hooks.d.ts → node/perf_hooks.d.ts +76 -8
  34. node v16.11/process.d.ts → node/process.d.ts +17 -16
  35. node v16.11/punycode.d.ts → node/punycode.d.ts +1 -1
  36. node v16.11/querystring.d.ts → node/querystring.d.ts +4 -4
  37. node/readline/promises.d.ts +143 -0
  38. node v16.11/readline.d.ts → node/readline.d.ts +140 -30
  39. node v16.11/repl.d.ts → node/repl.d.ts +2 -2
  40. node v16.11/stream/consumers.d.ts → node/stream/consumers.d.ts +2 -14
  41. {node v16.11 → node}/stream/promises.d.ts +0 -0
  42. node v16.11/stream/web.d.ts → node/stream/web.d.ts +3 -65
  43. node v16.11/stream.d.ts → node/stream.d.ts +97 -19
  44. node v16.11/string_decoder.d.ts → node/string_decoder.d.ts +1 -1
  45. node/test.d.ts +314 -0
  46. {node v16.11 → node}/timers/promises.d.ts +0 -0
  47. node v16.11/timers.d.ts → node/timers.d.ts +1 -1
  48. node v16.11/tls.d.ts → node/tls.d.ts +32 -23
  49. node v16.11/trace_events.d.ts → node/trace_events.d.ts +11 -1
  50. node/ts4.8/assert/strict.d.ts +8 -0
  51. node/ts4.8/assert.d.ts +911 -0
  52. node/ts4.8/async_hooks.d.ts +501 -0
  53. node v16.11/buffer.d.ts → node/ts4.8/buffer.d.ts +46 -19
  54. node/ts4.8/child_process.d.ts +1369 -0
  55. node/ts4.8/cluster.d.ts +410 -0
  56. node/ts4.8/console.d.ts +412 -0
  57. node/ts4.8/constants.d.ts +18 -0
  58. node/ts4.8/crypto.d.ts +3964 -0
  59. node/ts4.8/dgram.d.ts +545 -0
  60. node/ts4.8/diagnostics_channel.d.ts +153 -0
  61. node/ts4.8/dns/promises.d.ts +370 -0
  62. node/ts4.8/dns.d.ts +659 -0
  63. node/ts4.8/dom-events.d.ts +126 -0
  64. node/ts4.8/domain.d.ts +170 -0
  65. node/ts4.8/events.d.ts +678 -0
  66. node/ts4.8/fs/promises.d.ts +1138 -0
  67. node/ts4.8/fs.d.ts +3872 -0
  68. node v16.11/globals.d.ts → node/ts4.8/globals.d.ts +14 -4
  69. node/ts4.8/globals.global.d.ts +1 -0
  70. node/ts4.8/http.d.ts +1607 -0
  71. node/ts4.8/http2.d.ts +2134 -0
  72. node/ts4.8/https.d.ts +541 -0
  73. node/ts4.8/index.d.ts +88 -0
  74. node/ts4.8/inspector.d.ts +2741 -0
  75. node/ts4.8/module.d.ts +114 -0
  76. node/ts4.8/net.d.ts +869 -0
  77. node/ts4.8/os.d.ts +466 -0
  78. node/ts4.8/path.d.ts +191 -0
  79. node/ts4.8/perf_hooks.d.ts +625 -0
  80. node/ts4.8/process.d.ts +1482 -0
  81. node/ts4.8/punycode.d.ts +117 -0
  82. node/ts4.8/querystring.d.ts +131 -0
  83. node/ts4.8/readline/promises.d.ts +143 -0
  84. node/ts4.8/readline.d.ts +653 -0
  85. node/ts4.8/repl.d.ts +424 -0
  86. node/ts4.8/stream/consumers.d.ts +12 -0
  87. node/ts4.8/stream/promises.d.ts +42 -0
  88. node/ts4.8/stream/web.d.ts +330 -0
  89. node/ts4.8/stream.d.ts +1340 -0
  90. node/ts4.8/string_decoder.d.ts +67 -0
  91. node/ts4.8/test.d.ts +314 -0
  92. node/ts4.8/timers/promises.d.ts +68 -0
  93. node/ts4.8/timers.d.ts +94 -0
  94. node/ts4.8/tls.d.ts +1028 -0
  95. node/ts4.8/trace_events.d.ts +171 -0
  96. node v16.11/tty.d.ts → node/ts4.8/tty.d.ts +4 -2
  97. node v16.11/url.d.ts → node/ts4.8/url.d.ts +85 -39
  98. node v16.11/util.d.ts → node/ts4.8/util.d.ts +268 -12
  99. node v16.11/v8.d.ts → node/ts4.8/v8.d.ts +21 -3
  100. node v16.11/vm.d.ts → node/ts4.8/vm.d.ts +6 -4
  101. node v16.11/wasi.d.ts → node/ts4.8/wasi.d.ts +1 -1
  102. node v16.11/worker_threads.d.ts → node/ts4.8/worker_threads.d.ts +50 -10
  103. node v16.11/zlib.d.ts → node/ts4.8/zlib.d.ts +1 -1
  104. node/tty.d.ts +206 -0
  105. node/url.d.ts +897 -0
  106. node/util.d.ts +1850 -0
  107. node/v8.d.ts +396 -0
  108. node/vm.d.ts +509 -0
  109. node/wasi.d.ts +158 -0
  110. node/worker_threads.d.ts +689 -0
  111. node/zlib.d.ts +517 -0
@@ -13,47 +13,73 @@
13
13
  * // Prints:
14
14
  * // c0fa1bc00531bd78ef38c628449c5102aeabd49b5dc3a2a516ea6ea959d6658e
15
15
  * ```
16
- * @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/crypto.js)
16
+ * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/crypto.js)
17
17
  */
18
18
  declare module 'crypto' {
19
19
  import * as stream from 'node:stream';
20
20
  import { PeerCertificate } from 'node:tls';
21
- interface Certificate {
21
+ /**
22
+ * SPKAC is a Certificate Signing Request mechanism originally implemented by
23
+ * Netscape and was specified formally as part of [HTML5's `keygen` element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/keygen).
24
+ *
25
+ * `<keygen>` is deprecated since [HTML 5.2](https://www.w3.org/TR/html52/changes.html#features-removed) and new projects
26
+ * should not use this element anymore.
27
+ *
28
+ * The `crypto` module provides the `Certificate` class for working with SPKAC
29
+ * data. The most common usage is handling output generated by the HTML5`<keygen>` element. Node.js uses [OpenSSL's SPKAC
30
+ * implementation](https://www.openssl.org/docs/man1.1.0/apps/openssl-spkac.html) internally.
31
+ * @since v0.11.8
32
+ */
33
+ class Certificate {
22
34
  /**
23
- * @deprecated
24
- * @param spkac
25
- * @returns The challenge component of the `spkac` data structure,
26
- * which includes a public key and a challenge.
35
+ * ```js
36
+ * const { Certificate } = await import('crypto');
37
+ * const spkac = getSpkacSomehow();
38
+ * const challenge = Certificate.exportChallenge(spkac);
39
+ * console.log(challenge.toString('utf8'));
40
+ * // Prints: the challenge as a UTF8 string
41
+ * ```
42
+ * @since v9.0.0
43
+ * @param encoding The `encoding` of the `spkac` string.
44
+ * @return The challenge component of the `spkac` data structure, which includes a public key and a challenge.
27
45
  */
28
- exportChallenge(spkac: BinaryLike): Buffer;
46
+ static exportChallenge(spkac: BinaryLike): Buffer;
29
47
  /**
30
- * @deprecated
31
- * @param spkac
32
- * @param encoding The encoding of the spkac string.
33
- * @returns The public key component of the `spkac` data structure,
34
- * which includes a public key and a challenge.
48
+ * ```js
49
+ * const { Certificate } = await import('crypto');
50
+ * const spkac = getSpkacSomehow();
51
+ * const publicKey = Certificate.exportPublicKey(spkac);
52
+ * console.log(publicKey);
53
+ * // Prints: the public key as <Buffer ...>
54
+ * ```
55
+ * @since v9.0.0
56
+ * @param encoding The `encoding` of the `spkac` string.
57
+ * @return The public key component of the `spkac` data structure, which includes a public key and a challenge.
35
58
  */
36
- exportPublicKey(spkac: BinaryLike, encoding?: string): Buffer;
59
+ static exportPublicKey(spkac: BinaryLike, encoding?: string): Buffer;
37
60
  /**
38
- * @deprecated
39
- * @param spkac
40
- * @returns `true` if the given `spkac` data structure is valid,
41
- * `false` otherwise.
61
+ * ```js
62
+ * import { Buffer } from 'buffer';
63
+ * const { Certificate } = await import('crypto');
64
+ *
65
+ * const spkac = getSpkacSomehow();
66
+ * console.log(Certificate.verifySpkac(Buffer.from(spkac)));
67
+ * // Prints: true or false
68
+ * ```
69
+ * @since v9.0.0
70
+ * @param encoding The `encoding` of the `spkac` string.
71
+ * @return `true` if the given `spkac` data structure is valid, `false` otherwise.
42
72
  */
43
- verifySpkac(spkac: NodeJS.ArrayBufferView): boolean;
44
- }
45
- const Certificate: Certificate & {
46
- /** @deprecated since v14.9.0 - Use static methods of `crypto.Certificate` instead. */
47
- new (): Certificate;
48
- /** @deprecated since v14.9.0 - Use static methods of `crypto.Certificate` instead. */
49
- (): Certificate;
73
+ static verifySpkac(spkac: NodeJS.ArrayBufferView): boolean;
50
74
  /**
75
+ * @deprecated
51
76
  * @param spkac
52
77
  * @returns The challenge component of the `spkac` data structure,
53
78
  * which includes a public key and a challenge.
54
79
  */
55
80
  exportChallenge(spkac: BinaryLike): Buffer;
56
81
  /**
82
+ * @deprecated
57
83
  * @param spkac
58
84
  * @param encoding The encoding of the spkac string.
59
85
  * @returns The public key component of the `spkac` data structure,
@@ -61,12 +87,13 @@ declare module 'crypto' {
61
87
  */
62
88
  exportPublicKey(spkac: BinaryLike, encoding?: string): Buffer;
63
89
  /**
90
+ * @deprecated
64
91
  * @param spkac
65
92
  * @returns `true` if the given `spkac` data structure is valid,
66
93
  * `false` otherwise.
67
94
  */
68
95
  verifySpkac(spkac: NodeJS.ArrayBufferView): boolean;
69
- };
96
+ }
70
97
  namespace constants {
71
98
  // https://nodejs.org/dist/latest-v10.x/docs/api/crypto.html#crypto_crypto_constants
72
99
  const OPENSSL_VERSION_NUMBER: number;
@@ -172,7 +199,7 @@ declare module 'crypto' {
172
199
  *
173
200
  * The `algorithm` is dependent on the available algorithms supported by the
174
201
  * version of OpenSSL on the platform. Examples are `'sha256'`, `'sha512'`, etc.
175
- * On recent releases of OpenSSL, `openssl list -digest-algorithms`(`openssl list-message-digest-algorithms` for older versions of OpenSSL) will
202
+ * On recent releases of OpenSSL, `openssl list -digest-algorithms` will
176
203
  * display the available digest algorithms.
177
204
  *
178
205
  * Example: generating the sha256 sum of a file
@@ -212,7 +239,7 @@ declare module 'crypto' {
212
239
  *
213
240
  * The `algorithm` is dependent on the available algorithms supported by the
214
241
  * version of OpenSSL on the platform. Examples are `'sha256'`, `'sha512'`, etc.
215
- * On recent releases of OpenSSL, `openssl list -digest-algorithms`(`openssl list-message-digest-algorithms` for older versions of OpenSSL) will
242
+ * On recent releases of OpenSSL, `openssl list -digest-algorithms` will
216
243
  * display the available digest algorithms.
217
244
  *
218
245
  * The `key` is the HMAC key used to generate the cryptographic HMAC hash. If it is
@@ -250,7 +277,7 @@ declare module 'crypto' {
250
277
  */
251
278
  function createHmac(algorithm: string, key: BinaryLike | KeyObject, options?: stream.TransformOptions): Hmac;
252
279
  // https://nodejs.org/api/buffer.html#buffer_buffers_and_character_encodings
253
- type BinaryToTextEncoding = 'base64' | 'base64url' | 'hex';
280
+ type BinaryToTextEncoding = 'base64' | 'base64url' | 'hex' | 'binary';
254
281
  type CharacterEncoding = 'utf8' | 'utf-8' | 'utf16le' | 'latin1';
255
282
  type LegacyCharacterEncoding = 'ascii' | 'binary' | 'ucs2' | 'ucs-2';
256
283
  type Encoding = BinaryToTextEncoding | CharacterEncoding | LegacyCharacterEncoding;
@@ -529,9 +556,6 @@ declare module 'crypto' {
529
556
  */
530
557
  namedCurve?: string | undefined;
531
558
  }
532
- interface JwkKeyExportOptions {
533
- format: 'jwk';
534
- }
535
559
  /**
536
560
  * Node.js uses a `KeyObject` class to represent a symmetric or asymmetric key,
537
561
  * and each kind of key exposes different functions. The {@link createSecretKey}, {@link createPublicKey} and {@link createPrivateKey} methods are used to create `KeyObject`instances. `KeyObject`
@@ -662,12 +686,13 @@ declare module 'crypto' {
662
686
  * Creates and returns a `Cipher` object that uses the given `algorithm` and`password`.
663
687
  *
664
688
  * The `options` argument controls stream behavior and is optional except when a
665
- * cipher in CCM or OCB mode is used (e.g. `'aes-128-ccm'`). In that case, the`authTagLength` option is required and specifies the length of the
689
+ * 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
666
690
  * 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
667
691
  * tag that will be returned by `getAuthTag()` and defaults to 16 bytes.
692
+ * For `chacha20-poly1305`, the `authTagLength` option defaults to 16 bytes.
668
693
  *
669
694
  * The `algorithm` is dependent on OpenSSL, examples are `'aes192'`, etc. On
670
- * recent OpenSSL releases, `openssl list -cipher-algorithms`(`openssl list-cipher-algorithms` for older versions of OpenSSL) will
695
+ * recent OpenSSL releases, `openssl list -cipher-algorithms` will
671
696
  * display the available cipher algorithms.
672
697
  *
673
698
  * The `password` is used to derive the cipher key and initialization vector (IV).
@@ -700,12 +725,13 @@ declare module 'crypto' {
700
725
  * initialization vector (`iv`).
701
726
  *
702
727
  * The `options` argument controls stream behavior and is optional except when a
703
- * cipher in CCM or OCB mode is used (e.g. `'aes-128-ccm'`). In that case, the`authTagLength` option is required and specifies the length of the
728
+ * 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
704
729
  * 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
705
730
  * tag that will be returned by `getAuthTag()` and defaults to 16 bytes.
731
+ * For `chacha20-poly1305`, the `authTagLength` option defaults to 16 bytes.
706
732
  *
707
733
  * The `algorithm` is dependent on OpenSSL, examples are `'aes192'`, etc. On
708
- * recent OpenSSL releases, `openssl list -cipher-algorithms`(`openssl list-cipher-algorithms` for older versions of OpenSSL) will
734
+ * recent OpenSSL releases, `openssl list -cipher-algorithms` will
709
735
  * display the available cipher algorithms.
710
736
  *
711
737
  * The `key` is the raw key used by the `algorithm` and `iv` is an [initialization vector](https://en.wikipedia.org/wiki/Initialization_vector). Both arguments must be `'utf8'` encoded
@@ -925,8 +951,9 @@ declare module 'crypto' {
925
951
  * Creates and returns a `Decipher` object that uses the given `algorithm` and`password` (key).
926
952
  *
927
953
  * The `options` argument controls stream behavior and is optional except when a
928
- * cipher in CCM or OCB mode is used (e.g. `'aes-128-ccm'`). In that case, the`authTagLength` option is required and specifies the length of the
954
+ * 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
929
955
  * authentication tag in bytes, see `CCM mode`.
956
+ * For `chacha20-poly1305`, the `authTagLength` option defaults to 16 bytes.
930
957
  *
931
958
  * The implementation of `crypto.createDecipher()` derives keys using the OpenSSL
932
959
  * function [`EVP_BytesToKey`](https://www.openssl.org/docs/man1.1.0/crypto/EVP_BytesToKey.html) with the digest algorithm set to MD5, one
@@ -951,12 +978,13 @@ declare module 'crypto' {
951
978
  * Creates and returns a `Decipher` object that uses the given `algorithm`, `key`and initialization vector (`iv`).
952
979
  *
953
980
  * The `options` argument controls stream behavior and is optional except when a
954
- * cipher in CCM or OCB mode is used (e.g. `'aes-128-ccm'`). In that case, the`authTagLength` option is required and specifies the length of the
981
+ * 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
955
982
  * authentication tag in bytes, see `CCM mode`. In GCM mode, the `authTagLength`option is not required but can be used to restrict accepted authentication tags
956
983
  * to those with the specified length.
984
+ * For `chacha20-poly1305`, the `authTagLength` option defaults to 16 bytes.
957
985
  *
958
986
  * The `algorithm` is dependent on OpenSSL, examples are `'aes192'`, etc. On
959
- * recent OpenSSL releases, `openssl list -cipher-algorithms`(`openssl list-cipher-algorithms` for older versions of OpenSSL) will
987
+ * recent OpenSSL releases, `openssl list -cipher-algorithms` will
960
988
  * display the available cipher algorithms.
961
989
  *
962
990
  * The `key` is the raw key used by the `algorithm` and `iv` is an [initialization vector](https://en.wikipedia.org/wiki/Initialization_vector). Both arguments must be `'utf8'` encoded
@@ -1450,10 +1478,10 @@ declare module 'crypto' {
1450
1478
  * @param [generator=2]
1451
1479
  * @param generatorEncoding The `encoding` of the `generator` string.
1452
1480
  */
1453
- function createDiffieHellman(primeLength: number, generator?: number | NodeJS.ArrayBufferView): DiffieHellman;
1454
- function createDiffieHellman(prime: NodeJS.ArrayBufferView): DiffieHellman;
1455
- function createDiffieHellman(prime: string, primeEncoding: BinaryToTextEncoding): DiffieHellman;
1456
- function createDiffieHellman(prime: string, primeEncoding: BinaryToTextEncoding, generator: number | NodeJS.ArrayBufferView): DiffieHellman;
1481
+ function createDiffieHellman(primeLength: number, generator?: number): DiffieHellman;
1482
+ function createDiffieHellman(prime: ArrayBuffer | NodeJS.ArrayBufferView, generator?: number | ArrayBuffer | NodeJS.ArrayBufferView): DiffieHellman;
1483
+ function createDiffieHellman(prime: ArrayBuffer | NodeJS.ArrayBufferView, generator: string, generatorEncoding: BinaryToTextEncoding): DiffieHellman;
1484
+ function createDiffieHellman(prime: string, primeEncoding: BinaryToTextEncoding, generator?: number | ArrayBuffer | NodeJS.ArrayBufferView): DiffieHellman;
1457
1485
  function createDiffieHellman(prime: string, primeEncoding: BinaryToTextEncoding, generator: string, generatorEncoding: BinaryToTextEncoding): DiffieHellman;
1458
1486
  /**
1459
1487
  * The `DiffieHellman` class is a utility for creating Diffie-Hellman key
@@ -1510,9 +1538,9 @@ declare module 'crypto' {
1510
1538
  * @param inputEncoding The `encoding` of an `otherPublicKey` string.
1511
1539
  * @param outputEncoding The `encoding` of the return value.
1512
1540
  */
1513
- computeSecret(otherPublicKey: NodeJS.ArrayBufferView): Buffer;
1514
- computeSecret(otherPublicKey: string, inputEncoding: BinaryToTextEncoding): Buffer;
1515
- computeSecret(otherPublicKey: NodeJS.ArrayBufferView, outputEncoding: BinaryToTextEncoding): string;
1541
+ computeSecret(otherPublicKey: NodeJS.ArrayBufferView, inputEncoding?: null, outputEncoding?: null): Buffer;
1542
+ computeSecret(otherPublicKey: string, inputEncoding: BinaryToTextEncoding, outputEncoding?: null): Buffer;
1543
+ computeSecret(otherPublicKey: NodeJS.ArrayBufferView, inputEncoding: null, outputEncoding: BinaryToTextEncoding): string;
1516
1544
  computeSecret(otherPublicKey: string, inputEncoding: BinaryToTextEncoding, outputEncoding: BinaryToTextEncoding): string;
1517
1545
  /**
1518
1546
  * Returns the Diffie-Hellman prime in the specified `encoding`.
@@ -1582,6 +1610,36 @@ declare module 'crypto' {
1582
1610
  */
1583
1611
  verifyError: number;
1584
1612
  }
1613
+ /**
1614
+ * The `DiffieHellmanGroup` class takes a well-known modp group as its argument.
1615
+ * It works the same as `DiffieHellman`, except that it does not allow changing its keys after creation.
1616
+ * In other words, it does not implement `setPublicKey()` or `setPrivateKey()` methods.
1617
+ *
1618
+ * ```js
1619
+ * const { createDiffieHellmanGroup } = await import('node:crypto');
1620
+ * const dh = createDiffieHellmanGroup('modp1');
1621
+ * ```
1622
+ * The name (e.g. `'modp1'`) is taken from [RFC 2412](https://www.rfc-editor.org/rfc/rfc2412.txt) (modp1 and 2) and [RFC 3526](https://www.rfc-editor.org/rfc/rfc3526.txt):
1623
+ * ```bash
1624
+ * $ perl -ne 'print "$1\n" if /"(modp\d+)"/' src/node_crypto_groups.h
1625
+ * modp1 # 768 bits
1626
+ * modp2 # 1024 bits
1627
+ * modp5 # 1536 bits
1628
+ * modp14 # 2048 bits
1629
+ * modp15 # etc.
1630
+ * modp16
1631
+ * modp17
1632
+ * modp18
1633
+ * ```
1634
+ * @since v0.7.5
1635
+ */
1636
+ const DiffieHellmanGroup: DiffieHellmanGroupConstructor;
1637
+ interface DiffieHellmanGroupConstructor {
1638
+ new(name: string): DiffieHellmanGroup;
1639
+ (name: string): DiffieHellmanGroup;
1640
+ readonly prototype: DiffieHellmanGroup;
1641
+ }
1642
+ type DiffieHellmanGroup = Omit<DiffieHellman, 'setPublicKey' | 'setPrivateKey'>;
1585
1643
  /**
1586
1644
  * Creates a predefined `DiffieHellmanGroup` key exchange object. The
1587
1645
  * supported groups are: `'modp1'`, `'modp2'`, `'modp5'` (defined in [RFC 2412](https://www.rfc-editor.org/rfc/rfc2412.txt), but see `Caveats`) and `'modp14'`, `'modp15'`,`'modp16'`, `'modp17'`,
@@ -1612,7 +1670,12 @@ declare module 'crypto' {
1612
1670
  * ```
1613
1671
  * @since v0.7.5
1614
1672
  */
1615
- function getDiffieHellman(groupName: string): DiffieHellman;
1673
+ function getDiffieHellman(groupName: string): DiffieHellmanGroup;
1674
+ /**
1675
+ * An alias for {@link getDiffieHellman}
1676
+ * @since v0.9.3
1677
+ */
1678
+ function createDiffieHellmanGroup(name: string): DiffieHellmanGroup;
1616
1679
  /**
1617
1680
  * Provides an asynchronous Password-Based Key Derivation Function 2 (PBKDF2)
1618
1681
  * implementation. A selected HMAC digest algorithm specified by `digest` is
@@ -2094,6 +2157,12 @@ declare module 'crypto' {
2094
2157
  * @return `1` if and only if a FIPS compliant crypto provider is currently in use, `0` otherwise. A future semver-major release may change the return type of this API to a {boolean}.
2095
2158
  */
2096
2159
  function getFips(): 1 | 0;
2160
+ /**
2161
+ * Enables the FIPS compliant crypto provider in a FIPS-enabled Node.js build. Throws an error if FIPS mode is not available.
2162
+ * @since v10.0.0
2163
+ * @param bool `true` to enable FIPS mode.
2164
+ */
2165
+ function setFips(bool: boolean): void;
2097
2166
  /**
2098
2167
  * ```js
2099
2168
  * const {
@@ -2237,11 +2306,11 @@ declare module 'crypto' {
2237
2306
  * If `encoding` is specified, a string is returned; otherwise a `Buffer` is
2238
2307
  * returned.
2239
2308
  * @since v0.11.14
2240
- * @param encoding The `encoding` of the return value.
2309
+ * @param [encoding] The `encoding` of the return value.
2241
2310
  * @param [format='uncompressed']
2242
2311
  * @return The EC Diffie-Hellman public key in the specified `encoding` and `format`.
2243
2312
  */
2244
- getPublicKey(): Buffer;
2313
+ getPublicKey(encoding?: null, format?: ECDHKeyFormat): Buffer;
2245
2314
  getPublicKey(encoding: BinaryToTextEncoding, format?: ECDHKeyFormat): string;
2246
2315
  /**
2247
2316
  * Sets the EC Diffie-Hellman private key.
@@ -2272,7 +2341,8 @@ declare module 'crypto' {
2272
2341
  * comparing HMAC digests or secret values like authentication cookies or [capability urls](https://www.w3.org/TR/capability-urls/).
2273
2342
  *
2274
2343
  * `a` and `b` must both be `Buffer`s, `TypedArray`s, or `DataView`s, and they
2275
- * must have the same byte length.
2344
+ * must have the same byte length. An error is thrown if `a` and `b` have
2345
+ * different byte lengths.
2276
2346
  *
2277
2347
  * If at least one of `a` and `b` is a `TypedArray` with more than one byte per
2278
2348
  * entry, such as `Uint16Array`, the result will be computed using the platform
@@ -3054,7 +3124,7 @@ declare module 'crypto' {
3054
3124
  /**
3055
3125
  * Generates a random [RFC 4122](https://www.rfc-editor.org/rfc/rfc4122.txt) version 4 UUID. The UUID is generated using a
3056
3126
  * cryptographic pseudorandom number generator.
3057
- * @since v15.6.0
3127
+ * @since v15.6.0, v14.17.0
3058
3128
  */
3059
3129
  function randomUUID(options?: RandomUUIDOptions): string;
3060
3130
  interface X509CheckOptions {
@@ -3094,12 +3164,16 @@ declare module 'crypto' {
3094
3164
  */
3095
3165
  class X509Certificate {
3096
3166
  /**
3097
- * Will be \`true\` if this is a Certificate Authority (ca) certificate.
3167
+ * Will be \`true\` if this is a Certificate Authority (CA) certificate.
3098
3168
  * @since v15.6.0
3099
3169
  */
3100
3170
  readonly ca: boolean;
3101
3171
  /**
3102
3172
  * The SHA-1 fingerprint of this certificate.
3173
+ *
3174
+ * Because SHA-1 is cryptographically broken and because the security of SHA-1 is
3175
+ * significantly worse than that of algorithms that are commonly used to sign
3176
+ * certificates, consider using `x509.fingerprint256` instead.
3103
3177
  * @since v15.6.0
3104
3178
  */
3105
3179
  readonly fingerprint: string;
@@ -3158,6 +3232,10 @@ declare module 'crypto' {
3158
3232
  readonly raw: Buffer;
3159
3233
  /**
3160
3234
  * The serial number of this certificate.
3235
+ *
3236
+ * Serial numbers are assigned by certificate authorities and do not uniquely
3237
+ * identify certificates. Consider using `x509.fingerprint256` as a unique
3238
+ * identifier instead.
3161
3239
  * @since v15.6.0
3162
3240
  */
3163
3241
  readonly serialNumber: string;
@@ -3174,18 +3252,50 @@ declare module 'crypto' {
3174
3252
  constructor(buffer: BinaryLike);
3175
3253
  /**
3176
3254
  * Checks whether the certificate matches the given email address.
3255
+ *
3256
+ * If the `'subject'` option is undefined or set to `'default'`, the certificate
3257
+ * subject is only considered if the subject alternative name extension either does
3258
+ * not exist or does not contain any email addresses.
3259
+ *
3260
+ * If the `'subject'` option is set to `'always'` and if the subject alternative
3261
+ * name extension either does not exist or does not contain a matching email
3262
+ * address, the certificate subject is considered.
3263
+ *
3264
+ * If the `'subject'` option is set to `'never'`, the certificate subject is never
3265
+ * considered, even if the certificate contains no subject alternative names.
3177
3266
  * @since v15.6.0
3178
3267
  * @return Returns `email` if the certificate matches, `undefined` if it does not.
3179
3268
  */
3180
3269
  checkEmail(email: string, options?: Pick<X509CheckOptions, 'subject'>): string | undefined;
3181
3270
  /**
3182
3271
  * Checks whether the certificate matches the given host name.
3272
+ *
3273
+ * If the certificate matches the given host name, the matching subject name is
3274
+ * returned. The returned name might be an exact match (e.g., `foo.example.com`)
3275
+ * or it might contain wildcards (e.g., `*.example.com`). Because host name
3276
+ * comparisons are case-insensitive, the returned subject name might also differ
3277
+ * from the given `name` in capitalization.
3278
+ *
3279
+ * If the `'subject'` option is undefined or set to `'default'`, the certificate
3280
+ * subject is only considered if the subject alternative name extension either does
3281
+ * not exist or does not contain any DNS names. This behavior is consistent with [RFC 2818](https://www.rfc-editor.org/rfc/rfc2818.txt) ("HTTP Over TLS").
3282
+ *
3283
+ * If the `'subject'` option is set to `'always'` and if the subject alternative
3284
+ * name extension either does not exist or does not contain a matching DNS name,
3285
+ * the certificate subject is considered.
3286
+ *
3287
+ * If the `'subject'` option is set to `'never'`, the certificate subject is never
3288
+ * considered, even if the certificate contains no subject alternative names.
3183
3289
  * @since v15.6.0
3184
- * @return Returns `name` if the certificate matches, `undefined` if it does not.
3290
+ * @return Returns a subject name that matches `name`, or `undefined` if no subject name matches `name`.
3185
3291
  */
3186
3292
  checkHost(name: string, options?: X509CheckOptions): string | undefined;
3187
3293
  /**
3188
3294
  * Checks whether the certificate matches the given IP address (IPv4 or IPv6).
3295
+ *
3296
+ * Only [RFC 5280](https://www.rfc-editor.org/rfc/rfc5280.txt) `iPAddress` subject alternative names are considered, and they
3297
+ * must match the given `ip` address exactly. Other subject alternative names as
3298
+ * well as the subject field of the certificate are ignored.
3189
3299
  * @since v15.6.0
3190
3300
  * @return Returns `ip` if the certificate matches, `undefined` if it does not.
3191
3301
  */
@@ -3329,8 +3439,524 @@ declare module 'crypto' {
3329
3439
  * @return `true` if the candidate is a prime with an error probability less than `0.25 ** options.checks`.
3330
3440
  */
3331
3441
  function checkPrimeSync(candidate: LargeNumberLike, options?: CheckPrimeOptions): boolean;
3442
+ /**
3443
+ * Load and set the `engine` for some or all OpenSSL functions (selected by flags).
3444
+ *
3445
+ * `engine` could be either an id or a path to the engine's shared library.
3446
+ *
3447
+ * The optional `flags` argument uses `ENGINE_METHOD_ALL` by default.
3448
+ * The `flags` is a bit field taking one of or a mix of the following flags (defined in `crypto.constants`):
3449
+ *
3450
+ * - `crypto.constants.ENGINE_METHOD_RSA`
3451
+ * - `crypto.constants.ENGINE_METHOD_DSA`
3452
+ * - `crypto.constants.ENGINE_METHOD_DH`
3453
+ * - `crypto.constants.ENGINE_METHOD_RAND`
3454
+ * - `crypto.constants.ENGINE_METHOD_EC`
3455
+ * - `crypto.constants.ENGINE_METHOD_CIPHERS`
3456
+ * - `crypto.constants.ENGINE_METHOD_DIGESTS`
3457
+ * - `crypto.constants.ENGINE_METHOD_PKEY_METHS`
3458
+ * - `crypto.constants.ENGINE_METHOD_PKEY_ASN1_METHS`
3459
+ * - `crypto.constants.ENGINE_METHOD_ALL`
3460
+ * - `crypto.constants.ENGINE_METHOD_NONE`
3461
+ *
3462
+ * The flags below are deprecated in OpenSSL-1.1.0.
3463
+ *
3464
+ * - `crypto.constants.ENGINE_METHOD_ECDH`
3465
+ * - `crypto.constants.ENGINE_METHOD_ECDSA`
3466
+ * - `crypto.constants.ENGINE_METHOD_STORE`
3467
+ * @since v0.11.11
3468
+ * @param [flags=crypto.constants.ENGINE_METHOD_ALL]
3469
+ */
3470
+ function setEngine(engine: string, flags?: number): void;
3471
+ /**
3472
+ * A convenient alias for `crypto.webcrypto.getRandomValues()`.
3473
+ * This implementation is not compliant with the Web Crypto spec,
3474
+ * to write web-compatible code use `crypto.webcrypto.getRandomValues()` instead.
3475
+ * @since v17.4.0
3476
+ * @returns Returns `typedArray`.
3477
+ */
3478
+ function getRandomValues<T extends webcrypto.BufferSource>(typedArray: T): T;
3479
+ /**
3480
+ * A convenient alias for `crypto.webcrypto.subtle`.
3481
+ * @since v17.4.0
3482
+ */
3483
+ const subtle: webcrypto.SubtleCrypto;
3484
+ /**
3485
+ * An implementation of the Web Crypto API standard.
3486
+ *
3487
+ * See the {@link https://nodejs.org/docs/latest/api/webcrypto.html Web Crypto API documentation} for details.
3488
+ * @since v15.0.0
3489
+ */
3490
+ const webcrypto: webcrypto.Crypto;
3332
3491
  namespace webcrypto {
3333
- class CryptoKey {} // placeholder
3492
+ type BufferSource = ArrayBufferView | ArrayBuffer;
3493
+ type KeyFormat = 'jwk' | 'pkcs8' | 'raw' | 'spki';
3494
+ type KeyType = 'private' | 'public' | 'secret';
3495
+ type KeyUsage = 'decrypt' | 'deriveBits' | 'deriveKey' | 'encrypt' | 'sign' | 'unwrapKey' | 'verify' | 'wrapKey';
3496
+ type AlgorithmIdentifier = Algorithm | string;
3497
+ type HashAlgorithmIdentifier = AlgorithmIdentifier;
3498
+ type NamedCurve = string;
3499
+ type BigInteger = Uint8Array;
3500
+ interface AesCbcParams extends Algorithm {
3501
+ iv: BufferSource;
3502
+ }
3503
+ interface AesCtrParams extends Algorithm {
3504
+ counter: BufferSource;
3505
+ length: number;
3506
+ }
3507
+ interface AesDerivedKeyParams extends Algorithm {
3508
+ length: number;
3509
+ }
3510
+ interface AesGcmParams extends Algorithm {
3511
+ additionalData?: BufferSource;
3512
+ iv: BufferSource;
3513
+ tagLength?: number;
3514
+ }
3515
+ interface AesKeyAlgorithm extends KeyAlgorithm {
3516
+ length: number;
3517
+ }
3518
+ interface AesKeyGenParams extends Algorithm {
3519
+ length: number;
3520
+ }
3521
+ interface Algorithm {
3522
+ name: string;
3523
+ }
3524
+ interface EcKeyAlgorithm extends KeyAlgorithm {
3525
+ namedCurve: NamedCurve;
3526
+ }
3527
+ interface EcKeyGenParams extends Algorithm {
3528
+ namedCurve: NamedCurve;
3529
+ }
3530
+ interface EcKeyImportParams extends Algorithm {
3531
+ namedCurve: NamedCurve;
3532
+ }
3533
+ interface EcdhKeyDeriveParams extends Algorithm {
3534
+ public: CryptoKey;
3535
+ }
3536
+ interface EcdsaParams extends Algorithm {
3537
+ hash: HashAlgorithmIdentifier;
3538
+ }
3539
+ interface Ed448Params extends Algorithm {
3540
+ context?: BufferSource;
3541
+ }
3542
+ interface HkdfParams extends Algorithm {
3543
+ hash: HashAlgorithmIdentifier;
3544
+ info: BufferSource;
3545
+ salt: BufferSource;
3546
+ }
3547
+ interface HmacImportParams extends Algorithm {
3548
+ hash: HashAlgorithmIdentifier;
3549
+ length?: number;
3550
+ }
3551
+ interface HmacKeyAlgorithm extends KeyAlgorithm {
3552
+ hash: KeyAlgorithm;
3553
+ length: number;
3554
+ }
3555
+ interface HmacKeyGenParams extends Algorithm {
3556
+ hash: HashAlgorithmIdentifier;
3557
+ length?: number;
3558
+ }
3559
+ interface JsonWebKey {
3560
+ alg?: string;
3561
+ crv?: string;
3562
+ d?: string;
3563
+ dp?: string;
3564
+ dq?: string;
3565
+ e?: string;
3566
+ ext?: boolean;
3567
+ k?: string;
3568
+ key_ops?: string[];
3569
+ kty?: string;
3570
+ n?: string;
3571
+ oth?: RsaOtherPrimesInfo[];
3572
+ p?: string;
3573
+ q?: string;
3574
+ qi?: string;
3575
+ use?: string;
3576
+ x?: string;
3577
+ y?: string;
3578
+ }
3579
+ interface KeyAlgorithm {
3580
+ name: string;
3581
+ }
3582
+ interface Pbkdf2Params extends Algorithm {
3583
+ hash: HashAlgorithmIdentifier;
3584
+ iterations: number;
3585
+ salt: BufferSource;
3586
+ }
3587
+ interface RsaHashedImportParams extends Algorithm {
3588
+ hash: HashAlgorithmIdentifier;
3589
+ }
3590
+ interface RsaHashedKeyAlgorithm extends RsaKeyAlgorithm {
3591
+ hash: KeyAlgorithm;
3592
+ }
3593
+ interface RsaHashedKeyGenParams extends RsaKeyGenParams {
3594
+ hash: HashAlgorithmIdentifier;
3595
+ }
3596
+ interface RsaKeyAlgorithm extends KeyAlgorithm {
3597
+ modulusLength: number;
3598
+ publicExponent: BigInteger;
3599
+ }
3600
+ interface RsaKeyGenParams extends Algorithm {
3601
+ modulusLength: number;
3602
+ publicExponent: BigInteger;
3603
+ }
3604
+ interface RsaOaepParams extends Algorithm {
3605
+ label?: BufferSource;
3606
+ }
3607
+ interface RsaOtherPrimesInfo {
3608
+ d?: string;
3609
+ r?: string;
3610
+ t?: string;
3611
+ }
3612
+ interface RsaPssParams extends Algorithm {
3613
+ saltLength: number;
3614
+ }
3615
+ /**
3616
+ * Calling `require('node:crypto').webcrypto` returns an instance of the `Crypto` class.
3617
+ * `Crypto` is a singleton that provides access to the remainder of the crypto API.
3618
+ * @since v15.0.0
3619
+ */
3620
+ interface Crypto {
3621
+ /**
3622
+ * Provides access to the `SubtleCrypto` API.
3623
+ * @since v15.0.0
3624
+ */
3625
+ readonly subtle: SubtleCrypto;
3626
+ /**
3627
+ * Generates cryptographically strong random values.
3628
+ * The given `typedArray` is filled with random values, and a reference to `typedArray` is returned.
3629
+ *
3630
+ * The given `typedArray` must be an integer-based instance of {@link NodeJS.TypedArray}, i.e. `Float32Array` and `Float64Array` are not accepted.
3631
+ *
3632
+ * An error will be thrown if the given `typedArray` is larger than 65,536 bytes.
3633
+ * @since v15.0.0
3634
+ */
3635
+ getRandomValues<T extends Exclude<NodeJS.TypedArray, Float32Array | Float64Array>>(typedArray: T): T;
3636
+ /**
3637
+ * Generates a random {@link https://www.rfc-editor.org/rfc/rfc4122.txt RFC 4122} version 4 UUID.
3638
+ * The UUID is generated using a cryptographic pseudorandom number generator.
3639
+ * @since v16.7.0
3640
+ */
3641
+ randomUUID(): string;
3642
+ CryptoKey: CryptoKeyConstructor;
3643
+ }
3644
+ // This constructor throws ILLEGAL_CONSTRUCTOR so it should not be newable.
3645
+ interface CryptoKeyConstructor {
3646
+ /** Illegal constructor */
3647
+ (_: { readonly _: unique symbol }): never; // Allows instanceof to work but not be callable by the user.
3648
+ readonly length: 0;
3649
+ readonly name: 'CryptoKey';
3650
+ readonly prototype: CryptoKey;
3651
+ }
3652
+ /**
3653
+ * @since v15.0.0
3654
+ */
3655
+ interface CryptoKey {
3656
+ /**
3657
+ * An object detailing the algorithm for which the key can be used along with additional algorithm-specific parameters.
3658
+ * @since v15.0.0
3659
+ */
3660
+ readonly algorithm: KeyAlgorithm;
3661
+ /**
3662
+ * When `true`, the {@link CryptoKey} can be extracted using either `subtleCrypto.exportKey()` or `subtleCrypto.wrapKey()`.
3663
+ * @since v15.0.0
3664
+ */
3665
+ readonly extractable: boolean;
3666
+ /**
3667
+ * A string identifying whether the key is a symmetric (`'secret'`) or asymmetric (`'private'` or `'public'`) key.
3668
+ * @since v15.0.0
3669
+ */
3670
+ readonly type: KeyType;
3671
+ /**
3672
+ * An array of strings identifying the operations for which the key may be used.
3673
+ *
3674
+ * The possible usages are:
3675
+ * - `'encrypt'` - The key may be used to encrypt data.
3676
+ * - `'decrypt'` - The key may be used to decrypt data.
3677
+ * - `'sign'` - The key may be used to generate digital signatures.
3678
+ * - `'verify'` - The key may be used to verify digital signatures.
3679
+ * - `'deriveKey'` - The key may be used to derive a new key.
3680
+ * - `'deriveBits'` - The key may be used to derive bits.
3681
+ * - `'wrapKey'` - The key may be used to wrap another key.
3682
+ * - `'unwrapKey'` - The key may be used to unwrap another key.
3683
+ *
3684
+ * Valid key usages depend on the key algorithm (identified by `cryptokey.algorithm.name`).
3685
+ * @since v15.0.0
3686
+ */
3687
+ readonly usages: KeyUsage[];
3688
+ }
3689
+ /**
3690
+ * The `CryptoKeyPair` is a simple dictionary object with `publicKey` and `privateKey` properties, representing an asymmetric key pair.
3691
+ * @since v15.0.0
3692
+ */
3693
+ interface CryptoKeyPair {
3694
+ /**
3695
+ * A {@link CryptoKey} whose type will be `'private'`.
3696
+ * @since v15.0.0
3697
+ */
3698
+ privateKey: CryptoKey;
3699
+ /**
3700
+ * A {@link CryptoKey} whose type will be `'public'`.
3701
+ * @since v15.0.0
3702
+ */
3703
+ publicKey: CryptoKey;
3704
+ }
3705
+ /**
3706
+ * @since v15.0.0
3707
+ */
3708
+ interface SubtleCrypto {
3709
+ /**
3710
+ * Using the method and parameters specified in `algorithm` and the keying material provided by `key`,
3711
+ * `subtle.decrypt()` attempts to decipher the provided `data`. If successful,
3712
+ * the returned promise will be resolved with an `<ArrayBuffer>` containing the plaintext result.
3713
+ *
3714
+ * The algorithms currently supported include:
3715
+ *
3716
+ * - `'RSA-OAEP'`
3717
+ * - `'AES-CTR'`
3718
+ * - `'AES-CBC'`
3719
+ * - `'AES-GCM'`
3720
+ * @since v15.0.0
3721
+ */
3722
+ decrypt(algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer>;
3723
+ /**
3724
+ * Using the method and parameters specified in `algorithm` and the keying material provided by `baseKey`,
3725
+ * `subtle.deriveBits()` attempts to generate `length` bits.
3726
+ * The Node.js implementation requires that when `length` is a number it must be multiple of `8`.
3727
+ * When `length` is `null` the maximum number of bits for a given algorithm is generated. This is allowed
3728
+ * for the `'ECDH'`, `'X25519'`, and `'X448'` algorithms.
3729
+ * If successful, the returned promise will be resolved with an `<ArrayBuffer>` containing the generated data.
3730
+ *
3731
+ * The algorithms currently supported include:
3732
+ *
3733
+ * - `'ECDH'`
3734
+ * - `'X25519'`
3735
+ * - `'X448'`
3736
+ * - `'HKDF'`
3737
+ * - `'PBKDF2'`
3738
+ * @since v15.0.0
3739
+ */
3740
+ deriveBits(algorithm: EcdhKeyDeriveParams, baseKey: CryptoKey, length: number | null): Promise<ArrayBuffer>;
3741
+ deriveBits(algorithm: AlgorithmIdentifier | HkdfParams | Pbkdf2Params, baseKey: CryptoKey, length: number): Promise<ArrayBuffer>;
3742
+ /**
3743
+ * Using the method and parameters specified in `algorithm`, and the keying material provided by `baseKey`,
3744
+ * `subtle.deriveKey()` attempts to generate a new <CryptoKey>` based on the method and parameters in `derivedKeyAlgorithm`.
3745
+ *
3746
+ * Calling `subtle.deriveKey()` is equivalent to calling `subtle.deriveBits()` to generate raw keying material,
3747
+ * then passing the result into the `subtle.importKey()` method using the `deriveKeyAlgorithm`, `extractable`, and `keyUsages` parameters as input.
3748
+ *
3749
+ * The algorithms currently supported include:
3750
+ *
3751
+ * - `'ECDH'`
3752
+ * - `'X25519'`
3753
+ * - `'X448'`
3754
+ * - `'HKDF'`
3755
+ * - `'PBKDF2'`
3756
+ * @param keyUsages See {@link https://nodejs.org/docs/latest/api/webcrypto.html#cryptokeyusages Key usages}.
3757
+ * @since v15.0.0
3758
+ */
3759
+ deriveKey(
3760
+ algorithm: AlgorithmIdentifier | EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params,
3761
+ baseKey: CryptoKey,
3762
+ derivedKeyAlgorithm: AlgorithmIdentifier | AesDerivedKeyParams | HmacImportParams | HkdfParams | Pbkdf2Params,
3763
+ extractable: boolean,
3764
+ keyUsages: ReadonlyArray<KeyUsage>
3765
+ ): Promise<CryptoKey>;
3766
+ /**
3767
+ * Using the method identified by `algorithm`, `subtle.digest()` attempts to generate a digest of `data`.
3768
+ * If successful, the returned promise is resolved with an `<ArrayBuffer>` containing the computed digest.
3769
+ *
3770
+ * If `algorithm` is provided as a `<string>`, it must be one of:
3771
+ *
3772
+ * - `'SHA-1'`
3773
+ * - `'SHA-256'`
3774
+ * - `'SHA-384'`
3775
+ * - `'SHA-512'`
3776
+ *
3777
+ * If `algorithm` is provided as an `<Object>`, it must have a `name` property whose value is one of the above.
3778
+ * @since v15.0.0
3779
+ */
3780
+ digest(algorithm: AlgorithmIdentifier, data: BufferSource): Promise<ArrayBuffer>;
3781
+ /**
3782
+ * Using the method and parameters specified by `algorithm` and the keying material provided by `key`,
3783
+ * `subtle.encrypt()` attempts to encipher `data`. If successful,
3784
+ * the returned promise is resolved with an `<ArrayBuffer>` containing the encrypted result.
3785
+ *
3786
+ * The algorithms currently supported include:
3787
+ *
3788
+ * - `'RSA-OAEP'`
3789
+ * - `'AES-CTR'`
3790
+ * - `'AES-CBC'`
3791
+ * - `'AES-GCM'`
3792
+ * @since v15.0.0
3793
+ */
3794
+ encrypt(algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer>;
3795
+ /**
3796
+ * Exports the given key into the specified format, if supported.
3797
+ *
3798
+ * If the `<CryptoKey>` is not extractable, the returned promise will reject.
3799
+ *
3800
+ * When `format` is either `'pkcs8'` or `'spki'` and the export is successful,
3801
+ * the returned promise will be resolved with an `<ArrayBuffer>` containing the exported key data.
3802
+ *
3803
+ * When `format` is `'jwk'` and the export is successful, the returned promise will be resolved with a
3804
+ * JavaScript object conforming to the {@link https://tools.ietf.org/html/rfc7517 JSON Web Key} specification.
3805
+ * @param format Must be one of `'raw'`, `'pkcs8'`, `'spki'`, or `'jwk'`.
3806
+ * @returns `<Promise>` containing `<ArrayBuffer>`.
3807
+ * @since v15.0.0
3808
+ */
3809
+ exportKey(format: 'jwk', key: CryptoKey): Promise<JsonWebKey>;
3810
+ exportKey(format: Exclude<KeyFormat, 'jwk'>, key: CryptoKey): Promise<ArrayBuffer>;
3811
+ /**
3812
+ * Using the method and parameters provided in `algorithm`,
3813
+ * `subtle.generateKey()` attempts to generate new keying material.
3814
+ * Depending the method used, the method may generate either a single `<CryptoKey>` or a `<CryptoKeyPair>`.
3815
+ *
3816
+ * The `<CryptoKeyPair>` (public and private key) generating algorithms supported include:
3817
+ *
3818
+ * - `'RSASSA-PKCS1-v1_5'`
3819
+ * - `'RSA-PSS'`
3820
+ * - `'RSA-OAEP'`
3821
+ * - `'ECDSA'`
3822
+ * - `'Ed25519'`
3823
+ * - `'Ed448'`
3824
+ * - `'ECDH'`
3825
+ * - `'X25519'`
3826
+ * - `'X448'`
3827
+ * The `<CryptoKey>` (secret key) generating algorithms supported include:
3828
+ *
3829
+ * - `'HMAC'`
3830
+ * - `'AES-CTR'`
3831
+ * - `'AES-CBC'`
3832
+ * - `'AES-GCM'`
3833
+ * - `'AES-KW'`
3834
+ * @param keyUsages See {@link https://nodejs.org/docs/latest/api/webcrypto.html#cryptokeyusages Key usages}.
3835
+ * @since v15.0.0
3836
+ */
3837
+ generateKey(algorithm: RsaHashedKeyGenParams | EcKeyGenParams, extractable: boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKeyPair>;
3838
+ generateKey(algorithm: AesKeyGenParams | HmacKeyGenParams | Pbkdf2Params, extractable: boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>;
3839
+ generateKey(algorithm: AlgorithmIdentifier, extractable: boolean, keyUsages: KeyUsage[]): Promise<CryptoKeyPair | CryptoKey>;
3840
+ /**
3841
+ * The `subtle.importKey()` method attempts to interpret the provided `keyData` as the given `format`
3842
+ * to create a `<CryptoKey>` instance using the provided `algorithm`, `extractable`, and `keyUsages` arguments.
3843
+ * If the import is successful, the returned promise will be resolved with the created `<CryptoKey>`.
3844
+ *
3845
+ * If importing a `'PBKDF2'` key, `extractable` must be `false`.
3846
+ * @param format Must be one of `'raw'`, `'pkcs8'`, `'spki'`, or `'jwk'`.
3847
+ * @param keyUsages See {@link https://nodejs.org/docs/latest/api/webcrypto.html#cryptokeyusages Key usages}.
3848
+ * @since v15.0.0
3849
+ */
3850
+ importKey(
3851
+ format: 'jwk',
3852
+ keyData: JsonWebKey,
3853
+ algorithm: AlgorithmIdentifier | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | AesKeyAlgorithm,
3854
+ extractable: boolean,
3855
+ keyUsages: ReadonlyArray<KeyUsage>
3856
+ ): Promise<CryptoKey>;
3857
+ importKey(
3858
+ format: Exclude<KeyFormat, 'jwk'>,
3859
+ keyData: BufferSource,
3860
+ algorithm: AlgorithmIdentifier | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | AesKeyAlgorithm,
3861
+ extractable: boolean,
3862
+ keyUsages: KeyUsage[]
3863
+ ): Promise<CryptoKey>;
3864
+ /**
3865
+ * Using the method and parameters given by `algorithm` and the keying material provided by `key`,
3866
+ * `subtle.sign()` attempts to generate a cryptographic signature of `data`. If successful,
3867
+ * the returned promise is resolved with an `<ArrayBuffer>` containing the generated signature.
3868
+ *
3869
+ * The algorithms currently supported include:
3870
+ *
3871
+ * - `'RSASSA-PKCS1-v1_5'`
3872
+ * - `'RSA-PSS'`
3873
+ * - `'ECDSA'`
3874
+ * - `'Ed25519'`
3875
+ * - `'Ed448'`
3876
+ * - `'HMAC'`
3877
+ * @since v15.0.0
3878
+ */
3879
+ sign(algorithm: AlgorithmIdentifier | RsaPssParams | EcdsaParams | Ed448Params, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer>;
3880
+ /**
3881
+ * In cryptography, "wrapping a key" refers to exporting and then encrypting the keying material.
3882
+ * The `subtle.unwrapKey()` method attempts to decrypt a wrapped key and create a `<CryptoKey>` instance.
3883
+ * It is equivalent to calling `subtle.decrypt()` first on the encrypted key data (using the `wrappedKey`, `unwrapAlgo`, and `unwrappingKey` arguments as input)
3884
+ * then passing the results in to the `subtle.importKey()` method using the `unwrappedKeyAlgo`, `extractable`, and `keyUsages` arguments as inputs.
3885
+ * If successful, the returned promise is resolved with a `<CryptoKey>` object.
3886
+ *
3887
+ * The wrapping algorithms currently supported include:
3888
+ *
3889
+ * - `'RSA-OAEP'`
3890
+ * - `'AES-CTR'`
3891
+ * - `'AES-CBC'`
3892
+ * - `'AES-GCM'`
3893
+ * - `'AES-KW'`
3894
+ *
3895
+ * The unwrapped key algorithms supported include:
3896
+ *
3897
+ * - `'RSASSA-PKCS1-v1_5'`
3898
+ * - `'RSA-PSS'`
3899
+ * - `'RSA-OAEP'`
3900
+ * - `'ECDSA'`
3901
+ * - `'Ed25519'`
3902
+ * - `'Ed448'`
3903
+ * - `'ECDH'`
3904
+ * - `'X25519'`
3905
+ * - `'X448'`
3906
+ * - `'HMAC'`
3907
+ * - `'AES-CTR'`
3908
+ * - `'AES-CBC'`
3909
+ * - `'AES-GCM'`
3910
+ * - `'AES-KW'`
3911
+ * @param format Must be one of `'raw'`, `'pkcs8'`, `'spki'`, or `'jwk'`.
3912
+ * @param keyUsages See {@link https://nodejs.org/docs/latest/api/webcrypto.html#cryptokeyusages Key usages}.
3913
+ * @since v15.0.0
3914
+ */
3915
+ unwrapKey(
3916
+ format: KeyFormat,
3917
+ wrappedKey: BufferSource,
3918
+ unwrappingKey: CryptoKey,
3919
+ unwrapAlgorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams,
3920
+ unwrappedKeyAlgorithm: AlgorithmIdentifier | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | AesKeyAlgorithm,
3921
+ extractable: boolean,
3922
+ keyUsages: KeyUsage[]
3923
+ ): Promise<CryptoKey>;
3924
+ /**
3925
+ * Using the method and parameters given in `algorithm` and the keying material provided by `key`,
3926
+ * `subtle.verify()` attempts to verify that `signature` is a valid cryptographic signature of `data`.
3927
+ * The returned promise is resolved with either `true` or `false`.
3928
+ *
3929
+ * The algorithms currently supported include:
3930
+ *
3931
+ * - `'RSASSA-PKCS1-v1_5'`
3932
+ * - `'RSA-PSS'`
3933
+ * - `'ECDSA'`
3934
+ * - `'Ed25519'`
3935
+ * - `'Ed448'`
3936
+ * - `'HMAC'`
3937
+ * @since v15.0.0
3938
+ */
3939
+ verify(algorithm: AlgorithmIdentifier | RsaPssParams | EcdsaParams | Ed448Params, key: CryptoKey, signature: BufferSource, data: BufferSource): Promise<boolean>;
3940
+ /**
3941
+ * In cryptography, "wrapping a key" refers to exporting and then encrypting the keying material.
3942
+ * The `subtle.wrapKey()` method exports the keying material into the format identified by `format`,
3943
+ * then encrypts it using the method and parameters specified by `wrapAlgo` and the keying material provided by `wrappingKey`.
3944
+ * It is the equivalent to calling `subtle.exportKey()` using `format` and `key` as the arguments,
3945
+ * then passing the result to the `subtle.encrypt()` method using `wrappingKey` and `wrapAlgo` as inputs.
3946
+ * If successful, the returned promise will be resolved with an `<ArrayBuffer>` containing the encrypted key data.
3947
+ *
3948
+ * The wrapping algorithms currently supported include:
3949
+ *
3950
+ * - `'RSA-OAEP'`
3951
+ * - `'AES-CTR'`
3952
+ * - `'AES-CBC'`
3953
+ * - `'AES-GCM'`
3954
+ * - `'AES-KW'`
3955
+ * @param format Must be one of `'raw'`, `'pkcs8'`, `'spki'`, or `'jwk'`.
3956
+ * @since v15.0.0
3957
+ */
3958
+ wrapKey(format: KeyFormat, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams): Promise<ArrayBuffer>;
3959
+ }
3334
3960
  }
3335
3961
  }
3336
3962
  declare module 'node:crypto' {