@axa-fr/react-oidc 7.29.3 → 7.29.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/README.md +268 -643
- package/dist/FetchToken.d.ts +1 -1
- package/dist/FetchToken.d.ts.map +1 -1
- package/dist/OidcSecure.d.ts +1 -1
- package/dist/OidcSecure.d.ts.map +1 -1
- package/dist/index.js +154 -154
- package/dist/index.umd.cjs +1 -1
- package/package.json +18 -18
package/dist/FetchToken.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Fetch } from '@axa-fr/oidc-client';
|
|
|
2
2
|
export interface ComponentWithOidcFetchProps {
|
|
3
3
|
fetch?: Fetch;
|
|
4
4
|
}
|
|
5
|
-
export declare const withOidcFetch: (fetch?: Fetch, configurationName?: string, demonstratingProofOfPossession?: boolean) => (WrappedComponent: any) => (props: ComponentWithOidcFetchProps) => import("react
|
|
5
|
+
export declare const withOidcFetch: (fetch?: Fetch, configurationName?: string, demonstratingProofOfPossession?: boolean) => (WrappedComponent: any) => (props: ComponentWithOidcFetchProps) => import("react").JSX.Element;
|
|
6
6
|
export declare const useOidcFetch: (fetch?: Fetch, configurationName?: string, demonstratingProofOfPossession?: boolean) => {
|
|
7
7
|
fetch: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
8
8
|
};
|
package/dist/FetchToken.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FetchToken.d.ts","sourceRoot":"","sources":["../src/FetchToken.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAc,MAAM,qBAAqB,CAAC;AAGxD,MAAM,WAAW,2BAA2B;IAC1C,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;AAgBD,eAAO,MAAM,aAAa,GAEtB,QAAO,KAAY,EACnB,0BAA4C,EAC5C,iCAAgC,OAAe,MAEjD,qBAAgB,MACf,OAAO,2BAA2B,
|
|
1
|
+
{"version":3,"file":"FetchToken.d.ts","sourceRoot":"","sources":["../src/FetchToken.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAc,MAAM,qBAAqB,CAAC;AAGxD,MAAM,WAAW,2BAA2B;IAC1C,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;AAgBD,eAAO,MAAM,aAAa,GAEtB,QAAO,KAAY,EACnB,0BAA4C,EAC5C,iCAAgC,OAAe,MAEjD,qBAAgB,MACf,OAAO,2BAA2B,gCAOlC,CAAC;AAEJ,eAAO,MAAM,YAAY,GACvB,QAAO,KAAY,EACnB,0BAA4C,EAC5C,iCAAgC,OAAe;mBAQrC,WAAW,GAAG,GAAG,SAAS,WAAW;CAYhD,CAAC"}
|
package/dist/OidcSecure.d.ts
CHANGED
|
@@ -6,5 +6,5 @@ export type OidcSecureProps = {
|
|
|
6
6
|
configurationName?: string;
|
|
7
7
|
};
|
|
8
8
|
export declare const OidcSecure: FC<PropsWithChildren<OidcSecureProps>>;
|
|
9
|
-
export declare const withOidcSecure: (WrappedComponent: FC<PropsWithChildren<OidcSecureProps>>, callbackPath?: any, extras?: any, configurationName?: string) => (props: any) => import("react
|
|
9
|
+
export declare const withOidcSecure: (WrappedComponent: FC<PropsWithChildren<OidcSecureProps>>, callbackPath?: any, extras?: any, configurationName?: string) => (props: any) => import("react").JSX.Element;
|
|
10
10
|
//# sourceMappingURL=OidcSecure.d.ts.map
|
package/dist/OidcSecure.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OidcSecure.d.ts","sourceRoot":"","sources":["../src/OidcSecure.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,EAAE,EAAE,iBAAiB,EAAa,MAAM,OAAO,CAAC;AAEzD,MAAM,MAAM,eAAe,GAAG;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,EAAE,CAAC,iBAAiB,CAAC,eAAe,CAAC,CAwB7D,CAAC;AAEF,eAAO,MAAM,cAAc,GAEvB,kBAAkB,EAAE,CAAC,iBAAiB,CAAC,eAAe,CAAC,CAAC,EACxD,kBAAmB,EACnB,YAAa,EACb,0BAA6B,MAE/B,UAAK,
|
|
1
|
+
{"version":3,"file":"OidcSecure.d.ts","sourceRoot":"","sources":["../src/OidcSecure.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,EAAE,EAAE,iBAAiB,EAAa,MAAM,OAAO,CAAC;AAEzD,MAAM,MAAM,eAAe,GAAG;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,EAAE,CAAC,iBAAiB,CAAC,eAAe,CAAC,CAwB7D,CAAC;AAEF,eAAO,MAAM,cAAc,GAEvB,kBAAkB,EAAE,CAAC,iBAAiB,CAAC,eAAe,CAAC,CAAC,EACxD,kBAAmB,EACnB,YAAa,EACb,0BAA6B,MAE/B,UAAK,gCAMJ,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
import { OidcClient as e, OidcClient as t, OidcError as n, OidcErrorCode as r, OidcLocation as i, OidcLocation as a, OidcStateError as o, OidcStateErrorCode as s, PushedAuthorizationRequestError as c, PushedAuthorizationRequestErrorCode as l, TokenAutomaticRenewMode as u, TokenRenewMode as d, getFetchDefault as
|
|
2
|
-
import
|
|
3
|
-
import { Fragment as
|
|
1
|
+
import { OidcClient as e, OidcClient as t, OidcError as n, OidcErrorCode as r, OidcLocation as i, OidcLocation as a, OidcStateError as o, OidcStateErrorCode as s, PushedAuthorizationRequestError as c, PushedAuthorizationRequestErrorCode as l, TokenAutomaticRenewMode as u, TokenRenewMode as d, getFetchDefault as f, getParseQueryStringFromLocation as p, getPath as m, isOidcError as h, isOidcStateError as g, isPushedAuthorizationRequestError as _ } from "@axa-fr/oidc-client";
|
|
2
|
+
import v, { useCallback as y, useEffect as b, useRef as x, useState as S } from "react";
|
|
3
|
+
import { Fragment as C, jsx as w, jsxs as T } from "react/jsx-runtime";
|
|
4
4
|
//#region src/FetchToken.tsx
|
|
5
|
-
var
|
|
6
|
-
let { fetch: a } =
|
|
7
|
-
return /* @__PURE__ */
|
|
5
|
+
var E = "default", D = (e, t, n = !1) => async (...r) => await t().fetchWithTokens(e, n)(...r), O = (e = null, t = E, n = !1) => (r) => (i) => {
|
|
6
|
+
let { fetch: a } = k(e || i.fetch, t, n);
|
|
7
|
+
return /* @__PURE__ */ w(r, {
|
|
8
8
|
...i,
|
|
9
9
|
fetch: a
|
|
10
10
|
});
|
|
11
|
-
},
|
|
11
|
+
}, k = (e = null, n = E, r = !1) => {
|
|
12
12
|
let i = e || window.fetch, a = t.getOrThrow;
|
|
13
|
-
return { fetch:
|
|
13
|
+
return { fetch: y((e, t) => D(i, () => a(n), r)(e, t), [
|
|
14
14
|
i,
|
|
15
15
|
n,
|
|
16
16
|
r
|
|
17
17
|
]) };
|
|
18
|
-
},
|
|
18
|
+
}, A = () => /* @__PURE__ */ w("div", {
|
|
19
19
|
className: "oidc-authenticating",
|
|
20
|
-
children: /* @__PURE__ */
|
|
20
|
+
children: /* @__PURE__ */ T("div", {
|
|
21
21
|
className: "oidc-authenticating__container",
|
|
22
|
-
children: [/* @__PURE__ */
|
|
22
|
+
children: [/* @__PURE__ */ w("h1", {
|
|
23
23
|
className: "oidc-authenticating__title",
|
|
24
24
|
children: "Error authentication"
|
|
25
|
-
}), /* @__PURE__ */
|
|
25
|
+
}), /* @__PURE__ */ w("p", {
|
|
26
26
|
className: "oidc-authenticating__content",
|
|
27
27
|
children: "An error occurred during authentication."
|
|
28
28
|
})]
|
|
29
29
|
})
|
|
30
|
-
}),
|
|
30
|
+
}), ee = () => /* @__PURE__ */ w("div", {
|
|
31
31
|
className: "oidc-authenticating",
|
|
32
|
-
children: /* @__PURE__ */
|
|
32
|
+
children: /* @__PURE__ */ T("div", {
|
|
33
33
|
className: "oidc-authenticating__container",
|
|
34
|
-
children: [/* @__PURE__ */
|
|
34
|
+
children: [/* @__PURE__ */ w("h1", {
|
|
35
35
|
className: "oidc-authenticating__title",
|
|
36
36
|
children: "Authentication in progress"
|
|
37
|
-
}), /* @__PURE__ */
|
|
37
|
+
}), /* @__PURE__ */ w("p", {
|
|
38
38
|
className: "oidc-authenticating__content",
|
|
39
39
|
children: "You will be redirected to the login page."
|
|
40
40
|
})]
|
|
41
41
|
})
|
|
42
|
-
}),
|
|
42
|
+
}), j = () => Math.random().toString(36).slice(2, 8), M = (e, t) => (n, r) => {
|
|
43
43
|
if (typeof e.CustomEvent == "function") return new e.CustomEvent(n, r);
|
|
44
44
|
let i = r || {
|
|
45
45
|
bubbles: !1,
|
|
@@ -47,27 +47,27 @@ var T = "default", E = (e, t, n = !1) => async (...r) => await t().fetchWithToke
|
|
|
47
47
|
detail: void 0
|
|
48
48
|
}, a = t.createEvent("CustomEvent");
|
|
49
49
|
return a.initCustomEvent(n, i.bubbles, i.cancelable, i.detail), a.prototype = e.Event.prototype, a;
|
|
50
|
-
},
|
|
50
|
+
}, N = (e, t, n) => ({ replaceState: (r, i) => {
|
|
51
51
|
let a = n(), o = i || e.history.state;
|
|
52
52
|
e.history.replaceState({
|
|
53
53
|
key: a,
|
|
54
54
|
state: o
|
|
55
55
|
}, null, r), e.dispatchEvent(t("popstate"));
|
|
56
|
-
} }),
|
|
56
|
+
} }), P = () => N(window, M(window, document), j), F = () => /* @__PURE__ */ w("div", {
|
|
57
57
|
className: "oidc-callback",
|
|
58
|
-
children: /* @__PURE__ */
|
|
58
|
+
children: /* @__PURE__ */ T("div", {
|
|
59
59
|
className: "oidc-callback__container",
|
|
60
|
-
children: [/* @__PURE__ */
|
|
60
|
+
children: [/* @__PURE__ */ w("h1", {
|
|
61
61
|
className: "oidc-callback__title",
|
|
62
62
|
children: "Authentication complete"
|
|
63
|
-
}), /* @__PURE__ */
|
|
63
|
+
}), /* @__PURE__ */ w("p", {
|
|
64
64
|
className: "oidc-callback__content",
|
|
65
65
|
children: "You will be redirected to your application."
|
|
66
66
|
})]
|
|
67
67
|
})
|
|
68
|
-
}),
|
|
69
|
-
let [o, s] =
|
|
70
|
-
return
|
|
68
|
+
}), I = 200, L = (e, t = window) => t.location.pathname === e || e === "/", R = ({ callBackError: e, callBackSuccess: n, configurationName: r, withCustomHistory: i, navigateAfterCallback: a }) => {
|
|
69
|
+
let [o, s] = S(!1);
|
|
70
|
+
return b(() => {
|
|
71
71
|
let e = !0;
|
|
72
72
|
return (async () => {
|
|
73
73
|
let n = t.getOrThrow;
|
|
@@ -85,11 +85,11 @@ var T = "default", E = (e, t, n = !1) => async (...r) => await t().fetchWithToke
|
|
|
85
85
|
error: n
|
|
86
86
|
}), e && (console.warn(n), s(!0));
|
|
87
87
|
}
|
|
88
|
-
else (i ? i() :
|
|
88
|
+
else (i ? i() : P()).replaceState(l), await new Promise((e) => {
|
|
89
89
|
setTimeout(() => {
|
|
90
90
|
e();
|
|
91
|
-
},
|
|
92
|
-
}), e && (
|
|
91
|
+
}, I);
|
|
92
|
+
}), e && (L(l) ? o.publishEvent(t.eventNames.loginCallbackAsync_navigated, {
|
|
93
93
|
configurationName: r,
|
|
94
94
|
callbackPath: l
|
|
95
95
|
}) : (o.publishEvent(t.eventNames.loginCallbackAsync_navigation_error, {
|
|
@@ -103,233 +103,233 @@ var T = "default", E = (e, t, n = !1) => async (...r) => await t().fetchWithToke
|
|
|
103
103
|
})(), () => {
|
|
104
104
|
e = !1;
|
|
105
105
|
};
|
|
106
|
-
}, []),
|
|
107
|
-
},
|
|
106
|
+
}, []), w(o ? e || A : n || F, { configurationName: r });
|
|
107
|
+
}, te = () => /* @__PURE__ */ w("span", {
|
|
108
108
|
className: "oidc-loading",
|
|
109
109
|
children: "Loading"
|
|
110
|
-
}),
|
|
110
|
+
}), ne = () => /* @__PURE__ */ w("div", {
|
|
111
111
|
className: "oidc-loading-timeout",
|
|
112
|
-
children: /* @__PURE__ */
|
|
112
|
+
children: /* @__PURE__ */ T("div", {
|
|
113
113
|
className: "oidc-loading-timeout__container",
|
|
114
|
-
children: [/* @__PURE__ */
|
|
114
|
+
children: [/* @__PURE__ */ w("h1", {
|
|
115
115
|
className: "oidc-loading-timeout__title",
|
|
116
116
|
children: "Loading timeout"
|
|
117
|
-
}), /* @__PURE__ */
|
|
117
|
+
}), /* @__PURE__ */ w("p", {
|
|
118
118
|
className: "oidc-loading-timeout__content",
|
|
119
119
|
children: "Authentication is taking longer than expected. Please try refreshing the page."
|
|
120
120
|
})]
|
|
121
121
|
})
|
|
122
|
-
}),
|
|
122
|
+
}), re = () => /* @__PURE__ */ w("div", {
|
|
123
123
|
className: "oidc-serviceworker",
|
|
124
|
-
children: /* @__PURE__ */
|
|
124
|
+
children: /* @__PURE__ */ T("div", {
|
|
125
125
|
className: "oidc-serviceworker__container",
|
|
126
|
-
children: [/* @__PURE__ */
|
|
126
|
+
children: [/* @__PURE__ */ w("h1", {
|
|
127
127
|
className: "oidc-serviceworker__title",
|
|
128
128
|
children: "Unable to authenticate on this browser"
|
|
129
|
-
}), /* @__PURE__ */
|
|
129
|
+
}), /* @__PURE__ */ w("p", {
|
|
130
130
|
className: "oidc-serviceworker__content",
|
|
131
131
|
children: "Your browser is not secure enough to make authentication work. Try updating your browser or use a newer browser."
|
|
132
132
|
})]
|
|
133
133
|
})
|
|
134
|
-
}),
|
|
134
|
+
}), z = () => /* @__PURE__ */ w("div", {
|
|
135
135
|
className: "oidc-session-lost",
|
|
136
|
-
children: /* @__PURE__ */
|
|
136
|
+
children: /* @__PURE__ */ T("div", {
|
|
137
137
|
className: "oidc-session-lost__container",
|
|
138
|
-
children: [/* @__PURE__ */
|
|
138
|
+
children: [/* @__PURE__ */ w("h1", {
|
|
139
139
|
className: "oidc-session-lost__title",
|
|
140
140
|
children: "Session timed out"
|
|
141
|
-
}), /* @__PURE__ */
|
|
141
|
+
}), /* @__PURE__ */ w("p", {
|
|
142
142
|
className: "oidc-session-lost__content",
|
|
143
143
|
children: "Your session has expired. Please re-authenticate."
|
|
144
144
|
})]
|
|
145
145
|
})
|
|
146
|
-
}),
|
|
146
|
+
}), B = ({ configurationName: e }) => (b(() => {
|
|
147
147
|
(async () => {
|
|
148
148
|
t.getOrThrow(e).silentLoginCallbackAsync();
|
|
149
149
|
})().catch((e) => {
|
|
150
150
|
console.error("Error during silent login callback:", e);
|
|
151
151
|
});
|
|
152
|
-
}, [e]), null),
|
|
153
|
-
let n =
|
|
154
|
-
for (let [e, t] of Object.entries(n)) e
|
|
155
|
-
return
|
|
152
|
+
}, [e]), null), V = ({ configurationName: e }) => {
|
|
153
|
+
let n = p(window.location.href), r = t.getOrThrow, i = r(e), a = null;
|
|
154
|
+
for (let [e, t] of Object.entries(n)) e !== "state" && e !== "scope" && (a === null && (a = {}), a[e] = t);
|
|
155
|
+
return b(() => {
|
|
156
156
|
i.tokens || i.loginAsync(null, a, !0, n.scope);
|
|
157
|
-
}, []), /* @__PURE__ */ C
|
|
158
|
-
},
|
|
159
|
-
let
|
|
160
|
-
|
|
161
|
-
let e = () =>
|
|
157
|
+
}, []), /* @__PURE__ */ w(C, {});
|
|
158
|
+
}, ie = v.memo(({ callbackErrorComponent: e, callbackSuccessComponent: t, redirect_uri: n, silent_redirect_uri: r, silent_login_uri: i, children: a, configurationName: o, withCustomHistory: s = null, navigateAfterCallback: c = null }) => {
|
|
159
|
+
let l = window ? m(window.location.href) : "", [u, d] = S(l);
|
|
160
|
+
b(() => {
|
|
161
|
+
let e = () => d(m(window.location.href));
|
|
162
162
|
return e(), window.addEventListener("popstate", e, !1), () => window.removeEventListener("popstate", e, !1);
|
|
163
163
|
}, []);
|
|
164
|
-
let
|
|
165
|
-
if (r &&
|
|
166
|
-
if (i &&
|
|
167
|
-
switch (
|
|
168
|
-
case
|
|
164
|
+
let f = m(n);
|
|
165
|
+
if (r && u === m(r)) return /* @__PURE__ */ w(B, { configurationName: o });
|
|
166
|
+
if (i && u === m(i)) return /* @__PURE__ */ w(V, { configurationName: o });
|
|
167
|
+
switch (u) {
|
|
168
|
+
case f: return /* @__PURE__ */ w(R, {
|
|
169
169
|
callBackError: e,
|
|
170
170
|
callBackSuccess: t,
|
|
171
171
|
configurationName: o,
|
|
172
172
|
withCustomHistory: s,
|
|
173
173
|
navigateAfterCallback: c
|
|
174
174
|
});
|
|
175
|
-
default: return /* @__PURE__ */ C
|
|
175
|
+
default: return /* @__PURE__ */ w(C, { children: a });
|
|
176
176
|
}
|
|
177
177
|
}), H = {
|
|
178
178
|
name: "",
|
|
179
179
|
data: null
|
|
180
180
|
}, ae = ({ loadingComponent: e, children: n, configurationName: r }) => {
|
|
181
|
-
let [i, a] =
|
|
182
|
-
return
|
|
181
|
+
let [i, a] = S(!0), o = t.get, s = o(r);
|
|
182
|
+
return b(() => {
|
|
183
183
|
let e = !0;
|
|
184
184
|
return s && s.tryKeepExistingSessionAsync().then(() => {
|
|
185
185
|
e && a(!1);
|
|
186
186
|
}), () => {
|
|
187
187
|
e = !1;
|
|
188
188
|
};
|
|
189
|
-
}, [r]), /* @__PURE__ */ C
|
|
190
|
-
}, U = ({ isLoading: e, loadingComponent: t, children: n, configurationName: r }) => e ? /* @__PURE__ */
|
|
189
|
+
}, [r]), /* @__PURE__ */ w(C, { children: i ? /* @__PURE__ */ w(e, { configurationName: r }) : /* @__PURE__ */ w(C, { children: n }) });
|
|
190
|
+
}, U = ({ isLoading: e, loadingComponent: t, children: n, configurationName: r }) => e ? /* @__PURE__ */ w(t, {
|
|
191
191
|
configurationName: r,
|
|
192
192
|
children: n
|
|
193
|
-
}) : /* @__PURE__ */ C
|
|
193
|
+
}) : /* @__PURE__ */ w(C, { children: n }), oe = 3e4, W = (e) => e === t.eventNames.token_acquired || e === t.eventNames.token_renewed || e === t.eventNames.loginCallbackAsync_end || e === t.eventNames.tryKeepExistingSessionAsync_end || e === t.eventNames.tryKeepExistingSessionAsync_error, G = ({ children: e, configuration: n, configurationName: r = "default", callbackSuccessComponent: i = F, authenticatingComponent: o = ee, loadingComponent: s = te, loadingTimeoutComponent: c = ne, serviceWorkerNotSupportedComponent: l = re, authenticatingErrorComponent: u = A, sessionLostComponent: d = z, onSessionLost: p = null, onLogoutFromAnotherTab: m = null, onLogoutFromSameTab: h = null, withCustomHistory: g = null, navigateAfterCallback: _ = null, onEvent: v = null, getFetch: y = null, location: x = null }) => {
|
|
194
194
|
if (n && n.redirect_uri && n.silent_redirect_uri && n.redirect_uri === n.silent_redirect_uri) throw Error("redirect_uri and silent_redirect_uri must be different");
|
|
195
|
-
let
|
|
196
|
-
|
|
197
|
-
let e =
|
|
198
|
-
|
|
195
|
+
let C = (e = "default") => t.getOrCreate(y ?? f, x ?? new a())(n, e), [T, E] = S(H), [D, O] = S(!0), [k, j] = S(r);
|
|
196
|
+
b(() => {
|
|
197
|
+
let e = C(r).subscribeEvents((e, t) => {
|
|
198
|
+
v && v(r, e, t);
|
|
199
199
|
});
|
|
200
200
|
return () => {
|
|
201
|
-
|
|
201
|
+
C(r).removeEventSubscription(e);
|
|
202
202
|
};
|
|
203
|
-
}, [r,
|
|
204
|
-
let e =
|
|
205
|
-
if (e === t.eventNames.loginAsync_begin ?
|
|
206
|
-
if (
|
|
207
|
-
|
|
203
|
+
}, [r, v]), b(() => {
|
|
204
|
+
let e = C(r).subscribeEvents((e, r) => {
|
|
205
|
+
if (e === t.eventNames.loginAsync_begin ? O(!0) : W(e) && O(!1), e === t.eventNames.refreshTokensAsync_error || e === t.eventNames.syncTokensAsync_error) {
|
|
206
|
+
if (p != null) {
|
|
207
|
+
p();
|
|
208
208
|
return;
|
|
209
209
|
}
|
|
210
|
-
|
|
210
|
+
E({
|
|
211
211
|
name: e,
|
|
212
212
|
data: r
|
|
213
213
|
});
|
|
214
214
|
} else if (e === t.eventNames.logout_from_another_tab) {
|
|
215
|
-
if (
|
|
216
|
-
|
|
215
|
+
if (m != null) {
|
|
216
|
+
m();
|
|
217
217
|
return;
|
|
218
218
|
}
|
|
219
|
-
|
|
219
|
+
E({
|
|
220
220
|
name: e,
|
|
221
221
|
data: r
|
|
222
222
|
});
|
|
223
|
-
} else e === t.eventNames.logout_from_same_tab ?
|
|
223
|
+
} else e === t.eventNames.logout_from_same_tab ? h?.() : (e === t.eventNames.loadingTimeout_error || e === t.eventNames.loginAsync_begin || e === t.eventNames.loginCallbackAsync_end || e === t.eventNames.loginAsync_error || e === t.eventNames.loginCallbackAsync_error || e === t.eventNames.service_worker_not_supported_by_browser && n.service_worker_only === !0) && E({
|
|
224
224
|
name: e,
|
|
225
225
|
data: r
|
|
226
226
|
});
|
|
227
227
|
});
|
|
228
228
|
return queueMicrotask(() => {
|
|
229
|
-
|
|
229
|
+
j(r);
|
|
230
230
|
}), () => {
|
|
231
|
-
|
|
231
|
+
C(r).removeEventSubscription(e), E(H), O(!0);
|
|
232
232
|
};
|
|
233
|
-
}, [n, r]),
|
|
234
|
-
let e = n?.loading_timeout_ms ??
|
|
235
|
-
if (e <= 0 || !
|
|
233
|
+
}, [n, r]), b(() => {
|
|
234
|
+
let e = n?.loading_timeout_ms ?? oe;
|
|
235
|
+
if (e <= 0 || !D || C(r)?.tokens != null || T.name !== "" && T.name !== t.eventNames.loginAsync_begin) return;
|
|
236
236
|
let i = setTimeout(() => {
|
|
237
|
-
|
|
237
|
+
C(r).publishEvent(t.eventNames.loadingTimeout_error, { timeoutMs: e });
|
|
238
238
|
}, e);
|
|
239
239
|
return () => clearTimeout(i);
|
|
240
240
|
}, [
|
|
241
|
-
|
|
242
|
-
|
|
241
|
+
T.name,
|
|
242
|
+
D,
|
|
243
243
|
r,
|
|
244
244
|
n
|
|
245
245
|
]);
|
|
246
|
-
let
|
|
247
|
-
switch (
|
|
248
|
-
case t.eventNames.service_worker_not_supported_by_browser: return /* @__PURE__ */
|
|
249
|
-
loadingComponent:
|
|
250
|
-
isLoading:
|
|
246
|
+
let M = d, N = o, P = s, I = c, L = l, R = u, B = k !== r, V = C(r);
|
|
247
|
+
switch (T.name) {
|
|
248
|
+
case t.eventNames.service_worker_not_supported_by_browser: return /* @__PURE__ */ w(U, {
|
|
249
|
+
loadingComponent: P,
|
|
250
|
+
isLoading: B,
|
|
251
251
|
configurationName: r,
|
|
252
|
-
children: /* @__PURE__ */
|
|
252
|
+
children: /* @__PURE__ */ w(L, { configurationName: r })
|
|
253
253
|
});
|
|
254
|
-
case t.eventNames.loginAsync_begin: return /* @__PURE__ */
|
|
255
|
-
loadingComponent:
|
|
256
|
-
isLoading:
|
|
254
|
+
case t.eventNames.loginAsync_begin: return /* @__PURE__ */ w(U, {
|
|
255
|
+
loadingComponent: P,
|
|
256
|
+
isLoading: B,
|
|
257
257
|
configurationName: r,
|
|
258
|
-
children: /* @__PURE__ */
|
|
258
|
+
children: /* @__PURE__ */ w(N, { configurationName: r })
|
|
259
259
|
});
|
|
260
|
-
case t.eventNames.loadingTimeout_error: return /* @__PURE__ */
|
|
261
|
-
loadingComponent:
|
|
262
|
-
isLoading:
|
|
260
|
+
case t.eventNames.loadingTimeout_error: return /* @__PURE__ */ w(U, {
|
|
261
|
+
loadingComponent: P,
|
|
262
|
+
isLoading: B,
|
|
263
263
|
configurationName: r,
|
|
264
|
-
children: /* @__PURE__ */
|
|
264
|
+
children: /* @__PURE__ */ w(I, { configurationName: r })
|
|
265
265
|
});
|
|
266
266
|
case t.eventNames.loginAsync_error:
|
|
267
|
-
case t.eventNames.loginCallbackAsync_error: return /* @__PURE__ */
|
|
268
|
-
loadingComponent:
|
|
269
|
-
isLoading:
|
|
267
|
+
case t.eventNames.loginCallbackAsync_error: return /* @__PURE__ */ w(U, {
|
|
268
|
+
loadingComponent: P,
|
|
269
|
+
isLoading: B,
|
|
270
270
|
configurationName: r,
|
|
271
|
-
children: /* @__PURE__ */
|
|
271
|
+
children: /* @__PURE__ */ w(R, { configurationName: r })
|
|
272
272
|
});
|
|
273
273
|
case t.eventNames.refreshTokensAsync_error:
|
|
274
274
|
case t.eventNames.syncTokensAsync_error:
|
|
275
|
-
case t.eventNames.logout_from_another_tab: return /* @__PURE__ */
|
|
276
|
-
loadingComponent:
|
|
277
|
-
isLoading:
|
|
275
|
+
case t.eventNames.logout_from_another_tab: return /* @__PURE__ */ w(U, {
|
|
276
|
+
loadingComponent: P,
|
|
277
|
+
isLoading: B,
|
|
278
278
|
configurationName: r,
|
|
279
|
-
children: /* @__PURE__ */
|
|
279
|
+
children: /* @__PURE__ */ w(M, { configurationName: r })
|
|
280
280
|
});
|
|
281
|
-
default: return /* @__PURE__ */
|
|
282
|
-
loadingComponent:
|
|
283
|
-
isLoading:
|
|
281
|
+
default: return /* @__PURE__ */ w(U, {
|
|
282
|
+
loadingComponent: P,
|
|
283
|
+
isLoading: B,
|
|
284
284
|
configurationName: r,
|
|
285
|
-
children: /* @__PURE__ */
|
|
286
|
-
redirect_uri:
|
|
287
|
-
silent_redirect_uri:
|
|
288
|
-
silent_login_uri:
|
|
285
|
+
children: /* @__PURE__ */ w(ie, {
|
|
286
|
+
redirect_uri: V.configuration.redirect_uri,
|
|
287
|
+
silent_redirect_uri: V.configuration.silent_redirect_uri,
|
|
288
|
+
silent_login_uri: V.configuration.silent_login_uri,
|
|
289
289
|
callbackSuccessComponent: i,
|
|
290
290
|
callbackErrorComponent: u,
|
|
291
291
|
authenticatingComponent: o,
|
|
292
292
|
configurationName: r,
|
|
293
|
-
withCustomHistory:
|
|
294
|
-
navigateAfterCallback:
|
|
295
|
-
location:
|
|
296
|
-
children: /* @__PURE__ */
|
|
297
|
-
loadingComponent:
|
|
293
|
+
withCustomHistory: g,
|
|
294
|
+
navigateAfterCallback: _,
|
|
295
|
+
location: x ?? new a(),
|
|
296
|
+
children: /* @__PURE__ */ w(ae, {
|
|
297
|
+
loadingComponent: P,
|
|
298
298
|
configurationName: r,
|
|
299
299
|
children: e
|
|
300
300
|
})
|
|
301
301
|
})
|
|
302
302
|
});
|
|
303
303
|
}
|
|
304
|
-
},
|
|
304
|
+
}, K = ({ children: e, callbackPath: n = null, extras: r = null, configurationName: i = "default" }) => {
|
|
305
305
|
let a = t.getOrThrow, o = a(i);
|
|
306
|
-
return
|
|
306
|
+
return b(() => {
|
|
307
307
|
!o.tokens && !o.isLoggingOut && o.loginAsync(n, r);
|
|
308
308
|
}, [
|
|
309
309
|
i,
|
|
310
310
|
n,
|
|
311
311
|
r
|
|
312
|
-
]), o.tokens ? /* @__PURE__ */ C
|
|
313
|
-
},
|
|
312
|
+
]), o.tokens ? /* @__PURE__ */ w(C, { children: e }) : null;
|
|
313
|
+
}, se = (e, t = null, n = null, r = "default") => (i) => /* @__PURE__ */ w(K, {
|
|
314
314
|
callbackPath: t,
|
|
315
315
|
extras: n,
|
|
316
316
|
configurationName: r,
|
|
317
|
-
children: /* @__PURE__ */
|
|
318
|
-
}),
|
|
319
|
-
|
|
320
|
-
},
|
|
317
|
+
children: /* @__PURE__ */ w(e, { ...i })
|
|
318
|
+
}), q = /* @__PURE__ */ new Set(), J = (e) => {
|
|
319
|
+
q.has(e) || (q.add(e), console.warn(`@axa-fr/react-oidc: no OIDC configuration found for "${e}". Make sure to wrap your component tree with <OidcProvider configurationName="${e}">. Hooks are returning safe default values (issue #1679).`));
|
|
320
|
+
}, Y = "default", X = (e, t) => {
|
|
321
321
|
let n = !1, r = e(t);
|
|
322
322
|
return r && (n = r.tokens != null), n;
|
|
323
|
-
},
|
|
324
|
-
let n = t.get, [r, i] =
|
|
325
|
-
return
|
|
323
|
+
}, ce = (e = Y) => {
|
|
324
|
+
let n = t.get, [r, i] = S(() => X(n, e));
|
|
325
|
+
return b(() => {
|
|
326
326
|
let r = !0, a = n(e);
|
|
327
327
|
if (!a) {
|
|
328
|
-
|
|
328
|
+
J(e);
|
|
329
329
|
return;
|
|
330
330
|
}
|
|
331
331
|
let o = a.subscribeEvents((a, o) => {
|
|
332
|
-
(a === t.eventNames.logout_from_another_tab || a === t.eventNames.logout_from_same_tab || a === t.eventNames.token_acquired) && r && i(
|
|
332
|
+
(a === t.eventNames.logout_from_another_tab || a === t.eventNames.logout_from_same_tab || a === t.eventNames.token_acquired) && r && i(X(n, e));
|
|
333
333
|
});
|
|
334
334
|
return () => {
|
|
335
335
|
r = !1, a.removeEventSubscription(o);
|
|
@@ -337,15 +337,15 @@ var T = "default", E = (e, t, n = !1) => async (...r) => await t().fetchWithToke
|
|
|
337
337
|
}, [e]), {
|
|
338
338
|
login: (t = void 0, r = void 0, i = !1, a = void 0) => {
|
|
339
339
|
let o = n(e);
|
|
340
|
-
return o ? o.loginAsync(t, r, !1, a, i) : (
|
|
340
|
+
return o ? o.loginAsync(t, r, !1, a, i) : (J(e), Promise.resolve());
|
|
341
341
|
},
|
|
342
342
|
logout: (t = void 0, r = void 0) => {
|
|
343
343
|
let i = n(e);
|
|
344
|
-
return i ? i.logoutAsync(t, r) : (
|
|
344
|
+
return i ? i.logoutAsync(t, r) : (J(e), Promise.resolve());
|
|
345
345
|
},
|
|
346
346
|
renewTokens: async (t = void 0) => {
|
|
347
347
|
let r = n(e);
|
|
348
|
-
if (!r) return
|
|
348
|
+
if (!r) return J(e), {
|
|
349
349
|
accessToken: null,
|
|
350
350
|
accessTokenPayload: null,
|
|
351
351
|
idToken: null,
|
|
@@ -361,12 +361,12 @@ var T = "default", E = (e, t, n = !1) => async (...r) => await t().fetchWithToke
|
|
|
361
361
|
},
|
|
362
362
|
isAuthenticated: r
|
|
363
363
|
};
|
|
364
|
-
},
|
|
364
|
+
}, Z = {
|
|
365
365
|
accessToken: null,
|
|
366
366
|
accessTokenPayload: null
|
|
367
|
-
},
|
|
367
|
+
}, Q = (e) => {
|
|
368
368
|
let n = t.get, r = n(e);
|
|
369
|
-
if (!r) return
|
|
369
|
+
if (!r) return Z;
|
|
370
370
|
if (r.tokens) {
|
|
371
371
|
let e = r.tokens;
|
|
372
372
|
return {
|
|
@@ -375,23 +375,23 @@ var T = "default", E = (e, t, n = !1) => async (...r) => await t().fetchWithToke
|
|
|
375
375
|
generateDemonstrationOfProofOfPossessionAsync: r.configuration.demonstrating_proof_of_possession ? (t, n) => r.generateDemonstrationOfProofOfPossessionAsync(e.accessToken, t, n) : null
|
|
376
376
|
};
|
|
377
377
|
}
|
|
378
|
-
return
|
|
378
|
+
return Z;
|
|
379
379
|
};
|
|
380
380
|
function le(e, t) {
|
|
381
381
|
return e.configuration.demonstrating_proof_of_possession ? (n, r, i = {}) => e.generateDemonstrationOfProofOfPossessionAsync(t.accessToken, n, r, i) : null;
|
|
382
382
|
}
|
|
383
|
-
var ue = (e =
|
|
384
|
-
let n = t.get, [r, i] =
|
|
385
|
-
return
|
|
383
|
+
var ue = (e = Y) => {
|
|
384
|
+
let n = t.get, [r, i] = S(() => Q(e));
|
|
385
|
+
return b(() => {
|
|
386
386
|
let r = !0, a = n(e);
|
|
387
387
|
if (!a) {
|
|
388
|
-
|
|
388
|
+
J(e);
|
|
389
389
|
return;
|
|
390
390
|
}
|
|
391
391
|
let o = a.subscribeEvents((e, n) => {
|
|
392
392
|
if ((e === t.eventNames.token_renewed || e === t.eventNames.token_acquired || e === t.eventNames.logout_from_another_tab || e === t.eventNames.logout_from_same_tab || e === t.eventNames.refreshTokensAsync_error || e === t.eventNames.syncTokensAsync_error) && r) {
|
|
393
393
|
let e = a.tokens;
|
|
394
|
-
i(e == null ?
|
|
394
|
+
i(e == null ? Z : {
|
|
395
395
|
accessToken: e.accessToken,
|
|
396
396
|
accessTokenPayload: e.accessTokenPayload,
|
|
397
397
|
generateDemonstrationOfProofOfPossessionAsync: le(a, e)
|
|
@@ -416,12 +416,12 @@ var ue = (e = X) => {
|
|
|
416
416
|
};
|
|
417
417
|
}
|
|
418
418
|
return $;
|
|
419
|
-
}, fe = (e =
|
|
420
|
-
let n = t.get, [r, i] =
|
|
421
|
-
return
|
|
419
|
+
}, fe = (e = Y) => {
|
|
420
|
+
let n = t.get, [r, i] = S(() => de(e));
|
|
421
|
+
return b(() => {
|
|
422
422
|
let r = !0, a = n(e);
|
|
423
423
|
if (!a) {
|
|
424
|
-
|
|
424
|
+
J(e);
|
|
425
425
|
return;
|
|
426
426
|
}
|
|
427
427
|
let o = a.subscribeEvents((e, n) => {
|
|
@@ -440,14 +440,14 @@ var ue = (e = X) => {
|
|
|
440
440
|
}, pe = /* @__PURE__ */ function(e) {
|
|
441
441
|
return e.Unauthenticated = "Unauthenticated", e.Loading = "Loading user", e.Loaded = "User loaded", e.LoadingError = "Error loading user", e;
|
|
442
442
|
}({}), me = (e = "default", n = !1) => {
|
|
443
|
-
let r = t.get(e), i = r ? r.userInfo() : null, [a, o] =
|
|
443
|
+
let r = t.get(e), i = r ? r.userInfo() : null, [a, o] = S({
|
|
444
444
|
user: i,
|
|
445
445
|
status: i ? "User loaded" : "Unauthenticated"
|
|
446
|
-
}), [s, c] =
|
|
447
|
-
return
|
|
446
|
+
}), [s, c] = S(+!!i), l = x(+!!i);
|
|
447
|
+
return b(() => {
|
|
448
448
|
let r = t.get(e), i = !0;
|
|
449
449
|
if (!r) {
|
|
450
|
-
|
|
450
|
+
J(e);
|
|
451
451
|
return;
|
|
452
452
|
}
|
|
453
453
|
if (r.tokens) {
|
|
@@ -495,4 +495,4 @@ var ue = (e = X) => {
|
|
|
495
495
|
};
|
|
496
496
|
};
|
|
497
497
|
//#endregion
|
|
498
|
-
export { e as OidcClient, n as OidcError, r as OidcErrorCode, i as OidcLocation,
|
|
498
|
+
export { e as OidcClient, n as OidcError, r as OidcErrorCode, i as OidcLocation, G as OidcProvider, K as OidcSecure, o as OidcStateError, s as OidcStateErrorCode, pe as OidcUserStatus, c as PushedAuthorizationRequestError, l as PushedAuthorizationRequestErrorCode, u as TokenAutomaticRenewMode, d as TokenRenewMode, h as isOidcError, g as isOidcStateError, _ as isPushedAuthorizationRequestError, ce as useOidc, ue as useOidcAccessToken, k as useOidcFetch, fe as useOidcIdToken, me as useOidcUser, O as withOidcFetch, se as withOidcSecure };
|