Linear webhook verification: HMAC-SHA256 over the raw body, delivered as a hex digest in the linear-signature header, plus replay protection via the signed webhookTimestamp payload field. See https://developers.linear.app/docs/graphql/webhooks.

Values

DEFAULT_MAX_AGE_MS

DEFAULT_MAX_AGE_MS: Int 60000

Functions

verify-request

fn (request: Map): Bool
fn (request: Map, secret: Str): Bool
fn (request: Map, opts: Map): Bool
fn (request: Map, secret: Str, max-age-ms: Int): Bool

Verify a Linear webhook request: checks the linear-signature HMAC, then rejects replays whose signed webhookTimestamp is more than max-age-ms from now (default 60s, per Linear's docs). Pass a max-age-ms of 0 or less to skip the replay check. Uses the linear.webhook.secret context variable by default (failing when it is unset), or accepts an explicit secret — an empty explicit secret never verifies. The Map form takes webhook-secret and max-age-ms; without webhook-secret it reads the context variable. A webhook-secret present but blank or null is an Err, never a fallback to context.

Example

linear-webhook
meta {webhook: {service: "linear", path: "/linear/webhook"}}
fn (request) {
  if(not(::linear::webhooks/verify-request(request)),
    ::hot::http/HttpResponse({status: 401, body: "invalid signature"}),
    ::hot::http/HttpResponse({status: 200, body: "ok"}))
}

// One tenant's secret, for one call
tenant-b-webhook fn (request) {
  ::linear::webhooks/verify-request(request, {webhook-secret: ::hot::ctx/get("tenant-b.linear.webhook.secret")})
}
Context Vars: linear.webhook.secret