mirror of
https://codeberg.org/keyoxide/doipjs.git
synced 2024-12-22 22:49: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) => {
|
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
|
||||||
}
|
}
|
||||||
|
|
10
src/utils.js
10
src/utils.js
|
@ -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')
|
||||||
|
|
Loading…
Reference in a new issue