@chemmangat/msal-next 3.1.6 → 3.1.8
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.md +33 -36
- package/README.md +7 -65
- package/dist/index.d.mts +205 -59
- package/dist/index.d.ts +205 -59
- package/dist/index.js +2 -1726
- package/dist/index.mjs +2 -1671
- package/dist/server.js +1 -115
- package/dist/server.mjs +1 -87
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,57 +2,54 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
-
## [3.1.
|
|
5
|
+
## [3.1.7] - 2026-03-05
|
|
6
6
|
|
|
7
|
-
### 🔄 Breaking Change - Redirect Flow
|
|
7
|
+
### 🔄 Breaking Change - Redirect-Only Flow
|
|
8
8
|
|
|
9
|
-
**
|
|
9
|
+
**Removed all popup authentication support** - Package now only supports redirect flow for cleaner, simpler authentication.
|
|
10
10
|
|
|
11
11
|
**Why this change?**
|
|
12
|
-
- Popup flow
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
12
|
+
- Popup flow had persistent issues (full app loading in popup, logout popups, etc.)
|
|
13
|
+
- Redirect flow is simpler, more reliable, and works out of the box
|
|
14
|
+
- No need for blank.html or special Azure AD configuration
|
|
15
|
+
- Better user experience with full-page redirects
|
|
16
|
+
|
|
17
|
+
**What was removed:**
|
|
18
|
+
- `loginPopup()` method
|
|
19
|
+
- `logoutPopup()` method
|
|
20
|
+
- `acquireTokenPopup()` method
|
|
21
|
+
- `useRedirect` prop from MicrosoftSignInButton
|
|
22
|
+
- `useRedirect` prop from SignOutButton
|
|
23
|
+
- `popupRedirectUri` configuration option
|
|
24
|
+
- `getPopupRedirectUri()` utility
|
|
25
|
+
- All popup-related code and configuration
|
|
16
26
|
|
|
17
27
|
**Migration:**
|
|
18
28
|
|
|
19
|
-
If you were using the default popup behavior:
|
|
20
29
|
```tsx
|
|
21
|
-
// Before (v3.1.4 and earlier)
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
<MicrosoftSignInButton /> // Now redirects full page
|
|
30
|
+
// Before (v3.1.4 and earlier)
|
|
31
|
+
const { loginPopup, logoutPopup } = useMsalAuth();
|
|
32
|
+
await loginPopup();
|
|
33
|
+
await logoutPopup();
|
|
26
34
|
|
|
27
|
-
// To keep popup behavior:
|
|
28
35
|
<MicrosoftSignInButton useRedirect={false} />
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
**New Default Behavior:**
|
|
32
|
-
- Button redirects the entire browser window to Microsoft login
|
|
33
|
-
- After authentication, redirects back to your app
|
|
34
|
-
- No popup windows, no blank.html needed
|
|
35
|
-
- Works with your existing Azure AD redirect URI
|
|
36
|
+
<SignOutButton useRedirect={false} />
|
|
36
37
|
|
|
37
|
-
|
|
38
|
+
// After (v3.1.5) - redirect only
|
|
39
|
+
const { loginRedirect, logoutRedirect } = useMsalAuth();
|
|
40
|
+
await loginRedirect();
|
|
41
|
+
await logoutRedirect();
|
|
38
42
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
**For Popup Flow (Optional):**
|
|
42
|
-
1. Create `public/blank.html`
|
|
43
|
-
2. Add `/blank.html` to Azure AD redirect URIs
|
|
44
|
-
3. Use:
|
|
45
|
-
```tsx
|
|
46
|
-
<MSALProvider popupRedirectUri="/blank.html">
|
|
47
|
-
<MicrosoftSignInButton useRedirect={false} />
|
|
48
|
-
</MSALProvider>
|
|
43
|
+
<MicrosoftSignInButton />
|
|
44
|
+
<SignOutButton />
|
|
49
45
|
```
|
|
50
46
|
|
|
51
47
|
**Benefits:**
|
|
52
|
-
- Simpler
|
|
53
|
-
-
|
|
54
|
-
-
|
|
55
|
-
-
|
|
48
|
+
- Simpler API - no popup vs redirect decisions
|
|
49
|
+
- No popup-related bugs or issues
|
|
50
|
+
- Works perfectly out of the box
|
|
51
|
+
- Cleaner codebase and smaller bundle size
|
|
52
|
+
- Better user experience
|
|
56
53
|
|
|
57
54
|
## [3.1.4] - 2026-03-05
|
|
58
55
|
|
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ Production-grade MSAL authentication library for Next.js App Router with minimal
|
|
|
5
5
|
[](https://www.npmjs.com/package/@chemmangat/msal-next)
|
|
6
6
|
[](https://opensource.org/licenses/MIT)
|
|
7
7
|
|
|
8
|
-
> **📦 Current Version: 3.1.
|
|
8
|
+
> **📦 Current Version: 3.1.7** - Redirect-only authentication (popup support removed). [See changelog](./CHANGELOG.md)
|
|
9
9
|
|
|
10
10
|
> **⚠️ Important:** If you're on v3.0.6 or v3.0.7, please update immediately - those versions have a critical popup authentication bug.
|
|
11
11
|
|
|
@@ -134,59 +134,7 @@ export default function Home() {
|
|
|
134
134
|
|
|
135
135
|
That's it! 🎉
|
|
136
136
|
|
|
137
|
-
The button uses redirect flow
|
|
138
|
-
|
|
139
|
-
## Optional: Fix Popup Window Issue
|
|
140
|
-
|
|
141
|
-
**Important:** When using popup authentication, the popup window MUST navigate to your redirect URI to complete the OAuth flow. This is how OAuth works and cannot be avoided.
|
|
142
|
-
|
|
143
|
-
By default, this means your full Next.js app will briefly load in the popup before it closes. The package detects this and renders minimal content, but you may still see a flash of your app.
|
|
144
|
-
|
|
145
|
-
### Solution: Use a Blank Page (Recommended for Popup Flow)
|
|
146
|
-
|
|
147
|
-
For the cleanest popup experience, create a blank HTML page:
|
|
148
|
-
|
|
149
|
-
### 1. Create blank.html
|
|
150
|
-
|
|
151
|
-
Create `public/blank.html`:
|
|
152
|
-
|
|
153
|
-
```html
|
|
154
|
-
<!DOCTYPE html>
|
|
155
|
-
<html>
|
|
156
|
-
<head><title>Auth</title></head>
|
|
157
|
-
<body></body>
|
|
158
|
-
</html>
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
### 2. Add to Azure AD
|
|
162
|
-
|
|
163
|
-
Add to Azure AD redirect URIs:
|
|
164
|
-
- `http://localhost:3000/blank.html`
|
|
165
|
-
- `https://yourdomain.com/blank.html`
|
|
166
|
-
|
|
167
|
-
### 3. Configure MSALProvider
|
|
168
|
-
|
|
169
|
-
```tsx
|
|
170
|
-
<MSALProvider
|
|
171
|
-
clientId={process.env.NEXT_PUBLIC_AZURE_AD_CLIENT_ID!}
|
|
172
|
-
tenantId={process.env.NEXT_PUBLIC_AZURE_AD_TENANT_ID!}
|
|
173
|
-
popupRedirectUri="/blank.html" // Add this line
|
|
174
|
-
>
|
|
175
|
-
{children}
|
|
176
|
-
</MSALProvider>
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
This ensures the popup shows only a blank page and closes immediately.
|
|
180
|
-
|
|
181
|
-
### Alternative: Use Redirect Flow
|
|
182
|
-
|
|
183
|
-
If you don't want to set up blank.html, use redirect flow instead:
|
|
184
|
-
|
|
185
|
-
```tsx
|
|
186
|
-
<MicrosoftSignInButton useRedirect={true} />
|
|
187
|
-
```
|
|
188
|
-
|
|
189
|
-
Redirect flow navigates the entire browser window (no popup), so there's no "app in popup" issue.
|
|
137
|
+
The button uses redirect flow (full page redirect to Microsoft login, then back to your app). Simple and clean.
|
|
190
138
|
|
|
191
139
|
## Components
|
|
192
140
|
|
|
@@ -240,18 +188,14 @@ export function MyProviders({ children }) {
|
|
|
240
188
|
|
|
241
189
|
### MicrosoftSignInButton
|
|
242
190
|
|
|
243
|
-
Pre-styled sign-in button with Microsoft branding. Uses redirect flow
|
|
191
|
+
Pre-styled sign-in button with Microsoft branding. Uses redirect flow (full page redirect to Microsoft login).
|
|
244
192
|
|
|
245
193
|
```tsx
|
|
246
194
|
<MicrosoftSignInButton
|
|
247
195
|
variant="dark" // or "light"
|
|
248
196
|
size="medium" // "small", "medium", "large"
|
|
249
|
-
useRedirect={true} // Default: true (full page redirect)
|
|
250
197
|
onSuccess={() => console.log('Signed in!')}
|
|
251
198
|
/>
|
|
252
|
-
|
|
253
|
-
// If you prefer popup (requires blank.html setup):
|
|
254
|
-
<MicrosoftSignInButton useRedirect={false} />
|
|
255
199
|
```
|
|
256
200
|
|
|
257
201
|
### SignOutButton
|
|
@@ -332,21 +276,19 @@ const {
|
|
|
332
276
|
account,
|
|
333
277
|
isAuthenticated,
|
|
334
278
|
inProgress,
|
|
335
|
-
loginPopup,
|
|
336
279
|
loginRedirect,
|
|
337
|
-
logoutPopup,
|
|
338
280
|
logoutRedirect,
|
|
339
281
|
acquireToken,
|
|
340
282
|
} = useMsalAuth();
|
|
341
283
|
|
|
342
|
-
// Login
|
|
343
|
-
await
|
|
284
|
+
// Login (redirects to Microsoft)
|
|
285
|
+
await loginRedirect(['User.Read']);
|
|
344
286
|
|
|
345
287
|
// Get token
|
|
346
288
|
const token = await acquireToken(['User.Read']);
|
|
347
289
|
|
|
348
|
-
// Logout
|
|
349
|
-
await
|
|
290
|
+
// Logout (redirects to Microsoft)
|
|
291
|
+
await logoutRedirect();
|
|
350
292
|
```
|
|
351
293
|
|
|
352
294
|
### useGraphApi
|
package/dist/index.d.mts
CHANGED
|
@@ -5,103 +5,276 @@ import { ReactNode, CSSProperties, Component, ErrorInfo, ComponentType } from 'r
|
|
|
5
5
|
import { NextRequest, NextResponse } from 'next/server';
|
|
6
6
|
export { useAccount, useIsAuthenticated, useMsal } from '@azure/msal-react';
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Type definitions for @chemmangat/msal-next
|
|
10
|
+
*
|
|
11
|
+
* @packageDocumentation
|
|
12
|
+
*/
|
|
13
|
+
|
|
8
14
|
/**
|
|
9
15
|
* Custom token claims interface for TypeScript generics
|
|
10
|
-
*
|
|
16
|
+
*
|
|
17
|
+
* @remarks
|
|
18
|
+
* Extend this interface to add type-safe custom claims from your Azure AD tokens.
|
|
19
|
+
* This is useful when you have custom claims configured in your Azure AD app registration.
|
|
11
20
|
*
|
|
12
21
|
* @example
|
|
13
22
|
* ```tsx
|
|
23
|
+
* // Define your custom claims
|
|
14
24
|
* interface MyCustomClaims extends CustomTokenClaims {
|
|
15
25
|
* roles: string[];
|
|
16
26
|
* department: string;
|
|
27
|
+
* employeeId: string;
|
|
17
28
|
* }
|
|
18
29
|
*
|
|
19
|
-
*
|
|
30
|
+
* // Use with type safety
|
|
31
|
+
* const { account } = useMsalAuth();
|
|
32
|
+
* const claims = account?.idTokenClaims as MyCustomClaims;
|
|
33
|
+
*
|
|
34
|
+
* console.log(claims.roles); // Type-safe!
|
|
35
|
+
* console.log(claims.department); // Type-safe!
|
|
20
36
|
* ```
|
|
21
37
|
*/
|
|
22
38
|
interface CustomTokenClaims {
|
|
23
39
|
[key: string]: any;
|
|
24
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Configuration options for MSAL authentication
|
|
43
|
+
*
|
|
44
|
+
* @remarks
|
|
45
|
+
* This interface defines all available configuration options for the MSAL provider.
|
|
46
|
+
* Most options have sensible defaults and only clientId is required.
|
|
47
|
+
*/
|
|
25
48
|
interface MsalAuthConfig {
|
|
26
49
|
/**
|
|
27
50
|
* Azure AD Application (client) ID
|
|
51
|
+
*
|
|
52
|
+
* @remarks
|
|
53
|
+
* Required. Get this from your Azure AD app registration.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```tsx
|
|
57
|
+
* clientId: "12345678-1234-1234-1234-123456789012"
|
|
58
|
+
* ```
|
|
28
59
|
*/
|
|
29
60
|
clientId: string;
|
|
30
61
|
/**
|
|
31
|
-
* Azure AD Directory (tenant) ID
|
|
62
|
+
* Azure AD Directory (tenant) ID
|
|
63
|
+
*
|
|
64
|
+
* @remarks
|
|
65
|
+
* Optional. Required for single-tenant apps.
|
|
66
|
+
* Omit for multi-tenant apps (use authorityType: 'common' instead).
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```tsx
|
|
70
|
+
* tenantId: "87654321-4321-4321-4321-210987654321"
|
|
71
|
+
* ```
|
|
32
72
|
*/
|
|
33
73
|
tenantId?: string;
|
|
34
74
|
/**
|
|
35
|
-
* Authority type
|
|
36
|
-
*
|
|
75
|
+
* Authority type for authentication
|
|
76
|
+
*
|
|
77
|
+
* @remarks
|
|
78
|
+
* - 'common': Multi-tenant (any Azure AD tenant)
|
|
79
|
+
* - 'organizations': Any organizational Azure AD tenant
|
|
80
|
+
* - 'consumers': Microsoft personal accounts only
|
|
81
|
+
* - 'tenant': Single-tenant (requires tenantId)
|
|
82
|
+
*
|
|
83
|
+
* @defaultValue 'common'
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```tsx
|
|
87
|
+
* // Multi-tenant SaaS app
|
|
88
|
+
* authorityType: 'common'
|
|
89
|
+
*
|
|
90
|
+
* // Single-tenant enterprise app
|
|
91
|
+
* authorityType: 'tenant'
|
|
92
|
+
* tenantId: "your-tenant-id"
|
|
93
|
+
* ```
|
|
37
94
|
*/
|
|
38
95
|
authorityType?: 'common' | 'organizations' | 'consumers' | 'tenant';
|
|
39
96
|
/**
|
|
40
97
|
* Redirect URI after authentication
|
|
41
|
-
*
|
|
98
|
+
*
|
|
99
|
+
* @remarks
|
|
100
|
+
* Must match a redirect URI configured in your Azure AD app registration.
|
|
101
|
+
*
|
|
102
|
+
* @defaultValue window.location.origin
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```tsx
|
|
106
|
+
* redirectUri: "https://myapp.com/auth/callback"
|
|
107
|
+
* ```
|
|
42
108
|
*/
|
|
43
109
|
redirectUri?: string;
|
|
44
|
-
/**
|
|
45
|
-
* Redirect URI for popup authentication (optional)
|
|
46
|
-
* If not specified, uses the same redirectUri as redirect flow
|
|
47
|
-
* Only set this if you want a different URI for popup (e.g., /blank.html)
|
|
48
|
-
* @default redirectUri
|
|
49
|
-
*/
|
|
50
|
-
popupRedirectUri?: string;
|
|
51
110
|
/**
|
|
52
111
|
* Post logout redirect URI
|
|
53
|
-
*
|
|
112
|
+
*
|
|
113
|
+
* @remarks
|
|
114
|
+
* Where to redirect after logout. Defaults to redirectUri if not specified.
|
|
115
|
+
*
|
|
116
|
+
* @defaultValue redirectUri
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```tsx
|
|
120
|
+
* postLogoutRedirectUri: "https://myapp.com"
|
|
121
|
+
* ```
|
|
54
122
|
*/
|
|
55
123
|
postLogoutRedirectUri?: string;
|
|
56
124
|
/**
|
|
57
125
|
* Default scopes for authentication
|
|
58
|
-
*
|
|
126
|
+
*
|
|
127
|
+
* @remarks
|
|
128
|
+
* Scopes define what permissions your app requests.
|
|
129
|
+
* Common scopes: 'User.Read', 'Mail.Read', 'Calendars.Read'
|
|
130
|
+
*
|
|
131
|
+
* @defaultValue ['User.Read']
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* ```tsx
|
|
135
|
+
* scopes: ['User.Read', 'Mail.Read', 'Calendars.Read']
|
|
136
|
+
* ```
|
|
59
137
|
*/
|
|
60
138
|
scopes?: string[];
|
|
61
139
|
/**
|
|
62
|
-
* Cache location
|
|
63
|
-
*
|
|
140
|
+
* Cache location for tokens
|
|
141
|
+
*
|
|
142
|
+
* @remarks
|
|
143
|
+
* - 'sessionStorage': Tokens cleared when browser tab closes (more secure)
|
|
144
|
+
* - 'localStorage': Tokens persist across browser sessions
|
|
145
|
+
* - 'memoryStorage': Tokens only in memory (most secure, but lost on refresh)
|
|
146
|
+
*
|
|
147
|
+
* @defaultValue 'sessionStorage'
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* ```tsx
|
|
151
|
+
* cacheLocation: 'sessionStorage'
|
|
152
|
+
* ```
|
|
64
153
|
*/
|
|
65
154
|
cacheLocation?: 'sessionStorage' | 'localStorage' | 'memoryStorage';
|
|
66
155
|
/**
|
|
67
|
-
* Store auth state in cookie
|
|
68
|
-
*
|
|
156
|
+
* Store auth state in cookie
|
|
157
|
+
*
|
|
158
|
+
* @remarks
|
|
159
|
+
* Enable for IE11/Edge legacy support. Not needed for modern browsers.
|
|
160
|
+
*
|
|
161
|
+
* @defaultValue false
|
|
69
162
|
*/
|
|
70
163
|
storeAuthStateInCookie?: boolean;
|
|
71
164
|
/**
|
|
72
165
|
* Navigate to login request URL after authentication
|
|
73
|
-
*
|
|
166
|
+
*
|
|
167
|
+
* @remarks
|
|
168
|
+
* If true, redirects to the page that initiated login after successful auth.
|
|
169
|
+
*
|
|
170
|
+
* @defaultValue true
|
|
74
171
|
*/
|
|
75
172
|
navigateToLoginRequestUrl?: boolean;
|
|
76
173
|
/**
|
|
77
|
-
* Custom MSAL configuration
|
|
174
|
+
* Custom MSAL configuration
|
|
175
|
+
*
|
|
176
|
+
* @remarks
|
|
177
|
+
* Advanced: Provide a complete MSAL configuration object.
|
|
178
|
+
* This overrides all other configuration options.
|
|
179
|
+
*
|
|
180
|
+
* @example
|
|
181
|
+
* ```tsx
|
|
182
|
+
* msalConfig: {
|
|
183
|
+
* auth: {
|
|
184
|
+
* clientId: "your-client-id",
|
|
185
|
+
* authority: "https://login.microsoftonline.com/your-tenant-id",
|
|
186
|
+
* },
|
|
187
|
+
* cache: {
|
|
188
|
+
* cacheLocation: "sessionStorage",
|
|
189
|
+
* },
|
|
190
|
+
* }
|
|
191
|
+
* ```
|
|
78
192
|
*/
|
|
79
193
|
msalConfig?: Configuration;
|
|
80
194
|
/**
|
|
81
195
|
* Enable debug logging
|
|
82
|
-
*
|
|
196
|
+
*
|
|
197
|
+
* @remarks
|
|
198
|
+
* Logs authentication events to the console. Useful for troubleshooting.
|
|
199
|
+
*
|
|
200
|
+
* @defaultValue false
|
|
201
|
+
*
|
|
202
|
+
* @example
|
|
203
|
+
* ```tsx
|
|
204
|
+
* enableLogging: true
|
|
205
|
+
* ```
|
|
83
206
|
*/
|
|
84
207
|
enableLogging?: boolean;
|
|
85
208
|
/**
|
|
86
209
|
* Custom logger callback
|
|
210
|
+
*
|
|
211
|
+
* @remarks
|
|
212
|
+
* Advanced: Provide a custom function to handle MSAL logs.
|
|
213
|
+
*
|
|
214
|
+
* @example
|
|
215
|
+
* ```tsx
|
|
216
|
+
* loggerCallback: (level, message, containsPii) => {
|
|
217
|
+
* if (level === LogLevel.Error) {
|
|
218
|
+
* console.error('MSAL Error:', message);
|
|
219
|
+
* }
|
|
220
|
+
* }
|
|
221
|
+
* ```
|
|
87
222
|
*/
|
|
88
223
|
loggerCallback?: (level: LogLevel, message: string, containsPii: boolean) => void;
|
|
89
224
|
/**
|
|
90
|
-
* Allowed redirect URIs for validation
|
|
91
|
-
*
|
|
92
|
-
* @
|
|
225
|
+
* Allowed redirect URIs for validation
|
|
226
|
+
*
|
|
227
|
+
* @remarks
|
|
228
|
+
* Security: Whitelist of allowed redirect URIs to prevent open redirect vulnerabilities.
|
|
229
|
+
* Recommended for production apps.
|
|
230
|
+
*
|
|
231
|
+
* @example
|
|
232
|
+
* ```tsx
|
|
233
|
+
* allowedRedirectUris: [
|
|
234
|
+
* 'https://myapp.com',
|
|
235
|
+
* 'https://staging.myapp.com',
|
|
236
|
+
* 'http://localhost:3000'
|
|
237
|
+
* ]
|
|
238
|
+
* ```
|
|
93
239
|
*/
|
|
94
240
|
allowedRedirectUris?: string[];
|
|
95
241
|
/**
|
|
96
242
|
* Loading component to show while MSAL initializes
|
|
243
|
+
*
|
|
244
|
+
* @remarks
|
|
245
|
+
* Custom React component to display during MSAL initialization.
|
|
246
|
+
*
|
|
247
|
+
* @example
|
|
248
|
+
* ```tsx
|
|
249
|
+
* loadingComponent: <div className="spinner">Loading...</div>
|
|
250
|
+
* ```
|
|
97
251
|
*/
|
|
98
252
|
loadingComponent?: ReactNode;
|
|
99
253
|
/**
|
|
100
|
-
* Callback invoked after MSAL initialization completes
|
|
254
|
+
* Callback invoked after MSAL initialization completes
|
|
255
|
+
*
|
|
256
|
+
* @remarks
|
|
257
|
+
* Use this to perform actions after MSAL is ready, such as logging or analytics.
|
|
258
|
+
*
|
|
259
|
+
* @example
|
|
260
|
+
* ```tsx
|
|
261
|
+
* onInitialized: (instance) => {
|
|
262
|
+
* console.log('MSAL initialized with', instance.getAllAccounts().length, 'accounts');
|
|
263
|
+
* }
|
|
264
|
+
* ```
|
|
101
265
|
*/
|
|
102
266
|
onInitialized?: (instance: IPublicClientApplication) => void;
|
|
103
267
|
}
|
|
268
|
+
/**
|
|
269
|
+
* Props for MsalAuthProvider component
|
|
270
|
+
*
|
|
271
|
+
* @remarks
|
|
272
|
+
* Extends MsalAuthConfig with React children prop
|
|
273
|
+
*/
|
|
104
274
|
interface MsalAuthProviderProps extends MsalAuthConfig {
|
|
275
|
+
/**
|
|
276
|
+
* Child components to wrap with authentication context
|
|
277
|
+
*/
|
|
105
278
|
children: ReactNode;
|
|
106
279
|
}
|
|
107
280
|
|
|
@@ -156,11 +329,6 @@ interface MicrosoftSignInButtonProps {
|
|
|
156
329
|
* @default 'medium'
|
|
157
330
|
*/
|
|
158
331
|
size?: 'small' | 'medium' | 'large';
|
|
159
|
-
/**
|
|
160
|
-
* Use redirect flow instead of popup
|
|
161
|
-
* @default true
|
|
162
|
-
*/
|
|
163
|
-
useRedirect?: boolean;
|
|
164
332
|
/**
|
|
165
333
|
* Scopes to request
|
|
166
334
|
*/
|
|
@@ -182,7 +350,7 @@ interface MicrosoftSignInButtonProps {
|
|
|
182
350
|
*/
|
|
183
351
|
onError?: (error: Error) => void;
|
|
184
352
|
}
|
|
185
|
-
declare function MicrosoftSignInButton({ text, variant, size,
|
|
353
|
+
declare function MicrosoftSignInButton({ text, variant, size, scopes, className, style, onSuccess, onError, }: MicrosoftSignInButtonProps): react_jsx_runtime.JSX.Element;
|
|
186
354
|
|
|
187
355
|
interface SignOutButtonProps {
|
|
188
356
|
/**
|
|
@@ -200,11 +368,6 @@ interface SignOutButtonProps {
|
|
|
200
368
|
* @default 'medium'
|
|
201
369
|
*/
|
|
202
370
|
size?: 'small' | 'medium' | 'large';
|
|
203
|
-
/**
|
|
204
|
-
* Use redirect flow instead of popup
|
|
205
|
-
* @default false
|
|
206
|
-
*/
|
|
207
|
-
useRedirect?: boolean;
|
|
208
371
|
/**
|
|
209
372
|
* Custom className
|
|
210
373
|
*/
|
|
@@ -224,13 +387,14 @@ interface SignOutButtonProps {
|
|
|
224
387
|
}
|
|
225
388
|
/**
|
|
226
389
|
* SignOutButton component with Microsoft branding
|
|
390
|
+
* Uses redirect flow (full page redirect)
|
|
227
391
|
*
|
|
228
392
|
* @example
|
|
229
393
|
* ```tsx
|
|
230
394
|
* <SignOutButton variant="light" />
|
|
231
395
|
* ```
|
|
232
396
|
*/
|
|
233
|
-
declare function SignOutButton({ text, variant, size,
|
|
397
|
+
declare function SignOutButton({ text, variant, size, className, style, onSuccess, onError, }: SignOutButtonProps): react_jsx_runtime.JSX.Element;
|
|
234
398
|
|
|
235
399
|
interface UserAvatarProps {
|
|
236
400
|
/**
|
|
@@ -316,11 +480,6 @@ interface AuthGuardProps {
|
|
|
316
480
|
* Component to show when not authenticated (before redirect)
|
|
317
481
|
*/
|
|
318
482
|
fallbackComponent?: ReactNode;
|
|
319
|
-
/**
|
|
320
|
-
* Use redirect flow instead of popup
|
|
321
|
-
* @default true
|
|
322
|
-
*/
|
|
323
|
-
useRedirect?: boolean;
|
|
324
483
|
/**
|
|
325
484
|
* Scopes to request during authentication
|
|
326
485
|
*/
|
|
@@ -340,7 +499,7 @@ interface AuthGuardProps {
|
|
|
340
499
|
* </AuthGuard>
|
|
341
500
|
* ```
|
|
342
501
|
*/
|
|
343
|
-
declare function AuthGuard({ children, loadingComponent, fallbackComponent,
|
|
502
|
+
declare function AuthGuard({ children, loadingComponent, fallbackComponent, scopes, onAuthRequired, }: AuthGuardProps): react_jsx_runtime.JSX.Element;
|
|
344
503
|
|
|
345
504
|
interface ErrorBoundaryProps {
|
|
346
505
|
/**
|
|
@@ -402,34 +561,22 @@ interface UseMsalAuthReturn {
|
|
|
402
561
|
* Whether MSAL is currently performing an interaction
|
|
403
562
|
*/
|
|
404
563
|
inProgress: boolean;
|
|
405
|
-
/**
|
|
406
|
-
* Login using popup
|
|
407
|
-
*/
|
|
408
|
-
loginPopup: (scopes?: string[]) => Promise<void>;
|
|
409
564
|
/**
|
|
410
565
|
* Login using redirect
|
|
411
566
|
*/
|
|
412
567
|
loginRedirect: (scopes?: string[]) => Promise<void>;
|
|
413
|
-
/**
|
|
414
|
-
* Logout using popup
|
|
415
|
-
*/
|
|
416
|
-
logoutPopup: () => Promise<void>;
|
|
417
568
|
/**
|
|
418
569
|
* Logout using redirect
|
|
419
570
|
*/
|
|
420
571
|
logoutRedirect: () => Promise<void>;
|
|
421
572
|
/**
|
|
422
|
-
* Acquire access token silently
|
|
573
|
+
* Acquire access token silently
|
|
423
574
|
*/
|
|
424
575
|
acquireToken: (scopes: string[]) => Promise<string>;
|
|
425
576
|
/**
|
|
426
577
|
* Acquire access token silently only (no fallback)
|
|
427
578
|
*/
|
|
428
579
|
acquireTokenSilent: (scopes: string[]) => Promise<string>;
|
|
429
|
-
/**
|
|
430
|
-
* Acquire access token using popup
|
|
431
|
-
*/
|
|
432
|
-
acquireTokenPopup: (scopes: string[]) => Promise<string>;
|
|
433
580
|
/**
|
|
434
581
|
* Acquire access token using redirect
|
|
435
582
|
*/
|
|
@@ -591,7 +738,6 @@ interface UseRolesReturn {
|
|
|
591
738
|
*/
|
|
592
739
|
declare function useRoles(): UseRolesReturn;
|
|
593
740
|
|
|
594
|
-
declare function getPopupRedirectUri(): string | undefined;
|
|
595
741
|
declare function createMsalConfig(config: MsalAuthConfig): Configuration;
|
|
596
742
|
|
|
597
743
|
interface WithAuthOptions extends Omit<AuthGuardProps, 'children'> {
|
|
@@ -939,4 +1085,4 @@ interface ServerSession {
|
|
|
939
1085
|
accessToken?: string;
|
|
940
1086
|
}
|
|
941
1087
|
|
|
942
|
-
export { AuthGuard, type AuthGuardProps, type AuthMiddlewareConfig, AuthStatus, type AuthStatusProps, type CustomTokenClaims, type DebugLoggerConfig, ErrorBoundary, type ErrorBoundaryProps, type GraphApiOptions, MSALProvider, MicrosoftSignInButton, type MicrosoftSignInButtonProps, type MsalAuthConfig, MsalAuthProvider, type MsalAuthProviderProps, type RetryConfig, type ServerSession, SignOutButton, type SignOutButtonProps, type UseGraphApiReturn, type UseMsalAuthReturn, type UseRolesReturn, type UseUserProfileReturn, UserAvatar, type UserAvatarProps, type UserProfile, type ValidatedAccountData, type WithAuthOptions, createAuthMiddleware, createMsalConfig, createRetryWrapper, createScopedLogger, getDebugLogger, getMsalInstance,
|
|
1088
|
+
export { AuthGuard, type AuthGuardProps, type AuthMiddlewareConfig, AuthStatus, type AuthStatusProps, type CustomTokenClaims, type DebugLoggerConfig, ErrorBoundary, type ErrorBoundaryProps, type GraphApiOptions, MSALProvider, MicrosoftSignInButton, type MicrosoftSignInButtonProps, type MsalAuthConfig, MsalAuthProvider, type MsalAuthProviderProps, type RetryConfig, type ServerSession, SignOutButton, type SignOutButtonProps, type UseGraphApiReturn, type UseMsalAuthReturn, type UseRolesReturn, type UseUserProfileReturn, UserAvatar, type UserAvatarProps, type UserProfile, type ValidatedAccountData, type WithAuthOptions, createAuthMiddleware, createMsalConfig, createRetryWrapper, createScopedLogger, getDebugLogger, getMsalInstance, isValidAccountData, isValidRedirectUri, isValidScope, retryWithBackoff, safeJsonParse, sanitizeError, useGraphApi, useMsalAuth, useRoles, useUserProfile, validateScopes, withAuth };
|