From 0c04c045902feb321eadd5787bbf23f6d6eb349f Mon Sep 17 00:00:00 2001 From: Jiiks Date: Fri, 10 Aug 2018 12:48:56 +0300 Subject: [PATCH] Secure kvp --- client/src/data/user.settings.default.json | 2 +- client/src/structs/settings/setting.js | 2 + .../src/structs/settings/types/securekvp.js | 26 +++++++++ .../bd/setting/SecureKeyValuePair.vue | 58 +++++++++++++++++++ .../src/ui/components/bd/setting/Setting.vue | 3 + package-lock.json | 9 ++- package.json | 1 + 7 files changed, 97 insertions(+), 4 deletions(-) create mode 100644 client/src/structs/settings/types/securekvp.js create mode 100644 client/src/ui/components/bd/setting/SecureKeyValuePair.vue diff --git a/client/src/data/user.settings.default.json b/client/src/data/user.settings.default.json index 29137e6d..2ca31ad6 100644 --- a/client/src/data/user.settings.default.json +++ b/client/src/data/user.settings.default.json @@ -172,7 +172,7 @@ "settings": [ { "id": "e2ekvps", - "type": ["kvp"], + "type": [ "securekvp" ], "value": [] } ] diff --git a/client/src/structs/settings/setting.js b/client/src/structs/settings/setting.js index 618596ce..fe2b4e5a 100644 --- a/client/src/structs/settings/setting.js +++ b/client/src/structs/settings/setting.js @@ -21,6 +21,7 @@ import GuildSetting from './types/guild'; import ArraySetting from './types/array'; import CollectionSetting from './types/collection'; import KvpSetting from './types/kvp'; +import SecureKvpSetting from './types/securekvp'; import CustomSetting from './types/custom'; export default class Setting { @@ -44,6 +45,7 @@ export default class Setting { else if (args.type === 'array') return new ArraySetting(args, ...merge); else if (args.type === 'collection') return new CollectionSetting(args, ...merge); else if (args.type === 'kvp') return new KvpSetting(args, ...merge); + else if (args.type === 'securekvp') return new SecureKvpSetting(args, ...merge); else if (args.type === 'custom') return new CustomSetting(args, ...merge); else throw {message: `Setting type ${args.type} unknown`}; } diff --git a/client/src/structs/settings/types/securekvp.js b/client/src/structs/settings/types/securekvp.js new file mode 100644 index 00000000..bb6c4990 --- /dev/null +++ b/client/src/structs/settings/types/securekvp.js @@ -0,0 +1,26 @@ +/** + * BetterDiscord Secure Key Value Pair 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 Kvp from './kvp'; + +export default class SecureKvpSetting extends Kvp { + + constructor(args, ...merge) { + super(args, ...merge); + window.skvp = this; + } + + /** + * The value to use when the setting doesn't have a value. + */ + get defaultValue() { + return { key: 'Key', value: '**********' }; + } +} diff --git a/client/src/ui/components/bd/setting/SecureKeyValuePair.vue b/client/src/ui/components/bd/setting/SecureKeyValuePair.vue new file mode 100644 index 00000000..cb5f3249 --- /dev/null +++ b/client/src/ui/components/bd/setting/SecureKeyValuePair.vue @@ -0,0 +1,58 @@ +/** + * BetterDiscord Setting Secure 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. +*/ + + + + diff --git a/client/src/ui/components/bd/setting/Setting.vue b/client/src/ui/components/bd/setting/Setting.vue index af430c9e..107e6ee6 100644 --- a/client/src/ui/components/bd/setting/Setting.vue +++ b/client/src/ui/components/bd/setting/Setting.vue @@ -24,6 +24,7 @@ +
@@ -45,6 +46,7 @@ import ArraySetting from './Array.vue'; import Collection from './Collection.vue'; import KeyValuePair from './KeyValuePair.vue'; + import SecureKeyValuePair from './SecureKeyValuePair.vue'; import CustomSetting from './Custom.vue'; export default { @@ -66,6 +68,7 @@ ArraySetting, Collection, KeyValuePair, + SecureKeyValuePair, CustomSetting }, computed: { diff --git a/package-lock.json b/package-lock.json index b78a6481..9e8ed106 100644 --- a/package-lock.json +++ b/package-lock.json @@ -55,6 +55,12 @@ } } }, + "aes256": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/aes256/-/aes256-1.0.4.tgz", + "integrity": "sha512-yuaKOdoKebChkP+uRsQovWsJYm6qf58cQTvXBu6MM0BMnrXZ9SXEiXREBuU513ZRr+Uo2qX/Ci6EODLUu/qiHA==", + "dev": true + }, "ajv": { "version": "5.5.2", "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz", @@ -2733,9 +2739,6 @@ "randomfill": "1.0.4" } }, - "csp-parse": { - "version": "github:macropodhq/csp-parse#db7d5f954b420b527d7fb452a93bb6e2fa302c5a" - }, "css-color-names": { "version": "0.0.4", "resolved": "https://registry.npmjs.org/css-color-names/-/css-color-names-0.0.4.tgz", diff --git a/package.json b/package.json index b3b47fe0..03531f04 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "node-sass": "^4.9.2" }, "devDependencies": { + "aes256": "^1.0.4", "archiver": "^2.1.1", "babel-core": "^6.26.3", "babel-loader": "^7.1.5",