Fix a bug where UIA for cross signing wasn't needed until after checking for it. (#7874)

* Update the SDK.

* Fix a bug where UIA for cross signing wasn't needed until after checking for it.

This was due to the parameters not being present in the check, so we no longer check and instead do UIA on failure.
This commit is contained in:
Doug
2024-11-27 08:57:00 +00:00
committed by GitHub
parent 11568bdfc4
commit e4c73d4a9a
3 changed files with 28 additions and 29 deletions
@@ -45,7 +45,7 @@ final class CrossSigningSetupCoordinator: CrossSigningSetupCoordinatorType {
// MARK: - Public methods
func start() {
self.showReauthentication()
setupCrossSigning()
}
func toPresentable() -> UIViewController {
@@ -53,16 +53,33 @@ final class CrossSigningSetupCoordinator: CrossSigningSetupCoordinatorType {
}
// MARK: - Private methods
private func showReauthentication() {
private func setupCrossSigning(with authenticationParameters: [String: Any] = [:]) {
guard let crossSigning = parameters.session.crypto?.crossSigning else { return }
crossSigning.setup(withAuthParams: authenticationParameters) { [weak self] in
guard let self else { return }
delegate?.crossSigningSetupCoordinatorDidComplete(self)
} failure: { [weak self] error in
guard let self else { return }
if let responseData = (error as NSError).userInfo[MXHTTPClientErrorResponseDataKey] as? [AnyHashable: Any],
let authenticationSession = MXAuthenticationSession(fromJSON: responseData) {
showReauthentication(authenticationSession: authenticationSession)
} else {
delegate?.crossSigningSetupCoordinator(self, didFailWithError: error)
}
}
}
private func showReauthentication(authenticationSession: MXAuthenticationSession) {
let setupCrossSigningRequest = self.crossSigningService.setupCrossSigningRequest()
let reauthenticationParameters = ReauthenticationCoordinatorParameters(session: parameters.session,
presenter: parameters.presenter,
title: parameters.title,
message: parameters.message,
authenticatedEndpointRequest: setupCrossSigningRequest)
authenticationSession: authenticationSession)
let coordinator = ReauthenticationCoordinator(parameters: reauthenticationParameters)
coordinator.delegate = self
@@ -70,24 +87,6 @@ final class CrossSigningSetupCoordinator: CrossSigningSetupCoordinatorType {
coordinator.start()
}
private func setupCrossSigning(with authenticationParameters: [String: Any]) {
guard let crossSigning = self.parameters.session.crypto?.crossSigning else {
return
}
crossSigning.setup(withAuthParams: authenticationParameters) { [weak self] in
guard let self = self else {
return
}
self.delegate?.crossSigningSetupCoordinatorDidComplete(self)
} failure: { [weak self] error in
guard let self = self else {
return
}
self.delegate?.crossSigningSetupCoordinator(self, didFailWithError: error)
}
}
}
// MARK: - ReauthenticationCoordinatorDelegate