@azure/msal-browser 3.21.0 → 3.22.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 (109) 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 +0 -25
  9. package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
  10. package/dist/cache/BrowserCacheManager.mjs +1 -71
  11. package/dist/cache/BrowserCacheManager.mjs.map +1 -1
  12. package/dist/cache/BrowserStorage.mjs +1 -1
  13. package/dist/cache/DatabaseStorage.mjs +1 -1
  14. package/dist/cache/MemoryStorage.mjs +1 -1
  15. package/dist/cache/TokenCache.mjs +1 -1
  16. package/dist/config/Configuration.mjs +1 -1
  17. package/dist/controllers/ControllerFactory.mjs +1 -1
  18. package/dist/controllers/NestedAppAuthController.mjs +1 -1
  19. package/dist/controllers/StandardController.mjs +1 -1
  20. package/dist/controllers/UnknownOperatingContextController.mjs +1 -1
  21. package/dist/crypto/BrowserCrypto.mjs +1 -1
  22. package/dist/crypto/CryptoOps.mjs +1 -1
  23. package/dist/crypto/PkceGenerator.mjs +1 -1
  24. package/dist/crypto/SignedHttpRequest.mjs +1 -1
  25. package/dist/encode/Base64Decode.mjs +1 -1
  26. package/dist/encode/Base64Encode.mjs +1 -1
  27. package/dist/error/BrowserAuthError.d.ts +0 -1
  28. package/dist/error/BrowserAuthError.d.ts.map +1 -1
  29. package/dist/error/BrowserAuthError.mjs +2 -3
  30. package/dist/error/BrowserAuthError.mjs.map +1 -1
  31. package/dist/error/BrowserAuthErrorCodes.d.ts +0 -1
  32. package/dist/error/BrowserAuthErrorCodes.d.ts.map +1 -1
  33. package/dist/error/BrowserAuthErrorCodes.mjs +3 -4
  34. package/dist/error/BrowserAuthErrorCodes.mjs.map +1 -1
  35. package/dist/error/BrowserConfigurationAuthError.mjs +1 -1
  36. package/dist/error/BrowserConfigurationAuthErrorCodes.mjs +1 -1
  37. package/dist/error/NativeAuthError.mjs +1 -1
  38. package/dist/error/NativeAuthErrorCodes.mjs +1 -1
  39. package/dist/error/NestedAppAuthError.mjs +1 -1
  40. package/dist/event/EventHandler.mjs +1 -1
  41. package/dist/event/EventMessage.mjs +1 -1
  42. package/dist/event/EventType.mjs +1 -1
  43. package/dist/index.mjs +1 -1
  44. package/dist/interaction_client/BaseInteractionClient.mjs +1 -1
  45. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
  46. package/dist/interaction_client/NativeInteractionClient.mjs +1 -1
  47. package/dist/interaction_client/PopupClient.d.ts +2 -15
  48. package/dist/interaction_client/PopupClient.d.ts.map +1 -1
  49. package/dist/interaction_client/PopupClient.mjs +55 -81
  50. package/dist/interaction_client/PopupClient.mjs.map +1 -1
  51. package/dist/interaction_client/RedirectClient.d.ts.map +1 -1
  52. package/dist/interaction_client/RedirectClient.mjs +5 -36
  53. package/dist/interaction_client/RedirectClient.mjs.map +1 -1
  54. package/dist/interaction_client/SilentAuthCodeClient.mjs +1 -1
  55. package/dist/interaction_client/SilentCacheClient.mjs +1 -1
  56. package/dist/interaction_client/SilentIframeClient.d.ts.map +1 -1
  57. package/dist/interaction_client/SilentIframeClient.mjs +3 -3
  58. package/dist/interaction_client/SilentIframeClient.mjs.map +1 -1
  59. package/dist/interaction_client/SilentRefreshClient.mjs +1 -1
  60. package/dist/interaction_client/StandardInteractionClient.mjs +1 -1
  61. package/dist/interaction_handler/InteractionHandler.mjs +1 -1
  62. package/dist/interaction_handler/RedirectHandler.d.ts.map +1 -1
  63. package/dist/interaction_handler/RedirectHandler.mjs +1 -2
  64. package/dist/interaction_handler/RedirectHandler.mjs.map +1 -1
  65. package/dist/interaction_handler/SilentHandler.mjs +1 -1
  66. package/dist/naa/BridgeError.mjs +1 -1
  67. package/dist/naa/BridgeProxy.d.ts.map +1 -1
  68. package/dist/naa/BridgeProxy.mjs +3 -8
  69. package/dist/naa/BridgeProxy.mjs.map +1 -1
  70. package/dist/naa/BridgeStatusCode.mjs +1 -1
  71. package/dist/naa/mapping/NestedAppAuthAdapter.mjs +1 -1
  72. package/dist/navigation/NavigationClient.mjs +1 -1
  73. package/dist/network/FetchClient.mjs +1 -1
  74. package/dist/operatingcontext/BaseOperatingContext.mjs +1 -1
  75. package/dist/operatingcontext/NestedAppOperatingContext.mjs +1 -1
  76. package/dist/operatingcontext/StandardOperatingContext.mjs +1 -1
  77. package/dist/operatingcontext/UnknownOperatingContext.mjs +1 -1
  78. package/dist/packageMetadata.d.ts +1 -1
  79. package/dist/packageMetadata.mjs +2 -2
  80. package/dist/request/RequestHelpers.mjs +1 -1
  81. package/dist/response/ResponseHandler.mjs +1 -1
  82. package/dist/telemetry/BrowserPerformanceClient.d.ts +0 -4
  83. package/dist/telemetry/BrowserPerformanceClient.d.ts.map +1 -1
  84. package/dist/telemetry/BrowserPerformanceClient.mjs +2 -2
  85. package/dist/telemetry/BrowserPerformanceClient.mjs.map +1 -1
  86. package/dist/telemetry/BrowserPerformanceMeasurement.mjs +1 -1
  87. package/dist/utils/BrowserConstants.d.ts +0 -2
  88. package/dist/utils/BrowserConstants.d.ts.map +1 -1
  89. package/dist/utils/BrowserConstants.mjs +1 -3
  90. package/dist/utils/BrowserConstants.mjs.map +1 -1
  91. package/dist/utils/BrowserProtocolUtils.mjs +1 -1
  92. package/dist/utils/BrowserUtils.mjs +1 -1
  93. package/lib/msal-browser.cjs +287 -428
  94. package/lib/msal-browser.cjs.map +1 -1
  95. package/lib/msal-browser.js +287 -428
  96. package/lib/msal-browser.js.map +1 -1
  97. package/lib/msal-browser.min.js +62 -62
  98. package/package.json +2 -2
  99. package/src/cache/BrowserCacheManager.ts +0 -95
  100. package/src/error/BrowserAuthError.ts +0 -2
  101. package/src/error/BrowserAuthErrorCodes.ts +0 -1
  102. package/src/interaction_client/PopupClient.ts +118 -202
  103. package/src/interaction_client/RedirectClient.ts +1 -58
  104. package/src/interaction_client/SilentIframeClient.ts +1 -2
  105. package/src/interaction_handler/RedirectHandler.ts +0 -1
  106. package/src/naa/BridgeProxy.ts +2 -7
  107. package/src/packageMetadata.ts +1 -1
  108. package/src/telemetry/BrowserPerformanceClient.ts +1 -1
  109. package/src/utils/BrowserConstants.ts +0 -2
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "type": "git",
11
11
  "url": "https://github.com/AzureAD/microsoft-authentication-library-for-js.git"
