);
+ } else if (phase === PHASE_RECOVERY_KEY) {
+ const store = SetupEncryptionStore.sharedInstance();
+ let keyPrompt;
+ if (keyHasPassphrase(store.keyInfo)) {
+ keyPrompt = _t(
+ "Enter your Recovery Key or enter a Recovery Passphrase to continue.", {},
+ {
+ a: sub => {sub},
+ },
+ );
+ } else {
+ keyPrompt = _t("Enter your Recovery Key to continue.");
+ }
+
+ const Field = sdk.getComponent('elements.Field');
+ return ;
} else if (phase === PHASE_DONE) {
let message;
if (this.state.backupInfo) {
diff --git a/src/components/views/dialogs/keybackup/RestoreKeyBackupDialog.js b/src/components/views/dialogs/keybackup/RestoreKeyBackupDialog.js
index a16202ed93..2f4c524ed7 100644
--- a/src/components/views/dialogs/keybackup/RestoreKeyBackupDialog.js
+++ b/src/components/views/dialogs/keybackup/RestoreKeyBackupDialog.js
@@ -94,7 +94,7 @@ export default class RestoreKeyBackupDialog extends React.PureComponent {
if (SettingsStore.getValue("feature_cross_signing")) {
// If cross-signing is enabled, we reset the SSSS recovery passphrase (and cross-signing keys)
this.props.onFinished(false);
- accessSecretStorage(() => {}, /* forceReset = */ true);
+ accessSecretStorage(() => {}, {forceReset: true});
} else {
Modal.createTrackedDialogAsync('Key Backup', 'Key Backup',
import('../../../../async-components/views/dialogs/keybackup/CreateKeyBackupDialog'),
diff --git a/src/components/views/dialogs/secretstorage/AccessSecretStorageDialog.js b/src/components/views/dialogs/secretstorage/AccessSecretStorageDialog.js
index e2ceadfbb9..43697f8ee7 100644
--- a/src/components/views/dialogs/secretstorage/AccessSecretStorageDialog.js
+++ b/src/components/views/dialogs/secretstorage/AccessSecretStorageDialog.js
@@ -32,6 +32,9 @@ export default class AccessSecretStorageDialog extends React.PureComponent {
keyInfo: PropTypes.object.isRequired,
// Function from one of { passphrase, recoveryKey } -> boolean
checkPrivateKey: PropTypes.func.isRequired,
+ // If true, only prompt for a passphrase and do not offer to restore with
+ // a recovery key or reset keys.
+ passphraseOnly: PropTypes.bool,
}
constructor(props) {
@@ -58,7 +61,7 @@ export default class AccessSecretStorageDialog extends React.PureComponent {
_onResetRecoveryClick = () => {
// Re-enter the access flow, but resetting storage this time around.
this.props.onFinished(false);
- accessSecretStorage(() => {}, /* forceReset = */ true);
+ accessSecretStorage(() => {}, {forceReset: true});
}
_onRecoveryKeyChange = (e) => {
@@ -164,7 +167,7 @@ export default class AccessSecretStorageDialog extends React.PureComponent {
primaryDisabled={this.state.passPhrase.length === 0}
/>
- {_t(
+ {this.props.passphraseOnly ? null : _t(
"If you've forgotten your recovery passphrase you can "+
"use your recovery key or " +
"set up new recovery options."
@@ -234,7 +237,7 @@ export default class AccessSecretStorageDialog extends React.PureComponent {
primaryDisabled={!this.state.recoveryKeyValid}
/>
- {_t(
+ {this.props.passphraseOnly ? null : _t(
"If you've forgotten your recovery key you can "+
"."
, {}, {
diff --git a/src/components/views/settings/CrossSigningPanel.js b/src/components/views/settings/CrossSigningPanel.js
index b1642e260d..19148c2b6c 100644
--- a/src/components/views/settings/CrossSigningPanel.js
+++ b/src/components/views/settings/CrossSigningPanel.js
@@ -113,7 +113,7 @@ export default class CrossSigningPanel extends React.PureComponent {
_bootstrapSecureSecretStorage = async (forceReset=false) => {
this.setState({ error: null });
try {
- await accessSecretStorage(() => undefined, forceReset);
+ await accessSecretStorage(() => undefined, {forceReset});
} catch (e) {
this.setState({ error: e });
console.error("Error bootstrapping secret storage", e);
diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json
index 3b86c21015..18cfada862 100644
--- a/src/i18n/strings/en_EN.json
+++ b/src/i18n/strings/en_EN.json
@@ -2083,6 +2083,7 @@
"Uploading %(filename)s and %(count)s others|one": "Uploading %(filename)s and %(count)s other",
"Could not load user profile": "Could not load user profile",
"Verify this login": "Verify this login",
+ "Recovery Key": "Recovery Key",
"Session verified": "Session verified",
"Failed to send email": "Failed to send email",
"The email address linked to your account must be entered.": "The email address linked to your account must be entered.",
@@ -2136,10 +2137,16 @@
"You can now close this window or log in to your new account.": "You can now close this window or log in to your new account.",
"Registration Successful": "Registration Successful",
"Create your account": "Create your account",
+ "This isn't the recovery key for your account": "This isn't the recovery key for your account",
+ "This isn't a valid recovery key": "This isn't a valid recovery key",
+ "Looks good!": "Looks good!",
+ "Use Recovery Key or Passphrase": "Use Recovery Key or Passphrase",
+ "Use Recovery Key": "Use Recovery Key",
"Confirm your identity by verifying this login from one of your other sessions, granting it access to encrypted messages.": "Confirm your identity by verifying this login from one of your other sessions, granting it access to encrypted messages.",
"This requires the latest Riot on your other devices:": "This requires the latest Riot on your other devices:",
"or another cross-signing capable Matrix client": "or another cross-signing capable Matrix client",
- "Use Recovery Passphrase or Key": "Use Recovery Passphrase or Key",
+ "Enter your Recovery Key or enter a Recovery Passphrase to continue.": "Enter your Recovery Key or enter a Recovery Passphrase to continue.",
+ "Enter your Recovery Key to continue.": "Enter your Recovery Key to continue.",
"Your new session is now verified. It has access to your encrypted messages, and other users will see it as trusted.": "Your new session is now verified. It has access to your encrypted messages, and other users will see it as trusted.",
"Your new session is now verified. Other users will see it as trusted.": "Your new session is now verified. Other users will see it as trusted.",
"Without completing security on this session, it won’t have access to encrypted messages.": "Without completing security on this session, it won’t have access to encrypted messages.",
@@ -2182,9 +2189,9 @@
"Import": "Import",
"Confirm encryption setup": "Confirm encryption setup",
"Click the button below to confirm setting up encryption.": "Click the button below to confirm setting up encryption.",
- "Enter your account password to confirm the upgrade:": "Enter your account password to confirm the upgrade:",
"Restore your key backup to upgrade your encryption": "Restore your key backup to upgrade your encryption",
"Restore": "Restore",
+ "Enter your account password to confirm the upgrade:": "Enter your account password to confirm the upgrade:",
"You'll need to authenticate with the server to confirm the upgrade.": "You'll need to authenticate with the server to confirm the upgrade.",
"Upgrade this session to allow it to verify other sessions, granting them access to encrypted messages and marking them as trusted for other users.": "Upgrade this session to allow it to verify other sessions, granting them access to encrypted messages and marking them as trusted for other users.",
"Store your Recovery Key somewhere safe, it can be used to unlock your encrypted messages & data.": "Store your Recovery Key somewhere safe, it can be used to unlock your encrypted messages & data.",
diff --git a/src/stores/SetupEncryptionStore.js b/src/stores/SetupEncryptionStore.js
index ae1f998b02..8c081e1da9 100644
--- a/src/stores/SetupEncryptionStore.js
+++ b/src/stores/SetupEncryptionStore.js
@@ -20,10 +20,11 @@ import { accessSecretStorage, AccessCancelledError } from '../CrossSigningManage
import { PHASE_DONE as VERIF_PHASE_DONE } from "matrix-js-sdk/src/crypto/verification/request/VerificationRequest";
export const PHASE_INTRO = 0;
-export const PHASE_BUSY = 1;
-export const PHASE_DONE = 2; //final done stage, but still showing UX
-export const PHASE_CONFIRM_SKIP = 3;
-export const PHASE_FINISHED = 4; //UX can be closed
+export const PHASE_RECOVERY_KEY = 1;
+export const PHASE_BUSY = 2;
+export const PHASE_DONE = 3; //final done stage, but still showing UX
+export const PHASE_CONFIRM_SKIP = 4;
+export const PHASE_FINISHED = 5; //UX can be closed
export class SetupEncryptionStore extends EventEmitter {
static sharedInstance() {
@@ -36,11 +37,19 @@ export class SetupEncryptionStore extends EventEmitter {
return;
}
this._started = true;
- this.phase = PHASE_INTRO;
+ this.phase = PHASE_BUSY;
this.verificationRequest = null;
this.backupInfo = null;
+
+ // ID of the key that the secrets we want are encrypted with
+ this.keyId = null;
+ // Descriptor of the key that the secrets we want are encrypted with
+ this.keyInfo = null;
+
MatrixClientPeg.get().on("crypto.verification.request", this.onVerificationRequest);
MatrixClientPeg.get().on('userTrustStatusChanged', this._onUserTrustStatusChanged);
+
+ this.fetchKeyInfo();
}
stop() {
@@ -57,7 +66,40 @@ export class SetupEncryptionStore extends EventEmitter {
}
}
+ async fetchKeyInfo() {
+ const keys = await MatrixClientPeg.get().isSecretStored('m.cross_signing.master', false);
+ if (Object.keys(keys).length === 0) {
+ this.keyId = null;
+ this.keyInfo = null;
+ } else {
+ // If the secret is stored under more than one key, we just pick an arbitrary one
+ this.keyId = Object.keys(keys)[0];
+ this.keyInfo = keys[this.keyId];
+ }
+
+ this.phase = PHASE_INTRO;
+ this.emit("update");
+ }
+
+ async useRecoveryKey() {
+ this.phase = PHASE_RECOVERY_KEY;
+ this.emit("update");
+ }
+
+ cancelUseRecoveryKey() {
+ this.phase = PHASE_INTRO;
+ this.emit("update");
+ }
+
+ async setupWithRecoveryKey(recoveryKey) {
+ this.startTrustCheck({[this.keyId]: recoveryKey});
+ }
+
async usePassPhrase() {
+ this.startTrustCheck();
+ }
+
+ async startTrustCheck(withKeys) {
this.phase = PHASE_BUSY;
this.emit("update");
const cli = MatrixClientPeg.get();
@@ -84,6 +126,9 @@ export class SetupEncryptionStore extends EventEmitter {
// to advance before this.
await cli.restoreKeyBackupWithSecretStorage(backupInfo);
}
+ }, {
+ withKeys,
+ passphraseOnly: true,
}).catch(reject);
} catch (e) {
console.error(e);