jcicl 1.1.3 → 1.1.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.
@@ -26,6 +26,11 @@ export interface AuthContextValue {
26
26
  */
27
27
  acquireToken: (scopes?: string[]) => Promise<string>;
28
28
  }
29
+ /**
30
+ * Signature of {@link AuthContextValue.acquireToken}. Single source of truth so
31
+ * consumers (AuthenticatedApiClient, createUseApi) don't re-declare it and drift.
32
+ */
33
+ export type AcquireTokenFn = AuthContextValue['acquireToken'];
29
34
  /** Exported so tests and Storybook can mock the auth context directly. */
30
35
  export declare const AuthContext: import('react').Context<AuthContextValue | null>;
31
36
  export interface AuthProviderProps {
@@ -1,9 +1,9 @@
1
- import { jsx as m } from "react/jsx-runtime";
2
- import * as I from "react";
3
- import _, { useEffect as T, useMemo as L, useReducer as w, useContext as b, createContext as O } from "react";
4
- import { c, s, E as l, I as P, a as i, L as j, W as U, b as q } from "../.chunks/EventType.js";
1
+ import { jsx as C } from "react/jsx-runtime";
2
+ import * as j from "react";
3
+ import U, { useEffect as T, useMemo as h, useReducer as q, useContext as L, createContext as x, useCallback as A } from "react";
4
+ import { c, s, E as g, I as E, a as i, L as M, W as K, b as B } from "../.chunks/EventType.js";
5
5
  /*! @azure/msal-browser v5.10.0 2026-05-07 */
6
- const x = {
6
+ const S = {
7
7
  initialize: () => Promise.reject(c(s)),
8
8
  acquireTokenPopup: () => Promise.reject(c(s)),
9
9
  acquireTokenRedirect: () => Promise.reject(c(s)),
@@ -41,7 +41,7 @@ const x = {
41
41
  clearCache: () => Promise.reject(c(s))
42
42
  };
43
43
  /*! @azure/msal-browser v5.10.0 2026-05-07 */
44
- class M {
44
+ class D {
45
45
  /**
46
46
  * Gets interaction status from event message
47
47
  * @param message
@@ -49,26 +49,26 @@ class M {
49
49
  */
50
50
  static getInteractionStatusFromEvent(n, r) {
51
51
  switch (n.eventType) {
52
- case l.ACQUIRE_TOKEN_START:
53
- if (n.interactionType === P.Redirect || n.interactionType === P.Popup)
52
+ case g.ACQUIRE_TOKEN_START:
53
+ if (n.interactionType === E.Redirect || n.interactionType === E.Popup)
54
54
  return i.AcquireToken;
55
55
  break;
56
- case l.HANDLE_REDIRECT_START:
56
+ case g.HANDLE_REDIRECT_START:
57
57
  return i.HandleRedirect;
58
- case l.LOGOUT_START:
58
+ case g.LOGOUT_START:
59
59
  return i.Logout;
60
- case l.LOGOUT_END:
60
+ case g.LOGOUT_END:
61
61
  if (r && r !== i.Logout)
62
62
  break;
63
63
  return i.None;
64
- case l.HANDLE_REDIRECT_END:
64
+ case g.HANDLE_REDIRECT_END:
65
65
  if (r && r !== i.HandleRedirect)
66
66
  break;
67
67
  return i.None;
68
- case l.ACQUIRE_TOKEN_SUCCESS:
69
- case l.ACQUIRE_TOKEN_FAILURE:
70
- case l.RESTORE_FROM_BFCACHE:
71
- if (n.interactionType === P.Redirect || n.interactionType === P.Popup) {
68
+ case g.ACQUIRE_TOKEN_SUCCESS:
69
+ case g.ACQUIRE_TOKEN_FAILURE:
70
+ case g.RESTORE_FROM_BFCACHE:
71
+ if (n.interactionType === E.Redirect || n.interactionType === E.Popup) {
72
72
  if (r && r !== i.AcquireToken)
73
73
  break;
74
74
  return i.None;
@@ -79,15 +79,15 @@ class M {
79
79
  }
80
80
  }
81
81
  /*! @azure/msal-react v5.4.0 2026-05-07 */
82
- const S = {
83
- instance: x,
82
+ const G = {
83
+ instance: S,
84
84
  inProgress: i.None,
85
85
  accounts: [],
86
- logger: new j({})
87
- }, h = I.createContext(S);
88
- h.Consumer;
86
+ logger: new M({})
87
+ }, v = j.createContext(G);
88
+ v.Consumer;
89
89
  /*! @azure/msal-react v5.4.0 2026-05-07 */
90
- function v(e, n) {
90
+ function I(e, n) {
91
91
  if (e.length !== n.length)
92
92
  return !1;
93
93
  const r = [...n];
@@ -97,60 +97,60 @@ function v(e, n) {
97
97
  });
98
98
  }
99
99
  /*! @azure/msal-react v5.4.0 2026-05-07 */
100
- const K = "@azure/msal-react", k = "5.4.0";
100
+ const $ = "@azure/msal-react", _ = "5.4.0";
101
101
  /*! @azure/msal-react v5.4.0 2026-05-07 */
102
- const A = {
102
+ const f = {
103
103
  UNBLOCK_INPROGRESS: "UNBLOCK_INPROGRESS",
104
104
  EVENT: "EVENT"
105
- }, B = (e, n) => {
105
+ }, z = (e, n) => {
106
106
  const { type: r, payload: t } = n;
107
107
  let o = e.inProgress;
108
108
  switch (r) {
109
- case A.UNBLOCK_INPROGRESS:
109
+ case f.UNBLOCK_INPROGRESS:
110
110
  e.inProgress === i.Startup && (o = i.None, t.logger.info("MsalProvider - handleRedirectPromise resolved, setting inProgress to 'none'", ""));
111
111
  break;
112
- case A.EVENT:
113
- const u = t.message, d = M.getInteractionStatusFromEvent(u, e.inProgress);
114
- d && (t.logger.info(`MsalProvider - '${u.eventType}' results in setting inProgress from '${e.inProgress}' to '${d}'`, ""), o = d);
112
+ case f.EVENT:
113
+ const a = t.message, l = D.getInteractionStatusFromEvent(a, e.inProgress);
114
+ l && (t.logger.info(`MsalProvider - '${a.eventType}' results in setting inProgress from '${e.inProgress}' to '${l}'`, ""), o = l);
115
115
  break;
116
116
  default:
117
117
  throw new Error(`Unknown action type: ${r}`);
118
118
  }
119
119
  if (o === i.Startup)
120
120
  return e;
121
- const a = t.instance.getAllAccounts();
122
- return o !== e.inProgress && !v(a, e.accounts) ? {
121
+ const u = t.instance.getAllAccounts();
122
+ return o !== e.inProgress && !I(u, e.accounts) ? {
123
123
  ...e,
124
124
  inProgress: o,
125
- accounts: a
125
+ accounts: u
126
126
  } : o !== e.inProgress ? {
127
127
  ...e,
128
128
  inProgress: o
129
- } : v(a, e.accounts) ? e : {
129
+ } : I(u, e.accounts) ? e : {
130
130
  ...e,
131
- accounts: a
131
+ accounts: u
132
132
  };
133
133
  };
134
- function D({ instance: e, children: n }) {
134
+ function F({ instance: e, children: n }) {
135
135
  T(() => {
136
- e.initializeWrapperLibrary(U.React, k);
136
+ e.initializeWrapperLibrary(K.React, _);
137
137
  }, [e]);
138
- const r = L(() => e.getLogger().clone(K, k), [e]), [t, o] = w(B, void 0, () => ({
138
+ const r = h(() => e.getLogger().clone($, _), [e]), [t, o] = q(z, void 0, () => ({
139
139
  inProgress: i.Startup,
140
140
  accounts: []
141
141
  }));
142
142
  T(() => {
143
- const u = e.addEventCallback((d) => {
143
+ const a = e.addEventCallback((l) => {
144
144
  o({
145
145
  payload: {
146
146
  instance: e,
147
147
  logger: r,
148
- message: d
148
+ message: l
149
149
  },
150
- type: A.EVENT
150
+ type: f.EVENT
151
151
  });
152
152
  });
153
- return r.verbose(`MsalProvider - Registered event callback with id: '${u}'`, ""), e.initialize().then(() => {
153
+ return r.verbose(`MsalProvider - Registered event callback with id: '${a}'`, ""), e.initialize().then(() => {
154
154
  e.handleRedirectPromise().catch(() => {
155
155
  }).finally(() => {
156
156
  o({
@@ -158,70 +158,79 @@ function D({ instance: e, children: n }) {
158
158
  instance: e,
159
159
  logger: r
160
160
  },
161
- type: A.UNBLOCK_INPROGRESS
161
+ type: f.UNBLOCK_INPROGRESS
162
162
  });
163
163
  });
164
164
  }).catch(() => {
165
165
  }), () => {
166
- u && (r.verbose(`MsalProvider - Removing event callback '${u}'`, ""), e.removeEventCallback(u));
166
+ a && (r.verbose(`MsalProvider - Removing event callback '${a}'`, ""), e.removeEventCallback(a));
167
167
  };
168
168
  }, [e, r]);
169
- const a = {
169
+ const u = {
170
170
  instance: e,
171
171
  inProgress: t.inProgress,
172
172
  accounts: t.accounts,
173
173
  logger: r
174
174
  };
175
- return _.createElement(h.Provider, { value: a }, n);
175
+ return U.createElement(v.Provider, { value: u }, n);
176
176
  }
177
177
  /*! @azure/msal-react v5.4.0 2026-05-07 */
178
- const G = () => b(h), N = O(null);
179
- function $({ children: e, apiScope: n }) {
180
- const { instance: r, accounts: t, inProgress: o } = G();
178
+ const H = () => L(v), w = x(null);
179
+ function V({ children: e, apiScope: n }) {
180
+ const { instance: r, accounts: t, inProgress: o } = H();
181
181
  T(() => {
182
182
  t.length > 0 && !r.getActiveAccount() && r.setActiveAccount(t[0]);
183
183
  }, [t, r]);
184
- const a = r.getActiveAccount() ?? t[0] ?? null, u = !!a, d = o !== i.None, g = a == null ? void 0 : a.idTokenClaims, C = Array.isArray(g == null ? void 0 : g.roles) ? g.roles : [], y = {
185
- account: a,
186
- isAuthenticated: u,
187
- isLoading: d,
188
- roles: C,
189
- hasRole: (E) => C.includes(E),
190
- login: () => {
191
- r.loginRedirect({ scopes: [n] });
192
- },
193
- logout: () => {
194
- r.logoutRedirect({ account: a ?? void 0 });
195
- },
196
- acquireToken: async (E) => {
197
- const f = r.getActiveAccount() ?? t[0];
198
- if (!f)
184
+ const u = r.getActiveAccount() ?? t[0] ?? null, a = !!u, l = o !== i.None, P = h(() => {
185
+ const d = u == null ? void 0 : u.idTokenClaims;
186
+ return Array.isArray(d == null ? void 0 : d.roles) ? d.roles : [];
187
+ }, [u]), p = A((d) => P.includes(d), [P]), b = A(() => {
188
+ r.loginRedirect({ scopes: [n] });
189
+ }, [r, n]), k = A(() => {
190
+ r.logoutRedirect({ account: r.getActiveAccount() ?? t[0] ?? void 0 });
191
+ }, [r, t]), N = A(
192
+ async (d) => {
193
+ const R = r.getActiveAccount() ?? t[0];
194
+ if (!R)
199
195
  throw new Error("[Auth] No active account. The user must sign in first.");
200
- const p = E ?? [n];
196
+ const y = d ?? [n];
201
197
  try {
202
198
  return (await r.acquireTokenSilent({
203
- scopes: p,
204
- account: f
199
+ scopes: y,
200
+ account: R
205
201
  })).accessToken;
206
- } catch (R) {
207
- if (R instanceof q)
208
- return r.acquireTokenRedirect({ scopes: p, account: f }), "";
209
- throw R;
202
+ } catch (m) {
203
+ if (m instanceof B)
204
+ return r.acquireTokenRedirect({ scopes: y, account: R }), "";
205
+ throw m;
210
206
  }
211
- }
212
- };
213
- return /* @__PURE__ */ m(N.Provider, { value: y, children: e });
207
+ },
208
+ [r, t, n]
209
+ ), O = h(
210
+ () => ({
211
+ account: u,
212
+ isAuthenticated: a,
213
+ isLoading: l,
214
+ roles: P,
215
+ hasRole: p,
216
+ login: b,
217
+ logout: k,
218
+ acquireToken: N
219
+ }),
220
+ [u, a, l, P, p, b, k, N]
221
+ );
222
+ return /* @__PURE__ */ C(w.Provider, { value: O, children: e });
214
223
  }
215
224
  function X({ msalInstance: e, apiScope: n, children: r }) {
216
- return /* @__PURE__ */ m(D, { instance: e, children: /* @__PURE__ */ m($, { apiScope: n, children: r }) });
225
+ return /* @__PURE__ */ C(F, { instance: e, children: /* @__PURE__ */ C(V, { apiScope: n, children: r }) });
217
226
  }
218
227
  function Y() {
219
- const e = b(N);
228
+ const e = L(w);
220
229
  if (!e) throw new Error("useAuthContext must be used inside <AuthProvider>");
221
230
  return e;
222
231
  }
223
232
  export {
224
- N as AuthContext,
233
+ w as AuthContext,
225
234
  X as AuthProvider,
226
235
  Y as useAuthContext
227
236
  };
@@ -1,4 +1,4 @@
1
1
  export { AuthProvider, useAuthContext, AuthContext } from './AuthProvider';
2
- export type { AuthProviderProps, AuthContextValue } from './AuthProvider';
2
+ export type { AuthProviderProps, AuthContextValue, AcquireTokenFn } from './AuthProvider';
3
3
  export { createMsalInstance } from './msalConfig';
4
4
  export type { AuthConfig } from './msalConfig';