mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Merge the AuthenticationService with the QRCodeLoginService. (#4323)
* Merge the AuthenticationServer with the QRCodeLoginService. * Merge AuthenticationClientBuilderFactory and AuthenticationClientBuilder into AuthenticationClientFactory The separation is no longer needed now that password/OIDC login and QR code login have a similar API shape.
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
// Please see LICENSE files in the repository root for full details.
|
||||
//
|
||||
|
||||
import Combine
|
||||
import Foundation
|
||||
import MatrixRustSDK
|
||||
|
||||
@@ -19,6 +20,9 @@ enum AuthenticationFlow {
|
||||
enum AuthenticationServiceError: Error, Equatable {
|
||||
/// An error occurred during OIDC authentication.
|
||||
case oidcError(OIDCError)
|
||||
/// An error occurred during login with QR Code.
|
||||
case qrCodeError(QRCodeLoginError)
|
||||
|
||||
case invalidServer
|
||||
case invalidCredentials
|
||||
case invalidHomeserverAddress
|
||||
@@ -32,7 +36,7 @@ enum AuthenticationServiceError: Error, Equatable {
|
||||
case failedUsingWebCredentials
|
||||
}
|
||||
|
||||
protocol AuthenticationServiceProtocol {
|
||||
protocol AuthenticationServiceProtocol: QRCodeLoginServiceProtocol {
|
||||
/// The currently configured homeserver.
|
||||
var homeserver: CurrentValuePublisher<LoginHomeserver, Never> { get }
|
||||
/// The type of flow the service is currently configured with.
|
||||
@@ -86,3 +90,25 @@ extension OAuthAuthorizationData: @retroactive Hashable {
|
||||
hasher.combine(loginUrl())
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Login with QR code
|
||||
|
||||
enum QRCodeLoginError: Error, Equatable {
|
||||
case invalidQRCode
|
||||
case providerNotAllowed(scannedProvider: String, allowedProviders: [String])
|
||||
case cancelled
|
||||
case connectionInsecure
|
||||
case declined
|
||||
case linkingNotSupported
|
||||
case expired
|
||||
case deviceNotSupported
|
||||
case deviceNotSignedIn
|
||||
case unknown
|
||||
}
|
||||
|
||||
// sourcery: AutoMockable
|
||||
protocol QRCodeLoginServiceProtocol {
|
||||
var qrLoginProgressPublisher: AnyPublisher<QrLoginProgress, Never> { get }
|
||||
|
||||
func loginWithQRCode(data: Data) async -> Result<UserSessionProtocol, AuthenticationServiceError>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user