account library

Brix account block: what a logged-in user does with their own account (current user, profile, avatar, change password, delete account, app start and logout).

Also exports the auth block it builds on.

Classes

AccountProvider<TUser, TProfileUpdate>
The backend for a logged-in user's own account: current user, profile, avatar, password, deletion. Kept apart from AuthProvider, so an app writes only the parts it has.
AuthCapabilities
What the backend's auth flow looks like. The flows pick the next screen from this instead of checking which backend is used.
AuthCodeEntryFlow<TUser>
A CodeEntryFlow whose codes come from an AuthProvider (signup code, password reset).
AuthFeedback
Shows the auth flows' results in the app's own alert style.
AuthFormFlow<TUser>
A FormFlow talking to an AuthProvider.
AuthFormState
State of a form screen (login, forgot password, signup, change password...).
AuthNavigator
Opens the app's screens for the auth flows, so brix never knows route names or the navigation library.
AuthProvider<TSignup, TUser>
The backend behind the auth flows. Each app writes one subclass for its backend (REST, Firebase, Supabase, ...).
AuthSession<TUser>
A logged-in user and the tokens the backend gave for them.
AuthSessionStore<TUser>
Where the app keeps the session between launches. Each app writes one subclass on its own storage.
AuthWarning
A local problem the flows report before any backend call, with a plain English message the app can show as it is.
AvatarUpload
A picture for AccountProvider.uploadAvatar: a file path (mobile) or the bytes (web, memory), plus its name and type.
BrixFlow<S>
Base of every brix flow: holds one immutable state S and tells listeners when it changes.
BrixLogger
A readable console log for apps, one box per message, so lines that come one after another never run together:
ChangePasswordFlow
The change password screen of a logged-in user. The user stays logged in on this device; ending other sessions is the backend's job.
CodeEntryFlow
Base of the code screens: one submit at a time, a rejected code counted in CodeEntryState.failedAttempts, "resend" after a ResendCooldown, and the countdown stopped on dispose. Subclasses say how long a code is, how a code is sent and how errors map.
CodeEntryState
State of a screen where the user types an emailed code (signup code, password reset).
DeleteAccountFlow
Deleting the logged-in user's account, as the backend's AccountDeletionMode says. On success everything the store keeps is cleared ("remember me" too, the account is gone) and login opens.
Failed<T>
The call did not work; failure says why.
Failure
Why something did not work. Every block (auth, network, account, ...) reports problems with these classes instead of plain strings, so an app can react to the kind of problem, not only show a text.
ForgotPasswordFlow
The "forgot password" screen: asks the backend to send a reset code or link, then moves on as AuthCapabilities.resetMode says.
FormFlow
Base of the form flows: one call at a time, busy state while it runs, and thrown errors shown as a failure instead of crashing.
Json
A safe way to read decoded JSON (from any backend: REST, Firebase, Supabase, ...) into your own models.
LoginFlow<TUser>
Everything the login screen does, without any UI or state library.
NetworkFailure
No connection or the request timed out.
OtpPurpose
Why a one-time code was sent.
OtpVerificationFlow<TUser>
The code screen after signup: verify the emailed code, ask for a new one after a cooldown, or go back to change the email.
PasswordPolicy
What a new password must contain (signup, reset, change password).
PasswordRule
One requirement of a PasswordPolicy, for a live checklist on screen.
ProfileFlow<TUser, TProfileUpdate>
The logged-in user's profile: load, save the app's typed update, new avatar. After a save or an avatar the user is reloaded, and the saved session gets the fresh user.
ProfileState<TUser>
State of the profile screen.
RememberedCredentials
Login details kept for "remember me".
ResetPasswordFlow
The "new password" screen of ResetMode.otp: the emailed code plus a new password, a new code after a cooldown, or back to change the email.
Result<T>
Outcome of any brix call: Success or Failed, nothing else.
ServerFailure
The server failed or answered with an unexpected status.
SessionFlow<TUser>
Starts and ends the user's session: what opens when the app starts, and logout.
SessionState
State of the session actions.
SignupFlow<TSignup, TUser>
The signup screen. The app builds its own typed body (TSignup); the flow checks the password, sends it once, then opens the code screen (when the backend sends one) or login.
Success<T>
The call worked. For calls without data use Success<void>(null).
UnauthorizedFailure
Not logged in or the session ended (HTTP 401).
UnknownFailure
Anything else. cause keeps the original error for logging; it is never meant to be shown to the user.
UnsupportedFailure
The backend does not offer this call (e.g. OTP on a link-only backend).
ValidationFailure
The input was rejected (HTTP 400 / 422, form rules on the server).

Enums

AccountDeletionMode
How the backend confirms that the user really wants their account gone.
LogLevel
How important a log line is. Lines below BrixLogger.minLevel are skipped.
ResetMode
How a backend lets the user set a new password.

Functions

failureFromError(Object error, StackTrace stackTrace) → Failure
Default way to turn a thrown error into a Failure.
maskIdentifier(String identifier) → String
Hides most of an email or phone number for display, e.g. on the code screen ("code sent to ru•••@gmail.com").