import { EventEmitter } from "node:events"; import type { ITokenManager } from "@superblocksteam/util"; /** * Holds the active bearer credential and notifies subscribers on change. * * Two access patterns are intentionally supported and serve distinct roles: * * - `updateToken(t)` writes the current token AND emits `tokenUpdated`. * The event stream is the **refresh channel**: subscribers (e.g. * `AutoConnectingRpcClient`, `AiService`) react to changes (e.g. tear * down a socket and reconnect with the new credential). * * - `getCurrentToken()` returns the most recently set token, or * `undefined` if none. This is the **seed channel**: consumers that * need a bearer credential at construction time read it directly. * Without this, a consumer whose listener is attached *after* a prior * `updateToken()` would silently observe nothing — Node `EventEmitter` * has no replay. Closes the cold-start gap for `NpmRegistryClient` * when the CLI primes the manager from `tokenConfig.token` at startup. * * Events are deliberately NOT auto-replayed on `on(...)`: a fresh * subscriber receives only future emissions. Auto-replay would make a * late-attached refresh handler (e.g. one that closes and reconnects a * socket) fire on what is conceptually a seed read, producing spurious * tear-down/reconnect churn. * * The current implementation does not surface a `clearToken()` API. * Today's lifecycle never needs one — a process holds at most one user's * credentials and exits when they log out. Add one if/when a multi-tenant * or in-process re-auth path requires it. */ export declare class TokenManager extends EventEmitter implements ITokenManager { private currentToken; updateToken(newToken: string): void; getCurrentToken(): string | undefined; } //# sourceMappingURL=token-manager.d.ts.map