@azure/msal-react 1.0.2 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +130 -0
- package/CHANGELOG.md +138 -99
- package/LICENSE +21 -21
- package/README.md +143 -142
- package/dist/index.d.ts +1 -0
- package/dist/msal-react.cjs.development.js +13 -1
- package/dist/msal-react.cjs.development.js.map +1 -1
- package/dist/msal-react.cjs.production.min.js +1 -1
- package/dist/msal-react.cjs.production.min.js.map +1 -1
- package/dist/msal-react.esm.js +13 -2
- package/dist/msal-react.esm.js.map +1 -1
- package/dist/packageMetadata.d.ts +1 -1
- package/package.json +10 -4
package/README.md
CHANGED
|
@@ -1,142 +1,143 @@
|
|
|
1
|
-
# Microsoft Authentication Library for React (msal-react)
|
|
2
|
-
|
|
3
|
-
[](https://www.npmjs.com/package/@azure/msal-react/)
|
|
4
|
-
[](https://nodei.co/npm/@azure/msal-react/)
|
|
5
|
-
[](https://codecov.io/gh/AzureAD/microsoft-authentication-library-for-js)
|
|
6
|
-
|
|
7
|
-
| <a href="https://docs.microsoft.com/azure/active-directory/develop/tutorial-v2-react" target="blank">Getting Started</a> | <a href="https://aka.ms/aaddevv2" target="_blank">AAD Docs</a> | <a href="https://azuread.github.io/microsoft-authentication-library-for-js/ref/modules/_azure_msal_react.html" target="_blank">Library Reference</a> | <a href="https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/samples" target="blank">Samples</a>
|
|
8
|
-
|--- | --- | --- | --- |
|
|
9
|
-
|
|
10
|
-
1. [About](#about)
|
|
11
|
-
1. [FAQ](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-react/FAQ.md)
|
|
12
|
-
1. [
|
|
13
|
-
1. [
|
|
14
|
-
1. [
|
|
15
|
-
1. [
|
|
16
|
-
|
|
17
|
-
- [
|
|
18
|
-
- [
|
|
19
|
-
- [
|
|
20
|
-
|
|
21
|
-
1. [
|
|
22
|
-
1. [
|
|
23
|
-
1. [
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
npm install
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
1. [
|
|
97
|
-
1. [
|
|
98
|
-
1. [Managing
|
|
99
|
-
1. [
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
- [
|
|
105
|
-
- [
|
|
106
|
-
- [
|
|
107
|
-
- [
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
1. [
|
|
113
|
-
1. [
|
|
114
|
-
1. [
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
- [Create React App (
|
|
122
|
-
- [
|
|
123
|
-
- [
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
- [React SPA calling Express.js web API
|
|
129
|
-
- [React SPA calling
|
|
130
|
-
- [
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
1
|
+
# Microsoft Authentication Library for React (msal-react)
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@azure/msal-react/)
|
|
4
|
+
[](https://nodei.co/npm/@azure/msal-react/)
|
|
5
|
+
[](https://codecov.io/gh/AzureAD/microsoft-authentication-library-for-js)
|
|
6
|
+
|
|
7
|
+
| <a href="https://docs.microsoft.com/azure/active-directory/develop/tutorial-v2-react" target="blank">Getting Started</a> | <a href="https://aka.ms/aaddevv2" target="_blank">AAD Docs</a> | <a href="https://azuread.github.io/microsoft-authentication-library-for-js/ref/modules/_azure_msal_react.html" target="_blank">Library Reference</a> | <a href="https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/samples" target="blank">Samples</a>
|
|
8
|
+
|--- | --- | --- | --- |
|
|
9
|
+
|
|
10
|
+
1. [About](#about)
|
|
11
|
+
1. [FAQ](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-react/FAQ.md)
|
|
12
|
+
1. [Changelog](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-react/CHANGELOG.md)
|
|
13
|
+
1. [Prerequisites](#prerequisites)
|
|
14
|
+
1. [Installation](#installation)
|
|
15
|
+
1. [Build and Test](#build-and-test)
|
|
16
|
+
1. [Usage](#usage)
|
|
17
|
+
- [Getting Started](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-react/docs/getting-started.md)
|
|
18
|
+
- [Msal Basics](#msal-basics)
|
|
19
|
+
- [Advanced Topics](#advanced-topics)
|
|
20
|
+
- [MSAL React Specific Concepts](#msal-react-specific-concepts)
|
|
21
|
+
1. [Samples](#samples)
|
|
22
|
+
1. [Security Reporting](#security-reporting)
|
|
23
|
+
1. [License](#license)
|
|
24
|
+
1. [Code of Conduct](#we-value-and-adhere-to-the-microsoft-open-source-code-of-conduct)
|
|
25
|
+
|
|
26
|
+
## About
|
|
27
|
+
|
|
28
|
+
The MSAL library for JavaScript enables client-side JavaScript applications to authenticate users using [Azure AD](https://docs.microsoft.com/azure/active-directory/develop/v2-overview) work and school accounts (AAD), Microsoft personal accounts (MSA) and social identity providers like Facebook, Google, LinkedIn, Microsoft accounts, etc. through [Azure AD B2C](https://docs.microsoft.com/azure/active-directory-b2c/active-directory-b2c-overview#identity-providers) service. It also enables your app to get tokens to access [Microsoft Cloud](https://www.microsoft.com/enterprise) services such as [Microsoft Graph](https://graph.microsoft.io).
|
|
29
|
+
|
|
30
|
+
The `@azure/msal-react` package described by the code in this folder uses the [`@azure/msal-browser` package](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/lib/msal-browser) as a peer dependency to enable authentication in Javascript Single-Page Applications without backend servers. This version of the library uses the OAuth 2.0 Authorization Code Flow with PKCE. To read more about this protocol, as well as the differences between implicit flow and authorization code flow, see the section in the [@azure/msal-browser readme](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/README.md#implicit-flow-vs-authorization-code-flow-with-pkce).
|
|
31
|
+
|
|
32
|
+
## Prerequisites
|
|
33
|
+
|
|
34
|
+
- `@azure/msal-react` is meant to be used in [Single-Page Application scenarios](https://docs.microsoft.com/azure/active-directory/develop/scenario-spa-overview).
|
|
35
|
+
|
|
36
|
+
- Before using `@azure/msal-react` you will need to [register a Single Page Application in Azure AD](https://docs.microsoft.com/en-us/azure/active-directory/develop/scenario-spa-app-registration) to get a valid `clientId` for configuration, and to register the routes that your app will accept redirect traffic on.
|
|
37
|
+
|
|
38
|
+
## Installation
|
|
39
|
+
|
|
40
|
+
The MSAL React package is available on NPM.
|
|
41
|
+
|
|
42
|
+
```sh
|
|
43
|
+
npm install react react-dom
|
|
44
|
+
npm install @azure/msal-react @azure/msal-browser
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Build and Test
|
|
48
|
+
|
|
49
|
+
See the [`contributing.md`](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/contributing.md) file for more information.
|
|
50
|
+
|
|
51
|
+
### Building the package locally
|
|
52
|
+
|
|
53
|
+
To build the `@azure/msal-react` library, you can do the following:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
// Install dev dependencies from root of repo
|
|
57
|
+
npm install
|
|
58
|
+
// Change to the msal-react package directory
|
|
59
|
+
cd lib/msal-react/
|
|
60
|
+
// To run build only for react package
|
|
61
|
+
npm run build
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
To build both the `@azure/msal-react` library and `@azure/msal-browser` libraries, you can do the following:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
// Install dev dependencies from root of repo
|
|
68
|
+
npm install
|
|
69
|
+
// Change to the msal-react package directory
|
|
70
|
+
cd lib/msal-react/
|
|
71
|
+
// To run build for react and browser packages
|
|
72
|
+
npm run build:all
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Running Tests
|
|
76
|
+
|
|
77
|
+
`@azure/msal-react` uses [jest](https://jestjs.io/) to run unit tests and coverage.
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
// To run tests
|
|
81
|
+
npm test
|
|
82
|
+
// To run tests with code coverage
|
|
83
|
+
npm run test:coverage
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Usage
|
|
87
|
+
|
|
88
|
+
For help getting started with `@azure/msal-react` please see our [getting started](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-react/docs/getting-started.md) doc.
|
|
89
|
+
|
|
90
|
+
Migrating from [react-aad-msal](https://www.npmjs.com/package/react-aad-msal)? Check out our [migration guide](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-react/docs/migration-guide.md).
|
|
91
|
+
|
|
92
|
+
### MSAL Basics
|
|
93
|
+
|
|
94
|
+
Since `@azure/msal-react` is a wrapper around `@azure/msal-browser` many docs from the `msal-browser` repo are relevant here as well. For concepts specific to `@azure/msal-react` please see [below](#msal-react-specific-concepts)
|
|
95
|
+
|
|
96
|
+
1. [Initialization](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/docs/initialization.md)
|
|
97
|
+
1. [Acquiring and using an access token](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/docs/acquire-token.md)
|
|
98
|
+
1. [Managing token lifetimes](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/docs/token-lifetimes.md)
|
|
99
|
+
1. [Managing Accounts](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-common/docs/Accounts.md)
|
|
100
|
+
1. [Logging out](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/docs/logout.md)
|
|
101
|
+
|
|
102
|
+
### Advanced Topics
|
|
103
|
+
|
|
104
|
+
- [Configuration Options](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/docs/configuration.md)
|
|
105
|
+
- [Request and Response Details](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/docs/request-response-object.md)
|
|
106
|
+
- [Events](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/docs/events.md)
|
|
107
|
+
- [Cache Storage](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/docs/caching.md)
|
|
108
|
+
- [Performance Enhancements](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/docs/performance.md)
|
|
109
|
+
|
|
110
|
+
### MSAL React Specific Concepts
|
|
111
|
+
|
|
112
|
+
1. [Hooks](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-react/docs/hooks.md)
|
|
113
|
+
1. [Events](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-react/docs/events.md)
|
|
114
|
+
1. [Class Components](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-react/docs/class-components.md)
|
|
115
|
+
1. [Performance](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-react/docs/performance.md)
|
|
116
|
+
|
|
117
|
+
## Samples
|
|
118
|
+
|
|
119
|
+
Our [samples directory](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/samples/msal-react-samples) contains several example apps you can spin up to see how this library can be used in different contexts.
|
|
120
|
+
|
|
121
|
+
- [Create React App (JS) Sample](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/samples/msal-react-samples/react-router-sample)
|
|
122
|
+
- [Create React App (TS) Sample](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/samples/msal-react-samples/typescript-sample)
|
|
123
|
+
- [Next.js Sample](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/samples/msal-react-samples/nextjs-sample)
|
|
124
|
+
- [Gatsby Sample](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/samples/msal-react-samples/gatsby-sample)
|
|
125
|
+
|
|
126
|
+
More advanced samples backed with a tutorial can be found in the [Azure Samples](https://github.com/Azure-Samples) space on GitHub:
|
|
127
|
+
|
|
128
|
+
- [React SPA calling Express.js web API](https://github.com/Azure-Samples/ms-identity-javascript-react-tutorial/tree/main/3-Authorization-II/1-call-api)
|
|
129
|
+
- [React SPA calling Express.js web API using Proof of Possesion tokens](https://github.com/Azure-Samples/ms-identity-javascript-react-tutorial/tree/main/6-AdvancedScenarios/2-call-api-pop)
|
|
130
|
+
- [React SPA calling Microsoft Graph via Express.js web API using on-behalf-of flow](https://github.com/Azure-Samples/ms-identity-javascript-react-tutorial/tree/main/6-AdvancedScenarios/1-call-api-obo)
|
|
131
|
+
- [Deployment tutorial for Azure Static Web Apps](https://github.com/Azure-Samples/ms-identity-javascript-react-tutorial/tree/main/4-Deployment/2-deploy-static)
|
|
132
|
+
|
|
133
|
+
## Security Reporting
|
|
134
|
+
|
|
135
|
+
If you find a security issue with our libraries or services please report it to [secure@microsoft.com](mailto:secure@microsoft.com) with as much detail as possible. Your submission may be eligible for a bounty through the [Microsoft Bounty](http://aka.ms/bugbounty) program. Please do not post security issues to GitHub Issues or any other public site. We will contact you shortly upon receiving the information. We encourage you to get notifications of when security incidents occur by visiting [this page](https://technet.microsoft.com/security/dd252948) and subscribing to Security Advisory Alerts.
|
|
136
|
+
|
|
137
|
+
## License
|
|
138
|
+
|
|
139
|
+
Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License.
|
|
140
|
+
|
|
141
|
+
## We Value and Adhere to the Microsoft Open Source Code of Conduct
|
|
142
|
+
|
|
143
|
+
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
|
package/dist/index.d.ts
CHANGED
|
@@ -20,3 +20,4 @@ export { useMsal } from "./hooks/useMsal";
|
|
|
20
20
|
export { useAccount } from "./hooks/useAccount";
|
|
21
21
|
export { useIsAuthenticated } from "./hooks/useIsAuthenticated";
|
|
22
22
|
export { useMsalAuthentication } from "./hooks/useMsalAuthentication";
|
|
23
|
+
export { version } from "./packageMetadata";
|
|
@@ -63,7 +63,7 @@ function accountArraysAreEqual(arrayA, arrayB) {
|
|
|
63
63
|
|
|
64
64
|
/* eslint-disable header/header */
|
|
65
65
|
const name = "@azure/msal-react";
|
|
66
|
-
const version = "1.0
|
|
66
|
+
const version = "1.2.0";
|
|
67
67
|
|
|
68
68
|
/*
|
|
69
69
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -89,6 +89,8 @@ function MsalProvider({
|
|
|
89
89
|
React.useEffect(() => {
|
|
90
90
|
const callbackId = instance.addEventCallback(message => {
|
|
91
91
|
switch (message.eventType) {
|
|
92
|
+
case msalBrowser.EventType.ACCOUNT_ADDED:
|
|
93
|
+
case msalBrowser.EventType.ACCOUNT_REMOVED:
|
|
92
94
|
case msalBrowser.EventType.LOGIN_SUCCESS:
|
|
93
95
|
case msalBrowser.EventType.SSO_SILENT_SUCCESS:
|
|
94
96
|
case msalBrowser.EventType.HANDLE_REDIRECT_END:
|
|
@@ -132,6 +134,15 @@ function MsalProvider({
|
|
|
132
134
|
instance.handleRedirectPromise().catch(() => {
|
|
133
135
|
// Errors should be handled by listening to the LOGIN_FAILURE event
|
|
134
136
|
return;
|
|
137
|
+
}).finally(() => {
|
|
138
|
+
/*
|
|
139
|
+
* If handleRedirectPromise returns a cached promise the necessary events may not be fired
|
|
140
|
+
* This is a fallback to prevent inProgress from getting stuck in 'startup'
|
|
141
|
+
*/
|
|
142
|
+
if (inProgressRef.current === msalBrowser.InteractionStatus.Startup) {
|
|
143
|
+
inProgressRef.current = msalBrowser.InteractionStatus.None;
|
|
144
|
+
setInProgress(msalBrowser.InteractionStatus.None);
|
|
145
|
+
}
|
|
135
146
|
});
|
|
136
147
|
return () => {
|
|
137
148
|
if (callbackId) {
|
|
@@ -480,5 +491,6 @@ exports.useAccount = useAccount;
|
|
|
480
491
|
exports.useIsAuthenticated = useIsAuthenticated;
|
|
481
492
|
exports.useMsal = useMsal;
|
|
482
493
|
exports.useMsalAuthentication = useMsalAuthentication;
|
|
494
|
+
exports.version = version;
|
|
483
495
|
exports.withMsal = withMsal;
|
|
484
496
|
//# sourceMappingURL=msal-react.cjs.development.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"msal-react.cjs.development.js","sources":["../src/MsalContext.ts","../src/utils/utilities.ts","../src/packageMetadata.ts","../src/MsalProvider.tsx","../src/hooks/useMsal.ts","../src/hooks/useAccount.ts","../src/hooks/useIsAuthenticated.ts","../src/components/AuthenticatedTemplate.tsx","../src/components/UnauthenticatedTemplate.tsx","../src/hooks/useMsalAuthentication.ts","../src/components/MsalAuthenticationTemplate.tsx","../src/components/withMsal.tsx"],"sourcesContent":["/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport * as React from \"react\";\r\nimport { IPublicClientApplication, stubbedPublicClientApplication, Logger, InteractionStatus, AccountInfo } from \"@azure/msal-browser\";\r\n\r\nexport interface IMsalContext {\r\n instance: IPublicClientApplication;\r\n inProgress: InteractionStatus;\r\n accounts: AccountInfo[];\r\n logger: Logger;\r\n}\r\n\r\n/*\r\n * Stubbed context implementation\r\n * Only used when there is no provider, which is an unsupported scenario\r\n */\r\nconst defaultMsalContext: IMsalContext = {\r\n instance: stubbedPublicClientApplication,\r\n inProgress: InteractionStatus.None,\r\n accounts: [],\r\n logger: new Logger({})\r\n};\r\n\r\nexport const MsalContext = React.createContext<IMsalContext>(\r\n defaultMsalContext\r\n);\r\nexport const MsalConsumer = MsalContext.Consumer;\r\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { AccountIdentifiers } from \"../types/AccountIdentifiers\";\r\n\r\ntype FaaCFunction = <T>(args: T) => React.ReactNode;\r\n\r\nexport function getChildrenOrFunction<T>(\r\n children: React.ReactNode | FaaCFunction,\r\n args: T\r\n): React.ReactNode {\r\n if (typeof children === \"function\") {\r\n return children(args);\r\n }\r\n return children;\r\n}\r\n\r\n/*\r\n * Utility types\r\n * Reference: https://github.com/piotrwitek/utility-types\r\n */\r\ntype SetDifference<A, B> = A extends B ? never : A;\r\ntype SetComplement<A, A1 extends A> = SetDifference<A, A1>;\r\nexport type Subtract<T extends T1, T1 extends object> = Pick<T,SetComplement<keyof T, keyof T1>>;\r\n\r\n/**\r\n * Helper function to determine whether 2 arrays are equal\r\n * Used to avoid unnecessary state updates\r\n * @param arrayA \r\n * @param arrayB \r\n */\r\nexport function accountArraysAreEqual(arrayA: Array<AccountIdentifiers>, arrayB: Array<AccountIdentifiers>): boolean {\r\n if (arrayA.length !== arrayB.length) {\r\n return false;\r\n }\r\n\r\n const comparisonArray = [...arrayB];\r\n\r\n return arrayA.every((elementA) => {\r\n const elementB = comparisonArray.shift();\r\n if (!elementA || !elementB) {\r\n return false;\r\n }\r\n\r\n return (elementA.homeAccountId === elementB.homeAccountId) && \r\n (elementA.localAccountId === elementB.localAccountId) &&\r\n (elementA.username === elementB.username);\r\n });\r\n}\r\n","/* eslint-disable header/header */\nexport const name = \"@azure/msal-react\";\nexport const version = \"1.0.2\";\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport React, { useState, useEffect, useRef, PropsWithChildren, useMemo } from \"react\";\r\nimport {\r\n IPublicClientApplication,\r\n EventType,\r\n EventMessage,\r\n EventMessageUtils,\r\n InteractionStatus,\r\n Logger,\r\n WrapperSKU,\r\n AccountInfo\r\n} from \"@azure/msal-browser\";\r\nimport { MsalContext, IMsalContext } from \"./MsalContext\";\r\nimport { accountArraysAreEqual } from \"./utils/utilities\";\r\nimport { name as SKU, version } from \"./packageMetadata\";\r\n\r\nexport type MsalProviderProps = PropsWithChildren<{\r\n instance: IPublicClientApplication;\r\n}>;\r\n\r\nexport function MsalProvider({instance, children}: MsalProviderProps): React.ReactElement {\r\n useEffect(() => {\r\n instance.initializeWrapperLibrary(WrapperSKU.React, version);\r\n }, [instance]);\r\n // Create a logger instance for msal-react with the same options as PublicClientApplication\r\n const logger: Logger = useMemo(() => {\r\n return instance.getLogger().clone(SKU, version);\r\n }, [instance]);\r\n\r\n // State hook to store accounts\r\n const [accounts, setAccounts] = useState<AccountInfo[]>([]);\r\n // State hook to store in progress value\r\n const [inProgress, setInProgress] = useState<InteractionStatus>(InteractionStatus.Startup);\r\n // Mutable object used in the event callback\r\n const inProgressRef = useRef(inProgress);\r\n \r\n useEffect(() => {\r\n const callbackId = instance.addEventCallback((message: EventMessage) => {\r\n switch (message.eventType) {\r\n case EventType.LOGIN_SUCCESS:\r\n case EventType.SSO_SILENT_SUCCESS:\r\n case EventType.HANDLE_REDIRECT_END:\r\n case EventType.LOGIN_FAILURE:\r\n case EventType.SSO_SILENT_FAILURE:\r\n case EventType.LOGOUT_END:\r\n case EventType.ACQUIRE_TOKEN_SUCCESS:\r\n case EventType.ACQUIRE_TOKEN_FAILURE:\r\n const currentAccounts = instance.getAllAccounts();\r\n if (!accountArraysAreEqual(currentAccounts, accounts)) {\r\n logger.info(\"MsalProvider - updating account state\");\r\n setAccounts(currentAccounts);\r\n } else {\r\n logger.info(\"MsalProvider - no account changes\");\r\n }\r\n break;\r\n }\r\n });\r\n logger.verbose(`MsalProvider - Registered event callback with id: ${callbackId}`);\r\n\r\n return () => {\r\n // Remove callback when component unmounts or accounts change\r\n if (callbackId) {\r\n logger.verbose(`MsalProvider - Removing event callback ${callbackId}`);\r\n instance.removeEventCallback(callbackId);\r\n }\r\n };\r\n }, [instance, accounts, logger]);\r\n\r\n useEffect(() => {\r\n const callbackId = instance.addEventCallback((message: EventMessage) => {\r\n const status = EventMessageUtils.getInteractionStatusFromEvent(message, inProgressRef.current);\r\n if (status !== null) {\r\n logger.info(`MsalProvider - ${message.eventType} results in setting inProgress from ${inProgressRef.current} to ${status}`);\r\n inProgressRef.current = status;\r\n setInProgress(status);\r\n }\r\n });\r\n logger.verbose(`MsalProvider - Registered event callback with id: ${callbackId}`);\r\n\r\n instance.handleRedirectPromise().catch(() => {\r\n // Errors should be handled by listening to the LOGIN_FAILURE event\r\n return;\r\n });\r\n\r\n return () => {\r\n if (callbackId) {\r\n logger.verbose(`MsalProvider - Removing event callback ${callbackId}`);\r\n instance.removeEventCallback(callbackId);\r\n }\r\n };\r\n }, [instance, logger]);\r\n\r\n const contextValue: IMsalContext = {\r\n instance,\r\n inProgress,\r\n accounts,\r\n logger\r\n };\r\n\r\n return (\r\n <MsalContext.Provider value={contextValue}>\r\n {children}\r\n </MsalContext.Provider>\r\n );\r\n}\r\n\r\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { useContext } from \"react\";\r\nimport { IMsalContext, MsalContext } from \"../MsalContext\";\r\n\r\n/**\r\n * Returns Msal Context values\r\n */\r\nexport const useMsal = (): IMsalContext => useContext(MsalContext);\r\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { useState, useEffect } from \"react\";\r\nimport { AccountInfo, IPublicClientApplication, InteractionStatus, AccountEntity } from \"@azure/msal-browser\";\r\nimport { useMsal } from \"./useMsal\";\r\nimport { AccountIdentifiers } from \"../types/AccountIdentifiers\";\r\n\r\nfunction getAccount(instance: IPublicClientApplication, accountIdentifiers: AccountIdentifiers): AccountInfo | null {\r\n const allAccounts = instance.getAllAccounts();\r\n if (allAccounts.length > 0 && (accountIdentifiers.homeAccountId || accountIdentifiers.localAccountId || accountIdentifiers.username)) {\r\n const matchedAccounts = allAccounts.filter(accountObj => {\r\n if (accountIdentifiers.username && accountIdentifiers.username.toLowerCase() !== accountObj.username.toLowerCase()) {\r\n return false;\r\n }\r\n if (accountIdentifiers.homeAccountId && accountIdentifiers.homeAccountId.toLowerCase() !== accountObj.homeAccountId.toLowerCase()) {\r\n return false;\r\n }\r\n if (accountIdentifiers.localAccountId && accountIdentifiers.localAccountId.toLowerCase() !== accountObj.localAccountId.toLowerCase()) {\r\n return false;\r\n }\r\n\r\n return true;\r\n });\r\n\r\n return matchedAccounts[0] || null;\r\n } else {\r\n return null;\r\n }\r\n}\r\n\r\n/**\r\n * Given 1 or more accountIdentifiers, returns the Account object if the user is signed-in\r\n * @param accountIdentifiers \r\n */\r\nexport function useAccount(accountIdentifiers: AccountIdentifiers): AccountInfo | null {\r\n const { instance, inProgress } = useMsal();\r\n\r\n const initialStateValue = inProgress === InteractionStatus.Startup ? null : getAccount(instance, accountIdentifiers);\r\n const [account, setAccount] = useState<AccountInfo|null>(initialStateValue);\r\n\r\n useEffect(() => {\r\n const currentAccount = getAccount(instance, accountIdentifiers);\r\n if (!AccountEntity.accountInfoIsEqual(account, currentAccount, true)) {\r\n setAccount(currentAccount);\r\n }\r\n }, [inProgress, accountIdentifiers, instance, account]);\r\n\r\n return account;\r\n}\r\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { useState, useEffect } from \"react\";\r\nimport { useMsal } from \"./useMsal\";\r\nimport { AccountIdentifiers } from \"../types/AccountIdentifiers\";\r\nimport { useAccount } from \"./useAccount\";\r\nimport { AccountInfo, InteractionStatus } from \"@azure/msal-browser\";\r\n\r\nfunction isAuthenticated(allAccounts: AccountIdentifiers[], account: AccountInfo | null, matchAccount?: AccountIdentifiers): boolean {\r\n if(matchAccount && (matchAccount.username || matchAccount.homeAccountId || matchAccount.localAccountId)) {\r\n return !!account;\r\n } \r\n\r\n return allAccounts.length > 0;\r\n}\r\n\r\n/**\r\n * Returns whether or not a user is currently signed-in. Optionally provide 1 or more accountIdentifiers to determine if a specific user is signed-in\r\n * @param matchAccount \r\n */\r\nexport function useIsAuthenticated(matchAccount?: AccountIdentifiers): boolean {\r\n const { accounts: allAccounts, inProgress } = useMsal();\r\n const account = useAccount(matchAccount || {});\r\n\r\n const initialStateValue = inProgress === InteractionStatus.Startup ? false : isAuthenticated(allAccounts, account, matchAccount);\r\n const [hasAuthenticated, setHasAuthenticated] = useState<boolean>(initialStateValue);\r\n\r\n useEffect(() => {\r\n setHasAuthenticated(isAuthenticated(allAccounts, account, matchAccount));\r\n }, [allAccounts, account, matchAccount]);\r\n\r\n return hasAuthenticated;\r\n}\r\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport React, { PropsWithChildren, useMemo } from \"react\";\r\nimport { AccountIdentifiers } from \"../types/AccountIdentifiers\";\r\nimport { getChildrenOrFunction } from \"../utils/utilities\";\r\nimport { useMsal } from \"../hooks/useMsal\";\r\nimport { useIsAuthenticated } from \"../hooks/useIsAuthenticated\";\r\nimport { InteractionStatus } from \"@azure/msal-browser\";\r\n\r\nexport type AuthenticatedTemplateProps = PropsWithChildren<AccountIdentifiers>;\r\n\r\n/**\r\n * Renders child components if user is authenticated\r\n * @param props \r\n */\r\nexport function AuthenticatedTemplate({ username, homeAccountId, localAccountId, children }: AuthenticatedTemplateProps): React.ReactElement|null {\r\n const context = useMsal();\r\n const accountIdentifier: AccountIdentifiers = useMemo(() => {\r\n return {\r\n username,\r\n homeAccountId,\r\n localAccountId\r\n };\r\n }, [username, homeAccountId, localAccountId]);\r\n const isAuthenticated = useIsAuthenticated(accountIdentifier);\r\n\r\n if (isAuthenticated && context.inProgress !== InteractionStatus.Startup) {\r\n return (\r\n <React.Fragment>\r\n {getChildrenOrFunction(children, context)}\r\n </React.Fragment>\r\n );\r\n }\r\n return null;\r\n}\r\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport React, { PropsWithChildren, useMemo } from \"react\";\r\nimport { useMsal } from \"../hooks/useMsal\";\r\nimport { useIsAuthenticated } from \"../hooks/useIsAuthenticated\";\r\nimport { getChildrenOrFunction } from \"../utils/utilities\";\r\nimport { AccountIdentifiers } from \"../types/AccountIdentifiers\";\r\nimport { InteractionStatus } from \"@azure/msal-browser\";\r\n\r\nexport type UnauthenticatedTemplateProps = PropsWithChildren<AccountIdentifiers>;\r\n\r\n/**\r\n * Renders child components if user is unauthenticated\r\n * @param props \r\n */\r\nexport function UnauthenticatedTemplate({ username, homeAccountId, localAccountId, children }: UnauthenticatedTemplateProps): React.ReactElement|null {\r\n const context = useMsal();\r\n const accountIdentifier: AccountIdentifiers = useMemo(() => {\r\n return {\r\n username,\r\n homeAccountId,\r\n localAccountId\r\n };\r\n }, [username, homeAccountId, localAccountId]);\r\n const isAuthenticated = useIsAuthenticated(accountIdentifier);\r\n\r\n if (!isAuthenticated && context.inProgress !== InteractionStatus.Startup && context.inProgress !== InteractionStatus.HandleRedirect) {\r\n return (\r\n <React.Fragment>\r\n {getChildrenOrFunction(children, context)}\r\n </React.Fragment>\r\n );\r\n }\r\n return null;\r\n}\r\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { useCallback, useEffect, useState } from \"react\";\r\nimport { PopupRequest, RedirectRequest, SsoSilentRequest, InteractionType, AuthenticationResult, AuthError, EventMessage, EventType, InteractionStatus } from \"@azure/msal-browser\";\r\nimport { useIsAuthenticated } from \"./useIsAuthenticated\";\r\nimport { AccountIdentifiers } from \"../types/AccountIdentifiers\";\r\nimport { useMsal } from \"./useMsal\";\r\n\r\nexport type MsalAuthenticationResult = {\r\n login: Function; \r\n result: AuthenticationResult|null;\r\n error: AuthError|null;\r\n};\r\n\r\n/**\r\n * Invokes a login call if a user is not currently signed-in. Failed logins can be retried using the login callback returned.\r\n * Optionally provide a request object to be used in the login call.\r\n * Optionally provide a specific user that should be logged in.\r\n * @param interactionType \r\n * @param authenticationRequest \r\n * @param accountIdentifiers \r\n */\r\nexport function useMsalAuthentication(\r\n interactionType: InteractionType, \r\n authenticationRequest?: PopupRequest|RedirectRequest|SsoSilentRequest, \r\n accountIdentifiers?: AccountIdentifiers\r\n): MsalAuthenticationResult {\r\n const { instance, inProgress, logger } = useMsal();\r\n const isAuthenticated = useIsAuthenticated(accountIdentifiers);\r\n const [[result, error], setResponse] = useState<[AuthenticationResult|null, AuthError|null]>([null, null]);\r\n const [hasBeenCalled, setHasBeenCalled] = useState<boolean>(false);\r\n\r\n const login = useCallback(async (callbackInteractionType?: InteractionType, callbackRequest?: PopupRequest|RedirectRequest|SsoSilentRequest): Promise<AuthenticationResult|null> => {\r\n const loginType = callbackInteractionType || interactionType;\r\n const loginRequest = callbackRequest || authenticationRequest;\r\n switch (loginType) {\r\n case InteractionType.Popup:\r\n logger.verbose(\"useMsalAuthentication - Calling loginPopup\");\r\n return instance.loginPopup(loginRequest as PopupRequest);\r\n case InteractionType.Redirect:\r\n // This promise is not expected to resolve due to full frame redirect\r\n logger.verbose(\"useMsalAuthentication - Calling loginRedirect\");\r\n return instance.loginRedirect(loginRequest as RedirectRequest).then(null);\r\n case InteractionType.Silent:\r\n logger.verbose(\"useMsalAuthentication - Calling ssoSilent\");\r\n return instance.ssoSilent(loginRequest as SsoSilentRequest);\r\n default:\r\n throw \"Invalid interaction type provided.\";\r\n }\r\n }, [instance, interactionType, authenticationRequest, logger]);\r\n\r\n useEffect(() => {\r\n const callbackId = instance.addEventCallback((message: EventMessage) => {\r\n switch(message.eventType) {\r\n case EventType.LOGIN_SUCCESS:\r\n case EventType.SSO_SILENT_SUCCESS:\r\n if (message.payload) {\r\n setResponse([message.payload as AuthenticationResult, null]);\r\n }\r\n break;\r\n case EventType.LOGIN_FAILURE:\r\n case EventType.SSO_SILENT_FAILURE:\r\n if (message.error) {\r\n setResponse([null, message.error as AuthError]);\r\n }\r\n break;\r\n }\r\n });\r\n logger.verbose(`useMsalAuthentication - Registered event callback with id: ${callbackId}`);\r\n\r\n return () => {\r\n if (callbackId) {\r\n logger.verbose(`useMsalAuthentication - Removing event callback ${callbackId}`);\r\n instance.removeEventCallback(callbackId);\r\n }\r\n };\r\n }, [instance, logger]);\r\n\r\n useEffect(() => {\r\n if (!hasBeenCalled && !error && !isAuthenticated && inProgress === InteractionStatus.None) {\r\n logger.info(\"useMsalAuthentication - No user is authenticated, attempting to login\");\r\n // Ensure login is only called one time from within this hook, any subsequent login attempts should use the callback returned\r\n setHasBeenCalled(true);\r\n login().catch(() => {\r\n // Errors are handled by the event handler above\r\n return;\r\n });\r\n }\r\n }, [isAuthenticated, inProgress, error, hasBeenCalled, login, logger]);\r\n\r\n return { login, result, error };\r\n}\r\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport React, { PropsWithChildren, useMemo } from \"react\";\r\nimport { AccountIdentifiers } from \"../types/AccountIdentifiers\";\r\nimport { getChildrenOrFunction } from \"../utils/utilities\";\r\nimport { useMsal } from \"../hooks/useMsal\";\r\nimport { MsalAuthenticationResult, useMsalAuthentication } from \"../hooks/useMsalAuthentication\";\r\nimport { useIsAuthenticated } from \"../hooks/useIsAuthenticated\";\r\nimport { InteractionType, PopupRequest, RedirectRequest, SsoSilentRequest, InteractionStatus } from \"@azure/msal-browser\";\r\nimport { IMsalContext } from \"../MsalContext\";\r\n\r\nexport type MsalAuthenticationProps = PropsWithChildren<AccountIdentifiers & {\r\n interactionType: InteractionType;\r\n authenticationRequest?: PopupRequest|RedirectRequest|SsoSilentRequest;\r\n loadingComponent?: React.ElementType<IMsalContext>;\r\n errorComponent?: React.ElementType<MsalAuthenticationResult>;\r\n}>;\r\n\r\n/**\r\n * Attempts to authenticate user if not already authenticated, then renders child components\r\n * @param props\r\n */\r\nexport function MsalAuthenticationTemplate({ \r\n interactionType, \r\n username, \r\n homeAccountId, \r\n localAccountId,\r\n authenticationRequest, \r\n loadingComponent: LoadingComponent,\r\n errorComponent: ErrorComponent,\r\n children \r\n}: MsalAuthenticationProps): React.ReactElement|null {\r\n const accountIdentifier: AccountIdentifiers = useMemo(() => {\r\n return {\r\n username,\r\n homeAccountId,\r\n localAccountId\r\n };\r\n }, [username, homeAccountId, localAccountId]);\r\n const context = useMsal();\r\n const msalAuthResult = useMsalAuthentication(interactionType, authenticationRequest, accountIdentifier);\r\n const isAuthenticated = useIsAuthenticated(accountIdentifier);\r\n\r\n if (msalAuthResult.error && context.inProgress === InteractionStatus.None) {\r\n if (!!ErrorComponent) {\r\n return <ErrorComponent {...msalAuthResult} />;\r\n }\r\n\r\n throw msalAuthResult.error;\r\n }\r\n \r\n if (isAuthenticated) {\r\n return (\r\n <React.Fragment>\r\n {getChildrenOrFunction(children, msalAuthResult)}\r\n </React.Fragment>\r\n );\r\n } \r\n \r\n if (!!LoadingComponent && context.inProgress !== InteractionStatus.None) {\r\n return <LoadingComponent {...context} />;\r\n }\r\n\r\n return null;\r\n}\r\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport React from \"react\";\r\nimport { IMsalContext } from \"../MsalContext\";\r\nimport { useMsal } from \"../hooks/useMsal\";\r\nimport { Subtract } from \"../utils/utilities\";\r\n\r\nexport type WithMsalProps = {\r\n msalContext: IMsalContext;\r\n};\r\n\r\n/**\r\n * Higher order component wraps provided component with msal by injecting msal context values into the component's props \r\n * @param Component \r\n */\r\nexport const withMsal = <P extends WithMsalProps>(Component: React.ComponentType<P>): React.FunctionComponent<Subtract<P,WithMsalProps>> => {\r\n const ComponentWithMsal: React.FunctionComponent<Subtract<P,WithMsalProps>> = props => {\r\n const msal = useMsal();\r\n return <Component {...(props as P)} msalContext={msal} />;\r\n };\r\n\r\n const componentName =\r\n Component.displayName || Component.name || \"Component\";\r\n ComponentWithMsal.displayName = `withMsal(${componentName})`;\r\n\r\n return ComponentWithMsal;\r\n};\r\n"],"names":["defaultMsalContext","instance","stubbedPublicClientApplication","inProgress","InteractionStatus","None","accounts","logger","Logger","MsalContext","React","MsalConsumer","Consumer","getChildrenOrFunction","children","args","accountArraysAreEqual","arrayA","arrayB","length","comparisonArray","every","elementA","elementB","shift","homeAccountId","localAccountId","username","name","version","MsalProvider","useEffect","initializeWrapperLibrary","WrapperSKU","useMemo","getLogger","clone","SKU","setAccounts","useState","setInProgress","Startup","inProgressRef","useRef","callbackId","addEventCallback","message","eventType","EventType","LOGIN_SUCCESS","SSO_SILENT_SUCCESS","HANDLE_REDIRECT_END","LOGIN_FAILURE","SSO_SILENT_FAILURE","LOGOUT_END","ACQUIRE_TOKEN_SUCCESS","ACQUIRE_TOKEN_FAILURE","currentAccounts","getAllAccounts","info","verbose","removeEventCallback","status","EventMessageUtils","getInteractionStatusFromEvent","current","handleRedirectPromise","catch","contextValue","Provider","value","useMsal","useContext","getAccount","accountIdentifiers","allAccounts","matchedAccounts","filter","accountObj","toLowerCase","useAccount","initialStateValue","account","setAccount","currentAccount","AccountEntity","accountInfoIsEqual","isAuthenticated","matchAccount","useIsAuthenticated","hasAuthenticated","setHasAuthenticated","AuthenticatedTemplate","context","accountIdentifier","Fragment","UnauthenticatedTemplate","HandleRedirect","useMsalAuthentication","interactionType","authenticationRequest","result","error","setResponse","hasBeenCalled","setHasBeenCalled","login","useCallback","callbackInteractionType","callbackRequest","loginType","loginRequest","InteractionType","Popup","loginPopup","Redirect","loginRedirect","then","Silent","ssoSilent","payload","MsalAuthenticationTemplate","loadingComponent","LoadingComponent","errorComponent","ErrorComponent","msalAuthResult","withMsal","Component","ComponentWithMsal","props","msal","msalContext","componentName","displayName"],"mappings":";;;;;;;;;;AAAA;;;;AAeA;;;;;AAIA,MAAMA,kBAAkB,GAAiB;AACrCC,EAAAA,QAAQ,EAAEC,0CAD2B;AAErCC,EAAAA,UAAU,EAAEC,6BAAiB,CAACC,IAFO;AAGrCC,EAAAA,QAAQ,EAAE,EAH2B;AAIrCC,EAAAA,MAAM,eAAE,IAAIC,kBAAJ,CAAW,EAAX;AAJ6B,CAAzC;MAOaC,WAAW,gBAAGC,mBAAA,CACvBV,kBADuB;MAGdW,YAAY,GAAGF,WAAW,CAACG;;AC7BxC;;;;AASA,SAAgBC,sBACZC,UACAC;AAEA,MAAI,OAAOD,QAAP,KAAoB,UAAxB,EAAoC;AAChC,WAAOA,QAAQ,CAACC,IAAD,CAAf;AACH;;AACD,SAAOD,QAAP;AACH;AAUD;;;;;;;AAMA,SAAgBE,sBAAsBC,QAAmCC;AACrE,MAAID,MAAM,CAACE,MAAP,KAAkBD,MAAM,CAACC,MAA7B,EAAqC;AACjC,WAAO,KAAP;AACH;;AAED,QAAMC,eAAe,GAAG,CAAC,GAAGF,MAAJ,CAAxB;AAEA,SAA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;AAAaE,MAAAA,WAAW,EAAED;MAA1C,CAAP;AACH,GAHD;;AAKA,QAAME,aAAa,GACfL,SAAS,CAACM,WAAV,IAAyBN,SAAS,CAACpG,IAAnC,IAA2C,WAD/C;AAEAqG,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/useAccount.ts","../src/hooks/useIsAuthenticated.ts","../src/components/AuthenticatedTemplate.tsx","../src/components/UnauthenticatedTemplate.tsx","../src/hooks/useMsalAuthentication.ts","../src/components/MsalAuthenticationTemplate.tsx","../src/components/withMsal.tsx"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport * as React from \"react\";\nimport { IPublicClientApplication, stubbedPublicClientApplication, Logger, InteractionStatus, AccountInfo } from \"@azure/msal-browser\";\n\nexport interface IMsalContext {\n instance: IPublicClientApplication;\n inProgress: InteractionStatus;\n accounts: AccountInfo[];\n logger: Logger;\n}\n\n/*\n * Stubbed context implementation\n * Only used when there is no provider, which is an unsupported scenario\n */\nconst defaultMsalContext: IMsalContext = {\n instance: stubbedPublicClientApplication,\n inProgress: InteractionStatus.None,\n accounts: [],\n logger: new Logger({})\n};\n\nexport const MsalContext = React.createContext<IMsalContext>(\n defaultMsalContext\n);\nexport const MsalConsumer = MsalContext.Consumer;\n","/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { AccountIdentifiers } from \"../types/AccountIdentifiers\";\n\ntype FaaCFunction = <T>(args: T) => React.ReactNode;\n\nexport function getChildrenOrFunction<T>(\n children: React.ReactNode | FaaCFunction,\n args: T\n): React.ReactNode {\n if (typeof children === \"function\") {\n return children(args);\n }\n return children;\n}\n\n/*\n * Utility types\n * Reference: https://github.com/piotrwitek/utility-types\n */\ntype SetDifference<A, B> = A extends B ? never : A;\ntype SetComplement<A, A1 extends A> = SetDifference<A, A1>;\nexport type Subtract<T extends T1, T1 extends object> = Pick<T,SetComplement<keyof T, keyof T1>>;\n\n/**\n * Helper function to determine whether 2 arrays are equal\n * Used to avoid unnecessary state updates\n * @param arrayA \n * @param arrayB \n */\nexport function accountArraysAreEqual(arrayA: Array<AccountIdentifiers>, arrayB: Array<AccountIdentifiers>): boolean {\n if (arrayA.length !== arrayB.length) {\n return false;\n }\n\n const comparisonArray = [...arrayB];\n\n return arrayA.every((elementA) => {\n const elementB = comparisonArray.shift();\n if (!elementA || !elementB) {\n return false;\n }\n\n return (elementA.homeAccountId === elementB.homeAccountId) && \n (elementA.localAccountId === elementB.localAccountId) &&\n (elementA.username === elementB.username);\n });\n}\n","/* eslint-disable header/header */\nexport const name = \"@azure/msal-react\";\nexport const version = \"1.2.0\";\n","/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport React, { useState, useEffect, useRef, PropsWithChildren, useMemo } from \"react\";\nimport {\n IPublicClientApplication,\n EventType,\n EventMessage,\n EventMessageUtils,\n InteractionStatus,\n Logger,\n WrapperSKU,\n AccountInfo\n} from \"@azure/msal-browser\";\nimport { MsalContext, IMsalContext } from \"./MsalContext\";\nimport { accountArraysAreEqual } from \"./utils/utilities\";\nimport { name as SKU, version } from \"./packageMetadata\";\n\nexport type MsalProviderProps = PropsWithChildren<{\n instance: IPublicClientApplication;\n}>;\n\nexport function MsalProvider({instance, children}: MsalProviderProps): React.ReactElement {\n useEffect(() => {\n instance.initializeWrapperLibrary(WrapperSKU.React, version);\n }, [instance]);\n // Create a logger instance for msal-react with the same options as PublicClientApplication\n const logger: Logger = useMemo(() => {\n return instance.getLogger().clone(SKU, version);\n }, [instance]);\n\n // State hook to store accounts\n const [accounts, setAccounts] = useState<AccountInfo[]>([]);\n // State hook to store in progress value\n const [inProgress, setInProgress] = useState<InteractionStatus>(InteractionStatus.Startup);\n // Mutable object used in the event callback\n const inProgressRef = useRef(inProgress);\n \n useEffect(() => {\n const callbackId = instance.addEventCallback((message: EventMessage) => {\n switch (message.eventType) {\n case EventType.ACCOUNT_ADDED:\n case EventType.ACCOUNT_REMOVED:\n case EventType.LOGIN_SUCCESS:\n case EventType.SSO_SILENT_SUCCESS:\n case EventType.HANDLE_REDIRECT_END:\n case EventType.LOGIN_FAILURE:\n case EventType.SSO_SILENT_FAILURE:\n case EventType.LOGOUT_END:\n case EventType.ACQUIRE_TOKEN_SUCCESS:\n case EventType.ACQUIRE_TOKEN_FAILURE:\n const currentAccounts = instance.getAllAccounts();\n if (!accountArraysAreEqual(currentAccounts, accounts)) {\n logger.info(\"MsalProvider - updating account state\");\n setAccounts(currentAccounts);\n } else {\n logger.info(\"MsalProvider - no account changes\");\n }\n break;\n }\n });\n logger.verbose(`MsalProvider - Registered event callback with id: ${callbackId}`);\n\n return () => {\n // Remove callback when component unmounts or accounts change\n if (callbackId) {\n logger.verbose(`MsalProvider - Removing event callback ${callbackId}`);\n instance.removeEventCallback(callbackId);\n }\n };\n }, [instance, accounts, logger]);\n\n useEffect(() => {\n const callbackId = instance.addEventCallback((message: EventMessage) => {\n const status = EventMessageUtils.getInteractionStatusFromEvent(message, inProgressRef.current);\n if (status !== null) {\n logger.info(`MsalProvider - ${message.eventType} results in setting inProgress from ${inProgressRef.current} to ${status}`);\n inProgressRef.current = status;\n setInProgress(status);\n }\n });\n logger.verbose(`MsalProvider - Registered event callback with id: ${callbackId}`);\n\n instance.handleRedirectPromise().catch(() => {\n // Errors should be handled by listening to the LOGIN_FAILURE event\n return;\n }).finally(() => {\n /*\n * If handleRedirectPromise returns a cached promise the necessary events may not be fired\n * This is a fallback to prevent inProgress from getting stuck in 'startup'\n */\n if (inProgressRef.current === InteractionStatus.Startup) {\n inProgressRef.current = InteractionStatus.None;\n setInProgress(InteractionStatus.None);\n }\n });\n\n return () => {\n if (callbackId) {\n logger.verbose(`MsalProvider - Removing event callback ${callbackId}`);\n instance.removeEventCallback(callbackId);\n }\n };\n }, [instance, logger]);\n\n const contextValue: IMsalContext = {\n instance,\n inProgress,\n accounts,\n logger\n };\n\n return (\n <MsalContext.Provider value={contextValue}>\n {children}\n </MsalContext.Provider>\n );\n}\n\n","/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { useContext } from \"react\";\nimport { IMsalContext, MsalContext } from \"../MsalContext\";\n\n/**\n * Returns Msal Context values\n */\nexport const useMsal = (): IMsalContext => useContext(MsalContext);\n","/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { useState, useEffect } from \"react\";\nimport { AccountInfo, IPublicClientApplication, InteractionStatus, AccountEntity } from \"@azure/msal-browser\";\nimport { useMsal } from \"./useMsal\";\nimport { AccountIdentifiers } from \"../types/AccountIdentifiers\";\n\nfunction getAccount(instance: IPublicClientApplication, accountIdentifiers: AccountIdentifiers): AccountInfo | null {\n const allAccounts = instance.getAllAccounts();\n if (allAccounts.length > 0 && (accountIdentifiers.homeAccountId || accountIdentifiers.localAccountId || accountIdentifiers.username)) {\n const matchedAccounts = allAccounts.filter(accountObj => {\n if (accountIdentifiers.username && accountIdentifiers.username.toLowerCase() !== accountObj.username.toLowerCase()) {\n return false;\n }\n if (accountIdentifiers.homeAccountId && accountIdentifiers.homeAccountId.toLowerCase() !== accountObj.homeAccountId.toLowerCase()) {\n return false;\n }\n if (accountIdentifiers.localAccountId && accountIdentifiers.localAccountId.toLowerCase() !== accountObj.localAccountId.toLowerCase()) {\n return false;\n }\n\n return true;\n });\n\n return matchedAccounts[0] || null;\n } else {\n return null;\n }\n}\n\n/**\n * Given 1 or more accountIdentifiers, returns the Account object if the user is signed-in\n * @param accountIdentifiers \n */\nexport function useAccount(accountIdentifiers: AccountIdentifiers): AccountInfo | null {\n const { instance, inProgress } = useMsal();\n\n const initialStateValue = inProgress === InteractionStatus.Startup ? null : getAccount(instance, accountIdentifiers);\n const [account, setAccount] = useState<AccountInfo|null>(initialStateValue);\n\n useEffect(() => {\n const currentAccount = getAccount(instance, accountIdentifiers);\n if (!AccountEntity.accountInfoIsEqual(account, currentAccount, true)) {\n setAccount(currentAccount);\n }\n }, [inProgress, accountIdentifiers, instance, account]);\n\n return account;\n}\n","/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { useState, useEffect } from \"react\";\nimport { useMsal } from \"./useMsal\";\nimport { AccountIdentifiers } from \"../types/AccountIdentifiers\";\nimport { useAccount } from \"./useAccount\";\nimport { AccountInfo, InteractionStatus } from \"@azure/msal-browser\";\n\nfunction isAuthenticated(allAccounts: AccountIdentifiers[], account: AccountInfo | null, matchAccount?: AccountIdentifiers): boolean {\n if(matchAccount && (matchAccount.username || matchAccount.homeAccountId || matchAccount.localAccountId)) {\n return !!account;\n } \n\n return allAccounts.length > 0;\n}\n\n/**\n * Returns whether or not a user is currently signed-in. Optionally provide 1 or more accountIdentifiers to determine if a specific user is signed-in\n * @param matchAccount \n */\nexport function useIsAuthenticated(matchAccount?: AccountIdentifiers): boolean {\n const { accounts: allAccounts, inProgress } = useMsal();\n const account = useAccount(matchAccount || {});\n\n const initialStateValue = inProgress === InteractionStatus.Startup ? false : isAuthenticated(allAccounts, account, matchAccount);\n const [hasAuthenticated, setHasAuthenticated] = useState<boolean>(initialStateValue);\n\n useEffect(() => {\n setHasAuthenticated(isAuthenticated(allAccounts, account, matchAccount));\n }, [allAccounts, account, matchAccount]);\n\n return hasAuthenticated;\n}\n","/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport React, { PropsWithChildren, useMemo } from \"react\";\nimport { AccountIdentifiers } from \"../types/AccountIdentifiers\";\nimport { getChildrenOrFunction } from \"../utils/utilities\";\nimport { useMsal } from \"../hooks/useMsal\";\nimport { useIsAuthenticated } from \"../hooks/useIsAuthenticated\";\nimport { InteractionStatus } from \"@azure/msal-browser\";\n\nexport type AuthenticatedTemplateProps = PropsWithChildren<AccountIdentifiers>;\n\n/**\n * Renders child components if user is authenticated\n * @param props \n */\nexport function AuthenticatedTemplate({ username, homeAccountId, localAccountId, children }: AuthenticatedTemplateProps): React.ReactElement|null {\n const context = useMsal();\n const accountIdentifier: AccountIdentifiers = useMemo(() => {\n return {\n username,\n homeAccountId,\n localAccountId\n };\n }, [username, homeAccountId, localAccountId]);\n const isAuthenticated = useIsAuthenticated(accountIdentifier);\n\n if (isAuthenticated && context.inProgress !== InteractionStatus.Startup) {\n return (\n <React.Fragment>\n {getChildrenOrFunction(children, context)}\n </React.Fragment>\n );\n }\n return null;\n}\n","/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport React, { PropsWithChildren, useMemo } from \"react\";\nimport { useMsal } from \"../hooks/useMsal\";\nimport { useIsAuthenticated } from \"../hooks/useIsAuthenticated\";\nimport { getChildrenOrFunction } from \"../utils/utilities\";\nimport { AccountIdentifiers } from \"../types/AccountIdentifiers\";\nimport { InteractionStatus } from \"@azure/msal-browser\";\n\nexport type UnauthenticatedTemplateProps = PropsWithChildren<AccountIdentifiers>;\n\n/**\n * Renders child components if user is unauthenticated\n * @param props \n */\nexport function UnauthenticatedTemplate({ username, homeAccountId, localAccountId, children }: UnauthenticatedTemplateProps): React.ReactElement|null {\n const context = useMsal();\n const accountIdentifier: AccountIdentifiers = useMemo(() => {\n return {\n username,\n homeAccountId,\n localAccountId\n };\n }, [username, homeAccountId, localAccountId]);\n const isAuthenticated = useIsAuthenticated(accountIdentifier);\n\n if (!isAuthenticated && context.inProgress !== InteractionStatus.Startup && context.inProgress !== InteractionStatus.HandleRedirect) {\n return (\n <React.Fragment>\n {getChildrenOrFunction(children, context)}\n </React.Fragment>\n );\n }\n return null;\n}\n","/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { useCallback, useEffect, useState } from \"react\";\nimport { PopupRequest, RedirectRequest, SsoSilentRequest, InteractionType, AuthenticationResult, AuthError, EventMessage, EventType, InteractionStatus } from \"@azure/msal-browser\";\nimport { useIsAuthenticated } from \"./useIsAuthenticated\";\nimport { AccountIdentifiers } from \"../types/AccountIdentifiers\";\nimport { useMsal } from \"./useMsal\";\n\nexport type MsalAuthenticationResult = {\n login: Function; \n result: AuthenticationResult|null;\n error: AuthError|null;\n};\n\n/**\n * Invokes a login call if a user is not currently signed-in. Failed logins can be retried using the login callback returned.\n * Optionally provide a request object to be used in the login call.\n * Optionally provide a specific user that should be logged in.\n * @param interactionType \n * @param authenticationRequest \n * @param accountIdentifiers \n */\nexport function useMsalAuthentication(\n interactionType: InteractionType, \n authenticationRequest?: PopupRequest|RedirectRequest|SsoSilentRequest, \n accountIdentifiers?: AccountIdentifiers\n): MsalAuthenticationResult {\n const { instance, inProgress, logger } = useMsal();\n const isAuthenticated = useIsAuthenticated(accountIdentifiers);\n const [[result, error], setResponse] = useState<[AuthenticationResult|null, AuthError|null]>([null, null]);\n const [hasBeenCalled, setHasBeenCalled] = useState<boolean>(false);\n\n const login = useCallback(async (callbackInteractionType?: InteractionType, callbackRequest?: PopupRequest|RedirectRequest|SsoSilentRequest): Promise<AuthenticationResult|null> => {\n const loginType = callbackInteractionType || interactionType;\n const loginRequest = callbackRequest || authenticationRequest;\n switch (loginType) {\n case InteractionType.Popup:\n logger.verbose(\"useMsalAuthentication - Calling loginPopup\");\n return instance.loginPopup(loginRequest as PopupRequest);\n case InteractionType.Redirect:\n // This promise is not expected to resolve due to full frame redirect\n logger.verbose(\"useMsalAuthentication - Calling loginRedirect\");\n return instance.loginRedirect(loginRequest as RedirectRequest).then(null);\n case InteractionType.Silent:\n logger.verbose(\"useMsalAuthentication - Calling ssoSilent\");\n return instance.ssoSilent(loginRequest as SsoSilentRequest);\n default:\n throw \"Invalid interaction type provided.\";\n }\n }, [instance, interactionType, authenticationRequest, logger]);\n\n useEffect(() => {\n const callbackId = instance.addEventCallback((message: EventMessage) => {\n switch(message.eventType) {\n case EventType.LOGIN_SUCCESS:\n case EventType.SSO_SILENT_SUCCESS:\n if (message.payload) {\n setResponse([message.payload as AuthenticationResult, null]);\n }\n break;\n case EventType.LOGIN_FAILURE:\n case EventType.SSO_SILENT_FAILURE:\n if (message.error) {\n setResponse([null, message.error as AuthError]);\n }\n break;\n }\n });\n logger.verbose(`useMsalAuthentication - Registered event callback with id: ${callbackId}`);\n\n return () => {\n if (callbackId) {\n logger.verbose(`useMsalAuthentication - Removing event callback ${callbackId}`);\n instance.removeEventCallback(callbackId);\n }\n };\n }, [instance, logger]);\n\n useEffect(() => {\n if (!hasBeenCalled && !error && !isAuthenticated && inProgress === InteractionStatus.None) {\n logger.info(\"useMsalAuthentication - No user is authenticated, attempting to login\");\n // Ensure login is only called one time from within this hook, any subsequent login attempts should use the callback returned\n setHasBeenCalled(true);\n login().catch(() => {\n // Errors are handled by the event handler above\n return;\n });\n }\n }, [isAuthenticated, inProgress, error, hasBeenCalled, login, logger]);\n\n return { login, result, error };\n}\n","/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport React, { PropsWithChildren, useMemo } from \"react\";\nimport { AccountIdentifiers } from \"../types/AccountIdentifiers\";\nimport { getChildrenOrFunction } from \"../utils/utilities\";\nimport { useMsal } from \"../hooks/useMsal\";\nimport { MsalAuthenticationResult, useMsalAuthentication } from \"../hooks/useMsalAuthentication\";\nimport { useIsAuthenticated } from \"../hooks/useIsAuthenticated\";\nimport { InteractionType, PopupRequest, RedirectRequest, SsoSilentRequest, InteractionStatus } from \"@azure/msal-browser\";\nimport { IMsalContext } from \"../MsalContext\";\n\nexport type MsalAuthenticationProps = PropsWithChildren<AccountIdentifiers & {\n interactionType: InteractionType;\n authenticationRequest?: PopupRequest|RedirectRequest|SsoSilentRequest;\n loadingComponent?: React.ElementType<IMsalContext>;\n errorComponent?: React.ElementType<MsalAuthenticationResult>;\n}>;\n\n/**\n * Attempts to authenticate user if not already authenticated, then renders child components\n * @param props\n */\nexport function MsalAuthenticationTemplate({ \n interactionType, \n username, \n homeAccountId, \n localAccountId,\n authenticationRequest, \n loadingComponent: LoadingComponent,\n errorComponent: ErrorComponent,\n children \n}: MsalAuthenticationProps): React.ReactElement|null {\n const accountIdentifier: AccountIdentifiers = useMemo(() => {\n return {\n username,\n homeAccountId,\n localAccountId\n };\n }, [username, homeAccountId, localAccountId]);\n const context = useMsal();\n const msalAuthResult = useMsalAuthentication(interactionType, authenticationRequest, accountIdentifier);\n const isAuthenticated = useIsAuthenticated(accountIdentifier);\n\n if (msalAuthResult.error && context.inProgress === InteractionStatus.None) {\n if (!!ErrorComponent) {\n return <ErrorComponent {...msalAuthResult} />;\n }\n\n throw msalAuthResult.error;\n }\n \n if (isAuthenticated) {\n return (\n <React.Fragment>\n {getChildrenOrFunction(children, msalAuthResult)}\n </React.Fragment>\n );\n } \n \n if (!!LoadingComponent && context.inProgress !== InteractionStatus.None) {\n return <LoadingComponent {...context} />;\n }\n\n return null;\n}\n","/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport React from \"react\";\nimport { IMsalContext } from \"../MsalContext\";\nimport { useMsal } from \"../hooks/useMsal\";\nimport { Subtract } from \"../utils/utilities\";\n\nexport type WithMsalProps = {\n msalContext: IMsalContext;\n};\n\n/**\n * Higher order component wraps provided component with msal by injecting msal context values into the component's props \n * @param Component \n */\nexport const withMsal = <P extends WithMsalProps>(Component: React.ComponentType<P>): React.FunctionComponent<Subtract<P,WithMsalProps>> => {\n const ComponentWithMsal: React.FunctionComponent<Subtract<P,WithMsalProps>> = props => {\n const msal = useMsal();\n return <Component {...(props as P)} msalContext={msal} />;\n };\n\n const componentName =\n Component.displayName || Component.name || \"Component\";\n ComponentWithMsal.displayName = `withMsal(${componentName})`;\n\n return ComponentWithMsal;\n};\n"],"names":["defaultMsalContext","instance","stubbedPublicClientApplication","inProgress","InteractionStatus","None","accounts","logger","Logger","MsalContext","React","MsalConsumer","Consumer","getChildrenOrFunction","children","args","accountArraysAreEqual","arrayA","arrayB","length","comparisonArray","every","elementA","elementB","shift","homeAccountId","localAccountId","username","name","version","MsalProvider","useEffect","initializeWrapperLibrary","WrapperSKU","useMemo","getLogger","clone","SKU","setAccounts","useState","setInProgress","Startup","inProgressRef","useRef","callbackId","addEventCallback","message","eventType","EventType","ACCOUNT_ADDED","ACCOUNT_REMOVED","LOGIN_SUCCESS","SSO_SILENT_SUCCESS","HANDLE_REDIRECT_END","LOGIN_FAILURE","SSO_SILENT_FAILURE","LOGOUT_END","ACQUIRE_TOKEN_SUCCESS","ACQUIRE_TOKEN_FAILURE","currentAccounts","getAllAccounts","info","verbose","removeEventCallback","status","EventMessageUtils","getInteractionStatusFromEvent","current","handleRedirectPromise","catch","finally","contextValue","Provider","value","useMsal","useContext","getAccount","accountIdentifiers","allAccounts","matchedAccounts","filter","accountObj","toLowerCase","useAccount","initialStateValue","account","setAccount","currentAccount","AccountEntity","accountInfoIsEqual","isAuthenticated","matchAccount","useIsAuthenticated","hasAuthenticated","setHasAuthenticated","AuthenticatedTemplate","context","accountIdentifier","Fragment","UnauthenticatedTemplate","HandleRedirect","useMsalAuthentication","interactionType","authenticationRequest","result","error","setResponse","hasBeenCalled","setHasBeenCalled","login","useCallback","callbackInteractionType","callbackRequest","loginType","loginRequest","InteractionType","Popup","loginPopup","Redirect","loginRedirect","then","Silent","ssoSilent","payload","MsalAuthenticationTemplate","loadingComponent","LoadingComponent","errorComponent","ErrorComponent","msalAuthResult","withMsal","Component","ComponentWithMsal","props","msal","msalContext","componentName","displayName"],"mappings":";;;;;;;;;;AAAA;;;;AAeA;;;;;AAIA,MAAMA,kBAAkB,GAAiB;AACrCC,EAAAA,QAAQ,EAAEC,0CAD2B;AAErCC,EAAAA,UAAU,EAAEC,6BAAiB,CAACC,IAFO;AAGrCC,EAAAA,QAAQ,EAAE,EAH2B;AAIrC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Ae,GAAGE,kBAAkB,CAACK,iBAAD,CAA1C;;AAEA,MAAIgC,cAAc,CAACxB,KAAf,IAAwBT,OAAO,CAAC7F,UAAR,KAAuBC,6BAAiB,CAACC,IAArE,EAA2E;AACvE,QAAI,CAAC,CAAC2H,cAAN,EAAsB;AAClB,aAAOtH,4BAAA,CAACsH,cAAD,oBAAoBC,eAApB,CAAP;AACH;;AAED,UAAMA,cAAc,CAACxB,KAArB;AACH;;AAED,MAAIf,eAAJ,EAAqB;AACjB,WACIhF,4BAAA,CAACA,cAAK,CAACwF,QAAP,MAAA,EACKrF,qBAAqB,CAACC,QAAD,EAAWmH,cAAX,CAD1B,CADJ;AAKH;;AAED,MAAI,CAAC,CAACH,gBAAF,IAAsB9B,OAAO,CAAC7F,UAAR,KAAuBC,6BAAiB,CAACC,IAAnE,EAAyE;AACrE,WAAOK,4BAAA,CAACoH,gBAAD,oBAAsB9B,QAAtB,CAAP;AACH;;AAED,SAAO,IAAP;AACH;;ACnED;;;;AAKA,AASA;;;;;AAIA,MAAakC,QAAQ,GAA6BC,SAA1B;AACpB,QAAMC,iBAAiB,GAAuDC,KAAK;AAC/E,UAAMC,IAAI,GAAG5D,OAAO,EAApB;AACA,WAAOhE,4BAAA,CAACyH,SAAD,oBAAgBE;AAAaE,MAAAA,WAAW,EAAED;MAA1C,CAAP;AACH,GAHD;;AAKA,QAAME,aAAa,GACfL,SAAS,CAACM,WAAV,IAAyBN,SAAS,CAACvG,IAAnC,IAA2C,WAD/C;AAEAwG,EAAAA,iBAAiB,CAACK,WAAlB,eAA4CD,gBAA5C;AAEA,SAAOJ,iBAAP;AACH,CAXM;;;;;;;;;;;;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
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,o=require("@azure/msal-browser");const
|
|
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,o=require("@azure/msal-browser");const r=t.createContext({instance:o.stubbedPublicClientApplication,inProgress:o.InteractionStatus.None,accounts:[],logger:new o.Logger({})}),c=r.Consumer;function a(e,t){return"function"==typeof e?e(t):e}const s=()=>t.useContext(r);function u(e,t){const n=e.getAllAccounts();return n.length>0&&(t.homeAccountId||t.localAccountId||t.username)&&n.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}function l(e){const{instance:n,inProgress:r}=s(),c=r===o.InteractionStatus.Startup?null:u(n,e),[a,l]=t.useState(c);return t.useEffect(()=>{const t=u(n,e);o.AccountEntity.accountInfoIsEqual(a,t,!0)||l(t)},[r,e,n,a]),a}function i(e,t,n){return n&&(n.username||n.homeAccountId||n.localAccountId)?!!t:e.length>0}function d(e){const{accounts:n,inProgress:r}=s(),c=l(e||{}),a=r!==o.InteractionStatus.Startup&&i(n,c,e),[u,d]=t.useState(a);return t.useEffect(()=>{d(i(n,c,e))},[n,c,e]),u}function p(e,n,r){const{instance:c,inProgress:a,logger:u}=s(),l=d(r),[[i,p],m]=t.useState([null,null]),[E,I]=t.useState(!1),v=t.useCallback(async(t,r)=>{const a=r||n;switch(t||e){case o.InteractionType.Popup:return u.verbose("useMsalAuthentication - Calling loginPopup"),c.loginPopup(a);case o.InteractionType.Redirect:return u.verbose("useMsalAuthentication - Calling loginRedirect"),c.loginRedirect(a).then(null);case o.InteractionType.Silent:return u.verbose("useMsalAuthentication - Calling ssoSilent"),c.ssoSilent(a);default:throw"Invalid interaction type provided."}},[c,e,n,u]);return t.useEffect(()=>{const e=c.addEventCallback(e=>{switch(e.eventType){case o.EventType.LOGIN_SUCCESS:case o.EventType.SSO_SILENT_SUCCESS:e.payload&&m([e.payload,null]);break;case o.EventType.LOGIN_FAILURE:case o.EventType.SSO_SILENT_FAILURE:e.error&&m([null,e.error])}});return u.verbose("useMsalAuthentication - Registered event callback with id: "+e),()=>{e&&(u.verbose("useMsalAuthentication - Removing event callback "+e),c.removeEventCallback(e))}},[c,u]),t.useEffect(()=>{E||p||l||a!==o.InteractionStatus.None||(u.info("useMsalAuthentication - No user is authenticated, attempting to login"),I(!0),v().catch(()=>{}))},[l,a,p,E,v,u]),{login:v,result:i,error:p}}exports.AuthenticatedTemplate=function({username:e,homeAccountId:r,localAccountId:c,children:u}){const l=s();return d(t.useMemo(()=>({username:e,homeAccountId:r,localAccountId:c}),[e,r,c]))&&l.inProgress!==o.InteractionStatus.Startup?n.createElement(n.Fragment,null,a(u,l)):null},exports.MsalAuthenticationTemplate=function({interactionType:e,username:r,homeAccountId:c,localAccountId:u,authenticationRequest:l,loadingComponent:i,errorComponent:m,children:E}){const I=t.useMemo(()=>({username:r,homeAccountId:c,localAccountId:u}),[r,c,u]),v=s(),S=p(e,l,I),g=d(I);if(S.error&&v.inProgress===o.InteractionStatus.None){if(m)return n.createElement(m,Object.assign({},S));throw S.error}return g?n.createElement(n.Fragment,null,a(E,S)):i&&v.inProgress!==o.InteractionStatus.None?n.createElement(i,Object.assign({},v)):null},exports.MsalConsumer=c,exports.MsalContext=r,exports.MsalProvider=function({instance:e,children:c}){t.useEffect(()=>{e.initializeWrapperLibrary(o.WrapperSKU.React,"1.2.0")},[e]);const a=t.useMemo(()=>e.getLogger().clone("@azure/msal-react","1.2.0"),[e]),[s,u]=t.useState([]),[l,i]=t.useState(o.InteractionStatus.Startup),d=t.useRef(l);return t.useEffect(()=>{const t=e.addEventCallback(t=>{switch(t.eventType){case o.EventType.ACCOUNT_ADDED:case o.EventType.ACCOUNT_REMOVED:case o.EventType.LOGIN_SUCCESS:case o.EventType.SSO_SILENT_SUCCESS:case o.EventType.HANDLE_REDIRECT_END:case o.EventType.LOGIN_FAILURE:case o.EventType.SSO_SILENT_FAILURE:case o.EventType.LOGOUT_END:case o.EventType.ACQUIRE_TOKEN_SUCCESS:case o.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=o.EventMessageUtils.getInteractionStatusFromEvent(e,d.current);null!==t&&(a.info(`MsalProvider - ${e.eventType} results in setting inProgress from ${d.current} to ${t}`),d.current=t,i(t))});return a.verbose("MsalProvider - Registered event callback with id: "+t),e.handleRedirectPromise().catch(()=>{}).finally(()=>{d.current===o.InteractionStatus.Startup&&(d.current=o.InteractionStatus.None,i(o.InteractionStatus.None))}),()=>{t&&(a.verbose("MsalProvider - Removing event callback "+t),e.removeEventCallback(t))}},[e,a]),n.createElement(r.Provider,{value:{instance:e,inProgress:l,accounts:s,logger:a}},c)},exports.UnauthenticatedTemplate=function({username:e,homeAccountId:r,localAccountId:c,children:u}){const l=s();return d(t.useMemo(()=>({username:e,homeAccountId:r,localAccountId:c}),[e,r,c]))||l.inProgress===o.InteractionStatus.Startup||l.inProgress===o.InteractionStatus.HandleRedirect?null:n.createElement(n.Fragment,null,a(u,l))},exports.useAccount=l,exports.useIsAuthenticated=d,exports.useMsal=s,exports.useMsalAuthentication=p,exports.version="1.2.0",exports.withMsal=e=>{const t=t=>{const o=s();return n.createElement(e,Object.assign({},t,{msalContext:o}))};return t.displayName=`withMsal(${e.displayName||e.name||"Component"})`,t};
|
|
2
2
|
//# sourceMappingURL=msal-react.cjs.production.min.js.map
|