From 63986f8c425c59a06b8c650cb977bc9632b3c215 Mon Sep 17 00:00:00 2001 From: Florian Duros Date: Mon, 14 Oct 2024 18:10:41 +0200 Subject: [PATCH] Remove feature_dehydration (#138) * Remove feature_dehydration * Remove remaining old dehydration * Update test --- playwright/e2e/login/soft_logout.spec.ts | 2 +- src/Lifecycle.ts | 49 ------------------- src/SecurityManager.ts | 15 ------ src/components/structures/auth/SoftLogout.tsx | 4 +- src/i18n/strings/en_EN.json | 1 - src/settings/Settings.tsx | 8 --- 6 files changed, 3 insertions(+), 76 deletions(-) diff --git a/playwright/e2e/login/soft_logout.spec.ts b/playwright/e2e/login/soft_logout.spec.ts index 140875b9b1..ca0c11132a 100644 --- a/playwright/e2e/login/soft_logout.spec.ts +++ b/playwright/e2e/login/soft_logout.spec.ts @@ -32,7 +32,7 @@ test.describe("Soft logout", () => { // back to the welcome page await expect(page).toHaveURL(/\/#\/home/); - await expect(page.getByRole("heading", { name: "Welcome Alice", exact: true })).toBeVisible(); + await expect(page.getByRole("heading", { name: `Welcome ${user.userId}`, exact: true })).toBeVisible(); }); test("still shows the soft-logout page when the page is reloaded after a soft-logout", async ({ diff --git a/src/Lifecycle.ts b/src/Lifecycle.ts index 682d11aba5..39d93dec11 100644 --- a/src/Lifecycle.ts +++ b/src/Lifecycle.ts @@ -664,43 +664,6 @@ export async function setLoggedIn(credentials: IMatrixClientCreds): Promise { - const oldUserId = MatrixClientPeg.safeGet().getUserId(); - const oldDeviceId = MatrixClientPeg.safeGet().getDeviceId(); - - stopMatrixClient(); // unsets MatrixClientPeg.get() - localStorage.removeItem("mx_soft_logout"); - _isLoggingOut = false; - - const overwrite = credentials.userId !== oldUserId || credentials.deviceId !== oldDeviceId; - if (overwrite) { - logger.warn("Clearing all data: Old session belongs to a different user/session"); - } - - if (!credentials.pickleKey && credentials.deviceId !== undefined) { - logger.info("Lifecycle#hydrateSession: Pickle key not provided - trying to get one"); - credentials.pickleKey = - (await PlatformPeg.get()?.getPickleKey(credentials.userId, credentials.deviceId)) ?? undefined; - } - - return doSetLoggedIn(credentials, overwrite, false); -} - /** * When we have a authenticated via OIDC-native flow and have a refresh token * try to create a token refresher. @@ -799,18 +762,6 @@ async function doSetLoggedIn( PosthogAnalytics.instance.startListeningToSettingsChanges(client); } - if (credentials.freshLogin && SettingsStore.getValue("feature_dehydration")) { - // If we just logged in, try to rehydrate a device instead of using a - // new device. If it succeeds, we'll get a new device ID, so make sure - // we persist that ID to localStorage - const newDeviceId = await client.rehydrateDevice(); - if (newDeviceId) { - credentials.deviceId = newDeviceId; - } - - delete credentials.freshLogin; - } - if (localStorage) { try { await persistCredentials(credentials); diff --git a/src/SecurityManager.ts b/src/SecurityManager.ts index a89427e5f3..2d103cf25e 100644 --- a/src/SecurityManager.ts +++ b/src/SecurityManager.ts @@ -16,7 +16,6 @@ import { MatrixClientPeg } from "./MatrixClientPeg"; import { _t } from "./languageHandler"; import { isSecureBackupRequired } from "./utils/WellKnownUtils"; import AccessSecretStorageDialog, { KeyParams } from "./components/views/dialogs/security/AccessSecretStorageDialog"; -import SettingsStore from "./settings/SettingsStore"; import { ModuleRunner } from "./modules/ModuleRunner"; import QuestionDialog from "./components/views/dialogs/QuestionDialog"; import InteractiveAuthDialog from "./components/views/dialogs/InteractiveAuthDialog"; @@ -276,20 +275,6 @@ async function doAccessSecretStorage(func: () => Promise, forceReset: bool }); logger.debug("accessSecretStorage: bootstrapSecretStorage"); await crypto.bootstrapSecretStorage({}); - - const keyId = Object.keys(secretStorageKeys)[0]; - if (keyId && SettingsStore.getValue("feature_dehydration")) { - let dehydrationKeyInfo = {}; - if (secretStorageKeyInfo[keyId] && secretStorageKeyInfo[keyId].passphrase) { - dehydrationKeyInfo = { passphrase: secretStorageKeyInfo[keyId].passphrase }; - } - logger.log("accessSecretStorage: Setting dehydration key"); - await cli.setDehydrationKey(secretStorageKeys[keyId], dehydrationKeyInfo, "Backup device"); - } else if (!keyId) { - logger.warn("accessSecretStorage: Not setting dehydration key: no SSSS key found"); - } else { - logger.log("accessSecretStorage: Not setting dehydration key: feature disabled"); - } } logger.debug("accessSecretStorage: 4S now ready"); diff --git a/src/components/structures/auth/SoftLogout.tsx b/src/components/structures/auth/SoftLogout.tsx index 4c02f818a7..117485df7e 100644 --- a/src/components/structures/auth/SoftLogout.tsx +++ b/src/components/structures/auth/SoftLogout.tsx @@ -168,7 +168,7 @@ export default class SoftLogout extends React.Component { return; } - Lifecycle.hydrateSession(credentials).catch((e) => { + Lifecycle.setLoggedIn(credentials).catch((e) => { logger.error(e); this.setState({ busy: false, errorText: _t("auth|failed_soft_logout_auth") }); }); @@ -204,7 +204,7 @@ export default class SoftLogout extends React.Component { return false; } - return Lifecycle.hydrateSession(credentials) + return Lifecycle.setLoggedIn(credentials) .then(() => { if (this.props.onTokenLoginCompleted) { this.props.onTokenLoginCompleted(); diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 74265c1939..4e2a0c01d5 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -1410,7 +1410,6 @@ "click_for_info": "Click for more info", "currently_experimental": "Currently experimental.", "custom_themes": "Support adding custom themes", - "dehydration": "Offline encrypted messaging using dehydrated devices", "dynamic_room_predecessors": "Dynamic room predecessors", "dynamic_room_predecessors_description": "Enable MSC3946 (to support late-arriving room archives)", "element_call_video_rooms": "Element Call video rooms", diff --git a/src/settings/Settings.tsx b/src/settings/Settings.tsx index 834a735d8d..4f788ee224 100644 --- a/src/settings/Settings.tsx +++ b/src/settings/Settings.tsx @@ -303,14 +303,6 @@ export const SETTINGS: { [setting: string]: ISetting } = { supportedLevelsAreOrdered: true, default: false, }, - "feature_dehydration": { - isFeature: true, - labsGroup: LabGroup.Encryption, - displayName: _td("labs|dehydration"), - supportedLevels: LEVELS_DEVICE_ONLY_SETTINGS_WITH_CONFIG_PRIORITISED, - supportedLevelsAreOrdered: true, - default: false, - }, "feature_exclude_insecure_devices": { isFeature: true, labsGroup: LabGroup.Encryption,