2023-02-19 21:22:59 +00:00
|
|
|
import { Client, factory } from "@lumeweb/libkernel-universal";
|
2023-02-19 21:44:38 +00:00
|
|
|
import { DNS_RECORD_TYPE, } from "@lumeweb/libresolver";
|
2023-02-20 01:57:49 +00:00
|
|
|
import { createModule } from "./module.js";
|
2023-02-20 19:54:49 +00:00
|
|
|
const MODULE = "PAAUkZAnPjxi2CzQWZ7jCVcl-E9lQLvTOwE2vhU0hX5UXg";
|
2023-02-19 21:22:59 +00:00
|
|
|
export class DnsClient extends Client {
|
2023-02-19 21:30:01 +00:00
|
|
|
async register() {
|
|
|
|
return this.callModuleReturn("register");
|
2022-07-21 17:22:02 +00:00
|
|
|
}
|
2023-02-19 21:22:59 +00:00
|
|
|
async clear() {
|
|
|
|
return this.callModuleReturn("clear");
|
2022-07-21 17:22:02 +00:00
|
|
|
}
|
2023-02-20 01:21:59 +00:00
|
|
|
get resolvers() {
|
2023-02-20 01:57:49 +00:00
|
|
|
return this.callModuleReturn("getResolvers").then((resolvers) => {
|
|
|
|
return new Set(resolvers.map((resolver) => {
|
|
|
|
return createModule(resolver, this);
|
|
|
|
}));
|
|
|
|
});
|
2022-07-21 17:22:02 +00:00
|
|
|
}
|
2023-02-19 21:22:59 +00:00
|
|
|
async ready() {
|
|
|
|
return this.callModuleReturn("ready");
|
2022-07-20 11:11:06 +00:00
|
|
|
}
|
2023-02-19 21:42:13 +00:00
|
|
|
async resolve(domain, options = { type: DNS_RECORD_TYPE.CONTENT }, bypassCache = false) {
|
2023-02-19 21:44:38 +00:00
|
|
|
return this.callModuleReturn("resolve", { domain, options, bypassCache });
|
2023-02-19 21:42:13 +00:00
|
|
|
}
|
2022-07-20 11:11:06 +00:00
|
|
|
}
|
2023-02-19 21:22:59 +00:00
|
|
|
export const createClient = factory(DnsClient, MODULE);
|
2023-02-20 01:57:49 +00:00
|
|
|
export * from "./module.js";
|