From d296cac8fd9711e0c6c4362935b84775a0677a1c Mon Sep 17 00:00:00 2001
From: KulkarniShashank
Date: Wed, 25 Oct 2023 14:53:30 +0530
Subject: [PATCH] Added the API for get oob verification qr code
Signed-off-by: KulkarniShashank
---
.../src/issuance/issuance.controller.ts | 13 ++++++
.../src/verification/dto/request-proof.dto.ts | 6 +--
.../verification/verification.controller.ts | 20 ++++++++-
.../out-of-band-issuance.template.ts | 2 +-
apps/verification/src/verification.service.ts | 42 ++++++++++---------
.../out-of-band-verification.template.ts | 3 +-
6 files changed, 61 insertions(+), 25 deletions(-)
diff --git a/apps/api-gateway/src/issuance/issuance.controller.ts b/apps/api-gateway/src/issuance/issuance.controller.ts
index beb58488b..28430fa1f 100644
--- a/apps/api-gateway/src/issuance/issuance.controller.ts
+++ b/apps/api-gateway/src/issuance/issuance.controller.ts
@@ -57,6 +57,19 @@ export class IssuanceController {
) { }
private readonly logger = new Logger('IssuanceController');
+ @Get('/issuance/oob/qr/:base64Image')
+ @ApiOperation({ summary: 'Out-Of-Band issuance QR', description: 'Out-Of-Band issuance QR' })
+ @ApiResponse({ status: 200, description: 'Success', type: ApiResponseDto })
+ @ApiExcludeEndpoint()
+ async getOgPofile(@Param('base64Image') base64Image: string, @Res() res: Response): Promise {
+
+ const base64Data = base64Image.replace(/^data:image\/\w+;base64,/, '');
+
+ const imageBuffer = Buffer.from(base64Data, 'base64');
+ res.setHeader('Content-Type', 'image/png');
+ return res.send(imageBuffer);
+ }
+
/**
* Description: Get all issued credentials
* @param user
diff --git a/apps/api-gateway/src/verification/dto/request-proof.dto.ts b/apps/api-gateway/src/verification/dto/request-proof.dto.ts
index 8330f7a9e..c991ba434 100644
--- a/apps/api-gateway/src/verification/dto/request-proof.dto.ts
+++ b/apps/api-gateway/src/verification/dto/request-proof.dto.ts
@@ -85,9 +85,9 @@ export class OutOfBandRequestProof {
@IsNotEmpty({ message: 'please provide valid attributes' })
attributes: ProofRequestAttribute[];
- @ApiProperty({ example: ['exmaple@example.com'] })
- @IsArray({ message: 'emailId should be array' })
- emailId: string[];
+ @ApiProperty()
+ @IsString({ each: true, message: 'Each emailId in the array should be a string' })
+ emailId: string | string[];
@ApiProperty()
@IsOptional()
diff --git a/apps/api-gateway/src/verification/verification.controller.ts b/apps/api-gateway/src/verification/verification.controller.ts
index f9f555c52..c256db92c 100644
--- a/apps/api-gateway/src/verification/verification.controller.ts
+++ b/apps/api-gateway/src/verification/verification.controller.ts
@@ -31,7 +31,6 @@ import { WebhookPresentationProof } from './dto/webhook-proof.dto';
import { CustomExceptionFilter } from 'apps/api-gateway/common/exception-handler';
@UseFilters(CustomExceptionFilter)
-@ApiBearerAuth()
@Controller()
@ApiTags('verifications')
export class VerificationController {
@@ -39,6 +38,19 @@ export class VerificationController {
private readonly logger = new Logger('VerificationController');
+ @Get('/verification/oob/qr/:base64Image')
+ @ApiOperation({ summary: 'Out-Of-Band issuance QR', description: 'Out-Of-Band issuance QR' })
+ @ApiResponse({ status: 200, description: 'Success', type: ApiResponseDto })
+ @ApiExcludeEndpoint()
+ async getOgPofile(@Param('base64Image') base64Image: string, @Res() res: Response): Promise {
+
+ const base64Data = base64Image.replace(/^data:image\/\w+;base64,/, '');
+
+ const imageBuffer = Buffer.from(base64Data, 'base64');
+ res.setHeader('Content-Type', 'image/png');
+ return res.send(imageBuffer);
+ }
+
@Get('/orgs/:orgId/proofs/:proofId/form')
@ApiOperation({
summary: `Get a proof form data`,
@@ -46,6 +58,7 @@ export class VerificationController {
})
@Roles(OrgRoles.OWNER, OrgRoles.ADMIN, OrgRoles.ISSUER, OrgRoles.VERIFIER, OrgRoles.MEMBER, OrgRoles.HOLDER)
@UseGuards(AuthGuard('jwt'), OrgRolesGuard)
+ @ApiBearerAuth()
@ApiResponse({ status: 200, description: 'Success', type: ApiResponseDto })
@ApiUnauthorizedResponse({ status: 401, description: 'Unauthorized', type: UnauthorizedErrorDto })
@ApiForbiddenResponse({ status: 403, description: 'Forbidden', type: ForbiddenErrorDto })
@@ -81,6 +94,7 @@ export class VerificationController {
@ApiForbiddenResponse({ status: 403, description: 'Forbidden', type: ForbiddenErrorDto })
@Roles(OrgRoles.OWNER, OrgRoles.ADMIN, OrgRoles.ISSUER, OrgRoles.VERIFIER, OrgRoles.MEMBER, OrgRoles.HOLDER)
@UseGuards(AuthGuard('jwt'), OrgRolesGuard)
+ @ApiBearerAuth()
async getProofPresentationById(
@Res() res: Response,
@GetUser() user: IUserRequest,
@@ -113,6 +127,7 @@ export class VerificationController {
@ApiQuery(
{ name: 'threadId', required: false }
)
+ @ApiBearerAuth()
@Roles(OrgRoles.OWNER, OrgRoles.ADMIN, OrgRoles.ISSUER, OrgRoles.VERIFIER, OrgRoles.MEMBER, OrgRoles.HOLDER)
@UseGuards(AuthGuard('jwt'), OrgRolesGuard)
async getProofPresentations(
@@ -145,6 +160,7 @@ export class VerificationController {
@ApiUnauthorizedResponse({ status: 401, description: 'Unauthorized', type: UnauthorizedErrorDto })
@ApiForbiddenResponse({ status: 403, description: 'Forbidden', type: ForbiddenErrorDto })
@ApiBody({ type: RequestProof })
+ @ApiBearerAuth()
@UseGuards(AuthGuard('jwt'), OrgRolesGuard)
@Roles(OrgRoles.OWNER, OrgRoles.ADMIN, OrgRoles.VERIFIER)
async sendPresentationRequest(
@@ -184,6 +200,7 @@ export class VerificationController {
@ApiUnauthorizedResponse({ status: 401, description: 'Unauthorized', type: UnauthorizedErrorDto })
@ApiForbiddenResponse({ status: 403, description: 'Forbidden', type: ForbiddenErrorDto })
@Roles(OrgRoles.OWNER, OrgRoles.ADMIN, OrgRoles.VERIFIER)
+ @ApiBearerAuth()
@UseGuards(AuthGuard('jwt'), OrgRolesGuard)
async verifyPresentation(
@Res() res: Response,
@@ -216,6 +233,7 @@ export class VerificationController {
@ApiForbiddenResponse({ status: 403, description: 'Forbidden', type: ForbiddenErrorDto })
@ApiBody({ type: OutOfBandRequestProof })
@Roles(OrgRoles.OWNER, OrgRoles.ADMIN, OrgRoles.VERIFIER)
+ @ApiBearerAuth()
@UseGuards(AuthGuard('jwt'), OrgRolesGuard)
async sendOutOfBandPresentationRequest(
@Res() res: Response,
diff --git a/apps/issuance/templates/out-of-band-issuance.template.ts b/apps/issuance/templates/out-of-band-issuance.template.ts
index 6031fb0b2..d877cdb6f 100644
--- a/apps/issuance/templates/out-of-band-issuance.template.ts
+++ b/apps/issuance/templates/out-of-band-issuance.template.ts
@@ -36,7 +36,7 @@ export class OutOfBandIssuance {
Should you require any assistance or have questions, feel free to contact our dedicated support team.
-
+