mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-28 23:32:41 +00:00
Reset Crypto SDK on logout
This commit is contained in:
parent
13698ee8e7
commit
ff6fab708e
6 changed files with 65 additions and 8 deletions
|
@ -24,6 +24,9 @@ class AppConfiguration: CommonConfiguration {
|
|||
override func setupSettings() {
|
||||
super.setupSettings()
|
||||
setupAppSettings()
|
||||
#if DEBUG
|
||||
CryptoSDKConfiguration.shared.setup()
|
||||
#endif
|
||||
}
|
||||
|
||||
private func setupAppSettings() {
|
||||
|
|
|
@ -91,12 +91,6 @@ class CommonConfiguration: NSObject, Configurable {
|
|||
MXKeyProvider.sharedInstance().delegate = EncryptionKeyManager.shared
|
||||
|
||||
sdkOptions.enableNewClientInformationFeature = RiotSettings.shared.enableClientInformationFeature
|
||||
|
||||
#if DEBUG
|
||||
if sdkOptions.isCryptoSDKAvailable {
|
||||
sdkOptions.enableCryptoSDK = RiotSettings.shared.enableCryptoSDK
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
private func makeASCIIUserAgent() -> String? {
|
||||
|
|
55
Config/CryptoSDKConfiguration.swift
Normal file
55
Config/CryptoSDKConfiguration.swift
Normal file
|
@ -0,0 +1,55 @@
|
|||
//
|
||||
// Copyright 2023 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
#if DEBUG
|
||||
|
||||
/// Configuration for enabling / disabling Matrix Crypto SDK
|
||||
@objcMembers class CryptoSDKConfiguration: NSObject {
|
||||
static let shared = CryptoSDKConfiguration()
|
||||
|
||||
func setup() {
|
||||
guard MXSDKOptions.sharedInstance().isCryptoSDKAvailable else {
|
||||
return
|
||||
}
|
||||
|
||||
let isEnabled = RiotSettings.shared.enableCryptoSDK
|
||||
MXSDKOptions.sharedInstance().enableCryptoSDK = isEnabled
|
||||
|
||||
MXLog.debug("[CryptoSDKConfiguration] setup: Crypto SDK is \(isEnabled ? "enabled" : "disabled")")
|
||||
}
|
||||
|
||||
func enable() {
|
||||
guard MXSDKOptions.sharedInstance().isCryptoSDKAvailable else {
|
||||
return
|
||||
}
|
||||
|
||||
RiotSettings.shared.enableCryptoSDK = true
|
||||
MXSDKOptions.sharedInstance().enableCryptoSDK = true
|
||||
|
||||
MXLog.debug("[CryptoSDKConfiguration] enabling Crypto SDK")
|
||||
}
|
||||
|
||||
func disable() {
|
||||
RiotSettings.shared.enableCryptoSDK = false
|
||||
MXSDKOptions.sharedInstance().enableCryptoSDK = false
|
||||
|
||||
MXLog.debug("[CryptoSDKConfiguration] disabling Crypto SDK")
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -2183,6 +2183,11 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni
|
|||
// Clear cache
|
||||
[self clearCache];
|
||||
|
||||
// Reset Crypto SDK configuration (labs flag for which crypto module to use)
|
||||
#if DEBUG
|
||||
[CryptoSDKConfiguration.shared disable];
|
||||
#endif
|
||||
|
||||
// Reset key backup banner preferences
|
||||
[SecureBackupBannerPreferences.shared reset];
|
||||
|
||||
|
|
|
@ -3400,8 +3400,7 @@ ChangePasswordCoordinatorBridgePresenterDelegate>
|
|||
[confirmationAlert addAction:[UIAlertAction actionWithTitle:[VectorL10n continue] style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
|
||||
MXStrongifyAndReturnIfNil(self);
|
||||
|
||||
RiotSettings.shared.enableCryptoSDK = isEnabled;
|
||||
MXSDKOptions.sharedInstance.enableCryptoSDK = isEnabled;
|
||||
[CryptoSDKConfiguration.shared enable];
|
||||
[[AppDelegate theDelegate] reloadMatrixSessions:YES];
|
||||
}]];
|
||||
|
||||
|
|
1
changelog.d/pr-7323.change
Normal file
1
changelog.d/pr-7323.change
Normal file
|
@ -0,0 +1 @@
|
|||
CryptoV2: Reset Crypto SDK on logout
|
Loading…
Reference in a new issue