Compare commits

...

6 Commits

Author SHA1 Message Date
semantic-release-bot 3511c1de0f chore(release): 0.1.0-develop.1 [skip ci]
# [0.1.0-develop.1](https://git.lumeweb.com/LumeWeb/libresolver/compare/v0.0.2-develop.1...v0.1.0-develop.1) (2023-07-15)

### Features

* add ready method to AbstractResolverModule ([8be5af2](8be5af2f45))
2023-07-15 08:30:09 +00:00
Derrick Hammer 6237c84017
Merge remote-tracking branch 'origin/develop' into develop 2023-07-15 04:29:24 -04:00
Derrick Hammer 8be5af2f45
feat: add ready method to AbstractResolverModule 2023-07-15 04:29:02 -04:00
semantic-release-bot 3f0f14529d chore(release): 0.0.2-develop.1 [skip ci]
## [0.0.2-develop.1](https://git.lumeweb.com/LumeWeb/libresolver/compare/v0.0.1...v0.0.2-develop.1) (2023-07-05)
2023-07-05 08:43:20 +00:00
Derrick Hammer 17e840e859
ci: setup 2023-07-05 04:40:06 -04:00
Derrick Hammer 9dbcdd088d
refactor: move to new devops 2023-07-05 04:39:55 -04:00
19 changed files with 19372 additions and 212 deletions

13
.github/workflows/ci.yml vendored Normal file
View File

@ -0,0 +1,13 @@
name: Build/Publish
on:
push:
branches:
- master
- develop
- develop-*
jobs:
main:
uses: lumeweb/github-node-deploy-workflow/.github/workflows/main.yml@master
secrets: inherit

5
.presetterrc.json Normal file
View File

@ -0,0 +1,5 @@
{
"preset": [
"@lumeweb/node-library-preset"
]
}

8
CHANGELOG.md Normal file
View File

@ -0,0 +1,8 @@
# [0.1.0-develop.1](https://git.lumeweb.com/LumeWeb/libresolver/compare/v0.0.2-develop.1...v0.1.0-develop.1) (2023-07-15)
### Features
* add ready method to AbstractResolverModule ([8be5af2](https://git.lumeweb.com/LumeWeb/libresolver/commit/8be5af2f45087d10ae1ccf4d77c20a7a04d586ed))
## [0.0.2-develop.1](https://git.lumeweb.com/LumeWeb/libresolver/compare/v0.0.1...v0.0.2-develop.1) (2023-07-05)

4
dist/index.d.ts vendored
View File

@ -1,4 +0,0 @@
export * from "./types.js";
export * from "./util.js";
export * from "./resolverModule.js";
//# sourceMappingURL=index.d.ts.map

1
dist/index.d.ts.map vendored
View File

@ -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"}

3
dist/index.js vendored
View File

@ -1,3 +0,0 @@
export * from "./types.js";
export * from "./util.js";
export * from "./resolverModule.js";

View File

@ -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

View File

@ -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"}

View File

@ -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));
}
}

25
dist/types.d.ts vendored
View File

@ -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
dist/types.d.ts.map vendored
View File

@ -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"}

11
dist/types.js vendored
View File

@ -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 };

12
dist/util.d.ts vendored
View File

@ -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
dist/util.d.ts.map vendored
View File

@ -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"}

53
dist/util.js vendored
View File

@ -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));
}

19314
npm-shrinkwrap.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,14 +1,27 @@
{
"name": "@lumeweb/libresolver",
"version": "0.1.0",
"version": "0.1.0-develop.1",
"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",
"devDependencies": {
"@lumeweb/cfg": "git+https://git.lumeweb.com/LumeWeb/cfg.git",
"@lumeweb/relay-types": "git+https://git.lumeweb.com/LumeWeb/relay-types.git",
"@types/node": "^18.14.0",
"node-cache": "^5.1.2",
"typescript": "^4.9.5"
"@lumeweb/node-library-preset": "^0.2.7",
"presetter": "*"
},
"readme": "ERROR: No README data found!",
"scripts": {
"prepare": "presetter bootstrap",
"build": "run build",
"semantic-release": "semantic-release"
},
"files": [
"lib"
],
"publishConfig": {
"access": "public"
}
}

View File

@ -3,26 +3,33 @@ import { getTld, isPromise } from "./util.js";
declare class ResolverRegistry {
get resolvers(): Set<ResolverModule> | Promise<Set<ResolverModule>>;
resolve(
domain: string,
options?: ResolverOptions,
bypassCache?: boolean
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
bypassCache: boolean,
): Promise<DNSResult>;
getSupportedTlds(): string[];
getSupportedTlds(): Promise<string[]>;
getSupportedTlds(): any;
}
@ -45,7 +52,7 @@ export abstract class AbstractResolverModule {
abstract resolve(
domain: string,
options: ResolverOptions,
bypassCache: boolean
bypassCache: boolean,
): Promise<DNSResult>;
getSupportedTlds(): string[];
@ -66,4 +73,6 @@ export abstract class AbstractResolverModule {
return (supported as string[]).includes(getTld(domain));
}
abstract ready(): Promise<void>;
}

View File

@ -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"
]
}