From b0a01ed885ffdab858de3c74ffa88c3dfa52c732 Mon Sep 17 00:00:00 2001 From: neelkamath Date: Fri, 11 May 2018 19:04:09 +0530 Subject: Add pm2 as a dev dependency --- server/package-lock.json | 2425 +++++++++++++++++++++++++++++++++++++++++++++- server/package.json | 3 + 2 files changed, 2425 insertions(+), 3 deletions(-) (limited to 'server') diff --git a/server/package-lock.json b/server/package-lock.json index 32a861d..c17f028 100644 --- a/server/package-lock.json +++ b/server/package-lock.json @@ -1,9 +1,30 @@ { "name": "hack.chat-v2", - "version": "2.0.0", + "version": "2.0.1", "lockfileVersion": 1, "requires": true, "dependencies": { + "amp": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/amp/-/amp-0.3.1.tgz", + "integrity": "sha1-at+NWKdPNh6CwfqNOJwHnhOfxH0=", + "dev": true + }, + "amp-message": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/amp-message/-/amp-message-0.1.2.tgz", + "integrity": "sha1-p48cmJlQh602GSpBKY5NtJ49/EU=", + "dev": true, + "requires": { + "amp": "0.3.1" + } + }, + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "dev": true + }, "ansi-styles": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", @@ -12,16 +33,95 @@ "color-convert": "1.9.1" } }, + "anymatch": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-2.0.0.tgz", + "integrity": "sha512-5teOsQWABXHHBFP9y3skS5P3d/WfWXpv3FUpy+LorMrNYaT9pI4oLMQX7jzQ2KklNpGpWHzdCXTDT2Y3XGlZBw==", + "dev": true, + "requires": { + "micromatch": "3.1.10", + "normalize-path": "2.1.1" + } + }, + "argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dev": true, + "requires": { + "sprintf-js": "1.0.3" + }, + "dependencies": { + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", + "dev": true + } + } + }, + "arr-diff": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", + "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=", + "dev": true + }, + "arr-flatten": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", + "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", + "dev": true + }, + "arr-union": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz", + "integrity": "sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ=", + "dev": true + }, + "array-unique": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", + "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", + "dev": true + }, + "assign-symbols": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz", + "integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=", + "dev": true + }, "async": { "version": "0.9.2", "resolved": "https://registry.npmjs.org/async/-/async-0.9.2.tgz", "integrity": "sha1-rqdNXmHB+JlhO/ZL2mbUx48v0X0=" }, + "async-each": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/async-each/-/async-each-1.0.1.tgz", + "integrity": "sha1-GdOGodntxufByF04iu28xW0zYC0=", + "dev": true + }, "async-limiter": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.0.tgz", "integrity": "sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg==" }, + "async-listener": { + "version": "0.6.9", + "resolved": "https://registry.npmjs.org/async-listener/-/async-listener-0.6.9.tgz", + "integrity": "sha512-E7Z2/QMs0EPt/o9wpYO/J3hmMCDdr1aVDS3ttlur5D5JlZtxhfuOwi4e7S8zbYIxA5qOOYdxfqGj97XAfdNvkQ==", + "dev": true, + "requires": { + "semver": "5.5.0", + "shimmer": "1.2.0" + } + }, + "atob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.1.tgz", + "integrity": "sha1-ri1acpR38onWDdf5amMUoi3Wwio=", + "dev": true + }, "babel-runtime": { "version": "6.26.0", "resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz", @@ -36,11 +136,78 @@ "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" }, + "base": { + "version": "0.11.2", + "resolved": "https://registry.npmjs.org/base/-/base-0.11.2.tgz", + "integrity": "sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg==", + "dev": true, + "requires": { + "cache-base": "1.0.1", + "class-utils": "0.3.6", + "component-emitter": "1.2.1", + "define-property": "1.0.0", + "isobject": "3.0.1", + "mixin-deep": "1.3.1", + "pascalcase": "0.1.1" + }, + "dependencies": { + "define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", + "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", + "dev": true, + "requires": { + "is-descriptor": "1.0.2" + } + }, + "is-accessor-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", + "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", + "dev": true, + "requires": { + "kind-of": "6.0.2" + } + }, + "is-data-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", + "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", + "dev": true, + "requires": { + "kind-of": "6.0.2" + } + }, + "is-descriptor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", + "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "1.0.0", + "is-data-descriptor": "1.0.0", + "kind-of": "6.0.2" + } + } + } + }, + "binary-extensions": { + "version": "1.11.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.11.0.tgz", + "integrity": "sha1-RqoXUftqL5PuXmibsQh9SxTGwgU=", + "dev": true + }, "bindings": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.2.1.tgz", "integrity": "sha1-FK1hE4EtLTfXLme0ystLtyZQXxE=" }, + "blessed": { + "version": "0.1.81", + "resolved": "https://registry.npmjs.org/blessed/-/blessed-0.1.81.tgz", + "integrity": "sha1-+WLWh+wsNpVwrnGvhDJW5tDKESk=", + "dev": true + }, "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -50,6 +217,58 @@ "concat-map": "0.0.1" } }, + "braces": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz", + "integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==", + "dev": true, + "requires": { + "arr-flatten": "1.1.0", + "array-unique": "0.3.2", + "extend-shallow": "2.0.1", + "fill-range": "4.0.0", + "isobject": "3.0.1", + "repeat-element": "1.1.2", + "snapdragon": "0.8.2", + "snapdragon-node": "2.1.1", + "split-string": "3.1.0", + "to-regex": "3.0.2" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "0.1.1" + } + } + } + }, + "buffer-from": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.0.0.tgz", + "integrity": "sha512-83apNb8KK0Se60UE1+4Ukbe3HbfELJ6UlI4ldtOGs7So4KD26orJM8hIY9lxdzP+UpItH1Yh/Y8GUvNFWFFRxA==", + "dev": true + }, + "cache-base": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz", + "integrity": "sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ==", + "dev": true, + "requires": { + "collection-visit": "1.0.0", + "component-emitter": "1.2.1", + "get-value": "2.0.6", + "has-value": "1.0.0", + "isobject": "3.0.1", + "set-value": "2.0.0", + "to-object-path": "0.3.0", + "union-value": "1.0.0", + "unset-value": "1.0.0" + } + }, "chalk": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.2.tgz", @@ -60,6 +279,101 @@ "supports-color": "5.3.0" } }, + "charm": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/charm/-/charm-0.1.2.tgz", + "integrity": "sha1-BsIe7RobBq62dVPNxT4jJ0usIpY=", + "dev": true + }, + "chokidar": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.0.3.tgz", + "integrity": "sha512-zW8iXYZtXMx4kux/nuZVXjkLP+CyIK5Al5FHnj1OgTKGZfp4Oy6/ymtMSKFv3GD8DviEmUPmJg9eFdJ/JzudMg==", + "dev": true, + "requires": { + "anymatch": "2.0.0", + "async-each": "1.0.1", + "braces": "2.3.2", + "fsevents": "1.2.3", + "glob-parent": "3.1.0", + "inherits": "2.0.3", + "is-binary-path": "1.0.1", + "is-glob": "4.0.0", + "normalize-path": "2.1.1", + "path-is-absolute": "1.0.1", + "readdirp": "2.1.0", + "upath": "1.0.5" + } + }, + "class-utils": { + "version": "0.3.6", + "resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz", + "integrity": "sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg==", + "dev": true, + "requires": { + "arr-union": "3.1.0", + "define-property": "0.2.5", + "isobject": "3.0.1", + "static-extend": "0.1.2" + }, + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "0.1.6" + } + } + } + }, + "cli-table-redemption": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/cli-table-redemption/-/cli-table-redemption-1.0.1.tgz", + "integrity": "sha512-SjVCciRyx01I4azo2K2rcc0NP/wOceXGzG1ZpYkEulbbIxDA/5YWv0oxG2HtQ4v8zPC6bgbRI7SbNaTZCxMNkg==", + "dev": true, + "requires": { + "chalk": "1.1.3" + }, + "dependencies": { + "ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "dev": true + }, + "chalk": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "dev": true, + "requires": { + "ansi-styles": "2.2.1", + "escape-string-regexp": "1.0.5", + "has-ansi": "2.0.0", + "strip-ansi": "3.0.1", + "supports-color": "2.0.0" + } + }, + "supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", + "dev": true + } + } + }, + "collection-visit": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/collection-visit/-/collection-visit-1.0.0.tgz", + "integrity": "sha1-S8A3PBZLwykbTTaMgpzxqApZ3KA=", + "dev": true, + "requires": { + "map-visit": "1.0.0", + "object-visit": "1.0.1" + } + }, "color-convert": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", @@ -78,6 +392,12 @@ "resolved": "https://registry.npmjs.org/colors/-/colors-1.1.2.tgz", "integrity": "sha1-FopHAXVran9RoSzgyXv6KMCE7WM=" }, + "commander": { + "version": "2.13.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.13.0.tgz", + "integrity": "sha512-MVuS359B+YzaWqjCL/c+22gfryv+mCBPHAv3zyVI2GN8EY6IRP8VwtasXn8jyyhvvq84R4ImN1OKRtcbIasjYA==", + "dev": true + }, "common-tags": { "version": "1.7.2", "resolved": "https://registry.npmjs.org/common-tags/-/common-tags-1.7.2.tgz", @@ -86,16 +406,53 @@ "babel-runtime": "6.26.0" } }, + "component-emitter": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz", + "integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY=", + "dev": true + }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" }, + "continuation-local-storage": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/continuation-local-storage/-/continuation-local-storage-3.2.1.tgz", + "integrity": "sha512-jx44cconVqkCEEyLSKWwkvUXwO561jXMa3LPjTPsm5QR22PA0/mhe33FT4Xb5y74JDvt/Cq+5lm8S8rskLv9ZA==", + "dev": true, + "requires": { + "async-listener": "0.6.9", + "emitter-listener": "1.1.1" + } + }, + "copy-descriptor": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz", + "integrity": "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=", + "dev": true + }, "core-js": { "version": "2.5.3", "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.5.3.tgz", "integrity": "sha1-isw4NFgk8W2DZbfJtCWRaOjtYD4=" }, + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", + "dev": true + }, + "cron": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/cron/-/cron-1.3.0.tgz", + "integrity": "sha512-K/SF7JlgMmNjcThWxkKvsHhey2EDB4CeOEWJ9aXWj3fbQJppsvTPIeyLdHfNq5IbbsMUUjRW1nr5dSO95f2E4w==", + "dev": true, + "requires": { + "moment-timezone": "0.5.16" + } + }, "cycle": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/cycle/-/cycle-1.0.3.tgz", @@ -115,11 +472,76 @@ "nan": "2.9.2" } }, + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "decode-uri-component": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz", + "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=", + "dev": true + }, "deep-equal": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-0.2.2.tgz", "integrity": "sha1-hLdFiW80xoTpjyzg5Cq69Du6AX0=" }, + "deep-metrics": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/deep-metrics/-/deep-metrics-0.0.1.tgz", + "integrity": "sha512-732WmZgCWxOkf4QBvrCjPPuT6wTEzaGye/4JqYsU/sO0J53UNX4PBwK0JV262BZ5cxgLmKhU+NlrtKdPDgybkg==", + "dev": true, + "requires": { + "semver": "5.5.0" + } + }, + "define-property": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-2.0.2.tgz", + "integrity": "sha512-jwK2UV4cnPpbcG7+VRARKTZPUWowwXA8bzH5NP6ud0oeAxyYPuGZUAC7hMugpCdz4BeSZl2Dl9k66CHJ/46ZYQ==", + "dev": true, + "requires": { + "is-descriptor": "1.0.2", + "isobject": "3.0.1" + }, + "dependencies": { + "is-accessor-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", + "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", + "dev": true, + "requires": { + "kind-of": "6.0.2" + } + }, + "is-data-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", + "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", + "dev": true, + "requires": { + "kind-of": "6.0.2" + } + }, + "is-descriptor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", + "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "1.0.0", + "is-data-descriptor": "1.0.0", + "kind-of": "6.0.2" + } + } + } + }, "didyoumean2": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/didyoumean2/-/didyoumean2-1.3.0.tgz", @@ -129,16 +551,217 @@ "lodash": "4.17.5" } }, + "emitter-listener": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/emitter-listener/-/emitter-listener-1.1.1.tgz", + "integrity": "sha1-6Lu+gkS8jg0LTvcc0UKUx/JBx+w=", + "dev": true, + "requires": { + "shimmer": "1.2.0" + } + }, + "escape-regexp": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/escape-regexp/-/escape-regexp-0.0.1.tgz", + "integrity": "sha1-9EvaEtRbvfnLf4Yu5+SCez3TIlQ=", + "dev": true + }, "escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" }, + "eventemitter2": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/eventemitter2/-/eventemitter2-1.0.5.tgz", + "integrity": "sha1-+YNhBRexc3wLncZDvsqTiTwE3xg=", + "dev": true + }, + "expand-brackets": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", + "integrity": "sha1-t3c14xXOMPa27/D4OwQVGiJEliI=", + "dev": true, + "requires": { + "debug": "2.6.9", + "define-property": "0.2.5", + "extend-shallow": "2.0.1", + "posix-character-classes": "0.1.1", + "regex-not": "1.0.2", + "snapdragon": "0.8.2", + "to-regex": "3.0.2" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "0.1.6" + } + }, + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "0.1.1" + } + } + } + }, + "extend": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.1.tgz", + "integrity": "sha1-p1Xqe8Gt/MWjHOfnYtuq3F5jZEQ=", + "dev": true + }, + "extend-shallow": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", + "integrity": "sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg=", + "dev": true, + "requires": { + "assign-symbols": "1.0.0", + "is-extendable": "1.0.1" + }, + "dependencies": { + "is-extendable": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", + "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", + "dev": true, + "requires": { + "is-plain-object": "2.0.4" + } + } + } + }, + "extglob": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/extglob/-/extglob-2.0.4.tgz", + "integrity": "sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw==", + "dev": true, + "requires": { + "array-unique": "0.3.2", + "define-property": "1.0.0", + "expand-brackets": "2.1.4", + "extend-shallow": "2.0.1", + "fragment-cache": "0.2.1", + "regex-not": "1.0.2", + "snapdragon": "0.8.2", + "to-regex": "3.0.2" + }, + "dependencies": { + "define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", + "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", + "dev": true, + "requires": { + "is-descriptor": "1.0.2" + } + }, + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "0.1.1" + } + }, + "is-accessor-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", + "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", + "dev": true, + "requires": { + "kind-of": "6.0.2" + } + }, + "is-data-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", + "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", + "dev": true, + "requires": { + "kind-of": "6.0.2" + } + }, + "is-descriptor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", + "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "1.0.0", + "is-data-descriptor": "1.0.0", + "kind-of": "6.0.2" + } + } + } + }, "eyes": { "version": "0.1.8", "resolved": "https://registry.npmjs.org/eyes/-/eyes-0.1.8.tgz", "integrity": "sha1-Ys8SAjTGg3hdkCNIqADvPgzCC8A=" }, + "fclone": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/fclone/-/fclone-1.0.11.tgz", + "integrity": "sha1-EOhdo4v+p/xZk0HClu4ddyZu5kA=", + "dev": true + }, + "fill-range": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", + "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=", + "dev": true, + "requires": { + "extend-shallow": "2.0.1", + "is-number": "3.0.0", + "repeat-string": "1.6.1", + "to-regex-range": "2.1.1" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "0.1.1" + } + } + } + }, + "for-in": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", + "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=", + "dev": true + }, + "fragment-cache": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz", + "integrity": "sha1-QpD60n8T6Jvn8zeZxrxaCr//DRk=", + "dev": true, + "requires": { + "map-cache": "0.2.2" + } + }, "fs-extra": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-5.0.0.tgz", @@ -154,6 +777,547 @@ "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" }, + "fsevents": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.3.tgz", + "integrity": "sha512-X+57O5YkDTiEQGiw8i7wYc2nQgweIekqkepI8Q3y4wVlurgBt2SuwxTeYUYMZIGpLZH3r/TsMjczCMXE5ZOt7Q==", + "dev": true, + "optional": true, + "requires": { + "nan": "2.9.2", + "node-pre-gyp": "0.9.1" + }, + "dependencies": { + "abbrev": { + "version": "1.1.1", + "bundled": true, + "dev": true, + "optional": true + }, + "ansi-regex": { + "version": "2.1.1", + "bundled": true, + "dev": true + }, + "aproba": { + "version": "1.2.0", + "bundled": true, + "dev": true, + "optional": true + }, + "are-we-there-yet": { + "version": "1.1.4", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "delegates": "1.0.0", + "readable-stream": "2.3.6" + } + }, + "balanced-match": { + "version": "1.0.0", + "bundled": true, + "dev": true + }, + "brace-expansion": { + "version": "1.1.11", + "bundled": true, + "dev": true, + "requires": { + "balanced-match": "1.0.0", + "concat-map": "0.0.1" + } + }, + "chownr": { + "version": "1.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "code-point-at": { + "version": "1.1.0", + "bundled": true, + "dev": true + }, + "concat-map": { + "version": "0.0.1", + "bundled": true, + "dev": true + }, + "console-control-strings": { + "version": "1.1.0", + "bundled": true, + "dev": true + }, + "core-util-is": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "optional": true + }, + "debug": { + "version": "2.6.9", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "ms": "2.0.0" + } + }, + "deep-extend": { + "version": "0.4.2", + "bundled": true, + "dev": true, + "optional": true + }, + "delegates": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "detect-libc": { + "version": "1.0.3", + "bundled": true, + "dev": true, + "optional": true + }, + "fs-minipass": { + "version": "1.2.5", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "minipass": "2.2.4" + } + }, + "fs.realpath": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "gauge": { + "version": "2.7.4", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "aproba": "1.2.0", + "console-control-strings": "1.1.0", + "has-unicode": "2.0.1", + "object-assign": "4.1.1", + "signal-exit": "3.0.2", + "string-width": "1.0.2", + "strip-ansi": "3.0.1", + "wide-align": "1.1.2" + } + }, + "glob": { + "version": "7.1.2", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "fs.realpath": "1.0.0", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "1.0.1" + } + }, + "has-unicode": { + "version": "2.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "iconv-lite": { + "version": "0.4.21", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "safer-buffer": "2.1.2" + } + }, + "ignore-walk": { + "version": "3.0.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "minimatch": "3.0.4" + } + }, + "inflight": { + "version": "1.0.6", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "once": "1.4.0", + "wrappy": "1.0.2" + } + }, + "inherits": { + "version": "2.0.3", + "bundled": true, + "dev": true + }, + "ini": { + "version": "1.3.5", + "bundled": true, + "dev": true, + "optional": true + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "requires": { + "number-is-nan": "1.0.1" + } + }, + "isarray": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "minimatch": { + "version": "3.0.4", + "bundled": true, + "dev": true, + "requires": { + "brace-expansion": "1.1.11" + } + }, + "minimist": { + "version": "0.0.8", + "bundled": true, + "dev": true + }, + "minipass": { + "version": "2.2.4", + "bundled": true, + "dev": true, + "requires": { + "safe-buffer": "5.1.1", + "yallist": "3.0.2" + } + }, + "minizlib": { + "version": "1.1.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "minipass": "2.2.4" + } + }, + "mkdirp": { + "version": "0.5.1", + "bundled": true, + "dev": true, + "requires": { + "minimist": "0.0.8" + } + }, + "ms": { + "version": "2.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "needle": { + "version": "2.2.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "debug": "2.6.9", + "iconv-lite": "0.4.21", + "sax": "1.2.4" + } + }, + "node-pre-gyp": { + "version": "0.9.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "detect-libc": "1.0.3", + "mkdirp": "0.5.1", + "needle": "2.2.0", + "nopt": "4.0.1", + "npm-packlist": "1.1.10", + "npmlog": "4.1.2", + "rc": "1.2.6", + "rimraf": "2.6.2", + "semver": "5.5.0", + "tar": "4.4.1" + } + }, + "nopt": { + "version": "4.0.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "abbrev": "1.1.1", + "osenv": "0.1.5" + } + }, + "npm-bundled": { + "version": "1.0.3", + "bundled": true, + "dev": true, + "optional": true + }, + "npm-packlist": { + "version": "1.1.10", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "ignore-walk": "3.0.1", + "npm-bundled": "1.0.3" + } + }, + "npmlog": { + "version": "4.1.2", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "are-we-there-yet": "1.1.4", + "console-control-strings": "1.1.0", + "gauge": "2.7.4", + "set-blocking": "2.0.0" + } + }, + "number-is-nan": { + "version": "1.0.1", + "bundled": true, + "dev": true + }, + "object-assign": { + "version": "4.1.1", + "bundled": true, + "dev": true, + "optional": true + }, + "once": { + "version": "1.4.0", + "bundled": true, + "dev": true, + "requires": { + "wrappy": "1.0.2" + } + }, + "os-homedir": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "optional": true + }, + "os-tmpdir": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "optional": true + }, + "osenv": { + "version": "0.1.5", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "os-homedir": "1.0.2", + "os-tmpdir": "1.0.2" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "process-nextick-args": { + "version": "2.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "rc": { + "version": "1.2.6", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "deep-extend": "0.4.2", + "ini": "1.3.5", + "minimist": "1.2.0", + "strip-json-comments": "2.0.1" + }, + "dependencies": { + "minimist": { + "version": "1.2.0", + "bundled": true, + "dev": true, + "optional": true + } + } + }, + "readable-stream": { + "version": "2.3.6", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "1.0.0", + "process-nextick-args": "2.0.0", + "safe-buffer": "5.1.1", + "string_decoder": "1.1.1", + "util-deprecate": "1.0.2" + } + }, + "rimraf": { + "version": "2.6.2", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "glob": "7.1.2" + } + }, + "safe-buffer": { + "version": "5.1.1", + "bundled": true, + "dev": true + }, + "safer-buffer": { + "version": "2.1.2", + "bundled": true, + "dev": true, + "optional": true + }, + "sax": { + "version": "1.2.4", + "bundled": true, + "dev": true, + "optional": true + }, + "semver": { + "version": "5.5.0", + "bundled": true, + "dev": true, + "optional": true + }, + "set-blocking": { + "version": "2.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "signal-exit": { + "version": "3.0.2", + "bundled": true, + "dev": true, + "optional": true + }, + "string-width": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "requires": { + "code-point-at": "1.1.0", + "is-fullwidth-code-point": "1.0.0", + "strip-ansi": "3.0.1" + } + }, + "string_decoder": { + "version": "1.1.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "safe-buffer": "5.1.1" + } + }, + "strip-ansi": { + "version": "3.0.1", + "bundled": true, + "dev": true, + "requires": { + "ansi-regex": "2.1.1" + } + }, + "strip-json-comments": { + "version": "2.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "tar": { + "version": "4.4.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "chownr": "1.0.1", + "fs-minipass": "1.2.5", + "minipass": "2.2.4", + "minizlib": "1.1.0", + "mkdirp": "0.5.1", + "safe-buffer": "5.1.1", + "yallist": "3.0.2" + } + }, + "util-deprecate": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "optional": true + }, + "wide-align": { + "version": "1.1.2", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "string-width": "1.0.2" + } + }, + "wrappy": { + "version": "1.0.2", + "bundled": true, + "dev": true + }, + "yallist": { + "version": "3.0.2", + "bundled": true, + "dev": true + } + } + }, + "get-value": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/get-value/-/get-value-2.0.6.tgz", + "integrity": "sha1-3BXKHGcjh8p2vTesCjlbogQqLCg=", + "dev": true + }, + "gkt": { + "version": "https://tgz.pm2.io/gkt-1.0.0.tgz", + "integrity": "sha512-zr6QQnzLt3Ja0t0XI8gws2kn7zV2p0l/D3kreNvS6hFZhVU5g+uY/30l42jbgt0XGcNBEmBDGJR71J692V92tA==", + "dev": true, + "optional": true + }, "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", @@ -167,21 +1331,92 @@ "path-is-absolute": "1.0.1" } }, + "glob-parent": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", + "integrity": "sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4=", + "dev": true, + "requires": { + "is-glob": "3.1.0", + "path-dirname": "1.0.2" + }, + "dependencies": { + "is-glob": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz", + "integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=", + "dev": true, + "requires": { + "is-extglob": "2.1.1" + } + } + } + }, "graceful-fs": { "version": "4.1.11", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=" }, + "has-ansi": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", + "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", + "dev": true, + "requires": { + "ansi-regex": "2.1.1" + } + }, "has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=" }, - "i": { - "version": "0.3.6", + "has-value": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-value/-/has-value-1.0.0.tgz", + "integrity": "sha1-GLKB2lhbHFxR3vJMkw7SmgvmsXc=", + "dev": true, + "requires": { + "get-value": "2.0.6", + "has-values": "1.0.0", + "isobject": "3.0.1" + } + }, + "has-values": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-values/-/has-values-1.0.0.tgz", + "integrity": "sha1-lbC2P+whRmGab+V/51Yo1aOe/k8=", + "dev": true, + "requires": { + "is-number": "3.0.0", + "kind-of": "4.0.0" + }, + "dependencies": { + "kind-of": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-4.0.0.tgz", + "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=", + "dev": true, + "requires": { + "is-buffer": "1.1.6" + } + } + } + }, + "i": { + "version": "0.3.6", "resolved": "https://registry.npmjs.org/i/-/i-0.3.6.tgz", "integrity": "sha1-2WyScyB28HJxG2sQ/X1PZa2O4j0=" }, + "iconv-lite": { + "version": "0.4.23", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.23.tgz", + "integrity": "sha512-neyTUVFtahjf0mB3dZT77u+8O0QB89jFdnBkd5P1JgYPbPaia3gXXOVL2fq8VyU2gMMD7SaN7QukTB/pmXYvDA==", + "dev": true, + "requires": { + "safer-buffer": "2.1.2" + } + }, "inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", @@ -196,11 +1431,188 @@ "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" }, + "interpret": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.1.0.tgz", + "integrity": "sha1-ftGxQQxqDg94z5XTuEQMY/eLhhQ=", + "dev": true + }, + "is": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/is/-/is-3.2.1.tgz", + "integrity": "sha1-0Kwq1V63sL7JJqUmb2xmKqqD3KU=", + "dev": true + }, + "is-accessor-descriptor": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", + "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", + "dev": true, + "requires": { + "kind-of": "3.2.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "1.1.6" + } + } + } + }, + "is-binary-path": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-1.0.1.tgz", + "integrity": "sha1-dfFmQrSA8YenEcgUFh/TpKdlWJg=", + "dev": true, + "requires": { + "binary-extensions": "1.11.0" + } + }, + "is-buffer": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", + "dev": true + }, + "is-data-descriptor": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", + "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", + "dev": true, + "requires": { + "kind-of": "3.2.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "1.1.6" + } + } + } + }, + "is-descriptor": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", + "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "0.1.6", + "is-data-descriptor": "0.1.4", + "kind-of": "5.1.0" + }, + "dependencies": { + "kind-of": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", + "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", + "dev": true + } + } + }, + "is-extendable": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", + "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=", + "dev": true + }, + "is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", + "dev": true + }, + "is-glob": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.0.tgz", + "integrity": "sha1-lSHHaEXMJhCoUgPd8ICpWML/q8A=", + "dev": true, + "requires": { + "is-extglob": "2.1.1" + } + }, + "is-number": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", + "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", + "dev": true, + "requires": { + "kind-of": "3.2.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "1.1.6" + } + } + } + }, + "is-odd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-odd/-/is-odd-2.0.0.tgz", + "integrity": "sha512-OTiixgpZAT1M4NHgS5IguFp/Vz2VI3U7Goh4/HA1adtwyLtSBrxYlcSYkhpAE07s4fKEcjrFxyvtQBND4vFQyQ==", + "dev": true, + "requires": { + "is-number": "4.0.0" + }, + "dependencies": { + "is-number": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-4.0.0.tgz", + "integrity": "sha512-rSklcAIlf1OmFdyAqbnWTLVelsQ58uvZ66S/ZyawjWqIviTWCjg2PzVGw8WUA+nNuPTqb4wgA+NszrJ+08LlgQ==", + "dev": true + } + } + }, + "is-plain-object": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", + "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==", + "dev": true, + "requires": { + "isobject": "3.0.1" + } + }, + "is-windows": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", + "integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==", + "dev": true + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + }, + "isobject": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", + "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", + "dev": true + }, "isstream": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=" }, + "json-stringify-safe": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", + "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=", + "dev": true + }, "jsonfile": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", @@ -209,6 +1621,18 @@ "graceful-fs": "4.1.11" } }, + "kind-of": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", + "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", + "dev": true + }, + "lazy": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/lazy/-/lazy-1.0.11.tgz", + "integrity": "sha1-2qBoIGKCVCwIgojpdcKXwa53tpA=", + "dev": true + }, "leven": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/leven/-/leven-2.1.0.tgz", @@ -219,6 +1643,66 @@ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.5.tgz", "integrity": "sha512-svL3uiZf1RwhH+cWrfZn3A4+U58wbP0tGVTLQPbjplZxZ8ROD9VLuNgsRniTlLe7OlSqR79RUehXgpBW/s0IQw==" }, + "lodash.findindex": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/lodash.findindex/-/lodash.findindex-4.6.0.tgz", + "integrity": "sha1-oyRd7mH7m24GJLU1ElYku2nBEQY=", + "dev": true + }, + "lodash.isequal": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz", + "integrity": "sha1-QVxEePK8wwEgwizhDtMib30+GOA=", + "dev": true + }, + "lodash.merge": { + "version": "4.6.1", + "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.1.tgz", + "integrity": "sha512-AOYza4+Hf5z1/0Hztxpm2/xiPZgi/cjMqdnKTUWTBSKchJlxXXuUSxCCl8rJlf4g6yww/j6mA8nC8Hw/EZWxKQ==", + "dev": true + }, + "map-cache": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz", + "integrity": "sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8=", + "dev": true + }, + "map-visit": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/map-visit/-/map-visit-1.0.0.tgz", + "integrity": "sha1-7Nyo8TFE5mDxtb1B8S80edmN+48=", + "dev": true, + "requires": { + "object-visit": "1.0.1" + } + }, + "methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=", + "dev": true + }, + "micromatch": { + "version": "3.1.10", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", + "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", + "dev": true, + "requires": { + "arr-diff": "4.0.0", + "array-unique": "0.3.2", + "braces": "2.3.2", + "define-property": "2.0.2", + "extend-shallow": "3.0.2", + "extglob": "2.0.4", + "fragment-cache": "0.2.1", + "kind-of": "6.0.2", + "nanomatch": "1.2.9", + "object.pick": "1.3.0", + "regex-not": "1.0.2", + "snapdragon": "0.8.2", + "to-regex": "3.0.2" + } + }, "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", @@ -232,6 +1716,27 @@ "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" }, + "mixin-deep": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.1.tgz", + "integrity": "sha512-8ZItLHeEgaqEvd5lYBXfm4EZSFCX29Jb9K+lAHhDKzReKBQKj3R+7NOF6tjqYi9t4oI8VUfaWITJQm86wnXGNQ==", + "dev": true, + "requires": { + "for-in": "1.0.2", + "is-extendable": "1.0.1" + }, + "dependencies": { + "is-extendable": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", + "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", + "dev": true, + "requires": { + "is-plain-object": "2.0.4" + } + } + } + }, "mkdirp": { "version": "0.5.1", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", @@ -240,6 +1745,27 @@ "minimist": "0.0.8" } }, + "moment": { + "version": "2.22.1", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.22.1.tgz", + "integrity": "sha512-shJkRTSebXvsVqk56I+lkb2latjBs8I+pc2TzWc545y2iFnSjm7Wg0QMh+ZWcdSLQyGEau5jI8ocnmkyTgr9YQ==", + "dev": true + }, + "moment-timezone": { + "version": "0.5.16", + "resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.16.tgz", + "integrity": "sha512-4d1l92plNNqnMkqI/7boWNVXJvwGL2WyByl1Hxp3h/ao3HZiAqaoQY+6KBkYdiN5QtNDpndq+58ozl8W4GVoNw==", + "dev": true, + "requires": { + "moment": "2.22.1" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + }, "mute-stream": { "version": "0.0.7", "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz", @@ -250,11 +1776,129 @@ "resolved": "https://registry.npmjs.org/nan/-/nan-2.9.2.tgz", "integrity": "sha512-ltW65co7f3PQWBDbqVvaU1WtFJUsNW7sWWm4HINhbMQIyVyzIeyZ8toX5TC5eeooE6piZoaEh4cZkueSKG3KYw==" }, + "nanomatch": { + "version": "1.2.9", + "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.9.tgz", + "integrity": "sha512-n8R9bS8yQ6eSXaV6jHUpKzD8gLsin02w1HSFiegwrs9E098Ylhw5jdyKPaYqvHknHaSCKTPp7C8dGCQ0q9koXA==", + "dev": true, + "requires": { + "arr-diff": "4.0.0", + "array-unique": "0.3.2", + "define-property": "2.0.2", + "extend-shallow": "3.0.2", + "fragment-cache": "0.2.1", + "is-odd": "2.0.0", + "is-windows": "1.0.2", + "kind-of": "6.0.2", + "object.pick": "1.3.0", + "regex-not": "1.0.2", + "snapdragon": "0.8.2", + "to-regex": "3.0.2" + } + }, "ncp": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/ncp/-/ncp-1.0.1.tgz", "integrity": "sha1-0VNn5cuHQyuhF9K/gP30Wuz7QkY=" }, + "needle": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/needle/-/needle-2.2.1.tgz", + "integrity": "sha512-t/ZswCM9JTWjAdXS9VpvqhI2Ct2sL2MdY4fUXqGJaGBk13ge99ObqRksRTbBE56K+wxUXwwfZYOuZHifFW9q+Q==", + "dev": true, + "requires": { + "debug": "2.6.9", + "iconv-lite": "0.4.23", + "sax": "1.2.4" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + } + } + }, + "normalize-path": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", + "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", + "dev": true, + "requires": { + "remove-trailing-separator": "1.1.0" + } + }, + "nssocket": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/nssocket/-/nssocket-0.6.0.tgz", + "integrity": "sha1-Wflvb/MhVm8zxw99vu7N/cBxVPo=", + "dev": true, + "requires": { + "eventemitter2": "0.4.14", + "lazy": "1.0.11" + }, + "dependencies": { + "eventemitter2": { + "version": "0.4.14", + "resolved": "https://registry.npmjs.org/eventemitter2/-/eventemitter2-0.4.14.tgz", + "integrity": "sha1-j2G3XN4BKy6esoTUVFWDtWQ7Yas=", + "dev": true + } + } + }, + "object-copy": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/object-copy/-/object-copy-0.1.0.tgz", + "integrity": "sha1-fn2Fi3gb18mRpBupde04EnVOmYw=", + "dev": true, + "requires": { + "copy-descriptor": "0.1.1", + "define-property": "0.2.5", + "kind-of": "3.2.2" + }, + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "0.1.6" + } + }, + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "1.1.6" + } + } + } + }, + "object-visit": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/object-visit/-/object-visit-1.0.1.tgz", + "integrity": "sha1-95xEk68MU3e1n+OdOV5BBC3QRbs=", + "dev": true, + "requires": { + "isobject": "3.0.1" + } + }, + "object.pick": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz", + "integrity": "sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c=", + "dev": true, + "requires": { + "isobject": "3.0.1" + } + }, "once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", @@ -263,16 +1907,186 @@ "wrappy": "1.0.2" } }, + "pascalcase": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz", + "integrity": "sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=", + "dev": true + }, + "path-dirname": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/path-dirname/-/path-dirname-1.0.2.tgz", + "integrity": "sha1-zDPSTVJeCZpTiMAzbG4yuRYGCeA=", + "dev": true + }, "path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" }, + "path-parse": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.5.tgz", + "integrity": "sha1-PBrfhx6pzWyUMbbqK9dKD/BVxME=", + "dev": true + }, + "pidusage": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/pidusage/-/pidusage-1.2.0.tgz", + "integrity": "sha512-OGo+iSOk44HRJ8q15AyG570UYxcm5u+R99DI8Khu8P3tKGkVu5EZX4ywHglWSTMNNXQ274oeGpYrvFEhDIFGPg==", + "dev": true + }, "pkginfo": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/pkginfo/-/pkginfo-0.4.1.tgz", "integrity": "sha1-tUGO8EOd5UJfxJlQQtztFPsqhP8=" }, + "pm2": { + "version": "2.10.3", + "resolved": "https://registry.npmjs.org/pm2/-/pm2-2.10.3.tgz", + "integrity": "sha512-C3fEC4jkr4iR1mUfTdX4CoR9RRe1165MDbGToVm+H7lCuXeh25CgckjrsXHv6QMLFT0hNbQr5m44YYyWotBTAA==", + "dev": true, + "requires": { + "async": "2.6.0", + "blessed": "0.1.81", + "chalk": "1.1.3", + "chokidar": "2.0.3", + "cli-table-redemption": "1.0.1", + "commander": "2.13.0", + "cron": "1.3.0", + "debug": "3.1.0", + "eventemitter2": "1.0.5", + "fclone": "1.0.11", + "gkt": "https://tgz.pm2.io/gkt-1.0.0.tgz", + "mkdirp": "0.5.1", + "moment": "2.22.1", + "needle": "2.2.1", + "nssocket": "0.6.0", + "pidusage": "1.2.0", + "pm2-axon": "3.1.0", + "pm2-axon-rpc": "0.5.1", + "pm2-deploy": "0.3.9", + "pm2-multimeter": "0.1.2", + "pmx": "1.6.4", + "promptly": "2.2.0", + "semver": "5.5.0", + "shelljs": "0.7.8", + "source-map-support": "0.5.5", + "sprintf-js": "1.1.1", + "v8-compile-cache": "1.1.2", + "vizion": "0.2.13", + "yamljs": "0.3.0" + }, + "dependencies": { + "ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "dev": true + }, + "async": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.0.tgz", + "integrity": "sha512-xAfGg1/NTLBBKlHFmnd7PlmUW9KhVQIUuSrYem9xzFUZy13ScvtyGGejaae9iAVRiRq9+Cx7DPFaAAhCpyxyPw==", + "dev": true, + "requires": { + "lodash": "4.17.5" + } + }, + "chalk": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "dev": true, + "requires": { + "ansi-styles": "2.2.1", + "escape-string-regexp": "1.0.5", + "has-ansi": "2.0.0", + "strip-ansi": "3.0.1", + "supports-color": "2.0.0" + } + }, + "supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", + "dev": true + } + } + }, + "pm2-axon": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/pm2-axon/-/pm2-axon-3.1.0.tgz", + "integrity": "sha512-5sBM+vHw0Cp2K9CJ9ZOYhKtNCCcgQ0eKOyFrSo5Jusbq9FfvuelsMG4WDaxkqosaQbf8N5YfyHhD7eOUcnm5rQ==", + "dev": true, + "requires": { + "amp": "0.3.1", + "amp-message": "0.1.2", + "debug": "3.1.0", + "escape-regexp": "0.0.1" + } + }, + "pm2-axon-rpc": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/pm2-axon-rpc/-/pm2-axon-rpc-0.5.1.tgz", + "integrity": "sha512-hT8gN3/j05895QLXpwg+Ws8PjO4AVID6Uf9StWpud9HB2homjc1KKCcI0vg9BNOt56FmrqKDT1NQgheIz35+sA==", + "dev": true, + "requires": { + "debug": "3.1.0" + } + }, + "pm2-deploy": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/pm2-deploy/-/pm2-deploy-0.3.9.tgz", + "integrity": "sha512-IYF45fPwfLE27BivrtodK7zzN56BNDErK7brcldIHjVIHLlk+cdhijq3kwTkPPP3Tpc3H2C942QGRgjg0hHajA==", + "dev": true, + "requires": { + "async": "1.5.2", + "tv4": "1.3.0" + }, + "dependencies": { + "async": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", + "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=", + "dev": true + } + } + }, + "pm2-multimeter": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/pm2-multimeter/-/pm2-multimeter-0.1.2.tgz", + "integrity": "sha1-Gh5VFT1BoFU0zqI8/oYKuqDrSs4=", + "dev": true, + "requires": { + "charm": "0.1.2" + } + }, + "pmx": { + "version": "1.6.4", + "resolved": "https://registry.npmjs.org/pmx/-/pmx-1.6.4.tgz", + "integrity": "sha512-uk6REZHe8j3RhGlFUfyVwFrE6JFhZigTpMFs/4iYO4MzCqVTpNp1cED032oCc4R+m32wUITV/2RDmPX21T1LLg==", + "dev": true, + "requires": { + "debug": "3.1.0", + "deep-metrics": "0.0.1", + "json-stringify-safe": "5.0.1", + "semver": "5.5.0", + "vxx": "1.2.2" + } + }, + "posix-character-classes": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz", + "integrity": "sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=", + "dev": true + }, + "process-nextick-args": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", + "dev": true + }, "prompt": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/prompt/-/prompt-1.0.0.tgz", @@ -286,6 +2100,15 @@ "winston": "2.1.1" } }, + "promptly": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/promptly/-/promptly-2.2.0.tgz", + "integrity": "sha1-KhP6BjaIoqWYOxYf/wEIoH0m/HQ=", + "dev": true, + "requires": { + "read": "1.0.7" + } + }, "read": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/read/-/read-1.0.7.tgz", @@ -294,16 +2117,101 @@ "mute-stream": "0.0.7" } }, + "readable-stream": { + "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", + "inherits": "2.0.3", + "isarray": "1.0.0", + "process-nextick-args": "2.0.0", + "safe-buffer": "5.1.2", + "string_decoder": "1.1.1", + "util-deprecate": "1.0.2" + } + }, "readdir-recursive": { "version": "0.0.4", "resolved": "https://registry.npmjs.org/readdir-recursive/-/readdir-recursive-0.0.4.tgz", "integrity": "sha1-mvQ1q6nFi9gNvclIi025up8SMB8=" }, + "readdirp": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-2.1.0.tgz", + "integrity": "sha1-TtCtBg3zBzMAxIRANz9y0cxkLXg=", + "dev": true, + "requires": { + "graceful-fs": "4.1.11", + "minimatch": "3.0.4", + "readable-stream": "2.3.6", + "set-immediate-shim": "1.0.1" + } + }, + "rechoir": { + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz", + "integrity": "sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q=", + "dev": true, + "requires": { + "resolve": "1.7.1" + } + }, "regenerator-runtime": { "version": "0.11.1", "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz", "integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==" }, + "regex-not": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/regex-not/-/regex-not-1.0.2.tgz", + "integrity": "sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A==", + "dev": true, + "requires": { + "extend-shallow": "3.0.2", + "safe-regex": "1.1.0" + } + }, + "remove-trailing-separator": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz", + "integrity": "sha1-wkvOKig62tW8P1jg1IJJuSN52O8=", + "dev": true + }, + "repeat-element": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.2.tgz", + "integrity": "sha1-7wiaF40Ug7quTZPrmLT55OEdmQo=", + "dev": true + }, + "repeat-string": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", + "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", + "dev": true + }, + "resolve": { + "version": "1.7.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.7.1.tgz", + "integrity": "sha512-c7rwLofp8g1U+h1KNyHL/jicrKg1Ek4q+Lr33AL65uZTinUZHe30D5HlyN5V9NW0JX1D5dXQ4jqW5l7Sy/kGfw==", + "dev": true, + "requires": { + "path-parse": "1.0.5" + } + }, + "resolve-url": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz", + "integrity": "sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=", + "dev": true + }, + "ret": { + "version": "0.1.15", + "resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz", + "integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==", + "dev": true + }, "revalidator": { "version": "0.1.8", "resolved": "https://registry.npmjs.org/revalidator/-/revalidator-0.1.8.tgz", @@ -317,11 +2225,303 @@ "glob": "7.1.2" } }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true + }, + "safe-regex": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", + "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=", + "dev": true, + "requires": { + "ret": "0.1.15" + } + }, + "safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "dev": true + }, + "sax": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", + "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==", + "dev": true + }, + "semver": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", + "dev": true + }, + "set-immediate-shim": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/set-immediate-shim/-/set-immediate-shim-1.0.1.tgz", + "integrity": "sha1-SysbJ+uAip+NzEgaWOXlb1mfP2E=", + "dev": true + }, + "set-value": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.0.tgz", + "integrity": "sha512-hw0yxk9GT/Hr5yJEYnHNKYXkIA8mVJgd9ditYZCe16ZczcaELYYcfvaXesNACk2O8O0nTiPQcQhGUQj8JLzeeg==", + "dev": true, + "requires": { + "extend-shallow": "2.0.1", + "is-extendable": "0.1.1", + "is-plain-object": "2.0.4", + "split-string": "3.1.0" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "0.1.1" + } + } + } + }, + "shelljs": { + "version": "0.7.8", + "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.7.8.tgz", + "integrity": "sha1-3svPh0sNHl+3LhSxZKloMEjprLM=", + "dev": true, + "requires": { + "glob": "7.1.2", + "interpret": "1.1.0", + "rechoir": "0.6.2" + } + }, + "shimmer": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/shimmer/-/shimmer-1.2.0.tgz", + "integrity": "sha512-xTCx2vohXC2EWWDqY/zb4+5Mu28D+HYNSOuFzsyRDRvI/e1ICb69afwaUwfjr+25ZXldbOLyp+iDUZHq8UnTag==", + "dev": true + }, + "snapdragon": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz", + "integrity": "sha512-FtyOnWN/wCHTVXOMwvSv26d+ko5vWlIDD6zoUJ7LW8vh+ZBC8QdljveRP+crNrtBwioEUWy/4dMtbBjA4ioNlg==", + "dev": true, + "requires": { + "base": "0.11.2", + "debug": "2.6.9", + "define-property": "0.2.5", + "extend-shallow": "2.0.1", + "map-cache": "0.2.2", + "source-map": "0.5.7", + "source-map-resolve": "0.5.2", + "use": "3.1.0" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "0.1.6" + } + }, + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "0.1.1" + } + } + } + }, + "snapdragon-node": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/snapdragon-node/-/snapdragon-node-2.1.1.tgz", + "integrity": "sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw==", + "dev": true, + "requires": { + "define-property": "1.0.0", + "isobject": "3.0.1", + "snapdragon-util": "3.0.1" + }, + "dependencies": { + "define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", + "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", + "dev": true, + "requires": { + "is-descriptor": "1.0.2" + } + }, + "is-accessor-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", + "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", + "dev": true, + "requires": { + "kind-of": "6.0.2" + } + }, + "is-data-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", + "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", + "dev": true, + "requires": { + "kind-of": "6.0.2" + } + }, + "is-descriptor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", + "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "1.0.0", + "is-data-descriptor": "1.0.0", + "kind-of": "6.0.2" + } + } + } + }, + "snapdragon-util": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/snapdragon-util/-/snapdragon-util-3.0.1.tgz", + "integrity": "sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ==", + "dev": true, + "requires": { + "kind-of": "3.2.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "1.1.6" + } + } + } + }, + "source-map": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", + "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", + "dev": true + }, + "source-map-resolve": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.2.tgz", + "integrity": "sha512-MjqsvNwyz1s0k81Goz/9vRBe9SZdB09Bdw+/zYyO+3CuPk6fouTaxscHkgtE8jKvf01kVfl8riHzERQ/kefaSA==", + "dev": true, + "requires": { + "atob": "2.1.1", + "decode-uri-component": "0.2.0", + "resolve-url": "0.2.1", + "source-map-url": "0.4.0", + "urix": "0.1.0" + } + }, + "source-map-support": { + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.5.tgz", + "integrity": "sha512-mR7/Nd5l1z6g99010shcXJiNEaf3fEtmLhRB/sBcQVJGodcHCULPp2y4Sfa43Kv2zq7T+Izmfp/WHCR6dYkQCA==", + "dev": true, + "requires": { + "buffer-from": "1.0.0", + "source-map": "0.6.1" + }, + "dependencies": { + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + } + } + }, + "source-map-url": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.0.tgz", + "integrity": "sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=", + "dev": true + }, + "split-string": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", + "integrity": "sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw==", + "dev": true, + "requires": { + "extend-shallow": "3.0.2" + } + }, + "sprintf-js": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.1.tgz", + "integrity": "sha1-Nr54Mgr+WAH2zqPueLblqrlA6gw=", + "dev": true + }, "stack-trace": { "version": "0.0.10", "resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz", "integrity": "sha1-VHxws0fo0ytOEI6hoqFZ5f3eGcA=" }, + "static-extend": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz", + "integrity": "sha1-YICcOcv/VTNyJv1eC1IPNB8ftcY=", + "dev": true, + "requires": { + "define-property": "0.2.5", + "object-copy": "0.1.0" + }, + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "0.1.6" + } + } + } + }, + "string_decoder": { + "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.2" + } + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "dev": true, + "requires": { + "ansi-regex": "2.1.1" + } + }, "supports-color": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.3.0.tgz", @@ -330,11 +2530,161 @@ "has-flag": "3.0.0" } }, + "to-object-path": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/to-object-path/-/to-object-path-0.3.0.tgz", + "integrity": "sha1-KXWIt7Dn4KwI4E5nL4XB9JmeF68=", + "dev": true, + "requires": { + "kind-of": "3.2.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "1.1.6" + } + } + } + }, + "to-regex": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/to-regex/-/to-regex-3.0.2.tgz", + "integrity": "sha512-FWtleNAtZ/Ki2qtqej2CXTOayOH9bHDQF+Q48VpWyDXjbYxA4Yz8iDB31zXOBUlOHHKidDbqGVrTUvQMPmBGBw==", + "dev": true, + "requires": { + "define-property": "2.0.2", + "extend-shallow": "3.0.2", + "regex-not": "1.0.2", + "safe-regex": "1.1.0" + } + }, + "to-regex-range": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-2.1.1.tgz", + "integrity": "sha1-fIDBe53+vlmeJzZ+DU3VWQFB2zg=", + "dev": true, + "requires": { + "is-number": "3.0.0", + "repeat-string": "1.6.1" + } + }, + "tv4": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/tv4/-/tv4-1.3.0.tgz", + "integrity": "sha1-0CDIRvrdUMhVq7JeuuzGj8EPeWM=", + "dev": true + }, + "union-value": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.0.tgz", + "integrity": "sha1-XHHDTLW61dzr4+oM0IIHulqhrqQ=", + "dev": true, + "requires": { + "arr-union": "3.1.0", + "get-value": "2.0.6", + "is-extendable": "0.1.1", + "set-value": "0.4.3" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "0.1.1" + } + }, + "set-value": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/set-value/-/set-value-0.4.3.tgz", + "integrity": "sha1-fbCPnT0i3H945Trzw79GZuzfzPE=", + "dev": true, + "requires": { + "extend-shallow": "2.0.1", + "is-extendable": "0.1.1", + "is-plain-object": "2.0.4", + "to-object-path": "0.3.0" + } + } + } + }, "universalify": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.1.tgz", "integrity": "sha1-+nG63UQ3r0wUiEHjs7Fl+enlkLc=" }, + "unset-value": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unset-value/-/unset-value-1.0.0.tgz", + "integrity": "sha1-g3aHP30jNRef+x5vw6jtDfyKtVk=", + "dev": true, + "requires": { + "has-value": "0.3.1", + "isobject": "3.0.1" + }, + "dependencies": { + "has-value": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/has-value/-/has-value-0.3.1.tgz", + "integrity": "sha1-ex9YutpiyoJ+wKIHgCVlSEWZXh8=", + "dev": true, + "requires": { + "get-value": "2.0.6", + "has-values": "0.1.4", + "isobject": "2.1.0" + }, + "dependencies": { + "isobject": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", + "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=", + "dev": true, + "requires": { + "isarray": "1.0.0" + } + } + } + }, + "has-values": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/has-values/-/has-values-0.1.4.tgz", + "integrity": "sha1-bWHeldkd/Km5oCCJrThL/49it3E=", + "dev": true + } + } + }, + "upath": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/upath/-/upath-1.0.5.tgz", + "integrity": "sha512-qbKn90aDQ0YEwvXoLqj0oiuUYroLX2lVHZ+b+xwjozFasAOC4GneDq5+OaIG5Zj+jFmbz/uO+f7a9qxjktJQww==", + "dev": true + }, + "urix": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz", + "integrity": "sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI=", + "dev": true + }, + "use": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/use/-/use-3.1.0.tgz", + "integrity": "sha512-6UJEQM/L+mzC3ZJNM56Q4DFGLX/evKGRg15UJHGB9X5j5Z3AFbgZvjUh2yq/UJUY4U5dh7Fal++XbNg1uzpRAw==", + "dev": true, + "requires": { + "kind-of": "6.0.2" + } + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", + "dev": true + }, "utile": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/utile/-/utile-0.3.0.tgz", @@ -348,6 +2698,65 @@ "rimraf": "2.6.2" } }, + "uuid": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz", + "integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA==", + "dev": true + }, + "v8-compile-cache": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-1.1.2.tgz", + "integrity": "sha512-ejdrifsIydN1XDH7EuR2hn8ZrkRKUYF7tUcBjBy/lhrCvs2K+zRlbW9UHc0IQ9RsYFZJFqJrieoIHfkCa0DBRA==", + "dev": true + }, + "vizion": { + "version": "0.2.13", + "resolved": "https://registry.npmjs.org/vizion/-/vizion-0.2.13.tgz", + "integrity": "sha1-ExTN7is0EW+fWxJIU2+V2/zW718=", + "dev": true, + "requires": { + "async": "1.5.2" + }, + "dependencies": { + "async": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", + "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=", + "dev": true + } + } + }, + "vxx": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/vxx/-/vxx-1.2.2.tgz", + "integrity": "sha1-dB+1HG8R0zg9pvm5IBil17qAdhE=", + "dev": true, + "requires": { + "continuation-local-storage": "3.2.1", + "debug": "2.6.9", + "extend": "3.0.1", + "is": "3.2.1", + "lodash.findindex": "4.6.0", + "lodash.isequal": "4.5.0", + "lodash.merge": "4.6.1", + "methods": "1.1.2", + "semver": "5.5.0", + "shimmer": "1.2.0", + "uuid": "3.2.1" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + } + } + }, "winston": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/winston/-/winston-2.1.1.tgz", @@ -391,6 +2800,16 @@ "requires": { "async-limiter": "1.0.0" } + }, + "yamljs": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/yamljs/-/yamljs-0.3.0.tgz", + "integrity": "sha512-C/FsVVhht4iPQYXOInoxUM/1ELSf9EsgKH34FofQOp6hwCPrW4vG4w5++TED3xRUo8gD7l0P1J1dLlDYzODsTQ==", + "dev": true, + "requires": { + "argparse": "1.0.10", + "glob": "7.1.2" + } } } } diff --git a/server/package.json b/server/package.json index 8417c13..f1ea460 100644 --- a/server/package.json +++ b/server/package.json @@ -30,5 +30,8 @@ "prompt": "^1.0.0", "readdir-recursive": "0.0.4", "ws": "^5.0.0" + }, + "devDependencies": { + "pm2": "^2.10.3" } } -- cgit v1.2.1 From 73e5c5ccfe408e58eb4bb927c71a77e0fceb22c4 Mon Sep 17 00:00:00 2001 From: neelkamath Date: Fri, 11 May 2018 20:46:12 +0530 Subject: Remove forgettable, unused, occasionally harmful (w.r.t. ES6) directive --- server/src/commands/admin/addmod.js | 2 -- server/src/commands/admin/listusers.js | 2 -- server/src/commands/admin/reload.js | 2 -- server/src/commands/admin/saveconfig.js | 2 -- server/src/commands/admin/shout.js | 2 -- server/src/commands/core/changenick.js | 2 -- server/src/commands/core/chat.js | 2 -- server/src/commands/core/disconnect.js | 2 -- server/src/commands/core/help.js | 2 -- server/src/commands/core/invite.js | 2 -- server/src/commands/core/join.js | 2 -- server/src/commands/core/morestats.js | 2 -- server/src/commands/core/move.js | 2 -- server/src/commands/core/showcase.js | 2 -- server/src/commands/core/stats.js | 2 -- server/src/commands/mod/ban.js | 2 -- server/src/commands/mod/kick.js | 2 -- server/src/commands/mod/unban.js | 2 -- server/src/core/rateLimiter.js | 4 +--- server/src/core/server.js | 2 -- server/src/managers/commands.js | 2 -- server/src/managers/config.js | 2 -- server/src/managers/imports-manager.js | 2 -- server/src/managers/stats.js | 2 -- server/src/scripts/configure.js | 2 -- server/src/scripts/debug.js | 2 -- server/src/scripts/dev.js | 2 -- 27 files changed, 1 insertion(+), 55 deletions(-) (limited to 'server') diff --git a/server/src/commands/admin/addmod.js b/server/src/commands/admin/addmod.js index e9dde2c..4c13b22 100644 --- a/server/src/commands/admin/addmod.js +++ b/server/src/commands/admin/addmod.js @@ -2,8 +2,6 @@ Description: Adds the target trip to the mod list then elevates the uType */ -'use strict'; - exports.run = async (core, server, socket, data) => { if (socket.uType != 'admin') { // ignore if not admin diff --git a/server/src/commands/admin/listusers.js b/server/src/commands/admin/listusers.js index 226b000..a539a3c 100644 --- a/server/src/commands/admin/listusers.js +++ b/server/src/commands/admin/listusers.js @@ -2,8 +2,6 @@ Description: Outputs all current channels and their user nicks */ -'use strict'; - exports.run = async (core, server, socket, data) => { if (socket.uType != 'admin') { // ignore if not admin diff --git a/server/src/commands/admin/reload.js b/server/src/commands/admin/reload.js index 387ae97..4e22a95 100644 --- a/server/src/commands/admin/reload.js +++ b/server/src/commands/admin/reload.js @@ -2,8 +2,6 @@ Description: Clears and resets the command modules, outputting any errors */ -'use strict'; - exports.run = async (core, server, socket, data) => { if (socket.uType != 'admin') { // ignore if not admin diff --git a/server/src/commands/admin/saveconfig.js b/server/src/commands/admin/saveconfig.js index 0c4e0c9..ed3a312 100644 --- a/server/src/commands/admin/saveconfig.js +++ b/server/src/commands/admin/saveconfig.js @@ -2,8 +2,6 @@ Description: Writes any changes to the config to the disk */ -'use strict'; - exports.run = async (core, server, socket, data) => { if (socket.uType != 'admin') { // ignore if not admin diff --git a/server/src/commands/admin/shout.js b/server/src/commands/admin/shout.js index 736134a..4ebf696 100644 --- a/server/src/commands/admin/shout.js +++ b/server/src/commands/admin/shout.js @@ -2,8 +2,6 @@ Description: Emmits a server-wide message as `info` */ -'use strict'; - exports.run = async (core, server, socket, data) => { if (socket.uType != 'admin') { // ignore if not admin diff --git a/server/src/commands/core/changenick.js b/server/src/commands/core/changenick.js index 6b2932c..4041bb0 100644 --- a/server/src/commands/core/changenick.js +++ b/server/src/commands/core/changenick.js @@ -2,8 +2,6 @@ Description: Generates a semi-unique channel name then broadcasts it to each client */ -'use strict'; - const verifyNickname = (nick) => { return /^[a-zA-Z0-9_]{1,24}$/.test(nick); }; diff --git a/server/src/commands/core/chat.js b/server/src/commands/core/chat.js index ee45425..4e95940 100644 --- a/server/src/commands/core/chat.js +++ b/server/src/commands/core/chat.js @@ -2,8 +2,6 @@ Description: Rebroadcasts any `text` to all clients in a `channel` */ -'use strict'; - const parseText = (text) => { if (typeof text !== 'string') { return false; diff --git a/server/src/commands/core/disconnect.js b/server/src/commands/core/disconnect.js index 1a9c635..41ca380 100644 --- a/server/src/commands/core/disconnect.js +++ b/server/src/commands/core/disconnect.js @@ -4,8 +4,6 @@ by a client to have the connection severed. */ -'use strict'; - exports.run = async (core, server, socket, data) => { if (socket.channel) { server.broadcast({ diff --git a/server/src/commands/core/help.js b/server/src/commands/core/help.js index 71cc745..331e13f 100644 --- a/server/src/commands/core/help.js +++ b/server/src/commands/core/help.js @@ -2,8 +2,6 @@ Description: Outputs the current command module list or command categories */ -'use strict'; - const stripIndents = require('common-tags').stripIndents; exports.run = async (core, server, socket, data) => { diff --git a/server/src/commands/core/invite.js b/server/src/commands/core/invite.js index bd85812..735dace 100644 --- a/server/src/commands/core/invite.js +++ b/server/src/commands/core/invite.js @@ -2,8 +2,6 @@ Description: Generates a semi-unique channel name then broadcasts it to each client */ -'use strict'; - const verifyNickname = (nick) => { return /^[a-zA-Z0-9_]{1,24}$/.test(nick); }; diff --git a/server/src/commands/core/join.js b/server/src/commands/core/join.js index 82b48d2..b385b89 100644 --- a/server/src/commands/core/join.js +++ b/server/src/commands/core/join.js @@ -2,8 +2,6 @@ Description: Initial entry point, applies `channel` and `nick` to the calling socket */ -'use strict'; - const crypto = require('crypto'); const hash = (password) => { diff --git a/server/src/commands/core/morestats.js b/server/src/commands/core/morestats.js index d8bc23d..c1105f1 100644 --- a/server/src/commands/core/morestats.js +++ b/server/src/commands/core/morestats.js @@ -2,8 +2,6 @@ Description: Outputs more info than the legacy stats command */ -'use strict'; - const stripIndents = require('common-tags').stripIndents; const formatTime = (time) => { diff --git a/server/src/commands/core/move.js b/server/src/commands/core/move.js index 862025c..9e50f4f 100644 --- a/server/src/commands/core/move.js +++ b/server/src/commands/core/move.js @@ -2,8 +2,6 @@ Description: Generates a semi-unique channel name then broadcasts it to each client */ -'use strict'; - exports.run = async (core, server, socket, data) => { if (server._police.frisk(socket.remoteAddress, 6)) { server.reply({ diff --git a/server/src/commands/core/showcase.js b/server/src/commands/core/showcase.js index 5eca4a2..35d811a 100644 --- a/server/src/commands/core/showcase.js +++ b/server/src/commands/core/showcase.js @@ -2,8 +2,6 @@ Description: This is a template module that should not be on prod */ -'use strict'; - // you can require() modules here // this function will only be only in the scope of the module diff --git a/server/src/commands/core/stats.js b/server/src/commands/core/stats.js index a1abddb..3a96381 100644 --- a/server/src/commands/core/stats.js +++ b/server/src/commands/core/stats.js @@ -2,8 +2,6 @@ Description: Legacy stats output, kept for compatibility, outputs user and channel count */ -'use strict'; - exports.run = async (core, server, socket, data) => { let ips = {}; let channels = {}; diff --git a/server/src/commands/mod/ban.js b/server/src/commands/mod/ban.js index 409217a..e19efc2 100644 --- a/server/src/commands/mod/ban.js +++ b/server/src/commands/mod/ban.js @@ -2,8 +2,6 @@ Description: Adds the target socket's ip to the ratelimiter */ -'use strict'; - exports.run = async (core, server, socket, data) => { if (socket.uType == 'user') { // ignore if not mod or admin diff --git a/server/src/commands/mod/kick.js b/server/src/commands/mod/kick.js index f32eaf5..1797ba9 100644 --- a/server/src/commands/mod/kick.js +++ b/server/src/commands/mod/kick.js @@ -2,8 +2,6 @@ Description: Forces a change on the target socket's channel, then broadcasts event */ -'use strict'; - exports.run = async (core, server, socket, data) => { if (socket.uType === 'user') { // ignore if not mod or admin diff --git a/server/src/commands/mod/unban.js b/server/src/commands/mod/unban.js index 2406644..d63288e 100644 --- a/server/src/commands/mod/unban.js +++ b/server/src/commands/mod/unban.js @@ -2,8 +2,6 @@ Description: Removes a target ip from the ratelimiter */ -'use strict'; - exports.run = async (core, server, socket, data) => { if (socket.uType == 'user') { // ignore if not mod or admin diff --git a/server/src/core/rateLimiter.js b/server/src/core/rateLimiter.js index 0d94ef2..0c2a384 100644 --- a/server/src/core/rateLimiter.js +++ b/server/src/core/rateLimiter.js @@ -8,15 +8,13 @@ * */ -'use strict'; - class Police { /** * Create a ratelimiter instance. */ constructor () { this._records = {}; - this._halflife = 30000; // ms + this._halflife = 30 * 1000; // milliseconds this._threshold = 25; this._hashes = []; } diff --git a/server/src/core/server.js b/server/src/core/server.js index 9bea738..855aeba 100644 --- a/server/src/core/server.js +++ b/server/src/core/server.js @@ -7,8 +7,6 @@ * */ -'use strict'; - const wsServer = require('ws').Server; const socketReady = require('ws').OPEN; const crypto = require('crypto'); diff --git a/server/src/managers/commands.js b/server/src/managers/commands.js index 569206d..c38fb4d 100644 --- a/server/src/managers/commands.js +++ b/server/src/managers/commands.js @@ -7,8 +7,6 @@ * */ -'use strict'; - const path = require('path'); const chalk = require('chalk'); const didYouMean = require('didyoumean2'); diff --git a/server/src/managers/config.js b/server/src/managers/config.js index 1848cac..2865d00 100644 --- a/server/src/managers/config.js +++ b/server/src/managers/config.js @@ -8,8 +8,6 @@ * */ -'use strict'; - const stripIndents = require('common-tags').stripIndents; const dateFormat = require('dateformat'); const chalk = require('chalk'); diff --git a/server/src/managers/imports-manager.js b/server/src/managers/imports-manager.js index f4096b7..d8b2144 100644 --- a/server/src/managers/imports-manager.js +++ b/server/src/managers/imports-manager.js @@ -7,8 +7,6 @@ * */ -'use strict'; - const read = require('readdir-recursive'); const path = require('path'); diff --git a/server/src/managers/stats.js b/server/src/managers/stats.js index c3b6f9f..20f1ae3 100644 --- a/server/src/managers/stats.js +++ b/server/src/managers/stats.js @@ -7,8 +7,6 @@ * */ -'use strict'; - class Stats { /** * Create a stats instance. diff --git a/server/src/scripts/configure.js b/server/src/scripts/configure.js index 0ecd858..88cd098 100644 --- a/server/src/scripts/configure.js +++ b/server/src/scripts/configure.js @@ -7,8 +7,6 @@ * */ -'use strict'; - // import required classes const path = require('path'); const ImportsManager = require('../managers/imports-manager'); diff --git a/server/src/scripts/debug.js b/server/src/scripts/debug.js index 3a97d9f..97597cd 100644 --- a/server/src/scripts/debug.js +++ b/server/src/scripts/debug.js @@ -7,8 +7,6 @@ * */ -'use strict'; - // import required classes const path = require('path'); const ConfigManager = require('../managers/config'); diff --git a/server/src/scripts/dev.js b/server/src/scripts/dev.js index 5049b84..f1608ed 100644 --- a/server/src/scripts/dev.js +++ b/server/src/scripts/dev.js @@ -7,8 +7,6 @@ * */ -'use strict'; - // import required classes -- cgit v1.2.1 From 3cb0e8dc5fa436b50f83b978a0bb1e189f90a1f3 Mon Sep 17 00:00:00 2001 From: neelkamath Date: Fri, 11 May 2018 21:30:27 +0530 Subject: Document --- server/README.md | 1 - 1 file changed, 1 deletion(-) delete mode 100644 server/README.md (limited to 'server') diff --git a/server/README.md b/server/README.md deleted file mode 100644 index 292daab..0000000 --- a/server/README.md +++ /dev/null @@ -1 +0,0 @@ -(TODO) -- cgit v1.2.1 From 4b30736929e65ec7ad664b2ffb2d1eca10b0636a Mon Sep 17 00:00:00 2001 From: neelkamath Date: Sat, 12 May 2018 13:52:19 +0530 Subject: Remove help.js as we need human, not programmatic documentation for this --- server/src/commands/core/help.js | 49 ---------------------------------------- 1 file changed, 49 deletions(-) delete mode 100644 server/src/commands/core/help.js (limited to 'server') diff --git a/server/src/commands/core/help.js b/server/src/commands/core/help.js deleted file mode 100644 index 331e13f..0000000 --- a/server/src/commands/core/help.js +++ /dev/null @@ -1,49 +0,0 @@ -/* - Description: Outputs the current command module list or command categories -*/ - -const stripIndents = require('common-tags').stripIndents; - -exports.run = async (core, server, socket, data) => { - // verify passed arguments - let typeDt = typeof data.type; - let catDt = typeof data.category; - let cmdDt = typeof data.command; - if (typeDt !== 'undefined' && typeDt !== 'string' ) { - return; - } else if (catDt !== 'undefined' && catDt !== 'string' ) { - return; - } else if (cmdDt !== 'undefined' && cmdDt !== 'string' ) { - return; - } - - // set default reply - let reply = stripIndents`Help usage: - Show all categories -> { cmd: 'help', type: 'categories' } - Show all commands in category -> { cmd: 'help', category: '' } - Show specific command -> { cmd: 'help', command: '' }`; - - if (typeDt !== 'undefined') { - let categories = core.commands.categories().sort(); - reply = `Command Categories:\n${categories.map(c => `- ${c.replace('../src/commands/', '')}`).join('\n')}`; - } else if (catDt !== 'undefined') { - let catCommands = core.commands.all('../src/commands/' + data.category).sort((a, b) => a.info.name.localeCompare(b.info.name)); - reply = `${data.category} commands:\n${catCommands.map(c => `- ${c.info.name}`).join('\n')}`; - } else if (cmdDt !== 'undefined') { - let command = core.commands.get(data.command); - reply = stripIndents` - Usage: ${command.info.usage || command.info.name} - Description: ${command.info.description || '¯\_(ツ)_/¯'}`; - } - - server.reply({ - cmd: 'info', - text: reply - }, socket); -}; - -exports.info = { - name: 'help', - usage: 'help ([ type:categories] | [category: | command: ])', - description: 'Outputs information about the servers current protocol' -}; -- cgit v1.2.1 From acbad15f2bc4a6733407bc17e1a5b4190ed3b287 Mon Sep 17 00:00:00 2001 From: neelkamath Date: Sat, 12 May 2018 14:13:12 +0530 Subject: Remove unused object fields --- server/src/commands/admin/addmod.js | 6 +----- server/src/commands/admin/listusers.js | 5 +---- server/src/commands/admin/reload.js | 5 +---- server/src/commands/admin/saveconfig.js | 5 +---- server/src/commands/admin/shout.js | 6 +----- server/src/commands/core/changenick.js | 6 +----- server/src/commands/core/chat.js | 6 +----- server/src/commands/core/disconnect.js | 5 +---- server/src/commands/core/invite.js | 6 +----- server/src/commands/core/join.js | 6 +----- server/src/commands/core/morestats.js | 5 +---- server/src/commands/core/move.js | 6 +----- server/src/commands/core/showcase.js | 6 ++---- server/src/commands/core/stats.js | 5 +---- server/src/commands/mod/ban.js | 6 +----- server/src/commands/mod/kick.js | 6 +----- server/src/commands/mod/unban.js | 6 +----- 17 files changed, 18 insertions(+), 78 deletions(-) (limited to 'server') diff --git a/server/src/commands/admin/addmod.js b/server/src/commands/admin/addmod.js index 4c13b22..992f9c4 100644 --- a/server/src/commands/admin/addmod.js +++ b/server/src/commands/admin/addmod.js @@ -40,8 +40,4 @@ exports.run = async (core, server, socket, data) => { exports.requiredData = ['trip']; -exports.info = { - name: 'addmod', - usage: 'addmod {trip}', - description: 'Adds target trip to the config as a mod and upgrades the socket type' -}; +exports.info = { name: 'addmod' }; diff --git a/server/src/commands/admin/listusers.js b/server/src/commands/admin/listusers.js index a539a3c..92fa998 100644 --- a/server/src/commands/admin/listusers.js +++ b/server/src/commands/admin/listusers.js @@ -32,7 +32,4 @@ exports.run = async (core, server, socket, data) => { }, socket); }; -exports.info = { - name: 'listusers', - description: 'Outputs all current channels and sockets in those channels' -}; +exports.info = { name: 'listusers' }; diff --git a/server/src/commands/admin/reload.js b/server/src/commands/admin/reload.js index 4e22a95..40de059 100644 --- a/server/src/commands/admin/reload.js +++ b/server/src/commands/admin/reload.js @@ -28,7 +28,4 @@ exports.run = async (core, server, socket, data) => { }, { uType: 'mod' }); }; -exports.info = { - name: 'reload', - description: '(Re)loads any new commands into memory, outputs errors if any' -}; +exports.info = { name: 'reload' }; diff --git a/server/src/commands/admin/saveconfig.js b/server/src/commands/admin/saveconfig.js index ed3a312..116abd6 100644 --- a/server/src/commands/admin/saveconfig.js +++ b/server/src/commands/admin/saveconfig.js @@ -30,7 +30,4 @@ exports.run = async (core, server, socket, data) => { }, { uType: 'mod' }); }; -exports.info = { - name: 'saveconfig', - description: 'Saves current config' -}; +exports.info = { name: 'saveconfig' }; diff --git a/server/src/commands/admin/shout.js b/server/src/commands/admin/shout.js index 4ebf696..2efff32 100644 --- a/server/src/commands/admin/shout.js +++ b/server/src/commands/admin/shout.js @@ -16,8 +16,4 @@ exports.run = async (core, server, socket, data) => { exports.requiredData = ['text']; -exports.info = { - name: 'shout', - usage: 'shout {text}', - description: 'Displays passed text to every client connected' -}; +exports.info = { name: 'shout' }; diff --git a/server/src/commands/core/changenick.js b/server/src/commands/core/changenick.js index 4041bb0..94ae4d4 100644 --- a/server/src/commands/core/changenick.js +++ b/server/src/commands/core/changenick.js @@ -81,8 +81,4 @@ exports.run = async (core, server, socket, data) => { exports.requiredData = ['nick']; -exports.info = { - name: 'changenick', - usage: 'changenick {nick}', - description: 'This will change your current connections nickname' -}; +exports.info = { name: 'changenick' }; diff --git a/server/src/commands/core/chat.js b/server/src/commands/core/chat.js index 4e95940..36a98e8 100644 --- a/server/src/commands/core/chat.js +++ b/server/src/commands/core/chat.js @@ -55,8 +55,4 @@ exports.run = async (core, server, socket, data) => { exports.requiredData = ['text']; -exports.info = { - name: 'chat', - usage: 'chat {text}', - description: 'Broadcasts passed `text` field to the calling users channel' -}; +exports.info = { name: 'chat' }; diff --git a/server/src/commands/core/disconnect.js b/server/src/commands/core/disconnect.js index 41ca380..9e733fa 100644 --- a/server/src/commands/core/disconnect.js +++ b/server/src/commands/core/disconnect.js @@ -15,7 +15,4 @@ exports.run = async (core, server, socket, data) => { socket.terminate(); }; -exports.info = { - name: 'disconnect', - description: 'Event handler or force disconnect (if your into that kind of thing)' -}; +exports.info = { name: 'disconnect' }; diff --git a/server/src/commands/core/invite.js b/server/src/commands/core/invite.js index 735dace..3fbbe6e 100644 --- a/server/src/commands/core/invite.js +++ b/server/src/commands/core/invite.js @@ -58,8 +58,4 @@ exports.run = async (core, server, socket, data) => { exports.requiredData = ['nick']; -exports.info = { - name: 'invite', - usage: 'invite {nick}', - description: 'Generates a unique (more or less) room name and passes it to two clients' -}; +exports.info = { name: 'invite' }; diff --git a/server/src/commands/core/join.js b/server/src/commands/core/join.js index b385b89..b72824b 100644 --- a/server/src/commands/core/join.js +++ b/server/src/commands/core/join.js @@ -128,8 +128,4 @@ exports.run = async (core, server, socket, data) => { exports.requiredData = ['channel', 'nick']; -exports.info = { - name: 'join', - usage: 'join {channel} {nick}', - description: 'Place calling socket into target channel with target nick & broadcast event to channel' -}; +exports.info = { name: 'join' }; diff --git a/server/src/commands/core/morestats.js b/server/src/commands/core/morestats.js index c1105f1..ce0e87d 100644 --- a/server/src/commands/core/morestats.js +++ b/server/src/commands/core/morestats.js @@ -47,7 +47,4 @@ exports.run = async (core, server, socket, data) => { core.managers.stats.increment('stats-requested'); }; -exports.info = { - name: 'morestats', - description: 'Sends back current server stats to the calling client' -}; +exports.info = { name: 'morestats' }; diff --git a/server/src/commands/core/move.js b/server/src/commands/core/move.js index 9e50f4f..9462468 100644 --- a/server/src/commands/core/move.js +++ b/server/src/commands/core/move.js @@ -76,8 +76,4 @@ exports.run = async (core, server, socket, data) => { exports.requiredData = ['channel']; -exports.info = { - name: 'move', - usage: 'move {channel}', - description: 'This will change the current channel to the new one provided' -}; +exports.info = { name: 'move' }; diff --git a/server/src/commands/core/showcase.js b/server/src/commands/core/showcase.js index 35d811a..1f2cdd9 100644 --- a/server/src/commands/core/showcase.js +++ b/server/src/commands/core/showcase.js @@ -43,9 +43,7 @@ exports.init = (core) => { exports.requiredData = ['echo']; // optional parameters are marked, all others are required -exports.info = { +exports.info = { name: 'showcase', // actual command name - aliases: ['templateModule'], // optional, an array of other names this module can be executed by - usage: 'showcase {echo}', // used for help output, can be ommited if no parameters are required - description: 'Simple command module template & info' // used for help output + aliases: ['templateModule'] }; diff --git a/server/src/commands/core/stats.js b/server/src/commands/core/stats.js index 3a96381..2802579 100644 --- a/server/src/commands/core/stats.js +++ b/server/src/commands/core/stats.js @@ -26,7 +26,4 @@ exports.run = async (core, server, socket, data) => { core.managers.stats.increment('stats-requested'); }; -exports.info = { - name: 'stats', - description: 'Sends back legacy server stats to the calling client' -}; +exports.info = { name: 'stats' }; diff --git a/server/src/commands/mod/ban.js b/server/src/commands/mod/ban.js index e19efc2..b2749ae 100644 --- a/server/src/commands/mod/ban.js +++ b/server/src/commands/mod/ban.js @@ -57,8 +57,4 @@ exports.run = async (core, server, socket, data) => { exports.requiredData = ['nick']; -exports.info = { - name: 'ban', - usage: 'ban {nick}', - description: 'Disconnects the target nickname in the same channel as calling socket & adds to ratelimiter' -}; +exports.info = { name: 'ban' }; diff --git a/server/src/commands/mod/kick.js b/server/src/commands/mod/kick.js index 1797ba9..5c72160 100644 --- a/server/src/commands/mod/kick.js +++ b/server/src/commands/mod/kick.js @@ -71,8 +71,4 @@ exports.run = async (core, server, socket, data) => { exports.requiredData = ['nick']; -exports.info = { - name: 'kick', - usage: 'kick {nick}', - description: 'Silently forces target client(s) into another channel. `nick` may be string or array of strings' -}; +exports.info = { name: 'kick' }; diff --git a/server/src/commands/mod/unban.js b/server/src/commands/mod/unban.js index d63288e..5450858 100644 --- a/server/src/commands/mod/unban.js +++ b/server/src/commands/mod/unban.js @@ -48,8 +48,4 @@ exports.run = async (core, server, socket, data) => { core.managers.stats.decrement('users-banned'); }; -exports.info = { - name: 'unban', - usage: 'unban {[ip || hash]}', - description: 'Removes target ip from the ratelimiter' -}; +exports.info = { name: 'unban' }; -- cgit v1.2.1 From 5b3322ebba246c3d3581e3e51e3c29671d506a20 Mon Sep 17 00:00:00 2001 From: neelkamath Date: Sat, 12 May 2018 14:49:56 +0530 Subject: Enhance READM.md --- server/src/commands/core/showcase.js | 49 ------------------------------------ 1 file changed, 49 deletions(-) delete mode 100644 server/src/commands/core/showcase.js (limited to 'server') diff --git a/server/src/commands/core/showcase.js b/server/src/commands/core/showcase.js deleted file mode 100644 index 1f2cdd9..0000000 --- a/server/src/commands/core/showcase.js +++ /dev/null @@ -1,49 +0,0 @@ -/* - Description: This is a template module that should not be on prod -*/ - -// you can require() modules here - -// this function will only be only in the scope of the module -const createReply = (echoInput) => { - if (echoInput.length > 100) - echoInput = 'HOW ABOUT NO?'; - - return `You want me to echo: ${echoInput}?` -}; - -/* - `exports.run()` is required and will always be passed (core, server, socket, data) - - be sure it's async too - this is the main function that will run when called -*/ -exports.run = async (core, server, socket, data) => { - - server.reply({ - cmd: 'info', - text: `SHOWCASE MODULE: ${core.showcase} - ${createReply(data.echo)}` - }, socket); - -}; - -/* - `exports.init()` is optional, and will only be run when the module is loaded into memory - it will always be passed a reference to the global core class - note: this will fire again if a reload is issued, keep that in mind -*/ -exports.init = (core) => { - if (typeof core.showcase === 'undefined') { - core.showcase = 'init is a handy place to put global data by assigning it to `core`'; - } -} - -// optional, if `data.echo` is missing `exports.run()` will never be called & the user will be alerted -// remember; this will only verify that the data is not undefined, not the type of data -exports.requiredData = ['echo']; - -// optional parameters are marked, all others are required -exports.info = { - name: 'showcase', // actual command name - aliases: ['templateModule'] -}; -- cgit v1.2.1 From 89698d8afb069a6e5c20849411bd5e2e6cf8acad Mon Sep 17 00:00:00 2001 From: Neel Kamath Date: Sun, 13 May 2018 15:40:43 +0530 Subject: Make PM2 optional --- server/package.json | 3 --- 1 file changed, 3 deletions(-) (limited to 'server') diff --git a/server/package.json b/server/package.json index f1ea460..8417c13 100644 --- a/server/package.json +++ b/server/package.json @@ -30,8 +30,5 @@ "prompt": "^1.0.0", "readdir-recursive": "0.0.4", "ws": "^5.0.0" - }, - "devDependencies": { - "pm2": "^2.10.3" } } -- cgit v1.2.1 From 1bd79064020c09910d9b151d9b633c01ce4a972b Mon Sep 17 00:00:00 2001 From: Neel Kamath Date: Sun, 13 May 2018 15:48:46 +0530 Subject: Use the 'use strict' directive when needed --- server/src/scripts/configure.js | 2 ++ server/src/scripts/debug.js | 2 ++ server/src/scripts/dev.js | 2 ++ 3 files changed, 6 insertions(+) (limited to 'server') diff --git a/server/src/scripts/configure.js b/server/src/scripts/configure.js index 88cd098..0ecd858 100644 --- a/server/src/scripts/configure.js +++ b/server/src/scripts/configure.js @@ -7,6 +7,8 @@ * */ +'use strict'; + // import required classes const path = require('path'); const ImportsManager = require('../managers/imports-manager'); diff --git a/server/src/scripts/debug.js b/server/src/scripts/debug.js index 97597cd..3a97d9f 100644 --- a/server/src/scripts/debug.js +++ b/server/src/scripts/debug.js @@ -7,6 +7,8 @@ * */ +'use strict'; + // import required classes const path = require('path'); const ConfigManager = require('../managers/config'); diff --git a/server/src/scripts/dev.js b/server/src/scripts/dev.js index f1608ed..5049b84 100644 --- a/server/src/scripts/dev.js +++ b/server/src/scripts/dev.js @@ -7,6 +7,8 @@ * */ +'use strict'; + // import required classes -- cgit v1.2.1 From 343157350f627b9495184246a90033a1c41f1a2c Mon Sep 17 00:00:00 2001 From: Neel Kamath Date: Sun, 13 May 2018 16:03:22 +0530 Subject: Re-add module documentation --- server/src/commands/admin/addmod.js | 6 +++- server/src/commands/admin/listusers.js | 5 +++- server/src/commands/admin/reload.js | 6 +++- server/src/commands/admin/saveconfig.js | 5 +++- server/src/commands/admin/shout.js | 6 +++- server/src/commands/core/changenick.js | 6 +++- server/src/commands/core/chat.js | 6 +++- server/src/commands/core/disconnect.js | 5 +++- server/src/commands/core/help.js | 49 +++++++++++++++++++++++++++++++++ server/src/commands/core/invite.js | 6 +++- server/src/commands/core/join.js | 6 +++- server/src/commands/core/morestats.js | 5 +++- server/src/commands/core/move.js | 6 +++- server/src/commands/core/stats.js | 5 +++- server/src/commands/mod/ban.js | 6 +++- server/src/commands/mod/kick.js | 6 +++- server/src/commands/mod/unban.js | 6 +++- 17 files changed, 124 insertions(+), 16 deletions(-) create mode 100644 server/src/commands/core/help.js (limited to 'server') diff --git a/server/src/commands/admin/addmod.js b/server/src/commands/admin/addmod.js index 992f9c4..4c13b22 100644 --- a/server/src/commands/admin/addmod.js +++ b/server/src/commands/admin/addmod.js @@ -40,4 +40,8 @@ exports.run = async (core, server, socket, data) => { exports.requiredData = ['trip']; -exports.info = { name: 'addmod' }; +exports.info = { + name: 'addmod', + usage: 'addmod {trip}', + description: 'Adds target trip to the config as a mod and upgrades the socket type' +}; diff --git a/server/src/commands/admin/listusers.js b/server/src/commands/admin/listusers.js index 92fa998..a539a3c 100644 --- a/server/src/commands/admin/listusers.js +++ b/server/src/commands/admin/listusers.js @@ -32,4 +32,7 @@ exports.run = async (core, server, socket, data) => { }, socket); }; -exports.info = { name: 'listusers' }; +exports.info = { + name: 'listusers', + description: 'Outputs all current channels and sockets in those channels' +}; diff --git a/server/src/commands/admin/reload.js b/server/src/commands/admin/reload.js index 40de059..e2cfbe6 100644 --- a/server/src/commands/admin/reload.js +++ b/server/src/commands/admin/reload.js @@ -28,4 +28,8 @@ exports.run = async (core, server, socket, data) => { }, { uType: 'mod' }); }; -exports.info = { name: 'reload' }; +exports.info = { + name: 'reload', + description: '(Re)loads any new commands into memory, outputs errors if any' +}; + diff --git a/server/src/commands/admin/saveconfig.js b/server/src/commands/admin/saveconfig.js index 116abd6..ed3a312 100644 --- a/server/src/commands/admin/saveconfig.js +++ b/server/src/commands/admin/saveconfig.js @@ -30,4 +30,7 @@ exports.run = async (core, server, socket, data) => { }, { uType: 'mod' }); }; -exports.info = { name: 'saveconfig' }; +exports.info = { + name: 'saveconfig', + description: 'Saves current config' +}; diff --git a/server/src/commands/admin/shout.js b/server/src/commands/admin/shout.js index 2efff32..1358dd9 100644 --- a/server/src/commands/admin/shout.js +++ b/server/src/commands/admin/shout.js @@ -16,4 +16,8 @@ exports.run = async (core, server, socket, data) => { exports.requiredData = ['text']; -exports.info = { name: 'shout' }; +exports.info = { + name: 'shout', + usage: 'shout {text}', + description: 'Displays passed text to every client connected' +}; \ No newline at end of file diff --git a/server/src/commands/core/changenick.js b/server/src/commands/core/changenick.js index 94ae4d4..4041bb0 100644 --- a/server/src/commands/core/changenick.js +++ b/server/src/commands/core/changenick.js @@ -81,4 +81,8 @@ exports.run = async (core, server, socket, data) => { exports.requiredData = ['nick']; -exports.info = { name: 'changenick' }; +exports.info = { + name: 'changenick', + usage: 'changenick {nick}', + description: 'This will change your current connections nickname' +}; diff --git a/server/src/commands/core/chat.js b/server/src/commands/core/chat.js index 36a98e8..bce6adb 100644 --- a/server/src/commands/core/chat.js +++ b/server/src/commands/core/chat.js @@ -55,4 +55,8 @@ exports.run = async (core, server, socket, data) => { exports.requiredData = ['text']; -exports.info = { name: 'chat' }; +exports.info = { + name: 'chat', + usage: 'chat {text}', + description: 'Broadcasts passed `text` field to the calling users channel' +}; \ No newline at end of file diff --git a/server/src/commands/core/disconnect.js b/server/src/commands/core/disconnect.js index 9e733fa..9b54214 100644 --- a/server/src/commands/core/disconnect.js +++ b/server/src/commands/core/disconnect.js @@ -15,4 +15,7 @@ exports.run = async (core, server, socket, data) => { socket.terminate(); }; -exports.info = { name: 'disconnect' }; +exports.info = { + name: 'disconnect', + description: 'Event handler or force disconnect (if your into that kind of thing)' +}; \ No newline at end of file diff --git a/server/src/commands/core/help.js b/server/src/commands/core/help.js new file mode 100644 index 0000000..7f63d3d --- /dev/null +++ b/server/src/commands/core/help.js @@ -0,0 +1,49 @@ +/* + Description: Outputs the current command module list or command categories +*/ + +const stripIndents = require('common-tags').stripIndents; + +exports.run = async (core, server, socket, data) => { + // verify passed arguments + let typeDt = typeof data.type; + let catDt = typeof data.category; + let cmdDt = typeof data.command; + if (typeDt !== 'undefined' && typeDt !== 'string' ) { + return; + } else if (catDt !== 'undefined' && catDt !== 'string' ) { + return; + } else if (cmdDt !== 'undefined' && cmdDt !== 'string' ) { + return; + } + + // set default reply + let reply = stripIndents`Help usage: + Show all categories -> { cmd: 'help', type: 'categories' } + Show all commands in category -> { cmd: 'help', category: '' } + Show specific command -> { cmd: 'help', command: '' }`; + + if (typeDt !== 'undefined') { + let categories = core.commands.categories().sort(); + reply = `Command Categories:\n${categories.map(c => `- ${c.replace('../src/commands/', '')}`).join('\n')}`; + } else if (catDt !== 'undefined') { + let catCommands = core.commands.all('../src/commands/' + data.category).sort((a, b) => a.info.name.localeCompare(b.info.name)); + reply = `${data.category} commands:\n${catCommands.map(c => `- ${c.info.name}`).join('\n')}`; + } else if (cmdDt !== 'undefined') { + let command = core.commands.get(data.command); + reply = stripIndents` + Usage: ${command.info.usage || command.info.name} + Description: ${command.info.description || '¯\_(ツ)_/¯'}`; + } + + server.reply({ + cmd: 'info', + text: reply + }, socket); +}; + +exports.info = { + name: 'help', + usage: 'help ([ type:categories] | [category: | command: ])', + description: 'Outputs information about the servers current protocol' +}; \ No newline at end of file diff --git a/server/src/commands/core/invite.js b/server/src/commands/core/invite.js index 3fbbe6e..bcf9097 100644 --- a/server/src/commands/core/invite.js +++ b/server/src/commands/core/invite.js @@ -58,4 +58,8 @@ exports.run = async (core, server, socket, data) => { exports.requiredData = ['nick']; -exports.info = { name: 'invite' }; +exports.info = { + name: 'invite', + usage: 'invite {nick}', + description: 'Generates a unique (more or less) room name and passes it to two clients' +}; \ No newline at end of file diff --git a/server/src/commands/core/join.js b/server/src/commands/core/join.js index b72824b..f2b2c9d 100644 --- a/server/src/commands/core/join.js +++ b/server/src/commands/core/join.js @@ -128,4 +128,8 @@ exports.run = async (core, server, socket, data) => { exports.requiredData = ['channel', 'nick']; -exports.info = { name: 'join' }; +exports.info = { + name: 'join', + usage: 'join {channel} {nick}', + description: 'Place calling socket into target channel with target nick & broadcast event to channel' +}; \ No newline at end of file diff --git a/server/src/commands/core/morestats.js b/server/src/commands/core/morestats.js index ce0e87d..5510cb1 100644 --- a/server/src/commands/core/morestats.js +++ b/server/src/commands/core/morestats.js @@ -47,4 +47,7 @@ exports.run = async (core, server, socket, data) => { core.managers.stats.increment('stats-requested'); }; -exports.info = { name: 'morestats' }; +exports.info = { + name: 'morestats', + description: 'Sends back current server stats to the calling client' +}; \ No newline at end of file diff --git a/server/src/commands/core/move.js b/server/src/commands/core/move.js index 9462468..c5efafd 100644 --- a/server/src/commands/core/move.js +++ b/server/src/commands/core/move.js @@ -76,4 +76,8 @@ exports.run = async (core, server, socket, data) => { exports.requiredData = ['channel']; -exports.info = { name: 'move' }; +exports.info = { + name: 'move', + usage: 'move {channel}', + description: 'This will change the current channel to the new one provided' +}; \ No newline at end of file diff --git a/server/src/commands/core/stats.js b/server/src/commands/core/stats.js index 2802579..b9dc002 100644 --- a/server/src/commands/core/stats.js +++ b/server/src/commands/core/stats.js @@ -26,4 +26,7 @@ exports.run = async (core, server, socket, data) => { core.managers.stats.increment('stats-requested'); }; -exports.info = { name: 'stats' }; +exports.info = { + name: 'stats', + description: 'Sends back legacy server stats to the calling client' +}; \ No newline at end of file diff --git a/server/src/commands/mod/ban.js b/server/src/commands/mod/ban.js index b2749ae..e19efc2 100644 --- a/server/src/commands/mod/ban.js +++ b/server/src/commands/mod/ban.js @@ -57,4 +57,8 @@ exports.run = async (core, server, socket, data) => { exports.requiredData = ['nick']; -exports.info = { name: 'ban' }; +exports.info = { + name: 'ban', + usage: 'ban {nick}', + description: 'Disconnects the target nickname in the same channel as calling socket & adds to ratelimiter' +}; diff --git a/server/src/commands/mod/kick.js b/server/src/commands/mod/kick.js index 5c72160..157592d 100644 --- a/server/src/commands/mod/kick.js +++ b/server/src/commands/mod/kick.js @@ -71,4 +71,8 @@ exports.run = async (core, server, socket, data) => { exports.requiredData = ['nick']; -exports.info = { name: 'kick' }; +exports.info = { + name: 'kick', + usage: 'kick {nick}', + description: 'Silently forces target client(s) into another channel. `nick` may be string or array of strings' +}; \ No newline at end of file diff --git a/server/src/commands/mod/unban.js b/server/src/commands/mod/unban.js index 5450858..e82f0b9 100644 --- a/server/src/commands/mod/unban.js +++ b/server/src/commands/mod/unban.js @@ -48,4 +48,8 @@ exports.run = async (core, server, socket, data) => { core.managers.stats.decrement('users-banned'); }; -exports.info = { name: 'unban' }; +exports.info = { + name: 'unban', + usage: 'unban {[ip || hash]}', + description: 'Removes target ip from the ratelimiter' +}; \ No newline at end of file -- cgit v1.2.1 From 2bb5ced363b692a5696b176bc317fe525c0c05df Mon Sep 17 00:00:00 2001 From: Neel Kamath Date: Sun, 13 May 2018 16:09:55 +0530 Subject: Flatten --- server/.gitignore | 63 - server/commands/admin/addmod.js | 47 + server/commands/admin/listusers.js | 38 + server/commands/admin/reload.js | 35 + server/commands/admin/saveconfig.js | 36 + server/commands/admin/shout.js | 23 + server/commands/core/changenick.js | 88 + server/commands/core/chat.js | 62 + server/commands/core/disconnect.js | 21 + server/commands/core/help.js | 49 + server/commands/core/invite.js | 65 + server/commands/core/join.js | 135 ++ server/commands/core/morestats.js | 53 + server/commands/core/move.js | 83 + server/commands/core/stats.js | 32 + server/commands/mod/ban.js | 64 + server/commands/mod/kick.js | 78 + server/commands/mod/unban.js | 55 + server/core/rateLimiter.js | 103 ++ server/core/server.js | 282 ++++ server/managers/commands.js | 239 +++ server/managers/config.js | 224 +++ server/managers/imports-manager.js | 148 ++ server/managers/index.js | 6 + server/managers/stats.js | 59 + server/package-lock.json | 2815 ------------------------------- server/package.json | 34 - server/scripts/configure.js | 23 + server/scripts/debug.js | 18 + server/scripts/dev.js | 17 + server/src/commands/admin/addmod.js | 47 - server/src/commands/admin/listusers.js | 38 - server/src/commands/admin/reload.js | 35 - server/src/commands/admin/saveconfig.js | 36 - server/src/commands/admin/shout.js | 23 - server/src/commands/core/changenick.js | 88 - server/src/commands/core/chat.js | 62 - server/src/commands/core/disconnect.js | 21 - server/src/commands/core/help.js | 49 - server/src/commands/core/invite.js | 65 - server/src/commands/core/join.js | 135 -- server/src/commands/core/morestats.js | 53 - server/src/commands/core/move.js | 83 - server/src/commands/core/stats.js | 32 - server/src/commands/mod/ban.js | 64 - server/src/commands/mod/kick.js | 78 - server/src/commands/mod/unban.js | 55 - server/src/core/rateLimiter.js | 103 -- server/src/core/server.js | 282 ---- server/src/managers/commands.js | 239 --- server/src/managers/config.js | 224 --- server/src/managers/imports-manager.js | 148 -- server/src/managers/index.js | 6 - server/src/managers/stats.js | 59 - server/src/scripts/configure.js | 23 - server/src/scripts/debug.js | 18 - server/src/scripts/dev.js | 17 - 57 files changed, 2083 insertions(+), 4995 deletions(-) delete mode 100644 server/.gitignore create mode 100644 server/commands/admin/addmod.js create mode 100644 server/commands/admin/listusers.js create mode 100644 server/commands/admin/reload.js create mode 100644 server/commands/admin/saveconfig.js create mode 100644 server/commands/admin/shout.js create mode 100644 server/commands/core/changenick.js create mode 100644 server/commands/core/chat.js create mode 100644 server/commands/core/disconnect.js create mode 100644 server/commands/core/help.js create mode 100644 server/commands/core/invite.js create mode 100644 server/commands/core/join.js create mode 100644 server/commands/core/morestats.js create mode 100644 server/commands/core/move.js create mode 100644 server/commands/core/stats.js create mode 100644 server/commands/mod/ban.js create mode 100644 server/commands/mod/kick.js create mode 100644 server/commands/mod/unban.js create mode 100644 server/core/rateLimiter.js create mode 100644 server/core/server.js create mode 100644 server/managers/commands.js create mode 100644 server/managers/config.js create mode 100644 server/managers/imports-manager.js create mode 100644 server/managers/index.js create mode 100644 server/managers/stats.js delete mode 100644 server/package-lock.json delete mode 100644 server/package.json create mode 100644 server/scripts/configure.js create mode 100644 server/scripts/debug.js create mode 100644 server/scripts/dev.js delete mode 100644 server/src/commands/admin/addmod.js delete mode 100644 server/src/commands/admin/listusers.js delete mode 100644 server/src/commands/admin/reload.js delete mode 100644 server/src/commands/admin/saveconfig.js delete mode 100644 server/src/commands/admin/shout.js delete mode 100644 server/src/commands/core/changenick.js delete mode 100644 server/src/commands/core/chat.js delete mode 100644 server/src/commands/core/disconnect.js delete mode 100644 server/src/commands/core/help.js delete mode 100644 server/src/commands/core/invite.js delete mode 100644 server/src/commands/core/join.js delete mode 100644 server/src/commands/core/morestats.js delete mode 100644 server/src/commands/core/move.js delete mode 100644 server/src/commands/core/stats.js delete mode 100644 server/src/commands/mod/ban.js delete mode 100644 server/src/commands/mod/kick.js delete mode 100644 server/src/commands/mod/unban.js delete mode 100644 server/src/core/rateLimiter.js delete mode 100644 server/src/core/server.js delete mode 100644 server/src/managers/commands.js delete mode 100644 server/src/managers/config.js delete mode 100644 server/src/managers/imports-manager.js delete mode 100644 server/src/managers/index.js delete mode 100644 server/src/managers/stats.js delete mode 100644 server/src/scripts/configure.js delete mode 100644 server/src/scripts/debug.js delete mode 100644 server/src/scripts/dev.js (limited to 'server') diff --git a/server/.gitignore b/server/.gitignore deleted file mode 100644 index 46de862..0000000 --- a/server/.gitignore +++ /dev/null @@ -1,63 +0,0 @@ -# Logs -logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* - -# Runtime data -pids -*.pid -*.seed -*.pid.lock - -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul -coverage - -# nyc test coverage -.nyc_output - -# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) -.grunt - -# Bower dependency directory (https://bower.io/) -bower_components - -# node-waf configuration -.lock-wscript - -# Compiled binary addons (https://nodejs.org/api/addons.html) -build/Release - -# Dependency directories -node_modules/ -jspm_packages/ - -# Typescript v1 declaration files -typings/ - -# Optional npm cache directory -.npm - -# Optional eslint cache -.eslintcache - -# Optional REPL history -.node_repl_history - -# Output of 'npm pack' -*.tgz - -# Yarn Integrity file -.yarn-integrity - -# dotenv environment variables file -.env - -# next.js build output -.next - -config/ \ No newline at end of file diff --git a/server/commands/admin/addmod.js b/server/commands/admin/addmod.js new file mode 100644 index 0000000..4c13b22 --- /dev/null +++ b/server/commands/admin/addmod.js @@ -0,0 +1,47 @@ +/* + Description: Adds the target trip to the mod list then elevates the uType +*/ + +exports.run = async (core, server, socket, data) => { + if (socket.uType != 'admin') { + // ignore if not admin + return; + } + + let mod = { + trip: data.trip + } + + core.config.mods.push(mod); // purposely not using `config.set()` to avoid auto-save + + let newMod = server.findSockets({ trip: data.trip }); + + if (newMod.length !== 0) { + for (let i = 0, l = newMod.length; i < l; i++) { + newMod[i].uType = 'mod'; + + server.send({ + cmd: 'info', + text: 'You are now a mod.' + }, newMod[i]); + } + } + + server.reply({ + cmd: 'info', + text: `Added mod trip: ${data.trip}` + }, socket); + + server.broadcast({ + cmd: 'info', + text: `Added mod trip: ${data.trip}` + }, { uType: 'mod' }); +}; + +exports.requiredData = ['trip']; + +exports.info = { + name: 'addmod', + usage: 'addmod {trip}', + description: 'Adds target trip to the config as a mod and upgrades the socket type' +}; diff --git a/server/commands/admin/listusers.js b/server/commands/admin/listusers.js new file mode 100644 index 0000000..a539a3c --- /dev/null +++ b/server/commands/admin/listusers.js @@ -0,0 +1,38 @@ +/* + Description: Outputs all current channels and their user nicks +*/ + +exports.run = async (core, server, socket, data) => { + if (socket.uType != 'admin') { + // ignore if not admin + return; + } + + let channels = {}; + for (var client of server.clients) { + if (client.channel) { + if (!channels[client.channel]) { + channels[client.channel] = []; + } + channels[client.channel].push(client.nick); + } + } + + let lines = []; + for (let channel in channels) { + lines.push(`?${channel} ${channels[channel].join(", ")}`); + } + + let text = ''; + text += lines.join("\n"); + + server.reply({ + cmd: 'info', + text: text + }, socket); +}; + +exports.info = { + name: 'listusers', + description: 'Outputs all current channels and sockets in those channels' +}; diff --git a/server/commands/admin/reload.js b/server/commands/admin/reload.js new file mode 100644 index 0000000..e2cfbe6 --- /dev/null +++ b/server/commands/admin/reload.js @@ -0,0 +1,35 @@ +/* + Description: Clears and resets the command modules, outputting any errors +*/ + +exports.run = async (core, server, socket, data) => { + if (socket.uType != 'admin') { + // ignore if not admin + return; + } + + let loadResult = core.managers.dynamicImports.reloadDirCache('src/commands'); + loadResult += core.commands.loadCommands(); + + if (loadResult == '') { + loadResult = `Loaded ${core.commands._commands.length} commands, 0 errors`; + } else { + loadResult = `Loaded ${core.commands._commands.length} commands, error(s): ${loadResult}`; + } + + server.reply({ + cmd: 'info', + text: loadResult + }, socket); + + server.broadcast({ + cmd: 'info', + text: loadResult + }, { uType: 'mod' }); +}; + +exports.info = { + name: 'reload', + description: '(Re)loads any new commands into memory, outputs errors if any' +}; + diff --git a/server/commands/admin/saveconfig.js b/server/commands/admin/saveconfig.js new file mode 100644 index 0000000..ed3a312 --- /dev/null +++ b/server/commands/admin/saveconfig.js @@ -0,0 +1,36 @@ +/* + Description: Writes any changes to the config to the disk +*/ + +exports.run = async (core, server, socket, data) => { + if (socket.uType != 'admin') { + // ignore if not admin + return; + } + + let saveResult = core.managers.config.save(); + + if (!saveResult) { + server.reply({ + cmd: 'warn', + text: 'Failed to save config, check logs.' + }, client); + + return; + } + + server.reply({ + cmd: 'info', + text: 'Config saved!' + }, socket); + + server.broadcast({ + cmd: 'info', + text: 'Config saved!' + }, { uType: 'mod' }); +}; + +exports.info = { + name: 'saveconfig', + description: 'Saves current config' +}; diff --git a/server/commands/admin/shout.js b/server/commands/admin/shout.js new file mode 100644 index 0000000..1358dd9 --- /dev/null +++ b/server/commands/admin/shout.js @@ -0,0 +1,23 @@ +/* + Description: Emmits a server-wide message as `info` +*/ + +exports.run = async (core, server, socket, data) => { + if (socket.uType != 'admin') { + // ignore if not admin + return; + } + + server.broadcast( { + cmd: 'info', + text: `Server Notice: ${data.text}` + }, {}); +}; + +exports.requiredData = ['text']; + +exports.info = { + name: 'shout', + usage: 'shout {text}', + description: 'Displays passed text to every client connected' +}; \ No newline at end of file diff --git a/server/commands/core/changenick.js b/server/commands/core/changenick.js new file mode 100644 index 0000000..4041bb0 --- /dev/null +++ b/server/commands/core/changenick.js @@ -0,0 +1,88 @@ +/* + Description: Generates a semi-unique channel name then broadcasts it to each client +*/ + +const verifyNickname = (nick) => { + return /^[a-zA-Z0-9_]{1,24}$/.test(nick); +}; + +exports.run = async (core, server, socket, data) => { + if (server._police.frisk(socket.remoteAddress, 6)) { + server.reply({ + cmd: 'warn', + text: 'You are changing nicknames too fast. Wait a moment before trying again.' + }, socket); + + return; + } + + if (typeof data.nick !== 'string') { + return; + } + + let newNick = data.nick.trim(); + + if (!verifyNickname(newNick)) { + server.reply({ + cmd: 'warn', + text: 'Nickname must consist of up to 24 letters, numbers, and underscores' + }, socket); + + return; + } + + if (newNick.toLowerCase() == core.config.adminName.toLowerCase()) { + server._police.frisk(socket.remoteAddress, 4); + + server.reply({ + cmd: 'warn', + text: 'Gtfo' + }, socket); + + return; + } + + let userExists = server.findSockets({ + channel: socket.channel, + nick: (targetNick) => targetNick.toLowerCase() === newNick.toLowerCase() + }); + + if (userExists.length > 0) { + // That nickname is already in that channel + server.reply({ + cmd: 'warn', + text: 'Nickname taken' + }, socket); + + return; + } + + let peerList = server.findSockets({ channel: socket.channel }); + let leaveNotice = { + cmd: 'onlineRemove', + nick: socket.nick + }; + let joinNotice = { + cmd: 'onlineAdd', + nick: newNick, + trip: socket.trip || 'null', + hash: server.getSocketHash(socket) + }; + + server.broadcast( leaveNotice, { channel: socket.channel }); + server.broadcast( joinNotice, { channel: socket.channel }); + server.broadcast( { + cmd: 'info', + text: `${socket.nick} is now ${newNick}` + }, { channel: socket.channel }); + + socket.nick = newNick; +}; + +exports.requiredData = ['nick']; + +exports.info = { + name: 'changenick', + usage: 'changenick {nick}', + description: 'This will change your current connections nickname' +}; diff --git a/server/commands/core/chat.js b/server/commands/core/chat.js new file mode 100644 index 0000000..bce6adb --- /dev/null +++ b/server/commands/core/chat.js @@ -0,0 +1,62 @@ +/* + Description: Rebroadcasts any `text` to all clients in a `channel` +*/ + +const parseText = (text) => { + if (typeof text !== 'string') { + return false; + } + + // strip newlines from beginning and end + text = text.replace(/^\s*\n|^\s+$|\n\s*$/g, ''); + // replace 3+ newlines with just 2 newlines + text = text.replace(/\n{3,}/g, "\n\n"); + + return text; +}; + +exports.run = async (core, server, socket, data) => { + let text = parseText(data.text); + if (!text) { + // lets not send objects or empty text, yea? + return; + } + + let score = text.length / 83 / 4; + if (server._police.frisk(socket.remoteAddress, score)) { + server.reply({ + cmd: 'warn', + text: 'You are sending too much text. Wait a moment and try again.\nPress the up arrow key to restore your last message.' + }, socket); + + return; + } + + let payload = { + cmd: 'chat', + nick: socket.nick, + text: text + }; + + if (socket.uType == 'admin') { + payload.admin = true; + } else if (socket.uType == 'mod') { + payload.mod = true; + } + + if (socket.trip) { + payload.trip = socket.trip; + } + + server.broadcast( payload, { channel: socket.channel }); + + core.managers.stats.increment('messages-sent'); +}; + +exports.requiredData = ['text']; + +exports.info = { + name: 'chat', + usage: 'chat {text}', + description: 'Broadcasts passed `text` field to the calling users channel' +}; \ No newline at end of file diff --git a/server/commands/core/disconnect.js b/server/commands/core/disconnect.js new file mode 100644 index 0000000..9b54214 --- /dev/null +++ b/server/commands/core/disconnect.js @@ -0,0 +1,21 @@ +/* + Description: This module will be directly called by the server event handler + when a socket connection is closed or lost. It can calso be called + by a client to have the connection severed. +*/ + +exports.run = async (core, server, socket, data) => { + if (socket.channel) { + server.broadcast({ + cmd: 'onlineRemove', + nick: socket.nick + }, { channel: socket.channel }); + } + + socket.terminate(); +}; + +exports.info = { + name: 'disconnect', + description: 'Event handler or force disconnect (if your into that kind of thing)' +}; \ No newline at end of file diff --git a/server/commands/core/help.js b/server/commands/core/help.js new file mode 100644 index 0000000..7f63d3d --- /dev/null +++ b/server/commands/core/help.js @@ -0,0 +1,49 @@ +/* + Description: Outputs the current command module list or command categories +*/ + +const stripIndents = require('common-tags').stripIndents; + +exports.run = async (core, server, socket, data) => { + // verify passed arguments + let typeDt = typeof data.type; + let catDt = typeof data.category; + let cmdDt = typeof data.command; + if (typeDt !== 'undefined' && typeDt !== 'string' ) { + return; + } else if (catDt !== 'undefined' && catDt !== 'string' ) { + return; + } else if (cmdDt !== 'undefined' && cmdDt !== 'string' ) { + return; + } + + // set default reply + let reply = stripIndents`Help usage: + Show all categories -> { cmd: 'help', type: 'categories' } + Show all commands in category -> { cmd: 'help', category: '' } + Show specific command -> { cmd: 'help', command: '' }`; + + if (typeDt !== 'undefined') { + let categories = core.commands.categories().sort(); + reply = `Command Categories:\n${categories.map(c => `- ${c.replace('../src/commands/', '')}`).join('\n')}`; + } else if (catDt !== 'undefined') { + let catCommands = core.commands.all('../src/commands/' + data.category).sort((a, b) => a.info.name.localeCompare(b.info.name)); + reply = `${data.category} commands:\n${catCommands.map(c => `- ${c.info.name}`).join('\n')}`; + } else if (cmdDt !== 'undefined') { + let command = core.commands.get(data.command); + reply = stripIndents` + Usage: ${command.info.usage || command.info.name} + Description: ${command.info.description || '¯\_(ツ)_/¯'}`; + } + + server.reply({ + cmd: 'info', + text: reply + }, socket); +}; + +exports.info = { + name: 'help', + usage: 'help ([ type:categories] | [category: | command: ])', + description: 'Outputs information about the servers current protocol' +}; \ No newline at end of file diff --git a/server/commands/core/invite.js b/server/commands/core/invite.js new file mode 100644 index 0000000..bcf9097 --- /dev/null +++ b/server/commands/core/invite.js @@ -0,0 +1,65 @@ +/* + Description: Generates a semi-unique channel name then broadcasts it to each client +*/ + +const verifyNickname = (nick) => { + return /^[a-zA-Z0-9_]{1,24}$/.test(nick); +}; + +exports.run = async (core, server, socket, data) => { + if (server._police.frisk(socket.remoteAddress, 2)) { + server.reply({ + cmd: 'warn', + text: 'You are sending invites too fast. Wait a moment before trying again.' + }, socket); + + return; + } + + if (typeof data.nick !== 'string') { + return; + } + + if (!verifyNickname(data.nick)) { + // Not a valid nickname? Chances are we won't find them + return; + } + + if (data.nick == socket.nick) { + // They invited themself + return; + } + + let channel = Math.random().toString(36).substr(2, 8); + + let payload = { + cmd: 'info', + invite: channel, + text: `${socket.nick} invited you to ?${channel}` + }; + let inviteSent = server.broadcast( payload, { channel: socket.channel, nick: data.nick }); + + if (!inviteSent) { + server.reply({ + cmd: 'warn', + text: 'Could not find user in channel' + }, socket); + + return; + } + + server.reply({ + cmd: 'info', + text: `You invited ${data.nick} to ?${channel}` + }, socket); + + core.managers.stats.increment('invites-sent'); +}; + +exports.requiredData = ['nick']; + +exports.info = { + name: 'invite', + usage: 'invite {nick}', + description: 'Generates a unique (more or less) room name and passes it to two clients' +}; \ No newline at end of file diff --git a/server/commands/core/join.js b/server/commands/core/join.js new file mode 100644 index 0000000..f2b2c9d --- /dev/null +++ b/server/commands/core/join.js @@ -0,0 +1,135 @@ +/* + Description: Initial entry point, applies `channel` and `nick` to the calling socket +*/ + +const crypto = require('crypto'); + +const hash = (password) => { + let sha = crypto.createHash('sha256'); + sha.update(password); + return sha.digest('base64').substr(0, 6); +}; + +const verifyNickname = (nick) => { + return /^[a-zA-Z0-9_]{1,24}$/.test(nick); +}; + +exports.run = async (core, server, socket, data) => { + if (server._police.frisk(socket.remoteAddress, 3)) { + server.reply({ + cmd: 'warn', + text: 'You are joining channels too fast. Wait a moment and try again.' + }, socket); + + return; + } + + if (typeof socket.channel !== 'undefined') { + // Calling socket already in a channel + return; + } + + if (typeof data.channel !== 'string' || typeof data.nick !== 'string') { + return; + } + + let channel = data.channel.trim(); + if (!channel) { + // Must join a non-blank channel + return; + } + + // Process nickname + let nick = data.nick; + let nickArray = nick.split('#', 2); + nick = nickArray[0].trim(); + + if (!verifyNickname(nick)) { + server.reply({ + cmd: 'warn', + text: 'Nickname must consist of up to 24 letters, numbers, and underscores' + }, socket); + + return; + } + + let userExists = server.findSockets({ + channel: data.channel, + nick: (targetNick) => targetNick.toLowerCase() === nick.toLowerCase() + }); + + if (userExists.length > 0) { + // That nickname is already in that channel + server.reply({ + cmd: 'warn', + text: 'Nickname taken' + }, socket); + + return; + } + + // TODO: Should we check for mod status first to prevent overwriting of admin status somehow? Meh, w/e, cba. + let uType = 'user'; + let trip = null; + let password = nickArray[1]; + if (nick.toLowerCase() == core.config.adminName.toLowerCase()) { + if (password != core.config.adminPass) { + server._police.frisk(socket.remoteAddress, 4); + + server.reply({ + cmd: 'warn', + text: 'Gtfo' + }, socket); + + return; + } else { + uType = 'admin'; + trip = 'Admin'; + } + } else if (password) { + trip = hash(password + core.config.tripSalt); + } + + // TODO: Disallow moderator impersonation + for (let mod of core.config.mods) { + if (trip === mod.trip) { + uType = 'mod'; + } + } + + // Reply with online user list + let newPeerList = server.findSockets({ channel: data.channel }); + let joinAnnouncement = { + cmd: 'onlineAdd', + nick: nick, + trip: trip || 'null', + hash: server.getSocketHash(socket) + }; + let nicks = []; + + for (let i = 0, l = newPeerList.length; i < l; i++) { + server.reply(joinAnnouncement, newPeerList[i]); + nicks.push(newPeerList[i].nick); + } + + socket.uType = uType; + socket.nick = nick; + socket.channel = channel; + if (trip !== null) socket.trip = trip; + nicks.push(socket.nick); + + server.reply({ + cmd: 'onlineSet', + nicks: nicks + }, socket); + + core.managers.stats.increment('users-joined'); +}; + +exports.requiredData = ['channel', 'nick']; + +exports.info = { + name: 'join', + usage: 'join {channel} {nick}', + description: 'Place calling socket into target channel with target nick & broadcast event to channel' +}; \ No newline at end of file diff --git a/server/commands/core/morestats.js b/server/commands/core/morestats.js new file mode 100644 index 0000000..5510cb1 --- /dev/null +++ b/server/commands/core/morestats.js @@ -0,0 +1,53 @@ +/* + Description: Outputs more info than the legacy stats command +*/ + +const stripIndents = require('common-tags').stripIndents; + +const formatTime = (time) => { + let seconds = time[0] + time[1] / 1e9; + + let minutes = Math.floor(seconds / 60); + seconds = seconds % 60; + + let hours = Math.floor(minutes / 60); + minutes = minutes % 60; + return `${hours.toFixed(0)}h ${minutes.toFixed(0)}m ${seconds.toFixed(0)}s`; +}; + +exports.run = async (core, server, socket, data) => { + let ips = {}; + let channels = {}; + for (let client of server.clients) { + if (client.channel) { + channels[client.channel] = true; + ips[client.remoteAddress] = true; + } + } + + let uniqueClientCount = Object.keys(ips).length; + let uniqueChannels = Object.keys(channels).length; + + ips = null; + channels = null; + + server.reply({ + cmd: 'info', + text: stripIndents`current-connections: ${uniqueClientCount} + current-channels: ${uniqueChannels} + users-joined: ${(core.managers.stats.get('users-joined') || 0)} + invites-sent: ${(core.managers.stats.get('invites-sent') || 0)} + messages-sent: ${(core.managers.stats.get('messages-sent') || 0)} + users-banned: ${(core.managers.stats.get('users-banned') || 0)} + users-kicked: ${(core.managers.stats.get('users-kicked') || 0)} + stats-requested: ${(core.managers.stats.get('stats-requested') || 0)} + server-uptime: ${formatTime(process.hrtime(core.managers.stats.get('start-time')))}` + }, socket); + + core.managers.stats.increment('stats-requested'); +}; + +exports.info = { + name: 'morestats', + description: 'Sends back current server stats to the calling client' +}; \ No newline at end of file diff --git a/server/commands/core/move.js b/server/commands/core/move.js new file mode 100644 index 0000000..c5efafd --- /dev/null +++ b/server/commands/core/move.js @@ -0,0 +1,83 @@ +/* + Description: Generates a semi-unique channel name then broadcasts it to each client +*/ + +exports.run = async (core, server, socket, data) => { + if (server._police.frisk(socket.remoteAddress, 6)) { + server.reply({ + cmd: 'warn', + text: 'You are changing channels too fast. Wait a moment before trying again.' + }, socket); + + return; + } + + if (typeof data.channel !== 'string') { + return; + } + + if (data.channel === socket.channel) { + // They are trying to rejoin the channel + return; + } + + const currentNick = socket.nick.toLowerCase(); + let userExists = server.findSockets({ + channel: data.channel, + nick: (targetNick) => targetNick.toLowerCase() === currentNick + }); + + if (userExists.length > 0) { + // That nickname is already in that channel + return; + } + + let peerList = server.findSockets({ channel: socket.channel }); + + if (peerList.length > 1) { + for (let i = 0, l = peerList.length; i < l; i++) { + server.reply({ + cmd: 'onlineRemove', + nick: peerList[i].nick + }, socket); + + if (socket.nick !== peerList[i].nick){ + server.reply({ + cmd: 'onlineRemove', + nick: socket.nick + }, peerList[i]); + } + } + } + + let newPeerList = server.findSockets({ channel: data.channel }); + let moveAnnouncement = { + cmd: 'onlineAdd', + nick: socket.nick, + trip: socket.trip || 'null', + hash: server.getSocketHash(socket) + }; + let nicks = []; + + for (let i = 0, l = newPeerList.length; i < l; i++) { + server.reply(moveAnnouncement, newPeerList[i]); + nicks.push(newPeerList[i].nick); + } + + nicks.push(socket.nick); + + server.reply({ + cmd: 'onlineSet', + nicks: nicks + }, socket); + + socket.channel = data.channel; +}; + +exports.requiredData = ['channel']; + +exports.info = { + name: 'move', + usage: 'move {channel}', + description: 'This will change the current channel to the new one provided' +}; \ No newline at end of file diff --git a/server/commands/core/stats.js b/server/commands/core/stats.js new file mode 100644 index 0000000..b9dc002 --- /dev/null +++ b/server/commands/core/stats.js @@ -0,0 +1,32 @@ +/* + Description: Legacy stats output, kept for compatibility, outputs user and channel count +*/ + +exports.run = async (core, server, socket, data) => { + let ips = {}; + let channels = {}; + for (let client of server.clients) { + if (client.channel) { + channels[client.channel] = true; + ips[client.remoteAddress] = true; + } + } + + let uniqueClientCount = Object.keys(ips).length; + let uniqueChannels = Object.keys(channels).length; + + ips = null; + channels = null; + + server.reply({ + cmd: 'info', + text: `${uniqueClientCount} unique IPs in ${uniqueChannels} channels` + }, socket); + + core.managers.stats.increment('stats-requested'); +}; + +exports.info = { + name: 'stats', + description: 'Sends back legacy server stats to the calling client' +}; \ No newline at end of file diff --git a/server/commands/mod/ban.js b/server/commands/mod/ban.js new file mode 100644 index 0000000..e19efc2 --- /dev/null +++ b/server/commands/mod/ban.js @@ -0,0 +1,64 @@ +/* + Description: Adds the target socket's ip to the ratelimiter +*/ + +exports.run = async (core, server, socket, data) => { + if (socket.uType == 'user') { + // ignore if not mod or admin + return; + } + + if (typeof data.nick !== 'string') { + return; + } + + let targetNick = data.nick; + let badClient = server.findSockets({ channel: socket.channel, nick: targetNick }); + + if (badClient.length === 0) { + server.reply({ + cmd: 'warn', + text: 'Could not find user in channel' + }, socket); + + return; + } + + badClient = badClient[0]; + + if (badClient.uType !== 'user') { + server.reply({ + cmd: 'warn', + text: 'Cannot ban other mods, how rude' + }, socket); + + return; + } + + let clientHash = server.getSocketHash(badClient); + server._police.arrest(badClient.remoteAddress, clientHash); + + console.log(`${socket.nick} [${socket.trip}] banned ${targetNick} in ${socket.channel}`); + + server.broadcast({ + cmd: 'info', + text: `Banned ${targetNick}` + }, { channel: socket.channel, uType: 'user' }); + + server.broadcast({ + cmd: 'info', + text: `${socket.nick} banned ${targetNick} in ${socket.channel}, userhash: ${clientHash}` + }, { uType: 'mod' }); + + badClient.close(); + + core.managers.stats.increment('users-banned'); +}; + +exports.requiredData = ['nick']; + +exports.info = { + name: 'ban', + usage: 'ban {nick}', + description: 'Disconnects the target nickname in the same channel as calling socket & adds to ratelimiter' +}; diff --git a/server/commands/mod/kick.js b/server/commands/mod/kick.js new file mode 100644 index 0000000..157592d --- /dev/null +++ b/server/commands/mod/kick.js @@ -0,0 +1,78 @@ +/* + Description: Forces a change on the target socket's channel, then broadcasts event +*/ + +exports.run = async (core, server, socket, data) => { + if (socket.uType === 'user') { + // ignore if not mod or admin + return; + } + + if (typeof data.nick !== 'string') { + if (typeof data.nick !== 'object' && !Array.isArray(data.nick)) { + return; + } + } + + let badClients = server.findSockets({ channel: socket.channel, nick: data.nick }); + + if (badClients.length === 0) { + server.reply({ + cmd: 'warn', + text: 'Could not find user(s) in channel' + }, socket); + + return; + } + + let newChannel = ''; + let kicked = []; + for (let i = 0, j = badClients.length; i < j; i++) { + if (badClients[i].uType !== 'user') { + server.reply({ + cmd: 'warn', + text: 'Cannot kick other mods, how rude' + }, socket); + } else { + newChannel = Math.random().toString(36).substr(2, 8); + badClients[i].channel = newChannel; + + // inform mods with where they were sent + server.broadcast({ + cmd: 'info', + text: `${badClients[i].nick} was banished to ?${newChannel}` + }, { channel: socket.channel, uType: 'mod' }); + + kicked.push(badClients[i].nick); + console.log(`${socket.nick} [${socket.trip}] kicked ${badClients[i].nick} in ${socket.channel}`); + } + } + + if (kicked.length === 0) { + return; + } + + // broadcast client leave event + for (let i = 0, j = kicked.length; i < j; i++) { + server.broadcast({ + cmd: 'onlineRemove', + nick: kicked[i] + }, { channel: socket.channel }); + } + + // publicly broadcast kick event + server.broadcast({ + cmd: 'info', + text: `Kicked ${kicked.join(', ')}` + }, { channel: socket.channel, uType: 'user' }); + + core.managers.stats.increment('users-kicked', kicked.length); +}; + +exports.requiredData = ['nick']; + +exports.info = { + name: 'kick', + usage: 'kick {nick}', + description: 'Silently forces target client(s) into another channel. `nick` may be string or array of strings' +}; \ No newline at end of file diff --git a/server/commands/mod/unban.js b/server/commands/mod/unban.js new file mode 100644 index 0000000..e82f0b9 --- /dev/null +++ b/server/commands/mod/unban.js @@ -0,0 +1,55 @@ +/* + Description: Removes a target ip from the ratelimiter +*/ + +exports.run = async (core, server, socket, data) => { + if (socket.uType == 'user') { + // ignore if not mod or admin + return; + } + + if (typeof data.ip !== 'string' && typeof data.hash !== 'string') { + server.reply({ + cmd: 'warn', + text: "hash:'targethash' or ip:'1.2.3.4' is required" + }, socket); + + return; + } + + let mode, target; + + if (typeof data.ip === 'string') { + mode = 'ip'; + target = data.ip; + } else { + mode = 'hash'; + target = data.hash; + } + + server._police.pardon(target); + + if (mode === 'ip') { + target = server.getSocketHash(target); + } + + console.log(`${socket.nick} [${socket.trip}] unbanned ${target} in ${socket.channel}`); + + server.reply({ + cmd: 'info', + text: `Unbanned ${target}` + }, socket); + + server.broadcast({ + cmd: 'info', + text: `${socket.nick} unbanned: ${target}` + }, { uType: 'mod' }); + + core.managers.stats.decrement('users-banned'); +}; + +exports.info = { + name: 'unban', + usage: 'unban {[ip || hash]}', + description: 'Removes target ip from the ratelimiter' +}; \ No newline at end of file diff --git a/server/core/rateLimiter.js b/server/core/rateLimiter.js new file mode 100644 index 0000000..0c2a384 --- /dev/null +++ b/server/core/rateLimiter.js @@ -0,0 +1,103 @@ +/** + * Tracks frequency of occurances based on `id` (remote address), then allows or + * denies command execution based on comparison with `threshold` + * + * Version: v2.0.0 + * Developer: Marzavec ( https://github.com/marzavec ) + * License: WTFPL ( http://www.wtfpl.net/txt/copying/ ) + * + */ + +class Police { + /** + * Create a ratelimiter instance. + */ + constructor () { + this._records = {}; + this._halflife = 30 * 1000; // milliseconds + this._threshold = 25; + this._hashes = []; + } + + /** + * Finds current score by `id` + * + * @param {String} id target id / address + * @public + * + * @memberof Police + */ + search (id) { + let record = this._records[id]; + + if (!record) { + record = this._records[id] = { + time: Date.now(), + score: 0 + } + } + + return record; + } + + /** + * Adjusts the current ratelimit score by `deltaScore` + * + * @param {String} id target id / address + * @param {Number} deltaScore amount to adjust current score by + * @public + * + * @memberof Police + */ + frisk (id, deltaScore) { + let record = this.search(id); + + if (record.arrested) { + return true; + } + + record.score *= Math.pow(2, -(Date.now() - record.time ) / this._halflife); + record.score += deltaScore; + record.time = Date.now(); + + if (record.score >= this._threshold) { + return true; + } + + return false; + } + + /** + * Statically set server to no longer accept traffic from `id` + * + * @param {String} id target id / address + * @public + * + * @memberof Police + */ + arrest (id, hash) { + let record = this.search(id); + + record.arrested = true; + this._hashes[hash] = id; + } + + /** + * Remove statically assigned limit from `id` + * + * @param {String} id target id / address + * @public + * + * @memberof Police + */ + pardon (id) { + if (typeof this._hashes[id] !== 'undefined') { + id = this._hashes[id]; + } + + let record = this.search(id); + record.arrested = false; + } +} + +module.exports = Police; diff --git a/server/core/server.js b/server/core/server.js new file mode 100644 index 0000000..855aeba --- /dev/null +++ b/server/core/server.js @@ -0,0 +1,282 @@ +/** + * Main websocket server handling communications and connection events + * + * Version: v2.0.0 + * Developer: Marzavec ( https://github.com/marzavec ) + * License: WTFPL ( http://www.wtfpl.net/txt/copying/ ) + * + */ + +const wsServer = require('ws').Server; +const socketReady = require('ws').OPEN; +const crypto = require('crypto'); +const ipSalt = (Math.random().toString(36).substring(2, 16) + Math.random().toString(36).substring(2, (Math.random() * 16))).repeat(16); +const Police = require('./rateLimiter'); +const pulseSpeed = 16000; // ping all clients every X ms + +class server extends wsServer { + /** + * Create a HackChat server instance. + * + * @param {Object} core Reference to the global core object + */ + constructor (core) { + super({ port: core.config.websocketPort }); + + this._core = core; + this._police = new Police(); + this._cmdBlacklist = {}; + this._heartBeat = setInterval(((data) => { + this.beatHeart(); + }).bind(this), pulseSpeed); + + this.on('error', (err) => { + this.handleError('server', err); + }); + + this.on('connection', (socket, request) => { + this.newConnection(socket, request); + }); + } + + /** + * Send empty `ping` frame to each client + * + */ + beatHeart () { + let targetSockets = this.findSockets({}); + + if (targetSockets.length === 0) { + return; + } + + for (let i = 0, l = targetSockets.length; i < l; i++) { + try { + if (targetSockets[i].readyState === socketReady) { + targetSockets[i].ping(); + } + } catch (e) { } + } + } + + /** + * Bind listeners for the new socket created on connection to this class + * + * @param {Object} socket New socket object + * @param {Object} request Initial headers of the new connection + */ + newConnection (socket, request) { + socket.remoteAddress = request.headers['x-forwarded-for'] || request.connection.remoteAddress; + + socket.on('message', ((data) => { + this.handleData(socket, data); + }).bind(this)); + + socket.on('close', (() => { + this.handleClose(socket); + }).bind(this)); + + socket.on('error', ((err) => { + this.handleError(socket, err); + }).bind(this)); + } + + /** + * Handle incoming messages from clients, parse and check command, then hand-off + * + * @param {Object} socket Calling socket object + * @param {String} data Message sent from client + */ + handleData (socket, data) { + // Don't penalize yet, but check whether IP is rate-limited + if (this._police.frisk(socket.remoteAddress, 0)) { + this.reply({ cmd: 'warn', text: "Your IP is being rate-limited or blocked." }, socket); + + return; + } + + // Penalize here, but don't do anything about it + this._police.frisk(socket.remoteAddress, 1); + + // ignore ridiculously large packets + if (data.length > 65536) { + return; + } + + // Start sent data verification + var args = null; + try { + args = JSON.parse(data); + } catch (e) { + // Client sent malformed json, gtfo + socket.close(); + } + + if (args === null) { + return; + } + + if (typeof args.cmd === 'undefined' || args.cmd == 'ping') { + return; + } + + if (typeof args.cmd !== 'string') { + return; + } + + if (typeof socket.channel === 'undefined' && args.cmd !== 'join') { + return; + } + + if (typeof this._cmdBlacklist[args.cmd] === 'function') { + return; + } + + // Finished verification, pass to command modules + this._core.commands.handleCommand(this, socket, args); + } + + /** + * Handle socket close from clients + * + * @param {Object} socket Closing socket object + */ + handleClose (socket) { + this._core.commands.handleCommand(this, socket, { cmd: 'disconnect' }); + } + + /** + * "Handle" server or socket errors + * + * @param {Object||String} socket Calling socket object, or 'server' + * @param {String} err The sad stuff + */ + handleError (socket, err) { + console.log(`Server error: ${err}`); + } + + /** + * Send data payload to specific socket/client + * + * @param {Object} data Object to convert to json for transmission + * @param {Object} socket The target client + */ + send (data, socket) { + // Add timestamp to command + data.time = Date.now(); + + try { + if (socket.readyState === socketReady) { + socket.send(JSON.stringify(data)); + } + } catch (e) { } + } + + /** + * Overload function for `this.send()` + * + * @param {Object} data Object to convert to json for transmission + * @param {Object} socket The target client + */ + reply (data, socket) { + this.send(data, socket); + } + + /** + * Finds sockets/clients that meet the filter requirements, then passes the data to them + * + * @param {Object} data Object to convert to json for transmission + * @param {Object} filter see `this.findSockets()` + */ + broadcast (data, filter) { + let targetSockets = this.findSockets(filter); + + if (targetSockets.length === 0) { + return false; + } + + for (let i = 0, l = targetSockets.length; i < l; i++) { + this.send(data, targetSockets[i]); + } + + return true; + } + + /** + * Finds sockets/clients that meet the filter requirements, returns result as array + * + * @param {Object} data Object to convert to json for transmission + * @param {Object} filter The socket must of equal or greater attribs matching `filter` + * = {} // matches all + * = { channel: 'programming' } // matches any socket where (`socket.channel` === 'programming') + * = { channel: 'programming', nick: 'Marzavec' } // matches any socket where (`socket.channel` === 'programming' && `socket.nick` === 'Marzavec') + */ + findSockets (filter) { + let filterAttribs = Object.keys(filter); + let reqCount = filterAttribs.length; + let curMatch; + let matches = []; + for ( let socket of this.clients ) { + curMatch = 0; + + for (let i = 0; i < reqCount; i++) { + if (typeof socket[filterAttribs[i]] !== 'undefined') { + switch(typeof filter[filterAttribs[i]]) { + case 'object': { + if (Array.isArray(filter[filterAttribs[i]])) { + if (filter[filterAttribs[i]].indexOf(socket[filterAttribs[i]]) !== -1) { + curMatch++; + } + } else { + if (socket[filterAttribs[i]] === filter[filterAttribs[i]]) { + curMatch++; + } + } + break; + } + + case 'function': { + if (filter[filterAttribs[i]](socket[filterAttribs[i]])) { + curMatch++; + } + break; + } + + default: { + if (socket[filterAttribs[i]] === filter[filterAttribs[i]]) { + curMatch++; + } + break; + } + } + } + } + + if (curMatch === reqCount) { + matches.push(socket); + } + } + + return matches; + } + + /** + * Encrypts target socket's remote address using non-static variable length salt + * encodes and shortens the output, returns that value + * + * @param {Object||String} target Either the target socket or ip as string + */ + getSocketHash (target) { + let sha = crypto.createHash('sha256'); + + if (typeof target === 'string') { + sha.update(target + ipSalt); + } else { + sha.update(target.remoteAddress + ipSalt); + } + + return sha.digest('base64').substr(0, 15); + } +} + +module.exports = server; diff --git a/server/managers/commands.js b/server/managers/commands.js new file mode 100644 index 0000000..c38fb4d --- /dev/null +++ b/server/managers/commands.js @@ -0,0 +1,239 @@ +/** + * Commands / protocol manager- loads, validates and handles command execution + * + * Version: v2.0.0 + * Developer: Marzavec ( https://github.com/marzavec ) + * License: WTFPL ( http://www.wtfpl.net/txt/copying/ ) + * + */ + +const path = require('path'); +const chalk = require('chalk'); +const didYouMean = require('didyoumean2'); + +class CommandManager { + /** + * Create a `CommandManager` instance for handling commands/protocol + * + * @param {Object} core Reference to the global core object + */ + constructor (core) { + this.core = core; + this._commands = []; + this._categories = []; + } + + /** + * (Re)initializes name spaces for commands and starts load routine + * + */ + loadCommands () { + this._commands = []; + this._categories = []; + + const core = this.core; + + const commandImports = core.managers.dynamicImports.getImport('src/commands'); + let cmdErrors = ''; + Object.keys(commandImports).forEach(file => { + let command = commandImports[file]; + let name = path.basename(file); + cmdErrors += this._validateAndLoad(command, file, name); + }); + + return cmdErrors; + } + + /** + * Checks the module after having been `require()`ed in and reports errors + * + * @param {Object} command reference to the newly loaded object + * @param {String} file file path to the module + * @param {String} name command (`cmd`) name + */ + _validateAndLoad (command, file, name) { + let error = this._validateCommand(command); + + if (error) { + let errText = `Failed to load '${name}': ${error}`; + console.log(errText); + return errText; + } + + if (!command.category) { + let base = path.join(this.core.managers.dynamicImports.base, 'commands'); + + let category = 'Uncategorized'; + if (file.indexOf(path.sep) > -1) { + category = path.dirname(path.relative(base, file)) + .replace(new RegExp(path.sep.replace('\\', '\\\\'), 'g'), '/'); + } + + command.info.category = category; + + if (this._categories.indexOf(category) === -1) + this._categories.push(category); + } + + if (typeof command.init === 'function') { + try { + command.init(this.core); + } catch (err) { + let errText = `Failed to initialize '${name}': ${err}`; + console.log(errText); + return errText; + } + } + + this._commands.push(command); + + return ''; + } + + /** + * Checks the module after having been `require()`ed in and reports errors + * + * @param {Object} object reference to the newly loaded object + */ + _validateCommand (object) { + if (typeof object !== 'object') + return 'command setup is invalid'; + + if (typeof object.run !== 'function') + return 'run function is missing'; + + if (typeof object.info !== 'object') + return 'info object is missing'; + + if (typeof object.info.name !== 'string') + return 'info object is missing a valid name field'; + + return null; + } + + /** + * Pulls all command names from a passed `category` + * + * @param {String} category reference to the newly loaded object + */ + all (category) { + return !category ? this._commands : this._commands.filter(c => c.info.category.toLowerCase() === category.toLowerCase()); + } + + /** + * Pulls all category names + * + */ + categories () { + return this._categories; + } + + /** + * Pulls command by name or alia(s) + * + * @param {String} name name or alias of command + */ + get (name) { + return this.findBy('name', name) + || this._commands.find(command => command.info.aliases instanceof Array && command.info.aliases.indexOf(name) > -1); + } + + /** + * Pulls command by arbitrary search of the `module.info` attribute + * + * @param {String} key name or alias of command + * @param {String} value name or alias of command + */ + findBy (key, value) { + return this._commands.find(c => c.info[key] === value); + } + + /** + * Finds and executes the requested command, or fails with semi-intelligent error + * + * @param {Object} server main server reference + * @param {Object} socket calling socket reference + * @param {Object} data command structure passed by socket (client) + */ + handleCommand (server, socket, data) { + // Try to find command first + let command = this.get(data.cmd); + + if (command) { + return this.execute(command, server, socket, data); + } else { + // Then fail with helpful (sorta) message + return this._handleFail(server, socket, data); + } + } + + /** + * Requested command failure handler, attempts to find command and reports back + * + * @param {Object} server main server reference + * @param {Object} socket calling socket reference + * @param {Object} data command structure passed by socket (client) + */ + _handleFail(server, socket, data) { + const maybe = didYouMean(data.cmd, this.all().map(c => c.info.name), { + threshold: 5, + thresholdType: 'edit-distance' + }); + + if (maybe) { + // Found a suggestion, pass it on to their dyslexic self + return server.reply({ + cmd: 'warn', + text: `Command not found, did you mean: \`${maybe}\`?` + }, socket); + } + + // Request so mangled that I don't even, silently fail + return; + } + + /** + * Attempt to execute the requested command, fail if err or bad params + * + * @param {Object} command target command module + * @param {Object} server main server reference + * @param {Object} socket calling socket reference + * @param {Object} data command structure passed by socket (client) + */ + async execute(command, server, socket, data) { + if (typeof command.requiredData !== 'undefined') { + let missing = []; + for (let i = 0, len = command.requiredData.length; i < len; i++) { + if (typeof data[command.requiredData[i]] === 'undefined') + missing.push(command.requiredData[i]); + } + + if (missing.length > 0) { + let errText = `Failed to execute '${command.info.name}': missing required ${missing.join(', ')}\n\n`; + + server.reply({ + cmd: 'warn', + text: errText + }, socket); + + return null; + } + } + + try { + return await command.run(this.core, server, socket, data); + } catch (err) { + let errText = `Failed to execute '${command.info.name}': ${err}`; + console.log(errText); + + server.reply({ + cmd: 'warn', + text: errText + }, socket); + + return null; + } + } +} + +module.exports = CommandManager; diff --git a/server/managers/config.js b/server/managers/config.js new file mode 100644 index 0000000..2865d00 --- /dev/null +++ b/server/managers/config.js @@ -0,0 +1,224 @@ +/** + * Server configuration manager, handling loading, creation, parsing and saving + * of the main config.json file + * + * Version: v2.0.0 + * Developer: Marzavec ( https://github.com/marzavec ) + * License: WTFPL ( http://www.wtfpl.net/txt/copying/ ) + * + */ + +const stripIndents = require('common-tags').stripIndents; +const dateFormat = require('dateformat'); +const chalk = require('chalk'); +const fse = require('fs-extra'); +const prompt = require('prompt'); +const path = require('path'); +const deSync = require('deasync'); + +class ConfigManager { + /** + * Create a `ConfigManager` instance for (re)loading classes and config + * + * @param {Object} core reference to the global core object + * @param {String} base executing directory name; __dirname + * @param {Object} dynamicImports dynamic import engine reference + */ + constructor (core, base, dynamicImports) { + this._core = core; + this._base = base; + + this._configPath = path.resolve(base, 'config/config.json'); + + this._dynamicImports = dynamicImports; + } + + /** + * Pulls both core config questions along with any optional config questions, + * used in building the initial config.json or re-building it. + * + * @param {Object} currentConfig an object containing current server settings, if any + * @param {Object} optionalConfigs optional (non-core) module config + */ + getQuestions (currentConfig, optionalConfigs) { + // core server setup questions + const questions = { + properties: { + adminName: { + pattern: /^"?[a-zA-Z0-9_]+"?$/, + type: 'string', + message: 'Nicks can only contain letters, numbers and underscores', + required: !currentConfig.adminName, + default: currentConfig.adminName, + before: value => value.replace(/"/g, '') + }, + adminPass: { + type: 'string', + required: !currentConfig.adminPass, + default: currentConfig.adminPass, + hidden: true, + replace: '*', + }, + websocketPort: { + type: 'number', + required: !currentConfig.websocketPort, + default: currentConfig.websocketPort || 6060 + }, + tripSalt: { + type: 'string', + required: !currentConfig.tripSalt, + default: currentConfig.tripSalt, + hidden: true, + replace: '*', + } + } + }; + + // non-core server setup questions, for future plugin support + Object.keys(optionalConfigs).forEach(configName => { + const config = optionalConfigs[configName]; + const question = config.getQuestion(currentConfig, configName); + + if (!question) { + return; + } + + question.description = (question.description || configName) + ' (Optional)'; + questions.properties[configName] = question; + }); + + return questions; + } + + /** + * `load` function overload, only blocking + * + */ + loadSync () { + let conf = {}; + conf = this.load(); + + // trip salt is the last core config question, wait until it's been populated + // TODO: update this to work with new plugin support + while(conf === null || typeof conf.tripSalt === 'undefined') { + deSync.sleep(100); + } + + return conf; + } + + /** + * (Re)builds the config.json (main server config), or loads the config into mem + * if rebuilding, process will exit- this is to allow a process manager to take over + * + * @param {Boolean} reconfiguring set to true by `scripts/configure.js`, will exit if true + */ + load (reconfiguring = false) { + if (reconfiguring || !fse.existsSync(this._configPath)) { + // gotta have that sexy console + console.log(stripIndents` + ${chalk.magenta('°º¤ø,¸¸,ø¤º°`°º¤ø,¸,ø¤°º¤ø,¸¸,ø¤º°`°º¤ø,¸°º¤ø,¸¸,ø¤º°`°º¤ø')} + ${chalk.gray('--------------(') + chalk.white(' HackChat Setup Wizard v1.0 ') + chalk.gray(')--------------')} + ${chalk.magenta('°º¤ø,¸¸,ø¤º°`°º¤ø,¸,ø¤°º¤ø,¸¸,ø¤º°`°º¤ø,¸°º¤ø,¸¸,ø¤º°`°º¤ø')} + + For advanced setup, see the HackChat wiki at: + ${chalk.green('https://github.com/')} + + ${chalk.white('Note:')} ${chalk.green('npm/yarn run config')} will re-run this utility. + + You will now be asked for the following: + - ${chalk.magenta('Admin Name')}, the initial admin username + - ${chalk.magenta('Admin Pass')}, the initial admin password + - ${chalk.magenta(' Port')}, the port for the websocket + - ${chalk.magenta(' Salt')}, the salt for username trip + \u200b + `); + + let currentConfig = this._config || {}; + if (reconfiguring && fse.existsSync(this._configPath)) { + this._backup(); + currentConfig = fse.readJSONSync(this._configPath); + } + + prompt.get(this.getQuestions(currentConfig, this._dynamicImports.optionalConfigs), (err, res) => { + if (typeof res.mods === 'undefined') { + res.mods = []; + } + + if (err) { + console.error(err); + process.exit(666); // SPOOKY! + } + + try { + fse.outputJsonSync(this._configPath, res); + } catch (e) { + console.error(`Couldn't write config to ${this._configPath}\n${e.stack}`); + if (!reconfiguring) { + process.exit(666); // SPOOKY! + } + } + + console.log('Config generated! You may now start the server normally.') + + process.exit(reconfiguring ? 0 : 42); + }); + + return null; + } + + this._config = fse.readJSONSync(this._configPath); + + return this._config; + } + + /** + * Creates backup of current config into _configPath + * + */ + _backup () { + const backupPath = `${this._configPath}.${dateFormat('dd-mm-yy-HH-MM-ss')}.bak`; + fse.copySync(this._configPath, backupPath); + + return backupPath; + } + + /** + * First makes a backup of the current `config.json`, then writes current config + * to disk + * + */ + save () { + const backupPath = this._backup(); + + if (!fse.existsSync(this._configPath)){ + fse.mkdirSync(this._configPath); + } + + try { + fse.writeJSONSync(this._configPath, this._config); + fse.removeSync(backupPath); + + return true; + } catch (err) { + console.log(`Failed to save config file: ${err}`); + + return false; + } + } + + /** + * Updates current config[`key`] with `value` then writes changes to disk + * + * @param {*} key arbitrary configuration key + * @param {*} value new value to change `key` to + */ + set (key, value) { + const realKey = `${key}`; + this._config[realKey] = value; + + this.save(); + } +} + +module.exports = ConfigManager; diff --git a/server/managers/imports-manager.js b/server/managers/imports-manager.js new file mode 100644 index 0000000..d8b2144 --- /dev/null +++ b/server/managers/imports-manager.js @@ -0,0 +1,148 @@ +/** + * Import managment base, used to load commands/protocol and configuration objects + * + * Version: v2.0.0 + * Developer: Marzavec ( https://github.com/marzavec ) + * License: WTFPL ( http://www.wtfpl.net/txt/copying/ ) + * + */ + +const read = require('readdir-recursive'); +const path = require('path'); + +class ImportsManager { + /** + * Create a `ImportsManager` instance for (re)loading classes and config + * + * @param {Object} core reference to the global core object + * @param {String} base executing directory name; __dirname + */ + constructor (core, base) { + this._core = core; + this._base = base; + + this._imports = {}; + this._optionalConfigs = {}; + } + + /** + * Pull core reference + * + * @type {Object} readonly + */ + get core () { + return this._core; + } + + /** + * Pull base path that all imports are required in from + * + * @type {String} readonly + */ + get base () { + return this._base; + } + + /** + * Pull optional (none-core) config options + * + * @type {Object} + */ + get optionalConfigs () { + return Object.assign({}, this._optionalConfigs); + } + + /** + * Initialize this class and start loading target directories + * + */ + init () { + let errorText = ''; + ImportsManager.load_dirs.forEach(dir => { + errorText += this.loadDir(dir); + }); + + return errorText; + } + + /** + * Gather all js files from target directory, then verify and load + * + * @param {String} dirName The name of the dir to load, relative to the _base path. + */ + loadDir (dirName) { + const dir = path.resolve(this._base, dirName); + + let errorText = ''; + try { + read.fileSync(dir).forEach(file => { + const basename = path.basename(file); + if (basename.startsWith('_') || !basename.endsWith('.js')) return; + + let imported; + try { + imported = require(file); + } catch (e) { + let err = `Unable to load modules from ${dirName} (${path.relative(dir, file)})\n${e}`; + errorText += err; + console.error(err); + return errorText; + } + + if (imported.configs) { + imported.configs.forEach(config => { + this._optionalConfigs[config.name] = config; + }); + } + + if (!this._imports[dirName]) { + this._imports[dirName] = {}; + } + + this._imports[dirName][file] = imported; + }); + } catch (e) { + let err = `Unable to load modules from ${dirName}\n${e}`; + errorText += err; + console.error(err); + return errorText; + } + + return errorText; + } + + /** + * Unlink references to each loaded module, pray to google that gc knows it's job, + * then reinitialize this class to start the reload + * + * @param {String} dirName The name of the dir to load, relative to the _base path. + */ + reloadDirCache (dirName) { + Object.keys(this._imports[dirName]).forEach((mod) => { + delete require.cache[require.resolve(mod)]; + }); + + return this.init(); + } + + /** + * Pull reference to imported modules that were imported from dirName, or + * load required directory if not found + * + * @param {String} dirName The name of the dir to load, relative to the _base path. + */ + getImport (dirName) { + let imported = this._imports[dirName]; + + if (!imported) { + this.loadDir(dirName); + } + + return Object.assign({}, this._imports[dirName]); + } +} + +// automagically loaded directorys on instantiation +ImportsManager.load_dirs = ['src/commands']; + +module.exports = ImportsManager; diff --git a/server/managers/index.js b/server/managers/index.js new file mode 100644 index 0000000..2fac8fb --- /dev/null +++ b/server/managers/index.js @@ -0,0 +1,6 @@ +module.exports = { + CommandManager: require('./commands'), + Config: require('./config'), + ImportsManager: require('./imports-manager'), + Stats: require('./stats') +}; diff --git a/server/managers/stats.js b/server/managers/stats.js new file mode 100644 index 0000000..20f1ae3 --- /dev/null +++ b/server/managers/stats.js @@ -0,0 +1,59 @@ +/** + * Simple generic stats collection script for events occurances (etc) + * + * Version: v2.0.0 + * Developer: Marzavec ( https://github.com/marzavec ) + * License: WTFPL ( http://www.wtfpl.net/txt/copying/ ) + * + */ + +class Stats { + /** + * Create a stats instance. + * + */ + constructor () { + this._stats = {}; + } + + /** + * Retrieve value of arbitrary `key` reference + * + * @param {String} key Reference to the arbitrary store name + */ + get (key) { + return this._stats[key]; + } + + /** + * Set value of arbitrary `key` reference + * + * @param {String} key Reference to the arbitrary store name + * @param {Number} value New value for `key` + */ + set (key, value) { + this._stats[key] = value; + } + + /** + * Increase value of arbitrary `key` reference, by 1 or `amount` + * + * @param {String} key Reference to the arbitrary store name + * @param {Number} amount Value to increase `key` by, or 1 if omitted + */ + increment (key, amount) { + this.set(key, (this.get(key) || 0) + (amount || 1)); + } + + /** + * Reduce value of arbitrary `key` reference, by 1 or `amount` + * + * @param {String} key Reference to the arbitrary store name + * @param {Number} amount Value to decrease `key` by, or 1 if omitted + */ + decrement (key, amount) { + this.set(key, (this.get(key) || 0) - (amount || 1)); + } +} + +module.exports = Stats; diff --git a/server/package-lock.json b/server/package-lock.json deleted file mode 100644 index c17f028..0000000 --- a/server/package-lock.json +++ /dev/null @@ -1,2815 +0,0 @@ -{ - "name": "hack.chat-v2", - "version": "2.0.1", - "lockfileVersion": 1, - "requires": true, - "dependencies": { - "amp": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/amp/-/amp-0.3.1.tgz", - "integrity": "sha1-at+NWKdPNh6CwfqNOJwHnhOfxH0=", - "dev": true - }, - "amp-message": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/amp-message/-/amp-message-0.1.2.tgz", - "integrity": "sha1-p48cmJlQh602GSpBKY5NtJ49/EU=", - "dev": true, - "requires": { - "amp": "0.3.1" - } - }, - "ansi-regex": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "dev": true - }, - "ansi-styles": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "requires": { - "color-convert": "1.9.1" - } - }, - "anymatch": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-2.0.0.tgz", - "integrity": "sha512-5teOsQWABXHHBFP9y3skS5P3d/WfWXpv3FUpy+LorMrNYaT9pI4oLMQX7jzQ2KklNpGpWHzdCXTDT2Y3XGlZBw==", - "dev": true, - "requires": { - "micromatch": "3.1.10", - "normalize-path": "2.1.1" - } - }, - "argparse": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", - "dev": true, - "requires": { - "sprintf-js": "1.0.3" - }, - "dependencies": { - "sprintf-js": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", - "dev": true - } - } - }, - "arr-diff": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", - "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=", - "dev": true - }, - "arr-flatten": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", - "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", - "dev": true - }, - "arr-union": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz", - "integrity": "sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ=", - "dev": true - }, - "array-unique": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", - "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", - "dev": true - }, - "assign-symbols": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz", - "integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=", - "dev": true - }, - "async": { - "version": "0.9.2", - "resolved": "https://registry.npmjs.org/async/-/async-0.9.2.tgz", - "integrity": "sha1-rqdNXmHB+JlhO/ZL2mbUx48v0X0=" - }, - "async-each": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/async-each/-/async-each-1.0.1.tgz", - "integrity": "sha1-GdOGodntxufByF04iu28xW0zYC0=", - "dev": true - }, - "async-limiter": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.0.tgz", - "integrity": "sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg==" - }, - "async-listener": { - "version": "0.6.9", - "resolved": "https://registry.npmjs.org/async-listener/-/async-listener-0.6.9.tgz", - "integrity": "sha512-E7Z2/QMs0EPt/o9wpYO/J3hmMCDdr1aVDS3ttlur5D5JlZtxhfuOwi4e7S8zbYIxA5qOOYdxfqGj97XAfdNvkQ==", - "dev": true, - "requires": { - "semver": "5.5.0", - "shimmer": "1.2.0" - } - }, - "atob": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.1.tgz", - "integrity": "sha1-ri1acpR38onWDdf5amMUoi3Wwio=", - "dev": true - }, - "babel-runtime": { - "version": "6.26.0", - "resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz", - "integrity": "sha1-llxwWGaOgrVde/4E/yM3vItWR/4=", - "requires": { - "core-js": "2.5.3", - "regenerator-runtime": "0.11.1" - } - }, - "balanced-match": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" - }, - "base": { - "version": "0.11.2", - "resolved": "https://registry.npmjs.org/base/-/base-0.11.2.tgz", - "integrity": "sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg==", - "dev": true, - "requires": { - "cache-base": "1.0.1", - "class-utils": "0.3.6", - "component-emitter": "1.2.1", - "define-property": "1.0.0", - "isobject": "3.0.1", - "mixin-deep": "1.3.1", - "pascalcase": "0.1.1" - }, - "dependencies": { - "define-property": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", - "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", - "dev": true, - "requires": { - "is-descriptor": "1.0.2" - } - }, - "is-accessor-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", - "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "dev": true, - "requires": { - "kind-of": "6.0.2" - } - }, - "is-data-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", - "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "dev": true, - "requires": { - "kind-of": "6.0.2" - } - }, - "is-descriptor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", - "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "dev": true, - "requires": { - "is-accessor-descriptor": "1.0.0", - "is-data-descriptor": "1.0.0", - "kind-of": "6.0.2" - } - } - } - }, - "binary-extensions": { - "version": "1.11.0", - "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.11.0.tgz", - "integrity": "sha1-RqoXUftqL5PuXmibsQh9SxTGwgU=", - "dev": true - }, - "bindings": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.2.1.tgz", - "integrity": "sha1-FK1hE4EtLTfXLme0ystLtyZQXxE=" - }, - "blessed": { - "version": "0.1.81", - "resolved": "https://registry.npmjs.org/blessed/-/blessed-0.1.81.tgz", - "integrity": "sha1-+WLWh+wsNpVwrnGvhDJW5tDKESk=", - "dev": true - }, - "brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "requires": { - "balanced-match": "1.0.0", - "concat-map": "0.0.1" - } - }, - "braces": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz", - "integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==", - "dev": true, - "requires": { - "arr-flatten": "1.1.0", - "array-unique": "0.3.2", - "extend-shallow": "2.0.1", - "fill-range": "4.0.0", - "isobject": "3.0.1", - "repeat-element": "1.1.2", - "snapdragon": "0.8.2", - "snapdragon-node": "2.1.1", - "split-string": "3.1.0", - "to-regex": "3.0.2" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "0.1.1" - } - } - } - }, - "buffer-from": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.0.0.tgz", - "integrity": "sha512-83apNb8KK0Se60UE1+4Ukbe3HbfELJ6UlI4ldtOGs7So4KD26orJM8hIY9lxdzP+UpItH1Yh/Y8GUvNFWFFRxA==", - "dev": true - }, - "cache-base": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz", - "integrity": "sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ==", - "dev": true, - "requires": { - "collection-visit": "1.0.0", - "component-emitter": "1.2.1", - "get-value": "2.0.6", - "has-value": "1.0.0", - "isobject": "3.0.1", - "set-value": "2.0.0", - "to-object-path": "0.3.0", - "union-value": "1.0.0", - "unset-value": "1.0.0" - } - }, - "chalk": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.2.tgz", - "integrity": "sha512-ZM4j2/ld/YZDc3Ma8PgN7gyAk+kHMMMyzLNryCPGhWrsfAuDVeuid5bpRFTDgMH9JBK2lA4dyyAkkZYF/WcqDQ==", - "requires": { - "ansi-styles": "3.2.1", - "escape-string-regexp": "1.0.5", - "supports-color": "5.3.0" - } - }, - "charm": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/charm/-/charm-0.1.2.tgz", - "integrity": "sha1-BsIe7RobBq62dVPNxT4jJ0usIpY=", - "dev": true - }, - "chokidar": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.0.3.tgz", - "integrity": "sha512-zW8iXYZtXMx4kux/nuZVXjkLP+CyIK5Al5FHnj1OgTKGZfp4Oy6/ymtMSKFv3GD8DviEmUPmJg9eFdJ/JzudMg==", - "dev": true, - "requires": { - "anymatch": "2.0.0", - "async-each": "1.0.1", - "braces": "2.3.2", - "fsevents": "1.2.3", - "glob-parent": "3.1.0", - "inherits": "2.0.3", - "is-binary-path": "1.0.1", - "is-glob": "4.0.0", - "normalize-path": "2.1.1", - "path-is-absolute": "1.0.1", - "readdirp": "2.1.0", - "upath": "1.0.5" - } - }, - "class-utils": { - "version": "0.3.6", - "resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz", - "integrity": "sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg==", - "dev": true, - "requires": { - "arr-union": "3.1.0", - "define-property": "0.2.5", - "isobject": "3.0.1", - "static-extend": "0.1.2" - }, - "dependencies": { - "define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, - "requires": { - "is-descriptor": "0.1.6" - } - } - } - }, - "cli-table-redemption": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/cli-table-redemption/-/cli-table-redemption-1.0.1.tgz", - "integrity": "sha512-SjVCciRyx01I4azo2K2rcc0NP/wOceXGzG1ZpYkEulbbIxDA/5YWv0oxG2HtQ4v8zPC6bgbRI7SbNaTZCxMNkg==", - "dev": true, - "requires": { - "chalk": "1.1.3" - }, - "dependencies": { - "ansi-styles": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", - "dev": true - }, - "chalk": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", - "dev": true, - "requires": { - "ansi-styles": "2.2.1", - "escape-string-regexp": "1.0.5", - "has-ansi": "2.0.0", - "strip-ansi": "3.0.1", - "supports-color": "2.0.0" - } - }, - "supports-color": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", - "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", - "dev": true - } - } - }, - "collection-visit": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/collection-visit/-/collection-visit-1.0.0.tgz", - "integrity": "sha1-S8A3PBZLwykbTTaMgpzxqApZ3KA=", - "dev": true, - "requires": { - "map-visit": "1.0.0", - "object-visit": "1.0.1" - } - }, - "color-convert": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", - "integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==", - "requires": { - "color-name": "1.1.3" - } - }, - "color-name": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" - }, - "colors": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/colors/-/colors-1.1.2.tgz", - "integrity": "sha1-FopHAXVran9RoSzgyXv6KMCE7WM=" - }, - "commander": { - "version": "2.13.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.13.0.tgz", - "integrity": "sha512-MVuS359B+YzaWqjCL/c+22gfryv+mCBPHAv3zyVI2GN8EY6IRP8VwtasXn8jyyhvvq84R4ImN1OKRtcbIasjYA==", - "dev": true - }, - "common-tags": { - "version": "1.7.2", - "resolved": "https://registry.npmjs.org/common-tags/-/common-tags-1.7.2.tgz", - "integrity": "sha512-joj9ZlUOjCrwdbmiLqafeUSgkUM74NqhLsZtSqDmhKudaIY197zTrb8JMl31fMnCUuxwFT23eC/oWvrZzDLRJQ==", - "requires": { - "babel-runtime": "6.26.0" - } - }, - "component-emitter": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz", - "integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY=", - "dev": true - }, - "concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" - }, - "continuation-local-storage": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/continuation-local-storage/-/continuation-local-storage-3.2.1.tgz", - "integrity": "sha512-jx44cconVqkCEEyLSKWwkvUXwO561jXMa3LPjTPsm5QR22PA0/mhe33FT4Xb5y74JDvt/Cq+5lm8S8rskLv9ZA==", - "dev": true, - "requires": { - "async-listener": "0.6.9", - "emitter-listener": "1.1.1" - } - }, - "copy-descriptor": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz", - "integrity": "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=", - "dev": true - }, - "core-js": { - "version": "2.5.3", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.5.3.tgz", - "integrity": "sha1-isw4NFgk8W2DZbfJtCWRaOjtYD4=" - }, - "core-util-is": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", - "dev": true - }, - "cron": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/cron/-/cron-1.3.0.tgz", - "integrity": "sha512-K/SF7JlgMmNjcThWxkKvsHhey2EDB4CeOEWJ9aXWj3fbQJppsvTPIeyLdHfNq5IbbsMUUjRW1nr5dSO95f2E4w==", - "dev": true, - "requires": { - "moment-timezone": "0.5.16" - } - }, - "cycle": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/cycle/-/cycle-1.0.3.tgz", - "integrity": "sha1-IegLK+hYD5i0aPN5QwZisEbDStI=" - }, - "dateformat": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-3.0.3.tgz", - "integrity": "sha512-jyCETtSl3VMZMWeRo7iY1FL19ges1t55hMo5yaam4Jrsm5EPL89UQkoQRyiI+Yf4k8r2ZpdngkV8hr1lIdjb3Q==" - }, - "deasync": { - "version": "0.1.12", - "resolved": "https://registry.npmjs.org/deasync/-/deasync-0.1.12.tgz", - "integrity": "sha512-gpacYo8FBZh3INBp2KOtrQp9kCO5faHvOmEZx3/cZTr3Mm8/kAYs7/Ws3E3OAH0ApBNK6Y6N+7+Dka2Zn2Fldw==", - "requires": { - "bindings": "1.2.1", - "nan": "2.9.2" - } - }, - "debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - }, - "decode-uri-component": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz", - "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=", - "dev": true - }, - "deep-equal": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-0.2.2.tgz", - "integrity": "sha1-hLdFiW80xoTpjyzg5Cq69Du6AX0=" - }, - "deep-metrics": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/deep-metrics/-/deep-metrics-0.0.1.tgz", - "integrity": "sha512-732WmZgCWxOkf4QBvrCjPPuT6wTEzaGye/4JqYsU/sO0J53UNX4PBwK0JV262BZ5cxgLmKhU+NlrtKdPDgybkg==", - "dev": true, - "requires": { - "semver": "5.5.0" - } - }, - "define-property": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-2.0.2.tgz", - "integrity": "sha512-jwK2UV4cnPpbcG7+VRARKTZPUWowwXA8bzH5NP6ud0oeAxyYPuGZUAC7hMugpCdz4BeSZl2Dl9k66CHJ/46ZYQ==", - "dev": true, - "requires": { - "is-descriptor": "1.0.2", - "isobject": "3.0.1" - }, - "dependencies": { - "is-accessor-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", - "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "dev": true, - "requires": { - "kind-of": "6.0.2" - } - }, - "is-data-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", - "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "dev": true, - "requires": { - "kind-of": "6.0.2" - } - }, - "is-descriptor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", - "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "dev": true, - "requires": { - "is-accessor-descriptor": "1.0.0", - "is-data-descriptor": "1.0.0", - "kind-of": "6.0.2" - } - } - } - }, - "didyoumean2": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/didyoumean2/-/didyoumean2-1.3.0.tgz", - "integrity": "sha1-bjT0AUM1HJIGlulyO7oB/8C5ZAI=", - "requires": { - "leven": "2.1.0", - "lodash": "4.17.5" - } - }, - "emitter-listener": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/emitter-listener/-/emitter-listener-1.1.1.tgz", - "integrity": "sha1-6Lu+gkS8jg0LTvcc0UKUx/JBx+w=", - "dev": true, - "requires": { - "shimmer": "1.2.0" - } - }, - "escape-regexp": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/escape-regexp/-/escape-regexp-0.0.1.tgz", - "integrity": "sha1-9EvaEtRbvfnLf4Yu5+SCez3TIlQ=", - "dev": true - }, - "escape-string-regexp": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" - }, - "eventemitter2": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/eventemitter2/-/eventemitter2-1.0.5.tgz", - "integrity": "sha1-+YNhBRexc3wLncZDvsqTiTwE3xg=", - "dev": true - }, - "expand-brackets": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", - "integrity": "sha1-t3c14xXOMPa27/D4OwQVGiJEliI=", - "dev": true, - "requires": { - "debug": "2.6.9", - "define-property": "0.2.5", - "extend-shallow": "2.0.1", - "posix-character-classes": "0.1.1", - "regex-not": "1.0.2", - "snapdragon": "0.8.2", - "to-regex": "3.0.2" - }, - "dependencies": { - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - }, - "define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, - "requires": { - "is-descriptor": "0.1.6" - } - }, - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "0.1.1" - } - } - } - }, - "extend": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.1.tgz", - "integrity": "sha1-p1Xqe8Gt/MWjHOfnYtuq3F5jZEQ=", - "dev": true - }, - "extend-shallow": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", - "integrity": "sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg=", - "dev": true, - "requires": { - "assign-symbols": "1.0.0", - "is-extendable": "1.0.1" - }, - "dependencies": { - "is-extendable": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", - "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", - "dev": true, - "requires": { - "is-plain-object": "2.0.4" - } - } - } - }, - "extglob": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/extglob/-/extglob-2.0.4.tgz", - "integrity": "sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw==", - "dev": true, - "requires": { - "array-unique": "0.3.2", - "define-property": "1.0.0", - "expand-brackets": "2.1.4", - "extend-shallow": "2.0.1", - "fragment-cache": "0.2.1", - "regex-not": "1.0.2", - "snapdragon": "0.8.2", - "to-regex": "3.0.2" - }, - "dependencies": { - "define-property": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", - "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", - "dev": true, - "requires": { - "is-descriptor": "1.0.2" - } - }, - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "0.1.1" - } - }, - "is-accessor-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", - "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "dev": true, - "requires": { - "kind-of": "6.0.2" - } - }, - "is-data-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", - "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "dev": true, - "requires": { - "kind-of": "6.0.2" - } - }, - "is-descriptor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", - "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "dev": true, - "requires": { - "is-accessor-descriptor": "1.0.0", - "is-data-descriptor": "1.0.0", - "kind-of": "6.0.2" - } - } - } - }, - "eyes": { - "version": "0.1.8", - "resolved": "https://registry.npmjs.org/eyes/-/eyes-0.1.8.tgz", - "integrity": "sha1-Ys8SAjTGg3hdkCNIqADvPgzCC8A=" - }, - "fclone": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/fclone/-/fclone-1.0.11.tgz", - "integrity": "sha1-EOhdo4v+p/xZk0HClu4ddyZu5kA=", - "dev": true - }, - "fill-range": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", - "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=", - "dev": true, - "requires": { - "extend-shallow": "2.0.1", - "is-number": "3.0.0", - "repeat-string": "1.6.1", - "to-regex-range": "2.1.1" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "0.1.1" - } - } - } - }, - "for-in": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", - "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=", - "dev": true - }, - "fragment-cache": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz", - "integrity": "sha1-QpD60n8T6Jvn8zeZxrxaCr//DRk=", - "dev": true, - "requires": { - "map-cache": "0.2.2" - } - }, - "fs-extra": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-5.0.0.tgz", - "integrity": "sha512-66Pm4RYbjzdyeuqudYqhFiNBbCIuI9kgRqLPSHIlXHidW8NIQtVdkM1yeZ4lXwuhbTETv3EUGMNHAAw6hiundQ==", - "requires": { - "graceful-fs": "4.1.11", - "jsonfile": "4.0.0", - "universalify": "0.1.1" - } - }, - "fs.realpath": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" - }, - "fsevents": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.3.tgz", - "integrity": "sha512-X+57O5YkDTiEQGiw8i7wYc2nQgweIekqkepI8Q3y4wVlurgBt2SuwxTeYUYMZIGpLZH3r/TsMjczCMXE5ZOt7Q==", - "dev": true, - "optional": true, - "requires": { - "nan": "2.9.2", - "node-pre-gyp": "0.9.1" - }, - "dependencies": { - "abbrev": { - "version": "1.1.1", - "bundled": true, - "dev": true, - "optional": true - }, - "ansi-regex": { - "version": "2.1.1", - "bundled": true, - "dev": true - }, - "aproba": { - "version": "1.2.0", - "bundled": true, - "dev": true, - "optional": true - }, - "are-we-there-yet": { - "version": "1.1.4", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "delegates": "1.0.0", - "readable-stream": "2.3.6" - } - }, - "balanced-match": { - "version": "1.0.0", - "bundled": true, - "dev": true - }, - "brace-expansion": { - "version": "1.1.11", - "bundled": true, - "dev": true, - "requires": { - "balanced-match": "1.0.0", - "concat-map": "0.0.1" - } - }, - "chownr": { - "version": "1.0.1", - "bundled": true, - "dev": true, - "optional": true - }, - "code-point-at": { - "version": "1.1.0", - "bundled": true, - "dev": true - }, - "concat-map": { - "version": "0.0.1", - "bundled": true, - "dev": true - }, - "console-control-strings": { - "version": "1.1.0", - "bundled": true, - "dev": true - }, - "core-util-is": { - "version": "1.0.2", - "bundled": true, - "dev": true, - "optional": true - }, - "debug": { - "version": "2.6.9", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "ms": "2.0.0" - } - }, - "deep-extend": { - "version": "0.4.2", - "bundled": true, - "dev": true, - "optional": true - }, - "delegates": { - "version": "1.0.0", - "bundled": true, - "dev": true, - "optional": true - }, - "detect-libc": { - "version": "1.0.3", - "bundled": true, - "dev": true, - "optional": true - }, - "fs-minipass": { - "version": "1.2.5", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "minipass": "2.2.4" - } - }, - "fs.realpath": { - "version": "1.0.0", - "bundled": true, - "dev": true, - "optional": true - }, - "gauge": { - "version": "2.7.4", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "aproba": "1.2.0", - "console-control-strings": "1.1.0", - "has-unicode": "2.0.1", - "object-assign": "4.1.1", - "signal-exit": "3.0.2", - "string-width": "1.0.2", - "strip-ansi": "3.0.1", - "wide-align": "1.1.2" - } - }, - "glob": { - "version": "7.1.2", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "fs.realpath": "1.0.0", - "inflight": "1.0.6", - "inherits": "2.0.3", - "minimatch": "3.0.4", - "once": "1.4.0", - "path-is-absolute": "1.0.1" - } - }, - "has-unicode": { - "version": "2.0.1", - "bundled": true, - "dev": true, - "optional": true - }, - "iconv-lite": { - "version": "0.4.21", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "safer-buffer": "2.1.2" - } - }, - "ignore-walk": { - "version": "3.0.1", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "minimatch": "3.0.4" - } - }, - "inflight": { - "version": "1.0.6", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "once": "1.4.0", - "wrappy": "1.0.2" - } - }, - "inherits": { - "version": "2.0.3", - "bundled": true, - "dev": true - }, - "ini": { - "version": "1.3.5", - "bundled": true, - "dev": true, - "optional": true - }, - "is-fullwidth-code-point": { - "version": "1.0.0", - "bundled": true, - "dev": true, - "requires": { - "number-is-nan": "1.0.1" - } - }, - "isarray": { - "version": "1.0.0", - "bundled": true, - "dev": true, - "optional": true - }, - "minimatch": { - "version": "3.0.4", - "bundled": true, - "dev": true, - "requires": { - "brace-expansion": "1.1.11" - } - }, - "minimist": { - "version": "0.0.8", - "bundled": true, - "dev": true - }, - "minipass": { - "version": "2.2.4", - "bundled": true, - "dev": true, - "requires": { - "safe-buffer": "5.1.1", - "yallist": "3.0.2" - } - }, - "minizlib": { - "version": "1.1.0", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "minipass": "2.2.4" - } - }, - "mkdirp": { - "version": "0.5.1", - "bundled": true, - "dev": true, - "requires": { - "minimist": "0.0.8" - } - }, - "ms": { - "version": "2.0.0", - "bundled": true, - "dev": true, - "optional": true - }, - "needle": { - "version": "2.2.0", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "debug": "2.6.9", - "iconv-lite": "0.4.21", - "sax": "1.2.4" - } - }, - "node-pre-gyp": { - "version": "0.9.1", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "detect-libc": "1.0.3", - "mkdirp": "0.5.1", - "needle": "2.2.0", - "nopt": "4.0.1", - "npm-packlist": "1.1.10", - "npmlog": "4.1.2", - "rc": "1.2.6", - "rimraf": "2.6.2", - "semver": "5.5.0", - "tar": "4.4.1" - } - }, - "nopt": { - "version": "4.0.1", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "abbrev": "1.1.1", - "osenv": "0.1.5" - } - }, - "npm-bundled": { - "version": "1.0.3", - "bundled": true, - "dev": true, - "optional": true - }, - "npm-packlist": { - "version": "1.1.10", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "ignore-walk": "3.0.1", - "npm-bundled": "1.0.3" - } - }, - "npmlog": { - "version": "4.1.2", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "are-we-there-yet": "1.1.4", - "console-control-strings": "1.1.0", - "gauge": "2.7.4", - "set-blocking": "2.0.0" - } - }, - "number-is-nan": { - "version": "1.0.1", - "bundled": true, - "dev": true - }, - "object-assign": { - "version": "4.1.1", - "bundled": true, - "dev": true, - "optional": true - }, - "once": { - "version": "1.4.0", - "bundled": true, - "dev": true, - "requires": { - "wrappy": "1.0.2" - } - }, - "os-homedir": { - "version": "1.0.2", - "bundled": true, - "dev": true, - "optional": true - }, - "os-tmpdir": { - "version": "1.0.2", - "bundled": true, - "dev": true, - "optional": true - }, - "osenv": { - "version": "0.1.5", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "os-homedir": "1.0.2", - "os-tmpdir": "1.0.2" - } - }, - "path-is-absolute": { - "version": "1.0.1", - "bundled": true, - "dev": true, - "optional": true - }, - "process-nextick-args": { - "version": "2.0.0", - "bundled": true, - "dev": true, - "optional": true - }, - "rc": { - "version": "1.2.6", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "deep-extend": "0.4.2", - "ini": "1.3.5", - "minimist": "1.2.0", - "strip-json-comments": "2.0.1" - }, - "dependencies": { - "minimist": { - "version": "1.2.0", - "bundled": true, - "dev": true, - "optional": true - } - } - }, - "readable-stream": { - "version": "2.3.6", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", - "isarray": "1.0.0", - "process-nextick-args": "2.0.0", - "safe-buffer": "5.1.1", - "string_decoder": "1.1.1", - "util-deprecate": "1.0.2" - } - }, - "rimraf": { - "version": "2.6.2", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "glob": "7.1.2" - } - }, - "safe-buffer": { - "version": "5.1.1", - "bundled": true, - "dev": true - }, - "safer-buffer": { - "version": "2.1.2", - "bundled": true, - "dev": true, - "optional": true - }, - "sax": { - "version": "1.2.4", - "bundled": true, - "dev": true, - "optional": true - }, - "semver": { - "version": "5.5.0", - "bundled": true, - "dev": true, - "optional": true - }, - "set-blocking": { - "version": "2.0.0", - "bundled": true, - "dev": true, - "optional": true - }, - "signal-exit": { - "version": "3.0.2", - "bundled": true, - "dev": true, - "optional": true - }, - "string-width": { - "version": "1.0.2", - "bundled": true, - "dev": true, - "requires": { - "code-point-at": "1.1.0", - "is-fullwidth-code-point": "1.0.0", - "strip-ansi": "3.0.1" - } - }, - "string_decoder": { - "version": "1.1.1", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "safe-buffer": "5.1.1" - } - }, - "strip-ansi": { - "version": "3.0.1", - "bundled": true, - "dev": true, - "requires": { - "ansi-regex": "2.1.1" - } - }, - "strip-json-comments": { - "version": "2.0.1", - "bundled": true, - "dev": true, - "optional": true - }, - "tar": { - "version": "4.4.1", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "chownr": "1.0.1", - "fs-minipass": "1.2.5", - "minipass": "2.2.4", - "minizlib": "1.1.0", - "mkdirp": "0.5.1", - "safe-buffer": "5.1.1", - "yallist": "3.0.2" - } - }, - "util-deprecate": { - "version": "1.0.2", - "bundled": true, - "dev": true, - "optional": true - }, - "wide-align": { - "version": "1.1.2", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "string-width": "1.0.2" - } - }, - "wrappy": { - "version": "1.0.2", - "bundled": true, - "dev": true - }, - "yallist": { - "version": "3.0.2", - "bundled": true, - "dev": true - } - } - }, - "get-value": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/get-value/-/get-value-2.0.6.tgz", - "integrity": "sha1-3BXKHGcjh8p2vTesCjlbogQqLCg=", - "dev": true - }, - "gkt": { - "version": "https://tgz.pm2.io/gkt-1.0.0.tgz", - "integrity": "sha512-zr6QQnzLt3Ja0t0XI8gws2kn7zV2p0l/D3kreNvS6hFZhVU5g+uY/30l42jbgt0XGcNBEmBDGJR71J692V92tA==", - "dev": true, - "optional": true - }, - "glob": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", - "requires": { - "fs.realpath": "1.0.0", - "inflight": "1.0.6", - "inherits": "2.0.3", - "minimatch": "3.0.4", - "once": "1.4.0", - "path-is-absolute": "1.0.1" - } - }, - "glob-parent": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", - "integrity": "sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4=", - "dev": true, - "requires": { - "is-glob": "3.1.0", - "path-dirname": "1.0.2" - }, - "dependencies": { - "is-glob": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz", - "integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=", - "dev": true, - "requires": { - "is-extglob": "2.1.1" - } - } - } - }, - "graceful-fs": { - "version": "4.1.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", - "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=" - }, - "has-ansi": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", - "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", - "dev": true, - "requires": { - "ansi-regex": "2.1.1" - } - }, - "has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=" - }, - "has-value": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/has-value/-/has-value-1.0.0.tgz", - "integrity": "sha1-GLKB2lhbHFxR3vJMkw7SmgvmsXc=", - "dev": true, - "requires": { - "get-value": "2.0.6", - "has-values": "1.0.0", - "isobject": "3.0.1" - } - }, - "has-values": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/has-values/-/has-values-1.0.0.tgz", - "integrity": "sha1-lbC2P+whRmGab+V/51Yo1aOe/k8=", - "dev": true, - "requires": { - "is-number": "3.0.0", - "kind-of": "4.0.0" - }, - "dependencies": { - "kind-of": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-4.0.0.tgz", - "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=", - "dev": true, - "requires": { - "is-buffer": "1.1.6" - } - } - } - }, - "i": { - "version": "0.3.6", - "resolved": "https://registry.npmjs.org/i/-/i-0.3.6.tgz", - "integrity": "sha1-2WyScyB28HJxG2sQ/X1PZa2O4j0=" - }, - "iconv-lite": { - "version": "0.4.23", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.23.tgz", - "integrity": "sha512-neyTUVFtahjf0mB3dZT77u+8O0QB89jFdnBkd5P1JgYPbPaia3gXXOVL2fq8VyU2gMMD7SaN7QukTB/pmXYvDA==", - "dev": true, - "requires": { - "safer-buffer": "2.1.2" - } - }, - "inflight": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", - "requires": { - "once": "1.4.0", - "wrappy": "1.0.2" - } - }, - "inherits": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" - }, - "interpret": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.1.0.tgz", - "integrity": "sha1-ftGxQQxqDg94z5XTuEQMY/eLhhQ=", - "dev": true - }, - "is": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/is/-/is-3.2.1.tgz", - "integrity": "sha1-0Kwq1V63sL7JJqUmb2xmKqqD3KU=", - "dev": true - }, - "is-accessor-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", - "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", - "dev": true, - "requires": { - "kind-of": "3.2.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "1.1.6" - } - } - } - }, - "is-binary-path": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-1.0.1.tgz", - "integrity": "sha1-dfFmQrSA8YenEcgUFh/TpKdlWJg=", - "dev": true, - "requires": { - "binary-extensions": "1.11.0" - } - }, - "is-buffer": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", - "dev": true - }, - "is-data-descriptor": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", - "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", - "dev": true, - "requires": { - "kind-of": "3.2.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "1.1.6" - } - } - } - }, - "is-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", - "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", - "dev": true, - "requires": { - "is-accessor-descriptor": "0.1.6", - "is-data-descriptor": "0.1.4", - "kind-of": "5.1.0" - }, - "dependencies": { - "kind-of": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", - "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", - "dev": true - } - } - }, - "is-extendable": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", - "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=", - "dev": true - }, - "is-extglob": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", - "dev": true - }, - "is-glob": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.0.tgz", - "integrity": "sha1-lSHHaEXMJhCoUgPd8ICpWML/q8A=", - "dev": true, - "requires": { - "is-extglob": "2.1.1" - } - }, - "is-number": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", - "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", - "dev": true, - "requires": { - "kind-of": "3.2.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "1.1.6" - } - } - } - }, - "is-odd": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-odd/-/is-odd-2.0.0.tgz", - "integrity": "sha512-OTiixgpZAT1M4NHgS5IguFp/Vz2VI3U7Goh4/HA1adtwyLtSBrxYlcSYkhpAE07s4fKEcjrFxyvtQBND4vFQyQ==", - "dev": true, - "requires": { - "is-number": "4.0.0" - }, - "dependencies": { - "is-number": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-4.0.0.tgz", - "integrity": "sha512-rSklcAIlf1OmFdyAqbnWTLVelsQ58uvZ66S/ZyawjWqIviTWCjg2PzVGw8WUA+nNuPTqb4wgA+NszrJ+08LlgQ==", - "dev": true - } - } - }, - "is-plain-object": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", - "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==", - "dev": true, - "requires": { - "isobject": "3.0.1" - } - }, - "is-windows": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", - "integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==", - "dev": true - }, - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true - }, - "isobject": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true - }, - "isstream": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", - "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=" - }, - "json-stringify-safe": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", - "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=", - "dev": true - }, - "jsonfile": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", - "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", - "requires": { - "graceful-fs": "4.1.11" - } - }, - "kind-of": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", - "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", - "dev": true - }, - "lazy": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/lazy/-/lazy-1.0.11.tgz", - "integrity": "sha1-2qBoIGKCVCwIgojpdcKXwa53tpA=", - "dev": true - }, - "leven": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/leven/-/leven-2.1.0.tgz", - "integrity": "sha1-wuep93IJTe6dNCAq6KzORoeHVYA=" - }, - "lodash": { - "version": "4.17.5", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.5.tgz", - "integrity": "sha512-svL3uiZf1RwhH+cWrfZn3A4+U58wbP0tGVTLQPbjplZxZ8ROD9VLuNgsRniTlLe7OlSqR79RUehXgpBW/s0IQw==" - }, - "lodash.findindex": { - "version": "4.6.0", - "resolved": "https://registry.npmjs.org/lodash.findindex/-/lodash.findindex-4.6.0.tgz", - "integrity": "sha1-oyRd7mH7m24GJLU1ElYku2nBEQY=", - "dev": true - }, - "lodash.isequal": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz", - "integrity": "sha1-QVxEePK8wwEgwizhDtMib30+GOA=", - "dev": true - }, - "lodash.merge": { - "version": "4.6.1", - "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.1.tgz", - "integrity": "sha512-AOYza4+Hf5z1/0Hztxpm2/xiPZgi/cjMqdnKTUWTBSKchJlxXXuUSxCCl8rJlf4g6yww/j6mA8nC8Hw/EZWxKQ==", - "dev": true - }, - "map-cache": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz", - "integrity": "sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8=", - "dev": true - }, - "map-visit": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/map-visit/-/map-visit-1.0.0.tgz", - "integrity": "sha1-7Nyo8TFE5mDxtb1B8S80edmN+48=", - "dev": true, - "requires": { - "object-visit": "1.0.1" - } - }, - "methods": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", - "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=", - "dev": true - }, - "micromatch": { - "version": "3.1.10", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", - "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", - "dev": true, - "requires": { - "arr-diff": "4.0.0", - "array-unique": "0.3.2", - "braces": "2.3.2", - "define-property": "2.0.2", - "extend-shallow": "3.0.2", - "extglob": "2.0.4", - "fragment-cache": "0.2.1", - "kind-of": "6.0.2", - "nanomatch": "1.2.9", - "object.pick": "1.3.0", - "regex-not": "1.0.2", - "snapdragon": "0.8.2", - "to-regex": "3.0.2" - } - }, - "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "requires": { - "brace-expansion": "1.1.11" - } - }, - "minimist": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", - "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" - }, - "mixin-deep": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.1.tgz", - "integrity": "sha512-8ZItLHeEgaqEvd5lYBXfm4EZSFCX29Jb9K+lAHhDKzReKBQKj3R+7NOF6tjqYi9t4oI8VUfaWITJQm86wnXGNQ==", - "dev": true, - "requires": { - "for-in": "1.0.2", - "is-extendable": "1.0.1" - }, - "dependencies": { - "is-extendable": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", - "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", - "dev": true, - "requires": { - "is-plain-object": "2.0.4" - } - } - } - }, - "mkdirp": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", - "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", - "requires": { - "minimist": "0.0.8" - } - }, - "moment": { - "version": "2.22.1", - "resolved": "https://registry.npmjs.org/moment/-/moment-2.22.1.tgz", - "integrity": "sha512-shJkRTSebXvsVqk56I+lkb2latjBs8I+pc2TzWc545y2iFnSjm7Wg0QMh+ZWcdSLQyGEau5jI8ocnmkyTgr9YQ==", - "dev": true - }, - "moment-timezone": { - "version": "0.5.16", - "resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.16.tgz", - "integrity": "sha512-4d1l92plNNqnMkqI/7boWNVXJvwGL2WyByl1Hxp3h/ao3HZiAqaoQY+6KBkYdiN5QtNDpndq+58ozl8W4GVoNw==", - "dev": true, - "requires": { - "moment": "2.22.1" - } - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true - }, - "mute-stream": { - "version": "0.0.7", - "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz", - "integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=" - }, - "nan": { - "version": "2.9.2", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.9.2.tgz", - "integrity": "sha512-ltW65co7f3PQWBDbqVvaU1WtFJUsNW7sWWm4HINhbMQIyVyzIeyZ8toX5TC5eeooE6piZoaEh4cZkueSKG3KYw==" - }, - "nanomatch": { - "version": "1.2.9", - "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.9.tgz", - "integrity": "sha512-n8R9bS8yQ6eSXaV6jHUpKzD8gLsin02w1HSFiegwrs9E098Ylhw5jdyKPaYqvHknHaSCKTPp7C8dGCQ0q9koXA==", - "dev": true, - "requires": { - "arr-diff": "4.0.0", - "array-unique": "0.3.2", - "define-property": "2.0.2", - "extend-shallow": "3.0.2", - "fragment-cache": "0.2.1", - "is-odd": "2.0.0", - "is-windows": "1.0.2", - "kind-of": "6.0.2", - "object.pick": "1.3.0", - "regex-not": "1.0.2", - "snapdragon": "0.8.2", - "to-regex": "3.0.2" - } - }, - "ncp": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/ncp/-/ncp-1.0.1.tgz", - "integrity": "sha1-0VNn5cuHQyuhF9K/gP30Wuz7QkY=" - }, - "needle": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/needle/-/needle-2.2.1.tgz", - "integrity": "sha512-t/ZswCM9JTWjAdXS9VpvqhI2Ct2sL2MdY4fUXqGJaGBk13ge99ObqRksRTbBE56K+wxUXwwfZYOuZHifFW9q+Q==", - "dev": true, - "requires": { - "debug": "2.6.9", - "iconv-lite": "0.4.23", - "sax": "1.2.4" - }, - "dependencies": { - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - } - } - }, - "normalize-path": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", - "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", - "dev": true, - "requires": { - "remove-trailing-separator": "1.1.0" - } - }, - "nssocket": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/nssocket/-/nssocket-0.6.0.tgz", - "integrity": "sha1-Wflvb/MhVm8zxw99vu7N/cBxVPo=", - "dev": true, - "requires": { - "eventemitter2": "0.4.14", - "lazy": "1.0.11" - }, - "dependencies": { - "eventemitter2": { - "version": "0.4.14", - "resolved": "https://registry.npmjs.org/eventemitter2/-/eventemitter2-0.4.14.tgz", - "integrity": "sha1-j2G3XN4BKy6esoTUVFWDtWQ7Yas=", - "dev": true - } - } - }, - "object-copy": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/object-copy/-/object-copy-0.1.0.tgz", - "integrity": "sha1-fn2Fi3gb18mRpBupde04EnVOmYw=", - "dev": true, - "requires": { - "copy-descriptor": "0.1.1", - "define-property": "0.2.5", - "kind-of": "3.2.2" - }, - "dependencies": { - "define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, - "requires": { - "is-descriptor": "0.1.6" - } - }, - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "1.1.6" - } - } - } - }, - "object-visit": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/object-visit/-/object-visit-1.0.1.tgz", - "integrity": "sha1-95xEk68MU3e1n+OdOV5BBC3QRbs=", - "dev": true, - "requires": { - "isobject": "3.0.1" - } - }, - "object.pick": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz", - "integrity": "sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c=", - "dev": true, - "requires": { - "isobject": "3.0.1" - } - }, - "once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "requires": { - "wrappy": "1.0.2" - } - }, - "pascalcase": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz", - "integrity": "sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=", - "dev": true - }, - "path-dirname": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/path-dirname/-/path-dirname-1.0.2.tgz", - "integrity": "sha1-zDPSTVJeCZpTiMAzbG4yuRYGCeA=", - "dev": true - }, - "path-is-absolute": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" - }, - "path-parse": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.5.tgz", - "integrity": "sha1-PBrfhx6pzWyUMbbqK9dKD/BVxME=", - "dev": true - }, - "pidusage": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/pidusage/-/pidusage-1.2.0.tgz", - "integrity": "sha512-OGo+iSOk44HRJ8q15AyG570UYxcm5u+R99DI8Khu8P3tKGkVu5EZX4ywHglWSTMNNXQ274oeGpYrvFEhDIFGPg==", - "dev": true - }, - "pkginfo": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/pkginfo/-/pkginfo-0.4.1.tgz", - "integrity": "sha1-tUGO8EOd5UJfxJlQQtztFPsqhP8=" - }, - "pm2": { - "version": "2.10.3", - "resolved": "https://registry.npmjs.org/pm2/-/pm2-2.10.3.tgz", - "integrity": "sha512-C3fEC4jkr4iR1mUfTdX4CoR9RRe1165MDbGToVm+H7lCuXeh25CgckjrsXHv6QMLFT0hNbQr5m44YYyWotBTAA==", - "dev": true, - "requires": { - "async": "2.6.0", - "blessed": "0.1.81", - "chalk": "1.1.3", - "chokidar": "2.0.3", - "cli-table-redemption": "1.0.1", - "commander": "2.13.0", - "cron": "1.3.0", - "debug": "3.1.0", - "eventemitter2": "1.0.5", - "fclone": "1.0.11", - "gkt": "https://tgz.pm2.io/gkt-1.0.0.tgz", - "mkdirp": "0.5.1", - "moment": "2.22.1", - "needle": "2.2.1", - "nssocket": "0.6.0", - "pidusage": "1.2.0", - "pm2-axon": "3.1.0", - "pm2-axon-rpc": "0.5.1", - "pm2-deploy": "0.3.9", - "pm2-multimeter": "0.1.2", - "pmx": "1.6.4", - "promptly": "2.2.0", - "semver": "5.5.0", - "shelljs": "0.7.8", - "source-map-support": "0.5.5", - "sprintf-js": "1.1.1", - "v8-compile-cache": "1.1.2", - "vizion": "0.2.13", - "yamljs": "0.3.0" - }, - "dependencies": { - "ansi-styles": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", - "dev": true - }, - "async": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/async/-/async-2.6.0.tgz", - "integrity": "sha512-xAfGg1/NTLBBKlHFmnd7PlmUW9KhVQIUuSrYem9xzFUZy13ScvtyGGejaae9iAVRiRq9+Cx7DPFaAAhCpyxyPw==", - "dev": true, - "requires": { - "lodash": "4.17.5" - } - }, - "chalk": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", - "dev": true, - "requires": { - "ansi-styles": "2.2.1", - "escape-string-regexp": "1.0.5", - "has-ansi": "2.0.0", - "strip-ansi": "3.0.1", - "supports-color": "2.0.0" - } - }, - "supports-color": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", - "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", - "dev": true - } - } - }, - "pm2-axon": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/pm2-axon/-/pm2-axon-3.1.0.tgz", - "integrity": "sha512-5sBM+vHw0Cp2K9CJ9ZOYhKtNCCcgQ0eKOyFrSo5Jusbq9FfvuelsMG4WDaxkqosaQbf8N5YfyHhD7eOUcnm5rQ==", - "dev": true, - "requires": { - "amp": "0.3.1", - "amp-message": "0.1.2", - "debug": "3.1.0", - "escape-regexp": "0.0.1" - } - }, - "pm2-axon-rpc": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/pm2-axon-rpc/-/pm2-axon-rpc-0.5.1.tgz", - "integrity": "sha512-hT8gN3/j05895QLXpwg+Ws8PjO4AVID6Uf9StWpud9HB2homjc1KKCcI0vg9BNOt56FmrqKDT1NQgheIz35+sA==", - "dev": true, - "requires": { - "debug": "3.1.0" - } - }, - "pm2-deploy": { - "version": "0.3.9", - "resolved": "https://registry.npmjs.org/pm2-deploy/-/pm2-deploy-0.3.9.tgz", - "integrity": "sha512-IYF45fPwfLE27BivrtodK7zzN56BNDErK7brcldIHjVIHLlk+cdhijq3kwTkPPP3Tpc3H2C942QGRgjg0hHajA==", - "dev": true, - "requires": { - "async": "1.5.2", - "tv4": "1.3.0" - }, - "dependencies": { - "async": { - "version": "1.5.2", - "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", - "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=", - "dev": true - } - } - }, - "pm2-multimeter": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/pm2-multimeter/-/pm2-multimeter-0.1.2.tgz", - "integrity": "sha1-Gh5VFT1BoFU0zqI8/oYKuqDrSs4=", - "dev": true, - "requires": { - "charm": "0.1.2" - } - }, - "pmx": { - "version": "1.6.4", - "resolved": "https://registry.npmjs.org/pmx/-/pmx-1.6.4.tgz", - "integrity": "sha512-uk6REZHe8j3RhGlFUfyVwFrE6JFhZigTpMFs/4iYO4MzCqVTpNp1cED032oCc4R+m32wUITV/2RDmPX21T1LLg==", - "dev": true, - "requires": { - "debug": "3.1.0", - "deep-metrics": "0.0.1", - "json-stringify-safe": "5.0.1", - "semver": "5.5.0", - "vxx": "1.2.2" - } - }, - "posix-character-classes": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz", - "integrity": "sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=", - "dev": true - }, - "process-nextick-args": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", - "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", - "dev": true - }, - "prompt": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/prompt/-/prompt-1.0.0.tgz", - "integrity": "sha1-jlcSPDlquYiJf7Mn/Trtw+c15P4=", - "requires": { - "colors": "1.1.2", - "pkginfo": "0.4.1", - "read": "1.0.7", - "revalidator": "0.1.8", - "utile": "0.3.0", - "winston": "2.1.1" - } - }, - "promptly": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/promptly/-/promptly-2.2.0.tgz", - "integrity": "sha1-KhP6BjaIoqWYOxYf/wEIoH0m/HQ=", - "dev": true, - "requires": { - "read": "1.0.7" - } - }, - "read": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/read/-/read-1.0.7.tgz", - "integrity": "sha1-s9oZvQUkMal2cdRKQmNK33ELQMQ=", - "requires": { - "mute-stream": "0.0.7" - } - }, - "readable-stream": { - "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", - "inherits": "2.0.3", - "isarray": "1.0.0", - "process-nextick-args": "2.0.0", - "safe-buffer": "5.1.2", - "string_decoder": "1.1.1", - "util-deprecate": "1.0.2" - } - }, - "readdir-recursive": { - "version": "0.0.4", - "resolved": "https://registry.npmjs.org/readdir-recursive/-/readdir-recursive-0.0.4.tgz", - "integrity": "sha1-mvQ1q6nFi9gNvclIi025up8SMB8=" - }, - "readdirp": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-2.1.0.tgz", - "integrity": "sha1-TtCtBg3zBzMAxIRANz9y0cxkLXg=", - "dev": true, - "requires": { - "graceful-fs": "4.1.11", - "minimatch": "3.0.4", - "readable-stream": "2.3.6", - "set-immediate-shim": "1.0.1" - } - }, - "rechoir": { - "version": "0.6.2", - "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz", - "integrity": "sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q=", - "dev": true, - "requires": { - "resolve": "1.7.1" - } - }, - "regenerator-runtime": { - "version": "0.11.1", - "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz", - "integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==" - }, - "regex-not": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/regex-not/-/regex-not-1.0.2.tgz", - "integrity": "sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A==", - "dev": true, - "requires": { - "extend-shallow": "3.0.2", - "safe-regex": "1.1.0" - } - }, - "remove-trailing-separator": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz", - "integrity": "sha1-wkvOKig62tW8P1jg1IJJuSN52O8=", - "dev": true - }, - "repeat-element": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.2.tgz", - "integrity": "sha1-7wiaF40Ug7quTZPrmLT55OEdmQo=", - "dev": true - }, - "repeat-string": { - "version": "1.6.1", - "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", - "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", - "dev": true - }, - "resolve": { - "version": "1.7.1", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.7.1.tgz", - "integrity": "sha512-c7rwLofp8g1U+h1KNyHL/jicrKg1Ek4q+Lr33AL65uZTinUZHe30D5HlyN5V9NW0JX1D5dXQ4jqW5l7Sy/kGfw==", - "dev": true, - "requires": { - "path-parse": "1.0.5" - } - }, - "resolve-url": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz", - "integrity": "sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=", - "dev": true - }, - "ret": { - "version": "0.1.15", - "resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz", - "integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==", - "dev": true - }, - "revalidator": { - "version": "0.1.8", - "resolved": "https://registry.npmjs.org/revalidator/-/revalidator-0.1.8.tgz", - "integrity": "sha1-/s5hv6DBtSoga9axgZgYS91SOjs=" - }, - "rimraf": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", - "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", - "requires": { - "glob": "7.1.2" - } - }, - "safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true - }, - "safe-regex": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", - "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=", - "dev": true, - "requires": { - "ret": "0.1.15" - } - }, - "safer-buffer": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", - "dev": true - }, - "sax": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", - "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==", - "dev": true - }, - "semver": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", - "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", - "dev": true - }, - "set-immediate-shim": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/set-immediate-shim/-/set-immediate-shim-1.0.1.tgz", - "integrity": "sha1-SysbJ+uAip+NzEgaWOXlb1mfP2E=", - "dev": true - }, - "set-value": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.0.tgz", - "integrity": "sha512-hw0yxk9GT/Hr5yJEYnHNKYXkIA8mVJgd9ditYZCe16ZczcaELYYcfvaXesNACk2O8O0nTiPQcQhGUQj8JLzeeg==", - "dev": true, - "requires": { - "extend-shallow": "2.0.1", - "is-extendable": "0.1.1", - "is-plain-object": "2.0.4", - "split-string": "3.1.0" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "0.1.1" - } - } - } - }, - "shelljs": { - "version": "0.7.8", - "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.7.8.tgz", - "integrity": "sha1-3svPh0sNHl+3LhSxZKloMEjprLM=", - "dev": true, - "requires": { - "glob": "7.1.2", - "interpret": "1.1.0", - "rechoir": "0.6.2" - } - }, - "shimmer": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/shimmer/-/shimmer-1.2.0.tgz", - "integrity": "sha512-xTCx2vohXC2EWWDqY/zb4+5Mu28D+HYNSOuFzsyRDRvI/e1ICb69afwaUwfjr+25ZXldbOLyp+iDUZHq8UnTag==", - "dev": true - }, - "snapdragon": { - "version": "0.8.2", - "resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz", - "integrity": "sha512-FtyOnWN/wCHTVXOMwvSv26d+ko5vWlIDD6zoUJ7LW8vh+ZBC8QdljveRP+crNrtBwioEUWy/4dMtbBjA4ioNlg==", - "dev": true, - "requires": { - "base": "0.11.2", - "debug": "2.6.9", - "define-property": "0.2.5", - "extend-shallow": "2.0.1", - "map-cache": "0.2.2", - "source-map": "0.5.7", - "source-map-resolve": "0.5.2", - "use": "3.1.0" - }, - "dependencies": { - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - }, - "define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, - "requires": { - "is-descriptor": "0.1.6" - } - }, - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "0.1.1" - } - } - } - }, - "snapdragon-node": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/snapdragon-node/-/snapdragon-node-2.1.1.tgz", - "integrity": "sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw==", - "dev": true, - "requires": { - "define-property": "1.0.0", - "isobject": "3.0.1", - "snapdragon-util": "3.0.1" - }, - "dependencies": { - "define-property": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", - "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", - "dev": true, - "requires": { - "is-descriptor": "1.0.2" - } - }, - "is-accessor-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", - "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "dev": true, - "requires": { - "kind-of": "6.0.2" - } - }, - "is-data-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", - "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "dev": true, - "requires": { - "kind-of": "6.0.2" - } - }, - "is-descriptor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", - "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "dev": true, - "requires": { - "is-accessor-descriptor": "1.0.0", - "is-data-descriptor": "1.0.0", - "kind-of": "6.0.2" - } - } - } - }, - "snapdragon-util": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/snapdragon-util/-/snapdragon-util-3.0.1.tgz", - "integrity": "sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ==", - "dev": true, - "requires": { - "kind-of": "3.2.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "1.1.6" - } - } - } - }, - "source-map": { - "version": "0.5.7", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", - "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", - "dev": true - }, - "source-map-resolve": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.2.tgz", - "integrity": "sha512-MjqsvNwyz1s0k81Goz/9vRBe9SZdB09Bdw+/zYyO+3CuPk6fouTaxscHkgtE8jKvf01kVfl8riHzERQ/kefaSA==", - "dev": true, - "requires": { - "atob": "2.1.1", - "decode-uri-component": "0.2.0", - "resolve-url": "0.2.1", - "source-map-url": "0.4.0", - "urix": "0.1.0" - } - }, - "source-map-support": { - "version": "0.5.5", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.5.tgz", - "integrity": "sha512-mR7/Nd5l1z6g99010shcXJiNEaf3fEtmLhRB/sBcQVJGodcHCULPp2y4Sfa43Kv2zq7T+Izmfp/WHCR6dYkQCA==", - "dev": true, - "requires": { - "buffer-from": "1.0.0", - "source-map": "0.6.1" - }, - "dependencies": { - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true - } - } - }, - "source-map-url": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.0.tgz", - "integrity": "sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=", - "dev": true - }, - "split-string": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", - "integrity": "sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw==", - "dev": true, - "requires": { - "extend-shallow": "3.0.2" - } - }, - "sprintf-js": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.1.tgz", - "integrity": "sha1-Nr54Mgr+WAH2zqPueLblqrlA6gw=", - "dev": true - }, - "stack-trace": { - "version": "0.0.10", - "resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz", - "integrity": "sha1-VHxws0fo0ytOEI6hoqFZ5f3eGcA=" - }, - "static-extend": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz", - "integrity": "sha1-YICcOcv/VTNyJv1eC1IPNB8ftcY=", - "dev": true, - "requires": { - "define-property": "0.2.5", - "object-copy": "0.1.0" - }, - "dependencies": { - "define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, - "requires": { - "is-descriptor": "0.1.6" - } - } - } - }, - "string_decoder": { - "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.2" - } - }, - "strip-ansi": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "dev": true, - "requires": { - "ansi-regex": "2.1.1" - } - }, - "supports-color": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.3.0.tgz", - "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==", - "requires": { - "has-flag": "3.0.0" - } - }, - "to-object-path": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/to-object-path/-/to-object-path-0.3.0.tgz", - "integrity": "sha1-KXWIt7Dn4KwI4E5nL4XB9JmeF68=", - "dev": true, - "requires": { - "kind-of": "3.2.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "1.1.6" - } - } - } - }, - "to-regex": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/to-regex/-/to-regex-3.0.2.tgz", - "integrity": "sha512-FWtleNAtZ/Ki2qtqej2CXTOayOH9bHDQF+Q48VpWyDXjbYxA4Yz8iDB31zXOBUlOHHKidDbqGVrTUvQMPmBGBw==", - "dev": true, - "requires": { - "define-property": "2.0.2", - "extend-shallow": "3.0.2", - "regex-not": "1.0.2", - "safe-regex": "1.1.0" - } - }, - "to-regex-range": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-2.1.1.tgz", - "integrity": "sha1-fIDBe53+vlmeJzZ+DU3VWQFB2zg=", - "dev": true, - "requires": { - "is-number": "3.0.0", - "repeat-string": "1.6.1" - } - }, - "tv4": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/tv4/-/tv4-1.3.0.tgz", - "integrity": "sha1-0CDIRvrdUMhVq7JeuuzGj8EPeWM=", - "dev": true - }, - "union-value": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.0.tgz", - "integrity": "sha1-XHHDTLW61dzr4+oM0IIHulqhrqQ=", - "dev": true, - "requires": { - "arr-union": "3.1.0", - "get-value": "2.0.6", - "is-extendable": "0.1.1", - "set-value": "0.4.3" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "0.1.1" - } - }, - "set-value": { - "version": "0.4.3", - "resolved": "https://registry.npmjs.org/set-value/-/set-value-0.4.3.tgz", - "integrity": "sha1-fbCPnT0i3H945Trzw79GZuzfzPE=", - "dev": true, - "requires": { - "extend-shallow": "2.0.1", - "is-extendable": "0.1.1", - "is-plain-object": "2.0.4", - "to-object-path": "0.3.0" - } - } - } - }, - "universalify": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.1.tgz", - "integrity": "sha1-+nG63UQ3r0wUiEHjs7Fl+enlkLc=" - }, - "unset-value": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/unset-value/-/unset-value-1.0.0.tgz", - "integrity": "sha1-g3aHP30jNRef+x5vw6jtDfyKtVk=", - "dev": true, - "requires": { - "has-value": "0.3.1", - "isobject": "3.0.1" - }, - "dependencies": { - "has-value": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/has-value/-/has-value-0.3.1.tgz", - "integrity": "sha1-ex9YutpiyoJ+wKIHgCVlSEWZXh8=", - "dev": true, - "requires": { - "get-value": "2.0.6", - "has-values": "0.1.4", - "isobject": "2.1.0" - }, - "dependencies": { - "isobject": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", - "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=", - "dev": true, - "requires": { - "isarray": "1.0.0" - } - } - } - }, - "has-values": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/has-values/-/has-values-0.1.4.tgz", - "integrity": "sha1-bWHeldkd/Km5oCCJrThL/49it3E=", - "dev": true - } - } - }, - "upath": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/upath/-/upath-1.0.5.tgz", - "integrity": "sha512-qbKn90aDQ0YEwvXoLqj0oiuUYroLX2lVHZ+b+xwjozFasAOC4GneDq5+OaIG5Zj+jFmbz/uO+f7a9qxjktJQww==", - "dev": true - }, - "urix": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz", - "integrity": "sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI=", - "dev": true - }, - "use": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/use/-/use-3.1.0.tgz", - "integrity": "sha512-6UJEQM/L+mzC3ZJNM56Q4DFGLX/evKGRg15UJHGB9X5j5Z3AFbgZvjUh2yq/UJUY4U5dh7Fal++XbNg1uzpRAw==", - "dev": true, - "requires": { - "kind-of": "6.0.2" - } - }, - "util-deprecate": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", - "dev": true - }, - "utile": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/utile/-/utile-0.3.0.tgz", - "integrity": "sha1-E1LDQOuCDk2N26A5pPv6oy7U7zo=", - "requires": { - "async": "0.9.2", - "deep-equal": "0.2.2", - "i": "0.3.6", - "mkdirp": "0.5.1", - "ncp": "1.0.1", - "rimraf": "2.6.2" - } - }, - "uuid": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz", - "integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA==", - "dev": true - }, - "v8-compile-cache": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-1.1.2.tgz", - "integrity": "sha512-ejdrifsIydN1XDH7EuR2hn8ZrkRKUYF7tUcBjBy/lhrCvs2K+zRlbW9UHc0IQ9RsYFZJFqJrieoIHfkCa0DBRA==", - "dev": true - }, - "vizion": { - "version": "0.2.13", - "resolved": "https://registry.npmjs.org/vizion/-/vizion-0.2.13.tgz", - "integrity": "sha1-ExTN7is0EW+fWxJIU2+V2/zW718=", - "dev": true, - "requires": { - "async": "1.5.2" - }, - "dependencies": { - "async": { - "version": "1.5.2", - "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", - "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=", - "dev": true - } - } - }, - "vxx": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/vxx/-/vxx-1.2.2.tgz", - "integrity": "sha1-dB+1HG8R0zg9pvm5IBil17qAdhE=", - "dev": true, - "requires": { - "continuation-local-storage": "3.2.1", - "debug": "2.6.9", - "extend": "3.0.1", - "is": "3.2.1", - "lodash.findindex": "4.6.0", - "lodash.isequal": "4.5.0", - "lodash.merge": "4.6.1", - "methods": "1.1.2", - "semver": "5.5.0", - "shimmer": "1.2.0", - "uuid": "3.2.1" - }, - "dependencies": { - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - } - } - }, - "winston": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/winston/-/winston-2.1.1.tgz", - "integrity": "sha1-PJNJ0ZYgf9G9/51LxD73JRDjoS4=", - "requires": { - "async": "1.0.0", - "colors": "1.0.3", - "cycle": "1.0.3", - "eyes": "0.1.8", - "isstream": "0.1.2", - "pkginfo": "0.3.1", - "stack-trace": "0.0.10" - }, - "dependencies": { - "async": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/async/-/async-1.0.0.tgz", - "integrity": "sha1-+PwEyjoTeErenhZBr5hXjPvWR6k=" - }, - "colors": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/colors/-/colors-1.0.3.tgz", - "integrity": "sha1-BDP0TYCWgP3rYO0mDxsMJi6CpAs=" - }, - "pkginfo": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/pkginfo/-/pkginfo-0.3.1.tgz", - "integrity": "sha1-Wyn2qB9wcXFC4J52W76rl7T4HiE=" - } - } - }, - "wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" - }, - "ws": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-5.0.0.tgz", - "integrity": "sha512-XXG4S0b771C68AeTHebBsJJBZMguxj7Em+D657RViuj6ppRd3tfuOhIK8eGwZGNb76C8MjQfCTfH2NN50rJN4w==", - "requires": { - "async-limiter": "1.0.0" - } - }, - "yamljs": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/yamljs/-/yamljs-0.3.0.tgz", - "integrity": "sha512-C/FsVVhht4iPQYXOInoxUM/1ELSf9EsgKH34FofQOp6hwCPrW4vG4w5++TED3xRUo8gD7l0P1J1dLlDYzODsTQ==", - "dev": true, - "requires": { - "argparse": "1.0.10", - "glob": "7.1.2" - } - } - } -} diff --git a/server/package.json b/server/package.json deleted file mode 100644 index 8417c13..0000000 --- a/server/package.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "name": "hack.chat-v2", - "version": "2.0.1", - "description": "a minimal distraction free chat application", - "main": "main.js", - "repository": { - "type": "git", - "url": "git+https://github.com/hack-chat/main.git" - }, - "engines": { - "node": ">= 8.10.0", - "npm": ">= 5.7.1" - }, - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1", - "start": "node server.js", - "config": "node src/scripts/configure.js", - "debug": "node src/scripts/debug.js", - "dev": "node src/scripts/debug.js" - }, - "author": "Marzavec", - "license": "WTFPL", - "dependencies": { - "chalk": "^2.3.2", - "common-tags": "^1.7.2", - "dateformat": "^3.0.3", - "deasync": "^0.1.12", - "didyoumean2": "^1.3.0", - "fs-extra": "^5.0.0", - "prompt": "^1.0.0", - "readdir-recursive": "0.0.4", - "ws": "^5.0.0" - } -} diff --git a/server/scripts/configure.js b/server/scripts/configure.js new file mode 100644 index 0000000..0ecd858 --- /dev/null +++ b/server/scripts/configure.js @@ -0,0 +1,23 @@ +/** + * Server configuration script, used reconfiguring server options + * + * Version: v2.0.0 + * Developer: Marzavec ( https://github.com/marzavec ) + * License: WTFPL ( http://www.wtfpl.net/txt/copying/ ) + * + */ + +'use strict'; + +// import required classes +const path = require('path'); +const ImportsManager = require('../managers/imports-manager'); +const ConfigManager = require('../managers/config'); + +// import and initialize configManager & dependencies +const importManager = new ImportsManager(null, path.join(__dirname, '../..')); +importManager.init(); +const configManager = new ConfigManager(null, path.join(__dirname, '../..'), importManager); + +// execute config load with `reconfiguring` flag set to true +configManager.load(true); diff --git a/server/scripts/debug.js b/server/scripts/debug.js new file mode 100644 index 0000000..3a97d9f --- /dev/null +++ b/server/scripts/debug.js @@ -0,0 +1,18 @@ +/** + * Server debug test script + * + * Version: v2.0.0 + * Developer: Marzavec ( https://github.com/marzavec ) + * License: WTFPL ( http://www.wtfpl.net/txt/copying/ ) + * + */ + +'use strict'; + +// import required classes +const path = require('path'); +const ConfigManager = require('../managers/config'); + +// begin tests +// TODO: TODO +// TODO diff --git a/server/scripts/dev.js b/server/scripts/dev.js new file mode 100644 index 0000000..5049b84 --- /dev/null +++ b/server/scripts/dev.js @@ -0,0 +1,17 @@ +/** + * Server development script + * + * Version: v2.0.0 + * Developer: Marzavec ( https://github.com/marzavec ) + * License: WTFPL ( http://www.wtfpl.net/txt/copying/ ) + * + */ + +'use strict'; + +// import required classes + + +// begin tests +// TODO: TODO +// TODO diff --git a/server/src/commands/admin/addmod.js b/server/src/commands/admin/addmod.js deleted file mode 100644 index 4c13b22..0000000 --- a/server/src/commands/admin/addmod.js +++ /dev/null @@ -1,47 +0,0 @@ -/* - Description: Adds the target trip to the mod list then elevates the uType -*/ - -exports.run = async (core, server, socket, data) => { - if (socket.uType != 'admin') { - // ignore if not admin - return; - } - - let mod = { - trip: data.trip - } - - core.config.mods.push(mod); // purposely not using `config.set()` to avoid auto-save - - let newMod = server.findSockets({ trip: data.trip }); - - if (newMod.length !== 0) { - for (let i = 0, l = newMod.length; i < l; i++) { - newMod[i].uType = 'mod'; - - server.send({ - cmd: 'info', - text: 'You are now a mod.' - }, newMod[i]); - } - } - - server.reply({ - cmd: 'info', - text: `Added mod trip: ${data.trip}` - }, socket); - - server.broadcast({ - cmd: 'info', - text: `Added mod trip: ${data.trip}` - }, { uType: 'mod' }); -}; - -exports.requiredData = ['trip']; - -exports.info = { - name: 'addmod', - usage: 'addmod {trip}', - description: 'Adds target trip to the config as a mod and upgrades the socket type' -}; diff --git a/server/src/commands/admin/listusers.js b/server/src/commands/admin/listusers.js deleted file mode 100644 index a539a3c..0000000 --- a/server/src/commands/admin/listusers.js +++ /dev/null @@ -1,38 +0,0 @@ -/* - Description: Outputs all current channels and their user nicks -*/ - -exports.run = async (core, server, socket, data) => { - if (socket.uType != 'admin') { - // ignore if not admin - return; - } - - let channels = {}; - for (var client of server.clients) { - if (client.channel) { - if (!channels[client.channel]) { - channels[client.channel] = []; - } - channels[client.channel].push(client.nick); - } - } - - let lines = []; - for (let channel in channels) { - lines.push(`?${channel} ${channels[channel].join(", ")}`); - } - - let text = ''; - text += lines.join("\n"); - - server.reply({ - cmd: 'info', - text: text - }, socket); -}; - -exports.info = { - name: 'listusers', - description: 'Outputs all current channels and sockets in those channels' -}; diff --git a/server/src/commands/admin/reload.js b/server/src/commands/admin/reload.js deleted file mode 100644 index e2cfbe6..0000000 --- a/server/src/commands/admin/reload.js +++ /dev/null @@ -1,35 +0,0 @@ -/* - Description: Clears and resets the command modules, outputting any errors -*/ - -exports.run = async (core, server, socket, data) => { - if (socket.uType != 'admin') { - // ignore if not admin - return; - } - - let loadResult = core.managers.dynamicImports.reloadDirCache('src/commands'); - loadResult += core.commands.loadCommands(); - - if (loadResult == '') { - loadResult = `Loaded ${core.commands._commands.length} commands, 0 errors`; - } else { - loadResult = `Loaded ${core.commands._commands.length} commands, error(s): ${loadResult}`; - } - - server.reply({ - cmd: 'info', - text: loadResult - }, socket); - - server.broadcast({ - cmd: 'info', - text: loadResult - }, { uType: 'mod' }); -}; - -exports.info = { - name: 'reload', - description: '(Re)loads any new commands into memory, outputs errors if any' -}; - diff --git a/server/src/commands/admin/saveconfig.js b/server/src/commands/admin/saveconfig.js deleted file mode 100644 index ed3a312..0000000 --- a/server/src/commands/admin/saveconfig.js +++ /dev/null @@ -1,36 +0,0 @@ -/* - Description: Writes any changes to the config to the disk -*/ - -exports.run = async (core, server, socket, data) => { - if (socket.uType != 'admin') { - // ignore if not admin - return; - } - - let saveResult = core.managers.config.save(); - - if (!saveResult) { - server.reply({ - cmd: 'warn', - text: 'Failed to save config, check logs.' - }, client); - - return; - } - - server.reply({ - cmd: 'info', - text: 'Config saved!' - }, socket); - - server.broadcast({ - cmd: 'info', - text: 'Config saved!' - }, { uType: 'mod' }); -}; - -exports.info = { - name: 'saveconfig', - description: 'Saves current config' -}; diff --git a/server/src/commands/admin/shout.js b/server/src/commands/admin/shout.js deleted file mode 100644 index 1358dd9..0000000 --- a/server/src/commands/admin/shout.js +++ /dev/null @@ -1,23 +0,0 @@ -/* - Description: Emmits a server-wide message as `info` -*/ - -exports.run = async (core, server, socket, data) => { - if (socket.uType != 'admin') { - // ignore if not admin - return; - } - - server.broadcast( { - cmd: 'info', - text: `Server Notice: ${data.text}` - }, {}); -}; - -exports.requiredData = ['text']; - -exports.info = { - name: 'shout', - usage: 'shout {text}', - description: 'Displays passed text to every client connected' -}; \ No newline at end of file diff --git a/server/src/commands/core/changenick.js b/server/src/commands/core/changenick.js deleted file mode 100644 index 4041bb0..0000000 --- a/server/src/commands/core/changenick.js +++ /dev/null @@ -1,88 +0,0 @@ -/* - Description: Generates a semi-unique channel name then broadcasts it to each client -*/ - -const verifyNickname = (nick) => { - return /^[a-zA-Z0-9_]{1,24}$/.test(nick); -}; - -exports.run = async (core, server, socket, data) => { - if (server._police.frisk(socket.remoteAddress, 6)) { - server.reply({ - cmd: 'warn', - text: 'You are changing nicknames too fast. Wait a moment before trying again.' - }, socket); - - return; - } - - if (typeof data.nick !== 'string') { - return; - } - - let newNick = data.nick.trim(); - - if (!verifyNickname(newNick)) { - server.reply({ - cmd: 'warn', - text: 'Nickname must consist of up to 24 letters, numbers, and underscores' - }, socket); - - return; - } - - if (newNick.toLowerCase() == core.config.adminName.toLowerCase()) { - server._police.frisk(socket.remoteAddress, 4); - - server.reply({ - cmd: 'warn', - text: 'Gtfo' - }, socket); - - return; - } - - let userExists = server.findSockets({ - channel: socket.channel, - nick: (targetNick) => targetNick.toLowerCase() === newNick.toLowerCase() - }); - - if (userExists.length > 0) { - // That nickname is already in that channel - server.reply({ - cmd: 'warn', - text: 'Nickname taken' - }, socket); - - return; - } - - let peerList = server.findSockets({ channel: socket.channel }); - let leaveNotice = { - cmd: 'onlineRemove', - nick: socket.nick - }; - let joinNotice = { - cmd: 'onlineAdd', - nick: newNick, - trip: socket.trip || 'null', - hash: server.getSocketHash(socket) - }; - - server.broadcast( leaveNotice, { channel: socket.channel }); - server.broadcast( joinNotice, { channel: socket.channel }); - server.broadcast( { - cmd: 'info', - text: `${socket.nick} is now ${newNick}` - }, { channel: socket.channel }); - - socket.nick = newNick; -}; - -exports.requiredData = ['nick']; - -exports.info = { - name: 'changenick', - usage: 'changenick {nick}', - description: 'This will change your current connections nickname' -}; diff --git a/server/src/commands/core/chat.js b/server/src/commands/core/chat.js deleted file mode 100644 index bce6adb..0000000 --- a/server/src/commands/core/chat.js +++ /dev/null @@ -1,62 +0,0 @@ -/* - Description: Rebroadcasts any `text` to all clients in a `channel` -*/ - -const parseText = (text) => { - if (typeof text !== 'string') { - return false; - } - - // strip newlines from beginning and end - text = text.replace(/^\s*\n|^\s+$|\n\s*$/g, ''); - // replace 3+ newlines with just 2 newlines - text = text.replace(/\n{3,}/g, "\n\n"); - - return text; -}; - -exports.run = async (core, server, socket, data) => { - let text = parseText(data.text); - if (!text) { - // lets not send objects or empty text, yea? - return; - } - - let score = text.length / 83 / 4; - if (server._police.frisk(socket.remoteAddress, score)) { - server.reply({ - cmd: 'warn', - text: 'You are sending too much text. Wait a moment and try again.\nPress the up arrow key to restore your last message.' - }, socket); - - return; - } - - let payload = { - cmd: 'chat', - nick: socket.nick, - text: text - }; - - if (socket.uType == 'admin') { - payload.admin = true; - } else if (socket.uType == 'mod') { - payload.mod = true; - } - - if (socket.trip) { - payload.trip = socket.trip; - } - - server.broadcast( payload, { channel: socket.channel }); - - core.managers.stats.increment('messages-sent'); -}; - -exports.requiredData = ['text']; - -exports.info = { - name: 'chat', - usage: 'chat {text}', - description: 'Broadcasts passed `text` field to the calling users channel' -}; \ No newline at end of file diff --git a/server/src/commands/core/disconnect.js b/server/src/commands/core/disconnect.js deleted file mode 100644 index 9b54214..0000000 --- a/server/src/commands/core/disconnect.js +++ /dev/null @@ -1,21 +0,0 @@ -/* - Description: This module will be directly called by the server event handler - when a socket connection is closed or lost. It can calso be called - by a client to have the connection severed. -*/ - -exports.run = async (core, server, socket, data) => { - if (socket.channel) { - server.broadcast({ - cmd: 'onlineRemove', - nick: socket.nick - }, { channel: socket.channel }); - } - - socket.terminate(); -}; - -exports.info = { - name: 'disconnect', - description: 'Event handler or force disconnect (if your into that kind of thing)' -}; \ No newline at end of file diff --git a/server/src/commands/core/help.js b/server/src/commands/core/help.js deleted file mode 100644 index 7f63d3d..0000000 --- a/server/src/commands/core/help.js +++ /dev/null @@ -1,49 +0,0 @@ -/* - Description: Outputs the current command module list or command categories -*/ - -const stripIndents = require('common-tags').stripIndents; - -exports.run = async (core, server, socket, data) => { - // verify passed arguments - let typeDt = typeof data.type; - let catDt = typeof data.category; - let cmdDt = typeof data.command; - if (typeDt !== 'undefined' && typeDt !== 'string' ) { - return; - } else if (catDt !== 'undefined' && catDt !== 'string' ) { - return; - } else if (cmdDt !== 'undefined' && cmdDt !== 'string' ) { - return; - } - - // set default reply - let reply = stripIndents`Help usage: - Show all categories -> { cmd: 'help', type: 'categories' } - Show all commands in category -> { cmd: 'help', category: '' } - Show specific command -> { cmd: 'help', command: '' }`; - - if (typeDt !== 'undefined') { - let categories = core.commands.categories().sort(); - reply = `Command Categories:\n${categories.map(c => `- ${c.replace('../src/commands/', '')}`).join('\n')}`; - } else if (catDt !== 'undefined') { - let catCommands = core.commands.all('../src/commands/' + data.category).sort((a, b) => a.info.name.localeCompare(b.info.name)); - reply = `${data.category} commands:\n${catCommands.map(c => `- ${c.info.name}`).join('\n')}`; - } else if (cmdDt !== 'undefined') { - let command = core.commands.get(data.command); - reply = stripIndents` - Usage: ${command.info.usage || command.info.name} - Description: ${command.info.description || '¯\_(ツ)_/¯'}`; - } - - server.reply({ - cmd: 'info', - text: reply - }, socket); -}; - -exports.info = { - name: 'help', - usage: 'help ([ type:categories] | [category: | command: ])', - description: 'Outputs information about the servers current protocol' -}; \ No newline at end of file diff --git a/server/src/commands/core/invite.js b/server/src/commands/core/invite.js deleted file mode 100644 index bcf9097..0000000 --- a/server/src/commands/core/invite.js +++ /dev/null @@ -1,65 +0,0 @@ -/* - Description: Generates a semi-unique channel name then broadcasts it to each client -*/ - -const verifyNickname = (nick) => { - return /^[a-zA-Z0-9_]{1,24}$/.test(nick); -}; - -exports.run = async (core, server, socket, data) => { - if (server._police.frisk(socket.remoteAddress, 2)) { - server.reply({ - cmd: 'warn', - text: 'You are sending invites too fast. Wait a moment before trying again.' - }, socket); - - return; - } - - if (typeof data.nick !== 'string') { - return; - } - - if (!verifyNickname(data.nick)) { - // Not a valid nickname? Chances are we won't find them - return; - } - - if (data.nick == socket.nick) { - // They invited themself - return; - } - - let channel = Math.random().toString(36).substr(2, 8); - - let payload = { - cmd: 'info', - invite: channel, - text: `${socket.nick} invited you to ?${channel}` - }; - let inviteSent = server.broadcast( payload, { channel: socket.channel, nick: data.nick }); - - if (!inviteSent) { - server.reply({ - cmd: 'warn', - text: 'Could not find user in channel' - }, socket); - - return; - } - - server.reply({ - cmd: 'info', - text: `You invited ${data.nick} to ?${channel}` - }, socket); - - core.managers.stats.increment('invites-sent'); -}; - -exports.requiredData = ['nick']; - -exports.info = { - name: 'invite', - usage: 'invite {nick}', - description: 'Generates a unique (more or less) room name and passes it to two clients' -}; \ No newline at end of file diff --git a/server/src/commands/core/join.js b/server/src/commands/core/join.js deleted file mode 100644 index f2b2c9d..0000000 --- a/server/src/commands/core/join.js +++ /dev/null @@ -1,135 +0,0 @@ -/* - Description: Initial entry point, applies `channel` and `nick` to the calling socket -*/ - -const crypto = require('crypto'); - -const hash = (password) => { - let sha = crypto.createHash('sha256'); - sha.update(password); - return sha.digest('base64').substr(0, 6); -}; - -const verifyNickname = (nick) => { - return /^[a-zA-Z0-9_]{1,24}$/.test(nick); -}; - -exports.run = async (core, server, socket, data) => { - if (server._police.frisk(socket.remoteAddress, 3)) { - server.reply({ - cmd: 'warn', - text: 'You are joining channels too fast. Wait a moment and try again.' - }, socket); - - return; - } - - if (typeof socket.channel !== 'undefined') { - // Calling socket already in a channel - return; - } - - if (typeof data.channel !== 'string' || typeof data.nick !== 'string') { - return; - } - - let channel = data.channel.trim(); - if (!channel) { - // Must join a non-blank channel - return; - } - - // Process nickname - let nick = data.nick; - let nickArray = nick.split('#', 2); - nick = nickArray[0].trim(); - - if (!verifyNickname(nick)) { - server.reply({ - cmd: 'warn', - text: 'Nickname must consist of up to 24 letters, numbers, and underscores' - }, socket); - - return; - } - - let userExists = server.findSockets({ - channel: data.channel, - nick: (targetNick) => targetNick.toLowerCase() === nick.toLowerCase() - }); - - if (userExists.length > 0) { - // That nickname is already in that channel - server.reply({ - cmd: 'warn', - text: 'Nickname taken' - }, socket); - - return; - } - - // TODO: Should we check for mod status first to prevent overwriting of admin status somehow? Meh, w/e, cba. - let uType = 'user'; - let trip = null; - let password = nickArray[1]; - if (nick.toLowerCase() == core.config.adminName.toLowerCase()) { - if (password != core.config.adminPass) { - server._police.frisk(socket.remoteAddress, 4); - - server.reply({ - cmd: 'warn', - text: 'Gtfo' - }, socket); - - return; - } else { - uType = 'admin'; - trip = 'Admin'; - } - } else if (password) { - trip = hash(password + core.config.tripSalt); - } - - // TODO: Disallow moderator impersonation - for (let mod of core.config.mods) { - if (trip === mod.trip) { - uType = 'mod'; - } - } - - // Reply with online user list - let newPeerList = server.findSockets({ channel: data.channel }); - let joinAnnouncement = { - cmd: 'onlineAdd', - nick: nick, - trip: trip || 'null', - hash: server.getSocketHash(socket) - }; - let nicks = []; - - for (let i = 0, l = newPeerList.length; i < l; i++) { - server.reply(joinAnnouncement, newPeerList[i]); - nicks.push(newPeerList[i].nick); - } - - socket.uType = uType; - socket.nick = nick; - socket.channel = channel; - if (trip !== null) socket.trip = trip; - nicks.push(socket.nick); - - server.reply({ - cmd: 'onlineSet', - nicks: nicks - }, socket); - - core.managers.stats.increment('users-joined'); -}; - -exports.requiredData = ['channel', 'nick']; - -exports.info = { - name: 'join', - usage: 'join {channel} {nick}', - description: 'Place calling socket into target channel with target nick & broadcast event to channel' -}; \ No newline at end of file diff --git a/server/src/commands/core/morestats.js b/server/src/commands/core/morestats.js deleted file mode 100644 index 5510cb1..0000000 --- a/server/src/commands/core/morestats.js +++ /dev/null @@ -1,53 +0,0 @@ -/* - Description: Outputs more info than the legacy stats command -*/ - -const stripIndents = require('common-tags').stripIndents; - -const formatTime = (time) => { - let seconds = time[0] + time[1] / 1e9; - - let minutes = Math.floor(seconds / 60); - seconds = seconds % 60; - - let hours = Math.floor(minutes / 60); - minutes = minutes % 60; - return `${hours.toFixed(0)}h ${minutes.toFixed(0)}m ${seconds.toFixed(0)}s`; -}; - -exports.run = async (core, server, socket, data) => { - let ips = {}; - let channels = {}; - for (let client of server.clients) { - if (client.channel) { - channels[client.channel] = true; - ips[client.remoteAddress] = true; - } - } - - let uniqueClientCount = Object.keys(ips).length; - let uniqueChannels = Object.keys(channels).length; - - ips = null; - channels = null; - - server.reply({ - cmd: 'info', - text: stripIndents`current-connections: ${uniqueClientCount} - current-channels: ${uniqueChannels} - users-joined: ${(core.managers.stats.get('users-joined') || 0)} - invites-sent: ${(core.managers.stats.get('invites-sent') || 0)} - messages-sent: ${(core.managers.stats.get('messages-sent') || 0)} - users-banned: ${(core.managers.stats.get('users-banned') || 0)} - users-kicked: ${(core.managers.stats.get('users-kicked') || 0)} - stats-requested: ${(core.managers.stats.get('stats-requested') || 0)} - server-uptime: ${formatTime(process.hrtime(core.managers.stats.get('start-time')))}` - }, socket); - - core.managers.stats.increment('stats-requested'); -}; - -exports.info = { - name: 'morestats', - description: 'Sends back current server stats to the calling client' -}; \ No newline at end of file diff --git a/server/src/commands/core/move.js b/server/src/commands/core/move.js deleted file mode 100644 index c5efafd..0000000 --- a/server/src/commands/core/move.js +++ /dev/null @@ -1,83 +0,0 @@ -/* - Description: Generates a semi-unique channel name then broadcasts it to each client -*/ - -exports.run = async (core, server, socket, data) => { - if (server._police.frisk(socket.remoteAddress, 6)) { - server.reply({ - cmd: 'warn', - text: 'You are changing channels too fast. Wait a moment before trying again.' - }, socket); - - return; - } - - if (typeof data.channel !== 'string') { - return; - } - - if (data.channel === socket.channel) { - // They are trying to rejoin the channel - return; - } - - const currentNick = socket.nick.toLowerCase(); - let userExists = server.findSockets({ - channel: data.channel, - nick: (targetNick) => targetNick.toLowerCase() === currentNick - }); - - if (userExists.length > 0) { - // That nickname is already in that channel - return; - } - - let peerList = server.findSockets({ channel: socket.channel }); - - if (peerList.length > 1) { - for (let i = 0, l = peerList.length; i < l; i++) { - server.reply({ - cmd: 'onlineRemove', - nick: peerList[i].nick - }, socket); - - if (socket.nick !== peerList[i].nick){ - server.reply({ - cmd: 'onlineRemove', - nick: socket.nick - }, peerList[i]); - } - } - } - - let newPeerList = server.findSockets({ channel: data.channel }); - let moveAnnouncement = { - cmd: 'onlineAdd', - nick: socket.nick, - trip: socket.trip || 'null', - hash: server.getSocketHash(socket) - }; - let nicks = []; - - for (let i = 0, l = newPeerList.length; i < l; i++) { - server.reply(moveAnnouncement, newPeerList[i]); - nicks.push(newPeerList[i].nick); - } - - nicks.push(socket.nick); - - server.reply({ - cmd: 'onlineSet', - nicks: nicks - }, socket); - - socket.channel = data.channel; -}; - -exports.requiredData = ['channel']; - -exports.info = { - name: 'move', - usage: 'move {channel}', - description: 'This will change the current channel to the new one provided' -}; \ No newline at end of file diff --git a/server/src/commands/core/stats.js b/server/src/commands/core/stats.js deleted file mode 100644 index b9dc002..0000000 --- a/server/src/commands/core/stats.js +++ /dev/null @@ -1,32 +0,0 @@ -/* - Description: Legacy stats output, kept for compatibility, outputs user and channel count -*/ - -exports.run = async (core, server, socket, data) => { - let ips = {}; - let channels = {}; - for (let client of server.clients) { - if (client.channel) { - channels[client.channel] = true; - ips[client.remoteAddress] = true; - } - } - - let uniqueClientCount = Object.keys(ips).length; - let uniqueChannels = Object.keys(channels).length; - - ips = null; - channels = null; - - server.reply({ - cmd: 'info', - text: `${uniqueClientCount} unique IPs in ${uniqueChannels} channels` - }, socket); - - core.managers.stats.increment('stats-requested'); -}; - -exports.info = { - name: 'stats', - description: 'Sends back legacy server stats to the calling client' -}; \ No newline at end of file diff --git a/server/src/commands/mod/ban.js b/server/src/commands/mod/ban.js deleted file mode 100644 index e19efc2..0000000 --- a/server/src/commands/mod/ban.js +++ /dev/null @@ -1,64 +0,0 @@ -/* - Description: Adds the target socket's ip to the ratelimiter -*/ - -exports.run = async (core, server, socket, data) => { - if (socket.uType == 'user') { - // ignore if not mod or admin - return; - } - - if (typeof data.nick !== 'string') { - return; - } - - let targetNick = data.nick; - let badClient = server.findSockets({ channel: socket.channel, nick: targetNick }); - - if (badClient.length === 0) { - server.reply({ - cmd: 'warn', - text: 'Could not find user in channel' - }, socket); - - return; - } - - badClient = badClient[0]; - - if (badClient.uType !== 'user') { - server.reply({ - cmd: 'warn', - text: 'Cannot ban other mods, how rude' - }, socket); - - return; - } - - let clientHash = server.getSocketHash(badClient); - server._police.arrest(badClient.remoteAddress, clientHash); - - console.log(`${socket.nick} [${socket.trip}] banned ${targetNick} in ${socket.channel}`); - - server.broadcast({ - cmd: 'info', - text: `Banned ${targetNick}` - }, { channel: socket.channel, uType: 'user' }); - - server.broadcast({ - cmd: 'info', - text: `${socket.nick} banned ${targetNick} in ${socket.channel}, userhash: ${clientHash}` - }, { uType: 'mod' }); - - badClient.close(); - - core.managers.stats.increment('users-banned'); -}; - -exports.requiredData = ['nick']; - -exports.info = { - name: 'ban', - usage: 'ban {nick}', - description: 'Disconnects the target nickname in the same channel as calling socket & adds to ratelimiter' -}; diff --git a/server/src/commands/mod/kick.js b/server/src/commands/mod/kick.js deleted file mode 100644 index 157592d..0000000 --- a/server/src/commands/mod/kick.js +++ /dev/null @@ -1,78 +0,0 @@ -/* - Description: Forces a change on the target socket's channel, then broadcasts event -*/ - -exports.run = async (core, server, socket, data) => { - if (socket.uType === 'user') { - // ignore if not mod or admin - return; - } - - if (typeof data.nick !== 'string') { - if (typeof data.nick !== 'object' && !Array.isArray(data.nick)) { - return; - } - } - - let badClients = server.findSockets({ channel: socket.channel, nick: data.nick }); - - if (badClients.length === 0) { - server.reply({ - cmd: 'warn', - text: 'Could not find user(s) in channel' - }, socket); - - return; - } - - let newChannel = ''; - let kicked = []; - for (let i = 0, j = badClients.length; i < j; i++) { - if (badClients[i].uType !== 'user') { - server.reply({ - cmd: 'warn', - text: 'Cannot kick other mods, how rude' - }, socket); - } else { - newChannel = Math.random().toString(36).substr(2, 8); - badClients[i].channel = newChannel; - - // inform mods with where they were sent - server.broadcast({ - cmd: 'info', - text: `${badClients[i].nick} was banished to ?${newChannel}` - }, { channel: socket.channel, uType: 'mod' }); - - kicked.push(badClients[i].nick); - console.log(`${socket.nick} [${socket.trip}] kicked ${badClients[i].nick} in ${socket.channel}`); - } - } - - if (kicked.length === 0) { - return; - } - - // broadcast client leave event - for (let i = 0, j = kicked.length; i < j; i++) { - server.broadcast({ - cmd: 'onlineRemove', - nick: kicked[i] - }, { channel: socket.channel }); - } - - // publicly broadcast kick event - server.broadcast({ - cmd: 'info', - text: `Kicked ${kicked.join(', ')}` - }, { channel: socket.channel, uType: 'user' }); - - core.managers.stats.increment('users-kicked', kicked.length); -}; - -exports.requiredData = ['nick']; - -exports.info = { - name: 'kick', - usage: 'kick {nick}', - description: 'Silently forces target client(s) into another channel. `nick` may be string or array of strings' -}; \ No newline at end of file diff --git a/server/src/commands/mod/unban.js b/server/src/commands/mod/unban.js deleted file mode 100644 index e82f0b9..0000000 --- a/server/src/commands/mod/unban.js +++ /dev/null @@ -1,55 +0,0 @@ -/* - Description: Removes a target ip from the ratelimiter -*/ - -exports.run = async (core, server, socket, data) => { - if (socket.uType == 'user') { - // ignore if not mod or admin - return; - } - - if (typeof data.ip !== 'string' && typeof data.hash !== 'string') { - server.reply({ - cmd: 'warn', - text: "hash:'targethash' or ip:'1.2.3.4' is required" - }, socket); - - return; - } - - let mode, target; - - if (typeof data.ip === 'string') { - mode = 'ip'; - target = data.ip; - } else { - mode = 'hash'; - target = data.hash; - } - - server._police.pardon(target); - - if (mode === 'ip') { - target = server.getSocketHash(target); - } - - console.log(`${socket.nick} [${socket.trip}] unbanned ${target} in ${socket.channel}`); - - server.reply({ - cmd: 'info', - text: `Unbanned ${target}` - }, socket); - - server.broadcast({ - cmd: 'info', - text: `${socket.nick} unbanned: ${target}` - }, { uType: 'mod' }); - - core.managers.stats.decrement('users-banned'); -}; - -exports.info = { - name: 'unban', - usage: 'unban {[ip || hash]}', - description: 'Removes target ip from the ratelimiter' -}; \ No newline at end of file diff --git a/server/src/core/rateLimiter.js b/server/src/core/rateLimiter.js deleted file mode 100644 index 0c2a384..0000000 --- a/server/src/core/rateLimiter.js +++ /dev/null @@ -1,103 +0,0 @@ -/** - * Tracks frequency of occurances based on `id` (remote address), then allows or - * denies command execution based on comparison with `threshold` - * - * Version: v2.0.0 - * Developer: Marzavec ( https://github.com/marzavec ) - * License: WTFPL ( http://www.wtfpl.net/txt/copying/ ) - * - */ - -class Police { - /** - * Create a ratelimiter instance. - */ - constructor () { - this._records = {}; - this._halflife = 30 * 1000; // milliseconds - this._threshold = 25; - this._hashes = []; - } - - /** - * Finds current score by `id` - * - * @param {String} id target id / address - * @public - * - * @memberof Police - */ - search (id) { - let record = this._records[id]; - - if (!record) { - record = this._records[id] = { - time: Date.now(), - score: 0 - } - } - - return record; - } - - /** - * Adjusts the current ratelimit score by `deltaScore` - * - * @param {String} id target id / address - * @param {Number} deltaScore amount to adjust current score by - * @public - * - * @memberof Police - */ - frisk (id, deltaScore) { - let record = this.search(id); - - if (record.arrested) { - return true; - } - - record.score *= Math.pow(2, -(Date.now() - record.time ) / this._halflife); - record.score += deltaScore; - record.time = Date.now(); - - if (record.score >= this._threshold) { - return true; - } - - return false; - } - - /** - * Statically set server to no longer accept traffic from `id` - * - * @param {String} id target id / address - * @public - * - * @memberof Police - */ - arrest (id, hash) { - let record = this.search(id); - - record.arrested = true; - this._hashes[hash] = id; - } - - /** - * Remove statically assigned limit from `id` - * - * @param {String} id target id / address - * @public - * - * @memberof Police - */ - pardon (id) { - if (typeof this._hashes[id] !== 'undefined') { - id = this._hashes[id]; - } - - let record = this.search(id); - record.arrested = false; - } -} - -module.exports = Police; diff --git a/server/src/core/server.js b/server/src/core/server.js deleted file mode 100644 index 855aeba..0000000 --- a/server/src/core/server.js +++ /dev/null @@ -1,282 +0,0 @@ -/** - * Main websocket server handling communications and connection events - * - * Version: v2.0.0 - * Developer: Marzavec ( https://github.com/marzavec ) - * License: WTFPL ( http://www.wtfpl.net/txt/copying/ ) - * - */ - -const wsServer = require('ws').Server; -const socketReady = require('ws').OPEN; -const crypto = require('crypto'); -const ipSalt = (Math.random().toString(36).substring(2, 16) + Math.random().toString(36).substring(2, (Math.random() * 16))).repeat(16); -const Police = require('./rateLimiter'); -const pulseSpeed = 16000; // ping all clients every X ms - -class server extends wsServer { - /** - * Create a HackChat server instance. - * - * @param {Object} core Reference to the global core object - */ - constructor (core) { - super({ port: core.config.websocketPort }); - - this._core = core; - this._police = new Police(); - this._cmdBlacklist = {}; - this._heartBeat = setInterval(((data) => { - this.beatHeart(); - }).bind(this), pulseSpeed); - - this.on('error', (err) => { - this.handleError('server', err); - }); - - this.on('connection', (socket, request) => { - this.newConnection(socket, request); - }); - } - - /** - * Send empty `ping` frame to each client - * - */ - beatHeart () { - let targetSockets = this.findSockets({}); - - if (targetSockets.length === 0) { - return; - } - - for (let i = 0, l = targetSockets.length; i < l; i++) { - try { - if (targetSockets[i].readyState === socketReady) { - targetSockets[i].ping(); - } - } catch (e) { } - } - } - - /** - * Bind listeners for the new socket created on connection to this class - * - * @param {Object} socket New socket object - * @param {Object} request Initial headers of the new connection - */ - newConnection (socket, request) { - socket.remoteAddress = request.headers['x-forwarded-for'] || request.connection.remoteAddress; - - socket.on('message', ((data) => { - this.handleData(socket, data); - }).bind(this)); - - socket.on('close', (() => { - this.handleClose(socket); - }).bind(this)); - - socket.on('error', ((err) => { - this.handleError(socket, err); - }).bind(this)); - } - - /** - * Handle incoming messages from clients, parse and check command, then hand-off - * - * @param {Object} socket Calling socket object - * @param {String} data Message sent from client - */ - handleData (socket, data) { - // Don't penalize yet, but check whether IP is rate-limited - if (this._police.frisk(socket.remoteAddress, 0)) { - this.reply({ cmd: 'warn', text: "Your IP is being rate-limited or blocked." }, socket); - - return; - } - - // Penalize here, but don't do anything about it - this._police.frisk(socket.remoteAddress, 1); - - // ignore ridiculously large packets - if (data.length > 65536) { - return; - } - - // Start sent data verification - var args = null; - try { - args = JSON.parse(data); - } catch (e) { - // Client sent malformed json, gtfo - socket.close(); - } - - if (args === null) { - return; - } - - if (typeof args.cmd === 'undefined' || args.cmd == 'ping') { - return; - } - - if (typeof args.cmd !== 'string') { - return; - } - - if (typeof socket.channel === 'undefined' && args.cmd !== 'join') { - return; - } - - if (typeof this._cmdBlacklist[args.cmd] === 'function') { - return; - } - - // Finished verification, pass to command modules - this._core.commands.handleCommand(this, socket, args); - } - - /** - * Handle socket close from clients - * - * @param {Object} socket Closing socket object - */ - handleClose (socket) { - this._core.commands.handleCommand(this, socket, { cmd: 'disconnect' }); - } - - /** - * "Handle" server or socket errors - * - * @param {Object||String} socket Calling socket object, or 'server' - * @param {String} err The sad stuff - */ - handleError (socket, err) { - console.log(`Server error: ${err}`); - } - - /** - * Send data payload to specific socket/client - * - * @param {Object} data Object to convert to json for transmission - * @param {Object} socket The target client - */ - send (data, socket) { - // Add timestamp to command - data.time = Date.now(); - - try { - if (socket.readyState === socketReady) { - socket.send(JSON.stringify(data)); - } - } catch (e) { } - } - - /** - * Overload function for `this.send()` - * - * @param {Object} data Object to convert to json for transmission - * @param {Object} socket The target client - */ - reply (data, socket) { - this.send(data, socket); - } - - /** - * Finds sockets/clients that meet the filter requirements, then passes the data to them - * - * @param {Object} data Object to convert to json for transmission - * @param {Object} filter see `this.findSockets()` - */ - broadcast (data, filter) { - let targetSockets = this.findSockets(filter); - - if (targetSockets.length === 0) { - return false; - } - - for (let i = 0, l = targetSockets.length; i < l; i++) { - this.send(data, targetSockets[i]); - } - - return true; - } - - /** - * Finds sockets/clients that meet the filter requirements, returns result as array - * - * @param {Object} data Object to convert to json for transmission - * @param {Object} filter The socket must of equal or greater attribs matching `filter` - * = {} // matches all - * = { channel: 'programming' } // matches any socket where (`socket.channel` === 'programming') - * = { channel: 'programming', nick: 'Marzavec' } // matches any socket where (`socket.channel` === 'programming' && `socket.nick` === 'Marzavec') - */ - findSockets (filter) { - let filterAttribs = Object.keys(filter); - let reqCount = filterAttribs.length; - let curMatch; - let matches = []; - for ( let socket of this.clients ) { - curMatch = 0; - - for (let i = 0; i < reqCount; i++) { - if (typeof socket[filterAttribs[i]] !== 'undefined') { - switch(typeof filter[filterAttribs[i]]) { - case 'object': { - if (Array.isArray(filter[filterAttribs[i]])) { - if (filter[filterAttribs[i]].indexOf(socket[filterAttribs[i]]) !== -1) { - curMatch++; - } - } else { - if (socket[filterAttribs[i]] === filter[filterAttribs[i]]) { - curMatch++; - } - } - break; - } - - case 'function': { - if (filter[filterAttribs[i]](socket[filterAttribs[i]])) { - curMatch++; - } - break; - } - - default: { - if (socket[filterAttribs[i]] === filter[filterAttribs[i]]) { - curMatch++; - } - break; - } - } - } - } - - if (curMatch === reqCount) { - matches.push(socket); - } - } - - return matches; - } - - /** - * Encrypts target socket's remote address using non-static variable length salt - * encodes and shortens the output, returns that value - * - * @param {Object||String} target Either the target socket or ip as string - */ - getSocketHash (target) { - let sha = crypto.createHash('sha256'); - - if (typeof target === 'string') { - sha.update(target + ipSalt); - } else { - sha.update(target.remoteAddress + ipSalt); - } - - return sha.digest('base64').substr(0, 15); - } -} - -module.exports = server; diff --git a/server/src/managers/commands.js b/server/src/managers/commands.js deleted file mode 100644 index c38fb4d..0000000 --- a/server/src/managers/commands.js +++ /dev/null @@ -1,239 +0,0 @@ -/** - * Commands / protocol manager- loads, validates and handles command execution - * - * Version: v2.0.0 - * Developer: Marzavec ( https://github.com/marzavec ) - * License: WTFPL ( http://www.wtfpl.net/txt/copying/ ) - * - */ - -const path = require('path'); -const chalk = require('chalk'); -const didYouMean = require('didyoumean2'); - -class CommandManager { - /** - * Create a `CommandManager` instance for handling commands/protocol - * - * @param {Object} core Reference to the global core object - */ - constructor (core) { - this.core = core; - this._commands = []; - this._categories = []; - } - - /** - * (Re)initializes name spaces for commands and starts load routine - * - */ - loadCommands () { - this._commands = []; - this._categories = []; - - const core = this.core; - - const commandImports = core.managers.dynamicImports.getImport('src/commands'); - let cmdErrors = ''; - Object.keys(commandImports).forEach(file => { - let command = commandImports[file]; - let name = path.basename(file); - cmdErrors += this._validateAndLoad(command, file, name); - }); - - return cmdErrors; - } - - /** - * Checks the module after having been `require()`ed in and reports errors - * - * @param {Object} command reference to the newly loaded object - * @param {String} file file path to the module - * @param {String} name command (`cmd`) name - */ - _validateAndLoad (command, file, name) { - let error = this._validateCommand(command); - - if (error) { - let errText = `Failed to load '${name}': ${error}`; - console.log(errText); - return errText; - } - - if (!command.category) { - let base = path.join(this.core.managers.dynamicImports.base, 'commands'); - - let category = 'Uncategorized'; - if (file.indexOf(path.sep) > -1) { - category = path.dirname(path.relative(base, file)) - .replace(new RegExp(path.sep.replace('\\', '\\\\'), 'g'), '/'); - } - - command.info.category = category; - - if (this._categories.indexOf(category) === -1) - this._categories.push(category); - } - - if (typeof command.init === 'function') { - try { - command.init(this.core); - } catch (err) { - let errText = `Failed to initialize '${name}': ${err}`; - console.log(errText); - return errText; - } - } - - this._commands.push(command); - - return ''; - } - - /** - * Checks the module after having been `require()`ed in and reports errors - * - * @param {Object} object reference to the newly loaded object - */ - _validateCommand (object) { - if (typeof object !== 'object') - return 'command setup is invalid'; - - if (typeof object.run !== 'function') - return 'run function is missing'; - - if (typeof object.info !== 'object') - return 'info object is missing'; - - if (typeof object.info.name !== 'string') - return 'info object is missing a valid name field'; - - return null; - } - - /** - * Pulls all command names from a passed `category` - * - * @param {String} category reference to the newly loaded object - */ - all (category) { - return !category ? this._commands : this._commands.filter(c => c.info.category.toLowerCase() === category.toLowerCase()); - } - - /** - * Pulls all category names - * - */ - categories () { - return this._categories; - } - - /** - * Pulls command by name or alia(s) - * - * @param {String} name name or alias of command - */ - get (name) { - return this.findBy('name', name) - || this._commands.find(command => command.info.aliases instanceof Array && command.info.aliases.indexOf(name) > -1); - } - - /** - * Pulls command by arbitrary search of the `module.info` attribute - * - * @param {String} key name or alias of command - * @param {String} value name or alias of command - */ - findBy (key, value) { - return this._commands.find(c => c.info[key] === value); - } - - /** - * Finds and executes the requested command, or fails with semi-intelligent error - * - * @param {Object} server main server reference - * @param {Object} socket calling socket reference - * @param {Object} data command structure passed by socket (client) - */ - handleCommand (server, socket, data) { - // Try to find command first - let command = this.get(data.cmd); - - if (command) { - return this.execute(command, server, socket, data); - } else { - // Then fail with helpful (sorta) message - return this._handleFail(server, socket, data); - } - } - - /** - * Requested command failure handler, attempts to find command and reports back - * - * @param {Object} server main server reference - * @param {Object} socket calling socket reference - * @param {Object} data command structure passed by socket (client) - */ - _handleFail(server, socket, data) { - const maybe = didYouMean(data.cmd, this.all().map(c => c.info.name), { - threshold: 5, - thresholdType: 'edit-distance' - }); - - if (maybe) { - // Found a suggestion, pass it on to their dyslexic self - return server.reply({ - cmd: 'warn', - text: `Command not found, did you mean: \`${maybe}\`?` - }, socket); - } - - // Request so mangled that I don't even, silently fail - return; - } - - /** - * Attempt to execute the requested command, fail if err or bad params - * - * @param {Object} command target command module - * @param {Object} server main server reference - * @param {Object} socket calling socket reference - * @param {Object} data command structure passed by socket (client) - */ - async execute(command, server, socket, data) { - if (typeof command.requiredData !== 'undefined') { - let missing = []; - for (let i = 0, len = command.requiredData.length; i < len; i++) { - if (typeof data[command.requiredData[i]] === 'undefined') - missing.push(command.requiredData[i]); - } - - if (missing.length > 0) { - let errText = `Failed to execute '${command.info.name}': missing required ${missing.join(', ')}\n\n`; - - server.reply({ - cmd: 'warn', - text: errText - }, socket); - - return null; - } - } - - try { - return await command.run(this.core, server, socket, data); - } catch (err) { - let errText = `Failed to execute '${command.info.name}': ${err}`; - console.log(errText); - - server.reply({ - cmd: 'warn', - text: errText - }, socket); - - return null; - } - } -} - -module.exports = CommandManager; diff --git a/server/src/managers/config.js b/server/src/managers/config.js deleted file mode 100644 index 2865d00..0000000 --- a/server/src/managers/config.js +++ /dev/null @@ -1,224 +0,0 @@ -/** - * Server configuration manager, handling loading, creation, parsing and saving - * of the main config.json file - * - * Version: v2.0.0 - * Developer: Marzavec ( https://github.com/marzavec ) - * License: WTFPL ( http://www.wtfpl.net/txt/copying/ ) - * - */ - -const stripIndents = require('common-tags').stripIndents; -const dateFormat = require('dateformat'); -const chalk = require('chalk'); -const fse = require('fs-extra'); -const prompt = require('prompt'); -const path = require('path'); -const deSync = require('deasync'); - -class ConfigManager { - /** - * Create a `ConfigManager` instance for (re)loading classes and config - * - * @param {Object} core reference to the global core object - * @param {String} base executing directory name; __dirname - * @param {Object} dynamicImports dynamic import engine reference - */ - constructor (core, base, dynamicImports) { - this._core = core; - this._base = base; - - this._configPath = path.resolve(base, 'config/config.json'); - - this._dynamicImports = dynamicImports; - } - - /** - * Pulls both core config questions along with any optional config questions, - * used in building the initial config.json or re-building it. - * - * @param {Object} currentConfig an object containing current server settings, if any - * @param {Object} optionalConfigs optional (non-core) module config - */ - getQuestions (currentConfig, optionalConfigs) { - // core server setup questions - const questions = { - properties: { - adminName: { - pattern: /^"?[a-zA-Z0-9_]+"?$/, - type: 'string', - message: 'Nicks can only contain letters, numbers and underscores', - required: !currentConfig.adminName, - default: currentConfig.adminName, - before: value => value.replace(/"/g, '') - }, - adminPass: { - type: 'string', - required: !currentConfig.adminPass, - default: currentConfig.adminPass, - hidden: true, - replace: '*', - }, - websocketPort: { - type: 'number', - required: !currentConfig.websocketPort, - default: currentConfig.websocketPort || 6060 - }, - tripSalt: { - type: 'string', - required: !currentConfig.tripSalt, - default: currentConfig.tripSalt, - hidden: true, - replace: '*', - } - } - }; - - // non-core server setup questions, for future plugin support - Object.keys(optionalConfigs).forEach(configName => { - const config = optionalConfigs[configName]; - const question = config.getQuestion(currentConfig, configName); - - if (!question) { - return; - } - - question.description = (question.description || configName) + ' (Optional)'; - questions.properties[configName] = question; - }); - - return questions; - } - - /** - * `load` function overload, only blocking - * - */ - loadSync () { - let conf = {}; - conf = this.load(); - - // trip salt is the last core config question, wait until it's been populated - // TODO: update this to work with new plugin support - while(conf === null || typeof conf.tripSalt === 'undefined') { - deSync.sleep(100); - } - - return conf; - } - - /** - * (Re)builds the config.json (main server config), or loads the config into mem - * if rebuilding, process will exit- this is to allow a process manager to take over - * - * @param {Boolean} reconfiguring set to true by `scripts/configure.js`, will exit if true - */ - load (reconfiguring = false) { - if (reconfiguring || !fse.existsSync(this._configPath)) { - // gotta have that sexy console - console.log(stripIndents` - ${chalk.magenta('°º¤ø,¸¸,ø¤º°`°º¤ø,¸,ø¤°º¤ø,¸¸,ø¤º°`°º¤ø,¸°º¤ø,¸¸,ø¤º°`°º¤ø')} - ${chalk.gray('--------------(') + chalk.white(' HackChat Setup Wizard v1.0 ') + chalk.gray(')--------------')} - ${chalk.magenta('°º¤ø,¸¸,ø¤º°`°º¤ø,¸,ø¤°º¤ø,¸¸,ø¤º°`°º¤ø,¸°º¤ø,¸¸,ø¤º°`°º¤ø')} - - For advanced setup, see the HackChat wiki at: - ${chalk.green('https://github.com/')} - - ${chalk.white('Note:')} ${chalk.green('npm/yarn run config')} will re-run this utility. - - You will now be asked for the following: - - ${chalk.magenta('Admin Name')}, the initial admin username - - ${chalk.magenta('Admin Pass')}, the initial admin password - - ${chalk.magenta(' Port')}, the port for the websocket - - ${chalk.magenta(' Salt')}, the salt for username trip - \u200b - `); - - let currentConfig = this._config || {}; - if (reconfiguring && fse.existsSync(this._configPath)) { - this._backup(); - currentConfig = fse.readJSONSync(this._configPath); - } - - prompt.get(this.getQuestions(currentConfig, this._dynamicImports.optionalConfigs), (err, res) => { - if (typeof res.mods === 'undefined') { - res.mods = []; - } - - if (err) { - console.error(err); - process.exit(666); // SPOOKY! - } - - try { - fse.outputJsonSync(this._configPath, res); - } catch (e) { - console.error(`Couldn't write config to ${this._configPath}\n${e.stack}`); - if (!reconfiguring) { - process.exit(666); // SPOOKY! - } - } - - console.log('Config generated! You may now start the server normally.') - - process.exit(reconfiguring ? 0 : 42); - }); - - return null; - } - - this._config = fse.readJSONSync(this._configPath); - - return this._config; - } - - /** - * Creates backup of current config into _configPath - * - */ - _backup () { - const backupPath = `${this._configPath}.${dateFormat('dd-mm-yy-HH-MM-ss')}.bak`; - fse.copySync(this._configPath, backupPath); - - return backupPath; - } - - /** - * First makes a backup of the current `config.json`, then writes current config - * to disk - * - */ - save () { - const backupPath = this._backup(); - - if (!fse.existsSync(this._configPath)){ - fse.mkdirSync(this._configPath); - } - - try { - fse.writeJSONSync(this._configPath, this._config); - fse.removeSync(backupPath); - - return true; - } catch (err) { - console.log(`Failed to save config file: ${err}`); - - return false; - } - } - - /** - * Updates current config[`key`] with `value` then writes changes to disk - * - * @param {*} key arbitrary configuration key - * @param {*} value new value to change `key` to - */ - set (key, value) { - const realKey = `${key}`; - this._config[realKey] = value; - - this.save(); - } -} - -module.exports = ConfigManager; diff --git a/server/src/managers/imports-manager.js b/server/src/managers/imports-manager.js deleted file mode 100644 index d8b2144..0000000 --- a/server/src/managers/imports-manager.js +++ /dev/null @@ -1,148 +0,0 @@ -/** - * Import managment base, used to load commands/protocol and configuration objects - * - * Version: v2.0.0 - * Developer: Marzavec ( https://github.com/marzavec ) - * License: WTFPL ( http://www.wtfpl.net/txt/copying/ ) - * - */ - -const read = require('readdir-recursive'); -const path = require('path'); - -class ImportsManager { - /** - * Create a `ImportsManager` instance for (re)loading classes and config - * - * @param {Object} core reference to the global core object - * @param {String} base executing directory name; __dirname - */ - constructor (core, base) { - this._core = core; - this._base = base; - - this._imports = {}; - this._optionalConfigs = {}; - } - - /** - * Pull core reference - * - * @type {Object} readonly - */ - get core () { - return this._core; - } - - /** - * Pull base path that all imports are required in from - * - * @type {String} readonly - */ - get base () { - return this._base; - } - - /** - * Pull optional (none-core) config options - * - * @type {Object} - */ - get optionalConfigs () { - return Object.assign({}, this._optionalConfigs); - } - - /** - * Initialize this class and start loading target directories - * - */ - init () { - let errorText = ''; - ImportsManager.load_dirs.forEach(dir => { - errorText += this.loadDir(dir); - }); - - return errorText; - } - - /** - * Gather all js files from target directory, then verify and load - * - * @param {String} dirName The name of the dir to load, relative to the _base path. - */ - loadDir (dirName) { - const dir = path.resolve(this._base, dirName); - - let errorText = ''; - try { - read.fileSync(dir).forEach(file => { - const basename = path.basename(file); - if (basename.startsWith('_') || !basename.endsWith('.js')) return; - - let imported; - try { - imported = require(file); - } catch (e) { - let err = `Unable to load modules from ${dirName} (${path.relative(dir, file)})\n${e}`; - errorText += err; - console.error(err); - return errorText; - } - - if (imported.configs) { - imported.configs.forEach(config => { - this._optionalConfigs[config.name] = config; - }); - } - - if (!this._imports[dirName]) { - this._imports[dirName] = {}; - } - - this._imports[dirName][file] = imported; - }); - } catch (e) { - let err = `Unable to load modules from ${dirName}\n${e}`; - errorText += err; - console.error(err); - return errorText; - } - - return errorText; - } - - /** - * Unlink references to each loaded module, pray to google that gc knows it's job, - * then reinitialize this class to start the reload - * - * @param {String} dirName The name of the dir to load, relative to the _base path. - */ - reloadDirCache (dirName) { - Object.keys(this._imports[dirName]).forEach((mod) => { - delete require.cache[require.resolve(mod)]; - }); - - return this.init(); - } - - /** - * Pull reference to imported modules that were imported from dirName, or - * load required directory if not found - * - * @param {String} dirName The name of the dir to load, relative to the _base path. - */ - getImport (dirName) { - let imported = this._imports[dirName]; - - if (!imported) { - this.loadDir(dirName); - } - - return Object.assign({}, this._imports[dirName]); - } -} - -// automagically loaded directorys on instantiation -ImportsManager.load_dirs = ['src/commands']; - -module.exports = ImportsManager; diff --git a/server/src/managers/index.js b/server/src/managers/index.js deleted file mode 100644 index 2fac8fb..0000000 --- a/server/src/managers/index.js +++ /dev/null @@ -1,6 +0,0 @@ -module.exports = { - CommandManager: require('./commands'), - Config: require('./config'), - ImportsManager: require('./imports-manager'), - Stats: require('./stats') -}; diff --git a/server/src/managers/stats.js b/server/src/managers/stats.js deleted file mode 100644 index 20f1ae3..0000000 --- a/server/src/managers/stats.js +++ /dev/null @@ -1,59 +0,0 @@ -/** - * Simple generic stats collection script for events occurances (etc) - * - * Version: v2.0.0 - * Developer: Marzavec ( https://github.com/marzavec ) - * License: WTFPL ( http://www.wtfpl.net/txt/copying/ ) - * - */ - -class Stats { - /** - * Create a stats instance. - * - */ - constructor () { - this._stats = {}; - } - - /** - * Retrieve value of arbitrary `key` reference - * - * @param {String} key Reference to the arbitrary store name - */ - get (key) { - return this._stats[key]; - } - - /** - * Set value of arbitrary `key` reference - * - * @param {String} key Reference to the arbitrary store name - * @param {Number} value New value for `key` - */ - set (key, value) { - this._stats[key] = value; - } - - /** - * Increase value of arbitrary `key` reference, by 1 or `amount` - * - * @param {String} key Reference to the arbitrary store name - * @param {Number} amount Value to increase `key` by, or 1 if omitted - */ - increment (key, amount) { - this.set(key, (this.get(key) || 0) + (amount || 1)); - } - - /** - * Reduce value of arbitrary `key` reference, by 1 or `amount` - * - * @param {String} key Reference to the arbitrary store name - * @param {Number} amount Value to decrease `key` by, or 1 if omitted - */ - decrement (key, amount) { - this.set(key, (this.get(key) || 0) - (amount || 1)); - } -} - -module.exports = Stats; diff --git a/server/src/scripts/configure.js b/server/src/scripts/configure.js deleted file mode 100644 index 0ecd858..0000000 --- a/server/src/scripts/configure.js +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Server configuration script, used reconfiguring server options - * - * Version: v2.0.0 - * Developer: Marzavec ( https://github.com/marzavec ) - * License: WTFPL ( http://www.wtfpl.net/txt/copying/ ) - * - */ - -'use strict'; - -// import required classes -const path = require('path'); -const ImportsManager = require('../managers/imports-manager'); -const ConfigManager = require('../managers/config'); - -// import and initialize configManager & dependencies -const importManager = new ImportsManager(null, path.join(__dirname, '../..')); -importManager.init(); -const configManager = new ConfigManager(null, path.join(__dirname, '../..'), importManager); - -// execute config load with `reconfiguring` flag set to true -configManager.load(true); diff --git a/server/src/scripts/debug.js b/server/src/scripts/debug.js deleted file mode 100644 index 3a97d9f..0000000 --- a/server/src/scripts/debug.js +++ /dev/null @@ -1,18 +0,0 @@ -/** - * Server debug test script - * - * Version: v2.0.0 - * Developer: Marzavec ( https://github.com/marzavec ) - * License: WTFPL ( http://www.wtfpl.net/txt/copying/ ) - * - */ - -'use strict'; - -// import required classes -const path = require('path'); -const ConfigManager = require('../managers/config'); - -// begin tests -// TODO: TODO -// TODO diff --git a/server/src/scripts/dev.js b/server/src/scripts/dev.js deleted file mode 100644 index 5049b84..0000000 --- a/server/src/scripts/dev.js +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Server development script - * - * Version: v2.0.0 - * Developer: Marzavec ( https://github.com/marzavec ) - * License: WTFPL ( http://www.wtfpl.net/txt/copying/ ) - * - */ - -'use strict'; - -// import required classes - - -// begin tests -// TODO: TODO -// TODO -- cgit v1.2.1 From 949404cd1aad8492ae0338130f16054adfa38ab7 Mon Sep 17 00:00:00 2001 From: Neel Kamath Date: Sun, 13 May 2018 16:37:56 +0530 Subject: Prevent fucking shit up --- server/commands/admin/addmod.js | 47 ------ server/commands/admin/listusers.js | 38 ----- server/commands/admin/reload.js | 35 ---- server/commands/admin/saveconfig.js | 36 ---- server/commands/admin/shout.js | 23 --- server/commands/core/changenick.js | 88 ---------- server/commands/core/chat.js | 62 ------- server/commands/core/disconnect.js | 21 --- server/commands/core/help.js | 49 ------ server/commands/core/invite.js | 65 -------- server/commands/core/join.js | 135 --------------- server/commands/core/morestats.js | 53 ------ server/commands/core/move.js | 83 ---------- server/commands/core/stats.js | 32 ---- server/commands/mod/ban.js | 64 -------- server/commands/mod/kick.js | 78 --------- server/commands/mod/unban.js | 55 ------- server/core/rateLimiter.js | 103 ------------ server/core/server.js | 282 -------------------------------- server/managers/commands.js | 239 --------------------------- server/managers/config.js | 224 ------------------------- server/managers/imports-manager.js | 148 ----------------- server/managers/index.js | 6 - server/managers/stats.js | 59 ------- server/scripts/configure.js | 23 --- server/scripts/debug.js | 18 -- server/scripts/dev.js | 17 -- server/src/commands/admin/addmod.js | 47 ++++++ server/src/commands/admin/listusers.js | 38 +++++ server/src/commands/admin/reload.js | 35 ++++ server/src/commands/admin/saveconfig.js | 36 ++++ server/src/commands/admin/shout.js | 23 +++ server/src/commands/core/changenick.js | 88 ++++++++++ server/src/commands/core/chat.js | 62 +++++++ server/src/commands/core/disconnect.js | 21 +++ server/src/commands/core/help.js | 49 ++++++ server/src/commands/core/invite.js | 65 ++++++++ server/src/commands/core/join.js | 135 +++++++++++++++ server/src/commands/core/morestats.js | 53 ++++++ server/src/commands/core/move.js | 83 ++++++++++ server/src/commands/core/stats.js | 32 ++++ server/src/commands/mod/ban.js | 64 ++++++++ server/src/commands/mod/kick.js | 78 +++++++++ server/src/commands/mod/unban.js | 55 +++++++ server/src/core/rateLimiter.js | 103 ++++++++++++ server/src/core/server.js | 282 ++++++++++++++++++++++++++++++++ server/src/managers/commands.js | 239 +++++++++++++++++++++++++++ server/src/managers/config.js | 224 +++++++++++++++++++++++++ server/src/managers/imports-manager.js | 148 +++++++++++++++++ server/src/managers/index.js | 6 + server/src/managers/stats.js | 59 +++++++ server/src/scripts/configure.js | 23 +++ server/src/scripts/debug.js | 18 ++ server/src/scripts/dev.js | 17 ++ 54 files changed, 2083 insertions(+), 2083 deletions(-) delete mode 100644 server/commands/admin/addmod.js delete mode 100644 server/commands/admin/listusers.js delete mode 100644 server/commands/admin/reload.js delete mode 100644 server/commands/admin/saveconfig.js delete mode 100644 server/commands/admin/shout.js delete mode 100644 server/commands/core/changenick.js delete mode 100644 server/commands/core/chat.js delete mode 100644 server/commands/core/disconnect.js delete mode 100644 server/commands/core/help.js delete mode 100644 server/commands/core/invite.js delete mode 100644 server/commands/core/join.js delete mode 100644 server/commands/core/morestats.js delete mode 100644 server/commands/core/move.js delete mode 100644 server/commands/core/stats.js delete mode 100644 server/commands/mod/ban.js delete mode 100644 server/commands/mod/kick.js delete mode 100644 server/commands/mod/unban.js delete mode 100644 server/core/rateLimiter.js delete mode 100644 server/core/server.js delete mode 100644 server/managers/commands.js delete mode 100644 server/managers/config.js delete mode 100644 server/managers/imports-manager.js delete mode 100644 server/managers/index.js delete mode 100644 server/managers/stats.js delete mode 100644 server/scripts/configure.js delete mode 100644 server/scripts/debug.js delete mode 100644 server/scripts/dev.js create mode 100644 server/src/commands/admin/addmod.js create mode 100644 server/src/commands/admin/listusers.js create mode 100644 server/src/commands/admin/reload.js create mode 100644 server/src/commands/admin/saveconfig.js create mode 100644 server/src/commands/admin/shout.js create mode 100644 server/src/commands/core/changenick.js create mode 100644 server/src/commands/core/chat.js create mode 100644 server/src/commands/core/disconnect.js create mode 100644 server/src/commands/core/help.js create mode 100644 server/src/commands/core/invite.js create mode 100644 server/src/commands/core/join.js create mode 100644 server/src/commands/core/morestats.js create mode 100644 server/src/commands/core/move.js create mode 100644 server/src/commands/core/stats.js create mode 100644 server/src/commands/mod/ban.js create mode 100644 server/src/commands/mod/kick.js create mode 100644 server/src/commands/mod/unban.js create mode 100644 server/src/core/rateLimiter.js create mode 100644 server/src/core/server.js create mode 100644 server/src/managers/commands.js create mode 100644 server/src/managers/config.js create mode 100644 server/src/managers/imports-manager.js create mode 100644 server/src/managers/index.js create mode 100644 server/src/managers/stats.js create mode 100644 server/src/scripts/configure.js create mode 100644 server/src/scripts/debug.js create mode 100644 server/src/scripts/dev.js (limited to 'server') diff --git a/server/commands/admin/addmod.js b/server/commands/admin/addmod.js deleted file mode 100644 index 4c13b22..0000000 --- a/server/commands/admin/addmod.js +++ /dev/null @@ -1,47 +0,0 @@ -/* - Description: Adds the target trip to the mod list then elevates the uType -*/ - -exports.run = async (core, server, socket, data) => { - if (socket.uType != 'admin') { - // ignore if not admin - return; - } - - let mod = { - trip: data.trip - } - - core.config.mods.push(mod); // purposely not using `config.set()` to avoid auto-save - - let newMod = server.findSockets({ trip: data.trip }); - - if (newMod.length !== 0) { - for (let i = 0, l = newMod.length; i < l; i++) { - newMod[i].uType = 'mod'; - - server.send({ - cmd: 'info', - text: 'You are now a mod.' - }, newMod[i]); - } - } - - server.reply({ - cmd: 'info', - text: `Added mod trip: ${data.trip}` - }, socket); - - server.broadcast({ - cmd: 'info', - text: `Added mod trip: ${data.trip}` - }, { uType: 'mod' }); -}; - -exports.requiredData = ['trip']; - -exports.info = { - name: 'addmod', - usage: 'addmod {trip}', - description: 'Adds target trip to the config as a mod and upgrades the socket type' -}; diff --git a/server/commands/admin/listusers.js b/server/commands/admin/listusers.js deleted file mode 100644 index a539a3c..0000000 --- a/server/commands/admin/listusers.js +++ /dev/null @@ -1,38 +0,0 @@ -/* - Description: Outputs all current channels and their user nicks -*/ - -exports.run = async (core, server, socket, data) => { - if (socket.uType != 'admin') { - // ignore if not admin - return; - } - - let channels = {}; - for (var client of server.clients) { - if (client.channel) { - if (!channels[client.channel]) { - channels[client.channel] = []; - } - channels[client.channel].push(client.nick); - } - } - - let lines = []; - for (let channel in channels) { - lines.push(`?${channel} ${channels[channel].join(", ")}`); - } - - let text = ''; - text += lines.join("\n"); - - server.reply({ - cmd: 'info', - text: text - }, socket); -}; - -exports.info = { - name: 'listusers', - description: 'Outputs all current channels and sockets in those channels' -}; diff --git a/server/commands/admin/reload.js b/server/commands/admin/reload.js deleted file mode 100644 index e2cfbe6..0000000 --- a/server/commands/admin/reload.js +++ /dev/null @@ -1,35 +0,0 @@ -/* - Description: Clears and resets the command modules, outputting any errors -*/ - -exports.run = async (core, server, socket, data) => { - if (socket.uType != 'admin') { - // ignore if not admin - return; - } - - let loadResult = core.managers.dynamicImports.reloadDirCache('src/commands'); - loadResult += core.commands.loadCommands(); - - if (loadResult == '') { - loadResult = `Loaded ${core.commands._commands.length} commands, 0 errors`; - } else { - loadResult = `Loaded ${core.commands._commands.length} commands, error(s): ${loadResult}`; - } - - server.reply({ - cmd: 'info', - text: loadResult - }, socket); - - server.broadcast({ - cmd: 'info', - text: loadResult - }, { uType: 'mod' }); -}; - -exports.info = { - name: 'reload', - description: '(Re)loads any new commands into memory, outputs errors if any' -}; - diff --git a/server/commands/admin/saveconfig.js b/server/commands/admin/saveconfig.js deleted file mode 100644 index ed3a312..0000000 --- a/server/commands/admin/saveconfig.js +++ /dev/null @@ -1,36 +0,0 @@ -/* - Description: Writes any changes to the config to the disk -*/ - -exports.run = async (core, server, socket, data) => { - if (socket.uType != 'admin') { - // ignore if not admin - return; - } - - let saveResult = core.managers.config.save(); - - if (!saveResult) { - server.reply({ - cmd: 'warn', - text: 'Failed to save config, check logs.' - }, client); - - return; - } - - server.reply({ - cmd: 'info', - text: 'Config saved!' - }, socket); - - server.broadcast({ - cmd: 'info', - text: 'Config saved!' - }, { uType: 'mod' }); -}; - -exports.info = { - name: 'saveconfig', - description: 'Saves current config' -}; diff --git a/server/commands/admin/shout.js b/server/commands/admin/shout.js deleted file mode 100644 index 1358dd9..0000000 --- a/server/commands/admin/shout.js +++ /dev/null @@ -1,23 +0,0 @@ -/* - Description: Emmits a server-wide message as `info` -*/ - -exports.run = async (core, server, socket, data) => { - if (socket.uType != 'admin') { - // ignore if not admin - return; - } - - server.broadcast( { - cmd: 'info', - text: `Server Notice: ${data.text}` - }, {}); -}; - -exports.requiredData = ['text']; - -exports.info = { - name: 'shout', - usage: 'shout {text}', - description: 'Displays passed text to every client connected' -}; \ No newline at end of file diff --git a/server/commands/core/changenick.js b/server/commands/core/changenick.js deleted file mode 100644 index 4041bb0..0000000 --- a/server/commands/core/changenick.js +++ /dev/null @@ -1,88 +0,0 @@ -/* - Description: Generates a semi-unique channel name then broadcasts it to each client -*/ - -const verifyNickname = (nick) => { - return /^[a-zA-Z0-9_]{1,24}$/.test(nick); -}; - -exports.run = async (core, server, socket, data) => { - if (server._police.frisk(socket.remoteAddress, 6)) { - server.reply({ - cmd: 'warn', - text: 'You are changing nicknames too fast. Wait a moment before trying again.' - }, socket); - - return; - } - - if (typeof data.nick !== 'string') { - return; - } - - let newNick = data.nick.trim(); - - if (!verifyNickname(newNick)) { - server.reply({ - cmd: 'warn', - text: 'Nickname must consist of up to 24 letters, numbers, and underscores' - }, socket); - - return; - } - - if (newNick.toLowerCase() == core.config.adminName.toLowerCase()) { - server._police.frisk(socket.remoteAddress, 4); - - server.reply({ - cmd: 'warn', - text: 'Gtfo' - }, socket); - - return; - } - - let userExists = server.findSockets({ - channel: socket.channel, - nick: (targetNick) => targetNick.toLowerCase() === newNick.toLowerCase() - }); - - if (userExists.length > 0) { - // That nickname is already in that channel - server.reply({ - cmd: 'warn', - text: 'Nickname taken' - }, socket); - - return; - } - - let peerList = server.findSockets({ channel: socket.channel }); - let leaveNotice = { - cmd: 'onlineRemove', - nick: socket.nick - }; - let joinNotice = { - cmd: 'onlineAdd', - nick: newNick, - trip: socket.trip || 'null', - hash: server.getSocketHash(socket) - }; - - server.broadcast( leaveNotice, { channel: socket.channel }); - server.broadcast( joinNotice, { channel: socket.channel }); - server.broadcast( { - cmd: 'info', - text: `${socket.nick} is now ${newNick}` - }, { channel: socket.channel }); - - socket.nick = newNick; -}; - -exports.requiredData = ['nick']; - -exports.info = { - name: 'changenick', - usage: 'changenick {nick}', - description: 'This will change your current connections nickname' -}; diff --git a/server/commands/core/chat.js b/server/commands/core/chat.js deleted file mode 100644 index bce6adb..0000000 --- a/server/commands/core/chat.js +++ /dev/null @@ -1,62 +0,0 @@ -/* - Description: Rebroadcasts any `text` to all clients in a `channel` -*/ - -const parseText = (text) => { - if (typeof text !== 'string') { - return false; - } - - // strip newlines from beginning and end - text = text.replace(/^\s*\n|^\s+$|\n\s*$/g, ''); - // replace 3+ newlines with just 2 newlines - text = text.replace(/\n{3,}/g, "\n\n"); - - return text; -}; - -exports.run = async (core, server, socket, data) => { - let text = parseText(data.text); - if (!text) { - // lets not send objects or empty text, yea? - return; - } - - let score = text.length / 83 / 4; - if (server._police.frisk(socket.remoteAddress, score)) { - server.reply({ - cmd: 'warn', - text: 'You are sending too much text. Wait a moment and try again.\nPress the up arrow key to restore your last message.' - }, socket); - - return; - } - - let payload = { - cmd: 'chat', - nick: socket.nick, - text: text - }; - - if (socket.uType == 'admin') { - payload.admin = true; - } else if (socket.uType == 'mod') { - payload.mod = true; - } - - if (socket.trip) { - payload.trip = socket.trip; - } - - server.broadcast( payload, { channel: socket.channel }); - - core.managers.stats.increment('messages-sent'); -}; - -exports.requiredData = ['text']; - -exports.info = { - name: 'chat', - usage: 'chat {text}', - description: 'Broadcasts passed `text` field to the calling users channel' -}; \ No newline at end of file diff --git a/server/commands/core/disconnect.js b/server/commands/core/disconnect.js deleted file mode 100644 index 9b54214..0000000 --- a/server/commands/core/disconnect.js +++ /dev/null @@ -1,21 +0,0 @@ -/* - Description: This module will be directly called by the server event handler - when a socket connection is closed or lost. It can calso be called - by a client to have the connection severed. -*/ - -exports.run = async (core, server, socket, data) => { - if (socket.channel) { - server.broadcast({ - cmd: 'onlineRemove', - nick: socket.nick - }, { channel: socket.channel }); - } - - socket.terminate(); -}; - -exports.info = { - name: 'disconnect', - description: 'Event handler or force disconnect (if your into that kind of thing)' -}; \ No newline at end of file diff --git a/server/commands/core/help.js b/server/commands/core/help.js deleted file mode 100644 index 7f63d3d..0000000 --- a/server/commands/core/help.js +++ /dev/null @@ -1,49 +0,0 @@ -/* - Description: Outputs the current command module list or command categories -*/ - -const stripIndents = require('common-tags').stripIndents; - -exports.run = async (core, server, socket, data) => { - // verify passed arguments - let typeDt = typeof data.type; - let catDt = typeof data.category; - let cmdDt = typeof data.command; - if (typeDt !== 'undefined' && typeDt !== 'string' ) { - return; - } else if (catDt !== 'undefined' && catDt !== 'string' ) { - return; - } else if (cmdDt !== 'undefined' && cmdDt !== 'string' ) { - return; - } - - // set default reply - let reply = stripIndents`Help usage: - Show all categories -> { cmd: 'help', type: 'categories' } - Show all commands in category -> { cmd: 'help', category: '' } - Show specific command -> { cmd: 'help', command: '' }`; - - if (typeDt !== 'undefined') { - let categories = core.commands.categories().sort(); - reply = `Command Categories:\n${categories.map(c => `- ${c.replace('../src/commands/', '')}`).join('\n')}`; - } else if (catDt !== 'undefined') { - let catCommands = core.commands.all('../src/commands/' + data.category).sort((a, b) => a.info.name.localeCompare(b.info.name)); - reply = `${data.category} commands:\n${catCommands.map(c => `- ${c.info.name}`).join('\n')}`; - } else if (cmdDt !== 'undefined') { - let command = core.commands.get(data.command); - reply = stripIndents` - Usage: ${command.info.usage || command.info.name} - Description: ${command.info.description || '¯\_(ツ)_/¯'}`; - } - - server.reply({ - cmd: 'info', - text: reply - }, socket); -}; - -exports.info = { - name: 'help', - usage: 'help ([ type:categories] | [category: | command: ])', - description: 'Outputs information about the servers current protocol' -}; \ No newline at end of file diff --git a/server/commands/core/invite.js b/server/commands/core/invite.js deleted file mode 100644 index bcf9097..0000000 --- a/server/commands/core/invite.js +++ /dev/null @@ -1,65 +0,0 @@ -/* - Description: Generates a semi-unique channel name then broadcasts it to each client -*/ - -const verifyNickname = (nick) => { - return /^[a-zA-Z0-9_]{1,24}$/.test(nick); -}; - -exports.run = async (core, server, socket, data) => { - if (server._police.frisk(socket.remoteAddress, 2)) { - server.reply({ - cmd: 'warn', - text: 'You are sending invites too fast. Wait a moment before trying again.' - }, socket); - - return; - } - - if (typeof data.nick !== 'string') { - return; - } - - if (!verifyNickname(data.nick)) { - // Not a valid nickname? Chances are we won't find them - return; - } - - if (data.nick == socket.nick) { - // They invited themself - return; - } - - let channel = Math.random().toString(36).substr(2, 8); - - let payload = { - cmd: 'info', - invite: channel, - text: `${socket.nick} invited you to ?${channel}` - }; - let inviteSent = server.broadcast( payload, { channel: socket.channel, nick: data.nick }); - - if (!inviteSent) { - server.reply({ - cmd: 'warn', - text: 'Could not find user in channel' - }, socket); - - return; - } - - server.reply({ - cmd: 'info', - text: `You invited ${data.nick} to ?${channel}` - }, socket); - - core.managers.stats.increment('invites-sent'); -}; - -exports.requiredData = ['nick']; - -exports.info = { - name: 'invite', - usage: 'invite {nick}', - description: 'Generates a unique (more or less) room name and passes it to two clients' -}; \ No newline at end of file diff --git a/server/commands/core/join.js b/server/commands/core/join.js deleted file mode 100644 index f2b2c9d..0000000 --- a/server/commands/core/join.js +++ /dev/null @@ -1,135 +0,0 @@ -/* - Description: Initial entry point, applies `channel` and `nick` to the calling socket -*/ - -const crypto = require('crypto'); - -const hash = (password) => { - let sha = crypto.createHash('sha256'); - sha.update(password); - return sha.digest('base64').substr(0, 6); -}; - -const verifyNickname = (nick) => { - return /^[a-zA-Z0-9_]{1,24}$/.test(nick); -}; - -exports.run = async (core, server, socket, data) => { - if (server._police.frisk(socket.remoteAddress, 3)) { - server.reply({ - cmd: 'warn', - text: 'You are joining channels too fast. Wait a moment and try again.' - }, socket); - - return; - } - - if (typeof socket.channel !== 'undefined') { - // Calling socket already in a channel - return; - } - - if (typeof data.channel !== 'string' || typeof data.nick !== 'string') { - return; - } - - let channel = data.channel.trim(); - if (!channel) { - // Must join a non-blank channel - return; - } - - // Process nickname - let nick = data.nick; - let nickArray = nick.split('#', 2); - nick = nickArray[0].trim(); - - if (!verifyNickname(nick)) { - server.reply({ - cmd: 'warn', - text: 'Nickname must consist of up to 24 letters, numbers, and underscores' - }, socket); - - return; - } - - let userExists = server.findSockets({ - channel: data.channel, - nick: (targetNick) => targetNick.toLowerCase() === nick.toLowerCase() - }); - - if (userExists.length > 0) { - // That nickname is already in that channel - server.reply({ - cmd: 'warn', - text: 'Nickname taken' - }, socket); - - return; - } - - // TODO: Should we check for mod status first to prevent overwriting of admin status somehow? Meh, w/e, cba. - let uType = 'user'; - let trip = null; - let password = nickArray[1]; - if (nick.toLowerCase() == core.config.adminName.toLowerCase()) { - if (password != core.config.adminPass) { - server._police.frisk(socket.remoteAddress, 4); - - server.reply({ - cmd: 'warn', - text: 'Gtfo' - }, socket); - - return; - } else { - uType = 'admin'; - trip = 'Admin'; - } - } else if (password) { - trip = hash(password + core.config.tripSalt); - } - - // TODO: Disallow moderator impersonation - for (let mod of core.config.mods) { - if (trip === mod.trip) { - uType = 'mod'; - } - } - - // Reply with online user list - let newPeerList = server.findSockets({ channel: data.channel }); - let joinAnnouncement = { - cmd: 'onlineAdd', - nick: nick, - trip: trip || 'null', - hash: server.getSocketHash(socket) - }; - let nicks = []; - - for (let i = 0, l = newPeerList.length; i < l; i++) { - server.reply(joinAnnouncement, newPeerList[i]); - nicks.push(newPeerList[i].nick); - } - - socket.uType = uType; - socket.nick = nick; - socket.channel = channel; - if (trip !== null) socket.trip = trip; - nicks.push(socket.nick); - - server.reply({ - cmd: 'onlineSet', - nicks: nicks - }, socket); - - core.managers.stats.increment('users-joined'); -}; - -exports.requiredData = ['channel', 'nick']; - -exports.info = { - name: 'join', - usage: 'join {channel} {nick}', - description: 'Place calling socket into target channel with target nick & broadcast event to channel' -}; \ No newline at end of file diff --git a/server/commands/core/morestats.js b/server/commands/core/morestats.js deleted file mode 100644 index 5510cb1..0000000 --- a/server/commands/core/morestats.js +++ /dev/null @@ -1,53 +0,0 @@ -/* - Description: Outputs more info than the legacy stats command -*/ - -const stripIndents = require('common-tags').stripIndents; - -const formatTime = (time) => { - let seconds = time[0] + time[1] / 1e9; - - let minutes = Math.floor(seconds / 60); - seconds = seconds % 60; - - let hours = Math.floor(minutes / 60); - minutes = minutes % 60; - return `${hours.toFixed(0)}h ${minutes.toFixed(0)}m ${seconds.toFixed(0)}s`; -}; - -exports.run = async (core, server, socket, data) => { - let ips = {}; - let channels = {}; - for (let client of server.clients) { - if (client.channel) { - channels[client.channel] = true; - ips[client.remoteAddress] = true; - } - } - - let uniqueClientCount = Object.keys(ips).length; - let uniqueChannels = Object.keys(channels).length; - - ips = null; - channels = null; - - server.reply({ - cmd: 'info', - text: stripIndents`current-connections: ${uniqueClientCount} - current-channels: ${uniqueChannels} - users-joined: ${(core.managers.stats.get('users-joined') || 0)} - invites-sent: ${(core.managers.stats.get('invites-sent') || 0)} - messages-sent: ${(core.managers.stats.get('messages-sent') || 0)} - users-banned: ${(core.managers.stats.get('users-banned') || 0)} - users-kicked: ${(core.managers.stats.get('users-kicked') || 0)} - stats-requested: ${(core.managers.stats.get('stats-requested') || 0)} - server-uptime: ${formatTime(process.hrtime(core.managers.stats.get('start-time')))}` - }, socket); - - core.managers.stats.increment('stats-requested'); -}; - -exports.info = { - name: 'morestats', - description: 'Sends back current server stats to the calling client' -}; \ No newline at end of file diff --git a/server/commands/core/move.js b/server/commands/core/move.js deleted file mode 100644 index c5efafd..0000000 --- a/server/commands/core/move.js +++ /dev/null @@ -1,83 +0,0 @@ -/* - Description: Generates a semi-unique channel name then broadcasts it to each client -*/ - -exports.run = async (core, server, socket, data) => { - if (server._police.frisk(socket.remoteAddress, 6)) { - server.reply({ - cmd: 'warn', - text: 'You are changing channels too fast. Wait a moment before trying again.' - }, socket); - - return; - } - - if (typeof data.channel !== 'string') { - return; - } - - if (data.channel === socket.channel) { - // They are trying to rejoin the channel - return; - } - - const currentNick = socket.nick.toLowerCase(); - let userExists = server.findSockets({ - channel: data.channel, - nick: (targetNick) => targetNick.toLowerCase() === currentNick - }); - - if (userExists.length > 0) { - // That nickname is already in that channel - return; - } - - let peerList = server.findSockets({ channel: socket.channel }); - - if (peerList.length > 1) { - for (let i = 0, l = peerList.length; i < l; i++) { - server.reply({ - cmd: 'onlineRemove', - nick: peerList[i].nick - }, socket); - - if (socket.nick !== peerList[i].nick){ - server.reply({ - cmd: 'onlineRemove', - nick: socket.nick - }, peerList[i]); - } - } - } - - let newPeerList = server.findSockets({ channel: data.channel }); - let moveAnnouncement = { - cmd: 'onlineAdd', - nick: socket.nick, - trip: socket.trip || 'null', - hash: server.getSocketHash(socket) - }; - let nicks = []; - - for (let i = 0, l = newPeerList.length; i < l; i++) { - server.reply(moveAnnouncement, newPeerList[i]); - nicks.push(newPeerList[i].nick); - } - - nicks.push(socket.nick); - - server.reply({ - cmd: 'onlineSet', - nicks: nicks - }, socket); - - socket.channel = data.channel; -}; - -exports.requiredData = ['channel']; - -exports.info = { - name: 'move', - usage: 'move {channel}', - description: 'This will change the current channel to the new one provided' -}; \ No newline at end of file diff --git a/server/commands/core/stats.js b/server/commands/core/stats.js deleted file mode 100644 index b9dc002..0000000 --- a/server/commands/core/stats.js +++ /dev/null @@ -1,32 +0,0 @@ -/* - Description: Legacy stats output, kept for compatibility, outputs user and channel count -*/ - -exports.run = async (core, server, socket, data) => { - let ips = {}; - let channels = {}; - for (let client of server.clients) { - if (client.channel) { - channels[client.channel] = true; - ips[client.remoteAddress] = true; - } - } - - let uniqueClientCount = Object.keys(ips).length; - let uniqueChannels = Object.keys(channels).length; - - ips = null; - channels = null; - - server.reply({ - cmd: 'info', - text: `${uniqueClientCount} unique IPs in ${uniqueChannels} channels` - }, socket); - - core.managers.stats.increment('stats-requested'); -}; - -exports.info = { - name: 'stats', - description: 'Sends back legacy server stats to the calling client' -}; \ No newline at end of file diff --git a/server/commands/mod/ban.js b/server/commands/mod/ban.js deleted file mode 100644 index e19efc2..0000000 --- a/server/commands/mod/ban.js +++ /dev/null @@ -1,64 +0,0 @@ -/* - Description: Adds the target socket's ip to the ratelimiter -*/ - -exports.run = async (core, server, socket, data) => { - if (socket.uType == 'user') { - // ignore if not mod or admin - return; - } - - if (typeof data.nick !== 'string') { - return; - } - - let targetNick = data.nick; - let badClient = server.findSockets({ channel: socket.channel, nick: targetNick }); - - if (badClient.length === 0) { - server.reply({ - cmd: 'warn', - text: 'Could not find user in channel' - }, socket); - - return; - } - - badClient = badClient[0]; - - if (badClient.uType !== 'user') { - server.reply({ - cmd: 'warn', - text: 'Cannot ban other mods, how rude' - }, socket); - - return; - } - - let clientHash = server.getSocketHash(badClient); - server._police.arrest(badClient.remoteAddress, clientHash); - - console.log(`${socket.nick} [${socket.trip}] banned ${targetNick} in ${socket.channel}`); - - server.broadcast({ - cmd: 'info', - text: `Banned ${targetNick}` - }, { channel: socket.channel, uType: 'user' }); - - server.broadcast({ - cmd: 'info', - text: `${socket.nick} banned ${targetNick} in ${socket.channel}, userhash: ${clientHash}` - }, { uType: 'mod' }); - - badClient.close(); - - core.managers.stats.increment('users-banned'); -}; - -exports.requiredData = ['nick']; - -exports.info = { - name: 'ban', - usage: 'ban {nick}', - description: 'Disconnects the target nickname in the same channel as calling socket & adds to ratelimiter' -}; diff --git a/server/commands/mod/kick.js b/server/commands/mod/kick.js deleted file mode 100644 index 157592d..0000000 --- a/server/commands/mod/kick.js +++ /dev/null @@ -1,78 +0,0 @@ -/* - Description: Forces a change on the target socket's channel, then broadcasts event -*/ - -exports.run = async (core, server, socket, data) => { - if (socket.uType === 'user') { - // ignore if not mod or admin - return; - } - - if (typeof data.nick !== 'string') { - if (typeof data.nick !== 'object' && !Array.isArray(data.nick)) { - return; - } - } - - let badClients = server.findSockets({ channel: socket.channel, nick: data.nick }); - - if (badClients.length === 0) { - server.reply({ - cmd: 'warn', - text: 'Could not find user(s) in channel' - }, socket); - - return; - } - - let newChannel = ''; - let kicked = []; - for (let i = 0, j = badClients.length; i < j; i++) { - if (badClients[i].uType !== 'user') { - server.reply({ - cmd: 'warn', - text: 'Cannot kick other mods, how rude' - }, socket); - } else { - newChannel = Math.random().toString(36).substr(2, 8); - badClients[i].channel = newChannel; - - // inform mods with where they were sent - server.broadcast({ - cmd: 'info', - text: `${badClients[i].nick} was banished to ?${newChannel}` - }, { channel: socket.channel, uType: 'mod' }); - - kicked.push(badClients[i].nick); - console.log(`${socket.nick} [${socket.trip}] kicked ${badClients[i].nick} in ${socket.channel}`); - } - } - - if (kicked.length === 0) { - return; - } - - // broadcast client leave event - for (let i = 0, j = kicked.length; i < j; i++) { - server.broadcast({ - cmd: 'onlineRemove', - nick: kicked[i] - }, { channel: socket.channel }); - } - - // publicly broadcast kick event - server.broadcast({ - cmd: 'info', - text: `Kicked ${kicked.join(', ')}` - }, { channel: socket.channel, uType: 'user' }); - - core.managers.stats.increment('users-kicked', kicked.length); -}; - -exports.requiredData = ['nick']; - -exports.info = { - name: 'kick', - usage: 'kick {nick}', - description: 'Silently forces target client(s) into another channel. `nick` may be string or array of strings' -}; \ No newline at end of file diff --git a/server/commands/mod/unban.js b/server/commands/mod/unban.js deleted file mode 100644 index e82f0b9..0000000 --- a/server/commands/mod/unban.js +++ /dev/null @@ -1,55 +0,0 @@ -/* - Description: Removes a target ip from the ratelimiter -*/ - -exports.run = async (core, server, socket, data) => { - if (socket.uType == 'user') { - // ignore if not mod or admin - return; - } - - if (typeof data.ip !== 'string' && typeof data.hash !== 'string') { - server.reply({ - cmd: 'warn', - text: "hash:'targethash' or ip:'1.2.3.4' is required" - }, socket); - - return; - } - - let mode, target; - - if (typeof data.ip === 'string') { - mode = 'ip'; - target = data.ip; - } else { - mode = 'hash'; - target = data.hash; - } - - server._police.pardon(target); - - if (mode === 'ip') { - target = server.getSocketHash(target); - } - - console.log(`${socket.nick} [${socket.trip}] unbanned ${target} in ${socket.channel}`); - - server.reply({ - cmd: 'info', - text: `Unbanned ${target}` - }, socket); - - server.broadcast({ - cmd: 'info', - text: `${socket.nick} unbanned: ${target}` - }, { uType: 'mod' }); - - core.managers.stats.decrement('users-banned'); -}; - -exports.info = { - name: 'unban', - usage: 'unban {[ip || hash]}', - description: 'Removes target ip from the ratelimiter' -}; \ No newline at end of file diff --git a/server/core/rateLimiter.js b/server/core/rateLimiter.js deleted file mode 100644 index 0c2a384..0000000 --- a/server/core/rateLimiter.js +++ /dev/null @@ -1,103 +0,0 @@ -/** - * Tracks frequency of occurances based on `id` (remote address), then allows or - * denies command execution based on comparison with `threshold` - * - * Version: v2.0.0 - * Developer: Marzavec ( https://github.com/marzavec ) - * License: WTFPL ( http://www.wtfpl.net/txt/copying/ ) - * - */ - -class Police { - /** - * Create a ratelimiter instance. - */ - constructor () { - this._records = {}; - this._halflife = 30 * 1000; // milliseconds - this._threshold = 25; - this._hashes = []; - } - - /** - * Finds current score by `id` - * - * @param {String} id target id / address - * @public - * - * @memberof Police - */ - search (id) { - let record = this._records[id]; - - if (!record) { - record = this._records[id] = { - time: Date.now(), - score: 0 - } - } - - return record; - } - - /** - * Adjusts the current ratelimit score by `deltaScore` - * - * @param {String} id target id / address - * @param {Number} deltaScore amount to adjust current score by - * @public - * - * @memberof Police - */ - frisk (id, deltaScore) { - let record = this.search(id); - - if (record.arrested) { - return true; - } - - record.score *= Math.pow(2, -(Date.now() - record.time ) / this._halflife); - record.score += deltaScore; - record.time = Date.now(); - - if (record.score >= this._threshold) { - return true; - } - - return false; - } - - /** - * Statically set server to no longer accept traffic from `id` - * - * @param {String} id target id / address - * @public - * - * @memberof Police - */ - arrest (id, hash) { - let record = this.search(id); - - record.arrested = true; - this._hashes[hash] = id; - } - - /** - * Remove statically assigned limit from `id` - * - * @param {String} id target id / address - * @public - * - * @memberof Police - */ - pardon (id) { - if (typeof this._hashes[id] !== 'undefined') { - id = this._hashes[id]; - } - - let record = this.search(id); - record.arrested = false; - } -} - -module.exports = Police; diff --git a/server/core/server.js b/server/core/server.js deleted file mode 100644 index 855aeba..0000000 --- a/server/core/server.js +++ /dev/null @@ -1,282 +0,0 @@ -/** - * Main websocket server handling communications and connection events - * - * Version: v2.0.0 - * Developer: Marzavec ( https://github.com/marzavec ) - * License: WTFPL ( http://www.wtfpl.net/txt/copying/ ) - * - */ - -const wsServer = require('ws').Server; -const socketReady = require('ws').OPEN; -const crypto = require('crypto'); -const ipSalt = (Math.random().toString(36).substring(2, 16) + Math.random().toString(36).substring(2, (Math.random() * 16))).repeat(16); -const Police = require('./rateLimiter'); -const pulseSpeed = 16000; // ping all clients every X ms - -class server extends wsServer { - /** - * Create a HackChat server instance. - * - * @param {Object} core Reference to the global core object - */ - constructor (core) { - super({ port: core.config.websocketPort }); - - this._core = core; - this._police = new Police(); - this._cmdBlacklist = {}; - this._heartBeat = setInterval(((data) => { - this.beatHeart(); - }).bind(this), pulseSpeed); - - this.on('error', (err) => { - this.handleError('server', err); - }); - - this.on('connection', (socket, request) => { - this.newConnection(socket, request); - }); - } - - /** - * Send empty `ping` frame to each client - * - */ - beatHeart () { - let targetSockets = this.findSockets({}); - - if (targetSockets.length === 0) { - return; - } - - for (let i = 0, l = targetSockets.length; i < l; i++) { - try { - if (targetSockets[i].readyState === socketReady) { - targetSockets[i].ping(); - } - } catch (e) { } - } - } - - /** - * Bind listeners for the new socket created on connection to this class - * - * @param {Object} socket New socket object - * @param {Object} request Initial headers of the new connection - */ - newConnection (socket, request) { - socket.remoteAddress = request.headers['x-forwarded-for'] || request.connection.remoteAddress; - - socket.on('message', ((data) => { - this.handleData(socket, data); - }).bind(this)); - - socket.on('close', (() => { - this.handleClose(socket); - }).bind(this)); - - socket.on('error', ((err) => { - this.handleError(socket, err); - }).bind(this)); - } - - /** - * Handle incoming messages from clients, parse and check command, then hand-off - * - * @param {Object} socket Calling socket object - * @param {String} data Message sent from client - */ - handleData (socket, data) { - // Don't penalize yet, but check whether IP is rate-limited - if (this._police.frisk(socket.remoteAddress, 0)) { - this.reply({ cmd: 'warn', text: "Your IP is being rate-limited or blocked." }, socket); - - return; - } - - // Penalize here, but don't do anything about it - this._police.frisk(socket.remoteAddress, 1); - - // ignore ridiculously large packets - if (data.length > 65536) { - return; - } - - // Start sent data verification - var args = null; - try { - args = JSON.parse(data); - } catch (e) { - // Client sent malformed json, gtfo - socket.close(); - } - - if (args === null) { - return; - } - - if (typeof args.cmd === 'undefined' || args.cmd == 'ping') { - return; - } - - if (typeof args.cmd !== 'string') { - return; - } - - if (typeof socket.channel === 'undefined' && args.cmd !== 'join') { - return; - } - - if (typeof this._cmdBlacklist[args.cmd] === 'function') { - return; - } - - // Finished verification, pass to command modules - this._core.commands.handleCommand(this, socket, args); - } - - /** - * Handle socket close from clients - * - * @param {Object} socket Closing socket object - */ - handleClose (socket) { - this._core.commands.handleCommand(this, socket, { cmd: 'disconnect' }); - } - - /** - * "Handle" server or socket errors - * - * @param {Object||String} socket Calling socket object, or 'server' - * @param {String} err The sad stuff - */ - handleError (socket, err) { - console.log(`Server error: ${err}`); - } - - /** - * Send data payload to specific socket/client - * - * @param {Object} data Object to convert to json for transmission - * @param {Object} socket The target client - */ - send (data, socket) { - // Add timestamp to command - data.time = Date.now(); - - try { - if (socket.readyState === socketReady) { - socket.send(JSON.stringify(data)); - } - } catch (e) { } - } - - /** - * Overload function for `this.send()` - * - * @param {Object} data Object to convert to json for transmission - * @param {Object} socket The target client - */ - reply (data, socket) { - this.send(data, socket); - } - - /** - * Finds sockets/clients that meet the filter requirements, then passes the data to them - * - * @param {Object} data Object to convert to json for transmission - * @param {Object} filter see `this.findSockets()` - */ - broadcast (data, filter) { - let targetSockets = this.findSockets(filter); - - if (targetSockets.length === 0) { - return false; - } - - for (let i = 0, l = targetSockets.length; i < l; i++) { - this.send(data, targetSockets[i]); - } - - return true; - } - - /** - * Finds sockets/clients that meet the filter requirements, returns result as array - * - * @param {Object} data Object to convert to json for transmission - * @param {Object} filter The socket must of equal or greater attribs matching `filter` - * = {} // matches all - * = { channel: 'programming' } // matches any socket where (`socket.channel` === 'programming') - * = { channel: 'programming', nick: 'Marzavec' } // matches any socket where (`socket.channel` === 'programming' && `socket.nick` === 'Marzavec') - */ - findSockets (filter) { - let filterAttribs = Object.keys(filter); - let reqCount = filterAttribs.length; - let curMatch; - let matches = []; - for ( let socket of this.clients ) { - curMatch = 0; - - for (let i = 0; i < reqCount; i++) { - if (typeof socket[filterAttribs[i]] !== 'undefined') { - switch(typeof filter[filterAttribs[i]]) { - case 'object': { - if (Array.isArray(filter[filterAttribs[i]])) { - if (filter[filterAttribs[i]].indexOf(socket[filterAttribs[i]]) !== -1) { - curMatch++; - } - } else { - if (socket[filterAttribs[i]] === filter[filterAttribs[i]]) { - curMatch++; - } - } - break; - } - - case 'function': { - if (filter[filterAttribs[i]](socket[filterAttribs[i]])) { - curMatch++; - } - break; - } - - default: { - if (socket[filterAttribs[i]] === filter[filterAttribs[i]]) { - curMatch++; - } - break; - } - } - } - } - - if (curMatch === reqCount) { - matches.push(socket); - } - } - - return matches; - } - - /** - * Encrypts target socket's remote address using non-static variable length salt - * encodes and shortens the output, returns that value - * - * @param {Object||String} target Either the target socket or ip as string - */ - getSocketHash (target) { - let sha = crypto.createHash('sha256'); - - if (typeof target === 'string') { - sha.update(target + ipSalt); - } else { - sha.update(target.remoteAddress + ipSalt); - } - - return sha.digest('base64').substr(0, 15); - } -} - -module.exports = server; diff --git a/server/managers/commands.js b/server/managers/commands.js deleted file mode 100644 index c38fb4d..0000000 --- a/server/managers/commands.js +++ /dev/null @@ -1,239 +0,0 @@ -/** - * Commands / protocol manager- loads, validates and handles command execution - * - * Version: v2.0.0 - * Developer: Marzavec ( https://github.com/marzavec ) - * License: WTFPL ( http://www.wtfpl.net/txt/copying/ ) - * - */ - -const path = require('path'); -const chalk = require('chalk'); -const didYouMean = require('didyoumean2'); - -class CommandManager { - /** - * Create a `CommandManager` instance for handling commands/protocol - * - * @param {Object} core Reference to the global core object - */ - constructor (core) { - this.core = core; - this._commands = []; - this._categories = []; - } - - /** - * (Re)initializes name spaces for commands and starts load routine - * - */ - loadCommands () { - this._commands = []; - this._categories = []; - - const core = this.core; - - const commandImports = core.managers.dynamicImports.getImport('src/commands'); - let cmdErrors = ''; - Object.keys(commandImports).forEach(file => { - let command = commandImports[file]; - let name = path.basename(file); - cmdErrors += this._validateAndLoad(command, file, name); - }); - - return cmdErrors; - } - - /** - * Checks the module after having been `require()`ed in and reports errors - * - * @param {Object} command reference to the newly loaded object - * @param {String} file file path to the module - * @param {String} name command (`cmd`) name - */ - _validateAndLoad (command, file, name) { - let error = this._validateCommand(command); - - if (error) { - let errText = `Failed to load '${name}': ${error}`; - console.log(errText); - return errText; - } - - if (!command.category) { - let base = path.join(this.core.managers.dynamicImports.base, 'commands'); - - let category = 'Uncategorized'; - if (file.indexOf(path.sep) > -1) { - category = path.dirname(path.relative(base, file)) - .replace(new RegExp(path.sep.replace('\\', '\\\\'), 'g'), '/'); - } - - command.info.category = category; - - if (this._categories.indexOf(category) === -1) - this._categories.push(category); - } - - if (typeof command.init === 'function') { - try { - command.init(this.core); - } catch (err) { - let errText = `Failed to initialize '${name}': ${err}`; - console.log(errText); - return errText; - } - } - - this._commands.push(command); - - return ''; - } - - /** - * Checks the module after having been `require()`ed in and reports errors - * - * @param {Object} object reference to the newly loaded object - */ - _validateCommand (object) { - if (typeof object !== 'object') - return 'command setup is invalid'; - - if (typeof object.run !== 'function') - return 'run function is missing'; - - if (typeof object.info !== 'object') - return 'info object is missing'; - - if (typeof object.info.name !== 'string') - return 'info object is missing a valid name field'; - - return null; - } - - /** - * Pulls all command names from a passed `category` - * - * @param {String} category reference to the newly loaded object - */ - all (category) { - return !category ? this._commands : this._commands.filter(c => c.info.category.toLowerCase() === category.toLowerCase()); - } - - /** - * Pulls all category names - * - */ - categories () { - return this._categories; - } - - /** - * Pulls command by name or alia(s) - * - * @param {String} name name or alias of command - */ - get (name) { - return this.findBy('name', name) - || this._commands.find(command => command.info.aliases instanceof Array && command.info.aliases.indexOf(name) > -1); - } - - /** - * Pulls command by arbitrary search of the `module.info` attribute - * - * @param {String} key name or alias of command - * @param {String} value name or alias of command - */ - findBy (key, value) { - return this._commands.find(c => c.info[key] === value); - } - - /** - * Finds and executes the requested command, or fails with semi-intelligent error - * - * @param {Object} server main server reference - * @param {Object} socket calling socket reference - * @param {Object} data command structure passed by socket (client) - */ - handleCommand (server, socket, data) { - // Try to find command first - let command = this.get(data.cmd); - - if (command) { - return this.execute(command, server, socket, data); - } else { - // Then fail with helpful (sorta) message - return this._handleFail(server, socket, data); - } - } - - /** - * Requested command failure handler, attempts to find command and reports back - * - * @param {Object} server main server reference - * @param {Object} socket calling socket reference - * @param {Object} data command structure passed by socket (client) - */ - _handleFail(server, socket, data) { - const maybe = didYouMean(data.cmd, this.all().map(c => c.info.name), { - threshold: 5, - thresholdType: 'edit-distance' - }); - - if (maybe) { - // Found a suggestion, pass it on to their dyslexic self - return server.reply({ - cmd: 'warn', - text: `Command not found, did you mean: \`${maybe}\`?` - }, socket); - } - - // Request so mangled that I don't even, silently fail - return; - } - - /** - * Attempt to execute the requested command, fail if err or bad params - * - * @param {Object} command target command module - * @param {Object} server main server reference - * @param {Object} socket calling socket reference - * @param {Object} data command structure passed by socket (client) - */ - async execute(command, server, socket, data) { - if (typeof command.requiredData !== 'undefined') { - let missing = []; - for (let i = 0, len = command.requiredData.length; i < len; i++) { - if (typeof data[command.requiredData[i]] === 'undefined') - missing.push(command.requiredData[i]); - } - - if (missing.length > 0) { - let errText = `Failed to execute '${command.info.name}': missing required ${missing.join(', ')}\n\n`; - - server.reply({ - cmd: 'warn', - text: errText - }, socket); - - return null; - } - } - - try { - return await command.run(this.core, server, socket, data); - } catch (err) { - let errText = `Failed to execute '${command.info.name}': ${err}`; - console.log(errText); - - server.reply({ - cmd: 'warn', - text: errText - }, socket); - - return null; - } - } -} - -module.exports = CommandManager; diff --git a/server/managers/config.js b/server/managers/config.js deleted file mode 100644 index 2865d00..0000000 --- a/server/managers/config.js +++ /dev/null @@ -1,224 +0,0 @@ -/** - * Server configuration manager, handling loading, creation, parsing and saving - * of the main config.json file - * - * Version: v2.0.0 - * Developer: Marzavec ( https://github.com/marzavec ) - * License: WTFPL ( http://www.wtfpl.net/txt/copying/ ) - * - */ - -const stripIndents = require('common-tags').stripIndents; -const dateFormat = require('dateformat'); -const chalk = require('chalk'); -const fse = require('fs-extra'); -const prompt = require('prompt'); -const path = require('path'); -const deSync = require('deasync'); - -class ConfigManager { - /** - * Create a `ConfigManager` instance for (re)loading classes and config - * - * @param {Object} core reference to the global core object - * @param {String} base executing directory name; __dirname - * @param {Object} dynamicImports dynamic import engine reference - */ - constructor (core, base, dynamicImports) { - this._core = core; - this._base = base; - - this._configPath = path.resolve(base, 'config/config.json'); - - this._dynamicImports = dynamicImports; - } - - /** - * Pulls both core config questions along with any optional config questions, - * used in building the initial config.json or re-building it. - * - * @param {Object} currentConfig an object containing current server settings, if any - * @param {Object} optionalConfigs optional (non-core) module config - */ - getQuestions (currentConfig, optionalConfigs) { - // core server setup questions - const questions = { - properties: { - adminName: { - pattern: /^"?[a-zA-Z0-9_]+"?$/, - type: 'string', - message: 'Nicks can only contain letters, numbers and underscores', - required: !currentConfig.adminName, - default: currentConfig.adminName, - before: value => value.replace(/"/g, '') - }, - adminPass: { - type: 'string', - required: !currentConfig.adminPass, - default: currentConfig.adminPass, - hidden: true, - replace: '*', - }, - websocketPort: { - type: 'number', - required: !currentConfig.websocketPort, - default: currentConfig.websocketPort || 6060 - }, - tripSalt: { - type: 'string', - required: !currentConfig.tripSalt, - default: currentConfig.tripSalt, - hidden: true, - replace: '*', - } - } - }; - - // non-core server setup questions, for future plugin support - Object.keys(optionalConfigs).forEach(configName => { - const config = optionalConfigs[configName]; - const question = config.getQuestion(currentConfig, configName); - - if (!question) { - return; - } - - question.description = (question.description || configName) + ' (Optional)'; - questions.properties[configName] = question; - }); - - return questions; - } - - /** - * `load` function overload, only blocking - * - */ - loadSync () { - let conf = {}; - conf = this.load(); - - // trip salt is the last core config question, wait until it's been populated - // TODO: update this to work with new plugin support - while(conf === null || typeof conf.tripSalt === 'undefined') { - deSync.sleep(100); - } - - return conf; - } - - /** - * (Re)builds the config.json (main server config), or loads the config into mem - * if rebuilding, process will exit- this is to allow a process manager to take over - * - * @param {Boolean} reconfiguring set to true by `scripts/configure.js`, will exit if true - */ - load (reconfiguring = false) { - if (reconfiguring || !fse.existsSync(this._configPath)) { - // gotta have that sexy console - console.log(stripIndents` - ${chalk.magenta('°º¤ø,¸¸,ø¤º°`°º¤ø,¸,ø¤°º¤ø,¸¸,ø¤º°`°º¤ø,¸°º¤ø,¸¸,ø¤º°`°º¤ø')} - ${chalk.gray('--------------(') + chalk.white(' HackChat Setup Wizard v1.0 ') + chalk.gray(')--------------')} - ${chalk.magenta('°º¤ø,¸¸,ø¤º°`°º¤ø,¸,ø¤°º¤ø,¸¸,ø¤º°`°º¤ø,¸°º¤ø,¸¸,ø¤º°`°º¤ø')} - - For advanced setup, see the HackChat wiki at: - ${chalk.green('https://github.com/')} - - ${chalk.white('Note:')} ${chalk.green('npm/yarn run config')} will re-run this utility. - - You will now be asked for the following: - - ${chalk.magenta('Admin Name')}, the initial admin username - - ${chalk.magenta('Admin Pass')}, the initial admin password - - ${chalk.magenta(' Port')}, the port for the websocket - - ${chalk.magenta(' Salt')}, the salt for username trip - \u200b - `); - - let currentConfig = this._config || {}; - if (reconfiguring && fse.existsSync(this._configPath)) { - this._backup(); - currentConfig = fse.readJSONSync(this._configPath); - } - - prompt.get(this.getQuestions(currentConfig, this._dynamicImports.optionalConfigs), (err, res) => { - if (typeof res.mods === 'undefined') { - res.mods = []; - } - - if (err) { - console.error(err); - process.exit(666); // SPOOKY! - } - - try { - fse.outputJsonSync(this._configPath, res); - } catch (e) { - console.error(`Couldn't write config to ${this._configPath}\n${e.stack}`); - if (!reconfiguring) { - process.exit(666); // SPOOKY! - } - } - - console.log('Config generated! You may now start the server normally.') - - process.exit(reconfiguring ? 0 : 42); - }); - - return null; - } - - this._config = fse.readJSONSync(this._configPath); - - return this._config; - } - - /** - * Creates backup of current config into _configPath - * - */ - _backup () { - const backupPath = `${this._configPath}.${dateFormat('dd-mm-yy-HH-MM-ss')}.bak`; - fse.copySync(this._configPath, backupPath); - - return backupPath; - } - - /** - * First makes a backup of the current `config.json`, then writes current config - * to disk - * - */ - save () { - const backupPath = this._backup(); - - if (!fse.existsSync(this._configPath)){ - fse.mkdirSync(this._configPath); - } - - try { - fse.writeJSONSync(this._configPath, this._config); - fse.removeSync(backupPath); - - return true; - } catch (err) { - console.log(`Failed to save config file: ${err}`); - - return false; - } - } - - /** - * Updates current config[`key`] with `value` then writes changes to disk - * - * @param {*} key arbitrary configuration key - * @param {*} value new value to change `key` to - */ - set (key, value) { - const realKey = `${key}`; - this._config[realKey] = value; - - this.save(); - } -} - -module.exports = ConfigManager; diff --git a/server/managers/imports-manager.js b/server/managers/imports-manager.js deleted file mode 100644 index d8b2144..0000000 --- a/server/managers/imports-manager.js +++ /dev/null @@ -1,148 +0,0 @@ -/** - * Import managment base, used to load commands/protocol and configuration objects - * - * Version: v2.0.0 - * Developer: Marzavec ( https://github.com/marzavec ) - * License: WTFPL ( http://www.wtfpl.net/txt/copying/ ) - * - */ - -const read = require('readdir-recursive'); -const path = require('path'); - -class ImportsManager { - /** - * Create a `ImportsManager` instance for (re)loading classes and config - * - * @param {Object} core reference to the global core object - * @param {String} base executing directory name; __dirname - */ - constructor (core, base) { - this._core = core; - this._base = base; - - this._imports = {}; - this._optionalConfigs = {}; - } - - /** - * Pull core reference - * - * @type {Object} readonly - */ - get core () { - return this._core; - } - - /** - * Pull base path that all imports are required in from - * - * @type {String} readonly - */ - get base () { - return this._base; - } - - /** - * Pull optional (none-core) config options - * - * @type {Object} - */ - get optionalConfigs () { - return Object.assign({}, this._optionalConfigs); - } - - /** - * Initialize this class and start loading target directories - * - */ - init () { - let errorText = ''; - ImportsManager.load_dirs.forEach(dir => { - errorText += this.loadDir(dir); - }); - - return errorText; - } - - /** - * Gather all js files from target directory, then verify and load - * - * @param {String} dirName The name of the dir to load, relative to the _base path. - */ - loadDir (dirName) { - const dir = path.resolve(this._base, dirName); - - let errorText = ''; - try { - read.fileSync(dir).forEach(file => { - const basename = path.basename(file); - if (basename.startsWith('_') || !basename.endsWith('.js')) return; - - let imported; - try { - imported = require(file); - } catch (e) { - let err = `Unable to load modules from ${dirName} (${path.relative(dir, file)})\n${e}`; - errorText += err; - console.error(err); - return errorText; - } - - if (imported.configs) { - imported.configs.forEach(config => { - this._optionalConfigs[config.name] = config; - }); - } - - if (!this._imports[dirName]) { - this._imports[dirName] = {}; - } - - this._imports[dirName][file] = imported; - }); - } catch (e) { - let err = `Unable to load modules from ${dirName}\n${e}`; - errorText += err; - console.error(err); - return errorText; - } - - return errorText; - } - - /** - * Unlink references to each loaded module, pray to google that gc knows it's job, - * then reinitialize this class to start the reload - * - * @param {String} dirName The name of the dir to load, relative to the _base path. - */ - reloadDirCache (dirName) { - Object.keys(this._imports[dirName]).forEach((mod) => { - delete require.cache[require.resolve(mod)]; - }); - - return this.init(); - } - - /** - * Pull reference to imported modules that were imported from dirName, or - * load required directory if not found - * - * @param {String} dirName The name of the dir to load, relative to the _base path. - */ - getImport (dirName) { - let imported = this._imports[dirName]; - - if (!imported) { - this.loadDir(dirName); - } - - return Object.assign({}, this._imports[dirName]); - } -} - -// automagically loaded directorys on instantiation -ImportsManager.load_dirs = ['src/commands']; - -module.exports = ImportsManager; diff --git a/server/managers/index.js b/server/managers/index.js deleted file mode 100644 index 2fac8fb..0000000 --- a/server/managers/index.js +++ /dev/null @@ -1,6 +0,0 @@ -module.exports = { - CommandManager: require('./commands'), - Config: require('./config'), - ImportsManager: require('./imports-manager'), - Stats: require('./stats') -}; diff --git a/server/managers/stats.js b/server/managers/stats.js deleted file mode 100644 index 20f1ae3..0000000 --- a/server/managers/stats.js +++ /dev/null @@ -1,59 +0,0 @@ -/** - * Simple generic stats collection script for events occurances (etc) - * - * Version: v2.0.0 - * Developer: Marzavec ( https://github.com/marzavec ) - * License: WTFPL ( http://www.wtfpl.net/txt/copying/ ) - * - */ - -class Stats { - /** - * Create a stats instance. - * - */ - constructor () { - this._stats = {}; - } - - /** - * Retrieve value of arbitrary `key` reference - * - * @param {String} key Reference to the arbitrary store name - */ - get (key) { - return this._stats[key]; - } - - /** - * Set value of arbitrary `key` reference - * - * @param {String} key Reference to the arbitrary store name - * @param {Number} value New value for `key` - */ - set (key, value) { - this._stats[key] = value; - } - - /** - * Increase value of arbitrary `key` reference, by 1 or `amount` - * - * @param {String} key Reference to the arbitrary store name - * @param {Number} amount Value to increase `key` by, or 1 if omitted - */ - increment (key, amount) { - this.set(key, (this.get(key) || 0) + (amount || 1)); - } - - /** - * Reduce value of arbitrary `key` reference, by 1 or `amount` - * - * @param {String} key Reference to the arbitrary store name - * @param {Number} amount Value to decrease `key` by, or 1 if omitted - */ - decrement (key, amount) { - this.set(key, (this.get(key) || 0) - (amount || 1)); - } -} - -module.exports = Stats; diff --git a/server/scripts/configure.js b/server/scripts/configure.js deleted file mode 100644 index 0ecd858..0000000 --- a/server/scripts/configure.js +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Server configuration script, used reconfiguring server options - * - * Version: v2.0.0 - * Developer: Marzavec ( https://github.com/marzavec ) - * License: WTFPL ( http://www.wtfpl.net/txt/copying/ ) - * - */ - -'use strict'; - -// import required classes -const path = require('path'); -const ImportsManager = require('../managers/imports-manager'); -const ConfigManager = require('../managers/config'); - -// import and initialize configManager & dependencies -const importManager = new ImportsManager(null, path.join(__dirname, '../..')); -importManager.init(); -const configManager = new ConfigManager(null, path.join(__dirname, '../..'), importManager); - -// execute config load with `reconfiguring` flag set to true -configManager.load(true); diff --git a/server/scripts/debug.js b/server/scripts/debug.js deleted file mode 100644 index 3a97d9f..0000000 --- a/server/scripts/debug.js +++ /dev/null @@ -1,18 +0,0 @@ -/** - * Server debug test script - * - * Version: v2.0.0 - * Developer: Marzavec ( https://github.com/marzavec ) - * License: WTFPL ( http://www.wtfpl.net/txt/copying/ ) - * - */ - -'use strict'; - -// import required classes -const path = require('path'); -const ConfigManager = require('../managers/config'); - -// begin tests -// TODO: TODO -// TODO diff --git a/server/scripts/dev.js b/server/scripts/dev.js deleted file mode 100644 index 5049b84..0000000 --- a/server/scripts/dev.js +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Server development script - * - * Version: v2.0.0 - * Developer: Marzavec ( https://github.com/marzavec ) - * License: WTFPL ( http://www.wtfpl.net/txt/copying/ ) - * - */ - -'use strict'; - -// import required classes - - -// begin tests -// TODO: TODO -// TODO diff --git a/server/src/commands/admin/addmod.js b/server/src/commands/admin/addmod.js new file mode 100644 index 0000000..4c13b22 --- /dev/null +++ b/server/src/commands/admin/addmod.js @@ -0,0 +1,47 @@ +/* + Description: Adds the target trip to the mod list then elevates the uType +*/ + +exports.run = async (core, server, socket, data) => { + if (socket.uType != 'admin') { + // ignore if not admin + return; + } + + let mod = { + trip: data.trip + } + + core.config.mods.push(mod); // purposely not using `config.set()` to avoid auto-save + + let newMod = server.findSockets({ trip: data.trip }); + + if (newMod.length !== 0) { + for (let i = 0, l = newMod.length; i < l; i++) { + newMod[i].uType = 'mod'; + + server.send({ + cmd: 'info', + text: 'You are now a mod.' + }, newMod[i]); + } + } + + server.reply({ + cmd: 'info', + text: `Added mod trip: ${data.trip}` + }, socket); + + server.broadcast({ + cmd: 'info', + text: `Added mod trip: ${data.trip}` + }, { uType: 'mod' }); +}; + +exports.requiredData = ['trip']; + +exports.info = { + name: 'addmod', + usage: 'addmod {trip}', + description: 'Adds target trip to the config as a mod and upgrades the socket type' +}; diff --git a/server/src/commands/admin/listusers.js b/server/src/commands/admin/listusers.js new file mode 100644 index 0000000..a539a3c --- /dev/null +++ b/server/src/commands/admin/listusers.js @@ -0,0 +1,38 @@ +/* + Description: Outputs all current channels and their user nicks +*/ + +exports.run = async (core, server, socket, data) => { + if (socket.uType != 'admin') { + // ignore if not admin + return; + } + + let channels = {}; + for (var client of server.clients) { + if (client.channel) { + if (!channels[client.channel]) { + channels[client.channel] = []; + } + channels[client.channel].push(client.nick); + } + } + + let lines = []; + for (let channel in channels) { + lines.push(`?${channel} ${channels[channel].join(", ")}`); + } + + let text = ''; + text += lines.join("\n"); + + server.reply({ + cmd: 'info', + text: text + }, socket); +}; + +exports.info = { + name: 'listusers', + description: 'Outputs all current channels and sockets in those channels' +}; diff --git a/server/src/commands/admin/reload.js b/server/src/commands/admin/reload.js new file mode 100644 index 0000000..e2cfbe6 --- /dev/null +++ b/server/src/commands/admin/reload.js @@ -0,0 +1,35 @@ +/* + Description: Clears and resets the command modules, outputting any errors +*/ + +exports.run = async (core, server, socket, data) => { + if (socket.uType != 'admin') { + // ignore if not admin + return; + } + + let loadResult = core.managers.dynamicImports.reloadDirCache('src/commands'); + loadResult += core.commands.loadCommands(); + + if (loadResult == '') { + loadResult = `Loaded ${core.commands._commands.length} commands, 0 errors`; + } else { + loadResult = `Loaded ${core.commands._commands.length} commands, error(s): ${loadResult}`; + } + + server.reply({ + cmd: 'info', + text: loadResult + }, socket); + + server.broadcast({ + cmd: 'info', + text: loadResult + }, { uType: 'mod' }); +}; + +exports.info = { + name: 'reload', + description: '(Re)loads any new commands into memory, outputs errors if any' +}; + diff --git a/server/src/commands/admin/saveconfig.js b/server/src/commands/admin/saveconfig.js new file mode 100644 index 0000000..ed3a312 --- /dev/null +++ b/server/src/commands/admin/saveconfig.js @@ -0,0 +1,36 @@ +/* + Description: Writes any changes to the config to the disk +*/ + +exports.run = async (core, server, socket, data) => { + if (socket.uType != 'admin') { + // ignore if not admin + return; + } + + let saveResult = core.managers.config.save(); + + if (!saveResult) { + server.reply({ + cmd: 'warn', + text: 'Failed to save config, check logs.' + }, client); + + return; + } + + server.reply({ + cmd: 'info', + text: 'Config saved!' + }, socket); + + server.broadcast({ + cmd: 'info', + text: 'Config saved!' + }, { uType: 'mod' }); +}; + +exports.info = { + name: 'saveconfig', + description: 'Saves current config' +}; diff --git a/server/src/commands/admin/shout.js b/server/src/commands/admin/shout.js new file mode 100644 index 0000000..1358dd9 --- /dev/null +++ b/server/src/commands/admin/shout.js @@ -0,0 +1,23 @@ +/* + Description: Emmits a server-wide message as `info` +*/ + +exports.run = async (core, server, socket, data) => { + if (socket.uType != 'admin') { + // ignore if not admin + return; + } + + server.broadcast( { + cmd: 'info', + text: `Server Notice: ${data.text}` + }, {}); +}; + +exports.requiredData = ['text']; + +exports.info = { + name: 'shout', + usage: 'shout {text}', + description: 'Displays passed text to every client connected' +}; \ No newline at end of file diff --git a/server/src/commands/core/changenick.js b/server/src/commands/core/changenick.js new file mode 100644 index 0000000..4041bb0 --- /dev/null +++ b/server/src/commands/core/changenick.js @@ -0,0 +1,88 @@ +/* + Description: Generates a semi-unique channel name then broadcasts it to each client +*/ + +const verifyNickname = (nick) => { + return /^[a-zA-Z0-9_]{1,24}$/.test(nick); +}; + +exports.run = async (core, server, socket, data) => { + if (server._police.frisk(socket.remoteAddress, 6)) { + server.reply({ + cmd: 'warn', + text: 'You are changing nicknames too fast. Wait a moment before trying again.' + }, socket); + + return; + } + + if (typeof data.nick !== 'string') { + return; + } + + let newNick = data.nick.trim(); + + if (!verifyNickname(newNick)) { + server.reply({ + cmd: 'warn', + text: 'Nickname must consist of up to 24 letters, numbers, and underscores' + }, socket); + + return; + } + + if (newNick.toLowerCase() == core.config.adminName.toLowerCase()) { + server._police.frisk(socket.remoteAddress, 4); + + server.reply({ + cmd: 'warn', + text: 'Gtfo' + }, socket); + + return; + } + + let userExists = server.findSockets({ + channel: socket.channel, + nick: (targetNick) => targetNick.toLowerCase() === newNick.toLowerCase() + }); + + if (userExists.length > 0) { + // That nickname is already in that channel + server.reply({ + cmd: 'warn', + text: 'Nickname taken' + }, socket); + + return; + } + + let peerList = server.findSockets({ channel: socket.channel }); + let leaveNotice = { + cmd: 'onlineRemove', + nick: socket.nick + }; + let joinNotice = { + cmd: 'onlineAdd', + nick: newNick, + trip: socket.trip || 'null', + hash: server.getSocketHash(socket) + }; + + server.broadcast( leaveNotice, { channel: socket.channel }); + server.broadcast( joinNotice, { channel: socket.channel }); + server.broadcast( { + cmd: 'info', + text: `${socket.nick} is now ${newNick}` + }, { channel: socket.channel }); + + socket.nick = newNick; +}; + +exports.requiredData = ['nick']; + +exports.info = { + name: 'changenick', + usage: 'changenick {nick}', + description: 'This will change your current connections nickname' +}; diff --git a/server/src/commands/core/chat.js b/server/src/commands/core/chat.js new file mode 100644 index 0000000..bce6adb --- /dev/null +++ b/server/src/commands/core/chat.js @@ -0,0 +1,62 @@ +/* + Description: Rebroadcasts any `text` to all clients in a `channel` +*/ + +const parseText = (text) => { + if (typeof text !== 'string') { + return false; + } + + // strip newlines from beginning and end + text = text.replace(/^\s*\n|^\s+$|\n\s*$/g, ''); + // replace 3+ newlines with just 2 newlines + text = text.replace(/\n{3,}/g, "\n\n"); + + return text; +}; + +exports.run = async (core, server, socket, data) => { + let text = parseText(data.text); + if (!text) { + // lets not send objects or empty text, yea? + return; + } + + let score = text.length / 83 / 4; + if (server._police.frisk(socket.remoteAddress, score)) { + server.reply({ + cmd: 'warn', + text: 'You are sending too much text. Wait a moment and try again.\nPress the up arrow key to restore your last message.' + }, socket); + + return; + } + + let payload = { + cmd: 'chat', + nick: socket.nick, + text: text + }; + + if (socket.uType == 'admin') { + payload.admin = true; + } else if (socket.uType == 'mod') { + payload.mod = true; + } + + if (socket.trip) { + payload.trip = socket.trip; + } + + server.broadcast( payload, { channel: socket.channel }); + + core.managers.stats.increment('messages-sent'); +}; + +exports.requiredData = ['text']; + +exports.info = { + name: 'chat', + usage: 'chat {text}', + description: 'Broadcasts passed `text` field to the calling users channel' +}; \ No newline at end of file diff --git a/server/src/commands/core/disconnect.js b/server/src/commands/core/disconnect.js new file mode 100644 index 0000000..9b54214 --- /dev/null +++ b/server/src/commands/core/disconnect.js @@ -0,0 +1,21 @@ +/* + Description: This module will be directly called by the server event handler + when a socket connection is closed or lost. It can calso be called + by a client to have the connection severed. +*/ + +exports.run = async (core, server, socket, data) => { + if (socket.channel) { + server.broadcast({ + cmd: 'onlineRemove', + nick: socket.nick + }, { channel: socket.channel }); + } + + socket.terminate(); +}; + +exports.info = { + name: 'disconnect', + description: 'Event handler or force disconnect (if your into that kind of thing)' +}; \ No newline at end of file diff --git a/server/src/commands/core/help.js b/server/src/commands/core/help.js new file mode 100644 index 0000000..7f63d3d --- /dev/null +++ b/server/src/commands/core/help.js @@ -0,0 +1,49 @@ +/* + Description: Outputs the current command module list or command categories +*/ + +const stripIndents = require('common-tags').stripIndents; + +exports.run = async (core, server, socket, data) => { + // verify passed arguments + let typeDt = typeof data.type; + let catDt = typeof data.category; + let cmdDt = typeof data.command; + if (typeDt !== 'undefined' && typeDt !== 'string' ) { + return; + } else if (catDt !== 'undefined' && catDt !== 'string' ) { + return; + } else if (cmdDt !== 'undefined' && cmdDt !== 'string' ) { + return; + } + + // set default reply + let reply = stripIndents`Help usage: + Show all categories -> { cmd: 'help', type: 'categories' } + Show all commands in category -> { cmd: 'help', category: '' } + Show specific command -> { cmd: 'help', command: '' }`; + + if (typeDt !== 'undefined') { + let categories = core.commands.categories().sort(); + reply = `Command Categories:\n${categories.map(c => `- ${c.replace('../src/commands/', '')}`).join('\n')}`; + } else if (catDt !== 'undefined') { + let catCommands = core.commands.all('../src/commands/' + data.category).sort((a, b) => a.info.name.localeCompare(b.info.name)); + reply = `${data.category} commands:\n${catCommands.map(c => `- ${c.info.name}`).join('\n')}`; + } else if (cmdDt !== 'undefined') { + let command = core.commands.get(data.command); + reply = stripIndents` + Usage: ${command.info.usage || command.info.name} + Description: ${command.info.description || '¯\_(ツ)_/¯'}`; + } + + server.reply({ + cmd: 'info', + text: reply + }, socket); +}; + +exports.info = { + name: 'help', + usage: 'help ([ type:categories] | [category: | command: ])', + description: 'Outputs information about the servers current protocol' +}; \ No newline at end of file diff --git a/server/src/commands/core/invite.js b/server/src/commands/core/invite.js new file mode 100644 index 0000000..bcf9097 --- /dev/null +++ b/server/src/commands/core/invite.js @@ -0,0 +1,65 @@ +/* + Description: Generates a semi-unique channel name then broadcasts it to each client +*/ + +const verifyNickname = (nick) => { + return /^[a-zA-Z0-9_]{1,24}$/.test(nick); +}; + +exports.run = async (core, server, socket, data) => { + if (server._police.frisk(socket.remoteAddress, 2)) { + server.reply({ + cmd: 'warn', + text: 'You are sending invites too fast. Wait a moment before trying again.' + }, socket); + + return; + } + + if (typeof data.nick !== 'string') { + return; + } + + if (!verifyNickname(data.nick)) { + // Not a valid nickname? Chances are we won't find them + return; + } + + if (data.nick == socket.nick) { + // They invited themself + return; + } + + let channel = Math.random().toString(36).substr(2, 8); + + let payload = { + cmd: 'info', + invite: channel, + text: `${socket.nick} invited you to ?${channel}` + }; + let inviteSent = server.broadcast( payload, { channel: socket.channel, nick: data.nick }); + + if (!inviteSent) { + server.reply({ + cmd: 'warn', + text: 'Could not find user in channel' + }, socket); + + return; + } + + server.reply({ + cmd: 'info', + text: `You invited ${data.nick} to ?${channel}` + }, socket); + + core.managers.stats.increment('invites-sent'); +}; + +exports.requiredData = ['nick']; + +exports.info = { + name: 'invite', + usage: 'invite {nick}', + description: 'Generates a unique (more or less) room name and passes it to two clients' +}; \ No newline at end of file diff --git a/server/src/commands/core/join.js b/server/src/commands/core/join.js new file mode 100644 index 0000000..f2b2c9d --- /dev/null +++ b/server/src/commands/core/join.js @@ -0,0 +1,135 @@ +/* + Description: Initial entry point, applies `channel` and `nick` to the calling socket +*/ + +const crypto = require('crypto'); + +const hash = (password) => { + let sha = crypto.createHash('sha256'); + sha.update(password); + return sha.digest('base64').substr(0, 6); +}; + +const verifyNickname = (nick) => { + return /^[a-zA-Z0-9_]{1,24}$/.test(nick); +}; + +exports.run = async (core, server, socket, data) => { + if (server._police.frisk(socket.remoteAddress, 3)) { + server.reply({ + cmd: 'warn', + text: 'You are joining channels too fast. Wait a moment and try again.' + }, socket); + + return; + } + + if (typeof socket.channel !== 'undefined') { + // Calling socket already in a channel + return; + } + + if (typeof data.channel !== 'string' || typeof data.nick !== 'string') { + return; + } + + let channel = data.channel.trim(); + if (!channel) { + // Must join a non-blank channel + return; + } + + // Process nickname + let nick = data.nick; + let nickArray = nick.split('#', 2); + nick = nickArray[0].trim(); + + if (!verifyNickname(nick)) { + server.reply({ + cmd: 'warn', + text: 'Nickname must consist of up to 24 letters, numbers, and underscores' + }, socket); + + return; + } + + let userExists = server.findSockets({ + channel: data.channel, + nick: (targetNick) => targetNick.toLowerCase() === nick.toLowerCase() + }); + + if (userExists.length > 0) { + // That nickname is already in that channel + server.reply({ + cmd: 'warn', + text: 'Nickname taken' + }, socket); + + return; + } + + // TODO: Should we check for mod status first to prevent overwriting of admin status somehow? Meh, w/e, cba. + let uType = 'user'; + let trip = null; + let password = nickArray[1]; + if (nick.toLowerCase() == core.config.adminName.toLowerCase()) { + if (password != core.config.adminPass) { + server._police.frisk(socket.remoteAddress, 4); + + server.reply({ + cmd: 'warn', + text: 'Gtfo' + }, socket); + + return; + } else { + uType = 'admin'; + trip = 'Admin'; + } + } else if (password) { + trip = hash(password + core.config.tripSalt); + } + + // TODO: Disallow moderator impersonation + for (let mod of core.config.mods) { + if (trip === mod.trip) { + uType = 'mod'; + } + } + + // Reply with online user list + let newPeerList = server.findSockets({ channel: data.channel }); + let joinAnnouncement = { + cmd: 'onlineAdd', + nick: nick, + trip: trip || 'null', + hash: server.getSocketHash(socket) + }; + let nicks = []; + + for (let i = 0, l = newPeerList.length; i < l; i++) { + server.reply(joinAnnouncement, newPeerList[i]); + nicks.push(newPeerList[i].nick); + } + + socket.uType = uType; + socket.nick = nick; + socket.channel = channel; + if (trip !== null) socket.trip = trip; + nicks.push(socket.nick); + + server.reply({ + cmd: 'onlineSet', + nicks: nicks + }, socket); + + core.managers.stats.increment('users-joined'); +}; + +exports.requiredData = ['channel', 'nick']; + +exports.info = { + name: 'join', + usage: 'join {channel} {nick}', + description: 'Place calling socket into target channel with target nick & broadcast event to channel' +}; \ No newline at end of file diff --git a/server/src/commands/core/morestats.js b/server/src/commands/core/morestats.js new file mode 100644 index 0000000..5510cb1 --- /dev/null +++ b/server/src/commands/core/morestats.js @@ -0,0 +1,53 @@ +/* + Description: Outputs more info than the legacy stats command +*/ + +const stripIndents = require('common-tags').stripIndents; + +const formatTime = (time) => { + let seconds = time[0] + time[1] / 1e9; + + let minutes = Math.floor(seconds / 60); + seconds = seconds % 60; + + let hours = Math.floor(minutes / 60); + minutes = minutes % 60; + return `${hours.toFixed(0)}h ${minutes.toFixed(0)}m ${seconds.toFixed(0)}s`; +}; + +exports.run = async (core, server, socket, data) => { + let ips = {}; + let channels = {}; + for (let client of server.clients) { + if (client.channel) { + channels[client.channel] = true; + ips[client.remoteAddress] = true; + } + } + + let uniqueClientCount = Object.keys(ips).length; + let uniqueChannels = Object.keys(channels).length; + + ips = null; + channels = null; + + server.reply({ + cmd: 'info', + text: stripIndents`current-connections: ${uniqueClientCount} + current-channels: ${uniqueChannels} + users-joined: ${(core.managers.stats.get('users-joined') || 0)} + invites-sent: ${(core.managers.stats.get('invites-sent') || 0)} + messages-sent: ${(core.managers.stats.get('messages-sent') || 0)} + users-banned: ${(core.managers.stats.get('users-banned') || 0)} + users-kicked: ${(core.managers.stats.get('users-kicked') || 0)} + stats-requested: ${(core.managers.stats.get('stats-requested') || 0)} + server-uptime: ${formatTime(process.hrtime(core.managers.stats.get('start-time')))}` + }, socket); + + core.managers.stats.increment('stats-requested'); +}; + +exports.info = { + name: 'morestats', + description: 'Sends back current server stats to the calling client' +}; \ No newline at end of file diff --git a/server/src/commands/core/move.js b/server/src/commands/core/move.js new file mode 100644 index 0000000..c5efafd --- /dev/null +++ b/server/src/commands/core/move.js @@ -0,0 +1,83 @@ +/* + Description: Generates a semi-unique channel name then broadcasts it to each client +*/ + +exports.run = async (core, server, socket, data) => { + if (server._police.frisk(socket.remoteAddress, 6)) { + server.reply({ + cmd: 'warn', + text: 'You are changing channels too fast. Wait a moment before trying again.' + }, socket); + + return; + } + + if (typeof data.channel !== 'string') { + return; + } + + if (data.channel === socket.channel) { + // They are trying to rejoin the channel + return; + } + + const currentNick = socket.nick.toLowerCase(); + let userExists = server.findSockets({ + channel: data.channel, + nick: (targetNick) => targetNick.toLowerCase() === currentNick + }); + + if (userExists.length > 0) { + // That nickname is already in that channel + return; + } + + let peerList = server.findSockets({ channel: socket.channel }); + + if (peerList.length > 1) { + for (let i = 0, l = peerList.length; i < l; i++) { + server.reply({ + cmd: 'onlineRemove', + nick: peerList[i].nick + }, socket); + + if (socket.nick !== peerList[i].nick){ + server.reply({ + cmd: 'onlineRemove', + nick: socket.nick + }, peerList[i]); + } + } + } + + let newPeerList = server.findSockets({ channel: data.channel }); + let moveAnnouncement = { + cmd: 'onlineAdd', + nick: socket.nick, + trip: socket.trip || 'null', + hash: server.getSocketHash(socket) + }; + let nicks = []; + + for (let i = 0, l = newPeerList.length; i < l; i++) { + server.reply(moveAnnouncement, newPeerList[i]); + nicks.push(newPeerList[i].nick); + } + + nicks.push(socket.nick); + + server.reply({ + cmd: 'onlineSet', + nicks: nicks + }, socket); + + socket.channel = data.channel; +}; + +exports.requiredData = ['channel']; + +exports.info = { + name: 'move', + usage: 'move {channel}', + description: 'This will change the current channel to the new one provided' +}; \ No newline at end of file diff --git a/server/src/commands/core/stats.js b/server/src/commands/core/stats.js new file mode 100644 index 0000000..b9dc002 --- /dev/null +++ b/server/src/commands/core/stats.js @@ -0,0 +1,32 @@ +/* + Description: Legacy stats output, kept for compatibility, outputs user and channel count +*/ + +exports.run = async (core, server, socket, data) => { + let ips = {}; + let channels = {}; + for (let client of server.clients) { + if (client.channel) { + channels[client.channel] = true; + ips[client.remoteAddress] = true; + } + } + + let uniqueClientCount = Object.keys(ips).length; + let uniqueChannels = Object.keys(channels).length; + + ips = null; + channels = null; + + server.reply({ + cmd: 'info', + text: `${uniqueClientCount} unique IPs in ${uniqueChannels} channels` + }, socket); + + core.managers.stats.increment('stats-requested'); +}; + +exports.info = { + name: 'stats', + description: 'Sends back legacy server stats to the calling client' +}; \ No newline at end of file diff --git a/server/src/commands/mod/ban.js b/server/src/commands/mod/ban.js new file mode 100644 index 0000000..e19efc2 --- /dev/null +++ b/server/src/commands/mod/ban.js @@ -0,0 +1,64 @@ +/* + Description: Adds the target socket's ip to the ratelimiter +*/ + +exports.run = async (core, server, socket, data) => { + if (socket.uType == 'user') { + // ignore if not mod or admin + return; + } + + if (typeof data.nick !== 'string') { + return; + } + + let targetNick = data.nick; + let badClient = server.findSockets({ channel: socket.channel, nick: targetNick }); + + if (badClient.length === 0) { + server.reply({ + cmd: 'warn', + text: 'Could not find user in channel' + }, socket); + + return; + } + + badClient = badClient[0]; + + if (badClient.uType !== 'user') { + server.reply({ + cmd: 'warn', + text: 'Cannot ban other mods, how rude' + }, socket); + + return; + } + + let clientHash = server.getSocketHash(badClient); + server._police.arrest(badClient.remoteAddress, clientHash); + + console.log(`${socket.nick} [${socket.trip}] banned ${targetNick} in ${socket.channel}`); + + server.broadcast({ + cmd: 'info', + text: `Banned ${targetNick}` + }, { channel: socket.channel, uType: 'user' }); + + server.broadcast({ + cmd: 'info', + text: `${socket.nick} banned ${targetNick} in ${socket.channel}, userhash: ${clientHash}` + }, { uType: 'mod' }); + + badClient.close(); + + core.managers.stats.increment('users-banned'); +}; + +exports.requiredData = ['nick']; + +exports.info = { + name: 'ban', + usage: 'ban {nick}', + description: 'Disconnects the target nickname in the same channel as calling socket & adds to ratelimiter' +}; diff --git a/server/src/commands/mod/kick.js b/server/src/commands/mod/kick.js new file mode 100644 index 0000000..157592d --- /dev/null +++ b/server/src/commands/mod/kick.js @@ -0,0 +1,78 @@ +/* + Description: Forces a change on the target socket's channel, then broadcasts event +*/ + +exports.run = async (core, server, socket, data) => { + if (socket.uType === 'user') { + // ignore if not mod or admin + return; + } + + if (typeof data.nick !== 'string') { + if (typeof data.nick !== 'object' && !Array.isArray(data.nick)) { + return; + } + } + + let badClients = server.findSockets({ channel: socket.channel, nick: data.nick }); + + if (badClients.length === 0) { + server.reply({ + cmd: 'warn', + text: 'Could not find user(s) in channel' + }, socket); + + return; + } + + let newChannel = ''; + let kicked = []; + for (let i = 0, j = badClients.length; i < j; i++) { + if (badClients[i].uType !== 'user') { + server.reply({ + cmd: 'warn', + text: 'Cannot kick other mods, how rude' + }, socket); + } else { + newChannel = Math.random().toString(36).substr(2, 8); + badClients[i].channel = newChannel; + + // inform mods with where they were sent + server.broadcast({ + cmd: 'info', + text: `${badClients[i].nick} was banished to ?${newChannel}` + }, { channel: socket.channel, uType: 'mod' }); + + kicked.push(badClients[i].nick); + console.log(`${socket.nick} [${socket.trip}] kicked ${badClients[i].nick} in ${socket.channel}`); + } + } + + if (kicked.length === 0) { + return; + } + + // broadcast client leave event + for (let i = 0, j = kicked.length; i < j; i++) { + server.broadcast({ + cmd: 'onlineRemove', + nick: kicked[i] + }, { channel: socket.channel }); + } + + // publicly broadcast kick event + server.broadcast({ + cmd: 'info', + text: `Kicked ${kicked.join(', ')}` + }, { channel: socket.channel, uType: 'user' }); + + core.managers.stats.increment('users-kicked', kicked.length); +}; + +exports.requiredData = ['nick']; + +exports.info = { + name: 'kick', + usage: 'kick {nick}', + description: 'Silently forces target client(s) into another channel. `nick` may be string or array of strings' +}; \ No newline at end of file diff --git a/server/src/commands/mod/unban.js b/server/src/commands/mod/unban.js new file mode 100644 index 0000000..e82f0b9 --- /dev/null +++ b/server/src/commands/mod/unban.js @@ -0,0 +1,55 @@ +/* + Description: Removes a target ip from the ratelimiter +*/ + +exports.run = async (core, server, socket, data) => { + if (socket.uType == 'user') { + // ignore if not mod or admin + return; + } + + if (typeof data.ip !== 'string' && typeof data.hash !== 'string') { + server.reply({ + cmd: 'warn', + text: "hash:'targethash' or ip:'1.2.3.4' is required" + }, socket); + + return; + } + + let mode, target; + + if (typeof data.ip === 'string') { + mode = 'ip'; + target = data.ip; + } else { + mode = 'hash'; + target = data.hash; + } + + server._police.pardon(target); + + if (mode === 'ip') { + target = server.getSocketHash(target); + } + + console.log(`${socket.nick} [${socket.trip}] unbanned ${target} in ${socket.channel}`); + + server.reply({ + cmd: 'info', + text: `Unbanned ${target}` + }, socket); + + server.broadcast({ + cmd: 'info', + text: `${socket.nick} unbanned: ${target}` + }, { uType: 'mod' }); + + core.managers.stats.decrement('users-banned'); +}; + +exports.info = { + name: 'unban', + usage: 'unban {[ip || hash]}', + description: 'Removes target ip from the ratelimiter' +}; \ No newline at end of file diff --git a/server/src/core/rateLimiter.js b/server/src/core/rateLimiter.js new file mode 100644 index 0000000..0c2a384 --- /dev/null +++ b/server/src/core/rateLimiter.js @@ -0,0 +1,103 @@ +/** + * Tracks frequency of occurances based on `id` (remote address), then allows or + * denies command execution based on comparison with `threshold` + * + * Version: v2.0.0 + * Developer: Marzavec ( https://github.com/marzavec ) + * License: WTFPL ( http://www.wtfpl.net/txt/copying/ ) + * + */ + +class Police { + /** + * Create a ratelimiter instance. + */ + constructor () { + this._records = {}; + this._halflife = 30 * 1000; // milliseconds + this._threshold = 25; + this._hashes = []; + } + + /** + * Finds current score by `id` + * + * @param {String} id target id / address + * @public + * + * @memberof Police + */ + search (id) { + let record = this._records[id]; + + if (!record) { + record = this._records[id] = { + time: Date.now(), + score: 0 + } + } + + return record; + } + + /** + * Adjusts the current ratelimit score by `deltaScore` + * + * @param {String} id target id / address + * @param {Number} deltaScore amount to adjust current score by + * @public + * + * @memberof Police + */ + frisk (id, deltaScore) { + let record = this.search(id); + + if (record.arrested) { + return true; + } + + record.score *= Math.pow(2, -(Date.now() - record.time ) / this._halflife); + record.score += deltaScore; + record.time = Date.now(); + + if (record.score >= this._threshold) { + return true; + } + + return false; + } + + /** + * Statically set server to no longer accept traffic from `id` + * + * @param {String} id target id / address + * @public + * + * @memberof Police + */ + arrest (id, hash) { + let record = this.search(id); + + record.arrested = true; + this._hashes[hash] = id; + } + + /** + * Remove statically assigned limit from `id` + * + * @param {String} id target id / address + * @public + * + * @memberof Police + */ + pardon (id) { + if (typeof this._hashes[id] !== 'undefined') { + id = this._hashes[id]; + } + + let record = this.search(id); + record.arrested = false; + } +} + +module.exports = Police; diff --git a/server/src/core/server.js b/server/src/core/server.js new file mode 100644 index 0000000..855aeba --- /dev/null +++ b/server/src/core/server.js @@ -0,0 +1,282 @@ +/** + * Main websocket server handling communications and connection events + * + * Version: v2.0.0 + * Developer: Marzavec ( https://github.com/marzavec ) + * License: WTFPL ( http://www.wtfpl.net/txt/copying/ ) + * + */ + +const wsServer = require('ws').Server; +const socketReady = require('ws').OPEN; +const crypto = require('crypto'); +const ipSalt = (Math.random().toString(36).substring(2, 16) + Math.random().toString(36).substring(2, (Math.random() * 16))).repeat(16); +const Police = require('./rateLimiter'); +const pulseSpeed = 16000; // ping all clients every X ms + +class server extends wsServer { + /** + * Create a HackChat server instance. + * + * @param {Object} core Reference to the global core object + */ + constructor (core) { + super({ port: core.config.websocketPort }); + + this._core = core; + this._police = new Police(); + this._cmdBlacklist = {}; + this._heartBeat = setInterval(((data) => { + this.beatHeart(); + }).bind(this), pulseSpeed); + + this.on('error', (err) => { + this.handleError('server', err); + }); + + this.on('connection', (socket, request) => { + this.newConnection(socket, request); + }); + } + + /** + * Send empty `ping` frame to each client + * + */ + beatHeart () { + let targetSockets = this.findSockets({}); + + if (targetSockets.length === 0) { + return; + } + + for (let i = 0, l = targetSockets.length; i < l; i++) { + try { + if (targetSockets[i].readyState === socketReady) { + targetSockets[i].ping(); + } + } catch (e) { } + } + } + + /** + * Bind listeners for the new socket created on connection to this class + * + * @param {Object} socket New socket object + * @param {Object} request Initial headers of the new connection + */ + newConnection (socket, request) { + socket.remoteAddress = request.headers['x-forwarded-for'] || request.connection.remoteAddress; + + socket.on('message', ((data) => { + this.handleData(socket, data); + }).bind(this)); + + socket.on('close', (() => { + this.handleClose(socket); + }).bind(this)); + + socket.on('error', ((err) => { + this.handleError(socket, err); + }).bind(this)); + } + + /** + * Handle incoming messages from clients, parse and check command, then hand-off + * + * @param {Object} socket Calling socket object + * @param {String} data Message sent from client + */ + handleData (socket, data) { + // Don't penalize yet, but check whether IP is rate-limited + if (this._police.frisk(socket.remoteAddress, 0)) { + this.reply({ cmd: 'warn', text: "Your IP is being rate-limited or blocked." }, socket); + + return; + } + + // Penalize here, but don't do anything about it + this._police.frisk(socket.remoteAddress, 1); + + // ignore ridiculously large packets + if (data.length > 65536) { + return; + } + + // Start sent data verification + var args = null; + try { + args = JSON.parse(data); + } catch (e) { + // Client sent malformed json, gtfo + socket.close(); + } + + if (args === null) { + return; + } + + if (typeof args.cmd === 'undefined' || args.cmd == 'ping') { + return; + } + + if (typeof args.cmd !== 'string') { + return; + } + + if (typeof socket.channel === 'undefined' && args.cmd !== 'join') { + return; + } + + if (typeof this._cmdBlacklist[args.cmd] === 'function') { + return; + } + + // Finished verification, pass to command modules + this._core.commands.handleCommand(this, socket, args); + } + + /** + * Handle socket close from clients + * + * @param {Object} socket Closing socket object + */ + handleClose (socket) { + this._core.commands.handleCommand(this, socket, { cmd: 'disconnect' }); + } + + /** + * "Handle" server or socket errors + * + * @param {Object||String} socket Calling socket object, or 'server' + * @param {String} err The sad stuff + */ + handleError (socket, err) { + console.log(`Server error: ${err}`); + } + + /** + * Send data payload to specific socket/client + * + * @param {Object} data Object to convert to json for transmission + * @param {Object} socket The target client + */ + send (data, socket) { + // Add timestamp to command + data.time = Date.now(); + + try { + if (socket.readyState === socketReady) { + socket.send(JSON.stringify(data)); + } + } catch (e) { } + } + + /** + * Overload function for `this.send()` + * + * @param {Object} data Object to convert to json for transmission + * @param {Object} socket The target client + */ + reply (data, socket) { + this.send(data, socket); + } + + /** + * Finds sockets/clients that meet the filter requirements, then passes the data to them + * + * @param {Object} data Object to convert to json for transmission + * @param {Object} filter see `this.findSockets()` + */ + broadcast (data, filter) { + let targetSockets = this.findSockets(filter); + + if (targetSockets.length === 0) { + return false; + } + + for (let i = 0, l = targetSockets.length; i < l; i++) { + this.send(data, targetSockets[i]); + } + + return true; + } + + /** + * Finds sockets/clients that meet the filter requirements, returns result as array + * + * @param {Object} data Object to convert to json for transmission + * @param {Object} filter The socket must of equal or greater attribs matching `filter` + * = {} // matches all + * = { channel: 'programming' } // matches any socket where (`socket.channel` === 'programming') + * = { channel: 'programming', nick: 'Marzavec' } // matches any socket where (`socket.channel` === 'programming' && `socket.nick` === 'Marzavec') + */ + findSockets (filter) { + let filterAttribs = Object.keys(filter); + let reqCount = filterAttribs.length; + let curMatch; + let matches = []; + for ( let socket of this.clients ) { + curMatch = 0; + + for (let i = 0; i < reqCount; i++) { + if (typeof socket[filterAttribs[i]] !== 'undefined') { + switch(typeof filter[filterAttribs[i]]) { + case 'object': { + if (Array.isArray(filter[filterAttribs[i]])) { + if (filter[filterAttribs[i]].indexOf(socket[filterAttribs[i]]) !== -1) { + curMatch++; + } + } else { + if (socket[filterAttribs[i]] === filter[filterAttribs[i]]) { + curMatch++; + } + } + break; + } + + case 'function': { + if (filter[filterAttribs[i]](socket[filterAttribs[i]])) { + curMatch++; + } + break; + } + + default: { + if (socket[filterAttribs[i]] === filter[filterAttribs[i]]) { + curMatch++; + } + break; + } + } + } + } + + if (curMatch === reqCount) { + matches.push(socket); + } + } + + return matches; + } + + /** + * Encrypts target socket's remote address using non-static variable length salt + * encodes and shortens the output, returns that value + * + * @param {Object||String} target Either the target socket or ip as string + */ + getSocketHash (target) { + let sha = crypto.createHash('sha256'); + + if (typeof target === 'string') { + sha.update(target + ipSalt); + } else { + sha.update(target.remoteAddress + ipSalt); + } + + return sha.digest('base64').substr(0, 15); + } +} + +module.exports = server; diff --git a/server/src/managers/commands.js b/server/src/managers/commands.js new file mode 100644 index 0000000..c38fb4d --- /dev/null +++ b/server/src/managers/commands.js @@ -0,0 +1,239 @@ +/** + * Commands / protocol manager- loads, validates and handles command execution + * + * Version: v2.0.0 + * Developer: Marzavec ( https://github.com/marzavec ) + * License: WTFPL ( http://www.wtfpl.net/txt/copying/ ) + * + */ + +const path = require('path'); +const chalk = require('chalk'); +const didYouMean = require('didyoumean2'); + +class CommandManager { + /** + * Create a `CommandManager` instance for handling commands/protocol + * + * @param {Object} core Reference to the global core object + */ + constructor (core) { + this.core = core; + this._commands = []; + this._categories = []; + } + + /** + * (Re)initializes name spaces for commands and starts load routine + * + */ + loadCommands () { + this._commands = []; + this._categories = []; + + const core = this.core; + + const commandImports = core.managers.dynamicImports.getImport('src/commands'); + let cmdErrors = ''; + Object.keys(commandImports).forEach(file => { + let command = commandImports[file]; + let name = path.basename(file); + cmdErrors += this._validateAndLoad(command, file, name); + }); + + return cmdErrors; + } + + /** + * Checks the module after having been `require()`ed in and reports errors + * + * @param {Object} command reference to the newly loaded object + * @param {String} file file path to the module + * @param {String} name command (`cmd`) name + */ + _validateAndLoad (command, file, name) { + let error = this._validateCommand(command); + + if (error) { + let errText = `Failed to load '${name}': ${error}`; + console.log(errText); + return errText; + } + + if (!command.category) { + let base = path.join(this.core.managers.dynamicImports.base, 'commands'); + + let category = 'Uncategorized'; + if (file.indexOf(path.sep) > -1) { + category = path.dirname(path.relative(base, file)) + .replace(new RegExp(path.sep.replace('\\', '\\\\'), 'g'), '/'); + } + + command.info.category = category; + + if (this._categories.indexOf(category) === -1) + this._categories.push(category); + } + + if (typeof command.init === 'function') { + try { + command.init(this.core); + } catch (err) { + let errText = `Failed to initialize '${name}': ${err}`; + console.log(errText); + return errText; + } + } + + this._commands.push(command); + + return ''; + } + + /** + * Checks the module after having been `require()`ed in and reports errors + * + * @param {Object} object reference to the newly loaded object + */ + _validateCommand (object) { + if (typeof object !== 'object') + return 'command setup is invalid'; + + if (typeof object.run !== 'function') + return 'run function is missing'; + + if (typeof object.info !== 'object') + return 'info object is missing'; + + if (typeof object.info.name !== 'string') + return 'info object is missing a valid name field'; + + return null; + } + + /** + * Pulls all command names from a passed `category` + * + * @param {String} category reference to the newly loaded object + */ + all (category) { + return !category ? this._commands : this._commands.filter(c => c.info.category.toLowerCase() === category.toLowerCase()); + } + + /** + * Pulls all category names + * + */ + categories () { + return this._categories; + } + + /** + * Pulls command by name or alia(s) + * + * @param {String} name name or alias of command + */ + get (name) { + return this.findBy('name', name) + || this._commands.find(command => command.info.aliases instanceof Array && command.info.aliases.indexOf(name) > -1); + } + + /** + * Pulls command by arbitrary search of the `module.info` attribute + * + * @param {String} key name or alias of command + * @param {String} value name or alias of command + */ + findBy (key, value) { + return this._commands.find(c => c.info[key] === value); + } + + /** + * Finds and executes the requested command, or fails with semi-intelligent error + * + * @param {Object} server main server reference + * @param {Object} socket calling socket reference + * @param {Object} data command structure passed by socket (client) + */ + handleCommand (server, socket, data) { + // Try to find command first + let command = this.get(data.cmd); + + if (command) { + return this.execute(command, server, socket, data); + } else { + // Then fail with helpful (sorta) message + return this._handleFail(server, socket, data); + } + } + + /** + * Requested command failure handler, attempts to find command and reports back + * + * @param {Object} server main server reference + * @param {Object} socket calling socket reference + * @param {Object} data command structure passed by socket (client) + */ + _handleFail(server, socket, data) { + const maybe = didYouMean(data.cmd, this.all().map(c => c.info.name), { + threshold: 5, + thresholdType: 'edit-distance' + }); + + if (maybe) { + // Found a suggestion, pass it on to their dyslexic self + return server.reply({ + cmd: 'warn', + text: `Command not found, did you mean: \`${maybe}\`?` + }, socket); + } + + // Request so mangled that I don't even, silently fail + return; + } + + /** + * Attempt to execute the requested command, fail if err or bad params + * + * @param {Object} command target command module + * @param {Object} server main server reference + * @param {Object} socket calling socket reference + * @param {Object} data command structure passed by socket (client) + */ + async execute(command, server, socket, data) { + if (typeof command.requiredData !== 'undefined') { + let missing = []; + for (let i = 0, len = command.requiredData.length; i < len; i++) { + if (typeof data[command.requiredData[i]] === 'undefined') + missing.push(command.requiredData[i]); + } + + if (missing.length > 0) { + let errText = `Failed to execute '${command.info.name}': missing required ${missing.join(', ')}\n\n`; + + server.reply({ + cmd: 'warn', + text: errText + }, socket); + + return null; + } + } + + try { + return await command.run(this.core, server, socket, data); + } catch (err) { + let errText = `Failed to execute '${command.info.name}': ${err}`; + console.log(errText); + + server.reply({ + cmd: 'warn', + text: errText + }, socket); + + return null; + } + } +} + +module.exports = CommandManager; diff --git a/server/src/managers/config.js b/server/src/managers/config.js new file mode 100644 index 0000000..2865d00 --- /dev/null +++ b/server/src/managers/config.js @@ -0,0 +1,224 @@ +/** + * Server configuration manager, handling loading, creation, parsing and saving + * of the main config.json file + * + * Version: v2.0.0 + * Developer: Marzavec ( https://github.com/marzavec ) + * License: WTFPL ( http://www.wtfpl.net/txt/copying/ ) + * + */ + +const stripIndents = require('common-tags').stripIndents; +const dateFormat = require('dateformat'); +const chalk = require('chalk'); +const fse = require('fs-extra'); +const prompt = require('prompt'); +const path = require('path'); +const deSync = require('deasync'); + +class ConfigManager { + /** + * Create a `ConfigManager` instance for (re)loading classes and config + * + * @param {Object} core reference to the global core object + * @param {String} base executing directory name; __dirname + * @param {Object} dynamicImports dynamic import engine reference + */ + constructor (core, base, dynamicImports) { + this._core = core; + this._base = base; + + this._configPath = path.resolve(base, 'config/config.json'); + + this._dynamicImports = dynamicImports; + } + + /** + * Pulls both core config questions along with any optional config questions, + * used in building the initial config.json or re-building it. + * + * @param {Object} currentConfig an object containing current server settings, if any + * @param {Object} optionalConfigs optional (non-core) module config + */ + getQuestions (currentConfig, optionalConfigs) { + // core server setup questions + const questions = { + properties: { + adminName: { + pattern: /^"?[a-zA-Z0-9_]+"?$/, + type: 'string', + message: 'Nicks can only contain letters, numbers and underscores', + required: !currentConfig.adminName, + default: currentConfig.adminName, + before: value => value.replace(/"/g, '') + }, + adminPass: { + type: 'string', + required: !currentConfig.adminPass, + default: currentConfig.adminPass, + hidden: true, + replace: '*', + }, + websocketPort: { + type: 'number', + required: !currentConfig.websocketPort, + default: currentConfig.websocketPort || 6060 + }, + tripSalt: { + type: 'string', + required: !currentConfig.tripSalt, + default: currentConfig.tripSalt, + hidden: true, + replace: '*', + } + } + }; + + // non-core server setup questions, for future plugin support + Object.keys(optionalConfigs).forEach(configName => { + const config = optionalConfigs[configName]; + const question = config.getQuestion(currentConfig, configName); + + if (!question) { + return; + } + + question.description = (question.description || configName) + ' (Optional)'; + questions.properties[configName] = question; + }); + + return questions; + } + + /** + * `load` function overload, only blocking + * + */ + loadSync () { + let conf = {}; + conf = this.load(); + + // trip salt is the last core config question, wait until it's been populated + // TODO: update this to work with new plugin support + while(conf === null || typeof conf.tripSalt === 'undefined') { + deSync.sleep(100); + } + + return conf; + } + + /** + * (Re)builds the config.json (main server config), or loads the config into mem + * if rebuilding, process will exit- this is to allow a process manager to take over + * + * @param {Boolean} reconfiguring set to true by `scripts/configure.js`, will exit if true + */ + load (reconfiguring = false) { + if (reconfiguring || !fse.existsSync(this._configPath)) { + // gotta have that sexy console + console.log(stripIndents` + ${chalk.magenta('°º¤ø,¸¸,ø¤º°`°º¤ø,¸,ø¤°º¤ø,¸¸,ø¤º°`°º¤ø,¸°º¤ø,¸¸,ø¤º°`°º¤ø')} + ${chalk.gray('--------------(') + chalk.white(' HackChat Setup Wizard v1.0 ') + chalk.gray(')--------------')} + ${chalk.magenta('°º¤ø,¸¸,ø¤º°`°º¤ø,¸,ø¤°º¤ø,¸¸,ø¤º°`°º¤ø,¸°º¤ø,¸¸,ø¤º°`°º¤ø')} + + For advanced setup, see the HackChat wiki at: + ${chalk.green('https://github.com/')} + + ${chalk.white('Note:')} ${chalk.green('npm/yarn run config')} will re-run this utility. + + You will now be asked for the following: + - ${chalk.magenta('Admin Name')}, the initial admin username + - ${chalk.magenta('Admin Pass')}, the initial admin password + - ${chalk.magenta(' Port')}, the port for the websocket + - ${chalk.magenta(' Salt')}, the salt for username trip + \u200b + `); + + let currentConfig = this._config || {}; + if (reconfiguring && fse.existsSync(this._configPath)) { + this._backup(); + currentConfig = fse.readJSONSync(this._configPath); + } + + prompt.get(this.getQuestions(currentConfig, this._dynamicImports.optionalConfigs), (err, res) => { + if (typeof res.mods === 'undefined') { + res.mods = []; + } + + if (err) { + console.error(err); + process.exit(666); // SPOOKY! + } + + try { + fse.outputJsonSync(this._configPath, res); + } catch (e) { + console.error(`Couldn't write config to ${this._configPath}\n${e.stack}`); + if (!reconfiguring) { + process.exit(666); // SPOOKY! + } + } + + console.log('Config generated! You may now start the server normally.') + + process.exit(reconfiguring ? 0 : 42); + }); + + return null; + } + + this._config = fse.readJSONSync(this._configPath); + + return this._config; + } + + /** + * Creates backup of current config into _configPath + * + */ + _backup () { + const backupPath = `${this._configPath}.${dateFormat('dd-mm-yy-HH-MM-ss')}.bak`; + fse.copySync(this._configPath, backupPath); + + return backupPath; + } + + /** + * First makes a backup of the current `config.json`, then writes current config + * to disk + * + */ + save () { + const backupPath = this._backup(); + + if (!fse.existsSync(this._configPath)){ + fse.mkdirSync(this._configPath); + } + + try { + fse.writeJSONSync(this._configPath, this._config); + fse.removeSync(backupPath); + + return true; + } catch (err) { + console.log(`Failed to save config file: ${err}`); + + return false; + } + } + + /** + * Updates current config[`key`] with `value` then writes changes to disk + * + * @param {*} key arbitrary configuration key + * @param {*} value new value to change `key` to + */ + set (key, value) { + const realKey = `${key}`; + this._config[realKey] = value; + + this.save(); + } +} + +module.exports = ConfigManager; diff --git a/server/src/managers/imports-manager.js b/server/src/managers/imports-manager.js new file mode 100644 index 0000000..d8b2144 --- /dev/null +++ b/server/src/managers/imports-manager.js @@ -0,0 +1,148 @@ +/** + * Import managment base, used to load commands/protocol and configuration objects + * + * Version: v2.0.0 + * Developer: Marzavec ( https://github.com/marzavec ) + * License: WTFPL ( http://www.wtfpl.net/txt/copying/ ) + * + */ + +const read = require('readdir-recursive'); +const path = require('path'); + +class ImportsManager { + /** + * Create a `ImportsManager` instance for (re)loading classes and config + * + * @param {Object} core reference to the global core object + * @param {String} base executing directory name; __dirname + */ + constructor (core, base) { + this._core = core; + this._base = base; + + this._imports = {}; + this._optionalConfigs = {}; + } + + /** + * Pull core reference + * + * @type {Object} readonly + */ + get core () { + return this._core; + } + + /** + * Pull base path that all imports are required in from + * + * @type {String} readonly + */ + get base () { + return this._base; + } + + /** + * Pull optional (none-core) config options + * + * @type {Object} + */ + get optionalConfigs () { + return Object.assign({}, this._optionalConfigs); + } + + /** + * Initialize this class and start loading target directories + * + */ + init () { + let errorText = ''; + ImportsManager.load_dirs.forEach(dir => { + errorText += this.loadDir(dir); + }); + + return errorText; + } + + /** + * Gather all js files from target directory, then verify and load + * + * @param {String} dirName The name of the dir to load, relative to the _base path. + */ + loadDir (dirName) { + const dir = path.resolve(this._base, dirName); + + let errorText = ''; + try { + read.fileSync(dir).forEach(file => { + const basename = path.basename(file); + if (basename.startsWith('_') || !basename.endsWith('.js')) return; + + let imported; + try { + imported = require(file); + } catch (e) { + let err = `Unable to load modules from ${dirName} (${path.relative(dir, file)})\n${e}`; + errorText += err; + console.error(err); + return errorText; + } + + if (imported.configs) { + imported.configs.forEach(config => { + this._optionalConfigs[config.name] = config; + }); + } + + if (!this._imports[dirName]) { + this._imports[dirName] = {}; + } + + this._imports[dirName][file] = imported; + }); + } catch (e) { + let err = `Unable to load modules from ${dirName}\n${e}`; + errorText += err; + console.error(err); + return errorText; + } + + return errorText; + } + + /** + * Unlink references to each loaded module, pray to google that gc knows it's job, + * then reinitialize this class to start the reload + * + * @param {String} dirName The name of the dir to load, relative to the _base path. + */ + reloadDirCache (dirName) { + Object.keys(this._imports[dirName]).forEach((mod) => { + delete require.cache[require.resolve(mod)]; + }); + + return this.init(); + } + + /** + * Pull reference to imported modules that were imported from dirName, or + * load required directory if not found + * + * @param {String} dirName The name of the dir to load, relative to the _base path. + */ + getImport (dirName) { + let imported = this._imports[dirName]; + + if (!imported) { + this.loadDir(dirName); + } + + return Object.assign({}, this._imports[dirName]); + } +} + +// automagically loaded directorys on instantiation +ImportsManager.load_dirs = ['src/commands']; + +module.exports = ImportsManager; diff --git a/server/src/managers/index.js b/server/src/managers/index.js new file mode 100644 index 0000000..2fac8fb --- /dev/null +++ b/server/src/managers/index.js @@ -0,0 +1,6 @@ +module.exports = { + CommandManager: require('./commands'), + Config: require('./config'), + ImportsManager: require('./imports-manager'), + Stats: require('./stats') +}; diff --git a/server/src/managers/stats.js b/server/src/managers/stats.js new file mode 100644 index 0000000..20f1ae3 --- /dev/null +++ b/server/src/managers/stats.js @@ -0,0 +1,59 @@ +/** + * Simple generic stats collection script for events occurances (etc) + * + * Version: v2.0.0 + * Developer: Marzavec ( https://github.com/marzavec ) + * License: WTFPL ( http://www.wtfpl.net/txt/copying/ ) + * + */ + +class Stats { + /** + * Create a stats instance. + * + */ + constructor () { + this._stats = {}; + } + + /** + * Retrieve value of arbitrary `key` reference + * + * @param {String} key Reference to the arbitrary store name + */ + get (key) { + return this._stats[key]; + } + + /** + * Set value of arbitrary `key` reference + * + * @param {String} key Reference to the arbitrary store name + * @param {Number} value New value for `key` + */ + set (key, value) { + this._stats[key] = value; + } + + /** + * Increase value of arbitrary `key` reference, by 1 or `amount` + * + * @param {String} key Reference to the arbitrary store name + * @param {Number} amount Value to increase `key` by, or 1 if omitted + */ + increment (key, amount) { + this.set(key, (this.get(key) || 0) + (amount || 1)); + } + + /** + * Reduce value of arbitrary `key` reference, by 1 or `amount` + * + * @param {String} key Reference to the arbitrary store name + * @param {Number} amount Value to decrease `key` by, or 1 if omitted + */ + decrement (key, amount) { + this.set(key, (this.get(key) || 0) - (amount || 1)); + } +} + +module.exports = Stats; diff --git a/server/src/scripts/configure.js b/server/src/scripts/configure.js new file mode 100644 index 0000000..0ecd858 --- /dev/null +++ b/server/src/scripts/configure.js @@ -0,0 +1,23 @@ +/** + * Server configuration script, used reconfiguring server options + * + * Version: v2.0.0 + * Developer: Marzavec ( https://github.com/marzavec ) + * License: WTFPL ( http://www.wtfpl.net/txt/copying/ ) + * + */ + +'use strict'; + +// import required classes +const path = require('path'); +const ImportsManager = require('../managers/imports-manager'); +const ConfigManager = require('../managers/config'); + +// import and initialize configManager & dependencies +const importManager = new ImportsManager(null, path.join(__dirname, '../..')); +importManager.init(); +const configManager = new ConfigManager(null, path.join(__dirname, '../..'), importManager); + +// execute config load with `reconfiguring` flag set to true +configManager.load(true); diff --git a/server/src/scripts/debug.js b/server/src/scripts/debug.js new file mode 100644 index 0000000..3a97d9f --- /dev/null +++ b/server/src/scripts/debug.js @@ -0,0 +1,18 @@ +/** + * Server debug test script + * + * Version: v2.0.0 + * Developer: Marzavec ( https://github.com/marzavec ) + * License: WTFPL ( http://www.wtfpl.net/txt/copying/ ) + * + */ + +'use strict'; + +// import required classes +const path = require('path'); +const ConfigManager = require('../managers/config'); + +// begin tests +// TODO: TODO +// TODO diff --git a/server/src/scripts/dev.js b/server/src/scripts/dev.js new file mode 100644 index 0000000..5049b84 --- /dev/null +++ b/server/src/scripts/dev.js @@ -0,0 +1,17 @@ +/** + * Server development script + * + * Version: v2.0.0 + * Developer: Marzavec ( https://github.com/marzavec ) + * License: WTFPL ( http://www.wtfpl.net/txt/copying/ ) + * + */ + +'use strict'; + +// import required classes + + +// begin tests +// TODO: TODO +// TODO -- cgit v1.2.1