@azure/msal-browser 3.15.0 → 3.16.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 (80) 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.mjs +1 -1
  9. package/dist/cache/BrowserStorage.mjs +1 -1
  10. package/dist/cache/DatabaseStorage.mjs +1 -1
  11. package/dist/cache/MemoryStorage.mjs +1 -1
  12. package/dist/cache/TokenCache.mjs +1 -1
  13. package/dist/config/Configuration.mjs +1 -1
  14. package/dist/controllers/ControllerFactory.mjs +1 -1
  15. package/dist/controllers/NestedAppAuthController.mjs +1 -1
  16. package/dist/controllers/StandardController.d.ts.map +1 -1
  17. package/dist/controllers/StandardController.mjs +58 -37
  18. package/dist/controllers/StandardController.mjs.map +1 -1
  19. package/dist/controllers/UnknownOperatingContextController.mjs +1 -1
  20. package/dist/crypto/BrowserCrypto.mjs +1 -1
  21. package/dist/crypto/CryptoOps.mjs +1 -1
  22. package/dist/crypto/PkceGenerator.mjs +1 -1
  23. package/dist/crypto/SignedHttpRequest.mjs +1 -1
  24. package/dist/encode/Base64Decode.mjs +1 -1
  25. package/dist/encode/Base64Encode.mjs +1 -1
  26. package/dist/error/BrowserAuthError.mjs +1 -1
  27. package/dist/error/BrowserAuthErrorCodes.mjs +1 -1
  28. package/dist/error/BrowserConfigurationAuthError.mjs +1 -1
  29. package/dist/error/BrowserConfigurationAuthErrorCodes.mjs +1 -1
  30. package/dist/error/NativeAuthError.mjs +1 -1
  31. package/dist/error/NativeAuthErrorCodes.mjs +1 -1
  32. package/dist/error/NestedAppAuthError.mjs +1 -1
  33. package/dist/event/EventHandler.mjs +1 -1
  34. package/dist/event/EventMessage.mjs +1 -1
  35. package/dist/event/EventType.mjs +1 -1
  36. package/dist/index.mjs +1 -1
  37. package/dist/interaction_client/BaseInteractionClient.mjs +1 -1
  38. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
  39. package/dist/interaction_client/NativeInteractionClient.d.ts +4 -3
  40. package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
  41. package/dist/interaction_client/NativeInteractionClient.mjs +5 -3
  42. package/dist/interaction_client/NativeInteractionClient.mjs.map +1 -1
  43. package/dist/interaction_client/PopupClient.mjs +1 -1
  44. package/dist/interaction_client/RedirectClient.mjs +1 -1
  45. package/dist/interaction_client/SilentAuthCodeClient.mjs +1 -1
  46. package/dist/interaction_client/SilentCacheClient.mjs +1 -1
  47. package/dist/interaction_client/SilentIframeClient.mjs +1 -1
  48. package/dist/interaction_client/SilentRefreshClient.mjs +1 -1
  49. package/dist/interaction_client/StandardInteractionClient.mjs +1 -1
  50. package/dist/interaction_handler/InteractionHandler.mjs +1 -1
  51. package/dist/interaction_handler/RedirectHandler.mjs +1 -1
  52. package/dist/interaction_handler/SilentHandler.mjs +1 -1
  53. package/dist/naa/BridgeError.mjs +1 -1
  54. package/dist/naa/BridgeProxy.mjs +1 -1
  55. package/dist/naa/BridgeStatusCode.mjs +1 -1
  56. package/dist/naa/mapping/NestedAppAuthAdapter.mjs +1 -1
  57. package/dist/navigation/NavigationClient.mjs +1 -1
  58. package/dist/network/FetchClient.mjs +1 -1
  59. package/dist/operatingcontext/BaseOperatingContext.mjs +1 -1
  60. package/dist/operatingcontext/NestedAppOperatingContext.mjs +1 -1
  61. package/dist/operatingcontext/StandardOperatingContext.mjs +1 -1
  62. package/dist/operatingcontext/UnknownOperatingContext.mjs +1 -1
  63. package/dist/packageMetadata.d.ts +1 -1
  64. package/dist/packageMetadata.mjs +2 -2
  65. package/dist/request/RequestHelpers.mjs +1 -1
  66. package/dist/response/ResponseHandler.mjs +1 -1
  67. package/dist/telemetry/BrowserPerformanceClient.mjs +1 -1
  68. package/dist/telemetry/BrowserPerformanceMeasurement.mjs +1 -1
  69. package/dist/utils/BrowserConstants.mjs +1 -1
  70. package/dist/utils/BrowserProtocolUtils.mjs +1 -1
  71. package/dist/utils/BrowserUtils.mjs +1 -1
  72. package/lib/msal-browser.cjs +136 -106
  73. package/lib/msal-browser.cjs.map +1 -1
  74. package/lib/msal-browser.js +136 -106
  75. package/lib/msal-browser.js.map +1 -1
  76. package/lib/msal-browser.min.js +61 -61
  77. package/package.json +2 -2
  78. package/src/controllers/StandardController.ts +89 -63
  79. package/src/interaction_client/NativeInteractionClient.ts +8 -2
  80. package/src/packageMetadata.ts +1 -1
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.15.0",
13
+ "version": "3.16.0",
14
14
  "description": "Microsoft Authentication Library for js",
