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

61 lines
3.0 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { Feature } from 'oak-frontend-base/es/types/Feature';
import { OakException } from 'oak-domain/lib/types/Exception';
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 ignoreExceptionList: typeof OakException<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>;
loginWebByMpToken(mpToken: string): Promise<void>;
loginByWechatInWebEnv(wechatLoginId: string): Promise<void>;
loginByOAuth(code: string, state: string): Promise<void>;
loginWechat(code: string, params?: {
wechatLoginId?: string;
}): Promise<void>;
loginWechatMp(params?: {
wechatLoginId?: string;
}): 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;
isSelf(): 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>;
/**
* 添加一个异常到忽略列表如果refreshToken时出现这个异常不会强制用户登出
*/
addIgnoreException(clazz: typeof OakException<ED>): void;
removeIgnoreException(clazz: typeof OakException<ED>): void;
}