@sapphire/plugin-api 7.0.0-next.fc8c5ba → 7.0.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.
- package/CHANGELOG.md +61 -0
- package/dist/cjs/index.cjs +5 -31
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +90 -108
- package/dist/cjs/lib/structures/Middleware.cjs.map +1 -1
- package/dist/cjs/lib/structures/MiddlewareStore.cjs.map +1 -1
- package/dist/cjs/lib/structures/Route.cjs +4 -9
- package/dist/cjs/lib/structures/Route.cjs.map +1 -1
- package/dist/cjs/lib/structures/RouteLoaderStrategy.cjs.map +1 -1
- package/dist/cjs/lib/structures/RouteStore.cjs.map +1 -1
- package/dist/cjs/lib/structures/api/ApiRequest.cjs +128 -4
- package/dist/cjs/lib/structures/api/ApiRequest.cjs.map +1 -1
- package/dist/cjs/lib/structures/api/ApiResponse.cjs +4 -5
- package/dist/cjs/lib/structures/api/ApiResponse.cjs.map +1 -1
- package/dist/cjs/lib/structures/api/CookieStore.cjs.map +1 -1
- package/dist/cjs/lib/structures/http/Auth.cjs.map +1 -1
- package/dist/cjs/lib/structures/http/HttpCodes.cjs.map +1 -1
- package/dist/cjs/lib/structures/http/HttpMethods.cjs +1 -0
- package/dist/cjs/lib/structures/http/HttpMethods.cjs.map +1 -1
- package/dist/cjs/lib/structures/http/Server.cjs +1 -8
- package/dist/cjs/lib/structures/http/Server.cjs.map +1 -1
- package/dist/cjs/lib/structures/router/RouterBranch.cjs.map +1 -1
- package/dist/cjs/lib/structures/router/RouterNode.cjs.map +1 -1
- package/dist/cjs/lib/structures/router/RouterRoot.cjs +11 -1
- package/dist/cjs/lib/structures/router/RouterRoot.cjs.map +1 -1
- package/dist/cjs/lib/utils/MimeType.cjs +4 -0
- package/dist/cjs/lib/utils/MimeType.cjs.map +1 -0
- package/dist/cjs/lib/utils/_body/RequestHeadersProxy.cjs +100 -0
- package/dist/cjs/lib/utils/_body/RequestHeadersProxy.cjs.map +1 -0
- package/dist/cjs/lib/utils/_body/RequestProxy.cjs +124 -0
- package/dist/cjs/lib/utils/_body/RequestProxy.cjs.map +1 -0
- package/dist/cjs/lib/utils/_body/RequestURLProxy.cjs +179 -0
- package/dist/cjs/lib/utils/_body/RequestURLProxy.cjs.map +1 -0
- package/dist/cjs/lib/utils/constants.cjs +8 -0
- package/dist/cjs/lib/utils/constants.cjs.map +1 -0
- package/dist/cjs/listeners/PluginRouteError.cjs.map +1 -1
- package/dist/cjs/listeners/PluginServerMiddlewareError.cjs.map +1 -1
- package/dist/cjs/listeners/PluginServerMiddlewareSuccess.cjs.map +1 -1
- package/dist/cjs/listeners/PluginServerRequest.cjs.map +1 -1
- package/dist/cjs/listeners/PluginServerRouterBranchMethodNotAllowed.cjs.map +1 -1
- package/dist/cjs/listeners/PluginServerRouterBranchNotFound.cjs.map +1 -1
- package/dist/cjs/listeners/PluginServerRouterFound.cjs.map +1 -1
- package/dist/cjs/listeners/_load.cjs.map +1 -1
- package/dist/cjs/middlewares/_load.cjs.map +1 -1
- package/dist/cjs/middlewares/auth.cjs.map +1 -1
- package/dist/cjs/middlewares/body.cjs +1 -17
- package/dist/cjs/middlewares/body.cjs.map +1 -1
- package/dist/cjs/middlewares/cookies.cjs.map +1 -1
- package/dist/cjs/middlewares/headers.cjs.map +1 -1
- package/dist/cjs/register.cjs +2 -3
- package/dist/cjs/register.cjs.map +1 -1
- package/dist/cjs/register.d.cts +0 -1
- package/dist/cjs/routes/_load.cjs.map +1 -1
- package/dist/cjs/routes/oauth/callback.post.cjs +1 -1
- package/dist/cjs/routes/oauth/callback.post.cjs.map +1 -1
- package/dist/cjs/routes/oauth/logout.post.cjs.map +1 -1
- package/dist/esm/index.d.mts +90 -108
- package/dist/esm/index.mjs +1 -5
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/lib/structures/Middleware.mjs.map +1 -1
- package/dist/esm/lib/structures/MiddlewareStore.mjs.map +1 -1
- package/dist/esm/lib/structures/Route.mjs +4 -9
- package/dist/esm/lib/structures/Route.mjs.map +1 -1
- package/dist/esm/lib/structures/RouteLoaderStrategy.mjs.map +1 -1
- package/dist/esm/lib/structures/RouteStore.mjs.map +1 -1
- package/dist/esm/lib/structures/api/ApiRequest.mjs +122 -5
- package/dist/esm/lib/structures/api/ApiRequest.mjs.map +1 -1
- package/dist/esm/lib/structures/api/ApiResponse.mjs +4 -5
- package/dist/esm/lib/structures/api/ApiResponse.mjs.map +1 -1
- package/dist/esm/lib/structures/api/CookieStore.mjs.map +1 -1
- package/dist/esm/lib/structures/http/Auth.mjs.map +1 -1
- package/dist/esm/lib/structures/http/HttpCodes.mjs.map +1 -1
- package/dist/esm/lib/structures/http/HttpMethods.mjs +1 -0
- package/dist/esm/lib/structures/http/HttpMethods.mjs.map +1 -1
- package/dist/esm/lib/structures/http/Server.mjs +1 -8
- package/dist/esm/lib/structures/http/Server.mjs.map +1 -1
- package/dist/esm/lib/structures/router/RouterBranch.mjs.map +1 -1
- package/dist/esm/lib/structures/router/RouterNode.mjs.map +1 -1
- package/dist/esm/lib/structures/router/RouterRoot.mjs +11 -1
- package/dist/esm/lib/structures/router/RouterRoot.mjs.map +1 -1
- package/dist/esm/lib/utils/MimeType.mjs +3 -0
- package/dist/esm/lib/utils/MimeType.mjs.map +1 -0
- package/dist/esm/lib/utils/_body/RequestHeadersProxy.mjs +95 -0
- package/dist/esm/lib/utils/_body/RequestHeadersProxy.mjs.map +1 -0
- package/dist/esm/lib/utils/_body/RequestProxy.mjs +112 -0
- package/dist/esm/lib/utils/_body/RequestProxy.mjs.map +1 -0
- package/dist/esm/lib/utils/_body/RequestURLProxy.mjs +167 -0
- package/dist/esm/lib/utils/_body/RequestURLProxy.mjs.map +1 -0
- package/dist/esm/lib/utils/constants.mjs +8 -0
- package/dist/esm/lib/utils/constants.mjs.map +1 -0
- package/dist/esm/listeners/PluginRouteError.mjs.map +1 -1
- package/dist/esm/listeners/PluginServerMiddlewareError.mjs.map +1 -1
- package/dist/esm/listeners/PluginServerMiddlewareSuccess.mjs.map +1 -1
- package/dist/esm/listeners/PluginServerRequest.mjs.map +1 -1
- package/dist/esm/listeners/PluginServerRouterBranchMethodNotAllowed.mjs.map +1 -1
- package/dist/esm/listeners/PluginServerRouterBranchNotFound.mjs.map +1 -1
- package/dist/esm/listeners/PluginServerRouterFound.mjs.map +1 -1
- package/dist/esm/listeners/_load.mjs.map +1 -1
- package/dist/esm/middlewares/_load.mjs.map +1 -1
- package/dist/esm/middlewares/auth.mjs.map +1 -1
- package/dist/esm/middlewares/body.mjs +2 -16
- package/dist/esm/middlewares/body.mjs.map +1 -1
- package/dist/esm/middlewares/cookies.mjs.map +1 -1
- package/dist/esm/middlewares/headers.mjs.map +1 -1
- package/dist/esm/register.d.mts +0 -1
- package/dist/esm/register.mjs +2 -3
- package/dist/esm/register.mjs.map +1 -1
- package/dist/esm/routes/_load.mjs.map +1 -1
- package/dist/esm/routes/oauth/callback.post.mjs +1 -1
- package/dist/esm/routes/oauth/callback.post.mjs.map +1 -1
- package/dist/esm/routes/oauth/logout.post.mjs.map +1 -1
- package/package.json +14 -12
- package/dist/cjs/lib/structures/MediaParser.cjs +0 -79
- package/dist/cjs/lib/structures/MediaParser.cjs.map +0 -1
- package/dist/cjs/lib/structures/MediaParserStore.cjs +0 -27
- package/dist/cjs/lib/structures/MediaParserStore.cjs.map +0 -1
- package/dist/cjs/lib/utils/MimeTypes.cjs +0 -26
- package/dist/cjs/lib/utils/MimeTypes.cjs.map +0 -1
- package/dist/cjs/mediaParsers/_load.cjs +0 -20
- package/dist/cjs/mediaParsers/_load.cjs.map +0 -1
- package/dist/cjs/mediaParsers/applicationFormUrlEncoded.cjs +0 -23
- package/dist/cjs/mediaParsers/applicationFormUrlEncoded.cjs.map +0 -1
- package/dist/cjs/mediaParsers/applicationJson.cjs +0 -22
- package/dist/cjs/mediaParsers/applicationJson.cjs.map +0 -1
- package/dist/cjs/mediaParsers/textPlain.cjs +0 -22
- package/dist/cjs/mediaParsers/textPlain.cjs.map +0 -1
- package/dist/esm/lib/structures/MediaParser.mjs +0 -76
- package/dist/esm/lib/structures/MediaParser.mjs.map +0 -1
- package/dist/esm/lib/structures/MediaParserStore.mjs +0 -24
- package/dist/esm/lib/structures/MediaParserStore.mjs.map +0 -1
- package/dist/esm/lib/utils/MimeTypes.mjs +0 -26
- package/dist/esm/lib/utils/MimeTypes.mjs.map +0 -1
- package/dist/esm/mediaParsers/_load.mjs +0 -17
- package/dist/esm/mediaParsers/_load.mjs.map +0 -1
- package/dist/esm/mediaParsers/applicationFormUrlEncoded.mjs +0 -20
- package/dist/esm/mediaParsers/applicationFormUrlEncoded.mjs.map +0 -1
- package/dist/esm/mediaParsers/applicationJson.mjs +0 -19
- package/dist/esm/mediaParsers/applicationJson.mjs.map +0 -1
- package/dist/esm/mediaParsers/textPlain.mjs +0 -19
- package/dist/esm/mediaParsers/textPlain.mjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/lib/utils/_body/RequestURLProxy.ts"],"names":[],"mappings":";;;;AAAA,IAAA,SAAA,EAAA,SAAA,EAAA,KAAA,EAAA,SAAA,EAAA,OAAA,EAAA,aAAA,EAAA,QAAA;AAIO,IAAM,gBAAA,GAAN,MAAM,gBAA+B,CAAA;AAAA,EAepC,YAAY,OAAqB,EAAA;AAdxC,IAAA,aAAA,CAAA,IAAA,EAAO,MAAe,EAAA,EAAA,CAAA;AACtB,IAAA,aAAA,CAAA,IAAA,EAAO,UAAmB,EAAA,EAAA,CAAA;AAC1B,IAAA,aAAA,CAAA,IAAA,EAAO,UAAmB,EAAA,EAAA,CAAA;AAE1B,IAAgC,YAAA,CAAA,IAAA,EAAA,SAAA,EAAA,IAAA,CAAA;AAChC,IAA2B,YAAA,CAAA,IAAA,EAAA,SAAA,EAAA,IAAA,CAAA;AAC3B,IAAuB,YAAA,CAAA,IAAA,EAAA,KAAA,EAAA,IAAA,CAAA;AAEvB,IAA2B,YAA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A,CAAW,MAAM,GAAG,CAAA;AAC/C,EAAM,MAAA,KAAA,GAAQ,GAAI,CAAA,OAAA,CAAQ,GAAG,CAAA;AAC7B,EAAA,IAAI,UAAU,CAAI,CAAA,EAAA;AACjB,IAAO,OAAA,CAAC,KAAK,EAAE,CAAA;AAAA;AAGhB,EAAO,OAAA,CAAC,IAAI,KAAM,CAAA,CAAA,EAAG,KAAK,CAAG,EAAA,GAAA,CAAI,KAAM,CAAA,KAAK,CAAC,CAAA;AAC9C;AARS,MAAA,CAAA,SAAA,EAAA,WAAA,CAAA;AAUT,SAAS,UAAU,IAA4D,EAAA;AAC9E,EAAI,IAAA,gBAAA,CAAiB,IAAI,CAAG,EAAA;AAC3B,IAAO,OAAA,CAAC,aAAa,CAAE,CAAA,CAAA;AAAA;AAGxB,EAAM,MAAA,KAAA,GAAQ,IAAK,CAAA,OAAA,CAAQ,GAAG,CAAA;AAC9B,EAAA,IAAI,UAAU,CAAI,CAAA,EAAA;AACjB,IAAO,OAAA,CAAC,MAAM,CAAE,CAAA,CAAA;AAAA;AAGjB,EAAA,MAAM,IAAO,GAAA,MAAA,CAAO,IAAK,CAAA,KAAA,CAAM,KAAK,CAAC,CAAA;AACrC,EAAO,OAAA,CAAC,IAAK,CAAA,KAAA,CAAM,CAAG,EAAA,KAAK,CAAG,EAAA,MAAA,CAAO,aAAc,CAAA,IAAI,CAAI,GAAA,IAAA,GAAO,CAAE,CAAA,CAAA;AACrE;AAZS,MAAA,CAAA,SAAA,EAAA,WAAA,CAAA","file":"RequestURLProxy.mjs","sourcesContent":["import { isNullishOrEmpty } from '@sapphire/utilities';\nimport type { ApiRequest } from '../../structures/api/ApiRequest';\nimport { NodeUtilInspectSymbol } from '../constants';\n\nexport class RequestURLProxy implements URL {\n\tpublic hash: string = '';\n\tpublic password: string = '';\n\tpublic username: string = '';\n\n\t#protocol: URLProtocol | null = null;\n\t#hostname: string | null = null;\n\t#port: string | null = null;\n\n\t#pathname: string | null = null;\n\t#search: string | null = null;\n\t#searchParams: URLSearchParams | null = null;\n\n\treadonly #request: ApiRequest;\n\n\tpublic constructor(request: ApiRequest) {\n\t\tthis.#request = request;\n\t}\n\n\tpublic get host(): string {\n\t\treturn this.#request.headers.host ?? '';\n\t}\n\n\tpublic set host(value: string) {\n\t\tthis.#hostname = null;\n\t\tthis.#port = null;\n\t\tthis.#request.headers.host = value;\n\t}\n\n\tpublic get hostname(): string {\n\t\tif (this.#hostname === null) {\n\t\t\tconst [hostname, port] = parseHost(this.#request.headers.host);\n\t\t\tthis.#hostname = hostname;\n\t\t\tthis.#port = port === -1 ? '' : String(port);\n\t\t}\n\n\t\treturn this.#hostname;\n\t}\n\n\tpublic set hostname(value: string) {\n\t\tthis.#hostname = value;\n\t}\n\n\tpublic get port(): string {\n\t\tif (this.#port === null) {\n\t\t\tconst [hostname, port] = parseHost(this.#request.headers.host);\n\t\t\tthis.#hostname = hostname;\n\t\t\tthis.#port = port === -1 ? String(this.#request.socket.localPort ?? '') : String(port);\n\t\t}\n\n\t\treturn this.#port;\n\t}\n\n\tpublic set port(value: string) {\n\t\tthis.#port = String(Number(value || ''));\n\t}\n\n\tpublic get pathname(): string {\n\t\tif (this.#pathname === null) {\n\t\t\tconst [pathname, search] = parsePath(this.#request.url);\n\t\t\tthis.#pathname = pathname;\n\t\t\tthis.#search ??= search;\n\t\t}\n\n\t\treturn this.#pathname;\n\t}\n\n\tpublic set pathname(value: string) {\n\t\tconst normalized = value.startsWith('/') ? value : `/${value}`;\n\t\tif (normalized === this.#pathname) return;\n\n\t\tthis.#pathname = normalized;\n\t\tthis.#request.url = normalized + this.search;\n\t}\n\n\tpublic get search(): string {\n\t\tif (this.#search === null) {\n\t\t\tconst [pathname, search] = parsePath(this.#request.url);\n\t\t\tthis.#pathname ??= pathname;\n\t\t\tthis.#search = search;\n\t\t}\n\n\t\treturn this.#search;\n\t}\n\n\tpublic set search(value: string) {\n\t\tlet normalized: string;\n\t\tif (value === '?') {\n\t\t\tnormalized = '';\n\t\t} else if (value && !value.startsWith('?')) {\n\t\t\tnormalized = `?${value}`;\n\t\t} else {\n\t\t\tnormalized = value;\n\t\t}\n\n\t\tif (normalized === this.#search) return;\n\n\t\tthis.#search = normalized;\n\t\tthis.#searchParams = null;\n\t\tthis.#request.url = this.pathname + normalized;\n\t}\n\n\tpublic get searchParams(): URLSearchParams {\n\t\tthis.#searchParams ??= new URLSearchParams(this.search);\n\t\treturn this.#searchParams;\n\t}\n\n\tpublic set searchParams(value: URLSearchParams) {\n\t\tthis.#searchParams = value;\n\t\tthis.search = value.toString();\n\t}\n\n\tpublic get protocol(): URLProtocol {\n\t\tthis.#protocol ??= (this.#request.socket as any).encrypted || this.#request.headers['x-forwarded-proto'] === 'https' ? 'https:' : 'http:';\n\t\treturn this.#protocol;\n\t}\n\n\tpublic set protocol(value: URLProtocol) {\n\t\tthis.#protocol = value;\n\t}\n\n\tpublic get origin(): string {\n\t\treturn `${this.protocol}//${this.host}`;\n\t}\n\n\tpublic set origin(_value: string) {\n\t\t// No-op\n\t}\n\n\tpublic get href(): string {\n\t\treturn `${this.protocol}//${this.host}${this.pathname}${this.search}`;\n\t}\n\n\tpublic set href(value: string) {\n\t\tconst url = new URL(value);\n\t\tthis.#protocol = url.protocol as URLProtocol;\n\t\tthis.username = url.username;\n\t\tthis.password = url.password;\n\t\tthis.#hostname = url.hostname;\n\t\tthis.#port = url.port;\n\t\tthis.#pathname = url.pathname;\n\t\tthis.#search = url.search;\n\t\tthis.hash = url.hash;\n\t}\n\n\tpublic toString(): string {\n\t\treturn this.href;\n\t}\n\n\tpublic toJSON(): string {\n\t\treturn this.href;\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/class-literal-property-style\n\tpublic get [Symbol.toStringTag]() {\n\t\treturn 'URL';\n\t}\n\n\tpublic [NodeUtilInspectSymbol]() {\n\t\treturn this.href;\n\t}\n}\n\nexport type URLProtocol = 'https:' | 'http:';\n\nfunction parsePath(input: string | undefined): [pathname: string, search: string] {\n\tconst url = (input ?? '/').replaceAll('\\\\', '/');\n\tconst index = url.indexOf('?');\n\tif (index === -1) {\n\t\treturn [url, ''];\n\t}\n\n\treturn [url.slice(0, index), url.slice(index)];\n}\n\nfunction parseHost(host: string | undefined): [hostname: string, port: number] {\n\tif (isNullishOrEmpty(host)) {\n\t\treturn ['localhost', -1];\n\t}\n\n\tconst index = host.indexOf(':');\n\tif (index === -1) {\n\t\treturn [host, -1];\n\t}\n\n\tconst port = Number(host.slice(index));\n\treturn [host.slice(0, index), Number.isSafeInteger(port) ? port : -1];\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/utils/constants.ts"],"names":[],"mappings":";;;AAAa,IAAA,qBAAA,GAAwB,MAAO,CAAA,GAAA,CAAI,4BAA4B","file":"constants.mjs","sourcesContent":["export const NodeUtilInspectSymbol = Symbol.for('nodejs.util.inspect.custom');\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/listeners/PluginRouteError.ts"],"names":[],"mappings":";;;;;AAMO,IAAM,eAAA,GAAN,MAAM,eAAA,SAAuB,QAAS,CAAA;AAAA,EACrC,YAAY,OAAiC,EAAA;AACnD,IAAA,KAAA,CAAM,SAAS,EAAE,OAAA,EAAS,UAAU,KAAO,EAAA,WAAA,CAAY,YAAY,CAAA
|
|
1
|
+
{"version":3,"sources":["../../../src/listeners/PluginRouteError.ts"],"names":[],"mappings":";;;;;AAMO,IAAM,eAAA,GAAN,MAAM,eAAA,SAAuB,QAAS,CAAA;AAAA,EACrC,YAAY,OAAiC,EAAA;AACnD,IAAA,KAAA,CAAM,SAAS,EAAE,OAAA,EAAS,UAAU,KAAO,EAAA,WAAA,CAAY,YAAY,CAAA;AAAA;AACpE,EAEgB,GAAA,CAAI,KAAc,EAAA,QAAA,EAAsB,QAAuB,EAAA;AAE9E,IAAK,IAAA,CAAA,SAAA,CAAU,MAAO,CAAA,KAAA,CAAM,KAAK,CAAA;AAGjC,IAAA,IAAI,CAAC,QAAA,CAAS,aAAe,EAAA,QAAA,CAAS,OAAO,SAAU,CAAA,mBAAmB,CAAE,CAAA,IAAA,CAAK,EAAE,KAAA,EAAO,KAAM,CAAA,OAAA,IAAW,OAAO,CAAA;AAAA;AAEpH,CAAA;AAZ6C,MAAA,CAAA,eAAA,EAAA,gBAAA,CAAA;AAAtC,IAAM,cAAN,GAAA","file":"PluginRouteError.mjs","sourcesContent":["import { Listener } from '@sapphire/framework';\nimport type { ApiRequest } from '../lib/structures/api/ApiRequest';\nimport type { ApiResponse } from '../lib/structures/api/ApiResponse';\nimport { HttpCodes } from '../lib/structures/http/HttpCodes';\nimport { ServerEvent } from '../lib/structures/http/Server';\n\nexport class PluginListener extends Listener {\n\tpublic constructor(context: Listener.LoaderContext) {\n\t\tsuper(context, { emitter: 'server', event: ServerEvent.RouteError });\n\t}\n\n\tpublic override run(error: Error, _request: ApiRequest, response: ApiResponse) {\n\t\t// Log the error to console:\n\t\tthis.container.logger.fatal(error);\n\n\t\t// Send a response to the client if none was sent:\n\t\tif (!response.writableEnded) response.status(HttpCodes.InternalServerError).json({ error: error.message ?? error });\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/listeners/PluginServerMiddlewareError.ts"],"names":[],"mappings":";;;;;AAMO,IAAM,eAAA,GAAN,MAAM,eAAA,SAAuB,QAAS,CAAA;AAAA,EACrC,YAAY,OAAiC,EAAA;AACnD,IAAA,KAAA,CAAM,SAAS,EAAE,OAAA,EAAS,UAAU,KAAO,EAAA,WAAA,CAAY,iBAAiB,CAAA
|
|
1
|
+
{"version":3,"sources":["../../../src/listeners/PluginServerMiddlewareError.ts"],"names":[],"mappings":";;;;;AAMO,IAAM,eAAA,GAAN,MAAM,eAAA,SAAuB,QAAS,CAAA;AAAA,EACrC,YAAY,OAAiC,EAAA;AACnD,IAAA,KAAA,CAAM,SAAS,EAAE,OAAA,EAAS,UAAU,KAAO,EAAA,WAAA,CAAY,iBAAiB,CAAA;AAAA;AACzE,EAEgB,GAAA,CAAI,KAAc,EAAA,QAAA,EAAsB,QAAuB,EAAA;AAE9E,IAAK,IAAA,CAAA,SAAA,CAAU,MAAO,CAAA,KAAA,CAAM,KAAK,CAAA;AAGjC,IAAA,IAAI,CAAC,QAAA,CAAS,aAAe,EAAA,QAAA,CAAS,OAAO,SAAU,CAAA,mBAAmB,CAAE,CAAA,IAAA,CAAK,EAAE,KAAA,EAAO,KAAM,CAAA,OAAA,IAAW,OAAO,CAAA;AAAA;AAEpH,CAAA;AAZ6C,MAAA,CAAA,eAAA,EAAA,gBAAA,CAAA;AAAtC,IAAM,cAAN,GAAA","file":"PluginServerMiddlewareError.mjs","sourcesContent":["import { Listener } from '@sapphire/framework';\nimport type { ApiRequest } from '../lib/structures/api/ApiRequest';\nimport type { ApiResponse } from '../lib/structures/api/ApiResponse';\nimport { HttpCodes } from '../lib/structures/http/HttpCodes';\nimport { ServerEvent } from '../lib/structures/http/Server';\n\nexport class PluginListener extends Listener {\n\tpublic constructor(context: Listener.LoaderContext) {\n\t\tsuper(context, { emitter: 'server', event: ServerEvent.MiddlewareError });\n\t}\n\n\tpublic override run(error: Error, _request: ApiRequest, response: ApiResponse) {\n\t\t// Log the error to console:\n\t\tthis.container.logger.fatal(error);\n\n\t\t// Send a response to the client if none was sent:\n\t\tif (!response.writableEnded) response.status(HttpCodes.InternalServerError).json({ error: error.message ?? error });\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/listeners/PluginServerMiddlewareSuccess.ts"],"names":[],"mappings":";;;;AAKO,IAAM,eAAA,GAAN,MAAM,eAAA,SAAuB,QAAS,CAAA;AAAA,EACrC,YAAY,OAAiC,EAAA;AACnD,IAAA,KAAA,CAAM,SAAS,EAAE,OAAA,EAAS,UAAU,KAAO,EAAA,WAAA,CAAY,mBAAmB,CAAA
|
|
1
|
+
{"version":3,"sources":["../../../src/listeners/PluginServerMiddlewareSuccess.ts"],"names":[],"mappings":";;;;AAKO,IAAM,eAAA,GAAN,MAAM,eAAA,SAAuB,QAAS,CAAA;AAAA,EACrC,YAAY,OAAiC,EAAA;AACnD,IAAA,KAAA,CAAM,SAAS,EAAE,OAAA,EAAS,UAAU,KAAO,EAAA,WAAA,CAAY,mBAAmB,CAAA;AAAA;AAC3E,EAEA,MAAsB,GAAI,CAAA,OAAA,EAAqB,QAAuB,EAAA;AACrE,IAAI,IAAA;AACH,MAAA,MAAM,OAAQ,CAAA,KAAA,CAAO,GAAI,CAAA,OAAA,EAAS,QAAQ,CAAA;AAAA,aAClC,KAAO,EAAA;AACf,MAAA,IAAA,CAAK,UAAU,MAAO,CAAA,IAAA,CAAK,YAAY,UAAY,EAAA,KAAA,EAAgB,SAAS,QAAQ,CAAA;AAAA;AACrF;AAEF,CAAA;AAZ6C,MAAA,CAAA,eAAA,EAAA,gBAAA,CAAA;AAAtC,IAAM,cAAN,GAAA","file":"PluginServerMiddlewareSuccess.mjs","sourcesContent":["import { Listener } from '@sapphire/framework';\nimport type { ApiRequest } from '../lib/structures/api/ApiRequest';\nimport type { ApiResponse } from '../lib/structures/api/ApiResponse';\nimport { ServerEvent } from '../lib/structures/http/Server';\n\nexport class PluginListener extends Listener {\n\tpublic constructor(context: Listener.LoaderContext) {\n\t\tsuper(context, { emitter: 'server', event: ServerEvent.MiddlewareSuccess });\n\t}\n\n\tpublic override async run(request: ApiRequest, response: ApiResponse) {\n\t\ttry {\n\t\t\tawait request.route!.run(request, response);\n\t\t} catch (error) {\n\t\t\tthis.container.server.emit(ServerEvent.RouteError, error as Error, request, response);\n\t\t}\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/listeners/PluginServerRequest.ts"],"names":[],"mappings":";;;;;AAAA,IAAA,yBAAA,EAAA,WAAA
|
|
1
|
+
{"version":3,"sources":["../../../src/listeners/PluginServerRequest.ts"],"names":[],"mappings":";;;;;AAAA,IAAA,yBAAA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est';\nimport type { ApiResponse } from '../lib/structures/api/ApiResponse';\nimport type { MethodName } from '../lib/structures/http/HttpMethods';\nimport { ServerEvent } from '../lib/structures/http/Server';\nimport { RouterRoot } from '../lib/structures/router/RouterRoot';\n\nexport class PluginListener extends Listener {\n\tpublic constructor(context: Listener.LoaderContext) {\n\t\tsuper(context, { emitter: 'server', event: ServerEvent.Request });\n\t}\n\n\tpublic override async run(request: ApiRequest, response: ApiResponse) {\n\t\tconst { parts, querystring } = this.#parseURL(request.url);\n\t\trequest.query = Object.fromEntries(new URLSearchParams(querystring).entries());\n\n\t\tconst branch = this.container.server.routes.router.find(parts);\n\t\tconst node = branch ? branch.node : null;\n\t\tconst route = node ? node.get((request.method ?? 'GET') as MethodName) : null;\n\n\t\tif (node !== null) {\n\t\t\trequest.params = node!.extractParameters(parts);\n\t\t}\n\n\t\trequest.routerNode = node;\n\t\trequest.route = route;\n\n\t\ttry {\n\t\t\t// Middlewares need to be run regardless of the match, specially since browsers do an OPTIONS request first.\n\t\t\tawait this.container.server.middlewares.run(request, response);\n\t\t} catch (error) {\n\t\t\tthis.container.server.emit(ServerEvent.MiddlewareError, error as Error, request, response);\n\n\t\t\t// If a middleware errored, it might cause undefined behavior in the routes, so we will return early.\n\t\t\treturn;\n\t\t}\n\n\t\tif (branch === null) {\n\t\t\tthis.container.server.emit(ServerEvent.RouterBranchNotFound, request, response);\n\t\t} else if (route === null) {\n\t\t\tthis.container.server.emit(ServerEvent.RouterBranchMethodNotAllowed, request, response, branch);\n\t\t} else {\n\t\t\tthis.container.server.emit(ServerEvent.RouterFound, request, response);\n\t\t}\n\t}\n\n\t#parseURL(url = '') {\n\t\tconst index = url.indexOf('?');\n\n\t\tlet pathname: string;\n\t\tlet querystring: string;\n\t\tif (index === -1) {\n\t\t\tpathname = url;\n\t\t\tquerystring = '';\n\t\t} else {\n\t\t\tpathname = url.substring(0, index);\n\t\t\tquerystring = url.substring(index + 1);\n\t\t}\n\n\t\treturn { parts: RouterRoot.normalize(pathname), querystring };\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/listeners/PluginServerRouterBranchMethodNotAllowed.ts"],"names":[],"mappings":";;;;AAKO,IAAM,eAAA,GAAN,MAAM,eAAA,SAAuB,QAAS,CAAA;AAAA,EACrC,YAAY,OAAiC,EAAA;AACnD,IAAA,KAAA,CAAM,SAAS,EAAE,OAAA,EAAS,UAAU,KAAO,EAAA,WAAA,CAAY,8BAA8B,CAAA
|
|
1
|
+
{"version":3,"sources":["../../../src/listeners/PluginServerRouterBranchMethodNotAllowed.ts"],"names":[],"mappings":";;;;AAKO,IAAM,eAAA,GAAN,MAAM,eAAA,SAAuB,QAAS,CAAA;AAAA,EACrC,YAAY,OAAiC,EAAA;AACnD,IAAA,KAAA,CAAM,SAAS,EAAE,OAAA,EAAS,UAAU,KAAO,EAAA,WAAA,CAAY,8BAA8B,CAAA;AAAA;AACtF,EAEgB,GAAA,CAAI,GAAe,QAAuB,EAAA;AACzD,IAAA,IAAI,CAAC,QAAA,CAAS,aAAe,EAAA,QAAA,CAAS,gBAAiB,EAAA;AAAA;AAEzD,CAAA;AAR6C,MAAA,CAAA,eAAA,EAAA,gBAAA,CAAA;AAAtC,IAAM,cAAN,GAAA","file":"PluginServerRouterBranchMethodNotAllowed.mjs","sourcesContent":["import { Listener } from '@sapphire/framework';\nimport type { ApiRequest } from '../lib/structures/api/ApiRequest';\nimport type { ApiResponse } from '../lib/structures/api/ApiResponse';\nimport { ServerEvent } from '../lib/structures/http/Server';\n\nexport class PluginListener extends Listener {\n\tpublic constructor(context: Listener.LoaderContext) {\n\t\tsuper(context, { emitter: 'server', event: ServerEvent.RouterBranchMethodNotAllowed });\n\t}\n\n\tpublic override run(_: ApiRequest, response: ApiResponse) {\n\t\tif (!response.writableEnded) response.methodNotAllowed();\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/listeners/PluginServerRouterBranchNotFound.ts"],"names":[],"mappings":";;;;AAKO,IAAM,eAAA,GAAN,MAAM,eAAA,SAAuB,QAAS,CAAA;AAAA,EACrC,YAAY,OAAiC,EAAA;AACnD,IAAA,KAAA,CAAM,SAAS,EAAE,OAAA,EAAS,UAAU,KAAO,EAAA,WAAA,CAAY,sBAAsB,CAAA
|
|
1
|
+
{"version":3,"sources":["../../../src/listeners/PluginServerRouterBranchNotFound.ts"],"names":[],"mappings":";;;;AAKO,IAAM,eAAA,GAAN,MAAM,eAAA,SAAuB,QAAS,CAAA;AAAA,EACrC,YAAY,OAAiC,EAAA;AACnD,IAAA,KAAA,CAAM,SAAS,EAAE,OAAA,EAAS,UAAU,KAAO,EAAA,WAAA,CAAY,sBAAsB,CAAA;AAAA;AAC9E,EAEgB,GAAA,CAAI,GAAe,QAAuB,EAAA;AACzD,IAAA,IAAI,CAAC,QAAA,CAAS,aAAe,EAAA,QAAA,CAAS,QAAS,EAAA;AAAA;AAEjD,CAAA;AAR6C,MAAA,CAAA,eAAA,EAAA,gBAAA,CAAA;AAAtC,IAAM,cAAN,GAAA","file":"PluginServerRouterBranchNotFound.mjs","sourcesContent":["import { Listener } from '@sapphire/framework';\nimport type { ApiRequest } from '../lib/structures/api/ApiRequest';\nimport type { ApiResponse } from '../lib/structures/api/ApiResponse';\nimport { ServerEvent } from '../lib/structures/http/Server';\n\nexport class PluginListener extends Listener {\n\tpublic constructor(context: Listener.LoaderContext) {\n\t\tsuper(context, { emitter: 'server', event: ServerEvent.RouterBranchNotFound });\n\t}\n\n\tpublic override run(_: ApiRequest, response: ApiResponse) {\n\t\tif (!response.writableEnded) response.notFound();\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/listeners/PluginServerRouterFound.ts"],"names":[],"mappings":";;;;AAKO,IAAM,eAAA,GAAN,MAAM,eAAA,SAAuB,QAAS,CAAA;AAAA,EACrC,YAAY,OAAiC,EAAA;AACnD,IAAA,KAAA,CAAM,SAAS,EAAE,OAAA,EAAS,UAAU,KAAO,EAAA,WAAA,CAAY,aAAa,CAAA
|
|
1
|
+
{"version":3,"sources":["../../../src/listeners/PluginServerRouterFound.ts"],"names":[],"mappings":";;;;AAKO,IAAM,eAAA,GAAN,MAAM,eAAA,SAAuB,QAAS,CAAA;AAAA,EACrC,YAAY,OAAiC,EAAA;AACnD,IAAA,KAAA,CAAM,SAAS,EAAE,OAAA,EAAS,UAAU,KAAO,EAAA,WAAA,CAAY,aAAa,CAAA;AAAA;AACrE,EAEgB,GAAA,CAAI,SAAqB,QAAuB,EAAA;AAC/D,IAAA,MAAM,KAAQ,GAAA,QAAA,CAAS,aAAgB,GAAA,WAAA,CAAY,oBAAoB,WAAY,CAAA,iBAAA;AACnF,IAAA,IAAA,CAAK,SAAU,CAAA,MAAA,CAAO,IAAK,CAAA,KAAA,EAAO,SAAS,QAAQ,CAAA;AAAA;AAErD,CAAA;AAT6C,MAAA,CAAA,eAAA,EAAA,gBAAA,CAAA;AAAtC,IAAM,cAAN,GAAA","file":"PluginServerRouterFound.mjs","sourcesContent":["import { Listener } from '@sapphire/framework';\nimport type { ApiRequest } from '../lib/structures/api/ApiRequest';\nimport type { ApiResponse } from '../lib/structures/api/ApiResponse';\nimport { ServerEvent } from '../lib/structures/http/Server';\n\nexport class PluginListener extends Listener {\n\tpublic constructor(context: Listener.LoaderContext) {\n\t\tsuper(context, { emitter: 'server', event: ServerEvent.RouterFound });\n\t}\n\n\tpublic override run(request: ApiRequest, response: ApiResponse) {\n\t\tconst event = response.writableEnded ? ServerEvent.MiddlewareFailure : ServerEvent.MiddlewareSuccess;\n\t\tthis.container.server.emit(event, request, response);\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/listeners/_load.ts"],"names":["PluginRouteError","PluginServerMiddlewareError","PluginServerMiddlewareSuccess","PluginServerRequest","PluginServerRouterBranchMethodNotAllowed","PluginServerRouterBranchNotFound","PluginServerRouterFound"],"mappings":";;;;;;;;;;AASO,SAAS,aAAgB,GAAA;AAC/B,EAAA,MAAM,KAAQ,GAAA,WAAA
|
|
1
|
+
{"version":3,"sources":["../../../src/listeners/_load.ts"],"names":["PluginRouteError","PluginServerMiddlewareError","PluginServerMiddlewareSuccess","PluginServerRequest","PluginServerRouterBranchMethodNotAllowed","PluginServerRouterBranchNotFound","PluginServerRouterFound"],"mappings":";;;;;;;;;;AASO,SAAS,aAAgB,GAAA;AAC/B,EAAA,MAAM,KAAQ,GAAA,WAAA;AACd,EAAK,KAAA,SAAA,CAAU,OAAO,SAAU,CAAA,EAAE,MAAM,kBAAoB,EAAA,KAAA,EAAOA,cAAkB,EAAA,KAAA,EAAO,CAAA;AAC5F,EAAK,KAAA,SAAA,CAAU,OAAO,SAAU,CAAA,EAAE,MAAM,6BAA+B,EAAA,KAAA,EAAOC,gBAA6B,EAAA,KAAA,EAAO,CAAA;AAClH,EAAK,KAAA,SAAA,CAAU,OAAO,SAAU,CAAA,EAAE,MAAM,+BAAiC,EAAA,KAAA,EAAOC,gBAA+B,EAAA,KAAA,EAAO,CAAA;AACtH,EAAK,KAAA,SAAA,CAAU,OAAO,SAAU,CAAA,EAAE,MAAM,qBAAuB,EAAA,KAAA,EAAOC,gBAAqB,EAAA,KAAA,EAAO,CAAA;AAClG,EAAK,KAAA,SAAA,CAAU,OAAO,SAAU,CAAA,EAAE,MAAM,0CAA4C,EAAA,KAAA,EAAOC,gBAA0C,EAAA,KAAA,EAAO,CAAA;AAC5I,EAAK,KAAA,SAAA,CAAU,OAAO,SAAU,CAAA,EAAE,MAAM,kCAAoC,EAAA,KAAA,EAAOC,gBAAkC,EAAA,KAAA,EAAO,CAAA;AAC5H,EAAK,KAAA,SAAA,CAAU,OAAO,SAAU,CAAA,EAAE,MAAM,yBAA2B,EAAA,KAAA,EAAOC,gBAAyB,EAAA,KAAA,EAAO,CAAA;AAC3G;AATgB,MAAA,CAAA,aAAA,EAAA,eAAA,CAAA","file":"_load.mjs","sourcesContent":["import { container } from '@sapphire/pieces';\nimport { PluginListener as PluginRouteError } from './PluginRouteError';\nimport { PluginListener as PluginServerMiddlewareError } from './PluginServerMiddlewareError';\nimport { PluginListener as PluginServerMiddlewareSuccess } from './PluginServerMiddlewareSuccess';\nimport { PluginListener as PluginServerRequest } from './PluginServerRequest';\nimport { PluginListener as PluginServerRouterBranchMethodNotAllowed } from './PluginServerRouterBranchMethodNotAllowed';\nimport { PluginListener as PluginServerRouterBranchNotFound } from './PluginServerRouterBranchNotFound';\nimport { PluginListener as PluginServerRouterFound } from './PluginServerRouterFound';\n\nexport function loadListeners() {\n\tconst store = 'listeners';\n\tvoid container.stores.loadPiece({ name: 'PluginRouteError', piece: PluginRouteError, store });\n\tvoid container.stores.loadPiece({ name: 'PluginServerMiddlewareError', piece: PluginServerMiddlewareError, store });\n\tvoid container.stores.loadPiece({ name: 'PluginServerMiddlewareSuccess', piece: PluginServerMiddlewareSuccess, store });\n\tvoid container.stores.loadPiece({ name: 'PluginServerRequest', piece: PluginServerRequest, store });\n\tvoid container.stores.loadPiece({ name: 'PluginServerRouterBranchMethodNotAllowed', piece: PluginServerRouterBranchMethodNotAllowed, store });\n\tvoid container.stores.loadPiece({ name: 'PluginServerRouterBranchNotFound', piece: PluginServerRouterBranchNotFound, store });\n\tvoid container.stores.loadPiece({ name: 'PluginServerRouterFound', piece: PluginServerRouterFound, store });\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/middlewares/_load.ts"],"names":["PluginAuth","PluginBody","PluginCookies","PluginHeaders"],"mappings":";;;;;;;AAMO,SAAS,eAAkB,GAAA;AACjC,EAAA,MAAM,KAAQ,GAAA,aAAA
|
|
1
|
+
{"version":3,"sources":["../../../src/middlewares/_load.ts"],"names":["PluginAuth","PluginBody","PluginCookies","PluginHeaders"],"mappings":";;;;;;;AAMO,SAAS,eAAkB,GAAA;AACjC,EAAA,MAAM,KAAQ,GAAA,aAAA;AACd,EAAK,KAAA,SAAA,CAAU,OAAO,SAAU,CAAA,EAAE,MAAM,MAAQ,EAAA,KAAA,EAAOA,gBAAY,EAAA,KAAA,EAAO,CAAA;AAC1E,EAAK,KAAA,SAAA,CAAU,OAAO,SAAU,CAAA,EAAE,MAAM,MAAQ,EAAA,KAAA,EAAOC,kBAAY,EAAA,KAAA,EAAO,CAAA;AAC1E,EAAK,KAAA,SAAA,CAAU,OAAO,SAAU,CAAA,EAAE,MAAM,SAAW,EAAA,KAAA,EAAOC,kBAAe,EAAA,KAAA,EAAO,CAAA;AAChF,EAAK,KAAA,SAAA,CAAU,OAAO,SAAU,CAAA,EAAE,MAAM,SAAW,EAAA,KAAA,EAAOC,kBAAe,EAAA,KAAA,EAAO,CAAA;AACjF;AANgB,MAAA,CAAA,eAAA,EAAA,iBAAA,CAAA","file":"_load.mjs","sourcesContent":["import { container } from '@sapphire/pieces';\nimport { PluginMiddleware as PluginAuth } from './auth';\nimport { PluginMiddleware as PluginBody } from './body';\nimport { PluginMiddleware as PluginCookies } from './cookies';\nimport { PluginMiddleware as PluginHeaders } from './headers';\n\nexport function loadMiddlewares() {\n\tconst store = 'middlewares';\n\tvoid container.stores.loadPiece({ name: 'auth', piece: PluginAuth, store });\n\tvoid container.stores.loadPiece({ name: 'body', piece: PluginBody, store });\n\tvoid container.stores.loadPiece({ name: 'cookies', piece: PluginCookies, store });\n\tvoid container.stores.loadPiece({ name: 'headers', piece: PluginHeaders, store });\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/middlewares/auth.ts"],"names":[],"mappings":";;;AAEO,IAAM,iBAAA,GAAN,MAAM,iBAAA,SAAyB,UAAW,CAAA;AAAA,EAGzC,YAAY,OAAmC,EAAA;AACrD,IAAA,KAAA,CAAM,OAAS,EAAA,EAAE,QAAU,EAAA,EAAA,EAAI,CAAA
|
|
1
|
+
{"version":3,"sources":["../../../src/middlewares/auth.ts"],"names":[],"mappings":";;;AAEO,IAAM,iBAAA,GAAN,MAAM,iBAAA,SAAyB,UAAW,CAAA;AAAA,EAGzC,YAAY,OAAmC,EAAA;AACrD,IAAA,KAAA,CAAM,OAAS,EAAA,EAAE,QAAU,EAAA,EAAA,EAAI,CAAA;AAHhC,IAAiB,aAAA,CAAA,IAAA,EAAA,YAAA,CAAA;AAKhB,IAAM,MAAA,EAAE,MAAO,EAAA,GAAI,IAAK,CAAA,SAAA;AACxB,IAAK,IAAA,CAAA,UAAA,GAAa,MAAO,CAAA,IAAA,EAAM,MAAU,IAAA,eAAA;AACzC,IAAK,IAAA,CAAA,OAAA,GAAU,OAAO,IAAS,KAAA,IAAA;AAAA;AAChC,EAEgB,GAAA,CAAI,SAA6B,QAA+B,EAAA;AAE/E,IAAA,MAAM,aAAgB,GAAA,QAAA,CAAS,OAAQ,CAAA,GAAA,CAAI,KAAK,UAAU,CAAA;AAC1D,IAAA,IAAI,CAAC,aAAe,EAAA;AACnB,MAAA,OAAA,CAAQ,IAAO,GAAA,IAAA;AACf,MAAA;AAAA;AAID,IAAA,OAAA,CAAQ,OAAO,IAAK,CAAA,SAAA,CAAU,MAAO,CAAA,IAAA,CAAM,QAAQ,aAAa,CAAA;AAChE,IAAA,IAAI,QAAQ,IAAS,KAAA,IAAA,WAAe,OAAQ,CAAA,MAAA,CAAO,KAAK,UAAU,CAAA;AAAA;AAEpE,CAAA;AAvBiD,MAAA,CAAA,iBAAA,EAAA,kBAAA,CAAA;AAA1C,IAAM,gBAAN,GAAA","file":"auth.mjs","sourcesContent":["import { Middleware } from '../lib/structures/Middleware';\n\nexport class PluginMiddleware extends Middleware {\n\tprivate readonly cookieName: string;\n\n\tpublic constructor(context: Middleware.LoaderContext) {\n\t\tsuper(context, { position: 40 });\n\n\t\tconst { server } = this.container;\n\t\tthis.cookieName = server.auth?.cookie ?? 'SAPPHIRE_AUTH';\n\t\tthis.enabled = server.auth !== null;\n\t}\n\n\tpublic override run(request: Middleware.Request, response: Middleware.Response) {\n\t\t// If there are no cookies, set auth as null:\n\t\tconst authorization = response.cookies.get(this.cookieName);\n\t\tif (!authorization) {\n\t\t\trequest.auth = null;\n\t\t\treturn;\n\t\t}\n\n\t\t// Decrypt the cookie, and if the token is invalid, remove the cookie:\n\t\trequest.auth = this.container.server.auth!.decrypt(authorization);\n\t\tif (request.auth === null) response.cookies.remove(this.cookieName);\n\t}\n}\n"]}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import { __name
|
|
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
|
-
|
|
9
|
+
run(request, response) {
|
|
12
10
|
if (!request.route) return;
|
|
13
11
|
const contentType = request.headers["content-type"];
|
|
14
12
|
if (typeof contentType !== "string") return;
|
|
@@ -18,18 +16,6 @@ var _PluginMiddleware = class _PluginMiddleware extends Middleware {
|
|
|
18
16
|
const maximumLength = request.route.maximumBodyLength;
|
|
19
17
|
if (length > maximumLength) {
|
|
20
18
|
response.status(HttpCodes.PayloadTooLarge).json({ error: "Exceeded maximum content length." });
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
const type = this.mediaParsers.parseContentType(contentType);
|
|
24
|
-
const parser = this.mediaParsers.get(type);
|
|
25
|
-
if (!parser || !parser.accepts(request.route)) {
|
|
26
|
-
response.status(HttpCodes.UnsupportedMediaType).json({ error: `Unsupported type ${type}.` });
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
try {
|
|
30
|
-
request.body = await parser.run(request);
|
|
31
|
-
} catch {
|
|
32
|
-
response.status(HttpCodes.BadRequest).json({ error: `Cannot parse ${type} data.` });
|
|
33
19
|
}
|
|
34
20
|
}
|
|
35
21
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/middlewares/body.ts"],"names":[],"mappings":";;;;
|
|
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;AAAA;AAChC,EAEgB,GAAA,CAAI,SAA6B,QAA+B,EAAA;AAC/E,IAAI,IAAA,CAAC,QAAQ,KAAO,EAAA;AAGpB,IAAM,MAAA,WAAA,GAAc,OAAQ,CAAA,OAAA,CAAQ,cAAc,CAAA;AAClD,IAAI,IAAA,OAAO,gBAAgB,QAAU,EAAA;AAGrC,IAAM,MAAA,YAAA,GAAe,OAAQ,CAAA,OAAA,CAAQ,gBAAgB,CAAA;AACrD,IAAI,IAAA,OAAO,iBAAiB,QAAU,EAAA;AAGtC,IAAM,MAAA,MAAA,GAAS,OAAO,YAAY,CAAA;AAClC,IAAM,MAAA,aAAA,GAAgB,QAAQ,KAAM,CAAA,iBAAA;AACpC,IAAA,IAAI,SAAS,aAAe,EAAA;AAC3B,MAAS,QAAA,CAAA,MAAA,CAAO,UAAU,eAAe,CAAA,CAAE,KAAK,EAAE,KAAA,EAAO,oCAAoC,CAAA;AAAA;AAC9F;AAEF,CAAA;AAvBiD,MAAA,CAAA,iBAAA,EAAA,kBAAA,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 +1 @@
|
|
|
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
|
|
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;AAJhC,IAAiB,aAAA,CAAA,IAAA,EAAA,YAAA,EAAsB,OAAQ,CAAA,GAAA,CAAI,QAAa,KAAA,YAAA,CAAA;AAChE,IAAA,aAAA,CAAA,IAAA,EAAQ,iBAAiC,EAAA,IAAA,CAAA;AAKxC,IAAM,MAAA,EAAE,MAAO,EAAA,GAAI,IAAK,CAAA,SAAA;AACxB,IAAK,IAAA,CAAA,eAAA,GAAkB,MAAO,CAAA,IAAA,EAAM,eAAmB,IAAA,IAAA;AAAA;AACxD,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;AAAA;AAE7F,CAAA;AAdiD,MAAA,CAAA,iBAAA,EAAA,kBAAA,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 +1 @@
|
|
|
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
|
|
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;AAJhC,IAAiB,aAAA,CAAA,IAAA,EAAA,QAAA,CAAA;AACjB,IAAiB,aAAA,CAAA,IAAA,EAAA,QAAA,CAAA;AAIhB,IAAA,IAAA,CAAK,MAAS,GAAA,IAAA,CAAK,SAAU,CAAA,MAAA,CAAO,QAAQ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C,QAA+B,EAAA;AAClH,IAAA,IAAI,WAAW,SAAW,EAAA;AACzB,MAAA,IAAI,CAAC,KAAS,IAAA,CAAC,MAAM,OAAQ,CAAA,GAAA,CAAI,SAAS,CAAG,EAAA;AAC5C,QAAA,QAAA,CAAS,GAAI,EAAA;AAAA;AACd,KACD,MAAA,IAAW,eAAe,IAAM,EAAA;AAC/B,MAAA,QAAA,CAAS,MAAO,CAAA,SAAA,CAAU,QAAQ,CAAA,CAAE,GAAI,EAAA;AAAA,KACzC,MAAA,IAAW,UAAU,IAAM,EAAA;AAC1B,MAAA,QAAA,CAAS,MAAO,CAAA,SAAA,CAAU,gBAAgB,CAAA,CAAE,GAAI,EAAA;AAAA;AACjD;AAEF,CAAA;AAxDiD,MAAA,CAAA,iBAAA,EAAA,kBAAA,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"]}
|
package/dist/esm/register.d.mts
CHANGED
package/dist/esm/register.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __name } from './chunk-S573YWRP.mjs';
|
|
2
|
-
import { Server, loadListeners, loadMediaParsers, loadMiddlewares, loadRoutes } from './index.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.
|
|
11
|
+
this.stores.register(this.server.routes).register(this.server.middlewares);
|
|
12
12
|
loadListeners();
|
|
13
|
-
loadMediaParsers();
|
|
14
13
|
loadMiddlewares();
|
|
15
14
|
loadRoutes();
|
|
16
15
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/register.ts"],"names":[],"mappings":";;;;
|
|
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;AACpC,IAAK,IAAA,CAAA,MAAA,CACH,SAAS,IAAK,CAAA,MAAA,CAAO,MAAM,CAC3B,CAAA,QAAA,CAAS,IAAK,CAAA,MAAA,CAAO,WAAW,CAAA;AAElC,IAAc,aAAA,EAAA;AACd,IAAgB,eAAA,EAAA;AAChB,IAAW,UAAA,EAAA;AAAA;AACZ;AAAA;AAAA;AAAA,EAKA,cAAqB,QAAQ,CAAuC,GAAA;AACnE,IAAA,IAAI,EAAE,IAAA,CAAK,MAAO,CAAA,OAAA,CAAQ,wBAAwB,IAAO,CAAA,EAAA;AACxD,MAAA;AAAA;AAGD,IAAM,MAAA,IAAA,CAAK,OAAO,OAAQ,EAAA;AAAA;AAE5B,CAAA;AAzBgC,MAAA,CAAA,IAAA,EAAA,KAAA,CAAA;AAAzB,IAAM,GAAN,GAAA;AA2BP,cAAA,CAAe,OAAQ,CAAA,8BAAA,CAA+B,GAAI,CAAA,kBAAkB,GAAG,wBAAwB,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 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/routes/_load.ts"],"names":["PluginOAuthCallback","PluginOAuthLogout"],"mappings":";;;;;AAIO,SAAS,UAAa,GAAA;AAC5B,EAAA,MAAM,KAAQ,GAAA,QAAA
|
|
1
|
+
{"version":3,"sources":["../../../src/routes/_load.ts"],"names":["PluginOAuthCallback","PluginOAuthLogout"],"mappings":";;;;;AAIO,SAAS,UAAa,GAAA;AAC5B,EAAA,MAAM,KAAQ,GAAA,QAAA;AACd,EAAK,KAAA,SAAA,CAAU,OAAO,SAAU,CAAA,EAAE,MAAM,UAAY,EAAA,KAAA,EAAOA,WAAqB,EAAA,KAAA,EAAO,CAAA;AACvF,EAAK,KAAA,SAAA,CAAU,OAAO,SAAU,CAAA,EAAE,MAAM,QAAU,EAAA,KAAA,EAAOC,aAAmB,EAAA,KAAA,EAAO,CAAA;AACpF;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"]}
|
|
@@ -14,7 +14,7 @@ var _PluginRoute = class _PluginRoute extends Route {
|
|
|
14
14
|
this.redirectUri = server.auth?.redirect;
|
|
15
15
|
}
|
|
16
16
|
async run(request, response) {
|
|
17
|
-
const body = request.
|
|
17
|
+
const body = await request.readBodyJson();
|
|
18
18
|
if (typeof body?.code !== "string") {
|
|
19
19
|
return response.badRequest();
|
|
20
20
|
}
|
|
@@ -1 +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
|
|
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;AAH9D,IAAiB,aAAA,CAAA,IAAA,EAAA,aAAA,CAAA;AAKhB,IAAM,MAAA,EAAE,MAAO,EAAA,GAAI,IAAK,CAAA,SAAA;AACxB,IAAK,IAAA,CAAA,OAAA,GAAU,OAAO,IAAS,KAAA,IAAA;AAC/B,IAAK,IAAA,CAAA,WAAA,GAAc,OAAO,I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AAS,KAAK,IAAI,CAAA;AAAA;AAC1B,EAEA,MAAc,UAAU,IAAsB,EAAA;AAC7C,IAAA,MAAM,EAAE,EAAI,EAAA,MAAA,EAAW,GAAA,IAAA,CAAK,UAAU,MAAO,CAAA,IAAA;AAE7C,IAAA,MAAM,IAAgD,GAAA;AAAA;AAAA,MAErD,SAAW,EAAA,EAAA;AAAA,MACX,aAAe,EAAA,MAAA;AAAA,MACf,MAAM,IAAK,CAAA,IAAA;AAAA,MACX,UAAY,EAAA,oBAAA;AAAA,MACZ,YAAA,EAAc,IAAK,CAAA,WAAA,IAAe,IAAK,CAAA;AAAA;AAAA,KAExC;AAEA,IAAA,MAAM,MAAS,GAAA,MAAM,KAAM,CAAA,YAAA,CAAa,QAAU,EAAA;AAAA,MACjD,MAAQ,EAAA,MAAA;AAAA,MACR,IAAA,EAAM,UAAU,IAAW,CAAA;AAAA,MAC3B,OAAS,EAAA;AAAA,QACR,cAAgB,EAAA;AAAA;AACjB,KACA,CAAA;AAED,IAAM,MAAA,IAAA,GAAO,MAAM,MAAA,CAAO,IAAK,EAAA;AAC/B,IAAI,IAAA,MAAA,CAAO,IAAW,OAAA,IAAA;AAEtB,IAAK,IAAA,CAAA,SAAA,CAAU,MAAO,CAAA,KAAA,CAAM,IAAI,CAAA;AAChC,IAAO,OAAA,IAAA;AAAA;AAET,CAAA;AAnEuC,MAAA,CAAA,YAAA,EAAA,aAAA,CAAA;AAAhC,IAAM,WAAN,GAAA","file":"callback.post.mjs","sourcesContent":["import { OAuth2Routes, type RESTPostOAuth2AccessTokenResult, type RESTPostOAuth2AccessTokenURLEncodedData } from 'discord.js';\nimport { stringify } from 'querystring';\nimport { fetch } from 'undici';\nimport { Route } from '../../lib/structures/Route';\nimport { HttpCodes } from '../../lib/structures/http/HttpCodes';\n\nexport class PluginRoute extends Route {\n\tprivate readonly redirectUri: string | undefined;\n\n\tpublic constructor(context: Route.LoaderContext) {\n\t\tsuper(context, { route: 'oauth/callback', methods: ['POST'] });\n\n\t\tconst { server } = this.container;\n\t\tthis.enabled = server.auth !== null;\n\t\tthis.redirectUri = server.auth?.redirect;\n\t}\n\n\tpublic override async run(request: Route.Request, response: Route.Response) {\n\t\tconst body = (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 +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
|
|
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;AAC3D,IAAA,IAAA,CAAK,OAAU,GAAA,IAAA,CAAK,SAAU,CAAA,MAAA,CAAO,IAAS,KAAA,IAAA;AAAA;AAC/C,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;AAEjG,IAAA,MAAM,SAAS,MAAM,IAAA,CAAK,MAAO,CAAA,OAAA,CAAQ,KAAK,KAAK,CAAA;AACnD,IAAA,IAAI,MA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A,CAAA;AAED,IAAO,OAAA,MAAA;AAAA;AACR,EAEQ,kBAAkB,UAA2B,EAAA;AAGpD,IAAA,OAAO,UAAe,KAAA,IAAA,GAAO,GAAO,GAAA,MAAA,CAAO,UAAU,CAAI,GAAA,GAAA;AAAA;AAE3D,CAAA;AAvFuC,MAAA,CAAA,YAAA,EAAA,aAAA,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
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"description": "Plugin for @sapphire/framework to expose a REST API",
|
|
5
5
|
"author": "@sapphire",
|
|
6
6
|
"license": "MIT",
|
|
@@ -43,17 +43,19 @@
|
|
|
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
|
-
"docs": "typedoc-json-parser",
|
|
48
|
+
"docs": "echo \"temporarily disabled\" || typedoc-json-parser",
|
|
48
49
|
"prepack": "yarn build",
|
|
49
50
|
"bump": "cliff-jumper",
|
|
50
51
|
"check-update": "cliff-jumper --dry-run"
|
|
51
52
|
},
|
|
52
53
|
"dependencies": {
|
|
53
|
-
"@types/ws": "^8.5.
|
|
54
|
-
"@vladfrangu/async_event_emitter": "2.4.
|
|
55
|
-
"
|
|
56
|
-
"
|
|
54
|
+
"@types/ws": "^8.5.13",
|
|
55
|
+
"@vladfrangu/async_event_emitter": "2.4.6",
|
|
56
|
+
"cookie-es": "^1.2.2",
|
|
57
|
+
"tldts": "^6.1.58",
|
|
58
|
+
"undici": "^6.20.1"
|
|
57
59
|
},
|
|
58
60
|
"repository": {
|
|
59
61
|
"type": "git",
|
|
@@ -84,13 +86,13 @@
|
|
|
84
86
|
"access": "public"
|
|
85
87
|
},
|
|
86
88
|
"devDependencies": {
|
|
87
|
-
"@favware/cliff-jumper": "^
|
|
89
|
+
"@favware/cliff-jumper": "^5.0.0",
|
|
88
90
|
"@favware/rollup-type-bundler": "^3.3.0",
|
|
89
|
-
"concurrently": "^
|
|
90
|
-
"tsup": "^8.
|
|
91
|
-
"tsx": "^4.
|
|
92
|
-
"typedoc": "^0.
|
|
93
|
-
"typedoc-json-parser": "^10.
|
|
91
|
+
"concurrently": "^9.0.1",
|
|
92
|
+
"tsup": "^8.3.5",
|
|
93
|
+
"tsx": "^4.19.2",
|
|
94
|
+
"typedoc": "^0.26.11",
|
|
95
|
+
"typedoc-json-parser": "^10.2.0",
|
|
94
96
|
"typescript": "~5.4.5"
|
|
95
97
|
}
|
|
96
98
|
}
|
|
@@ -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=MediaParser.cjs.map
|
|
79
|
-
//# sourceMappingURL=MediaParser.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O,OAAO,MAAM,CAAA,CAAA;AAAA,GAC5B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOU,cAAc,OAAmE,EAAA;AAC1F,IAAA,QAAA,CAAS,QAAQ,OAAQ,CAAA,kBAAkB,CAAK,IAAA,UAAA,EAAY,aAAe;AAAA,MAK1E,KAAK,SAAW,EAAA;AACf,QAAA,MAAM,SAASC,kBAAc,EAAA,CAAA;AAC7B,QAAA,OAAA,CAAQ,KAAK,MAAM,CAAA,CAAA;AACnB,QAAO,OAAA,MAAA,CAAA;AAAA,OACR;AAAA,MAMA,KAAK,QAAA,CAAA;AAAA,MACL,KAAK,MAAQ,EAAA;AACZ,QAAA,MAAM,SAASC,iBAAa,EAAA,CAAA;AAC5B,QAAA,OAAA,CAAQ,KAAK,MAAM,CAAA,CAAA;AACnB,QAAO,OAAA,MAAA,CAAA;AAAA,OACR;AAAA,MAKA,KAAK,IAAM,EAAA;AACV,QAAA,MAAM,SAASC,2BAAuB,EAAA,CAAA;AACtC,QAAA,OAAA,CAAQ,KAAK,MAAM,CAAA,CAAA;AACnB,QAAO,OAAA,MAAA,CAAA;AAAA,OACR;AAAA,MAIA,KAAK,UAAY,EAAA;AAChB,QAAO,OAAA,OAAA,CAAA;AAAA,OACR;AAAA,KACD;AAEA,IAAO,OAAA,IAAA,CAAA;AAAA,GACR;AACD,CAAA,CAAA;AAhGoI,MAAA,CAAA,YAAA,EAAA,aAAA,CAAA,CAAA;AAA7H,IAAe,WAAf,GAAA","file":"MediaParser.cjs","sourcesContent":["import { Piece } from '@sapphire/pieces';\nimport type { Awaitable } from '@sapphire/utilities';\nimport { createBrotliDecompress, createGunzip, createInflate, type Gunzip } from 'zlib';\nimport type { ApiRequest } from './api/ApiRequest';\nimport type { MimeTypeWithoutParameters } from './http/Server';\nimport type { Route } from './Route';\n\n/**\n * A media parser\n * @since 1.3.0\n */\nexport abstract class MediaParser<Options extends MediaParser.Options = MediaParser.Options> extends Piece<Options, 'mediaParsers'> {\n\tpublic constructor(context: MediaParser.LoaderContext, options: Options = {} as Options) {\n\t\tsuper(context, options);\n\t}\n\n\t/**\n\t * Parses the body data from an API request.\n\t * @since 1.3.0\n\t */\n\tpublic abstract run(request: MediaParser.Request): Awaitable<unknown>;\n\n\t/**\n\t * Checks if a route accepts the media type from this parser.\n\t * @since 1.3.0\n\t * @param route The route to be checked.\n\t */\n\tpublic accepts(route: Route): boolean {\n\t\treturn route.acceptedContentMimeTypes === null || route.acceptedContentMimeTypes.includes(this.name as MimeTypeWithoutParameters);\n\t}\n\n\t/**\n\t * Reads the content body as a string, this is useful for parsing/reading plain-text data.\n\t * @since 1.3.0\n\t * @param request The request to read the body from.\n\t */\n\tprotected async readString(request: MediaParser.Request): Promise<string> {\n\t\tconst stream = this.contentStream(request);\n\t\tif (stream === null) return '';\n\n\t\tlet body = '';\n\t\tfor await (const chunk of stream) body += chunk;\n\n\t\treturn body;\n\t}\n\n\t/**\n\t * Reads the content body as a buffer, this is useful for parsing/reading binary data.\n\t * @since 1.3.0\n\t * @param request The request to read the body from.\n\t */\n\tprotected async readBuffer(request: MediaParser.Request): Promise<Buffer> {\n\t\tconst stream = this.contentStream(request);\n\t\tif (stream === null) return Buffer.alloc(0);\n\n\t\tconst bodies: Buffer[] = [];\n\t\tfor await (const chunk of stream) bodies.push(chunk);\n\n\t\treturn Buffer.concat(bodies);\n\t}\n\n\t/**\n\t * Reads the content stream from a request, piping the data through a transformer stream.\n\t * @since 1.3.0\n\t * @param request The request to read the body from.\n\t */\n\tprotected contentStream(request: MediaParser.Request): MediaParser.Request | Gunzip | null {\n\t\tswitch ((request.headers['content-encoding'] ?? 'identity').toLowerCase()) {\n\t\t\t// RFC 7230 4.2.2:\n\t\t\t//\n\t\t\t// The \"deflate\" coding is a \"zlib\" data format (RFC 1950) containing a \"deflate\" compressed data stream\n\t\t\t// (RFC 1951) that uses a combination of the Lempel-Ziv (LZ77) compression algorithm and Huffman coding.\n\t\t\tcase 'deflate': {\n\t\t\t\tconst stream = createInflate();\n\t\t\t\trequest.pipe(stream);\n\t\t\t\treturn stream;\n\t\t\t}\n\n\t\t\t// RFC 7230 4.2.3\n\t\t\t//\n\t\t\t// The \"gzip\" coding is an LZ77 coding with a 32-bit Cyclic Redundancy Check (CRC) that is commonly produced\n\t\t\t// by the gzip file compression program (RFC 1952).\n\t\t\tcase 'x-gzip':\n\t\t\tcase 'gzip': {\n\t\t\t\tconst stream = createGunzip();\n\t\t\t\trequest.pipe(stream);\n\t\t\t\treturn stream;\n\t\t\t}\n\n\t\t\t// RFC 7932\n\t\t\t//\n\t\t\t// A format using the Brotli algorithm.\n\t\t\tcase 'br': {\n\t\t\t\tconst stream = createBrotliDecompress();\n\t\t\t\trequest.pipe(stream);\n\t\t\t\treturn stream;\n\t\t\t}\n\n\t\t\t// An \"identity\" token is used as a synonym for \"no encoding\" in order to communicate when no encoding is\n\t\t\t// preferred.\n\t\t\tcase 'identity': {\n\t\t\t\treturn request;\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}\n}\n\nexport namespace MediaParser {\n\t/** @deprecated Use {@linkcode LoaderContext} instead. */\n\texport type Context = LoaderContext;\n\texport type LoaderContext = Piece.LoaderContext<'mediaParsers'>;\n\texport type Options = Piece.Options;\n\texport type JSON = Piece.JSON;\n\texport type LocationJSON = Piece.LocationJSON;\n\n\texport type Request = ApiRequest;\n}\n"]}
|
|
@@ -1,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=MediaParserStore.cjs.map
|
|
27
|
-
//# sourceMappingURL=MediaParserStore.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/structures/MediaParserStore.ts"],"names":["Store","MediaParser"],"mappings":";;;;;;;AAMO,IAAM,iBAAA,GAAN,MAAM,iBAAA,SAAyBA,YAAmC,CAAA;AAAA,EACjE,WAAc,GAAA;AACpB,IAAA,KAAA,CAAMC,2BAAa,EAAA,EAAE,IAAM,EAAA,cAAA,EAAgB,CAAA,CAAA;AAAA,GAC5C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOO,iBAAiB,WAA6B,EAAA;AACpD,IAAM,MAAA,KAAA,GAAQ,WAAY,CAAA,OAAA,CAAQ,GAAG,CAAA,CAAA;AACrC,IAAA,OAAO,UAAU,CAAK,CAAA,GAAA,WAAA,GAAc,WAAY,CAAA,KAAA,CAAM,GAAG,KAAK,CAAA,CAAA;AAAA,GAC/D;AACD,CAAA,CAAA;AAdyE,MAAA,CAAA,iBAAA,EAAA,kBAAA,CAAA,CAAA;AAAlE,IAAM,gBAAN,GAAA","file":"MediaParserStore.cjs","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"]}
|