*Update dist
This commit is contained in:
parent
4642c10bf2
commit
03503c1b77
|
@ -0,0 +1 @@
|
||||||
|
export declare const dnsClient: import("@lumeweb/kernel-dns-client").DnsClient;
|
|
@ -0,0 +1,2 @@
|
||||||
|
import { createClient } from "@lumeweb/kernel-dns-client";
|
||||||
|
export const dnsClient = createClient();
|
|
@ -1,31 +0,0 @@
|
||||||
import {
|
|
||||||
DNSResult,
|
|
||||||
ResolverOptions,
|
|
||||||
ResolverModuleConstructor as ResolverModuleConstructorBase,
|
|
||||||
} from "@lumeweb/libresolver";
|
|
||||||
import { Client } from "@lumeweb/libkernel-universal";
|
|
||||||
export interface ResolverModuleConstructor
|
|
||||||
extends ResolverModuleConstructorBase {
|
|
||||||
new (resolver: ResolverRegistry): ResolverModule;
|
|
||||||
}
|
|
||||||
export declare class ResolverRegistry {
|
|
||||||
get resolvers(): Promise<Set<ResolverModule>>;
|
|
||||||
resolve(
|
|
||||||
domain: string,
|
|
||||||
options?: ResolverOptions,
|
|
||||||
bypassCache?: boolean
|
|
||||||
): Promise<DNSResult>;
|
|
||||||
register(resolver: ResolverModule): void;
|
|
||||||
clear(): void;
|
|
||||||
}
|
|
||||||
export declare class ResolverModule extends Client {
|
|
||||||
private resolver;
|
|
||||||
private domain;
|
|
||||||
constructor(resolver: ResolverRegistry, domain: string);
|
|
||||||
resolve(
|
|
||||||
domain: string,
|
|
||||||
options: ResolverOptions,
|
|
||||||
bypassCache: boolean
|
|
||||||
): Promise<DNSResult>;
|
|
||||||
getSupportedTlds(): Promise<string[]>;
|
|
||||||
}
|
|
|
@ -1,49 +0,0 @@
|
||||||
import { DNS_RECORD_TYPE, resolverError, } from "@lumeweb/libresolver";
|
|
||||||
import { Client, factory } from "@lumeweb/libkernel-universal";
|
|
||||||
import { dnsClient } from "./client.js";
|
|
||||||
export class ResolverRegistry {
|
|
||||||
get resolvers() {
|
|
||||||
return dnsClient
|
|
||||||
.getResolvers()
|
|
||||||
.then((resolvers) => {
|
|
||||||
return new Set(resolvers.map((resolver) => factory(ResolverModule, resolver)(this, resolver)));
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
return new Set();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
async resolve(domain, options = { type: DNS_RECORD_TYPE.CONTENT }, bypassCache = false) {
|
|
||||||
try {
|
|
||||||
return dnsClient.resolve(domain, options, bypassCache);
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
return resolverError(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
register(resolver) { }
|
|
||||||
clear() { }
|
|
||||||
}
|
|
||||||
export class ResolverModule extends Client {
|
|
||||||
resolver;
|
|
||||||
domain;
|
|
||||||
constructor(resolver, domain) {
|
|
||||||
super();
|
|
||||||
this.resolver = resolver;
|
|
||||||
this.domain = domain;
|
|
||||||
}
|
|
||||||
async resolve(domain, options, bypassCache) {
|
|
||||||
try {
|
|
||||||
return this.callModuleReturn("resolve", {
|
|
||||||
domain,
|
|
||||||
options,
|
|
||||||
bypassCache,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
return resolverError(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
async getSupportedTlds() {
|
|
||||||
return this.callModuleReturn("getSupportedTlds");
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue