/** * Token 跨窗口同步模块 * * 用于 Staging 环境下,iframe 中通过新标签页完成 OAuth 登录后, * 将 token 同步回 iframe 的场景。 */ /** * 发送端:通知 opener (iframe) token 已更新 * 调用时机:TokenStore.setToken() 时 */ export declare function notifyOpenerTokenUpdate(token: string, origin: string): void; /** * 接收端:监听来自新 tab 的 token 消息 * 调用时机:TokenStore 初始化时 * * @param onToken 收到 token 时的回调 * @returns 清理函数 */ export declare function listenForTokenSync(onToken: (token: string, origin: string) => void): () => void; /** * 页面加载时检测是否需要同步 token * * 场景:用户在 iframe 中登出后,再次点击 OAuth 按钮打开新 tab, * 但新 tab 的 localStorage 中仍有 token(两边不共享)。 * 此时需要主动发送 postMessage 给 opener。 * * @param getAllTokens 获取所有存储的 token 的函数(返回 origin -> token 的映射) */ export declare function syncTokenOnLoad(getAllTokens: () => Record): void; /** * 构建带有同步参数的 URL * 用于 IframeOAuthModal 打开新 tab 时 */ export declare function buildSyncUrl(baseUrl: string): string;