mirror of
https://codeberg.org/keyoxide/doipjs.git
synced 2024-12-22 14:39:28 -07:00
Modify generateClaim behavior
This commit is contained in:
parent
80335a04f6
commit
8bcf779d33
2 changed files with 7 additions and 7 deletions
|
@ -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
|
||||
}
|
||||
|
|
10
src/utils.js
10
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')
|
||||
|
|
Loading…
Reference in a new issue