Documentation for Standard Webhooks
Summary
Functions
Calculate the response to an endpoint verification challenge given a challenge and secret
Sign a Standard Webhook given an id, timestamp, payload and secret
Verify a Standard Webhook given a payload, Plug.Conn and secret
Verify the response to an endpoint verification challenge given a challenge, response and secret
Functions
Calculate the response to an endpoint verification challenge given a challenge and secret
Takes the value of the webhook-challenge header and returns the value for the
webhook-challenge-response header.
@spec sign( id :: String.t(), timestamp :: integer(), payload :: binary() | String.t(), secret :: binary() ) :: String.t()
Sign a Standard Webhook given an id, timestamp, payload and secret
The payload can be bytes (a binary) or a string (a UTF-8 binary). It's signed byte for byte, so it must be the exact body that will be sent.
@spec verify(binary() | String.t(), Plug.Conn.t(), binary()) :: boolean()
Verify a Standard Webhook given a payload, Plug.Conn and secret
The payload must be the raw request body, exactly as received, either as bytes (a binary) or as a string (a UTF-8 binary). It's verified byte for byte, so don't pass a re-encoded version of the parsed body: even a minor difference in the serialization (e.g. whitespace or key order) will cause verification to fail.
@spec verify_endpoint_verification_response( challenge :: String.t(), header :: String.t(), secret :: binary() ) :: boolean()
Verify the response to an endpoint verification challenge given a challenge, response and secret
Takes the challenge that was sent and the value of the webhook-challenge-response header.