From c47e476532afc209fdda526d7d228135df353b1f Mon Sep 17 00:00:00 2001 From: Ankita Patidar Date: Fri, 6 Dec 2024 09:48:01 +0530 Subject: [PATCH 1/4] add threadId to response in proofrequest email API Signed-off-by: Ankita Patidar --- apps/verification/src/verification.service.ts | 33 ++++++++++++++----- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/apps/verification/src/verification.service.ts b/apps/verification/src/verification.service.ts index c56604bbb..1428ca1d1 100644 --- a/apps/verification/src/verification.service.ts +++ b/apps/verification/src/verification.service.ts @@ -1,5 +1,5 @@ /* eslint-disable camelcase */ -import { BadRequestException, HttpException, Inject, Injectable, InternalServerErrorException, Logger, NotFoundException } from '@nestjs/common'; +import { BadRequestException, HttpException, HttpStatus, Inject, Injectable, InternalServerErrorException, Logger, NotFoundException } from '@nestjs/common'; import { ClientProxy, RpcException } from '@nestjs/microservices'; import { map } from 'rxjs/operators'; import { IGetAllProofPresentations, IProofRequestSearchCriteria, IGetProofPresentationById, IProofPresentation, IProofRequestPayload, IRequestProof, ISendProofRequestPayload, IVerifyPresentation, IVerifiedProofData, IInvitation } from './interfaces/verification.interface'; @@ -454,8 +454,8 @@ export class VerificationService { } if (emailId) { - await this.sendEmailInBatches(payload, emailId, getAgentDetails, getOrganization); - return true; + const emailResponse = await this.sendEmailInBatches(payload, emailId, getAgentDetails, getOrganization); + return emailResponse; } else { const presentationProof: IInvitation = await this.generateOOBProofReq(payload); const proofRequestInvitationUrl: string = presentationProof.invitationUrl; @@ -498,13 +498,16 @@ export class VerificationService { // Currently batch size is not used, as length of emails sent is restricted to '10' - async sendEmailInBatches(payload: IProofRequestPayload, emailIds: string[], getAgentDetails: org_agents, organizationDetails: organisation): Promise { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + async sendEmailInBatches(payload: IProofRequestPayload, emailIds: string[], getAgentDetails: org_agents, organizationDetails: organisation): Promise { try { const accumulatedErrors = []; + const accumulatedResponse = []; for (const email of emailIds) { try { - await this.sendOutOfBandProofRequest(payload, email, getAgentDetails, organizationDetails); + const response = await this.sendOutOfBandProofRequest(payload, email, getAgentDetails, organizationDetails); + accumulatedResponse.push({email, ...response}); await this.delay(500); } catch (error) { this.logger.error(`Error sending email to ${email}::::::`, error); @@ -517,6 +520,8 @@ export class VerificationService { throw new Error(ResponseMessages.verification.error.emailSend); } + return accumulatedResponse; + } catch (error) { this.logger.error('[sendEmailInBatches] - error in sending email in batches'); throw new Error(ResponseMessages.verification.error.batchEmailSend); @@ -525,8 +530,9 @@ export class VerificationService { // This function is specifically for OOB verification using email - async sendOutOfBandProofRequest(payload: IProofRequestPayload, email: string, getAgentDetails: org_agents, organizationDetails: organisation): Promise { - const getProofPresentation = await this._sendOutOfBandProofRequest(payload); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + async sendOutOfBandProofRequest(payload: IProofRequestPayload, email: string, getAgentDetails: org_agents, organizationDetails: organisation): Promise { + const getProofPresentation = await this._sendOutOfBandProofRequest(payload); if (!getProofPresentation) { throw new Error(ResponseMessages.verification.error.proofPresentationNotFound); @@ -564,7 +570,11 @@ export class VerificationService { throw new Error(ResponseMessages.verification.error.emailSend); } - return isEmailSent; + return { + isEmailSent, + outOfBandRecordId: getProofPresentation?.response?.outOfBandRecord?.id, + proofRecordThId: getProofPresentation?.response?.proofRecordThId + }; } @@ -975,9 +985,14 @@ export class VerificationService { verificationErrorHandling(error): void { if (!error && !error?.status && !error?.status?.message && !error?.status?.message?.error) { - throw new RpcException(error.response ? error.response : error); } else { + if (error?.message) { + throw new RpcException({ + message: error?.message, + statusCode: HttpStatus.INTERNAL_SERVER_ERROR + }); + } throw new RpcException({ message: error?.status?.message?.error?.reason ? error?.status?.message?.error?.reason : error?.status?.message?.error, statusCode: error?.status?.code From 5a89313961f27808efc71ec87b13b2b39ed9378a Mon Sep 17 00:00:00 2001 From: Ankita Patidar Date: Tue, 10 Dec 2024 13:56:41 +0530 Subject: [PATCH 2/4] update email template Signed-off-by: Ankita Patidar --- .../out-of-band-verification.template.ts | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/apps/verification/templates/out-of-band-verification.template.ts b/apps/verification/templates/out-of-band-verification.template.ts index df33d0d68..c92ebccdc 100644 --- a/apps/verification/templates/out-of-band-verification.template.ts +++ b/apps/verification/templates/out-of-band-verification.template.ts @@ -1,6 +1,6 @@ export class OutOfBandVerification { - public outOfBandVerification(email: string, orgName: string, deeplLinkURL: string): string { + public outOfBandVerification(email: string, orgName: string, deepLinkURL: string): string { try { return ` @@ -45,27 +45,21 @@ export class OutOfBandVerification {
  • Complete the onboarding process in ${process.env.MOBILE_APP}.
  • Open the “Share Credential” link below in this email (This will open the link in the ${process.env.MOBILE_APP} App)
  • -
  • Tap the "Send Proof" button in ${process.env.MOBILE_APP} to share you credential data.
  • +
  • Tap the "Share" button in ${process.env.MOBILE_APP} to share you credential data.
  • - Note: If the above steps do not work for you, please open the attached QR Code image in this email on another device, and scan the QR code using the ${process.env.MOBILE_APP_NAME} on your mobile device. + Note: Alternatively, you will find a QR Code image attached to this email. You can open the QR code on another device and scan the QR code using the BHUTAN NDI App on your mobile device. The QR Code is single-use.

    -