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