Compare commits
No commits in common. "3f96c6d1de0e92d66e594d3d3f7a77961005df5c" and "19caf515d50805e577019077c92fc98f1d9dc524" have entirely different histories.
3f96c6d1de
...
19caf515d5
|
@ -4,14 +4,13 @@
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@lumeweb/libkernel-universal": "git+https://git.lumeweb.com/LumeWeb/libkernel-universal.git",
|
"@lumeweb/resolver-common": "github:LumeWeb/resolver-common",
|
||||||
"libkernel": "^0.1.43",
|
"libkernel": "^0.1.43",
|
||||||
"libkmodule": "^0.2.44",
|
"libkmodule": "^0.2.44",
|
||||||
"libskynet": "^0.0.62"
|
"libskynet": "^0.0.62"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^18.0.6",
|
"@types/node": "^18.0.6",
|
||||||
"prettier": "^2.7.1",
|
"prettier": "^2.7.1"
|
||||||
"typescript": "^4.9.5"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
79
src/index.ts
79
src/index.ts
|
@ -1,20 +1,71 @@
|
||||||
import { Client, factory } from "@lumeweb/libkernel-universal";
|
import { DNS_RECORD_TYPE, ResolverOptions } from "@lumeweb/resolver-common";
|
||||||
|
|
||||||
const MODULE = "PACYNuYbp_5hgCjMK16EGcytB9QCxDLe4_uitahwePdeaA";
|
const DNS_MODULE = "AQBLKpieqOfKVRgMa8k45P4S_ILYgJmswVso4vT1qzoG-A";
|
||||||
|
|
||||||
export class DnsClient extends Client {
|
let callModule: any, connectModule: any;
|
||||||
public async register(): Promise<void> {
|
|
||||||
return this.callModuleReturn("register");
|
async function loadLibs() {
|
||||||
|
if (callModule && connectModule) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
public async clear(): Promise<void> {
|
if (typeof window !== "undefined" && window?.document) {
|
||||||
return this.callModuleReturn("clear");
|
const pkg = await import("libkernel");
|
||||||
}
|
callModule = pkg.callModule;
|
||||||
public async getResolvers(): Promise<void> {
|
connectModule = pkg.connectModule;
|
||||||
return this.callModuleReturn("clear");
|
} else {
|
||||||
}
|
const pkg = await import("libkmodule");
|
||||||
public async ready(): Promise<void> {
|
callModule = pkg.callModule;
|
||||||
return this.callModuleReturn("ready");
|
connectModule = pkg.connectModule;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const createClient = factory<DnsClient>(DnsClient, MODULE);
|
export async function resolve(
|
||||||
|
domain: string,
|
||||||
|
options: ResolverOptions = { type: DNS_RECORD_TYPE.CONTENT },
|
||||||
|
bypassCache = false
|
||||||
|
) {
|
||||||
|
await loadLibs();
|
||||||
|
const [resp, err] = await callModule(DNS_MODULE, "resolve", {
|
||||||
|
domain,
|
||||||
|
options,
|
||||||
|
bypassCache,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (err) {
|
||||||
|
throw new Error(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
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 getResolvers() {
|
||||||
|
await loadLibs();
|
||||||
|
const [resp, err] = await callModule(DNS_MODULE, "getResolvers");
|
||||||
|
|
||||||
|
if (err) {
|
||||||
|
throw new Error(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
return resp;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function ready() {
|
||||||
|
await loadLibs();
|
||||||
|
const [resp, err] = await callModule(DNS_MODULE, "ready");
|
||||||
|
|
||||||
|
if (err) {
|
||||||
|
throw new Error(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
return resp;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue