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"; ...@@ -4,6 +4,7 @@ import { ProducerService } from "@ocm-engine/nats";
import { MessagePattern, RpcException } from "@nestjs/microservices"; import { MessagePattern, RpcException } from "@nestjs/microservices";
import { import {
ProofReqDto, ProofReqDto,
IdReqDto,
CloudEventDto, CloudEventDto,
GatewayAcceptedResponseDto, GatewayAcceptedResponseDto,
makeEvent, makeEvent,
...@@ -20,7 +21,7 @@ export class AppController { ...@@ -20,7 +21,7 @@ export class AppController {
async create( async create(
@Body() @Body()
payload: { payload: {
data: null | ProofReqDto; data: null | ProofReqDto | IdReqDto;
type: ProofEvent; type: ProofEvent;
source: string; source: string;
}, },
......
...@@ -14,6 +14,9 @@ AGENT_IS_REST=false ...@@ -14,6 +14,9 @@ AGENT_IS_REST=false
AGENT_MAX_MESSAGES=10 AGENT_MAX_MESSAGES=10
AGENT_RETE_LIMIT=5 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_SERVERS=broker-holder:4222
NATS_STREAM_NAME=ssi_holder_stream NATS_STREAM_NAME=ssi_holder_stream
NATS_SUBJECTS="connections.*,proofs.*,credentials.*,schemas.*,messages.*" NATS_SUBJECTS="connections.*,proofs.*,credentials.*,schemas.*,messages.*"
......
...@@ -55,6 +55,7 @@ export class AgentService { ...@@ -55,6 +55,7 @@ export class AgentService {
const r = new ConnectionRecordDto(); const r = new ConnectionRecordDto();
r.connectionName = connectionRecord.theirLabel; r.connectionName = connectionRecord.theirLabel;
r.state = connectionRecord.state;
r.id = connectionRecord.id; r.id = connectionRecord.id;
r.did = connectionRecord.did; r.did = connectionRecord.did;
r.invitationDid = connectionRecord.invitationDid; r.invitationDid = connectionRecord.invitationDid;
...@@ -269,11 +270,14 @@ export class AgentService { ...@@ -269,11 +270,14 @@ export class AgentService {
const credentials = await this.askar.agent.credentials.findAllByQuery({ const credentials = await this.askar.agent.credentials.findAllByQuery({
state: CredentialState.Done, state: CredentialState.Done,
}); });
// REVIEW: get All credentials, or make the filter optional?
// const credentials = await this.askar.agent.credentials.getAll();
const response: Array<CredentialRecordDto> = []; const response: Array<CredentialRecordDto> = [];
for (const offer of credentials) { for (const offer of credentials) {
const t = new CredentialRecordDto(); const t = new CredentialRecordDto();
t.id = offer.id; t.id = offer.id;
t.state = offer.state;
t.connectionId = offer.connectionId; t.connectionId = offer.connectionId;
t.createdAt = offer.createdAt; t.createdAt = offer.createdAt;
t.attributes = offer.credentialAttributes; t.attributes = offer.credentialAttributes;
...@@ -341,7 +345,10 @@ export class AgentService { ...@@ -341,7 +345,10 @@ export class AgentService {
domain: this.askar.agentConfig.agentPeerAddress, domain: this.askar.agentConfig.agentPeerAddress,
}); });
return { proofUrl: invitationUrl }; return {
proofUrl: invitationUrl,
proofId: proofRecord.id
};
} }
console.log(`${issueProofDto.connectionId} detected, issuing proof`); console.log(`${issueProofDto.connectionId} detected, issuing proof`);
...@@ -406,12 +413,11 @@ export class AgentService { ...@@ -406,12 +413,11 @@ export class AgentService {
return proofResponse; return proofResponse;
}; };
acceptProof = async (acceptProofDto: ProofReqDto) => { acceptProof = async (acceptProofDto: ProofReqDto) => {
if (acceptProofDto.proofUrl) { if (acceptProofDto.proofUrl) {
return this.acceptOobProof(acceptProofDto.proofUrl); return this.acceptOobProof(acceptProofDto.proofUrl);
} }
// REVIEW: should the undefined case be covered inside acceptConnectionProof? return this.acceptConnectionProof(acceptProofDto.proofId);
return this.acceptConnectionProof(acceptProofDto.proofRecordId as string);
}; };
acceptOobProof = async (url: string) => { acceptOobProof = async (url: string) => {
...@@ -424,7 +430,7 @@ export class AgentService { ...@@ -424,7 +430,7 @@ export class AgentService {
const record = await waitForProofExchangeRecordSubject(this.askar.agentR, { const record = await waitForProofExchangeRecordSubject(this.askar.agentR, {
state: ProofState.RequestReceived, state: ProofState.RequestReceived,
}); });
const requestedCredentials = const requestedCredentials =
await this.askar.agent.proofs.selectCredentialsForRequest({ await this.askar.agent.proofs.selectCredentialsForRequest({
proofRecordId: record.id, proofRecordId: record.id,
...@@ -434,7 +440,7 @@ export class AgentService { ...@@ -434,7 +440,7 @@ export class AgentService {
proofRecordId: record.id, proofRecordId: record.id,
proofFormats: requestedCredentials.proofFormats, proofFormats: requestedCredentials.proofFormats,
}); });
const response = new ProofRecordDto(); const response = new ProofRecordDto();
response.id = acceptedRecord.id; response.id = acceptedRecord.id;
...@@ -442,7 +448,7 @@ export class AgentService { ...@@ -442,7 +448,7 @@ export class AgentService {
response.updatedAt = acceptedRecord.updatedAt; response.updatedAt = acceptedRecord.updatedAt;
response.createdAt = acceptedRecord.createdAt; response.createdAt = acceptedRecord.createdAt;
return acceptedRecord; return response;
}; };
acceptConnectionProof = async (proofRecordId: string) => { acceptConnectionProof = async (proofRecordId: string) => {
......
...@@ -17,6 +17,9 @@ export class CredentialRecordDto extends BaseRecordDto { ...@@ -17,6 +17,9 @@ export class CredentialRecordDto extends BaseRecordDto {
@IsString() @IsString()
connectionId?: string; connectionId?: string;
@IsString()
state: string;
@IsArray() @IsArray()
@ValidateNested({ each: true }) @ValidateNested({ each: true })
@Type(() => IssueCredentialAttributes) @Type(() => IssueCredentialAttributes)
......
import { IsNotEmpty, IsString, Matches } from "class-validator"; import { IsArray, IsNotEmpty, IsString, Matches, ValidateNested } from "class-validator";
export class CreateSchemaRequestDto { export class CreateSchemaRequestDto {
//@example "my test schema" //@example "my test schema"
...@@ -8,6 +8,9 @@ export class CreateSchemaRequestDto { ...@@ -8,6 +8,9 @@ export class CreateSchemaRequestDto {
//@example ['first_name, last_name'] //@example ['first_name, last_name']
@IsNotEmpty() @IsNotEmpty()
@IsArray()
@ValidateNested({ each: true })
@IsString()
attributes: string[]; attributes: string[];
//@example 1.0.2 //@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 { ...@@ -5,10 +5,10 @@ export class ProofReqDto {
@ValidateIf((o) => o.proofUrl === undefined, { always: true }) @ValidateIf((o) => o.proofUrl === undefined, { always: true })
@IsString() @IsString()
@IsNotEmpty() @IsNotEmpty()
proofRecordId: string | undefined; proofId: string;
@ValidateIf((o) => o.proofRecordId === undefined, { always: true }) @ValidateIf((o) => o.proofId === undefined, { always: true })
@IsString() @IsString()
@IsNotEmpty() @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