diff --git a/agent-swagger.json b/agent-swagger.json index 92c6d0a931d70be330027110b9bda0b55d63fc6e..b5159a18d92a8be1bbc6255416850c6596f3209c 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 bc98939c47ad2d43973518354390658b8a8ad68a..56e7741d919e7192faa7d986ed724d62a11ad862 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 90b3c5e5349a752c17a7dce591fd194c1e2517c4..e69c485e22ee6279fa15f706a755a0ef09bf4aac 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 514018b0051dd7bed6670a2295eb9ad3bdc04365..d381e8009cb5e88b76edc55e148e75ff99253f8a 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 09b3d483ceff9ebcc88232bc4d6651c4621d6948..bccbe2c0c578c18f87f3c7a1d6a3173065733144 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 1adcb8568c9c34aa4955799e06159347c3e7b57b..8c91e5796190fdd3f28432233ed3d8145d883a25 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 2eb450f1f8adf1dbb73f51fa8f7f1f97cc780bb5..da439333932c78ed91dcc3bd10d4ef9055f33d3f 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 be1e364fa7feae15379e0d8ca779efeea89ac8e5..a5dac9183725a0414bd9a927fcd27ab047bfb316 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 9cea64c90950d36aadd29ab0bf2765d7576d9e2a..79d1276e3d16fe70e0155c8d633219c26c0c4c1e 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 202f75492734b2bfae1d17e00db3599870090ff5..c81dd8fecc29b1ed54305a6b37de13442870928b 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; }