/** * @module transport/TokensManager * @description Manager for handling multiple bot tokens */ import { TokensData, TokensDictionary } from '../types/transport.types.js'; import type { ILogger, LoggerOptions, ILoggerAware } from '../types/logger.types.js'; /** * Tokens manager configuration options */ export interface TokensManagerOptions extends LoggerOptions { /** Initial tokens map */ initialTokens?: TokensDictionary; /** Default token ID */ defaultTokenId?: string; } /** * Tokens manager implementation for managing multiple bot tokens * Supports adding, removing, and retrieving tokens by ID */ export declare class TokensManager implements TokensData, ILoggerAware { private tokens; private defaultTokenId?; /** Logger instance - mutable to support LoggerBinder.bind() */ logger?: ILogger; /** * Create a new TokensManager instance * @param options - Configuration options or initial tokens map (for backward compatibility) * @param defaultTokenId - Optional default token ID (for backward compatibility) */ constructor(options?: TokensManagerOptions | TokensDictionary, defaultTokenId?: string); /** * Add a bot token to the manager * @param tokenId - Unique identifier for the token (e.g., bot name or ID) * @param token - Bot token from BotFather * @returns True if token was added successfully, false if tokenId already exists */ addToken(tokenId: string, token: string): boolean; /** * Remove a bot token from the manager * @param tokenId - Token identifier to remove * @param defaultId - Optional new default token ID if removing the current default * @returns True if token was removed, false if tokenId doesn't exist */ removeToken(tokenId: string, defaultId?: string): boolean; /** * Get a bot token by ID * @param tokenId - Token identifier * @returns Bot token or undefined if not found */ getToken(tokenId: string): string | undefined; /** * Set the default token * @param tokenId - Token identifier to set as default * @returns True if successfully set, false if tokenId doesn't exist */ setDefaultToken(tokenId: string): boolean; /** * Get the default token * @returns Default bot token or undefined if no default is set */ getDefaultToken(): string | undefined; /** * Get the default token ID * @returns Default token ID or undefined if no default is set */ getDefaultTokenId(): string | undefined; /** * Get all token IDs * @returns Array of all token IDs */ getTokenIds(): string[]; /** * Get all token IDs (alias for getTokenIds) * @returns Array of all token IDs */ getAllTokenIds(): string[]; /** * Check if a token exists * @param tokenId - Token identifier to check * @returns True if token exists, false otherwise */ hasToken(tokenId: string): boolean; /** * Get the number of tokens * @returns Number of tokens in the manager */ getTokenCount(): number; /** * Clear all tokens */ clear(): void; }