yq-dns 1.0.1 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +351 -756
  2. package/dist/index.d.ts +1611 -0
  3. package/package.json +4 -4
@@ -0,0 +1,1611 @@
1
+ import { AnyARecord, AnyAaaaRecord, AnyCnameRecord, AnyMxRecord, AnyNaptrRecord, AnyNsRecord, AnyPtrRecord, AnySoaRecord, AnySrvRecord, AnyTlsaRecord, AnyTxtRecord, CaaRecord, MxRecord, NaptrRecord, RecordWithTtl, ResolveOptions, ResolveWithTtlOptions, SoaRecord, SrvRecord, TlsaRecord } from 'node:dns';
2
+
3
+ /**
4
+ * Configuration for a DNS provider's concurrency and rate limiting.
5
+ */
6
+ export interface ProviderConfig {
7
+ /**
8
+ * Concurrency and rate limiting configuration.
9
+ * Can be either a simple concurrency limit or include interval-based rate limiting.
10
+ */
11
+ limit?: {
12
+ /** Maximum number of concurrent requests */
13
+ concurrency: number;
14
+ /** Time interval in milliseconds for rate limiting */
15
+ interval?: number;
16
+ /** Maximum number of requests per interval */
17
+ intervalCap?: number;
18
+ /**
19
+ * Whether to carry over the concurrency count from the previous interval.
20
+ * @default false
21
+ */
22
+ carryoverConcurrencyCount?: boolean;
23
+ };
24
+ /**
25
+ * Whether this provider is enabled.
26
+ * @default true
27
+ */
28
+ enabled?: boolean;
29
+ }
30
+ /**
31
+ * Configuration for all DNS providers.
32
+ */
33
+ export interface YqConfig {
34
+ /** Configuration for the native Node.js DNS resolver */
35
+ native?: ProviderConfig;
36
+ /** Configuration for Google DNS-over-HTTPS */
37
+ google?: ProviderConfig;
38
+ /** Configuration for Cloudflare DNS-over-HTTPS */
39
+ cloudflare?: ProviderConfig;
40
+ /** Configuration for Quad9 DNS-over-HTTPS */
41
+ quad9?: ProviderConfig;
42
+ }
43
+ /**
44
+ * Union type of all possible DNS record types returned by ANY queries.
45
+ */
46
+ export type AnyRecord = AnyARecord | AnyAaaaRecord | AnyCnameRecord | AnyMxRecord | AnyNaptrRecord | AnyNsRecord | AnyPtrRecord | AnySoaRecord | AnySrvRecord | AnyTlsaRecord | AnyTxtRecord;
47
+ /**
48
+ * Available DNS provider names.
49
+ */
50
+ export type ProviderName = "native" | "google" | "cloudflare" | "quad9";
51
+ /**
52
+ * DNS record types supported by the resolver.
53
+ */
54
+ export type RecordType = "A" | "AAAA" | "ANY" | "CAA" | "CNAME" | "MX" | "NAPTR" | "NS" | "PTR" | "SOA" | "SRV" | "TLSA" | "TXT";
55
+ /**
56
+ * Error thrown when no providers are enabled.
57
+ */
58
+ export declare class NoEnabledProvidersError extends Error {
59
+ constructor();
60
+ }
61
+ /**
62
+ * Error thrown when an invalid hostname is provided.
63
+ */
64
+ export declare class InvalidHostnameError extends Error {
65
+ constructor(hostname: string);
66
+ }
67
+ /**
68
+ * Error thrown when a provider is not enabled.
69
+ */
70
+ export declare class ProviderNotEnabledError extends Error {
71
+ constructor(provider: string);
72
+ }
73
+ /**
74
+ * Error thrown when an invalid provider name is specified.
75
+ */
76
+ export declare class InvalidProviderError extends Error {
77
+ constructor(provider: string);
78
+ }
79
+ export interface IResolver {
80
+ /**
81
+ * Resolves DNS records for a hostname without specifying record type (defaults to A records)
82
+ * @param hostname - The hostname to resolve
83
+ * @returns Promise resolving to an array of IPv4 addresses
84
+ */
85
+ resolve(hostname: string): Promise<string[]>;
86
+ /**
87
+ * Resolves DNS records for a hostname without specifying record type but with a specific provider
88
+ * @param hostname - The hostname to resolve
89
+ * @param provider - The DNS provider to use
90
+ * @returns Promise resolving to an array of IPv4 addresses
91
+ */
92
+ resolve(hostname: string, provider: ProviderName): Promise<string[]>;
93
+ /**
94
+ * Resolves A records for a hostname
95
+ * @param hostname - The hostname to resolve
96
+ * @param rrtype - DNS record type "A"
97
+ * @returns Promise resolving to an array of IPv4 addresses
98
+ */
99
+ resolve(hostname: string, rrtype: "A"): Promise<string[]>;
100
+ /**
101
+ * Resolves A records for a hostname with a specific provider
102
+ * @param hostname - The hostname to resolve
103
+ * @param rrtype - DNS record type "A"
104
+ * @param provider - The DNS provider to use
105
+ * @returns Promise resolving to an array of IPv4 addresses
106
+ */
107
+ resolve(hostname: string, rrtype: "A", provider: ProviderName): Promise<string[]>;
108
+ /**
109
+ * Resolves AAAA records for a hostname
110
+ * @param hostname - The hostname to resolve
111
+ * @param rrtype - DNS record type "AAAA"
112
+ * @returns Promise resolving to an array of IPv6 addresses
113
+ */
114
+ resolve(hostname: string, rrtype: "AAAA"): Promise<string[]>;
115
+ /**
116
+ * Resolves AAAA records for a hostname with a specific provider
117
+ * @param hostname - The hostname to resolve
118
+ * @param rrtype - DNS record type "AAAA"
119
+ * @param provider - The DNS provider to use
120
+ * @returns Promise resolving to an array of IPv6 addresses
121
+ */
122
+ resolve(hostname: string, rrtype: "AAAA", provider: ProviderName): Promise<string[]>;
123
+ /**
124
+ * Resolves ANY records for a hostname
125
+ * @param hostname - The hostname to resolve
126
+ * @param rrtype - DNS record type "ANY"
127
+ * @returns Promise resolving to an array of any DNS records
128
+ */
129
+ resolve(hostname: string, rrtype: "ANY"): Promise<AnyRecord[]>;
130
+ /**
131
+ * Resolves ANY records for a hostname with a specific provider
132
+ * @param hostname - The hostname to resolve
133
+ * @param rrtype - DNS record type "ANY"
134
+ * @param provider - The DNS provider to use
135
+ * @returns Promise resolving to an array of any DNS records
136
+ */
137
+ resolve(hostname: string, rrtype: "ANY", provider: ProviderName): Promise<AnyRecord[]>;
138
+ /**
139
+ * Resolves CAA records for a hostname
140
+ * @param hostname - The hostname to resolve
141
+ * @param rrtype - DNS record type "CAA"
142
+ * @returns Promise resolving to an array of CAA records
143
+ */
144
+ resolve(hostname: string, rrtype: "CAA"): Promise<CaaRecord[]>;
145
+ /**
146
+ * Resolves CAA records for a hostname with a specific provider
147
+ * @param hostname - The hostname to resolve
148
+ * @param rrtype - DNS record type "CAA"
149
+ * @param provider - The DNS provider to use
150
+ * @returns Promise resolving to an array of CAA records
151
+ */
152
+ resolve(hostname: string, rrtype: "CAA", provider: ProviderName): Promise<CaaRecord[]>;
153
+ /**
154
+ * Resolves CNAME records for a hostname
155
+ * @param hostname - The hostname to resolve
156
+ * @param rrtype - DNS record type "CNAME"
157
+ * @returns Promise resolving to an array of canonical names
158
+ */
159
+ resolve(hostname: string, rrtype: "CNAME"): Promise<string[]>;
160
+ /**
161
+ * Resolves CNAME records for a hostname with a specific provider
162
+ * @param hostname - The hostname to resolve
163
+ * @param rrtype - DNS record type "CNAME"
164
+ * @param provider - The DNS provider to use
165
+ * @returns Promise resolving to an array of canonical names
166
+ */
167
+ resolve(hostname: string, rrtype: "CNAME", provider: ProviderName): Promise<string[]>;
168
+ /**
169
+ * Resolves MX records for a hostname
170
+ * @param hostname - The hostname to resolve
171
+ * @param rrtype - DNS record type "MX"
172
+ * @returns Promise resolving to an array of mail exchange records
173
+ */
174
+ resolve(hostname: string, rrtype: "MX"): Promise<MxRecord[]>;
175
+ /**
176
+ * Resolves MX records for a hostname with a specific provider
177
+ * @param hostname - The hostname to resolve
178
+ * @param rrtype - DNS record type "MX"
179
+ * @param provider - The DNS provider to use
180
+ * @returns Promise resolving to an array of mail exchange records
181
+ */
182
+ resolve(hostname: string, rrtype: "MX", provider: ProviderName): Promise<MxRecord[]>;
183
+ /**
184
+ * Resolves NAPTR records for a hostname
185
+ * @param hostname - The hostname to resolve
186
+ * @param rrtype - DNS record type "NAPTR"
187
+ * @returns Promise resolving to an array of NAPTR records
188
+ */
189
+ resolve(hostname: string, rrtype: "NAPTR"): Promise<NaptrRecord[]>;
190
+ /**
191
+ * Resolves NAPTR records for a hostname with a specific provider
192
+ * @param hostname - The hostname to resolve
193
+ * @param rrtype - DNS record type "NAPTR"
194
+ * @param provider - The DNS provider to use
195
+ * @returns Promise resolving to an array of NAPTR records
196
+ */
197
+ resolve(hostname: string, rrtype: "NAPTR", provider: ProviderName): Promise<NaptrRecord[]>;
198
+ /**
199
+ * Resolves NS records for a hostname
200
+ * @param hostname - The hostname to resolve
201
+ * @param rrtype - DNS record type "NS"
202
+ * @returns Promise resolving to an array of nameserver hostnames
203
+ */
204
+ resolve(hostname: string, rrtype: "NS"): Promise<string[]>;
205
+ /**
206
+ * Resolves NS records for a hostname with a specific provider
207
+ * @param hostname - The hostname to resolve
208
+ * @param rrtype - DNS record type "NS"
209
+ * @param provider - The DNS provider to use
210
+ * @returns Promise resolving to an array of nameserver hostnames
211
+ */
212
+ resolve(hostname: string, rrtype: "NS", provider: ProviderName): Promise<string[]>;
213
+ /**
214
+ * Resolves PTR records for a hostname
215
+ * @param hostname - The hostname to resolve
216
+ * @param rrtype - DNS record type "PTR"
217
+ * @returns Promise resolving to an array of pointer records
218
+ */
219
+ resolve(hostname: string, rrtype: "PTR"): Promise<string[]>;
220
+ /**
221
+ * Resolves PTR records for a hostname with a specific provider
222
+ * @param hostname - The hostname to resolve
223
+ * @param rrtype - DNS record type "PTR"
224
+ * @param provider - The DNS provider to use
225
+ * @returns Promise resolving to an array of pointer records
226
+ */
227
+ resolve(hostname: string, rrtype: "PTR", provider: ProviderName): Promise<string[]>;
228
+ /**
229
+ * Resolves SOA record for a hostname
230
+ * @param hostname - The hostname to resolve
231
+ * @param rrtype - DNS record type "SOA"
232
+ * @returns Promise resolving to a start of authority record
233
+ */
234
+ resolve(hostname: string, rrtype: "SOA"): Promise<SoaRecord>;
235
+ /**
236
+ * Resolves SOA record for a hostname with a specific provider
237
+ * @param hostname - The hostname to resolve
238
+ * @param rrtype - DNS record type "SOA"
239
+ * @param provider - The DNS provider to use
240
+ * @returns Promise resolving to a start of authority record
241
+ */
242
+ resolve(hostname: string, rrtype: "SOA", provider: ProviderName): Promise<SoaRecord>;
243
+ /**
244
+ * Resolves SRV records for a hostname
245
+ * @param hostname - The hostname to resolve
246
+ * @param rrtype - DNS record type "SRV"
247
+ * @returns Promise resolving to an array of service records
248
+ */
249
+ resolve(hostname: string, rrtype: "SRV"): Promise<SrvRecord[]>;
250
+ /**
251
+ * Resolves SRV records for a hostname with a specific provider
252
+ * @param hostname - The hostname to resolve
253
+ * @param rrtype - DNS record type "SRV"
254
+ * @param provider - The DNS provider to use
255
+ * @returns Promise resolving to an array of service records
256
+ */
257
+ resolve(hostname: string, rrtype: "SRV", provider: ProviderName): Promise<SrvRecord[]>;
258
+ /**
259
+ * Resolves TLSA records for a hostname
260
+ * @param hostname - The hostname to resolve
261
+ * @param rrtype - DNS record type "TLSA"
262
+ * @returns Promise resolving to an array of TLSA records
263
+ */
264
+ resolve(hostname: string, rrtype: "TLSA"): Promise<TlsaRecord[]>;
265
+ /**
266
+ * Resolves TLSA records for a hostname with a specific provider
267
+ * @param hostname - The hostname to resolve
268
+ * @param rrtype - DNS record type "TLSA"
269
+ * @param provider - The DNS provider to use
270
+ * @returns Promise resolving to an array of TLSA records
271
+ */
272
+ resolve(hostname: string, rrtype: "TLSA", provider: ProviderName): Promise<TlsaRecord[]>;
273
+ /**
274
+ * Resolves TXT records for a hostname
275
+ * @param hostname - The hostname to resolve
276
+ * @param rrtype - DNS record type "TXT"
277
+ * @returns Promise resolving to an array of text record arrays
278
+ */
279
+ resolve(hostname: string, rrtype: "TXT"): Promise<string[][]>;
280
+ /**
281
+ * Resolves TXT records for a hostname with a specific provider
282
+ * @param hostname - The hostname to resolve
283
+ * @param rrtype - DNS record type "TXT"
284
+ * @param provider - The DNS provider to use
285
+ * @returns Promise resolving to an array of text record arrays
286
+ */
287
+ resolve(hostname: string, rrtype: "TXT", provider: ProviderName): Promise<string[][]>;
288
+ /**
289
+ * Uses the DNS protocol to resolve IPv4 addresses (`A` records) for the `hostname`. On success, the `Promise` is resolved with an array of IPv4
290
+ * addresses (e.g. `['74.125.79.104', '74.125.79.105', '74.125.79.106']`).
291
+ * @since v10.6.0
292
+ * @param hostname Host name to resolve.
293
+ */
294
+ resolve4(hostname: string): Promise<string[]>;
295
+ resolve4(hostname: string, options: ResolveWithTtlOptions): Promise<RecordWithTtl[]>;
296
+ resolve4(hostname: string, options: ResolveOptions): Promise<string[] | RecordWithTtl[]>;
297
+ /**
298
+ * Uses the DNS protocol to resolve IPv4 addresses (`A` records) for the `hostname` using a specific provider.
299
+ * @param hostname Host name to resolve.
300
+ * @param provider The DNS provider to use for resolution.
301
+ */
302
+ resolve4(hostname: string, provider: ProviderName): Promise<string[]>;
303
+ /**
304
+ * Uses the DNS protocol to resolve IPv4 addresses (`A` records) for the `hostname` with TTL using a specific provider.
305
+ * @param hostname Host name to resolve.
306
+ * @param options Resolution options with TTL enabled.
307
+ * @param provider The DNS provider to use for resolution.
308
+ */
309
+ resolve4(hostname: string, options: ResolveWithTtlOptions, provider: ProviderName): Promise<RecordWithTtl[]>;
310
+ /**
311
+ * Uses the DNS protocol to resolve IPv4 addresses (`A` records) for the `hostname` with options using a specific provider.
312
+ * @param hostname Host name to resolve.
313
+ * @param options Resolution options.
314
+ * @param provider The DNS provider to use for resolution.
315
+ */
316
+ resolve4(hostname: string, options: ResolveOptions, provider: ProviderName): Promise<string[] | RecordWithTtl[]>;
317
+ /**
318
+ * Uses the DNS protocol to resolve IPv6 addresses (`AAAA` records) for the `hostname`. On success, the `Promise` is resolved with an array of IPv6
319
+ * addresses.
320
+ * @since v10.6.0
321
+ * @param hostname Host name to resolve.
322
+ */
323
+ resolve6(hostname: string): Promise<string[]>;
324
+ resolve6(hostname: string, options: ResolveWithTtlOptions): Promise<RecordWithTtl[]>;
325
+ resolve6(hostname: string, options: ResolveOptions): Promise<string[] | RecordWithTtl[]>;
326
+ /**
327
+ * Uses the DNS protocol to resolve IPv6 addresses (`AAAA` records) for the `hostname` using a specific provider.
328
+ * @param hostname Host name to resolve.
329
+ * @param provider The DNS provider to use for resolution.
330
+ */
331
+ resolve6(hostname: string, provider: ProviderName): Promise<string[]>;
332
+ /**
333
+ * Uses the DNS protocol to resolve IPv6 addresses (`AAAA` records) for the `hostname` with TTL using a specific provider.
334
+ * @param hostname Host name to resolve.
335
+ * @param options Resolution options with TTL enabled.
336
+ * @param provider The DNS provider to use for resolution.
337
+ */
338
+ resolve6(hostname: string, options: ResolveWithTtlOptions, provider: ProviderName): Promise<RecordWithTtl[]>;
339
+ /**
340
+ * Uses the DNS protocol to resolve IPv6 addresses (`AAAA` records) for the `hostname` with options using a specific provider.
341
+ * @param hostname Host name to resolve.
342
+ * @param options Resolution options.
343
+ * @param provider The DNS provider to use for resolution.
344
+ */
345
+ resolve6(hostname: string, options: ResolveOptions, provider: ProviderName): Promise<string[] | RecordWithTtl[]>;
346
+ /**
347
+ * Uses the DNS protocol to resolve all records (also known as `ANY` or `*` query).
348
+ * On success, the `Promise` is resolved with an array containing various types of
349
+ * records. Each object has a property `type` that indicates the type of the
350
+ * current record. And depending on the `type`, additional properties will be
351
+ * present on the object:
352
+ *
353
+ * <omitted>
354
+ *
355
+ * Here is an example of the result object:
356
+ *
357
+ * ```js
358
+ * [ { type: 'A', address: '127.0.0.1', ttl: 299 },
359
+ * { type: 'CNAME', value: 'example.com' },
360
+ * { type: 'MX', exchange: 'alt4.aspmx.l.example.com', priority: 50 },
361
+ * { type: 'NS', value: 'ns1.example.com' },
362
+ * { type: 'TXT', entries: [ 'v=spf1 include:_spf.example.com ~all' ] },
363
+ * { type: 'SOA',
364
+ * nsname: 'ns1.example.com',
365
+ * hostmaster: 'admin.example.com',
366
+ * serial: 156696742,
367
+ * refresh: 900,
368
+ * retry: 900,
369
+ * expire: 1800,
370
+ * minttl: 60 } ]
371
+ * ```
372
+ * @since v10.6.0
373
+ */
374
+ resolveAny(hostname: string): Promise<AnyRecord[]>;
375
+ /**
376
+ * Uses the DNS protocol to resolve all records (also known as `ANY` or `*` query) using a specific provider.
377
+ * @param hostname Host name to resolve.
378
+ * @param provider The DNS provider to use for resolution.
379
+ */
380
+ resolveAny(hostname: string, provider: ProviderName): Promise<AnyRecord[]>;
381
+ /**
382
+ * Uses the DNS protocol to resolve `CAA` records for the `hostname`. On success,
383
+ * the `Promise` is resolved with an array of objects containing available
384
+ * certification authority authorization records available for the `hostname` (e.g. `[{critical: 0, iodef: 'mailto:pki@example.com'},{critical: 128, issue: 'pki.example.com'}]`).
385
+ * @since v15.0.0, v14.17.0
386
+ */
387
+ resolveCaa(hostname: string): Promise<CaaRecord[]>;
388
+ /**
389
+ * Uses the DNS protocol to resolve `CAA` records for the `hostname` using a specific provider.
390
+ * @param hostname Host name to resolve.
391
+ * @param provider The DNS provider to use for resolution.
392
+ */
393
+ resolveCaa(hostname: string, provider: ProviderName): Promise<CaaRecord[]>;
394
+ /**
395
+ * Uses the DNS protocol to resolve `CNAME` records for the `hostname`. On success,
396
+ * the `Promise` is resolved with an array of canonical name records available for
397
+ * the `hostname` (e.g. `['bar.example.com']`).
398
+ * @since v10.6.0
399
+ */
400
+ resolveCname(hostname: string): Promise<string[]>;
401
+ /**
402
+ * Uses the DNS protocol to resolve `CNAME` records for the `hostname` using a specific provider.
403
+ * @param hostname Host name to resolve.
404
+ * @param provider The DNS provider to use for resolution.
405
+ */
406
+ resolveCname(hostname: string, provider: ProviderName): Promise<string[]>;
407
+ /**
408
+ * 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
409
+ * containing both a `priority` and `exchange` property (e.g.`[{priority: 10, exchange: 'mx.example.com'}, ...]`).
410
+ * @since v10.6.0
411
+ */
412
+ resolveMx(hostname: string): Promise<MxRecord[]>;
413
+ /**
414
+ * Uses the DNS protocol to resolve mail exchange records (`MX` records) for the `hostname` using a specific provider.
415
+ * @param hostname Host name to resolve.
416
+ * @param provider The DNS provider to use for resolution.
417
+ */
418
+ resolveMx(hostname: string, provider: ProviderName): Promise<MxRecord[]>;
419
+ /**
420
+ * Uses the DNS protocol to resolve regular expression-based records (`NAPTR` records) for the `hostname`. On success, the `Promise` is resolved with an array
421
+ * of objects with the following properties:
422
+ *
423
+ * * `flags`
424
+ * * `service`
425
+ * * `regexp`
426
+ * * `replacement`
427
+ * * `order`
428
+ * * `preference`
429
+ *
430
+ * ```js
431
+ * {
432
+ * flags: 's',
433
+ * service: 'SIP+D2U',
434
+ * regexp: '',
435
+ * replacement: '_sip._udp.example.com',
436
+ * order: 30,
437
+ * preference: 100
438
+ * }
439
+ * ```
440
+ * @since v10.6.0
441
+ */
442
+ resolveNaptr(hostname: string): Promise<NaptrRecord[]>;
443
+ /**
444
+ * Uses the DNS protocol to resolve regular expression-based records (`NAPTR` records) for the `hostname` using a specific provider.
445
+ * @param hostname Host name to resolve.
446
+ * @param provider The DNS provider to use for resolution.
447
+ */
448
+ resolveNaptr(hostname: string, provider: ProviderName): Promise<NaptrRecord[]>;
449
+ /**
450
+ * 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
451
+ * records available for `hostname` (e.g.`['ns1.example.com', 'ns2.example.com']`).
452
+ * @since v10.6.0
453
+ */
454
+ resolveNs(hostname: string): Promise<string[]>;
455
+ /**
456
+ * Uses the DNS protocol to resolve name server records (`NS` records) for the `hostname` using a specific provider.
457
+ * @param hostname Host name to resolve.
458
+ * @param provider The DNS provider to use for resolution.
459
+ */
460
+ resolveNs(hostname: string, provider: ProviderName): Promise<string[]>;
461
+ /**
462
+ * Uses the DNS protocol to resolve pointer records (`PTR` records) for the `hostname`. On success, the `Promise` is resolved with an array of strings
463
+ * containing the reply records.
464
+ * @since v10.6.0
465
+ */
466
+ resolvePtr(hostname: string): Promise<string[]>;
467
+ /**
468
+ * Uses the DNS protocol to resolve pointer records (`PTR` records) for the `hostname` using a specific provider.
469
+ * @param hostname Host name to resolve.
470
+ * @param provider The DNS provider to use for resolution.
471
+ */
472
+ resolvePtr(hostname: string, provider: ProviderName): Promise<string[]>;
473
+ /**
474
+ * Uses the DNS protocol to resolve a start of authority record (`SOA` record) for
475
+ * the `hostname`. On success, the `Promise` is resolved with an object with the
476
+ * following properties:
477
+ *
478
+ * * `nsname`
479
+ * * `hostmaster`
480
+ * * `serial`
481
+ * * `refresh`
482
+ * * `retry`
483
+ * * `expire`
484
+ * * `minttl`
485
+ *
486
+ * ```js
487
+ * {
488
+ * nsname: 'ns.example.com',
489
+ * hostmaster: 'root.example.com',
490
+ * serial: 2013101809,
491
+ * refresh: 10000,
492
+ * retry: 2400,
493
+ * expire: 604800,
494
+ * minttl: 3600
495
+ * }
496
+ * ```
497
+ * @since v10.6.0
498
+ */
499
+ resolveSoa(hostname: string): Promise<SoaRecord>;
500
+ /**
501
+ * Uses the DNS protocol to resolve a start of authority record (`SOA` record) for the `hostname` using a specific provider.
502
+ * @param hostname Host name to resolve.
503
+ * @param provider The DNS provider to use for resolution.
504
+ */
505
+ resolveSoa(hostname: string, provider: ProviderName): Promise<SoaRecord>;
506
+ /**
507
+ * 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
508
+ * the following properties:
509
+ *
510
+ * * `priority`
511
+ * * `weight`
512
+ * * `port`
513
+ * * `name`
514
+ *
515
+ * ```js
516
+ * {
517
+ * priority: 10,
518
+ * weight: 5,
519
+ * port: 21223,
520
+ * name: 'service.example.com'
521
+ * }
522
+ * ```
523
+ * @since v10.6.0
524
+ */
525
+ resolveSrv(hostname: string): Promise<SrvRecord[]>;
526
+ /**
527
+ * Uses the DNS protocol to resolve service records (`SRV` records) for the `hostname` using a specific provider.
528
+ * @param hostname Host name to resolve.
529
+ * @param provider The DNS provider to use for resolution.
530
+ */
531
+ resolveSrv(hostname: string, provider: ProviderName): Promise<SrvRecord[]>;
532
+ /**
533
+ * Uses the DNS protocol to resolve certificate associations (`TLSA` records) for
534
+ * the `hostname`. On success, the `Promise` is resolved with an array of objectsAdd commentMore actions
535
+ * with these properties:
536
+ *
537
+ * * `certUsage`
538
+ * * `selector`
539
+ * * `match`
540
+ * * `data`
541
+ *
542
+ * ```js
543
+ * {
544
+ * certUsage: 3,
545
+ * selector: 1,
546
+ * match: 1,
547
+ * data: [ArrayBuffer]
548
+ * }
549
+ * ```
550
+ * @since v23.9.0, v22.15.0
551
+ */
552
+ resolveTlsa(hostname: string): Promise<TlsaRecord[]>;
553
+ /**
554
+ * Uses the DNS protocol to resolve certificate associations (`TLSA` records) for the `hostname` using a specific provider.
555
+ * @param hostname Host name to resolve.
556
+ * @param provider The DNS provider to use for resolution.
557
+ */
558
+ resolveTlsa(hostname: string, provider: ProviderName): Promise<TlsaRecord[]>;
559
+ /**
560
+ * Uses the DNS protocol to resolve text queries (`TXT` records) for the `hostname`. On success, the `Promise` is resolved with a two-dimensional array
561
+ * of the text records available for `hostname` (e.g.`[ ['v=spf1 ip4:0.0.0.0 ', '~all' ] ]`). Each sub-array contains TXT chunks of
562
+ * one record. Depending on the use case, these could be either joined together or
563
+ * treated separately.
564
+ * @since v10.6.0
565
+ */
566
+ resolveTxt(hostname: string): Promise<string[][]>;
567
+ /**
568
+ * Uses the DNS protocol to resolve text queries (`TXT` records) for the `hostname` using a specific provider.
569
+ * @param hostname Host name to resolve.
570
+ * @param provider The DNS provider to use for resolution.
571
+ */
572
+ resolveTxt(hostname: string, provider: ProviderName): Promise<string[][]>;
573
+ /**
574
+ * Performs a reverse DNS query that resolves an IPv4 or IPv6 address to an
575
+ * array of host names.
576
+ *
577
+ * On error, the `Promise` is rejected with an [`Error`](https://nodejs.org/docs/latest-v20.x/api/errors.html#class-error) object, where `err.code`
578
+ * is one of the [DNS error codes](https://nodejs.org/docs/latest-v20.x/api/dns.html#error-codes).
579
+ * @since v10.6.0
580
+ */
581
+ reverse(ip: string): Promise<string[]>;
582
+ /**
583
+ * Performs a reverse DNS query that resolves an IPv4 or IPv6 address to an array of host names using a specific provider.
584
+ * @param ip IPv4 or IPv6 address to reverse resolve.
585
+ * @param provider The DNS provider to use for resolution.
586
+ */
587
+ reverse(ip: string, provider: ProviderName): Promise<string[]>;
588
+ }
589
+ declare const records: readonly [
590
+ {
591
+ readonly name: "Sohu";
592
+ readonly mx: "a.sohu.com";
593
+ },
594
+ {
595
+ readonly name: "Sohu";
596
+ readonly mx: "sohu.com";
597
+ },
598
+ {
599
+ readonly name: "Strato";
600
+ readonly mx: ".rzone.de";
601
+ },
602
+ {
603
+ readonly name: "Strato";
604
+ readonly mx: ".strato.de";
605
+ },
606
+ {
607
+ readonly name: "21cn";
608
+ readonly mx: ".21cn.com";
609
+ },
610
+ {
611
+ readonly name: "163";
612
+ readonly mx: ".netease.com";
613
+ },
614
+ {
615
+ readonly name: "Netvigator";
616
+ readonly mx: ".netvigator.com";
617
+ },
618
+ {
619
+ readonly name: "139";
620
+ readonly mx: ".mail.139.com";
621
+ },
622
+ {
623
+ readonly name: "Nate";
624
+ readonly mx: ".nate.com";
625
+ },
626
+ {
627
+ readonly name: "Naver";
628
+ readonly mx: ".naver.com";
629
+ },
630
+ {
631
+ readonly name: "Daum";
632
+ readonly mx: ".daum.kgslb.com";
633
+ },
634
+ {
635
+ readonly name: "Daum";
636
+ readonly mx: ".hanmail.net";
637
+ },
638
+ {
639
+ readonly name: "Ziggo";
640
+ readonly mx: ".ziggo.nl";
641
+ },
642
+ {
643
+ readonly name: "QQ";
644
+ readonly mx: ".qq.com";
645
+ },
646
+ {
647
+ readonly name: "263.net";
648
+ readonly mx: "263.net";
649
+ },
650
+ {
651
+ readonly name: "Sina";
652
+ readonly mx: ".vip.sina.com";
653
+ },
654
+ {
655
+ readonly name: "Sina";
656
+ readonly mx: ".sina.com.cn";
657
+ },
658
+ {
659
+ readonly name: "Aruba";
660
+ readonly mx: ".aruba.it";
661
+ },
662
+ {
663
+ readonly name: "Aliyun";
664
+ readonly mx: ".mxhichina.com";
665
+ },
666
+ {
667
+ readonly name: "Plala Webmail";
668
+ readonly mx: ".plala.or.jp";
669
+ },
670
+ {
671
+ readonly name: "AOL";
672
+ readonly mx: "mx-aol.mail";
673
+ },
674
+ {
675
+ readonly name: "Turbify";
676
+ readonly mx: "mx-biz.mail.am0.yahoodns.net";
677
+ },
678
+ {
679
+ readonly name: "Turbify";
680
+ readonly mx: "mx-biz.mail.am.yahoodns.net";
681
+ },
682
+ {
683
+ readonly name: "Turbify";
684
+ readonly mx: "mx-biz.mail.am1.yahoodns.net";
685
+ },
686
+ {
687
+ readonly name: "Turbify";
688
+ readonly mx: "mx1.biz.mail.yahoo.com";
689
+ },
690
+ {
691
+ readonly name: "Turbify";
692
+ readonly mx: "mx5.biz.mail.yahoo.com";
693
+ },
694
+ {
695
+ readonly name: "Turbify";
696
+ readonly mx: ".biz.mail.yahoo.com";
697
+ },
698
+ {
699
+ readonly name: "AT&T";
700
+ readonly mx: ".prodigy.net";
701
+ },
702
+ {
703
+ readonly name: "Yahoo";
704
+ readonly mx: ".yahoo.";
705
+ },
706
+ {
707
+ readonly name: "Zoho";
708
+ readonly mx: ".zoho.com";
709
+ },
710
+ {
711
+ readonly name: "Sitestar Webmail";
712
+ readonly mx: ".sitestar.everyone.net";
713
+ readonly webmail: "https://webmail.sitestar.net";
714
+ },
715
+ {
716
+ readonly name: "Outlook Web App (OWA)";
717
+ readonly mx: ".serverdata.net";
718
+ readonly webmail: "https://owa.serverdata.net";
719
+ },
720
+ {
721
+ readonly name: "1and1";
722
+ readonly mx: ".1and1.";
723
+ },
724
+ {
725
+ readonly name: "Outlook";
726
+ readonly mx: "olc.protection.outlook.com";
727
+ },
728
+ {
729
+ readonly name: "Outlook";
730
+ readonly mx: ".mail.outlook.com";
731
+ },
732
+ {
733
+ readonly name: "Outlook";
734
+ readonly mx: ".hotmail.";
735
+ },
736
+ {
737
+ readonly name: "Office 365";
738
+ readonly mx: "mail.protection.outlook.com";
739
+ },
740
+ {
741
+ readonly name: "Office 365";
742
+ readonly mx: ".outlook.com";
743
+ },
744
+ {
745
+ readonly name: "Office 365";
746
+ readonly mx: ".office365.com";
747
+ },
748
+ {
749
+ readonly name: "Gmail";
750
+ readonly mx: ".google.com";
751
+ },
752
+ {
753
+ readonly name: "Mail.ru";
754
+ readonly mx: ".mail.ru";
755
+ },
756
+ {
757
+ readonly name: "Mail.com";
758
+ readonly mx: ".mail.com";
759
+ },
760
+ {
761
+ readonly name: "Earthlink";
762
+ readonly mx: ".earthlink.net";
763
+ },
764
+ {
765
+ readonly name: "Earthlink";
766
+ readonly mx: ".oxsus-vadesecure.net";
767
+ },
768
+ {
769
+ readonly name: "Rackspace";
770
+ readonly mx: ".emailsrvr.com";
771
+ },
772
+ {
773
+ readonly name: "Mimecast";
774
+ readonly mx: ".mimecast.com";
775
+ },
776
+ {
777
+ readonly name: "Godaddy";
778
+ readonly mx: ".secureserver.net";
779
+ },
780
+ {
781
+ readonly name: "Comcast";
782
+ readonly mx: ".comcast.net";
783
+ },
784
+ {
785
+ readonly name: "Office 365";
786
+ readonly mx: ".ppe-hosted.com";
787
+ },
788
+ {
789
+ readonly name: "Office 365";
790
+ readonly mx: ".gslb.pphosted.com";
791
+ },
792
+ {
793
+ readonly name: "Office 365";
794
+ readonly mx: ".arsmtp.com";
795
+ },
796
+ {
797
+ readonly name: "Zoho";
798
+ readonly mx: ".zoho.com";
799
+ },
800
+ {
801
+ readonly name: "ProtonMail";
802
+ readonly mx: "mail.protonmail.ch";
803
+ },
804
+ {
805
+ readonly name: "Facebook";
806
+ readonly mx: ".facebook.com";
807
+ },
808
+ {
809
+ readonly name: "163";
810
+ readonly mx: ".netease.com";
811
+ },
812
+ {
813
+ readonly name: "163";
814
+ readonly mx: ".163.com";
815
+ },
816
+ {
817
+ readonly name: "263";
818
+ readonly mx: ".263.net";
819
+ },
820
+ {
821
+ readonly name: "Aliyun";
822
+ readonly mx: ".alibaba.com";
823
+ },
824
+ {
825
+ readonly name: "Aliyun";
826
+ readonly mx: ".aliyun.com";
827
+ },
828
+ {
829
+ readonly name: "Amazon";
830
+ readonly mx: ".amazon.com";
831
+ },
832
+ {
833
+ readonly name: "Amazon";
834
+ readonly mx: ".amazonaws.com";
835
+ },
836
+ {
837
+ readonly name: "Anazana";
838
+ readonly mx: ".anazana.com";
839
+ },
840
+ {
841
+ readonly name: "CoreMail";
842
+ readonly mx: ".icoremail.net";
843
+ },
844
+ {
845
+ readonly name: "GMX";
846
+ readonly mx: ".gmx.net";
847
+ },
848
+ {
849
+ readonly name: "GMX";
850
+ readonly mx: ".gmx.com";
851
+ },
852
+ {
853
+ readonly name: "Hinet";
854
+ readonly mx: ".hinet.";
855
+ },
856
+ {
857
+ readonly name: "iCloud";
858
+ readonly mx: ".icloud.com";
859
+ },
860
+ {
861
+ readonly name: "Iinet";
862
+ readonly mx: ".iinet.net.au";
863
+ },
864
+ {
865
+ readonly name: "Namecheap";
866
+ readonly mx: ".registrar-servers.com";
867
+ },
868
+ {
869
+ readonly name: "Network Solutions";
870
+ readonly mx: ".myregisteredsite.com";
871
+ },
872
+ {
873
+ readonly name: "Orange";
874
+ readonly mx: ".orange.";
875
+ },
876
+ {
877
+ readonly name: "QQ";
878
+ readonly mx: ".qq.com";
879
+ },
880
+ {
881
+ readonly name: "Synaq";
882
+ readonly mx: ".synaq.";
883
+ },
884
+ {
885
+ readonly name: "Web.de";
886
+ readonly mx: ".web.de";
887
+ },
888
+ {
889
+ readonly name: "Yandex";
890
+ readonly mx: ".yandex.";
891
+ },
892
+ {
893
+ readonly name: "Zmail";
894
+ readonly mx: ".zmail.";
895
+ },
896
+ {
897
+ readonly name: "Strato";
898
+ readonly mx: ".strato.de";
899
+ },
900
+ {
901
+ readonly name: "Apple";
902
+ readonly mx: ".apple.com";
903
+ },
904
+ {
905
+ readonly name: "Cox Webmail";
906
+ readonly mx: ".cloudfilter.net";
907
+ },
908
+ {
909
+ readonly name: "Fastmail";
910
+ readonly mx: ".messagingengine.com";
911
+ },
912
+ {
913
+ readonly name: "Mailgun";
914
+ readonly mx: ".mailgun.org";
915
+ },
916
+ {
917
+ readonly name: "Postmark";
918
+ readonly mx: ".pmta.postmarkapp.com";
919
+ },
920
+ {
921
+ readonly name: "SendGrid";
922
+ readonly mx: ".sendgrid.net";
923
+ },
924
+ {
925
+ readonly name: "Elastic Email";
926
+ readonly mx: ".elasticemail.com";
927
+ },
928
+ {
929
+ readonly name: "Zendesk";
930
+ readonly mx: ".zendesk.com";
931
+ },
932
+ {
933
+ readonly name: "Intermedia";
934
+ readonly mx: ".intermedia.net";
935
+ },
936
+ {
937
+ readonly name: "Mailjet";
938
+ readonly mx: ".mailjet.com";
939
+ },
940
+ {
941
+ readonly name: "Front";
942
+ readonly mx: ".frontapp.com";
943
+ },
944
+ {
945
+ readonly name: "Unknown";
946
+ readonly mx: "..................";
947
+ },
948
+ {
949
+ readonly name: "Webmail";
950
+ readonly mx: "..................";
951
+ },
952
+ {
953
+ readonly name: "Zimbra";
954
+ readonly mx: "..................";
955
+ },
956
+ {
957
+ readonly name: "Others";
958
+ readonly mx: "..................";
959
+ },
960
+ {
961
+ readonly name: "Aruba";
962
+ readonly mx: "..................";
963
+ },
964
+ {
965
+ readonly name: "Alibaba";
966
+ readonly mx: "..................";
967
+ },
968
+ {
969
+ readonly name: "IBM";
970
+ readonly mx: "..................";
971
+ },
972
+ {
973
+ readonly name: "Digitalocean";
974
+ readonly mx: "..................";
975
+ },
976
+ {
977
+ readonly name: "AWS Partner";
978
+ readonly mx: "..................";
979
+ },
980
+ {
981
+ readonly name: "Microsoft Exchange";
982
+ readonly mx: "..................";
983
+ },
984
+ {
985
+ readonly name: "Oracle Cloud";
986
+ readonly mx: "..................";
987
+ },
988
+ {
989
+ readonly name: "Roundcube Webmail";
990
+ readonly mx: "..................";
991
+ },
992
+ {
993
+ readonly name: "cPanel Webmail";
994
+ readonly mx: "..................";
995
+ },
996
+ {
997
+ readonly name: "Yahoo (External Provider)";
998
+ readonly mx: "..................";
999
+ }
1000
+ ];
1001
+ type ProviderName$1 = typeof records[number]["name"];
1002
+ export interface ValidationConfig {
1003
+ /**
1004
+ * @description This will enable deep validation of the email. slower than normal email validator as it triggers multiple dns requests, or travel to the ip address to get the domain name.
1005
+ * This is per request option, passing true to the getProvider without turning this ON, it wont work and vice versa.
1006
+ * @default false
1007
+ */
1008
+ enableDeepValidation?: boolean;
1009
+ /**
1010
+ * @description This will enable the ipResolver for the email validator on deep validation.
1011
+ * @default undefined
1012
+ */
1013
+ ipResolver?: {
1014
+ /**
1015
+ * @description Get your free api keys from https://findip.net to use find-api as a fallback for ipApi if enabled
1016
+ * @default undefined
1017
+ */
1018
+ findip?: {
1019
+ enabled: boolean;
1020
+ apiKey: string[];
1021
+ };
1022
+ /**
1023
+ * @description This is 100% but might throagth that's why we have a fallback to findip.net
1024
+ * if you want to use this feature, change to true enable it
1025
+ * @default false
1026
+ */
1027
+ ipApi?: boolean;
1028
+ };
1029
+ }
1030
+ export declare class EmailValidator {
1031
+ private resolver;
1032
+ private findIpKeys;
1033
+ private rejectList;
1034
+ private roles;
1035
+ private records;
1036
+ private yahooList;
1037
+ private domain;
1038
+ private IpInfo;
1039
+ private static instance;
1040
+ private dns;
1041
+ private validationConfig;
1042
+ private constructor();
1043
+ static create(config?: ValidationConfig, dnsConfig?: YqConfig): EmailValidator;
1044
+ private getMxRecords;
1045
+ /**
1046
+ * Validates an email address and determines its provider/service
1047
+ * @param email - The email address to validate and analyze
1048
+ * @returns Promise resolving to EmailResponse containing validation status and provider details
1049
+ * @throws Error if email validation fails
1050
+ * @example
1051
+ * const validator = EmailValidator.create();
1052
+ * const result = await validator.validate("user@gmail.com");
1053
+ */
1054
+ validate(email: string): Promise<EmailResponse>;
1055
+ /**
1056
+ * Validates an email address with deep validation and determines its provider/service
1057
+ * @param email - The email address to validate and analyze
1058
+ * @param deep - Set to true to enable deep validation with additional DNS lookups
1059
+ * @returns Promise resolving to EmailResponse containing validation status and provider details
1060
+ * @throws Error if email validation fails
1061
+ * @remarks Deep validation performs additional DNS lookups and domain checks which may be slower
1062
+ * @example
1063
+ * const validator = EmailValidator.create();
1064
+ * const result = await validator.getProvider("user@company.com", true);
1065
+ */
1066
+ validate(email: string, deep: true): Promise<EmailResponse>;
1067
+ private is_wale4r_zimbra;
1068
+ private is_zimbra;
1069
+ private is_webmail;
1070
+ private is_owa;
1071
+ private is_cPanel;
1072
+ private toToken;
1073
+ private parseJSCpanel;
1074
+ private is_Roundcube;
1075
+ protected domain_check(email?: string, direct?: boolean, pattern?: number): Promise<{
1076
+ status: boolean;
1077
+ type: string;
1078
+ webmail?: string;
1079
+ }>;
1080
+ private resolveA;
1081
+ private dnsLookup;
1082
+ private returnDNS;
1083
+ protected ipApi(ip: string): Promise<IPResponseData | null>;
1084
+ protected findIp(ip: string): Promise<IPResponseDataFindIp | null>;
1085
+ isEmail(email: string): boolean;
1086
+ private is_email;
1087
+ }
1088
+ export type IPResponseData = {
1089
+ status: string;
1090
+ continent: string;
1091
+ continentCode: string;
1092
+ country: string;
1093
+ countryCode: string;
1094
+ region: string;
1095
+ regionName: string;
1096
+ city: string;
1097
+ zip: string;
1098
+ lat: number;
1099
+ lon: number;
1100
+ timezone: string;
1101
+ currency: string;
1102
+ isp: string;
1103
+ org: string;
1104
+ as: string;
1105
+ reverse: string;
1106
+ mobile: boolean;
1107
+ proxy: boolean;
1108
+ hosting: boolean;
1109
+ query: string;
1110
+ };
1111
+ export type IPResponseDataFindIp = {
1112
+ city: {
1113
+ geoname_id: number;
1114
+ names: {
1115
+ de: string;
1116
+ en: string;
1117
+ es: string;
1118
+ fa: string;
1119
+ fr: string;
1120
+ ja: string;
1121
+ ko: string;
1122
+ "pt-BR": string;
1123
+ ru: string;
1124
+ "zh-CN": string;
1125
+ };
1126
+ };
1127
+ continent: {
1128
+ code: string;
1129
+ geoname_id: number;
1130
+ names: {
1131
+ de: string;
1132
+ en: string;
1133
+ es: string;
1134
+ fa: string;
1135
+ fr: string;
1136
+ ja: string;
1137
+ ko: string;
1138
+ "pt-BR": string;
1139
+ ru: string;
1140
+ "zh-CN": string;
1141
+ };
1142
+ };
1143
+ country: {
1144
+ geoname_id: number;
1145
+ is_in_european_union: boolean;
1146
+ iso_code: string;
1147
+ names: {
1148
+ de: string;
1149
+ en: string;
1150
+ es: string;
1151
+ fa: string;
1152
+ fr: string;
1153
+ ja: string;
1154
+ ko: string;
1155
+ "pt-BR": string;
1156
+ ru: string;
1157
+ "zh-CN": string;
1158
+ };
1159
+ };
1160
+ location: {
1161
+ latitude: number;
1162
+ longitude: number;
1163
+ time_zone: string;
1164
+ weather_code: string;
1165
+ };
1166
+ subdivisions: Array<{
1167
+ geoname_id: number;
1168
+ iso_code?: string;
1169
+ names: {
1170
+ en: string;
1171
+ };
1172
+ }>;
1173
+ traits: {
1174
+ autonomous_system_number: number;
1175
+ autonomous_system_organization: string;
1176
+ connection_type: string;
1177
+ isp: string;
1178
+ user_type: string;
1179
+ };
1180
+ };
1181
+ export interface Valid {
1182
+ success: true;
1183
+ data: {
1184
+ provider: ProviderName$1;
1185
+ email: string;
1186
+ role: boolean;
1187
+ webmail?: string;
1188
+ };
1189
+ }
1190
+ export interface Invalid {
1191
+ success: false;
1192
+ type: "Invalid";
1193
+ email: string;
1194
+ }
1195
+ export interface Rejected {
1196
+ success: false;
1197
+ type: "Rejected";
1198
+ email: string;
1199
+ }
1200
+ export interface Syntanx {
1201
+ success: false;
1202
+ type: "Syntanx";
1203
+ email: string;
1204
+ }
1205
+ interface Error$1 {
1206
+ success: false;
1207
+ type: "Error";
1208
+ email: string;
1209
+ message: string;
1210
+ }
1211
+ export type EmailResponse = Valid | Invalid | Rejected | Syntanx | Error$1;
1212
+ /**
1213
+ * Main DNS resolver class that aggregates multiple DNS providers.
1214
+ */
1215
+ export declare class YqDns {
1216
+ private providers;
1217
+ private static __emailValidator;
1218
+ /**
1219
+ * Creates a new YqDns resolver instance.
1220
+ * @param config - Configuration for all providers
1221
+ * @example
1222
+ * ```typescript
1223
+ * const dns = new YqDns({
1224
+ * google: { enabled: true, limit: { concurrency: 10 } },
1225
+ * cloudflare: { enabled: false }
1226
+ * });
1227
+ * ```
1228
+ */
1229
+ constructor(config?: YqConfig);
1230
+ static createEmailValidator(config?: ValidationConfig, dnsConfig?: YqConfig): EmailValidator;
1231
+ static get emailValidator(): EmailValidator;
1232
+ /**
1233
+ * Initializes all DNS providers with their configurations.
1234
+ */
1235
+ private initializeProviders;
1236
+ /**
1237
+ * Sets configuration for a specific provider.
1238
+ * @param provider - The provider name
1239
+ * @param config - The provider configuration
1240
+ * @throws {InvalidProviderError} If the provider name is invalid
1241
+ * @example
1242
+ * ```typescript
1243
+ * dns.setConfig('google', { enabled: true, limit: { concurrency: 15 } });
1244
+ * ```
1245
+ */
1246
+ setConfig(provider: string, config: ProviderConfig): void;
1247
+ /**
1248
+ * Sets configurations for all providers.
1249
+ * @param config - Configuration object for all providers
1250
+ * @example
1251
+ * ```typescript
1252
+ * dns.setConfigs({
1253
+ * native: { enabled: true },
1254
+ * google: { enabled: true, limit: { concurrency: 10 } },
1255
+ * cloudflare: { enabled: false },
1256
+ * quad9: { enabled: true }
1257
+ * });
1258
+ * ```
1259
+ */
1260
+ setConfigs(config: YqConfig): void;
1261
+ /**
1262
+ * Validates if a provider name is valid.
1263
+ */
1264
+ private isValidProvider;
1265
+ /**
1266
+ * Validates hostname format.
1267
+ */
1268
+ private validateHostname;
1269
+ /**
1270
+ * Gets all enabled providers.
1271
+ */
1272
+ private getEnabledProviders;
1273
+ /**
1274
+ * Selects a random enabled provider, preferring non-full queues.
1275
+ */
1276
+ private selectProvider;
1277
+ private rnd;
1278
+ /**
1279
+ * Gets a provider instance by name.
1280
+ */
1281
+ private getProvider;
1282
+ /**
1283
+ * Resolves A records for a hostname.
1284
+ * @param hostname - The hostname to resolve
1285
+ * @param options - Optional resolution options
1286
+ * @param provider - Optional specific provider to use (e.g., 'google', 'cloudflare')
1287
+ * @returns A promise resolving to an array of IPv4 addresses or records with TTL
1288
+ * @throws {InvalidHostnameError} If the hostname is invalid
1289
+ * @throws {NoEnabledProvidersError} If no providers are enabled
1290
+ * @example
1291
+ * ```typescript
1292
+ * const addresses = await dns.resolve4('example.com');
1293
+ * console.log(addresses); // ['93.184.216.34']
1294
+ *
1295
+ * const withTtl = await dns.resolve4('example.com', { ttl: true });
1296
+ * console.log(withTtl); // [{ address: '93.184.216.34', ttl: 300 }]
1297
+ * ```
1298
+ */
1299
+ resolve4: IResolver["resolve4"];
1300
+ /**
1301
+ * Resolves AAAA records for a hostname.
1302
+ * @param hostname - The hostname to resolve
1303
+ * @param options - Optional resolution options
1304
+ * @param provider - Optional specific provider to use
1305
+ * @returns A promise resolving to an array of IPv6 addresses or records with TTL
1306
+ * @throws {InvalidHostnameError} If the hostname is invalid
1307
+ * @throws {NoEnabledProvidersError} If no providers are enabled
1308
+ * @example
1309
+ * ```typescript
1310
+ * const addresses = await dns.resolve6('example.com');
1311
+ * console.log(addresses); // ['2606:2800:220:1:248:1893:25c8:1946']
1312
+ * ```
1313
+ */
1314
+ resolve6: IResolver["resolve6"];
1315
+ /**
1316
+ * Resolves ANY records for a hostname.
1317
+ * @param hostname - The hostname to resolve
1318
+ * @param provider - Optional specific provider to use
1319
+ * @returns A promise resolving to an array of any DNS records
1320
+ * @throws {InvalidHostnameError} If the hostname is invalid
1321
+ * @throws {NoEnabledProvidersError} If no providers are enabled
1322
+ * @example
1323
+ * ```typescript
1324
+ * const records = await dns.resolveAny('example.com');
1325
+ * console.log(records); // [{ type: 'A', address: '93.184.216.34' }, ...]
1326
+ * ```
1327
+ */
1328
+ resolveAny: IResolver["resolveAny"];
1329
+ /**
1330
+ * Resolves CAA records for a hostname.
1331
+ * @param hostname - The hostname to resolve
1332
+ * @param provider - Optional specific provider to use
1333
+ * @returns A promise resolving to an array of CAA records
1334
+ * @throws {InvalidHostnameError} If the hostname is invalid
1335
+ * @throws {NoEnabledProvidersError} If no providers are enabled
1336
+ */
1337
+ resolveCaa(hostname: string, provider?: string): Promise<CaaRecord[]>;
1338
+ /**
1339
+ * Resolves CNAME records for a hostname.
1340
+ * @param hostname - The hostname to resolve
1341
+ * @param provider - Optional specific provider to use
1342
+ * @returns A promise resolving to an array of CNAME records
1343
+ * @throws {InvalidHostnameError} If the hostname is invalid
1344
+ * @throws {NoEnabledProvidersError} If no providers are enabled
1345
+ */
1346
+ resolveCname: IResolver["resolveCname"];
1347
+ /**
1348
+ * Resolves MX records for a hostname.
1349
+ * @param hostname - The hostname to resolve
1350
+ * @param provider - Optional specific provider to use
1351
+ * @returns A promise resolving to an array of MX records
1352
+ * @throws {InvalidHostnameError} If the hostname is invalid
1353
+ * @throws {NoEnabledProvidersError} If no providers are enabled
1354
+ * @example
1355
+ * ```typescript
1356
+ * const mxRecords = await dns.resolveMx('example.com');
1357
+ * console.log(mxRecords); // [{ priority: 10, exchange: 'mail.example.com' }]
1358
+ * ```
1359
+ */
1360
+ resolveMx: IResolver["resolveMx"];
1361
+ /**
1362
+ * Resolves NAPTR records for a hostname.
1363
+ * @param hostname - The hostname to resolve
1364
+ * @param provider - Optional specific provider to use
1365
+ * @returns A promise resolving to an array of NAPTR records
1366
+ * @throws {InvalidHostnameError} If the hostname is invalid
1367
+ * @throws {NoEnabledProvidersError} If no providers are enabled
1368
+ */
1369
+ resolveNaptr: IResolver["resolveNaptr"];
1370
+ /**
1371
+ * Resolves NS records for a hostname.
1372
+ * @param hostname - The hostname to resolve
1373
+ * @param provider - Optional specific provider to use
1374
+ * @returns A promise resolving to an array of NS records
1375
+ * @throws {InvalidHostnameError} If the hostname is invalid
1376
+ * @throws {NoEnabledProvidersError} If no providers are enabled
1377
+ */
1378
+ resolveNs: IResolver["resolveNs"];
1379
+ /**
1380
+ * Resolves PTR records for an IP address.
1381
+ * @param ip - The IP address to resolve
1382
+ * @param provider - Optional specific provider to use
1383
+ * @returns A promise resolving to an array of PTR records
1384
+ * @throws {InvalidHostnameError} If the IP address is invalid
1385
+ * @throws {NoEnabledProvidersError} If no providers are enabled
1386
+ */
1387
+ resolvePtr: IResolver["resolvePtr"];
1388
+ /**
1389
+ * Resolves SOA record for a hostname.
1390
+ * @param hostname - The hostname to resolve
1391
+ * @param provider - Optional specific provider to use
1392
+ * @returns A promise resolving to the SOA record
1393
+ * @throws {InvalidHostnameError} If the hostname is invalid
1394
+ * @throws {NoEnabledProvidersError} If no providers are enabled
1395
+ */
1396
+ resolveSoa: IResolver["resolveSoa"];
1397
+ /**
1398
+ * Resolves SRV records for a hostname.
1399
+ * @param hostname - The hostname to resolve
1400
+ * @param provider - Optional specific provider to use
1401
+ * @returns A promise resolving to an array of SRV records
1402
+ * @throws {InvalidHostnameError} If the hostname is invalid
1403
+ * @throws {NoEnabledProvidersError} If no providers are enabled
1404
+ */
1405
+ resolveSrv: IResolver["resolveSrv"];
1406
+ /**
1407
+ * Resolves TLSA records for a hostname.
1408
+ * @param hostname - The hostname to resolve
1409
+ * @param provider - Optional specific provider to use
1410
+ * @returns A promise resolving to an array of TLSA records
1411
+ * @throws {InvalidHostnameError} If the hostname is invalid
1412
+ * @throws {NoEnabledProvidersError} If no providers are enabled
1413
+ */
1414
+ resolveTlsa: IResolver["resolveTlsa"];
1415
+ /**
1416
+ * Resolves TXT records for a hostname.
1417
+ * @param hostname - The hostname to resolve
1418
+ * @param provider - Optional specific provider to use
1419
+ * @returns A promise resolving to an array of TXT records
1420
+ * @throws {InvalidHostnameError} If the hostname is invalid
1421
+ * @throws {NoEnabledProvidersError} If no providers are enabled
1422
+ * @example
1423
+ * ```typescript
1424
+ * const txtRecords = await dns.resolveTxt('example.com');
1425
+ * console.log(txtRecords); // [['v=spf1 include:_spf.example.com ~all']]
1426
+ * ```
1427
+ */
1428
+ resolveTxt: IResolver["resolveTxt"];
1429
+ /**
1430
+ * Performs reverse DNS lookup for an IP address.
1431
+ * @param ip - The IP address to reverse lookup
1432
+ * @param provider - Optional specific provider to use
1433
+ * @returns A promise resolving to an array of hostnames
1434
+ * @throws {InvalidHostnameError} If the IP address is invalid
1435
+ * @throws {NoEnabledProvidersError} If no providers are enabled
1436
+ * @example
1437
+ * ```typescript
1438
+ * const hostnames = await dns.reverse('8.8.8.8');
1439
+ * console.log(hostnames); // ['dns.google.']
1440
+ * ```
1441
+ */
1442
+ reverse: IResolver["reverse"];
1443
+ /**
1444
+ * Generic resolve method that delegates to specific resolve methods.
1445
+ * @param hostname - The hostname to resolve
1446
+ * @param rrtype - The DNS record type
1447
+ * @param provider - Optional specific provider to use
1448
+ * @returns A promise resolving to DNS records of the specified type
1449
+ * @throws {InvalidHostnameError} If the hostname is invalid
1450
+ * @throws {NoEnabledProvidersError} If no providers are enabled
1451
+ * @example
1452
+ * ```typescript
1453
+ * const aRecords = await dns.resolve('example.com', 'A');
1454
+ * const mxRecords = await dns.resolve('example.com', 'MX');
1455
+ * ```
1456
+ */
1457
+ resolve: IResolver["resolve"];
1458
+ }
1459
+ /**
1460
+ * Resets the default resolver instance.
1461
+ * This is useful for testing or when you want to change the default configuration.
1462
+ */
1463
+ export declare const resetDefaultResolver: () => void;
1464
+ /**
1465
+ * Sets a custom default resolver instance.
1466
+ * @param resolver - The YqDns instance to use as default
1467
+ */
1468
+ export declare const setDefaultResolver: (resolver: YqDns) => void;
1469
+ /**
1470
+ * Resolves A records for a hostname using the default resolver.
1471
+ * @param hostname - The hostname to resolve
1472
+ * @param options - Optional resolution options
1473
+ * @param provider - Optional specific provider to use
1474
+ * @returns A promise resolving to an array of IPv4 addresses or records with TTL
1475
+ * @example
1476
+ * ```typescript
1477
+ * import { resolve4 } from 'yq-dns';
1478
+ *
1479
+ * const addresses = await resolve4('example.com');
1480
+ * console.log(addresses); // ['93.184.216.34']
1481
+ *
1482
+ * const withTtl = await resolve4('example.com', { ttl: true });
1483
+ * console.log(withTtl); // [{ address: '93.184.216.34', ttl: 300 }]
1484
+ * ```
1485
+ */
1486
+ export declare const resolve4: IResolver["resolve4"];
1487
+ /**
1488
+ * Resolves AAAA records for a hostname using the default resolver.
1489
+ * @param hostname - The hostname to resolve
1490
+ * @param options - Optional resolution options
1491
+ * @param provider - Optional specific provider to use
1492
+ * @returns A promise resolving to an array of IPv6 addresses or records with TTL
1493
+ * @example
1494
+ * ```typescript
1495
+ * import { resolve6 } from 'yq-dns';
1496
+ *
1497
+ * const addresses = await resolve6('example.com');
1498
+ * console.log(addresses); // ['2606:2800:220:1:248:1893:25c8:1946']
1499
+ * ```
1500
+ */
1501
+ export declare const resolve6: IResolver["resolve6"];
1502
+ /**
1503
+ * Resolves ANY records for a hostname using the default resolver.
1504
+ * @param hostname - The hostname to resolve
1505
+ * @param provider - Optional specific provider to use
1506
+ * @returns A promise resolving to an array of any DNS records
1507
+ * @example
1508
+ * ```typescript
1509
+ * import { resolveAny } from 'yq-dns';
1510
+ *
1511
+ * const records = await resolveAny('example.com');
1512
+ * console.log(records); // [{ type: 'A', address: '93.184.216.34' }, ...]
1513
+ * ```
1514
+ */
1515
+ export declare const resolveAny: IResolver["resolveAny"];
1516
+ /**
1517
+ * Resolves CAA records for a hostname using the default resolver.
1518
+ * @param hostname - The hostname to resolve
1519
+ * @param provider - Optional specific provider to use
1520
+ * @returns A promise resolving to an array of CAA records
1521
+ */
1522
+ export declare const resolveCaa: IResolver["resolveCaa"];
1523
+ /**
1524
+ * Resolves CNAME records for a hostname using the default resolver.
1525
+ * @param hostname - The hostname to resolve
1526
+ * @param provider - Optional specific provider to use
1527
+ * @returns A promise resolving to an array of CNAME records
1528
+ */
1529
+ export declare const resolveCname: IResolver["resolveCname"];
1530
+ /**
1531
+ * Resolves MX records for a hostname using the default resolver.
1532
+ * @param hostname - The hostname to resolve
1533
+ * @param provider - Optional specific provider to use
1534
+ * @returns A promise resolving to an array of MX records
1535
+ * @example
1536
+ * ```typescript
1537
+ * import { resolveMx } from 'yq-dns';
1538
+ *
1539
+ * const mxRecords = await resolveMx('example.com');
1540
+ * console.log(mxRecords); // [{ priority: 10, exchange: 'mail.example.com' }]
1541
+ * ```
1542
+ */
1543
+ export declare const resolveMx: IResolver["resolveMx"];
1544
+ /**
1545
+ * Resolves NAPTR records for a hostname using the default resolver.
1546
+ * @param hostname - The hostname to resolve
1547
+ * @param provider - Optional specific provider to use
1548
+ * @returns A promise resolving to an array of NAPTR records
1549
+ */
1550
+ export declare const resolveNaptr: IResolver["resolveNaptr"];
1551
+ /**
1552
+ * Resolves NS records for a hostname using the default resolver.
1553
+ * @param hostname - The hostname to resolve
1554
+ * @param provider - Optional specific provider to use
1555
+ * @returns A promise resolving to an array of NS records
1556
+ */
1557
+ export declare const resolveNs: IResolver["resolveNs"];
1558
+ export declare const resolvePtr: IResolver["resolvePtr"];
1559
+ export declare const resolveSoa: IResolver["resolveSoa"];
1560
+ export declare const resolveSrv: IResolver["resolveSrv"];
1561
+ /**
1562
+ * Resolves TLSA records for a hostname using the default resolver.
1563
+ * @param hostname - The hostname to resolve
1564
+ * @param provider - Optional specific provider to use
1565
+ * @returns A promise resolving to an array of TLSA records
1566
+ */
1567
+ export declare const resolveTlsa: IResolver["resolveTlsa"];
1568
+ /**
1569
+ * Resolves TXT records for a hostname using the default resolver.
1570
+ * @param hostname - The hostname to resolve
1571
+ * @param provider - Optional specific provider to use
1572
+ * @returns A promise resolving to an array of TXT records
1573
+ * @example
1574
+ * ```typescript
1575
+ * import { resolveTxt } from 'yq-dns';
1576
+ *
1577
+ * const txtRecords = await resolveTxt('example.com');
1578
+ * console.log(txtRecords); // [['v=spf1 include:_spf.example.com ~all']]
1579
+ * ```
1580
+ */
1581
+ export declare const resolveTxt: IResolver["resolveTxt"];
1582
+ /**
1583
+ * Performs reverse DNS lookup for an IP address using the default resolver.
1584
+ * @param ip - The IP address to reverse lookup
1585
+ * @param provider - Optional specific provider to use
1586
+ * @returns A promise resolving to an array of hostnames
1587
+ * @example
1588
+ * ```typescript
1589
+ * import { reverse } from 'yq-dns';
1590
+ *
1591
+ * const hostnames = await reverse('8.8.8.8');
1592
+ * console.log(hostnames); // ['dns.google.']
1593
+ * ```
1594
+ */
1595
+ export declare const reverse: IResolver["reverse"];
1596
+ export declare const resolve: IResolver["resolve"];
1597
+
1598
+ export {
1599
+ CaaRecord,
1600
+ MxRecord,
1601
+ NaptrRecord,
1602
+ RecordWithTtl,
1603
+ ResolveOptions,
1604
+ ResolveWithTtlOptions,
1605
+ SoaRecord,
1606
+ SrvRecord,
1607
+ TlsaRecord,
1608
+ YqDns as default,
1609
+ };
1610
+
1611
+ export {};