ReadKeep/readeck/Data/TokenProvider.swift
Ilyas Hallak ffb41347af refactor: Implement state machine architecture for offline sync
- Replace multiple boolean properties with single OfflineBookmarkSyncState enum
- Add Use Case pattern for OfflineSyncManager with dependency injection
- Simplify LocalBookmarksSyncView using state-driven UI with external bindings
- Convert OfflineBookmarksViewModel to use @Observable instead of ObservableObject
- Move credentials from Core Data to Keychain for better persistence
- Implement comprehensive database migration for App Group containers
- Add structured logging throughout sync operations and API calls

Architecture improvements follow MVVM principles with clean separation of concerns.
2025-08-18 22:58:42 +02:00

29 lines
662 B
Swift

import Foundation
protocol TokenProvider {
func getToken() async -> String?
func getEndpoint() async -> String?
func setToken(_ token: String) async
func clearToken() async
}
class KeychainTokenProvider: TokenProvider {
private let keychainHelper = KeychainHelper.shared
func getToken() async -> String? {
return keychainHelper.loadToken()
}
func getEndpoint() async -> String? {
return keychainHelper.loadEndpoint()
}
func setToken(_ token: String) async {
keychainHelper.saveToken(token)
}
func clearToken() async {
keychainHelper.clearCredentials()
}
}