Remove upgrade encryption in `DeviceListener` and `SetupEncryptionToast` (#28299)

* Remove upgrade encryption in `DeviceListener` and `SetupEncryptionToast`

* Update comments to `2 different toasts`
pull/28319/head
Florian Duros 2024-10-29 13:28:41 +01:00 committed by GitHub
parent 79c956388f
commit e5b55db1db
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 11 additions and 25 deletions

View File

@ -292,27 +292,21 @@ export default class DeviceListener {
await crypto.getUserDeviceInfo([cli.getSafeUserId()]);
// cross signing isn't enabled - nag to enable it
// There are 3 different toasts for:
// There are 2 different toasts for:
if (!(await crypto.getCrossSigningKeyId()) && (await crypto.userHasCrossSigningKeys())) {
// Cross-signing on account but this device doesn't trust the master key (verify this session)
showSetupEncryptionToast(SetupKind.VERIFY_THIS_SESSION);
this.checkKeyBackupStatus();
} else {
const backupInfo = await this.getKeyBackupInfo();
if (backupInfo) {
// No cross-signing on account but key backup available (upgrade encryption)
showSetupEncryptionToast(SetupKind.UPGRADE_ENCRYPTION);
// No cross-signing or key backup on account (set up encryption)
await cli.waitForClientWellKnown();
if (isSecureBackupRequired(cli) && isLoggedIn()) {
// If we're meant to set up, and Secure Backup is required,
// trigger the flow directly without a toast once logged in.
hideSetupEncryptionToast();
accessSecretStorage();
} else {
// No cross-signing or key backup on account (set up encryption)
await cli.waitForClientWellKnown();
if (isSecureBackupRequired(cli) && isLoggedIn()) {
// If we're meant to set up, and Secure Backup is required,
// trigger the flow directly without a toast once logged in.
hideSetupEncryptionToast();
accessSecretStorage();
} else {
showSetupEncryptionToast(SetupKind.SET_UP_ENCRYPTION);
}
showSetupEncryptionToast(SetupKind.SET_UP_ENCRYPTION);
}
}
}

View File

@ -930,7 +930,6 @@
},
"unable_to_setup_keys_error": "Unable to set up keys",
"unsupported": "This client does not support end-to-end encryption.",
"upgrade_toast_title": "Encryption upgrade available",
"verification": {
"accepting": "Accepting…",
"after_new_login": {

View File

@ -23,8 +23,6 @@ const getTitle = (kind: Kind): string => {
switch (kind) {
case Kind.SET_UP_ENCRYPTION:
return _t("encryption|set_up_toast_title");
case Kind.UPGRADE_ENCRYPTION:
return _t("encryption|upgrade_toast_title");
case Kind.VERIFY_THIS_SESSION:
return _t("encryption|verify_toast_title");
}
@ -33,7 +31,6 @@ const getTitle = (kind: Kind): string => {
const getIcon = (kind: Kind): string => {
switch (kind) {
case Kind.SET_UP_ENCRYPTION:
case Kind.UPGRADE_ENCRYPTION:
return "secure_backup";
case Kind.VERIFY_THIS_SESSION:
return "verification_warning";
@ -44,8 +41,6 @@ const getSetupCaption = (kind: Kind): string => {
switch (kind) {
case Kind.SET_UP_ENCRYPTION:
return _t("action|continue");
case Kind.UPGRADE_ENCRYPTION:
return _t("action|upgrade");
case Kind.VERIFY_THIS_SESSION:
return _t("action|verify");
}
@ -54,7 +49,6 @@ const getSetupCaption = (kind: Kind): string => {
const getDescription = (kind: Kind): string => {
switch (kind) {
case Kind.SET_UP_ENCRYPTION:
case Kind.UPGRADE_ENCRYPTION:
return _t("encryption|set_up_toast_description");
case Kind.VERIFY_THIS_SESSION:
return _t("encryption|verify_toast_description");
@ -63,7 +57,6 @@ const getDescription = (kind: Kind): string => {
export enum Kind {
SET_UP_ENCRYPTION = "set_up_encryption",
UPGRADE_ENCRYPTION = "upgrade_encryption",
VERIFY_THIS_SESSION = "verify_this_session",
}

View File

@ -351,13 +351,13 @@ describe("DeviceListener", () => {
mockCrypto!.getCrossSigningKeyId.mockResolvedValue("abc");
});
it("shows upgrade encryption toast when user has a key backup available", async () => {
it("shows set up encryption toast when user has a key backup available", async () => {
// non falsy response
mockClient!.getKeyBackupVersion.mockResolvedValue({} as unknown as KeyBackupInfo);
await createAndStart();
expect(SetupEncryptionToast.showToast).toHaveBeenCalledWith(
SetupEncryptionToast.Kind.UPGRADE_ENCRYPTION,
SetupEncryptionToast.Kind.SET_UP_ENCRYPTION,
);
});
});