*Update to new API and support registration of resolver modules

This commit is contained in:
Derrick Hammer 2022-08-18 16:51:48 -04:00
parent 1ba24bee76
commit 52821f43b6
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
2 changed files with 21 additions and 3 deletions

View File

@ -4,6 +4,7 @@
"type": "module",
"main": "dist/index.js",
"dependencies": {
"@lumeweb/resolver-common": "github:LumeWeb/resolver-common",
"buffer": "^6.0.3",
"libkernel": "^0.1.43",
"libkmodule": "^0.2.44",

View File

@ -1,3 +1,5 @@
import { ResolverOptions } from "@lumeweb/resolver-common";
const DNS_MODULE = "AQBLKpieqOfKVRgMa8k45P4S_ILYgJmswVso4vT1qzoG-A";
let callModule: any, connectModule: any;
@ -17,12 +19,16 @@ async function loadLibs() {
}
}
export async function resolve(domain: string, params: any, force = false) {
export async function resolve(
domain: string,
options: ResolverOptions,
bypassCache = false
) {
await loadLibs();
const [resp, err] = await callModule(DNS_MODULE, "resolve", {
domain,
params,
force,
options,
bypassCache,
});
if (err) {
@ -31,6 +37,17 @@ export async function resolve(domain: string, params: any, force = false) {
return resp;
}
export async function register() {
await loadLibs();
await callModule(DNS_MODULE, "register");
}
export async function clear() {
await loadLibs();
await callModule(DNS_MODULE, "clear");
}
export async function ready() {
await loadLibs();
const [resp, err] = await callModule(DNS_MODULE, "ready");