Skip to content

Commit fade2c9

Browse files
author
Vitor
committed
refactor(oauth2): separate OAuth2 scopes
1 parent 12072b7 commit fade2c9

File tree

4 files changed

+276
-180
lines changed

4 files changed

+276
-180
lines changed

deno/payloads/v10/oauth2.ts

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

5-
export enum OAuth2Scopes {
5+
export enum OAuth2PublicUserScopes {
66
/**
7-
* For oauth2 bots, this puts the bot in the user's selected guild by default
7+
* Allows your app to read build data for a user's applications
88
*/
9-
Bot = 'bot',
9+
ApplicationsBuildsRead = 'applications.builds.read',
10+
/**
11+
* Allows your app to update permissions for its commands using a Bearer token - client credentials grant only
12+
*
13+
* See https://discord.com/developers/docs/interactions/application-commands
14+
*/
15+
ApplicationCommandsPermissionsUpdate = 'applications.commands.permissions.update',
16+
/**
17+
* Allows your app to read entitlements for a user's applications
18+
*/
19+
ApplicationsEntitlements = 'applications.entitlements',
20+
/**
21+
* Allows your app to read and update store data (SKUs, store listings, achievements, etc.) for a user's applications
22+
*/
23+
ApplicationsStoreUpdate = 'applications.store.update',
1024
/**
1125
* Allows [/users/@me/connections](https://discord.com/developers/docs/resources/user#get-user-connections)
1226
* to return linked third-party accounts
1327
*
1428
* See https://discord.com/developers/docs/resources/user#get-user-connections
1529
*/
1630
Connections = 'connections',
17-
/**
18-
* Allows your app to see information about the user's DMs and group DMs - requires Discord approval
19-
*/
20-
DMChannelsRead = 'dm_channels.read',
2131
/**
2232
* Enables [/users/@me](https://discord.com/developers/docs/resources/user#get-current-user) to return an `email`
2333
*
2434
* See https://discord.com/developers/docs/resources/user#get-current-user
2535
*/
2636
Email = 'email',
2737
/**
28-
* Allows [/users/@me](https://discord.com/developers/docs/resources/user#get-current-user) without `email`
38+
* Allows your app to join users to a group dm
2939
*
30-
* See https://discord.com/developers/docs/resources/user#get-current-user
40+
* See https://discord.com/developers/docs/resources/channel#group-dm-add-recipient
3141
*/
32-
Identify = 'identify',
42+
GroupDMJoins = 'gdm.join',
3343
/**
3444
* Allows [/users/@me/guilds](https://discord.com/developers/docs/resources/user#get-current-user-guilds)
3545
* to return basic information about all of a user's guilds
@@ -51,78 +61,92 @@ export enum OAuth2Scopes {
5161
*/
5262
GuildsMembersRead = 'guilds.members.read',
5363
/**
54-
* Allows your app to join users to a group dm
64+
* Allows [/users/@me](https://discord.com/developers/docs/resources/user#get-current-user) without `email`
5565
*
56-
* See https://discord.com/developers/docs/resources/channel#group-dm-add-recipient
66+
* See https://discord.com/developers/docs/resources/user#get-current-user
5767
*/
58-
GroupDMJoins = 'gdm.join',
68+
Identify = 'identify',
5969
/**
6070
* For local rpc server api access, this allows you to read messages from all client channels
6171
* (otherwise restricted to channels/guilds your app creates)
6272
*/
6373
MessagesRead = 'messages.read',
6474
/**
65-
* For local rpc server access, this allows you to control a user's local Discord client - requires Discord approval
75+
* For local rpc server api access, this allows you to receive notifications pushed out to the user
6676
*/
67-
RPC = 'rpc',
77+
RPCNotificationsRead = 'rpc.notifications.read',
78+
}
79+
80+
export enum OAuth2GuildScopes {
6881
/**
69-
* For local rpc server api access, this allows you to receive notifications pushed out to the user - requires Discord approval
82+
* Allows your app to use Application Commands in a guild
83+
*
84+
* See https://discord.com/developers/docs/interactions/application-commands
7085
*/
71-
RPCNotificationsRead = 'rpc.notifications.read',
86+
ApplicationsCommands = 'applications.commands',
7287
/**
73-
* This generates a webhook that is returned in the oauth token response for authorization code grants
88+
* For oauth2 bots, this puts the bot in the user's selected guild by default
7489
*/
75-
WebhookIncoming = 'webhook.incoming',
90+
Bot = 'bot',
91+
}
92+
93+
export enum OAuth2OtherScopes {
7694
/**
77-
* Allows your app to connect to voice on user's behalf and see all the voice members - requires Discord approval
95+
* Allows your app to update its Application Commands via this bearer token - client credentials grant only
96+
*
97+
* See https://discord.com/developers/docs/interactions/application-commands
7898
*/
79-
Voice = 'voice',
99+
ApplicationsCommandsUpdate = 'applications.commands.update',
80100
/**
81-
* Allows your app to upload/update builds for a user's applications - requires Discord approval
101+
* This generates a webhook that is returned in the oauth token response for authorization code grants
82102
*/
83-
ApplicationsBuildsUpload = 'applications.builds.upload',
103+
WebhookIncoming = 'webhook.incoming',
104+
}
105+
106+
export enum OAuth2RestrictedUserScopes {
84107
/**
85-
* Allows your app to read build data for a user's applications
108+
* For local rpc server access, this allows you to control a user's local Discord client
86109
*/
87-
ApplicationsBuildsRead = 'applications.builds.read',
110+
RPC = 'rpc',
88111
/**
89-
* Allows your app to read and update store data (SKUs, store listings, achievements, etc.) for a user's applications
112+
* For local rpc server access, this allows you to update a user's activity
90113
*/
91-
ApplicationsStoreUpdate = 'applications.store.update',
114+
RPCActivitiesWrite = 'rpc.activities.write',
92115
/**
93-
* Allows your app to read entitlements for a user's applications
116+
* For local rpc server access, this allows you to read a user's voice settings and listen for voice events
94117
*/
95-
ApplicationsEntitlements = 'applications.entitlements',
118+
RPCVoiceRead = 'rpc.voice.read',
96119
/**
97-
* Allows your app to know a user's friends and implicit relationships - requires Discord approval
120+
* For local rpc server access, this allows you to update a user's voice settings
98121
*/
99-
RelationshipsRead = 'relationships.read',
122+
RPCVoiceWrite = 'rpc.voice.write',
123+
}
124+
125+
export enum OAuth2PrivateUserScopes {
100126
/**
101-
* Allows your app to fetch data from a user's "Now Playing/Recently Played" list - requires Discord approval
127+
* Allows your app to fetch data from a user's "Now Playing/Recently Played" list
102128
*/
103129
ActivitiesRead = 'activities.read',
104130
/**
105-
* Allows your app to update a user's activity - requires Discord approval (NOT REQUIRED FOR GAMESDK ACTIVITY MANAGER)
131+
* Allows your app to update a user's activity (NOT REQUIRED FOR GAMESDK ACTIVITY MANAGER)
106132
*
107133
* See https://discord.com/developers/docs/game-sdk/activities
108134
*/
109135
ActivitiesWrite = 'activities.write',
110136
/**
111-
* Allows your app to use Application Commands in a guild
112-
*
113-
* See https://discord.com/developers/docs/interactions/application-commands
137+
* Allows your app to upload/update builds for a user's applications
114138
*/
115-
ApplicationsCommands = 'applications.commands',
139+
ApplicationsBuildsUpload = 'applications.builds.upload',
116140
/**
117-
* Allows your app to update its Application Commands via this bearer token - client credentials grant only
118-
*
119-
* See https://discord.com/developers/docs/interactions/application-commands
141+
* Allows your app to see information about the user's DMs and group DMs
120142
*/
121-
ApplicationsCommandsUpdate = 'applications.commands.update',
143+
DMChannelsRead = 'dm_channels.read',
122144
/**
123-
* Allows your app to update permissions for its commands using a Bearer token - client credentials grant only
124-
*
125-
* See https://discord.com/developers/docs/interactions/application-commands
145+
* Allows your app to know a user's friends and implicit relationships
126146
*/
127-
ApplicationCommandsPermissionsUpdate = 'applications.commands.permissions.update',
147+
RelationshipsRead = 'relationships.read',
148+
/**
149+
* Allows your app to connect to voice on user's behalf and see all the voice members
150+
*/
151+
Voice = 'voice',
128152
}

deno/payloads/v9/oauth2.ts

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

5-
export enum OAuth2Scopes {
5+
export enum OAuth2PublicUserScopes {
66
/**
7-
* For oauth2 bots, this puts the bot in the user's selected guild by default
7+
* Allows your app to read build data for a user's applications
88
*/
9-
Bot = 'bot',
9+
ApplicationsBuildsRead = 'applications.builds.read',
10+
/**
11+
* Allows your app to update permissions for its commands using a Bearer token - client credentials grant only
12+
*
13+
* See https://discord.com/developers/docs/interactions/application-commands
14+
*/
15+
ApplicationCommandsPermissionsUpdate = 'applications.commands.permissions.update',
16+
/**
17+
* Allows your app to read entitlements for a user's applications
18+
*/
19+
ApplicationsEntitlements = 'applications.entitlements',
20+
/**
21+
* Allows your app to read and update store data (SKUs, store listings, achievements, etc.) for a user's applications
22+
*/
23+
ApplicationsStoreUpdate = 'applications.store.update',
1024
/**
1125
* Allows [/users/@me/connections](https://discord.com/developers/docs/resources/user#get-user-connections)
1226
* to return linked third-party accounts
1327
*
1428
* See https://discord.com/developers/docs/resources/user#get-user-connections
1529
*/
1630
Connections = 'connections',
17-
/**
18-
* Allows your app to see information about the user's DMs and group DMs - requires Discord approval
19-
*/
20-
DMChannelsRead = 'dm_channels.read',
2131
/**
2232
* Enables [/users/@me](https://discord.com/developers/docs/resources/user#get-current-user) to return an `email`
2333
*
2434
* See https://discord.com/developers/docs/resources/user#get-current-user
2535
*/
2636
Email = 'email',
2737
/**
28-
* Allows [/users/@me](https://discord.com/developers/docs/resources/user#get-current-user) without `email`
38+
* Allows your app to join users to a group dm
2939
*
30-
* See https://discord.com/developers/docs/resources/user#get-current-user
40+
* See https://discord.com/developers/docs/resources/channel#group-dm-add-recipient
3141
*/
32-
Identify = 'identify',
42+
GroupDMJoins = 'gdm.join',
3343
/**
3444
* Allows [/users/@me/guilds](https://discord.com/developers/docs/resources/user#get-current-user-guilds)
3545
* to return basic information about all of a user's guilds
@@ -51,78 +61,92 @@ export enum OAuth2Scopes {
5161
*/
5262
GuildsMembersRead = 'guilds.members.read',
5363
/**
54-
* Allows your app to join users to a group dm
64+
* Allows [/users/@me](https://discord.com/developers/docs/resources/user#get-current-user) without `email`
5565
*
56-
* See https://discord.com/developers/docs/resources/channel#group-dm-add-recipient
66+
* See https://discord.com/developers/docs/resources/user#get-current-user
5767
*/
58-
GroupDMJoins = 'gdm.join',
68+
Identify = 'identify',
5969
/**
6070
* For local rpc server api access, this allows you to read messages from all client channels
6171
* (otherwise restricted to channels/guilds your app creates)
6272
*/
6373
MessagesRead = 'messages.read',
6474
/**
65-
* For local rpc server access, this allows you to control a user's local Discord client - requires Discord approval
75+
* For local rpc server api access, this allows you to receive notifications pushed out to the user
6676
*/
67-
RPC = 'rpc',
77+
RPCNotificationsRead = 'rpc.notifications.read',
78+
}
79+
80+
export enum OAuth2GuildScopes {
6881
/**
69-
* For local rpc server api access, this allows you to receive notifications pushed out to the user - requires Discord approval
82+
* Allows your app to use Application Commands in a guild
83+
*
84+
* See https://discord.com/developers/docs/interactions/application-commands
7085
*/
71-
RPCNotificationsRead = 'rpc.notifications.read',
86+
ApplicationsCommands = 'applications.commands',
7287
/**
73-
* This generates a webhook that is returned in the oauth token response for authorization code grants
88+
* For oauth2 bots, this puts the bot in the user's selected guild by default
7489
*/
75-
WebhookIncoming = 'webhook.incoming',
90+
Bot = 'bot',
91+
}
92+
93+
export enum OAuth2OtherScopes {
7694
/**
77-
* Allows your app to connect to voice on user's behalf and see all the voice members - requires Discord approval
95+
* Allows your app to update its Application Commands via this bearer token - client credentials grant only
96+
*
97+
* See https://discord.com/developers/docs/interactions/application-commands
7898
*/
79-
Voice = 'voice',
99+
ApplicationsCommandsUpdate = 'applications.commands.update',
80100
/**
81-
* Allows your app to upload/update builds for a user's applications - requires Discord approval
101+
* This generates a webhook that is returned in the oauth token response for authorization code grants
82102
*/
83-
ApplicationsBuildsUpload = 'applications.builds.upload',
103+
WebhookIncoming = 'webhook.incoming',
104+
}
105+
106+
export enum OAuth2RestrictedUserScopes {
84107
/**
85-
* Allows your app to read build data for a user's applications
108+
* For local rpc server access, this allows you to control a user's local Discord client
86109
*/
87-
ApplicationsBuildsRead = 'applications.builds.read',
110+
RPC = 'rpc',
88111
/**
89-
* Allows your app to read and update store data (SKUs, store listings, achievements, etc.) for a user's applications
112+
* For local rpc server access, this allows you to update a user's activity
90113
*/
91-
ApplicationsStoreUpdate = 'applications.store.update',
114+
RPCActivitiesWrite = 'rpc.activities.write',
92115
/**
93-
* Allows your app to read entitlements for a user's applications
116+
* For local rpc server access, this allows you to read a user's voice settings and listen for voice events
94117
*/
95-
ApplicationsEntitlements = 'applications.entitlements',
118+
RPCVoiceRead = 'rpc.voice.read',
96119
/**
97-
* Allows your app to know a user's friends and implicit relationships - requires Discord approval
120+
* For local rpc server access, this allows you to update a user's voice settings
98121
*/
99-
RelationshipsRead = 'relationships.read',
122+
RPCVoiceWrite = 'rpc.voice.write',
123+
}
124+
125+
export enum OAuth2PrivateUserScopes {
100126
/**
101-
* Allows your app to fetch data from a user's "Now Playing/Recently Played" list - requires Discord approval
127+
* Allows your app to fetch data from a user's "Now Playing/Recently Played" list
102128
*/
103129
ActivitiesRead = 'activities.read',
104130
/**
105-
* Allows your app to update a user's activity - requires Discord approval (NOT REQUIRED FOR GAMESDK ACTIVITY MANAGER)
131+
* Allows your app to update a user's activity (NOT REQUIRED FOR GAMESDK ACTIVITY MANAGER)
106132
*
107133
* See https://discord.com/developers/docs/game-sdk/activities
108134
*/
109135
ActivitiesWrite = 'activities.write',
110136
/**
111-
* Allows your app to use Application Commands in a guild
112-
*
113-
* See https://discord.com/developers/docs/interactions/application-commands
137+
* Allows your app to upload/update builds for a user's applications
114138
*/
115-
ApplicationsCommands = 'applications.commands',
139+
ApplicationsBuildsUpload = 'applications.builds.upload',
116140
/**
117-
* Allows your app to update its Application Commands via this bearer token - client credentials grant only
118-
*
119-
* See https://discord.com/developers/docs/interactions/application-commands
141+
* Allows your app to see information about the user's DMs and group DMs
120142
*/
121-
ApplicationsCommandsUpdate = 'applications.commands.update',
143+
DMChannelsRead = 'dm_channels.read',
122144
/**
123-
* Allows your app to update permissions for its commands using a Bearer token - client credentials grant only
124-
*
125-
* See https://discord.com/developers/docs/interactions/application-commands
145+
* Allows your app to know a user's friends and implicit relationships
126146
*/
127-
ApplicationCommandsPermissionsUpdate = 'applications.commands.permissions.update',
147+
RelationshipsRead = 'relationships.read',
148+
/**
149+
* Allows your app to connect to voice on user's behalf and see all the voice members
150+
*/
151+
Voice = 'voice',
128152
}

0 commit comments

Comments
 (0)