diff --git a/assets/openapi.json b/assets/openapi.json index 05474f8..4129af5 100644 --- a/assets/openapi.json +++ b/assets/openapi.json @@ -69,7 +69,10 @@ "type": "string" }, "name_localizations": { - "$ref": "#/components/schemas/Record" + "type": "object", + "additionalProperties": { + "type": "string" + } }, "name_localized": { "type": "string", @@ -79,7 +82,10 @@ "type": "string" }, "description_localizations": { - "$ref": "#/components/schemas/Record" + "type": "object", + "additionalProperties": { + "type": "string" + } }, "description_localized": { "type": "string", @@ -9696,6 +9702,23 @@ "user_ids" ] }, + "PartialEmoji": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "animated": { + "type": "boolean" + } + }, + "required": [ + "name" + ] + }, "MessageType": { "type": "number", "enum": [ @@ -11212,6 +11235,127 @@ "type" ] }, + "PartialMessage": { + "description": "https://docs.discord.food/resources/message#partial-message-structure", + "type": "object", + "properties": { + "id": { + "description": "A Twitter-like snowflake, except the epoch is 2015-01-01T00:00:00.000Z\n```\nIf we have a snowflake '266241948824764416' we can represent it as binary:\n\n64 22 17 12 0\n 000000111011000111100001101001000101000000 00001 00000 000000000000\n number of ms since Discord epoch worker pid increment\n```", + "type": "string" + }, + "channel_id": { + "type": "string" + }, + "type": { + "$ref": "#/components/schemas/MessageType" + }, + "content": { + "type": "string" + }, + "author": { + "$ref": "#/components/schemas/PartialUser" + }, + "flags": { + "type": "integer" + }, + "application_id": { + "type": "string" + } + }, + "required": [ + "author", + "channel_id", + "content", + "id", + "type" + ] + }, + "PartialUser": { + "type": "object", + "properties": { + "id": { + "description": "A Twitter-like snowflake, except the epoch is 2015-01-01T00:00:00.000Z\n```\nIf we have a snowflake '266241948824764416' we can represent it as binary:\n\n64 22 17 12 0\n 000000111011000111100001101001000101000000 00001 00000 000000000000\n number of ms since Discord epoch worker pid increment\n```", + "type": "string" + }, + "username": { + "type": "string" + }, + "discriminator": { + "type": "string" + }, + "global_name": { + "type": "string", + "nullable": true + }, + "avatar": { + "type": "string", + "nullable": true + }, + "avatar_decoration_data": { + "anyOf": [ + { + "$ref": "#/components/schemas/AvatarDecorationData" + }, + { + "type": "null" + } + ] + }, + "collectibles": { + "anyOf": [ + { + "$ref": "#/components/schemas/Collectibles" + }, + { + "type": "null" + } + ] + }, + "display_name_styles": { + "anyOf": [ + { + "$ref": "#/components/schemas/DisplayNameStyle" + }, + { + "type": "null" + } + ] + }, + "primary_guild": { + "anyOf": [ + { + "$ref": "#/components/schemas/PrimaryGuild" + }, + { + "type": "null" + } + ] + }, + "bot": { + "type": "boolean" + }, + "system": { + "type": "boolean" + }, + "banner": { + "type": "string", + "nullable": true + }, + "accent_color": { + "type": "integer", + "nullable": true + }, + "public_flags": { + "type": "integer" + } + }, + "required": [ + "avatar", + "discriminator", + "id", + "username" + ] + }, "AvatarDecorationData": { "type": "object", "properties": { @@ -21182,6 +21326,61 @@ ] } }, + "/channels/{channel_id}/messages/search/": { + "get": { + "security": [ + { + "bearer": [] + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GuildMessagesSearchResponse" + } + } + } + }, + "403": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/APIErrorResponse" + } + } + } + }, + "422": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/APIErrorResponse" + } + } + } + } + }, + "parameters": [ + { + "name": "channel_id", + "in": "path", + "required": true, + "schema": { + "type": "string" + }, + "description": "channel_id" + } + ], + "tags": [ + "channels" + ] + } + }, "/channels/{channel_id}/messages/pins/{message_id}": { "put": { "x-permission-required": "VIEW_CHANNEL", diff --git a/package-lock.json b/package-lock.json index c194261..caf3689 100644 --- a/package-lock.json +++ b/package-lock.json @@ -41,11 +41,9 @@ "multer": "^2.0.2", "murmurhash-js": "^1.0.0", "node-2fa": "^2.0.3", - "node-fetch-commonjs": "^3.3.2", "pg": "^8.16.3", "picocolors": "^1.1.1", "probe-image-size": "^7.2.3", - "proxy-agent": "^6.5.0", "reflect-metadata": "^0.2.2", "sqlite3": "^5.1.7", "tslib": "^2.8.1", @@ -70,7 +68,6 @@ "@types/multer": "^2.0.0", "@types/murmurhash-js": "^1.0.6", "@types/node": "^24.10.1", - "@types/node-fetch": "^2.6.13", "@types/nodemailer": "^7.0.4", "@types/probe-image-size": "^7.2.5", "@types/sharp": "^0.31.1", @@ -3137,12 +3134,6 @@ "node": ">= 6" } }, - "node_modules/@tootallnate/quickjs-emscripten": { - "version": "0.23.0", - "resolved": "https://registry.npmjs.org/@tootallnate/quickjs-emscripten/-/quickjs-emscripten-0.23.0.tgz", - "integrity": "sha512-C5Mc6rdnsaJDjO3UpGW/CQTHtCKaYlScZTly4JIu97Jxo/odCiH0ITnDXSJPTOrEKk/ycSZ0AOgTmkDtkOsvIA==", - "license": "MIT" - }, "node_modules/@tsconfig/node10": { "version": "1.0.12", "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.12.tgz", @@ -3365,17 +3356,6 @@ "undici-types": "~7.16.0" } }, - "node_modules/@types/node-fetch": { - "version": "2.6.13", - "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.13.tgz", - "integrity": "sha512-QGpRVpzSaUs30JBSGPjOg4Uveu384erbHBoT1zeONvyCfwQxIkUshLAOqN/k9EjGviPRmWTTe6aH2qySWKTVSw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/node": "*", - "form-data": "^4.0.4" - } - }, "node_modules/@types/nodemailer": { "version": "7.0.4", "resolved": "https://registry.npmjs.org/@types/nodemailer/-/nodemailer-7.0.4.tgz", @@ -4026,18 +4006,6 @@ "node": ">=12.0.0" } }, - "node_modules/ast-types": { - "version": "0.13.4", - "resolved": "https://registry.npmjs.org/ast-types/-/ast-types-0.13.4.tgz", - "integrity": "sha512-x1FCFnFifvYDDzTaLII71vG5uvDwgtmDTEVWAxrgeiR8VjMONcCXJx7E+USjDtHlwFmt9MysbqgF9b9Vjr6w+w==", - "license": "MIT", - "dependencies": { - "tslib": "^2.0.1" - }, - "engines": { - "node": ">=4" - } - }, "node_modules/asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", @@ -4132,15 +4100,6 @@ "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", "license": "MIT" }, - "node_modules/basic-ftp": { - "version": "5.0.5", - "resolved": "https://registry.npmjs.org/basic-ftp/-/basic-ftp-5.0.5.tgz", - "integrity": "sha512-4Bcg1P8xhUuqcii/S0Z9wiHIrQVPMermM1any+MX5GeGD7faD3/msQUDGLol9wOcz4/jbg/WJnGqoJF6LiBdtg==", - "license": "MIT", - "engines": { - "node": ">=10.0.0" - } - }, "node_modules/bcrypt": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/bcrypt/-/bcrypt-6.0.0.tgz", @@ -4742,15 +4701,6 @@ "url": "https://github.com/sponsors/fb55" } }, - "node_modules/data-uri-to-buffer": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-6.0.2.tgz", - "integrity": "sha512-7hvf7/GW8e86rW0ptuwS3OcBGDjIi6SZva7hCyWC0yYry2cOPmLIjXAUHI6DK2HsnwJd9ifmt57i8eV2n4YNpw==", - "license": "MIT", - "engines": { - "node": ">= 14" - } - }, "node_modules/dayjs": { "version": "1.11.19", "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.19.tgz", @@ -4846,20 +4796,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/degenerator": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/degenerator/-/degenerator-5.0.1.tgz", - "integrity": "sha512-TllpMR/t0M5sqCXfj85i4XaAzxmS5tVA16dqvdkMwGmzI+dXLXnw3J+3Vdv7VKw+ThlTMboK6i9rnZ6Nntj5CQ==", - "license": "MIT", - "dependencies": { - "ast-types": "^0.13.4", - "escodegen": "^2.1.0", - "esprima": "^4.0.1" - }, - "engines": { - "node": ">= 14" - } - }, "node_modules/delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", @@ -5173,27 +5109,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/escodegen": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-2.1.0.tgz", - "integrity": "sha512-2NlIDTwUWJN0mRPQOdtQBzbUHvdGY2P1VXSyU83Q3xKxM7WHX2Ql8dKq782Q9TgQUNOLEzEYu9bzLNj1q88I5w==", - "license": "BSD-2-Clause", - "dependencies": { - "esprima": "^4.0.1", - "estraverse": "^5.2.0", - "esutils": "^2.0.2" - }, - "bin": { - "escodegen": "bin/escodegen.js", - "esgenerate": "bin/esgenerate.js" - }, - "engines": { - "node": ">=6.0" - }, - "optionalDependencies": { - "source-map": "~0.6.1" - } - }, "node_modules/eslint": { "version": "9.39.1", "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.39.1.tgz", @@ -5370,19 +5285,6 @@ "url": "https://opencollective.com/eslint" } }, - "node_modules/esprima": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", - "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", - "license": "BSD-2-Clause", - "bin": { - "esparse": "bin/esparse.js", - "esvalidate": "bin/esvalidate.js" - }, - "engines": { - "node": ">=4" - } - }, "node_modules/esquery": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.6.0.tgz", @@ -5413,6 +5315,7 @@ "version": "5.3.0", "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "dev": true, "license": "BSD-2-Clause", "engines": { "node": ">=4.0" @@ -5422,6 +5325,7 @@ "version": "2.0.3", "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "dev": true, "license": "BSD-2-Clause", "engines": { "node": ">=0.10.0" @@ -6005,20 +5909,6 @@ "node": ">= 0.4" } }, - "node_modules/get-uri": { - "version": "6.0.5", - "resolved": "https://registry.npmjs.org/get-uri/-/get-uri-6.0.5.tgz", - "integrity": "sha512-b1O07XYq8eRuVzBNgJLstU6FYc1tS6wnMtF1I1D9lE8LxZSOGZ7LhxN54yPP6mGw5f2CkXY2BQUL9Fx41qvcIg==", - "license": "MIT", - "dependencies": { - "basic-ftp": "^5.0.2", - "data-uri-to-buffer": "^6.0.2", - "debug": "^4.3.4" - }, - "engines": { - "node": ">= 14" - } - }, "node_modules/gifwrap": { "version": "0.10.1", "resolved": "https://registry.npmjs.org/gifwrap/-/gifwrap-0.10.1.tgz", @@ -6241,28 +6131,6 @@ "node": ">= 0.8" } }, - "node_modules/http-proxy-agent": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-7.0.2.tgz", - "integrity": "sha512-T1gkAiYYDWYx3V5Bmyu7HcfcvL7mUrTWiM6yOfa3PIphViJ/gFPbvidQ+veqSOHci/PxBcDabeUNCzpOODJZig==", - "license": "MIT", - "dependencies": { - "agent-base": "^7.1.0", - "debug": "^4.3.4" - }, - "engines": { - "node": ">= 14" - } - }, - "node_modules/http-proxy-agent/node_modules/agent-base": { - "version": "7.1.4", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.4.tgz", - "integrity": "sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ==", - "license": "MIT", - "engines": { - "node": ">= 14" - } - }, "node_modules/https-proxy-agent": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", @@ -6490,6 +6358,7 @@ "resolved": "https://registry.npmjs.org/ip-address/-/ip-address-10.1.0.tgz", "integrity": "sha512-XXADHxXmvT9+CRxhXg56LJovE+bmWnEWB78LB83VZTprKTmaC5QfruXocxzTZ2Kl0DNwKuBdlIhjL8LeY8Sf8Q==", "license": "MIT", + "optional": true, "engines": { "node": ">= 12" } @@ -6922,15 +6791,6 @@ "integrity": "sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg==", "license": "MIT" }, - "node_modules/lru-cache": { - "version": "7.18.3", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.18.3.tgz", - "integrity": "sha512-jumlc0BIUrS3qJGgIkWZsyfAM7NCWiBcCDhnd+3NNM5KbBmLTgHVfWBcg6W+rLUsIpzpERPsvwUP7CckAQSOoA==", - "license": "ISC", - "engines": { - "node": ">=12" - } - }, "node_modules/mailgun.js": { "version": "12.1.1", "resolved": "https://registry.npmjs.org/mailgun.js/-/mailgun.js-12.1.1.tgz", @@ -7491,15 +7351,6 @@ "node": ">= 0.6" } }, - "node_modules/netmask": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/netmask/-/netmask-2.0.2.tgz", - "integrity": "sha512-dBpDMdxv9Irdq66304OLfEmQ9tbNRFnFTuZiLo+bD+r332bBmMJ8GBLXklIXXgxd3+v9+KUnZaUR5PJMa75Gsg==", - "license": "MIT", - "engines": { - "node": ">= 0.4.0" - } - }, "node_modules/node-2fa": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/node-2fa/-/node-2fa-2.0.3.tgz", @@ -7531,26 +7382,6 @@ "license": "MIT", "optional": true }, - "node_modules/node-domexception": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz", - "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==", - "deprecated": "Use your platform's native DOMException instead", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/jimmywarting" - }, - { - "type": "github", - "url": "https://paypal.me/jimmywarting" - } - ], - "license": "MIT", - "engines": { - "node": ">=10.5.0" - } - }, "node_modules/node-fetch": { "version": "2.7.0", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", @@ -7572,23 +7403,6 @@ } } }, - "node_modules/node-fetch-commonjs": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/node-fetch-commonjs/-/node-fetch-commonjs-3.3.2.tgz", - "integrity": "sha512-VBlAiynj3VMLrotgwOS3OyECFxas5y7ltLcK4t41lMUZeaK15Ym4QRkqN0EQKAFL42q9i21EPKjzLUPfltR72A==", - "license": "MIT", - "dependencies": { - "node-domexception": "^1.0.0", - "web-streams-polyfill": "^3.0.3" - }, - "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/node-fetch" - } - }, "node_modules/node-gyp": { "version": "8.4.1", "resolved": "https://registry.npmjs.org/node-gyp/-/node-gyp-8.4.1.tgz", @@ -7920,60 +7734,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/pac-proxy-agent": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/pac-proxy-agent/-/pac-proxy-agent-7.2.0.tgz", - "integrity": "sha512-TEB8ESquiLMc0lV8vcd5Ql/JAKAoyzHFXaStwjkzpOpC5Yv+pIzLfHvjTSdf3vpa2bMiUQrg9i6276yn8666aA==", - "license": "MIT", - "dependencies": { - "@tootallnate/quickjs-emscripten": "^0.23.0", - "agent-base": "^7.1.2", - "debug": "^4.3.4", - "get-uri": "^6.0.1", - "http-proxy-agent": "^7.0.0", - "https-proxy-agent": "^7.0.6", - "pac-resolver": "^7.0.1", - "socks-proxy-agent": "^8.0.5" - }, - "engines": { - "node": ">= 14" - } - }, - "node_modules/pac-proxy-agent/node_modules/agent-base": { - "version": "7.1.4", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.4.tgz", - "integrity": "sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ==", - "license": "MIT", - "engines": { - "node": ">= 14" - } - }, - "node_modules/pac-proxy-agent/node_modules/https-proxy-agent": { - "version": "7.0.6", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.6.tgz", - "integrity": "sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw==", - "license": "MIT", - "dependencies": { - "agent-base": "^7.1.2", - "debug": "4" - }, - "engines": { - "node": ">= 14" - } - }, - "node_modules/pac-resolver": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/pac-resolver/-/pac-resolver-7.0.1.tgz", - "integrity": "sha512-5NPgf87AT2STgwa2ntRMr45jTKrYBGkVU36yT0ig/n/GMAa3oPqhZfIQ2kMEimReg0+t9kZViDVZ83qfVUlckg==", - "license": "MIT", - "dependencies": { - "degenerator": "^5.0.0", - "netmask": "^2.0.2" - }, - "engines": { - "node": ">= 14" - } - }, "node_modules/package-json-from-dist": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz", @@ -8587,52 +8347,12 @@ "node": ">= 0.10" } }, - "node_modules/proxy-agent": { - "version": "6.5.0", - "resolved": "https://registry.npmjs.org/proxy-agent/-/proxy-agent-6.5.0.tgz", - "integrity": "sha512-TmatMXdr2KlRiA2CyDu8GqR8EjahTG3aY3nXjdzFyoZbmB8hrBsTyMezhULIXKnC0jpfjlmiZ3+EaCzoInSu/A==", - "license": "MIT", - "dependencies": { - "agent-base": "^7.1.2", - "debug": "^4.3.4", - "http-proxy-agent": "^7.0.1", - "https-proxy-agent": "^7.0.6", - "lru-cache": "^7.14.1", - "pac-proxy-agent": "^7.1.0", - "proxy-from-env": "^1.1.0", - "socks-proxy-agent": "^8.0.5" - }, - "engines": { - "node": ">= 14" - } - }, - "node_modules/proxy-agent/node_modules/agent-base": { - "version": "7.1.4", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.4.tgz", - "integrity": "sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ==", - "license": "MIT", - "engines": { - "node": ">= 14" - } - }, - "node_modules/proxy-agent/node_modules/https-proxy-agent": { - "version": "7.0.6", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.6.tgz", - "integrity": "sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw==", - "license": "MIT", - "dependencies": { - "agent-base": "^7.1.2", - "debug": "4" - }, - "engines": { - "node": ">= 14" - } - }, "node_modules/proxy-from-env": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", - "license": "MIT" + "license": "MIT", + "optional": true }, "node_modules/pump": { "version": "3.0.3", @@ -9290,6 +9010,7 @@ "resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz", "integrity": "sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg==", "license": "MIT", + "optional": true, "engines": { "node": ">= 6.0.0", "npm": ">= 3.0.0" @@ -9300,6 +9021,7 @@ "resolved": "https://registry.npmjs.org/socks/-/socks-2.8.7.tgz", "integrity": "sha512-HLpt+uLy/pxB+bum/9DzAgiKS8CX1EvbWxI4zlmgGCExImLdiad2iCwXT5Z4c9c3Eq8rP2318mPW2c+QbtjK8A==", "license": "MIT", + "optional": true, "dependencies": { "ip-address": "^10.0.1", "smart-buffer": "^4.2.0" @@ -9309,39 +9031,6 @@ "npm": ">= 3.0.0" } }, - "node_modules/socks-proxy-agent": { - "version": "8.0.5", - "resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-8.0.5.tgz", - "integrity": "sha512-HehCEsotFqbPW9sJ8WVYB6UbmIMv7kUUORIF2Nncq4VQvBfNBLibW9YZR5dlYCSUhwcD628pRllm7n+E+YTzJw==", - "license": "MIT", - "dependencies": { - "agent-base": "^7.1.2", - "debug": "^4.3.4", - "socks": "^2.8.3" - }, - "engines": { - "node": ">= 14" - } - }, - "node_modules/socks-proxy-agent/node_modules/agent-base": { - "version": "7.1.4", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.4.tgz", - "integrity": "sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ==", - "license": "MIT", - "engines": { - "node": ">= 14" - } - }, - "node_modules/source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "license": "BSD-3-Clause", - "optional": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/split2": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/split2/-/split2-4.2.0.tgz", @@ -10269,15 +9958,6 @@ "node": ">= 0.8" } }, - "node_modules/web-streams-polyfill": { - "version": "3.3.3", - "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz", - "integrity": "sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==", - "license": "MIT", - "engines": { - "node": ">= 8" - } - }, "node_modules/webcrypto-core": { "version": "1.8.1", "resolved": "https://registry.npmjs.org/webcrypto-core/-/webcrypto-core-1.8.1.tgz", diff --git a/package.json b/package.json index 01a705d..97bc567 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,6 @@ "@types/multer": "^2.0.0", "@types/murmurhash-js": "^1.0.6", "@types/node": "^24.10.1", - "@types/node-fetch": "^2.6.13", "@types/nodemailer": "^7.0.4", "@types/probe-image-size": "^7.2.5", "@types/sharp": "^0.31.1", @@ -104,11 +103,9 @@ "multer": "^2.0.2", "murmurhash-js": "^1.0.0", "node-2fa": "^2.0.3", - "node-fetch-commonjs": "^3.3.2", "pg": "^8.16.3", "picocolors": "^1.1.1", "probe-image-size": "^7.2.3", - "proxy-agent": "^6.5.0", "reflect-metadata": "^0.2.2", "sqlite3": "^5.1.7", "tslib": "^2.8.1", diff --git a/scripts/stress/login.js b/scripts/stress/login.js index 473e2e9..5cb254d 100644 --- a/scripts/stress/login.js +++ b/scripts/stress/login.js @@ -1,4 +1,3 @@ -const fetch = require("node-fetch"); const ENDPOINT = process.env.API || "http://localhost:3001"; async function main() { diff --git a/scripts/stress/users.js b/scripts/stress/users.js index 053943d..67fa3ec 100644 --- a/scripts/stress/users.js +++ b/scripts/stress/users.js @@ -17,7 +17,6 @@ */ require("dotenv").config({ quiet: true }); -const fetch = require("node-fetch"); const count = Number(process.env.COUNT) || 50; const endpoint = process.env.API || "http://localhost:3001"; diff --git a/src/api/middlewares/ImageProxy.ts b/src/api/middlewares/ImageProxy.ts index 814f0e6..d87a8de 100644 --- a/src/api/middlewares/ImageProxy.ts +++ b/src/api/middlewares/ImageProxy.ts @@ -20,7 +20,6 @@ import { Request, Response } from "express"; import { yellow } from "picocolors"; import crypto from "crypto"; -import fetch from "node-fetch-commonjs"; let sharp: undefined | false | { default: typeof import("sharp") } = undefined; diff --git "a/src/api/routes/channels/\043channel_id/attachments.ts" "b/src/api/routes/channels/\043channel_id/attachments.ts" index 2c08931..4699fe4 100644 --- "a/src/api/routes/channels/\043channel_id/attachments.ts" +++ "b/src/api/routes/channels/\043channel_id/attachments.ts" @@ -25,7 +25,6 @@ } from "@spacebar/util"; import { Request, Response, Router } from "express"; import { CloudAttachment } from "@spacebar/util"; -import fetch from "node-fetch-commonjs"; import { UploadAttachmentRequestSchema, UploadAttachmentResponseSchema } from "@spacebar/schemas" const router: Router = Router({ mergeParams: true }); diff --git a/src/api/routes/gifs/search.ts b/src/api/routes/gifs/search.ts index 378e398..199d43d 100644 --- a/src/api/routes/gifs/search.ts +++ b/src/api/routes/gifs/search.ts @@ -22,8 +22,6 @@ parseGifResult, } from "@spacebar/util"; import { Request, Response, Router } from "express"; -import fetch from "node-fetch-commonjs"; -import { ProxyAgent } from "proxy-agent"; import http from "http"; import { TenorGif, TenorMediaTypes } from "@spacebar/schemas" @@ -62,12 +60,9 @@ const apiKey = getGifApiKey(); - const agent = new ProxyAgent(); - const response = await fetch( `https://g.tenor.com/v1/search?q=${q}&media_format=${media_format}&locale=${locale}&key=${apiKey}`, { - agent: agent as http.Agent, method: "get", headers: { "Content-Type": "application/json" }, }, diff --git a/src/api/routes/gifs/trending-gifs.ts b/src/api/routes/gifs/trending-gifs.ts index 48c2a3b..8de1065 100644 --- a/src/api/routes/gifs/trending-gifs.ts +++ b/src/api/routes/gifs/trending-gifs.ts @@ -22,9 +22,6 @@ parseGifResult, } from "@spacebar/util"; import { Request, Response, Router } from "express"; -import fetch from "node-fetch-commonjs"; -import { ProxyAgent } from "proxy-agent"; -import http from "http"; import { TenorGif, TenorMediaTypes } from "@spacebar/schemas" const router = Router({ mergeParams: true }); @@ -57,12 +54,9 @@ const apiKey = getGifApiKey(); - const agent = new ProxyAgent(); - const response = await fetch( `https://g.tenor.com/v1/trending?media_format=${media_format}&locale=${locale}&key=${apiKey}`, { - agent: agent as http.Agent, method: "get", headers: { "Content-Type": "application/json" }, }, diff --git a/src/api/routes/gifs/trending.ts b/src/api/routes/gifs/trending.ts index bcbd450..59314af 100644 --- a/src/api/routes/gifs/trending.ts +++ b/src/api/routes/gifs/trending.ts @@ -22,9 +22,6 @@ parseGifResult, } from "@spacebar/util"; import { Request, Response, Router } from "express"; -import fetch from "node-fetch-commonjs"; -import { ProxyAgent } from "proxy-agent"; -import http from "http"; import { TenorCategoriesResults, TenorTrendingResults } from "@spacebar/schemas" const router = Router({ mergeParams: true }); @@ -52,13 +49,10 @@ const apiKey = getGifApiKey(); - const agent = new ProxyAgent(); - const [responseSource, trendGifSource] = await Promise.all([ fetch( `https://g.tenor.com/v1/categories?locale=${locale}&key=${apiKey}`, { - agent: agent as http.Agent, method: "get", headers: { "Content-Type": "application/json" }, }, @@ -66,7 +60,6 @@ fetch( `https://g.tenor.com/v1/trending?locale=${locale}&key=${apiKey}`, { - agent: agent as http.Agent, method: "get", headers: { "Content-Type": "application/json" }, }, diff --git a/src/api/routes/guilds/templates/index.ts b/src/api/routes/guilds/templates/index.ts index 7937e98..d5950a4 100644 --- a/src/api/routes/guilds/templates/index.ts +++ b/src/api/routes/guilds/templates/index.ts @@ -19,7 +19,6 @@ import { route } from "@spacebar/api"; import { Config, DiscordApiErrors, Guild, Member, Template } from "@spacebar/util"; import { Request, Response, Router } from "express"; -import fetch from "node-fetch-commonjs"; import { HTTPError } from "lambert-server"; import { GuildTemplateCreateSchema } from "@spacebar/schemas" diff --git a/src/api/util/handlers/Message.ts b/src/api/util/handlers/Message.ts index fd16301..828576a 100644 --- a/src/api/util/handlers/Message.ts +++ b/src/api/util/handlers/Message.ts @@ -50,7 +50,6 @@ } from "@spacebar/util"; import { HTTPError } from "lambert-server"; import { In, Or, Equal, IsNull } from "typeorm"; -import fetch from "node-fetch-commonjs"; import { ChannelType, Embed, EmbedType, MessageCreateAttachment, MessageCreateCloudAttachment, MessageCreateSchema, MessageType, Reaction } from "@spacebar/schemas"; const allow_empty = false; // TODO: check webhook, application, system author, stickers @@ -206,7 +205,7 @@ } if (opts.avatar_url) { const avatarData = await fetch(opts.avatar_url); - const base64 = await avatarData.buffer().then((x) => x.toString("base64")); + const base64 = await avatarData.text().then((x) => btoa(x)); const dataUri = "data:" + avatarData.headers.get("content-type") + ";base64," + base64; diff --git a/src/api/util/utility/EmbedHandlers.ts b/src/api/util/utility/EmbedHandlers.ts index f93df3e..96fbe1c 100644 --- a/src/api/util/utility/EmbedHandlers.ts +++ b/src/api/util/utility/EmbedHandlers.ts @@ -20,19 +20,16 @@ import { Embed, EmbedImage, EmbedType } from "@spacebar/schemas"; import * as cheerio from "cheerio"; import crypto from "crypto"; -import fetch, { RequestInit } from "node-fetch-commonjs"; import { yellow } from "picocolors"; import probe from "probe-image-size"; export const DEFAULT_FETCH_OPTIONS: RequestInit = { redirect: "follow", - follow: 1, headers: { "user-agent": "Mozilla/5.0 (compatible; Spacebar/1.0; +https://github.com/spacebarchat/server)", }, // size: 1024 * 1024 * 5, // grabbed from config later - compress: true, method: "GET", }; @@ -130,10 +127,16 @@ const doFetch = async (url: URL) => { try { - return await fetch(url, { + const res = await fetch(url, { ...DEFAULT_FETCH_OPTIONS, - size: Config.get().limits.message.maxEmbedDownloadSize, }); + if (res.headers.get("content-length")) { + const contentLength = parseInt(res.headers.get("content-length")!); + if (Config.get().limits.message.maxEmbedDownloadSize && contentLength > Config.get().limits.message.maxEmbedDownloadSize) { + return null; + } + } + return res; } catch (e) { return null; } diff --git a/src/api/util/utility/captcha.ts b/src/api/util/utility/captcha.ts index 3c0ac76..3f654a4 100644 --- a/src/api/util/utility/captcha.ts +++ b/src/api/util/utility/captcha.ts @@ -17,7 +17,6 @@ */ import { Config } from "@spacebar/util"; -import fetch from "node-fetch-commonjs"; export interface hcaptchaResponse { success: boolean; diff --git a/src/api/util/utility/ipAddress.ts b/src/api/util/utility/ipAddress.ts index c19c7c3..2609dae 100644 --- a/src/api/util/utility/ipAddress.ts +++ b/src/api/util/utility/ipAddress.ts @@ -19,7 +19,6 @@ import { Config } from "@spacebar/util"; import { Request } from "express"; // use ipdata package instead of simple fetch because of integrated caching -import fetch from "node-fetch-commonjs"; const exampleData = { ip: "", diff --git a/src/util/util/AutoUpdate.ts b/src/util/util/AutoUpdate.ts index e62a5c5..efd0954 100644 --- a/src/util/util/AutoUpdate.ts +++ b/src/util/util/AutoUpdate.ts @@ -16,12 +16,9 @@ along with this program. If not, see . */ -import fetch from "node-fetch-commonjs"; -import { ProxyAgent } from "proxy-agent"; import readline from "readline"; import fs from "fs/promises"; import path from "path"; -import http from "http"; const rl = readline.createInterface({ input: process.stdin, @@ -74,9 +71,8 @@ try { // TODO: use file stream instead of buffer (to prevent crash because of high memory usage for big files) // TODO check file hash - const agent = new ProxyAgent(); - const response = await fetch(url, { agent: agent as http.Agent }); - const buffer = await response.buffer(); + const response = await fetch(url); + const buffer = await response.bytes(); const tempDir = await fs.mkdtemp("spacebar"); await fs.writeFile(path.join(tempDir, "Spacebar.zip"), buffer); } catch (error) { @@ -97,8 +93,7 @@ async function getLatestVersion(url: string) { try { - const agent = new ProxyAgent(); - const response = await fetch(url, { agent: agent as http.Agent }); + const response = await fetch(url); const content = (await response.json()) as { version: string }; return content.version; } catch (error) { diff --git a/src/util/util/cdn.ts b/src/util/util/cdn.ts index d5ca9ba..01f03fc 100644 --- a/src/util/util/cdn.ts +++ b/src/util/util/cdn.ts @@ -18,7 +18,6 @@ import FormData from "form-data"; import { HTTPError } from "lambert-server"; -import fetch from "node-fetch-commonjs"; import { Attachment } from "../entities"; import { Config } from "./Config";