Skip to content

Commit

Permalink
Display upgrade verification prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
Anderas committed Mar 27, 2023
1 parent 022d7e7 commit 6293386
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 3 deletions.
5 changes: 5 additions & 0 deletions Riot/Assets/en.lproj/Vector.strings
Original file line number Diff line number Diff line change
Expand Up @@ -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" = "Your end-to-end encryption algorithms have 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.";
Expand Down
20 changes: 19 additions & 1 deletion Riot/Experiments/CryptoSDKFeature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
}
}
8 changes: 8 additions & 0 deletions Riot/Generated/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
3 changes: 3 additions & 0 deletions Riot/Managers/Settings/RiotSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 12 additions & 2 deletions Riot/Modules/Home/AllChats/AllChatsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -985,8 +985,18 @@ 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 MXSDKOptions.sharedInstance().enableCryptoSDK && MXSDKOptions.sharedInstance().cryptoSDKFeature?.needsVerificationUpgrade == true {
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,
Expand Down

0 comments on commit 6293386

Please sign in to comment.