@moh-sso/auth 0.0.0-stage → 1.3.2

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.
Files changed (88) hide show
  1. package/README.md +21 -2
  2. package/dist/_types/packages/api/src/api/baseApi.d.ts +2 -0
  3. package/dist/_types/packages/api/src/index.d.ts +1 -0
  4. package/dist/_types/packages/auth/src/api/auth.api.d.ts +531 -0
  5. package/dist/_types/packages/auth/src/api/health-context.api.d.ts +374 -0
  6. package/dist/_types/packages/auth/src/auth/AuthBootstrap.d.ts +1 -0
  7. package/dist/_types/packages/auth/src/auth/HealthContextProvider.d.ts +20 -0
  8. package/dist/_types/packages/auth/src/auth/PermissionGuard.d.ts +10 -0
  9. package/dist/_types/packages/auth/src/auth/auth.selectors.d.ts +896 -0
  10. package/dist/_types/packages/auth/src/auth/auth.slice.d.ts +14 -0
  11. package/dist/_types/packages/auth/src/auth/auth.types.d.ts +61 -0
  12. package/dist/_types/packages/auth/src/auth/login-url.d.ts +2 -0
  13. package/dist/_types/packages/auth/src/auth/permissions.d.ts +58 -0
  14. package/dist/_types/packages/auth/src/auth/rbac.d.ts +8 -0
  15. package/dist/_types/packages/auth/src/auth/system-launch-url.d.ts +9 -0
  16. package/dist/_types/packages/auth/src/auth/useAuthorization.d.ts +14 -0
  17. package/dist/_types/packages/auth/src/index.d.ts +14 -0
  18. package/dist/_types/packages/config/src/appMeta.d.ts +3 -0
  19. package/dist/_types/packages/config/src/index.d.ts +6 -0
  20. package/dist/_types/packages/config/src/lib/constants/api.constants.d.ts +178 -0
  21. package/dist/_types/packages/config/src/lib/constants/document-templates.d.ts +11 -0
  22. package/dist/_types/packages/config/src/lib/errors/errorMessages.d.ts +2 -0
  23. package/dist/_types/packages/config/src/lib/errors/errorSeverity.d.ts +3 -0
  24. package/dist/_types/packages/config/src/lib/errors/errorTypes.d.ts +1 -0
  25. package/dist/_types/packages/state/src/clients/clients.selectors.d.ts +534 -0
  26. package/dist/_types/packages/state/src/clients/clients.slice.d.ts +4 -0
  27. package/dist/_types/packages/state/src/document/documents.selectors.d.ts +1 -0
  28. package/dist/_types/packages/state/src/index.d.ts +29 -0
  29. package/dist/_types/packages/state/src/ui/ui.state.d.ts +1 -0
  30. package/dist/_types/packages/types/src/index.d.ts +6 -0
  31. package/dist/_types/packages/types/src/types/announcement-summary.types.d.ts +16 -0
  32. package/dist/_types/packages/types/src/types/client-role.types.d.ts +6 -0
  33. package/dist/_types/packages/types/src/types/client.types.d.ts +46 -0
  34. package/dist/_types/packages/types/src/types/document-processing.types.d.ts +1 -0
  35. package/dist/_types/packages/types/src/types/notifications.types.d.ts +96 -0
  36. package/dist/_types/packages/types/src/types/system-navigation.types.d.ts +18 -0
  37. package/dist/_types/packages/ui/src/accessibility/index.d.ts +1 -0
  38. package/dist/_types/packages/ui/src/accessibility/useFocusTrap.d.ts +10 -0
  39. package/dist/_types/packages/ui/src/branding/BuildMeta.d.ts +6 -0
  40. package/dist/_types/packages/ui/src/branding/PublicFooter.d.ts +6 -0
  41. package/dist/_types/packages/ui/src/branding/index.d.ts +2 -0
  42. package/dist/_types/packages/ui/src/data-display/DataTablePagination.d.ts +12 -0
  43. package/dist/_types/packages/ui/src/data-display/DataTableShell.d.ts +35 -0
  44. package/dist/_types/packages/ui/src/data-display/RowActionsCell.d.ts +7 -0
  45. package/dist/_types/packages/ui/src/data-display/TableEmptyState.d.ts +8 -0
  46. package/dist/_types/packages/ui/src/data-display/TableStatusTag.d.ts +8 -0
  47. package/dist/_types/packages/ui/src/data-display/index.d.ts +5 -0
  48. package/dist/_types/packages/ui/src/feedback/comingsoon/ComingSoon.d.ts +7 -0
  49. package/dist/_types/packages/ui/src/feedback/emptystate/EmptyState.d.ts +15 -0
  50. package/dist/_types/packages/ui/src/feedback/errorstate/ErrorState.d.ts +14 -0
  51. package/dist/_types/packages/ui/src/feedback/errorstate/MicrofrontendErrorBoundary.d.ts +16 -0
  52. package/dist/_types/packages/ui/src/feedback/index.d.ts +5 -0
  53. package/dist/_types/packages/ui/src/feedback/loadingstate/LoadingState.d.ts +5 -0
  54. package/dist/_types/packages/ui/src/forms/CaseFormsGrid.d.ts +1 -0
  55. package/dist/_types/packages/ui/src/forms/index.d.ts +1 -0
  56. package/dist/_types/packages/ui/src/index.d.ts +16 -0
  57. package/dist/_types/packages/ui/src/layout/PageShell/PageShell.d.ts +9 -0
  58. package/dist/_types/packages/ui/src/layout/SectionCard/SectionCard.d.ts +11 -0
  59. package/dist/_types/packages/ui/src/layout/index.d.ts +2 -0
  60. package/dist/_types/packages/ui/src/navigation/appmenu/AppGridContent.d.ts +12 -0
  61. package/dist/_types/packages/ui/src/navigation/appmenu/AppMenu.component.d.ts +6 -0
  62. package/dist/_types/packages/ui/src/navigation/appmenu/AppMenuItem.component.d.ts +13 -0
  63. package/dist/_types/packages/ui/src/navigation/appmenu/appMenuGroups.d.ts +11 -0
  64. package/dist/_types/packages/ui/src/navigation/breadcrumbs/AppBreadcrumbs.d.ts +12 -0
  65. package/dist/_types/packages/ui/src/navigation/breadcrumbs/BreadcrumbBar.d.ts +10 -0
  66. package/dist/_types/packages/ui/src/navigation/index.d.ts +2 -0
  67. package/dist/_types/packages/ui/src/navigation/sidenav/ClientSideNav.d.ts +14 -0
  68. package/dist/_types/packages/ui/src/notifications/FormInlineAlert.d.ts +7 -0
  69. package/dist/_types/packages/ui/src/notifications/NotificationsPanel.d.ts +14 -0
  70. package/dist/_types/packages/ui/src/notifications/index.d.ts +4 -0
  71. package/dist/_types/packages/ui/src/notifications/toast/ToastProvider.d.ts +20 -0
  72. package/dist/_types/packages/ui/src/notifications/toast/useToast.d.ts +20 -0
  73. package/dist/_types/packages/ui/src/overlays/header-panel/ReusableHeaderPanel.d.ts +17 -0
  74. package/dist/_types/packages/ui/src/overlays/header-panel/header-panel.context.d.ts +23 -0
  75. package/dist/_types/packages/ui/src/overlays/index.d.ts +4 -0
  76. package/dist/_types/packages/ui/src/overlays/modal/ReusableModal.d.ts +20 -0
  77. package/dist/_types/packages/ui/src/overlays/modal/modal.context.d.ts +14 -0
  78. package/dist/_types/packages/ui/src/shell/ExternalAppHeader.d.ts +22 -0
  79. package/dist/_types/packages/ui/src/shell/PublicHeader.component.d.ts +8 -0
  80. package/dist/_types/packages/ui/src/shell/UserHeader.component.d.ts +17 -0
  81. package/dist/_types/packages/ui/src/shell/index.d.ts +5 -0
  82. package/dist/_types/packages/ui/src/theme/ThemeProvider.d.ts +8 -0
  83. package/dist/_types/packages/ui/src/theme/index.d.ts +1 -0
  84. package/dist/_types/packages/ui/src/utils/severity.d.ts +22 -0
  85. package/dist/_types/packages/ui/src/utils/status.d.ts +1 -0
  86. package/dist/index.d.ts +1 -0
  87. package/dist/index.js +656 -0
  88. package/package.json +40 -4
