UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

40 lines (39 loc) • 1.83 kB
import { l as isRecord } from "./record-coerce-CVPuDqcc.mjs"; import { d as normalizeRequiredSecretInput } from "./types.secrets-BmNLLnHp.mjs"; import { o as registerSecretValueForRedaction } from "./secret-redaction-registry-Cy0acctn.mjs"; import { t as findEdgeAuthIssue } from "./gateway-edge-auth-headers-DTVglEpb.mjs"; import { n as gatewayOriginScope } from "./gateway-origin-scope-SP9yyLnR.mjs"; import { t as materializeSecretInput } from "./resolve-secret-input-string-DjfC9izQ.mjs"; //#region src/gateway/edge-auth.ts function normalizeEdgeAuthHeadersConfig(e) { if (e === void 0 || e === null) return; if (!isRecord(e)) throw new Error("invalid gateway.remote.edgeAuth: expected a header map"); const t = findEdgeAuthIssue(e); if (t) throw new Error(t.message); const n = Object.entries(e).map(([e, t]) => { return [e, normalizeRequiredSecretInput(t, `gateway.remote.edgeAuth header "${e}"`)]; }); return Object.fromEntries(n); } async function resolveEdgeAuthHeaders(e) { if (!e.value) return; if (URL.parse(e.targetUrl)?.protocol !== "wss:") throw new Error("gateway.remote.edgeAuth requires a wss:// connection target"); const t = await Promise.all(Object.entries(e.value).map(async ([t, n]) => { const r = await materializeSecretInput({ config: e.config, value: n, env: e.env }); if (!r) throw new Error(`gateway.remote.edgeAuth header "${t}" resolved empty`); registerSecretValueForRedaction(r); return [t, r]; })); return Object.freeze(Object.fromEntries(t)); } function gatewayEdgeAuthValueForTarget(e) { const t = e.config.gateway?.remote; if (!t?.url || gatewayOriginScope(e.targetUrl) !== gatewayOriginScope(t.url)) return; return t.edgeAuth; } //#endregion export { normalizeEdgeAuthHeadersConfig as n, resolveEdgeAuthHeaders as r, gatewayEdgeAuthValueForTarget as t };