From cec3f92752eb52f85de0f7d943369f059d079fd6 Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Thu, 23 Dec 2021 11:52:54 -0500 Subject: [PATCH] Making expiration date optional on the JWT. --- lib/shc.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/shc.js b/lib/shc.js index 82f5bbc..3339b7f 100644 --- a/lib/shc.js +++ b/lib/shc.js @@ -9,17 +9,19 @@ const URI_SCHEMA = 'shc'; * I am not sure if I should build this by hand. */ export async function makeJWT(payload, monthsToExpire, issuer, notBeforeDate) { - let iss = new Date(); - let exp = new Date(iss); + let today = new Date(); + let exp = new Date(today); exp.setMonth(exp.getMonth()+monthsToExpire); let jwt = { iss: issuer, - iat: Math.round(iss.getTime()/1000), - exp: Math.round(exp.getTime()/1000), vc: payload }; + if (monthsToExpire) { + jwt['exp'] = Math.round(exp.getTime()/1000) + } + if (notBeforeDate) jwt['nbf'] = Math.round(notBeforeDate.getTime()/1000);