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) => { const run = (proofData, spData) => {
switch (spData.proof.format) { switch (spData.proof.format) {
case 'json': 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 break
case 'text': 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/, '')) return re.test(proofData.replace(/\r?\n|\r/, ''))
break break
} }

View file

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