signToken creates an HMAC-SHA256 signed JWT for the GatelitSigned auth scheme. It runs on your backend using the Web Crypto API — available natively in Node.js 18+, Bun, Deno, and all edge runtimes (Cloudflare Workers, Vercel Edge).
Import from
@gatelit/sdk/sign (not @gatelit/sdk) to tree-shake the rest
of the SDK. The /sign subpath export only includes signToken and its
dependencies.Signature
header.payload.signature.
Options
Examples
Minimal — user identity only
Constrained — specific model with a token cap
Full — end-user tracking with request source
Nuxt server route
Next.js API route
Express route
Token structure
The signed token embeds the following JWT claims the gateway reads:iat— Issued at (epoch seconds)exp— Expires at (iat+ttl)sub— Subject (user ID)orgId— (optional) Organisation contextpolicyOverride— (optional) Encoded model restriction and token capendUserId— (optional) End-user identifierrequestSource— (optional)api|dashboard|eval