2022-07-20 11:11:06 +00:00
|
|
|
const DNS_MODULE = "AQBLKpieqOfKVRgMa8k45P4S_ILYgJmswVso4vT1qzoG-A";
|
|
|
|
let callModule, connectModule;
|
2022-07-21 17:22:02 +00:00
|
|
|
async function loadLibs() {
|
|
|
|
if (callModule && connectModule) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (typeof window !== "undefined" && window?.document) {
|
2022-08-14 10:54:52 +00:00
|
|
|
const pkg = await import("libkernel");
|
2022-07-21 17:22:02 +00:00
|
|
|
callModule = pkg.callModule;
|
|
|
|
connectModule = pkg.connectModule;
|
|
|
|
}
|
|
|
|
else {
|
2022-08-14 10:54:52 +00:00
|
|
|
const pkg = await import("libkmodule");
|
2022-07-21 17:22:02 +00:00
|
|
|
callModule = pkg.callModule;
|
|
|
|
connectModule = pkg.connectModule;
|
|
|
|
}
|
2022-07-20 11:11:06 +00:00
|
|
|
}
|
2022-08-18 20:52:45 +00:00
|
|
|
export async function resolve(domain, options, bypassCache = false) {
|
2022-07-21 17:22:02 +00:00
|
|
|
await loadLibs();
|
2022-08-14 10:54:52 +00:00
|
|
|
const [resp, err] = await callModule(DNS_MODULE, "resolve", {
|
|
|
|
domain,
|
2022-08-18 20:52:45 +00:00
|
|
|
options,
|
|
|
|
bypassCache,
|
2022-08-14 10:54:52 +00:00
|
|
|
});
|
|
|
|
if (err) {
|
|
|
|
throw new Error(err);
|
|
|
|
}
|
|
|
|
return resp;
|
|
|
|
}
|
2022-08-18 20:52:45 +00:00
|
|
|
export async function register() {
|
|
|
|
await loadLibs();
|
|
|
|
await callModule(DNS_MODULE, "register");
|
|
|
|
}
|
|
|
|
export async function clear() {
|
|
|
|
await loadLibs();
|
|
|
|
await callModule(DNS_MODULE, "clear");
|
|
|
|
}
|
2022-08-14 10:54:52 +00:00
|
|
|
export async function ready() {
|
|
|
|
await loadLibs();
|
|
|
|
const [resp, err] = await callModule(DNS_MODULE, "ready");
|
2022-07-20 11:11:06 +00:00
|
|
|
if (err) {
|
|
|
|
throw new Error(err);
|
|
|
|
}
|
|
|
|
return resp;
|
|
|
|
}
|