@sapphire/plugin-api 7.0.0-next.03b2a90 → 7.0.0-next.1054b61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -1
- package/dist/cjs/index.cjs +23 -9
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +207 -114
- package/dist/cjs/lib/structures/Augmentations.d.cjs +1 -1
- package/dist/cjs/lib/structures/Augmentations.d.cjs.map +1 -1
- package/dist/cjs/lib/structures/MediaParser.cjs +1 -1
- package/dist/cjs/lib/structures/MediaParser.cjs.map +1 -1
- package/dist/cjs/lib/structures/MediaParserStore.cjs +1 -1
- package/dist/cjs/lib/structures/MediaParserStore.cjs.map +1 -1
- package/dist/cjs/lib/structures/Middleware.cjs +2 -2
- package/dist/cjs/lib/structures/Middleware.cjs.map +1 -1
- package/dist/cjs/lib/structures/MiddlewareStore.cjs +4 -4
- package/dist/cjs/lib/structures/MiddlewareStore.cjs.map +1 -1
- package/dist/cjs/lib/structures/Route.cjs +15 -12
- package/dist/cjs/lib/structures/Route.cjs.map +1 -1
- package/dist/cjs/lib/structures/RouteLoaderStrategy.cjs +3 -11
- package/dist/cjs/lib/structures/RouteLoaderStrategy.cjs.map +1 -1
- package/dist/cjs/lib/structures/RouteStore.cjs +4 -42
- package/dist/cjs/lib/structures/RouteStore.cjs.map +1 -1
- package/dist/cjs/lib/structures/api/ApiRequest.cjs +27 -1
- package/dist/cjs/lib/structures/api/ApiRequest.cjs.map +1 -1
- package/dist/cjs/lib/structures/api/ApiResponse.cjs +8 -2
- package/dist/cjs/lib/structures/api/ApiResponse.cjs.map +1 -1
- package/dist/cjs/lib/structures/api/CookieStore.cjs +1 -1
- package/dist/cjs/lib/structures/api/CookieStore.cjs.map +1 -1
- package/dist/cjs/lib/structures/http/Auth.cjs +2 -2
- package/dist/cjs/lib/structures/http/Auth.cjs.map +1 -1
- package/dist/cjs/lib/structures/http/HttpCodes.cjs +1 -1
- package/dist/cjs/lib/structures/http/HttpCodes.cjs.map +1 -1
- package/dist/cjs/lib/structures/http/HttpMethods.cjs +1 -1
- package/dist/cjs/lib/structures/http/HttpMethods.cjs.map +1 -1
- package/dist/cjs/lib/structures/http/Server.cjs +16 -15
- package/dist/cjs/lib/structures/http/Server.cjs.map +1 -1
- package/dist/cjs/lib/structures/router/RouterBranch.cjs +184 -0
- package/dist/cjs/lib/structures/router/RouterBranch.cjs.map +1 -0
- package/dist/cjs/lib/structures/router/RouterNode.cjs +67 -0
- package/dist/cjs/lib/structures/router/RouterNode.cjs.map +1 -0
- package/dist/cjs/lib/structures/router/RouterRoot.cjs +71 -0
- package/dist/cjs/lib/structures/router/RouterRoot.cjs.map +1 -0
- package/dist/cjs/lib/utils/MimeTypes.cjs +1 -1
- package/dist/cjs/lib/utils/MimeTypes.cjs.map +1 -1
- package/dist/cjs/listeners/PluginRouteError.cjs +3 -3
- package/dist/cjs/listeners/PluginRouteError.cjs.map +1 -1
- package/dist/cjs/listeners/PluginServerMiddlewareError.cjs +3 -3
- package/dist/cjs/listeners/PluginServerMiddlewareError.cjs.map +1 -1
- package/dist/cjs/listeners/PluginServerMiddlewareSuccess.cjs +5 -5
- package/dist/cjs/listeners/PluginServerMiddlewareSuccess.cjs.map +1 -1
- package/dist/cjs/listeners/PluginServerRequest.cjs +42 -8
- package/dist/cjs/listeners/PluginServerRequest.cjs.map +1 -1
- package/dist/cjs/listeners/{PluginServerMatch.cjs → PluginServerRouterBranchMethodNotAllowed.cjs} +5 -10
- package/dist/cjs/listeners/PluginServerRouterBranchMethodNotAllowed.cjs.map +1 -0
- package/dist/cjs/listeners/{PluginServerNoMatch.cjs → PluginServerRouterBranchNotFound.cjs} +3 -3
- package/dist/cjs/listeners/PluginServerRouterBranchNotFound.cjs.map +1 -0
- package/dist/cjs/listeners/PluginServerRouterFound.cjs +22 -0
- package/dist/cjs/listeners/PluginServerRouterFound.cjs.map +1 -0
- package/dist/cjs/listeners/_load.cjs +7 -5
- package/dist/cjs/listeners/_load.cjs.map +1 -1
- package/dist/cjs/mediaParsers/_load.cjs +1 -1
- package/dist/cjs/mediaParsers/_load.cjs.map +1 -1
- package/dist/cjs/mediaParsers/applicationFormUrlEncoded.cjs +1 -1
- package/dist/cjs/mediaParsers/applicationFormUrlEncoded.cjs.map +1 -1
- package/dist/cjs/mediaParsers/applicationJson.cjs +1 -1
- package/dist/cjs/mediaParsers/applicationJson.cjs.map +1 -1
- package/dist/cjs/mediaParsers/textPlain.cjs +1 -1
- package/dist/cjs/mediaParsers/textPlain.cjs.map +1 -1
- package/dist/cjs/middlewares/_load.cjs +1 -1
- package/dist/cjs/middlewares/_load.cjs.map +1 -1
- package/dist/cjs/middlewares/auth.cjs +2 -2
- package/dist/cjs/middlewares/auth.cjs.map +1 -1
- package/dist/cjs/middlewares/body.cjs +6 -5
- package/dist/cjs/middlewares/body.cjs.map +1 -1
- package/dist/cjs/middlewares/cookies.cjs +1 -1
- package/dist/cjs/middlewares/cookies.cjs.map +1 -1
- package/dist/cjs/middlewares/headers.cjs +10 -11
- package/dist/cjs/middlewares/headers.cjs.map +1 -1
- package/dist/cjs/register.cjs +1 -1
- package/dist/cjs/register.cjs.map +1 -1
- package/dist/cjs/routes/_load.cjs +1 -1
- package/dist/cjs/routes/_load.cjs.map +1 -1
- package/dist/cjs/routes/oauth/callback.post.cjs +2 -2
- package/dist/cjs/routes/oauth/callback.post.cjs.map +1 -1
- package/dist/cjs/routes/oauth/logout.post.cjs +1 -1
- package/dist/cjs/routes/oauth/logout.post.cjs.map +1 -1
- package/dist/esm/{chunk-JTFKMR4I.mjs → chunk-S573YWRP.mjs} +4 -3
- package/dist/esm/chunk-S573YWRP.mjs.map +1 -0
- package/dist/esm/index.d.mts +207 -114
- package/dist/esm/index.mjs +6 -4
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/lib/structures/Augmentations.d.mjs +1 -1
- package/dist/esm/lib/structures/Augmentations.d.mjs.map +1 -1
- package/dist/esm/lib/structures/MediaParser.mjs +2 -2
- package/dist/esm/lib/structures/MediaParser.mjs.map +1 -1
- package/dist/esm/lib/structures/MediaParserStore.mjs +2 -2
- package/dist/esm/lib/structures/MediaParserStore.mjs.map +1 -1
- package/dist/esm/lib/structures/Middleware.mjs +2 -2
- package/dist/esm/lib/structures/Middleware.mjs.map +1 -1
- package/dist/esm/lib/structures/MiddlewareStore.mjs +4 -4
- package/dist/esm/lib/structures/MiddlewareStore.mjs.map +1 -1
- package/dist/esm/lib/structures/Route.mjs +16 -13
- package/dist/esm/lib/structures/Route.mjs.map +1 -1
- package/dist/esm/lib/structures/RouteLoaderStrategy.mjs +4 -12
- package/dist/esm/lib/structures/RouteLoaderStrategy.mjs.map +1 -1
- package/dist/esm/lib/structures/RouteStore.mjs +4 -42
- package/dist/esm/lib/structures/RouteStore.mjs.map +1 -1
- package/dist/esm/lib/structures/api/ApiRequest.mjs +28 -2
- package/dist/esm/lib/structures/api/ApiRequest.mjs.map +1 -1
- package/dist/esm/lib/structures/api/ApiResponse.mjs +8 -2
- package/dist/esm/lib/structures/api/ApiResponse.mjs.map +1 -1
- package/dist/esm/lib/structures/api/CookieStore.mjs +2 -2
- package/dist/esm/lib/structures/api/CookieStore.mjs.map +1 -1
- package/dist/esm/lib/structures/http/Auth.mjs +2 -2
- package/dist/esm/lib/structures/http/Auth.mjs.map +1 -1
- package/dist/esm/lib/structures/http/HttpCodes.mjs +2 -2
- package/dist/esm/lib/structures/http/HttpCodes.mjs.map +1 -1
- package/dist/esm/lib/structures/http/HttpMethods.mjs +2 -2
- package/dist/esm/lib/structures/http/HttpMethods.mjs.map +1 -1
- package/dist/esm/lib/structures/http/Server.mjs +17 -16
- package/dist/esm/lib/structures/http/Server.mjs.map +1 -1
- package/dist/esm/lib/structures/router/RouterBranch.mjs +179 -0
- package/dist/esm/lib/structures/router/RouterBranch.mjs.map +1 -0
- package/dist/esm/lib/structures/router/RouterNode.mjs +56 -0
- package/dist/esm/lib/structures/router/RouterNode.mjs.map +1 -0
- package/dist/esm/lib/structures/router/RouterRoot.mjs +68 -0
- package/dist/esm/lib/structures/router/RouterRoot.mjs.map +1 -0
- package/dist/esm/lib/utils/MimeTypes.mjs +2 -2
- package/dist/esm/lib/utils/MimeTypes.mjs.map +1 -1
- package/dist/esm/listeners/PluginRouteError.mjs +5 -5
- package/dist/esm/listeners/PluginRouteError.mjs.map +1 -1
- package/dist/esm/listeners/PluginServerMiddlewareError.mjs +5 -5
- package/dist/esm/listeners/PluginServerMiddlewareError.mjs.map +1 -1
- package/dist/esm/listeners/PluginServerMiddlewareSuccess.mjs +7 -7
- package/dist/esm/listeners/PluginServerMiddlewareSuccess.mjs.map +1 -1
- package/dist/esm/listeners/PluginServerRequest.mjs +38 -10
- package/dist/esm/listeners/PluginServerRequest.mjs.map +1 -1
- package/dist/esm/listeners/PluginServerRouterBranchMethodNotAllowed.mjs +18 -0
- package/dist/esm/listeners/PluginServerRouterBranchMethodNotAllowed.mjs.map +1 -0
- package/dist/esm/listeners/{PluginServerNoMatch.mjs → PluginServerRouterBranchNotFound.mjs} +5 -5
- package/dist/esm/listeners/PluginServerRouterBranchNotFound.mjs.map +1 -0
- package/dist/esm/listeners/PluginServerRouterFound.mjs +19 -0
- package/dist/esm/listeners/PluginServerRouterFound.mjs.map +1 -0
- package/dist/esm/listeners/_load.mjs +14 -12
- package/dist/esm/listeners/_load.mjs.map +1 -1
- package/dist/esm/mediaParsers/_load.mjs +2 -2
- package/dist/esm/mediaParsers/_load.mjs.map +1 -1
- package/dist/esm/mediaParsers/applicationFormUrlEncoded.mjs +2 -2
- package/dist/esm/mediaParsers/applicationFormUrlEncoded.mjs.map +1 -1
- package/dist/esm/mediaParsers/applicationJson.mjs +2 -2
- package/dist/esm/mediaParsers/applicationJson.mjs.map +1 -1
- package/dist/esm/mediaParsers/textPlain.mjs +2 -2
- package/dist/esm/mediaParsers/textPlain.mjs.map +1 -1
- package/dist/esm/middlewares/_load.mjs +2 -2
- package/dist/esm/middlewares/_load.mjs.map +1 -1
- package/dist/esm/middlewares/auth.mjs +2 -2
- package/dist/esm/middlewares/auth.mjs.map +1 -1
- package/dist/esm/middlewares/body.mjs +6 -5
- package/dist/esm/middlewares/body.mjs.map +1 -1
- package/dist/esm/middlewares/cookies.mjs +2 -2
- package/dist/esm/middlewares/cookies.mjs.map +1 -1
- package/dist/esm/middlewares/headers.mjs +11 -12
- package/dist/esm/middlewares/headers.mjs.map +1 -1
- package/dist/esm/register.mjs +2 -2
- package/dist/esm/register.mjs.map +1 -1
- package/dist/esm/routes/_load.mjs +2 -2
- package/dist/esm/routes/_load.mjs.map +1 -1
- package/dist/esm/routes/oauth/callback.post.mjs +2 -2
- package/dist/esm/routes/oauth/callback.post.mjs.map +1 -1
- package/dist/esm/routes/oauth/logout.post.mjs +2 -2
- package/dist/esm/routes/oauth/logout.post.mjs.map +1 -1
- package/package.json +8 -7
- package/dist/cjs/lib/utils/RouteData.cjs +0 -62
- package/dist/cjs/lib/utils/RouteData.cjs.map +0 -1
- package/dist/cjs/listeners/PluginServerMatch.cjs.map +0 -1
- package/dist/cjs/listeners/PluginServerNoMatch.cjs.map +0 -1
- package/dist/esm/chunk-JTFKMR4I.mjs.map +0 -1
- package/dist/esm/lib/utils/RouteData.mjs +0 -56
- package/dist/esm/lib/utils/RouteData.mjs.map +0 -1
- package/dist/esm/listeners/PluginServerMatch.mjs +0 -23
- package/dist/esm/listeners/PluginServerMatch.mjs.map +0 -1
- package/dist/esm/listeners/PluginServerNoMatch.mjs.map +0 -1
|
@@ -9,7 +9,7 @@ var HttpCodes_cjs = require('../../lib/structures/http/HttpCodes.cjs');
|
|
|
9
9
|
var __defProp = Object.defineProperty;
|
|
10
10
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
11
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
12
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj,
|
|
12
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, key + "" , value);
|
|
13
13
|
var _PluginRoute = class _PluginRoute extends Route_cjs.Route {
|
|
14
14
|
constructor(context) {
|
|
15
15
|
super(context, { route: "oauth/callback", methods: ["POST"] });
|
|
@@ -70,5 +70,5 @@ __name(_PluginRoute, "PluginRoute");
|
|
|
70
70
|
var PluginRoute = _PluginRoute;
|
|
71
71
|
|
|
72
72
|
exports.PluginRoute = PluginRoute;
|
|
73
|
-
//# sourceMappingURL=
|
|
73
|
+
//# sourceMappingURL=callback.post.cjs.map
|
|
74
74
|
//# sourceMappingURL=callback.post.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/routes/oauth/callback.post.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../src/routes/oauth/callback.post.ts"],"names":["Route","HttpCodes","fetch","OAuth2Routes","stringify"],"mappings":";;;;;;;;;;;;AAMO,IAAM,YAAA,GAAN,MAAM,YAAA,SAAoBA,eAAM,CAAA;AAAA,EAG/B,YAAY,OAA8B,EAAA;AAChD,IAAM,KAAA,CAAA,OAAA,EAAS,EAAE,KAAO,EAAA,gBAAA,EAAkB,SAAS,CAAC,MAAM,GAAG,CAAA,CAAA;AAH9D,IAAiB,aAAA,CAAA,IAAA,EAAA,aAAA,CAAA,CAAA;AAKhB,IAAM,MAAA,EAAE,MAAO,EAAA,GAAI,IAAK,CAAA,SAAA,CAAA;AACxB,IAAK,IAAA,CAAA,OAAA,GAAU,OAAO,IAAS,KAAA,IAAA,CAAA;AAC/B,IAAK,IAAA,CAAA,WAAA,GAAc,OAAO,IAAM,EAAA,QAAA,CAAA;AAAA,GACjC;AAAA,EAEA,MAAsB,GAAI,CAAA,OAAA,EAAwB,QAA0B,EAAA;AAC3E,IAAA,MAAM,OAAO,OAAQ,CAAA,IAAA,CAAA;AACrB,IAAI,IAAA,OAAO,IAAM,EAAA,IAAA,KAAS,QAAU,EAAA;AACnC,MAAA,OAAO,SAAS,UAAW,EAAA,CAAA;AAAA,KAC5B;AAEA,IAAA,MAAM,KAAQ,GAAA,MAAM,IAAK,CAAA,SAAA,CAAU,IAAI,CAAA,CAAA;AACvC,IAAA,IAAI,UAAU,IAAM,EAAA;AACnB,MAAO,OAAA,QAAA,CAAS,OAAOC,uBAAU,CAAA,mBAAmB,EAAE,IAAK,CAAA,EAAE,KAAO,EAAA,4BAAA,EAA8B,CAAA,CAAA;AAAA,KACnG;AAEA,IAAM,MAAA,GAAA,GAAM,KAAK,GAAI,EAAA,CAAA;AACrB,IAAM,MAAA,IAAA,GAAO,IAAK,CAAA,SAAA,CAAU,MAAO,CAAA,IAAA,CAAA;AACnC,IAAA,MAAM,IAAO,GAAA,MAAM,IAAK,CAAA,SAAA,CAAU,MAAM,YAAY,CAAA,CAAA;AACpD,IAAI,IAAA,CAAC,KAAK,IAAM,EAAA;AACf,MAAO,OAAA,QAAA,CAAS,OAAOA,uBAAU,CAAA,mBAAmB,EAAE,IAAK,CAAA,EAAE,KAAO,EAAA,2BAAA,EAA6B,CAAA,CAAA;AAAA,KAClG;AAEA,IAAM,MAAA,KAAA,GAAQ,KAAK,OAAQ,CAAA;AAAA,MAC1B,EAAA,EAAI,KAAK,IAAK,CAAA,EAAA;AAAA,MACd,OAAA,EAAS,GAAM,GAAA,KAAA,CAAM,UAAa,GAAA,GAAA;AAAA,MAClC,SAAS,KAAM,CAAA,aAAA;AAAA,MACf,OAAO,KAAM,CAAA,YAAA;AAAA,KACb,CAAA,CAAA;AAED,IAAS,QAAA,CAAA,OAAA,CAAQ,IAAI,IAAK,CAAA,MAAA,EAAQ,OAAO,EAAE,MAAA,EAAQ,KAAM,CAAA,UAAA,EAAY,CAAA,CAAA;AACrE,IAAO,OAAA,QAAA,CAAS,KAAK,IAAI,CAAA,CAAA;AAAA,GAC1B;AAAA,EAEA,MAAc,UAAU,IAAsB,EAAA;AAC7C,IAAA,MAAM,EAAE,EAAI,EAAA,MAAA,EAAW,GAAA,IAAA,CAAK,UAAU,MAAO,CAAA,IAAA,CAAA;AAE7C,IAAA,MAAM,IAAgD,GAAA;AAAA;AAAA,MAErD,SAAW,EAAA,EAAA;AAAA,MACX,aAAe,EAAA,MAAA;AAAA,MACf,MAAM,IAAK,CAAA,IAAA;AAAA,MACX,UAAY,EAAA,oBAAA;AAAA,MACZ,YAAA,EAAc,IAAK,CAAA,WAAA,IAAe,IAAK,CAAA,WAAA;AAAA;AAAA,KAExC,CAAA;AAEA,IAAA,MAAM,MAAS,GAAA,MAAMC,YAAM,CAAAC,uBAAA,CAAa,QAAU,EAAA;AAAA,MACjD,MAAQ,EAAA,MAAA;AAAA,MACR,IAAA,EAAMC,sBAAU,IAAW,CAAA;AAAA,MAC3B,OAAS,EAAA;AAAA,QACR,cAAgB,EAAA,mCAAA;AAAA,OACjB;AAAA,KACA,CAAA,CAAA;AAED,IAAM,MAAA,IAAA,GAAO,MAAM,MAAA,CAAO,IAAK,EAAA,CAAA;AAC/B,IAAI,IAAA,MAAA,CAAO,IAAW,OAAA,IAAA,CAAA;AAEtB,IAAK,IAAA,CAAA,SAAA,CAAU,MAAO,CAAA,KAAA,CAAM,IAAI,CAAA,CAAA;AAChC,IAAO,OAAA,IAAA,CAAA;AAAA,GACR;AACD,CAAA,CAAA;AAnEuC,MAAA,CAAA,YAAA,EAAA,aAAA,CAAA,CAAA;AAAhC,IAAM,WAAN,GAAA","file":"callback.post.cjs","sourcesContent":["import { OAuth2Routes, type RESTPostOAuth2AccessTokenResult, type RESTPostOAuth2AccessTokenURLEncodedData } from 'discord.js';\nimport { stringify } from 'querystring';\nimport { fetch } from 'undici';\nimport { Route } from '../../lib/structures/Route';\nimport { HttpCodes } from '../../lib/structures/http/HttpCodes';\n\nexport class PluginRoute extends Route {\n\tprivate readonly redirectUri: string | undefined;\n\n\tpublic constructor(context: Route.LoaderContext) {\n\t\tsuper(context, { route: 'oauth/callback', methods: ['POST'] });\n\n\t\tconst { server } = this.container;\n\t\tthis.enabled = server.auth !== null;\n\t\tthis.redirectUri = server.auth?.redirect;\n\t}\n\n\tpublic override async run(request: Route.Request, response: Route.Response) {\n\t\tconst body = request.body as OAuth2BodyData;\n\t\tif (typeof body?.code !== 'string') {\n\t\t\treturn response.badRequest();\n\t\t}\n\n\t\tconst value = await this.fetchAuth(body);\n\t\tif (value === null) {\n\t\t\treturn response.status(HttpCodes.InternalServerError).json({ error: 'Failed to fetch the token.' });\n\t\t}\n\n\t\tconst now = Date.now();\n\t\tconst auth = this.container.server.auth!;\n\t\tconst data = await auth.fetchData(value.access_token);\n\t\tif (!data.user) {\n\t\t\treturn response.status(HttpCodes.InternalServerError).json({ error: 'Failed to fetch the user.' });\n\t\t}\n\n\t\tconst token = auth.encrypt({\n\t\t\tid: data.user.id,\n\t\t\texpires: now + value.expires_in * 1000,\n\t\t\trefresh: value.refresh_token,\n\t\t\ttoken: value.access_token\n\t\t});\n\n\t\tresponse.cookies.add(auth.cookie, token, { maxAge: value.expires_in });\n\t\treturn response.json(data);\n\t}\n\n\tprivate async fetchAuth(body: OAuth2BodyData) {\n\t\tconst { id, secret } = this.container.server.auth!;\n\n\t\tconst data: RESTPostOAuth2AccessTokenURLEncodedData = {\n\t\t\t/* eslint-disable @typescript-eslint/naming-convention */\n\t\t\tclient_id: id,\n\t\t\tclient_secret: secret,\n\t\t\tcode: body.code,\n\t\t\tgrant_type: 'authorization_code',\n\t\t\tredirect_uri: this.redirectUri ?? body.redirectUri\n\t\t\t/* eslint-enable @typescript-eslint/naming-convention */\n\t\t};\n\n\t\tconst result = await fetch(OAuth2Routes.tokenURL, {\n\t\t\tmethod: 'POST',\n\t\t\tbody: stringify(data as any),\n\t\t\theaders: {\n\t\t\t\t'content-type': 'application/x-www-form-urlencoded'\n\t\t\t}\n\t\t});\n\n\t\tconst json = await result.json();\n\t\tif (result.ok) return json as RESTPostOAuth2AccessTokenResult;\n\n\t\tthis.container.logger.error(json);\n\t\treturn null;\n\t}\n}\n\n/**\n * The OAuth2 body data sent to the callback.\n * @since 1.2.0\n */\nexport interface OAuth2BodyData {\n\t/**\n\t * The code sent by the client.\n\t * @since 1.2.0\n\t */\n\tcode: string;\n\n\t/**\n\t * The client's ID.\n\t * @since 1.2.0\n\t */\n\tclientId: string;\n\n\t/**\n\t * The redirect URI.\n\t * @since 1.2.0\n\t */\n\tredirectUri: string;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/routes/oauth/logout.post.ts"],"names":["
|
|
1
|
+
{"version":3,"sources":["../../../../src/routes/oauth/logout.post.ts"],"names":["Route","HttpCodes","sleep","result","fetch","OAuth2Routes","stringify"],"mappings":";;;;;;;;;;;AAOO,IAAM,YAAA,GAAN,MAAM,YAAA,SAAoBA,eAAM,CAAA;AAAA,EAC/B,YAAY,OAA8B,EAAA;AAChD,IAAM,KAAA,CAAA,OAAA,EAAS,EAAE,KAAO,EAAA,cAAA,EAAgB,SAAS,CAAC,MAAM,GAAG,CAAA,CAAA;AAC3D,IAAA,IAAA,CAAK,OAAU,GAAA,IAAA,CAAK,SAAU,CAAA,MAAA,CAAO,IAAS,KAAA,IAAA,CAAA;AAAA,GAC/C;AAAA,EAEA,MAAsB,GAAI,CAAA,OAAA,EAAwB,QAA0B,EAAA;AAC3E,IAAA,IAAI,CAAC,OAAA,CAAQ,IAAM,EAAA,OAAO,QAAS,CAAA,MAAA,CAAOC,uBAAU,CAAA,YAAY,CAAE,CAAA,IAAA,CAAK,EAAE,KAAA,EAAO,iBAAiB,CAAA,CAAA;AAEjG,IAAA,MAAM,SAAS,MAAM,IAAA,CAAK,MAAO,CAAA,OAAA,CAAQ,KAAK,KAAK,CAAA,CAAA;AACnD,IAAA,IAAI,MAAO,CAAA,EAAA,EAAW,OAAA,IAAA,CAAK,QAAQ,QAAQ,CAAA,CAAA;AAM3C,IAAI,IAAA,MAAA,CAAO,MAAW,KAAAA,uBAAA,CAAU,kBAAoB,EAAA;AAMnD,MAAA,MAAM,aAAa,IAAK,CAAA,iBAAA,CAAkB,OAAO,OAAQ,CAAA,GAAA,CAAI,aAAa,CAAC,CAAA,CAAA;AAC3E,MAAA,IAAI,UAAY,EAAA;AACf,QAAA,MAAMC,gBAAM,UAAU,CAAA,CAAA;AAEtB,QAAA,MAAMC,UAAS,MAAM,IAAA,CAAK,MAAO,CAAA,OAAA,CAAQ,KAAK,KAAK,CAAA,CAAA;AACnD,QAAA,IAAIA,OAAO,CAAA,EAAA,EAAW,OAAA,IAAA,CAAK,QAAQ,QAAQ,CAAA,CAAA;AAAA,OAC5C;AAAA,KACD;AAQA,IAAO,OAAA,QAAA,CAAS,OAAOF,uBAAU,CAAA,mBAAmB,EAAE,IAAK,CAAA,EAAE,KAAO,EAAA,+BAAA,EAAiC,CAAA,CAAA;AAAA,GACtG;AAAA,EAEQ,QAAQ,QAA0B,EAAA;AAEzC,IAAA,QAAA,CAAS,QAAQ,MAAO,CAAA,IAAA,CAAK,SAAU,CAAA,MAAA,CAAO,KAAM,MAAM,CAAA,CAAA;AAC1D,IAAA,OAAO,QAAS,CAAA,IAAA,CAAK,EAAE,OAAA,EAAS,MAAM,CAAA,CAAA;AAAA,GACvC;AAAA,EAEA,MAAc,OAAO,KAAe,EAAA;AACnC,IAAM,MAAA,IAAA,GAAO,IAAK,CAAA,SAAA,CAAU,MAAO,CAAA,IAAA,CAAA;AAkBnC,IAAA,MAAM,MAAS,GAAA,MAAMG,YAAM,CAAAC,uBAAA,CAAa,kBAAoB,EAAA;AAAA,MAC3D,MAAQ,EAAA,MAAA;AAAA,MACR,MAAMC,qBAAU,CAAA;AAAA,QACf,KAAA;AAAA;AAAA,QAEA,WAAW,IAAK,CAAA,EAAA;AAAA,QAChB,eAAe,IAAK,CAAA,MAAA;AAAA;AAAA,OAEpB,CAAA;AAAA,MACD,OAAS,EAAA;AAAA,QACR,cAAgB,EAAA,mCAAA;AAAA,OACjB;AAAA,KACA,CAAA,CAAA;AAED,IAAO,OAAA,MAAA,CAAA;AAAA,GACR;AAAA,EAEQ,kBAAkB,UAA2B,EAAA;AAGpD,IAAA,OAAO,UAAe,KAAA,IAAA,GAAO,GAAO,GAAA,MAAA,CAAO,UAAU,CAAI,GAAA,GAAA,CAAA;AAAA,GAC1D;AACD,CAAA,CAAA;AAvFuC,MAAA,CAAA,YAAA,EAAA,aAAA,CAAA,CAAA;AAAhC,IAAM,WAAN,GAAA","file":"logout.post.cjs","sourcesContent":["import { sleep } from '@sapphire/utilities';\nimport { OAuth2Routes } from 'discord.js';\nimport { stringify } from 'querystring';\nimport { fetch } from 'undici';\nimport { Route } from '../../lib/structures/Route';\nimport { HttpCodes } from '../../lib/structures/http/HttpCodes';\n\nexport class PluginRoute extends Route {\n\tpublic constructor(context: Route.LoaderContext) {\n\t\tsuper(context, { route: 'oauth/logout', methods: ['POST'] });\n\t\tthis.enabled = this.container.server.auth !== null;\n\t}\n\n\tpublic override async run(request: Route.Request, response: Route.Response) {\n\t\tif (!request.auth) return response.status(HttpCodes.Unauthorized).json({ error: 'Unauthorized.' });\n\n\t\tconst result = await this.revoke(request.auth.token);\n\t\tif (result.ok) return this.success(response);\n\n\t\t// RFC 7009 2.2.1. If the server responds with HTTP status code 503, the client must assume the token still\n\t\t// exists and may retry after a reasonable delay.\n\t\t// The server may include a \"Retry-After\" header in the response to indicate how long the service is expected to\n\t\t// be unavailable to the requesting client.\n\t\tif (result.status === HttpCodes.ServiceUnavailable) {\n\t\t\t// RFC 7231 7.1.3. Servers send the \"Retry-After\" header field to indicate how long the user agent ought to\n\t\t\t// wait before making a follow-up request.\n\t\t\t//\n\t\t\t// The value of this field can be either an HTTP-date or a number of seconds to delay after the response is\n\t\t\t// received.\n\t\t\tconst retryAfter = this.processRetryAfter(result.headers.get('Retry-After'));\n\t\t\tif (retryAfter) {\n\t\t\t\tawait sleep(retryAfter);\n\n\t\t\t\tconst result = await this.revoke(request.auth.token);\n\t\t\t\tif (result.ok) return this.success(response);\n\t\t\t}\n\t\t}\n\n\t\t// RFC 7009 2.2. The authorization server responds with HTTP status code 200 if the token has been revoked\n\t\t// successfully or if the client submitted an invalid token.\n\t\t//\n\t\t// Note: invalid tokens do not cause an error response since the client cannot handle such an error in a\n\t\t// reasonable way. Moreover, the purpose of the revocation request, invalidating the particular token, is\n\t\t// already achieved.\n\t\treturn response.status(HttpCodes.InternalServerError).json({ error: 'Unexpected error from server.' });\n\t}\n\n\tprivate success(response: Route.Response) {\n\t\t// Sending an empty cookie with \"expires\" set to 1970-01-01 makes the browser instantly remove the cookie.\n\t\tresponse.cookies.remove(this.container.server.auth!.cookie);\n\t\treturn response.json({ success: true });\n\t}\n\n\tprivate async revoke(token: string) {\n\t\tconst auth = this.container.server.auth!;\n\n\t\t// RFC 7009 2.1.\n\t\t// The following parameters must be formatted as \"application/x-www-form-urlencoded\" in the HTTP request-body:\n\t\t//\n\t\t// - token: The token the client wants to be revoked.\n\t\t// - token_type_hint: [Optional]: `access_token` (RFC 6749 1.4), `refresh_token` (RFC 6749 1.5)\n\t\t//\n\t\t// The client also includes its authentication credentials, as described in RFC 6749 2.3.\n\t\t//\n\t\t// RFC 6749 2.3.1.\n\t\t// The authorization server MAY include the client credentials in the request - body using the following parameters:\n\t\t//\n\t\t// - client_id: The client identifier issued to the client during the registration process (RFC 6749 2.2)\n\t\t// - client_secret: The client secret.\n\t\t//\n\t\t// RFC 7009 2.2.\n\t\t// The content of the response body is ignored by the client as all necessary information is conveyed in the response code.\n\t\tconst result = await fetch(OAuth2Routes.tokenRevocationURL, {\n\t\t\tmethod: 'POST',\n\t\t\tbody: stringify({\n\t\t\t\ttoken,\n\t\t\t\t/* eslint-disable @typescript-eslint/naming-convention */\n\t\t\t\tclient_id: auth.id,\n\t\t\t\tclient_secret: auth.secret\n\t\t\t\t/* eslint-enable @typescript-eslint/naming-convention */\n\t\t\t}),\n\t\t\theaders: {\n\t\t\t\t'content-type': 'application/x-www-form-urlencoded'\n\t\t\t}\n\t\t});\n\n\t\treturn result;\n\t}\n\n\tprivate processRetryAfter(retryAfter: string | null) {\n\t\t// Discord sends Retry-After in seconds, never an HTTP-date, therefore, we will assume this behaviour.\n\t\t// Either way, if it's not present, we will retry in 5 seconds.\n\t\treturn retryAfter === null ? 5000 : Number(retryAfter) * 1000;\n\t}\n}\n"]}
|
|
@@ -9,7 +9,8 @@ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot
|
|
|
9
9
|
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
10
10
|
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
11
11
|
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
12
|
+
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
12
13
|
|
|
13
|
-
export { __name, __privateAdd, __privateGet, __privateSet, __publicField };
|
|
14
|
-
//# sourceMappingURL=
|
|
15
|
-
//# sourceMappingURL=chunk-
|
|
14
|
+
export { __name, __privateAdd, __privateGet, __privateMethod, __privateSet, __publicField };
|
|
15
|
+
//# sourceMappingURL=chunk-S573YWRP.mjs.map
|
|
16
|
+
//# sourceMappingURL=chunk-S573YWRP.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"chunk-S573YWRP.mjs"}
|
package/dist/esm/index.d.mts
CHANGED
|
@@ -1,11 +1,33 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AsyncEventEmitter } from '@vladfrangu/async_event_emitter';
|
|
2
2
|
import { IncomingMessage, ServerResponse, Server as Server$1, ServerOptions as ServerOptions$1 } from 'node:http';
|
|
3
3
|
import { ListenOptions } from 'node:net';
|
|
4
4
|
import { Piece, Store } from '@sapphire/pieces';
|
|
5
5
|
import { Awaitable } from '@sapphire/utilities';
|
|
6
6
|
import { Gunzip } from 'zlib';
|
|
7
|
-
import { Snowflake, OAuth2Scopes, RESTGetAPICurrentUserResult, RESTGetAPICurrentUserGuildsResult, RESTGetAPICurrentUserConnectionsResult, Collection } from 'discord.js';
|
|
8
7
|
import { Readable } from 'node:stream';
|
|
8
|
+
import { Snowflake, OAuth2Scopes, RESTGetAPICurrentUserResult, RESTGetAPICurrentUserGuildsResult, RESTGetAPICurrentUserConnectionsResult } from 'discord.js';
|
|
9
|
+
|
|
10
|
+
declare enum MimeTypes {
|
|
11
|
+
ApplicationFormUrlEncoded = "application/x-www-form-urlencoded",
|
|
12
|
+
ApplicationJson = "application/json",
|
|
13
|
+
AudioOgg = "audio/ogg",
|
|
14
|
+
AudioOpus = "audio/opus",
|
|
15
|
+
AudioWebm = "audio/webm",
|
|
16
|
+
ImageGif = "image/gif",
|
|
17
|
+
ImageJpg = "image/jpeg",
|
|
18
|
+
ImagePng = "image/png",
|
|
19
|
+
ImageWebp = "image/webp",
|
|
20
|
+
ImageXIcon = "image/x-icon",
|
|
21
|
+
TextPlain = "text/plain",
|
|
22
|
+
TextHtml = "text/html",
|
|
23
|
+
VideoMp4 = "video/mp4",
|
|
24
|
+
VideoMpeg = "video/mpeg",
|
|
25
|
+
VideoOgg = "video/ogg",
|
|
26
|
+
VideoWebm = "video/webm"
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
type MethodName = (typeof MethodNames)[number];
|
|
30
|
+
declare const MethodNames: readonly ["ACL", "BIND", "CHECKOUT", "CONNECT", "COPY", "DELETE", "GET", "HEAD", "LINK", "LOCK", "M-SEARCH", "MERGE", "MKACTIVITY", "MKCALENDAR", "MKCOL", "MOVE", "NOTIFY", "OPTIONS", "PATCH", "POST", "PROPFIND", "PROPPATCH", "PURGE", "PUT", "REBIND", "REPORT", "SEARCH", "SOURCE", "SUBSCRIBE", "TRACE", "UNBIND", "UNLINK", "UNLOCK", "UNSUBSCRIBE"];
|
|
9
31
|
|
|
10
32
|
declare class Auth {
|
|
11
33
|
#private;
|
|
@@ -167,82 +189,6 @@ interface LoginDataTransformer<T extends LoginData = LoginData> {
|
|
|
167
189
|
(data: LoginData): Awaitable<T>;
|
|
168
190
|
}
|
|
169
191
|
|
|
170
|
-
declare class ApiRequest extends IncomingMessage {
|
|
171
|
-
/**
|
|
172
|
-
* The query parameters.
|
|
173
|
-
*/
|
|
174
|
-
query: Record<string, string | string[]>;
|
|
175
|
-
/**
|
|
176
|
-
* The URI parameters.
|
|
177
|
-
*/
|
|
178
|
-
params: Record<string, string>;
|
|
179
|
-
/**
|
|
180
|
-
* The body that was sent by the user.
|
|
181
|
-
*/
|
|
182
|
-
body?: unknown;
|
|
183
|
-
/**
|
|
184
|
-
* The authorization information. This field indicates three possible values:
|
|
185
|
-
*
|
|
186
|
-
* - `undefined`: The authorization middleware has not been executed yet.
|
|
187
|
-
* - `null`: The user is not authorized.
|
|
188
|
-
* - `AuthData`: The user is authorized.
|
|
189
|
-
*/
|
|
190
|
-
auth?: AuthData | null;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
* @since 1.0.0
|
|
195
|
-
*/
|
|
196
|
-
declare enum TypeState {
|
|
197
|
-
/**
|
|
198
|
-
* @since 1.0.0
|
|
199
|
-
*/
|
|
200
|
-
Static = 0,
|
|
201
|
-
/**
|
|
202
|
-
* @since 1.0.0
|
|
203
|
-
*/
|
|
204
|
-
Dynamic = 1
|
|
205
|
-
}
|
|
206
|
-
type MatchData = Record<string, string> | null;
|
|
207
|
-
declare class RouteData {
|
|
208
|
-
readonly path: string;
|
|
209
|
-
private readonly static;
|
|
210
|
-
private readonly parts;
|
|
211
|
-
constructor(path: string);
|
|
212
|
-
match(split: readonly string[]): MatchData;
|
|
213
|
-
/**
|
|
214
|
-
* @since 1.0.0
|
|
215
|
-
*/
|
|
216
|
-
private static parsePart;
|
|
217
|
-
/**
|
|
218
|
-
* @since 1.0.0
|
|
219
|
-
*/
|
|
220
|
-
private static split;
|
|
221
|
-
}
|
|
222
|
-
interface ParsedPart {
|
|
223
|
-
value: string;
|
|
224
|
-
type: TypeState;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
declare enum MimeTypes {
|
|
228
|
-
ApplicationFormUrlEncoded = "application/x-www-form-urlencoded",
|
|
229
|
-
ApplicationJson = "application/json",
|
|
230
|
-
AudioOgg = "audio/ogg",
|
|
231
|
-
AudioOpus = "audio/opus",
|
|
232
|
-
AudioWebm = "audio/webm",
|
|
233
|
-
ImageGif = "image/gif",
|
|
234
|
-
ImageJpg = "image/jpeg",
|
|
235
|
-
ImagePng = "image/png",
|
|
236
|
-
ImageWebp = "image/webp",
|
|
237
|
-
ImageXIcon = "image/x-icon",
|
|
238
|
-
TextPlain = "text/plain",
|
|
239
|
-
TextHtml = "text/html",
|
|
240
|
-
VideoMp4 = "video/mp4",
|
|
241
|
-
VideoMpeg = "video/mpeg",
|
|
242
|
-
VideoOgg = "video/ogg",
|
|
243
|
-
VideoWebm = "video/webm"
|
|
244
|
-
}
|
|
245
|
-
|
|
246
192
|
declare class CookieStore extends Map<string, string> {
|
|
247
193
|
protected request: ApiRequest;
|
|
248
194
|
protected response: ApiResponse;
|
|
@@ -307,6 +253,10 @@ declare class ApiResponse<Request extends IncomingMessage = IncomingMessage> ext
|
|
|
307
253
|
* @since 1.0.0
|
|
308
254
|
*/
|
|
309
255
|
notFound(data?: unknown): void;
|
|
256
|
+
/**
|
|
257
|
+
* @since 7.0.0
|
|
258
|
+
*/
|
|
259
|
+
methodNotAllowed(data?: unknown): void;
|
|
310
260
|
/**
|
|
311
261
|
* @since 1.0.0
|
|
312
262
|
*/
|
|
@@ -350,9 +300,6 @@ declare class ApiResponse<Request extends IncomingMessage = IncomingMessage> ext
|
|
|
350
300
|
setContentType(contentType: MimeTypes): this;
|
|
351
301
|
}
|
|
352
302
|
|
|
353
|
-
type MethodName = (typeof MethodNames)[number];
|
|
354
|
-
declare const MethodNames: readonly ["ACL", "BIND", "CHECKOUT", "CONNECT", "COPY", "DELETE", "GET", "HEAD", "LINK", "LOCK", "M-SEARCH", "MERGE", "MKACTIVITY", "MKCALENDAR", "MKCOL", "MOVE", "NOTIFY", "OPTIONS", "PATCH", "POST", "PROPFIND", "PROPPATCH", "PURGE", "PUT", "REBIND", "REPORT", "SEARCH", "SOURCE", "SUBSCRIBE", "TRACE", "UNBIND", "UNLINK", "UNLOCK", "UNSUBSCRIBE"];
|
|
355
|
-
|
|
356
303
|
interface RouteOptions extends Piece.Options {
|
|
357
304
|
/**
|
|
358
305
|
* The route the piece should represent.
|
|
@@ -441,9 +388,9 @@ declare abstract class Route<Options extends Route.Options = Route.Options> exte
|
|
|
441
388
|
*/
|
|
442
389
|
readonly acceptedContentMimeTypes: readonly MimeTypeWithoutParameters[] | null;
|
|
443
390
|
/**
|
|
444
|
-
* The route
|
|
391
|
+
* The path this route represents.
|
|
445
392
|
*/
|
|
446
|
-
readonly
|
|
393
|
+
readonly path: readonly string[];
|
|
447
394
|
/**
|
|
448
395
|
* The methods this route accepts.
|
|
449
396
|
*/
|
|
@@ -462,6 +409,141 @@ declare namespace Route {
|
|
|
462
409
|
type Response = ApiResponse;
|
|
463
410
|
}
|
|
464
411
|
|
|
412
|
+
declare class RouterBranch {
|
|
413
|
+
/**
|
|
414
|
+
* The name of the branch.
|
|
415
|
+
*/
|
|
416
|
+
readonly name: string;
|
|
417
|
+
/**
|
|
418
|
+
* Whether or not the branch is dynamic.
|
|
419
|
+
*/
|
|
420
|
+
readonly dynamic: boolean;
|
|
421
|
+
/**
|
|
422
|
+
* The parent branch, if any.
|
|
423
|
+
*/
|
|
424
|
+
readonly parent: RouterBranch | null;
|
|
425
|
+
/**
|
|
426
|
+
* The node this branch is associated with.
|
|
427
|
+
*/
|
|
428
|
+
readonly node: RouterNode;
|
|
429
|
+
/**
|
|
430
|
+
* The methods supported by the branch's node or any of its children.
|
|
431
|
+
*/
|
|
432
|
+
supportedMethods: readonly string[];
|
|
433
|
+
private _staticChildren;
|
|
434
|
+
private _dynamicChild;
|
|
435
|
+
constructor(name: string, dynamic: boolean, parent: RouterBranch | null);
|
|
436
|
+
/**
|
|
437
|
+
* The path representing this branch
|
|
438
|
+
* @version 7.0.0
|
|
439
|
+
*/
|
|
440
|
+
get path(): string;
|
|
441
|
+
/**
|
|
442
|
+
* The branches the branch is associated with
|
|
443
|
+
* @version 7.0.0
|
|
444
|
+
*/
|
|
445
|
+
get children(): RouterBranch[];
|
|
446
|
+
/**
|
|
447
|
+
* Whether or not the branch is empty
|
|
448
|
+
* @version 7.0.0
|
|
449
|
+
*/
|
|
450
|
+
get empty(): boolean;
|
|
451
|
+
/**
|
|
452
|
+
* Tries to find a branch given a path
|
|
453
|
+
* @version 7.0.0
|
|
454
|
+
*
|
|
455
|
+
* @param parts The parts of a path to find a node from
|
|
456
|
+
* @returns The branch found, or null if not found
|
|
457
|
+
*/
|
|
458
|
+
find(parts: readonly string[]): RouterBranch | null;
|
|
459
|
+
/**
|
|
460
|
+
* Checks if the given name matches the branch
|
|
461
|
+
* @version 7.0.0
|
|
462
|
+
*
|
|
463
|
+
* @param name The name to match
|
|
464
|
+
* @returns Whether or not the branch matches the name
|
|
465
|
+
*/
|
|
466
|
+
matches(name: string): boolean;
|
|
467
|
+
/**
|
|
468
|
+
* Returns the string representation of the branch
|
|
469
|
+
* @version 7.0.0
|
|
470
|
+
*
|
|
471
|
+
* @returns The string representation of the branch
|
|
472
|
+
*/
|
|
473
|
+
toString(): string;
|
|
474
|
+
nodes(): IterableIterator<RouterNode>;
|
|
475
|
+
protected _add(parts: readonly string[], index: number, route: Route): RouterNode;
|
|
476
|
+
protected _remove(parts: readonly string[], index: number, route: Route): boolean;
|
|
477
|
+
protected _performAdd(parts: readonly string[], index: number, route: Route): RouterNode;
|
|
478
|
+
protected _performRemove(parts: readonly string[], index: number, route: Route): boolean;
|
|
479
|
+
protected _find(parts: readonly string[], index: number): RouterBranch | null;
|
|
480
|
+
protected _updateSupportedChildrenMethods(): void;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
declare class RouterNode {
|
|
484
|
+
#private;
|
|
485
|
+
/**
|
|
486
|
+
* The branch containing this node.
|
|
487
|
+
*/
|
|
488
|
+
readonly parent: RouterBranch;
|
|
489
|
+
constructor(parent: RouterBranch);
|
|
490
|
+
get path(): string;
|
|
491
|
+
extractParameters(parts: readonly string[]): Record<string, string>;
|
|
492
|
+
get(method: MethodName): Route | null;
|
|
493
|
+
set(method: MethodName, route: Route): this;
|
|
494
|
+
delete(method: MethodName, route: Route): boolean;
|
|
495
|
+
methods(): IterableIterator<MethodName>;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
declare class ApiRequest extends IncomingMessage {
|
|
499
|
+
/**
|
|
500
|
+
* The query parameters.
|
|
501
|
+
*/
|
|
502
|
+
query: Record<string, string | string[]>;
|
|
503
|
+
/**
|
|
504
|
+
* The URI parameters.
|
|
505
|
+
*/
|
|
506
|
+
params: Record<string, string>;
|
|
507
|
+
/**
|
|
508
|
+
* The body that was sent by the user.
|
|
509
|
+
*/
|
|
510
|
+
body?: unknown;
|
|
511
|
+
/**
|
|
512
|
+
* The authorization information. This field indicates three possible values:
|
|
513
|
+
*
|
|
514
|
+
* - `undefined`: The authorization middleware has not been executed yet.
|
|
515
|
+
* - `null`: The user is not authorized.
|
|
516
|
+
* - `AuthData`: The user is authorized.
|
|
517
|
+
*/
|
|
518
|
+
auth?: AuthData | null;
|
|
519
|
+
/**
|
|
520
|
+
* The router node that matched the request. The field indicates three
|
|
521
|
+
* possible values:
|
|
522
|
+
*
|
|
523
|
+
* - `undefined`: The router handler has not been executed yet.
|
|
524
|
+
* - `null`: The router handler has been executed, but no node matched the
|
|
525
|
+
* request.
|
|
526
|
+
* - `RouterNode`: The router handler has been executed and a node matched
|
|
527
|
+
* the request.
|
|
528
|
+
*
|
|
529
|
+
* @since 7.0.0
|
|
530
|
+
*/
|
|
531
|
+
routerNode?: RouterNode | null;
|
|
532
|
+
/**
|
|
533
|
+
* The route that matched the request. The field indicates three possible
|
|
534
|
+
* values:
|
|
535
|
+
*
|
|
536
|
+
* - `undefined`: The router handler has not been executed yet.
|
|
537
|
+
* - `null`: The router handler has been executed, but no route matched the
|
|
538
|
+
* request.
|
|
539
|
+
* - `Route`: The router handler has been executed and a route matched the
|
|
540
|
+
* request.
|
|
541
|
+
*
|
|
542
|
+
* @since 7.0.0
|
|
543
|
+
*/
|
|
544
|
+
route?: Route | null;
|
|
545
|
+
}
|
|
546
|
+
|
|
465
547
|
/**
|
|
466
548
|
* A media parser
|
|
467
549
|
* @since 1.3.0
|
|
@@ -554,7 +636,7 @@ declare abstract class Middleware<Options extends Middleware.Options = Middlewar
|
|
|
554
636
|
* @param response The server's response.
|
|
555
637
|
* @param route The route that matched this request, will be `null` if none matched.
|
|
556
638
|
*/
|
|
557
|
-
abstract run(request: Middleware.Request, response: Middleware.Response
|
|
639
|
+
abstract run(request: Middleware.Request, response: Middleware.Response): Awaitable<unknown>;
|
|
558
640
|
}
|
|
559
641
|
declare namespace Middleware {
|
|
560
642
|
/** @deprecated Use {@linkcode LoaderContext} instead. */
|
|
@@ -576,36 +658,68 @@ declare class MiddlewareStore extends Store<Middleware, 'middlewares'> {
|
|
|
576
658
|
*/
|
|
577
659
|
readonly sortedMiddlewares: Middleware[];
|
|
578
660
|
constructor();
|
|
579
|
-
run(request: Middleware.Request, response: Middleware.Response
|
|
661
|
+
run(request: Middleware.Request, response: Middleware.Response): Promise<void>;
|
|
580
662
|
set(key: string, value: Middleware): this;
|
|
581
663
|
delete(key: string): boolean;
|
|
582
664
|
clear(): void;
|
|
583
665
|
}
|
|
584
666
|
|
|
667
|
+
declare class RouterRoot extends RouterBranch {
|
|
668
|
+
constructor();
|
|
669
|
+
/**
|
|
670
|
+
* Adds a route to the branch
|
|
671
|
+
*
|
|
672
|
+
* @param route The route to add
|
|
673
|
+
* @returns The node the route was added to
|
|
674
|
+
*/
|
|
675
|
+
add(route: Route): RouterNode;
|
|
676
|
+
/**
|
|
677
|
+
* Removes a route from the branch
|
|
678
|
+
*
|
|
679
|
+
* @param route The route to remove
|
|
680
|
+
* @returns Whether or not the route was removed
|
|
681
|
+
*/
|
|
682
|
+
remove(route: Route): boolean;
|
|
683
|
+
get path(): string;
|
|
684
|
+
toString(): string;
|
|
685
|
+
static normalize(path: string | null | undefined): string[];
|
|
686
|
+
static extractMethod(path: readonly string[]): MethodName | null;
|
|
687
|
+
}
|
|
688
|
+
|
|
585
689
|
/**
|
|
586
690
|
* @since 1.0.0
|
|
587
691
|
*/
|
|
588
692
|
declare class RouteStore extends Store<Route, 'routes'> {
|
|
589
|
-
readonly
|
|
693
|
+
readonly router: RouterRoot;
|
|
590
694
|
constructor();
|
|
591
|
-
match(request: Route.Request): Route | null;
|
|
592
|
-
private parseURL;
|
|
593
695
|
}
|
|
594
696
|
|
|
595
|
-
declare enum
|
|
697
|
+
declare enum ServerEvent {
|
|
596
698
|
Error = "error",
|
|
597
699
|
Request = "request",
|
|
598
|
-
|
|
599
|
-
|
|
700
|
+
RouterBranchNotFound = "routerBranchNotFound",
|
|
701
|
+
RouterBranchMethodNotAllowed = "routerBranchMethodNotAllowed",
|
|
702
|
+
RouterFound = "routerFound",
|
|
600
703
|
RouteError = "routeError",
|
|
601
704
|
MiddlewareFailure = "middlewareFailure",
|
|
602
705
|
MiddlewareError = "middlewareError",
|
|
603
706
|
MiddlewareSuccess = "middlewareSuccess"
|
|
604
707
|
}
|
|
708
|
+
interface ServerEvents {
|
|
709
|
+
[ServerEvent.Error]: [error: Error, request: ApiRequest, response: ApiResponse];
|
|
710
|
+
[ServerEvent.Request]: [request: ApiRequest, response: ApiResponse];
|
|
711
|
+
[ServerEvent.RouterBranchNotFound]: [request: ApiRequest, response: ApiResponse];
|
|
712
|
+
[ServerEvent.RouterBranchMethodNotAllowed]: [request: ApiRequest, response: ApiResponse, node: RouterBranch];
|
|
713
|
+
[ServerEvent.RouterFound]: [request: ApiRequest, response: ApiResponse];
|
|
714
|
+
[ServerEvent.RouteError]: [error: Error, request: ApiRequest, response: ApiResponse];
|
|
715
|
+
[ServerEvent.MiddlewareFailure]: [request: ApiRequest, response: ApiResponse];
|
|
716
|
+
[ServerEvent.MiddlewareSuccess]: [request: Route.Request, response: Route.Response, route: Route];
|
|
717
|
+
[ServerEvent.MiddlewareError]: [error: Error, request: ApiRequest, response: ApiResponse];
|
|
718
|
+
}
|
|
605
719
|
/**
|
|
606
720
|
* @since 1.0.0
|
|
607
721
|
*/
|
|
608
|
-
declare class Server extends
|
|
722
|
+
declare class Server extends AsyncEventEmitter<ServerEvents> {
|
|
609
723
|
/**
|
|
610
724
|
* The routes this server holds.
|
|
611
725
|
* @since 1.0.0
|
|
@@ -738,27 +852,6 @@ interface ServerOptions {
|
|
|
738
852
|
* @since 1.0.0
|
|
739
853
|
*/
|
|
740
854
|
type AuthLessServerOptions = Omit<ServerOptions, 'auth'>;
|
|
741
|
-
/**
|
|
742
|
-
* The context sent in the error events.
|
|
743
|
-
* @since 1.2.0
|
|
744
|
-
*/
|
|
745
|
-
interface MiddlewareErrorContext {
|
|
746
|
-
/**
|
|
747
|
-
* The erroneous request.
|
|
748
|
-
* @since 1.2.0
|
|
749
|
-
*/
|
|
750
|
-
request: ApiRequest;
|
|
751
|
-
/**
|
|
752
|
-
* The server's response.
|
|
753
|
-
* @since 1.2.0
|
|
754
|
-
*/
|
|
755
|
-
response: ApiResponse;
|
|
756
|
-
/**
|
|
757
|
-
* The route match.
|
|
758
|
-
* @since 1.2.0
|
|
759
|
-
*/
|
|
760
|
-
route: Route;
|
|
761
|
-
}
|
|
762
855
|
|
|
763
856
|
declare enum HttpCodes {
|
|
764
857
|
/**
|
|
@@ -1172,4 +1265,4 @@ declare module '@sapphire/pieces' {
|
|
|
1172
1265
|
*/
|
|
1173
1266
|
declare const version: string;
|
|
1174
1267
|
|
|
1175
|
-
export { ApiRequest, ApiResponse, Auth, type AuthData, type AuthLessServerOptions, type ContentTypeParameter, type ContentTypeType, CookieStore, HttpCodes, type LoginData, type LoginDataTransformer,
|
|
1268
|
+
export { ApiRequest, ApiResponse, Auth, type AuthData, type AuthLessServerOptions, type ContentTypeParameter, type ContentTypeType, CookieStore, HttpCodes, type LoginData, type LoginDataTransformer, MediaParser, MediaParserStore, type MethodName, MethodNames, Middleware, type MiddlewareOptions, MiddlewareStore, type MimeType, type MimeTypeWithoutParameters, MimeTypes, Route, type RouteOptions, RouteStore, RouterBranch, RouterNode, RouterRoot, type SecureCookieStoreSetOptions, Server, ServerEvent, type ServerEvents, type ServerOptions, type ServerOptionsAuth, loadListeners, loadMediaParsers, loadMiddlewares, loadRoutes, version };
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import './chunk-
|
|
1
|
+
import './chunk-S573YWRP.mjs';
|
|
2
2
|
export * from './lib/structures/api/ApiRequest.mjs';
|
|
3
3
|
export * from './lib/structures/api/ApiResponse.mjs';
|
|
4
4
|
export * from './lib/structures/api/CookieStore.mjs';
|
|
@@ -11,16 +11,18 @@ export * from './lib/structures/MediaParserStore.mjs';
|
|
|
11
11
|
export * from './lib/structures/Middleware.mjs';
|
|
12
12
|
export * from './lib/structures/MiddlewareStore.mjs';
|
|
13
13
|
export * from './lib/structures/Route.mjs';
|
|
14
|
+
export * from './lib/structures/router/RouterBranch.mjs';
|
|
15
|
+
export * from './lib/structures/router/RouterNode.mjs';
|
|
16
|
+
export * from './lib/structures/router/RouterRoot.mjs';
|
|
14
17
|
export * from './lib/structures/RouteStore.mjs';
|
|
15
18
|
export * from './lib/utils/MimeTypes.mjs';
|
|
16
|
-
export * from './lib/utils/RouteData.mjs';
|
|
17
19
|
export { loadListeners } from './listeners/_load.mjs';
|
|
18
20
|
export { loadMediaParsers } from './mediaParsers/_load.mjs';
|
|
19
21
|
export { loadMiddlewares } from './middlewares/_load.mjs';
|
|
20
22
|
export { loadRoutes } from './routes/_load.mjs';
|
|
21
23
|
|
|
22
|
-
var version = "7.0.0-next.
|
|
24
|
+
var version = "7.0.0-next.1054b61";
|
|
23
25
|
|
|
24
26
|
export { version };
|
|
25
|
-
//# sourceMappingURL=
|
|
27
|
+
//# sourceMappingURL=index.mjs.map
|
|
26
28
|
//# sourceMappingURL=index.mjs.map
|
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAyDO,IAAM,OAAkB,GAAA","file":"index.mjs","sourcesContent":["import type { Server, ServerOptions } from './lib/structures/http/Server';\nimport type { MediaParserStore } from './lib/structures/MediaParserStore';\nimport type { MiddlewareStore } from './lib/structures/MiddlewareStore';\nimport type { RouteStore } from './lib/structures/RouteStore';\n\nexport * from './lib/structures/api/ApiRequest';\nexport * from './lib/structures/api/ApiResponse';\nexport * from './lib/structures/api/CookieStore';\nexport * from './lib/structures/http/Auth';\nexport * from './lib/structures/http/HttpCodes';\nexport * from './lib/structures/http/HttpMethods';\nexport * from './lib/structures/http/Server';\nexport * from './lib/structures/MediaParser';\nexport * from './lib/structures/MediaParserStore';\nexport * from './lib/structures/Middleware';\nexport * from './lib/structures/MiddlewareStore';\nexport * from './lib/structures/Route';\nexport * from './lib/structures/router/RouterBranch';\nexport * from './lib/structures/router/RouterNode';\nexport * from './lib/structures/router/RouterRoot';\nexport * from './lib/structures/RouteStore';\nexport * from './lib/utils/MimeTypes';\n\nexport { loadListeners } from './listeners/_load';\nexport { loadMediaParsers } from './mediaParsers/_load';\nexport { loadMiddlewares } from './middlewares/_load';\nexport { loadRoutes } from './routes/_load';\n\ndeclare module 'discord.js' {\n\tinterface Client {\n\t\tserver: Server;\n\t}\n\n\tinterface ClientOptions {\n\t\tapi?: ServerOptions;\n\t}\n}\n\ndeclare module '@sapphire/pieces' {\n\tinterface StoreRegistryEntries {\n\t\troutes: RouteStore;\n\t\tmediaParsers: MediaParserStore;\n\t\tmiddlewares: MiddlewareStore;\n\t}\n\n\tinterface Container {\n\t\tserver: Server;\n\t}\n}\n\n/**\n * The [@sapphire/plugin-api](https://github.com/sapphiredev/plugins/blob/main/packages/api) version that you are currently using.\n * An example use of this is showing it of in a bot information command.\n *\n * Note to Sapphire developers: This needs to explicitly be `string` so it is not typed as the string that gets replaced by esbuild\n */\n// eslint-disable-next-line @typescript-eslint/no-inferrable-types\nexport const version: string = '7.0.0-next.1054b61';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"Augmentations.d.mjs"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __name } from '../../chunk-
|
|
1
|
+
import { __name } from '../../chunk-S573YWRP.mjs';
|
|
2
2
|
import { Piece } from '@sapphire/pieces';
|
|
3
3
|
import { createBrotliDecompress, createGunzip, createInflate } from 'zlib';
|
|
4
4
|
|
|
@@ -72,5 +72,5 @@ __name(_MediaParser, "MediaParser");
|
|
|
72
72
|
var MediaParser = _MediaParser;
|
|
73
73
|
|
|
74
74
|
export { MediaParser };
|
|
75
|
-
//# sourceMappingURL=
|
|
75
|
+
//# sourceMappingURL=MediaParser.mjs.map
|
|
76
76
|
//# sourceMappingURL=MediaParser.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/structures/MediaParser.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/structures/MediaParser.ts"],"names":[],"mappings":";;;;AAWO,IAAe,YAAA,GAAf,MAAe,YAAA,SAA+E,KAA+B,CAAA;AAAA,EAC5H,WAAY,CAAA,OAAA,EAAoC,OAAmB,GAAA,EAAe,EAAA;AACxF,IAAA,KAAA,CAAM,SAAS,OAAO,CAAA,CAAA;AAAA,GACvB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaO,QAAQ,KAAuB,EAAA;AACrC,IAAA,OAAO,MAAM,wBAA6B,KAAA,IAAA,IAAQ,MAAM,wBAAyB,CAAA,QAAA,CAAS,KAAK,IAAiC,CAAA,CAAA;AAAA,GACjI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAgB,WAAW,OAA+C,EAAA;AACzE,IAAM,MAAA,MAAA,GAAS,IAAK,CAAA,aAAA,CAAc,OAAO,CAAA,CAAA;AACzC,IAAI,IAAA,MAAA,KAAW,MAAa,OAAA,EAAA,CAAA;AAE5B,IAAA,IAAI,IAAO,GAAA,EAAA,CAAA;AACX,IAAiB,WAAA,MAAA,KAAA,IAAS,QAAgB,IAAA,IAAA,KAAA,CAAA;AAE1C,IAAO,OAAA,IAAA,CAAA;AAAA,GACR;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAgB,WAAW,OAA+C,EAAA;AACzE,IAAM,MAAA,MAAA,GAAS,IAAK,CAAA,aAAA,CAAc,OAAO,CAAA,CAAA;AACzC,IAAA,IAAI,MAAW,KAAA,IAAA,EAAa,OAAA,MAAA,CAAO,MAAM,CAAC,CAAA,CAAA;AAE1C,IAAA,MAAM,SAAmB,EAAC,CAAA;AAC1B,IAAA,WAAA,MAAiB,KAAS,IAAA,MAAA,EAAe,MAAA,CAAA,IAAA,CAAK,KAAK,CAAA,CAAA;AAEnD,IAAO,OAAA,MAAA,CAAO,OAAO,MAAM,CAAA,CAAA;AAAA,GAC5B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOU,cAAc,OAAmE,EAAA;AAC1F,IAAA,QAAA,CAAS,QAAQ,OAAQ,CAAA,kBAAkB,CAAK,IAAA,UAAA,EAAY,aAAe;AAAA,MAK1E,KAAK,SAAW,EAAA;AACf,QAAA,MAAM,SAAS,aAAc,EAAA,CAAA;AAC7B,QAAA,OAAA,CAAQ,KAAK,MAAM,CAAA,CAAA;AACnB,QAAO,OAAA,MAAA,CAAA;AAAA,OACR;AAAA,MAMA,KAAK,QAAA,CAAA;AAAA,MACL,KAAK,MAAQ,EAAA;AACZ,QAAA,MAAM,SAAS,YAAa,EAAA,CAAA;AAC5B,QAAA,OAAA,CAAQ,KAAK,MAAM,CAAA,CAAA;AACnB,QAAO,OAAA,MAAA,CAAA;AAAA,OACR;AAAA,MAKA,KAAK,IAAM,EAAA;AACV,QAAA,MAAM,SAAS,sBAAuB,EAAA,CAAA;AACtC,QAAA,OAAA,CAAQ,KAAK,MAAM,CAAA,CAAA;AACnB,QAAO,OAAA,MAAA,CAAA;AAAA,OACR;AAAA,MAIA,KAAK,UAAY,EAAA;AAChB,QAAO,OAAA,OAAA,CAAA;AAAA,OACR;AAAA,KACD;AAEA,IAAO,OAAA,IAAA,CAAA;AAAA,GACR;AACD,CAAA,CAAA;AAhGoI,MAAA,CAAA,YAAA,EAAA,aAAA,CAAA,CAAA;AAA7H,IAAe,WAAf,GAAA","file":"MediaParser.mjs","sourcesContent":["import { Piece } from '@sapphire/pieces';\nimport type { Awaitable } from '@sapphire/utilities';\nimport { createBrotliDecompress, createGunzip, createInflate, type Gunzip } from 'zlib';\nimport type { ApiRequest } from './api/ApiRequest';\nimport type { MimeTypeWithoutParameters } from './http/Server';\nimport type { Route } from './Route';\n\n/**\n * A media parser\n * @since 1.3.0\n */\nexport abstract class MediaParser<Options extends MediaParser.Options = MediaParser.Options> extends Piece<Options, 'mediaParsers'> {\n\tpublic constructor(context: MediaParser.LoaderContext, options: Options = {} as Options) {\n\t\tsuper(context, options);\n\t}\n\n\t/**\n\t * Parses the body data from an API request.\n\t * @since 1.3.0\n\t */\n\tpublic abstract run(request: MediaParser.Request): Awaitable<unknown>;\n\n\t/**\n\t * Checks if a route accepts the media type from this parser.\n\t * @since 1.3.0\n\t * @param route The route to be checked.\n\t */\n\tpublic accepts(route: Route): boolean {\n\t\treturn route.acceptedContentMimeTypes === null || route.acceptedContentMimeTypes.includes(this.name as MimeTypeWithoutParameters);\n\t}\n\n\t/**\n\t * Reads the content body as a string, this is useful for parsing/reading plain-text data.\n\t * @since 1.3.0\n\t * @param request The request to read the body from.\n\t */\n\tprotected async readString(request: MediaParser.Request): Promise<string> {\n\t\tconst stream = this.contentStream(request);\n\t\tif (stream === null) return '';\n\n\t\tlet body = '';\n\t\tfor await (const chunk of stream) body += chunk;\n\n\t\treturn body;\n\t}\n\n\t/**\n\t * Reads the content body as a buffer, this is useful for parsing/reading binary data.\n\t * @since 1.3.0\n\t * @param request The request to read the body from.\n\t */\n\tprotected async readBuffer(request: MediaParser.Request): Promise<Buffer> {\n\t\tconst stream = this.contentStream(request);\n\t\tif (stream === null) return Buffer.alloc(0);\n\n\t\tconst bodies: Buffer[] = [];\n\t\tfor await (const chunk of stream) bodies.push(chunk);\n\n\t\treturn Buffer.concat(bodies);\n\t}\n\n\t/**\n\t * Reads the content stream from a request, piping the data through a transformer stream.\n\t * @since 1.3.0\n\t * @param request The request to read the body from.\n\t */\n\tprotected contentStream(request: MediaParser.Request): MediaParser.Request | Gunzip | null {\n\t\tswitch ((request.headers['content-encoding'] ?? 'identity').toLowerCase()) {\n\t\t\t// RFC 7230 4.2.2:\n\t\t\t//\n\t\t\t// The \"deflate\" coding is a \"zlib\" data format (RFC 1950) containing a \"deflate\" compressed data stream\n\t\t\t// (RFC 1951) that uses a combination of the Lempel-Ziv (LZ77) compression algorithm and Huffman coding.\n\t\t\tcase 'deflate': {\n\t\t\t\tconst stream = createInflate();\n\t\t\t\trequest.pipe(stream);\n\t\t\t\treturn stream;\n\t\t\t}\n\n\t\t\t// RFC 7230 4.2.3\n\t\t\t//\n\t\t\t// The \"gzip\" coding is an LZ77 coding with a 32-bit Cyclic Redundancy Check (CRC) that is commonly produced\n\t\t\t// by the gzip file compression program (RFC 1952).\n\t\t\tcase 'x-gzip':\n\t\t\tcase 'gzip': {\n\t\t\t\tconst stream = createGunzip();\n\t\t\t\trequest.pipe(stream);\n\t\t\t\treturn stream;\n\t\t\t}\n\n\t\t\t// RFC 7932\n\t\t\t//\n\t\t\t// A format using the Brotli algorithm.\n\t\t\tcase 'br': {\n\t\t\t\tconst stream = createBrotliDecompress();\n\t\t\t\trequest.pipe(stream);\n\t\t\t\treturn stream;\n\t\t\t}\n\n\t\t\t// An \"identity\" token is used as a synonym for \"no encoding\" in order to communicate when no encoding is\n\t\t\t// preferred.\n\t\t\tcase 'identity': {\n\t\t\t\treturn request;\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}\n}\n\nexport namespace MediaParser {\n\t/** @deprecated Use {@linkcode LoaderContext} instead. */\n\texport type Context = LoaderContext;\n\texport type LoaderContext = Piece.LoaderContext<'mediaParsers'>;\n\texport type Options = Piece.Options;\n\texport type JSON = Piece.JSON;\n\texport type LocationJSON = Piece.LocationJSON;\n\n\texport type Request = ApiRequest;\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __name } from '../../chunk-
|
|
1
|
+
import { __name } from '../../chunk-S573YWRP.mjs';
|
|
2
2
|
import { Store } from '@sapphire/pieces';
|
|
3
3
|
import { MediaParser } from './MediaParser.mjs';
|
|
4
4
|
|
|
@@ -20,5 +20,5 @@ __name(_MediaParserStore, "MediaParserStore");
|
|
|
20
20
|
var MediaParserStore = _MediaParserStore;
|
|
21
21
|
|
|
22
22
|
export { MediaParserStore };
|
|
23
|
-
//# sourceMappingURL=
|
|
23
|
+
//# sourceMappingURL=MediaParserStore.mjs.map
|
|
24
24
|
//# sourceMappingURL=MediaParserStore.mjs.map
|