diff options
-rw-r--r-- | bundle/package-lock.json | 110 | ||||
-rw-r--r-- | bundle/package.json | 15 | ||||
-rw-r--r-- | gateway/package-lock.json | 78 | ||||
-rw-r--r-- | gateway/package.json | 2 | ||||
-rw-r--r-- | gateway/src/events/Message.ts | 11 | ||||
-rw-r--r-- | gateway/src/listener/listener.ts | 2 | ||||
-rw-r--r-- | gateway/src/opcodes/Identify.ts | 3 | ||||
-rw-r--r-- | gateway/src/opcodes/LazyRequest.ts | 9 |
8 files changed, 204 insertions, 26 deletions
diff --git a/bundle/package-lock.json b/bundle/package-lock.json index 4046e7b6..644a3a3c 100644 --- a/bundle/package-lock.json +++ b/bundle/package-lock.json @@ -41,6 +41,7 @@ "i18next-node-fs-backend": "^2.1.3", "image-size": "^1.0.0", "jest": "^27.0.6", + "json-bigint": "^1.0.0", "jsonwebtoken": "^8.5.1", "lambert-db": "^1.2.3", "lambert-server": "^1.2.11", @@ -49,6 +50,7 @@ "multer": "^1.4.2", "nan": "^2.15.0", "nanocolors": "^0.2.12", + "node-2fa": "^2.0.3", "node-fetch": "^2.6.2", "node-os-utils": "^1.3.5", "patch-package": "^6.4.7", @@ -80,6 +82,7 @@ "@types/i18next-node-fs-backend": "^2.1.0", "@types/jest": "^27.0.1", "@types/jest-expect-message": "^1.0.3", + "@types/json-bigint": "^1.0.1", "@types/jsonwebtoken": "^8.5.0", "@types/morgan": "^1.9.3", "@types/multer": "^1.4.7", @@ -220,6 +223,7 @@ "amqplib": "^0.8.0", "dotenv": "^8.2.0", "fast-zlib": "^2.0.1", + "json-bigint": "^1.0.0", "jsonwebtoken": "^8.5.1", "lambert-server": "^1.2.11", "missing-native-js-functions": "^1.2.18", @@ -3606,6 +3610,12 @@ "@types/jest": "*" } }, + "node_modules/@types/json-bigint": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@types/json-bigint/-/json-bigint-1.0.1.tgz", + "integrity": "sha512-zpchZLNsNuzJHi6v64UBoFWAvQlPhch7XAi36FkH6tL1bbbmimIF+cS7vwkzY4u5RaSWMoflQfu+TshMPPw8uw==", + "dev": true + }, "node_modules/@types/json-schema": { "version": "7.0.9", "integrity": "sha512-qcUXuemtEu+E5wZSJHNxUXeCZhAfXKQ41D+duX+VYPde7xyEVZci+/oXKJL13tnRs9lR2pr4fod59GT6/X1/yQ==", @@ -3686,6 +3696,14 @@ "integrity": "sha512-sstDo2s8gQR/Qh2Bd6yNQ5xJv+D4ttyB9ZVjB3mBm3VkGl2RoqjV7fiw9mIHLbshHSRm2m8uf0XrIRQNWB/z6A==", "dev": true }, + "node_modules/@types/notp": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/@types/notp/-/notp-2.0.2.tgz", + "integrity": "sha512-JUcVYN9Tmw0AjoAfvjslS4hbv39fPBbZdftBK3b50g5z/DmhLsu6cd0UOEBiQuMwy2FirshF2Gk9gAvfWjshMw==", + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@types/prettier": { "version": "2.4.1", "integrity": "sha512-Fo79ojj3vdEZOHg3wR9ksAMRz4P3S5fDB5e/YWZiFnyFQI1WY2Vftu9XoXVVtJfxB7Bpce/QTqWSSntkz2Znrw==", @@ -4293,6 +4311,14 @@ "tar": "^6.1.0" } }, + "node_modules/bignumber.js": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.1.0.tgz", + "integrity": "sha512-4LwHK4nfDOraBCtst+wOWIHbu1vhvAPJK8g8nROd4iuc3PSEjWif/qwbkh8jwCJz6yDBvtU4KPynETgrfh7y3A==", + "engines": { + "node": "*" + } + }, "node_modules/binary-extensions": { "version": "2.2.0", "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", @@ -7068,6 +7094,14 @@ "node": ">=4" } }, + "node_modules/json-bigint": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-bigint/-/json-bigint-1.0.0.tgz", + "integrity": "sha512-SiPv/8VpZuWbvLSMtTDU8hEfrZWg/mH/nV/b4o0CYbSxu1UIQPLdwKOCIyLQX+VIPO5vrLX3i8qtqFyhdPSUSQ==", + "dependencies": { + "bignumber.js": "^9.0.0" + } + }, "node_modules/json-schema-traverse": { "version": "1.0.0", "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==" @@ -7733,6 +7767,17 @@ "version": "1.0.5", "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==" }, + "node_modules/node-2fa": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/node-2fa/-/node-2fa-2.0.3.tgz", + "integrity": "sha512-PQldrOhjuoZyoydMvMSctllPN1ZPZ1/NwkEcgYwY9faVqE/OymxR+3awPpbWZxm6acLKqvmNqQmdqTsqYyflFw==", + "dependencies": { + "@types/notp": "^2.0.0", + "notp": "^2.0.3", + "thirty-two": "1.0.2", + "tslib": "^2.1.0" + } + }, "node_modules/node-abi": { "version": "2.30.1", "integrity": "sha512-/2D0wOQPgaUWzVSVgRMx+trKJRC2UG4SUc4oCJoXx9Uxjtp0Vy3/kt7zcbxHF8+Z/pK3UloLWzBISg72brfy1w==", @@ -7945,6 +7990,14 @@ "node": ">=0.10.0" } }, + "node_modules/notp": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/notp/-/notp-2.0.3.tgz", + "integrity": "sha512-oBig/2uqkjQ5AkBuw4QJYwkEWa/q+zHxI5/I5z6IeP2NT0alpJFsP/trrfCC+9xOAgQSZXssNi962kp5KBmypQ==", + "engines": { + "node": "> v0.6.0" + } + }, "node_modules/npm-bundled": { "version": "1.1.2", "integrity": "sha512-x5DHup0SuyQcmL3s7Rx/YQ8sbw/Hzg0rj48eN0dV7hf5cmQq5PXIeioroH3raV1QC1yh3uTYuMThvEQF3iKgGQ==", @@ -10084,6 +10137,14 @@ "node": ">=0.8" } }, + "node_modules/thirty-two": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/thirty-two/-/thirty-two-1.0.2.tgz", + "integrity": "sha512-OEI0IWCe+Dw46019YLl6V10Us5bi574EvlJEOcAkB29IzQ/mYD1A6RyNHLjZPiHCmuodxvgF6U+vZO1L15lxVA==", + "engines": { + "node": ">=0.2.6" + } + }, "node_modules/throat": { "version": "6.0.1", "integrity": "sha512-8hmiGIJMDlwjg7dlJ4yKGLK8EsYqKgPWbG3b4wjJddKNwc7N7Dpn08Df4szr/sZdMVeOstrdYSsqzX6BYbcB+w==", @@ -13257,6 +13318,7 @@ "amqplib": "^0.8.0", "dotenv": "^8.2.0", "fast-zlib": "^2.0.1", + "json-bigint": "^1.0.0", "jsonwebtoken": "^8.5.1", "lambert-server": "^1.2.11", "missing-native-js-functions": "^1.2.18", @@ -13910,6 +13972,12 @@ "@types/jest": "*" } }, + "@types/json-bigint": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@types/json-bigint/-/json-bigint-1.0.1.tgz", + "integrity": "sha512-zpchZLNsNuzJHi6v64UBoFWAvQlPhch7XAi36FkH6tL1bbbmimIF+cS7vwkzY4u5RaSWMoflQfu+TshMPPw8uw==", + "dev": true + }, "@types/json-schema": { "version": "7.0.9", "integrity": "sha512-qcUXuemtEu+E5wZSJHNxUXeCZhAfXKQ41D+duX+VYPde7xyEVZci+/oXKJL13tnRs9lR2pr4fod59GT6/X1/yQ==", @@ -13989,6 +14057,14 @@ "integrity": "sha512-sstDo2s8gQR/Qh2Bd6yNQ5xJv+D4ttyB9ZVjB3mBm3VkGl2RoqjV7fiw9mIHLbshHSRm2m8uf0XrIRQNWB/z6A==", "dev": true }, + "@types/notp": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/@types/notp/-/notp-2.0.2.tgz", + "integrity": "sha512-JUcVYN9Tmw0AjoAfvjslS4hbv39fPBbZdftBK3b50g5z/DmhLsu6cd0UOEBiQuMwy2FirshF2Gk9gAvfWjshMw==", + "requires": { + "@types/node": "*" + } + }, "@types/prettier": { "version": "2.4.1", "integrity": "sha512-Fo79ojj3vdEZOHg3wR9ksAMRz4P3S5fDB5e/YWZiFnyFQI1WY2Vftu9XoXVVtJfxB7Bpce/QTqWSSntkz2Znrw==", @@ -14465,6 +14541,11 @@ "tar": "^6.1.0" } }, + "bignumber.js": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.1.0.tgz", + "integrity": "sha512-4LwHK4nfDOraBCtst+wOWIHbu1vhvAPJK8g8nROd4iuc3PSEjWif/qwbkh8jwCJz6yDBvtU4KPynETgrfh7y3A==" + }, "binary-extensions": { "version": "2.2.0", "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", @@ -16522,6 +16603,14 @@ "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==", "dev": true }, + "json-bigint": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-bigint/-/json-bigint-1.0.0.tgz", + "integrity": "sha512-SiPv/8VpZuWbvLSMtTDU8hEfrZWg/mH/nV/b4o0CYbSxu1UIQPLdwKOCIyLQX+VIPO5vrLX3i8qtqFyhdPSUSQ==", + "requires": { + "bignumber.js": "^9.0.0" + } + }, "json-schema-traverse": { "version": "1.0.0", "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==" @@ -17015,6 +17104,17 @@ "version": "1.0.5", "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==" }, + "node-2fa": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/node-2fa/-/node-2fa-2.0.3.tgz", + "integrity": "sha512-PQldrOhjuoZyoydMvMSctllPN1ZPZ1/NwkEcgYwY9faVqE/OymxR+3awPpbWZxm6acLKqvmNqQmdqTsqYyflFw==", + "requires": { + "@types/notp": "^2.0.0", + "notp": "^2.0.3", + "thirty-two": "1.0.2", + "tslib": "^2.1.0" + } + }, "node-abi": { "version": "2.30.1", "integrity": "sha512-/2D0wOQPgaUWzVSVgRMx+trKJRC2UG4SUc4oCJoXx9Uxjtp0Vy3/kt7zcbxHF8+Z/pK3UloLWzBISg72brfy1w==", @@ -17177,6 +17277,11 @@ "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", "dev": true }, + "notp": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/notp/-/notp-2.0.3.tgz", + "integrity": "sha512-oBig/2uqkjQ5AkBuw4QJYwkEWa/q+zHxI5/I5z6IeP2NT0alpJFsP/trrfCC+9xOAgQSZXssNi962kp5KBmypQ==" + }, "npm-bundled": { "version": "1.1.2", "integrity": "sha512-x5DHup0SuyQcmL3s7Rx/YQ8sbw/Hzg0rj48eN0dV7hf5cmQq5PXIeioroH3raV1QC1yh3uTYuMThvEQF3iKgGQ==", @@ -18752,6 +18857,11 @@ "thenify": ">= 3.1.0 < 4" } }, + "thirty-two": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/thirty-two/-/thirty-two-1.0.2.tgz", + "integrity": "sha512-OEI0IWCe+Dw46019YLl6V10Us5bi574EvlJEOcAkB29IzQ/mYD1A6RyNHLjZPiHCmuodxvgF6U+vZO1L15lxVA==" + }, "throat": { "version": "6.0.1", "integrity": "sha512-8hmiGIJMDlwjg7dlJ4yKGLK8EsYqKgPWbG3b4wjJddKNwc7N7Dpn08Df4szr/sZdMVeOstrdYSsqzX6BYbcB+w==", diff --git a/bundle/package.json b/bundle/package.json index b8678f81..484c0f05 100644 --- a/bundle/package.json +++ b/bundle/package.json @@ -37,12 +37,14 @@ "@types/i18next-node-fs-backend": "^2.1.0", "@types/jest": "^27.0.1", "@types/jest-expect-message": "^1.0.3", + "@types/json-bigint": "^1.0.1", "@types/jsonwebtoken": "^8.5.0", "@types/morgan": "^1.9.3", "@types/multer": "^1.4.7", "@types/node": "^14.18.24", "@types/node-fetch": "^2.5.12", "@types/node-os-utils": "^1.2.0", + "@types/sharp": "^0.30.4", "@types/supertest": "^2.0.11", "@types/ws": "^7.4.0", "@zerollup/ts-transform-paths": "^1.7.18", @@ -54,8 +56,7 @@ "ts-patch": "^1.4.4", "tsconfig-paths": "^3.12.0", "typescript": "^4.2.3", - "typescript-json-schema": "0.50.1", - "@types/sharp": "^0.30.4" + "typescript-json-schema": "0.50.1" }, "dependencies": { "@aws-sdk/client-s3": "^3.36.1", @@ -81,6 +82,7 @@ "exif-be-gone": "^1.2.0", "express": "^4.17.1", "express-async-errors": "^3.1.1", + "fast-zlib": "^2.0.1", "file-type": "^16.5.4", "form-data": "^4.0.0", "fs-extra": "^10.0.0", @@ -89,6 +91,7 @@ "i18next-node-fs-backend": "^2.1.3", "image-size": "^1.0.0", "jest": "^27.0.6", + "json-bigint": "^1.0.0", "jsonwebtoken": "^8.5.1", "lambert-db": "^1.2.3", "lambert-server": "^1.2.11", @@ -97,6 +100,7 @@ "multer": "^1.4.2", "nan": "^2.15.0", "nanocolors": "^0.2.12", + "node-2fa": "^2.0.3", "node-fetch": "^2.6.2", "node-os-utils": "^1.3.5", "patch-package": "^6.4.7", @@ -104,6 +108,7 @@ "picocolors": "^1.0.0", "proxy-agent": "^5.0.0", "reflect-metadata": "^0.1.13", + "sharp": "^0.30.7", "sqlite3": "^4.2.0", "supertest": "^6.1.6", "tslib": "^2.3.1", @@ -111,8 +116,6 @@ "typescript": "^4.1.2", "typescript-cached-transpile": "^0.0.6", "typescript-json-schema": "^0.50.1", - "ws": "^7.4.2", - "sharp": "^0.30.7", - "fast-zlib": "^2.0.1" + "ws": "^7.4.2" } -} \ No newline at end of file +} diff --git a/gateway/package-lock.json b/gateway/package-lock.json index 38bdab90..e39901de 100644 --- a/gateway/package-lock.json +++ b/gateway/package-lock.json @@ -8,11 +8,13 @@ "name": "@fosscord/gateway", "version": "1.0.0", "hasInstallScript": true, - "license": "GPLV3", + "license": "AGPL-3.0-only", "dependencies": { "@fosscord/util": "file:../util", "amqplib": "^0.8.0", "dotenv": "^8.2.0", + "fast-zlib": "^2.0.1", + "json-bigint": "^1.0.0", "jsonwebtoken": "^8.5.1", "lambert-server": "^1.2.11", "missing-native-js-functions": "^1.2.18", @@ -23,8 +25,9 @@ }, "devDependencies": { "@types/amqplib": "^0.8.1", + "@types/json-bigint": "^1.0.1", "@types/jsonwebtoken": "^8.5.0", - "@types/node": "^14.17.9", + "@types/node": "^14.18.24", "@types/node-fetch": "^2.5.12", "@types/ws": "^7.4.0", "@zerollup/ts-transform-paths": "^1.7.18", @@ -40,7 +43,7 @@ "name": "@fosscord/util", "version": "1.0.0", "hasInstallScript": true, - "license": "GPLV3", + "license": "AGPL-3.0-only", "dependencies": { "amqplib": "^0.8.0", "form-data": "^4.0.0", @@ -54,7 +57,7 @@ "picocolors": "^1.0.0", "proxy-agent": "^5.0.0", "reflect-metadata": "^0.1.13", - "typeorm": "^0.2.38", + "typeorm": "^0.2.37", "typescript": "^4.4.2", "typescript-json-schema": "^0.50.1" }, @@ -7164,6 +7167,12 @@ "integrity": "sha512-HBNx4lhkxN7bx6P0++W8E289foSu8kO8GCk2unhuVggO+cE7rh9DhZUyPhUxNRG9m+5B5BTKxZQ5ZP92x/mx9Q==", "dev": true }, + "node_modules/@types/json-bigint": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@types/json-bigint/-/json-bigint-1.0.1.tgz", + "integrity": "sha512-zpchZLNsNuzJHi6v64UBoFWAvQlPhch7XAi36FkH6tL1bbbmimIF+cS7vwkzY4u5RaSWMoflQfu+TshMPPw8uw==", + "dev": true + }, "node_modules/@types/jsonwebtoken": { "version": "8.5.5", "integrity": "sha512-OGqtHQ7N5/Ap/TUwO6IgHDuLiAoTmHhGpNvgkCm/F4N6pKzx/RBSfr2OXZSwC6vkfnsEdb6+7DNZVtiXiwdwFw==", @@ -7173,8 +7182,9 @@ } }, "node_modules/@types/node": { - "version": "14.17.16", - "integrity": "sha512-WiFf2izl01P1CpeY8WqFAeKWwByMueBEkND38EcN8N68qb0aDG3oIS1P5MhAX5kUdr469qRyqsY/MjanLjsFbQ==", + "version": "14.18.25", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.25.tgz", + "integrity": "sha512-9pLfceRSrKIsv/MISN6RoFWTIzka36Uk2Uuf5a8cHyDYhEgl5Hm5dXoe621KULeBjt+cFsY18mILsWWtJeG80w==", "dev": true }, "node_modules/@types/node-fetch": { @@ -7459,6 +7469,14 @@ } ] }, + "node_modules/bignumber.js": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.1.0.tgz", + "integrity": "sha512-4LwHK4nfDOraBCtst+wOWIHbu1vhvAPJK8g8nROd4iuc3PSEjWif/qwbkh8jwCJz6yDBvtU4KPynETgrfh7y3A==", + "engines": { + "node": "*" + } + }, "node_modules/binary-extensions": { "version": "2.2.0", "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", @@ -8012,6 +8030,15 @@ "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=" }, + "node_modules/fast-zlib": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/fast-zlib/-/fast-zlib-2.0.1.tgz", + "integrity": "sha512-DCoYgNagM2Bt1VIpXpdGnRx4LzqJeYG0oh6Nf/7cWo6elTXkFGMw9CrRCYYUIapYNrozYMoyDRflx9mgT3Awyw==", + "funding": { + "type": "patreon", + "url": "https://patreon.com/timotejroiko" + } + }, "node_modules/figlet": { "version": "1.5.2", "integrity": "sha512-WOn21V8AhyE1QqVfPIVxe3tupJacq1xGkPTB4iagT6o+P2cAgEOOwIxMftr4+ZCTI6d551ij9j61DFr0nsP2uQ==", @@ -8560,6 +8587,14 @@ "js-yaml": "bin/js-yaml.js" } }, + "node_modules/json-bigint": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-bigint/-/json-bigint-1.0.0.tgz", + "integrity": "sha512-SiPv/8VpZuWbvLSMtTDU8hEfrZWg/mH/nV/b4o0CYbSxu1UIQPLdwKOCIyLQX+VIPO5vrLX3i8qtqFyhdPSUSQ==", + "dependencies": { + "bignumber.js": "^9.0.0" + } + }, "node_modules/jsonfile": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", @@ -10226,7 +10261,7 @@ "proxy-agent": "^5.0.0", "reflect-metadata": "^0.1.13", "ts-node": "^10.2.1", - "typeorm": "^0.2.38", + "typeorm": "^0.2.37", "typescript": "^4.4.2", "typescript-json-schema": "^0.50.1" }, @@ -15633,6 +15668,12 @@ "integrity": "sha512-HBNx4lhkxN7bx6P0++W8E289foSu8kO8GCk2unhuVggO+cE7rh9DhZUyPhUxNRG9m+5B5BTKxZQ5ZP92x/mx9Q==", "dev": true }, + "@types/json-bigint": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@types/json-bigint/-/json-bigint-1.0.1.tgz", + "integrity": "sha512-zpchZLNsNuzJHi6v64UBoFWAvQlPhch7XAi36FkH6tL1bbbmimIF+cS7vwkzY4u5RaSWMoflQfu+TshMPPw8uw==", + "dev": true + }, "@types/jsonwebtoken": { "version": "8.5.5", "integrity": "sha512-OGqtHQ7N5/Ap/TUwO6IgHDuLiAoTmHhGpNvgkCm/F4N6pKzx/RBSfr2OXZSwC6vkfnsEdb6+7DNZVtiXiwdwFw==", @@ -15642,8 +15683,9 @@ } }, "@types/node": { - "version": "14.17.16", - "integrity": "sha512-WiFf2izl01P1CpeY8WqFAeKWwByMueBEkND38EcN8N68qb0aDG3oIS1P5MhAX5kUdr469qRyqsY/MjanLjsFbQ==", + "version": "14.18.25", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.25.tgz", + "integrity": "sha512-9pLfceRSrKIsv/MISN6RoFWTIzka36Uk2Uuf5a8cHyDYhEgl5Hm5dXoe621KULeBjt+cFsY18mILsWWtJeG80w==", "dev": true }, "@types/node-fetch": { @@ -15867,6 +15909,11 @@ "version": "1.5.1", "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==" }, + "bignumber.js": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.1.0.tgz", + "integrity": "sha512-4LwHK4nfDOraBCtst+wOWIHbu1vhvAPJK8g8nROd4iuc3PSEjWif/qwbkh8jwCJz6yDBvtU4KPynETgrfh7y3A==" + }, "binary-extensions": { "version": "2.2.0", "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", @@ -16307,6 +16354,11 @@ "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=" }, + "fast-zlib": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/fast-zlib/-/fast-zlib-2.0.1.tgz", + "integrity": "sha512-DCoYgNagM2Bt1VIpXpdGnRx4LzqJeYG0oh6Nf/7cWo6elTXkFGMw9CrRCYYUIapYNrozYMoyDRflx9mgT3Awyw==" + }, "figlet": { "version": "1.5.2", "integrity": "sha512-WOn21V8AhyE1QqVfPIVxe3tupJacq1xGkPTB4iagT6o+P2cAgEOOwIxMftr4+ZCTI6d551ij9j61DFr0nsP2uQ==" @@ -16703,6 +16755,14 @@ "argparse": "^2.0.1" } }, + "json-bigint": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-bigint/-/json-bigint-1.0.0.tgz", + "integrity": "sha512-SiPv/8VpZuWbvLSMtTDU8hEfrZWg/mH/nV/b4o0CYbSxu1UIQPLdwKOCIyLQX+VIPO5vrLX3i8qtqFyhdPSUSQ==", + "requires": { + "bignumber.js": "^9.0.0" + } + }, "jsonfile": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", diff --git a/gateway/package.json b/gateway/package.json index 205cd9c1..ad500897 100644 --- a/gateway/package.json +++ b/gateway/package.json @@ -16,6 +16,7 @@ "license": "AGPL-3.0-only", "devDependencies": { "@types/amqplib": "^0.8.1", + "@types/json-bigint": "^1.0.1", "@types/jsonwebtoken": "^8.5.0", "@types/node": "^14.18.24", "@types/node-fetch": "^2.5.12", @@ -30,6 +31,7 @@ "amqplib": "^0.8.0", "dotenv": "^8.2.0", "fast-zlib": "^2.0.1", + "json-bigint": "^1.0.0", "jsonwebtoken": "^8.5.1", "lambert-server": "^1.2.11", "missing-native-js-functions": "^1.2.18", diff --git a/gateway/src/events/Message.ts b/gateway/src/events/Message.ts index e9271da4..1a177e0c 100644 --- a/gateway/src/events/Message.ts +++ b/gateway/src/events/Message.ts @@ -8,6 +8,8 @@ import OPCodeHandlers from "../opcodes"; import { Tuple } from "lambert-server"; import { check } from "../opcodes/instanceOf"; import WS from "ws"; +import BigIntJson from "json-bigint"; +const bigIntJson = BigIntJson({ storeAsString: true }); const PayloadSchema = { op: Number, @@ -30,16 +32,13 @@ export async function Message(this: WebSocket, buffer: WS.Data) { buffer = buffer.toString() as any; } } - data = JSON.parse(buffer as string); + data = bigIntJson.parse(buffer as string); } else if (typeof buffer == "string") { - data = JSON.parse(buffer as string); + data = bigIntJson.parse(buffer as string) } else return; - // TODO: find a way to properly convert a funny number to string - if (data?.op == 14 && typeof data.d.guild_id == "number") return; - check.call(this, PayloadSchema, data); // @ts-ignore @@ -54,7 +53,7 @@ export async function Message(this: WebSocket, buffer: WS.Data) { try { return await OPCodeHandler.call(this, data); } catch (error) { - console.error(error); + console.error(`Error: Op ${data.op}`, error); // if (!this.CLOSED && this.CLOSING) return this.close(CLOSECODES.Unknown_error); } diff --git a/gateway/src/listener/listener.ts b/gateway/src/listener/listener.ts index 060de65b..8a90ce0c 100644 --- a/gateway/src/listener/listener.ts +++ b/gateway/src/listener/listener.ts @@ -241,7 +241,7 @@ async function consume(this: WebSocket, opts: EventOpts) { break; } - Send(this, { + await Send(this, { op: OPCODES.Dispatch, t: event, d: data, diff --git a/gateway/src/opcodes/Identify.ts b/gateway/src/opcodes/Identify.ts index 041512c5..57c45d1f 100644 --- a/gateway/src/opcodes/Identify.ts +++ b/gateway/src/opcodes/Identify.ts @@ -137,12 +137,13 @@ export async function onIdentify(this: WebSocket, data: Payload) { guilds = guilds.map((guild) => { if (user.bot) { setTimeout(() => { - Send(this, { + var promise = Send(this, { op: OPCODES.Dispatch, t: EVENTEnum.GuildCreate, s: this.sequence++, d: guild, }); + if (promise) promise.catch(console.error); }, 500); return { id: guild.id, unavailable: true }; } diff --git a/gateway/src/opcodes/LazyRequest.ts b/gateway/src/opcodes/LazyRequest.ts index 0db35286..54b06eb2 100644 --- a/gateway/src/opcodes/LazyRequest.ts +++ b/gateway/src/opcodes/LazyRequest.ts @@ -39,13 +39,16 @@ async function getMembers(guild_id: string, range: [number, number]) { } catch (e) { console.error(`LazyRequest`, e); + } + + if (!members) { return { items: [], groups: [], range: [], members: [], - } - } + }; + } const groups = [] as any[]; const items = []; @@ -157,7 +160,7 @@ export async function onLazyRequest(this: WebSocket, { d }: Payload) { .flat() .unique(); - return Send(this, { + return await Send(this, { op: OPCODES.Dispatch, s: this.sequence++, t: "GUILD_MEMBER_LIST_UPDATE", |