app_auth_manager 1.0.6
app_auth_manager: ^1.0.6 copied to clipboard
A comprehensive Flutter app auth manager package that provides authentication support.
Changelog #
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
1.0.6 - 2025-06-30 #
Fixed #
- Removed redundant refreshAuthState() call during initialization: Firebase's
authStateChanges()
listener automatically emits the current auth state when it starts listening, so the manual refresh was causing duplicate state emissions and potential race conditions. This improves stream reliability and prevents misleading state changes.
1.0.5 - 2025-06-29 #
- Improve error parameter passing
1.0.4 - 2025-06-29 #
- Undo initial stream event yield
1.0.3 - 2025-06-29 #
Improved #
- Stream-based Authentication State: Enhanced authStateStream to properly emit current state for new subscribers
1.0.2 - 2025-06-29 #
- Update error message required parameter for auth state
1.0.1 - 2025-06-23 #
- Update error handling in authentication flows to display 'Unknown error' when error message is null
1.0.0 - 2025-06-23 #
Added #
- Core Authentication Interface: Abstract
IAuthManager
interface for dependency inversion - Comprehensive Data Models: Type-safe models using flutter_shared_utilities BaseDataModel
AuthUserModel
: Complete user profile information with provider dataAuthStateModel
: Real-time authentication state managementAuthResultModel
: Detailed operation results with success/failure statesAuthErrorModel
: Comprehensive error handling with user-friendly messages
- Firebase Authentication Implementation: Full Firebase Auth integration
- Email/password authentication (sign in, sign up)
- Anonymous authentication
- Google Sign-In integration
- Apple Sign-In integration
- Account deletion functionality
- Social Authentication Support:
- Google Sign-In with full profile data
- Apple Sign-In with privacy-focused implementation
- Extensible framework for additional providers
- Authentication State Management:
- Real-time state updates via streams
- Authentication status tracking (authenticated, unauthenticated, unknown)
- Loading state management
- Error state handling
- Comprehensive Error Handling:
- Firebase Auth error conversion
- User-friendly error messages
- Error categorization (network, user, system, permission)
- Retryable error identification
- Validation Utilities:
- Email format validation
- Phone number format validation
- Password strength validation with scoring (0-4)
- Provider support validation
- Session Management Framework:
- Session timeout configuration
- Token refresh capabilities
- Session validation methods
- Analytics and Monitoring:
- Authentication operation statistics
- Debug logging capabilities
- Authentication event tracking
- Configuration Management:
- Configurable authentication settings
- Provider capability management
- Debug mode toggle
- Example Application: Complete Flutter app demonstrating:
- Authentication state management
- Email/password authentication
- Social authentication (Google, Apple)
- Anonymous authentication
- User profile display
- Account deletion
- Error handling
- Comprehensive Documentation:
- Detailed README with setup instructions
- API documentation
- Best practices guide
- Troubleshooting section
- Migration guide from firebase_auth
Dependencies #
flutter_shared_utilities: ^1.0.5
- Type-safe data models and utilitiesfirebase_core: ^3.14.0
- Firebase core functionalityfirebase_auth: ^5.6.0
- Firebase authentication servicesgoogle_sign_in: ^6.3.0
- Google Sign-In integrationsign_in_with_apple: ^7.0.1
- Apple Sign-In integrationlocal_auth: ^2.3.0
- Biometric authentication supportcrypto: ^3.0.6
- Cryptographic utilities for secure operationsdart_jsonwebtoken: ^3.2.0
- JWT token handling and validationapp_logger_manager: ^1.0.2
- Comprehensive logging and debugging
Project Structure #
lib/
├── src/
│ ├── constants/
│ │ └── auth_constants.dart # Authentication constants
│ ├── interfaces/
│ │ └── i_auth_manager.dart # Abstract authentication interface
│ ├── models/
│ │ ├── auth_user_model.dart # User data model
│ │ ├── auth_state_model.dart # Authentication state model
│ │ ├── auth_result_model.dart # Operation result model
│ │ └── auth_error_model.dart # Error handling model
│ ├── implementations/
│ │ └── firebase_auth_manager.dart # Firebase implementation
│ └── mixin/
│ ├── auth_error_mixin.dart # Error handling utilities
│ ├── auth_mixin.dart # Core authentication utilities
│ ├── auth_provider_mixin.dart # Provider-specific utilities
│ └── auth_validation_mixin.dart # Validation utilities
└── app_auth_manager.dart # Main export file
example/
├── lib/
│ ├── main.dart # Main application entry
│ ├── auth_example_app.dart # App configuration
│ ├── pages/ # Application pages
│ ├── theme/ # App theming
│ └── widgets/ # Reusable widgets
├── android/ # Android configuration
├── ios/ # iOS configuration
└── firebase.json # Firebase configuration
Features Overview #
- ✅ Email/Password Authentication - Complete sign-up and sign-in flow
- ✅ Anonymous Authentication - Guest access functionality
- ✅ Google Sign-In - Full profile integration
- ✅ Apple Sign-In - Privacy-focused authentication
- ✅ Account Management - Profile updates and account deletion
- ✅ Error Handling - Comprehensive error management
- ✅ State Management - Real-time authentication state
- ✅ Validation - Input validation and password strength
- ✅ Analytics - Authentication operation tracking
- ⏳ Phone Authentication - SMS verification (planned)
- ⏳ Email Verification - Email confirmation flow (planned)
- ⏳ Password Reset - Password recovery (planned)
- ⏳ Multi-Factor Authentication - Enhanced security (planned)
- ⏳ Biometric Authentication - Fingerprint/Face ID (planned)
- ⏳ Additional Social Providers - Facebook, Twitter, GitHub (planned)
API Overview #
// Initialize authentication manager using factory constructor
final authManager = await FirebaseAuthManager.create();
// Email/password authentication
final signUpResult = await authManager.signUpWithEmailAndPassword(
email: 'user@example.com',
password: 'securePassword123',
displayName: 'John Doe',
);
final signInResult = await authManager.signInWithEmailAndPassword(
email: 'user@example.com',
password: 'securePassword123',
);
// Social authentication
final googleResult = await authManager.signInWithGoogle();
final appleResult = await authManager.signInWithApple();
// Anonymous authentication
final anonymousResult = await authManager.signInAnonymously();
// State management
StreamBuilder<AuthStateModel>(
stream: authManager.authStateStream,
builder: (context, snapshot) {
final state = snapshot.data ?? AuthStateModel.initial();
return state.isAuthenticated
? HomePage(user: state.user!)
: LoginPage();
},
);
// Error handling
if (result.isFailure) {
final userMessage = authManager.getUserFriendlyErrorMessage(result.errorCode);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(userMessage)),
);
}
Documentation #
- Setup Guide: Complete Firebase, Google, and Apple Sign-In configuration
- API Reference: Detailed method documentation
- Best Practices: Security and implementation guidelines
- Migration Guide: Easy migration from firebase_auth package
- Troubleshooting: Common issues and solutions
- Example App: Full working implementation
Testing #
- Abstract interface enables easy mocking for unit tests
- Example app provides integration testing reference
- Comprehensive error handling for robust testing scenarios
Security Features #
- Input validation for all authentication methods
- Password strength validation with configurable requirements
- Session timeout management
- Secure token handling
- Error message sanitization
- Provider-specific security implementations
Performance #
- Lazy initialization of authentication providers
- Efficient state management with streams
- Minimal dependencies for core functionality
- Optimized for production use
Accessibility #
- User-friendly error messages
- Comprehensive documentation
- Clear API design
- Support for assistive technologies