initial master encrypt

This commit is contained in:
Jiiks 2018-08-10 17:01:07 +03:00
parent 3d4204f080
commit 3bc7c28a97
1 changed files with 8 additions and 5 deletions

View File

@ -15,16 +15,19 @@ import { VueInjector, Reflection } from 'ui';
import E2EEComponent from './E2EEComponent.vue';
import aes256 from 'aes256';
const seed = Math.random().toString(36).replace(/[^a-z]+/g, '');
export default new class E2EE extends BuiltinModule {
constructor() {
super();
this.master = this.encrypt(seed, 'temporarymasterkey');
}
get settingPath() {
return ['security', 'default', 'e2ee'];
}
get master() {
return 'temporarymasterkey';
}
get database() {
return Settings.getSet('security').settings.find(s => s.id === 'e2eedb').settings[0].value;
}
@ -59,7 +62,7 @@ export default new class E2EE extends BuiltinModule {
handleSubmit(component, args, retVal) {
const key = this.getKey(DiscordApi.currentChannel.id);
if (!key) return;
component.props.value = this.encrypt(this.decrypt(this.master, key), component.props.value);
component.props.value = this.encrypt(this.decrypt(this.decrypt(seed, this.master), key), component.props.value);
}
disabled(e) {