@axa-fr/react-oidc 6.25.6 → 7.0.0
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/README.md +79 -69
- package/dist/FetchToken.d.ts +1 -2
- package/dist/OidcProvider.d.ts +2 -3
- package/dist/OidcSecure.d.ts +1 -2
- package/dist/ReactOidc.d.ts +1 -2
- package/dist/User.d.ts +1 -2
- package/dist/core/default-component/AuthenticateError.component.d.ts +0 -1
- package/dist/core/default-component/Authenticating.component.d.ts +0 -1
- package/dist/core/default-component/Callback.component.d.ts +0 -1
- package/dist/core/default-component/Loading.component.d.ts +0 -1
- package/dist/core/default-component/ServiceWorkerNotSupported.component.d.ts +0 -1
- package/dist/core/default-component/SessionLost.component.d.ts +0 -1
- package/dist/core/default-component/SilentCallback.component.d.ts +0 -1
- package/dist/core/default-component/SilentLogin.component.d.ts +0 -1
- package/dist/core/default-component/index.d.ts +0 -1
- package/dist/core/routes/OidcRoutes.d.ts +0 -1
- package/dist/core/routes/index.d.ts.map +1 -1
- package/dist/core/routes/withRouter.d.ts +0 -1
- package/dist/index.d.ts +2 -3
- package/dist/index.js +43 -43
- package/dist/index.umd.cjs +10 -10
- package/package.json +3 -11
- package/src/FetchToken.tsx +3 -3
- package/src/OidcProvider.tsx +19 -19
- package/src/OidcSecure.tsx +2 -2
- package/src/ReactOidc.tsx +19 -19
- package/src/User.ts +2 -2
- package/src/core/default-component/Callback.component.tsx +2 -2
- package/src/core/default-component/SilentCallback.component.tsx +2 -2
- package/src/core/default-component/SilentLogin.component.tsx +2 -2
- package/src/core/routes/OidcRoutes.spec.tsx +4 -3
- package/src/core/routes/OidcRoutes.tsx +1 -1
- package/src/core/routes/withRouter.spec.tsx +4 -3
- package/src/index.ts +2 -2
- package/dist/FetchToken.d.ts.map +0 -1
- package/dist/OidcProvider.d.ts.map +0 -1
- package/dist/OidcSecure.d.ts.map +0 -1
- package/dist/ReactOidc.d.ts.map +0 -1
- package/dist/User.d.ts.map +0 -1
- package/dist/core/default-component/AuthenticateError.component.d.ts.map +0 -1
- package/dist/core/default-component/Authenticating.component.d.ts.map +0 -1
- package/dist/core/default-component/Callback.component.d.ts.map +0 -1
- package/dist/core/default-component/Loading.component.d.ts.map +0 -1
- package/dist/core/default-component/ServiceWorkerNotSupported.component.d.ts.map +0 -1
- package/dist/core/default-component/SessionLost.component.d.ts.map +0 -1
- package/dist/core/default-component/SilentCallback.component.d.ts.map +0 -1
- package/dist/core/default-component/SilentLogin.component.d.ts.map +0 -1
- package/dist/core/default-component/index.d.ts.map +0 -1
- package/dist/core/routes/OidcRoutes.d.ts.map +0 -1
- package/dist/core/routes/withRouter.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import be, { useCallback as kt, useState as P, useEffect as O } from "react";
|
|
2
|
-
import {
|
|
3
|
-
import { TokenRenewMode as rr } from "@axa-fr/
|
|
2
|
+
import { OidcClient as f, getParseQueryStringFromLocation as mt, getPath as z, getFetchDefault as Et } from "@axa-fr/oidc-client";
|
|
3
|
+
import { TokenRenewMode as rr } from "@axa-fr/oidc-client";
|
|
4
4
|
var ye = { exports: {} }, G = {};
|
|
5
5
|
/**
|
|
6
6
|
* @license React
|
|
@@ -18,14 +18,14 @@ function Tt() {
|
|
|
18
18
|
Ye = 1;
|
|
19
19
|
var o = be, s = Symbol.for("react.element"), r = Symbol.for("react.fragment"), a = Object.prototype.hasOwnProperty, u = o.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, l = { key: !0, ref: !0, __self: !0, __source: !0 };
|
|
20
20
|
function h(c, v, g) {
|
|
21
|
-
var b, m = {},
|
|
22
|
-
g !== void 0 && (
|
|
21
|
+
var b, m = {}, C = null, D = null;
|
|
22
|
+
g !== void 0 && (C = "" + g), v.key !== void 0 && (C = "" + v.key), v.ref !== void 0 && (D = v.ref);
|
|
23
23
|
for (b in v)
|
|
24
24
|
a.call(v, b) && !l.hasOwnProperty(b) && (m[b] = v[b]);
|
|
25
25
|
if (c && c.defaultProps)
|
|
26
26
|
for (b in v = c.defaultProps, v)
|
|
27
27
|
m[b] === void 0 && (m[b] = v[b]);
|
|
28
|
-
return { $$typeof: s, type: c, key:
|
|
28
|
+
return { $$typeof: s, type: c, key: C, ref: D, props: m, _owner: u.current };
|
|
29
29
|
}
|
|
30
30
|
return G.Fragment = r, G.jsx = h, G.jsxs = h, G;
|
|
31
31
|
}
|
|
@@ -42,7 +42,7 @@ var H = {};
|
|
|
42
42
|
var Me;
|
|
43
43
|
function wt() {
|
|
44
44
|
return Me || (Me = 1, process.env.NODE_ENV !== "production" && function() {
|
|
45
|
-
var o = be, s = Symbol.for("react.element"), r = Symbol.for("react.portal"), a = Symbol.for("react.fragment"), u = Symbol.for("react.strict_mode"), l = Symbol.for("react.profiler"), h = Symbol.for("react.provider"), c = Symbol.for("react.context"), v = Symbol.for("react.forward_ref"), g = Symbol.for("react.suspense"), b = Symbol.for("react.suspense_list"), m = Symbol.for("react.memo"),
|
|
45
|
+
var o = be, s = Symbol.for("react.element"), r = Symbol.for("react.portal"), a = Symbol.for("react.fragment"), u = Symbol.for("react.strict_mode"), l = Symbol.for("react.profiler"), h = Symbol.for("react.provider"), c = Symbol.for("react.context"), v = Symbol.for("react.forward_ref"), g = Symbol.for("react.suspense"), b = Symbol.for("react.suspense_list"), m = Symbol.for("react.memo"), C = Symbol.for("react.lazy"), D = Symbol.for("react.offscreen"), K = Symbol.iterator, U = "@@iterator";
|
|
46
46
|
function ne(e) {
|
|
47
47
|
if (e === null || typeof e != "object")
|
|
48
48
|
return null;
|
|
@@ -50,7 +50,7 @@ function wt() {
|
|
|
50
50
|
return typeof t == "function" ? t : null;
|
|
51
51
|
}
|
|
52
52
|
var L = o.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
53
|
-
function
|
|
53
|
+
function R(e) {
|
|
54
54
|
{
|
|
55
55
|
for (var t = arguments.length, n = new Array(t > 1 ? t - 1 : 0), d = 1; d < t; d++)
|
|
56
56
|
n[d - 1] = arguments[d];
|
|
@@ -70,7 +70,7 @@ function wt() {
|
|
|
70
70
|
var oe = !1, se = !1, ae = !1, ie = !1, W = !1, X;
|
|
71
71
|
X = Symbol.for("react.module.reference");
|
|
72
72
|
function ce(e) {
|
|
73
|
-
return !!(typeof e == "string" || typeof e == "function" || e === a || e === l || W || e === u || e === g || e === b || ie || e === D || oe || se || ae || typeof e == "object" && e !== null && (e.$$typeof ===
|
|
73
|
+
return !!(typeof e == "string" || typeof e == "function" || e === a || e === l || W || e === u || e === g || e === b || ie || e === D || oe || se || ae || typeof e == "object" && e !== null && (e.$$typeof === C || e.$$typeof === m || e.$$typeof === h || e.$$typeof === c || e.$$typeof === v || // This needs to include all possible module reference object
|
|
74
74
|
// types supported by any Flight configuration anywhere since
|
|
75
75
|
// we don't know which Flight build this will end up being used
|
|
76
76
|
// with.
|
|
@@ -89,7 +89,7 @@ function wt() {
|
|
|
89
89
|
function A(e) {
|
|
90
90
|
if (e == null)
|
|
91
91
|
return null;
|
|
92
|
-
if (typeof e.tag == "number" &&
|
|
92
|
+
if (typeof e.tag == "number" && R("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof e == "function")
|
|
93
93
|
return e.displayName || e.name || null;
|
|
94
94
|
if (typeof e == "string")
|
|
95
95
|
return e;
|
|
@@ -120,7 +120,7 @@ function wt() {
|
|
|
120
120
|
case m:
|
|
121
121
|
var d = e.displayName || null;
|
|
122
122
|
return d !== null ? d : A(e.type) || "Memo";
|
|
123
|
-
case
|
|
123
|
+
case C: {
|
|
124
124
|
var y = e, k = y._payload, _ = y._init;
|
|
125
125
|
try {
|
|
126
126
|
return A(_(k));
|
|
@@ -131,18 +131,18 @@ function wt() {
|
|
|
131
131
|
}
|
|
132
132
|
return null;
|
|
133
133
|
}
|
|
134
|
-
var S = Object.assign, F = 0, T, N, me, Ee, Te, we,
|
|
135
|
-
function
|
|
134
|
+
var S = Object.assign, F = 0, T, N, me, Ee, Te, we, Ce;
|
|
135
|
+
function Re() {
|
|
136
136
|
}
|
|
137
|
-
|
|
137
|
+
Re.__reactDisabledLog = !0;
|
|
138
138
|
function Je() {
|
|
139
139
|
{
|
|
140
140
|
if (F === 0) {
|
|
141
|
-
T = console.log, N = console.info, me = console.warn, Ee = console.error, Te = console.group, we = console.groupCollapsed,
|
|
141
|
+
T = console.log, N = console.info, me = console.warn, Ee = console.error, Te = console.group, we = console.groupCollapsed, Ce = console.groupEnd;
|
|
142
142
|
var e = {
|
|
143
143
|
configurable: !0,
|
|
144
144
|
enumerable: !0,
|
|
145
|
-
value:
|
|
145
|
+
value: Re,
|
|
146
146
|
writable: !0
|
|
147
147
|
};
|
|
148
148
|
Object.defineProperties(console, {
|
|
@@ -186,11 +186,11 @@ function wt() {
|
|
|
186
186
|
value: we
|
|
187
187
|
}),
|
|
188
188
|
groupEnd: S({}, e, {
|
|
189
|
-
value:
|
|
189
|
+
value: Ce
|
|
190
190
|
})
|
|
191
191
|
});
|
|
192
192
|
}
|
|
193
|
-
F < 0 &&
|
|
193
|
+
F < 0 && R("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
196
|
var le = L.ReactCurrentDispatcher, ue;
|
|
@@ -309,7 +309,7 @@ function wt() {
|
|
|
309
309
|
return Qe(e.render);
|
|
310
310
|
case m:
|
|
311
311
|
return ee(e.type, t, n);
|
|
312
|
-
case
|
|
312
|
+
case C: {
|
|
313
313
|
var d = e, y = d._payload, k = d._init;
|
|
314
314
|
try {
|
|
315
315
|
return ee(k(y), t, n);
|
|
@@ -342,7 +342,7 @@ function wt() {
|
|
|
342
342
|
} catch (E) {
|
|
343
343
|
p = E;
|
|
344
344
|
}
|
|
345
|
-
p && !(p instanceof Error) && (re(y),
|
|
345
|
+
p && !(p instanceof Error) && (re(y), R("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", d || "React class", n, _, typeof p), re(null)), p instanceof Error && !(p.message in je) && (je[p.message] = !0, re(y), R("Failed %s type: %s", n, p.message), re(null));
|
|
346
346
|
}
|
|
347
347
|
}
|
|
348
348
|
}
|
|
@@ -368,7 +368,7 @@ function wt() {
|
|
|
368
368
|
}
|
|
369
369
|
function Pe(e) {
|
|
370
370
|
if (nt(e))
|
|
371
|
-
return
|
|
371
|
+
return R("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", rt(e)), Se(e);
|
|
372
372
|
}
|
|
373
373
|
var q = L.ReactCurrentOwner, ot = {
|
|
374
374
|
key: !0,
|
|
@@ -396,13 +396,13 @@ function wt() {
|
|
|
396
396
|
function it(e, t) {
|
|
397
397
|
if (typeof e.ref == "string" && q.current && t && q.current.stateNode !== t) {
|
|
398
398
|
var n = A(q.current.type);
|
|
399
|
-
ve[n] || (
|
|
399
|
+
ve[n] || (R('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref', A(q.current.type), e.ref), ve[n] = !0);
|
|
400
400
|
}
|
|
401
401
|
}
|
|
402
402
|
function ct(e, t) {
|
|
403
403
|
{
|
|
404
404
|
var n = function() {
|
|
405
|
-
Ae || (Ae = !0,
|
|
405
|
+
Ae || (Ae = !0, R("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", t));
|
|
406
406
|
};
|
|
407
407
|
n.isReactWarning = !0, Object.defineProperty(e, "key", {
|
|
408
408
|
get: n,
|
|
@@ -413,7 +413,7 @@ function wt() {
|
|
|
413
413
|
function lt(e, t) {
|
|
414
414
|
{
|
|
415
415
|
var n = function() {
|
|
416
|
-
Fe || (Fe = !0,
|
|
416
|
+
Fe || (Fe = !0, R("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", t));
|
|
417
417
|
};
|
|
418
418
|
n.isReactWarning = !0, Object.defineProperty(e, "ref", {
|
|
419
419
|
get: n,
|
|
@@ -527,7 +527,7 @@ Check the top-level render call using <` + n + ">.");
|
|
|
527
527
|
return;
|
|
528
528
|
De[n] = !0;
|
|
529
529
|
var d = "";
|
|
530
|
-
e && e._owner && e._owner !== he.current && (d = " It was passed a child from " + A(e._owner.type) + "."), V(e),
|
|
530
|
+
e && e._owner && e._owner !== he.current && (d = " It was passed a child from " + A(e._owner.type) + "."), V(e), R('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', n, d), V(null);
|
|
531
531
|
}
|
|
532
532
|
}
|
|
533
533
|
function We(e, t) {
|
|
@@ -569,9 +569,9 @@ Check the top-level render call using <` + n + ">.");
|
|
|
569
569
|
} else if (t.PropTypes !== void 0 && !pe) {
|
|
570
570
|
pe = !0;
|
|
571
571
|
var y = A(t);
|
|
572
|
-
|
|
572
|
+
R("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", y || "Unknown");
|
|
573
573
|
}
|
|
574
|
-
typeof t.getDefaultProps == "function" && !t.getDefaultProps.isReactClassApproved &&
|
|
574
|
+
typeof t.getDefaultProps == "function" && !t.getDefaultProps.isReactClassApproved && R("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
|
|
575
575
|
}
|
|
576
576
|
}
|
|
577
577
|
function pt(e) {
|
|
@@ -579,11 +579,11 @@ Check the top-level render call using <` + n + ">.");
|
|
|
579
579
|
for (var t = Object.keys(e.props), n = 0; n < t.length; n++) {
|
|
580
580
|
var d = t[n];
|
|
581
581
|
if (d !== "children" && d !== "key") {
|
|
582
|
-
V(e),
|
|
582
|
+
V(e), R("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", d), V(null);
|
|
583
583
|
break;
|
|
584
584
|
}
|
|
585
585
|
}
|
|
586
|
-
e.ref !== null && (V(e),
|
|
586
|
+
e.ref !== null && (V(e), R("Invalid attribute `ref` supplied to `React.Fragment`."), V(null));
|
|
587
587
|
}
|
|
588
588
|
}
|
|
589
589
|
function Ue(e, t, n, d, y, k) {
|
|
@@ -595,7 +595,7 @@ Check the top-level render call using <` + n + ">.");
|
|
|
595
595
|
var x = ft(y);
|
|
596
596
|
x ? p += x : p += Ie();
|
|
597
597
|
var E;
|
|
598
|
-
e === null ? E = "null" : fe(e) ? E = "array" : e !== void 0 && e.$$typeof === s ? (E = "<" + (A(e.type) || "Unknown") + " />", p = " Did you accidentally export a JSX literal instead of a component?") : E = typeof e,
|
|
598
|
+
e === null ? E = "null" : fe(e) ? E = "array" : e !== void 0 && e.$$typeof === s ? (E = "<" + (A(e.type) || "Unknown") + " />", p = " Did you accidentally export a JSX literal instead of a component?") : E = typeof e, R("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", E, p);
|
|
599
599
|
}
|
|
600
600
|
var w = dt(e, t, n, y, k);
|
|
601
601
|
if (w == null)
|
|
@@ -609,7 +609,7 @@ Check the top-level render call using <` + n + ">.");
|
|
|
609
609
|
We(j[B], e);
|
|
610
610
|
Object.freeze && Object.freeze(j);
|
|
611
611
|
} else
|
|
612
|
-
|
|
612
|
+
R("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
|
|
613
613
|
else
|
|
614
614
|
We(j, e);
|
|
615
615
|
}
|
|
@@ -628,22 +628,22 @@ Check the top-level render call using <` + n + ">.");
|
|
|
628
628
|
}
|
|
629
629
|
process.env.NODE_ENV === "production" ? ye.exports = Tt() : ye.exports = wt();
|
|
630
630
|
var i = ye.exports;
|
|
631
|
-
const Be = "default",
|
|
632
|
-
var
|
|
631
|
+
const Be = "default", Ct = (o, s) => async (...r) => {
|
|
632
|
+
var C;
|
|
633
633
|
const [a, u, ...l] = r, h = u ? { ...u } : { method: "GET" };
|
|
634
634
|
let c = new Headers();
|
|
635
635
|
h.headers && (c = h.headers instanceof Headers ? h.headers : new Headers(h.headers));
|
|
636
|
-
const g = await s().getValidTokenAsync(), b = (
|
|
636
|
+
const g = await s().getValidTokenAsync(), b = (C = g == null ? void 0 : g.tokens) == null ? void 0 : C.accessToken;
|
|
637
637
|
c.has("Accept") || c.set("Accept", "application/json"), b && (c.set("Authorization", `Bearer ${b}`), h.credentials || (h.credentials = "same-origin"));
|
|
638
638
|
const m = { ...h, headers: c };
|
|
639
639
|
return await o(a, m, ...l);
|
|
640
640
|
}, Gt = (o = null, s = Be) => (r) => (a) => {
|
|
641
|
-
const { fetch: u } =
|
|
641
|
+
const { fetch: u } = Rt(o || a.fetch, s);
|
|
642
642
|
return /* @__PURE__ */ i.jsx(r, { ...a, fetch: u });
|
|
643
|
-
},
|
|
643
|
+
}, Rt = (o = null, s = Be) => {
|
|
644
644
|
const r = o || window.fetch, a = f.get;
|
|
645
645
|
return { fetch: kt(
|
|
646
|
-
(l, h) =>
|
|
646
|
+
(l, h) => Ct(r, () => a(s))(l, h),
|
|
647
647
|
[r, s]
|
|
648
648
|
) };
|
|
649
649
|
}, qe = () => /* @__PURE__ */ i.jsx("div", { className: "oidc-authenticating", children: /* @__PURE__ */ i.jsxs("div", { className: "oidc-authenticating__container", children: [
|
|
@@ -714,8 +714,8 @@ const Be = "default", Rt = (o, s) => async (...r) => {
|
|
|
714
714
|
}) => {
|
|
715
715
|
const v = window ? z(window.location.href) : "", [g, b] = P(v);
|
|
716
716
|
O(() => {
|
|
717
|
-
const
|
|
718
|
-
return
|
|
717
|
+
const C = () => b(z(window.location.href));
|
|
718
|
+
return C(), window.addEventListener("popstate", C, !1), () => window.removeEventListener("popstate", C, !1);
|
|
719
719
|
}, []);
|
|
720
720
|
const m = z(r);
|
|
721
721
|
if (a && g === z(a))
|
|
@@ -756,11 +756,11 @@ const Be = "default", Rt = (o, s) => async (...r) => {
|
|
|
756
756
|
onSessionLost: g = null,
|
|
757
757
|
onLogoutFromAnotherTab: b = null,
|
|
758
758
|
onLogoutFromSameTab: m = null,
|
|
759
|
-
withCustomHistory:
|
|
759
|
+
withCustomHistory: C = null,
|
|
760
760
|
onEvent: D = null,
|
|
761
761
|
getFetch: K = null
|
|
762
762
|
}) => {
|
|
763
|
-
const U = (S = "default") => f.getOrCreate(K ?? Et)(s, S), [ne, L] = P(!0), [
|
|
763
|
+
const U = (S = "default") => f.getOrCreate(K ?? Et)(s, S), [ne, L] = P(!0), [R, $] = P(Ve), [oe, se] = P("default");
|
|
764
764
|
O(() => {
|
|
765
765
|
const F = U(r).subscribeEvents((T, N) => {
|
|
766
766
|
D && D(r, T, N);
|
|
@@ -790,7 +790,7 @@ const Be = "default", Rt = (o, s) => async (...r) => {
|
|
|
790
790
|
};
|
|
791
791
|
}, [s, r]);
|
|
792
792
|
const ae = v, ie = u, W = l, X = h, ce = c, Y = ne || oe !== r, M = U(r);
|
|
793
|
-
switch (
|
|
793
|
+
switch (R.name) {
|
|
794
794
|
case f.eventNames.service_worker_not_supported_by_browser:
|
|
795
795
|
return /* @__PURE__ */ i.jsx(J, { loadingComponent: W, isLoading: Y, configurationName: r, children: /* @__PURE__ */ i.jsx(X, { configurationName: r }) });
|
|
796
796
|
case f.eventNames.loginAsync_begin:
|
|
@@ -813,7 +813,7 @@ const Be = "default", Rt = (o, s) => async (...r) => {
|
|
|
813
813
|
callbackErrorComponent: c,
|
|
814
814
|
authenticatingComponent: u,
|
|
815
815
|
configurationName: r,
|
|
816
|
-
withCustomHistory:
|
|
816
|
+
withCustomHistory: C,
|
|
817
817
|
children: /* @__PURE__ */ i.jsx($t, { loadingComponent: W, configurationName: r, children: o })
|
|
818
818
|
}
|
|
819
819
|
) });
|
|
@@ -956,7 +956,7 @@ export {
|
|
|
956
956
|
rr as TokenRenewMode,
|
|
957
957
|
Kt as useOidc,
|
|
958
958
|
Xt as useOidcAccessToken,
|
|
959
|
-
|
|
959
|
+
Rt as useOidcFetch,
|
|
960
960
|
Qt as useOidcIdToken,
|
|
961
961
|
Zt as useOidcUser,
|
|
962
962
|
Gt as withOidcFetch,
|
package/dist/index.umd.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(R,y){typeof exports=="object"&&typeof module<"u"?y(exports,require("react"),require("@axa-fr/oidc-client")):typeof define=="function"&&define.amd?define(["exports","react","@axa-fr/oidc-client"],y):(R=typeof globalThis<"u"?globalThis:R||self,y(R["react-oidc"]={},R.React,R.oidcClient))})(this,function(R,y,l){"use strict";var ne={exports:{}},G={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var be;function Qe(){if(be)return G;be=1;var s=y,o=Symbol.for("react.element"),n=Symbol.for("react.fragment"),a=Object.prototype.hasOwnProperty,d=s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,u={key:!0,ref:!0,__self:!0,__source:!0};function h(i,v,g){var k,
|
|
9
|
+
*/var be;function Qe(){if(be)return G;be=1;var s=y,o=Symbol.for("react.element"),n=Symbol.for("react.fragment"),a=Object.prototype.hasOwnProperty,d=s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,u={key:!0,ref:!0,__self:!0,__source:!0};function h(i,v,g){var k,O={},S=null,D=null;g!==void 0&&(S=""+g),v.key!==void 0&&(S=""+v.key),v.ref!==void 0&&(D=v.ref);for(k in v)a.call(v,k)&&!u.hasOwnProperty(k)&&(O[k]=v[k]);if(i&&i.defaultProps)for(k in v=i.defaultProps,v)O[k]===void 0&&(O[k]=v[k]);return{$$typeof:o,type:i,key:S,ref:D,props:O,_owner:d.current}}return G.Fragment=n,G.jsx=h,G.jsxs=h,G}var H={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,14 +14,14 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var ke;function Ze(){return ke||(ke=1,process.env.NODE_ENV!=="production"&&function(){var s=y,o=Symbol.for("react.element"),n=Symbol.for("react.portal"),a=Symbol.for("react.fragment"),d=Symbol.for("react.strict_mode"),u=Symbol.for("react.profiler"),h=Symbol.for("react.provider"),i=Symbol.for("react.context"),v=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),k=Symbol.for("react.suspense_list"),
|
|
18
|
-
`+fe+e}}var ve=!1,q;{var
|
|
19
|
-
`),
|
|
20
|
-
`),
|
|
21
|
-
`+p[
|
|
17
|
+
*/var ke;function Ze(){return ke||(ke=1,process.env.NODE_ENV!=="production"&&function(){var s=y,o=Symbol.for("react.element"),n=Symbol.for("react.portal"),a=Symbol.for("react.fragment"),d=Symbol.for("react.strict_mode"),u=Symbol.for("react.profiler"),h=Symbol.for("react.provider"),i=Symbol.for("react.context"),v=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),k=Symbol.for("react.suspense_list"),O=Symbol.for("react.memo"),S=Symbol.for("react.lazy"),D=Symbol.for("react.offscreen"),X=Symbol.iterator,W="@@iterator";function oe(e){if(e===null||typeof e!="object")return null;var t=X&&e[X]||e[W];return typeof t=="function"?t:null}var L=s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function j(e){{for(var t=arguments.length,r=new Array(t>1?t-1:0),f=1;f<t;f++)r[f-1]=arguments[f];M("error",e,r)}}function M(e,t,r){{var f=L.ReactDebugCurrentFrame,b=f.getStackAddendum();b!==""&&(t+="%s",r=r.concat([b]));var m=r.map(function(_){return String(_)});m.unshift("Warning: "+t),Function.prototype.apply.call(console[e],console,m)}}var ae=!1,ce=!1,ie=!1,le=!1,U=!1,Q;Q=Symbol.for("react.module.reference");function ue(e){return!!(typeof e=="string"||typeof e=="function"||e===a||e===u||U||e===d||e===g||e===k||le||e===D||ae||ce||ie||typeof e=="object"&&e!==null&&(e.$$typeof===S||e.$$typeof===O||e.$$typeof===h||e.$$typeof===i||e.$$typeof===v||e.$$typeof===Q||e.getModuleId!==void 0))}function Y(e,t,r){var f=e.displayName;if(f)return f;var b=t.displayName||t.name||"";return b!==""?r+"("+b+")":r}function V(e){return e.displayName||"Context"}function A(e){if(e==null)return null;if(typeof e.tag=="number"&&j("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case a:return"Fragment";case n:return"Portal";case u:return"Profiler";case d:return"StrictMode";case g:return"Suspense";case k:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case i:var t=e;return V(t)+".Consumer";case h:var r=e;return V(r._context)+".Provider";case v:return Y(e,e.render,"ForwardRef");case O:var f=e.displayName||null;return f!==null?f:A(e.type)||"Memo";case S:{var b=e,m=b._payload,_=b._init;try{return A(_(m))}catch{return null}}}return null}var P=Object.assign,F=0,T,N,xe,Pe,Ae,Fe,Ne;function Ie(){}Ie.__reactDisabledLog=!0;function Ot(){{if(F===0){T=console.log,N=console.info,xe=console.warn,Pe=console.error,Ae=console.group,Fe=console.groupCollapsed,Ne=console.groupEnd;var e={configurable:!0,enumerable:!0,value:Ie,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}F++}}function Et(){{if(F--,F===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:P({},e,{value:T}),info:P({},e,{value:N}),warn:P({},e,{value:xe}),error:P({},e,{value:Pe}),group:P({},e,{value:Ae}),groupCollapsed:P({},e,{value:Fe}),groupEnd:P({},e,{value:Ne})})}F<0&&j("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var de=L.ReactCurrentDispatcher,fe;function Z(e,t,r){{if(fe===void 0)try{throw Error()}catch(b){var f=b.stack.trim().match(/\n( *(at )?)/);fe=f&&f[1]||""}return`
|
|
18
|
+
`+fe+e}}var ve=!1,q;{var Tt=typeof WeakMap=="function"?WeakMap:Map;q=new Tt}function De(e,t){if(!e||ve)return"";{var r=q.get(e);if(r!==void 0)return r}var f;ve=!0;var b=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var m;m=de.current,de.current=null,Ot();try{if(t){var _=function(){throw Error()};if(Object.defineProperty(_.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(_,[])}catch(I){f=I}Reflect.construct(e,[],_)}else{try{_.call()}catch(I){f=I}e.call(_.prototype)}}else{try{throw Error()}catch(I){f=I}e()}}catch(I){if(I&&f&&typeof I.stack=="string"){for(var p=I.stack.split(`
|
|
19
|
+
`),C=f.stack.split(`
|
|
20
|
+
`),E=p.length-1,w=C.length-1;E>=1&&w>=0&&p[E]!==C[w];)w--;for(;E>=1&&w>=0;E--,w--)if(p[E]!==C[w]){if(E!==1||w!==1)do if(E--,w--,w<0||p[E]!==C[w]){var x=`
|
|
21
|
+
`+p[E].replace(" at new "," at ");return e.displayName&&x.includes("<anonymous>")&&(x=x.replace("<anonymous>",e.displayName)),typeof e=="function"&&q.set(e,x),x}while(E>=1&&w>=0);break}}}finally{ve=!1,de.current=m,Et(),Error.prepareStackTrace=b}var z=e?e.displayName||e.name:"",Xe=z?Z(z):"";return typeof e=="function"&&q.set(e,Xe),Xe}function wt(e,t,r){return De(e,!1)}function Rt(e){var t=e.prototype;return!!(t&&t.isReactComponent)}function $(e,t,r){if(e==null)return"";if(typeof e=="function")return De(e,Rt(e));if(typeof e=="string")return Z(e);switch(e){case g:return Z("Suspense");case k:return Z("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case v:return wt(e.render);case O:return $(e.type,t,r);case S:{var f=e,b=f._payload,m=f._init;try{return $(m(b),t,r)}catch{}}}return""}var ee=Object.prototype.hasOwnProperty,Le={},Ue=L.ReactDebugCurrentFrame;function te(e){if(e){var t=e._owner,r=$(e.type,e._source,t?t.type:null);Ue.setExtraStackFrame(r)}else Ue.setExtraStackFrame(null)}function St(e,t,r,f,b){{var m=Function.call.bind(ee);for(var _ in e)if(m(e,_)){var p=void 0;try{if(typeof e[_]!="function"){var C=Error((f||"React class")+": "+r+" type `"+_+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[_]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw C.name="Invariant Violation",C}p=e[_](t,_,f,r,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(E){p=E}p&&!(p instanceof Error)&&(te(b),j("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",f||"React class",r,_,typeof p),te(null)),p instanceof Error&&!(p.message in Le)&&(Le[p.message]=!0,te(b),j("Failed %s type: %s",r,p.message),te(null))}}}var jt=Array.isArray;function he(e){return jt(e)}function Ct(e){{var t=typeof Symbol=="function"&&Symbol.toStringTag,r=t&&e[Symbol.toStringTag]||e.constructor.name||"Object";return r}}function xt(e){try{return We(e),!1}catch{return!0}}function We(e){return""+e}function Me(e){if(xt(e))return j("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Ct(e)),We(e)}var K=L.ReactCurrentOwner,Pt={key:!0,ref:!0,__self:!0,__source:!0},Ye,Ve,pe;pe={};function At(e){if(ee.call(e,"ref")){var t=Object.getOwnPropertyDescriptor(e,"ref").get;if(t&&t.isReactWarning)return!1}return e.ref!==void 0}function Ft(e){if(ee.call(e,"key")){var t=Object.getOwnPropertyDescriptor(e,"key").get;if(t&&t.isReactWarning)return!1}return e.key!==void 0}function Nt(e,t){if(typeof e.ref=="string"&&K.current&&t&&K.current.stateNode!==t){var r=A(K.current.type);pe[r]||(j('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',A(K.current.type),e.ref),pe[r]=!0)}}function It(e,t){{var r=function(){Ye||(Ye=!0,j("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",t))};r.isReactWarning=!0,Object.defineProperty(e,"key",{get:r,configurable:!0})}}function Dt(e,t){{var r=function(){Ve||(Ve=!0,j("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",t))};r.isReactWarning=!0,Object.defineProperty(e,"ref",{get:r,configurable:!0})}}var Lt=function(e,t,r,f,b,m,_){var p={$$typeof:o,type:e,key:t,ref:r,props:_,_owner:m};return p._store={},Object.defineProperty(p._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(p,"_self",{configurable:!1,enumerable:!1,writable:!1,value:f}),Object.defineProperty(p,"_source",{configurable:!1,enumerable:!1,writable:!1,value:b}),Object.freeze&&(Object.freeze(p.props),Object.freeze(p)),p};function Ut(e,t,r,f,b){{var m,_={},p=null,C=null;r!==void 0&&(Me(r),p=""+r),Ft(t)&&(Me(t.key),p=""+t.key),At(t)&&(C=t.ref,Nt(t,b));for(m in t)ee.call(t,m)&&!Pt.hasOwnProperty(m)&&(_[m]=t[m]);if(e&&e.defaultProps){var E=e.defaultProps;for(m in E)_[m]===void 0&&(_[m]=E[m])}if(p||C){var w=typeof e=="function"?e.displayName||e.name||"Unknown":e;p&&It(_,w),C&&Dt(_,w)}return Lt(e,p,C,b,f,K.current,_)}}var _e=L.ReactCurrentOwner,Be=L.ReactDebugCurrentFrame;function B(e){if(e){var t=e._owner,r=$(e.type,e._source,t?t.type:null);Be.setExtraStackFrame(r)}else Be.setExtraStackFrame(null)}var ge;ge=!1;function ye(e){return typeof e=="object"&&e!==null&&e.$$typeof===o}function ze(){{if(_e.current){var e=A(_e.current.type);if(e)return`
|
|
22
22
|
|
|
23
|
-
Check the render method of \``+e+"`."}return""}}function
|
|
23
|
+
Check the render method of \``+e+"`."}return""}}function Wt(e){{if(e!==void 0){var t=e.fileName.replace(/^.*[\\\/]/,""),r=e.lineNumber;return`
|
|
24
24
|
|
|
25
|
-
Check your code at `+t+":"+r+"."}return""}}var Ge={};function
|
|
25
|
+
Check your code at `+t+":"+r+"."}return""}}var Ge={};function Mt(e){{var t=ze();if(!t){var r=typeof e=="string"?e:e.displayName||e.name;r&&(t=`
|
|
26
26
|
|
|
27
|
-
Check the top-level render call using <`+r+">.")}return t}}function He(e,t){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var r=Wt(t);if(Ge[r])return;Ge[r]=!0;var f="";e&&e._owner&&e._owner!==_e.current&&(f=" It was passed a child from "+A(e._owner.type)+"."),B(e),j('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',r,f),B(null)}}function Je(e,t){{if(typeof e!="object")return;if(he(e))for(var r=0;r<e.length;r++){var f=e[r];ye(f)&&He(f,t)}else if(ye(e))e._store&&(e._store.validated=!0);else if(e){var b=oe(e);if(typeof b=="function"&&b!==e.entries)for(var m=b.call(e),_;!(_=m.next()).done;)ye(_.value)&&He(_.value,t)}}}function Mt(e){{var t=e.type;if(t==null||typeof t=="string")return;var r;if(typeof t=="function")r=t.propTypes;else if(typeof t=="object"&&(t.$$typeof===v||t.$$typeof===E))r=t.propTypes;else return;if(r){var f=A(t);Ct(r,e.props,"prop",f,e)}else if(t.PropTypes!==void 0&&!ge){ge=!0;var b=A(t);j("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",b||"Unknown")}typeof t.getDefaultProps=="function"&&!t.getDefaultProps.isReactClassApproved&&j("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Yt(e){{for(var t=Object.keys(e.props),r=0;r<t.length;r++){var f=t[r];if(f!=="children"&&f!=="key"){B(e),j("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",f),B(null);break}}e.ref!==null&&(B(e),j("Invalid attribute `ref` supplied to `React.Fragment`."),B(null))}}function Ke(e,t,r,f,b,m){{var _=ue(e);if(!_){var p="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(p+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var O=Ut(b);O?p+=O:p+=ze();var T;e===null?T="null":he(e)?T="array":e!==void 0&&e.$$typeof===o?(T="<"+(A(e.type)||"Unknown")+" />",p=" Did you accidentally export a JSX literal instead of a component?"):T=typeof e,j("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",T,p)}var R=Lt(e,t,r,b,m);if(R==null)return R;if(_){var x=t.children;if(x!==void 0)if(f)if(he(x)){for(var z=0;z<x.length;z++)Je(x[z],e);Object.freeze&&Object.freeze(x)}else j("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Je(x,e)}return e===a?Yt(R):Mt(R),R}}function Bt(e,t,r){return Ke(e,t,r,!0)}function zt(e,t,r){return Ke(e,t,r,!1)}var Gt=zt,Ht=Bt;H.Fragment=a,H.jsx=Gt,H.jsxs=Ht}()),H}process.env.NODE_ENV==="production"?ne.exports=Qe():ne.exports=Ze();var c=ne.exports;const me="default",qe=(s,o)=>async(...n)=>{var C;const[a,d,...u]=n,h=d?{...d}:{method:"GET"};let i=new Headers;h.headers&&(i=h.headers instanceof Headers?h.headers:new Headers(h.headers));const g=await o().getValidTokenAsync(),k=(C=g==null?void 0:g.tokens)==null?void 0:C.accessToken;i.has("Accept")||i.set("Accept","application/json"),k&&(i.set("Authorization",`Bearer ${k}`),h.credentials||(h.credentials="same-origin"));const E={...h,headers:i};return await s(a,E,...u)},$e=(s=null,o=me)=>n=>a=>{const{fetch:d}=Ee(s||a.fetch,o);return c.jsx(n,{...a,fetch:d})},Ee=(s=null,o=me)=>{const n=s||window.fetch,a=l.VanillaOidc.get;return{fetch:y.useCallback((u,h)=>qe(n,()=>a(o))(u,h),[n,o])}},Te=()=>c.jsx("div",{className:"oidc-authenticating",children:c.jsxs("div",{className:"oidc-authenticating__container",children:[c.jsx("h1",{className:"oidc-authenticating__title",children:"Error authentication"}),c.jsx("p",{className:"oidc-authenticating__content",children:"An error occurred during authentication."})]})}),et=()=>c.jsx("div",{className:"oidc-authenticating",children:c.jsxs("div",{className:"oidc-authenticating__container",children:[c.jsx("h1",{className:"oidc-authenticating__title",children:"Authentication in progress"}),c.jsx("p",{className:"oidc-authenticating__content",children:"You will be redirected to the login page."})]})}),tt=()=>Math.random().toString(36).substr(2,6),nt=(s,o)=>(n,a)=>{if(typeof s.CustomEvent=="function")return new s.CustomEvent(n,a);const d=a||{bubbles:!1,cancelable:!1,detail:void 0},u=o.createEvent("CustomEvent");return u.initCustomEvent(n,d.bubbles,d.cancelable,d.detail),u.prototype=s.Event.prototype,u},rt=(s,o,n)=>({replaceState:(a,d)=>{const u=n(),h=d||s.history.state;s.history.replaceState({key:u,state:h},null,a),s.dispatchEvent(o("popstate"))}}),st=()=>rt(window,nt(window,document),tt),we=()=>c.jsx("div",{className:"oidc-callback",children:c.jsxs("div",{className:"oidc-callback__container",children:[c.jsx("h1",{className:"oidc-callback__title",children:"Authentication complete"}),c.jsx("p",{className:"oidc-callback__content",children:"You will be redirected to your application."})]})}),ot=({callBackError:s,callBackSuccess:o,configurationName:n,withCustomHistory:a})=>{const[d,u]=y.useState(!1);y.useEffect(()=>{let v=!0;return(async()=>{const k=l.VanillaOidc.get;try{const{callbackPath:E}=await k(n).loginCallbackAsync();(a?a():st()).replaceState(E||"/")}catch(E){v&&(console.warn(E),u(!0))}})(),()=>{v=!1}},[]);const h=s||Te,i=o||we;return d?c.jsx(h,{configurationName:n}):c.jsx(i,{configurationName:n})},at=()=>c.jsx("span",{className:"oidc-loading",children:"Loading"}),ct=()=>c.jsx("div",{className:"oidc-serviceworker",children:c.jsxs("div",{className:"oidc-serviceworker__container",children:[c.jsx("h1",{className:"oidc-serviceworker__title",children:"Unable to authenticate on this browser"}),c.jsx("p",{className:"oidc-serviceworker__content",children:"Your browser is not secure enough to make authentication work. Try updating your browser or use a newer browser."})]})}),it=()=>c.jsx("div",{className:"oidc-session-lost",children:c.jsxs("div",{className:"oidc-session-lost__container",children:[c.jsx("h1",{className:"oidc-session-lost__title",children:"Session timed out"}),c.jsx("p",{className:"oidc-session-lost__content",children:"Your session has expired. Please re-authenticate."})]})}),lt=({configurationName:s})=>(y.useEffect(()=>{(async()=>{const n=l.VanillaOidc.get;n(s).silentLoginCallbackAsync()})()},[]),c.jsx(c.Fragment,{})),ut=({configurationName:s})=>{const o=l.getParseQueryStringFromLocation(window.location.href),n=l.VanillaOidc.get,a=n(s);let d=null;for(const[u,h]of Object.entries(o))u==="state"||u==="scope"||(d===null&&(d={}),d[u]=h);return y.useEffect(()=>{a.tokens||a.loginAsync(null,d,!0,o.scope)},[]),c.jsx(c.Fragment,{})},dt=({callbackErrorComponent:s,callbackSuccessComponent:o,redirect_uri:n,silent_redirect_uri:a,silent_login_uri:d,children:u,configurationName:h,withCustomHistory:i=null})=>{const v=window?l.getPath(window.location.href):"",[g,k]=y.useState(v);y.useEffect(()=>{const C=()=>k(l.getPath(window.location.href));return C(),window.addEventListener("popstate",C,!1),()=>window.removeEventListener("popstate",C,!1)},[]);const E=l.getPath(n);if(a&&g===l.getPath(a))return c.jsx(lt,{configurationName:h});if(d&&g===l.getPath(d))return c.jsx(ut,{configurationName:h});switch(g){case E:return c.jsx(ot,{callBackError:s,callBackSuccess:o,configurationName:h,withCustomHistory:i});default:return c.jsx(c.Fragment,{children:u})}},ft=y.memo(dt),Re={name:"",data:null},vt=({loadingComponent:s,children:o,configurationName:n})=>{const[a,d]=y.useState(!0),u=l.VanillaOidc.get,h=u(n);y.useEffect(()=>{let v=!0;return h&&h.tryKeepExistingSessionAsync().then(()=>{v&&d(!1)}),()=>{v=!1}},[n]);const i=s;return c.jsx(c.Fragment,{children:a?c.jsx(i,{configurationName:n}):c.jsx(c.Fragment,{children:o})})},J=({isLoading:s,loadingComponent:o,children:n,configurationName:a})=>{const d=o;return s?c.jsx(d,{configurationName:a,children:n}):c.jsx(c.Fragment,{children:n})},ht=({children:s,configuration:o,configurationName:n="default",callbackSuccessComponent:a=we,authenticatingComponent:d=et,loadingComponent:u=at,serviceWorkerNotSupportedComponent:h=ct,authenticatingErrorComponent:i=Te,sessionLostComponent:v=it,onSessionLost:g=null,onLogoutFromAnotherTab:k=null,onLogoutFromSameTab:E=null,withCustomHistory:C=null,onEvent:I=null,getFetch:X=null})=>{const U=(P="default")=>l.VanillaOidc.getOrCreate(X??l.getFetchDefault)(o,P),[oe,D]=y.useState(!0),[j,W]=y.useState(Re),[ae,ce]=y.useState("default");y.useEffect(()=>{const V=U(n).subscribeEvents((w,F)=>{I&&I(n,w,F)});return()=>{U(n).removeEventSubscription(V)}},[n,I]),y.useEffect(()=>{const V=U(n).subscribeEvents((w,F)=>{if(w===l.VanillaOidc.eventNames.refreshTokensAsync_error||w===l.VanillaOidc.eventNames.syncTokensAsync_error){if(g!=null){g();return}W({name:w,data:F})}else if(w===l.VanillaOidc.eventNames.logout_from_another_tab){if(k!=null){k();return}W({name:w,data:F})}else w===l.VanillaOidc.eventNames.logout_from_same_tab?E!=null&&E():w===l.VanillaOidc.eventNames.loginAsync_begin||w===l.VanillaOidc.eventNames.loginCallbackAsync_end||w===l.VanillaOidc.eventNames.loginAsync_error||w===l.VanillaOidc.eventNames.loginCallbackAsync_error?W({name:w,data:F}):w===l.VanillaOidc.eventNames.service_worker_not_supported_by_browser&&o.service_worker_only===!0&&W({name:w,data:F})});return ce(n),D(!1),()=>{U(n).removeEventSubscription(V),W(Re)}},[o,n]);const ie=v,le=d,L=u,Q=h,ue=i,M=oe||ae!==n,Y=U(n);switch(j.name){case l.VanillaOidc.eventNames.service_worker_not_supported_by_browser:return c.jsx(J,{loadingComponent:L,isLoading:M,configurationName:n,children:c.jsx(Q,{configurationName:n})});case l.VanillaOidc.eventNames.loginAsync_begin:return c.jsx(J,{loadingComponent:L,isLoading:M,configurationName:n,children:c.jsx(le,{configurationName:n})});case l.VanillaOidc.eventNames.loginAsync_error:case l.VanillaOidc.eventNames.loginCallbackAsync_error:return c.jsx(J,{loadingComponent:L,isLoading:M,configurationName:n,children:c.jsx(ue,{configurationName:n})});case l.VanillaOidc.eventNames.refreshTokensAsync_error:case l.VanillaOidc.eventNames.syncTokensAsync_error:case l.VanillaOidc.eventNames.logout_from_another_tab:return c.jsx(J,{loadingComponent:L,isLoading:M,configurationName:n,children:c.jsx(ie,{configurationName:n})});default:return c.jsx(J,{loadingComponent:L,isLoading:M,configurationName:n,children:c.jsx(ft,{redirect_uri:Y.configuration.redirect_uri,silent_redirect_uri:Y.configuration.silent_redirect_uri,silent_login_uri:Y.configuration.silent_login_uri,callbackSuccessComponent:a,callbackErrorComponent:i,authenticatingComponent:d,configurationName:n,withCustomHistory:C,children:c.jsx(vt,{loadingComponent:L,configurationName:n,children:s})})})}},Se=({children:s,callbackPath:o=null,extras:n=null,configurationName:a="default"})=>{const d=l.VanillaOidc.get,u=d(a);return y.useEffect(()=>{u.tokens||u.loginAsync(o,n)},[a,o,n]),u.tokens?c.jsx(c.Fragment,{children:s}):null},pt=(s,o=null,n=null,a="default")=>d=>c.jsx(Se,{callbackPath:o,extras:n,configurationName:a,children:c.jsx(s,{...d})}),re="default",se=(s,o)=>{let n=!1;return s(o)&&(n=s(o).tokens!=null),n},_t=(s=re)=>{const o=l.VanillaOidc.get,[n,a]=y.useState(se(o,s));return y.useEffect(()=>{let i=!0;const v=o(s);a(se(o,s));const g=v.subscribeEvents((k,E)=>{(k===l.VanillaOidc.eventNames.logout_from_another_tab||k===l.VanillaOidc.eventNames.logout_from_same_tab||k===l.VanillaOidc.eventNames.token_aquired)&&i&&a(se(o,s))});return()=>{i=!1,v.removeEventSubscription(g)}},[s]),{login:(i=void 0,v=null,g=!1)=>o(s).loginAsync(i,v,!1,void 0,g),logout:(i=void 0,v=null)=>o(s).logoutAsync(i,v),renewTokens:async(i=null)=>{const v=await o(s).renewTokensAsync(i);return{accessToken:v.accessToken,accessTokenPayload:v.accessTokenPayload,idToken:v.idToken,idTokenPayload:v.idTokenPayload}},isAuthenticated:n}},Ce={accessToken:null,accessTokenPayload:null},gt=s=>{const o=l.VanillaOidc.get,n=o(s);if(n.tokens){const a=n.tokens;return{accessToken:a.accessToken,accessTokenPayload:a.accessTokenPayload}}return Ce},yt=(s=re)=>{const o=l.VanillaOidc.get,[n,a]=y.useState(gt(s));return y.useEffect(()=>{let d=!0;const u=o(s);if(u.tokens){const i=u.tokens;a({accessToken:i.accessToken,accessTokenPayload:i.accessTokenPayload})}const h=u.subscribeEvents((i,v)=>{if((i===l.VanillaOidc.eventNames.token_renewed||i===l.VanillaOidc.eventNames.token_aquired||i===l.VanillaOidc.eventNames.logout_from_another_tab||i===l.VanillaOidc.eventNames.logout_from_same_tab||i===l.VanillaOidc.eventNames.refreshTokensAsync_error||i===l.VanillaOidc.eventNames.syncTokensAsync_error)&&d){const g=u.tokens;a(g!=null?{accessToken:g.accessToken,accessTokenPayload:g.accessTokenPayload}:Ce)}});return()=>{d=!1,u.removeEventSubscription(h)}},[s]),n},je={idToken:null,idTokenPayload:null},bt=s=>{const o=l.VanillaOidc.get,n=o(s);if(n.tokens){const a=n.tokens;return{idToken:a.idToken,idTokenPayload:a.idTokenPayload}}return je},kt=(s=re)=>{const o=l.VanillaOidc.get,[n,a]=y.useState(bt(s));return y.useEffect(()=>{let d=!0;const u=o(s);if(u.tokens){const i=u.tokens;a({idToken:i.idToken,idTokenPayload:i.idTokenPayload})}const h=u.subscribeEvents((i,v)=>{if((i===l.VanillaOidc.eventNames.token_renewed||i===l.VanillaOidc.eventNames.token_aquired||i===l.VanillaOidc.eventNames.logout_from_another_tab||i===l.VanillaOidc.eventNames.logout_from_same_tab||i===l.VanillaOidc.eventNames.refreshTokensAsync_error||i===l.VanillaOidc.eventNames.syncTokensAsync_error)&&d){const g=u.tokens;a(g!=null?{idToken:g.idToken,idTokenPayload:g.idTokenPayload}:je)}});return()=>{d=!1,u.removeEventSubscription(h)}},[s]),n};var Oe=(s=>(s.Unauthenticated="Unauthenticated",s.Loading="Loading user",s.Loaded="User loaded",s.LoadingError="Error loading user",s))(Oe||{});const mt=(s="default")=>{const[o,n]=y.useState({user:null,status:"Unauthenticated"}),[a,d]=y.useState(""),u=l.VanillaOidc.get(s);y.useEffect(()=>{let i=!0;if(u&&u.tokens){n({...o,status:"Loading user"});const v=a!=="";u.userInfoAsync(v).then(g=>{i&&n({user:g,status:"User loaded"})}).catch(()=>n({...o,status:"Error loading user"}))}else n({user:null,status:"Unauthenticated"});return()=>{i=!1}},[a]);const h=()=>{d(a+" ")};return{oidcUser:o.user,oidcUserLoadingState:o.status,reloadOidcUser:h}};Object.defineProperty(S,"TokenRenewMode",{enumerable:!0,get:()=>l.TokenRenewMode}),S.OidcProvider=ht,S.OidcSecure=Se,S.OidcUserStatus=Oe,S.useOidc=_t,S.useOidcAccessToken=yt,S.useOidcFetch=Ee,S.useOidcIdToken=kt,S.useOidcUser=mt,S.withOidcFetch=$e,S.withOidcSecure=pt,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})});
|
|
27
|
+
Check the top-level render call using <`+r+">.")}return t}}function He(e,t){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var r=Mt(t);if(Ge[r])return;Ge[r]=!0;var f="";e&&e._owner&&e._owner!==_e.current&&(f=" It was passed a child from "+A(e._owner.type)+"."),B(e),j('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',r,f),B(null)}}function Je(e,t){{if(typeof e!="object")return;if(he(e))for(var r=0;r<e.length;r++){var f=e[r];ye(f)&&He(f,t)}else if(ye(e))e._store&&(e._store.validated=!0);else if(e){var b=oe(e);if(typeof b=="function"&&b!==e.entries)for(var m=b.call(e),_;!(_=m.next()).done;)ye(_.value)&&He(_.value,t)}}}function Yt(e){{var t=e.type;if(t==null||typeof t=="string")return;var r;if(typeof t=="function")r=t.propTypes;else if(typeof t=="object"&&(t.$$typeof===v||t.$$typeof===O))r=t.propTypes;else return;if(r){var f=A(t);St(r,e.props,"prop",f,e)}else if(t.PropTypes!==void 0&&!ge){ge=!0;var b=A(t);j("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",b||"Unknown")}typeof t.getDefaultProps=="function"&&!t.getDefaultProps.isReactClassApproved&&j("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Vt(e){{for(var t=Object.keys(e.props),r=0;r<t.length;r++){var f=t[r];if(f!=="children"&&f!=="key"){B(e),j("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",f),B(null);break}}e.ref!==null&&(B(e),j("Invalid attribute `ref` supplied to `React.Fragment`."),B(null))}}function Ke(e,t,r,f,b,m){{var _=ue(e);if(!_){var p="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(p+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var C=Wt(b);C?p+=C:p+=ze();var E;e===null?E="null":he(e)?E="array":e!==void 0&&e.$$typeof===o?(E="<"+(A(e.type)||"Unknown")+" />",p=" Did you accidentally export a JSX literal instead of a component?"):E=typeof e,j("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",E,p)}var w=Ut(e,t,r,b,m);if(w==null)return w;if(_){var x=t.children;if(x!==void 0)if(f)if(he(x)){for(var z=0;z<x.length;z++)Je(x[z],e);Object.freeze&&Object.freeze(x)}else j("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Je(x,e)}return e===a?Vt(w):Yt(w),w}}function Bt(e,t,r){return Ke(e,t,r,!0)}function zt(e,t,r){return Ke(e,t,r,!1)}var Gt=zt,Ht=Bt;H.Fragment=a,H.jsx=Gt,H.jsxs=Ht}()),H}process.env.NODE_ENV==="production"?ne.exports=Qe():ne.exports=Ze();var c=ne.exports;const me="default",qe=(s,o)=>async(...n)=>{var S;const[a,d,...u]=n,h=d?{...d}:{method:"GET"};let i=new Headers;h.headers&&(i=h.headers instanceof Headers?h.headers:new Headers(h.headers));const g=await o().getValidTokenAsync(),k=(S=g==null?void 0:g.tokens)==null?void 0:S.accessToken;i.has("Accept")||i.set("Accept","application/json"),k&&(i.set("Authorization",`Bearer ${k}`),h.credentials||(h.credentials="same-origin"));const O={...h,headers:i};return await s(a,O,...u)},$e=(s=null,o=me)=>n=>a=>{const{fetch:d}=Oe(s||a.fetch,o);return c.jsx(n,{...a,fetch:d})},Oe=(s=null,o=me)=>{const n=s||window.fetch,a=l.OidcClient.get;return{fetch:y.useCallback((u,h)=>qe(n,()=>a(o))(u,h),[n,o])}},Ee=()=>c.jsx("div",{className:"oidc-authenticating",children:c.jsxs("div",{className:"oidc-authenticating__container",children:[c.jsx("h1",{className:"oidc-authenticating__title",children:"Error authentication"}),c.jsx("p",{className:"oidc-authenticating__content",children:"An error occurred during authentication."})]})}),et=()=>c.jsx("div",{className:"oidc-authenticating",children:c.jsxs("div",{className:"oidc-authenticating__container",children:[c.jsx("h1",{className:"oidc-authenticating__title",children:"Authentication in progress"}),c.jsx("p",{className:"oidc-authenticating__content",children:"You will be redirected to the login page."})]})}),tt=()=>Math.random().toString(36).substr(2,6),nt=(s,o)=>(n,a)=>{if(typeof s.CustomEvent=="function")return new s.CustomEvent(n,a);const d=a||{bubbles:!1,cancelable:!1,detail:void 0},u=o.createEvent("CustomEvent");return u.initCustomEvent(n,d.bubbles,d.cancelable,d.detail),u.prototype=s.Event.prototype,u},rt=(s,o,n)=>({replaceState:(a,d)=>{const u=n(),h=d||s.history.state;s.history.replaceState({key:u,state:h},null,a),s.dispatchEvent(o("popstate"))}}),st=()=>rt(window,nt(window,document),tt),Te=()=>c.jsx("div",{className:"oidc-callback",children:c.jsxs("div",{className:"oidc-callback__container",children:[c.jsx("h1",{className:"oidc-callback__title",children:"Authentication complete"}),c.jsx("p",{className:"oidc-callback__content",children:"You will be redirected to your application."})]})}),ot=({callBackError:s,callBackSuccess:o,configurationName:n,withCustomHistory:a})=>{const[d,u]=y.useState(!1);y.useEffect(()=>{let v=!0;return(async()=>{const k=l.OidcClient.get;try{const{callbackPath:O}=await k(n).loginCallbackAsync();(a?a():st()).replaceState(O||"/")}catch(O){v&&(console.warn(O),u(!0))}})(),()=>{v=!1}},[]);const h=s||Ee,i=o||Te;return d?c.jsx(h,{configurationName:n}):c.jsx(i,{configurationName:n})},at=()=>c.jsx("span",{className:"oidc-loading",children:"Loading"}),ct=()=>c.jsx("div",{className:"oidc-serviceworker",children:c.jsxs("div",{className:"oidc-serviceworker__container",children:[c.jsx("h1",{className:"oidc-serviceworker__title",children:"Unable to authenticate on this browser"}),c.jsx("p",{className:"oidc-serviceworker__content",children:"Your browser is not secure enough to make authentication work. Try updating your browser or use a newer browser."})]})}),it=()=>c.jsx("div",{className:"oidc-session-lost",children:c.jsxs("div",{className:"oidc-session-lost__container",children:[c.jsx("h1",{className:"oidc-session-lost__title",children:"Session timed out"}),c.jsx("p",{className:"oidc-session-lost__content",children:"Your session has expired. Please re-authenticate."})]})}),lt=({configurationName:s})=>(y.useEffect(()=>{(async()=>{const n=l.OidcClient.get;n(s).silentLoginCallbackAsync()})()},[]),c.jsx(c.Fragment,{})),ut=({configurationName:s})=>{const o=l.getParseQueryStringFromLocation(window.location.href),n=l.OidcClient.get,a=n(s);let d=null;for(const[u,h]of Object.entries(o))u==="state"||u==="scope"||(d===null&&(d={}),d[u]=h);return y.useEffect(()=>{a.tokens||a.loginAsync(null,d,!0,o.scope)},[]),c.jsx(c.Fragment,{})},dt=({callbackErrorComponent:s,callbackSuccessComponent:o,redirect_uri:n,silent_redirect_uri:a,silent_login_uri:d,children:u,configurationName:h,withCustomHistory:i=null})=>{const v=window?l.getPath(window.location.href):"",[g,k]=y.useState(v);y.useEffect(()=>{const S=()=>k(l.getPath(window.location.href));return S(),window.addEventListener("popstate",S,!1),()=>window.removeEventListener("popstate",S,!1)},[]);const O=l.getPath(n);if(a&&g===l.getPath(a))return c.jsx(lt,{configurationName:h});if(d&&g===l.getPath(d))return c.jsx(ut,{configurationName:h});switch(g){case O:return c.jsx(ot,{callBackError:s,callBackSuccess:o,configurationName:h,withCustomHistory:i});default:return c.jsx(c.Fragment,{children:u})}},ft=y.memo(dt),we={name:"",data:null},vt=({loadingComponent:s,children:o,configurationName:n})=>{const[a,d]=y.useState(!0),u=l.OidcClient.get,h=u(n);y.useEffect(()=>{let v=!0;return h&&h.tryKeepExistingSessionAsync().then(()=>{v&&d(!1)}),()=>{v=!1}},[n]);const i=s;return c.jsx(c.Fragment,{children:a?c.jsx(i,{configurationName:n}):c.jsx(c.Fragment,{children:o})})},J=({isLoading:s,loadingComponent:o,children:n,configurationName:a})=>{const d=o;return s?c.jsx(d,{configurationName:a,children:n}):c.jsx(c.Fragment,{children:n})},ht=({children:s,configuration:o,configurationName:n="default",callbackSuccessComponent:a=Te,authenticatingComponent:d=et,loadingComponent:u=at,serviceWorkerNotSupportedComponent:h=ct,authenticatingErrorComponent:i=Ee,sessionLostComponent:v=it,onSessionLost:g=null,onLogoutFromAnotherTab:k=null,onLogoutFromSameTab:O=null,withCustomHistory:S=null,onEvent:D=null,getFetch:X=null})=>{const W=(P="default")=>l.OidcClient.getOrCreate(X??l.getFetchDefault)(o,P),[oe,L]=y.useState(!0),[j,M]=y.useState(we),[ae,ce]=y.useState("default");y.useEffect(()=>{const F=W(n).subscribeEvents((T,N)=>{D&&D(n,T,N)});return()=>{W(n).removeEventSubscription(F)}},[n,D]),y.useEffect(()=>{const F=W(n).subscribeEvents((T,N)=>{if(T===l.OidcClient.eventNames.refreshTokensAsync_error||T===l.OidcClient.eventNames.syncTokensAsync_error){if(g!=null){g();return}M({name:T,data:N})}else if(T===l.OidcClient.eventNames.logout_from_another_tab){if(k!=null){k();return}M({name:T,data:N})}else T===l.OidcClient.eventNames.logout_from_same_tab?O!=null&&O():T===l.OidcClient.eventNames.loginAsync_begin||T===l.OidcClient.eventNames.loginCallbackAsync_end||T===l.OidcClient.eventNames.loginAsync_error||T===l.OidcClient.eventNames.loginCallbackAsync_error?M({name:T,data:N}):T===l.OidcClient.eventNames.service_worker_not_supported_by_browser&&o.service_worker_only===!0&&M({name:T,data:N})});return ce(n),L(!1),()=>{W(n).removeEventSubscription(F),M(we)}},[o,n]);const ie=v,le=d,U=u,Q=h,ue=i,Y=oe||ae!==n,V=W(n);switch(j.name){case l.OidcClient.eventNames.service_worker_not_supported_by_browser:return c.jsx(J,{loadingComponent:U,isLoading:Y,configurationName:n,children:c.jsx(Q,{configurationName:n})});case l.OidcClient.eventNames.loginAsync_begin:return c.jsx(J,{loadingComponent:U,isLoading:Y,configurationName:n,children:c.jsx(le,{configurationName:n})});case l.OidcClient.eventNames.loginAsync_error:case l.OidcClient.eventNames.loginCallbackAsync_error:return c.jsx(J,{loadingComponent:U,isLoading:Y,configurationName:n,children:c.jsx(ue,{configurationName:n})});case l.OidcClient.eventNames.refreshTokensAsync_error:case l.OidcClient.eventNames.syncTokensAsync_error:case l.OidcClient.eventNames.logout_from_another_tab:return c.jsx(J,{loadingComponent:U,isLoading:Y,configurationName:n,children:c.jsx(ie,{configurationName:n})});default:return c.jsx(J,{loadingComponent:U,isLoading:Y,configurationName:n,children:c.jsx(ft,{redirect_uri:V.configuration.redirect_uri,silent_redirect_uri:V.configuration.silent_redirect_uri,silent_login_uri:V.configuration.silent_login_uri,callbackSuccessComponent:a,callbackErrorComponent:i,authenticatingComponent:d,configurationName:n,withCustomHistory:S,children:c.jsx(vt,{loadingComponent:U,configurationName:n,children:s})})})}},Re=({children:s,callbackPath:o=null,extras:n=null,configurationName:a="default"})=>{const d=l.OidcClient.get,u=d(a);return y.useEffect(()=>{u.tokens||u.loginAsync(o,n)},[a,o,n]),u.tokens?c.jsx(c.Fragment,{children:s}):null},pt=(s,o=null,n=null,a="default")=>d=>c.jsx(Re,{callbackPath:o,extras:n,configurationName:a,children:c.jsx(s,{...d})}),re="default",se=(s,o)=>{let n=!1;return s(o)&&(n=s(o).tokens!=null),n},_t=(s=re)=>{const o=l.OidcClient.get,[n,a]=y.useState(se(o,s));return y.useEffect(()=>{let i=!0;const v=o(s);a(se(o,s));const g=v.subscribeEvents((k,O)=>{(k===l.OidcClient.eventNames.logout_from_another_tab||k===l.OidcClient.eventNames.logout_from_same_tab||k===l.OidcClient.eventNames.token_aquired)&&i&&a(se(o,s))});return()=>{i=!1,v.removeEventSubscription(g)}},[s]),{login:(i=void 0,v=null,g=!1)=>o(s).loginAsync(i,v,!1,void 0,g),logout:(i=void 0,v=null)=>o(s).logoutAsync(i,v),renewTokens:async(i=null)=>{const v=await o(s).renewTokensAsync(i);return{accessToken:v.accessToken,accessTokenPayload:v.accessTokenPayload,idToken:v.idToken,idTokenPayload:v.idTokenPayload}},isAuthenticated:n}},Se={accessToken:null,accessTokenPayload:null},gt=s=>{const o=l.OidcClient.get,n=o(s);if(n.tokens){const a=n.tokens;return{accessToken:a.accessToken,accessTokenPayload:a.accessTokenPayload}}return Se},yt=(s=re)=>{const o=l.OidcClient.get,[n,a]=y.useState(gt(s));return y.useEffect(()=>{let d=!0;const u=o(s);if(u.tokens){const i=u.tokens;a({accessToken:i.accessToken,accessTokenPayload:i.accessTokenPayload})}const h=u.subscribeEvents((i,v)=>{if((i===l.OidcClient.eventNames.token_renewed||i===l.OidcClient.eventNames.token_aquired||i===l.OidcClient.eventNames.logout_from_another_tab||i===l.OidcClient.eventNames.logout_from_same_tab||i===l.OidcClient.eventNames.refreshTokensAsync_error||i===l.OidcClient.eventNames.syncTokensAsync_error)&&d){const g=u.tokens;a(g!=null?{accessToken:g.accessToken,accessTokenPayload:g.accessTokenPayload}:Se)}});return()=>{d=!1,u.removeEventSubscription(h)}},[s]),n},je={idToken:null,idTokenPayload:null},bt=s=>{const o=l.OidcClient.get,n=o(s);if(n.tokens){const a=n.tokens;return{idToken:a.idToken,idTokenPayload:a.idTokenPayload}}return je},kt=(s=re)=>{const o=l.OidcClient.get,[n,a]=y.useState(bt(s));return y.useEffect(()=>{let d=!0;const u=o(s);if(u.tokens){const i=u.tokens;a({idToken:i.idToken,idTokenPayload:i.idTokenPayload})}const h=u.subscribeEvents((i,v)=>{if((i===l.OidcClient.eventNames.token_renewed||i===l.OidcClient.eventNames.token_aquired||i===l.OidcClient.eventNames.logout_from_another_tab||i===l.OidcClient.eventNames.logout_from_same_tab||i===l.OidcClient.eventNames.refreshTokensAsync_error||i===l.OidcClient.eventNames.syncTokensAsync_error)&&d){const g=u.tokens;a(g!=null?{idToken:g.idToken,idTokenPayload:g.idTokenPayload}:je)}});return()=>{d=!1,u.removeEventSubscription(h)}},[s]),n};var Ce=(s=>(s.Unauthenticated="Unauthenticated",s.Loading="Loading user",s.Loaded="User loaded",s.LoadingError="Error loading user",s))(Ce||{});const mt=(s="default")=>{const[o,n]=y.useState({user:null,status:"Unauthenticated"}),[a,d]=y.useState(""),u=l.OidcClient.get(s);y.useEffect(()=>{let i=!0;if(u&&u.tokens){n({...o,status:"Loading user"});const v=a!=="";u.userInfoAsync(v).then(g=>{i&&n({user:g,status:"User loaded"})}).catch(()=>n({...o,status:"Error loading user"}))}else n({user:null,status:"Unauthenticated"});return()=>{i=!1}},[a]);const h=()=>{d(a+" ")};return{oidcUser:o.user,oidcUserLoadingState:o.status,reloadOidcUser:h}};Object.defineProperty(R,"TokenRenewMode",{enumerable:!0,get:()=>l.TokenRenewMode}),R.OidcProvider=ht,R.OidcSecure=Re,R.OidcUserStatus=Ce,R.useOidc=_t,R.useOidcAccessToken=yt,R.useOidcFetch=Oe,R.useOidcIdToken=kt,R.useOidcUser=mt,R.withOidcFetch=$e,R.withOidcSecure=pt,Object.defineProperty(R,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axa-fr/react-oidc",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.umd.cjs",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"lint": "eslint src"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@axa-fr/oidc-client-service-worker": "
|
|
44
|
-
"@axa-fr/
|
|
43
|
+
"@axa-fr/oidc-client-service-worker": "7.0.0",
|
|
44
|
+
"@axa-fr/oidc-client": "7.0.0",
|
|
45
45
|
"base64-js": "1.5.1"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
@@ -52,19 +52,11 @@
|
|
|
52
52
|
"@testing-library/react": "13.3.0",
|
|
53
53
|
"@testing-library/user-event": "14.4.3",
|
|
54
54
|
"@types/react": "^18.2.15",
|
|
55
|
-
"@typescript-eslint/eslint-plugin": "^5.50.0",
|
|
56
|
-
"@typescript-eslint/parser": "^5.50.0",
|
|
57
55
|
"@vitejs/plugin-react": "4.0.3",
|
|
58
56
|
"@vitest/coverage-v8": "^0.33.0",
|
|
59
57
|
"cpy": "^10.1.0",
|
|
60
58
|
"cpy-cli": "^5.0.0",
|
|
61
59
|
"cross-env": "^7.0.3",
|
|
62
|
-
"eslint": "^8.26.0",
|
|
63
|
-
"eslint-config-standard": "^17.1.0",
|
|
64
|
-
"eslint-config-standard-with-typescript": "^36.1.0",
|
|
65
|
-
"eslint-import-resolver-typescript": "^3.5.5",
|
|
66
|
-
"eslint-plugin-react": "^7.32.2",
|
|
67
|
-
"eslint-plugin-simple-import-sort": "^10.0.0",
|
|
68
60
|
"jsdom": "22.1.0",
|
|
69
61
|
"msw": "1.2.2",
|
|
70
62
|
"react": "^18.2.0",
|
package/src/FetchToken.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Fetch,
|
|
1
|
+
import { Fetch, OidcClient } from '@axa-fr/oidc-client';
|
|
2
2
|
import { useCallback } from 'react';
|
|
3
3
|
|
|
4
4
|
export interface ComponentWithOidcFetchProps {
|
|
@@ -7,7 +7,7 @@ export interface ComponentWithOidcFetchProps {
|
|
|
7
7
|
|
|
8
8
|
const defaultConfigurationName = 'default';
|
|
9
9
|
|
|
10
|
-
const fetchWithToken = (fetch: Fetch, getOidcWithConfigurationName: () =>
|
|
10
|
+
const fetchWithToken = (fetch: Fetch, getOidcWithConfigurationName: () => OidcClient | null) => async (...params: Parameters<Fetch>) => {
|
|
11
11
|
const [url, options, ...rest] = params;
|
|
12
12
|
const optionTmp = options ? { ...options } : { method: 'GET' };
|
|
13
13
|
|
|
@@ -45,7 +45,7 @@ export const withOidcFetch = (fetch: Fetch = null, configurationName = defaultCo
|
|
|
45
45
|
|
|
46
46
|
export const useOidcFetch = (fetch: Fetch = null, configurationName = defaultConfigurationName) => {
|
|
47
47
|
const previousFetch = fetch || window.fetch;
|
|
48
|
-
const getOidc =
|
|
48
|
+
const getOidc = OidcClient.get;
|
|
49
49
|
|
|
50
50
|
const memoizedFetchCallback = useCallback(
|
|
51
51
|
(input: RequestInfo | URL, init?: RequestInit) => {
|
package/src/OidcProvider.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Fetch, getFetchDefault, OidcConfiguration,
|
|
1
|
+
import { Fetch, getFetchDefault, OidcConfiguration, OidcClient } from '@axa-fr/oidc-client';
|
|
2
2
|
import { ComponentType, FC, PropsWithChildren, useEffect, useState } from 'react';
|
|
3
3
|
|
|
4
4
|
import AuthenticatingError from './core/default-component/AuthenticateError.component.js';
|
|
@@ -8,7 +8,7 @@ import OidcRoutes from './core/routes/OidcRoutes.js';
|
|
|
8
8
|
import { CustomHistory } from './core/routes/withRouter.js';
|
|
9
9
|
|
|
10
10
|
export type oidcContext = {
|
|
11
|
-
(name?: string):
|
|
11
|
+
(name?: string): OidcClient;
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
const defaultEventState = { name: '', data: null };
|
|
@@ -38,7 +38,7 @@ export type OidcSessionProps = {
|
|
|
38
38
|
|
|
39
39
|
const OidcSession: FC<PropsWithChildren<OidcSessionProps>> = ({ loadingComponent, children, configurationName }) => {
|
|
40
40
|
const [isLoading, setIsLoading] = useState(true);
|
|
41
|
-
const getOidc =
|
|
41
|
+
const getOidc = OidcClient.get;
|
|
42
42
|
const oidc = getOidc(configurationName);
|
|
43
43
|
useEffect(() => {
|
|
44
44
|
let isMounted = true;
|
|
@@ -94,7 +94,7 @@ export const OidcProvider: FC<PropsWithChildren<OidcProviderProps>> = ({
|
|
|
94
94
|
getFetch = null,
|
|
95
95
|
}) => {
|
|
96
96
|
const getOidc = (configurationName = 'default') => {
|
|
97
|
-
return
|
|
97
|
+
return OidcClient.getOrCreate(getFetch ?? getFetchDefault)(configuration, configurationName);
|
|
98
98
|
};
|
|
99
99
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
100
100
|
const [loading, setLoading] = useState(true);
|
|
@@ -117,30 +117,30 @@ export const OidcProvider: FC<PropsWithChildren<OidcProviderProps>> = ({
|
|
|
117
117
|
useEffect(() => {
|
|
118
118
|
const oidc = getOidc(configurationName);
|
|
119
119
|
const newSubscriptionId = oidc.subscribeEvents((name, data) => {
|
|
120
|
-
if (name ===
|
|
120
|
+
if (name === OidcClient.eventNames.refreshTokensAsync_error || name === OidcClient.eventNames.syncTokensAsync_error) {
|
|
121
121
|
if (onSessionLost != null) {
|
|
122
122
|
onSessionLost();
|
|
123
123
|
return;
|
|
124
124
|
}
|
|
125
125
|
setEvent({ name, data });
|
|
126
|
-
} else if (name ===
|
|
126
|
+
} else if (name === OidcClient.eventNames.logout_from_another_tab) {
|
|
127
127
|
if (onLogoutFromAnotherTab != null) {
|
|
128
128
|
onLogoutFromAnotherTab();
|
|
129
129
|
return;
|
|
130
130
|
}
|
|
131
131
|
setEvent({ name, data });
|
|
132
|
-
} else if (name ===
|
|
132
|
+
} else if (name === OidcClient.eventNames.logout_from_same_tab) {
|
|
133
133
|
if (onLogoutFromSameTab != null) {
|
|
134
134
|
onLogoutFromSameTab();
|
|
135
135
|
}
|
|
136
136
|
// setEvent({name, data});
|
|
137
|
-
} else if (name ===
|
|
138
|
-
name ===
|
|
139
|
-
name ===
|
|
140
|
-
name ===
|
|
137
|
+
} else if (name === OidcClient.eventNames.loginAsync_begin ||
|
|
138
|
+
name === OidcClient.eventNames.loginCallbackAsync_end ||
|
|
139
|
+
name === OidcClient.eventNames.loginAsync_error ||
|
|
140
|
+
name === OidcClient.eventNames.loginCallbackAsync_error
|
|
141
141
|
) {
|
|
142
142
|
setEvent({ name, data });
|
|
143
|
-
} else if (name ===
|
|
143
|
+
} else if (name === OidcClient.eventNames.service_worker_not_supported_by_browser && configuration.service_worker_only === true) {
|
|
144
144
|
setEvent({ name, data });
|
|
145
145
|
}
|
|
146
146
|
});
|
|
@@ -165,22 +165,22 @@ export const OidcProvider: FC<PropsWithChildren<OidcProviderProps>> = ({
|
|
|
165
165
|
const oidc = getOidc(configurationName);
|
|
166
166
|
const eventName = event.name;
|
|
167
167
|
switch (eventName) {
|
|
168
|
-
case
|
|
168
|
+
case OidcClient.eventNames.service_worker_not_supported_by_browser:
|
|
169
169
|
return (<Switch loadingComponent={LoadingComponent} isLoading={isLoading} configurationName={configurationName}>
|
|
170
170
|
<ServiceWorkerNotSupportedComponent configurationName={configurationName} />
|
|
171
171
|
</Switch>);
|
|
172
|
-
case
|
|
172
|
+
case OidcClient.eventNames.loginAsync_begin:
|
|
173
173
|
return (<Switch loadingComponent={LoadingComponent} isLoading={isLoading} configurationName={configurationName}>
|
|
174
174
|
<AuthenticatingComponent configurationName={configurationName} />
|
|
175
175
|
</Switch>);
|
|
176
|
-
case
|
|
177
|
-
case
|
|
176
|
+
case OidcClient.eventNames.loginAsync_error:
|
|
177
|
+
case OidcClient.eventNames.loginCallbackAsync_error:
|
|
178
178
|
return (<Switch loadingComponent={LoadingComponent} isLoading={isLoading} configurationName={configurationName}>
|
|
179
179
|
<AuthenticatingErrorComponent configurationName={configurationName} />
|
|
180
180
|
</Switch>);
|
|
181
|
-
case
|
|
182
|
-
case
|
|
183
|
-
case
|
|
181
|
+
case OidcClient.eventNames.refreshTokensAsync_error:
|
|
182
|
+
case OidcClient.eventNames.syncTokensAsync_error:
|
|
183
|
+
case OidcClient.eventNames.logout_from_another_tab:
|
|
184
184
|
return (<Switch loadingComponent={LoadingComponent} isLoading={isLoading} configurationName={configurationName}>
|
|
185
185
|
<SessionLostComponent configurationName={configurationName} />
|
|
186
186
|
</Switch>);
|