15
15
  "keywords": [
16
16
  "implicit",
@@ -103,6 +103,6 @@
103
103
  "typescript": "^4.9.5"
104
104
  },
105
105
  "dependencies": {
106
- "@azure/msal-common": "14.10.0"
106
+ "@azure/msal-common": "14.11.0"
107
107
  }
108
108
  }
@@ -422,7 +422,7 @@ export class StandardController implements IController {
422
422
  true
423
423
  ) || "";
424
424
  const rootMeasurement = this.performanceClient.startMeasurement(
425
- "acquireTokenRedirect",
425
+ PerformanceEvents.AcquireTokenRedirect,
426
426
  correlationId
427
427
  );
428
428
  this.eventHandler.emitEvent(
@@ -567,88 +567,114 @@ export class StandardController implements IController {
567
567
  // Preflight request
568
568
  const correlationId = this.getRequestCorrelationId(request);
569
569
  this.logger.verbose("acquireTokenRedirect called", correlationId);
570
- BrowserUtils.redirectPreflightCheck(this.initialized, this.config);
571
- this.browserStorage.setInteractionInProgress(true);
570
+
571
+ const atrMeasurement = this.performanceClient.startMeasurement(
572
+ PerformanceEvents.AcquireTokenPreRedirect,
573
+ correlationId
574
+ );
575
+ atrMeasurement.add({
576
+ accountType: getAccountType(request.account),
577
+ scenarioId: request.scenarioId,
578
+ });
579
+
580
+ const onRedirectNavigateCb = request.onRedirectNavigate;
581
+ request.onRedirectNavigate = (url: string) => {
582
+ const navigate =
583
+ typeof onRedirectNavigateCb === "function"
584
+ ? onRedirectNavigateCb(url)
585
+ : undefined;
586
+ if (navigate !== false) {
587
+ atrMeasurement.end({ success: true });
588
+ } else {
589
+ atrMeasurement.discard();
590
+ }
591
+ return navigate;
592
+ };
572
593
 
573
594
  // If logged in, emit acquire token events
574
595
  const isLoggedIn = this.getAllAccounts().length > 0;
575
- if (isLoggedIn) {
576
- this.eventHandler.emitEvent(
577
- EventType.ACQUIRE_TOKEN_START,
578
- InteractionType.Redirect,
579
- request
580
- );
581
- } else {
582
- this.eventHandler.emitEvent(
583
- EventType.LOGIN_START,
584
- InteractionType.Redirect,
585
- request
586
- );
587
- }
596
+ try {
597
+ BrowserUtils.redirectPreflightCheck(this.initialized, this.config);
598
+ this.browserStorage.setInteractionInProgress(true);
588
599
 
589
- let result: Promise<void>;
600
+ if (isLoggedIn) {
601
+ this.eventHandler.emitEvent(
602
+ EventType.ACQUIRE_TOKEN_START,
603
+ InteractionType.Redirect,
604
+ request
605
+ );
606
+ } else {
607
+ this.eventHandler.emitEvent(
608
+ EventType.LOGIN_START,
609
+ InteractionType.Redirect,
610
+ request
611
+ );
612
+ }
590
613
 
591
- if (this.nativeExtensionProvider && this.canUseNative(request)) {
592
- const nativeClient = new NativeInteractionClient(
593
- this.config,
594
- this.browserStorage,
595
- this.browserCrypto,
596
- this.logger,
597
- this.eventHandler,
598
- this.navigationClient,
599
- ApiId.acquireTokenRedirect,
600
- this.performanceClient,
601
- this.nativeExtensionProvider,
602
- this.getNativeAccountId(request),
603
- this.nativeInternalStorage,
604
- correlationId
605
- );
606
- result = nativeClient
607
- .acquireTokenRedirect(request)
608
- .catch((e: AuthError) => {
609
- if (
610
- e instanceof NativeAuthError &&
611
- isFatalNativeAuthError(e)
612
- ) {
613
- this.nativeExtensionProvider = undefined; // If extension gets uninstalled during session prevent future requests from continuing to attempt
614
- const redirectClient =
615
- this.createRedirectClient(correlationId);
616
- return redirectClient.acquireToken(request);
617
- } else if (e instanceof InteractionRequiredAuthError) {
618
- this.logger.verbose(
619
- "acquireTokenRedirect - Resolving interaction required error thrown by native broker by falling back to web flow"
620
- );
621
- const redirectClient =
622
- this.createRedirectClient(correlationId);
623
- return redirectClient.acquireToken(request);
624
- }
625
- this.browserStorage.setInteractionInProgress(false);
626
- throw e;
627
- });
628
- } else {
629
- const redirectClient = this.createRedirectClient(correlationId);
630
- result = redirectClient.acquireToken(request);
631
- }
614
+ let result: Promise<void>;
632
615
 
633
- return result.catch((e) => {
634
- // If logged in, emit acquire token events
616
+ if (this.nativeExtensionProvider && this.canUseNative(request)) {
617
+ const nativeClient = new NativeInteractionClient(
618
+ this.config,
619
+ this.browserStorage,
620
+ this.browserCrypto,
621
+ this.logger,
622
+ this.eventHandler,
623
+ this.navigationClient,
624
+ ApiId.acquireTokenRedirect,
625
+ this.performanceClient,
626
+ this.nativeExtensionProvider,
627
+ this.getNativeAccountId(request),
628
+ this.nativeInternalStorage,
629
+ correlationId
630
+ );
631
+ result = nativeClient
632
+ .acquireTokenRedirect(request, atrMeasurement)
633
+ .catch((e: AuthError) => {
634
+ if (
635
+ e instanceof NativeAuthError &&
636
+ isFatalNativeAuthError(e)
637
+ ) {
638
+ this.nativeExtensionProvider = undefined; // If extension gets uninstalled during session prevent future requests from continuing to attempt
639
+ const redirectClient =
640
+ this.createRedirectClient(correlationId);
641
+ return redirectClient.acquireToken(request);
642
+ } else if (e instanceof InteractionRequiredAuthError) {
643
+ this.logger.verbose(
644
+ "acquireTokenRedirect - Resolving interaction required error thrown by native broker by falling back to web flow"
645
+ );
646
+ const redirectClient =
647
+ this.createRedirectClient(correlationId);
648
+ return redirectClient.acquireToken(request);
649
+ }
650
+ this.browserStorage.setInteractionInProgress(false);
651
+ throw e;
652
+ });
653
+ } else {
654
+ const redirectClient = this.createRedirectClient(correlationId);
655
+ result = redirectClient.acquireToken(request);
656
+ }
657
+
658
+ return await result;
659
+ } catch (e) {
660
+ atrMeasurement.end({ success: false }, e);
635
661
  if (isLoggedIn) {
636
662
  this.eventHandler.emitEvent(
637
663
  EventType.ACQUIRE_TOKEN_FAILURE,
638
664
  InteractionType.Redirect,
639
665
  null,
640
- e
666
+ e as EventError
641
667
  );
642
668
  } else {
643
669
  this.eventHandler.emitEvent(
644
670
  EventType.LOGIN_FAILURE,
645
671
  InteractionType.Redirect,
646
672
  null,
647
- e
673
+ e as EventError
648
674
  );
649
675
  }
650
676
  throw e;
651
- });
677
+ }
652
678
  }
653
679
 
654
680
  // #endregion
@@ -36,6 +36,7 @@ import {
36
36
  updateAccountTenantProfileData,
37
37
  CacheHelpers,
38
38
  buildAccountToCache,
39
+ InProgressPerformanceEvent,
39
40
  } from "@azure/msal-common";
40
41
  import { BaseInteractionClient } from "./BaseInteractionClient";
41
42
  import { BrowserConfiguration } from "../config/Configuration";
@@ -276,9 +277,13 @@ export class NativeInteractionClient extends BaseInteractionClient {
276
277
 
277
278
  /**
278
279
  * Acquires a token from native platform then redirects to the redirectUri instead of returning the response
279
- * @param request
280
+ * @param {RedirectRequest} request
281
+ * @param {InProgressPerformanceEvent} rootMeasurement
280
282
  */
281
- async acquireTokenRedirect(request: RedirectRequest): Promise<void> {
283
+ async acquireTokenRedirect(
284
+ request: RedirectRequest,
285
+ rootMeasurement: InProgressPerformanceEvent
286
+ ): Promise<void> {
282
287
  this.logger.trace(
283
288
  "NativeInteractionClient - acquireTokenRedirect called."
284
289
  );
@@ -313,6 +318,7 @@ export class NativeInteractionClient extends BaseInteractionClient {
313
318
  const redirectUri = this.config.auth.navigateToLoginRequestUrl
314
319
  ? window.location.href
315
320
  : this.getRedirectUri(request.redirectUri);
321
+ rootMeasurement.end({ success: true });
316
322
  await this.navigationClient.navigateExternal(
317
323
  redirectUri,
318
324
  navigationOptions
@@ -1,3 +1,3 @@
1
1
  /* eslint-disable header/header */
2
2
  export const name = "@azure/msal-browser";
3
- export const version = "3.15.0";
3
+ export const version = "3.16.0";