import { ensureRawRequest , OpenSearchDashboardsRequest , LegacyRequest } from './router' ; public export enum AuthStatus { /**
     * `auth` interceptor successfully authenticated a user
     */ authenticated = 'authenticated' , /**
     * `auth` interceptor failed user authentication
     */ unauthenticated = 'unauthenticated' , /**
     * `auth` interceptor has not been registered
     */ unknown = 'unknown' } param request OpenSearchDashboardsRequest - an incoming request.
 *  public export type GetAuthState = < T = unknown > ( request : OpenSearchDashboardsRequest | LegacyRequest ) => { status : AuthStatus ; state : T ; } ; param request OpenSearchDashboardsRequest - an incoming request.
 *  public export type IsAuthenticated = ( request : OpenSearchDashboardsRequest | LegacyRequest ) => boolean ; internal export class AuthStateStorage { private readonly storage = new WeakMap < LegacyRequest , unknown > ( ) ; constructor ( private readonly canBeAuthenticated ) { } public set = ( request , state ) => { this . storage . set ( ensureRawRequest ( request ) , state ) ; } ; public get = < T = unknown > ( request ) => { const key = ensureRawRequest ( request ) ; const state = this . storage . get ( key ) as T ; const status = this . storage . has ( key ) ? AuthStatus . authenticated : this . canBeAuthenticated ( ) ? AuthStatus . unauthenticated : AuthStatus . unknown ; return { status , state } ; } ; public isAuthenticated : IsAuthenticated = ( request ) => { return this . get ( request ) . status === AuthStatus . authenticated ; } ; }