Skip to content

Commit 05cc037

Browse files
author
Vitor
committed
refactor: update outdated OAuth2Scopes links & add description
1 parent fade2c9 commit 05cc037

File tree

12 files changed

+260
-48
lines changed

12 files changed

+260
-48
lines changed

deno/payloads/v10/application.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22
* Types extracted from https://discord.com/developers/docs/resources/application
33
*/
44

5-
import type { OAuth2Scopes } from './oauth2.ts';
5+
import type {
6+
OAuth2PublicUserScopes,
7+
OAuth2GuildScopes,
8+
OAuth2OtherScopes,
9+
OAuth2RestrictedUserScopes,
10+
OAuth2PrivateUserScopes,
11+
} from './oauth2.ts';
612
import type { APITeam } from './teams.ts';
713
import type { APIUser } from './user.ts';
814
import type { Permissions, Snowflake } from '../../globals.ts';
@@ -108,7 +114,13 @@ export interface APIApplication {
108114
}
109115

110116
export interface APIApplicationInstallParams {
111-
scopes: OAuth2Scopes[];
117+
scopes: (
118+
| OAuth2PublicUserScopes
119+
| OAuth2GuildScopes
120+
| OAuth2OtherScopes
121+
| OAuth2RestrictedUserScopes
122+
| OAuth2PrivateUserScopes
123+
)[];
112124
permissions: Permissions;
113125
}
114126

deno/payloads/v10/oauth2.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
* Types extracted from https://discord.com/developers/docs/topics/oauth2
33
*/
44

