Skip to content
Snippets Groups Projects
Commit 60d80372 authored by Alexey Lunin's avatar Alexey Lunin
Browse files

core-dots refactoring

parent d4921a80
Branches core-dtos
No related tags found
1 merge request!43chore: abstract dtos to encompass a wider range of use cases and fix for out of band proof requests
Pipeline #67440 passed with stage
in 1 minute and 58 seconds
Showing
with 343 additions and 251 deletions
{"openapi":"3.0.0","paths":{"/api/v1/invitation":{"post":{"operationId":"RestController_createInvitation","parameters":[],"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateInvitationResponseDto"}}}}}}},"/api/v1/invitation/accept":{"post":{"operationId":"RestController_acceptInvitation","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateInvitationResponseDto"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AcceptInvitationResponseDto"}}}}}}},"/api/v1/connections":{"get":{"operationId":"RestController_connections","parameters":[],"responses":{"200":{"description":""}}}},"/api/v1/schema":{"post":{"operationId":"RestController_createSchema","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateSchemaRequestDto"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateSchemaResponseDto"}}}}}}},"/api/v1/credential/definition":{"post":{"operationId":"RestController_createCredentialDefinition","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateCredentialDefinitionRequsetDto"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateCredentialDefinitionResponseDto"}}}}}}},"/api/v1/credential/issue":{"post":{"operationId":"RestController_issueCredential","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/IssueCredentialRequestDto"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IssueCredentialResponseDto"}}}}}}},"/api/v1/credentials":{"get":{"operationId":"RestController_credentials","parameters":[],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/IssueCredentialResponseDto"}}}}}}}},"/api/v1/credential/offers":{"get":{"operationId":"RestController_getCredentialOffers","parameters":[],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/IssueCredentialResponseDto"}}}}}}}},"/api/v1/credential/{credential_record_id}/accept":{"post":{"operationId":"RestController_acceptCredential","parameters":[{"name":"credential_record_id","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IssueCredentialResponseDto"}}}}}}},"/api/v1/credential/proof":{"get":{"operationId":"RestController_proofs","parameters":[],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/IssueProofResponseDto"}}}}}}}},"/api/v1/credential/proof/issue":{"post":{"operationId":"RestController_issueProof","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/IssueProofRequestDto"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IssueProofResponseDto"}}}}}}},"/api/v1/credential/proof/{proof_record_id}/accept":{"post":{"operationId":"RestController_acceptProof","parameters":[{"name":"proof_record_id","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IssueProofResponseDto"}}}}}}},"/api/v1/resolve":{"post":{"operationId":"RestController_resolve","parameters":[],"responses":{"201":{"description":"","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/api/v1/messages":{"post":{"operationId":"RestController_sendMeesage","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MakeBasicMessageRequestDto"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MakeBasicMessageResponseDto"}}}}}}}},"info":{"title":"Agent","description":"Agent API","version":"1.0","contact":{}},"tags":[],"servers":[],"components":{"schemas":{"CreateInvitationResponseDto":{"type":"object","properties":{"invitationUrl":{"type":"string","description":"A list of user's roles","example":"http://0.0.0.0:8001?oob=eyJAdHlwZSI6Imh0dHBzOi8vZGlkY29tbS5vcmcvb3V0LW9mLWJhbmQvMS4xL2ludml0YXRpb24iLCJAaWQiOiIzYWExNGIzNC04YTk5LTQxY2UtYTY3NC1jODUxYmVhMTIxMWEiLCJsYWJlbCI6IkRFeGNWYXNkX0FHRU5UXzQ1IiwiYWNjZXB0IjpbImRpZGNvbW0vYWlwMSIsImRpZGNvbW0vYWlwMjtlbnY9cmZjMTkiXSwiaGFuZHNoYWtlX3Byb3RvY29scyI6WyJodHRwczovL2RpZGNvbW0ub3JnL2RpZGV4Y2hhbmdlLzEuMCIsImh0dHBzOi8vZGlkY29tbS5vcmcvY29ubmVjdGlvbnMvMS4wIl0sInNlcnZpY2VzIjpbeyJpZCI6IiNpbmxpbmUtMCIsInNlcnZpY2VFbmRwb2ludCI6Imh0dHA6Ly8wLjAuMC4wOjgwMDEiLCJ0eXBlIjoiZGlkLWNvbW11bmljYXRpb24iLCJyZWNpcGllbnRLZXlzIjpbImRpZDprZXk6ejZNa3VFcHllc1pNa3k0a1BpQzhEOEplZERlcm55YTFuaTREMUF3ZmdnWWt6YmR4Il0sInJvdXRpbmdLZXlzIjpbXX1dfQ"}},"required":["invitationUrl"]},"AcceptInvitationResponseDto":{"type":"object","properties":{"connectionId":{"type":"string"},"connectionName":{"type":"string"},"did":{"type":"string"},"invitationDid":{"type":"string"},"outOfBandId":{"type":"string"},"createdAt":{"format":"date-time","type":"string"}},"required":["connectionId","createdAt"]},"CreateSchemaRequestDto":{"type":"object","properties":{"name":{"type":"string","example":"my test schema"},"attributes":{"example":["first_name, last_name"],"type":"array","items":{"type":"string"}},"version":{"type":"string","example":"1.0.2","pattern":"/^(\\d+\\.)?(\\d+\\.)?(\\*|\\d+)$/"}},"required":["name","attributes","version"]},"CreateSchemaResponseDto":{"type":"object","properties":{"schemaId":{"type":"string"},"issuerId":{"type":"string"},"name":{"type":"string"},"version":{"type":"string"},"attributes":{"type":"array","items":{"type":"string"}}},"required":["schemaId","issuerId","name","version","attributes"]},"CreateCredentialDefinitionRequsetDto":{"type":"object","properties":{"schemaId":{"type":"string"},"tag":{"type":"string"}},"required":["schemaId","tag"]},"CreateCredentialDefinitionResponseDto":{"type":"object","properties":{"credentialDefinitionId":{"type":"string"},"schemaId":{"type":"string"},"isserId":{"type":"string"},"tag":{"type":"string"}},"required":["credentialDefinitionId","schemaId","isserId","tag"]},"IssueCredentialAttributes":{"type":"object","properties":{"name":{"type":"string"},"value":{"type":"string"}},"required":["name","value"]},"IssueCredentialRequestDto":{"type":"object","properties":{"connectionId":{"type":"string","example":"6464b521-005a-4379-91e0-a3692b31cafd"},"credentialDefinitionId":{"type":"string"},"attributes":{"type":"array","items":{"$ref":"#/components/schemas/IssueCredentialAttributes"}}},"required":["connectionId","credentialDefinitionId","attributes"]},"Credential":{"type":"object","properties":{"credentialRecordType":{"type":"string"},"credentialRecordId":{"type":"string"}},"required":["credentialRecordType","credentialRecordId"]},"IssueCredentialResponseDto":{"type":"object","properties":{"credentials":{"type":"array","items":{"$ref":"#/components/schemas/Credential"}},"credentialId":{"type":"string"},"connectionId":{"type":"string"},"attributes":{"type":"array","items":{"$ref":"#/components/schemas/IssueCredentialAttributes"}},"createdAt":{"format":"date-time","type":"string"}},"required":["credentialId","createdAt"]},"IssueProofResponseDto":{"type":"object","properties":{"proofId":{"type":"string"},"connectionId":{"type":"string","example":"6464b521-005a-4379-91e0-a3692b31cafd"},"state":{"type":"string"},"updatedAt":{"format":"date-time","type":"string"},"createdAt":{"format":"date-time","type":"string"}},"required":["proofId","state","createdAt"]},"IssueProofAttribute":{"type":"object","properties":{"attributeName":{"type":"string"},"credentialDefinitionId":{"type":"string"},"schemaId":{"type":"string"}},"required":["attributeName","credentialDefinitionId","schemaId"]},"IssueProofRequestDto":{"type":"object","properties":{"connectionId":{"type":"string","example":"6464b521-005a-4379-91e0-a3692b31cafd"},"attributes":{"type":"array","items":{"$ref":"#/components/schemas/IssueProofAttribute"}}},"required":["attributes"]},"MakeBasicMessageRequestDto":{"type":"object","properties":{"connectionId":{"type":"string","example":"6464b521-005a-4379-91e0-a3692b31cafd"},"message":{"type":"string","example":"hello world"}},"required":["connectionId","message"]},"MakeBasicMessageResponseDto":{"type":"object","properties":{"id":{"type":"string"},"connectionId":{"type":"string","example":"6464b521-005a-4379-91e0-a3692b31cafd"},"from":{"type":"string","example":"example-ocm-name"},"to":{"type":"string","example":"example-ocm-name"},"message":{"type":"string","example":"hello world"}},"required":["id","connectionId","message"]}}}}
\ No newline at end of file
{"openapi":"3.0.0","paths":{"/api/v1/invitation":{"post":{"operationId":"RestController_createInvitation","parameters":[],"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateInvitationResponseDto"}}}}}}},"/api/v1/invitation/accept":{"post":{"operationId":"RestController_acceptInvitation","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateInvitationResponseDto"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectionRecordDto"}}}}}}},"/api/v1/connections":{"get":{"operationId":"RestController_connections","parameters":[],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/ConnectionRecordDto"}}}}}}}},"/api/v1/schema":{"post":{"operationId":"RestController_createSchema","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateSchemaRequestDto"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SchemaRecordDto"}}}}}}},"/api/v1/credential/definition":{"post":{"operationId":"RestController_createCredentialDefinition","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateCredentialDefinitionRequsetDto"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreddefRecordDto"}}}}}}},"/api/v1/credential/issue":{"post":{"operationId":"RestController_issueCredential","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/IssueCredentialRequestDto"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CredentialRecordDto"}}}}}}},"/api/v1/credentials":{"get":{"operationId":"RestController_credentials","parameters":[],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/CredentialRecordDto"}}}}}}}},"/api/v1/credential/offers":{"get":{"operationId":"RestController_getCredentialOffers","parameters":[],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/CredentialRecordDto"}}}}}}}},"/api/v1/credential/{credential_record_id}/accept":{"post":{"operationId":"RestController_acceptCredential","parameters":[{"name":"credential_record_id","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CredentialRecordDto"}}}}}}},"/api/v1/credential/proof":{"get":{"operationId":"RestController_proofs","parameters":[],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/ProofRecordDto"}}}}}}}},"/api/v1/credential/proof/issue":{"post":{"operationId":"RestController_issueProof","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/IssueProofRequestDto"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/api/v1/credential/proof/{proof_record_id}":{"get":{"operationId":"RestController_getProof","parameters":[{"required":true,"name":"id","in":"query","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/api/v1/credential/c/proof/accept":{"post":{"operationId":"RestController_acceptProof","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProofReqDto"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProofRecordDto"}}}}}}},"/api/v1/credential/proof/{proof_record_id}/decline":{"post":{"operationId":"RestController_declineProofRequest","parameters":[{"name":"proof_record_id","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProofRecordDto"}}}}}}},"/api/v1/resolve":{"post":{"operationId":"RestController_resolve","parameters":[],"responses":{"201":{"description":"","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/api/v1/messages":{"post":{"operationId":"RestController_sendMeesage","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MakeBasicMessageRequestDto"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageRecordDto"}}}}}}}},"info":{"title":"Agent","description":"Agent API","version":"1.0","contact":{}},"tags":[],"servers":[],"components":{"schemas":{"CreateInvitationResponseDto":{"type":"object","properties":{"invitationUrl":{"type":"string","description":"Example of long invitation url","example":"http://0.0.0.0:8001?oob=eyJAdHlwZSI6Imh0dHBzOi8vZGlkY29tbS5vcmcvb3V0LW9mLWJhbmQvMS4xL2ludml0YXRpb24iLCJAaWQiOiIzYWExNGIzNC04YTk5LTQxY2UtYTY3NC1jODUxYmVhMTIxMWEiLCJsYWJlbCI6IkRFeGNWYXNkX0FHRU5UXzQ1IiwiYWNjZXB0IjpbImRpZGNvbW0vYWlwMSIsImRpZGNvbW0vYWlwMjtlbnY9cmZjMTkiXSwiaGFuZHNoYWtlX3Byb3RvY29scyI6WyJodHRwczovL2RpZGNvbW0ub3JnL2RpZGV4Y2hhbmdlLzEuMCIsImh0dHBzOi8vZGlkY29tbS5vcmcvY29ubmVjdGlvbnMvMS4wIl0sInNlcnZpY2VzIjpbeyJpZCI6IiNpbmxpbmUtMCIsInNlcnZpY2VFbmRwb2ludCI6Imh0dHA6Ly8wLjAuMC4wOjgwMDEiLCJ0eXBlIjoiZGlkLWNvbW11bmljYXRpb24iLCJyZWNpcGllbnRLZXlzIjpbImRpZDprZXk6ejZNa3VFcHllc1pNa3k0a1BpQzhEOEplZERlcm55YTFuaTREMUF3ZmdnWWt6YmR4Il0sInJvdXRpbmdLZXlzIjpbXX1dfQ"},"shortInvitationUrl":{"type":"string","example":"http://0.0.0.0:8001/invitations/85a7c179-122b-4d2d-9a86-d92ad31cef2b"}},"required":["invitationUrl","shortInvitationUrl"]},"ConnectionRecordDto":{"type":"object","properties":{"state":{"type":"string"},"connectionName":{"type":"string"},"alias":{"type":"string"},"did":{"type":"string"},"invitationDid":{"type":"string"},"outOfBandId":{"type":"string"},"id":{"type":"string"},"createdAt":{"format":"date-time","type":"string"},"updatedAt":{"format":"date-time","type":"string"}},"required":["state","id","createdAt"]},"CreateSchemaRequestDto":{"type":"object","properties":{"name":{"type":"string","example":"my test schema"},"attributes":{"example":["first_name, last_name"],"type":"array","items":{"type":"string"}},"version":{"type":"string","example":"1.0.2","pattern":"/^(\\d+\\.)?(\\d+\\.)?(\\*|\\d+)$/"}},"required":["name","attributes","version"]},"SchemaRecordDto":{"type":"object","properties":{"name":{"type":"string"},"attributes":{"type":"array","items":{"type":"string"}},"version":{"type":"string"},"issuerId":{"type":"string"},"methodName":{"type":"string"},"id":{"type":"string"},"createdAt":{"format":"date-time","type":"string"},"updatedAt":{"format":"date-time","type":"string"}},"required":["name","attributes","version","id","createdAt"]},"CreateCredentialDefinitionRequsetDto":{"type":"object","properties":{"schemaId":{"type":"string"},"tag":{"type":"string"}},"required":["schemaId","tag"]},"CreddefRecordDto":{"type":"object","properties":{"schemaId":{"type":"string"},"issuerId":{"type":"string"},"tag":{"type":"string"},"id":{"type":"string"},"createdAt":{"format":"date-time","type":"string"},"updatedAt":{"format":"date-time","type":"string"}},"required":["schemaId","issuerId","tag","id","createdAt"]},"IssueCredentialAttributes":{"type":"object","properties":{"name":{"type":"string"},"value":{"type":"string"}},"required":["name","value"]},"IssueCredentialRequestDto":{"type":"object","properties":{"connectionId":{"type":"string","example":"6464b521-005a-4379-91e0-a3692b31cafd"},"credentialDefinitionId":{"type":"string"},"attributes":{"type":"array","items":{"$ref":"#/components/schemas/IssueCredentialAttributes"}}},"required":["connectionId","credentialDefinitionId","attributes"]},"CredentialRecordDto":{"type":"object","properties":{"credentialRecordType":{"type":"string"},"connectionId":{"type":"string"},"state":{"type":"string"},"attributes":{"type":"array","items":{"$ref":"#/components/schemas/IssueCredentialAttributes"}},"id":{"type":"string"},"createdAt":{"format":"date-time","type":"string"},"updatedAt":{"format":"date-time","type":"string"}},"required":["credentialRecordType","state","id","createdAt"]},"ProofRecordDto":{"type":"object","properties":{"connectionId":{"type":"string"},"state":{"type":"string"},"id":{"type":"string"},"createdAt":{"format":"date-time","type":"string"},"updatedAt":{"format":"date-time","type":"string"}},"required":["state","id","createdAt"]},"IssueProofAttribute":{"type":"object","properties":{"attributeName":{"type":"string"},"credentialDefinitionId":{"type":"string"},"schemaId":{"type":"string"}},"required":["attributeName","credentialDefinitionId","schemaId"]},"IssueProofRequestDto":{"type":"object","properties":{"connectionId":{"type":"string","example":"6464b521-005a-4379-91e0-a3692b31cafd"},"attributes":{"type":"array","items":{"$ref":"#/components/schemas/IssueProofAttribute"}}},"required":["attributes"]},"ProofReqDto":{"type":"object","properties":{"proofId":{"type":"string"},"proofUrl":{"type":"string"}},"required":["proofId","proofUrl"]},"MakeBasicMessageRequestDto":{"type":"object","properties":{"connectionId":{"type":"string","example":"6464b521-005a-4379-91e0-a3692b31cafd"},"message":{"type":"string","example":"hello world"}},"required":["connectionId","message"]},"MessageRecordDto":{"type":"object","properties":{"connectionId":{"type":"string","example":"6464b521-005a-4379-91e0-a3692b31cafd"},"from":{"type":"string","example":"example-ocm-name"},"to":{"type":"string","example":"example-ocm-name"},"message":{"type":"string","example":"hello world"},"id":{"type":"string"},"createdAt":{"format":"date-time","type":"string"},"updatedAt":{"format":"date-time","type":"string"}},"required":["connectionId","message","id","createdAt"]}}}}
\ No newline at end of file
......@@ -7,8 +7,8 @@ import {
ConnectionEvent,
CreateInvitationResponseDto,
GatewayAcceptedResponseDto,
GetConnectionRequestDto,
makeEvent,
IdReqDto,
} from "@ocm-engine/dtos";
@Controller()
......@@ -21,7 +21,7 @@ export class AppController {
async create(
@Body()
payload: {
data: null | CreateInvitationResponseDto | GetConnectionRequestDto;
data: null | CreateInvitationResponseDto | IdReqDto;
type: ConnectionEvent;
source: string;
},
......
......@@ -2,7 +2,6 @@ import { Body, Controller, Get, Param, Post, UseFilters } from "@nestjs/common";
import { AllExceptionsHandler } from "../exception.handler";
import { AttestationManagerClient } from "@ocm-engine/clients";
import {
AcceptCredentialOfferRequestDto,
CreateCredentialDefinitionRequsetDto,
CreateSchemaRequestDto,
CRED_DEF_CREATE,
......@@ -11,13 +10,13 @@ import {
CRED_OFFER_ACCEPT,
CRED_OFFER_LIST,
GatewayAcceptedResponseDto,
GetSchemaRequestDto,
IssueCredentialRequestDto,
MakeBasicMessageRequestDto,
MESSAGE_MAKE,
SCHEMA_CREATE,
SCHEMA_GET,
SCHEMA_LIST,
IdReqDto,
} from "@ocm-engine/dtos";
import {
ApiBadRequestResponse,
......@@ -165,8 +164,8 @@ export class AttestationController {
"Method will fetch specific schema or return null. The id of the response will be matched when you receive event from the websocket",
tags: ["Schema"],
})
async getSchemaById(@Body() schemaRequestDto: GetSchemaRequestDto) {
return this.amClient.sendPayload<GetSchemaRequestDto>({
async getSchemaById(@Body() schemaRequestDto: IdReqDto) {
return this.amClient.sendPayload<IdReqDto>({
pattern: "schemas",
payload: {
source: "/schemas-by-id",
......@@ -504,8 +503,8 @@ export class AttestationController {
tags: ["Credentials Offers"],
})
acceptCredential(@Param("credential_record_id") credentialRecordId: string) {
const data = new AcceptCredentialOfferRequestDto();
data.credentialRecordId = credentialRecordId;
const data = new IdReqDto();
data.id = credentialRecordId;
return this.amClient.sendPayload({
pattern: "credentials",
payload: {
......
......@@ -15,7 +15,7 @@ import {
CONNECTION_LIST,
CreateInvitationResponseDto,
GatewayAcceptedResponseDto,
GetConnectionRequestDto,
IdReqDto,
} from "@ocm-engine/dtos";
import { AllExceptionsHandler } from "../exception.handler";
import {
......@@ -238,10 +238,10 @@ export class ConnectionController {
tags: ["Connections"],
})
async getById(@Param("id") id: string) {
const request = new GetConnectionRequestDto();
request.connectionId = id;
const request = new IdReqDto();
request.id = id;
return this.cmClient.sendPayload<GetConnectionRequestDto>({
return this.cmClient.sendPayload<IdReqDto>({
pattern: "connections",
payload: {
source: "/connections/:id",
......
import { Body, Controller, Get, Param, Post, UseFilters } from "@nestjs/common";
import {
AcceptProofRequestDto,
DeclineProofRequestDto,
ProofReqDto,
GatewayAcceptedResponseDto,
GetProofRequestDto,
GetSchemaRequestDto,
IssueProofRequestDto,
PROOF_ACCEPT,
PROOF_DECLINE,
PROOF_GET,
PROOF_ISSUE,
PROOF_LIST,
IdReqDto,
} from "@ocm-engine/dtos";
import { AllExceptionsHandler } from "../exception.handler";
import { ProofManagerClient } from "@ocm-engine/clients";
......@@ -62,7 +60,7 @@ export class ProofController {
tags: ["Credentials Proof"],
})
proofs() {
return this.pmClient.sendPayload<GetSchemaRequestDto>({
return this.pmClient.sendPayload<IdReqDto>({
pattern: "proofs",
payload: {
source: "/credential/proofs",
......@@ -108,10 +106,10 @@ export class ProofController {
tags: ["Credentials Proof"],
})
getProofById(@Param("proof_record_id") proofRecordId: string) {
const data = new GetProofRequestDto();
data.proofRecordId = proofRecordId;
const data = new IdReqDto();
data.id = proofRecordId;
return this.pmClient.sendPayload<GetProofRequestDto>({
return this.pmClient.sendPayload<IdReqDto>({
pattern: "proofs",
payload: {
source: "/credentials/proof/:proof_record_id",
......@@ -230,8 +228,8 @@ export class ProofController {
"Method accept credential proof. The id of the response will be matched when you receive event from the websocket",
tags: ["Credentials Proof"],
})
acceptProof(@Body() acceptProofRequestDto: AcceptProofRequestDto) {
return this.pmClient.sendPayload<AcceptProofRequestDto>({
acceptProof(@Body() acceptProofRequestDto: ProofReqDto) {
return this.pmClient.sendPayload<ProofReqDto>({
pattern: "proofs",
payload: {
source: "/credentials/proofs/accept",
......@@ -277,10 +275,10 @@ export class ProofController {
tags: ["Credentials Proof"],
})
declineProofRequest(@Param("proof_record_id") proofRecordId: string) {
const data = new DeclineProofRequestDto();
data.proofRecordId = proofRecordId;
const data = new IdReqDto();
data.id = proofRecordId;
return this.pmClient.sendPayload<DeclineProofRequestDto>({
return this.pmClient.sendPayload<IdReqDto>({
pattern: "proofs",
payload: {
source: "/credentials/proof/:proof_record_id/decline",
......
......@@ -17,6 +17,7 @@ import * as fs from "fs";
async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.enableCors();
app.useWebSocketAdapter(new WsAdapter(app));
const configService = app.get(ConfigService);
......
......@@ -3,7 +3,8 @@ import { Body, Controller, Logger } from "@nestjs/common";
import { ProducerService } from "@ocm-engine/nats";
import { MessagePattern, RpcException } from "@nestjs/microservices";
import {
AcceptProofRequestDto,
ProofReqDto,
IdReqDto,
CloudEventDto,
GatewayAcceptedResponseDto,
makeEvent,
......@@ -20,7 +21,7 @@ export class AppController {
async create(
@Body()
payload: {
data: null | AcceptProofRequestDto;
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.*"
......
......@@ -50,7 +50,7 @@ import {
lastValueFrom,
map,
Observable,
ReplaySubject,
BehaviorSubject,
Subject,
take,
timeout,
......@@ -58,7 +58,7 @@ import {
import { SubjectInboundTransport } from "./askar/transports/agent.subject.inbound.transport";
import { SubjectOutboundTransport } from "./askar/transports/agent.subject.outbound.transport";
export type EventReplaySubject = ReplaySubject<BaseEvent>;
export type EventBehaviorSubject = BehaviorSubject<BaseEvent>;
export type SubjectMessage = {
message: EncryptedMessage;
replySubject?: Subject<SubjectMessage>;
......@@ -171,23 +171,31 @@ export const getAskarAnonCredsIndyModules = (networks: any) => {
} as const;
};
export const setupEventReplaySubjects = (
const INITIAL_EVENT: BaseEvent = {
type: "unknown",
payload: {},
metadata: {
contextCorrelationId: "-1",
},
};
export const setupEventBehaviorSubjects = (
agents: Agent[],
eventTypes: string[],
): ReplaySubject<BaseEvent>[] => {
const replaySubjects: EventReplaySubject[] = [];
): BehaviorSubject<BaseEvent>[] => {
const behaviorSubjects: EventBehaviorSubject[] = [];
for (const agent of agents) {
const replaySubject = new ReplaySubject<BaseEvent>();
const behaviorSubject = new BehaviorSubject<BaseEvent>(INITIAL_EVENT);
for (const eventType of eventTypes) {
agent.events.observable(eventType).subscribe(replaySubject);
agent.events.observable(eventType).subscribe(behaviorSubject);
}
replaySubjects.push(replaySubject);
behaviorSubjects.push(behaviorSubject);
}
return replaySubjects;
return behaviorSubjects;
};
export const setupSubjectTransports = (agents: Agent[]) => {
......@@ -335,7 +343,7 @@ export const isProofStateChangedEvent = (
): e is ProofStateChangedEvent => e.type === ProofEventTypes.ProofStateChanged;
export const waitForProofExchangeRecordSubject = (
subject: ReplaySubject<BaseEvent> | Observable<BaseEvent>,
subject: BehaviorSubject<BaseEvent> | Observable<BaseEvent>,
{
threadId,
parentThreadId,
......@@ -353,7 +361,7 @@ export const waitForProofExchangeRecordSubject = (
},
) => {
const observable: Observable<BaseEvent> =
subject instanceof ReplaySubject ? subject.asObservable() : subject;
subject instanceof BehaviorSubject ? subject.asObservable() : subject;
return lastValueFrom(
observable.pipe(
filter(isProofStateChangedEvent),
......
import { Injectable, Logger } from "@nestjs/common";
import { AgentService } from "../askar/agent.service";
import {
AcceptCredentialOfferRequestDto,
AcceptProofRequestDto,
ProofReqDto,
CloudEventDto,
CONNECTION_ACCEPT,
CONNECTION_CREATE,
......@@ -16,12 +15,9 @@ import {
CRED_LIST,
CRED_OFFER_ACCEPT,
CRED_OFFER_LIST,
GetConnectionRequestDto,
GetSchemaRequestDto,
IssueCredentialRequestDto,
IssueProofRequestDto,
MakeBasicMessageRequestDto,
DeclineProofRequestDto,
MESSAGE_MAKE,
PROOF_ACCEPT,
PROOF_ISSUE,
......@@ -30,10 +26,9 @@ import {
SCHEMA_CREATE,
SCHEMA_GET,
SCHEMA_LIST,
GetProofRequestDto,
PROOF_DECLINE,
IdReqDto,
} from "@ocm-engine/dtos";
import asyncRetry from "async-retry";
@Injectable()
export class EventHandlerService {
......@@ -44,105 +39,89 @@ export class EventHandlerService {
async handle<T>(event: CloudEventDto<T>) {
let data;
let dto;
await asyncRetry(
async () => {
switch (event.type) {
case CONNECTION_CREATE:
data = await this.agentService.createInvitation();
break;
case CONNECTION_ACCEPT:
dto = event.data as CreateInvitationResponseDto;
data = await this.agentService.acceptInvitation(dto.invitationUrl);
break;
case CONNECTION_LIST:
data = await this.agentService.fetchConnections();
break;
case CONNECTION_GET:
dto = event.data as GetConnectionRequestDto;
data = await this.agentService.getConnectionById(dto.connectionId);
break;
case SCHEMA_CREATE:
dto = event.data as CreateSchemaRequestDto;
data = await this.agentService.createSchema(dto);
break;
case SCHEMA_LIST:
data = await this.agentService.fetchSchemas();
break;
case SCHEMA_GET:
dto = event.data as GetSchemaRequestDto;
data = await this.agentService.getSchemaById(dto.schemaId);
break;
case CRED_DEF_CREATE:
data = await this.agentService.createCredentialDefinition(
event.data as CreateCredentialDefinitionRequsetDto,
);
break;
case CRED_ISSUE:
data = await this.agentService.issueCredential(
event.data as IssueCredentialRequestDto,
);
break;
case CRED_LIST:
data = await this.agentService.credentials();
break;
case CRED_OFFER_LIST:
data = await this.agentService.credentialByStatedOfferReceived();
break;
case CRED_OFFER_ACCEPT:
dto = event.data as AcceptCredentialOfferRequestDto;
data = await this.agentService.acceptCredential(
dto.credentialRecordId,
);
break;
case PROOF_ISSUE:
dto = event.data as IssueProofRequestDto;
data = await this.agentService.issueProof(dto);
break;
case PROOF_LIST:
data = await this.agentService.proofs();
break;
case PROOF_GET:
dto = event.data as GetProofRequestDto;
data = await this.agentService.getProofById(dto.proofRecordId);
break;
case PROOF_ACCEPT:
data = await this.agentService.acceptProof(
event.data as AcceptProofRequestDto,
);
break;
case PROOF_DECLINE:
dto = event.data as DeclineProofRequestDto;
data = await this.agentService.declineProofRequest(
dto.proofRecordId,
);
break;
case MESSAGE_MAKE:
dto = event.data as MakeBasicMessageRequestDto;
data = await this.agentService.sendMessage(dto);
break;
}
},
{
retries: 5,
onRetry: (error: unknown) => {
this.logger.log(JSON.stringify(error, null, 2));
},
},
);
switch (event.type) {
case CONNECTION_CREATE:
data = await this.agentService.createInvitation();
break;
case CONNECTION_ACCEPT:
dto = event.data as CreateInvitationResponseDto;
data = await this.agentService.acceptInvitation(dto.invitationUrl);
break;
case CONNECTION_LIST:
data = await this.agentService.fetchConnections();
break;
case CONNECTION_GET:
dto = event.data as IdReqDto;
data = await this.agentService.getConnectionById(dto.id);
break;
case SCHEMA_CREATE:
dto = event.data as CreateSchemaRequestDto;
data = await this.agentService.createSchema(dto);
break;
case SCHEMA_LIST:
data = await this.agentService.fetchSchemas();
break;
case SCHEMA_GET:
dto = event.data as IdReqDto;
data = await this.agentService.getSchemaById(dto.id);
break;
case CRED_DEF_CREATE:
data = await this.agentService.createCredentialDefinition(
event.data as CreateCredentialDefinitionRequsetDto,
);
break;
case CRED_ISSUE:
data = await this.agentService.issueCredential(
event.data as IssueCredentialRequestDto,
);
break;
case CRED_LIST:
data = await this.agentService.credentials();
break;
case CRED_OFFER_LIST:
data = await this.agentService.credentialByStatedOfferReceived();
break;
case CRED_OFFER_ACCEPT:
dto = event.data as IdReqDto;
data = await this.agentService.acceptCredential(dto.id);
break;
case PROOF_ISSUE:
dto = event.data as IssueProofRequestDto;
data = await this.agentService.issueProof(dto);
break;
case PROOF_LIST:
data = await this.agentService.proofs();
break;
case PROOF_GET:
dto = event.data as IdReqDto;
data = await this.agentService.getProofById(dto.id);
break;
case PROOF_ACCEPT:
data = await this.agentService.acceptProof(event.data as ProofReqDto);
break;
case PROOF_DECLINE:
dto = event.data as IdReqDto;
data = await this.agentService.declineProofRequest(dto.id);
break;
case MESSAGE_MAKE:
dto = event.data as MakeBasicMessageRequestDto;
data = await this.agentService.sendMessage(dto);
break;
}
event.data = data;
return event;
......
......@@ -8,8 +8,8 @@ import {
IssueProofRequestDto,
CreateSchemaRequestDto,
MakeBasicMessageRequestDto,
AcceptProofRequestDto,
GetProofRequestDto,
ProofReqDto,
IdReqDto,
} from "@ocm-engine/dtos";
import { AllExceptionsHandler } from "./exception.handler";
......@@ -80,12 +80,12 @@ export class RestController {
}
@Get("credential/proof/:proof_record_id")
getProof(@Param("proof_record_id") data: GetProofRequestDto) {
return this.agentService.getProofById(data.proofRecordId);
getProof(@Param("proof_record_id") data: IdReqDto) {
return this.agentService.getProofById(data.id);
}
@Post(`/credential/proof/accept`)
acceptProof(@Body() acceptProofRequestDto: AcceptProofRequestDto) {
@Post(`/credential/c/proof/accept`)
acceptProof(@Body() acceptProofRequestDto: ProofReqDto) {
return this.agentService.acceptProof(acceptProofRequestDto);
}
......
......@@ -10,11 +10,7 @@ import {
ProofEventTypes,
ProofStateChangedEvent,
} from "@aries-framework/core";
import {
MakeBasicMessageResponseDto,
makeEvent,
MESSAGE_MAKE,
} from "@ocm-engine/dtos";
import { MessageRecordDto, makeEvent, MESSAGE_MAKE } from "@ocm-engine/dtos";
import { IConfAgent } from "@ocm-engine/config";
import { ConfigService } from "@nestjs/config";
import {
......@@ -76,7 +72,7 @@ export class AgentEventListenerService implements OnModuleInit {
ev.payload.basicMessageRecord.connectionId,
);
const dto = new MakeBasicMessageResponseDto();
const dto = new MessageRecordDto();
dto.message = ev.payload.basicMessageRecord.content;
dto.id = ev.payload.basicMessageRecord.id;
dto.connectionId = ev.payload.basicMessageRecord.connectionId;
......
import { Injectable } from "@nestjs/common";
import { AskarService } from "./askar.service";
import {
AcceptInvitationResponseDto,
AcceptProofRequestDto,
ConnectionRecordDto,
ProofReqDto,
ConnectionNotFoundError,
CreateCredentialDefinitionRequsetDto,
CreateCredentialDefinitionResponseDto,
CreddefRecordDto,
CreateInvitationResponseDto,
CreateSchemaRequestDto,
CreateSchemaResponseDto,
SchemaRecordDto,
CredentialNotCreatedError,
IssueCredentialRequestDto,
IssueCredentialResponseDto,
CredentialRecordDto,
IssueProofRequestDto,
IssueProofResponseDto,
GetProofByIdResponseDto,
ProofRecordDto,
MakeBasicMessageRequestDto,
MakeBasicMessageResponseDto,
MessageRecordDto,
SchemaNotCreatedError,
DeclineProofResponseDto,
SchemaNotFoundError,
} from "@ocm-engine/dtos";
import {
AutoAcceptProof,
CredentialState,
JsonEncoder,
ProofState,
} from "@aries-framework/core";
import { CredentialState, ProofState } from "@aries-framework/core";
import { AnonCredsRequestedAttribute } from "@aries-framework/anoncreds";
import { uuid } from "@aries-framework/core/build/utils/uuid";
import { waitForProofExchangeRecordSubject } from "../agent.utils";
......@@ -54,9 +48,10 @@ export class AgentService {
throw new ConnectionNotFoundError();
}
const r = new AcceptInvitationResponseDto();
const r = new ConnectionRecordDto();
r.connectionName = connectionRecord.theirLabel;
r.connectionId = connectionRecord.id;
r.state = connectionRecord.state;
r.id = connectionRecord.id;
r.did = connectionRecord.did;
r.invitationDid = connectionRecord.invitationDid;
r.outOfBandId = connectionRecord.outOfBandId;
......@@ -65,20 +60,90 @@ export class AgentService {
return r;
};
fetchConnections() {
return this.askar.agent.connections.getAll();
async fetchConnections() {
const agentResponse = await this.askar.agent.connections.getAll();
const connectionArray = agentResponse.map((singleConnectionRes) => {
const connectionResponse = new ConnectionRecordDto();
connectionResponse.id = singleConnectionRes.id;
connectionResponse.state = singleConnectionRes.state;
connectionResponse.connectionName = singleConnectionRes.theirLabel;
connectionResponse.alias = singleConnectionRes.alias;
connectionResponse.did = singleConnectionRes.did;
connectionResponse.invitationDid = singleConnectionRes.invitationDid;
connectionResponse.outOfBandId = singleConnectionRes.outOfBandId;
connectionResponse.createdAt = singleConnectionRes.createdAt;
return connectionResponse;
});
if (connectionArray.length < 1) {
throw new ConnectionNotFoundError();
}
return connectionArray;
}
getConnectionById = (id: string) => {
return this.askar.agent.connections.findById(id);
getConnectionById = async (id: string) => {
const agentResponse = await this.askar.agent.connections.findById(id);
if (!agentResponse) {
throw new ConnectionNotFoundError();
}
const connectionResponse = new ConnectionRecordDto();
connectionResponse.id = agentResponse.id;
connectionResponse.state = agentResponse.state;
connectionResponse.connectionName = agentResponse.theirLabel;
connectionResponse.alias = agentResponse.alias;
connectionResponse.did = agentResponse.did;
connectionResponse.invitationDid = agentResponse.invitationDid;
connectionResponse.outOfBandId = agentResponse.outOfBandId;
connectionResponse.createdAt = agentResponse.createdAt;
return connectionResponse;
};
fetchSchemas = () => {
return this.askar.agent.modules.anoncreds.getCreatedSchemas({});
fetchSchemas = async () => {
const agentResponse =
await this.askar.agent.modules.anoncreds.getCreatedSchemas({});
const schemaResponse = agentResponse.map((singleSchemaRes) => {
const schemaResponse = new SchemaRecordDto();
schemaResponse.id = singleSchemaRes.schemaId;
schemaResponse.name = singleSchemaRes.schema.name;
schemaResponse.attributes = singleSchemaRes.schema.attrNames;
schemaResponse.version = singleSchemaRes.schema.version;
schemaResponse.issuerId = singleSchemaRes.schema.issuerId;
schemaResponse.methodName = singleSchemaRes.methodName;
return schemaResponse;
});
if (schemaResponse.length < 1) {
throw new SchemaNotFoundError();
}
return schemaResponse;
};
getSchemaById = (schemaId: string) => {
return this.askar.agent.modules.anoncreds.getSchema(schemaId);
getSchemaById = async (schemaId: string) => {
const agentResponse = await this.askar.agent.modules.anoncreds.getSchema(
schemaId,
);
if (!agentResponse || !agentResponse.schema) {
throw new SchemaNotFoundError();
}
const schemaResponse = new SchemaRecordDto();
schemaResponse.id = agentResponse.schemaId;
schemaResponse.name = agentResponse.schema.name;
schemaResponse.attributes = agentResponse.schema.attrNames;
schemaResponse.version = agentResponse.schema.version;
schemaResponse.issuerId = agentResponse.schema.issuerId;
return schemaResponse;
};
createSchema = async (schema: CreateSchemaRequestDto) => {
......@@ -99,10 +164,10 @@ export class AgentService {
throw new SchemaNotCreatedError();
}
const response = new CreateSchemaResponseDto();
const response = new SchemaRecordDto();
response.name = schemaResult.schemaState.schema.name;
response.schemaId = schemaResult.schemaState.schemaId;
response.id = schemaResult.schemaState.schemaId;
response.issuerId = schemaResult.schemaState.schema.issuerId;
response.version = schemaResult.schemaState.schema.version;
response.attributes = schemaResult.schemaState.schema.attrNames;
......@@ -129,12 +194,11 @@ export class AgentService {
throw new CredentialNotCreatedError();
}
const response = new CreateCredentialDefinitionResponseDto();
response.credentialDefinitionId =
credDef.credentialDefinitionState.credentialDefinitionId;
const response = new CreddefRecordDto();
response.id = credDef.credentialDefinitionState.credentialDefinitionId;
response.schemaId =
credDef.credentialDefinitionState.credentialDefinition.schemaId;
response.isserId =
response.issuerId =
credDef.credentialDefinitionState.credentialDefinition.issuerId;
response.tag = credDef.credentialDefinitionState.credentialDefinition.tag;
......@@ -160,8 +224,8 @@ export class AgentService {
});
console.log(JSON.stringify(credentialExchangeRecord, null, 2));
const response = new IssueCredentialResponseDto();
response.credentialId = credentialExchangeRecord.id;
const response = new CredentialRecordDto();
response.id = credentialExchangeRecord.id;
response.connectionId = credentialExchangeRecord.connectionId;
response.attributes = credentialExchangeRecord.credentialAttributes;
response.createdAt = credentialExchangeRecord.createdAt;
......@@ -188,8 +252,8 @@ export class AgentService {
credentialRecordId,
});
const response = new IssueCredentialResponseDto();
response.credentialId = credentialExchangeRecord.id;
const response = new CredentialRecordDto();
response.id = credentialExchangeRecord.id;
response.connectionId = credentialExchangeRecord.connectionId;
response.attributes = credentialExchangeRecord.credentialAttributes;
response.createdAt = credentialExchangeRecord.createdAt;
......@@ -201,11 +265,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<IssueCredentialResponseDto> = [];
const response: Array<CredentialRecordDto> = [];
for (const offer of credentials) {
const t = new IssueCredentialResponseDto();
t.credentialId = offer.id;
const t = new CredentialRecordDto();
t.id = offer.id;
t.state = offer.state;
t.connectionId = offer.connectionId;
t.createdAt = offer.createdAt;
t.attributes = offer.credentialAttributes;
......@@ -220,10 +287,10 @@ export class AgentService {
state: CredentialState.OfferReceived,
});
const response: Array<IssueCredentialResponseDto> = [];
const response: Array<CredentialRecordDto> = [];
for (const offer of offers) {
const t = new IssueCredentialResponseDto();
t.credentialId = offer.id;
const t = new CredentialRecordDto();
t.id = offer.id;
t.connectionId = offer.connectionId;
t.createdAt = offer.createdAt;
t.attributes = offer.credentialAttributes;
......@@ -262,7 +329,6 @@ export class AgentService {
requested_attributes: requestedAttributes,
},
},
autoAcceptProof: AutoAcceptProof.ContentApproved,
});
console.log({ proofRecord });
......@@ -273,7 +339,9 @@ export class AgentService {
domain: this.askar.agentConfig.agentPeerAddress,
});
return { proofUrl: invitationUrl };
return {
proofUrl: invitationUrl,
};
}
console.log(`${issueProofDto.connectionId} detected, issuing proof`);
......@@ -290,8 +358,8 @@ export class AgentService {
},
});
const response = new IssueProofResponseDto();
response.proofId = exchangeRecord.id;
const response = new ProofRecordDto();
response.id = exchangeRecord.id;
response.connectionId = exchangeRecord.connectionId;
response.state = exchangeRecord.state;
response.updatedAt = exchangeRecord.updatedAt;
......@@ -305,10 +373,10 @@ export class AgentService {
state: ProofState.RequestReceived,
});
const response: Array<IssueProofResponseDto> = [];
const response: Array<ProofRecordDto> = [];
for (const proof of proofs) {
const t = new IssueProofResponseDto();
t.proofId = proof.id;
const t = new ProofRecordDto();
t.id = proof.id;
t.connectionId = proof.connectionId;
t.state = proof.state;
t.updatedAt = proof.updatedAt;
......@@ -327,9 +395,9 @@ export class AgentService {
return proofRecord;
}
const proofResponse = new GetProofByIdResponseDto();
const proofResponse = new ProofRecordDto();
proofResponse.proofId = proofRecord.id;
proofResponse.id = proofRecord.id;
proofResponse.connectionId = proofRecord.connectionId;
proofResponse.state = proofRecord.state;
proofResponse.updatedAt = proofRecord.updatedAt;
......@@ -338,7 +406,7 @@ export class AgentService {
return proofResponse;
};
acceptProof = async (acceptProofDto: AcceptProofRequestDto) => {
acceptProof = async (acceptProofDto: ProofReqDto) => {
if (acceptProofDto.proofUrl) {
return this.acceptOobProof(acceptProofDto.proofUrl);
}
......@@ -346,11 +414,11 @@ export class AgentService {
};
acceptOobProof = async (url: string) => {
const param = url.split("d_m=")[1];
const t = JsonEncoder.fromBase64(param);
await this.askar.agent.receiveMessage(t);
await this.askar.agent.oob.receiveInvitationFromUrl(url, {
autoAcceptConnection: false,
autoAcceptInvitation: true,
// reuseConnection: true,
});
const record = await waitForProofExchangeRecordSubject(this.askar.agentR, {
state: ProofState.RequestReceived,
......@@ -366,14 +434,14 @@ export class AgentService {
proofFormats: requestedCredentials.proofFormats,
});
const response = new IssueProofResponseDto();
const response = new ProofRecordDto();
response.proofId = acceptedRecord.id;
response.id = acceptedRecord.id;
response.state = acceptedRecord.state;
response.updatedAt = acceptedRecord.updatedAt;
response.createdAt = acceptedRecord.createdAt;
return acceptedRecord;
return response;
};
acceptConnectionProof = async (proofRecordId: string) => {
......@@ -392,8 +460,8 @@ export class AgentService {
console.log(JSON.stringify(proof, null, 2));
const response = new IssueProofResponseDto();
response.proofId = proof.id;
const response = new ProofRecordDto();
response.id = proof.id;
response.connectionId = proof.connectionId;
response.state = proof.state;
response.updatedAt = proof.updatedAt;
......@@ -408,8 +476,8 @@ export class AgentService {
// sendProblemReport: false, // REVIEW: do we have a use case for this key?
});
const declineResponse = new DeclineProofResponseDto();
declineResponse.proofId = resultFromDecline.id;
const declineResponse = new ProofRecordDto();
declineResponse.id = resultFromDecline.id;
declineResponse.connectionId = resultFromDecline.connectionId;
declineResponse.state = resultFromDecline.state;
declineResponse.updatedAt = resultFromDecline.updatedAt;
......@@ -423,7 +491,7 @@ export class AgentService {
};
sendMessage = async (message: MakeBasicMessageRequestDto) => {
const response = new MakeBasicMessageResponseDto();
const response = new MessageRecordDto();
const m = await this.askar.agent.basicMessages.sendMessage(
message.connectionId,
......@@ -433,7 +501,7 @@ export class AgentService {
const connectionInfo = await this.getConnectionById(message.connectionId);
response.connectionId = m.connectionId;
response.to = connectionInfo?.theirLabel || "";
response.to = connectionInfo?.connectionName || "";
response.id = m.id;
response.message = m.content;
......
......@@ -25,17 +25,17 @@ import {
getAskarAnonCredsIndyModules,
importDidsToWallet,
attachShortUrlHandler,
setupEventReplaySubjects,
setupEventBehaviorSubjects,
setupSubjectTransports,
} from "../agent.utils";
import { IConfAgent } from "@ocm-engine/config";
import { ReplaySubject } from "rxjs";
import { BehaviorSubject } from "rxjs";
import express from "express";
@Injectable()
export class AskarService implements OnModuleInit, OnModuleDestroy {
public agent: Agent<ReturnType<typeof getAskarAnonCredsIndyModules>>;
public agentR: ReplaySubject<BaseEvent>;
public agentR: BehaviorSubject<BaseEvent>;
public agentConfig: IConfAgent;
private readonly logger: Logger = new Logger(AskarService.name);
private readonly server = express();
......@@ -90,7 +90,7 @@ export class AskarService implements OnModuleInit, OnModuleDestroy {
setupSubjectTransports([this.agent]);
const [agentR] = setupEventReplaySubjects(
const [agentR] = setupEventBehaviorSubjects(
[this.agent],
[ProofEventTypes.ProofStateChanged],
);
......
import { IsDateString, IsNotEmpty, IsString } from "class-validator";
export class IssueProofResponseDto {
export class BaseRecordDto {
@IsString()
@IsNotEmpty()
proofId: string;
id: string;
//@example 6464b521-005a-4379-91e0-a3692b31cafd
@IsString()
connectionId?: string;
@IsString()
@IsDateString()
@IsNotEmpty()
state: string;
createdAt: Date;
@IsDateString()
updatedAt?: Date;
@IsNotEmpty()
@IsDateString()
createdAt: Date;
}
import { IsNotEmpty, IsString } from "class-validator";
import { BaseRecordDto } from "./base.record.dto";
export class ConnectionRecordDto extends BaseRecordDto {
@IsNotEmpty()
@IsString()
state: string;
@IsString()
connectionName?: string;
@IsString()
alias?: string;
@IsString()
did?: string;
@IsString()
invitationDid?: string;
@IsString()
outOfBandId?: string;
}
import { IsNotEmpty, IsString } from "class-validator";
import { BaseRecordDto } from "./base.record.dto";
export class CreateCredentialDefinitionResponseDto {
@IsNotEmpty()
@IsString()
credentialDefinitionId: string;
export class CreddefRecordDto extends BaseRecordDto {
@IsNotEmpty()
@IsString()
schemaId: string;
@IsNotEmpty()
@IsString()
isserId: string;
issuerId: string;
@IsNotEmpty()
@IsString()
......
import {
IsArray,
IsDateString,
IsNotEmpty,
IsString,
ValidateNested,
} from "class-validator";
import { IsArray, IsNotEmpty, IsString, ValidateNested } from "class-validator";
import { Type } from "class-transformer";
import { IssueCredentialAttributes } from "../requests/issue.credential.request.dto";
import { BaseRecordDto } from "./base.record.dto";
export class Credential {
export class CredentialRecordDto extends BaseRecordDto {
@IsNotEmpty()
@IsString()
credentialRecordType: string;
@IsNotEmpty()
@IsString()
credentialRecordId: string;
}
export class IssueCredentialResponseDto {
@IsArray()
@ValidateNested({ each: true })
@Type(() => Credential)
credentials?: Array<Credential>;
@IsNotEmpty()
@IsString()
credentialId: string;
connectionId?: string;
@IsString()
connectionId?: string;
state: string;
@IsArray()
@ValidateNested({ each: true })
@Type(() => IssueCredentialAttributes)
attributes?: Array<IssueCredentialAttributes>;
@IsNotEmpty()
@IsDateString()
createdAt: Date;
}
import { IsNotEmpty, IsString } from "class-validator";
import { BaseRecordDto } from "./base.record.dto";
export class MakeBasicMessageResponseDto {
@IsNotEmpty()
@IsString()
id: string;
export class MessageRecordDto extends BaseRecordDto {
// @example 6464b521-005a-4379-91e0-a3692b31cafd
@IsNotEmpty()
@IsString()
connectionId: string;
// @example "example-ocm-name"
@IsNotEmpty()
@IsString()
from?: string;
// @example "example-ocm-name"
@IsNotEmpty()
@IsString()
to?: string;
......
import { IsNotEmpty, IsString } from "class-validator";
import { BaseRecordDto } from "./base.record.dto";
export class ProofRecordDto extends BaseRecordDto {
@IsString()
connectionId?: string;
export class GetSchemaRequestDto {
//@example "did:indy:LEDNGER:SXM76gQwRnjkgoz2oBnGjd/anoncreds/v0/SCHEMA/test schema/1.0.2"
@IsNotEmpty()
@IsString()
schemaId: string;
@IsNotEmpty()
state: string;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment