Compare commits
No commits in common. "cf6435ef1e8c29fc5b0240bedcb7c28c9a87b8de" and "dd1b25aa30eef96ae92200c3953c3ee0cd29426f" have entirely different histories.
cf6435ef1e
...
dd1b25aa30
|
@ -1,10 +1,9 @@
|
|||
import { Client } from "@lumeweb/libkernel-universal";
|
||||
import { DNSResult, ResolverOptions } from "@lumeweb/libresolver";
|
||||
import { ResolverModule } from "./module.js";
|
||||
export declare class DnsClient extends Client {
|
||||
register(): Promise<void>;
|
||||
clear(): Promise<void>;
|
||||
get resolvers(): Promise<Set<ResolverModule>>;
|
||||
get resolvers(): Promise<string[]>;
|
||||
ready(): Promise<void>;
|
||||
resolve(
|
||||
domain: string,
|
||||
|
@ -13,5 +12,4 @@ export declare class DnsClient extends Client {
|
|||
): Promise<DNSResult>;
|
||||
}
|
||||
export declare const createClient: (...args: any) => DnsClient;
|
||||
export * from "./module.js";
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAW,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAEL,SAAS,EACT,eAAe,EAChB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAgB,cAAc,EAAE,MAAM,aAAa,CAAC;AAI3D,qBAAa,SAAU,SAAQ,MAAM;IACtB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAGzB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAGnC,IAAI,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAQ5C;IACY,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAGtB,OAAO,CAClB,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,eAAmD,EAC5D,WAAW,GAAE,OAAe,GAC3B,OAAO,CAAC,SAAS,CAAC;CAGtB;AAED,eAAO,MAAM,YAAY,6BAAwC,CAAC;AAClE,cAAc,aAAa,CAAC"}
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAW,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAEL,SAAS,EACT,eAAe,EAChB,MAAM,sBAAsB,CAAC;AAI9B,qBAAa,SAAU,SAAQ,MAAM;IACtB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAGzB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAGnC,IAAI,SAAS,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAEjC;IACY,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAGtB,OAAO,CAClB,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,eAAmD,EAC5D,WAAW,GAAE,OAAe,GAC3B,OAAO,CAAC,SAAS,CAAC;CAGtB;AAED,eAAO,MAAM,YAAY,6BAAwC,CAAC"}
|
|
@ -1,6 +1,5 @@
|
|||
import { Client, factory } from "@lumeweb/libkernel-universal";
|
||||
import { DNS_RECORD_TYPE, } from "@lumeweb/libresolver";
|
||||
import { createModule } from "./module.js";
|
||||
const MODULE = "PACYNuYbp_5hgCjMK16EGcytB9QCxDLe4_uitahwePdeaA";
|
||||
export class DnsClient extends Client {
|
||||
async register() {
|
||||
|
@ -10,11 +9,7 @@ export class DnsClient extends Client {
|
|||
return this.callModuleReturn("clear");
|
||||
}
|
||||
get resolvers() {
|
||||
return this.callModuleReturn("getResolvers").then((resolvers) => {
|
||||
return new Set(resolvers.map((resolver) => {
|
||||
return createModule(resolver, this);
|
||||
}));
|
||||
});
|
||||
return this.callModuleReturn("getResolvers");
|
||||
}
|
||||
async ready() {
|
||||
return this.callModuleReturn("ready");
|
||||
|
@ -24,4 +19,3 @@ export class DnsClient extends Client {
|
|||
}
|
||||
}
|
||||
export const createClient = factory(DnsClient, MODULE);
|
||||
export * from "./module.js";
|
||||
|
|
12
src/index.ts
12
src/index.ts
|
@ -4,7 +4,6 @@ import {
|
|||
DNSResult,
|
||||
ResolverOptions,
|
||||
} from "@lumeweb/libresolver";
|
||||
import { createModule, ResolverModule } from "./module.js";
|
||||
|
||||
const MODULE = "PACYNuYbp_5hgCjMK16EGcytB9QCxDLe4_uitahwePdeaA";
|
||||
|
||||
|
@ -15,14 +14,8 @@ export class DnsClient extends Client {
|
|||
public async clear(): Promise<void> {
|
||||
return this.callModuleReturn("clear");
|
||||
}
|
||||
get resolvers(): Promise<Set<ResolverModule>> {
|
||||
return this.callModuleReturn("getResolvers").then((resolvers: string[]) => {
|
||||
return new Set(
|
||||
resolvers.map((resolver: string): ResolverModule => {
|
||||
return createModule(resolver, this);
|
||||
})
|
||||
);
|
||||
});
|
||||
get resolvers(): Promise<string[]> {
|
||||
return this.callModuleReturn("getResolvers");
|
||||
}
|
||||
public async ready(): Promise<void> {
|
||||
return this.callModuleReturn("ready");
|
||||
|
@ -37,4 +30,3 @@ export class DnsClient extends Client {
|
|||
}
|
||||
|
||||
export const createClient = factory<DnsClient>(DnsClient, MODULE);
|
||||
export * from "./module.js";
|
||||
|
|
|
@ -1,52 +0,0 @@
|
|||
import { Client, factory } from "@lumeweb/libkernel-universal";
|
||||
import { DnsClient } from "./index.js";
|
||||
import {
|
||||
DNSResult,
|
||||
resolverError,
|
||||
ResolverOptions,
|
||||
} from "@lumeweb/libresolver";
|
||||
|
||||
export class ResolverModule extends Client {
|
||||
private domain: string;
|
||||
|
||||
constructor(domain: string, resolver?: DnsClient) {
|
||||
super();
|
||||
this._resolver = resolver;
|
||||
this.domain = domain;
|
||||
}
|
||||
|
||||
private _resolver?: DnsClient;
|
||||
|
||||
get resolver(): DnsClient {
|
||||
return this._resolver as DnsClient;
|
||||
}
|
||||
|
||||
set resolver(value: DnsClient) {
|
||||
this._resolver = value;
|
||||
}
|
||||
|
||||
async resolve(
|
||||
domain: string,
|
||||
options: ResolverOptions,
|
||||
bypassCache: boolean
|
||||
): Promise<DNSResult> {
|
||||
try {
|
||||
return this.callModuleReturn("resolve", {
|
||||
domain,
|
||||
options,
|
||||
bypassCache,
|
||||
});
|
||||
} catch (e) {
|
||||
return resolverError(e as Error);
|
||||
}
|
||||
}
|
||||
async getSupportedTlds(): Promise<string[]> {
|
||||
return this.callModuleReturn("getSupportedTlds");
|
||||
}
|
||||
}
|
||||
|
||||
export const createModule = (
|
||||
module: string,
|
||||
client: DnsClient
|
||||
): ResolverModule =>
|
||||
factory<ResolverModule>(ResolverModule, module)(module, client);
|
Loading…
Reference in New Issue