import { Injectable } from '@nestjs/common' ; import { ConfigService } from '@fc/config' ; import { CryptographyService } from '@fc/cryptography' ; import { CryptographyFcaConfig } from './dto/cryptography-fca-config' ; import { IAgentIdentity } from './interfaces' ; @ Injectable ( ) export class CryptographyFcaService { constructor ( private readonly crypto , private readonly config ) { } param idpId param AgentIdentity returns computeIdentityHash ( idpId , { uid } ) { const { hashSecretKey } = this . config . get < CryptographyFcaConfig > ( 'CryptographyFca' ) ; const serial = idpId + uid + hashSecretKey ; return this . crypto . hash ( serial , 'binary' , 'sha256' , 'base64' ) ; } param providerRef param identityHash returns computeSubV1 ( providerRef , identityHash ) { const { subSecretKey } = this . config . get < CryptographyFcaConfig > ( 'CryptographyFca' ) ; const data = [ providerRef , identityHash , subSecretKey ] ; return `${ this . crypto . hash ( data . join ( '' ) ) }` ; } }