@equinor/fusion-framework-module-msal 5.1.2 → 6.0.0-next.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.
Files changed (144) hide show
  1. package/CHANGELOG.md +98 -0
  2. package/README.md +237 -40
  3. package/dist/esm/MsalClient.interface.js +2 -0
  4. package/dist/esm/MsalClient.interface.js.map +1 -0
  5. package/dist/esm/MsalClient.js +215 -0
  6. package/dist/esm/MsalClient.js.map +1 -0
  7. package/dist/esm/MsalConfigurator.js +248 -0
  8. package/dist/esm/MsalConfigurator.js.map +1 -0
  9. package/dist/esm/MsalProvider.interface.js +2 -0
  10. package/dist/esm/MsalProvider.interface.js.map +1 -0
  11. package/dist/esm/MsalProvider.js +525 -0
  12. package/dist/esm/MsalProvider.js.map +1 -0
  13. package/dist/esm/MsalProxyProvider.interface.js +2 -0
  14. package/dist/esm/MsalProxyProvider.interface.js.map +1 -0
  15. package/dist/esm/__tests__/versioning/resolve-version.test.js +29 -38
  16. package/dist/esm/__tests__/versioning/resolve-version.test.js.map +1 -1
  17. package/dist/esm/create-client-log-callback.js +87 -0
  18. package/dist/esm/create-client-log-callback.js.map +1 -0
  19. package/dist/esm/create-proxy-provider.js +84 -0
  20. package/dist/esm/create-proxy-provider.js.map +1 -0
  21. package/dist/esm/index.js +1 -1
  22. package/dist/esm/index.js.map +1 -1
  23. package/dist/esm/module.js +64 -16
  24. package/dist/esm/module.js.map +1 -1
  25. package/dist/esm/static.js +32 -2
  26. package/dist/esm/static.js.map +1 -1
  27. package/dist/esm/types.js +9 -0
  28. package/dist/esm/types.js.map +1 -1
  29. package/dist/esm/util/compare-origin.js +11 -0
  30. package/dist/esm/util/compare-origin.js.map +1 -0
  31. package/dist/esm/{v2/client/util/url.js → util/normalize-uri.js} +1 -10
  32. package/dist/esm/util/normalize-uri.js.map +1 -0
  33. package/dist/esm/{v2/client/util/browser.js → util/redirect.js} +1 -1
  34. package/dist/esm/util/redirect.js.map +1 -0
  35. package/dist/esm/v2/IAuthClient.interface.js +2 -0
  36. package/dist/esm/v2/IAuthClient.interface.js.map +1 -0
  37. package/dist/esm/v2/IPublicClientApplication.interface.js +2 -0
  38. package/dist/esm/v2/IPublicClientApplication.interface.js.map +1 -0
  39. package/dist/esm/v2/MsalProvider.interface.js +2 -0
  40. package/dist/esm/v2/MsalProvider.interface.js.map +1 -0
  41. package/dist/esm/v2/create-proxy-client.js +155 -0
  42. package/dist/esm/v2/create-proxy-client.js.map +1 -0
  43. package/dist/esm/v2/create-proxy-provider.js +140 -0
  44. package/dist/esm/v2/create-proxy-provider.js.map +1 -0
  45. package/dist/esm/v2/map-account-info.js +18 -0
  46. package/dist/esm/v2/map-account-info.js.map +1 -0
  47. package/dist/esm/v2/map-authentication-result.js +22 -0
  48. package/dist/esm/v2/map-authentication-result.js.map +1 -0
  49. package/dist/esm/version.js +1 -1
  50. package/dist/esm/version.js.map +1 -1
  51. package/dist/esm/versioning/resolve-version.js +28 -16
  52. package/dist/esm/versioning/resolve-version.js.map +1 -1
  53. package/dist/tsconfig.tsbuildinfo +1 -1
  54. package/dist/types/MsalClient.d.ts +141 -0
  55. package/dist/types/MsalClient.interface.d.ts +103 -0
  56. package/dist/types/MsalConfigurator.d.ts +147 -0
  57. package/dist/types/MsalProvider.d.ts +291 -0
  58. package/dist/types/MsalProvider.interface.d.ts +159 -0
  59. package/dist/types/MsalProxyProvider.interface.d.ts +52 -0
  60. package/dist/types/create-client-log-callback.d.ts +38 -0
  61. package/dist/types/create-proxy-provider.d.ts +19 -0
  62. package/dist/types/index.d.ts +5 -4
  63. package/dist/types/module.d.ts +70 -4
  64. package/dist/types/static.d.ts +32 -1
  65. package/dist/types/types.d.ts +14 -6
  66. package/dist/types/util/redirect.d.ts +1 -0
  67. package/dist/types/v2/IAuthClient.interface.d.ts +68 -0
  68. package/dist/types/v2/IPublicClientApplication.interface.d.ts +68 -0
  69. package/dist/types/v2/MsalProvider.interface.d.ts +85 -0
  70. package/dist/types/v2/create-proxy-client.d.ts +22 -0
  71. package/dist/types/v2/create-proxy-provider.d.ts +24 -0
  72. package/dist/types/v2/map-account-info.d.ts +9 -0
  73. package/dist/types/v2/map-authentication-result.d.ts +9 -0
  74. package/dist/types/v2/types.d.ts +12 -0
  75. package/dist/types/version.d.ts +1 -1
  76. package/dist/types/versioning/resolve-version.d.ts +1 -1
  77. package/package.json +11 -6
  78. package/src/MsalClient.interface.ts +121 -0
  79. package/src/MsalClient.ts +274 -0
  80. package/src/MsalConfigurator.ts +289 -0
  81. package/src/MsalProvider.interface.ts +175 -0
  82. package/src/MsalProvider.ts +597 -0
  83. package/src/MsalProxyProvider.interface.ts +71 -0
  84. package/src/__tests__/versioning/resolve-version.test.ts +29 -42
  85. package/src/create-client-log-callback.ts +101 -0
  86. package/src/create-proxy-provider.ts +89 -0
  87. package/src/index.ts +6 -7
  88. package/src/module.ts +88 -20
  89. package/src/static.ts +32 -3
  90. package/src/types.ts +15 -7
  91. package/src/util/compare-origin.ts +11 -0
  92. package/src/{v2/client/util/url.ts → util/normalize-uri.ts} +0 -10
  93. package/src/v2/IAuthClient.interface.ts +91 -0
  94. package/src/v2/IPublicClientApplication.interface.ts +71 -0
  95. package/src/v2/MsalProvider.interface.ts +92 -0
  96. package/src/v2/create-proxy-client.ts +186 -0
  97. package/src/v2/create-proxy-provider.ts +156 -0
  98. package/src/v2/map-account-info.ts +20 -0
  99. package/src/v2/map-authentication-result.ts +24 -0
  100. package/src/v2/types.ts +12 -0
  101. package/src/version.ts +1 -1
  102. package/src/versioning/resolve-version.ts +35 -28
  103. package/tsconfig.json +3 -0
  104. package/dist/esm/v2/client/behavior.js +0 -5
  105. package/dist/esm/v2/client/behavior.js.map +0 -1
  106. package/dist/esm/v2/client/client.js +0 -142
  107. package/dist/esm/v2/client/client.js.map +0 -1
  108. package/dist/esm/v2/client/create-auth-client.js +0 -36
  109. package/dist/esm/v2/client/create-auth-client.js.map +0 -1
  110. package/dist/esm/v2/client/index.js +0 -5
  111. package/dist/esm/v2/client/index.js.map +0 -1
  112. package/dist/esm/v2/client/log/console.js +0 -45
  113. package/dist/esm/v2/client/log/console.js.map +0 -1
  114. package/dist/esm/v2/client/request.js +0 -2
  115. package/dist/esm/v2/client/request.js.map +0 -1
  116. package/dist/esm/v2/client/util/browser.js.map +0 -1
  117. package/dist/esm/v2/client/util/url.js.map +0 -1
  118. package/dist/esm/v2/configurator.js +0 -42
  119. package/dist/esm/v2/configurator.js.map +0 -1
  120. package/dist/esm/v2/index.js +0 -3
  121. package/dist/esm/v2/index.js.map +0 -1
  122. package/dist/esm/v2/provider.js +0 -115
  123. package/dist/esm/v2/provider.js.map +0 -1
  124. package/dist/types/v2/client/behavior.d.ts +0 -13
  125. package/dist/types/v2/client/client.d.ts +0 -89
  126. package/dist/types/v2/client/create-auth-client.d.ts +0 -27
  127. package/dist/types/v2/client/index.d.ts +0 -5
  128. package/dist/types/v2/client/log/console.d.ts +0 -28
  129. package/dist/types/v2/client/request.d.ts +0 -65
  130. package/dist/types/v2/configurator.d.ts +0 -32
  131. package/dist/types/v2/index.d.ts +0 -2
  132. package/dist/types/v2/provider.d.ts +0 -59
  133. package/src/v2/client/behavior.ts +0 -14
  134. package/src/v2/client/client.ts +0 -180
  135. package/src/v2/client/create-auth-client.ts +0 -48
  136. package/src/v2/client/index.ts +0 -8
  137. package/src/v2/client/log/console.ts +0 -58
  138. package/src/v2/client/request.ts +0 -66
  139. package/src/v2/configurator.ts +0 -58
  140. package/src/v2/index.ts +0 -2
  141. package/src/v2/provider.ts +0 -178
  142. /package/dist/types/{v2/client/util/browser.d.ts → util/compare-origin.d.ts} +0 -0
  143. /package/dist/types/{v2/client/util/url.d.ts → util/normalize-uri.d.ts} +0 -0
  144. /package/src/{v2/client/util/browser.ts → util/redirect.ts} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,103 @@
