FLOWDocs

JWT verification

Verify identity and audience before authorizing backend requests.

Before trusting a Flow access token, verify its signature, issuer, audience, expiry, and subject. The browser obtains a current bearer token with flow.getToken(); it never needs the rotating refresh secret.

Verify on your server

import { verifyFlowJWT } from "@flow-industries/id/verify";

const payload = await verifyFlowJWT(token, {
  audience: "https://your-app.example",
});

The helper returns verified claims or throws. audience is required and must exactly match your app's runtime origin, including scheme and port. issuerUrl defaults to https://id.flow.industries. Self-hosted deployments can override it; the optional server-only apiUrl changes the transport destination while retaining the public issuer check.

The helper uses jose and the issuer's /api/auth/jwks endpoint, with a cached remote key set. Do not accept a token merely because it decodes successfully.

Identity and authorization

Use payload.sub as the stable identity key. username and profile data can change. Tokens carry the issuer (iss), audience (aud), issued time (iat), expiry (exp), and an explicit guest boolean, among other claims.

For an operation restricted to registered accounts:

if (payload.guest !== false) {
  throw new Error("A registered account is required");
}

A missing guest claim must not grant registered-account privileges. Even a registered account may have no signing credential. Room membership, moderation, and resource ownership require their own authorization checks.

Expiry and revocation

Access tokens normally last one hour. The app's first-party session route refreshes them using a rotating refresh cookie. Prefer getToken() before a request to a cached flow.jwt value. If retrying a failed request, bound the retry and refresh deliberately; do not loop on authorization errors.

Local signature verification alone cannot learn that a session was revoked after its token was issued. If an operation requires current revocation state, use an authoritative check appropriate to that service. Flow ID also exposes POST /api/session/verify with JSON { "token": "…", "audience": "https://your-app.example" }, returning a payload on success. That endpoint verifies the token and can resolve current profile or room information; it is not a general immediate-revocation check. Revocation prevents refresh, while a valid access JWT can survive until expiry.

See Account security for the user-facing revocation controls and Getting started for first-party session integration.

On this page