@pisell/pisellos
Version:
一个可扩展的前端模块化SDK框架,支持插件系统
190 lines (189 loc) • 6.78 kB
TypeScript
import { Module, PisellCore } from '../../types';
import { BaseModule } from '../../modules/BaseModule';
import { RegisterParams, LoginParams, OAuthLoginParams, SendVerificationCodeParams, VerifyCodeParams, PasswordResetParams, UserInfo, ApiResponse, LoginResponse, RegisterResponse, OAuthLoginResponse, OAuthConfig, CountryInfo, SendSmsRegisterCodeParams, VerifyEmailRegistrationLinkParams, EmailPasswordLoginParams, SendSmsLoginCodeParams, PhoneCodeLoginParams, GuestLoginResponse, CheckEmailExistsParams, CheckEmailExistsResponse, CheckEmailCodeParams, CheckMobileCodeParams, CheckCodeValidResponse, PhonePasswordLoginParams, SendPasswordResetEmailParams, SendPasswordResetSmsParams, SendResetPasswordLinkParams, CheckResetPasswordCodeParams, ResetPasswordByCodeParams, EmailCodeRegisterParams, PhoneCodeRegisterParams, CheckEmailLinkCodeParams, CheckEmailLinkCodeResponse } from './types';
import { ApiCaller } from './config';
export * from './types';
export * from './config';
/**
* 注册登录解决方案实现
*/
export declare class RegisterAndLoginImpl extends BaseModule implements Module {
protected defaultName: string;
protected defaultVersion: string;
isSolution: boolean;
private request;
private window;
private store;
private apiCaller;
private otherParams;
private channel;
private countriesCache;
constructor(name?: string, version?: string);
/**
* 重新发送邮箱注册链接
*/
resendEmailRegisterLink(): Promise<ApiResponse>;
/**
* 邮箱验证码注册
* @param params 注册参数
* @returns 注册结果
*/
emailCodeRegister(params: EmailCodeRegisterParams): Promise<ApiResponse<RegisterResponse>>;
/**
* 手机验证码注册
*/
phoneCodeRegister(params: PhoneCodeRegisterParams): Promise<ApiResponse<RegisterResponse>>;
initialize(core: PisellCore, options: any): Promise<void>;
/**
* 从本地存储恢复登录状态
*/
private restoreLoginState;
/**
* 验证 token 有效性
*/
private validateToken;
/**
* 清除登录状态
*/
private clearLoginState;
/**
* 发送邮箱验证码
*/
sendEmailVerificationCode(params: SendVerificationCodeParams): Promise<ApiResponse>;
/**
* 发送邮箱登录验证码
*/
sendEmailLoginCode(params: SendVerificationCodeParams): Promise<ApiResponse>;
/**
* 发送手机号注册验证码
*/
sendSmsRegisterCode(params: SendSmsRegisterCodeParams): Promise<ApiResponse>;
/**
* 发送邮箱注册邀请链接
*/
sendEmailRegisterLink(email: string): Promise<ApiResponse>;
/**
* 验证邮箱注册链接
*/
verifyEmailRegistrationLink(params: VerifyEmailRegistrationLinkParams): Promise<ApiResponse>;
/**
* 邮箱密码登录
*/
emailPasswordLogin(params: EmailPasswordLoginParams): Promise<ApiResponse<LoginResponse>>;
/**
* 验证验证码
*/
verifyCode(params: VerifyCodeParams): Promise<ApiResponse>;
/**
* 用户注册
*/
register(params: RegisterParams): Promise<ApiResponse<RegisterResponse>>;
/**
* 用户登录
*/
login(params: LoginParams): Promise<ApiResponse<LoginResponse>>;
/**
* OAuth 登录
*/
oauthLogin(params: OAuthLoginParams): Promise<ApiResponse<OAuthLoginResponse>>;
/**
* 用户登出
*/
logout(): Promise<void>;
/** 发送重置密码邮箱链接 */
sendResetPasswordLink(params: SendResetPasswordLinkParams): Promise<ApiResponse>;
/** 检测重置密码链接code有效性 */
checkResetPasswordCode(params: CheckResetPasswordCodeParams): Promise<ApiResponse>;
/** 校验邮件链接 code 有效性 */
checkEmailLinkCode(params: CheckEmailLinkCodeParams): Promise<ApiResponse<CheckEmailLinkCodeResponse>>;
/** 通过code重置密码 */
resetPasswordByCode(params: ResetPasswordByCodeParams): Promise<ApiResponse>;
/**
* 重置密码
*/
resetPassword(params: PasswordResetParams): Promise<ApiResponse>;
/** 发送手机登录验证码 */
sendSmsLoginCode(params: SendSmsLoginCodeParams): Promise<ApiResponse>;
/** 手机号+短信验证码登录 */
phoneCodeLogin(params: PhoneCodeLoginParams): Promise<ApiResponse<LoginResponse>>;
private formatLoginParams;
/** Guest 登录 */
guestLogin(): Promise<ApiResponse<GuestLoginResponse>>;
/** 检查邮箱是否已注册 */
checkEmailExists(params: CheckEmailExistsParams): Promise<ApiResponse<CheckEmailExistsResponse>>;
/** 检查邮箱验证码是否有效 */
checkEmailCode(params: CheckEmailCodeParams): Promise<ApiResponse<CheckCodeValidResponse>>;
/** 检查手机验证码是否有效 */
checkMobileCode(params: CheckMobileCodeParams): Promise<ApiResponse<CheckCodeValidResponse>>;
/** 手机号密码登录 */
phonePasswordLogin(params: PhonePasswordLoginParams): Promise<ApiResponse<LoginResponse>>;
/** 发送密码重置邮箱验证码 */
sendPasswordResetEmail(params: SendPasswordResetEmailParams): Promise<ApiResponse>;
/** 发送手机号验证码重置密码 */
sendPasswordResetSms(params: SendPasswordResetSmsParams): Promise<ApiResponse>;
/**
* 获取当前用户信息
*/
getCurrentUser(): UserInfo | null;
/**
* 检查是否已登录
*/
isLoggedIn(): boolean;
/**
* 获取加载状态
*/
isLoading(): boolean;
/**
* 获取错误信息
*/
getError(): string | null;
/**
* 清除错误信息
*/
clearError(): void;
/**
* 检查验证码是否已发送且未过期
*/
isVerificationCodeSent(target: string): boolean;
/**
* 获取验证码剩余时间(秒)
*/
getVerificationCodeRemainingTime(target: string): number;
/**
* 初始化 Facebook SDK
*/
initFacebookSDK(token: string): Promise<void>;
/**
* 初始化 Apple SDK
*/
initAppleSDK(): Promise<void>;
/**
* Facebook 登录
*/
loginWithFacebook(token: string): Promise<unknown>;
/**
* Apple 登录(需要在支持的环境中使用)
*/
loginWithApple(token: string): Promise<unknown>;
/**
* 更新 OAuth 配置
*/
updateOAuthConfig(config: Partial<OAuthConfig>): void;
/**
* 获取当前渠道
*/
getCurrentChannel(): string;
/**
* 获取 API 调用器(用于高级用法)
*/
getApiCaller(): ApiCaller;
/**
* 获取国家区号列表
*/
getCountries(): Promise<CountryInfo[]>;
/**
* 异步更新国家缓存数据
*/
private updateCountriesCache;
destroy(): Promise<void>;
}