@types/node 15.6.2 → 15.12.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
node/README.md CHANGED
@@ -8,7 +8,7 @@ This package contains type definitions for Node.js (http://nodejs.org/).
8
8
  Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node.
9
9
 
10
10
  ### Additional Details
11
- * Last updated: Wed, 02 Jun 2021 07:31:33 GMT
11
+ * Last updated: Mon, 07 Jun 2021 23:01:23 GMT
12
12
  * Dependencies: none
13
13
  * Global values: `AbortController`, `AbortSignal`, `Buffer`, `__dirname`, `__filename`, `clearImmediate`, `clearInterval`, `clearTimeout`, `console`, `exports`, `global`, `module`, `process`, `queueMicrotask`, `require`, `setImmediate`, `setInterval`, `setTimeout`
14
14
 
node/buffer.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  declare module 'buffer' {
2
+ import { BinaryLike } from 'crypto';
3
+
2
4
  export const INSPECT_MAX_BYTES: number;
3
5
  export const kMaxLength: number;
4
6
  export const kStringMaxLength: number;
@@ -19,4 +21,64 @@ declare module 'buffer' {
19
21
  };
20
22
 
21
23
  export { BuffType as Buffer };
24
+
25
+ /**
26
+ * @experimental
27
+ */
28
+ export interface BlobOptions {
29
+ /**
30
+ * @default 'utf8'
31
+ */
32
+ encoding?: BufferEncoding;
33
+
34
+ /**
35
+ * The Blob content-type. The intent is for `type` to convey
36
+ * the MIME media type of the data, however no validation of the type format
37
+ * is performed.
38
+ */
39
+ type?: string;
40
+ }
41
+
42
+ /**
43
+ * @experimental
44
+ */
45
+ export class Blob {
46
+ /**
47
+ * Returns a promise that fulfills with an {ArrayBuffer} containing a copy of the `Blob` data.
48
+ */
49
+ readonly size: number;
50
+
51
+ /**
52
+ * The content-type of the `Blob`.
53
+ */
54
+ readonly type: string;
55
+
56
+ /**
57
+ * Creates a new `Blob` object containing a concatenation of the given sources.
58
+ *
59
+ * {ArrayBuffer}, {TypedArray}, {DataView}, and {Buffer} sources are copied into
60
+ * the 'Blob' and can therefore be safely modified after the 'Blob' is created.
61
+ *
62
+ * String sources are also copied into the `Blob`.
63
+ */
64
+ constructor(sources: Array<(BinaryLike | Blob)>, options?: BlobOptions);
65
+
66
+ arrayBuffer(): Promise<ArrayBuffer>;
67
+
68
+ /**
69
+ * @param start The starting index.
70
+ * @param end The ending index.
71
+ * @param type The content-type for the new `Blob`
72
+ */
73
+ slice(start?: number, end?: number, type?: string): Blob;
74
+
75
+ /**
76
+ * Returns a promise that resolves the contents of the `Blob` decoded as a UTF-8 string.
77
+ */
78
+ text(): Promise<string>;
79
+ }
80
+ }
81
+
82
+ declare module 'node:buffer' {
83
+ export * from 'buffer';
22
84
  }
node/child_process.d.ts CHANGED
@@ -4,7 +4,7 @@ declare module 'child_process' {
4
4
  import * as net from 'net';
5
5
  import { Writable, Readable, Stream, Pipe } from 'stream';
6
6
 
7
- type Serializable = string | object | number | boolean;
7
+ type Serializable = string | object | number | boolean | bigint;
8
8
  type SendHandle = net.Socket | net.Server;
9
9
 
10
10
  interface ChildProcess extends EventEmitter {
@@ -20,7 +20,7 @@ declare module 'child_process' {
20
20
  Readable | Writable | null | undefined // extra
21
21
  ];
22
22
  readonly killed: boolean;
23
- readonly pid: number;
23
+ readonly pid?: number;
24
24
  readonly connected: boolean;
25
25
  readonly exitCode: number | null;
26
26
  readonly signalCode: NodeJS.Signals | null;
@@ -135,12 +135,18 @@ declare module 'child_process' {
135
135
 
136
136
  type SerializationType = 'json' | 'advanced';
137
137
 
138
- interface MessagingOptions {
138
+ interface MessagingOptions extends Abortable {
139
139
  /**
140
140
  * Specify the kind of serialization used for sending messages between processes.
141
141
  * @default 'json'
142
142
  */
143
143
  serialization?: SerializationType;
144
+
145
+ /**
146
+ * The signal value to be used when the spawned process will be killed by the abort signal.
147
+ * @default 'SIGTERM'
148
+ */
149
+ killSignal?: NodeJS.Signals | number;
144
150
  }
145
151
 
146
152
  interface ProcessEnvOptions {
@@ -451,7 +457,6 @@ declare module 'child_process' {
451
457
 
452
458
  interface SpawnSyncOptions extends CommonSpawnOptions {
453
459
  input?: string | NodeJS.ArrayBufferView;
454
- killSignal?: NodeJS.Signals | number;
455
460
  maxBuffer?: number;
456
461
  encoding?: BufferEncoding | 'buffer' | null;
457
462
  }
node/console.d.ts CHANGED
@@ -25,16 +25,16 @@ declare module 'console' {
25
25
  */
26
26
  countReset(label?: string): void;
27
27
  /**
28
- * The `console.debug()` function is an alias for {@link console.log()}.
28
+ * The `console.debug()` function is an alias for {@link console.log}.
29
29
  */
30
30
  debug(message?: any, ...optionalParams: any[]): void;
31
31
  /**
32
- * Uses {@link util.inspect()} on `obj` and prints the resulting string to `stdout`.
32
+ * Uses {@link util.inspect} on `obj` and prints the resulting string to `stdout`.
33
33
  * This function bypasses any custom `inspect()` function defined on `obj`.
34
34
  */
35
35
  dir(obj: any, options?: InspectOptions): void;
36
36
  /**
37
- * This method calls {@link console.log()} passing it the arguments received. Please note that this method does not produce any XML formatting
37
+ * This method calls {@link console.log} passing it the arguments received. Please note that this method does not produce any XML formatting
38
38
  */
39
39
  dirxml(...data: any[]): void;
40
40
  /**
@@ -47,7 +47,7 @@ declare module 'console' {
47
47
  */
48
48
  group(...label: any[]): void;
49
49
  /**
50
- * The `console.groupCollapsed()` function is an alias for {@link console.group()}.
50
+ * The `console.groupCollapsed()` function is an alias for {@link console.group}.
51
51
  */
52
52
  groupCollapsed(...label: any[]): void;
53
53
  /**
@@ -55,7 +55,7 @@ declare module 'console' {
55
55
  */
56
56
  groupEnd(): void;
57
57
  /**
58
- * The {@link console.info()} function is an alias for {@link console.log()}.
58
+ * The {@link console.info} function is an alias for {@link console.log}.
59
59
  */
60
60
  info(message?: any, ...optionalParams: any[]): void;
61
61
  /**
@@ -72,19 +72,19 @@ declare module 'console' {
72
72
  */
73
73
  time(label?: string): void;
74
74
  /**
75
- * Stops a timer that was previously started by calling {@link console.time()} and prints the result to `stdout`.
75
+ * Stops a timer that was previously started by calling {@link console.time} and prints the result to `stdout`.
76
76
  */
77
77
  timeEnd(label?: string): void;
78
78
  /**
79
- * For a timer that was previously started by calling {@link console.time()}, prints the elapsed time and other `data` arguments to `stdout`.
79
+ * For a timer that was previously started by calling {@link console.time}, prints the elapsed time and other `data` arguments to `stdout`.
80
80
  */
81
81
  timeLog(label?: string, ...data: any[]): void;
82
82
  /**
83
- * Prints to `stderr` the string 'Trace :', followed by the {@link util.format()} formatted message and stack trace to the current position in the code.
83
+ * Prints to `stderr` the string 'Trace :', followed by the {@link util.format} formatted message and stack trace to the current position in the code.
84
84
  */
85
85
  trace(message?: any, ...optionalParams: any[]): void;
86
86
  /**
87
- * The {@link console.warn()} function is an alias for {@link console.error()}.
87
+ * The {@link console.warn} function is an alias for {@link console.error}.
88
88
  */
89
89
  warn(message?: any, ...optionalParams: any[]): void;
90
90
 
node/crypto.d.ts CHANGED
@@ -197,6 +197,45 @@ declare module 'crypto' {
197
197
  passphrase?: string | Buffer;
198
198
  }
199
199
 
200
+ interface JwkKeyExportOptions {
201
+ format: 'jwk';
202
+ }
203
+
204
+ interface JsonWebKey {
205
+ crv?: string;
206
+ d?: string;
207
+ dp?: string;
208
+ dq?: string;
209
+ e?: string;
210
+ k?: string;
211
+ kty?: string;
212
+ n?: string;
213
+ p?: string;
214
+ q?: string;
215
+ qi?: string;
216
+ x?: string;
217
+ y?: string;
218
+ }
219
+
220
+ interface AsymmetricKeyDetails {
221
+ /**
222
+ * Key size in bits (RSA, DSA).
223
+ */
224
+ modulusLength?: number;
225
+ /**
226
+ * Public exponent (RSA).
227
+ */
228
+ publicExponent?: bigint;
229
+ /**
230
+ * Size of q in bits (DSA).
231
+ */
232
+ divisorLength?: number;
233
+ /**
234
+ * Name of the curve (EC).
235
+ */
236
+ namedCurve?: string;
237
+ }
238
+
200
239
  class KeyObject {
201
240
  private constructor();
202
241
  asymmetricKeyType?: KeyType;
@@ -205,6 +244,13 @@ declare module 'crypto' {
205
244
  * bytes. This property is `undefined` for symmetric keys.
206
245
  */
207
246
  asymmetricKeySize?: number;
247
+ /**
248
+ * This property exists only on asymmetric keys. Depending on the type of the key,
249
+ * this object contains information about the key. None of the information obtained
250
+ * through this property can be used to uniquely identify a key or to compromise the
251
+ * security of the key.
252
+ */
253
+ asymmetricKeyDetails?: AsymmetricKeyDetails;
208
254
  export(options: KeyExportOptions<'pem'>): string | Buffer;
209
255
  export(options?: KeyExportOptions<'der'>): Buffer;
210
256
  symmetricKeySize?: number;
@@ -1163,22 +1209,28 @@ declare module 'crypto' {
1163
1209
  * algorithm. If `algorithm` is `null` or `undefined`, then the algorithm is
1164
1210
  * dependent upon the key type (especially Ed25519 and Ed448).
1165
1211
  *
1166
- * If `key` is not a [`KeyObject`][], this function behaves as if `key` had been
1167
- * passed to [`crypto.createPrivateKey()`][].
1212
+ * If `key` is not a `KeyObject`, this function behaves as if `key` had been
1213
+ * passed to `crypto.createPrivateKey().
1168
1214
  */
1169
1215
  function sign(
1170
1216
  algorithm: string | null | undefined,
1171
1217
  data: NodeJS.ArrayBufferView,
1172
1218
  key: KeyLike | SignKeyObjectInput | SignPrivateKeyInput,
1173
1219
  ): Buffer;
1220
+ function sign(
1221
+ algorithm: string | null | undefined,
1222
+ data: NodeJS.ArrayBufferView,
1223
+ key: KeyLike | SignKeyObjectInput | SignPrivateKeyInput,
1224
+ callback: (error: Error | null, data: Buffer) => void
1225
+ ): void;
1174
1226
 
1175
1227
  /**
1176
1228
  * Calculates and returns the signature for `data` using the given private key and
1177
1229
  * algorithm. If `algorithm` is `null` or `undefined`, then the algorithm is
1178
1230
  * dependent upon the key type (especially Ed25519 and Ed448).
1179
1231
  *
1180
- * If `key` is not a [`KeyObject`][], this function behaves as if `key` had been
1181
- * passed to [`crypto.createPublicKey()`][].
1232
+ * If `key` is not a `KeyObject`, this function behaves as if `key` had been
1233
+ * passed to `crypto.createPublicKey()`.
1182
1234
  */
1183
1235
  function verify(
1184
1236
  algorithm: string | null | undefined,
@@ -1186,6 +1238,13 @@ declare module 'crypto' {
1186
1238
  key: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput,
1187
1239
  signature: NodeJS.ArrayBufferView,
1188
1240
  ): boolean;
1241
+ function verify(
1242
+ algorithm: string | null | undefined,
1243
+ data: NodeJS.ArrayBufferView,
1244
+ key: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput,
1245
+ signature: NodeJS.ArrayBufferView,
1246
+ callback: (error: Error | null, result: boolean) => void
1247
+ ): void;
1189
1248
 
1190
1249
  /**
1191
1250
  * Computes the Diffie-Hellman secret based on a privateKey and a publicKey.
@@ -1254,7 +1313,7 @@ declare module 'crypto' {
1254
1313
  *
1255
1314
  * The supplied `callback` function is called with two arguments: `err` and `derivedKey`.
1256
1315
  * If an errors occurs while deriving the key, `err` will be set; otherwise `err` will be `null`.
1257
- * The successfully generated `derivedKey` will be passed to the callback as an [`ArrayBuffer`][].
1316
+ * The successfully generated `derivedKey` will be passed to the callback as an `ArrayBuffer`.
1258
1317
  * An error will be thrown if any of the input aguments specify invalid values or types.
1259
1318
  */
1260
1319
  function hkdf(digest: string, key: BinaryLike | KeyObject, salt: BinaryLike, info: BinaryLike, keylen: number, callback: (err: Error | null, derivedKey: ArrayBuffer) => any): void;
@@ -1263,7 +1322,7 @@ declare module 'crypto' {
1263
1322
  * Provides a synchronous HKDF key derivation function as defined in RFC 5869.
1264
1323
  * The given `key`, `salt` and `info` are used with the `digest` to derive a key of `keylen` bytes.
1265
1324
  *
1266
- * The successfully generated `derivedKey` will be returned as an [`ArrayBuffer`][].
1325
+ * The successfully generated `derivedKey` will be returned as an `ArrayBuffer`.
1267
1326
  * An error will be thrown if any of the input aguments specify invalid values or types,
1268
1327
  * or if the derived key cannot be generated.
1269
1328
  */
@@ -1372,6 +1431,16 @@ declare module 'crypto' {
1372
1431
  */
1373
1432
  readonly keyUsage: string[];
1374
1433
 
1434
+ /**
1435
+ * The issuer identification included in this certificate.
1436
+ */
1437
+ readonly issuer: string;
1438
+
1439
+ /**
1440
+ * The issuer certificate or `undefined` if the issuer certificate is not available.
1441
+ */
1442
+ readonly issuerCertificate?: X509Certificate;
1443
+
1375
1444
  /**
1376
1445
  * The public key for this certificate.
1377
1446
  */
@@ -1438,7 +1507,7 @@ declare module 'crypto' {
1438
1507
  toJSON(): string;
1439
1508
 
1440
1509
  /**
1441
- * Returns information about this certificate using the legacy [certificate object][] encoding.
1510
+ * Returns information about this certificate using the legacy certificate object encoding.
1442
1511
  */
1443
1512
  toLegacyObject(): PeerCertificate;
1444
1513
 
@@ -1453,4 +1522,57 @@ declare module 'crypto' {
1453
1522
  */
1454
1523
  verify(publicKey: KeyObject): boolean;
1455
1524
  }
1525
+
1526
+ type LargeNumberLike = NodeJS.ArrayBufferView | SharedArrayBuffer | ArrayBuffer | bigint;
1527
+
1528
+ interface GeneratePrimeOptions {
1529
+ add?: LargeNumberLike;
1530
+ rem?: LargeNumberLike;
1531
+ /**
1532
+ * @default false
1533
+ */
1534
+ safe?: boolean;
1535
+ bigint?: boolean;
1536
+ }
1537
+
1538
+ interface GeneratePrimeOptionsBigInt extends GeneratePrimeOptions {
1539
+ bigint: true;
1540
+ }
1541
+
1542
+ interface GeneratePrimeOptionsArrayBuffer extends GeneratePrimeOptions {
1543
+ bigint?: false;
1544
+ }
1545
+
1546
+ function generatePrime(size: number, callback: (err: Error | null, prime: ArrayBuffer) => void): void;
1547
+ function generatePrime(size: number, options: GeneratePrimeOptionsBigInt, callback: (err: Error | null, prime: bigint) => void): void;
1548
+ function generatePrime(size: number, options: GeneratePrimeOptionsArrayBuffer, callback: (err: Error | null, prime: ArrayBuffer) => void): void;
1549
+ function generatePrime(size: number, options: GeneratePrimeOptions, callback: (err: Error | null, prime: ArrayBuffer | bigint) => void): void;
1550
+
1551
+ function generatePrimeSync(size: number): ArrayBuffer;
1552
+ function generatePrimeSync(size: number, options: GeneratePrimeOptionsBigInt): bigint;
1553
+ function generatePrimeSync(size: number, options: GeneratePrimeOptionsArrayBuffer): ArrayBuffer;
1554
+ function generatePrimeSync(size: number, options: GeneratePrimeOptions): ArrayBuffer | bigint;
1555
+
1556
+ interface CheckPrimeOptions {
1557
+ /**
1558
+ * The number of Miller-Rabin probabilistic primality iterations to perform.
1559
+ * 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.
1560
+ * Care must be used when selecting a number of checks.
1561
+ * Refer to the OpenSSL documentation for the BN_is_prime_ex function nchecks options for more details.
1562
+ *
1563
+ * @default 0
1564
+ */
1565
+ checks?: number;
1566
+ }
1567
+
1568
+ /**
1569
+ * Checks the primality of the candidate.
1570
+ */
1571
+ function checkPrime(value: LargeNumberLike, callback: (err: Error | null, result: boolean) => void): void;
1572
+ function checkPrime(value: LargeNumberLike, options: CheckPrimeOptions, callback: (err: Error | null, result: boolean) => void): void;
1573
+
1574
+ /**
1575
+ * Checks the primality of the candidate.
1576
+ */
1577
+ function checkPrimeSync(value: LargeNumberLike, options?: CheckPrimeOptions): boolean;
1456
1578
  }
node/dgram.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  declare module 'dgram' {
2
2
  import { AddressInfo } from 'net';
3
3
  import * as dns from 'dns';
4
- import EventEmitter = require('events');
4
+ import { EventEmitter, Abortable } from 'events';
5
5
 
6
6
  interface RemoteInfo {
7
7
  address: string;
@@ -19,7 +19,7 @@ declare module 'dgram' {
19
19
 
20
20
  type SocketType = "udp4" | "udp6";
21
21
 
22
- interface SocketOptions {
22
+ interface SocketOptions extends Abortable {
23
23
  type: SocketType;
24
24
  reuseAddr?: boolean;
25
25
  /**
node/fs/promises.d.ts CHANGED
@@ -17,6 +17,7 @@ declare module 'fs/promises' {
17
17
  BufferEncodingOption,
18
18
  OpenMode,
19
19
  Mode,
20
+ WatchOptions,
20
21
  } from 'fs';
21
22
 
22
23
  interface FileHandle {
@@ -555,4 +556,37 @@ declare module 'fs/promises' {
555
556
  function readFile(path: PathLike | FileHandle, options?: BaseEncodingOptions & Abortable & { flag?: OpenMode } | BufferEncoding | null): Promise<string | Buffer>;
556
557
 
557
558
  function opendir(path: string, options?: OpenDirOptions): Promise<Dir>;
559
+
560
+ /**
561
+ * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
562
+ * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
563
+ * @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options.
564
+ * If `encoding` is not supplied, the default of `'utf8'` is used.
565
+ * If `persistent` is not supplied, the default of `true` is used.
566
+ * If `recursive` is not supplied, the default of `false` is used.
567
+ */
568
+ function watch(filename: PathLike, options: WatchOptions & { encoding: "buffer" } | "buffer"): AsyncIterable<Buffer>;
569
+
570
+ /**
571
+ * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
572
+ * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
573
+ * @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options.
574
+ * If `encoding` is not supplied, the default of `'utf8'` is used.
575
+ * If `persistent` is not supplied, the default of `true` is used.
576
+ * If `recursive` is not supplied, the default of `false` is used.
577
+ */
578
+ function watch(
579
+ filename: PathLike,
580
+ options?: WatchOptions | BufferEncoding
581
+ ): AsyncIterable<string>;
582
+
583
+ /**
584
+ * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
585
+ * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
586
+ * @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options.
587
+ * If `encoding` is not supplied, the default of `'utf8'` is used.
588
+ * If `persistent` is not supplied, the default of `true` is used.
589
+ * If `recursive` is not supplied, the default of `false` is used.
590
+ */
591
+ function watch(filename: PathLike, options: WatchOptions | string): AsyncIterable<string> | AsyncIterable<Buffer>;
558
592
  }