import type { authModels, OAUTH_TYPE } from '@cloudbase/oauth'; import { AuthError } from '@cloudbase/oauth'; export interface SignInAnonymouslyReq { provider_token?: string; } export declare type User = { id: any; aud: string; role: string[]; email: any; email_confirmed_at: string; phone: any; phone_confirmed_at: string; confirmed_at: string; last_sign_in_at: string; app_metadata: { provider: any; providers: any[]; }; user_metadata: { name: any; picture: any; username: any; gender: any; locale: any; uid: any; nickName: any; avatarUrl: any; location: any; hasPassword: any; }; identities: any; created_at: string; updated_at: string; is_anonymous: boolean; }; export declare type Session = { access_token?: string; refresh_token?: string; expires_in?: number; token_type?: string; user: User; }; export interface SignInWithPasswordReq { username?: string; email?: string; phone?: string; password: string; is_encrypt?: boolean; } export interface CommonRes { data: {}; error: AuthError | null; } export interface SignInRes { data: { user?: User; session?: Session; }; error: AuthError | null; } export interface GetUserRes { data: { user?: User; }; error: AuthError | null; } export interface UpdateUserVerifyOtpParams { email?: string; phone?: string; token: string; } declare type UpdateUserVerifyCallback = (params: UpdateUserVerifyOtpParams) => Promise; export interface UpdateUserWithVerificationRes { data: { verifyOtp?: UpdateUserVerifyCallback; messageId?: string; }; error: AuthError | null; } export interface SignInWithIdTokenReq { provider?: string; token: string; } export interface SignInWithOAuthReq { provider: string; options?: { redirectTo?: string; skipBrowserRedirect?: boolean; state?: string; queryParams?: Record; type?: (typeof OAUTH_TYPE)[keyof typeof OAUTH_TYPE]; }; } export interface SignInOAuthRes { data: { url?: string; provider?: string; scopes?: string; }; error: AuthError | null; } export interface GetClaimsRes { data: { claims?: { iss: string; sub: string; aud: string; exp: number; iat: number; at_hash: string; name: string; picture?: string; email?: string; phone_number?: string; scope: string; project_id: string; provider?: string; provider_type?: string; groups?: string[]; meta?: { wxOpenId?: string; wxUnionId?: string; }; user_id: string; roles: string[]; user_type: string; client_type: string; is_system_admin: boolean; }; header?: { alg: string; kid: string; }; signature?: string; }; error: AuthError | null; } export interface UpdateUserReq extends authModels.ModifyUserBasicInfoRequest { email?: string; phone?: string; username?: string; description?: string; avatar_url?: string; nickname?: string; gender?: 'MALE' | 'FEMALE'; } export interface GetUserIdentitiesRes { data: { identities?: Array<{ id: string; name: string; picture: string; }>; }; error: AuthError | null; } export interface LinkIdentityReq { provider: string; } export interface UnlinkIdentityReq { provider: string; } export interface LinkIdentityRes { data: { provider?: string; type?: (typeof OAUTH_TYPE)[keyof typeof OAUTH_TYPE]; }; error: AuthError | null; } export declare type OnAuthStateChangeEvent = 'SIGNED_OUT' | 'SIGNED_IN' | 'INITIAL_SESSION' | 'PASSWORD_RECOVERY' | 'TOKEN_REFRESHED' | 'USER_UPDATED' | 'BIND_IDENTITY'; export declare type OnAuthStateChangeCallback = (event: OnAuthStateChangeEvent, session: Session, info?: Record) => void; type MobileOtpType = 'sms' | 'phone_change'; type EmailOtpType = 'signup' | 'invite' | 'magiclink' | 'recovery' | 'email_change' | 'email'; export interface VerifyOtpReq { type?: MobileOtpType | EmailOtpType; email?: string; phone?: string; token: string; messageId?: string; } export interface SignInWithOtpReq { email?: string; phone?: string; } declare type OtpCallback = (params: VerifyOtpReq) => Promise; export interface SignInWithOtpRes { data: SignInRes['data'] & { verifyOtp?: OtpCallback; }; error: AuthError | null; } export interface SignUpRes { data: { verifyOtp?: OtpCallback; }; error: AuthError | null; } export interface ResendReq { email?: string; phone?: string; type?: 'signup' | 'email_change' | 'phone_change' | 'sms'; } export interface ResendRes { data: { messageId?: string; }; error: AuthError | null; } export interface VerifyOAuthReq { code?: string; state?: string; provider?: string; } export interface UpdateUserAttributes { nonce: string; password: string; } export interface ResetPasswordForEmailRes { data: { updateUser?: (attributes: UpdateUserAttributes) => Promise; }; error: AuthError | null; } export interface ReauthenticateRes { data: { updateUser?: (attributes: UpdateUserAttributes) => Promise; }; error: AuthError | null; } export interface SetSessionReq { access_token: string; refresh_token: string; } export interface DeleteMeReq { password: string; } export interface ResetPasswordForOldReq { old_password: string; new_password: string; } export {};