{"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(\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 = (args: T) => React.ReactNode;\n\nexport function getChildrenOrFunction(\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 extends B ? never : A;\ntype SetComplement = SetDifference;\nexport type Subtract = Pick>;\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, arrayB: Array): 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.5.2\";\n","/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport React, { useEffect, useReducer, PropsWithChildren, useMemo} from \"react\";\nimport {\n IPublicClientApplication,\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\ntype MsalState = {\n inProgress: InteractionStatus;\n accounts: AccountInfo[];\n};\n\nenum MsalProviderActionType {\n UNBLOCK_INPROGRESS = \"UNBLOCK_INPROGRESS\",\n EVENT = \"EVENT\"\n}\n\ntype MsalProviderReducerAction = {\n type: MsalProviderActionType,\n payload: {\n logger: Logger;\n instance: IPublicClientApplication;\n message?: EventMessage;\n };\n};\n\n/**\n * Returns the next inProgress and accounts state based on event message\n * @param previousState \n * @param action \n */\nconst reducer = (previousState: MsalState, action: MsalProviderReducerAction): MsalState => {\n const { type, payload } = action;\n let newInProgress = previousState.inProgress;\n\n switch (type) {\n case MsalProviderActionType.UNBLOCK_INPROGRESS:\n if (previousState.inProgress === InteractionStatus.Startup){\n newInProgress = InteractionStatus.None;\n payload.logger.info(\"MsalProvider - handleRedirectPromise resolved, setting inProgress to 'none'\");\n }\n break;\n case MsalProviderActionType.EVENT:\n const message = payload.message as EventMessage;\n const status = EventMessageUtils.getInteractionStatusFromEvent(message, previousState.inProgress);\n if (status) {\n payload.logger.info(`MsalProvider - ${message.eventType} results in setting inProgress from ${previousState.inProgress} to ${status}`);\n newInProgress = status;\n }\n break;\n default:\n throw new Error(`Unknown action type: ${type}`);\n }\n \n const currentAccounts = payload.instance.getAllAccounts();\n if (newInProgress !== previousState.inProgress && \n !accountArraysAreEqual(currentAccounts, previousState.accounts)) {\n // Both inProgress and accounts changed\n return {\n ...previousState,\n inProgress: newInProgress,\n accounts: currentAccounts\n };\n } else if (newInProgress !== previousState.inProgress) {\n // Only only inProgress changed\n return {\n ...previousState,\n inProgress: newInProgress\n };\n } else if (!accountArraysAreEqual(currentAccounts, previousState.accounts)) {\n // Only accounts changed\n return {\n ...previousState,\n accounts: currentAccounts\n };\n } else {\n // Nothing changed\n return previousState;\n }\n};\n\n/**\n * MSAL context provider component. This must be rendered above any other components that use MSAL.\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 = useMemo(() => {\n return instance.getLogger().clone(SKU, version);\n }, [instance]);\n\n const [state, updateState] = useReducer(reducer, undefined, () => {\n // Lazy initialization of the initial state\n return {\n inProgress: InteractionStatus.Startup,\n accounts: instance.getAllAccounts()\n };\n });\n \n useEffect(() => {\n const callbackId = instance.addEventCallback((message: EventMessage) => {\n updateState({\n payload: {\n instance,\n logger,\n message\n }, \n type: MsalProviderActionType.EVENT\n });\n });\n logger.verbose(`MsalProvider - Registered event callback with id: ${callbackId}`);\n\n instance.initialize().then(() => {\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 updateState({\n payload: {\n instance,\n logger\n },\n type: MsalProviderActionType.UNBLOCK_INPROGRESS \n });\n });\n });\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, logger]);\n\n const contextValue: IMsalContext = {\n instance,\n inProgress: state.inProgress,\n accounts: state.accounts,\n logger\n };\n\n return (\n \n {children}\n \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, InteractionStatus } 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, inProgress } = useMsal();\n\n const [hasAuthenticated, setHasAuthenticated] = useState(() => {\n if (inProgress === InteractionStatus.Startup) {\n return false;\n }\n return isAuthenticated(allAccounts, matchAccount);\n });\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;\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 \n {getChildrenOrFunction(children, context)}\n \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;\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 \n {getChildrenOrFunction(children, context)}\n \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(() => 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; \n acquireToken: (callbackInteractionType?: InteractionType | undefined, callbackRequest?: SilentRequest | undefined) => Promise;\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 // Used to prevent state updates after unmount\n const mounted = useRef(true);\n useEffect(() => {\n return () => {\n mounted.current = false;\n };\n },[]);\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 => {\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 => {\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 => {\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 if (mounted.current) {\n setResponse([response, null]);\n }\n return response;\n }).catch((e: AuthError) => {\n if (mounted.current) {\n setResponse([null, e]);\n }\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;\n errorComponent?: React.ElementType;\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 ;\n }\n\n throw msalAuthResult.error;\n }\n \n if (isAuthenticated) {\n return (\n \n {getChildrenOrFunction(children, msalAuthResult)}\n \n );\n } \n \n if (!!LoadingComponent && context.inProgress !== InteractionStatus.None) {\n return ;\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 =

(Component: React.ComponentType

): React.FunctionComponent> => {\n const ComponentWithMsal: React.FunctionComponent> = props => {\n const msal = useMsal();\n return ;\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","MsalProviderActionType","reducer","previousState","action","type","payload","newInProgress","UNBLOCK_INPROGRESS","Startup","info","EVENT","message","status","EventMessageUtils","getInteractionStatusFromEvent","eventType","Error","currentAccounts","getAllAccounts","MsalProvider","useEffect","initializeWrapperLibrary","WrapperSKU","useMemo","getLogger","clone","SKU","state","updateState","useReducer","undefined","callbackId","addEventCallback","verbose","initialize","then","handleRedirectPromise","catch","finally","removeEventCallback","contextValue","Provider","value","useMsal","useContext","isAuthenticated","matchAccount","useIsAuthenticated","hasAuthenticated","setHasAuthenticated","useState","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","mounted","useRef","current","interactionInProgress","shouldAcquireToken","login","useCallback","callbackInteractionType","callbackRequest","loginType","loginRequest","InteractionType","Popup","loginPopup","Redirect","loginRedirect","Silent","ssoSilent","acquireToken","fallbackInteractionType","tokenRequest","trace","scopes","OIDC_DEFAULT_SCOPES","getToken","acquireTokenSilent","e","InteractionRequiredAuthError","response","EventType","LOGIN_SUCCESS","SSO_SILENT_SUCCESS","LOGIN_FAILURE","SSO_SILENT_FAILURE","MsalAuthenticationTemplate","loadingComponent","LoadingComponent","errorComponent","ErrorComponent","msalAuthResult","withMsal","Component","ComponentWithMsal","props","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