import TokenKind from './TokenKind.js'; import TokenProvider from './TokenProvider.js'; import type { GuestTokenRequester, OptionsStorageProvider, OptionsStorageSerializer } from '../types/TokenManagerOptions.types.js'; import type { TokenContext } from './types/TokenContext.types.js'; export declare const DEFAULT_STORAGE_KEY = "GuestToken"; /** * Token provider for guest users. */ declare class GuestTokenProvider extends TokenProvider { currentGetAccessTokenPromise: Promise | null; requester: GuestTokenRequester; tokenContext: TokenContext | null; /** * Creates a new GuestTokenProvider instance. * * @param requester - A function that will be responsible to request new tokens. If async, * the call will be awaited. * @param storageProvider - An object implementing the Storage API's methods getItem, setItem and * removeItem. If those methods are async, the calls will be awaited. * @param tokenDataSerializer - An object implementing the serializeTokenData and deserializeTokenData * methods. If storage provider is defined, tokenDataSerializer is * required. * @param storageKey - The storage key that will be used on the calls to storageProvider's * methods as the key argument. If not provided, a default will be used. */ constructor(requester: GuestTokenRequester, storageProvider?: OptionsStorageProvider, tokenDataSerializer?: OptionsStorageSerializer, storageKey?: string); /** * Overrides TokenProvider's getSupportedTokenKind method. Returns the kind of * tokens that will be produced by this token provider. * * @returns Guest token kind. */ getSupportedTokenKind(): TokenKind; /** * Overrides TokenProvider's getAccessToken method. Will retrieve valid access * token from either the cache or through the requester. If using the requester, * will pass an object with a guestUserId property indicating either a guestUserId * if available or null if not available. * * @param useCache - If cache should be used or not. * * @returns Promise that will be resolved with a valid access token to be used. */ getAccessToken(useCache?: boolean): Promise; /** * Gets the token context object to use as the argument for requests to get new * guest user tokens. * * @returns The token context to be used on requests to get new guest user tokens. */ getTokenContext(): TokenContext; /** * Sets the token context to be used as the argument for future requests to get new * guest user tokens. Will override any previously set contexts. * * @param newContext - The new context to be set to. */ setTokenContext(newContext: TokenContext | null): void; /** * Resets the token context to the default one. */ resetTokenContext(): void; /** * Overrides TokenProvider's canRetrieveTokens method. Will return true if there is * a requester available and false otherwise. * * @returns - True if the instance is ready to retrieve tokens and false otherwise. */ canRetrieveTokens(): boolean; /** * Overrides TokenProvider's canSaveTokenData method. This ensures that for guest * tokens, only when there is a user id associated with the token and the token * does not have a context it can then be persisted. There is not much value in * saving the guest token without a user id associated or if the token is for a * specific context. */ canSaveTokenData(): boolean; } export default GuestTokenProvider;