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
13 KiB
1 line
13 KiB
{"version":3,"sources":["node_modules/matrix-react-sdk/lib/async-components/views/dialogs/ImportE2eKeysDialog.js"],"names":["Object","defineProperty","exports","value","_promise2","_interopRequireDefault","__webpack_require__","_react2","_propTypes2","Matrix","_interopRequireWildcard","MegolmExportEncryption","_index2","_languageHandler","obj","__esModule","newObj","key","prototype","hasOwnProperty","call","default","createClass","displayName","propTypes","matrixClient","instanceOf","MatrixClient","isRequired","onFinished","func","getInitialState","enableSubmit","phase","errStr","componentWillMount","this","_unmounted","componentWillUnmount","_onFormChange","ev","files","refs","file","setState","passphrase","length","_onFormSubmit","preventDefault","_startImport","_this","resolve","reject","reader","FileReader","onload","e","target","result","onerror","readAsArrayBuffer","readFileAsArrayBuffer","then","arrayBuffer","decryptMegolmKeyFile","keys","props","importRoomKeys","JSON","parse","catch","console","error","msg","friendlyText","_t","_onCancelClick","render","BaseDialog","getComponent","disableForm","state","createElement","className","title","onSubmit","htmlFor","ref","id","type","autoFocus","onChange","disabled","size","onClick","module"],"mappings":"4FAEAA,OAAAC,eAAAC,EAAA,cACAC,OAAA,IAGA,IAEAC,EAAAC,EAFeC,EAAQ,KAMvBC,EAAAF,EAFaC,EAAQ,IAMrBE,EAAAH,EAFiBC,EAAQ,IAMzBG,EAAAC,EAFmBJ,EAAQ,KAM3BK,EAAAD,EAF8BJ,EAAQ,MAMtCM,EAAAP,EAFaC,EAAQ,IAIrBO,EAAuBP,EAAQ,GAE/B,SAAAI,EAAAI,GAAuC,GAAAA,KAAAC,WAA6B,OAAAD,EAAqB,IAAAE,EAAA,GAAiB,SAAAF,EAAmB,QAAAG,KAAAH,EAAuBd,OAAAkB,UAAAC,eAAAC,KAAAN,EAAAG,KAAAD,EAAAC,GAAAH,EAAAG,IAAsG,OAAtBD,EAAAK,QAAAP,EAAsBE,EAE1P,SAAAX,EAAAS,GAAsC,OAAAA,KAAAC,WAAAD,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iCC,UAAA,8BACjC5E,EAAAc,QAAA6D,cAAA,SAAwEK,IAAA,aAAAC,GAAA,aACxEK,KAAA,KAAAJ,KAAA,WACAE,SAAAvD,KAAAG,cACAqD,SAAAZ,QAKAzE,EAAAc,QAAA6D,cACA,MACA,CAAqBC,UAAA,qBACrB5E,EAAAc,QAAA6D,cAAA,SAA4DC,UAAA,oBAAAM,KAAA,SAAAtF,OAAA,EAAAU,EAAA8D,IAAA,UAC5DiB,UAAAxD,KAAA6C,MAAAjD,cAAAgD,IAEAzE,EAAAc,QAAA6D,cACA,SACA,CAAyBY,QAAA1D,KAAAwC,eAAAgB,SAAAZ,IACzB,EAAAnE,EAAA8D,IAAA,iBAOAoB,EAAA7F,UAAA","file":"bundles/8be32dac4bfa4015fcdc/11.js","sourcesContent":["'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _promise = require('babel-runtime/core-js/promise');\n\nvar _promise2 = _interopRequireDefault(_promise);\n\nvar _react = require('react');\n\nvar _react2 = _interopRequireDefault(_react);\n\nvar _propTypes = require('prop-types');\n\nvar _propTypes2 = _interopRequireDefault(_propTypes);\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\nvar _languageHandler = require('../../../languageHandler');\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\n/*\nCopyright 2017 Vector Creations Ltd\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nfunction readFileAsArrayBuffer(file) {\n return new _promise2.default(function (resolve, reject) {\n var reader = new FileReader();\n reader.onload = function (e) {\n resolve(e.target.result);\n };\n reader.onerror = reject;\n\n reader.readAsArrayBuffer(file);\n });\n}\n\nvar PHASE_EDIT = 1;\nvar PHASE_IMPORTING = 2;\n\nexports.default = _react2.default.createClass({\n displayName: 'ImportE2eKeysDialog',\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 enableSubmit: false,\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 _onFormChange: function _onFormChange(ev) {\n var files = this.refs.file.files || [];\n this.setState({\n enableSubmit: this.refs.passphrase.value !== \"\" && files.length > 0\n });\n },\n\n _onFormSubmit: function _onFormSubmit(ev) {\n ev.preventDefault();\n this._startImport(this.refs.file.files[0], this.refs.passphrase.value);\n return false;\n },\n\n _startImport: function _startImport(file, passphrase) {\n var _this = this;\n\n this.setState({\n errStr: null,\n phase: PHASE_IMPORTING\n });\n\n return readFileAsArrayBuffer(file).then(function (arrayBuffer) {\n return MegolmExportEncryption.decryptMegolmKeyFile(arrayBuffer, passphrase);\n }).then(function (keys) {\n return _this.props.matrixClient.importRoomKeys(JSON.parse(keys));\n }).then(function () {\n // TODO: it would probably be nice to give some feedback about what we've imported here.\n _this.props.onFinished(true);\n }).catch(function (e) {\n console.error(\"Error importing 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\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_EDIT;\n\n return _react2.default.createElement(\n BaseDialog,\n { className: 'mx_importE2eKeysDialog',\n onFinished: this.props.onFinished,\n title: (0, _languageHandler._t)(\"Import room keys\")\n },\n _react2.default.createElement(\n 'form',\n { onSubmit: this._onFormSubmit },\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 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.')\n ),\n _react2.default.createElement(\n 'p',\n null,\n (0, _languageHandler._t)('The export file will be protected with a passphrase. ' + 'You should enter the passphrase here, to decrypt the file.')\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: 'importFile' },\n (0, _languageHandler._t)(\"File to import\")\n )\n ),\n _react2.default.createElement(\n 'div',\n { className: 'mx_E2eKeysDialog_inputCell' },\n _react2.default.createElement('input', { ref: 'file', id: 'importFile', type: 'file',\n autoFocus: true,\n onChange: this._onFormChange,\n disabled: disableForm })\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: 'passphrase' },\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: 'passphrase', id: 'passphrase',\n size: '64', type: 'password',\n onChange: this._onFormChange,\n disabled: disableForm })\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)('Import'),\n disabled: !this.state.enableSubmit || 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=ImportE2eKeysDialog.js.map"],"sourceRoot":""} |