mirror of
https://github.com/jakejarvis/rdapper.git
synced 2025-10-18 20:14:27 -04:00
Remove fetchedAt
field from DomainRecord interface and related functions
This commit is contained in:
@@ -123,7 +123,6 @@ interface DomainRecord {
|
||||
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[];
|
||||
}
|
||||
```
|
||||
@@ -139,8 +138,7 @@ interface DomainRecord {
|
||||
"statuses": [{ "status": "clientTransferProhibited" }],
|
||||
"nameservers": [{ "host": "a.iana-servers.net" }, { "host": "b.iana-servers.net" }],
|
||||
"dnssec": { "enabled": true },
|
||||
"source": "rdap",
|
||||
"fetchedAt": "2025-01-01T00:00:00Z"
|
||||
"source": "rdap"
|
||||
}
|
||||
```
|
||||
|
||||
|
@@ -1,4 +1,3 @@
|
||||
import { toISO } from "./lib/dates";
|
||||
import { getDomainParts, isLikelyDomain } from "./lib/domain";
|
||||
import { getRdapBaseUrlsForTld } from "./rdap/bootstrap";
|
||||
import { fetchRdapDomain } from "./rdap/client";
|
||||
@@ -28,9 +27,6 @@ export async function lookupDomain(
|
||||
return { ok: false, error: "Input does not look like a domain" };
|
||||
}
|
||||
const { publicSuffix, tld } = getDomainParts(domain);
|
||||
// Avoid non-null assertion: fallback to a stable ISO string if parsing ever fails
|
||||
const now =
|
||||
toISO(new Date()) ?? new Date().toISOString().replace(/\.\d{3}Z$/, "Z");
|
||||
|
||||
// If WHOIS-only, skip RDAP path
|
||||
if (!opts?.whoisOnly) {
|
||||
@@ -50,7 +46,6 @@ export async function lookupDomain(
|
||||
tld,
|
||||
rdapEnriched.merged,
|
||||
[...tried, ...rdapEnriched.serversTried],
|
||||
now,
|
||||
!!opts?.includeRaw,
|
||||
);
|
||||
return { ok: true, record };
|
||||
@@ -106,7 +101,6 @@ export async function lookupDomain(
|
||||
tld,
|
||||
alt.text,
|
||||
alt.serverQueried,
|
||||
now,
|
||||
!!opts?.includeRaw,
|
||||
),
|
||||
};
|
||||
@@ -120,7 +114,6 @@ export async function lookupDomain(
|
||||
tld,
|
||||
res.text,
|
||||
res.serverQueried,
|
||||
now,
|
||||
!!opts?.includeRaw,
|
||||
);
|
||||
return { ok: true, record };
|
||||
|
@@ -59,13 +59,9 @@ test("normalizeRdap maps registrar, contacts, nameservers, events, dnssec", () =
|
||||
status: ["clientTransferProhibited"],
|
||||
port43: "whois.example-registrar.test",
|
||||
};
|
||||
const rec = normalizeRdap(
|
||||
"example.com",
|
||||
"com",
|
||||
rdap,
|
||||
["https://rdap.example/"],
|
||||
"2025-01-01T00:00:00Z",
|
||||
);
|
||||
const rec = normalizeRdap("example.com", "com", rdap, [
|
||||
"https://rdap.example/",
|
||||
]);
|
||||
expect(rec.domain).toBe("example.com");
|
||||
expect(rec.tld).toBe("com");
|
||||
expect(rec.registrar?.name).toBe("Registrar LLC");
|
||||
@@ -98,12 +94,8 @@ test("normalizeRdap derives privacyEnabled from registrant keywords", () => {
|
||||
},
|
||||
],
|
||||
};
|
||||
const rec = normalizeRdap(
|
||||
"example.com",
|
||||
"com",
|
||||
rdap,
|
||||
["https://rdap.example/"],
|
||||
"2025-01-01T00:00:00Z",
|
||||
);
|
||||
const rec = normalizeRdap("example.com", "com", rdap, [
|
||||
"https://rdap.example/",
|
||||
]);
|
||||
expect(rec.privacyEnabled).toBe(true);
|
||||
});
|
||||
|
@@ -19,7 +19,6 @@ export function normalizeRdap(
|
||||
tld: string,
|
||||
rdap: unknown,
|
||||
rdapServersTried: string[],
|
||||
fetchedAtISO: string,
|
||||
includeRaw = false,
|
||||
): DomainRecord {
|
||||
const doc = (rdap ?? {}) as RdapDoc;
|
||||
@@ -155,7 +154,6 @@ export function normalizeRdap(
|
||||
rawRdap: includeRaw ? rdap : undefined,
|
||||
rawWhois: undefined,
|
||||
source: "rdap",
|
||||
fetchedAt: fetchedAtISO,
|
||||
warnings: undefined,
|
||||
};
|
||||
|
||||
|
@@ -100,8 +100,6 @@ export interface DomainRecord {
|
||||
rawWhois?: string;
|
||||
/** Which source produced data */
|
||||
source: LookupSource;
|
||||
/** ISO 8601 timestamp at time of lookup */
|
||||
fetchedAt: string;
|
||||
/** Warnings generated during lookup */
|
||||
warnings?: string[];
|
||||
}
|
||||
|
@@ -9,13 +9,7 @@ Nserver: ns2.example.net
|
||||
Status: connect
|
||||
Changed: 2020-01-02
|
||||
`;
|
||||
const rec = normalizeWhois(
|
||||
"example.de",
|
||||
"de",
|
||||
text,
|
||||
"whois.denic.de",
|
||||
"2025-01-01T00:00:00Z",
|
||||
);
|
||||
const rec = normalizeWhois("example.de", "de", text, "whois.denic.de");
|
||||
expect(rec.nameservers && rec.nameservers.length === 2).toBe(true);
|
||||
expect(rec.nameservers?.[0].host).toBe("ns1.example.net");
|
||||
});
|
||||
@@ -36,13 +30,7 @@ Name servers:
|
||||
ns1.example.net 192.0.2.1
|
||||
ns2.example.net
|
||||
`;
|
||||
const rec = normalizeWhois(
|
||||
"example.uk",
|
||||
"uk",
|
||||
text,
|
||||
"whois.nic.uk",
|
||||
"2025-01-01T00:00:00Z",
|
||||
);
|
||||
const rec = normalizeWhois("example.uk", "uk", text, "whois.nic.uk");
|
||||
expect(rec.nameservers && rec.nameservers.length === 2).toBe(true);
|
||||
expect(Boolean(rec.creationDate)).toBe(true);
|
||||
expect(Boolean(rec.expirationDate)).toBe(true);
|
||||
@@ -58,13 +46,7 @@ test("WHOIS .jp JPRS style privacy redacted", () => {
|
||||
[Expires on] 2030/01/02
|
||||
[Status] Active
|
||||
`;
|
||||
const rec = normalizeWhois(
|
||||
"example.jp",
|
||||
"jp",
|
||||
text,
|
||||
"whois.jprs.jp",
|
||||
"2025-01-01T00:00:00Z",
|
||||
);
|
||||
const rec = normalizeWhois("example.jp", "jp", text, "whois.jprs.jp");
|
||||
expect(Boolean(rec.creationDate)).toBe(true);
|
||||
expect(Boolean(rec.expirationDate)).toBe(true);
|
||||
expect(Boolean(rec.statuses)).toBe(true);
|
||||
@@ -84,13 +66,7 @@ Name Server: NS1.EXAMPLE.IO
|
||||
Name Server: NS2.EXAMPLE.IO
|
||||
DNSSEC: unsigned
|
||||
`;
|
||||
const rec = normalizeWhois(
|
||||
"example.io",
|
||||
"io",
|
||||
text,
|
||||
"whois.nic.io",
|
||||
"2025-01-01T00:00:00Z",
|
||||
);
|
||||
const rec = normalizeWhois("example.io", "io", text, "whois.nic.io");
|
||||
expect(Boolean(rec.creationDate)).toBe(true);
|
||||
expect(Boolean(rec.expirationDate)).toBe(true);
|
||||
expect(rec.nameservers && rec.nameservers.length === 2).toBe(true);
|
||||
@@ -106,13 +82,7 @@ Creation Date: 2020-04-24T15:03:39+0000
|
||||
Registrar Registration Expiration Date: 2027-04-23T00:00:00+0000
|
||||
Registrar: Registrar LLC
|
||||
`;
|
||||
const rec = normalizeWhois(
|
||||
"example.us",
|
||||
"us",
|
||||
text,
|
||||
"whois.registrar.test",
|
||||
"2025-01-01T00:00:00Z",
|
||||
);
|
||||
const rec = normalizeWhois("example.us", "us", text, "whois.registrar.test");
|
||||
expect(Boolean(rec.expirationDate)).toBe(true);
|
||||
expect(rec.expirationDate).toBe("2027-04-23T00:00:00Z");
|
||||
});
|
||||
@@ -127,13 +97,7 @@ Domain record activated: 22-Jun-1987
|
||||
Domain record last updated: 02-Jul-2025
|
||||
Domain expires: 31-Jul-2026
|
||||
`;
|
||||
const rec = normalizeWhois(
|
||||
"tufts.edu",
|
||||
"edu",
|
||||
text,
|
||||
"whois.educause.edu",
|
||||
"2025-01-01T00:00:00Z",
|
||||
);
|
||||
const rec = normalizeWhois("tufts.edu", "edu", text, "whois.educause.edu");
|
||||
expect(rec.creationDate).toBe("1987-06-22T00:00:00Z");
|
||||
expect(rec.updatedDate).toBe("2025-07-02T00:00:00Z");
|
||||
expect(rec.expirationDate).toBe("2026-07-31T00:00:00Z");
|
||||
@@ -163,7 +127,6 @@ Domain Status: clientTransferProhibited https://icann.org/epp#clientTransferProh
|
||||
"com",
|
||||
text,
|
||||
"whois.verisign-grs.com",
|
||||
"2025-01-01T00:00:00Z",
|
||||
);
|
||||
expect(Boolean(rec.creationDate)).toBe(true);
|
||||
expect(Boolean(rec.expirationDate)).toBe(true);
|
||||
@@ -183,7 +146,6 @@ Registrant Organization: Example Org
|
||||
"com",
|
||||
text,
|
||||
"whois.verisign-grs.com",
|
||||
"2025-01-01T00:00:00Z",
|
||||
);
|
||||
expect(rec.privacyEnabled).toBe(true);
|
||||
});
|
||||
|
@@ -18,7 +18,6 @@ export function normalizeWhois(
|
||||
tld: string,
|
||||
whoisText: string,
|
||||
whoisServer: string | undefined,
|
||||
fetchedAtISO: string,
|
||||
includeRaw = false,
|
||||
): DomainRecord {
|
||||
const map = parseKeyValueLines(whoisText);
|
||||
@@ -177,7 +176,6 @@ export function normalizeWhois(
|
||||
rawRdap: undefined,
|
||||
rawWhois: includeRaw ? whoisText : undefined,
|
||||
source: "whois",
|
||||
fetchedAt: fetchedAtISO,
|
||||
warnings: undefined,
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user