openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
38 lines (37 loc) • 1.13 kB
JavaScript
//#region src/shared/gateway-edge-auth-headers.ts
const HTTP_HEADER_NAME_PATTERN = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/u;
const TRANSPORT_OWNED_HEADERS = /* @__PURE__ */ new Set([
"host",
"connection",
"upgrade",
"content-length",
"sec-websocket-key",
"sec-websocket-version",
"sec-websocket-protocol",
"sec-websocket-extensions"
]);
function findEdgeAuthIssue(e) {
const t = Object.entries(e);
if (t.length === 0) return { message: "invalid gateway.remote.edgeAuth: header map must not be empty" };
const n = /* @__PURE__ */ new Map();
for (const [e] of t) {
if (!HTTP_HEADER_NAME_PATTERN.test(e)) return {
headerName: e,
message: `invalid gateway.remote.edgeAuth header name: ${JSON.stringify(e)}`
};
const t = e.toLowerCase();
if (TRANSPORT_OWNED_HEADERS.has(t)) return {
headerName: e,
message: `gateway.remote.edgeAuth cannot set transport-owned header "${e}"`
};
const r = n.get(t);
if (r) return {
headerName: e,
message: `gateway.remote.edgeAuth header names "${r}" and "${e}" differ only by case`
};
n.set(t, e);
}
return null;
}
//#endregion
export { findEdgeAuthIssue as t };