mirror of
https://github.com/metabolist/metatext.git
synced 2024-11-25 17:50:59 +00:00
Renaming
This commit is contained in:
parent
7631b92afb
commit
b6704c1099
8 changed files with 18 additions and 18 deletions
|
@ -53,7 +53,7 @@ extension AppEnvironment {
|
||||||
extension IdentitiesService {
|
extension IdentitiesService {
|
||||||
static func fresh(
|
static func fresh(
|
||||||
identityDatabase: IdentityDatabase = .fresh(),
|
identityDatabase: IdentityDatabase = .fresh(),
|
||||||
keychainService: KeychainServiceType = MockKeychainService(),
|
keychainService: KeychainService = MockKeychainService(),
|
||||||
environment: AppEnvironment = .development) -> IdentitiesService {
|
environment: AppEnvironment = .development) -> IdentitiesService {
|
||||||
IdentitiesService(
|
IdentitiesService(
|
||||||
identityDatabase: identityDatabase,
|
identityDatabase: identityDatabase,
|
||||||
|
|
|
@ -10,7 +10,7 @@ extension MockKeychainService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension MockKeychainService: KeychainServiceType {
|
extension MockKeychainService: KeychainService {
|
||||||
static func setGenericPassword(data: Data, forAccount key: String, service: String) throws {
|
static func setGenericPassword(data: Data, forAccount key: String, service: String) throws {
|
||||||
items[key] = data
|
items[key] = data
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
class MockWebAuthSession: WebAuthSessionType {
|
class MockWebAuthSession: WebAuthSession {
|
||||||
let completionHandler: WebAuthSessionCompletionHandler
|
let completionHandler: WebAuthSessionCompletionHandler
|
||||||
let url: URL
|
let url: URL
|
||||||
let callbackURLScheme: String?
|
let callbackURLScheme: String?
|
||||||
|
|
|
@ -4,14 +4,14 @@ import Foundation
|
||||||
|
|
||||||
struct AppEnvironment {
|
struct AppEnvironment {
|
||||||
let session: Session
|
let session: Session
|
||||||
let webAuthSessionType: WebAuthSessionType.Type
|
let webAuthSessionType: WebAuthSession.Type
|
||||||
let keychainServiceType: KeychainServiceType.Type
|
let keychainServiceType: KeychainService.Type
|
||||||
let userDefaults: UserDefaults = .standard
|
let userDefaults: UserDefaults = .standard
|
||||||
}
|
}
|
||||||
|
|
||||||
extension AppEnvironment {
|
extension AppEnvironment {
|
||||||
static let live: Self = Self(
|
static let live: Self = Self(
|
||||||
session: Session(configuration: .default),
|
session: Session(configuration: .default),
|
||||||
webAuthSessionType: WebAuthSession.self,
|
webAuthSessionType: LiveWebAuthSession.self,
|
||||||
keychainServiceType: KeychainService.self)
|
keychainServiceType: LiveKeychainService.self)
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import Foundation
|
||||||
import AuthenticationServices
|
import AuthenticationServices
|
||||||
import Combine
|
import Combine
|
||||||
|
|
||||||
protocol WebAuthSessionType: AnyObject {
|
protocol WebAuthSession: AnyObject {
|
||||||
init(url URL: URL,
|
init(url URL: URL,
|
||||||
callbackURLScheme: String?,
|
callbackURLScheme: String?,
|
||||||
completionHandler: @escaping WebAuthSessionCompletionHandler)
|
completionHandler: @escaping WebAuthSessionCompletionHandler)
|
||||||
|
@ -12,7 +12,7 @@ protocol WebAuthSessionType: AnyObject {
|
||||||
@discardableResult func start() -> Bool
|
@discardableResult func start() -> Bool
|
||||||
}
|
}
|
||||||
|
|
||||||
extension WebAuthSessionType {
|
extension WebAuthSession {
|
||||||
static func publisher(
|
static func publisher(
|
||||||
url: URL,
|
url: URL,
|
||||||
callbackURLScheme: String?,
|
callbackURLScheme: String?,
|
||||||
|
@ -44,6 +44,6 @@ class WebAuthSessionContextProvider: NSObject, ASWebAuthenticationPresentationCo
|
||||||
typealias WebAuthSessionCompletionHandler = ASWebAuthenticationSession.CompletionHandler
|
typealias WebAuthSessionCompletionHandler = ASWebAuthenticationSession.CompletionHandler
|
||||||
typealias WebAuthSessionError = ASWebAuthenticationSessionError
|
typealias WebAuthSessionError = ASWebAuthenticationSessionError
|
||||||
typealias WebAuthPresentationContextProviding = ASWebAuthenticationPresentationContextProviding
|
typealias WebAuthPresentationContextProviding = ASWebAuthenticationPresentationContextProviding
|
||||||
typealias WebAuthSession = ASWebAuthenticationSession
|
typealias LiveWebAuthSession = ASWebAuthenticationSession
|
||||||
|
|
||||||
extension WebAuthSession: WebAuthSessionType {}
|
extension LiveWebAuthSession: WebAuthSession {}
|
||||||
|
|
|
@ -5,7 +5,7 @@ import Combine
|
||||||
|
|
||||||
struct AuthenticationService {
|
struct AuthenticationService {
|
||||||
private let networkClient: MastodonClient
|
private let networkClient: MastodonClient
|
||||||
private let webAuthSessionType: WebAuthSessionType.Type
|
private let webAuthSessionType: WebAuthSession.Type
|
||||||
private let webAuthSessionContextProvider = WebAuthSessionContextProvider()
|
private let webAuthSessionContextProvider = WebAuthSessionContextProvider()
|
||||||
|
|
||||||
init(environment: AppEnvironment) {
|
init(environment: AppEnvironment) {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
protocol KeychainServiceType {
|
protocol KeychainService {
|
||||||
static func setGenericPassword(data: Data, forAccount key: String, service: String) throws
|
static func setGenericPassword(data: Data, forAccount key: String, service: String) throws
|
||||||
static func deleteGenericPassword(account: String, service: String) throws
|
static func deleteGenericPassword(account: String, service: String) throws
|
||||||
static func getGenericPassword(account: String, service: String) throws -> Data?
|
static func getGenericPassword(account: String, service: String) throws -> Data?
|
||||||
|
@ -10,9 +10,9 @@ protocol KeychainServiceType {
|
||||||
static func getPrivateKey(applicationTag: String) throws -> Data?
|
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 {
|
static func setGenericPassword(data: Data, forAccount account: String, service: String) throws {
|
||||||
var query = genericPasswordQueryDictionary(account: account, service: service)
|
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 let keySizeInBits = 256
|
||||||
|
|
||||||
static func genericPasswordQueryDictionary(account: String, service: String) -> [String: Any] {
|
static func genericPasswordQueryDictionary(account: String, service: String) -> [String: Any] {
|
||||||
|
|
|
@ -13,9 +13,9 @@ enum SecretsStorableError: Error {
|
||||||
|
|
||||||
struct SecretsService {
|
struct SecretsService {
|
||||||
let identityID: UUID
|
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.identityID = identityID
|
||||||
self.keychainServiceType = keychainServiceType
|
self.keychainServiceType = keychainServiceType
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue