You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2 lines
18 KiB

/*! For license information please see 3.js.LICENSE */
(window.webpackJsonp=window.webpackJsonp||[]).push([[3],{1497:function(e,t,a){"use strict";a.r(t),a.d(t,"default",(function(){return b}));var s=a(5),n=a.n(s),r=a(0),o=a.n(r),i=a(2),c=a.n(i),l=a(3),u=a(4),h=a(1504),p=a(1499),d=a.n(p),m=a(1),y=a(9);const g=2;class b extends o.a.PureComponent{constructor(e){super(e),n()(this,"_onKeyBackupStatusChange",()=>{1===this.state.phase&&this._fetchBackupInfo()}),n()(this,"_collectRecoveryKeyNode",e=>{this._recoveryKeyNode=e}),n()(this,"_onUseKeyBackupChange",e=>{this.setState({useKeyBackup:e})}),n()(this,"_onMigrateFormSubmit",e=>{e.preventDefault(),this.state.backupSigStatus.usable?this._bootstrapSecretStorage():this._restoreBackup()}),n()(this,"_onCopyClick",()=>{!function(e){const t=document.createRange();t.selectNodeContents(e);const a=window.getSelection();a.removeAllRanges(),a.addRange(t)}(this._recoveryKeyNode),document.execCommand("copy")&&this.setState({copied:!0,phase:5})}),n()(this,"_onDownloadClick",()=>{const e=new Blob([this._encodedRecoveryKey],{type:"text/plain;charset=us-ascii"});d.a.saveAs(e,"recovery-key.txt"),this.setState({downloaded:!0,phase:5})}),n()(this,"_doBootstrapUIAuth",async e=>{if(this.state.canUploadKeysWithPasswordOnly&&this.state.accountPassword)await e({type:"m.login.password",identifier:{type:"m.id.user",user:u.a.get().getUserId()},user:u.a.get().getUserId(),password:this.state.accountPassword});else{const t=l.a("dialogs.InteractiveAuthDialog"),{finished:a}=y.a.createTrackedDialog("Cross-signing keys dialog","",t,{title:Object(m.a)("Setting up keys"),matrixClient:u.a.get(),makeRequest:e}),[s]=await a;if(!s)throw new Error("Cross-signing key upload auth canceled")}}),n()(this,"_bootstrapSecretStorage",async()=>{this.setState({phase:6,error:null});const e=u.a.get(),{force:t}=this.props;try{t?await e.bootstrapSecretStorage({authUploadDeviceSigningKeys:this._doBootstrapUIAuth,createSecretStorageKey:async()=>this._keyInfo,setupNewKeyBackup:!0,setupNewSecretStorage:!0}):await e.bootstrapSecretStorage({authUploadDeviceSigningKeys:this._doBootstrapUIAuth,createSecretStorageKey:async()=>this._keyInfo,keyBackupInfo:this.state.backupInfo,setupNewKeyBackup:!this.state.backupInfo&&this.state.useKeyBackup}),this.setState({phase:7})}catch(e){this.state.canUploadKeysWithPasswordOnly&&401===e.httpStatus&&e.data.flows?this.setState({accountPassword:"",accountPasswordCorrect:!1,phase:1}):this.setState({error:e}),console.error("Error bootstrapping secret storage",e)}}),n()(this,"_onCancel",()=>{this.props.onFinished(!1)}),n()(this,"_onDone",()=>{this.props.onFinished(!0)}),n()(this,"_restoreBackup",async()=>{const e=l.a("dialogs.keybackup.RestoreKeyBackupDialog"),{finished:t}=y.a.createTrackedDialog("Restore Backup","",e,{showSummary:!1},null,!1,!0);await t,await this._fetchBackupInfo(),this.state.backupSigStatus.usable&&this.state.canUploadKeysWithPasswordOnly&&this.state.accountPassword&&this._bootstrapSecretStorage()}),n()(this,"_onSkipSetupClick",()=>{this.setState({phase:8})}),n()(this,"_onSetUpClick",()=>{this.setState({phase:g})}),n()(this,"_onSkipPassPhraseClick",async()=>{const[e,t]=await u.a.get().createRecoveryKeyFromPassphrase();this._keyInfo=e,this._encodedRecoveryKey=t,this.setState({copied:!1,downloaded:!1,phase:4})}),n()(this,"_onPassPhraseNextClick",async e=>{e.preventDefault(),null!==this._setZxcvbnResultTimeout&&(clearTimeout(this._setZxcvbnResultTimeout),this._setZxcvbnResultTimeout=null,await new Promise(e=>{this.setState({zxcvbnResult:Object(h.scorePassword)(this.state.passPhrase)},e)})),this._passPhraseIsValid()&&this.setState({phase:3})}),n()(this,"_onPassPhraseConfirmNextClick",async e=>{if(e.preventDefault(),this.state.passPhrase!==this.state.passPhraseConfirm)return;const[t,a]=await u.a.get().createRecoveryKeyFromPassphrase(this.state.passPhrase);this._keyInfo=t,this._encodedRecoveryKey=a,this.setState({copied:!1,downloaded:!1,phase:4})}),n()(this,"_onSetAgainClick",()=>{this.setState({passPhrase:"",passPhraseConfirm:"",phase:g,zxcvbnResult:null})}),n()(this,"_onKeepItSafeBackClick",()=>{this.setState({phase:4})}),n()(this,"_onPassPhraseCh