Remove remaining support for outdated .well-known settings (#30702)
* Remove remaining support for `secure_backup_setup_methods` option Support for this .well-known setting had been removed everywhere except in a rather obscure corner of the code. There are many other problems with this area (https://github.com/element-hq/element-web/issues/29171) but removing support for the outdated option is an easy step. * Remove remaining `secure_backup_required` setting support Again, this setting was only honoured in the obscure "New Recovery Method" flow.
This commit is contained in:
@@ -14,7 +14,6 @@ import { logger as rootLogger } from "matrix-js-sdk/src/logger";
|
|||||||
import Modal from "./Modal";
|
import Modal from "./Modal";
|
||||||
import { MatrixClientPeg } from "./MatrixClientPeg";
|
import { MatrixClientPeg } from "./MatrixClientPeg";
|
||||||
import { _t } from "./languageHandler";
|
import { _t } from "./languageHandler";
|
||||||
import { isSecureBackupRequired } from "./utils/WellKnownUtils";
|
|
||||||
import AccessSecretStorageDialog, {
|
import AccessSecretStorageDialog, {
|
||||||
type KeyParams,
|
type KeyParams,
|
||||||
} from "./components/views/dialogs/security/AccessSecretStorageDialog";
|
} from "./components/views/dialogs/security/AccessSecretStorageDialog";
|
||||||
@@ -232,15 +231,6 @@ async function doAccessSecretStorage(func: () => Promise<void>, opts: AccessSecr
|
|||||||
undefined,
|
undefined,
|
||||||
/* priority = */ false,
|
/* priority = */ false,
|
||||||
/* static = */ true,
|
/* static = */ true,
|
||||||
/* options = */ {
|
|
||||||
onBeforeClose: async (reason): Promise<boolean> => {
|
|
||||||
// If Secure Backup is required, you cannot leave the modal.
|
|
||||||
if (reason === "backgroundClick") {
|
|
||||||
return !isSecureBackupRequired(cli);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
const [confirmed] = await finished;
|
const [confirmed] = await finished;
|
||||||
if (!confirmed) {
|
if (!confirmed) {
|
||||||
|
|||||||
@@ -25,11 +25,6 @@ import StyledRadioButton from "../../../../components/views/elements/StyledRadio
|
|||||||
import AccessibleButton from "../../../../components/views/elements/AccessibleButton";
|
import AccessibleButton from "../../../../components/views/elements/AccessibleButton";
|
||||||
import DialogButtons from "../../../../components/views/elements/DialogButtons";
|
import DialogButtons from "../../../../components/views/elements/DialogButtons";
|
||||||
import InlineSpinner from "../../../../components/views/elements/InlineSpinner";
|
import InlineSpinner from "../../../../components/views/elements/InlineSpinner";
|
||||||
import {
|
|
||||||
getSecureBackupSetupMethods,
|
|
||||||
isSecureBackupRequired,
|
|
||||||
SecureBackupSetupMethod,
|
|
||||||
} from "../../../../utils/WellKnownUtils";
|
|
||||||
import { ModuleRunner } from "../../../../modules/ModuleRunner";
|
import { ModuleRunner } from "../../../../modules/ModuleRunner";
|
||||||
import type Field from "../../../../components/views/elements/Field";
|
import type Field from "../../../../components/views/elements/Field";
|
||||||
import BaseDialog from "../../../../components/views/dialogs/BaseDialog";
|
import BaseDialog from "../../../../components/views/dialogs/BaseDialog";
|
||||||
@@ -39,6 +34,11 @@ import { type IValidationResult } from "../../../../components/views/elements/Va
|
|||||||
import PassphraseConfirmField from "../../../../components/views/auth/PassphraseConfirmField";
|
import PassphraseConfirmField from "../../../../components/views/auth/PassphraseConfirmField";
|
||||||
import { initialiseDehydrationIfEnabled } from "../../../../utils/device/dehydration";
|
import { initialiseDehydrationIfEnabled } from "../../../../utils/device/dehydration";
|
||||||
|
|
||||||
|
enum SecureBackupSetupMethod {
|
||||||
|
Key = "key",
|
||||||
|
Passphrase = "passphrase",
|
||||||
|
}
|
||||||
|
|
||||||
// I made a mistake while converting this and it has to be fixed!
|
// I made a mistake while converting this and it has to be fixed!
|
||||||
enum Phase {
|
enum Phase {
|
||||||
Loading = "loading",
|
Loading = "loading",
|
||||||
@@ -68,7 +68,6 @@ interface IState {
|
|||||||
downloaded: boolean;
|
downloaded: boolean;
|
||||||
setPassphrase: boolean;
|
setPassphrase: boolean;
|
||||||
|
|
||||||
canSkip: boolean;
|
|
||||||
passPhraseKeySelected: string;
|
passPhraseKeySelected: string;
|
||||||
error?: boolean;
|
error?: boolean;
|
||||||
}
|
}
|
||||||
@@ -93,16 +92,6 @@ export default class CreateSecretStorageDialog extends React.PureComponent<IProp
|
|||||||
public constructor(props: IProps) {
|
public constructor(props: IProps) {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
const cli = MatrixClientPeg.safeGet();
|
|
||||||
|
|
||||||
let passPhraseKeySelected: SecureBackupSetupMethod;
|
|
||||||
const setupMethods = getSecureBackupSetupMethods(cli);
|
|
||||||
if (setupMethods.includes(SecureBackupSetupMethod.Key)) {
|
|
||||||
passPhraseKeySelected = SecureBackupSetupMethod.Key;
|
|
||||||
} else {
|
|
||||||
passPhraseKeySelected = SecureBackupSetupMethod.Passphrase;
|
|
||||||
}
|
|
||||||
|
|
||||||
const keyFromCustomisations = ModuleRunner.instance.extensions.cryptoSetup.createSecretStorageKey();
|
const keyFromCustomisations = ModuleRunner.instance.extensions.cryptoSetup.createSecretStorageKey();
|
||||||
const phase = keyFromCustomisations ? Phase.Loading : Phase.ChooseKeyPassphrase;
|
const phase = keyFromCustomisations ? Phase.Loading : Phase.ChooseKeyPassphrase;
|
||||||
|
|
||||||
@@ -114,8 +103,7 @@ export default class CreateSecretStorageDialog extends React.PureComponent<IProp
|
|||||||
copied: false,
|
copied: false,
|
||||||
downloaded: false,
|
downloaded: false,
|
||||||
setPassphrase: false,
|
setPassphrase: false,
|
||||||
canSkip: !isSecureBackupRequired(cli),
|
passPhraseKeySelected: SecureBackupSetupMethod.Key,
|
||||||
passPhraseKeySelected,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -391,11 +379,8 @@ export default class CreateSecretStorageDialog extends React.PureComponent<IProp
|
|||||||
}
|
}
|
||||||
|
|
||||||
private renderPhaseChooseKeyPassphrase(): JSX.Element {
|
private renderPhaseChooseKeyPassphrase(): JSX.Element {
|
||||||
const setupMethods = getSecureBackupSetupMethods(MatrixClientPeg.safeGet());
|
const optionKey = this.renderOptionKey();
|
||||||
const optionKey = setupMethods.includes(SecureBackupSetupMethod.Key) ? this.renderOptionKey() : null;
|
const optionPassphrase = this.renderOptionPassphrase();
|
||||||
const optionPassphrase = setupMethods.includes(SecureBackupSetupMethod.Passphrase)
|
|
||||||
? this.renderOptionPassphrase()
|
|
||||||
: null;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<form onSubmit={this.onChooseKeyPassphraseFormSubmit}>
|
<form onSubmit={this.onChooseKeyPassphraseFormSubmit}>
|
||||||
@@ -410,7 +395,6 @@ export default class CreateSecretStorageDialog extends React.PureComponent<IProp
|
|||||||
primaryButton={_t("action|continue")}
|
primaryButton={_t("action|continue")}
|
||||||
onPrimaryButtonClick={this.onChooseKeyPassphraseFormSubmit}
|
onPrimaryButtonClick={this.onChooseKeyPassphraseFormSubmit}
|
||||||
onCancel={this.onCancelClick}
|
onCancel={this.onCancelClick}
|
||||||
hasCancel={this.state.canSkip}
|
|
||||||
/>
|
/>
|
||||||
</form>
|
</form>
|
||||||
);
|
);
|
||||||
@@ -601,7 +585,6 @@ export default class CreateSecretStorageDialog extends React.PureComponent<IProp
|
|||||||
<DialogButtons
|
<DialogButtons
|
||||||
primaryButton={_t("action|retry")}
|
primaryButton={_t("action|retry")}
|
||||||
onPrimaryButtonClick={this.onLoadRetryClick}
|
onPrimaryButtonClick={this.onLoadRetryClick}
|
||||||
hasCancel={this.state.canSkip}
|
|
||||||
onCancel={this.onCancel}
|
onCancel={this.onCancel}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -672,7 +655,6 @@ export default class CreateSecretStorageDialog extends React.PureComponent<IProp
|
|||||||
<DialogButtons
|
<DialogButtons
|
||||||
primaryButton={_t("action|retry")}
|
primaryButton={_t("action|retry")}
|
||||||
onPrimaryButtonClick={this.bootstrapSecretStorage}
|
onPrimaryButtonClick={this.bootstrapSecretStorage}
|
||||||
hasCancel={this.state.canSkip}
|
|
||||||
onCancel={this.onCancel}
|
onCancel={this.onCancel}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -30,8 +30,6 @@ export interface IE2EEWellKnown {
|
|||||||
* Disables the option to enable encryption in room settings for all new and existing rooms
|
* Disables the option to enable encryption in room settings for all new and existing rooms
|
||||||
*/
|
*/
|
||||||
force_disable?: boolean;
|
force_disable?: boolean;
|
||||||
secure_backup_required?: boolean;
|
|
||||||
secure_backup_setup_methods?: SecureBackupSetupMethod[];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ITileServerWellKnown {
|
export interface ITileServerWellKnown {
|
||||||
@@ -74,28 +72,3 @@ export function getEmbeddedPagesWellKnown(matrixClient: MatrixClient | undefined
|
|||||||
export function embeddedPagesFromWellKnown(clientWellKnown?: IClientWellKnown): IEmbeddedPagesWellKnown {
|
export function embeddedPagesFromWellKnown(clientWellKnown?: IClientWellKnown): IEmbeddedPagesWellKnown {
|
||||||
return clientWellKnown?.[EMBEDDED_PAGES_WK_PROPERTY];
|
return clientWellKnown?.[EMBEDDED_PAGES_WK_PROPERTY];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isSecureBackupRequired(matrixClient: MatrixClient): boolean {
|
|
||||||
return getE2EEWellKnown(matrixClient)?.["secure_backup_required"] === true;
|
|
||||||
}
|
|
||||||
|
|
||||||
export enum SecureBackupSetupMethod {
|
|
||||||
Key = "key",
|
|
||||||
Passphrase = "passphrase",
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getSecureBackupSetupMethods(matrixClient: MatrixClient): SecureBackupSetupMethod[] {
|
|
||||||
const wellKnown = getE2EEWellKnown(matrixClient);
|
|
||||||
if (
|
|
||||||
!wellKnown ||
|
|
||||||
!wellKnown["secure_backup_setup_methods"] ||
|
|
||||||
!wellKnown["secure_backup_setup_methods"].length ||
|
|
||||||
!(
|
|
||||||
wellKnown["secure_backup_setup_methods"].includes(SecureBackupSetupMethod.Key) ||
|
|
||||||
wellKnown["secure_backup_setup_methods"].includes(SecureBackupSetupMethod.Passphrase)
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
return [SecureBackupSetupMethod.Key, SecureBackupSetupMethod.Passphrase];
|
|
||||||
}
|
|
||||||
return wellKnown["secure_backup_setup_methods"];
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user