mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 12:07:55 +00:00
Update the SDK and build a client before logging in with a QR code. (#4320)
This commit is contained in:
@@ -8771,7 +8771,7 @@
|
||||
repositoryURL = "https://github.com/element-hq/matrix-rust-components-swift";
|
||||
requirement = {
|
||||
kind = exactVersion;
|
||||
version = 25.07.10;
|
||||
version = "25.07.14-2";
|
||||
};
|
||||
};
|
||||
701C7BEF8F70F7A83E852DCC /* XCRemoteSwiftPackageReference "GZIP" */ = {
|
||||
|
||||
@@ -158,8 +158,8 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/element-hq/matrix-rust-components-swift",
|
||||
"state" : {
|
||||
"revision" : "91d7262dfdea3eec2e6a6fff5ab303ca953dd90b",
|
||||
"version" : "25.7.10"
|
||||
"revision" : "08ec4eaad53ca384e41bcb72bc198f26d7b17bd5",
|
||||
"version" : "25.7.14-2"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -31,7 +31,6 @@ extension AuthenticationClientBuilderMock {
|
||||
supportsOIDCCreatePrompt: false,
|
||||
supportsPasswordLogin: false))
|
||||
]
|
||||
var qrCodeClient = ClientSDKMock(configuration: .init())
|
||||
}
|
||||
|
||||
convenience init(configuration: Configuration) {
|
||||
@@ -43,7 +42,5 @@ extension AuthenticationClientBuilderMock {
|
||||
}
|
||||
return client
|
||||
}
|
||||
|
||||
buildWithQRCodeQrCodeDataOidcConfigurationProgressListenerReturnValue = configuration.qrCodeClient
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1972,80 +1972,6 @@ class AuthenticationClientBuilderMock: AuthenticationClientBuilderProtocol, @unc
|
||||
return buildHomeserverAddressReturnValue
|
||||
}
|
||||
}
|
||||
//MARK: - buildWithQRCode
|
||||
|
||||
var buildWithQRCodeQrCodeDataOidcConfigurationProgressListenerThrowableError: Error?
|
||||
var buildWithQRCodeQrCodeDataOidcConfigurationProgressListenerUnderlyingCallsCount = 0
|
||||
var buildWithQRCodeQrCodeDataOidcConfigurationProgressListenerCallsCount: Int {
|
||||
get {
|
||||
if Thread.isMainThread {
|
||||
return buildWithQRCodeQrCodeDataOidcConfigurationProgressListenerUnderlyingCallsCount
|
||||
} else {
|
||||
var returnValue: Int? = nil
|
||||
DispatchQueue.main.sync {
|
||||
returnValue = buildWithQRCodeQrCodeDataOidcConfigurationProgressListenerUnderlyingCallsCount
|
||||
}
|
||||
|
||||
return returnValue!
|
||||
}
|
||||
}
|
||||
set {
|
||||
if Thread.isMainThread {
|
||||
buildWithQRCodeQrCodeDataOidcConfigurationProgressListenerUnderlyingCallsCount = newValue
|
||||
} else {
|
||||
DispatchQueue.main.sync {
|
||||
buildWithQRCodeQrCodeDataOidcConfigurationProgressListenerUnderlyingCallsCount = newValue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var buildWithQRCodeQrCodeDataOidcConfigurationProgressListenerCalled: Bool {
|
||||
return buildWithQRCodeQrCodeDataOidcConfigurationProgressListenerCallsCount > 0
|
||||
}
|
||||
var buildWithQRCodeQrCodeDataOidcConfigurationProgressListenerReceivedArguments: (qrCodeData: QrCodeData, oidcConfiguration: OIDCConfigurationProxy, progressListener: SDKListener<QrLoginProgress>)?
|
||||
var buildWithQRCodeQrCodeDataOidcConfigurationProgressListenerReceivedInvocations: [(qrCodeData: QrCodeData, oidcConfiguration: OIDCConfigurationProxy, progressListener: SDKListener<QrLoginProgress>)] = []
|
||||
|
||||
var buildWithQRCodeQrCodeDataOidcConfigurationProgressListenerUnderlyingReturnValue: ClientProtocol!
|
||||
var buildWithQRCodeQrCodeDataOidcConfigurationProgressListenerReturnValue: ClientProtocol! {
|
||||
get {
|
||||
if Thread.isMainThread {
|
||||
return buildWithQRCodeQrCodeDataOidcConfigurationProgressListenerUnderlyingReturnValue
|
||||
} else {
|
||||
var returnValue: ClientProtocol? = nil
|
||||
DispatchQueue.main.sync {
|
||||
returnValue = buildWithQRCodeQrCodeDataOidcConfigurationProgressListenerUnderlyingReturnValue
|
||||
}
|
||||
|
||||
return returnValue!
|
||||
}
|
||||
}
|
||||
set {
|
||||
if Thread.isMainThread {
|
||||
buildWithQRCodeQrCodeDataOidcConfigurationProgressListenerUnderlyingReturnValue = newValue
|
||||
} else {
|
||||
DispatchQueue.main.sync {
|
||||
buildWithQRCodeQrCodeDataOidcConfigurationProgressListenerUnderlyingReturnValue = newValue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var buildWithQRCodeQrCodeDataOidcConfigurationProgressListenerClosure: ((QrCodeData, OIDCConfigurationProxy, SDKListener<QrLoginProgress>) async throws -> ClientProtocol)?
|
||||
|
||||
func buildWithQRCode(qrCodeData: QrCodeData, oidcConfiguration: OIDCConfigurationProxy, progressListener: SDKListener<QrLoginProgress>) async throws -> ClientProtocol {
|
||||
if let error = buildWithQRCodeQrCodeDataOidcConfigurationProgressListenerThrowableError {
|
||||
throw error
|
||||
}
|
||||
buildWithQRCodeQrCodeDataOidcConfigurationProgressListenerCallsCount += 1
|
||||
buildWithQRCodeQrCodeDataOidcConfigurationProgressListenerReceivedArguments = (qrCodeData: qrCodeData, oidcConfiguration: oidcConfiguration, progressListener: progressListener)
|
||||
DispatchQueue.main.async {
|
||||
self.buildWithQRCodeQrCodeDataOidcConfigurationProgressListenerReceivedInvocations.append((qrCodeData: qrCodeData, oidcConfiguration: oidcConfiguration, progressListener: progressListener))
|
||||
}
|
||||
if let buildWithQRCodeQrCodeDataOidcConfigurationProgressListenerClosure = buildWithQRCodeQrCodeDataOidcConfigurationProgressListenerClosure {
|
||||
return try await buildWithQRCodeQrCodeDataOidcConfigurationProgressListenerClosure(qrCodeData, oidcConfiguration, progressListener)
|
||||
} else {
|
||||
return buildWithQRCodeQrCodeDataOidcConfigurationProgressListenerReturnValue
|
||||
}
|
||||
}
|
||||
}
|
||||
class BannedRoomProxyMock: BannedRoomProxyProtocol, @unchecked Sendable {
|
||||
var info: BaseRoomInfoProxyProtocol {
|
||||
|
||||
@@ -3031,6 +3031,52 @@ open class ClientSDKMock: MatrixRustSDK.Client, @unchecked Sendable {
|
||||
try await loginWithOidcCallbackCallbackUrlClosure?(callbackUrl)
|
||||
}
|
||||
|
||||
//MARK: - loginWithQrCode
|
||||
|
||||
open var loginWithQrCodeQrCodeDataOidcConfigurationProgressListenerThrowableError: Error?
|
||||
var loginWithQrCodeQrCodeDataOidcConfigurationProgressListenerUnderlyingCallsCount = 0
|
||||
open var loginWithQrCodeQrCodeDataOidcConfigurationProgressListenerCallsCount: Int {
|
||||
get {
|
||||
if Thread.isMainThread {
|
||||
return loginWithQrCodeQrCodeDataOidcConfigurationProgressListenerUnderlyingCallsCount
|
||||
} else {
|
||||
var returnValue: Int? = nil
|
||||
DispatchQueue.main.sync {
|
||||
returnValue = loginWithQrCodeQrCodeDataOidcConfigurationProgressListenerUnderlyingCallsCount
|
||||
}
|
||||
|
||||
return returnValue!
|
||||
}
|
||||
}
|
||||
set {
|
||||
if Thread.isMainThread {
|
||||
loginWithQrCodeQrCodeDataOidcConfigurationProgressListenerUnderlyingCallsCount = newValue
|
||||
} else {
|
||||
DispatchQueue.main.sync {
|
||||
loginWithQrCodeQrCodeDataOidcConfigurationProgressListenerUnderlyingCallsCount = newValue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
open var loginWithQrCodeQrCodeDataOidcConfigurationProgressListenerCalled: Bool {
|
||||
return loginWithQrCodeQrCodeDataOidcConfigurationProgressListenerCallsCount > 0
|
||||
}
|
||||
open var loginWithQrCodeQrCodeDataOidcConfigurationProgressListenerReceivedArguments: (qrCodeData: QrCodeData, oidcConfiguration: OidcConfiguration, progressListener: QrLoginProgressListener)?
|
||||
open var loginWithQrCodeQrCodeDataOidcConfigurationProgressListenerReceivedInvocations: [(qrCodeData: QrCodeData, oidcConfiguration: OidcConfiguration, progressListener: QrLoginProgressListener)] = []
|
||||
open var loginWithQrCodeQrCodeDataOidcConfigurationProgressListenerClosure: ((QrCodeData, OidcConfiguration, QrLoginProgressListener) async throws -> Void)?
|
||||
|
||||
open override func loginWithQrCode(qrCodeData: QrCodeData, oidcConfiguration: OidcConfiguration, progressListener: QrLoginProgressListener) async throws {
|
||||
if let error = loginWithQrCodeQrCodeDataOidcConfigurationProgressListenerThrowableError {
|
||||
throw error
|
||||
}
|
||||
loginWithQrCodeQrCodeDataOidcConfigurationProgressListenerCallsCount += 1
|
||||
loginWithQrCodeQrCodeDataOidcConfigurationProgressListenerReceivedArguments = (qrCodeData: qrCodeData, oidcConfiguration: oidcConfiguration, progressListener: progressListener)
|
||||
DispatchQueue.main.async {
|
||||
self.loginWithQrCodeQrCodeDataOidcConfigurationProgressListenerReceivedInvocations.append((qrCodeData: qrCodeData, oidcConfiguration: oidcConfiguration, progressListener: progressListener))
|
||||
}
|
||||
try await loginWithQrCodeQrCodeDataOidcConfigurationProgressListenerClosure?(qrCodeData, oidcConfiguration, progressListener)
|
||||
}
|
||||
|
||||
//MARK: - logout
|
||||
|
||||
open var logoutThrowableError: Error?
|
||||
@@ -5637,81 +5683,6 @@ open class ClientBuilderSDKMock: MatrixRustSDK.ClientBuilder, @unchecked Sendabl
|
||||
}
|
||||
}
|
||||
|
||||
//MARK: - buildWithQrCode
|
||||
|
||||
open var buildWithQrCodeQrCodeDataOidcConfigurationProgressListenerThrowableError: Error?
|
||||
var buildWithQrCodeQrCodeDataOidcConfigurationProgressListenerUnderlyingCallsCount = 0
|
||||
open var buildWithQrCodeQrCodeDataOidcConfigurationProgressListenerCallsCount: Int {
|
||||
get {
|
||||
if Thread.isMainThread {
|
||||
return buildWithQrCodeQrCodeDataOidcConfigurationProgressListenerUnderlyingCallsCount
|
||||
} else {
|
||||
var returnValue: Int? = nil
|
||||
DispatchQueue.main.sync {
|
||||
returnValue = buildWithQrCodeQrCodeDataOidcConfigurationProgressListenerUnderlyingCallsCount
|
||||
}
|
||||
|
||||
return returnValue!
|
||||
}
|
||||
}
|
||||
set {
|
||||
if Thread.isMainThread {
|
||||
buildWithQrCodeQrCodeDataOidcConfigurationProgressListenerUnderlyingCallsCount = newValue
|
||||
} else {
|
||||
DispatchQueue.main.sync {
|
||||
buildWithQrCodeQrCodeDataOidcConfigurationProgressListenerUnderlyingCallsCount = newValue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
open var buildWithQrCodeQrCodeDataOidcConfigurationProgressListenerCalled: Bool {
|
||||
return buildWithQrCodeQrCodeDataOidcConfigurationProgressListenerCallsCount > 0
|
||||
}
|
||||
open var buildWithQrCodeQrCodeDataOidcConfigurationProgressListenerReceivedArguments: (qrCodeData: QrCodeData, oidcConfiguration: OidcConfiguration, progressListener: QrLoginProgressListener)?
|
||||
open var buildWithQrCodeQrCodeDataOidcConfigurationProgressListenerReceivedInvocations: [(qrCodeData: QrCodeData, oidcConfiguration: OidcConfiguration, progressListener: QrLoginProgressListener)] = []
|
||||
|
||||
var buildWithQrCodeQrCodeDataOidcConfigurationProgressListenerUnderlyingReturnValue: Client!
|
||||
open var buildWithQrCodeQrCodeDataOidcConfigurationProgressListenerReturnValue: Client! {
|
||||
get {
|
||||
if Thread.isMainThread {
|
||||
return buildWithQrCodeQrCodeDataOidcConfigurationProgressListenerUnderlyingReturnValue
|
||||
} else {
|
||||
var returnValue: Client? = nil
|
||||
DispatchQueue.main.sync {
|
||||
returnValue = buildWithQrCodeQrCodeDataOidcConfigurationProgressListenerUnderlyingReturnValue
|
||||
}
|
||||
|
||||
return returnValue!
|
||||
}
|
||||
}
|
||||
set {
|
||||
if Thread.isMainThread {
|
||||
buildWithQrCodeQrCodeDataOidcConfigurationProgressListenerUnderlyingReturnValue = newValue
|
||||
} else {
|
||||
DispatchQueue.main.sync {
|
||||
buildWithQrCodeQrCodeDataOidcConfigurationProgressListenerUnderlyingReturnValue = newValue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
open var buildWithQrCodeQrCodeDataOidcConfigurationProgressListenerClosure: ((QrCodeData, OidcConfiguration, QrLoginProgressListener) async throws -> Client)?
|
||||
|
||||
open override func buildWithQrCode(qrCodeData: QrCodeData, oidcConfiguration: OidcConfiguration, progressListener: QrLoginProgressListener) async throws -> Client {
|
||||
if let error = buildWithQrCodeQrCodeDataOidcConfigurationProgressListenerThrowableError {
|
||||
throw error
|
||||
}
|
||||
buildWithQrCodeQrCodeDataOidcConfigurationProgressListenerCallsCount += 1
|
||||
buildWithQrCodeQrCodeDataOidcConfigurationProgressListenerReceivedArguments = (qrCodeData: qrCodeData, oidcConfiguration: oidcConfiguration, progressListener: progressListener)
|
||||
DispatchQueue.main.async {
|
||||
self.buildWithQrCodeQrCodeDataOidcConfigurationProgressListenerReceivedInvocations.append((qrCodeData: qrCodeData, oidcConfiguration: oidcConfiguration, progressListener: progressListener))
|
||||
}
|
||||
if let buildWithQrCodeQrCodeDataOidcConfigurationProgressListenerClosure = buildWithQrCodeQrCodeDataOidcConfigurationProgressListenerClosure {
|
||||
return try await buildWithQrCodeQrCodeDataOidcConfigurationProgressListenerClosure(qrCodeData, oidcConfiguration, progressListener)
|
||||
} else {
|
||||
return buildWithQrCodeQrCodeDataOidcConfigurationProgressListenerReturnValue
|
||||
}
|
||||
}
|
||||
|
||||
//MARK: - crossProcessStoreLocksHolderName
|
||||
|
||||
var crossProcessStoreLocksHolderNameHolderNameUnderlyingCallsCount = 0
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -137,8 +137,7 @@ class AuthenticationStartScreenViewModelTests: XCTestCase {
|
||||
client = ClientSDKMock(configuration: .init(oidcLoginURL: supportsOIDC ? "https://account.company.com/authorize" : nil,
|
||||
supportsOIDCCreatePrompt: false,
|
||||
supportsPasswordLogin: true))
|
||||
let configuration = AuthenticationClientBuilderMock.Configuration(homeserverClients: ["company.com": client],
|
||||
qrCodeClient: client)
|
||||
let configuration = AuthenticationClientBuilderMock.Configuration(homeserverClients: ["company.com": client])
|
||||
|
||||
clientBuilderFactory = AuthenticationClientBuilderFactoryMock(configuration: .init(builderConfiguration: configuration))
|
||||
authenticationService = AuthenticationService(userSessionStore: UserSessionStoreMock(configuration: .init()),
|
||||
|
||||
@@ -316,8 +316,7 @@ class ServerConfirmationScreenViewModelTests: XCTestCase {
|
||||
client = ClientSDKMock(configuration: .init(oidcLoginURL: supportsOIDC ? "https://account.matrix.org/authorize" : nil,
|
||||
supportsOIDCCreatePrompt: supportsOIDCCreatePrompt,
|
||||
supportsPasswordLogin: supportsPasswordLogin))
|
||||
let configuration = AuthenticationClientBuilderMock.Configuration(homeserverClients: ["matrix.org": client],
|
||||
qrCodeClient: client)
|
||||
let configuration = AuthenticationClientBuilderMock.Configuration(homeserverClients: ["matrix.org": client])
|
||||
|
||||
clientBuilderFactory = AuthenticationClientBuilderFactoryMock(configuration: .init(builderConfiguration: configuration))
|
||||
service = AuthenticationService(userSessionStore: UserSessionStoreMock(configuration: .init()),
|
||||
|
||||
+1
-1
@@ -65,7 +65,7 @@ packages:
|
||||
# Element/Matrix dependencies
|
||||
MatrixRustSDK:
|
||||
url: https://github.com/element-hq/matrix-rust-components-swift
|
||||
exactVersion: 25.07.10
|
||||
exactVersion: 25.07.14-2
|
||||
# path: ../matrix-rust-sdk
|
||||
Compound:
|
||||
url: https://github.com/element-hq/compound-ios
|
||||
|
||||
Reference in New Issue
Block a user