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
13 KiB

(window.webpackJsonp=window.webpackJsonp||[]).push([[4],{1321:function(e,t,a){"use strict";a.r(t),a.d(t,"default",(function(){return C}));var s=a(83),n=a.n(s),r=a(82),o=a.n(r),i=a(289),c=a.n(i),l=a(86),u=a(87),h=a(85),p=a.n(h),m=a(84),d=a(165),y=a(92),b=a(340),f=a(288);const k=0,_=5;class C extends o.a.PureComponent{constructor(e){super(e),n()(this,"_collectRecoveryKeyNode",e=>{this._recoveryKeyNode=e}),n()(this,"_onCopyClick",()=>{Object(b.a)(this._recoveryKeyNode)&&this.setState({copied:!0,phase:3})}),n()(this,"_onDownloadClick",()=>{const e=new Blob([this._keyBackupInfo.recovery_key],{type:"text/plain;charset=us-ascii"});c.a.saveAs(e,"security-key.txt"),this.setState({downloaded:!0,phase:3})}),n()(this,"_createBackup",async()=>{const{secureSecretStorage:e}=this.state;let t;this.setState({phase:4,error:null});try{e?await Object(d.b)(async()=>{t=await u.a.get().prepareKeyBackupVersion(null,{secureSecretStorage:!0}),t=await u.a.get().createKeyBackupVersion(t)}):t=await u.a.get().createKeyBackupVersion(this._keyBackupInfo),await u.a.get().scheduleAllGroupSessionsForBackup(),this.setState({phase:_})}catch(e){console.error("Error creating key backup",e),t&&u.a.get().deleteKeyBackupVersion(t.version),this.setState({error:e})}}),n()(this,"_onCancel",()=>{this.props.onFinished(!1)}),n()(this,"_onDone",()=>{this.props.onFinished(!0)}),n()(this,"_onOptOutClick",()=>{this.setState({phase:6})}),n()(this,"_onSetUpClick",()=>{this.setState({phase:k})}),n()(this,"_onSkipPassPhraseClick",async()=>{this._keyBackupInfo=await u.a.get().prepareKeyBackupVersion(),this.setState({copied:!1,downloaded:!1,phase:2})}),n()(this,"_onPassPhraseNextClick",async e=>{if(e.preventDefault(),this._passphraseField.current){if(await this._passphraseField.current.validate({allowEmpty:!1}),!this._passphraseField.current.state.valid)return this._passphraseField.current.focus(),void this._passphraseField.current.validate({allowEmpty:!1,focused:!0});this.setState({phase:1})}}),n()(this,"_onPassPhraseConfirmNextClick",async e=>{e.preventDefault(),this.state.passPhrase===this.state.passPhraseConfirm&&(this._keyBackupInfo=await u.a.get().prepareKeyBackupVersion(this.state.passPhrase),this.setState({copied:!1,downloaded:!1,phase:2}))}),n()(this,"_onSetAgainClick",()=>{this.setState({passPhrase:"",passPhraseValid:!1,passPhraseConfirm:"",phase:k})}),n()(this,"_onKeepItSafeBackClick",()=>{this.setState({phase:2})}),n()(this,"_onPassPhraseValidate",e=>{this.setState({passPhraseValid:e.valid})}),n()(this,"_onPassPhraseChange",e=>{this.setState({passPhrase:e.target.value})}),n()(this,"_onPassPhraseConfirmChange",e=>{this.setState({passPhraseConfirm:e.target.value})}),this._recoveryKeyNode=null,this._keyBackupInfo=null,this.state={secureSecretStorage:null,phase:k,passPhrase:"",passPhraseValid:!1,passPhraseConfirm:"",copied:!1,downloaded:!1},this._passphraseField=Object(r.createRef)()}async componentDidMount(){const e=u.a.get(),t=await e.doesServerSupportUnstableFeature("org.matrix.e2e_cross_signing");this.setState({secureSecretStorage:t}),t&&(this.setState({phase:4}),this._createBackup())}_renderPhasePassPhrase(){const e=l.getComponent("views.elements.DialogButtons");return o.a.createElement("form",{onSubmit:this._onPassPhraseNextClick},o.a.createElement("p",null,Object(m.a)("<b>Warning</b>: You should only set up key backup from a trusted computer.",{},{b:e=>o.a.createElement("b",null,e)})),o.a.createElement("p",null,Object(m.a)("We'll store an encrypted copy of your keys on our server. Secure your backup with a Security Phrase.")),o.a.createElement("p",null,Object(m.a)("For maximum security, this should be different from your account password.")),o.a.createElement("div",{className:"mx_CreateKeyBackupDialog_primaryContainer"},o.a.createElement("div",{className:"mx_CreateKeyBackupDialog_passPhraseContainer"},o.a.createElement(f.a,{className:"mx_CreateKeyBackupDialog_passPhraseInput",onChange:this._onPassPhraseChange,minScore:4,value:this.state.passPhrase,onValidate:this._onPassPhraseValidate,fieldRef:this._passphraseField,autoFocus:!0,label:Object(m.b)("Enter a Security Phrase"),labelEnterPassword:Object(m.b)("Enter a Security Phrase"),labelStrongPassword:Object(m.b)("Great! This Security Phrase looks strong enough."),labelAllowedButUnsafe:Object(m.b)("Great! This Security Phrase looks strong enough.")}))),o.a.createElement(e,{primaryButton:Object(m.a)("Next"),onPrimaryButtonClick:this._onPassPhraseNextClick,hasCancel:!1,disabled:!this.state.passPhraseValid}),o.a.createElement("details",null,o.a.createElement("summary",null,Object(m.a)("Advanced")),o.a.createElement(y.a,{kind:"primary",onClick:this._onSkipPassPhraseClick},Object(m.a)("Set up with a Security Key"))))}_renderPhasePassPhraseConfirm(){const e=l.getComponent("elements.AccessibleButton");let t,a;this.state.passPhraseConfirm===this.state.passPhrase?(t=Object(m.a)("That matches!"),a=Object(m.a)("Use a different passphrase?")):this.state.passPhrase.startsWith(this.state.passPhraseConfirm)||(t=Object(m.a)("That doesn't match."),a=Object(m.a)("Go back to set it again."));let s=null;t&&(s=o.a.createElement("div",{className:"mx_CreateKeyBackupDialog_passPhraseMatch"},o.a.createElement("div",null,t),o.a.createElement("div",null,o.a.createElement(e,{element:"span",className:"mx_linkButton",onClick:this._onSetAgainClick},a))));const n=l.getComponent("views.elements.DialogButtons");return o.a.createElement("form",{onSubmit:this._onPassPhraseConfirmNextClick},o.a.createElement("p",null,Object(m.a)("Please enter your Security Phrase a second time to confirm.")),o.a.createElement("div",{className:"mx_CreateKeyBackupDialog_primaryContainer"},o.a.createElement("div",{className:"mx_CreateKeyBackupDialog_passPhraseContainer"},o.a.createElement("div",null,o.a.createElement("input",{type:"password",onChange:this._onPassPhraseConfirmChange,value:this.state.passPhraseConfirm,className:"mx_CreateKeyBackupDialog_passPhraseInput",placeholder:Object(m.a)("Repeat your Security Phrase..."),autoFocus:!0})),s)),o.a.createElement(n,{primaryButton:Object(m.a)("Next"),onPrimaryButtonClick:this._onPassPhraseConfirmNextClick,hasCancel:!1,disabled:this.state.passPhrase!==this.state.passPhraseConfirm}))}_renderPhaseShowKey(){return o.a.createElement("div",null,o.a.createElement("p",null,Object(m.a)("Your Security Key is a safety net - you can use it to restore access to your encrypted messages if you forget your Security Phrase.")),o.a.createElement("p",null,Object(m.a)("Keep a copy of it somewhere secure, like a password manager or even a safe.")),o.a.createElement("div",{className:"mx_CreateKeyBackupDialog_primaryContainer"},o.a.createElement("div",{className:"mx_CreateKeyBackupDialog_recoveryKeyHeader"},Object(m.a)("Your Security Key")),o.a.createElement("div",{className:"mx_CreateKeyBackupDialog_recoveryKeyContainer"},o.a.createElement("div",{className:"mx_CreateKeyBackupDialog_recoveryKey"},o.a.createElement("code",{ref:this._collectRecoveryKeyNode},this._keyBackupInfo.recovery_key)),o.a.createElement("div",{className:"mx_CreateKeyBackupDialog_recoveryKeyButtons"},o.a.createElement("button",{className:"mx_Dialog_primary",onClick:this._onCopyClick},Object(m.a)("Copy")),o.a.createElement("button",{className:"mx_Dialog_primary",onClick:this._onDownloadClick},Object(m.a)("Download"))))))}_renderPhaseKeepItSafe(){let e;this.state.copied?e=Object(m.a)("Your Security Key has been <b>copied to your clipboard</b>, paste it to:",{},{b:e=>o.a.createElement("b",null,e)}):this.state.downloaded&&(e=Object(m.a)("Your Security Key is in your <b>Downloads</b> folder.",{},{b:e=>o.a.createElement("b",null,e)}));const t=l.getComponent("views.elements.DialogButtons");return o.a.createElement("div",null,e,o.a.createElement("ul",null,o.a.createElement("li",null,Object(m.a)("<b>Print it</b> and store it somewhere safe",{},{b:e=>o.a.createElement("b",null,e)})),o.a.createElement("li",null,Object(m.a)("<b>Save it</b> on a USB key or backup drive",{},{b:e=>o.a.createElement("b",null,e)})),o.a.createElement("li",null,Object(m.a)("<b>Copy it</b> to your personal cloud storage",{},{b:e=>o.a.createElement("b",null,e)}))),o.a.createElement(t,{primaryButton:Object(m.a)("Continue"),onPrimaryButtonClick:this._createBackup,hasCancel:!1},o.a.createElement("button",{onClick:this._onKeepItSafeBackClick},Object(m.a)("Back"))))}_renderBusyPhase(e){const t=l.getComponent("views.elements.Spinner");return o.a.createElement("div",null,o.a.createElement(t,null))}_renderPhaseDone(){const e=l.getComponent("views.elements.DialogButtons");return o.a.createElement("div",null,o.a.createElement("p",null,Object(m.a)("Your keys are being backed up (the first backup could take a few minutes).")),o.a.createElement(e,{primaryButton:Object(m.a)("OK"),onPrimaryButtonClick:this._onDone,hasCancel:!1}))}_renderPhaseOptOutConfirm(){const e=l.getComponent("views.elements.DialogButtons");return o.a.createElement("div",null,Object(m.a)("Without setting up Secure Message Recovery, you won't be able to restore your encrypted message history if you log out or use another session."),o.a.createElement(e,{primaryButton:Object(m.a)("Set up Secure Message Recovery"),onPrimaryButtonClick:this._onSetUpClick,hasCancel:!1},o.a.createElement("button",{onClick:this._onCancel},"I understand, continue without")))}_titleForPhase(e){switch(e){case k:return Object(m.a)("Secure your backup with a Security Phrase");case 1:return Object(m.a)("Confirm your Security Phrase");case 6:return Object(m.a)("Warning!");case 2:case 3:return Object(m.a)("Make a copy of your Security Key");case 4:return Object(m.a)("Starting backup...");case _:return Object(m.a)("Success!");default:return Object(m.a)("Create key backup")}}render(){const e=l.getComponent("views.dialogs.BaseDialog");let t;if(this.state.error){const e=l.getComponent("views.elements.DialogButtons");t=o.a.createElement("div",null,o.a.createElement("p",null,Object(m.a)("Unable to create key backup")),o.a.createElement("div",{className:"mx_Dialog_buttons"},o.a.createElement(e,{primaryButton:Object(m.a)("Retry"),onPrimaryButtonClick:this._createBackup,hasCancel:!0,onCancel:this._onCancel})))}else switch(this.state.phase){case k:t=this._renderPhasePassPhrase();break;case 1:t=this._renderPhasePassPhraseConfirm();break;case 2:t=this._renderPhaseShowKey();break;case 3:t=this._renderPhaseKeepItSafe();break;case 4:t=this._renderBusyPhase();break;case _:t=this._renderPhaseDone();break;case 6:t=this._renderPhaseOptOutConfirm()}return o.a.createElement(e,{className:"mx_CreateKeyBackupDialog",onFinished:this.props.onFinished,title:this._titleForPhase(this.state.phase),hasCancel:[k,_].includes(this.state.phase)},o.a.createElement("div",null,t))}}n()(C,"propTypes",{onFinished:p.a.func.isRequired})},289:function(e,t,a){(function(a){var s,n,r;n=[],void 0===(r="function"==typeof(s=function(){"use strict";function t(e,t,a){var s=new XMLHttpRequest;s.open("GET",e),s.responseType="blob",s.onload=function(){i(s.response,t,a)},s.onerror=function(){console.error("could not download file")},s.send()}function s(e){var t=new XMLHttpRequest;t.open("HEAD",e,!1);try{t.send()}catch(e){}return 200<=t.status&&299>=t.status}function n(e){try{e.dispatchEvent(new MouseEvent("click"))}catch(a){var t=document.createEvent("MouseEvents");t.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),e.dispatchEvent(t)}}var r="object"==typeof window&&window.window===window?window:"object"==typeof self&&self.self===self?self:"object"==typeof a&&a.global===a?a:void 0,o=r.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),i=r.saveAs||("object"!=typeof window||window!==r?function(){}:"download"in HTMLAnchorElement.prototype&&!o?function(e,a,o){var i=r.URL||r.webkitURL,c=document.createElement("a");a=a||e.name||"download",c.download=a,c.rel="noopener","string"==typeof e?(c.href=e,c.origin===location.origin?n(c):s(c.href)?t(e,a,o):n(c,c.target="_blank")):(c.href=i.createObjectURL(e),setTimeout((function(){i.revokeObjectURL(c.href)}),4e4),setTimeout((function(){n(c)}),0))}:"msSaveOrOpenBlob"in navigator?function(e,a,r){if(a=a||e.name||"download","string"!=typeof e)navigator.msSaveOrOpenBlob(function(e,t){return void 0===t?t={autoBom:!1}:"object"!=typeof t&&(console.warn("Deprecated: Expected third argument to be a object"),t={autoBom:!t}),t.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob(["\ufeff",e],{type:e.type}):e}(e,r),a);else if(s(e))t(e,a,r);else{var o=document.createElement("a");o.href=e,o.target="_blank",setTimeout((function(){n(o)}))}}:function(e,a,s,n){if((n=n||open("","_blank"))&&(n.document.title=n.document.body.innerText="downloading..."),"string"==typeof e)return t(e,a,s);var i="application/octet-stream"===e.type,c=/constructor/i.test(r.HTMLElement)||r.safari,l=/CriOS\/[\d]+/.test(navigator.userAgent);if((l||i&&c||o)&&"undefined"!=typeof FileReader){var u=new FileReader;u.onloadend=function(){var e=u.result;e=l?e:e.replace(/^data:[^;]*;/,"data:attachment/file;"),n?n.location.href=e:location=e,n=null},u.readAsDataURL(e)}else{var h=r.URL||r.webkitURL,p=h.createObjectURL(e);n?n.location=p:location.href=p,n=null,setTimeout((function(){h.revokeObjectURL(p)}),4e4)}});r.saveAs=i.saveAs=i,e.exports=i})?s.apply(t,n):s)||(e.exports=r)}).call(this,a(5))}}]);
//# sourceMappingURL=4.js.map