Add an AccountProvider type and use it within the authentication flow. (#6103)

* Add an AccountProvider type and use it within AppSettings.

* Use the AccountProvider type within the Authentication flow too.

* Fix unit test compilation with Swift 6.4

* Make sure defaultAccountProvider takes allowOtherAccountProviders into account.

* Document a caveat on using AuthenticationService.homeserver.value.accountProvider.
This commit is contained in:
Doug
2026-09-14 15:25:33 +01:00
committed by GitHub
parent 26fddb8aa2
commit 64aae09c6d
29 changed files with 442 additions and 265 deletions
@@ -26,7 +26,7 @@ enum AuthenticationServiceError: Error, Equatable {
case invalidServer
case invalidCredentials
case invalidHomeserverAddress
case invalidServerNameOrBaseURL
case invalidWellKnown(String)
case slidingSyncNotAvailable
case loginNotSupported
@@ -39,12 +39,14 @@ enum AuthenticationServiceError: Error, Equatable {
protocol AuthenticationServiceProtocol: QRCodeLoginServiceProtocol {
/// The currently configured homeserver.
///
/// **Note:** The value's `accountProvider` will always be `.generic` after calling `configure(for:flow:)`.
var homeserver: CurrentValuePublisher<LoginHomeserver, Never> { get }
/// The type of flow the service is currently configured with.
var flow: AuthenticationFlow { get }
/// Sets up the service for login on the specified homeserver address.
func configure(for homeserverAddress: String, flow: AuthenticationFlow) async -> Result<Void, AuthenticationServiceError>
/// Sets up the service for login or registration using the supplied server name or base URL.
func configure(for serverNameOrBaseURL: String, flow: AuthenticationFlow) async -> Result<Void, AuthenticationServiceError>
/// Performs login using OAuth for the current homeserver.
func urlForOAuthLogin(loginHint: String?) async -> Result<OAuthAuthorizationDataProxy, AuthenticationServiceError>
/// Asks the SDK to abort an ongoing OAuth login if we didn't get a callback to complete the request with.