@helia/ipns 6.0.0 → 6.0.1-2c71b6e

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 (54) hide show
  1. package/README.md +16 -1
  2. package/dist/index.min.js +5 -5
  3. package/dist/src/dnslink.d.ts +5 -0
  4. package/dist/src/dnslink.d.ts.map +1 -0
  5. package/dist/src/dnslink.js +123 -0
  6. package/dist/src/dnslink.js.map +1 -0
  7. package/dist/src/index.d.ts +18 -22
  8. package/dist/src/index.d.ts.map +1 -1
  9. package/dist/src/index.js +10 -9
  10. package/dist/src/index.js.map +1 -1
  11. package/package.json +14 -18
  12. package/src/dnslink.ts +142 -0
  13. package/src/index.ts +30 -38
  14. package/dist/src/dns-resolvers/default.d.ts +0 -3
  15. package/dist/src/dns-resolvers/default.d.ts.map +0 -1
  16. package/dist/src/dns-resolvers/default.js +0 -8
  17. package/dist/src/dns-resolvers/default.js.map +0 -1
  18. package/dist/src/dns-resolvers/dns-json-over-https.d.ts +0 -18
  19. package/dist/src/dns-resolvers/dns-json-over-https.d.ts.map +0 -1
  20. package/dist/src/dns-resolvers/dns-json-over-https.js +0 -72
  21. package/dist/src/dns-resolvers/dns-json-over-https.js.map +0 -1
  22. package/dist/src/dns-resolvers/dns-over-https.d.ts +0 -16
  23. package/dist/src/dns-resolvers/dns-over-https.d.ts.map +0 -1
  24. package/dist/src/dns-resolvers/dns-over-https.js +0 -123
  25. package/dist/src/dns-resolvers/dns-over-https.js.map +0 -1
  26. package/dist/src/dns-resolvers/index.d.ts +0 -3
  27. package/dist/src/dns-resolvers/index.d.ts.map +0 -1
  28. package/dist/src/dns-resolvers/index.js +0 -3
  29. package/dist/src/dns-resolvers/index.js.map +0 -1
  30. package/dist/src/dns-resolvers/resolver.browser.d.ts +0 -4
  31. package/dist/src/dns-resolvers/resolver.browser.d.ts.map +0 -1
  32. package/dist/src/dns-resolvers/resolver.browser.js +0 -39
  33. package/dist/src/dns-resolvers/resolver.browser.js.map +0 -1
  34. package/dist/src/dns-resolvers/resolver.d.ts +0 -4
  35. package/dist/src/dns-resolvers/resolver.d.ts.map +0 -1
  36. package/dist/src/dns-resolvers/resolver.js +0 -21
  37. package/dist/src/dns-resolvers/resolver.js.map +0 -1
  38. package/dist/src/utils/dns.d.ts +0 -35
  39. package/dist/src/utils/dns.d.ts.map +0 -1
  40. package/dist/src/utils/dns.js +0 -79
  41. package/dist/src/utils/dns.js.map +0 -1
  42. package/dist/src/utils/tlru.d.ts +0 -15
  43. package/dist/src/utils/tlru.d.ts.map +0 -1
  44. package/dist/src/utils/tlru.js +0 -40
  45. package/dist/src/utils/tlru.js.map +0 -1
  46. package/dist/typedoc-urls.json +0 -44
  47. package/src/dns-resolvers/default.ts +0 -9
  48. package/src/dns-resolvers/dns-json-over-https.ts +0 -90
  49. package/src/dns-resolvers/dns-over-https.ts +0 -146
  50. package/src/dns-resolvers/index.ts +0 -2
  51. package/src/dns-resolvers/resolver.browser.ts +0 -50
  52. package/src/dns-resolvers/resolver.ts +0 -25
  53. package/src/utils/dns.ts +0 -126
  54. package/src/utils/tlru.ts +0 -52
package/src/index.ts CHANGED
@@ -235,13 +235,13 @@ import { ipnsSelector } from 'ipns/selector'
235
235
  import { ipnsValidator } from 'ipns/validator'
236
236
  import { CID } from 'multiformats/cid'
237
237
  import { CustomProgressEvent } from 'progress-events'
238
- import { defaultResolver } from './dns-resolvers/default.js'
238
+ import { resolveDNSLink } from './dnslink.js'
239
239
  import { helia } from './routing/helia.js'
240
240
  import { localStore, type LocalStore } from './routing/local-store.js'
241
241
  import type { IPNSRouting, IPNSRoutingEvents } from './routing/index.js'
