import * as plugins from '../../plugins.js'; import { DKIMCreator } from '../security/classes.dkimcreator.js'; /** * Interface for DNS record information */ export interface IDnsRecord { name: string; type: string; value: string; ttl?: number; dnsSecEnabled?: boolean; } /** * Interface for DNS lookup options */ export interface IDnsLookupOptions { /** Cache time to live in milliseconds, 0 to disable caching */ cacheTtl?: number; /** Timeout for DNS queries in milliseconds */ timeout?: number; } /** * Interface for DNS verification result */ export interface IDnsVerificationResult { record: string; found: boolean; valid: boolean; value?: string; expectedValue?: string; error?: string; } /** * Manager for DNS-related operations, including record lookups, verification, and generation */ export declare class DNSManager { dkimCreator: DKIMCreator; private cache; private defaultOptions; constructor(dkimCreatorArg: DKIMCreator, options?: IDnsLookupOptions); /** * Lookup MX records for a domain * @param domain Domain to look up * @param options Lookup options * @returns Array of MX records sorted by priority */ lookupMx(domain: string, options?: IDnsLookupOptions): Promise; /** * Lookup TXT records for a domain * @param domain Domain to look up * @param options Lookup options * @returns Array of TXT records */ lookupTxt(domain: string, options?: IDnsLookupOptions): Promise; /** * Find specific TXT record by subdomain and prefix * @param domain Base domain * @param subdomain Subdomain prefix (e.g., "dkim._domainkey") * @param prefix Record prefix to match (e.g., "v=DKIM1") * @param options Lookup options * @returns Matching TXT record or null if not found */ findTxtRecord(domain: string, subdomain?: string, prefix?: string, options?: IDnsLookupOptions): Promise; /** * Verify if a domain has a valid SPF record * @param domain Domain to verify * @returns Verification result */ verifySpfRecord(domain: string): Promise; /** * Verify if a domain has a valid DKIM record * @param domain Domain to verify * @param selector DKIM selector (usually "mta" in our case) * @returns Verification result */ verifyDkimRecord(domain: string, selector?: string): Promise; /** * Verify if a domain has a valid DMARC record * @param domain Domain to verify * @returns Verification result */ verifyDmarcRecord(domain: string): Promise; /** * Check all email authentication records (SPF, DKIM, DMARC) for a domain * @param domain Domain to check * @param dkimSelector DKIM selector * @returns Object with verification results for each record type */ verifyEmailAuthRecords(domain: string, dkimSelector?: string): Promise<{ spf: IDnsVerificationResult; dkim: IDnsVerificationResult; dmarc: IDnsVerificationResult; }>; /** * Generate a recommended SPF record for a domain * @param domain Domain name * @param options Configuration options for the SPF record * @returns Generated SPF record */ generateSpfRecord(domain: string, options?: { includeMx?: boolean; includeA?: boolean; includeIps?: string[]; includeSpf?: string[]; policy?: 'none' | 'neutral' | 'softfail' | 'fail' | 'reject'; }): IDnsRecord; /** * Generate a recommended DMARC record for a domain * @param domain Domain name * @param options Configuration options for the DMARC record * @returns Generated DMARC record */ generateDmarcRecord(domain: string, options?: { policy?: 'none' | 'quarantine' | 'reject'; subdomainPolicy?: 'none' | 'quarantine' | 'reject'; pct?: number; rua?: string; ruf?: string; daysInterval?: number; }): IDnsRecord; /** * Save DNS record recommendations to a file * @param domain Domain name * @param records DNS records to save */ saveDnsRecommendations(domain: string, records: IDnsRecord[]): Promise; /** * Get cache key value * @param key Cache key * @returns Cached value or undefined if not found or expired */ private getFromCache; /** * Set cache key value * @param key Cache key * @param data Data to cache * @param ttl TTL in milliseconds */ private setInCache; /** * Clear the DNS cache * @param key Optional specific key to clear, or all cache if not provided */ clearCache(key?: string): void; /** * Promise-based wrapper for dns.resolveMx * @param domain Domain to resolve * @param timeout Timeout in milliseconds * @returns Promise resolving to MX records */ private dnsResolveMx; /** * Promise-based wrapper for dns.resolveTxt * @param domain Domain to resolve * @param timeout Timeout in milliseconds * @returns Promise resolving to TXT records */ private dnsResolveTxt; /** * Generate all recommended DNS records for proper email authentication * @param domain Domain to generate records for * @returns Array of recommended DNS records */ generateAllRecommendedRecords(domain: string): Promise; }