declare type LoginMode = "mp" | "code"; /** * 单次登录调用的可选项(requireAuth / showAuthModal 入参)。 * * `required` 只作用于「本次弹出的这个弹窗」,不污染 init 的全局配置: * - 不传 → 用 init 时的 config.required; * - false → 本次弹窗带 × 可关闭(用户主动点登录的场景,如右上角头像); * - true → 本次弹窗强制不可关闭(后台校验 / 后端 401 拦截的场景)。 */ export declare interface RequireAuthOptions { required?: boolean; } export declare const WxAuth: { init(options?: Partial): void; /** * 取当前匿名票据(同步,不触发签发)。没有或临期返回 null—— * 一般业务直接用 getOrCreateAnonTicket,本方法供想自己控制签发时机的接入方。 */ getAnonTicket(): string | null; /** * 取匿名票据,没有/临期则自动向 wx-auth 签发口要一张(并发调用合并为一次)。 * 签发失败(bot UA 403 / 限流 429 / 断网)返回 null——fail-open:票据系统 * 故障不阻断业务,是否放行无票请求由接入方自己定夺。 * * 建议在建立 SSE 连接前 await 本方法,把返回值拼在 URL 上: * const at = await WxAuth.getOrCreateAnonTicket(); * const es = new EventSource(`${url}${url.includes("?") ? "&" : "?"}at=${at}`); */ getOrCreateAnonTicket(): Promise; /** * 静默验证(silent 模式专用) * - cookie 有效 → setCookie(token) + onVerified,不调 showAuthModal * - cookie 无效 / 不存在 → 不清 cookie、不弹窗,仅返回 false * (2026-08-28:不再 deleteCookie。失效 cookie 保留,供后端识别"有凭证但 * 失效"(取关)→ 返回 401 → 前端弹认证弹窗;后端通过有无 cookie 区分 * "页面用户取关"(401)与"无凭证爬虫"(蜜罐假数据)) * - 网络错误 → 静默忽略(留给消费者后续 requireAuth 重试) */ silentCheck(): Promise; autoCheck(): Promise; showAuthModal(options?: RequireAuthOptions): Promise; switchMode(mode: LoginMode): void; startMpLogin(): Promise; requireAuth(options?: RequireAuthOptions): Promise; completeLogin(result: { token?: string; user?: any; }): void; verifyCode(): Promise; close(skipOnClose?: boolean): void; clearToken(): void; revoke(): Promise; onVerified(user: any): void; onError(error: any): void; }; /** * 微信订阅号认证 SDK - 极简版 * * 特点: * - 仅需配置 apiBase * - 复用现有后端 API * - 无额外依赖 * - 总大小 < 10KB * - 弹窗防删除保护 * * 使用方法: * * 1. 引入SDK * import { WxAuth } from './wx-auth'; * import './wx-auth.css'; * * 2. 初始化 * WxAuth.init({ * apiBase: 'https://wx-auth.shenzjd.com', * onVerified: (user) => { console.log('验证通过', user); } * }); * * 3. 使用 * await WxAuth.requireAuth(); */ export declare interface WxAuthConfig { apiBase: string; onVerified?: ((user: any) => void) | null; onError?: ((error: any) => void) | null; onClose?: (() => void) | null; required?: boolean; wechatName?: string; qrcodeUrl?: string; silent?: boolean; } export { }