unjwt 0.5.6 → 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.DQNXDqfd.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.DQNXDqfd.mjs';
4
+ export { s as sign, v as verify } from './shared/unjwt.BZCtr-eB.mjs';
@@ -33,9 +33,8 @@ async function sign(payload, key, options = {}) {
33
33
  const currentTime = Math.round(
34
34
  (options.currentDate ?? /* @__PURE__ */ new Date()).getTime() / 1e3
35
35
  );
36
- const iat = typeof payload.iat === "number" ? payload.iat : currentTime;
37
- computedPayload.iat = iat;
38
- computedPayload.exp = iat + options.expiresIn;
36
+ computedPayload.iat ||= currentTime;
37
+ computedPayload.exp = currentTime + options.expiresIn;
39
38
  }
40
39
  const protectedHeaderString = JSON.stringify(protectedHeader);
41
40
  const protectedHeaderEncoded = base64UrlEncode(protectedHeaderString);
@@ -173,7 +172,7 @@ async function verify(jws, key, options = {}) {
173
172
  );
174
173
  }
175
174
  }
176
- if (payload && typeof payload === "object" && !options.forceUint8Array) {
175
+ if (payload && typeof payload === "object" && protectedHeader.typ === "JWT" && !options.forceUint8Array) {
177
176
  const jwtClaims = payload;
178
177
  const clockTolerance = options.clockTolerance ?? 0;
179
178
  const currentTime = Math.round(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unjwt",
3
- "version": "0.5.6",
3
+ "version": "0.5.8",
4
4
  "description": "Low-level JWT utilities",
5
5
  "repository": "sandros94/unjwt",
6
6
  "license": "MIT",