These session scopes are different from the
TokenScope enum used for elevated access tokens (e.g. wallet:export). Elevated scopes are short-lived and granted via step-up auth — see Step-Up Authentication.How it works
Dynamic emits scopes as a standard JWTscope claim — a single whitespace-separated string per RFC 8693. To check them client-side:
- Read the JWT from
client.token. - Decode the payload (a Base64URL JSON blob).
- Split the
scopeclaim into a string array.
Checking scopes
Wrap the helper above in auserHasScopes function with AND / OR semantics matching the React hook:
Usage
- JavaScript
- React
Server-side validation
Always validate scopes on the server when gating sensitive resources. A determined client can hide UI but cannot fake a JWT signature — verify the JWT against your project’s JWKS in your backend, then check thescope claim there too. See Cookie Authentication for a server-aware setup.
Limitations
- No mixing of
AND/ORin one call. The helper above mirrors the React hook — for nested predicates, compose two calls. - Cookie-based sessions hide the token. In cookie-auth mode,
client.tokenisnullbecause the token lives in an HTTP-only cookie. Read scopes server-side and pass them back to the client through your own API. - Access list / gate evaluation runs at sign-in. If you change a list while the user is signed in, the scopes update only on the next
refreshUserorrefreshAuth.