@azure/msal-react 1.1.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +690 -574
- package/CHANGELOG.md +161 -126
- package/LICENSE +21 -21
- package/README.md +143 -143
- package/dist/error/ReactAuthError.d.ts +16 -0
- package/dist/hooks/useAccount.d.ts +1 -1
- package/dist/hooks/useMsalAuthentication.d.ts +6 -4
- package/dist/msal-react.cjs.development.js +205 -77
- package/dist/msal-react.cjs.development.js.map +1 -1
- package/dist/msal-react.cjs.production.min.js +1 -1
- package/dist/msal-react.cjs.production.min.js.map +1 -1
- package/dist/msal-react.esm.js +206 -78
- package/dist/msal-react.esm.js.map +1 -1
- package/dist/packageMetadata.d.ts +1 -1
- package/dist/utils/utilities.d.ts +2 -0
- package/package.json +65 -64
package/CHANGELOG.md
CHANGED
|
@@ -1,126 +1,161 @@
|
|
|
1
|
-
# Change Log - @azure/msal-react
|
|
2
|
-
|
|
3
|
-
This log was last generated on
|
|
4
|
-
|
|
5
|
-
<!-- Start content -->
|
|
6
|
-
|
|
7
|
-
## 1.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
### Minor changes
|
|
12
|
-
|
|
13
|
-
-
|
|
14
|
-
- Bump @azure/msal-browser to v2.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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.0.0-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
### Changes
|
|
101
|
-
|
|
102
|
-
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
1
|
+
# Change Log - @azure/msal-react
|
|
2
|
+
|
|
3
|
+
This log was last generated on Tue, 08 Feb 2022 00:41:07 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
<!-- Start content -->
|
|
6
|
+
|
|
7
|
+
## 1.3.0
|
|
8
|
+
|
|
9
|
+
Tue, 08 Feb 2022 00:41:07 GMT
|
|
10
|
+
|
|
11
|
+
### Minor changes
|
|
12
|
+
|
|
13
|
+
- useMsalAuthentication hook acquires a token if user is already signed in #4280 (thomas.norling@microsoft.com)
|
|
14
|
+
- Bump @azure/msal-browser to v2.22.0
|
|
15
|
+
|
|
16
|
+
## 1.2.0
|
|
17
|
+
|
|
18
|
+
Tue, 04 Jan 2022 00:20:29 GMT
|
|
19
|
+
|
|
20
|
+
### Minor changes
|
|
21
|
+
|
|
22
|
+
- Bump @azure/msal-browser to v2.21.0
|
|
23
|
+
|
|
24
|
+
## 1.1.2
|
|
25
|
+
|
|
26
|
+
Tue, 07 Dec 2021 00:17:01 GMT
|
|
27
|
+
|
|
28
|
+
### Patches
|
|
29
|
+
|
|
30
|
+
- Fix inProgress stuck in startup state #4302 (thomas.norling@microsoft.com)
|
|
31
|
+
- Bump @azure/msal-browser to v2.20.0
|
|
32
|
+
|
|
33
|
+
## 1.1.1
|
|
34
|
+
|
|
35
|
+
Mon, 01 Nov 2021 23:53:22 GMT
|
|
36
|
+
|
|
37
|
+
### Patches
|
|
38
|
+
|
|
39
|
+
- Support React version 16.8.0+ (thomas.norling@microsoft.com)
|
|
40
|
+
- Bump @azure/msal-browser to v2.19.0
|
|
41
|
+
|
|
42
|
+
## 1.1.0
|
|
43
|
+
|
|
44
|
+
Mon, 04 Oct 2021 23:12:35 GMT
|
|
45
|
+
|
|
46
|
+
### Minor changes
|
|
47
|
+
|
|
48
|
+
- Update account state when user logs in or out from a different tab or window #3981 (thomas.norling@microsoft.com)
|
|
49
|
+
- Bump @azure/msal-browser to v2.18.0
|
|
50
|
+
|
|
51
|
+
### Patches
|
|
52
|
+
|
|
53
|
+
- Export library version #4124 (thomas.norling@microsoft.com)
|
|
54
|
+
|
|
55
|
+
## 1.0.2
|
|
56
|
+
|
|
57
|
+
Tue, 07 Sep 2021 23:22:24 GMT
|
|
58
|
+
|
|
59
|
+
### Patches
|
|
60
|
+
|
|
61
|
+
- Fix inProgress state bug when returning from a redirect #4013 (thomas.norling@microsoft.com)
|
|
62
|
+
|
|
63
|
+
## 1.0.1
|
|
64
|
+
|
|
65
|
+
Mon, 28 Jun 2021 23:39:48 GMT
|
|
66
|
+
|
|
67
|
+
### Patches
|
|
68
|
+
|
|
69
|
+
- Change accounts context type to AccountInfo[] #3677 (thomas.norling@microsoft.com)
|
|
70
|
+
|
|
71
|
+
## 1.0.0
|
|
72
|
+
|
|
73
|
+
Thu, 13 May 2021 18:34:08 GMT
|
|
74
|
+
|
|
75
|
+
### Patches
|
|
76
|
+
|
|
77
|
+
- Move MSAL Angular v2 and MSAL React to GA (janutter@microsoft.com)
|
|
78
|
+
|
|
79
|
+
## 1.0.0-beta.3
|
|
80
|
+
|
|
81
|
+
Wed, 12 May 2021 18:35:03 GMT
|
|
82
|
+
|
|
83
|
+
### Changes
|
|
84
|
+
|
|
85
|
+
- Fix extra state update in useAccount hook #3527 (thomas.norling@microsoft.com)
|
|
86
|
+
- Prevent UnauthenticatedTemplate from rendering children while processing redirect response #3552 (thomas.norling@microsoft.com)
|
|
87
|
+
|
|
88
|
+
## 1.0.0-beta.2
|
|
89
|
+
|
|
90
|
+
Thu, 22 Apr 2021 23:26:08 GMT
|
|
91
|
+
|
|
92
|
+
### Changes
|
|
93
|
+
|
|
94
|
+
- Add .browserslistrc #3471 (thomas.norling@microsoft.com)
|
|
95
|
+
|
|
96
|
+
## 1.0.0-beta.1
|
|
97
|
+
|
|
98
|
+
Wed, 24 Mar 2021 22:55:46 GMT
|
|
99
|
+
|
|
100
|
+
### Changes
|
|
101
|
+
|
|
102
|
+
- Add support for logoutPopup #3044 (thomas.norling@microsoft.com)
|
|
103
|
+
|
|
104
|
+
## 1.0.0-beta.0
|
|
105
|
+
|
|
106
|
+
Wed, 03 Mar 2021 21:47:05 GMT
|
|
107
|
+
|
|
108
|
+
### Changes
|
|
109
|
+
|
|
110
|
+
- Remove InteractionStatus export (#3048) (thomas.norling@microsoft.com)
|
|
111
|
+
|
|
112
|
+
## 1.0.0-alpha.5
|
|
113
|
+
|
|
114
|
+
Tue, 09 Feb 2021 01:48:22 GMT
|
|
115
|
+
|
|
116
|
+
### Changes
|
|
117
|
+
|
|
118
|
+
- Check InteractionStatus in Authenticated/UnauthenticatedTemplate (#2996) (thomas.norling@microsoft.com)
|
|
119
|
+
- Fix version.json import errors (#2993) (thomas.norling@microsoft.com)
|
|
120
|
+
|
|
121
|
+
## 1.0.0-alpha.4
|
|
122
|
+
|
|
123
|
+
Tue, 02 Feb 2021 01:56:47 GMT
|
|
124
|
+
|
|
125
|
+
### Changes
|
|
126
|
+
|
|
127
|
+
- Get package version from version.json (#2915) (thomas.norling@microsoft.com)
|
|
128
|
+
- Use interactionStatus and inProgress from msal-browser (#2885) (joarroyo@microsoft.com)
|
|
129
|
+
- Pass SKU and version to msal-browser (#2845) (thomas.norling@microsoft.com)
|
|
130
|
+
|
|
131
|
+
## 1.0.0-alpha.3
|
|
132
|
+
|
|
133
|
+
Thu, 21 Jan 2021 21:48:01 GMT
|
|
134
|
+
|
|
135
|
+
### Changes
|
|
136
|
+
|
|
137
|
+
- Fix initial state values (#2865) (thomas.norling@microsoft.com)
|
|
138
|
+
- Add missing license files (janutter@microsoft.com)
|
|
139
|
+
|
|
140
|
+
## 1.0.0-alpha.2
|
|
141
|
+
|
|
142
|
+
Tue, 12 Jan 2021 00:51:26 GMT
|
|
143
|
+
|
|
144
|
+
### Changes
|
|
145
|
+
|
|
146
|
+
- Add logger (#2727) (thomas.norling@microsoft.com)
|
|
147
|
+
- Fix redirect loop when service returns error (#2762) (thomas.norling@microsoft.com)
|
|
148
|
+
|
|
149
|
+
## 1.0.0-alpha.1
|
|
150
|
+
|
|
151
|
+
Mon, 07 Dec 2020 22:19:03 GMT
|
|
152
|
+
|
|
153
|
+
### Changes
|
|
154
|
+
|
|
155
|
+
- Prevent unnecessary context updates (#2671) (thomas.norling@microsoft.com)
|
|
156
|
+
- Updating TestConstants.ts (prkanher@microsoft.com)
|
|
157
|
+
- Readme Updates (thomas.norling@microsoft.com)
|
|
158
|
+
- Fix Server/Client mismatch when using SSR (#2646) (thomas.norling@microsoft.com)
|
|
159
|
+
- useMsalAuthentication consumes response from login callback (#2610) (thomas.norling@microsoft.com)
|
|
160
|
+
- Update msal-react ssoSilent example (janutter@microsoft.com)
|
|
161
|
+
- Readme updates (#2592) (thomas.norling@microsoft.com)
|
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE
|
package/README.md
CHANGED
|
@@ -1,143 +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. [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.
|
|
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.
|