@azure/msal-react 1.1.0 → 1.3.0
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/CHANGELOG.json +690 -574
- package/CHANGELOG.md +161 -126
- package/LICENSE +21 -21
- package/README.md +143 -143
- package/dist/error/ReactAuthError.d.ts +16 -0
- package/dist/hooks/useAccount.d.ts +1 -1
- package/dist/hooks/useMsalAuthentication.d.ts +6 -4
- package/dist/msal-react.cjs.development.js +205 -77
- package/dist/msal-react.cjs.development.js.map +1 -1
- package/dist/msal-react.cjs.production.min.js +1 -1
- package/dist/msal-react.cjs.production.min.js.map +1 -1
- package/dist/msal-react.esm.js +206 -78
- package/dist/msal-react.esm.js.map +1 -1
- package/dist/packageMetadata.d.ts +1 -1
- package/dist/utils/utilities.d.ts +2 -0
- package/package.json +65 -64
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AuthError } from "@azure/msal-browser";
|
|
2
|
+
export declare const ReactAuthErrorMessage: {
|
|
3
|
+
invalidInteractionType: {
|
|
4
|
+
code: string;
|
|
5
|
+
desc: string;
|
|
6
|
+
};
|
|
7
|
+
unableToFallbackToInteraction: {
|
|
8
|
+
code: string;
|
|
9
|
+
desc: string;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
export declare class ReactAuthError extends AuthError {
|
|
13
|
+
constructor(errorCode: string, errorMessage?: string);
|
|
14
|
+
static createInvalidInteractionTypeError(): ReactAuthError;
|
|
15
|
+
static createUnableToFallbackToInteractionError(): ReactAuthError;
|
|
16
|
+
}
|
|
@@ -4,4 +4,4 @@ import { AccountIdentifiers } from "../types/AccountIdentifiers";
|
|
|
4
4
|
* Given 1 or more accountIdentifiers, returns the Account object if the user is signed-in
|
|
5
5
|
* @param accountIdentifiers
|
|
6
6
|
*/
|
|
7
|
-
export declare function useAccount(accountIdentifiers
|
|
7
|
+
export declare function useAccount(accountIdentifiers?: AccountIdentifiers): AccountInfo | null;
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import { PopupRequest, RedirectRequest, SsoSilentRequest, InteractionType, AuthenticationResult, AuthError } from "@azure/msal-browser";
|
|
1
|
+
import { PopupRequest, RedirectRequest, SsoSilentRequest, InteractionType, AuthenticationResult, AuthError, SilentRequest } from "@azure/msal-browser";
|
|
2
2
|
import { AccountIdentifiers } from "../types/AccountIdentifiers";
|
|
3
3
|
export declare type MsalAuthenticationResult = {
|
|
4
|
-
login:
|
|
4
|
+
login: (callbackInteractionType?: InteractionType | undefined, callbackRequest?: PopupRequest | RedirectRequest | SilentRequest) => Promise<AuthenticationResult | null>;
|
|
5
|
+
acquireToken: (callbackInteractionType?: InteractionType | undefined, callbackRequest?: SilentRequest | undefined) => Promise<AuthenticationResult | null>;
|
|
5
6
|
result: AuthenticationResult | null;
|
|
6
7
|
error: AuthError | null;
|
|
7
8
|
};
|
|
8
9
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
10
|
+
* If a user is not currently signed in this hook invokes a login. Failed logins can be retried using the login callback returned.
|
|
11
|
+
* If a user is currently signed in this hook attempts to acquire a token. Subsequent token requests can use the acquireToken callback returned.
|
|
12
|
+
* Optionally provide a request object to be used in the login/acquireToken call.
|
|
11
13
|
* Optionally provide a specific user that should be logged in.
|
|
12
14
|
* @param interactionType
|
|
13
15
|
* @param authenticationRequest
|
|
@@ -60,10 +60,32 @@ function accountArraysAreEqual(arrayA, arrayB) {
|
|
|
60
60
|
return elementA.homeAccountId === elementB.homeAccountId && elementA.localAccountId === elementB.localAccountId && elementA.username === elementB.username;
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
|
+
function getAccountByIdentifiers(allAccounts, accountIdentifiers) {
|
|
64
|
+
if (allAccounts.length > 0 && (accountIdentifiers.homeAccountId || accountIdentifiers.localAccountId || accountIdentifiers.username)) {
|
|
65
|
+
const matchedAccounts = allAccounts.filter(accountObj => {
|
|
66
|
+
if (accountIdentifiers.username && accountIdentifiers.username.toLowerCase() !== accountObj.username.toLowerCase()) {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (accountIdentifiers.homeAccountId && accountIdentifiers.homeAccountId.toLowerCase() !== accountObj.homeAccountId.toLowerCase()) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (accountIdentifiers.localAccountId && accountIdentifiers.localAccountId.toLowerCase() !== accountObj.localAccountId.toLowerCase()) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return true;
|
|
79
|
+
});
|
|
80
|
+
return matchedAccounts[0] || null;
|
|
81
|
+
} else {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
63
85
|
|
|
64
86
|
/* eslint-disable header/header */
|
|
65
87
|
const name = "@azure/msal-react";
|
|
66
|
-
const version = "1.
|
|
88
|
+
const version = "1.3.0";
|
|
67
89
|
|
|
68
90
|
/*
|
|
69
91
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -81,7 +103,7 @@ function MsalProvider({
|
|
|
81
103
|
return instance.getLogger().clone(name, version);
|
|
82
104
|
}, [instance]); // State hook to store accounts
|
|
83
105
|
|
|
84
|
-
const [accounts, setAccounts] = React.useState(
|
|
106
|
+
const [accounts, setAccounts] = React.useState(() => instance.getAllAccounts()); // State hook to store in progress value
|
|
85
107
|
|
|
86
108
|
const [inProgress, setInProgress] = React.useState(msalBrowser.InteractionStatus.Startup); // Mutable object used in the event callback
|
|
87
109
|
|
|
@@ -134,6 +156,15 @@ function MsalProvider({
|
|
|
134
156
|
instance.handleRedirectPromise().catch(() => {
|
|
135
157
|
// Errors should be handled by listening to the LOGIN_FAILURE event
|
|
136
158
|
return;
|
|
159
|
+
}).finally(() => {
|
|
160
|
+
/*
|
|
161
|
+
* If handleRedirectPromise returns a cached promise the necessary events may not be fired
|
|
162
|
+
* This is a fallback to prevent inProgress from getting stuck in 'startup'
|
|
163
|
+
*/
|
|
164
|
+
if (inProgressRef.current === msalBrowser.InteractionStatus.Startup) {
|
|
165
|
+
inProgressRef.current = msalBrowser.InteractionStatus.None;
|
|
166
|
+
setInProgress(msalBrowser.InteractionStatus.None);
|
|
167
|
+
}
|
|
137
168
|
});
|
|
138
169
|
return () => {
|
|
139
170
|
if (callbackId) {
|
|
@@ -168,61 +199,9 @@ const useMsal = () => React.useContext(MsalContext);
|
|
|
168
199
|
* Licensed under the MIT License.
|
|
169
200
|
*/
|
|
170
201
|
|
|
171
|
-
function
|
|
172
|
-
const allAccounts = instance.getAllAccounts();
|
|
173
|
-
|
|
174
|
-
if (allAccounts.length > 0 && (accountIdentifiers.homeAccountId || accountIdentifiers.localAccountId || accountIdentifiers.username)) {
|
|
175
|
-
const matchedAccounts = allAccounts.filter(accountObj => {
|
|
176
|
-
if (accountIdentifiers.username && accountIdentifiers.username.toLowerCase() !== accountObj.username.toLowerCase()) {
|
|
177
|
-
return false;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
if (accountIdentifiers.homeAccountId && accountIdentifiers.homeAccountId.toLowerCase() !== accountObj.homeAccountId.toLowerCase()) {
|
|
181
|
-
return false;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
if (accountIdentifiers.localAccountId && accountIdentifiers.localAccountId.toLowerCase() !== accountObj.localAccountId.toLowerCase()) {
|
|
185
|
-
return false;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
return true;
|
|
189
|
-
});
|
|
190
|
-
return matchedAccounts[0] || null;
|
|
191
|
-
} else {
|
|
192
|
-
return null;
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* Given 1 or more accountIdentifiers, returns the Account object if the user is signed-in
|
|
197
|
-
* @param accountIdentifiers
|
|
198
|
-
*/
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
function useAccount(accountIdentifiers) {
|
|
202
|
-
const {
|
|
203
|
-
instance,
|
|
204
|
-
inProgress
|
|
205
|
-
} = useMsal();
|
|
206
|
-
const initialStateValue = inProgress === msalBrowser.InteractionStatus.Startup ? null : getAccount(instance, accountIdentifiers);
|
|
207
|
-
const [account, setAccount] = React.useState(initialStateValue);
|
|
208
|
-
React.useEffect(() => {
|
|
209
|
-
const currentAccount = getAccount(instance, accountIdentifiers);
|
|
210
|
-
|
|
211
|
-
if (!msalBrowser.AccountEntity.accountInfoIsEqual(account, currentAccount, true)) {
|
|
212
|
-
setAccount(currentAccount);
|
|
213
|
-
}
|
|
214
|
-
}, [inProgress, accountIdentifiers, instance, account]);
|
|
215
|
-
return account;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
/*
|
|
219
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
220
|
-
* Licensed under the MIT License.
|
|
221
|
-
*/
|
|
222
|
-
|
|
223
|
-
function isAuthenticated(allAccounts, account, matchAccount) {
|
|
202
|
+
function isAuthenticated(allAccounts, matchAccount) {
|
|
224
203
|
if (matchAccount && (matchAccount.username || matchAccount.homeAccountId || matchAccount.localAccountId)) {
|
|
225
|
-
return !!
|
|
204
|
+
return !!getAccountByIdentifiers(allAccounts, matchAccount);
|
|
226
205
|
}
|
|
227
206
|
|
|
228
207
|
return allAccounts.length > 0;
|
|
@@ -235,15 +214,12 @@ function isAuthenticated(allAccounts, account, matchAccount) {
|
|
|
235
214
|
|
|
236
215
|
function useIsAuthenticated(matchAccount) {
|
|
237
216
|
const {
|
|
238
|
-
accounts: allAccounts
|
|
239
|
-
inProgress
|
|
217
|
+
accounts: allAccounts
|
|
240
218
|
} = useMsal();
|
|
241
|
-
const
|
|
242
|
-
const initialStateValue = inProgress === msalBrowser.InteractionStatus.Startup ? false : isAuthenticated(allAccounts, account, matchAccount);
|
|
243
|
-
const [hasAuthenticated, setHasAuthenticated] = React.useState(initialStateValue);
|
|
219
|
+
const [hasAuthenticated, setHasAuthenticated] = React.useState(() => isAuthenticated(allAccounts, matchAccount));
|
|
244
220
|
React.useEffect(() => {
|
|
245
|
-
setHasAuthenticated(isAuthenticated(allAccounts,
|
|
246
|
-
}, [allAccounts,
|
|
221
|
+
setHasAuthenticated(isAuthenticated(allAccounts, matchAccount));
|
|
222
|
+
}, [allAccounts, matchAccount]);
|
|
247
223
|
return hasAuthenticated;
|
|
248
224
|
}
|
|
249
225
|
|
|
@@ -311,13 +287,86 @@ function UnauthenticatedTemplate({
|
|
|
311
287
|
return null;
|
|
312
288
|
}
|
|
313
289
|
|
|
290
|
+
/*
|
|
291
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
292
|
+
* Licensed under the MIT License.
|
|
293
|
+
*/
|
|
294
|
+
|
|
295
|
+
function getAccount(instance, accountIdentifiers) {
|
|
296
|
+
if (!accountIdentifiers || !accountIdentifiers.homeAccountId && !accountIdentifiers.localAccountId && !accountIdentifiers.username) {
|
|
297
|
+
// If no account identifiers are provided, return active account
|
|
298
|
+
return instance.getActiveAccount();
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
return getAccountByIdentifiers(instance.getAllAccounts(), accountIdentifiers);
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Given 1 or more accountIdentifiers, returns the Account object if the user is signed-in
|
|
305
|
+
* @param accountIdentifiers
|
|
306
|
+
*/
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
function useAccount(accountIdentifiers) {
|
|
310
|
+
const {
|
|
311
|
+
instance,
|
|
312
|
+
inProgress,
|
|
313
|
+
logger
|
|
314
|
+
} = useMsal();
|
|
315
|
+
const [account, setAccount] = React.useState(() => getAccount(instance, accountIdentifiers));
|
|
316
|
+
React.useEffect(() => {
|
|
317
|
+
setAccount(currentAccount => {
|
|
318
|
+
const nextAccount = getAccount(instance, accountIdentifiers);
|
|
319
|
+
|
|
320
|
+
if (!msalBrowser.AccountEntity.accountInfoIsEqual(currentAccount, nextAccount, true)) {
|
|
321
|
+
logger.info("useAccount - Updating account");
|
|
322
|
+
return nextAccount;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
return currentAccount;
|
|
326
|
+
});
|
|
327
|
+
}, [inProgress, accountIdentifiers, instance, logger]);
|
|
328
|
+
return account;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/*
|
|
332
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
333
|
+
* Licensed under the MIT License.
|
|
334
|
+
*/
|
|
335
|
+
const ReactAuthErrorMessage = {
|
|
336
|
+
invalidInteractionType: {
|
|
337
|
+
code: "invalid_interaction_type",
|
|
338
|
+
desc: "The provided interaction type is invalid."
|
|
339
|
+
},
|
|
340
|
+
unableToFallbackToInteraction: {
|
|
341
|
+
code: "unable_to_fallback_to_interaction",
|
|
342
|
+
desc: "Interaction is required but another interaction is already in progress. Please try again when the current interaction is complete."
|
|
343
|
+
}
|
|
344
|
+
};
|
|
345
|
+
class ReactAuthError extends msalBrowser.AuthError {
|
|
346
|
+
constructor(errorCode, errorMessage) {
|
|
347
|
+
super(errorCode, errorMessage);
|
|
348
|
+
Object.setPrototypeOf(this, ReactAuthError.prototype);
|
|
349
|
+
this.name = "ReactAuthError";
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
static createInvalidInteractionTypeError() {
|
|
353
|
+
return new ReactAuthError(ReactAuthErrorMessage.invalidInteractionType.code, ReactAuthErrorMessage.invalidInteractionType.desc);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
static createUnableToFallbackToInteractionError() {
|
|
357
|
+
return new ReactAuthError(ReactAuthErrorMessage.unableToFallbackToInteraction.code, ReactAuthErrorMessage.unableToFallbackToInteraction.desc);
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
}
|
|
361
|
+
|
|
314
362
|
/*
|
|
315
363
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
316
364
|
* Licensed under the MIT License.
|
|
317
365
|
*/
|
|
318
366
|
/**
|
|
319
|
-
*
|
|
320
|
-
*
|
|
367
|
+
* If a user is not currently signed in this hook invokes a login. Failed logins can be retried using the login callback returned.
|
|
368
|
+
* If a user is currently signed in this hook attempts to acquire a token. Subsequent token requests can use the acquireToken callback returned.
|
|
369
|
+
* Optionally provide a request object to be used in the login/acquireToken call.
|
|
321
370
|
* Optionally provide a specific user that should be logged in.
|
|
322
371
|
* @param interactionType
|
|
323
372
|
* @param authenticationRequest
|
|
@@ -331,8 +380,28 @@ function useMsalAuthentication(interactionType, authenticationRequest, accountId
|
|
|
331
380
|
logger
|
|
332
381
|
} = useMsal();
|
|
333
382
|
const isAuthenticated = useIsAuthenticated(accountIdentifiers);
|
|
334
|
-
const
|
|
335
|
-
const [
|
|
383
|
+
const account = useAccount(accountIdentifiers);
|
|
384
|
+
const [[result, error], setResponse] = React.useState([null, null]); // Boolean used to check if interaction is in progress in acquireTokenSilent fallback. Use Ref instead of state to prevent acquireToken function from being regenerated on each change to interactionInProgress value
|
|
385
|
+
|
|
386
|
+
const interactionInProgress = React.useRef(inProgress !== msalBrowser.InteractionStatus.None);
|
|
387
|
+
React.useEffect(() => {
|
|
388
|
+
interactionInProgress.current = inProgress !== msalBrowser.InteractionStatus.None;
|
|
389
|
+
}, [inProgress]); // Flag used to control when the hook calls login/acquireToken
|
|
390
|
+
|
|
391
|
+
const shouldAcquireToken = React.useRef(true);
|
|
392
|
+
React.useEffect(() => {
|
|
393
|
+
if (!!error) {
|
|
394
|
+
// Errors should be handled by consuming component
|
|
395
|
+
shouldAcquireToken.current = false;
|
|
396
|
+
return;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
if (!!result) {
|
|
400
|
+
// Token has already been acquired, consuming component/application is responsible for renewing
|
|
401
|
+
shouldAcquireToken.current = false;
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
404
|
+
}, [error, result]);
|
|
336
405
|
const login = React.useCallback(async (callbackInteractionType, callbackRequest) => {
|
|
337
406
|
const loginType = callbackInteractionType || interactionType;
|
|
338
407
|
const loginRequest = callbackRequest || authenticationRequest;
|
|
@@ -352,9 +421,59 @@ function useMsalAuthentication(interactionType, authenticationRequest, accountId
|
|
|
352
421
|
return instance.ssoSilent(loginRequest);
|
|
353
422
|
|
|
354
423
|
default:
|
|
355
|
-
throw
|
|
424
|
+
throw ReactAuthError.createInvalidInteractionTypeError();
|
|
356
425
|
}
|
|
357
426
|
}, [instance, interactionType, authenticationRequest, logger]);
|
|
427
|
+
const acquireToken = React.useCallback(async (callbackInteractionType, callbackRequest) => {
|
|
428
|
+
const fallbackInteractionType = callbackInteractionType || interactionType;
|
|
429
|
+
let tokenRequest;
|
|
430
|
+
|
|
431
|
+
if (callbackRequest) {
|
|
432
|
+
logger.trace("useMsalAuthentication - acquireToken - Using request provided in the callback");
|
|
433
|
+
tokenRequest = { ...callbackRequest
|
|
434
|
+
};
|
|
435
|
+
} else if (authenticationRequest) {
|
|
436
|
+
logger.trace("useMsalAuthentication - acquireToken - Using request provided in the hook");
|
|
437
|
+
tokenRequest = { ...authenticationRequest,
|
|
438
|
+
scopes: authenticationRequest.scopes || msalBrowser.OIDC_DEFAULT_SCOPES
|
|
439
|
+
};
|
|
440
|
+
} else {
|
|
441
|
+
logger.trace("useMsalAuthentication - acquireToken - No request object provided, using default request.");
|
|
442
|
+
tokenRequest = {
|
|
443
|
+
scopes: msalBrowser.OIDC_DEFAULT_SCOPES
|
|
444
|
+
};
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
if (!tokenRequest.account && account) {
|
|
448
|
+
logger.trace("useMsalAuthentication - acquireToken - Attaching account to request");
|
|
449
|
+
tokenRequest.account = account;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
const getToken = async () => {
|
|
453
|
+
logger.verbose("useMsalAuthentication - Calling acquireTokenSilent");
|
|
454
|
+
return instance.acquireTokenSilent(tokenRequest).catch(async e => {
|
|
455
|
+
if (e instanceof msalBrowser.InteractionRequiredAuthError) {
|
|
456
|
+
if (!interactionInProgress.current) {
|
|
457
|
+
logger.error("useMsalAuthentication - Interaction required, falling back to interaction");
|
|
458
|
+
return login(fallbackInteractionType, tokenRequest);
|
|
459
|
+
} else {
|
|
460
|
+
logger.error("useMsalAuthentication - Interaction required but is already in progress. Please try again, if needed, after interaction completes.");
|
|
461
|
+
throw ReactAuthError.createUnableToFallbackToInteractionError();
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
throw e;
|
|
466
|
+
});
|
|
467
|
+
};
|
|
468
|
+
|
|
469
|
+
return getToken().then(response => {
|
|
470
|
+
setResponse([response, null]);
|
|
471
|
+
return response;
|
|
472
|
+
}).catch(e => {
|
|
473
|
+
setResponse([null, e]);
|
|
474
|
+
throw e;
|
|
475
|
+
});
|
|
476
|
+
}, [instance, interactionType, authenticationRequest, logger, account, login]);
|
|
358
477
|
React.useEffect(() => {
|
|
359
478
|
const callbackId = instance.addEventCallback(message => {
|
|
360
479
|
switch (message.eventType) {
|
|
@@ -384,18 +503,27 @@ function useMsalAuthentication(interactionType, authenticationRequest, accountId
|
|
|
384
503
|
};
|
|
385
504
|
}, [instance, logger]);
|
|
386
505
|
React.useEffect(() => {
|
|
387
|
-
if (
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
506
|
+
if (shouldAcquireToken.current && inProgress === msalBrowser.InteractionStatus.None) {
|
|
507
|
+
shouldAcquireToken.current = false;
|
|
508
|
+
|
|
509
|
+
if (!isAuthenticated) {
|
|
510
|
+
logger.info("useMsalAuthentication - No user is authenticated, attempting to login");
|
|
511
|
+
login().catch(() => {
|
|
512
|
+
// Errors are saved in state above
|
|
513
|
+
return;
|
|
514
|
+
});
|
|
515
|
+
} else if (account) {
|
|
516
|
+
logger.info("useMsalAuthentication - User is authenticated, attempting to acquire token");
|
|
517
|
+
acquireToken().catch(() => {
|
|
518
|
+
// Errors are saved in state above
|
|
519
|
+
return;
|
|
520
|
+
});
|
|
521
|
+
}
|
|
395
522
|
}
|
|
396
|
-
}, [isAuthenticated,
|
|
523
|
+
}, [isAuthenticated, account, inProgress, login, acquireToken, logger]);
|
|
397
524
|
return {
|
|
398
525
|
login,
|
|
526
|
+
acquireToken,
|
|
399
527
|
result,
|
|
400
528
|
error
|
|
401
529
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"msal-react.cjs.development.js","sources":["../src/MsalContext.ts","../src/utils/utilities.ts","../src/packageMetadata.ts","../src/MsalProvider.tsx","../src/hooks/useMsal.ts","../src/hooks/useAccount.ts","../src/hooks/useIsAuthenticated.ts","../src/components/AuthenticatedTemplate.tsx","../src/components/UnauthenticatedTemplate.tsx","../src/hooks/useMsalAuthentication.ts","../src/components/MsalAuthenticationTemplate.tsx","../src/components/withMsal.tsx"],"sourcesContent":["/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport * as React from \"react\";\r\nimport { IPublicClientApplication, stubbedPublicClientApplication, Logger, InteractionStatus, AccountInfo } from \"@azure/msal-browser\";\r\n\r\nexport interface IMsalContext {\r\n instance: IPublicClientApplication;\r\n inProgress: InteractionStatus;\r\n accounts: AccountInfo[];\r\n logger: Logger;\r\n}\r\n\r\n/*\r\n * Stubbed context implementation\r\n * Only used when there is no provider, which is an unsupported scenario\r\n */\r\nconst defaultMsalContext: IMsalContext = {\r\n instance: stubbedPublicClientApplication,\r\n inProgress: InteractionStatus.None,\r\n accounts: [],\r\n logger: new Logger({})\r\n};\r\n\r\nexport const MsalContext = React.createContext<IMsalContext>(\r\n defaultMsalContext\r\n);\r\nexport const MsalConsumer = MsalContext.Consumer;\r\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { AccountIdentifiers } from \"../types/AccountIdentifiers\";\r\n\r\ntype FaaCFunction = <T>(args: T) => React.ReactNode;\r\n\r\nexport function getChildrenOrFunction<T>(\r\n children: React.ReactNode | FaaCFunction,\r\n args: T\r\n): React.ReactNode {\r\n if (typeof children === \"function\") {\r\n return children(args);\r\n }\r\n return children;\r\n}\r\n\r\n/*\r\n * Utility types\r\n * Reference: https://github.com/piotrwitek/utility-types\r\n */\r\ntype SetDifference<A, B> = A extends B ? never : A;\r\ntype SetComplement<A, A1 extends A> = SetDifference<A, A1>;\r\nexport type Subtract<T extends T1, T1 extends object> = Pick<T,SetComplement<keyof T, keyof T1>>;\r\n\r\n/**\r\n * Helper function to determine whether 2 arrays are equal\r\n * Used to avoid unnecessary state updates\r\n * @param arrayA \r\n * @param arrayB \r\n */\r\nexport function accountArraysAreEqual(arrayA: Array<AccountIdentifiers>, arrayB: Array<AccountIdentifiers>): boolean {\r\n if (arrayA.length !== arrayB.length) {\r\n return false;\r\n }\r\n\r\n const comparisonArray = [...arrayB];\r\n\r\n return arrayA.every((elementA) => {\r\n const elementB = comparisonArray.shift();\r\n if (!elementA || !elementB) {\r\n return false;\r\n }\r\n\r\n return (elementA.homeAccountId === elementB.homeAccountId) && \r\n (elementA.localAccountId === elementB.localAccountId) &&\r\n (elementA.username === elementB.username);\r\n });\r\n}\r\n","/* eslint-disable header/header */\r\nexport const name = \"@azure/msal-react\";\r\nexport const version = \"1.1.0\";\r\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport React, { useState, useEffect, useRef, PropsWithChildren, useMemo } from \"react\";\r\nimport {\r\n IPublicClientApplication,\r\n EventType,\r\n EventMessage,\r\n EventMessageUtils,\r\n InteractionStatus,\r\n Logger,\r\n WrapperSKU,\r\n AccountInfo\r\n} from \"@azure/msal-browser\";\r\nimport { MsalContext, IMsalContext } from \"./MsalContext\";\r\nimport { accountArraysAreEqual } from \"./utils/utilities\";\r\nimport { name as SKU, version } from \"./packageMetadata\";\r\n\r\nexport type MsalProviderProps = PropsWithChildren<{\r\n instance: IPublicClientApplication;\r\n}>;\r\n\r\nexport function MsalProvider({instance, children}: MsalProviderProps): React.ReactElement {\r\n useEffect(() => {\r\n instance.initializeWrapperLibrary(WrapperSKU.React, version);\r\n }, [instance]);\r\n // Create a logger instance for msal-react with the same options as PublicClientApplication\r\n const logger: Logger = useMemo(() => {\r\n return instance.getLogger().clone(SKU, version);\r\n }, [instance]);\r\n\r\n // State hook to store accounts\r\n const [accounts, setAccounts] = useState<AccountInfo[]>([]);\r\n // State hook to store in progress value\r\n const [inProgress, setInProgress] = useState<InteractionStatus>(InteractionStatus.Startup);\r\n // Mutable object used in the event callback\r\n const inProgressRef = useRef(inProgress);\r\n \r\n useEffect(() => {\r\n const callbackId = instance.addEventCallback((message: EventMessage) => {\r\n switch (message.eventType) {\r\n case EventType.ACCOUNT_ADDED:\r\n case EventType.ACCOUNT_REMOVED:\r\n case EventType.LOGIN_SUCCESS:\r\n case EventType.SSO_SILENT_SUCCESS:\r\n case EventType.HANDLE_REDIRECT_END:\r\n case EventType.LOGIN_FAILURE:\r\n case EventType.SSO_SILENT_FAILURE:\r\n case EventType.LOGOUT_END:\r\n case EventType.ACQUIRE_TOKEN_SUCCESS:\r\n case EventType.ACQUIRE_TOKEN_FAILURE:\r\n const currentAccounts = instance.getAllAccounts();\r\n if (!accountArraysAreEqual(currentAccounts, accounts)) {\r\n logger.info(\"MsalProvider - updating account state\");\r\n setAccounts(currentAccounts);\r\n } else {\r\n logger.info(\"MsalProvider - no account changes\");\r\n }\r\n break;\r\n }\r\n });\r\n logger.verbose(`MsalProvider - Registered event callback with id: ${callbackId}`);\r\n\r\n return () => {\r\n // Remove callback when component unmounts or accounts change\r\n if (callbackId) {\r\n logger.verbose(`MsalProvider - Removing event callback ${callbackId}`);\r\n instance.removeEventCallback(callbackId);\r\n }\r\n };\r\n }, [instance, accounts, logger]);\r\n\r\n useEffect(() => {\r\n const callbackId = instance.addEventCallback((message: EventMessage) => {\r\n const status = EventMessageUtils.getInteractionStatusFromEvent(message, inProgressRef.current);\r\n if (status !== null) {\r\n logger.info(`MsalProvider - ${message.eventType} results in setting inProgress from ${inProgressRef.current} to ${status}`);\r\n inProgressRef.current = status;\r\n setInProgress(status);\r\n }\r\n });\r\n logger.verbose(`MsalProvider - Registered event callback with id: ${callbackId}`);\r\n\r\n instance.handleRedirectPromise().catch(() => {\r\n // Errors should be handled by listening to the LOGIN_FAILURE event\r\n return;\r\n });\r\n\r\n return () => {\r\n if (callbackId) {\r\n logger.verbose(`MsalProvider - Removing event callback ${callbackId}`);\r\n instance.removeEventCallback(callbackId);\r\n }\r\n };\r\n }, [instance, logger]);\r\n\r\n const contextValue: IMsalContext = {\r\n instance,\r\n inProgress,\r\n accounts,\r\n logger\r\n };\r\n\r\n return (\r\n <MsalContext.Provider value={contextValue}>\r\n {children}\r\n </MsalContext.Provider>\r\n );\r\n}\r\n\r\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { useContext } from \"react\";\r\nimport { IMsalContext, MsalContext } from \"../MsalContext\";\r\n\r\n/**\r\n * Returns Msal Context values\r\n */\r\nexport const useMsal = (): IMsalContext => useContext(MsalContext);\r\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { useState, useEffect } from \"react\";\r\nimport { AccountInfo, IPublicClientApplication, InteractionStatus, AccountEntity } from \"@azure/msal-browser\";\r\nimport { useMsal } from \"./useMsal\";\r\nimport { AccountIdentifiers } from \"../types/AccountIdentifiers\";\r\n\r\nfunction getAccount(instance: IPublicClientApplication, accountIdentifiers: AccountIdentifiers): AccountInfo | null {\r\n const allAccounts = instance.getAllAccounts();\r\n if (allAccounts.length > 0 && (accountIdentifiers.homeAccountId || accountIdentifiers.localAccountId || accountIdentifiers.username)) {\r\n const matchedAccounts = allAccounts.filter(accountObj => {\r\n if (accountIdentifiers.username && accountIdentifiers.username.toLowerCase() !== accountObj.username.toLowerCase()) {\r\n return false;\r\n }\r\n if (accountIdentifiers.homeAccountId && accountIdentifiers.homeAccountId.toLowerCase() !== accountObj.homeAccountId.toLowerCase()) {\r\n return false;\r\n }\r\n if (accountIdentifiers.localAccountId && accountIdentifiers.localAccountId.toLowerCase() !== accountObj.localAccountId.toLowerCase()) {\r\n return false;\r\n }\r\n\r\n return true;\r\n });\r\n\r\n return matchedAccounts[0] || null;\r\n } else {\r\n return null;\r\n }\r\n}\r\n\r\n/**\r\n * Given 1 or more accountIdentifiers, returns the Account object if the user is signed-in\r\n * @param accountIdentifiers \r\n */\r\nexport function useAccount(accountIdentifiers: AccountIdentifiers): AccountInfo | null {\r\n const { instance, inProgress } = useMsal();\r\n\r\n const initialStateValue = inProgress === InteractionStatus.Startup ? null : getAccount(instance, accountIdentifiers);\r\n const [account, setAccount] = useState<AccountInfo|null>(initialStateValue);\r\n\r\n useEffect(() => {\r\n const currentAccount = getAccount(instance, accountIdentifiers);\r\n if (!AccountEntity.accountInfoIsEqual(account, currentAccount, true)) {\r\n setAccount(currentAccount);\r\n }\r\n }, [inProgress, accountIdentifiers, instance, account]);\r\n\r\n return account;\r\n}\r\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { useState, useEffect } from \"react\";\r\nimport { useMsal } from \"./useMsal\";\r\nimport { AccountIdentifiers } from \"../types/AccountIdentifiers\";\r\nimport { useAccount } from \"./useAccount\";\r\nimport { AccountInfo, InteractionStatus } from \"@azure/msal-browser\";\r\n\r\nfunction isAuthenticated(allAccounts: AccountIdentifiers[], account: AccountInfo | null, matchAccount?: AccountIdentifiers): boolean {\r\n if(matchAccount && (matchAccount.username || matchAccount.homeAccountId || matchAccount.localAccountId)) {\r\n return !!account;\r\n } \r\n\r\n return allAccounts.length > 0;\r\n}\r\n\r\n/**\r\n * Returns whether or not a user is currently signed-in. Optionally provide 1 or more accountIdentifiers to determine if a specific user is signed-in\r\n * @param matchAccount \r\n */\r\nexport function useIsAuthenticated(matchAccount?: AccountIdentifiers): boolean {\r\n const { accounts: allAccounts, inProgress } = useMsal();\r\n const account = useAccount(matchAccount || {});\r\n\r\n const initialStateValue = inProgress === InteractionStatus.Startup ? false : isAuthenticated(allAccounts, account, matchAccount);\r\n const [hasAuthenticated, setHasAuthenticated] = useState<boolean>(initialStateValue);\r\n\r\n useEffect(() => {\r\n setHasAuthenticated(isAuthenticated(allAccounts, account, matchAccount));\r\n }, [allAccounts, account, matchAccount]);\r\n\r\n return hasAuthenticated;\r\n}\r\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport React, { PropsWithChildren, useMemo } from \"react\";\r\nimport { AccountIdentifiers } from \"../types/AccountIdentifiers\";\r\nimport { getChildrenOrFunction } from \"../utils/utilities\";\r\nimport { useMsal } from \"../hooks/useMsal\";\r\nimport { useIsAuthenticated } from \"../hooks/useIsAuthenticated\";\r\nimport { InteractionStatus } from \"@azure/msal-browser\";\r\n\r\nexport type AuthenticatedTemplateProps = PropsWithChildren<AccountIdentifiers>;\r\n\r\n/**\r\n * Renders child components if user is authenticated\r\n * @param props \r\n */\r\nexport function AuthenticatedTemplate({ username, homeAccountId, localAccountId, children }: AuthenticatedTemplateProps): React.ReactElement|null {\r\n const context = useMsal();\r\n const accountIdentifier: AccountIdentifiers = useMemo(() => {\r\n return {\r\n username,\r\n homeAccountId,\r\n localAccountId\r\n };\r\n }, [username, homeAccountId, localAccountId]);\r\n const isAuthenticated = useIsAuthenticated(accountIdentifier);\r\n\r\n if (isAuthenticated && context.inProgress !== InteractionStatus.Startup) {\r\n return (\r\n <React.Fragment>\r\n {getChildrenOrFunction(children, context)}\r\n </React.Fragment>\r\n );\r\n }\r\n return null;\r\n}\r\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport React, { PropsWithChildren, useMemo } from \"react\";\r\nimport { useMsal } from \"../hooks/useMsal\";\r\nimport { useIsAuthenticated } from \"../hooks/useIsAuthenticated\";\r\nimport { getChildrenOrFunction } from \"../utils/utilities\";\r\nimport { AccountIdentifiers } from \"../types/AccountIdentifiers\";\r\nimport { InteractionStatus } from \"@azure/msal-browser\";\r\n\r\nexport type UnauthenticatedTemplateProps = PropsWithChildren<AccountIdentifiers>;\r\n\r\n/**\r\n * Renders child components if user is unauthenticated\r\n * @param props \r\n */\r\nexport function UnauthenticatedTemplate({ username, homeAccountId, localAccountId, children }: UnauthenticatedTemplateProps): React.ReactElement|null {\r\n const context = useMsal();\r\n const accountIdentifier: AccountIdentifiers = useMemo(() => {\r\n return {\r\n username,\r\n homeAccountId,\r\n localAccountId\r\n };\r\n }, [username, homeAccountId, localAccountId]);\r\n const isAuthenticated = useIsAuthenticated(accountIdentifier);\r\n\r\n if (!isAuthenticated && context.inProgress !== InteractionStatus.Startup && context.inProgress !== InteractionStatus.HandleRedirect) {\r\n return (\r\n <React.Fragment>\r\n {getChildrenOrFunction(children, context)}\r\n </React.Fragment>\r\n );\r\n }\r\n return null;\r\n}\r\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { useCallback, useEffect, useState } from \"react\";\r\nimport { PopupRequest, RedirectRequest, SsoSilentRequest, InteractionType, AuthenticationResult, AuthError, EventMessage, EventType, InteractionStatus } from \"@azure/msal-browser\";\r\nimport { useIsAuthenticated } from \"./useIsAuthenticated\";\r\nimport { AccountIdentifiers } from \"../types/AccountIdentifiers\";\r\nimport { useMsal } from \"./useMsal\";\r\n\r\nexport type MsalAuthenticationResult = {\r\n login: Function; \r\n result: AuthenticationResult|null;\r\n error: AuthError|null;\r\n};\r\n\r\n/**\r\n * Invokes a login call if a user is not currently signed-in. Failed logins can be retried using the login callback returned.\r\n * Optionally provide a request object to be used in the login call.\r\n * Optionally provide a specific user that should be logged in.\r\n * @param interactionType \r\n * @param authenticationRequest \r\n * @param accountIdentifiers \r\n */\r\nexport function useMsalAuthentication(\r\n interactionType: InteractionType, \r\n authenticationRequest?: PopupRequest|RedirectRequest|SsoSilentRequest, \r\n accountIdentifiers?: AccountIdentifiers\r\n): MsalAuthenticationResult {\r\n const { instance, inProgress, logger } = useMsal();\r\n const isAuthenticated = useIsAuthenticated(accountIdentifiers);\r\n const [[result, error], setResponse] = useState<[AuthenticationResult|null, AuthError|null]>([null, null]);\r\n const [hasBeenCalled, setHasBeenCalled] = useState<boolean>(false);\r\n\r\n const login = useCallback(async (callbackInteractionType?: InteractionType, callbackRequest?: PopupRequest|RedirectRequest|SsoSilentRequest): Promise<AuthenticationResult|null> => {\r\n const loginType = callbackInteractionType || interactionType;\r\n const loginRequest = callbackRequest || authenticationRequest;\r\n switch (loginType) {\r\n case InteractionType.Popup:\r\n logger.verbose(\"useMsalAuthentication - Calling loginPopup\");\r\n return instance.loginPopup(loginRequest as PopupRequest);\r\n case InteractionType.Redirect:\r\n // This promise is not expected to resolve due to full frame redirect\r\n logger.verbose(\"useMsalAuthentication - Calling loginRedirect\");\r\n return instance.loginRedirect(loginRequest as RedirectRequest).then(null);\r\n case InteractionType.Silent:\r\n logger.verbose(\"useMsalAuthentication - Calling ssoSilent\");\r\n return instance.ssoSilent(loginRequest as SsoSilentRequest);\r\n default:\r\n throw \"Invalid interaction type provided.\";\r\n }\r\n }, [instance, interactionType, authenticationRequest, logger]);\r\n\r\n useEffect(() => {\r\n const callbackId = instance.addEventCallback((message: EventMessage) => {\r\n switch(message.eventType) {\r\n case EventType.LOGIN_SUCCESS:\r\n case EventType.SSO_SILENT_SUCCESS:\r\n if (message.payload) {\r\n setResponse([message.payload as AuthenticationResult, null]);\r\n }\r\n break;\r\n case EventType.LOGIN_FAILURE:\r\n case EventType.SSO_SILENT_FAILURE:\r\n if (message.error) {\r\n setResponse([null, message.error as AuthError]);\r\n }\r\n break;\r\n }\r\n });\r\n logger.verbose(`useMsalAuthentication - Registered event callback with id: ${callbackId}`);\r\n\r\n return () => {\r\n if (callbackId) {\r\n logger.verbose(`useMsalAuthentication - Removing event callback ${callbackId}`);\r\n instance.removeEventCallback(callbackId);\r\n }\r\n };\r\n }, [instance, logger]);\r\n\r\n useEffect(() => {\r\n if (!hasBeenCalled && !error && !isAuthenticated && inProgress === InteractionStatus.None) {\r\n logger.info(\"useMsalAuthentication - No user is authenticated, attempting to login\");\r\n // Ensure login is only called one time from within this hook, any subsequent login attempts should use the callback returned\r\n setHasBeenCalled(true);\r\n login().catch(() => {\r\n // Errors are handled by the event handler above\r\n return;\r\n });\r\n }\r\n }, [isAuthenticated, inProgress, error, hasBeenCalled, login, logger]);\r\n\r\n return { login, result, error };\r\n}\r\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport React, { PropsWithChildren, useMemo } from \"react\";\r\nimport { AccountIdentifiers } from \"../types/AccountIdentifiers\";\r\nimport { getChildrenOrFunction } from \"../utils/utilities\";\r\nimport { useMsal } from \"../hooks/useMsal\";\r\nimport { MsalAuthenticationResult, useMsalAuthentication } from \"../hooks/useMsalAuthentication\";\r\nimport { useIsAuthenticated } from \"../hooks/useIsAuthenticated\";\r\nimport { InteractionType, PopupRequest, RedirectRequest, SsoSilentRequest, InteractionStatus } from \"@azure/msal-browser\";\r\nimport { IMsalContext } from \"../MsalContext\";\r\n\r\nexport type MsalAuthenticationProps = PropsWithChildren<AccountIdentifiers & {\r\n interactionType: InteractionType;\r\n authenticationRequest?: PopupRequest|RedirectRequest|SsoSilentRequest;\r\n loadingComponent?: React.ElementType<IMsalContext>;\r\n errorComponent?: React.ElementType<MsalAuthenticationResult>;\r\n}>;\r\n\r\n/**\r\n * Attempts to authenticate user if not already authenticated, then renders child components\r\n * @param props\r\n */\r\nexport function MsalAuthenticationTemplate({ \r\n interactionType, \r\n username, \r\n homeAccountId, \r\n localAccountId,\r\n authenticationRequest, \r\n loadingComponent: LoadingComponent,\r\n errorComponent: ErrorComponent,\r\n children \r\n}: MsalAuthenticationProps): React.ReactElement|null {\r\n const accountIdentifier: AccountIdentifiers = useMemo(() => {\r\n return {\r\n username,\r\n homeAccountId,\r\n localAccountId\r\n };\r\n }, [username, homeAccountId, localAccountId]);\r\n const context = useMsal();\r\n const msalAuthResult = useMsalAuthentication(interactionType, authenticationRequest, accountIdentifier);\r\n const isAuthenticated = useIsAuthenticated(accountIdentifier);\r\n\r\n if (msalAuthResult.error && context.inProgress === InteractionStatus.None) {\r\n if (!!ErrorComponent) {\r\n return <ErrorComponent {...msalAuthResult} />;\r\n }\r\n\r\n throw msalAuthResult.error;\r\n }\r\n \r\n if (isAuthenticated) {\r\n return (\r\n <React.Fragment>\r\n {getChildrenOrFunction(children, msalAuthResult)}\r\n </React.Fragment>\r\n );\r\n } \r\n \r\n if (!!LoadingComponent && context.inProgress !== InteractionStatus.None) {\r\n return <LoadingComponent {...context} />;\r\n }\r\n\r\n return null;\r\n}\r\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport React from \"react\";\r\nimport { IMsalContext } from \"../MsalContext\";\r\nimport { useMsal } from \"../hooks/useMsal\";\r\nimport { Subtract } from \"../utils/utilities\";\r\n\r\nexport type WithMsalProps = {\r\n msalContext: IMsalContext;\r\n};\r\n\r\n/**\r\n * Higher order component wraps provided component with msal by injecting msal context values into the component's props \r\n * @param Component \r\n */\r\nexport const withMsal = <P extends WithMsalProps>(Component: React.ComponentType<P>): React.FunctionComponent<Subtract<P,WithMsalProps>> => {\r\n const ComponentWithMsal: React.FunctionComponent<Subtract<P,WithMsalProps>> = props => {\r\n const msal = useMsal();\r\n return <Component {...(props as P)} msalContext={msal} />;\r\n };\r\n\r\n const componentName =\r\n Component.displayName || Component.name || \"Component\";\r\n ComponentWithMsal.displayName = `withMsal(${componentName})`;\r\n\r\n return ComponentWithMsal;\r\n};\r\n"],"names":["defaultMsalContext","instance","stubbedPublicClientApplication","inProgress","InteractionStatus","None","accounts","logger","Logger","MsalContext","React","MsalConsumer","Consumer","getChildrenOrFunction","children","args","accountArraysAreEqual","arrayA","arrayB","length","comparisonArray","every","elementA","elementB","shift","homeAccountId","localAccountId","username","name","version","MsalProvider","useEffect","initializeWrapperLibrary","WrapperSKU","useMemo","getLogger","clone","SKU","setAccounts","useState","setInProgress","Startup","inProgressRef","useRef","callbackId","addEventCallback","message","eventType","EventType","ACCOUNT_ADDED","ACCOUNT_REMOVED","LOGIN_SUCCESS","SSO_SILENT_SUCCESS","HANDLE_REDIRECT_END","LOGIN_FAILURE","SSO_SILENT_FAILURE","LOGOUT_END","ACQUIRE_TOKEN_SUCCESS","ACQUIRE_TOKEN_FAILURE","currentAccounts","getAllAccounts","info","verbose","removeEventCallback","status","EventMessageUtils","getInteractionStatusFromEvent","current","handleRedirectPromise","catch","contextValue","Provider","value","useMsal","useContext","getAccount","accountIdentifiers","allAccounts","matchedAccounts","filter","accountObj","toLowerCase","useAccount","initialStateValue","account","setAccount","currentAccount","AccountEntity","accountInfoIsEqual","isAuthenticated","matchAccount","useIsAuthenticated","hasAuthenticated","setHasAuthenticated","AuthenticatedTemplate","context","accountIdentifier","Fragment","UnauthenticatedTemplate","HandleRedirect","useMsalAuthentication","interactionType","authenticationRequest","result","error","setResponse","hasBeenCalled","setHasBeenCalled","login","useCallback","callbackInteractionType","callbackRequest","loginType","loginRequest","InteractionType","Popup","loginPopup","Redirect","loginRedirect","then","Silent","ssoSilent","payload","MsalAuthenticationTemplate","loadingComponent","LoadingComponent","errorComponent","ErrorComponent","msalAuthResult","withMsal","Component","ComponentWithMsal","props","msal","msalContext","componentName","displayName"],"mappings":";;;;;;;;;;AAAA;;;;AAeA;;;;;AAIA,MAAMA,kBAAkB,GAAiB;AACrCC,EAAAA,QAAQ,EAAEC,0CAD2B;AAErCC,EAAAA,UAAU,EAAEC,6BAAiB,CAACC,IAFO;AAGrCC,EAAAA,QAAQ,EAAE,EAH2B;AAIrCC,EAAAA,MAAM,eAAE,IAAIC,kBAAJ,CAAW,EAAX;AAJ6B,CAAzC;MAOaC,WAAW,gBAAGC,mBAAA,CACvBV,kBADuB;MAGdW,YAAY,GAAGF,WAAW,CAACG;;AC7BxC;;;;AASA,SAAgBC,sBACZC,UACAC;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AAKH;;AAED,MAAI,CAAC,CAACH,gBAAF,IAAsB9B,OAAO,CAAC5F,UAAR,KAAuBC,6BAAiB,CAACC,IAAnE,EAAyE;AACrE,WAAOK,4BAAA,CAACmH,gBAAD,oBAAsB9B,QAAtB,CAAP;AACH;;AAED,SAAO,IAAP;AACH;;ACnED;;;;AAKA,AASA;;;;;AAIA,MAAakC,QAAQ,GAA6BC,SAA1B;AACpB,QAAMC,iBAAiB,GAAuDC,KAAK;AAC/E,UAAMC,IAAI,GAAG5D,OAAO,EAApB;AACA,WAAO/D,4BAAA,CAACwH,SAAD,oBAAgBE;AAAaE,MAAAA,WAAW,EAAED;MAA1C,CAAP;AACH,GAHD;;AAKA,QAAME,aAAa,GACfL,SAAS,CAACM,WAAV,IAAyBN,SAAS,CAACtG,IAAnC,IAA2C,WAD/C;AAEAuG,EAAAA,iBAAiB,CAACK,WAAlB,eAA4CD,gBAA5C;AAEA,SAAOJ,iBAAP;AACH,CAXM;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"msal-react.cjs.development.js","sources":["../src/MsalContext.ts","../src/utils/utilities.ts","../src/packageMetadata.ts","../src/MsalProvider.tsx","../src/hooks/useMsal.ts","../src/hooks/useIsAuthenticated.ts","../src/components/AuthenticatedTemplate.tsx","../src/components/UnauthenticatedTemplate.tsx","../src/hooks/useAccount.ts","../src/error/ReactAuthError.ts","../src/hooks/useMsalAuthentication.ts","../src/components/MsalAuthenticationTemplate.tsx","../src/components/withMsal.tsx"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport * as React from \"react\";\nimport { IPublicClientApplication, stubbedPublicClientApplication, Logger, InteractionStatus, AccountInfo } from \"@azure/msal-browser\";\n\nexport interface IMsalContext {\n instance: IPublicClientApplication;\n inProgress: InteractionStatus;\n accounts: AccountInfo[];\n logger: Logger;\n}\n\n/*\n * Stubbed context implementation\n * Only used when there is no provider, which is an unsupported scenario\n */\nconst defaultMsalContext: IMsalContext = {\n instance: stubbedPublicClientApplication,\n inProgress: InteractionStatus.None,\n accounts: [],\n logger: new Logger({})\n};\n\nexport const MsalContext = React.createContext<IMsalContext>(\n defaultMsalContext\n);\nexport const MsalConsumer = MsalContext.Consumer;\n","/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { AccountIdentifiers } from \"../types/AccountIdentifiers\";\nimport { AccountInfo } from \"@azure/msal-browser\";\n\ntype FaaCFunction = <T>(args: T) => React.ReactNode;\n\nexport function getChildrenOrFunction<T>(\n children: React.ReactNode | FaaCFunction,\n args: T\n): React.ReactNode {\n if (typeof children === \"function\") {\n return children(args);\n }\n return children;\n}\n\n/*\n * Utility types\n * Reference: https://github.com/piotrwitek/utility-types\n */\ntype SetDifference<A, B> = A extends B ? never : A;\ntype SetComplement<A, A1 extends A> = SetDifference<A, A1>;\nexport type Subtract<T extends T1, T1 extends object> = Pick<T,SetComplement<keyof T, keyof T1>>;\n\n/**\n * Helper function to determine whether 2 arrays are equal\n * Used to avoid unnecessary state updates\n * @param arrayA \n * @param arrayB \n */\nexport function accountArraysAreEqual(arrayA: Array<AccountIdentifiers>, arrayB: Array<AccountIdentifiers>): boolean {\n if (arrayA.length !== arrayB.length) {\n return false;\n }\n\n const comparisonArray = [...arrayB];\n\n return arrayA.every((elementA) => {\n const elementB = comparisonArray.shift();\n if (!elementA || !elementB) {\n return false;\n }\n\n return (elementA.homeAccountId === elementB.homeAccountId) && \n (elementA.localAccountId === elementB.localAccountId) &&\n (elementA.username === elementB.username);\n });\n}\n\nexport function getAccountByIdentifiers(allAccounts: AccountInfo[], accountIdentifiers: AccountIdentifiers): AccountInfo | null {\n if (allAccounts.length > 0 && (accountIdentifiers.homeAccountId || accountIdentifiers.localAccountId || accountIdentifiers.username)) {\n const matchedAccounts = allAccounts.filter(accountObj => {\n if (accountIdentifiers.username && accountIdentifiers.username.toLowerCase() !== accountObj.username.toLowerCase()) {\n return false;\n }\n if (accountIdentifiers.homeAccountId && accountIdentifiers.homeAccountId.toLowerCase() !== accountObj.homeAccountId.toLowerCase()) {\n return false;\n }\n if (accountIdentifiers.localAccountId && accountIdentifiers.localAccountId.toLowerCase() !== accountObj.localAccountId.toLowerCase()) {\n return false;\n }\n\n return true;\n });\n\n return matchedAccounts[0] || null;\n } else {\n return null;\n }\n}\n","/* eslint-disable header/header */\nexport const name = \"@azure/msal-react\";\nexport const version = \"1.3.0\";\n","/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport React, { useState, useEffect, useRef, PropsWithChildren, useMemo } from \"react\";\nimport {\n IPublicClientApplication,\n EventType,\n EventMessage,\n EventMessageUtils,\n InteractionStatus,\n Logger,\n WrapperSKU,\n AccountInfo\n} from \"@azure/msal-browser\";\nimport { MsalContext, IMsalContext } from \"./MsalContext\";\nimport { accountArraysAreEqual } from \"./utils/utilities\";\nimport { name as SKU, version } from \"./packageMetadata\";\n\nexport type MsalProviderProps = PropsWithChildren<{\n instance: IPublicClientApplication;\n}>;\n\nexport function MsalProvider({instance, children}: MsalProviderProps): React.ReactElement {\n useEffect(() => {\n instance.initializeWrapperLibrary(WrapperSKU.React, version);\n }, [instance]);\n // Create a logger instance for msal-react with the same options as PublicClientApplication\n const logger: Logger = useMemo(() => {\n return instance.getLogger().clone(SKU, version);\n }, [instance]);\n\n // State hook to store accounts\n const [accounts, setAccounts] = useState<AccountInfo[]>(() => instance.getAllAccounts());\n // State hook to store in progress value\n const [inProgress, setInProgress] = useState<InteractionStatus>(InteractionStatus.Startup);\n // Mutable object used in the event callback\n const inProgressRef = useRef(inProgress);\n \n useEffect(() => {\n const callbackId = instance.addEventCallback((message: EventMessage) => {\n switch (message.eventType) {\n case EventType.ACCOUNT_ADDED:\n case EventType.ACCOUNT_REMOVED:\n case EventType.LOGIN_SUCCESS:\n case EventType.SSO_SILENT_SUCCESS:\n case EventType.HANDLE_REDIRECT_END:\n case EventType.LOGIN_FAILURE:\n case EventType.SSO_SILENT_FAILURE:\n case EventType.LOGOUT_END:\n case EventType.ACQUIRE_TOKEN_SUCCESS:\n case EventType.ACQUIRE_TOKEN_FAILURE:\n const currentAccounts = instance.getAllAccounts();\n if (!accountArraysAreEqual(currentAccounts, accounts)) {\n logger.info(\"MsalProvider - updating account state\");\n setAccounts(currentAccounts);\n } else {\n logger.info(\"MsalProvider - no account changes\");\n }\n break;\n }\n });\n logger.verbose(`MsalProvider - Registered event callback with id: ${callbackId}`);\n\n return () => {\n // Remove callback when component unmounts or accounts change\n if (callbackId) {\n logger.verbose(`MsalProvider - Removing event callback ${callbackId}`);\n instance.removeEventCallback(callbackId);\n }\n };\n }, [instance, accounts, logger]);\n\n useEffect(() => {\n const callbackId = instance.addEventCallback((message: EventMessage) => {\n const status = EventMessageUtils.getInteractionStatusFromEvent(message, inProgressRef.current);\n if (status !== null) {\n logger.info(`MsalProvider - ${message.eventType} results in setting inProgress from ${inProgressRef.current} to ${status}`);\n inProgressRef.current = status;\n setInProgress(status);\n }\n });\n logger.verbose(`MsalProvider - Registered event callback with id: ${callbackId}`);\n\n instance.handleRedirectPromise().catch(() => {\n // Errors should be handled by listening to the LOGIN_FAILURE event\n return;\n }).finally(() => {\n /*\n * If handleRedirectPromise returns a cached promise the necessary events may not be fired\n * This is a fallback to prevent inProgress from getting stuck in 'startup'\n */\n if (inProgressRef.current === InteractionStatus.Startup) {\n inProgressRef.current = InteractionStatus.None;\n setInProgress(InteractionStatus.None);\n }\n });\n\n return () => {\n if (callbackId) {\n logger.verbose(`MsalProvider - Removing event callback ${callbackId}`);\n instance.removeEventCallback(callbackId);\n }\n };\n }, [instance, logger]);\n\n const contextValue: IMsalContext = {\n instance,\n inProgress,\n accounts,\n logger\n };\n\n return (\n <MsalContext.Provider value={contextValue}>\n {children}\n </MsalContext.Provider>\n );\n}\n\n","/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { useContext } from \"react\";\nimport { IMsalContext, MsalContext } from \"../MsalContext\";\n\n/**\n * Returns Msal Context values\n */\nexport const useMsal = (): IMsalContext => useContext(MsalContext);\n","/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { useState, useEffect } from \"react\";\nimport { useMsal } from \"./useMsal\";\nimport { AccountIdentifiers } from \"../types/AccountIdentifiers\";\nimport { AccountInfo } from \"@azure/msal-browser\";\nimport { getAccountByIdentifiers } from \"../utils/utilities\";\n\nfunction isAuthenticated(allAccounts: AccountInfo[], matchAccount?: AccountIdentifiers): boolean {\n if(matchAccount && (matchAccount.username || matchAccount.homeAccountId || matchAccount.localAccountId)) {\n return !!getAccountByIdentifiers(allAccounts, matchAccount);\n } \n\n return allAccounts.length > 0;\n}\n\n/**\n * Returns whether or not a user is currently signed-in. Optionally provide 1 or more accountIdentifiers to determine if a specific user is signed-in\n * @param matchAccount \n */\nexport function useIsAuthenticated(matchAccount?: AccountIdentifiers): boolean {\n const { accounts: allAccounts } = useMsal();\n\n const [hasAuthenticated, setHasAuthenticated] = useState<boolean>(() => isAuthenticated(allAccounts, matchAccount));\n\n useEffect(() => {\n setHasAuthenticated(isAuthenticated(allAccounts, matchAccount));\n }, [allAccounts, matchAccount]);\n\n return hasAuthenticated;\n}\n","/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport React, { PropsWithChildren, useMemo } from \"react\";\nimport { AccountIdentifiers } from \"../types/AccountIdentifiers\";\nimport { getChildrenOrFunction } from \"../utils/utilities\";\nimport { useMsal } from \"../hooks/useMsal\";\nimport { useIsAuthenticated } from \"../hooks/useIsAuthenticated\";\nimport { InteractionStatus } from \"@azure/msal-browser\";\n\nexport type AuthenticatedTemplateProps = PropsWithChildren<AccountIdentifiers>;\n\n/**\n * Renders child components if user is authenticated\n * @param props \n */\nexport function AuthenticatedTemplate({ username, homeAccountId, localAccountId, children }: AuthenticatedTemplateProps): React.ReactElement|null {\n const context = useMsal();\n const accountIdentifier: AccountIdentifiers = useMemo(() => {\n return {\n username,\n homeAccountId,\n localAccountId\n };\n }, [username, homeAccountId, localAccountId]);\n const isAuthenticated = useIsAuthenticated(accountIdentifier);\n\n if (isAuthenticated && context.inProgress !== InteractionStatus.Startup) {\n return (\n <React.Fragment>\n {getChildrenOrFunction(children, context)}\n </React.Fragment>\n );\n }\n return null;\n}\n","/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport React, { PropsWithChildren, useMemo } from \"react\";\nimport { useMsal } from \"../hooks/useMsal\";\nimport { useIsAuthenticated } from \"../hooks/useIsAuthenticated\";\nimport { getChildrenOrFunction } from \"../utils/utilities\";\nimport { AccountIdentifiers } from \"../types/AccountIdentifiers\";\nimport { InteractionStatus } from \"@azure/msal-browser\";\n\nexport type UnauthenticatedTemplateProps = PropsWithChildren<AccountIdentifiers>;\n\n/**\n * Renders child components if user is unauthenticated\n * @param props \n */\nexport function UnauthenticatedTemplate({ username, homeAccountId, localAccountId, children }: UnauthenticatedTemplateProps): React.ReactElement|null {\n const context = useMsal();\n const accountIdentifier: AccountIdentifiers = useMemo(() => {\n return {\n username,\n homeAccountId,\n localAccountId\n };\n }, [username, homeAccountId, localAccountId]);\n const isAuthenticated = useIsAuthenticated(accountIdentifier);\n\n if (!isAuthenticated && context.inProgress !== InteractionStatus.Startup && context.inProgress !== InteractionStatus.HandleRedirect) {\n return (\n <React.Fragment>\n {getChildrenOrFunction(children, context)}\n </React.Fragment>\n );\n }\n return null;\n}\n","/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { useState, useEffect } from \"react\";\nimport { AccountInfo, IPublicClientApplication, AccountEntity } from \"@azure/msal-browser\";\nimport { useMsal } from \"./useMsal\";\nimport { AccountIdentifiers } from \"../types/AccountIdentifiers\";\nimport { getAccountByIdentifiers } from \"../utils/utilities\";\n\nfunction getAccount(instance: IPublicClientApplication, accountIdentifiers?: AccountIdentifiers): AccountInfo | null {\n if (!accountIdentifiers || (!accountIdentifiers.homeAccountId && !accountIdentifiers.localAccountId && !accountIdentifiers.username)) {\n // If no account identifiers are provided, return active account\n return instance.getActiveAccount();\n }\n\n return getAccountByIdentifiers(instance.getAllAccounts(), accountIdentifiers);\n}\n\n/**\n * Given 1 or more accountIdentifiers, returns the Account object if the user is signed-in\n * @param accountIdentifiers \n */\nexport function useAccount(accountIdentifiers?: AccountIdentifiers): AccountInfo | null {\n const { instance, inProgress, logger } = useMsal();\n\n const [account, setAccount] = useState<AccountInfo|null>(() => getAccount(instance, accountIdentifiers));\n\n useEffect(() => {\n setAccount((currentAccount: AccountInfo | null) => {\n const nextAccount = getAccount(instance, accountIdentifiers);\n if (!AccountEntity.accountInfoIsEqual(currentAccount, nextAccount, true)) {\n logger.info(\"useAccount - Updating account\");\n return nextAccount;\n }\n\n return currentAccount;\n });\n }, [inProgress, accountIdentifiers, instance, logger]);\n\n return account;\n}\n","/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { AuthError } from \"@azure/msal-browser\";\n\nexport const ReactAuthErrorMessage = {\n invalidInteractionType: {\n code: \"invalid_interaction_type\",\n desc: \"The provided interaction type is invalid.\"\n },\n unableToFallbackToInteraction: {\n code: \"unable_to_fallback_to_interaction\",\n desc: \"Interaction is required but another interaction is already in progress. Please try again when the current interaction is complete.\"\n }\n};\n\nexport class ReactAuthError extends AuthError {\n constructor(errorCode: string, errorMessage?: string) {\n super(errorCode, errorMessage);\n\n Object.setPrototypeOf(this, ReactAuthError.prototype);\n this.name = \"ReactAuthError\";\n }\n\n static createInvalidInteractionTypeError(): ReactAuthError {\n return new ReactAuthError(ReactAuthErrorMessage.invalidInteractionType.code, ReactAuthErrorMessage.invalidInteractionType.desc);\n }\n\n static createUnableToFallbackToInteractionError(): ReactAuthError {\n return new ReactAuthError(ReactAuthErrorMessage.unableToFallbackToInteraction.code, ReactAuthErrorMessage.unableToFallbackToInteraction.desc);\n }\n}\n","/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { useCallback, useEffect, useState, useRef } from \"react\";\nimport { PopupRequest, RedirectRequest, SsoSilentRequest, InteractionType, AuthenticationResult, AuthError, EventMessage, EventType, InteractionStatus, SilentRequest, InteractionRequiredAuthError, OIDC_DEFAULT_SCOPES } from \"@azure/msal-browser\";\nimport { useIsAuthenticated } from \"./useIsAuthenticated\";\nimport { AccountIdentifiers } from \"../types/AccountIdentifiers\";\nimport { useMsal } from \"./useMsal\";\nimport { useAccount } from \"./useAccount\";\nimport { ReactAuthError } from \"../error/ReactAuthError\";\n\nexport type MsalAuthenticationResult = {\n login: (callbackInteractionType?: InteractionType | undefined, callbackRequest?: PopupRequest | RedirectRequest | SilentRequest) => Promise<AuthenticationResult | null>; \n acquireToken: (callbackInteractionType?: InteractionType | undefined, callbackRequest?: SilentRequest | undefined) => Promise<AuthenticationResult | null>;\n result: AuthenticationResult|null;\n error: AuthError|null;\n};\n\n/**\n * If a user is not currently signed in this hook invokes a login. Failed logins can be retried using the login callback returned.\n * If a user is currently signed in this hook attempts to acquire a token. Subsequent token requests can use the acquireToken callback returned.\n * Optionally provide a request object to be used in the login/acquireToken call.\n * Optionally provide a specific user that should be logged in.\n * @param interactionType \n * @param authenticationRequest \n * @param accountIdentifiers \n */\nexport function useMsalAuthentication(\n interactionType: InteractionType, \n authenticationRequest?: PopupRequest|RedirectRequest|SsoSilentRequest, \n accountIdentifiers?: AccountIdentifiers\n): MsalAuthenticationResult {\n const { instance, inProgress, logger } = useMsal();\n const isAuthenticated = useIsAuthenticated(accountIdentifiers);\n const account = useAccount(accountIdentifiers);\n const [[result, error], setResponse] = useState<[AuthenticationResult|null, AuthError|null]>([null, null]);\n\n // Boolean used to check if interaction is in progress in acquireTokenSilent fallback. Use Ref instead of state to prevent acquireToken function from being regenerated on each change to interactionInProgress value\n const interactionInProgress = useRef(inProgress !== InteractionStatus.None);\n useEffect(() => {\n interactionInProgress.current = inProgress !== InteractionStatus.None;\n }, [inProgress]);\n\n // Flag used to control when the hook calls login/acquireToken\n const shouldAcquireToken = useRef(true);\n useEffect(() => {\n if (!!error) {\n // Errors should be handled by consuming component\n shouldAcquireToken.current = false;\n return;\n }\n\n if (!!result) {\n // Token has already been acquired, consuming component/application is responsible for renewing\n shouldAcquireToken.current = false;\n return;\n }\n }, [error, result]);\n\n const login = useCallback(async (callbackInteractionType?: InteractionType, callbackRequest?: PopupRequest|RedirectRequest|SsoSilentRequest): Promise<AuthenticationResult|null> => {\n const loginType = callbackInteractionType || interactionType;\n const loginRequest = callbackRequest || authenticationRequest;\n switch (loginType) {\n case InteractionType.Popup:\n logger.verbose(\"useMsalAuthentication - Calling loginPopup\");\n return instance.loginPopup(loginRequest as PopupRequest);\n case InteractionType.Redirect:\n // This promise is not expected to resolve due to full frame redirect\n logger.verbose(\"useMsalAuthentication - Calling loginRedirect\");\n return instance.loginRedirect(loginRequest as RedirectRequest).then(null);\n case InteractionType.Silent:\n logger.verbose(\"useMsalAuthentication - Calling ssoSilent\");\n return instance.ssoSilent(loginRequest as SsoSilentRequest);\n default:\n throw ReactAuthError.createInvalidInteractionTypeError();\n }\n }, [instance, interactionType, authenticationRequest, logger]);\n\n const acquireToken = useCallback(async (callbackInteractionType?: InteractionType, callbackRequest?: SilentRequest): Promise<AuthenticationResult|null> => {\n const fallbackInteractionType = callbackInteractionType || interactionType;\n\n let tokenRequest: SilentRequest;\n\n if (callbackRequest) {\n logger.trace(\"useMsalAuthentication - acquireToken - Using request provided in the callback\");\n tokenRequest = {\n ...callbackRequest\n };\n } else if (authenticationRequest) {\n logger.trace(\"useMsalAuthentication - acquireToken - Using request provided in the hook\");\n tokenRequest = {\n ...authenticationRequest,\n scopes: authenticationRequest.scopes || OIDC_DEFAULT_SCOPES\n };\n } else {\n logger.trace(\"useMsalAuthentication - acquireToken - No request object provided, using default request.\");\n tokenRequest = {\n scopes: OIDC_DEFAULT_SCOPES\n };\n }\n \n if (!tokenRequest.account && account) {\n logger.trace(\"useMsalAuthentication - acquireToken - Attaching account to request\");\n tokenRequest.account = account;\n }\n\n const getToken = async (): Promise<AuthenticationResult|null> => {\n logger.verbose(\"useMsalAuthentication - Calling acquireTokenSilent\");\n return instance.acquireTokenSilent(tokenRequest).catch(async (e: AuthError) => {\n if (e instanceof InteractionRequiredAuthError) {\n if (!interactionInProgress.current) {\n logger.error(\"useMsalAuthentication - Interaction required, falling back to interaction\");\n return login(fallbackInteractionType, tokenRequest);\n } else {\n logger.error(\"useMsalAuthentication - Interaction required but is already in progress. Please try again, if needed, after interaction completes.\");\n throw ReactAuthError.createUnableToFallbackToInteractionError();\n }\n }\n\n throw e;\n });\n };\n\n return getToken().then((response: AuthenticationResult|null) => {\n setResponse([response, null]);\n return response;\n }).catch((e: AuthError) => {\n setResponse([null, e]);\n throw e;\n });\n }, [instance, interactionType, authenticationRequest, logger, account, login]);\n\n useEffect(() => {\n const callbackId = instance.addEventCallback((message: EventMessage) => {\n switch(message.eventType) {\n case EventType.LOGIN_SUCCESS:\n case EventType.SSO_SILENT_SUCCESS:\n if (message.payload) {\n setResponse([message.payload as AuthenticationResult, null]);\n }\n break;\n case EventType.LOGIN_FAILURE:\n case EventType.SSO_SILENT_FAILURE:\n if (message.error) {\n setResponse([null, message.error as AuthError]);\n }\n break;\n }\n });\n logger.verbose(`useMsalAuthentication - Registered event callback with id: ${callbackId}`);\n\n return () => {\n if (callbackId) {\n logger.verbose(`useMsalAuthentication - Removing event callback ${callbackId}`);\n instance.removeEventCallback(callbackId);\n }\n };\n }, [instance, logger]);\n\n useEffect(() => {\n if (shouldAcquireToken.current && inProgress === InteractionStatus.None) {\n shouldAcquireToken.current = false;\n if (!isAuthenticated) {\n logger.info(\"useMsalAuthentication - No user is authenticated, attempting to login\");\n login().catch(() => {\n // Errors are saved in state above\n return;\n });\n } else if (account) {\n logger.info(\"useMsalAuthentication - User is authenticated, attempting to acquire token\");\n acquireToken().catch(() => {\n // Errors are saved in state above\n return;\n });\n }\n }\n }, [isAuthenticated, account, inProgress, login, acquireToken, logger]);\n\n return { \n login, \n acquireToken, \n result, \n error\n };\n}\n","/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport React, { PropsWithChildren, useMemo } from \"react\";\nimport { AccountIdentifiers } from \"../types/AccountIdentifiers\";\nimport { getChildrenOrFunction } from \"../utils/utilities\";\nimport { useMsal } from \"../hooks/useMsal\";\nimport { MsalAuthenticationResult, useMsalAuthentication } from \"../hooks/useMsalAuthentication\";\nimport { useIsAuthenticated } from \"../hooks/useIsAuthenticated\";\nimport { InteractionType, PopupRequest, RedirectRequest, SsoSilentRequest, InteractionStatus } from \"@azure/msal-browser\";\nimport { IMsalContext } from \"../MsalContext\";\n\nexport type MsalAuthenticationProps = PropsWithChildren<AccountIdentifiers & {\n interactionType: InteractionType;\n authenticationRequest?: PopupRequest|RedirectRequest|SsoSilentRequest;\n loadingComponent?: React.ElementType<IMsalContext>;\n errorComponent?: React.ElementType<MsalAuthenticationResult>;\n}>;\n\n/**\n * Attempts to authenticate user if not already authenticated, then renders child components\n * @param props\n */\nexport function MsalAuthenticationTemplate({ \n interactionType, \n username, \n homeAccountId, \n localAccountId,\n authenticationRequest, \n loadingComponent: LoadingComponent,\n errorComponent: ErrorComponent,\n children \n}: MsalAuthenticationProps): React.ReactElement|null {\n const accountIdentifier: AccountIdentifiers = useMemo(() => {\n return {\n username,\n homeAccountId,\n localAccountId\n };\n }, [username, homeAccountId, localAccountId]);\n const context = useMsal();\n const msalAuthResult = useMsalAuthentication(interactionType, authenticationRequest, accountIdentifier);\n const isAuthenticated = useIsAuthenticated(accountIdentifier);\n\n if (msalAuthResult.error && context.inProgress === InteractionStatus.None) {\n if (!!ErrorComponent) {\n return <ErrorComponent {...msalAuthResult} />;\n }\n\n throw msalAuthResult.error;\n }\n \n if (isAuthenticated) {\n return (\n <React.Fragment>\n {getChildrenOrFunction(children, msalAuthResult)}\n </React.Fragment>\n );\n } \n \n if (!!LoadingComponent && context.inProgress !== InteractionStatus.None) {\n return <LoadingComponent {...context} />;\n }\n\n return null;\n}\n","/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport React from \"react\";\nimport { IMsalContext } from \"../MsalContext\";\nimport { useMsal } from \"../hooks/useMsal\";\nimport { Subtract } from \"../utils/utilities\";\n\nexport type WithMsalProps = {\n msalContext: IMsalContext;\n};\n\n/**\n * Higher order component wraps provided component with msal by injecting msal context values into the component's props \n * @param Component \n */\nexport const withMsal = <P extends WithMsalProps>(Component: React.ComponentType<P>): React.FunctionComponent<Subtract<P,WithMsalProps>> => {\n const ComponentWithMsal: React.FunctionComponent<Subtract<P,WithMsalProps>> = props => {\n const msal = useMsal();\n return <Component {...(props as P)} msalContext={msal} />;\n };\n\n const componentName =\n Component.displayName || Component.name || \"Component\";\n ComponentWithMsal.displayName = `withMsal(${componentName})`;\n\n return ComponentWithMsal;\n};\n"],"names":["defaultMsalContext","instance","stubbedPublicClientApplication","inProgress","InteractionStatus","None","accounts","logger","Logger","MsalContext","React","MsalConsumer","Consumer","getChildrenOrFunction","children","args","accountArraysAreEqual","arrayA","arrayB","length","comparisonArray","every","elementA","elementB","shift","homeAccountId","localAccountId","username","getAccountByIdentifiers","allAccounts","accountIdentifiers","matchedAccounts","filter","accountObj","toLowerCase","name","version","MsalProvider","useEffect","initializeWrapperLibrary","WrapperSKU","useMemo","getLogger","clone","SKU","setAccounts","useState","getAllAccounts","setInProgress","Startup","inProgressRef","useRef","callbackId","addEventCallback","message","eventType","EventType","ACCOUNT_ADDED","ACCOUNT_REMOVED","LOGIN_SUCCESS","SSO_SILENT_SUCCESS","HANDLE_REDIRECT_END","LOGIN_FAILURE","SSO_SILENT_FAILURE","LOGOUT_END","ACQUIRE_TOKEN_SUCCESS","ACQUIRE_TOKEN_FAILURE","currentAccounts","info","verbose","removeEventCallback","status","EventMessageUtils","getInteractionStatusFromEvent","current","handleRedirectPromise","catch","finally","contextValue","Provider","value","useMsal","useContext","isAuthenticated","matchAccount","useIsAuthenticated","hasAuthenticated","setHasAuthenticated","AuthenticatedTemplate","context","accountIdentifier","Fragment","UnauthenticatedTemplate","HandleRedirect","getAccount","getActiveAccount","useAccount","account","setAccount","currentAccount","nextAccount","AccountEntity","accountInfoIsEqual","ReactAuthErrorMessage","invalidInteractionType","code","desc","unableToFallbackToInteraction","ReactAuthError","AuthError","constructor","errorCode","errorMessage","Object","setPrototypeOf","prototype","createInvalidInteractionTypeError","createUnableToFallbackToInteractionError","useMsalAuthentication","interactionType","authenticationRequest","result","error","setResponse","interactionInProgress","shouldAcquireToken","login","useCallback","callbackInteractionType","callbackRequest","loginType","loginRequest","InteractionType","Popup","loginPopup","Redirect","loginRedirect","then","Silent","ssoSilent","acquireToken","fallbackInteractionType","tokenRequest","trace","scopes","OIDC_DEFAULT_SCOPES","getToken","acquireTokenSilent","e","InteractionRequiredAuthError","response","payload","MsalAuthenticationTemplate","loadingComponent","LoadingComponent","errorComponent","ErrorComponent","msalAuthResult","withMsal","Component","ComponentWithMsal","props","msal","msalContext","componentName","displayName"],"mappings":";;;;;;;;;;AAAA;;;;AAeA;;;;;AAIA,MAAMA,kBAAkB,GAAiB;AACrCC,EAAAA,QAAQ,EAAEC,0CAD2B;AAErCC,EAAAA,UAAU,EAAEC,6BAAiB,CAACC,IAFO;AAGrCC,EAAAA,QAAQ,EAAE,EAH2B;AAIrCC,EAAAA,MAAM,eAAE,IAAIC,kBAAJ,CAAW,EAAX;AAJ6B,CAAzC;MAOaC,WAAW,gBAAGC,mBAAA,CACvBV,kBADuB;MAGdW,YAAY,GAAGF,WAAW,CAACG;;AC7BxC;;;;AAUA,SAAgBC,sBACZC,UACAC;AAEA,MAAI,OAAOD,QAAP,KAAoB,UAAxB,EAAoC;AAChC,WAAOA,QAAQ,CAACC,IAAD,CAAf;AACH;;AACD,SAAOD,QAAP;AACH;AAUD;;;;;;;AAMA,SAAgBE,sBAAsBC,QAAm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