Manza::Webhook
Verifies incoming webhook deliveries. Pure functions — no HTTP.
Every delivery carries X-Manza-Signature (hex HMAC-SHA256 of
"<timestamp>.<raw body>" under the endpoint's signing secret) and
X-Manza-Timestamp (Unix seconds, fresh on every attempt). The
legacy X-Zazu-* names carry the same values.
Pass the raw request body, never re-serialized JSON:
event = Manza::Webhook.construct_event(
context.request.body.try(&.gets_to_end) || "", context.request.headers, signing_secret
)
event["event"] # => "payment.authorization_requested"
Constants
Class methods
Reads X-Manza-Signature / X-Manza-Timestamp (any case, falling
back to X-Zazu-*), verifies them, and returns the parsed event,
always a JSON object. Raises Manza::ArgumentError when a header is
missing, the signature does not match, the timestamp is outside
tolerance, or the body is not a JSON object.
Hex HMAC-SHA256 of "<timestamp>.<payload>". For tests and local tools.
True when the signature matches (constant time) and the timestamp is
within tolerance of now. tolerance: nil skips the timestamp
check (for replaying a captured delivery in a local tool or test,
never on a live endpoint). Never raises on bad input; returns false.