Skip to content

Commit cec3f92

Browse files
committed
Making expiration date optional on the JWT.
1 parent e37ef0e commit cec3f92

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/shc.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,19 @@ const URI_SCHEMA = 'shc';
99
* I am not sure if I should build this by hand.
1010
*/
1111
export async function makeJWT(payload, monthsToExpire, issuer, notBeforeDate) {
12-
let iss = new Date();
13-
let exp = new Date(iss);
12+
let today = new Date();
13+
let exp = new Date(today);
1414
exp.setMonth(exp.getMonth()+monthsToExpire);
1515

1616
let jwt = {
1717
iss: issuer,
18-
iat: Math.round(iss.getTime()/1000),
19-
exp: Math.round(exp.getTime()/1000),
2018
vc: payload
2119
};
2220

21+
if (monthsToExpire) {
22+
jwt['exp'] = Math.round(exp.getTime()/1000)
23+
}
24+
2325
if (notBeforeDate)
2426
jwt['nbf'] = Math.round(notBeforeDate.getTime()/1000);
2527

0 commit comments

Comments
 (0)