mirror of
https://github.com/jakejarvis/rdapper.git
synced 2026-09-23 01:25:31 -04:00
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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user