import { ConfigOptions } from '../config'; import { OAuth2Tokens } from '../oauth2-client'; import { StringDict } from '../shared/interfaces'; interface GetTokensOptions extends ConfigOptions { forceRenew?: boolean; login?: 'embedded' | 'redirect' | undefined; skipBackgroundRequest?: boolean; query?: StringDict; } /** * Token Manager class that provides high-level abstraction for Authorization Code flow, * PKCE value generation, token exchange and token storage. * * Supports both embedded authentication as well as external authentication via redirects */ declare abstract class TokenManager { /** * @function getTokens - Retrieves OAuth2 tokens from the server or local storage. * @param {Object} options - Options for retrieving tokens. * @param {boolean} [options.forceRenew] - If true, forces a new token request even if tokens are already stored. * @param {string} [options.login] - Specifies the type of login: 'embedded' or 'redirect'. * @param {boolean} [options.skipBackgroundRequest] - If true, skips the background request to get tokens without redirect. * @param {Object} [options.query] - Query key-value pairs to convert to URL parameters for the /authorize request. * @param {string} [options.query.code] - Authorization code from the redirect URL. * @param {string} [options.query.state] - State parameter from the redirect URL. * @returns {Promise} - Returns a promise that resolves to the retrieved tokens or void. * @throws {Error} - Throws an error if the client ID is not provided, if tokens cannot be exchanged, or if there is a state mismatch. * Example 1: ```js const tokens = forgerock.TokenManager.getTokens({ forceRenew: true, // If you want to get new tokens, despite existing ones login: 'embedded', // If user authentication is handled in-app serverConfig: { timeout: 5000, }, }); ``` Example 2: ```js const tokens = forgerock.TokenManager.getTokens({ forceRenew: false, // Will immediately return stored tokens, if they exist login: 'redirect', // If user authentication is handled in external Web app }); ``` Example 3: ```js const tokens = forgerock.TokenManager.getTokens({ query: { code: 'lFJQYdoQG1u7nUm8 ... ', // Authorization code from redirect URL state: 'MTY2NDkxNTQ2Nde3D ... ', // State from redirect URL }, }); ``` Example 4: ```js const tokens = forgerock.TokenManager.getTokens({ skipBackgroundRequest: true, // OPTIONAL; this will skip the iframe request to silently get tokens w/o redirect }); ``` */ static getTokens(options?: GetTokensOptions): Promise; static deleteTokens(): Promise; private static tokenExchange; } export default TokenManager; export type { GetTokensOptions }; //# sourceMappingURL=index.d.ts.map