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.
3 lines
15 KiB
3 lines
15 KiB
(window.webpackJsonp=window.webpackJsonp||[]).push([[1],{1022:function(e,t){e.exports=function(){throw new Error("define cannot be used indirect")}},1023:function(e,t){(function(t){e.exports=t}).call(this,{})},216:function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=p(a(41)),s=p(a(14)),r=a(9),o=p(a(0)),l=p(a(11)),i=p(a(5)),u=p(a(10)),c=a(518),d=p(a(510)),h=a(4);function p(e){return e&&e.__esModule?e:{default:e}}var f,m,y,v,_=0,k=5;t.default=(0,l.default)({displayName:"CreateKeyBackupDialog",getInitialState:function(){return{phase:_,passPhrase:"",passPhraseConfirm:"",copied:!1,downloaded:!1,zxcvbnResult:null,setPassPhrase:!1}},componentWillMount:function(){this._recoveryKeyNode=null,this._keyBackupInfo=null,this._setZxcvbnResultTimeout=null},componentWillUnmount:function(){null!==this._setZxcvbnResultTimeout&&clearTimeout(this._setZxcvbnResultTimeout)},_collectRecoveryKeyNode:function(e){this._recoveryKeyNode=e},_onCopyClick:function(){!function(e){var t=document.createRange();t.selectNodeContents(e);var a=window.getSelection();a.removeAllRanges(),a.addRange(t)}(this._recoveryKeyNode),document.execCommand("copy")&&this.setState({copied:!0,phase:3})},_onDownloadClick:function(){var e=new Blob([this._keyBackupInfo.recovery_key],{type:"text/plain;charset=us-ascii"});d.default.saveAs(e,"recovery-key.txt"),this.setState({downloaded:!0,phase:3})},_createBackup:(v=(0,r.coroutine)(s.default.mark((function e(){var t;return s.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.setState({phase:4,error:null}),t=void 0,e.prev=2,e.next=5,(0,r.resolve)(u.default.get().createKeyBackupVersion(this._keyBackupInfo));case 5:return t=e.sent,e.next=8,(0,r.resolve)(u.default.get().scheduleAllGroupSessionsForBackup());case 8:this.setState({phase:k}),e.next=16;break;case 11:e.prev=11,e.t0=e.catch(2),console.log("Error creating key backup",e.t0),t&&u.default.get().deleteKeyBackupVersion(t.version),this.setState({error:e.t0});case 16:case"end":return e.stop()}}),e,this,[[2,11]])}))),function(){return v.apply(this,arguments)}),_onCancel:function(){this.props.onFinished(!1)},_onDone:function(){this.props.onFinished(!0)},_onOptOutClick:function(){this.setState({phase:6})},_onSetUpClick:function(){this.setState({phase:_})},_onSkipPassPhraseClick:(y=(0,r.coroutine)(s.default.mark((function e(){return s.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,r.resolve)(u.default.get().prepareKeyBackupVersion());case 2:this._keyBackupInfo=e.sent,this.setState({copied:!1,downloaded:!1,phase:2});case 4:case"end":return e.stop()}}),e,this)}))),function(){return y.apply(this,arguments)}),_onPassPhraseNextClick:function(){this.setState({phase:1})},_onPassPhraseKeyPress:(m=(0,r.coroutine)(s.default.mark((function e(t){var a=this;return s.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("Enter"!==t.key){e.next=7;break}if(null===this._setZxcvbnResultTimeout){e.next=6;break}return clearTimeout(this._setZxcvbnResultTimeout),this._setZxcvbnResultTimeout=null,e.next=6,(0,r.resolve)(new n.default((function(e){a.setState({zxcvbnResult:(0,c.scorePassword)(a.state.passPhrase)},e)})));case 6:this._passPhraseIsValid()&&this._onPassPhraseNextClick();case 7:case"end":return e.stop()}}),e,this)}))),function(e){return m.apply(this,arguments)}),_onPassPhraseConfirmNextClick:(f=(0,r.coroutine)(s.default.mark((function e(){return s.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,r.resolve)(u.default.get().prepareKeyBackupVersion(this.state.passPhrase));case 2:this._keyBackupInfo=e.sent,this.setState({setPassPhrase:!0,copied:!1,downloaded:!1,phase:2});case 4:case"end":return e.stop()}}),e,this)}))),function(){return f.apply(this,arguments)}),_onPassPhraseConfirmKeyPress:function(e){"Enter"===e.key&&this.state.passPhrase===this.state.passPhraseConfirm&&this._onPassPhraseConfirmNextClick()},_onSetAgainClick:function(){this.setState({passPhrase:"",passPhraseConfirm:"",phase:_,zxcvbnResult:null})},_onKeepItSafeBackClick:function(){this.setState({phase:2})},_onPassPhraseChange:function(e){var t=this;this.setState({passPhrase:e.target.value}),null!==this._setZxcvbnResultTimeout&&clearTimeout(this._setZxcvbnResultTimeout),this._setZxcvbnResultTimeout=setTimeout((function(){t._setZxcvbnResultTimeout=null,t.setState({zxcvbnResult:(0,c.scorePassword)(t.state.passPhrase)})}),500)},_onPassPhraseConfirmChange:function(e){this.setState({passPhraseConfirm:e.target.value})},_passPhraseIsValid:function(){return this.state.zxcvbnResult&&this.state.zxcvbnResult.score>=4},_renderPhasePassPhrase:function(){var e=i.default.getComponent("views.elements.DialogButtons"),t=void 0,a=void 0;if(this.state.zxcvbnResult){if(this.state.zxcvbnResult.score>=4)a=(0,h._t)("Great! This passphrase looks strong enough.");else{for(var n=[],s=0;s<this.state.zxcvbnResult.feedback.suggestions.length;++s)n.push(o.default.createElement("div",{key:s},this.state.zxcvbnResult.feedback.suggestions[s]));var r=o.default.createElement("div",null,n.length>0?n:(0,h._t)("Keep going..."));a=o.default.createElement("div",null,this.state.zxcvbnResult.feedback.warning,r)}t=o.default.createElement("div",null,o.default.createElement("progress",{max:4,value:this.state.zxcvbnResult.score}))}return o.default.createElement("div",null,o.default.createElement("p",null,(0,h._t)("<b>Warning</b>: you should only set up key backup from a trusted computer.",{},{b:function(e){return o.default.createElement("b",null,e)}})),o.default.createElement("p",null,(0,h._t)("We'll store an encrypted copy of your keys on our server. Protect your backup with a passphrase to keep it secure.")),o.default.createElement("p",null,(0,h._t)("For maximum security, this should be different from your account password.")),o.default.createElement("div",{className:"mx_CreateKeyBackupDialog_primaryContainer"},o.default.createElement("div",{className:"mx_CreateKeyBackupDialog_passPhraseContainer"},o.default.createElement("input",{type:"password",onChange:this._onPassPhraseChange,onKeyPress:this._onPassPhraseKeyPress,value:this.state.passPhrase,className:"mx_CreateKeyBackupDialog_passPhraseInput",placeholder:(0,h._t)("Enter a passphrase..."),autoFocus:!0}),o.default.createElement("div",{className:"mx_CreateKeyBackupDialog_passPhraseHelp"},t,a))),o.default.createElement(e,{primaryButton:(0,h._t)("Next"),onPrimaryButtonClick:this._onPassPhraseNextClick,hasCancel:!1,disabled:!this._passPhraseIsValid()}),o.default.createElement("details",null,o.default.createElement("summary",null,(0,h._t)("Advanced")),o.default.createElement("p",null,o.default.createElement("button",{onClick:this._onSkipPassPhraseClick},(0,h._t)("Set up with a Recovery Key")))))},_renderPhasePassPhraseConfirm:function(){var e=i.default.getComponent("elements.AccessibleButton"),t=void 0;this.state.passPhraseConfirm===this.state.passPhrase?t=(0,h._t)("That matches!"):this.state.passPhrase.startsWith(this.state.passPhraseConfirm)||(t=(0,h._t)("That doesn't match."));var a=null;t&&(a=o.default.createElement("div",{className:"mx_CreateKeyBackupDialog_passPhraseMatch"},o.default.createElement("div",null,t),o.default.createElement("div",null,o.default.createElement(e,{element:"span",className:"mx_linkButton",onClick:this._onSetAgainClick},(0,h._t)("Go back to set it again.")))));var n=i.default.getComponent("views.elements.DialogButtons");return o.default.createElement("div",null,o.default.createElement("p",null,(0,h._t)("Please enter your passphrase a second time to confirm.")),o.default.createElement("div",{className:"mx_CreateKeyBackupDialog_primaryContainer"},o.default.createElement("div",{className:"mx_CreateKeyBackupDialog_passPhraseContainer"},o.default.createElement("div",null,o.default.createElement("input",{type:"password",onChange:this._onPassPhraseConfirmChange,onKeyPress:this._onPassPhraseConfirmKeyPress,value:this.state.passPhraseConfirm,className:"mx_CreateKeyBackupDialog_passPhraseInput",placeholder:(0,h._t)("Repeat your passphrase..."),autoFocus:!0})),a)),o.default.createElement(n,{primaryButton:(0,h._t)("Next"),onPrimaryButtonClick:this._onPassPhraseConfirmNextClick,hasCancel:!1,disabled:this.state.passPhrase!==this.state.passPhraseConfirm}))},_renderPhaseShowKey:function(){var e=void 0;return e=this.state.setPassPhrase?(0,h._t)("As a safety net, you can use it to restore your encrypted message history if you forget your Recovery Passphrase."):(0,h._t)("As a safety net, you can use it to restore your encrypted message history."),o.default.createElement("div",null,o.default.createElement("p",null,(0,h._t)("Your recovery key is a safety net - you can use it to restore access to your encrypted messages if you forget your passphrase.")),o.default.createElement("p",null,(0,h._t)("Keep your recovery key somewhere very secure, like a password manager (or a safe)")),o.default.createElement("p",null,e),o.default.createElement("div",{className:"mx_CreateKeyBackupDialog_primaryContainer"},o.default.createElement("div",{className:"mx_CreateKeyBackupDialog_recoveryKeyHeader"},(0,h._t)("Your Recovery Key")),o.default.createElement("div",{className:"mx_CreateKeyBackupDialog_recoveryKeyContainer"},o.default.createElement("div",{className:"mx_CreateKeyBackupDialog_recoveryKey"},o.default.createElement("code",{ref:this._collectRecoveryKeyNode},this._keyBackupInfo.recovery_key)),o.default.createElement("div",{className:"mx_CreateKeyBackupDialog_recoveryKeyButtons"},o.default.createElement("button",{className:"mx_Dialog_primary",onClick:this._onCopyClick},(0,h._t)("Copy to clipboard")),o.default.createElement("button",{className:"mx_Dialog_primary",onClick:this._onDownloadClick},(0,h._t)("Download"))))))},_renderPhaseKeepItSafe:function(){var e=void 0;this.state.copied?e=(0,h._t)("Your Recovery Key has been <b>copied to your clipboard</b>, paste it to:",{},{b:function(e){return o.default.createElement("b",null,e)}}):this.state.downloaded&&(e=(0,h._t)("Your Recovery Key is in your <b>Downloads</b> folder.",{},{b:function(e){return o.default.createElement("b",null,e)}}));var t=i.default.getComponent("views.elements.DialogButtons");return o.default.createElement("div",null,e,o.default.createElement("ul",null,o.default.createElement("li",null,(0,h._t)("<b>Print it</b> and store it somewhere safe",{},{b:function(e){return o.default.createElement("b",null,e)}})),o.default.createElement("li",null,(0,h._t)("<b>Save it</b> on a USB key or backup drive",{},{b:function(e){return o.default.createElement("b",null,e)}})),o.default.createElement("li",null,(0,h._t)("<b>Copy it</b> to your personal cloud storage",{},{b:function(e){return o.default.createElement("b",null,e)}}))),o.default.createElement(t,{primaryButton:(0,h._t)("OK"),onPrimaryButtonClick:this._createBackup,hasCancel:!1},o.default.createElement("button",{onClick:this._onKeepItSafeBackClick},(0,h._t)("Back"))))},_renderBusyPhase:function(e){var t=i.default.getComponent("views.elements.Spinner");return o.default.createElement("div",null,o.default.createElement(t,null))},_renderPhaseDone:function(){var e=i.default.getComponent("views.elements.DialogButtons");return o.default.createElement("div",null,o.default.createElement("p",null,(0,h._t)("Your keys are being backed up (the first backup could take a few minutes).")),o.default.createElement(e,{primaryButton:(0,h._t)("OK"),onPrimaryButtonClick:this._onDone,hasCancel:!1}))},_renderPhaseOptOutConfirm:function(){var e=i.default.getComponent("views.elements.DialogButtons");return o.default.createElement("div",null,(0,h._t)("Without setting up Secure Message Recovery, you won't be able to restore your encrypted message history if you log out or use another device."),o.default.createElement(e,{primaryButton:(0,h._t)("Set up Secure Message Recovery"),onPrimaryButtonClick:this._onSetUpClick,hasCancel:!1},o.default.createElement("button",{onClick:this._onCancel},"I understand, continue without")))},_titleForPhase:function(e){switch(e){case _:return(0,h._t)("Secure your backup with a passphrase");case 1:return(0,h._t)("Confirm your passphrase");case 6:return(0,h._t)("Warning!");case 2:return(0,h._t)("Recovery key");case 3:return(0,h._t)("Keep it safe");case 4:return(0,h._t)("Starting backup...");case k:return(0,h._t)("Success!");default:return(0,h._t)("Create Key Backup")}},render:function(){var e=i.default.getComponent("views.dialogs.BaseDialog"),t=void 0;if(this.state.error){var a=i.default.getComponent("views.elements.DialogButtons");t=o.default.createElement("div",null,o.default.createElement("p",null,(0,h._t)("Unable to create key backup")),o.default.createElement("div",{className:"mx_Dialog_buttons"},o.default.createElement(a,{primaryButton:(0,h._t)("Retry"),onPrimaryButtonClick:this._createBackup,hasCancel:!0,onCancel:this._onCancel})))}else switch(this.state.phase){case _: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 k:t=this._renderPhaseDone();break;case 6:t=this._renderPhaseOptOutConfirm()}return o.default.createElement(e,{className:"mx_CreateKeyBackupDialog",onFinished:this.props.onFinished,title:this._titleForPhase(this.state.phase),hasCancel:[_,k].includes(this.state.phase)},o.default.createElement("div",null,t))}}),e.exports=t.default},510:function(e,t,a){var n,s=s||function(e){"use strict";if(!(void 0===e||"undefined"!=typeof navigator&&/MSIE [1-9]\./.test(navigator.userAgent))){var t=e.document,a=function(){return e.URL||e.webkitURL||e},n=t.createElementNS("http://www.w3.org/1999/xhtml","a"),s="download"in n,r=/constructor/i.test(e.HTMLElement)||e.safari,o=/CriOS\/[\d]+/.test(navigator.userAgent),l=function(t){(e.setImmediate||e.setTimeout)((function(){throw t}),0)},i=function(e){setTimeout((function(){"string"==typeof e?a().revokeObjectURL(e):e.remove()}),4e4)},u=function(e){return/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob([String.fromCharCode(65279),e],{type:e.type}):e},c=function(t,c,d){d||(t=u(t));var h,p=this,f="application/octet-stream"===t.type,m=function(){!function(e,t,a){for(var n=(t=[].concat(t)).length;n--;){var s=e["on"+t[n]];if("function"==typeof s)try{s.call(e,a||e)}catch(e){l(e)}}}(p,"writestart progress write writeend".split(" "))};if(p.readyState=p.INIT,s)return h=a().createObjectURL(t),void setTimeout((function(){var e,t;n.href=h,n.download=c,e=n,t=new MouseEvent("click"),e.dispatchEvent(t),m(),i(h),p.readyState=p.DONE}));!function(){if((o||f&&r)&&e.FileReader){var n=new FileReader;return n.onloadend=function(){var t=o?n.result:n.result.replace(/^data:[^;]*;/,"data:attachment/file;");e.open(t,"_blank")||(e.location.href=t),t=void 0,p.readyState=p.DONE,m()},n.readAsDataURL(t),void(p.readyState=p.INIT)}(h||(h=a().createObjectURL(t)),f)?e.location.href=h:e.open(h,"_blank")||(e.location.href=h);p.readyState=p.DONE,m(),i(h)}()},d=c.prototype;return"undefined"!=typeof navigator&&navigator.msSaveOrOpenBlob?function(e,t,a){return t=t||e.name||"download",a||(e=u(e)),navigator.msSaveOrOpenBlob(e,t)}:(d.abort=function(){},d.readyState=d.INIT=0,d.WRITING=1,d.DONE=2,d.error=d.onwritestart=d.onprogress=d.onwrite=d.onabort=d.onerror=d.onwriteend=null,function(e,t,a){return new c(e,t||e.name||"download",a)})}}("undefined"!=typeof self&&self||"undefined"!=typeof window&&window||this.content);
|
|
/*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js */e.exports?e.exports.saveAs=s:null!==a(1022)&&null!==a(1023)&&(void 0===(n=function(){return s}.call(t,a,t,e))||(e.exports=n))}}]);
|
|
//# sourceMappingURL=1.js.map
|