UNPKG

@nanggo/social-preview

Version:

Generate beautiful social media preview images from any URL

49 lines (48 loc) 1.46 kB
/** * Enhanced Secure HTTP/HTTPS Agent implementation * * Addresses TOCTOU (Time-of-Check-Time-of-Use) vulnerabilities in DNS rebinding protection * by implementing DNS result caching and socket-level IP validation */ import http from 'http'; import https from 'https'; interface SecurityValidationResult { allowed: boolean; blockedIPs: string[]; allowedIPs: string[]; reason?: string; } /** * Create enhanced secure HTTP agent */ export declare function createEnhancedSecureHttpAgent(): http.Agent; /** * Create enhanced secure HTTPS agent */ export declare function createEnhancedSecureHttpsAgent(): https.Agent; export declare function getEnhancedSecureHttpAgent(): http.Agent; export declare function getEnhancedSecureHttpsAgent(): https.Agent; /** * Get appropriate enhanced secure agent based on protocol */ export declare function getEnhancedSecureAgentForUrl(url: string): http.Agent | https.Agent; /** * DNS cache management functions */ export declare function getDNSCacheStats(): { size: number; maxSize: number; entries: { hostname: string; addresses: string[]; age: number; ttl: number; }[]; }; export declare function invalidateDNSCache(hostname?: string): void; /** * Advanced security validation for HTTP requests */ export declare function validateRequestSecurity(url: string): Promise<SecurityValidationResult>; export declare const cleanup: () => void; export {};