mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 10:33:45 +00:00
Update the SDK.
Handles changes that removed support for the sliding sync proxy.
This commit is contained in:
@@ -27,55 +27,25 @@ struct AuthenticationClientBuilder: AuthenticationClientBuilderProtocol {
|
||||
|
||||
/// Builds a Client for login using OIDC or password authentication.
|
||||
func build(homeserverAddress: String) async throws -> ClientProtocol {
|
||||
if appSettings.slidingSyncDiscovery == .forceNative {
|
||||
return try await makeClientBuilder(slidingSync: .forceNative).serverNameOrHomeserverUrl(serverNameOrUrl: homeserverAddress).build()
|
||||
}
|
||||
|
||||
if appSettings.slidingSyncDiscovery == .native {
|
||||
do {
|
||||
return try await makeClientBuilder(slidingSync: .discoverNative).serverNameOrHomeserverUrl(serverNameOrUrl: homeserverAddress).build()
|
||||
} catch {
|
||||
MXLog.warning("Native sliding sync not available: \(error)")
|
||||
MXLog.info("Falling back to a sliding sync proxy.")
|
||||
}
|
||||
}
|
||||
|
||||
return try await makeClientBuilder(slidingSync: .discoverProxy).serverNameOrHomeserverUrl(serverNameOrUrl: homeserverAddress).build()
|
||||
try await makeClientBuilder().serverNameOrHomeserverUrl(serverNameOrUrl: homeserverAddress).build()
|
||||
}
|
||||
|
||||
/// Builds a Client, authenticating with the given QR code data.
|
||||
func buildWithQRCode(qrCodeData: QrCodeData,
|
||||
oidcConfiguration: OIDCConfigurationProxy,
|
||||
progressListener: QrLoginProgressListenerProxy) async throws -> ClientProtocol {
|
||||
if appSettings.slidingSyncDiscovery == .forceNative {
|
||||
return try await makeClientBuilder(slidingSync: .forceNative).buildWithQrCode(qrCodeData: qrCodeData,
|
||||
oidcConfiguration: oidcConfiguration.rustValue,
|
||||
progressListener: progressListener)
|
||||
}
|
||||
|
||||
if appSettings.slidingSyncDiscovery == .native {
|
||||
do {
|
||||
return try await makeClientBuilder(slidingSync: .discoverNative).buildWithQrCode(qrCodeData: qrCodeData,
|
||||
oidcConfiguration: oidcConfiguration.rustValue,
|
||||
progressListener: progressListener)
|
||||
} catch HumanQrLoginError.SlidingSyncNotAvailable {
|
||||
MXLog.warning("Native sliding sync not available")
|
||||
MXLog.info("Falling back to a sliding sync proxy.")
|
||||
}
|
||||
}
|
||||
|
||||
return try await makeClientBuilder(slidingSync: .discoverProxy).buildWithQrCode(qrCodeData: qrCodeData,
|
||||
oidcConfiguration: oidcConfiguration.rustValue,
|
||||
progressListener: progressListener)
|
||||
try await makeClientBuilder().buildWithQrCode(qrCodeData: qrCodeData,
|
||||
oidcConfiguration: oidcConfiguration.rustValue,
|
||||
progressListener: progressListener)
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
/// The base builder configuration used for authentication within the app.
|
||||
private func makeClientBuilder(slidingSync: ClientBuilderSlidingSync) -> ClientBuilder {
|
||||
private func makeClientBuilder() -> ClientBuilder {
|
||||
ClientBuilder
|
||||
.baseBuilder(httpProxy: appSettings.websiteURL.globalProxy,
|
||||
slidingSync: slidingSync,
|
||||
slidingSync: .discover,
|
||||
sessionDelegate: clientSessionDelegate,
|
||||
appHooks: appHooks,
|
||||
enableOnlySignedDeviceIsolationMode: appSettings.enableOnlySignedDeviceIsolationMode,
|
||||
|
||||
Reference in New Issue
Block a user