@sapphire/plugin-api 5.2.1-next.eccc557.0 → 6.0.0-next.d9aa006.0

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 (300) hide show
  1. package/dist/cjs/index.cjs +114 -0
  2. package/dist/cjs/index.cjs.map +1 -0
  3. package/dist/cjs/index.d.ts +1126 -0
  4. package/dist/cjs/lib/structures/Augmentations.d.cjs +4 -0
  5. package/dist/cjs/lib/structures/Augmentations.d.cjs.map +1 -0
  6. package/dist/cjs/lib/structures/MediaParser.cjs +83 -0
  7. package/dist/cjs/lib/structures/MediaParser.cjs.map +1 -0
  8. package/dist/cjs/lib/structures/MediaParserStore.cjs +27 -0
  9. package/dist/cjs/lib/structures/MediaParserStore.cjs.map +1 -0
  10. package/dist/cjs/lib/structures/Middleware.cjs +34 -0
  11. package/dist/cjs/lib/structures/Middleware.cjs.map +1 -0
  12. package/dist/cjs/lib/structures/MiddlewareStore.cjs +53 -0
  13. package/dist/cjs/lib/structures/MiddlewareStore.cjs.map +1 -0
  14. package/dist/cjs/lib/structures/Route.cjs +72 -0
  15. package/dist/cjs/lib/structures/Route.cjs.map +1 -0
  16. package/dist/cjs/lib/structures/RouteStore.cjs +68 -0
  17. package/dist/cjs/lib/structures/RouteStore.cjs.map +1 -0
  18. package/dist/cjs/lib/structures/api/ApiRequest.cjs +42 -0
  19. package/dist/cjs/lib/structures/api/ApiRequest.cjs.map +1 -0
  20. package/dist/cjs/lib/structures/api/ApiResponse.cjs +126 -0
  21. package/dist/cjs/lib/structures/api/ApiResponse.cjs.map +1 -0
  22. package/dist/cjs/lib/structures/api/CookieStore.cjs +106 -0
  23. package/dist/cjs/lib/structures/api/CookieStore.cjs.map +1 -0
  24. package/dist/cjs/lib/structures/http/Auth.cjs +152 -0
  25. package/dist/cjs/lib/structures/http/Auth.cjs.map +1 -0
  26. package/dist/cjs/lib/structures/http/HttpCodes.cjs +70 -0
  27. package/dist/cjs/lib/structures/http/HttpCodes.cjs.map +1 -0
  28. package/dist/cjs/lib/structures/http/HttpMethods.cjs +12 -0
  29. package/dist/cjs/lib/structures/http/HttpMethods.cjs.map +1 -0
  30. package/dist/cjs/lib/structures/http/Server.cjs +127 -0
  31. package/dist/cjs/lib/structures/http/Server.cjs.map +1 -0
  32. package/dist/cjs/lib/utils/MimeTypes.cjs +26 -0
  33. package/dist/cjs/lib/utils/MimeTypes.cjs.map +1 -0
  34. package/dist/cjs/lib/utils/RouteData.cjs +73 -0
  35. package/dist/cjs/lib/utils/RouteData.cjs.map +1 -0
  36. package/dist/cjs/listeners/PluginRouteError.cjs +24 -0
  37. package/dist/cjs/listeners/PluginRouteError.cjs.map +1 -0
  38. package/dist/cjs/listeners/PluginServerMatch.cjs +26 -0
  39. package/dist/cjs/listeners/PluginServerMatch.cjs.map +1 -0
  40. package/dist/cjs/listeners/PluginServerMiddlewareError.cjs +24 -0
  41. package/dist/cjs/listeners/PluginServerMiddlewareError.cjs.map +1 -0
  42. package/dist/cjs/listeners/PluginServerMiddlewareSuccess.cjs +25 -0
  43. package/dist/cjs/listeners/PluginServerMiddlewareSuccess.cjs.map +1 -0
  44. package/dist/cjs/listeners/PluginServerNoMatch.cjs +22 -0
  45. package/dist/cjs/listeners/PluginServerNoMatch.cjs.map +1 -0
  46. package/dist/cjs/listeners/PluginServerRequest.cjs +32 -0
  47. package/dist/cjs/listeners/PluginServerRequest.cjs.map +1 -0
  48. package/dist/cjs/listeners/_load.cjs +26 -0
  49. package/dist/cjs/listeners/_load.cjs.map +1 -0
  50. package/dist/cjs/mediaParsers/_load.cjs +20 -0
  51. package/dist/cjs/mediaParsers/_load.cjs.map +1 -0
  52. package/dist/cjs/mediaParsers/applicationFormUrlEncoded.cjs +23 -0
  53. package/dist/cjs/mediaParsers/applicationFormUrlEncoded.cjs.map +1 -0
  54. package/dist/cjs/mediaParsers/applicationJson.cjs +22 -0
  55. package/dist/cjs/mediaParsers/applicationJson.cjs.map +1 -0
  56. package/dist/cjs/mediaParsers/textPlain.cjs +22 -0
  57. package/dist/cjs/mediaParsers/textPlain.cjs.map +1 -0
  58. package/dist/cjs/middlewares/_load.cjs +22 -0
  59. package/dist/cjs/middlewares/_load.cjs.map +1 -0
  60. package/dist/cjs/middlewares/auth.cjs +36 -0
  61. package/dist/cjs/middlewares/auth.cjs.map +1 -0
  62. package/dist/cjs/middlewares/body.cjs +50 -0
  63. package/dist/cjs/middlewares/body.cjs.map +1 -0
  64. package/dist/cjs/middlewares/cookies.cjs +30 -0
  65. package/dist/cjs/middlewares/cookies.cjs.map +1 -0
  66. package/dist/cjs/middlewares/headers.cjs +59 -0
  67. package/dist/cjs/middlewares/headers.cjs.map +1 -0
  68. package/dist/cjs/register.cjs +42 -0
  69. package/dist/cjs/register.cjs.map +1 -0
  70. package/dist/{register.d.ts → cjs/register.d.ts} +7 -5
  71. package/dist/cjs/routes/_load.cjs +18 -0
  72. package/dist/cjs/routes/_load.cjs.map +1 -0
  73. package/dist/cjs/routes/oauth/callback.cjs +79 -0
  74. package/dist/cjs/routes/oauth/callback.cjs.map +1 -0
  75. package/dist/cjs/routes/oauth/logout.cjs +66 -0
  76. package/dist/cjs/routes/oauth/logout.cjs.map +1 -0
  77. package/dist/esm/chunk-PYETHG4R.mjs +29 -0
  78. package/dist/esm/chunk-PYETHG4R.mjs.map +1 -0
  79. package/dist/esm/index.d.mts +1126 -0
  80. package/dist/esm/index.mjs +22 -0
  81. package/dist/esm/index.mjs.map +1 -0
  82. package/dist/esm/lib/structures/Augmentations.d.mjs +3 -0
  83. package/dist/esm/lib/structures/Augmentations.d.mjs.map +1 -0
  84. package/dist/esm/lib/structures/MediaParser.mjs +80 -0
  85. package/dist/esm/lib/structures/MediaParser.mjs.map +1 -0
  86. package/dist/esm/lib/structures/MediaParserStore.mjs +24 -0
  87. package/dist/esm/lib/structures/MediaParserStore.mjs.map +1 -0
  88. package/dist/esm/lib/structures/Middleware.mjs +26 -0
  89. package/dist/esm/lib/structures/Middleware.mjs.map +1 -0
  90. package/dist/esm/lib/structures/MiddlewareStore.mjs +45 -0
  91. package/dist/esm/lib/structures/MiddlewareStore.mjs.map +1 -0
  92. package/dist/esm/lib/structures/Route.mjs +64 -0
  93. package/dist/esm/lib/structures/Route.mjs.map +1 -0
  94. package/dist/esm/lib/structures/RouteStore.mjs +60 -0
  95. package/dist/esm/lib/structures/RouteStore.mjs.map +1 -0
  96. package/dist/esm/lib/structures/api/ApiRequest.mjs +34 -0
  97. package/dist/esm/lib/structures/api/ApiRequest.mjs.map +1 -0
  98. package/dist/esm/lib/structures/api/ApiResponse.mjs +118 -0
  99. package/dist/esm/lib/structures/api/ApiResponse.mjs.map +1 -0
  100. package/dist/esm/lib/structures/api/CookieStore.mjs +98 -0
  101. package/dist/esm/lib/structures/api/CookieStore.mjs.map +1 -0
  102. package/dist/esm/lib/structures/http/Auth.mjs +126 -0
  103. package/dist/esm/lib/structures/http/Auth.mjs.map +1 -0
  104. package/dist/esm/lib/structures/http/HttpCodes.mjs +70 -0
  105. package/dist/esm/lib/structures/http/HttpCodes.mjs.map +1 -0
  106. package/dist/esm/lib/structures/http/HttpMethods.mjs +9 -0
  107. package/dist/esm/lib/structures/http/HttpMethods.mjs.map +1 -0
  108. package/dist/esm/lib/structures/http/Server.mjs +118 -0
  109. package/dist/esm/lib/structures/http/Server.mjs.map +1 -0
  110. package/dist/esm/lib/utils/MimeTypes.mjs +26 -0
  111. package/dist/esm/lib/utils/MimeTypes.mjs.map +1 -0
  112. package/dist/esm/lib/utils/RouteData.mjs +64 -0
  113. package/dist/esm/lib/utils/RouteData.mjs.map +1 -0
  114. package/dist/esm/listeners/PluginRouteError.mjs +21 -0
  115. package/dist/esm/listeners/PluginRouteError.mjs.map +1 -0
  116. package/dist/esm/listeners/PluginServerMatch.mjs +23 -0
  117. package/dist/esm/listeners/PluginServerMatch.mjs.map +1 -0
  118. package/dist/esm/listeners/PluginServerMiddlewareError.mjs +21 -0
  119. package/dist/esm/listeners/PluginServerMiddlewareError.mjs.map +1 -0
  120. package/dist/esm/listeners/PluginServerMiddlewareSuccess.mjs +22 -0
  121. package/dist/esm/listeners/PluginServerMiddlewareSuccess.mjs.map +1 -0
  122. package/dist/esm/listeners/PluginServerNoMatch.mjs +19 -0
  123. package/dist/esm/listeners/PluginServerNoMatch.mjs.map +1 -0
  124. package/dist/esm/listeners/PluginServerRequest.mjs +29 -0
  125. package/dist/esm/listeners/PluginServerRequest.mjs.map +1 -0
  126. package/dist/esm/listeners/_load.mjs +23 -0
  127. package/dist/esm/listeners/_load.mjs.map +1 -0
  128. package/dist/esm/mediaParsers/_load.mjs +17 -0
  129. package/dist/esm/mediaParsers/_load.mjs.map +1 -0
  130. package/dist/esm/mediaParsers/applicationFormUrlEncoded.mjs +20 -0
  131. package/dist/esm/mediaParsers/applicationFormUrlEncoded.mjs.map +1 -0
  132. package/dist/esm/mediaParsers/applicationJson.mjs +19 -0
  133. package/dist/esm/mediaParsers/applicationJson.mjs.map +1 -0
  134. package/dist/esm/mediaParsers/textPlain.mjs +19 -0
  135. package/dist/esm/mediaParsers/textPlain.mjs.map +1 -0
  136. package/dist/esm/middlewares/_load.mjs +19 -0
  137. package/dist/esm/middlewares/_load.mjs.map +1 -0
  138. package/dist/esm/middlewares/auth.mjs +28 -0
  139. package/dist/esm/middlewares/auth.mjs.map +1 -0
  140. package/dist/esm/middlewares/body.mjs +42 -0
  141. package/dist/esm/middlewares/body.mjs.map +1 -0
  142. package/dist/esm/middlewares/cookies.mjs +22 -0
  143. package/dist/esm/middlewares/cookies.mjs.map +1 -0
  144. package/dist/esm/middlewares/headers.mjs +51 -0
  145. package/dist/esm/middlewares/headers.mjs.map +1 -0
  146. package/dist/esm/register.d.mts +19 -0
  147. package/dist/esm/register.mjs +39 -0
  148. package/dist/esm/register.mjs.map +1 -0
  149. package/dist/esm/routes/_load.mjs +15 -0
  150. package/dist/esm/routes/_load.mjs.map +1 -0
  151. package/dist/esm/routes/oauth/callback.mjs +71 -0
  152. package/dist/esm/routes/oauth/callback.mjs.map +1 -0
  153. package/dist/esm/routes/oauth/logout.mjs +63 -0
  154. package/dist/esm/routes/oauth/logout.mjs.map +1 -0
  155. package/package.json +37 -21
  156. package/dist/index.d.ts +0 -38
  157. package/dist/index.d.ts.map +0 -1
  158. package/dist/index.js +0 -32
  159. package/dist/index.js.map +0 -1
  160. package/dist/index.mjs +0 -21
  161. package/dist/lib/structures/MediaParser.d.ts +0 -51
  162. package/dist/lib/structures/MediaParser.d.ts.map +0 -1
  163. package/dist/lib/structures/MediaParser.js +0 -94
  164. package/dist/lib/structures/MediaParser.js.map +0 -1
  165. package/dist/lib/structures/MediaParserStore.d.ts +0 -15
  166. package/dist/lib/structures/MediaParserStore.d.ts.map +0 -1
  167. package/dist/lib/structures/MediaParserStore.js +0 -24
  168. package/dist/lib/structures/MediaParserStore.js.map +0 -1
  169. package/dist/lib/structures/Middleware.d.ts +0 -49
  170. package/dist/lib/structures/Middleware.d.ts.map +0 -1
  171. package/dist/lib/structures/Middleware.js +0 -31
  172. package/dist/lib/structures/Middleware.js.map +0 -1
  173. package/dist/lib/structures/MiddlewareStore.d.ts +0 -20
  174. package/dist/lib/structures/MiddlewareStore.d.ts.map +0 -1
  175. package/dist/lib/structures/MiddlewareStore.js +0 -52
  176. package/dist/lib/structures/MiddlewareStore.js.map +0 -1
  177. package/dist/lib/structures/Route.d.ts +0 -78
  178. package/dist/lib/structures/Route.d.ts.map +0 -1
  179. package/dist/lib/structures/Route.js +0 -84
  180. package/dist/lib/structures/Route.js.map +0 -1
  181. package/dist/lib/structures/RouteStore.d.ts +0 -23
  182. package/dist/lib/structures/RouteStore.d.ts.map +0 -1
  183. package/dist/lib/structures/RouteStore.js +0 -71
  184. package/dist/lib/structures/RouteStore.js.map +0 -1
  185. package/dist/lib/structures/api/ApiRequest.d.ts +0 -26
  186. package/dist/lib/structures/api/ApiRequest.d.ts.map +0 -1
  187. package/dist/lib/structures/api/ApiRequest.js +0 -51
  188. package/dist/lib/structures/api/ApiRequest.js.map +0 -1
  189. package/dist/lib/structures/api/ApiResponse.d.ts +0 -74
  190. package/dist/lib/structures/api/ApiResponse.d.ts.map +0 -1
  191. package/dist/lib/structures/api/ApiResponse.js +0 -123
  192. package/dist/lib/structures/api/ApiResponse.js.map +0 -1
  193. package/dist/lib/structures/api/CookieStore.d.ts +0 -30
  194. package/dist/lib/structures/api/CookieStore.d.ts.map +0 -1
  195. package/dist/lib/structures/api/CookieStore.js +0 -132
  196. package/dist/lib/structures/api/CookieStore.js.map +0 -1
  197. package/dist/lib/structures/http/Auth.d.ts +0 -164
  198. package/dist/lib/structures/http/Auth.d.ts.map +0 -1
  199. package/dist/lib/structures/http/Auth.js +0 -164
  200. package/dist/lib/structures/http/Auth.js.map +0 -1
  201. package/dist/lib/structures/http/HttpCodes.d.ts +0 -378
  202. package/dist/lib/structures/http/HttpCodes.d.ts.map +0 -1
  203. package/dist/lib/structures/http/HttpCodes.js +0 -382
  204. package/dist/lib/structures/http/HttpCodes.js.map +0 -1
  205. package/dist/lib/structures/http/HttpMethods.d.ts +0 -4
  206. package/dist/lib/structures/http/HttpMethods.d.ts.map +0 -1
  207. package/dist/lib/structures/http/HttpMethods.js +0 -7
  208. package/dist/lib/structures/http/HttpMethods.js.map +0 -1
  209. package/dist/lib/structures/http/Server.d.ts +0 -179
  210. package/dist/lib/structures/http/Server.d.ts.map +0 -1
  211. package/dist/lib/structures/http/Server.js +0 -144
  212. package/dist/lib/structures/http/Server.js.map +0 -1
  213. package/dist/lib/utils/MimeTypes.d.ts +0 -19
  214. package/dist/lib/utils/MimeTypes.d.ts.map +0 -1
  215. package/dist/lib/utils/MimeTypes.js +0 -23
  216. package/dist/lib/utils/MimeTypes.js.map +0 -1
  217. package/dist/lib/utils/RouteData.d.ts +0 -34
  218. package/dist/lib/utils/RouteData.d.ts.map +0 -1
  219. package/dist/lib/utils/RouteData.js +0 -84
  220. package/dist/lib/utils/RouteData.js.map +0 -1
  221. package/dist/listeners/PluginRouteError.d.ts +0 -7
  222. package/dist/listeners/PluginRouteError.d.ts.map +0 -1
  223. package/dist/listeners/PluginRouteError.js +0 -20
  224. package/dist/listeners/PluginRouteError.js.map +0 -1
  225. package/dist/listeners/PluginServerMatch.d.ts +0 -9
  226. package/dist/listeners/PluginServerMatch.d.ts.map +0 -1
  227. package/dist/listeners/PluginServerMatch.js +0 -15
  228. package/dist/listeners/PluginServerMatch.js.map +0 -1
  229. package/dist/listeners/PluginServerMiddlewareError.d.ts +0 -7
  230. package/dist/listeners/PluginServerMiddlewareError.d.ts.map +0 -1
  231. package/dist/listeners/PluginServerMiddlewareError.js +0 -20
  232. package/dist/listeners/PluginServerMiddlewareError.js.map +0 -1
  233. package/dist/listeners/PluginServerMiddlewareSuccess.d.ts +0 -9
  234. package/dist/listeners/PluginServerMiddlewareSuccess.d.ts.map +0 -1
  235. package/dist/listeners/PluginServerMiddlewareSuccess.js +0 -20
  236. package/dist/listeners/PluginServerMiddlewareSuccess.js.map +0 -1
  237. package/dist/listeners/PluginServerNoMatch.d.ts +0 -8
  238. package/dist/listeners/PluginServerNoMatch.d.ts.map +0 -1
  239. package/dist/listeners/PluginServerNoMatch.js +0 -16
  240. package/dist/listeners/PluginServerNoMatch.js.map +0 -1
  241. package/dist/listeners/PluginServerRequest.d.ts +0 -8
  242. package/dist/listeners/PluginServerRequest.d.ts.map +0 -1
  243. package/dist/listeners/PluginServerRequest.js +0 -30
  244. package/dist/listeners/PluginServerRequest.js.map +0 -1
  245. package/dist/listeners/_load.d.ts +0 -2
  246. package/dist/listeners/_load.d.ts.map +0 -1
  247. package/dist/listeners/_load.js +0 -21
  248. package/dist/listeners/_load.js.map +0 -1
  249. package/dist/mediaParsers/_load.d.ts +0 -2
  250. package/dist/mediaParsers/_load.d.ts.map +0 -1
  251. package/dist/mediaParsers/_load.js +0 -15
  252. package/dist/mediaParsers/_load.js.map +0 -1
  253. package/dist/mediaParsers/applicationFormUrlEncoded.d.ts +0 -7
  254. package/dist/mediaParsers/applicationFormUrlEncoded.d.ts.map +0 -1
  255. package/dist/mediaParsers/applicationFormUrlEncoded.js +0 -17
  256. package/dist/mediaParsers/applicationFormUrlEncoded.js.map +0 -1
  257. package/dist/mediaParsers/applicationJson.d.ts +0 -7
  258. package/dist/mediaParsers/applicationJson.d.ts.map +0 -1
  259. package/dist/mediaParsers/applicationJson.js +0 -16
  260. package/dist/mediaParsers/applicationJson.js.map +0 -1
  261. package/dist/mediaParsers/textPlain.d.ts +0 -7
  262. package/dist/mediaParsers/textPlain.d.ts.map +0 -1
  263. package/dist/mediaParsers/textPlain.js +0 -16
  264. package/dist/mediaParsers/textPlain.js.map +0 -1
  265. package/dist/middlewares/_load.d.ts +0 -2
  266. package/dist/middlewares/_load.d.ts.map +0 -1
  267. package/dist/middlewares/_load.js +0 -17
  268. package/dist/middlewares/_load.js.map +0 -1
  269. package/dist/middlewares/auth.d.ts +0 -9
  270. package/dist/middlewares/auth.d.ts.map +0 -1
  271. package/dist/middlewares/auth.js +0 -32
  272. package/dist/middlewares/auth.js.map +0 -1
  273. package/dist/middlewares/body.d.ts +0 -10
  274. package/dist/middlewares/body.d.ts.map +0 -1
  275. package/dist/middlewares/body.js +0 -50
  276. package/dist/middlewares/body.js.map +0 -1
  277. package/dist/middlewares/cookies.d.ts +0 -10
  278. package/dist/middlewares/cookies.d.ts.map +0 -1
  279. package/dist/middlewares/cookies.js +0 -29
  280. package/dist/middlewares/cookies.js.map +0 -1
  281. package/dist/middlewares/headers.d.ts +0 -27
  282. package/dist/middlewares/headers.d.ts.map +0 -1
  283. package/dist/middlewares/headers.js +0 -59
  284. package/dist/middlewares/headers.js.map +0 -1
  285. package/dist/register.d.ts.map +0 -1
  286. package/dist/register.js +0 -42
  287. package/dist/register.js.map +0 -1
  288. package/dist/register.mjs +0 -4
  289. package/dist/routes/_load.d.ts +0 -2
  290. package/dist/routes/_load.d.ts.map +0 -1
  291. package/dist/routes/_load.js +0 -13
  292. package/dist/routes/_load.js.map +0 -1
  293. package/dist/routes/oauth/callback.d.ts +0 -28
  294. package/dist/routes/oauth/callback.d.ts.map +0 -1
  295. package/dist/routes/oauth/callback.js +0 -73
  296. package/dist/routes/oauth/callback.js.map +0 -1
  297. package/dist/routes/oauth/logout.d.ts +0 -8
  298. package/dist/routes/oauth/logout.d.ts.map +0 -1
  299. package/dist/routes/oauth/logout.js +0 -94
  300. package/dist/routes/oauth/logout.js.map +0 -1
