import { Client } from './client'; import { EnvatoHttpOptions } from '../helpers/http'; /** * Helper class for OAuth applications. Includes methods to both authorize new clients and renew tokens. */ export declare class OAuth { private _options; private _httpClient; constructor(options: OAuthOptions); /** * Returns the URL that you should redirect users to in order to authenticate with the Envato API for this app. * This will include the `client_id` and `redirect_uri` from your options. */ getRedirectUrl(): string; /** * Authorizes the user based on the given authentication code and returns a `Client` with their access token, * refresh token, and expiration time configured and ready-to-go. * * @param code The single-use authentication code returned from the Envato authorization screen. */ getClient(code: string): Promise; /** * Returns a new access token for the given client. * * @param client The client whose access token needs to be renewed. */ renew(client: Client): Promise; /** * Performs an OAuth request. * * @param form */ private _sendRequest; } export interface OAuthOptions { /** * The application's unique ID. */ client_id: string; /** * The application's secret. */ client_secret: string; /** * The application's redirect URL. This must exactly match the URL provided when creating the application. */ redirect_uri: string; /** * The user agent string to send with requests. This should briefly explain what your app is or its purpose. * Please do not use a generic browser user agent. Note that this also applies to `Client` instances generated by * the OAuth helper. * * Here are some examples of good user agents: * * - `"License activation for my themes"` * - `"Support forum authentication & license verification"` * - `"Gathering data on items"` */ userAgent?: string; /** * Optional configuration for the underlying `axios` library. */ http?: EnvatoHttpOptions; } export interface IResponseData { refresh_token: string; token_type: string; access_token: string; expires_in: number; } export interface IRefreshResponseData { token_type: string; access_token: string; expires_in: number; } export interface IRefreshedToken { /** * Alias for `accessToken`, here only for backwards compatibility! */ token: string; /** * The new access token. This should be stored in the database alongside the existing refresh token. */ accessToken: string; /** * The timestamp at which the new access token will expire (epoch milliseconds). */ expiration: number; [key: string]: any; }