@azure/msal-react 1.2.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.
@@ -1,5 +1,5 @@
1
1
  import React__default, { createContext, useEffect, useMemo, useState, useRef, useContext, useCallback } from 'react';
2
- import { stubbedPublicClientApplication, InteractionStatus, Logger, WrapperSKU, EventType, EventMessageUtils, AccountEntity, InteractionType } from '@azure/msal-browser';
2
+ import { stubbedPublicClientApplication, InteractionStatus, Logger, WrapperSKU, EventType, EventMessageUtils, AccountEntity, AuthError, InteractionType, InteractionRequiredAuthError, OIDC_DEFAULT_SCOPES } from '@azure/msal-browser';
3
3
 
4
4
  /*
5
5
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -53,10 +53,32 @@ function accountArraysAreEqual(arrayA, arrayB) {
53
53
  return elementA.homeAccountId === elementB.homeAccountId && elementA.localAccountId === elementB.localAccountId && elementA.username === elementB.username;
54
54
  });
55
55
  }
56
+ function getAccountByIdentifiers(allAccounts, accountIdentifiers) {
57
+ if (allAccounts.length > 0 && (accountIdentifiers.homeAccountId || accountIdentifiers.localAccountId || accountIdentifiers.username)) {
58
+ const matchedAccounts = allAccounts.filter(accountObj => {
59
+ if (accountIdentifiers.username && accountIdentifiers.username.toLowerCase() !== accountObj.username.toLowerCase()) {
60
+ return false;
61
+ }
62
+
63
+ if (accountIdentifiers.homeAccountId && accountIdentifiers.homeAccountId.toLowerCase() !== accountObj.homeAccountId.toLowerCase()) {
64
+ return false;
65
+ }
66
+
67
+ if (accountIdentifiers.localAccountId && accountIdentifiers.localAccountId.toLowerCase() !== accountObj.localAccountId.toLowerCase()) {
68
+ return false;
69
+ }
70
+
71
+ return true;
72
+ });
73
+ return matchedAccounts[0] || null;
74
+ } else {
75
+ return null;
76
+ }
77
+ }
56
78
 
57
79
  /* eslint-disable header/header */
58
80
  const name = "@azure/msal-react";
59
- const version = "1.2.0";
81
+ const version = "1.3.0";
60
82
 
61
83
  /*
62
84
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -74,7 +96,7 @@ function MsalProvider({
74
96
  return instance.getLogger().clone(name, version);
75
97
  }, [instance]); // State hook to store accounts
76
98
 
77
- const [accounts, setAccounts] = useState([]); // State hook to store in progress value
99
+ const [accounts, setAccounts] = useState(() => instance.getAllAccounts()); // State hook to store in progress value
78
100
 
79
101
  const [inProgress, setInProgress] = useState(InteractionStatus.Startup); // Mutable object used in the event callback
80
102
 
@@ -170,61 +192,9 @@ const useMsal = () => useContext(MsalContext);
170
192
  * Licensed under the MIT License.
171
193
  */
172
194
 
