oak-general-business/lib/features/token.d.ts

49 lines
2.5 KiB
TypeScript

import { Feature } from 'oak-frontend-base/es/types/Feature';
import { Cache } from 'oak-frontend-base/es/features/cache';
import { LocalStorage } from 'oak-frontend-base/es/features/localStorage';
import { Environment } from 'oak-frontend-base/es/features/environment';
import { Application } from './application';
import { EntityDict } from '../oak-app-domain';
export declare class Token<ED extends EntityDict> extends Feature {
protected tokenValue?: string;
protected environment: Environment;
protected cache: Cache<ED>;
protected storage: LocalStorage;
protected application: Application<ED>;
protected loadSavedToken(): Promise<void>;
constructor(cache: Cache<ED>, storage: LocalStorage, environment: Environment, application: Application<ED>);
protected checkNeedSetPassword(): Promise<never> | undefined;
refreshTokenData(tokenValue?: string): Promise<void>;
loginByMobile(mobile: string, captcha?: string, disableRegister?: boolean): Promise<void>;
loginByEmail(email: string, captcha: string, disableRegister?: boolean): Promise<void>;
loginByAccount(account: string, password: string): Promise<void>;
bindByMobile(mobile: string, captcha?: string): Promise<void>;
bindByEmail(email: string, captcha?: string): Promise<void>;
loginByWechatInWebEnv(wechatLoginId: string): Promise<void>;
loginWechat(code: string, params?: {
wechatLoginId?: string;
}): Promise<void>;
loginWechatMp(): Promise<void>;
loginWechatNative(code: string): Promise<void>;
syncUserInfoWechatMp(): Promise<void>;
logout(dontPublish?: boolean): Promise<void>;
removeToken(dontPublish?: boolean): void;
getTokenValue(): string | undefined;
getToken(allowUnloggedIn?: boolean): Partial<ED["token"]["Schema"]> | undefined;
getUserId(allowUnloggedIn?: boolean): NonNullable<ED["token"]["Schema"]["userId"]> | undefined;
getUserInfo(): NonNullable<ED["token"]["Schema"]["user"]> | undefined;
isRoot(): boolean;
/**
* 这个是指token的player到底是不是root
* @returns
*/
isReallyRoot(): boolean;
sendCaptcha(origin: 'email' | 'mobile', content: string, type: 'login' | 'changePassword' | 'confirm'): Promise<string>;
switchTo(userId: string): Promise<void>;
refreshWechatPublicUserInfo(): Promise<void>;
getWechatMpUserPhoneNumber(code: string): Promise<void>;
wakeupParasite(id: string): Promise<void>;
needVerifyPassword(): boolean | null | undefined;
verifyPassword(password: string): Promise<void>;
}