Skip to content

Commit

Permalink
Merge pull request #33 from niscy-eudiw/feat/conditionally-request-md
Browse files Browse the repository at this point in the history
conditionally request md data
  • Loading branch information
SmirlakisParis authored Oct 4, 2024
2 parents c94edba + 4c8d055 commit 02d2e7b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/server/services/BookingService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ export class BookingService {

const verificationData = await this.verifier.initVerification(
newBooking.id,
isMobile
isMobile,
newBooking.carRental
);

if (isMobile) {
Expand Down
15 changes: 9 additions & 6 deletions src/server/services/VerifierService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ export class VerifierService {

public async initVerification(
bookingId: string,
isMobile: boolean
isMobile: boolean,
carRental: boolean,
): Promise<{ requestUri: string; TransactionId: string }> {
const payload: Payload = this.buildPayload(bookingId, isMobile);
const payload: Payload = this.buildPayload(bookingId, isMobile, carRental);

try {
const response = await fetch(`${env.VERIFIER_API_URL}/ui/presentations`, {
Expand All @@ -43,25 +44,27 @@ export class VerifierService {
}
}

private buildPayload(bookingId: string, isMobile: boolean): Payload {
private buildPayload(bookingId: string, isMobile: boolean, carRental:boolean ): Payload {
const payload: Payload = {
type: "vp_token",
presentation_definition: {
id: bookingId,
input_descriptors: [
this.mdlInputDescriptor(),
this.photoIdInputDescriptor(),
this.photoIdInputDescriptor()
],
},
jar_mode: "by_reference",
presentation_definition_mode: "by_reference",
nonce: "eaaace85-4d77-45dc-b57a-9043a548ab86",
};

if(carRental){
payload.presentation_definition.input_descriptors.push(this.mdlInputDescriptor());
}

if (isMobile) {
payload.wallet_response_redirect_uri_template = `${env.NEXT_PUBLIC_APP_URI}/confirmation/${bookingId}?response_code={RESPONSE_CODE}`;
}

return payload;
}

Expand Down

0 comments on commit 02d2e7b

Please sign in to comment.