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:
committed by
GitHub
parent
1c30bec083
commit
5534c0dbe9
@@ -14,7 +14,6 @@ import { logger as rootLogger } from "matrix-js-sdk/src/logger";
|
||||
import Modal from "./Modal";
|
||||
import { MatrixClientPeg } from "./MatrixClientPeg";
|
||||
import { _t } from "./languageHandler";
|
||||
import { isSecureBackupRequired } from "./utils/WellKnownUtils";
|
||||
import AccessSecretStorageDialog, {
|
||||
type KeyParams,
|
||||
} from "./components/views/dialogs/security/AccessSecretStorageDialog";
|
||||
@@ -232,15 +231,6 @@ async function doAccessSecretStorage(func: () => Promise<void>, opts: AccessSecr
|
||||
undefined,
|
||||
/* priority = */ false,
|
||||
/* 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;
|
||||
if (!confirmed) {
|
||||
|
||||
@@ -25,11 +25,6 @@ import StyledRadioButton from "../../../../components/views/elements/StyledRadio
|
||||
import AccessibleButton from "../../../../components/views/elements/AccessibleButton";
|
||||
import DialogButtons from "../../../../components/views/elements/DialogButtons";
|
||||
import InlineSpinner from "../../../../components/views/elements/InlineSpinner";
|
||||
import {
|
||||
getSecureBackupSetupMethods,
|
||||
isSecureBackupRequired,
|
||||
SecureBackupSetupMethod,
|
||||
} from "../../../../utils/WellKnownUtils";
|
||||
import { ModuleRunner } from "../../../../modules/ModuleRunner";
|
||||
import type Field from "../../../../components/views/elements/Field";
|
||||
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 { initialiseDehydrationIfEnabled } from "../../../../utils/device/dehydration";
|
||||
|
||||
enum SecureBackupSetupMethod {
|
||||
Key = "key",
|
||||
Passphrase = "passphrase",
|
||||
}
|
||||
|
||||
// I made a mistake while converting this and it has to be fixed!
|
||||
enum Phase {
|
||||
Loading = "loading",
|
||||
@@ -68,7 +68,6 @@ interface IState {
|
||||
downloaded: boolean;
|
||||
setPassphrase: boolean;
|
||||
|
||||
canSkip: boolean;
|
||||
passPhraseKeySelected: string;
|
||||
error?: boolean;
|
||||
}
|
||||
@@ -93,16 +92,6 @@ export default class CreateSecretStorageDialog extends React.PureComponent<IProp
|
||||
public constructor(props: IProps) {
|
||||
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 phase = keyFromCustomisations ? Phase.Loading : Phase.ChooseKeyPassphrase;
|
||||
|
||||
@@ -114,8 +103,7 @@ export default class CreateSecretStorageDialog extends React.PureComponent<IProp
|
||||
copied: false,
|
||||
downloaded: false,
|
||||
setPassphrase: false,
|
||||
canSkip: !isSecureBackupRequired(cli),
|
||||
passPhraseKeySelected,
|
||||
passPhraseKeySelected: SecureBackupSetupMethod.Key,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -391,11 +379,8 @@ export default class CreateSecretStorageDialog extends React.PureComponent<IProp
|
||||
}
|
||||
|
||||
private renderPhaseChooseKeyPassphrase(): JSX.Element {
|
||||
const setupMethods = getSecureBackupSetupMethods(MatrixClientPeg.safeGet());
|
||||
const optionKey = setupMethods.includes(SecureBackupSetupMethod.Key) ? this.renderOptionKey() : null;
|
||||
const optionPassphrase = setupMethods.includes(SecureBackupSetupMethod.Passphrase)
|
||||
? this.renderOptionPassphrase()
|
||||
: null;
|
||||
const optionKey = this.renderOptionKey();
|
||||
const optionPassphrase = this.renderOptionPassphrase();
|
||||
|
||||
return (
|
||||
<form onSubmit={this.onChooseKeyPassphraseFormSubmit}>
|
||||
@@ -410,7 +395,6 @@ export default class CreateSecretStorageDialog extends React.PureComponent<IProp
|
||||
primaryButton={_t("action|continue")}
|
||||
onPrimaryButtonClick={this.onChooseKeyPassphraseFormSubmit}
|
||||
onCancel={this.onCancelClick}
|
||||
hasCancel={this.state.canSkip}
|
||||
/>
|
||||
</form>
|
||||
);
|
||||
@@ -601,7 +585,6 @@ export default class CreateSecretStorageDialog extends React.PureComponent<IProp
|
||||
<DialogButtons
|
||||
primaryButton={_t("action|retry")}
|
||||
onPrimaryButtonClick={this.onLoadRetryClick}
|
||||
hasCancel={this.state.canSkip}
|
||||
onCancel={this.onCancel}
|
||||
/>
|
||||
</div>
|
||||
@@ -672,7 +655,6 @@ export default class CreateSecretStorageDialog extends React.PureComponent<IProp
|
||||
<DialogButtons
|
||||
primaryButton={_t("action|retry")}
|
||||
onPrimaryButtonClick={this.bootstrapSecretStorage}
|
||||
hasCancel={this.state.canSkip}
|
||||
onCancel={this.onCancel}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -30,8 +30,6 @@ export interface IE2EEWellKnown {
|
||||
* Disables the option to enable encryption in room settings for all new and existing rooms
|
||||
*/
|
||||
force_disable?: boolean;
|
||||
secure_backup_required?: boolean;
|
||||
secure_backup_setup_methods?: SecureBackupSetupMethod[];
|
||||
}
|
||||
|
||||
export interface ITileServerWellKnown {
|
||||
@@ -74,28 +72,3 @@ export function getEmbeddedPagesWellKnown(matrixClient: MatrixClient | undefined
|
||||
export function embeddedPagesFromWellKnown(clientWellKnown?: IClientWellKnown): IEmbeddedPagesWellKnown {
|
||||
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