diff --git a/agent-swagger.json b/agent-swagger.json index 26d802bccf5037f513409bbd06a3481700e9907a..2e00ff9eb78054378b1c93846577049557718103 100644 --- a/agent-swagger.json +++ b/agent-swagger.json @@ -848,6 +848,18 @@ "properties": { "goal": { "type": "string" + }, + "label": { + "type": "string" + }, + "alias": { + "type": "string" + }, + "imageUrl": { + "type": "string" + }, + "multiUseInvitation": { + "type": "boolean" } } }, @@ -862,6 +874,10 @@ "shortInvitationUrl": { "type": "string", "example": "http://0.0.0.0:8001/invitations/85a7c179-122b-4d2d-9a86-d92ad31cef2b" + }, + "outOfBandId": { + "type": "string", + "example": "85a7c179-122b-4d2d-9a86-d92ad31cef2b" } }, "required": [ @@ -901,6 +917,9 @@ "outOfBandId": { "type": "string" }, + "imageUrl": { + "type": "string" + }, "id": { "type": "string" }, diff --git a/apps/agent/README.md b/apps/agent/README.md index 4ac3348f0ac105fab17515d54b5b7442a06ea0b9..63a0c6113ee88579512ff090302b25584e202825 100644 --- a/apps/agent/README.md +++ b/apps/agent/README.md @@ -1,4 +1,4 @@ -# OCM ENGINE - AGENT +# OCM ENGINE - AGENT Agent service is a wrapper around @ocm-engine/askar library. diff --git a/libs/askar/src/askar/agent.service.ts b/libs/askar/src/askar/agent.service.ts index b56dc2fd704e008b6f20e1c2a9799f92a0494996..9fde3b83f1868134ee7408ccd5527e0fa2b7e9af 100644 --- a/libs/askar/src/askar/agent.service.ts +++ b/libs/askar/src/askar/agent.service.ts @@ -34,7 +34,6 @@ import { ConnectionRecord, CredentialExchangeRecord, CredentialState, - OutOfBandRecord, ProofState, Query, ProofExchangeRecord, @@ -53,32 +52,19 @@ export class AgentService { createInvitation = async ( createInvitationRequestDto?: CreateInvitationRequestDto, ) => { - let outOfBoundRecordPromise: Promise<OutOfBandRecord>; - - if ( - createInvitationRequestDto && - createInvitationRequestDto.goal && - this.askar.agentConfig.agentOobGoals && - this.askar.agentConfig.agentOobGoals.includes( - createInvitationRequestDto.goal, - ) - ) { - outOfBoundRecordPromise = this.askar.agent.oob.createInvitation({ - goal: createInvitationRequestDto.goal, - }); - } else { - outOfBoundRecordPromise = this.askar.agent.oob.createInvitation(); - } + const outOfBoundRecord = await this.askar.agent.oob.createInvitation( + createInvitationRequestDto, + ); - const outOfBoundRecord = await outOfBoundRecordPromise; + const response = new CreateInvitationResponseDto(); - const i = new CreateInvitationResponseDto(); - i.invitationUrl = outOfBoundRecord.outOfBandInvitation.toUrl({ + response.invitationUrl = outOfBoundRecord.outOfBandInvitation.toUrl({ domain: this.askar.agentConfig.agentPeerAddress, }); + response.shortInvitationUrl = `${this.askar.agentConfig.agentPeerAddress}/invitations/${outOfBoundRecord.outOfBandInvitation.id}`; + response.outOfBandId = outOfBoundRecord.id; - i.shortInvitationUrl = `${this.askar.agentConfig.agentPeerAddress}/invitations/${outOfBoundRecord.outOfBandInvitation.id}`; - return i; + return response; }; acceptInvitation = async ( @@ -91,16 +77,17 @@ export class AgentService { throw new EntityNotFoundError(); } - const r = new ConnectionRecordDto(); - r.connectionName = connectionRecord.theirLabel; - r.state = connectionRecord.state; - r.id = connectionRecord.id; - r.did = connectionRecord.did; - r.invitationDid = connectionRecord.invitationDid; - r.outOfBandId = connectionRecord.outOfBandId; - r.createdAt = connectionRecord.createdAt; + const response = new ConnectionRecordDto(); + response.connectionName = connectionRecord.theirLabel; + response.state = connectionRecord.state; + response.id = connectionRecord.id; + response.did = connectionRecord.did; + response.invitationDid = connectionRecord.invitationDid; + response.outOfBandId = connectionRecord.outOfBandId; + response.createdAt = connectionRecord.createdAt; + response.imageUrl = connectionRecord.imageUrl; - return r; + return response; }; async fetchConnections(): Promise<ConnectionRecordDto[]> { @@ -116,6 +103,7 @@ export class AgentService { connectionResponse.invitationDid = singleConnectionRes.invitationDid; connectionResponse.outOfBandId = singleConnectionRes.outOfBandId; connectionResponse.createdAt = singleConnectionRes.createdAt; + connectionResponse.imageUrl = singleConnectionRes.imageUrl; return connectionResponse; }); @@ -139,6 +127,7 @@ export class AgentService { connectionResponse.invitationDid = agentResponse.invitationDid; connectionResponse.outOfBandId = agentResponse.outOfBandId; connectionResponse.createdAt = agentResponse.createdAt; + connectionResponse.imageUrl = agentResponse.imageUrl; return connectionResponse; }; diff --git a/libs/dtos/src/dtos/generics/connection.record.dto.ts b/libs/dtos/src/dtos/generics/connection.record.dto.ts index 6ced725ca84d1a1a3f14d9c1554ad784e7593b9a..f5d8ad7bfef220e02811327b29c37e8bb1afdbf3 100644 --- a/libs/dtos/src/dtos/generics/connection.record.dto.ts +++ b/libs/dtos/src/dtos/generics/connection.record.dto.ts @@ -21,4 +21,7 @@ export class ConnectionRecordDto extends BaseRecordDto { @IsString() outOfBandId?: string; + + @IsString() + imageUrl?: string; } diff --git a/libs/dtos/src/dtos/requests/create.invitation.request.dto.ts b/libs/dtos/src/dtos/requests/create.invitation.request.dto.ts index 9bfad1343dfd48cdcbdb728d759ff3e84e42d32a..ff81e588d297d9002f78c850054fe51f656fafb0 100644 --- a/libs/dtos/src/dtos/requests/create.invitation.request.dto.ts +++ b/libs/dtos/src/dtos/requests/create.invitation.request.dto.ts @@ -1,8 +1,27 @@ -import { IsNotEmpty, IsOptional, IsString } from "class-validator"; +import { IsBoolean, IsNotEmpty, IsOptional, IsString } from "class-validator"; export class CreateInvitationRequestDto { @IsOptional() @IsString() @IsNotEmpty() goal?: string; + + @IsOptional() + @IsString() + @IsNotEmpty() + label?: string; + + @IsOptional() + @IsString() + @IsNotEmpty() + alias?: string; + + @IsOptional() + @IsString() + @IsNotEmpty() + imageUrl?: string; + + @IsOptional() + @IsBoolean() + multiUseInvitation?: boolean; } diff --git a/libs/dtos/src/dtos/responses/create.invitation.response.dto.ts b/libs/dtos/src/dtos/responses/create.invitation.response.dto.ts index f617fe2715e8ed8bc2360bfc04d2bb9d8b688fb3..238bb3607f4cfd6f5383452fb567d4f5f1c80dc6 100644 --- a/libs/dtos/src/dtos/responses/create.invitation.response.dto.ts +++ b/libs/dtos/src/dtos/responses/create.invitation.response.dto.ts @@ -1,4 +1,4 @@ -import { IsString, ValidateIf } from "class-validator"; +import { IsNotEmpty, IsOptional, IsString, ValidateIf } from "class-validator"; export class CreateInvitationResponseDto { /** @@ -6,6 +6,7 @@ export class CreateInvitationResponseDto { * @example "http://0.0.0.0:8001?oob=eyJAdHlwZSI6Imh0dHBzOi8vZGlkY29tbS5vcmcvb3V0LW9mLWJhbmQvMS4xL2ludml0YXRpb24iLCJAaWQiOiIzYWExNGIzNC04YTk5LTQxY2UtYTY3NC1jODUxYmVhMTIxMWEiLCJsYWJlbCI6IkRFeGNWYXNkX0FHRU5UXzQ1IiwiYWNjZXB0IjpbImRpZGNvbW0vYWlwMSIsImRpZGNvbW0vYWlwMjtlbnY9cmZjMTkiXSwiaGFuZHNoYWtlX3Byb3RvY29scyI6WyJodHRwczovL2RpZGNvbW0ub3JnL2RpZGV4Y2hhbmdlLzEuMCIsImh0dHBzOi8vZGlkY29tbS5vcmcvY29ubmVjdGlvbnMvMS4wIl0sInNlcnZpY2VzIjpbeyJpZCI6IiNpbmxpbmUtMCIsInNlcnZpY2VFbmRwb2ludCI6Imh0dHA6Ly8wLjAuMC4wOjgwMDEiLCJ0eXBlIjoiZGlkLWNvbW11bmljYXRpb24iLCJyZWNpcGllbnRLZXlzIjpbImRpZDprZXk6ejZNa3VFcHllc1pNa3k0a1BpQzhEOEplZERlcm55YTFuaTREMUF3ZmdnWWt6YmR4Il0sInJvdXRpbmdLZXlzIjpbXX1dfQ" */ @IsString() + @IsNotEmpty() @ValidateIf((o) => o.shortInvitationUrl === undefined) public invitationUrl: string; @@ -14,6 +15,15 @@ export class CreateInvitationResponseDto { * @example "http://0.0.0.0:8001/invitations/85a7c179-122b-4d2d-9a86-d92ad31cef2b" */ @IsString() + @IsNotEmpty() @ValidateIf((o) => o.invitationUrl === undefined) public shortInvitationUrl: string; + + /** + * @example "85a7c179-122b-4d2d-9a86-d92ad31cef2b" + */ + @IsString() + @IsNotEmpty() + @IsOptional() + outOfBandId?: string; }