/
oauth2.ts
240 lines (222 loc) · 7.57 KB
/
oauth2.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
import type { Permissions, Snowflake } from '../../globals';
import type { APIApplication, APIGuild, APIUser, APIWebhook, OAuth2Scopes } from '../../payloads/v8/index';
/**
* https://discord.com/developers/docs/topics/oauth2#get-current-application-information
*
* @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10.
*/
export type RESTGetAPIOAuth2CurrentApplicationResult = Omit<APIApplication, 'flags'>;
/**
* https://discord.com/developers/docs/topics/oauth2#get-current-authorization-information
*
* @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10.
*/
export interface RESTGetAPIOAuth2CurrentAuthorizationResult {
/**
* the current application
*/
application: Partial<APIApplication>;
/**
* the scopes the user has authorized the application for
*/
scopes: OAuth2Scopes[];
/**
* when the access token expires
*/
expires: string;
/**
* the user who has authorized, if the user has authorized with the `identify` scope
*/
user?: APIUser;
}
/**
* https://discord.com/developers/docs/topics/oauth2#authorization-code-grant
*
* @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10.
*/
export interface RESTOAuth2AuthorizationQuery {
response_type: 'code';
client_id: Snowflake;
scope: string;
redirect_uri?: string;
state?: string;
prompt?: 'consent' | 'none';
}
/**
* https://discord.com/developers/docs/topics/oauth2#authorization-code-grant-redirect-url-example
*
* @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10.
*/
export interface RESTOAuth2AuthorizationQueryResult {
code: string;
state?: string;
}
/**
* https://discord.com/developers/docs/topics/oauth2#authorization-code-grant-redirect-url-example
*
* @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10.
*/
export interface RESTPostOAuth2AccessTokenURLEncodedData {
client_id: Snowflake;
client_secret: string;
grant_type: 'authorization_code';
code: string;
redirect_uri?: string;
}
/**
* https://discord.com/developers/docs/topics/oauth2#authorization-code-grant-access-token-response
*
* @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10.
*/
export interface RESTPostOAuth2AccessTokenResult {
access_token: string;
token_type: string;
expires_in: number;
refresh_token: string;
scope: string;
}
/**
* https://discord.com/developers/docs/topics/oauth2#authorization-code-grant-refresh-token-exchange-example
*
* @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10.
*/
export interface RESTPostOAuth2RefreshTokenURLEncodedData {
client_id: Snowflake;
client_secret: string;
grant_type: 'refresh_token';
refresh_token: string;
}
/**
* @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10.
*/
export type RESTPostOAuth2RefreshTokenResult = RESTPostOAuth2AccessTokenResult;
/**
* https://discord.com/developers/docs/topics/oauth2#implicit-grant
*
* @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10.
*/
export interface RESTOAuth2ImplicitAuthorizationQuery {
response_type: 'token';
client_id: Snowflake;
scope: string;
redirect_uri?: string;
state?: string;
prompt?: 'consent' | 'none';
}
/**
* https://discord.com/developers/docs/topics/oauth2#implicit-grant-redirect-url-example
*
* @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10.
*/
export type RESTOAuth2ImplicitAuthorizationURLFragmentResult = Omit<RESTPostOAuth2AccessTokenResult, 'refresh_token'>;
/**
* https://discord.com/developers/docs/topics/oauth2#client-credentials-grant
*
* @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10.
*/
export interface RESTPostOAuth2ClientCredentialsURLEncodedData {
grant_type: 'client_credentials';
scope: string;
}
/**
* @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10.
*/
export type RESTPostOAuth2ClientCredentialsResult = RESTOAuth2ImplicitAuthorizationURLFragmentResult;
/**
* https://discord.com/developers/docs/topics/oauth2#bot-authorization-flow-bot-auth-parameters
*
* @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10.
*/
export interface RESTOAuth2BotAuthorizationQuery {
/**
* Your app's client id
*/
client_id: Snowflake;
/**
* Needs to include bot for the bot flow
*/
scope:
| OAuth2Scopes.Bot
| `${OAuth2Scopes.Bot}${' ' | '%20'}${string}`
| `${string}${' ' | '%20'}${OAuth2Scopes.Bot}`
| `${string}${' ' | '%20'}${OAuth2Scopes.Bot}${string}${' ' | '%20'}`;
/**
* The permissions you're requesting
*
* See https://discord.com/developers/docs/topics/permissions
*/
permissions?: Permissions;
/**
* Pre-fills the dropdown picker with a guild for the user
*/
guild_id?: Snowflake;
/**
* `true` or `false`—disallows the user from changing the guild dropdown
*/
disable_guild_select?: boolean;
}
/**
* https://discord.com/developers/docs/topics/oauth2#advanced-bot-authorization
*
* @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10.
*/
export interface RESTOAuth2AdvancedBotAuthorizationQuery {
client_id: Snowflake;
/**
* This assumes you include the `bot` scope alongside others (like `identify` for example)
*/
scope:
| OAuth2Scopes.Bot
| `${OAuth2Scopes.Bot}${' ' | '%20'}${string}`
| `${string}${' ' | '%20'}${OAuth2Scopes.Bot}`
| `${string}${' ' | '%20'}${OAuth2Scopes.Bot}${string}${' ' | '%20'}`;
/**
* The required permissions bitfield, stringified
*/
permissions?: Permissions;
guild_id?: Snowflake;
disable_guild_select?: boolean;
response_type: string;
redirect_uri?: string;
}
/**
* @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10.
*/
export interface RESTOAuth2AdvancedBotAuthorizationQueryResult {
code: string;
state?: string;
guild_id: Snowflake;
permissions: Permissions;
}
/**
* https://discord.com/developers/docs/topics/oauth2#advanced-bot-authorization-extended-bot-authorization-access-token-example
*
* @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10.
*/
export interface RESTPostOAuth2AccessTokenWithBotAndGuildsScopeResult {
access_token: string;
token_type: string;
expires_in: number;
refresh_token: string;
scope: string;
guild: APIGuild;
}
/**
* https://discord.com/developers/docs/topics/oauth2#webhooks-webhook-token-response-example
*
* @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10.
*/
export interface RESTPostOAuth2AccessTokenWithBotAndWebhookIncomingScopeResult {
access_token: string;
token_type: string;
expires_in: number;
refresh_token: string;
scope: string;
webhook: APIWebhook;
}
/**
* @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10.
*/
export type RESTPostOAuth2AccessTokenWithBotAndGuildsAndWebhookIncomingScopeResult =
RESTPostOAuth2AccessTokenWithBotAndGuildsScopeResult &
RESTPostOAuth2AccessTokenWithBotAndWebhookIncomingScopeResult;