Overview
Signatures
Everything we send you, webhooks and decision-hook calls, carries ogawifi-signature: t=<unix seconds>,v1=<hex>. To check it:
- read the raw body, before any JSON parsing;
- refuse it if
tis more than 5 minutes old, or more than a minute in the future; - compute HMAC-SHA256 of
t, a dot, then the raw body, with that endpoint's or hook's signing secret, as hex; - accept it if that equals any
v1, compared in constant time (check lengths first).
JavaScript
1const crypto = require("crypto");23function verifyOgaWiFi(rawBody, header, secret) {4 const parts = header.split(",").map((p) => p.trim());5 const t = Number(parts.find((p) => p.startsWith("t="))?.slice(2));6 const now = Math.floor(Date.now() / 1000);7 if (!Number.isInteger(t) || now - t > 300 || t - now > 60) return false;89 const expected = Buffer.from(10 crypto.createHmac("sha256", secret).update(`${t}.${rawBody}`).digest("hex")11 );12 return parts13 .filter((p) => p.startsWith("v1="))14 .some((p) => {15 const given = Buffer.from(p.slice(3));16 return given.length === expected.length && crypto.timingSafeEqual(given, expected);17 });18}With Express, keep the raw body: express.json({ verify: (req, _res, buf) => { req.rawBody = buf.toString("utf8"); } }).
After New secret, the old secret stays valid for 24 hours and every request carries two v1 values. Don't allowlist our IP addresses; they aren't fixed. The signature is how you know it's us.
Was this helpful?