Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add deeplink support #767

Merged
merged 8 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ PUBLIC_QA_API_URL= // Please specify your your QA environment api URL
PUBLIC_PRODUCTION_API_URL= // Please specify your PRODUCTION environment api URL
PUBLIC_SANDBOX_API_URL= // Please specify your sandbox environment URL

SHORTENED_URL_DOMAIN= // Please specify the domain for your bucket responsible for storing shortened url objects e.g. 'https://bucket-name.s3.ap-east-1.amazonaws.com'
DEEPLINK_DOMAIN= // Please specify your doamin/subdomain responsible for deeplinking with 'url' as a query param e.g. 'https://your-deeplink-domain?url='

[email protected] // Please specify your agent host VM and IP address
AWS_ACCOUNT_ID=xxxxx // Please provide your AWS account Id
Expand Down
4 changes: 1 addition & 3 deletions apps/api-gateway/src/verification/dto/request-proof.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,7 @@ export class SendProofRequestPayload {
comment: string;

@ApiProperty({
'example': [
{
'example': {
indy: {
name: 'Verify national identity',
version: '1.0',
Expand All @@ -358,7 +357,6 @@ export class SendProofRequestPayload {
requested_predicates: {}
}
}
]
})
@IsObject({ each: true })
@IsNotEmpty({ message: 'please provide valid proofFormat' })
Expand Down
8 changes: 6 additions & 2 deletions apps/issuance/src/issuance.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { parse as paParse } from 'papaparse';
import { v4 as uuidv4 } from 'uuid';
import { Cache } from 'cache-manager';
import { CACHE_MANAGER } from '@nestjs/cache-manager';
import { orderValues, paginator } from '@credebl/common/common.utils';
import { convertUrlToDeepLinkUrl, orderValues, paginator } from '@credebl/common/common.utils';
import { InjectQueue } from '@nestjs/bull';
import { Queue } from 'bull';
import { FileUploadStatus, FileUploadType } from 'apps/api-gateway/src/enum';
Expand Down Expand Up @@ -252,6 +252,9 @@ export class IssuanceService {
const invitationUrl: string = credentialCreateOfferDetails.response?.invitationUrl;
const url: string = await this.storeIssuanceObjectReturnUrl(invitationUrl);
credentialCreateOfferDetails.response['invitationUrl'] = url;
// Add deepLinkURL param to response
const deepLinkURL = convertUrlToDeepLinkUrl(url);
credentialCreateOfferDetails.response['deepLinkURL'] = deepLinkURL;
}
return credentialCreateOfferDetails.response;
} catch (error) {
Expand Down Expand Up @@ -671,6 +674,7 @@ async sendEmailForCredentialOffer(sendEmailCredentialOffer: SendEmailCredentialO

const invitationUrl: string = credentialCreateOfferDetails.response?.invitationUrl;
const shortenUrl: string = await this.storeIssuanceObjectReturnUrl(invitationUrl);
const deeplLinkURL = convertUrlToDeepLinkUrl(shortenUrl);

if (!invitationUrl) {
errors.push(new NotFoundException(ResponseMessages.issuance.error.invitationNotFound));
Expand All @@ -686,7 +690,7 @@ async sendEmailForCredentialOffer(sendEmailCredentialOffer: SendEmailCredentialO
this.emailData.emailFrom = platformConfigData?.emailFrom;
this.emailData.emailTo = iterator?.emailId ?? emailId;
this.emailData.emailSubject = `${process.env.PLATFORM_NAME} Platform: Issuance of Your Credential`;
this.emailData.emailHtml = this.outOfBandIssuance.outOfBandIssuance(emailId, organizationDetails.name, shortenUrl);
this.emailData.emailHtml = this.outOfBandIssuance.outOfBandIssuance(emailId, organizationDetails.name, deeplLinkURL);
this.emailData.emailAttachments = [
{
filename: 'qrcode.png',
Expand Down
4 changes: 2 additions & 2 deletions apps/issuance/templates/out-of-band-issuance.template.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export class OutOfBandIssuance {
public outOfBandIssuance(email: string, orgName: string, agentEndPoint: string): string {
public outOfBandIssuance(email: string, orgName: string, deepLinkURL: string): string {
try {
return `<!DOCTYPE html>
<html lang="en">
Expand Down Expand Up @@ -35,7 +35,7 @@ export class OutOfBandIssuance {
<li>Check <b>"Credentials"</b> tab in ${process.env.MOBILE_APP} to view the issued credential.</li>
</ul>
<div style="text-align: center; padding-bottom: 20px;">
<a clicktracking=off href="${agentEndPoint}"
<a clicktracking=off href="${deepLinkURL}"
style="padding: 10px 20px 10px 20px;color: #fff;background: #1F4EAD;border-radius: 5px;text-decoration: none;">
Accept Credential
</a>
Expand Down
1 change: 1 addition & 0 deletions apps/verification/src/interfaces/verification.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,4 +233,5 @@ export interface IProofRequestSearchCriteria {

export interface IInvitation{
invitationUrl?: string;
deepLinkURL?: string;
}
5 changes: 4 additions & 1 deletion apps/verification/src/verification.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { IUserRequest } from '@credebl/user-request/user-request.interface';
import { IProofPresentationDetails, IProofPresentationList, IVerificationRecords } from '@credebl/common/interfaces/verification.interface';
import { ProofRequestType } from 'apps/api-gateway/src/verification/enum/verification.enum';
import { UserActivityService } from '@credebl/user-activity';
import { convertUrlToDeepLinkUrl } from '@credebl/common/common.utils';

@Injectable()
export class VerificationService {
Expand Down Expand Up @@ -409,6 +410,7 @@ export class VerificationService {
this.logger.log('shortenedUrl', shortenedUrl);
if (shortenedUrl) {
presentationProof.invitationUrl = shortenedUrl;
presentationProof.deepLinkURL = convertUrlToDeepLinkUrl(shortenedUrl);
}
}
if (!presentationProof) {
Expand Down Expand Up @@ -480,6 +482,7 @@ export class VerificationService {
// Currently have shortenedUrl to store only for 30 days
const persist: boolean = false;
const shortenedUrl = await this.storeVerificationObjectAndReturnUrl(invitationUrl, persist);
const deepLinkURL = convertUrlToDeepLinkUrl(shortenedUrl);
const qrCodeOptions: QRCode.QRCodeToDataURLOptions = { type: 'image/png' };
const outOfBandVerificationQrCode = await QRCode.toDataURL(shortenedUrl, qrCodeOptions);

Expand All @@ -492,7 +495,7 @@ export class VerificationService {
this.emailData.emailFrom = platformConfigData.emailFrom;
this.emailData.emailTo = email;
this.emailData.emailSubject = `${process.env.PLATFORM_NAME} Platform: Verification of Your Credentials`;
this.emailData.emailHtml = await this.outOfBandVerification.outOfBandVerification(email, organizationDetails.name, shortenedUrl);
this.emailData.emailHtml = await this.outOfBandVerification.outOfBandVerification(email, organizationDetails.name, deepLinkURL);
this.emailData.emailAttachments = [
{
filename: 'qrcode.png',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export class OutOfBandVerification {

public outOfBandVerification(email: string, orgName: string, shortenedUrl: string): string {
public outOfBandVerification(email: string, orgName: string, deeplLinkURL: string): string {
try {
return `<!DOCTYPE html>
<html lang="en">
Expand Down Expand Up @@ -33,7 +33,7 @@ export class OutOfBandVerification {
<li>Tap the <b>"Send Proof"</b> button in ${process.env.MOBILE_APP} to share you credential data.</li>
</ul>
<div style="text-align: center; padding-bottom: 20px;">
<a clicktracking=off href="${shortenedUrl}"
<a clicktracking=off href="${deeplLinkURL}"
style="padding: 10px 20px 10px 20px;color: #fff;background: #1F4EAD;border-radius: 5px;text-decoration: none;">
Share Credential
</a>
Expand Down
8 changes: 8 additions & 0 deletions libs/common/src/common.utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as dotenv from 'dotenv';
dotenv.config();
/* eslint-disable camelcase */
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/explicit-function-return-type
export function paginator<T>(
Expand Down Expand Up @@ -42,3 +44,9 @@ export function orderValues(key, order = 'asc') {
return 'desc' === order ? comparison * -1 : comparison;
};
}


export function convertUrlToDeepLinkUrl(url: string): string {
const deepLinkUrl = (process.env.DEEPLINK_DOMAIN as string).concat(url);
return deepLinkUrl;
}