From 580510d0d0f2ce2b4f8455cfa30c6797e0f7ac06 Mon Sep 17 00:00:00 2001 From: Yarmo Mackenbach Date: Fri, 20 Nov 2020 23:20:26 +0100 Subject: [PATCH] Make claims.verify handle notations from all users --- src/claims.js | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/claims.js b/src/claims.js index 6e76bd0..3d1b813 100644 --- a/src/claims.js +++ b/src/claims.js @@ -108,9 +108,24 @@ const runVerification = (proofData, spData) => { const verify = async (input, fingerprint, opts) => { if (input instanceof openpgp.key.Key) { - const fingerprintLocal = await keys.getFingerprint(input) - const claims = await keys.getClaims(input) - return await verify(claims, fingerprintLocal, opts) + const fingerprintFromKey = await keys.getFingerprint(input) + const userData = await keys.getUserData(input) + + const promises = userData.map(async (user, i) => { + return new Promise(async (resolve, reject) => { + try { + const res = await verify(user.notations, fingerprintFromKey, opts) + resolve(res) + } catch (e) { + console.error(`Claim verification failed: ${user.userData.id}`, e) + reject(e) + } + }) + }) + + return Promise.all(promises).then((values) => { + return values + }) } if (input instanceof Array) { const promises = input.map(async (uri, i) => {