import { TokenSourceResponse } from '@livekit/protocol'; import { TokenSourceConfigurable, type TokenSourceFetchOptions, TokenSourceFixed, type TokenSourceResponseObject } from './types'; import { areTokenSourceFetchOptionsEqual, decodeTokenPayload } from './utils'; /** A TokenSourceCached is a TokenSource which caches the last {@link TokenSourceResponseObject} value and returns it * until a) it expires or b) the {@link TokenSourceFetchOptions} provided to .fetch(...) change. */ declare abstract class TokenSourceCached extends TokenSourceConfigurable { private cachedFetchOptions; private cachedResponse; private fetchMutex; private isSameAsCachedFetchOptions; private shouldReturnCachedValueFromFetch; getCachedResponseJwtPayload(): import("./types").TokenPayload | null; fetch(options: TokenSourceFetchOptions, force?: boolean): Promise; protected abstract update(options: TokenSourceFetchOptions): Promise; } type LiteralOrFn = TokenSourceResponseObject | (() => TokenSourceResponseObject | Promise); declare class TokenSourceLiteral extends TokenSourceFixed { private literalOrFn; constructor(literalOrFn: LiteralOrFn); fetch(): Promise; } type CustomFn = (options: TokenSourceFetchOptions) => TokenSourceResponseObject | Promise; declare class TokenSourceCustom extends TokenSourceCached { private customFn; constructor(customFn: CustomFn); protected update(options: TokenSourceFetchOptions): Promise; } export type EndpointOptions = Omit; declare class TokenSourceEndpoint extends TokenSourceCached { private url; private endpointOptions; constructor(url: string, options?: EndpointOptions); private createRequestFromOptions; protected update(options: TokenSourceFetchOptions): Promise; } export type SandboxTokenServerOptions = { baseUrl?: string; }; declare class TokenSourceSandboxTokenServer extends TokenSourceEndpoint { constructor(sandboxId: string, options: SandboxTokenServerOptions); } export { /** The return type of {@link TokenSource.literal} */ type TokenSourceLiteral, /** The return type of {@link TokenSource.custom} */ type TokenSourceCustom, /** The return type of {@link TokenSource.endpoint} */ type TokenSourceEndpoint, /** The return type of {@link TokenSource.sandboxTokenServer} */ type TokenSourceSandboxTokenServer, decodeTokenPayload, areTokenSourceFetchOptionsEqual, }; export declare const TokenSource: { /** TokenSource.literal contains a single, literal set of {@link TokenSourceResponseObject} * credentials, either provided directly or returned from a provided function. */ literal(literalOrFn: LiteralOrFn): TokenSourceLiteral; /** * TokenSource.custom allows a user to define a manual function which generates new * {@link TokenSourceResponseObject} values on demand. * * Use this to get credentials from custom backends / etc. */ custom(customFn: CustomFn): TokenSourceCustom; /** * TokenSource.endpoint creates a token source that fetches credentials from a given URL using * the standard endpoint format: * @see https://cloud.livekit.io/projects/p_/sandbox/templates/token-server */ endpoint(url: string, options?: EndpointOptions): TokenSourceEndpoint; /** * TokenSource.sandboxTokenServer queries a sandbox token server for credentials, * which supports quick prototyping / getting started types of use cases. * * This token provider is INSECURE and should NOT be used in production. * * For more info: * @see https://cloud.livekit.io/projects/p_/sandbox/templates/token-server */ sandboxTokenServer(sandboxId: string, options?: SandboxTokenServerOptions): TokenSourceSandboxTokenServer; }; //# sourceMappingURL=TokenSource.d.ts.map