mirror of
https://codeberg.org/keyoxide/doipjs.git
synced 2024-12-22 14:39:28 -07:00
Improve claim verification logic
This commit is contained in:
parent
5258da3353
commit
c5a1b2104d
1 changed files with 23 additions and 15 deletions
32
src/claim.js
32
src/claim.js
|
@ -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,10 +246,23 @@ class Claim {
|
|||
claimData,
|
||||
this._fingerprint
|
||||
)
|
||||
|
||||
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
|
||||
verificationResult = verificationResult || {
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue