Skip to content
Snippets Groups Projects
Commit deb60f01 authored by Boyan Tsolov's avatar Boyan Tsolov
Browse files

fix: return of oobproof based on the dto

parent e7c360d3
No related branches found
No related tags found
1 merge request!44Preparations for ui
Pipeline #66841 passed
......@@ -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;
},
......
......@@ -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.*"
......
......@@ -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) => {
......
......@@ -17,6 +17,9 @@ export class CredentialRecordDto extends BaseRecordDto {
@IsString()
connectionId?: string;
@IsString()
state: string;
@IsArray()
@ValidateNested({ each: true })
@Type(() => IssueCredentialAttributes)
......
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
......
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
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment