import 'two_factor.dart'; import 'verification.dart'; /// Ephemeral input: never persist, log, or include passwords in provider state. class LoginRequest { const LoginRequest({ required this.email, required this.password, required this.locale, }); final String email; final String password; final String locale; } class SignupRequest { const SignupRequest({ required this.name, required this.email, required this.password, required this.locale, }); final String name; final String email; final String password; final String locale; } /// An operation result, not proof of a session or an authorization decision. class AuthResult { const AuthResult({ required this.userId, required this.isSimulated, this.challenge, this.delivery, }); final String userId; final FactorChallenge? challenge; final VerificationDelivery? delivery; final bool isSimulated; } enum AuthError { invalidCredentials, accountNotVerified, emailInUse, signupNeedsAssistance, unavailable, unexpected, factorLocked, factorCooldown, factorRequired, } class AuthException implements Exception { const AuthException(this.code); final AuthError code; @override String toString() => 'AuthException(${code.name})'; } enum AuthStatus { idle, loading, challenge, success, error } class AuthState { const AuthState._(this.status, {this.result, this.error}); const AuthState.idle() : this._(AuthStatus.idle); const AuthState.loading() : this._(AuthStatus.loading); const AuthState.success(AuthResult result) : this._(AuthStatus.success, result: result); const AuthState.challenge(AuthResult result) : this._(AuthStatus.challenge, result: result); const AuthState.failure(AuthError error) : this._(AuthStatus.error, error: error); final AuthStatus status; final AuthResult? result; final AuthError? error; bool get isLoading => status == AuthStatus.loading; }