1
1
  # Change Log
2
2
 
3
+ ## 6.0.0-next.0
4
+
5
+ ### Major Changes
6
+
7
+ - [#3693](https://github.com/equinor/fusion-framework/pull/3693) [`d81294a`](https://github.com/equinor/fusion-framework/commit/d81294a4d74f7c7bebd8c7c3734c32c34fcb6b1e) Thanks [@github-actions](https://github.com/apps/github-actions)! - # MSAL v4 Upgrade
8
+
9
+ ## What Changed
10
+
11
+ Upgraded from MSAL v2 to MSAL v4 with full backward compatibility, addressing the requirements outlined in [issue #3621](https://github.com/equinor/fusion-framework/issues/3621).
12
+
13
+ ## Impact on Your Code
14
+
15
+ **✅ No breaking changes for existing code** - All current MSAL v2 API calls continue to work exactly as before.
16
+
17
+ **🚀 Enhanced features available** - New v4 APIs provide better performance, security, and error handling.
18
+
19
+ ## What You Get
20
+
21
+ - **Better Security**: Latest MSAL v4 security improvements and vulnerability fixes
22
+ - **Improved Performance**: Faster token acquisition and caching
23
+ - **Enhanced Error Handling**: More robust error recovery and retry mechanisms
24
+ - **Future-Proof**: Access to latest Microsoft authentication features
25
+
26
+ ## Migration (Optional)
27
+
28
+ **Current code works unchanged:**
29
+
30
+ ```typescript
31
+ // Framework configuration still works exactly the same
32
+ const framework = await createFramework({
33
+ modules: [enableMSAL()],
34
+ });
35
+
36
+ // Provider usage remains unchanged
37
+ const token = await framework.modules.auth.acquireToken({
38
+ scopes: ["User.Read"],
39
+ });
40
+ ```
41
+
42
+ **New v4 features available:**
43
+
44
+ ```typescript
45
+ // Enhanced configuration with new options
46
+ const framework = await createFramework({
47
+ modules: [enableMSAL()],
48
+ });
49
+
50
+ // Improved token acquisition with MSAL v4 request structure
51
+ const token = await framework.modules.auth.acquireToken({
52
+ request: { scopes: ["User.Read"] },
53
+ behavior: "popup",
54
+ silent: true,
55
+ });
56
+ ```
57
+
58
+ ## Breaking Changes
59
+
60
+ None for existing consumers. This is marked as major due to internal architecture changes, but the public API remains fully compatible.
61
+
62
+ - [#3693](https://github.com/equinor/fusion-framework/pull/3693) [`dd26dd3`](https://github.com/equinor/fusion-framework/commit/dd26dd3e652eb07a77bcdc878f8493c6db4fed48) Thanks [@github-actions](https://github.com/apps/github-actions)! - Add optional provider-level telemetry for MSAL flows and update interface methods.
63
+
64
+ **BREAKING CHANGES:**
65
+
66
+ - `acquireAccessToken(options: AcquireTokenOptions)` → `acquireAccessToken(options: AcquireTokenOptionsLegacy)`
67
+ - `acquireToken(options: AcquireTokenOptions)` → `acquireToken(options: AcquireTokenOptionsLegacy)`
68
+ - `logout(options?: LogoutOptions): Promise<void>` → `logout(options?: LogoutOptions): Promise<boolean>`
69
+ - `handleRedirect(): Promise<void>` → `handleRedirect(): Promise<AuthenticationResult | null>`
70
+ - Added `initialize(): Promise<void>` method
71
+
72
+ **New Features:**
73
+
74
+ - Optional provider-level telemetry for MSAL flows (login, token acquisition, redirect handling)
75
+ - Emits telemetry events and measurements via injected telemetry provider when available
76
+ - Includes basic metadata (framework module version, clientId, tenantId) and authentication context
77
+ - Integrates MSAL client logging with framework telemetry system
78
+
79
+ **Migration:**
80
+
81
+ ```typescript
82
+ // Before
83
+ await msalProvider.acquireAccessToken({ scopes: ["user.read"] });
84
+ await msalProvider.logout();
85
+ const result = await msalProvider.handleRedirect();
86
+
87
+ // After
88
+ await msalProvider.acquireAccessToken({ request: { scopes: ["user.read"] } });
89
+ const logoutResult = await msalProvider.logout(); // Now returns boolean
90
+ const result = await msalProvider.handleRedirect(); // Now returns AuthenticationResult | null
91
+ await msalProvider.initialize(); // New required method
92
+ ```
93
+
94
+ Related to `Add Telemetry Integration to MSAL Module` [#3634](https://github.com/equinor/fusion-framework/issues/3634).
95
+
96
+ ### Patch Changes
97
+
98
+ - Updated dependencies [[`dd26dd3`](https://github.com/equinor/fusion-framework/commit/dd26dd3e652eb07a77bcdc878f8493c6db4fed48)]:
99
+ - @equinor/fusion-framework-module-telemetry@4.4.0-next.0
100
+
3
101
  ## 5.1.2
4
102
 
5
103
  ### Patch Changes
package/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
 
2
2
  `@equinor/fusion-framework-module-msal` provides secure Azure AD authentication for browser applications using Microsoft's MSAL (Microsoft Authentication Library). Perfect for web applications, SPAs, and React apps that need to authenticate with Microsoft services.
3
3
 
4
+ > **Version**: This package now uses **MSAL Browser v4**, providing the latest security improvements and features from Microsoft.
5
+
4
6
  ## Features
5
7
 
6
8
  - **Single Sign-On (SSO)** support for Microsoft Azure AD and Azure AD B2C
@@ -9,6 +11,7 @@
9
11
  - **Silent Authentication** for seamless user experience
10
12
  - **Popup & Redirect Flows** for different authentication scenarios
11
13
  - **Zero Configuration** with sensible defaults and optional customization
14
+ - **MSAL v4 Compatibility** with v2 proxy layer for backward compatibility
12
15
 
13
16
  ## Quick Start
14
17
 
@@ -17,24 +20,59 @@ pnpm add @equinor/fusion-framework-module-msal
17
20
  ```
18
21
 
19
22
  ```typescript
20
- import { enableMSAL } from '@equinor/fusion-framework-module-msal';
23
+ import { enableMSAL, initialize, type IMsalProvider } from '@equinor/fusion-framework-module-msal';
21
24
  import { ModulesConfigurator } from '@equinor/fusion-framework-module';
22
25
 
26
+ // 1. Configure the module
23
27
  const configurator = new ModulesConfigurator();
24
28
 
25
29
  enableMSAL(configurator, (builder) => {
26
30
  builder.setClientConfig({
27
- tenantId: 'your-tenant-id',
28
- clientId: 'your-client-id',
29
- redirectUri: 'https://your-app.com/callback'
31
+ auth: {
32
+ clientId: 'your-client-id',
33
+ tenantId: 'your-tenant-id',
34
+ redirectUri: 'https://your-app.com/callback'
35
+ }
30
36
  });
37
+ // With requiresAuth=true, the module will attempt automatic login during initialization
38
+ // and await a valid authenticated account before initialization completes
31
39
  builder.setRequiresAuth(true);
32
40
  });
33
41
 
34
- const framework = await initialize();
35
- const token = await framework.auth.acquireAccessToken({
36
- scopes: ['https://graph.microsoft.com/.default']
42
+ // 2. Initialize the framework (auto-initializes auth provider)
43
+ const framework = await initialize(configurator);
44
+ const auth: IMsalProvider = framework.auth;
45
+
46
+ // 3. Optional: Handle authentication redirect manually (auto-called during initialization)
47
+ const redirectResult = await auth.handleRedirect();
48
+ if (redirectResult?.account) {
49
+ console.log('Authenticated:', redirectResult.account.username);
50
+ }
51
+
52
+ // 4. Use authentication
53
+ // Option A: Token acquisition (v4 format - recommended)
54
+ const token = await auth.acquireAccessToken({
55
+ request: { scopes: ['api://your-app-id/.default'] }
56
+ });
57
+
58
+ // Option B: Legacy format (still supported via v2 proxy)
59
+ const legacyToken = await auth.acquireAccessToken({
60
+ scopes: ['api://your-app-id/.default']
37
61
  });
62
+
63
+ // Option C: Silent authentication with fallback
64
+ try {
65
+ const result = await auth.login({
66
+ request: { scopes: ['api://your-app-id/.default'] },
67
+ silent: true // Attempts SSO first
68
+ });
69
+ } catch {
70
+ // Fallback to interactive if silent fails
71
+ await auth.login({
72
+ request: { scopes: ['api://your-app-id/.default'] },
73
+ behavior: 'popup'
74
+ });
75
+ }
38
76
  ```
39
77
 
40
78
  > [!IMPORTANT]
@@ -47,9 +85,9 @@ const token = await framework.auth.acquireAccessToken({
47
85
 
48
86
  | Setting | Description | Required |
49
87
  |---------|-------------|----------|
50
- | `clientId` | Azure AD application client ID | ✅ |
51
- | `tenantId` | Azure AD tenant ID | ✅ |
52
- | `redirectUri` | Authentication callback URL | Optional |
88
+ | `auth.clientId` | Azure AD application client ID | ✅ |
89
+ | `auth.tenantId` | Azure AD tenant ID | ✅ |
90
+ | `auth.redirectUri` | Authentication callback URL | Optional |
53
91
 
54
92
  ### Optional Settings
55
93
 
@@ -71,38 +109,88 @@ AZURE_REDIRECT_URI=https://your-app.com/callback
71
109
 
72
110
  ## API Reference
73
111
 
74
- ### `enableMSAL(configurator, configure)`
112
+ ### `enableMSAL(configurator, configure?)`
75
113
 
76
114
  Enables the MSAL module in your Fusion Framework application.
77
115
 
78
116
  **Parameters:**
79
- - `configurator`: `ModulesConfigurator` - The modules configurator instance
80
- - `configure`: `(builder: IAuthConfigurator) => void` - Configuration function
117
+ - `configurator`: `IModulesConfigurator` - The modules configurator instance
118
+ - `configure?`: `(builder: { setClientConfig, setRequiresAuth }) => void` - Optional configuration function
119
+
120
+ **Returns:** `void`
121
+
122
+ **Example:**
123
+ ```typescript
124
+ enableMSAL(configurator, (builder) => {
125
+ builder.setClientConfig({ auth: { clientId: '...', tenantId: '...' } });
126
+ builder.setRequiresAuth(true);
127
+ });
128
+ ```
81
129
 
82
- ### `IAuthProvider`
130
+ ### Type Definitions
131
+
132
+ #### `LoginOptions`
133
+
134
+ ```typescript
135
+ type LoginOptions = {
136
+ request: PopupRequest | RedirectRequest; // MSAL request object
137
+ behavior?: 'popup' | 'redirect'; // Auth method (default: 'redirect')
138
+ silent?: boolean; // Attempt silent auth first (default: true)
139
+ };
140
+ ```
141
+
142
+ #### `LogoutOptions`
143
+
144
+ ```typescript
145
+ type LogoutOptions = {
146
+ redirectUri?: string; // Redirect after logout
147
+ account?: AccountInfo; // Account to logout (defaults to active)
148
+ };
149
+ ```
150
+
151
+ #### `AcquireTokenOptions`
152
+
153
+ ```typescript
154
+ type AcquireTokenOptions = {
155
+ request: PopupRequest | RedirectRequest; // MSAL request with scopes
156
+ behavior?: 'popup' | 'redirect'; // Auth method (default: 'redirect')
157
+ silent?: boolean; // Attempt silent first (default: true if account available)
158
+ };
159
+ ```
160
+
161
+ ### `IMsalProvider`
83
162
 
84
163
  The authentication provider interface available at `framework.auth`:
85
164
 
86
165
  ```typescript
87
- interface IAuthProvider {
166
+ interface IMsalProvider {
167
+ // The MSAL PublicClientApplication instance
168
+ readonly client: IMsalClient;
169
+
88
170
  // Current user account information
89
- readonly defaultAccount: AccountInfo | undefined;
171
+ readonly account: AccountInfo | null;
172
+
173
+ // Initialize the MSAL provider
174
+ initialize(): Promise<void>;
90
175
 
91
176
  // Acquire an access token for the specified scopes
92
- acquireAccessToken(options: { scopes: string[] }): Promise<string | undefined>;
177
+ acquireAccessToken(options: AcquireTokenOptionsLegacy): Promise<string | undefined>;
93
178
 
94
179
  // Acquire full authentication result
95
- acquireToken(options: { scopes: string[] }): Promise<AuthenticationResult | void>;
180
+ acquireToken(options: AcquireTokenOptionsLegacy): Promise<AcquireTokenResult>;
96
181
 
97
- // Login user
98
- login(): Promise<void>;
182
+ // Login user interactively
183
+ login(options: LoginOptions): Promise<LoginResult>;
99
184
 
100
- // Logout user
101
- logout(options?: { redirectUri?: string }): Promise<void>;
185
+ // Logout user (returns boolean)
186
+ logout(options?: LogoutOptions): Promise<boolean>;
102
187
 
103
- // Handle authentication redirect
104
- handleRedirect(): Promise<void | null>;
188
+ // Handle authentication redirect (returns AuthenticationResult | null)
189
+ handleRedirect(): Promise<AuthenticationResult | null>;
105
190
  }
191
+
192
+ // Note: defaultAccount and other deprecated v2 properties are available only
193
+ // when using a v2-compatible proxy via createProxyProvider()
106
194
  ```
107
195
 
108
196
 
@@ -115,24 +203,119 @@ The module implements a hoisting pattern where the authentication provider is cr
115
203
 
116
204
  ## Migration Guide
117
205
 
118
- ### Version 4 Breaking Changes
206
+ ### MSAL v2 to v4 Migration
207
+
208
+ This package has been upgraded from MSAL Browser v2 to v4, providing the latest security improvements and features from Microsoft.
209
+
210
+ #### What Changed in v4
211
+
212
+ **New MSAL Browser v4 Features:**
213
+ - Enhanced security with improved token management
214
+ - Better performance and memory usage
215
+ - New authentication API structure with nested request objects
216
+ - Improved error handling and retry mechanisms
217
+
218
+ **Architecture Changes:**
219
+ - **Module Hoisting**: The module uses module hoisting, meaning sub-module instances proxy the parent module instance
220
+ - **Shared Authentication State**: Authentication state is shared across all module instances
221
+ - **Async Initialization**: New `initialize()` method must be called before using the provider
222
+
223
+ #### Breaking Changes
119
224
 
120
- **Module Hoisting**: The module now uses module hoisting, meaning sub-module instances proxy the parent module instance. This creates a shared authentication state across all module instances.
225
+ 1. **Auto-initialization via Framework**
226
+ ```typescript
227
+ // The provider initializes automatically when framework loads
228
+ const framework = await initialize(configurator);
229
+ const auth = framework.auth; // Already initialized
230
+
231
+ // Manual initialization is only needed for standalone usage
232
+ const provider = new MsalProvider(config);
233
+ await provider.initialize();
234
+ ```
121
235
 
122
- **Removed Multi-Client Support**: This version no longer supports multiple MSAL clients (multi-tenant, multi-authority) in the same scoped instance due to how `@azure/msal-browser` uses a shared cache.
236
+ 2. **API Method Signature Updates**
237
+ - `logout()` now returns `Promise<boolean>` instead of `Promise<void>`
238
+ - `handleRedirect()` now returns `Promise<AuthenticationResult | null>` instead of `Promise<void>`
239
+ - Methods now expect nested request objects (v4 format)
123
240
 
124
- **Benefits of V4**:
125
- - Shared authentication state across application scopes
126
- - Improved performance and memory usage
127
- - Simplified configuration management
128
- - Better integration with Fusion Framework architecture
241
+ 3. **Account Property Changes**
242
+ - Use `account` property (returns `AccountInfo | null`) - v4 native
243
+ - `defaultAccount` is deprecated and only available via v2 proxy layer
244
+ - Migration: Replace `defaultAccount` with `account` throughout your code
129
245
 
130
246
  #### Migration Steps
131
247
 
132
- 1. **Update Configuration**: Ensure only the root module configures MSAL
133
- 2. **Remove Duplicate Configurations**: Remove MSAL configuration from child modules
134
- 3. **Update Authentication Logic**: Rely on shared authentication state
135
- 4. **Test Multi-Scope Applications**: Verify authentication works across different application scopes
248
+ 1. **Update Token Acquisition** (Recommended)
249
+ ```typescript
250
+ // Before (v2 format - still works via proxy)
251
+ const token = await framework.auth.acquireAccessToken({
252
+ scopes: ['api.read']
253
+ });
254
+
255
+ // After (v4 format - recommended)
256
+ const token = await framework.auth.acquireAccessToken({
257
+ request: { scopes: ['api.read'] }
258
+ });
259
+ ```
260
+
261
+ 2. **Update Logout Handling**
262
+ ```typescript
263
+ // Before
264
+ await framework.auth.logout();
265
+
266
+ // After (check return value)
267
+ const success = await framework.auth.logout();
268
+ if (success) {
269
+ // Handle successful logout
270
+ }
271
+ ```
272
+
273
+ 3. **Update Redirect Handling**
274
+ ```typescript
275
+ // Before
276
+ await framework.auth.handleRedirect();
277
+
278
+ // After (handle result)
279
+ const result = await framework.auth.handleRedirect();
280
+ if (result?.account) {
281
+ // User authenticated successfully
282
+ console.log('Logged in as:', result.account.username);
283
+ }
284
+ ```
285
+
286
+ 4. **Update Configuration** (if needed)
287
+ ```typescript
288
+ // Ensure only the root module configures MSAL
289
+ enableMSAL(configurator, (builder) => {
290
+ builder.setClientConfig({
291
+ auth: {
292
+ clientId: 'your-client-id',
293
+ tenantId: 'your-tenant-id',
294
+ redirectUri: 'https://your-app.com/callback'
295
+ }
296
+ });
297
+ builder.setRequiresAuth(true);
298
+ });
299
+ ```
300
+
301
+ 5. **Remove Duplicate Configurations**: Remove MSAL configuration from child modules
302
+
303
+ #### Backward Compatibility
304
+
305
+ The module includes a **v2 proxy layer** that automatically converts v2 API calls to v4 format. This means:
306
+ - ✅ Existing code continues to work without changes
307
+ - ✅ Legacy format `{ scopes: [] }` is still supported
308
+ - ✅ Deprecated v2 properties like `defaultAccount` are available via v2 proxy (with deprecation warnings)
309
+ - ⚠️ New v4 features require using v4 format
310
+
311
+ #### Benefits of Migration
312
+
313
+ - **Better Security**: Latest MSAL v4 security improvements and token handling
314
+ - **Improved Performance**: Faster token acquisition, better caching, reduced memory usage
315
+ - **Enhanced Error Handling**: More robust error recovery and retry mechanisms
316
+ - **Future-Proof**: Access to latest Microsoft authentication features and updates
317
+ - **Shared State**: Improved authentication state management across app scopes via module hoisting
318
+ - **Better Developer Experience**: Cleaner API, better TypeScript support, comprehensive documentation
136
319
 
137
320
  ## Troubleshooting
138
321
 
@@ -144,6 +327,8 @@ The module implements a hoisting pattern where the authentication provider is cr
144
327
  | **Token Acquisition Fails** | Check that required scopes are properly configured |
145
328
  | **Module Not Found** | Ensure the module is properly configured and framework is initialized |
146
329
  | **Multiple MSAL Instances** | Remove duplicate configurations from child modules |
330
+ | **Redirect Returns Void** | For redirect flows, use `handleRedirect()` after navigation completes |
331
+ | **Token Empty/Undefined** | Verify user is authenticated and scopes are correct |
147
332
 
148
333
  ### Getting Help
149
334
 
@@ -220,10 +405,22 @@ try {
220
405
 
221
406
  ## Additional Resources
222
407
 
223
- - [Microsoft Graph API Documentation](https://docs.microsoft.com/en-us/graph/)
224
- - [Azure AD App Registration Guide](https://docs.microsoft.com/en-us/azure/active-directory/develop/quickstart-register-app)
225
- - [MSAL Browser Documentation](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/lib/msal-browser)
226
- - [Fusion Framework Documentation](https://github.com/equinor/fusion-framework)
408
+ ### Official Documentation
409
+ - 🔐 [Azure AD App Registration Guide](https://docs.microsoft.com/en-us/azure/active-directory/develop/quickstart-register-app)
410
+ - 📚 [MSAL Browser Documentation](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/lib/msal-browser)
411
+ - 🏗️ [Fusion Framework Documentation](https://github.com/equinor/fusion-framework)
412
+ - 🌐 [Microsoft Identity Platform Overview](https://docs.microsoft.com/en-us/azure/active-directory/develop/)
413
+
414
+ ### Learning Resources
415
+ - 📖 [MSAL Cookbook Examples](https://github.com/equinor/fusion-framework/tree/main/cookbooks/app-react-msal)
416
+ - 🎯 [OAuth 2.0 Scopes Explained](https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-permissions-and-consent)
417
+ - 🛠️ [MSAL Troubleshooting Guide](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/docs/errors.md)
418
+ - 📖 [Azure AD API Permissions Guide](https://docs.microsoft.com/en-us/azure/active-directory/develop/scenario-protected-web-api-app-registration)
419
+
420
+ ### Support
421
+ - 💬 For questions: [Fusion Framework Discussions](https://github.com/equinor/fusion-framework/discussions)
422
+ - 🐛 Report bugs: [Fusion Framework Issues](https://github.com/equinor/fusion-framework/issues)
423
+ - 📧 Contact: Equinor Fusion Framework Team
227
424
 
228
425
 
229
426
 
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=MsalClient.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MsalClient.interface.js","sourceRoot":"","sources":["../../src/MsalClient.interface.ts"],"names":[],"mappings":""}