Skip to main content

Node.js SDK

Requires Node 18+. Zero runtime dependencies.

Initialize + verify

Maps to:

Verify response (JSON)

keverd.verify() resolves to this object (same as POST /v2/verify):
action / recommendation: allow | soft_challenge | hard_challenge | block

Express

Your route typically accepts JSON from the browser:

Webhooks

See Webhooks for the full envelope JSON.

Errors

All SDK failures extend KeverdError. Catch the specific subclass when you need different handling.

KeverdError

Base error for client-side failures before a successful API response, or when the request never completes. Thrown when
  • Missing config (e.g. no secretKey)
  • Invalid arguments (e.g. empty eventId)
  • Network failures
  • Request timeouts
Fields: message, code (string | null), statusCode (number | null)

KeverdAPIError

Thrown when the API returns a non-2xx HTTP status. Extends KeverdError. Thrown when
  • Auth fails (401 / 403)
  • Bad request (400)
  • Quota exceeded (402)
  • Server errors (5xx)
Fields: statusCode, code, body (parsed JSON when available)

KeverdSignatureError

Thrown by keverd.webhooks.constructEvent(...) when webhook signature verification fails. Extends KeverdError with code: "invalid_signature". Thrown when
  • Missing X-Keverd-Signature or webhook secret
  • Malformed signature header
  • Timestamp outside the 300s tolerance
  • HMAC mismatch (wrong secret, or body was parsed/modified before verify)
  • Payload is not valid JSON
Treat these as untrusted requests — return 400 and do not process the event. See Webhooks.