mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-18 23:48:29 +02:00
Configured and applied SwiftFormat
This commit is contained in:
committed by
Stefan Ceriu
parent
ff2e6ddfa7
commit
43c28d23b7
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2022 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2022 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -18,6 +18,7 @@ import Foundation
|
||||
|
||||
protocol AuthenticationRestClient: AnyObject {
|
||||
// MARK: Configuration
|
||||
|
||||
var homeserver: String! { get }
|
||||
var identityServer: String! { get set }
|
||||
var credentials: MXCredentials! { get }
|
||||
@@ -26,24 +27,27 @@ protocol AuthenticationRestClient: AnyObject {
|
||||
init(homeServer: URL, unrecognizedCertificateHandler handler: MXHTTPClientOnUnrecognizedCertificate?)
|
||||
|
||||
// MARK: Login
|
||||
|
||||
var loginFallbackURL: URL { get }
|
||||
func wellKnown() async throws -> MXWellKnown
|
||||
func getLoginSession() async throws -> MXAuthenticationSession
|
||||
func login(parameters: LoginParameters) async throws -> MXCredentials
|
||||
func login(parameters: [String : Any]) async throws -> MXCredentials
|
||||
func login(parameters: [String: Any]) async throws -> MXCredentials
|
||||
|
||||
// MARK: Registration
|
||||
|
||||
var registerFallbackURL: URL { get }
|
||||
func getRegisterSession() async throws -> MXAuthenticationSession
|
||||
func isUsernameAvailable(_ username: String) async throws -> Bool
|
||||
func register(parameters: RegistrationParameters) async throws -> MXLoginResponse
|
||||
func register(parameters: [String : Any]) async throws -> MXLoginResponse
|
||||
func register(parameters: [String: Any]) async throws -> MXLoginResponse
|
||||
func requestTokenDuringRegistration(for threePID: RegisterThreePID, clientSecret: String, sendAttempt: UInt) async throws -> RegistrationThreePIDTokenResponse
|
||||
|
||||
// MARK: Forgot Password
|
||||
|
||||
func forgetPassword(for email: String, clientSecret: String, sendAttempt: UInt) async throws -> String
|
||||
func resetPassword(parameters: CheckResetPasswordParameters) async throws
|
||||
func resetPassword(parameters: [String : Any]) async throws
|
||||
func resetPassword(parameters: [String: Any]) async throws
|
||||
}
|
||||
|
||||
extension MXRestClient: AuthenticationRestClient { }
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2021 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -39,7 +39,6 @@ protocol AuthenticationServiceDelegate: AnyObject {
|
||||
|
||||
@objcMembers
|
||||
class AuthenticationService: NSObject {
|
||||
|
||||
/// The shared service object.
|
||||
static let shared = AuthenticationService()
|
||||
|
||||
@@ -97,7 +96,7 @@ class AuthenticationService: NSObject {
|
||||
let hsUrl = universalLink.homeserverUrl
|
||||
let isUrl = universalLink.identityServerUrl
|
||||
|
||||
if hsUrl == nil && isUrl == nil {
|
||||
if hsUrl == nil, isUrl == nil {
|
||||
MXLog.debug("[AuthenticationService] handleServerProvisioningLink: no hsUrl or isUrl")
|
||||
return false
|
||||
}
|
||||
@@ -166,7 +165,7 @@ class AuthenticationService: NSObject {
|
||||
|
||||
// The state and client are set after trying the registration flow to
|
||||
// ensure the existing state isn't wiped out when an error occurs.
|
||||
self.state = AuthenticationState(flow: flow, homeserver: homeserver)
|
||||
state = AuthenticationState(flow: flow, homeserver: homeserver)
|
||||
self.client = client
|
||||
}
|
||||
|
||||
@@ -200,9 +199,9 @@ class AuthenticationService: NSObject {
|
||||
// completeness revert to the default homeserver if requested anyway.
|
||||
let address = useDefaultServer ? BuildSettings.serverConfigDefaultHomeserverUrlString : state.homeserver.addressFromUser ?? state.homeserver.address
|
||||
let identityServer = state.identityServer
|
||||
self.state = AuthenticationState(flow: .login,
|
||||
homeserverAddress: address,
|
||||
identityServer: identityServer)
|
||||
state = AuthenticationState(flow: .login,
|
||||
homeserverAddress: address,
|
||||
identityServer: identityServer)
|
||||
}
|
||||
|
||||
/// Continues an SSO flow when completion comes via a deep link.
|
||||
@@ -289,7 +288,7 @@ class AuthenticationService: NSObject {
|
||||
|
||||
let identityProviders = loginFlowResponse.flows?.compactMap { $0 as? MXLoginSSOFlow }.first?.identityProviders ?? []
|
||||
return LoginFlowResult(supportedLoginTypes: loginFlowResponse.flows?.compactMap { $0 } ?? [],
|
||||
ssoIdentityProviders: identityProviders.sorted { $0.name < $1.name }.map { $0.ssoIdentityProvider },
|
||||
ssoIdentityProviders: identityProviders.sorted { $0.name < $1.name }.map(\.ssoIdentityProvider),
|
||||
homeserverAddress: client.homeserver)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2022 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -29,7 +29,7 @@ struct AuthenticationState {
|
||||
|
||||
init(flow: AuthenticationFlow, homeserverAddress: String, identityServer: String? = nil) {
|
||||
self.flow = flow
|
||||
self.homeserver = Homeserver(address: homeserverAddress)
|
||||
homeserver = Homeserver(address: homeserverAddress)
|
||||
self.identityServer = identityServer
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ struct AuthenticationState {
|
||||
|
||||
/// Needs authentication fallback for login
|
||||
var needsLoginFallback: Bool {
|
||||
return preferredLoginMode.isUnsupported
|
||||
preferredLoginMode.isUnsupported
|
||||
}
|
||||
|
||||
/// Needs authentication fallback for registration
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2022 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -93,4 +93,3 @@ enum LoginMode {
|
||||
struct ResetPasswordData {
|
||||
let addThreePIDSessionID: String
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2022 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -110,7 +110,7 @@ struct CheckResetPasswordParameters: DictionaryEncodable {
|
||||
}
|
||||
|
||||
init(clientSecret: String, sessionID: String, newPassword: String, signoutAllDevices: Bool) {
|
||||
self.auth = AuthenticationParameters.resetPasswordParameters(clientSecret: clientSecret, sessionID: sessionID)
|
||||
auth = AuthenticationParameters.resetPasswordParameters(clientSecret: clientSecret, sessionID: sessionID)
|
||||
self.newPassword = newPassword
|
||||
self.signoutAllDevices = signoutAllDevices
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2022 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -40,7 +40,7 @@ class LoginWizard {
|
||||
self.client = client
|
||||
self.sessionCreator = sessionCreator
|
||||
|
||||
self.state = State()
|
||||
state = State()
|
||||
}
|
||||
|
||||
/// Login to the homeserver.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2022 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -114,7 +114,7 @@ struct FlowResult {
|
||||
}
|
||||
|
||||
/// Whether fallback registration should be used due to unsupported stages.
|
||||
var needsFallback : Bool {
|
||||
var needsFallback: Bool {
|
||||
missingStages.filter(\.isMandatory).contains { stage in
|
||||
if case .other = stage { return true } else { return false }
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2022 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
||||
@@ -63,7 +63,7 @@ class RegistrationWizard {
|
||||
self.client = client
|
||||
self.sessionCreator = sessionCreator
|
||||
|
||||
self.state = State()
|
||||
state = State()
|
||||
}
|
||||
|
||||
/// Call this method to get the possible registration flow of the current homeserver.
|
||||
@@ -164,7 +164,7 @@ class RegistrationWizard {
|
||||
/// Send the code received by SMS to validate a msisdn.
|
||||
/// If the code is correct, the registration request will be executed to validate the msisdn.
|
||||
func handleValidateThreePID(code: String) async throws -> RegistrationResult {
|
||||
return try await validateThreePid(code: code)
|
||||
try await validateThreePid(code: code)
|
||||
}
|
||||
|
||||
/// Useful to poll the homeserver when waiting for the email to be validated by the user.
|
||||
@@ -197,7 +197,6 @@ class RegistrationWizard {
|
||||
throw RegistrationError.missingThreePIDURL
|
||||
}
|
||||
|
||||
|
||||
let validationBody = ThreePIDValidationCodeBody(clientSecret: state.clientSecret,
|
||||
sessionID: threePIDData.registrationResponse.sessionID,
|
||||
code: code)
|
||||
@@ -278,7 +277,7 @@ class RegistrationWizard {
|
||||
/// Checks for a dummy stage and handles it automatically when possible.
|
||||
private func handleDummyStage(flowResult: FlowResult) async throws -> RegistrationResult {
|
||||
// If the dummy stage is mandatory, do the dummy stage now
|
||||
guard flowResult.missingStages.contains(where: { $0.isDummy }) else { return .flowResponse(flowResult) }
|
||||
guard flowResult.missingStages.contains(where: \.isDummy) else { return .flowResponse(flowResult) }
|
||||
return try await dummy()
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2022 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -29,7 +29,6 @@ protocol SessionCreatorProtocol {
|
||||
|
||||
/// A struct that provides common functionality to create a new session.
|
||||
struct SessionCreator: SessionCreatorProtocol {
|
||||
|
||||
private let accountManager: MXKAccountManager
|
||||
|
||||
init(withAccountManager accountManager: MXKAccountManager = .shared()) {
|
||||
@@ -44,7 +43,7 @@ struct SessionCreator: SessionCreatorProtocol {
|
||||
}
|
||||
|
||||
if removeOtherAccounts {
|
||||
let otherAccounts = accountManager.accounts.filter({ $0.mxCredentials.userId != credentials.userId })
|
||||
let otherAccounts = accountManager.accounts.filter { $0.mxCredentials.userId != credentials.userId }
|
||||
for account in otherAccounts {
|
||||
accountManager.removeAccount(account, completion: nil)
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2022 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -53,13 +53,13 @@ struct RegistrationThreePIDTokenResponse {
|
||||
///
|
||||
/// If this field is not present, the client can assume that verification will happen without the client's involvement provided
|
||||
/// the homeserver advertises this specification version in the /versions response (ie: r0.5.0).
|
||||
var submitURL: String? = nil
|
||||
var submitURL: String?
|
||||
|
||||
// MARK: - Additional data that may be needed
|
||||
|
||||
var msisdn: String? = nil
|
||||
var formattedMSISDN: String? = nil
|
||||
var success: Bool? = nil
|
||||
var msisdn: String?
|
||||
var formattedMSISDN: String?
|
||||
var success: Bool?
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case sessionID = "sid"
|
||||
|
||||
Reference in New Issue
Block a user