/** @module Routes/OAuth */ import type { AuthorizationInformation, ClientCredentialsTokenOptions, ClientCredentialsTokenResponse, Connection, ExchangeCodeOptions, ExchangeCodeResponse, OAuthURLOptions, RefreshTokenOptions, RefreshTokenResponse, RevokeTokenOptions, GetCurrentGuildsOptions, RoleConnectionMetadata, RoleConnection } from "../types/oauth"; import Application from "../structures/Application"; import Member from "../structures/Member"; import type RESTManager from "../rest/RESTManager"; import OAuthHelper from "../rest/OAuthHelper"; import OAuthGuild from "../structures/OAuthGuild"; import ExtendedUser from "../structures/ExtendedUser"; /** Various methods for interacting with oauth. */ export default class OAuth { #private; constructor(manager: RESTManager); /** * Construct an oauth authorization url. * @param options The options to construct the url with. * @deprecated Moved to {@link OAuthHelper~OAuthHelper.constructURL | OAuthHelper#constructURL}. This will be removed in `1.5.0`. */ static constructURL(options: OAuthURLOptions): string; /** * Alias for {@link Routes/OAuth~OAuth.constructURL | OAuth#constructURL}. * @deprecated Moved to {@link OAuthHelper~OAuthHelper.constructURL | OAuthHelper#constructURL}. This will be removed in `1.5.0`. */ get constructURL(): typeof OAuthHelper["constructURL"]; /** * Get an access token for the application owner. If the application is owned by a team, this is restricted to `identify` & `applications.commands.update`. * @param options The options to for the client credentials grant. */ clientCredentialsGrant(options: ClientCredentialsTokenOptions): Promise; /** * Exchange a code for an access token. * @param options The options for exchanging the code. */ exchangeCode(options: ExchangeCodeOptions): Promise; /** * Get the current OAuth2 application's information. */ getApplication(): Promise; /** * Get information about the current authorization. * * Note: OAuth only. Bots cannot use this. */ getCurrentAuthorizationInformation(): Promise; /** * Get the connections of the currently authenticated user. * * Note: Requires the `connections` scope when using oauth. */ getCurrentConnections(): Promise>; /** * Get the guild member information about the currently authenticated user. * * Note: OAuth only. Requires the `guilds.members.read` scope. Bots cannot use this. * @param guild the ID of the guild */ getCurrentGuildMember(guild: string): Promise; /** * Get the currently authenticated user's guilds. Note these are missing several properties gateway guilds have. * @param options The options for getting the current user's guilds. */ getCurrentGuilds(options?: GetCurrentGuildsOptions): Promise>; /** * Get the currently authenticated user's information. * * Note: This does not touch the client's cache in any way. */ getCurrentUser(): Promise; /** Get a helper instance that can be used with a specific bearer token. */ getHelper(token: string): OAuthHelper; /** * Get an application's role connection metadata records. * @param application The ID of the application. */ getRoleConnectionsMetatdata(applicationID: string): Promise>; /** * Get the authenticated user's role connection object for an application. This requires the `role_connections.write` scope. * @param applicationID The ID of the application. */ getUserRoleConnection(applicationID: string): Promise; /** * Refresh an existing access token. * @param options The options for refreshing the token. */ refreshToken(options: RefreshTokenOptions): Promise; /** * Revoke an access token. * @param options The options for revoking the token. */ revokeToken(options: RevokeTokenOptions): Promise; /** * Update an application's role connections metadata. * @param application The ID of the application. * @param metadata The metadata records. */ updateRoleConnectionsMetata(applicationID: string, metadata: Array): Promise>; /** * Update the authenticated user's role connection object for an application. This requires the `role_connections.write` scope. * @param applicationID The ID of the application. * @param data The metadata to update. */ updateUserRoleConnection(applicationID: string, data: RoleConnection): Promise; }