Signature Algorithm
KyrenPay uses HMAC-SHA256 to sign webhook payloads:Verification Steps
1
Extract headers
Read
X-Kyren-Signature and X-Kyren-Timestamp from the request headers.2
Check timestamp
Verify the timestamp is within 5 minutes (300000 milliseconds) of the current time. This prevents replay attacks.
3
Compute expected signature
Concatenate
timestamp + "." + raw_request_body, then compute HMAC-SHA256 using your webhook secret.4
Compare signatures
Compare the computed signature with the one in the header. Use constant-time comparison to prevent timing attacks.
Code Examples
Register the raw Webhook route before any global JSON parser, or parse JSON only on regular routes. Verify headers and the original body before parsing the event. The examples below require your durable inbox adapter: uniquely save an event ID and pending payload before returning2xx; a worker must retry and fulfill idempotently. Invalid headers return a rejection, not an unhandled exception. Each retry uses a fresh sending timestamp; use the header, not created_at, for signature verification.
