From 3618ad9153ed22add872ba742c6f14ebc44c2966 Mon Sep 17 00:00:00 2001 From: Andy Uhnak Date: Mon, 27 Mar 2023 13:25:35 +0100 Subject: [PATCH 1/2] Display upgrade verification prompt --- Riot/Assets/en.lproj/Vector.strings | 5 +++++ Riot/Experiments/CryptoSDKFeature.swift | 20 ++++++++++++++++++- Riot/Generated/Strings.swift | 8 ++++++++ Riot/Managers/Settings/RiotSettings.swift | 3 +++ .../AllChats/AllChatsViewController.swift | 18 +++++++++++++++-- changelog.d/pr-7454.change | 1 + 6 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 changelog.d/pr-7454.change diff --git a/Riot/Assets/en.lproj/Vector.strings b/Riot/Assets/en.lproj/Vector.strings index 8a9f712c3..9c929a9cf 100644 --- a/Riot/Assets/en.lproj/Vector.strings +++ b/Riot/Assets/en.lproj/Vector.strings @@ -1560,6 +1560,11 @@ Tap the + to start adding people."; "key_verification_self_verify_current_session_alert_message" = "Other users may not trust it."; "key_verification_self_verify_current_session_alert_validate_action" = "Verify"; +// Legacy to Rust security upgrade + +"key_verification_self_verify_security_upgrade_alert_title" = "Encryption upgraded"; +"key_verification_self_verify_security_upgrade_alert_message" = "The end-to-end encryption has been upgraded to be more secure. Please re-verify your account."; + // Unverified sessions "key_verification_alert_title" = "You have unverified sessions"; "key_verification_alert_body" = "Review to ensure your account is safe."; diff --git a/Riot/Experiments/CryptoSDKFeature.swift b/Riot/Experiments/CryptoSDKFeature.swift index 96c743951..8404675c2 100644 --- a/Riot/Experiments/CryptoSDKFeature.swift +++ b/Riot/Experiments/CryptoSDKFeature.swift @@ -40,7 +40,18 @@ import MatrixSDKCrypto 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 @@ -98,6 +109,13 @@ import MatrixSDKCrypto } private func isFeatureEnabled(userId: String) -> Bool { - remoteFeature.isFeatureEnabled(Self.FeatureName) || localFeature.isEnabled(userId: userId) + // 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) } } diff --git a/Riot/Generated/Strings.swift b/Riot/Generated/Strings.swift index b31ee8596..365fe90ef 100644 --- a/Riot/Generated/Strings.swift +++ b/Riot/Generated/Strings.swift @@ -3027,6 +3027,14 @@ public class VectorL10n: NSObject { public static var keyVerificationSelfVerifyCurrentSessionAlertValidateAction: String { return VectorL10n.tr("Vector", "key_verification_self_verify_current_session_alert_validate_action") } + /// Your end-to-end encryption algorithms have been upgraded to be more secure. Please re-verify your account. + public static var keyVerificationSelfVerifySecurityUpgradeAlertMessage: String { + return VectorL10n.tr("Vector", "key_verification_self_verify_security_upgrade_alert_message") + } + /// Encryption upgraded + public static var keyVerificationSelfVerifySecurityUpgradeAlertTitle: String { + return VectorL10n.tr("Vector", "key_verification_self_verify_security_upgrade_alert_title") + } /// Review public static var keyVerificationSelfVerifyUnverifiedSessionsAlertValidateAction: String { return VectorL10n.tr("Vector", "key_verification_self_verify_unverified_sessions_alert_validate_action") diff --git a/Riot/Managers/Settings/RiotSettings.swift b/Riot/Managers/Settings/RiotSettings.swift index efb9a8e1c..06746801c 100644 --- a/Riot/Managers/Settings/RiotSettings.swift +++ b/Riot/Managers/Settings/RiotSettings.swift @@ -211,6 +211,9 @@ final class RiotSettings: NSObject { @UserDefault(key: "hideVerifyThisSessionAlert", defaultValue: false, storage: defaults) var hideVerifyThisSessionAlert + @UserDefault(key: "showVerificationUpgradeAlert", defaultValue: false, storage: defaults) + var showVerificationUpgradeAlert + @UserDefault(key: "matrixApps", defaultValue: false, storage: defaults) var matrixApps diff --git a/Riot/Modules/Home/AllChats/AllChatsViewController.swift b/Riot/Modules/Home/AllChats/AllChatsViewController.swift index 1c72df342..3c5d194d3 100644 --- a/Riot/Modules/Home/AllChats/AllChatsViewController.swift +++ b/Riot/Modules/Home/AllChats/AllChatsViewController.swift @@ -985,8 +985,22 @@ extension AllChatsViewController: SplitViewMasterViewControllerProtocol { private func presentVerifyCurrentSessionAlert(with session: MXSession) { MXLog.debug("[AllChatsViewController] presentVerifyCurrentSessionAlertWithSession") - let alert = UIAlertController(title: VectorL10n.keyVerificationSelfVerifyCurrentSessionAlertTitle, - message: VectorL10n.keyVerificationSelfVerifyCurrentSessionAlertMessage, + let title: String + let message: String + + if + let feature = MXSDKOptions.sharedInstance().cryptoSDKFeature, + feature.isEnabled && feature.needsVerificationUpgrade + { + title = VectorL10n.keyVerificationSelfVerifySecurityUpgradeAlertTitle + message = VectorL10n.keyVerificationSelfVerifySecurityUpgradeAlertMessage + } else { + title = VectorL10n.keyVerificationSelfVerifyCurrentSessionAlertTitle + message = VectorL10n.keyVerificationSelfVerifyCurrentSessionAlertMessage + } + + let alert = UIAlertController(title: title, + message: message, preferredStyle: .alert) alert.addAction(UIAlertAction(title: VectorL10n.keyVerificationSelfVerifyCurrentSessionAlertValidateAction, diff --git a/changelog.d/pr-7454.change b/changelog.d/pr-7454.change new file mode 100644 index 000000000..de71f8f8d --- /dev/null +++ b/changelog.d/pr-7454.change @@ -0,0 +1 @@ +Verification: Display upgrade verification prompt From be14fc3e0dae84853e461576d54b732054d03fd1 Mon Sep 17 00:00:00 2001 From: Andy Uhnak Date: Tue, 28 Mar 2023 14:24:54 +0100 Subject: [PATCH 2/2] Update copy --- Riot/Assets/en.lproj/Vector.strings | 4 ++-- Riot/Generated/Strings.swift | 4 ++-- Riot/Modules/Home/AllChats/AllChatsViewController.swift | 6 ++---- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Riot/Assets/en.lproj/Vector.strings b/Riot/Assets/en.lproj/Vector.strings index 9c929a9cf..5b98db946 100644 --- a/Riot/Assets/en.lproj/Vector.strings +++ b/Riot/Assets/en.lproj/Vector.strings @@ -1562,8 +1562,8 @@ Tap the + to start adding people."; // Legacy to Rust security upgrade -"key_verification_self_verify_security_upgrade_alert_title" = "Encryption upgraded"; -"key_verification_self_verify_security_upgrade_alert_message" = "The end-to-end encryption has been upgraded to be more secure. Please re-verify your account."; +"key_verification_self_verify_security_upgrade_alert_title" = "App updated"; +"key_verification_self_verify_security_upgrade_alert_message" = "Secure messaging has been improved with the latest update. Please re-verify your device."; // Unverified sessions "key_verification_alert_title" = "You have unverified sessions"; diff --git a/Riot/Generated/Strings.swift b/Riot/Generated/Strings.swift index 365fe90ef..3cde53fe9 100644 --- a/Riot/Generated/Strings.swift +++ b/Riot/Generated/Strings.swift @@ -3027,11 +3027,11 @@ public class VectorL10n: NSObject { public static var keyVerificationSelfVerifyCurrentSessionAlertValidateAction: String { return VectorL10n.tr("Vector", "key_verification_self_verify_current_session_alert_validate_action") } - /// Your end-to-end encryption algorithms have been upgraded to be more secure. Please re-verify your account. + /// Secure messaging has been improved with the latest update. Please re-verify your device. public static var keyVerificationSelfVerifySecurityUpgradeAlertMessage: String { return VectorL10n.tr("Vector", "key_verification_self_verify_security_upgrade_alert_message") } - /// Encryption upgraded + /// App updated public static var keyVerificationSelfVerifySecurityUpgradeAlertTitle: String { return VectorL10n.tr("Vector", "key_verification_self_verify_security_upgrade_alert_title") } diff --git a/Riot/Modules/Home/AllChats/AllChatsViewController.swift b/Riot/Modules/Home/AllChats/AllChatsViewController.swift index 3c5d194d3..ea96873ba 100644 --- a/Riot/Modules/Home/AllChats/AllChatsViewController.swift +++ b/Riot/Modules/Home/AllChats/AllChatsViewController.swift @@ -988,10 +988,8 @@ extension AllChatsViewController: SplitViewMasterViewControllerProtocol { let title: String let message: String - if - let feature = MXSDKOptions.sharedInstance().cryptoSDKFeature, - feature.isEnabled && feature.needsVerificationUpgrade - { + if let feature = MXSDKOptions.sharedInstance().cryptoSDKFeature, + feature.isEnabled && feature.needsVerificationUpgrade { title = VectorL10n.keyVerificationSelfVerifySecurityUpgradeAlertTitle message = VectorL10n.keyVerificationSelfVerifySecurityUpgradeAlertMessage } else {