Skip to main content

Class: Auth

@sapphire/plugin-api.Auth

Constructors

constructor

new Auth(options): Auth

Parameters

NameType
optionsServerOptionsAuth

Returns

Auth

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:25


domainOverwrite

domainOverwrite: null | string = null

Defined in

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


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:19


redirect

redirect: undefined | string

The redirect uri.

Since

1.0.0

Defined in

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


scopes

scopes: readonly OAuth2Scopes[]

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:31


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:43

Accessors

secret

get secret(): string

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

Returns

string

Since

1.0.0

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.

Parameters

NameTypeDescription
tokenstringAn data to decrypt

Returns

null | AuthData

Since

1.0.0

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.

Parameters

NameTypeDescription
dataAuthDataAn object to encrypt

Returns

string

Since

1.0.0

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.

Parameters

NameTypeDescription
tokenstringThe access token from the user.

Returns

Promise<LoginData>

Since

1.4.0

Defined in

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


fetchInformation

fetchInformation<T>(scope, token, url): Promise<undefined | null | T>

Type parameters

Name
T

Parameters

NameType
scopeOAuth2Scopes
tokenstring
urlstring

Returns

Promise<undefined | null | T>

Defined in

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


create

create(options?): null | Auth

Parameters

NameType
options?ServerOptionsAuth

Returns

null | Auth

Defined in

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