242
- import type { DNSResponse } from './utils/dns.js'
243
242
  import type { Routing } from '@helia/interface'
244
- import type { AbortOptions, PeerId } from '@libp2p/interface'
243
+ import type { AbortOptions, ComponentLogger, Logger, PeerId } from '@libp2p/interface'
244
+ import type { DNS, ResolveDnsProgressEvents } from '@multiformats/dns'
245
245
  import type { Datastore } from 'interface-datastore'
246
246
  import type { IPNSRecord } from 'ipns'
247
247
  import type { ProgressEvent, ProgressOptions } from 'progress-events'
@@ -269,10 +269,10 @@ export type RepublishProgressEvents =
269
269
  ProgressEvent<'ipns:republish:success', IPNSRecord> |
270
270
  ProgressEvent<'ipns:republish:error', { record: IPNSRecord, err: Error }>
271
271
 
272
- export type ResolveDnsLinkProgressEvents =
273
- ProgressEvent<'dnslink:cache', string> |
274
- ProgressEvent<'dnslink:query', string> |
275
- ProgressEvent<'dnslink:answer', DNSResponse>
272
+ export type ResolveDNSLinkProgressEvents =
273
+ ResolveProgressEvents |
274
+ IPNSRoutingEvents |
275
+ ResolveDnsProgressEvents
276
276
 
277
277
  export interface PublishOptions extends AbortOptions, ProgressOptions<PublishProgressEvents | IPNSRoutingEvents> {
278
278
  /**
@@ -299,35 +299,28 @@ export interface ResolveOptions extends AbortOptions, ProgressOptions<ResolvePro
299
299
  offline?: boolean
300
300
  }
301
301
 
302
- export interface ResolveDnsLinkOptions extends AbortOptions, ProgressOptions<ResolveDnsLinkProgressEvents> {
302
+ export interface ResolveDNSLinkOptions extends AbortOptions, ProgressOptions<ResolveDNSLinkProgressEvents> {
303
303
  /**
304
- * Do not use cached DNS entries (default: false)
305
- */
306
- nocache?: boolean
307
- }
308
-
309
- export interface DNSResolver {
310
- (domain: string, options?: ResolveDnsLinkOptions): Promise<string>
311
- }
312
-
313
- export interface ResolveDNSOptions extends AbortOptions, ProgressOptions<ResolveProgressEvents | IPNSRoutingEvents | ResolveDnsLinkProgressEvents> {
314
- /**
315
- * Do not query the network for the IPNS record (default: false)
304
+ * Do not query the network for the IPNS record
305
+ *
306
+ * @default false
316
307
  */
317
308
  offline?: boolean
318
309
 
319
310
  /**
320
- * Do not use cached DNS entries (default: false)
311
+ * Do not use cached DNS entries
312
+ *
313
+ * @default false
321
314
  */
322
315
  nocache?: boolean
323
316
 
324
317
  /**
325
- * These resolvers will be used to resolve the dnslink entries, if unspecified node will
326
- * fall back to the `dns` module and browsers fall back to querying google/cloudflare DoH
318
+ * When resolving DNSLink records that resolve to other DNSLink records, limit
319
+ * how many times we will recursively resolve them.
327
320
  *
328
- * @see https://github.com/ipfs/helia-ipns/pull/55#discussion_r1270096881
321
+ * @default 32
329
322
  */
330
- resolvers?: DNSResolver[]
323
+ maxRecursiveDepth?: number
331
324
  }
332
325
 
