*Update dist

This commit is contained in:
Derrick Hammer 2022-08-19 09:57:34 -04:00
parent 0204e4d5e3
commit 9818d17a06
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
2 changed files with 41 additions and 1 deletions

View File

@ -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 };

View File

@ -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 };