Update the SDK and build a client before logging in with a QR code. (#4320)

This commit is contained in:
Doug
2025-07-14 14:31:06 +01:00
committed by GitHub
parent e46165119f
commit de4f05f338
10 changed files with 56 additions and 175 deletions
@@ -11,9 +11,6 @@ import MatrixRustSDK
// sourcery: AutoMockable
protocol AuthenticationClientBuilderProtocol {
func build(homeserverAddress: String) async throws -> ClientProtocol
func buildWithQRCode(qrCodeData: QrCodeData,
oidcConfiguration: OIDCConfigurationProxy,
progressListener: SDKListener<QrLoginProgress>) async throws -> ClientProtocol
}
/// A wrapper around `ClientBuilder` to share reusable code between Normal and QR logins.
@@ -30,15 +27,6 @@ struct AuthenticationClientBuilder: AuthenticationClientBuilderProtocol {
try await makeClientBuilder().serverNameOrHomeserverUrl(serverNameOrUrl: homeserverAddress).build()
}
/// Builds a Client, authenticating with the given QR code data.
func buildWithQRCode(qrCodeData: QrCodeData,
oidcConfiguration: OIDCConfigurationProxy,
progressListener: SDKListener<QrLoginProgress>) async throws -> ClientProtocol {
try await makeClientBuilder().buildWithQrCode(qrCodeData: qrCodeData,
oidcConfiguration: oidcConfiguration.rustValue,
progressListener: progressListener)
}
// MARK: - Private
/// The base builder configuration used for authentication within the app.
@@ -58,9 +58,10 @@ final class QRCodeLoginService: QRCodeLoginServiceProtocol {
}
do {
let client = try await makeClientBuilder().buildWithQRCode(qrCodeData: qrData,
oidcConfiguration: appSettings.oidcConfiguration,
progressListener: listener)
let client = try await makeClientBuilder().build(homeserverAddress: scannedServerName)
try await client.loginWithQrCode(qrCodeData: qrData,
oidcConfiguration: appSettings.oidcConfiguration.rustValue,
progressListener: listener)
MXLog.info("Sliding sync: \(client.slidingSyncVersion())")
return await userSession(for: client)
} catch let error as HumanQrLoginError {