diff --git a/LICENSE b/LICENSE index 13a5b6e..8995c8b 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2022 Lume Web +Copyright (c) 2022 Hammer Technologies LLC Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/dist/index.d.ts b/dist/index.d.ts new file mode 100644 index 0000000..b1da2b4 --- /dev/null +++ b/dist/index.d.ts @@ -0,0 +1,2 @@ +export declare function resolve(domain: string, params: any, force?: boolean): Promise; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/dist/index.d.ts.map b/dist/index.d.ts.map new file mode 100644 index 0000000..83264a8 --- /dev/null +++ b/dist/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAsBA,wBAAsB,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,UAAQ,gBAQvE"} \ No newline at end of file diff --git a/dist/index.js b/dist/index.js new file mode 100644 index 0000000..92a4026 --- /dev/null +++ b/dist/index.js @@ -0,0 +1,19 @@ +import { callModule as callModuleKernel, connectModule as connectModuleKernel, } from "libkernel"; +import { callModule as callModuleModule, connectModule as connectModuleModule, } from "libkmodule"; +const DNS_MODULE = "AQBLKpieqOfKVRgMa8k45P4S_ILYgJmswVso4vT1qzoG-A"; +let callModule, connectModule; +if (window.document) { + callModule = callModuleKernel; + connectModule = connectModuleKernel; +} +else { + callModule = callModuleModule; + connectModule = connectModuleModule; +} +export async function resolve(domain, params, force = false) { + const [resp, err] = await callModule(DNS_MODULE, "resolve", { domain, params, force }); + if (err) { + throw new Error(err); + } + return resp; +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..f974e04 --- /dev/null +++ b/package.json @@ -0,0 +1,16 @@ +{ + "name": "@lumeweb/kernel-dns-client", + "version": "0.1.0", + "type": "module", + "main": "dist/index.js", + "dependencies": { + "buffer": "^6.0.3", + "libkernel": "^0.1.43", + "libkmodule": "^0.2.44", + "libskynet": "^0.0.62" + }, + "devDependencies": { + "@types/node": "^18.0.6", + "prettier": "^2.7.1" + } +} diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..caac35f --- /dev/null +++ b/src/index.ts @@ -0,0 +1,31 @@ +import { + callModule as callModuleKernel, + connectModule as connectModuleKernel, +} from "libkernel"; +import { + callModule as callModuleModule, + connectModule as connectModuleModule, +} from "libkmodule"; + +const DNS_MODULE = "AQBLKpieqOfKVRgMa8k45P4S_ILYgJmswVso4vT1qzoG-A"; + +let callModule: typeof callModuleModule, + connectModule: typeof connectModuleModule; + +if (window.document) { + callModule = callModuleKernel; + connectModule = connectModuleKernel; +} else { + callModule = callModuleModule; + connectModule = connectModuleModule; +} + +export async function resolve(domain: string, params: any, force = false) { + const [resp, err] = await callModule(DNS_MODULE, "resolve", {domain, params, force}); + + if (err) { + throw new Error(err); + } + + return resp; +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..a4d5cd4 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "declaration": true, + "strict": true, + "module": "esnext", + "target": "esnext", + "esModuleInterop": true, + "sourceMap": false, + "rootDir": "src", + "outDir": "dist", + "typeRoots": [ + "node_modules/@types", + ], + "moduleResolution": "node", + "declarationMap": true, + "declarationDir": "dist", + "emitDeclarationOnly": false, + "allowJs": true + }, + "include": [ + "src" + ] +}