vaultbase library

Dart client for Vaultbase.

Classes

AdminAuth
Admin sign-in and admin-only flows: vb.auth.admin.
AsyncAuthStore
A store backed by async storage: read loads the saved session (a JSON string, or null) once at construction, write saves each change (null to delete).
AuthResult
The outcome of a sign-in.
AuthService
Sign-in and the session.
AuthStore
Holds the session. Requests read current synchronously; onChange emits every change (sign-in, refresh, sign-out).
Batch
Several operations sent in one request and run in one transaction.
BatchResult
The result of one operation in a batch.
CancelToken
Cancels the requests it is passed to.
Collection<T>
Records of one collection.
CollectionAuth
Sign-in flows of one auth collection: vb.auth.collection('users').
CustomRoutes
Custom routes, served under /api/v1/custom/.
Field
A field name or dotted path, inserted into a filter without quotes.
FileMeta
A stored file, as the upload returns it. Set a file field to filename to attach it to a record.
Files
Upload, URLs and access tokens.
FileToken
An access token for a protected file.
Flags
Feature flags, evaluated by the server for this client's context.
ListResult<T>
One page of a list.
MemoryAuthStore
Keeps the session in memory only; it is gone when the app exits.
MergeRequired
An OAuth sign-in matched an existing account by email: confirm the link with CollectionAuth.oauth2MergeConfirm. Nothing is stored yet.
MfaRequired
The account has two-factor sign-in on: finish with CollectionAuth.loginMfa and this mfaToken. Nothing is stored yet.
OAuth2Authorization
The start of an OAuth sign-in: send the user to authorizeUrl.
OAuth2Provider
An OAuth provider enabled on the server.
Realtime
Record changes pushed over one WebSocket (<baseUrl>/realtime), shared by every subscription of a client. It connects on the first subscription, sends the session's token (and a new one after each refresh), reconnects with backoff and subscribes again, and closes after the last subscription is cancelled. A server that refuses this app's origin (origin_not_allowed) is not retried until the client is created again.
RealtimeEvent
A change to a record, as realtime delivers it.
RealtimeSubscription
A live subscription. cancel it when done.
RecordModel
A record as the server returns it, with typed getters over the JSON map.
SignedIn
Signed in; the session is stored (except for AdminAuth.impersonate).
Singleton<T>
The one record of a singleton collection, at the collection's own path.
StoredAuth
A signed-in session: the token, and the user or admin record it belongs to.
UploadFile
A file to upload. Build it from bytes, or from a function that opens the data again each time it is sent (a retry after a token refresh sends it twice).
Vaultbase
The Vaultbase client.

Enums

AuthFailure
Why a request was refused for its credentials.
ImageFormat
MaintenanceLevel
The level of a server's maintenance mode.
RealtimeAction
What happened to a record.
RealtimeState
The realtime connection's state.
ThumbFit

Constants

sdkVersion → const String
This package's version.
serverCompat → const String
The server versions this SDK is tested against.

Functions

buildFilter(String expression, [Map<String, Object?> params = const {}]) → String
Builds a filter expression, inserting each {:name} from params escaped for the server's filter grammar:
decodeJwtPayload(String token) → Map<String, dynamic>?
The payload of a JWT, without checking the signature (that is the server's job). Null when token is not a JWT.

Exceptions / Errors

AuthException
401 / 403.
CancelledException
The request was cancelled: by its CancelToken, or by a newer request with the same request key.
ConflictException
  • MaintenanceException
    503 from a server in maintenance mode. until and retryAfter are set when the admin said when it should be back.
    NetworkException
    The request never got a response: no connection, DNS, TLS, a timeout.
    PreconditionFailedException
    412: the record changed since its ETag was read. currentEtag is the record's ETag now, when the server sent it.
    RateLimitException
  • retryAfter is the server's Retry-After, capped at 10 seconds.
  • ServerException
    Any other non-2xx response.
    ValidationException
    422: the body failed validation. details maps field names to messages.
    VaultbaseException
    Every error the client throws is a VaultbaseException; switch over the subclasses is exhaustive.