Skip to content

Commit 5dfb8c9

Browse files
feat: implemented get verified presentation counts by issuer id (#1184)
Signed-off-by: bhavanakarwade <[email protected]>
1 parent 09c80ed commit 5dfb8c9

File tree

5 files changed

+616
-399
lines changed

5 files changed

+616
-399
lines changed

apps/api-gateway/src/verification/verification.controller.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,37 @@ export class VerificationController {
142142
return res.status(HttpStatus.OK).json(finalResponse);
143143
}
144144

145+
/**
146+
* Get proof presentation details by issuerId
147+
* @param proofId The ID of the proof
148+
* @param issuerId The ID of the issuer
149+
* @returns Proof presentation details by issuerId
150+
*/
151+
@Get('/orgs/proofs')
152+
@ApiOperation({
153+
summary: 'Get verified proof presentation details by issuer Id',
154+
description: 'Retrieve the details of a proof presentation by its issuer Id'
155+
})
156+
@ApiResponse({ status: HttpStatus.OK, description: 'Success', type: ApiResponseDto })
157+
@ApiUnauthorizedResponse({ status: HttpStatus.UNAUTHORIZED, description: 'Unauthorized', type: UnauthorizedErrorDto })
158+
@ApiForbiddenResponse({ status: HttpStatus.FORBIDDEN, description: 'Forbidden', type: ForbiddenErrorDto })
159+
@UseGuards(AuthGuard('jwt'))
160+
@ApiBearerAuth()
161+
async getProofPresentationByIssuerId(
162+
@Res() res: Response,
163+
@User() user: IUserRequest,
164+
@Query('issuerId') issuerId: string
165+
): Promise<Response> {
166+
const verifiedProofDetails = await this.verificationService.getPresentationDetailsByIssuerId(issuerId, user);
167+
168+
const finalResponse: IResponse = {
169+
statusCode: HttpStatus.OK,
170+
message: ResponseMessages.verification.success.fetch,
171+
data: verifiedProofDetails
172+
};
173+
return res.status(HttpStatus.OK).json(finalResponse);
174+
}
175+
145176
/**
146177
* Get all proof presentations
147178
* @param user The user making the request
Lines changed: 124 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,119 +1,147 @@
1-
import { Injectable, Inject} from '@nestjs/common';
2-
import { ClientProxy} from '@nestjs/microservices';
1+
import { Injectable, Inject } from '@nestjs/common';
2+
import { ClientProxy } from '@nestjs/microservices';
33
import { BaseService } from 'libs/service/base.service';
44
import { SendProofRequestPayload, RequestProofDtoV1, RequestProofDtoV2 } from './dto/request-proof.dto';
55
import { IUserRequest } from '@credebl/user-request/user-request.interface';
66
import { WebhookPresentationProofDto } from './dto/webhook-proof.dto';
7-
import { IProofPresentationDetails, IProofPresentationList, IVerificationRecords } from '@credebl/common/interfaces/verification.interface';
7+
import {
8+
IProofPresentationDetails,
9+
IProofPresentationList,
10+
IVerificationRecords
11+
} from '@credebl/common/interfaces/verification.interface';
812
import { IPresentation, IProofRequest, IProofRequestSearchCriteria } from './interfaces/verification.interface';
913
import { IProofPresentation } from './interfaces/verification.interface';
1014
// To do make a similar interface in API-gateway
1115
import { user } from '@prisma/client';
1216
import { NATSClient } from '@credebl/common/NATSClient';
1317

14-
1518
@Injectable()
1619
export class VerificationService extends BaseService {
17-
constructor(
18-
@Inject('NATS_CLIENT') private readonly verificationServiceProxy: ClientProxy,
19-
private readonly natsClient : NATSClient
20-
) {
21-
super('VerificationService');
22-
}
20+
constructor(
21+
@Inject('NATS_CLIENT') private readonly verificationServiceProxy: ClientProxy,
22+
private readonly natsClient: NATSClient
23+
) {
24+
super('VerificationService');
25+
}
2326

24-
/**
25-
* Get all proof presentations
26-
* @param orgId
27-
* @returns All proof presentations details
28-
*/
29-
getProofPresentations(proofRequestsSearchCriteria: IProofRequestSearchCriteria, user: IUserRequest, orgId: string): Promise<IProofPresentationList> {
30-
const payload = { proofRequestsSearchCriteria, user, orgId };
31-
return this.natsClient.sendNatsMessage(this.verificationServiceProxy, 'get-all-proof-presentations', payload);
32-
}
27+
/**
28+
* Get all proof presentations
29+
* @param orgId
30+
* @returns All proof presentations details
31+
*/
32+
getProofPresentations(
33+
proofRequestsSearchCriteria: IProofRequestSearchCriteria,
34+
user: IUserRequest,
35+
orgId: string
36+
): Promise<IProofPresentationList> {
37+
const payload = { proofRequestsSearchCriteria, user, orgId };
38+
return this.natsClient.sendNatsMessage(this.verificationServiceProxy, 'get-all-proof-presentations', payload);
39+
}
3340

34-
/**
35-
* Get proof presentation by proofId
36-
* @param proofId
37-
* @param orgId
38-
* @returns Proof presentation details by proofId
39-
*/
40-
getProofPresentationById(proofId: string, orgId: string, user: IUserRequest): Promise<IProofPresentation> {
41-
const payload = { proofId, orgId, user };
42-
return this.natsClient.sendNatsMessage(this.verificationServiceProxy, 'get-proof-presentations-by-proofId', payload);
43-
}
41+
/**
42+
* Get proof presentation by proofId
43+
* @param proofId
44+
* @param orgId
45+
* @returns Proof presentation details by proofId
46+
*/
47+
getProofPresentationById(proofId: string, orgId: string, user: IUserRequest): Promise<IProofPresentation> {
48+
const payload = { proofId, orgId, user };
49+
return this.natsClient.sendNatsMessage(
50+
this.verificationServiceProxy,
51+
'get-proof-presentations-by-proofId',
52+
payload
53+
);
54+
}
4455

45-
/**
46-
* Send proof request
47-
* @param orgId
48-
* @returns Requested proof presentation details
49-
*/
50-
sendProofRequest(requestProofDto: RequestProofDtoV1 | RequestProofDtoV2, user: IUserRequest): Promise<IProofRequest> {
51-
const payload = { requestProofDto, user };
52-
return this.natsClient.sendNatsMessage(this.verificationServiceProxy, 'send-proof-request', payload);
53-
}
56+
/**
57+
* Get verifier proof presentation by issuerId
58+
* @param issuerId
59+
* @returns Proof presentation details by issuerId
60+
*/
61+
getPresentationDetailsByIssuerId(issuerId: string, user: IUserRequest): Promise<number> {
62+
const payload = { issuerId, user };
63+
return this.natsClient.sendNatsMessage(
64+
this.verificationServiceProxy,
65+
'get-proof-presentation-details-by-issuerId',
66+
payload
67+
);
68+
}
5469

55-
/**
56-
* Verify proof presentation
57-
* @param proofId
58-
* @param orgId
59-
* @returns Verified proof presentation details
60-
*/
61-
verifyPresentation(proofId: string, orgId: string, user: IUserRequest): Promise<IPresentation> {
62-
const payload = { proofId, orgId, user };
63-
return this.natsClient.sendNatsMessage(this.verificationServiceProxy, 'verify-presentation', payload);
64-
}
70+
/**
71+
* Send proof request
72+
* @param orgId
73+
* @returns Requested proof presentation details
74+
*/
75+
sendProofRequest(requestProofDto: RequestProofDtoV1 | RequestProofDtoV2, user: IUserRequest): Promise<IProofRequest> {
76+
const payload = { requestProofDto, user };
77+
return this.natsClient.sendNatsMessage(this.verificationServiceProxy, 'send-proof-request', payload);
78+
}
6579

66-
webhookProofPresentation(orgId: string, proofPresentationPayload: WebhookPresentationProofDto): Promise<object> {
67-
const payload = { orgId, proofPresentationPayload };
68-
return this.natsClient.sendNatsMessage(this.verificationServiceProxy, 'webhook-proof-presentation', payload);
69-
}
80+
/**
81+
* Verify proof presentation
82+
* @param proofId
83+
* @param orgId
84+
* @returns Verified proof presentation details
85+
*/
86+
verifyPresentation(proofId: string, orgId: string, user: IUserRequest): Promise<IPresentation> {
87+
const payload = { proofId, orgId, user };
88+
return this.natsClient.sendNatsMessage(this.verificationServiceProxy, 'verify-presentation', payload);
89+
}
7090

71-
/**
72-
* Out-Of-Band Proof Presentation
73-
* @param user
74-
* @param outOfBandRequestProof
75-
* @returns Get out-of-band requested proof presentation details
76-
*/
77-
sendOutOfBandPresentationRequest(outOfBandRequestProof: SendProofRequestPayload, user: IUserRequest): Promise<object> {
78-
const payload = { outOfBandRequestProof, user };
79-
return this.natsClient.sendNatsMessage(this.verificationServiceProxy, 'send-out-of-band-proof-request', payload);
80-
}
81-
82-
getVerifiedProofDetails(proofId: string, orgId: string, user: IUserRequest): Promise<IProofPresentationDetails[]> {
83-
const payload = { proofId, orgId, user };
84-
return this.natsClient.sendNatsMessage(this.verificationServiceProxy, 'get-verified-proof-details', payload);
85-
}
91+
webhookProofPresentation(orgId: string, proofPresentationPayload: WebhookPresentationProofDto): Promise<object> {
92+
const payload = { orgId, proofPresentationPayload };
93+
return this.natsClient.sendNatsMessage(this.verificationServiceProxy, 'webhook-proof-presentation', payload);
94+
}
8695

87-
async _getWebhookUrl(tenantId?: string, orgId?: string): Promise<string> {
88-
const pattern = { cmd: 'get-webhookurl' };
89-
const payload = { tenantId, orgId };
90-
91-
try {
92-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
93-
const message = await this.verificationServiceProxy.send<any>(pattern, payload).toPromise();
94-
return message;
95-
} catch (error) {
96-
this.logger.error(`catch: ${JSON.stringify(error)}`);
97-
throw error;
98-
}
99-
}
100-
101-
async _postWebhookResponse(webhookUrl: string, data:object): Promise<string> {
102-
const pattern = { cmd: 'post-webhook-response-to-webhook-url' };
103-
const payload = { webhookUrl, data };
96+
/**
97+
* Out-Of-Band Proof Presentation
98+
* @param user
99+
* @param outOfBandRequestProof
100+
* @returns Get out-of-band requested proof presentation details
101+
*/
102+
sendOutOfBandPresentationRequest(
103+
outOfBandRequestProof: SendProofRequestPayload,
104+
user: IUserRequest
105+
): Promise<object> {
106+
const payload = { outOfBandRequestProof, user };
107+
return this.natsClient.sendNatsMessage(this.verificationServiceProxy, 'send-out-of-band-proof-request', payload);
108+
}
104109

105-
try {
106-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
107-
const message = await this.verificationServiceProxy.send<any>(pattern, payload).toPromise();
108-
return message;
109-
} catch (error) {
110-
this.logger.error(`catch: ${JSON.stringify(error)}`);
111-
throw error;
112-
}
113-
}
110+
getVerifiedProofDetails(proofId: string, orgId: string, user: IUserRequest): Promise<IProofPresentationDetails[]> {
111+
const payload = { proofId, orgId, user };
112+
return this.natsClient.sendNatsMessage(this.verificationServiceProxy, 'get-verified-proof-details', payload);
113+
}
114114

115-
async deleteVerificationRecords(orgId: string, userDetails: user): Promise<IVerificationRecords> {
116-
const payload = { orgId, userDetails };
117-
return this.natsClient.sendNatsMessage(this.verificationServiceProxy, 'delete-verification-records', payload);
115+
async _getWebhookUrl(tenantId?: string, orgId?: string): Promise<string> {
116+
const pattern = { cmd: 'get-webhookurl' };
117+
const payload = { tenantId, orgId };
118+
119+
try {
120+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
121+
const message = await this.verificationServiceProxy.send<any>(pattern, payload).toPromise();
122+
return message;
123+
} catch (error) {
124+
this.logger.error(`catch: ${JSON.stringify(error)}`);
125+
throw error;
118126
}
127+
}
128+
129+
async _postWebhookResponse(webhookUrl: string, data: object): Promise<string> {
130+
const pattern = { cmd: 'post-webhook-response-to-webhook-url' };
131+
const payload = { webhookUrl, data };
132+
133+
try {
134+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
135+
const message = await this.verificationServiceProxy.send<any>(pattern, payload).toPromise();
136+
return message;
137+
} catch (error) {
138+
this.logger.error(`catch: ${JSON.stringify(error)}`);
139+
throw error;
140+
}
141+
}
142+
143+
async deleteVerificationRecords(orgId: string, userDetails: user): Promise<IVerificationRecords> {
144+
const payload = { orgId, userDetails };
145+
return this.natsClient.sendNatsMessage(this.verificationServiceProxy, 'delete-verification-records', payload);
146+
}
119147
}

0 commit comments

Comments
 (0)