@azure/msal-browser 4.1.0 → 4.2.1

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 (123) 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 +10 -3
  9. package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
  10. package/dist/cache/BrowserCacheManager.mjs +32 -6
  11. package/dist/cache/BrowserCacheManager.mjs.map +1 -1
  12. package/dist/cache/CacheHelpers.mjs +1 -1
  13. package/dist/cache/CookieStorage.d.ts +6 -1
  14. package/dist/cache/CookieStorage.d.ts.map +1 -1
  15. package/dist/cache/CookieStorage.mjs +10 -5
  16. package/dist/cache/CookieStorage.mjs.map +1 -1
  17. package/dist/cache/DatabaseStorage.mjs +1 -1
  18. package/dist/cache/LocalStorage.d.ts +2 -0
  19. package/dist/cache/LocalStorage.d.ts.map +1 -1
  20. package/dist/cache/LocalStorage.mjs +52 -4
  21. package/dist/cache/LocalStorage.mjs.map +1 -1
  22. package/dist/cache/MemoryStorage.mjs +1 -1
  23. package/dist/cache/SessionStorage.mjs +1 -1
  24. package/dist/cache/TokenCache.mjs +1 -1
  25. package/dist/config/Configuration.d.ts +2 -1
  26. package/dist/config/Configuration.d.ts.map +1 -1
  27. package/dist/config/Configuration.mjs +1 -1
  28. package/dist/config/Configuration.mjs.map +1 -1
  29. package/dist/controllers/ControllerFactory.mjs +1 -1
  30. package/dist/controllers/NestedAppAuthController.d.ts.map +1 -1
  31. package/dist/controllers/NestedAppAuthController.mjs +11 -7
  32. package/dist/controllers/NestedAppAuthController.mjs.map +1 -1
  33. package/dist/controllers/StandardController.d.ts +2 -5
  34. package/dist/controllers/StandardController.d.ts.map +1 -1
  35. package/dist/controllers/StandardController.mjs +16 -63
  36. package/dist/controllers/StandardController.mjs.map +1 -1
  37. package/dist/controllers/UnknownOperatingContextController.d.ts +1 -0
  38. package/dist/controllers/UnknownOperatingContextController.d.ts.map +1 -1
  39. package/dist/controllers/UnknownOperatingContextController.mjs +5 -3
  40. package/dist/controllers/UnknownOperatingContextController.mjs.map +1 -1
  41. package/dist/crypto/BrowserCrypto.mjs +1 -1
  42. package/dist/crypto/CryptoOps.mjs +1 -1
  43. package/dist/crypto/PkceGenerator.mjs +1 -1
  44. package/dist/crypto/SignedHttpRequest.mjs +1 -1
  45. package/dist/encode/Base64Decode.mjs +1 -1
  46. package/dist/encode/Base64Encode.mjs +1 -1
  47. package/dist/error/BrowserAuthError.mjs +1 -1
  48. package/dist/error/BrowserAuthErrorCodes.mjs +1 -1
  49. package/dist/error/BrowserConfigurationAuthError.mjs +1 -1
  50. package/dist/error/BrowserConfigurationAuthErrorCodes.mjs +1 -1
  51. package/dist/error/NativeAuthError.mjs +1 -1
  52. package/dist/error/NativeAuthErrorCodes.mjs +1 -1
  53. package/dist/error/NestedAppAuthError.mjs +1 -1
  54. package/dist/event/EventHandler.d.ts +19 -0
  55. package/dist/event/EventHandler.d.ts.map +1 -1
  56. package/dist/event/EventHandler.mjs +56 -16
  57. package/dist/event/EventHandler.mjs.map +1 -1
  58. package/dist/event/EventMessage.mjs +1 -1
  59. package/dist/event/EventType.mjs +1 -1
  60. package/dist/index.mjs +1 -1
  61. package/dist/interaction_client/BaseInteractionClient.mjs +1 -1
  62. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
  63. package/dist/interaction_client/NativeInteractionClient.mjs +1 -1
  64. package/dist/interaction_client/PopupClient.mjs +1 -1
  65. package/dist/interaction_client/RedirectClient.mjs +1 -1
  66. package/dist/interaction_client/SilentAuthCodeClient.mjs +1 -1
  67. package/dist/interaction_client/SilentCacheClient.mjs +1 -1
  68. package/dist/interaction_client/SilentIframeClient.mjs +1 -1
  69. package/dist/interaction_client/SilentRefreshClient.mjs +1 -1
  70. package/dist/interaction_client/StandardInteractionClient.mjs +1 -1
  71. package/dist/interaction_handler/InteractionHandler.mjs +1 -1
  72. package/dist/interaction_handler/RedirectHandler.mjs +1 -1
  73. package/dist/interaction_handler/SilentHandler.mjs +1 -1
  74. package/dist/naa/BridgeError.mjs +1 -1
  75. package/dist/naa/BridgeProxy.mjs +1 -1
  76. package/dist/naa/BridgeStatusCode.mjs +1 -1
  77. package/dist/naa/mapping/NestedAppAuthAdapter.mjs +1 -1
  78. package/dist/navigation/NavigationClient.mjs +1 -1
  79. package/dist/network/FetchClient.mjs +1 -1
  80. package/dist/operatingcontext/BaseOperatingContext.mjs +1 -1
  81. package/dist/operatingcontext/NestedAppOperatingContext.mjs +1 -1
  82. package/dist/operatingcontext/StandardOperatingContext.mjs +1 -1
  83. package/dist/operatingcontext/UnknownOperatingContext.mjs +1 -1
  84. package/dist/packageMetadata.d.ts +1 -1
  85. package/dist/packageMetadata.mjs +2 -2
  86. package/dist/request/RequestHelpers.mjs +1 -1
  87. package/dist/response/ResponseHandler.mjs +1 -1
  88. package/dist/telemetry/BrowserPerformanceClient.mjs +1 -1
  89. package/dist/telemetry/BrowserPerformanceMeasurement.mjs +1 -1
  90. package/dist/utils/BrowserConstants.mjs +1 -1
  91. package/dist/utils/BrowserProtocolUtils.mjs +1 -1
  92. package/dist/utils/BrowserUtils.mjs +1 -1
  93. package/lib/msal-browser.cjs +267 -190
  94. package/lib/msal-browser.cjs.map +1 -1
  95. package/lib/msal-browser.js +267 -190
  96. package/lib/msal-browser.js.map +1 -1
  97. package/lib/msal-browser.min.js +63 -63
  98. package/lib/types/cache/BrowserCacheManager.d.ts +10 -3
  99. package/lib/types/cache/BrowserCacheManager.d.ts.map +1 -1
  100. package/lib/types/cache/CookieStorage.d.ts +6 -1
  101. package/lib/types/cache/CookieStorage.d.ts.map +1 -1
  102. package/lib/types/cache/LocalStorage.d.ts +2 -0
  103. package/lib/types/cache/LocalStorage.d.ts.map +1 -1
  104. package/lib/types/config/Configuration.d.ts +2 -1
  105. package/lib/types/config/Configuration.d.ts.map +1 -1
  106. package/lib/types/controllers/NestedAppAuthController.d.ts.map +1 -1
  107. package/lib/types/controllers/StandardController.d.ts +2 -5
  108. package/lib/types/controllers/StandardController.d.ts.map +1 -1
  109. package/lib/types/controllers/UnknownOperatingContextController.d.ts +1 -0
  110. package/lib/types/controllers/UnknownOperatingContextController.d.ts.map +1 -1
  111. package/lib/types/event/EventHandler.d.ts +19 -0
  112. package/lib/types/event/EventHandler.d.ts.map +1 -1
  113. package/lib/types/packageMetadata.d.ts +1 -1
  114. package/package.json +3 -3
  115. package/src/cache/BrowserCacheManager.ts +51 -4
  116. package/src/cache/CookieStorage.ts +12 -3
  117. package/src/cache/LocalStorage.ts +65 -3
  118. package/src/config/Configuration.ts +2 -1
  119. package/src/controllers/NestedAppAuthController.ts +13 -5
  120. package/src/controllers/StandardController.ts +23 -82
  121. package/src/controllers/UnknownOperatingContextController.ts +9 -1
  122. package/src/event/EventHandler.ts +78 -27
  123. package/src/packageMetadata.ts +1 -1
