From 438d47f63448ac97e6ce6d80c60dc09c8e628593 Mon Sep 17 00:00:00 2001 From: Sanjana Rajan Date: Tue, 24 Jul 2018 17:17:12 +0200 Subject: [PATCH] handle case where primary user doesn't exist when getting exp time --- src/key.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/key.js b/src/key.js index 4b6fdf69..4e90d1a2 100644 --- a/src/key.js +++ b/src/key.js @@ -484,6 +484,9 @@ Key.prototype.getExpirationTime = async function(capabilities, keyId, userId) { } if (this.keyPacket.version >= 4) { const primaryUser = await this.getPrimaryUser(null); + if (!primaryUser) { + throw new Error('Could not find primary user'); + } const selfCert = primaryUser.selfCertification; const keyExpiry = getExpirationTime(this.keyPacket, selfCert); const sigExpiry = selfCert.getExpirationTime();