Skip to content

Commit 0a59f20

Browse files
author
Matt Gaunt
authored
VAPID Expiration within 12 Hours
1 parent 28592a2 commit 0a59f20

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/vapid-helper.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ function getVapidHeaders(audience, subject, publicKey, privateKey, expiration) {
123123
publicKey = urlBase64.decode(publicKey);
124124
privateKey = urlBase64.decode(privateKey);
125125

126-
126+
const DEFAULT_EXPIRATION = Math.floor(Date.now() / 1000) + 43200;
127+
127128
if (expiration) {
128129
// TODO: Check if expiration is valid and use it in place of the hard coded
129130
// expiration of 24hours.
@@ -134,9 +135,11 @@ function getVapidHeaders(audience, subject, publicKey, privateKey, expiration) {
134135
alg: 'ES256'
135136
};
136137

138+
139+
137140
const jwtPayload = {
138141
aud: audience,
139-
exp: Math.floor(Date.now() / 1000) + 86400,
142+
exp: DEFAULT_EXPIRATION,
140143
sub: subject
141144
};
142145

0 commit comments

Comments
 (0)