@versini/auth-provider 7.4.0 → 7.4.2
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.js +31 -31
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -4,13 +4,13 @@ var X = (e, t, r) => Tt(e, typeof t != "symbol" ? t + "" : t, r);
|
|
|
4
4
|
import { jsx as Oe } from "react/jsx-runtime";
|
|
5
5
|
import Rt, { useSyncExternalStore as _t, useCallback as D, useEffect as Je, createContext as It, useReducer as bt, useRef as kt, useContext as Ot } from "react";
|
|
6
6
|
/*!
|
|
7
|
-
@versini/auth-provider v7.4.
|
|
8
|
-
©
|
|
7
|
+
@versini/auth-provider v7.4.2
|
|
8
|
+
© 2025 gizmette.com
|
|
9
9
|
*/
|
|
10
10
|
try {
|
|
11
11
|
window.__VERSINI_AUTH_CLIENT__ || (window.__VERSINI_AUTH_CLIENT__ = {
|
|
12
|
-
version: "7.4.
|
|
13
|
-
buildTime: "
|
|
12
|
+
version: "7.4.2",
|
|
13
|
+
buildTime: "02/09/2025 06:14 PM EST",
|
|
14
14
|
homepage: "https://github.com/aversini/auth-client",
|
|
15
15
|
license: "MIT"
|
|
16
16
|
});
|
|
@@ -303,12 +303,12 @@ async function Ut(e, t = !1) {
|
|
|
303
303
|
}
|
|
304
304
|
/*!
|
|
305
305
|
@versini/auth-common v4.2.0
|
|
306
|
-
©
|
|
306
|
+
© 2025 gizmette.com
|
|
307
307
|
*/
|
|
308
308
|
try {
|
|
309
309
|
window.__VERSINI_AUTH_COMMON__ || (window.__VERSINI_AUTH_COMMON__ = {
|
|
310
310
|
version: "4.2.0",
|
|
311
|
-
buildTime: "
|
|
311
|
+
buildTime: "02/09/2025 06:14 PM EST",
|
|
312
312
|
homepage: "https://github.com/aversini/auth-client",
|
|
313
313
|
license: "MIT"
|
|
314
314
|
});
|
|
@@ -350,14 +350,14 @@ awIDAQAB
|
|
|
350
350
|
LOGIN: "login",
|
|
351
351
|
REFRESH: "refresh"
|
|
352
352
|
}, le = crypto, je = (e) => e instanceof CryptoKey, Z = new TextEncoder(), q = new TextDecoder();
|
|
353
|
-
function
|
|
353
|
+
function Ht(...e) {
|
|
354
354
|
const t = e.reduce((a, { length: s }) => a + s, 0), r = new Uint8Array(t);
|
|
355
355
|
let n = 0;
|
|
356
356
|
for (const a of e)
|
|
357
357
|
r.set(a, n), n += a.length;
|
|
358
358
|
return r;
|
|
359
359
|
}
|
|
360
|
-
const
|
|
360
|
+
const Wt = (e) => {
|
|
361
361
|
const t = atob(e), r = new Uint8Array(t.length);
|
|
362
362
|
for (let n = 0; n < t.length; n++)
|
|
363
363
|
r[n] = t.charCodeAt(n);
|
|
@@ -366,7 +366,7 @@ const Ht = (e) => {
|
|
|
366
366
|
let t = e;
|
|
367
367
|
t instanceof Uint8Array && (t = q.decode(t)), t = t.replace(/-/g, "+").replace(/_/g, "/").replace(/\s/g, "");
|
|
368
368
|
try {
|
|
369
|
-
return
|
|
369
|
+
return Wt(t);
|
|
370
370
|
} catch {
|
|
371
371
|
throw new TypeError("The input to be decoded is not correctly encoded.");
|
|
372
372
|
}
|
|
@@ -690,7 +690,7 @@ const Xe = async (e) => {
|
|
|
690
690
|
], a = { ...e };
|
|
691
691
|
return delete a.alg, delete a.use, le.subtle.importKey("jwk", a, ...n);
|
|
692
692
|
}, Ze = (e) => C(e);
|
|
693
|
-
let L,
|
|
693
|
+
let L, H;
|
|
694
694
|
const et = (e) => e?.[Symbol.toStringTag] === "KeyObject", ie = async (e, t, r, n, a = !1) => {
|
|
695
695
|
let s = e.get(t);
|
|
696
696
|
if (s != null && s[n])
|
|
@@ -700,9 +700,9 @@ const et = (e) => e?.[Symbol.toStringTag] === "KeyObject", ie = async (e, t, r,
|
|
|
700
700
|
}, rr = (e, t) => {
|
|
701
701
|
if (et(e)) {
|
|
702
702
|
let r = e.export({ format: "jwk" });
|
|
703
|
-
return delete r.d, delete r.dp, delete r.dq, delete r.p, delete r.q, delete r.qi, r.k ? Ze(r.k) : (
|
|
703
|
+
return delete r.d, delete r.dp, delete r.dq, delete r.p, delete r.q, delete r.qi, r.k ? Ze(r.k) : (H || (H = /* @__PURE__ */ new WeakMap()), ie(H, e, r, t));
|
|
704
704
|
}
|
|
705
|
-
return j(e) ? e.k ? C(e.k) : (
|
|
705
|
+
return j(e) ? e.k ? C(e.k) : (H || (H = /* @__PURE__ */ new WeakMap()), ie(H, e, e, t, !0)) : e;
|
|
706
706
|
}, nr = (e, t) => {
|
|
707
707
|
if (et(e)) {
|
|
708
708
|
let r = e.export({ format: "jwk" });
|
|
@@ -970,7 +970,7 @@ async function Er(e, t, r) {
|
|
|
970
970
|
throw new E("JWS Payload must be a string or an Uint8Array instance");
|
|
971
971
|
let h = !1;
|
|
972
972
|
typeof t == "function" ? (t = await t(n, e), h = !0, Ce(i, t, "verify"), j(t) && (t = await cr(t, i))) : Ce(i, t, "verify");
|
|
973
|
-
const y =
|
|
973
|
+
const y = Ht(Z.encode(e.protected ?? ""), Z.encode("."), typeof e.payload == "string" ? Z.encode(e.payload) : e.payload);
|
|
974
974
|
let p;
|
|
975
975
|
try {
|
|
976
976
|
p = C(e.signature);
|
|
@@ -1207,23 +1207,23 @@ const sn = async (e, t) => {
|
|
|
1207
1207
|
function at(e, t) {
|
|
1208
1208
|
window.dispatchEvent(new StorageEvent("storage", { key: e, newValue: t }));
|
|
1209
1209
|
}
|
|
1210
|
-
const
|
|
1210
|
+
const He = (e, t) => {
|
|
1211
1211
|
const r = JSON.stringify(
|
|
1212
1212
|
typeof t == "function" ? t() : t
|
|
1213
1213
|
);
|
|
1214
1214
|
window.localStorage.setItem(e, r), at(e, r);
|
|
1215
1215
|
}, Lr = (e) => {
|
|
1216
1216
|
window.localStorage.removeItem(e), at(e, null);
|
|
1217
|
-
},
|
|
1217
|
+
}, We = (e) => window.localStorage.getItem(e), Hr = (e) => (window.addEventListener("storage", e), () => window.removeEventListener("storage", e));
|
|
1218
1218
|
function te({
|
|
1219
1219
|
key: e,
|
|
1220
1220
|
initialValue: t
|
|
1221
1221
|
}) {
|
|
1222
|
-
const r = _t(
|
|
1222
|
+
const r = _t(Hr, () => We(e)), n = D(
|
|
1223
1223
|
(o) => {
|
|
1224
1224
|
try {
|
|
1225
1225
|
const i = typeof o == "function" ? o(JSON.parse(r)) : o;
|
|
1226
|
-
i == null ? Lr(e) :
|
|
1226
|
+
i == null ? Lr(e) : He(e, i);
|
|
1227
1227
|
} catch (i) {
|
|
1228
1228
|
console.warn(i);
|
|
1229
1229
|
}
|
|
@@ -1236,7 +1236,7 @@ function te({
|
|
|
1236
1236
|
}, [n]);
|
|
1237
1237
|
return Je(() => {
|
|
1238
1238
|
try {
|
|
1239
|
-
|
|
1239
|
+
We(e) === null && typeof t < "u" && He(e, t);
|
|
1240
1240
|
} catch (o) {
|
|
1241
1241
|
console.warn(o);
|
|
1242
1242
|
}
|
|
@@ -1245,7 +1245,7 @@ function te({
|
|
|
1245
1245
|
const w = [];
|
|
1246
1246
|
for (let e = 0; e < 256; ++e)
|
|
1247
1247
|
w.push((e + 256).toString(16).slice(1));
|
|
1248
|
-
function
|
|
1248
|
+
function Wr(e, t = 0) {
|
|
1249
1249
|
return (w[e[t + 0]] + w[e[t + 1]] + w[e[t + 2]] + w[e[t + 3]] + "-" + w[e[t + 4]] + w[e[t + 5]] + "-" + w[e[t + 6]] + w[e[t + 7]] + "-" + w[e[t + 8]] + w[e[t + 9]] + "-" + w[e[t + 10]] + w[e[t + 11]] + w[e[t + 12]] + w[e[t + 13]] + w[e[t + 14]] + w[e[t + 15]]).toLowerCase();
|
|
1250
1250
|
}
|
|
1251
1251
|
let ge;
|
|
@@ -1264,12 +1264,9 @@ function me(e, t, r) {
|
|
|
1264
1264
|
return $e.randomUUID();
|
|
1265
1265
|
e = e || {};
|
|
1266
1266
|
const n = e.random || (e.rng || Jr)();
|
|
1267
|
-
return n[6] = n[6] & 15 | 64, n[8] = n[8] & 63 | 128,
|
|
1267
|
+
return n[6] = n[6] & 15 | 64, n[8] = n[8] & 63 | 128, Wr(n);
|
|
1268
1268
|
}
|
|
1269
|
-
const
|
|
1270
|
-
dev: "https://auth.gizmette.local.com:3003",
|
|
1271
|
-
prod: "https://mylogin.gizmette.com/auth"
|
|
1272
|
-
}, re = "@@auth@@", B = "LOADING", ae = "LOGIN", ot = "LOGOUT", z = "success", O = "failure", st = "include", it = "POST", ct = "application/json", ne = {
|
|
1269
|
+
const W = "Your session has expired. For your security, please log in again to continue.", xr = "Your session has been successfully terminated.", we = "Login failed. Please try again.", Mr = "Error getting access token, please re-authenticate.", Gr = "You forgot to wrap your component in <AuthProvider>.", re = "@@auth@@", B = "LOADING", ae = "LOGIN", ot = "LOGOUT", z = "success", O = "failure", st = "include", it = "POST", ct = "application/json", ne = {
|
|
1273
1270
|
GET_REGISTRATION_OPTIONS: `mutation GetPasskeyRegistrationOptions(
|
|
1274
1271
|
$clientId: String!,
|
|
1275
1272
|
$username: String!,
|
|
@@ -1428,7 +1425,10 @@ const H = "Your session has expired. For your security, please log in again to c
|
|
|
1428
1425
|
} catch (n) {
|
|
1429
1426
|
return console.error(n), { status: O, data: [] };
|
|
1430
1427
|
}
|
|
1431
|
-
}, Vr = process.env.NODE_ENV === "production", ut = !Vr,
|
|
1428
|
+
}, Vr = process.env.NODE_ENV === "production", ut = !Vr, ce = {
|
|
1429
|
+
dev: process.env.PUBLIC_AUTH_SERVER_URL || "https://auth.gizmette.local.com:3003",
|
|
1430
|
+
prod: "https://mylogin.gizmette.com/auth"
|
|
1431
|
+
}, lt = {
|
|
1432
1432
|
isLoading: !0,
|
|
1433
1433
|
isAuthenticated: !1,
|
|
1434
1434
|
user: void 0,
|
|
@@ -1700,7 +1700,7 @@ const Xr = (e) => D(
|
|
|
1700
1700
|
), o({
|
|
1701
1701
|
type: ot,
|
|
1702
1702
|
payload: {
|
|
1703
|
-
logoutReason: u ||
|
|
1703
|
+
logoutReason: u || W
|
|
1704
1704
|
}
|
|
1705
1705
|
}), Q(), o({ type: B, payload: { isLoading: !1 } });
|
|
1706
1706
|
},
|
|
@@ -1716,7 +1716,7 @@ const Xr = (e) => D(
|
|
|
1716
1716
|
clientId: r,
|
|
1717
1717
|
domain: n,
|
|
1718
1718
|
idToken: h
|
|
1719
|
-
}), F(u ||
|
|
1719
|
+
}), F(u || W);
|
|
1720
1720
|
},
|
|
1721
1721
|
[h, s, r, n, F, i]
|
|
1722
1722
|
);
|
|
@@ -1735,11 +1735,11 @@ const Xr = (e) => D(
|
|
|
1735
1735
|
email: u.payload[f.EMAIL_KEY]
|
|
1736
1736
|
}
|
|
1737
1737
|
}
|
|
1738
|
-
})) : (i("useEffect: invalid JWT, invalidating and logging out"), await N(
|
|
1738
|
+
})) : (i("useEffect: invalid JWT, invalidating and logging out"), await N(W));
|
|
1739
1739
|
} catch {
|
|
1740
1740
|
i(
|
|
1741
1741
|
"useEffect: exception validating JWT, invalidating and logging out"
|
|
1742
|
-
), await N(
|
|
1742
|
+
), await N(W);
|
|
1743
1743
|
}
|
|
1744
1744
|
})() : (i("useEffect: setting the loading state to false"), o({ type: B, payload: { isLoading: !1 } })), () => {
|
|
1745
1745
|
c.current = !0;
|
|
@@ -1801,11 +1801,11 @@ const Xr = (e) => D(
|
|
|
1801
1801
|
});
|
|
1802
1802
|
return d.status && d.status === "success" && d.newAccessToken ? (T(d.newAccessToken), pe(d.newRefreshToken), d.newAccessToken) : (i(
|
|
1803
1803
|
"getAccessToken: invalid refresh token, need to re-authenticate"
|
|
1804
|
-
), await N(
|
|
1804
|
+
), await N(W), "");
|
|
1805
1805
|
}
|
|
1806
1806
|
return i(
|
|
1807
1807
|
"getAccessToken: user is not authenticated, cannot get access token"
|
|
1808
|
-
), await N(
|
|
1808
|
+
), await N(W), "";
|
|
1809
1809
|
} catch {
|
|
1810
1810
|
return i(
|
|
1811
1811
|
"getAccessToken: exception occurred, invalidating and logging out"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@versini/auth-provider",
|
|
3
|
-
"version": "7.4.
|
|
3
|
+
"version": "7.4.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Arno Versini",
|
|
6
6
|
"publishConfig": {
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"jose": "5.9.6",
|
|
47
47
|
"uuid": "11.0.3"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "540c722611c468e14a0b765c6f9758c0dd040e24"
|
|
50
50
|
}
|