- LiveKit call E2EE: CallE2EEManager exchanges encryption keys via Matrix to-device events (m.rtc.encryption_keys) for interop with Element X - Olm bootstrapped in index.html before Flutter init; main.dart logs result - Encrypted messages shown with lock icon and informative fallback text - Profile screen: key restore dialog + security setup (cross-signing/backup) - Jitsi feature: welcome screen (public, no login), conference tab, full-screen embed via JitsiMeetExternalAPI, JitsiLink parser for all common link formats - Help tab: expandable cards for encryption, video calls, account management - Web security model: no session persistence — device ID only across visits - Media auth: MSC3916 authenticated endpoint for avatars (Synapse 1.120+) - Router: welcome route as public landing page; jitsi route as public - Manifest/index.html: M8Chat branding, dark theme colours Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
69 lines
2.0 KiB
Dart
69 lines
2.0 KiB
Dart
// Version: 2.0.0 | Created: 2026-04-01 | Updated: 2026-04-11
|
|
// Riverpod notifier that owns the auth state machine.
|
|
//
|
|
// WEB SECURITY MODEL: Every visit requires a fresh login. No session
|
|
// persistence. Only the Matrix device ID is saved across sessions so
|
|
// encryption keys accumulate on one device instead of creating ghosts.
|
|
|
|
import 'package:flutter/foundation.dart';
|
|
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
|
|
|
import '../../features/auth/data/auth_repository.dart';
|
|
import '../../features/auth/domain/auth_failure.dart';
|
|
import '../storage/sync_persistence_service.dart';
|
|
import 'auth_state.dart';
|
|
|
|
part 'auth_notifier.g.dart';
|
|
|
|
@Riverpod(keepAlive: true)
|
|
class AuthNotifier extends _$AuthNotifier {
|
|
@override
|
|
AuthState build() {
|
|
// No session restore on web — always require fresh login.
|
|
return const AuthState.unauthenticated();
|
|
}
|
|
|
|
Future<void> login({
|
|
required String username,
|
|
required String password,
|
|
}) async {
|
|
state = const AuthState.loading();
|
|
|
|
try {
|
|
final repo = ref.read(authRepositoryProvider);
|
|
debugPrint('[Auth] Logging in...');
|
|
|
|
final response = await repo.login(
|
|
username: username,
|
|
password: password,
|
|
);
|
|
|
|
debugPrint('[Auth] Login OK as ${response.userId} '
|
|
'device=${response.deviceId}');
|
|
|
|
state = AuthState.authenticated(
|
|
userId: response.userId,
|
|
accessToken: response.accessToken,
|
|
deviceId: response.deviceId,
|
|
);
|
|
|
|
// Start background sync-to-database persistence.
|
|
try {
|
|
ref.read(syncPersistenceServiceProvider).start();
|
|
} catch (_) {}
|
|
} on AuthFailure catch (failure) {
|
|
state = AuthState.unauthenticated(failure: failure.userMessage);
|
|
}
|
|
}
|
|
|
|
Future<void> logout() async {
|
|
state = const AuthState.loading();
|
|
|
|
final repo = ref.read(authRepositoryProvider);
|
|
await repo.logout();
|
|
|
|
// Keep the device ID in storage so the next login reuses it.
|
|
state = const AuthState.unauthenticated();
|
|
}
|
|
}
|