UNPKG

@langchain/core

Version:
49 lines • 1.73 kB
/** * Check if an IP address is private (RFC 1918, loopback, link-local, etc.) */ export declare function isPrivateIp(ip: string): boolean; /** * Check if a hostname or IP is a known cloud metadata endpoint. */ export declare function isCloudMetadata(hostname: string, ip?: string): boolean; /** * Check if a hostname or IP is localhost. */ export declare function isLocalhost(hostname: string, ip?: string): boolean; /** * Validate that a URL is safe to connect to. * Performs static validation checks against hostnames and direct IP addresses. * Does not perform DNS resolution. * * @param url URL to validate * @param options.allowPrivate Allow private IPs (default: false) * @param options.allowHttp Allow http:// scheme (default: false) * @returns The validated URL * @throws Error if URL is not safe */ export declare function validateSafeUrl(url: string, options?: { allowPrivate?: boolean; allowHttp?: boolean; }): string; /** * Check if a URL is safe to connect to (non-throwing version). * * @param url URL to check * @param options.allowPrivate Allow private IPs (default: false) * @param options.allowHttp Allow http:// scheme (default: false) * @returns true if URL is safe, false otherwise */ export declare function isSafeUrl(url: string, options?: { allowPrivate?: boolean; allowHttp?: boolean; }): boolean; /** * Check if two URLs have the same origin (scheme, host, port). * Uses semantic URL parsing to prevent SSRF bypasses via URL variations. * * @param url1 First URL * @param url2 Second URL * @returns true if both URLs have the same origin, false otherwise */ export declare function isSameOrigin(url1: string, url2: string): boolean; //# sourceMappingURL=ssrf.d.cts.map