333
326
  export interface RepublishOptions extends AbortOptions, ProgressOptions<RepublishProgressEvents | IPNSRoutingEvents> {
@@ -359,7 +352,7 @@ export interface IPNS {
359
352
  /**
360
353
  * Resolve a CID from a dns-link style IPNS record
361
354
  */
362
- resolveDns(domain: string, options?: ResolveDNSOptions): Promise<ResolveResult>
355
+ resolveDNSLink(domain: string, options?: ResolveDNSLinkOptions): Promise<ResolveResult>
363
356
 
364
357
  /**
365
358
  * Periodically republish all IPNS records found in the datastore
@@ -372,21 +365,25 @@ export type { IPNSRouting } from './routing/index.js'
372
365
  export interface IPNSComponents {
373
366
  datastore: Datastore
374
367
  routing: Routing
368
+ dns: DNS
369
+ logger: ComponentLogger
375
370
  }
376
371
 
377
372
  class DefaultIPNS implements IPNS {
378
373
  private readonly routers: IPNSRouting[]
379
374
  private readonly localStore: LocalStore
380
375
  private timeout?: ReturnType<typeof setTimeout>
381
- private readonly defaultResolvers: DNSResolver[]
376
+ private readonly dns: DNS
377
+ private readonly log: Logger
382
378
 
383
- constructor (components: IPNSComponents, routers: IPNSRouting[] = [], resolvers: DNSResolver[] = []) {
379
+ constructor (components: IPNSComponents, routers: IPNSRouting[] = []) {
384
380
  this.routers = [
385
381
  helia(components.routing),
386
382
  ...routers
387
383
  ]
388
384
  this.localStore = localStore(components.datastore)
389
- this.defaultResolvers = resolvers.length > 0 ? resolvers : [defaultResolver()]
385
+ this.dns = components.dns
386
+ this.log = components.logger.forComponent('helia:ipns')
390
387
  }
391
388
 
392
389
  async publish (key: PeerId, value: CID | PeerId | string, options: PublishOptions = {}): Promise<IPNSRecord> {
@@ -426,12 +423,8 @@ class DefaultIPNS implements IPNS {
426
423
  return this.#resolve(record.value, options)
427
424
  }
428
425
 
429
- async resolveDns (domain: string, options: ResolveDNSOptions = {}): Promise<ResolveResult> {
430
- const resolvers = options.resolvers ?? this.defaultResolvers
431
-
432
- const dnslink = await Promise.any(
433
- resolvers.map(async resolver => resolver(domain, options))
434
- )
426
+ async resolveDNSLink (domain: string, options: ResolveDNSLinkOptions = {}): Promise<ResolveResult> {
427
+ const dnslink = await resolveDNSLink(domain, this.dns, this.log, options)
435
428
 
436
429
  return this.#resolve(dnslink, options)
437
430
  }
@@ -564,11 +557,10 @@ class DefaultIPNS implements IPNS {
564
557
 
565
558
  export interface IPNSOptions {
566
559
  routers?: IPNSRouting[]
567
- resolvers?: DNSResolver[]
568
560
  }
569
561
 
570
- export function ipns (components: IPNSComponents, { routers = [], resolvers = [] }: IPNSOptions = {}): IPNS {
571
- return new DefaultIPNS(components, routers, resolvers)
562
+ export function ipns (components: IPNSComponents, { routers = [] }: IPNSOptions = {}): IPNS {
563
+ return new DefaultIPNS(components, routers)
572
564
  }
573
565
 
574
566
  export { ipnsValidator, type IPNSRoutingEvents }
@@ -1,3 +0,0 @@
1
- import type { DNSResolver } from '../index.js';
2
- export declare function defaultResolver(): DNSResolver;
3
- //# sourceMappingURL=default.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../../src/dns-resolvers/default.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAyB,MAAM,aAAa,CAAA;AAErE,wBAAgB,eAAe,IAAK,WAAW,CAI9C"}
@@ -1,8 +0,0 @@
1
- import { MAX_RECURSIVE_DEPTH, recursiveResolveDnslink } from '../utils/dns.js';
2
- import resolve from './resolver.js';
3
- export function defaultResolver() {
4
- return async (domain, options = {}) => {
5
- return recursiveResolveDnslink(domain, MAX_RECURSIVE_DEPTH, resolve, options);
6
- };
7
- }
8
- //# sourceMappingURL=default.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"default.js","sourceRoot":"","sources":["../../../src/dns-resolvers/default.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAA;AAC9E,OAAO,OAAO,MAAM,eAAe,CAAA;AAGnC,MAAM,UAAU,eAAe;IAC7B,OAAO,KAAK,EAAE,MAAc,EAAE,UAAiC,EAAE,EAAmB,EAAE;QACpF,OAAO,uBAAuB,CAAC,MAAM,EAAE,mBAAmB,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;IAC/E,CAAC,CAAA;AACH,CAAC"}
@@ -1,18 +0,0 @@
1
- import type { DNSResolver } from '../index.js';
2
- /**
3
- * Uses the RFC 8427 'application/dns-json' content-type to resolve DNS queries.
4
- *
5
- * Supports and server that uses the same schema as Google's DNS over HTTPS
6
- * resolver.
7
- *
8
- * This resolver needs fewer dependencies than the regular DNS-over-HTTPS
9
- * resolver so can result in a smaller bundle size and consequently is preferred
10
- * for browser use.
11
- *
12
- * @see https://developers.cloudflare.com/1.1.1.1/encryption/dns-over-https/make-api-requests/dns-json/
13
- * @see https://github.com/curl/curl/wiki/DNS-over-HTTPS#publicly-available-servers
14
- * @see https://dnsprivacy.org/public_resolvers/
15
- * @see https://datatracker.ietf.org/doc/html/rfc8427
16
- */
17
- export declare function dnsJsonOverHttps(url: string): DNSResolver;
18
- //# sourceMappingURL=dns-json-over-https.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dns-json-over-https.d.ts","sourceRoot":"","sources":["../../../src/dns-resolvers/dns-json-over-https.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAyB,WAAW,EAAE,MAAM,aAAa,CAAA;AAOrE;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,gBAAgB,CAAE,GAAG,EAAE,MAAM,GAAG,WAAW,CA6D1D"}
@@ -1,72 +0,0 @@
1
- /* eslint-env browser */
2
- import PQueue from 'p-queue';
3
- import { CustomProgressEvent } from 'progress-events';
4
- import { MAX_RECURSIVE_DEPTH, recursiveResolveDnslink, ipfsPathAndAnswer } from '../utils/dns.js';
5
- import { TLRU } from '../utils/tlru.js';
6
- // Avoid sending multiple queries for the same hostname by caching results
7
- const cache = new TLRU(1000);
8
- // This TTL will be used if the remote service does not return one
9
- const ttl = 60 * 1000;
10
- /**
11
- * Uses the RFC 8427 'application/dns-json' content-type to resolve DNS queries.
12
- *
13
- * Supports and server that uses the same schema as Google's DNS over HTTPS
14
- * resolver.
15
- *
16
- * This resolver needs fewer dependencies than the regular DNS-over-HTTPS
17
- * resolver so can result in a smaller bundle size and consequently is preferred
18
- * for browser use.
19
- *
20
- * @see https://developers.cloudflare.com/1.1.1.1/encryption/dns-over-https/make-api-requests/dns-json/
21
- * @see https://github.com/curl/curl/wiki/DNS-over-HTTPS#publicly-available-servers
22
- * @see https://dnsprivacy.org/public_resolvers/
23
- * @see https://datatracker.ietf.org/doc/html/rfc8427
24
- */
25
- export function dnsJsonOverHttps(url) {
26
- // browsers limit concurrent connections per host,
27
- // we don't want preload calls to exhaust the limit (~6)
28
- const httpQueue = new PQueue({ concurrency: 4 });
29
- const resolve = async (fqdn, options = {}) => {
30
- const searchParams = new URLSearchParams();
31
- searchParams.set('name', fqdn);
32
- searchParams.set('type', 'TXT');
33
- const query = searchParams.toString();
34
- // try cache first
35
- if (options.nocache !== true && cache.has(query)) {
36
- const response = cache.get(query);
37
- if (response != null) {
38
- options.onProgress?.(new CustomProgressEvent('dnslink:cache', { detail: response }));
39
- return response;
40
- }
41
- }
42
- options.onProgress?.(new CustomProgressEvent('dnslink:query', { detail: fqdn }));
43
- // query DNS-JSON over HTTPS server
44
- const response = await httpQueue.add(async () => {
45
- const res = await fetch(`${url}?${searchParams}`, {
46
- headers: {
47
- accept: 'application/dns-json'
48
- },
49
- signal: options.signal
50
- });
51
- if (res.status !== 200) {
52
- throw new Error(`Unexpected HTTP status: ${res.status} - ${res.statusText}`);
53
- }
54
- const query = new URL(res.url).search.slice(1);
55
- const json = await res.json();
56
- options.onProgress?.(new CustomProgressEvent('dnslink:answer', { detail: json }));
57
- const { ipfsPath, answer } = ipfsPathAndAnswer(fqdn, json);
58
- cache.set(query, ipfsPath, answer.TTL ?? ttl);
59
- return ipfsPath;
60
- }, {
61
- signal: options.signal
62
- });
63
- if (response == null) {
64
- throw new Error('No DNS response received');
65
- }
66
- return response;
67
- };
68
- return async (domain, options = {}) => {
69
- return recursiveResolveDnslink(domain, MAX_RECURSIVE_DEPTH, resolve, options);
70
- };
71
- }
72
- //# sourceMappingURL=dns-json-over-https.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dns-json-over-https.js","sourceRoot":"","sources":["../../../src/dns-resolvers/dns-json-over-https.ts"],"names":[],"mappings":"AAAA,wBAAwB;AAExB,OAAO,MAAM,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,EAAoB,mBAAmB,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AACnH,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAGvC,0EAA0E;AAC1E,MAAM,KAAK,GAAG,IAAI,IAAI,CAAS,IAAI,CAAC,CAAA;AACpC,kEAAkE;AAClE,MAAM,GAAG,GAAG,EAAE,GAAG,IAAI,CAAA;AAErB;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,gBAAgB,CAAE,GAAW;IAC3C,kDAAkD;IAClD,wDAAwD;IACxD,MAAM,SAAS,GAAG,IAAI,MAAM,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,CAAC,CAAA;IAEhD,MAAM,OAAO,GAAG,KAAK,EAAE,IAAY,EAAE,UAAiC,EAAE,EAAmB,EAAE;QAC3F,MAAM,YAAY,GAAG,IAAI,eAAe,EAAE,CAAA;QAC1C,YAAY,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;QAC9B,YAAY,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,CA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AI,mBAAmB,CAAc,gBAAgB,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;YAE9F,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;YAE1D,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAC,GAAG,IAAI,GAAG,CAAC,CAAA;YAE7C,OAAO,QAAQ,CAAA;QACjB,CAAC,EAAE;YACD,MAAM,EAAE,OAAO,CAAC,MAAM;SACvB,CAAC,CAAA;QAEF,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAC;YACrB,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAA;QAC7C,CAAC;QAED,OAAO,QAAQ,CAAA;IACjB,CAAC,CAAA;IAED,OAAO,KAAK,EAAE,MAAc,EAAE,UAAiC,EAAE,EAAE,EAAE;QACnE,OAAO,uBAAuB,CAAC,MAAM,EAAE,mBAAmB,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;IAC/E,CAAC,CAAA;AACH,CAAC"}
@@ -1,16 +0,0 @@
1
- import type { DNSResolver } from '../index.js';
2
- /**
3
- * Uses the RFC 1035 'application/dns-message' content-type to resolve DNS
4
- * queries.
5
- *
6
- * This resolver needs more dependencies than the non-standard
7
- * DNS-JSON-over-HTTPS resolver so can result in a larger bundle size and
8
- * consequently is not preferred for browser use.
9
- *
10
- * @see https://datatracker.ietf.org/doc/html/rfc1035
11
- * @see https://developers.cloudflare.com/1.1.1.1/encryption/dns-over-https/make-api-requests/dns-wireformat/
12
- * @see https://github.com/curl/curl/wiki/DNS-over-HTTPS#publicly-available-servers
13
- * @see https://dnsprivacy.org/public_resolvers/
14
- */
15
- export declare function dnsOverHttps(url: string): DNSResolver;
16
- //# sourceMappingURL=dns-over-https.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dns-over-https.d.ts","sourceRoot":"","sources":["../../../src/dns-resolvers/dns-over-https.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAyB,WAAW,EAAE,MAAM,aAAa,CAAA;AAOrE;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAAE,GAAG,EAAE,MAAM,GAAG,WAAW,CAwEtD"}
@@ -1,123 +0,0 @@
1
- /* eslint-env browser */
2
- import { Buffer } from 'buffer';
3
- import dnsPacket, {} from 'dns-packet';
4
- import { base64url } from 'multiformats/bases/base64';
5
- import PQueue from 'p-queue';
6
- import { CustomProgressEvent } from 'progress-events';
7
- import { toString as uint8ArrayToString } from 'uint8arrays/to-string';
8
- import { MAX_RECURSIVE_DEPTH, recursiveResolveDnslink, ipfsPathAndAnswer } from '../utils/dns.js';
9
- import { TLRU } from '../utils/tlru.js';
10
- // Avoid sending multiple queries for the same hostname by caching results
11
- const cache = new TLRU(1000);
12
- // This TTL will be used if the remote service does not return one
13
- const ttl = 60 * 1000;
14
- /**
15
- * Uses the RFC 1035 'application/dns-message' content-type to resolve DNS
16
- * queries.
17
- *
18
- * This resolver needs more dependencies than the non-standard
19
- * DNS-JSON-over-HTTPS resolver so can result in a larger bundle size and
20
- * consequently is not preferred for browser use.
21
- *
22
- * @see https://datatracker.ietf.org/doc/html/rfc1035
23
- * @see https://developers.cloudflare.com/1.1.1.1/encryption/dns-over-https/make-api-requests/dns-wireformat/
24
- * @see https://github.com/curl/curl/wiki/DNS-over-HTTPS#publicly-available-servers
25
- * @see https://dnsprivacy.org/public_resolvers/
26
- */
27
- export function dnsOverHttps(url) {
28
- // browsers limit concurrent connections per host,
29
- // we don't want preload calls to exhaust the limit (~6)
30
- const httpQueue = new PQueue({ concurrency: 4 });
31
- const resolve = async (fqdn, options = {}) => {
32
- const dnsQuery = dnsPacket.encode({
33
- type: 'query',
34
- id: 0,
35
- flags: dnsPacket.RECURSION_DESIRED,
36
- questions: [{
37
- type: 'TXT',
38
- name: fqdn
39
- }]
40
- });
41
- const searchParams = new URLSearchParams();
42
- searchParams.set('dns', base64url.encode(dnsQuery).substring(1));
43
- const query = searchParams.toString();
44
- // try cache first
45
- if (options.nocache !== true && cache.has(query)) {
46
- const response = cache.get(query);
47
- if (response != null) {
48
- options.onProgress?.(new CustomProgressEvent('dnslink:cache', { detail: response }));
49
- return response;
50
- }
51
- }
52
- options.onProgress?.(new CustomProgressEvent('dnslink:query', { detail: fqdn }));
53
- // query DNS over HTTPS server
54
- const response = await httpQueue.add(async () => {
55
- const res = await fetch(`${url}?${searchParams}`, {
56
- headers: {
57
- accept: 'application/dns-message'
58
- },
59
- signal: options.signal
60
- });
61
- if (res.status !== 200) {
62
- throw new Error(`Unexpected HTTP status: ${res.status} - ${res.statusText}`);
63
- }
64
- const query = new URL(res.url).search.slice(1);
65
- const buf = await res.arrayBuffer();
66
- // map to expected response format
67
- const json = toDNSResponse(dnsPacket.decode(Buffer.from(buf)));
68
- options.onProgress?.(new CustomProgressEvent('dnslink:answer', { detail: json }));
69
- const { ipfsPath, answer } = ipfsPathAndAnswer(fqdn, json);
70
- cache.set(query, ipfsPath, answer.TTL ?? ttl);
71
- return ipfsPath;
72
- }, {
73
- signal: options.signal
74
- });
75
- if (response == null) {
76
- throw new Error('No DNS response received');
77
- }
78
- return response;
79
- };
80
- return async (domain, options = {}) => {
81
- return recursiveResolveDnslink(domain, MAX_RECURSIVE_DEPTH, resolve, options);
82
- };
83
- }
84
- function toDNSResponse(response) {
85
- const txtType = 16;
86
- return {
87
- Status: 0,
88
- TC: response.flag_tc ?? false,
89
- RD: response.flag_rd ?? false,
90
- RA: response.flag_ra ?? false,
91
- AD: response.flag_ad ?? false,
92
- CD: response.flag_cd ?? false,
93
- Question: response.questions?.map(q => ({
94
- name: q.name,
95
- type: txtType
96
- })) ?? [],
97
- Answer: response.answers?.map(a => {
98
- if (a.type !== 'TXT' || a.data.length < 1) {
99
- return {
100
- name: a.name,
101
- type: txtType,
102
- TTL: 0,
103
- data: 'invalid'
104
- };
105
- }
106
- if (!Buffer.isBuffer(a.data[0])) {
107
- return {
108
- name: a.name,
109
- type: txtType,
110
- TTL: a.ttl ?? ttl,
111
- data: String(a.data[0])
112
- };
113
- }
114
- return {
115
- name: a.name,
116
- type: txtType,
117
- TTL: a.ttl ?? ttl,
118
- data: uint8ArrayToString(a.data[0])
119
- };
120
- }) ?? []
121
- };
122
- }
123
- //# sourceMappingURL=dns-over-https.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dns-over-https.js","sourceRoot":"","sources":["../../../src/dns-resolvers/dns-over-https.ts"],"names":[],"mappings":"AAAA,wBAAwB;AAExB,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,SAAS,EAAE,EAAsB,MAAM,YAAY,CAAA;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AACrD,OAAO,MAAM,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,EAAE,QAAQ,IAAI,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AACtE,OAAO,EAAoB,mBAAmB,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AACnH,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAGvC,0EAA0E;AAC1E,MAAM,KAAK,GAAG,IAAI,IAAI,CAAS,IAAI,CAAC,CAAA;AACpC,kEAAkE;AAClE,MAAM,GAAG,GAAG,EAAE,GAAG,IAAI,CAAA;AAErB;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,YAAY,CAAE,GAAW;IACvC,kDAAkD;IAClD,wDAAwD;IACxD,MAAM,SAAS,GAAG,IAAI,MAAM,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,CAAC,CAAA;IAEhD,MAAM,OAAO,GAAG,KAAK,EAAE,IAAY,EAAE,UAAiC,EAAE,EAAmB,EAAE;QAC3F,MAAM,QAAQ,GAAG,SAAS,CAAC,MAAM,CAAC;YAChC,IAA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E,kBAAkB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;aACpC,CAAA;QACH,CAAC,CAAC,IAAI,EAAE;KACT,CAAA;AACH,CAAC"}
@@ -1,3 +0,0 @@
1
- export { dnsOverHttps } from './dns-over-https.js';
2
- export { dnsJsonOverHttps } from './dns-json-over-https.js';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/dns-resolvers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA"}
@@ -1,3 +0,0 @@
1
- export { dnsOverHttps } from './dns-over-https.js';
2
- export { dnsJsonOverHttps } from './dns-json-over-https.js';
3
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/dns-resolvers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA"}
@@ -1,4 +0,0 @@
1
- import type { DNSResolver } from '../index.js';
2
- declare const resolve: DNSResolver;
3
- export default resolve;
4
- //# sourceMappingURL=resolver.browser.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolver.browser.d.ts","sourceRoot":"","sources":["../../../src/dns-resolvers/resolver.browser.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAW9C,QAAA,MAAM,OAAO,EAAE,WA+Bd,CAAA;AAED,eAAe,OAAO,CAAA"}
@@ -1,39 +0,0 @@
1
- import Resolver from 'dns-over-http-resolver';
2
- import PQueue from 'p-queue';
3
- import { CustomProgressEvent } from 'progress-events';
4
- import { resolveFn } from '../utils/dns.js';
5
- import { TLRU } from '../utils/tlru.js';
6
- const cache = new TLRU(1000);
7
- // We know browsers themselves cache DNS records for at least 1 minute,
8
- // which acts a provisional default ttl: https://stackoverflow.com/a/36917902/11518426
9
- const ttl = 60 * 1000;
10
- // browsers limit concurrent connections per host,
11
- // we don't want to exhaust the limit (~6)
12
- const httpQueue = new PQueue({ concurrency: 4 });
13
- const resolve = async function resolve(domain, options = {}) {
14
- const resolver = new Resolver({ maxCache: 0 });
15
- // try cache first
16
- if (options.nocache !== true && cache.has(domain)) {
17
- const response = cache.get(domain);
18
- if (response != null) {
19
- options?.onProgress?.(new CustomProgressEvent('dnslink:cache', { detail: response }));
20
- return response;
21
- }
22
- }
23
- options.onProgress?.(new CustomProgressEvent('dnslink:query', { detail: domain }));
24
- // Add the query to the queue
25
- const response = await httpQueue.add(async () => {
26
- const dnslinkRecord = await resolveFn(resolver, domain);
27
- options.onProgress?.(new CustomProgressEvent('dnslink:answer', { detail: dnslinkRecord }));
28
- cache.set(domain, dnslinkRecord, ttl);
29
- return dnslinkRecord;
30
- }, {
31
- signal: options?.signal
32
- });
33
- if (response == null) {
34
- throw new Error('No DNS response received');
35
- }
36
- return response;
37
- };
38
- export default resolve;
39
- //# sourceMappingURL=resolver.browser.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolver.browser.js","sourceRoot":"","sources":["../../../src/dns-resolvers/resolver.browser.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,wBAAwB,CAAA;AAC7C,OAAO,MAAM,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,EAAE,SAAS,EAAoB,MAAM,iBAAiB,CAAA;AAC7D,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAGvC,MAAM,KAAK,GAAG,IAAI,IAAI,CAAS,IAAI,CAAC,CAAA;AACpC,uEAAuE;AACvE,sFAAsF;AACtF,MAAM,GAAG,GAAG,EAAE,GAAG,IAAI,CAAA;AAErB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AA;IAEF,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAA;IAC7C,CAAC;IAED,OAAO,QAAQ,CAAA;AACjB,CAAC,CAAA;AAED,eAAe,OAAO,CAAA"}
@@ -1,4 +0,0 @@
1
- import type { DNSResolver } from '../index.js';
2
- declare const resolve: DNSResolver;
3
- export default resolve;
4
- //# sourceMappingURL=resolver.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../../../src/dns-resolvers/resolver.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAE9C,QAAA,MAAM,OAAO,EAAE,WAiBd,CAAA;AAED,eAAe,OAAO,CAAA"}
@@ -1,21 +0,0 @@
1
- import { Resolver } from 'dns/promises';
2
- import { CustomProgressEvent } from 'progress-events';
3
- import { resolveFn } from '../utils/dns.js';
4
- const resolve = async function resolve(domain, options = {}) {
5
- const resolver = new Resolver();
6
- const listener = () => {
7
- resolver.cancel();
8
- };
9
- options.signal?.addEventListener('abort', listener);
10
- try {
11
- options.onProgress?.(new CustomProgressEvent('dnslink:query', { detail: domain }));
12
- const dnslinkRecord = await resolveFn(resolver, domain);
13
- options.onProgress?.(new CustomProgressEvent('dnslink:answer', { detail: dnslinkRecord }));
14
- return dnslinkRecord;
15
- }
16
- finally {
17
- options.signal?.removeEventListener('abort', listener);
18
- }
19
- };
20
- export default resolve;
21
- //# sourceMappingURL=resolver.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolver.js","sourceRoot":"","sources":["../../../src/dns-resolvers/resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AACvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,EAAE,SAAS,EAAoB,MAAM,iBAAiB,CAAA;AAG7D,MAAM,OAAO,GAAgB,KAAK,UAAU,OAAO,CAAE,MAAM,EAAE,OAAO,GAAG,EAAE;IACvE,MAAM,QAAQ,GAAG,IAAI,QAAQ,EAAE,CAAA;IAC/B,MAAM,QAAQ,GAAG,GAAS,EAAE;QAC1B,QAAQ,CAAC,MAAM,EAAE,CAAA;IACnB,CAAC,CAAA;IAED,OAAO,CAAC,MAAM,EAAE,gBAAgB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;IAEnD,IAAI,CAAC;QACH,OAAO,CAAC,UAAU,EAAE,CAAC,IAAI,mBAAmB,CAAS,eAAe,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,CAAA;QAC1F,MAAM,aAAa,GAAG,MAAM,SAAS,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;QAEvD,OAAO,CAAC,UAAU,EAAE,CAAC,IAAI,mBAAmB,CAAc,gBAAgB,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC,CAAC,CAAA;QACvG,OAAO,aAAa,CAAA;IACtB,CAAC;YAAS,CAAC;QACT,OAAO,CAAC,MAAM,EAAE,mBAAmB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;IACxD,CAAC;AACH,CAAC,CAAA;AAED,eAAe,OAAO,CAAA"}
@@ -1,35 +0,0 @@
1
- import type { DNSResolver, ResolveDnsLinkOptions } from '../index.js';
2
- export interface Question {
3
- name: string;
4
- type: number;
5
- }
6
- export interface Answer {
7
- name: string;
8
- type: number;
9
- TTL: number;
10
- data: string;
11
- }
12
- export interface DNSResponse {
13
- Status: number;
14
- TC: boolean;
15
- RD: boolean;
16
- RA: boolean;
17
- AD: boolean;
18
- CD: boolean;
19
- Question: Question[];
20
- Answer?: Answer[];
21
- }
22
- export declare const ipfsPathForAnswer: (answer: Answer) => string;
23
- export declare const ipfsPathAndAnswer: (domain: string, response: DNSResponse) => {
24
- ipfsPath: string;
25
- answer: Answer;
26
- };
27
- export declare const findDNSLinkAnswer: (domain: string, response: DNSResponse) => Answer;
28
- export declare const MAX_RECURSIVE_DEPTH = 32;
29
- export declare const recursiveResolveDnslink: (domain: string, depth: number, resolve: DNSResolver, options?: ResolveDnsLinkOptions) => Promise<string>;
30
- interface DnsResolver {
31
- resolveTxt(domain: string): Promise<string[][]>;
32
- }
33
- export declare const resolveFn: (resolver: DnsResolver, domain: string) => Promise<string>;
34
- export {};
35
- //# sourceMappingURL=dns.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dns.d.ts","sourceRoot":"","sources":["../../../src/utils/dns.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAErE,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAA;IACd,EAAE,EAAE,OAAO,CAAA;IACX,EAAE,EAAE,OAAO,CAAA;IACX,EAAE,EAAE,OAAO,CAAA;IACX,EAAE,EAAE,OAAO,CAAA;IACX,EAAE,EAAE,OAAO,CAAA;IACX,QAAQ,EAAE,QAAQ,EAAE,CAAA;IACpB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;CAClB;AAED,eAAO,MAAM,iBAAiB,WAAY,MAAM,KAAG,MAYlD,CAAA;AAED,eAAO,MAAM,iBAAiB,WAAY,MAAM,YAAY,WAAW;cAAe,MAAM;YAAU,MAAM;CAO3G,CAAA;AAED,eAAO,MAAM,iBAAiB,WAAY,MAAM,YAAY,WAAW,KAAG,MAQzE,CAAA;AAED,eAAO,MAAM,mBAAmB,KAAK,CAAA;AAErC,eAAO,MAAM,uBAAuB,WAAkB,MAAM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