refactor: move to new devops
This commit is contained in:
parent
e9ac273378
commit
9dbcdd088d
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"preset": [
|
||||||
|
"@lumeweb/node-library-preset"
|
||||||
|
]
|
||||||
|
}
|
|
@ -1,4 +0,0 @@
|
||||||
export * from "./types.js";
|
|
||||||
export * from "./util.js";
|
|
||||||
export * from "./resolverModule.js";
|
|
||||||
//# sourceMappingURL=index.d.ts.map
|
|
|
@ -1 +0,0 @@
|
||||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,qBAAqB,CAAC"}
|
|
|
@ -1,3 +0,0 @@
|
||||||
export * from "./types.js";
|
|
||||||
export * from "./util.js";
|
|
||||||
export * from "./resolverModule.js";
|
|
|
@ -1,40 +0,0 @@
|
||||||
import type { DNSResult, ResolverOptions } from "./types.js";
|
|
||||||
declare class ResolverRegistry {
|
|
||||||
get resolvers(): Set<ResolverModule> | Promise<Set<ResolverModule>>;
|
|
||||||
resolve(
|
|
||||||
domain: string,
|
|
||||||
options?: ResolverOptions,
|
|
||||||
bypassCache?: boolean
|
|
||||||
): Promise<DNSResult>;
|
|
||||||
register(resolver: ResolverModule): void;
|
|
||||||
clear(): void;
|
|
||||||
}
|
|
||||||
export interface ResolverModule {
|
|
||||||
get resolver(): ResolverRegistry;
|
|
||||||
set resolver(value: ResolverRegistry);
|
|
||||||
resolve(
|
|
||||||
domain: string,
|
|
||||||
options: ResolverOptions,
|
|
||||||
bypassCache: boolean
|
|
||||||
): Promise<DNSResult>;
|
|
||||||
getSupportedTlds(): string[];
|
|
||||||
getSupportedTlds(): Promise<string[]>;
|
|
||||||
getSupportedTlds(): any;
|
|
||||||
}
|
|
||||||
export declare abstract class AbstractResolverModule {
|
|
||||||
constructor(resolver?: ResolverRegistry);
|
|
||||||
private _resolver?;
|
|
||||||
get resolver(): ResolverRegistry;
|
|
||||||
set resolver(value: ResolverRegistry);
|
|
||||||
abstract resolve(
|
|
||||||
domain: string,
|
|
||||||
options: ResolverOptions,
|
|
||||||
bypassCache: boolean
|
|
||||||
): Promise<DNSResult>;
|
|
||||||
getSupportedTlds(): string[];
|
|
||||||
getSupportedTlds(): Promise<string[]>;
|
|
||||||
isTldSupported(domain: string): Promise<boolean>;
|
|
||||||
isTldSupported(domain: string): boolean;
|
|
||||||
}
|
|
||||||
export {};
|
|
||||||
//# sourceMappingURL=resolverModule.d.ts.map
|
|
|
@ -1 +0,0 @@
|
||||||
{"version":3,"file":"resolverModule.d.ts","sourceRoot":"","sources":["../src/resolverModule.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAG7D,OAAO,OAAO,gBAAgB;IAC5B,IAAI,SAAS,IAAI,GAAG,CAAC,cAAc,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC;IACpE,OAAO,CACL,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,eAAe,EACzB,WAAW,CAAC,EAAE,OAAO,GACpB,OAAO,CAAC,SAAS,CAAC;IACrB,QAAQ,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI;IACxC,KAAK,IAAI,IAAI;CACd;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,QAAQ,IAAI,gBAAgB,CAAC;IACjC,IAAI,QAAQ,CAAC,KAAK,EAAE,gBAAgB,EAAE;IACtC,OAAO,CACL,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,eAAe,EACxB,WAAW,EAAE,OAAO,GACnB,OAAO,CAAC,SAAS,CAAC,CAAC;IAEtB,gBAAgB,IAAI,MAAM,EAAE,CAAC;IAC7B,gBAAgB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IACtC,gBAAgB,IAAI,GAAG,CAAC;CACzB;AAGD,8BAAsB,sBAAsB;gBAC9B,QAAQ,CAAC,EAAE,gBAAgB;IAIvC,OAAO,CAAC,SAAS,CAAC,CAAmB;IAErC,IAAI,QAAQ,IAAI,gBAAgB,CAE/B;IAED,IAAI,QAAQ,CAAC,KAAK,EAAE,gBAAgB,EAEnC;IAED,QAAQ,CAAC,OAAO,CACd,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,eAAe,EACxB,WAAW,EAAE,OAAO,GACnB,OAAO,CAAC,SAAS,CAAC;IAErB,gBAAgB,IAAI,MAAM,EAAE;IAC5B,gBAAgB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAKrC,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAChD,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;CAWxC"}
|
|
|
@ -1,26 +0,0 @@
|
||||||
import { getTld, isPromise } from "./util.js";
|
|
||||||
// ts-ignore
|
|
||||||
export class AbstractResolverModule {
|
|
||||||
constructor(resolver) {
|
|
||||||
this._resolver = resolver;
|
|
||||||
}
|
|
||||||
_resolver;
|
|
||||||
get resolver() {
|
|
||||||
return this._resolver;
|
|
||||||
}
|
|
||||||
set resolver(value) {
|
|
||||||
this._resolver = value;
|
|
||||||
}
|
|
||||||
getSupportedTlds() {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
isTldSupported(domain) {
|
|
||||||
let supported = this.getSupportedTlds();
|
|
||||||
if (isPromise(supported)) {
|
|
||||||
return supported.then((supported) => {
|
|
||||||
return supported.includes(getTld(domain));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return supported.includes(getTld(domain));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,25 +0,0 @@
|
||||||
export interface ResolverOptions {
|
|
||||||
type: string;
|
|
||||||
customType?: string;
|
|
||||||
options?: any;
|
|
||||||
}
|
|
||||||
export interface DNSResult {
|
|
||||||
records: DNSRecord[];
|
|
||||||
error?: Error;
|
|
||||||
}
|
|
||||||
export interface DNSRecord {
|
|
||||||
type: string;
|
|
||||||
customType?: string;
|
|
||||||
value: string;
|
|
||||||
}
|
|
||||||
declare const DNS_RECORD_TYPE: {
|
|
||||||
A: string;
|
|
||||||
CNAME: string;
|
|
||||||
NS: string;
|
|
||||||
CONTENT: string;
|
|
||||||
TEXT: string;
|
|
||||||
ALL: string;
|
|
||||||
CUSTOM: string;
|
|
||||||
};
|
|
||||||
export { DNS_RECORD_TYPE };
|
|
||||||
//# sourceMappingURL=types.d.ts.map
|
|
|
@ -1 +0,0 @@
|
||||||
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,GAAG,CAAC;CACf;AAED,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,SAAS,EAAE,CAAC;IACrB,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;CACf;AACD,QAAA,MAAM,eAAe;;;;;;;;CAQpB,CAAC;AAIF,OAAO,EAAE,eAAe,EAAE,CAAC"}
|
|
|
@ -1,11 +0,0 @@
|
||||||
const DNS_RECORD_TYPE = {
|
|
||||||
A: "A",
|
|
||||||
CNAME: "CNAME",
|
|
||||||
NS: "NS",
|
|
||||||
CONTENT: "CONTENT",
|
|
||||||
TEXT: "TEXT",
|
|
||||||
ALL: "ALL",
|
|
||||||
CUSTOM: "CUSTOM",
|
|
||||||
};
|
|
||||||
Object.freeze(DNS_RECORD_TYPE);
|
|
||||||
export { DNS_RECORD_TYPE };
|
|
|
@ -1,12 +0,0 @@
|
||||||
import { DNSRecord, DNSResult } from "./types.js";
|
|
||||||
export declare function getTld(domain: string): string;
|
|
||||||
export declare function getSld(domain: string): string;
|
|
||||||
export declare function isIp(ip: string): boolean;
|
|
||||||
export declare function isDomain(domain: string): boolean;
|
|
||||||
export declare function resolverEmptyResponse(): DNSResult;
|
|
||||||
export declare function resolverError(e: Error | string): DNSResult;
|
|
||||||
export declare function resolveSuccess(records: DNSRecord[]): DNSResult;
|
|
||||||
export declare function normalizeDomain(domain: string): string;
|
|
||||||
export declare function isPromise(obj: Promise<any>): boolean;
|
|
||||||
export declare function ensureUniqueRecords(records: DNSRecord[]): any[];
|
|
||||||
//# sourceMappingURL=util.d.ts.map
|
|
|
@ -1 +0,0 @@
|
||||||
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAElD,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAM7C;AAED,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAS7C;AAED,wBAAgB,IAAI,CAAC,EAAE,EAAE,MAAM,WAI9B;AAED,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,WAItC;AACD,wBAAgB,qBAAqB,IAAI,SAAS,CAIjD;AAED,wBAAgB,aAAa,CAAC,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,SAAS,CAQ1D;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,SAAS,EAAE,GAAG,SAAS,CAI9D;AACD,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEtD;AACD,wBAAgB,SAAS,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,WAM1C;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,SAAS,EAAE,SAIvD"}
|
|
|
@ -1,53 +0,0 @@
|
||||||
export function getTld(domain) {
|
|
||||||
if (domain.includes(".")) {
|
|
||||||
domain = domain.split(".")[domain.split(".").length - 1];
|
|
||||||
}
|
|
||||||
return domain;
|
|
||||||
}
|
|
||||||
export function getSld(domain) {
|
|
||||||
if (domain.includes(".")) {
|
|
||||||
domain = domain
|
|
||||||
.split(".")
|
|
||||||
.slice(0, domain.split(".").length - 1)
|
|
||||||
.join(".");
|
|
||||||
}
|
|
||||||
return domain;
|
|
||||||
}
|
|
||||||
export function isIp(ip) {
|
|
||||||
return /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(ip);
|
|
||||||
}
|
|
||||||
export function isDomain(domain) {
|
|
||||||
return /(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]/.test(domain);
|
|
||||||
}
|
|
||||||
export function resolverEmptyResponse() {
|
|
||||||
return {
|
|
||||||
records: [],
|
|
||||||
};
|
|
||||||
}
|
|
||||||
export function resolverError(e) {
|
|
||||||
if (!(e instanceof Error)) {
|
|
||||||
e = new Error(e);
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
records: [],
|
|
||||||
error: e,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
export function resolveSuccess(records) {
|
|
||||||
return {
|
|
||||||
records,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
export function normalizeDomain(domain) {
|
|
||||||
return domain.replace(/^\.+|\.+$/g, "").replace(/^\/+|\/+$/g, "");
|
|
||||||
}
|
|
||||||
export function isPromise(obj) {
|
|
||||||
return (!!obj &&
|
|
||||||
(typeof obj === "object" || typeof obj === "function") &&
|
|
||||||
typeof obj.then === "function");
|
|
||||||
}
|
|
||||||
export function ensureUniqueRecords(records) {
|
|
||||||
return [
|
|
||||||
...new Set(records.map((item) => JSON.stringify(item))),
|
|
||||||
].map((item) => JSON.parse(item));
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
26
package.json
26
package.json
|
@ -2,13 +2,27 @@
|
||||||
"name": "@lumeweb/libresolver",
|
"name": "@lumeweb/libresolver",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"description": "Common code and interfaces for the DNS resolver modules",
|
"description": "Common code and interfaces for the DNS resolver modules",
|
||||||
"main": "dist/index.js",
|
"main": "lib/index.js",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "gitea@git.lumeweb.com:LumeWeb/libresolver.git"
|
||||||
|
},
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@lumeweb/cfg": "git+https://git.lumeweb.com/LumeWeb/cfg.git",
|
"@lumeweb/node-library-preset": "^0.2.7",
|
||||||
"@lumeweb/relay-types": "git+https://git.lumeweb.com/LumeWeb/relay-types.git",
|
"presetter": "*"
|
||||||
"@types/node": "^18.14.0",
|
},
|
||||||
"node-cache": "^5.1.2",
|
"readme": "ERROR: No README data found!",
|
||||||
"typescript": "^4.9.5"
|
"_id": "@lumeweb/libresolver@0.1.0",
|
||||||
|
"scripts": {
|
||||||
|
"prepare": "presetter bootstrap",
|
||||||
|
"build": "run build",
|
||||||
|
"semantic-release": "semantic-release"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"lib"
|
||||||
|
],
|
||||||
|
"publishConfig": {
|
||||||
|
"access": "public"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
{
|
|
||||||
"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,
|
|
||||||
"noImplicitAny": false
|
|
||||||
},
|
|
||||||
"include": [
|
|
||||||
"src"
|
|
||||||
]
|
|
||||||
}
|
|
Loading…
Reference in New Issue