@types/node 18.16.5 → 20.1.0
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.
- node v18.16/README.md → node/README.md +2 -2
- node v18.16/ts4.8/assert.d.ts → node/assert.d.ts +71 -75
- node v18.16/async_hooks.d.ts → node/async_hooks.d.ts +62 -42
- node v18.16/buffer.d.ts → node/buffer.d.ts +127 -99
- node v18.16/child_process.d.ts → node/child_process.d.ts +50 -54
- node v18.16/ts4.8/cluster.d.ts → node/cluster.d.ts +12 -12
- node v18.16/ts4.8/console.d.ts → node/console.d.ts +5 -5
- node v18.16/crypto.d.ts → node/crypto.d.ts +209 -220
- node v18.16/ts4.8/dgram.d.ts → node/dgram.d.ts +15 -15
- node v18.16/diagnostics_channel.d.ts → node/diagnostics_channel.d.ts +25 -26
- node v18.16/dns/promises.d.ts → node/dns/promises.d.ts +6 -6
- node v18.16/ts4.8/dns.d.ts → node/dns.d.ts +24 -16
- node v18.16/domain.d.ts → node/domain.d.ts +4 -4
- node v18.16/events.d.ts → node/events.d.ts +60 -60
- node v18.16/fs/promises.d.ts → node/fs/promises.d.ts +78 -48
- node v18.16/fs.d.ts → node/fs.d.ts +117 -81
- node v18.16/http.d.ts → node/http.d.ts +155 -145
- node v18.16/ts4.8/http2.d.ts → node/http2.d.ts +42 -46
- node v18.16/https.d.ts → node/https.d.ts +52 -153
- node v18.16/index.d.ts → node/index.d.ts +1 -1
- node v18.16/ts4.8/inspector.d.ts → node/inspector.d.ts +10 -3
- node v18.16/ts4.8/module.d.ts → node/module.d.ts +5 -4
- node v18.16/ts4.8/net.d.ts → node/net.d.ts +24 -21
- node v18.16/ts4.8/os.d.ts → node/os.d.ts +22 -18
- node v18.16/package.json → node/package.json +2 -2
- node v18.16/ts4.8/path.d.ts → node/path.d.ts +4 -4
- node v18.16/perf_hooks.d.ts → node/perf_hooks.d.ts +28 -15
- node v18.16/process.d.ts → node/process.d.ts +43 -46
- node v18.16/ts4.8/punycode.d.ts → node/punycode.d.ts +1 -1
- node v18.16/ts4.8/querystring.d.ts → node/querystring.d.ts +5 -5
- node v18.16/readline/promises.d.ts → node/readline/promises.d.ts +6 -4
- node v18.16/readline.d.ts → node/readline.d.ts +15 -15
- node v18.16/repl.d.ts → node/repl.d.ts +9 -9
- node v18.16/stream/consumers.d.ts → node/stream/consumers.d.ts +1 -1
- node v18.16/stream.d.ts → node/stream.d.ts +88 -136
- node v18.16/ts4.8/string_decoder.d.ts → node/string_decoder.d.ts +6 -6
- node v18.16/ts4.8/test.d.ts → node/test.d.ts +423 -186
- node v18.16/timers/promises.d.ts → node/timers/promises.d.ts +3 -3
- node v18.16/timers.d.ts → node/timers.d.ts +2 -2
- node v18.16/ts4.8/tls.d.ts → node/tls.d.ts +24 -16
- node v18.16/ts4.8/trace_events.d.ts → node/trace_events.d.ts +20 -9
- node v18.16/assert.d.ts → node/ts4.8/assert.d.ts +71 -75
- node v18.16/ts4.8/async_hooks.d.ts → node/ts4.8/async_hooks.d.ts +62 -42
- node v18.16/ts4.8/buffer.d.ts → node/ts4.8/buffer.d.ts +127 -99
- node v18.16/ts4.8/child_process.d.ts → node/ts4.8/child_process.d.ts +50 -54
- node v18.16/cluster.d.ts → node/ts4.8/cluster.d.ts +12 -12
- node v18.16/console.d.ts → node/ts4.8/console.d.ts +5 -5
- node v18.16/ts4.8/crypto.d.ts → node/ts4.8/crypto.d.ts +209 -220
- node v18.16/dgram.d.ts → node/ts4.8/dgram.d.ts +15 -15
- node v18.16/ts4.8/diagnostics_channel.d.ts → node/ts4.8/diagnostics_channel.d.ts +25 -26
- node v18.16/ts4.8/dns/promises.d.ts → node/ts4.8/dns/promises.d.ts +6 -6
- node v18.16/dns.d.ts → node/ts4.8/dns.d.ts +24 -16
- node v18.16/ts4.8/domain.d.ts → node/ts4.8/domain.d.ts +4 -4
- node v18.16/ts4.8/events.d.ts → node/ts4.8/events.d.ts +60 -60
- node v18.16/ts4.8/fs/promises.d.ts → node/ts4.8/fs/promises.d.ts +96 -45
- node v18.16/ts4.8/fs.d.ts → node/ts4.8/fs.d.ts +203 -67
- node v18.16/ts4.8/globals.d.ts → node/ts4.8/globals.d.ts +29 -28
- node v18.16/ts4.8/http.d.ts → node/ts4.8/http.d.ts +198 -126
- node v18.16/http2.d.ts → node/ts4.8/http2.d.ts +42 -46
- node v18.16/ts4.8/https.d.ts → node/ts4.8/https.d.ts +52 -153
- node v18.16/inspector.d.ts → node/ts4.8/inspector.d.ts +10 -3
- node v18.16/module.d.ts → node/ts4.8/module.d.ts +5 -4
- node v18.16/net.d.ts → node/ts4.8/net.d.ts +21 -18
- node v18.16/os.d.ts → node/ts4.8/os.d.ts +22 -18
- node v18.16/path.d.ts → node/ts4.8/path.d.ts +4 -4
- node v18.16/ts4.8/perf_hooks.d.ts → node/ts4.8/perf_hooks.d.ts +28 -15
- node v18.16/ts4.8/process.d.ts → node/ts4.8/process.d.ts +43 -46
- node v18.16/punycode.d.ts → node/ts4.8/punycode.d.ts +1 -1
- node v18.16/querystring.d.ts → node/ts4.8/querystring.d.ts +5 -5
- node v18.16/ts4.8/readline/promises.d.ts → node/ts4.8/readline/promises.d.ts +6 -4
- node v18.16/ts4.8/readline.d.ts → node/ts4.8/readline.d.ts +15 -15
- node v18.16/ts4.8/repl.d.ts → node/ts4.8/repl.d.ts +9 -9
- node v18.16/ts4.8/stream/consumers.d.ts → node/ts4.8/stream/consumers.d.ts +1 -1
- node v18.16/ts4.8/stream.d.ts → node/ts4.8/stream.d.ts +91 -139
- node v18.16/string_decoder.d.ts → node/ts4.8/string_decoder.d.ts +6 -6
- node v18.16/test.d.ts → node/ts4.8/test.d.ts +423 -186
- node v18.16/ts4.8/timers/promises.d.ts → node/ts4.8/timers/promises.d.ts +3 -3
- node v18.16/ts4.8/timers.d.ts → node/ts4.8/timers.d.ts +9 -2
- node v18.16/tls.d.ts → node/ts4.8/tls.d.ts +24 -16
- node v18.16/trace_events.d.ts → node/ts4.8/trace_events.d.ts +20 -9
- node v18.16/tty.d.ts → node/ts4.8/tty.d.ts +4 -5
- node v18.16/ts4.8/url.d.ts → node/ts4.8/url.d.ts +26 -36
- node v18.16/ts4.8/util.d.ts → node/ts4.8/util.d.ts +143 -116
- node v18.16/ts4.8/v8.d.ts → node/ts4.8/v8.d.ts +110 -16
- node v18.16/vm.d.ts → node/ts4.8/vm.d.ts +292 -42
- node v18.16/wasi.d.ts → node/ts4.8/wasi.d.ts +13 -19
- node v18.16/ts4.8/worker_threads.d.ts → node/ts4.8/worker_threads.d.ts +32 -34
- node v18.16/zlib.d.ts → node/ts4.8/zlib.d.ts +11 -11
- node v18.16/ts4.8/tty.d.ts → node/tty.d.ts +4 -5
- node v18.16/url.d.ts → node/url.d.ts +26 -36
- node v18.16/util.d.ts → node/util.d.ts +146 -111
- node v18.16/v8.d.ts → node/v8.d.ts +110 -16
- node v18.16/ts4.8/vm.d.ts → node/vm.d.ts +292 -42
- node v18.16/ts4.8/wasi.d.ts → node/wasi.d.ts +13 -19
- node v18.16/worker_threads.d.ts → node/worker_threads.d.ts +32 -34
- node v18.16/ts4.8/zlib.d.ts → node/zlib.d.ts +11 -11
- {node v18.16 → node}/LICENSE +0 -0
- {node v18.16 → node}/assert/strict.d.ts +0 -0
- {node v18.16 → node}/constants.d.ts +0 -0
- {node v18.16 → node}/dom-events.d.ts +0 -0
- {node v18.16 → node}/globals.d.ts +0 -0
- {node v18.16 → node}/globals.global.d.ts +0 -0
- {node v18.16 → node}/stream/promises.d.ts +0 -0
- {node v18.16 → node}/stream/web.d.ts +0 -0
- {node v18.16 → node}/ts4.8/assert/strict.d.ts +0 -0
- {node v18.16 → node}/ts4.8/constants.d.ts +0 -0
- {node v18.16 → node}/ts4.8/dom-events.d.ts +0 -0
- {node v18.16 → node}/ts4.8/globals.global.d.ts +0 -0
- {node v18.16 → node}/ts4.8/index.d.ts +0 -0
- {node v18.16 → node}/ts4.8/stream/promises.d.ts +0 -0
- {node v18.16 → node}/ts4.8/stream/web.d.ts +0 -0
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The `crypto` module provides cryptographic functionality that includes a
|
|
3
|
-
* wrappers for OpenSSL's hash, HMAC, cipher, decipher, sign, and verify
|
|
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/
|
|
17
|
+
* @see [source](https://github.com/nodejs/node/blob/v20.1.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)));
|
|
@@ -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 {
|
|
579
|
-
* const { subtle } =
|
|
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';
|
|
@@ -1203,8 +1192,8 @@ declare module 'crypto' {
|
|
|
1203
1192
|
*
|
|
1204
1193
|
* ```js
|
|
1205
1194
|
* const {
|
|
1206
|
-
* generateKey
|
|
1207
|
-
* } = await import('crypto');
|
|
1195
|
+
* generateKey,
|
|
1196
|
+
* } = await import('node:crypto');
|
|
1208
1197
|
*
|
|
1209
1198
|
* generateKey('hmac', { length: 64 }, (err, key) => {
|
|
1210
1199
|
* if (err) throw err;
|
|
@@ -1226,8 +1215,8 @@ declare module 'crypto' {
|
|
|
1226
1215
|
*
|
|
1227
1216
|
* ```js
|
|
1228
1217
|
* const {
|
|
1229
|
-
* generateKeySync
|
|
1230
|
-
* } = await import('crypto');
|
|
1218
|
+
* generateKeySync,
|
|
1219
|
+
* } = await import('node:crypto');
|
|
1231
1220
|
*
|
|
1232
1221
|
* const key = generateKeySync('hmac', { length: 64 });
|
|
1233
1222
|
* console.log(key.export().toString('hex')); // e89..........41e
|
|
@@ -1327,11 +1316,11 @@ declare module 'crypto' {
|
|
|
1327
1316
|
* const {
|
|
1328
1317
|
* generateKeyPairSync,
|
|
1329
1318
|
* createSign,
|
|
1330
|
-
* createVerify
|
|
1331
|
-
* } = await import('crypto');
|
|
1319
|
+
* createVerify,
|
|
1320
|
+
* } = await import('node:crypto');
|
|
1332
1321
|
*
|
|
1333
1322
|
* const { privateKey, publicKey } = generateKeyPairSync('ec', {
|
|
1334
|
-
* namedCurve: 'sect239k1'
|
|
1323
|
+
* namedCurve: 'sect239k1',
|
|
1335
1324
|
* });
|
|
1336
1325
|
*
|
|
1337
1326
|
* const sign = createSign('SHA256');
|
|
@@ -1352,8 +1341,8 @@ declare module 'crypto' {
|
|
|
1352
1341
|
* const {
|
|
1353
1342
|
* generateKeyPairSync,
|
|
1354
1343
|
* createSign,
|
|
1355
|
-
* createVerify
|
|
1356
|
-
* } = await import('crypto');
|
|
1344
|
+
* createVerify,
|
|
1345
|
+
* } = await import('node:crypto');
|
|
1357
1346
|
*
|
|
1358
1347
|
* const { privateKey, publicKey } = generateKeyPairSync('rsa', {
|
|
1359
1348
|
* modulusLength: 2048,
|
|
@@ -1493,11 +1482,11 @@ declare module 'crypto' {
|
|
|
1493
1482
|
* Instances of the `DiffieHellman` class can be created using the {@link createDiffieHellman} function.
|
|
1494
1483
|
*
|
|
1495
1484
|
* ```js
|
|
1496
|
-
* import assert from 'assert';
|
|
1485
|
+
* import assert from 'node:assert';
|
|
1497
1486
|
*
|
|
1498
1487
|
* const {
|
|
1499
|
-
* createDiffieHellman
|
|
1500
|
-
* } = await import('crypto');
|
|
1488
|
+
* createDiffieHellman,
|
|
1489
|
+
* } = await import('node:crypto');
|
|
1501
1490
|
*
|
|
1502
1491
|
* // Generate Alice's keys...
|
|
1503
1492
|
* const alice = createDiffieHellman(2048);
|
|
@@ -1603,7 +1592,7 @@ declare module 'crypto' {
|
|
|
1603
1592
|
* A bit field containing any warnings and/or errors resulting from a check
|
|
1604
1593
|
* performed during initialization of the `DiffieHellman` object.
|
|
1605
1594
|
*
|
|
1606
|
-
* 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):
|
|
1607
1596
|
*
|
|
1608
1597
|
* * `DH_CHECK_P_NOT_SAFE_PRIME`
|
|
1609
1598
|
* * `DH_CHECK_P_NOT_PRIME`
|
|
@@ -1638,16 +1627,16 @@ declare module 'crypto' {
|
|
|
1638
1627
|
*/
|
|
1639
1628
|
const DiffieHellmanGroup: DiffieHellmanGroupConstructor;
|
|
1640
1629
|
interface DiffieHellmanGroupConstructor {
|
|
1641
|
-
new(name: string): DiffieHellmanGroup;
|
|
1630
|
+
new (name: string): DiffieHellmanGroup;
|
|
1642
1631
|
(name: string): DiffieHellmanGroup;
|
|
1643
1632
|
readonly prototype: DiffieHellmanGroup;
|
|
1644
1633
|
}
|
|
1645
1634
|
type DiffieHellmanGroup = Omit<DiffieHellman, 'setPublicKey' | 'setPrivateKey'>;
|
|
1646
1635
|
/**
|
|
1647
1636
|
* Creates a predefined `DiffieHellmanGroup` key exchange object. The
|
|
1648
|
-
* supported groups are
|
|
1649
|
-
*
|
|
1650
|
-
* 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
|
|
1651
1640
|
* the keys (with `diffieHellman.setPublicKey()`, for example). The
|
|
1652
1641
|
* advantage of using this method is that the parties do not have to
|
|
1653
1642
|
* generate nor exchange a group modulus beforehand, saving both processor
|
|
@@ -1657,8 +1646,8 @@ declare module 'crypto' {
|
|
|
1657
1646
|
*
|
|
1658
1647
|
* ```js
|
|
1659
1648
|
* const {
|
|
1660
|
-
* getDiffieHellman
|
|
1661
|
-
* } = await import('crypto');
|
|
1649
|
+
* getDiffieHellman,
|
|
1650
|
+
* } = await import('node:crypto');
|
|
1662
1651
|
* const alice = getDiffieHellman('modp14');
|
|
1663
1652
|
* const bob = getDiffieHellman('modp14');
|
|
1664
1653
|
*
|
|
@@ -1688,9 +1677,6 @@ declare module 'crypto' {
|
|
|
1688
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
|
|
1689
1678
|
* thrown if any of the input arguments specify invalid values or types.
|
|
1690
1679
|
*
|
|
1691
|
-
* If `digest` is `null`, `'sha1'` will be used. This behavior is deprecated,
|
|
1692
|
-
* please specify a `digest` explicitly.
|
|
1693
|
-
*
|
|
1694
1680
|
* The `iterations` argument must be a number set as high as possible. The
|
|
1695
1681
|
* higher the number of iterations, the more secure the derived key will be,
|
|
1696
1682
|
* but will take a longer amount of time to complete.
|
|
@@ -1702,8 +1688,8 @@ declare module 'crypto' {
|
|
|
1702
1688
|
*
|
|
1703
1689
|
* ```js
|
|
1704
1690
|
* const {
|
|
1705
|
-
* pbkdf2
|
|
1706
|
-
* } = await import('crypto');
|
|
1691
|
+
* pbkdf2,
|
|
1692
|
+
* } = await import('node:crypto');
|
|
1707
1693
|
*
|
|
1708
1694
|
* pbkdf2('secret', 'salt', 100000, 64, 'sha512', (err, derivedKey) => {
|
|
1709
1695
|
* if (err) throw err;
|
|
@@ -1711,18 +1697,6 @@ declare module 'crypto' {
|
|
|
1711
1697
|
* });
|
|
1712
1698
|
* ```
|
|
1713
1699
|
*
|
|
1714
|
-
* The `crypto.DEFAULT_ENCODING` property can be used to change the way the`derivedKey` is passed to the callback. This property, however, has been
|
|
1715
|
-
* deprecated and use should be avoided.
|
|
1716
|
-
*
|
|
1717
|
-
* ```js
|
|
1718
|
-
* import crypto from 'crypto';
|
|
1719
|
-
* crypto.DEFAULT_ENCODING = 'hex';
|
|
1720
|
-
* crypto.pbkdf2('secret', 'salt', 100000, 512, 'sha512', (err, derivedKey) => {
|
|
1721
|
-
* if (err) throw err;
|
|
1722
|
-
* console.log(derivedKey); // '3745e48...aa39b34'
|
|
1723
|
-
* });
|
|
1724
|
-
* ```
|
|
1725
|
-
*
|
|
1726
1700
|
* An array of supported digest functions can be retrieved using {@link getHashes}.
|
|
1727
1701
|
*
|
|
1728
1702
|
* This API uses libuv's threadpool, which can have surprising and
|
|
@@ -1738,9 +1712,6 @@ declare module 'crypto' {
|
|
|
1738
1712
|
* If an error occurs an `Error` will be thrown, otherwise the derived key will be
|
|
1739
1713
|
* returned as a `Buffer`.
|
|
1740
1714
|
*
|
|
1741
|
-
* If `digest` is `null`, `'sha1'` will be used. This behavior is deprecated,
|
|
1742
|
-
* please specify a `digest` explicitly.
|
|
1743
|
-
*
|
|
1744
1715
|
* The `iterations` argument must be a number set as high as possible. The
|
|
1745
1716
|
* higher the number of iterations, the more secure the derived key will be,
|
|
1746
1717
|
* but will take a longer amount of time to complete.
|
|
@@ -1752,23 +1723,13 @@ declare module 'crypto' {
|
|
|
1752
1723
|
*
|
|
1753
1724
|
* ```js
|
|
1754
1725
|
* const {
|
|
1755
|
-
* pbkdf2Sync
|
|
1756
|
-
* } = await import('crypto');
|
|
1726
|
+
* pbkdf2Sync,
|
|
1727
|
+
* } = await import('node:crypto');
|
|
1757
1728
|
*
|
|
1758
1729
|
* const key = pbkdf2Sync('secret', 'salt', 100000, 64, 'sha512');
|
|
1759
1730
|
* console.log(key.toString('hex')); // '3745e48...08d59ae'
|
|
1760
1731
|
* ```
|
|
1761
1732
|
*
|
|
1762
|
-
* The `crypto.DEFAULT_ENCODING` property may be used to change the way the`derivedKey` is returned. This property, however, is deprecated and use
|
|
1763
|
-
* should be avoided.
|
|
1764
|
-
*
|
|
1765
|
-
* ```js
|
|
1766
|
-
* import crypto from 'crypto';
|
|
1767
|
-
* crypto.DEFAULT_ENCODING = 'hex';
|
|
1768
|
-
* const key = crypto.pbkdf2Sync('secret', 'salt', 100000, 512, 'sha512');
|
|
1769
|
-
* console.log(key); // '3745e48...aa39b34'
|
|
1770
|
-
* ```
|
|
1771
|
-
*
|
|
1772
1733
|
* An array of supported digest functions can be retrieved using {@link getHashes}.
|
|
1773
1734
|
* @since v0.9.3
|
|
1774
1735
|
*/
|
|
@@ -1784,8 +1745,8 @@ declare module 'crypto' {
|
|
|
1784
1745
|
* ```js
|
|
1785
1746
|
* // Asynchronous
|
|
1786
1747
|
* const {
|
|
1787
|
-
* randomBytes
|
|
1788
|
-
* } = await import('crypto');
|
|
1748
|
+
* randomBytes,
|
|
1749
|
+
* } = await import('node:crypto');
|
|
1789
1750
|
*
|
|
1790
1751
|
* randomBytes(256, (err, buf) => {
|
|
1791
1752
|
* if (err) throw err;
|
|
@@ -1800,8 +1761,8 @@ declare module 'crypto' {
|
|
|
1800
1761
|
* ```js
|
|
1801
1762
|
* // Synchronous
|
|
1802
1763
|
* const {
|
|
1803
|
-
* randomBytes
|
|
1804
|
-
* } = await import('crypto');
|
|
1764
|
+
* randomBytes,
|
|
1765
|
+
* } = await import('node:crypto');
|
|
1805
1766
|
*
|
|
1806
1767
|
* const buf = randomBytes(256);
|
|
1807
1768
|
* console.log(
|
|
@@ -1833,7 +1794,7 @@ declare module 'crypto' {
|
|
|
1833
1794
|
* Return a random integer `n` such that `min <= n < max`. This
|
|
1834
1795
|
* implementation avoids [modulo bias](https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#Modulo_bias).
|
|
1835
1796
|
*
|
|
1836
|
-
* The range (`max - min`) must be less than
|
|
1797
|
+
* The range (`max - min`) must be less than 248. `min` and `max` must
|
|
1837
1798
|
* be [safe integers](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger).
|
|
1838
1799
|
*
|
|
1839
1800
|
* If the `callback` function is not provided, the random integer is
|
|
@@ -1842,8 +1803,8 @@ declare module 'crypto' {
|
|
|
1842
1803
|
* ```js
|
|
1843
1804
|
* // Asynchronous
|
|
1844
1805
|
* const {
|
|
1845
|
-
* randomInt
|
|
1846
|
-
* } = await import('crypto');
|
|
1806
|
+
* randomInt,
|
|
1807
|
+
* } = await import('node:crypto');
|
|
1847
1808
|
*
|
|
1848
1809
|
* randomInt(3, (err, n) => {
|
|
1849
1810
|
* if (err) throw err;
|
|
@@ -1854,8 +1815,8 @@ declare module 'crypto' {
|
|
|
1854
1815
|
* ```js
|
|
1855
1816
|
* // Synchronous
|
|
1856
1817
|
* const {
|
|
1857
|
-
* randomInt
|
|
1858
|
-
* } = await import('crypto');
|
|
1818
|
+
* randomInt,
|
|
1819
|
+
* } = await import('node:crypto');
|
|
1859
1820
|
*
|
|
1860
1821
|
* const n = randomInt(3);
|
|
1861
1822
|
* console.log(`Random number chosen from (0, 1, 2): ${n}`);
|
|
@@ -1864,8 +1825,8 @@ declare module 'crypto' {
|
|
|
1864
1825
|
* ```js
|
|
1865
1826
|
* // With `min` argument
|
|
1866
1827
|
* const {
|
|
1867
|
-
* randomInt
|
|
1868
|
-
* } = await import('crypto');
|
|
1828
|
+
* randomInt,
|
|
1829
|
+
* } = await import('node:crypto');
|
|
1869
1830
|
*
|
|
1870
1831
|
* const n = randomInt(1, 7);
|
|
1871
1832
|
* console.log(`The dice rolled: ${n}`);
|
|
@@ -1883,8 +1844,8 @@ declare module 'crypto' {
|
|
|
1883
1844
|
* Synchronous version of {@link randomFill}.
|
|
1884
1845
|
*
|
|
1885
1846
|
* ```js
|
|
1886
|
-
* import { Buffer } from 'buffer';
|
|
1887
|
-
* const { randomFillSync } = await import('crypto');
|
|
1847
|
+
* import { Buffer } from 'node:buffer';
|
|
1848
|
+
* const { randomFillSync } = await import('node:crypto');
|
|
1888
1849
|
*
|
|
1889
1850
|
* const buf = Buffer.alloc(10);
|
|
1890
1851
|
* console.log(randomFillSync(buf).toString('hex'));
|
|
@@ -1900,8 +1861,8 @@ declare module 'crypto' {
|
|
|
1900
1861
|
* Any `ArrayBuffer`, `TypedArray` or `DataView` instance may be passed as`buffer`.
|
|
1901
1862
|
*
|
|
1902
1863
|
* ```js
|
|
1903
|
-
* import { Buffer } from 'buffer';
|
|
1904
|
-
* const { randomFillSync } = await import('crypto');
|
|
1864
|
+
* import { Buffer } from 'node:buffer';
|
|
1865
|
+
* const { randomFillSync } = await import('node:crypto');
|
|
1905
1866
|
*
|
|
1906
1867
|
* const a = new Uint32Array(10);
|
|
1907
1868
|
* console.log(Buffer.from(randomFillSync(a).buffer,
|
|
@@ -1929,8 +1890,8 @@ declare module 'crypto' {
|
|
|
1929
1890
|
* If the `callback` function is not provided, an error will be thrown.
|
|
1930
1891
|
*
|
|
1931
1892
|
* ```js
|
|
1932
|
-
* import { Buffer } from 'buffer';
|
|
1933
|
-
* const { randomFill } = await import('crypto');
|
|
1893
|
+
* import { Buffer } from 'node:buffer';
|
|
1894
|
+
* const { randomFill } = await import('node:crypto');
|
|
1934
1895
|
*
|
|
1935
1896
|
* const buf = Buffer.alloc(10);
|
|
1936
1897
|
* randomFill(buf, (err, buf) => {
|
|
@@ -1959,8 +1920,8 @@ declare module 'crypto' {
|
|
|
1959
1920
|
* distribution and have no meaningful lower or upper bounds.
|
|
1960
1921
|
*
|
|
1961
1922
|
* ```js
|
|
1962
|
-
* import { Buffer } from 'buffer';
|
|
1963
|
-
* const { randomFill } = await import('crypto');
|
|
1923
|
+
* import { Buffer } from 'node:buffer';
|
|
1924
|
+
* const { randomFill } = await import('node:crypto');
|
|
1964
1925
|
*
|
|
1965
1926
|
* const a = new Uint32Array(10);
|
|
1966
1927
|
* randomFill(a, (err, buf) => {
|
|
@@ -2026,8 +1987,8 @@ declare module 'crypto' {
|
|
|
2026
1987
|
*
|
|
2027
1988
|
* ```js
|
|
2028
1989
|
* const {
|
|
2029
|
-
* scrypt
|
|
2030
|
-
* } = await import('crypto');
|
|
1990
|
+
* scrypt,
|
|
1991
|
+
* } = await import('node:crypto');
|
|
2031
1992
|
*
|
|
2032
1993
|
* // Using the factory defaults.
|
|
2033
1994
|
* scrypt('password', 'salt', 64, (err, derivedKey) => {
|
|
@@ -2062,8 +2023,8 @@ declare module 'crypto' {
|
|
|
2062
2023
|
*
|
|
2063
2024
|
* ```js
|
|
2064
2025
|
* const {
|
|
2065
|
-
* scryptSync
|
|
2066
|
-
* } = await import('crypto');
|
|
2026
|
+
* scryptSync,
|
|
2027
|
+
* } = await import('node:crypto');
|
|
2067
2028
|
* // Using the factory defaults.
|
|
2068
2029
|
*
|
|
2069
2030
|
* const key1 = scryptSync('password', 'salt', 64);
|
|
@@ -2134,8 +2095,8 @@ declare module 'crypto' {
|
|
|
2134
2095
|
/**
|
|
2135
2096
|
* ```js
|
|
2136
2097
|
* const {
|
|
2137
|
-
* getCiphers
|
|
2138
|
-
* } = await import('crypto');
|
|
2098
|
+
* getCiphers,
|
|
2099
|
+
* } = await import('node:crypto');
|
|
2139
2100
|
*
|
|
2140
2101
|
* console.log(getCiphers()); // ['aes-128-cbc', 'aes-128-ccm', ...]
|
|
2141
2102
|
* ```
|
|
@@ -2146,8 +2107,8 @@ declare module 'crypto' {
|
|
|
2146
2107
|
/**
|
|
2147
2108
|
* ```js
|
|
2148
2109
|
* const {
|
|
2149
|
-
* getCurves
|
|
2150
|
-
* } = await import('crypto');
|
|
2110
|
+
* getCurves,
|
|
2111
|
+
* } = await import('node:crypto');
|
|
2151
2112
|
*
|
|
2152
2113
|
* console.log(getCurves()); // ['Oakley-EC2N-3', 'Oakley-EC2N-4', ...]
|
|
2153
2114
|
* ```
|
|
@@ -2161,7 +2122,8 @@ declare module 'crypto' {
|
|
|
2161
2122
|
*/
|
|
2162
2123
|
function getFips(): 1 | 0;
|
|
2163
2124
|
/**
|
|
2164
|
-
* Enables the FIPS compliant crypto provider in a FIPS-enabled Node.js build.
|
|
2125
|
+
* Enables the FIPS compliant crypto provider in a FIPS-enabled Node.js build.
|
|
2126
|
+
* Throws an error if FIPS mode is not available.
|
|
2165
2127
|
* @since v10.0.0
|
|
2166
2128
|
* @param bool `true` to enable FIPS mode.
|
|
2167
2129
|
*/
|
|
@@ -2169,8 +2131,8 @@ declare module 'crypto' {
|
|
|
2169
2131
|
/**
|
|
2170
2132
|
* ```js
|
|
2171
2133
|
* const {
|
|
2172
|
-
* getHashes
|
|
2173
|
-
* } = await import('crypto');
|
|
2134
|
+
* getHashes,
|
|
2135
|
+
* } = await import('node:crypto');
|
|
2174
2136
|
*
|
|
2175
2137
|
* console.log(getHashes()); // ['DSA', 'DSA-SHA', 'DSA-SHA1', ...]
|
|
2176
2138
|
* ```
|
|
@@ -2185,11 +2147,11 @@ declare module 'crypto' {
|
|
|
2185
2147
|
* Instances of the `ECDH` class can be created using the {@link createECDH} function.
|
|
2186
2148
|
*
|
|
2187
2149
|
* ```js
|
|
2188
|
-
* import assert from 'assert';
|
|
2150
|
+
* import assert from 'node:assert';
|
|
2189
2151
|
*
|
|
2190
2152
|
* const {
|
|
2191
|
-
* createECDH
|
|
2192
|
-
* } = await import('crypto');
|
|
2153
|
+
* createECDH,
|
|
2154
|
+
* } = await import('node:crypto');
|
|
2193
2155
|
*
|
|
2194
2156
|
* // Generate Alice's keys...
|
|
2195
2157
|
* const alice = createECDH('secp521r1');
|
|
@@ -2230,8 +2192,8 @@ declare module 'crypto' {
|
|
|
2230
2192
|
* ```js
|
|
2231
2193
|
* const {
|
|
2232
2194
|
* createECDH,
|
|
2233
|
-
* ECDH
|
|
2234
|
-
* } = await import('crypto');
|
|
2195
|
+
* ECDH,
|
|
2196
|
+
* } = await import('node:crypto');
|
|
2235
2197
|
*
|
|
2236
2198
|
* const ecdh = createECDH('secp256k1');
|
|
2237
2199
|
* ecdh.generateKeys();
|
|
@@ -2309,7 +2271,7 @@ declare module 'crypto' {
|
|
|
2309
2271
|
* If `encoding` is specified, a string is returned; otherwise a `Buffer` is
|
|
2310
2272
|
* returned.
|
|
2311
2273
|
* @since v0.11.14
|
|
2312
|
-
* @param
|
|
2274
|
+
* @param encoding The `encoding` of the return value.
|
|
2313
2275
|
* @param [format='uncompressed']
|
|
2314
2276
|
* @return The EC Diffie-Hellman public key in the specified `encoding` and `format`.
|
|
2315
2277
|
*/
|
|
@@ -2338,8 +2300,10 @@ declare module 'crypto' {
|
|
|
2338
2300
|
*/
|
|
2339
2301
|
function createECDH(curveName: string): ECDH;
|
|
2340
2302
|
/**
|
|
2341
|
-
* This function
|
|
2342
|
-
*
|
|
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
|
|
2343
2307
|
* would allow an attacker to guess one of the values. This is suitable for
|
|
2344
2308
|
* comparing HMAC digests or secret values like authentication cookies or [capability urls](https://www.w3.org/TR/capability-urls/).
|
|
2345
2309
|
*
|
|
@@ -2351,14 +2315,16 @@ declare module 'crypto' {
|
|
|
2351
2315
|
* entry, such as `Uint16Array`, the result will be computed using the platform
|
|
2352
2316
|
* byte order.
|
|
2353
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
|
+
*
|
|
2354
2322
|
* Use of `crypto.timingSafeEqual` does not guarantee that the _surrounding_ code
|
|
2355
2323
|
* is timing-safe. Care should be taken to ensure that the surrounding code does
|
|
2356
2324
|
* not introduce timing vulnerabilities.
|
|
2357
2325
|
* @since v6.6.0
|
|
2358
2326
|
*/
|
|
2359
2327
|
function timingSafeEqual(a: NodeJS.ArrayBufferView, b: NodeJS.ArrayBufferView): boolean;
|
|
2360
|
-
/** @deprecated since v10.0.0 */
|
|
2361
|
-
const DEFAULT_ENCODING: BufferEncoding;
|
|
2362
2328
|
type KeyType = 'rsa' | 'rsa-pss' | 'dsa' | 'ec' | 'ed25519' | 'ed448' | 'x25519' | 'x448';
|
|
2363
2329
|
type KeyFormat = 'pem' | 'der' | 'jwk';
|
|
2364
2330
|
interface BasePrivateKeyEncodingOptions<T extends KeyFormat> {
|
|
@@ -2556,8 +2522,8 @@ declare module 'crypto' {
|
|
|
2556
2522
|
*
|
|
2557
2523
|
* ```js
|
|
2558
2524
|
* const {
|
|
2559
|
-
* generateKeyPairSync
|
|
2560
|
-
* } = await import('crypto');
|
|
2525
|
+
* generateKeyPairSync,
|
|
2526
|
+
* } = await import('node:crypto');
|
|
2561
2527
|
*
|
|
2562
2528
|
* const {
|
|
2563
2529
|
* publicKey,
|
|
@@ -2566,14 +2532,14 @@ declare module 'crypto' {
|
|
|
2566
2532
|
* modulusLength: 4096,
|
|
2567
2533
|
* publicKeyEncoding: {
|
|
2568
2534
|
* type: 'spki',
|
|
2569
|
-
* format: 'pem'
|
|
2535
|
+
* format: 'pem',
|
|
2570
2536
|
* },
|
|
2571
2537
|
* privateKeyEncoding: {
|
|
2572
2538
|
* type: 'pkcs8',
|
|
2573
2539
|
* format: 'pem',
|
|
2574
2540
|
* cipher: 'aes-256-cbc',
|
|
2575
|
-
* passphrase: 'top secret'
|
|
2576
|
-
* }
|
|
2541
|
+
* passphrase: 'top secret',
|
|
2542
|
+
* },
|
|
2577
2543
|
* });
|
|
2578
2544
|
* ```
|
|
2579
2545
|
*
|
|
@@ -2635,21 +2601,21 @@ declare module 'crypto' {
|
|
|
2635
2601
|
*
|
|
2636
2602
|
* ```js
|
|
2637
2603
|
* const {
|
|
2638
|
-
* generateKeyPair
|
|
2639
|
-
* } = await import('crypto');
|
|
2604
|
+
* generateKeyPair,
|
|
2605
|
+
* } = await import('node:crypto');
|
|
2640
2606
|
*
|
|
2641
2607
|
* generateKeyPair('rsa', {
|
|
2642
2608
|
* modulusLength: 4096,
|
|
2643
2609
|
* publicKeyEncoding: {
|
|
2644
2610
|
* type: 'spki',
|
|
2645
|
-
* format: 'pem'
|
|
2611
|
+
* format: 'pem',
|
|
2646
2612
|
* },
|
|
2647
2613
|
* privateKeyEncoding: {
|
|
2648
2614
|
* type: 'pkcs8',
|
|
2649
2615
|
* format: 'pem',
|
|
2650
2616
|
* cipher: 'aes-256-cbc',
|
|
2651
|
-
* passphrase: 'top secret'
|
|
2652
|
-
* }
|
|
2617
|
+
* passphrase: 'top secret',
|
|
2618
|
+
* },
|
|
2653
2619
|
* }, (err, publicKey, privateKey) => {
|
|
2654
2620
|
* // Handle errors and use the generated key pair.
|
|
2655
2621
|
* });
|
|
@@ -3050,10 +3016,10 @@ declare module 'crypto' {
|
|
|
3050
3016
|
* of the input arguments specify invalid values or types.
|
|
3051
3017
|
*
|
|
3052
3018
|
* ```js
|
|
3053
|
-
* import { Buffer } from 'buffer';
|
|
3019
|
+
* import { Buffer } from 'node:buffer';
|
|
3054
3020
|
* const {
|
|
3055
|
-
* hkdf
|
|
3056
|
-
* } = await import('crypto');
|
|
3021
|
+
* hkdf,
|
|
3022
|
+
* } = await import('node:crypto');
|
|
3057
3023
|
*
|
|
3058
3024
|
* hkdf('sha512', 'key', 'salt', 'info', 64, (err, derivedKey) => {
|
|
3059
3025
|
* if (err) throw err;
|
|
@@ -3062,7 +3028,7 @@ declare module 'crypto' {
|
|
|
3062
3028
|
* ```
|
|
3063
3029
|
* @since v15.0.0
|
|
3064
3030
|
* @param digest The digest algorithm to use.
|
|
3065
|
-
* @param ikm The input keying material.
|
|
3031
|
+
* @param ikm The input keying material. Must be provided but can be zero-length.
|
|
3066
3032
|
* @param salt The salt value. Must be provided but can be zero-length.
|
|
3067
3033
|
* @param info Additional info value. Must be provided but can be zero-length, and cannot be more than 1024 bytes.
|
|
3068
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`
|
|
@@ -3079,17 +3045,17 @@ declare module 'crypto' {
|
|
|
3079
3045
|
* types, or if the derived key cannot be generated.
|
|
3080
3046
|
*
|
|
3081
3047
|
* ```js
|
|
3082
|
-
* import { Buffer } from 'buffer';
|
|
3048
|
+
* import { Buffer } from 'node:buffer';
|
|
3083
3049
|
* const {
|
|
3084
|
-
* hkdfSync
|
|
3085
|
-
* } = await import('crypto');
|
|
3050
|
+
* hkdfSync,
|
|
3051
|
+
* } = await import('node:crypto');
|
|
3086
3052
|
*
|
|
3087
3053
|
* const derivedKey = hkdfSync('sha512', 'key', 'salt', 'info', 64);
|
|
3088
3054
|
* console.log(Buffer.from(derivedKey).toString('hex')); // '24156e2...5391653'
|
|
3089
3055
|
* ```
|
|
3090
3056
|
* @since v15.0.0
|
|
3091
3057
|
* @param digest The digest algorithm to use.
|
|
3092
|
-
* @param ikm The input keying material.
|
|
3058
|
+
* @param ikm The input keying material. Must be provided but can be zero-length.
|
|
3093
3059
|
* @param salt The salt value. Must be provided but can be zero-length.
|
|
3094
3060
|
* @param info Additional info value. Must be provided but can be zero-length, and cannot be more than 1024 bytes.
|
|
3095
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`
|
|
@@ -3162,7 +3128,7 @@ declare module 'crypto' {
|
|
|
3162
3128
|
* its information.
|
|
3163
3129
|
*
|
|
3164
3130
|
* ```js
|
|
3165
|
-
* const { X509Certificate } = await import('crypto');
|
|
3131
|
+
* const { X509Certificate } = await import('node:crypto');
|
|
3166
3132
|
*
|
|
3167
3133
|
* const x509 = new X509Certificate('{... pem encoded cert ...}');
|
|
3168
3134
|
*
|
|
@@ -3192,23 +3158,53 @@ declare module 'crypto' {
|
|
|
3192
3158
|
readonly fingerprint256: string;
|
|
3193
3159
|
/**
|
|
3194
3160
|
* The SHA-512 fingerprint of this certificate.
|
|
3195
|
-
*
|
|
3161
|
+
*
|
|
3162
|
+
* Because computing the SHA-256 fingerprint is usually faster and because it is
|
|
3163
|
+
* only half the size of the SHA-512 fingerprint, `x509.fingerprint256` may be
|
|
3164
|
+
* a better choice. While SHA-512 presumably provides a higher level of security in
|
|
3165
|
+
* general, the security of SHA-256 matches that of most algorithms that are
|
|
3166
|
+
* commonly used to sign certificates.
|
|
3167
|
+
* @since v17.2.0, v16.14.0
|
|
3196
3168
|
*/
|
|
3197
|
-
|
|
3169
|
+
readonly fingerprint512: string;
|
|
3198
3170
|
/**
|
|
3199
3171
|
* The complete subject of this certificate.
|
|
3200
3172
|
* @since v15.6.0
|
|
3201
3173
|
*/
|
|
3202
3174
|
readonly subject: string;
|
|
3203
3175
|
/**
|
|
3204
|
-
* The subject alternative name specified for this certificate
|
|
3205
|
-
*
|
|
3176
|
+
* The subject alternative name specified for this certificate.
|
|
3177
|
+
*
|
|
3178
|
+
* This is a comma-separated list of subject alternative names. Each entry begins
|
|
3179
|
+
* with a string identifying the kind of the subject alternative name followed by
|
|
3180
|
+
* a colon and the value associated with the entry.
|
|
3181
|
+
*
|
|
3182
|
+
* Earlier versions of Node.js incorrectly assumed that it is safe to split this
|
|
3183
|
+
* property at the two-character sequence `', '` (see [CVE-2021-44532](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-44532)). However,
|
|
3184
|
+
* both malicious and legitimate certificates can contain subject alternative names
|
|
3185
|
+
* that include this sequence when represented as a string.
|
|
3186
|
+
*
|
|
3187
|
+
* After the prefix denoting the type of the entry, the remainder of each entry
|
|
3188
|
+
* might be enclosed in quotes to indicate that the value is a JSON string literal.
|
|
3189
|
+
* For backward compatibility, Node.js only uses JSON string literals within this
|
|
3190
|
+
* property when necessary to avoid ambiguity. Third-party code should be prepared
|
|
3191
|
+
* to handle both possible entry formats.
|
|
3206
3192
|
* @since v15.6.0
|
|
3207
3193
|
*/
|
|
3208
3194
|
readonly subjectAltName: string | undefined;
|
|
3209
3195
|
/**
|
|
3210
|
-
*
|
|
3211
|
-
*
|
|
3196
|
+
* A textual representation of the certificate's authority information access
|
|
3197
|
+
* extension.
|
|
3198
|
+
*
|
|
3199
|
+
* This is a line feed separated list of access descriptions. Each line begins with
|
|
3200
|
+
* the access method and the kind of the access location, followed by a colon and
|
|
3201
|
+
* the value associated with the access location.
|
|
3202
|
+
*
|
|
3203
|
+
* After the prefix denoting the access method and the kind of the access location,
|
|
3204
|
+
* the remainder of each line might be enclosed in quotes to indicate that the
|
|
3205
|
+
* value is a JSON string literal. For backward compatibility, Node.js only uses
|
|
3206
|
+
* JSON string literals within this property when necessary to avoid ambiguity.
|
|
3207
|
+
* Third-party code should be prepared to handle both possible entry formats.
|
|
3212
3208
|
* @since v15.6.0
|
|
3213
3209
|
*/
|
|
3214
3210
|
readonly infoAccess: string | undefined;
|
|
@@ -3452,36 +3448,29 @@ declare module 'crypto' {
|
|
|
3452
3448
|
*
|
|
3453
3449
|
* `engine` could be either an id or a path to the engine's shared library.
|
|
3454
3450
|
*
|
|
3455
|
-
* The optional `flags` argument uses `ENGINE_METHOD_ALL` by default.
|
|
3456
|
-
*
|
|
3457
|
-
*
|
|
3458
|
-
*
|
|
3459
|
-
*
|
|
3460
|
-
*
|
|
3461
|
-
*
|
|
3462
|
-
*
|
|
3463
|
-
*
|
|
3464
|
-
*
|
|
3465
|
-
*
|
|
3466
|
-
*
|
|
3467
|
-
*
|
|
3468
|
-
* - `crypto.constants.ENGINE_METHOD_NONE`
|
|
3469
|
-
*
|
|
3470
|
-
* The flags below are deprecated in OpenSSL-1.1.0.
|
|
3471
|
-
*
|
|
3472
|
-
* - `crypto.constants.ENGINE_METHOD_ECDH`
|
|
3473
|
-
* - `crypto.constants.ENGINE_METHOD_ECDSA`
|
|
3474
|
-
* - `crypto.constants.ENGINE_METHOD_STORE`
|
|
3451
|
+
* 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`):
|
|
3452
|
+
*
|
|
3453
|
+
* * `crypto.constants.ENGINE_METHOD_RSA`
|
|
3454
|
+
* * `crypto.constants.ENGINE_METHOD_DSA`
|
|
3455
|
+
* * `crypto.constants.ENGINE_METHOD_DH`
|
|
3456
|
+
* * `crypto.constants.ENGINE_METHOD_RAND`
|
|
3457
|
+
* * `crypto.constants.ENGINE_METHOD_EC`
|
|
3458
|
+
* * `crypto.constants.ENGINE_METHOD_CIPHERS`
|
|
3459
|
+
* * `crypto.constants.ENGINE_METHOD_DIGESTS`
|
|
3460
|
+
* * `crypto.constants.ENGINE_METHOD_PKEY_METHS`
|
|
3461
|
+
* * `crypto.constants.ENGINE_METHOD_PKEY_ASN1_METHS`
|
|
3462
|
+
* * `crypto.constants.ENGINE_METHOD_ALL`
|
|
3463
|
+
* * `crypto.constants.ENGINE_METHOD_NONE`
|
|
3475
3464
|
* @since v0.11.11
|
|
3476
|
-
* @param
|
|
3465
|
+
* @param flags
|
|
3477
3466
|
*/
|
|
3478
3467
|
function setEngine(engine: string, flags?: number): void;
|
|
3479
3468
|
/**
|
|
3480
|
-
* A convenient alias for
|
|
3481
|
-
*
|
|
3482
|
-
*
|
|
3469
|
+
* A convenient alias for {@link webcrypto.getRandomValues}. This
|
|
3470
|
+
* implementation is not compliant with the Web Crypto spec, to write
|
|
3471
|
+
* web-compatible code use {@link webcrypto.getRandomValues} instead.
|
|
3483
3472
|
* @since v17.4.0
|
|
3484
|
-
* @
|
|
3473
|
+
* @return Returns `typedArray`.
|
|
3485
3474
|
*/
|
|
3486
3475
|
function getRandomValues<T extends webcrypto.BufferSource>(typedArray: T): T;
|
|
3487
3476
|
/**
|