@azure/msal-react 1.3.0 → 1.4.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.
@@ -3,4 +3,7 @@ import { IPublicClientApplication } from "@azure/msal-browser";
3
3
  export declare type MsalProviderProps = PropsWithChildren<{
4
4
  instance: IPublicClientApplication;
5
5
  }>;
6
+ /**
7
+ * MSAL context provider component. This must be rendered above any other components that use MSAL.
8
+ */
6
9
  export declare function MsalProvider({ instance, children }: MsalProviderProps): React.ReactElement;
@@ -85,88 +85,135 @@ function getAccountByIdentifiers(allAccounts, accountIdentifiers) {
85
85
 
86
86
  /* eslint-disable header/header */
87
87
  const name = "@azure/msal-react";
88
- const version = "1.3.0";
88
+ const version = "1.4.0";
89
89
 
90
90
  /*
91
91
  * Copyright (c) Microsoft Corporation. All rights reserved.
92
92
  * Licensed under the MIT License.
93
93
  */
94
- function MsalProvider({
95
- instance,
96
- children
97
- }) {
98
- React.useEffect(() => {
99
- instance.initializeWrapperLibrary(msalBrowser.WrapperSKU.React, version);
100
- }, [instance]); // Create a logger instance for msal-react with the same options as PublicClientApplication
94
+ var MsalProviderActionType;
101
95
 
102
- const logger = React.useMemo(() => {
103
- return instance.getLogger().clone(name, version);
104
- }, [instance]); // State hook to store accounts
96
+ (function (MsalProviderActionType) {
97
+ MsalProviderActionType["UNBLOCK_INPROGRESS"] = "UNBLOCK_INPROGRESS";
98
+ MsalProviderActionType["EVENT"] = "EVENT";
99
+ })(MsalProviderActionType || (MsalProviderActionType = {}));
100
+ /**
101
+ * Returns the next inProgress and accounts state based on event message
102
+ * @param previousState
103
+ * @param action
104
+ */
105
105
 
106
- const [accounts, setAccounts] = React.useState(() => instance.getAllAccounts()); // State hook to store in progress value
107
106
 
108
- const [inProgress, setInProgress] = React.useState(msalBrowser.InteractionStatus.Startup); // Mutable object used in the event callback
107
+ const reducer = (previousState, action) => {
108
+ const {
109
+ type,
110
+ payload
111
+ } = action;
112
+ let newInProgress = previousState.inProgress;
113
+
114
+ switch (type) {
115
+ case MsalProviderActionType.UNBLOCK_INPROGRESS:
116
+ if (previousState.inProgress === msalBrowser.InteractionStatus.Startup) {
117
+ newInProgress = msalBrowser.InteractionStatus.None;
118
+ payload.logger.info("MsalProvider - handleRedirectPromise resolved, setting inProgress to 'none'");
119
+ }
109
120
 
110
- const inProgressRef = React.useRef(inProgress);
111
- React.useEffect(() => {
112
- const callbackId = instance.addEventCallback(message => {
113
- switch (message.eventType) {
114
- case msalBrowser.EventType.ACCOUNT_ADDED:
115
- case msalBrowser.EventType.ACCOUNT_REMOVED:
116
- case msalBrowser.EventType.LOGIN_SUCCESS:
117
- case msalBrowser.EventType.SSO_SILENT_SUCCESS:
118
- case msalBrowser.EventType.HANDLE_REDIRECT_END:
119
- case msalBrowser.EventType.LOGIN_FAILURE:
120
- case msalBrowser.EventType.SSO_SILENT_FAILURE:
121
- case msalBrowser.EventType.LOGOUT_END:
122
- case msalBrowser.EventType.ACQUIRE_TOKEN_SUCCESS:
123
- case msalBrowser.EventType.ACQUIRE_TOKEN_FAILURE:
124
- const currentAccounts = instance.getAllAccounts();
125
-
126
- if (!accountArraysAreEqual(currentAccounts, accounts)) {
127
- logger.info("MsalProvider - updating account state");
128
- setAccounts(currentAccounts);
129
- } else {
130
- logger.info("MsalProvider - no account changes");
131
- }
121
+ break;
132
122
 
133
- break;
134
- }
135
- });
136
- logger.verbose(`MsalProvider - Registered event callback with id: ${callbackId}`);
137
- return () => {
138
- // Remove callback when component unmounts or accounts change
139
- if (callbackId) {
140
- logger.verbose(`MsalProvider - Removing event callback ${callbackId}`);
141
- instance.removeEventCallback(callbackId);
123
+ case MsalProviderActionType.EVENT:
124
+ const message = payload.message;
125
+ const status = msalBrowser.EventMessageUtils.getInteractionStatusFromEvent(message, previousState.inProgress);
126
+
127
+ if (status) {
128
+ payload.logger.info(`MsalProvider - ${message.eventType} results in setting inProgress from ${previousState.inProgress} to ${status}`);
129
+ newInProgress = status;
142
130
  }
131
+
132
+ break;
133
+
134
+ default:
135
+ throw new Error(`Unknown action type: ${type}`);
136
+ }
137
+
138
+ const currentAccounts = payload.instance.getAllAccounts();
139
+
140
+ if (newInProgress !== previousState.inProgress && !accountArraysAreEqual(currentAccounts, previousState.accounts)) {
141
+ // Both inProgress and accounts changed
142
+ return { ...previousState,
143
+ inProgress: newInProgress,
144
+ accounts: currentAccounts
145
+ };
146
+ } else if (newInProgress !== previousState.inProgress) {
147
+ // Only only inProgress changed
148
+ return { ...previousState,
149
+ inProgress: newInProgress
150
+ };
151
+ } else if (!accountArraysAreEqual(currentAccounts, previousState.accounts)) {
152
+ // Only accounts changed
153
+ return { ...previousState,
154
+ accounts: currentAccounts
143
155
  };
144
- }, [instance, accounts, logger]);
156
+ } else {
157
+ // Nothing changed
158
+ return previousState;
159
+ }
160
+ };
161
+ /**
162
+ * MSAL context provider component. This must be rendered above any other components that use MSAL.
163
+ */
164
+
165
+
166
+ function MsalProvider(_ref) {
167
+ let {
168
+ instance,
169
+ children
170
+ } = _ref;
145
171
  React.useEffect(() => {
146
- const callbackId = instance.addEventCallback(message => {
147
- const status = msalBrowser.EventMessageUtils.getInteractionStatusFromEvent(message, inProgressRef.current);
172
+ instance.initializeWrapperLibrary(msalBrowser.WrapperSKU.React, version);
173
+ }, [instance]); // Create a logger instance for msal-react with the same options as PublicClientApplication
148
174
 
149
- if (status !== null) {
150
- logger.info(`MsalProvider - ${message.eventType} results in setting inProgress from ${inProgressRef.current} to ${status}`);
151
- inProgressRef.current = status;
152
- setInProgress(status);
153
- }
175
+ const logger = React.useMemo(() => {
176
+ return instance.getLogger().clone(name, version);
177
+ }, [instance]);
178
+ const [state, updateState] = React.useReducer(reducer, undefined, () => {
179
+ // Lazy initialization of the initial state
180
+ return {
181
+ inProgress: msalBrowser.InteractionStatus.Startup,
182
+ accounts: instance.getAllAccounts()
183
+ };
184
+ });
185
+ React.useEffect(() => {
186
+ const callbackId = instance.addEventCallback(message => {
187
+ updateState({
188
+ payload: {
189
+ instance,
190
+ logger,
191
+ message
192
+ },
193
+ type: MsalProviderActionType.EVENT
194
+ });
154
195
  });
155
196
  logger.verbose(`MsalProvider - Registered event callback with id: ${callbackId}`);
156
- instance.handleRedirectPromise().catch(() => {
157
- // Errors should be handled by listening to the LOGIN_FAILURE event
158
- return;
159
- }).finally(() => {
160
- /*
161
- * If handleRedirectPromise returns a cached promise the necessary events may not be fired
162
- * This is a fallback to prevent inProgress from getting stuck in 'startup'
163
- */
164
- if (inProgressRef.current === msalBrowser.InteractionStatus.Startup) {
165
- inProgressRef.current = msalBrowser.InteractionStatus.None;
166
- setInProgress(msalBrowser.InteractionStatus.None);
167
- }
197
+ instance.initialize().then(() => {
198
+ instance.handleRedirectPromise().catch(() => {
199
+ // Errors should be handled by listening to the LOGIN_FAILURE event
200
+ return;
201
+ }).finally(() => {
202
+ /*
203
+ * If handleRedirectPromise returns a cached promise the necessary events may not be fired
204
+ * This is a fallback to prevent inProgress from getting stuck in 'startup'
205
+ */
206
+ updateState({
207
+ payload: {
208
+ instance,
209
+ logger
210
+ },
211
+ type: MsalProviderActionType.UNBLOCK_INPROGRESS
212
+ });
213
+ });
168
214
  });
169
215
  return () => {
216
+ // Remove callback when component unmounts or accounts change
170
217
  if (callbackId) {
171
218
  logger.verbose(`MsalProvider - Removing event callback ${callbackId}`);
172
219
  instance.removeEventCallback(callbackId);
@@ -175,8 +222,8 @@ function MsalProvider({
175
222
  }, [instance, logger]);
176
223
  const contextValue = {
177
224
  instance,
178
- inProgress,
179
- accounts,
225
+ inProgress: state.inProgress,
226
+ accounts: state.accounts,
180
227
  logger
181
228
  };
182
229
  return React__default.createElement(MsalContext.Provider, {
@@ -232,12 +279,13 @@ function useIsAuthenticated(matchAccount) {
232
279
  * @param props
233
280
  */
234
281
 
235
- function AuthenticatedTemplate({
236
- username,
237
- homeAccountId,
238
- localAccountId,
239
- children
240
- }) {
282
+ function AuthenticatedTemplate(_ref) {
283
+ let {
284
+ username,
285
+ homeAccountId,
286
+ localAccountId,
287
+ children
288
+ } = _ref;
241
289
  const context = useMsal();
242
290
  const accountIdentifier = React.useMemo(() => {
243
291
  return {
@@ -264,12 +312,13 @@ function AuthenticatedTemplate({
264
312
  * @param props
265
313
  */
266
314
 
267
- function UnauthenticatedTemplate({
268
- username,
269
- homeAccountId,
270
- localAccountId,
271
- children
272
- }) {
315
+ function UnauthenticatedTemplate(_ref) {
316
+ let {
317
+ username,
318
+ homeAccountId,
319
+ localAccountId,
320
+ children
321
+ } = _ref;
273
322
  const context = useMsal();
274
323
  const accountIdentifier = React.useMemo(() => {
275
324
  return {
@@ -538,16 +587,17 @@ function useMsalAuthentication(interactionType, authenticationRequest, accountId
538
587
  * @param props
539
588
  */
540
589
 
541
- function MsalAuthenticationTemplate({
542
- interactionType,
543
- username,
544
- homeAccountId,
545
- localAccountId,
546
- authenticationRequest,
547
- loadingComponent: LoadingComponent,
548
- errorComponent: ErrorComponent,
549
- children
550
- }) {
590
+ function MsalAuthenticationTemplate(_ref) {
591
+ let {
592
+ interactionType,
593
+ username,
594
+ homeAccountId,
595
+ localAccountId,
596
+ authenticationRequest,
597
+ loadingComponent: LoadingComponent,
598
+ errorComponent: ErrorComponent,
599
+ children
600
+ } = _ref;
551
601
  const accountIdentifier = React.useMemo(() => {
552
602
  return {
553
603
  username,
@@ -1 +1 @@
1
- {"version":3,"file":"msal-react.cjs.development.js","sources":["../src/MsalContext.ts","../src/utils/utilities.ts","../src/packageMetadata.ts","../src/MsalProvider.tsx","../src/hooks/useMsal.ts","../src/hooks/useIsAuthenticated.ts","../src/components/AuthenticatedTemplate.tsx","../src/components/UnauthenticatedTemplate.tsx","../src/hooks/useAccount.ts","../src/error/ReactAuthError.ts","../src/hooks/useMsalAuthentication.ts","../src/components/MsalAuthenticationTemplate.tsx","../src/components/withMsal.tsx"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport * as React from \"react\";\nimport { IPublicClientApplication, stubbedPublicClientApplication, Logger, InteractionStatus, AccountInfo } from \"@azure/msal-browser\";\n\nexport interface IMsalContext {\n instance: IPublicClientApplication;\n inProgress: InteractionStatus;\n accounts: AccountInfo[];\n logger: Logger;\n}\n\n/*\n * Stubbed context implementation\n * Only used when there is no provider, which is an unsupported scenario\n */\nconst defaultMsalContext: IMsalContext = {\n instance: stubbedPublicClientApplication,\n inProgress: InteractionStatus.None,\n accounts: [],\n logger: new Logger({})\n};\n\nexport const MsalContext = React.createContext<IMsalContext>(\n defaultMsalContext\n);\nexport const MsalConsumer = MsalContext.Consumer;\n","/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { AccountIdentifiers } from \"../types/AccountIdentifiers\";\nimport { AccountInfo } from \"@azure/msal-browser\";\n\ntype FaaCFunction = <T>(args: T) => React.ReactNode;\n\nexport function getChildrenOrFunction<T>(\n children: React.ReactNode | FaaCFunction,\n args: T\n): React.ReactNode {\n if (typeof children === \"function\") {\n return children(args);\n }\n return children;\n}\n\n/*\n * Utility types\n * Reference: https://github.com/piotrwitek/utility-types\n */\ntype SetDifference<A, B> = A extends B ? never : A;\ntype SetComplement<A, A1 extends A> = SetDifference<A, A1>;\nexport type Subtract<T extends T1, T1 extends object> = Pick<T,SetComplement<keyof T, keyof T1>>;\n\n/**\n * Helper function to determine whether 2 arrays are equal\n * Used to avoid unnecessary state updates\n * @param arrayA \n * @param arrayB \n */\nexport function accountArraysAreEqual(arrayA: Array<AccountIdentifiers>, arrayB: Array<AccountIdentifiers>): boolean {\n if (arrayA.length !== arrayB.length) {\n return false;\n }\n\n const comparisonArray = [...arrayB];\n\n return arrayA.every((elementA) => {\n const elementB = comparisonArray.shift();\n if (!elementA || !elementB) {\n return false;\n }\n\n return (elementA.homeAccountId === elementB.homeAccountId) && \n (elementA.localAccountId === elementB.localAccountId) &&\n (elementA.username === elementB.username);\n });\n}\n\nexport function getAccountByIdentifiers(allAccounts: AccountInfo[], accountIdentifiers: AccountIdentifiers): AccountInfo | null {\n if (allAccounts.length > 0 && (accountIdentifiers.homeAccountId || accountIdentifiers.localAccountId || accountIdentifiers.username)) {\n const matchedAccounts = allAccounts.filter(accountObj => {\n if (accountIdentifiers.username && accountIdentifiers.username.toLowerCase() !== accountObj.username.toLowerCase()) {\n return false;\n }\n if (accountIdentifiers.homeAccountId && accountIdentifiers.homeAccountId.toLowerCase() !== accountObj.homeAccountId.toLowerCase()) {\n return false;\n }\n if (accountIdentifiers.localAccountId && accountIdentifiers.localAccountId.toLowerCase() !== accountObj.localAccountId.toLowerCase()) {\n return false;\n }\n\n return true;\n });\n\n return matchedAccounts[0] || null;\n } else {\n return null;\n }\n}\n","/* eslint-disable header/header */\nexport const name = \"@azure/msal-react\";\nexport const version = \"1.3.0\";\n","/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport React, { useState, useEffect, useRef, PropsWithChildren, useMemo } from \"react\";\nimport {\n IPublicClientApplication,\n EventType,\n EventMessage,\n EventMessageUtils,\n InteractionStatus,\n Logger,\n WrapperSKU,\n AccountInfo\n} from \"@azure/msal-browser\";\nimport { MsalContext, IMsalContext } from \"./MsalContext\";\nimport { accountArraysAreEqual } from \"./utils/utilities\";\nimport { name as SKU, version } from \"./packageMetadata\";\n\nexport type MsalProviderProps = PropsWithChildren<{\n instance: IPublicClientApplication;\n}>;\n\nexport function MsalProvider({instance, children}: MsalProviderProps): React.ReactElement {\n useEffect(() => {\n instance.initializeWrapperLibrary(WrapperSKU.React, version);\n }, [instance]);\n // Create a logger instance for msal-react with the same options as PublicClientApplication\n const logger: Logger = useMemo(() => {\n return instance.getLogger().clone(SKU, version);\n }, [instance]);\n\n // State hook to store accounts\n const [accounts, setAccounts] = useState<AccountInfo[]>(() => instance.getAllAccounts());\n // State hook to store in progress value\n const [inProgress, setInProgress] = useState<InteractionStatus>(InteractionStatus.Startup);\n // Mutable object used in the event callback\n const inProgressRef = useRef(inProgress);\n \n useEffect(() => {\n const callbackId = instance.addEventCallback((message: EventMessage) => {\n switch (message.eventType) {\n case EventType.ACCOUNT_ADDED:\n case EventType.ACCOUNT_REMOVED:\n case EventType.LOGIN_SUCCESS:\n case EventType.SSO_SILENT_SUCCESS:\n case EventType.HANDLE_REDIRECT_END:\n case EventType.LOGIN_FAILURE:\n case EventType.SSO_SILENT_FAILURE:\n case EventType.LOGOUT_END:\n case EventType.ACQUIRE_TOKEN_SUCCESS:\n case EventType.ACQUIRE_TOKEN_FAILURE:\n const currentAccounts = instance.getAllAccounts();\n if (!accountArraysAreEqual(currentAccounts, accounts)) {\n logger.info(\"MsalProvider - updating account state\");\n setAccounts(currentAccounts);\n } else {\n logger.info(\"MsalProvider - no account changes\");\n }\n break;\n }\n });\n logger.verbose(`MsalProvider - Registered event callback with id: ${callbackId}`);\n\n return () => {\n // Remove callback when component unmounts or accounts change\n if (callbackId) {\n logger.verbose(`MsalProvider - Removing event callback ${callbackId}`);\n instance.removeEventCallback(callbackId);\n }\n };\n }, [instance, accounts, logger]);\n\n useEffect(() => {\n const callbackId = instance.addEventCallback((message: EventMessage) => {\n const status = EventMessageUtils.getInteractionStatusFromEvent(message, inProgressRef.current);\n if (status !== null) {\n logger.info(`MsalProvider - ${message.eventType} results in setting inProgress from ${inProgressRef.current} to ${status}`);\n inProgressRef.current = status;\n setInProgress(status);\n }\n });\n logger.verbose(`MsalProvider - Registered event callback with id: ${callbackId}`);\n\n instance.handleRedirectPromise().catch(() => {\n // Errors should be handled by listening to the LOGIN_FAILURE event\n return;\n }).finally(() => {\n /*\n * If handleRedirectPromise returns a cached promise the necessary events may not be fired\n * This is a fallback to prevent inProgress from getting stuck in 'startup'\n */\n if (inProgressRef.current === InteractionStatus.Startup) {\n inProgressRef.current = InteractionStatus.None;\n setInProgress(InteractionStatus.None);\n }\n });\n\n return () => {\n if (callbackId) {\n logger.verbose(`MsalProvider - Removing event callback ${callbackId}`);\n instance.removeEventCallback(callbackId);\n }\n };\n }, [instance, logger]);\n\n const contextValue: IMsalContext = {\n instance,\n inProgress,\n accounts,\n logger\n };\n\n return (\n <MsalContext.Provider value={contextValue}>\n {children}\n </MsalContext.Provider>\n );\n}\n\n","/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { useContext } from \"react\";\nimport { IMsalContext, MsalContext } from \"../MsalContext\";\n\n/**\n * Returns Msal Context values\n */\nexport const useMsal = (): IMsalContext => useContext(MsalContext);\n","/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { useState, useEffect } from \"react\";\nimport { useMsal } from \"./useMsal\";\nimport { AccountIdentifiers } from \"../types/AccountIdentifiers\";\nimport { AccountInfo } from \"@azure/msal-browser\";\nimport { getAccountByIdentifiers } from \"../utils/utilities\";\n\nfunction isAuthenticated(allAccounts: AccountInfo[], matchAccount?: AccountIdentifiers): boolean {\n if(matchAccount && (matchAccount.username || matchAccount.homeAccountId || matchAccount.localAccountId)) {\n return !!getAccountByIdentifiers(allAccounts, matchAccount);\n } \n\n return allAccounts.length > 0;\n}\n\n/**\n * Returns whether or not a user is currently signed-in. Optionally provide 1 or more accountIdentifiers to determine if a specific user is signed-in\n * @param matchAccount \n */\nexport function useIsAuthenticated(matchAccount?: AccountIdentifiers): boolean {\n const { accounts: allAccounts } = useMsal();\n\n const [hasAuthenticated, setHasAuthenticated] = useState<boolean>(() => isAuthenticated(allAccounts, matchAccount));\n\n useEffect(() => {\n setHasAuthenticated(isAuthenticated(allAccounts, matchAccount));\n }, [allAccounts, matchAccount]);\n\n return hasAuthenticated;\n}\n","/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport React, { PropsWithChildren, useMemo } from \"react\";\nimport { AccountIdentifiers } from \"../types/AccountIdentifiers\";\nimport { getChildrenOrFunction } from \"../utils/utilities\";\nimport { useMsal } from \"../hooks/useMsal\";\nimport { useIsAuthenticated } from \"../hooks/useIsAuthenticated\";\nimport { InteractionStatus } from \"@azure/msal-browser\";\n\nexport type AuthenticatedTemplateProps = PropsWithChildren<AccountIdentifiers>;\n\n/**\n * Renders child components if user is authenticated\n * @param props \n */\nexport function AuthenticatedTemplate({ username, homeAccountId, localAccountId, children }: AuthenticatedTemplateProps): React.ReactElement|null {\n const context = useMsal();\n const accountIdentifier: AccountIdentifiers = useMemo(() => {\n return {\n username,\n homeAccountId,\n localAccountId\n };\n }, [username, homeAccountId, localAccountId]);\n const isAuthenticated = useIsAuthenticated(accountIdentifier);\n\n if (isAuthenticated && context.inProgress !== InteractionStatus.Startup) {\n return (\n <React.Fragment>\n {getChildrenOrFunction(children, context)}\n </React.Fragment>\n );\n }\n return null;\n}\n","/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport React, { PropsWithChildren, useMemo } from \"react\";\nimport { useMsal } from \"../hooks/useMsal\";\nimport { useIsAuthenticated } from \"../hooks/useIsAuthenticated\";\nimport { getChildrenOrFunction } from \"../utils/utilities\";\nimport { AccountIdentifiers } from \"../types/AccountIdentifiers\";\nimport { InteractionStatus } from \"@azure/msal-browser\";\n\nexport type UnauthenticatedTemplateProps = PropsWithChildren<AccountIdentifiers>;\n\n/**\n * Renders child components if user is unauthenticated\n * @param props \n */\nexport function UnauthenticatedTemplate({ username, homeAccountId, localAccountId, children }: UnauthenticatedTemplateProps): React.ReactElement|null {\n const context = useMsal();\n const accountIdentifier: AccountIdentifiers = useMemo(() => {\n return {\n username,\n homeAccountId,\n localAccountId\n };\n }, [username, homeAccountId, localAccountId]);\n const isAuthenticated = useIsAuthenticated(accountIdentifier);\n\n if (!isAuthenticated && context.inProgress !== InteractionStatus.Startup && context.inProgress !== InteractionStatus.HandleRedirect) {\n return (\n <React.Fragment>\n {getChildrenOrFunction(children, context)}\n </React.Fragment>\n );\n }\n return null;\n}\n","/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { useState, useEffect } from \"react\";\nimport { AccountInfo, IPublicClientApplication, AccountEntity } from \"@azure/msal-browser\";\nimport { useMsal } from \"./useMsal\";\nimport { AccountIdentifiers } from \"../types/AccountIdentifiers\";\nimport { getAccountByIdentifiers } from \"../utils/utilities\";\n\nfunction getAccount(instance: IPublicClientApplication, accountIdentifiers?: AccountIdentifiers): AccountInfo | null {\n if (!accountIdentifiers || (!accountIdentifiers.homeAccountId && !accountIdentifiers.localAccountId && !accountIdentifiers.username)) {\n // If no account identifiers are provided, return active account\n return instance.getActiveAccount();\n }\n\n return getAccountByIdentifiers(instance.getAllAccounts(), accountIdentifiers);\n}\n\n/**\n * Given 1 or more accountIdentifiers, returns the Account object if the user is signed-in\n * @param accountIdentifiers \n */\nexport function useAccount(accountIdentifiers?: AccountIdentifiers): AccountInfo | null {\n const { instance, inProgress, logger } = useMsal();\n\n const [account, setAccount] = useState<AccountInfo|null>(() => getAccount(instance, accountIdentifiers));\n\n useEffect(() => {\n setAccount((currentAccount: AccountInfo | null) => {\n const nextAccount = getAccount(instance, accountIdentifiers);\n if (!AccountEntity.accountInfoIsEqual(currentAccount, nextAccount, true)) {\n logger.info(\"useAccount - Updating account\");\n return nextAccount;\n }\n\n return currentAccount;\n });\n }, [inProgress, accountIdentifiers, instance, logger]);\n\n return account;\n}\n","/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { AuthError } from \"@azure/msal-browser\";\n\nexport const ReactAuthErrorMessage = {\n invalidInteractionType: {\n code: \"invalid_interaction_type\",\n desc: \"The provided interaction type is invalid.\"\n },\n unableToFallbackToInteraction: {\n code: \"unable_to_fallback_to_interaction\",\n desc: \"Interaction is required but another interaction is already in progress. Please try again when the current interaction is complete.\"\n }\n};\n\nexport class ReactAuthError extends AuthError {\n constructor(errorCode: string, errorMessage?: string) {\n super(errorCode, errorMessage);\n\n Object.setPrototypeOf(this, ReactAuthError.prototype);\n this.name = \"ReactAuthError\";\n }\n\n static createInvalidInteractionTypeError(): ReactAuthError {\n return new ReactAuthError(ReactAuthErrorMessage.invalidInteractionType.code, ReactAuthErrorMessage.invalidInteractionType.desc);\n }\n\n static createUnableToFallbackToInteractionError(): ReactAuthError {\n return new ReactAuthError(ReactAuthErrorMessage.unableToFallbackToInteraction.code, ReactAuthErrorMessage.unableToFallbackToInteraction.desc);\n }\n}\n","/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { useCallback, useEffect, useState, useRef } from \"react\";\nimport { PopupRequest, RedirectRequest, SsoSilentRequest, InteractionType, AuthenticationResult, AuthError, EventMessage, EventType, InteractionStatus, SilentRequest, InteractionRequiredAuthError, OIDC_DEFAULT_SCOPES } from \"@azure/msal-browser\";\nimport { useIsAuthenticated } from \"./useIsAuthenticated\";\nimport { AccountIdentifiers } from \"../types/AccountIdentifiers\";\nimport { useMsal } from \"./useMsal\";\nimport { useAccount } from \"./useAccount\";\nimport { ReactAuthError } from \"../error/ReactAuthError\";\n\nexport type MsalAuthenticationResult = {\n login: (callbackInteractionType?: InteractionType | undefined, callbackRequest?: PopupRequest | RedirectRequest | SilentRequest) => Promise<AuthenticationResult | null>; \n acquireToken: (callbackInteractionType?: InteractionType | undefined, callbackRequest?: SilentRequest | undefined) => Promise<AuthenticationResult | null>;\n result: AuthenticationResult|null;\n error: AuthError|null;\n};\n\n/**\n * If a user is not currently signed in this hook invokes a login. Failed logins can be retried using the login callback returned.\n * If a user is currently signed in this hook attempts to acquire a token. Subsequent token requests can use the acquireToken callback returned.\n * Optionally provide a request object to be used in the login/acquireToken call.\n * Optionally provide a specific user that should be logged in.\n * @param interactionType \n * @param authenticationRequest \n * @param accountIdentifiers \n */\nexport function useMsalAuthentication(\n interactionType: InteractionType, \n authenticationRequest?: PopupRequest|RedirectRequest|SsoSilentRequest, \n accountIdentifiers?: AccountIdentifiers\n): MsalAuthenticationResult {\n const { instance, inProgress, logger } = useMsal();\n const isAuthenticated = useIsAuthenticated(accountIdentifiers);\n const account = useAccount(accountIdentifiers);\n const [[result, error], setResponse] = useState<[AuthenticationResult|null, AuthError|null]>([null, null]);\n\n // Boolean used to check if interaction is in progress in acquireTokenSilent fallback. Use Ref instead of state to prevent acquireToken function from being regenerated on each change to interactionInProgress value\n const interactionInProgress = useRef(inProgress !== InteractionStatus.None);\n useEffect(() => {\n interactionInProgress.current = inProgress !== InteractionStatus.None;\n }, [inProgress]);\n\n // Flag used to control when the hook calls login/acquireToken\n const shouldAcquireToken = useRef(true);\n useEffect(() => {\n if (!!error) {\n // Errors should be handled by consuming component\n shouldAcquireToken.current = false;\n return;\n }\n\n if (!!result) {\n // Token has already been acquired, consuming component/application is responsible for renewing\n shouldAcquireToken.current = false;\n return;\n }\n }, [error, result]);\n\n const login = useCallback(async (callbackInteractionType?: InteractionType, callbackRequest?: PopupRequest|RedirectRequest|SsoSilentRequest): Promise<AuthenticationResult|null> => {\n const loginType = callbackInteractionType || interactionType;\n const loginRequest = callbackRequest || authenticationRequest;\n switch (loginType) {\n case InteractionType.Popup:\n logger.verbose(\"useMsalAuthentication - Calling loginPopup\");\n return instance.loginPopup(loginRequest as PopupRequest);\n case InteractionType.Redirect:\n // This promise is not expected to resolve due to full frame redirect\n logger.verbose(\"useMsalAuthentication - Calling loginRedirect\");\n return instance.loginRedirect(loginRequest as RedirectRequest).then(null);\n case InteractionType.Silent:\n logger.verbose(\"useMsalAuthentication - Calling ssoSilent\");\n return instance.ssoSilent(loginRequest as SsoSilentRequest);\n default:\n throw ReactAuthError.createInvalidInteractionTypeError();\n }\n }, [instance, interactionType, authenticationRequest, logger]);\n\n const acquireToken = useCallback(async (callbackInteractionType?: InteractionType, callbackRequest?: SilentRequest): Promise<AuthenticationResult|null> => {\n const fallbackInteractionType = callbackInteractionType || interactionType;\n\n let tokenRequest: SilentRequest;\n\n if (callbackRequest) {\n logger.trace(\"useMsalAuthentication - acquireToken - Using request provided in the callback\");\n tokenRequest = {\n ...callbackRequest\n };\n } else if (authenticationRequest) {\n logger.trace(\"useMsalAuthentication - acquireToken - Using request provided in the hook\");\n tokenRequest = {\n ...authenticationRequest,\n scopes: authenticationRequest.scopes || OIDC_DEFAULT_SCOPES\n };\n } else {\n logger.trace(\"useMsalAuthentication - acquireToken - No request object provided, using default request.\");\n tokenRequest = {\n scopes: OIDC_DEFAULT_SCOPES\n };\n }\n \n if (!tokenRequest.account && account) {\n logger.trace(\"useMsalAuthentication - acquireToken - Attaching account to request\");\n tokenRequest.account = account;\n }\n\n const getToken = async (): Promise<AuthenticationResult|null> => {\n logger.verbose(\"useMsalAuthentication - Calling acquireTokenSilent\");\n return instance.acquireTokenSilent(tokenRequest).catch(async (e: AuthError) => {\n if (e instanceof InteractionRequiredAuthError) {\n if (!interactionInProgress.current) {\n logger.error(\"useMsalAuthentication - Interaction required, falling back to interaction\");\n return login(fallbackInteractionType, tokenRequest);\n } else {\n logger.error(\"useMsalAuthentication - Interaction required but is already in progress. Please try again, if needed, after interaction completes.\");\n throw ReactAuthError.createUnableToFallbackToInteractionError();\n }\n }\n\n throw e;\n });\n };\n\n return getToken().then((response: AuthenticationResult|null) => {\n setResponse([response, null]);\n return response;\n }).catch((e: AuthError) => {\n setResponse([null, e]);\n throw e;\n });\n }, [instance, interactionType, authenticationRequest, logger, account, login]);\n\n useEffect(() => {\n const callbackId = instance.addEventCallback((message: EventMessage) => {\n switch(message.eventType) {\n case EventType.LOGIN_SUCCESS:\n case EventType.SSO_SILENT_SUCCESS:\n if (message.payload) {\n setResponse([message.payload as AuthenticationResult, null]);\n }\n break;\n case EventType.LOGIN_FAILURE:\n case EventType.SSO_SILENT_FAILURE:\n if (message.error) {\n setResponse([null, message.error as AuthError]);\n }\n break;\n }\n });\n logger.verbose(`useMsalAuthentication - Registered event callback with id: ${callbackId}`);\n\n return () => {\n if (callbackId) {\n logger.verbose(`useMsalAuthentication - Removing event callback ${callbackId}`);\n instance.removeEventCallback(callbackId);\n }\n };\n }, [instance, logger]);\n\n useEffect(() => {\n if (shouldAcquireToken.current && inProgress === InteractionStatus.None) {\n shouldAcquireToken.current = false;\n if (!isAuthenticated) {\n logger.info(\"useMsalAuthentication - No user is authenticated, attempting to login\");\n login().catch(() => {\n // Errors are saved in state above\n return;\n });\n } else if (account) {\n logger.info(\"useMsalAuthentication - User is authenticated, attempting to acquire token\");\n acquireToken().catch(() => {\n // Errors are saved in state above\n return;\n });\n }\n }\n }, [isAuthenticated, account, inProgress, login, acquireToken, logger]);\n\n return { \n login, \n acquireToken, \n result, \n error\n };\n}\n","/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport React, { PropsWithChildren, useMemo } from \"react\";\nimport { AccountIdentifiers } from \"../types/AccountIdentifiers\";\nimport { getChildrenOrFunction } from \"../utils/utilities\";\nimport { useMsal } from \"../hooks/useMsal\";\nimport { MsalAuthenticationResult, useMsalAuthentication } from \"../hooks/useMsalAuthentication\";\nimport { useIsAuthenticated } from \"../hooks/useIsAuthenticated\";\nimport { InteractionType, PopupRequest, RedirectRequest, SsoSilentRequest, InteractionStatus } from \"@azure/msal-browser\";\nimport { IMsalContext } from \"../MsalContext\";\n\nexport type MsalAuthenticationProps = PropsWithChildren<AccountIdentifiers & {\n interactionType: InteractionType;\n authenticationRequest?: PopupRequest|RedirectRequest|SsoSilentRequest;\n loadingComponent?: React.ElementType<IMsalContext>;\n errorComponent?: React.ElementType<MsalAuthenticationResult>;\n}>;\n\n/**\n * Attempts to authenticate user if not already authenticated, then renders child components\n * @param props\n */\nexport function MsalAuthenticationTemplate({ \n interactionType, \n username, \n homeAccountId, \n localAccountId,\n authenticationRequest, \n loadingComponent: LoadingComponent,\n errorComponent: ErrorComponent,\n children \n}: MsalAuthenticationProps): React.ReactElement|null {\n const accountIdentifier: AccountIdentifiers = useMemo(() => {\n return {\n username,\n homeAccountId,\n localAccountId\n };\n }, [username, homeAccountId, localAccountId]);\n const context = useMsal();\n const msalAuthResult = useMsalAuthentication(interactionType, authenticationRequest, accountIdentifier);\n const isAuthenticated = useIsAuthenticated(accountIdentifier);\n\n if (msalAuthResult.error && context.inProgress === InteractionStatus.None) {\n if (!!ErrorComponent) {\n return <ErrorComponent {...msalAuthResult} />;\n }\n\n throw msalAuthResult.error;\n }\n \n if (isAuthenticated) {\n return (\n <React.Fragment>\n {getChildrenOrFunction(children, msalAuthResult)}\n </React.Fragment>\n );\n } \n \n if (!!LoadingComponent && context.inProgress !== InteractionStatus.None) {\n return <LoadingComponent {...context} />;\n }\n\n return null;\n}\n","/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport React from \"react\";\nimport { IMsalContext } from \"../MsalContext\";\nimport { useMsal } from \"../hooks/useMsal\";\nimport { Subtract } from \"../utils/utilities\";\n\nexport type WithMsalProps = {\n msalContext: IMsalContext;\n};\n\n/**\n * Higher order component wraps provided component with msal by injecting msal context values into the component's props \n * @param Component \n */\nexport const withMsal = <P extends WithMsalProps>(Component: React.ComponentType<P>): React.FunctionComponent<Subtract<P,WithMsalProps>> => {\n const ComponentWithMsal: React.FunctionComponent<Subtract<P,WithMsalProps>> = props => {\n const msal = useMsal();\n return <Component {...(props as P)} msalContext={msal} />;\n };\n\n const componentName =\n Component.displayName || Component.name || \"Component\";\n ComponentWithMsal.displayName = `withMsal(${componentName})`;\n\n return ComponentWithMsal;\n};\n"],"names":["defaultMsalContext","instance","stubbedPublicClientApplication","inProgress","InteractionStatus","None","accounts","logger","Logger","MsalContext","React","MsalConsumer","Consumer","getChildrenOrFunction","children","args","accountArraysAreEqual","arrayA","arrayB","length","comparisonArray","every","elementA","elementB","shift","homeAccountId","localAccountId","username","getAccountByIdentifiers","allAccounts","accountIdentifiers","matchedAccounts","filter","accountObj","toLowerCase","name","version","MsalProvider","useEffect","initializeWrapperLibrary","WrapperSKU","useMemo","getLogger","clone","SKU","setAccounts","useState","getAllAccounts","setInProgress","Startup","inProgressRef","useRef","callbackId","addEventCallback","message","eventType","EventType","ACCOUNT_ADDED","ACCOUNT_REMOVED","LOGIN_SUCCESS","SSO_SILENT_SUCCESS","HANDLE_REDIRECT_END","LOGIN_FAILURE","SSO_SILENT_FAILURE","LOGOUT_END","ACQUIRE_TOKEN_SUCCESS","ACQUIRE_TOKEN_FAILURE","currentAccounts","info","verbose","removeEventCallback","status","EventMessageUtils","getInteractionStatusFromEvent","current","handleRedirectPromise","catch","finally","contextValue","Provider","value","useMsal","useContext","isAuthenticated","matchAccount","useIsAuthenticated","hasAuthenticated","setHasAuthenticated","AuthenticatedTemplate","context","accountIdentifier","Fragment","UnauthenticatedTemplate","HandleRedirect","getAccount","getActiveAccount","useAccount","account","setAccount","currentAccount","nextAccount","AccountEntity","accountInfoIsEqual","ReactAuthErrorMessage","invalidInteractionType","code","desc","unableToFallbackToInteraction","ReactAuthError","AuthError","constructor","errorCode","errorMessage","Object","setPrototypeOf","prototype","createInvalidInteractionTypeError","createUnableToFallbackToInteractionError","useMsalAuthentication","interactionType","authenticationRequest","result","error","setResponse","interactionInProgress","shouldAcquireToken","login","useCallback","callbackInteractionType","callbackRequest","loginType","loginRequest","InteractionType","Popup","loginPopup","Redirect","loginRedirect","then","Silent","ssoSilent","acquireToken","fallbackInteractionType","tokenRequest","trace","scopes","OIDC_DEFAULT_SCOPES","getToken","acquireTokenSilent","e","InteractionRequiredAuthError","response","payload","MsalAuthenticationTemplate","loadingComponent","LoadingComponent","errorComponent","ErrorComponent","msalAuthResult","withMsal","Component","ComponentWithMsal","props","msal","msalContext","componentName","displayName"],"mappings":";;;;;;;;;;AAAA;;;;AAeA;;;;;AAIA,MAAMA,kBAAkB,GAAiB;AACrCC,EAAAA,QAAQ,EAAEC,0CAD2B;AAErCC,EAAAA,UAAU,EAAEC,6BAAiB,CAACC,IAFO;AAGrCC,EAAAA,QAAQ,EAAE,EAH2B;AAIrCC,EAAAA,MAAM,eAAE,IAAIC,kBAAJ,CAAW,EAAX;AAJ6B,CAAzC;MAOaC,WAAW,gBAAGC,mBAAA,CACvBV,kBADuB;MAGdW,YAAY,GAAGF,WAAW,CAACG;;AC7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BAAiB,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
+ {"version":3,"file":"msal-react.cjs.development.js","sources":["../src/MsalContext.ts","../src/utils/utilities.ts","../src/packageMetadata.ts","../src/MsalProvider.tsx","../src/hooks/useMsal.ts","../src/hooks/useIsAuthenticated.ts","../src/components/AuthenticatedTemplate.tsx","../src/components/UnauthenticatedTemplate.tsx","../src/hooks/useAccount.ts","../src/error/ReactAuthError.ts","../src/hooks/useMsalAuthentication.ts","../src/components/MsalAuthenticationTemplate.tsx","../src/components/withMsal.tsx"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport * as React from \"react\";\nimport { IPublicClientApplication, stubbedPublicClientApplication, Logger, InteractionStatus, AccountInfo } from \"@azure/msal-browser\";\n\nexport interface IMsalContext {\n instance: IPublicClientApplication;\n inProgress: InteractionStatus;\n accounts: AccountInfo[];\n logger: Logger;\n}\n\n/*\n * Stubbed context implementation\n * Only used when there is no provider, which is an unsupported scenario\n */\nconst defaultMsalContext: IMsalContext = {\n instance: stubbedPublicClientApplication,\n inProgress: InteractionStatus.None,\n accounts: [],\n logger: new Logger({})\n};\n\nexport const MsalContext = React.createContext<IMsalContext>(\n defaultMsalContext\n);\nexport const MsalConsumer = MsalContext.Consumer;\n","/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { AccountIdentifiers } from \"../types/AccountIdentifiers\";\nimport { AccountInfo } from \"@azure/msal-browser\";\n\ntype FaaCFunction = <T>(args: T) => React.ReactNode;\n\nexport function getChildrenOrFunction<T>(\n children: React.ReactNode | FaaCFunction,\n args: T\n): React.ReactNode {\n if (typeof children === \"function\") {\n return children(args);\n }\n return children;\n}\n\n/*\n * Utility types\n * Reference: https://github.com/piotrwitek/utility-types\n */\ntype SetDifference<A, B> = A extends B ? never : A;\ntype SetComplement<A, A1 extends A> = SetDifference<A, A1>;\nexport type Subtract<T extends T1, T1 extends object> = Pick<T,SetComplement<keyof T, keyof T1>>;\n\n/**\n * Helper function to determine whether 2 arrays are equal\n * Used to avoid unnecessary state updates\n * @param arrayA \n * @param arrayB \n */\nexport function accountArraysAreEqual(arrayA: Array<AccountIdentifiers>, arrayB: Array<AccountIdentifiers>): boolean {\n if (arrayA.length !== arrayB.length) {\n return false;\n }\n\n const comparisonArray = [...arrayB];\n\n return arrayA.every((elementA) => {\n const elementB = comparisonArray.shift();\n if (!elementA || !elementB) {\n return false;\n }\n\n return (elementA.homeAccountId === elementB.homeAccountId) && \n (elementA.localAccountId === elementB.localAccountId) &&\n (elementA.username === elementB.username);\n });\n}\n\nexport function getAccountByIdentifiers(allAccounts: AccountInfo[], accountIdentifiers: AccountIdentifiers): AccountInfo | null {\n if (allAccounts.length > 0 && (accountIdentifiers.homeAccountId || accountIdentifiers.localAccountId || accountIdentifiers.username)) {\n const matchedAccounts = allAccounts.filter(accountObj => {\n if (accountIdentifiers.username && accountIdentifiers.username.toLowerCase() !== accountObj.username.toLowerCase()) {\n return false;\n }\n if (accountIdentifiers.homeAccountId && accountIdentifiers.homeAccountId.toLowerCase() !== accountObj.homeAccountId.toLowerCase()) {\n return false;\n }\n if (accountIdentifiers.localAccountId && accountIdentifiers.localAccountId.toLowerCase() !== accountObj.localAccountId.toLowerCase()) {\n return false;\n }\n\n return true;\n });\n\n return matchedAccounts[0] || null;\n } else {\n return null;\n }\n}\n","/* eslint-disable header/header */\nexport const name = \"@azure/msal-react\";\nexport const version = \"1.4.0\";\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 <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","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","interactionInProgress","useRef","current","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","msal","msalContext","componentName","displayName"],"mappings":";;;;;;;;;;AAAA;;;;AAeA;;;;;AAIA,MAAMA,kBAAkB,GAAiB;AACrCC,EAAAA,QAAQ,EAAEC,0CAD2B;AAErCC,EAAAA,UAAU,EAAEC,6BAAiB,CAACC,IAFO;AAGrCC,EAAAA,QAAQ,EAAE,EAH2B;AAIrCC,EAAAA,MAAM,eAAE,IAAIC,kBAAJ,CAAW,EAAX;AAJ6B,CAAzC;MAOaC,WAAW,gBAAGC,mBAAA,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)&&"object"==typeof e&&"default"in e?e.default:e,r=require("@azure/msal-browser");const o=t.createContext({instance:r.stubbedPublicClientApplication,inProgress:r.InteractionStatus.None,accounts:[],logger:new r.Logger({})}),c=o.Consumer;function a(e,t){return"function"==typeof e?e(t):e}function s(e,t){return e.length>0&&(t.homeAccountId||t.localAccountId||t.username)&&e.filter(e=>!(t.username&&t.username.toLowerCase()!==e.username.toLowerCase()||t.homeAccountId&&t.homeAccountId.toLowerCase()!==e.homeAccountId.toLowerCase()||t.localAccountId&&t.localAccountId.toLowerCase()!==e.localAccountId.toLowerCase()))[0]||null}const u=()=>t.useContext(o);function i(e,t){return t&&(t.username||t.homeAccountId||t.localAccountId)?!!s(e,t):e.length>0}function l(e){const{accounts:n}=u(),[r,o]=t.useState(()=>i(n,e));return t.useEffect(()=>{o(i(n,e))},[n,e]),r}function d(e,t){return t&&(t.homeAccountId||t.localAccountId||t.username)?s(e.getAllAccounts(),t):e.getActiveAccount()}function p(e){const{instance:n,inProgress:o,logger:c}=u(),[a,s]=t.useState(()=>d(n,e));return t.useEffect(()=>{s(t=>{const o=d(n,e);return r.AccountEntity.accountInfoIsEqual(t,o,!0)?t:(c.info("useAccount - Updating account"),o)})},[o,e,n,c]),a}class h extends r.AuthError{constructor(e,t){super(e,t),Object.setPrototypeOf(this,h.prototype),this.name="ReactAuthError"}static createInvalidInteractionTypeError(){return new h("invalid_interaction_type","The provided interaction type is invalid.")}static createUnableToFallbackToInteractionError(){return new h("unable_to_fallback_to_interaction","Interaction is required but another interaction is already in progress. Please try again when the current interaction is complete.")}}function E(e,n,o){const{instance:c,inProgress:a,logger:s}=u(),i=l(o),d=p(o),[[E,I],A]=t.useState([null,null]),g=t.useRef(a!==r.InteractionStatus.None);t.useEffect(()=>{g.current=a!==r.InteractionStatus.None},[a]);const m=t.useRef(!0);t.useEffect(()=>{(I||E)&&(m.current=!1)},[I,E]);const v=t.useCallback(async(t,o)=>{const a=o||n;switch(t||e){case r.InteractionType.Popup:return s.verbose("useMsalAuthentication - Calling loginPopup"),c.loginPopup(a);case r.InteractionType.Redirect:return s.verbose("useMsalAuthentication - Calling loginRedirect"),c.loginRedirect(a).then(null);case r.InteractionType.Silent:return s.verbose("useMsalAuthentication - Calling ssoSilent"),c.ssoSilent(a);default:throw h.createInvalidInteractionTypeError()}},[c,e,n,s]),f=t.useCallback(async(t,o)=>{const a=t||e;let u;return o?(s.trace("useMsalAuthentication - acquireToken - Using request provided in the callback"),u={...o}):n?(s.trace("useMsalAuthentication - acquireToken - Using request provided in the hook"),u={...n,scopes:n.scopes||r.OIDC_DEFAULT_SCOPES}):(s.trace("useMsalAuthentication - acquireToken - No request object provided, using default request."),u={scopes:r.OIDC_DEFAULT_SCOPES}),!u.account&&d&&(s.trace("useMsalAuthentication - acquireToken - Attaching account to request"),u.account=d),(async()=>(s.verbose("useMsalAuthentication - Calling acquireTokenSilent"),c.acquireTokenSilent(u).catch(async e=>{if(e instanceof r.InteractionRequiredAuthError){if(g.current)throw s.error("useMsalAuthentication - Interaction required but is already in progress. Please try again, if needed, after interaction completes."),h.createUnableToFallbackToInteractionError();return s.error("useMsalAuthentication - Interaction required, falling back to interaction"),v(a,u)}throw e})))().then(e=>(A([e,null]),e)).catch(e=>{throw A([null,e]),e})},[c,e,n,s,d,v]);return t.useEffect(()=>{const e=c.addEventCallback(e=>{switch(e.eventType){case r.EventType.LOGIN_SUCCESS:case r.EventType.SSO_SILENT_SUCCESS:e.payload&&A([e.payload,null]);break;case r.EventType.LOGIN_FAILURE:case r.EventType.SSO_SILENT_FAILURE:e.error&&A([null,e.error])}});return s.verbose("useMsalAuthentication - Registered event callback with id: "+e),()=>{e&&(s.verbose("useMsalAuthentication - Removing event callback "+e),c.removeEventCallback(e))}},[c,s]),t.useEffect(()=>{m.current&&a===r.InteractionStatus.None&&(m.current=!1,i?d&&(s.info("useMsalAuthentication - User is authenticated, attempting to acquire token"),f().catch(()=>{})):(s.info("useMsalAuthentication - No user is authenticated, attempting to login"),v().catch(()=>{})))},[i,d,a,v,f,s]),{login:v,acquireToken:f,result:E,error:I}}exports.AuthenticatedTemplate=function({username:e,homeAccountId:o,localAccountId:c,children:s}){const i=u();return l(t.useMemo(()=>({username:e,homeAccountId:o,localAccountId:c}),[e,o,c]))&&i.inProgress!==r.InteractionStatus.Startup?n.createElement(n.Fragment,null,a(s,i)):null},exports.MsalAuthenticationTemplate=function({interactionType:e,username:o,homeAccountId:c,localAccountId:s,authenticationRequest:i,loadingComponent:d,errorComponent:p,children:h}){const I=t.useMemo(()=>({username:o,homeAccountId:c,localAccountId:s}),[o,c,s]),A=u(),g=E(e,i,I),m=l(I);if(g.error&&A.inProgress===r.InteractionStatus.None){if(p)return n.createElement(p,Object.assign({},g));throw g.error}return m?n.createElement(n.Fragment,null,a(h,g)):d&&A.inProgress!==r.InteractionStatus.None?n.createElement(d,Object.assign({},A)):null},exports.MsalConsumer=c,exports.MsalContext=o,exports.MsalProvider=function({instance:e,children:c}){t.useEffect(()=>{e.initializeWrapperLibrary(r.WrapperSKU.React,"1.3.0")},[e]);const a=t.useMemo(()=>e.getLogger().clone("@azure/msal-react","1.3.0"),[e]),[s,u]=t.useState(()=>e.getAllAccounts()),[i,l]=t.useState(r.InteractionStatus.Startup),d=t.useRef(i);return t.useEffect(()=>{const t=e.addEventCallback(t=>{switch(t.eventType){case r.EventType.ACCOUNT_ADDED:case r.EventType.ACCOUNT_REMOVED:case r.EventType.LOGIN_SUCCESS:case r.EventType.SSO_SILENT_SUCCESS:case r.EventType.HANDLE_REDIRECT_END:case r.EventType.LOGIN_FAILURE:case r.EventType.SSO_SILENT_FAILURE:case r.EventType.LOGOUT_END:case r.EventType.ACQUIRE_TOKEN_SUCCESS:case r.EventType.ACQUIRE_TOKEN_FAILURE:const t=e.getAllAccounts();!function(e,t){if(e.length!==t.length)return!1;const n=[...t];return e.every(e=>{const t=n.shift();return!(!e||!t)&&e.homeAccountId===t.homeAccountId&&e.localAccountId===t.localAccountId&&e.username===t.username})}(t,s)?(a.info("MsalProvider - updating account state"),u(t)):a.info("MsalProvider - no account changes")}});return a.verbose("MsalProvider - Registered event callback with id: "+t),()=>{t&&(a.verbose("MsalProvider - Removing event callback "+t),e.removeEventCallback(t))}},[e,s,a]),t.useEffect(()=>{const t=e.addEventCallback(e=>{const t=r.EventMessageUtils.getInteractionStatusFromEvent(e,d.current);null!==t&&(a.info(`MsalProvider - ${e.eventType} results in setting inProgress from ${d.current} to ${t}`),d.current=t,l(t))});return a.verbose("MsalProvider - Registered event callback with id: "+t),e.handleRedirectPromise().catch(()=>{}).finally(()=>{d.current===r.InteractionStatus.Startup&&(d.current=r.InteractionStatus.None,l(r.InteractionStatus.None))}),()=>{t&&(a.verbose("MsalProvider - Removing event callback "+t),e.removeEventCallback(t))}},[e,a]),n.createElement(o.Provider,{value:{instance:e,inProgress:i,accounts:s,logger:a}},c)},exports.UnauthenticatedTemplate=function({username:e,homeAccountId:o,localAccountId:c,children:s}){const i=u();return l(t.useMemo(()=>({username:e,homeAccountId:o,localAccountId:c}),[e,o,c]))||i.inProgress===r.InteractionStatus.Startup||i.inProgress===r.InteractionStatus.HandleRedirect?null:n.createElement(n.Fragment,null,a(s,i))},exports.useAccount=p,exports.useIsAuthenticated=l,exports.useMsal=u,exports.useMsalAuthentication=E,exports.version="1.3.0",exports.withMsal=e=>{const t=t=>{const r=u();return n.createElement(e,Object.assign({},t,{msalContext:r}))};return t.displayName=`withMsal(${e.displayName||e.name||"Component"})`,t};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react"),n=(e=t)&&"object"==typeof e&&"default"in e?e.default:e,r=require("@azure/msal-browser");const o=t.createContext({instance:r.stubbedPublicClientApplication,inProgress:r.InteractionStatus.None,accounts:[],logger:new r.Logger({})}),c=o.Consumer;function a(e,t){return"function"==typeof e?e(t):e}function s(e,t){if(e.length!==t.length)return!1;const n=[...t];return e.every(e=>{const t=n.shift();return!(!e||!t)&&e.homeAccountId===t.homeAccountId&&e.localAccountId===t.localAccountId&&e.username===t.username})}function i(e,t){return e.length>0&&(t.homeAccountId||t.localAccountId||t.username)&&e.filter(e=>!(t.username&&t.username.toLowerCase()!==e.username.toLowerCase()||t.homeAccountId&&t.homeAccountId.toLowerCase()!==e.homeAccountId.toLowerCase()||t.localAccountId&&t.localAccountId.toLowerCase()!==e.localAccountId.toLowerCase()))[0]||null}var u;!function(e){e.UNBLOCK_INPROGRESS="UNBLOCK_INPROGRESS",e.EVENT="EVENT"}(u||(u={}));const l=(e,t)=>{const{type:n,payload:o}=t;let c=e.inProgress;switch(n){case u.UNBLOCK_INPROGRESS:e.inProgress===r.InteractionStatus.Startup&&(c=r.InteractionStatus.None,o.logger.info("MsalProvider - handleRedirectPromise resolved, setting inProgress to 'none'"));break;case u.EVENT:const t=o.message,a=r.EventMessageUtils.getInteractionStatusFromEvent(t,e.inProgress);a&&(o.logger.info(`MsalProvider - ${t.eventType} results in setting inProgress from ${e.inProgress} to ${a}`),c=a);break;default:throw new Error("Unknown action type: "+n)}const a=o.instance.getAllAccounts();return c===e.inProgress||s(a,e.accounts)?c!==e.inProgress?{...e,inProgress:c}:s(a,e.accounts)?e:{...e,accounts:a}:{...e,inProgress:c,accounts:a}},d=()=>t.useContext(o);function g(e,t){return t&&(t.username||t.homeAccountId||t.localAccountId)?!!i(e,t):e.length>0}function h(e){const{accounts:n}=d(),[r,o]=t.useState(()=>g(n,e));return t.useEffect(()=>{o(g(n,e))},[n,e]),r}function p(e,t){return t&&(t.homeAccountId||t.localAccountId||t.username)?i(e.getAllAccounts(),t):e.getActiveAccount()}function m(e){const{instance:n,inProgress:o,logger:c}=d(),[a,s]=t.useState(()=>p(n,e));return t.useEffect(()=>{s(t=>{const o=p(n,e);return r.AccountEntity.accountInfoIsEqual(t,o,!0)?t:(c.info("useAccount - Updating account"),o)})},[o,e,n,c]),a}class I extends r.AuthError{constructor(e,t){super(e,t),Object.setPrototypeOf(this,I.prototype),this.name="ReactAuthError"}static createInvalidInteractionTypeError(){return new I("invalid_interaction_type","The provided interaction type is invalid.")}static createUnableToFallbackToInteractionError(){return new I("unable_to_fallback_to_interaction","Interaction is required but another interaction is already in progress. Please try again when the current interaction is complete.")}}function A(e,n,o){const{instance:c,inProgress:a,logger:s}=d(),i=h(o),u=m(o),[[l,g],p]=t.useState([null,null]),A=t.useRef(a!==r.InteractionStatus.None);t.useEffect(()=>{A.current=a!==r.InteractionStatus.None},[a]);const f=t.useRef(!0);t.useEffect(()=>{(g||l)&&(f.current=!1)},[g,l]);const E=t.useCallback(async(t,o)=>{const a=o||n;switch(t||e){case r.InteractionType.Popup:return s.verbose("useMsalAuthentication - Calling loginPopup"),c.loginPopup(a);case r.InteractionType.Redirect:return s.verbose("useMsalAuthentication - Calling loginRedirect"),c.loginRedirect(a).then(null);case r.InteractionType.Silent:return s.verbose("useMsalAuthentication - Calling ssoSilent"),c.ssoSilent(a);default:throw I.createInvalidInteractionTypeError()}},[c,e,n,s]),v=t.useCallback(async(t,o)=>{const a=t||e;let i;return o?(s.trace("useMsalAuthentication - acquireToken - Using request provided in the callback"),i={...o}):n?(s.trace("useMsalAuthentication - acquireToken - Using request provided in the hook"),i={...n,scopes:n.scopes||r.OIDC_DEFAULT_SCOPES}):(s.trace("useMsalAuthentication - acquireToken - No request object provided, using default request."),i={scopes:r.OIDC_DEFAULT_SCOPES}),!i.account&&u&&(s.trace("useMsalAuthentication - acquireToken - Attaching account to request"),i.account=u),(async()=>(s.verbose("useMsalAuthentication - Calling acquireTokenSilent"),c.acquireTokenSilent(i).catch(async e=>{if(e instanceof r.InteractionRequiredAuthError){if(A.current)throw s.error("useMsalAuthentication - Interaction required but is already in progress. Please try again, if needed, after interaction completes."),I.createUnableToFallbackToInteractionError();return s.error("useMsalAuthentication - Interaction required, falling back to interaction"),E(a,i)}throw e})))().then(e=>(p([e,null]),e)).catch(e=>{throw p([null,e]),e})},[c,e,n,s,u,E]);return t.useEffect(()=>{const e=c.addEventCallback(e=>{switch(e.eventType){case r.EventType.LOGIN_SUCCESS:case r.EventType.SSO_SILENT_SUCCESS:e.payload&&p([e.payload,null]);break;case r.EventType.LOGIN_FAILURE:case r.EventType.SSO_SILENT_FAILURE:e.error&&p([null,e.error])}});return s.verbose("useMsalAuthentication - Registered event callback with id: "+e),()=>{e&&(s.verbose("useMsalAuthentication - Removing event callback "+e),c.removeEventCallback(e))}},[c,s]),t.useEffect(()=>{f.current&&a===r.InteractionStatus.None&&(f.current=!1,i?u&&(s.info("useMsalAuthentication - User is authenticated, attempting to acquire token"),v().catch(()=>{})):(s.info("useMsalAuthentication - No user is authenticated, attempting to login"),E().catch(()=>{})))},[i,u,a,E,v,s]),{login:E,acquireToken:v,result:l,error:g}}exports.AuthenticatedTemplate=function(e){let{username:o,homeAccountId:c,localAccountId:s,children:i}=e;const u=d();return h(t.useMemo(()=>({username:o,homeAccountId:c,localAccountId:s}),[o,c,s]))&&u.inProgress!==r.InteractionStatus.Startup?n.createElement(n.Fragment,null,a(i,u)):null},exports.MsalAuthenticationTemplate=function(e){let{interactionType:o,username:c,homeAccountId:s,localAccountId:i,authenticationRequest:u,loadingComponent:l,errorComponent:g,children:p}=e;const m=t.useMemo(()=>({username:c,homeAccountId:s,localAccountId:i}),[c,s,i]),I=d(),f=A(o,u,m),E=h(m);if(f.error&&I.inProgress===r.InteractionStatus.None){if(g)return n.createElement(g,Object.assign({},f));throw f.error}return E?n.createElement(n.Fragment,null,a(p,f)):l&&I.inProgress!==r.InteractionStatus.None?n.createElement(l,Object.assign({},I)):null},exports.MsalConsumer=c,exports.MsalContext=o,exports.MsalProvider=function(e){let{instance:c,children:a}=e;t.useEffect(()=>{c.initializeWrapperLibrary(r.WrapperSKU.React,"1.4.0")},[c]);const s=t.useMemo(()=>c.getLogger().clone("@azure/msal-react","1.4.0"),[c]),[i,d]=t.useReducer(l,void 0,()=>({inProgress:r.InteractionStatus.Startup,accounts:c.getAllAccounts()}));return t.useEffect(()=>{const e=c.addEventCallback(e=>{d({payload:{instance:c,logger:s,message:e},type:u.EVENT})});return s.verbose("MsalProvider - Registered event callback with id: "+e),c.initialize().then(()=>{c.handleRedirectPromise().catch(()=>{}).finally(()=>{d({payload:{instance:c,logger:s},type:u.UNBLOCK_INPROGRESS})})}),()=>{e&&(s.verbose("MsalProvider - Removing event callback "+e),c.removeEventCallback(e))}},[c,s]),n.createElement(o.Provider,{value:{instance:c,inProgress:i.inProgress,accounts:i.accounts,logger:s}},a)},exports.UnauthenticatedTemplate=function(e){let{username:o,homeAccountId:c,localAccountId:s,children:i}=e;const u=d();return h(t.useMemo(()=>({username:o,homeAccountId:c,localAccountId:s}),[o,c,s]))||u.inProgress===r.InteractionStatus.Startup||u.inProgress===r.InteractionStatus.HandleRedirect?null:n.createElement(n.Fragment,null,a(i,u))},exports.useAccount=m,exports.useIsAuthenticated=h,exports.useMsal=d,exports.useMsalAuthentication=A,exports.version="1.4.0",exports.withMsal=e=>{const t=t=>{const r=d();return n.createElement(e,Object.assign({},t,{msalContext:r}))};return t.displayName=`withMsal(${e.displayName||e.name||"Component"})`,t};
2
2
  //# sourceMappingURL=msal-react.cjs.production.min.js.map