UNPKG

@xyz/whois

Version:

A powerful TypeScript/JavaScript tool for comprehensive domain analysis, featuring detailed WHOIS data with registration dates, registrars, and domain status. Offers SSL certificate extraction (with PEM support), DNS records, and server details. Includes

89 lines (88 loc) 2.77 kB
import * as dns from 'dns'; import { WhoisData } from './src/whois'; interface SslData { subject: { [key: string]: string | string[]; }; issuer: { [key: string]: string | string[]; }; valid: boolean; validFrom: number; validTo: number; certificate?: string; intermediateCertificate?: string; rootCertificate?: string; details?: { issuer: string; subject: string; validFrom: Date; validTo: Date; }; } interface DomainInfo { sslData: SslData; serverData: string | undefined; dnsData: { A: string[]; CNAME: string | null; TXT: string[]; MX: Array<{ exchange: string; priority: number; }>; NS: string[]; SOA: dns.SoaRecord | null; } | undefined; httpStatus: number | undefined; whoisData?: WhoisData; } export interface RequestOptions { /** Timeout in milliseconds for HTTP requests */ timeout?: number; /** Custom headers to include in HTTP requests */ headers?: Record<string, string>; /** Whether to follow redirects in HTTP requests */ followRedirects?: boolean; /** Maximum number of redirects to follow */ maxRedirects?: number; debug?: boolean; } /** * Formats a given domain to `example.com` format. * @param domain The domain to format. * @returns The formatted domain. */ export declare function formatDomain(domain: string): string; /** * Extracts the subdomain from a given domain. * @param domain The domain to extract the subdomain from. * @returns The subdomain or null if no subdomain is present. */ export declare function extractSubdomain(domain: string): string | null; /** * Gets the root domain (e.g., example.com) from a domain that may include a subdomain. * @param domain The domain to extract the root domain from. * @returns The root domain. */ export declare function getRootDomain(domain: string): string; /** * Checks if the given domain is valid. * @param domain The domain to check. * @returns True if the domain is valid, false otherwise. */ export declare const checkDomain: (domain: string) => boolean; /** * converts a date string to a timestamp * @param dateString * @returns timestamp */ export declare function dateToTimestamp(dateString: string): number; /** * Fetches SSL, server, and DNS data for the given domain. * @param domain The domain to fetch the information for. * @param options Optional request configuration * @returns A Promise that resolves to an object containing the SSL, server, and DNS data. */ export declare function fetchDomainInfo(domain: string, options?: RequestOptions): Promise<DomainInfo | undefined>; export { WhoisData } from './src/whois';