Skip to content

Commit c28e678

Browse files
authored
persist the delegated credential in the offer for revocation purposes (#566)
* persist delegated credential in the offer for revocation purposes * persist delegated credential in the offer for revocation purposes * persist delegated credential in the offer for revocation purposes * refactoring * assert revocationData is present in the delegation offer document
1 parent c76f686 commit c28e678

5 files changed

Lines changed: 19 additions & 0 deletions

File tree

integration-tests/delegation-offer.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ describe('Credential Distribution', () => {
167167
expect(updatedOffer.type).toContain('DelegationOffer');
168168
expect(updatedOffer.status).toBe('accepted');
169169
expect(updatedOffer.holderDID).toBe(holderWallet.did);
170+
expect(updatedOffer.revocationData.credentialId).toBeDefined();
171+
expect(updatedOffer.revocationData.credentialStatus).toBeDefined();
170172

171173
// Step 4: Holder receive the delegatable credential from the issuer
172174
const delegationIssuanceMessage =

integration-tests/helpers/wallet-helpers.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,18 @@ type FullWalletClient = {
4343
messageProvider: IMessageProvider;
4444
}
4545

46+
const SPONSOR_KEY = process.env.TRUVERA_API_SPONSOR_KEY;
47+
const API_URL = process.env.DELEGATION_REVOCATION_API_URL;
48+
4649
export async function createFullWalletClient(): Promise<FullWalletClient> {
4750
const dataStore = await createDataStore({
4851
databasePath: ':memory:',
4952
dbType: 'sqlite',
5053
defaultNetwork: 'testnet',
54+
truveraApi: {
55+
authKey: SPONSOR_KEY,
56+
apiUrl: API_URL,
57+
}
5158
});
5259
const wallet = await createWallet({
5360
dataStore,

packages/core/src/delegation/delegation-offer.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,14 @@ export const DELEGATION_REQUEST_HANDLER = {
380380
},
381381
});
382382

383+
// Persist revocation data on the delegation offer so the issuer can update it when revoking.
384+
delegationOffer.revocationData = {
385+
credentialStatus: delegatedCredential.credentialStatus,
386+
credentialId: delegatedCredential.id,
387+
};
388+
389+
await wallet.updateDocument(delegationOffer);
390+
383391
const delegationChain = await getDelegationChain(parentCredential, wallet);
384392

385393
await messageProvider.sendMessage({

packages/data-store/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export async function createDataStore({
6363
const dataStore: DataStore = {
6464
events: new EventEmitter(),
6565
db: dataSource,
66+
configs: configs,
6667
networkId: options.defaultNetwork,
6768
network: options.networks.find(item => item.id === options.defaultNetwork),
6869
testNetworkId: options.testNetworkId,

packages/data-store/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export type DataStore = {
5757
setNetwork: (networkId: string) => Promise<void>;
5858
documents: DocumentStore;
5959
wallet: WalletStore;
60+
configs: DataStoreConfigs;
6061
};
6162

6263
export type ContextProps = {

0 commit comments

Comments
 (0)