@versini/auth-provider 2.1.1 → 2.1.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 +88 -84
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import * as
|
|
3
|
-
import { useRef as
|
|
1
|
+
import { jsx as oe } from "react/jsx-runtime";
|
|
2
|
+
import * as b from "react";
|
|
3
|
+
import { useRef as ae, useEffect as Y, createContext as se, useState as ie, useContext as ce } from "react";
|
|
4
4
|
/*!
|
|
5
|
-
@versini/auth-provider v2.1.
|
|
5
|
+
@versini/auth-provider v2.1.2
|
|
6
6
|
© 2024 gizmette.com
|
|
7
7
|
*/
|
|
8
8
|
try {
|
|
9
9
|
window.__VERSINI_AUTH_CLIENT__ || (window.__VERSINI_AUTH_CLIENT__ = {
|
|
10
|
-
version: "2.1.
|
|
11
|
-
buildTime: "06/24/2024
|
|
10
|
+
version: "2.1.2",
|
|
11
|
+
buildTime: "06/24/2024 05:12 PM EDT",
|
|
12
12
|
homepage: "https://github.com/aversini/auth-client",
|
|
13
13
|
license: "MIT"
|
|
14
14
|
});
|
|
@@ -21,55 +21,55 @@ try {
|
|
|
21
21
|
try {
|
|
22
22
|
window.__VERSINI_AUTH_COMMON__ || (window.__VERSINI_AUTH_COMMON__ = {
|
|
23
23
|
version: "2.1.0",
|
|
24
|
-
buildTime: "06/24/2024
|
|
24
|
+
buildTime: "06/24/2024 05:12 PM EDT",
|
|
25
25
|
homepage: "https://github.com/aversini/auth-client",
|
|
26
26
|
license: "MIT"
|
|
27
27
|
});
|
|
28
28
|
} catch {
|
|
29
29
|
}
|
|
30
|
-
const
|
|
30
|
+
const ue = {
|
|
31
31
|
ID_TOKEN: "id_token"
|
|
32
|
-
},
|
|
32
|
+
}, de = {
|
|
33
33
|
CLIENT_ID: "X-Auth-ClientId"
|
|
34
|
-
},
|
|
34
|
+
}, A = {
|
|
35
35
|
ALG: "RS256",
|
|
36
36
|
USER_ID_KEY: "_id",
|
|
37
37
|
ISSUER: "gizmette.com"
|
|
38
38
|
};
|
|
39
|
-
function
|
|
39
|
+
function q(e, t) {
|
|
40
40
|
window.dispatchEvent(new StorageEvent("storage", { key: e, newValue: t }));
|
|
41
41
|
}
|
|
42
42
|
const D = (e, t) => {
|
|
43
43
|
const n = JSON.stringify(
|
|
44
44
|
typeof t == "function" ? t() : t
|
|
45
45
|
);
|
|
46
|
-
window.localStorage.setItem(e, n),
|
|
47
|
-
},
|
|
48
|
-
window.localStorage.removeItem(e),
|
|
49
|
-
}, K = (e) => window.localStorage.getItem(e),
|
|
50
|
-
function
|
|
46
|
+
window.localStorage.setItem(e, n), q(e, n);
|
|
47
|
+
}, le = (e) => {
|
|
48
|
+
window.localStorage.removeItem(e), q(e, null);
|
|
49
|
+
}, K = (e) => window.localStorage.getItem(e), fe = (e) => (window.addEventListener("storage", e), () => window.removeEventListener("storage", e));
|
|
50
|
+
function he({
|
|
51
51
|
key: e,
|
|
52
52
|
initialValue: t
|
|
53
53
|
}) {
|
|
54
|
-
const n = () => K(e), r =
|
|
55
|
-
|
|
54
|
+
const n = () => K(e), r = b.useSyncExternalStore(
|
|
55
|
+
fe,
|
|
56
56
|
n
|
|
57
|
-
), o =
|
|
57
|
+
), o = b.useCallback(
|
|
58
58
|
(i) => {
|
|
59
59
|
try {
|
|
60
60
|
const c = typeof i == "function" ? i(JSON.parse(r)) : i;
|
|
61
|
-
c == null ?
|
|
61
|
+
c == null ? le(e) : D(e, c);
|
|
62
62
|
} catch (c) {
|
|
63
63
|
console.warn(c);
|
|
64
64
|
}
|
|
65
65
|
},
|
|
66
66
|
[e, r]
|
|
67
|
-
), s =
|
|
67
|
+
), s = b.useCallback(() => {
|
|
68
68
|
o(t);
|
|
69
|
-
}, [t, o]), a =
|
|
69
|
+
}, [t, o]), a = b.useCallback(() => {
|
|
70
70
|
o(null);
|
|
71
71
|
}, [o]);
|
|
72
|
-
return
|
|
72
|
+
return b.useEffect(() => {
|
|
73
73
|
try {
|
|
74
74
|
K(e) === null && typeof t < "u" && D(e, t);
|
|
75
75
|
} catch (i) {
|
|
@@ -77,7 +77,7 @@ function fe({
|
|
|
77
77
|
}
|
|
78
78
|
}, [e, t]), [r ? JSON.parse(r) : null, o, s, a];
|
|
79
79
|
}
|
|
80
|
-
const
|
|
80
|
+
const L = "Oops! It looks like your session has expired. For your security, please log in again to continue.", pe = "Your session has been successfully terminated.", me = "You forgot to wrap your component in <AuthProvider>.", W = {
|
|
81
81
|
dev: "https://auth.gizmette.local.com:3003",
|
|
82
82
|
prod: "https://mylogin.gizmette.com"
|
|
83
83
|
}, ye = "@@auth@@", Se = `-----BEGIN PUBLIC KEY-----
|
|
@@ -88,7 +88,7 @@ aMwPFOIcJH+rKfFgNcHLcaS5syp7zU1ANwZ+trgR+DifBr8TLVkBynmNeTyhDm2+
|
|
|
88
88
|
l0haqjMk0UoNPPE8iYBWUHQJJE1Dqstj65d6Eh5g64Pao25y4cmYJbKjiblIGEkE
|
|
89
89
|
sjqybA9mARAqh9k/eiIopecWSiffNQTwVQVd2I9ZH3BalhEXHlqFgrjz51kFqg81
|
|
90
90
|
awIDAQAB
|
|
91
|
-
-----END PUBLIC KEY-----`, J = crypto,
|
|
91
|
+
-----END PUBLIC KEY-----`, J = crypto, z = (e) => e instanceof CryptoKey, _ = new TextEncoder(), R = new TextDecoder();
|
|
92
92
|
function we(...e) {
|
|
93
93
|
const t = e.reduce((o, { length: s }) => o + s, 0), n = new Uint8Array(t);
|
|
94
94
|
let r = 0;
|
|
@@ -127,7 +127,7 @@ class m extends g {
|
|
|
127
127
|
super(t), this.code = "ERR_JWT_CLAIM_VALIDATION_FAILED", this.claim = r, this.reason = o, this.payload = n;
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
|
-
class
|
|
130
|
+
class H extends g {
|
|
131
131
|
static get code() {
|
|
132
132
|
return "ERR_JWT_EXPIRED";
|
|
133
133
|
}
|
|
@@ -159,7 +159,7 @@ class l extends g {
|
|
|
159
159
|
return "ERR_JWS_INVALID";
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
|
-
class
|
|
162
|
+
class X extends g {
|
|
163
163
|
constructor() {
|
|
164
164
|
super(...arguments), this.code = "ERR_JWT_INVALID";
|
|
165
165
|
}
|
|
@@ -167,7 +167,7 @@ class z extends g {
|
|
|
167
167
|
return "ERR_JWT_INVALID";
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
|
-
class
|
|
170
|
+
class Ae extends g {
|
|
171
171
|
constructor() {
|
|
172
172
|
super(...arguments), this.code = "ERR_JWS_SIGNATURE_VERIFICATION_FAILED", this.message = "signature verification failed";
|
|
173
173
|
}
|
|
@@ -184,7 +184,7 @@ function T(e, t) {
|
|
|
184
184
|
function O(e) {
|
|
185
185
|
return parseInt(e.name.slice(4), 10);
|
|
186
186
|
}
|
|
187
|
-
function
|
|
187
|
+
function be(e) {
|
|
188
188
|
switch (e) {
|
|
189
189
|
case "ES256":
|
|
190
190
|
return "P-256";
|
|
@@ -249,7 +249,7 @@ function _e(e, t, ...n) {
|
|
|
249
249
|
case "ES512": {
|
|
250
250
|
if (!T(e.algorithm, "ECDSA"))
|
|
251
251
|
throw S("ECDSA");
|
|
252
|
-
const r =
|
|
252
|
+
const r = be(t);
|
|
253
253
|
if (e.algorithm.namedCurve !== r)
|
|
254
254
|
throw S(r, "algorithm.namedCurve");
|
|
255
255
|
break;
|
|
@@ -259,7 +259,7 @@ function _e(e, t, ...n) {
|
|
|
259
259
|
}
|
|
260
260
|
Ie(e, n);
|
|
261
261
|
}
|
|
262
|
-
function
|
|
262
|
+
function j(e, t, ...n) {
|
|
263
263
|
var r;
|
|
264
264
|
if (n.length > 2) {
|
|
265
265
|
const o = n.pop();
|
|
@@ -268,11 +268,11 @@ function X(e, t, ...n) {
|
|
|
268
268
|
n.length === 2 ? e += `one of type ${n[0]} or ${n[1]}.` : e += `of type ${n[0]}.`;
|
|
269
269
|
return t == null ? e += ` Received ${t}` : typeof t == "function" && t.name ? e += ` Received function ${t.name}` : typeof t == "object" && t != null && (r = t.constructor) != null && r.name && (e += ` Received an instance of ${t.constructor.name}`), e;
|
|
270
270
|
}
|
|
271
|
-
const
|
|
272
|
-
function
|
|
273
|
-
return
|
|
271
|
+
const $ = (e, ...t) => j("Key must be ", e, ...t);
|
|
272
|
+
function Q(e, t, ...n) {
|
|
273
|
+
return j(`Key for the ${e} algorithm must be `, t, ...n);
|
|
274
274
|
}
|
|
275
|
-
const
|
|
275
|
+
const Z = (e) => z(e), E = ["CryptoKey"], Te = (...e) => {
|
|
276
276
|
const t = e.filter(Boolean);
|
|
277
277
|
if (t.length === 0 || t.length === 1)
|
|
278
278
|
return !0;
|
|
@@ -317,7 +317,7 @@ const Re = (e, t) => {
|
|
|
317
317
|
return !1;
|
|
318
318
|
const o = e.subarray(r, r + t.length);
|
|
319
319
|
return o.length !== t.length ? !1 : o.every((s, a) => s === t[a]) || w(e, t, r + 1);
|
|
320
|
-
},
|
|
320
|
+
}, M = (e) => {
|
|
321
321
|
switch (!0) {
|
|
322
322
|
case w(e, [42, 134, 72, 206, 61, 3, 1, 7]):
|
|
323
323
|
return "P-256";
|
|
@@ -372,12 +372,12 @@ const Re = (e, t) => {
|
|
|
372
372
|
case "ECDH-ES+A128KW":
|
|
373
373
|
case "ECDH-ES+A192KW":
|
|
374
374
|
case "ECDH-ES+A256KW": {
|
|
375
|
-
const c =
|
|
375
|
+
const c = M(i);
|
|
376
376
|
s = c.startsWith("P-") ? { name: "ECDH", namedCurve: c } : { name: c }, a = [];
|
|
377
377
|
break;
|
|
378
378
|
}
|
|
379
379
|
case "EdDSA":
|
|
380
|
-
s = { name:
|
|
380
|
+
s = { name: M(i) }, a = ["verify"];
|
|
381
381
|
break;
|
|
382
382
|
default:
|
|
383
383
|
throw new C('Invalid or unsupported "alg" (Algorithm) value');
|
|
@@ -391,14 +391,14 @@ async function xe(e, t, n) {
|
|
|
391
391
|
}
|
|
392
392
|
const Oe = (e, t) => {
|
|
393
393
|
if (!(t instanceof Uint8Array)) {
|
|
394
|
-
if (!
|
|
395
|
-
throw new TypeError(
|
|
394
|
+
if (!Z(t))
|
|
395
|
+
throw new TypeError(Q(e, t, ...E, "Uint8Array"));
|
|
396
396
|
if (t.type !== "secret")
|
|
397
397
|
throw new TypeError(`${E.join(" or ")} instances for symmetric algorithms must be of type "secret"`);
|
|
398
398
|
}
|
|
399
399
|
}, Ne = (e, t, n) => {
|
|
400
|
-
if (!
|
|
401
|
-
throw new TypeError(
|
|
400
|
+
if (!Z(t))
|
|
401
|
+
throw new TypeError(Q(e, t, ...E));
|
|
402
402
|
if (t.type === "secret")
|
|
403
403
|
throw new TypeError(`${E.join(" or ")} instances for asymmetric algorithms must not be of type "secret"`);
|
|
404
404
|
if (t.algorithm && n === "verify" && t.type === "private")
|
|
@@ -459,14 +459,14 @@ function De(e, t) {
|
|
|
459
459
|
}
|
|
460
460
|
}
|
|
461
461
|
function Ke(e, t, n) {
|
|
462
|
-
if (
|
|
462
|
+
if (z(t))
|
|
463
463
|
return _e(t, e, n), t;
|
|
464
464
|
if (t instanceof Uint8Array) {
|
|
465
465
|
if (!e.startsWith("HS"))
|
|
466
|
-
throw new TypeError(
|
|
466
|
+
throw new TypeError($(t, ...E));
|
|
467
467
|
return J.subtle.importKey("raw", t, { hash: `SHA-${e.slice(-3)}`, name: "HMAC" }, !1, [n]);
|
|
468
468
|
}
|
|
469
|
-
throw new TypeError(
|
|
469
|
+
throw new TypeError($(t, ...E, "Uint8Array"));
|
|
470
470
|
}
|
|
471
471
|
const Le = async (e, t, n, r) => {
|
|
472
472
|
const o = await Ke(e, t, "verify");
|
|
@@ -529,7 +529,7 @@ async function We(e, t, n) {
|
|
|
529
529
|
throw new l("Failed to base64url decode the signature");
|
|
530
530
|
}
|
|
531
531
|
if (!await Le(i, t, u, y))
|
|
532
|
-
throw new
|
|
532
|
+
throw new Ae();
|
|
533
533
|
let f;
|
|
534
534
|
if (a)
|
|
535
535
|
try {
|
|
@@ -551,7 +551,7 @@ async function He(e, t, n) {
|
|
|
551
551
|
const i = await We({ payload: o, protected: r, signature: s }, t, n), c = { payload: i.payload, protectedHeader: i.protectedHeader };
|
|
552
552
|
return typeof t == "function" ? { ...c, key: i.key } : c;
|
|
553
553
|
}
|
|
554
|
-
const $e = (e) => Math.floor(e.getTime() / 1e3),
|
|
554
|
+
const $e = (e) => Math.floor(e.getTime() / 1e3), ee = 60, te = ee * 60, k = te * 24, Me = k * 7, Ve = k * 365.25, Be = /^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i, V = (e) => {
|
|
555
555
|
const t = Be.exec(e);
|
|
556
556
|
if (!t || t[4] && t[1])
|
|
557
557
|
throw new TypeError("Invalid time period format");
|
|
@@ -570,14 +570,14 @@ const $e = (e) => Math.floor(e.getTime() / 1e3), Z = 60, ee = Z * 60, k = ee * 2
|
|
|
570
570
|
case "min":
|
|
571
571
|
case "mins":
|
|
572
572
|
case "m":
|
|
573
|
-
o = Math.round(n *
|
|
573
|
+
o = Math.round(n * ee);
|
|
574
574
|
break;
|
|
575
575
|
case "hour":
|
|
576
576
|
case "hours":
|
|
577
577
|
case "hr":
|
|
578
578
|
case "hrs":
|
|
579
579
|
case "h":
|
|
580
|
-
o = Math.round(n *
|
|
580
|
+
o = Math.round(n * te);
|
|
581
581
|
break;
|
|
582
582
|
case "day":
|
|
583
583
|
case "days":
|
|
@@ -594,16 +594,16 @@ const $e = (e) => Math.floor(e.getTime() / 1e3), Z = 60, ee = Z * 60, k = ee * 2
|
|
|
594
594
|
break;
|
|
595
595
|
}
|
|
596
596
|
return t[1] === "-" || t[4] === "ago" ? -o : o;
|
|
597
|
-
},
|
|
597
|
+
}, B = (e) => e.toLowerCase().replace(/^application\//, ""), Fe = (e, t) => typeof e == "string" ? t.includes(e) : Array.isArray(e) ? t.some(Set.prototype.has.bind(new Set(e))) : !1, Ge = (e, t, n = {}) => {
|
|
598
598
|
let r;
|
|
599
599
|
try {
|
|
600
600
|
r = JSON.parse(R.decode(t));
|
|
601
601
|
} catch {
|
|
602
602
|
}
|
|
603
603
|
if (!U(r))
|
|
604
|
-
throw new
|
|
604
|
+
throw new X("JWT Claims Set must be a top-level JSON object");
|
|
605
605
|
const { typ: o } = n;
|
|
606
|
-
if (o && (typeof e.typ != "string" ||
|
|
606
|
+
if (o && (typeof e.typ != "string" || B(e.typ) !== B(o)))
|
|
607
607
|
throw new m('unexpected "typ" JWT header value', r, "typ", "check_failed");
|
|
608
608
|
const { requiredClaims: s = [], issuer: a, subject: i, audience: c, maxTokenAge: h } = n, y = [...s];
|
|
609
609
|
h !== void 0 && y.push("iat"), c !== void 0 && y.push("aud"), i !== void 0 && y.push("sub"), a !== void 0 && y.push("iss");
|
|
@@ -619,7 +619,7 @@ const $e = (e) => Math.floor(e.getTime() / 1e3), Z = 60, ee = Z * 60, k = ee * 2
|
|
|
619
619
|
let u;
|
|
620
620
|
switch (typeof n.clockTolerance) {
|
|
621
621
|
case "string":
|
|
622
|
-
u =
|
|
622
|
+
u = V(n.clockTolerance);
|
|
623
623
|
break;
|
|
624
624
|
case "number":
|
|
625
625
|
u = n.clockTolerance;
|
|
@@ -643,12 +643,12 @@ const $e = (e) => Math.floor(e.getTime() / 1e3), Z = 60, ee = Z * 60, k = ee * 2
|
|
|
643
643
|
if (typeof r.exp != "number")
|
|
644
644
|
throw new m('"exp" claim must be a number', r, "exp", "invalid");
|
|
645
645
|
if (r.exp <= f - u)
|
|
646
|
-
throw new
|
|
646
|
+
throw new H('"exp" claim timestamp check failed', r, "exp", "check_failed");
|
|
647
647
|
}
|
|
648
648
|
if (h) {
|
|
649
|
-
const p = f - r.iat, P = typeof h == "number" ? h :
|
|
649
|
+
const p = f - r.iat, P = typeof h == "number" ? h : V(h);
|
|
650
650
|
if (p - u > P)
|
|
651
|
-
throw new
|
|
651
|
+
throw new H('"iat" claim timestamp check failed (too far in the past)', r, "iat", "check_failed");
|
|
652
652
|
if (p < 0 - u)
|
|
653
653
|
throw new m('"iat" claim timestamp check failed (it should be in the past)', r, "iat", "check_failed");
|
|
654
654
|
}
|
|
@@ -658,7 +658,7 @@ async function Ye(e, t, n) {
|
|
|
658
658
|
var a;
|
|
659
659
|
const r = await He(e, t, n);
|
|
660
660
|
if ((a = r.protectedHeader.crit) != null && a.includes("b64") && r.protectedHeader.b64 === !1)
|
|
661
|
-
throw new
|
|
661
|
+
throw new X("JWTs MUST NOT use unencoded payload");
|
|
662
662
|
const s = { payload: Ge(r.protectedHeader, r.payload, n), protectedHeader: r.protectedHeader };
|
|
663
663
|
return typeof t == "function" ? { ...s, key: r.key } : s;
|
|
664
664
|
}
|
|
@@ -675,12 +675,12 @@ function Xe() {
|
|
|
675
675
|
return v(ze);
|
|
676
676
|
}
|
|
677
677
|
var je = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
678
|
-
const
|
|
678
|
+
const F = {
|
|
679
679
|
randomUUID: je
|
|
680
680
|
};
|
|
681
681
|
function Qe(e, t, n) {
|
|
682
|
-
if (
|
|
683
|
-
return
|
|
682
|
+
if (F.randomUUID && !t && !e)
|
|
683
|
+
return F.randomUUID();
|
|
684
684
|
e = e || {};
|
|
685
685
|
var r = e.random || (e.rng || Xe)();
|
|
686
686
|
return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, qe(r);
|
|
@@ -688,13 +688,13 @@ function Qe(e, t, n) {
|
|
|
688
688
|
const Ze = process.env.NODE_ENV === "production", et = !Ze, tt = async ({ params: e = {} }) => {
|
|
689
689
|
try {
|
|
690
690
|
const t = Qe(), n = await fetch(
|
|
691
|
-
et ? `${
|
|
691
|
+
et ? `${W.dev}/authenticate` : `${W.prod}/authenticate`,
|
|
692
692
|
{
|
|
693
693
|
credentials: "include",
|
|
694
694
|
method: "POST",
|
|
695
695
|
headers: {
|
|
696
696
|
"Content-Type": "application/json",
|
|
697
|
-
[
|
|
697
|
+
[de.CLIENT_ID]: `${e.clientId}`
|
|
698
698
|
},
|
|
699
699
|
body: JSON.stringify({ ...e, nonce: t })
|
|
700
700
|
}
|
|
@@ -710,11 +710,11 @@ const Ze = process.env.NODE_ENV === "production", et = !Ze, tt = async ({ params
|
|
|
710
710
|
} catch (t) {
|
|
711
711
|
return console.error(t), { status: 500, data: [] };
|
|
712
712
|
}
|
|
713
|
-
},
|
|
713
|
+
}, re = async (e, t) => {
|
|
714
714
|
try {
|
|
715
|
-
const n =
|
|
715
|
+
const n = A.ALG, o = await xe(Se, n);
|
|
716
716
|
return await Ye(e, o, {
|
|
717
|
-
issuer:
|
|
717
|
+
issuer: A.ISSUER,
|
|
718
718
|
audience: t
|
|
719
719
|
});
|
|
720
720
|
} catch {
|
|
@@ -729,16 +729,16 @@ const Ze = process.env.NODE_ENV === "production", et = !Ze, tt = async ({ params
|
|
|
729
729
|
try {
|
|
730
730
|
const o = await tt({
|
|
731
731
|
params: {
|
|
732
|
-
type:
|
|
732
|
+
type: ue.ID_TOKEN,
|
|
733
733
|
username: e,
|
|
734
734
|
password: t,
|
|
735
735
|
sessionExpiration: r,
|
|
736
736
|
clientId: n
|
|
737
737
|
}
|
|
738
|
-
}), s = await
|
|
739
|
-
return s && s.payload[
|
|
738
|
+
}), s = await re(o.data.idToken, n);
|
|
739
|
+
return s && s.payload[A.USER_ID_KEY] !== "" ? {
|
|
740
740
|
idToken: o.data.idToken,
|
|
741
|
-
userId: s.payload[
|
|
741
|
+
userId: s.payload[A.USER_ID_KEY],
|
|
742
742
|
status: !0
|
|
743
743
|
} : {
|
|
744
744
|
status: !1
|
|
@@ -750,17 +750,17 @@ const Ze = process.env.NODE_ENV === "production", et = !Ze, tt = async ({ params
|
|
|
750
750
|
}
|
|
751
751
|
};
|
|
752
752
|
function nt(e) {
|
|
753
|
-
const t =
|
|
754
|
-
return
|
|
753
|
+
const t = ae();
|
|
754
|
+
return Y(() => {
|
|
755
755
|
t.current = e;
|
|
756
756
|
}), t.current;
|
|
757
757
|
}
|
|
758
|
-
const
|
|
758
|
+
const G = () => {
|
|
759
759
|
throw new Error(me);
|
|
760
|
-
},
|
|
760
|
+
}, ne = se({
|
|
761
761
|
isAuthenticated: !1,
|
|
762
|
-
login:
|
|
763
|
-
logout:
|
|
762
|
+
login: G,
|
|
763
|
+
logout: G,
|
|
764
764
|
accessToken: void 0,
|
|
765
765
|
refreshToken: void 0,
|
|
766
766
|
idToken: void 0,
|
|
@@ -770,26 +770,30 @@ const F = () => {
|
|
|
770
770
|
sessionExpiration: t,
|
|
771
771
|
clientId: n
|
|
772
772
|
}) => {
|
|
773
|
-
const [r, o, , s] =
|
|
773
|
+
const [r, o, , s] = he({
|
|
774
774
|
key: `${ye}::${n}::@@user@@`
|
|
775
|
-
}), [a, i] =
|
|
775
|
+
}), [a, i] = ie({
|
|
776
776
|
isAuthenticated: !!r,
|
|
777
777
|
logoutReason: "",
|
|
778
778
|
userId: ""
|
|
779
779
|
}), c = nt(r) || "";
|
|
780
|
-
|
|
780
|
+
Y(() => {
|
|
781
781
|
c !== r && r !== null && (async () => {
|
|
782
782
|
try {
|
|
783
|
-
const u = await
|
|
784
|
-
u && u.payload[
|
|
783
|
+
const u = await re(r, n);
|
|
784
|
+
u && u.payload[A.USER_ID_KEY] !== "" ? i({
|
|
785
785
|
isAuthenticated: !0,
|
|
786
786
|
logoutReason: "",
|
|
787
|
-
userId: u.payload[
|
|
787
|
+
userId: u.payload[A.USER_ID_KEY]
|
|
788
|
+
}) : i({
|
|
789
|
+
isAuthenticated: !1,
|
|
790
|
+
logoutReason: L,
|
|
791
|
+
userId: ""
|
|
788
792
|
});
|
|
789
793
|
} catch {
|
|
790
794
|
i({
|
|
791
795
|
isAuthenticated: !1,
|
|
792
|
-
logoutReason:
|
|
796
|
+
logoutReason: L,
|
|
793
797
|
userId: ""
|
|
794
798
|
});
|
|
795
799
|
}
|
|
@@ -813,8 +817,8 @@ const F = () => {
|
|
|
813
817
|
userId: ""
|
|
814
818
|
}), s();
|
|
815
819
|
};
|
|
816
|
-
return /* @__PURE__ */ ne
|
|
817
|
-
}, it = (e =
|
|
820
|
+
return /* @__PURE__ */ oe(ne.Provider, { value: { ...a, login: h, logout: y }, children: e });
|
|
821
|
+
}, it = (e = ne) => ce(e);
|
|
818
822
|
export {
|
|
819
823
|
st as AuthProvider,
|
|
820
824
|
it as useAuth
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@versini/auth-provider",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Arno Versini",
|
|
6
6
|
"publishConfig": {
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"jose": "5.4.1",
|
|
50
50
|
"uuid": "10.0.0"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "3a70e5d3382595c6fad816559e819eacd0431e3b"
|
|
53
53
|
}
|