diff --git a/Riot/Modules/CrossSigning/CrossSigningService.swift b/Riot/Modules/CrossSigning/CrossSigningService.swift index 7c3b59a6f..ab40e6369 100644 --- a/Riot/Modules/CrossSigning/CrossSigningService.swift +++ b/Riot/Modules/CrossSigning/CrossSigningService.swift @@ -39,7 +39,7 @@ final class CrossSigningService: NSObject { // MARK - Properties private var supportSetupKeyVerificationByUser: [String: Bool] = [:] // Cached server response - private var authenticationSessionService: AuthenticationSessionService? + private var userInteractiveAuthenticationService: UserInteractiveAuthenticationService? // MARK - Public @@ -60,13 +60,13 @@ final class CrossSigningService: NSObject { return nil } - let authenticationSessionService = AuthenticationSessionService(session: session) + let userInteractiveAuthenticationService = UserInteractiveAuthenticationService(session: session) - self.authenticationSessionService = authenticationSessionService + self.userInteractiveAuthenticationService = userInteractiveAuthenticationService - let authenticationSessionParameters = self.setupCrossSigningAuthenticationSessionParameters() + let request = self.setupCrossSigningRequest() - return authenticationSessionService.canAuthenticate(for: authenticationSessionParameters) { (result) in + return userInteractiveAuthenticationService.canAuthenticate(with: request) { (result) in switch result { case .success(let succeeded): success(succeeded) @@ -76,9 +76,9 @@ final class CrossSigningService: NSObject { } } - func setupCrossSigningAuthenticationSessionParameters() -> AuthenticationSessionParameters { + func setupCrossSigningRequest() -> AuthenticatedEndpointRequest { let path = "\(kMXAPIPrefixPathUnstable)/keys/device_signing/upload" - return AuthenticationSessionParameters(path: path, httpMethod: "POST") + return AuthenticatedEndpointRequest(path: path, httpMethod: "POST") } /// Setup cross-signing without authentication. Useful when a grace period is enabled. @@ -90,15 +90,15 @@ final class CrossSigningService: NSObject { return nil } - let authenticationSessionService = AuthenticationSessionService(session: session) - self.authenticationSessionService = authenticationSessionService + let userInteractiveAuthenticationService = UserInteractiveAuthenticationService(session: session) + self.userInteractiveAuthenticationService = userInteractiveAuthenticationService - let authenticationSessionParameters = self.setupCrossSigningAuthenticationSessionParameters() + let request = self.setupCrossSigningRequest() - return authenticationSessionService.authenticationSession(for: authenticationSessionParameters) { result in + return userInteractiveAuthenticationService.authenticatedEndpointStatus(for: request) { result in switch result { - case .success(let authenticationSessionResult): - switch authenticationSessionResult { + case .success(let authenticatedEnpointStatus): + switch authenticatedEnpointStatus { case .authenticationNeeded: failure(CrossSigningServiceError.authenticationRequired) case .authenticationNotNeeded: diff --git a/Riot/Modules/CrossSigning/Setup/CrossSigningSetupCoordinator.swift b/Riot/Modules/CrossSigning/Setup/CrossSigningSetupCoordinator.swift index 05d5f1d4c..f545b2e44 100644 --- a/Riot/Modules/CrossSigning/Setup/CrossSigningSetupCoordinator.swift +++ b/Riot/Modules/CrossSigning/Setup/CrossSigningSetupCoordinator.swift @@ -56,13 +56,13 @@ final class CrossSigningSetupCoordinator: CrossSigningSetupCoordinatorType { private func showReauthentication() { - let authenticationSessionParameters = self.crossSigningService.setupCrossSigningAuthenticationSessionParameters() + let setupCrossSigningRequest = self.crossSigningService.setupCrossSigningRequest() let reauthenticationParameters = ReauthenticationCoordinatorParameters(session: parameters.session, presenter: parameters.presenter, title: parameters.title, message: parameters.message, - authenticationSessionParameters: authenticationSessionParameters) + authenticatedEndpointRequest: setupCrossSigningRequest) let coordinator = ReauthenticationCoordinator(parameters: reauthenticationParameters) coordinator.delegate = self diff --git a/Riot/Modules/Secrets/Reset/SecretsResetCoordinator.swift b/Riot/Modules/Secrets/Reset/SecretsResetCoordinator.swift index 426907887..6c72ebe5d 100644 --- a/Riot/Modules/Secrets/Reset/SecretsResetCoordinator.swift +++ b/Riot/Modules/Secrets/Reset/SecretsResetCoordinator.swift @@ -59,13 +59,13 @@ final class SecretsResetCoordinator: SecretsResetCoordinatorType { // MARK: - Private - private func showAuthentication(with authenticationSessionParameters: AuthenticationSessionParameters) { + private func showAuthentication(with request: AuthenticatedEndpointRequest) { let reauthenticationCoordinatorParameters = ReauthenticationCoordinatorParameters(session: self.session, presenter: self.toPresentable(), title: nil, message: VectorL10n.secretsResetAuthenticationMessage, - authenticationSessionParameters: authenticationSessionParameters) + authenticatedEndpointRequest: request) let coordinator = ReauthenticationCoordinator(parameters: reauthenticationCoordinatorParameters) coordinator.delegate = self @@ -77,8 +77,8 @@ final class SecretsResetCoordinator: SecretsResetCoordinatorType { // MARK: - SecretsResetViewModelCoordinatorDelegate extension SecretsResetCoordinator: SecretsResetViewModelCoordinatorDelegate { - func secretsResetViewModel(_ viewModel: SecretsResetViewModelType, needsToAuthenticateWith authenticationSessionParamaters: AuthenticationSessionParameters) { - self.showAuthentication(with: authenticationSessionParamaters) + func secretsResetViewModel(_ viewModel: SecretsResetViewModelType, needsToAuthenticateWith request: AuthenticatedEndpointRequest) { + self.showAuthentication(with: request) } func secretsResetViewModelDidResetSecrets(_ viewModel: SecretsResetViewModelType) { diff --git a/Riot/Modules/Secrets/Reset/SecretsResetViewModel.swift b/Riot/Modules/Secrets/Reset/SecretsResetViewModel.swift index 72330e934..8a122b23c 100644 --- a/Riot/Modules/Secrets/Reset/SecretsResetViewModel.swift +++ b/Riot/Modules/Secrets/Reset/SecretsResetViewModel.swift @@ -96,7 +96,7 @@ final class SecretsResetViewModel: SecretsResetViewModelType { } private func askAuthentication() { - let authenticationSessionParameters = self.crossSigningService.setupCrossSigningAuthenticationSessionParameters() - self.coordinatorDelegate?.secretsResetViewModel(self, needsToAuthenticateWith: authenticationSessionParameters) + let setupCrossSigningRequest = self.crossSigningService.setupCrossSigningRequest() + self.coordinatorDelegate?.secretsResetViewModel(self, needsToAuthenticateWith: setupCrossSigningRequest) } } diff --git a/Riot/Modules/Secrets/Reset/SecretsResetViewModelType.swift b/Riot/Modules/Secrets/Reset/SecretsResetViewModelType.swift index 26b9b295c..ce64f4c31 100644 --- a/Riot/Modules/Secrets/Reset/SecretsResetViewModelType.swift +++ b/Riot/Modules/Secrets/Reset/SecretsResetViewModelType.swift @@ -23,7 +23,7 @@ protocol SecretsResetViewModelViewDelegate: class { } protocol SecretsResetViewModelCoordinatorDelegate: class { - func secretsResetViewModel(_ viewModel: SecretsResetViewModelType, needsToAuthenticateWith authenticationSessionParamaters: AuthenticationSessionParameters) + func secretsResetViewModel(_ viewModel: SecretsResetViewModelType, needsToAuthenticateWith request: AuthenticatedEndpointRequest) func secretsResetViewModelDidResetSecrets(_ viewModel: SecretsResetViewModelType) func secretsResetViewModelDidCancel(_ viewModel: SecretsResetViewModelType) }