mirror of
https://github.com/element-hq/element-web
synced 2024-11-28 12:28:50 +03:00
Remove feature_dehydration (#138)
* Remove feature_dehydration * Remove remaining old dehydration * Update test
This commit is contained in:
parent
91e84f7951
commit
63986f8c42
6 changed files with 3 additions and 76 deletions
|
@ -32,7 +32,7 @@ test.describe("Soft logout", () => {
|
||||||
|
|
||||||
// back to the welcome page
|
// back to the welcome page
|
||||||
await expect(page).toHaveURL(/\/#\/home/);
|
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 ({
|
test("still shows the soft-logout page when the page is reloaded after a soft-logout", async ({
|
||||||
|
|
|
@ -664,43 +664,6 @@ export async function setLoggedIn(credentials: IMatrixClientCreds): Promise<Matr
|
||||||
return doSetLoggedIn(Object.assign({}, credentials, { pickleKey }), true, true);
|
return doSetLoggedIn(Object.assign({}, credentials, { pickleKey }), true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Hydrates an existing session by using the credentials provided. This will
|
|
||||||
* not clear any local storage, unlike setLoggedIn().
|
|
||||||
*
|
|
||||||
* Stops the existing Matrix client (without clearing its data) and starts a
|
|
||||||
* new one in its place. This additionally starts all other react-sdk services
|
|
||||||
* which use the new Matrix client.
|
|
||||||
*
|
|
||||||
* If the credentials belong to a different user from the session already stored,
|
|
||||||
* the old session will be cleared automatically.
|
|
||||||
*
|
|
||||||
* @param {IMatrixClientCreds} credentials The credentials to use
|
|
||||||
*
|
|
||||||
* @returns {Promise} promise which resolves to the new MatrixClient once it has been started
|
|
||||||
*/
|
|
||||||
export async function hydrateSession(credentials: IMatrixClientCreds): Promise<MatrixClient> {
|
|
||||||
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
|
* When we have a authenticated via OIDC-native flow and have a refresh token
|
||||||
* try to create a token refresher.
|
* try to create a token refresher.
|
||||||
|
@ -799,18 +762,6 @@ async function doSetLoggedIn(
|
||||||
PosthogAnalytics.instance.startListeningToSettingsChanges(client);
|
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) {
|
if (localStorage) {
|
||||||
try {
|
try {
|
||||||
await persistCredentials(credentials);
|
await persistCredentials(credentials);
|
||||||
|
|
|
@ -16,7 +16,6 @@ import { MatrixClientPeg } from "./MatrixClientPeg";
|
||||||
import { _t } from "./languageHandler";
|
import { _t } from "./languageHandler";
|
||||||
import { isSecureBackupRequired } from "./utils/WellKnownUtils";
|
import { isSecureBackupRequired } from "./utils/WellKnownUtils";
|
||||||
import AccessSecretStorageDialog, { KeyParams } from "./components/views/dialogs/security/AccessSecretStorageDialog";
|
import AccessSecretStorageDialog, { KeyParams } from "./components/views/dialogs/security/AccessSecretStorageDialog";
|
||||||
import SettingsStore from "./settings/SettingsStore";
|
|
||||||
import { ModuleRunner } from "./modules/ModuleRunner";
|
import { ModuleRunner } from "./modules/ModuleRunner";
|
||||||
import QuestionDialog from "./components/views/dialogs/QuestionDialog";
|
import QuestionDialog from "./components/views/dialogs/QuestionDialog";
|
||||||
import InteractiveAuthDialog from "./components/views/dialogs/InteractiveAuthDialog";
|
import InteractiveAuthDialog from "./components/views/dialogs/InteractiveAuthDialog";
|
||||||
|
@ -276,20 +275,6 @@ async function doAccessSecretStorage(func: () => Promise<void>, forceReset: bool
|
||||||
});
|
});
|
||||||
logger.debug("accessSecretStorage: bootstrapSecretStorage");
|
logger.debug("accessSecretStorage: bootstrapSecretStorage");
|
||||||
await crypto.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");
|
logger.debug("accessSecretStorage: 4S now ready");
|
||||||
|
|
|
@ -168,7 +168,7 @@ export default class SoftLogout extends React.Component<IProps, IState> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Lifecycle.hydrateSession(credentials).catch((e) => {
|
Lifecycle.setLoggedIn(credentials).catch((e) => {
|
||||||
logger.error(e);
|
logger.error(e);
|
||||||
this.setState({ busy: false, errorText: _t("auth|failed_soft_logout_auth") });
|
this.setState({ busy: false, errorText: _t("auth|failed_soft_logout_auth") });
|
||||||
});
|
});
|
||||||
|
@ -204,7 +204,7 @@ export default class SoftLogout extends React.Component<IProps, IState> {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Lifecycle.hydrateSession(credentials)
|
return Lifecycle.setLoggedIn(credentials)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
if (this.props.onTokenLoginCompleted) {
|
if (this.props.onTokenLoginCompleted) {
|
||||||
this.props.onTokenLoginCompleted();
|
this.props.onTokenLoginCompleted();
|
||||||
|
|
|
@ -1410,7 +1410,6 @@
|
||||||
"click_for_info": "Click for more info",
|
"click_for_info": "Click for more info",
|
||||||
"currently_experimental": "Currently experimental.",
|
"currently_experimental": "Currently experimental.",
|
||||||
"custom_themes": "Support adding custom themes",
|
"custom_themes": "Support adding custom themes",
|
||||||
"dehydration": "Offline encrypted messaging using dehydrated devices",
|
|
||||||
"dynamic_room_predecessors": "Dynamic room predecessors",
|
"dynamic_room_predecessors": "Dynamic room predecessors",
|
||||||
"dynamic_room_predecessors_description": "Enable MSC3946 (to support late-arriving room archives)",
|
"dynamic_room_predecessors_description": "Enable MSC3946 (to support late-arriving room archives)",
|
||||||
"element_call_video_rooms": "Element Call video rooms",
|
"element_call_video_rooms": "Element Call video rooms",
|
||||||
|
|
|
@ -303,14 +303,6 @@ export const SETTINGS: { [setting: string]: ISetting } = {
|
||||||
supportedLevelsAreOrdered: true,
|
supportedLevelsAreOrdered: true,
|
||||||
default: false,
|
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": {
|
"feature_exclude_insecure_devices": {
|
||||||
isFeature: true,
|
isFeature: true,
|
||||||
labsGroup: LabGroup.Encryption,
|
labsGroup: LabGroup.Encryption,
|
||||||
|
|
Loading…
Reference in a new issue