diff --git a/src/CrossSigningManager.js b/src/CrossSigningManager.js index 676c41d7d7..46f0284776 100644 --- a/src/CrossSigningManager.js +++ b/src/CrossSigningManager.js @@ -21,6 +21,7 @@ import { deriveKey } from 'matrix-js-sdk/src/crypto/key_passphrase'; import { decodeRecoveryKey } from 'matrix-js-sdk/src/crypto/recoverykey'; import { _t } from './languageHandler'; import {encodeBase64} from "matrix-js-sdk/src/crypto/olmlib"; +import { isSecureBackupRequired } from './utils/WellKnownUtils'; // This stores the secret storage private keys in memory for the JS SDK. This is // only meant to act as a cache to avoid prompting the user multiple times @@ -208,7 +209,18 @@ export async function accessSecretStorage(func = async () => { }, forceReset = f { force: forceReset, }, - null, /* priority = */ false, /* static = */ true, + null, + /* priority = */ false, + /* static = */ true, + /* options = */ { + onBeforeClose(reason) { + // If Secure Backup is required, you cannot leave the modal. + if (reason === "backgroundClick") { + return !isSecureBackupRequired(); + } + return true; + }, + }, ); const [confirmed] = await finished; if (!confirmed) { diff --git a/src/async-components/views/dialogs/secretstorage/CreateSecretStorageDialog.js b/src/async-components/views/dialogs/secretstorage/CreateSecretStorageDialog.js index bb231c24a0..47faa35df4 100644 --- a/src/async-components/views/dialogs/secretstorage/CreateSecretStorageDialog.js +++ b/src/async-components/views/dialogs/secretstorage/CreateSecretStorageDialog.js @@ -30,6 +30,7 @@ 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 { isSecureBackupRequired } from '../../../../utils/WellKnownUtils'; const PHASE_LOADING = 0; const PHASE_LOADERROR = 1; @@ -85,8 +86,8 @@ export default class CreateSecretStorageDialog extends React.PureComponent { canUploadKeysWithPasswordOnly: null, accountPassword: props.accountPassword || "", accountPasswordCorrect: null, - passPhraseKeySelected: CREATE_STORAGE_OPTION_KEY, + canSkip: !isSecureBackupRequired(), }; this._passphraseField = createRef(); @@ -470,7 +471,7 @@ export default class CreateSecretStorageDialog extends React.PureComponent { primaryButton={_t("Continue")} onPrimaryButtonClick={this._onChooseKeyPassphraseFormSubmit} onCancel={this._onCancelClick} - hasCancel={true} + hasCancel={this.state.canSkip} /> ; } @@ -687,7 +688,7 @@ export default class CreateSecretStorageDialog extends React.PureComponent {
@@ -742,7 +743,7 @@ export default class CreateSecretStorageDialog extends React.PureComponent {
diff --git a/src/utils/WellKnownUtils.ts b/src/utils/WellKnownUtils.ts index 2712570396..f16acdb408 100644 --- a/src/utils/WellKnownUtils.ts +++ b/src/utils/WellKnownUtils.ts @@ -33,3 +33,8 @@ export function getE2EEWellKnown(): IE2EEWellKnown { } return null; } + +export function isSecureBackupRequired(): boolean { + const wellKnown = getE2EEWellKnown(); + return wellKnown && wellKnown["secure_backup_required"] === true; +}