Files
plezy/lib/services/trackers/oauth_proxy_auth_service.dart
edde746 78090d8bd6 refactor(trackers): unify session and account store across services
Replace the per-tracker json_serializable session classes and account stores with a shared TrackerSession (service-aware persisted validation), a single TrackerAccountStore, a shared TrackerHttpClient, and an AnimeListTrackerBase mixin for MAL/AniList. Scope the per-service rebind guard so a disconnect can't abort a racing profile load. Add migration-safety, MAL refresh, episode-count cache, and content-type tests.
2026-06-27 10:05:03 +02:00

27 lines
772 B
Dart

import 'oauth_proxy_client.dart';
import 'tracker_session.dart';
abstract class OAuthProxyAuthServiceBase {
final OAuthProxyClient proxy;
OAuthProxyAuthServiceBase({OAuthProxyClient? proxy}) : proxy = proxy ?? OAuthProxyClient();
String get service;
TrackerSession buildSession(OAuthProxyResult result);
void dispose() => proxy.dispose();
Future<TrackerSession?> authorize({
required void Function(OAuthProxyStart) onCodeReady,
bool Function()? shouldCancel,
Future<void>? onCancel,
}) async {
final start = await proxy.start(service);
onCodeReady(start);
final result = await proxy.poll(start.session, shouldCancel: shouldCancel, onCancel: onCancel);
if (result == null) return null;
return buildSession(result);
}
}