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