Webhook signature verification for HookSniff.
Supports both simple HMAC-SHA256 verification and Standard Webhooks (Svix-compatible) verification with timestamp tolerance.
Also supports Svix headers (svix-id, svix-signature, svix-timestamp) as fallback.
Example
# Verify from request headers
result = HookSniff.WebhookVerification.verify_webhook_from_headers(
payload: body,
headers: conn.req_headers |> Map.new(),
secret: "whsec_..."
)
case result do
{:ok, payload} -> # Valid webhook
{:error, reason} -> # Invalid
end
Summary
Functions
Verify a webhook signature using HMAC-SHA256 (legacy format).
Verify a webhook using Standard Webhooks headers (Svix-compatible).
Verify a webhook from headers with automatic header detection.
Functions
Verify a webhook signature using HMAC-SHA256 (legacy format).
Verify a webhook using Standard Webhooks headers (Svix-compatible).
Returns {:ok, parsed_payload} or {:error, reason}.
Verify a webhook from headers with automatic header detection.
Supports both Standard Webhooks headers (webhook-id, webhook-signature, webhook-timestamp) and Svix headers (svix-id, svix-signature, svix-timestamp) as fallback.