fix: strip polar_whs_ prefix from webhook secret before base64 decode
This commit is contained in:
@@ -70,10 +70,11 @@ export function verifyPolarWebhook(
|
|||||||
|
|
||||||
const signedContent = `${webhookId}.${webhookTimestamp}.${rawBody}`;
|
const signedContent = `${webhookId}.${webhookTimestamp}.${rawBody}`;
|
||||||
|
|
||||||
// Secret base64 olabilir
|
// Polar secret: "polar_whs_<base64>" — prefix soyulup base64 decode edilir
|
||||||
let secretBytes: Buffer;
|
let secretBytes: Buffer;
|
||||||
try {
|
try {
|
||||||
secretBytes = Buffer.from(WEBHOOK_SECRET.replace(/^whsec_/, ""), "base64");
|
const raw = WEBHOOK_SECRET.replace(/^(whsec_|polar_whs_)/, "");
|
||||||
|
secretBytes = Buffer.from(raw, "base64");
|
||||||
} catch {
|
} catch {
|
||||||
secretBytes = Buffer.from(WEBHOOK_SECRET);
|
secretBytes = Buffer.from(WEBHOOK_SECRET);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user