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.
1 line
24 KiB
1 line
24 KiB
{"version":3,"sources":["(webpack)/buildin/amd-define.js","node_modules/matrix-react-sdk/lib/async-components/views/dialogs/ExportE2eKeysDialog.js","node_modules/file-saver/FileSaver.js"],"names":["module","exports","Error","Object","defineProperty","value","_stringify2","_interopRequireDefault","__webpack_require__","_promise2","_fileSaver2","_react2","_propTypes2","_languageHandler","Matrix","_interopRequireWildcard","MegolmExportEncryption","_index2","obj","__esModule","newObj","key","prototype","hasOwnProperty","call","default","createClass","displayName","propTypes","matrixClient","instanceOf","MatrixClient","isRequired","onFinished","func","getInitialState","phase","errStr","componentWillMount","this","_unmounted","componentWillUnmount","_onPassphraseFormSubmit","ev","preventDefault","passphrase","refs","passphrase1","passphrase2","setState","_t","_startExport","_this","resolve","then","props","exportRoomKeys","k","encryptMegolmKeyFile","f","blob","Blob","type","saveAs","catch","e","console","error","msg","friendlyText","_onCancelClick","render","BaseDialog","getComponent","disableForm","state","createElement","className","title","onSubmit","htmlFor","ref","id","autoFocus","size","disabled","onClick","__WEBPACK_AMD_DEFINE_RESULT__","view","navigator","test","userAgent","doc","document","get_URL","URL","webkitURL","save_link","createElementNS","can_use_save_link","is_safari","HTMLElement","safari","is_chrome_ios","throw_outside","ex","setImmediate","setTimeout","revoke","file","revokeObjectURL","remove","auto_bom","String","fromCharCode","FileSaver","name","no_auto_bom","object_url","filesaver","force","dispatch_all","event_types","event","i","concat","length","listener","dispatch","split","readyState","INIT","createObjectURL","node","href","download","MouseEvent","dispatchEvent","DONE","FileReader","reader","onloadend","url","result","replace","open","location","undefined","readAsDataURL","fs_error","FS_proto","msSaveOrOpenBlob","abort","WRITING","onwritestart","onprogress","onwrite","onabort","onerror","onwriteend","self","window","content"],"mappings":"4EAAAA,EAAAC,QAAA,WACA,UAAAC,MAAA,qECCAC,OAAAC,eAAAH,EAAA,cACAI,OAAA,IAGA,IAEAC,EAAAC,EAFiBC,EAA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AAW,WAAAX,EAAAY,MAIAb,IACAA,EAAAxB,IAAAsC,gBAAAxE,IAEA4D,EACAhC,EAAA0D,SAAAZ,KAAAhB,EAEA9B,EAAAyD,KAAA3B,EAAA,YAGA9B,EAAA0D,SAAAZ,KAAAhB,GAGAC,EAAAW,WAAAX,EAAAmB,KACAjB,IACAb,EAAAU,GAkBA+B,IAEAC,EAAAnC,EAAA7F,UAMA,0BAAAmE,qBAAA8D,iBACA,SAAA3F,EAAAwD,EAAAC,GAMA,OALAD,KAAAxD,EAAAwD,MAAA,WAEAC,IACAzD,EAAAoD,EAAApD,IAEA6B,UAAA8D,iBAAA3F,EAAAwD,KAIAkC,EAAAE,MAAA,aACAF,EAAApB,WAAAoB,EAAAnB,KAAA,EACAmB,EAAAG,QAAA,EACAH,EAAAZ,KAAA,EAEAY,EAAAnF,MACAmF,EAAAI,aACAJ,EAAAK,WACAL,EAAAM,QACAN,EAAAO,QACAP,EAAAQ,QACAR,EAAAS,WACA,KA5BA,SAAAnG,EAAAwD,EAAAC,GACA,WAAAF,EAAAvD,EAAAwD,GAAAxD,EAAAwD,MAAA,WAAAC,MA/HA,CA8JA,oBAAA2C,YACA,oBAAAC,gBACA1H,KAAA2H;mFAMiClK,EAAAC,QACjCD,EAAAC,QAAA8D,SACmD,OAANvD,EAAA,OAA+B,OAAVA,EAAA,YAG/D2I,KAFD5D,EAAA,WACF,OAAAxB,GACGvC,KAAAvB,EAAAO,EAAAP,EAAAD,QAAAC,QAAAsF","file":"bundles/e9b8313cd5591059cfdc/3.js","sourcesContent":["module.exports = function() {\n\tthrow new Error(\"define cannot be used indirect\");\n};\n","'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _stringify = require('babel-runtime/core-js/json/stringify');\n\nvar _stringify2 = _interopRequireDefault(_stringify);\n\nvar _promise = require('babel-runtime/core-js/promise');\n\nvar _promise2 = _interopRequireDefault(_promise);\n\nvar _fileSaver = require('file-saver');\n\nvar _fileSaver2 = _interopRequireDefault(_fileSaver);\n\nvar _react = require('react');\n\nvar _react2 = _interopRequireDefault(_react);\n\nvar _propTypes = require('prop-types');\n\nvar _propTypes2 = _interopRequireDefault(_propTypes);\n\nvar _languageHandler = require('../../../languageHandler');\n\nvar _matrixJsSdk = require('matrix-js-sdk');\n\nvar Matrix = _interopRequireWildcard(_matrixJsSdk);\n\nvar _MegolmExportEncryption = require('../../../utils/MegolmExportEncryption');\n\nvar MegolmExportEncryption = _interopRequireWildcard(_MegolmExportEncryption);\n\nvar _index = require('../../../index');\n\nvar _index2 = _interopRequireDefault(_index);\n\nfunction _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nvar PHASE_EDIT = 1; /*\n Copyright 2017 Vector Creations Ltd\n \n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n \n http://www.apache.org/licenses/LICENSE-2.0\n \n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n */\n\nvar PHASE_EXPORTING = 2;\n\nexports.default = _react2.default.createClass({\n displayName: 'ExportE2eKeysDialog',\n\n propTypes: {\n matrixClient: _propTypes2.default.instanceOf(Matrix.MatrixClient).isRequired,\n onFinished: _propTypes2.default.func.isRequired\n },\n\n getInitialState: function getInitialState() {\n return {\n phase: PHASE_EDIT,\n errStr: null\n };\n },\n\n componentWillMount: function componentWillMount() {\n this._unmounted = false;\n },\n\n componentWillUnmount: function componentWillUnmount() {\n this._unmounted = true;\n },\n\n _onPassphraseFormSubmit: function _onPassphraseFormSubmit(ev) {\n ev.preventDefault();\n\n var passphrase = this.refs.passphrase1.value;\n if (passphrase !== this.refs.passphrase2.value) {\n this.setState({ errStr: (0, _languageHandler._t)('Passphrases must match') });\n return false;\n }\n if (!passphrase) {\n this.setState({ errStr: (0, _languageHandler._t)('Passphrase must not be empty') });\n return false;\n }\n\n this._startExport(passphrase);\n return false;\n },\n\n _startExport: function _startExport(passphrase) {\n var _this = this;\n\n // extra Promise.resolve() to turn synchronous exceptions into\n // asynchronous ones.\n _promise2.default.resolve().then(function () {\n return _this.props.matrixClient.exportRoomKeys();\n }).then(function (k) {\n return MegolmExportEncryption.encryptMegolmKeyFile((0, _stringify2.default)(k), passphrase);\n }).then(function (f) {\n var blob = new Blob([f], {\n type: 'text/plain;charset=us-ascii'\n });\n _fileSaver2.default.saveAs(blob, 'riot-keys.txt');\n _this.props.onFinished(true);\n }).catch(function (e) {\n console.error(\"Error exporting e2e keys:\", e);\n if (_this._unmounted) {\n return;\n }\n var msg = e.friendlyText || (0, _languageHandler._t)('Unknown error');\n _this.setState({\n errStr: msg,\n phase: PHASE_EDIT\n });\n });\n\n this.setState({\n errStr: null,\n phase: PHASE_EXPORTING\n });\n },\n\n _onCancelClick: function _onCancelClick(ev) {\n ev.preventDefault();\n this.props.onFinished(false);\n return false;\n },\n\n render: function render() {\n var BaseDialog = _index2.default.getComponent('views.dialogs.BaseDialog');\n\n var disableForm = this.state.phase === PHASE_EXPORTING;\n\n return _react2.default.createElement(\n BaseDialog,\n { className: 'mx_exportE2eKeysDialog',\n onFinished: this.props.onFinished,\n title: (0, _languageHandler._t)(\"Export room keys\")\n },\n _react2.default.createElement(\n 'form',\n { onSubmit: this._onPassphraseFormSubmit },\n _react2.default.createElement(\n 'div',\n { className: 'mx_Dialog_content' },\n _react2.default.createElement(\n 'p',\n null,\n (0, _languageHandler._t)('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.')\n ),\n _react2.default.createElement(\n 'p',\n null,\n (0, _languageHandler._t)('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.')\n ),\n _react2.default.createElement(\n 'div',\n { className: 'error' },\n this.state.errStr\n ),\n _react2.default.createElement(\n 'div',\n { className: 'mx_E2eKeysDialog_inputTable' },\n _react2.default.createElement(\n 'div',\n { className: 'mx_E2eKeysDialog_inputRow' },\n _react2.default.createElement(\n 'div',\n { className: 'mx_E2eKeysDialog_inputLabel' },\n _react2.default.createElement(\n 'label',\n { htmlFor: 'passphrase1' },\n (0, _languageHandler._t)(\"Enter passphrase\")\n )\n ),\n _react2.default.createElement(\n 'div',\n { className: 'mx_E2eKeysDialog_inputCell' },\n _react2.default.createElement('input', { ref: 'passphrase1', id: 'passphrase1',\n autoFocus: true, size: '64', type: 'password',\n disabled: disableForm\n })\n )\n ),\n _react2.default.createElement(\n 'div',\n { className: 'mx_E2eKeysDialog_inputRow' },\n _react2.default.createElement(\n 'div',\n { className: 'mx_E2eKeysDialog_inputLabel' },\n _react2.default.createElement(\n 'label',\n { htmlFor: 'passphrase2' },\n (0, _languageHandler._t)(\"Confirm passphrase\")\n )\n ),\n _react2.default.createElement(\n 'div',\n { className: 'mx_E2eKeysDialog_inputCell' },\n _react2.default.createElement('input', { ref: 'passphrase2', id: 'passphrase2',\n size: '64', type: 'password',\n disabled: disableForm\n })\n )\n )\n )\n ),\n _react2.default.createElement(\n 'div',\n { className: 'mx_Dialog_buttons' },\n _react2.default.createElement('input', { className: 'mx_Dialog_primary', type: 'submit', value: (0, _languageHandler._t)('Export'),\n disabled: disableForm\n }),\n _react2.default.createElement(\n 'button',\n { onClick: this._onCancelClick, disabled: disableForm },\n (0, _languageHandler._t)(\"Cancel\")\n )\n )\n )\n );\n }\n});\nmodule.exports = exports['default'];\n//# sourceMappingURL=ExportE2eKeysDialog.js.map","/* FileSaver.js\n * A saveAs() FileSaver implementation.\n * 1.3.2\n * 2016-06-16 18:25:19\n *\n * By Eli Grey, http://eligrey.com\n * License: MIT\n * See https://github.com/eligrey/FileSaver.js/blob/master/LICENSE.md\n */\n\n/*global self */\n/*jslint bitwise: true, indent: 4, laxbreak: true, laxcomma: true, smarttabs: true, plusplus: true */\n\n/*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js */\n\nvar saveAs = saveAs || (function(view) {\n\t\"use strict\";\n\t// IE <10 is explicitly unsupported\n\tif (typeof view === \"undefined\" || typeof navigator !== \"undefined\" && /MSIE [1-9]\\./.test(navigator.userAgent)) {\n\t\treturn;\n\t}\n\tvar\n\t\t doc = view.document\n\t\t // only get URL when necessary in case Blob.js hasn't overridden it yet\n\t\t, get_URL = function() {\n\t\t\treturn view.URL || view.webkitURL || view;\n\t\t}\n\t\t, save_link = doc.createElementNS(\"http://www.w3.org/1999/xhtml\", \"a\")\n\t\t, can_use_save_link = \"download\" in save_link\n\t\t, click = function(node) {\n\t\t\tvar event = new MouseEvent(\"click\");\n\t\t\tnode.dispatchEvent(event);\n\t\t}\n\t\t, is_safari = /constructor/i.test(view.HTMLElement) || view.safari\n\t\t, is_chrome_ios =/CriOS\\/[\\d]+/.test(navigator.userAgent)\n\t\t, throw_outside = function(ex) {\n\t\t\t(view.setImmediate || view.setTimeout)(function() {\n\t\t\t\tthrow ex;\n\t\t\t}, 0);\n\t\t}\n\t\t, force_saveable_type = \"application/octet-stream\"\n\t\t// the Blob API is fundamentally broken as there is no \"downloadfinished\" event to subscribe to\n\t\t, arbitrary_revoke_timeout = 1000 * 40 // in ms\n\t\t, revoke = function(file) {\n\t\t\tvar revoker = function() {\n\t\t\t\tif (typeof file === \"string\") { // file is an object URL\n\t\t\t\t\tget_URL().revokeObjectURL(file);\n\t\t\t\t} else { // file is a File\n\t\t\t\t\tfile.remove();\n\t\t\t\t}\n\t\t\t};\n\t\t\tsetTimeout(revoker, arbitrary_revoke_timeout);\n\t\t}\n\t\t, dispatch = function(filesaver, event_types, event) {\n\t\t\tevent_types = [].concat(event_types);\n\t\t\tvar i = event_types.length;\n\t\t\twhile (i--) {\n\t\t\t\tvar listener = filesaver[\"on\" + event_types[i]];\n\t\t\t\tif (typeof listener === \"function\") {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tlistener.call(filesaver, event || filesaver);\n\t\t\t\t\t} catch (ex) {\n\t\t\t\t\t\tthrow_outside(ex);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t, auto_bom = function(blob) {\n\t\t\t// prepend BOM for UTF-8 XML and text/* types (including HTML)\n\t\t\t// note: your browser will automatically convert UTF-16 U+FEFF to EF BB BF\n\t\t\tif (/^\\s*(?:text\\/\\S*|application\\/xml|\\S*\\/\\S*\\+xml)\\s*;.*charset\\s*=\\s*utf-8/i.test(blob.type)) {\n\t\t\t\treturn new Blob([String.fromCharCode(0xFEFF), blob], {type: blob.type});\n\t\t\t}\n\t\t\treturn blob;\n\t\t}\n\t\t, FileSaver = function(blob, name, no_auto_bom) {\n\t\t\tif (!no_auto_bom) {\n\t\t\t\tblob = auto_bom(blob);\n\t\t\t}\n\t\t\t// First try a.download, then web filesystem, then object URLs\n\t\t\tvar\n\t\t\t\t filesaver = this\n\t\t\t\t, type = blob.type\n\t\t\t\t, force = type === force_saveable_type\n\t\t\t\t, object_url\n\t\t\t\t, dispatch_all = function() {\n\t\t\t\t\tdispatch(filesaver, \"writestart progress write writeend\".split(\" \"));\n\t\t\t\t}\n\t\t\t\t// on any filesys errors revert to saving with object URLs\n\t\t\t\t, fs_error = function() {\n\t\t\t\t\tif ((is_chrome_ios || (force && is_safari)) && view.FileReader) {\n\t\t\t\t\t\t// Safari doesn't allow downloading of blob urls\n\t\t\t\t\t\tvar reader = new FileReader();\n\t\t\t\t\t\treader.onloadend = function() {\n\t\t\t\t\t\t\tvar url = is_chrome_ios ? reader.result : reader.result.replace(/^data:[^;]*;/, 'data:attachment/file;');\n\t\t\t\t\t\t\tvar popup = view.open(url, '_blank');\n\t\t\t\t\t\t\tif(!popup) view.location.href = url;\n\t\t\t\t\t\t\turl=undefined; // release reference before dispatching\n\t\t\t\t\t\t\tfilesaver.readyState = filesaver.DONE;\n\t\t\t\t\t\t\tdispatch_all();\n\t\t\t\t\t\t};\n\t\t\t\t\t\treader.readAsDataURL(blob);\n\t\t\t\t\t\tfilesaver.readyState = filesaver.INIT;\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\t// don't create more object URLs than needed\n\t\t\t\t\tif (!object_url) {\n\t\t\t\t\t\tobject_url = get_URL().createObjectURL(blob);\n\t\t\t\t\t}\n\t\t\t\t\tif (force) {\n\t\t\t\t\t\tview.location.href = object_url;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tvar opened = view.open(object_url, \"_blank\");\n\t\t\t\t\t\tif (!opened) {\n\t\t\t\t\t\t\t// Apple does not allow window.open, see https://developer.apple.com/library/safari/documentation/Tools/Conceptual/SafariExtensionGuide/WorkingwithWindowsandTabs/WorkingwithWindowsandTabs.html\n\t\t\t\t\t\t\tview.location.href = object_url;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tfilesaver.readyState = filesaver.DONE;\n\t\t\t\t\tdispatch_all();\n\t\t\t\t\trevoke(object_url);\n\t\t\t\t}\n\t\t\t;\n\t\t\tfilesaver.readyState = filesaver.INIT;\n\n\t\t\tif (can_use_save_link) {\n\t\t\t\tobject_url = get_URL().createObjectURL(blob);\n\t\t\t\tsetTimeout(function() {\n\t\t\t\t\tsave_link.href = object_url;\n\t\t\t\t\tsave_link.download = name;\n\t\t\t\t\tclick(save_link);\n\t\t\t\t\tdispatch_all();\n\t\t\t\t\trevoke(object_url);\n\t\t\t\t\tfilesaver.readyState = filesaver.DONE;\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tfs_error();\n\t\t}\n\t\t, FS_proto = FileSaver.prototype\n\t\t, saveAs = function(blob, name, no_auto_bom) {\n\t\t\treturn new FileSaver(blob, name || blob.name || \"download\", no_auto_bom);\n\t\t}\n\t;\n\t// IE 10+ (native saveAs)\n\tif (typeof navigator !== \"undefined\" && navigator.msSaveOrOpenBlob) {\n\t\treturn function(blob, name, no_auto_bom) {\n\t\t\tname = name || blob.name || \"download\";\n\n\t\t\tif (!no_auto_bom) {\n\t\t\t\tblob = auto_bom(blob);\n\t\t\t}\n\t\t\treturn navigator.msSaveOrOpenBlob(blob, name);\n\t\t};\n\t}\n\n\tFS_proto.abort = function(){};\n\tFS_proto.readyState = FS_proto.INIT = 0;\n\tFS_proto.WRITING = 1;\n\tFS_proto.DONE = 2;\n\n\tFS_proto.error =\n\tFS_proto.onwritestart =\n\tFS_proto.onprogress =\n\tFS_proto.onwrite =\n\tFS_proto.onabort =\n\tFS_proto.onerror =\n\tFS_proto.onwriteend =\n\t\tnull;\n\n\treturn saveAs;\n}(\n\t typeof self !== \"undefined\" && self\n\t|| typeof window !== \"undefined\" && window\n\t|| this.content\n));\n// `self` is undefined in Firefox for Android content script context\n// while `this` is nsIContentFrameMessageManager\n// with an attribute `content` that corresponds to the window\n\nif (typeof module !== \"undefined\" && module.exports) {\n module.exports.saveAs = saveAs;\n} else if ((typeof define !== \"undefined\" && define !== null) && (define.amd !== null)) {\n define(\"FileSaver.js\", function() {\n return saveAs;\n });\n}\n"],"sourceRoot":""} |