UNPKG

@pisell/pisellos

Version:

一个可扩展的前端模块化SDK框架,支持插件系统

446 lines (445 loc) 9.78 kB
/** * 注册登录解决方案类型定义 */ /** * 注册登录流程 hooks */ export declare enum RegisterAndLoginHooks { onInited = "registerAndLogin:onInited", onDestroy = "registerAndLogin:onDestroy", onEmailVerificationSent = "registerAndLogin:onEmailVerificationSent", onEmailVerificationVerified = "registerAndLogin:onEmailVerificationVerified", onEmailVerificationFailed = "registerAndLogin:onEmailVerificationFailed", onSmsVerificationSent = "registerAndLogin:onSmsVerificationSent", onSmsVerificationVerified = "registerAndLogin:onSmsVerificationVerified", onSmsVerificationFailed = "registerAndLogin:onSmsVerificationFailed", onOAuthLoginStarted = "registerAndLogin:onOAuthLoginStarted", onOAuthLoginSuccess = "registerAndLogin:onOAuthLoginSuccess", onOAuthLoginFailed = "registerAndLogin:onOAuthLoginFailed", onRegisterStarted = "registerAndLogin:onRegisterStarted", onRegisterSuccess = "registerAndLogin:onRegisterSuccess", onRegisterFailed = "registerAndLogin:onRegisterFailed", onLoginStarted = "registerAndLogin:onLoginStarted", onLoginSuccess = "registerAndLogin:onLoginSuccess", onLoginFailed = "registerAndLogin:onLoginFailed", onPasswordResetStarted = "registerAndLogin:onPasswordResetStarted", onPasswordResetSuccess = "registerAndLogin:onPasswordResetSuccess", onPasswordResetFailed = "registerAndLogin:onPasswordResetFailed" } /** * OAuth 提供商类型 */ export declare enum OAuthProvider { FACEBOOK = "facebook", APPLE = "apple", GOOGLE = "google", WECHAT = "wechat", GITHUB = "github" } /** * 验证码类型 */ export declare enum VerificationCodeType { EMAIL = "email", SMS = "sms" } /** * 验证码用途 */ export declare enum VerificationPurpose { REGISTER = "register", LOGIN = "login", PASSWORD_RESET = "password_reset", CHANGE_EMAIL = "change_email", CHANGE_PHONE = "change_phone" } /** * 用户信息接口 */ export interface UserInfo { id: string; email?: string; phone?: string; name?: string; avatar?: string; isEmailVerified: boolean; isPhoneVerified: boolean; createdAt: string; updatedAt: string; [key: string]: any; } /** * 注册参数接口 */ export interface RegisterParams { email?: string; phone?: string; password: string; name?: string; verificationCode?: string; verificationCodeType?: VerificationCodeType; [key: string]: any; } /** * 登录参数接口 */ export interface LoginParams { email?: string; phone?: string; password?: string; verificationCode?: string; verificationCodeType?: VerificationCodeType; rememberMe?: boolean; [key: string]: any; } /** * OAuth 登录参数接口 */ export interface OAuthLoginParams { provider: OAuthProvider; code?: string; accessToken?: string; redirectUri?: string; [key: string]: any; } /** * 发送验证码参数接口 */ export interface SendVerificationCodeParams { type: VerificationCodeType; target: string; purpose: VerificationPurpose; [key: string]: any; } /** * 验证验证码参数接口 */ export interface VerifyCodeParams { type: VerificationCodeType; target: string; code: string; purpose: VerificationPurpose; [key: string]: any; } /** * 密码重置参数接口 */ export interface PasswordResetParams { type: 'email' | 'phone'; target: { email?: string; phone?: string; country_calling_code?: string; }; password: string; code: string; } /** * OAuth 配置接口 */ export interface OAuthConfig { [OAuthProvider.FACEBOOK]?: { appId: string; appSecret?: string; redirectUri?: string; scope?: string[]; }; [OAuthProvider.APPLE]?: { clientId: string; teamId?: string; keyId?: string; privateKey?: string; redirectUri?: string; scope?: string[]; }; [OAuthProvider.GOOGLE]?: { clientId: string; clientSecret?: string; redirectUri?: string; scope?: string[]; }; [OAuthProvider.WECHAT]?: { appId: string; appSecret?: string; redirectUri?: string; scope?: string[]; }; [OAuthProvider.GITHUB]?: { clientId: string; clientSecret?: string; redirectUri?: string; scope?: string[]; }; } /** * 注册登录状态接口 */ export interface RegisterAndLoginState { currentUser: UserInfo | null; isLoggedIn: boolean; isLoading: boolean; verificationCodeSent: { [key: string]: { sent: boolean; sentAt: number; expiresAt: number; }; }; emailRegisterLinkCode: string | null; oauthConfig: OAuthConfig; error: string | null; [key: string]: any; } /** * API 响应接口 */ export interface ApiResponse<T = any> { status: boolean; data?: T; message?: string; error?: string; code?: number; } /** * 登录响应接口 */ export interface LoginResponse { user: UserInfo; token: string; refreshToken?: string; expiresAt: number; } /** * 注册响应接口 */ export interface RegisterResponse { user: UserInfo; token?: string; refreshToken?: string; expiresAt?: number; needVerification?: boolean; } /** * OAuth 登录响应接口 */ export interface OAuthLoginResponse { user: UserInfo; token: string; refreshToken?: string; expiresAt: number; isNewUser: boolean; } /** * 国家信息接口 */ export interface CountryInfo { name: string; code: string; calling_code: string; currency_code: string; } /** * 获取国家区号响应接口 */ export interface GetCountriesResponse { status: boolean; code: number; message: string; data: CountryInfo[]; } /** * 发送手机号注册验证码参数接口 */ export interface SendSmsRegisterCodeParams { phone: string; country_calling_code: string; } /** * 发送邮箱注册邀请链接参数接口 */ export interface SendEmailRegisterLinkParams { email: string; } /** * 验证邮箱注册链接参数接口 */ export interface VerifyEmailRegistrationLinkParams { code: string; password: string; } /** * 邮箱密码登录参数接口 */ export interface EmailPasswordLoginParams { email: string; password: string; } /** * 发送手机登录验证码参数接口 */ export interface SendSmsLoginCodeParams { phone: string; country_calling_code: string; } /** * 手机号验证码登录参数接口 */ export interface PhoneCodeLoginParams { phone: string; country_calling_code: string; code: string; } /** * Guest 登录响应接口 */ export interface GuestLoginResponse { user: UserInfo; token: string; refreshToken?: string; customer: any; } /** * 检查邮箱是否已注册参数接口 */ export interface CheckEmailExistsParams { email: string; shop_id: number; } /** * 检查邮箱是否已注册响应接口 */ export interface CheckEmailExistsResponse { exists: boolean; } /** * 检查邮箱验证码是否有效参数接口 */ export interface CheckEmailCodeParams { email: string; shop_id: number; code: string; action: string; } /** * 检查手机验证码是否有效参数接口 */ export interface CheckMobileCodeParams { phone: string; shop_id: number; code: string; country_calling_code: string; action: string; } /** * 验证码有效性检查响应接口 */ export interface CheckCodeValidResponse { valid: boolean; } /** * 手机号密码登录参数接口 */ export interface PhonePasswordLoginParams { phone: string; password: string; country_calling_code: string; } /** * 发送密码重置邮箱验证码参数接口 */ export interface SendPasswordResetEmailParams { email: string; } /** * 发送重置密码手机号验证码参数接口 */ export interface SendPasswordResetSmsParams { phone: string; country_calling_code: string; } /** * 发送重置密码邮箱链接参数接口 */ export interface SendResetPasswordLinkParams { email: string; } /** * 检测重置密码链接code有效性参数接口 */ export interface CheckResetPasswordCodeParams { code: string; } /** * 通过code重置密码参数接口 */ export interface ResetPasswordByCodeParams { code: string; password: string; } /** * 邮箱验证码注册参数接口 */ export interface EmailCodeRegisterParams { email: string; code: string; password: string; } /** * 手机验证码注册参数接口 */ export interface PhoneCodeRegisterParams { phone: string; password: string; code: string; country_calling_code: string; } /** * 重新发送邮箱注册链接参数接口 */ export interface ResendEmailRegisterLinkParams { code: string; } /** * 校验邮件链接 code 有效性参数接口 */ export interface CheckEmailLinkCodeParams { code: string; } /** * 校验邮件链接 code 有效性响应接口 */ export interface CheckEmailLinkCodeResponse { valid: boolean; } /** * Apple 登录参数 */ export interface AppleLoginParams { token: string; } /** * Apple 登录响应 */ export interface AppleLoginResponse { user: UserInfo; token: string; refreshToken?: string; expiresAt: number; isNewUser: boolean; } /** * Facebook 登录参数 */ export interface FacebookLoginParams { token: string; } /** * Facebook 登录响应 */ export interface FacebookLoginResponse { user: UserInfo; token: string; refreshToken?: string; expiresAt: number; isNewUser: boolean; }