kikloper-domain-check
v0.1.0
Published
Domain registration and SSL certificate information
Readme
domain-check
Fetch SSL and domain expiry dates for a domain. One call, no monitoring.
A zero-dependency TypeScript library that reads a domain's SSL certificate dates and its registration (RDAP) dates. Pure input → output: no database, no state, no scheduling, no notifications. What you do with the result is up to you.
Install
npm install @kikloper/domain-checkRequires Node.js 20+. Ships as ESM only.
Usage
import { lookup } from "@kikloper/domain-check";
const result = await lookup("example.com");
console.log(result.ssl?.validTo); // SSL certificate expiry
console.log(result.domainInfo?.expiresAt); // domain registration expirylookup() never throws. If either the SSL or RDAP lookup fails, that field
is null and the reason is recorded in errors — the other field is
unaffected. So both fields need a null check:
const result = await lookup("example.com");
if (result.ssl) {
console.log(`SSL expires ${result.ssl.validTo.toISOString()}`);
} else {
console.warn(`SSL lookup failed: ${result.errors.ssl}`);
}API
Main
| Export | Signature | Description |
| --- | --- | --- |
| lookup | (domain: string, opts?: LookupOptions) => Promise<LookupResult> | Runs SSL and RDAP lookups in parallel. Never throws. |
| getSslInfo | (domain: string, opts?: SslLookupOptions) => Promise<SslInfo> | Fetches TLS certificate dates/issuer/subject. Throws on failure. |
| getDomainInfo | (domain: string, opts?: DomainLookupOptions) => Promise<DomainInfo> | Fetches registrar/registration/expiry via RDAP. Throws on failure. |
Low-level (SSRF guard)
Exported so the guard can be reused independently. Most callers only need
lookup().
| Export | Signature | Description |
| --- | --- | --- |
| normalizeDomain | (input: string) => string | Strips scheme/port/path/query, normalizes to a bare ASCII hostname. |
| resolveAndValidate | (hostname: string) => Promise<string> | Resolves a hostname once and rejects private/reserved IPs. |
| safeRequest | (url: string, opts?: SafeRequestOptions) => Promise<SafeResponse> | SSRF-safe HTTP(S) request with manually re-validated redirects. |
| createPinnedAgent | (hostname: string, ip: string) => https.Agent | Builds an https.Agent pinned to an already-resolved IP. |
Types
SslInfo, DomainInfo, LookupResult, LookupOptions, SslLookupOptions,
DomainLookupOptions, RequestOptions are all exported from the package
root.
Registration data coverage
RDAP is the authoritative source for registration data, but coverage varies
by registry. Some TLDs omit the expiry event entirely, so
domainInfo.expiresAt can be null even when the lookup itself succeeded.
If you pass fallbackApiKey, the library falls back to a secondary WHOIS
API when RDAP returns no expiry date:
const result = await lookup("example.com", {
fallbackApiKey: process.env.WHOIS_API_KEY,
});Without that option, no request is ever made to any third-party service — only the IANA bootstrap registry and the registry's own RDAP server.
Design notes
- No runtime dependencies. Only
node:tls,node:https,node:http,node:dns,node:net. - SSRF-safe by construction. DNS is resolved exactly once per hop and the connection is pinned to that resolved IP directly, closing the DNS-rebinding TOCTOU window that a "resolve, validate, then fetch (which resolves again)" guard leaves open. Every address returned for a hostname is validated, not just the first.
- RDAP over WHOIS. Registration data comes from RDAP via the IANA bootstrap registry — a structured, machine-readable protocol, not screen-scraped WHOIS text.
Known limits
- RDAP coverage varies by TLD; see above.
- Certificate dates are read as presented. Expired or otherwise invalid certificates are reported rather than rejected — the goal is to read the dates, not to validate trust.
- Bare IP addresses and single-label hosts (
localhost,intranet) are rejected by design. - Only ports 80 and 443 are connectable, on every redirect hop.
More features
This package intentionally does one thing: pull certificate and registration expiry dates for a domain, once, on demand. It does not poll, persist, or alert you when something is about to expire.
If you want that part handled for you, Kikloper watches SSL certificates and domain expiry dates continuously and notifies you before they lapse.
License
MIT © Webicha LLC
