import { AuthTokens, AuthUser } from '../types'; import { Logger } from './Logger'; export interface SharedSession { user: AuthUser; tokens: AuthTokens; } export interface TabSyncCallbacks { onRemoteLogin: (user: AuthUser, tokens: AuthTokens) => void; onRemoteLogout: () => void; onRemoteTokenRefresh: (tokens: AuthTokens) => void; /** * Another instance asks for the current session (e.g. a secondary window * whose token expired). Resolve `null` to stay silent. */ onSessionRequest?: () => Promise; } /** * TabSyncManager — synchronises auth state across browser tabs on the same origin. * * Uses the BroadcastChannel API (browser-only). Each SDK instance gets a random * tabId so it can ignore messages it originally sent, preventing echo loops. * * Usage: * const mgr = new TabSyncManager('myapp', callbacks, logger); * mgr.start(); // open channel * mgr.broadcastLogin(); // notify other tabs * mgr.destroy(); // close channel (call from AuthSDK.destroy()) */ export declare class TabSyncManager { private readonly callbacks; private readonly logger; private channel; private readonly tabId; private readonly pendingRequests; private readonly channelName; constructor(channelName: string, callbacks: TabSyncCallbacks, logger: Logger); /** Open the BroadcastChannel and start listening for remote events. */ start(): void; /** Notify other tabs that this tab logged in. */ broadcastLogin(user: AuthUser, tokens: AuthTokens): void; /** Notify other tabs that this tab logged out. */ broadcastLogout(): void; /** Notify other tabs that tokens were refreshed so they update in-memory state. */ broadcastTokenRefresh(tokens: AuthTokens): void; /** * Asks the other instances for the current session. Resolves with the first * answer, or `null` if nobody answers within `timeoutMs`. */ requestSession(timeoutMs: number): Promise; /** Close the channel. Safe to call multiple times. */ destroy(): void; /** Returns true when the BroadcastChannel API is available (browser only). */ static isSupported(): boolean; private send; private handleMessage; private answerSessionRequest; } //# sourceMappingURL=TabSyncManager.d.ts.map