mirror of
https://codeberg.org/keyoxide/doipjs.git
synced 2024-12-22 22:49: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
38
src/claim.js
38
src/claim.js
|
@ -169,6 +169,13 @@ class Claim {
|
||||||
}
|
}
|
||||||
|
|
||||||
const candidate = def.processURI(this._uri)
|
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) {
|
if (candidate.match.isAmbiguous) {
|
||||||
// Add to the possible candidates
|
// Add to the possible candidates
|
||||||
this._matches.push(candidate)
|
this._matches.push(candidate)
|
||||||
|
@ -239,9 +246,22 @@ class Claim {
|
||||||
claimData,
|
claimData,
|
||||||
this._fingerprint
|
this._fingerprint
|
||||||
)
|
)
|
||||||
verificationResult.proof = {
|
|
||||||
fetcher: proofData.fetcher,
|
if (verificationResult.completed) {
|
||||||
viaProxy: proofData.viaProxy
|
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 {
|
} else {
|
||||||
// Consider the proof completed but with a negative result
|
// Consider the proof completed but with a negative result
|
||||||
|
@ -251,18 +271,6 @@ class Claim {
|
||||||
proof: {},
|
proof: {},
|
||||||
errors: [proofFetchError]
|
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