mirror of
https://github.com/jakejarvis/rdapper.git
synced 2025-10-18 20:14:27 -04:00
Add includeRaw option to CLI and API: enable inclusion of raw RDAP/WHOIS data in results
This commit is contained in:
@@ -54,6 +54,7 @@ await isAvailable("likely-unregistered-thing-320485230458.com"); // => false
|
||||
- `followWhoisReferral?: boolean` – Follow registrar referral from the TLD WHOIS (default `true`).
|
||||
- `customBootstrapUrl?: string` – Override RDAP bootstrap URL.
|
||||
- `whoisHints?: Record<string, string>` – Override/add authoritative WHOIS per TLD (keys are lowercase TLDs, values may include or omit `whois://`).
|
||||
- `includeRaw?: boolean` – Include `rawRdap`/`rawWhois` in the returned record (default `false`).
|
||||
- `signal?: AbortSignal` – Optional cancellation signal.
|
||||
|
||||
### `DomainRecord` schema
|
||||
@@ -95,8 +96,8 @@ interface DomainRecord {
|
||||
}>;
|
||||
whoisServer?: string; // authoritative WHOIS queried (if any)
|
||||
rdapServers?: string[]; // RDAP base URLs tried
|
||||
rawRdap?: unknown; // raw RDAP JSON (RDAP source)
|
||||
rawWhois?: string; // raw WHOIS text (WHOIS source)
|
||||
rawRdap?: unknown; // raw RDAP JSON (only when options.includeRaw)
|
||||
rawWhois?: string; // raw WHOIS text (only when options.includeRaw)
|
||||
source: "rdap" | "whois"; // which path produced data
|
||||
fetchedAt: string; // ISO 8601 timestamp
|
||||
warnings?: string[];
|
||||
|
5
cli.mjs
5
cli.mjs
@@ -2,9 +2,9 @@
|
||||
|
||||
// Quick informal test runner for rdapper
|
||||
// Usage:
|
||||
// npm run build && node dev.mjs example.com
|
||||
// npm run build && node cli.mjs example.com
|
||||
// Env:
|
||||
// RDAP_ONLY=1 | WHOIS_ONLY=1 | TIMEOUT_MS=15000 | FOLLOW_REFERRAL=0
|
||||
// RDAP_ONLY=1 | WHOIS_ONLY=1 | TIMEOUT_MS=15000 | FOLLOW_REFERRAL=0 | INCLUDE_RAW=1
|
||||
|
||||
import { lookupDomain } from "./dist/index.js";
|
||||
|
||||
@@ -15,6 +15,7 @@ const options = {
|
||||
followWhoisReferral: process.env.FOLLOW_REFERRAL !== "0",
|
||||
rdapOnly: process.env.RDAP_ONLY === "1",
|
||||
whoisOnly: process.env.WHOIS_ONLY === "1",
|
||||
includeRaw: process.env.INCLUDE_RAW === "1",
|
||||
};
|
||||
|
||||
const result = await lookupDomain(domain, options);
|
||||
|
@@ -43,6 +43,7 @@ export async function lookupDomain(
|
||||
json,
|
||||
tried,
|
||||
now,
|
||||
!!opts?.includeRaw,
|
||||
);
|
||||
return { ok: true, record };
|
||||
} catch {
|
||||
@@ -105,6 +106,7 @@ export async function lookupDomain(
|
||||
res.text,
|
||||
res.serverQueried,
|
||||
now,
|
||||
!!opts?.includeRaw,
|
||||
);
|
||||
return { ok: true, record };
|
||||
} catch (err: unknown) {
|
||||
|
@@ -19,6 +19,7 @@ export function normalizeRdap(
|
||||
rdap: unknown,
|
||||
rdapServersTried: string[],
|
||||
fetchedAtISO: string,
|
||||
includeRaw = false,
|
||||
): DomainRecord {
|
||||
const doc = (rdap ?? {}) as RdapDoc;
|
||||
// Safe helpers for optional fields
|
||||
@@ -146,7 +147,7 @@ export function normalizeRdap(
|
||||
contacts,
|
||||
whoisServer,
|
||||
rdapServers: rdapServersTried,
|
||||
rawRdap: rdap,
|
||||
rawRdap: includeRaw ? rdap : undefined,
|
||||
rawWhois: undefined,
|
||||
source: "rdap",
|
||||
fetchedAt: fetchedAtISO,
|
||||
|
@@ -87,6 +87,7 @@ export interface LookupOptions {
|
||||
customBootstrapUrl?: string; // override IANA bootstrap
|
||||
// WHOIS discovery and query tuning
|
||||
whoisHints?: Record<string, string>; // override/add authoritative WHOIS per TLD
|
||||
includeRaw?: boolean; // include rawRdap/rawWhois in results (default false)
|
||||
signal?: AbortSignal;
|
||||
}
|
||||
|
||||
|
@@ -18,6 +18,7 @@ export function normalizeWhois(
|
||||
whoisText: string,
|
||||
whoisServer: string | undefined,
|
||||
fetchedAtISO: string,
|
||||
includeRaw = false,
|
||||
): DomainRecord {
|
||||
const map = parseKeyValueLines(whoisText);
|
||||
|
||||
@@ -151,7 +152,7 @@ export function normalizeWhois(
|
||||
whoisServer,
|
||||
rdapServers: undefined,
|
||||
rawRdap: undefined,
|
||||
rawWhois: whoisText,
|
||||
rawWhois: includeRaw ? whoisText : undefined,
|
||||
source: "whois",
|
||||
fetchedAt: fetchedAtISO,
|
||||
warnings: undefined,
|
||||
|
Reference in New Issue
Block a user