NestCoreAuth class
Simplified Auth API that wraps the BLoC pattern Provides direct async methods like Supabase
- Inheritance
-
- Object
- ChangeNotifier
- NestCoreAuth
Constructors
- NestCoreAuth(AuthBloc _authBloc, AuthService _authService, TokenManager _tokenManager)
Properties
- currentSession → Session?
-
Get current session (null only when explicitly unauthenticated).
no setter
- currentUser → User?
-
Get current user (null only when explicitly unauthenticated).
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Whether any listeners are currently registered.
no setterinherited
- isAuthenticated → bool
-
Check if user is currently authenticated.
no setter
-
onAuthStateChange
→ Stream<
AuthState> -
Stream of auth state changes for listening to auth events
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- state → AuthState
-
Get current auth state for UI reactivity
no setter
Methods
-
addListener(
VoidCallback listener) → void -
Register a closure to be called when the object changes.
inherited
-
decodeToken(
String token) → Map< String, dynamic> ? - Decode a JWT token locally without a network call (ON-SEC-06) Returns the token payload, or null if the token is malformed
-
deleteUser(
) → Future< void> - Permanently delete the signed-in user's account, then clear the local session (auth state becomes unauthenticated).
-
dispose(
) → void -
Discards any resources used by the object.
override
-
enrollMfaTotp(
{String? friendlyName, String? code}) → Future< Map< String, dynamic> > -
Begin TOTP enrollment — returns
secret,otpauth_url,qr_code,factor_id. When the user already has a verified factor, pass a current TOTP or recoverycode(server answers 401MFA_REAUTH_REQUIREDotherwise). -
getUser(
) → Future< User> - Get current user profile Returns user when successful, throws if not authenticated
-
isPasskeySupported(
) → Future< bool> - True if the platform exposes any passkey authenticator (Touch/Face ID, device PIN, security key, etc.).
-
listMfaFactors(
) → Future< List> - List the current user's MFA factors.
-
listPasskeys(
) → Future< List< PasskeyDevice> > - List all registered passkeys for the current user.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyListeners(
) → void -
Call all the registered listeners.
inherited
-
refreshSession(
) → Future< Map< String, dynamic> > -
Refresh current session.
Returns user and session when successful. Throws AuthException when the
session is gone (
UNAUTHENTICATED) or the server could not be reached (REFRESH_FAILED— the stored session is kept). -
regenerateMfaRecoveryCodes(
{String? code}) → Future< Map< String, dynamic> > -
Regenerate the user's MFA recovery codes. Returns
{ codes: [...] }once. Requires a current TOTP or recoverycodewhen MFA is active. -
registerPasskey(
{String? deviceName}) → Future< PasskeyDevice> - Register a new passkey for the currently authenticated user. Drives the native registration ceremony and posts the attestation back to the NestCore server.
-
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that are
notified when the object changes.
inherited
-
renamePasskey(
{required String deviceId, required String deviceName}) → Future< void> - Rename a registered passkey.
-
resetPassword(
{required String email, required String token, required String newPassword}) → Future< Map< String, dynamic> > -
Reset password with the code from the recovery email.
Returns
{email, message}; the user then signs in with the new password. -
resetPasswordForEmail(
String email) → Future< Map< String, dynamic> > - Send password recovery email Returns a map with email and message when email is sent
-
revokePasskey(
{required String deviceId}) → Future< void> - Revoke (remove) a registered passkey.
-
signInWithEmail(
String email) → Future< Map< String, dynamic> > - Sign in with email (OTP-based flow) Returns a map with email and message when OTP is sent
-
signInWithPasskey(
{String? identifier}) → Future< Map< String, dynamic> > - Sign in using a passkey. Drives the native assertion ceremony and stores the resulting session.
-
signInWithPassword(
{required String email, required String password}) → Future< Map< String, dynamic> > - Traditional signin with email and password.
-
signInWithSms(
String phone) → Future< Map< String, dynamic> > -
Send a one-time code to a phone number (E.164, e.g.
+15555550123). Rate limited per phone:AuthExceptioncodeSMS_RATE_LIMITED(429). -
signOut(
) → Future< void> - Sign out current user Returns when signout is complete
-
signUp(
{required String email, required String password, Map< String, dynamic> ? metadata}) → Future<Map< String, dynamic> > - Traditional signup with email and password Returns email and message when OTP is sent for verification
-
signUpWithEmail(
String email, {Map< String, dynamic> ? metadata}) → Future<Map< String, dynamic> > - Sign up with email (OTP-based flow) Returns a map with email and message when OTP is sent
-
signUpWithPasskey(
{required String email, Map< String, dynamic> ? userMetadata, String? deviceName}) → Future<Map< String, dynamic> > -
Sign up a new account using a passkey in a single ceremony.
Only
emailis required;userMetadataanddeviceNameare optional. -
toString(
) → String -
A string representation of this object.
inherited
-
unenrollMfa(
{required String factorId, String? code}) → Future< void> -
Remove an MFA factor. Requires a current TOTP or recovery
codewhen the user has a verified factor. -
updateUser(
{String? email, String? password, String? currentPassword, Map< String, dynamic> ? metadata}) → Future<Map< String, dynamic> > -
Update current user profile.
Changing
emailorpasswordrequirescurrentPassword(accounts without a password instead need a session less than 10 minutes old); otherwise the server answers 401REAUTH_REQUIRED. Returns updated user when successful -
verifyEmailChange(
String code) → Future< Map< String, dynamic> > -
Apply a pending email change (requested with updateUser) using the code
sent to the new address. The access token keeps the old
emailclaim until the next refresh. -
verifyMfa(
{required String challengeToken, required String code}) → Future< Map< String, dynamic> > -
Complete an MFA-gated sign-in. When
signInWithPasswordreturns anmfa_requiredchallenge, call this with itschallenge_tokenand a TOTP code. Stores the resulting session. -
verifyMfaEnrollment(
{required String factorId, required String code}) → Future< Map< String, dynamic> > -
Confirm a TOTP enrollment with the first code from the authenticator.
On success the result includes
recovery_codes(shown once). -
verifySignIn(
{required String email, required String otp}) → Future< Map< String, dynamic> > - Verify email signin with OTP Returns user and session when successful
-
verifySignUp(
{required String email, required String otp, String? password}) → Future< Map< String, dynamic> > - Verify email signup with OTP Returns user and session when successful
-
verifySmsOtp(
{required String phone, required String code}) → Future< Map< String, dynamic> > -
Verify a phone OTP and sign in (creates the user on first sign-in).
Returns
{user, session}and updates auth state like a password sign-in. Too many attempts →AuthExceptionwith codeOTP_RATE_LIMITED(429). -
verifyToken(
String token) → Future< Map< String, dynamic> > - Verify a JWT token against the server (ON-SEC-04) Returns a map with valid, user, and error fields from the API
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited