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
7.0 KiB
2 lines
7.0 KiB
2 years ago
|
(window.webpackJsonp=window.webpackJsonp||[]).push([[34],{1566:function(e,t,r){"use strict";r.r(t),r.d(t,"default",(function(){return p}));var n,a=r(13),o=r.n(a),i=r(120),s=r.n(i),l=r(1),c=r(644),h=r(121),u=r(135),d=r(139);!function(e){e.Edit="edit",e.Importing="importing"}(n||(n={}));class p extends s.a.Component{constructor(e){super(e),o()(this,"unmounted",!1),o()(this,"file",Object(i.createRef)()),o()(this,"onFormChange",(()=>{var e;const t=null===(e=this.file.current)||void 0===e?void 0:e.files;this.setState({enableSubmit:""!==this.state.passphrase&&!(null==t||!t.length)})})),o()(this,"onPassphraseChange",(e=>{this.setState({passphrase:e.target.value}),this.onFormChange()})),o()(this,"onFormSubmit",(e=>{var t,r;e.preventDefault();const n=null===(t=this.file.current)||void 0===t||null===(r=t.files)||void 0===r?void 0:r[0];return n&&this.startImport(n,this.state.passphrase),!1})),o()(this,"onCancelClick",(e=>(e.preventDefault(),this.props.onFinished(!1),!1))),this.state={enableSubmit:!1,phase:n.Edit,errStr:null,passphrase:""}}componentWillUnmount(){this.unmounted=!0}startImport(e,t){return this.setState({errStr:null,phase:n.Importing}),function(e){return new Promise(((t,r)=>{const n=new FileReader;n.onload=e=>{var n;null!==(n=e.target)&&void 0!==n&&n.result?t(e.target.result):r(new Error("Failed to read file due to unknown error"))},n.onerror=r,n.readAsArrayBuffer(e)}))}(e).then((e=>c.a(e,t))).then((e=>this.props.matrixClient.importRoomKeys(JSON.parse(e)))).then((()=>{this.props.onFinished(!0)})).catch((e=>{if(l.a.error("Error importing e2e keys:",e),this.unmounted)return;const t=e.friendlyText||Object(h.a)("Unknown error");this.setState({errStr:t,phase:n.Edit})}))}render(){const e=this.state.phase!==n.Edit;return s.a.createElement(u.a,{className:"mx_importE2eKeysDialog",onFinished:this.props.onFinished,title:Object(h.a)("Import room keys")},s.a.createElement("form",{onSubmit:this.onFormSubmit},s.a.createElement("div",{className:"mx_Dialog_content"},s.a.createElement("p",null,Object(h.a)("This process allows you to import encryption keys that you had previously exported from another Matrix client. You will then be able to decrypt any messages that the other client could decrypt.")),s.a.createElement("p",null,Object(h.a)("The export file will be protected with a passphrase. You should enter the passphrase here, to decrypt the file.")),s.a.createElement("div",{className:"error"},this.state.errStr),s.a.createElement("div",{className:"mx_E2eKeysDialog_inputTable"},s.a.createElement("div",{className:"mx_E2eKeysDialog_inputRow"},s.a.createElement("div",{className:"mx_E2eKeysDialog_inputLabel"},s.a.createElement("label",{htmlFor:"importFile"},Object(h.a)("File to import"))),s.a.createElement("div",{className:"mx_E2eKeysDialog_inputCell"},s.a.createElement("input",{ref:this.file,id:"importFile",type:"file",autoFocus:!0,onChange:this.onFormChange,disabled:e}))),s.a.createElement("div",{className:"mx_E2eKeysDialog_inputRow"},s.a.createElement(d.a,{label:Object(h.a)("Enter passphrase"),value:this.state.passphrase,onChange:this.onPassphraseChange,size:64,type:"password",disabled:e})))),s.a.createElement("div",{className:"mx_Dialog_buttons"},s.a.createElement("input",{className:"mx_Dialog_primary",type:"submit",value:Object(h.a)("Import"),disabled:!this.state.enableSubmit||e}),s.a.createElement("button",{onClick:this.onCancelClick,disabled:e},Object(h.a)("Cancel")))))}}},644:function(e,t,r){"use strict";r.d(t,"a",(function(){return c})),r.d(t,"b",(function(){return h}));var n=r(1),a=r(121),o=r(131);const i=window.crypto.subtle||window.crypto.webkitSubtle;function s(e,t){return{message:e,friendlyText:t}}function l(){return Object(a.a)("Your browser does not support the required cryptography extensions")}async function c(e,t){const r=function(e){const t=(new TextDecoder).decode(new Uint8Array(e));let r=0;for(;;){const e=t.indexOf("\n",r);if(e<0)throw new Error("Header line not found");const n=t.slice(r,e).trim();if(r=e+1,n===d)break}const n=r;for(;;){const e=t.indexOf("\n",r);if(t.slice(r,e<0?void 0:e).trim()===p)break;if(e<0)throw
|
||
|
//# sourceMappingURL=34.js.map
|