@@ -0,0 +1,1126 @@
1
+ import { EventEmitter } from 'node:events';
2
+ import { IncomingMessage, ServerResponse, Server as Server$1, ServerOptions as ServerOptions$1 } from 'node:http';
3
+ import { ListenOptions } from 'node:net';
4
+ import { Store, Piece } from '@sapphire/pieces';
5
+ import { Awaitable } from '@sapphire/utilities';
6
+ import { Gunzip } from 'zlib';
7
+ import { Snowflake, OAuth2Scopes, RESTGetAPICurrentUserResult, RESTGetAPICurrentUserGuildsResult, RESTGetAPICurrentUserConnectionsResult, Collection } from 'discord.js';
8
+
9
+ declare class Auth {
10
+ #private;
11
+ /**
12
+ * The client's application id, this can be retrieved in Discord Developer Portal at https://discord.com/developers/applications.
13
+ * @since 1.0.0
14
+ */
15
+ id: Snowflake;
16
+ /**
17
+ * The name for the cookie, this will be used to identify a Secure HttpOnly cookie.
18
+ * @since 1.0.0
19
+ */
20
+ cookie: string;
21
+ /**
22
+ * The scopes defined at https://discord.com/developers/docs/topics/oauth2#shared-resources-oauth2-scopes.
23
+ * @since 1.0.0
24
+ */
25
+ scopes: readonly OAuth2Scopes[];
26
+ /**
27
+ * The redirect uri.
28
+ * @since 1.0.0
29
+ */
30
+ redirect: string | undefined;
31
+ /**
32
+ * The transformers used for {@link Auth.fetchData}.
33
+ * @since 1.4.0
34
+ */
35
+ transformers: LoginDataTransformer[];
36
+ domainOverwrite: string | null;
37
+ private constructor();
38
+ /**
39
+ * The client secret, this can be retrieved in Discord Developer Portal at https://discord.com/developers/applications.
40
+ * @since 1.0.0
41
+ */
42
+ get secret(): string;
43
+ /**
44
+ * Encrypts an object with aes-256-cbc to use as a token.
45
+ * @since 1.0.0
46
+ * @param data An object to encrypt
47
+ * @param secret The secret to encrypt the data with
48
+ */
49
+ encrypt(data: AuthData): string;
50
+ /**
51
+ * Decrypts an object with aes-256-cbc to use as a token.
52
+ * @since 1.0.0
53
+ * @param token An data to decrypt
54
+ * @param secret The secret to decrypt the data with
55
+ */
56
+ decrypt(token: string): AuthData | null;
57
+ /**
58
+ * Retrieves the data for a specific user.
59
+ * @since 1.4.0
60
+ * @param token The access token from the user.
61
+ */
62
+ fetchData(token: string): Promise<LoginData>;
63
+ private fetchInformation;
64
+ static create(options?: ServerOptionsAuth): Auth | null;
65
+ }
66
+ /**
67
+ * Defines the authentication data, this is to be encrypted and decrypted by the server.
68
+ * @since 1.0.0
69
+ */
70
+ interface AuthData {
71
+ /**
72
+ * The user ID.
73
+ * @since 1.0.0
74
+ */
75
+ id: string;
76
+ /**
77
+ * The timestamp at which the token expires.
78
+ * @since 1.0.0
79
+ */
80
+ expires: number;
81
+ /**
82
+ * The refresh token.
83
+ * @since 1.0.0
84
+ */
85
+ refresh: string;
86
+ /**
87
+ * The access token.
88
+ * @since 1.0.0
89
+ */
90
+ token: string;
91
+ }
92
+ /**
93
+ * Defines the authentication options.
94
+ * @since 1.0.0
95
+ */
96
+ interface ServerOptionsAuth {
97
+ /**
98
+ * The client's application id, this can be retrieved in Discord Developer Portal at https://discord.com/developers/applications.
99
+ * @since 1.0.0
100
+ */
101
+ id: string;
102
+ /**
103
+ * The name for the cookie, this will be used to identify a Secure HttpOnly cookie.
104
+ * @since 1.0.0
105
+ * @default 'SAPPHIRE_AUTH'
106
+ */
107
+ cookie?: string;
108
+ /**
109
+ * The client secret, this can be retrieved in Discord Developer Portal at https://discord.com/developers/applications.
110
+ * @since 1.0.0
111
+ */
112
+ secret: string;
113
+ /**
114
+ * The scopes defined at https://discord.com/developers/docs/topics/oauth2#shared-resources-oauth2-scopes.
115
+ * @since 1.0.0
116
+ * @default [OAuth2Scopes.Identify]
117
+ */
118
+ scopes?: OAuth2Scopes[];
119
+ /**
120
+ * The redirect uri. This will default to {@link OAuth2BodyData.redirectUri} if missing.
121
+ * @since 1.0.0
122
+ */
123
+ redirect?: string;
124
+ /**
125
+ * The login data transformers used for {@link Auth.fetchData}.
126
+ * @since 1.4.0
127
+ * @default []
128
+ */
129
+ transformers?: LoginDataTransformer[];
130
+ /**
131
+ * The domain that should be used for the cookie. This overwrites the automatic detection of the domain.
132
+ * @remark if you want to support subdomains (`one.example.two` and `two.example.com`) then you need to use prefix your domain with a `.`, for example `.example.com`
133
+ * @since 2.1.0
134
+ * @default undefined
135
+ */
136
+ domainOverwrite?: string;
137
+ }
138
+ /**
139
+ * The login data sent when fetching data from a user.
140
+ * @since 1.4.0
141
+ */
142
+ interface LoginData {
143
+ /**
144
+ * The user data, defined when the `'identify'` scope is defined.
145
+ * @since 1.4.0
146
+ */
147
+ user?: RESTGetAPICurrentUserResult | null;
148
+ /**
149
+ * The guilds data, defined when the `'guilds'` scope is defined.
150
+ * @since 1.4.0
151
+ */
152
+ guilds?: RESTGetAPICurrentUserGuildsResult | null;
153
+ /**
154
+ * The connections data, defined when the `'connections'` scope is defined.
155
+ * @since 1.4.0
156
+ */
157
+ connections?: RESTGetAPICurrentUserConnectionsResult | null;
158
+ }
159
+ /**
160
+ * A login data transformer.
161
+ * @since 1.4.0
162
+ */
163
+ interface LoginDataTransformer<T extends LoginData = LoginData> {
164
+ /**
165
+ * Transforms the object by mutating its properties or adding new ones.
166
+ * @since 1.4.0
167
+ */
168
+ (data: LoginData): Awaitable<T>;
169
+ }
170
+
171
+ declare class ApiRequest extends IncomingMessage {
172
+ /**
173
+ * The query parameters.
174
+ */
175
+ query: Record<string, string | string[]>;
176
+ /**
177
+ * The URI parameters.
178
+ */
179
+ params: Record<string, string>;
180
+ /**
181
+ * The body that was sent by the user.
182
+ */
183
+ body?: unknown;
184
+ /**
185
+ * The authorization information. This field indicates three possible values:
186
+ *
187
+ * - `undefined`: The authorization middleware has not been executed yet.
188
+ * - `null`: The user is not authorized.
189
+ * - `AuthData`: The user is authorized.
190
+ */
191
+ auth?: AuthData | null;
192
+ }
193
+
194
+ /**
195
+ * @since 1.0.0
196
+ */
197
+ declare enum TypeState {
198
+ /**
199
+ * @since 1.0.0
200
+ */
201
+ Static = 0,
202
+ /**
203
+ * @since 1.0.0
204
+ */
205
+ Dynamic = 1
206
+ }
207
+ type MatchData = Record<string, string> | null;
208
+ declare class RouteData {
209
+ readonly path: string;
210
+ private readonly static;
211
+ private readonly parts;
212
+ constructor(path: string);
213
+ match(split: readonly string[]): MatchData;
214
+ /**
215
+ * @since 1.0.0
216
+ */
217
+ private static parsePart;
218
+ /**
219
+ * @since 1.0.0
220
+ */
221
+ private static split;
222
+ }
223
+ interface ParsedPart {
224
+ value: string;
225
+ type: TypeState;
226
+ }
227
+
228
+ type Methods = 'ACL' | 'BIND' | 'CHECKOUT' | 'CONNECT' | 'COPY' | 'DELETE' | 'GET' | 'HEAD' | 'LINK' | 'LOCK' | 'M-SEARCH' | 'MERGE' | 'MKACTIVITY' | 'MKCALENDAR' | 'MKCOL' | 'MOVE' | 'NOTIFY' | 'OPTIONS' | 'PATCH' | 'POST' | 'PRI' | 'PROPFIND' | 'PROPPATCH' | 'PURGE' | 'PUT' | 'REBIND' | 'REPORT' | 'SEARCH' | 'SOURCE' | 'SUBSCRIBE' | 'TRACE' | 'UNBIND' | 'UNLINK' | 'UNLOCK' | 'UNSUBSCRIBE';
229
+ declare const methods: Record<Methods, symbol>;
230
+ declare const methodEntries: readonly [Methods, symbol][];
231
+
232
+ declare enum MimeTypes {
233
+ ApplicationFormUrlEncoded = "application/x-www-form-urlencoded",
234
+ ApplicationJson = "application/json",
235
+ AudioOgg = "audio/ogg",
236
+ AudioOpus = "audio/opus",
237
+ AudioWebm = "audio/webm",
238
+ ImageGif = "image/gif",
239
+ ImageJpg = "image/jpeg",
240
+ ImagePng = "image/png",
241
+ ImageWebp = "image/webp",
242
+ ImageXIcon = "image/x-icon",
243
+ TextPlain = "text/plain",
244
+ TextHtml = "text/html",
245
+ VideoMp4 = "video/mp4",
246
+ VideoMpeg = "video/mpeg",
247
+ VideoOgg = "video/ogg",
248
+ VideoWebm = "video/webm"
249
+ }
250
+
251
+ declare class CookieStore extends Map<string, string> {
252
+ protected request: ApiRequest;
253
+ protected response: ApiResponse;
254
+ private domain;
255
+ private secure;
256
+ constructor(request: ApiRequest, response: ApiResponse, secure: boolean, domainOverwrite?: string | null);
257
+ add(name: string, value: string, options?: SecureCookieStoreSetOptions): void;
258
+ remove(name: string): void;
259
+ protected insert(name: string, entry: string): void;
260
+ protected prepare(name: string, value: string, { expires, maxAge, domain, path, httpOnly }?: SecureCookieStoreSetOptions): string;
261
+ /**
262
+ * Parses a host using the {@linkplain https://github.com/remusao/tldts tldts} library to extract the domain.
263
+ * This is used for the domain of the cookie
264
+ * @param host The hot to parse
265
+ * @returns Either the host in all lower case or the parsed domain, ready for use on cookies
266
+ */
267
+ private getHostDomain;
268
+ private static readonly octetRegExp;
269
+ private static encodeCookieOctet;
270
+ }
271
+ interface SecureCookieStoreSetOptions {
272
+ expires?: Date;
273
+ maxAge?: number;
274
+ domain?: string;
275
+ path?: string;
276
+ httpOnly?: boolean;
277
+ }
278
+
279
+ /**
280
+ * @since 1.0.0
281
+ */
282
+ declare class ApiResponse<Request extends IncomingMessage = IncomingMessage> extends ServerResponse<Request> {
283
+ /**
284
+ * @since 1.0.0
285
+ */
286
+ cookies: CookieStore;
287
+ /**
288
+ * @since 1.0.0
289
+ */
290
+ ok(data?: unknown): void;
291
+ /**
292
+ * @since 1.0.0
293
+ */
294
+ created(data?: unknown): void;
295
+ /**
296
+ * @since 1.0.0
297
+ */
298
+ noContent(data?: unknown): void;
299
+ /**
300
+ * @since 1.0.0
301
+ */
302
+ badRequest(data?: unknown): void;
303
+ /**
304
+ * @since 1.0.0
305
+ */
306
+ unauthorized(data?: unknown): void;
307
+ /**
308
+ * @since 1.0.0
309
+ */
310
+ forbidden(data?: unknown): void;
311
+ /**
312
+ * @since 1.0.0
313
+ */
314
+ notFound(data?: unknown): void;
315
+ /**
316
+ * @since 1.0.0
317
+ */
318
+ conflict(data?: unknown): void;
319
+ /**
320
+ * @since 1.0.0
321
+ */
322
+ error(error: number | string, data?: unknown): void;
323
+ /**
324
+ * @since 1.0.0
325
+ */
326
+ respond(data: unknown): void;
327
+ /**
328
+ * @since 1.0.0
329
+ */
330
+ status(code: number): this;
331
+ /**
332
+ * @since 1.0.0
333
+ */
334
+ json(data: any): void;
335
+ /**
336
+ * @since 1.0.0
337
+ */
338
+ text(data: string): void;
339
+ /**
340
+ * @since 5.1.0
341
+ */
342
+ html(code: number, data: string): void;
343
+ /**
344
+ * @since 1.0.0
345
+ */
346
+ setContentType(contentType: MimeTypes): this;
347
+ }
348
+
349
+ interface MethodCallback {
350
+ (request: ApiRequest, response: ApiResponse): unknown;
351
+ }
352
+ interface RouteMatch {
353
+ route: Route;
354
+ cb: MethodCallback;
355
+ }
356
+ /**
357
+ * @since 1.0.0
358
+ */
359
+ declare class RouteStore extends Store<Route, 'routes'> {
360
+ readonly table: Collection<Methods, Collection<Route<RouteOptions>, MethodCallback>>;
361
+ constructor();
362
+ match(request: ApiRequest): RouteMatch | null;
363
+ private parseURL;
364
+ }
365
+
366
+ interface RouteOptions extends Piece.Options {
367
+ /**
368
+ * The route the piece should represent.
369
+ * @since 1.0.0
370
+ * @default ''
371
+ * @example
372
+ * ```typescript
373
+ * '/users'
374
+ * // request.params -> {}
375
+ * ```
376
+ * @example
377
+ * ```typescript
378
+ * '/guilds/:guild/members/:member/'
379
+ * // request.params -> { guild: '...', member: '...' }
380
+ * ```
381
+ */
382
+ route?: string;
383
+ /**
384
+ * (RFC 7230 3.3.2) The maximum decimal number of octets.
385
+ * @since 1.0.0
386
+ * @default this.context.server.options.maximumBodyLength ?? 1024 * 1024 * 50
387
+ */
388
+ maximumBodyLength?: number;
389
+ /**
390
+ * The accepted content types for this route. If set to null, the route will accept any data.
391
+ * @since 1.3.0
392
+ * @default this.context.server.options.acceptedContentMimeTypes ?? null
393
+ */
394
+ acceptedContentMimeTypes?: MimeTypeWithoutParameters[] | null;
395
+ }
396
+ /**
397
+ * @since 1.0.0
398
+ */
399
+ declare abstract class Route<Options extends Route.Options = Route.Options> extends Piece<Options, 'routes'> {
400
+ /**
401
+ * (RFC 7230 3.3.2) The maximum decimal number of octets.
402
+ */
403
+ readonly maximumBodyLength: number;
404
+ /**
405
+ * The accepted content types.
406
+ */
407
+ readonly acceptedContentMimeTypes: readonly MimeTypeWithoutParameters[] | null;
408
+ /**
409
+ * The route information.
410
+ */
411
+ readonly router: RouteData;
412
+ /**
413
+ * The methods this route accepts.
414
+ */
415
+ readonly methods: Collection<Methods, MethodCallback>;
416
+ constructor(context: Route.LoaderContext, options?: Options);
417
+ /**
418
+ * Per-piece listener that is called when the piece is loaded into the store.
419
+ * Useful to set-up asynchronous initialization tasks.
420
+ */
421
+ onLoad(): Awaitable<unknown>;
422
+ /**
423
+ * Per-piece listener that is called when the piece is unloaded from the store.
424
+ * Useful to set-up clean-up tasks.
425
+ */
426
+ onUnload(): Awaitable<unknown>;
427
+ }
428
+ declare namespace Route {
429
+ /** @deprecated Use {@linkcode LoaderContext} instead. */
430
+ type Context = LoaderContext;
431
+ type LoaderContext = Piece.LoaderContext<'routes'>;
432
+ type Options = RouteOptions;
433
+ type JSON = Piece.JSON;
434
+ type LocationJSON = Piece.LocationJSON;
435
+ }
436
+
437
+ /**
438
+ * A media parser
439
+ * @since 1.3.0
440
+ */
441
+ declare abstract class MediaParser<Options extends MediaParser.Options = MediaParser.Options> extends Piece<Options, 'mediaParsers'> {
442
+ constructor(context: MediaParser.LoaderContext, options?: Options);
443
+ /**
444
+ * Parses the body data from an API request.
445
+ * @since 1.3.0
446
+ */
447
+ abstract run(request: ApiRequest): Awaitable<unknown>;
448
+ /**
449
+ * Checks if a route accepts the media type from this parser.
450
+ * @since 1.3.0
451
+ * @param route The route to be checked.
452
+ */
453
+ accepts(route: Route): boolean;
454
+ /**
455
+ * Reads the content body as a string, this is useful for parsing/reading plain-text data.
456
+ * @since 1.3.0
457
+ * @param request The request to read the body from.
458
+ */
459
+ protected readString(request: ApiRequest): Promise<string>;
460
+ /**
461
+ * Reads the content body as a buffer, this is useful for parsing/reading binary data.
462
+ * @since 1.3.0
463
+ * @param request The request to read the body from.
464
+ */
465
+ protected readBuffer(request: ApiRequest): Promise<Buffer>;
466
+ /**
467
+ * Reads the content stream from a request, piping the data through a transformer stream.
468
+ * @since 1.3.0
469
+ * @param request The request to read the body from.
470
+ */
471
+ protected contentStream(request: ApiRequest): ApiRequest | Gunzip | null;
472
+ }
473
+ declare namespace MediaParser {
474
+ /** @deprecated Use {@linkcode LoaderContext} instead. */
475
+ type Context = LoaderContext;
476
+ type LoaderContext = Piece.LoaderContext<'mediaParsers'>;
477
+ type Options = Piece.Options;
478
+ type JSON = Piece.JSON;
479
+ type LocationJSON = Piece.LocationJSON;
480
+ }
481
+
482
+ /**
483
+ * @since 1.3.0
484
+ */
485
+ declare class MediaParserStore extends Store<MediaParser, 'mediaParsers'> {
486
+ constructor();
487
+ /**
488
+ * Parses a content type by getting the relevant information inside.
489
+ * @since 1.3.0
490
+ * @param contentType The content type to parse.
491
+ */
492
+ parseContentType(contentType: string): string;
493
+ }
494
+
495
+ /**
496
+ * The options for all middlewares.
497
+ */
498
+ interface MiddlewareOptions extends Piece.Options {
499
+ /**
500
+ * The position to insert the middleware at.
501
+ * @see Middleware#position
502
+ * @default 1000
503
+ */
504
+ position?: number;
505
+ }
506
+ /**
507
+ * @since 1.0.0
508
+ */
509
+ declare abstract class Middleware<Options extends Middleware.Options = Middleware.Options> extends Piece<Options, 'middlewares'> {
510
+ /**
511
+ * The position the middleware has. The {@link MiddlewareStore} will run all middlewares with lower position than
512
+ * this one.
513
+ *
514
+ * The built-in middlewares follow the following positions:
515
+ * - headers: 10
516
+ * - body: 20
517
+ * - cookies: 30
518
+ * - auth: 40
519
+ */
520
+ readonly position: number;
521
+ constructor(context: Middleware.LoaderContext, options?: Options);
522
+ /**
523
+ * The method to be overridden by other middlewares.
524
+ * @param request The client's request.
525
+ * @param response The server's response.
526
+ * @param route The route that matched this request, will be `null` if none matched.
527
+ */
528
+ abstract run(request: ApiRequest, response: ApiResponse, route: Route | null): Awaitable<unknown>;
529
+ }
530
+ declare namespace Middleware {
531
+ /** @deprecated Use {@linkcode LoaderContext} instead. */
532
+ type Context = LoaderContext;
533
+ type LoaderContext = Piece.LoaderContext<'middlewares'>;
534
+ type Options = MiddlewareOptions;
535
+ type JSON = Piece.JSON;
536
+ type LocationJSON = Piece.LocationJSON;
537
+ }
538
+
539
+ /**
540
+ * @since 1.0.0
541
+ */
542
+ declare class MiddlewareStore extends Store<Middleware, 'middlewares'> {
543
+ /**
544
+ * The sorted middlewares, in ascending order of see {@link Middleware.position}.
545
+ */
546
+ readonly sortedMiddlewares: Middleware[];
547
+ constructor();
548
+ run(request: ApiRequest, response: ApiResponse, route: Route | null): Promise<void>;
549
+ set(key: string, value: Middleware): this;
550
+ delete(key: string): boolean;
551
+ clear(): void;
552
+ }
553
+
554
+ declare enum ServerEvents {
555
+ Error = "error",
556
+ Request = "request",
557
+ Match = "match",
558
+ NoMatch = "noMatch",
559
+ RouteError = "routeError",
560
+ MiddlewareFailure = "middlewareFailure",
561
+ MiddlewareError = "middlewareError",
562
+ MiddlewareSuccess = "middlewareSuccess"
563
+ }
564
+ /**
565
+ * @since 1.0.0
566
+ */
567
+ declare class Server extends EventEmitter {
568
+ /**
569
+ * The routes this server holds.
570
+ * @since 1.0.0
571
+ */
572
+ readonly routes: RouteStore;
573
+ /**
574
+ * The middlewares this server holds.
575
+ * @since 1.0.0
576
+ */
577
+ readonly middlewares: MiddlewareStore;
578
+ /**
579
+ * The media parsers this server holds.
580
+ * @since 1.3.0
581
+ */
582
+ readonly mediaParsers: MediaParserStore;
583
+ /**
584
+ * The authentication system.
585
+ * @since 1.0.0
586
+ */
587
+ readonly auth: Auth | null;
588
+ /**
589
+ * The http.Server instance that manages the recieved HTTP requests.
590
+ * @since 1.0.0
591
+ */
592
+ readonly server: Server$1;
593
+ /**
594
+ * The options for this server.
595
+ * @since 1.0.0
596
+ */
597
+ readonly options: AuthLessServerOptions;
598
+ /**
599
+ * @since 1.0.0
600
+ * @param options The options for this server
601
+ */
602
+ constructor({ auth, ...options }?: ServerOptions);
603
+ connect(): Promise<void>;
604
+ disconnect(): Promise<void>;
605
+ }
606
+ /**
607
+ * RFC 1341 4: Defines a Content-Type's type, which follows the following structure:
608
+ *
609
+ * - `type` = `text` | `multipart` | `message` | `image` | `audio` | `video` | `application` | x-token
610
+ * - `x-token` = The two characters "X-" followed, with no intervening white space, by any token
611
+ * @since 1.3.0
612
+ */
613
+ type ContentTypeType = 'text' | 'multipart' | 'message' | 'image' | 'audio' | 'video' | 'application' | `X-${string}`;
614
+ /**
615
+ * RFC 1341 4: Defines a Content-Type's parameter, which follows the following structure:
616
+ *
617
+ * - `parameter` = `attribute` "=" `value`
618
+ * - `attribute` = `token`
619
+ * - `value` = `token` / `quoted-string`
620
+ * - `token` = `1*<any CHAR except "SPACE", "CTLs", or "tspecials">`
621
+ * - `tspecials` = `(` | `)` | `<` | `>` | `@` | `,` | `;` | `:` | `\` | `"` | `/` | `[` | `]` | `?` | `.` | `=`
622
+ *
623
+ * @note `tspecials` must be in quoted-string, to use within parameter values.
624
+ * @note The definition of `tspecials` is the same as the RFC 822 definition of `specials` with the addition of the
625
+ * three characters `/`, `?`, and `=`.
626
+ * @since 1.3.0
627
+ */
628
+ type ContentTypeParameter = `; ${string}=${string}`;
629
+ /**
630
+ * RFC 1341 4: Defines the syntax for a Content-Type field without parameters, which follows the following structure:
631
+ * `type "/" subtype`.
632
+ */
633
+ type MimeTypeWithoutParameters = `${ContentTypeType}/${string}`;
634
+ /**
635
+ * RFC 1341 4: Defines the syntax for a Content-Type field, which follows the following structure:
636
+ * `type "/" subtype *[";" parameter]`.
637
+ * @since 1.3.0
638
+ */
639
+ type MimeType = `${MimeTypeWithoutParameters}${'' | ContentTypeParameter}`;
640
+ /**
641
+ * The API options.
642
+ * @since 1.0.0
643
+ */
644
+ interface ServerOptions {
645
+ /**
646
+ * The prefix for all routes, e.g. `v1/`.
647
+ * @since 1.0.0
648
+ * @default ''
649
+ */
650
+ prefix?: string;
651
+ /**
652
+ * The origin header to be set on every request at 'Access-Control-Allow-Origin'.
653
+ * @since 1.0.0
654
+ * @default '*'
655
+ */
656
+ origin?: string;
657
+ /**
658
+ * (RFC 7230 3.3.2) The maximum decimal number of octets.
659
+ * @since 1.0.0
660
+ * @default 1024 * 1024 * 50
661
+ */
662
+ maximumBodyLength?: number;
663
+ /**
664
+ * The accepted content types for this route. If set to null, the route will accept any data.
665
+ * @since 1.3.0
666
+ * @default null
667
+ */
668
+ acceptedContentMimeTypes?: MimeTypeWithoutParameters[] | null;
669
+ /**
670
+ * The HTTP server options.
671
+ * @since 1.0.0
672
+ * @default {}
673
+ */
674
+ server?: ServerOptions$1;
675
+ /**
676
+ * The HTTP listen options.
677
+ * @since 1.0.0
678
+ * @default { port: 4000 }
679
+ */
680
+ listenOptions?: ListenOptions;
681
+ /**
682
+ * The auth options. If neither `auth` nor `auth.secret` are defined, auth-related routes and middlewares will be
683
+ * automatically disabled.
684
+ * @since 1.0.0
685
+ * @default {}
686
+ */
687
+ auth?: ServerOptionsAuth;
688
+ /**
689
+ * Whether the server should connect upon being when the plugin is loaded.
690
+ * @since 3.2.0
691
+ * @default true
692
+ */
693
+ automaticallyConnect?: boolean;
694
+ }
695
+ /**
696
+ * The {@link ServerOptions} without {@link ServerOptions.auth}.
697
+ * @since 1.0.0
698
+ */
699
+ type AuthLessServerOptions = Omit<ServerOptions, 'auth'>;
700
+ /**
701
+ * The context sent in the error events.
702
+ * @since 1.2.0
703
+ */
704
+ interface MiddlewareErrorContext {
705
+ /**
706
+ * The erroneous request.
707
+ * @since 1.2.0
708
+ */
709
+ request: ApiRequest;
710
+ /**
711
+ * The server's response.
712
+ * @since 1.2.0
713
+ */
714
+ response: ApiResponse;
715
+ /**
716
+ * The route match.
717
+ * @since 1.2.0
718
+ */
719
+ match: RouteMatch;
720
+ }
721
+
722
+ declare enum HttpCodes {
723
+ /**
724
+ * Standard response for successful HTTP requests. The actual response will
725
+ * depend on the request method used. In a GET request, the response will
726
+ * contain an entity corresponding to the requested resource. In a POST
727
+ * request, the response will contain an entity describing or containing the
728
+ * result of the action.
729
+ */
730
+ OK = 200,
731
+ /**
732
+ * The request has been fulfilled, resulting in the creation of a new
733
+ * resource.
734
+ */
735
+ Created = 201,
736
+ /**
737
+ * The request has been accepted for processing, but the processing has not
738
+ * been completed. The request might or might not be eventually acted upon,
739
+ * and may be disallowed when processing occurs.
740
+ */
741
+ Accepted = 202,
742
+ /**
743
+ * The server is a transforming proxy (e.g. a Web accelerator) that received
744
+ * a 200 OK from its origin, but is returning a modified version of the
745
+ * origin's response.
746
+ */
747
+ NonAuthoritativeInformation = 203,
748
+ /**
749
+ * The server successfully processed the request, and is not returning any
750
+ * content.
751
+ */
752
+ NoContent = 204,
753
+ /**
754
+ * The server successfully processed the request, asks that the requester
755
+ * reset its document view, and is not returning any content.
756
+ */
757
+ ResetContent = 205,
758
+ /**
759
+ * (RFC 7233) The server is delivering only part of the resource (byte
760
+ * serving) due to a range header sent by the client. The range header is
761
+ * used by HTTP clients to enable resuming of interrupted downloads, or
762
+ * split a download into multiple simultaneous streams.
763
+ */
764
+ PartialContent = 206,
765
+ /**
766
+ * (WebDAV; RFC 4918) The message body that follows is by default an XML
767
+ * message and can contain a number of separate response codes, depending on
768
+ * how many sub-requests were made.
769
+ */
770
+ MultiStatus = 207,
771
+ /**
772
+ * (WebDAV; RFC 5842) The members of a DAV binding have already been
773
+ * enumerated in a preceding part of the (multistatus) response, and are not
774
+ * being included again.
775
+ */
776
+ AlreadyReported = 208,
777
+ /**
778
+ * (RFC 3229) The server has fulfilled a request for the resource, and the
779
+ * response is a representation of the result of one or more
780
+ * instance-manipulations applied to the current instance.
781
+ */
782
+ IMUsed = 226,
783
+ /**
784
+ * Indicates multiple options for the resource from which the client may
785
+ * choose (via agent-driven content negotiation). For example, this code
786
+ * could be used to present multiple video format options, to list files
787
+ * with different filename extensions, or to suggest word-sense
788
+ * disambiguation.
789
+ */
790
+ MultipleChoices = 300,
791
+ /**
792
+ * This and all future requests should be directed to the given URI.
793
+ */
794
+ MovedPermanently = 301,
795
+ /**
796
+ * (Previously "Moved temporarily") Tells the client to look at (browse to)
797
+ * another URL. 302 has been superseded by 303 and 307. This is an example
798
+ * of industry practice contradicting the standard. The HTTP/1.0
799
+ * specification (RFC 1945) required the client to perform a temporary
800
+ * redirect (the original describing phrase was "Moved Temporarily"), but
801
+ * popular browsers implemented 302 with the functionality of a 303 See
802
+ * Other. Therefore, HTTP/1.1 added status codes 303 and 307 to distinguish
803
+ * between the two behaviours. However, some Web applications and frameworks
804
+ * use the 302 status code as if it were the 303.
805
+ */
806
+ Found = 302,
807
+ /**
808
+ * The response to the request can be found under another URI using the GET
809
+ * method. When received in response to a POST (or PUT/DELETE), the client
810
+ * should presume that the server has received the data and should issue a
811
+ * new GET request to the given URI.
812
+ */
813
+ SeeOther = 303,
814
+ /**
815
+ * (RFC 7232) Indicates that the resource has not been modified since the
816
+ * version specified by the request headers If-Modified-Since or
817
+ * If-None-Match. In such case, there is no need to retransmit the resource
818
+ * since the client still has a previously-downloaded copy.
819
+ */
820
+ NotModified = 304,
821
+ /**
822
+ * The requested resource is available only through a proxy, the address for
823
+ * which is provided in the response. For security reasons, many HTTP
824
+ * clients (such as Mozilla Firefox and Internet Explorer) do not obey this
825
+ * status code.
826
+ */
827
+ UseProxy = 305,
828
+ /**
829
+ * No longer used. Originally meant "Subsequent requests should use the
830
+ * specified proxy.".
831
+ */
832
+ SwitchProxy = 306,
833
+ /**
834
+ * In this case, the request should be repeated with another URI; however,
835
+ * future requests should still use the original URI. In contrast to how 302
836
+ * was historically implemented, the request method is not allowed to be
837
+ * changed when reissuing the original request. For example, a POST request
838
+ * should be repeated using another POST request.
839
+ */
840
+ TemporaryRedirect = 307,
841
+ /**
842
+ * (RFC 7538) The request and all future requests should be repeated using
843
+ * another URI. 307 and 308 parallel the behaviors of 302 and 301, but do
844
+ * not allow the HTTP method to change. So, for example, submitting a form
845
+ * to a permanently redirected resource may continue smoothly.
846
+ */
847
+ PermanentRedirect = 308,
848
+ /**
849
+ * The server cannot or will not process the request due to an apparent
850
+ * client error (e.g., malformed request syntax, size too large, invalid
851
+ * request message framing, or deceptive request routing).
852
+ */
853
+ BadRequest = 400,
854
+ /**
855
+ * (RFC 7235) Similar to 403 Forbidden, but specifically for use when
856
+ * authentication is required and has failed or has not yet been provided.
857
+ * The response must include a WWW-Authenticate header field containing a
858
+ * challenge applicable to the requested resource. See Basic access
859
+ * authentication and Digest access authentication. 401 semantically means
860
+ * "unauthorised", the user does not have valid authentication credentials
861
+ * for the target resource.
862
+ */
863
+ Unauthorized = 401,
864
+ /**
865
+ * Reserved for future use. The original intention was that this code might
866
+ * be used as part of some form of digital cash or micropayment scheme, as
867
+ * proposed, for example, by GNU Taler, but that has not yet happened, and
868
+ * this code is not widely used. Google Developers API uses this status if a
869
+ * particular developer has exceeded the daily limit on requests. Sipgate
870
+ * uses this code if an account does not have sufficient funds to start a
871
+ * call. Shopify uses this code when the store has not paid their fees and
872
+ * is temporarily disabled. Stripe uses this code for failed payments where
873
+ * parameters were correct, for example blocked fraudulent payments.
874
+ */
875
+ PaymentRequired = 402,
876
+ /**
877
+ * The request contained valid data and was understood by the server, but
878
+ * the server is refusing action. This may be due to the user not having the
879
+ * necessary permissions for a resource or needing an account of some sort,
880
+ * or attempting a prohibited action (e.g. creating a duplicate record
881
+ * where only one is allowed). This code is also typically used if the
882
+ * request provided authentication by answering the WWW-Authenticate header
883
+ * field challenge, but the server did not accept that authentication. The
884
+ * request should not be repeated.
885
+ */
886
+ Forbidden = 403,
887
+ /**
888
+ * The requested resource could not be found but may be available in the
889
+ * future. Subsequent requests by the client are permissible.
890
+ */
891
+ NotFound = 404,
892
+ /**
893
+ * A request method is not supported for the requested resource; for example,
894
+ * a GET request on a form that requires data to be presented via POST, or a
895
+ * PUT request on a read-only resource.
896
+ */
897
+ MethodNotAllowed = 405,
898
+ /**
899
+ * The requested resource is capable of generating only content not
900
+ * acceptable according to the Accept headers sent in the request. See Content negotiation.
901
+ */
902
+ NotAcceptable = 406,
903
+ /**
904
+ * (RFC 7235) The client must first authenticate itself with the proxy.
905
+ */
906
+ ProxyAuthenticationRequired = 407,
907
+ /**
908
+ * The server timed out waiting for the request. According to HTTP
909
+ * specifications: "The client did not produce a request within the time
910
+ * that the server was prepared to wait. The client MAY repeat the request
911
+ * without modifications at any later time."
912
+ */
913
+ RequestTimeout = 408,
914
+ /**
915
+ * Indicates that the request could not be processed because of conflict in
916
+ * the current state of the resource, such as an edit conflict between
917
+ * multiple simultaneous updates.
918
+ */
919
+ Conflict = 409,
920
+ /**
921
+ * Indicates that the resource requested is no longer available and will not
922
+ * be available again. This should be used when a resource has been
923
+ * intentionally removed and the resource should be purged. Upon receiving a
924
+ * 410 status code, the client should not request the resource in the future.
925
+ * Clients such as search engines should remove the resource from their
926
+ * indices. Most use cases do not require clients and search engines to
927
+ * purge the resource, and a "404 Not Found" may be used instead.
928
+ */
929
+ Gone = 410,
930
+ /**
931
+ * The request did not specify the length of its content, which is required
932
+ * by the requested resource.
933
+ */
934
+ LengthRequired = 411,
935
+ /**
936
+ * (RFC 7232) The server does not meet one of the preconditions that the
937
+ * requester put on the request header fields.
938
+ */
939
+ PreconditionFailed = 412,
940
+ /**
941
+ * (RFC 7231) The request is larger than the server is willing or able to
942
+ * process. Previously called "Request Entity Too Large".
943
+ */
944
+ PayloadTooLarge = 413,
945
+ /**
946
+ * (RFC 7231) The URI provided was too long for the server to process. Often
947
+ * the result of too much data being encoded as a query-string of a GET
948
+ * request, in which case it should be converted to a POST request. Called
949
+ * "Request-URI Too Long" previously.
950
+ */
951
+ URITooLong = 414,
952
+ /**
953
+ * (RFC 7231) The request entity has a media type which the server or
954
+ * resource does not support. For example, the client uploads an image as
955
+ * image/svg+xml, but the server requires that images use a different format.
956
+ */
957
+ UnsupportedMediaType = 415,
958
+ /**
959
+ * (RFC 7233) The client has asked for a portion of the file (byte serving),
960
+ * but the server cannot supply that portion. For example, if the client
961
+ * asked for a part of the file that lies beyond the end of the file. Called
962
+ * "Requested Range Not Satisfiable" previously.
963
+ */
964
+ RangeNotSatisfiable = 416,
965
+ /**
966
+ * The server cannot meet the requirements of the Expect request-header
967
+ * field.
968
+ */
969
+ ExpectationFailed = 417,
970
+ /**
971
+ * (RFC 2324, RFC 7168) This code was defined in 1998 as one of the
972
+ * traditional IETF April Fools' jokes, in RFC 2324, Hyper Text Coffee Pot
973
+ * Control Protocol, and is not expected to be implemented by actual HTTP
974
+ * servers. The RFC specifies this code should be returned by teapots
975
+ * requested to brew coffee. This HTTP status is used as an Easter egg in
976
+ * some websites, such as Google.com's I'm a teapot easter egg.
977
+ */
978
+ IAmATeapot = 418,
979
+ /**
980
+ * Returned by the Twitter Search and Trends API when the client is being rate limited.
981
+ * The text is a quote from 'Demolition Man' and the '420' code is likely a reference
982
+ * to this number's association with marijuana. Other services may wish to implement
983
+ * the 429 Too Many Requests response code instead.
984
+ */
985
+ EnhanceYourCalm = 420,
986
+ /**
987
+ * (RFC 7540) The request was directed at a server that is not able to
988
+ * produce a response (for example because of connection reuse).
989
+ */
990
+ MisdirectedRequest = 421,
991
+ /**
992
+ * (WebDAV; RFC 4918) The request was well-formed but was unable to be
993
+ * followed due to semantic errors.
994
+ */
995
+ UnprocessableEntity = 422,
996
+ /**
997
+ * (WebDAV; RFC 4918) The resource that is being accessed is locked.
998
+ */
999
+ Locked = 423,
1000
+ /**
1001
+ * (WebDAV; RFC 4918) The request failed because it depended on another
1002
+ * request and that request failed (e.g., a PROPPATCH).
1003
+ */
1004
+ FailedDependency = 424,
1005
+ /**
1006
+ * (RFC 8470) Indicates that the server is unwilling to risk processing a
1007
+ * request that might be replayed.
1008
+ */
1009
+ TooEarly = 425,
1010
+ /**
1011
+ * The client should switch to a different protocol such as TLS/1.0, given
1012
+ * in the Upgrade header field.
1013
+ */
1014
+ UpgradeRequired = 426,
1015
+ /**
1016
+ * (RFC 6585) The origin server requires the request to be conditional.
1017
+ * Intended to prevent the 'lost update' problem, where a client GETs a
1018
+ * resource's state, modifies it, and PUTs it back to the server, when
1019
+ * meanwhile a third party has modified the state on the server, leading to
1020
+ * a conflict.
1021
+ */
1022
+ PreconditionRequired = 428,
1023
+ /**
1024
+ * (RFC 6585) The user has sent too many requests in a given amount of time.
1025
+ * Intended for use with rate-limiting schemes.
1026
+ */
1027
+ TooManyRequests = 429,
1028
+ /**
1029
+ * (RFC 6585) The server is unwilling to process the request because either
1030
+ * an individual header field, or all the header fields collectively, are
1031
+ * too large.
1032
+ */
1033
+ RequestHeaderFieldsTooLarge = 431,
1034
+ /**
1035
+ * (RFC 7725) A server operator has received a legal demand to deny access
1036
+ * to a resource or to a set of resources that includes the requested
1037
+ * resource. The code 451 was chosen as a reference to the novel Fahrenheit
1038
+ * 451 (see the Acknowledgements in the RFC).
1039
+ */
1040
+ UnavailableForLegalReasons = 451,
1041
+ /**
1042
+ * A generic error message, given when an unexpected condition was
1043
+ * encountered and no more specific message is suitable.
1044
+ */
1045
+ InternalServerError = 500,
1046
+ /**
1047
+ * The server either does not recognize the request method, or it lacks the
1048
+ * ability to fulfil the request. Usually this implies future availability
1049
+ * (e.g., a new feature of a web-service API).
1050
+ */
1051
+ NotImplemented = 501,
1052
+ /**
1053
+ * The server was acting as a gateway or proxy and received an invalid
1054
+ * response from the upstream server.
1055
+ */
1056
+ BadGateway = 502,
1057
+ /**
1058
+ * The server cannot handle the request (because it is overloaded or down
1059
+ * for maintenance). Generally, this is a temporary state.
1060
+ */
1061
+ ServiceUnavailable = 503,
1062
+ /**
1063
+ * The server was acting as a gateway or proxy and did not receive a timely
1064
+ * response from the upstream server.
1065
+ */
1066
+ GatewayTimeout = 504,
1067
+ /**
1068
+ * The server does not support the HTTP protocol version used in the request.
1069
+ */
1070
+ HTTPVersionNotSupported = 505,
1071
+ /**
1072
+ * (RFC 2295) Transparent content negotiation for the request results in a
1073
+ * circular reference.
1074
+ */
1075
+ VariantAlsoNegotiates = 506,
1076
+ /**
1077
+ * (WebDAV; RFC 4918) The server is unable to store the representation
1078
+ * needed to complete the request.
1079
+ */
1080
+ InsufficientStorage = 507,
1081
+ /**
1082
+ * (WebDAV; RFC 5842) The server detected an infinite loop while processing
1083
+ * the request (sent instead of 208 Already Reported).
1084
+ */
1085
+ LoopDetected = 508,
1086
+ /**
1087
+ * (RFC 2774) Further extensions to the request are required for the server
1088
+ * to fulfil it.
1089
+ */
1090
+ NotExtended = 510,
1091
+ /**
1092
+ * (RFC 6585) The client needs to authenticate to gain network access.
1093
+ * Intended for use by intercepting proxies used to control access to the
1094
+ * network (e.g., "captive portals" used to require agreement to Terms of
1095
+ * Service before granting full Internet access via a Wi-Fi hotspot).
1096
+ */
1097
+ NetworkAuthenticationRequired = 511
1098
+ }
1099
+
1100
+ declare module 'discord.js' {
1101
+ interface Client {
1102
+ server: Server;
1103
+ }
1104
+ interface ClientOptions {
1105
+ api?: ServerOptions;
1106
+ }
1107
+ }
1108
+ declare module '@sapphire/pieces' {
1109
+ interface StoreRegistryEntries {
1110
+ routes: RouteStore;
1111
+ mediaParsers: MediaParserStore;
1112
+ middlewares: MiddlewareStore;
1113
+ }
1114
+ interface Container {
1115
+ server: Server;
1116
+ }
1117
+ }
1118
+ /**
1119
+ * The [@sapphire/plugin-api](https://github.com/sapphiredev/plugins/blob/main/packages/api) version that you are currently using.
1120
+ * An example use of this is showing it of in a bot information command.
1121
+ *
1122
+ * Note to Sapphire developers: This needs to explicitly be `string` so it is not typed as the string that gets replaced by esbuild
1123
+ */
1124
+ declare const version: string;
1125
+
1126
+ export { ApiRequest, ApiResponse, Auth, type AuthData, type AuthLessServerOptions, type ContentTypeParameter, type ContentTypeType, CookieStore, HttpCodes, type LoginData, type LoginDataTransformer, type MatchData, MediaParser, MediaParserStore, type MethodCallback, type Methods, Middleware, type MiddlewareErrorContext, type MiddlewareOptions, MiddlewareStore, type MimeType, type MimeTypeWithoutParameters, MimeTypes, type ParsedPart, Route, RouteData, type RouteMatch, type RouteOptions, RouteStore, type SecureCookieStoreSetOptions, Server, ServerEvents, type ServerOptions, type ServerOptionsAuth, TypeState, methodEntries, methods, version };