Modify generateClaim behavior

This commit is contained in:
Yarmo Mackenbach 2020-10-25 00:39:43 +02:00
parent 80335a04f6
commit 8bcf779d33
2 changed files with 7 additions and 7 deletions

View file

@ -42,10 +42,10 @@ const runOnJson = (proofData, checkPath, checkClaim, checkRelation) => {
const run = (proofData, spData) => {
switch (spData.proof.format) {
case 'json':
return runOnJson(proofData, spData.claim.path, utils.generateClaim(spData), spData.claim.relation)
return runOnJson(proofData, spData.claim.path, utils.generateClaim(spData.claim.fingerprint, spData.claim.format), spData.claim.relation)
break
case 'text':
re = new RegExp(utils.generateClaim(spData), "gi")
re = new RegExp(utils.generateClaim(spData.claim.fingerprint, spData.claim.format), "gi")
return re.test(proofData.replace(/\r?\n|\r/, ''))
break
}

View file

@ -1,13 +1,13 @@
const generateClaim = (spData) => {
switch (spData.claim.format) {
const generateClaim = (fingerprint, format) => {
switch (format) {
case 'uri':
return `openpgp4fpr:${spData.claim.fingerprint}`
return `openpgp4fpr:${fingerprint}`
break;
case 'message':
return `[Verifying my OpenPGP key: openpgp4fpr:${spData.claim.fingerprint}]`
return `[Verifying my OpenPGP key: openpgp4fpr:${fingerprint}]`
break;
case 'fingerprint':
return pData.claim.fingerprint
return fingerprint
break;
default:
throw new Error('No valid claim format')