From 33f4b5c882864a99aad346436ea3942d569153ea Mon Sep 17 00:00:00 2001 From: Yarmo Mackenbach Date: Fri, 20 Nov 2020 22:53:56 +0100 Subject: [PATCH] Make keys.process get notations from all users --- src/keys.js | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/src/keys.js b/src/keys.js index 5e1abec..887cd0e 100644 --- a/src/keys.js +++ b/src/keys.js @@ -144,11 +144,33 @@ const fetchURI = async (uri) => { const process = async (publicKey) => { try { const fingerprint = await publicKey.primaryKey.getFingerprint() - const user = await publicKey.getPrimaryUser() + const primaryUser = await publicKey.getPrimaryUser() + const users = publicKey.users + let primaryUserIndex, usersOutput = [] + + users.forEach((user, i) => { + usersOutput[i] = { + userData: { + id: user.userId.userid, + name: user.userId.name, + email: user.userId.email, + comment: user.userId.comment, + isPrimary: primaryUser.index === i + } + } + + const notations = user.selfCertifications[0].rawNotations + usersOutput[i].notations = notations.map(({ name, value, humanReadable }) => { + if (humanReadable && name === 'proof@metacode.biz') { + return openpgp.util.decode_utf8(value) + } + }) + }) return { fingerprint: fingerprint, - user: user, + users: usersOutput, + primaryUserIndex: primaryUser.index, } } catch (e) { console.error(e) @@ -156,18 +178,11 @@ const process = async (publicKey) => { } } -const getClaims = async (publicKey) => { +const getUserData = async (publicKey) => { try { const keyData = await process(publicKey) - let notations = keyData.user.selfCertification.rawNotations - notations = notations.map(({ name, value, humanReadable }) => { - if (humanReadable && name === 'proof@metacode.biz') { - return openpgp.util.decode_utf8(value) - } - }) - - return notations + return keyData.users } catch (e) { console.error(e) return undefined @@ -194,5 +209,5 @@ exports.fetch = { signature: fetchSignature, } exports.process = process -exports.getClaims = getClaims +exports.getUserData = getUserData exports.getFingerprint = getFingerprint