juice_auth
Canonical specification for the juice_auth companion package
Purpose
Authentication and authorization workflows including login, logout, token refresh, and session management.
Dependencies
External: None
Juice Packages:
- juice_network - API calls
- juice_storage - Secure token storage
Architecture
Bloc: AuthBloc
Lifecycle: Permanent
State
class AuthState extends BlocState {
final AuthStatus status; // unauthenticated, authenticating, authenticated, refreshing
final User? currentUser;
final AuthTokens? tokens;
final DateTime? tokenExpiry;
final AuthError? lastError;
final Set<String> permissions;
}
Events
LoginEvent- Username/password or OAuth loginLogoutEvent- Clear session and tokensRefreshTokenEvent- Refresh access tokenCheckAuthStatusEvent- Restore session from storageUpdatePermissionsEvent- Update user permissionsBiometricAuthEvent- Biometric authentication
Rebuild Groups
auth:status- Authentication state changesauth:user- User profile changesauth:permissions- Permission changes
Integration Points
StateRelay to:
- juice_network - Authorization header injection
EventSubscription to:
- juice_analytics - Auth events tracking
Open Questions
To be discussed