unjwt 0.5.35 → 0.5.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -215,15 +215,15 @@ async function sealJWESession(event, config) {
215
215
  const key = getEncryptKey(config.key || config.secret);
216
216
  const sessionName = config.name || DEFAULT_NAME$1;
217
217
  const session = event.context.sessions?.[sessionName] || await getJWESession(event, config);
218
- const iatSeconds = Math.floor(session.createdAt / 1e3);
219
- const expSeconds = config.maxAge === void 0 ? void 0 : iatSeconds + computeExpiresInSeconds(config.maxAge);
218
+ const iat = Math.floor(Date.now() / 1e3);
219
+ const exp = config.maxAge === void 0 ? void 0 : iat + computeExpiresInSeconds(config.maxAge);
220
220
  const payload = {
221
221
  ...session.data,
222
222
  jti: session.id,
223
- iat: iatSeconds
223
+ iat
224
224
  };
225
- if (expSeconds) {
226
- payload.exp = expSeconds;
225
+ if (exp) {
226
+ payload.exp = exp;
227
227
  }
228
228
  let typ = void 0;
229
229
  if (config.jwe?.encryptOptions?.protectedHeader?.typ && typeof config.jwe.encryptOptions.protectedHeader.typ === "string" && config.jwe.encryptOptions.protectedHeader.typ.toLowerCase().includes("jwt")) {
@@ -563,15 +563,15 @@ async function signJWSSession(event, config) {
563
563
  const key = getSignKey(config.key);
564
564
  const sessionName = config.name || DEFAULT_NAME;
565
565
  const session = event.context.sessions?.[sessionName] || await getJWSSession(event, config);
566
- const iatSeconds = Math.floor(session.createdAt / 1e3);
567
- const expSeconds = config.maxAge === void 0 ? void 0 : iatSeconds + computeExpiresInSeconds(config.maxAge);
566
+ const iat = Math.floor(Date.now() / 1e3);
567
+ const exp = config.maxAge === void 0 ? void 0 : iat + computeExpiresInSeconds(config.maxAge);
568
568
  const payload = {
569
569
  ...session.data,
570
570
  jti: session.id,
571
- iat: iatSeconds
571
+ iat
572
572
  };
573
- if (expSeconds) {
574
- payload.exp = expSeconds;
573
+ if (exp) {
574
+ payload.exp = exp;
575
575
  }
576
576
  let typ = void 0;
577
577
  if (config.jws?.signOptions?.protectedHeader?.typ && typeof config.jws.signOptions.protectedHeader.typ === "string" && config.jws.signOptions.protectedHeader.typ.toLowerCase().includes("jwt")) {
@@ -175,15 +175,15 @@ async function sealJWESession(event, config) {
175
175
  const sessionName = config.name || DEFAULT_NAME$1;
176
176
  const context = getEventContext(event);
177
177
  const session = context.sessions?.[sessionName] || await getJWESession(event, config);
178
- const iatSeconds = Math.floor(session.createdAt / 1e3);
179
- const expSeconds = config.maxAge === void 0 ? void 0 : iatSeconds + computeExpiresInSeconds(config.maxAge);
178
+ const iat = Math.floor(Date.now() / 1e3);
179
+ const exp = config.maxAge === void 0 ? void 0 : iat + computeExpiresInSeconds(config.maxAge);
180
180
  const payload = {
181
181
  ...session.data,
182
182
  jti: session.id,
183
- iat: iatSeconds
183
+ iat
184
184
  };
185
- if (expSeconds) {
186
- payload.exp = expSeconds;
185
+ if (exp) {
186
+ payload.exp = exp;
187
187
  }
188
188
  let typ = void 0;
189
189
  if (config.jwe?.encryptOptions?.protectedHeader?.typ && typeof config.jwe.encryptOptions.protectedHeader.typ === "string" && config.jwe.encryptOptions.protectedHeader.typ.toLowerCase().includes("jwt")) {
@@ -488,15 +488,15 @@ async function signJWSSession(event, config) {
488
488
  const sessionName = config.name || DEFAULT_NAME;
489
489
  const context = getEventContext(event);
490
490
  const session = context.sessions?.[sessionName] || await getJWSSession(event, config);
491
- const iatSeconds = Math.floor(session.createdAt / 1e3);
492
- const expSeconds = config.maxAge === void 0 ? void 0 : iatSeconds + computeExpiresInSeconds(config.maxAge);
491
+ const iat = Math.floor(Date.now() / 1e3);
492
+ const exp = config.maxAge === void 0 ? void 0 : iat + computeExpiresInSeconds(config.maxAge);
493
493
  const payload = {
494
494
  ...session.data,
495
495
  jti: session.id,
496
- iat: iatSeconds
496
+ iat
497
497
  };
498
- if (expSeconds) {
499
- payload.exp = expSeconds;
498
+ if (exp) {
499
+ payload.exp = exp;
500
500
  }
501
501
  let typ;
502
502
  if (config.jws?.signOptions?.protectedHeader?.typ && typeof config.jws.signOptions.protectedHeader.typ === "string" && config.jws.signOptions.protectedHeader.typ.toLowerCase().includes("jwt")) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unjwt",
3
- "version": "0.5.35",
3
+ "version": "0.5.36",
4
4
  "description": "Low-level JWT utilities",
5
5
  "repository": "sandros94/unjwt",
6
6
  "license": "MIT",