*Update dist
This commit is contained in:
parent
0204e4d5e3
commit
9818d17a06
|
@ -4,10 +4,21 @@ export declare class ResolverRegistry {
|
|||
private _rpcNetwork;
|
||||
constructor(network: RpcNetwork);
|
||||
get rpcNetwork(): RpcNetwork;
|
||||
get resolvers(): Promise<Set<ResolverModule>>;
|
||||
resolve(
|
||||
domain: string,
|
||||
options?: ResolverOptions,
|
||||
bypassCache?: boolean
|
||||
): Promise<DNSResult>;
|
||||
}
|
||||
export declare class ResolverModule {
|
||||
private resolver;
|
||||
private domain;
|
||||
constructor(resolver: ResolverRegistry, domain: string);
|
||||
resolve(
|
||||
domain: string,
|
||||
options: ResolverOptions,
|
||||
bypassCache: boolean
|
||||
): Promise<DNSResult>;
|
||||
}
|
||||
export { RpcNetwork };
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { DNS_RECORD_TYPE, resolverError, } from "@lumeweb/resolver-common";
|
||||
import { resolve } from "@lumeweb/kernel-dns-client";
|
||||
import { getResolvers, resolve } from "@lumeweb/kernel-dns-client";
|
||||
import { RpcNetwork } from "@lumeweb/kernel-rpc-client";
|
||||
import { callModule } from "libkmodule";
|
||||
export class ResolverRegistry {
|
||||
_rpcNetwork;
|
||||
constructor(network) {
|
||||
|
@ -9,6 +10,15 @@ export class ResolverRegistry {
|
|||
get rpcNetwork() {
|
||||
return this._rpcNetwork;
|
||||
}
|
||||
get resolvers() {
|
||||
return getResolvers()
|
||||
.catch(() => {
|
||||
return new Set();
|
||||
})
|
||||
.then((resolvers) => {
|
||||
return new Set(resolvers.map((resolver) => new ResolverModule(this, resolver)));
|
||||
});
|
||||
}
|
||||
async resolve(domain, options = { type: DNS_RECORD_TYPE.DEFAULT }, bypassCache = false) {
|
||||
let result;
|
||||
try {
|
||||
|
@ -20,4 +30,23 @@ export class ResolverRegistry {
|
|||
return result;
|
||||
}
|
||||
}
|
||||
export class ResolverModule {
|
||||
resolver;
|
||||
domain;
|
||||
constructor(resolver, domain) {
|
||||
this.resolver = resolver;
|
||||
this.domain = domain;
|
||||
}
|
||||
async resolve(domain, options, bypassCache) {
|
||||
const [ret, err] = await callModule(this.domain, "resolve", {
|
||||
domain,
|
||||
options,
|
||||
bypassCache,
|
||||
});
|
||||
if (err) {
|
||||
return resolverError(err);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
export { RpcNetwork };
|
||||
|
|
Loading…
Reference in New Issue