@types/node 18.11.5 → 20.2.5

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 (97) hide show
  1. node/README.md +2 -2
  2. node/assert.d.ts +86 -75
  3. node/async_hooks.d.ts +66 -37
  4. node/buffer.d.ts +193 -100
  5. node/child_process.d.ts +82 -56
  6. node/cluster.d.ts +12 -12
  7. node/console.d.ts +5 -5
  8. node/crypto.d.ts +233 -235
  9. node/dgram.d.ts +15 -15
  10. node/diagnostics_channel.d.ts +59 -21
  11. node/dns/promises.d.ts +50 -6
  12. node/dns.d.ts +26 -17
  13. node/domain.d.ts +4 -4
  14. node/events.d.ts +111 -65
  15. node/fs/promises.d.ts +99 -47
  16. node/fs.d.ts +244 -73
  17. node/globals.d.ts +6 -3
  18. node/http.d.ts +265 -148
  19. node/http2.d.ts +42 -47
  20. node/https.d.ts +53 -153
  21. node/index.d.ts +2 -1
  22. node/inspector.d.ts +10 -3
  23. node/module.d.ts +6 -4
  24. node/net.d.ts +32 -15
  25. node/os.d.ts +27 -16
  26. node/package.json +9 -4
  27. node/path.d.ts +4 -4
  28. node/perf_hooks.d.ts +28 -15
  29. node/process.d.ts +49 -46
  30. node/punycode.d.ts +1 -1
  31. node/querystring.d.ts +5 -5
  32. node/readline/promises.d.ts +65 -63
  33. node/readline.d.ts +32 -159
  34. node/repl.d.ts +20 -20
  35. node/stream/consumers.d.ts +1 -1
  36. node/stream.d.ts +950 -869
  37. node/string_decoder.d.ts +6 -6
  38. node/test.d.ts +877 -139
  39. node/timers/promises.d.ts +26 -1
  40. node/timers.d.ts +125 -4
  41. node/tls.d.ts +120 -29
  42. node/trace_events.d.ts +20 -9
  43. node/ts4.8/assert.d.ts +86 -75
  44. node/ts4.8/async_hooks.d.ts +66 -37
  45. node/ts4.8/buffer.d.ts +193 -101
  46. node/ts4.8/child_process.d.ts +82 -56
  47. node/ts4.8/cluster.d.ts +12 -12
  48. node/ts4.8/console.d.ts +5 -5
  49. node/ts4.8/crypto.d.ts +230 -233
  50. node/ts4.8/dgram.d.ts +15 -15
  51. node/ts4.8/diagnostics_channel.d.ts +59 -21
  52. node/ts4.8/dns/promises.d.ts +50 -6
  53. node/ts4.8/dns.d.ts +26 -17
  54. node/ts4.8/domain.d.ts +4 -4
  55. node/ts4.8/events.d.ts +111 -65
  56. node/ts4.8/fs/promises.d.ts +97 -46
  57. node/ts4.8/fs.d.ts +244 -73
  58. node/ts4.8/globals.d.ts +21 -12
  59. node/ts4.8/http.d.ts +265 -148
  60. node/ts4.8/http2.d.ts +42 -47
  61. node/ts4.8/https.d.ts +53 -153
  62. node/ts4.8/inspector.d.ts +10 -3
  63. node/ts4.8/module.d.ts +6 -4
  64. node/ts4.8/net.d.ts +33 -16
  65. node/ts4.8/os.d.ts +27 -16
  66. node/ts4.8/path.d.ts +4 -4
  67. node/ts4.8/perf_hooks.d.ts +28 -15
  68. node/ts4.8/process.d.ts +49 -46
  69. node/ts4.8/punycode.d.ts +1 -1
  70. node/ts4.8/querystring.d.ts +5 -5
  71. node/ts4.8/readline/promises.d.ts +65 -63
  72. node/ts4.8/readline.d.ts +32 -159
  73. node/ts4.8/repl.d.ts +20 -20
  74. node/ts4.8/stream/consumers.d.ts +1 -1
  75. node/ts4.8/stream.d.ts +192 -140
  76. node/ts4.8/string_decoder.d.ts +6 -6
  77. node/ts4.8/test.d.ts +877 -139
  78. node/ts4.8/timers/promises.d.ts +26 -1
  79. node/ts4.8/timers.d.ts +125 -4
  80. node/ts4.8/tls.d.ts +120 -29
  81. node/ts4.8/trace_events.d.ts +20 -9
  82. node/ts4.8/tty.d.ts +4 -5
  83. node/ts4.8/url.d.ts +46 -42
  84. node/ts4.8/util.d.ts +325 -123
  85. node/ts4.8/v8.d.ts +253 -14
  86. node/ts4.8/vm.d.ts +417 -32
  87. node/ts4.8/wasi.d.ts +13 -19
  88. node/ts4.8/worker_threads.d.ts +38 -34
  89. node/ts4.8/zlib.d.ts +11 -11
  90. node/tty.d.ts +4 -5
  91. node/url.d.ts +46 -42
  92. node/util.d.ts +325 -123
  93. node/v8.d.ts +253 -14
  94. node/vm.d.ts +417 -32
  95. node/wasi.d.ts +13 -19
  96. node/worker_threads.d.ts +38 -34
  97. node/zlib.d.ts +11 -11
node/crypto.d.ts CHANGED
@@ -1,9 +1,10 @@
1
1
  /**
2
- * The `crypto` module provides cryptographic functionality that includes a set of
3
- * wrappers for OpenSSL's hash, HMAC, cipher, decipher, sign, and verify functions.
2
+ * The `node:crypto` module provides cryptographic functionality that includes a
3
+ * set of wrappers for OpenSSL's hash, HMAC, cipher, decipher, sign, and verify
4
+ * functions.
4
5
  *
5
6
  * ```js
6
- * const { createHmac } = await import('crypto');
7
+ * const { createHmac } = await import('node:crypto');
7
8
  *
8
9
  * const secret = 'abcdefg';
9
10
  * const hash = createHmac('sha256', secret)
@@ -13,7 +14,7 @@
13
14
  * // Prints:
14
15
  * // c0fa1bc00531bd78ef38c628449c5102aeabd49b5dc3a2a516ea6ea959d6658e
15
16
  * ```
16
- * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/crypto.js)
17
+ * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/crypto.js)
17
18
  */
