@@ -63,7 +63,6 @@ import { Prisma, RecordType, ledgers, org_agents, organisation, platform_config,
6363import { CommonConstants } from '@credebl/common/common.constant' ;
6464import { CommonService } from '@credebl/common' ;
6565import { GetSchemaAgentRedirection } from 'apps/ledger/src/schema/schema.interface' ;
66- import { ConnectionService } from 'apps/connection/src/connection.service' ;
6766import { ResponseMessages } from '@credebl/common/response-messages' ;
6867import { Socket , io } from 'socket.io-client' ;
6968import { WebSocketGateway } from '@nestjs/websockets' ;
@@ -80,6 +79,11 @@ import { NATSClient } from '@credebl/common/NATSClient';
8079import { SignDataDto } from '../../api-gateway/src/agent-service/dto/agent-service.dto' ;
8180import { IVerificationMethod } from 'apps/organization/interfaces/organization.interface' ;
8281import { getAgentUrl } from '@credebl/common/common.utils' ;
82+ import {
83+ IX509ImportCertificateOptionsDto ,
84+ x509CertificateDecodeDto ,
85+ X509CreateCertificateOptions
86+ } from '@credebl/common/interfaces/x509.interface' ;
8387@Injectable ( )
8488@WebSocketGateway ( )
8589export class AgentServiceService {
@@ -89,8 +93,6 @@ export class AgentServiceService {
8993 private readonly agentServiceRepository : AgentServiceRepository ,
9094 private readonly prisma : PrismaService ,
9195 private readonly commonService : CommonService ,
92- // TODO: Remove duplicate, unused variable
93- private readonly connectionService : ConnectionService ,
9496 @Inject ( 'NATS_CLIENT' ) private readonly agentServiceProxy : ClientProxy ,
9597 // TODO: Remove duplicate, unused variable
9698 @Inject ( CACHE_MANAGER ) private cacheService : Cache ,
@@ -2223,4 +2225,49 @@ export class AgentServiceService {
22232225 throw error ;
22242226 }
22252227 }
2228+
2229+ async createX509Certificate ( options : X509CreateCertificateOptions , url : string , orgId : string ) : Promise < object > {
2230+ try {
2231+ this . logger . log ( 'Start creating X509 certificate' ) ;
2232+ this . logger . debug ( 'Creating X509 certificate with options' , options ) ;
2233+ const getApiKey = await this . getOrgAgentApiKey ( orgId ) ;
2234+ const x509Certificate = await this . commonService
2235+ . httpPost ( url , options , { headers : { authorization : getApiKey } } )
2236+ . then ( async ( response ) => response ) ;
2237+ return x509Certificate ;
2238+ } catch ( error ) {
2239+ this . logger . error ( `Error in creating x509 certificate in agent service : ${ JSON . stringify ( error ) } ` ) ;
2240+ throw error ;
2241+ }
2242+ }
2243+
2244+ async decodeX509Certificate ( options : x509CertificateDecodeDto , url : string , orgId : string ) : Promise < object > {
2245+ try {
2246+ this . logger . log ( 'Start decoding X509 certificate' ) ;
2247+ this . logger . debug ( 'Decoding X509 certificate with options' , options ) ;
2248+ const getApiKey = await this . getOrgAgentApiKey ( orgId ) ;
2249+ const x509Certificate = await this . commonService
2250+ . httpPost ( url , options , { headers : { authorization : getApiKey } } )
2251+ . then ( async ( response ) => response ) ;
2252+ return x509Certificate ;
2253+ } catch ( error ) {
2254+ this . logger . error ( `Error in decoding x509 certificate in agent service : ${ JSON . stringify ( error ) } ` ) ;
2255+ throw error ;
2256+ }
2257+ }
2258+
2259+ async importX509Certificate ( options : IX509ImportCertificateOptionsDto , url : string , orgId : string ) : Promise < object > {
2260+ try {
2261+ this . logger . log ( 'Start importing X509 certificate' ) ;
2262+ this . logger . debug ( `Importing X509 certificate with options` , options . certificate ) ;
2263+ const getApiKey = await this . getOrgAgentApiKey ( orgId ) ;
2264+ const x509Certificate = await this . commonService
2265+ . httpPost ( url , options , { headers : { authorization : getApiKey } } )
2266+ . then ( async ( response ) => response ) ;
2267+ return x509Certificate ;
2268+ } catch ( error ) {
2269+ this . logger . error ( `Error in creating x509 certificate in agent service : ${ JSON . stringify ( error ) } ` ) ;
2270+ throw error ;
2271+ }
2272+ }
22262273}
0 commit comments