ElevenLabs webhook verification. Each delivery carries an
ElevenLabs-Signature header of the form t=<unix seconds>,v0=<hex>,
where the hex value is HMAC-SHA256 of <t>.<raw body> keyed with the
webhook's secret. Deliveries older than 30 minutes are rejected, as
in ElevenLabs' docs and SDKs. See
https://elevenlabs.io/docs/product-guides/administration/webhooks.
Values
DEFAULT_TOLERANCE_SECONDS
DEFAULT_TOLERANCE_SECONDS: Int 1800
Functions
parse-signature-header
fn (header: Str): Map
Split an ElevenLabs-Signature header into {timestamp, signatures} (timestamp is the t= value as a Str, or null; signatures every v0= value). Exposed for testing.
timestamp-fresh
fn (timestamp: Str, tolerance-seconds: Int): Bool
verify-request
fn (request: Map): Bool
fn (request: Map, secret: Str?): Bool
fn (request: Map, secret: Str?, tolerance-seconds: Int): Bool
Verify an ElevenLabs webhook request: checks the
ElevenLabs-Signature HMAC over <t>.<raw body>, then rejects
deliveries whose signed timestamp is more than tolerance-seconds
from now (default 1800, ElevenLabs' 30 minutes). Pass a tolerance of
0 or less to skip the age check. Uses the
elevenlabs.webhook.secret context variable by default (failing
when it is unset), or an explicit secret, which is masked in call
records; an empty explicit secret never verifies.
Example
elevenlabs-webhook
meta {webhook: {service: "elevenlabs", path: "/elevenlabs/webhook"}}
fn (request) {
if(not(::elevenlabs::webhooks/verify-request(request)),
::hot::http/HttpResponse({status: 401, body: "invalid signature"}),
::hot::http/HttpResponse({status: 200, body: {received: request.body.type}}))
}
elevenlabs.webhook.secret