@sapphire/plugin-api 7.0.0-next.d27dc1c → 7.0.0-next.d2c9aaa

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.
Files changed (206) hide show
  1. package/README.md +0 -1
  2. package/dist/cjs/index.cjs +21 -33
  3. package/dist/cjs/index.cjs.map +1 -1
  4. package/dist/cjs/index.d.cts +318 -212
  5. package/dist/cjs/lib/structures/Augmentations.d.cjs +1 -1
  6. package/dist/cjs/lib/structures/Augmentations.d.cjs.map +1 -1
  7. package/dist/cjs/lib/structures/Middleware.cjs +2 -2
  8. package/dist/cjs/lib/structures/Middleware.cjs.map +1 -1
  9. package/dist/cjs/lib/structures/MiddlewareStore.cjs +4 -4
  10. package/dist/cjs/lib/structures/MiddlewareStore.cjs.map +1 -1
  11. package/dist/cjs/lib/structures/Route.cjs +18 -40
  12. package/dist/cjs/lib/structures/Route.cjs.map +1 -1
  13. package/dist/cjs/lib/structures/RouteLoaderStrategy.cjs +20 -0
  14. package/dist/cjs/lib/structures/RouteLoaderStrategy.cjs.map +1 -0
  15. package/dist/cjs/lib/structures/RouteStore.cjs +6 -44
  16. package/dist/cjs/lib/structures/RouteStore.cjs.map +1 -1
  17. package/dist/cjs/lib/structures/api/ApiRequest.cjs +155 -5
  18. package/dist/cjs/lib/structures/api/ApiRequest.cjs.map +1 -1
  19. package/dist/cjs/lib/structures/api/ApiResponse.cjs +12 -7
  20. package/dist/cjs/lib/structures/api/ApiResponse.cjs.map +1 -1
  21. package/dist/cjs/lib/structures/api/CookieStore.cjs +4 -4
  22. package/dist/cjs/lib/structures/api/CookieStore.cjs.map +1 -1
  23. package/dist/cjs/lib/structures/http/Auth.cjs +2 -2
  24. package/dist/cjs/lib/structures/http/Auth.cjs.map +1 -1
  25. package/dist/cjs/lib/structures/http/HttpCodes.cjs +1 -1
  26. package/dist/cjs/lib/structures/http/HttpCodes.cjs.map +1 -1
  27. package/dist/cjs/lib/structures/http/HttpMethods.cjs +39 -7
  28. package/dist/cjs/lib/structures/http/HttpMethods.cjs.map +1 -1
  29. package/dist/cjs/lib/structures/http/Server.cjs +17 -23
  30. package/dist/cjs/lib/structures/http/Server.cjs.map +1 -1
  31. package/dist/cjs/lib/structures/router/RouterBranch.cjs +184 -0
  32. package/dist/cjs/lib/structures/router/RouterBranch.cjs.map +1 -0
  33. package/dist/cjs/lib/structures/router/RouterNode.cjs +67 -0
  34. package/dist/cjs/lib/structures/router/RouterNode.cjs.map +1 -0
  35. package/dist/cjs/lib/structures/router/RouterRoot.cjs +81 -0
  36. package/dist/cjs/lib/structures/router/RouterRoot.cjs.map +1 -0
  37. package/dist/cjs/lib/utils/MimeType.cjs +4 -0
  38. package/dist/cjs/lib/utils/MimeType.cjs.map +1 -0
  39. package/dist/cjs/lib/utils/_body/RequestHeadersProxy.cjs +100 -0
  40. package/dist/cjs/lib/utils/_body/RequestHeadersProxy.cjs.map +1 -0
  41. package/dist/cjs/lib/utils/_body/RequestProxy.cjs +123 -0
  42. package/dist/cjs/lib/utils/_body/RequestProxy.cjs.map +1 -0
  43. package/dist/cjs/lib/utils/_body/RequestURLProxy.cjs +179 -0
  44. package/dist/cjs/lib/utils/_body/RequestURLProxy.cjs.map +1 -0
  45. package/dist/cjs/lib/utils/constants.cjs +8 -0
  46. package/dist/cjs/lib/utils/constants.cjs.map +1 -0
  47. package/dist/cjs/listeners/PluginRouteError.cjs +3 -3
  48. package/dist/cjs/listeners/PluginRouteError.cjs.map +1 -1
  49. package/dist/cjs/listeners/PluginServerMiddlewareError.cjs +3 -3
  50. package/dist/cjs/listeners/PluginServerMiddlewareError.cjs.map +1 -1
  51. package/dist/cjs/listeners/PluginServerMiddlewareSuccess.cjs +5 -5
  52. package/dist/cjs/listeners/PluginServerMiddlewareSuccess.cjs.map +1 -1
  53. package/dist/cjs/listeners/PluginServerRequest.cjs +42 -8
  54. package/dist/cjs/listeners/PluginServerRequest.cjs.map +1 -1
  55. package/dist/cjs/listeners/{PluginServerMatch.cjs → PluginServerRouterBranchMethodNotAllowed.cjs} +5 -10
  56. package/dist/cjs/listeners/PluginServerRouterBranchMethodNotAllowed.cjs.map +1 -0
  57. package/dist/cjs/listeners/{PluginServerNoMatch.cjs → PluginServerRouterBranchNotFound.cjs} +3 -3
  58. package/dist/cjs/listeners/PluginServerRouterBranchNotFound.cjs.map +1 -0
  59. package/dist/cjs/listeners/PluginServerRouterFound.cjs +22 -0
  60. package/dist/cjs/listeners/PluginServerRouterFound.cjs.map +1 -0
  61. package/dist/cjs/listeners/_load.cjs +7 -5
  62. package/dist/cjs/listeners/_load.cjs.map +1 -1
  63. package/dist/cjs/middlewares/_load.cjs +1 -1
  64. package/dist/cjs/middlewares/_load.cjs.map +1 -1
  65. package/dist/cjs/middlewares/auth.cjs +2 -2
  66. package/dist/cjs/middlewares/auth.cjs.map +1 -1
  67. package/dist/cjs/middlewares/body.cjs +4 -19
  68. package/dist/cjs/middlewares/body.cjs.map +1 -1
  69. package/dist/cjs/middlewares/cookies.cjs +1 -1
  70. package/dist/cjs/middlewares/cookies.cjs.map +1 -1
  71. package/dist/cjs/middlewares/headers.cjs +19 -9
  72. package/dist/cjs/middlewares/headers.cjs.map +1 -1
  73. package/dist/cjs/register.cjs +3 -4
  74. package/dist/cjs/register.cjs.map +1 -1
  75. package/dist/cjs/register.d.cts +0 -1
  76. package/dist/cjs/routes/_load.cjs +5 -5
  77. package/dist/cjs/routes/_load.cjs.map +1 -1
  78. package/dist/cjs/routes/oauth/{callback.cjs → callback.post.cjs} +6 -7
  79. package/dist/cjs/routes/oauth/callback.post.cjs.map +1 -0
  80. package/dist/cjs/routes/oauth/{logout.cjs → logout.post.cjs} +6 -8
  81. package/dist/cjs/routes/oauth/logout.post.cjs.map +1 -0
  82. package/dist/esm/{chunk-JTFKMR4I.mjs → chunk-S573YWRP.mjs} +4 -3
  83. package/dist/esm/chunk-S573YWRP.mjs.map +1 -0
  84. package/dist/esm/index.d.mts +318 -212
  85. package/dist/esm/index.mjs +6 -8
  86. package/dist/esm/index.mjs.map +1 -1
  87. package/dist/esm/lib/structures/Augmentations.d.mjs +1 -1
  88. package/dist/esm/lib/structures/Augmentations.d.mjs.map +1 -1
  89. package/dist/esm/lib/structures/Middleware.mjs +2 -2
  90. package/dist/esm/lib/structures/Middleware.mjs.map +1 -1
  91. package/dist/esm/lib/structures/MiddlewareStore.mjs +4 -4
  92. package/dist/esm/lib/structures/MiddlewareStore.mjs.map +1 -1
  93. package/dist/esm/lib/structures/Route.mjs +19 -41
  94. package/dist/esm/lib/structures/Route.mjs.map +1 -1
  95. package/dist/esm/lib/structures/RouteLoaderStrategy.mjs +17 -0
  96. package/dist/esm/lib/structures/RouteLoaderStrategy.mjs.map +1 -0
  97. package/dist/esm/lib/structures/RouteStore.mjs +6 -44
  98. package/dist/esm/lib/structures/RouteStore.mjs.map +1 -1
  99. package/dist/esm/lib/structures/api/ApiRequest.mjs +149 -6
  100. package/dist/esm/lib/structures/api/ApiRequest.mjs.map +1 -1
  101. package/dist/esm/lib/structures/api/ApiResponse.mjs +12 -7
  102. package/dist/esm/lib/structures/api/ApiResponse.mjs.map +1 -1
  103. package/dist/esm/lib/structures/api/CookieStore.mjs +5 -5
  104. package/dist/esm/lib/structures/api/CookieStore.mjs.map +1 -1
  105. package/dist/esm/lib/structures/http/Auth.mjs +2 -2
  106. package/dist/esm/lib/structures/http/Auth.mjs.map +1 -1
  107. package/dist/esm/lib/structures/http/HttpCodes.mjs +2 -2
  108. package/dist/esm/lib/structures/http/HttpCodes.mjs.map +1 -1
  109. package/dist/esm/lib/structures/http/HttpMethods.mjs +41 -6
  110. package/dist/esm/lib/structures/http/HttpMethods.mjs.map +1 -1
  111. package/dist/esm/lib/structures/http/Server.mjs +18 -24
  112. package/dist/esm/lib/structures/http/Server.mjs.map +1 -1
  113. package/dist/esm/lib/structures/router/RouterBranch.mjs +179 -0
  114. package/dist/esm/lib/structures/router/RouterBranch.mjs.map +1 -0
  115. package/dist/esm/lib/structures/router/RouterNode.mjs +56 -0
  116. package/dist/esm/lib/structures/router/RouterNode.mjs.map +1 -0
  117. package/dist/esm/lib/structures/router/RouterRoot.mjs +78 -0
  118. package/dist/esm/lib/structures/router/RouterRoot.mjs.map +1 -0
  119. package/dist/esm/lib/utils/MimeType.mjs +3 -0
  120. package/dist/esm/lib/utils/MimeType.mjs.map +1 -0
  121. package/dist/esm/lib/utils/_body/RequestHeadersProxy.mjs +95 -0
  122. package/dist/esm/lib/utils/_body/RequestHeadersProxy.mjs.map +1 -0
  123. package/dist/esm/lib/utils/_body/RequestProxy.mjs +111 -0
  124. package/dist/esm/lib/utils/_body/RequestProxy.mjs.map +1 -0
  125. package/dist/esm/lib/utils/_body/RequestURLProxy.mjs +167 -0
  126. package/dist/esm/lib/utils/_body/RequestURLProxy.mjs.map +1 -0
  127. package/dist/esm/lib/utils/constants.mjs +8 -0
  128. package/dist/esm/lib/utils/constants.mjs.map +1 -0
  129. package/dist/esm/listeners/PluginRouteError.mjs +5 -5
  130. package/dist/esm/listeners/PluginRouteError.mjs.map +1 -1
  131. package/dist/esm/listeners/PluginServerMiddlewareError.mjs +5 -5
  132. package/dist/esm/listeners/PluginServerMiddlewareError.mjs.map +1 -1
  133. package/dist/esm/listeners/PluginServerMiddlewareSuccess.mjs +7 -7
  134. package/dist/esm/listeners/PluginServerMiddlewareSuccess.mjs.map +1 -1
  135. package/dist/esm/listeners/PluginServerRequest.mjs +38 -10
  136. package/dist/esm/listeners/PluginServerRequest.mjs.map +1 -1
  137. package/dist/esm/listeners/PluginServerRouterBranchMethodNotAllowed.mjs +18 -0
  138. package/dist/esm/listeners/PluginServerRouterBranchMethodNotAllowed.mjs.map +1 -0
  139. package/dist/esm/listeners/{PluginServerNoMatch.mjs → PluginServerRouterBranchNotFound.mjs} +5 -5
  140. package/dist/esm/listeners/PluginServerRouterBranchNotFound.mjs.map +1 -0
  141. package/dist/esm/listeners/PluginServerRouterFound.mjs +19 -0
  142. package/dist/esm/listeners/PluginServerRouterFound.mjs.map +1 -0
  143. package/dist/esm/listeners/_load.mjs +14 -12
  144. package/dist/esm/listeners/_load.mjs.map +1 -1
  145. package/dist/esm/middlewares/_load.mjs +2 -2
  146. package/dist/esm/middlewares/_load.mjs.map +1 -1
  147. package/dist/esm/middlewares/auth.mjs +2 -2
  148. package/dist/esm/middlewares/auth.mjs.map +1 -1
  149. package/dist/esm/middlewares/body.mjs +5 -18
  150. package/dist/esm/middlewares/body.mjs.map +1 -1
  151. package/dist/esm/middlewares/cookies.mjs +2 -2
  152. package/dist/esm/middlewares/cookies.mjs.map +1 -1
  153. package/dist/esm/middlewares/headers.mjs +20 -10
  154. package/dist/esm/middlewares/headers.mjs.map +1 -1
  155. package/dist/esm/register.d.mts +0 -1
  156. package/dist/esm/register.mjs +4 -5
  157. package/dist/esm/register.mjs.map +1 -1
  158. package/dist/esm/routes/_load.mjs +4 -4
  159. package/dist/esm/routes/_load.mjs.map +1 -1
  160. package/dist/esm/routes/oauth/{callback.mjs → callback.post.mjs} +6 -7
  161. package/dist/esm/routes/oauth/callback.post.mjs.map +1 -0
  162. package/dist/esm/routes/oauth/{logout.mjs → logout.post.mjs} +6 -8
  163. package/dist/esm/routes/oauth/logout.post.mjs.map +1 -0
  164. package/package.json +11 -8
  165. package/dist/cjs/lib/structures/MediaParser.cjs +0 -79
  166. package/dist/cjs/lib/structures/MediaParser.cjs.map +0 -1
  167. package/dist/cjs/lib/structures/MediaParserStore.cjs +0 -27
  168. package/dist/cjs/lib/structures/MediaParserStore.cjs.map +0 -1
  169. package/dist/cjs/lib/utils/MimeTypes.cjs +0 -26
  170. package/dist/cjs/lib/utils/MimeTypes.cjs.map +0 -1
  171. package/dist/cjs/lib/utils/RouteData.cjs +0 -62
  172. package/dist/cjs/lib/utils/RouteData.cjs.map +0 -1
  173. package/dist/cjs/listeners/PluginServerMatch.cjs.map +0 -1
  174. package/dist/cjs/listeners/PluginServerNoMatch.cjs.map +0 -1
  175. package/dist/cjs/mediaParsers/_load.cjs +0 -20
  176. package/dist/cjs/mediaParsers/_load.cjs.map +0 -1
  177. package/dist/cjs/mediaParsers/applicationFormUrlEncoded.cjs +0 -23
  178. package/dist/cjs/mediaParsers/applicationFormUrlEncoded.cjs.map +0 -1
  179. package/dist/cjs/mediaParsers/applicationJson.cjs +0 -22
  180. package/dist/cjs/mediaParsers/applicationJson.cjs.map +0 -1
  181. package/dist/cjs/mediaParsers/textPlain.cjs +0 -22
  182. package/dist/cjs/mediaParsers/textPlain.cjs.map +0 -1
  183. package/dist/cjs/routes/oauth/callback.cjs.map +0 -1
  184. package/dist/cjs/routes/oauth/logout.cjs.map +0 -1
  185. package/dist/esm/chunk-JTFKMR4I.mjs.map +0 -1
  186. package/dist/esm/lib/structures/MediaParser.mjs +0 -76
  187. package/dist/esm/lib/structures/MediaParser.mjs.map +0 -1
  188. package/dist/esm/lib/structures/MediaParserStore.mjs +0 -24
  189. package/dist/esm/lib/structures/MediaParserStore.mjs.map +0 -1
  190. package/dist/esm/lib/utils/MimeTypes.mjs +0 -26
  191. package/dist/esm/lib/utils/MimeTypes.mjs.map +0 -1
  192. package/dist/esm/lib/utils/RouteData.mjs +0 -56
  193. package/dist/esm/lib/utils/RouteData.mjs.map +0 -1
  194. package/dist/esm/listeners/PluginServerMatch.mjs +0 -23
  195. package/dist/esm/listeners/PluginServerMatch.mjs.map +0 -1
  196. package/dist/esm/listeners/PluginServerNoMatch.mjs.map +0 -1
  197. package/dist/esm/mediaParsers/_load.mjs +0 -17
  198. package/dist/esm/mediaParsers/_load.mjs.map +0 -1
  199. package/dist/esm/mediaParsers/applicationFormUrlEncoded.mjs +0 -20
  200. package/dist/esm/mediaParsers/applicationFormUrlEncoded.mjs.map +0 -1
  201. package/dist/esm/mediaParsers/applicationJson.mjs +0 -19
  202. package/dist/esm/mediaParsers/applicationJson.mjs.map +0 -1
  203. package/dist/esm/mediaParsers/textPlain.mjs +0 -19
  204. package/dist/esm/mediaParsers/textPlain.mjs.map +0 -1
  205. package/dist/esm/routes/oauth/callback.mjs.map +0 -1
  206. package/dist/esm/routes/oauth/logout.mjs.map +0 -1
