From 4738a8b68c2cbc6c15a1352d2c22ebba7bda839a Mon Sep 17 00:00:00 2001 From: Filip Skokan Date: Mon, 11 Nov 2019 21:57:26 +0100 Subject: [PATCH] fix: regression introduced in 58f7348 --- lib/helpers/jwt.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/helpers/jwt.js b/lib/helpers/jwt.js index 108a48df2..ad878e7b7 100644 --- a/lib/helpers/jwt.js +++ b/lib/helpers/jwt.js @@ -143,12 +143,12 @@ class JWT { try { ({ protected: header, payload } = JWS.verify(jwt, keyOrStore, opts)); } catch (err) { - if (isKeyStore(keyOrStore) && keyOrStore.stale()) { - await keyOrStore.refresh(); - ({ protected: header, payload } = JWS.verify(jwt, keyOrStore, opts)); - } else { + if (!isKeyStore(keyOrStore) || typeof keyOrStore.fresh !== 'function' || keyOrStore.fresh()) { throw err; } + + await keyOrStore.refresh(); + ({ protected: header, payload } = JWS.verify(jwt, keyOrStore, opts)); } payload = JSON.parse(payload);