mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-02 19:50:21 +00:00
refactor: simplify webhook secret headers
This commit is contained in:
@@ -308,15 +308,13 @@ function writeJson(res: ServerResponse, statusCode: number, body: unknown): void
|
||||
|
||||
function extractSharedSecret(req: IncomingMessage): string {
|
||||
const authHeader = Array.isArray(req.headers.authorization)
|
||||
? String(req.headers.authorization[0] ?? "")
|
||||
: String(req.headers.authorization ?? "");
|
||||
? (req.headers.authorization[0] ?? "")
|
||||
: (req.headers.authorization ?? "");
|
||||
if (normalizeLowercaseStringOrEmpty(authHeader).startsWith("bearer ")) {
|
||||
return authHeader.slice("bearer ".length).trim();
|
||||
}
|
||||
const sharedHeader = req.headers["x-openclaw-webhook-secret"];
|
||||
return Array.isArray(sharedHeader)
|
||||
? String(sharedHeader[0] ?? "").trim()
|
||||
: String(sharedHeader ?? "").trim();
|
||||
return Array.isArray(sharedHeader) ? (sharedHeader[0] ?? "").trim() : (sharedHeader ?? "").trim();
|
||||
}
|
||||
|
||||
function timingSafeEquals(left: string, right: string): boolean {
|
||||
|
||||
Reference in New Issue
Block a user