From 25a0feb059446212972f33291ca69ac578aaa260 Mon Sep 17 00:00:00 2001 From: Krishna Waske Date: Thu, 13 Nov 2025 15:06:55 +0530 Subject: [PATCH 1/8] fix: nats call from nats client for verification service Signed-off-by: Krishna Waske --- .../src/interfaces/verification.interface.ts | 5 + .../src/verification.controller.ts | 6 +- apps/verification/src/verification.service.ts | 140 +++++++----------- 3 files changed, 59 insertions(+), 92 deletions(-) diff --git a/apps/verification/src/interfaces/verification.interface.ts b/apps/verification/src/interfaces/verification.interface.ts index 2e259a785..909b72c06 100644 --- a/apps/verification/src/interfaces/verification.interface.ts +++ b/apps/verification/src/interfaces/verification.interface.ts @@ -236,6 +236,11 @@ export interface IProofRequestSearchCriteria { } export interface IInvitation { + outOfBandRecord?: { + id: string; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + } & Record; + proofRecordThId?: string; invitationUrl?: string; deepLinkURL?: string; } diff --git a/apps/verification/src/verification.controller.ts b/apps/verification/src/verification.controller.ts index 5b795d419..907c00a77 100644 --- a/apps/verification/src/verification.controller.ts +++ b/apps/verification/src/verification.controller.ts @@ -45,7 +45,7 @@ export class VerificationController { * @returns Proof presentation details by proofId */ @MessagePattern({ cmd: 'get-proof-presentations-by-proofId' }) - async getProofPresentationById(payload: { proofId: string; orgId: string; user: IUserRequest }): Promise { + async getProofPresentationById(payload: { proofId: string; orgId: string; user: IUserRequest }): Promise { return this.verificationService.getProofPresentationById(payload.proofId, payload.orgId); } @@ -68,7 +68,7 @@ export class VerificationController { async sendProofRequest(payload: { requestProofDto: IProofRequestData; user: IUserRequest; - }): Promise { + }): Promise { return this.verificationService.sendProofRequest(payload.requestProofDto); } @@ -79,7 +79,7 @@ export class VerificationController { * @returns Verified proof presentation details */ @MessagePattern({ cmd: 'verify-presentation' }) - async verifyPresentation(payload: { proofId: string; orgId: string; user: IUserRequest }): Promise { + async verifyPresentation(payload: { proofId: string; orgId: string; user: IUserRequest }): Promise { return this.verificationService.verifyPresentation(payload.proofId, payload.orgId); } diff --git a/apps/verification/src/verification.service.ts b/apps/verification/src/verification.service.ts index 7b62b9637..1f9b91d9b 100644 --- a/apps/verification/src/verification.service.ts +++ b/apps/verification/src/verification.service.ts @@ -9,7 +9,6 @@ import { NotFoundException } from '@nestjs/common'; import { ClientProxy, RpcException } from '@nestjs/microservices'; -import { map } from 'rxjs/operators'; import { IGetAllProofPresentations, IProofRequestSearchCriteria, @@ -53,7 +52,6 @@ import { convertUrlToDeepLinkUrl, getAgentUrl } from '@credebl/common/common.uti import { UserActivityRepository } from 'libs/user-activity/repositories'; import { ISchemaDetail } from '@credebl/common/interfaces/schema.interface'; import { NATSClient } from '@credebl/common/NATSClient'; -import { from } from 'rxjs'; @Injectable() export class VerificationService { @@ -188,7 +186,7 @@ export class VerificationService { }> { try { const pattern = { cmd: 'agent-get-proof-presentations' }; - return await this.natsCall(pattern, payload); + return this.natsClient.send(this.verificationServiceProxy, pattern, payload); } catch (error) { this.logger.error(`[_getProofPresentations] - error in get proof presentations : ${JSON.stringify(error)}`); throw error; @@ -224,7 +222,7 @@ export class VerificationService { * @param orgId * @returns Proof presentation details by proofId */ - async getProofPresentationById(proofId: string, orgId: string): Promise { + async getProofPresentationById(proofId: string, orgId: string): Promise { try { const getAgentDetails = await this.verificationRepository.getAgentEndPoint(orgId); const url = await getAgentUrl( @@ -236,18 +234,18 @@ export class VerificationService { const payload = { orgId, url }; const getProofPresentationById = await this._getProofPresentationById(payload); - return getProofPresentationById?.response; + return getProofPresentationById; } catch (error) { this.logger.error( `[getProofPresentationById] - error in get proof presentation by proofId : ${JSON.stringify(error)}` ); - const errorMessage = error?.response?.error?.reason || error?.message; + const errorMessage = error?.error?.reason || error?.message; if (errorMessage?.includes('not found')) { throw new NotFoundException(errorMessage); } - throw new RpcException(error.response ? error.response : error); + throw new RpcException(error); } } @@ -256,15 +254,13 @@ export class VerificationService { * @param payload * @returns Get proof presentation details */ - async _getProofPresentationById(payload: IGetProofPresentationById): Promise<{ - response: string; - }> { + async _getProofPresentationById(payload: IGetProofPresentationById): Promise { try { const pattern = { cmd: 'agent-get-proof-presentation-by-id' }; - return await this.natsCall(pattern, payload); + return this.natsClient.send(this.verificationServiceProxy, pattern, payload); } catch (error) { this.logger.error( `[_getProofPresentationById] - error in get proof presentation by id : ${JSON.stringify(error)}` @@ -279,7 +275,7 @@ export class VerificationService { * @returns Requested proof presentation details */ - async sendProofRequest(requestProof: IProofRequestData): Promise { + async sendProofRequest(requestProof: IProofRequestData): Promise { try { const comment = requestProof.comment ? requestProof.comment : ''; const getAgentDetails = await this.verificationRepository.getAgentEndPoint(requestProof.orgId); @@ -337,11 +333,11 @@ export class VerificationService { ? requestProof.connectionId : [requestProof.connectionId]; - const responses: string[] = []; + const responses: object[] = []; for (const connectionId of connectionIds) { const payload = await createPayload(connectionId); const getProofPresentationById = await this._sendProofRequest(payload); - responses.push(getProofPresentationById?.response); + responses.push(getProofPresentationById); } return responses; } else { @@ -351,7 +347,7 @@ export class VerificationService { const payload = await createPayload(connectionId); const getProofPresentationById = await this._sendProofRequest(payload); - return getProofPresentationById?.response; + return getProofPresentationById; } } catch (error) { // Handle cases where identical attributes are used in both predicates and non-predicates. @@ -380,15 +376,13 @@ export class VerificationService { * @param orgId * @returns Get requested proof presentation details */ - async _sendProofRequest(payload: IProofRequestPayload): Promise<{ - response: string; - }> { + async _sendProofRequest(payload: IProofRequestPayload): Promise { try { const pattern = { cmd: 'agent-send-proof-request' }; - return await this.natsCall(pattern, payload); + return this.natsClient.send(this.verificationServiceProxy, pattern, payload); } catch (error) { this.logger.error(`[_sendProofRequest] - error in verify presentation : ${JSON.stringify(error)}`); throw error; @@ -401,28 +395,28 @@ export class VerificationService { * @param orgId * @returns Verified proof presentation details */ - async verifyPresentation(proofId: string, orgId: string): Promise { + async verifyPresentation(proofId: string, orgId: string): Promise { try { const getAgentData = await this.verificationRepository.getAgentEndPoint(orgId); const url = await getAgentUrl(getAgentData?.agentEndPoint, CommonConstants.ACCEPT_PRESENTATION, proofId); const payload = { orgId, url }; const getProofPresentationById = await this._verifyPresentation(payload); - return getProofPresentationById?.response; + return getProofPresentationById; } catch (error) { this.logger.error( `[getProofPresentationById] - error in get proof presentation by proofId : ${JSON.stringify(error)}` ); - const errorStack = error?.response?.error?.reason; + const errorStack = error?.error?.reason; if (errorStack) { throw new RpcException({ message: ResponseMessages.verification.error.proofNotFound, - statusCode: error?.response?.status, + statusCode: error?.status, error: errorStack }); } else { - throw new RpcException(error.response ? error.response : error); + throw new RpcException(error || 'Something went wrong'); } } } @@ -432,15 +426,13 @@ export class VerificationService { * @param payload * @returns Get verified proof presentation details */ - async _verifyPresentation(payload: IVerifyPresentation): Promise<{ - response: string; - }> { + async _verifyPresentation(payload: IVerifyPresentation): Promise { try { const pattern = { cmd: 'agent-verify-presentation' }; - return await this.natsCall(pattern, payload); + return this.natsClient.send(this.verificationServiceProxy, pattern, payload); } catch (error) { this.logger.error(`[_verifyPresentation] - error in verify presentation : ${JSON.stringify(error)}`); throw error; @@ -570,17 +562,17 @@ export class VerificationService { //nats call in agent-service to create an invitation url const pattern = { cmd: 'store-object-return-url' }; const payload = { persistent, storeObj }; - const message = await this.natsCall(pattern, payload); - return message.response; + const message = await this.natsClient.send(this.verificationServiceProxy, pattern, payload); + return message; } - private async generateOOBProofReq(payload: IProofRequestPayload): Promise { + private async generateOOBProofReq(payload: IProofRequestPayload): Promise { const getProofPresentation = await this._sendOutOfBandProofRequest(payload); if (!getProofPresentation) { throw new Error(ResponseMessages.verification.error.proofPresentationNotFound); } - return getProofPresentation.response; + return getProofPresentation; } // Currently batch size is not used, as length of emails sent is restricted to '10' @@ -625,13 +617,13 @@ export class VerificationService { getAgentDetails: org_agents, organizationDetails: organisation ): Promise { - const getProofPresentation = await this._sendOutOfBandProofRequest(payload); + const getProofPresentation: IInvitation = await this._sendOutOfBandProofRequest(payload); if (!getProofPresentation) { throw new Error(ResponseMessages.verification.error.proofPresentationNotFound); } - const invitationUrl = getProofPresentation?.response?.invitationUrl; + const invitationUrl = getProofPresentation?.invitationUrl; // Currently have shortenedUrl to store only for 30 days const persist: boolean = false; const shortenedUrl = await this.storeVerificationObjectAndReturnUrl(invitationUrl, persist); @@ -669,8 +661,8 @@ export class VerificationService { return { isEmailSent, - outOfBandRecordId: getProofPresentation?.response?.outOfBandRecord?.id, - proofRecordThId: getProofPresentation?.response?.proofRecordThId + outOfBandRecordId: getProofPresentation?.outOfBandRecord?.id, + proofRecordThId: getProofPresentation?.proofRecordThId }; } @@ -679,15 +671,13 @@ export class VerificationService { * @param payload * @returns Get requested proof presentation details */ - async _sendOutOfBandProofRequest(payload: IProofRequestPayload): Promise<{ - response; - }> { + async _sendOutOfBandProofRequest(payload: IProofRequestPayload): Promise { try { const pattern = { cmd: 'agent-send-out-of-band-proof-request' }; - return await this.natsCall(pattern, payload); + return this.natsClient.send(this.verificationServiceProxy, pattern, payload); } catch (error) { this.logger.error(`[_sendOutOfBandProofRequest] - error in Out Of Band Presentation : ${JSON.stringify(error)}`); throw error; @@ -770,7 +760,7 @@ export class VerificationService { const getProofPresentationById = await this._getVerifiedProofDetails(payload); - if (!getProofPresentationById?.response?.presentation) { + if (!getProofPresentationById?.presentation) { throw new NotFoundException(ResponseMessages.verification.error.proofPresentationNotFound, { cause: new Error(), description: ResponseMessages.errorMessages.notFound @@ -780,11 +770,10 @@ export class VerificationService { const extractedDataArray: IProofPresentationDetails[] = []; // For Presentation Exchange format - if (getProofPresentationById?.response?.request?.presentationExchange) { - const presentationDefinition = - getProofPresentationById?.response?.request?.presentationExchange?.presentation_definition; + if (getProofPresentationById?.request?.presentationExchange) { + const presentationDefinition = getProofPresentationById?.request?.presentationExchange?.presentation_definition; const verifiableCredentials = - getProofPresentationById?.response?.presentation?.presentationExchange?.verifiableCredential; + getProofPresentationById?.presentation?.presentationExchange?.verifiableCredential; presentationDefinition?.input_descriptors.forEach((descriptor, index) => { const schemaId = descriptor?.schema[0]?.uri; @@ -794,7 +783,7 @@ export class VerificationService { if (getProofPresentationById?.response) { certificate = - getProofPresentationById?.response?.presentation?.presentationExchange?.verifiableCredential[0].prettyVc + getProofPresentationById?.presentation?.presentationExchange?.verifiableCredential[0].prettyVc ?.certificate; } @@ -821,10 +810,10 @@ export class VerificationService { }); } // For Indy format - if (getProofPresentationById?.response?.request?.indy) { - const requestedAttributes = getProofPresentationById?.response?.request?.indy?.requested_attributes; - const requestedPredicates = getProofPresentationById?.response?.request?.indy?.requested_predicates; - const revealedAttrs = getProofPresentationById?.response?.presentation?.indy?.requested_proof?.revealed_attrs; + if (getProofPresentationById?.request?.indy) { + const requestedAttributes = getProofPresentationById?.request?.indy?.requested_attributes; + const requestedPredicates = getProofPresentationById?.request?.indy?.requested_predicates; + const revealedAttrs = getProofPresentationById?.presentation?.indy?.requested_proof?.revealed_attrs; if (0 !== Object.keys(requestedAttributes).length && 0 !== Object.keys(requestedPredicates).length) { for (const key in requestedAttributes) { @@ -835,9 +824,9 @@ export class VerificationService { if (requestedAttributeKey?.restrictions) { credDefId = requestedAttributeKey?.restrictions[0]?.cred_def_id; schemaId = requestedAttributeKey?.restrictions[0]?.schema_id; - } else if (getProofPresentationById?.response?.presentation?.indy?.identifiers) { - credDefId = getProofPresentationById?.response?.presentation?.indy?.identifiers[0].cred_def_id; - schemaId = getProofPresentationById?.response?.presentation?.indy?.identifiers[0].schema_id; + } else if (getProofPresentationById?.presentation?.indy?.identifiers) { + credDefId = getProofPresentationById?.presentation?.indy?.identifiers[0].cred_def_id; + schemaId = getProofPresentationById?.presentation?.indy?.identifiers[0].schema_id; } if (revealedAttrs.hasOwnProperty(key)) { @@ -914,16 +903,16 @@ export class VerificationService { return extractedDataArray; } catch (error) { this.logger.error(`[getVerifiedProofDetails] - error in get verified proof details : ${JSON.stringify(error)}`); - const errorStack = error?.response?.error?.reason; + const errorStack = error?.error?.reason; if (errorStack) { throw new RpcException({ message: ResponseMessages.verification.error.verifiedProofNotFound, - statusCode: error?.response?.status, + statusCode: error?.status, error: errorStack }); } else { - throw new RpcException(error.response ? error.response : error); + throw new RpcException(error); } } } @@ -935,24 +924,23 @@ export class VerificationService { if (attribute?.restrictions) { credDefId = attribute?.restrictions[0]?.cred_def_id; schemaId = attribute?.restrictions[0]?.schema_id; - } else if (getProofPresentationById?.response?.presentation?.indy?.identifiers) { - credDefId = getProofPresentationById?.response?.presentation?.indy?.identifiers[0].cred_def_id; - schemaId = getProofPresentationById?.response?.presentation?.indy?.identifiers[0].schema_id; + } else if (getProofPresentationById?.presentation?.indy?.identifiers) { + credDefId = getProofPresentationById?.presentation?.indy?.identifiers[0].cred_def_id; + schemaId = getProofPresentationById?.presentation?.indy?.identifiers[0].schema_id; } return [credDefId, schemaId]; } - async _getVerifiedProofDetails(payload: IVerifiedProofData): Promise<{ - response; - }> { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + async _getVerifiedProofDetails(payload: IVerifiedProofData): Promise { try { //nats call in agent for fetch verified proof details const pattern = { cmd: 'get-agent-verified-proof-details' }; - return await this.natsCall(pattern, payload); + return this.natsClient.send(this.verificationServiceProxy, pattern, payload); } catch (error) { this.logger.error(`[_getVerifiedProofDetails] - error in verified proof details : ${JSON.stringify(error)}`); throw error; @@ -992,32 +980,6 @@ export class VerificationService { } } - async natsCall( - pattern: object, - payload: object - ): Promise<{ - response: string; - }> { - return from(this.natsClient.send(this.verificationServiceProxy, pattern, payload)) - .pipe( - map((response) => ({ - response - })) - ) - .toPromise() - .catch((error) => { - this.logger.error(`catch: ${JSON.stringify(error)}`); - throw new HttpException( - { - status: error.statusCode, - error: error.error, - message: error.message - }, - error.error - ); - }); - } - async delay(ms: number): Promise { return new Promise((resolve) => setTimeout(resolve, ms)); } From 2b215c3af542309e85d993e8a49d9e766aa62590 Mon Sep 17 00:00:00 2001 From: Krishna Waske Date: Thu, 13 Nov 2025 15:37:22 +0530 Subject: [PATCH 2/8] fix: ledger nats fix in agent-service Signed-off-by: Krishna Waske --- .../src/agent-service.service.ts | 72 +++++-------------- .../src/interface/agent-service.interface.ts | 7 +- 2 files changed, 20 insertions(+), 59 deletions(-) diff --git a/apps/agent-service/src/agent-service.service.ts b/apps/agent-service/src/agent-service.service.ts index 5d3123d3a..8d6360f97 100644 --- a/apps/agent-service/src/agent-service.service.ts +++ b/apps/agent-service/src/agent-service.service.ts @@ -47,7 +47,6 @@ import { IDidCreate, IWallet, ITenantRecord, - LedgerListResponse, ICreateConnectionInvitation, IStoreAgent, AgentHealthData, @@ -55,7 +54,9 @@ import { IAgentConfigure, OrgDid, IBasicMessage, - WalletDetails + WalletDetails, + ILedger, + IStoreOrgAgent } from './interface/agent-service.interface'; import { AgentSpinUpStatus, AgentType, DidMethod, Ledgers, OrgAgentType, PromiseResult } from '@credebl/enum/enum'; import { AgentServiceRepository } from './repositories/agent-service.repository'; @@ -497,8 +498,8 @@ export class AgentServiceService { if (agentSpinupDto.method !== DidMethod.KEY && agentSpinupDto.method !== DidMethod.WEB) { const { network } = agentSpinupDto; const ledger = await ledgerName(network); - const ledgerList = (await this._getALlLedgerDetails()) as unknown as LedgerListResponse; - const isLedgerExist = ledgerList.response.find((existingLedgers) => existingLedgers.name === ledger); + const ledgerList = await this._getALlLedgerDetails(); + const isLedgerExist = ledgerList.find((existingLedgers) => existingLedgers.name === ledger); if (!isLedgerExist) { throw new BadRequestException(ResponseMessages.agent.error.invalidLedger, { cause: new Error(), @@ -511,15 +512,14 @@ export class AgentServiceService { /** * Invoke wallet create and provision with agent */ - const walletProvision = await this._walletProvision(walletProvisionPayload); - if (!walletProvision?.response) { + const agentDetails = await this._walletProvision(walletProvisionPayload); + if (!agentDetails) { this.logger.error(`Agent not able to spin-up`); throw new BadRequestException(ResponseMessages.agent.error.notAbleToSpinup, { cause: new Error(), description: ResponseMessages.errorMessages.badRequest }); } - const agentDetails = walletProvision.response; const agentEndPoint = `${process.env.API_GATEWAY_PROTOCOL}://${agentDetails.agentEndPoint}`; /** * Socket connection @@ -693,48 +693,38 @@ export class AgentServiceService { } } - async _createConnectionInvitation( - orgId: string, - user: IUserRequestInterface, - label: string - ): Promise<{ - response; - }> { + async _createConnectionInvitation(orgId: string, user: IUserRequestInterface, label: string): Promise { try { const pattern = { cmd: 'create-connection-invitation' }; const payload = { createOutOfBandConnectionInvitation: { orgId, user, label } }; - return await this.natsCall(pattern, payload); + return this.natsClient.send(this.agentServiceProxy, pattern, payload); } catch (error) { - this.logger.error(`error in create-connection in wallet provision : ${JSON.stringify(error)}`); + this.logger.error(`[natsCall] - error in create-connection in wallet provision : ${JSON.stringify(error)}`); } } - async _getALlLedgerDetails(): Promise<{ - response; - }> { + async _getALlLedgerDetails(): Promise { try { const pattern = { cmd: 'get-all-ledgers' }; const payload = {}; - return await this.natsCall(pattern, payload); + return this.natsClient.send(this.agentServiceProxy, pattern, payload); } catch (error) { - this.logger.error(`error in while fetching all the ledger details : ${JSON.stringify(error)}`); + this.logger.error(`[natsCall] - error in while fetching all the ledger details : ${JSON.stringify(error)}`); } } - async _walletProvision(payload: IWalletProvision): Promise<{ - response; - }> { + async _walletProvision(payload: IWalletProvision): Promise> { try { const pattern = { cmd: 'wallet-provisioning' }; - return await this.natsCall(pattern, payload); + return this.natsClient.send(this.agentServiceProxy, pattern, payload); } catch (error) { - this.logger.error(`error in wallet provision : ${JSON.stringify(error)}`); + this.logger.error(`[natsCall] - error in wallet provision : ${JSON.stringify(error)}`); throw error; } } @@ -795,8 +785,8 @@ export class AgentServiceService { ledger = Ledgers.Not_Applicable; } - const ledgerList = (await this._getALlLedgerDetails()) as unknown as LedgerListResponse; - const isLedgerExist = ledgerList.response.find((existingLedgers) => existingLedgers.name === ledger); + const ledgerList = await this._getALlLedgerDetails(); + const isLedgerExist = ledgerList.find((existingLedgers) => existingLedgers.name === ledger); if (!isLedgerExist) { throw new BadRequestException(ResponseMessages.agent.error.invalidLedger, { cause: new Error(), @@ -2191,32 +2181,6 @@ export class AgentServiceService { } } - async natsCall( - pattern: object, - payload: object - ): Promise<{ - response: string; - }> { - try { - return from(this.natsClient.send(this.agentServiceProxy, pattern, payload)) - .pipe(map((response) => ({ response }))) - .toPromise() - .catch((error) => { - this.logger.error(`catch: ${JSON.stringify(error)}`); - throw new HttpException( - { - status: error.statusCode, - error: error.message - }, - error.error - ); - }); - } catch (error) { - this.logger.error(`[natsCall] - error in nats call : ${JSON.stringify(error)}`); - throw error; - } - } - private async tokenEncryption(token: string): Promise { try { const encryptedToken = CryptoJS.AES.encrypt(JSON.stringify(token), process.env.CRYPTO_PRIVATE_KEY).toString(); diff --git a/apps/agent-service/src/interface/agent-service.interface.ts b/apps/agent-service/src/interface/agent-service.interface.ts index 28b711b93..8c4a60197 100644 --- a/apps/agent-service/src/interface/agent-service.interface.ts +++ b/apps/agent-service/src/interface/agent-service.interface.ts @@ -213,6 +213,7 @@ export interface IStoreOrgAgent { id?: string; clientSocketId?: string; agentEndPoint?: string; + agentToken?: string; apiKey?: string; seed?: string; did?: string; @@ -556,7 +557,7 @@ export interface IQuestionPayload { export interface IBasicMessage { content: string; } -interface Ledger { +export interface ILedger { id: string; createDateTime: string; lastChangedDateTime: string; @@ -570,10 +571,6 @@ interface Ledger { networkUrl: string | null; } -export interface LedgerListResponse { - response: Ledger[]; -} - export interface ICreateConnectionInvitation { label?: string; alias?: string; From 47b14a212ae4d2a9ec16e77adaed61be29776979 Mon Sep 17 00:00:00 2001 From: Krishna Waske Date: Thu, 13 Nov 2025 15:41:18 +0530 Subject: [PATCH 3/8] fix: remove unused variable Signed-off-by: Krishna Waske --- apps/cloud-wallet/src/cloud-wallet.service.ts | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/apps/cloud-wallet/src/cloud-wallet.service.ts b/apps/cloud-wallet/src/cloud-wallet.service.ts index 0a396251a..988ada3db 100644 --- a/apps/cloud-wallet/src/cloud-wallet.service.ts +++ b/apps/cloud-wallet/src/cloud-wallet.service.ts @@ -3,14 +3,11 @@ import { CommonService } from '@credebl/common'; import { BadRequestException, ConflictException, - Inject, Injectable, InternalServerErrorException, Logger, NotFoundException } from '@nestjs/common'; -import { Cache } from 'cache-manager'; -import { CACHE_MANAGER } from '@nestjs/cache-manager'; import { IAcceptOffer, ICreateCloudWalletDid, @@ -40,17 +37,13 @@ import { CloudWalletRepository } from './cloud-wallet.repository'; import { ResponseMessages } from '@credebl/common/response-messages'; import { CloudWalletType } from '@credebl/enum/enum'; import { CommonConstants } from '@credebl/common/common.constant'; -import { ClientProxy } from '@nestjs/microservices'; @Injectable() export class CloudWalletService { constructor( private readonly commonService: CommonService, - @Inject('NATS_CLIENT') private readonly cloudWalletServiceProxy: ClientProxy, private readonly cloudWalletRepository: CloudWalletRepository, - private readonly logger: Logger, - // TODO: Remove duplicate, unused variable - @Inject(CACHE_MANAGER) private cacheService: Cache + private readonly logger: Logger ) {} /** From 4446826533d304d3720904ce0059c050e757688b Mon Sep 17 00:00:00 2001 From: Krishna Waske Date: Thu, 13 Nov 2025 17:26:12 +0530 Subject: [PATCH 4/8] fix: nats calls in connection service Signed-off-by: Krishna Waske --- .../src/connection/connection.service.ts | 2 +- apps/connection/src/connection.controller.ts | 18 +- apps/connection/src/connection.service.ts | 176 ++++++------------ 3 files changed, 63 insertions(+), 133 deletions(-) diff --git a/apps/api-gateway/src/connection/connection.service.ts b/apps/api-gateway/src/connection/connection.service.ts index 88efdbad7..d08d181ca 100644 --- a/apps/api-gateway/src/connection/connection.service.ts +++ b/apps/api-gateway/src/connection/connection.service.ts @@ -32,7 +32,7 @@ export class ConnectionService extends BaseService { try { return this.natsClient.sendNatsMessage(this.connectionServiceProxy, 'send-question', questionDto); } catch (error) { - throw new RpcException(error.response); + throw new RpcException(error?.response ?? error); } } diff --git a/apps/connection/src/connection.controller.ts b/apps/connection/src/connection.controller.ts index 0cc2e63d7..cb5c92fbd 100644 --- a/apps/connection/src/connection.controller.ts +++ b/apps/connection/src/connection.controller.ts @@ -46,15 +46,15 @@ export class ConnectionController { } @MessagePattern({ cmd: 'get-all-agent-connection-list' }) - async getConnectionListFromAgent(payload: GetAllConnections): Promise { - const {orgId, connectionSearchCriteria } = payload; + async getConnectionListFromAgent(payload: GetAllConnections): Promise { + const { orgId, connectionSearchCriteria } = payload; return this.connectionService.getAllConnectionListFromAgent(orgId, connectionSearchCriteria); } /** - * + * * @param connectionId - * @param orgId + * @param orgId * @returns connection details by connection Id */ @MessagePattern({ cmd: 'get-connection-details-by-connectionId' }) @@ -64,7 +64,7 @@ export class ConnectionController { } @MessagePattern({ cmd: 'get-connection-records' }) - async getConnectionRecordsByOrgId(payload: { orgId: string, userId: string }): Promise { + async getConnectionRecordsByOrgId(payload: { orgId: string; userId: string }): Promise { const { orgId } = payload; return this.connectionService.getConnectionRecords(orgId); } @@ -80,7 +80,7 @@ export class ConnectionController { const { user, receiveInvitation, orgId } = payload; return this.connectionService.receiveInvitation(user, receiveInvitation, orgId); } - + @MessagePattern({ cmd: 'send-question' }) async sendQuestion(payload: IQuestionPayload): Promise { return this.connectionService.sendQuestion(payload); @@ -97,13 +97,13 @@ export class ConnectionController { } @MessagePattern({ cmd: 'delete-connection-records' }) - async deleteConnectionRecords(payload: {orgId: string, userDetails: user}): Promise { + async deleteConnectionRecords(payload: { orgId: string; userDetails: user }): Promise { const { orgId, userDetails } = payload; return this.connectionService.deleteConnectionRecords(orgId, userDetails); } @MessagePattern({ cmd: 'send-basic-message-on-connection' }) - async sendBasicMessage(payload: {content: string, orgId: string, connectionId: string}): Promise { - return this.connectionService.sendBasicMesage(payload); + async sendBasicMessage(payload: { content: string; orgId: string; connectionId: string }): Promise { + return this.connectionService.sendBasicMessage(payload); } } diff --git a/apps/connection/src/connection.service.ts b/apps/connection/src/connection.service.ts index 8442c7421..f98fe99a0 100644 --- a/apps/connection/src/connection.service.ts +++ b/apps/connection/src/connection.service.ts @@ -3,7 +3,6 @@ import { CommonService } from '@credebl/common'; import { CommonConstants } from '@credebl/common/common.constant'; import { HttpException, HttpStatus, Inject, Injectable, Logger, NotFoundException } from '@nestjs/common'; import { ClientProxy, RpcException } from '@nestjs/microservices'; -import { from, map } from 'rxjs'; import { ConnectionResponseDetail, AgentConnectionSearchCriteria, @@ -19,8 +18,6 @@ import { ConnectionRepository } from './connection.repository'; import { ResponseMessages } from '@credebl/common/response-messages'; import { IUserRequest } from '@credebl/user-request/user-request.interface'; import { ConnectionProcessState } from '@credebl/enum/enum'; -import { Cache } from 'cache-manager'; -import { CACHE_MANAGER } from '@nestjs/cache-manager'; import { IConnectionList, ICreateConnectionUrl, @@ -41,8 +38,6 @@ export class ConnectionService { private readonly connectionRepository: ConnectionRepository, private readonly userActivityRepository: UserActivityRepository, private readonly logger: Logger, - // TODO: Remove unused variable - @Inject(CACHE_MANAGER) private readonly cacheService: Cache, private readonly natsClient: NATSClient ) {} @@ -57,7 +52,7 @@ export class ConnectionService { return saveConnectionDetails; } catch (error) { this.logger.error(`[getConnectionWebhook] - error in fetch connection webhook: ${error}`); - throw new RpcException(error.response ? error.response : error); + throw new RpcException(error?.response ?? error); } } @@ -66,19 +61,13 @@ export class ConnectionService { * @param orgId * @returns connection invitation URL */ - async _createConnectionInvitation( - connectionPayload: object, - url: string, - orgId: string - ): Promise<{ - response; - }> { + async _createConnectionInvitation(connectionPayload: object, url: string, orgId: string): Promise { //nats call in agent-service to create an invitation url const pattern = { cmd: 'agent-create-connection-legacy-invitation' }; const payload = { connectionPayload, url, orgId }; try { - return await this.natsCall(pattern, payload); + return this.natsClient.send(this.connectionServiceProxy, pattern, payload); } catch (error) { this.logger.error(`catch: ${JSON.stringify(error)}`); throw new HttpException( @@ -107,7 +96,7 @@ export class ConnectionService { this.logger.error( `[getConnectionRecords ] [NATS call]- error in get connection records count : ${JSON.stringify(error)}` ); - throw new RpcException(error.response ? error.response : error); + throw new RpcException(error?.response ?? error); } } @@ -122,7 +111,7 @@ export class ConnectionService { return urlDetails.referenceId; } catch (error) { this.logger.error(`Error in get url in connection service: ${JSON.stringify(error)}`); - throw new RpcException(error.response ? error.response : error); + throw new RpcException(error?.response ?? error); } } @@ -178,14 +167,14 @@ export class ConnectionService { } catch (error) { this.logger.error(`[getConnections] [NATS call]- error in fetch connections details : ${JSON.stringify(error)}`); - throw new RpcException(error.response ? error.response : error); + throw new RpcException(error?.response ?? error); } } async getAllConnectionListFromAgent( orgId: string, connectionSearchCriteria: AgentConnectionSearchCriteria - ): Promise { + ): Promise { try { const { alias, myDid, outOfBandId, state, theirDid, theirLabel } = connectionSearchCriteria; const agentDetails = await this.connectionRepository.getAgentEndPoint(orgId); @@ -223,26 +212,21 @@ export class ConnectionService { } const connectionResponse = await this._getAllConnections(url, orgId); - return connectionResponse.response; + return connectionResponse; } catch (error) { this.logger.error( `[getConnectionsFromAgent] [NATS call]- error in fetch connections details : ${JSON.stringify(error)}` ); - throw new RpcException(error.response ? error.response : error); + throw new RpcException(error); } } - async _getAllConnections( - url: string, - orgId: string - ): Promise<{ - response: string; - }> { + async _getAllConnections(url: string, orgId: string): Promise { try { const pattern = { cmd: 'agent-get-all-connections' }; const payload = { url, orgId }; - return await this.natsCall(pattern, payload); + return this.natsClient.send(this.connectionServiceProxy, pattern, payload); } catch (error) { this.logger.error( `[_getAllConnections] [NATS call]- error in fetch connections details : ${JSON.stringify(error)}` @@ -260,18 +244,18 @@ export class ConnectionService { } const url = `${agentEndPoint}${CommonConstants.URL_CONN_GET_CONNECTION_BY_ID}`.replace('#', connectionId); const createConnectionInvitation = await this._getConnectionsByConnectionId(url, orgId); - return createConnectionInvitation?.response; + return createConnectionInvitation; } catch (error) { this.logger.error(`[getConnectionsById] - error in get connections : ${JSON.stringify(error)}`); - if (error?.response?.error?.reason) { + if (error?.error?.reason) { throw new RpcException({ message: ResponseMessages.connection.error.connectionNotFound, - statusCode: error?.response?.status, - error: error?.response?.error?.reason + statusCode: error?.status, + error: error?.error?.reason }); } else { - throw new RpcException(error.response ? error.response : error); + throw new RpcException(error); } } } @@ -293,41 +277,23 @@ export class ConnectionService { } } - async _getConnectionsByConnectionId( - url: string, - orgId: string - ): Promise<{ - response; - }> { + async _getConnectionsByConnectionId(url: string, orgId: string): Promise { //nats call in agent service for fetch connection details const pattern = { cmd: 'agent-get-connection-details-by-connectionId' }; const payload = { url, orgId }; - return this.natsCall(pattern, payload); + return this.natsClient.send(this.connectionServiceProxy, pattern, payload); } async _getQuestionAnswersRecord(url: string, orgId: string): Promise { - const pattern = { cmd: 'agent-get-question-answer-record' }; - const payload = { url, orgId }; - return this.natsCall(pattern, payload); - } - - async _getOrgAgentApiKey(orgId: string): Promise<{ - response: string; - }> { - const pattern = { cmd: 'get-org-agent-api-key' }; - const payload = { orgId }; - try { - return await this.natsCall(pattern, payload); + const pattern = { cmd: 'agent-get-question-answer-record' }; + const payload = { url, orgId }; + return this.natsClient.send(this.connectionServiceProxy, pattern, payload); } catch (error) { - this.logger.error(`catch: ${JSON.stringify(error)}`); - throw new HttpException( - { - status: error.status, - error: error.message - }, - error.status + this.logger.error( + `[_getQuestionAnswersRecord ] [NATS call]- error in get question and answer records : ${JSON.stringify(error)}` ); + throw error; } } @@ -344,7 +310,7 @@ export class ConnectionService { } const url = `${agentEndPoint}${CommonConstants.URL_RECEIVE_INVITATION_URL}`; const createConnectionInvitation = await this._receiveInvitationUrl(url, orgId, receiveInvitationUrl); - return createConnectionInvitation.response; + return createConnectionInvitation; } catch (error) { this.logger.error(`[receiveInvitationUrl] - error in receive invitation url : ${JSON.stringify(error, null, 2)}`); @@ -355,14 +321,14 @@ export class ConnectionService { message: customErrorMessage, error: ResponseMessages.errorMessages.conflict }); - } else if (error?.response?.error?.reason) { + } else if (error?.error?.reason) { throw new RpcException({ message: ResponseMessages.connection.error.connectionNotFound, - statusCode: error?.response?.status, - error: error?.response?.error?.reason + statusCode: error?.status, + error: error?.error?.reason }); } else { - throw new RpcException(error.response ? error.response : error); + throw new RpcException(error?.response ?? error); } } } @@ -371,14 +337,12 @@ export class ConnectionService { url: string, orgId: string, receiveInvitationUrl: IReceiveInvitationUrl - ): Promise<{ - response; - }> { + ): Promise { const pattern = { cmd: 'agent-receive-invitation-url' }; const payload = { url, orgId, receiveInvitationUrl }; try { - return await this.natsCall(pattern, payload); + return this.natsClient.send(this.connectionServiceProxy, pattern, payload); } catch (error) { this.logger.error(`catch: ${JSON.stringify(error)}`); throw new HttpException( @@ -404,18 +368,18 @@ export class ConnectionService { } const url = `${agentEndPoint}${CommonConstants.URL_RECEIVE_INVITATION}`; const createConnectionInvitation = await this._receiveInvitation(url, orgId, receiveInvitation); - return createConnectionInvitation?.response; + return createConnectionInvitation; } catch (error) { this.logger.error(`[receiveInvitation] - error in receive invitation : ${JSON.stringify(error)}`); - if (error?.response?.error?.reason) { + if (error?.error?.reason) { throw new RpcException({ message: ResponseMessages.connection.error.connectionNotFound, - statusCode: error?.response?.status, - error: error?.response?.error?.reason + statusCode: error?.status, + error: error?.error?.reason }); } else { - throw new RpcException(error.response ? error.response : error); + throw new RpcException(error?.response ?? error); } } } @@ -424,18 +388,16 @@ export class ConnectionService { url: string, orgId: string, receiveInvitation: IReceiveInvitation - ): Promise<{ - response; - }> { + ): Promise { const pattern = { cmd: 'agent-receive-invitation' }; const payload = { url, orgId, receiveInvitation }; - return this.natsCall(pattern, payload); + return this.natsClient.send(this.connectionServiceProxy, pattern, payload); } async _sendQuestion(questionPayload: IQuestionPayload, url: string, orgId: string): Promise { const pattern = { cmd: 'agent-send-question' }; const payload = { questionPayload, url, orgId }; - return this.natsCall(pattern, payload); + return this.natsClient.send(this.connectionServiceProxy, pattern, payload); } async sendQuestion(payload: IQuestionPayload): Promise { @@ -467,7 +429,7 @@ export class ConnectionService { statusCode: error.status?.code ?? HttpStatus.INTERNAL_SERVER_ERROR }); } - throw new RpcException(error.response || error); + throw new RpcException(error?.response ?? error); } } @@ -478,8 +440,8 @@ export class ConnectionService { const payload = { persistent, storeObj }; try { - const message = await this.natsCall(pattern, payload); - return message.response; + const message = this.natsClient.send(this.connectionServiceProxy, pattern, payload); + return message; } catch (error) { this.logger.error(`catch: ${JSON.stringify(error)}`); throw new HttpException( @@ -561,13 +523,13 @@ export class ConnectionService { }; const url = await getAgentUrl(agentEndPoint, CommonConstants.CONNECTION_INVITATION); const createConnectionInvitation = await this._createOutOfBandConnectionInvitation(connectionPayload, url, orgId); - const connectionInvitationUrl = createConnectionInvitation?.response?.invitationUrl; + const connectionInvitationUrl = createConnectionInvitation?.invitationUrl; const shortenedUrl = await this.storeConnectionObjectAndReturnUrl( connectionInvitationUrl, connectionPayload.multiUseInvitation ); - const invitationsDid = createConnectionInvitation?.response?.invitationDid || invitationDid; + const invitationsDid = createConnectionInvitation?.invitationDid || invitationDid; const saveConnectionDetails = await this.connectionRepository.saveAgentConnectionInvitations( shortenedUrl, agentId, @@ -584,7 +546,7 @@ export class ConnectionService { createdBy: saveConnectionDetails.createdBy, lastChangedDateTime: saveConnectionDetails.lastChangedDateTime, lastChangedBy: saveConnectionDetails.lastChangedBy, - recordId: createConnectionInvitation.response.outOfBandRecord.id, + recordId: createConnectionInvitation.outOfBandRecord.id, invitationDid: saveConnectionDetails.invitationDid }; return connectionStorePayload; @@ -603,15 +565,14 @@ export class ConnectionService { connectionPayload: ICreateConnectionInvitation, url: string, orgId: string - ): Promise<{ - response; - }> { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + ): Promise { //nats call in agent-service to create an invitation url const pattern = { cmd: 'agent-create-connection-invitation' }; const payload = { connectionPayload, url, orgId }; try { - return await this.natsCall(pattern, payload); + return this.natsClient.send(this.connectionServiceProxy, pattern, payload); } catch (error) { this.logger.error(`catch: ${JSON.stringify(error)}`); throw new HttpException( @@ -624,36 +585,6 @@ export class ConnectionService { } } - async natsCall( - pattern: object, - payload: object - ): Promise<{ - response: string; - }> { - try { - return from(this.natsClient.send(this.connectionServiceProxy, pattern, payload)) - .pipe( - map((response) => ({ - response - })) - ) - .toPromise() - .catch((error) => { - this.logger.error(`catch: ${JSON.stringify(error)}`); - throw new HttpException( - { - status: error.statusCode, - error: error.message - }, - error.error - ); - }); - } catch (error) { - this.logger.error(`[ConnectionService natsCall] - error in nats call : ${JSON.stringify(error)}`); - throw error; - } - } - handleError(error): Promise { if (error?.status?.message?.error) { throw new RpcException({ @@ -661,7 +592,7 @@ export class ConnectionService { statusCode: error.status?.code ?? HttpStatus.INTERNAL_SERVER_ERROR }); } - throw new RpcException(error.response || error); + throw new RpcException(error?.response ?? error); } async deleteConnectionRecords(orgId: string, user: user): Promise { @@ -703,11 +634,11 @@ export class ConnectionService { return deleteConnections; } catch (error) { this.logger.error(`[deleteConnectionRecords] - error in deleting connection records: ${JSON.stringify(error)}`); - throw new RpcException(error.response ? error.response : error); + throw new RpcException(error?.response ?? error); } } - async sendBasicMesage(payload: IBasicMessage): Promise { + async sendBasicMessage(payload: IBasicMessage): Promise { const { content, orgId, connectionId } = payload; try { const agentDetails = await this.connectionRepository.getAgentEndPoint(orgId); @@ -733,14 +664,13 @@ export class ConnectionService { statusCode: error.status?.code ?? HttpStatus.INTERNAL_SERVER_ERROR }); } - throw new RpcException(error.response || error); + throw new RpcException(error?.response ?? error); } } async _sendBasicMessageToAgent(content: IBasicMessage, url: string, orgId: string): Promise { const pattern = { cmd: 'agent-send-basic-message' }; const payload = { content, url, orgId }; - // eslint-disable-next-line no-return-await - return await this.natsCall(pattern, payload); + return this.natsClient.send(this.connectionServiceProxy, pattern, payload); } } From a03632e2be9a03d24b648efbfbc389b80d80a4a8 Mon Sep 17 00:00:00 2001 From: Krishna Waske Date: Thu, 13 Nov 2025 17:33:02 +0530 Subject: [PATCH 5/8] fix: webhook service unwanted imports Signed-off-by: Krishna Waske --- apps/webhook/src/webhook.service.ts | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/apps/webhook/src/webhook.service.ts b/apps/webhook/src/webhook.service.ts index 3d3402bd2..f0e899261 100644 --- a/apps/webhook/src/webhook.service.ts +++ b/apps/webhook/src/webhook.service.ts @@ -1,27 +1,16 @@ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ -import { CommonService } from '@credebl/common'; import { WebhookRepository } from './webhook.repository'; import { ResponseMessages } from '@credebl/common/response-messages'; -import { ClientProxy, RpcException } from '@nestjs/microservices'; +import { RpcException } from '@nestjs/microservices'; import AsyncRetry = require('async-retry'); import { ICreateWebhookUrl, IGetWebhookUrl, IWebhookDto } from '../interfaces/webhook.interfaces'; -import { - Inject, - Injectable, - InternalServerErrorException, - Logger, - NotFoundException -} from '@nestjs/common'; +import { Injectable, InternalServerErrorException, Logger, NotFoundException } from '@nestjs/common'; import { IWebhookUrl } from '@credebl/common/interfaces/webhook.interface'; @Injectable() export class WebhookService { private readonly logger = new Logger('WebhookService'); - constructor( - @Inject('NATS_CLIENT') private readonly webhookProxy: ClientProxy, - private readonly commonService: CommonService, - private readonly webhookRepository: WebhookRepository - ) {} + constructor(private readonly webhookRepository: WebhookRepository) {} // eslint-disable-next-line @typescript-eslint/explicit-function-return-type retryOptions(logger: Logger) { From 00d00acea1244da4bee857d7450bfd48182b8d38 Mon Sep 17 00:00:00 2001 From: Krishna Waske Date: Thu, 13 Nov 2025 17:39:07 +0530 Subject: [PATCH 6/8] chore: add todos to remove nested mapping Signed-off-by: Krishna Waske --- apps/ledger/src/schema/schema.service.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/ledger/src/schema/schema.service.ts b/apps/ledger/src/schema/schema.service.ts index 276c840ed..d4b4f5f31 100644 --- a/apps/ledger/src/schema/schema.service.ts +++ b/apps/ledger/src/schema/schema.service.ts @@ -402,6 +402,7 @@ export class SchemaService extends BaseService { }; const schemaResponse = await from(this.natsClient.send(this.schemaServiceProxy, pattern, payload)) .pipe( + // TODO: remove nested mapping map((response) => ({ response })) @@ -429,6 +430,7 @@ export class SchemaService extends BaseService { }; const W3CSchemaResponse = await from(this.natsClient.send(this.schemaServiceProxy, natsPattern, payload)) .pipe( + // TODO: remove nested mapping map((response) => ({ response })) @@ -553,6 +555,7 @@ export class SchemaService extends BaseService { }; const schemaResponse = await from(this.natsClient.send(this.schemaServiceProxy, pattern, payload)) .pipe( + // TODO: remove nested mapping map((response) => ({ response })) From 8c71442005c4429c5969d5157aba6524d673fc78 Mon Sep 17 00:00:00 2001 From: Krishna Waske Date: Fri, 14 Nov 2025 18:18:55 +0530 Subject: [PATCH 7/8] fix: sonar cube issues Signed-off-by: Krishna Waske --- .../src/agent-service.service.ts | 9 ++++--- apps/connection/src/connection.service.ts | 21 +++++++++++----- apps/verification/src/verification.service.ts | 24 +++++++++++-------- 3 files changed, 35 insertions(+), 19 deletions(-) diff --git a/apps/agent-service/src/agent-service.service.ts b/apps/agent-service/src/agent-service.service.ts index 8d6360f97..d963677b0 100644 --- a/apps/agent-service/src/agent-service.service.ts +++ b/apps/agent-service/src/agent-service.service.ts @@ -699,7 +699,8 @@ export class AgentServiceService { cmd: 'create-connection-invitation' }; const payload = { createOutOfBandConnectionInvitation: { orgId, user, label } }; - return this.natsClient.send(this.agentServiceProxy, pattern, payload); + const result = await this.natsClient.send(this.agentServiceProxy, pattern, payload); + return result; } catch (error) { this.logger.error(`[natsCall] - error in create-connection in wallet provision : ${JSON.stringify(error)}`); } @@ -711,7 +712,8 @@ export class AgentServiceService { cmd: 'get-all-ledgers' }; const payload = {}; - return this.natsClient.send(this.agentServiceProxy, pattern, payload); + const result = await this.natsClient.send(this.agentServiceProxy, pattern, payload); + return result; } catch (error) { this.logger.error(`[natsCall] - error in while fetching all the ledger details : ${JSON.stringify(error)}`); } @@ -722,7 +724,8 @@ export class AgentServiceService { const pattern = { cmd: 'wallet-provisioning' }; - return this.natsClient.send(this.agentServiceProxy, pattern, payload); + const result = await this.natsClient.send>(this.agentServiceProxy, pattern, payload); + return result; } catch (error) { this.logger.error(`[natsCall] - error in wallet provision : ${JSON.stringify(error)}`); throw error; diff --git a/apps/connection/src/connection.service.ts b/apps/connection/src/connection.service.ts index f98fe99a0..0d45f2ae1 100644 --- a/apps/connection/src/connection.service.ts +++ b/apps/connection/src/connection.service.ts @@ -67,7 +67,8 @@ export class ConnectionService { const payload = { connectionPayload, url, orgId }; try { - return this.natsClient.send(this.connectionServiceProxy, pattern, payload); + const result = await this.natsClient.send(this.connectionServiceProxy, pattern, payload); + return result; } catch (error) { this.logger.error(`catch: ${JSON.stringify(error)}`); throw new HttpException( @@ -226,7 +227,8 @@ export class ConnectionService { try { const pattern = { cmd: 'agent-get-all-connections' }; const payload = { url, orgId }; - return this.natsClient.send(this.connectionServiceProxy, pattern, payload); + const result = await this.natsClient.send(this.connectionServiceProxy, pattern, payload); + return result; } catch (error) { this.logger.error( `[_getAllConnections] [NATS call]- error in fetch connections details : ${JSON.stringify(error)}` @@ -288,7 +290,8 @@ export class ConnectionService { try { const pattern = { cmd: 'agent-get-question-answer-record' }; const payload = { url, orgId }; - return this.natsClient.send(this.connectionServiceProxy, pattern, payload); + const result = await this.natsClient.send(this.connectionServiceProxy, pattern, payload); + return result; } catch (error) { this.logger.error( `[_getQuestionAnswersRecord ] [NATS call]- error in get question and answer records : ${JSON.stringify(error)}` @@ -342,7 +345,12 @@ export class ConnectionService { const payload = { url, orgId, receiveInvitationUrl }; try { - return this.natsClient.send(this.connectionServiceProxy, pattern, payload); + const result = await this.natsClient.send( + this.connectionServiceProxy, + pattern, + payload + ); + return result; } catch (error) { this.logger.error(`catch: ${JSON.stringify(error)}`); throw new HttpException( @@ -440,7 +448,7 @@ export class ConnectionService { const payload = { persistent, storeObj }; try { - const message = this.natsClient.send(this.connectionServiceProxy, pattern, payload); + const message = await this.natsClient.send(this.connectionServiceProxy, pattern, payload); return message; } catch (error) { this.logger.error(`catch: ${JSON.stringify(error)}`); @@ -572,7 +580,8 @@ export class ConnectionService { const payload = { connectionPayload, url, orgId }; try { - return this.natsClient.send(this.connectionServiceProxy, pattern, payload); + const result = await this.natsClient.send(this.connectionServiceProxy, pattern, payload); + return result; } catch (error) { this.logger.error(`catch: ${JSON.stringify(error)}`); throw new HttpException( diff --git a/apps/verification/src/verification.service.ts b/apps/verification/src/verification.service.ts index 1f9b91d9b..9798cd387 100644 --- a/apps/verification/src/verification.service.ts +++ b/apps/verification/src/verification.service.ts @@ -181,12 +181,11 @@ export class VerificationService { * @param payload * @returns Get all proof presentation */ - async _getProofPresentations(payload: IGetAllProofPresentations): Promise<{ - response: string; - }> { + async _getProofPresentations(payload: IGetAllProofPresentations): Promise { try { const pattern = { cmd: 'agent-get-proof-presentations' }; - return this.natsClient.send(this.verificationServiceProxy, pattern, payload); + const result = await this.natsClient.send(this.verificationServiceProxy, pattern, payload); + return result; } catch (error) { this.logger.error(`[_getProofPresentations] - error in get proof presentations : ${JSON.stringify(error)}`); throw error; @@ -260,7 +259,8 @@ export class VerificationService { cmd: 'agent-get-proof-presentation-by-id' }; - return this.natsClient.send(this.verificationServiceProxy, pattern, payload); + const result = await this.natsClient.send(this.verificationServiceProxy, pattern, payload); + return result; } catch (error) { this.logger.error( `[_getProofPresentationById] - error in get proof presentation by id : ${JSON.stringify(error)}` @@ -382,9 +382,10 @@ export class VerificationService { cmd: 'agent-send-proof-request' }; - return this.natsClient.send(this.verificationServiceProxy, pattern, payload); + const result = await this.natsClient.send(this.verificationServiceProxy, pattern, payload); + return result; } catch (error) { - this.logger.error(`[_sendProofRequest] - error in verify presentation : ${JSON.stringify(error)}`); + this.logger.error(`[_sendProofRequest] - error in nats in verify presentation : ${JSON.stringify(error)}`); throw error; } } @@ -432,7 +433,8 @@ export class VerificationService { cmd: 'agent-verify-presentation' }; - return this.natsClient.send(this.verificationServiceProxy, pattern, payload); + const result = await this.natsClient.send(this.verificationServiceProxy, pattern, payload); + return result; } catch (error) { this.logger.error(`[_verifyPresentation] - error in verify presentation : ${JSON.stringify(error)}`); throw error; @@ -677,7 +679,8 @@ export class VerificationService { cmd: 'agent-send-out-of-band-proof-request' }; - return this.natsClient.send(this.verificationServiceProxy, pattern, payload); + const result = await this.natsClient.send(this.verificationServiceProxy, pattern, payload); + return result; } catch (error) { this.logger.error(`[_sendOutOfBandProofRequest] - error in Out Of Band Presentation : ${JSON.stringify(error)}`); throw error; @@ -940,7 +943,8 @@ export class VerificationService { cmd: 'get-agent-verified-proof-details' }; - return this.natsClient.send(this.verificationServiceProxy, pattern, payload); + const result = await this.natsClient.send(this.verificationServiceProxy, pattern, payload); + return result; } catch (error) { this.logger.error(`[_getVerifiedProofDetails] - error in verified proof details : ${JSON.stringify(error)}`); throw error; From cfd62578bcfcb1551093949081b2bca3daddad59 Mon Sep 17 00:00:00 2001 From: Krishna Waske Date: Fri, 14 Nov 2025 18:55:02 +0530 Subject: [PATCH 8/8] fix: coderabbit suggestions Signed-off-by: Krishna Waske --- apps/agent-service/src/agent-service.service.ts | 15 +++++++++++++++ apps/verification/src/verification.service.ts | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/apps/agent-service/src/agent-service.service.ts b/apps/agent-service/src/agent-service.service.ts index d963677b0..648e64b9e 100644 --- a/apps/agent-service/src/agent-service.service.ts +++ b/apps/agent-service/src/agent-service.service.ts @@ -499,6 +499,13 @@ export class AgentServiceService { const { network } = agentSpinupDto; const ledger = await ledgerName(network); const ledgerList = await this._getALlLedgerDetails(); + if (!ledgerList) { + throw new BadRequestException(ResponseMessages.agent.error.invalidLedger, { + cause: new Error(), + description: ResponseMessages.errorMessages.notFound + }); + } + const isLedgerExist = ledgerList.find((existingLedgers) => existingLedgers.name === ledger); if (!isLedgerExist) { throw new BadRequestException(ResponseMessages.agent.error.invalidLedger, { @@ -703,6 +710,7 @@ export class AgentServiceService { return result; } catch (error) { this.logger.error(`[natsCall] - error in create-connection in wallet provision : ${JSON.stringify(error)}`); + throw new RpcException(error?.response ? error.response : error); } } @@ -716,6 +724,7 @@ export class AgentServiceService { return result; } catch (error) { this.logger.error(`[natsCall] - error in while fetching all the ledger details : ${JSON.stringify(error)}`); + throw new RpcException(error?.response ? error.response : error); } } @@ -789,6 +798,12 @@ export class AgentServiceService { } const ledgerList = await this._getALlLedgerDetails(); + if (!ledgerList) { + throw new BadRequestException(ResponseMessages.agent.error.invalidLedger, { + cause: new Error(), + description: ResponseMessages.errorMessages.notFound + }); + } const isLedgerExist = ledgerList.find((existingLedgers) => existingLedgers.name === ledger); if (!isLedgerExist) { throw new BadRequestException(ResponseMessages.agent.error.invalidLedger, { diff --git a/apps/verification/src/verification.service.ts b/apps/verification/src/verification.service.ts index 9798cd387..3f2e84b00 100644 --- a/apps/verification/src/verification.service.ts +++ b/apps/verification/src/verification.service.ts @@ -385,7 +385,7 @@ export class VerificationService { const result = await this.natsClient.send(this.verificationServiceProxy, pattern, payload); return result; } catch (error) { - this.logger.error(`[_sendProofRequest] - error in nats in verify presentation : ${JSON.stringify(error)}`); + this.logger.error(`[_sendProofRequest] - nats error in sending proof request : ${JSON.stringify(error)}`); throw error; } }