@azure/msal-browser 4.8.0 → 4.9.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 (204) hide show
  1. package/dist/app/IPublicClientApplication.mjs +1 -1
  2. package/dist/app/PublicClientApplication.mjs +1 -1
  3. package/dist/app/PublicClientNext.mjs +1 -1
  4. package/dist/broker/nativeBroker/NativeMessageHandler.mjs +1 -1
  5. package/dist/broker/nativeBroker/NativeStatusCodes.mjs +1 -1
  6. package/dist/cache/AccountManager.mjs +1 -1
  7. package/dist/cache/AsyncMemoryStorage.mjs +1 -1
  8. package/dist/cache/BrowserCacheManager.d.ts +4 -41
  9. package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
  10. package/dist/cache/BrowserCacheManager.mjs +18 -143
  11. package/dist/cache/BrowserCacheManager.mjs.map +1 -1
  12. package/dist/cache/CacheHelpers.mjs +1 -1
  13. package/dist/cache/CookieStorage.mjs +1 -1
  14. package/dist/cache/DatabaseStorage.mjs +1 -1
  15. package/dist/cache/LocalStorage.mjs +1 -1
  16. package/dist/cache/MemoryStorage.mjs +1 -1
  17. package/dist/cache/SessionStorage.mjs +1 -1
  18. package/dist/cache/TokenCache.mjs +1 -1
  19. package/dist/config/Configuration.d.ts.map +1 -1
  20. package/dist/config/Configuration.mjs +12 -3
  21. package/dist/config/Configuration.mjs.map +1 -1
  22. package/dist/controllers/ControllerFactory.mjs +1 -1
  23. package/dist/controllers/NestedAppAuthController.d.ts +2 -2
  24. package/dist/controllers/NestedAppAuthController.d.ts.map +1 -1
  25. package/dist/controllers/NestedAppAuthController.mjs +1 -1
  26. package/dist/controllers/NestedAppAuthController.mjs.map +1 -1
  27. package/dist/controllers/StandardController.d.ts.map +1 -1
  28. package/dist/controllers/StandardController.mjs +28 -16
  29. package/dist/controllers/StandardController.mjs.map +1 -1
  30. package/dist/controllers/UnknownOperatingContextController.d.ts +2 -2
  31. package/dist/controllers/UnknownOperatingContextController.d.ts.map +1 -1
  32. package/dist/controllers/UnknownOperatingContextController.mjs +1 -1
  33. package/dist/controllers/UnknownOperatingContextController.mjs.map +1 -1
  34. package/dist/crypto/BrowserCrypto.d.ts +11 -0
  35. package/dist/crypto/BrowserCrypto.d.ts.map +1 -1
  36. package/dist/crypto/BrowserCrypto.mjs +68 -5
  37. package/dist/crypto/BrowserCrypto.mjs.map +1 -1
  38. package/dist/crypto/CryptoOps.mjs +1 -1
  39. package/dist/crypto/PkceGenerator.mjs +1 -1
  40. package/dist/crypto/SignedHttpRequest.mjs +1 -1
  41. package/dist/encode/Base64Decode.mjs +1 -1
  42. package/dist/encode/Base64Encode.mjs +1 -1
  43. package/dist/error/BrowserAuthError.d.ts +3 -5
  44. package/dist/error/BrowserAuthError.d.ts.map +1 -1
  45. package/dist/error/BrowserAuthError.mjs +5 -7
  46. package/dist/error/BrowserAuthError.mjs.map +1 -1
  47. package/dist/error/BrowserAuthErrorCodes.d.ts +3 -1
  48. package/dist/error/BrowserAuthErrorCodes.d.ts.map +1 -1
  49. package/dist/error/BrowserAuthErrorCodes.mjs +6 -4
  50. package/dist/error/BrowserAuthErrorCodes.mjs.map +1 -1
  51. package/dist/error/BrowserConfigurationAuthError.mjs +1 -1
  52. package/dist/error/BrowserConfigurationAuthErrorCodes.mjs +1 -1
  53. package/dist/error/NativeAuthError.mjs +1 -1
  54. package/dist/error/NativeAuthErrorCodes.mjs +1 -1
  55. package/dist/error/NestedAppAuthError.mjs +1 -1
  56. package/dist/event/EventHandler.mjs +1 -1
  57. package/dist/event/EventMessage.mjs +1 -1
  58. package/dist/event/EventType.mjs +1 -1
  59. package/dist/index.mjs +1 -1
  60. package/dist/interaction_client/BaseInteractionClient.mjs +1 -1
  61. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
  62. package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
  63. package/dist/interaction_client/NativeInteractionClient.mjs +1 -3
  64. package/dist/interaction_client/NativeInteractionClient.mjs.map +1 -1
  65. package/dist/interaction_client/PopupClient.d.ts +14 -1
  66. package/dist/interaction_client/PopupClient.d.ts.map +1 -1
  67. package/dist/interaction_client/PopupClient.mjs +65 -64
  68. package/dist/interaction_client/PopupClient.mjs.map +1 -1
  69. package/dist/interaction_client/RedirectClient.d.ts +20 -3
  70. package/dist/interaction_client/RedirectClient.d.ts.map +1 -1
  71. package/dist/interaction_client/RedirectClient.mjs +132 -76
  72. package/dist/interaction_client/RedirectClient.mjs.map +1 -1
  73. package/dist/interaction_client/SilentAuthCodeClient.d.ts.map +1 -1
  74. package/dist/interaction_client/SilentAuthCodeClient.mjs +1 -1
  75. package/dist/interaction_client/SilentAuthCodeClient.mjs.map +1 -1
  76. package/dist/interaction_client/SilentCacheClient.mjs +1 -1
  77. package/dist/interaction_client/SilentIframeClient.d.ts +13 -3
  78. package/dist/interaction_client/SilentIframeClient.d.ts.map +1 -1
  79. package/dist/interaction_client/SilentIframeClient.mjs +57 -44
  80. package/dist/interaction_client/SilentIframeClient.mjs.map +1 -1
  81. package/dist/interaction_client/SilentRefreshClient.mjs +1 -1
  82. package/dist/interaction_client/StandardInteractionClient.d.ts +2 -3
  83. package/dist/interaction_client/StandardInteractionClient.d.ts.map +1 -1
  84. package/dist/interaction_client/StandardInteractionClient.mjs +1 -1
  85. package/dist/interaction_client/StandardInteractionClient.mjs.map +1 -1
  86. package/dist/interaction_handler/InteractionHandler.d.ts +4 -5
  87. package/dist/interaction_handler/InteractionHandler.d.ts.map +1 -1
  88. package/dist/interaction_handler/InteractionHandler.mjs +1 -1
  89. package/dist/interaction_handler/InteractionHandler.mjs.map +1 -1
  90. package/dist/interaction_handler/SilentHandler.d.ts +4 -2
  91. package/dist/interaction_handler/SilentHandler.d.ts.map +1 -1
  92. package/dist/interaction_handler/SilentHandler.mjs +13 -3
  93. package/dist/interaction_handler/SilentHandler.mjs.map +1 -1
  94. package/dist/naa/BridgeError.mjs +1 -1
  95. package/dist/naa/BridgeProxy.mjs +1 -1
  96. package/dist/naa/BridgeStatusCode.mjs +1 -1
  97. package/dist/naa/mapping/NestedAppAuthAdapter.mjs +1 -1
  98. package/dist/navigation/NavigationClient.mjs +1 -1
  99. package/dist/network/FetchClient.mjs +1 -1
  100. package/dist/operatingcontext/BaseOperatingContext.mjs +1 -1
  101. package/dist/operatingcontext/NestedAppOperatingContext.mjs +1 -1
  102. package/dist/operatingcontext/StandardOperatingContext.mjs +1 -1
  103. package/dist/operatingcontext/UnknownOperatingContext.mjs +1 -1
  104. package/dist/packageMetadata.d.ts +1 -1
  105. package/dist/packageMetadata.mjs +2 -2
  106. package/dist/protocol/Authorize.d.ts +53 -1
  107. package/dist/protocol/Authorize.d.ts.map +1 -1
  108. package/dist/protocol/Authorize.mjs +147 -4
  109. package/dist/protocol/Authorize.mjs.map +1 -1
  110. package/dist/request/AuthorizationUrlRequest.d.ts +2 -4
  111. package/dist/request/AuthorizationUrlRequest.d.ts.map +1 -1
  112. package/dist/request/PopupRequest.d.ts +1 -1
  113. package/dist/request/PopupRequest.d.ts.map +1 -1
  114. package/dist/request/RedirectRequest.d.ts +1 -1
  115. package/dist/request/RedirectRequest.d.ts.map +1 -1
  116. package/dist/request/RequestHelpers.mjs +1 -1
  117. package/dist/request/SsoSilentRequest.d.ts +1 -1
  118. package/dist/request/SsoSilentRequest.d.ts.map +1 -1
  119. package/dist/response/ResponseHandler.mjs +1 -1
  120. package/dist/telemetry/BrowserPerformanceClient.mjs +1 -1
  121. package/dist/telemetry/BrowserPerformanceMeasurement.mjs +1 -1
  122. package/dist/utils/BrowserConstants.d.ts +1 -10
  123. package/dist/utils/BrowserConstants.d.ts.map +1 -1
  124. package/dist/utils/BrowserConstants.mjs +2 -11
  125. package/dist/utils/BrowserConstants.mjs.map +1 -1
  126. package/dist/utils/BrowserProtocolUtils.mjs +1 -1
  127. package/dist/utils/BrowserUtils.mjs +1 -1
  128. package/lib/msal-browser.cjs +1595 -1514
  129. package/lib/msal-browser.cjs.map +1 -1
  130. package/lib/msal-browser.js +1595 -1514
  131. package/lib/msal-browser.js.map +1 -1
  132. package/lib/msal-browser.min.js +68 -67
  133. package/lib/types/cache/BrowserCacheManager.d.ts +4 -41
  134. package/lib/types/cache/BrowserCacheManager.d.ts.map +1 -1
  135. package/lib/types/config/Configuration.d.ts.map +1 -1
  136. package/lib/types/controllers/NestedAppAuthController.d.ts +2 -2
  137. package/lib/types/controllers/NestedAppAuthController.d.ts.map +1 -1
  138. package/lib/types/controllers/StandardController.d.ts.map +1 -1
  139. package/lib/types/controllers/UnknownOperatingContextController.d.ts +2 -2
  140. package/lib/types/controllers/UnknownOperatingContextController.d.ts.map +1 -1
  141. package/lib/types/crypto/BrowserCrypto.d.ts +11 -0
  142. package/lib/types/crypto/BrowserCrypto.d.ts.map +1 -1
  143. package/lib/types/error/BrowserAuthError.d.ts +3 -5
  144. package/lib/types/error/BrowserAuthError.d.ts.map +1 -1
  145. package/lib/types/error/BrowserAuthErrorCodes.d.ts +3 -1
  146. package/lib/types/error/BrowserAuthErrorCodes.d.ts.map +1 -1
  147. package/lib/types/interaction_client/NativeInteractionClient.d.ts.map +1 -1
  148. package/lib/types/interaction_client/PopupClient.d.ts +14 -1
  149. package/lib/types/interaction_client/PopupClient.d.ts.map +1 -1
  150. package/lib/types/interaction_client/RedirectClient.d.ts +20 -3
  151. package/lib/types/interaction_client/RedirectClient.d.ts.map +1 -1
  152. package/lib/types/interaction_client/SilentAuthCodeClient.d.ts.map +1 -1
  153. package/lib/types/interaction_client/SilentIframeClient.d.ts +13 -3
  154. package/lib/types/interaction_client/SilentIframeClient.d.ts.map +1 -1
  155. package/lib/types/interaction_client/StandardInteractionClient.d.ts +2 -3
  156. package/lib/types/interaction_client/StandardInteractionClient.d.ts.map +1 -1
  157. package/lib/types/interaction_handler/InteractionHandler.d.ts +4 -5
  158. package/lib/types/interaction_handler/InteractionHandler.d.ts.map +1 -1
  159. package/lib/types/interaction_handler/SilentHandler.d.ts +4 -2
  160. package/lib/types/interaction_handler/SilentHandler.d.ts.map +1 -1
  161. package/lib/types/packageMetadata.d.ts +1 -1
  162. package/lib/types/protocol/Authorize.d.ts +53 -1
  163. package/lib/types/protocol/Authorize.d.ts.map +1 -1
  164. package/lib/types/request/AuthorizationUrlRequest.d.ts +2 -4
  165. package/lib/types/request/AuthorizationUrlRequest.d.ts.map +1 -1
  166. package/lib/types/request/PopupRequest.d.ts +1 -1
  167. package/lib/types/request/PopupRequest.d.ts.map +1 -1
  168. package/lib/types/request/RedirectRequest.d.ts +1 -1
  169. package/lib/types/request/RedirectRequest.d.ts.map +1 -1
  170. package/lib/types/request/SsoSilentRequest.d.ts +1 -1
  171. package/lib/types/request/SsoSilentRequest.d.ts.map +1 -1
  172. package/lib/types/utils/BrowserConstants.d.ts +1 -10
  173. package/lib/types/utils/BrowserConstants.d.ts.map +1 -1
  174. package/package.json +2 -2
  175. package/src/cache/BrowserCacheManager.ts +30 -205
  176. package/src/config/Configuration.ts +14 -2
  177. package/src/controllers/NestedAppAuthController.ts +2 -0
  178. package/src/controllers/StandardController.ts +35 -24
  179. package/src/controllers/UnknownOperatingContextController.ts +2 -0
  180. package/src/crypto/BrowserCrypto.ts +91 -2
  181. package/src/error/BrowserAuthError.ts +6 -8
  182. package/src/error/BrowserAuthErrorCodes.ts +3 -1
  183. package/src/interaction_client/NativeInteractionClient.ts +0 -2
  184. package/src/interaction_client/PopupClient.ts +163 -119
  185. package/src/interaction_client/RedirectClient.ts +258 -140
  186. package/src/interaction_client/SilentAuthCodeClient.ts +2 -2
  187. package/src/interaction_client/SilentIframeClient.ts +154 -99
  188. package/src/interaction_client/StandardInteractionClient.ts +3 -3
  189. package/src/interaction_handler/InteractionHandler.ts +4 -4
  190. package/src/interaction_handler/SilentHandler.ts +31 -2
  191. package/src/packageMetadata.ts +1 -1
  192. package/src/protocol/Authorize.ts +356 -2
  193. package/src/request/AuthorizationUrlRequest.ts +3 -5
  194. package/src/request/PopupRequest.ts +1 -0
  195. package/src/request/RedirectRequest.ts +1 -0
  196. package/src/request/SsoSilentRequest.ts +1 -0
  197. package/src/utils/BrowserConstants.ts +1 -10
  198. package/dist/interaction_handler/RedirectHandler.d.ts +0 -33
  199. package/dist/interaction_handler/RedirectHandler.d.ts.map +0 -1
  200. package/dist/interaction_handler/RedirectHandler.mjs +0 -144
  201. package/dist/interaction_handler/RedirectHandler.mjs.map +0 -1
  202. package/lib/types/interaction_handler/RedirectHandler.d.ts +0 -33
  203. package/lib/types/interaction_handler/RedirectHandler.d.ts.map +0 -1
  204. package/src/interaction_handler/RedirectHandler.ts +0 -252