@@ -1,34 +1,21 @@
1
- import { __name, __publicField } from '../chunk-JTFKMR4I.mjs';
1
+ import { __name } from '../chunk-S573YWRP.mjs';
2
2
  import { HttpCodes } from '../lib/structures/http/HttpCodes.mjs';
3
3
  import { Middleware } from '../lib/structures/Middleware.mjs';
4
4
 
5
5
  var _PluginMiddleware = class _PluginMiddleware extends Middleware {
6
6
  constructor(context) {
7
7
  super(context, { position: 20 });
8
- __publicField(this, "mediaParsers");
9
- this.mediaParsers = this.container.server.mediaParsers;
10
8
  }
11
- async run(request, response, route) {
9
+ run(request, response) {
10
+ if (!request.route) return;
12
11
  const contentType = request.headers["content-type"];
13
12
  if (typeof contentType !== "string") return;
14
13
  const lengthString = request.headers["content-length"];
15
14
  if (typeof lengthString !== "string") return;
16
15
  const length = Number(lengthString);
17
- const maximumLength = route.maximumBodyLength;
16
+ const maximumLength = request.route.maximumBodyLength;
18
17
  if (length > maximumLength) {
19
18
  response.status(HttpCodes.PayloadTooLarge).json({ error: "Exceeded maximum content length." });
20
- return;
21
- }
22
- const type = this.mediaParsers.parseContentType(contentType);
23
- const parser = this.mediaParsers.get(type);
24
- if (!parser || !parser.accepts(route)) {
25
- response.status(HttpCodes.UnsupportedMediaType).json({ error: `Unsupported type ${type}.` });
26
- return;
27
- }
28
- try {
29
- request.body = await parser.run(request);
30
- } catch {
31
- response.status(HttpCodes.BadRequest).json({ error: `Cannot parse ${type} data.` });
32
19
  }
33
20
  }
34
21
  };
@@ -36,5 +23,5 @@ __name(_PluginMiddleware, "PluginMiddleware");
36
23
  var PluginMiddleware = _PluginMiddleware;
37
24
 
38
25
  export { PluginMiddleware };
39
- //# sourceMappingURL=out.js.map
26
+ //# sourceMappingURL=body.mjs.map
40
27
  //# sourceMappingURL=body.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/middlewares/body.ts"],"names":[],"mappings":";;;;;;AAEA,SAAS,iBAAiB;AAE1B,SAAS,kBAAkB;AAGpB,IAAM,oBAAN,MAAM,0BAAyB,WAAW;AAAA,EAGzC,YAAY,SAAmC;AACrD,UAAM,SAAS,EAAE,UAAU,GAAG,CAAC;AAHhC,wBAAiB;AAIhB,SAAK,eAAe,KAAK,UAAU,OAAO;AAAA,EAC3C;AAAA,EAEA,MAAsB,IAAI,SAAqB,UAAuB,OAAc;AAEnF,UAAM,cAAc,QAAQ,QAAQ,cAAc;AAClD,QAAI,OAAO,gBAAgB,SAAU;AAGrC,UAAM,eAAe,QAAQ,QAAQ,gBAAgB;AACrD,QAAI,OAAO,iBAAiB,SAAU;AAGtC,UAAM,SAAS,OAAO,YAAY;AAClC,UAAM,gBAAgB,MAAM;AAC5B,QAAI,SAAS,eAAe;AAC3B,eAAS,OAAO,UAAU,eAAe,EAAE,KAAK,EAAE,OAAO,mCAAmC,CAAC;AAC7F;AAAA,IACD;AAGA,UAAM,OAAO,KAAK,aAAa,iBAAiB,WAAW;AAC3D,UAAM,SAAS,KAAK,aAAa,IAAI,IAAI;AACzC,QAAI,CAAC,UAAU,CAAC,OAAO,QAAQ,KAAK,GAAG;AACtC,eAAS,OAAO,UAAU,oBAAoB,EAAE,KAAK,EAAE,OAAO,oBAAoB,IAAI,IAAI,CAAC;AAC3F;AAAA,IACD;AAEA,QAAI;AAEH,cAAQ,OAAO,MAAM,OAAO,IAAI,OAAO;AAAA,IACxC,QAAQ;AACP,eAAS,OAAO,UAAU,UAAU,EAAE,KAAK,EAAE,OAAO,gBAAgB,IAAI,SAAS,CAAC;AAAA,IACnF;AAAA,EACD;AACD;AAxCiD;AAA1C,IAAM,mBAAN","sourcesContent":["import type { ApiRequest } from '../lib/structures/api/ApiRequest';\nimport type { ApiResponse } from '../lib/structures/api/ApiResponse';\nimport { HttpCodes } from '../lib/structures/http/HttpCodes';\nimport type { MediaParserStore } from '../lib/structures/MediaParserStore';\nimport { Middleware } from '../lib/structures/Middleware';\nimport type { Route } from '../lib/structures/Route';\n\nexport class PluginMiddleware extends Middleware {\n\tprivate readonly mediaParsers: MediaParserStore;\n\n\tpublic constructor(context: Middleware.LoaderContext) {\n\t\tsuper(context, { position: 20 });\n\t\tthis.mediaParsers = this.container.server.mediaParsers;\n\t}\n\n\tpublic override async run(request: ApiRequest, response: ApiResponse, route: Route) {\n\t\t// RFC 1341 4.\n\t\tconst contentType = request.headers['content-type'];\n\t\tif (typeof contentType !== 'string') return;\n\n\t\t// RFC 7230 3.3.2.\n\t\tconst lengthString = request.headers['content-length'];\n\t\tif (typeof lengthString !== 'string') return;\n\n\t\t// Verify if the content length is lower than accepted:\n\t\tconst length = Number(lengthString);\n\t\tconst maximumLength = route.maximumBodyLength;\n\t\tif (length > maximumLength) {\n\t\t\tresponse.status(HttpCodes.PayloadTooLarge).json({ error: 'Exceeded maximum content length.' });\n\t\t\treturn;\n\t\t}\n\n\t\t// Verify if the content type is supported by the parser:\n\t\tconst type = this.mediaParsers.parseContentType(contentType);\n\t\tconst parser = this.mediaParsers.get(type);\n\t\tif (!parser || !parser.accepts(route)) {\n\t\t\tresponse.status(HttpCodes.UnsupportedMediaType).json({ error: `Unsupported type ${type}.` });\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\t// Parse the content body:\n\t\t\trequest.body = await parser.run(request);\n\t\t} catch {\n\t\t\tresponse.status(HttpCodes.BadRequest).json({ error: `Cannot parse ${type} data.` });\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"sources":["../../../src/middlewares/body.ts"],"names":[],"mappings":";;;;AAGO,IAAM,iBAAA,GAAN,MAAM,iBAAA,SAAyB,UAAW,CAAA;AAAA,EACzC,YAAY,OAAmC,EAAA;AACrD,IAAA,KAAA,CAAM,OAAS,EAAA,EAAE,QAAU,EAAA,EAAA,EAAI,CAAA,CAAA;AAAA,GAChC;AAAA,EAEgB,GAAA,CAAI,SAA6B,QAA+B,EAAA;AAC/E,IAAI,IAAA,CAAC,QAAQ,KAAO,EAAA,OAAA;AAGpB,IAAM,MAAA,WAAA,GAAc,OAAQ,CAAA,OAAA,CAAQ,cAAc,CAAA,CAAA;AAClD,IAAI,IAAA,OAAO,gBAAgB,QAAU,EAAA,OAAA;AAGrC,IAAM,MAAA,YAAA,GAAe,OAAQ,CAAA,OAAA,CAAQ,gBAAgB,CAAA,CAAA;AACrD,IAAI,IAAA,OAAO,iBAAiB,QAAU,EAAA,OAAA;AAGtC,IAAM,MAAA,MAAA,GAAS,OAAO,YAAY,CAAA,CAAA;AAClC,IAAM,MAAA,aAAA,GAAgB,QAAQ,KAAM,CAAA,iBAAA,CAAA;AACpC,IAAA,IAAI,SAAS,aAAe,EAAA;AAC3B,MAAS,QAAA,CAAA,MAAA,CAAO,UAAU,eAAe,CAAA,CAAE,KAAK,EAAE,KAAA,EAAO,oCAAoC,CAAA,CAAA;AAAA,KAC9F;AAAA,GACD;AACD,CAAA,CAAA;AAvBiD,MAAA,CAAA,iBAAA,EAAA,kBAAA,CAAA,CAAA;AAA1C,IAAM,gBAAN,GAAA","file":"body.mjs","sourcesContent":["import { HttpCodes } from '../lib/structures/http/HttpCodes';\nimport { Middleware } from '../lib/structures/Middleware';\n\nexport class PluginMiddleware extends Middleware {\n\tpublic constructor(context: Middleware.LoaderContext) {\n\t\tsuper(context, { position: 20 });\n\t}\n\n\tpublic override run(request: Middleware.Request, response: Middleware.Response) {\n\t\tif (!request.route) return;\n\n\t\t// RFC 1341 4.\n\t\tconst contentType = request.headers['content-type'];\n\t\tif (typeof contentType !== 'string') return;\n\n\t\t// RFC 7230 3.3.2.\n\t\tconst lengthString = request.headers['content-length'];\n\t\tif (typeof lengthString !== 'string') return;\n\n\t\t// Verify if the content length is lower than accepted:\n\t\tconst length = Number(lengthString);\n\t\tconst maximumLength = request.route.maximumBodyLength;\n\t\tif (length > maximumLength) {\n\t\t\tresponse.status(HttpCodes.PayloadTooLarge).json({ error: 'Exceeded maximum content length.' });\n\t\t}\n\t}\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { __name, __publicField } from '../chunk-JTFKMR4I.mjs';
1
+ import { __name, __publicField } from '../chunk-S573YWRP.mjs';
2
2
  import { Middleware } from '../lib/structures/Middleware.mjs';
3
3
  import { CookieStore } from '../lib/structures/api/CookieStore.mjs';
4
4
 
@@ -18,5 +18,5 @@ __name(_PluginMiddleware, "PluginMiddleware");
18
18
  var PluginMiddleware = _PluginMiddleware;
19
19
 
20
20
  export { PluginMiddleware };
21
- //# sourceMappingURL=out.js.map
21
+ //# sourceMappingURL=cookies.mjs.map
22
22
  //# sourceMappingURL=cookies.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/middlewares/cookies.ts"],"names":[],"mappings":";;;;;;AAAA,SAAS,kBAAkB;AAG3B,SAAS,mBAAmB;AAErB,IAAM,oBAAN,MAAM,0BAAyB,WAAW;AAAA,EAIzC,YAAY,SAAmC;AACrD,UAAM,SAAS,EAAE,UAAU,GAAG,CAAC;AAJhC,wBAAiB,cAAsB,QAAQ,IAAI,aAAa;AAChE,wBAAQ,mBAAiC;AAKxC,UAAM,EAAE,OAAO,IAAI,KAAK;AACxB,SAAK,kBAAkB,OAAO,MAAM,mBAAmB;AAAA,EACxD;AAAA,EAEgB,IAAI,SAAqB,UAAuB;AAC/D,aAAS,UAAU,IAAI,YAAY,SAAS,UAAU,KAAK,YAAY,KAAK,eAAe;AAAA,EAC5F;AACD;AAdiD;AAA1C,IAAM,mBAAN","sourcesContent":["import { Middleware } from '../lib/structures/Middleware';\nimport type { ApiRequest } from '../lib/structures/api/ApiRequest';\nimport type { ApiResponse } from '../lib/structures/api/ApiResponse';\nimport { CookieStore } from '../lib/structures/api/CookieStore';\n\nexport class PluginMiddleware extends Middleware {\n\tprivate readonly production: boolean = process.env.NODE_ENV === 'production';\n\tprivate domainOverwrite: string | null = null;\n\n\tpublic constructor(context: Middleware.LoaderContext) {\n\t\tsuper(context, { position: 30 });\n\n\t\tconst { server } = this.container;\n\t\tthis.domainOverwrite = server.auth?.domainOverwrite ?? null;\n\t}\n\n\tpublic override run(request: ApiRequest, response: ApiResponse) {\n\t\tresponse.cookies = new CookieStore(request, response, this.production, this.domainOverwrite);\n\t}\n}\n"]}
1
+ {"version":3,"sources":["../../../src/middlewares/cookies.ts"],"names":[],"mappings":";;;;AAGO,IAAM,iBAAA,GAAN,MAAM,iBAAA,SAAyB,UAAW,CAAA;AAAA,EAIzC,YAAY,OAAmC,EAAA;AACrD,IAAA,KAAA,CAAM,OAAS,EAAA,EAAE,QAAU,EAAA,EAAA,EAAI,CAAA,CAAA;AAJhC,IAAiB,aAAA,CAAA,IAAA,EAAA,YAAA,EAAsB,OAAQ,CAAA,GAAA,CAAI,QAAa,KAAA,YAAA,CAAA,CAAA;AAChE,IAAA,aAAA,CAAA,IAAA,EAAQ,iBAAiC,EAAA,IAAA,CAAA,CAAA;AAKxC,IAAM,MAAA,EAAE,MAAO,EAAA,GAAI,IAAK,CAAA,SAAA,CAAA;AACxB,IAAK,IAAA,CAAA,eAAA,GAAkB,MAAO,CAAA,IAAA,EAAM,eAAmB,IAAA,IAAA,CAAA;AAAA,GACxD;AAAA,EAEgB,GAAA,CAAI,SAA6B,QAA+B,EAAA;AAC/E,IAAS,QAAA,CAAA,OAAA,GAAU,IAAI,WAAY,CAAA,OAAA,EAAS,UAAU,IAAK,CAAA,UAAA,EAAY,KAAK,eAAe,CAAA,CAAA;AAAA,GAC5F;AACD,CAAA,CAAA;AAdiD,MAAA,CAAA,iBAAA,EAAA,kBAAA,CAAA,CAAA;AAA1C,IAAM,gBAAN,GAAA","file":"cookies.mjs","sourcesContent":["import { Middleware } from '../lib/structures/Middleware';\nimport { CookieStore } from '../lib/structures/api/CookieStore';\n\nexport class PluginMiddleware extends Middleware {\n\tprivate readonly production: boolean = process.env.NODE_ENV === 'production';\n\tprivate domainOverwrite: string | null = null;\n\n\tpublic constructor(context: Middleware.LoaderContext) {\n\t\tsuper(context, { position: 30 });\n\n\t\tconst { server } = this.container;\n\t\tthis.domainOverwrite = server.auth?.domainOverwrite ?? null;\n\t}\n\n\tpublic override run(request: Middleware.Request, response: Middleware.Response) {\n\t\tresponse.cookies = new CookieStore(request, response, this.production, this.domainOverwrite);\n\t}\n}\n"]}
@@ -1,5 +1,4 @@
1
- import { __name, __publicField } from '../chunk-JTFKMR4I.mjs';
2
- import { METHODS } from 'node:http';
1
+ import { __name, __publicField } from '../chunk-S573YWRP.mjs';
3
2
  import { Middleware } from '../lib/structures/Middleware.mjs';
4
3
  import { HttpCodes } from '../lib/structures/http/HttpCodes.mjs';
5
4
 
@@ -7,16 +6,25 @@ var _PluginMiddleware = class _PluginMiddleware extends Middleware {
7
6
  constructor(context) {
8
7
  super(context, { position: 10 });
9
8
  __publicField(this, "origin");
10
- __publicField(this, "methods", METHODS.join(", "));
9
+ __publicField(this, "routes");
11
10
  this.origin = this.container.server.options.origin ?? "*";
11
+ this.routes = this.container.stores.get("routes");
12
12
  }
13
- run(request, response, route) {
13
+ run(request, response) {
14
14
  response.setHeader("Date", (/* @__PURE__ */ new Date()).toUTCString());
15
15
  response.setHeader("Access-Control-Allow-Credentials", "true");
16
16
  response.setHeader("Access-Control-Allow-Origin", this.origin);
17
17
  response.setHeader("Access-Control-Allow-Headers", "Authorization, User-Agent, Content-Type");
18
- response.setHeader("Access-Control-Allow-Methods", this.methods);
19
- this.ensurePotentialEarlyExit(request, response, route);
18
+ response.setHeader("Access-Control-Allow-Methods", this.getMethods(request.route ?? null));
19
+ this.ensurePotentialEarlyExit(request, response);
20
+ }
21
+ getMethods(route) {
22
+ if (route === null) {
23
+ return this.routes.router.supportedMethods.join(", ");
24
+ }
25
+ if (route.methods.size === 0) return "";
26
+ if (route.methods.size === 1) return route.methods.keys().next().value;
27
+ return [...route.methods].join(", ");
20
28
  }
21
29
  /**
22
30
  * **RFC 7231 4.3.7.**
@@ -33,13 +41,15 @@ var _PluginMiddleware = class _PluginMiddleware extends Middleware {
33
41
  * @param response The API response that will go out
34
42
  * @param route The route being requested by the request
35
43
  */
36
- ensurePotentialEarlyExit(request, response, route) {
37
- if (request.method === "OPTIONS") {
44
+ ensurePotentialEarlyExit({ method, route, routerNode }, response) {
45
+ if (method === "OPTIONS") {
38
46
  if (!route || !route.methods.has("OPTIONS")) {
39
47
  response.end();
40
48
  }
41
- } else if (route === null) {
49
+ } else if (routerNode === null) {
42
50
  response.status(HttpCodes.NotFound).end();
51
+ } else if (route === null) {
52
+ response.status(HttpCodes.MethodNotAllowed).end();
43
53
  }
44
54
  }
45
55
  };
@@ -47,5 +57,5 @@ __name(_PluginMiddleware, "PluginMiddleware");
47
57
  var PluginMiddleware = _PluginMiddleware;
48
58
 
49
59
  export { PluginMiddleware };
50
- //# sourceMappingURL=out.js.map
60
+ //# sourceMappingURL=headers.mjs.map
51
61
  //# sourceMappingURL=headers.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/middlewares/headers.ts"],"names":[],"mappings":";;;;;;AAAA,SAAS,eAAe;AACxB,SAAS,kBAAkB;AAI3B,SAAS,iBAAiB;AAEnB,IAAM,oBAAN,MAAM,0BAAyB,WAAW;AAAA,EAIzC,YAAY,SAAmC;AACrD,UAAM,SAAS,EAAE,UAAU,GAAG,CAAC;AAJhC,wBAAiB;AACjB,wBAAiB,WAAkB,QAAQ,KAAK,IAAI;AAInD,SAAK,SAAS,KAAK,UAAU,OAAO,QAAQ,UAAU;AAAA,EACvD;AAAA,EAEgB,IAAI,SAAqB,UAAuB,OAAqB;AACpF,aAAS,UAAU,SAAQ,oBAAI,KAAK,GAAE,YAAY,CAAC;AACnD,aAAS,UAAU,oCAAoC,MAAM;AAC7D,aAAS,UAAU,+BAA+B,KAAK,MAAM;AAC7D,aAAS,UAAU,gCAAgC,yCAAyC;AAC5F,aAAS,UAAU,gCAAgC,KAAK,OAAO;AAE/D,SAAK,yBAAyB,SAAS,UAAU,KAAK;AAAA,EACvD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAiBQ,yBAAyB,SAAqB,UAAuB,OAAqB;AACjG,QAAI,QAAQ,WAAW,WAAW;AACjC,UAAI,CAAC,SAAS,CAAC,MAAM,QAAQ,IAAI,SAAS,GAAG;AAC5C,iBAAS,IAAI;AAAA,MACd;AAAA,IACD,WAAW,UAAU,MAAM;AAC1B,eAAS,OAAO,UAAU,QAAQ,EAAE,IAAI;AAAA,IACzC;AAAA,EACD;AACD;AA3CiD;AAA1C,IAAM,mBAAN","sourcesContent":["import { METHODS } from 'node:http';\nimport { Middleware } from '../lib/structures/Middleware';\nimport type { Route } from '../lib/structures/Route';\nimport type { ApiRequest } from '../lib/structures/api/ApiRequest';\nimport type { ApiResponse } from '../lib/structures/api/ApiResponse';\nimport { HttpCodes } from '../lib/structures/http/HttpCodes';\n\nexport class PluginMiddleware extends Middleware {\n\tprivate readonly origin: string;\n\tprivate readonly methods: string = METHODS.join(', ');\n\n\tpublic constructor(context: Middleware.LoaderContext) {\n\t\tsuper(context, { position: 10 });\n\t\tthis.origin = this.container.server.options.origin ?? '*';\n\t}\n\n\tpublic override run(request: ApiRequest, response: ApiResponse, route: Route | null) {\n\t\tresponse.setHeader('Date', new Date().toUTCString());\n\t\tresponse.setHeader('Access-Control-Allow-Credentials', 'true');\n\t\tresponse.setHeader('Access-Control-Allow-Origin', this.origin);\n\t\tresponse.setHeader('Access-Control-Allow-Headers', 'Authorization, User-Agent, Content-Type');\n\t\tresponse.setHeader('Access-Control-Allow-Methods', this.methods);\n\n\t\tthis.ensurePotentialEarlyExit(request, response, route);\n\t}\n\n\t/**\n\t * **RFC 7231 4.3.7.**\n\t * > This method allows a client to determine the options and/or requirements associated with a\n\t * > resource, or the capabilities of a server, without implying a resource action.\n\t *\n\t * This method ensures that the request is exited early in case required\n\t * The conditions in which an early exit is required are:\n\t * 1. If the request method is 'OPTIONS'. In this case the request is returned with status code 200\n\t * 2. If the requested route isn't matched with any existing route in the RouteStore.\n\t * In this case the request is returned with a status code 404.\n\t *\n\t * @param request The API Request coming in\n\t * @param response The API response that will go out\n\t * @param route The route being requested by the request\n\t */\n\tprivate ensurePotentialEarlyExit(request: ApiRequest, response: ApiResponse, route: Route | null) {\n\t\tif (request.method === 'OPTIONS') {\n\t\t\tif (!route || !route.methods.has('OPTIONS')) {\n\t\t\t\tresponse.end();\n\t\t\t}\n\t\t} else if (route === null) {\n\t\t\tresponse.status(HttpCodes.NotFound).end();\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"sources":["../../../src/middlewares/headers.ts"],"names":[],"mappings":";;;;AAKO,IAAM,iBAAA,GAAN,MAAM,iBAAA,SAAyB,UAAW,CAAA;AAAA,EAIzC,YAAY,OAAmC,EAAA;AACrD,IAAA,KAAA,CAAM,OAAS,EAAA,EAAE,QAAU,EAAA,EAAA,EAAI,CAAA,CAAA;AAJhC,IAAiB,aAAA,CAAA,IAAA,EAAA,QAAA,CAAA,CAAA;AACjB,IAAiB,aAAA,CAAA,IAAA,EAAA,QAAA,CAAA,CAAA;AAIhB,IAAA,IAAA,CAAK,MAAS,GAAA,IAAA,CAAK,SAAU,CAAA,MAAA,CAAO,QAAQ,MAAU,IAAA,GAAA,CAAA;AACtD,IAAA,IAAA,CAAK,MAAS,GAAA,IAAA,CAAK,SAAU,CAAA,MAAA,CAAO,IAAI,QAAQ,CAAA,CAAA;AAAA,GACjD;AAAA,EAEgB,GAAA,CAAI,SAA6B,QAA+B,EAAA;AAC/E,IAAA,QAAA,CAAS,UAAU,MAAQ,EAAA,iBAAA,IAAI,IAAK,EAAA,EAAE,aAAa,CAAA,CAAA;AACnD,IAAS,QAAA,CAAA,SAAA,CAAU,oCAAoC,MAAM,CAAA,CAAA;AAC7D,IAAS,QAAA,CAAA,SAAA,CAAU,6BAA+B,EAAA,IAAA,CAAK,MAAM,CAAA,CAAA;AAC7D,IAAS,QAAA,CAAA,SAAA,CAAU,gCAAgC,yCAAyC,CAAA,CAAA;AAC5F,IAAA,QAAA,CAAS,UAAU,8BAAgC,EAAA,IAAA,CAAK,WAAW,OAAQ,CA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D;AAAA,GACD;AACD,CAAA,CAAA;AAxDiD,MAAA,CAAA,iBAAA,EAAA,kBAAA,CAAA,CAAA;AAA1C,IAAM,gBAAN,GAAA","file":"headers.mjs","sourcesContent":["import { Middleware } from '../lib/structures/Middleware';\nimport type { Route } from '../lib/structures/Route';\nimport type { RouteStore } from '../lib/structures/RouteStore';\nimport { HttpCodes } from '../lib/structures/http/HttpCodes';\n\nexport class PluginMiddleware extends Middleware {\n\tprivate readonly origin: string;\n\tprivate readonly routes: RouteStore;\n\n\tpublic constructor(context: Middleware.LoaderContext) {\n\t\tsuper(context, { position: 10 });\n\t\tthis.origin = this.container.server.options.origin ?? '*';\n\t\tthis.routes = this.container.stores.get('routes');\n\t}\n\n\tpublic override run(request: Middleware.Request, response: Middleware.Response) {\n\t\tresponse.setHeader('Date', new Date().toUTCString());\n\t\tresponse.setHeader('Access-Control-Allow-Credentials', 'true');\n\t\tresponse.setHeader('Access-Control-Allow-Origin', this.origin);\n\t\tresponse.setHeader('Access-Control-Allow-Headers', 'Authorization, User-Agent, Content-Type');\n\t\tresponse.setHeader('Access-Control-Allow-Methods', this.getMethods(request.route ?? null));\n\n\t\tthis.ensurePotentialEarlyExit(request, response);\n\t}\n\n\tprivate getMethods(route: Route | null) {\n\t\tif (route === null) {\n\t\t\treturn this.routes.router.supportedMethods.join(', ');\n\t\t}\n\n\t\tif (route.methods.size === 0) return '';\n\t\tif (route.methods.size === 1) return route.methods.keys().next().value;\n\t\treturn [...route.methods].join(', ');\n\t}\n\n\t/**\n\t * **RFC 7231 4.3.7.**\n\t * > This method allows a client to determine the options and/or requirements associated with a\n\t * > resource, or the capabilities of a server, without implying a resource action.\n\t *\n\t * This method ensures that the request is exited early in case required\n\t * The conditions in which an early exit is required are:\n\t * 1. If the request method is 'OPTIONS'. In this case the request is returned with status code 200\n\t * 2. If the requested route isn't matched with any existing route in the RouteStore.\n\t * In this case the request is returned with a status code 404.\n\t *\n\t * @param request The API Request coming in\n\t * @param response The API response that will go out\n\t * @param route The route being requested by the request\n\t */\n\tprivate ensurePotentialEarlyExit({ method, route, routerNode }: Middleware.Request, response: Middleware.Response) {\n\t\tif (method === 'OPTIONS') {\n\t\t\tif (!route || !route.methods.has('OPTIONS')) {\n\t\t\t\tresponse.end();\n\t\t\t}\n\t\t} else if (routerNode === null) {\n\t\t\tresponse.status(HttpCodes.NotFound).end();\n\t\t} else if (route === null) {\n\t\t\tresponse.status(HttpCodes.MethodNotAllowed).end();\n\t\t}\n\t}\n}\n"]}
@@ -1,4 +1,3 @@
1
- import './index.mjs';
2
1
  import { Plugin, postInitialization, SapphireClient, preLogin } from '@sapphire/framework';
3
2
  import { ClientOptions } from 'discord.js';
4
3
 
@@ -1,6 +1,6 @@
1
- import { __name } from './chunk-JTFKMR4I.mjs';
2
- import { Server, loadListeners, loadMediaParsers, loadMiddlewares, loadRoutes } from './index.mjs';
1
+ import { __name } from './chunk-S573YWRP.mjs';
3
2
  import { SapphireClient, postInitialization, preLogin, Plugin } from '@sapphire/framework';
3
+ import { Server, loadListeners, loadMiddlewares, loadRoutes } from './index.mjs';
4
4
 
5
5
  var _Api = class _Api extends Plugin {
6
6
  /**
@@ -8,9 +8,8 @@ var _Api = class _Api extends Plugin {
8
8
  */
9
9
  static [postInitialization](options) {
10
10
  this.server = new Server(options.api);
11
- this.stores.register(this.server.routes).register(this.server.mediaParsers).register(this.server.middlewares);
11
+ this.stores.register(this.server.routes).register(this.server.middlewares);
12
12
  loadListeners();
13
- loadMediaParsers();
14
13
  loadMiddlewares();
15
14
  loadRoutes();
16
15
  }
@@ -30,5 +29,5 @@ SapphireClient.plugins.registerPostInitializationHook(Api[postInitialization], "
30
29
  SapphireClient.plugins.registerPreLoginHook(Api[preLogin], "API-PreLogin");
31
30
 
32
31
  export { Api };
33
- //# sourceMappingURL=out.js.map
32
+ //# sourceMappingURL=register.mjs.map
34
33
  //# sourceMappingURL=register.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/register.ts"],"names":[],"mappings":";;;;;AAAA,OAAO;AAEP,SAAS,QAAQ,oBAAoB,UAAU,sBAAsB;AAErE,SAAS,eAAe,kBAAkB,iBAAiB,YAAY,cAAc;AAK9E,IAAM,OAAN,MAAM,aAAY,OAAO;AAAA;AAAA;AAAA;AAAA,EAI/B,QAAe,kBAAkB,EAAwB,SAA8B;AACtF,SAAK,SAAS,IAAI,OAAO,QAAQ,GAAG;AACpC,SAAK,OACH,SAAS,KAAK,OAAO,MAAM,EAC3B,SAAS,KAAK,OAAO,YAAY,EACjC,SAAS,KAAK,OAAO,WAAW;AAElC,kBAAc;AACd,qBAAiB;AACjB,oBAAgB;AAChB,eAAW;AAAA,EACZ;AAAA;AAAA;AAAA;AAAA,EAKA,cAAqB,QAAQ,IAAuC;AACnE,QAAI,EAAE,KAAK,OAAO,QAAQ,wBAAwB,OAAO;AACxD;AAAA,IACD;AAEA,UAAM,KAAK,OAAO,QAAQ;AAAA,EAC3B;AACD;AA3BgC;AAAzB,IAAM,MAAN;AA6BP,eAAe,QAAQ,+BAA+B,IAAI,kBAAkB,GAAG,wBAAwB;AACvG,eAAe,QAAQ,qBAAqB,IAAI,QAAQ,GAAG,cAAc","sourcesContent":["import './index';\n\nimport { Plugin, postInitialization, preLogin, SapphireClient } from '@sapphire/framework';\nimport type { ClientOptions } from 'discord.js';\nimport { loadListeners, loadMediaParsers, loadMiddlewares, loadRoutes, Server } from './index';\n\n/**\n * @since 1.0.0\n */\nexport class Api extends Plugin {\n\t/**\n\t * @since 1.0.0\n\t */\n\tpublic static [postInitialization](this: SapphireClient, options: ClientOptions): void {\n\t\tthis.server = new Server(options.api);\n\t\tthis.stores\n\t\t\t.register(this.server.routes) //\n\t\t\t.register(this.server.mediaParsers)\n\t\t\t.register(this.server.middlewares);\n\n\t\tloadListeners();\n\t\tloadMediaParsers();\n\t\tloadMiddlewares();\n\t\tloadRoutes();\n\t}\n\n\t/**\n\t * @since 1.0.0\n\t */\n\tpublic static async [preLogin](this: SapphireClient): Promise<void> {\n\t\tif (!(this.server.options.automaticallyConnect ?? true)) {\n\t\t\treturn;\n\t\t}\n\n\t\tawait this.server.connect();\n\t}\n}\n\nSapphireClient.plugins.registerPostInitializationHook(Api[postInitialization], 'API-PostInitialization');\nSapphireClient.plugins.registerPreLoginHook(Api[preLogin], 'API-PreLogin');\n"]}
1
+ {"version":3,"sources":["../../src/register.ts"],"names":[],"mappings":";;;;AAOO,IAAM,IAAA,GAAN,MAAM,IAAA,SAAY,MAAO,CAAA;AAAA;AAAA;AAAA;AAAA,EAI/B,QAAe,kBAAkB,CAAA,CAAwB,OAA8B,EAAA;AACtF,IAAA,IAAA,CAAK,MAAS,GAAA,IAAI,MAAO,CAAA,OAAA,CAAQ,GAAG,CAAA,CAAA;AACpC,IAAK,IAAA,CAAA,MAAA,CACH,SAAS,IAAK,CAAA,MAAA,CAAO,MAAM,CAC3B,CAAA,QAAA,CAAS,IAAK,CAAA,MAAA,CAAO,WAAW,CAAA,CAAA;AAElC,IAAc,aAAA,EAAA,CAAA;AACd,IAAgB,eAAA,EAAA,CAAA;AAChB,IAAW,UAAA,EAAA,CAAA;AAAA,GACZ;AAAA;AAAA;AAAA;AAAA,EAKA,cAAqB,QAAQ,CAAuC,GAAA;AACnE,IAAA,IAAI,EAAE,IAAA,CAAK,MAAO,CAAA,OAAA,CAAQ,wBAAwB,IAAO,CAAA,EAAA;AACxD,MAAA,OAAA;AAAA,KACD;AAEA,IAAM,MAAA,IAAA,CAAK,OAAO,OAAQ,EAAA,CAAA;AAAA,GAC3B;AACD,CAAA,CAAA;AAzBgC,MAAA,CAAA,IAAA,EAAA,KAAA,CAAA,CAAA;AAAzB,IAAM,GAAN,GAAA,KAAA;AA2BP,cAAA,CAAe,OAAQ,CAAA,8BAAA,CAA+B,GAAI,CAAA,kBAAkB,GAAG,wBAAwB,CAAA,CAAA;AACvG,cAAA,CAAe,OAAQ,CAAA,oBAAA,CAAqB,GAAI,CAAA,QAAQ,GAAG,cAAc,CAAA","file":"register.mjs","sourcesContent":["import { Plugin, postInitialization, preLogin, SapphireClient } from '@sapphire/framework';\nimport type { ClientOptions } from 'discord.js';\nimport { loadListeners, loadMiddlewares, loadRoutes, Server } from './index';\n\n/**\n * @since 1.0.0\n */\nexport class Api extends Plugin {\n\t/**\n\t * @since 1.0.0\n\t */\n\tpublic static [postInitialization](this: SapphireClient, options: ClientOptions): void {\n\t\tthis.server = new Server(options.api);\n\t\tthis.stores\n\t\t\t.register(this.server.routes) //\n\t\t\t.register(this.server.middlewares);\n\n\t\tloadListeners();\n\t\tloadMiddlewares();\n\t\tloadRoutes();\n\t}\n\n\t/**\n\t * @since 1.0.0\n\t */\n\tpublic static async [preLogin](this: SapphireClient): Promise<void> {\n\t\tif (!(this.server.options.automaticallyConnect ?? true)) {\n\t\t\treturn;\n\t\t}\n\n\t\tawait this.server.connect();\n\t}\n}\n\nSapphireClient.plugins.registerPostInitializationHook(Api[postInitialization], 'API-PostInitialization');\nSapphireClient.plugins.registerPreLoginHook(Api[preLogin], 'API-PreLogin');\n"]}
@@ -1,7 +1,7 @@
1
- import { __name } from '../chunk-JTFKMR4I.mjs';
1
+ import { __name } from '../chunk-S573YWRP.mjs';
2
2
  import { container } from '@sapphire/pieces';
3
- import { PluginRoute } from './oauth/callback.mjs';
4
- import { PluginRoute as PluginRoute$1 } from './oauth/logout.mjs';
3
+ import { PluginRoute } from './oauth/callback.post.mjs';
4
+ import { PluginRoute as PluginRoute$1 } from './oauth/logout.post.mjs';
5
5
 
6
6
  function loadRoutes() {
7
7
  const store = "routes";
@@ -11,5 +11,5 @@ function loadRoutes() {
11
11
  __name(loadRoutes, "loadRoutes");
12
12
 
13
13
  export { loadRoutes };
14
- //# sourceMappingURL=out.js.map
14
+ //# sourceMappingURL=_load.mjs.map
15
15
  //# sourceMappingURL=_load.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/routes/_load.ts"],"names":[],"mappings":";;;;;AAAA,SAAS,iBAAiB;AAC1B,SAAS,eAAe,2BAA2B;AACnD,SAAS,eAAe,yBAAyB;AAE1C,SAAS,aAAa;AAC5B,QAAM,QAAQ;AACd,OAAK,UAAU,OAAO,UAAU,EAAE,MAAM,YAAY,OAAO,qBAAqB,MAAM,CAAC;AACvF,OAAK,UAAU,OAAO,UAAU,EAAE,MAAM,UAAU,OAAO,mBAAmB,MAAM,CAAC;AACpF;AAJgB","sourcesContent":["import { container } from '@sapphire/pieces';\nimport { PluginRoute as PluginOAuthCallback } from './oauth/callback';\nimport { PluginRoute as PluginOAuthLogout } from './oauth/logout';\n\nexport function loadRoutes() {\n\tconst store = 'routes' as const;\n\tvoid container.stores.loadPiece({ name: 'callback', piece: PluginOAuthCallback, store });\n\tvoid container.stores.loadPiece({ name: 'logout', piece: PluginOAuthLogout, store });\n}\n"]}
1
+ {"version":3,"sources":["../../../src/routes/_load.ts"],"names":["PluginOAuthCallback","PluginOAuthLogout"],"mappings":";;;;;AAIO,SAAS,UAAa,GAAA;AAC5B,EAAA,MAAM,KAAQ,GAAA,QAAA,CAAA;AACd,EAAK,KAAA,SAAA,CAAU,OAAO,SAAU,CAAA,EAAE,MAAM,UAAY,EAAA,KAAA,EAAOA,WAAqB,EAAA,KAAA,EAAO,CAAA,CAAA;AACvF,EAAK,KAAA,SAAA,CAAU,OAAO,SAAU,CAAA,EAAE,MAAM,QAAU,EAAA,KAAA,EAAOC,aAAmB,EAAA,KAAA,EAAO,CAAA,CAAA;AACpF,CAAA;AAJgB,MAAA,CAAA,UAAA,EAAA,YAAA,CAAA","file":"_load.mjs","sourcesContent":["import { container } from '@sapphire/pieces';\nimport { PluginRoute as PluginOAuthCallback } from './oauth/callback.post';\nimport { PluginRoute as PluginOAuthLogout } from './oauth/logout.post';\n\nexport function loadRoutes() {\n\tconst store = 'routes';\n\tvoid container.stores.loadPiece({ name: 'callback', piece: PluginOAuthCallback, store });\n\tvoid container.stores.loadPiece({ name: 'logout', piece: PluginOAuthLogout, store });\n}\n"]}
@@ -1,21 +1,20 @@
1
- import { __publicField, __name } from '../../chunk-JTFKMR4I.mjs';
1
+ import { __name, __publicField } from '../../chunk-S573YWRP.mjs';
2
2
  import { OAuth2Routes } from 'discord.js';
3
3
  import { stringify } from 'querystring';
4
4
  import { fetch } from 'undici';
5
5
  import { Route } from '../../lib/structures/Route.mjs';
6
6
  import { HttpCodes } from '../../lib/structures/http/HttpCodes.mjs';
7
- import { methods } from '../../lib/structures/http/HttpMethods.mjs';
8
7
 
9
8
  var _PluginRoute = class _PluginRoute extends Route {
10
9
  constructor(context) {
11
- super(context, { route: "oauth/callback" });
10
+ super(context, { route: "oauth/callback", methods: ["POST"] });
12
11
  __publicField(this, "redirectUri");
13
12
  const { server } = this.container;
14
13
  this.enabled = server.auth !== null;
15
14
  this.redirectUri = server.auth?.redirect;
16
15
  }
17
- async [methods.POST](request, response) {
18
- const body = request.body;
16
+ async run(request, response) {
17
+ const body = await request.readBodyJson();
19
18
  if (typeof body?.code !== "string") {
20
19
  return response.badRequest();
21
20
  }
@@ -66,5 +65,5 @@ __name(_PluginRoute, "PluginRoute");
66
65
  var PluginRoute = _PluginRoute;
67
66
 
68
67
  export { PluginRoute };
69
- //# sourceMappingURL=out.js.map
70
- //# sourceMappingURL=callback.mjs.map
68
+ //# sourceMappingURL=callback.post.mjs.map
69
+ //# sourceMappingURL=callback.post.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/routes/oauth/callback.post.ts"],"names":[],"mappings":";;;;;;;AAMO,IAAM,YAAA,GAAN,MAAM,YAAA,SAAoB,KAAM,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,CAA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AccessTokenResult, 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 = (await request.readBodyJson()) 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,19 +1,17 @@
1
- import { __name } from '../../chunk-JTFKMR4I.mjs';
1
+ import { __name } from '../../chunk-S573YWRP.mjs';
2
+ import { sleep } from '@sapphire/utilities';
2
3
  import { OAuth2Routes } from 'discord.js';
3
4
  import { stringify } from 'querystring';
4
5
  import { fetch } from 'undici';
5
- import { promisify } from 'util';
6
6
  import { Route } from '../../lib/structures/Route.mjs';
7
7
  import { HttpCodes } from '../../lib/structures/http/HttpCodes.mjs';
8
- import { methods } from '../../lib/structures/http/HttpMethods.mjs';
9
8
 
10
- var sleep = promisify(setTimeout);
11
9
  var _PluginRoute = class _PluginRoute extends Route {
12
10
  constructor(context) {
13
- super(context, { route: "oauth/logout" });
11
+ super(context, { route: "oauth/logout", methods: ["POST"] });
14
12
  this.enabled = this.container.server.auth !== null;
15
13
  }
16
- async [methods.POST](request, response) {
14
+ async run(request, response) {
17
15
  if (!request.auth) return response.status(HttpCodes.Unauthorized).json({ error: "Unauthorized." });
18
16
  const result = await this.revoke(request.auth.token);
19
17
  if (result.ok) return this.success(response);
@@ -56,5 +54,5 @@ __name(_PluginRoute, "PluginRoute");
56
54
  var PluginRoute = _PluginRoute;
57
55
 
58
56
  export { PluginRoute };
59
- //# sourceMappingURL=out.js.map
60
- //# sourceMappingURL=logout.mjs.map
57
+ //# sourceMappingURL=logout.post.mjs.map
58
+ //# sourceMappingURL=logout.post.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/routes/oauth/logout.post.ts"],"names":["result"],"mappings":";;;;;;;;AAOO,IAAM,YAAA,GAAN,MAAM,YAAA,SAAoB,KAAM,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,CAAO,SAAU,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,KAAA,SAAA,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,MAAM,MAAM,UAAU,CAAA,CAAA;AAEtB,QAAA,MAAMA,UAAS,M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AA,aAAA,CAAA,CAAA;AAAhC,IAAM,WAAN,GAAA","file":"logout.post.mjs","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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sapphire/plugin-api",
3
- "version": "7.0.0-next.d27dc1c",
3
+ "version": "7.0.0-next.d2c9aaa",
4
4
  "description": "Plugin for @sapphire/framework to expose a REST API",
5
5
  "author": "@sapphire",
6
6
  "license": "MIT",
@@ -43,6 +43,7 @@
43
43
  "build:types:esm": "rollup-type-bundler -d dist/esm -t .mts",
44
44
  "build:types:cleanup": "tsx ../../scripts/clean-register-imports.mts",
45
45
  "build:rename-cjs-register": "tsx ../../scripts/rename-cjs-register.mts",
46
+ "sync-mime-types": "tsx scripts/sync-mime-types.mts",
46
47
  "typecheck": "tsc -b src",
47
48
  "docs": "typedoc-json-parser",
48
49
  "prepack": "yarn build",
@@ -50,9 +51,11 @@
50
51
  "check-update": "cliff-jumper --dry-run"
51
52
  },
52
53
  "dependencies": {
53
- "@types/ws": "^8.5.10",
54
- "tldts": "^6.1.29",
55
- "undici": "^6.19.2"
54
+ "@types/ws": "^8.5.12",
55
+ "@vladfrangu/async_event_emitter": "2.4.6",
56
+ "cookie-es": "^1.2.2",
57
+ "tldts": "^6.1.56",
58
+ "undici": "^6.20.1"
56
59
  },
57
60
  "repository": {
58
61
  "type": "git",
@@ -83,11 +86,11 @@
83
86
  "access": "public"
84
87
  },
85
88
  "devDependencies": {
86
- "@favware/cliff-jumper": "^4.0.2",
89
+ "@favware/cliff-jumper": "^5.0.0",
87
90
  "@favware/rollup-type-bundler": "^3.3.0",
88
- "concurrently": "^8.2.2",
89
- "tsup": "^8.1.0",
90
- "tsx": "^4.15.7",
91
+ "concurrently": "^9.0.1",
92
+ "tsup": "^8.3.5",
93
+ "tsx": "^4.19.2",
91
94
  "typedoc": "^0.25.13",
92
95
  "typedoc-json-parser": "^10.0.0",
93
96
  "typescript": "~5.4.5"
@@ -1,79 +0,0 @@
1
- 'use strict';
2
-
3
- var pieces = require('@sapphire/pieces');
4
- var zlib = require('zlib');
5
-
6
- var __defProp = Object.defineProperty;
7
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
- var _MediaParser = class _MediaParser extends pieces.Piece {
9
- constructor(context, options = {}) {
10
- super(context, options);
11
- }
12
- /**
13
- * Checks if a route accepts the media type from this parser.
14
- * @since 1.3.0
15
- * @param route The route to be checked.
16
- */
17
- accepts(route) {
18
- return route.acceptedContentMimeTypes === null || route.acceptedContentMimeTypes.includes(this.name);
19
- }
20
- /**
21
- * Reads the content body as a string, this is useful for parsing/reading plain-text data.
22
- * @since 1.3.0
23
- * @param request The request to read the body from.
24
- */
25
- async readString(request) {
26
- const stream = this.contentStream(request);
27
- if (stream === null) return "";
28
- let body = "";
29
- for await (const chunk of stream) body += chunk;
30
- return body;
31
- }
32
- /**
33
- * Reads the content body as a buffer, this is useful for parsing/reading binary data.
34
- * @since 1.3.0
35
- * @param request The request to read the body from.
36
- */
37
- async readBuffer(request) {
38
- const stream = this.contentStream(request);
39
- if (stream === null) return Buffer.alloc(0);
40
- const bodies = [];
41
- for await (const chunk of stream) bodies.push(chunk);
42
- return Buffer.concat(bodies);
43
- }
44
- /**
45
- * Reads the content stream from a request, piping the data through a transformer stream.
46
- * @since 1.3.0
47
- * @param request The request to read the body from.
48
- */
49
- contentStream(request) {
50
- switch ((request.headers["content-encoding"] ?? "identity").toLowerCase()) {
51
- case "deflate": {
52
- const stream = zlib.createInflate();
53
- request.pipe(stream);
54
- return stream;
55
- }
56
- case "x-gzip":
57
- case "gzip": {
58
- const stream = zlib.createGunzip();
59
- request.pipe(stream);
60
- return stream;
61
- }
62
- case "br": {
63
- const stream = zlib.createBrotliDecompress();
64
- request.pipe(stream);
65
- return stream;
66
- }
67
- case "identity": {
68
- return request;
69
- }
70
- }
71
- return null;
72
- }
73
- };
74
- __name(_MediaParser, "MediaParser");
75
- var MediaParser = _MediaParser;
76
-
77
- exports.MediaParser = MediaParser;
78
- //# sourceMappingURL=out.js.map
79
- //# sourceMappingURL=MediaParser.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/lib/structures/MediaParser.ts"],"names":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AIA,KAAK,YAAY;AAChB,eAAO;AAAA,MACR;AAAA,IACD;AAEA,WAAO;AAAA,EACR;AACD;AAhGoI;AAA7H,IAAe,cAAf","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: ApiRequest): 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: ApiRequest): 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: ApiRequest): 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: ApiRequest): ApiRequest | 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"]}
@@ -1,27 +0,0 @@
1
- 'use strict';
2
-
3
- var pieces = require('@sapphire/pieces');
4
- var MediaParser_cjs = require('./MediaParser.cjs');
5
-
6
- var __defProp = Object.defineProperty;
7
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
- var _MediaParserStore = class _MediaParserStore extends pieces.Store {
9
- constructor() {
10
- super(MediaParser_cjs.MediaParser, { name: "mediaParsers" });
11
- }
12
- /**
13
- * Parses a content type by getting the relevant information inside.
14
- * @since 1.3.0
15
- * @param contentType The content type to parse.
16
- */
17
- parseContentType(contentType) {
18
- const index = contentType.indexOf(";");
19
- return index === -1 ? contentType : contentType.slice(0, index);
20
- }
21
- };
22
- __name(_MediaParserStore, "MediaParserStore");
23
- var MediaParserStore = _MediaParserStore;
24
-
25
- exports.MediaParserStore = MediaParserStore;
26
- //# sourceMappingURL=out.js.map
27
- //# sourceMappingURL=MediaParserStore.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/lib/structures/MediaParserStore.ts"],"names":[],"mappings":";;;;AAAA,SAAS,aAAa;AACtB,SAAS,mBAAmB;AAKrB,IAAM,oBAAN,MAAM,0BAAyB,MAAmC;AAAA,EACjE,cAAc;AACpB,UAAM,aAAa,EAAE,MAAM,eAAe,CAAC;AAAA,EAC5C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOO,iBAAiB,aAA6B;AACpD,UAAM,QAAQ,YAAY,QAAQ,GAAG;AACrC,WAAO,UAAU,KAAK,cAAc,YAAY,MAAM,GAAG,KAAK;AAAA,EAC/D;AACD;AAdyE;AAAlE,IAAM,mBAAN","sourcesContent":["import { Store } from '@sapphire/pieces';\nimport { MediaParser } from './MediaParser';\n\n/**\n * @since 1.3.0\n */\nexport class MediaParserStore extends Store<MediaParser, 'mediaParsers'> {\n\tpublic constructor() {\n\t\tsuper(MediaParser, { name: 'mediaParsers' });\n\t}\n\n\t/**\n\t * Parses a content type by getting the relevant information inside.\n\t * @since 1.3.0\n\t * @param contentType The content type to parse.\n\t */\n\tpublic parseContentType(contentType: string): string {\n\t\tconst index = contentType.indexOf(';');\n\t\treturn index === -1 ? contentType : contentType.slice(0, index);\n\t}\n}\n"]}
@@ -1,26 +0,0 @@
1
- 'use strict';
2
-
3
- // src/lib/utils/MimeTypes.ts
4
- var MimeTypes = /* @__PURE__ */ ((MimeTypes2) => {
5
- MimeTypes2["ApplicationFormUrlEncoded"] = "application/x-www-form-urlencoded";
6
- MimeTypes2["ApplicationJson"] = "application/json";
7
- MimeTypes2["AudioOgg"] = "audio/ogg";
8
- MimeTypes2["AudioOpus"] = "audio/opus";
9
- MimeTypes2["AudioWebm"] = "audio/webm";
10
- MimeTypes2["ImageGif"] = "image/gif";
11
- MimeTypes2["ImageJpg"] = "image/jpeg";
12
- MimeTypes2["ImagePng"] = "image/png";
13
- MimeTypes2["ImageWebp"] = "image/webp";
14
- MimeTypes2["ImageXIcon"] = "image/x-icon";
15
- MimeTypes2["TextPlain"] = "text/plain";
16
- MimeTypes2["TextHtml"] = "text/html";
17
- MimeTypes2["VideoMp4"] = "video/mp4";
18
- MimeTypes2["VideoMpeg"] = "video/mpeg";
19
- MimeTypes2["VideoOgg"] = "video/ogg";
20
- MimeTypes2["VideoWebm"] = "video/webm";
21
- return MimeTypes2;
22
- })(MimeTypes || {});
23
-
24
- exports.MimeTypes = MimeTypes;
25
- //# sourceMappingURL=out.js.map
26
- //# sourceMappingURL=MimeTypes.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/lib/utils/MimeTypes.ts"],"names":["MimeTypes"],"mappings":";AAAO,IAAK,YAAL,kBAAKA,eAAL;AACN,EAAAA,WAAA,+BAA4B;AAC5B,EAAAA,WAAA,qBAAkB;AAClB,EAAAA,WAAA,cAAW;AACX,EAAAA,WAAA,eAAY;AACZ,EAAAA,WAAA,eAAY;AACZ,EAAAA,WAAA,cAAW;AACX,EAAAA,WAAA,cAAW;AACX,EAAAA,WAAA,cAAW;AACX,EAAAA,WAAA,eAAY;AACZ,EAAAA,WAAA,gBAAa;AACb,EAAAA,WAAA,eAAY;AACZ,EAAAA,WAAA,cAAW;AACX,EAAAA,WAAA,cAAW;AACX,EAAAA,WAAA,eAAY;AACZ,EAAAA,WAAA,cAAW;AACX,EAAAA,WAAA,eAAY;AAhBD,SAAAA;AAAA,GAAA","sourcesContent":["export enum MimeTypes {\n\tApplicationFormUrlEncoded = 'application/x-www-form-urlencoded',\n\tApplicationJson = 'application/json',\n\tAudioOgg = 'audio/ogg',\n\tAudioOpus = 'audio/opus',\n\tAudioWebm = 'audio/webm',\n\tImageGif = 'image/gif',\n\tImageJpg = 'image/jpeg',\n\tImagePng = 'image/png',\n\tImageWebp = 'image/webp',\n\tImageXIcon = 'image/x-icon',\n\tTextPlain = 'text/plain',\n\tTextHtml = 'text/html',\n\tVideoMp4 = 'video/mp4',\n\tVideoMpeg = 'video/mpeg',\n\tVideoOgg = 'video/ogg',\n\tVideoWebm = 'video/webm'\n}\n"]}