diff --git a/Riot.xcodeproj/project.pbxproj b/Riot.xcodeproj/project.pbxproj index 18e069960..8598de56b 100644 --- a/Riot.xcodeproj/project.pbxproj +++ b/Riot.xcodeproj/project.pbxproj @@ -280,12 +280,12 @@ B158253B2475350A00604D79 /* EventFormatter+DTCoreTextFix.m in Sources */ = {isa = PBXBuildFile; fileRef = B158253A2475350A00604D79 /* EventFormatter+DTCoreTextFix.m */; }; B158E72125485B9E000A7F75 /* Base32Coder.swift in Sources */ = {isa = PBXBuildFile; fileRef = B158E72025485B9E000A7F75 /* Base32Coder.swift */; }; B158E72325485EAB000A7F75 /* JitsiJWTTokenBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = B158E72225485EAB000A7F75 /* JitsiJWTTokenBuilder.swift */; }; - B1622D1825BF1A0000C73AE2 /* AuthenticationSessionService.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1622D1725BF1A0000C73AE2 /* AuthenticationSessionService.swift */; }; + B1622D1825BF1A0000C73AE2 /* UserInteractiveAuthenticationService.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1622D1725BF1A0000C73AE2 /* UserInteractiveAuthenticationService.swift */; }; B1622D1D25BF2B6800C73AE2 /* ReauthenticationCoordinatorBridgePresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1622D1A25BF2B6800C73AE2 /* ReauthenticationCoordinatorBridgePresenter.swift */; }; B1622D1E25BF2B6800C73AE2 /* ReauthenticationCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1622D1B25BF2B6800C73AE2 /* ReauthenticationCoordinator.swift */; }; B1622D1F25BF2B6800C73AE2 /* ReauthenticationCoordinatorType.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1622D1C25BF2B6800C73AE2 /* ReauthenticationCoordinatorType.swift */; }; B1622D2125BF2B7B00C73AE2 /* ReauthenticationCoordinatorParameters.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1622D2025BF2B7B00C73AE2 /* ReauthenticationCoordinatorParameters.swift */; }; - B1622D2325BF2E6500C73AE2 /* AuthenticationSessionParameters.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1622D2225BF2E6500C73AE2 /* AuthenticationSessionParameters.swift */; }; + B1622D2325BF2E6500C73AE2 /* AuthenticatedEndpointRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1622D2225BF2E6500C73AE2 /* AuthenticatedEndpointRequest.swift */; }; B1622D2525BF784300C73AE2 /* AuthenticationParametersBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1622D2425BF784300C73AE2 /* AuthenticationParametersBuilder.swift */; }; B1664BC520F4E67600808783 /* FallbackViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = B1664BAD20F4E67500808783 /* FallbackViewController.xib */; }; B1664BC620F4E67600808783 /* FallbackViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B1664BAE20F4E67500808783 /* FallbackViewController.m */; }; @@ -343,7 +343,7 @@ B16DC23E258A8025004DAB1A /* ThemeIdentifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = B16DC23D258A8025004DAB1A /* ThemeIdentifier.swift */; }; B17982FF2119FED2001FD722 /* GDPRConsentViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B17982FE2119FED2001FD722 /* GDPRConsentViewController.swift */; }; B1798302211B13B3001FD722 /* OnBoardingManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1798301211B13B3001FD722 /* OnBoardingManager.swift */; }; - B17DA77925C81A2B003FA4C1 /* AuthenticationSessionServiceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B17DA77825C81A2B003FA4C1 /* AuthenticationSessionServiceTests.swift */; }; + B17DA77925C81A2B003FA4C1 /* UserInteractiveAuthenticationServiceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B17DA77825C81A2B003FA4C1 /* UserInteractiveAuthenticationServiceTests.swift */; }; B17DA77B25C8B085003FA4C1 /* ReauthFallBackViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B17DA77A25C8B085003FA4C1 /* ReauthFallBackViewController.swift */; }; B183226623F55D6B0035B2E8 /* CameraAccessManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = B183226523F55D6B0035B2E8 /* CameraAccessManager.swift */; }; B183226823F561380035B2E8 /* CameraAccessAlertPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = B183226723F561380035B2E8 /* CameraAccessAlertPresenter.swift */; }; @@ -922,6 +922,7 @@ EC7749CD25A48F6100AB1295 /* PiPAnimator.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC7749CC25A48F6100AB1295 /* PiPAnimator.swift */; }; EC7749D125A5C58000AB1295 /* PiPView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC7749D025A5C58000AB1295 /* PiPView.swift */; }; EC7749D325A5C75400AB1295 /* PictureInPicturable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC7749D225A5C75400AB1295 /* PictureInPicturable.swift */; }; + EC711BB624A63C11008F830C /* UserInteractiveAuthenticationViewControllerFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC711BB524A63C11008F830C /* UserInteractiveAuthenticationViewControllerFactory.swift */; }; EC85D6AE2477DC89002C44C9 /* RoundedButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC85D6AD2477DC89002C44C9 /* RoundedButton.swift */; }; EC85D7142477DCD7002C44C9 /* KeyVerificationScanConfirmationViewState.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC85D70C2477DCD7002C44C9 /* KeyVerificationScanConfirmationViewState.swift */; }; EC85D7152477DCD7002C44C9 /* KeyVerificationScanConfirmationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC85D70D2477DCD7002C44C9 /* KeyVerificationScanConfirmationViewController.swift */; }; @@ -1395,12 +1396,12 @@ B158253A2475350A00604D79 /* EventFormatter+DTCoreTextFix.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "EventFormatter+DTCoreTextFix.m"; sourceTree = ""; }; B158E72025485B9E000A7F75 /* Base32Coder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Base32Coder.swift; sourceTree = ""; }; B158E72225485EAB000A7F75 /* JitsiJWTTokenBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JitsiJWTTokenBuilder.swift; sourceTree = ""; }; - B1622D1725BF1A0000C73AE2 /* AuthenticationSessionService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthenticationSessionService.swift; sourceTree = ""; }; + B1622D1725BF1A0000C73AE2 /* UserInteractiveAuthenticationService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserInteractiveAuthenticationService.swift; sourceTree = ""; }; B1622D1A25BF2B6800C73AE2 /* ReauthenticationCoordinatorBridgePresenter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ReauthenticationCoordinatorBridgePresenter.swift; sourceTree = ""; }; B1622D1B25BF2B6800C73AE2 /* ReauthenticationCoordinator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ReauthenticationCoordinator.swift; sourceTree = ""; }; B1622D1C25BF2B6800C73AE2 /* ReauthenticationCoordinatorType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ReauthenticationCoordinatorType.swift; sourceTree = ""; }; B1622D2025BF2B7B00C73AE2 /* ReauthenticationCoordinatorParameters.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReauthenticationCoordinatorParameters.swift; sourceTree = ""; }; - B1622D2225BF2E6500C73AE2 /* AuthenticationSessionParameters.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthenticationSessionParameters.swift; sourceTree = ""; }; + B1622D2225BF2E6500C73AE2 /* AuthenticatedEndpointRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthenticatedEndpointRequest.swift; sourceTree = ""; }; B1622D2425BF784300C73AE2 /* AuthenticationParametersBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthenticationParametersBuilder.swift; sourceTree = ""; }; B1664BAD20F4E67500808783 /* FallbackViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = FallbackViewController.xib; sourceTree = ""; }; B1664BAE20F4E67500808783 /* FallbackViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FallbackViewController.m; sourceTree = ""; }; @@ -1506,7 +1507,7 @@ B16DC23D258A8025004DAB1A /* ThemeIdentifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThemeIdentifier.swift; sourceTree = ""; }; B17982FE2119FED2001FD722 /* GDPRConsentViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GDPRConsentViewController.swift; sourceTree = ""; }; B1798301211B13B3001FD722 /* OnBoardingManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnBoardingManager.swift; sourceTree = ""; }; - B17DA77825C81A2B003FA4C1 /* AuthenticationSessionServiceTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthenticationSessionServiceTests.swift; sourceTree = ""; }; + B17DA77825C81A2B003FA4C1 /* UserInteractiveAuthenticationServiceTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserInteractiveAuthenticationServiceTests.swift; sourceTree = ""; }; B17DA77A25C8B085003FA4C1 /* ReauthFallBackViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReauthFallBackViewController.swift; sourceTree = ""; }; B183226523F55D6B0035B2E8 /* CameraAccessManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CameraAccessManager.swift; sourceTree = ""; }; B183226723F561380035B2E8 /* CameraAccessAlertPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CameraAccessAlertPresenter.swift; sourceTree = ""; }; @@ -2232,6 +2233,7 @@ EC7749CC25A48F6100AB1295 /* PiPAnimator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PiPAnimator.swift; sourceTree = ""; }; EC7749D025A5C58000AB1295 /* PiPView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PiPView.swift; sourceTree = ""; }; EC7749D225A5C75400AB1295 /* PictureInPicturable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PictureInPicturable.swift; sourceTree = ""; }; + EC711BB524A63C11008F830C /* UserInteractiveAuthenticationViewControllerFactory.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UserInteractiveAuthenticationViewControllerFactory.swift; sourceTree = ""; }; EC85D6AD2477DC89002C44C9 /* RoundedButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RoundedButton.swift; sourceTree = ""; }; EC85D70C2477DCD7002C44C9 /* KeyVerificationScanConfirmationViewState.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KeyVerificationScanConfirmationViewState.swift; sourceTree = ""; }; EC85D70D2477DCD7002C44C9 /* KeyVerificationScanConfirmationViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KeyVerificationScanConfirmationViewController.swift; sourceTree = ""; }; @@ -3628,7 +3630,7 @@ B10A3E9524FE86AE007C380F /* SplitView */, EC1CA84F24C1DEC400DE9EBF /* SetPinCode */, EC3B066324AC6ADD000DF9BF /* CrossSigning */, - EC711BB424A63C11008F830C /* AuthenticatedSession */, + EC711BB424A63C11008F830C /* UserInteractiveAuthentication */, EC711B9A24A63B58008F830C /* SecureBackup */, EC711B4724A63B36008F830C /* Secrets */, B1560DA024B65A9500490F50 /* LaunchLoading */, @@ -5371,15 +5373,15 @@ path = Banners; sourceTree = ""; }; - EC711BB424A63C11008F830C /* AuthenticatedSession */ = { + EC711BB424A63C11008F830C /* UserInteractiveAuthentication */ = { isa = PBXGroup; children = ( - EC711BB524A63C11008F830C /* AuthenticatedSessionViewControllerFactory.swift */, - B1622D1725BF1A0000C73AE2 /* AuthenticationSessionService.swift */, - B1622D2225BF2E6500C73AE2 /* AuthenticationSessionParameters.swift */, + EC711BB524A63C11008F830C /* UserInteractiveAuthenticationViewControllerFactory.swift */, + B1622D1725BF1A0000C73AE2 /* UserInteractiveAuthenticationService.swift */, + B1622D2225BF2E6500C73AE2 /* AuthenticatedEndpointRequest.swift */, B1622D2425BF784300C73AE2 /* AuthenticationParametersBuilder.swift */, ); - path = AuthenticatedSession; + path = UserInteractiveAuthentication; sourceTree = ""; }; EC757B2025B85C7F00DF5787 /* Dialpad */ = { @@ -5689,7 +5691,7 @@ F083BB041E7005FD00A9B29C /* RiotTests.m */, B152C73022DF561E0041315A /* EmojiServiceTests.swift */, B1562CE42541D113002F8436 /* JitsiWellKnownTests.swift */, - B17DA77825C81A2B003FA4C1 /* AuthenticationSessionServiceTests.swift */, + B17DA77825C81A2B003FA4C1 /* UserInteractiveAuthenticationServiceTests.swift */, F083BB071E70067700A9B29C /* Supporting Files */, ); path = RiotTests; @@ -6770,7 +6772,7 @@ B1B5571A20EE6C4D00210D55 /* SettingsViewController.m in Sources */, B1CE9EFD22148703000FAE6A /* SignOutAlertPresenter.swift in Sources */, 32F6B9692270623100BBA352 /* KeyVerificationDataLoadingCoordinator.swift in Sources */, - B1622D1825BF1A0000C73AE2 /* AuthenticationSessionService.swift in Sources */, + B1622D1825BF1A0000C73AE2 /* UserInteractiveAuthenticationService.swift in Sources */, B125FE1D231D5DE400B72806 /* SettingsDiscoveryViewModel.swift in Sources */, 32863A5A2384070300D07C4A /* RiotSharedSettings.swift in Sources */, B1B5594720EF7BD000210D55 /* RoomCollectionViewCell.m in Sources */, @@ -6996,7 +6998,7 @@ EC711BAF24A63B58008F830C /* SecureBackupSetupCoordinatorType.swift in Sources */, EC9E9B082575AF730007C0A0 /* CallVCDismissOperation.swift in Sources */, ECFBD5D4250A7AAF00DD5F5A /* ShowDirectoryCoordinatorType.swift in Sources */, - B1622D2325BF2E6500C73AE2 /* AuthenticationSessionParameters.swift in Sources */, + B1622D2325BF2E6500C73AE2 /* AuthenticatedEndpointRequest.swift in Sources */, EC1CA89C24C9C9A200DE9EBF /* SetupBiometricsViewModel.swift in Sources */, B157FAA323264AE900EBFBD4 /* SettingsDiscoveryThreePidDetailsViewState.swift in Sources */, B1098BF921ECFE65000DDA48 /* KeyBackupSetupCoordinator.swift in Sources */, @@ -7330,7 +7332,7 @@ EC1CA87724C82D0E00DE9EBF /* MemoryStore.swift in Sources */, B169746F25C21C1900E6B3FB /* CrossSigningSetupCoordinatorParameters.swift in Sources */, B1B9DEEE22EB34EF0065E677 /* ReactionHistoryViewAction.swift in Sources */, - EC711BB624A63C11008F830C /* AuthenticatedSessionViewControllerFactory.swift in Sources */, + EC711BB624A63C11008F830C /* UserInteractiveAuthenticationViewControllerFactory.swift in Sources */, B1C543A4239E98E400DCA1FA /* KeyVerificationCellInnerContentView.swift in Sources */, B10A3E8E24FE4368007C380F /* ElementView.swift in Sources */, B1CE83B62422812100D07506 /* KeyVerificationCoordinatorBridgePresenter.swift in Sources */, @@ -7357,7 +7359,7 @@ 32FD754D24D06EBF00BA7B37 /* RiotSettings.swift in Sources */, B1562CE52541D113002F8436 /* JitsiWellKnownTests.swift in Sources */, 32FD757124D2BEF700BA7B37 /* InfoPlist.swift in Sources */, - B17DA77925C81A2B003FA4C1 /* AuthenticationSessionServiceTests.swift in Sources */, + B17DA77925C81A2B003FA4C1 /* UserInteractiveAuthenticationServiceTests.swift in Sources */, 32FD756524D2AD5100BA7B37 /* BuildSettings.swift in Sources */, 32FD755524D0754500BA7B37 /* AppConfiguration.swift in Sources */, 32FD755124D074C700BA7B37 /* CommonConfiguration.swift in Sources */, diff --git a/Riot/Modules/AuthenticatedSession/AuthenticationSessionParameters.swift b/Riot/Modules/UserInteractiveAuthentication/AuthenticatedEndpointRequest.swift similarity index 85% rename from Riot/Modules/AuthenticatedSession/AuthenticationSessionParameters.swift rename to Riot/Modules/UserInteractiveAuthentication/AuthenticatedEndpointRequest.swift index 97a8e344b..dfa8c8ee5 100644 --- a/Riot/Modules/AuthenticatedSession/AuthenticationSessionParameters.swift +++ b/Riot/Modules/UserInteractiveAuthentication/AuthenticatedEndpointRequest.swift @@ -16,9 +16,9 @@ import Foundation -/// AuthenticationSessionParameters represents authenticated API endpoint parameters. +/// AuthenticatedEndpointRequest represents authenticated API endpoint request. @objcMembers -class AuthenticationSessionParameters: NSObject { +class AuthenticatedEndpointRequest: NSObject { let path: String let httpMethod: String diff --git a/Riot/Modules/AuthenticatedSession/AuthenticationParametersBuilder.swift b/Riot/Modules/UserInteractiveAuthentication/AuthenticationParametersBuilder.swift similarity index 100% rename from Riot/Modules/AuthenticatedSession/AuthenticationParametersBuilder.swift rename to Riot/Modules/UserInteractiveAuthentication/AuthenticationParametersBuilder.swift diff --git a/Riot/Modules/AuthenticatedSession/AuthenticationSessionService.swift b/Riot/Modules/UserInteractiveAuthentication/UserInteractiveAuthenticationService.swift similarity index 80% rename from Riot/Modules/AuthenticatedSession/AuthenticationSessionService.swift rename to Riot/Modules/UserInteractiveAuthentication/UserInteractiveAuthenticationService.swift index 379f2d2c7..9b3a0574a 100644 --- a/Riot/Modules/AuthenticatedSession/AuthenticationSessionService.swift +++ b/Riot/Modules/UserInteractiveAuthentication/UserInteractiveAuthenticationService.swift @@ -16,13 +16,13 @@ import Foundation -/// AuthenticationSessionService errors -enum AuthenticationSessionServiceError: Int, Error { +/// UserInteractiveAuthenticationService errors +enum UserInteractiveAuthenticationServiceError: Int, Error { case flowNotSupported = 0 } -extension AuthenticationSessionServiceError: CustomNSError { - static let errorDomain = "AuthenticationSessionServiceErrorDomain" +extension UserInteractiveAuthenticationServiceError: CustomNSError { + static let errorDomain = "UserInteractiveAuthenticationServiceErrorDomain" var errorCode: Int { return self.rawValue @@ -39,15 +39,15 @@ extension AuthenticationSessionServiceError: CustomNSError { } } -/// AuthenticationSessionResult indicates the success state after checking if an API endpoint needs authentication -enum AuthenticationSessionResult { +/// AuthenticatedEndpointStatus indicates the success status after checking if an API endpoint needs authentication +enum AuthenticatedEndpointStatus { case authenticationNotNeeded case authenticationNeeded(_ authenticationSession: MXAuthenticationSession) } -/// AuthenticationSessionService enables to check if an API endpoint needs authentication. +/// UserInteractiveAuthenticationService enables to check if an API endpoint needs authentication. @objcMembers -final class AuthenticationSessionService: NSObject { +final class UserInteractiveAuthenticationService: NSObject { // MARK: - Constants @@ -70,23 +70,23 @@ final class AuthenticationSessionService: NSObject { /// Check if API endpoint requires authentication and get authentication session if needed /// - Parameters: - /// - authenticationSessionParameters: API endpoint parameters - /// - completion: The closure executed the operation completes. AuthenticationSessionResult indicates + /// - request: Authenticated API endpoint request. + /// - completion: The closure executed the operation completes. AuthenticatedEndpointStatus indicates if authentication is needed or not. /// - Returns: A `MXHTTPOperation` instance. @discardableResult - func authenticationSession(for authenticationSessionParameters: AuthenticationSessionParameters, completion: @escaping (Result) -> Void) -> MXHTTPOperation { + func authenticatedEndpointStatus(for request: AuthenticatedEndpointRequest, completion: @escaping (Result) -> Void) -> MXHTTPOperation { - return self.authenticationSession(for: authenticationSessionParameters) { (authenticationSession) in + return self.authenticationSession(with: request) { (authenticationSession) in - let authenticationResult: AuthenticationSessionResult + let status: AuthenticatedEndpointStatus if let authenticationSession = authenticationSession { - authenticationResult = .authenticationNeeded(authenticationSession) + status = .authenticationNeeded(authenticationSession) } else { - authenticationResult = .authenticationNotNeeded + status = .authenticationNotNeeded } - completion(.success(authenticationResult)) + completion(.success(status)) } failure: { (error) in completion(.failure(error)) } @@ -94,13 +94,13 @@ final class AuthenticationSessionService: NSObject { /// Check if API endpoint requires authentication. /// - Parameters: - /// - authenticationSessionParameters: API endpoint parameters + /// - request: Authenticated API endpoint request. /// - completion: The closure executed the operation completes. /// - Returns: A `MXHTTPOperation` instance. @discardableResult - func canAuthenticate(for authenticationSessionParameters: AuthenticationSessionParameters, completion: @escaping (Result) -> Void) -> MXHTTPOperation { + func canAuthenticate(with request: AuthenticatedEndpointRequest, completion: @escaping (Result) -> Void) -> MXHTTPOperation { - return self.authenticationSession(for: authenticationSessionParameters) { (result) in + return self.authenticatedEndpointStatus(for: request) { (result) in switch result { case .success(let authenticationSessionResult): let canAuthenticate: Bool @@ -122,16 +122,16 @@ final class AuthenticationSessionService: NSObject { /// Check if API endpoint requires authentication. /// This method is compatible with Objective-C /// - Parameters: - /// - authenticationSessionParameters: API endpoint parameters + /// - request: Authenticated API endpoint request. /// - success: The closure executed the operation succeed. Get an MXAuthenticationSession if authentication is required or nil if there is no authentication needed. /// - failure: The closure executed the operation fails. /// - Returns: A `MXHTTPOperation` instance. @discardableResult - func authenticationSession(for authenticationSessionParameters: AuthenticationSessionParameters, + func authenticationSession(with request: AuthenticatedEndpointRequest, success: @escaping (MXAuthenticationSession?) -> Void, failure: @escaping (Error) -> Void) -> MXHTTPOperation { // Get the authentication flow required for this API - return self.session.matrixRestClient.authSessionForRequest(withMethod: authenticationSessionParameters.httpMethod, path: authenticationSessionParameters.path, parameters: [:], success: { [weak self] (authenticationSession) in + return self.session.matrixRestClient.authSessionForRequest(withMethod: request.httpMethod, path: request.path, parameters: [:], success: { [weak self] (authenticationSession) in guard let self = self else { return } @@ -146,7 +146,7 @@ final class AuthenticationSessionService: NSObject { success(authenticationSession) } else { // Flow not supported - failure(AuthenticationSessionServiceError.flowNotSupported) + failure(UserInteractiveAuthenticationServiceError.flowNotSupported) } } } else { diff --git a/Riot/Modules/AuthenticatedSession/AuthenticatedSessionViewControllerFactory.swift b/Riot/Modules/UserInteractiveAuthentication/UserInteractiveAuthenticationViewControllerFactory.swift similarity index 97% rename from Riot/Modules/AuthenticatedSession/AuthenticatedSessionViewControllerFactory.swift rename to Riot/Modules/UserInteractiveAuthentication/UserInteractiveAuthenticationViewControllerFactory.swift index b9ccc22f9..39bb1fc6a 100644 --- a/Riot/Modules/AuthenticatedSession/AuthenticatedSessionViewControllerFactory.swift +++ b/Riot/Modules/UserInteractiveAuthentication/UserInteractiveAuthenticationViewControllerFactory.swift @@ -17,7 +17,7 @@ import Foundation /// This class creates view controllers that can handle an authentication flow for given requests. @objcMembers -final class AuthenticatedSessionViewControllerFactory: NSObject { +final class UserInteractiveAuthenticationViewControllerFactory: NSObject { // MARK: - Password flow diff --git a/RiotTests/AuthenticationSessionServiceTests.swift b/RiotTests/UserInteractiveAuthenticationServiceTests.swift similarity index 91% rename from RiotTests/AuthenticationSessionServiceTests.swift rename to RiotTests/UserInteractiveAuthenticationServiceTests.swift index f7a89f6d0..223a2bfb4 100644 --- a/RiotTests/AuthenticationSessionServiceTests.swift +++ b/RiotTests/UserInteractiveAuthenticationServiceTests.swift @@ -18,7 +18,7 @@ import XCTest @testable import Riot -class AuthenticationSessionServiceTests: XCTestCase { +class UserInteractiveAuthenticationServiceTests: XCTestCase { override func setUpWithError() throws { // Put setup code here. This method is called before the invocation of each test method in the class. @@ -45,7 +45,7 @@ class AuthenticationSessionServiceTests: XCTestCase { authenticationSession.flows = [flow1, flow2] let mxSession = MXSession() - let authenticationSessionService = AuthenticationSessionService(session: mxSession) + let authenticationSessionService = UserInteractiveAuthenticationService(session: mxSession) let firstUncompletedStage = authenticationSessionService.firstUncompletedFlowIdentifier(in: authenticationSession)