Fix verification logic

This commit is contained in:
Yarmo Mackenbach 2022-10-25 09:22:25 +02:00
parent f64f9cff58
commit 2c722d31a9
No known key found for this signature in database
GPG key ID: 37367F4AF4087AD1
2 changed files with 9 additions and 7 deletions

View file

@ -251,7 +251,9 @@ class Claim {
// Post process the data
if (claimData.functions && claimData.functions.postprocess) {
try {
({ claimData, proofData } = claimData.functions.postprocess(claimData, proofData))
} catch (_) {}
}
} else {
// Consider the proof completed but with a negative result
@ -261,12 +263,12 @@ class Claim {
proof: {},
errors: [proofFetchError]
}
}
if (this.isAmbiguous()) {
if (this.isAmbiguous() && !verificationResult.result) {
// Assume a wrong match and continue
continue
}
}
if (verificationResult.completed) {
// Store the result, keep a single match and stop verifying
@ -283,7 +285,7 @@ class Claim {
result: false,
completed: true,
proof: {},
errors: ['Unknown error']
errors: []
}
this._status = E.ClaimStatus.VERIFIED

View file

@ -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')
}