diff --git a/client/src/builtin/E2EE.js b/client/src/builtin/E2EE.js index 423310bf..1292ee3d 100644 --- a/client/src/builtin/E2EE.js +++ b/client/src/builtin/E2EE.js @@ -159,8 +159,13 @@ export default new class E2EE extends BuiltinModule { async enabled(e) { seed = Security.randomBytes(); - // TODO Input modal for key - this.master = Security.encrypt(seed, TEMP_KEY); + let newMaster = ''; + try { + newMaster = await Modals.input('E2EE', 'Master Key:').promise; + } catch (err) { + Toasts.error('Failed to set master key!'); + } + this.master = Security.encrypt(seed, newMaster); this.patchDispatcher(); this.patchMessageContent(); const selector = '.' + WebpackModules.getClassName('channelTextArea', 'emojiButton'); diff --git a/client/src/styles/partials/modals/index.scss b/client/src/styles/partials/modals/index.scss index 994bbd64..722a1aca 100644 --- a/client/src/styles/partials/modals/index.scss +++ b/client/src/styles/partials/modals/index.scss @@ -7,3 +7,4 @@ @import './error-modal.scss'; @import './settings-modal.scss'; @import './permission-modal.scss'; +@import './input-modal.scss'; diff --git a/client/src/styles/partials/modals/input-modal.scss b/client/src/styles/partials/modals/input-modal.scss new file mode 100644 index 00000000..6c76644e --- /dev/null +++ b/client/src/styles/partials/modals/input-modal.scss @@ -0,0 +1,8 @@ +.bd-inputModalBody { + display: flex; + flex-direction: column; + + input { + margin-top: 5px; + } +} diff --git a/client/src/ui/components/bd/modals/InputModal.vue b/client/src/ui/components/bd/modals/InputModal.vue new file mode 100644 index 00000000..a38b3d37 --- /dev/null +++ b/client/src/ui/components/bd/modals/InputModal.vue @@ -0,0 +1,52 @@ +/** + * BetterDiscord Input Modal Component + * Copyright (c) 2015-present Jiiks/JsSucks - https://github.com/Jiiks / https://github.com/JsSucks + * All rights reserved. + * https://betterdiscord.net + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. +*/ + + + + diff --git a/client/src/ui/modals.js b/client/src/ui/modals.js index b9f572ae..1f46a2d1 100644 --- a/client/src/ui/modals.js +++ b/client/src/ui/modals.js @@ -16,6 +16,7 @@ import ConfirmModal from './components/bd/modals/ConfirmModal.vue'; import ErrorModal from './components/bd/modals/ErrorModal.vue'; import SettingsModal from './components/bd/modals/SettingsModal.vue'; import PermissionModal from './components/bd/modals/PermissionModal.vue'; +import InputModal from './components/bd/modals/InputModal.vue'; let modals = 0; @@ -176,6 +177,19 @@ export default class Modals { return new Modal(modal, ConfirmModal); } + static input(title, text) { + return this.add(this.createInputModal(title, text)); + } + + static createInputModal(title, text) { + const modal = { title, text }; + modal.promise = new Promise((resolve, reject) => { + modal.confirm = value => resolve(value); + modal.beforeClose = () => reject(); + }); + return new Modal(modal, InputModal); + } + /** * Creates a new permissions modal and adds it to the open stack. * The modal will have a promise property that will be set to a Promise object that is resolved or rejected if the user accepts the permissions or closes the modal.