From 1373f145879261000bb2dccbac41a0ccf842b0ec Mon Sep 17 00:00:00 2001 From: Yarmo Mackenbach Date: Thu, 31 Aug 2023 14:38:03 +0200 Subject: [PATCH] fix: handle doip promise rejection --- src/server/openpgpProfiles.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/server/openpgpProfiles.js b/src/server/openpgpProfiles.js index 2192bbe..c0086af 100644 --- a/src/server/openpgpProfiles.js +++ b/src/server/openpgpProfiles.js @@ -102,7 +102,16 @@ const fetchWKD = (id) => { reject(new Error('No public keys could be read from the data fetched using WKD')) } - profile = await doipjs.openpgp.parsePublicKey(publicKey) + try { + profile = await doipjs.openpgp.parsePublicKey(publicKey) + } catch (error) { + profile = null + } + + if (!profile) { + reject(new Error('No public keys could be fetched using WKD')) + return + } profile.publicKey.fetch.method = 'wkd' profile.publicKey.fetch.query = id profile.publicKey.fetch.resolvedUrl = fetchURL