mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-20 16:42:44 +02:00
Cross-signing: Handle UserInteractiveAuthenticationService refactoring for cross signing setup.
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user