Run prettier

This commit is contained in:
Yarmo Mackenbach 2021-01-07 16:17:24 +01:00
parent 9db48d627d
commit 6c2aa92187
2 changed files with 10 additions and 7 deletions

View file

@ -20,7 +20,8 @@ const keys = require('./keys')
const verify = (signature, opts) => { const verify = (signature, opts) => {
return new Promise(async (resolve, reject) => { return new Promise(async (resolve, reject) => {
let errors = [], sigData let errors = [],
sigData
try { try {
sigData = await openpgp.cleartext.readArmored(signature) sigData = await openpgp.cleartext.readArmored(signature)
} catch (error) { } catch (error) {
@ -44,7 +45,7 @@ const verify = (signature, opts) => {
case 'proof': case 'proof':
sigClaims.push(match[2]) sigClaims.push(match[2])
break break
default: default:
break break
} }
@ -54,10 +55,10 @@ const verify = (signature, opts) => {
errors.push('no_linked_keys') errors.push('no_linked_keys')
reject({ errors: errors }) reject({ errors: errors })
} }
const keyData = await keys.fetch.uri(sigKeys[0]) const keyData = await keys.fetch.uri(sigKeys[0])
const fingerprint = keyData.keyPacket.getFingerprint() const fingerprint = keyData.keyPacket.getFingerprint()
try { try {
const sigVerification = await sigData.verify([keyData]) const sigVerification = await sigData.verify([keyData])
await sigVerification[0].verified await sigVerification[0].verified
@ -72,9 +73,9 @@ const verify = (signature, opts) => {
errors: errors, errors: errors,
publicKey: keyData, publicKey: keyData,
fingerprint: fingerprint, fingerprint: fingerprint,
claims: claimVerifications claims: claimVerifications,
}) })
}) })
} }
exports.verify = verify exports.verify = verify

View file

@ -49,7 +49,9 @@ describe('signatures.verify', () => {
it('should verify the demonstration signature', async () => { it('should verify the demonstration signature', async () => {
const verification = await doipjs.signatures.verify(sigProfile) const verification = await doipjs.signatures.verify(sigProfile)
expect(verification.errors).to.be.length(0) expect(verification.errors).to.be.length(0)
expect(verification.fingerprint).to.be.equal('3637202523e7c1309ab79e99ef2dc5827b445f4b') expect(verification.fingerprint).to.be.equal(
'3637202523e7c1309ab79e99ef2dc5827b445f4b'
)
expect(verification.claims).to.be.length(1) expect(verification.claims).to.be.length(1)
expect(verification.claims[0].isVerified).to.be.true expect(verification.claims[0].isVerified).to.be.true
}) })