import { reduce } from "bluebird" ; import IAuthenticationStrategy from "../dependencies/IAuthenticationStrategy" ; import { IIdpUser } from "../entities/User" ; export default class Authenticator { constructor ( private authenticationStrategies , private authToken ) { } async getIdpUser ( ) { if ( ! this . authToken ) { return null ; } return reduce < IAuthenticationStrategy , IIdpUser | null > ( this . authenticationStrategies , ( idpUser , authenticationStrategy ) => idpUser || authenticationStrategy . getIdpUserFromAuthToken ( this . authToken ! ) , null ) ; } }