import type { EbsiEnvConfiguration } from "./types.ts"; import { ConfigurationError } from "./errors/index.ts"; /** * Validate EBSI environment configuration. * @param config - EBSI environment configuration to validate. */ export function validateConfig(config: EbsiEnvConfiguration) { // Validate hosts const { hosts } = config; if (!Array.isArray(hosts) || hosts.length === 0) { throw new ConfigurationError("At least 1 trusted host must be defined"); } for (const host of hosts) { try { new URL(`https://${host}`); } catch { throw new ConfigurationError(`Invalid host ${host}`); } } }