From 35582f0ab2985469a33e959a626c30384658e565 Mon Sep 17 00:00:00 2001 From: sujitaw Date: Wed, 3 Dec 2025 10:22:48 +0530 Subject: [PATCH 1/2] fix/get formatted data error Signed-off-by: sujitaw --- src/events/CredentialEvents.ts | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/src/events/CredentialEvents.ts b/src/events/CredentialEvents.ts index 9c94693e..feb48702 100644 --- a/src/events/CredentialEvents.ts +++ b/src/events/CredentialEvents.ts @@ -4,6 +4,7 @@ import type { Agent, CredentialStateChangedEvent } from '@credo-ts/core' import { CredentialEventTypes } from '@credo-ts/core' + import { sendWebSocketEvent } from './WebSocketEvents' import { sendWebhookEvent } from './WebhookEvent' @@ -19,12 +20,34 @@ export const credentialEvents = async (agent: Agent, config: ServerConfig) => { } if (record?.connectionId) { - const connectionRecord = await agent.connections.findById(record.connectionId!) + let connectionRecord + if (event.metadata.contextCorrelationId !== 'default') { + await (agent as Agent).modules.tenants.withTenantAgent( + { tenantId: body.contextCorrelationId as string }, + async (tenantAgent) => { + connectionRecord = await tenantAgent.connections.findById(record.connectionId!) + }, + ) + } else { + connectionRecord = await agent.connections.getById(record.connectionId!) + } body.outOfBandId = connectionRecord?.outOfBandId } - const data = await agent.credentials.getFormatData(record.id) - body.credentialData = data + + let formatData = null + if (event.metadata.contextCorrelationId !== 'default') { + await (agent as Agent).modules.tenants.withTenantAgent( + { tenantId: body.contextCorrelationId as string }, + async (tenantAgent) => { + formatData = await tenantAgent.credentials.getFormatData(record.id) + }, + ) + } else { + formatData = await agent.credentials.getFormatData(record.id) + } + + body.credentialData = formatData if (config.webhookUrl) { await sendWebhookEvent(config.webhookUrl + '/credentials', body, agent.config.logger) From b642f9eb392092c6e0f1142b3cdd6ee6aafaad51 Mon Sep 17 00:00:00 2001 From: sujitaw Date: Wed, 3 Dec 2025 10:53:57 +0530 Subject: [PATCH 2/2] fix/ellipse comments Signed-off-by: sujitaw --- src/events/CredentialEvents.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/events/CredentialEvents.ts b/src/events/CredentialEvents.ts index feb48702..9ebbbcda 100644 --- a/src/events/CredentialEvents.ts +++ b/src/events/CredentialEvents.ts @@ -4,7 +4,6 @@ import type { Agent, CredentialStateChangedEvent } from '@credo-ts/core' import { CredentialEventTypes } from '@credo-ts/core' - import { sendWebSocketEvent } from './WebSocketEvents' import { sendWebhookEvent } from './WebhookEvent' @@ -21,22 +20,21 @@ export const credentialEvents = async (agent: Agent, config: ServerConfig) => { if (record?.connectionId) { let connectionRecord - if (event.metadata.contextCorrelationId !== 'default') { + if (event.metadata.contextCorrelationId && event.metadata.contextCorrelationId !== 'default') { await (agent as Agent).modules.tenants.withTenantAgent( { tenantId: body.contextCorrelationId as string }, async (tenantAgent) => { - connectionRecord = await tenantAgent.connections.findById(record.connectionId!) + connectionRecord = await tenantAgent.connections.findById(record.connectionId ? record.connectionId : '') }, ) } else { - connectionRecord = await agent.connections.getById(record.connectionId!) + connectionRecord = await agent.connections.getById(record.connectionId) } body.outOfBandId = connectionRecord?.outOfBandId } - let formatData = null - if (event.metadata.contextCorrelationId !== 'default') { + if (event.metadata.contextCorrelationId && event.metadata.contextCorrelationId !== 'default') { await (agent as Agent).modules.tenants.withTenantAgent( { tenantId: body.contextCorrelationId as string }, async (tenantAgent) => {