validate Stripe webhook event shape

This commit is contained in:
2026-09-06 17:44:43 +03:00
parent bb96f0d9ac
commit 84ce2b8155
+4 -1
View File
@@ -114,7 +114,10 @@ export function verifyWebhook(hamGovde, imzaBasligi, { tolerans = 300 } = {}) {
const b = Buffer.from(v1, 'utf8'); const b = Buffer.from(v1, 'utf8');
if (a.length !== b.length || !crypto.timingSafeEqual(a, b)) throw new Error('İmza doğrulanamadı'); if (a.length !== b.length || !crypto.timingSafeEqual(a, b)) throw new Error('İmza doğrulanamadı');
return JSON.parse(hamGovde); const olay = JSON.parse(hamGovde);
if (!olay || typeof olay !== 'object' || Array.isArray(olay) || typeof olay.type !== 'string' || !olay.type.trim())
throw new Error('Stripe webhook olay biçimi geçersiz');
return olay;
} }
/** Stripe Price ID → plan kimliği */ /** Stripe Price ID → plan kimliği */