import { Api } from './api'; import { BehaviorSubject } from 'rxjs'; import { LoginPrompt, LoginPromptOptions } from './login-prompt'; /** User Account */ export type User = { /** Whether user is active */ active: number; /** User's authentication reference */ auth_ref: number; /** Contact email address */ email: string; /** User ID */ id: number; /** 2-Factor authentication type (optional) */ "2FA"?: string; /** 2-Factor authentication code (optional) */ "2FA_code"?: string; /** Current user ID if available (optional) */ CurrentUserID?: number | null; /** Reference to the user that created this user */ creatorRef: number; /** Date when the user was created (ISO 8601) */ created: string; /** Communication ID (optional) */ communicationid?: number | null; /** Account holder's first name */ first_name: string; /** Last time this user was reported (optional) */ lastreported?: string | null; /** Account holder's last name */ last_name: string; /** Link to user's landing page (optional) */ landingpage?: string; /** Username for logging in */ login: string; /** Mobile info or alternate format (optional) */ mobile?: string; /** Name of user's mobile app (optional) */ mobileappname?: string | null; /** Color theme of user's mobile app (optional) */ mobileappcolor?: string | null; /** Contact mobile phone number (optional) */ mobile_phone?: string; /** Date when the user was last modified (ISO 8601) */ modified: string; /** Reference to the user that last modified this user (optional) */ modifierRef?: number | null; /** Phone number (optional) */ Phone?: string; /** Type of phone (optional) */ phonetype?: string | null; /** Spoke user comes from */ spoke: string; /** Whether account is considered a guest */ guest: boolean; /** Whether account is an admin */ sysadmin: boolean; /** Current session token */ token: string; }; /** * Authentication requests */ export declare class Auth { private readonly api; private onlinePrompt?; /** Current user as an observable */ user$: BehaviorSubject; /** Current user */ get user(): User | null | undefined; /** Set current user info */ set user(user: User | null | undefined); get spoke(): string | null; constructor(api: Api); /** * Get current user associated with API token * * @return {Promise} */ current(token?: string | null): Promise; /** * Automatically handle sessions by checking localStorage & URL parameters for a token & prompting * user with a login screen if required * * @param {string} spoke Desired spoke * @param {LoginPromptOptions} options Aesthetic options * @return {Promise} Login complete */ handleLogin(spoke: string, options?: LoginPromptOptions): Promise; /** * Check whether user has a token * * @return {boolean} True if session token authenticated */ isAuthenticated(): boolean; /** * Check if the current user is a guest * * @return {boolean} True if guest */ isGuest(): boolean; /** * Check if user is a system administrator * * @return {Promise} True if system administrator */ isSysAdmin(): Promise; /** * Check if user is a table administrator * * @return {Promise} True if table administrator */ isTableAdmin(): Promise; /** * Check if user is a user administrator * * @return {Promise} True if user administrator */ isUserAdmin(): Promise; /** * Perform login and save the session token * * @param {string} login Login username or email * @param {string} password Password for account * @param {string} spoke Override login spoke * @param {twoFactor?: string, expire?: string} opts 2FA code & expire date (YYYY-MM-DD) * @returns {Promise} User account */ login(spoke: string, login: string, password: string, opts?: { twoFactor?: string; expire?: null | string; }): Promise; /** * Login as guest user * * @return {Promise} Guest account */ loginGuest(): Promise; /** * Create Login UI * * @param {string} spoke Desired spoke * @param {LoginPromptOptions} options Aesthetic options * @return {LoginPrompt} Login prompt */ loginPrompt(spoke: string, options?: LoginPromptOptions): LoginPrompt; /** * Logout current user * * @return {Promise<{closed: string, new: string}>} */ logout(reload?: boolean): Promise<{ closed: string; new: string; }>; /** * Reset user account password * * @param {string} login User login * @param {string} newPassword New password * @param {string} code Reset code sent with `resetRequest` * @return {Promise} New session */ reset(login: string, newPassword: string, code?: string): Promise; /** * Request reset code for user * * @param {string} login User to reset * @param {"email" | "sms" | "voice"} mode Method of sending reset code * @return {Promise} Unknown */ resetRequest(login: string, mode: 'email' | 'sms' | 'voice'): Promise; } //# sourceMappingURL=auth.d.ts.map