@types/node 16.18.88 → 16.18.90

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 v16.18/README.md CHANGED
@@ -8,7 +8,7 @@ This package contains type definitions for node (https://nodejs.org/).
8
8
  Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node/v16.
9
9
 
10
10
  ### Additional Details
11
- * Last updated: Mon, 11 Mar 2024 22:06:43 GMT
11
+ * Last updated: Mon, 18 Mar 2024 19:35:28 GMT
12
12
  * Dependencies: none
13
13
 
14
14
  # Credits
node v16.18/crypto.d.ts CHANGED
@@ -76,7 +76,7 @@ declare module "crypto" {
76
76
  const SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION: number;
77
77
  /** Attempts to use the server's preferences instead of the client's when selecting a cipher. See https://www.openssl.org/docs/man1.0.2/ssl/SSL_CTX_set_options.html. */
78
78
  const SSL_OP_CIPHER_SERVER_PREFERENCE: number;
79
- /** Instructs OpenSSL to use Cisco's "speshul" version of DTLS_BAD_VER. */
79
+ /** Instructs OpenSSL to use Cisco's version identifier of DTLS_BAD_VER. */
80
80
  const SSL_OP_CISCO_ANYCONNECT: number;
81
81
  /** Instructs OpenSSL to turn on cookie exchange. */
82
82
  const SSL_OP_COOKIE_EXCHANGE: number;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * The `dns.promises` API provides an alternative set of asynchronous DNS methods
3
3
  * that return `Promise` objects rather than using callbacks. The API is accessible
4
- * via `require('dns').promises` or `require('dns/promises')`.
4
+ * via `require('node:dns').promises` or `require('node:dns/promises')`.
5
5
  * @since v10.6.0
6
6
  */
7
7
  declare module "dns/promises" {
@@ -43,24 +43,24 @@ declare module "dns/promises" {
43
43
  * integer, then it must be `4` or `6` – if `options` is not provided, then IPv4
44
44
  * and IPv6 addresses are both returned if found.
45
45
  *
46
- * With the `all` option set to `true`, the `Promise` is resolved with `addresses`being an array of objects with the properties `address` and `family`.
46
+ * With the `all` option set to `true`, the `Promise` is resolved with `addresses` being an array of objects with the properties `address` and `family`.
47
47
  *
48
- * On error, the `Promise` is rejected with an `Error` object, where `err.code`is the error code.
48
+ * On error, the `Promise` is rejected with an [`Error`](https://nodejs.org/docs/latest-v16.x/api/errors.html#class-error) object, where `err.code` is the error code.
49
49
  * Keep in mind that `err.code` will be set to `'ENOTFOUND'` not only when
50
50
  * the host name does not exist but also when the lookup fails in other ways
51
51
  * such as no available file descriptors.
52
52
  *
53
- * `dnsPromises.lookup()` does not necessarily have anything to do with the DNS
53
+ * [`dnsPromises.lookup()`](https://nodejs.org/docs/latest-v16.x/api/dns.html#dnspromiseslookuphostname-options) does not necessarily have anything to do with the DNS
54
54
  * protocol. The implementation uses an operating system facility that can
55
- * associate names with addresses, and vice versa. This implementation can have
55
+ * associate names with addresses and vice versa. This implementation can have
56
56
  * subtle but important consequences on the behavior of any Node.js program. Please
57
- * take some time to consult the `Implementation considerations section` before
57
+ * take some time to consult the [Implementation considerations section](https://nodejs.org/docs/latest-v16.x/api/dns.html#implementation-considerations) before
58
58
  * using `dnsPromises.lookup()`.
59
59
  *
60
60
  * Example usage:
61
61
  *
62
62
  * ```js
63
- * const dns = require('dns');
63
+ * const dns = require('node:dns');
64
64
  * const dnsPromises = dns.promises;
65
65
  * const options = {
66
66
  * family: 6,
@@ -91,12 +91,12 @@ declare module "dns/promises" {
91
91
  * the operating system's underlying `getnameinfo` implementation.
92
92
  *
93
93
  * If `address` is not a valid IP address, a `TypeError` will be thrown.
94
- * The `port` will be coerced to a number. If it is not a legal port, a `TypeError`will be thrown.
94
+ * The `port` will be coerced to a number. If it is not a legal port, a `TypeError` will be thrown.
95
95
  *
96
- * On error, the `Promise` is rejected with an `Error` object, where `err.code`is the error code.
96
+ * On error, the `Promise` is rejected with an [`Error`](https://nodejs.org/docs/latest-v16.x/api/errors.html#class-error) object, where `err.code` is the error code.
97
97
  *
98
98
  * ```js
99
- * const dnsPromises = require('dns').promises;
99
+ * const dnsPromises = require('node:dns').promises;
100
100
  * dnsPromises.lookupService('127.0.0.1', 22).then((result) => {
101
101
  * console.log(result.hostname, result.service);
102
102
  * // Prints: localhost ssh
@@ -119,7 +119,8 @@ declare module "dns/promises" {
119
119
  *
120
120
  * <omitted>
121
121
  *
122
- * On error, the `Promise` is rejected with an `Error` object, where `err.code`is one of the `DNS error codes`.
122
+ * On error, the `Promise` is rejected with an [`Error`](https://nodejs.org/docs/latest-v16.x/api/errors.html#class-error) object, where `err.code`
123
+ * is one of the [DNS error codes](https://nodejs.org/docs/latest-v16.x/api/dns.html#error-codes).
123
124
  * @since v10.6.0
124
125
  * @param hostname Host name to resolve.
125
126
  * @param [rrtype='A'] Resource record type.
@@ -142,7 +143,7 @@ declare module "dns/promises" {
142
143
  rrtype: string,
143
144
  ): Promise<string[] | MxRecord[] | NaptrRecord[] | SoaRecord | SrvRecord[] | string[][] | AnyRecord[]>;
144
145
  /**
145
- * Uses the DNS protocol to resolve IPv4 addresses (`A` records) for the`hostname`. On success, the `Promise` is resolved with an array of IPv4
146
+ * Uses the DNS protocol to resolve IPv4 addresses (`A` records) for the `hostname`. On success, the `Promise` is resolved with an array of IPv4
146
147
  * addresses (e.g. `['74.125.79.104', '74.125.79.105', '74.125.79.106']`).
147
148
  * @since v10.6.0
148
149
  * @param hostname Host name to resolve.
@@ -151,7 +152,7 @@ declare module "dns/promises" {
151
152
  function resolve4(hostname: string, options: ResolveWithTtlOptions): Promise<RecordWithTtl[]>;
152
153
  function resolve4(hostname: string, options: ResolveOptions): Promise<string[] | RecordWithTtl[]>;
153
154
  /**
154
- * Uses the DNS protocol to resolve IPv6 addresses (`AAAA` records) for the`hostname`. On success, the `Promise` is resolved with an array of IPv6
155
+ * Uses the DNS protocol to resolve IPv6 addresses (`AAAA` records) for the `hostname`. On success, the `Promise` is resolved with an array of IPv6
155
156
  * addresses.
156
157
  * @since v10.6.0
157
158
  * @param hostname Host name to resolve.
@@ -191,7 +192,7 @@ declare module "dns/promises" {
191
192
  /**
192
193
  * Uses the DNS protocol to resolve `CAA` records for the `hostname`. On success,
193
194
  * the `Promise` is resolved with an array of objects containing available
194
- * certification authority authorization records available for the `hostname`(e.g. `[{critical: 0, iodef: 'mailto:pki@example.com'},{critical: 128, issue: 'pki.example.com'}]`).
195
+ * certification authority authorization records available for the `hostname` (e.g. `[{critical: 0, iodef: 'mailto:pki@example.com'},{critical: 128, issue: 'pki.example.com'}]`).
195
196
  * @since v15.0.0
196
197
  */
197
198
  function resolveCaa(hostname: string): Promise<CaaRecord[]>;
@@ -203,13 +204,13 @@ declare module "dns/promises" {
203
204
  */
204
205
  function resolveCname(hostname: string): Promise<string[]>;
205
206
  /**
206
- * Uses the DNS protocol to resolve mail exchange records (`MX` records) for the`hostname`. On success, the `Promise` is resolved with an array of objects
207
+ * Uses the DNS protocol to resolve mail exchange records (`MX` records) for the `hostname`. On success, the `Promise` is resolved with an array of objects
207
208
  * containing both a `priority` and `exchange` property (e.g.`[{priority: 10, exchange: 'mx.example.com'}, ...]`).
208
209
  * @since v10.6.0
209
210
  */
210
211
  function resolveMx(hostname: string): Promise<MxRecord[]>;
211
212
  /**
212
- * Uses the DNS protocol to resolve regular expression based records (`NAPTR`records) for the `hostname`. On success, the `Promise` is resolved with an array
213
+ * Uses the DNS protocol to resolve regular expression-based records (`NAPTR` records) for the `hostname`. On success, the `Promise` is resolved with an array
213
214
  * of objects with the following properties:
214
215
  *
215
216
  * * `flags`
@@ -233,13 +234,13 @@ declare module "dns/promises" {
233
234
  */
234
235
  function resolveNaptr(hostname: string): Promise<NaptrRecord[]>;
235
236
  /**
236
- * Uses the DNS protocol to resolve name server records (`NS` records) for the`hostname`. On success, the `Promise` is resolved with an array of name server
237
+ * Uses the DNS protocol to resolve name server records (`NS` records) for the `hostname`. On success, the `Promise` is resolved with an array of name server
237
238
  * records available for `hostname` (e.g.`['ns1.example.com', 'ns2.example.com']`).
238
239
  * @since v10.6.0
239
240
  */
240
241
  function resolveNs(hostname: string): Promise<string[]>;
241
242
  /**
242
- * Uses the DNS protocol to resolve pointer records (`PTR` records) for the`hostname`. On success, the `Promise` is resolved with an array of strings
243
+ * Uses the DNS protocol to resolve pointer records (`PTR` records) for the `hostname`. On success, the `Promise` is resolved with an array of strings
243
244
  * containing the reply records.
244
245
  * @since v10.6.0
245
246
  */
@@ -272,7 +273,7 @@ declare module "dns/promises" {
272
273
  */
273
274
  function resolveSoa(hostname: string): Promise<SoaRecord>;
274
275
  /**
275
- * Uses the DNS protocol to resolve service records (`SRV` records) for the`hostname`. On success, the `Promise` is resolved with an array of objects with
276
+ * Uses the DNS protocol to resolve service records (`SRV` records) for the `hostname`. On success, the `Promise` is resolved with an array of objects with
276
277
  * the following properties:
277
278
  *
278
279
  * * `priority`
@@ -292,7 +293,7 @@ declare module "dns/promises" {
292
293
  */
293
294
  function resolveSrv(hostname: string): Promise<SrvRecord[]>;
294
295
  /**
295
- * Uses the DNS protocol to resolve text queries (`TXT` records) for the`hostname`. On success, the `Promise` is resolved with a two-dimensional array
296
+ * Uses the DNS protocol to resolve text queries (`TXT` records) for the `hostname`. On success, the `Promise` is resolved with a two-dimensional array
296
297
  * of the text records available for `hostname` (e.g.`[ ['v=spf1 ip4:0.0.0.0 ', '~all' ] ]`). Each sub-array contains TXT chunks of
297
298
  * one record. Depending on the use case, these could be either joined together or
298
299
  * treated separately.
@@ -303,7 +304,8 @@ declare module "dns/promises" {
303
304
  * Performs a reverse DNS query that resolves an IPv4 or IPv6 address to an
304
305
  * array of host names.
305
306
  *
306
- * On error, the `Promise` is rejected with an `Error` object, where `err.code`is one of the `DNS error codes`.
307
+ * On error, the `Promise` is rejected with an [`Error`](https://nodejs.org/docs/latest-v16.x/api/errors.html#class-error) object, where `err.code`
308
+ * is one of the [DNS error codes](https://nodejs.org/docs/latest-v16.x/api/dns.html#error-codes).
307
309
  * @since v10.6.0
308
310
  */
309
311
  function reverse(ip: string): Promise<string[]>;
@@ -335,18 +337,93 @@ declare module "dns/promises" {
335
337
  */
336
338
  function setServers(servers: readonly string[]): void;
337
339
  /**
338
- * Set the default value of `verbatim` in {@link lookup}. The value could be:
339
- * - `ipv4first`: sets default `verbatim` `false`.
340
- * - `verbatim`: sets default `verbatim` `true`.
341
- *
342
- * The default is `ipv4first` and {@link setDefaultResultOrder} have higher priority than `--dns-result-order`.
343
- * When using worker threads, {@link setDefaultResultOrder} from the main thread won't affect the default dns orders in workers.
344
- * @since v14.18.0
345
- * @param order must be 'ipv4first' or 'verbatim'.
340
+ * Set the default value of `verbatim` in `dns.lookup()` and `dnsPromises.lookup()`. The value could be:
341
+ *
342
+ * * `ipv4first`: sets default `verbatim` `false`.
343
+ * * `verbatim`: sets default `verbatim` `true`.
344
+ *
345
+ * The default is `verbatim` and [dnsPromises.setDefaultResultOrder()](https://nodejs.org/docs/latest-v16.x/api/dns.html#dnspromisessetdefaultresultorderorder)
346
+ * have higher priority than [`--dns-result-order`](https://nodejs.org/docs/latest-v16.x/api/cli.html#--dns-result-orderorder).
347
+ * When using [worker threads](https://nodejs.org/docs/latest-v16.x/api/worker_threads.html), [`dnsPromises.setDefaultResultOrder()`](https://nodejs.org/docs/latest-v16.x/api/dns.html#dnspromisessetdefaultresultorderorder)
348
+ * from the main thread won't affect the default dns orders in workers.
349
+ * @since v16.4.0, v14.18.0
350
+ * @param order must be `'ipv4first'` or `'verbatim'`.
346
351
  */
347
352
  function setDefaultResultOrder(order: "ipv4first" | "verbatim"): void;
353
+ const NODATA: "NODATA";
354
+ const FORMERR: "FORMERR";
355
+ const SERVFAIL: "SERVFAIL";
356
+ const NOTFOUND: "NOTFOUND";
357
+ const NOTIMP: "NOTIMP";
358
+ const REFUSED: "REFUSED";
359
+ const BADQUERY: "BADQUERY";
360
+ const BADNAME: "BADNAME";
361
+ const BADFAMILY: "BADFAMILY";
362
+ const BADRESP: "BADRESP";
363
+ const CONNREFUSED: "TIMEOUT";
364
+ const TIMEOUT: "TIMEOUT";
365
+ const EOF: "EOF";
366
+ const FILE: "FILE";
367
+ const NOMEM: "NOMEM";
368
+ const DESTRUCTION: "DESTRUCTION";
369
+ const BADSTR: "BADSTR";
370
+ const BADFLAGS: "BADFLAGS";
371
+ const NONAME: "NONAME";
372
+ const BADHINTS: "BADHINTS";
373
+ const NOTINITIALIZED: "NOTINITIALIZED";
374
+ const LOADIPHLPAPI: "LOADIPHLPAPI";
375
+ const ADDRGETNETWORKPARAMS: "ADDRGETNETWORKPARAMS";
376
+ const CANCELLED: "CANCELLED";
377
+ /**
378
+ * An independent resolver for DNS requests.
379
+ *
380
+ * Creating a new resolver uses the default server settings. Setting
381
+ * the servers used for a resolver using [`resolver.setServers()`](https://nodejs.org/docs/latest-v16.x/api/dns.html#dnspromisessetserversservers) does not affect
382
+ * other resolvers:
383
+ *
384
+ * ```js
385
+ * const { Resolver } = require('node:dns').promises;
386
+ * const resolver = new Resolver();
387
+ * resolver.setServers(['4.4.4.4']);
388
+ *
389
+ * // This request will use the server at 4.4.4.4, independent of global settings.
390
+ * resolver.resolve4('example.org').then((addresses) => {
391
+ * // ...
392
+ * });
393
+ *
394
+ * // Alternatively, the same code can be written using async-await style.
395
+ * (async function() {
396
+ * const addresses = await resolver.resolve4('example.org');
397
+ * })();
398
+ * ```
399
+ *
400
+ * The following methods from the `dnsPromises` API are available:
401
+ *
402
+ * * `resolver.getServers()`
403
+ * * `resolver.resolve()`
404
+ * * `resolver.resolve4()`
405
+ * * `resolver.resolve6()`
406
+ * * `resolver.resolveAny()`
407
+ * * `resolver.resolveCaa()`
408
+ * * `resolver.resolveCname()`
409
+ * * `resolver.resolveMx()`
410
+ * * `resolver.resolveNaptr()`
411
+ * * `resolver.resolveNs()`
412
+ * * `resolver.resolvePtr()`
413
+ * * `resolver.resolveSoa()`
414
+ * * `resolver.resolveSrv()`
415
+ * * `resolver.resolveTxt()`
416
+ * * `resolver.reverse()`
417
+ * * `resolver.setServers()`
418
+ * @since v10.6.0
419
+ */
348
420
  class Resolver {
349
421
  constructor(options?: ResolverOptions);
422
+ /**
423
+ * Cancel all outstanding DNS queries made by this resolver. The corresponding
424
+ * callbacks will be called with an error with code `ECANCELLED`.
425
+ * @since v8.3.0
426
+ */
350
427
  cancel(): void;
351
428
  getServers: typeof getServers;
352
429
  resolve: typeof resolve;
@@ -363,6 +440,21 @@ declare module "dns/promises" {
363
440
  resolveSrv: typeof resolveSrv;
364
441
  resolveTxt: typeof resolveTxt;
365
442
  reverse: typeof reverse;
443
+ /**
444
+ * The resolver instance will send its requests from the specified IP address.
445
+ * This allows programs to specify outbound interfaces when used on multi-homed
446
+ * systems.
447
+ *
448
+ * If a v4 or v6 address is not specified, it is set to the default and the
449
+ * operating system will choose a local address automatically.
450
+ *
451
+ * The resolver will use the v4 local address when making requests to IPv4 DNS
452
+ * servers, and the v6 local address when making requests to IPv6 DNS servers.
453
+ * The `rrtype` of resolution requests has no impact on the local address used.
454
+ * @since v15.1.0
455
+ * @param [ipv4='0.0.0.0'] A string representation of an IPv4 address.
456
+ * @param [ipv6='::0'] A string representation of an IPv6 address.
457
+ */
366
458
  setLocalAddress(ipv4?: string, ipv6?: string): void;
367
459
  setServers: typeof setServers;
368
460
  }
node v16.18/dns.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * The `dns` module enables name resolution. For example, use it to look up IP
2
+ * The `node:dns` module enables name resolution. For example, use it to look up IP
3
3
  * addresses of host names.
4
4
  *
5
5
  * Although named for the [Domain Name System (DNS)](https://en.wikipedia.org/wiki/Domain_Name_System), it does not always use the
@@ -9,7 +9,7 @@
9
9
  * system do, use {@link lookup}.
10
10
  *
11
11
  * ```js
12
- * const dns = require('dns');
12
+ * const dns = require('node:dns');
13
13
  *
14
14
  * dns.lookup('example.org', (err, address, family) => {
15
15
  * console.log('address: %j family: IPv%s', address, family);
@@ -17,13 +17,13 @@
17
17
  * // address: "93.184.216.34" family: IPv4
18
18
  * ```
19
19
  *
20
- * All other functions in the `dns` module connect to an actual DNS server to
20
+ * All other functions in the `node:dns` module connect to an actual DNS server to
21
21
  * perform name resolution. They will always use the network to perform DNS
22
22
  * queries. These functions do not use the same set of configuration files used by {@link lookup} (e.g. `/etc/hosts`). Use these functions to always perform
23
23
  * DNS queries, bypassing other name-resolution facilities.
24
24
  *
25
25
  * ```js
26
- * const dns = require('dns');
26
+ * const dns = require('node:dns');
27
27
  *
28
28
  * dns.resolve4('archive.org', (err, addresses) => {
29
29
  * if (err) throw err;
@@ -41,13 +41,21 @@
41
41
  * });
42
42
  * ```
43
43
  *
44
- * See the `Implementation considerations section` for more information.
45
- * @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/dns.js)
44
+ * See the [Implementation considerations section](https://nodejs.org/docs/latest-v16.x/api/dns.html#implementation-considerations) for more information.
45
+ * @see [source](https://github.com/nodejs/node/blob/v16.20.2/lib/dns.js)
46
46
  */
47
47
  declare module "dns" {
48
48
  import * as dnsPromises from "node:dns/promises";
49
49
  // Supported getaddrinfo flags.
50
+ /**
51
+ * Limits returned address types to the types of non-loopback addresses configured on the system. For example, IPv4 addresses are
52
+ * only returned if the current system has at least one IPv4 address configured.
53
+ */
50
54
  export const ADDRCONFIG: number;
55
+ /**
56
+ * If the IPv6 family was specified, but no IPv6 addresses were found, then return IPv4 mapped IPv6 addresses. It is not supported
57
+ * on some operating systems (e.g. FreeBSD 10.1).
58
+ */
51
59
  export const V4MAPPED: number;
52
60
  /**
53
61
  * If `dns.V4MAPPED` is specified, return resolved IPv6 addresses as
@@ -55,9 +63,29 @@ declare module "dns" {
55
63
  */
56
64
  export const ALL: number;
57
65
  export interface LookupOptions {
58
- family?: number | undefined;
66
+ /**
67
+ * The record family. Must be `4`, `6`, or `0`. For backward compatibility reasons,`'IPv4'` and `'IPv6'` are interpreted
68
+ * as `4` and `6` respectively. The value 0 indicates that either an IPv4 or IPv6 address is returned. If the value `0` is used
69
+ * with `{ all: true } (see below)`, both IPv4 and IPv6 addresses are returned.
70
+ * @default 0
71
+ */
72
+ family?: number | "IPv4" | "IPv6" | undefined;
73
+ /**
74
+ * One or more [supported `getaddrinfo`](https://nodejs.org/docs/latest-v16.x/api/dns.html#supported-getaddrinfo-flags) flags. Multiple flags may be
75
+ * passed by bitwise `OR`ing their values.
76
+ */
59
77
  hints?: number | undefined;
78
+ /**
79
+ * When `true`, the callback returns all resolved addresses in an array. Otherwise, returns a single address.
80
+ * @default false
81
+ */
60
82
  all?: boolean | undefined;
83
+ /**
84
+ * When `true`, the callback receives IPv4 and IPv6 addresses in the order the DNS resolver returned them. When `false`, IPv4
85
+ * addresses are placed before IPv6 addresses. Default value is configurable using {@link setDefaultResultOrder()}
86
+ * or [`--dns-result-order`](https://nodejs.org/docs/latest-v16.x/api/cli.html#--dns-result-orderorder).
87
+ * @default true (addresses are not reordered)
88
+ */
61
89
  verbatim?: boolean | undefined;
62
90
  }
63
91
  export interface LookupOneOptions extends LookupOptions {
@@ -67,16 +95,23 @@ declare module "dns" {
67
95
  all: true;
68
96
  }
69
97
  export interface LookupAddress {
98
+ /**
99
+ * A string representation of an IPv4 or IPv6 address.
100
+ */
70
101
  address: string;
102
+ /**
103
+ * `4` or `6`, denoting the family of `address`, or `0` if the address is not an IPv4 or IPv6 address. `0` is a likely indicator of a
104
+ * bug in the name resolution service used by the operating system.
105
+ */
71
106
  family: number;
72
107
  }
73
108
  /**
74
109
  * Resolves a host name (e.g. `'nodejs.org'`) into the first found A (IPv4) or
75
110
  * AAAA (IPv6) record. All `option` properties are optional. If `options` is an
76
- * integer, then it must be `4` or `6` – if `options` is not provided, then IPv4
77
- * and IPv6 addresses are both returned if found.
111
+ * integer, then it must be `4` or `6` – if `options` is `0` or not provided, then
112
+ * IPv4 and IPv6 addresses are both returned if found.
78
113
  *
79
- * With the `all` option set to `true`, the arguments for `callback` change to`(err, addresses)`, with `addresses` being an array of objects with the
114
+ * With the `all` option set to `true`, the arguments for `callback` change to `(err, addresses)`, with `addresses` being an array of objects with the
80
115
  * properties `address` and `family`.
81
116
  *
82
117
  * On error, `err` is an `Error` object, where `err.code` is the error code.
@@ -86,14 +121,15 @@ declare module "dns" {
86
121
  *
87
122
  * `dns.lookup()` does not necessarily have anything to do with the DNS protocol.
88
123
  * The implementation uses an operating system facility that can associate names
89
- * with addresses, and vice versa. This implementation can have subtle but
124
+ * with addresses and vice versa. This implementation can have subtle but
90
125
  * important consequences on the behavior of any Node.js program. Please take some
91
- * time to consult the `Implementation considerations section` before using`dns.lookup()`.
126
+ * time to consult the [Implementation considerations section](https://nodejs.org/docs/latest-v16.x/api/dns.html#implementation-considerations)
127
+ * before using `dns.lookup()`.
92
128
  *
93
129
  * Example usage:
94
130
  *
95
131
  * ```js
96
- * const dns = require('dns');
132
+ * const dns = require('node:dns');
97
133
  * const options = {
98
134
  * family: 6,
99
135
  * hints: dns.ADDRCONFIG | dns.V4MAPPED,
@@ -109,7 +145,8 @@ declare module "dns" {
109
145
  * // addresses: [{"address":"2606:2800:220:1:248:1893:25c8:1946","family":6}]
110
146
  * ```
111
147
  *
112
- * If this method is invoked as its `util.promisify()` ed version, and `all`is not set to `true`, it returns a `Promise` for an `Object` with `address` and`family` properties.
148
+ * If this method is invoked as its [util.promisify()](https://nodejs.org/docs/latest-v16.x/api/util.html#utilpromisifyoriginal) ed
149
+ * version, and `all` is not set to `true`, it returns a `Promise` for an `Object` with `address` and `family` properties.
113
150
  * @since v0.1.90
114
151
  */
115
152
  export function lookup(
@@ -146,19 +183,21 @@ declare module "dns" {
146
183
  * the operating system's underlying `getnameinfo` implementation.
147
184
  *
148
185
  * If `address` is not a valid IP address, a `TypeError` will be thrown.
149
- * The `port` will be coerced to a number. If it is not a legal port, a `TypeError`will be thrown.
186
+ * The `port` will be coerced to a number. If it is not a legal port, a `TypeError` will be thrown.
150
187
  *
151
- * On an error, `err` is an `Error` object, where `err.code` is the error code.
188
+ * On an error, `err` is an [`Error`](https://nodejs.org/docs/latest-v16.x/api/errors.html#class-error) object,
189
+ * where `err.code` is the error code.
152
190
  *
153
191
  * ```js
154
- * const dns = require('dns');
192
+ * const dns = require('node:dns');
155
193
  * dns.lookupService('127.0.0.1', 22, (err, hostname, service) => {
156
194
  * console.log(hostname, service);
157
195
  * // Prints: localhost ssh
158
196
  * });
159
197
  * ```
160
198
  *
161
- * If this method is invoked as its `util.promisify()` ed version, it returns a`Promise` for an `Object` with `hostname` and `service` properties.
199
+ * If this method is invoked as its [util.promisify()](https://nodejs.org/docs/latest-v16.x/api/util.html#utilpromisifyoriginal) ed
200
+ * version, it returns a `Promise` for an `Object` with `hostname` and `service` properties.
162
201
  * @since v0.11.14
163
202
  */
164
203
  export function lookupService(
@@ -269,12 +308,13 @@ declare module "dns" {
269
308
  | AnyTxtRecord;
270
309
  /**
271
310
  * Uses the DNS protocol to resolve a host name (e.g. `'nodejs.org'`) into an array
272
- * of the resource records. The `callback` function has arguments`(err, records)`. When successful, `records` will be an array of resource
311
+ * of the resource records. The `callback` function has arguments `(err, records)`. When successful, `records` will be an array of resource
273
312
  * records. The type and structure of individual results varies based on `rrtype`:
274
313
  *
275
314
  * <omitted>
276
315
  *
277
- * On error, `err` is an `Error` object, where `err.code` is one of the `DNS error codes`.
316
+ * On error, `err` is an [`Error`](https://nodejs.org/docs/latest-v16.x/api/errors.html#class-error) object,
317
+ * where `err.code` is one of the `DNS error codes`.
278
318
  * @since v0.1.27
279
319
  * @param hostname Host name to resolve.
280
320
  * @param [rrtype='A'] Resource record type.
@@ -360,7 +400,7 @@ declare module "dns" {
360
400
  ): Promise<string[] | MxRecord[] | NaptrRecord[] | SoaRecord | SrvRecord[] | string[][] | AnyRecord[]>;
361
401
  }
362
402
  /**
363
- * Uses the DNS protocol to resolve a IPv4 addresses (`A` records) for the`hostname`. The `addresses` argument passed to the `callback` function
403
+ * Uses the DNS protocol to resolve a IPv4 addresses (`A` records) for the `hostname`. The `addresses` argument passed to the `callback` function
364
404
  * will contain an array of IPv4 addresses (e.g.`['74.125.79.104', '74.125.79.105', '74.125.79.106']`).
365
405
  * @since v0.1.16
366
406
  * @param hostname Host name to resolve.
@@ -385,7 +425,7 @@ declare module "dns" {
385
425
  function __promisify__(hostname: string, options?: ResolveOptions): Promise<string[] | RecordWithTtl[]>;
386
426
  }
387
427
  /**
388
- * Uses the DNS protocol to resolve a IPv6 addresses (`AAAA` records) for the`hostname`. The `addresses` argument passed to the `callback` function
428
+ * Uses the DNS protocol to resolve IPv6 addresses (`AAAA` records) for the `hostname`. The `addresses` argument passed to the `callback` function
389
429
  * will contain an array of IPv6 addresses.
390
430
  * @since v0.1.16
391
431
  * @param hostname Host name to resolve.
@@ -410,8 +450,8 @@ declare module "dns" {
410
450
  function __promisify__(hostname: string, options?: ResolveOptions): Promise<string[] | RecordWithTtl[]>;
411
451
  }
412
452
  /**
413
- * Uses the DNS protocol to resolve `CNAME` records for the `hostname`. The`addresses` argument passed to the `callback` function
414
- * will contain an array of canonical name records available for the `hostname`(e.g. `['bar.example.com']`).
453
+ * Uses the DNS protocol to resolve `CNAME` records for the `hostname`. The `addresses` argument passed to the `callback` function
454
+ * will contain an array of canonical name records available for the `hostname` (e.g. `['bar.example.com']`).
415
455
  * @since v0.3.2
416
456
  */
417
457
  export function resolveCname(
@@ -422,7 +462,7 @@ declare module "dns" {
422
462
  function __promisify__(hostname: string): Promise<string[]>;
423
463
  }
424
464
  /**
425
- * Uses the DNS protocol to resolve `CAA` records for the `hostname`. The`addresses` argument passed to the `callback` function
465
+ * Uses the DNS protocol to resolve `CAA` records for the `hostname`. The `addresses` argument passed to the `callback` function
426
466
  * will contain an array of certification authority authorization records
427
467
  * available for the `hostname` (e.g. `[{critical: 0, iodef: 'mailto:pki@example.com'}, {critical: 128, issue: 'pki.example.com'}]`).
428
468
  * @since v15.0.0
@@ -435,8 +475,8 @@ declare module "dns" {
435
475
  function __promisify__(hostname: string): Promise<CaaRecord[]>;
436
476
  }
437
477
  /**
438
- * Uses the DNS protocol to resolve mail exchange records (`MX` records) for the`hostname`. The `addresses` argument passed to the `callback` function will
439
- * contain an array of objects containing both a `priority` and `exchange`property (e.g. `[{priority: 10, exchange: 'mx.example.com'}, ...]`).
478
+ * Uses the DNS protocol to resolve mail exchange records (`MX` records) for the `hostname`. The `addresses` argument passed to the `callback` function will
479
+ * contain an array of objects containing both a `priority` and `exchange` property (e.g. `[{priority: 10, exchange: 'mx.example.com'}, ...]`).
440
480
  * @since v0.1.27
441
481
  */
442
482
  export function resolveMx(
@@ -447,7 +487,7 @@ declare module "dns" {
447
487
  function __promisify__(hostname: string): Promise<MxRecord[]>;
448
488
  }
449
489
  /**
450
- * Uses the DNS protocol to resolve regular expression based records (`NAPTR`records) for the `hostname`. The `addresses` argument passed to the `callback`function will contain an array of
490
+ * Uses the DNS protocol to resolve regular expression-based records (`NAPTR` records) for the `hostname`. The `addresses` argument passed to the `callback` function will contain an array of
451
491
  * objects with the following properties:
452
492
  *
453
493
  * * `flags`
@@ -477,8 +517,8 @@ declare module "dns" {
477
517
  function __promisify__(hostname: string): Promise<NaptrRecord[]>;
478
518
  }
479
519
  /**
480
- * Uses the DNS protocol to resolve name server records (`NS` records) for the`hostname`. The `addresses` argument passed to the `callback` function will
481
- * contain an array of name server records available for `hostname`(e.g. `['ns1.example.com', 'ns2.example.com']`).
520
+ * Uses the DNS protocol to resolve name server records (`NS` records) for the `hostname`. The `addresses` argument passed to the `callback` function will
521
+ * contain an array of name server records available for `hostname` (e.g. `['ns1.example.com', 'ns2.example.com']`).
482
522
  * @since v0.1.90
483
523
  */
484
524
  export function resolveNs(
@@ -489,7 +529,7 @@ declare module "dns" {
489
529
  function __promisify__(hostname: string): Promise<string[]>;
490
530
  }
491
531
  /**
492
- * Uses the DNS protocol to resolve pointer records (`PTR` records) for the`hostname`. The `addresses` argument passed to the `callback` function will
532
+ * Uses the DNS protocol to resolve pointer records (`PTR` records) for the `hostname`. The `addresses` argument passed to the `callback` function will
493
533
  * be an array of strings containing the reply records.
494
534
  * @since v6.0.0
495
535
  */
@@ -534,7 +574,7 @@ declare module "dns" {
534
574
  function __promisify__(hostname: string): Promise<SoaRecord>;
535
575
  }
536
576
  /**
537
- * Uses the DNS protocol to resolve service records (`SRV` records) for the`hostname`. The `addresses` argument passed to the `callback` function will
577
+ * Uses the DNS protocol to resolve service records (`SRV` records) for the `hostname`. The `addresses` argument passed to the `callback` function will
538
578
  * be an array of objects with the following properties:
539
579
  *
540
580
  * * `priority`
@@ -560,7 +600,7 @@ declare module "dns" {
560
600
  function __promisify__(hostname: string): Promise<SrvRecord[]>;
561
601
  }
562
602
  /**
563
- * Uses the DNS protocol to resolve text queries (`TXT` records) for the`hostname`. The `records` argument passed to the `callback` function is a
603
+ * Uses the DNS protocol to resolve text queries (`TXT` records) for the `hostname`. The `records` argument passed to the `callback` function is a
564
604
  * two-dimensional array of the text records available for `hostname` (e.g.`[ ['v=spf1 ip4:0.0.0.0 ', '~all' ] ]`). Each sub-array contains TXT chunks of
565
605
  * one record. Depending on the use case, these could be either joined together or
566
606
  * treated separately.
@@ -600,8 +640,8 @@ declare module "dns" {
600
640
  * minttl: 60 } ]
601
641
  * ```
602
642
  *
603
- * DNS server operators may choose not to respond to `ANY`queries. It may be better to call individual methods like {@link resolve4},{@link resolveMx}, and so on. For more details, see [RFC
604
- * 8482](https://tools.ietf.org/html/rfc8482).
643
+ * DNS server operators may choose not to respond to `ANY` queries. It may be better to call individual methods like {@link resolve4}, {@link resolveMx}, and so on. For more details, see
644
+ * [RFC 8482](https://tools.ietf.org/html/rfc8482).
605
645
  */
606
646
  export function resolveAny(
607
647
  hostname: string,
@@ -614,8 +654,8 @@ declare module "dns" {
614
654
  * Performs a reverse DNS query that resolves an IPv4 or IPv6 address to an
615
655
  * array of host names.
616
656
  *
617
- * On error, `err` is an `Error` object, where `err.code` is
618
- * one of the `DNS error codes`.
657
+ * On error, `err` is an [`Error`](https://nodejs.org/docs/latest-v16.x/api/errors.html#class-error) object, where `err.code` is
658
+ * one of the [DNS error codes](https://nodejs.org/docs/latest-v16.x/api/dns.html#error-codes).
619
659
  * @since v0.1.16
620
660
  */
621
661
  export function reverse(
@@ -641,14 +681,14 @@ declare module "dns" {
641
681
  * The `dns.setServers()` method must not be called while a DNS query is in
642
682
  * progress.
643
683
  *
644
- * The {@link setServers} method affects only {@link resolve},`dns.resolve*()` and {@link reverse} (and specifically _not_ {@link lookup}).
684
+ * The {@link setServers} method affects only {@link resolve}, `dns.resolve*()` and {@link reverse} (and specifically _not_ {@link lookup}).
645
685
  *
646
686
  * This method works much like [resolve.conf](https://man7.org/linux/man-pages/man5/resolv.conf.5.html).
647
- * That is, if attempting to resolve with the first server provided results in a`NOTFOUND` error, the `resolve()` method will _not_ attempt to resolve with
687
+ * That is, if attempting to resolve with the first server provided results in a `NOTFOUND` error, the `resolve()` method will _not_ attempt to resolve with
648
688
  * subsequent servers provided. Fallback DNS servers will only be used if the
649
689
  * earlier ones time out or result in some other error.
650
690
  * @since v0.11.3
651
- * @param servers array of `RFC 5952` formatted addresses
691
+ * @param servers array of [RFC 5952](https://datatracker.ietf.org/doc/html/rfc5952#section-6) formatted addresses
652
692
  */
653
693
  export function setServers(servers: readonly string[]): void;
654
694
  /**
@@ -668,44 +708,52 @@ declare module "dns" {
668
708
  */
669
709
  export function getServers(): string[];
670
710
  /**
671
- * Set the default value of `verbatim` in {@link lookup}. The value could be:
672
- * - `ipv4first`: sets default `verbatim` `false`.
673
- * - `verbatim`: sets default `verbatim` `true`.
674
- *
675
- * The default is `ipv4first` and {@link setDefaultResultOrder} have higher priority than `--dns-result-order`.
676
- * When using worker threads, {@link setDefaultResultOrder} from the main thread won't affect the default dns orders in workers.
677
- * @since v14.18.0
678
- * @param order must be 'ipv4first' or 'verbatim'.
711
+ * Set the default value of `verbatim` in {@link lookup} and [`dnsPromises.lookup()`](https://nodejs.org/docs/latest-v16.x/api/dns.html#dnspromiseslookuphostname-options).
712
+ * The value could be:
713
+ *
714
+ * * `ipv4first`: sets default `verbatim` `false`.
715
+ * * `verbatim`: sets default `verbatim` `true`.
716
+ *
717
+ * The default is `verbatim` and {@link setDefaultResultOrder} have higher
718
+ * priority than [`--dns-result-order`](https://nodejs.org/docs/latest-v16.x/api/cli.html#--dns-result-orderorder). When using
719
+ * [worker threads](https://nodejs.org/docs/latest-v16.x/api/worker_threads.html), {@link setDefaultResultOrder} from the main
720
+ * thread won't affect the default dns orders in workers.
721
+ * @since v16.4.0, v14.18.0
722
+ * @param order must be `'ipv4first'` or `'verbatim'`.
679
723
  */
680
724
  export function setDefaultResultOrder(order: "ipv4first" | "verbatim"): void;
681
725
  // Error codes
682
- export const NODATA: string;
683
- export const FORMERR: string;
684
- export const SERVFAIL: string;
685
- export const NOTFOUND: string;
686
- export const NOTIMP: string;
687
- export const REFUSED: string;
688
- export const BADQUERY: string;
689
- export const BADNAME: string;
690
- export const BADFAMILY: string;
691
- export const BADRESP: string;
692
- export const CONNREFUSED: string;
693
- export const TIMEOUT: string;
694
- export const EOF: string;
695
- export const FILE: string;
696
- export const NOMEM: string;
697
- export const DESTRUCTION: string;
698
- export const BADSTR: string;
699
- export const BADFLAGS: string;
700
- export const NONAME: string;
701
- export const BADHINTS: string;
702
- export const NOTINITIALIZED: string;
703
- export const LOADIPHLPAPI: string;
704
- export const ADDRGETNETWORKPARAMS: string;
705
- export const CANCELLED: string;
726
+ export const NODATA: "NODATA";
727
+ export const FORMERR: "FORMERR";
728
+ export const SERVFAIL: "SERVFAIL";
729
+ export const NOTFOUND: "NOTFOUND";
730
+ export const NOTIMP: "NOTIMP";
731
+ export const REFUSED: "REFUSED";
732
+ export const BADQUERY: "BADQUERY";
733
+ export const BADNAME: "BADNAME";
734
+ export const BADFAMILY: "BADFAMILY";
735
+ export const BADRESP: "BADRESP";
736
+ export const CONNREFUSED: "TIMEOUT";
737
+ export const TIMEOUT: "TIMEOUT";
738
+ export const EOF: "EOF";
739
+ export const FILE: "FILE";
740
+ export const NOMEM: "NOMEM";
741
+ export const DESTRUCTION: "DESTRUCTION";
742
+ export const BADSTR: "BADSTR";
743
+ export const BADFLAGS: "BADFLAGS";
744
+ export const NONAME: "NONAME";
745
+ export const BADHINTS: "BADHINTS";
746
+ export const NOTINITIALIZED: "NOTINITIALIZED";
747
+ export const LOADIPHLPAPI: "LOADIPHLPAPI";
748
+ export const ADDRGETNETWORKPARAMS: "ADDRGETNETWORKPARAMS";
749
+ export const CANCELLED: "CANCELLED";
706
750
  export interface ResolverOptions {
751
+ /**
752
+ * Query timeout in milliseconds, or `-1` to use the default timeout.
753
+ */
707
754
  timeout?: number | undefined;
708
755
  /**
756
+ * The number of tries the resolver will try contacting each name server before giving up.
709
757
  * @default 4
710
758
  */
711
759
  tries?: number;
@@ -714,11 +762,11 @@ declare module "dns" {
714
762
  * An independent resolver for DNS requests.
715
763
  *
716
764
  * Creating a new resolver uses the default server settings. Setting
717
- * the servers used for a resolver using `resolver.setServers()` does not affect
765
+ * the servers used for a resolver using [`resolver.setServers()`](https://nodejs.org/docs/latest-v16.x/api/dns.html#dnssetserversservers) does not affect
718
766
  * other resolvers:
719
767
  *
720
768
  * ```js
721
- * const { Resolver } = require('dns');
769
+ * const { Resolver } = require('node:dns');
722
770
  * const resolver = new Resolver();
723
771
  * resolver.setServers(['4.4.4.4']);
724
772
  *
@@ -728,7 +776,7 @@ declare module "dns" {
728
776
  * });
729
777
  * ```
730
778
  *
731
- * The following methods from the `dns` module are available:
779
+ * The following methods from the `node:dns` module are available:
732
780
  *
733
781
  * * `resolver.getServers()`
734
782
  * * `resolver.resolve()`
@@ -776,7 +824,7 @@ declare module "dns" {
776
824
  * This allows programs to specify outbound interfaces when used on multi-homed
777
825
  * systems.
778
826
  *
779
- * If a v4 or v6 address is not specified, it is set to the default, and the
827
+ * If a v4 or v6 address is not specified, it is set to the default and the
780
828
  * operating system will choose a local address automatically.
781
829
  *
782
830
  * The resolver will use the v4 local address when making requests to IPv4 DNS
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/node",
3
- "version": "16.18.88",
3
+ "version": "16.18.90",
4
4
  "description": "TypeScript definitions for node",
5
5
  "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
6
6
  "license": "MIT",
@@ -210,6 +210,6 @@
210
210
  },
211
211
  "scripts": {},
212
212
  "dependencies": {},
213
- "typesPublisherContentHash": "318619be749b3fa9d2951d2c3a54e00f080bd2c4ee4b34faa7f292a01eb6ac89",
213
+ "typesPublisherContentHash": "aa9c14fcc25efc459c4ff74300efccbebda4f58f09560cf5e9afd66f72e92ddf",
214
214
  "typeScriptVersion": "4.7"
215
215
  }