Check that a webhook request really came from Vaartix (Standard Webhooks spec).
# Phoenix: read the raw body first (see the README), then:
case Vaartix.Webhook.verify(raw_body, conn.req_headers, System.fetch_env!("VAARTIX_WEBHOOK_SECRET")) do
{:ok, %{"type" => "email.bounced", "data" => %{"details" => details}}} ->
details["diagnosticCode"] # the receiving server's reply
{:ok, _event} -> :ok
{:error, reason} -> reason
end
Summary
Functions
Every webhook event type.
Verify a request and return {:ok, payload} or {:error, reason}. headers is a list of
{name, value} tuples (like conn.req_headers) or a map; names are matched case-insensitively.
Options: :tolerance in seconds (default 300), :now (Unix seconds).
Functions
Every webhook event type.
@spec verify(binary(), list() | map(), String.t(), keyword()) :: {:ok, map()} | {:error, String.t()}
Verify a request and return {:ok, payload} or {:error, reason}. headers is a list of
{name, value} tuples (like conn.req_headers) or a map; names are matched case-insensitively.
Options: :tolerance in seconds (default 300), :now (Unix seconds).