rdapper
Version:
🎩 RDAP/WHOIS fetcher, parser, and normalizer for Node
99 lines • 2.78 kB
TypeScript
//#region src/types.d.ts
type LookupSource = "rdap" | "whois";
interface RegistrarInfo {
name?: string;
ianaId?: string;
url?: string;
email?: string;
phone?: string;
}
interface Contact {
type: "registrant" | "admin" | "tech" | "billing" | "abuse" | "registrar" | "reseller" | "unknown";
name?: string;
organization?: string;
email?: string | string[];
phone?: string | string[];
fax?: string | string[];
street?: string[];
city?: string;
state?: string;
postalCode?: string;
country?: string;
countryCode?: string;
}
interface Nameserver {
host: string;
ipv4?: string[];
ipv6?: string[];
}
interface StatusEvent {
status: string;
description?: string;
raw?: string;
}
interface DomainRecord {
domain: string;
tld: string;
isRegistered: boolean;
isIDN?: boolean;
unicodeName?: string;
punycodeName?: string;
registry?: string;
registrar?: RegistrarInfo;
reseller?: string;
statuses?: StatusEvent[];
creationDate?: string;
updatedDate?: string;
expirationDate?: string;
deletionDate?: string;
transferLock?: boolean;
dnssec?: {
enabled: boolean;
dsRecords?: Array<{
keyTag?: number;
algorithm?: number;
digestType?: number;
digest?: string;
}>;
};
nameservers?: Nameserver[];
contacts?: Contact[];
whoisServer?: string;
rdapServers?: string[];
rawRdap?: unknown;
rawWhois?: string;
source: LookupSource;
fetchedAt: string;
warnings?: string[];
}
interface LookupOptions {
timeoutMs?: number;
rdapOnly?: boolean;
whoisOnly?: boolean;
followWhoisReferral?: boolean;
customBootstrapUrl?: string;
whoisHints?: Record<string, string>;
includeRaw?: boolean;
signal?: AbortSignal;
}
interface LookupResult {
ok: boolean;
record?: DomainRecord;
error?: string;
}
type FetchLike = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
//#endregion
//#region src/index.d.ts
/**
* High-level lookup that prefers RDAP and falls back to WHOIS.
* Ensures a standardized DomainRecord, independent of the source.
*/
declare function lookupDomain(domain: string, opts?: LookupOptions): Promise<LookupResult>;
/** Determine if a domain appears available (not registered).
* Performs a lookup and resolves to a boolean. Rejects on lookup error. */
declare function isAvailable(domain: string, opts?: LookupOptions): Promise<boolean>;
/** Determine if a domain appears registered.
* Performs a lookup and resolves to a boolean. Rejects on lookup error. */
declare function isRegistered(domain: string, opts?: LookupOptions): Promise<boolean>;
//#endregion
export { Contact, DomainRecord, FetchLike, LookupOptions, LookupResult, LookupSource, Nameserver, RegistrarInfo, StatusEvent, isAvailable, isRegistered, lookupDomain };