diff --git a/apps/proof-manager/src/app/app.controller.ts b/apps/proof-manager/src/app/app.controller.ts index c4d40fc0f483acb7d8011b2542b30222ee2a4f4f..4f44cc594aef10cfe3c619d4f8e2205e13ca1d55 100644 --- a/apps/proof-manager/src/app/app.controller.ts +++ b/apps/proof-manager/src/app/app.controller.ts @@ -4,6 +4,7 @@ import { ProducerService } from "@ocm-engine/nats"; import { MessagePattern, RpcException } from "@nestjs/microservices"; import { ProofReqDto, + IdReqDto, CloudEventDto, GatewayAcceptedResponseDto, makeEvent, @@ -20,7 +21,7 @@ export class AppController { async create( @Body() payload: { - data: null | ProofReqDto; + data: null | ProofReqDto | IdReqDto; type: ProofEvent; source: string; }, diff --git a/compose/env/holder.env b/compose/env/holder.env index 3b3a226cb653b0feab3f597f61109b3912b8de14..f45841eed3ca5cad003faf173bc6e566c8e61e38 100644 --- a/compose/env/holder.env +++ b/compose/env/holder.env @@ -14,6 +14,9 @@ AGENT_IS_REST=false AGENT_MAX_MESSAGES=10 AGENT_RETE_LIMIT=5 +AGENT_PEER_PORT=6001 +NATS_SUBJECTS="connections.,proofs.,credentials.,credentials.definition.,credentials.offer.,schemas.,messages.*" + NATS_SERVERS=broker-holder:4222 NATS_STREAM_NAME=ssi_holder_stream NATS_SUBJECTS="connections.*,proofs.*,credentials.*,schemas.*,messages.*" diff --git a/libs/askar/src/askar/agent.service.ts b/libs/askar/src/askar/agent.service.ts index a4622aa538b7c2a09f4fe533b6fc5bfd712209a7..45d007772670082d0357e14d9548448e7a78e957 100644 --- a/libs/askar/src/askar/agent.service.ts +++ b/libs/askar/src/askar/agent.service.ts @@ -55,6 +55,7 @@ export class AgentService { const r = new ConnectionRecordDto(); r.connectionName = connectionRecord.theirLabel; + r.state = connectionRecord.state; r.id = connectionRecord.id; r.did = connectionRecord.did; r.invitationDid = connectionRecord.invitationDid; @@ -269,11 +270,14 @@ export class AgentService { const credentials = await this.askar.agent.credentials.findAllByQuery({ state: CredentialState.Done, }); + // REVIEW: get All credentials, or make the filter optional? + // const credentials = await this.askar.agent.credentials.getAll(); const response: Array<CredentialRecordDto> = []; for (const offer of credentials) { const t = new CredentialRecordDto(); t.id = offer.id; + t.state = offer.state; t.connectionId = offer.connectionId; t.createdAt = offer.createdAt; t.attributes = offer.credentialAttributes; @@ -341,7 +345,10 @@ export class AgentService { domain: this.askar.agentConfig.agentPeerAddress, }); - return { proofUrl: invitationUrl }; + return { + proofUrl: invitationUrl, + proofId: proofRecord.id + }; } console.log(`${issueProofDto.connectionId} detected, issuing proof`); @@ -406,12 +413,11 @@ export class AgentService { return proofResponse; }; - acceptProof = async (acceptProofDto: ProofReqDto) => { + acceptProof = async (acceptProofDto: ProofReqDto) => { if (acceptProofDto.proofUrl) { return this.acceptOobProof(acceptProofDto.proofUrl); } - // REVIEW: should the undefined case be covered inside acceptConnectionProof? - return this.acceptConnectionProof(acceptProofDto.proofRecordId as string); + return this.acceptConnectionProof(acceptProofDto.proofId); }; acceptOobProof = async (url: string) => { @@ -424,7 +430,7 @@ export class AgentService { const record = await waitForProofExchangeRecordSubject(this.askar.agentR, { state: ProofState.RequestReceived, }); - + const requestedCredentials = await this.askar.agent.proofs.selectCredentialsForRequest({ proofRecordId: record.id, @@ -434,7 +440,7 @@ export class AgentService { proofRecordId: record.id, proofFormats: requestedCredentials.proofFormats, }); - + const response = new ProofRecordDto(); response.id = acceptedRecord.id; @@ -442,7 +448,7 @@ export class AgentService { response.updatedAt = acceptedRecord.updatedAt; response.createdAt = acceptedRecord.createdAt; - return acceptedRecord; + return response; }; acceptConnectionProof = async (proofRecordId: string) => { diff --git a/libs/dtos/src/dtos/generics/credential.record.dto.ts b/libs/dtos/src/dtos/generics/credential.record.dto.ts index f14aa33d3fc8e711506f77fa9fa7bbebc7d7cbb7..87cb703d2a4b515a71dc20aeff8902a9f83dccf6 100644 --- a/libs/dtos/src/dtos/generics/credential.record.dto.ts +++ b/libs/dtos/src/dtos/generics/credential.record.dto.ts @@ -17,6 +17,9 @@ export class CredentialRecordDto extends BaseRecordDto { @IsString() connectionId?: string; + @IsString() + state: string; + @IsArray() @ValidateNested({ each: true }) @Type(() => IssueCredentialAttributes) diff --git a/libs/dtos/src/dtos/requests/create.schema.request.dto.ts b/libs/dtos/src/dtos/requests/create.schema.request.dto.ts index 01d49ccdefddf83767d45a7e2de040ca7cd7d3e4..d782585588060f95513a023c43cbae0aa25d9ace 100644 --- a/libs/dtos/src/dtos/requests/create.schema.request.dto.ts +++ b/libs/dtos/src/dtos/requests/create.schema.request.dto.ts @@ -1,4 +1,4 @@ -import { IsNotEmpty, IsString, Matches } from "class-validator"; +import { IsArray, IsNotEmpty, IsString, Matches, ValidateNested } from "class-validator"; export class CreateSchemaRequestDto { //@example "my test schema" @@ -8,6 +8,9 @@ export class CreateSchemaRequestDto { //@example ['first_name, last_name'] @IsNotEmpty() + @IsArray() + @ValidateNested({ each: true }) + @IsString() attributes: string[]; //@example 1.0.2 diff --git a/libs/dtos/src/dtos/requests/credential.req.dto.ts b/libs/dtos/src/dtos/requests/credential.req.dto.ts new file mode 100644 index 0000000000000000000000000000000000000000..f94a268201126e6f8a18ff0a0ad68f80ba233bbe --- /dev/null +++ b/libs/dtos/src/dtos/requests/credential.req.dto.ts @@ -0,0 +1,9 @@ +import { IsNotEmpty, IsString } from "class-validator"; + + +export class CredentialReqDto { + //@example cf8395a5-9a53-4e06-8a5d-04e0fc00ca04 + @IsNotEmpty() + @IsString() + credentialRecordId: string; +} \ No newline at end of file diff --git a/libs/dtos/src/dtos/requests/proof.req.dto.ts b/libs/dtos/src/dtos/requests/proof.req.dto.ts index 8e995435c423e9b450bbab572ebc3a2a61eeb187..063d3b0b33e2dc6eb0db729f3406010974a3d41c 100644 --- a/libs/dtos/src/dtos/requests/proof.req.dto.ts +++ b/libs/dtos/src/dtos/requests/proof.req.dto.ts @@ -5,10 +5,10 @@ export class ProofReqDto { @ValidateIf((o) => o.proofUrl === undefined, { always: true }) @IsString() @IsNotEmpty() - proofRecordId: string | undefined; + proofId: string; - @ValidateIf((o) => o.proofRecordId === undefined, { always: true }) + @ValidateIf((o) => o.proofId === undefined, { always: true }) @IsString() @IsNotEmpty() - proofUrl: string | undefined; + proofUrl: string; } \ No newline at end of file