forked from OceanicJS/Oceanic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoauth.d.ts
209 lines (186 loc) · 6.72 KB
/
oauth.d.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
/** @module Types/OAuth */
import type { RawUser } from "./users";
import type { OAuthWebhook } from "./webhooks";
import type { RawIntegration } from "./guilds";
import type { LocaleMap, RawPartialApplication } from "./applications";
import type {
ConnectionService,
PermissionName,
RoleConnectionMetadataTypes,
ConnectionVisibilityTypes,
ApplicationIntegrationTypes
} from "../Constants";
import type PartialApplication from "../structures/PartialApplication";
import type User from "../structures/User";
import type Webhook from "../structures/Webhook";
import type Integration from "../structures/Integration";
export interface InstallParams {
permissions: Array<PermissionName>;
scopes: Array<string>;
}
export interface RawAuthorizationInformation {
application: RawPartialApplication;
expires: string;
scopes: Array<string>;
user: RawUser;
}
export interface AuthorizationInformation {
application: PartialApplication;
expires: Date;
scopes: Array<string>;
user: User;
}
export interface RawConnection {
friend_sync: boolean;
id: string;
integrations?: Array<RawIntegration>;
name: string;
revoked?: boolean;
show_activity: boolean;
two_way_link: boolean;
type: ConnectionService;
verified: boolean;
visibility: ConnectionVisibilityTypes;
}
export interface Connection {
friendSync: boolean;
id: string;
integrations?: Array<Integration>;
name: string;
revoked?: boolean;
showActivity: boolean;
twoWayLink: boolean;
type: ConnectionService;
verified: boolean;
visibility: ConnectionVisibilityTypes;
}
export interface OAuthURLOptions {
/** The client id of the application. */
clientID: string;
/** If the guild dropdown should be disabled. */
disableGuildSelect?: boolean;
/** The id of the guild to preselect. */
guildID?: string;
/** The integration (install) type. */
integrationType?: ApplicationIntegrationTypes;
/** The permissions to request. */
permissions?: string;
/** `consent` to show the prompt, `none` to not show the prompt if the user has already authorized previously. */
prompt?: "consent" | "none";
/** The redirect uri of the application. */
redirectURI?: string;
/** The response type when authorized. `code` will result in query parameters that need to be exchanged with Discord for a token. `token` will result in fragment parameters that are not accessible server side, but this will be an immediate token. */
responseType?: "code" | "token";
/** The [scopes](https://discord.com/developers/docs/topics/oauth2#shared-resources-oauth2-scopes) to request. */
scopes: Array<string>;
/** The state to send. */
state?: string;
}
export interface ExchangeCodeOptions {
/** The id of the client the authorization was performed with. */
clientID: string;
/** The secret of the client the authorization was performed with. */
clientSecret: string;
/** The code from the authorization. */
code: string;
/** The redirect uri used in the authorization. */
redirectURI: string;
}
export interface RawExchangeCodeResponse {
access_token: string;
expires_in: number;
refresh_token: string;
scope: string;
token_type: "Bearer";
webhook?: OAuthWebhook;
}
export interface ExchangeCodeResponse {
accessToken: string;
expiresIn: number;
refreshToken: string;
scopes: Array<string>;
tokenType: "Bearer";
webhook: Webhook | null;
}
export interface RefreshTokenOptions {
/** The id of the client the authorization was performed with. */
clientID: string;
/** The secret of the client the authorization was performed with. */
clientSecret: string;
/** The refresh token from when the code was exchanged. */
refreshToken: string;
}
export interface RawRefreshTokenResponse extends Omit<RawExchangeCodeResponse, "webhook"> {}
export interface RefreshTokenResponse extends Omit<ExchangeCodeResponse, "webhook"> {}
export interface ClientCredentialsTokenOptions {
/** The id of the client to perform the authorization with. This can be omitted if the global authorization is the proper (Basic base64(clientID:clientSecret)) already, or if connected to the gateway and ready. */
clientID?: string;
/** The secret of the client to perform the authorization with. This can be omitted if the global authorization is the proper (Basic base64(clientID:clientSecret)) already. */
clientSecret?: string;
/** The [scopes](https://discord.com/developers/docs/topics/oauth2#shared-resources-oauth2-scopes) to request. */
scopes: Array<string>;
}
export interface RawClientCredentialsTokenResponse extends Omit<RawExchangeCodeResponse, "refresh_token"> {}
export interface ClientCredentialsTokenResponse extends Omit<ExchangeCodeResponse, "refreshToken"> {}
export interface RevokeTokenOptions {
/** The id of the client the authorization was performed with. */
clientID: string;
/** The secret of the client the authorization was performed with. */
clientSecret: string;
/** The access token to revoke. */
token: string;
}
export interface GetCurrentGuildsOptions {
/** Get guilds after this id. */
after?: string;
/** Get guilds before this id. */
before?: string;
/** Max number of guilds to return (1-200). */
limit?: number;
/** Whether to include approximate member and presence counts. */
withCounts?: boolean;
}
export interface UpdateRoleConnectionOptions {
metadata?: Record<string, RoleConnectionMetadataOptions>;
platformName?: string;
platformUsername?: string;
}
export interface RoleConnectionMetadataOptions {
description: string;
descriptionLocalizations?: LocaleMap;
key: string;
name: string;
nameLocalizations?: LocaleMap;
type: RoleConnectionMetadataTypes;
}
export interface RawRoleConnection {
metadata: Record<string, RawRoleConnectionMetadata>;
platform_name: string | null;
platform_username: string | null;
}
export interface RawRoleConnectionMetadata {
description: string;
description_localizations?: LocaleMap;
key: string;
name: string;
name_localizations?: LocaleMap;
type: RoleConnectionMetadataTypes;
}
export interface RoleConnection {
metadata: Record<string, RoleConnectionMetadata>;
platformName: string | null;
platformUsername: string | null;
}
export interface UpdateUserApplicationRoleConnectionOptions {
metadata: Record<string, string>;
platformName: string | null;
platformUsername: string | null;
}
export interface RoleConnectionMetadata {
description: string;
descriptionLocalizations?: LocaleMap;
key: string;
name: string;
nameLocalizations?: LocaleMap;
type: RoleConnectionMetadataTypes;
}