import { LogLevel } from '../../enums/LogLevel.enum'; import { log } from './log'; /** * Validates a download URL for security purposes * @param url The URL to validate * @returns true if the URL is valid and uses HTTPS, false otherwise */ export function validateDownloadUrl(url: string): boolean { try { const urlObj = new URL(url); // Security: Only allow HTTPS to prevent man-in-the-middle attacks if (urlObj.protocol !== 'https:') { log(LogLevel.ERROR, `Download URL must use HTTPS protocol. Received: ${urlObj.protocol}`); return false; } return true; } catch (error) { log(LogLevel.ERROR, `Invalid download URL format: ${error instanceof Error ? error.message : String(error)}`); return false; } }