/**
 *  @author Kevin Nielsen <knielsen@alertlogic.com>
 *  @author Robert Parker <robert.parker@alertlogic.com>
 *
 *  @copyright Alert Logic, Inc 2019
 */
import { WebAuth } from 'auth0-js';
import { AIMSSessionDescriptor, AlBehaviorPromise, AlCabinet, AlConduitClient, AlStopwatch } from '@al/core';
import { AlMiniConduit } from '../types/al-mini-conduit';
import Keycloak from 'keycloak-js';
import * as i0 from "@angular/core";
export declare class AlSessionManagerService {
    /**
     *  Indicates whether or not this authentication provider is currently authenticated.
     */
    authenticated: boolean;
    conduit: AlConduitClient;
    echoConduit?: AlMiniConduit;
    /**
     *  Keycloak and Auth0 client instances
     */
    protected auth0Client: WebAuth;
    protected cloak: Keycloak;
    protected cloakPromise: AlBehaviorPromise<any>;
    protected conduitSync?: AlStopwatch;
    /**
     * If session detection is currently executing, this is the observable in progress.
     */
    protected detectionPromise: Promise<boolean>;
    /**
     * Cached userInfo (this holds data from auth0's userInfo endpoint, keyed by access token)
     */
    protected cachedA0UserInfo: {
        [accessKey: string]: any;
    };
    protected storage: AlCabinet;
    protected lastSyncedToken?: string;
    protected lastSyncedExpiry?: number;
    protected allIsLost: boolean;
    constructor();
    onSessionChangeEvent(): void;
    /**
     *  Checks to see if a session already exists.
     *  If a session exists or is discovered, the observable emits `true` and internal state is guaranteed to be authenticated and properly populated.
     *  If no session is found, the observable emits `false` and internal state is guaranteed to be clean and unauthenticated.
     *
     *  @param {string} preferredActingAccountId - If provided and there is no current session, this accountId will be used instead of the default/primary.
     */
    detectSession(preferredActingAccountId?: string): Promise<boolean>;
    /**
     * Imperatively destroys a session -- includes local session state, defender authentication state and cookies,
     * and conduit session cache.  Optionally redirects upon completion (pass false as the `returnURL` parameter to
     * suppress redirection).
     */
    destroySession(returnURL?: string | boolean): Promise<void>;
    /**
     * Returns a promise that either resolves immediately (if no session detection is in process) or resolves after
     * an in-progress detection cycle has completed.  This allows the caller to wait for detection to finish without
     * starting an unwanted detection cycle.
     */
    detectionComplete(): Promise<boolean>;
    /**
     *  Imperatively forces the user to authenticate via Fortra IdP.
     */
    forceFortraLogin(rawReturnURL?: string | boolean, userEmail?: string): Promise<void>;
    /**
     * Determine whether or not the current session should be shown the fortra SSO splash screen after login.
     * This should happen if the primary account has the `fortra_authenticated` property set and the current user has NOT
     * logged in via Fortra before.
     */
    useFortraEntry(): boolean;
    /**
     * Imperatively destroys the Fortra keycloak session.
     */
    forceFortraLogout(rawReturnURL?: string | boolean): Promise<void>;
    /**
     * Currently, this relies on local storage and keycloak to determine whether or not the user has a working fortra identity -- e.g., the proof is
     * in the pudding.  Ideally, this is something we should be able to determine via AIMS to avoid this act of guesswork.
     */
    hasFortraIdentity(): any;
    refreshAccessToken(): Promise<void>;
    innerDetectSession(resolve: any, reject: any): Promise<void>;
    protected innerDestroySession(returnURI?: string | boolean): Promise<void>;
    getGestaltSession(): Promise<AIMSSessionDescriptor | null>;
    /**
     *  Given an AIMSAuthentication object -- which defines the token, user, and account whose session is being
     *  referenced -- this method will collect any missing data elements
     */
    ingestExistingSession: (proposedSession: AIMSSessionDescriptor) => Promise<boolean>;
    /**
     * Checks to see if a session is currently active
     */
    sessionIsValid(proposed: AIMSSessionDescriptor): boolean;
    /**
     * Handles promise-based session-detection success (resolve true)
     */
    onDetectionFail: (resolve: (error: any) => any, warning?: string) => void;
    /**
     * Handles promise-based session-detection failure (resolve false)
     */
    onDetectionSuccess: (resolve: (result: any) => any, sessionOrigin?: string) => Promise<void>;
    /**
     * Normalizes session data.
     */
    normalizeSessionDescriptor(session: AIMSSessionDescriptor): Promise<AIMSSessionDescriptor>;
    getFortraSession(): Promise<boolean>;
    /**
     * Retrieve a keycloak authentication interface.
     */
    getKeyCloak(): Promise<Keycloak>;
    /**
     * Calculates the correct auth0 configuration to use.
     */
    getAuth0Config(merge?: any): any;
    /**
     * Retrieve a reference to the Auth0 web auth instance.  This code is excluded from unit testing.
     */
    getAuth0Authenticator(): WebAuth;
    getAuth0UserInfo: (authenticator: WebAuth, userAccessToken: string, callback: (error: any, userInfo: any) => void) => void;
    /**
     *  Extracts necessary data from the response to auth0's getUserInfo endpoint
     */
    extractUserInfo: (identityData: any) => {
        accountId: string;
        userId: string;
    };
    /**
     * Given a token, determine its expiration timestamp in seconds.
     */
    getTokenExpiration(token: string): any;
    /**
     * Uses a race to make sure that keycloak initialization doesn't time out -- since a misconfigured client can cause the
     * promise to hang indefinitely.
     */
    protected innerGetKeyCloak(cloak: Keycloak, timeout?: number): Promise<void>;
    /**
     * Uses a race to make sure that auth0 session detection doesn't time out -- since a misconfigured client can cause the
     * promise to hang indefinitely.
     */
    protected getAuth0SessionToken(authenticator: WebAuth, config: any, timeout?: number): Promise<string>;
    /**
     * Synchronizes session state to one or more conduit instances and gestalt's proxy endpoint, depending on configuration.
     */
    protected synchronizeCurrentSession: (forceSync?: boolean) => Promise<void>;
    static ɵfac: i0.ɵɵFactoryDef<AlSessionManagerService, never>;
    static ɵprov: i0.ɵɵInjectableDef<AlSessionManagerService>;
}
