interface IRocketChatAuthOptions { host: string; saveToken: (token: string) => Promise; getToken: () => Promise; deleteToken: () => Promise; autoLogin?: boolean; } declare class ApiError extends Error { response: Response; constructor(response: Response, message?: string | undefined, options?: ErrorOptions | undefined, ...other: any[]); } declare class Api { baseUrl: string; constructor(baseUrl: string); getFetchConfig: (config: RequestInit) => RequestInit; request(method: string | undefined, endpoint: string, data: any, config: RequestInit): Promise<{ data: any; }>; post(endpoint: string, data: any, config?: RequestInit): Promise<{ data: any; }>; get(endpoint: string, config?: RequestInit): Promise<{ data: any; }>; put(endpoint: string, data: any, config?: RequestInit): Promise<{ data: any; }>; delete(endpoint: string, config?: RequestInit): Promise<{ data: any; }>; } declare class RocketChatAuth { host: string; api: Api; currentUser: any; lastFetched: Date; authListeners: ((user: object | null) => void)[]; deleteToken: () => Promise; saveToken: (token: string) => Promise; getToken: () => Promise; constructor({ host, saveToken, getToken, deleteToken, autoLogin, }: IRocketChatAuthOptions); /** * Add a callback that will be called when user login status changes * @param callback */ onAuthChange(callback: (user: object | null) => void): Promise; removeAuthListener(callback: (user: object | null) => void): Promise; notifyAuthListeners(): void; /** * Login with username and password * @param credentials * @returns */ loginWithPassword({ user, password, code, }: { user: string; password: string; code?: string | number; }): Promise; /** * Login with OAuthService's accessToken. The service must be configured in RocketChat. * @param credentials * @returns */ loginWithOAuthServiceToken(credentials: { [key: string]: string; service: string; access_token: string; }): Promise; /** * Login with RocketChat OAuth. The EmbeddedChatApp must be installed and configured in RocketChat. * @returns */ loginWithRocketChatOAuth(): Promise; /** * Login with resume token * @param resume Previous issued authToken * @returns */ loginWithResumeToken(resume: string): Promise; /** * Get current user. * @param refresh * @returns */ getCurrentUser(refresh?: boolean): Promise; /** * Set current user * @param user */ setUser(user: object): Promise; save(): Promise; /** * Load current user from localStorage */ load(): Promise; /** * Logout current user */ logout(): Promise; } declare const rocketChatAuth: ({ host, saveToken, getToken, deleteToken, autoLogin, }: IRocketChatAuthOptions) => RocketChatAuth; export { ApiError, type IRocketChatAuthOptions, RocketChatAuth, rocketChatAuth };