This commit is contained in:
Justin Mazzocchi 2020-08-12 02:01:21 -07:00
parent 7631b92afb
commit b6704c1099
No known key found for this signature in database
GPG key ID: E223E6937AAFB01C
8 changed files with 18 additions and 18 deletions

View file

@ -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,

View file

@ -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
}

View file

@ -2,7 +2,7 @@
import Foundation
class MockWebAuthSession: WebAuthSessionType {
class MockWebAuthSession: WebAuthSession {
let completionHandler: WebAuthSessionCompletionHandler
let url: URL
let callbackURLScheme: String?

View file

@ -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)
}

View file

@ -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 {}

View file

@ -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) {

View file

@ -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] {

View file

@ -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
}