mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-16 06:28:27 +02:00
Deprecate MXLegacyCrypto
This commit is contained in:
@@ -92,8 +92,7 @@ class CommonConfiguration: NSObject, Configurable {
|
||||
|
||||
sdkOptions.enableNewClientInformationFeature = RiotSettings.shared.enableClientInformationFeature
|
||||
|
||||
// Configure Crypto SDK feature deciding which crypto module to use
|
||||
sdkOptions.cryptoSDKFeature = CryptoSDKFeature.shared
|
||||
sdkOptions.cryptoMigrationDelegate = self
|
||||
}
|
||||
|
||||
private func makeASCIIUserAgent() -> String? {
|
||||
@@ -168,14 +167,16 @@ class CommonConfiguration: NSObject, Configurable {
|
||||
if RiotSettings.shared.allowStunServerFallback, let stunServerFallback = BuildSettings.stunServerFallbackUrlString {
|
||||
callManager.fallbackSTUNServer = stunServerFallback
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Per loaded matrix session settings
|
||||
|
||||
func setupSettingsWhenLoaded(for matrixSession: MXSession) {
|
||||
// Do not warn for unknown devices. We have cross-signing now
|
||||
(matrixSession.crypto as? MXLegacyCrypto)?.warnOnUnknowDevices = false
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
extension CommonConfiguration: MXCryptoV2MigrationDelegate {
|
||||
var needsVerificationUpgrade: Bool {
|
||||
get {
|
||||
RiotSettings.shared.showVerificationUpgradeAlert
|
||||
}
|
||||
set {
|
||||
RiotSettings.shared.showVerificationUpgradeAlert = newValue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,4 @@ import MatrixSDK
|
||||
|
||||
// MARK: - Per matrix session settings
|
||||
func setupSettings(for matrixSession: MXSession)
|
||||
|
||||
// MARK: - Per loaded matrix session settings
|
||||
func setupSettingsWhenLoaded(for matrixSession: MXSession)
|
||||
}
|
||||
|
||||
@@ -807,9 +807,6 @@ Tap the + to start adding people.";
|
||||
"settings_labs_enable_new_app_layout" = "New Application Layout";
|
||||
"settings_labs_enable_wysiwyg_composer" = "Try out the rich text editor";
|
||||
"settings_labs_enable_voice_broadcast" = "Voice broadcast";
|
||||
"settings_labs_enable_crypto_sdk" = "Rust end-to-end encryption";
|
||||
"settings_labs_confirm_crypto_sdk" = "Please be advised that as this feature is still in its experimental stage, it may not function as expected and could potentially have unintended consequences. To revert the feature, simply log out and log back in. Use at your own discretion and with caution.";
|
||||
"settings_labs_disable_crypto_sdk" = "Rust end-to-end encryption (log out to disable)";
|
||||
|
||||
"settings_version" = "Version %@";
|
||||
"settings_olm_version" = "Olm Version %@";
|
||||
|
||||
@@ -70,7 +70,6 @@ extension MXBugReportRestClient {
|
||||
|
||||
// SDKs
|
||||
userInfo["matrix_sdk_version"] = MatrixSDKVersion
|
||||
userInfo["crypto_module"] = MXSDKOptions.sharedInstance().cryptoModuleId
|
||||
if let crypto = mainAccount?.mxSession?.crypto {
|
||||
userInfo["crypto_module_version"] = crypto.version
|
||||
}
|
||||
|
||||
@@ -1,116 +0,0 @@
|
||||
//
|
||||
// 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
|
||||
import MatrixSDKCrypto
|
||||
|
||||
/// An implementation of `MXCryptoV2Feature` which uses `UserDefaults` to persist the enabled status
|
||||
/// of `CryptoSDK`, and which uses feature flags to control rollout availability.
|
||||
///
|
||||
/// The implementation uses both remote and local feature flags to control the availability of `CryptoSDK`.
|
||||
/// Whilst remote is more convenient in that it allows changes to the rollout without new app releases,
|
||||
/// it is not available to all users because it requires data tracking user consent. Remote therefore
|
||||
/// represents the safer, albeit limited rollout strategy, whereas the local feature flags allows eventually
|
||||
/// targetting all users, but each target change requires new app release.
|
||||
///
|
||||
/// Additionally users can manually enable this feature from the settings if they are not already in the
|
||||
/// feature group.
|
||||
@objc class CryptoSDKFeature: NSObject, MXCryptoV2Feature {
|
||||
@objc static let shared = CryptoSDKFeature()
|
||||
|
||||
var isEnabled: Bool {
|
||||
RiotSettings.shared.enableCryptoSDK
|
||||
}
|
||||
|
||||
var needsVerificationUpgrade: Bool {
|
||||
get {
|
||||
return RiotSettings.shared.showVerificationUpgradeAlert
|
||||
}
|
||||
set {
|
||||
RiotSettings.shared.showVerificationUpgradeAlert = newValue
|
||||
}
|
||||
}
|
||||
|
||||
private static let FeatureName = "ios-crypto-sdk"
|
||||
private static let FeatureNameV2 = "ios-crypto-sdk-v2"
|
||||
|
||||
private let remoteFeature: RemoteFeaturesClientProtocol
|
||||
private let localFeature: PhasedRolloutFeature
|
||||
|
||||
init(
|
||||
remoteFeature: RemoteFeaturesClientProtocol = PostHogAnalyticsClient.shared,
|
||||
localTargetPercentage: Double = 1
|
||||
) {
|
||||
self.remoteFeature = remoteFeature
|
||||
self.localFeature = PhasedRolloutFeature(
|
||||
name: Self.FeatureName,
|
||||
targetPercentage: localTargetPercentage
|
||||
)
|
||||
}
|
||||
|
||||
func enable() {
|
||||
RiotSettings.shared.enableCryptoSDK = true
|
||||
Analytics.shared.trackCryptoSDKEnabled()
|
||||
|
||||
MXLog.debug("[CryptoSDKFeature] Crypto SDK enabled")
|
||||
}
|
||||
|
||||
func enableIfAvailable(forUserId userId: String!) {
|
||||
guard !isEnabled else {
|
||||
MXLog.debug("[CryptoSDKFeature] enableIfAvailable: Feature is already enabled")
|
||||
return
|
||||
}
|
||||
|
||||
guard let userId else {
|
||||
MXLog.failure("[CryptoSDKFeature] enableIfAvailable: Missing user id")
|
||||
return
|
||||
}
|
||||
|
||||
guard isFeatureEnabled(userId: userId) else {
|
||||
MXLog.debug("[CryptoSDKFeature] enableIfAvailable: Feature is currently not available for this user")
|
||||
return
|
||||
}
|
||||
|
||||
MXLog.debug("[CryptoSDKFeature] enableIfAvailable: Feature has become available for this user and will be enabled")
|
||||
enable()
|
||||
}
|
||||
|
||||
@objc func canManuallyEnable(forUserId userId: String!) -> Bool {
|
||||
guard let userId else {
|
||||
MXLog.failure("[CryptoSDKFeature] canManuallyEnable: Missing user id")
|
||||
return false
|
||||
}
|
||||
|
||||
// User can manually enable only if not already within the automatic feature group
|
||||
return !isFeatureEnabled(userId: userId)
|
||||
}
|
||||
|
||||
@objc func reset() {
|
||||
RiotSettings.shared.enableCryptoSDK = false
|
||||
MXLog.debug("[CryptoSDKFeature] Crypto SDK disabled")
|
||||
}
|
||||
|
||||
private func isFeatureEnabled(userId: String) -> Bool {
|
||||
// This feature includes app version with a bug, and thus will not be rolled out to 100% users
|
||||
remoteFeature.isFeatureEnabled(Self.FeatureName)
|
||||
|
||||
// Second version of the remote feature with a bugfix and released eventually to 100% users
|
||||
|| remoteFeature.isFeatureEnabled(Self.FeatureNameV2)
|
||||
|
||||
// Local feature
|
||||
|| localFeature.isEnabled(userId: userId)
|
||||
}
|
||||
}
|
||||
@@ -7647,18 +7647,10 @@ public class VectorL10n: NSObject {
|
||||
public static var settingsLabs: String {
|
||||
return VectorL10n.tr("Vector", "settings_labs")
|
||||
}
|
||||
/// Please be advised that as this feature is still in its experimental stage, it may not function as expected and could potentially have unintended consequences. To revert the feature, simply log out and log back in. Use at your own discretion and with caution.
|
||||
public static var settingsLabsConfirmCryptoSdk: String {
|
||||
return VectorL10n.tr("Vector", "settings_labs_confirm_crypto_sdk")
|
||||
}
|
||||
/// Create conference calls with jitsi
|
||||
public static var settingsLabsCreateConferenceWithJitsi: String {
|
||||
return VectorL10n.tr("Vector", "settings_labs_create_conference_with_jitsi")
|
||||
}
|
||||
/// Rust end-to-end encryption (log out to disable)
|
||||
public static var settingsLabsDisableCryptoSdk: String {
|
||||
return VectorL10n.tr("Vector", "settings_labs_disable_crypto_sdk")
|
||||
}
|
||||
/// End-to-End Encryption
|
||||
public static var settingsLabsE2eEncryption: String {
|
||||
return VectorL10n.tr("Vector", "settings_labs_e2e_encryption")
|
||||
@@ -7671,10 +7663,6 @@ public class VectorL10n: NSObject {
|
||||
public static var settingsLabsEnableAutoReportDecryptionErrors: String {
|
||||
return VectorL10n.tr("Vector", "settings_labs_enable_auto_report_decryption_errors")
|
||||
}
|
||||
/// Rust end-to-end encryption
|
||||
public static var settingsLabsEnableCryptoSdk: String {
|
||||
return VectorL10n.tr("Vector", "settings_labs_enable_crypto_sdk")
|
||||
}
|
||||
/// Live location sharing - share current location (active development, and temporarily, locations persist in room history)
|
||||
public static var settingsLabsEnableLiveLocationSharing: String {
|
||||
return VectorL10n.tr("Vector", "settings_labs_enable_live_location_sharing")
|
||||
|
||||
@@ -274,7 +274,7 @@ extension Analytics {
|
||||
func trackE2EEError(_ reason: DecryptionFailureReason, context: String) {
|
||||
let event = AnalyticsEvent.Error(
|
||||
context: context,
|
||||
cryptoModule: MXSDKOptions.sharedInstance().enableCryptoSDK ? .Rust : .Native,
|
||||
cryptoModule: .Rust,
|
||||
domain: .E2EE,
|
||||
name: reason.errorName
|
||||
)
|
||||
|
||||
@@ -46,9 +46,6 @@ struct SentryMonitoringClient {
|
||||
if let message = event.message?.formatted {
|
||||
event.fingerprint = [message]
|
||||
}
|
||||
event.tags = [
|
||||
"crypto_module": MXSDKOptions.sharedInstance().cryptoModuleId
|
||||
]
|
||||
MXLog.debug("[SentryMonitoringClient] Issue detected: \(event)")
|
||||
return event
|
||||
}
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
#import "ContactDetailsViewController.h"
|
||||
|
||||
#import "BugReportViewController.h"
|
||||
#import "RoomKeyRequestViewController.h"
|
||||
#import "DecryptionFailureTracker.h"
|
||||
|
||||
#import "Tools.h"
|
||||
@@ -114,11 +113,6 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni
|
||||
id roomKeyRequestObserver;
|
||||
id roomKeyRequestCancellationObserver;
|
||||
|
||||
/**
|
||||
If any the currently displayed sharing key dialog
|
||||
*/
|
||||
RoomKeyRequestViewController *roomKeyRequestViewController;
|
||||
|
||||
/**
|
||||
Incoming key verification requests observers
|
||||
*/
|
||||
@@ -1823,8 +1817,6 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni
|
||||
// start the call service
|
||||
[self.callPresenter start];
|
||||
|
||||
[self.configuration setupSettingsWhenLoadedFor:mxSession];
|
||||
|
||||
// Register to user new device sign in notification
|
||||
[self registerUserDidSignInOnNewDeviceNotificationForSession:mxSession];
|
||||
|
||||
@@ -1833,8 +1825,6 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni
|
||||
// Register to new key verification request
|
||||
[self registerNewRequestNotificationForSession:mxSession];
|
||||
|
||||
[self checkLocalPrivateKeysInSession:mxSession];
|
||||
|
||||
[self.pushNotificationService checkPushKitPushersInSession:mxSession];
|
||||
}
|
||||
else if (mxSession.state == MXSessionStateRunning)
|
||||
@@ -2031,9 +2021,6 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni
|
||||
// If any, disable the no VoIP support workaround
|
||||
[self disableNoVoIPOnMatrixSession:mxSession];
|
||||
|
||||
// Disable listening of incoming key share requests
|
||||
[self disableRoomKeyRequestObserver:mxSession];
|
||||
|
||||
// Disable listening of incoming key verification requests
|
||||
[self disableIncomingKeyVerificationObserver:mxSession];
|
||||
|
||||
@@ -2183,9 +2170,6 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni
|
||||
// Clear cache
|
||||
[self clearCache];
|
||||
|
||||
// Reset Crypto SDK configuration (labs flag for which crypto module to use)
|
||||
[CryptoSDKFeature.shared reset];
|
||||
|
||||
// Reset key backup banner preferences
|
||||
[SecureBackupBannerPreferences.shared reset];
|
||||
|
||||
@@ -2296,11 +2280,6 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni
|
||||
case MXSessionStateSyncInProgress:
|
||||
// Stay in launching during the first server sync if the store is empty.
|
||||
isLaunching = (mainSession.rooms.count == 0 && launchAnimationContainerView);
|
||||
|
||||
if (mainSession.crypto.crossSigning && mainSession.crypto.crossSigning.state == MXCrossSigningStateCrossSigningExists && [mainSession.crypto isKindOfClass:[MXLegacyCrypto class]])
|
||||
{
|
||||
[(MXLegacyCrypto *)mainSession.crypto setOutgoingKeyRequestsEnabled:NO onComplete:nil];
|
||||
}
|
||||
break;
|
||||
case MXSessionStateRunning:
|
||||
self.clearingCache = NO;
|
||||
@@ -2360,7 +2339,6 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni
|
||||
|
||||
// This is the time to check existing requests
|
||||
MXLogDebug(@"[AppDelegate] handleAppState: Check pending verification requests");
|
||||
[self checkPendingRoomKeyRequests];
|
||||
[self checkPendingIncomingKeyVerificationsInSession:mainSession];
|
||||
|
||||
// TODO: When we will have an application state, we will do all of this in a dedicated initialisation state
|
||||
@@ -2369,9 +2347,6 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni
|
||||
{
|
||||
MXLogDebug(@"[AppDelegate] handleAppState: Set up observers for the crypto module");
|
||||
|
||||
// Enable listening of incoming key share requests
|
||||
[self enableRoomKeyRequestObserver:mainSession];
|
||||
|
||||
// Enable listening of incoming key verification requests
|
||||
[self enableIncomingKeyVerificationObserver:mainSession];
|
||||
}
|
||||
@@ -2397,16 +2372,8 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni
|
||||
{
|
||||
MXLogDebug(@"[AppDelegate] showLaunchAnimation");
|
||||
|
||||
LaunchLoadingView *launchLoadingView;
|
||||
if (MXSDKOptions.sharedInstance.enableStartupProgress)
|
||||
{
|
||||
MXSession *mainSession = self.mxSessions.firstObject;
|
||||
launchLoadingView = [LaunchLoadingView instantiateWithStartupProgress:mainSession.startupProgress];
|
||||
}
|
||||
else
|
||||
{
|
||||
launchLoadingView = [LaunchLoadingView instantiateWithStartupProgress:nil];
|
||||
}
|
||||
MXSession *mainSession = self.mxSessions.firstObject;
|
||||
LaunchLoadingView *launchLoadingView = [LaunchLoadingView instantiateWithStartupProgress:mainSession.startupProgress];
|
||||
|
||||
launchLoadingView.frame = window.bounds;
|
||||
[launchLoadingView updateWithTheme:ThemeService.shared.theme];
|
||||
@@ -2520,38 +2487,6 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)checkLocalPrivateKeysInSession:(MXSession*)mxSession
|
||||
{
|
||||
if (![mxSession.crypto isKindOfClass:[MXLegacyCrypto class]])
|
||||
{
|
||||
return;
|
||||
}
|
||||
MXLegacyCrypto *crypto = (MXLegacyCrypto *)mxSession.crypto;
|
||||
|
||||
MXRecoveryService *recoveryService = mxSession.crypto.recoveryService;
|
||||
NSUInteger keysCount = 0;
|
||||
if ([recoveryService hasSecretWithSecretId:MXSecretId.keyBackup])
|
||||
{
|
||||
keysCount++;
|
||||
}
|
||||
if ([recoveryService hasSecretWithSecretId:MXSecretId.crossSigningUserSigning])
|
||||
{
|
||||
keysCount++;
|
||||
}
|
||||
if ([recoveryService hasSecretWithSecretId:MXSecretId.crossSigningSelfSigning])
|
||||
{
|
||||
keysCount++;
|
||||
}
|
||||
|
||||
if ((keysCount > 0 && keysCount < 3)
|
||||
|| (mxSession.crypto.crossSigning.canTrustCrossSigning && !mxSession.crypto.crossSigning.canCrossSign))
|
||||
{
|
||||
// We should have 3 of them. If not, request them again as mitigation
|
||||
MXLogDebug(@"[AppDelegate] checkLocalPrivateKeysInSession: request keys because keysCount = %@", @(keysCount));
|
||||
[crypto requestAllPrivateKeys];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)authenticationDidComplete
|
||||
{
|
||||
[self handleAppState];
|
||||
@@ -3461,173 +3396,6 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - Incoming room key requests handling
|
||||
|
||||
- (void)enableRoomKeyRequestObserver:(MXSession*)mxSession
|
||||
{
|
||||
roomKeyRequestObserver =
|
||||
[[NSNotificationCenter defaultCenter] addObserverForName:kMXCryptoRoomKeyRequestNotification
|
||||
object:mxSession.crypto
|
||||
queue:[NSOperationQueue mainQueue]
|
||||
usingBlock:^(NSNotification *notif)
|
||||
{
|
||||
[self checkPendingRoomKeyRequestsInSession:mxSession];
|
||||
}];
|
||||
|
||||
roomKeyRequestCancellationObserver =
|
||||
[[NSNotificationCenter defaultCenter] addObserverForName:kMXCryptoRoomKeyRequestCancellationNotification
|
||||
object:mxSession.crypto
|
||||
queue:[NSOperationQueue mainQueue]
|
||||
usingBlock:^(NSNotification *notif)
|
||||
{
|
||||
[self checkPendingRoomKeyRequestsInSession:mxSession];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)disableRoomKeyRequestObserver:(MXSession*)mxSession
|
||||
{
|
||||
if (roomKeyRequestObserver)
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:roomKeyRequestObserver];
|
||||
roomKeyRequestObserver = nil;
|
||||
}
|
||||
|
||||
if (roomKeyRequestCancellationObserver)
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:roomKeyRequestCancellationObserver];
|
||||
roomKeyRequestCancellationObserver = nil;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if a key share dialog must be displayed for the given session
|
||||
- (void)checkPendingRoomKeyRequestsInSession:(MXSession*)mxSession
|
||||
{
|
||||
if ([UIApplication sharedApplication].applicationState != UIApplicationStateActive)
|
||||
{
|
||||
MXLogDebug(@"[AppDelegate] checkPendingRoomKeyRequestsInSession called while the app is not active. Ignore it.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (![mxSession.crypto isKindOfClass:[MXLegacyCrypto class]])
|
||||
{
|
||||
MXLogDebug(@"[AppDelegate] checkPendingRoomKeyRequestsInSession: Only legacy crypto allows manually accepting/rejecting key requests");
|
||||
return;
|
||||
}
|
||||
MXLegacyCrypto *crypto = (MXLegacyCrypto *)mxSession.crypto;
|
||||
|
||||
MXWeakify(self);
|
||||
[crypto pendingKeyRequests:^(MXUsersDevicesMap<NSArray<MXIncomingRoomKeyRequest *> *> *pendingKeyRequests) {
|
||||
|
||||
MXStrongifyAndReturnIfNil(self);
|
||||
MXLogDebug(@"[AppDelegate] checkPendingRoomKeyRequestsInSession: cross-signing state: %ld, pendingKeyRequests.count: %@. Already displayed: %@",
|
||||
crypto.crossSigning.state,
|
||||
@(pendingKeyRequests.count),
|
||||
self->roomKeyRequestViewController ? @"YES" : @"NO");
|
||||
|
||||
if (!crypto.crossSigning || crypto.crossSigning.state == MXCrossSigningStateNotBootstrapped)
|
||||
{
|
||||
if (self->roomKeyRequestViewController)
|
||||
{
|
||||
// Check if the current RoomKeyRequestViewController is still valid
|
||||
MXSession *currentMXSession = self->roomKeyRequestViewController.mxSession;
|
||||
NSString *currentUser = self->roomKeyRequestViewController.device.userId;
|
||||
NSString *currentDevice = self->roomKeyRequestViewController.device.deviceId;
|
||||
|
||||
NSArray<MXIncomingRoomKeyRequest *> *currentPendingRequest = [pendingKeyRequests objectForDevice:currentDevice forUser:currentUser];
|
||||
|
||||
if (currentMXSession == mxSession && currentPendingRequest.count == 0)
|
||||
{
|
||||
MXLogDebug(@"[AppDelegate] checkPendingRoomKeyRequestsInSession: Cancel current dialog");
|
||||
|
||||
// The key request has been probably cancelled, remove the popup
|
||||
[self->roomKeyRequestViewController hide];
|
||||
self->roomKeyRequestViewController = nil;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!self->roomKeyRequestViewController && pendingKeyRequests.count)
|
||||
{
|
||||
// Pick the first coming user/device pair
|
||||
NSString *userId = pendingKeyRequests.userIds.firstObject;
|
||||
NSString *deviceId = [pendingKeyRequests deviceIdsForUser:userId].firstObject;
|
||||
|
||||
// Give the client a chance to refresh the device list
|
||||
MXWeakify(self);
|
||||
[crypto downloadKeys:@[userId] forceDownload:NO success:^(MXUsersDevicesMap<MXDeviceInfo *> *usersDevicesInfoMap, NSDictionary<NSString *,MXCrossSigningInfo *> *crossSigningKeysMap) {
|
||||
|
||||
MXStrongifyAndReturnIfNil(self);
|
||||
MXDeviceInfo *deviceInfo = [usersDevicesInfoMap objectForDevice:deviceId forUser:userId];
|
||||
if (deviceInfo)
|
||||
{
|
||||
if (!crypto.crossSigning || crypto.crossSigning.state == MXCrossSigningStateNotBootstrapped)
|
||||
{
|
||||
BOOL wasNewDevice = (deviceInfo.trustLevel.localVerificationStatus == MXDeviceUnknown);
|
||||
|
||||
void (^openDialog)(void) = ^void()
|
||||
{
|
||||
MXLogDebug(@"[AppDelegate] checkPendingRoomKeyRequestsInSession: Open dialog for %@", deviceInfo);
|
||||
|
||||
self->roomKeyRequestViewController = [[RoomKeyRequestViewController alloc] initWithDeviceInfo:deviceInfo wasNewDevice:wasNewDevice andMatrixSession:mxSession crypto:crypto onComplete:^{
|
||||
|
||||
self->roomKeyRequestViewController = nil;
|
||||
|
||||
// Check next pending key request, if any
|
||||
[self checkPendingRoomKeyRequests];
|
||||
}];
|
||||
|
||||
[self->roomKeyRequestViewController show];
|
||||
};
|
||||
|
||||
// If the device was new before, it's not any more.
|
||||
if (wasNewDevice)
|
||||
{
|
||||
[crypto setDeviceVerification:MXDeviceUnverified forDevice:deviceId ofUser:userId success:openDialog failure:nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
openDialog();
|
||||
}
|
||||
}
|
||||
else if (deviceInfo.trustLevel.isVerified)
|
||||
{
|
||||
[crypto acceptAllPendingKeyRequestsFromUser:userId andDevice:deviceId onComplete:^{
|
||||
[self checkPendingRoomKeyRequests];
|
||||
}];
|
||||
}
|
||||
else
|
||||
{
|
||||
[crypto ignoreAllPendingKeyRequestsFromUser:userId andDevice:deviceId onComplete:^{
|
||||
[self checkPendingRoomKeyRequests];
|
||||
}];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MXLogDebug(@"[AppDelegate] checkPendingRoomKeyRequestsInSession: No details found for device %@:%@", userId, deviceId);
|
||||
[crypto ignoreAllPendingKeyRequestsFromUser:userId andDevice:deviceId onComplete:^{
|
||||
[self checkPendingRoomKeyRequests];
|
||||
}];
|
||||
}
|
||||
} failure:^(NSError *error) {
|
||||
// Retry later
|
||||
MXLogDebug(@"[AppDelegate] checkPendingRoomKeyRequestsInSession: Failed to download device keys. Retry");
|
||||
[self checkPendingRoomKeyRequests];
|
||||
}];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
// Check all opened MXSessions for key share dialog
|
||||
- (void)checkPendingRoomKeyRequests
|
||||
{
|
||||
for (MXSession *mxSession in mxSessionArray)
|
||||
{
|
||||
[self checkPendingRoomKeyRequestsInSession:mxSession];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Incoming key verification handling
|
||||
|
||||
- (void)enableIncomingKeyVerificationObserver:(MXSession*)mxSession
|
||||
@@ -3785,12 +3553,6 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni
|
||||
|
||||
- (void)keyVerificationCoordinatorBridgePresenterDelegateDidComplete:(KeyVerificationCoordinatorBridgePresenter *)coordinatorBridgePresenter otherUserId:(NSString * _Nonnull)otherUserId otherDeviceId:(NSString * _Nonnull)otherDeviceId
|
||||
{
|
||||
id<MXCrypto> crypto = coordinatorBridgePresenter.session.crypto;
|
||||
if ([crypto isKindOfClass:[MXLegacyCrypto class]] && (!crypto.backup.hasPrivateKeyInCryptoStore || !crypto.backup.enabled))
|
||||
{
|
||||
MXLogDebug(@"[AppDelegate][MXKeyVerification] requestAllPrivateKeys: Request key backup private keys");
|
||||
[(MXLegacyCrypto *)crypto setOutgoingKeyRequestsEnabled:YES onComplete:nil];
|
||||
}
|
||||
[self dismissKeyVerificationCoordinatorBridgePresenter];
|
||||
}
|
||||
|
||||
|
||||
@@ -613,8 +613,7 @@ final class AuthenticationCoordinator: NSObject, AuthenticationCoordinatorProtoc
|
||||
|
||||
/// Replace the contents of the navigation router with a loading animation.
|
||||
private func showLoadingAnimation() {
|
||||
let startupProgress: MXSessionStartupProgress? = MXSDKOptions.sharedInstance().enableStartupProgress ? session?.startupProgress : nil
|
||||
let loadingViewController = LaunchLoadingViewController(startupProgress: startupProgress)
|
||||
let loadingViewController = LaunchLoadingViewController(startupProgress: session?.startupProgress)
|
||||
loadingViewController.modalPresentationStyle = .fullScreen
|
||||
|
||||
// Replace the navigation stack with the loading animation
|
||||
@@ -759,12 +758,6 @@ extension AuthenticationCoordinator: AuthenticationServiceDelegate {
|
||||
// MARK: - KeyVerificationCoordinatorDelegate
|
||||
extension AuthenticationCoordinator: KeyVerificationCoordinatorDelegate {
|
||||
func keyVerificationCoordinatorDidComplete(_ coordinator: KeyVerificationCoordinatorType, otherUserId: String, otherDeviceId: String) {
|
||||
if let crypto = session?.crypto as? MXLegacyCrypto, let backup = crypto.backup,
|
||||
!backup.hasPrivateKeyInCryptoStore || !backup.enabled {
|
||||
MXLog.debug("[AuthenticationCoordinator][MXKeyVerification] requestAllPrivateKeys: Request key backup private keys")
|
||||
crypto.setOutgoingKeyRequestsEnabled(true, onComplete: nil)
|
||||
}
|
||||
|
||||
navigationRouter.dismissModule(animated: true) { [weak self] in
|
||||
self?.authenticationDidComplete()
|
||||
}
|
||||
|
||||
@@ -106,8 +106,7 @@ final class LegacyAuthenticationCoordinator: NSObject, AuthenticationCoordinator
|
||||
// MARK: - Private
|
||||
|
||||
private func showLoadingAnimation() {
|
||||
let startupProgress: MXSessionStartupProgress? = MXSDKOptions.sharedInstance().enableStartupProgress ? session?.startupProgress : nil
|
||||
let loadingViewController = LaunchLoadingViewController(startupProgress: startupProgress)
|
||||
let loadingViewController = LaunchLoadingViewController(startupProgress: session?.startupProgress)
|
||||
loadingViewController.modalPresentationStyle = .fullScreen
|
||||
|
||||
// Replace the navigation stack with the loading animation
|
||||
@@ -220,12 +219,6 @@ extension LegacyAuthenticationCoordinator: AuthenticationViewControllerDelegate
|
||||
// MARK: - KeyVerificationCoordinatorDelegate
|
||||
extension LegacyAuthenticationCoordinator: KeyVerificationCoordinatorDelegate {
|
||||
func keyVerificationCoordinatorDidComplete(_ coordinator: KeyVerificationCoordinatorType, otherUserId: String, otherDeviceId: String) {
|
||||
if let crypto = session?.crypto as? MXLegacyCrypto, let backup = crypto.backup,
|
||||
!backup.hasPrivateKeyInCryptoStore || !backup.enabled {
|
||||
MXLog.debug("[LegacyAuthenticationCoordinator][MXKeyVerification] requestAllPrivateKeys: Request key backup private keys")
|
||||
crypto.setOutgoingKeyRequestsEnabled(true, onComplete: nil)
|
||||
}
|
||||
|
||||
navigationRouter.dismissModule(animated: true) { [weak self] in
|
||||
self?.authenticationDidComplete()
|
||||
}
|
||||
|
||||
@@ -68,14 +68,7 @@ class SessionVerificationListener {
|
||||
return
|
||||
}
|
||||
|
||||
if session.state == .storeDataReady {
|
||||
if let crypto = session.crypto as? MXLegacyCrypto {
|
||||
// Do not make key share requests while the "Complete security" is not complete.
|
||||
// If the device is self-verified, the SDK will restore the existing key backup.
|
||||
// Then, it will re-enable outgoing key share requests
|
||||
crypto.setOutgoingKeyRequestsEnabled(false, onComplete: nil)
|
||||
}
|
||||
} else if session.state == .running {
|
||||
if session.state == .running {
|
||||
unregisterSessionStateChangeNotification()
|
||||
|
||||
if let crypto = session.crypto {
|
||||
@@ -101,7 +94,6 @@ class SessionVerificationListener {
|
||||
self.completion?(.authenticationIsComplete)
|
||||
} failure: { error in
|
||||
MXLog.error("[SessionVerificationListener] sessionStateDidChange: Bootstrap failed", context: error)
|
||||
(crypto as? MXLegacyCrypto)?.setOutgoingKeyRequestsEnabled(true, onComplete: nil)
|
||||
self.completion?(.authenticationIsComplete)
|
||||
}
|
||||
} else {
|
||||
@@ -111,12 +103,10 @@ class SessionVerificationListener {
|
||||
self.completion?(.authenticationIsComplete)
|
||||
} failure: { error in
|
||||
MXLog.error("[SessionVerificationListener] sessionStateDidChange: Do not know how to bootstrap cross-signing. Skip it.")
|
||||
(crypto as? MXLegacyCrypto)?.setOutgoingKeyRequestsEnabled(true, onComplete: nil)
|
||||
self.completion?(.authenticationIsComplete)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
(crypto as? MXLegacyCrypto)?.setOutgoingKeyRequestsEnabled(true, onComplete: nil)
|
||||
self.completion?(.authenticationIsComplete)
|
||||
}
|
||||
case .crossSigningExists:
|
||||
@@ -124,13 +114,10 @@ class SessionVerificationListener {
|
||||
self.completion?(.needsVerification)
|
||||
default:
|
||||
MXLog.debug("[SessionVerificationListener] sessionStateDidChange: Nothing to do")
|
||||
|
||||
(crypto as? MXLegacyCrypto)?.setOutgoingKeyRequestsEnabled(true, onComplete: nil)
|
||||
self.completion?(.authenticationIsComplete)
|
||||
}
|
||||
} failure: { [weak self] error in
|
||||
MXLog.error("[SessionVerificationListener] sessionStateDidChange: Fail to refresh crypto state", context: error)
|
||||
(crypto as? MXLegacyCrypto)?.setOutgoingKeyRequestsEnabled(true, onComplete: nil)
|
||||
self?.completion?(.authenticationIsComplete)
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -370,28 +370,16 @@ CallAudioRouteMenuViewDelegate>
|
||||
{
|
||||
typeof(self) self = weakSelf;
|
||||
self->currentAlert = nil;
|
||||
|
||||
// Acknowledge the existence of all devices
|
||||
[self startActivityIndicator];
|
||||
if (![self.mainSession.crypto isKindOfClass:[MXLegacyCrypto class]])
|
||||
|
||||
// Retry the call
|
||||
if (call.isIncoming)
|
||||
{
|
||||
MXLogFailure(@"[CallViewController] call: Only legacy crypto supports manual setting of known devices");
|
||||
return;
|
||||
[call answer];
|
||||
}
|
||||
else
|
||||
{
|
||||
[call callWithVideo:call.isVideoCall];
|
||||
}
|
||||
[(MXLegacyCrypto *)self.mainSession.crypto setDevicesKnown:unknownDevices complete:^{
|
||||
|
||||
[self stopActivityIndicator];
|
||||
|
||||
// Retry the call
|
||||
if (call.isIncoming)
|
||||
{
|
||||
[call answer];
|
||||
}
|
||||
else
|
||||
{
|
||||
[call callWithVideo:call.isVideoCall];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
}]];
|
||||
|
||||
@@ -988,8 +988,7 @@ extension AllChatsViewController: SplitViewMasterViewControllerProtocol {
|
||||
let title: String
|
||||
let message: String
|
||||
|
||||
if let feature = MXSDKOptions.sharedInstance().cryptoSDKFeature,
|
||||
feature.isEnabled && feature.needsVerificationUpgrade {
|
||||
if MXSDKOptions.sharedInstance().cryptoMigrationDelegate?.needsVerificationUpgrade == true {
|
||||
title = VectorL10n.keyVerificationSelfVerifySecurityUpgradeAlertTitle
|
||||
message = VectorL10n.keyVerificationSelfVerifySecurityUpgradeAlertMessage
|
||||
} else {
|
||||
|
||||
@@ -69,9 +69,6 @@ final class LaunchLoadingView: UIView, NibLoadable, Themable {
|
||||
|
||||
extension LaunchLoadingView: MXSessionStartupProgressDelegate {
|
||||
func sessionDidUpdateStartupProgress(state: MXSessionStartupProgress.State) {
|
||||
guard MXSDKOptions.sharedInstance().enableStartupProgress else {
|
||||
return
|
||||
}
|
||||
update(with: state)
|
||||
|
||||
}
|
||||
|
||||
@@ -946,15 +946,7 @@ static NSArray<NSNumber*> *initialSyncSilentErrorsHTTPStatusCodes;
|
||||
[MXKRoomDataSourceManager removeSharedManagerForMatrixSession:mxSession];
|
||||
|
||||
if (clearStore)
|
||||
{
|
||||
// Force a reload of device keys at the next session start, unless we are just about to migrate
|
||||
// all data and device keys into CryptoSDK.
|
||||
// This will fix potential UISIs other peoples receive for our messages.
|
||||
if ([mxSession.crypto isKindOfClass:[MXLegacyCrypto class]] && !MXSDKOptions.sharedInstance.enableCryptoSDK)
|
||||
{
|
||||
[(MXLegacyCrypto *)mxSession.crypto resetDeviceKeys];
|
||||
}
|
||||
|
||||
{
|
||||
// Clean other stores
|
||||
[mxSession.scanManager deleteAllAntivirusScans];
|
||||
[mxSession.aggregations resetData];
|
||||
|
||||
@@ -6356,21 +6356,10 @@ static CGSize kThreadListBarButtonItemImageSize;
|
||||
self->currentAlert = nil;
|
||||
|
||||
// Acknowledge the existence of all devices
|
||||
[self startActivityIndicator];
|
||||
self->unknownDevices = nil;
|
||||
|
||||
if (![self.mainSession.crypto isKindOfClass:[MXLegacyCrypto class]])
|
||||
{
|
||||
MXLogFailure(@"[RoomVC] eventDidChangeSentState: Only legacy crypto supports manual setting of known devices");
|
||||
return;
|
||||
}
|
||||
[(MXLegacyCrypto *)self.mainSession.crypto setDevicesKnown:self->unknownDevices complete:^{
|
||||
|
||||
self->unknownDevices = nil;
|
||||
[self stopActivityIndicator];
|
||||
|
||||
// And resend pending messages
|
||||
[self resendAllUnsentMessages];
|
||||
}];
|
||||
// And resend pending messages
|
||||
[self resendAllUnsentMessages];
|
||||
}
|
||||
|
||||
}]];
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
/*
|
||||
Copyright 2017 Vector Creations 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 <UIKit/UIKit.h>
|
||||
|
||||
#import <MatrixSDK/MatrixSDK.h>
|
||||
|
||||
/**
|
||||
The `RoomKeyRequestViewController` display a modal dialog at the top of the
|
||||
application asking the user if he wants to share room keys with a user's device.
|
||||
For the moment, the user is himself.
|
||||
*/
|
||||
@interface RoomKeyRequestViewController : NSObject
|
||||
|
||||
/**
|
||||
The UIAlertController instance which handles the dialog.
|
||||
*/
|
||||
@property (nonatomic, readonly) UIAlertController *alertController;
|
||||
|
||||
@property (nonatomic, readonly) MXSession *mxSession;
|
||||
@property (nonatomic, readonly) MXDeviceInfo *device;
|
||||
|
||||
/**
|
||||
Initialise an `RoomKeyRequestViewController` instance.
|
||||
|
||||
@param deviceInfo the device to share keys to.
|
||||
@param wasNewDevice flag indicating whether this is the first time we meet the device.
|
||||
@param session the related matrix session.
|
||||
@param crypto the related (legacy) crypto module
|
||||
@param onComplete a block called when the the dialog is closed.
|
||||
@return the newly created instance.
|
||||
*/
|
||||
- (instancetype)initWithDeviceInfo:(MXDeviceInfo*)deviceInfo
|
||||
wasNewDevice:(BOOL)wasNewDevice
|
||||
andMatrixSession:(MXSession*)session
|
||||
crypto:(MXLegacyCrypto *)crypto
|
||||
onComplete:(void (^)(void))onComplete;
|
||||
|
||||
/**
|
||||
Show the dialog in a modal way.
|
||||
*/
|
||||
- (void)show;
|
||||
|
||||
/**
|
||||
Hide the dialog.
|
||||
*/
|
||||
- (void)hide;
|
||||
|
||||
@end
|
||||
@@ -1,195 +0,0 @@
|
||||
/*
|
||||
Copyright 2017 Vector Creations 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 "RoomKeyRequestViewController.h"
|
||||
|
||||
#import "GeneratedInterface-Swift.h"
|
||||
|
||||
@interface RoomKeyRequestViewController () <KeyVerificationCoordinatorBridgePresenterDelegate>
|
||||
{
|
||||
void (^onComplete)(void);
|
||||
|
||||
KeyVerificationCoordinatorBridgePresenter *keyVerificationCoordinatorBridgePresenter;
|
||||
|
||||
BOOL wasNewDevice;
|
||||
}
|
||||
|
||||
@property (nonatomic, strong) MXLegacyCrypto *crypto;
|
||||
|
||||
@end
|
||||
|
||||
@implementation RoomKeyRequestViewController
|
||||
|
||||
- (instancetype)initWithDeviceInfo:(MXDeviceInfo *)deviceInfo
|
||||
wasNewDevice:(BOOL)theWasNewDevice
|
||||
andMatrixSession:(MXSession *)session
|
||||
crypto:(MXLegacyCrypto *)crypto
|
||||
onComplete:(void (^)(void))onCompleteBlock
|
||||
{
|
||||
self = [super init];
|
||||
if (self)
|
||||
{
|
||||
_mxSession = session;
|
||||
_crypto = crypto;
|
||||
_device = deviceInfo;
|
||||
wasNewDevice = theWasNewDevice;
|
||||
onComplete = onCompleteBlock;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)show
|
||||
{
|
||||
// Show it modally on the root view controller
|
||||
UIViewController *rootViewController = [AppDelegate theDelegate].window.rootViewController;
|
||||
if (rootViewController)
|
||||
{
|
||||
NSString *title = [VectorL10n e2eRoomKeyRequestTitle];
|
||||
NSString *message;
|
||||
if (wasNewDevice)
|
||||
{
|
||||
message = [VectorL10n e2eRoomKeyRequestMessageNewDevice:_device.displayName];
|
||||
}
|
||||
else
|
||||
{
|
||||
message = [VectorL10n e2eRoomKeyRequestMessage:_device.displayName];
|
||||
}
|
||||
|
||||
_alertController = [UIAlertController alertControllerWithTitle:title
|
||||
message:message
|
||||
preferredStyle:UIAlertControllerStyleAlert];
|
||||
|
||||
__weak typeof(self) weakSelf = self;
|
||||
|
||||
[_alertController addAction:[UIAlertAction actionWithTitle:[VectorL10n e2eRoomKeyRequestStartVerification]
|
||||
style:UIAlertActionStyleDefault
|
||||
handler:^(UIAlertAction * action) {
|
||||
|
||||
if (weakSelf)
|
||||
{
|
||||
typeof(self) self = weakSelf;
|
||||
|
||||
self->_alertController = nil;
|
||||
[self showVerificationView];
|
||||
}
|
||||
}]];
|
||||
|
||||
[_alertController addAction:[UIAlertAction actionWithTitle:[VectorL10n e2eRoomKeyRequestShareWithoutVerifying]
|
||||
style:UIAlertActionStyleDefault
|
||||
handler:^(UIAlertAction * action) {
|
||||
|
||||
if (weakSelf)
|
||||
{
|
||||
typeof(self) self = weakSelf;
|
||||
|
||||
self->_alertController = nil;
|
||||
|
||||
// Accept the received requests from this device
|
||||
[self.crypto acceptAllPendingKeyRequestsFromUser:self.device.userId andDevice:self.device.deviceId onComplete:^{
|
||||
|
||||
self->onComplete();
|
||||
}];
|
||||
}
|
||||
}]];
|
||||
|
||||
[_alertController addAction:[UIAlertAction actionWithTitle:[VectorL10n e2eRoomKeyRequestIgnoreRequest]
|
||||
style:UIAlertActionStyleDefault
|
||||
handler:^(UIAlertAction * action) {
|
||||
|
||||
if (weakSelf)
|
||||
{
|
||||
typeof(self) self = weakSelf;
|
||||
|
||||
self->_alertController = nil;
|
||||
|
||||
// Ignore all pending requests from this device
|
||||
[self.crypto ignoreAllPendingKeyRequestsFromUser:self.device.userId andDevice:self.device.deviceId onComplete:^{
|
||||
|
||||
self->onComplete();
|
||||
}];
|
||||
}
|
||||
}]];
|
||||
|
||||
[rootViewController presentViewController:_alertController animated:YES completion:nil];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)hide
|
||||
{
|
||||
if (_alertController)
|
||||
{
|
||||
[_alertController dismissViewControllerAnimated:YES completion:nil];
|
||||
_alertController = nil;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (void)showVerificationView
|
||||
{
|
||||
// Show it modally on the root view controller
|
||||
UIViewController *rootViewController = [AppDelegate theDelegate].window.rootViewController;
|
||||
if (rootViewController)
|
||||
{
|
||||
keyVerificationCoordinatorBridgePresenter = [[KeyVerificationCoordinatorBridgePresenter alloc] initWithSession:_mxSession];
|
||||
keyVerificationCoordinatorBridgePresenter.delegate = self;
|
||||
|
||||
[keyVerificationCoordinatorBridgePresenter presentFrom:rootViewController otherUserId:_device.userId otherDeviceId:_device.deviceId animated:YES];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - DeviceVerificationCoordinatorBridgePresenterDelegate
|
||||
|
||||
- (void)keyVerificationCoordinatorBridgePresenterDelegateDidComplete:(KeyVerificationCoordinatorBridgePresenter *)coordinatorBridgePresenter otherUserId:(NSString * _Nonnull)otherUserId otherDeviceId:(NSString * _Nonnull)otherDeviceId
|
||||
{
|
||||
[self dismissKeyVerificationCoordinatorBridgePresenter];
|
||||
}
|
||||
|
||||
- (void)keyVerificationCoordinatorBridgePresenterDelegateDidCancel:(KeyVerificationCoordinatorBridgePresenter * _Nonnull)coordinatorBridgePresenter
|
||||
{
|
||||
[self dismissKeyVerificationCoordinatorBridgePresenter];
|
||||
}
|
||||
|
||||
- (void)dismissKeyVerificationCoordinatorBridgePresenter
|
||||
{
|
||||
[keyVerificationCoordinatorBridgePresenter dismissWithAnimated:YES completion:nil];
|
||||
keyVerificationCoordinatorBridgePresenter = nil;
|
||||
|
||||
// Check device new status
|
||||
[self.crypto downloadKeys:@[self.device.userId] forceDownload:NO success:^(MXUsersDevicesMap<MXDeviceInfo *> *usersDevicesInfoMap, NSDictionary<NSString *,MXCrossSigningInfo *> *crossSigningKeysMap) {
|
||||
|
||||
MXDeviceInfo *deviceInfo = [usersDevicesInfoMap objectForDevice:self.device.deviceId forUser:self.device.userId];
|
||||
if (deviceInfo && deviceInfo.trustLevel.localVerificationStatus == MXDeviceVerified)
|
||||
{
|
||||
// Accept the received requests from this device
|
||||
// As the device is now verified, all other key requests will be automatically accepted.
|
||||
[self.crypto acceptAllPendingKeyRequestsFromUser:self.device.userId andDevice:self.device.deviceId onComplete:^{
|
||||
|
||||
self->onComplete();
|
||||
}];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Come back to self.alertController - ie, reopen it
|
||||
[self show];
|
||||
}
|
||||
} failure:^(NSError *error) {
|
||||
|
||||
// Should not happen (the device is in the crypto db)
|
||||
[self show];
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -176,8 +176,7 @@ typedef NS_ENUM(NSUInteger, LABS_ENABLE)
|
||||
LABS_ENABLE_NEW_SESSION_MANAGER,
|
||||
LABS_ENABLE_NEW_CLIENT_INFO_FEATURE,
|
||||
LABS_ENABLE_WYSIWYG_COMPOSER,
|
||||
LABS_ENABLE_VOICE_BROADCAST,
|
||||
LABS_ENABLE_CRYPTO_SDK
|
||||
LABS_ENABLE_VOICE_BROADCAST
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSUInteger, SECURITY)
|
||||
@@ -588,11 +587,6 @@ ChangePasswordCoordinatorBridgePresenterDelegate>
|
||||
if (BuildSettings.settingsScreenShowLabSettings)
|
||||
{
|
||||
Section *sectionLabs = [Section sectionWithTag:SECTION_TAG_LABS];
|
||||
if ([CryptoSDKFeature.shared canManuallyEnableForUserId:self.mainSession.myUserId])
|
||||
{
|
||||
[sectionLabs addRowWithTag:LABS_ENABLE_CRYPTO_SDK];
|
||||
}
|
||||
|
||||
[sectionLabs addRowWithTag:LABS_ENABLE_RINGING_FOR_GROUP_CALLS_INDEX];
|
||||
[sectionLabs addRowWithTag:LABS_ENABLE_THREADS_INDEX];
|
||||
[sectionLabs addRowWithTag:LABS_ENABLE_AUTO_REPORT_DECRYPTION_ERRORS];
|
||||
@@ -2587,18 +2581,6 @@ ChangePasswordCoordinatorBridgePresenterDelegate>
|
||||
|
||||
[labelAndSwitchCell.mxkSwitch addTarget:self action:@selector(toggleEnableVoiceBroadcastFeature:) forControlEvents:UIControlEventTouchUpInside];
|
||||
|
||||
cell = labelAndSwitchCell;
|
||||
}
|
||||
else if (row == LABS_ENABLE_CRYPTO_SDK)
|
||||
{
|
||||
MXKTableViewCellWithLabelAndSwitch *labelAndSwitchCell = [self getLabelAndSwitchCell:tableView forIndexPath:indexPath];
|
||||
BOOL isEnabled = MXSDKOptions.sharedInstance.enableCryptoSDK;
|
||||
labelAndSwitchCell.mxkLabel.text = isEnabled ? VectorL10n.settingsLabsDisableCryptoSdk : VectorL10n.settingsLabsEnableCryptoSdk;
|
||||
labelAndSwitchCell.mxkSwitch.on = isEnabled;
|
||||
[labelAndSwitchCell.mxkSwitch setEnabled:!isEnabled];
|
||||
labelAndSwitchCell.mxkSwitch.onTintColor = ThemeService.shared.theme.tintColor;
|
||||
[labelAndSwitchCell.mxkSwitch addTarget:self action:@selector(enableCryptoSDKFeature:) forControlEvents:UIControlEventTouchUpInside];
|
||||
|
||||
cell = labelAndSwitchCell;
|
||||
}
|
||||
}
|
||||
@@ -3372,30 +3354,6 @@ ChangePasswordCoordinatorBridgePresenterDelegate>
|
||||
RiotSettings.shared.enableVoiceBroadcast = sender.isOn;
|
||||
}
|
||||
|
||||
- (void)enableCryptoSDKFeature:(UISwitch *)sender
|
||||
{
|
||||
[currentAlert dismissViewControllerAnimated:NO completion:nil];
|
||||
UIAlertController *confirmationAlert = [UIAlertController alertControllerWithTitle:VectorL10n.settingsLabsEnableCryptoSdk
|
||||
message:VectorL10n.settingsLabsConfirmCryptoSdk
|
||||
preferredStyle:UIAlertControllerStyleAlert];
|
||||
|
||||
MXWeakify(self);
|
||||
[confirmationAlert addAction:[UIAlertAction actionWithTitle:[VectorL10n cancel] style:UIAlertActionStyleCancel handler:^(UIAlertAction * action) {
|
||||
MXStrongifyAndReturnIfNil(self);
|
||||
self->currentAlert = nil;
|
||||
|
||||
[sender setOn:NO animated:YES];
|
||||
}]];
|
||||
|
||||
[confirmationAlert addAction:[UIAlertAction actionWithTitle:[VectorL10n continue] style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
|
||||
[CryptoSDKFeature.shared enable];
|
||||
[[AppDelegate theDelegate] reloadMatrixSessions:YES];
|
||||
}]];
|
||||
|
||||
[self presentViewController:confirmationAlert animated:YES completion:nil];
|
||||
currentAlert = confirmationAlert;
|
||||
}
|
||||
|
||||
- (void)togglePinRoomsWithMissedNotif:(UISwitch *)sender
|
||||
{
|
||||
RiotSettings.shared.pinRoomsWithMissedNotificationsOnHome = sender.isOn;
|
||||
|
||||
@@ -273,22 +273,12 @@
|
||||
- (IBAction)onDone:(id)sender
|
||||
{
|
||||
// Acknowledge the existence of all devices before leaving this screen
|
||||
[self startActivityIndicator];
|
||||
if (![self.mainSession.crypto isKindOfClass:[MXLegacyCrypto class]])
|
||||
[self dismissViewControllerAnimated:YES completion:nil];
|
||||
|
||||
if (self->onCompleteBlock)
|
||||
{
|
||||
MXLogFailure(@"[UsersDevicesViewController] onDone: Only legacy crypto supports manual setting of known devices");
|
||||
return;
|
||||
self->onCompleteBlock(YES);
|
||||
}
|
||||
[(MXLegacyCrypto *)mxSession.crypto setDevicesKnown:usersDevices complete:^{
|
||||
|
||||
[self stopActivityIndicator];
|
||||
[self dismissViewControllerAnimated:YES completion:nil];
|
||||
|
||||
if (self->onCompleteBlock)
|
||||
{
|
||||
self->onCompleteBlock(YES);
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
- (IBAction)onCancel:(id)sender
|
||||
|
||||
@@ -41,7 +41,6 @@ class NotificationService: UNNotificationServiceExtension {
|
||||
private var ongoingVoIPPushRequests: [String: Bool] = [:]
|
||||
|
||||
private var userAccount: MXKAccount?
|
||||
private var isCryptoSDKEnabled = false
|
||||
|
||||
/// Best attempt contents. Will be updated incrementally, if something fails during the process, this best attempt content will be showed as notification. Keys are eventId's
|
||||
private var bestAttemptContents: [String: UNMutableNotificationContent] = [:]
|
||||
@@ -196,13 +195,12 @@ class NotificationService: UNNotificationServiceExtension {
|
||||
self.userAccount = MXKAccountManager.shared()?.activeAccounts.first
|
||||
if let userAccount = userAccount {
|
||||
Self.backgroundServiceInitQueue.sync {
|
||||
if hasChangedCryptoSDK() || NotificationService.backgroundSyncService?.credentials != userAccount.mxCredentials {
|
||||
if NotificationService.backgroundSyncService?.credentials != userAccount.mxCredentials {
|
||||
MXLog.debug("[NotificationService] setup: MXBackgroundSyncService init: BEFORE")
|
||||
self.logMemory()
|
||||
|
||||
NotificationService.backgroundSyncService = MXBackgroundSyncService(
|
||||
withCredentials: userAccount.mxCredentials,
|
||||
isCryptoSDKEnabled: isCryptoSDKEnabled,
|
||||
persistTokenDataHandler: { persistTokenDataHandler in
|
||||
MXKAccountManager.shared().readAndWriteCredentials(persistTokenDataHandler)
|
||||
}, unauthenticatedHandler: { error, softLogout, refreshTokenAuth, completion in
|
||||
@@ -219,16 +217,6 @@ class NotificationService: UNNotificationServiceExtension {
|
||||
}
|
||||
}
|
||||
|
||||
/// Determine whether we have switched from using crypto v1 to v2 or vice versa which will require
|
||||
/// rebuilding `MXBackgroundSyncService`
|
||||
private func hasChangedCryptoSDK() -> Bool {
|
||||
guard isCryptoSDKEnabled != MXSDKOptions.sharedInstance().enableCryptoSDK else {
|
||||
return false
|
||||
}
|
||||
isCryptoSDKEnabled = MXSDKOptions.sharedInstance().enableCryptoSDK
|
||||
return true
|
||||
}
|
||||
|
||||
/// Attempts to preprocess payload and attach room display name to the best attempt content
|
||||
/// - Parameters:
|
||||
/// - eventId: Event identifier to mutate best attempt content
|
||||
|
||||
@@ -102,11 +102,6 @@ static MXSession *fakeSession;
|
||||
[session setStore:self.fileStore success:^{
|
||||
MXStrongifyAndReturnIfNil(session);
|
||||
|
||||
if ([session.crypto isKindOfClass:[MXLegacyCrypto class]])
|
||||
{
|
||||
((MXLegacyCrypto *)session.crypto).warnOnUnknowDevices = NO; // Do not warn for unknown devices. We have cross-signing now
|
||||
}
|
||||
|
||||
self.selectedRooms = [NSMutableArray array];
|
||||
for (NSString *roomIdentifier in roomIdentifiers) {
|
||||
MXRoom *room = [MXRoom loadRoomFromStore:self.fileStore withRoomId:roomIdentifier matrixSession:session];
|
||||
|
||||
@@ -267,17 +267,6 @@ class QRLoginService: NSObject, QRLoginServiceProtocol {
|
||||
|
||||
let session = sessionCreator.createSession(credentials: credentials, client: client, removeOtherAccounts: false)
|
||||
|
||||
// MXLog.debug("[QRLoginService] Session created without E2EE support. Inform the interlocutor of finishing")
|
||||
// guard let requestData = try? JSONEncoder().encode(QRLoginRendezvousPayload(type: .loginFinish, outcome: .success)),
|
||||
// case .success = await rendezvousService.send(data: requestData) else {
|
||||
// await teardownRendezvous(state: .failed(error: .rendezvousFailed))
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// MXLog.debug("[QRLoginService] Login flow finished, returning session")
|
||||
// state = .completed(session: session, securityCompleted: false)
|
||||
// return
|
||||
|
||||
let cryptoResult = await withCheckedContinuation { continuation in
|
||||
session.enableCrypto(true) { response in
|
||||
continuation.resume(returning: response)
|
||||
|
||||
@@ -1,79 +0,0 @@
|
||||
//
|
||||
// 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
|
||||
import XCTest
|
||||
@testable import Element
|
||||
|
||||
class CryptoSDKFeatureTests: XCTestCase {
|
||||
class RemoteFeatureClient: RemoteFeaturesClientProtocol {
|
||||
var isEnabled = false
|
||||
func isFeatureEnabled(_ feature: String) -> Bool {
|
||||
isEnabled
|
||||
}
|
||||
}
|
||||
|
||||
var remote: RemoteFeatureClient!
|
||||
var feature: CryptoSDKFeature!
|
||||
|
||||
override func setUp() {
|
||||
RiotSettings.shared.enableCryptoSDK = false
|
||||
remote = RemoteFeatureClient()
|
||||
feature = CryptoSDKFeature(remoteFeature: remote, localTargetPercentage: 0)
|
||||
}
|
||||
|
||||
override func tearDown() {
|
||||
RiotSettings.shared.enableCryptoSDK = false
|
||||
}
|
||||
|
||||
func test_disabledByDefault() {
|
||||
XCTAssertFalse(feature.isEnabled)
|
||||
}
|
||||
|
||||
func test_enable() {
|
||||
feature.enable()
|
||||
XCTAssertTrue(feature.isEnabled)
|
||||
}
|
||||
|
||||
func test_enableIfAvailable_remainsEnabledWhenRemoteClientDisabled() {
|
||||
feature.enable()
|
||||
remote.isEnabled = false
|
||||
|
||||
feature.enableIfAvailable(forUserId: "alice")
|
||||
|
||||
XCTAssertTrue(feature.isEnabled)
|
||||
}
|
||||
|
||||
func test_enableIfAvailable_notEnabledIfRemoteFeatureDisabled() {
|
||||
remote.isEnabled = false
|
||||
feature.enableIfAvailable(forUserId: "alice")
|
||||
XCTAssertFalse(feature.isEnabled)
|
||||
}
|
||||
|
||||
func test_canManuallyEnable() {
|
||||
remote.isEnabled = false
|
||||
XCTAssertTrue(feature.canManuallyEnable(forUserId: "alice"))
|
||||
|
||||
remote.isEnabled = true
|
||||
XCTAssertFalse(feature.canManuallyEnable(forUserId: "alice"))
|
||||
}
|
||||
|
||||
func test_reset() {
|
||||
feature.enable()
|
||||
feature.reset()
|
||||
XCTAssertFalse(RiotSettings.shared.enableCryptoSDK)
|
||||
}
|
||||
}
|
||||
@@ -117,12 +117,6 @@
|
||||
|
||||
self.selectedRoom = [MXRoom loadRoomFromStore:fileStore withRoomId:roomID matrixSession:session];
|
||||
|
||||
// Do not warn for unknown devices. We have cross-signing now
|
||||
if ([session.crypto isKindOfClass:[MXLegacyCrypto class]])
|
||||
{
|
||||
((MXLegacyCrypto *)session.crypto).warnOnUnknowDevices = NO;
|
||||
}
|
||||
|
||||
MXWeakify(self);
|
||||
[self.selectedRoom sendTextMessage:intent.content
|
||||
threadId:nil
|
||||
|
||||
1
changelog.d/pr-7508.change
Normal file
1
changelog.d/pr-7508.change
Normal file
@@ -0,0 +1 @@
|
||||
Crypto: Deprecate MXLegacyCrypto
|
||||
Reference in New Issue
Block a user