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
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

clearStoredSession() Future<void>
Log the user out.
deleteAccount() Future<void>
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.
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).
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.
login({required String email, required String password}) Future<KoolbaseUser>
logout() Future<bool>
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.
resendVerificationEmail() Future<ResendVerificationResult>
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.
resetPassword({required String token, required String password}) Future<void>
restoreSession() Future<RestoreResult>
Restore a previously saved session on app launch.
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.
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.
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<KoolbaseUser>
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}) Future<KoolbaseUser>
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>
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.

Operators

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