Improve property name

This commit is contained in:
Yarmo Mackenbach 2021-04-30 15:32:34 +02:00
parent b643815fee
commit e718c02628
No known key found for this signature in database
GPG key ID: 37367F4AF4087AD1

View file

@ -29,7 +29,7 @@ const E = require('./enums')
* @property {string} fingerprint - The fingerprint to verify the claim against * @property {string} fingerprint - The fingerprint to verify the claim against
* @property {string} status - The current status of the claim * @property {string} status - The current status of the claim
* @property {Array<object>} matches - The claim definitions matched against the URI * @property {Array<object>} matches - The claim definitions matched against the URI
* @property {object} result - The result of the verification process * @property {object} verification - The result of the verification process
*/ */
class Claim { class Claim {
/** /**
@ -41,6 +41,7 @@ class Claim {
* const claim = doip.Claim(); * const claim = doip.Claim();
* const claim = doip.Claim('dns:domain.tld?type=TXT'); * const claim = doip.Claim('dns:domain.tld?type=TXT');
* const claim = doip.Claim('dns:domain.tld?type=TXT', '123abc123abc'); * const claim = doip.Claim('dns:domain.tld?type=TXT', '123abc123abc');
* const claimAlt = doip.Claim(JSON.stringify(claim));
*/ */
constructor(uri, fingerprint) { constructor(uri, fingerprint) {
// Import JSON // Import JSON
@ -52,7 +53,7 @@ class Claim {
this._fingerprint = data.fingerprint this._fingerprint = data.fingerprint
this._status = data.status this._status = data.status
this._matches = data.matches this._matches = data.matches
this._result = data.result this._verification = data.verification
break break
default: default:
@ -80,7 +81,7 @@ class Claim {
this._fingerprint = fingerprint ? fingerprint : null this._fingerprint = fingerprint ? fingerprint : null
this._status = E.ClaimStatus.INIT this._status = E.ClaimStatus.INIT
this._matches = null this._matches = null
this._result = null this._verification = null
} }
get uri() { get uri() {
@ -102,11 +103,11 @@ class Claim {
return this._matches return this._matches
} }
get result() { get verification() {
if (this._status !== E.ClaimStatus.VERIFIED) { if (this._status !== E.ClaimStatus.VERIFIED) {
throw new Error('This claim has not yet been verified') throw new Error('This claim has not yet been verified')
} }
return this._result return this._verification
} }
set uri(uri) { set uri(uri) {
@ -142,7 +143,7 @@ class Claim {
throw new Error("Cannot change a claim's matches") throw new Error("Cannot change a claim's matches")
} }
set result(anything) { set verification(anything) {
throw new Error("Cannot change a claim's verification result") throw new Error("Cannot change a claim's verification result")
} }
@ -250,7 +251,7 @@ class Claim {
if (verificationResult.completed) { if (verificationResult.completed) {
// Store the result, keep a single match and stop verifying // Store the result, keep a single match and stop verifying
this._result = verificationResult this._verification = verificationResult
this._matches = [claimData] this._matches = [claimData]
index = this._matches.length index = this._matches.length
} }
@ -291,7 +292,7 @@ class Claim {
fingerprint: this._fingerprint, fingerprint: this._fingerprint,
status: this._status, status: this._status,
matches: this._matches, matches: this._matches,
result: this._result, verification: this._verification,
} }
} }
} }