UNPKG

@salad-labs/loopz-typescript

Version:
69 lines 2.73 kB
import { AuthConfig, AuthEvents, AuthInfo } from "./types/auth"; import { ApiKeyAuthorized, Maybe } from "./types/base"; import { AuthInternalEvents } from "./interfaces/auth/authinternalevents"; import { Account } from "."; /** * Represents an authentication client that interacts with a backend server for user authentication. */ export declare class Auth implements AuthInternalEvents { private static _config; private static _instance; private static _client; private static _realtimeAuthorizationToken; private static _authToken; private static _apiKey; private static _account; private static _authInfo; private static _storage; private static _eventsCallbacks; private static _isAuthenticated; private static set authToken(value); private static set account(value); static get realtimeAuthorizationToken(): Maybe<string>; static get apiKey(): string; static get authToken(): Maybe<string>; static get account(): Maybe<Account>; static fetchTokenAttemptsRealtime: number; static prevToken: Maybe<string>; static get MAX_ATTEMPTS_REALTIME_FETCH_AUTH_TOKEN(): number; private constructor(); /** static methods */ private static _generateKeys; private static _getKeys; private static _getOrCreateUserKeys; private static _storeUserOnLocalDB; private static _callBackendAuth; private static _formatAuthParams; private static _clearEventsCallbacks; private static _handleDesktopAuthentication; static _emit(event: AuthEvents, params?: any): void; static config(config: AuthConfig & ApiKeyAuthorized): void; static getInstance(): Auth; /** public instance methods */ /** * Add a new event and the associated callback. * @param event - The event to listen. * @param callback - The callback related to this event. * @param onlyOnce - An optional flag, it allows the adding of only one callback associated to this event. */ on(event: AuthEvents, callback: Function, onlyOnce?: boolean): void; /** * Remove an event and the associated callback or all the callbacks associated to that event. * @param event - The event to unlisten. * @param callback - The callback related to this event. * @returns None */ off(event: AuthEvents, callback?: Function): void; authenticate(): Promise<{ auth: AuthInfo; account: Account; }>; dismiss(): void; logout(): void; isAuthenticated(): boolean; getAuthInfo(): Maybe<AuthInfo>; getCurrentAccount(): Maybe<Account>; static recoverAccountFromLocalDB(): Promise<void>; static fetchAuthToken(): Promise<void>; } //# sourceMappingURL=auth.d.ts.map