From 63ff399deeac55e668ad9f441392e62358b01f5f Mon Sep 17 00:00:00 2001 From: Alexey Lunin <alexey.lunin@vereign.com> Date: Wed, 8 May 2024 13:48:43 +0300 Subject: [PATCH] Add comment when offering credential and proof request --- agent-swagger.json | 6 ++++++ .../OfferCredentialDialogStore.ts | 2 ++ .../src/modals/OfferCredentialDialog/index.tsx | 13 +++++++++++-- .../RequestProofDialogStore.ts | 2 ++ .../src/modals/RequestProofDialog/index.tsx | 18 +++++++++++++++--- .../src/askar/agent.credentials.service.ts | 2 ++ libs/askar/src/askar/agent.proofs.service.ts | 2 ++ libs/clients/src/frontend/agent_gen.ts | 2 ++ .../requests/offer.credential.request.dto.ts | 4 ++++ .../src/dtos/requests/request.proof.dto.ts | 4 ++++ 10 files changed, 50 insertions(+), 5 deletions(-) diff --git a/agent-swagger.json b/agent-swagger.json index 92c6d0a9..b5159a18 100644 --- a/agent-swagger.json +++ b/agent-swagger.json @@ -1424,6 +1424,9 @@ "items": { "$ref": "#/components/schemas/OfferCredentialAttributes" } + }, + "comment": { + "type": "string" } }, "required": [ @@ -1870,6 +1873,9 @@ "items": { "$ref": "#/components/schemas/RequestProofAttribute" } + }, + "comment": { + "type": "string" } }, "required": [ diff --git a/apps/dashboard/src/modals/OfferCredentialDialog/OfferCredentialDialogStore.ts b/apps/dashboard/src/modals/OfferCredentialDialog/OfferCredentialDialogStore.ts index bc98939c..56e7741d 100644 --- a/apps/dashboard/src/modals/OfferCredentialDialog/OfferCredentialDialogStore.ts +++ b/apps/dashboard/src/modals/OfferCredentialDialog/OfferCredentialDialogStore.ts @@ -56,6 +56,7 @@ class OfferCredentialDialogStore { public offerCredential = async ( attributes: { name: string; value: string }[], + comment: string ) => { runInAction(() => (this.issuingLoading = true)); try { @@ -63,6 +64,7 @@ class OfferCredentialDialogStore { connectionId: this.connectionId, credentialDefinitionId: this.selectedCredDefId!, attributes: attributes, + comment }); toast.success("Credential offer sent"); runInAction(() => { diff --git a/apps/dashboard/src/modals/OfferCredentialDialog/index.tsx b/apps/dashboard/src/modals/OfferCredentialDialog/index.tsx index 90b3c5e5..e69c485e 100644 --- a/apps/dashboard/src/modals/OfferCredentialDialog/index.tsx +++ b/apps/dashboard/src/modals/OfferCredentialDialog/index.tsx @@ -24,10 +24,12 @@ const OfferCredentialDialog = observer( const onFinish = async ({ attributes, + comment }: { attributes: { name: string; value: string }[]; + comment: string; }) => { - const response = await store.offerCredential(attributes); + const response = await store.offerCredential(attributes, comment); if (response) { data.onCredentialOffered(response); onClose(); @@ -76,7 +78,7 @@ const OfferCredentialDialog = observer( /> </Form.Item> </Form> - {} + {store.schema && ( <Form labelCol={{ span: 8 }} @@ -115,6 +117,13 @@ const OfferCredentialDialog = observer( }} </Form.List> + <Form.Item + label="Comment" + name="comment" + > + <Input.TextArea /> + </Form.Item> + <Form.Item wrapperCol={{ offset: 8, span: 16 }}> <Button type="primary" diff --git a/apps/dashboard/src/modals/RequestProofDialog/RequestProofDialogStore.ts b/apps/dashboard/src/modals/RequestProofDialog/RequestProofDialogStore.ts index 514018b0..d381e800 100644 --- a/apps/dashboard/src/modals/RequestProofDialog/RequestProofDialogStore.ts +++ b/apps/dashboard/src/modals/RequestProofDialog/RequestProofDialogStore.ts @@ -14,6 +14,7 @@ class RequestProofDialogStore { public initLoading = false; public connectionId: string | undefined = undefined; public credDefList: CreddefRecordDto[] = []; + public comment: string = ""; public rows: ProofUiAttribute[] = []; @@ -123,6 +124,7 @@ class RequestProofDialogStore { credentialDefinitionId: p.credentialDefinitionId!, schemaId: p.schema!.id!, })), + comment: this.comment }); toast("Proof request created"); runInAction(() => { diff --git a/apps/dashboard/src/modals/RequestProofDialog/index.tsx b/apps/dashboard/src/modals/RequestProofDialog/index.tsx index 09b3d483..bccbe2c0 100644 --- a/apps/dashboard/src/modals/RequestProofDialog/index.tsx +++ b/apps/dashboard/src/modals/RequestProofDialog/index.tsx @@ -1,10 +1,11 @@ import React, { useEffect, useState } from "react"; import { observer } from "mobx-react"; -import { Button, Spin, Select, Space } from "antd"; +import {Button, Spin, Select, Space, Form, Input} from "antd"; import Modal, { FcProps } from "@dashboard/components/Modal"; import { RequestProofResponseDto } from "@dashboard/engine-api"; import RequestProofDialogStore from "./RequestProofDialogStore"; import s from "./styles.module.scss"; +import {runInAction} from "mobx"; export interface RequestProofDialogProps { connectionId?: string; @@ -32,7 +33,7 @@ const RequestProofDialog = observer( {store.rows.map((row, rowIndex) => ( <Space direction="horizontal" className={s.row} key={rowIndex}> <div className={s.field}> - <div className={s.field__label} /> + <div className={s.field__label}/> <span>{rowIndex + 1}.</span> </div> <div className={s.field}> @@ -49,7 +50,7 @@ const RequestProofDialog = observer( }))} /> </div> - {row.schemaLoading && <Spin />} + {row.schemaLoading && <Spin/>} {row.schema && ( <div className={s.field}> <div className={s.field__label}>Attribute</div> @@ -77,6 +78,17 @@ const RequestProofDialog = observer( </div> </Space> ))} + <div className={s.field}> + <div className={s.field__label}>Comment</div> + <Input.TextArea + value={store.comment} + onChange={(e) => { + runInAction(() => { + store.comment = e.target.value + }) + }} + /> + </div> <Space direction="vertical" className={s.actions}> <Button onClick={() => store.addRow()}>Add row</Button> <Button diff --git a/libs/askar/src/askar/agent.credentials.service.ts b/libs/askar/src/askar/agent.credentials.service.ts index 1adcb856..8c91e579 100644 --- a/libs/askar/src/askar/agent.credentials.service.ts +++ b/libs/askar/src/askar/agent.credentials.service.ts @@ -43,6 +43,7 @@ export class AgentCredentialsService { }, }, autoAcceptCredential: AutoAcceptCredential.ContentApproved, + ...(offerCredentialDto.comment ? { comment: offerCredentialDto.comment } : {}) }); credentialRecord.setTag("xRole", "issuer"); @@ -83,6 +84,7 @@ export class AgentCredentialsService { attributes: offerCredentialDto.attributes, }, }, + ...(offerCredentialDto.comment ? { comment: offerCredentialDto.comment } : {}) }); credentialExchangeRecord.setTag("xRole", "issuer"); diff --git a/libs/askar/src/askar/agent.proofs.service.ts b/libs/askar/src/askar/agent.proofs.service.ts index 2eb450f1..da439333 100644 --- a/libs/askar/src/askar/agent.proofs.service.ts +++ b/libs/askar/src/askar/agent.proofs.service.ts @@ -56,6 +56,7 @@ export class AgentProofsService { requested_attributes: requestedAttributes, }, }, + ...(requestProofDto.comment ? { comment: requestProofDto.comment } : {}) }); proofRecord.setTag("xRole", "requester"); @@ -98,6 +99,7 @@ export class AgentProofsService { requested_attributes: requestedAttributes, }, }, + ...(requestProofDto.comment ? { comment: requestProofDto.comment } : {}) }); exchangeRecord.setTag("xRole", "requester"); diff --git a/libs/clients/src/frontend/agent_gen.ts b/libs/clients/src/frontend/agent_gen.ts index be1e364f..a5dac918 100644 --- a/libs/clients/src/frontend/agent_gen.ts +++ b/libs/clients/src/frontend/agent_gen.ts @@ -1543,6 +1543,7 @@ export interface OfferCredentialRequestDto { connectionId?: string; credentialDefinitionId: string; attributes: OfferCredentialAttributes[]; + comment?: string; [key: string]: any; } @@ -1698,6 +1699,7 @@ export interface RequestProofAttribute { export interface RequestProofDto { connectionId?: string; attributes: RequestProofAttribute[]; + comment?: string; [key: string]: any; } diff --git a/libs/dtos/src/dtos/requests/offer.credential.request.dto.ts b/libs/dtos/src/dtos/requests/offer.credential.request.dto.ts index 9cea64c9..79d1276e 100644 --- a/libs/dtos/src/dtos/requests/offer.credential.request.dto.ts +++ b/libs/dtos/src/dtos/requests/offer.credential.request.dto.ts @@ -34,6 +34,10 @@ export class OfferCredentialRequestDto { @ValidateNested({ each: true }) @Type(() => OfferCredentialAttributes) attributes: Array<OfferCredentialAttributes>; + + @IsString() + @IsOptional() + comment?: string | undefined; } export class OfferJsonCredentialRequests { diff --git a/libs/dtos/src/dtos/requests/request.proof.dto.ts b/libs/dtos/src/dtos/requests/request.proof.dto.ts index 202f7549..c81dd8fe 100644 --- a/libs/dtos/src/dtos/requests/request.proof.dto.ts +++ b/libs/dtos/src/dtos/requests/request.proof.dto.ts @@ -34,4 +34,8 @@ export class RequestProofDto { @ValidateNested({ each: true }) @Type(() => RequestProofAttribute) attributes: Array<RequestProofAttribute>; + + @IsString() + @IsOptional() + comment?: string; } -- GitLab