From 8bcf779d33ea7d80a14bdc50cedf163ae042e516 Mon Sep 17 00:00:00 2001 From: Yarmo Mackenbach Date: Sun, 25 Oct 2020 00:39:43 +0200 Subject: [PATCH] Modify generateClaim behavior --- src/claimVerification.js | 4 ++-- src/utils.js | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/claimVerification.js b/src/claimVerification.js index 0184814..7b5980a 100644 --- a/src/claimVerification.js +++ b/src/claimVerification.js @@ -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 } diff --git a/src/utils.js b/src/utils.js index 0a333d5..63f5d52 100644 --- a/src/utils.js +++ b/src/utils.js @@ -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')