From 4e3a56e46680c40a6e7de47c128f1a7b5a3b62c1 Mon Sep 17 00:00:00 2001 From: Jiiks Date: Sun, 26 Aug 2018 22:39:04 +0300 Subject: [PATCH 01/29] Plugin packager --- client/src/ui/components/bd/PluginCard.vue | 41 ++++++- .../src/ui/components/common/MaterialIcon.js | 1 + .../common/materialicons/BoxDownload.vue | 27 +++++ client/webpack.config.js | 1 + package-lock.json | 108 ++++++++++-------- 5 files changed, 128 insertions(+), 50 deletions(-) create mode 100644 client/src/ui/components/common/materialicons/BoxDownload.vue diff --git a/client/src/ui/components/bd/PluginCard.vue b/client/src/ui/components/bd/PluginCard.vue index d36691db..f04aa102 100644 --- a/client/src/ui/components/bd/PluginCard.vue +++ b/client/src/ui/components/bd/PluginCard.vue @@ -12,6 +12,7 @@ + @@ -22,18 +23,54 @@ diff --git a/client/webpack.config.js b/client/webpack.config.js index ca202b4d..f168c850 100644 --- a/client/webpack.config.js +++ b/client/webpack.config.js @@ -39,6 +39,7 @@ module.exports = { net: 'require("net")', request: 'require(require("path").join(require("electron").remote.app.getAppPath(), "node_modules", "request"))', sparkplug: 'require("../../core/dist/sparkplug")', + archiver: 'require("archiver")', 'node-crypto': 'require("crypto")' }, resolve: { diff --git a/package-lock.json b/package-lock.json index 5f627d6d..ccc6cf80 100644 --- a/package-lock.json +++ b/package-lock.json @@ -295,7 +295,7 @@ "buffer-crc32": "0.2.13", "glob": "7.1.2", "lodash": "4.17.10", - "readable-stream": "2.3.5", + "readable-stream": "2.3.6", "tar-stream": "1.5.5", "zip-stream": "1.2.0" }, @@ -313,9 +313,9 @@ "dev": true }, "readable-stream": { - "version": "2.3.5", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.5.tgz", - "integrity": "sha512-tK0yDhrkygt/knjowCUiWP9YdV7c5R+8cR0r/kt9ZhBU906Fs6RpQJCEilamRJj1Nx2rWI6LkW9gKqjTkshhEw==", + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "dev": true, "requires": { "core-util-is": "1.0.2", @@ -323,14 +323,14 @@ "isarray": "1.0.0", "process-nextick-args": "2.0.0", "safe-buffer": "5.1.1", - "string_decoder": "1.0.3", + "string_decoder": "1.1.1", "util-deprecate": "1.0.2" } }, "string_decoder": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", - "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", "dev": true, "requires": { "safe-buffer": "5.1.1" @@ -349,7 +349,7 @@ "lazystream": "1.0.0", "lodash": "4.17.10", "normalize-path": "2.1.1", - "readable-stream": "2.3.5" + "readable-stream": "2.3.6" }, "dependencies": { "isarray": { @@ -365,9 +365,9 @@ "dev": true }, "readable-stream": { - "version": "2.3.5", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.5.tgz", - "integrity": "sha512-tK0yDhrkygt/knjowCUiWP9YdV7c5R+8cR0r/kt9ZhBU906Fs6RpQJCEilamRJj1Nx2rWI6LkW9gKqjTkshhEw==", + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "dev": true, "requires": { "core-util-is": "1.0.2", @@ -375,14 +375,14 @@ "isarray": "1.0.0", "process-nextick-args": "2.0.0", "safe-buffer": "5.1.1", - "string_decoder": "1.0.3", + "string_decoder": "1.1.1", "util-deprecate": "1.0.2" } }, "string_decoder": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", - "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", "dev": true, "requires": { "safe-buffer": "5.1.1" @@ -2396,7 +2396,7 @@ "buffer-crc32": "0.2.13", "crc32-stream": "2.0.0", "normalize-path": "2.1.1", - "readable-stream": "2.3.5" + "readable-stream": "2.3.6" }, "dependencies": { "isarray": { @@ -2412,9 +2412,9 @@ "dev": true }, "readable-stream": { - "version": "2.3.5", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.5.tgz", - "integrity": "sha512-tK0yDhrkygt/knjowCUiWP9YdV7c5R+8cR0r/kt9ZhBU906Fs6RpQJCEilamRJj1Nx2rWI6LkW9gKqjTkshhEw==", + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "dev": true, "requires": { "core-util-is": "1.0.2", @@ -2422,14 +2422,14 @@ "isarray": "1.0.0", "process-nextick-args": "2.0.0", "safe-buffer": "5.1.1", - "string_decoder": "1.0.3", + "string_decoder": "1.1.1", "util-deprecate": "1.0.2" } }, "string_decoder": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", - "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", "dev": true, "requires": { "safe-buffer": "5.1.1" @@ -2601,10 +2601,25 @@ } }, "crc": { - "version": "3.5.0", - "resolved": "https://registry.npmjs.org/crc/-/crc-3.5.0.tgz", - "integrity": "sha1-mLi6fUiWZbo5efWbITgTdBAaGWQ=", - "dev": true + "version": "3.8.0", + "resolved": "https://registry.npmjs.org/crc/-/crc-3.8.0.tgz", + "integrity": "sha512-iX3mfgcTMIq3ZKLIsVFAbv7+Mc10kxabAGQb8HvjA1o3T1PIYprbakQ65d3I+2HGHt6nSKkM9PYjgoJO2KcFBQ==", + "dev": true, + "requires": { + "buffer": "5.2.0" + }, + "dependencies": { + "buffer": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.2.0.tgz", + "integrity": "sha512-nUJyfChH7PMJy75eRDCCKtszSEFokUNXC1hNVSe+o+VdcgvDPLs20k3v8UXI8ruRYAJiYtyRea8mYyqPxoHWDw==", + "dev": true, + "requires": { + "base64-js": "1.3.0", + "ieee754": "1.1.12" + } + } + } }, "crc32-stream": { "version": "2.0.0", @@ -2612,8 +2627,8 @@ "integrity": "sha1-483TtN8xaN10494/u8t7KX/pCPQ=", "dev": true, "requires": { - "crc": "3.5.0", - "readable-stream": "2.3.5" + "crc": "3.8.0", + "readable-stream": "2.3.6" }, "dependencies": { "isarray": { @@ -2629,9 +2644,9 @@ "dev": true }, "readable-stream": { - "version": "2.3.5", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.5.tgz", - "integrity": "sha512-tK0yDhrkygt/knjowCUiWP9YdV7c5R+8cR0r/kt9ZhBU906Fs6RpQJCEilamRJj1Nx2rWI6LkW9gKqjTkshhEw==", + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "dev": true, "requires": { "core-util-is": "1.0.2", @@ -2639,14 +2654,14 @@ "isarray": "1.0.0", "process-nextick-args": "2.0.0", "safe-buffer": "5.1.1", - "string_decoder": "1.0.3", + "string_decoder": "1.1.1", "util-deprecate": "1.0.2" } }, "string_decoder": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", - "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", "dev": true, "requires": { "safe-buffer": "5.1.1" @@ -2733,9 +2748,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", @@ -14655,7 +14667,7 @@ "archiver-utils": "1.3.0", "compress-commons": "1.2.2", "lodash": "4.17.10", - "readable-stream": "2.3.5" + "readable-stream": "2.3.6" }, "dependencies": { "isarray": { @@ -14671,9 +14683,9 @@ "dev": true }, "readable-stream": { - "version": "2.3.5", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.5.tgz", - "integrity": "sha512-tK0yDhrkygt/knjowCUiWP9YdV7c5R+8cR0r/kt9ZhBU906Fs6RpQJCEilamRJj1Nx2rWI6LkW9gKqjTkshhEw==", + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "dev": true, "requires": { "core-util-is": "1.0.2", @@ -14681,14 +14693,14 @@ "isarray": "1.0.0", "process-nextick-args": "2.0.0", "safe-buffer": "5.1.1", - "string_decoder": "1.0.3", + "string_decoder": "1.1.1", "util-deprecate": "1.0.2" } }, "string_decoder": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", - "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", "dev": true, "requires": { "safe-buffer": "5.1.1" From f14b1b71e7c5a07db2946f5b9a7671bc2627c1ee Mon Sep 17 00:00:00 2001 From: Jiiks Date: Mon, 27 Aug 2018 17:28:42 +0300 Subject: [PATCH 02/29] Use asar instead --- client/src/ui/components/bd/PluginCard.vue | 17 +- client/webpack.config.js | 3 +- package-lock.json | 793 +++++++++------------ package.json | 4 +- 4 files changed, 335 insertions(+), 482 deletions(-) diff --git a/client/src/ui/components/bd/PluginCard.vue b/client/src/ui/components/bd/PluginCard.vue index f04aa102..9a371ce8 100644 --- a/client/src/ui/components/bd/PluginCard.vue +++ b/client/src/ui/components/bd/PluginCard.vue @@ -23,9 +23,10 @@ diff --git a/client/src/ui/components/common/Modal.vue b/client/src/ui/components/common/Modal.vue index c06ab439..4fd0a688 100644 --- a/client/src/ui/components/common/Modal.vue +++ b/client/src/ui/components/common/Modal.vue @@ -11,7 +11,7 @@ diff --git a/client/src/ui/modals.js b/client/src/ui/modals.js index a4b71b84..d7302ace 100644 --- a/client/src/ui/modals.js +++ b/client/src/ui/modals.js @@ -191,12 +191,12 @@ export default class Modals { return new Modal(modal, InputModal); } - static installModal(title, config) { - return this.add(this.createInstallModal(title, config)); + static installModal(contentType, config) { + return this.add(this.createInstallModal(contentType, config)); } - static createInstallModal(title, config) { - const modal = { title, config }; + static createInstallModal(contentType, config) { + const modal = { contentType, config }; modal.promise = new Promise((resolve, reject) => { modal.confirm = value => resolve(value); modal.beforeClose = () => reject(); From 09fb76d1480cd1943345cd78a1837f72c83b8b7e Mon Sep 17 00:00:00 2001 From: Jiiks Date: Wed, 29 Aug 2018 23:07:32 +0300 Subject: [PATCH 14/29] Versions should be strings --- tests/ext/modules/Example Module/config.json | 2 +- tests/ext/plugins/Depend Error Test/config.json | 2 +- tests/ext/plugins/Doubleclick Edit/config.json | 2 +- tests/ext/plugins/Example 2/config.json | 2 +- tests/ext/plugins/Example 3/config.json | 2 +- tests/ext/plugins/Example 4/config.json | 2 +- tests/ext/plugins/Example/config.json | 2 +- tests/ext/plugins/Patcher Test/config.json | 2 +- tests/ext/plugins/Permission Test/config.json | 2 +- tests/ext/plugins/Render Example/config.json | 2 +- tests/ext/themes/Example/config.json | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/ext/modules/Example Module/config.json b/tests/ext/modules/Example Module/config.json index 77a56834..2c54b9c5 100644 --- a/tests/ext/modules/Example Module/config.json +++ b/tests/ext/modules/Example Module/config.json @@ -2,7 +2,7 @@ "info": { "name": "Example Module", "authors": [ "Jiiks" ], - "version": 1.0, + "version": "1.0", "description": "Module Example" }, "main": "index.js", diff --git a/tests/ext/plugins/Depend Error Test/config.json b/tests/ext/plugins/Depend Error Test/config.json index 39729839..61ab11bf 100644 --- a/tests/ext/plugins/Depend Error Test/config.json +++ b/tests/ext/plugins/Depend Error Test/config.json @@ -3,7 +3,7 @@ "id": "depend-error", "name": "Depend Error", "authors": [ "Jiiks" ], - "version": 1.0, + "version": "1.0", "description": "Depend Error Plugin Description", "icon": "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiPjxzdmcgdmVyc2lvbj0iMS4xIiBpZD0iQ2FscXVlXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4IiB2aWV3Qm94PSIwIDAgMjAwMCAyMDAwIiBlbmFibGUtYmFja2dyb3VuZD0ibmV3IDAgMCAyMDAwIDIwMDAiIHhtbDpzcGFjZT0icHJlc2VydmUiPjxnPjxwYXRoIGZpbGw9IiMzRTgyRTUiIGQ9Ik0xNDAyLjIsNjMxLjdjLTkuNy0zNTMuNC0yODYuMi00OTYtNjQyLjYtNDk2SDY4LjR2NzE0LjFsNDQyLDM5OFY0OTAuN2gyNTdjMjc0LjUsMCwyNzQuNSwzNDQuOSwwLDM0NC45SDU5Ny42djMyOS41aDE2OS44YzI3NC41LDAsMjc0LjUsMzQ0LjgsMCwzNDQuOGgtNjk5djM1NC45aDY5MS4yYzM1Ni4zLDAsNjMyLjgtMTQyLjYsNjQyLjYtNDk2YzAtMTYyLjYtNDQuNS0yODQuMS0xMjIuOS0zNjguNkMxMzU3LjcsOTE1LjgsMTQwMi4yLDc5NC4zLDE0MDIuMiw2MzEuN3oiLz48cGF0aCBmaWxsPSIjRkZGRkZGIiBkPSJNMTI2Mi41LDEzNS4yTDEyNjIuNSwxMzUuMmwtNzYuOCwwYzI2LjYsMTMuMyw1MS43LDI4LjEsNzUsNDQuM2M3MC43LDQ5LjEsMTI2LjEsMTExLjUsMTY0LjYsMTg1LjNjMzkuOSw3Ni42LDYxLjUsMTY1LjYsNjQuMywyNjQuNmwwLDEuMnYxLjJjMCwxNDEuMSwwLDU5Ni4xLDAsNzM3LjF2MS4ybDAsMS4yYy0yLjcsOTktMjQuMywxODgtNjQuMywyNjQuNmMtMzguNSw3My44LTkzLjgsMTM2LjItMTY0LjYsMTg1LjNjLTIyLjYsMTUuNy00Ni45LDMwLjEtNzIuNiw0My4xaDcyLjVjMzQ2LjIsMS45LDY3MS0xNzEuMiw2NzEtNTY3LjlWNzE2LjdDMTkzMy41LDMxMi4yLDE2MDguNywxMzUuMiwxMjYyLjUsMTM1LjJ6Ii8+PC9nPjwvc3ZnPg==" }, diff --git a/tests/ext/plugins/Doubleclick Edit/config.json b/tests/ext/plugins/Doubleclick Edit/config.json index c6bfa681..4f34b7ba 100644 --- a/tests/ext/plugins/Doubleclick Edit/config.json +++ b/tests/ext/plugins/Doubleclick Edit/config.json @@ -10,7 +10,7 @@ "twitter_username": "Jiiksi" } ], - "version": 1.0, + "version": "1.0," "description": "Edit messages by double clicking them. This is a v1 fix" }, "main": "index.js" diff --git a/tests/ext/plugins/Example 2/config.json b/tests/ext/plugins/Example 2/config.json index 7dafbd76..e414f3a4 100644 --- a/tests/ext/plugins/Example 2/config.json +++ b/tests/ext/plugins/Example 2/config.json @@ -4,7 +4,7 @@ "authors": [ "Jiiks" ], - "version": 1.0, + "version": "1.0", "description": "Example Plugin 2 Description" } } diff --git a/tests/ext/plugins/Example 3/config.json b/tests/ext/plugins/Example 3/config.json index 196b38e6..ec2d1d0b 100644 --- a/tests/ext/plugins/Example 3/config.json +++ b/tests/ext/plugins/Example 3/config.json @@ -17,7 +17,7 @@ "twitter_username": "Jiiksi" } ], - "version": 1.0, + "version": "1.0", "description": "A plugin for testing BetterDiscord plugin bridge." }, "main": "index.js" diff --git a/tests/ext/plugins/Example 4/config.json b/tests/ext/plugins/Example 4/config.json index c7f354e7..9f3b0b42 100644 --- a/tests/ext/plugins/Example 4/config.json +++ b/tests/ext/plugins/Example 4/config.json @@ -11,7 +11,7 @@ "twitter_username": "_samuelelliott" } ], - "version": 1.0, + "version": "1.0", "description": "Plugin for testing array setting events as the first example plugin has a lot of stuff in it now." }, "main": "index.js", diff --git a/tests/ext/plugins/Example/config.json b/tests/ext/plugins/Example/config.json index 159ab529..22543194 100644 --- a/tests/ext/plugins/Example/config.json +++ b/tests/ext/plugins/Example/config.json @@ -22,7 +22,7 @@ }, "Just a string" ], - "version": 1.0, + "version": "1.0", "description": "Example Plugin Description.\n\nDescriptions are preformatted (you can use newlines).", "icon": "icon.svg", "icon_type": "image/svg+xml" diff --git a/tests/ext/plugins/Patcher Test/config.json b/tests/ext/plugins/Patcher Test/config.json index bcf5e5fd..7267cc66 100644 --- a/tests/ext/plugins/Patcher Test/config.json +++ b/tests/ext/plugins/Patcher Test/config.json @@ -10,7 +10,7 @@ "twitter_username": "Jiiksi" } ], - "version": 1.0, + "version": "1.0", "description": "Patcher Test Description" }, "main": "index.js" diff --git a/tests/ext/plugins/Permission Test/config.json b/tests/ext/plugins/Permission Test/config.json index 1de44cd1..33f2ae3f 100644 --- a/tests/ext/plugins/Permission Test/config.json +++ b/tests/ext/plugins/Permission Test/config.json @@ -10,7 +10,7 @@ "twitter_username": "Jiiksi" } ], - "version": 1.0, + "version": "1.0", "description": "Permission Test Description" }, "main": "index.js", diff --git a/tests/ext/plugins/Render Example/config.json b/tests/ext/plugins/Render Example/config.json index ea3abb01..fbc0c489 100644 --- a/tests/ext/plugins/Render Example/config.json +++ b/tests/ext/plugins/Render Example/config.json @@ -10,7 +10,7 @@ "twitter_username": "Jiiksi" } ], - "version": 1.0, + "version": "1.0", "description": "Example for rendering stuff" }, "main": "index.js" diff --git a/tests/ext/themes/Example/config.json b/tests/ext/themes/Example/config.json index 2e657e4a..effb8b62 100644 --- a/tests/ext/themes/Example/config.json +++ b/tests/ext/themes/Example/config.json @@ -2,7 +2,7 @@ "info": { "name": "Example Theme 1", "authors": [ "Jiiks" ], - "version": 1.0, + "version": "1.0", "description": "Example Theme 1 Description", "icon": "icon.svg", "icon_type": "image/svg+xml", From a040a605d49c891b186837fb9aa93527cabe4f55 Mon Sep 17 00:00:00 2001 From: Jiiks Date: Wed, 29 Aug 2018 23:09:30 +0300 Subject: [PATCH 15/29] Version is in info not in config --- client/src/ui/components/bd/modals/InstallModal.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/src/ui/components/bd/modals/InstallModal.vue b/client/src/ui/components/bd/modals/InstallModal.vue index b1d72dec..b99378a6 100644 --- a/client/src/ui/components/bd/modals/InstallModal.vue +++ b/client/src/ui/components/bd/modals/InstallModal.vue @@ -63,8 +63,8 @@ if (alreadyInstalled) { this.alreadyInstalled = true; - if (config.version > alreadyInstalled.version) { - this.upDoDate = false; + if (config.info.version > alreadyInstalled.version) { + this.upToDate = false; } } From 8c060314da1a32ced2cd316e7f3131e75b3b1277 Mon Sep 17 00:00:00 2001 From: Jiiks Date: Thu, 30 Aug 2018 05:39:23 +0300 Subject: [PATCH 16/29] Functional installer/updater. Still needs lots of work. --- client/src/modules/modulemanager.js | 4 +-- client/src/modules/modules.js | 1 + client/src/modules/packageinstaller.js | 34 ++++++++++++++----- client/src/modules/reactcomponents.js | 6 ++-- .../ui/components/bd/modals/InstallModal.vue | 12 +++++-- 5 files changed, 42 insertions(+), 15 deletions(-) diff --git a/client/src/modules/modulemanager.js b/client/src/modules/modulemanager.js index 28f1b011..962b7e93 100644 --- a/client/src/modules/modulemanager.js +++ b/client/src/modules/modulemanager.js @@ -12,7 +12,6 @@ import { ClientLogger as Logger } from 'common'; import { SocketProxy, EventHook, CssEditor } from 'modules'; import { ProfileBadges, ClassNormaliser } from 'ui'; import Updater from './updater'; -import PackageInstaller from './packageinstaller'; /** * Module Manager initializes all modules when everything is ready @@ -29,8 +28,7 @@ export default class { new SocketProxy(), new EventHook(), CssEditor, - Updater, - new PackageInstaller() + Updater ]); } diff --git a/client/src/modules/modules.js b/client/src/modules/modules.js index 8f39537f..239e89f8 100644 --- a/client/src/modules/modules.js +++ b/client/src/modules/modules.js @@ -27,3 +27,4 @@ export { default as Connectivity } from './connectivity'; export { default as Security } from './security'; export { default as Cache } from './cache'; export { default as Reflection } from './reflection/index'; +export { default as PackageInstaller } from './packageinstaller'; diff --git a/client/src/modules/packageinstaller.js b/client/src/modules/packageinstaller.js index 8aa1f43e..7831aa8d 100644 --- a/client/src/modules/packageinstaller.js +++ b/client/src/modules/packageinstaller.js @@ -1,19 +1,16 @@ import EventListener from './eventlistener'; import asar from 'asar'; +import fs from 'fs'; +import path from 'path'; import { Modals } from 'ui'; import { Utils } from 'common'; import PluginManager from './pluginmanager'; +import Globals from './globals'; -export default class extends EventListener { +export default class { - get eventBindings() { - return [ - { id: 'install-pkg', callback: this.installPackage } - ]; - } - - async installPackage(pkg, upload) { + static async installPackageEvent(pkg, upload) { try { const config = JSON.parse(asar.extractFile(pkg.path, 'config.json').toString()); const { info, main } = config; @@ -26,6 +23,8 @@ export default class extends EventListener { if (icon) config.iconEncoded = icon; const isPlugin = info.type && info.type === 'plugin' || main.endsWith('.js'); + config.path = pkg.path; + /* config.permissions = [ { @@ -58,4 +57,23 @@ export default class extends EventListener { } catch (err) {} } + // TODO lots of stuff + /** + * Installs or updates defined package + * @param {Byte[]|String} bytesOrPath byte array of binary or path to local file + * @param {String} name Package name + * @param {Boolean} update Does an older version already exist + */ + static async installPackage(bytesOrPath, name, update = false) { + const bytes = typeof bytesOrPath === 'string' ? fs.readFileSync(bytesOrPath) : bytesOrPath; + const outputPath = path.join(Globals.getPath('plugins'), `${name}.bd`); + fs.writeFileSync(outputPath, bytes); + + if (!update) { + return PluginManager.preloadPackedContent(`${name}.bd`); + } + + return PluginManager.reloadContent(PluginManager.getPluginByName(name)); + } + } diff --git a/client/src/modules/reactcomponents.js b/client/src/modules/reactcomponents.js index 30e2161a..92f4e59e 100644 --- a/client/src/modules/reactcomponents.js +++ b/client/src/modules/reactcomponents.js @@ -15,7 +15,7 @@ import { Utils, Filters, ClientLogger as Logger } from 'common'; import { MonkeyPatch } from './patcher'; import Reflection from './reflection/index'; import DiscordApi from './discordapi'; -import Events from './events'; +import PackageInstaller from './packageinstaller'; class Helpers { static get plannedActions() { @@ -514,7 +514,9 @@ export class ReactAutoPatcher { e.stopImmediatePropagation(); stateNode.clearDragging(); - Events.emit('install-pkg', e.dataTransfer.files[0], DiscordApi.currentChannel.id); + PackageInstaller.installPackageEvent(e.dataTransfer.files[0], DiscordApi.currentChannel.id); + + // Events.emit('install-pkg', e.dataTransfer.files[0], DiscordApi.currentChannel.id); }; // Remove their handler, add ours, then read theirs to give ours priority to stop theirs when we get a .bd file. diff --git a/client/src/ui/components/bd/modals/InstallModal.vue b/client/src/ui/components/bd/modals/InstallModal.vue index b99378a6..013ab026 100644 --- a/client/src/ui/components/bd/modals/InstallModal.vue +++ b/client/src/ui/components/bd/modals/InstallModal.vue @@ -35,14 +35,14 @@
Upload
-
{{ !alreadyInstalled ? 'Install' : 'Update' }}
+
{{ !alreadyInstalled ? 'Install' : 'Update' }}
From ecb0b3e9d0036a34f47dc0ce1e7fa69de96a1c4d Mon Sep 17 00:00:00 2001 From: Jiiks Date: Thu, 30 Aug 2018 07:05:14 +0300 Subject: [PATCH 17/29] Verify step --- client/src/modules/packageinstaller.js | 15 +++++++++++++++ .../src/ui/components/bd/modals/InstallModal.vue | 15 +++++++++------ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/client/src/modules/packageinstaller.js b/client/src/modules/packageinstaller.js index 7831aa8d..09212c43 100644 --- a/client/src/modules/packageinstaller.js +++ b/client/src/modules/packageinstaller.js @@ -7,6 +7,7 @@ import { Modals } from 'ui'; import { Utils } from 'common'; import PluginManager from './pluginmanager'; import Globals from './globals'; +import Security from './security'; export default class { @@ -57,6 +58,19 @@ export default class { } catch (err) {} } + /** + * Hash and verify a package + * @param {Byte[]|String} bytesOrPath byte array of binary or path to local file + */ + static async verifyPackage(bytesOrPath) { + const bytes = typeof bytesOrPath === 'string' ? fs.readFileSync(bytesOrPath) : bytesOrPath; + // Temporary hash to simulate response from server + const tempVerified = '2e3532ee366816adc37b0f478bfef35e03f96e7aeee9b115f5918ef6a4e94de8'; + const hashBytes = Security.hash('sha256', bytes, 'hex'); + + return hashBytes === tempVerified; + } + // TODO lots of stuff /** * Installs or updates defined package @@ -66,6 +80,7 @@ export default class { */ static async installPackage(bytesOrPath, name, update = false) { const bytes = typeof bytesOrPath === 'string' ? fs.readFileSync(bytesOrPath) : bytesOrPath; + const outputPath = path.join(Globals.getPath('plugins'), `${name}.bd`); fs.writeFileSync(outputPath, bytes); diff --git a/client/src/ui/components/bd/modals/InstallModal.vue b/client/src/ui/components/bd/modals/InstallModal.vue index 013ab026..0ae6c92a 100644 --- a/client/src/ui/components/bd/modals/InstallModal.vue +++ b/client/src/ui/components/bd/modals/InstallModal.vue @@ -30,6 +30,9 @@
Verifying {{this.modal.contentType}}
+
+ Not verified! +
Up to date version already installed!
@@ -67,14 +70,14 @@ this.upToDate = false; } } - - // TODO Verify - setTimeout(() => { - this.verifying = false; - }, 2000); - + this.verify(); }, methods: { + async verify() { + const verified = await PackageInstaller.verifyPackage(this.modal.config.path); + this.verified = verified; + this.verifying = false; + }, async install() { const installed = await PackageInstaller.installPackage(this.modal.config.path, this.modal.config.info.name, this.alreadyInstalled); console.log(installed); From 6db016060b571df9bd34c7bc091a05dfec6558cf Mon Sep 17 00:00:00 2001 From: Jiiks Date: Thu, 30 Aug 2018 09:08:52 +0300 Subject: [PATCH 18/29] Small things --- client/src/modules/packageinstaller.js | 46 +++++-------------- client/src/modules/reactcomponents.js | 2 +- .../styles/partials/modals/install-modal.scss | 29 ++++++++++-- .../ui/components/bd/modals/InstallModal.vue | 24 ++++++---- client/src/ui/modals.js | 8 ++-- 5 files changed, 57 insertions(+), 52 deletions(-) diff --git a/client/src/modules/packageinstaller.js b/client/src/modules/packageinstaller.js index 09212c43..77e86fc7 100644 --- a/client/src/modules/packageinstaller.js +++ b/client/src/modules/packageinstaller.js @@ -11,7 +11,7 @@ import Security from './security'; export default class { - static async installPackageEvent(pkg, upload) { + static async installPackageDragAndDrop(pkg, upload) { try { const config = JSON.parse(asar.extractFile(pkg.path, 'config.json').toString()); const { info, main } = config; @@ -21,54 +21,31 @@ export default class { const extractIcon = asar.extractFile(pkg.path, info.icon); icon = `data:${info.icon_type};base64,${Utils.arrayBufferToBase64(extractIcon)}`; } - if (icon) config.iconEncoded = icon; + const isPlugin = info.type && info.type === 'plugin' || main.endsWith('.js'); - config.path = pkg.path; - - /* - config.permissions = [ - { - HEADER: 'Test Permission Header', - BODY: 'Test Permission Body' - }, - { - HEADER: 'Test Permission Header', - BODY: 'Test Permission Body' - }, - { - HEADER: 'Test Permission Header', - BODY: 'Test Permission Body' - }, - { - HEADER: 'Test Permission Header', - BODY: 'Test Permission Body' - } - ]; - */ // Show install modal - const modalResult = await Modals.installModal(isPlugin ? 'plugin' : 'theme', config).promise; + const modalResult = await Modals.installModal(isPlugin ? 'plugin' : 'theme', config, pkg.path, icon).promise; if (modalResult === 0) { // Upload it instead } - console.log(modalResult); - } catch (err) {} } /** * Hash and verify a package * @param {Byte[]|String} bytesOrPath byte array of binary or path to local file + * @param {String} id Package id */ - static async verifyPackage(bytesOrPath) { + static async verifyPackage(bytesOrPath, id) { const bytes = typeof bytesOrPath === 'string' ? fs.readFileSync(bytesOrPath) : bytesOrPath; // Temporary hash to simulate response from server - const tempVerified = '2e3532ee366816adc37b0f478bfef35e03f96e7aeee9b115f5918ef6a4e94de8'; + const tempVerified = ['2e3532ee366816adc37b0f478bfef35e03f96e7aeee9b115f5918ef6a4e94de8', '06a2eb4e37b926354ab80cd83207db67e544c932e9beddce545967a21f8db5aa']; const hashBytes = Security.hash('sha256', bytes, 'hex'); - return hashBytes === tempVerified; + return tempVerified.includes(hashBytes); } // TODO lots of stuff @@ -78,17 +55,18 @@ export default class { * @param {String} name Package name * @param {Boolean} update Does an older version already exist */ - static async installPackage(bytesOrPath, name, update = false) { + static async installPackage(bytesOrPath, id, update = false) { const bytes = typeof bytesOrPath === 'string' ? fs.readFileSync(bytesOrPath) : bytesOrPath; - const outputPath = path.join(Globals.getPath('plugins'), `${name}.bd`); + const outputName = `${id}.bd`; + const outputPath = path.join(Globals.getPath('plugins'), outputName); fs.writeFileSync(outputPath, bytes); if (!update) { - return PluginManager.preloadPackedContent(`${name}.bd`); + return PluginManager.preloadPackedContent(outputName); } - return PluginManager.reloadContent(PluginManager.getPluginByName(name)); + return PluginManager.reloadContent(PluginManager.getPluginById(id)); } } diff --git a/client/src/modules/reactcomponents.js b/client/src/modules/reactcomponents.js index 92f4e59e..662d6a8a 100644 --- a/client/src/modules/reactcomponents.js +++ b/client/src/modules/reactcomponents.js @@ -514,7 +514,7 @@ export class ReactAutoPatcher { e.stopImmediatePropagation(); stateNode.clearDragging(); - PackageInstaller.installPackageEvent(e.dataTransfer.files[0], DiscordApi.currentChannel.id); + PackageInstaller.installPackageDragAndDrop(e.dataTransfer.files[0], DiscordApi.currentChannel.id); // Events.emit('install-pkg', e.dataTransfer.files[0], DiscordApi.currentChannel.id); }; diff --git a/client/src/styles/partials/modals/install-modal.scss b/client/src/styles/partials/modals/install-modal.scss index 0f676c3a..b474ebb5 100644 --- a/client/src/styles/partials/modals/install-modal.scss +++ b/client/src/styles/partials/modals/install-modal.scss @@ -1,5 +1,11 @@ .bd-installModal { + &.bd-err { + .bd-modalInner { + border: 2px solid $colerr; + } + } + .bd-modalInner { min-width: 520px; min-height: 200px; @@ -85,7 +91,17 @@ background: rgba(0, 0, 0, .1); .bd-installModalStatus { - color: #fff; + height: 36px; + line-height: 36px; + flex-grow: 1; + padding: 0 25px; + } + + .bd-installModalStatus { + &:not(.bd-err) { + color: #fff; + } + font-weight: 600; } @@ -94,14 +110,21 @@ padding: 10px; border-radius: 3px; min-width: 100px; - background: #3ecc9c; transition: opacity .2s ease-in-out; + &.bd-ok { + background: #3ecc9c; + } + + &.bd-err { + color: #fff; + } + &:hover { opacity: .8; } - &:first-child { + &.bd-installModalUpload { background: transparent; transition: none; diff --git a/client/src/ui/components/bd/modals/InstallModal.vue b/client/src/ui/components/bd/modals/InstallModal.vue index 0ae6c92a..0d2010aa 100644 --- a/client/src/ui/components/bd/modals/InstallModal.vue +++ b/client/src/ui/components/bd/modals/InstallModal.vue @@ -1,13 +1,13 @@