import type { LoggerOptions, LogLevel } from '@d-fischer/logger'; import type { TwitchApiCallFetchOptions, TwitchApiCallOptions } from 'twitch-api-call'; import type { AccessToken, AuthProvider, AuthProviderTokenType, RefreshConfig } from 'twitch-auth'; import { TokenInfo } from 'twitch-auth'; import { BadgesApi } from './API/Badges/BadgesApi'; import { HelixApiGroup } from './API/Helix/HelixApiGroup'; import { KrakenApiGroup } from './API/Kraken/KrakenApiGroup'; import { CheermoteBackground, CheermoteScale, CheermoteState } from './API/Shared/BaseCheermoteList'; import { UnsupportedApi } from './API/Unsupported/UnsupportedApi'; /** * Default configuration for the cheermote API. * * @deprecated Pass the full {@CheermoteFormat} to the applicable methods instead. */ export interface TwitchCheermoteConfig { /** * The default background type. */ defaultBackground: CheermoteBackground; /** * The default cheermote state. */ defaultState: CheermoteState; /** * The default cheermote scale. */ defaultScale: CheermoteScale; } /** * Configuration for an {@ApiClient} instance. */ export interface ApiConfig { /** * An authentication provider that supplies tokens to the client. * * For more information, see the {@AuthProvider} documentation. */ authProvider: AuthProvider; /** * Additional options to pass to the fetch method. */ fetchOptions?: TwitchApiCallFetchOptions; /** * Whether to authenticate the client before a request is made. * * @deprecated Call {@ApiClient#requestScopes} after instantiating the client instead. */ preAuth: boolean; /** * The scopes to request with the initial request, even if it's not necessary for the request. * * @deprecated Call {@ApiClient#requestScopes} after instantiating the client instead. */ initialScopes?: string[]; /** * Default values for fetched cheermotes. * * @deprecated Pass the full {@CheermoteFormat} to the applicable methods instead. */ cheermotes: TwitchCheermoteConfig; /** * The minimum level of log levels to see. Defaults to critical errors. * * @deprecated Use logger.minLevel instead. */ logLevel?: LogLevel; /** * Options to pass to the logger. */ logger?: Partial; } /** * @private */ export interface TwitchApiCallOptionsInternal { options: TwitchApiCallOptions; clientId?: string; accessToken?: string; fetchOptions?: TwitchApiCallFetchOptions; } /** * An API client for the Twitch Kraken and Helix APIs. */ export declare class ApiClient implements AuthProvider { private readonly _config; private readonly _helixRateLimiter; /** * Creates a new instance with fixed credentials. * * @deprecated Use the constructor of {@StaticAuthProvider} or {@RefreshableAuthProvider} and pass it as `authProvider` option to this class' constructor instead. * * @param clientId The client ID of your application. * @param accessToken The access token to call the API with. * * You need to obtain one using one of the [Twitch OAuth flows](https://dev.twitch.tv/docs/authentication/getting-tokens-oauth/). * @param scopes The scopes your supplied token has. * * If this argument is given, the scopes need to be correct, or weird things might happen. If it's not (i.e. it's `undefined`), we fetch the correct scopes for you. * * If you can't exactly say which scopes your token has, don't use this parameter/set it to `undefined`. * @param refreshConfig Configuration to automatically refresh expired tokens. * @param config Additional configuration to pass to the constructor. * @param tokenType The type of token you passed. * * This should almost always be 'user' (which is the default). * * If you're passing 'app' here, please consider using {@ApiClient.withClientCredentials} instead. */ static withCredentials(clientId: string, accessToken?: string, scopes?: string[], refreshConfig?: RefreshConfig, config?: Partial, tokenType?: AuthProviderTokenType): ApiClient; /** * Creates a new instance with client credentials. * * @deprecated Use the constructor of {@ClientCredentialsAuthProvider} and pass it as `authProvider` option to this class' constructor instead. * * @param clientId The client ID of your application. * @param clientSecret The client secret of your application. * @param config Additional configuration to pass to the constructor. */ static withClientCredentials(clientId: string, clientSecret?: string, config?: Partial): ApiClient; /** * Makes a call to the Twitch API using given credentials. * * @deprecated Use `callTwitchApi` from `twitch-api-call` instead. * * @param options The configuration of the call. * @param clientId The client ID of your application. * @param accessToken The access token to call the API with. * * You need to obtain one using one of the [Twitch OAuth flows](https://dev.twitch.tv/docs/authentication/getting-tokens-oauth/). */ static callApi(options: TwitchApiCallOptions, clientId?: string, accessToken?: string): Promise; /** * Makes a call to the Twitch API using given credentials. * * @deprecated Use `callTwitchApi` from `twitch-api-call` instead. * * @param options The configuration of the call. * @param clientId The client ID of your application. * @param accessToken The access token to call the API with. * * You need to obtain one using one of the [Twitch OAuth flows](https://dev.twitch.tv/docs/authentication/getting-tokens-oauth/). */ static callAPI(options: TwitchApiCallOptions, clientId?: string, accessToken?: string): Promise; /** * Retrieves an access token with your client credentials and an authorization code. * * @deprecated Use `exchangeCode` from `twitch-auth` instead. * * @param clientId The client ID of your application. * @param clientSecret The client secret of your application. * @param code The authorization code. * @param redirectUri The redirect URI. This serves no real purpose here, but must still match with the redirect URI you configured in the Twitch Developer dashboard. */ static getAccessToken(clientId: string, clientSecret: string, code: string, redirectUri: string): Promise; /** * Retrieves an app access token with your client credentials. * * @deprecated Use `getAppToken` from `twitch-auth` instead. * * @param clientId The client ID of your application. * @param clientSecret The client secret of your application. */ static getAppAccessToken(clientId: string, clientSecret: string): Promise; /** * Refreshes an expired access token with your client credentials and the refresh token that was given by the initial authentication. * * @deprecated Use `refreshUserToken` from `twitch-auth` instead. * * @param clientId The client ID of your application. * @param clientSecret The client secret of your application. * @param refreshToken The refresh token. */ static refreshAccessToken(clientId: string, clientSecret: string, refreshToken: string): Promise; /** * Retrieves information about an access token. * * @deprecated Use `getTokenInfo` from `twitch-auth` instead. * * @param clientId The client ID of your application. * @param accessToken The access token to get the information of. * * You need to obtain one using one of the [Twitch OAuth flows](https://dev.twitch.tv/docs/authentication/getting-tokens-oauth/). */ static getTokenInfo(accessToken: string, clientId?: string): Promise; /** * Creates a new API client instance. * * @param config Configuration for the client instance. */ constructor(config: Partial); /** * Requests scopes from the auth provider. * * @param scopes The scopes to request. */ requestScopes(scopes: string[]): Promise; /** * Retrieves information about your access token. */ getTokenInfo(): Promise; /** * Retrieves an access token for the authentication provider. * * @param scopes The scopes to request. * * @deprecated Use {@AuthProvider#getAccessToken} directly instead. */ getAccessToken(scopes?: string | string[]): Promise; /** * The scopes that are currently available using the access token. * * @deprecated Use {@AuthProvider#currentScopes} directly instead. */ get currentScopes(): string[]; /** @private */ setAccessToken(token: AccessToken): void; /** * Forces the authentication provider to refresh the access token, if possible. * * @deprecated Use {@AuthProvider#refresh} directly instead. */ refresh(): Promise; /** * Forces the authentication provider to refresh the access token, if possible. * * @deprecated Use {@AuthProvider#refresh} directly instead. */ refreshAccessToken(): Promise; /** * The type of token used by the client. */ get tokenType(): AuthProviderTokenType; /** * The client ID of your application. */ get clientId(): string; /** * Makes a call to the Twitch API using your access token. * * @param options The configuration of the call. */ callApi(options: TwitchApiCallOptions): Promise; /** * Makes a call to the Twitch API using your access token. * * @deprecated Use callApi instead. * * @param options The configuration of the call. */ callAPI(options: TwitchApiCallOptions): Promise; /** * The default specs for cheermotes. */ get cheermoteDefaults(): TwitchCheermoteConfig; /** * A group of Kraken API methods. */ get kraken(): KrakenApiGroup; /** * A group of Helix API methods. */ get helix(): HelixApiGroup; /** * The API methods that deal with badges. * * @deprecated Use {@HelixChatApi}'s badge methods instead. */ get badges(): BadgesApi; /** * Various API methods that are not officially supported by Twitch. */ get unsupported(): UnsupportedApi; private _callApiInternal; }