/** * @author Kevin Nielsen * @author Robert Parker * * @copyright Alert Logic, Inc 2019 */ import { WebAuth } from 'auth0-js'; import { AIMSSessionDescriptor } from "../../aims-client"; import { AlActingAccountResolvedEvent } from '../events'; import { AlConduitClient } from './al-conduit-client'; export declare class AlSessionDetector { conduit: AlConduitClient; useAuth0?: boolean; protected static auth0Client: WebAuth; /** * If session detection is currently executing, this is the observable in progress. */ protected static detectionPromise: Promise; /** * Cached userInfo (this holds data from auth0's userInfo endpoint, keyed by access token) */ protected static cachedA0UserInfo: { [accessKey: string]: any; }; /** * Indicates whether a listener to acting account changes has been attached to AlSession yet */ protected static listening: boolean; authenticated: boolean; constructor(conduit: AlConduitClient, useAuth0?: boolean); onActingAccountResolved(event: AlActingAccountResolvedEvent): Promise; /** * 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; /** * 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; /** * Imperatively forces the user to authenticate. */ forceAuthentication(): void; innerDetectSession(resolve: any, reject: any): Promise; getGestaltSession(): Promise; /** * 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; /** * Checks to see if a session is currently active */ sessionIsValid(proposed: AIMSSessionDescriptor): boolean; redirect: (targetUri: string, message?: string) => void; /** * 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) => void; /** * Normalizes session data. */ normalizeSessionDescriptor(session: AIMSSessionDescriptor): Promise; /** * 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; protected getAuth0SessionToken(authenticator: WebAuth, config: any, timeout: number): Promise; }