Merge pull request #206 from JsSucks/security

Merge due to changes to core functionality to avoid conflicts
This commit is contained in:
Alexei Stukov 2018-08-09 13:24:00 +03:00 committed by GitHub
commit 4c20115705
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 198 additions and 23 deletions

View File

@ -0,0 +1,27 @@
/**
* BetterDiscord E2EE Module
* 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.
*/
import BuiltinModule from './BuiltinModule';
export default new class E2EE extends BuiltinModule {
get settingPath() {
return ['security', 'default', 'e2ee'];
}
enabled(e) {
}
disabled(e) {
}
}

View File

@ -0,0 +1,13 @@
import { default as EmoteModule } from './EmoteModule';
import { default as ReactDevtoolsModule } from './ReactDevtoolsModule';
import { default as VueDevtoolsModule } from './VueDevToolsModule';
import { default as TrackingProtection } from './TrackingProtection';
export default class {
static initAll() {
EmoteModule.init();
ReactDevtoolsModule.init();
VueDevtoolsModule.init();
TrackingProtection.init();
}
}

View File

@ -0,0 +1,36 @@
/**
* BetterDiscord Tracking Protection Module
* 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.
*/
import BuiltinModule from './BuiltinModule';
import { Patcher, MonkeyPatch, WebpackModules } from 'modules';
export default new class E2EE extends BuiltinModule {
get settingPath() {
return ['security', 'default', 'tracking-protection'];
}
track(e) {
// console.log('Blocked Tracking');
}
enabled(e) {
if (Patcher.getPatchesByCaller('BD:TrackingProtection').length) return;
const trackingModule = WebpackModules.getModuleByProps(['track']);
if (!trackingModule) return; // TODO Log it
MonkeyPatch('BD:TrackingProtection', trackingModule).instead('track', this.track);
}
disabled(e) {
for (const patch of Patcher.getPatchesByCaller('BD:TrackingProtection')) patch.unpatch();
}
}

View File

@ -1,3 +1,5 @@
export { default as EmoteModule } from './EmoteModule';
export { default as ReactDevtoolsModule } from './ReactDevtoolsModule';
export { default as VueDevtoolsModule } from './VueDevToolsModule';
export { default as TrackingProtection } from './TrackingProtection';
export { default as BuiltinManager } from './Manager';

View File

