@axa-fr/react-oidc 7.26.3 → 7.26.4
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/OidcProvider.d.ts.map +1 -1
- package/dist/index.js +190 -188
- package/dist/index.umd.cjs +1 -1
- package/package.json +3 -3
- package/src/OidcProvider.tsx +5 -1
- package/src/ReactOidc.tsx +1 -1
- package/src/User.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OidcProvider.d.ts","sourceRoot":"","sources":["../src/OidcProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EAEL,cAAc,EACd,UAAU,EACV,iBAAiB,EAElB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,EAAE,EAAE,iBAAiB,EAAuB,MAAM,OAAO,CAAC;AAWlF,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D,MAAM,MAAM,WAAW,GAAG;IACxB,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;CAC7B,CAAC;AAIF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,wBAAwB,CAAC,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC;IAC9C,oBAAoB,CAAC,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC;IAC1C,uBAAuB,CAAC,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC;IAC7C,4BAA4B,CAAC,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC;IAClD,gBAAgB,CAAC,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC;IACtC,kCAAkC,CAAC,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC;IACxD,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,aAAa,CAAC,EAAE,iBAAiB,CAAC;IAClC,QAAQ,EAAE,GAAG,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAC3B,sBAAsB,CAAC,EAAE,MAAM,IAAI,CAAC;IACpC,mBAAmB,CAAC,EAAE,MAAM,IAAI,CAAC;IACjC,iBAAiB,CAAC,EAAE,MAAM,aAAa,CAAC;IACxC,OAAO,CAAC,EAAE,CAAC,aAAa,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC;IACnE,QAAQ,CAAC,EAAE,MAAM,KAAK,CAAC;IACvB,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,EAAE,iBAAiB,CAAC,GAAG,CAAC,CAAC;CAC1C,CAAC;AAqCF,eAAO,MAAM,YAAY,EAAE,EAAE,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,
|
|
1
|
+
{"version":3,"file":"OidcProvider.d.ts","sourceRoot":"","sources":["../src/OidcProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EAEL,cAAc,EACd,UAAU,EACV,iBAAiB,EAElB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,EAAE,EAAE,iBAAiB,EAAuB,MAAM,OAAO,CAAC;AAWlF,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D,MAAM,MAAM,WAAW,GAAG;IACxB,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;CAC7B,CAAC;AAIF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,wBAAwB,CAAC,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC;IAC9C,oBAAoB,CAAC,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC;IAC1C,uBAAuB,CAAC,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC;IAC7C,4BAA4B,CAAC,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC;IAClD,gBAAgB,CAAC,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC;IACtC,kCAAkC,CAAC,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC;IACxD,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,aAAa,CAAC,EAAE,iBAAiB,CAAC;IAClC,QAAQ,EAAE,GAAG,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAC3B,sBAAsB,CAAC,EAAE,MAAM,IAAI,CAAC;IACpC,mBAAmB,CAAC,EAAE,MAAM,IAAI,CAAC;IACjC,iBAAiB,CAAC,EAAE,MAAM,aAAa,CAAC;IACxC,OAAO,CAAC,EAAE,CAAC,aAAa,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC;IACnE,QAAQ,CAAC,EAAE,MAAM,KAAK,CAAC;IACvB,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,EAAE,iBAAiB,CAAC,GAAG,CAAC,CAAC;CAC1C,CAAC;AAqCF,eAAO,MAAM,YAAY,EAAE,EAAE,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,CAoLjE,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,165 +1,165 @@
|
|
|
1
1
|
import { jsx as i, jsxs as S, Fragment as m } from "react/jsx-runtime";
|
|
2
|
-
import { OidcClient as c, getParseQueryStringFromLocation as
|
|
3
|
-
import { OidcClient as
|
|
4
|
-
import
|
|
5
|
-
const
|
|
6
|
-
const { fetch: r } =
|
|
2
|
+
import { OidcClient as c, getParseQueryStringFromLocation as Q, getPath as O, OidcLocation as F, getFetchDefault as J } from "@axa-fr/oidc-client";
|
|
3
|
+
import { OidcClient as Ue, OidcLocation as Me, TokenAutomaticRenewMode as Fe, TokenRenewMode as qe } from "@axa-fr/oidc-client";
|
|
4
|
+
import V, { useCallback as X, useState as p, useEffect as v } from "react";
|
|
5
|
+
const x = "default", Z = (t, s, e = !1) => async (...n) => await s().fetchWithTokens(t, e)(...n), Ce = (t = null, s = x, e = !1) => (n) => (o) => {
|
|
6
|
+
const { fetch: r } = ee(
|
|
7
7
|
t || o.fetch,
|
|
8
|
-
|
|
8
|
+
s,
|
|
9
9
|
e
|
|
10
10
|
);
|
|
11
|
-
return /* @__PURE__ */ i(
|
|
12
|
-
},
|
|
13
|
-
const
|
|
14
|
-
return { fetch:
|
|
15
|
-
(
|
|
16
|
-
|
|
17
|
-
() => o(
|
|
11
|
+
return /* @__PURE__ */ i(n, { ...o, fetch: r });
|
|
12
|
+
}, ee = (t = null, s = x, e = !1) => {
|
|
13
|
+
const n = t || window.fetch, o = c.get;
|
|
14
|
+
return { fetch: X(
|
|
15
|
+
(d, l) => Z(
|
|
16
|
+
n,
|
|
17
|
+
() => o(s),
|
|
18
18
|
e
|
|
19
|
-
)(
|
|
20
|
-
[
|
|
19
|
+
)(d, l),
|
|
20
|
+
[n, s, e]
|
|
21
21
|
) };
|
|
22
|
-
},
|
|
22
|
+
}, W = () => /* @__PURE__ */ i("div", { className: "oidc-authenticating", children: /* @__PURE__ */ S("div", { className: "oidc-authenticating__container", children: [
|
|
23
23
|
/* @__PURE__ */ i("h1", { className: "oidc-authenticating__title", children: "Error authentication" }),
|
|
24
24
|
/* @__PURE__ */ i("p", { className: "oidc-authenticating__content", children: "An error occurred during authentication." })
|
|
25
|
-
] }) }),
|
|
25
|
+
] }) }), te = () => /* @__PURE__ */ i("div", { className: "oidc-authenticating", children: /* @__PURE__ */ S("div", { className: "oidc-authenticating__container", children: [
|
|
26
26
|
/* @__PURE__ */ i("h1", { className: "oidc-authenticating__title", children: "Authentication in progress" }),
|
|
27
27
|
/* @__PURE__ */ i("p", { className: "oidc-authenticating__content", children: "You will be redirected to the login page." })
|
|
28
|
-
] }) }),
|
|
28
|
+
] }) }), se = () => Math.random().toString(36).slice(2, 8), ne = (t, s) => (e, n) => {
|
|
29
29
|
if (typeof t.CustomEvent == "function")
|
|
30
|
-
return new t.CustomEvent(e,
|
|
31
|
-
const o =
|
|
30
|
+
return new t.CustomEvent(e, n);
|
|
31
|
+
const o = n || { bubbles: !1, cancelable: !1, detail: void 0 }, r = s.createEvent("CustomEvent");
|
|
32
32
|
return r.initCustomEvent(
|
|
33
33
|
e,
|
|
34
34
|
o.bubbles,
|
|
35
35
|
o.cancelable,
|
|
36
36
|
o.detail
|
|
37
37
|
), r.prototype = t.Event.prototype, r;
|
|
38
|
-
},
|
|
39
|
-
replaceState: (
|
|
40
|
-
const r = e(),
|
|
41
|
-
t.history.replaceState({ key: r, state:
|
|
38
|
+
}, oe = (t, s, e) => ({
|
|
39
|
+
replaceState: (n, o) => {
|
|
40
|
+
const r = e(), d = o || t.history.state;
|
|
41
|
+
t.history.replaceState({ key: r, state: d }, null, n), t.dispatchEvent(s("popstate"));
|
|
42
42
|
}
|
|
43
|
-
}),
|
|
43
|
+
}), ce = () => oe(window, ne(window, document), se), R = () => /* @__PURE__ */ i("div", { className: "oidc-callback", children: /* @__PURE__ */ S("div", { className: "oidc-callback__container", children: [
|
|
44
44
|
/* @__PURE__ */ i("h1", { className: "oidc-callback__title", children: "Authentication complete" }),
|
|
45
45
|
/* @__PURE__ */ i("p", { className: "oidc-callback__content", children: "You will be redirected to your application." })
|
|
46
|
-
] }) }),
|
|
46
|
+
] }) }), re = ({
|
|
47
47
|
callBackError: t,
|
|
48
|
-
callBackSuccess:
|
|
48
|
+
callBackSuccess: s,
|
|
49
49
|
configurationName: e,
|
|
50
|
-
withCustomHistory:
|
|
50
|
+
withCustomHistory: n
|
|
51
51
|
}) => {
|
|
52
|
-
const [o, r] =
|
|
53
|
-
|
|
54
|
-
let
|
|
52
|
+
const [o, r] = p(!1);
|
|
53
|
+
v(() => {
|
|
54
|
+
let a = !0;
|
|
55
55
|
return (async () => {
|
|
56
56
|
const _ = c.get;
|
|
57
57
|
try {
|
|
58
58
|
const { callbackPath: k } = await _(e).loginCallbackAsync();
|
|
59
|
-
(
|
|
59
|
+
(n ? n() : ce()).replaceState(k || "/");
|
|
60
60
|
} catch (k) {
|
|
61
|
-
|
|
61
|
+
a && (console.warn(k), r(!0));
|
|
62
62
|
}
|
|
63
63
|
})(), () => {
|
|
64
|
-
|
|
64
|
+
a = !1;
|
|
65
65
|
};
|
|
66
66
|
}, []);
|
|
67
|
-
const
|
|
68
|
-
return o ? /* @__PURE__ */ i(
|
|
69
|
-
},
|
|
67
|
+
const d = t || W, l = s || R;
|
|
68
|
+
return o ? /* @__PURE__ */ i(d, { configurationName: e }) : /* @__PURE__ */ i(l, { configurationName: e });
|
|
69
|
+
}, ie = () => /* @__PURE__ */ i("span", { className: "oidc-loading", children: "Loading" }), le = () => /* @__PURE__ */ i("div", { className: "oidc-serviceworker", children: /* @__PURE__ */ S("div", { className: "oidc-serviceworker__container", children: [
|
|
70
70
|
/* @__PURE__ */ i("h1", { className: "oidc-serviceworker__title", children: "Unable to authenticate on this browser" }),
|
|
71
71
|
/* @__PURE__ */ i("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." })
|
|
72
|
-
] }) }),
|
|
72
|
+
] }) }), ae = () => /* @__PURE__ */ i("div", { className: "oidc-session-lost", children: /* @__PURE__ */ S("div", { className: "oidc-session-lost__container", children: [
|
|
73
73
|
/* @__PURE__ */ i("h1", { className: "oidc-session-lost__title", children: "Session timed out" }),
|
|
74
74
|
/* @__PURE__ */ i("p", { className: "oidc-session-lost__content", children: "Your session has expired. Please re-authenticate." })
|
|
75
|
-
] }) }),
|
|
75
|
+
] }) }), de = ({ configurationName: t }) => (v(() => {
|
|
76
76
|
(async () => {
|
|
77
77
|
c.get(t).silentLoginCallbackAsync();
|
|
78
78
|
})().catch((e) => {
|
|
79
79
|
console.error("Error during silent login callback:", e);
|
|
80
80
|
});
|
|
81
|
-
}, [t]), null),
|
|
82
|
-
const
|
|
81
|
+
}, [t]), null), ue = ({ configurationName: t }) => {
|
|
82
|
+
const s = Q(window.location.href), e = c.get, n = e(t);
|
|
83
83
|
let o = null;
|
|
84
|
-
for (const [r,
|
|
85
|
-
r === "state" || r === "scope" || (o === null && (o = {}), o[r] =
|
|
86
|
-
return
|
|
87
|
-
|
|
84
|
+
for (const [r, d] of Object.entries(s))
|
|
85
|
+
r === "state" || r === "scope" || (o === null && (o = {}), o[r] = d);
|
|
86
|
+
return v(() => {
|
|
87
|
+
n.tokens || n.loginAsync(null, o, !0, s.scope);
|
|
88
88
|
}, []), /* @__PURE__ */ i(m, {});
|
|
89
|
-
},
|
|
89
|
+
}, he = ({
|
|
90
90
|
callbackErrorComponent: t,
|
|
91
|
-
callbackSuccessComponent:
|
|
91
|
+
callbackSuccessComponent: s,
|
|
92
92
|
redirect_uri: e,
|
|
93
|
-
silent_redirect_uri:
|
|
93
|
+
silent_redirect_uri: n,
|
|
94
94
|
silent_login_uri: o,
|
|
95
95
|
children: r,
|
|
96
|
-
configurationName:
|
|
96
|
+
configurationName: d,
|
|
97
97
|
withCustomHistory: l = null
|
|
98
98
|
}) => {
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
const
|
|
102
|
-
return
|
|
99
|
+
const a = window ? O(window.location.href) : "", [u, _] = p(a);
|
|
100
|
+
v(() => {
|
|
101
|
+
const f = () => _(O(window.location.href));
|
|
102
|
+
return f(), window.addEventListener("popstate", f, !1), () => window.removeEventListener("popstate", f, !1);
|
|
103
103
|
}, []);
|
|
104
104
|
const k = O(e);
|
|
105
|
-
return
|
|
106
|
-
|
|
105
|
+
return n && u === O(n) ? /* @__PURE__ */ i(de, { configurationName: d }) : o && u === O(o) ? /* @__PURE__ */ i(ue, { configurationName: d }) : u === k ? /* @__PURE__ */ i(
|
|
106
|
+
re,
|
|
107
107
|
{
|
|
108
108
|
callBackError: t,
|
|
109
|
-
callBackSuccess:
|
|
110
|
-
configurationName:
|
|
109
|
+
callBackSuccess: s,
|
|
110
|
+
configurationName: d,
|
|
111
111
|
withCustomHistory: l
|
|
112
112
|
}
|
|
113
113
|
) : /* @__PURE__ */ i(m, { children: r });
|
|
114
|
-
},
|
|
114
|
+
}, ke = V.memo(he), q = { name: "", data: null }, _e = ({
|
|
115
115
|
loadingComponent: t,
|
|
116
|
-
children:
|
|
116
|
+
children: s,
|
|
117
117
|
configurationName: e
|
|
118
118
|
}) => {
|
|
119
|
-
const [
|
|
120
|
-
return
|
|
121
|
-
let
|
|
122
|
-
return
|
|
123
|
-
|
|
119
|
+
const [n, o] = p(!0), r = c.get, d = r(e);
|
|
120
|
+
return v(() => {
|
|
121
|
+
let a = !0;
|
|
122
|
+
return d && d.tryKeepExistingSessionAsync().then(() => {
|
|
123
|
+
a && o(!1);
|
|
124
124
|
}), () => {
|
|
125
|
-
|
|
125
|
+
a = !1;
|
|
126
126
|
};
|
|
127
|
-
}, [e]), /* @__PURE__ */ i(m, { children:
|
|
128
|
-
}, E = ({ isLoading: t, loadingComponent:
|
|
129
|
-
const o =
|
|
130
|
-
return t ? /* @__PURE__ */ i(o, { configurationName:
|
|
131
|
-
},
|
|
127
|
+
}, [e]), /* @__PURE__ */ i(m, { children: n ? /* @__PURE__ */ i(t, { configurationName: e }) : /* @__PURE__ */ i(m, { children: s }) });
|
|
128
|
+
}, E = ({ isLoading: t, loadingComponent: s, children: e, configurationName: n }) => {
|
|
129
|
+
const o = s;
|
|
130
|
+
return t ? /* @__PURE__ */ i(o, { configurationName: n, children: e }) : /* @__PURE__ */ i(m, { children: e });
|
|
131
|
+
}, Ae = ({
|
|
132
132
|
children: t,
|
|
133
|
-
configuration:
|
|
133
|
+
configuration: s,
|
|
134
134
|
configurationName: e = "default",
|
|
135
|
-
callbackSuccessComponent:
|
|
136
|
-
authenticatingComponent: o =
|
|
137
|
-
loadingComponent: r =
|
|
138
|
-
serviceWorkerNotSupportedComponent:
|
|
139
|
-
authenticatingErrorComponent: l =
|
|
140
|
-
sessionLostComponent:
|
|
135
|
+
callbackSuccessComponent: n = R,
|
|
136
|
+
authenticatingComponent: o = te,
|
|
137
|
+
loadingComponent: r = ie,
|
|
138
|
+
serviceWorkerNotSupportedComponent: d = le,
|
|
139
|
+
authenticatingErrorComponent: l = W,
|
|
140
|
+
sessionLostComponent: a = ae,
|
|
141
141
|
onSessionLost: u = null,
|
|
142
142
|
onLogoutFromAnotherTab: _ = null,
|
|
143
143
|
onLogoutFromSameTab: k = null,
|
|
144
|
-
withCustomHistory:
|
|
144
|
+
withCustomHistory: f = null,
|
|
145
145
|
onEvent: w = null,
|
|
146
146
|
getFetch: y = null,
|
|
147
147
|
location: P = null
|
|
148
148
|
}) => {
|
|
149
|
-
if (
|
|
149
|
+
if (s && s.redirect_uri && s.silent_redirect_uri && s.redirect_uri === s.silent_redirect_uri)
|
|
150
150
|
throw new Error("redirect_uri and silent_redirect_uri must be different");
|
|
151
|
-
const T = (
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
), [
|
|
155
|
-
|
|
151
|
+
const T = (N = "default") => c.getOrCreate(y ?? J, P ?? new F())(
|
|
152
|
+
s,
|
|
153
|
+
N
|
|
154
|
+
), [B, C] = p(q), [z, M] = p(e);
|
|
155
|
+
v(() => {
|
|
156
156
|
const I = T(e).subscribeEvents((h, g) => {
|
|
157
157
|
w && w(e, h, g);
|
|
158
158
|
});
|
|
159
159
|
return () => {
|
|
160
160
|
T(e).removeEventSubscription(I);
|
|
161
161
|
};
|
|
162
|
-
}, [e, w]),
|
|
162
|
+
}, [e, w]), v(() => {
|
|
163
163
|
const I = T(e).subscribeEvents((h, g) => {
|
|
164
164
|
if (h === c.eventNames.refreshTokensAsync_error || h === c.eventNames.syncTokensAsync_error) {
|
|
165
165
|
if (u != null) {
|
|
@@ -173,16 +173,18 @@ const D = "default", te = (t, n, e = !1) => async (...s) => await n().fetchWithT
|
|
|
173
173
|
return;
|
|
174
174
|
}
|
|
175
175
|
C({ name: h, data: g });
|
|
176
|
-
} else h === c.eventNames.logout_from_same_tab ? k?.() : h === c.eventNames.loginAsync_begin || h === c.eventNames.loginCallbackAsync_end || h === c.eventNames.loginAsync_error || h === c.eventNames.loginCallbackAsync_error ? C({ name: h, data: g }) : h === c.eventNames.service_worker_not_supported_by_browser &&
|
|
176
|
+
} else h === c.eventNames.logout_from_same_tab ? k?.() : h === c.eventNames.loginAsync_begin || h === c.eventNames.loginCallbackAsync_end || h === c.eventNames.loginAsync_error || h === c.eventNames.loginCallbackAsync_error ? C({ name: h, data: g }) : h === c.eventNames.service_worker_not_supported_by_browser && s.service_worker_only === !0 && C({ name: h, data: g });
|
|
177
177
|
});
|
|
178
178
|
return queueMicrotask(() => {
|
|
179
|
-
|
|
179
|
+
M(e), setLoading(!1);
|
|
180
180
|
}), () => {
|
|
181
|
-
T(e).removeEventSubscription(I), C(
|
|
181
|
+
T(e).removeEventSubscription(I), C(q);
|
|
182
182
|
};
|
|
183
|
-
}, [
|
|
184
|
-
|
|
185
|
-
|
|
183
|
+
}, [s, e]), v(() => {
|
|
184
|
+
M(e);
|
|
185
|
+
}, [e]);
|
|
186
|
+
const K = a, $ = o, b = r, G = d, H = l, A = z !== e, L = T(e);
|
|
187
|
+
switch (B.name) {
|
|
186
188
|
case c.eventNames.service_worker_not_supported_by_browser:
|
|
187
189
|
return /* @__PURE__ */ i(
|
|
188
190
|
E,
|
|
@@ -190,7 +192,7 @@ const D = "default", te = (t, n, e = !1) => async (...s) => await n().fetchWithT
|
|
|
190
192
|
loadingComponent: b,
|
|
191
193
|
isLoading: A,
|
|
192
194
|
configurationName: e,
|
|
193
|
-
children: /* @__PURE__ */ i(
|
|
195
|
+
children: /* @__PURE__ */ i(G, { configurationName: e })
|
|
194
196
|
}
|
|
195
197
|
);
|
|
196
198
|
case c.eventNames.loginAsync_begin:
|
|
@@ -200,7 +202,7 @@ const D = "default", te = (t, n, e = !1) => async (...s) => await n().fetchWithT
|
|
|
200
202
|
loadingComponent: b,
|
|
201
203
|
isLoading: A,
|
|
202
204
|
configurationName: e,
|
|
203
|
-
children: /* @__PURE__ */ i(
|
|
205
|
+
children: /* @__PURE__ */ i($, { configurationName: e })
|
|
204
206
|
}
|
|
205
207
|
);
|
|
206
208
|
case c.eventNames.loginAsync_error:
|
|
@@ -211,7 +213,7 @@ const D = "default", te = (t, n, e = !1) => async (...s) => await n().fetchWithT
|
|
|
211
213
|
loadingComponent: b,
|
|
212
214
|
isLoading: A,
|
|
213
215
|
configurationName: e,
|
|
214
|
-
children: /* @__PURE__ */ i(
|
|
216
|
+
children: /* @__PURE__ */ i(H, { configurationName: e })
|
|
215
217
|
}
|
|
216
218
|
);
|
|
217
219
|
case c.eventNames.refreshTokensAsync_error:
|
|
@@ -223,7 +225,7 @@ const D = "default", te = (t, n, e = !1) => async (...s) => await n().fetchWithT
|
|
|
223
225
|
loadingComponent: b,
|
|
224
226
|
isLoading: A,
|
|
225
227
|
configurationName: e,
|
|
226
|
-
children: /* @__PURE__ */ i(
|
|
228
|
+
children: /* @__PURE__ */ i(K, { configurationName: e })
|
|
227
229
|
}
|
|
228
230
|
);
|
|
229
231
|
default:
|
|
@@ -234,148 +236,148 @@ const D = "default", te = (t, n, e = !1) => async (...s) => await n().fetchWithT
|
|
|
234
236
|
isLoading: A,
|
|
235
237
|
configurationName: e,
|
|
236
238
|
children: /* @__PURE__ */ i(
|
|
237
|
-
|
|
239
|
+
ke,
|
|
238
240
|
{
|
|
239
|
-
redirect_uri:
|
|
240
|
-
silent_redirect_uri:
|
|
241
|
-
silent_login_uri:
|
|
242
|
-
callbackSuccessComponent:
|
|
241
|
+
redirect_uri: L.configuration.redirect_uri,
|
|
242
|
+
silent_redirect_uri: L.configuration.silent_redirect_uri,
|
|
243
|
+
silent_login_uri: L.configuration.silent_login_uri,
|
|
244
|
+
callbackSuccessComponent: n,
|
|
243
245
|
callbackErrorComponent: l,
|
|
244
246
|
authenticatingComponent: o,
|
|
245
247
|
configurationName: e,
|
|
246
|
-
withCustomHistory:
|
|
247
|
-
location: P ?? new
|
|
248
|
-
children: /* @__PURE__ */ i(
|
|
248
|
+
withCustomHistory: f,
|
|
249
|
+
location: P ?? new F(),
|
|
250
|
+
children: /* @__PURE__ */ i(_e, { loadingComponent: b, configurationName: e, children: t })
|
|
249
251
|
}
|
|
250
252
|
)
|
|
251
253
|
}
|
|
252
254
|
);
|
|
253
255
|
}
|
|
254
|
-
},
|
|
256
|
+
}, ve = ({
|
|
255
257
|
children: t,
|
|
256
|
-
callbackPath:
|
|
258
|
+
callbackPath: s = null,
|
|
257
259
|
extras: e = null,
|
|
258
|
-
configurationName:
|
|
260
|
+
configurationName: n = "default"
|
|
259
261
|
}) => {
|
|
260
|
-
const o = c.get, r = o(
|
|
261
|
-
return
|
|
262
|
-
r.tokens || r.loginAsync(
|
|
263
|
-
}, [
|
|
264
|
-
},
|
|
262
|
+
const o = c.get, r = o(n);
|
|
263
|
+
return v(() => {
|
|
264
|
+
r.tokens || r.loginAsync(s, e);
|
|
265
|
+
}, [n, s, e]), r.tokens ? /* @__PURE__ */ i(m, { children: t }) : null;
|
|
266
|
+
}, Oe = (t, s = null, e = null, n = "default") => (o) => /* @__PURE__ */ i(ve, { callbackPath: s, extras: e, configurationName: n, children: /* @__PURE__ */ i(t, { ...o }) }), U = "default", D = (t, s) => {
|
|
265
267
|
let e = !1;
|
|
266
|
-
return t(
|
|
267
|
-
},
|
|
268
|
-
const
|
|
269
|
-
|
|
268
|
+
return t(s) && (e = t(s).tokens != null), e;
|
|
269
|
+
}, Ee = (t = U) => {
|
|
270
|
+
const s = c.get, [e, n] = p(
|
|
271
|
+
() => D(s, t)
|
|
270
272
|
);
|
|
271
|
-
return
|
|
273
|
+
return v(() => {
|
|
272
274
|
let l = !0;
|
|
273
|
-
const
|
|
274
|
-
(_ === c.eventNames.logout_from_another_tab || _ === c.eventNames.logout_from_same_tab || _ === c.eventNames.token_acquired) && l &&
|
|
275
|
+
const a = s(t), u = a.subscribeEvents((_, k) => {
|
|
276
|
+
(_ === c.eventNames.logout_from_another_tab || _ === c.eventNames.logout_from_same_tab || _ === c.eventNames.token_acquired) && l && n(D(s, t));
|
|
275
277
|
});
|
|
276
278
|
return () => {
|
|
277
|
-
l = !1,
|
|
279
|
+
l = !1, a.removeEventSubscription(u);
|
|
278
280
|
};
|
|
279
|
-
}, [t]), { login: (l = void 0,
|
|
281
|
+
}, [t]), { login: (l = void 0, a = void 0, u = !1, _ = void 0) => s(t).loginAsync(
|
|
280
282
|
l,
|
|
281
|
-
|
|
283
|
+
a,
|
|
282
284
|
!1,
|
|
283
285
|
_,
|
|
284
286
|
u
|
|
285
|
-
), logout: (l = void 0,
|
|
286
|
-
const
|
|
287
|
+
), logout: (l = void 0, a = void 0) => s(t).logoutAsync(l, a), renewTokens: async (l = void 0) => {
|
|
288
|
+
const a = await s(t).renewTokensAsync(l);
|
|
287
289
|
return {
|
|
288
290
|
// @ts-ignore
|
|
289
|
-
accessToken:
|
|
291
|
+
accessToken: a.accessToken,
|
|
290
292
|
// @ts-ignore
|
|
291
|
-
accessTokenPayload:
|
|
293
|
+
accessTokenPayload: a.accessTokenPayload,
|
|
292
294
|
// @ts-ignore
|
|
293
|
-
idToken:
|
|
295
|
+
idToken: a.idToken,
|
|
294
296
|
// @ts-ignore
|
|
295
|
-
idTokenPayload:
|
|
297
|
+
idTokenPayload: a.idTokenPayload
|
|
296
298
|
};
|
|
297
299
|
}, isAuthenticated: e };
|
|
298
|
-
},
|
|
299
|
-
const
|
|
300
|
+
}, Y = { accessToken: null, accessTokenPayload: null }, fe = (t) => {
|
|
301
|
+
const s = c.get, e = s(t);
|
|
300
302
|
if (e.tokens) {
|
|
301
|
-
const
|
|
303
|
+
const n = e.tokens;
|
|
302
304
|
return {
|
|
303
|
-
accessToken:
|
|
304
|
-
accessTokenPayload:
|
|
305
|
-
generateDemonstrationOfProofOfPossessionAsync: e.configuration.demonstrating_proof_of_possession ? (o, r) => e.generateDemonstrationOfProofOfPossessionAsync(
|
|
305
|
+
accessToken: n.accessToken,
|
|
306
|
+
accessTokenPayload: n.accessTokenPayload,
|
|
307
|
+
generateDemonstrationOfProofOfPossessionAsync: e.configuration.demonstrating_proof_of_possession ? (o, r) => e.generateDemonstrationOfProofOfPossessionAsync(n.accessToken, o, r) : null
|
|
306
308
|
};
|
|
307
309
|
}
|
|
308
|
-
return
|
|
310
|
+
return Y;
|
|
309
311
|
};
|
|
310
|
-
function
|
|
311
|
-
return t.configuration.demonstrating_proof_of_possession ? (e,
|
|
312
|
+
function pe(t, s) {
|
|
313
|
+
return t.configuration.demonstrating_proof_of_possession ? (e, n, o = {}) => t.generateDemonstrationOfProofOfPossessionAsync(s.accessToken, e, n, o) : null;
|
|
312
314
|
}
|
|
313
|
-
const
|
|
314
|
-
const
|
|
315
|
-
return
|
|
315
|
+
const Se = (t = U) => {
|
|
316
|
+
const s = c.get, [e, n] = p(() => fe(t));
|
|
317
|
+
return v(() => {
|
|
316
318
|
let o = !0;
|
|
317
|
-
const r =
|
|
319
|
+
const r = s(t), d = r.subscribeEvents((l, a) => {
|
|
318
320
|
if ((l === c.eventNames.token_renewed || l === c.eventNames.token_acquired || l === c.eventNames.logout_from_another_tab || l === c.eventNames.logout_from_same_tab || l === c.eventNames.refreshTokensAsync_error || l === c.eventNames.syncTokensAsync_error) && o) {
|
|
319
321
|
const u = r.tokens;
|
|
320
|
-
|
|
322
|
+
n(
|
|
321
323
|
u != null ? {
|
|
322
324
|
accessToken: u.accessToken,
|
|
323
325
|
accessTokenPayload: u.accessTokenPayload,
|
|
324
|
-
generateDemonstrationOfProofOfPossessionAsync:
|
|
325
|
-
} :
|
|
326
|
+
generateDemonstrationOfProofOfPossessionAsync: pe(r, u)
|
|
327
|
+
} : Y
|
|
326
328
|
);
|
|
327
329
|
}
|
|
328
330
|
});
|
|
329
331
|
return () => {
|
|
330
|
-
o = !1, r.removeEventSubscription(
|
|
332
|
+
o = !1, r.removeEventSubscription(d);
|
|
331
333
|
};
|
|
332
334
|
}, [t]), e;
|
|
333
|
-
},
|
|
334
|
-
const
|
|
335
|
+
}, j = { idToken: null, idTokenPayload: null }, ye = (t) => {
|
|
336
|
+
const s = c.get, e = s(t);
|
|
335
337
|
if (e.tokens) {
|
|
336
|
-
const
|
|
337
|
-
return { idToken:
|
|
338
|
+
const n = e.tokens;
|
|
339
|
+
return { idToken: n.idToken, idTokenPayload: n.idTokenPayload };
|
|
338
340
|
}
|
|
339
|
-
return
|
|
340
|
-
},
|
|
341
|
-
const
|
|
342
|
-
return
|
|
341
|
+
return j;
|
|
342
|
+
}, Pe = (t = U) => {
|
|
343
|
+
const s = c.get, [e, n] = p(() => ye(t));
|
|
344
|
+
return v(() => {
|
|
343
345
|
let o = !0;
|
|
344
|
-
const r =
|
|
346
|
+
const r = s(t), d = r.subscribeEvents((l, a) => {
|
|
345
347
|
if ((l === c.eventNames.token_renewed || l === c.eventNames.token_acquired || l === c.eventNames.logout_from_another_tab || l === c.eventNames.logout_from_same_tab || l === c.eventNames.refreshTokensAsync_error || l === c.eventNames.syncTokensAsync_error) && o) {
|
|
346
348
|
const u = r.tokens;
|
|
347
|
-
|
|
348
|
-
u != null ? { idToken: u.idToken, idTokenPayload: u.idTokenPayload } :
|
|
349
|
+
n(
|
|
350
|
+
u != null ? { idToken: u.idToken, idTokenPayload: u.idTokenPayload } : j
|
|
349
351
|
);
|
|
350
352
|
}
|
|
351
353
|
});
|
|
352
354
|
return () => {
|
|
353
|
-
o = !1, r.removeEventSubscription(
|
|
355
|
+
o = !1, r.removeEventSubscription(d);
|
|
354
356
|
};
|
|
355
357
|
}, [t]), e;
|
|
356
358
|
};
|
|
357
|
-
var
|
|
358
|
-
const
|
|
359
|
-
const
|
|
360
|
-
user:
|
|
361
|
-
status:
|
|
359
|
+
var be = /* @__PURE__ */ ((t) => (t.Unauthenticated = "Unauthenticated", t.Loading = "Loading user", t.Loaded = "User loaded", t.LoadingError = "Error loading user", t))(be || {});
|
|
360
|
+
const Le = (t = "default", s = !1) => {
|
|
361
|
+
const n = c.get(t).userInfo(), [o, r] = p({
|
|
362
|
+
user: n,
|
|
363
|
+
status: n ? "User loaded" : "Unauthenticated"
|
|
362
364
|
/* Unauthenticated */
|
|
363
|
-
}), [
|
|
364
|
-
|
|
365
|
+
}), [d, l] = p(n ? 1 : 0), [a, u] = p(n ? 1 : 0);
|
|
366
|
+
v(() => {
|
|
365
367
|
const k = c.get(t);
|
|
366
|
-
let
|
|
368
|
+
let f = !0;
|
|
367
369
|
if (k && k.tokens) {
|
|
368
|
-
const y =
|
|
370
|
+
const y = d === a;
|
|
369
371
|
if (y && k.userInfo())
|
|
370
372
|
return;
|
|
371
373
|
queueMicrotask(() => {
|
|
372
|
-
|
|
374
|
+
f && (r({
|
|
373
375
|
...o,
|
|
374
376
|
status: "Loading user"
|
|
375
377
|
/* Loading */
|
|
376
|
-
}), u(
|
|
377
|
-
}), k.userInfoAsync(!y,
|
|
378
|
-
|
|
378
|
+
}), u(d));
|
|
379
|
+
}), k.userInfoAsync(!y, s).then((P) => {
|
|
380
|
+
f && r({
|
|
379
381
|
user: P,
|
|
380
382
|
status: "User loaded"
|
|
381
383
|
/* Loaded */
|
|
@@ -387,41 +389,41 @@ const Ie = (t = "default", n = !1) => {
|
|
|
387
389
|
}));
|
|
388
390
|
} else
|
|
389
391
|
queueMicrotask(() => {
|
|
390
|
-
|
|
392
|
+
f && r({
|
|
391
393
|
user: null,
|
|
392
394
|
status: "Unauthenticated"
|
|
393
395
|
/* Unauthenticated */
|
|
394
396
|
});
|
|
395
397
|
});
|
|
396
398
|
const w = k.subscribeEvents((y) => {
|
|
397
|
-
(y === c.eventNames.logout_from_another_tab || y === c.eventNames.logout_from_same_tab) &&
|
|
399
|
+
(y === c.eventNames.logout_from_another_tab || y === c.eventNames.logout_from_same_tab) && f && r({
|
|
398
400
|
user: null,
|
|
399
401
|
status: "Unauthenticated"
|
|
400
402
|
/* Unauthenticated */
|
|
401
403
|
});
|
|
402
404
|
});
|
|
403
405
|
return () => {
|
|
404
|
-
|
|
406
|
+
f = !1, k.removeEventSubscription(w);
|
|
405
407
|
};
|
|
406
|
-
}, [a]);
|
|
408
|
+
}, [d, t, s, a]);
|
|
407
409
|
const _ = () => {
|
|
408
|
-
l(
|
|
410
|
+
l(d + 1);
|
|
409
411
|
};
|
|
410
412
|
return { oidcUser: o.user, oidcUserLoadingState: o.status, reloadOidcUser: _ };
|
|
411
413
|
};
|
|
412
414
|
export {
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
415
|
+
Ue as OidcClient,
|
|
416
|
+
Me as OidcLocation,
|
|
417
|
+
Ae as OidcProvider,
|
|
418
|
+
ve as OidcSecure,
|
|
419
|
+
be as OidcUserStatus,
|
|
420
|
+
Fe as TokenAutomaticRenewMode,
|
|
421
|
+
qe as TokenRenewMode,
|
|
422
|
+
Ee as useOidc,
|
|
423
|
+
Se as useOidcAccessToken,
|
|
424
|
+
ee as useOidcFetch,
|
|
425
|
+
Pe as useOidcIdToken,
|
|
426
|
+
Le as useOidcUser,
|
|
427
|
+
Ce as withOidcFetch,
|
|
428
|
+
Oe as withOidcSecure
|
|
427
429
|
};
|
package/dist/index.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(h,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("react/jsx-runtime"),require("@axa-fr/oidc-client"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@axa-fr/oidc-client","react"],n):(h=typeof globalThis<"u"?globalThis:h||self,n(h["react-oidc"]={},h.jsxRuntime,h.oidcClient,h.React))})(this,(function(h,n,s,l){"use strict";const m="default",B=(t,c,e=!1)=>async(...o)=>await c().fetchWithTokens(t,e)(...o),z=(t=null,c=m,e=!1)=>o=>r=>{const{fetch:i}=F(t||r.fetch,c,e);return n.jsx(o,{...r,fetch:i})},F=(t=null,c=m,e=!1)=>{const o=t||window.fetch,r=s.OidcClient.get;return{fetch:l.useCallback((d,a)=>B(o,()=>r(c),e)(d,a),[o,c,e])}},I=()=>n.jsx("div",{className:"oidc-authenticating",children:n.jsxs("div",{className:"oidc-authenticating__container",children:[n.jsx("h1",{className:"oidc-authenticating__title",children:"Error authentication"}),n.jsx("p",{className:"oidc-authenticating__content",children:"An error occurred during authentication."})]})}),K=()=>n.jsx("div",{className:"oidc-authenticating",children:n.jsxs("div",{className:"oidc-authenticating__container",children:[n.jsx("h1",{className:"oidc-authenticating__title",children:"Authentication in progress"}),n.jsx("p",{className:"oidc-authenticating__content",children:"You will be redirected to the login page."})]})}),$=()=>Math.random().toString(36).slice(2,8),G=(t,c)=>(e,o)=>{if(typeof t.CustomEvent=="function")return new t.CustomEvent(e,o);const r=o||{bubbles:!1,cancelable:!1,detail:void 0},i=c.createEvent("CustomEvent");return i.initCustomEvent(e,r.bubbles,r.cancelable,r.detail),i.prototype=t.Event.prototype,i},H=(t,c,e)=>({replaceState:(o,r)=>{const i=e(),d=r||t.history.state;t.history.replaceState({key:i,state:d},null,o),t.dispatchEvent(c("popstate"))}}),Q=()=>H(window,G(window,document),$),U=()=>n.jsx("div",{className:"oidc-callback",children:n.jsxs("div",{className:"oidc-callback__container",children:[n.jsx("h1",{className:"oidc-callback__title",children:"Authentication complete"}),n.jsx("p",{className:"oidc-callback__content",children:"You will be redirected to your application."})]})}),J=({callBackError:t,callBackSuccess:c,configurationName:e,withCustomHistory:o})=>{const[r,i]=l.useState(!1);l.useEffect(()=>{let u=!0;return(async()=>{const O=s.OidcClient.get;try{const{callbackPath:_}=await O(e).loginCallbackAsync();(o?o():Q()).replaceState(_||"/")}catch(_){u&&(console.warn(_),i(!0))}})(),()=>{u=!1}},[]);const d=t||I,a=c||U;return r?n.jsx(d,{configurationName:e}):n.jsx(a,{configurationName:e})},V=()=>n.jsx("span",{className:"oidc-loading",children:"Loading"}),X=()=>n.jsx("div",{className:"oidc-serviceworker",children:n.jsxs("div",{className:"oidc-serviceworker__container",children:[n.jsx("h1",{className:"oidc-serviceworker__title",children:"Unable to authenticate on this browser"}),n.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."})]})}),Z=()=>n.jsx("div",{className:"oidc-session-lost",children:n.jsxs("div",{className:"oidc-session-lost__container",children:[n.jsx("h1",{className:"oidc-session-lost__title",children:"Session timed out"}),n.jsx("p",{className:"oidc-session-lost__content",children:"Your session has expired. Please re-authenticate."})]})}),x=({configurationName:t})=>(l.useEffect(()=>{(async()=>{s.OidcClient.get(t).silentLoginCallbackAsync()})().catch(e=>{console.error("Error during silent login callback:",e)})},[t]),null),R=({configurationName:t})=>{const c=s.getParseQueryStringFromLocation(window.location.href),e=s.OidcClient.get,o=e(t);let r=null;for(const[i,d]of Object.entries(c))i==="state"||i==="scope"||(r===null&&(r={}),r[i]=d);return l.useEffect(()=>{o.tokens||o.loginAsync(null,r,!0,c.scope)},[]),n.jsx(n.Fragment,{})},ee=({callbackErrorComponent:t,callbackSuccessComponent:c,redirect_uri:e,silent_redirect_uri:o,silent_login_uri:r,children:i,configurationName:d,withCustomHistory:a=null})=>{const u=window?s.getPath(window.location.href):"",[f,O]=l.useState(u);l.useEffect(()=>{const v=()=>O(s.getPath(window.location.href));return v(),window.addEventListener("popstate",v,!1),()=>window.removeEventListener("popstate",v,!1)},[]);const _=s.getPath(e);return o&&f===s.getPath(o)?n.jsx(x,{configurationName:d}):r&&f===s.getPath(r)?n.jsx(R,{configurationName:d}):f===_?n.jsx(J,{callBackError:t,callBackSuccess:c,configurationName:d,withCustomHistory:a}):n.jsx(n.Fragment,{children:i})},te=l.memo(ee),M={name:"",data:null},se=({loadingComponent:t,children:c,configurationName:e})=>{const[o,r]=l.useState(!0),i=s.OidcClient.get,d=i(e);l.useEffect(()=>{let u=!0;return d&&d.tryKeepExistingSessionAsync().then(()=>{u&&r(!1)}),()=>{u=!1}},[e]);const a=t;return n.jsx(n.Fragment,{children:o?n.jsx(a,{configurationName:e}):n.jsx(n.Fragment,{children:c})})},p=({isLoading:t,loadingComponent:c,children:e,configurationName:o})=>{const r=c;return t?n.jsx(r,{configurationName:o,children:e}):n.jsx(n.Fragment,{children:e})},ne=({children:t,configuration:c,configurationName:e="default",callbackSuccessComponent:o=U,authenticatingComponent:r=K,loadingComponent:i=V,serviceWorkerNotSupportedComponent:d=X,authenticatingErrorComponent:a=I,sessionLostComponent:u=Z,onSessionLost:f=null,onLogoutFromAnotherTab:O=null,onLogoutFromSameTab:_=null,withCustomHistory:v=null,onEvent:w=null,getFetch:g=null,location:E=null})=>{if(c&&c.redirect_uri&&c.silent_redirect_uri&&c.redirect_uri===c.silent_redirect_uri)throw new Error("redirect_uri and silent_redirect_uri must be different");const T=(L="default")=>s.OidcClient.getOrCreate(g??s.getFetchDefault,E??new s.OidcLocation)(c,L),[fe,he]=l.useState(!0),[ke,S]=l.useState(M),[_e,Oe]=l.useState(e);l.useEffect(()=>{const N=T(e).subscribeEvents((k,b)=>{w&&w(e,k,b)});return()=>{T(e).removeEventSubscription(N)}},[e,w]),l.useEffect(()=>{const N=T(e).subscribeEvents((k,b)=>{if(k===s.OidcClient.eventNames.refreshTokensAsync_error||k===s.OidcClient.eventNames.syncTokensAsync_error){if(f!=null){f();return}S({name:k,data:b})}else if(k===s.OidcClient.eventNames.logout_from_another_tab){if(O!=null){O();return}S({name:k,data:b})}else k===s.OidcClient.eventNames.logout_from_same_tab?_?.():k===s.OidcClient.eventNames.loginAsync_begin||k===s.OidcClient.eventNames.loginCallbackAsync_end||k===s.OidcClient.eventNames.loginAsync_error||k===s.OidcClient.eventNames.loginCallbackAsync_error?S({name:k,data:b}):k===s.OidcClient.eventNames.service_worker_not_supported_by_browser&&c.service_worker_only===!0&&S({name:k,data:b})});return queueMicrotask(()=>{Oe(e),he(!1)}),()=>{T(e).removeEventSubscription(N),S(M)}},[c,e]);const ve=u,ge=r,y=i,ye=d,be=a,A=fe||_e!==e,C=T(e);switch(ke.name){case s.OidcClient.eventNames.service_worker_not_supported_by_browser:return n.jsx(p,{loadingComponent:y,isLoading:A,configurationName:e,children:n.jsx(ye,{configurationName:e})});case s.OidcClient.eventNames.loginAsync_begin:return n.jsx(p,{loadingComponent:y,isLoading:A,configurationName:e,children:n.jsx(ge,{configurationName:e})});case s.OidcClient.eventNames.loginAsync_error:case s.OidcClient.eventNames.loginCallbackAsync_error:return n.jsx(p,{loadingComponent:y,isLoading:A,configurationName:e,children:n.jsx(be,{configurationName:e})});case s.OidcClient.eventNames.refreshTokensAsync_error:case s.OidcClient.eventNames.syncTokensAsync_error:case s.OidcClient.eventNames.logout_from_another_tab:return n.jsx(p,{loadingComponent:y,isLoading:A,configurationName:e,children:n.jsx(ve,{configurationName:e})});default:return n.jsx(p,{loadingComponent:y,isLoading:A,configurationName:e,children:n.jsx(te,{redirect_uri:C.configuration.redirect_uri,silent_redirect_uri:C.configuration.silent_redirect_uri,silent_login_uri:C.configuration.silent_login_uri,callbackSuccessComponent:o,callbackErrorComponent:a,authenticatingComponent:r,configurationName:e,withCustomHistory:v,location:E??new s.OidcLocation,children:n.jsx(se,{loadingComponent:y,configurationName:e,children:t})})})}},q=({children:t,callbackPath:c=null,extras:e=null,configurationName:o="default"})=>{const r=s.OidcClient.get,i=r(o);return l.useEffect(()=>{i.tokens||i.loginAsync(c,e)},[o,c,e]),i.tokens?n.jsx(n.Fragment,{children:t}):null},ce=(t,c=null,e=null,o="default")=>r=>n.jsx(q,{callbackPath:c,extras:e,configurationName:o,children:n.jsx(t,{...r})}),P="default",D=(t,c)=>{let e=!1;return t(c)&&(e=t(c).tokens!=null),e},oe=(t=P)=>{const c=s.OidcClient.get,[e,o]=l.useState(D(c,t));return l.useEffect(()=>{let a=!0;const u=c(t),f=u.subscribeEvents((O,_)=>{(O===s.OidcClient.eventNames.logout_from_another_tab||O===s.OidcClient.eventNames.logout_from_same_tab||O===s.OidcClient.eventNames.token_acquired)&&a&&o(D(c,t))});return()=>{a=!1,u.removeEventSubscription(f)}},[t]),{login:(a=void 0,u=void 0,f=!1,O=void 0)=>c(t).loginAsync(a,u,!1,O,f),logout:(a=void 0,u=void 0)=>c(t).logoutAsync(a,u),renewTokens:async(a=void 0)=>{const u=await c(t).renewTokensAsync(a);return{accessToken:u.accessToken,accessTokenPayload:u.accessTokenPayload,idToken:u.idToken,idTokenPayload:u.idTokenPayload}},isAuthenticated:e}},W={accessToken:null,accessTokenPayload:null},re=t=>{const c=s.OidcClient.get,e=c(t);if(e.tokens){const o=e.tokens;return{accessToken:o.accessToken,accessTokenPayload:o.accessTokenPayload,generateDemonstrationOfProofOfPossessionAsync:e.configuration.demonstrating_proof_of_possession?(r,i)=>e.generateDemonstrationOfProofOfPossessionAsync(o.accessToken,r,i):null}}return W};function ie(t,c){return t.configuration.demonstrating_proof_of_possession?(e,o,r={})=>t.generateDemonstrationOfProofOfPossessionAsync(c.accessToken,e,o,r):null}const ae=(t=P)=>{const c=s.OidcClient.get,[e,o]=l.useState(()=>re(t));return l.useEffect(()=>{let r=!0;const i=c(t),d=i.subscribeEvents((a,u)=>{if((a===s.OidcClient.eventNames.token_renewed||a===s.OidcClient.eventNames.token_acquired||a===s.OidcClient.eventNames.logout_from_another_tab||a===s.OidcClient.eventNames.logout_from_same_tab||a===s.OidcClient.eventNames.refreshTokensAsync_error||a===s.OidcClient.eventNames.syncTokensAsync_error)&&r){const f=i.tokens;o(f!=null?{accessToken:f.accessToken,accessTokenPayload:f.accessTokenPayload,generateDemonstrationOfProofOfPossessionAsync:ie(i,f)}:W)}});return()=>{r=!1,i.removeEventSubscription(d)}},[t]),e},j={idToken:null,idTokenPayload:null},le=t=>{const c=s.OidcClient.get,e=c(t);if(e.tokens){const o=e.tokens;return{idToken:o.idToken,idTokenPayload:o.idTokenPayload}}return j},de=(t=P)=>{const c=s.OidcClient.get,[e,o]=l.useState(()=>le(t));return l.useEffect(()=>{let r=!0;const i=c(t),d=i.subscribeEvents((a,u)=>{if((a===s.OidcClient.eventNames.token_renewed||a===s.OidcClient.eventNames.token_acquired||a===s.OidcClient.eventNames.logout_from_another_tab||a===s.OidcClient.eventNames.logout_from_same_tab||a===s.OidcClient.eventNames.refreshTokensAsync_error||a===s.OidcClient.eventNames.syncTokensAsync_error)&&r){const f=i.tokens;o(f!=null?{idToken:f.idToken,idTokenPayload:f.idTokenPayload}:j)}});return()=>{r=!1,i.removeEventSubscription(d)}},[t]),e};var Y=(t=>(t.Unauthenticated="Unauthenticated",t.Loading="Loading user",t.Loaded="User loaded",t.LoadingError="Error loading user",t))(Y||{});const ue=(t="default",c=!1)=>{const o=s.OidcClient.get(t).userInfo(),[r,i]=l.useState({user:o,status:o?"User loaded":"Unauthenticated"}),[d,a]=l.useState(o?1:0),[u,f]=l.useState(o?1:0);l.useEffect(()=>{const _=s.OidcClient.get(t);let v=!0;if(_&&_.tokens){const g=d===u;if(g&&_.userInfo())return;queueMicrotask(()=>{v&&(i({...r,status:"Loading user"}),f(d))}),_.userInfoAsync(!g,c).then(E=>{v&&i({user:E,status:"User loaded"})}).catch(()=>i({...r,status:"Error loading user"}))}else queueMicrotask(()=>{v&&i({user:null,status:"Unauthenticated"})});const w=_.subscribeEvents(g=>{(g===s.OidcClient.eventNames.logout_from_another_tab||g===s.OidcClient.eventNames.logout_from_same_tab)&&v&&i({user:null,status:"Unauthenticated"})});return()=>{v=!1,_.removeEventSubscription(w)}},[d]);const O=()=>{a(d+1)};return{oidcUser:r.user,oidcUserLoadingState:r.status,reloadOidcUser:O}};Object.defineProperty(h,"OidcClient",{enumerable:!0,get:()=>s.OidcClient}),Object.defineProperty(h,"OidcLocation",{enumerable:!0,get:()=>s.OidcLocation}),Object.defineProperty(h,"TokenAutomaticRenewMode",{enumerable:!0,get:()=>s.TokenAutomaticRenewMode}),Object.defineProperty(h,"TokenRenewMode",{enumerable:!0,get:()=>s.TokenRenewMode}),h.OidcProvider=ne,h.OidcSecure=q,h.OidcUserStatus=Y,h.useOidc=oe,h.useOidcAccessToken=ae,h.useOidcFetch=F,h.useOidcIdToken=de,h.useOidcUser=ue,h.withOidcFetch=z,h.withOidcSecure=ce,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})}));
|
|
1
|
+
(function(f,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("react/jsx-runtime"),require("@axa-fr/oidc-client"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@axa-fr/oidc-client","react"],c):(f=typeof globalThis<"u"?globalThis:f||self,c(f["react-oidc"]={},f.jsxRuntime,f.oidcClient,f.React))})(this,(function(f,c,s,d){"use strict";const F="default",z=(t,n,e=!1)=>async(...o)=>await n().fetchWithTokens(t,e)(...o),K=(t=null,n=F,e=!1)=>o=>r=>{const{fetch:i}=I(t||r.fetch,n,e);return c.jsx(o,{...r,fetch:i})},I=(t=null,n=F,e=!1)=>{const o=t||window.fetch,r=s.OidcClient.get;return{fetch:d.useCallback((u,a)=>z(o,()=>r(n),e)(u,a),[o,n,e])}},U=()=>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."})]})}),$=()=>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."})]})}),G=()=>Math.random().toString(36).slice(2,8),H=(t,n)=>(e,o)=>{if(typeof t.CustomEvent=="function")return new t.CustomEvent(e,o);const r=o||{bubbles:!1,cancelable:!1,detail:void 0},i=n.createEvent("CustomEvent");return i.initCustomEvent(e,r.bubbles,r.cancelable,r.detail),i.prototype=t.Event.prototype,i},Q=(t,n,e)=>({replaceState:(o,r)=>{const i=e(),u=r||t.history.state;t.history.replaceState({key:i,state:u},null,o),t.dispatchEvent(n("popstate"))}}),J=()=>Q(window,H(window,document),G),m=()=>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."})]})}),V=({callBackError:t,callBackSuccess:n,configurationName:e,withCustomHistory:o})=>{const[r,i]=d.useState(!1);d.useEffect(()=>{let l=!0;return(async()=>{const O=s.OidcClient.get;try{const{callbackPath:_}=await O(e).loginCallbackAsync();(o?o():J()).replaceState(_||"/")}catch(_){l&&(console.warn(_),i(!0))}})(),()=>{l=!1}},[]);const u=t||U,a=n||m;return r?c.jsx(u,{configurationName:e}):c.jsx(a,{configurationName:e})},X=()=>c.jsx("span",{className:"oidc-loading",children:"Loading"}),Z=()=>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."})]})}),x=()=>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."})]})}),R=({configurationName:t})=>(d.useEffect(()=>{(async()=>{s.OidcClient.get(t).silentLoginCallbackAsync()})().catch(e=>{console.error("Error during silent login callback:",e)})},[t]),null),ee=({configurationName:t})=>{const n=s.getParseQueryStringFromLocation(window.location.href),e=s.OidcClient.get,o=e(t);let r=null;for(const[i,u]of Object.entries(n))i==="state"||i==="scope"||(r===null&&(r={}),r[i]=u);return d.useEffect(()=>{o.tokens||o.loginAsync(null,r,!0,n.scope)},[]),c.jsx(c.Fragment,{})},te=({callbackErrorComponent:t,callbackSuccessComponent:n,redirect_uri:e,silent_redirect_uri:o,silent_login_uri:r,children:i,configurationName:u,withCustomHistory:a=null})=>{const l=window?s.getPath(window.location.href):"",[h,O]=d.useState(l);d.useEffect(()=>{const v=()=>O(s.getPath(window.location.href));return v(),window.addEventListener("popstate",v,!1),()=>window.removeEventListener("popstate",v,!1)},[]);const _=s.getPath(e);return o&&h===s.getPath(o)?c.jsx(R,{configurationName:u}):r&&h===s.getPath(r)?c.jsx(ee,{configurationName:u}):h===_?c.jsx(V,{callBackError:t,callBackSuccess:n,configurationName:u,withCustomHistory:a}):c.jsx(c.Fragment,{children:i})},se=d.memo(te),M={name:"",data:null},ne=({loadingComponent:t,children:n,configurationName:e})=>{const[o,r]=d.useState(!0),i=s.OidcClient.get,u=i(e);d.useEffect(()=>{let l=!0;return u&&u.tryKeepExistingSessionAsync().then(()=>{l&&r(!1)}),()=>{l=!1}},[e]);const a=t;return c.jsx(c.Fragment,{children:o?c.jsx(a,{configurationName:e}):c.jsx(c.Fragment,{children:n})})},p=({isLoading:t,loadingComponent:n,children:e,configurationName:o})=>{const r=n;return t?c.jsx(r,{configurationName:o,children:e}):c.jsx(c.Fragment,{children:e})},ce=({children:t,configuration:n,configurationName:e="default",callbackSuccessComponent:o=m,authenticatingComponent:r=$,loadingComponent:i=X,serviceWorkerNotSupportedComponent:u=Z,authenticatingErrorComponent:a=U,sessionLostComponent:l=x,onSessionLost:h=null,onLogoutFromAnotherTab:O=null,onLogoutFromSameTab:_=null,withCustomHistory:v=null,onEvent:w=null,getFetch:y=null,location:E=null})=>{if(n&&n.redirect_uri&&n.silent_redirect_uri&&n.redirect_uri===n.silent_redirect_uri)throw new Error("redirect_uri and silent_redirect_uri must be different");const T=(L="default")=>s.OidcClient.getOrCreate(y??s.getFetchDefault,E??new s.OidcLocation)(n,L),[fe,S]=d.useState(M),[ke,B]=d.useState(e);d.useEffect(()=>{const N=T(e).subscribeEvents((k,g)=>{w&&w(e,k,g)});return()=>{T(e).removeEventSubscription(N)}},[e,w]),d.useEffect(()=>{const N=T(e).subscribeEvents((k,g)=>{if(k===s.OidcClient.eventNames.refreshTokensAsync_error||k===s.OidcClient.eventNames.syncTokensAsync_error){if(h!=null){h();return}S({name:k,data:g})}else if(k===s.OidcClient.eventNames.logout_from_another_tab){if(O!=null){O();return}S({name:k,data:g})}else k===s.OidcClient.eventNames.logout_from_same_tab?_?.():k===s.OidcClient.eventNames.loginAsync_begin||k===s.OidcClient.eventNames.loginCallbackAsync_end||k===s.OidcClient.eventNames.loginAsync_error||k===s.OidcClient.eventNames.loginCallbackAsync_error?S({name:k,data:g}):k===s.OidcClient.eventNames.service_worker_not_supported_by_browser&&n.service_worker_only===!0&&S({name:k,data:g})});return queueMicrotask(()=>{B(e),setLoading(!1)}),()=>{T(e).removeEventSubscription(N),S(M)}},[n,e]),d.useEffect(()=>{B(e)},[e]);const _e=l,Oe=r,b=i,ve=u,ye=a,A=ke!==e,C=T(e);switch(fe.name){case s.OidcClient.eventNames.service_worker_not_supported_by_browser:return c.jsx(p,{loadingComponent:b,isLoading:A,configurationName:e,children:c.jsx(ve,{configurationName:e})});case s.OidcClient.eventNames.loginAsync_begin:return c.jsx(p,{loadingComponent:b,isLoading:A,configurationName:e,children:c.jsx(Oe,{configurationName:e})});case s.OidcClient.eventNames.loginAsync_error:case s.OidcClient.eventNames.loginCallbackAsync_error:return c.jsx(p,{loadingComponent:b,isLoading:A,configurationName:e,children:c.jsx(ye,{configurationName:e})});case s.OidcClient.eventNames.refreshTokensAsync_error:case s.OidcClient.eventNames.syncTokensAsync_error:case s.OidcClient.eventNames.logout_from_another_tab:return c.jsx(p,{loadingComponent:b,isLoading:A,configurationName:e,children:c.jsx(_e,{configurationName:e})});default:return c.jsx(p,{loadingComponent:b,isLoading:A,configurationName:e,children:c.jsx(se,{redirect_uri:C.configuration.redirect_uri,silent_redirect_uri:C.configuration.silent_redirect_uri,silent_login_uri:C.configuration.silent_login_uri,callbackSuccessComponent:o,callbackErrorComponent:a,authenticatingComponent:r,configurationName:e,withCustomHistory:v,location:E??new s.OidcLocation,children:c.jsx(ne,{loadingComponent:b,configurationName:e,children:t})})})}},q=({children:t,callbackPath:n=null,extras:e=null,configurationName:o="default"})=>{const r=s.OidcClient.get,i=r(o);return d.useEffect(()=>{i.tokens||i.loginAsync(n,e)},[o,n,e]),i.tokens?c.jsx(c.Fragment,{children:t}):null},oe=(t,n=null,e=null,o="default")=>r=>c.jsx(q,{callbackPath:n,extras:e,configurationName:o,children:c.jsx(t,{...r})}),P="default",D=(t,n)=>{let e=!1;return t(n)&&(e=t(n).tokens!=null),e},re=(t=P)=>{const n=s.OidcClient.get,[e,o]=d.useState(()=>D(n,t));return d.useEffect(()=>{let a=!0;const l=n(t),h=l.subscribeEvents((O,_)=>{(O===s.OidcClient.eventNames.logout_from_another_tab||O===s.OidcClient.eventNames.logout_from_same_tab||O===s.OidcClient.eventNames.token_acquired)&&a&&o(D(n,t))});return()=>{a=!1,l.removeEventSubscription(h)}},[t]),{login:(a=void 0,l=void 0,h=!1,O=void 0)=>n(t).loginAsync(a,l,!1,O,h),logout:(a=void 0,l=void 0)=>n(t).logoutAsync(a,l),renewTokens:async(a=void 0)=>{const l=await n(t).renewTokensAsync(a);return{accessToken:l.accessToken,accessTokenPayload:l.accessTokenPayload,idToken:l.idToken,idTokenPayload:l.idTokenPayload}},isAuthenticated:e}},W={accessToken:null,accessTokenPayload:null},ie=t=>{const n=s.OidcClient.get,e=n(t);if(e.tokens){const o=e.tokens;return{accessToken:o.accessToken,accessTokenPayload:o.accessTokenPayload,generateDemonstrationOfProofOfPossessionAsync:e.configuration.demonstrating_proof_of_possession?(r,i)=>e.generateDemonstrationOfProofOfPossessionAsync(o.accessToken,r,i):null}}return W};function ae(t,n){return t.configuration.demonstrating_proof_of_possession?(e,o,r={})=>t.generateDemonstrationOfProofOfPossessionAsync(n.accessToken,e,o,r):null}const le=(t=P)=>{const n=s.OidcClient.get,[e,o]=d.useState(()=>ie(t));return d.useEffect(()=>{let r=!0;const i=n(t),u=i.subscribeEvents((a,l)=>{if((a===s.OidcClient.eventNames.token_renewed||a===s.OidcClient.eventNames.token_acquired||a===s.OidcClient.eventNames.logout_from_another_tab||a===s.OidcClient.eventNames.logout_from_same_tab||a===s.OidcClient.eventNames.refreshTokensAsync_error||a===s.OidcClient.eventNames.syncTokensAsync_error)&&r){const h=i.tokens;o(h!=null?{accessToken:h.accessToken,accessTokenPayload:h.accessTokenPayload,generateDemonstrationOfProofOfPossessionAsync:ae(i,h)}:W)}});return()=>{r=!1,i.removeEventSubscription(u)}},[t]),e},j={idToken:null,idTokenPayload:null},de=t=>{const n=s.OidcClient.get,e=n(t);if(e.tokens){const o=e.tokens;return{idToken:o.idToken,idTokenPayload:o.idTokenPayload}}return j},ue=(t=P)=>{const n=s.OidcClient.get,[e,o]=d.useState(()=>de(t));return d.useEffect(()=>{let r=!0;const i=n(t),u=i.subscribeEvents((a,l)=>{if((a===s.OidcClient.eventNames.token_renewed||a===s.OidcClient.eventNames.token_acquired||a===s.OidcClient.eventNames.logout_from_another_tab||a===s.OidcClient.eventNames.logout_from_same_tab||a===s.OidcClient.eventNames.refreshTokensAsync_error||a===s.OidcClient.eventNames.syncTokensAsync_error)&&r){const h=i.tokens;o(h!=null?{idToken:h.idToken,idTokenPayload:h.idTokenPayload}:j)}});return()=>{r=!1,i.removeEventSubscription(u)}},[t]),e};var Y=(t=>(t.Unauthenticated="Unauthenticated",t.Loading="Loading user",t.Loaded="User loaded",t.LoadingError="Error loading user",t))(Y||{});const he=(t="default",n=!1)=>{const o=s.OidcClient.get(t).userInfo(),[r,i]=d.useState({user:o,status:o?"User loaded":"Unauthenticated"}),[u,a]=d.useState(o?1:0),[l,h]=d.useState(o?1:0);d.useEffect(()=>{const _=s.OidcClient.get(t);let v=!0;if(_&&_.tokens){const y=u===l;if(y&&_.userInfo())return;queueMicrotask(()=>{v&&(i({...r,status:"Loading user"}),h(u))}),_.userInfoAsync(!y,n).then(E=>{v&&i({user:E,status:"User loaded"})}).catch(()=>i({...r,status:"Error loading user"}))}else queueMicrotask(()=>{v&&i({user:null,status:"Unauthenticated"})});const w=_.subscribeEvents(y=>{(y===s.OidcClient.eventNames.logout_from_another_tab||y===s.OidcClient.eventNames.logout_from_same_tab)&&v&&i({user:null,status:"Unauthenticated"})});return()=>{v=!1,_.removeEventSubscription(w)}},[u,t,n,l]);const O=()=>{a(u+1)};return{oidcUser:r.user,oidcUserLoadingState:r.status,reloadOidcUser:O}};Object.defineProperty(f,"OidcClient",{enumerable:!0,get:()=>s.OidcClient}),Object.defineProperty(f,"OidcLocation",{enumerable:!0,get:()=>s.OidcLocation}),Object.defineProperty(f,"TokenAutomaticRenewMode",{enumerable:!0,get:()=>s.TokenAutomaticRenewMode}),Object.defineProperty(f,"TokenRenewMode",{enumerable:!0,get:()=>s.TokenRenewMode}),f.OidcProvider=ce,f.OidcSecure=q,f.OidcUserStatus=Y,f.useOidc=re,f.useOidcAccessToken=le,f.useOidcFetch=I,f.useOidcIdToken=ue,f.useOidcUser=he,f.withOidcFetch=K,f.withOidcSecure=oe,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axa-fr/react-oidc",
|
|
3
|
-
"version": "7.26.
|
|
3
|
+
"version": "7.26.4",
|
|
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": "7.26.
|
|
44
|
-
"@axa-fr/oidc-client": "7.26.
|
|
43
|
+
"@axa-fr/oidc-client-service-worker": "7.26.4",
|
|
44
|
+
"@axa-fr/oidc-client": "7.26.4"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"react": "^17.0.0 || ^18.0.0 || ^19.0.0"
|
package/src/OidcProvider.tsx
CHANGED
|
@@ -115,7 +115,7 @@ export const OidcProvider: FC<PropsWithChildren<OidcProviderProps>> = ({
|
|
|
115
115
|
);
|
|
116
116
|
};
|
|
117
117
|
|
|
118
|
-
const
|
|
118
|
+
const loading = false;
|
|
119
119
|
const [event, setEvent] = useState(defaultEventState);
|
|
120
120
|
const [currentConfigurationName, setConfigurationName] = useState(configurationName);
|
|
121
121
|
|
|
@@ -182,6 +182,10 @@ export const OidcProvider: FC<PropsWithChildren<OidcProviderProps>> = ({
|
|
|
182
182
|
};
|
|
183
183
|
}, [configuration, configurationName]);
|
|
184
184
|
|
|
185
|
+
useEffect(() => {
|
|
186
|
+
setConfigurationName(configurationName);
|
|
187
|
+
}, [configurationName]);
|
|
188
|
+
|
|
185
189
|
const SessionLostComponent = sessionLostComponent;
|
|
186
190
|
const AuthenticatingComponent = authenticatingComponent;
|
|
187
191
|
const LoadingComponent = loadingComponent;
|
package/src/ReactOidc.tsx
CHANGED
|
@@ -18,7 +18,7 @@ const defaultIsAuthenticated = (getOidc: GetOidcFn, configurationName: string) =
|
|
|
18
18
|
|
|
19
19
|
export const useOidc = (configurationName = defaultConfigurationName) => {
|
|
20
20
|
const getOidc = OidcClient.get;
|
|
21
|
-
const [isAuthenticated, setIsAuthenticated] = useState<boolean>(
|
|
21
|
+
const [isAuthenticated, setIsAuthenticated] = useState<boolean>(() =>
|
|
22
22
|
defaultIsAuthenticated(getOidc, configurationName),
|
|
23
23
|
);
|
|
24
24
|
|
package/src/User.ts
CHANGED
|
@@ -71,7 +71,7 @@ export const useOidcUser = <T extends OidcUserInfo = OidcUserInfo>(
|
|
|
71
71
|
isMounted = false;
|
|
72
72
|
oidc.removeEventSubscription(newSubscriptionId);
|
|
73
73
|
};
|
|
74
|
-
}, [oidcUserId]);
|
|
74
|
+
}, [oidcUserId, configurationName, demonstrating_proof_of_possession, oidcPreviousUserId]);
|
|
75
75
|
|
|
76
76
|
const reloadOidcUser = () => {
|
|
77
77
|
setOidcUserId(oidcUserId + 1);
|