From 9dd3446b64f31ae0831944f5c608095d650142d7 Mon Sep 17 00:00:00 2001 From: "Matt (IPv4) Cowley" Date: Sat, 9 Oct 2021 23:55:18 +0100 Subject: [PATCH] feat(Routes): add missing OAuth2 routes (#218) --- deno/rest/v8/mod.ts | 30 +++++++++++++++++++++++++++--- deno/rest/v9/mod.ts | 30 +++++++++++++++++++++++++++--- rest/v8/index.ts | 30 +++++++++++++++++++++++++++--- rest/v9/index.ts | 30 +++++++++++++++++++++++++++--- 4 files changed, 108 insertions(+), 12 deletions(-) diff --git a/deno/rest/v8/mod.ts b/deno/rest/v8/mod.ts index 7030653a..6b3f4bd4 100644 --- a/deno/rest/v8/mod.ts +++ b/deno/rest/v8/mod.ts @@ -569,6 +569,30 @@ export const Routes = { return `/oauth2/@me` as const; }, + /** + * Route for: + * - GET `/oauth2/authorize` + */ + oauth2Authorization() { + return `/oauth2/authorize` as const; + }, + + /** + * Route for: + * - POST `/oauth2/token` + */ + oauth2TokenExchange() { + return `/oauth2/token` as const; + }, + + /** + * Route for: + * - POST `/oauth2/token/revoke` + */ + oauth2TokenRevocation() { + return `/oauth2/token/revoke` as const; + }, + /** * Route for: * - GET `/applications/{application.id}/commands` @@ -728,12 +752,12 @@ export const RouteBases = { Object.freeze(RouteBases); export const OAuth2Routes = { - authorizationURL: `https://discord.com/api/v${APIVersion}/oauth2/authorize`, - tokenURL: `https://discord.com/api/v${APIVersion}/oauth2/token`, + authorizationURL: `${RouteBases.api}${Routes.oauth2Authorization()}`, + tokenURL: `${RouteBases.api}${Routes.oauth2TokenExchange()}`, /** * See https://tools.ietf.org/html/rfc7009 */ - tokenRevocationURL: `https://discord.com/api/v${APIVersion}/oauth2/token/revoke`, + tokenRevocationURL: `${RouteBases.api}${Routes.oauth2TokenRevocation()}`, } as const; // Freeze OAuth2 route object diff --git a/deno/rest/v9/mod.ts b/deno/rest/v9/mod.ts index b7a503d2..7ec3f207 100644 --- a/deno/rest/v9/mod.ts +++ b/deno/rest/v9/mod.ts @@ -637,6 +637,30 @@ export const Routes = { return `/oauth2/@me` as const; }, + /** + * Route for: + * - GET `/oauth2/authorize` + */ + oauth2Authorization() { + return `/oauth2/authorize` as const; + }, + + /** + * Route for: + * - POST `/oauth2/token` + */ + oauth2TokenExchange() { + return `/oauth2/token` as const; + }, + + /** + * Route for: + * - POST `/oauth2/token/revoke` + */ + oauth2TokenRevocation() { + return `/oauth2/token/revoke` as const; + }, + /** * Route for: * - GET `/applications/{application.id}/commands` @@ -796,12 +820,12 @@ export const RouteBases = { Object.freeze(RouteBases); export const OAuth2Routes = { - authorizationURL: `https://discord.com/api/v${APIVersion}/oauth2/authorize`, - tokenURL: `https://discord.com/api/v${APIVersion}/oauth2/token`, + authorizationURL: `${RouteBases.api}${Routes.oauth2Authorization()}`, + tokenURL: `${RouteBases.api}${Routes.oauth2TokenExchange()}`, /** * See https://tools.ietf.org/html/rfc7009 */ - tokenRevocationURL: `https://discord.com/api/v${APIVersion}/oauth2/token/revoke`, + tokenRevocationURL: `${RouteBases.api}${Routes.oauth2TokenRevocation()}`, } as const; // Freeze OAuth2 route object diff --git a/rest/v8/index.ts b/rest/v8/index.ts index 6a407780..de475255 100644 --- a/rest/v8/index.ts +++ b/rest/v8/index.ts @@ -569,6 +569,30 @@ export const Routes = { return `/oauth2/@me` as const; }, + /** + * Route for: + * - GET `/oauth2/authorize` + */ + oauth2Authorization() { + return `/oauth2/authorize` as const; + }, + + /** + * Route for: + * - POST `/oauth2/token` + */ + oauth2TokenExchange() { + return `/oauth2/token` as const; + }, + + /** + * Route for: + * - POST `/oauth2/token/revoke` + */ + oauth2TokenRevocation() { + return `/oauth2/token/revoke` as const; + }, + /** * Route for: * - GET `/applications/{application.id}/commands` @@ -728,12 +752,12 @@ export const RouteBases = { Object.freeze(RouteBases); export const OAuth2Routes = { - authorizationURL: `https://discord.com/api/v${APIVersion}/oauth2/authorize`, - tokenURL: `https://discord.com/api/v${APIVersion}/oauth2/token`, + authorizationURL: `${RouteBases.api}${Routes.oauth2Authorization()}`, + tokenURL: `${RouteBases.api}${Routes.oauth2TokenExchange()}`, /** * See https://tools.ietf.org/html/rfc7009 */ - tokenRevocationURL: `https://discord.com/api/v${APIVersion}/oauth2/token/revoke`, + tokenRevocationURL: `${RouteBases.api}${Routes.oauth2TokenRevocation()}`, } as const; // Freeze OAuth2 route object diff --git a/rest/v9/index.ts b/rest/v9/index.ts index 644fd896..b5971d33 100644 --- a/rest/v9/index.ts +++ b/rest/v9/index.ts @@ -637,6 +637,30 @@ export const Routes = { return `/oauth2/@me` as const; }, + /** + * Route for: + * - GET `/oauth2/authorize` + */ + oauth2Authorization() { + return `/oauth2/authorize` as const; + }, + + /** + * Route for: + * - POST `/oauth2/token` + */ + oauth2TokenExchange() { + return `/oauth2/token` as const; + }, + + /** + * Route for: + * - POST `/oauth2/token/revoke` + */ + oauth2TokenRevocation() { + return `/oauth2/token/revoke` as const; + }, + /** * Route for: * - GET `/applications/{application.id}/commands` @@ -796,12 +820,12 @@ export const RouteBases = { Object.freeze(RouteBases); export const OAuth2Routes = { - authorizationURL: `https://discord.com/api/v${APIVersion}/oauth2/authorize`, - tokenURL: `https://discord.com/api/v${APIVersion}/oauth2/token`, + authorizationURL: `${RouteBases.api}${Routes.oauth2Authorization()}`, + tokenURL: `${RouteBases.api}${Routes.oauth2TokenExchange()}`, /** * See https://tools.ietf.org/html/rfc7009 */ - tokenRevocationURL: `https://discord.com/api/v${APIVersion}/oauth2/token/revoke`, + tokenRevocationURL: `${RouteBases.api}${Routes.oauth2TokenRevocation()}`, } as const; // Freeze OAuth2 route object