import type { RuntimeConfig } from './types'; export function bearer(request:Request){ const value=request.headers.get('authorization')??''; return value.startsWith('Bearer ')?value.slice(7):''; } export function requireAleBridge(request:Request,config:RuntimeConfig){ const expected=config.ALE_BRIDGE_TOKEN; if(!expected||bearer(request)!==expected)throw new Error('Unauthorized ALE bridge'); } export function requireAleOperator(request:Request,config:RuntimeConfig){ const expected=config.ALE_OPERATOR_TOKEN; if(!expected||bearer(request)!==expected)throw new Error('Unauthorized ALE operator'); } export function rawAleEnabled(config:RuntimeConfig){ return String(config.ALE_RAW_EXEC_ENABLED??'').toLowerCase()==='true'; }