Skip to content

Commit

Permalink
Remove upgrade encryption in DeviceListener and SetupEncryptionToast
Browse files Browse the repository at this point in the history
  • Loading branch information
florianduros committed Oct 25, 2024
1 parent 7de5c84 commit 11173ab
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 25 deletions.
22 changes: 8 additions & 14 deletions src/DeviceListener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,21 +298,15 @@ export default class DeviceListener {
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);
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/i18n/strings/en_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -913,8 +913,8 @@
"warning": "If you didn't remove the recovery method, an attacker may be trying to access your account. Change your account password and set a new recovery method immediately in Settings."
},
"reset_all_button": "Forgotten or lost all recovery methods? <a>Reset all</a>",
"set_up_toast_description": "Safeguard against losing access to encrypted messages & data",
"set_up_toast_title": "Set up Secure Backup",
"set_up_toast_description": "Safeguard against losing access to encrypted messages & data",
"setup_secure_backup": {
"explainer": "Back up your keys before signing out to avoid losing them.",
"title": "Set up"
Expand All @@ -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": {
Expand Down
7 changes: 0 additions & 7 deletions src/toasts/SetupEncryptionToast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand All @@ -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";
Expand All @@ -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");
}
Expand All @@ -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");
Expand All @@ -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",
}

Expand Down
4 changes: 2 additions & 2 deletions test/unit-tests/DeviceListener-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
});
});
Expand Down

0 comments on commit 11173ab

Please sign in to comment.