@types/node 15.3.1 → 15.9.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/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, 19 May 2021 22:31:29 GMT
11
+ * Last updated: Wed, 02 Jun 2021 22:31:36 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
@@ -1,13 +1,13 @@
1
1
  declare module 'child_process' {
2
2
  import { BaseEncodingOptions } from 'fs';
3
- import * as events from 'events';
3
+ import { EventEmitter, Abortable } from 'events';
4
4
  import * as net from 'net';
5
5
  import { Writable, Readable, Stream, Pipe } from 'stream';
6
6
 
7
7
  type Serializable = string | object | number | boolean;
8
8
  type SendHandle = net.Socket | net.Server;
9
9
 
10
- interface ChildProcess extends events.EventEmitter {
10
+ interface ChildProcess extends EventEmitter {
11
11
  stdin: Writable | null;
12
12
  stdout: Readable | null;
13
13
  stderr: Readable | null;
@@ -129,7 +129,9 @@ declare module 'child_process' {
129
129
  keepOpen?: boolean;
130
130
  }
131
131
 
132
- type StdioOptions = "pipe" | "ignore" | "inherit" | Array<("pipe" | "ipc" | "ignore" | "inherit" | Stream | number | null | undefined)>;
132
+ type IOType = "overlapped" | "pipe" | "ignore" | "inherit";
133
+
134
+ type StdioOptions = IOType | Array<(IOType | "ipc" | Stream | number | null | undefined)>;
133
135
 
134
136
  type SerializationType = 'json' | 'advanced';
135
137
 
@@ -159,7 +161,7 @@ declare module 'child_process' {
159
161
  timeout?: number;
160
162
  }
161
163
 
162
- interface CommonSpawnOptions extends CommonOptions, MessagingOptions {
164
+ interface CommonSpawnOptions extends CommonOptions, MessagingOptions, Abortable {
163
165
  argv0?: string;
164
166
  stdio?: StdioOptions;
165
167
  shell?: boolean | string;
@@ -171,11 +173,12 @@ declare module 'child_process' {
171
173
  }
172
174
 
173
175
  interface SpawnOptionsWithoutStdio extends SpawnOptions {
174
- stdio?: 'pipe' | Array<null | undefined | 'pipe'>;
176
+ stdio?: StdioPipeNamed | StdioPipe[];
175
177
  }
176
178
 
177
179
  type StdioNull = 'inherit' | 'ignore' | Stream;
178
- type StdioPipe = undefined | null | 'pipe';
180
+ type StdioPipeNamed = 'pipe' | 'overlapped';
181
+ type StdioPipe = undefined | null | StdioPipeNamed;
179
182
 
180
183
  interface SpawnOptionsWithStdioTuple<
181
184
  Stdin extends StdioNull | StdioPipe,
@@ -330,11 +333,12 @@ declare module 'child_process' {
330
333
  function __promisify__(command: string, options?: (BaseEncodingOptions & ExecOptions) | null): PromiseWithChild<{ stdout: string | Buffer, stderr: string | Buffer }>;
331
334
  }
332
335
 
333
- interface ExecFileOptions extends CommonOptions {
336
+ interface ExecFileOptions extends CommonOptions, Abortable {
334
337
  maxBuffer?: number;
335
338
  killSignal?: NodeJS.Signals | number;
336
339
  windowsVerbatimArguments?: boolean;
337
340
  shell?: boolean | string;
341
+ signal?: AbortSignal;
338
342
  }
339
343
  interface ExecFileOptionsWithStringEncoding extends ExecFileOptions {
340
344
  encoding: BufferEncoding;
@@ -434,7 +438,7 @@ declare module 'child_process' {
434
438
  ): PromiseWithChild<{ stdout: string | Buffer, stderr: string | Buffer }>;
435
439
  }
436
440
 
437
- interface ForkOptions extends ProcessEnvOptions, MessagingOptions {
441
+ interface ForkOptions extends ProcessEnvOptions, MessagingOptions, Abortable {
438
442
  execPath?: string;
439
443
  execArgv?: string[];
440
444
  silent?: boolean;
node/crypto.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  declare module 'crypto' {
2
2
  import * as stream from 'stream';
3
+ import { PeerCertificate } from 'tls';
3
4
 
4
5
  interface Certificate {
5
6
  /**
@@ -1162,8 +1163,8 @@ declare module 'crypto' {
1162
1163
  * algorithm. If `algorithm` is `null` or `undefined`, then the algorithm is
1163
1164
  * dependent upon the key type (especially Ed25519 and Ed448).
1164
1165
  *
1165
- * If `key` is not a [`KeyObject`][], this function behaves as if `key` had been
1166
- * passed to [`crypto.createPrivateKey()`][].
1166
+ * If `key` is not a `KeyObject`, this function behaves as if `key` had been
1167
+ * passed to `crypto.createPrivateKey().
1167
1168
  */
1168
1169
  function sign(
1169
1170
  algorithm: string | null | undefined,
@@ -1176,8 +1177,8 @@ declare module 'crypto' {
1176
1177
  * algorithm. If `algorithm` is `null` or `undefined`, then the algorithm is
1177
1178
  * dependent upon the key type (especially Ed25519 and Ed448).
1178
1179
  *
1179
- * If `key` is not a [`KeyObject`][], this function behaves as if `key` had been
1180
- * passed to [`crypto.createPublicKey()`][].
1180
+ * If `key` is not a `KeyObject`, this function behaves as if `key` had been
1181
+ * passed to `crypto.createPublicKey()`.
1181
1182
  */
1182
1183
  function verify(
1183
1184
  algorithm: string | null | undefined,
@@ -1253,7 +1254,7 @@ declare module 'crypto' {
1253
1254
  *
1254
1255
  * The supplied `callback` function is called with two arguments: `err` and `derivedKey`.
1255
1256
  * If an errors occurs while deriving the key, `err` will be set; otherwise `err` will be `null`.
1256
- * The successfully generated `derivedKey` will be passed to the callback as an [`ArrayBuffer`][].
1257
+ * The successfully generated `derivedKey` will be passed to the callback as an `ArrayBuffer`.
1257
1258
  * An error will be thrown if any of the input aguments specify invalid values or types.
1258
1259
  */
1259
1260
  function hkdf(digest: string, key: BinaryLike | KeyObject, salt: BinaryLike, info: BinaryLike, keylen: number, callback: (err: Error | null, derivedKey: ArrayBuffer) => any): void;
@@ -1262,9 +1263,257 @@ declare module 'crypto' {
1262
1263
  * Provides a synchronous HKDF key derivation function as defined in RFC 5869.
1263
1264
  * The given `key`, `salt` and `info` are used with the `digest` to derive a key of `keylen` bytes.
1264
1265
  *
1265
- * The successfully generated `derivedKey` will be returned as an [`ArrayBuffer`][].
1266
+ * The successfully generated `derivedKey` will be returned as an `ArrayBuffer`.
1266
1267
  * An error will be thrown if any of the input aguments specify invalid values or types,
1267
1268
  * or if the derived key cannot be generated.
1268
1269
  */
1269
1270
  function hkdfSync(digest: string, key: BinaryLike | KeyObject, salt: BinaryLike, info: BinaryLike, keylen: number): ArrayBuffer;
1271
+
1272
+ interface SecureHeapUsage {
1273
+ /**
1274
+ * The total allocated secure heap size as specified using the `--secure-heap=n` command-line flag.
1275
+ */
1276
+ total: number;
1277
+
1278
+ /**
1279
+ * The minimum allocation from the secure heap as specified using the `--secure-heap-min` command-line flag.
1280
+ */
1281
+ min: number;
1282
+
1283
+ /**
1284
+ * The total number of bytes currently allocated from the secure heap.
1285
+ */
1286
+ used: number;
1287
+
1288
+ /**
1289
+ * The calculated ratio of `used` to `total` allocated bytes.
1290
+ */
1291
+ utilization: number;
1292
+ }
1293
+
1294
+ function secureHeapUsed(): SecureHeapUsage;
1295
+
1296
+ // TODO: X509Certificate
1297
+
1298
+ interface RandomUUIDOptions {
1299
+ /**
1300
+ * By default, to improve performance,
1301
+ * Node.js will pre-emptively generate and persistently cache enough
1302
+ * random data to generate up to 128 random UUIDs. To generate a UUID
1303
+ * without using the cache, set `disableEntropyCache` to `true`.
1304
+ *
1305
+ * @default `false`
1306
+ */
1307
+ disableEntropyCache?: boolean;
1308
+ }
1309
+
1310
+ function randomUUID(options?: RandomUUIDOptions): string;
1311
+
1312
+ interface X509CheckOptions {
1313
+ /**
1314
+ * @default 'always'
1315
+ */
1316
+ subject: 'always' | 'never';
1317
+
1318
+ /**
1319
+ * @default true
1320
+ */
1321
+ wildcards: boolean;
1322
+
1323
+ /**
1324
+ * @default true
1325
+ */
1326
+ partialWildcards: boolean;
1327
+
1328
+ /**
1329
+ * @default false
1330
+ */
1331
+ multiLabelWildcards: boolean;
1332
+
1333
+ /**
1334
+ * @default false
1335
+ */
1336
+ singleLabelSubdomains: boolean;
1337
+ }
1338
+
1339
+ class X509Certificate {
1340
+ /**
1341
+ * Will be `true` if this is a Certificate Authority (ca) certificate.
1342
+ */
1343
+ readonly ca: boolean;
1344
+
1345
+ /**
1346
+ * The SHA-1 fingerprint of this certificate.
1347
+ */
1348
+ readonly fingerprint: string;
1349
+
1350
+ /**
1351
+ * The SHA-256 fingerprint of this certificate.
1352
+ */
1353
+ readonly fingerprint256: string;
1354
+
1355
+ /**
1356
+ * The complete subject of this certificate.
1357
+ */
1358
+ readonly subject: string;
1359
+
1360
+ /**
1361
+ * The subject alternative name specified for this certificate.
1362
+ */
1363
+ readonly subjectAltName: string;
1364
+
1365
+ /**
1366
+ * The information access content of this certificate.
1367
+ */
1368
+ readonly infoAccess: string;
1369
+
1370
+ /**
1371
+ * An array detailing the key usages for this certificate.
1372
+ */
1373
+ readonly keyUsage: string[];
1374
+
1375
+ /**
1376
+ * The issuer identification included in this certificate.
1377
+ */
1378
+ readonly issuer: string;
1379
+
1380
+ /**
1381
+ * The issuer certificate or `undefined` if the issuer certificate is not available.
1382
+ */
1383
+ readonly issuerCertificate?: X509Certificate;
1384
+
1385
+ /**
1386
+ * The public key for this certificate.
1387
+ */
1388
+ readonly publicKey: KeyObject;
1389
+
1390
+ /**
1391
+ * A `Buffer` containing the DER encoding of this certificate.
1392
+ */
1393
+ readonly raw: Buffer;
1394
+
1395
+ /**
1396
+ * The serial number of this certificate.
1397
+ */
1398
+ readonly serialNumber: string;
1399
+
1400
+ /**
1401
+ * Returns the PEM-encoded certificate.
1402
+ */
1403
+ readonly validFrom: string;
1404
+
1405
+ /**
1406
+ * The date/time from which this certificate is considered valid.
1407
+ */
1408
+ readonly validTo: string;
1409
+
1410
+ constructor(buffer: BinaryLike);
1411
+
1412
+ /**
1413
+ * Checks whether the certificate matches the given email address.
1414
+ *
1415
+ * Returns `email` if the certificate matches,`undefined` if it does not.
1416
+ */
1417
+ checkEmail(email: string, options?: X509CheckOptions): string | undefined;
1418
+
1419
+ /**
1420
+ * Checks whether the certificate matches the given host name.
1421
+ *
1422
+ * Returns `name` if the certificate matches, `undefined` if it does not.
1423
+ */
1424
+ checkHost(name: string, options?: X509CheckOptions): string | undefined;
1425
+
1426
+ /**
1427
+ * Checks whether the certificate matches the given IP address (IPv4 or IPv6).
1428
+ *
1429
+ * Returns `ip` if the certificate matches, `undefined` if it does not.
1430
+ */
1431
+ checkIP(ip: string, options?: X509CheckOptions): string | undefined;
1432
+
1433
+ /**
1434
+ * Checks whether this certificate was issued by the given `otherCert`.
1435
+ */
1436
+ checkIssued(otherCert: X509Certificate): boolean;
1437
+
1438
+ /**
1439
+ * Checks whether this certificate was issued by the given `otherCert`.
1440
+ */
1441
+ checkPrivateKey(privateKey: KeyObject): boolean;
1442
+
1443
+ /**
1444
+ * There is no standard JSON encoding for X509 certificates. The
1445
+ * `toJSON()` method returns a string containing the PEM encoded
1446
+ * certificate.
1447
+ */
1448
+ toJSON(): string;
1449
+
1450
+ /**
1451
+ * Returns information about this certificate using the legacy certificate object encoding.
1452
+ */
1453
+ toLegacyObject(): PeerCertificate;
1454
+
1455
+ /**
1456
+ * Returns the PEM-encoded certificate.
1457
+ */
1458
+ toString(): string;
1459
+
1460
+ /**
1461
+ * Verifies that this certificate was signed by the given public key.
1462
+ * Does not perform any other validation checks on the certificate.
1463
+ */
1464
+ verify(publicKey: KeyObject): boolean;
1465
+ }
1466
+
1467
+ type LargeNumberLike = NodeJS.ArrayBufferView | SharedArrayBuffer | ArrayBuffer | bigint;
1468
+
1469
+ interface GeneratePrimeOptions {
1470
+ add?: LargeNumberLike;
1471
+ rem?: LargeNumberLike;
1472
+ /**
1473
+ * @default false
1474
+ */
1475
+ safe?: boolean;
1476
+ bigint?: boolean;
1477
+ }
1478
+
1479
+ interface GeneratePrimeOptionsBigInt extends GeneratePrimeOptions {
1480
+ bigint: true;
1481
+ }
1482
+
1483
+ interface GeneratePrimeOptionsArrayBuffer extends GeneratePrimeOptions {
1484
+ bigint?: false;
1485
+ }
1486
+
1487
+ function generatePrime(size: number, callback: (err: Error | null, prime: ArrayBuffer) => void): void;
1488
+ function generatePrime(size: number, options: GeneratePrimeOptionsBigInt, callback: (err: Error | null, prime: bigint) => void): void;
1489
+ function generatePrime(size: number, options: GeneratePrimeOptionsArrayBuffer, callback: (err: Error | null, prime: ArrayBuffer) => void): void;
1490
+ function generatePrime(size: number, options: GeneratePrimeOptions, callback: (err: Error | null, prime: ArrayBuffer | bigint) => void): void;
1491
+
1492
+ function generatePrimeSync(size: number): ArrayBuffer;
1493
+ function generatePrimeSync(size: number, options: GeneratePrimeOptionsBigInt): bigint;
1494
+ function generatePrimeSync(size: number, options: GeneratePrimeOptionsArrayBuffer): ArrayBuffer;
1495
+ function generatePrimeSync(size: number, options: GeneratePrimeOptions): ArrayBuffer | bigint;
1496
+
1497
+ interface CheckPrimeOptions {
1498
+ /**
1499
+ * The number of Miller-Rabin probabilistic primality iterations to perform.
1500
+ * 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.
1501
+ * Care must be used when selecting a number of checks.
1502
+ * Refer to the OpenSSL documentation for the BN_is_prime_ex function nchecks options for more details.
1503
+ *
1504
+ * @default 0
1505
+ */
1506
+ checks?: number;
1507
+ }
1508
+
1509
+ /**
1510
+ * Checks the primality of the candidate.
1511
+ */
1512
+ function checkPrime(value: LargeNumberLike, callback: (err: Error | null, result: boolean) => void): void;
1513
+ function checkPrime(value: LargeNumberLike, options: CheckPrimeOptions, callback: (err: Error | null, result: boolean) => void): void;
1514
+
1515
+ /**
1516
+ * Checks the primality of the candidate.
1517
+ */
1518
+ function checkPrimeSync(value: LargeNumberLike, options?: CheckPrimeOptions): boolean;
1270
1519
  }
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/events.d.ts CHANGED
@@ -57,6 +57,13 @@ declare module 'events' {
57
57
  namespace EventEmitter {
58
58
  // Should just be `export { EventEmitter }`, but that doesn't work in TypeScript 3.4
59
59
  export { internal as EventEmitter };
60
+
61
+ export interface Abortable {
62
+ /**
63
+ * When provided the corresponding `AbortController` can be used to cancel an asynchronous action.
64
+ */
65
+ signal?: AbortSignal;
66
+ }
60
67
  }
61
68
 
62
69
  global {
node/fs/promises.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  declare module 'fs/promises' {
2
+ import { Abortable } from 'events';
2
3
  import {
3
4
  Stats,
4
5
  BigIntStats,
@@ -16,7 +17,7 @@ declare module 'fs/promises' {
16
17
  BufferEncodingOption,
17
18
  OpenMode,
18
19
  Mode,
19
- Abortable,
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
  }