New privacyEnabled field to detect redaction based on keyword heuristics

Updated the DomainRecord interface to include detailed comments for clarity and added a new privacyEnabled field to indicate if the registrant's information is privacy-redacted. Enhanced normalization functions for both RDAP and WHOIS to derive the privacy flag based on registrant keywords. Updated tests to verify the correct functionality of privacy detection in both normalization processes. Additionally, the README was updated to reflect the inclusion of the privacy flag in the normalized output.
This commit is contained in:
2025-10-08 21:31:21 -04:00
parent 57209eae39
commit 2c9904e5e8
7 changed files with 146 additions and 26 deletions
+18
View File
@@ -169,3 +169,21 @@ Domain Status: clientTransferProhibited https://icann.org/epp#clientTransferProh
expect(Boolean(rec.expirationDate)).toBe(true);
expect(rec.source).toBe("whois");
});
test("WHOIS derives privacyEnabled from registrant keywords", () => {
const text = `
Domain Name: EXAMPLE.COM
Registrar WHOIS Server: whois.registrar.test
Registrar URL: http://www.registrar.test
Registrant Name: REDACTED FOR PRIVACY
Registrant Organization: Example Org
`;
const rec = normalizeWhois(
"example.com",
"com",
text,
"whois.verisign-grs.com",
"2025-01-01T00:00:00Z",
);
expect(rec.privacyEnabled).toBe(true);
});
+11
View File
@@ -1,5 +1,6 @@
import { toISO } from "../lib/dates";
import { isWhoisAvailable } from "../lib/domain";
import { isPrivacyName } from "../lib/privacy";
import { parseKeyValueLines, uniq } from "../lib/text";
import type {
Contact,
@@ -132,6 +133,15 @@ export function normalizeWhois(
// Contacts: best-effort parse common keys
const contacts = collectContacts(map);
// Derive privacy flag from registrant name/org keywords
const registrant = contacts?.find((c) => c.type === "registrant");
const privacyEnabled = !!(
registrant &&
(
[registrant.name, registrant.organization].filter(Boolean) as string[]
).some(isPrivacyName)
);
const dnssecRaw = (map.dnssec?.[0] || "").toLowerCase();
const dnssec = dnssecRaw
? { enabled: /signed|yes|true/.test(dnssecRaw) }
@@ -161,6 +171,7 @@ export function normalizeWhois(
dnssec,
nameservers,
contacts,
privacyEnabled: privacyEnabled ? true : undefined,
whoisServer,
rdapServers: undefined,
rawRdap: undefined,