import { Injectable } from '@nestjs/common' ; import { ConfigService } from '@fc/config' ; import { IServiceProviderAdapter , ServiceProviderMetadata } from '@fc/oidc' ; import { ServiceProviderAdapterEnvConfig } from './dto' ; @ Injectable ( ) export class ServiceProviderAdapterEnvService implements IServiceProviderAdapter { constructor ( private readonly config ) { } async getList ( ) { const configuredSp = this . config . get < ServiceProviderAdapterEnvConfig > ( 'ServiceProviderAdapterEnv' ) as ServiceProviderMetadata ; return [ JSON . parse ( JSON . stringify ( configuredSp ) ) ] ; } async shouldExcludeIdp ( spId , idpId ) { const { idpFilterExclude , idpFilterList } = await this . getById ( spId ) ; const idpFound = idpFilterList . includes ( idpId ) ; return idpFilterExclude ? idpFound : ! idpFound ; } async getById ( id ) { const list = await this . getList ( ) ; return list . find ( ( { client_id : dbId } ) => dbId === id ) ; } }