From f8eba3b361af3a260141ab9060cebab66a853dc5 Mon Sep 17 00:00:00 2001 From: Maycon Mello Date: Tue, 28 Jul 2026 14:38:43 -0300 Subject: [PATCH 1/5] persist delegated credential in the offer for revocation purposes --- packages/core/src/delegation/delegation-offer.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/core/src/delegation/delegation-offer.ts b/packages/core/src/delegation/delegation-offer.ts index 03d8c306..a7548f96 100644 --- a/packages/core/src/delegation/delegation-offer.ts +++ b/packages/core/src/delegation/delegation-offer.ts @@ -363,8 +363,6 @@ export const DELEGATION_REQUEST_HANDLER = { delegationOffer.holderDID = holderDID; delegationOffer.updatedAt = new Date().toISOString(); - await wallet.updateDocument(delegationOffer); - const issuerDID = pickDID(message.to); const delegatedCredential = await delegateCredential({ @@ -380,6 +378,10 @@ export const DELEGATION_REQUEST_HANDLER = { }, }); + delegationOffer.credential = delegatedCredential; + + await wallet.updateDocument(delegationOffer); + const delegationChain = await getDelegationChain(parentCredential, wallet); await messageProvider.sendMessage({ From f4af68ea62ed49d4e98b978a5295b4d6353d7658 Mon Sep 17 00:00:00 2001 From: Maycon Mello Date: Tue, 28 Jul 2026 14:49:00 -0300 Subject: [PATCH 2/5] persist delegated credential in the offer for revocation purposes --- packages/core/src/delegation/delegation-offer.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/core/src/delegation/delegation-offer.ts b/packages/core/src/delegation/delegation-offer.ts index a7548f96..c98023d3 100644 --- a/packages/core/src/delegation/delegation-offer.ts +++ b/packages/core/src/delegation/delegation-offer.ts @@ -378,7 +378,8 @@ export const DELEGATION_REQUEST_HANDLER = { }, }); - delegationOffer.credential = delegatedCredential; + delegationOffer.credentialStatus = delegatedCredential.credentialStatus; + delegationOffer.credentialId = delegatedCredential.id; await wallet.updateDocument(delegationOffer); From caf87d7a35f306348df28da11ff61bd1d8ad7cd8 Mon Sep 17 00:00:00 2001 From: Maycon Mello Date: Tue, 28 Jul 2026 14:55:07 -0300 Subject: [PATCH 3/5] persist delegated credential in the offer for revocation purposes --- packages/core/src/delegation/delegation-offer.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/core/src/delegation/delegation-offer.ts b/packages/core/src/delegation/delegation-offer.ts index c98023d3..9092756c 100644 --- a/packages/core/src/delegation/delegation-offer.ts +++ b/packages/core/src/delegation/delegation-offer.ts @@ -363,6 +363,8 @@ export const DELEGATION_REQUEST_HANDLER = { delegationOffer.holderDID = holderDID; delegationOffer.updatedAt = new Date().toISOString(); + await wallet.updateDocument(delegationOffer); + const issuerDID = pickDID(message.to); const delegatedCredential = await delegateCredential({ @@ -378,6 +380,7 @@ export const DELEGATION_REQUEST_HANDLER = { }, }); + // Persist revocation data on the delegation offer so the issuer can update it when revoking. delegationOffer.credentialStatus = delegatedCredential.credentialStatus; delegationOffer.credentialId = delegatedCredential.id; From 81520ae7cb444b6093446bd8ea5a437d93664111 Mon Sep 17 00:00:00 2001 From: Maycon Mello Date: Tue, 28 Jul 2026 15:37:17 -0300 Subject: [PATCH 4/5] refactoring --- packages/core/src/delegation/delegation-offer.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/core/src/delegation/delegation-offer.ts b/packages/core/src/delegation/delegation-offer.ts index 9092756c..a42df6f0 100644 --- a/packages/core/src/delegation/delegation-offer.ts +++ b/packages/core/src/delegation/delegation-offer.ts @@ -381,8 +381,10 @@ export const DELEGATION_REQUEST_HANDLER = { }); // Persist revocation data on the delegation offer so the issuer can update it when revoking. - delegationOffer.credentialStatus = delegatedCredential.credentialStatus; - delegationOffer.credentialId = delegatedCredential.id; + delegationOffer.revocationData = { + credentialStatus: delegatedCredential.credentialStatus, + credentialId: delegatedCredential.id, + }; await wallet.updateDocument(delegationOffer); From e61dda5e571281a938824b51bfe9307bf83942e1 Mon Sep 17 00:00:00 2001 From: Maycon Mello Date: Tue, 28 Jul 2026 17:09:39 -0300 Subject: [PATCH 5/5] assert revocationData is present in the delegation offer document --- integration-tests/delegation-offer.test.ts | 2 ++ integration-tests/helpers/wallet-helpers.ts | 7 +++++++ packages/data-store/src/index.ts | 1 + packages/data-store/src/types.ts | 1 + 4 files changed, 11 insertions(+) diff --git a/integration-tests/delegation-offer.test.ts b/integration-tests/delegation-offer.test.ts index a499fc99..7720f48e 100644 --- a/integration-tests/delegation-offer.test.ts +++ b/integration-tests/delegation-offer.test.ts @@ -167,6 +167,8 @@ describe('Credential Distribution', () => { expect(updatedOffer.type).toContain('DelegationOffer'); expect(updatedOffer.status).toBe('accepted'); expect(updatedOffer.holderDID).toBe(holderWallet.did); + expect(updatedOffer.revocationData.credentialId).toBeDefined(); + expect(updatedOffer.revocationData.credentialStatus).toBeDefined(); // Step 4: Holder receive the delegatable credential from the issuer const delegationIssuanceMessage = diff --git a/integration-tests/helpers/wallet-helpers.ts b/integration-tests/helpers/wallet-helpers.ts index f155b8d0..44c326ec 100644 --- a/integration-tests/helpers/wallet-helpers.ts +++ b/integration-tests/helpers/wallet-helpers.ts @@ -43,11 +43,18 @@ type FullWalletClient = { messageProvider: IMessageProvider; } +const SPONSOR_KEY = process.env.TRUVERA_API_SPONSOR_KEY; +const API_URL = process.env.DELEGATION_REVOCATION_API_URL; + export async function createFullWalletClient(): Promise { const dataStore = await createDataStore({ databasePath: ':memory:', dbType: 'sqlite', defaultNetwork: 'testnet', + truveraApi: { + authKey: SPONSOR_KEY, + apiUrl: API_URL, + } }); const wallet = await createWallet({ dataStore, diff --git a/packages/data-store/src/index.ts b/packages/data-store/src/index.ts index dd9559be..93e1235b 100644 --- a/packages/data-store/src/index.ts +++ b/packages/data-store/src/index.ts @@ -63,6 +63,7 @@ export async function createDataStore({ const dataStore: DataStore = { events: new EventEmitter(), db: dataSource, + configs: configs, networkId: options.defaultNetwork, network: options.networks.find(item => item.id === options.defaultNetwork), testNetworkId: options.testNetworkId, diff --git a/packages/data-store/src/types.ts b/packages/data-store/src/types.ts index 6efb522f..97fb34ee 100644 --- a/packages/data-store/src/types.ts +++ b/packages/data-store/src/types.ts @@ -57,6 +57,7 @@ export type DataStore = { setNetwork: (networkId: string) => Promise; documents: DocumentStore; wallet: WalletStore; + configs: DataStoreConfigs; }; export type ContextProps = {