KoolbaseAuthClient class

Constructors

KoolbaseAuthClient({required AuthApi api, KoolbaseAuthStorage? storage})

Properties

accessToken → String?
no setter
authStateChanges → Stream<KoolbaseUser?>
no setter
currentUser → KoolbaseUser?
no setter
hashCode → int
The hash code for this object.
no setterinherited
isAuthenticated → bool
no setter
lastSignOutReason → KoolbaseSignOutReason?
Why the last session ended (#104): KoolbaseSignOutReason.signedOut when the person signed out, KoolbaseSignOutReason.sessionEnded when it ended on its own. Null while signed in. Read it when authStateChanges emits null.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

auditLog({int? limit, int? offset}) → Future<KoolbaseAuditPage>
Permanently deletes the signed-in user's account: the server removes every session and the auth record, then fires auth.user.deleted (subscribe a Function to it for app-data cleanup). Unlike logout, a server failure here rethrows — the account still existing is a state the app must know about. Local session state is cleared only after the server confirms. Every session the signed-in user has — a "where you're signed in" list.
changePassword({required String currentPassword, required String newPassword}) → Future<void>
Changes the signed-in user's password.
clearStoredSession() → Future<void>
Log the user out.
confirmMfaEnrollment(String code) → Future<List<String>>
Turns MFA on and returns ten recovery codes — shown this once only. Every other device is signed out.
deleteAccount() → Future<void>
disableMfa() → Future<void>
Turns MFA off. Needs stepUpMfa within the last ten minutes.
dispose() → void
Dispose of the auth client. Closes the auth state stream and cascades to AuthApi.dispose which closes the underlying HTTP client iff the SDK owns it (caller-supplied clients are not closed).
enrollMfa() → Future<MfaEnrollment>
Starts adding an authenticator. Needs a sign-in within ten minutes. Show MfaEnrollment.otpauthUri as a QR code, then call confirmMfaEnrollment with the first code the app shows.
forgotPassword({required String email}) → Future<void>
getCurrentUser() → Future<KoolbaseUser>
linkPhone({required String phoneNumber, required String code}) → Future<void>
Link a phone number to the currently authenticated user. User must already be signed in (via email/password or another auth method) and must have requested an OTP for this phone number first.
listSessions() → Future<List<KoolbaseSessionInfo>>
login({required String email, required String password}) → Future<KoolbaseUser>
logout() → Future<bool>
mfaStatus() → Future<MfaStatus>
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
refreshSession() → Future<bool>
Manually refresh the access token using the persisted refresh token. Returns true on success, false if no session exists or refresh failed.
regenerateRecoveryCodes() → Future<List<String>>
Replaces all recovery codes; the old ones stop working. Needs stepUpMfa within the last ten minutes.
renewRejected(String refused) → Future<String?>
A data request carrying refused came back unauthenticated. Renews the session and returns the token to send again with, or null when there is none: nobody is signed in, or the server refused the renewal too, which ends the session (#96).
requestEmailCode(String email) → Future<void>
Emails a six-digit sign-in code.
resendVerificationEmail() → Future<ResendVerificationResult>
resendVerificationEmailToAddress(String email) → Future<void>
Re-send the email-verification link to the current (authenticated but unverified) user. No-op-safe: if the account is already verified, the result's ResendVerificationResult.alreadyVerified is true and nothing is sent. Server-throttled — a 60s cooldown between sends and a daily cap; the result carries ResendVerificationResult.cooldownUntil so you can show a countdown. Throws if the cooldown or daily cap is exceeded. Ask for a new verification email, with no session.
resetPassword({required String token, required String password}) → Future<void>
restoreSession() → Future<RestoreResult>
Restore a previously saved session on app launch.
revokeAllOtherSessions() → Future<int>
Sign out every OTHER session, keeping this one. Returns how many ended.
revokeSession(String sessionId) → Future<void>
Sign out one session by id.
sendOtp({required String phoneNumber}) → Future<OtpSendResult>
Send a 6-digit OTP to the given E.164 phone number. Returns the OTP expiry timestamp so the app can show a resend countdown.
sessionRejected() → Future<void>
A data request was refused as unauthenticated and renewing could not help: the session is over, so it ends here and authStateChanges emits null. Unless the renewal failed only for want of a connection: then the session may well be good, and signing someone out for a dropped network would be wrong (#96).
signInWithApple({required String identityToken, String? nonce, AppleFullName? fullName}) → Future<KoolbaseUser>
Sign in with Apple using a credential obtained from a native Apple Sign-In SDK.
signInWithEmailCode({required String email, required String code}) → Future<KoolbaseUser>
Signs in with a code from requestEmailCode, storing the session exactly as login does. An unknown address becomes an account only if the project still accepts sign-ups. Each code works once and allows three attempts.
signInWithGoogle({required String idToken, String? nonce}) → Future<KoolbaseUser>
Sign in with Google using an idToken obtained from a native Google Sign-In SDK.
signUp({required String email, required String password, String? fullName}) → Future<SignUpResult>
Create an account.
stepUpMfa({String? code, String? recoveryCode}) → Future<void>
Re-confirms the second factor, opening ten minutes to change MFA — with a code from the authenticator, or a recovery code.
toString() → String
A string representation of this object.
inherited
unlock(String token) → Future<void>
Consume an unlock token from a brute-force unlock email. Apps typically extract this token from a deep link parameter when the user clicks the unlock link in their email.
updateProfile({String? fullName, String? avatarUrl, KoolbaseAvatarFile? avatar, bool removeAvatar = false}) → Future<KoolbaseUser>
Updates the signed-in user's profile. Only what is given changes.
validAccessToken() → Future<String?>
Returns a currently-valid access token for data-plane requests, refreshing (single-flight) if the cached one is at/near expiry. Returns null when no user is authenticated or a refresh fails — callers then send the request api-key-only and the server treats it as having no end-user identity.
verifyEmail(String token) → Future<void>
verifyMfa({required String challengeToken, required String code}) → Future<KoolbaseUser>
Finishes sign-in with a code from the person's authenticator app.
verifyOtp({required String phoneNumber, required String code}) → Future<PhoneVerifyResult>
Verify the OTP code and complete sign-in. If no user exists with this phone, one is created. The returned PhoneVerifyResult.isNewUser flag lets the app route first-time users to onboarding.
verifyRecoveryCode({required String challengeToken, required String code}) → Future<RecoveryCodeSignInResult>
Finishes sign-in with a recovery code. Each works once; prompt the person to regenerate when RecoveryCodeSignInResult.recoveryCodesRemaining reaches zero.

Operators

operator ==(Object other) → bool
The equality operator.
inherited