/** * ============================================================================ * @amaster.ai/auth-client - Type Definitions * ============================================================================ * * 🤖 AI NAVIGATION - Read these files based on your task: * * 1. Need LOGIN/REGISTER/LOGOUT? → Read: ./auth.d.ts * 2. Need PERMISSION checks? → Read: ./permissions.d.ts * 3. Need USER profile management? → Read: ./user.d.ts * 4. Need OAUTH binding? → Read: ./oauth.d.ts * 5. Need SESSION management? → Read: ./sessions.d.ts * * ============================================================================ */ import { HttpClient, ClientResult } from '@amaster.ai/http-client'; import { w as User, R as RefreshTokenResponse, o as RegisterParams, e as LoginResponse, L as LoginParams, c as CodeLoginParams, S as SendCodeParams, v as SuccessResponse, b as CaptchaResponse, m as OAuthProvider, i as MiniProgramLoginParams, h as MiniLoginParams, k as MiniProgramPhoneParams, l as MiniProgramPhoneResponse, g as MiniGetPhoneParams } from './types-DqwQ2EzH.js'; /** * Authentication Module * * @module auth * @category Authentication * * Handles user authentication including: * - Registration * - Login (email/username/phone + password) * - Verification code login * - OAuth social login * - Logout and token refresh */ declare const browserNavigation: { replace(url: string): void; }; interface AuthModuleDeps { http: HttpClient; onLoginSuccess: (user: User, accessToken: string) => void; onLogout: () => void; autoRedirectAfterLogin: boolean; storage: { getItem: (key: string) => string | null; setItem: (key: string, value: string) => void; }; clearAuth: () => void; onRefreshFailure?: (result: ClientResult) => void; } declare function createAuthModule(deps: AuthModuleDeps): { /** * Register a new user account * * @category Authentication * @example * ```typescript * const result = await auth.register({ * email: "user@example.com", * password: "Password@123", * displayName: "John Doe", * }); * ``` */ register(params: RegisterParams): Promise>; /** * Login with username/email/phone and password * * @category Authentication * @example * ```typescript * // Auto-detect loginType from username * await auth.login({ * username: "john_doe", * password: "Password@123", * }); * * // Auto-detect loginType from email * await auth.login({ * email: "user@example.com", * password: "Password@123", * }); * ``` */ login(params: LoginParams): Promise>; /** * Login with verification code * * @category Authentication * @example * ```typescript * // Auto-detect loginType from email * await auth.loginWithCode({ * email: "user@example.com", * code: "123456", * }); * * // Auto-detect loginType from phone * await auth.loginWithCode({ * phone: "13800138000", * code: "123456", * }); * ``` */ loginWithCode(params: CodeLoginParams): Promise>; /** * Send verification code to email or phone * * @category Authentication * @example * ```typescript * await auth.sendCode({ * type: "email", * email: "user@example.com", * }); * ``` */ sendCode(params: SendCodeParams): Promise>; /** * Get captcha image * * @category Authentication */ getCaptcha(): Promise>; /** * Redirect to OAuth provider for authentication * * @category Authentication * @example * ```typescript * auth.loginWithOAuth("google"); * ``` */ loginWithOAuth(provider: OAuthProvider, redirectUrl?: string): void; /** * Handle OAuth callback * * @category Authentication */ handleOAuthCallback(): Promise>; /** * Login with Mini Program code * * Lower-level API for submitting an already acquired mini-program login code. * For most app code, prefer `miniLogin()`. * * @deprecated Prefer `miniLogin()` unless you already have a resolved mini-program login code. * * @category Authentication */ loginWithMiniProgram(input: string | MiniProgramLoginParams): Promise>; /** * Unified Mini Program login entry. * * Automatically calls Taro / WeChat `wx` / Douyin `tt` login APIs to fetch the temporary login code, * then submits it to the backend using the correct platform endpoint. * * @category Authentication * @example * ```typescript * const result = await auth.miniLogin(); * * const douyinResult = await auth.miniLogin({ * platform: "douyin", * }); * ``` */ miniLogin(params?: MiniLoginParams): Promise>; /** * Get Mini Program user phone number * Requires user authorization via getPhoneNumber button * * Lower-level API for submitting an already acquired phone code. * For most app code, prefer `miniGetPhone(...)`. * * @deprecated Prefer `miniGetPhone(...)` unless you already have a resolved phone authorization code. * * @category Authentication */ getMiniProgramPhoneNumber(input: string | MiniProgramPhoneParams): Promise>; /** * Unified Mini Program phone binding entry. * * Accepts a raw code, a `{ code, platform }` object, or a Mini Program event object * such as the payload received from WeChat `wx`, Douyin `tt`, or Taro `getPhoneNumber`. * * @category Authentication * @example * ```typescript * const result = await auth.miniGetPhone(e); * * const douyinResult = await auth.miniGetPhone({ * code, * platform: "douyin", * }); * ``` */ miniGetPhone(input: MiniGetPhoneParams): Promise>; /** * Logout current user * * @category Authentication * @example * ```typescript * await auth.logout(); * ``` */ logout(): Promise>; /** * Refresh access token * * @category Authentication */ refreshToken(): Promise>; }; type AuthModule = ReturnType; export { type AuthModule, type AuthModuleDeps, browserNavigation, createAuthModule };