Skip to content
This repository was archived by the owner on Oct 22, 2024. It is now read-only.

Commit 63986f8

Browse files
authored
Remove feature_dehydration (#138)
* Remove feature_dehydration * Remove remaining old dehydration * Update test
1 parent 91e84f7 commit 63986f8

File tree

6 files changed

+3
-76
lines changed

6 files changed

+3
-76
lines changed

playwright/e2e/login/soft_logout.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ test.describe("Soft logout", () => {
3232

3333
// back to the welcome page
3434
await expect(page).toHaveURL(/\/#\/home/);
35-
await expect(page.getByRole("heading", { name: "Welcome Alice", exact: true })).toBeVisible();
35+
await expect(page.getByRole("heading", { name: `Welcome ${user.userId}`, exact: true })).toBeVisible();
3636
});
3737

3838
test("still shows the soft-logout page when the page is reloaded after a soft-logout", async ({

src/Lifecycle.ts

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -664,43 +664,6 @@ export async function setLoggedIn(credentials: IMatrixClientCreds): Promise<Matr
664664
return doSetLoggedIn(Object.assign({}, credentials, { pickleKey }), true, true);
665665
}
666666

667-
/**
668-
* Hydrates an existing session by using the credentials provided. This will
669-
* not clear any local storage, unlike setLoggedIn().
670-
*
671-
* Stops the existing Matrix client (without clearing its data) and starts a
672-
* new one in its place. This additionally starts all other react-sdk services
673-
* which use the new Matrix client.
674-
*
675-
* If the credentials belong to a different user from the session already stored,
676-
* the old session will be cleared automatically.
677-
*
678-
* @param {IMatrixClientCreds} credentials The credentials to use
679-
*
680-
* @returns {Promise} promise which resolves to the new MatrixClient once it has been started
681-
*/
682-
export async function hydrateSession(credentials: IMatrixClientCreds): Promise<MatrixClient> {
683-
const oldUserId = MatrixClientPeg.safeGet().getUserId();
684-
const oldDeviceId = MatrixClientPeg.safeGet().getDeviceId();
685-
686-
stopMatrixClient(); // unsets MatrixClientPeg.get()
687-
localStorage.removeItem("mx_soft_logout");
688-
_isLoggingOut = false;
689-
690-
const overwrite = credentials.userId !== oldUserId || credentials.deviceId !== oldDeviceId;
691-
if (overwrite) {
692-
logger.warn("Clearing all data: Old session belongs to a different user/session");
693-
}
694-
695-
if (!credentials.pickleKey && credentials.deviceId !== undefined) {
696-
logger.info("Lifecycle#hydrateSession: Pickle key not provided - trying to get one");
697-
credentials.pickleKey =
698-
(await PlatformPeg.get()?.getPickleKey(credentials.userId, credentials.deviceId)) ?? undefined;
699-
}
700-
701-
return doSetLoggedIn(credentials, overwrite, false);
702-
}
703-
704667
/**
705668
* When we have a authenticated via OIDC-native flow and have a refresh token
706669
* try to create a token refresher.
@@ -799,18 +762,6 @@ async function doSetLoggedIn(
799762
PosthogAnalytics.instance.startListeningToSettingsChanges(client);
800763
}
801764

802-
if (credentials.freshLogin && SettingsStore.getValue("feature_dehydration")) {
803-
// If we just logged in, try to rehydrate a device instead of using a
804-
// new device. If it succeeds, we'll get a new device ID, so make sure
805-
// we persist that ID to localStorage
806-
const newDeviceId = await client.rehydrateDevice();
807-
if (newDeviceId) {
808-
credentials.deviceId = newDeviceId;
809-
}
810-
811-
delete credentials.freshLogin;
812-
}
813-
814765
if (localStorage) {
815766
try {
816767
await persistCredentials(credentials);

src/SecurityManager.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import { MatrixClientPeg } from "./MatrixClientPeg";
1616
import { _t } from "./languageHandler";
1717
import { isSecureBackupRequired } from "./utils/WellKnownUtils";
1818
import AccessSecretStorageDialog, { KeyParams } from "./components/views/dialogs/security/AccessSecretStorageDialog";
19-
import SettingsStore from "./settings/SettingsStore";
2019
import { ModuleRunner } from "./modules/ModuleRunner";
2120
import QuestionDialog from "./components/views/dialogs/QuestionDialog";
2221
import InteractiveAuthDialog from "./components/views/dialogs/InteractiveAuthDialog";
@@ -276,20 +275,6 @@ async function doAccessSecretStorage(func: () => Promise<void>, forceReset: bool
276275
});
277276
logger.debug("accessSecretStorage: bootstrapSecretStorage");
278277
await crypto.bootstrapSecretStorage({});
279-
280-
const keyId = Object.keys(secretStorageKeys)[0];
281-
if (keyId && SettingsStore.getValue("feature_dehydration")) {
282-
let dehydrationKeyInfo = {};
283-
if (secretStorageKeyInfo[keyId] && secretStorageKeyInfo[keyId].passphrase) {
284-
dehydrationKeyInfo = { passphrase: secretStorageKeyInfo[keyId].passphrase };
285-
}
286-
logger.log("accessSecretStorage: Setting dehydration key");
287-
await cli.setDehydrationKey(secretStorageKeys[keyId], dehydrationKeyInfo, "Backup device");
288-
} else if (!keyId) {
289-
logger.warn("accessSecretStorage: Not setting dehydration key: no SSSS key found");
290-
} else {
291-
logger.log("accessSecretStorage: Not setting dehydration key: feature disabled");
292-
}
293278
}
294279

295280
logger.debug("accessSecretStorage: 4S now ready");

src/components/structures/auth/SoftLogout.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ export default class SoftLogout extends React.Component<IProps, IState> {
168168
return;
169169
}
170170

171-
Lifecycle.hydrateSession(credentials).catch((e) => {
171+
Lifecycle.setLoggedIn(credentials).catch((e) => {
172172
logger.error(e);
173173
this.setState({ busy: false, errorText: _t("auth|failed_soft_logout_auth") });
174174
});
@@ -204,7 +204,7 @@ export default class SoftLogout extends React.Component<IProps, IState> {
204204
return false;
205205
}
206206

207-
return Lifecycle.hydrateSession(credentials)
207+
return Lifecycle.setLoggedIn(credentials)
208208
.then(() => {
209209
if (this.props.onTokenLoginCompleted) {
210210
this.props.onTokenLoginCompleted();

src/i18n/strings/en_EN.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1410,7 +1410,6 @@
14101410
"click_for_info": "Click for more info",
14111411
"currently_experimental": "Currently experimental.",
14121412
"custom_themes": "Support adding custom themes",
1413-
"dehydration": "Offline encrypted messaging using dehydrated devices",
14141413
"dynamic_room_predecessors": "Dynamic room predecessors",
14151414
"dynamic_room_predecessors_description": "Enable MSC3946 (to support late-arriving room archives)",
14161415
"element_call_video_rooms": "Element Call video rooms",

src/settings/Settings.tsx

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -303,14 +303,6 @@ export const SETTINGS: { [setting: string]: ISetting } = {
303303
supportedLevelsAreOrdered: true,
304304
default: false,
305305
},
306-
"feature_dehydration": {
307-
isFeature: true,
308-
labsGroup: LabGroup.Encryption,
309-
displayName: _td("labs|dehydration"),
310-
supportedLevels: LEVELS_DEVICE_ONLY_SETTINGS_WITH_CONFIG_PRIORITISED,
311-
supportedLevelsAreOrdered: true,
312-
default: false,
313-
},
314306
"feature_exclude_insecure_devices": {
315307
isFeature: true,
316308
labsGroup: LabGroup.Encryption,

0 commit comments

Comments
 (0)