diff --git a/Development Assets/DevelopmentModels.swift b/Development Assets/DevelopmentModels.swift index ac9bdbf..2d46497 100644 --- a/Development Assets/DevelopmentModels.swift +++ b/Development Assets/DevelopmentModels.swift @@ -53,7 +53,7 @@ extension AppEnvironment { extension IdentitiesService { static func fresh( identityDatabase: IdentityDatabase = .fresh(), - keychainService: KeychainServiceType = MockKeychainService(), + keychainService: KeychainService = MockKeychainService(), environment: AppEnvironment = .development) -> IdentitiesService { IdentitiesService( identityDatabase: identityDatabase, diff --git a/Development Assets/MockKeychainService.swift b/Development Assets/MockKeychainService.swift index a443cd7..11049f5 100644 --- a/Development Assets/MockKeychainService.swift +++ b/Development Assets/MockKeychainService.swift @@ -10,7 +10,7 @@ extension MockKeychainService { } } -extension MockKeychainService: KeychainServiceType { +extension MockKeychainService: KeychainService { static func setGenericPassword(data: Data, forAccount key: String, service: String) throws { items[key] = data } diff --git a/Development Assets/MockWebAuthSession.swift b/Development Assets/MockWebAuthSession.swift index 93f0fe9..4733d0b 100644 --- a/Development Assets/MockWebAuthSession.swift +++ b/Development Assets/MockWebAuthSession.swift @@ -2,7 +2,7 @@ import Foundation -class MockWebAuthSession: WebAuthSessionType { +class MockWebAuthSession: WebAuthSession { let completionHandler: WebAuthSessionCompletionHandler let url: URL let callbackURLScheme: String? diff --git a/Shared/Model/AppEnvironment.swift b/Shared/Model/AppEnvironment.swift index 8ab371a..be09c6b 100644 --- a/Shared/Model/AppEnvironment.swift +++ b/Shared/Model/AppEnvironment.swift @@ -4,14 +4,14 @@ import Foundation struct AppEnvironment { let session: Session - let webAuthSessionType: WebAuthSessionType.Type - let keychainServiceType: KeychainServiceType.Type + let webAuthSessionType: WebAuthSession.Type + let keychainServiceType: KeychainService.Type let userDefaults: UserDefaults = .standard } extension AppEnvironment { static let live: Self = Self( session: Session(configuration: .default), - webAuthSessionType: WebAuthSession.self, - keychainServiceType: KeychainService.self) + webAuthSessionType: LiveWebAuthSession.self, + keychainServiceType: LiveKeychainService.self) } diff --git a/Shared/Networking/WebAuthSession.swift b/Shared/Networking/WebAuthSession.swift index 7eb90fc..c87e823 100644 --- a/Shared/Networking/WebAuthSession.swift +++ b/Shared/Networking/WebAuthSession.swift @@ -4,7 +4,7 @@ import Foundation import AuthenticationServices import Combine -protocol WebAuthSessionType: AnyObject { +protocol WebAuthSession: AnyObject { init(url URL: URL, callbackURLScheme: String?, completionHandler: @escaping WebAuthSessionCompletionHandler) @@ -12,7 +12,7 @@ protocol WebAuthSessionType: AnyObject { @discardableResult func start() -> Bool } -extension WebAuthSessionType { +extension WebAuthSession { static func publisher( url: URL, callbackURLScheme: String?, @@ -44,6 +44,6 @@ class WebAuthSessionContextProvider: NSObject, ASWebAuthenticationPresentationCo typealias WebAuthSessionCompletionHandler = ASWebAuthenticationSession.CompletionHandler typealias WebAuthSessionError = ASWebAuthenticationSessionError typealias WebAuthPresentationContextProviding = ASWebAuthenticationPresentationContextProviding -typealias WebAuthSession = ASWebAuthenticationSession +typealias LiveWebAuthSession = ASWebAuthenticationSession -extension WebAuthSession: WebAuthSessionType {} +extension LiveWebAuthSession: WebAuthSession {} diff --git a/Shared/Services/AuthenticationService.swift b/Shared/Services/AuthenticationService.swift index c5c0d4f..b12f0e0 100644 --- a/Shared/Services/AuthenticationService.swift +++ b/Shared/Services/AuthenticationService.swift @@ -5,7 +5,7 @@ import Combine struct AuthenticationService { private let networkClient: MastodonClient - private let webAuthSessionType: WebAuthSessionType.Type + private let webAuthSessionType: WebAuthSession.Type private let webAuthSessionContextProvider = WebAuthSessionContextProvider() init(environment: AppEnvironment) { diff --git a/Shared/Services/KeychainService.swift b/Shared/Services/KeychainService.swift index bf57fc8..64e9332 100644 --- a/Shared/Services/KeychainService.swift +++ b/Shared/Services/KeychainService.swift @@ -2,7 +2,7 @@ import Foundation -protocol KeychainServiceType { +protocol KeychainService { static func setGenericPassword(data: Data, forAccount key: String, service: String) throws static func deleteGenericPassword(account: String, service: String) throws static func getGenericPassword(account: String, service: String) throws -> Data? @@ -10,9 +10,9 @@ protocol KeychainServiceType { static func getPrivateKey(applicationTag: String) throws -> Data? } -struct KeychainService {} +struct LiveKeychainService {} -extension KeychainService: KeychainServiceType { +extension LiveKeychainService: KeychainService { static func setGenericPassword(data: Data, forAccount account: String, service: String) throws { var query = genericPasswordQueryDictionary(account: account, service: service) @@ -84,7 +84,7 @@ extension KeychainService: KeychainServiceType { } } -private extension KeychainService { +private extension LiveKeychainService { static let keySizeInBits = 256 static func genericPasswordQueryDictionary(account: String, service: String) -> [String: Any] { diff --git a/Shared/Services/SecretsService.swift b/Shared/Services/SecretsService.swift index 399e816..c7405ec 100644 --- a/Shared/Services/SecretsService.swift +++ b/Shared/Services/SecretsService.swift @@ -13,9 +13,9 @@ enum SecretsStorableError: Error { struct SecretsService { let identityID: UUID - private let keychainServiceType: KeychainServiceType.Type + private let keychainServiceType: KeychainService.Type - init(identityID: UUID, keychainServiceType: KeychainServiceType.Type) { + init(identityID: UUID, keychainServiceType: KeychainService.Type) { self.identityID = identityID self.keychainServiceType = keychainServiceType }