From ca22161f12c21fbbb53cc79cda9868bf41cb41b8 Mon Sep 17 00:00:00 2001 From: Jose Olarte III Date: Fri, 20 Jun 2025 20:37:14 +0800 Subject: [PATCH] Fix: entity-type identifier validation - Ensure claims contain only correct and necessary giver and recipient identifiers, as per Endorser.ch documentation --- src/components/GiftedDialog.vue | 74 +++++++++++++++++++++++---------- 1 file changed, 51 insertions(+), 23 deletions(-) diff --git a/src/components/GiftedDialog.vue b/src/components/GiftedDialog.vue index af6dee5c..fe3b2054 100644 --- a/src/components/GiftedDialog.vue +++ b/src/components/GiftedDialog.vue @@ -417,21 +417,7 @@ @@ -824,24 +810,46 @@ export default class GiftedDialog extends Vue { unitCode: string = "HUR", ) { try { + // Determine the correct parameters based on entity types + let fromDid: string | undefined; + let toDid: string | undefined; + let fulfillsProjectHandleId: string | undefined; + let providerPlanHandleId: string | undefined; + + if (this.giverEntityType === "project" && this.recipientEntityType === "person") { + // Project-to-person gift + fromDid = undefined; // No person giver + toDid = recipientDid as string; // Person recipient + fulfillsProjectHandleId = undefined; // No project recipient + providerPlanHandleId = this.giver?.handleId; // Project giver + } else if (this.giverEntityType === "person" && this.recipientEntityType === "project") { + // Person-to-project gift + fromDid = giverDid as string; // Person giver + toDid = undefined; // No person recipient + fulfillsProjectHandleId = this.toProjectId; // Project recipient + providerPlanHandleId = undefined; // No project giver + } else { + // Person-to-person gift + fromDid = giverDid as string; + toDid = recipientDid as string; + fulfillsProjectHandleId = undefined; + providerPlanHandleId = undefined; + } + const result = await createAndSubmitGive( this.axios, this.apiServer, this.activeDid, - this.showProjects ? undefined : (giverDid as string), - this.showProjects && this.isFromProjectView - ? this.giver?.handleId - : (recipientDid as string), + fromDid, + toDid, description, amount, unitCode, - this.showProjects && this.isFromProjectView - ? this.giver?.handleId - : this.toProjectId, + fulfillsProjectHandleId, this.offerId, false, undefined, - this.showProjects ? this.giver?.handleId : undefined, + providerPlanHandleId, ); if (!result.success) { @@ -1003,6 +1011,26 @@ export default class GiftedDialog extends Vue { }; this.currentStep = 2; } + + // Computed property for the query parameters + get giftedDetailsQuery() { + return { + amountInput: this.amountInput, + description: this.description, + giverDid: this.giverEntityType === "person" ? this.giver?.did : undefined, + giverName: this.giver?.name, + offerId: this.offerId, + fulfillsProjectId: this.giverEntityType === "person" && this.recipientEntityType === "project" + ? this.toProjectId + : undefined, + providerProjectId: this.giverEntityType === "project" && this.recipientEntityType === "person" + ? this.giver?.handleId + : this.fromProjectId, + recipientDid: this.receiver?.did, + recipientName: this.receiver?.name, + unitCode: this.unitCode, + }; + } }