Ajoute la couche application (ports, use cases), les entités du domaine, l'endpoint api/auth_api.dart (register/login/logout) et son câblage dans le router, le hashing de mot de passe et le service de token (infrastructure/security), et l'adapter Postgres des repositories d'auth s'appuyant sur la table users du ticket #49. dart pub get OK, dart analyze clean, dart test 10/10 vert (test PostgreSQL réel skip faute de Docker disponible dans ce sandbox). Logique d'auth et middleware testés via repositories fake en mémoire ; les endpoints HTTP register/login/logout n'ont pas pu être exercés de bout en bout faute d'accès à un vrai PostgreSQL local. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
33 lines
822 B
Dart
33 lines
822 B
Dart
import 'dart:math';
|
|
|
|
import '../../application/application.dart';
|
|
|
|
final class SystemClock implements Clock {
|
|
const SystemClock();
|
|
|
|
@override
|
|
DateTime now() => DateTime.now().toUtc();
|
|
}
|
|
|
|
final class UuidV4Generator implements IdGenerator {
|
|
UuidV4Generator({Random? random}) : _random = random ?? Random.secure();
|
|
|
|
final Random _random;
|
|
|
|
@override
|
|
String newId() {
|
|
final bytes = List<int>.generate(16, (_) => _random.nextInt(256));
|
|
bytes[6] = (bytes[6] & 0x0f) | 0x40;
|
|
bytes[8] = (bytes[8] & 0x3f) | 0x80;
|
|
final hex = bytes.map((byte) => byte.toRadixString(16).padLeft(2, '0'));
|
|
final value = hex.join();
|
|
return [
|
|
value.substring(0, 8),
|
|
value.substring(8, 12),
|
|
value.substring(12, 16),
|
|
value.substring(16, 20),
|
|
value.substring(20),
|
|
].join('-');
|
|
}
|
|
}
|