Merge branch 'e2ee-dev' of https://github.com/Mega-Mewthree/BetterDiscordApp into e2ee-dev
This commit is contained in:
parent
816f809ca7
commit
1a8946b151
|
@ -16,6 +16,7 @@ import { ClientLogger as Logger } from 'common';
|
|||
import E2EEComponent from './E2EEComponent.vue';
|
||||
import E2EEMessageButton from './E2EEMessageButton.vue';
|
||||
import aes256 from 'aes256';
|
||||
import crypto from 'crypto';
|
||||
|
||||
let seed = Math.random().toString(36).replace(/[^a-z]+/g, '');
|
||||
|
||||
|
@ -38,6 +39,7 @@ export default new class E2EE extends BuiltinModule {
|
|||
return ['security', 'default', 'e2ee'];
|
||||
}
|
||||
|
||||
|
||||
get database() {
|
||||
return Settings.getSetting('security', 'e2eedb', 'e2ekvps').value;
|
||||
}
|
||||
|
@ -121,6 +123,28 @@ export default new class E2EE extends BuiltinModule {
|
|||
MonkeyPatch('BD:E2EE', cta.component.prototype).before('handleSubmit', this.handleChannelTextAreaSubmit.bind(this));
|
||||
}
|
||||
|
||||
get ecdh() {
|
||||
if (!this._ecdh) this._ecdh = {};
|
||||
return this._ecdh;
|
||||
}
|
||||
|
||||
createKeyExchange(userID) {
|
||||
this.ecdh[userID] = crypto.createECDH('secp521r1');
|
||||
return this.ecdh[userID].generateKeys('base64');
|
||||
}
|
||||
|
||||
publicKeyFor(userID) {
|
||||
return this.ecdh[userID].getPublicKey('base64');
|
||||
}
|
||||
|
||||
computeSecret(userID, otherKey) {
|
||||
const secret = this.ecdh[userID].computeSecret(otherKey, 'base64', 'base64');
|
||||
delete this.ecdh[userID];
|
||||
const hash = crypto.createHash('sha256');
|
||||
hash.update(secret);
|
||||
return hash.digest('base64');
|
||||
}
|
||||
|
||||
handleChannelTextAreaSubmit(component, args, retVal) {
|
||||
const key = this.getKey(DiscordApi.currentChannel.id);
|
||||
if (!this.encryptNewMessages || !key) return;
|
||||
|
|
|
@ -12,7 +12,7 @@ import { DOM, BdUI, BdMenu, Modals, Reflection, Toasts } from 'ui';
|
|||
import BdCss from './styles/index.scss';
|
||||
import { Events, CssEditor, Globals, Settings, Database, Updater, ModuleManager, PluginManager, ThemeManager, ExtModuleManager, Vendor, WebpackModules, Patcher, MonkeyPatch, ReactComponents, ReactHelpers, ReactAutoPatcher, DiscordApi, BdWebApi, Connectivity } from 'modules';
|
||||
import { ClientLogger as Logger, ClientIPC, Utils } from 'common';
|
||||
import { BuiltinManager, EmoteModule, ReactDevtoolsModule, VueDevtoolsModule, TrackingProtection } from 'builtin';
|
||||
import { BuiltinManager, EmoteModule, ReactDevtoolsModule, VueDevtoolsModule, TrackingProtection, E2EE } from 'builtin';
|
||||
import electron from 'electron';
|
||||
import path from 'path';
|
||||
|
||||
|
|
|
@ -38,7 +38,8 @@ module.exports = {
|
|||
process: 'require("process")',
|
||||
net: 'require("net")',
|
||||
request: 'require(require("path").join(require("electron").remote.app.getAppPath(), "node_modules", "request"))',
|
||||
sparkplug: 'require("../../core/dist/sparkplug")'
|
||||
sparkplug: 'require("../../core/dist/sparkplug")',
|
||||
crypto: 'require("crypto")'
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
|
|
|
@ -39,7 +39,8 @@ module.exports = {
|
|||
process: 'require("process")',
|
||||
net: 'require("net")',
|
||||
request: 'require(require("path").join(require("electron").remote.app.getAppPath(), "node_modules", "request"))',
|
||||
sparkplug: 'require("./sparkplug")'
|
||||
sparkplug: 'require("./sparkplug")',
|
||||
crypto: 'require("crypto")'
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
|
|
Loading…
Reference in New Issue