Verify signatures
Every delivery carries an IDEALX-Signature header:
IDEALX-Signature: t=1763631000,v1=e5b62c98312f1df0b8e332e5d167a371abdb9284cfa91a02407f300e00bd5e58tis the Unix time (seconds) when IDEALX signed the delivery.v1is the hex HMAC-SHA256 of the string<t>.<raw body>, keyed with your endpoint’s signing secret.
To verify:
- Split the header on
,and each part on the first=; readtandv1. - Reject the delivery if
tis more than five minutes away from your clock (it stops replays). - Compute HMAC-SHA256 of
t + "." + rawBodywith your secret, using the body exactly as received, before any JSON parsing or re-encoding. - Compare it with
v1in constant time.
import { createHmac, timingSafeEqual } from "node:crypto";
export function verifyIdealxSignature(secret: string, rawBody: string, header: string, toleranceSeconds = 300): boolean { const parts = Object.fromEntries( header.split(",").map((p) => { const i = p.indexOf("="); return [p.slice(0, i).trim(), p.slice(i + 1).trim()]; }), ); const t = Number(parts.t); if (!parts.v1 || !Number.isFinite(t) || Math.abs(Date.now() / 1000 - t) > toleranceSeconds) return false; const want = createHmac("sha256", secret).update(`${t}.${rawBody}`).digest(); const got = Buffer.from(parts.v1, "hex"); return got.length === want.length && timingSafeEqual(got, want);}import hashlibimport hmacimport time
def verify_idealx_signature(secret: str, raw_body: bytes, header: str, tolerance_seconds: int = 300) -> bool: parts = dict(p.strip().split("=", 1) for p in header.split(",") if "=" in p) try: t = int(parts["t"]) v1 = parts["v1"] except (KeyError, ValueError): return False if abs(time.time() - t) > tolerance_seconds: return False want = hmac.new(secret.encode(), f"{t}.".encode() + raw_body, hashlib.sha256).hexdigest() return hmac.compare_digest(want, v1)package idealx
import ( "crypto/hmac" "crypto/sha256" "encoding/hex" "math" "strconv" "strings" "time")
func VerifySignature(secret string, rawBody []byte, header string, tolerance time.Duration) bool { var t int64 var v1 string for _, part := range strings.Split(header, ",") { k, v, ok := strings.Cut(strings.TrimSpace(part), "=") if !ok { continue } switch k { case "t": t, _ = strconv.ParseInt(v, 10, 64) case "v1": v1 = v } } if t == 0 || v1 == "" || math.Abs(float64(time.Now().Unix()-t)) > tolerance.Seconds() { return false } mac := hmac.New(sha256.New, []byte(secret)) mac.Write([]byte(strconv.FormatInt(t, 10) + ".")) mac.Write(rawBody) got, err := hex.DecodeString(v1) return err == nil && hmac.Equal(got, mac.Sum(nil))}Test vector
Section titled “Test vector”Check your code with these values (turn the time check off, or set your clock, for the test):
| Value | |
|---|---|
| Secret | whsec_test_5cQx2rN8vLmA0pT7yK3eW9uB4sD6fG1h |
t |
1763631000 |
| Raw body | {"id":"whd_01937e5f6a7b8c9d0e1f2a3b4c5d6e7f","type":"deposit.credited","createdAt":"2026-11-20T09:30:00.000Z","data":{"accountId":"acc_01937c4e8a2b7d1f9e0c3b5a6d7e8f90","units":"25000","currency":"AUD"}} |
Expected v1 |
e5b62c98312f1df0b8e332e5d167a371abdb9284cfa91a02407f300e00bd5e58 |
Rotating a secret
Section titled “Rotating a secret”Each endpoint has its own secret. To replace one, add a new endpoint (for example a new path on your server) with the same events, move your code to it, then delete the old endpoint. While both exist, each event is delivered to both, each with its own delivery id.