import { Authenticator } from './Authenticator' ; import { AuthenticatorResponse , Chain } from './interfaces' ; /**
 * This class provides the business logic layer for the UAL.
 */ export class UAL { param chains param appName param authenticators constructor ( public chains , public appName , private authenticators ) { } /**
     * Returns an object with a list of initialized Authenticators that returned true for shouldRender()
     * as well as an authenticator that supports autoLogin
     */ public getAuthenticators ( ) { const availableAuthenticators = this . authenticators . filter ( ( authenticator ) => { return authenticator . shouldRender ( ) ; } ) as Authenticator [ ] ; availableAuthenticators . forEach ( ( authenticator ) => authenticator . init ( ) ) ; let autoLoginAuthenticator = null ; if ( availableAuthenticators . length === 1 ) { if ( availableAuthenticators [ 0 ] . shouldAutoLogin ( ) ) { autoLoginAuthenticator = availableAuthenticators [ 0 ] ; } } return { availableAuthenticators , autoLoginAuthenticator } ; } }