jcicl 1.1.2 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AuthContext/AuthProvider.d.ts +5 -0
- package/AuthContext/AuthProvider.js +85 -76
- package/AuthContext/index.d.ts +1 -1
- package/AuthContext/msalConfig.js +439 -435
- package/AuthenticatedApiClient.d.ts +3 -5
- package/AuthenticatedApiClient.js +36 -17
- package/LoginPage/LoginPage.js +32 -38
- package/Table/Table.js +8 -8
- package/assets/style.css +1 -1
- package/assets/tailwind.css +1 -1
- package/createUseApi.d.ts +1 -2
- package/package.json +1 -1
|
@@ -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
|
|
2
|
-
import * as
|
|
3
|
-
import
|
|
4
|
-
import { c, s, E as
|
|
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
|
|
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
|
|
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
|
|
53
|
-
if (n.interactionType ===
|
|
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
|
|
56
|
+
case g.HANDLE_REDIRECT_START:
|
|
57
57
|
return i.HandleRedirect;
|
|
58
|
-
case
|
|
58
|
+
case g.LOGOUT_START:
|
|
59
59
|
return i.Logout;
|
|
60
|
-
case
|
|
60
|
+
case g.LOGOUT_END:
|
|
61
61
|
if (r && r !== i.Logout)
|
|
62
62
|
break;
|
|
63
63
|
return i.None;
|
|
64
|
-
case
|
|
64
|
+
case g.HANDLE_REDIRECT_END:
|
|
65
65
|
if (r && r !== i.HandleRedirect)
|
|
66
66
|
break;
|
|
67
67
|
return i.None;
|
|
68
|
-
case
|
|
69
|
-
case
|
|
70
|
-
case
|
|
71
|
-
if (n.interactionType ===
|
|
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
|
|
83
|
-
instance:
|
|
82
|
+
const G = {
|
|
83
|
+
instance: S,
|
|
84
84
|
inProgress: i.None,
|
|
85
85
|
accounts: [],
|
|
86
|
-
logger: new
|
|
87
|
-
},
|
|
88
|
-
|
|
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
|
|
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
|
|
100
|
+
const $ = "@azure/msal-react", _ = "5.4.0";
|
|
101
101
|
/*! @azure/msal-react v5.4.0 2026-05-07 */
|
|
102
|
-
const
|
|
102
|
+
const f = {
|
|
103
103
|
UNBLOCK_INPROGRESS: "UNBLOCK_INPROGRESS",
|
|
104
104
|
EVENT: "EVENT"
|
|
105
|
-
},
|
|
105
|
+
}, z = (e, n) => {
|
|
106
106
|
const { type: r, payload: t } = n;
|
|
107
107
|
let o = e.inProgress;
|
|
108
108
|
switch (r) {
|
|
109
|
-
case
|
|
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
|
|
113
|
-
const
|
|
114
|
-
|
|
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
|
|
122
|
-
return o !== e.inProgress && !
|
|
121
|
+
const u = t.instance.getAllAccounts();
|
|
122
|
+
return o !== e.inProgress && !I(u, e.accounts) ? {
|
|
123
123
|
...e,
|
|
124
124
|
inProgress: o,
|
|
125
|
-
accounts:
|
|
125
|
+
accounts: u
|
|
126
126
|
} : o !== e.inProgress ? {
|
|
127
127
|
...e,
|
|
128
128
|
inProgress: o
|
|
129
|
-
} :
|
|
129
|
+
} : I(u, e.accounts) ? e : {
|
|
130
130
|
...e,
|
|
131
|
-
accounts:
|
|
131
|
+
accounts: u
|
|
132
132
|
};
|
|
133
133
|
};
|
|
134
|
-
function
|
|
134
|
+
function F({ instance: e, children: n }) {
|
|
135
135
|
T(() => {
|
|
136
|
-
e.initializeWrapperLibrary(
|
|
136
|
+
e.initializeWrapperLibrary(K.React, _);
|
|
137
137
|
}, [e]);
|
|
138
|
-
const r =
|
|
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
|
|
143
|
+
const a = e.addEventCallback((l) => {
|
|
144
144
|
o({
|
|
145
145
|
payload: {
|
|
146
146
|
instance: e,
|
|
147
147
|
logger: r,
|
|
148
|
-
message:
|
|
148
|
+
message: l
|
|
149
149
|
},
|
|
150
|
-
type:
|
|
150
|
+
type: f.EVENT
|
|
151
151
|
});
|
|
152
152
|
});
|
|
153
|
-
return r.verbose(`MsalProvider - Registered event callback with id: '${
|
|
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:
|
|
161
|
+
type: f.UNBLOCK_INPROGRESS
|
|
162
162
|
});
|
|
163
163
|
});
|
|
164
164
|
}).catch(() => {
|
|
165
165
|
}), () => {
|
|
166
|
-
|
|
166
|
+
a && (r.verbose(`MsalProvider - Removing event callback '${a}'`, ""), e.removeEventCallback(a));
|
|
167
167
|
};
|
|
168
168
|
}, [e, r]);
|
|
169
|
-
const
|
|
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
|
|
175
|
+
return U.createElement(v.Provider, { value: u }, n);
|
|
176
176
|
}
|
|
177
177
|
/*! @azure/msal-react v5.4.0 2026-05-07 */
|
|
178
|
-
const
|
|
179
|
-
function
|
|
180
|
-
const { instance: r, accounts: t, inProgress: o } =
|
|
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
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
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
|
|
196
|
+
const y = d ?? [n];
|
|
201
197
|
try {
|
|
202
198
|
return (await r.acquireTokenSilent({
|
|
203
|
-
scopes:
|
|
204
|
-
account:
|
|
199
|
+
scopes: y,
|
|
200
|
+
account: R
|
|
205
201
|
})).accessToken;
|
|
206
|
-
} catch (
|
|
207
|
-
if (
|
|
208
|
-
return r.acquireTokenRedirect({ scopes:
|
|
209
|
-
throw
|
|
202
|
+
} catch (m) {
|
|
203
|
+
if (m instanceof B)
|
|
204
|
+
return r.acquireTokenRedirect({ scopes: y, account: R }), "";
|
|
205
|
+
throw m;
|
|
210
206
|
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
|
|
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__ */
|
|
225
|
+
return /* @__PURE__ */ C(F, { instance: e, children: /* @__PURE__ */ C(V, { apiScope: n, children: r }) });
|
|
217
226
|
}
|
|
218
227
|
function Y() {
|
|
219
|
-
const e =
|
|
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
|
-
|
|
233
|
+
w as AuthContext,
|
|
225
234
|
X as AuthProvider,
|
|
226
235
|
Y as useAuthContext
|
|
227
236
|
};
|
package/AuthContext/index.d.ts
CHANGED
|
@@ -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';
|