@ -7,22 +7,6 @@
{
"id": "default",
"settings": [
{
"id": "test-setting",
"type": "bool",
"text": "Test Setting",
"hint": "Test Setting",
"value": false,
"disabled": false
},
{
"id": "test-setting2",
"type": "bool",
"text": "Test Setting 2",
"hint": "Test Setting 2",
"value": true,
"disabled": false
},
{
"id": "voice-disconnect",
"type": "bool",
@ -55,7 +39,7 @@
"id": "debugger-keybind",
"type": "keybind",
"text": "Debugger keybind",
"hint": "When this keybind is activated the developer tools will be opened and Discord will be paused."
"hint": "Open developer tools and pause"
},
{
"id": "ignore-content-manager-errors",
@ -159,8 +143,41 @@
},
{
"id": "security",
"text": "Security",
"text": "Security and Privacy",
"headertext": "Security Settings",
"settings": []
"settings": [
{
"id": "default",
"settings": [
{
"id": "tracking-protection",
"type": "bool",
"text": "Tracking Protection",
"hint": "Disable any Discord tracking",
"value": false
},
{
"id": "e2ee",
"type": "bool",
"text": "E2EE",
"hint": "End-to-end encryption",
"value": false
}
]
},
{
"id": "e2eedb",
"name": "E2EE Database",
"type": "drawer",
"settings": [
{
"id": "kvp0",
"type": "kvp",
"text": "",
"value": { "key": "kvpKey", "value": "kvpValue" }
}
]
}
]
}
]

View File

@ -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 { EmoteModule, ReactDevtoolsModule, VueDevtoolsModule } from 'builtin';
import { BuiltinManager, EmoteModule, ReactDevtoolsModule, VueDevtoolsModule, TrackingProtection } from 'builtin';
import electron from 'electron';
import path from 'path';
@ -73,8 +73,6 @@ class BetterDiscord {
async init() {
try {
ReactDevtoolsModule.init();
VueDevtoolsModule.init();
await Database.init();
await Settings.loadSettings();
await ModuleManager.initModules();
@ -90,7 +88,7 @@ class BetterDiscord {
Events.emit('ready');
Events.emit('discord-ready');
EmoteModule.init();
BuiltinManager.initAll();
} catch (err) {
Logger.err('main', ['FAILED TO LOAD!', err]);
}

View File

@ -19,6 +19,7 @@ import KeybindSetting from './types/keybind';
import FileSetting from './types/file';
import GuildSetting from './types/guild';
import ArraySetting from './types/array';
import KvpSetting from './types/kvp';
import CustomSetting from './types/custom';
export default class Setting {
@ -40,6 +41,7 @@ export default class Setting {
else if (args.type === 'guild') return new GuildSetting(args, ...merge);
else if (args.type === 'array') return new ArraySetting(args, ...merge);
else if (args.type === 'custom') return new CustomSetting(args, ...merge);
else if (args.type === 'kvp') return new KvpSetting(args, ...merge);
else throw {message: `Setting type ${args.type} unknown`};
}

View File

@ -9,4 +9,5 @@ export { default as KeybindSetting } from './keybind';
export { default as FileSetting } from './file';
export { default as GuildSetting } from './guild';
export { default as ArraySetting } from './array';
export { default as KvpSetting } from './kvp';
export { default as CustomSetting } from './custom';

View File

@ -0,0 +1,21 @@
/**
* BetterDiscord String Setting Struct
* 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.
*/
import Setting from './basesetting';
export default class KvpSetting extends Setting {
/**
* The value to use when the setting doesn't have a value.
*/
get defaultValue() {
return { key: 'Channel ID', value: 'Encryption Key' };
}
}

View File

@ -7,3 +7,4 @@
@import './settings-schemes.scss';
@import './updater.scss';
@import './window-preferences';
@import './kvp';

View File

@ -0,0 +1,22 @@
.bd-formKvp {
display: flex;
.bd-formKvpDetails {
display: flex;
flex: 1 0 auto;
.bd-inputWrapper {
flex: 1 0 auto;
margin-right: 15px;
input {
width: 100%;
padding: 5px;
}
&:first-child {
max-width: 150px;
}
}
}
}

View File

@ -42,6 +42,7 @@ export const BdMenuItems = new class {
this.addSettingsSet('Internal', 'core', 'Core');
this.addSettingsSet('Internal', 'ui', 'UI');
this.addSettingsSet('Internal', 'emotes', 'Emotes');
this.addSettingsSet('Internal', 'security', 'Security and Privacy');
this.add({category: 'Internal', contentid: 'css', text: 'CSS Editor'});
this.add({category: 'External', contentid: 'plugins', text: 'Plugins'});

View File

@ -0,0 +1,31 @@
/**
* BetterDiscord Setting Key Value Pair 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.
*/
<template>
<div class="bd-formKvp">
<div class="bd-formKvpDetails">
<div class="bd-inputWrapper">
<input type="text" class="bd-textInput" :value="setting.value.key" />
</div>
<div class="bd-inputWrapper">
<input type="text" class="bd-textInput" :value="setting.value.value" />
</div>
<!-- using a text field is temporary -->
</div>
</div>
</template>
<script>
export default {
props: ['setting'],
methods: {},
mounted() {console.log('setting', this.setting)}
}
</script>

View File

@ -22,6 +22,7 @@
<FileSetting v-if="setting.type === 'file'" :setting="setting" />
<GuildSetting v-if="setting.type === 'guild'" :setting="setting" />
<ArraySetting v-if="setting.type === 'array'" :setting="setting" />
<KeyValuePair v-if="setting.type === 'kvp'" :setting="setting"/>
<CustomSetting v-if="setting.type === 'custom'" :setting="setting" />
<div class="bd-form-divider"></div>
</div>
@ -41,6 +42,7 @@
import FileSetting from './File.vue';
import GuildSetting from './Guild.vue';
import ArraySetting from './Array.vue';
import KeyValuePair from './KeyValuePair.vue';
import CustomSetting from './Custom.vue';
export default {
@ -60,6 +62,7 @@
FileSetting,
GuildSetting,
ArraySetting,
KeyValuePair,
CustomSetting
},
computed: {