mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-03 09:20:08 +00:00
types: add oauth2 types (#719)
* add types * Update get_current_authorization_information.ts * Update src/types/oauth2/get_current_authorization_information.ts Co-authored-by: ayntee <ayyantee@gmail.com> * Update src/types/oauth2/get_current_authorization_information.ts Co-authored-by: ayntee <ayyantee@gmail.com> * Update bot_auth_query.ts * Update scopes.ts Co-authored-by: ayntee <ayyantee@gmail.com>
This commit is contained in:
40
src/types/oauth2/application.ts
Normal file
40
src/types/oauth2/application.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { User } from "../users/user.ts";
|
||||
import { SnakeCaseProps } from "../util.ts";
|
||||
|
||||
export interface Application {
|
||||
/** The id of the app */
|
||||
id: string;
|
||||
/** The name of the app */
|
||||
name: string;
|
||||
/** The icon hash of the app */
|
||||
icon: string | null;
|
||||
/** The description of the app */
|
||||
description: string;
|
||||
/** An array of rpc origin urls, if rpc is enabled */
|
||||
rpcOrigins?: string[];
|
||||
/** When false only app owner can join the app's bot to guilds */
|
||||
botPublic: boolean;
|
||||
/** When true the app's bot will only join upon completion of the full oauth2 code grant flow */
|
||||
botRequireCodeGrant: boolean;
|
||||
/** Partial user object containing info on the owner of the application */
|
||||
owner: Partial<User>;
|
||||
/** If this application is a game sold on Discord, this field will be the summary field for the store page of its primary sku */
|
||||
summary: string;
|
||||
/** The base64 encoded key for the GameSDK's GetTicket */
|
||||
verifyKey: string;
|
||||
/** If the application belongs to a team, this will be a list of the members of that team */
|
||||
team: Team | null;
|
||||
/** If this application is a game sold on Discord, this field will be the guild to which it has been linked */
|
||||
guildId?: string;
|
||||
/** If this application is a game sold on Discord, this field will be the id of the "Game SKU" that is created, if exists */
|
||||
primarySkuId?: string;
|
||||
/** If this application is a game sold on Discord, this field will be the URL slug that links to the store page */
|
||||
slug?: string;
|
||||
/** If this application is a game sold on Discord, this field will be the hash of the image on store embeds */
|
||||
coverImage?: string;
|
||||
/** The application's public flags */
|
||||
flags: number;
|
||||
}
|
||||
|
||||
/** https://discord.com/developers/docs/topics/oauth2#application-object */
|
||||
export type DiscordApplication = SnakeCaseProps<Application>;
|
||||
20
src/types/oauth2/bot_auth_query.ts
Normal file
20
src/types/oauth2/bot_auth_query.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { SnakeCaseProps } from "../util.ts";
|
||||
import { DiscordOAuth2Scopes } from "./scopes.ts";
|
||||
|
||||
export interface BotAuthenticationFlowQuery {
|
||||
/** App's client id */
|
||||
clientId: string;
|
||||
/** Needs to include bot for the bot flow */
|
||||
scope: DiscordOAuth2Scopes[];
|
||||
/** The permissions you're requesting */
|
||||
permissions: string;
|
||||
/** Pre-fills the dropdown picker with a guild for the user */
|
||||
guildId: string;
|
||||
/** True or false—disallows the user from changing the guild dropdown */
|
||||
disableGuildSelect: boolean;
|
||||
}
|
||||
|
||||
/** https://discord.com/developers/docs/topics/oauth2#bot-authorization-flow-bot-auth-parameters */
|
||||
export type DiscordBotAuthenticationFlowQuery = SnakeCaseProps<
|
||||
BotAuthenticationFlowQuery
|
||||
>;
|
||||
20
src/types/oauth2/get_current_authorization_information.ts
Normal file
20
src/types/oauth2/get_current_authorization_information.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { User } from "../users/user.ts";
|
||||
import { SnakeCaseProps } from "../util.ts";
|
||||
import { Application } from "./application.ts";
|
||||
import { DiscordOAuth2Scopes } from "./scopes.ts";
|
||||
|
||||
export interface GetCurrentAuthorizationInformation {
|
||||
/** The current application */
|
||||
application: Partial<Application>;
|
||||
/** The scopes the user has authorized the application for */
|
||||
scopes: DiscordOAuth2Scopes[];
|
||||
/** When the access token expires */
|
||||
expires: string;
|
||||
/** The user who has authorized, if the user has authorized with the `identify` scope */
|
||||
user?: User;
|
||||
}
|
||||
|
||||
/** https://discord.com/developers/docs/topics/oauth2#get-current-authorization-information-response-structure */
|
||||
export type DiscordGetCurrentAuthoriationInformation = SnakeCaseProps<
|
||||
GetCurrentAuthorizationInformation
|
||||
>;
|
||||
23
src/types/oauth2/scopes.ts
Normal file
23
src/types/oauth2/scopes.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
/** https://discord.com/developers/docs/topics/oauth2#shared-resources-oauth2-scopes */
|
||||
export type DiscordOAuth2Scopes =
|
||||
| "bot"
|
||||
| "connections"
|
||||
| "email"
|
||||
| "identify"
|
||||
| "guilds"
|
||||
| "guilds.join"
|
||||
| "gdm.join"
|
||||
| "messages.read"
|
||||
| "rpc"
|
||||
| "rpc.api"
|
||||
| "rpc.notifications"
|
||||
| "webhook.incomming"
|
||||
| "applications.builds.upload"
|
||||
| "applications.builds.read"
|
||||
| "applications.store.update"
|
||||
| "applications.entitlements"
|
||||
| "relationships.read"
|
||||
| "activities.read"
|
||||
| "activities.write"
|
||||
| "applications.commands"
|
||||
| "applications.commands.update";
|
||||
Reference in New Issue
Block a user