Add includeRaw option to CLI and API: enable inclusion of raw RDAP/WHOIS data in results

This commit is contained in:
2025-09-24 19:24:57 -04:00
parent 05445ef831
commit fda6d09096
6 changed files with 13 additions and 6 deletions
+2
View File
@@ -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) {
+2 -1
View File
@@ -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,
+1
View File
@@ -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;
}
+2 -1
View File
@@ -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,