173
- function getAccount(instance, accountIdentifiers) {
174
- const allAccounts = instance.getAllAccounts();
175
-
176
- if (allAccounts.length > 0 && (accountIdentifiers.homeAccountId || accountIdentifiers.localAccountId || accountIdentifiers.username)) {
177
- const matchedAccounts = allAccounts.filter(accountObj => {
178
- if (accountIdentifiers.username && accountIdentifiers.username.toLowerCase() !== accountObj.username.toLowerCase()) {
179
- return false;
180
- }
181
-
182
- if (accountIdentifiers.homeAccountId && accountIdentifiers.homeAccountId.toLowerCase() !== accountObj.homeAccountId.toLowerCase()) {
183
- return false;
184
- }
185
-
186
- if (accountIdentifiers.localAccountId && accountIdentifiers.localAccountId.toLowerCase() !== accountObj.localAccountId.toLowerCase()) {
187
- return false;
188
- }
189
-
190
- return true;
191
- });
192
- return matchedAccounts[0] || null;
193
- } else {
194
- return null;
195
- }
196
- }
197
- /**
198
- * Given 1 or more accountIdentifiers, returns the Account object if the user is signed-in
199
- * @param accountIdentifiers
200
- */
201
-
202
-
203
- function useAccount(accountIdentifiers) {
204
- const {
205
- instance,
206
- inProgress
207
- } = useMsal();
208
- const initialStateValue = inProgress === InteractionStatus.Startup ? null : getAccount(instance, accountIdentifiers);
209
- const [account, setAccount] = useState(initialStateValue);
210
- useEffect(() => {
211
- const currentAccount = getAccount(instance, accountIdentifiers);
212
-
213
- if (!AccountEntity.accountInfoIsEqual(account, currentAccount, true)) {
214
- setAccount(currentAccount);
215
- }
216
- }, [inProgress, accountIdentifiers, instance, account]);
217
- return account;
218
- }
219
-
220
- /*
221
- * Copyright (c) Microsoft Corporation. All rights reserved.
222
- * Licensed under the MIT License.
223
- */
224
-
225
- function isAuthenticated(allAccounts, account, matchAccount) {
195
+ function isAuthenticated(allAccounts, matchAccount) {
226
196
  if (matchAccount && (matchAccount.username || matchAccount.homeAccountId || matchAccount.localAccountId)) {
227
- return !!account;
197
+ return !!getAccountByIdentifiers(allAccounts, matchAccount);
228
198
  }
229
199
 
230
200
  return allAccounts.length > 0;
@@ -237,15 +207,12 @@ function isAuthenticated(allAccounts, account, matchAccount) {
237
207
 
238
208
  function useIsAuthenticated(matchAccount) {
239
209
  const {
240
- accounts: allAccounts,
241
- inProgress
210
+ accounts: allAccounts
242
211
  } = useMsal();
243
- const account = useAccount(matchAccount || {});
244
- const initialStateValue = inProgress === InteractionStatus.Startup ? false : isAuthenticated(allAccounts, account, matchAccount);
245
- const [hasAuthenticated, setHasAuthenticated] = useState(initialStateValue);
212
+ const [hasAuthenticated, setHasAuthenticated] = useState(() => isAuthenticated(allAccounts, matchAccount));
246
213
  useEffect(() => {
247
- setHasAuthenticated(isAuthenticated(allAccounts, account, matchAccount));
248
- }, [allAccounts, account, matchAccount]);
214
+ setHasAuthenticated(isAuthenticated(allAccounts, matchAccount));
215
+ }, [allAccounts, matchAccount]);
249
216
  return hasAuthenticated;
250
217
  }
251
218
 
@@ -317,9 +284,82 @@ function UnauthenticatedTemplate({
317
284
  * Copyright (c) Microsoft Corporation. All rights reserved.
318
285
  * Licensed under the MIT License.
319
286
  */
287
+
288
+ function getAccount(instance, accountIdentifiers) {
289
+ if (!accountIdentifiers || !accountIdentifiers.homeAccountId && !accountIdentifiers.localAccountId && !accountIdentifiers.username) {
290
+ // If no account identifiers are provided, return active account
291
+ return instance.getActiveAccount();
292
+ }
293
+
294
+ return getAccountByIdentifiers(instance.getAllAccounts(), accountIdentifiers);
295
+ }
320
296
  /**
321
- * Invokes a login call if a user is not currently signed-in. Failed logins can be retried using the login callback returned.
322
- * Optionally provide a request object to be used in the login call.
297
+ * Given 1 or more accountIdentifiers, returns the Account object if the user is signed-in
298
+ * @param accountIdentifiers
299
+ */
300
+
301
+
302
+ function useAccount(accountIdentifiers) {
303
+ const {
304
+ instance,
305
+ inProgress,
306
+ logger
307
+ } = useMsal();
308
+ const [account, setAccount] = useState(() => getAccount(instance, accountIdentifiers));
309
+ useEffect(() => {
310
+ setAccount(currentAccount => {
311
+ const nextAccount = getAccount(instance, accountIdentifiers);
312
+
313
+ if (!AccountEntity.accountInfoIsEqual(currentAccount, nextAccount, true)) {
314
+ logger.info("useAccount - Updating account");
315
+ return nextAccount;
316
+ }
317
+
318
+ return currentAccount;
319
+ });
320
+ }, [inProgress, accountIdentifiers, instance, logger]);
321
+ return account;
322
+ }
323
+
324
+ /*
325
+ * Copyright (c) Microsoft Corporation. All rights reserved.
326
+ * Licensed under the MIT License.
327
+ */
328
+ const ReactAuthErrorMessage = {
329
+ invalidInteractionType: {
330
+ code: "invalid_interaction_type",
331
+ desc: "The provided interaction type is invalid."
332
+ },
333
+ unableToFallbackToInteraction: {
334
+ code: "unable_to_fallback_to_interaction",
335
+ desc: "Interaction is required but another interaction is already in progress. Please try again when the current interaction is complete."
336
+ }
337
+ };
338
+ class ReactAuthError extends AuthError {
339
+ constructor(errorCode, errorMessage) {
340
+ super(errorCode, errorMessage);
341
+ Object.setPrototypeOf(this, ReactAuthError.prototype);
342
+ this.name = "ReactAuthError";
343
+ }
344
+
345
+ static createInvalidInteractionTypeError() {
346
+ return new ReactAuthError(ReactAuthErrorMessage.invalidInteractionType.code, ReactAuthErrorMessage.invalidInteractionType.desc);
347
+ }
348
+
349
+ static createUnableToFallbackToInteractionError() {
350
+ return new ReactAuthError(ReactAuthErrorMessage.unableToFallbackToInteraction.code, ReactAuthErrorMessage.unableToFallbackToInteraction.desc);
351
+ }
352
+
353
+ }
354
+
355
+ /*
356
+ * Copyright (c) Microsoft Corporation. All rights reserved.
357
+ * Licensed under the MIT License.
358
+ */
359
+ /**
360
+ * If a user is not currently signed in this hook invokes a login. Failed logins can be retried using the login callback returned.
361
+ * If a user is currently signed in this hook attempts to acquire a token. Subsequent token requests can use the acquireToken callback returned.
362
+ * Optionally provide a request object to be used in the login/acquireToken call.
323
363
  * Optionally provide a specific user that should be logged in.
324
364
  * @param interactionType
325
365
  * @param authenticationRequest
@@ -333,8 +373,28 @@ function useMsalAuthentication(interactionType, authenticationRequest, accountId
333
373
  logger
334
374
  } = useMsal();
335
375
  const isAuthenticated = useIsAuthenticated(accountIdentifiers);
336
- const [[result, error], setResponse] = useState([null, null]);
337
- const [hasBeenCalled, setHasBeenCalled] = useState(false);
376
+ const account = useAccount(accountIdentifiers);
377
+ const [[result, error], setResponse] = 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
378
+
379
+ const interactionInProgress = useRef(inProgress !== InteractionStatus.None);
380
+ useEffect(() => {
381
+ interactionInProgress.current = inProgress !== InteractionStatus.None;
382
+ }, [inProgress]); // Flag used to control when the hook calls login/acquireToken
383
+
384
+ const shouldAcquireToken = useRef(true);
385
+ useEffect(() => {
386
+ if (!!error) {
387
+ // Errors should be handled by consuming component
388
+ shouldAcquireToken.current = false;
389
+ return;
390
+ }
391
+
392
+ if (!!result) {
393
+ // Token has already been acquired, consuming component/application is responsible for renewing
394
+ shouldAcquireToken.current = false;
395
+ return;
396
+ }
397
+ }, [error, result]);
338
398
  const login = useCallback(async (callbackInteractionType, callbackRequest) => {
339
399
  const loginType = callbackInteractionType || interactionType;
340
400
  const loginRequest = callbackRequest || authenticationRequest;
@@ -354,9 +414,59 @@ function useMsalAuthentication(interactionType, authenticationRequest, accountId
354
414
  return instance.ssoSilent(loginRequest);
355
415
 
356
416
  default:
357
- throw "Invalid interaction type provided.";
417
+ throw ReactAuthError.createInvalidInteractionTypeError();
358
418
  }
359
419
  }, [instance, interactionType, authenticationRequest, logger]);
420
+ const acquireToken = useCallback(async (callbackInteractionType, callbackRequest) => {
421
+ const fallbackInteractionType = callbackInteractionType || interactionType;
422
+ let tokenRequest;
423
+
424
+ if (callbackRequest) {
425
+ logger.trace("useMsalAuthentication - acquireToken - Using request provided in the callback");
426
+ tokenRequest = { ...callbackRequest
427
+ };
428
+ } else if (authenticationRequest) {
429
+ logger.trace("useMsalAuthentication - acquireToken - Using request provided in the hook");
430
+ tokenRequest = { ...authenticationRequest,
431
+ scopes: authenticationRequest.scopes || OIDC_DEFAULT_SCOPES
432
+ };
433
+ } else {
434
+ logger.trace("useMsalAuthentication - acquireToken - No request object provided, using default request.");
435
+ tokenRequest = {
436
+ scopes: OIDC_DEFAULT_SCOPES
437
+ };
438
+ }
439
+
440
+ if (!tokenRequest.account && account) {
441
+ logger.trace("useMsalAuthentication - acquireToken - Attaching account to request");
442
+ tokenRequest.account = account;
443
+ }
444
+
445
+ const getToken = async () => {
446
+ logger.verbose("useMsalAuthentication - Calling acquireTokenSilent");
447
+ return instance.acquireTokenSilent(tokenRequest).catch(async e => {
448
+ if (e instanceof InteractionRequiredAuthError) {
449
+ if (!interactionInProgress.current) {
450
+ logger.error("useMsalAuthentication - Interaction required, falling back to interaction");
451
+ return login(fallbackInteractionType, tokenRequest);
452
+ } else {
453
+ logger.error("useMsalAuthentication - Interaction required but is already in progress. Please try again, if needed, after interaction completes.");
454
+ throw ReactAuthError.createUnableToFallbackToInteractionError();
455
+ }
456
+ }
457
+
458
+ throw e;
459
+ });
460
+ };
461
+
462
+ return getToken().then(response => {
463
+ setResponse([response, null]);
464
+ return response;
465
+ }).catch(e => {
466
+ setResponse([null, e]);
467
+ throw e;
468
+ });
469
+ }, [instance, interactionType, authenticationRequest, logger, account, login]);
360
470
  useEffect(() => {
361
471
  const callbackId = instance.addEventCallback(message => {
362
472
  switch (message.eventType) {
@@ -386,18 +496,27 @@ function useMsalAuthentication(interactionType, authenticationRequest, accountId
386
496
  };
387
497
  }, [instance, logger]);
388
498
  useEffect(() => {
389
- if (!hasBeenCalled && !error && !isAuthenticated && inProgress === InteractionStatus.None) {
390
- logger.info("useMsalAuthentication - No user is authenticated, attempting to login"); // Ensure login is only called one time from within this hook, any subsequent login attempts should use the callback returned
391
-
392
- setHasBeenCalled(true);
393
- login().catch(() => {
394
- // Errors are handled by the event handler above
395
- return;
396
- });
499
+ if (shouldAcquireToken.current && inProgress === InteractionStatus.None) {
500
+ shouldAcquireToken.current = false;
501
+
502
+ if (!isAuthenticated) {
503
+ logger.info("useMsalAuthentication - No user is authenticated, attempting to login");
504
+ login().catch(() => {
505
+ // Errors are saved in state above
506
+ return;
507
+ });
508
+ } else if (account) {
509
+ logger.info("useMsalAuthentication - User is authenticated, attempting to acquire token");
510
+ acquireToken().catch(() => {
511
+ // Errors are saved in state above
512
+ return;
513
+ });
514
+ }
397
515
  }
398
- }, [isAuthenticated, inProgress, error, hasBeenCalled, login, logger]);
516
+ }, [isAuthenticated, account, inProgress, login, acquireToken, logger]);
399
517
  return {
400
518
  login,
519
+ acquireToken,
401
520
  result,
402
521
  error
403
522
  };
@@ -1 +1 @@
1
- {"version":3,"file":"msal-react.esm.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":["/*\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\";\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","/* eslint-disable header/header */\nexport const name = \"@azure/msal-react\";\nexport const version = \"1.2.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[]>([]);\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 { AccountInfo, IPublicClientApplication, InteractionStatus, AccountEntity } from \"@azure/msal-browser\";\nimport { useMsal } from \"./useMsal\";\nimport { AccountIdentifiers } from \"../types/AccountIdentifiers\";\n\nfunction getAccount(instance: IPublicClientApplication, accountIdentifiers: AccountIdentifiers): AccountInfo | null {\n const allAccounts = instance.getAllAccounts();\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\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 } = useMsal();\n\n const initialStateValue = inProgress === InteractionStatus.Startup ? null : getAccount(instance, accountIdentifiers);\n const [account, setAccount] = useState<AccountInfo|null>(initialStateValue);\n\n useEffect(() => {\n const currentAccount = getAccount(instance, accountIdentifiers);\n if (!AccountEntity.accountInfoIsEqual(account, currentAccount, true)) {\n setAccount(currentAccount);\n }\n }, [inProgress, accountIdentifiers, instance, account]);\n\n return account;\n}\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 { useAccount } from \"./useAccount\";\nimport { AccountInfo, InteractionStatus } from \"@azure/msal-browser\";\n\nfunction isAuthenticated(allAccounts: AccountIdentifiers[], account: AccountInfo | null, matchAccount?: AccountIdentifiers): boolean {\n if(matchAccount && (matchAccount.username || matchAccount.homeAccountId || matchAccount.localAccountId)) {\n return !!account;\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, inProgress } = useMsal();\n const account = useAccount(matchAccount || {});\n\n const initialStateValue = inProgress === InteractionStatus.Startup ? false : isAuthenticated(allAccounts, account, matchAccount);\n const [hasAuthenticated, setHasAuthenticated] = useState<boolean>(initialStateValue);\n\n useEffect(() => {\n setHasAuthenticated(isAuthenticated(allAccounts, account, matchAccount));\n }, [allAccounts, account, 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 { useCallback, useEffect, useState } from \"react\";\nimport { PopupRequest, RedirectRequest, SsoSilentRequest, InteractionType, AuthenticationResult, AuthError, EventMessage, EventType, InteractionStatus } from \"@azure/msal-browser\";\nimport { useIsAuthenticated } from \"./useIsAuthenticated\";\nimport { AccountIdentifiers } from \"../types/AccountIdentifiers\";\nimport { useMsal } from \"./useMsal\";\n\nexport type MsalAuthenticationResult = {\n login: Function; \n result: AuthenticationResult|null;\n error: AuthError|null;\n};\n\n/**\n * Invokes a login call if a user is not currently signed-in. Failed logins can be retried using the login callback returned.\n * Optionally provide a request object to be used in the login 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 [[result, error], setResponse] = useState<[AuthenticationResult|null, AuthError|null]>([null, null]);\n const [hasBeenCalled, setHasBeenCalled] = useState<boolean>(false);\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 \"Invalid interaction type provided.\";\n }\n }, [instance, interactionType, authenticationRequest, logger]);\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 (!hasBeenCalled && !error && !isAuthenticated && inProgress === InteractionStatus.None) {\n logger.info(\"useMsalAuthentication - No user is authenticated, attempting to login\");\n // Ensure login is only called one time from within this hook, any subsequent login attempts should use the callback returned\n setHasBeenCalled(true);\n login().catch(() => {\n // Errors are handled by the event handler above\n return;\n });\n }\n }, [isAuthenticated, inProgress, error, hasBeenCalled, login, logger]);\n\n return { login, result, error };\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","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","finally","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,8BAD2B;AAErCC,EAAAA,UAAU,EAAEC,iBAAiB,CAACC,IAFO;AAGrCC,EAAAA,QAAQ,EAAE,EAH2B;AAIrCC,EAAAA,MAAM,eAAE,IAAIC,MAAJ,CAAW,EAAX;AAJ6B,CAAzC;MAOaC,WAAW,gBAAGC,aAAA,CACvBV,kBADuB;MAGdW,YAAY,GAAGF,WAAW,CAACG;;AC7BxC;;;;AASA,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,QAAmCC;AACrE,MAAID,MAAM,CAACE,MAAP,KAAkBD,MAAM,CAACC,MAA7B,EAAqC;AACjC,WAAO,KAAP;AACH;;AAED,QAAMC,eAAe,GAAG,CAAC,GAAGF,MAAJ,CAAxB;AAEA,SAAOD,MAAM,CAACI,KAAP,CAAcC,QAAD;AAChB,UAAMC,QAAQ,GAAGH,eAAe,CAACI,KAAhB,EAAjB;;AACA,QAAI,CAACF,QAAD,IAAa,CAACC,QAAlB,EAA4B;AACxB,aAAO,KAAP;AACH;;AAED,WAAQD,QAAQ,CAACG,aAAT,KAA2BF,QAAQ,CAACE,aAArC,IACCH,QAAQ,CAACI,cAAT,KAA4BH,QAAQ,CAACG,cADtC,IAECJ,QAAQ,CAACK,QAAT,KAAsBJ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AACH,GAHD;;AAKA,QAAME,aAAa,GACfL,SAAS,CAACM,WAAV,IAAyBN,SAAS,CAACvG,IAAnC,IAA2C,WAD/C;AAEAwG,EAAAA,iBAAiB,CAACK,WAAlB,eAA4CD,gBAA5C;AAEA,SAAOJ,iBAAP;AACH,CAXM;;;;"}
1
+ {"version":3,"file":"msal-react.esm.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,8BAD2B;AAErCC,EAAAA,UAAU,EAAEC,iBAAiB,CAACC,IAFO;AAGrCC,EAAAA,QAAQ,EAAE,EAH2B;AAIrCC,EAAAA,MAAM,eAAE,IAAIC,MAAJ,CAAW,EAAX;AAJ6B,CAAzC;MAOaC,WAAW,gBAAGC,aAAA,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,QAAmCC;AACrE,MAAID,MAAM,CAACE,MAAP,KAAkBD,MAAM,CAACC,MAA7B,EAAqC;AACjC,WAAO,KAAP;AACH;;AAED,QAAMC,eAAe,GAAG,CAAC,GAAGF,MAAJ,CAAxB;AAEA,SAAOD,MAAM,CAACI,KAAP,CAAcC,QAAD;AAChB,UAAMC,QAAQ,GAAGH,eAAe,CAACI,KAAhB,EAAjB;;AACA,QAAI,CAACF,QAAD,IAAa,CAACC,QAAlB,EAA4B;AACxB,aAAO,KAAP;AACH;;AAED,WAAQD,QAAQ,CAACG,aAAT,KAA2BF,QAAQ,CAACE,aAArC,IACCH,QAAQ,CAACI,cAAT,KAA4BH,QAAQ,CAACG,cADtC,IAECJ,QAAQ,CAACK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AqB,CAACC,eAAD,EAAkBC,qBAAlB,EAAyC9B,iBAAzC,CAA5C;AACA,QAAMP,eAAe,GAAGE,kBAAkB,CAACK,iBAAD,CAA1C;;AAEA,MAAImE,cAAc,CAACnC,KAAf,IAAwBjC,OAAO,CAACtF,UAAR,KAAuBC,iBAAiB,CAACC,IAArE,EAA2E;AACvE,QAAI,CAAC,CAACuJ,cAAN,EAAsB;AAClB,aAAOlJ,4BAAA,CAACkJ,cAAD,oBAAoBC,eAApB,CAAP;AACH;;AAED,UAAMA,cAAc,CAACnC,KAArB;AACH;;AAED,MAAIvC,eAAJ,EAAqB;AACjB,WACIzE,4BAAA,CAACA,cAAK,CAACiF,QAAP,MAAA,EACK9E,qBAAqB,CAACC,QAAD,EAAW+I,cAAX,CAD1B,CADJ;AAKH;;AAED,MAAI,CAAC,CAACH,gBAAF,IAAsBjE,OAAO,CAACtF,UAAR,KAAuBC,iBAAiB,CAACC,IAAnE,EAAyE;AACrE,WAAOK,4BAAA,CAACgJ,gBAAD,oBAAsBjE,QAAtB,CAAP;AACH;;AAED,SAAO,IAAP;AACH;;ACnED;;;;AAKA,AASA;;;;;AAIA,MAAaqE,QAAQ,GAA6BC,SAA1B;AACpB,QAAMC,iBAAiB,GAAuDC,KAAK;AAC/E,UAAMC,IAAI,GAAGjF,OAAO,EAApB;AACA,WAAOvE,4BAAA,CAACqJ,SAAD,oBAAgBE;AAAaE,MAAAA,WAAW,EAAED;MAA1C,CAAP;AACH,GAHD;;AAKA,QAAME,aAAa,GACfL,SAAS,CAACM,WAAV,IAAyBN,SAAS,CAAC5H,IAAnC,IAA2C,WAD/C;AAEA6H,EAAAA,iBAAiB,CAACK,WAAlB,eAA4CD,gBAA5C;AAEA,SAAOJ,iBAAP;AACH,CAXM;;;;"}
@@ -1,2 +1,2 @@
1
1
  export declare const name = "@azure/msal-react";
2
- export declare const version = "1.2.0";
2
+ export declare const version = "1.3.0";
@@ -1,5 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { AccountIdentifiers } from "../types/AccountIdentifiers";
3
+ import { AccountInfo } from "@azure/msal-browser";
3
4
  declare type FaaCFunction = <T>(args: T) => React.ReactNode;
4
5
  export declare function getChildrenOrFunction<T>(children: React.ReactNode | FaaCFunction, args: T): React.ReactNode;
5
6
  declare type SetDifference<A, B> = A extends B ? never : A;
@@ -12,4 +13,5 @@ export declare type Subtract<T extends T1, T1 extends object> = Pick<T, SetCompl
12
13
  * @param arrayB
13
14
  */
14
15
  export declare function accountArraysAreEqual(arrayA: Array<AccountIdentifiers>, arrayB: Array<AccountIdentifiers>): boolean;
16
+ export declare function getAccountByIdentifiers(allAccounts: AccountInfo[], accountIdentifiers: AccountIdentifiers): AccountInfo | null;
15
17
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azure/msal-react",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "author": {
5
5
  "name": "Microsoft",
6
6
  "email": "nugetaad@microsoft.com",
@@ -41,12 +41,12 @@
41
41
  "prepack": "npm run build:all"
42
42
  },
43
43
  "peerDependencies": {
44
- "@azure/msal-browser": "^2.21.0",
44
+ "@azure/msal-browser": "^2.22.0",
45
45
  "react": "^16.8.0 || ^17"
46
46
  },
47
47
  "module": "dist/msal-react.esm.js",
48
48
  "devDependencies": {
49
- "@azure/msal-browser": "^2.21.0",
49
+ "@azure/msal-browser": "^2.22.0",
50
50
  "@testing-library/jest-dom": "^5.11.5",
51
51
  "@testing-library/react": "^11.2.3",
52
52
  "@types/jest": "^26.0.15",