mirror of
https://github.com/jakejarvis/rdapper.git
synced 2026-09-23 00:15:31 -04:00
Replaced tsconfig.build.json with tsdown configuration for simplified builds.
This commit is contained in:
Vendored
-17
@@ -1,17 +0,0 @@
|
|||||||
{
|
|
||||||
"typescript.tsdk": "node_modules/typescript/lib",
|
|
||||||
"editor.defaultFormatter": "biomejs.biome",
|
|
||||||
"editor.formatOnSave": true,
|
|
||||||
"editor.formatOnPaste": true,
|
|
||||||
"emmet.showExpandedAbbreviation": "never",
|
|
||||||
"editor.codeActionsOnSave": {
|
|
||||||
"source.fixAll.biome": "explicit",
|
|
||||||
"source.organizeImports.biome": "explicit"
|
|
||||||
},
|
|
||||||
"[typescript]": {
|
|
||||||
"editor.defaultFormatter": "biomejs.biome"
|
|
||||||
},
|
|
||||||
"[javascript]": {
|
|
||||||
"editor.defaultFormatter": "biomejs.biome"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Generated
+752
-768
File diff suppressed because it is too large
Load Diff
+11
-8
@@ -7,6 +7,9 @@
|
|||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/jakejarvis/rdapper.git"
|
"url": "git+https://github.com/jakejarvis/rdapper.git"
|
||||||
},
|
},
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/jakejarvis/rdapper/issues"
|
||||||
|
},
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Jake Jarvis",
|
"name": "Jake Jarvis",
|
||||||
"email": "jake@jarv.is",
|
"email": "jake@jarv.is",
|
||||||
@@ -14,6 +17,7 @@
|
|||||||
},
|
},
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "./dist/index.js",
|
"main": "./dist/index.js",
|
||||||
|
"module": "./dist/index.js",
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": {
|
".": {
|
||||||
@@ -26,13 +30,12 @@
|
|||||||
"dist"
|
"dist"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"clean": "rm -rf dist",
|
"build": "tsdown",
|
||||||
"build": "npm run clean && tsc -p tsconfig.build.json",
|
"dev": "tsdown --watch",
|
||||||
"test": "npm run clean && tsc -p tsconfig.json && vitest run",
|
"typecheck": "tsc --noEmit",
|
||||||
"test:watch": "npm run clean && tsc -p tsconfig.json && vitest",
|
"test": "vitest",
|
||||||
"test:coverage": "npm run clean && tsc -p tsconfig.json && vitest run --coverage",
|
"test:run": "vitest run",
|
||||||
"test:smoke": "SMOKE=1 npm run test",
|
"lint": "biome check",
|
||||||
"lint": "biome check --write",
|
|
||||||
"prepublishOnly": "npm run build"
|
"prepublishOnly": "npm run build"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -42,7 +45,7 @@
|
|||||||
"@biomejs/biome": "2.2.4",
|
"@biomejs/biome": "2.2.4",
|
||||||
"@types/node": "24.5.2",
|
"@types/node": "24.5.2",
|
||||||
"@types/psl": "1.1.3",
|
"@types/psl": "1.1.3",
|
||||||
"@vitest/coverage-v8": "^3.2.4",
|
"tsdown": "0.15.5",
|
||||||
"typescript": "5.9.2",
|
"typescript": "5.9.2",
|
||||||
"vitest": "^3.2.4"
|
"vitest": "^3.2.4"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/** biome-ignore-all lint/style/noNonNullAssertion: this is fine for tests */
|
/** biome-ignore-all lint/style/noNonNullAssertion: this is fine for tests */
|
||||||
|
|
||||||
import { expect, test } from "vitest";
|
import { expect, test } from "vitest";
|
||||||
import { isAvailable, isRegistered, lookupDomain } from "./index.js";
|
import { isAvailable, isRegistered, lookupDomain } from ".";
|
||||||
|
|
||||||
// Run only when SMOKE=1 to avoid flakiness and network in CI by default
|
// Run only when SMOKE=1 to avoid flakiness and network in CI by default
|
||||||
const shouldRun = process.env.SMOKE === "1";
|
const shouldRun = process.env.SMOKE === "1";
|
||||||
|
|||||||
+6
-6
@@ -37,12 +37,12 @@ vi.mock("./lib/domain.js", async () => {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
import { lookupDomain } from "./index.js";
|
import { lookupDomain } from ".";
|
||||||
import * as domain from "./lib/domain.js";
|
import * as domain from "./lib/domain";
|
||||||
import * as rdapClient from "./rdap/client.js";
|
import * as rdapClient from "./rdap/client";
|
||||||
import type { WhoisQueryResult } from "./whois/client.js";
|
import type { WhoisQueryResult } from "./whois/client";
|
||||||
import * as whoisClient from "./whois/client.js";
|
import * as whoisClient from "./whois/client";
|
||||||
import * as discovery from "./whois/discovery.js";
|
import * as discovery from "./whois/discovery";
|
||||||
|
|
||||||
// 1) Orchestration tests (RDAP path, fallback, whoisOnly)
|
// 1) Orchestration tests (RDAP path, fallback, whoisOnly)
|
||||||
describe("lookupDomain orchestration", () => {
|
describe("lookupDomain orchestration", () => {
|
||||||
|
|||||||
+13
-15
@@ -1,18 +1,18 @@
|
|||||||
import { toISO } from "./lib/dates.js";
|
import { toISO } from "./lib/dates";
|
||||||
import { getDomainParts, isLikelyDomain } from "./lib/domain.js";
|
import { getDomainParts, isLikelyDomain } from "./lib/domain";
|
||||||
import { getRdapBaseUrlsForTld } from "./rdap/bootstrap.js";
|
import { getRdapBaseUrlsForTld } from "./rdap/bootstrap";
|
||||||
import { fetchRdapDomain } from "./rdap/client.js";
|
import { fetchRdapDomain } from "./rdap/client";
|
||||||
import { normalizeRdap } from "./rdap/normalize.js";
|
import { normalizeRdap } from "./rdap/normalize";
|
||||||
import type { DomainRecord, LookupOptions, LookupResult } from "./types.js";
|
import type { DomainRecord, LookupOptions, LookupResult } from "./types";
|
||||||
import { whoisQuery } from "./whois/client.js";
|
import { whoisQuery } from "./whois/client";
|
||||||
import {
|
import {
|
||||||
extractWhoisReferral,
|
extractWhoisReferral,
|
||||||
ianaWhoisServerForTld,
|
|
||||||
getIanaWhoisTextForTld,
|
getIanaWhoisTextForTld,
|
||||||
|
ianaWhoisServerForTld,
|
||||||
parseIanaRegistrationInfoUrl,
|
parseIanaRegistrationInfoUrl,
|
||||||
} from "./whois/discovery.js";
|
} from "./whois/discovery";
|
||||||
import { normalizeWhois } from "./whois/normalize.js";
|
import { normalizeWhois } from "./whois/normalize";
|
||||||
import { WHOIS_TLD_EXCEPTIONS } from "./whois/servers.js";
|
import { WHOIS_TLD_EXCEPTIONS } from "./whois/servers";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* High-level lookup that prefers RDAP and falls back to WHOIS.
|
* High-level lookup that prefers RDAP and falls back to WHOIS.
|
||||||
@@ -69,9 +69,7 @@ export async function lookupDomain(
|
|||||||
const regUrl = ianaText
|
const regUrl = ianaText
|
||||||
? parseIanaRegistrationInfoUrl(ianaText)
|
? parseIanaRegistrationInfoUrl(ianaText)
|
||||||
: undefined;
|
: undefined;
|
||||||
const hint = regUrl
|
const hint = regUrl ? ` See registration info at ${regUrl}.` : "";
|
||||||
? ` See registration info at ${regUrl}.`
|
|
||||||
: "";
|
|
||||||
return {
|
return {
|
||||||
ok: false,
|
ok: false,
|
||||||
error: `No WHOIS server discovered for TLD '${tld}'. This registry may not publish public WHOIS over port 43.${hint}`,
|
error: `No WHOIS server discovered for TLD '${tld}'. This registry may not publish public WHOIS over port 43.${hint}`,
|
||||||
@@ -150,4 +148,4 @@ export async function isRegistered(
|
|||||||
return res.record.isRegistered === true;
|
return res.record.isRegistered === true;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type * from "./types.js";
|
export type * from "./types";
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/** biome-ignore-all lint/style/noNonNullAssertion: this is fine for tests */
|
/** biome-ignore-all lint/style/noNonNullAssertion: this is fine for tests */
|
||||||
|
|
||||||
import { expect, test } from "vitest";
|
import { expect, test } from "vitest";
|
||||||
import { toISO } from "./dates.js";
|
import { toISO } from "./dates";
|
||||||
|
|
||||||
test("toISO parses ISO and common whois formats", () => {
|
test("toISO parses ISO and common whois formats", () => {
|
||||||
const iso = toISO("2023-01-02T03:04:05Z");
|
const iso = toISO("2023-01-02T03:04:05Z");
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { expect, test } from "vitest";
|
import { expect, test } from "vitest";
|
||||||
import { extractTld, isLikelyDomain } from "./domain.js";
|
import { extractTld, isLikelyDomain } from "./domain";
|
||||||
|
|
||||||
test("extractTld basic", () => {
|
test("extractTld basic", () => {
|
||||||
expect(extractTld("example.com")).toBe("com");
|
expect(extractTld("example.com")).toBe("com");
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { withTimeout } from "../lib/async.js";
|
import { withTimeout } from "../lib/async";
|
||||||
import { DEFAULT_TIMEOUT_MS } from "../lib/constants.js";
|
import { DEFAULT_TIMEOUT_MS } from "../lib/constants";
|
||||||
import type { LookupOptions } from "../types.js";
|
import type { LookupOptions } from "../types";
|
||||||
|
|
||||||
// Use global fetch (Node 18+). For large JSON we keep it simple.
|
// Use global fetch (Node 18+). For large JSON we keep it simple.
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -1,6 +1,6 @@
|
|||||||
import { withTimeout } from "../lib/async.js";
|
import { withTimeout } from "../lib/async";
|
||||||
import { DEFAULT_TIMEOUT_MS } from "../lib/constants.js";
|
import { DEFAULT_TIMEOUT_MS } from "../lib/constants";
|
||||||
import type { LookupOptions } from "../types.js";
|
import type { LookupOptions } from "../types";
|
||||||
|
|
||||||
// Use global fetch (Node 18+). For large JSON we keep it simple.
|
// Use global fetch (Node 18+). For large JSON we keep it simple.
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { expect, test } from "vitest";
|
import { expect, test } from "vitest";
|
||||||
import { normalizeRdap } from "./normalize.js";
|
import { normalizeRdap } from "./normalize";
|
||||||
|
|
||||||
test("normalizeRdap maps registrar, contacts, nameservers, events, dnssec", () => {
|
test("normalizeRdap maps registrar, contacts, nameservers, events, dnssec", () => {
|
||||||
const rdap = {
|
const rdap = {
|
||||||
|
|||||||
+3
-10
@@ -1,11 +1,11 @@
|
|||||||
import { toISO } from "../lib/dates.js";
|
import { toISO } from "../lib/dates";
|
||||||
import { asDateLike, asString, asStringArray, uniq } from "../lib/text.js";
|
import { asDateLike, asString, asStringArray, uniq } from "../lib/text";
|
||||||
import type {
|
import type {
|
||||||
Contact,
|
Contact,
|
||||||
DomainRecord,
|
DomainRecord,
|
||||||
Nameserver,
|
Nameserver,
|
||||||
RegistrarInfo,
|
RegistrarInfo,
|
||||||
} from "../types.js";
|
} from "../types";
|
||||||
|
|
||||||
type RdapDoc = Record<string, unknown>;
|
type RdapDoc = Record<string, unknown>;
|
||||||
|
|
||||||
@@ -22,12 +22,6 @@ export function normalizeRdap(
|
|||||||
includeRaw = false,
|
includeRaw = false,
|
||||||
): DomainRecord {
|
): DomainRecord {
|
||||||
const doc = (rdap ?? {}) as RdapDoc;
|
const doc = (rdap ?? {}) as RdapDoc;
|
||||||
// Safe helpers for optional fields
|
|
||||||
const _get = (obj: unknown, path: string[]): unknown =>
|
|
||||||
path.reduce<unknown>(
|
|
||||||
(o, k) => ((o as RdapDoc)?.[k] as unknown) ?? undefined,
|
|
||||||
obj,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Prefer ldhName (punycode) and unicodeName if provided
|
// Prefer ldhName (punycode) and unicodeName if provided
|
||||||
const ldhName: string | undefined =
|
const ldhName: string | undefined =
|
||||||
@@ -254,7 +248,6 @@ function parseVcard(vcardArray: unknown): ParsedVCard {
|
|||||||
const out: ParsedVCard = {};
|
const out: ParsedVCard = {};
|
||||||
for (const e of entries) {
|
for (const e of entries) {
|
||||||
const key = e?.[0];
|
const key = e?.[0];
|
||||||
const _valueType = e?.[2];
|
|
||||||
const value = e?.[3];
|
const value = e?.[3];
|
||||||
if (!key) continue;
|
if (!key) continue;
|
||||||
switch (String(key).toLowerCase()) {
|
switch (String(key).toLowerCase()) {
|
||||||
|
|||||||
+3
-3
@@ -1,7 +1,7 @@
|
|||||||
import { createConnection } from "node:net";
|
import { createConnection } from "node:net";
|
||||||
import { withTimeout } from "../lib/async.js";
|
import { withTimeout } from "../lib/async";
|
||||||
import { DEFAULT_TIMEOUT_MS } from "../lib/constants.js";
|
import { DEFAULT_TIMEOUT_MS } from "../lib/constants";
|
||||||
import type { LookupOptions } from "../types.js";
|
import type { LookupOptions } from "../types";
|
||||||
|
|
||||||
export interface WhoisQueryResult {
|
export interface WhoisQueryResult {
|
||||||
serverQueried: string;
|
serverQueried: string;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import type { LookupOptions } from "../types.js";
|
import type { LookupOptions } from "../types";
|
||||||
import { whoisQuery } from "./client.js";
|
import { whoisQuery } from "./client";
|
||||||
import { WHOIS_TLD_EXCEPTIONS } from "./servers.js";
|
import { WHOIS_TLD_EXCEPTIONS } from "./servers";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse the IANA WHOIS response for a TLD and extract the WHOIS server
|
* Parse the IANA WHOIS response for a TLD and extract the WHOIS server
|
||||||
@@ -32,9 +32,7 @@ export function parseIanaWhoisServer(text: string): string | undefined {
|
|||||||
* remarks: Registration information: http://example.tld
|
* remarks: Registration information: http://example.tld
|
||||||
* url: https://registry.example
|
* url: https://registry.example
|
||||||
*/
|
*/
|
||||||
export function parseIanaRegistrationInfoUrl(
|
export function parseIanaRegistrationInfoUrl(text: string): string | undefined {
|
||||||
text: string,
|
|
||||||
): string | undefined {
|
|
||||||
const lines = String(text).split(/\r?\n/);
|
const lines = String(text).split(/\r?\n/);
|
||||||
for (const raw of lines) {
|
for (const raw of lines) {
|
||||||
const line = raw.trim();
|
const line = raw.trim();
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { expect, test } from "vitest";
|
import { expect, test } from "vitest";
|
||||||
import { normalizeWhois } from "./normalize.js";
|
import { normalizeWhois } from "./normalize";
|
||||||
|
|
||||||
test("WHOIS .de (DENIC-like) nserver lines", () => {
|
test("WHOIS .de (DENIC-like) nserver lines", () => {
|
||||||
const text = `
|
const text = `
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
import { toISO } from "../lib/dates.js";
|
import { toISO } from "../lib/dates";
|
||||||
import { isWhoisAvailable } from "../lib/domain.js";
|
import { isWhoisAvailable } from "../lib/domain";
|
||||||
import { parseKeyValueLines, uniq } from "../lib/text.js";
|
import { parseKeyValueLines, uniq } from "../lib/text";
|
||||||
import type {
|
import type {
|
||||||
Contact,
|
Contact,
|
||||||
DomainRecord,
|
DomainRecord,
|
||||||
Nameserver,
|
Nameserver,
|
||||||
RegistrarInfo,
|
RegistrarInfo,
|
||||||
} from "../types.js";
|
} from "../types";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert raw WHOIS text into our normalized DomainRecord.
|
* Convert raw WHOIS text into our normalized DomainRecord.
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"$schema": "https://json.schemastore.org/tsconfig",
|
|
||||||
"extends": "./tsconfig.json",
|
|
||||||
"include": ["src/**/*"],
|
|
||||||
"exclude": ["node_modules", "dist", "src/**/*.test.ts", "src/**/__tests__/**"]
|
|
||||||
}
|
|
||||||
+11
-9
@@ -1,17 +1,19 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://json.schemastore.org/tsconfig",
|
"$schema": "https://json.schemastore.org/tsconfig",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "ES2022",
|
"target": "esnext",
|
||||||
"module": "NodeNext",
|
"moduleDetection": "force",
|
||||||
"moduleResolution": "NodeNext",
|
"module": "preserve",
|
||||||
|
"moduleResolution": "bundler",
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"esModuleInterop": true,
|
|
||||||
"forceConsistentCasingInFileNames": true,
|
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"skipLibCheck": true,
|
"noUnusedLocals": true,
|
||||||
"outDir": "dist",
|
"declaration": true,
|
||||||
"rootDir": "src",
|
"emitDeclarationOnly": true,
|
||||||
"declaration": true
|
"esModuleInterop": true,
|
||||||
|
"isolatedModules": true,
|
||||||
|
"verbatimModuleSyntax": true,
|
||||||
|
"skipLibCheck": true
|
||||||
},
|
},
|
||||||
"include": ["src/**/*"],
|
"include": ["src/**/*"],
|
||||||
"exclude": ["node_modules", "dist"]
|
"exclude": ["node_modules", "dist"]
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
import { defineConfig } from "tsdown";
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
entry: ["src/index.ts"],
|
||||||
|
platform: "node",
|
||||||
|
dts: true,
|
||||||
|
external: ["psl"],
|
||||||
|
});
|
||||||
@@ -8,10 +8,5 @@ export default defineConfig({
|
|||||||
sequence: { hooks: "list" },
|
sequence: { hooks: "list" },
|
||||||
globals: false,
|
globals: false,
|
||||||
testTimeout: process.env.SMOKE === "1" ? 30000 : 5000,
|
testTimeout: process.env.SMOKE === "1" ? 30000 : 5000,
|
||||||
coverage: {
|
|
||||||
provider: "v8",
|
|
||||||
reportsDirectory: "coverage",
|
|
||||||
reporter: ["text", "lcov"],
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user