From 2c722d31a9c0a5aa6da963b7573e920e037e6e42 Mon Sep 17 00:00:00 2001 From: Yarmo Mackenbach Date: Tue, 25 Oct 2022 09:22:25 +0200 Subject: [PATCH] Fix verification logic --- src/claim.js | 14 ++++++++------ src/verifications.js | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/claim.js b/src/claim.js index b3db90b..eff8343 100644 --- a/src/claim.js +++ b/src/claim.js @@ -251,7 +251,9 @@ class Claim { // Post process the data if (claimData.functions && claimData.functions.postprocess) { - ({ claimData, proofData } = claimData.functions.postprocess(claimData, proofData)) + try { + ({ claimData, proofData } = claimData.functions.postprocess(claimData, proofData)) + } catch (_) {} } } else { // Consider the proof completed but with a negative result @@ -261,11 +263,11 @@ class Claim { proof: {}, errors: [proofFetchError] } + } - if (this.isAmbiguous()) { - // Assume a wrong match and continue - continue - } + if (this.isAmbiguous() && !verificationResult.result) { + // Assume a wrong match and continue + continue } if (verificationResult.completed) { @@ -283,7 +285,7 @@ class Claim { result: false, completed: true, proof: {}, - errors: ['Unknown error'] + errors: [] } this._status = E.ClaimStatus.VERIFIED diff --git a/src/verifications.js b/src/verifications.js index 41f9637..e24ddd7 100644 --- a/src/verifications.js +++ b/src/verifications.js @@ -172,7 +172,7 @@ const runJSON = async (proofData, checkPath, checkClaim, checkClaimFormat, check } } - if (!(checkPath[0] in proofData)) { + if (typeof proofData === 'object' && !(checkPath[0] in proofData)) { throw new Error('err_json_structure_incorrect') }