export namespace ZoneRecordTypings { type Name = string; type TTL = string; /** * every record can have a name and ttl * every record except SOA has values */ export interface BaseRecord { name: string; ttl?: DirectiveValueTypings.TTLInput; /** these are the values after the type */ values: string[]; } export interface AnyIndexSignature extends BaseRecord { [key: string]: any; } /** * @name StartOfAuthority * @description * - authoritative properties of a DNS zone * - primary name server * - email of domain administrator * - domain serial number * - several timers relating to refreshing the zone */ export interface SOA { name: string; minimum: number; expire: number; retry: number; refresh: number; serial: number; rname: string; mname: string; ttl?: number | string; [key: string]: unknown; } /** * @name NameServer * @description delegates a DNS zone to use the given authoritative name servers * @format `$start [host]` */ export interface NS extends BaseRecord { host: string; /** values after `aaaa`: [_name, ttl_, **host**] */ values: [Name, TTL, string]; } /** * @name ServerSelectionRecord * * @description finds hosts running services in a domain. An SRV record will normally * @template ..domain * @example _sips._tcp.example.org // for the secure SIP protocol * @example _http._tcp.example.com // if HTTP used SRV records */ export interface SRV extends BaseRecord { target: string; priority: number; weight: number; port: number; } /** * @alias IPV4 * @name AddressRecord * @description maps a domain name to an IPV4 address * @format `$start [ip]` */ export interface A extends BaseRecord { ip: string; /** values after `aaaa`: [_name, ttl_, **ipv4**] */ values: [Name, TTL, string]; } /** * @alias IPV6 * @name IPv6AddressRecord * @description maps a domain name to an IPv6 address * @format `$start [ip]` */ export interface AAAA extends BaseRecord { ip: string; /** values after `aaaa`: [_name, ttl_, **ipv6**] */ values: [Name, TTL, string]; } /** * @alias CanonicalName * @description maps an alias to its real name * @format `$start [alias]` * @example `www CNAME igloo.com.` */ export interface CNAME extends BaseRecord { alias: string; /** values after `cname`: [_name, ttl_, **alias**] */ values: [Name, TTL, string]; } /** * @alias MailExchanger * @description specifies where mail to a domain is sent * @format `$start [preference][host]` * @example @ MX 20 mail2.igloo.com */ export interface MX extends BaseRecord { preference: number; host: string; /** values after `mx`: [_name, ttl_, **preference host**] */ values: [Name, TTL, string, string]; } /** * @name CertificationAuthorityAuthorization * @description constraining acceptable CAs for a host/domain */ export interface CAA extends BaseRecord { flags: number; tag: string; data: string; /** values after `caa`: [_name, ttl_, **flags, tag, data**] */ values: [Name, TTL, string, string, string]; } /** * @name TextRecord * @description stores text strings */ export interface TXT extends BaseRecord { txt: string; /** values after `txt`: [_name, ttl_, **data**] */ values: [Name, TTL, string]; } /** * @alias Reverse-lookup_Pointer_Records * @name PointerRecord * @description * - pointer to a canonical name. * - Unlike a CNAME, DNS processing stops and just the name is returned * - the most common use is for implementing reverse DNS lookups, but other uses include such things as DNS-SD. */ export interface PTR extends BaseRecord { host: string; fullname: string; /** values after `ptr`: [_name, ttl_, **flags, tag, data**] */ values: [Name, TTL, string, string]; } /** * @alias SenderPolicyFramework * @description * - an alternative to storing SPF data in TXT records, using the same format. * - support for it was discontinued in RFC 7208 due to widespread lack of support. */ export interface SPF extends BaseRecord { data: string; /** * values after `spf`: [_name, ttl_, **data**] * @example values: [Name, TTL, string] */ values: [string]; } /** * @name NamingAuthorityPointer * @description regular-expression-based rewriting of domain names which can then be used as URIs, further domain names to lookups, etc. */ export interface NAPTR extends BaseRecord { order: number; preference: number; flags: string; services: string; regexp: string; replacement: string; } } export namespace DirectiveValueTypings { export type Origin = string; /** * @example 1 * @example 1h */ export type TTLInput = string; export type TTLValue = number; } export namespace ParsedTypings { /** @private */ type IndexedObj = { NS?: ZoneRecordTypings.NS[]; SRV?: ZoneRecordTypings.SRV[]; A?: ZoneRecordTypings.A[]; AAAA?: ZoneRecordTypings.AAAA[]; CNAME?: ZoneRecordTypings.CNAME[]; MX?: ZoneRecordTypings.MX[]; CAA?: ZoneRecordTypings.CAA[]; TXT?: ZoneRecordTypings.TXT[]; PTR?: ZoneRecordTypings.PTR[]; SPF?: ZoneRecordTypings.SPF[]; NAPTR?: ZoneRecordTypings.NAPTR[]; }; export type Obj = IndexedObj & { SOA?: ZoneRecordTypings.SOA; $ORIGIN: DirectiveValueTypings.Origin; $TTL?: DirectiveValueTypings.TTLValue; }; export type ByType = { NS: ZoneRecordTypings.NS; SRV: ZoneRecordTypings.SRV; A: ZoneRecordTypings.A; AAAA: ZoneRecordTypings.AAAA; CNAME: ZoneRecordTypings.CNAME; MX: ZoneRecordTypings.MX; CAA: ZoneRecordTypings.CAA; TXT: ZoneRecordTypings.TXT; PTR: ZoneRecordTypings.PTR; SPF: ZoneRecordTypings.SPF; NAPTR: ZoneRecordTypings.NAPTR; }; }