Pass new secret storage key to bootstrap path

This passes the newly created secret storage key down to the bootstrap path for
temporary caching to avoid prompting the user for it again in the later stages
of bootstrapping.

Fixes https://github.com/vector-im/riot-web/issues/12867
This commit is contained in:
J. Ryan Stinnett 2020-03-30 21:40:09 +01:00
parent 4e8cec354d
commit 690b5945d0

View file

@ -69,6 +69,7 @@ export default class CreateSecretStorageDialog extends React.PureComponent {
this._keyInfo = null; this._keyInfo = null;
this._encodedRecoveryKey = null; this._encodedRecoveryKey = null;
this._recoveryKey = null;
this._recoveryKeyNode = null; this._recoveryKeyNode = null;
this._setZxcvbnResultTimeout = null; this._setZxcvbnResultTimeout = null;
@ -234,14 +235,22 @@ export default class CreateSecretStorageDialog extends React.PureComponent {
if (force) { if (force) {
await cli.bootstrapSecretStorage({ await cli.bootstrapSecretStorage({
authUploadDeviceSigningKeys: this._doBootstrapUIAuth, authUploadDeviceSigningKeys: this._doBootstrapUIAuth,
createSecretStorageKey: async () => this._keyInfo, createSecretStorageKey: async () => [
this._keyInfo,
this._encodedRecoveryKey,
this._recoveryKey,
],
setupNewKeyBackup: true, setupNewKeyBackup: true,
setupNewSecretStorage: true, setupNewSecretStorage: true,
}); });
} else { } else {
await cli.bootstrapSecretStorage({ await cli.bootstrapSecretStorage({
authUploadDeviceSigningKeys: this._doBootstrapUIAuth, authUploadDeviceSigningKeys: this._doBootstrapUIAuth,
createSecretStorageKey: async () => this._keyInfo, createSecretStorageKey: async () => [
this._keyInfo,
this._encodedRecoveryKey,
this._recoveryKey,
],
keyBackupInfo: this.state.backupInfo, keyBackupInfo: this.state.backupInfo,
setupNewKeyBackup: !this.state.backupInfo && this.state.useKeyBackup, setupNewKeyBackup: !this.state.backupInfo && this.state.useKeyBackup,
getKeyBackupPassphrase: promptForBackupPassphrase, getKeyBackupPassphrase: promptForBackupPassphrase,
@ -299,10 +308,11 @@ export default class CreateSecretStorageDialog extends React.PureComponent {
} }
_onSkipPassPhraseClick = async () => { _onSkipPassPhraseClick = async () => {
const [keyInfo, encodedRecoveryKey] = const [keyInfo, encodedRecoveryKey, recoveryKey] =
await MatrixClientPeg.get().createRecoveryKeyFromPassphrase(); await MatrixClientPeg.get().createRecoveryKeyFromPassphrase();
this._keyInfo = keyInfo; this._keyInfo = keyInfo;
this._encodedRecoveryKey = encodedRecoveryKey; this._encodedRecoveryKey = encodedRecoveryKey;
this._recoveryKey = recoveryKey;
this.setState({ this.setState({
copied: false, copied: false,
downloaded: false, downloaded: false,
@ -335,10 +345,11 @@ export default class CreateSecretStorageDialog extends React.PureComponent {
if (this.state.passPhrase !== this.state.passPhraseConfirm) return; if (this.state.passPhrase !== this.state.passPhraseConfirm) return;
const [keyInfo, encodedRecoveryKey] = const [keyInfo, encodedRecoveryKey, recoveryKey] =
await MatrixClientPeg.get().createRecoveryKeyFromPassphrase(this.state.passPhrase); await MatrixClientPeg.get().createRecoveryKeyFromPassphrase(this.state.passPhrase);
this._keyInfo = keyInfo; this._keyInfo = keyInfo;
this._encodedRecoveryKey = encodedRecoveryKey; this._encodedRecoveryKey = encodedRecoveryKey;
this._recoveryKey = recoveryKey;
this.setState({ this.setState({
copied: false, copied: false,
downloaded: false, downloaded: false,