import { verifyWebhookSignature } from '@omni-ward/sdk-node';// rawBody: o corpo exatamente como chegou, antes de qualquer parsing.const ok = verifyWebhookSignature({ secret: process.env.OMNI_WARD_WEBHOOK_SECRET!, rawBody, signature: req.headers['omni-ward-signature'],});if (!ok) return res.status(400).end();
import hmac, hashlib, timedef verify(secret: str, raw_body: bytes, header: str, tolerance=300) -> bool: parts = dict(p.split("=", 1) for p in header.split(",")) t, v1 = int(parts["t"]), parts["v1"] if abs(time.time() - t) > tolerance: return False expected = hmac.new(secret.encode(), f"{t}.".encode() + raw_body, hashlib.sha256).hexdigest() return hmac.compare_digest(expected, v1)