oak-general-business/lib/utils/oauth/index.d.ts

21 lines
1.1 KiB
TypeScript

import BackendRuntimeContext from "../../context/BackendRuntimeContext";
import { EntityDict } from "../../oak-app-domain";
type UserInfo = EntityDict['oauthUser']['Schema']['rawUserInfo'];
type UserID = {
id: EntityDict['oauthUser']['Schema']['providerUserId'];
name: EntityDict['user']['Schema']['name'];
nickname: EntityDict['user']['Schema']['nickname'];
gender: EntityDict['user']['Schema']['gender'];
birth: EntityDict['user']['Schema']['birth'];
avatarUrl: string | null;
};
export type UserInfoHandler = (data: UserInfo) => UserID | Promise<UserID>;
export declare const registerOauthUserinfoHandler: (type: EntityDict["oauthProvider"]["Schema"]["type"], handler: UserInfoHandler) => void;
export declare const processUserInfo: (type: EntityDict["oauthProvider"]["Schema"]["type"], data: UserInfo) => UserID | Promise<UserID>;
export declare function checkOauthTokenAvaliable(context: BackendRuntimeContext<EntityDict>, token: string | undefined): Promise<{
error: string | null;
statusCode?: number;
tokenRecord?: Partial<EntityDict['oauthToken']['Schema']>;
}>;
export {};