From 32c01756d39c4b46163abc73704ab52875e9aa78 Mon Sep 17 00:00:00 2001 From: Yarmo Mackenbach Date: Sat, 26 Dec 2020 13:56:36 +0100 Subject: [PATCH] Fix handling users without selfCertifications --- src/keys.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/keys.js b/src/keys.js index 84f8dac..820ef7d 100644 --- a/src/keys.js +++ b/src/keys.js @@ -159,14 +159,18 @@ const process = (publicKey) => { }, } - 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) + if ('selfCertifications' in user && user.selfCertifications.length >= 0) { + 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) + } } - } - ) + ) + } else { + usersOutput[i].notations = [] + } }) resolve({