From 445996daed6f56b06825d6c9219705a4e5ca3248 Mon Sep 17 00:00:00 2001 From: KulkarniShashank Date: Tue, 27 Feb 2024 14:08:12 +0530 Subject: [PATCH] fix: solved verification predicates values Signed-off-by: KulkarniShashank --- apps/verification/src/verification.service.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/apps/verification/src/verification.service.ts b/apps/verification/src/verification.service.ts index b8fc4c9e9..10c1d494a 100644 --- a/apps/verification/src/verification.service.ts +++ b/apps/verification/src/verification.service.ts @@ -687,8 +687,6 @@ export class VerificationService { const extractedDataArray: IProofPresentationDetails[] = []; if (0 !== Object.keys(requestedAttributes).length && 0 !== Object.keys(requestedPredicates).length) { - - for (const key in requestedAttributes) { if (requestedAttributes.hasOwnProperty(key)) { @@ -699,10 +697,12 @@ export class VerificationService { credDefId = requestedAttributeKey?.restrictions[0]?.cred_def_id; schemaId = requestedAttributeKey?.restrictions[0]?.schema_id; + } else if (getProofPresentationById?.response?.presentation?.indy?.identifiers) { credDefId = getProofPresentationById?.response?.presentation?.indy?.identifiers[0].cred_def_id; schemaId = getProofPresentationById?.response?.presentation?.indy?.identifiers[0].schema_id; + } if (revealedAttrs.hasOwnProperty(key)) { @@ -717,11 +717,16 @@ export class VerificationService { } for (const key in requestedPredicates) { + if (requestedPredicates.hasOwnProperty(key)) { const attribute = requestedPredicates[key]; + const attributeName = attribute?.name; - const credDefId = attribute?.restrictions[0]?.cred_def_id; - const schemaId = attribute?.restrictions[0]?.schema_id; + + if (attribute?.restrictions) { + credDefId = attribute?.restrictions[0]?.cred_def_id; + schemaId = attribute?.restrictions[0]?.schema_id; + } const extractedData: IProofPresentationDetails = { [attributeName]: `${attribute?.p_type}${attribute?.p_value}`, @@ -755,6 +760,7 @@ export class VerificationService { } } } else if (0 !== Object.keys(requestedPredicates).length) { + for (const key in requestedPredicates) { if (requestedPredicates.hasOwnProperty(key)) { @@ -762,9 +768,8 @@ export class VerificationService { const attributeName = attribute?.name; [credDefId, schemaId] = await this._schemaCredDefRestriction(attribute, getProofPresentationById); - const extractedData: IProofPresentationDetails = { - [attributeName]: `${requestedPredicates?.p_type}${requestedPredicates?.p_value}`, + [attributeName]: `${attribute?.p_type}${attribute?.p_value}`, 'credDefId': credDefId || null, 'schemaId': schemaId || null };