mirror of https://github.com/vector-im/riot-web
				
				
				
			Merge pull request #4308 from matrix-org/jryans/4s-prompt-overload
Pass new secret storage key to bootstrap pathpull/21833/head
						commit
						223a4e285d
					
				| 
						 | 
					@ -67,8 +67,7 @@ export default class CreateSecretStorageDialog extends React.PureComponent {
 | 
				
			||||||
    constructor(props) {
 | 
					    constructor(props) {
 | 
				
			||||||
        super(props);
 | 
					        super(props);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        this._keyInfo = null;
 | 
					        this._recoveryKey = null;
 | 
				
			||||||
        this._encodedRecoveryKey = null;
 | 
					 | 
				
			||||||
        this._recoveryKeyNode = null;
 | 
					        this._recoveryKeyNode = null;
 | 
				
			||||||
        this._setZxcvbnResultTimeout = null;
 | 
					        this._setZxcvbnResultTimeout = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -180,7 +179,7 @@ export default class CreateSecretStorageDialog extends React.PureComponent {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    _onDownloadClick = () => {
 | 
					    _onDownloadClick = () => {
 | 
				
			||||||
        const blob = new Blob([this._encodedRecoveryKey], {
 | 
					        const blob = new Blob([this._recoveryKey.encodedPrivateKey], {
 | 
				
			||||||
            type: 'text/plain;charset=us-ascii',
 | 
					            type: 'text/plain;charset=us-ascii',
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
        FileSaver.saveAs(blob, 'recovery-key.txt');
 | 
					        FileSaver.saveAs(blob, 'recovery-key.txt');
 | 
				
			||||||
| 
						 | 
					@ -234,14 +233,14 @@ 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._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._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 +298,8 @@ export default class CreateSecretStorageDialog extends React.PureComponent {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    _onSkipPassPhraseClick = async () => {
 | 
					    _onSkipPassPhraseClick = async () => {
 | 
				
			||||||
        const [keyInfo, encodedRecoveryKey] =
 | 
					        this._recoveryKey =
 | 
				
			||||||
            await MatrixClientPeg.get().createRecoveryKeyFromPassphrase();
 | 
					            await MatrixClientPeg.get().createRecoveryKeyFromPassphrase();
 | 
				
			||||||
        this._keyInfo = keyInfo;
 | 
					 | 
				
			||||||
        this._encodedRecoveryKey = encodedRecoveryKey;
 | 
					 | 
				
			||||||
        this.setState({
 | 
					        this.setState({
 | 
				
			||||||
            copied: false,
 | 
					            copied: false,
 | 
				
			||||||
            downloaded: false,
 | 
					            downloaded: false,
 | 
				
			||||||
| 
						 | 
					@ -335,10 +332,8 @@ 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] =
 | 
					        this._recoveryKey =
 | 
				
			||||||
            await MatrixClientPeg.get().createRecoveryKeyFromPassphrase(this.state.passPhrase);
 | 
					            await MatrixClientPeg.get().createRecoveryKeyFromPassphrase(this.state.passPhrase);
 | 
				
			||||||
        this._keyInfo = keyInfo;
 | 
					 | 
				
			||||||
        this._encodedRecoveryKey = encodedRecoveryKey;
 | 
					 | 
				
			||||||
        this.setState({
 | 
					        this.setState({
 | 
				
			||||||
            copied: false,
 | 
					            copied: false,
 | 
				
			||||||
            downloaded: false,
 | 
					            downloaded: false,
 | 
				
			||||||
| 
						 | 
					@ -613,7 +608,7 @@ export default class CreateSecretStorageDialog extends React.PureComponent {
 | 
				
			||||||
                </div>
 | 
					                </div>
 | 
				
			||||||
                <div className="mx_CreateSecretStorageDialog_recoveryKeyContainer">
 | 
					                <div className="mx_CreateSecretStorageDialog_recoveryKeyContainer">
 | 
				
			||||||
                    <div className="mx_CreateSecretStorageDialog_recoveryKey">
 | 
					                    <div className="mx_CreateSecretStorageDialog_recoveryKey">
 | 
				
			||||||
                        <code ref={this._collectRecoveryKeyNode}>{this._encodedRecoveryKey}</code>
 | 
					                        <code ref={this._collectRecoveryKeyNode}>{this._recoveryKey.encodedPrivateKey}</code>
 | 
				
			||||||
                    </div>
 | 
					                    </div>
 | 
				
			||||||
                    <div className="mx_CreateSecretStorageDialog_recoveryKeyButtons">
 | 
					                    <div className="mx_CreateSecretStorageDialog_recoveryKeyButtons">
 | 
				
			||||||
                        <AccessibleButton kind='primary' className="mx_Dialog_primary" onClick={this._onCopyClick}>
 | 
					                        <AccessibleButton kind='primary' className="mx_Dialog_primary" onClick={this._onCopyClick}>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue