(window.webpackJsonp=window.webpackJsonp||[]).push([[7],{1536:function(e,t,a){"use strict";a.r(t),a.d(t,"default",(function(){return m}));var r,n=a(13),s=a.n(n),o=a(400),i=a.n(o),c=a(120),l=a.n(c),h=a(1),p=a(121),u=a(644),d=a(135),y=a(139);!function(e){e.Edit="edit",e.Exporting="exporting"}(r||(r={}));class m extends l.a.Component{constructor(e){super(e),s()(this,"unmounted",!1),s()(this,"onPassphraseFormSubmit",(e=>{e.preventDefault();const t=this.state.passphrase1;return t!==this.state.passphrase2?(this.setState({errStr:Object(p.a)("Passphrases must match")}),!1):t?(this.startExport(t),!1):(this.setState({errStr:Object(p.a)("Passphrase must not be empty")}),!1)})),s()(this,"onCancelClick",(e=>(e.preventDefault(),this.props.onFinished(!1),!1))),s()(this,"onPassphraseChange",((e,t)=>{this.setState({[t]:e.target.value})})),this.state={phase:r.Edit,errStr:null,passphrase1:"",passphrase2:""}}componentWillUnmount(){this.unmounted=!0}startExport(e){Promise.resolve().then((()=>this.props.matrixClient.exportRoomKeys())).then((t=>u.b(JSON.stringify(t),e))).then((e=>{const t=new Blob([e],{type:"text/plain;charset=us-ascii"});i.a.saveAs(t,"element-keys.txt"),this.props.onFinished(!0)})).catch((e=>{if(h.a.error("Error exporting e2e keys:",e),this.unmounted)return;const t=e.friendlyText||Object(p.a)("Unknown error");this.setState({errStr:t,phase:r.Edit})})),this.setState({errStr:null,phase:r.Exporting})}render(){const e=this.state.phase===r.Exporting;return l.a.createElement(d.a,{className:"mx_exportE2eKeysDialog",onFinished:this.props.onFinished,title:Object(p.a)("Export room keys")},l.a.createElement("form",{onSubmit:this.onPassphraseFormSubmit},l.a.createElement("div",{className:"mx_Dialog_content"},l.a.createElement("p",null,Object(p.a)("This process allows you to export the keys for messages you have received in encrypted rooms to a local file. You will then be able to import the file into another Matrix client in the future, so that client will also be able to decrypt these messages.")),l.a.createElement("p",null,Object(p.a)("The exported file will allow anyone who can read it to decrypt any encrypted messages that you can see, so you should be careful to keep it secure. To help with this, you should enter a passphrase below, which will be used to encrypt the exported data. It will only be possible to import the data by using the same passphrase.")),l.a.createElement("div",{className:"error"},this.state.errStr),l.a.createElement("div",{className:"mx_E2eKeysDialog_inputTable"},l.a.createElement("div",{className:"mx_E2eKeysDialog_inputRow"},l.a.createElement(y.a,{label:Object(p.a)("Enter passphrase"),value:this.state.passphrase1,onChange:e=>this.onPassphraseChange(e,"passphrase1"),autoFocus:!0,size:64,type:"password",disabled:e})),l.a.createElement("div",{className:"mx_E2eKeysDialog_inputRow"},l.a.createElement(y.a,{label:Object(p.a)("Confirm passphrase"),value:this.state.passphrase2,onChange:e=>this.onPassphraseChange(e,"passphrase2"),size:64,type:"password",disabled:e})))),l.a.createElement("div",{className:"mx_Dialog_buttons"},l.a.createElement("input",{className:"mx_Dialog_primary",type:"submit",value:Object(p.a)("Export"),disabled:e}),l.a.createElement("button",{onClick:this.onCancelClick,disabled:e},Object(p.a)("Cancel")))))}}},644:function(e,t,a){"use strict";a.d(t,"a",(function(){return l})),a.d(t,"b",(function(){return h}));var r=a(1),n=a(121),s=a(131);const o=window.crypto.subtle||window.crypto.webkitSubtle;function i(e,t){return{message:e,friendlyText:t}}function c(){return Object(n.a)("Your browser does not support the required cryptography extensions")}async function l(e,t){const a=function(e){const t=(new TextDecoder).decode(new Uint8Array(e));let a=0;for(;;){const e=t.indexOf("\n",a);if(e<0)throw new Error("Header line not found");const r=t.slice(a,e).trim();if(a=e+1,r===u)break}const r=a;for(;;){const e=t.indexOf("\n",a);if(t.slice(a,e<0?void 0:e).trim()===d)break;if(e<0)throw new Error("Trailer line not found");a=e+1}const n=a;return function(e){const t=window.atob(e),a=new Uint8Array(t.length);for(let e=0;e>24,g[E++]=r>>16&255,g[E++]=r>>8&255,g[E++]=255&r,g.set(b,E),E+=b.length;const x=g.subarray(0,E);let v;try{v=await o.sign({name:"HMAC"},h,x)}catch(e){throw i("subtleCrypto.sign failed: "+e,c())}const C=new Uint8Array(v);return g.set(C,E),function(e){const t=96,a=Math.ceil(e.length/t),r=new Array(a+3);r[0]=u;let n,s=0;for(n=1;n<=a;n++)r[n]=y(e.subarray(s,s+t)),s+=t;return r[n++]=d,r[n]="",(new TextEncoder).encode(r.join("\n")).buffer}(g)}async function p(e,t,a){const n=new Date;let s,l;try{s=await o.importKey("raw",(new TextEncoder).encode(a),{name:"PBKDF2"},!1,["deriveBits"])}catch(e){throw i("subtleCrypto.importKey failed: "+e,c())}try{l=await o.deriveBits({name:"PBKDF2",salt:e,iterations:t,hash:"SHA-512"},s,512)}catch(e){throw i("subtleCrypto.deriveBits failed: "+e,c())}const h=new Date;r.a.log("E2e import/export: deriveKeys took "+(h.getTime()-n.getTime())+"ms");const p=l.slice(0,32),u=l.slice(32),d=o.importKey("raw",p,{name:"AES-CTR"},!1,["encrypt","decrypt"]).catch((e=>{throw i("subtleCrypto.importKey failed for AES key: "+e,c())})),y=o.importKey("raw",u,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign","verify"]).catch((e=>{throw i("subtleCrypto.importKey failed for HMAC key: "+e,c())}));return Promise.all([d,y])}const u="-----BEGIN MEGOLM SESSION DATA-----",d="-----END MEGOLM SESSION DATA-----";function y(e){const t=String.fromCharCode.apply(null,Array.from(e));return window.btoa(t)}}}]); //# sourceMappingURL=7.js.map