fix: strip polar_whs_ prefix from webhook secret before base64 decode

This commit is contained in:
kovakmedya
2026-05-04 18:26:30 +03:00
parent e8a766c60a
commit 106c33d1b4
+3 -2
View File
@@ -70,10 +70,11 @@ export function verifyPolarWebhook(
const signedContent = `${webhookId}.${webhookTimestamp}.${rawBody}`;
// Secret base64 olabilir
// Polar secret: "polar_whs_<base64>" — prefix soyulup base64 decode edilir
let secretBytes: Buffer;
try {
secretBytes = Buffer.from(WEBHOOK_SECRET.replace(/^whsec_/, ""), "base64");
const raw = WEBHOOK_SECRET.replace(/^(whsec_|polar_whs_)/, "");
secretBytes = Buffer.from(raw, "base64");
} catch {
secretBytes = Buffer.from(WEBHOOK_SECRET);
}