Authentication
KalamDB supports user/password bootstrap and JWT bearer tokens. For long-lived apps, prefer JWT + refresh flows.
Auth types
authProvider — recommended
Use authProvider as the source of credentials. The callback is invoked
when the client is created, and you can re-run it with refreshAuth() when
your token changes or before an explicit reconnect path:
The AuthProvider typedef is:
Provider return guidance
Return Auth.jwt(...) for normal deployments.
The Dart SDK also supports:
Auth.basic(...)when you want the client to exchange user/password credentials for a JWT onPOST /v1/api/auth/loginbefore the first query or WebSocket connectAuth.none()for local anonymous access
There is no separate auth: parameter on KalamClient.connect(...) in the Dart SDK. Auth flows go through authProvider, login(...), and refreshToken(...).
refreshAuth()
Call refreshAuth() to proactively push fresh credentials to the Rust layer
without waiting for the next reconnect — useful for scheduled token rotation:
refreshAuth() re-runs the configured authProvider and pushes the refreshed credentials into the Rust client.
disableCompression
Disable gzip compression on WebSocket messages for easier local debugging:
The server will respond with plain-text JSON frames instead of compressed binary frames, making inspection in Wireshark or proxy tools straightforward.
Do not use in production. Compression significantly reduces bandwidth. Only enable for local debugging.
Login (user/password → JWT upgrade)
If your server requires an explicit login step, create a temporary client,
perform login(), then reconnect with the returned access token:
If you return Auth.basic(...) from authProvider, the SDK will also perform the login exchange automatically before the first query or WebSocket connection.
Refresh token
If you have a refresh token and want a new access token: