From 4a64ddf6fc19a3b35fa8706157b74b96a94a119c Mon Sep 17 00:00:00 2001 From: pranalidhanavade Date: Thu, 20 Feb 2025 15:49:13 +0530 Subject: [PATCH 1/5] fix: added goalCode, outOfBandRecordId, credentialRequestThId in credential controller Signed-off-by: pranalidhanavade --- src/controllers/credentials/CredentialController.ts | 3 +++ src/events/CredentialEvents.ts | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/controllers/credentials/CredentialController.ts b/src/controllers/credentials/CredentialController.ts index 150a9f6b..ef5ba843 100644 --- a/src/controllers/credentials/CredentialController.ts +++ b/src/controllers/credentials/CredentialController.ts @@ -219,6 +219,7 @@ export class CredentialController extends Controller { messages: [credentialMessage], autoAcceptConnection: true, imageUrl: outOfBandOption?.imageUrl, + goalCode: outOfBandOption?.goalCode, invitationDid, }) return { @@ -230,6 +231,8 @@ export class CredentialController extends Controller { }), outOfBandRecord: outOfBandRecord.toJSON(), invitationDid: outOfBandOption?.invitationDid ? '' : invitationDid, + outOfBandRecordId: outOfBandRecord.id, + credentialRequestThId: offerOob.credentialRecord.threadId, } } catch (error) { throw ErrorHandlingService.handle(error) diff --git a/src/events/CredentialEvents.ts b/src/events/CredentialEvents.ts index e266da51..cca76e98 100644 --- a/src/events/CredentialEvents.ts +++ b/src/events/CredentialEvents.ts @@ -30,9 +30,12 @@ export const credentialEvents = async (agent: Agent ) } - if (event.metadata.contextCorrelationId === 'default') { + if (event.metadata.contextCorrelationId === 'default' && record?.connectionId) { + const connectionRecord = await agent.connections.findById(record.connectionId!) + const data = await agent.credentials.getFormatData(record.id) body.credentialData = data + body.outOfBandId = connectionRecord?.outOfBandId } // Only send webhook if webhook url is configured if (config.webhookUrl) { @@ -50,4 +53,4 @@ export const credentialEvents = async (agent: Agent }) } }) -} \ No newline at end of file +} From 94a59c07d528d84d6f5799a49b1ad835811982e3 Mon Sep 17 00:00:00 2001 From: pranalidhanavade Date: Fri, 21 Feb 2025 11:46:25 +0530 Subject: [PATCH 2/5] fix: added conditions for connectionId and outOfBandId in credential controller Signed-off-by: pranalidhanavade --- .../credentials/CredentialController.ts | 2 +- src/events/CredentialEvents.ts | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/controllers/credentials/CredentialController.ts b/src/controllers/credentials/CredentialController.ts index ef5ba843..41fb3c1d 100644 --- a/src/controllers/credentials/CredentialController.ts +++ b/src/controllers/credentials/CredentialController.ts @@ -230,9 +230,9 @@ export class CredentialController extends Controller { useDidSovPrefixWhereAllowed: this.agent.config.useDidSovPrefixWhereAllowed, }), outOfBandRecord: outOfBandRecord.toJSON(), - invitationDid: outOfBandOption?.invitationDid ? '' : invitationDid, outOfBandRecordId: outOfBandRecord.id, credentialRequestThId: offerOob.credentialRecord.threadId, + invitationDid: outOfBandOption?.invitationDid ? '' : invitationDid, } } catch (error) { throw ErrorHandlingService.handle(error) diff --git a/src/events/CredentialEvents.ts b/src/events/CredentialEvents.ts index cca76e98..f8fe6c5d 100644 --- a/src/events/CredentialEvents.ts +++ b/src/events/CredentialEvents.ts @@ -18,24 +18,28 @@ export const credentialEvents = async (agent: Agent credentialData: null, } - if (event.metadata.contextCorrelationId !== 'default' && record?.connectionId) { + if (event.metadata.contextCorrelationId !== 'default') { await agent.modules.tenants.withTenantAgent( { tenantId: event.metadata.contextCorrelationId }, async (tenantAgent) => { - const connectionRecord = await tenantAgent.connections.findById(record.connectionId!) + if (record.connectionId) { + const connectionRecord = await tenantAgent.connections.findById(record.connectionId!) + body.outOfBandId = connectionRecord?.outOfBandId + } const data = await tenantAgent.credentials.getFormatData(record.id) body.credentialData = data - body.outOfBandId = connectionRecord?.outOfBandId } ) } - if (event.metadata.contextCorrelationId === 'default' && record?.connectionId) { - const connectionRecord = await agent.connections.findById(record.connectionId!) + if (event.metadata.contextCorrelationId === 'default') { + if (record.connectionId) { + const connectionRecord = await agent.connections.findById(record.connectionId!) + body.outOfBandId = connectionRecord?.outOfBandId + } const data = await agent.credentials.getFormatData(record.id) body.credentialData = data - body.outOfBandId = connectionRecord?.outOfBandId } // Only send webhook if webhook url is configured if (config.webhookUrl) { From e4bb354a2c2a62f83a5252c4afadad0f1a2c8484 Mon Sep 17 00:00:00 2001 From: pranalidhanavade Date: Fri, 21 Feb 2025 11:49:21 +0530 Subject: [PATCH 3/5] fix: added optional chaining for connectionId record Signed-off-by: pranalidhanavade --- src/events/CredentialEvents.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/events/CredentialEvents.ts b/src/events/CredentialEvents.ts index f8fe6c5d..7ee22e27 100644 --- a/src/events/CredentialEvents.ts +++ b/src/events/CredentialEvents.ts @@ -22,7 +22,7 @@ export const credentialEvents = async (agent: Agent await agent.modules.tenants.withTenantAgent( { tenantId: event.metadata.contextCorrelationId }, async (tenantAgent) => { - if (record.connectionId) { + if (record?.connectionId) { const connectionRecord = await tenantAgent.connections.findById(record.connectionId!) body.outOfBandId = connectionRecord?.outOfBandId } @@ -33,7 +33,7 @@ export const credentialEvents = async (agent: Agent } if (event.metadata.contextCorrelationId === 'default') { - if (record.connectionId) { + if (record?.connectionId) { const connectionRecord = await agent.connections.findById(record.connectionId!) body.outOfBandId = connectionRecord?.outOfBandId } From 8974a5e72bf0fcef207a304eb718ded60f5d1748 Mon Sep 17 00:00:00 2001 From: pranalidhanavade Date: Fri, 21 Feb 2025 12:21:11 +0530 Subject: [PATCH 4/5] fix: added extra check contextCorrelationId in credential events Signed-off-by: pranalidhanavade --- src/events/CredentialEvents.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/events/CredentialEvents.ts b/src/events/CredentialEvents.ts index 7ee22e27..dca1de0b 100644 --- a/src/events/CredentialEvents.ts +++ b/src/events/CredentialEvents.ts @@ -18,7 +18,7 @@ export const credentialEvents = async (agent: Agent credentialData: null, } - if (event.metadata.contextCorrelationId !== 'default') { + if (event.metadata.contextCorrelationId && event.metadata.contextCorrelationId !== 'default') { await agent.modules.tenants.withTenantAgent( { tenantId: event.metadata.contextCorrelationId }, async (tenantAgent) => { @@ -32,7 +32,7 @@ export const credentialEvents = async (agent: Agent ) } - if (event.metadata.contextCorrelationId === 'default') { + if (event.metadata.contextCorrelationId && event.metadata.contextCorrelationId === 'default') { if (record?.connectionId) { const connectionRecord = await agent.connections.findById(record.connectionId!) body.outOfBandId = connectionRecord?.outOfBandId From ee69b65ceaaee8f79a61f0ebaf339628596dc277 Mon Sep 17 00:00:00 2001 From: pranalidhanavade Date: Fri, 21 Feb 2025 18:20:02 +0530 Subject: [PATCH 5/5] fix: removed extra check for contextCorrelationId Signed-off-by: pranalidhanavade --- src/events/CredentialEvents.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/events/CredentialEvents.ts b/src/events/CredentialEvents.ts index dca1de0b..7ee22e27 100644 --- a/src/events/CredentialEvents.ts +++ b/src/events/CredentialEvents.ts @@ -18,7 +18,7 @@ export const credentialEvents = async (agent: Agent credentialData: null, } - if (event.metadata.contextCorrelationId && event.metadata.contextCorrelationId !== 'default') { + if (event.metadata.contextCorrelationId !== 'default') { await agent.modules.tenants.withTenantAgent( { tenantId: event.metadata.contextCorrelationId }, async (tenantAgent) => { @@ -32,7 +32,7 @@ export const credentialEvents = async (agent: Agent ) } - if (event.metadata.contextCorrelationId && event.metadata.contextCorrelationId === 'default') { + if (event.metadata.contextCorrelationId === 'default') { if (record?.connectionId) { const connectionRecord = await agent.connections.findById(record.connectionId!) body.outOfBandId = connectionRecord?.outOfBandId