@moh-sso/auth 1.3.2 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +188 -447
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useDispatch as
|
|
3
|
-
import { API as
|
|
4
|
-
import { createSlice as
|
|
5
|
-
import { baseApi as
|
|
6
|
-
|
|
1
|
+
import { useEffect as S, useMemo as C, createContext as D, useState as j, useRef as G, useCallback as O, useContext as V } from "react";
|
|
2
|
+
import { useDispatch as H, useSelector as v } from "react-redux";
|
|
3
|
+
import { API as p } from "@moh-sso/config";
|
|
4
|
+
import { createSlice as z, createSelector as i } from "@reduxjs/toolkit";
|
|
5
|
+
import { baseApi as f } from "@moh-sso/api";
|
|
6
|
+
import { jsx as N } from "react/jsx-runtime";
|
|
7
|
+
const K = {
|
|
7
8
|
accessToken: null,
|
|
8
9
|
user: null,
|
|
9
10
|
loading: !0,
|
|
10
11
|
loaded: !1,
|
|
11
12
|
isAuthenticated: !1
|
|
12
|
-
},
|
|
13
|
+
}, E = z({
|
|
13
14
|
name: "auth",
|
|
14
|
-
initialState:
|
|
15
|
+
initialState: K,
|
|
15
16
|
reducers: {
|
|
16
17
|
/* ---------------------------
|
|
17
18
|
* Bootstrap finished
|
|
@@ -25,8 +26,8 @@ const xe = {
|
|
|
25
26
|
* Access token is optional because backend stores it
|
|
26
27
|
* in an HttpOnly cookie.
|
|
27
28
|
* --------------------------- */
|
|
28
|
-
loginSuccess(e,
|
|
29
|
-
e.user =
|
|
29
|
+
loginSuccess(e, t) {
|
|
30
|
+
e.user = t.payload.user, e.accessToken = t.payload.accessToken ?? null, e.isAuthenticated = !0, e.loading = !1, e.loaded = !0;
|
|
30
31
|
},
|
|
31
32
|
/* ---------------------------
|
|
32
33
|
* Token refresh only
|
|
@@ -34,8 +35,8 @@ const xe = {
|
|
|
34
35
|
* Kept for backward compatibility.
|
|
35
36
|
* Prefer not using this with HttpOnly cookies.
|
|
36
37
|
* --------------------------- */
|
|
37
|
-
setAccessToken(e,
|
|
38
|
-
e.accessToken =
|
|
38
|
+
setAccessToken(e, t) {
|
|
39
|
+
e.accessToken = t.payload;
|
|
39
40
|
},
|
|
40
41
|
/* ---------------------------
|
|
41
42
|
* Logout
|
|
@@ -44,31 +45,31 @@ const xe = {
|
|
|
44
45
|
e.accessToken = null, e.user = null, e.loading = !1, e.loaded = !0, e.isAuthenticated = !1;
|
|
45
46
|
}
|
|
46
47
|
}
|
|
47
|
-
}), { loginSuccess:
|
|
48
|
+
}), { loginSuccess: X, logout: U, setAccessToken: ye, authLoaded: W } = E.actions, ge = E.reducer, M = f.injectEndpoints({
|
|
48
49
|
endpoints: (e) => ({
|
|
49
50
|
/* -----------------------------
|
|
50
51
|
* Get current user
|
|
51
52
|
* ----------------------------- */
|
|
52
53
|
me: e.query({
|
|
53
54
|
query: () => ({
|
|
54
|
-
url:
|
|
55
|
+
url: p.auth.me(),
|
|
55
56
|
method: "GET",
|
|
56
57
|
credentials: "include"
|
|
57
58
|
}),
|
|
58
|
-
transformResponse: (
|
|
59
|
-
async onQueryStarted(
|
|
59
|
+
transformResponse: (t) => t.data.user,
|
|
60
|
+
async onQueryStarted(t, { dispatch: n, queryFulfilled: s }) {
|
|
60
61
|
try {
|
|
61
|
-
const { data: o } = await
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
const { data: o } = await s;
|
|
63
|
+
n(
|
|
64
|
+
X({
|
|
64
65
|
accessToken: null,
|
|
65
66
|
user: o
|
|
66
67
|
})
|
|
67
68
|
);
|
|
68
69
|
} catch {
|
|
69
|
-
|
|
70
|
+
n(U());
|
|
70
71
|
} finally {
|
|
71
|
-
|
|
72
|
+
n(W());
|
|
72
73
|
}
|
|
73
74
|
}
|
|
74
75
|
}),
|
|
@@ -76,13 +77,13 @@ const xe = {
|
|
|
76
77
|
* Update profile
|
|
77
78
|
* ----------------------------- */
|
|
78
79
|
updateProfile: e.mutation({
|
|
79
|
-
query: (
|
|
80
|
-
url:
|
|
80
|
+
query: (t) => ({
|
|
81
|
+
url: p.auth.me(),
|
|
81
82
|
method: "PUT",
|
|
82
|
-
body:
|
|
83
|
+
body: t,
|
|
83
84
|
credentials: "include"
|
|
84
85
|
}),
|
|
85
|
-
transformResponse: (
|
|
86
|
+
transformResponse: (t) => t.data.user
|
|
86
87
|
}),
|
|
87
88
|
/* -----------------------------
|
|
88
89
|
* Refresh session
|
|
@@ -93,53 +94,53 @@ const xe = {
|
|
|
93
94
|
* ----------------------------- */
|
|
94
95
|
refresh: e.mutation({
|
|
95
96
|
query: () => ({
|
|
96
|
-
url:
|
|
97
|
+
url: p.auth.refresh(),
|
|
97
98
|
method: "POST",
|
|
98
99
|
credentials: "include"
|
|
99
100
|
})
|
|
100
101
|
})
|
|
101
102
|
})
|
|
102
|
-
}), { useMeQuery:
|
|
103
|
-
let
|
|
104
|
-
function
|
|
105
|
-
const e =
|
|
106
|
-
return
|
|
107
|
-
|
|
108
|
-
|
|
103
|
+
}), { useMeQuery: Se, useUpdateProfileMutation: Re, useRefreshMutation: Ce } = M;
|
|
104
|
+
let b = !1;
|
|
105
|
+
function ve() {
|
|
106
|
+
const e = H();
|
|
107
|
+
return S(() => {
|
|
108
|
+
b || (b = !0, e(
|
|
109
|
+
M.endpoints.me.initiate(void 0, {
|
|
109
110
|
forceRefetch: !0
|
|
110
111
|
})
|
|
111
112
|
).unwrap().catch(() => {
|
|
112
|
-
e(
|
|
113
|
+
e(U());
|
|
113
114
|
}).finally(() => {
|
|
114
|
-
e(
|
|
115
|
+
e(W());
|
|
115
116
|
}));
|
|
116
117
|
}, [e]), null;
|
|
117
118
|
}
|
|
118
|
-
const
|
|
119
|
+
const Y = f.injectEndpoints({
|
|
119
120
|
endpoints: (e) => ({
|
|
120
121
|
myHealthContexts: e.query({
|
|
121
122
|
query: () => ({
|
|
122
|
-
url:
|
|
123
|
+
url: p.healthContexts.mine(),
|
|
123
124
|
credentials: "include"
|
|
124
125
|
}),
|
|
125
|
-
transformResponse: (
|
|
126
|
+
transformResponse: (t) => t.data.healthContexts ?? [],
|
|
126
127
|
providesTags: ["HealthContext"]
|
|
127
128
|
}),
|
|
128
129
|
selectHealthContext: e.mutation({
|
|
129
|
-
query: (
|
|
130
|
-
url:
|
|
130
|
+
query: (t) => ({
|
|
131
|
+
url: p.healthContexts.select(),
|
|
131
132
|
method: "POST",
|
|
132
133
|
credentials: "include",
|
|
133
|
-
body: { contextId:
|
|
134
|
+
body: { contextId: t }
|
|
134
135
|
}),
|
|
135
|
-
transformResponse: (
|
|
136
|
+
transformResponse: (t) => t.data,
|
|
136
137
|
invalidatesTags: ["HealthContext"]
|
|
137
138
|
})
|
|
138
139
|
})
|
|
139
|
-
}), { useMyHealthContextsQuery:
|
|
140
|
-
|
|
141
|
-
(
|
|
142
|
-
),
|
|
140
|
+
}), { useMyHealthContextsQuery: F, useSelectHealthContextMutation: J } = Y, y = (e) => e.auth, Ae = i(y, (e) => e.accessToken), g = i(y, (e) => e.user), Z = i(y, (e) => e.isAuthenticated), xe = i(g, (e) => e?.isAdmin === !0), ke = i(g, (e) => e?.isUser === !0), I = i(g, (e) => e?.permissions ?? []), ee = i(g, (e) => e?.systems ?? []), Te = (e) => i(I, (t) => t.includes(e)), Le = (e) => i(
|
|
141
|
+
I,
|
|
142
|
+
(t) => e.some((n) => t.includes(n))
|
|
143
|
+
), _e = (e) => i(ee, (t) => t.includes(e)), be = i(y, (e) => e.loading), te = i(y, (e) => e.loaded), se = {
|
|
143
144
|
portalAccess: "portal:access",
|
|
144
145
|
systemsRead: "systems:read",
|
|
145
146
|
systemsLaunch: "systems:launch",
|
|
@@ -197,460 +198,200 @@ const Pe = A.injectEndpoints({
|
|
|
197
198
|
issueTrackerReopen: "issue_tracker:reopen",
|
|
198
199
|
issueTrackerComment: "issue_tracker:comment"
|
|
199
200
|
};
|
|
200
|
-
function
|
|
201
|
+
function w(e) {
|
|
201
202
|
return e.trim().toLowerCase();
|
|
202
203
|
}
|
|
203
|
-
function
|
|
204
|
-
return e?.permissions?.includes(
|
|
204
|
+
function R(e, t) {
|
|
205
|
+
return e?.permissions?.includes(t) ?? !1;
|
|
205
206
|
}
|
|
206
|
-
function
|
|
207
|
-
return
|
|
207
|
+
function ne(e, t) {
|
|
208
|
+
return t.some((n) => R(e, n));
|
|
208
209
|
}
|
|
209
|
-
function
|
|
210
|
-
return
|
|
210
|
+
function re(e, t) {
|
|
211
|
+
return t.every((n) => R(e, n));
|
|
211
212
|
}
|
|
212
|
-
function
|
|
213
|
-
const
|
|
214
|
-
return e?.systems?.some((
|
|
213
|
+
function q(e, t) {
|
|
214
|
+
const n = w(t);
|
|
215
|
+
return e?.systems?.some((s) => w(s) === n) || e?.accessibleSystems?.some((s) => w(s.clientId) === n) || !1;
|
|
215
216
|
}
|
|
216
|
-
function
|
|
217
|
-
const
|
|
218
|
-
return (e?.clientRoles?.[
|
|
219
|
-
(o) =>
|
|
217
|
+
function oe(e, t, n) {
|
|
218
|
+
const s = w(n);
|
|
219
|
+
return (e?.clientRoles?.[t] ?? []).some(
|
|
220
|
+
(o) => w(o) === s
|
|
220
221
|
);
|
|
221
222
|
}
|
|
222
|
-
function
|
|
223
|
-
return
|
|
223
|
+
function ae(e, t) {
|
|
224
|
+
return R(e, se.systemsLaunch) && q(e, t);
|
|
224
225
|
}
|
|
225
|
-
function
|
|
226
|
+
function ie(e) {
|
|
226
227
|
return e?.accessibleSystems ?? [];
|
|
227
228
|
}
|
|
228
|
-
function
|
|
229
|
-
const e =
|
|
230
|
-
return
|
|
231
|
-
const
|
|
229
|
+
function ce() {
|
|
230
|
+
const e = v(g);
|
|
231
|
+
return C(() => {
|
|
232
|
+
const t = new Set((e?.realmRoles ?? []).map((s) => s.toLowerCase())), n = e?.clientRoles ?? {};
|
|
232
233
|
return {
|
|
233
|
-
can: (
|
|
234
|
-
canAny: (
|
|
235
|
-
canAll: (
|
|
236
|
-
hasRealmRole: (
|
|
237
|
-
hasClientRole: (
|
|
238
|
-
(
|
|
234
|
+
can: (s) => R(e, s),
|
|
235
|
+
canAny: (s) => ne(e, s),
|
|
236
|
+
canAll: (s) => re(e, s),
|
|
237
|
+
hasRealmRole: (s) => t.has(s.trim().toLowerCase()),
|
|
238
|
+
hasClientRole: (s, o) => (n[s] ?? []).some(
|
|
239
|
+
(c) => c.trim().toLowerCase() === o.trim().toLowerCase()
|
|
239
240
|
),
|
|
240
|
-
hasSystem: (
|
|
241
|
-
hasSystemRole: (
|
|
242
|
-
canLaunchSystem: (
|
|
241
|
+
hasSystem: (s) => q(e, s),
|
|
242
|
+
hasSystemRole: (s, o) => oe(e, s, o),
|
|
243
|
+
canLaunchSystem: (s) => ae(e, s),
|
|
243
244
|
permissions: e?.permissions ?? [],
|
|
244
245
|
systems: e?.systems ?? [],
|
|
245
|
-
accessibleSystems:
|
|
246
|
+
accessibleSystems: ie(e)
|
|
246
247
|
};
|
|
247
248
|
}, [e]);
|
|
248
249
|
}
|
|
249
|
-
function
|
|
250
|
+
function Pe({
|
|
250
251
|
permission: e,
|
|
251
|
-
anyOf:
|
|
252
|
-
fallback:
|
|
253
|
-
children:
|
|
252
|
+
anyOf: t,
|
|
253
|
+
fallback: n = null,
|
|
254
|
+
children: s
|
|
254
255
|
}) {
|
|
255
|
-
const { can: o, canAny:
|
|
256
|
-
return (e ? o(e) : !0) && (
|
|
256
|
+
const { can: o, canAny: c } = ce();
|
|
257
|
+
return (e ? o(e) : !0) && (t && t.length > 0 ? c(t) : !0) ? s : n;
|
|
257
258
|
}
|
|
258
|
-
function
|
|
259
|
+
function le() {
|
|
259
260
|
return typeof window > "u" ? "/portal" : `${window.location.pathname}${window.location.search}${window.location.hash}`;
|
|
260
261
|
}
|
|
261
|
-
function
|
|
262
|
-
const
|
|
262
|
+
function He(e, t = le()) {
|
|
263
|
+
const n = new URL(
|
|
263
264
|
e,
|
|
264
265
|
typeof window > "u" ? "http://localhost" : window.location.origin
|
|
265
266
|
);
|
|
266
|
-
return
|
|
267
|
+
return n.searchParams.set("returnTo", t), n.toString();
|
|
267
268
|
}
|
|
268
|
-
function
|
|
269
|
+
function ue(e) {
|
|
269
270
|
try {
|
|
270
|
-
const
|
|
271
|
-
return ["http:", "https:"].includes(
|
|
271
|
+
const t = new URL(e);
|
|
272
|
+
return ["http:", "https:"].includes(t.protocol) && !t.username && !t.password;
|
|
272
273
|
} catch {
|
|
273
274
|
return !1;
|
|
274
275
|
}
|
|
275
276
|
}
|
|
276
|
-
function
|
|
277
|
-
const
|
|
278
|
-
return !
|
|
277
|
+
function P(e, t) {
|
|
278
|
+
const n = t.trim().replace(/\/$/, "");
|
|
279
|
+
return !n || ue(e) ? e : `${n}${e.startsWith("/") ? e : `/${e}`}`;
|
|
279
280
|
}
|
|
280
|
-
function
|
|
281
|
-
const
|
|
282
|
-
return !
|
|
281
|
+
function Ee(e, t) {
|
|
282
|
+
const n = e.launchUrl?.trim() ?? "", s = e.authenticatedLaunchUrl?.trim() ?? "";
|
|
283
|
+
return !t.hasPortalSession && s ? P(s, t.apiBaseUrl) : n || P(s, t.apiBaseUrl);
|
|
283
284
|
}
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
} else i = o;
|
|
297
|
-
return o = i.ref, {
|
|
298
|
-
$$typeof: e,
|
|
299
|
-
type: n,
|
|
300
|
-
key: f,
|
|
301
|
-
ref: o !== void 0 ? o : null,
|
|
302
|
-
props: i
|
|
303
|
-
};
|
|
304
|
-
}
|
|
305
|
-
return S.Fragment = r, S.jsx = a, S.jsxs = a, S;
|
|
306
|
-
}
|
|
307
|
-
var b = {};
|
|
308
|
-
var te;
|
|
309
|
-
function ze() {
|
|
310
|
-
return te || (te = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
311
|
-
function e(t) {
|
|
312
|
-
if (t == null) return null;
|
|
313
|
-
if (typeof t == "function")
|
|
314
|
-
return t.$$typeof === _e ? null : t.displayName || t.name || null;
|
|
315
|
-
if (typeof t == "string") return t;
|
|
316
|
-
switch (t) {
|
|
317
|
-
case R:
|
|
318
|
-
return "Fragment";
|
|
319
|
-
case W:
|
|
320
|
-
return "Profiler";
|
|
321
|
-
case w:
|
|
322
|
-
return "StrictMode";
|
|
323
|
-
case he:
|
|
324
|
-
return "Suspense";
|
|
325
|
-
case pe:
|
|
326
|
-
return "SuspenseList";
|
|
327
|
-
case we:
|
|
328
|
-
return "Activity";
|
|
329
|
-
}
|
|
330
|
-
if (typeof t == "object")
|
|
331
|
-
switch (typeof t.tag == "number" && console.error(
|
|
332
|
-
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
333
|
-
), t.$$typeof) {
|
|
334
|
-
case l:
|
|
335
|
-
return "Portal";
|
|
336
|
-
case me:
|
|
337
|
-
return t.displayName || "Context";
|
|
338
|
-
case de:
|
|
339
|
-
return (t._context.displayName || "Context") + ".Consumer";
|
|
340
|
-
case fe:
|
|
341
|
-
var s = t.render;
|
|
342
|
-
return t = t.displayName, t || (t = s.displayName || s.name || "", t = t !== "" ? "ForwardRef(" + t + ")" : "ForwardRef"), t;
|
|
343
|
-
case Re:
|
|
344
|
-
return s = t.displayName || null, s !== null ? s : e(t.type) || "Memo";
|
|
345
|
-
case H:
|
|
346
|
-
s = t._payload, t = t._init;
|
|
347
|
-
try {
|
|
348
|
-
return e(t(s));
|
|
349
|
-
} catch {
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
return null;
|
|
353
|
-
}
|
|
354
|
-
function r(t) {
|
|
355
|
-
return "" + t;
|
|
356
|
-
}
|
|
357
|
-
function a(t) {
|
|
358
|
-
try {
|
|
359
|
-
r(t);
|
|
360
|
-
var s = !1;
|
|
361
|
-
} catch {
|
|
362
|
-
s = !0;
|
|
363
|
-
}
|
|
364
|
-
if (s) {
|
|
365
|
-
s = console;
|
|
366
|
-
var c = s.error, d = typeof Symbol == "function" && Symbol.toStringTag && t[Symbol.toStringTag] || t.constructor.name || "Object";
|
|
367
|
-
return c.call(
|
|
368
|
-
s,
|
|
369
|
-
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
370
|
-
d
|
|
371
|
-
), r(t);
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
function n(t) {
|
|
375
|
-
if (t === R) return "<>";
|
|
376
|
-
if (typeof t == "object" && t !== null && t.$$typeof === H)
|
|
377
|
-
return "<...>";
|
|
378
|
-
try {
|
|
379
|
-
var s = e(t);
|
|
380
|
-
return s ? "<" + s + ">" : "<...>";
|
|
381
|
-
} catch {
|
|
382
|
-
return "<...>";
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
function o() {
|
|
386
|
-
var t = M.A;
|
|
387
|
-
return t === null ? null : t.getOwner();
|
|
388
|
-
}
|
|
389
|
-
function i() {
|
|
390
|
-
return Error("react-stack-top-frame");
|
|
391
|
-
}
|
|
392
|
-
function f(t) {
|
|
393
|
-
if (z.call(t, "key")) {
|
|
394
|
-
var s = Object.getOwnPropertyDescriptor(t, "key").get;
|
|
395
|
-
if (s && s.isReactWarning) return !1;
|
|
396
|
-
}
|
|
397
|
-
return t.key !== void 0;
|
|
398
|
-
}
|
|
399
|
-
function u(t, s) {
|
|
400
|
-
function c() {
|
|
401
|
-
B || (B = !0, console.error(
|
|
402
|
-
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
403
|
-
s
|
|
404
|
-
));
|
|
405
|
-
}
|
|
406
|
-
c.isReactWarning = !0, Object.defineProperty(t, "key", {
|
|
407
|
-
get: c,
|
|
408
|
-
configurable: !0
|
|
409
|
-
});
|
|
410
|
-
}
|
|
411
|
-
function P() {
|
|
412
|
-
var t = e(this.type);
|
|
413
|
-
return G[t] || (G[t] = !0, console.error(
|
|
414
|
-
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
415
|
-
)), t = this.props.ref, t !== void 0 ? t : null;
|
|
416
|
-
}
|
|
417
|
-
function O(t, s, c, d, j, Y) {
|
|
418
|
-
var m = c.ref;
|
|
419
|
-
return t = {
|
|
420
|
-
$$typeof: L,
|
|
421
|
-
type: t,
|
|
422
|
-
key: s,
|
|
423
|
-
props: c,
|
|
424
|
-
_owner: d
|
|
425
|
-
}, (m !== void 0 ? m : null) !== null ? Object.defineProperty(t, "ref", {
|
|
426
|
-
enumerable: !1,
|
|
427
|
-
get: P
|
|
428
|
-
}) : Object.defineProperty(t, "ref", { enumerable: !1, value: null }), t._store = {}, Object.defineProperty(t._store, "validated", {
|
|
429
|
-
configurable: !1,
|
|
430
|
-
enumerable: !1,
|
|
431
|
-
writable: !0,
|
|
432
|
-
value: 0
|
|
433
|
-
}), Object.defineProperty(t, "_debugInfo", {
|
|
434
|
-
configurable: !1,
|
|
435
|
-
enumerable: !1,
|
|
436
|
-
writable: !0,
|
|
437
|
-
value: null
|
|
438
|
-
}), Object.defineProperty(t, "_debugStack", {
|
|
439
|
-
configurable: !1,
|
|
440
|
-
enumerable: !1,
|
|
441
|
-
writable: !0,
|
|
442
|
-
value: j
|
|
443
|
-
}), Object.defineProperty(t, "_debugTask", {
|
|
444
|
-
configurable: !1,
|
|
445
|
-
enumerable: !1,
|
|
446
|
-
writable: !0,
|
|
447
|
-
value: Y
|
|
448
|
-
}), Object.freeze && (Object.freeze(t.props), Object.freeze(t)), t;
|
|
449
|
-
}
|
|
450
|
-
function E(t, s, c, d, j, Y) {
|
|
451
|
-
var m = s.children;
|
|
452
|
-
if (m !== void 0)
|
|
453
|
-
if (d)
|
|
454
|
-
if (ve(m)) {
|
|
455
|
-
for (d = 0; d < m.length; d++)
|
|
456
|
-
T(m[d]);
|
|
457
|
-
Object.freeze && Object.freeze(m);
|
|
458
|
-
} else
|
|
459
|
-
console.error(
|
|
460
|
-
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
461
|
-
);
|
|
462
|
-
else T(m);
|
|
463
|
-
if (z.call(s, "key")) {
|
|
464
|
-
m = e(t);
|
|
465
|
-
var v = Object.keys(s).filter(function(ye) {
|
|
466
|
-
return ye !== "key";
|
|
467
|
-
});
|
|
468
|
-
d = 0 < v.length ? "{key: someKey, " + v.join(": ..., ") + ": ...}" : "{key: someKey}", X[m + d] || (v = 0 < v.length ? "{" + v.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
469
|
-
`A props object containing a "key" prop is being spread into JSX:
|
|
470
|
-
let props = %s;
|
|
471
|
-
<%s {...props} />
|
|
472
|
-
React keys must be passed directly to JSX without using spread:
|
|
473
|
-
let props = %s;
|
|
474
|
-
<%s key={someKey} {...props} />`,
|
|
475
|
-
d,
|
|
476
|
-
m,
|
|
477
|
-
v,
|
|
478
|
-
m
|
|
479
|
-
), X[m + d] = !0);
|
|
480
|
-
}
|
|
481
|
-
if (m = null, c !== void 0 && (a(c), m = "" + c), f(s) && (a(s.key), m = "" + s.key), "key" in s) {
|
|
482
|
-
c = {};
|
|
483
|
-
for (var q in s)
|
|
484
|
-
q !== "key" && (c[q] = s[q]);
|
|
485
|
-
} else c = s;
|
|
486
|
-
return m && u(
|
|
487
|
-
c,
|
|
488
|
-
typeof t == "function" ? t.displayName || t.name || "Unknown" : t
|
|
489
|
-
), O(
|
|
490
|
-
t,
|
|
491
|
-
m,
|
|
492
|
-
c,
|
|
493
|
-
o(),
|
|
494
|
-
j,
|
|
495
|
-
Y
|
|
496
|
-
);
|
|
497
|
-
}
|
|
498
|
-
function T(t) {
|
|
499
|
-
h(t) ? t._store && (t._store.validated = 1) : typeof t == "object" && t !== null && t.$$typeof === H && (t._payload.status === "fulfilled" ? h(t._payload.value) && t._payload.value._store && (t._payload.value._store.validated = 1) : t._store && (t._store.validated = 1));
|
|
500
|
-
}
|
|
501
|
-
function h(t) {
|
|
502
|
-
return typeof t == "object" && t !== null && t.$$typeof === L;
|
|
503
|
-
}
|
|
504
|
-
var _ = Ee, L = /* @__PURE__ */ Symbol.for("react.transitional.element"), l = /* @__PURE__ */ Symbol.for("react.portal"), R = /* @__PURE__ */ Symbol.for("react.fragment"), w = /* @__PURE__ */ Symbol.for("react.strict_mode"), W = /* @__PURE__ */ Symbol.for("react.profiler"), de = /* @__PURE__ */ Symbol.for("react.consumer"), me = /* @__PURE__ */ Symbol.for("react.context"), fe = /* @__PURE__ */ Symbol.for("react.forward_ref"), he = /* @__PURE__ */ Symbol.for("react.suspense"), pe = /* @__PURE__ */ Symbol.for("react.suspense_list"), Re = /* @__PURE__ */ Symbol.for("react.memo"), H = /* @__PURE__ */ Symbol.for("react.lazy"), we = /* @__PURE__ */ Symbol.for("react.activity"), _e = /* @__PURE__ */ Symbol.for("react.client.reference"), M = _.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, z = Object.prototype.hasOwnProperty, ve = Array.isArray, $ = console.createTask ? console.createTask : function() {
|
|
505
|
-
return null;
|
|
506
|
-
};
|
|
507
|
-
_ = {
|
|
508
|
-
react_stack_bottom_frame: function(t) {
|
|
509
|
-
return t();
|
|
510
|
-
}
|
|
511
|
-
};
|
|
512
|
-
var B, G = {}, J = _.react_stack_bottom_frame.bind(
|
|
513
|
-
_,
|
|
514
|
-
i
|
|
515
|
-
)(), Q = $(n(i)), X = {};
|
|
516
|
-
b.Fragment = R, b.jsx = function(t, s, c) {
|
|
517
|
-
var d = 1e4 > M.recentlyCreatedOwnerStacks++;
|
|
518
|
-
return E(
|
|
519
|
-
t,
|
|
520
|
-
s,
|
|
521
|
-
c,
|
|
522
|
-
!1,
|
|
523
|
-
d ? Error("react-stack-top-frame") : J,
|
|
524
|
-
d ? $(n(t)) : Q
|
|
525
|
-
);
|
|
526
|
-
}, b.jsxs = function(t, s, c) {
|
|
527
|
-
var d = 1e4 > M.recentlyCreatedOwnerStacks++;
|
|
528
|
-
return E(
|
|
529
|
-
t,
|
|
530
|
-
s,
|
|
531
|
-
c,
|
|
532
|
-
!0,
|
|
533
|
-
d ? Error("react-stack-top-frame") : J,
|
|
534
|
-
d ? $(n(t)) : Q
|
|
535
|
-
);
|
|
536
|
-
};
|
|
537
|
-
})()), b;
|
|
538
|
-
}
|
|
539
|
-
var re;
|
|
540
|
-
function Be() {
|
|
541
|
-
return re || (re = 1, process.env.NODE_ENV === "production" ? N.exports = Ve() : N.exports = ze()), N.exports;
|
|
542
|
-
}
|
|
543
|
-
var Ge = Be();
|
|
544
|
-
const y = "moh.activeHealthContextId", le = Te(void 0);
|
|
545
|
-
function Rt({ children: e }) {
|
|
546
|
-
const r = ne(), a = F(je), n = F(Ue), [o, i] = Se(
|
|
547
|
-
() => typeof window > "u" ? null : window.localStorage.getItem(y)
|
|
548
|
-
), f = be(o), {
|
|
549
|
-
data: u = [],
|
|
550
|
-
isLoading: P,
|
|
551
|
-
isSuccess: O
|
|
552
|
-
} = Oe(void 0, {
|
|
553
|
-
skip: !a
|
|
554
|
-
}), [E, { isLoading: T }] = Le(), h = D(() => u.find((l) => l.id === o) ?? u.find((l) => l.isActive) ?? u.find((l) => l.isDefault) ?? u[0], [u, o]);
|
|
555
|
-
U(() => {
|
|
285
|
+
const h = "moh.activeHealthContextId", B = D(void 0);
|
|
286
|
+
function Ue({ children: e }) {
|
|
287
|
+
const t = H(), n = v(Z), s = v(te), [o, c] = j(
|
|
288
|
+
() => typeof window > "u" ? null : window.localStorage.getItem(h)
|
|
289
|
+
), u = G(o), {
|
|
290
|
+
data: a = [],
|
|
291
|
+
isLoading: x,
|
|
292
|
+
isSuccess: k
|
|
293
|
+
} = F(void 0, {
|
|
294
|
+
skip: !n
|
|
295
|
+
}), [T, { isLoading: L }] = J(), l = C(() => a.find((r) => r.id === o) ?? a.find((r) => r.isActive) ?? a.find((r) => r.isDefault) ?? a[0], [a, o]);
|
|
296
|
+
S(() => {
|
|
556
297
|
if (!(typeof window > "u")) {
|
|
557
|
-
if (
|
|
558
|
-
window.localStorage.removeItem(
|
|
298
|
+
if (s && !n) {
|
|
299
|
+
window.localStorage.removeItem(h), u.current = null, c(null);
|
|
559
300
|
return;
|
|
560
301
|
}
|
|
561
|
-
if (
|
|
562
|
-
window.localStorage.removeItem(
|
|
302
|
+
if (n && k && a.length === 0) {
|
|
303
|
+
window.localStorage.removeItem(h), u.current = null, c(null);
|
|
563
304
|
return;
|
|
564
305
|
}
|
|
565
|
-
|
|
566
|
-
new CustomEvent("moh:health-context-changed", { detail:
|
|
306
|
+
l && (u.current = l.id, window.localStorage.setItem(h, l.id), o !== l.id && c(l.id), window.dispatchEvent(
|
|
307
|
+
new CustomEvent("moh:health-context-changed", { detail: l })
|
|
567
308
|
));
|
|
568
309
|
}
|
|
569
|
-
}, [
|
|
570
|
-
const
|
|
571
|
-
|
|
310
|
+
}, [l, n, s, a.length, k, o]), S(() => {
|
|
311
|
+
const r = (d) => {
|
|
312
|
+
d.key === h && (u.current = d.newValue, c(d.newValue), t(f.util.resetApiState()));
|
|
572
313
|
};
|
|
573
|
-
return window.addEventListener("storage",
|
|
574
|
-
}, [
|
|
575
|
-
const
|
|
576
|
-
const
|
|
577
|
-
!
|
|
314
|
+
return window.addEventListener("storage", r), () => window.removeEventListener("storage", r);
|
|
315
|
+
}, [t]), S(() => {
|
|
316
|
+
const r = (d) => {
|
|
317
|
+
const m = d.detail;
|
|
318
|
+
!m?.id || !a.some((Q) => Q.id === m.id) || u.current !== m.id && (u.current = m.id, c(m.id), t(f.util.resetApiState()));
|
|
578
319
|
};
|
|
579
|
-
return window.addEventListener("moh:health-context-changed",
|
|
580
|
-
}, [
|
|
581
|
-
const _ =
|
|
582
|
-
async (
|
|
583
|
-
await
|
|
584
|
-
const
|
|
585
|
-
window.dispatchEvent(new CustomEvent("moh:health-context-changed", { detail:
|
|
320
|
+
return window.addEventListener("moh:health-context-changed", r), () => window.removeEventListener("moh:health-context-changed", r);
|
|
321
|
+
}, [a, t]);
|
|
322
|
+
const _ = O(
|
|
323
|
+
async (r) => {
|
|
324
|
+
await T(r).unwrap(), u.current = r, window.localStorage.setItem(h, r), c(r), t(f.util.resetApiState());
|
|
325
|
+
const d = a.find((m) => m.id === r);
|
|
326
|
+
window.dispatchEvent(new CustomEvent("moh:health-context-changed", { detail: d }));
|
|
586
327
|
},
|
|
587
|
-
[
|
|
588
|
-
),
|
|
589
|
-
() => ({ contexts:
|
|
590
|
-
[
|
|
328
|
+
[a, t, T]
|
|
329
|
+
), $ = C(
|
|
330
|
+
() => ({ contexts: a, activeContext: l, isLoading: x, isUpdating: L, selectContext: _ }),
|
|
331
|
+
[l, a, x, L, _]
|
|
591
332
|
);
|
|
592
|
-
return /* @__PURE__ */
|
|
333
|
+
return /* @__PURE__ */ N(B.Provider, { value: $, children: e });
|
|
593
334
|
}
|
|
594
|
-
function
|
|
595
|
-
const e =
|
|
335
|
+
function A() {
|
|
336
|
+
const e = V(B);
|
|
596
337
|
if (!e)
|
|
597
338
|
throw new Error("useHealthContext must be used inside HealthContextProvider");
|
|
598
339
|
return e;
|
|
599
340
|
}
|
|
600
|
-
function
|
|
601
|
-
return
|
|
341
|
+
function We() {
|
|
342
|
+
return A().contexts;
|
|
602
343
|
}
|
|
603
|
-
function
|
|
604
|
-
return
|
|
344
|
+
function Me() {
|
|
345
|
+
return A().activeContext;
|
|
605
346
|
}
|
|
606
|
-
function
|
|
607
|
-
const e =
|
|
347
|
+
function Ie() {
|
|
348
|
+
const e = A();
|
|
608
349
|
return { ...e, hasContext: !!e.activeContext };
|
|
609
350
|
}
|
|
610
351
|
export {
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
352
|
+
h as ACTIVE_HEALTH_CONTEXT_STORAGE_KEY,
|
|
353
|
+
ve as AuthBootstrap,
|
|
354
|
+
Ue as HealthContextProvider,
|
|
355
|
+
se as PERMISSIONS,
|
|
356
|
+
Pe as PermissionGuard,
|
|
357
|
+
M as authApi,
|
|
358
|
+
W as authLoaded,
|
|
359
|
+
ge as authReducer,
|
|
360
|
+
He as buildLoginURL,
|
|
361
|
+
ae as canLaunchSystem,
|
|
362
|
+
le as currentPortalReturnTo,
|
|
363
|
+
ie as getAccessibleSystems,
|
|
364
|
+
re as hasAllPermissions,
|
|
365
|
+
ne as hasAnyPermission,
|
|
366
|
+
R as hasPermission,
|
|
367
|
+
q as hasSystem,
|
|
368
|
+
oe as hasSystemRole,
|
|
369
|
+
Y as healthContextApi,
|
|
370
|
+
X as loginSuccess,
|
|
371
|
+
U as logout,
|
|
372
|
+
Ee as resolveSystemLaunchUrl,
|
|
373
|
+
Ae as selectAccessToken,
|
|
374
|
+
y as selectAuth,
|
|
375
|
+
te as selectAuthLoaded,
|
|
376
|
+
be as selectAuthLoading,
|
|
377
|
+
Z as selectAuthenticated,
|
|
378
|
+
Le as selectHasAnyPermission,
|
|
379
|
+
Te as selectHasPermission,
|
|
380
|
+
_e as selectHasSystem,
|
|
381
|
+
xe as selectIsAdmin,
|
|
382
|
+
ke as selectIsUser,
|
|
383
|
+
I as selectPermissions,
|
|
384
|
+
ee as selectSystems,
|
|
385
|
+
g as selectUser,
|
|
386
|
+
ye as setAccessToken,
|
|
387
|
+
Me as useActiveHealthContext,
|
|
388
|
+
ce as useAuthorization,
|
|
389
|
+
We as useAvailableHealthContexts,
|
|
390
|
+
A as useHealthContext,
|
|
391
|
+
Se as useMeQuery,
|
|
392
|
+
F as useMyHealthContextsQuery,
|
|
393
|
+
Ce as useRefreshMutation,
|
|
394
|
+
Ie as useRequireHealthContext,
|
|
395
|
+
J as useSelectHealthContextMutation,
|
|
396
|
+
Re as useUpdateProfileMutation
|
|
656
397
|
};
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"type": "module",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
|
-
"version": "1.
|
|
6
|
+
"version": "1.4.1",
|
|
7
7
|
"license": "UNLICENSED",
|
|
8
8
|
"module": "./dist/index.js",
|
|
9
9
|
"files": [
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
"access": "public"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@moh-sso/api": "^1.
|
|
28
|
-
"@moh-sso/state": "^1.
|
|
29
|
-
"@moh-sso/config": "^1.
|
|
27
|
+
"@moh-sso/api": "^1.4.1",
|
|
28
|
+
"@moh-sso/state": "^1.4.1",
|
|
29
|
+
"@moh-sso/config": "^1.4.1"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"@reduxjs/toolkit": "^2.11.2",
|