@versini/auth-provider 5.0.5 → 5.0.6

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.
Files changed (2) hide show
  1. package/dist/index.js +42 -42
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -5,13 +5,13 @@ import { jsx as Ye } from "react/jsx-runtime";
5
5
  import * as U from "react";
6
6
  import { createContext as Be, useRef as Fe, useState as Ge, useCallback as de, useEffect as qe, useContext as ze } from "react";
7
7
  /*!
8
- @versini/auth-provider v5.0.5
8
+ @versini/auth-provider v5.0.6
9
9
  © 2024 gizmette.com
10
10
  */
11
11
  try {
12
12
  window.__VERSINI_AUTH_CLIENT__ || (window.__VERSINI_AUTH_CLIENT__ = {
13
- version: "5.0.5",
14
- buildTime: "07/05/2024 02:22 PM EDT",
13
+ version: "5.0.6",
14
+ buildTime: "07/06/2024 03:39 PM EDT",
15
15
  homepage: "https://github.com/aversini/auth-client",
16
16
  license: "MIT"
17
17
  });
@@ -24,7 +24,7 @@ try {
24
24
  try {
25
25
  window.__VERSINI_AUTH_COMMON__ || (window.__VERSINI_AUTH_COMMON__ = {
26
26
  version: "2.10.1",
27
- buildTime: "07/05/2024 02:22 PM EDT",
27
+ buildTime: "07/06/2024 03:39 PM EDT",
28
28
  homepage: "https://github.com/aversini/auth-client",
29
29
  license: "MIT"
30
30
  });
@@ -88,7 +88,7 @@ class C extends Error {
88
88
  super(t), this.code = "ERR_JOSE_GENERIC", this.name = this.constructor.name, (r = Error.captureStackTrace) == null || r.call(Error, this, this.constructor);
89
89
  }
90
90
  }
91
- class g extends C {
91
+ class A extends C {
92
92
  static get code() {
93
93
  return "ERR_JWT_CLAIM_VALIDATION_FAILED";
94
94
  }
@@ -564,8 +564,8 @@ async function _t(e, t, r) {
564
564
  let a = {};
565
565
  if (e.protected)
566
566
  try {
567
- const E = B(e.protected);
568
- a = JSON.parse(Q.decode(E));
567
+ const S = B(e.protected);
568
+ a = JSON.parse(Q.decode(S));
569
569
  } catch {
570
570
  throw new f("JWS Protected Header is invalid");
571
571
  }
@@ -600,17 +600,17 @@ async function _t(e, t, r) {
600
600
  }
601
601
  if (!await bt(i, t, p, m))
602
602
  throw new rt();
603
- let A;
603
+ let w;
604
604
  if (o)
605
605
  try {
606
- A = B(e.payload);
606
+ w = B(e.payload);
607
607
  } catch {
608
608
  throw new f("Failed to base64url decode the payload");
609
609
  }
610
610
  else
611
- typeof e.payload == "string" ? A = $.encode(e.payload) : A = e.payload;
612
- const w = { payload: A };
613
- return e.protected !== void 0 && (w.protectedHeader = a), e.header !== void 0 && (w.unprotectedHeader = e.header), d ? { ...w, key: t } : w;
611
+ typeof e.payload == "string" ? w = $.encode(e.payload) : w = e.payload;
612
+ const E = { payload: w };
613
+ return e.protected !== void 0 && (E.protectedHeader = a), e.header !== void 0 && (E.unprotectedHeader = e.header), d ? { ...E, key: t } : E;
614
614
  }
615
615
  async function vt(e, t, r) {
616
616
  if (e instanceof Uint8Array && (e = Q.decode(e)), typeof e != "string")
@@ -674,18 +674,18 @@ const Rt = (e) => Math.floor(e.getTime() / 1e3), Ue = 60, He = Ue * 60, ce = He
674
674
  throw new ve("JWT Claims Set must be a top-level JSON object");
675
675
  const { typ: n } = r;
676
676
  if (n && (typeof e.typ != "string" || ye(e.typ) !== ye(n)))
677
- throw new g('unexpected "typ" JWT header value', a, "typ", "check_failed");
677
+ throw new A('unexpected "typ" JWT header value', a, "typ", "check_failed");
678
678
  const { requiredClaims: s = [], issuer: o, subject: i, audience: c, maxTokenAge: d } = r, m = [...s];
679
679
  d !== void 0 && m.push("iat"), c !== void 0 && m.push("aud"), i !== void 0 && m.push("sub"), o !== void 0 && m.push("iss");
680
- for (const E of new Set(m.reverse()))
681
- if (!(E in a))
682
- throw new g(`missing required "${E}" claim`, a, E, "missing");
680
+ for (const S of new Set(m.reverse()))
681
+ if (!(S in a))
682
+ throw new A(`missing required "${S}" claim`, a, S, "missing");
683
683
  if (o && !(Array.isArray(o) ? o : [o]).includes(a.iss))
684
- throw new g('unexpected "iss" claim value', a, "iss", "check_failed");
684
+ throw new A('unexpected "iss" claim value', a, "iss", "check_failed");
685
685
  if (i && a.sub !== i)
686
- throw new g('unexpected "sub" claim value', a, "sub", "check_failed");
686
+ throw new A('unexpected "sub" claim value', a, "sub", "check_failed");
687
687
  if (c && !Ot(a.aud, typeof c == "string" ? [c] : c))
688
- throw new g('unexpected "aud" claim value', a, "aud", "check_failed");
688
+ throw new A('unexpected "aud" claim value', a, "aud", "check_failed");
689
689
  let p;
690
690
  switch (typeof r.clockTolerance) {
691
691
  case "string":
@@ -700,27 +700,27 @@ const Rt = (e) => Math.floor(e.getTime() / 1e3), Ue = 60, He = Ue * 60, ce = He
700
700
  default:
701
701
  throw new TypeError("Invalid clockTolerance option type");
702
702
  }
703
- const { currentDate: A } = r, w = Rt(A || /* @__PURE__ */ new Date());
703
+ const { currentDate: w } = r, E = Rt(w || /* @__PURE__ */ new Date());
704
704
  if ((a.iat !== void 0 || d) && typeof a.iat != "number")
705
- throw new g('"iat" claim must be a number', a, "iat", "invalid");
705
+ throw new A('"iat" claim must be a number', a, "iat", "invalid");
706
706
  if (a.nbf !== void 0) {
707
707
  if (typeof a.nbf != "number")
708
- throw new g('"nbf" claim must be a number', a, "nbf", "invalid");
709
- if (a.nbf > w + p)
710
- throw new g('"nbf" claim timestamp check failed', a, "nbf", "check_failed");
708
+ throw new A('"nbf" claim must be a number', a, "nbf", "invalid");
709
+ if (a.nbf > E + p)
710
+ throw new A('"nbf" claim timestamp check failed', a, "nbf", "check_failed");
711
711
  }
712
712
  if (a.exp !== void 0) {
713
713
  if (typeof a.exp != "number")
714
- throw new g('"exp" claim must be a number', a, "exp", "invalid");
715
- if (a.exp <= w - p)
714
+ throw new A('"exp" claim must be a number', a, "exp", "invalid");
715
+ if (a.exp <= E - p)
716
716
  throw new le('"exp" claim timestamp check failed', a, "exp", "check_failed");
717
717
  }
718
718
  if (d) {
719
- const E = w - a.iat, K = typeof d == "number" ? d : pe(d);
720
- if (E - p > K)
719
+ const S = E - a.iat, K = typeof d == "number" ? d : pe(d);
720
+ if (S - p > K)
721
721
  throw new le('"iat" claim timestamp check failed (too far in the past)', a, "iat", "check_failed");
722
- if (E < 0 - p)
723
- throw new g('"iat" claim timestamp check failed (it should be in the past)', a, "iat", "check_failed");
722
+ if (S < 0 - p)
723
+ throw new A('"iat" claim timestamp check failed (it should be in the past)', a, "iat", "check_failed");
724
724
  }
725
725
  return a;
726
726
  };
@@ -1068,11 +1068,11 @@ const Y = () => {
1068
1068
  key: `${V}::${r}::@@user@@`
1069
1069
  }), [i, c, , d] = x({
1070
1070
  key: `${V}::${r}::@@access@@`
1071
- }), [m, p, , A] = x(
1071
+ }), [m, p, , w] = x(
1072
1072
  {
1073
1073
  key: `${V}::${r}::@@refresh@@`
1074
1074
  }
1075
- ), [w, E, , K] = x({
1075
+ ), [E, S, , K] = x({
1076
1076
  key: `${V}::${r}::@@nonce@@`
1077
1077
  }), Le = new rr(i, m), [P, v] = Ge({
1078
1078
  isLoading: !0,
@@ -1086,9 +1086,9 @@ const Y = () => {
1086
1086
  isAuthenticated: !1,
1087
1087
  user: void 0,
1088
1088
  logoutReason: u || M
1089
- }), o(), d(), A(), K();
1089
+ }), o(), d(), w(), K();
1090
1090
  },
1091
- [o, d, K, A]
1091
+ [o, d, K, w]
1092
1092
  ), R = de(
1093
1093
  async (u) => {
1094
1094
  N(u || M), await Zt({
@@ -1127,12 +1127,12 @@ const Y = () => {
1127
1127
  a.current = !0;
1128
1128
  };
1129
1129
  }, [P.isLoading, n, R]);
1130
- const $e = async (u, k, S) => {
1130
+ const $e = async (u, k, g) => {
1131
1131
  const I = Gt();
1132
- if (E(I), v((ee) => ({
1132
+ if (S(I), v((ee) => ({
1133
1133
  ...ee,
1134
1134
  isLoading: !0
1135
- })), S === q.CODE) {
1135
+ })), o(), d(), w(), g === q.CODE) {
1136
1136
  const { code_verifier: ee, code_challenge: je } = await xt(), ue = await er({
1137
1137
  nonce: I,
1138
1138
  clientId: r,
@@ -1145,7 +1145,7 @@ const Y = () => {
1145
1145
  clientId: r,
1146
1146
  sessionExpiration: t,
1147
1147
  nonce: I,
1148
- type: S,
1148
+ type: g,
1149
1149
  code: ue.code,
1150
1150
  code_verifier: ee
1151
1151
  });
@@ -1167,7 +1167,7 @@ const Y = () => {
1167
1167
  clientId: r,
1168
1168
  sessionExpiration: t,
1169
1169
  nonce: I,
1170
- type: S
1170
+ type: g
1171
1171
  });
1172
1172
  return O.status ? (s(O.idToken), c(O.accessToken), p(O.refreshToken), v({
1173
1173
  isLoading: !1,
@@ -1188,12 +1188,12 @@ const Y = () => {
1188
1188
  if (I && I.payload[y.USER_ID_KEY] !== "")
1189
1189
  return i;
1190
1190
  }
1191
- const S = await Le.refreshtoken({
1191
+ const g = await Le.refreshtoken({
1192
1192
  clientId: r,
1193
1193
  userId: k.userId,
1194
- nonce: w
1194
+ nonce: E
1195
1195
  });
1196
- return S.status && S.status === "success" ? (c(S.newAccessToken), p(S.newRefreshToken), S.newAccessToken) : (await R(oe), "");
1196
+ return g.status && g.status === "success" ? (c(g.newAccessToken), p(g.newRefreshToken), g.newAccessToken) : (await R(oe), "");
1197
1197
  }
1198
1198
  return await R(oe), "";
1199
1199
  } catch {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@versini/auth-provider",
3
- "version": "5.0.5",
3
+ "version": "5.0.6",
4
4
  "license": "MIT",
5
5
  "author": "Arno Versini",
6
6
  "publishConfig": {
@@ -49,5 +49,5 @@
49
49
  "jose": "5.6.3",
50
50
  "uuid": "10.0.0"
51
51
  },
52
- "gitHead": "4a2ce0cc03567f791e235375cad30177adb6b15e"
52
+ "gitHead": "86d112a1eb52d8150f740a052decb9bf2cc0a4a7"
53
53
  }