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:{ 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’sPermEntry::matches exactly:
- V1 tokens — glob-matched against the
read/writelists. 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’sclient_idbefore matching.
Multi-agent pattern
When using{clientId} in V2 permission patterns, each agent’s token is automatically scoped to its own keys:
{clientId} patterns.