import { UserData } from './UserSettings'; import { Semaphore } from './Utils'; export declare type User = { kind: 'user'; username: string; nickname: string; userId: string; picture: string; email?: string; emailVerified?: boolean; givenName?: string; familyName?: string; userMetadata: { onboarded: boolean; legacy?: boolean; }; currentConnection: ConnectionType; sessionSecret: string; }; export declare type LegacyUser = { kind: 'legacyUser'; username: string; userMetadata: { legacy: boolean; needsPasswordMigration: boolean; }; }; export declare type UserOrLegacyUser = User | LegacyUser; export declare type ConnectionType = 'Username-Password-Authentication' | 'facebook' | 'google-oauth2' | 'github'; export declare type RegistrationData = { username: string; password: string; email?: string; givenName?: string; familyName?: string; }; export declare type LoginType = 'user-pass' | 'facebook' | 'google' | 'github'; export declare const ANONYMOUS_USERNAME = "anonymous"; export declare class UserManagerInstance { _currentUser: User | null; _getSessionLock: Semaphore; _interactiveAuthenticationCallbackAsync?: () => Promise<User>; static getGlobalInstance(): UserManagerInstance; initialize(): void; /** * Logs in a user for a given login type. * * Valid login types are: * - "user-pass": Username and password authentication * * If the login type is "user-pass", we directly make the request to www * to login a user. */ loginAsync(loginType: LoginType, loginArgs?: { username: string; password: string; }): Promise<User>; registerAsync(userData: RegistrationData, user?: UserOrLegacyUser | null): Promise<User>; /** * Ensure user is logged in and has a valid token. * * If there are any issues with the login, this method throws. */ ensureLoggedInAsync(): Promise<User>; setInteractiveAuthenticationCallback(callback: () => Promise<User>): void; _readUserData(): Promise<UserData | null>; /** * Get the current user based on the available token. * If there is no current token, returns null. */ getCurrentUserAsync(): Promise<User | null>; getCurrentUsernameAsync(): Promise<string | null>; getSessionAsync(): Promise<{ sessionSecret: string; } | null>; /** * Create or update a user. */ createOrUpdateUserAsync(userData: object): Promise<User | null>; /** * Logout */ logoutAsync(): Promise<void>; /** * Forgot Password */ forgotPasswordAsync(usernameOrEmail: string): Promise<void>; /** * Get profile given token data. Errors if token is not valid or if no * user profile is returned. * * This method is called by all public authentication methods of `UserManager` * except `logoutAsync`. Therefore, we use this method as a way to: * - update the UserSettings store with the current token and user id * - update UserManager._currentUser * - Fire login analytics events * * Also updates UserManager._currentUser. * * @private */ _getProfileAsync({ currentConnection, sessionSecret, }: { currentConnection?: ConnectionType; sessionSecret: string; }): Promise<User>; } declare const _default: UserManagerInstance; export default _default;