Skip to main content
The SDK evaluates permissions against the parsed token claims on the client side. This lets you gate UI actions (disable buttons, hide sections) without waiting for a server response.

client.canRead(crdtId)

Returns true if the token allows reading crdtId.

client.canWrite(crdtId, opMask?)

Returns true if the token allows writing crdtId. Pass an optional opMask to check op-level access (V2 tokens only).

Standalone helpers

canRead and canWrite are also exported as standalone functions — useful when you have the claims but not a client instance (e.g. in server-side rendering or middleware):

OpMasks reference

Op masks are combined with | to allow multiple operations.

Session revocation

An admin token can forcefully close any active WebSocket connection:
The server sends the target client a { code: 4401, message: "session revoked" } error frame before closing, giving the client an opportunity to surface a meaningful error. Returns HttpError with status 404 if the client is not currently connected, or 403 if the caller’s token is not admin.
Revocation takes effect immediately regardless of ops the target client has in flight — the connection is closed before the next message is processed. This is a hard close, not a graceful drain.

How it works

The logic mirrors the server’s PermEntry::matches exactly:
  • V1 tokens — glob-matched against the read/write lists. Op masks are ignored (no op granularity in V1).
  • V2 tokens — rules are evaluated first-match-wins. Each rule may have a glob pattern (p), an op mask (o), and a per-rule expiry (e). The {clientId} placeholder is expanded to the token’s client_id before matching.
Because this runs locally against the decoded claims, it is synchronous and requires no network access. The server still enforces permissions independently — client-side checks are for UX only.

Multi-agent pattern

When using {clientId} in V2 permission patterns, each agent’s token is automatically scoped to its own keys:
See Tokens for how to issue V2 tokens with {clientId} patterns.