From 86b51fb1044f58d45322fea05f979b179ee25e0b Mon Sep 17 00:00:00 2001 From: Doug <6060466+pixlwave@users.noreply.github.com> Date: Fri, 22 May 2026 15:26:54 +0100 Subject: [PATCH] Remove the CertificateValidatorHook. (#5624) --- ElementX.xcodeproj/project.pbxproj | 4 ---- ElementX/Sources/AppHooks/AppHooks.swift | 9 --------- .../Hooks/CertificateValidatorHook.swift | 19 ------------------- .../UserSessionFlowCoordinator.swift | 1 - .../CallScreen/CallScreenCoordinator.swift | 2 -- .../Screens/CallScreen/CallScreenModels.swift | 2 -- .../CallScreen/CallScreenViewModel.swift | 4 +--- .../Screens/CallScreen/View/CallScreen.swift | 19 +++++++------------ Enterprise | 2 +- 9 files changed, 9 insertions(+), 53 deletions(-) delete mode 100644 ElementX/Sources/AppHooks/Hooks/CertificateValidatorHook.swift diff --git a/ElementX.xcodeproj/project.pbxproj b/ElementX.xcodeproj/project.pbxproj index 08c70daae..d6f89bba6 100644 --- a/ElementX.xcodeproj/project.pbxproj +++ b/ElementX.xcodeproj/project.pbxproj @@ -1332,7 +1332,6 @@ DF05F9C9D3D977EB77E13692 /* DeviceKit in Frameworks */ = {isa = PBXBuildFile; productRef = 385D4C28F9DC5CF53BD9ECDB /* DeviceKit */; }; DF40CDBEFE1D02B5F9C4ACB1 /* test_image.png in Resources */ = {isa = PBXBuildFile; fileRef = 810133CF215075C285FC6F3A /* test_image.png */; }; DF504B10A4918F971A57BEF2 /* PostHogAnalyticsClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1715E3D7F53C0748AA50C91C /* PostHogAnalyticsClient.swift */; }; - DF8F1211F2B0B56F0FCCA5C2 /* CertificateValidatorHook.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3865AD7B7249C939D7C69C33 /* CertificateValidatorHook.swift */; }; DFF7D6A6C26DDD40D00AE579 /* target.yml in Resources */ = {isa = PBXBuildFile; fileRef = F012CB5EE3F2B67359F6CC52 /* target.yml */; }; E010DDE938032D3B8E84CC35 /* TracingHook.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A95C9B8299A36A6495DECA6 /* TracingHook.swift */; }; E02DAD9FD8D62587049FFFEC /* LinkNewDeviceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80F04B12FA231E797B7151A8 /* LinkNewDeviceTests.swift */; }; @@ -1962,7 +1961,6 @@ 38345442415E07A931197C55 /* AppLockScreenPINKeypad.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppLockScreenPINKeypad.swift; sourceTree = ""; }; 38354164AF59C5006CD05878 /* GlobalSearchScreenViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GlobalSearchScreenViewModel.swift; sourceTree = ""; }; 384A744714571BAF138C6B86 /* ClassicAppAES.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClassicAppAES.swift; sourceTree = ""; }; - 3865AD7B7249C939D7C69C33 /* CertificateValidatorHook.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CertificateValidatorHook.swift; sourceTree = ""; }; 38E521D6C2BF8DF0DFB35146 /* DeveloperOptionsScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeveloperOptionsScreen.swift; sourceTree = ""; }; 3984C93B8E9B10C92DADF9EE /* RoomDirectorySearchScreenScreenModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomDirectorySearchScreenScreenModelProtocol.swift; sourceTree = ""; }; 398817652FA8ABAE0A31AC6D /* ReadableFrameModifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReadableFrameModifier.swift; sourceTree = ""; }; @@ -3738,7 +3736,6 @@ children = ( 13BE9781699FB510E9263192 /* AppSettingsHook.swift */, 25586C0ADB814FEE9897DCAA /* BugReportHook.swift */, - 3865AD7B7249C939D7C69C33 /* CertificateValidatorHook.swift */, 7AC0CD1CAFD3F8B057F9AEA5 /* ClientBuilderHook.swift */, 8B89D6C760E8CAE29CA28FB1 /* CompoundHook.swift */, 0F60FDB3AEFC60830BD289FE /* DeveloperOptionsScreenHook.swift */, @@ -8273,7 +8270,6 @@ 84CAE3E96D93194DA06B9194 /* CallScreenViewModelProtocol.swift in Sources */, BB6BF528BC7F5B87E08C4F18 /* CameraPicker.swift in Sources */, E14E469CD97550D0FC58F3CA /* CancellableTask.swift in Sources */, - DF8F1211F2B0B56F0FCCA5C2 /* CertificateValidatorHook.swift in Sources */, D885B783B95AD7832D4EF5DD /* CharacterSet.swift in Sources */, 3E2EE5782688054B3026EF8E /* ChatsSpaceFilterCell.swift in Sources */, E713F930C5AD0F4B11119E2B /* ChatsSpaceFiltersScreen.swift in Sources */, diff --git a/ElementX/Sources/AppHooks/AppHooks.swift b/ElementX/Sources/AppHooks/AppHooks.swift index 2e370ecba..ad735c92a 100644 --- a/ElementX/Sources/AppHooks/AppHooks.swift +++ b/ElementX/Sources/AppHooks/AppHooks.swift @@ -42,15 +42,6 @@ final class AppHooks: AppHooksProtocol { _bugReportHook.withLock { $0 = hook } } - private let _certificateValidatorHook: Mutex = Mutex(DefaultCertificateValidator()) - var certificateValidatorHook: CertificateValidatorHookProtocol { - _certificateValidatorHook.withLock { $0 } - } - - func registerCertificateValidatorHook(_ hook: CertificateValidatorHookProtocol) { - _certificateValidatorHook.withLock { $0 = hook } - } - private let _oAuthPresenterHook: Mutex = Mutex(DefaultOAuthPresenterHook()) var oAuthPresenterHook: OAuthPresenterHookProtocol { _oAuthPresenterHook.withLock { $0 } diff --git a/ElementX/Sources/AppHooks/Hooks/CertificateValidatorHook.swift b/ElementX/Sources/AppHooks/Hooks/CertificateValidatorHook.swift deleted file mode 100644 index 64fff370a..000000000 --- a/ElementX/Sources/AppHooks/Hooks/CertificateValidatorHook.swift +++ /dev/null @@ -1,19 +0,0 @@ -// -// Copyright 2025 Element Creations Ltd. -// Copyright 2024-2025 New Vector Ltd. -// -// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial. -// Please see LICENSE files in the repository root for full details. -// - -import Foundation - -protocol CertificateValidatorHookProtocol { - func respondTo(_ challenge: URLAuthenticationChallenge) async -> (URLSession.AuthChallengeDisposition, URLCredential?) -} - -struct DefaultCertificateValidator: CertificateValidatorHookProtocol { - func respondTo(_ challenge: URLAuthenticationChallenge) async -> (URLSession.AuthChallengeDisposition, URLCredential?) { - (.performDefaultHandling, nil) - } -} diff --git a/ElementX/Sources/FlowCoordinators/UserSessionFlowCoordinator.swift b/ElementX/Sources/FlowCoordinators/UserSessionFlowCoordinator.swift index ddb677a57..58d2b406d 100644 --- a/ElementX/Sources/FlowCoordinators/UserSessionFlowCoordinator.swift +++ b/ElementX/Sources/FlowCoordinators/UserSessionFlowCoordinator.swift @@ -433,7 +433,6 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol { configuration: configuration, allowPictureInPicture: true, appSettings: flowParameters.appSettings, - appHooks: flowParameters.appHooks, analytics: flowParameters.analytics)) callScreenCoordinator.actions diff --git a/ElementX/Sources/Screens/CallScreen/CallScreenCoordinator.swift b/ElementX/Sources/Screens/CallScreen/CallScreenCoordinator.swift index 396da8df4..ae24b3e7d 100644 --- a/ElementX/Sources/Screens/CallScreen/CallScreenCoordinator.swift +++ b/ElementX/Sources/Screens/CallScreen/CallScreenCoordinator.swift @@ -15,7 +15,6 @@ struct CallScreenCoordinatorParameters { let configuration: ElementCallConfiguration let allowPictureInPicture: Bool let appSettings: AppSettings - let appHooks: AppHooks let analytics: AnalyticsServiceProtocol } @@ -46,7 +45,6 @@ final class CallScreenCoordinator: CoordinatorProtocol { viewModel = CallScreenViewModel(elementCallService: parameters.elementCallService, configuration: parameters.configuration, allowPictureInPicture: parameters.allowPictureInPicture, - appHooks: parameters.appHooks, appSettings: parameters.appSettings, analyticsService: parameters.analytics) } diff --git a/ElementX/Sources/Screens/CallScreen/CallScreenModels.swift b/ElementX/Sources/Screens/CallScreen/CallScreenModels.swift index be14267ec..d05d8ed65 100644 --- a/ElementX/Sources/Screens/CallScreen/CallScreenModels.swift +++ b/ElementX/Sources/Screens/CallScreen/CallScreenModels.swift @@ -20,8 +20,6 @@ struct CallScreenViewState: BindableState { let script: String? var url: URL? - let certificateValidator: CertificateValidatorHookProtocol - var bindings = Bindings() } diff --git a/ElementX/Sources/Screens/CallScreen/CallScreenViewModel.swift b/ElementX/Sources/Screens/CallScreen/CallScreenViewModel.swift index 28b15f1b2..63ce49819 100644 --- a/ElementX/Sources/Screens/CallScreen/CallScreenViewModel.swift +++ b/ElementX/Sources/Screens/CallScreen/CallScreenViewModel.swift @@ -39,7 +39,6 @@ class CallScreenViewModel: CallScreenViewModelType, CallScreenViewModelProtocol init(elementCallService: ElementCallServiceProtocol, configuration: ElementCallConfiguration, allowPictureInPicture: Bool, - appHooks: AppHooks, appSettings: AppSettings, analyticsService: AnalyticsServiceProtocol) { self.elementCallService = elementCallService @@ -51,8 +50,7 @@ class CallScreenViewModel: CallScreenViewModelType, CallScreenViewModelProtocol guard let deviceID = configuration.clientProxy.deviceID else { fatalError("Missing device ID for the call.") } widgetDriver = configuration.roomProxy.elementCallWidgetDriver(deviceID: deviceID) - super.init(initialViewState: CallScreenViewState(script: CallScreenJavaScriptMessageName.allCasesInjectionScript, - certificateValidator: appHooks.certificateValidatorHook)) + super.init(initialViewState: CallScreenViewState(script: CallScreenJavaScriptMessageName.allCasesInjectionScript)) elementCallService.actions .receive(on: DispatchQueue.main) diff --git a/ElementX/Sources/Screens/CallScreen/View/CallScreen.swift b/ElementX/Sources/Screens/CallScreen/View/CallScreen.swift index 0671a36db..a2d38508d 100644 --- a/ElementX/Sources/Screens/CallScreen/View/CallScreen.swift +++ b/ElementX/Sources/Screens/CallScreen/View/CallScreen.swift @@ -74,7 +74,6 @@ private struct CallView: UIViewRepresentable { @MainActor class Coordinator: NSObject, WKUIDelegate, WKNavigationDelegate, AVPictureInPictureControllerDelegate { private weak var viewModelContext: CallScreenViewModel.Context? - private let certificateValidator: CertificateValidatorHookProtocol private var webView: WKWebView! private var pictureInPictureController: AVPictureInPictureController? @@ -88,7 +87,6 @@ private struct CallView: UIViewRepresentable { init(viewModelContext: CallScreenViewModel.Context) { self.viewModelContext = viewModelContext - certificateValidator = viewModelContext.viewState.certificateValidator pictureInPictureViewController = AVPictureInPictureVideoCallViewController() pictureInPictureViewController.preferredContentSize = CGSize(width: 1920, height: 1080) @@ -238,10 +236,6 @@ private struct CallView: UIViewRepresentable { // MARK: - WKNavigationDelegate - func webView(_ webView: WKWebView, respondTo challenge: URLAuthenticationChallenge) async -> (URLSession.AuthChallengeDisposition, URLCredential?) { - await certificateValidator.respondTo(challenge) - } - func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction) async -> WKNavigationActionPolicy { if let navigationURL = navigationAction.request.url { // Do not allow navigation to a different URL scheme. @@ -351,7 +345,13 @@ private struct CallView: UIViewRepresentable { // MARK: - Previews struct CallScreen_Previews: PreviewProvider { - static let viewModel = { + static let viewModel = makeViewModel() + + static var previews: some View { + CallScreen(context: viewModel.context) + } + + static func makeViewModel() -> CallScreenViewModel { let clientProxy = ClientProxyMock() clientProxy.deviceID = "call-device-id" @@ -373,12 +373,7 @@ struct CallScreen_Previews: PreviewProvider { voiceOnly: false, colorScheme: .light), allowPictureInPicture: false, - appHooks: AppHooks(), appSettings: .volatile(), analyticsService: AnalyticsServiceMock.default) - }() - - static var previews: some View { - CallScreen(context: viewModel.context) } } diff --git a/Enterprise b/Enterprise index 0157e8257..a8ea823ff 160000 --- a/Enterprise +++ b/Enterprise @@ -1 +1 @@ -Subproject commit 0157e82576946965e789b943532fba9b02f0340e +Subproject commit a8ea823ff9796f6485e4c34de9ddb1d309a8dc63