18
19
  declare module 'crypto' {
19
20
  import * as stream from 'node:stream';
@@ -25,7 +26,7 @@ declare module 'crypto' {
25
26
  * `<keygen>` is deprecated since [HTML 5.2](https://www.w3.org/TR/html52/changes.html#features-removed) and new projects
26
27
  * should not use this element anymore.
27
28
  *
28
- * The `crypto` module provides the `Certificate` class for working with SPKAC
29
+ * The `node:crypto` module provides the `Certificate` class for working with SPKAC
29
30
  * data. The most common usage is handling output generated by the HTML5`<keygen>` element. Node.js uses [OpenSSL's SPKAC
30
31
  * implementation](https://www.openssl.org/docs/man1.1.0/apps/openssl-spkac.html) internally.
31
32
  * @since v0.11.8
@@ -33,7 +34,7 @@ declare module 'crypto' {
33
34
  class Certificate {
34
35
  /**
35
36
  * ```js
36
- * const { Certificate } = await import('crypto');
37
+ * const { Certificate } = await import('node:crypto');
37
38
  * const spkac = getSpkacSomehow();
38
39
  * const challenge = Certificate.exportChallenge(spkac);
39
40
  * console.log(challenge.toString('utf8'));
@@ -46,7 +47,7 @@ declare module 'crypto' {
46
47
  static exportChallenge(spkac: BinaryLike): Buffer;
47
48
  /**
48
49
  * ```js
49
- * const { Certificate } = await import('crypto');
50
+ * const { Certificate } = await import('node:crypto');
50
51
  * const spkac = getSpkacSomehow();
51
52
  * const publicKey = Certificate.exportPublicKey(spkac);
52
53
  * console.log(publicKey);
@@ -59,8 +60,8 @@ declare module 'crypto' {
59
60
  static exportPublicKey(spkac: BinaryLike, encoding?: string): Buffer;
60
61
  /**
61
62
  * ```js
62
- * import { Buffer } from 'buffer';
63
- * const { Certificate } = await import('crypto');
63
+ * import { Buffer } from 'node:buffer';
64
+ * const { Certificate } = await import('node:crypto');
64
65
  *
65
66
  * const spkac = getSpkacSomehow();
66
67
  * console.log(Certificate.verifySpkac(Buffer.from(spkac)));
@@ -95,7 +96,7 @@ declare module 'crypto' {
95
96
  verifySpkac(spkac: NodeJS.ArrayBufferView): boolean;
96
97
  }
97
98
  namespace constants {
98
- // https://nodejs.org/dist/latest-v10.x/docs/api/crypto.html#crypto_crypto_constants
99
+ // https://nodejs.org/dist/latest-v20.x/docs/api/crypto.html#crypto-constants
99
100
  const OPENSSL_VERSION_NUMBER: number;
100
101
  /** Applies multiple bug workarounds within OpenSSL. See https://www.openssl.org/docs/man1.0.2/ssl/SSL_CTX_set_options.html for detail. */
101
102
  const SSL_OP_ALL: number;
@@ -111,18 +112,8 @@ declare module 'crypto' {
111
112
  const SSL_OP_CRYPTOPRO_TLSEXT_BUG: number;
112
113
  /** Instructs OpenSSL to disable a SSL 3.0/TLS 1.0 vulnerability workaround added in OpenSSL 0.9.6d. */
113
114
  const SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS: number;
114
- /** Instructs OpenSSL to always use the tmp_rsa key when performing RSA operations. */
115
- const SSL_OP_EPHEMERAL_RSA: number;
116
115
  /** Allows initial connection to servers that do not support RI. */
117
116
  const SSL_OP_LEGACY_SERVER_CONNECT: number;
118
- const SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER: number;
119
- const SSL_OP_MICROSOFT_SESS_ID_BUG: number;
120
- /** Instructs OpenSSL to disable the workaround for a man-in-the-middle protocol-version vulnerability in the SSL 2.0 server implementation. */
121
- const SSL_OP_MSIE_SSLV2_RSA_PADDING: number;
122
- const SSL_OP_NETSCAPE_CA_DN_BUG: number;
123
- const SSL_OP_NETSCAPE_CHALLENGE_BUG: number;
124
- const SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG: number;
125
- const SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG: number;
126
117
  /** Instructs OpenSSL to disable support for SSL/TLS compression. */
127
118
  const SSL_OP_NO_COMPRESSION: number;
128
119
  const SSL_OP_NO_QUERY_MTU: number;
@@ -134,16 +125,6 @@ declare module 'crypto' {
134
125
  const SSL_OP_NO_TLSv1: number;
135
126
  const SSL_OP_NO_TLSv1_1: number;
136
127
  const SSL_OP_NO_TLSv1_2: number;
137
- const SSL_OP_PKCS1_CHECK_1: number;
138
- const SSL_OP_PKCS1_CHECK_2: number;
139
- /** Instructs OpenSSL to always create a new key when using temporary/ephemeral DH parameters. */
140
- const SSL_OP_SINGLE_DH_USE: number;
141
- /** Instructs OpenSSL to always create a new key when using temporary/ephemeral ECDH parameters. */
142
- const SSL_OP_SINGLE_ECDH_USE: number;
143
- const SSL_OP_SSLEAY_080_CLIENT_DH_BUG: number;
144
- const SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG: number;
145
- const SSL_OP_TLS_BLOCK_PADDING_BUG: number;
146
- const SSL_OP_TLS_D5_BUG: number;
147
128
  /** Instructs OpenSSL to disable version rollback attack detection. */
148
129
  const SSL_OP_TLS_ROLLBACK_BUG: number;
149
130
  const ENGINE_METHOD_RSA: number;
@@ -161,7 +142,6 @@ declare module 'crypto' {
161
142
  const DH_CHECK_P_NOT_PRIME: number;
162
143
  const DH_UNABLE_TO_CHECK_GENERATOR: number;
163
144
  const DH_NOT_SUITABLE_GENERATOR: number;
164
- const ALPN_ENABLED: number;
165
145
  const RSA_PKCS1_PADDING: number;
166
146
  const RSA_SSLV23_PADDING: number;
167
147
  const RSA_NO_PADDING: number;
@@ -206,12 +186,12 @@ declare module 'crypto' {
206
186
  *
207
187
  * ```js
208
188
  * import {
209
- * createReadStream
210
- * } from 'fs';
211
- * import { argv } from 'process';
189
+ * createReadStream,
190
+ * } from 'node:fs';
191
+ * import { argv } from 'node:process';
212
192
  * const {
213
- * createHash
214
- * } = await import('crypto');
193
+ * createHash,
194
+ * } = await import('node:crypto');
215
195
  *
216
196
  * const filename = argv[2];
217
197
  *
@@ -249,12 +229,12 @@ declare module 'crypto' {
249
229
  *
250
230
  * ```js
251
231
  * import {
252
- * createReadStream
253
- * } from 'fs';
254
- * import { argv } from 'process';
232
+ * createReadStream,
233
+ * } from 'node:fs';
234
+ * import { argv } from 'node:process';
255
235
  * const {
256
- * createHmac
257
- * } = await import('crypto');
236
+ * createHmac,
237
+ * } = await import('node:crypto');
258
238
  *
259
239
  * const filename = argv[2];
260
240
  *
@@ -297,8 +277,8 @@ declare module 'crypto' {
297
277
  *
298
278
  * ```js
299
279
  * const {
300
- * createHash
301
- * } = await import('crypto');
280
+ * createHash,
281
+ * } = await import('node:crypto');
302
282
  *
303
283
  * const hash = createHash('sha256');
304
284
  *
@@ -320,9 +300,9 @@ declare module 'crypto' {
320
300
  * Example: Using `Hash` and piped streams:
321
301
  *
322
302
  * ```js
323
- * import { createReadStream } from 'fs';
324
- * import { stdout } from 'process';
325
- * const { createHash } = await import('crypto');
303
+ * import { createReadStream } from 'node:fs';
304
+ * import { stdout } from 'node:process';
305
+ * const { createHash } = await import('node:crypto');
326
306
  *
327
307
  * const hash = createHash('sha256');
328
308
  *
@@ -334,8 +314,8 @@ declare module 'crypto' {
334
314
  *
335
315
  * ```js
336
316
  * const {
337
- * createHash
338
- * } = await import('crypto');
317
+ * createHash,
318
+ * } = await import('node:crypto');
339
319
  *
340
320
  * const hash = createHash('sha256');
341
321
  *
@@ -362,8 +342,8 @@ declare module 'crypto' {
362
342
  * ```js
363
343
  * // Calculate a rolling hash.
364
344
  * const {
365
- * createHash
366
- * } = await import('crypto');
345
+ * createHash,
346
+ * } = await import('node:crypto');
367
347
  *
368
348
  * const hash = createHash('sha256');
369
349
  *
@@ -422,8 +402,8 @@ declare module 'crypto' {
422
402
  *
423
403
  * ```js
424
404
  * const {
425
- * createHmac
426
- * } = await import('crypto');
405
+ * createHmac,
406
+ * } = await import('node:crypto');
427
407
  *
428
408
  * const hmac = createHmac('sha256', 'a secret');
429
409
  *
@@ -445,11 +425,11 @@ declare module 'crypto' {
445
425
  * Example: Using `Hmac` and piped streams:
446
426
  *
447
427
  * ```js
448
- * import { createReadStream } from 'fs';
449
- * import { stdout } from 'process';
428
+ * import { createReadStream } from 'node:fs';
429
+ * import { stdout } from 'node:process';
450
430
  * const {
451
- * createHmac
452
- * } = await import('crypto');
431
+ * createHmac,
432
+ * } = await import('node:crypto');
453
433
  *
454
434
  * const hmac = createHmac('sha256', 'a secret');
455
435
  *
@@ -461,8 +441,8 @@ declare module 'crypto' {
461
441
  *
462
442
  * ```js
463
443
  * const {
464
- * createHmac
465
- * } = await import('crypto');
444
+ * createHmac,
445
+ * } = await import('node:crypto');
466
446
  *
467
447
  * const hmac = createHmac('sha256', 'a secret');
468
448
  *
@@ -575,13 +555,13 @@ declare module 'crypto' {
575
555
  * Example: Converting a `CryptoKey` instance to a `KeyObject`:
576
556
  *
577
557
  * ```js
578
- * const { webcrypto, KeyObject } = await import('crypto');
579
- * const { subtle } = webcrypto;
558
+ * const { KeyObject } = await import('node:crypto');
559
+ * const { subtle } = globalThis.crypto;
580
560
  *
581
561
  * const key = await subtle.generateKey({
582
562
  * name: 'HMAC',
583
563
  * hash: 'SHA-256',
584
- * length: 256
564
+ * length: 256,
585
565
  * }, true, ['sign', 'verify']);
586
566
  *
587
567
  * const keyObject = KeyObject.from(key);
@@ -698,6 +678,10 @@ declare module 'crypto' {
698
678
  * The `password` is used to derive the cipher key and initialization vector (IV).
699
679
  * The value must be either a `'latin1'` encoded string, a `Buffer`, a`TypedArray`, or a `DataView`.
700
680
  *
681
+ * **This function is semantically insecure for all**
682
+ * **supported ciphers and fatally flawed for ciphers in counter mode (such as CTR,**
683
+ * **GCM, or CCM).**
684
+ *
701
685
  * The implementation of `crypto.createCipher()` derives keys using the OpenSSL
702
686
  * function [`EVP_BytesToKey`](https://www.openssl.org/docs/man1.1.0/crypto/EVP_BytesToKey.html) with the digest algorithm set to MD5, one
703
687
  * iteration, and no salt. The lack of salt allows dictionary attacks as the same
@@ -773,8 +757,8 @@ declare module 'crypto' {
773
757
  * const {
774
758
  * scrypt,
775
759
  * randomFill,
776
- * createCipheriv
777
- * } = await import('crypto');
760
+ * createCipheriv,
761
+ * } = await import('node:crypto');
778
762
  *
779
763
  * const algorithm = 'aes-192-cbc';
780
764
  * const password = 'Password used to generate key';
@@ -808,17 +792,17 @@ declare module 'crypto' {
808
792
  * import {
809
793
  * createReadStream,
810
794
  * createWriteStream,
811
- * } from 'fs';
795
+ * } from 'node:fs';
812
796
  *
813
797
  * import {
814
- * pipeline
815
- * } from 'stream';
798
+ * pipeline,
799
+ * } from 'node:stream';
816
800
  *
817
801
  * const {
818
802
  * scrypt,
819
803
  * randomFill,
820
- * createCipheriv
821
- * } = await import('crypto');
804
+ * createCipheriv,
805
+ * } = await import('node:crypto');
822
806
  *
823
807
  * const algorithm = 'aes-192-cbc';
824
808
  * const password = 'Password used to generate key';
@@ -849,8 +833,8 @@ declare module 'crypto' {
849
833
  * const {
850
834
  * scrypt,
851
835
  * randomFill,
852
- * createCipheriv
853
- * } = await import('crypto');
836
+ * createCipheriv,
837
+ * } = await import('node:crypto');
854
838
  *
855
839
  * const algorithm = 'aes-192-cbc';
856
840
  * const password = 'Password used to generate key';
@@ -955,6 +939,10 @@ declare module 'crypto' {
955
939
  * authentication tag in bytes, see `CCM mode`.
956
940
  * For `chacha20-poly1305`, the `authTagLength` option defaults to 16 bytes.
957
941
  *
942
+ * **This function is semantically insecure for all**
943
+ * **supported ciphers and fatally flawed for ciphers in counter mode (such as CTR,**
944
+ * **GCM, or CCM).**
945
+ *
958
946
  * The implementation of `crypto.createDecipher()` derives keys using the OpenSSL
959
947
  * function [`EVP_BytesToKey`](https://www.openssl.org/docs/man1.1.0/crypto/EVP_BytesToKey.html) with the digest algorithm set to MD5, one
960
948
  * iteration, and no salt. The lack of salt allows dictionary attacks as the same
@@ -1023,11 +1011,11 @@ declare module 'crypto' {
1023
1011
  * Example: Using `Decipher` objects as streams:
1024
1012
  *
1025
1013
  * ```js
1026
- * import { Buffer } from 'buffer';
1014
+ * import { Buffer } from 'node:buffer';
1027
1015
  * const {
1028
1016
  * scryptSync,
1029
- * createDecipheriv
1030
- * } = await import('crypto');
1017
+ * createDecipheriv,
1018
+ * } = await import('node:crypto');
1031
1019
  *
1032
1020
  * const algorithm = 'aes-192-cbc';
1033
1021
  * const password = 'Password used to generate key';
@@ -1042,6 +1030,7 @@ declare module 'crypto' {
1042
1030
  *
1043
1031
  * let decrypted = '';
1044
1032
  * decipher.on('readable', () => {
1033
+ * let chunk;
1045
1034
  * while (null !== (chunk = decipher.read())) {
1046
1035
  * decrypted += chunk.toString('utf8');
1047
1036
  * }
@@ -1064,12 +1053,12 @@ declare module 'crypto' {
1064
1053
  * import {
1065
1054
  * createReadStream,
1066
1055
  * createWriteStream,
1067
- * } from 'fs';
1068
- * import { Buffer } from 'buffer';
1056
+ * } from 'node:fs';
1057
+ * import { Buffer } from 'node:buffer';
1069
1058
  * const {
1070
1059
  * scryptSync,
1071
- * createDecipheriv
1072
- * } = await import('crypto');
1060
+ * createDecipheriv,
1061
+ * } = await import('node:crypto');
1073
1062
  *
1074
1063
  * const algorithm = 'aes-192-cbc';
1075
1064
  * const password = 'Password used to generate key';
@@ -1089,11 +1078,11 @@ declare module 'crypto' {
1089
1078
  * Example: Using the `decipher.update()` and `decipher.final()` methods:
1090
1079
  *
1091
1080
  * ```js
1092
- * import { Buffer } from 'buffer';
1081
+ * import { Buffer } from 'node:buffer';
1093
1082
  * const {
1094
1083
  * scryptSync,
1095
- * createDecipheriv
1096
- * } = await import('crypto');
1084
+ * createDecipheriv,
1085
+ * } = await import('node:crypto');
1097
1086
  *
1098
1087
  * const algorithm = 'aes-192-cbc';
1099
1088
  * const password = 'Password used to generate key';
@@ -1190,19 +1179,21 @@ declare module 'crypto' {
1190
1179
  format?: KeyFormat | undefined;
1191
1180
  type?: 'pkcs1' | 'pkcs8' | 'sec1' | undefined;
1192
1181
  passphrase?: string | Buffer | undefined;
1182
+ encoding?: string | undefined;
1193
1183
  }
1194
1184
  interface PublicKeyInput {
1195
1185
  key: string | Buffer;
1196
1186
  format?: KeyFormat | undefined;
1197
1187
  type?: 'pkcs1' | 'spki' | undefined;
1188
+ encoding?: string | undefined;
1198
1189
  }
1199
1190
  /**
1200
1191
  * Asynchronously generates a new random secret key of the given `length`. The`type` will determine which validations will be performed on the `length`.
1201
1192
  *
1202
1193
  * ```js
1203
1194
  * const {
1204
- * generateKey
1205
- * } = await import('crypto');
1195
+ * generateKey,
1196
+ * } = await import('node:crypto');
1206
1197
  *
1207
1198
  * generateKey('hmac', { length: 64 }, (err, key) => {
1208
1199
  * if (err) throw err;
@@ -1224,8 +1215,8 @@ declare module 'crypto' {
1224
1215
  *
1225
1216
  * ```js
1226
1217
  * const {
1227
- * generateKeySync
1228
- * } = await import('crypto');
1218
+ * generateKeySync,
1219
+ * } = await import('node:crypto');
1229
1220
  *
1230
1221
  * const key = generateKeySync('hmac', { length: 64 });
1231
1222
  * console.log(key.export().toString('hex')); // e89..........41e
@@ -1291,7 +1282,7 @@ declare module 'crypto' {
1291
1282
  type DSAEncoding = 'der' | 'ieee-p1363';
1292
1283
  interface SigningOptions {
1293
1284
  /**
1294
- * @See crypto.constants.RSA_PKCS1_PADDING
1285
+ * @see crypto.constants.RSA_PKCS1_PADDING
1295
1286
  */
1296
1287
  padding?: number | undefined;
1297
1288
  saltLength?: number | undefined;
@@ -1305,6 +1296,7 @@ declare module 'crypto' {
1305
1296
  interface VerifyKeyObjectInput extends SigningOptions {
1306
1297
  key: KeyObject;
1307
1298
  }
1299
+ interface VerifyJsonWebKeyInput extends JsonWebKeyInput, SigningOptions {}
1308
1300
  type KeyLike = string | Buffer | KeyObject;
1309
1301
  /**
1310
1302
  * The `Sign` class is a utility for generating signatures. It can be used in one
@@ -1324,11 +1316,11 @@ declare module 'crypto' {
1324
1316
  * const {
1325
1317
  * generateKeyPairSync,
1326
1318
  * createSign,
1327
- * createVerify
1328
- * } = await import('crypto');
1319
+ * createVerify,
1320
+ * } = await import('node:crypto');
1329
1321
  *
1330
1322
  * const { privateKey, publicKey } = generateKeyPairSync('ec', {
1331
- * namedCurve: 'sect239k1'
1323
+ * namedCurve: 'sect239k1',
1332
1324
  * });
1333
1325
  *
1334
1326
  * const sign = createSign('SHA256');
@@ -1349,8 +1341,8 @@ declare module 'crypto' {
1349
1341
  * const {
1350
1342
  * generateKeyPairSync,
1351
1343
  * createSign,
1352
- * createVerify
1353
- * } = await import('crypto');
1344
+ * createVerify,
1345
+ * } = await import('node:crypto');
1354
1346
  *
1355
1347
  * const { privateKey, publicKey } = generateKeyPairSync('rsa', {
1356
1348
  * modulusLength: 2048,
@@ -1459,8 +1451,8 @@ declare module 'crypto' {
1459
1451
  * be passed instead of a public key.
1460
1452
  * @since v0.1.92
1461
1453
  */
1462
- verify(object: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput, signature: NodeJS.ArrayBufferView): boolean;
1463
- verify(object: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput, signature: string, signature_format?: BinaryToTextEncoding): boolean;
1454
+ verify(object: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput | VerifyJsonWebKeyInput, signature: NodeJS.ArrayBufferView): boolean;
1455
+ verify(object: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput | VerifyJsonWebKeyInput, signature: string, signature_format?: BinaryToTextEncoding): boolean;
1464
1456
  }
1465
1457
  /**
1466
1458
  * Creates a `DiffieHellman` key exchange object using the supplied `prime` and an
@@ -1490,11 +1482,11 @@ declare module 'crypto' {
1490
1482
  * Instances of the `DiffieHellman` class can be created using the {@link createDiffieHellman} function.
1491
1483
  *
1492
1484
  * ```js
1493
- * import assert from 'assert';
1485
+ * import assert from 'node:assert';
1494
1486
  *
1495
1487
  * const {
1496
- * createDiffieHellman
1497
- * } = await import('crypto');
1488
+ * createDiffieHellman,
1489
+ * } = await import('node:crypto');
1498
1490
  *
1499
1491
  * // Generate Alice's keys...
1500
1492
  * const alice = createDiffieHellman(2048);
@@ -1600,7 +1592,7 @@ declare module 'crypto' {
1600
1592
  * A bit field containing any warnings and/or errors resulting from a check
1601
1593
  * performed during initialization of the `DiffieHellman` object.
1602
1594
  *
1603
- * The following values are valid for this property (as defined in `constants`module):
1595
+ * The following values are valid for this property (as defined in `node:constants` module):
1604
1596
  *
1605
1597
  * * `DH_CHECK_P_NOT_SAFE_PRIME`
1606
1598
  * * `DH_CHECK_P_NOT_PRIME`
@@ -1635,16 +1627,16 @@ declare module 'crypto' {
1635
1627
  */
1636
1628
  const DiffieHellmanGroup: DiffieHellmanGroupConstructor;
1637
1629
  interface DiffieHellmanGroupConstructor {
1638
- new(name: string): DiffieHellmanGroup;
1630
+ new (name: string): DiffieHellmanGroup;
1639
1631
  (name: string): DiffieHellmanGroup;
1640
1632
  readonly prototype: DiffieHellmanGroup;
1641
1633
  }
1642
1634
  type DiffieHellmanGroup = Omit<DiffieHellman, 'setPublicKey' | 'setPrivateKey'>;
1643
1635
  /**
1644
1636
  * Creates a predefined `DiffieHellmanGroup` key exchange object. The
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'`,
1646
- * `'modp18'` (defined in [RFC 3526](https://www.rfc-editor.org/rfc/rfc3526.txt)). The
1647
- * returned object mimics the interface of objects created by {@link createDiffieHellman}, but will not allow changing
1637
+ * supported groups are listed in the documentation for `DiffieHellmanGroup`.
1638
+ *
1639
+ * The returned object mimics the interface of objects created by {@link createDiffieHellman}, but will not allow changing
1648
1640
  * the keys (with `diffieHellman.setPublicKey()`, for example). The
1649
1641
  * advantage of using this method is that the parties do not have to
1650
1642
  * generate nor exchange a group modulus beforehand, saving both processor
@@ -1654,8 +1646,8 @@ declare module 'crypto' {
1654
1646
  *
1655
1647
  * ```js
1656
1648
  * const {
1657
- * getDiffieHellman
1658
- * } = await import('crypto');
1649
+ * getDiffieHellman,
1650
+ * } = await import('node:crypto');
1659
1651
  * const alice = getDiffieHellman('modp14');
1660
1652
  * const bob = getDiffieHellman('modp14');
1661
1653
  *
@@ -1685,9 +1677,6 @@ declare module 'crypto' {
1685
1677
  * otherwise `err` will be `null`. By default, the successfully generated`derivedKey` will be passed to the callback as a `Buffer`. An error will be
1686
1678
  * thrown if any of the input arguments specify invalid values or types.
1687
1679
  *
1688
- * If `digest` is `null`, `'sha1'` will be used. This behavior is deprecated,
1689
- * please specify a `digest` explicitly.
1690
- *
1691
1680
  * The `iterations` argument must be a number set as high as possible. The
1692
1681
  * higher the number of iterations, the more secure the derived key will be,
1693
1682
  * but will take a longer amount of time to complete.
@@ -1699,8 +1688,8 @@ declare module 'crypto' {
1699
1688
  *
1700
1689
  * ```js
1701
1690
  * const {
1702
- * pbkdf2
1703
- * } = await import('crypto');
1691
+ * pbkdf2,
1692
+ * } = await import('node:crypto');
1704
1693
  *
1705
1694
  * pbkdf2('secret', 'salt', 100000, 64, 'sha512', (err, derivedKey) => {
1706
1695
  * if (err) throw err;
@@ -1708,18 +1697,6 @@ declare module 'crypto' {
1708
1697
  * });
1709
1698
  * ```
1710
1699
  *
1711
- * The `crypto.DEFAULT_ENCODING` property can be used to change the way the`derivedKey` is passed to the callback. This property, however, has been
1712
- * deprecated and use should be avoided.
1713
- *
1714
- * ```js
1715
- * import crypto from 'crypto';
1716
- * crypto.DEFAULT_ENCODING = 'hex';
1717
- * crypto.pbkdf2('secret', 'salt', 100000, 512, 'sha512', (err, derivedKey) => {
1718
- * if (err) throw err;
1719
- * console.log(derivedKey); // '3745e48...aa39b34'
1720
- * });
1721
- * ```
1722
- *
1723
1700
  * An array of supported digest functions can be retrieved using {@link getHashes}.
1724
1701
  *
1725
1702
  * This API uses libuv's threadpool, which can have surprising and
@@ -1735,9 +1712,6 @@ declare module 'crypto' {
1735
1712
  * If an error occurs an `Error` will be thrown, otherwise the derived key will be
1736
1713
  * returned as a `Buffer`.
1737
1714
  *
1738
- * If `digest` is `null`, `'sha1'` will be used. This behavior is deprecated,
1739
- * please specify a `digest` explicitly.
1740
- *
1741
1715
  * The `iterations` argument must be a number set as high as possible. The
1742
1716
  * higher the number of iterations, the more secure the derived key will be,
1743
1717
  * but will take a longer amount of time to complete.
@@ -1749,23 +1723,13 @@ declare module 'crypto' {
1749
1723
  *
1750
1724
  * ```js
1751
1725
  * const {
1752
- * pbkdf2Sync
1753
- * } = await import('crypto');
1726
+ * pbkdf2Sync,
1727
+ * } = await import('node:crypto');
1754
1728
  *
1755
1729
  * const key = pbkdf2Sync('secret', 'salt', 100000, 64, 'sha512');
1756
1730
  * console.log(key.toString('hex')); // '3745e48...08d59ae'
1757
1731
  * ```
1758
1732
  *
1759
- * The `crypto.DEFAULT_ENCODING` property may be used to change the way the`derivedKey` is returned. This property, however, is deprecated and use
1760
- * should be avoided.
1761
- *
1762
- * ```js
1763
- * import crypto from 'crypto';
1764
- * crypto.DEFAULT_ENCODING = 'hex';
1765
- * const key = crypto.pbkdf2Sync('secret', 'salt', 100000, 512, 'sha512');
1766
- * console.log(key); // '3745e48...aa39b34'
1767
- * ```
1768
- *
1769
1733
  * An array of supported digest functions can be retrieved using {@link getHashes}.
1770
1734
  * @since v0.9.3
1771
1735
  */
@@ -1781,8 +1745,8 @@ declare module 'crypto' {
1781
1745
  * ```js
1782
1746
  * // Asynchronous
1783
1747
  * const {
1784
- * randomBytes
1785
- * } = await import('crypto');
1748
+ * randomBytes,
1749
+ * } = await import('node:crypto');
1786
1750
  *
1787
1751
  * randomBytes(256, (err, buf) => {
1788
1752
  * if (err) throw err;
@@ -1797,8 +1761,8 @@ declare module 'crypto' {
1797
1761
  * ```js
1798
1762
  * // Synchronous
1799
1763
  * const {
1800
- * randomBytes
1801
- * } = await import('crypto');
1764
+ * randomBytes,
1765
+ * } = await import('node:crypto');
1802
1766
  *
1803
1767
  * const buf = randomBytes(256);
1804
1768
  * console.log(
@@ -1830,7 +1794,7 @@ declare module 'crypto' {
1830
1794
  * Return a random integer `n` such that `min <= n < max`. This
1831
1795
  * implementation avoids [modulo bias](https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#Modulo_bias).
1832
1796
  *
1833
- * The range (`max - min`) must be less than 2^48. `min` and `max` must
1797
+ * The range (`max - min`) must be less than 248. `min` and `max` must
1834
1798
  * be [safe integers](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger).
1835
1799
  *
1836
1800
  * If the `callback` function is not provided, the random integer is
@@ -1839,8 +1803,8 @@ declare module 'crypto' {
1839
1803
  * ```js
1840
1804
  * // Asynchronous
1841
1805
  * const {
1842
- * randomInt
1843
- * } = await import('crypto');
1806
+ * randomInt,
1807
+ * } = await import('node:crypto');
1844
1808
  *
1845
1809
  * randomInt(3, (err, n) => {
1846
1810
  * if (err) throw err;
@@ -1851,8 +1815,8 @@ declare module 'crypto' {
1851
1815
  * ```js
1852
1816
  * // Synchronous
1853
1817
  * const {
1854
- * randomInt
1855
- * } = await import('crypto');
1818
+ * randomInt,
1819
+ * } = await import('node:crypto');
1856
1820
  *
1857
1821
  * const n = randomInt(3);
1858
1822
  * console.log(`Random number chosen from (0, 1, 2): ${n}`);
@@ -1861,8 +1825,8 @@ declare module 'crypto' {
1861
1825
  * ```js
1862
1826
  * // With `min` argument
1863
1827
  * const {
1864
- * randomInt
1865
- * } = await import('crypto');
1828
+ * randomInt,
1829
+ * } = await import('node:crypto');
1866
1830
  *
1867
1831
  * const n = randomInt(1, 7);
1868
1832
  * console.log(`The dice rolled: ${n}`);
@@ -1880,8 +1844,8 @@ declare module 'crypto' {
1880
1844
  * Synchronous version of {@link randomFill}.
1881
1845
  *
1882
1846
  * ```js
1883
- * import { Buffer } from 'buffer';
1884
- * const { randomFillSync } = await import('crypto');
1847
+ * import { Buffer } from 'node:buffer';
1848
+ * const { randomFillSync } = await import('node:crypto');
1885
1849
  *
1886
1850
  * const buf = Buffer.alloc(10);
1887
1851
  * console.log(randomFillSync(buf).toString('hex'));
@@ -1897,8 +1861,8 @@ declare module 'crypto' {
1897
1861
  * Any `ArrayBuffer`, `TypedArray` or `DataView` instance may be passed as`buffer`.
1898
1862
  *
1899
1863
  * ```js
1900
- * import { Buffer } from 'buffer';
1901
- * const { randomFillSync } = await import('crypto');
1864
+ * import { Buffer } from 'node:buffer';
1865
+ * const { randomFillSync } = await import('node:crypto');
1902
1866
  *
1903
1867
  * const a = new Uint32Array(10);
1904
1868
  * console.log(Buffer.from(randomFillSync(a).buffer,
@@ -1926,8 +1890,8 @@ declare module 'crypto' {
1926
1890
  * If the `callback` function is not provided, an error will be thrown.
1927
1891
  *
1928
1892
  * ```js
1929
- * import { Buffer } from 'buffer';
1930
- * const { randomFill } = await import('crypto');
1893
+ * import { Buffer } from 'node:buffer';
1894
+ * const { randomFill } = await import('node:crypto');
1931
1895
  *
1932
1896
  * const buf = Buffer.alloc(10);
1933
1897
  * randomFill(buf, (err, buf) => {
@@ -1956,8 +1920,8 @@ declare module 'crypto' {
1956
1920
  * distribution and have no meaningful lower or upper bounds.
1957
1921
  *
1958
1922
  * ```js
1959
- * import { Buffer } from 'buffer';
1960
- * const { randomFill } = await import('crypto');
1923
+ * import { Buffer } from 'node:buffer';
1924
+ * const { randomFill } = await import('node:crypto');
1961
1925
  *
1962
1926
  * const a = new Uint32Array(10);
1963
1927
  * randomFill(a, (err, buf) => {
@@ -2023,8 +1987,8 @@ declare module 'crypto' {
2023
1987
  *
2024
1988
  * ```js
2025
1989
  * const {
2026
- * scrypt
2027
- * } = await import('crypto');
1990
+ * scrypt,
1991
+ * } = await import('node:crypto');
2028
1992
  *
2029
1993
  * // Using the factory defaults.
2030
1994
  * scrypt('password', 'salt', 64, (err, derivedKey) => {
@@ -2059,8 +2023,8 @@ declare module 'crypto' {
2059
2023
  *
2060
2024
  * ```js
2061
2025
  * const {
2062
- * scryptSync
2063
- * } = await import('crypto');
2026
+ * scryptSync,
2027
+ * } = await import('node:crypto');
2064
2028
  * // Using the factory defaults.
2065
2029
  *
2066
2030
  * const key1 = scryptSync('password', 'salt', 64);
@@ -2131,8 +2095,8 @@ declare module 'crypto' {
2131
2095
  /**
2132
2096
  * ```js
2133
2097
  * const {
2134
- * getCiphers
2135
- * } = await import('crypto');
2098
+ * getCiphers,
2099
+ * } = await import('node:crypto');
2136
2100
  *
2137
2101
  * console.log(getCiphers()); // ['aes-128-cbc', 'aes-128-ccm', ...]
2138
2102
  * ```
@@ -2143,8 +2107,8 @@ declare module 'crypto' {
2143
2107
  /**
2144
2108
  * ```js
2145
2109
  * const {
2146
- * getCurves
2147
- * } = await import('crypto');
2110
+ * getCurves,
2111
+ * } = await import('node:crypto');
2148
2112
  *
2149
2113
  * console.log(getCurves()); // ['Oakley-EC2N-3', 'Oakley-EC2N-4', ...]
2150
2114
  * ```
@@ -2158,7 +2122,8 @@ declare module 'crypto' {
2158
2122
  */
2159
2123
  function getFips(): 1 | 0;
2160
2124
  /**
2161
- * Enables the FIPS compliant crypto provider in a FIPS-enabled Node.js build. Throws an error if FIPS mode is not available.
2125
+ * Enables the FIPS compliant crypto provider in a FIPS-enabled Node.js build.
2126
+ * Throws an error if FIPS mode is not available.
2162
2127
  * @since v10.0.0
2163
2128
  * @param bool `true` to enable FIPS mode.
2164
2129
  */
@@ -2166,8 +2131,8 @@ declare module 'crypto' {
2166
2131
  /**
2167
2132
  * ```js
2168
2133
  * const {
2169
- * getHashes
2170
- * } = await import('crypto');
2134
+ * getHashes,
2135
+ * } = await import('node:crypto');
2171
2136
  *
2172
2137
  * console.log(getHashes()); // ['DSA', 'DSA-SHA', 'DSA-SHA1', ...]
2173
2138
  * ```
@@ -2182,11 +2147,11 @@ declare module 'crypto' {
2182
2147
  * Instances of the `ECDH` class can be created using the {@link createECDH} function.
2183
2148
  *
2184
2149
  * ```js
2185
- * import assert from 'assert';
2150
+ * import assert from 'node:assert';
2186
2151
  *
2187
2152
  * const {
2188
- * createECDH
2189
- * } = await import('crypto');
2153
+ * createECDH,
2154
+ * } = await import('node:crypto');
2190
2155
  *
2191
2156
  * // Generate Alice's keys...
2192
2157
  * const alice = createECDH('secp521r1');
@@ -2227,8 +2192,8 @@ declare module 'crypto' {
2227
2192
  * ```js
2228
2193
  * const {
2229
2194
  * createECDH,
2230
- * ECDH
2231
- * } = await import('crypto');
2195
+ * ECDH,
2196
+ * } = await import('node:crypto');
2232
2197
  *
2233
2198
  * const ecdh = createECDH('secp256k1');
2234
2199
  * ecdh.generateKeys();
@@ -2306,7 +2271,7 @@ declare module 'crypto' {
2306
2271
  * If `encoding` is specified, a string is returned; otherwise a `Buffer` is
2307
2272
  * returned.
2308
2273
  * @since v0.11.14
2309
- * @param [encoding] The `encoding` of the return value.
2274
+ * @param encoding The `encoding` of the return value.
2310
2275
  * @param [format='uncompressed']
2311
2276
  * @return The EC Diffie-Hellman public key in the specified `encoding` and `format`.
2312
2277
  */
@@ -2335,8 +2300,10 @@ declare module 'crypto' {
2335
2300
  */
2336
2301
  function createECDH(curveName: string): ECDH;
2337
2302
  /**
2338
- * This function is based on a constant-time algorithm.
2339
- * Returns true if `a` is equal to `b`, without leaking timing information that
2303
+ * This function compares the underlying bytes that represent the given`ArrayBuffer`, `TypedArray`, or `DataView` instances using a constant-time
2304
+ * algorithm.
2305
+ *
2306
+ * This function does not leak timing information that
2340
2307
  * would allow an attacker to guess one of the values. This is suitable for
2341
2308
  * comparing HMAC digests or secret values like authentication cookies or [capability urls](https://www.w3.org/TR/capability-urls/).
2342
2309
  *
@@ -2348,16 +2315,18 @@ declare module 'crypto' {
2348
2315
  * entry, such as `Uint16Array`, the result will be computed using the platform
2349
2316
  * byte order.
2350
2317
  *
2318
+ * **When both of the inputs are `Float32Array`s or`Float64Array`s, this function might return unexpected results due to IEEE 754**
2319
+ * **encoding of floating-point numbers. In particular, neither `x === y` nor`Object.is(x, y)` implies that the byte representations of two floating-point**
2320
+ * **numbers `x` and `y` are equal.**
2321
+ *
2351
2322
  * Use of `crypto.timingSafeEqual` does not guarantee that the _surrounding_ code
2352
2323
  * is timing-safe. Care should be taken to ensure that the surrounding code does
2353
2324
  * not introduce timing vulnerabilities.
2354
2325
  * @since v6.6.0
2355
2326
  */
2356
2327
  function timingSafeEqual(a: NodeJS.ArrayBufferView, b: NodeJS.ArrayBufferView): boolean;
2357
- /** @deprecated since v10.0.0 */
2358
- const DEFAULT_ENCODING: BufferEncoding;
2359
2328
  type KeyType = 'rsa' | 'rsa-pss' | 'dsa' | 'ec' | 'ed25519' | 'ed448' | 'x25519' | 'x448';
2360
- type KeyFormat = 'pem' | 'der';
2329
+ type KeyFormat = 'pem' | 'der' | 'jwk';
2361
2330
  interface BasePrivateKeyEncodingOptions<T extends KeyFormat> {
2362
2331
  format: T;
2363
2332
  cipher?: string | undefined;
@@ -2553,8 +2522,8 @@ declare module 'crypto' {
2553
2522
  *
2554
2523
  * ```js
2555
2524
  * const {
2556
- * generateKeyPairSync
2557
- * } = await import('crypto');
2525
+ * generateKeyPairSync,
2526
+ * } = await import('node:crypto');
2558
2527
  *
2559
2528
  * const {
2560
2529
  * publicKey,
@@ -2563,14 +2532,14 @@ declare module 'crypto' {
2563
2532
  * modulusLength: 4096,
2564
2533
  * publicKeyEncoding: {
2565
2534
  * type: 'spki',
2566
- * format: 'pem'
2535
+ * format: 'pem',
2567
2536
  * },
2568
2537
  * privateKeyEncoding: {
2569
2538
  * type: 'pkcs8',
2570
2539
  * format: 'pem',
2571
2540
  * cipher: 'aes-256-cbc',
2572
- * passphrase: 'top secret'
2573
- * }
2541
+ * passphrase: 'top secret',
2542
+ * },
2574
2543
  * });
2575
2544
  * ```
2576
2545
  *
@@ -2632,21 +2601,21 @@ declare module 'crypto' {
2632
2601
  *
2633
2602
  * ```js
2634
2603
  * const {
2635
- * generateKeyPair
2636
- * } = await import('crypto');
2604
+ * generateKeyPair,
2605
+ * } = await import('node:crypto');
2637
2606
  *
2638
2607
  * generateKeyPair('rsa', {
2639
2608
  * modulusLength: 4096,
2640
2609
  * publicKeyEncoding: {
2641
2610
  * type: 'spki',
2642
- * format: 'pem'
2611
+ * format: 'pem',
2643
2612
  * },
2644
2613
  * privateKeyEncoding: {
2645
2614
  * type: 'pkcs8',
2646
2615
  * format: 'pem',
2647
2616
  * cipher: 'aes-256-cbc',
2648
- * passphrase: 'top secret'
2649
- * }
2617
+ * passphrase: 'top secret',
2618
+ * },
2650
2619
  * }, (err, publicKey, privateKey) => {
2651
2620
  * // Handle errors and use the generated key pair.
2652
2621
  * });
@@ -2968,11 +2937,16 @@ declare module 'crypto' {
2968
2937
  * If the `callback` function is provided this function uses libuv's threadpool.
2969
2938
  * @since v12.0.0
2970
2939
  */
2971
- function verify(algorithm: string | null | undefined, data: NodeJS.ArrayBufferView, key: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput, signature: NodeJS.ArrayBufferView): boolean;
2972
2940
  function verify(
2973
2941
  algorithm: string | null | undefined,
2974
2942
  data: NodeJS.ArrayBufferView,
2975
- key: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput,
2943
+ key: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput | VerifyJsonWebKeyInput,
2944
+ signature: NodeJS.ArrayBufferView
2945
+ ): boolean;
2946
+ function verify(
2947
+ algorithm: string | null | undefined,
2948
+ data: NodeJS.ArrayBufferView,
2949
+ key: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput | VerifyJsonWebKeyInput,
2976
2950
  signature: NodeJS.ArrayBufferView,
2977
2951
  callback: (error: Error | null, result: boolean) => void
2978
2952
  ): void;
@@ -3042,10 +3016,10 @@ declare module 'crypto' {
3042
3016
  * of the input arguments specify invalid values or types.
3043
3017
  *
3044
3018
  * ```js
3045
- * import { Buffer } from 'buffer';
3019
+ * import { Buffer } from 'node:buffer';
3046
3020
  * const {
3047
- * hkdf
3048
- * } = await import('crypto');
3021
+ * hkdf,
3022
+ * } = await import('node:crypto');
3049
3023
  *
3050
3024
  * hkdf('sha512', 'key', 'salt', 'info', 64, (err, derivedKey) => {
3051
3025
  * if (err) throw err;
@@ -3054,7 +3028,7 @@ declare module 'crypto' {
3054
3028
  * ```
3055
3029
  * @since v15.0.0
3056
3030
  * @param digest The digest algorithm to use.
3057
- * @param ikm The input keying material. It must be at least one byte in length.
3031
+ * @param ikm The input keying material. Must be provided but can be zero-length.
3058
3032
  * @param salt The salt value. Must be provided but can be zero-length.
3059
3033
  * @param info Additional info value. Must be provided but can be zero-length, and cannot be more than 1024 bytes.
3060
3034
  * @param keylen The length of the key to generate. Must be greater than 0. The maximum allowable value is `255` times the number of bytes produced by the selected digest function (e.g. `sha512`
@@ -3071,17 +3045,17 @@ declare module 'crypto' {
3071
3045
  * types, or if the derived key cannot be generated.
3072
3046
  *
3073
3047
  * ```js
3074
- * import { Buffer } from 'buffer';
3048
+ * import { Buffer } from 'node:buffer';
3075
3049
  * const {
3076
- * hkdfSync
3077
- * } = await import('crypto');
3050
+ * hkdfSync,
3051
+ * } = await import('node:crypto');
3078
3052
  *
3079
3053
  * const derivedKey = hkdfSync('sha512', 'key', 'salt', 'info', 64);
3080
3054
  * console.log(Buffer.from(derivedKey).toString('hex')); // '24156e2...5391653'
3081
3055
  * ```
3082
3056
  * @since v15.0.0
3083
3057
  * @param digest The digest algorithm to use.
3084
- * @param ikm The input keying material. It must be at least one byte in length.
3058
+ * @param ikm The input keying material. Must be provided but can be zero-length.
3085
3059
  * @param salt The salt value. Must be provided but can be zero-length.
3086
3060
  * @param info Additional info value. Must be provided but can be zero-length, and cannot be more than 1024 bytes.
3087
3061
  * @param keylen The length of the key to generate. Must be greater than 0. The maximum allowable value is `255` times the number of bytes produced by the selected digest function (e.g. `sha512`
@@ -3121,40 +3095,41 @@ declare module 'crypto' {
3121
3095
  */
3122
3096
  disableEntropyCache?: boolean | undefined;
3123
3097
  }
3098
+ type UUID = `${string}-${string}-${string}-${string}-${string}`;
3124
3099
  /**
3125
3100
  * Generates a random [RFC 4122](https://www.rfc-editor.org/rfc/rfc4122.txt) version 4 UUID. The UUID is generated using a
3126
3101
  * cryptographic pseudorandom number generator.
3127
3102
  * @since v15.6.0, v14.17.0
3128
3103
  */
3129
- function randomUUID(options?: RandomUUIDOptions): string;
3104
+ function randomUUID(options?: RandomUUIDOptions): UUID;
3130
3105
  interface X509CheckOptions {
3131
3106
  /**
3132
3107
  * @default 'always'
3133
3108
  */
3134
- subject: 'always' | 'never';
3109
+ subject?: 'always' | 'default' | 'never';
3135
3110
  /**
3136
3111
  * @default true
3137
3112
  */
3138
- wildcards: boolean;
3113
+ wildcards?: boolean;
3139
3114
  /**
3140
3115
  * @default true
3141
3116
  */
3142
- partialWildcards: boolean;
3117
+ partialWildcards?: boolean;
3143
3118
  /**
3144
3119
  * @default false
3145
3120
  */
3146
- multiLabelWildcards: boolean;
3121
+ multiLabelWildcards?: boolean;
3147
3122
  /**
3148
3123
  * @default false
3149
3124
  */
3150
- singleLabelSubdomains: boolean;
3125
+ singleLabelSubdomains?: boolean;
3151
3126
  }
3152
3127
  /**
3153
3128
  * Encapsulates an X509 certificate and provides read-only access to
3154
3129
  * its information.
3155
3130
  *
3156
3131
  * ```js
3157
- * const { X509Certificate } = await import('crypto');
3132
+ * const { X509Certificate } = await import('node:crypto');
3158
3133
  *
3159
3134
  * const x509 = new X509Certificate('{... pem encoded cert ...}');
3160
3135
  *
@@ -3184,23 +3159,53 @@ declare module 'crypto' {
3184
3159
  readonly fingerprint256: string;
3185
3160
  /**
3186
3161
  * The SHA-512 fingerprint of this certificate.
3187
- * @since v16.14.0
3162
+ *
3163
+ * Because computing the SHA-256 fingerprint is usually faster and because it is
3164
+ * only half the size of the SHA-512 fingerprint, `x509.fingerprint256` may be
3165
+ * a better choice. While SHA-512 presumably provides a higher level of security in
3166
+ * general, the security of SHA-256 matches that of most algorithms that are
3167
+ * commonly used to sign certificates.
3168
+ * @since v17.2.0, v16.14.0
3188
3169
  */
3189
- readonly fingerprint512: string;
3170
+ readonly fingerprint512: string;
3190
3171
  /**
3191
3172
  * The complete subject of this certificate.
3192
3173
  * @since v15.6.0
3193
3174
  */
3194
3175
  readonly subject: string;
3195
3176
  /**
3196
- * The subject alternative name specified for this certificate or `undefined`
3197
- * if not available.
3177
+ * The subject alternative name specified for this certificate.
3178
+ *
3179
+ * This is a comma-separated list of subject alternative names. Each entry begins
3180
+ * with a string identifying the kind of the subject alternative name followed by
3181
+ * a colon and the value associated with the entry.
3182
+ *
3183
+ * Earlier versions of Node.js incorrectly assumed that it is safe to split this
3184
+ * property at the two-character sequence `', '` (see [CVE-2021-44532](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-44532)). However,
3185
+ * both malicious and legitimate certificates can contain subject alternative names
3186
+ * that include this sequence when represented as a string.
3187
+ *
3188
+ * After the prefix denoting the type of the entry, the remainder of each entry
3189
+ * might be enclosed in quotes to indicate that the value is a JSON string literal.
3190
+ * For backward compatibility, Node.js only uses JSON string literals within this
3191
+ * property when necessary to avoid ambiguity. Third-party code should be prepared
3192
+ * to handle both possible entry formats.
3198
3193
  * @since v15.6.0
3199
3194
  */
3200
3195
  readonly subjectAltName: string | undefined;
3201
3196
  /**
3202
- * The information access content of this certificate or `undefined` if not
3203
- * available.
3197
+ * A textual representation of the certificate's authority information access
3198
+ * extension.
3199
+ *
3200
+ * This is a line feed separated list of access descriptions. Each line begins with
3201
+ * the access method and the kind of the access location, followed by a colon and
3202
+ * the value associated with the access location.
3203
+ *
3204
+ * After the prefix denoting the access method and the kind of the access location,
3205
+ * the remainder of each line might be enclosed in quotes to indicate that the
3206
+ * value is a JSON string literal. For backward compatibility, Node.js only uses
3207
+ * JSON string literals within this property when necessary to avoid ambiguity.
3208
+ * Third-party code should be prepared to handle both possible entry formats.
3204
3209
  * @since v15.6.0
3205
3210
  */
3206
3211
  readonly infoAccess: string | undefined;
@@ -3417,7 +3422,7 @@ declare module 'crypto' {
3417
3422
  interface CheckPrimeOptions {
3418
3423
  /**
3419
3424
  * The number of Miller-Rabin probabilistic primality iterations to perform.
3420
- * When the value is 0 (zero), a number of checks is used that yields a false positive rate of at most 2-64 for random input.
3425
+ * When the value is 0 (zero), a number of checks is used that yields a false positive rate of at most `2**-64` for random input.
3421
3426
  * Care must be used when selecting a number of checks.
3422
3427
  * Refer to the OpenSSL documentation for the BN_is_prime_ex function nchecks options for more details.
3423
3428
  *
@@ -3444,36 +3449,29 @@ declare module 'crypto' {
3444
3449
  *
3445
3450
  * `engine` could be either an id or a path to the engine's shared library.
3446
3451
  *
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`
3452
+ * The optional `flags` argument uses `ENGINE_METHOD_ALL` by default. The `flags`is a bit field taking one of or a mix of the following flags (defined in`crypto.constants`):
3453
+ *
3454
+ * * `crypto.constants.ENGINE_METHOD_RSA`
3455
+ * * `crypto.constants.ENGINE_METHOD_DSA`
3456
+ * * `crypto.constants.ENGINE_METHOD_DH`
3457
+ * * `crypto.constants.ENGINE_METHOD_RAND`
3458
+ * * `crypto.constants.ENGINE_METHOD_EC`
3459
+ * * `crypto.constants.ENGINE_METHOD_CIPHERS`
3460
+ * * `crypto.constants.ENGINE_METHOD_DIGESTS`
3461
+ * * `crypto.constants.ENGINE_METHOD_PKEY_METHS`
3462
+ * * `crypto.constants.ENGINE_METHOD_PKEY_ASN1_METHS`
3463
+ * * `crypto.constants.ENGINE_METHOD_ALL`
3464
+ * * `crypto.constants.ENGINE_METHOD_NONE`
3467
3465
  * @since v0.11.11
3468
- * @param [flags=crypto.constants.ENGINE_METHOD_ALL]
3466
+ * @param flags
3469
3467
  */
3470
3468
  function setEngine(engine: string, flags?: number): void;
3471
3469
  /**
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.
3470
+ * A convenient alias for {@link webcrypto.getRandomValues}. This
3471
+ * implementation is not compliant with the Web Crypto spec, to write
3472
+ * web-compatible code use {@link webcrypto.getRandomValues} instead.
3475
3473
  * @since v17.4.0
3476
- * @returns Returns `typedArray`.
3474
+ * @return Returns `typedArray`.
3477
3475
  */
3478
3476
  function getRandomValues<T extends webcrypto.BufferSource>(typedArray: T): T;
3479
3477
  /**
@@ -3638,7 +3636,7 @@ declare module 'crypto' {
3638
3636
  * The UUID is generated using a cryptographic pseudorandom number generator.
3639
3637
  * @since v16.7.0
3640
3638
  */
3641
- randomUUID(): string;
3639
+ randomUUID(): UUID;
3642
3640
  CryptoKey: CryptoKeyConstructor;
3643
3641
  }
3644
3642
  // This constructor throws ILLEGAL_CONSTRUCTOR so it should not be newable.