unjwt 0.5.7 → 0.5.8

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.
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  export { i as utils } from './shared/unjwt.BHpknTpg.mjs';
2
2
  export { j as jwe } from './shared/unjwt.B2olxeGL.mjs';
3
3
  export { j as jwk } from './shared/unjwt.DRUXIabl.mjs';
4
- export { j as jws } from './shared/unjwt.DqUOpdA-.mjs';
4
+ export { j as jws } from './shared/unjwt.BZCtr-eB.mjs';
5
5
  import './shared/unjwt.Ca03jPX3.mjs';
package/dist/jws.mjs CHANGED
@@ -1,4 +1,4 @@
1
1
  import './shared/unjwt.DRUXIabl.mjs';
2
2
  import './shared/unjwt.BHpknTpg.mjs';
3
3
  import './shared/unjwt.Ca03jPX3.mjs';
4
- export { s as sign, v as verify } from './shared/unjwt.DqUOpdA-.mjs';
4
+ export { s as sign, v as verify } from './shared/unjwt.BZCtr-eB.mjs';
@@ -30,9 +30,11 @@ async function sign(payload, key, options = {}) {
30
30
  let computedPayload = void 0;
31
31
  if (options.expiresIn !== void 0 && protectedHeader.typ === "JWT" && typeof payload === "object" && !(payload instanceof Uint8Array) && !payload.exp) {
32
32
  computedPayload = { ...payload };
33
- const iat = typeof payload.iat === "number" ? payload.iat : Math.round((options.currentDate ?? /* @__PURE__ */ new Date()).getTime() / 1e3);
34
- computedPayload.iat = iat;
35
- computedPayload.exp = iat + options.expiresIn;
33
+ const currentTime = Math.round(
34
+ (options.currentDate ?? /* @__PURE__ */ new Date()).getTime() / 1e3
35
+ );
36
+ computedPayload.iat ||= currentTime;
37
+ computedPayload.exp = currentTime + options.expiresIn;
36
38
  }
37
39
  const protectedHeaderString = JSON.stringify(protectedHeader);
38
40
  const protectedHeaderEncoded = base64UrlEncode(protectedHeaderString);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unjwt",
3
- "version": "0.5.7",
3
+ "version": "0.5.8",
4
4
  "description": "Low-level JWT utilities",
5
5
  "repository": "sandros94/unjwt",
6
6
  "license": "MIT",