kernel-dns-client/dist/index.js

25 lines
934 B
JavaScript
Raw Normal View History

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-04-09 18:04:08 +00:00
const MODULE = "vAA-phmM1ztqu8zGBKF2nM3b8N_IQGWlB6J_doi2FhqS-A";
2023-02-19 21:22:59 +00:00
export class DnsClient extends Client {
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: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";