12
12
  },
13
- "version": "3.21.0",
13
+ "version": "3.22.0",
14
14
  "description": "Microsoft Authentication Library for js",
15
15
  "keywords": [
16
16
  "implicit",
@@ -104,6 +104,6 @@
104
104
  "typescript": "^4.9.5"
105
105
  },
106
106
  "dependencies": {
107
- "@azure/msal-common": "14.14.1"
107
+ "@azure/msal-common": "14.14.2"
108
108
  }
109
109
  }
@@ -1552,9 +1552,6 @@ export class BrowserCacheManager extends CacheManager {
1552
1552
  this.removeTemporaryItem(
1553
1553
  this.generateCacheKey(TemporaryCacheKeys.NATIVE_REQUEST)
1554
1554
  );
1555
- this.removeTemporaryItem(
1556
- this.generateCacheKey(TemporaryCacheKeys.REDIRECT_REQUEST)
1557
- );
1558
1555
  this.setInteractionInProgress(false);
1559
1556
  }
1560
1557
 
@@ -1616,98 +1613,6 @@ export class BrowserCacheManager extends CacheManager {
1616
1613
  this.setInteractionInProgress(false);
1617
1614
  }
1618
1615
 
1619
- /**
1620
- * Create request retry key to cache retry status
1621
- */
1622
- generateRequestRetriedKey(): string {
1623
- return `${Constants.CACHE_PREFIX}.${TemporaryCacheKeys.REQUEST_RETRY}.${this.clientId}`;
1624
- }
1625
-
1626
- /**
1627
- * Gets the request retry value from the cache
1628
- */
1629
- getRequestRetried(): number | null {
1630
- const requestRetriedKey = this.generateRequestRetriedKey();
1631
- const cachedRetryNumber = this.getTemporaryCache(requestRetriedKey);
1632
- if (!cachedRetryNumber) {
1633
- return null;
1634
- }
1635
- return parseInt(cachedRetryNumber);
1636
- }
1637
-
1638
- /**
1639
- * Sets the request retry value to "retried" in the cache
1640
- */
1641
- setRequestRetried(): void {
1642
- this.logger.trace("BrowserCacheManager.setRequestRetried called");
1643
- const requestRetriedKey = this.generateRequestRetriedKey();
1644
- this.setTemporaryCache(requestRetriedKey, "1", false);
1645
- }
1646
-
1647
- /**
1648
- * Removes all request retry values in the cache
1649
- */
1650
- removeRequestRetried(): void {
1651
- const requestRetriedKey = this.generateRequestRetriedKey();
1652
- this.removeTemporaryItem(requestRetriedKey);
1653
- }
1654
-
1655
- /**
1656
- * Caches the redirectRequest in the cache
1657
- * @param redirectRequest
1658
- */
1659
- cacheRedirectRequest(redirectRequest: RedirectRequest): void {
1660
- this.logger.trace("BrowserCacheManager.cacheRedirectRequest called");
1661
- const { ...restParams } = redirectRequest;
1662
- delete restParams.onRedirectNavigate;
1663
- const encodedValue = JSON.stringify(restParams);
1664
-
1665
- this.setTemporaryCache(
1666
- TemporaryCacheKeys.REDIRECT_REQUEST,
1667
- encodedValue,
1668
- true
1669
- );
1670
- }
1671
-
1672
- /**
1673
- * Gets redirect request from the cache. Logs an error and returns undefined if nothing is found.
1674
- */
1675
- getCachedRedirectRequest(): RedirectRequest | undefined {
1676
- this.logger.trace(
1677
- "BrowserCacheManager.getCachedRedirectRequest called"
1678
- );
1679
- const cachedRedirectRequest = this.getTemporaryCache(
1680
- TemporaryCacheKeys.REDIRECT_REQUEST,
1681
- true
1682
- );
1683
- if (!cachedRedirectRequest) {
1684
- this.logger.error(`No cached redirect request found.`);
1685
- } else {
1686
- this.removeTemporaryItem(
1687
- this.generateCacheKey(TemporaryCacheKeys.REDIRECT_REQUEST)
1688
- );
1689
- let parsedRequest: RedirectRequest;
1690
- try {
1691
- parsedRequest = JSON.parse(
1692
- cachedRedirectRequest
1693
- ) as RedirectRequest;
1694
- } catch (e) {
1695
- this.logger.errorPii(
1696
- `Attempted to parse: ${cachedRedirectRequest}`
1697
- );
1698
- this.logger.error(
1699
- `Parsing cached redirect request threw with error: ${e}`
1700
- );
1701
- return;
1702
- }
1703
-
1704
- if (parsedRequest) {
1705
- return parsedRequest;
1706
- }
1707
- }
1708
- return;
1709
- }
1710
-
1711
1616
  cacheCodeRequest(authCodeRequest: CommonAuthorizationCodeRequest): void {
1712
1617
  this.logger.trace("BrowserCacheManager.cacheCodeRequest called");
1713
1618
 
@@ -92,8 +92,6 @@ export const BrowserAuthErrorMessages = {
92
92
  "Invalid base64 encoded string.",
93
93
  [BrowserAuthErrorCodes.invalidPopTokenRequest]:
94
94
  "Invalid PoP token request. The request should not have both a popKid value and signPopToken set to true.",
95
- [BrowserAuthErrorCodes.failedToRetry]:
96
- "Unable to retry failed auth code redemption due to usage of the onRedirectNavigate request parameter. Please set onRedirectNavigate on the PublicClientApplication configuration instead or call loginRedirect again.",
97
95
  };
98
96
 
99
97
  /**
@@ -56,4 +56,3 @@ export const uninitializedPublicClientApplication =
56
56
  export const nativePromptNotSupported = "native_prompt_not_supported";
57
57
  export const invalidBase64String = "invalid_base64_string";
58
58
  export const invalidPopTokenRequest = "invalid_pop_token_request";
59
- export const failedToRetry = "failed_to_retry";
@@ -20,7 +20,6 @@ import {
20
20
  ServerResponseType,
21
21
  invokeAsync,
22
22
  invoke,
23
- ServerError,
24
23
  } from "@azure/msal-common";
25
24
  import { StandardInteractionClient } from "./StandardInteractionClient";
26
25
  import { EventType } from "../event/EventType";
@@ -48,7 +47,6 @@ import { PopupWindowAttributes } from "../request/PopupWindowAttributes";
48
47
  import { EventError } from "../event/EventMessage";
49
48
  import { AuthenticationResult } from "../response/AuthenticationResult";
50
49
  import * as ResponseHandler from "../response/ResponseHandler";
51
- import { AuthorizationUrlRequest } from "../request/AuthorizationUrlRequest";
52
50
 
53
51
  export type PopupParams = {
54
52
  popup?: Window | null;
@@ -184,7 +182,7 @@ export class PopupClient extends StandardInteractionClient {
184
182
  }
185
183
 
186
184
  /**
187
- * Helper which initializes authorization clients and requests
185
+ * Helper which obtains an access_token for your API via opening a popup window in the user's browser
188
186
  * @param validRequest
189
187
  * @param popupName
190
188
  * @param popup
@@ -213,20 +211,19 @@ export class PopupClient extends StandardInteractionClient {
213
211
 
214
212
  BrowserUtils.preconnect(validRequest.authority);
215
213
 
216
- let authClient: AuthorizationCodeClient | undefined;
217
-
218
214
  try {
219
215
  // Create auth code request and generate PKCE params
220
- const authCodeRequest = await invokeAsync(
221
- this.initializeAuthorizationCodeRequest.bind(this),
222
- PerformanceEvents.StandardInteractionClientInitializeAuthorizationCodeRequest,
223
- this.logger,
224
- this.performanceClient,
225
- this.correlationId
226
- )(validRequest);
216
+ const authCodeRequest: CommonAuthorizationCodeRequest =
217
+ await invokeAsync(
218
+ this.initializeAuthorizationCodeRequest.bind(this),
219
+ PerformanceEvents.StandardInteractionClientInitializeAuthorizationCodeRequest,
220
+ this.logger,
221
+ this.performanceClient,
222
+ this.correlationId
223
+ )(validRequest);
227
224
 
228
225
  // Initialize the client
229
- authClient = await invokeAsync(
226
+ const authClient: AuthorizationCodeClient = await invokeAsync(
230
227
  this.createAuthCodeClient.bind(this),
231
228
  PerformanceEvents.StandardInteractionClientCreateAuthCodeClient,
232
229
  this.logger,
@@ -239,218 +236,137 @@ export class PopupClient extends StandardInteractionClient {
239
236
  validRequest.account
240
237
  );
241
238
 
242
- return await invokeAsync(
243
- this.acquireTokenPopupAsyncHelper.bind(this),
244
- PerformanceEvents.PopupClientTokenHelper,
239
+ const isNativeBroker = NativeMessageHandler.isNativeAvailable(
240
+ this.config,
245
241
  this.logger,
246
- this.performanceClient,
247
- this.correlationId
248
- )(
249
- authClient,
250
- authCodeRequest,
251
- validRequest,
252
- request,
253
- popupName,
254
- popupWindowAttributes,
255
- popup
242
+ this.nativeMessageHandler,
243
+ request.authenticationScheme
256
244
  );
257
- } catch (e) {
258
- if (popup) {
259
- // Close the synchronous popup if an error is thrown before the window unload event is registered
260
- popup.close();
245
+ // Start measurement for server calls with native brokering enabled
246
+ let fetchNativeAccountIdMeasurement;
247
+ if (isNativeBroker) {
248
+ fetchNativeAccountIdMeasurement =
249
+ this.performanceClient.startMeasurement(
250
+ PerformanceEvents.FetchAccountIdWithNativeBroker,
251
+ request.correlationId
252
+ );
261
253
  }
262
254
 
263
- if (e instanceof AuthError) {
264
- (e as AuthError).setCorrelationId(this.correlationId);
265
- serverTelemetryManager.cacheFailedRequest(e);
266
- }
255
+ // Create acquire token url.
256
+ const navigateUrl = await authClient.getAuthCodeUrl({
257
+ ...validRequest,
258
+ nativeBroker: isNativeBroker,
259
+ });
267
260
 
268
- if (
269
- !authClient ||
270
- !(e instanceof ServerError) ||
271
- e.errorCode !== BrowserConstants.INVALID_GRANT_ERROR
272
- ) {
273
- throw e;
274
- }
261
+ // Create popup interaction handler.
262
+ const interactionHandler = new InteractionHandler(
263
+ authClient,
264
+ this.browserStorage,
265
+ authCodeRequest,
266
+ this.logger,
267
+ this.performanceClient
268
+ );
275
269
 
276
- this.performanceClient.addFields(
277
- {
278
- retryError: e.errorCode,
279
- },
280
- this.correlationId
270
+ // Show the UI once the url has been created. Get the window handle for the popup.
271
+ const popupParameters: PopupParams = {
272
+ popup,
273
+ popupName,
274
+ popupWindowAttributes,
275
+ };
276
+ const popupWindow: Window = this.initiateAuthRequest(
277
+ navigateUrl,
278
+ popupParameters
279
+ );
280
+ this.eventHandler.emitEvent(
281
+ EventType.POPUP_OPENED,
282
+ InteractionType.Popup,
283
+ { popupWindow },
284
+ null
281
285
  );
282
286
 
283
- const retryAuthCodeRequest = await invokeAsync(
284
- this.initializeAuthorizationCodeRequest.bind(this),
285
- PerformanceEvents.StandardInteractionClientInitializeAuthorizationCodeRequest,
286
- this.logger,
287
- this.performanceClient,
288
- this.correlationId
289
- )(validRequest);
287
+ // Monitor the window for the hash. Return the string value and close the popup when the hash is received. Default timeout is 60 seconds.
288
+ const responseString = await this.monitorPopupForHash(popupWindow);
290
289
 
291
- return await invokeAsync(
292
- this.acquireTokenPopupAsyncHelper.bind(this),
293
- PerformanceEvents.PopupClientTokenHelper,
290
+ const serverParams = invoke(
291
+ ResponseHandler.deserializeResponse,
292
+ PerformanceEvents.DeserializeResponse,
294
293
  this.logger,
295
294
  this.performanceClient,
296
295
  this.correlationId
297
296
  )(
298
- authClient,
299
- retryAuthCodeRequest,
300
- validRequest,
301
- request,
302
- popupName,
303
- popupWindowAttributes,
304
- popup
297
+ responseString,
298
+ this.config.auth.OIDCOptions.serverResponseType,
299
+ this.logger
300
+ );
301
+ // Remove throttle if it exists
302
+ ThrottlingUtils.removeThrottle(
303
+ this.browserStorage,
304
+ this.config.auth.clientId,
305
+ authCodeRequest
305
306
  );
306
- }
307
- }
308
-
309
- /**
310
- * Helper which obtains an access_token for your API via opening a popup window in the user's browser
311
- * @param authClient
312
- * @param authCodeRequest
313
- * @param validRequest
314
- * @param request
315
- * @param popupName
316
- * @param popupWindowAttributes
317
- * @param popup
318
- * @returns A promise that is fulfilled when this function has completed, or rejected if an error was raised.
319
- */
320
- protected async acquireTokenPopupAsyncHelper(
321
- authClient: AuthorizationCodeClient,
322
- authCodeRequest: CommonAuthorizationCodeRequest,
323
- validRequest: AuthorizationUrlRequest,
324
- request: PopupRequest,
325
- popupName: string,
326
- popupWindowAttributes: PopupWindowAttributes,
327
- popup?: Window | null
328
- ): Promise<AuthenticationResult> {
329
- const correlationId = validRequest.correlationId;
330
- this.performanceClient.addQueueMeasurement(
331
- PerformanceEvents.PopupClientTokenHelper,
332
- correlationId
333
- );
334
-
335
- const isNativeBroker = NativeMessageHandler.isNativeAvailable(
336
- this.config,
337
- this.logger,
338
- this.nativeMessageHandler,
339
- request.authenticationScheme
340
- );
341
307
 
342
- // Start measurement for server calls with native brokering enabled
343
- let fetchNativeAccountIdMeasurement;
344
- if (isNativeBroker) {
345
- fetchNativeAccountIdMeasurement =
346
- this.performanceClient.startMeasurement(
347
- PerformanceEvents.FetchAccountIdWithNativeBroker,
348
- request.correlationId
308
+ if (serverParams.accountId) {
309
+ this.logger.verbose(
310
+ "Account id found in hash, calling WAM for token"
349
311
  );
350
- }
351
-
352
- // Create acquire token url.
353
- const navigateUrl = await authClient.getAuthCodeUrl({
354
- ...validRequest,
355
- nativeBroker: isNativeBroker,
356
- });
357
-
358
- // Create popup interaction handler.
359
- const interactionHandler = new InteractionHandler(
360
- authClient,
361
- this.browserStorage,
362
- authCodeRequest,
363
- this.logger,
364
- this.performanceClient
365
- );
366
-
367
- // Show the UI once the url has been created. Get the window handle for the popup.
368
- const popupParameters: PopupParams = {
369
- popup,
370
- popupName,
371
- popupWindowAttributes,
372
- };
373
- const popupWindow: Window = this.initiateAuthRequest(
374
- navigateUrl,
375
- popupParameters
376
- );
377
- this.eventHandler.emitEvent(
378
- EventType.POPUP_OPENED,
379
- InteractionType.Popup,
380
- { popupWindow },
381
- null
382
- );
383
-
384
- // Monitor the window for the hash. Return the string value and close the popup when the hash is received. Default timeout is 60 seconds.
385
- const responseString = await this.monitorPopupForHash(popupWindow);
386
-
387
- const serverParams = invoke(
388
- ResponseHandler.deserializeResponse,
389
- PerformanceEvents.DeserializeResponse,
390
- this.logger,
391
- this.performanceClient,
392
- this.correlationId
393
- )(
394
- responseString,
395
- this.config.auth.OIDCOptions.serverResponseType,
396
- this.logger
397
- );
398
- // Remove throttle if it exists
399
- ThrottlingUtils.removeThrottle(
400
- this.browserStorage,
401
- this.config.auth.clientId,
402
- authCodeRequest
403
- );
312
+ // end measurement for server call with native brokering enabled
313
+ if (fetchNativeAccountIdMeasurement) {
314
+ fetchNativeAccountIdMeasurement.end({
315
+ success: true,
316
+ isNativeBroker: true,
317
+ });
318
+ }
404
319
 
405
- if (serverParams.accountId) {
406
- this.logger.verbose(
407
- "Account id found in hash, calling WAM for token"
408
- );
409
- // end measurement for server call with native brokering enabled
410
- if (fetchNativeAccountIdMeasurement) {
411
- fetchNativeAccountIdMeasurement.end({
412
- success: true,
413
- isNativeBroker: true,
320
+ if (!this.nativeMessageHandler) {
321
+ throw createBrowserAuthError(
322
+ BrowserAuthErrorCodes.nativeConnectionNotEstablished
323
+ );
324
+ }
325
+ const nativeInteractionClient = new NativeInteractionClient(
326
+ this.config,
327
+ this.browserStorage,
328
+ this.browserCrypto,
329
+ this.logger,
330
+ this.eventHandler,
331
+ this.navigationClient,
332
+ ApiId.acquireTokenPopup,
333
+ this.performanceClient,
334
+ this.nativeMessageHandler,
335
+ serverParams.accountId,
336
+ this.nativeStorage,
337
+ validRequest.correlationId
338
+ );
339
+ const { userRequestState } = ProtocolUtils.parseRequestState(
340
+ this.browserCrypto,
341
+ validRequest.state
342
+ );
343
+ return await nativeInteractionClient.acquireToken({
344
+ ...validRequest,
345
+ state: userRequestState,
346
+ prompt: undefined, // Server should handle the prompt, ideally native broker can do this part silently
414
347
  });
415
348
  }
416
349
 
417
- if (!this.nativeMessageHandler) {
418
- throw createBrowserAuthError(
419
- BrowserAuthErrorCodes.nativeConnectionNotEstablished
420
- );
421
- }
422
- const nativeInteractionClient = new NativeInteractionClient(
423
- this.config,
424
- this.browserStorage,
425
- this.browserCrypto,
426
- this.logger,
427
- this.eventHandler,
428
- this.navigationClient,
429
- ApiId.acquireTokenPopup,
430
- this.performanceClient,
431
- this.nativeMessageHandler,
432
- serverParams.accountId,
433
- this.nativeStorage,
434
- validRequest.correlationId
435
- );
436
- const { userRequestState } = ProtocolUtils.parseRequestState(
437
- this.browserCrypto,
438
- validRequest.state
350
+ // Handle response from hash string.
351
+ const result = await interactionHandler.handleCodeResponse(
352
+ serverParams,
353
+ validRequest
439
354
  );
440
- return nativeInteractionClient.acquireToken({
441
- ...validRequest,
442
- state: userRequestState,
443
- prompt: undefined, // Server should handle the prompt, ideally native broker can do this part silently
444
- });
445
- }
446
355
 
447
- // Handle response from hash string.
448
- const result = await interactionHandler.handleCodeResponse(
449
- serverParams,
450
- validRequest
451
- );
356
+ return result;
357
+ } catch (e) {
358
+ if (popup) {
359
+ // Close the synchronous popup if an error is thrown before the window unload event is registered
360
+ popup.close();
361
+ }
452
362
 
453
- return result;
363
+ if (e instanceof AuthError) {
364
+ (e as AuthError).setCorrelationId(this.correlationId);
365
+ serverTelemetryManager.cacheFailedRequest(e);
366
+ }
367
+
368
+ throw e;
369
+ }
454
370
  }
455
371
 
456
372
  /**
@@ -22,12 +22,10 @@ import {
22
22
  ServerResponseType,
23
23
  UrlUtils,
24
24
  InProgressPerformanceEvent,
25
- ServerError,
26
25
  } from "@azure/msal-common";
27
26
  import { StandardInteractionClient } from "./StandardInteractionClient";
28
27
  import {
29
28
  ApiId,
30
- BrowserConstants,
31
29
  InteractionType,
32
30
  TemporaryCacheKeys,
33
31
  } from "../utils/BrowserConstants";
@@ -85,14 +83,6 @@ export class RedirectClient extends StandardInteractionClient {
85
83
  * @param request
86
84
  */
87
85
  async acquireToken(request: RedirectRequest): Promise<void> {
88
- if (request.onRedirectNavigate) {
89
- this.logger.warning(
90
- "Unable to cache redirect request, onRedirectNavigate request option has been deprecated. Please set onRedirectNavigate on PublicClientApplication config instead."
91
- );
92
- } else {
93
- this.browserStorage.cacheRedirectRequest(request);
94
- }
95
-
96
86
  const validRequest = await invokeAsync(
97
87
  this.initializeAuthorizationRequest.bind(this),
98
88
  PerformanceEvents.StandardInteractionClientInitializeAuthorizationRequest,
@@ -344,57 +334,10 @@ export class RedirectClient extends StandardInteractionClient {
344
334
  (e as AuthError).setCorrelationId(this.correlationId);
345
335
  serverTelemetryManager.cacheFailedRequest(e);
346
336
  }
347
-
348
- if (
349
- e instanceof ServerError &&
350
- e.errorCode === BrowserConstants.INVALID_GRANT_ERROR
351
- ) {
352
- this.performanceClient.addFields(
353
- {
354
- retryError: e.errorCode,
355
- },
356
- this.correlationId
357
- );
358
-
359
- const requestRetried = this.browserStorage.getRequestRetried();
360
-
361
- if (requestRetried) {
362
- this.logger.error(
363
- "Retried request already detected. Throwing error."
364
- );
365
- this.browserStorage.removeRequestRetried();
366
- throw e;
367
- }
368
-
369
- const redirectRequest =
370
- this.browserStorage.getCachedRedirectRequest();
371
- if (!redirectRequest) {
372
- this.logger.error(
373
- "Unable to retry. Please retry with redirect request"
374
- );
375
- this.browserStorage.setRequestRetried();
376
- throw createBrowserAuthError(
377
- BrowserAuthErrorCodes.failedToRetry
378
- );
379
- }
380
-
381
- this.browserStorage.setRequestRetried();
382
-
383
- await this.acquireToken(redirectRequest);
384
- return null;
385
- }
386
-
387
- this.browserStorage.removeTemporaryItem(
388
- this.browserStorage.generateCacheKey(
389
- TemporaryCacheKeys.REDIRECT_REQUEST
390
- )
391
- );
392
- this.browserStorage.removeRequestRetried();
393
- throw e;
394
- } finally {
395
337
  this.browserStorage.cleanRequestByInteractionType(
396
338
  InteractionType.Redirect
397
339
  );
340
+ throw e;
398
341
  }
399
342
  }
400
343
 
@@ -15,7 +15,6 @@ import {
15
15
  PerformanceEvents,
16
16
  invokeAsync,
17
17
  invoke,
18
- ServerError,
19
18
  } from "@azure/msal-common";
20
19
  import { StandardInteractionClient } from "./StandardInteractionClient";
21
20
  import { AuthorizationUrlRequest } from "../request/AuthorizationUrlRequest";
@@ -160,7 +159,7 @@ export class SilentIframeClient extends StandardInteractionClient {
160
159
 
161
160
  if (
162
161
  !authClient ||
163
- !(e instanceof ServerError) ||
162
+ !(e instanceof AuthError) ||
164
163
  e.errorCode !== BrowserConstants.INVALID_GRANT_ERROR
165
164
  ) {
166
165
  throw e;
@@ -222,7 +222,6 @@ export class RedirectHandler {
222
222
  )) as AuthenticationResult;
223
223
 
224
224
  this.browserStorage.cleanRequestByState(state);
225
- this.browserStorage.removeRequestRetried();
226
225
  return tokenResponse;
227
226
  }
228
227
 
@@ -16,7 +16,6 @@ import { IBridgeProxy } from "./IBridgeProxy";
16
16
  import { InitContext } from "./InitContext";
17
17
  import { TokenRequest } from "./TokenRequest";
18
18
  import * as BrowserCrypto from "../crypto/BrowserCrypto";
19
- import { supportsBrowserPerformanceNow } from "../telemetry/BrowserPerformanceClient";
20
19
 
21
20
  declare global {
22
21
  interface Window {
@@ -82,9 +81,7 @@ export class BridgeProxy implements IBridgeProxy {
82
81
  messageType: "NestedAppAuthRequest",
83
82
  method: "GetInitContext",
84
83
  requestId: BrowserCrypto.createNewGuid(),
85
- sendTime: supportsBrowserPerformanceNow()
86
- ? window.performance.now()
87
- : Date.now(),
84
+ sendTime: Date.now(),
88
85
  };
89
86
  const request: BridgeRequest = {
90
87
  requestId: message.requestId,
@@ -160,9 +157,7 @@ export class BridgeProxy implements IBridgeProxy {
160
157
  messageType: "NestedAppAuthRequest",
161
158
  method: method,
162
159
  requestId: BrowserCrypto.createNewGuid(),
163
- sendTime: supportsBrowserPerformanceNow()
164
- ? window.performance.now()
165
- : Date.now(),
160
+ sendTime: Date.now(),
166
161
  ...requestParams,
167
162
  };
168
163
 
@@ -1,3 +1,3 @@
1
1
  /* eslint-disable header/header */
2
2
  export const name = "@azure/msal-browser";
3
- export const version = "3.21.0";
3
+ export const version = "3.22.0";