Improve claim verification logic

This commit is contained in:
Yarmo Mackenbach 2022-09-26 15:55:34 +02:00
parent 5258da3353
commit c5a1b2104d
No known key found for this signature in database
GPG key ID: 37367F4AF4087AD1

View file

@ -169,6 +169,13 @@ class Claim {
}
const candidate = def.processURI(this._uri)
// If the candidate is valid but the URI could not be processed,
// continue matching
if (!candidate) {
return true
}
if (candidate.match.isAmbiguous) {
// Add to the possible candidates
this._matches.push(candidate)
@ -239,9 +246,22 @@ class Claim {
claimData,
this._fingerprint
)
verificationResult.proof = {
fetcher: proofData.fetcher,
viaProxy: proofData.viaProxy
if (verificationResult.completed) {
if (!verificationResult.result && this.isAmbiguous()) {
// Assume a wrong match and continue
continue
}
verificationResult.proof = {
fetcher: proofData.fetcher,
viaProxy: proofData.viaProxy
}
// Store the result, keep a single match and stop verifying
this._verification = verificationResult
this._matches = [claimData]
index = this._matches.length
}
} else {
// Consider the proof completed but with a negative result
@ -251,18 +271,6 @@ class Claim {
proof: {},
errors: [proofFetchError]
}
if (this.isAmbiguous()) {
// Assume a wrong match and continue
continue
}
}
if (verificationResult.completed) {
// Store the result, keep a single match and stop verifying
this._verification = verificationResult
this._matches = [claimData]
index = this._matches.length
}
}