5+
/**
6+
* Users can authorize these scopes using the normal OAuth2 process
7+
*
8+
* See https://discord.com/developers/docs/topics/oauth2#shared-resources-oauth2-scopes-public-user-scopes
9+
*/
510
export enum OAuth2PublicUserScopes {
611
/**
712
* Allows your app to read build data for a user's applications
@@ -77,6 +82,11 @@ export enum OAuth2PublicUserScopes {
7782
RPCNotificationsRead = 'rpc.notifications.read',
7883
}
7984

85+
/**
86+
* Applications can be added to a guild with these scopes by members with the `Manage Server` permission
87+
*
88+
* See https://discord.com/developers/docs/topics/oauth2#shared-resources-oauth2-scopes-guild-scopes
89+
*/
8090
export enum OAuth2GuildScopes {
8191
/**
8292
* Allows your app to use Application Commands in a guild
@@ -90,6 +100,11 @@ export enum OAuth2GuildScopes {
90100
Bot = 'bot',
91101
}
92102

103+
/**
104+
* These scopes can be used to do other actions with Discord's OAuth2 system
105+
*
106+
* See https://discord.com/developers/docs/topics/oauth2#shared-resources-oauth2-scopes-other-scopes
107+
*/
93108
export enum OAuth2OtherScopes {
94109
/**
95110
* Allows your app to update its Application Commands via this bearer token - client credentials grant only
@@ -103,6 +118,11 @@ export enum OAuth2OtherScopes {
103118
WebhookIncoming = 'webhook.incoming',
104119
}
105120

121+
/**
122+
* These scopes can be publicly used for application owners and testers. Certain approved apps can use these for all users
123+
*
124+
* See https://discord.com/developers/docs/topics/oauth2#shared-resources-oauth2-scopes-restricted-user-scopes
125+
*/
106126
export enum OAuth2RestrictedUserScopes {
107127
/**
108128
* For local rpc server access, this allows you to control a user's local Discord client
@@ -122,6 +142,11 @@ export enum OAuth2RestrictedUserScopes {
122142
RPCVoiceWrite = 'rpc.voice.write',
123143
}
124144

145+
/**
146+
* These scopes can only be used by certain approved apps
147+
*
148+
* See https://discord.com/developers/docs/topics/oauth2#shared-resources-oauth2-scopes-private-user-scopes
149+
*/
125150
export enum OAuth2PrivateUserScopes {
126151
/**
127152
* Allows your app to fetch data from a user's "Now Playing/Recently Played" list

deno/payloads/v9/application.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22
* Types extracted from https://discord.com/developers/docs/resources/application
33
*/
44

5-
import type { OAuth2Scopes } from './oauth2.ts';
5+
import type {
6+
OAuth2PublicUserScopes,
7+
OAuth2GuildScopes,
8+
OAuth2OtherScopes,
9+
OAuth2RestrictedUserScopes,
10+
OAuth2PrivateUserScopes,
11+
} from './oauth2.ts';
612
import type { APITeam } from './teams.ts';
713
import type { APIUser } from './user.ts';
814
import type { Permissions, Snowflake } from '../../globals.ts';
@@ -108,7 +114,13 @@ export interface APIApplication {
108114
}
109115

110116
export interface APIApplicationInstallParams {
111-
scopes: OAuth2Scopes[];
117+
scopes: (
118+
| OAuth2PublicUserScopes
119+
| OAuth2GuildScopes
120+
| OAuth2OtherScopes
121+
| OAuth2RestrictedUserScopes
122+
| OAuth2PrivateUserScopes
123+
)[];
112124
permissions: Permissions;
113125
}
114126

deno/payloads/v9/oauth2.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
* Types extracted from https://discord.com/developers/docs/topics/oauth2
33
*/
44

5+
/**
6+
* Users can authorize these scopes using the normal OAuth2 process
7+
*
8+
* See https://discord.com/developers/docs/topics/oauth2#shared-resources-oauth2-scopes-public-user-scopes
9+
*/
510
export enum OAuth2PublicUserScopes {
611
/**
712
* Allows your app to read build data for a user's applications
@@ -77,6 +82,11 @@ export enum OAuth2PublicUserScopes {
7782
RPCNotificationsRead = 'rpc.notifications.read',
7883
}
7984

85+
/**
86+
* Applications can be added to a guild with these scopes by members with the `Manage Server` permission
87+
*
88+
* See https://discord.com/developers/docs/topics/oauth2#shared-resources-oauth2-scopes-guild-scopes
89+
*/
8090
export enum OAuth2GuildScopes {
8191
/**
8292
* Allows your app to use Application Commands in a guild
@@ -90,6 +100,11 @@ export enum OAuth2GuildScopes {
90100
Bot = 'bot',
91101
}
92102

103+
/**
104+
* These scopes can be used to do other actions with Discord's OAuth2 system
105+
*
106+
* See https://discord.com/developers/docs/topics/oauth2#shared-resources-oauth2-scopes-other-scopes
107+
*/
93108
export enum OAuth2OtherScopes {
94109
/**
95110
* Allows your app to update its Application Commands via this bearer token - client credentials grant only
@@ -103,6 +118,11 @@ export enum OAuth2OtherScopes {
103118
WebhookIncoming = 'webhook.incoming',
104119
}
105120

121+
/**
122+
* These scopes can be publicly used for application owners and testers. Certain approved apps can use these for all users
123+
*
124+
* See https://discord.com/developers/docs/topics/oauth2#shared-resources-oauth2-scopes-restricted-user-scopes
125+
*/
106126
export enum OAuth2RestrictedUserScopes {
107127
/**
108128
* For local rpc server access, this allows you to control a user's local Discord client
@@ -122,6 +142,11 @@ export enum OAuth2RestrictedUserScopes {
122142
RPCVoiceWrite = 'rpc.voice.write',
123143
}
124144

145+
/**
146+
* These scopes can only be used by certain approved apps
147+
*
148+
* See https://discord.com/developers/docs/topics/oauth2#shared-resources-oauth2-scopes-private-user-scopes
149+
*/
125150
export enum OAuth2PrivateUserScopes {
126151
/**
127152
* Allows your app to fetch data from a user's "Now Playing/Recently Played" list

deno/rest/v10/oauth2.ts

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
import type { Permissions, Snowflake } from '../../globals.ts';
2-
import type { APIApplication, APIGuild, APIUser, APIWebhook, OAuth2Scopes } from '../../payloads/v10/mod.ts';
2+
import type {
3+
APIApplication,
4+
APIGuild,
5+
APIUser,
6+
APIWebhook,
7+
OAuth2PublicUserScopes,
8+
OAuth2GuildScopes,
9+
OAuth2OtherScopes,
10+
OAuth2RestrictedUserScopes,
11+
OAuth2PrivateUserScopes,
12+
} from '../../payloads/v10/mod.ts';
313

414
/**
515
* https://discord.com/developers/docs/topics/oauth2#get-current-bot-application-information
@@ -17,7 +27,13 @@ export interface RESTGetAPIOAuth2CurrentAuthorizationResult {
1727
/**
1828
* the scopes the user has authorized the application for
1929
*/
20-
scopes: OAuth2Scopes[];
30+
scopes: (
31+
| OAuth2PublicUserScopes
32+
| OAuth2GuildScopes
33+
| OAuth2OtherScopes
34+
| OAuth2RestrictedUserScopes
35+
| OAuth2PrivateUserScopes
36+
)[];
2137
/**
2238
* when the access token expires
2339
*/
@@ -121,10 +137,10 @@ export interface RESTOAuth2BotAuthorizationQuery {
121137
* Needs to include bot for the bot flow
122138
*/
123139
scope:
124-
| OAuth2Scopes.Bot
125-
| `${string}${' ' | '%20'}${OAuth2Scopes.Bot}`
126-
| `${OAuth2Scopes.Bot}${' ' | '%20'}${string}`
127-
| `${string}${' ' | '%20'}${OAuth2Scopes.Bot}${string}${' ' | '%20'}`;
140+
| OAuth2GuildScopes.Bot
141+
| `${string}${' ' | '%20'}${OAuth2GuildScopes.Bot}`
142+
| `${OAuth2GuildScopes.Bot}${' ' | '%20'}${string}`
143+
| `${string}${' ' | '%20'}${OAuth2GuildScopes.Bot}${string}${' ' | '%20'}`;
128144
/**
129145
* The permissions you're requesting
130146
*
@@ -150,10 +166,10 @@ export interface RESTOAuth2AdvancedBotAuthorizationQuery {
150166
* This assumes you include the `bot` scope alongside others (like `identify` for example)
151167
*/
152168
scope:
153-
| OAuth2Scopes.Bot
154-
| `${string}${' ' | '%20'}${OAuth2Scopes.Bot}`
155-
| `${OAuth2Scopes.Bot}${' ' | '%20'}${string}`
156-
| `${string}${' ' | '%20'}${OAuth2Scopes.Bot}${string}${' ' | '%20'}`;
169+
| OAuth2GuildScopes.Bot
170+
| `${string}${' ' | '%20'}${OAuth2GuildScopes.Bot}`
171+
| `${OAuth2GuildScopes.Bot}${' ' | '%20'}${string}`
172+
| `${string}${' ' | '%20'}${OAuth2GuildScopes.Bot}${string}${' ' | '%20'}`;
157173
/**
158174
* The required permissions bitfield, stringified
159175
*/

deno/rest/v9/oauth2.ts

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
import type { Permissions, Snowflake } from '../../globals.ts';
2-
import type { APIApplication, APIGuild, APIUser, APIWebhook, OAuth2Scopes } from '../../payloads/v9/mod.ts';
2+
import type {
3+
APIApplication,
4+
APIGuild,
5+
APIUser,
6+
APIWebhook,
7+
OAuth2PublicUserScopes,
8+
OAuth2GuildScopes,
9+
OAuth2OtherScopes,
10+
OAuth2RestrictedUserScopes,
11+
OAuth2PrivateUserScopes,
12+
} from '../../payloads/v10/mod.ts';
313

414
/**
515
* https://discord.com/developers/docs/topics/oauth2#get-current-bot-application-information
@@ -17,7 +27,13 @@ export interface RESTGetAPIOAuth2CurrentAuthorizationResult {
1727
/**
1828
* the scopes the user has authorized the application for
1929
*/
20-
scopes: OAuth2Scopes[];
30+
scopes: (
31+
| OAuth2PublicUserScopes
32+
| OAuth2GuildScopes
33+
| OAuth2OtherScopes
34+
| OAuth2RestrictedUserScopes
35+
| OAuth2PrivateUserScopes
36+
)[];
2137
/**
2238
* when the access token expires
2339
*/
@@ -121,10 +137,10 @@ export interface RESTOAuth2BotAuthorizationQuery {
121137
* Needs to include bot for the bot flow
122138
*/
123139
scope:
124-
| OAuth2Scopes.Bot
125-
| `${string}${' ' | '%20'}${OAuth2Scopes.Bot}`
126-
| `${OAuth2Scopes.Bot}${' ' | '%20'}${string}`
127-
| `${string}${' ' | '%20'}${OAuth2Scopes.Bot}${string}${' ' | '%20'}`;
140+
| OAuth2GuildScopes.Bot
141+
| `${string}${' ' | '%20'}${OAuth2GuildScopes.Bot}`
142+
| `${OAuth2GuildScopes.Bot}${' ' | '%20'}${string}`
143+
| `${string}${' ' | '%20'}${OAuth2GuildScopes.Bot}${string}${' ' | '%20'}`;
128144
/**
129145
* The permissions you're requesting
130146
*
@@ -150,10 +166,10 @@ export interface RESTOAuth2AdvancedBotAuthorizationQuery {
150166
* This assumes you include the `bot` scope alongside others (like `identify` for example)
151167
*/
152168
scope:
153-
| OAuth2Scopes.Bot
154-
| `${string}${' ' | '%20'}${OAuth2Scopes.Bot}`
155-
| `${OAuth2Scopes.Bot}${' ' | '%20'}${string}`
156-
| `${string}${' ' | '%20'}${OAuth2Scopes.Bot}${string}${' ' | '%20'}`;
169+
| OAuth2GuildScopes.Bot
170+
| `${string}${' ' | '%20'}${OAuth2GuildScopes.Bot}`
171+
| `${OAuth2GuildScopes.Bot}${' ' | '%20'}${string}`
172+
| `${string}${' ' | '%20'}${OAuth2GuildScopes.Bot}${string}${' ' | '%20'}`;
157173
/**
158174
* The required permissions bitfield, stringified
159175
*/

payloads/v10/application.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22
* Types extracted from https://discord.com/developers/docs/resources/application
33
*/
44

5-
import type { OAuth2Scopes } from './oauth2';
5+
import type {
6+
OAuth2PublicUserScopes,
7+
OAuth2GuildScopes,
8+
OAuth2OtherScopes,
9+
OAuth2RestrictedUserScopes,
10+
OAuth2PrivateUserScopes,
11+
} from './oauth2';
612
import type { APITeam } from './teams';
713
import type { APIUser } from './user';
814
import type { Permissions, Snowflake } from '../../globals';
@@ -108,7 +114,13 @@ export interface APIApplication {
108114
}
109115

110116
export interface APIApplicationInstallParams {
111-
scopes: OAuth2Scopes[];
117+
scopes: (
118+
| OAuth2PublicUserScopes
119+
| OAuth2GuildScopes
120+
| OAuth2OtherScopes
121+
| OAuth2RestrictedUserScopes
122+
| OAuth2PrivateUserScopes
123+
)[];
112124
permissions: Permissions;
113125
}
114126

payloads/v10/oauth2.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
* Types extracted from https://discord.com/developers/docs/topics/oauth2
33
*/
44

5+
/**
6+
* Users can authorize these scopes using the normal OAuth2 process
7+
*
8+
* See https://discord.com/developers/docs/topics/oauth2#shared-resources-oauth2-scopes-public-user-scopes
9+
*/
510
export enum OAuth2PublicUserScopes {
611
/**
712
* Allows your app to read build data for a user's applications
@@ -77,6 +82,11 @@ export enum OAuth2PublicUserScopes {
7782
RPCNotificationsRead = 'rpc.notifications.read',
7883
}
7984

85+
/**
86+
* Applications can be added to a guild with these scopes by members with the `Manage Server` permission
87+
*
88+
* See https://discord.com/developers/docs/topics/oauth2#shared-resources-oauth2-scopes-guild-scopes
89+
*/
8090
export enum OAuth2GuildScopes {
8191
/**
8292
* Allows your app to use Application Commands in a guild
@@ -90,6 +100,11 @@ export enum OAuth2GuildScopes {
90100
Bot = 'bot',
91101
}
92102

103+
/**
104+
* These scopes can be used to do other actions with Discord's OAuth2 system
105+
*
106+
* See https://discord.com/developers/docs/topics/oauth2#shared-resources-oauth2-scopes-other-scopes
107+
*/
93108
export enum OAuth2OtherScopes {
94109
/**
95110
* Allows your app to update its Application Commands via this bearer token - client credentials grant only
@@ -103,6 +118,11 @@ export enum OAuth2OtherScopes {
103118
WebhookIncoming = 'webhook.incoming',
104119
}
105120

121+
/**
122+
* These scopes can be publicly used for application owners and testers. Certain approved apps can use these for all users
123+
*
124+
* See https://discord.com/developers/docs/topics/oauth2#shared-resources-oauth2-scopes-restricted-user-scopes
125+
*/
106126
export enum OAuth2RestrictedUserScopes {
107127
/**
108128
* For local rpc server access, this allows you to control a user's local Discord client
@@ -122,6 +142,11 @@ export enum OAuth2RestrictedUserScopes {
122142
RPCVoiceWrite = 'rpc.voice.write',
123143
}
124144

145+
/**
146+
* These scopes can only be used by certain approved apps
147+
*
148+
* See https://discord.com/developers/docs/topics/oauth2#shared-resources-oauth2-scopes-private-user-scopes
149+
*/
125150
export enum OAuth2PrivateUserScopes {
126151
/**
127152
* Allows your app to fetch data from a user's "Now Playing/Recently Played" list

0 commit comments

Comments
 (0)