auth library

Brix auth block: backend-agnostic login, signup, OTP, password reset.

Also exports the core block (Result, Failure) it is built on.

Classes

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.
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:
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).
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.
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.
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

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").