From ce1fc60a85716cb784ee163f4d8ea7e009543444 Mon Sep 17 00:00:00 2001 From: Andres Vallecilla Date: Thu, 12 Dec 2024 20:20:28 -0500 Subject: [PATCH] feat: update credential generation --- package.json | 1 + .../credentials/CredentialTypeController.ts | 16 ++++++++++----- packages/main/src/didWebServer.ts | 20 +++++++++---------- .../messages/calls/CallOfferRequestMessage.ts | 3 +-- 4 files changed, 23 insertions(+), 17 deletions(-) diff --git a/package.json b/package.json index 2b6ce82..a02ddbe 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "prebuild": "yarn workspace @2060.io/service-agent-model run build", "build": "yarn workspaces run build", "start": "yarn workspace @2060.io/service-agent-main run start", + "start:dev": "yarn workspace @2060.io/service-agent-main run start:dev", "check-types": "yarn check-types:build", "check-types:build": "yarn workspaces run tsc --noEmit -p tsconfig.build.json", "format": "prettier \"packages/*/src/**/*.ts\" --write", diff --git a/packages/main/src/controllers/credentials/CredentialTypeController.ts b/packages/main/src/controllers/credentials/CredentialTypeController.ts index 5645ac0..c08cb71 100644 --- a/packages/main/src/controllers/credentials/CredentialTypeController.ts +++ b/packages/main/src/controllers/credentials/CredentialTypeController.ts @@ -176,6 +176,7 @@ export class CredentialTypesController { options: {}, }) + this.logger.log(`revStatusListResult: ${JSON.stringify(revStatusListResult)}`) this.logger.log(`Credential Definition Id: ${credentialDefinitionId}`) this.logger.log(`Revocation Definition Id: ${revocationDefinitionId}`) @@ -190,15 +191,20 @@ export class CredentialTypesController { const revocationDefinitionRepository = agent.dependencyManager.resolve( AnonCredsRevocationRegistryDefinitionRepository, ) - const revocationDefinitionRecord = await revocationDefinitionRepository.getByRevocationRegistryDefinitionId( - agent.context, - revocationDefinitionId, - ) + const revocationDefinitionRecord = + await revocationDefinitionRepository.getByRevocationRegistryDefinitionId( + agent.context, + revocationDefinitionId, + ) credentialDefinitionRecord.setTag('name', options.name) credentialDefinitionRecord.setTag('version', options.version) credentialDefinitionRecord.setTag('revocationDefinitionId', revocationDefinitionId) + await credentialDefinitionRepository.update(agent.context, credentialDefinitionRecord) - revocationDefinitionRecord.metadata.add('revStatusList', revStatusListResult.revocationStatusListState.revocationStatusList!) + revocationDefinitionRecord.metadata.set( + 'revStatusList', + revStatusListResult.revocationStatusListState.revocationStatusList!, + ) await revocationDefinitionRepository.update(agent.context, revocationDefinitionRecord) return { diff --git a/packages/main/src/didWebServer.ts b/packages/main/src/didWebServer.ts index 7432301..f046da0 100644 --- a/packages/main/src/didWebServer.ts +++ b/packages/main/src/didWebServer.ts @@ -147,11 +147,11 @@ export const addDidWebRoutes = async ( ) if (revocationDefinitionRecord) { - res.send({ - resource: revocationDefinitionRecord.revocationRegistryDefinition, + res.send({ + resource: revocationDefinitionRecord.revocationRegistryDefinition, resourceMetadata: { - revocationStatusListEndpoint: `${anoncredsBaseUrl}/anoncreds/v1/revStatus/${revocationDefinitionId}` - } + statusListEndpoint: `${anoncredsBaseUrl}/anoncreds/v1/revStatus/${revocationDefinitionId}`, + }, }) return } @@ -159,7 +159,7 @@ export const addDidWebRoutes = async ( res.send(404) }) - app.get('/anoncreds/v1/revStatus/:revocationDefinitionId', async (req, res) => { + app.get('/anoncreds/v1/revStatus/:revocationDefinitionId/:timestamp?', async (req, res) => { const revocationDefinitionId = req.params.revocationDefinitionId agent.config.logger.debug(`revocate definition requested: ${revocationDefinitionId}`) @@ -175,12 +175,12 @@ export const addDidWebRoutes = async ( if (revocationDefinitionRecord) { const revStatusList = revocationDefinitionRecord.metadata.get('revStatusList') - res.send({ - resource: revStatusList, + res.send({ + resource: revStatusList, resourceMetadata: { - previousVersionId: "", - nextVersionId: "", - } + previousVersionId: '', + nextVersionId: '', + }, }) return } diff --git a/packages/model/src/messages/calls/CallOfferRequestMessage.ts b/packages/model/src/messages/calls/CallOfferRequestMessage.ts index c739912..9ba4401 100644 --- a/packages/model/src/messages/calls/CallOfferRequestMessage.ts +++ b/packages/model/src/messages/calls/CallOfferRequestMessage.ts @@ -1,5 +1,4 @@ -import { DateParser } from '@credo-ts/core/build/utils/transformers' -import { Expose, Transform } from 'class-transformer' +import { Expose } from 'class-transformer' import { IsOptional, IsString } from 'class-validator' import { BaseMessage, BaseMessageOptions } from '../BaseMessage'