Validates LiveKit webhook callbacks and decodes them into
LiveKit.Proto.WebhookEvent.
LiveKit POSTs JSON with Content-Type: application/webhook+json and an
Authorization header holding a JWT whose sha256 claim is the Base64
SHA-256 of the raw request body. Pass that raw body (binary or iodata),
not a pre-decoded map:
iex> {:ok, receiver} = LiveKit.WebhookReceiver.new(api_key: "k", api_secret: "s")
iex> body = ~s({"event":"room_started","id":"EV_1"})
iex> {:ok, event} = LiveKit.WebhookReceiver.receive(receiver, body, nil, skip_auth: true)
iex> event.event
"room_started"When authentication is enabled (the default), the JWT is verified with
LiveKit.TokenVerifier and the body digest must match claims["sha256"].
Summary
Functions
Builds a receiver from keyword credentials or a LiveKit.Client.
Same as new/1 but raises LiveKit.Error on failure.
Verifies and decodes a webhook request.
Types
@type t() :: %LiveKit.WebhookReceiver{verifier: LiveKit.TokenVerifier.t()}
Functions
@spec new(keyword() | LiveKit.Client.t()) :: {:ok, t()} | {:error, LiveKit.Error.t()}
Builds a receiver from keyword credentials or a LiveKit.Client.
Examples
iex> {:ok, receiver} = LiveKit.WebhookReceiver.new(api_key: "k", api_secret: "s")
iex> receiver.verifier.api_key
"k"
@spec new!(keyword() | LiveKit.Client.t()) :: t()
Same as new/1 but raises LiveKit.Error on failure.
@spec receive(t(), iodata(), String.t() | nil, keyword()) :: {:ok, LiveKit.Proto.WebhookEvent.t()} | {:error, LiveKit.Error.t()}
Verifies and decodes a webhook request.
Arguments
receiver- aLiveKit.WebhookReceiverbody- raw POST body as a binary or iodataauth_header- value of theAuthorizationheader (JWT, optionally prefixed withBearer). Ignored when:skip_authis true.opts- see below
Options
:skip_auth- whentrue, skip JWT and hash checks (defaultfalse):clock_tolerance- forwarded toLiveKit.TokenVerifier.verify/3
Examples
iex> receiver = LiveKit.WebhookReceiver.new!(api_key: "k", api_secret: "s")
iex> {:error, error} = LiveKit.WebhookReceiver.receive(receiver, "{}", nil)
iex> error.type
:authentication