@axa-fr/react-oidc 7.29.3 → 7.29.5
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/ReactOidc.d.ts.map +1 -1
- package/dist/core/default-component/SilentLogin.component.d.ts.map +1 -1
- package/dist/core/routes/OidcRoutes.d.ts.map +1 -1
- package/dist/index.js +164 -169
- package/dist/index.umd.cjs +1 -1
- package/package.json +18 -18
- package/src/FetchToken.spec.tsx +135 -0
- package/src/FetchToken.tsx +4 -17
- package/src/OidcSecure.spec.tsx +84 -0
- package/src/ReactOidc.spec.tsx +222 -0
- package/src/ReactOidc.tsx +12 -22
- package/src/core/default-component/SilentLogin.component.spec.tsx +71 -0
- package/src/core/default-component/SilentLogin.component.tsx +1 -3
- package/src/core/routes/OidcRoutes.behavior.spec.tsx +123 -0
- package/src/core/routes/OidcRoutes.tsx +15 -21
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;
|
|
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;AAID,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;mBAQ/B,WAAW,GAAG,GAAG,SAAS,WAAW,KAAG,OAAO,CAAC,QAAQ,CAAC;CAW1E,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/ReactOidc.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReactOidc.d.ts","sourceRoot":"","sources":["../src/ReactOidc.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,SAAS,EAAU,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"ReactOidc.d.ts","sourceRoot":"","sources":["../src/ReactOidc.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,SAAS,EAAU,MAAM,qBAAqB,CAAC;AAwBpE,eAAO,MAAM,OAAO,GAAI,0BAA4C;2BAkClD,MAAM,GAAG,SAAS,WACxB,SAAS,GAAG,SAAS,qCAEtB,MAAM,KACZ,OAAO,CAAC,OAAO,CAAC;4BASH,MAAM,GAAG,IAAI,GAAG,SAAS,WAC/B,SAAS,GAAG,SAAS,KAC5B,OAAO,CAAC,IAAI,CAAC;2BASN,SAAS,GAAG,SAAS,KAC5B,OAAO,CAAC,eAAe,GAAG,WAAW,CAAC;;CAoB1C,CAAC;AAyBF,MAAM,MAAM,eAAe,GAAG;IAC5B,WAAW,CAAC,EAAE,GAAG,CAAC;IAClB,kBAAkB,CAAC,EAAE,GAAG,CAAC;IACzB,6CAA6C,CAAC,EAAE,GAAG,CAAC;CACrD,CAAC;AASF,eAAO,MAAM,kBAAkB,GAAI,0BAA4C,oBAoC9E,CAAC;AAkBF,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,cAAc,CAAC,EAAE,GAAG,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,0BAA4C,gBA+B1E,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SilentLogin.component.d.ts","sourceRoot":"","sources":["../../../src/core/default-component/SilentLogin.component.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAa,MAAM,OAAO,CAAC;AAEjD,QAAA,MAAM,WAAW,EAAE,aAAa,CAAC,GAAG,
|
|
1
|
+
{"version":3,"file":"SilentLogin.component.d.ts","sourceRoot":"","sources":["../../../src/core/default-component/SilentLogin.component.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAa,MAAM,OAAO,CAAC;AAEjD,QAAA,MAAM,WAAW,EAAE,aAAa,CAAC,GAAG,CAuBnC,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OidcRoutes.d.ts","sourceRoot":"","sources":["../../../src/core/routes/OidcRoutes.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAW,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,KAAK,EAAE,EAAE,aAAa,EAA8C,MAAM,OAAO,CAAC;AAKzF,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,KAAK,eAAe,GAAG;IACrB,wBAAwB,CAAC,EAAE,aAAa,CAAC;IACzC,sBAAsB,CAAC,EAAE,aAAa,CAAC;IACvC,uBAAuB,CAAC,EAAE,aAAa,CAAC;IACxC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,iBAAiB,CAAC,EAAE,MAAM,aAAa,CAAC;IACxC,qBAAqB,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAChE,QAAQ,EAAE,cAAc,CAAC;CAC1B,CAAC;;
|
|
1
|
+
{"version":3,"file":"OidcRoutes.d.ts","sourceRoot":"","sources":["../../../src/core/routes/OidcRoutes.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAW,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,KAAK,EAAE,EAAE,aAAa,EAA8C,MAAM,OAAO,CAAC;AAKzF,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,KAAK,eAAe,GAAG;IACrB,wBAAwB,CAAC,EAAE,aAAa,CAAC;IACzC,sBAAsB,CAAC,EAAE,aAAa,CAAC;IACvC,uBAAuB,CAAC,EAAE,aAAa,CAAC;IACxC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,iBAAiB,CAAC,EAAE,MAAM,aAAa,CAAC;IACxC,qBAAqB,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAChE,QAAQ,EAAE,cAAc,CAAC;CAC1B,CAAC;;AAiDF,wBAAsC"}
|
package/dist/index.js
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
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
|
|
5
|
+
var E = "default", D = (e = null, t = E, n = !1) => (r) => (i) => {
|
|
6
6
|
let { fetch: a } = O(e || i.fetch, t, n);
|
|
7
|
-
return /* @__PURE__ */
|
|
7
|
+
return /* @__PURE__ */ w(r, {
|
|
8
8
|
...i,
|
|
9
9
|
fetch: a
|
|
10
10
|
});
|
|
11
|
-
}, O = (e = null, n =
|
|
11
|
+
}, O = (e = null, n = E, r = !1) => {
|
|
12
12
|
let i = e || window.fetch, a = t.getOrThrow;
|
|
13
|
-
return { fetch:
|
|
13
|
+
return { fetch: y(async (e, t) => await a(n).fetchWithTokens(i, r)(e, t), [
|
|
14
14
|
i,
|
|
15
15
|
n,
|
|
16
16
|
r
|
|
17
17
|
]) };
|
|
18
|
-
}, k = () => /* @__PURE__ */
|
|
18
|
+
}, k = () => /* @__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
|
})]
|
|
@@ -53,21 +53,21 @@ var T = "default", E = (e, t, n = !1) => async (...r) => await t().fetchWithToke
|
|
|
53
53
|
key: a,
|
|
54
54
|
state: o
|
|
55
55
|
}, null, r), e.dispatchEvent(t("popstate"));
|
|
56
|
-
} }), N = () => M(window, j(window, document), A), P = () => /* @__PURE__ */
|
|
56
|
+
} }), N = () => M(window, j(window, document), A), P = () => /* @__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
68
|
}), F = 200, I = (e, t = window) => t.location.pathname === e || e === "/", L = ({ callBackError: e, callBackSuccess: n, configurationName: r, withCustomHistory: i, navigateAfterCallback: a }) => {
|
|
69
|
-
let [o, s] =
|
|
70
|
-
return
|
|
69
|
+
let [o, s] = S(!1);
|
|
70
|
+
return b(() => {
|
|
71
71
|
let e = !0;
|
|
72
72
|
return (async () => {
|
|
73
73
|
let n = t.getOrThrow;
|
|
@@ -103,233 +103,228 @@ 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 || k : n || P, { configurationName: r });
|
|
107
|
+
}, R = () => /* @__PURE__ */ w("span", {
|
|
108
108
|
className: "oidc-loading",
|
|
109
109
|
children: "Loading"
|
|
110
|
-
}),
|
|
110
|
+
}), te = () => /* @__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
|
+
}), ne = () => /* @__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
|
+
}), re = () => /* @__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
|
-
}), z = ({ configurationName: e }) => (
|
|
146
|
+
}), z = ({ 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
152
|
}, [e]), null), B = ({ configurationName: e }) => {
|
|
153
|
-
let n =
|
|
154
|
-
for (let [e, t] of Object.entries(n)) e
|
|
155
|
-
return
|
|
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 ??= {}, 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
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
navigateAfterCallback: c
|
|
174
|
-
});
|
|
175
|
-
default: return /* @__PURE__ */ C(S, { children: a });
|
|
176
|
-
}
|
|
177
|
-
}), H = {
|
|
164
|
+
let f = m(n);
|
|
165
|
+
return r && u === m(r) ? /* @__PURE__ */ w(z, { configurationName: o }) : i && u === m(i) ? /* @__PURE__ */ w(B, { configurationName: o }) : u === f ? /* @__PURE__ */ w(L, {
|
|
166
|
+
callBackError: e,
|
|
167
|
+
callBackSuccess: t,
|
|
168
|
+
configurationName: o,
|
|
169
|
+
withCustomHistory: s,
|
|
170
|
+
navigateAfterCallback: c
|
|
171
|
+
}) : /* @__PURE__ */ w(C, { children: a });
|
|
172
|
+
}), V = {
|
|
178
173
|
name: "",
|
|
179
174
|
data: null
|
|
180
175
|
}, ae = ({ loadingComponent: e, children: n, configurationName: r }) => {
|
|
181
|
-
let [i, a] =
|
|
182
|
-
return
|
|
176
|
+
let [i, a] = S(!0), o = t.get, s = o(r);
|
|
177
|
+
return b(() => {
|
|
183
178
|
let e = !0;
|
|
184
179
|
return s && s.tryKeepExistingSessionAsync().then(() => {
|
|
185
180
|
e && a(!1);
|
|
186
181
|
}), () => {
|
|
187
182
|
e = !1;
|
|
188
183
|
};
|
|
189
|
-
}, [r]), /* @__PURE__ */ C
|
|
190
|
-
},
|
|
184
|
+
}, [r]), /* @__PURE__ */ w(C, { children: i ? /* @__PURE__ */ w(e, { configurationName: r }) : /* @__PURE__ */ w(C, { children: n }) });
|
|
185
|
+
}, H = ({ isLoading: e, loadingComponent: t, children: n, configurationName: r }) => e ? /* @__PURE__ */ w(t, {
|
|
191
186
|
configurationName: r,
|
|
192
187
|
children: n
|
|
193
|
-
}) : /* @__PURE__ */ C
|
|
188
|
+
}) : /* @__PURE__ */ w(C, { children: n }), oe = 3e4, se = (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, U = ({ children: e, configuration: n, configurationName: r = "default", callbackSuccessComponent: i = P, authenticatingComponent: o = ee, loadingComponent: s = R, loadingTimeoutComponent: c = te, serviceWorkerNotSupportedComponent: l = ne, authenticatingErrorComponent: u = k, sessionLostComponent: d = re, onSessionLost: p = null, onLogoutFromAnotherTab: m = null, onLogoutFromSameTab: h = null, withCustomHistory: g = null, navigateAfterCallback: _ = null, onEvent: v = null, getFetch: y = null, location: x = null }) => {
|
|
194
189
|
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
|
-
|
|
190
|
+
let C = (e = "default") => t.getOrCreate(y ?? f, x ?? new a())(n, e), [T, E] = S(V), [D, O] = S(!0), [A, j] = S(r);
|
|
191
|
+
b(() => {
|
|
192
|
+
let e = C(r).subscribeEvents((e, t) => {
|
|
193
|
+
v && v(r, e, t);
|
|
199
194
|
});
|
|
200
195
|
return () => {
|
|
201
|
-
|
|
196
|
+
C(r).removeEventSubscription(e);
|
|
202
197
|
};
|
|
203
|
-
}, [r,
|
|
204
|
-
let e =
|
|
205
|
-
if (e === t.eventNames.loginAsync_begin ?
|
|
206
|
-
if (
|
|
207
|
-
|
|
198
|
+
}, [r, v]), b(() => {
|
|
199
|
+
let e = C(r).subscribeEvents((e, r) => {
|
|
200
|
+
if (e === t.eventNames.loginAsync_begin ? O(!0) : se(e) && O(!1), e === t.eventNames.refreshTokensAsync_error || e === t.eventNames.syncTokensAsync_error) {
|
|
201
|
+
if (p != null) {
|
|
202
|
+
p();
|
|
208
203
|
return;
|
|
209
204
|
}
|
|
210
|
-
|
|
205
|
+
E({
|
|
211
206
|
name: e,
|
|
212
207
|
data: r
|
|
213
208
|
});
|
|
214
209
|
} else if (e === t.eventNames.logout_from_another_tab) {
|
|
215
|
-
if (
|
|
216
|
-
|
|
210
|
+
if (m != null) {
|
|
211
|
+
m();
|
|
217
212
|
return;
|
|
218
213
|
}
|
|
219
|
-
|
|
214
|
+
E({
|
|
220
215
|
name: e,
|
|
221
216
|
data: r
|
|
222
217
|
});
|
|
223
|
-
} else e === t.eventNames.logout_from_same_tab ?
|
|
218
|
+
} 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
219
|
name: e,
|
|
225
220
|
data: r
|
|
226
221
|
});
|
|
227
222
|
});
|
|
228
223
|
return queueMicrotask(() => {
|
|
229
|
-
|
|
224
|
+
j(r);
|
|
230
225
|
}), () => {
|
|
231
|
-
|
|
226
|
+
C(r).removeEventSubscription(e), E(V), O(!0);
|
|
232
227
|
};
|
|
233
|
-
}, [n, r]),
|
|
234
|
-
let e = n?.loading_timeout_ms ??
|
|
235
|
-
if (e <= 0 || !
|
|
228
|
+
}, [n, r]), b(() => {
|
|
229
|
+
let e = n?.loading_timeout_ms ?? oe;
|
|
230
|
+
if (e <= 0 || !D || C(r)?.tokens != null || T.name !== "" && T.name !== t.eventNames.loginAsync_begin) return;
|
|
236
231
|
let i = setTimeout(() => {
|
|
237
|
-
|
|
232
|
+
C(r).publishEvent(t.eventNames.loadingTimeout_error, { timeoutMs: e });
|
|
238
233
|
}, e);
|
|
239
234
|
return () => clearTimeout(i);
|
|
240
235
|
}, [
|
|
241
|
-
|
|
242
|
-
|
|
236
|
+
T.name,
|
|
237
|
+
D,
|
|
243
238
|
r,
|
|
244
239
|
n
|
|
245
240
|
]);
|
|
246
|
-
let
|
|
247
|
-
switch (
|
|
248
|
-
case t.eventNames.service_worker_not_supported_by_browser: return /* @__PURE__ */
|
|
249
|
-
loadingComponent:
|
|
250
|
-
isLoading:
|
|
241
|
+
let M = d, N = o, F = s, I = c, L = l, z = u, B = A !== r, U = C(r);
|
|
242
|
+
switch (T.name) {
|
|
243
|
+
case t.eventNames.service_worker_not_supported_by_browser: return /* @__PURE__ */ w(H, {
|
|
244
|
+
loadingComponent: F,
|
|
245
|
+
isLoading: B,
|
|
251
246
|
configurationName: r,
|
|
252
|
-
children: /* @__PURE__ */
|
|
247
|
+
children: /* @__PURE__ */ w(L, { configurationName: r })
|
|
253
248
|
});
|
|
254
|
-
case t.eventNames.loginAsync_begin: return /* @__PURE__ */
|
|
255
|
-
loadingComponent:
|
|
256
|
-
isLoading:
|
|
249
|
+
case t.eventNames.loginAsync_begin: return /* @__PURE__ */ w(H, {
|
|
250
|
+
loadingComponent: F,
|
|
251
|
+
isLoading: B,
|
|
257
252
|
configurationName: r,
|
|
258
|
-
children: /* @__PURE__ */
|
|
253
|
+
children: /* @__PURE__ */ w(N, { configurationName: r })
|
|
259
254
|
});
|
|
260
|
-
case t.eventNames.loadingTimeout_error: return /* @__PURE__ */
|
|
261
|
-
loadingComponent:
|
|
262
|
-
isLoading:
|
|
255
|
+
case t.eventNames.loadingTimeout_error: return /* @__PURE__ */ w(H, {
|
|
256
|
+
loadingComponent: F,
|
|
257
|
+
isLoading: B,
|
|
263
258
|
configurationName: r,
|
|
264
|
-
children: /* @__PURE__ */
|
|
259
|
+
children: /* @__PURE__ */ w(I, { configurationName: r })
|
|
265
260
|
});
|
|
266
261
|
case t.eventNames.loginAsync_error:
|
|
267
|
-
case t.eventNames.loginCallbackAsync_error: return /* @__PURE__ */
|
|
268
|
-
loadingComponent:
|
|
269
|
-
isLoading:
|
|
262
|
+
case t.eventNames.loginCallbackAsync_error: return /* @__PURE__ */ w(H, {
|
|
263
|
+
loadingComponent: F,
|
|
264
|
+
isLoading: B,
|
|
270
265
|
configurationName: r,
|
|
271
|
-
children: /* @__PURE__ */
|
|
266
|
+
children: /* @__PURE__ */ w(z, { configurationName: r })
|
|
272
267
|
});
|
|
273
268
|
case t.eventNames.refreshTokensAsync_error:
|
|
274
269
|
case t.eventNames.syncTokensAsync_error:
|
|
275
|
-
case t.eventNames.logout_from_another_tab: return /* @__PURE__ */
|
|
276
|
-
loadingComponent:
|
|
277
|
-
isLoading:
|
|
270
|
+
case t.eventNames.logout_from_another_tab: return /* @__PURE__ */ w(H, {
|
|
271
|
+
loadingComponent: F,
|
|
272
|
+
isLoading: B,
|
|
278
273
|
configurationName: r,
|
|
279
|
-
children: /* @__PURE__ */
|
|
274
|
+
children: /* @__PURE__ */ w(M, { configurationName: r })
|
|
280
275
|
});
|
|
281
|
-
default: return /* @__PURE__ */
|
|
282
|
-
loadingComponent:
|
|
283
|
-
isLoading:
|
|
276
|
+
default: return /* @__PURE__ */ w(H, {
|
|
277
|
+
loadingComponent: F,
|
|
278
|
+
isLoading: B,
|
|
284
279
|
configurationName: r,
|
|
285
|
-
children: /* @__PURE__ */
|
|
286
|
-
redirect_uri:
|
|
287
|
-
silent_redirect_uri:
|
|
288
|
-
silent_login_uri:
|
|
280
|
+
children: /* @__PURE__ */ w(ie, {
|
|
281
|
+
redirect_uri: U.configuration.redirect_uri,
|
|
282
|
+
silent_redirect_uri: U.configuration.silent_redirect_uri,
|
|
283
|
+
silent_login_uri: U.configuration.silent_login_uri,
|
|
289
284
|
callbackSuccessComponent: i,
|
|
290
285
|
callbackErrorComponent: u,
|
|
291
286
|
authenticatingComponent: o,
|
|
292
287
|
configurationName: r,
|
|
293
|
-
withCustomHistory:
|
|
294
|
-
navigateAfterCallback:
|
|
295
|
-
location:
|
|
296
|
-
children: /* @__PURE__ */
|
|
297
|
-
loadingComponent:
|
|
288
|
+
withCustomHistory: g,
|
|
289
|
+
navigateAfterCallback: _,
|
|
290
|
+
location: x ?? new a(),
|
|
291
|
+
children: /* @__PURE__ */ w(ae, {
|
|
292
|
+
loadingComponent: F,
|
|
298
293
|
configurationName: r,
|
|
299
294
|
children: e
|
|
300
295
|
})
|
|
301
296
|
})
|
|
302
297
|
});
|
|
303
298
|
}
|
|
304
|
-
},
|
|
299
|
+
}, W = ({ children: e, callbackPath: n = null, extras: r = null, configurationName: i = "default" }) => {
|
|
305
300
|
let a = t.getOrThrow, o = a(i);
|
|
306
|
-
return
|
|
301
|
+
return b(() => {
|
|
307
302
|
!o.tokens && !o.isLoggingOut && o.loginAsync(n, r);
|
|
308
303
|
}, [
|
|
309
304
|
i,
|
|
310
305
|
n,
|
|
311
306
|
r
|
|
312
|
-
]), o.tokens ? /* @__PURE__ */ C
|
|
313
|
-
},
|
|
307
|
+
]), o.tokens ? /* @__PURE__ */ w(C, { children: e }) : null;
|
|
308
|
+
}, G = (e, t = null, n = null, r = "default") => (i) => /* @__PURE__ */ w(W, {
|
|
314
309
|
callbackPath: t,
|
|
315
310
|
extras: n,
|
|
316
311
|
configurationName: r,
|
|
317
|
-
children: /* @__PURE__ */
|
|
318
|
-
}),
|
|
319
|
-
|
|
320
|
-
},
|
|
321
|
-
let n =
|
|
322
|
-
return
|
|
323
|
-
},
|
|
324
|
-
let n = t.get, [r, i] =
|
|
325
|
-
return
|
|
312
|
+
children: /* @__PURE__ */ w(e, { ...i })
|
|
313
|
+
}), K = /* @__PURE__ */ new Set(), q = (e) => {
|
|
314
|
+
K.has(e) || (K.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).`));
|
|
315
|
+
}, J = "default", Y = (e, t) => {
|
|
316
|
+
let n = e(t);
|
|
317
|
+
return n ? n.tokens != null : !1;
|
|
318
|
+
}, X = (e) => 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, ce = (e = J) => {
|
|
319
|
+
let n = t.get, [r, i] = S(() => Y(n, e));
|
|
320
|
+
return b(() => {
|
|
326
321
|
let r = !0, a = n(e);
|
|
327
322
|
if (!a) {
|
|
328
|
-
|
|
323
|
+
q(e);
|
|
329
324
|
return;
|
|
330
325
|
}
|
|
331
326
|
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(
|
|
327
|
+
(a === t.eventNames.logout_from_another_tab || a === t.eventNames.logout_from_same_tab || a === t.eventNames.token_acquired) && r && i(Y(n, e));
|
|
333
328
|
});
|
|
334
329
|
return () => {
|
|
335
330
|
r = !1, a.removeEventSubscription(o);
|
|
@@ -337,15 +332,15 @@ var T = "default", E = (e, t, n = !1) => async (...r) => await t().fetchWithToke
|
|
|
337
332
|
}, [e]), {
|
|
338
333
|
login: (t = void 0, r = void 0, i = !1, a = void 0) => {
|
|
339
334
|
let o = n(e);
|
|
340
|
-
return o ? o.loginAsync(t, r, !1, a, i) : (
|
|
335
|
+
return o ? o.loginAsync(t, r, !1, a, i) : (q(e), Promise.resolve());
|
|
341
336
|
},
|
|
342
337
|
logout: (t = void 0, r = void 0) => {
|
|
343
338
|
let i = n(e);
|
|
344
|
-
return i ? i.logoutAsync(t, r) : (
|
|
339
|
+
return i ? i.logoutAsync(t, r) : (q(e), Promise.resolve());
|
|
345
340
|
},
|
|
346
341
|
renewTokens: async (t = void 0) => {
|
|
347
342
|
let r = n(e);
|
|
348
|
-
if (!r) return
|
|
343
|
+
if (!r) return q(e), {
|
|
349
344
|
accessToken: null,
|
|
350
345
|
accessTokenPayload: null,
|
|
351
346
|
idToken: null,
|
|
@@ -361,12 +356,12 @@ var T = "default", E = (e, t, n = !1) => async (...r) => await t().fetchWithToke
|
|
|
361
356
|
},
|
|
362
357
|
isAuthenticated: r
|
|
363
358
|
};
|
|
364
|
-
},
|
|
359
|
+
}, Z = {
|
|
365
360
|
accessToken: null,
|
|
366
361
|
accessTokenPayload: null
|
|
367
|
-
},
|
|
362
|
+
}, Q = (e) => {
|
|
368
363
|
let n = t.get, r = n(e);
|
|
369
|
-
if (!r) return
|
|
364
|
+
if (!r) return Z;
|
|
370
365
|
if (r.tokens) {
|
|
371
366
|
let e = r.tokens;
|
|
372
367
|
return {
|
|
@@ -375,31 +370,31 @@ var T = "default", E = (e, t, n = !1) => async (...r) => await t().fetchWithToke
|
|
|
375
370
|
generateDemonstrationOfProofOfPossessionAsync: r.configuration.demonstrating_proof_of_possession ? (t, n) => r.generateDemonstrationOfProofOfPossessionAsync(e.accessToken, t, n) : null
|
|
376
371
|
};
|
|
377
372
|
}
|
|
378
|
-
return
|
|
373
|
+
return Z;
|
|
379
374
|
};
|
|
380
375
|
function le(e, t) {
|
|
381
376
|
return e.configuration.demonstrating_proof_of_possession ? (n, r, i = {}) => e.generateDemonstrationOfProofOfPossessionAsync(t.accessToken, n, r, i) : null;
|
|
382
377
|
}
|
|
383
|
-
var ue = (e =
|
|
384
|
-
let n = t.get, [r, i] =
|
|
385
|
-
return
|
|
386
|
-
let
|
|
387
|
-
if (!
|
|
388
|
-
|
|
378
|
+
var ue = (e = J) => {
|
|
379
|
+
let n = t.get, [r, i] = S(() => Q(e));
|
|
380
|
+
return b(() => {
|
|
381
|
+
let t = !0, r = n(e);
|
|
382
|
+
if (!r) {
|
|
383
|
+
q(e);
|
|
389
384
|
return;
|
|
390
385
|
}
|
|
391
|
-
let
|
|
392
|
-
if ((e
|
|
393
|
-
let e =
|
|
394
|
-
i(e == null ?
|
|
386
|
+
let a = r.subscribeEvents((e, n) => {
|
|
387
|
+
if (X(e) && t) {
|
|
388
|
+
let e = r.tokens;
|
|
389
|
+
i(e == null ? Z : {
|
|
395
390
|
accessToken: e.accessToken,
|
|
396
391
|
accessTokenPayload: e.accessTokenPayload,
|
|
397
|
-
generateDemonstrationOfProofOfPossessionAsync: le(
|
|
392
|
+
generateDemonstrationOfProofOfPossessionAsync: le(r, e)
|
|
398
393
|
});
|
|
399
394
|
}
|
|
400
395
|
});
|
|
401
396
|
return () => {
|
|
402
|
-
|
|
397
|
+
t = !1, r.removeEventSubscription(a);
|
|
403
398
|
};
|
|
404
399
|
}, [e]), r;
|
|
405
400
|
}, $ = {
|
|
@@ -416,17 +411,17 @@ var ue = (e = X) => {
|
|
|
416
411
|
};
|
|
417
412
|
}
|
|
418
413
|
return $;
|
|
419
|
-
}, fe = (e =
|
|
420
|
-
let n = t.get, [r, i] =
|
|
421
|
-
return
|
|
422
|
-
let
|
|
423
|
-
if (!
|
|
424
|
-
|
|
414
|
+
}, fe = (e = J) => {
|
|
415
|
+
let n = t.get, [r, i] = S(() => de(e));
|
|
416
|
+
return b(() => {
|
|
417
|
+
let t = !0, r = n(e);
|
|
418
|
+
if (!r) {
|
|
419
|
+
q(e);
|
|
425
420
|
return;
|
|
426
421
|
}
|
|
427
|
-
let
|
|
428
|
-
if ((e
|
|
429
|
-
let e =
|
|
422
|
+
let a = r.subscribeEvents((e, n) => {
|
|
423
|
+
if (X(e) && t) {
|
|
424
|
+
let e = r.tokens;
|
|
430
425
|
i(e == null ? $ : {
|
|
431
426
|
idToken: e.idToken,
|
|
432
427
|
idTokenPayload: e.idTokenPayload
|
|
@@ -434,20 +429,20 @@ var ue = (e = X) => {
|
|
|
434
429
|
}
|
|
435
430
|
});
|
|
436
431
|
return () => {
|
|
437
|
-
|
|
432
|
+
t = !1, r.removeEventSubscription(a);
|
|
438
433
|
};
|
|
439
434
|
}, [e]), r;
|
|
440
435
|
}, pe = /* @__PURE__ */ function(e) {
|
|
441
436
|
return e.Unauthenticated = "Unauthenticated", e.Loading = "Loading user", e.Loaded = "User loaded", e.LoadingError = "Error loading user", e;
|
|
442
437
|
}({}), me = (e = "default", n = !1) => {
|
|
443
|
-
let r = t.get(e), i = r ? r.userInfo() : null, [a, o] =
|
|
438
|
+
let r = t.get(e), i = r ? r.userInfo() : null, [a, o] = S({
|
|
444
439
|
user: i,
|
|
445
440
|
status: i ? "User loaded" : "Unauthenticated"
|
|
446
|
-
}), [s, c] =
|
|
447
|
-
return
|
|
441
|
+
}), [s, c] = S(+!!i), l = x(+!!i);
|
|
442
|
+
return b(() => {
|
|
448
443
|
let r = t.get(e), i = !0;
|
|
449
444
|
if (!r) {
|
|
450
|
-
|
|
445
|
+
q(e);
|
|
451
446
|
return;
|
|
452
447
|
}
|
|
453
448
|
if (r.tokens) {
|
|
@@ -495,4 +490,4 @@ var ue = (e = X) => {
|
|
|
495
490
|
};
|
|
496
491
|
};
|
|
497
492
|
//#endregion
|
|
498
|
-
export { e as OidcClient, n as OidcError, r as OidcErrorCode, i as OidcLocation,
|
|
493
|
+
export { e as OidcClient, n as OidcError, r as OidcErrorCode, i as OidcLocation, U as OidcProvider, W 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, O as useOidcFetch, fe as useOidcIdToken, me as useOidcUser, D as withOidcFetch, G as withOidcSecure };
|