@@ -4,14 +4,11 @@
4
4
  */
5
5
 
6
6
  import {
7
- CommonAuthorizationCodeRequest,
8
7
  AuthorizationCodeClient,
9
- ThrottlingUtils,
10
8
  CommonEndSessionRequest,
11
9
  UrlString,
12
10
  AuthError,
13
11
  OIDC_DEFAULT_SCOPES,
14
- ProtocolUtils,
15
12
  PerformanceEvents,
16
13
  IPerformanceClient,
17
14
  Logger,
@@ -21,6 +18,7 @@ import {
21
18
  invokeAsync,
22
19
  invoke,
23
20
  PkceCodes,
21
+ CommonAuthorizationUrlRequest,
24
22
  } from "@azure/msal-common/browser";
25
23
  import { StandardInteractionClient } from "./StandardInteractionClient.js";
26
24
  import { EventType } from "../event/EventType.js";
@@ -33,7 +31,6 @@ import { EndSessionPopupRequest } from "../request/EndSessionPopupRequest.js";
33
31
  import { NavigationOptions } from "../navigation/NavigationOptions.js";
34
32
  import * as BrowserUtils from "../utils/BrowserUtils.js";
35
33
  import { PopupRequest } from "../request/PopupRequest.js";
36
- import { NativeInteractionClient } from "./NativeInteractionClient.js";
37
34
  import { NativeMessageHandler } from "../broker/nativeBroker/NativeMessageHandler.js";
38
35
  import {
39
36
  createBrowserAuthError,
@@ -43,13 +40,13 @@ import { INavigationClient } from "../navigation/INavigationClient.js";
43
40
  import { EventHandler } from "../event/EventHandler.js";
44
41
  import { BrowserCacheManager } from "../cache/BrowserCacheManager.js";
45
42
  import { BrowserConfiguration } from "../config/Configuration.js";
46
- import { InteractionHandler } from "../interaction_handler/InteractionHandler.js";
47
43
  import { PopupWindowAttributes } from "../request/PopupWindowAttributes.js";
48
44
  import { EventError } from "../event/EventMessage.js";
49
45
  import { AuthenticationResult } from "../response/AuthenticationResult.js";
50
46
  import * as ResponseHandler from "../response/ResponseHandler.js";
51
- import { getAuthCodeRequestUrl } from "../protocol/Authorize.js";
47
+ import * as Authorize from "../protocol/Authorize.js";
52
48
  import { generatePkceCodes } from "../crypto/PkceGenerator.js";
49
+ import { generateEarKey } from "../crypto/BrowserCrypto.js";
53
50
 
54
51
  export type PopupParams = {
55
52
  popup?: Window | null;
@@ -88,6 +85,7 @@ export class PopupClient extends StandardInteractionClient {
88
85
  // Properly sets this reference for the unload event.
89
86
  this.unloadWindow = this.unloadWindow.bind(this);
90
87
  this.nativeStorage = nativeStorageImpl;
88
+ this.eventHandler = eventHandler;
91
89
  }
92
90
 
93
91
  /**
@@ -207,9 +205,6 @@ export class PopupClient extends StandardInteractionClient {
207
205
  pkceCodes?: PkceCodes
208
206
  ): Promise<AuthenticationResult> {
209
207
  this.logger.verbose("acquireTokenPopupAsync called");
210
- const serverTelemetryManager = this.initializeServerTelemetryManager(
211
- ApiId.acquireTokenPopup
212
- );
213
208
 
214
209
  const validRequest = await invokeAsync(
215
210
  this.initializeAuthorizationRequest.bind(this),
@@ -219,6 +214,46 @@ export class PopupClient extends StandardInteractionClient {
219
214
  this.correlationId
220
215
  )(request, InteractionType.Popup);
221
216
 
217
+ /*
218
+ * Skip pre-connect for async popups to reduce time between user interaction and popup window creation to avoid
219
+ * popup from being blocked by browsers with shorter popup timers
220
+ */
221
+ if (popupParams.popup) {
222
+ BrowserUtils.preconnect(validRequest.authority);
223
+ }
224
+
225
+ const isPlatformBroker = NativeMessageHandler.isPlatformBrokerAvailable(
226
+ this.config,
227
+ this.logger,
228
+ this.nativeMessageHandler,
229
+ request.authenticationScheme
230
+ );
231
+ validRequest.platformBroker = isPlatformBroker;
232
+
233
+ if (this.config.auth.protocolMode === ProtocolMode.EAR) {
234
+ return this.executeEarFlow(validRequest, popupParams);
235
+ } else {
236
+ return this.executeCodeFlow(validRequest, popupParams, pkceCodes);
237
+ }
238
+ }
239
+
240
+ /**
241
+ * Executes auth code + PKCE flow
242
+ * @param request
243
+ * @param popupParams
244
+ * @param pkceCodes
245
+ * @returns
246
+ */
247
+ async executeCodeFlow(
248
+ request: CommonAuthorizationUrlRequest,
249
+ popupParams: PopupParams,
250
+ pkceCodes?: PkceCodes
251
+ ): Promise<AuthenticationResult> {
252
+ const correlationId = request.correlationId;
253
+ const serverTelemetryManager = this.initializeServerTelemetryManager(
254
+ ApiId.acquireTokenPopup
255
+ );
256
+
222
257
  const pkce =
223
258
  pkceCodes ||
224
259
  (await invokeAsync(
@@ -226,17 +261,13 @@ export class PopupClient extends StandardInteractionClient {
226
261
  PerformanceEvents.GeneratePkceCodes,
227
262
  this.logger,
228
263
  this.performanceClient,
229
- this.correlationId
230
- )(this.performanceClient, this.logger, this.correlationId));
231
- validRequest.codeChallenge = pkce.challenge;
264
+ correlationId
265
+ )(this.performanceClient, this.logger, correlationId));
232
266
 
233
- /*
234
- * Skip pre-connect for async popups to reduce time between user interaction and popup window creation to avoid
235
- * popup from being blocked by browsers with shorter popup timers
236
- */
237
- if (popupParams.popup) {
238
- BrowserUtils.preconnect(validRequest.authority);
239
- }
267
+ const popupRequest = {
268
+ ...request,
269
+ codeChallenge: pkce.challenge,
270
+ };
240
271
 
241
272
  try {
242
273
  // Initialize the client
@@ -245,46 +276,26 @@ export class PopupClient extends StandardInteractionClient {
245
276
  PerformanceEvents.StandardInteractionClientCreateAuthCodeClient,
246
277
  this.logger,
247
278
  this.performanceClient,
248
- this.correlationId
279
+ correlationId
249
280
  )({
250
281
  serverTelemetryManager,
251
- requestAuthority: validRequest.authority,
252
- requestAzureCloudOptions: validRequest.azureCloudOptions,
253
- requestExtraQueryParameters: validRequest.extraQueryParameters,
254
- account: validRequest.account,
282
+ requestAuthority: popupRequest.authority,
283
+ requestAzureCloudOptions: popupRequest.azureCloudOptions,
284
+ requestExtraQueryParameters: popupRequest.extraQueryParameters,
285
+ account: popupRequest.account,
255
286
  });
256
287
 
257
- const isPlatformBroker =
258
- NativeMessageHandler.isPlatformBrokerAvailable(
259
- this.config,
260
- this.logger,
261
- this.nativeMessageHandler,
262
- request.authenticationScheme
263
- );
264
- // Start measurement for server calls with native brokering enabled
265
- let fetchNativeAccountIdMeasurement;
266
- if (isPlatformBroker) {
267
- fetchNativeAccountIdMeasurement =
268
- this.performanceClient.startMeasurement(
269
- PerformanceEvents.FetchAccountIdWithNativeBroker,
270
- request.correlationId
271
- );
272
- }
273
-
274
288
  // Create acquire token url.
275
289
  const navigateUrl = await invokeAsync(
276
- getAuthCodeRequestUrl,
290
+ Authorize.getAuthCodeRequestUrl,
277
291
  PerformanceEvents.GetAuthCodeUrl,
278
292
  this.logger,
279
293
  this.performanceClient,
280
- validRequest.correlationId
294
+ correlationId
281
295
  )(
282
296
  this.config,
283
297
  authClient.authority,
284
- {
285
- ...validRequest,
286
- platformBroker: isPlatformBroker,
287
- },
298
+ popupRequest,
288
299
  this.logger,
289
300
  this.performanceClient
290
301
  );
@@ -318,75 +329,27 @@ export class PopupClient extends StandardInteractionClient {
318
329
  this.config.auth.OIDCOptions.serverResponseType,
319
330
  this.logger
320
331
  );
321
- // Remove throttle if it exists
322
- ThrottlingUtils.removeThrottle(
323
- this.browserStorage,
324
- this.config.auth.clientId,
325
- validRequest
326
- );
327
-
328
- if (serverParams.accountId) {
329
- this.logger.verbose(
330
- "Account id found in hash, calling WAM for token"
331
- );
332
- // end measurement for server call with native brokering enabled
333
- if (fetchNativeAccountIdMeasurement) {
334
- fetchNativeAccountIdMeasurement.end({
335
- success: true,
336
- isNativeBroker: true,
337
- });
338
- }
339
-
340
- if (!this.nativeMessageHandler) {
341
- throw createBrowserAuthError(
342
- BrowserAuthErrorCodes.nativeConnectionNotEstablished
343
- );
344
- }
345
- const nativeInteractionClient = new NativeInteractionClient(
346
- this.config,
347
- this.browserStorage,
348
- this.browserCrypto,
349
- this.logger,
350
- this.eventHandler,
351
- this.navigationClient,
352
- ApiId.acquireTokenPopup,
353
- this.performanceClient,
354
- this.nativeMessageHandler,
355
- serverParams.accountId,
356
- this.nativeStorage,
357
- validRequest.correlationId
358
- );
359
- const { userRequestState } = ProtocolUtils.parseRequestState(
360
- this.browserCrypto,
361
- validRequest.state
362
- );
363
- return await nativeInteractionClient.acquireToken({
364
- ...validRequest,
365
- state: userRequestState,
366
- prompt: undefined, // Server should handle the prompt, ideally native broker can do this part silently
367
- });
368
- }
369
332
 
370
- const authCodeRequest: CommonAuthorizationCodeRequest = {
371
- ...validRequest,
372
- code: serverParams.code || "",
373
- codeVerifier: pkce.verifier,
374
- };
375
- // Create popup interaction handler.
376
- const interactionHandler = new InteractionHandler(
333
+ return await invokeAsync(
334
+ Authorize.handleResponseCode,
335
+ PerformanceEvents.HandleResponseCode,
336
+ this.logger,
337
+ this.performanceClient,
338
+ correlationId
339
+ )(
340
+ request,
341
+ serverParams,
342
+ pkce.verifier,
343
+ ApiId.acquireTokenPopup,
344
+ this.config,
377
345
  authClient,
378
346
  this.browserStorage,
379
- authCodeRequest,
347
+ this.nativeStorage,
348
+ this.eventHandler,
380
349
  this.logger,
381
- this.performanceClient
382
- );
383
- // Handle response from hash string.
384
- const result = await interactionHandler.handleCodeResponse(
385
- serverParams,
386
- validRequest
350
+ this.performanceClient,
351
+ this.nativeMessageHandler
387
352
  );
388
-
389
- return result;
390
353
  } catch (e) {
391
354
  // Close the synchronous popup if an error is thrown before the window unload event is registered
392
355
  popupParams.popup?.close();
@@ -399,6 +362,95 @@ export class PopupClient extends StandardInteractionClient {
399
362
  }
400
363
  }
401
364
 
365
+ /**
366
+ * Executes EAR flow
367
+ * @param request
368
+ */
369
+ async executeEarFlow(
370
+ request: CommonAuthorizationUrlRequest,
371
+ popupParams: PopupParams
372
+ ): Promise<AuthenticationResult> {
373
+ const correlationId = request.correlationId;
374
+ // Get the frame handle for the silent request
375
+ const discoveredAuthority = await invokeAsync(
376
+ this.getDiscoveredAuthority.bind(this),
377
+ PerformanceEvents.StandardInteractionClientGetDiscoveredAuthority,
378
+ this.logger,
379
+ this.performanceClient,
380
+ correlationId
381
+ )({
382
+ requestAuthority: request.authority,
383
+ requestAzureCloudOptions: request.azureCloudOptions,
384
+ requestExtraQueryParameters: request.extraQueryParameters,
385
+ account: request.account,
386
+ });
387
+
388
+ const earJwk = await invokeAsync(
389
+ generateEarKey,
390
+ PerformanceEvents.GenerateEarKey,
391
+ this.logger,
392
+ this.performanceClient,
393
+ correlationId
394
+ )();
395
+ const popupRequest = {
396
+ ...request,
397
+ earJwk: earJwk,
398
+ };
399
+ const popupWindow =
400
+ popupParams.popup || this.openPopup("about:blank", popupParams);
401
+
402
+ const form = await Authorize.getEARForm(
403
+ popupWindow.document,
404
+ this.config,
405
+ discoveredAuthority,
406
+ popupRequest,
407
+ this.logger,
408
+ this.performanceClient
409
+ );
410
+ form.submit();
411
+
412
+ // Monitor the popup for the hash. Return the string value and close the popup when the hash is received. Default timeout is 60 seconds.
413
+ const responseString = await invokeAsync(
414
+ this.monitorPopupForHash.bind(this),
415
+ PerformanceEvents.SilentHandlerMonitorIframeForHash,
416
+ this.logger,
417
+ this.performanceClient,
418
+ correlationId
419
+ )(popupWindow, popupParams.popupWindowParent);
420
+
421
+ const serverParams = invoke(
422
+ ResponseHandler.deserializeResponse,
423
+ PerformanceEvents.DeserializeResponse,
424
+ this.logger,
425
+ this.performanceClient,
426
+ this.correlationId
427
+ )(
428
+ responseString,
429
+ this.config.auth.OIDCOptions.serverResponseType,
430
+ this.logger
431
+ );
432
+
433
+ return invokeAsync(
434
+ Authorize.handleResponseEAR,
435
+ PerformanceEvents.HandleResponseEar,
436
+ this.logger,
437
+ this.performanceClient,
438
+ correlationId
439
+ )(
440
+ popupRequest,
441
+ serverParams,
442
+ ApiId.acquireTokenPopup,
443
+ this.config,
444
+ discoveredAuthority,
445
+ this.browserStorage,
446
+ this.nativeStorage,
447
+ this.eventHandler,
448
+ this.logger,
449
+ this.performanceClient,
450
+ this.nativeMessageHandler
451
+ );
452
+ }
453
+
402
454
  /**
403
455
  *
404
456
  * @param validRequest
@@ -540,7 +592,6 @@ export class PopupClient extends StandardInteractionClient {
540
592
  (e as AuthError).setCorrelationId(this.correlationId);
541
593
  serverTelemetryManager.cacheFailedRequest(e);
542
594
  }
543
- this.browserStorage.setInteractionInProgress(false);
544
595
  this.eventHandler.emitEvent(
545
596
  EventType.LOGOUT_FAILURE,
546
597
  InteractionType.Popup,
@@ -697,7 +748,6 @@ export class PopupClient extends StandardInteractionClient {
697
748
  this.logger.error(
698
749
  "error opening popup " + (e as AuthError).message
699
750
  );
700
- this.browserStorage.setInteractionInProgress(false);
701
751
  throw createBrowserAuthError(
702
752
  BrowserAuthErrorCodes.popupWindowError
703
753
  );
@@ -788,9 +838,6 @@ export class PopupClient extends StandardInteractionClient {
788
838
  * Event callback to unload main window.
789
839
  */
790
840
  unloadWindow(e: Event): void {
791
- this.browserStorage.cleanRequestByInteractionType(
792
- InteractionType.Popup
793
- );
794
841
  if (this.currentWindow) {
795
842
  this.currentWindow.close();
796
843
  }
@@ -811,9 +858,6 @@ export class PopupClient extends StandardInteractionClient {
811
858
  "beforeunload",
812
859
  this.unloadWindow
813
860
  );
814
-
815
- // Interaction is completed - remove interaction status.
816
- this.browserStorage.setInteractionInProgress(false);
817
861
  }
818
862
 
819
863
  /**