diff --git a/packages/ipns/src/dnslink.ts b/packages/ipns/src/dnslink.ts index 372a6762a..24d71a0aa 100644 --- a/packages/ipns/src/dnslink.ts +++ b/packages/ipns/src/dnslink.ts @@ -2,12 +2,12 @@ import { CodeError, type Logger } from '@libp2p/interface' import { peerIdFromString } from '@libp2p/peer-id' import { RecordType } from '@multiformats/dns' import { CID } from 'multiformats/cid' -import type { ResolveDNSOptions } from './index.js' +import type { ResolveDNSLinkOptions } from './index.js' import type { DNS } from '@multiformats/dns' const MAX_RECURSIVE_DEPTH = 32 -async function recursiveResolveDnslink (domain: string, depth: number, dns: DNS, log: Logger, options: ResolveDNSOptions = {}): Promise { +async function recursiveResolveDnslink (domain: string, depth: number, dns: DNS, log: Logger, options: ResolveDNSLinkOptions = {}): Promise { if (depth === 0) { throw new Error('recursion limit exceeded') } @@ -103,7 +103,7 @@ async function recursiveResolveDnslink (domain: string, depth: number, dns: DNS, throw new CodeError(`No DNSLink records found for domain: ${domain}`, 'ERR_DNSLINK_NOT_FOUND') } -async function recursiveResolveDomain (domain: string, depth: number, dns: DNS, log: Logger, options: ResolveDNSOptions = {}): Promise { +async function recursiveResolveDomain (domain: string, depth: number, dns: DNS, log: Logger, options: ResolveDNSLinkOptions = {}): Promise { if (depth === 0) { throw new Error('recursion limit exceeded') } @@ -137,6 +137,6 @@ async function recursiveResolveDomain (domain: string, depth: number, dns: DNS, } } -export async function resolveDNSLink (domain: string, dns: DNS, log: Logger, options: ResolveDNSOptions = {}): Promise { +export async function resolveDNSLink (domain: string, dns: DNS, log: Logger, options: ResolveDNSLinkOptions = {}): Promise { return recursiveResolveDomain(domain, options.maxRecursiveDepth ?? MAX_RECURSIVE_DEPTH, dns, log, options) } diff --git a/packages/ipns/src/index.ts b/packages/ipns/src/index.ts index 2debde604..72f9013af 100644 --- a/packages/ipns/src/index.ts +++ b/packages/ipns/src/index.ts @@ -241,7 +241,7 @@ import { localStore, type LocalStore } from './routing/local-store.js' import type { IPNSRouting, IPNSRoutingEvents } from './routing/index.js' import type { Routing } from '@helia/interface' import type { AbortOptions, ComponentLogger, Logger, PeerId } from '@libp2p/interface' -import type { DNS, ResolveDnsProgressEvents, DNSResponse } from '@multiformats/dns' +import type { DNS, ResolveDnsProgressEvents } from '@multiformats/dns' import type { Datastore } from 'interface-datastore' import type { IPNSRecord } from 'ipns' import type { ProgressEvent, ProgressOptions } from 'progress-events' @@ -269,10 +269,10 @@ export type RepublishProgressEvents = ProgressEvent<'ipns:republish:success', IPNSRecord> | ProgressEvent<'ipns:republish:error', { record: IPNSRecord, err: Error }> -export type ResolveDnsLinkProgressEvents = - ProgressEvent<'dnslink:cache', string> | - ProgressEvent<'dnslink:query', string> | - ProgressEvent<'dnslink:answer', DNSResponse> +export type ResolveDNSLinkProgressEvents = + ResolveProgressEvents | + IPNSRoutingEvents | + ResolveDnsProgressEvents export interface PublishOptions extends AbortOptions, ProgressOptions { /** @@ -299,7 +299,7 @@ export interface ResolveOptions extends AbortOptions, ProgressOptions { +export interface ResolveDNSLinkOptions extends AbortOptions, ProgressOptions { /** * Do not query the network for the IPNS record * @@ -352,7 +352,7 @@ export interface IPNS { /** * Resolve a CID from a dns-link style IPNS record */ - resolveDNSLink(domain: string, options?: ResolveDNSOptions): Promise + resolveDNSLink(domain: string, options?: ResolveDNSLinkOptions): Promise /** * Periodically republish all IPNS records found in the datastore @@ -423,7 +423,7 @@ class DefaultIPNS implements IPNS { return this.#resolve(record.value, options) } - async resolveDNSLink (domain: string, options: ResolveDNSOptions = {}): Promise { + async resolveDNSLink (domain: string, options: ResolveDNSLinkOptions = {}): Promise { const dnslink = await resolveDNSLink(domain, this.dns, this.log, options) return this.#resolve(dnslink, options)