rdapper 0.1.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -49,6 +49,10 @@ await isAvailable("likely-unregistered-thing-320485230458.com"); // => false
49
49
  - `rdapOnly?: boolean` – Only attempt RDAP; do not fall back to WHOIS.
50
50
  - `whoisOnly?: boolean` – Skip RDAP and query WHOIS directly.
51
51
  - `followWhoisReferral?: boolean` – Follow registrar referral from the TLD WHOIS (default `true`).
52
+ - `maxWhoisReferralHops?: number` – Maximum registrar WHOIS referral hops to follow (default `2`).
53
+ - `rdapFollowLinks?: boolean` – Follow related/entity RDAP links to enrich data (default `true`).
54
+ - `maxRdapLinkHops?: number` – Maximum RDAP related link hops to follow (default `2`).
55
+ - `rdapLinkRels?: string[]` – RDAP link rel values to consider (default `["related","entity","registrar","alternate"]`).
52
56
  - `customBootstrapUrl?: string` – Override RDAP bootstrap URL.
53
57
  - `whoisHints?: Record<string, string>` – Override/add authoritative WHOIS per TLD (keys are lowercase TLDs, values may include or omit `whois://`).
54
58
  - `includeRaw?: boolean` – Include `rawRdap`/`rawWhois` in the returned record (default `false`).
@@ -144,10 +148,11 @@ interface DomainRecord {
144
148
  - RDAP
145
149
  - Discovers base URLs for the TLD via IANA’s RDAP bootstrap JSON.
146
150
  - Tries each base until one responds successfully; parses standard RDAP domain JSON.
151
+ - Optionally follows related/entity links to registrar RDAP resources and merges results (bounded by hop limits).
147
152
  - Normalizes registrar (from `entities`), contacts (vCard), nameservers (`ipAddresses`), events (created/changed/expiration), statuses, and DNSSEC (`secureDNS`).
148
153
  - WHOIS
149
154
  - Discovers the authoritative TLD WHOIS via `whois.iana.org` (TCP 43), with curated exceptions for tricky zones and public SLDs.
150
- - Queries the TLD WHOIS; if a registrar referral is present and `followWhoisReferral !== false`, follows one hop to the registrar WHOIS.
155
+ - Queries the TLD WHOIS and follows registrar referrals recursively up to `maxWhoisReferralHops` (unless disabled).
151
156
  - Normalizes common key/value variants across gTLD/ccTLD formats (dates, statuses, nameservers, contacts). Availability is inferred from common phrases (best‑effort heuristic).
152
157
 
153
158
  Timeouts are enforced per request using a simple race against `timeoutMs` (default 15s). All network I/O is performed with global `fetch` (RDAP) and a raw TCP socket (WHOIS).
package/dist/index.d.ts CHANGED
@@ -1,13 +1,103 @@
1
- import type { LookupOptions, LookupResult } from "./types.js";
1
+ //#region src/types.d.ts
2
+ type LookupSource = "rdap" | "whois";
3
+ interface RegistrarInfo {
4
+ name?: string;
5
+ ianaId?: string;
6
+ url?: string;
7
+ email?: string;
8
+ phone?: string;
9
+ }
10
+ interface Contact {
11
+ type: "registrant" | "admin" | "tech" | "billing" | "abuse" | "registrar" | "reseller" | "unknown";
12
+ name?: string;
13
+ organization?: string;
14
+ email?: string | string[];
15
+ phone?: string | string[];
16
+ fax?: string | string[];
17
+ street?: string[];
18
+ city?: string;
19
+ state?: string;
20
+ postalCode?: string;
21
+ country?: string;
22
+ countryCode?: string;
23
+ }
24
+ interface Nameserver {
25
+ host: string;
26
+ ipv4?: string[];
27
+ ipv6?: string[];
28
+ }
29
+ interface StatusEvent {
30
+ status: string;
31
+ description?: string;
32
+ raw?: string;
33
+ }
34
+ interface DomainRecord {
35
+ domain: string;
36
+ tld: string;
37
+ isRegistered: boolean;
38
+ isIDN?: boolean;
39
+ unicodeName?: string;
40
+ punycodeName?: string;
41
+ registry?: string;
42
+ registrar?: RegistrarInfo;
43
+ reseller?: string;
44
+ statuses?: StatusEvent[];
45
+ creationDate?: string;
46
+ updatedDate?: string;
47
+ expirationDate?: string;
48
+ deletionDate?: string;
49
+ transferLock?: boolean;
50
+ dnssec?: {
51
+ enabled: boolean;
52
+ dsRecords?: Array<{
53
+ keyTag?: number;
54
+ algorithm?: number;
55
+ digestType?: number;
56
+ digest?: string;
57
+ }>;
58
+ };
59
+ nameservers?: Nameserver[];
60
+ contacts?: Contact[];
61
+ whoisServer?: string;
62
+ rdapServers?: string[];
63
+ rawRdap?: unknown;
64
+ rawWhois?: string;
65
+ source: LookupSource;
66
+ fetchedAt: string;
67
+ warnings?: string[];
68
+ }
69
+ interface LookupOptions {
70
+ timeoutMs?: number;
71
+ rdapOnly?: boolean;
72
+ whoisOnly?: boolean;
73
+ followWhoisReferral?: boolean;
74
+ maxWhoisReferralHops?: number;
75
+ rdapFollowLinks?: boolean;
76
+ maxRdapLinkHops?: number;
77
+ rdapLinkRels?: string[];
78
+ customBootstrapUrl?: string;
79
+ whoisHints?: Record<string, string>;
80
+ includeRaw?: boolean;
81
+ signal?: AbortSignal;
82
+ }
83
+ interface LookupResult {
84
+ ok: boolean;
85
+ record?: DomainRecord;
86
+ error?: string;
87
+ }
88
+ type FetchLike = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
89
+ //#endregion
90
+ //#region src/index.d.ts
2
91
  /**
3
92
  * High-level lookup that prefers RDAP and falls back to WHOIS.
4
93
  * Ensures a standardized DomainRecord, independent of the source.
5
94
  */
6
- export declare function lookupDomain(domain: string, opts?: LookupOptions): Promise<LookupResult>;
95
+ declare function lookupDomain(domain: string, opts?: LookupOptions): Promise<LookupResult>;
7
96
  /** Determine if a domain appears available (not registered).
8
97
  * Performs a lookup and resolves to a boolean. Rejects on lookup error. */
9
- export declare function isAvailable(domain: string, opts?: LookupOptions): Promise<boolean>;
98
+ declare function isAvailable(domain: string, opts?: LookupOptions): Promise<boolean>;
10
99
  /** Determine if a domain appears registered.
11
100
  * Performs a lookup and resolves to a boolean. Rejects on lookup error. */
12
- export declare function isRegistered(domain: string, opts?: LookupOptions): Promise<boolean>;
13
- export type * from "./types.js";
101
+ declare function isRegistered(domain: string, opts?: LookupOptions): Promise<boolean>;
102
+ //#endregion
103
+ export { Contact, DomainRecord, FetchLike, LookupOptions, LookupResult, LookupSource, Nameserver, RegistrarInfo, StatusEvent, isAvailable, isRegistered, lookupDomain };