feat(online): session compte, stockage sécurisé et adapter API (ticket #64)
Ajoute l'adapter API distant (infrastructure/remote/auth_api.dart, http_api_client.dart) et le stockage sécurisé du token d'auth (infrastructure/security/secure_storage_auth_token_store.dart), câblés dans app_bootstrap.dart. Étend le modèle Drift (migration schemaVersion 9→10) et la couche application (ports, use cases, entités) pour la session de compte. flutter pub get OK (ajout http, flutter_secure_storage), build_runner OK, dart format appliqué, analyze propre (mêmes infos préexistantes), 109/109 tests verts, build APK debug validé. Premier ticket du chantier "Ajouter les features serveur au client" (#63). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@ -15,6 +15,64 @@ abstract interface class IdGenerator {
|
||||
String newId();
|
||||
}
|
||||
|
||||
enum RemoteAuthFailure {
|
||||
invalidCredentials,
|
||||
emailAlreadyUsed,
|
||||
network,
|
||||
unknown,
|
||||
}
|
||||
|
||||
final class RemoteAuthException implements Exception {
|
||||
const RemoteAuthException(this.failure, [this.message]);
|
||||
|
||||
final RemoteAuthFailure failure;
|
||||
final String? message;
|
||||
|
||||
@override
|
||||
String toString() => message ?? failure.name;
|
||||
}
|
||||
|
||||
final class RemoteAuthResult {
|
||||
const RemoteAuthResult({
|
||||
required this.userId,
|
||||
required this.email,
|
||||
required this.token,
|
||||
required this.expiresAt,
|
||||
});
|
||||
|
||||
final String userId;
|
||||
final String email;
|
||||
final String token;
|
||||
final DateTime expiresAt;
|
||||
}
|
||||
|
||||
abstract interface class AuthTokenStore {
|
||||
Future<void> saveToken(String token, DateTime expiresAt);
|
||||
Future<String?> readToken();
|
||||
Future<void> clearToken();
|
||||
}
|
||||
|
||||
abstract interface class OnlineAccountRepository {
|
||||
Future<UserAccountSession?> currentSession();
|
||||
Future<void> saveSession(UserAccountSession session);
|
||||
Future<void> clearSession();
|
||||
}
|
||||
|
||||
abstract interface class RemoteAuthApi {
|
||||
Future<RemoteAuthResult> register({
|
||||
required String email,
|
||||
required String password,
|
||||
String? displayName,
|
||||
});
|
||||
|
||||
Future<RemoteAuthResult> login({
|
||||
required String email,
|
||||
required String password,
|
||||
});
|
||||
|
||||
Future<void> logout(String token);
|
||||
}
|
||||
|
||||
abstract interface class ExerciseRepository {
|
||||
Future<Exercise?> findById(String id);
|
||||
Future<List<Exercise>> listActive();
|
||||
|
||||
Reference in New Issue
Block a user