Skip to main content

Class: Auth

@sapphire/plugin-api.Auth

Constructors

constructor

โ€ข Private new Auth(options)

Parameters

NameType
optionsServerOptionsAuth

Defined in

projects/plugins/packages/api/src/lib/structures/http/Auth.ts:49

Properties

#secret

โ€ข Private #secret: string

Defined in

projects/plugins/packages/api/src/lib/structures/http/Auth.ts:47


โ€ข cookie: string

The name for the cookie, this will be used to identify a Secure HttpOnly cookie.

since 1.0.0

Defined in

projects/plugins/packages/api/src/lib/structures/http/Auth.ts:24


domainOverwrite

โ€ข domainOverwrite: null | string = null

Defined in

projects/plugins/packages/api/src/lib/structures/http/Auth.ts:44


id

โ€ข id: string

The client's application id, this can be retrieved in Discord Developer Portal at https://discord.com/developers/applications.

since 1.0.0

Defined in

projects/plugins/packages/api/src/lib/structures/http/Auth.ts:18


redirect

โ€ข redirect: undefined | string

The redirect uri.

since 1.0.0

Defined in

projects/plugins/packages/api/src/lib/structures/http/Auth.ts:36


scopes

โ€ข scopes: readonly string[]

The scopes defined at https://discord.com/developers/docs/topics/oauth2#shared-resources-oauth2-scopes.

since 1.0.0

Defined in

projects/plugins/packages/api/src/lib/structures/http/Auth.ts:30


transformers

โ€ข transformers: LoginDataTransformer<LoginData>[]

The transformers used for Auth.fetchData.

since 1.4.0

Defined in

projects/plugins/packages/api/src/lib/structures/http/Auth.ts:42

Accessors

secret

โ€ข get secret(): string

The client secret, this can be retrieved in Discord Developer Portal at https://discord.com/developers/applications.

since 1.0.0

Returns

string

Defined in

projects/plugins/packages/api/src/lib/structures/http/Auth.ts:63

Methods

decrypt

โ–ธ decrypt(token): null | AuthData

Decrypts an object with aes-256-cbc to use as a token.

since 1.0.0

Parameters

NameTypeDescription
tokenstringAn data to decrypt

Returns

null | AuthData

Defined in

projects/plugins/packages/api/src/lib/structures/http/Auth.ts:85


encrypt

โ–ธ encrypt(data): string

Encrypts an object with aes-256-cbc to use as a token.

since 1.0.0

Parameters

NameTypeDescription
dataAuthDataAn object to encrypt

Returns

string

Defined in

projects/plugins/packages/api/src/lib/structures/http/Auth.ts:73


fetchData

โ–ธ fetchData(token): Promise<LoginData>

Retrieves the data for a specific user.

since 1.4.0

Parameters

NameTypeDescription
tokenstringThe access token from the user.

Returns

Promise<LoginData>

Defined in

projects/plugins/packages/api/src/lib/structures/http/Auth.ts:103


fetchInformation

โ–ธ Private fetchInformation<T>(scope, token, url): Promise<undefined | null | T>

Type parameters

Name
T

Parameters

NameType
scopestring
tokenstring
urlstring

Returns

Promise<undefined | null | T>

Defined in

projects/plugins/packages/api/src/lib/structures/http/Auth.ts:122


create

โ–ธ Static create(options?): null | Auth

Parameters

NameType
options?ServerOptionsAuth

Returns

null | Auth

Defined in

projects/plugins/packages/api/src/lib/structures/http/Auth.ts:134