package/dist/index.js ADDED
@@ -0,0 +1,656 @@
1
+ import Ee, { useEffect as U, useMemo as D, createContext as Te, useState as Se, useRef as be, useCallback as ge, useContext as Ae } from "react";
2
+ import { useDispatch as ne, useSelector as F } from "react-redux";
3
+ import { API as g } from "@moh-sso/config";
4
+ import { createSlice as ke, createSelector as p } from "@reduxjs/toolkit";
5
+ import { baseApi as A } from "@moh-sso/api";
6
+ const xe = {
7
+ accessToken: null,
8
+ user: null,
9
+ loading: !0,
10
+ loaded: !1,
11
+ isAuthenticated: !1
12
+ }, se = ke({
13
+ name: "auth",
14
+ initialState: xe,
15
+ reducers: {
16
+ /* ---------------------------
17
+ * Bootstrap finished
18
+ * --------------------------- */
19
+ authLoaded(e) {
20
+ e.loading = !1, e.loaded = !0, e.isAuthenticated = !!e.user;
21
+ },
22
+ /* ---------------------------
23
+ * Successful login / refresh
24
+ *
25
+ * Access token is optional because backend stores it
26
+ * in an HttpOnly cookie.
27
+ * --------------------------- */
28
+ loginSuccess(e, r) {
29
+ e.user = r.payload.user, e.accessToken = r.payload.accessToken ?? null, e.isAuthenticated = !0, e.loading = !1, e.loaded = !0;
30
+ },
31
+ /* ---------------------------
32
+ * Token refresh only
33
+ *
34
+ * Kept for backward compatibility.
35
+ * Prefer not using this with HttpOnly cookies.
36
+ * --------------------------- */
37
+ setAccessToken(e, r) {
38
+ e.accessToken = r.payload;
39
+ },
40
+ /* ---------------------------
41
+ * Logout
42
+ * --------------------------- */
43
+ logout(e) {
44
+ e.accessToken = null, e.user = null, e.loading = !1, e.loaded = !0, e.isAuthenticated = !1;
45
+ }
46
+ }
47
+ }), { loginSuccess: Ce, logout: ae, setAccessToken: et, authLoaded: oe } = se.actions, tt = se.reducer, ce = A.injectEndpoints({
48
+ endpoints: (e) => ({
49
+ /* -----------------------------
50
+ * Get current user
51
+ * ----------------------------- */
52
+ me: e.query({
53
+ query: () => ({
54
+ url: g.auth.me(),
55
+ method: "GET",
56
+ credentials: "include"
57
+ }),
58
+ transformResponse: (r) => r.data.user,
59
+ async onQueryStarted(r, { dispatch: a, queryFulfilled: n }) {
60
+ try {
61
+ const { data: o } = await n;
62
+ a(
63
+ Ce({
64
+ accessToken: null,
65
+ user: o
66
+ })
67
+ );
68
+ } catch {
69
+ a(ae());
70
+ } finally {
71
+ a(oe());
72
+ }
73
+ }
74
+ }),
75
+ /* -----------------------------
76
+ * Update profile
77
+ * ----------------------------- */
78
+ updateProfile: e.mutation({
79
+ query: (r) => ({
80
+ url: g.auth.me(),
81
+ method: "PUT",
82
+ body: r,
83
+ credentials: "include"
84
+ }),
85
+ transformResponse: (r) => r.data.user
86
+ }),
87
+ /* -----------------------------
88
+ * Refresh session
89
+ *
90
+ * Backend sets HttpOnly cookies.
91
+ * Do not store access_token in Redux.
92
+ * Do not call /me here.
93
+ * ----------------------------- */
94
+ refresh: e.mutation({
95
+ query: () => ({
96
+ url: g.auth.refresh(),
97
+ method: "POST",
98
+ credentials: "include"
99
+ })
100
+ })
101
+ })
102
+ }), { useMeQuery: rt, useUpdateProfileMutation: nt, useRefreshMutation: st } = ce;
103
+ let Z = !1;
104
+ function at() {
105
+ const e = ne();
106
+ return U(() => {
107
+ Z || (Z = !0, e(
108
+ ce.endpoints.me.initiate(void 0, {
109
+ forceRefetch: !0
110
+ })
111
+ ).unwrap().catch(() => {
112
+ e(ae());
113
+ }).finally(() => {
114
+ e(oe());
115
+ }));
116
+ }, [e]), null;
117
+ }
118
+ const Pe = A.injectEndpoints({
119
+ endpoints: (e) => ({
120
+ myHealthContexts: e.query({
121
+ query: () => ({
122
+ url: g.healthContexts.mine(),
123
+ credentials: "include"
124
+ }),
125
+ transformResponse: (r) => r.data.healthContexts ?? [],
126
+ providesTags: ["HealthContext"]
127
+ }),
128
+ selectHealthContext: e.mutation({
129
+ query: (r) => ({
130
+ url: g.healthContexts.select(),
131
+ method: "POST",
132
+ credentials: "include",
133
+ body: { contextId: r }
134
+ }),
135
+ transformResponse: (r) => r.data,
136
+ invalidatesTags: ["HealthContext"]
137
+ })
138
+ })
139
+ }), { useMyHealthContextsQuery: Oe, useSelectHealthContextMutation: Le } = Pe, x = (e) => e.auth, ot = p(x, (e) => e.accessToken), C = p(x, (e) => e.user), je = p(x, (e) => e.isAuthenticated), ct = p(C, (e) => e?.isAdmin === !0), it = p(C, (e) => e?.isUser === !0), ie = p(C, (e) => e?.permissions ?? []), Ne = p(C, (e) => e?.systems ?? []), ut = (e) => p(ie, (r) => r.includes(e)), lt = (e) => p(
140
+ ie,
141
+ (r) => e.some((a) => r.includes(a))
142
+ ), dt = (e) => p(Ne, (r) => r.includes(e)), mt = p(x, (e) => e.loading), Ue = p(x, (e) => e.loaded), Ie = {
143
+ portalAccess: "portal:access",
144
+ systemsRead: "systems:read",
145
+ systemsLaunch: "systems:launch",
146
+ usersRead: "users:read",
147
+ usersWrite: "users:write",
148
+ usersRolesWrite: "users:roles:write",
149
+ clientsRead: "clients:read",
150
+ clientsWrite: "clients:write",
151
+ clientsRolesWrite: "clients:roles:write",
152
+ announcementsRead: "announcements:read",
153
+ announcementsWrite: "announcements:write",
154
+ announcementsPublish: "announcements:publish",
155
+ documentsRead: "documents:read",
156
+ documentsWrite: "documents:write",
157
+ documentsProcess: "documents:process",
158
+ documentTemplatesRead: "document_templates:read",
159
+ documentTemplatesWrite: "document_templates:write",
160
+ documentTemplatesPublish: "document_templates:publish",
161
+ surveillanceRead: "surveillance:read",
162
+ surveillanceImport: "surveillance:import",
163
+ surveillanceManageLocations: "surveillance:manage_locations",
164
+ surveillanceManageAlerts: "surveillance:manage_alerts",
165
+ emailRead: "email:read",
166
+ emailSend: "email:send",
167
+ emailManage: "email:manage",
168
+ storageLocationsRead: "storage_locations:read",
169
+ storageLocationsWrite: "storage_locations:write",
170
+ dataQualityRead: "data_quality:read",
171
+ dataQualityWrite: "data_quality:write",
172
+ dataQualityResolve: "data_quality:resolve",
173
+ reportBrowserRead: "report_browser:read",
174
+ reportSchedulerRead: "report_scheduler:read",
175
+ reportSchedulerCreate: "report_scheduler:create",
176
+ reportSchedulerUpdate: "report_scheduler:update",
177
+ reportSchedulerDelete: "report_scheduler:delete",
178
+ reportSchedulerExecute: "report_scheduler:execute",
179
+ reportSchedulerHistory: "report_scheduler:history",
180
+ reportSchedulerManage: "report_scheduler:manage",
181
+ outbreakAccess: "outbreak:access",
182
+ outbreakManage: "outbreak:manage",
183
+ metricsRead: "metrics:read",
184
+ auditRead: "audit:read",
185
+ notificationsRead: "notifications:read",
186
+ notificationsWrite: "notifications:write",
187
+ rbacRead: "rbac:read",
188
+ rbacWrite: "rbac:write",
189
+ rbacRolesWrite: "rbac:roles:write",
190
+ rbacPermissionsWrite: "rbac:permissions:write",
191
+ issueTrackerResolve: "issue_tracker:resolve",
192
+ issueTrackerRead: "issue_tracker:read",
193
+ issueTrackerWrite: "issue_tracker:write",
194
+ issueTrackerManage: "issue_tracker:manage",
195
+ issueTrackerAssign: "issue_tracker:assign",
196
+ issueTrackerClose: "issue_tracker:close",
197
+ issueTrackerReopen: "issue_tracker:reopen",
198
+ issueTrackerComment: "issue_tracker:comment"
199
+ };
200
+ function k(e) {
201
+ return e.trim().toLowerCase();
202
+ }
203
+ function I(e, r) {
204
+ return e?.permissions?.includes(r) ?? !1;
205
+ }
206
+ function We(e, r) {
207
+ return r.some((a) => I(e, a));
208
+ }
209
+ function He(e, r) {
210
+ return r.every((a) => I(e, a));
211
+ }
212
+ function ue(e, r) {
213
+ const a = k(r);
214
+ return e?.systems?.some((n) => k(n) === a) || e?.accessibleSystems?.some((n) => k(n.clientId) === a) || !1;
215
+ }
216
+ function Me(e, r, a) {
217
+ const n = k(a);
218
+ return (e?.clientRoles?.[r] ?? []).some(
219
+ (o) => k(o) === n
220
+ );
221
+ }
222
+ function $e(e, r) {
223
+ return I(e, Ie.systemsLaunch) && ue(e, r);
224
+ }
225
+ function Ye(e) {
226
+ return e?.accessibleSystems ?? [];
227
+ }
228
+ function qe() {
229
+ const e = F(C);
230
+ return D(() => {
231
+ const r = new Set((e?.realmRoles ?? []).map((n) => n.toLowerCase())), a = e?.clientRoles ?? {};
232
+ return {
233
+ can: (n) => I(e, n),
234
+ canAny: (n) => We(e, n),
235
+ canAll: (n) => He(e, n),
236
+ hasRealmRole: (n) => r.has(n.trim().toLowerCase()),
237
+ hasClientRole: (n, o) => (a[n] ?? []).some(
238
+ (i) => i.trim().toLowerCase() === o.trim().toLowerCase()
239
+ ),
240
+ hasSystem: (n) => ue(e, n),
241
+ hasSystemRole: (n, o) => Me(e, n, o),
242
+ canLaunchSystem: (n) => $e(e, n),
243
+ permissions: e?.permissions ?? [],
244
+ systems: e?.systems ?? [],
245
+ accessibleSystems: Ye(e)
246
+ };
247
+ }, [e]);
248
+ }
249
+ function ft({
250
+ permission: e,
251
+ anyOf: r,
252
+ fallback: a = null,
253
+ children: n
254
+ }) {
255
+ const { can: o, canAny: i } = qe();
256
+ return (e ? o(e) : !0) && (r && r.length > 0 ? i(r) : !0) ? n : a;
257
+ }
258
+ function De() {
259
+ return typeof window > "u" ? "/portal" : `${window.location.pathname}${window.location.search}${window.location.hash}`;
260
+ }
261
+ function ht(e, r = De()) {
262
+ const a = new URL(
263
+ e,
264
+ typeof window > "u" ? "http://localhost" : window.location.origin
265
+ );
266
+ return a.searchParams.set("returnTo", r), a.toString();
267
+ }
268
+ function Fe(e) {
269
+ try {
270
+ const r = new URL(e);
271
+ return ["http:", "https:"].includes(r.protocol) && !r.username && !r.password;
272
+ } catch {
273
+ return !1;
274
+ }
275
+ }
276
+ function K(e, r) {
277
+ const a = r.trim().replace(/\/$/, "");
278
+ return !a || Fe(e) ? e : `${a}${e.startsWith("/") ? e : `/${e}`}`;
279
+ }
280
+ function pt(e, r) {
281
+ const a = e.launchUrl?.trim() ?? "", n = e.authenticatedLaunchUrl?.trim() ?? "";
282
+ return !r.hasPortalSession && n ? K(n, r.apiBaseUrl) : a || K(n, r.apiBaseUrl);
283
+ }
284
+ var N = { exports: {} }, S = {};
285
+ var ee;
286
+ function Ve() {
287
+ if (ee) return S;
288
+ ee = 1;
289
+ var e = /* @__PURE__ */ Symbol.for("react.transitional.element"), r = /* @__PURE__ */ Symbol.for("react.fragment");
290
+ function a(n, o, i) {
291
+ var f = null;
292
+ if (i !== void 0 && (f = "" + i), o.key !== void 0 && (f = "" + o.key), "key" in o) {
293
+ i = {};
294
+ for (var u in o)
295
+ u !== "key" && (i[u] = o[u]);
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(() => {
556
+ if (!(typeof window > "u")) {
557
+ if (n && !a) {
558
+ window.localStorage.removeItem(y), f.current = null, i(null);
559
+ return;
560
+ }
561
+ if (a && O && u.length === 0) {
562
+ window.localStorage.removeItem(y), f.current = null, i(null);
563
+ return;
564
+ }
565
+ h && (f.current = h.id, window.localStorage.setItem(y, h.id), o !== h.id && i(h.id), window.dispatchEvent(
566
+ new CustomEvent("moh:health-context-changed", { detail: h })
567
+ ));
568
+ }
569
+ }, [h, a, n, u.length, O, o]), U(() => {
570
+ const l = (R) => {
571
+ R.key === y && (f.current = R.newValue, i(R.newValue), r(A.util.resetApiState()));
572
+ };
573
+ return window.addEventListener("storage", l), () => window.removeEventListener("storage", l);
574
+ }, [r]), U(() => {
575
+ const l = (R) => {
576
+ const w = R.detail;
577
+ !w?.id || !u.some((W) => W.id === w.id) || f.current !== w.id && (f.current = w.id, i(w.id), r(A.util.resetApiState()));
578
+ };
579
+ return window.addEventListener("moh:health-context-changed", l), () => window.removeEventListener("moh:health-context-changed", l);
580
+ }, [u, r]);
581
+ const _ = ge(
582
+ async (l) => {
583
+ await E(l).unwrap(), f.current = l, window.localStorage.setItem(y, l), i(l), r(A.util.resetApiState());
584
+ const R = u.find((w) => w.id === l);
585
+ window.dispatchEvent(new CustomEvent("moh:health-context-changed", { detail: R }));
586
+ },
587
+ [u, r, E]
588
+ ), L = D(
589
+ () => ({ contexts: u, activeContext: h, isLoading: P, isUpdating: T, selectContext: _ }),
590
+ [h, u, P, T, _]
591
+ );
592
+ return /* @__PURE__ */ Ge.jsx(le.Provider, { value: L, children: e });
593
+ }
594
+ function V() {
595
+ const e = Ae(le);
596
+ if (!e)
597
+ throw new Error("useHealthContext must be used inside HealthContextProvider");
598
+ return e;
599
+ }
600
+ function wt() {
601
+ return V().contexts;
602
+ }
603
+ function _t() {
604
+ return V().activeContext;
605
+ }
606
+ function vt() {
607
+ const e = V();
608
+ return { ...e, hasContext: !!e.activeContext };
609
+ }
610
+ export {
611
+ y as ACTIVE_HEALTH_CONTEXT_STORAGE_KEY,
612
+ at as AuthBootstrap,
613
+ Rt as HealthContextProvider,
614
+ Ie as PERMISSIONS,
615
+ ft as PermissionGuard,
616
+ ce as authApi,
617
+ oe as authLoaded,
618
+ tt as authReducer,
619
+ ht as buildLoginURL,
620
+ $e as canLaunchSystem,
621
+ De as currentPortalReturnTo,
622
+ Ye as getAccessibleSystems,
623
+ He as hasAllPermissions,
624
+ We as hasAnyPermission,
625
+ I as hasPermission,
626
+ ue as hasSystem,
627
+ Me as hasSystemRole,
628
+ Pe as healthContextApi,
629
+ Ce as loginSuccess,
630
+ ae as logout,
631
+ pt as resolveSystemLaunchUrl,
632
+ ot as selectAccessToken,
633
+ x as selectAuth,
634
+ Ue as selectAuthLoaded,
635
+ mt as selectAuthLoading,
636
+ je as selectAuthenticated,
637
+ lt as selectHasAnyPermission,
638
+ ut as selectHasPermission,
639
+ dt as selectHasSystem,
640
+ ct as selectIsAdmin,
641
+ it as selectIsUser,
642
+ ie as selectPermissions,
643
+ Ne as selectSystems,
644
+ C as selectUser,
645
+ et as setAccessToken,
646
+ _t as useActiveHealthContext,
647
+ qe as useAuthorization,
648
+ wt as useAvailableHealthContexts,
649
+ V as useHealthContext,
650
+ rt as useMeQuery,
651
+ Oe as useMyHealthContextsQuery,
652
+ st as useRefreshMutation,
653
+ vt as useRequireHealthContext,
654
+ Le as useSelectHealthContextMutation,
655
+ nt as useUpdateProfileMutation
656
+ };
package/package.json CHANGED
@@ -1,6 +1,42 @@
1
1
  {
2
2
  "name": "@moh-sso/auth",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "type": "module",
4
+ "main": "./dist/index.js",
5
+ "types": "./dist/index.d.ts",
6
+ "version": "1.3.2",
7
+ "license": "UNLICENSED",
8
+ "module": "./dist/index.js",
9
+ "files": [
10
+ "dist",
11
+ "README.md",
12
+ "package.json"
13
+ ],
14
+ "scripts": {
15
+ "build": "vite build --config vite.config.ts && node ../../scripts/write-package-declarations.mjs package auth"
16
+ },
17
+ "exports": {
18
+ ".": {
19
+ "types": "./dist/index.d.ts",
20
+ "import": "./dist/index.js"
21
+ }
22
+ },
23
+ "publishConfig": {
24
+ "access": "public"
25
+ },
26
+ "dependencies": {
27
+ "@moh-sso/api": "^1.3.2",
28
+ "@moh-sso/state": "^1.3.2",
29
+ "@moh-sso/config": "^1.3.2"
30
+ },
31
+ "peerDependencies": {
32
+ "@reduxjs/toolkit": "^2.11.2",
33
+ "react": "^19.2.0",
34
+ "react-redux": "^9.2.0"
35
+ },
36
+ "private": false,
37
+ "repository": {
38
+ "type": "git",
39
+ "url": "git+https://github.com/mohuganda/moh-sso-dashboard.git",
40
+ "directory": "frontend/packages/auth"
41
+ }
42
+ }