@@ -1,4 +1,4 @@
1
- /*! @azure/msal-browser v4.1.0 2025-02-03 */
1
+ /*! @azure/msal-browser v4.2.1 2025-02-11 */
2
2
  'use strict';
3
3
  (function (global, factory) {
4
4
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
@@ -6,7 +6,7 @@
6
6
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.msal = {}));
7
7
  })(this, (function (exports) { 'use strict';
8
8
 
9
- /*! @azure/msal-common v15.1.0 2025-02-03 */
9
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
10
10
  /*
11
11
  * Copyright (c) Microsoft Corporation. All rights reserved.
12
12
  * Licensed under the MIT License.
@@ -310,7 +310,7 @@
310
310
  // Token renewal offset default in seconds
311
311
  const DEFAULT_TOKEN_RENEWAL_OFFSET_SEC = 300;
312
312
 
313
- /*! @azure/msal-common v15.1.0 2025-02-03 */
313
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
314
314
  /*
315
315
  * Copyright (c) Microsoft Corporation. All rights reserved.
316
316
  * Licensed under the MIT License.
@@ -327,7 +327,7 @@
327
327
  unexpectedError: unexpectedError
328
328
  });
329
329
 
330
- /*! @azure/msal-common v15.1.0 2025-02-03 */
330
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
331
331
 
332
332
  /*
333
333
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -376,7 +376,7 @@
376
376
  : AuthErrorMessages[code]);
377
377
  }
378
378
 
379
- /*! @azure/msal-common v15.1.0 2025-02-03 */
379
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
380
380
  /*
381
381
  * Copyright (c) Microsoft Corporation. All rights reserved.
382
382
  * Licensed under the MIT License.
@@ -474,7 +474,7 @@
474
474
  userTimeoutReached: userTimeoutReached
475
475
  });
476
476
 
477
- /*! @azure/msal-common v15.1.0 2025-02-03 */
477
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
478
478
 
479
479
  /*
480
480
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -726,7 +726,7 @@
726
726
  return new ClientAuthError(errorCode, additionalMessage);
727
727
  }
728
728
 
729
- /*! @azure/msal-common v15.1.0 2025-02-03 */
729
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
730
730
 
731
731
  /*
732
732
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -765,7 +765,7 @@
765
765
  },
766
766
  };
767
767
 
768
- /*! @azure/msal-common v15.1.0 2025-02-03 */
768
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
769
769
 
770
770
  /*
771
771
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -956,12 +956,12 @@
956
956
  }
957
957
  }
958
958
 
959
- /*! @azure/msal-common v15.1.0 2025-02-03 */
959
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
960
960
  /* eslint-disable header/header */
961
961
  const name$1 = "@azure/msal-common";
962
- const version$1 = "15.1.0";
962
+ const version$1 = "15.1.1";
963
963
 
964
- /*! @azure/msal-common v15.1.0 2025-02-03 */
964
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
965
965
  /*
966
966
  * Copyright (c) Microsoft Corporation. All rights reserved.
967
967
  * Licensed under the MIT License.
@@ -981,7 +981,7 @@
981
981
  AzureUsGovernment: "https://login.microsoftonline.us",
982
982
  };
983
983
 
984
- /*! @azure/msal-common v15.1.0 2025-02-03 */
984
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
985
985
 
986
986
  /*
987
987
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1042,7 +1042,7 @@
1042
1042
  }
1043
1043
  }
1044
1044
 
1045
- /*! @azure/msal-common v15.1.0 2025-02-03 */
1045
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
1046
1046
  /*
1047
1047
  * Copyright (c) Microsoft Corporation. All rights reserved.
1048
1048
  * Licensed under the MIT License.
@@ -1079,7 +1079,7 @@
1079
1079
  return cachedAtSec > nowSeconds();
1080
1080
  }
1081
1081
 
1082
- /*! @azure/msal-common v15.1.0 2025-02-03 */
1082
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
1083
1083
 
1084
1084
  /*
1085
1085
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1406,7 +1406,7 @@
1406
1406
  return metadata.expiresAt <= nowSeconds();
1407
1407
  }
1408
1408
 
1409
- /*! @azure/msal-common v15.1.0 2025-02-03 */
1409
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
1410
1410
  /*
1411
1411
  * Copyright (c) Microsoft Corporation. All rights reserved.
1412
1412
  * Licensed under the MIT License.
@@ -1460,7 +1460,7 @@
1460
1460
  urlParseError: urlParseError
1461
1461
  });
1462
1462
 
1463
- /*! @azure/msal-common v15.1.0 2025-02-03 */
1463
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
1464
1464
 
1465
1465
  /*
1466
1466
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1598,7 +1598,7 @@
1598
1598
  return new ClientConfigurationError(errorCode);
1599
1599
  }
1600
1600
 
1601
- /*! @azure/msal-common v15.1.0 2025-02-03 */
1601
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
1602
1602
  /*
1603
1603
  * Copyright (c) Microsoft Corporation. All rights reserved.
1604
1604
  * Licensed under the MIT License.
@@ -1695,7 +1695,7 @@
1695
1695
  }
1696
1696
  }
1697
1697
 
1698
- /*! @azure/msal-common v15.1.0 2025-02-03 */
1698
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
1699
1699
 
1700
1700
  /*
1701
1701
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1886,7 +1886,7 @@
1886
1886
  }
1887
1887
  }
1888
1888
 
1889
- /*! @azure/msal-common v15.1.0 2025-02-03 */
1889
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
1890
1890
 
1891
1891
  /*
1892
1892
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1926,7 +1926,7 @@
1926
1926
  };
1927
1927
  }
1928
1928
 
1929
- /*! @azure/msal-common v15.1.0 2025-02-03 */
1929
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
1930
1930
  /*
1931
1931
  * Copyright (c) Microsoft Corporation. All rights reserved.
1932
1932
  * Licensed under the MIT License.
@@ -2005,7 +2005,7 @@
2005
2005
  return updatedAccountInfo;
2006
2006
  }
2007
2007
 
2008
- /*! @azure/msal-common v15.1.0 2025-02-03 */
2008
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
2009
2009
  /*
2010
2010
  * Copyright (c) Microsoft Corporation. All rights reserved.
2011
2011
  * Licensed under the MIT License.
@@ -2020,7 +2020,7 @@
2020
2020
  Ciam: 3,
2021
2021
  };
2022
2022
 
2023
- /*! @azure/msal-common v15.1.0 2025-02-03 */
2023
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
2024
2024
  /*
2025
2025
  * Copyright (c) Microsoft Corporation. All rights reserved.
2026
2026
  * Licensed under the MIT License.
@@ -2042,7 +2042,7 @@
2042
2042
  return null;
2043
2043
  }
2044
2044
 
2045
- /*! @azure/msal-common v15.1.0 2025-02-03 */
2045
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
2046
2046
  /*
2047
2047
  * Copyright (c) Microsoft Corporation. All rights reserved.
2048
2048
  * Licensed under the MIT License.
@@ -2055,7 +2055,7 @@
2055
2055
  OIDC: "OIDC",
2056
2056
  };
2057
2057
 
2058
- /*! @azure/msal-common v15.1.0 2025-02-03 */
2058
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
2059
2059
 
2060
2060
  /*
2061
2061
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2298,7 +2298,7 @@
2298
2298
  }
2299
2299
  }
2300
2300
 
2301
- /*! @azure/msal-common v15.1.0 2025-02-03 */
2301
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
2302
2302
 
2303
2303
  /*
2304
2304
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2345,7 +2345,7 @@
2345
2345
  return null;
2346
2346
  }
2347
2347
 
2348
- /*! @azure/msal-common v15.1.0 2025-02-03 */
2348
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
2349
2349
 
2350
2350
  /*
2351
2351
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2509,7 +2509,7 @@
2509
2509
  }
2510
2510
  }
2511
2511
 
2512
- /*! @azure/msal-common v15.1.0 2025-02-03 */
2512
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
2513
2513
 
2514
2514
  /*
2515
2515
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2649,7 +2649,7 @@
2649
2649
  return null;
2650
2650
  }
2651
2651
 
2652
- /*! @azure/msal-common v15.1.0 2025-02-03 */
2652
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
2653
2653
  /*
2654
2654
  * Copyright (c) Microsoft Corporation. All rights reserved.
2655
2655
  * Licensed under the MIT License.
@@ -2657,7 +2657,7 @@
2657
2657
  const cacheQuotaExceededErrorCode = "cache_quota_exceeded";
2658
2658
  const cacheUnknownErrorCode = "cache_error_unknown";
2659
2659
 
2660
- /*! @azure/msal-common v15.1.0 2025-02-03 */
2660
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
2661
2661
 
2662
2662
  /*
2663
2663
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2684,7 +2684,7 @@
2684
2684
  }
2685
2685
  }
2686
2686
 
2687
- /*! @azure/msal-common v15.1.0 2025-02-03 */
2687
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
2688
2688
 
2689
2689
  /*
2690
2690
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3869,7 +3869,7 @@
3869
3869
  }
3870
3870
  }
3871
3871
 
3872
- /*! @azure/msal-common v15.1.0 2025-02-03 */
3872
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
3873
3873
 
3874
3874
  /*
3875
3875
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3968,7 +3968,7 @@
3968
3968
  return (config.authOptions.authority.options.protocolMode === ProtocolMode.OIDC);
3969
3969
  }
3970
3970
 
3971
- /*! @azure/msal-common v15.1.0 2025-02-03 */
3971
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
3972
3972
  /*
3973
3973
  * Copyright (c) Microsoft Corporation. All rights reserved.
3974
3974
  * Licensed under the MIT License.
@@ -3978,7 +3978,7 @@
3978
3978
  UPN: "UPN",
3979
3979
  };
3980
3980
 
3981
- /*! @azure/msal-common v15.1.0 2025-02-03 */
3981
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
3982
3982
  /*
3983
3983
  * Copyright (c) Microsoft Corporation. All rights reserved.
3984
3984
  * Licensed under the MIT License.
@@ -4028,7 +4028,7 @@
4028
4028
  const BROKER_CLIENT_ID = "brk_client_id";
4029
4029
  const BROKER_REDIRECT_URI = "brk_redirect_uri";
4030
4030
 
4031
- /*! @azure/msal-common v15.1.0 2025-02-03 */
4031
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
4032
4032
 
4033
4033
  /*
4034
4034
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4095,7 +4095,7 @@
4095
4095
  }
4096
4096
  }
4097
4097
 
4098
- /*! @azure/msal-common v15.1.0 2025-02-03 */
4098
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
4099
4099
 
4100
4100
  /*
4101
4101
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4503,7 +4503,7 @@
4503
4503
  }
4504
4504
  }
4505
4505
 
4506
- /*! @azure/msal-common v15.1.0 2025-02-03 */
4506
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
4507
4507
  /*
4508
4508
  * Copyright (c) Microsoft Corporation. All rights reserved.
4509
4509
  * Licensed under the MIT License.
@@ -4515,7 +4515,7 @@
4515
4515
  response.hasOwnProperty("jwks_uri"));
4516
4516
  }
4517
4517
 
4518
- /*! @azure/msal-common v15.1.0 2025-02-03 */
4518
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
4519
4519
  /*
4520
4520
  * Copyright (c) Microsoft Corporation. All rights reserved.
4521
4521
  * Licensed under the MIT License.
@@ -4525,7 +4525,7 @@
4525
4525
  response.hasOwnProperty("metadata"));
4526
4526
  }
4527
4527
 
4528
- /*! @azure/msal-common v15.1.0 2025-02-03 */
4528
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
4529
4529
  /*
4530
4530
  * Copyright (c) Microsoft Corporation. All rights reserved.
4531
4531
  * Licensed under the MIT License.
@@ -4535,7 +4535,7 @@
4535
4535
  response.hasOwnProperty("error_description"));
4536
4536
  }
4537
4537
 
4538
- /*! @azure/msal-common v15.1.0 2025-02-03 */
4538
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
4539
4539
  /*
4540
4540
  * Copyright (c) Microsoft Corporation. All rights reserved.
4541
4541
  * Licensed under the MIT License.
@@ -4773,6 +4773,7 @@
4773
4773
  CacheManagerGetRefreshToken: "cacheManagerGetRefreshToken",
4774
4774
  ImportExistingCache: "importExistingCache",
4775
4775
  SetUserData: "setUserData",
4776
+ LocalStorageUpdated: "localStorageUpdated",
4776
4777
  /**
4777
4778
  * Crypto Operations
4778
4779
  */
@@ -4874,6 +4875,7 @@
4874
4875
  [PerformanceEvents.InitializeCache, "InitCache"],
4875
4876
  [PerformanceEvents.ImportExistingCache, "importCache"],
4876
4877
  [PerformanceEvents.SetUserData, "setUserData"],
4878
+ [PerformanceEvents.LocalStorageUpdated, "localStorageUpdated"],
4877
4879
  [PerformanceEvents.SilentIframeClientTokenHelper, "SIClientTHelper"],
4878
4880
  [
4879
4881
  PerformanceEvents.SilentHandlerInitiateAuthRequest,
@@ -5042,7 +5044,7 @@
5042
5044
  "encryptedCacheExpiredCount",
5043
5045
  ]);
5044
5046
 
5045
- /*! @azure/msal-common v15.1.0 2025-02-03 */
5047
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
5046
5048
  /*
5047
5049
  * Copyright (c) Microsoft Corporation. All rights reserved.
5048
5050
  * Licensed under the MIT License.
@@ -5138,7 +5140,7 @@
5138
5140
  };
5139
5141
  };
5140
5142
 
5141
- /*! @azure/msal-common v15.1.0 2025-02-03 */
5143
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
5142
5144
 
5143
5145
  /*
5144
5146
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5247,7 +5249,7 @@
5247
5249
  },
5248
5250
  };
5249
5251
 
5250
- /*! @azure/msal-common v15.1.0 2025-02-03 */
5252
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
5251
5253
 
5252
5254
  /*
5253
5255
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6086,7 +6088,7 @@
6086
6088
  };
6087
6089
  }
6088
6090
 
6089
- /*! @azure/msal-common v15.1.0 2025-02-03 */
6091
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
6090
6092
 
6091
6093
  /*
6092
6094
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6117,7 +6119,7 @@
6117
6119
  }
6118
6120
  }
6119
6121
 
6120
- /*! @azure/msal-common v15.1.0 2025-02-03 */
6122
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
6121
6123
 
6122
6124
  /*
6123
6125
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6136,7 +6138,7 @@
6136
6138
  }
6137
6139
  }
6138
6140
 
6139
- /*! @azure/msal-common v15.1.0 2025-02-03 */
6141
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
6140
6142
 
6141
6143
  /*
6142
6144
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6234,7 +6236,7 @@
6234
6236
  }
6235
6237
  }
6236
6238
 
6237
- /*! @azure/msal-common v15.1.0 2025-02-03 */
6239
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
6238
6240
 
6239
6241
  /*
6240
6242
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6264,7 +6266,7 @@
6264
6266
  return new NetworkError(error, httpStatus, responseHeaders);
6265
6267
  }
6266
6268
 
6267
- /*! @azure/msal-common v15.1.0 2025-02-03 */
6269
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
6268
6270
 
6269
6271
  /*
6270
6272
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6414,7 +6416,7 @@
6414
6416
  }
6415
6417
  }
6416
6418
 
6417
- /*! @azure/msal-common v15.1.0 2025-02-03 */
6419
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
6418
6420
  /*
6419
6421
  * Copyright (c) Microsoft Corporation. All rights reserved.
6420
6422
  * Licensed under the MIT License.
@@ -6440,7 +6442,7 @@
6440
6442
  refreshTokenExpired: refreshTokenExpired
6441
6443
  });
6442
6444
 
6443
- /*! @azure/msal-common v15.1.0 2025-02-03 */
6445
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
6444
6446
 
6445
6447
  /*
6446
6448
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6528,7 +6530,7 @@
6528
6530
  return new InteractionRequiredAuthError(errorCode, InteractionRequiredAuthErrorMessages[errorCode]);
6529
6531
  }
6530
6532
 
6531
- /*! @azure/msal-common v15.1.0 2025-02-03 */
6533
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
6532
6534
 
6533
6535
  /*
6534
6536
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6600,7 +6602,7 @@
6600
6602
  }
6601
6603
  }
6602
6604
 
6603
- /*! @azure/msal-common v15.1.0 2025-02-03 */
6605
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
6604
6606
 
6605
6607
  /*
6606
6608
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6684,7 +6686,7 @@
6684
6686
  }
6685
6687
  }
6686
6688
 
6687
- /*! @azure/msal-common v15.1.0 2025-02-03 */
6689
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
6688
6690
  /*
6689
6691
  * Copyright (c) Microsoft Corporation. All rights reserved.
6690
6692
  * Licensed under the MIT License.
@@ -6711,7 +6713,7 @@
6711
6713
  }
6712
6714
  }
6713
6715
 
6714
- /*! @azure/msal-common v15.1.0 2025-02-03 */
6716
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
6715
6717
 
6716
6718
  /*
6717
6719
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7088,7 +7090,7 @@
7088
7090
  return baseAccount;
7089
7091
  }
7090
7092
 
7091
- /*! @azure/msal-common v15.1.0 2025-02-03 */
7093
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
7092
7094
  /*
7093
7095
  * Copyright (c) Microsoft Corporation. All rights reserved.
7094
7096
  * Licensed under the MIT License.
@@ -7106,7 +7108,7 @@
7106
7108
  }
7107
7109
  }
7108
7110
 
7109
- /*! @azure/msal-common v15.1.0 2025-02-03 */
7111
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
7110
7112
 
7111
7113
  /*
7112
7114
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7556,7 +7558,7 @@
7556
7558
  }
7557
7559
  }
7558
7560
 
7559
- /*! @azure/msal-common v15.1.0 2025-02-03 */
7561
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
7560
7562
 
7561
7563
  /*
7562
7564
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7779,7 +7781,7 @@
7779
7781
  }
7780
7782
  }
7781
7783
 
7782
- /*! @azure/msal-common v15.1.0 2025-02-03 */
7784
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
7783
7785
 
7784
7786
  /*
7785
7787
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7877,7 +7879,7 @@
7877
7879
  }
7878
7880
  }
7879
7881
 
7880
- /*! @azure/msal-common v15.1.0 2025-02-03 */
7882
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
7881
7883
 
7882
7884
  /*
7883
7885
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7892,7 +7894,7 @@
7892
7894
  },
7893
7895
  };
7894
7896
 
7895
- /*! @azure/msal-common v15.1.0 2025-02-03 */
7897
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
7896
7898
 
7897
7899
  /*
7898
7900
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7950,7 +7952,7 @@
7950
7952
  }
7951
7953
  }
7952
7954
 
7953
- /*! @azure/msal-common v15.1.0 2025-02-03 */
7955
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
7954
7956
 
7955
7957
  /*
7956
7958
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8213,7 +8215,7 @@
8213
8215
  }
8214
8216
  }
8215
8217
 
8216
- /*! @azure/msal-common v15.1.0 2025-02-03 */
8218
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
8217
8219
  /*
8218
8220
  * Copyright (c) Microsoft Corporation. All rights reserved.
8219
8221
  * Licensed under the MIT License.
@@ -8221,7 +8223,7 @@
8221
8223
  const missingKidError = "missing_kid_error";
8222
8224
  const missingAlgError = "missing_alg_error";
8223
8225
 
8224
- /*! @azure/msal-common v15.1.0 2025-02-03 */
8226
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
8225
8227
 
8226
8228
  /*
8227
8229
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8246,7 +8248,7 @@
8246
8248
  return new JoseHeaderError(code, JoseHeaderErrorMessages[code]);
8247
8249
  }
8248
8250
 
8249
- /*! @azure/msal-common v15.1.0 2025-02-03 */
8251
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
8250
8252
 
8251
8253
  /*
8252
8254
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8286,7 +8288,7 @@
8286
8288
  }
8287
8289
  }
8288
8290
 
8289
- /*! @azure/msal-common v15.1.0 2025-02-03 */
8291
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
8290
8292
 
8291
8293
  /*
8292
8294
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8365,7 +8367,7 @@
8365
8367
  }
8366
8368
  }
8367
8369
 
8368
- /*! @azure/msal-common v15.1.0 2025-02-03 */
8370
+ /*! @azure/msal-common v15.1.1 2025-02-11 */
8369
8371
 
8370
8372
  /*
8371
8373
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -10402,7 +10404,7 @@
10402
10404
 
10403
10405
  /* eslint-disable header/header */
10404
10406
  const name = "@azure/msal-browser";
10405
- const version = "4.1.0";
10407
+ const version = "4.2.1";
10406
10408
 
10407
10409
  /*
10408
10410
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -11335,6 +11337,10 @@
11335
11337
  */
11336
11338
  // Cookie life calculation (hours * minutes * seconds * ms)
11337
11339
  const COOKIE_LIFE_MULTIPLIER = 24 * 60 * 60 * 1000;
11340
+ const SameSiteOptions = {
11341
+ Lax: "Lax",
11342
+ None: "None",
11343
+ };
11338
11344
  class CookieStorage {
11339
11345
  initialize() {
11340
11346
  return Promise.resolve();
@@ -11355,13 +11361,14 @@
11355
11361
  getUserData() {
11356
11362
  throw createClientAuthError(methodNotImplemented);
11357
11363
  }
11358
- setItem(key, value, cookieLifeDays, secure = true) {
11359
- let cookieStr = `${encodeURIComponent(key)}=${encodeURIComponent(value)};path=/;SameSite=Lax;`;
11364
+ setItem(key, value, cookieLifeDays, secure = true, sameSite = SameSiteOptions.Lax) {
11365
+ let cookieStr = `${encodeURIComponent(key)}=${encodeURIComponent(value)};path=/;SameSite=${sameSite};`;
11360
11366
  if (cookieLifeDays) {
11361
11367
  const expireTime = getCookieExpirationTime(cookieLifeDays);
11362
11368
  cookieStr += `expires=${expireTime};`;
11363
11369
  }
11364
- if (secure) {
11370
+ if (secure || sameSite === SameSiteOptions.None) {
11371
+ // SameSite None requires Secure flag
11365
11372
  cookieStr += "Secure;";
11366
11373
  }
11367
11374
  document.cookie = cookieStr;
@@ -11441,6 +11448,7 @@
11441
11448
  * Licensed under the MIT License.
11442
11449
  */
11443
11450
  const ENCRYPTION_KEY = "msal.cache.encryption";
11451
+ const BROADCAST_CHANNEL_NAME$1 = "msal.broadcast.cache";
11444
11452
  class LocalStorage {
11445
11453
  constructor(clientId, logger, performanceClient) {
11446
11454
  if (!window.localStorage) {
@@ -11451,6 +11459,7 @@
11451
11459
  this.clientId = clientId;
11452
11460
  this.logger = logger;
11453
11461
  this.performanceClient = performanceClient;
11462
+ this.broadcast = new BroadcastChannel(BROADCAST_CHANNEL_NAME$1);
11454
11463
  }
11455
11464
  async initialize(correlationId) {
11456
11465
  this.initialized = true;
@@ -11486,8 +11495,13 @@
11486
11495
  id: id,
11487
11496
  key: keyStr,
11488
11497
  };
11489
- cookies.setItem(ENCRYPTION_KEY, JSON.stringify(cookieData));
11498
+ cookies.setItem(ENCRYPTION_KEY, JSON.stringify(cookieData), 0, // Expiration - 0 means cookie will be cleared at the end of the browser session
11499
+ true, // Secure flag
11500
+ SameSiteOptions.None // SameSite must be None to support iframed apps
11501
+ );
11490
11502
  }
11503
+ // Register listener for cache updates in other tabs
11504
+ this.broadcast.addEventListener("message", this.updateCache.bind(this));
11491
11505
  }
11492
11506
  getItem(key) {
11493
11507
  return window.localStorage.getItem(key);
@@ -11513,9 +11527,22 @@
11513
11527
  };
11514
11528
  this.memoryStorage.setItem(key, value);
11515
11529
  this.setItem(key, JSON.stringify(encryptedData));
11530
+ // Notify other frames to update their in-memory cache
11531
+ this.broadcast.postMessage({
11532
+ key: key,
11533
+ value: value,
11534
+ context: this.getContext(key),
11535
+ });
11516
11536
  }
11517
11537
  removeItem(key) {
11518
- this.memoryStorage.removeItem(key);
11538
+ if (this.memoryStorage.containsKey(key)) {
11539
+ this.memoryStorage.removeItem(key);
11540
+ this.broadcast.postMessage({
11541
+ key: key,
11542
+ value: null,
11543
+ context: this.getContext(key),
11544
+ });
11545
+ }
11519
11546
  window.localStorage.removeItem(key);
11520
11547
  }
11521
11548
  getKeys() {
@@ -11632,6 +11659,34 @@
11632
11659
  }
11633
11660
  return context;
11634
11661
  }
11662
+ updateCache(event) {
11663
+ this.logger.trace("Updating internal cache from broadcast event");
11664
+ const perfMeasurement = this.performanceClient.startMeasurement(PerformanceEvents.LocalStorageUpdated);
11665
+ perfMeasurement.add({ isBackground: true });
11666
+ const { key, value, context } = event.data;
11667
+ if (!key) {
11668
+ this.logger.error("Broadcast event missing key");
11669
+ perfMeasurement.end({ success: false, errorCode: "noKey" });
11670
+ return;
11671
+ }
11672
+ if (context && context !== this.clientId) {
11673
+ this.logger.trace(`Ignoring broadcast event from clientId: ${context}`);
11674
+ perfMeasurement.end({
11675
+ success: false,
11676
+ errorCode: "contextMismatch",
11677
+ });
11678
+ return;
11679
+ }
11680
+ if (!value) {
11681
+ this.memoryStorage.removeItem(key);
11682
+ this.logger.verbose("Removed item from internal cache");
11683
+ }
11684
+ else {
11685
+ this.memoryStorage.setItem(key, value);
11686
+ this.logger.verbose("Updated item in internal cache");
11687
+ }
11688
+ perfMeasurement.end({ success: true });
11689
+ }
11635
11690
  }
11636
11691
 
11637
11692
  /*
@@ -11692,6 +11747,39 @@
11692
11747
  }
11693
11748
  }
11694
11749
 
11750
+ /*
11751
+ * Copyright (c) Microsoft Corporation. All rights reserved.
11752
+ * Licensed under the MIT License.
11753
+ */
11754
+ const EventType = {
11755
+ INITIALIZE_START: "msal:initializeStart",
11756
+ INITIALIZE_END: "msal:initializeEnd",
11757
+ ACCOUNT_ADDED: "msal:accountAdded",
11758
+ ACCOUNT_REMOVED: "msal:accountRemoved",
11759
+ ACTIVE_ACCOUNT_CHANGED: "msal:activeAccountChanged",
11760
+ LOGIN_START: "msal:loginStart",
11761
+ LOGIN_SUCCESS: "msal:loginSuccess",
11762
+ LOGIN_FAILURE: "msal:loginFailure",
11763
+ ACQUIRE_TOKEN_START: "msal:acquireTokenStart",
11764
+ ACQUIRE_TOKEN_SUCCESS: "msal:acquireTokenSuccess",
11765
+ ACQUIRE_TOKEN_FAILURE: "msal:acquireTokenFailure",
11766
+ ACQUIRE_TOKEN_NETWORK_START: "msal:acquireTokenFromNetworkStart",
11767
+ SSO_SILENT_START: "msal:ssoSilentStart",
11768
+ SSO_SILENT_SUCCESS: "msal:ssoSilentSuccess",
11769
+ SSO_SILENT_FAILURE: "msal:ssoSilentFailure",
11770
+ ACQUIRE_TOKEN_BY_CODE_START: "msal:acquireTokenByCodeStart",
11771
+ ACQUIRE_TOKEN_BY_CODE_SUCCESS: "msal:acquireTokenByCodeSuccess",
11772
+ ACQUIRE_TOKEN_BY_CODE_FAILURE: "msal:acquireTokenByCodeFailure",
11773
+ HANDLE_REDIRECT_START: "msal:handleRedirectStart",
11774
+ HANDLE_REDIRECT_END: "msal:handleRedirectEnd",
11775
+ POPUP_OPENED: "msal:popupOpened",
11776
+ LOGOUT_START: "msal:logoutStart",
11777
+ LOGOUT_SUCCESS: "msal:logoutSuccess",
11778
+ LOGOUT_FAILURE: "msal:logoutFailure",
11779
+ LOGOUT_END: "msal:logoutEnd",
11780
+ RESTORE_FROM_BFCACHE: "msal:restoreFromBFCache",
11781
+ };
11782
+
11695
11783
  /*
11696
11784
  * Copyright (c) Microsoft Corporation. All rights reserved.
11697
11785
  * Licensed under the MIT License.
@@ -11702,7 +11790,7 @@
11702
11790
  * parameters such as state and nonce, generally.
11703
11791
  */
11704
11792
  class BrowserCacheManager extends CacheManager {
11705
- constructor(clientId, cacheConfig, cryptoImpl, logger, performanceClient, staticAuthorityOptions) {
11793
+ constructor(clientId, cacheConfig, cryptoImpl, logger, performanceClient, eventHandler, staticAuthorityOptions) {
11706
11794
  super(clientId, cryptoImpl, logger, staticAuthorityOptions);
11707
11795
  this.cacheConfig = cacheConfig;
11708
11796
  this.logger = logger;
@@ -11711,6 +11799,7 @@
11711
11799
  this.temporaryCacheStorage = getStorageImplementation(clientId, cacheConfig.temporaryCacheLocation, logger, performanceClient);
11712
11800
  this.cookieStorage = new CookieStorage();
11713
11801
  this.performanceClient = performanceClient;
11802
+ this.eventHandler = eventHandler;
11714
11803
  }
11715
11804
  async initialize(correlationId) {
11716
11805
  await this.browserStorage.initialize(correlationId);
@@ -11764,7 +11853,15 @@
11764
11853
  this.logger.trace("BrowserCacheManager.setAccount called");
11765
11854
  const key = account.generateAccountKey();
11766
11855
  await invokeAsync(this.browserStorage.setUserData.bind(this.browserStorage), PerformanceEvents.SetUserData, this.logger, this.performanceClient)(key, JSON.stringify(account), correlationId);
11767
- this.addAccountKeyToMap(key);
11856
+ const wasAdded = this.addAccountKeyToMap(key);
11857
+ /**
11858
+ * @deprecated - Remove this in next major version in favor of more consistent LOGIN event
11859
+ */
11860
+ if (this.cacheConfig.cacheLocation ===
11861
+ BrowserCacheLocation.LocalStorage &&
11862
+ wasAdded) {
11863
+ this.eventHandler.emitEvent(EventType.ACCOUNT_ADDED, undefined, account.getAccountInfo());
11864
+ }
11768
11865
  }
11769
11866
  /**
11770
11867
  * Returns the array of account keys currently cached
@@ -11786,9 +11883,11 @@
11786
11883
  accountKeys.push(key);
11787
11884
  this.browserStorage.setItem(StaticCacheKeys.ACCOUNT_KEYS, JSON.stringify(accountKeys));
11788
11885
  this.logger.verbose("BrowserCacheManager.addAccountKeyToMap account key added");
11886
+ return true;
11789
11887
  }
11790
11888
  else {
11791
11889
  this.logger.verbose("BrowserCacheManager.addAccountKeyToMap account key already exists in map");
11890
+ return false;
11792
11891
  }
11793
11892
  }
11794
11893
  /**
@@ -11817,6 +11916,19 @@
11817
11916
  void super.removeAccount(key);
11818
11917
  this.removeAccountKeyFromMap(key);
11819
11918
  }
11919
+ /**
11920
+ * Removes credentials associated with the provided account
11921
+ * @param account
11922
+ */
11923
+ async removeAccountContext(account) {
11924
+ await super.removeAccountContext(account);
11925
+ /**
11926
+ * @deprecated - Remove this in next major version in favor of more consistent LOGOUT event
11927
+ */
11928
+ if (this.cacheConfig.cacheLocation === BrowserCacheLocation.LocalStorage) {
11929
+ this.eventHandler.emitEvent(EventType.ACCOUNT_REMOVED, undefined, account.getAccountInfo());
11930
+ }
11931
+ }
11820
11932
  /**
11821
11933
  * Removes given idToken from the cache and from the key map
11822
11934
  * @param key
@@ -12171,6 +12283,7 @@
12171
12283
  this.logger.verbose("setActiveAccount: No account passed, active account not set");
12172
12284
  this.browserStorage.removeItem(activeAccountKey);
12173
12285
  }
12286
+ this.eventHandler.emitEvent(EventType.ACTIVE_ACCOUNT_CHANGED);
12174
12287
  }
12175
12288
  /**
12176
12289
  * fetch throttling entity from the platform cache
@@ -12628,7 +12741,7 @@
12628
12741
  }
12629
12742
  return new MemoryStorage();
12630
12743
  }
12631
- const DEFAULT_BROWSER_CACHE_MANAGER = (clientId, logger, performanceClient) => {
12744
+ const DEFAULT_BROWSER_CACHE_MANAGER = (clientId, logger, performanceClient, eventHandler) => {
12632
12745
  const cacheOptions = {
12633
12746
  cacheLocation: BrowserCacheLocation.MemoryStorage,
12634
12747
  temporaryCacheLocation: BrowserCacheLocation.MemoryStorage,
@@ -12637,7 +12750,7 @@
12637
12750
  cacheMigrationEnabled: false,
12638
12751
  claimsBasedCachingEnabled: false,
12639
12752
  };
12640
- return new BrowserCacheManager(clientId, cacheOptions, DEFAULT_CRYPTO_IMPLEMENTATION, logger, performanceClient);
12753
+ return new BrowserCacheManager(clientId, cacheOptions, DEFAULT_CRYPTO_IMPLEMENTATION, logger, performanceClient, eventHandler);
12641
12754
  };
12642
12755
 
12643
12756
  /*
@@ -12771,43 +12884,13 @@
12771
12884
  * Copyright (c) Microsoft Corporation. All rights reserved.
12772
12885
  * Licensed under the MIT License.
12773
12886
  */
12774
- const EventType = {
12775
- INITIALIZE_START: "msal:initializeStart",
12776
- INITIALIZE_END: "msal:initializeEnd",
12777
- ACCOUNT_ADDED: "msal:accountAdded",
12778
- ACCOUNT_REMOVED: "msal:accountRemoved",
12779
- ACTIVE_ACCOUNT_CHANGED: "msal:activeAccountChanged",
12780
- LOGIN_START: "msal:loginStart",
12781
- LOGIN_SUCCESS: "msal:loginSuccess",
12782
- LOGIN_FAILURE: "msal:loginFailure",
12783
- ACQUIRE_TOKEN_START: "msal:acquireTokenStart",
12784
- ACQUIRE_TOKEN_SUCCESS: "msal:acquireTokenSuccess",
12785
- ACQUIRE_TOKEN_FAILURE: "msal:acquireTokenFailure",
12786
- ACQUIRE_TOKEN_NETWORK_START: "msal:acquireTokenFromNetworkStart",
12787
- SSO_SILENT_START: "msal:ssoSilentStart",
12788
- SSO_SILENT_SUCCESS: "msal:ssoSilentSuccess",
12789
- SSO_SILENT_FAILURE: "msal:ssoSilentFailure",
12790
- ACQUIRE_TOKEN_BY_CODE_START: "msal:acquireTokenByCodeStart",
12791
- ACQUIRE_TOKEN_BY_CODE_SUCCESS: "msal:acquireTokenByCodeSuccess",
12792
- ACQUIRE_TOKEN_BY_CODE_FAILURE: "msal:acquireTokenByCodeFailure",
12793
- HANDLE_REDIRECT_START: "msal:handleRedirectStart",
12794
- HANDLE_REDIRECT_END: "msal:handleRedirectEnd",
12795
- POPUP_OPENED: "msal:popupOpened",
12796
- LOGOUT_START: "msal:logoutStart",
12797
- LOGOUT_SUCCESS: "msal:logoutSuccess",
12798
- LOGOUT_FAILURE: "msal:logoutFailure",
12799
- LOGOUT_END: "msal:logoutEnd",
12800
- RESTORE_FROM_BFCACHE: "msal:restoreFromBFCache",
12801
- };
12802
-
12803
- /*
12804
- * Copyright (c) Microsoft Corporation. All rights reserved.
12805
- * Licensed under the MIT License.
12806
- */
12887
+ const BROADCAST_CHANNEL_NAME = "msal.broadcast.event";
12807
12888
  class EventHandler {
12808
12889
  constructor(logger) {
12809
12890
  this.eventCallbacks = new Map();
12810
12891
  this.logger = logger || new Logger({});
12892
+ this.broadcastChannel = new BroadcastChannel(BROADCAST_CHANNEL_NAME);
12893
+ this.invokeCrossTabCallbacks = this.invokeCrossTabCallbacks.bind(this);
12811
12894
  }
12812
12895
  /**
12813
12896
  * Adds event callbacks to array
@@ -12844,23 +12927,59 @@
12844
12927
  * @param error
12845
12928
  */
12846
12929
  emitEvent(eventType, interactionType, payload, error) {
12847
- if (typeof window !== "undefined") {
12848
- const message = {
12849
- eventType: eventType,
12850
- interactionType: interactionType || null,
12851
- payload: payload || null,
12852
- error: error || null,
12853
- timestamp: Date.now(),
12854
- };
12855
- this.eventCallbacks.forEach(([callback, eventTypes], callbackId) => {
12856
- if (eventTypes.length === 0 ||
12857
- eventTypes.includes(eventType)) {
12858
- this.logger.verbose(`Emitting event to callback ${callbackId}: ${eventType}`);
12859
- callback.apply(null, [message]);
12860
- }
12861
- });
12930
+ const message = {
12931
+ eventType: eventType,
12932
+ interactionType: interactionType || null,
12933
+ payload: payload || null,
12934
+ error: error || null,
12935
+ timestamp: Date.now(),
12936
+ };
12937
+ switch (eventType) {
12938
+ case EventType.ACCOUNT_ADDED:
12939
+ case EventType.ACCOUNT_REMOVED:
12940
+ case EventType.ACTIVE_ACCOUNT_CHANGED:
12941
+ // Send event to other open tabs / MSAL instances on same domain
12942
+ this.broadcastChannel.postMessage(message);
12943
+ break;
12944
+ default:
12945
+ // Emit event to callbacks registered in this instance
12946
+ this.invokeCallbacks(message);
12947
+ break;
12862
12948
  }
12863
12949
  }
12950
+ /**
12951
+ * Invoke registered callbacks
12952
+ * @param message
12953
+ */
12954
+ invokeCallbacks(message) {
12955
+ this.eventCallbacks.forEach(([callback, eventTypes], callbackId) => {
12956
+ if (eventTypes.length === 0 ||
12957
+ eventTypes.includes(message.eventType)) {
12958
+ this.logger.verbose(`Emitting event to callback ${callbackId}: ${message.eventType}`);
12959
+ callback.apply(null, [message]);
12960
+ }
12961
+ });
12962
+ }
12963
+ /**
12964
+ * Wrapper around invokeCallbacks to handle broadcast events received from other tabs/instances
12965
+ * @param event
12966
+ */
12967
+ invokeCrossTabCallbacks(event) {
12968
+ const message = event.data;
12969
+ this.invokeCallbacks(message);
12970
+ }
12971
+ /**
12972
+ * Listen for events broadcasted from other tabs/instances
12973
+ */
12974
+ subscribeCrossTab() {
12975
+ this.broadcastChannel.addEventListener("message", this.invokeCrossTabCallbacks);
12976
+ }
12977
+ /**
12978
+ * Unsubscribe from broadcast events
12979
+ */
12980
+ unsubscribeCrossTab() {
12981
+ this.broadcastChannel.removeEventListener("message", this.invokeCrossTabCallbacks);
12982
+ }
12864
12983
  }
12865
12984
 
12866
12985
  /*
@@ -16033,8 +16152,8 @@
16033
16152
  this.eventHandler = new EventHandler(this.logger);
16034
16153
  // Initialize the browser storage class.
16035
16154
  this.browserStorage = this.isBrowserEnvironment
16036
- ? new BrowserCacheManager(this.config.auth.clientId, this.config.cache, this.browserCrypto, this.logger, this.performanceClient, buildStaticAuthorityOptions(this.config.auth))
16037
- : DEFAULT_BROWSER_CACHE_MANAGER(this.config.auth.clientId, this.logger, this.performanceClient);
16155
+ ? new BrowserCacheManager(this.config.auth.clientId, this.config.cache, this.browserCrypto, this.logger, this.performanceClient, this.eventHandler, buildStaticAuthorityOptions(this.config.auth))
16156
+ : DEFAULT_BROWSER_CACHE_MANAGER(this.config.auth.clientId, this.logger, this.performanceClient, this.eventHandler);
16038
16157
  // initialize in memory storage for native flows
16039
16158
  const nativeCacheOptions = {
16040
16159
  cacheLocation: BrowserCacheLocation.MemoryStorage,
@@ -16044,7 +16163,7 @@
16044
16163
  cacheMigrationEnabled: false,
16045
16164
  claimsBasedCachingEnabled: false,
16046
16165
  };
16047
- this.nativeInternalStorage = new BrowserCacheManager(this.config.auth.clientId, nativeCacheOptions, this.browserCrypto, this.logger, this.performanceClient);
16166
+ this.nativeInternalStorage = new BrowserCacheManager(this.config.auth.clientId, nativeCacheOptions, this.browserCrypto, this.logger, this.performanceClient, this.eventHandler);
16048
16167
  // Initialize the token cache
16049
16168
  this.tokenCache = new TokenCache(this.config, this.browserStorage, this.logger, this.browserCrypto);
16050
16169
  this.activeSilentTokenRequests = new Map();
@@ -16053,10 +16172,6 @@
16053
16172
  // Register listener functions
16054
16173
  this.trackPageVisibilityWithMeasurement =
16055
16174
  this.trackPageVisibilityWithMeasurement.bind(this);
16056
- // account storage events
16057
- this.listeningToStorageEvents = false;
16058
- this.handleAccountCacheChange =
16059
- this.handleAccountCacheChange.bind(this);
16060
16175
  }
16061
16176
  static async createController(operatingContext, request) {
16062
16177
  const controller = new StandardController(operatingContext);
@@ -16955,70 +17070,27 @@
16955
17070
  }
16956
17071
  /**
16957
17072
  * Adds event listener that emits an event when a user account is added or removed from localstorage in a different browser tab or window
17073
+ * @deprecated These events will be raised by default and this method will be removed in a future major version.
16958
17074
  */
16959
17075
  enableAccountStorageEvents() {
16960
- if (typeof window === "undefined") {
17076
+ if (this.config.cache.cacheLocation !==
17077
+ BrowserCacheLocation.LocalStorage) {
17078
+ this.logger.info("Account storage events are only available when cacheLocation is set to localStorage");
16961
17079
  return;
16962
17080
  }
16963
- if (!this.listeningToStorageEvents) {
16964
- this.logger.verbose("Adding account storage listener.");
16965
- this.listeningToStorageEvents = true;
16966
- window.addEventListener("storage", this.handleAccountCacheChange);
16967
- }
16968
- else {
16969
- this.logger.verbose("Account storage listener already registered.");
16970
- }
17081
+ this.eventHandler.subscribeCrossTab();
16971
17082
  }
16972
17083
  /**
16973
17084
  * Removes event listener that emits an event when a user account is added or removed from localstorage in a different browser tab or window
17085
+ * @deprecated These events will be raised by default and this method will be removed in a future major version.
16974
17086
  */
16975
17087
  disableAccountStorageEvents() {
16976
- if (typeof window === "undefined") {
16977
- return;
16978
- }
16979
- if (this.listeningToStorageEvents) {
16980
- this.logger.verbose("Removing account storage listener.");
16981
- window.removeEventListener("storage", this.handleAccountCacheChange);
16982
- this.listeningToStorageEvents = false;
16983
- }
16984
- else {
16985
- this.logger.verbose("No account storage listener registered.");
16986
- }
16987
- }
16988
- /**
16989
- * Emit account added/removed events when cached accounts are changed in a different tab or frame
16990
- */
16991
- handleAccountCacheChange(e) {
16992
- try {
16993
- // Handle active account filter change
16994
- if (e.key?.includes(PersistentCacheKeys.ACTIVE_ACCOUNT_FILTERS)) {
16995
- // This event has no payload, it only signals cross-tab app instances that the results of calling getActiveAccount() will have changed
16996
- this.eventHandler.emitEvent(EventType.ACTIVE_ACCOUNT_CHANGED);
16997
- }
16998
- // Handle account object change
16999
- const cacheValue = e.newValue || e.oldValue;
17000
- if (!cacheValue) {
17001
- return;
17002
- }
17003
- const parsedValue = JSON.parse(cacheValue);
17004
- if (typeof parsedValue !== "object" ||
17005
- !AccountEntity.isAccountEntity(parsedValue)) {
17006
- return;
17007
- }
17008
- const accountEntity = CacheManager.toObject(new AccountEntity(), parsedValue);
17009
- const accountInfo = accountEntity.getAccountInfo();
17010
- if (!e.oldValue && e.newValue) {
17011
- this.logger.info("Account was added to cache in a different window");
17012
- this.eventHandler.emitEvent(EventType.ACCOUNT_ADDED, undefined, accountInfo);
17013
- }
17014
- else if (!e.newValue && e.oldValue) {
17015
- this.logger.info("Account was removed from cache in a different window");
17016
- this.eventHandler.emitEvent(EventType.ACCOUNT_REMOVED, undefined, accountInfo);
17017
- }
17018
- }
17019
- catch (e) {
17088
+ if (this.config.cache.cacheLocation !==
17089
+ BrowserCacheLocation.LocalStorage) {
17090
+ this.logger.info("Account storage events are only available when cacheLocation is set to localStorage");
17020
17091
  return;
17021
17092
  }
17093
+ this.eventHandler.unsubscribeCrossTab();
17022
17094
  }
17023
17095
  /**
17024
17096
  * Gets the token cache for the application.
@@ -17591,11 +17663,11 @@
17591
17663
  this.browserCrypto = operatingContext.isBrowserEnvironment()
17592
17664
  ? new CryptoOps(this.logger, this.performanceClient, true)
17593
17665
  : DEFAULT_CRYPTO_IMPLEMENTATION;
17666
+ this.eventHandler = new EventHandler(this.logger);
17594
17667
  // Initialize the browser storage class.
17595
17668
  this.browserStorage = this.operatingContext.isBrowserEnvironment()
17596
- ? new BrowserCacheManager(this.config.auth.clientId, this.config.cache, this.browserCrypto, this.logger, this.performanceClient, buildStaticAuthorityOptions(this.config.auth))
17597
- : DEFAULT_BROWSER_CACHE_MANAGER(this.config.auth.clientId, this.logger, this.performanceClient);
17598
- this.eventHandler = new EventHandler(this.logger);
17669
+ ? new BrowserCacheManager(this.config.auth.clientId, this.config.cache, this.browserCrypto, this.logger, this.performanceClient, this.eventHandler, buildStaticAuthorityOptions(this.config.auth))
17670
+ : DEFAULT_BROWSER_CACHE_MANAGER(this.config.auth.clientId, this.logger, this.performanceClient, this.eventHandler);
17599
17671
  this.nestedAppAuthAdapter = new NestedAppAuthAdapter(this.config.auth.clientId, this.config.auth.clientCapabilities, this.browserCrypto, this.logger);
17600
17672
  // Set the active account if available
17601
17673
  const accountContext = this.bridgeProxy.getAccountContext();
@@ -17670,7 +17742,9 @@
17670
17742
  return result;
17671
17743
  }
17672
17744
  catch (e) {
17673
- const error = this.nestedAppAuthAdapter.fromBridgeError(e);
17745
+ const error = e instanceof AuthError
17746
+ ? e
17747
+ : this.nestedAppAuthAdapter.fromBridgeError(e);
17674
17748
  this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_FAILURE, exports.InteractionType.Popup, null, e);
17675
17749
  atPopupMeasurement.end({
17676
17750
  success: false,
@@ -17725,7 +17799,9 @@
17725
17799
  return result;
17726
17800
  }
17727
17801
  catch (e) {
17728
- const error = this.nestedAppAuthAdapter.fromBridgeError(e);
17802
+ const error = e instanceof AuthError
17803
+ ? e
17804
+ : this.nestedAppAuthAdapter.fromBridgeError(e);
17729
17805
  this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_FAILURE, exports.InteractionType.Silent, null, e);
17730
17806
  ssoSilentMeasurement?.end({
17731
17807
  success: false,
@@ -18491,10 +18567,11 @@
18491
18567
  this.browserCrypto = this.isBrowserEnvironment
18492
18568
  ? new CryptoOps(this.logger, this.performanceClient)
18493
18569
  : DEFAULT_CRYPTO_IMPLEMENTATION;
18570
+ this.eventHandler = new EventHandler(this.logger);
18494
18571
  // Initialize the browser storage class.
18495
18572
  this.browserStorage = this.isBrowserEnvironment
18496
- ? new BrowserCacheManager(this.config.auth.clientId, this.config.cache, this.browserCrypto, this.logger, this.performanceClient, undefined)
18497
- : DEFAULT_BROWSER_CACHE_MANAGER(this.config.auth.clientId, this.logger, this.performanceClient);
18573
+ ? new BrowserCacheManager(this.config.auth.clientId, this.config.cache, this.browserCrypto, this.logger, this.performanceClient, this.eventHandler, undefined)
18574
+ : DEFAULT_BROWSER_CACHE_MANAGER(this.config.auth.clientId, this.logger, this.performanceClient, this.eventHandler);
18498
18575
  }
18499
18576
  getBrowserStorage() {
18500
18577
  return this.browserStorage;