From 0324259da31506516a98307bded51fa4aa26f0bf Mon Sep 17 00:00:00 2001 From: Dotta Date: Fri, 6 Mar 2026 12:49:41 -0600 Subject: [PATCH] Handle single-key wrapped OpenClaw auth headers --- .../invite-accept-openclaw-defaults.test.ts | 20 +++++++++++++++++++ server/src/routes/access.ts | 16 +++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/server/src/__tests__/invite-accept-openclaw-defaults.test.ts b/server/src/__tests__/invite-accept-openclaw-defaults.test.ts index 64a3cd4e..b886e210 100644 --- a/server/src/__tests__/invite-accept-openclaw-defaults.test.ts +++ b/server/src/__tests__/invite-accept-openclaw-defaults.test.ts @@ -142,6 +142,26 @@ describe("buildJoinDefaultsPayloadForAccept", () => { }); }); + it("accepts auth headers wrapped in a single unknown key", () => { + const result = buildJoinDefaultsPayloadForAccept({ + adapterType: "openclaw", + defaultsPayload: { + headers: { + "x-openclaw-auth": { + gatewayToken: "gateway-token", + }, + }, + }, + }) as Record; + + expect(result).toMatchObject({ + headers: { + "x-openclaw-auth": "gateway-token", + }, + webhookAuthHeader: "Bearer gateway-token", + }); + }); + it("leaves non-openclaw payloads unchanged", () => { const defaultsPayload = { command: "echo hello" }; const result = buildJoinDefaultsPayloadForAccept({ diff --git a/server/src/routes/access.ts b/server/src/routes/access.ts index bcebe68b..f6fd1664 100644 --- a/server/src/routes/access.ts +++ b/server/src/routes/access.ts @@ -159,6 +159,22 @@ function normalizeHeaderValue( const normalized = normalizeHeaderValue((value as Record)[key], depth + 1); if (normalized) return normalized; } + + const entries = Object.entries(value as Record); + if (entries.length === 1) { + const [singleKey, singleValue] = entries[0]; + const normalizedKey = singleKey.trim().toLowerCase(); + if ( + normalizedKey !== "type" && + normalizedKey !== "version" && + normalizedKey !== "secretid" && + normalizedKey !== "secret_id" + ) { + const normalized = normalizeHeaderValue(singleValue, depth + 1); + if (normalized) return normalized; + } + } + return null; }