@azure/msal-browser 3.11.1 → 3.14.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 (110) hide show
  1. package/dist/app/IPublicClientApplication.d.ts +2 -1
  2. package/dist/app/IPublicClientApplication.d.ts.map +1 -1
  3. package/dist/app/IPublicClientApplication.mjs +4 -1
  4. package/dist/app/IPublicClientApplication.mjs.map +1 -1
  5. package/dist/app/PublicClientApplication.mjs +1 -1
  6. package/dist/app/PublicClientNext.mjs +1 -1
  7. package/dist/broker/nativeBroker/NativeMessageHandler.mjs +1 -1
  8. package/dist/broker/nativeBroker/NativeStatusCodes.mjs +1 -1
  9. package/dist/cache/AsyncMemoryStorage.mjs +1 -1
  10. package/dist/cache/BrowserCacheManager.d.ts +10 -2
  11. package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
  12. package/dist/cache/BrowserCacheManager.mjs +31 -3
  13. package/dist/cache/BrowserCacheManager.mjs.map +1 -1
  14. package/dist/cache/BrowserStorage.mjs +1 -1
  15. package/dist/cache/DatabaseStorage.mjs +1 -1
  16. package/dist/cache/MemoryStorage.mjs +1 -1
  17. package/dist/cache/TokenCache.mjs +1 -1
  18. package/dist/config/Configuration.mjs +1 -1
  19. package/dist/controllers/ControllerFactory.d.ts.map +1 -1
  20. package/dist/controllers/ControllerFactory.mjs +2 -3
  21. package/dist/controllers/ControllerFactory.mjs.map +1 -1
  22. package/dist/controllers/NestedAppAuthController.d.ts.map +1 -1
  23. package/dist/controllers/NestedAppAuthController.mjs +3 -8
  24. package/dist/controllers/NestedAppAuthController.mjs.map +1 -1
  25. package/dist/controllers/StandardController.d.ts +14 -0
  26. package/dist/controllers/StandardController.d.ts.map +1 -1
  27. package/dist/controllers/StandardController.mjs +213 -117
  28. package/dist/controllers/StandardController.mjs.map +1 -1
  29. package/dist/controllers/UnknownOperatingContextController.d.ts.map +1 -1
  30. package/dist/controllers/UnknownOperatingContextController.mjs +2 -2
  31. package/dist/controllers/UnknownOperatingContextController.mjs.map +1 -1
  32. package/dist/crypto/BrowserCrypto.mjs +1 -1
  33. package/dist/crypto/CryptoOps.mjs +1 -1
  34. package/dist/crypto/PkceGenerator.mjs +1 -1
  35. package/dist/crypto/SignedHttpRequest.mjs +1 -1
  36. package/dist/encode/Base64Decode.mjs +1 -1
  37. package/dist/encode/Base64Encode.mjs +1 -1
  38. package/dist/error/BrowserAuthError.mjs +1 -1
  39. package/dist/error/BrowserAuthErrorCodes.mjs +1 -1
  40. package/dist/error/BrowserConfigurationAuthError.mjs +1 -1
  41. package/dist/error/BrowserConfigurationAuthErrorCodes.mjs +1 -1
  42. package/dist/error/NativeAuthError.mjs +1 -1
  43. package/dist/error/NativeAuthErrorCodes.mjs +1 -1
  44. package/dist/error/NestedAppAuthError.mjs +1 -1
  45. package/dist/event/EventHandler.mjs +1 -1
  46. package/dist/event/EventMessage.mjs +1 -1
  47. package/dist/event/EventType.mjs +1 -1
  48. package/dist/index.mjs +1 -1
  49. package/dist/interaction_client/BaseInteractionClient.mjs +1 -1
  50. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
  51. package/dist/interaction_client/NativeInteractionClient.mjs +1 -1
  52. package/dist/interaction_client/PopupClient.mjs +1 -1
  53. package/dist/interaction_client/RedirectClient.d.ts +4 -5
  54. package/dist/interaction_client/RedirectClient.d.ts.map +1 -1
  55. package/dist/interaction_client/RedirectClient.mjs +5 -8
  56. package/dist/interaction_client/RedirectClient.mjs.map +1 -1
  57. package/dist/interaction_client/SilentAuthCodeClient.mjs +1 -1
  58. package/dist/interaction_client/SilentCacheClient.mjs +1 -1
  59. package/dist/interaction_client/SilentIframeClient.mjs +1 -1
  60. package/dist/interaction_client/SilentRefreshClient.mjs +1 -1
  61. package/dist/interaction_client/StandardInteractionClient.mjs +1 -1
  62. package/dist/interaction_handler/InteractionHandler.mjs +1 -1
  63. package/dist/interaction_handler/RedirectHandler.mjs +1 -1
  64. package/dist/interaction_handler/SilentHandler.mjs +2 -1
  65. package/dist/interaction_handler/SilentHandler.mjs.map +1 -1
  66. package/dist/naa/BridgeError.mjs +1 -1
  67. package/dist/naa/BridgeProxy.d.ts +0 -2
  68. package/dist/naa/BridgeProxy.d.ts.map +1 -1
  69. package/dist/naa/BridgeProxy.mjs +4 -10
  70. package/dist/naa/BridgeProxy.mjs.map +1 -1
  71. package/dist/naa/BridgeStatusCode.mjs +1 -1
  72. package/dist/naa/mapping/NestedAppAuthAdapter.mjs +1 -1
  73. package/dist/navigation/NavigationClient.mjs +1 -1
  74. package/dist/network/FetchClient.mjs +1 -1
  75. package/dist/operatingcontext/BaseOperatingContext.mjs +1 -1
  76. package/dist/operatingcontext/StandardOperatingContext.mjs +1 -1
  77. package/dist/operatingcontext/TeamsAppOperatingContext.d.ts.map +1 -1
  78. package/dist/operatingcontext/TeamsAppOperatingContext.mjs +10 -11
  79. package/dist/operatingcontext/TeamsAppOperatingContext.mjs.map +1 -1
  80. package/dist/operatingcontext/UnknownOperatingContext.mjs +1 -1
  81. package/dist/packageMetadata.d.ts +1 -1
  82. package/dist/packageMetadata.mjs +2 -2
  83. package/dist/request/RequestHelpers.mjs +1 -1
  84. package/dist/response/ResponseHandler.mjs +1 -1
  85. package/dist/telemetry/BrowserPerformanceClient.mjs +1 -1
  86. package/dist/telemetry/BrowserPerformanceMeasurement.mjs +1 -1
  87. package/dist/utils/BrowserConstants.mjs +1 -1
  88. package/dist/utils/BrowserProtocolUtils.mjs +1 -1
  89. package/dist/utils/BrowserUtils.d.ts +3 -0
  90. package/dist/utils/BrowserUtils.d.ts.map +1 -1
  91. package/dist/utils/BrowserUtils.mjs +2 -1
  92. package/dist/utils/BrowserUtils.mjs.map +1 -1
  93. package/lib/msal-browser.cjs +486 -257
  94. package/lib/msal-browser.cjs.map +1 -1
  95. package/lib/msal-browser.js +486 -257
  96. package/lib/msal-browser.js.map +1 -1
  97. package/lib/msal-browser.min.js +68 -66
  98. package/package.json +4 -4
  99. package/src/app/IPublicClientApplication.ts +5 -0
  100. package/src/cache/BrowserCacheManager.ts +49 -1
  101. package/src/controllers/ControllerFactory.ts +1 -4
  102. package/src/controllers/NestedAppAuthController.ts +7 -6
  103. package/src/controllers/StandardController.ts +380 -263
  104. package/src/controllers/UnknownOperatingContextController.ts +3 -1
  105. package/src/interaction_client/RedirectClient.ts +6 -12
  106. package/src/interaction_handler/SilentHandler.ts +1 -0
  107. package/src/naa/BridgeProxy.ts +3 -12
  108. package/src/operatingcontext/TeamsAppOperatingContext.ts +14 -8
  109. package/src/packageMetadata.ts +1 -1
  110. package/src/utils/BrowserUtils.ts +4 -1
@@ -1,4 +1,4 @@
1
- /*! @azure/msal-browser v3.11.1 2024-03-27 */
1
+ /*! @azure/msal-browser v3.14.0 2024-05-07 */
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 v14.8.1 2024-03-27 */
9
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
10
10
  /*
11
11
  * Copyright (c) Microsoft Corporation. All rights reserved.
12
12
  * Licensed under the MIT License.
@@ -70,13 +70,24 @@
70
70
  INVALID_INSTANCE: "invalid_instance",
71
71
  };
72
72
  const HttpStatus = {
73
+ SUCCESS: 200,
73
74
  SUCCESS_RANGE_START: 200,
74
75
  SUCCESS_RANGE_END: 299,
75
76
  REDIRECT: 302,
77
+ CLIENT_ERROR: 400,
76
78
  CLIENT_ERROR_RANGE_START: 400,
79
+ BAD_REQUEST: 400,
80
+ UNAUTHORIZED: 401,
81
+ NOT_FOUND: 404,
82
+ REQUEST_TIMEOUT: 408,
83
+ TOO_MANY_REQUESTS: 429,
77
84
  CLIENT_ERROR_RANGE_END: 499,
85
+ SERVER_ERROR: 500,
78
86
  SERVER_ERROR_RANGE_START: 500,
87
+ SERVICE_UNAVAILABLE: 503,
88
+ GATEWAY_TIMEOUT: 504,
79
89
  SERVER_ERROR_RANGE_END: 599,
90
+ MULTI_SIDED_ERROR: 600,
80
91
  };
81
92
  const OIDC_DEFAULT_SCOPES = [
82
93
  Constants.OPENID_SCOPE,
@@ -300,8 +311,10 @@
300
311
  Jwk: "JWK",
301
312
  Pop: "pop",
302
313
  };
314
+ // Token renewal offset default in seconds
315
+ const DEFAULT_TOKEN_RENEWAL_OFFSET_SEC = 300;
303
316
 
304
- /*! @azure/msal-common v14.8.1 2024-03-27 */
317
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
305
318
  /*
306
319
  * Copyright (c) Microsoft Corporation. All rights reserved.
307
320
  * Licensed under the MIT License.
@@ -318,7 +331,7 @@
318
331
  unexpectedError: unexpectedError
319
332
  });
320
333
 
321
- /*! @azure/msal-common v14.8.1 2024-03-27 */
334
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
322
335
 
323
336
  /*
324
337
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -367,7 +380,7 @@
367
380
  : AuthErrorMessages[code]);
368
381
  }
369
382
 
370
- /*! @azure/msal-common v14.8.1 2024-03-27 */
383
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
371
384
  /*
372
385
  * Copyright (c) Microsoft Corporation. All rights reserved.
373
386
  * Licensed under the MIT License.
@@ -465,7 +478,7 @@
465
478
  userTimeoutReached: userTimeoutReached
466
479
  });
467
480
 
468
- /*! @azure/msal-common v14.8.1 2024-03-27 */
481
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
469
482
 
470
483
  /*
471
484
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -717,7 +730,7 @@
717
730
  return new ClientAuthError(errorCode, additionalMessage);
718
731
  }
719
732
 
720
- /*! @azure/msal-common v14.8.1 2024-03-27 */
733
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
721
734
 
722
735
  /*
723
736
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -750,7 +763,7 @@
750
763
  },
751
764
  };
752
765
 
753
- /*! @azure/msal-common v14.8.1 2024-03-27 */
766
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
754
767
 
755
768
  /*
756
769
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -941,12 +954,12 @@
941
954
  }
942
955
  }
943
956
 
944
- /*! @azure/msal-common v14.8.1 2024-03-27 */
957
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
945
958
  /* eslint-disable header/header */
946
959
  const name$1 = "@azure/msal-common";
947
- const version$1 = "14.8.1";
960
+ const version$1 = "14.10.0";
948
961
 
949
- /*! @azure/msal-common v14.8.1 2024-03-27 */
962
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
950
963
  /*
951
964
  * Copyright (c) Microsoft Corporation. All rights reserved.
952
965
  * Licensed under the MIT License.
@@ -966,7 +979,7 @@
966
979
  AzureUsGovernment: "https://login.microsoftonline.us",
967
980
  };
968
981
 
969
- /*! @azure/msal-common v14.8.1 2024-03-27 */
982
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
970
983
 
971
984
  /*
972
985
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1027,7 +1040,7 @@
1027
1040
  }
1028
1041
  }
1029
1042
 
1030
- /*! @azure/msal-common v14.8.1 2024-03-27 */
1043
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
1031
1044
  /*
1032
1045
  * Copyright (c) Microsoft Corporation. All rights reserved.
1033
1046
  * Licensed under the MIT License.
@@ -1064,7 +1077,7 @@
1064
1077
  return cachedAtSec > nowSeconds();
1065
1078
  }
1066
1079
 
1067
- /*! @azure/msal-common v14.8.1 2024-03-27 */
1080
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
1068
1081
 
1069
1082
  /*
1070
1083
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1391,7 +1404,7 @@
1391
1404
  return metadata.expiresAt <= nowSeconds();
1392
1405
  }
1393
1406
 
1394
- /*! @azure/msal-common v14.8.1 2024-03-27 */
1407
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
1395
1408
  /*
1396
1409
  * Copyright (c) Microsoft Corporation. All rights reserved.
1397
1410
  * Licensed under the MIT License.
@@ -1445,7 +1458,7 @@
1445
1458
  urlParseError: urlParseError
1446
1459
  });
1447
1460
 
1448
- /*! @azure/msal-common v14.8.1 2024-03-27 */
1461
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
1449
1462
 
1450
1463
  /*
1451
1464
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1583,7 +1596,7 @@
1583
1596
  return new ClientConfigurationError(errorCode);
1584
1597
  }
1585
1598
 
1586
- /*! @azure/msal-common v14.8.1 2024-03-27 */
1599
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
1587
1600
  /*
1588
1601
  * Copyright (c) Microsoft Corporation. All rights reserved.
1589
1602
  * Licensed under the MIT License.
@@ -1680,7 +1693,7 @@
1680
1693
  }
1681
1694
  }
1682
1695
 
1683
- /*! @azure/msal-common v14.8.1 2024-03-27 */
1696
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
1684
1697
 
1685
1698
  /*
1686
1699
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1880,7 +1893,7 @@
1880
1893
  }
1881
1894
  }
1882
1895
 
1883
- /*! @azure/msal-common v14.8.1 2024-03-27 */
1896
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
1884
1897
 
1885
1898
  /*
1886
1899
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1920,7 +1933,7 @@
1920
1933
  };
1921
1934
  }
1922
1935
 
1923
- /*! @azure/msal-common v14.8.1 2024-03-27 */
1936
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
1924
1937
  /*
1925
1938
  * Copyright (c) Microsoft Corporation. All rights reserved.
1926
1939
  * Licensed under the MIT License.
@@ -1982,7 +1995,7 @@
1982
1995
  return updatedAccountInfo;
1983
1996
  }
1984
1997
 
1985
- /*! @azure/msal-common v14.8.1 2024-03-27 */
1998
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
1986
1999
  /*
1987
2000
  * Copyright (c) Microsoft Corporation. All rights reserved.
1988
2001
  * Licensed under the MIT License.
@@ -1997,7 +2010,7 @@
1997
2010
  Ciam: 3,
1998
2011
  };
1999
2012
 
2000
- /*! @azure/msal-common v14.8.1 2024-03-27 */
2013
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
2001
2014
  /*
2002
2015
  * Copyright (c) Microsoft Corporation. All rights reserved.
2003
2016
  * Licensed under the MIT License.
@@ -2019,7 +2032,7 @@
2019
2032
  return null;
2020
2033
  }
2021
2034
 
2022
- /*! @azure/msal-common v14.8.1 2024-03-27 */
2035
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
2023
2036
  /*
2024
2037
  * Copyright (c) Microsoft Corporation. All rights reserved.
2025
2038
  * Licensed under the MIT License.
@@ -2032,7 +2045,7 @@
2032
2045
  OIDC: "OIDC",
2033
2046
  };
2034
2047
 
2035
- /*! @azure/msal-common v14.8.1 2024-03-27 */
2048
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
2036
2049
 
2037
2050
  /*
2038
2051
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2279,7 +2292,7 @@
2279
2292
  }
2280
2293
  }
2281
2294
 
2282
- /*! @azure/msal-common v14.8.1 2024-03-27 */
2295
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
2283
2296
 
2284
2297
  /*
2285
2298
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2326,7 +2339,7 @@
2326
2339
  return null;
2327
2340
  }
2328
2341
 
2329
- /*! @azure/msal-common v14.8.1 2024-03-27 */
2342
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
2330
2343
 
2331
2344
  /*
2332
2345
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2490,7 +2503,7 @@
2490
2503
  }
2491
2504
  }
2492
2505
 
2493
- /*! @azure/msal-common v14.8.1 2024-03-27 */
2506
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
2494
2507
 
2495
2508
  /*
2496
2509
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2630,7 +2643,42 @@
2630
2643
  return null;
2631
2644
  }
2632
2645
 
2633
- /*! @azure/msal-common v14.8.1 2024-03-27 */
2646
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
2647
+ /*
2648
+ * Copyright (c) Microsoft Corporation. All rights reserved.
2649
+ * Licensed under the MIT License.
2650
+ */
2651
+ const cacheQuotaExceededErrorCode = "cache_quota_exceeded";
2652
+ const cacheUnknownErrorCode = "cache_error_unknown";
2653
+
2654
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
2655
+
2656
+ /*
2657
+ * Copyright (c) Microsoft Corporation. All rights reserved.
2658
+ * Licensed under the MIT License.
2659
+ */
2660
+ const CacheErrorMessages = {
2661
+ [cacheQuotaExceededErrorCode]: "Exceeded cache storage capacity.",
2662
+ [cacheUnknownErrorCode]: "Unexpected error occurred when using cache storage.",
2663
+ };
2664
+ /**
2665
+ * Error thrown when there is an error with the cache
2666
+ */
2667
+ class CacheError extends Error {
2668
+ constructor(errorCode, errorMessage) {
2669
+ const message = errorMessage ||
2670
+ (CacheErrorMessages[errorCode]
2671
+ ? CacheErrorMessages[errorCode]
2672
+ : CacheErrorMessages[cacheUnknownErrorCode]);
2673
+ super(`${errorCode}: ${message}`);
2674
+ Object.setPrototypeOf(this, CacheError.prototype);
2675
+ this.name = "CacheError";
2676
+ this.errorCode = errorCode;
2677
+ this.errorMessage = message;
2678
+ }
2679
+ }
2680
+
2681
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
2634
2682
 
2635
2683
  /*
2636
2684
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2794,27 +2842,51 @@
2794
2842
  }
2795
2843
  /**
2796
2844
  * saves a cache record
2797
- * @param cacheRecord
2845
+ * @param cacheRecord {CacheRecord}
2846
+ * @param storeInCache {?StoreInCache}
2847
+ * @param correlationId {?string} correlation id
2798
2848
  */
2799
- async saveCacheRecord(cacheRecord, storeInCache) {
2849
+ async saveCacheRecord(cacheRecord, storeInCache, correlationId) {
2800
2850
  if (!cacheRecord) {
2801
2851
  throw createClientAuthError(invalidCacheRecord);
2802
2852
  }
2803
- if (!!cacheRecord.account) {
2804
- this.setAccount(cacheRecord.account);
2805
- }
2806
- if (!!cacheRecord.idToken && storeInCache?.idToken !== false) {
2807
- this.setIdTokenCredential(cacheRecord.idToken);
2808
- }
2809
- if (!!cacheRecord.accessToken && storeInCache?.accessToken !== false) {
2810
- await this.saveAccessToken(cacheRecord.accessToken);
2811
- }
2812
- if (!!cacheRecord.refreshToken &&
2813
- storeInCache?.refreshToken !== false) {
2814
- this.setRefreshTokenCredential(cacheRecord.refreshToken);
2853
+ try {
2854
+ if (!!cacheRecord.account) {
2855
+ this.setAccount(cacheRecord.account);
2856
+ }
2857
+ if (!!cacheRecord.idToken && storeInCache?.idToken !== false) {
2858
+ this.setIdTokenCredential(cacheRecord.idToken);
2859
+ }
2860
+ if (!!cacheRecord.accessToken &&
2861
+ storeInCache?.accessToken !== false) {
2862
+ await this.saveAccessToken(cacheRecord.accessToken);
2863
+ }
2864
+ if (!!cacheRecord.refreshToken &&
2865
+ storeInCache?.refreshToken !== false) {
2866
+ this.setRefreshTokenCredential(cacheRecord.refreshToken);
2867
+ }
2868
+ if (!!cacheRecord.appMetadata) {
2869
+ this.setAppMetadata(cacheRecord.appMetadata);
2870
+ }
2815
2871
  }
2816
- if (!!cacheRecord.appMetadata) {
2817
- this.setAppMetadata(cacheRecord.appMetadata);
2872
+ catch (e) {
2873
+ this.commonLogger?.error(`CacheManager.saveCacheRecord: failed`);
2874
+ if (e instanceof Error) {
2875
+ this.commonLogger?.errorPii(`CacheManager.saveCacheRecord: ${e.message}`, correlationId);
2876
+ if (e.name === "QuotaExceededError" ||
2877
+ e.name === "NS_ERROR_DOM_QUOTA_REACHED" ||
2878
+ e.message.includes("exceeded the quota")) {
2879
+ this.commonLogger?.error(`CacheManager.saveCacheRecord: exceeded storage quota`, correlationId);
2880
+ throw new CacheError(cacheQuotaExceededErrorCode);
2881
+ }
2882
+ else {
2883
+ throw new CacheError(e.name, e.message);
2884
+ }
2885
+ }
2886
+ else {
2887
+ this.commonLogger?.errorPii(`CacheManager.saveCacheRecord: ${e}`, correlationId);
2888
+ throw new CacheError(cacheUnknownErrorCode);
2889
+ }
2818
2890
  }
2819
2891
  }
2820
2892
  /**
@@ -3861,14 +3933,12 @@
3861
3933
  }
3862
3934
  }
3863
3935
 
3864
- /*! @azure/msal-common v14.8.1 2024-03-27 */
3936
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
3865
3937
 
3866
3938
  /*
3867
3939
  * Copyright (c) Microsoft Corporation. All rights reserved.
3868
3940
  * Licensed under the MIT License.
3869
3941
  */
3870
- // Token renewal offset default in seconds
3871
- const DEFAULT_TOKEN_RENEWAL_OFFSET_SEC = 300;
3872
3942
  const DEFAULT_SYSTEM_OPTIONS = {
3873
3943
  tokenRenewalOffsetSeconds: DEFAULT_TOKEN_RENEWAL_OFFSET_SEC,
3874
3944
  preventCorsPreflight: false,
@@ -3961,7 +4031,7 @@
3961
4031
  return (config.authOptions.authority.options.protocolMode === ProtocolMode.OIDC);
3962
4032
  }
3963
4033
 
3964
- /*! @azure/msal-common v14.8.1 2024-03-27 */
4034
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
3965
4035
 
3966
4036
  /*
3967
4037
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3971,14 +4041,15 @@
3971
4041
  * Error thrown when there is an error with the server code, for example, unavailability.
3972
4042
  */
3973
4043
  class ServerError extends AuthError {
3974
- constructor(errorCode, errorMessage, subError) {
4044
+ constructor(errorCode, errorMessage, subError, errorNo) {
3975
4045
  super(errorCode, errorMessage, subError);
3976
4046
  this.name = "ServerError";
4047
+ this.errorNo = errorNo;
3977
4048
  Object.setPrototypeOf(this, ServerError.prototype);
3978
4049
  }
3979
4050
  }
3980
4051
 
3981
- /*! @azure/msal-common v14.8.1 2024-03-27 */
4052
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
3982
4053
 
3983
4054
  /*
3984
4055
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4076,7 +4147,7 @@
4076
4147
  }
4077
4148
  }
4078
4149
 
4079
- /*! @azure/msal-common v14.8.1 2024-03-27 */
4150
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
4080
4151
 
4081
4152
  /*
4082
4153
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4113,7 +4184,7 @@
4113
4184
  }
4114
4185
  }
4115
4186
 
4116
- /*! @azure/msal-common v14.8.1 2024-03-27 */
4187
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
4117
4188
  /*
4118
4189
  * Copyright (c) Microsoft Corporation. All rights reserved.
4119
4190
  * Licensed under the MIT License.
@@ -4123,7 +4194,7 @@
4123
4194
  UPN: "UPN",
4124
4195
  };
4125
4196
 
4126
- /*! @azure/msal-common v14.8.1 2024-03-27 */
4197
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
4127
4198
  /*
4128
4199
  * Copyright (c) Microsoft Corporation. All rights reserved.
4129
4200
  * Licensed under the MIT License.
@@ -4170,7 +4241,7 @@
4170
4241
  const LOGIN_HINT = "login_hint";
4171
4242
  const DOMAIN_HINT = "domain_hint";
4172
4243
 
4173
- /*! @azure/msal-common v14.8.1 2024-03-27 */
4244
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
4174
4245
 
4175
4246
  /*
4176
4247
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4254,7 +4325,7 @@
4254
4325
  }
4255
4326
  }
4256
4327
 
4257
- /*! @azure/msal-common v14.8.1 2024-03-27 */
4328
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
4258
4329
 
4259
4330
  /*
4260
4331
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4638,7 +4709,7 @@
4638
4709
  }
4639
4710
  }
4640
4711
 
4641
- /*! @azure/msal-common v14.8.1 2024-03-27 */
4712
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
4642
4713
  /*
4643
4714
  * Copyright (c) Microsoft Corporation. All rights reserved.
4644
4715
  * Licensed under the MIT License.
@@ -4650,7 +4721,7 @@
4650
4721
  response.hasOwnProperty("jwks_uri"));
4651
4722
  }
4652
4723
 
4653
- /*! @azure/msal-common v14.8.1 2024-03-27 */
4724
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
4654
4725
  /*
4655
4726
  * Copyright (c) Microsoft Corporation. All rights reserved.
4656
4727
  * Licensed under the MIT License.
@@ -4660,7 +4731,7 @@
4660
4731
  response.hasOwnProperty("metadata"));
4661
4732
  }
4662
4733
 
4663
- /*! @azure/msal-common v14.8.1 2024-03-27 */
4734
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
4664
4735
  /*
4665
4736
  * Copyright (c) Microsoft Corporation. All rights reserved.
4666
4737
  * Licensed under the MIT License.
@@ -4670,7 +4741,7 @@
4670
4741
  response.hasOwnProperty("error_description"));
4671
4742
  }
4672
4743
 
4673
- /*! @azure/msal-common v14.8.1 2024-03-27 */
4744
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
4674
4745
  /*
4675
4746
  * Copyright (c) Microsoft Corporation. All rights reserved.
4676
4747
  * Licensed under the MIT License.
@@ -4732,6 +4803,7 @@
4732
4803
  * Used to acquire a new set of tokens from the authorize endpoint in a hidden iframe.
4733
4804
  */
4734
4805
  SilentIframeClientAcquireToken: "silentIframeClientAcquireToken",
4806
+ AwaitConcurrentIframe: "awaitConcurrentIframe",
4735
4807
  /**
4736
4808
  * acquireToken API in SilentRereshClient (msal-browser).
4737
4809
  * Used to acquire a new set of tokens from the token endpoint using a refresh token.
@@ -5144,7 +5216,7 @@
5144
5216
  "multiMatchedRT",
5145
5217
  ]);
5146
5218
 
5147
- /*! @azure/msal-common v14.8.1 2024-03-27 */
5219
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
5148
5220
  /*
5149
5221
  * Copyright (c) Microsoft Corporation. All rights reserved.
5150
5222
  * Licensed under the MIT License.
@@ -5240,7 +5312,7 @@
5240
5312
  };
5241
5313
  };
5242
5314
 
5243
- /*! @azure/msal-common v14.8.1 2024-03-27 */
5315
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
5244
5316
 
5245
5317
  /*
5246
5318
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5349,7 +5421,7 @@
5349
5421
  },
5350
5422
  };
5351
5423
 
5352
- /*! @azure/msal-common v14.8.1 2024-03-27 */
5424
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
5353
5425
 
5354
5426
  /*
5355
5427
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5361,7 +5433,7 @@
5361
5433
  * @internal
5362
5434
  */
5363
5435
  class Authority {
5364
- constructor(authority, networkInterface, cacheManager, authorityOptions, logger, correlationId, performanceClient) {
5436
+ constructor(authority, networkInterface, cacheManager, authorityOptions, logger, correlationId, performanceClient, managedIdentity) {
5365
5437
  this.canonicalAuthority = authority;
5366
5438
  this._canonicalAuthority.validateAsUri();
5367
5439
  this.networkInterface = networkInterface;
@@ -5375,6 +5447,7 @@
5375
5447
  this.logger = logger;
5376
5448
  this.performanceClient = performanceClient;
5377
5449
  this.correlationId = correlationId;
5450
+ this.managedIdentity = managedIdentity || false;
5378
5451
  this.regionDiscovery = new RegionDiscovery(networkInterface, this.logger, this.performanceClient, this.correlationId);
5379
5452
  }
5380
5453
  /**
@@ -5580,7 +5653,7 @@
5580
5653
  return `${this.canonicalAuthority}v2.0/.well-known/openid-configuration`;
5581
5654
  }
5582
5655
  /**
5583
- * Boolean that returns whethr or not tenant discovery has been completed.
5656
+ * Boolean that returns whether or not tenant discovery has been completed.
5584
5657
  */
5585
5658
  discoveryComplete() {
5586
5659
  return !!this.metadata;
@@ -6032,7 +6105,10 @@
6032
6105
  * helper function to generate environment from authority object
6033
6106
  */
6034
6107
  getPreferredCache() {
6035
- if (this.discoveryComplete()) {
6108
+ if (this.managedIdentity) {
6109
+ return Constants.DEFAULT_AUTHORITY_HOST;
6110
+ }
6111
+ else if (this.discoveryComplete()) {
6036
6112
  return this.metadata.preferred_cache;
6037
6113
  }
6038
6114
  else {
@@ -6184,7 +6260,7 @@
6184
6260
  };
6185
6261
  }
6186
6262
 
6187
- /*! @azure/msal-common v14.8.1 2024-03-27 */
6263
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
6188
6264
 
6189
6265
  /*
6190
6266
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6215,7 +6291,7 @@
6215
6291
  }
6216
6292
  }
6217
6293
 
6218
- /*! @azure/msal-common v14.8.1 2024-03-27 */
6294
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
6219
6295
 
6220
6296
  /*
6221
6297
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6318,7 +6394,7 @@
6318
6394
  }
6319
6395
  }
6320
6396
 
6321
- /*! @azure/msal-common v14.8.1 2024-03-27 */
6397
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
6322
6398
  /*
6323
6399
  * Copyright (c) Microsoft Corporation. All rights reserved.
6324
6400
  * Licensed under the MIT License.
@@ -6344,7 +6420,7 @@
6344
6420
  refreshTokenExpired: refreshTokenExpired
6345
6421
  });
6346
6422
 
6347
- /*! @azure/msal-common v14.8.1 2024-03-27 */
6423
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
6348
6424
 
6349
6425
  /*
6350
6426
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6395,7 +6471,7 @@
6395
6471
  * Error thrown when user interaction is required.
6396
6472
  */
6397
6473
  class InteractionRequiredAuthError extends AuthError {
6398
- constructor(errorCode, errorMessage, subError, timestamp, traceId, correlationId, claims) {
6474
+ constructor(errorCode, errorMessage, subError, timestamp, traceId, correlationId, claims, errorNo) {
6399
6475
  super(errorCode, errorMessage, subError);
6400
6476
  Object.setPrototypeOf(this, InteractionRequiredAuthError.prototype);
6401
6477
  this.timestamp = timestamp || Constants.EMPTY_STRING;
@@ -6403,6 +6479,7 @@
6403
6479
  this.correlationId = correlationId || Constants.EMPTY_STRING;
6404
6480
  this.claims = claims || Constants.EMPTY_STRING;
6405
6481
  this.name = "InteractionRequiredAuthError";
6482
+ this.errorNo = errorNo;
6406
6483
  }
6407
6484
  }
6408
6485
  /**
@@ -6431,7 +6508,7 @@
6431
6508
  return new InteractionRequiredAuthError(errorCode, InteractionRequiredAuthErrorMessages[errorCode]);
6432
6509
  }
6433
6510
 
6434
- /*! @azure/msal-common v14.8.1 2024-03-27 */
6511
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
6435
6512
  /*
6436
6513
  * Copyright (c) Microsoft Corporation. All rights reserved.
6437
6514
  * Licensed under the MIT License.
@@ -6447,7 +6524,7 @@
6447
6524
  }
6448
6525
  }
6449
6526
 
6450
- /*! @azure/msal-common v14.8.1 2024-03-27 */
6527
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
6451
6528
 
6452
6529
  /*
6453
6530
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6519,7 +6596,7 @@
6519
6596
  }
6520
6597
  }
6521
6598
 
6522
- /*! @azure/msal-common v14.8.1 2024-03-27 */
6599
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
6523
6600
 
6524
6601
  /*
6525
6602
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6604,7 +6681,7 @@
6604
6681
  }
6605
6682
  }
6606
6683
 
6607
- /*! @azure/msal-common v14.8.1 2024-03-27 */
6684
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
6608
6685
  /*
6609
6686
  * Copyright (c) Microsoft Corporation. All rights reserved.
6610
6687
  * Licensed under the MIT License.
@@ -6631,12 +6708,19 @@
6631
6708
  }
6632
6709
  }
6633
6710
 
6634
- /*! @azure/msal-common v14.8.1 2024-03-27 */
6711
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
6635
6712
 
6636
6713
  /*
6637
6714
  * Copyright (c) Microsoft Corporation. All rights reserved.
6638
6715
  * Licensed under the MIT License.
6639
6716
  */
6717
+ function parseServerErrorNo(serverResponse) {
6718
+ const errorCodePrefix = "code=";
6719
+ const errorCodePrefixIndex = serverResponse.error_uri?.lastIndexOf(errorCodePrefix);
6720
+ return errorCodePrefixIndex && errorCodePrefixIndex >= 0
6721
+ ? serverResponse.error_uri?.substring(errorCodePrefixIndex + errorCodePrefix.length)
6722
+ : undefined;
6723
+ }
6640
6724
  /**
6641
6725
  * Class that handles response parsing.
6642
6726
  * @internal
@@ -6684,10 +6768,11 @@
6684
6768
  if (serverResponse.error ||
6685
6769
  serverResponse.error_description ||
6686
6770
  serverResponse.suberror) {
6771
+ const serverErrorNo = parseServerErrorNo(serverResponse);
6687
6772
  if (isInteractionRequiredError(serverResponse.error, serverResponse.error_description, serverResponse.suberror)) {
6688
- throw new InteractionRequiredAuthError(serverResponse.error || "", serverResponse.error_description, serverResponse.suberror, serverResponse.timestamp || "", serverResponse.trace_id || "", serverResponse.correlation_id || "", serverResponse.claims || "");
6773
+ throw new InteractionRequiredAuthError(serverResponse.error || "", serverResponse.error_description, serverResponse.suberror, serverResponse.timestamp || "", serverResponse.trace_id || "", serverResponse.correlation_id || "", serverResponse.claims || "", serverErrorNo);
6689
6774
  }
6690
- throw new ServerError(serverResponse.error || "", serverResponse.error_description, serverResponse.suberror);
6775
+ throw new ServerError(serverResponse.error || "", serverResponse.error_description, serverResponse.suberror, serverErrorNo);
6691
6776
  }
6692
6777
  }
6693
6778
  /**
@@ -6701,7 +6786,10 @@
6701
6786
  serverResponse.error_description ||
6702
6787
  serverResponse.suberror) {
6703
6788
  const errString = `${serverResponse.error_codes} - [${serverResponse.timestamp}]: ${serverResponse.error_description} - Correlation ID: ${serverResponse.correlation_id} - Trace ID: ${serverResponse.trace_id}`;
6704
- const serverError = new ServerError(serverResponse.error, errString, serverResponse.suberror);
6789
+ const serverErrorNo = serverResponse.error_codes?.length
6790
+ ? serverResponse.error_codes[0]
6791
+ : undefined;
6792
+ const serverError = new ServerError(serverResponse.error, errString, serverResponse.suberror, serverErrorNo);
6705
6793
  // check if 500 error
6706
6794
  if (refreshAccessToken &&
6707
6795
  serverResponse.status &&
@@ -6721,7 +6809,7 @@
6721
6809
  return;
6722
6810
  }
6723
6811
  if (isInteractionRequiredError(serverResponse.error, serverResponse.error_description, serverResponse.suberror)) {
6724
- throw new InteractionRequiredAuthError(serverResponse.error, serverResponse.error_description, serverResponse.suberror, serverResponse.timestamp || Constants.EMPTY_STRING, serverResponse.trace_id || Constants.EMPTY_STRING, serverResponse.correlation_id || Constants.EMPTY_STRING, serverResponse.claims || Constants.EMPTY_STRING);
6812
+ throw new InteractionRequiredAuthError(serverResponse.error, serverResponse.error_description, serverResponse.suberror, serverResponse.timestamp || Constants.EMPTY_STRING, serverResponse.trace_id || Constants.EMPTY_STRING, serverResponse.correlation_id || Constants.EMPTY_STRING, serverResponse.claims || Constants.EMPTY_STRING, serverErrorNo);
6725
6813
  }
6726
6814
  throw serverError;
6727
6815
  }
@@ -6786,7 +6874,7 @@
6786
6874
  return await ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenClaims, requestStateObj, undefined, serverRequestId);
6787
6875
  }
6788
6876
  }
6789
- await this.cacheStorage.saveCacheRecord(cacheRecord, request.storeInCache);
6877
+ await this.cacheStorage.saveCacheRecord(cacheRecord, request.storeInCache, request.correlationId);
6790
6878
  }
6791
6879
  finally {
6792
6880
  if (this.persistencePlugin &&
@@ -6984,7 +7072,25 @@
6984
7072
  return baseAccount;
6985
7073
  }
6986
7074
 
6987
- /*! @azure/msal-common v14.8.1 2024-03-27 */
7075
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
7076
+ /*
7077
+ * Copyright (c) Microsoft Corporation. All rights reserved.
7078
+ * Licensed under the MIT License.
7079
+ */
7080
+ async function getClientAssertion(clientAssertion, clientId, tokenEndpoint) {
7081
+ if (typeof clientAssertion === "string") {
7082
+ return clientAssertion;
7083
+ }
7084
+ else {
7085
+ const config = {
7086
+ clientId: clientId,
7087
+ tokenEndpoint: tokenEndpoint,
7088
+ };
7089
+ return clientAssertion(config);
7090
+ }
7091
+ }
7092
+
7093
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
6988
7094
 
6989
7095
  /*
6990
7096
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7145,7 +7251,7 @@
7145
7251
  }
7146
7252
  if (this.config.clientCredentials.clientAssertion) {
7147
7253
  const clientAssertion = this.config.clientCredentials.clientAssertion;
7148
- parameterBuilder.addClientAssertion(clientAssertion.assertion);
7254
+ parameterBuilder.addClientAssertion(await getClientAssertion(clientAssertion.assertion, this.config.authOptions.clientId, request.resourceRequestUri));
7149
7255
  parameterBuilder.addClientAssertionType(clientAssertion.assertionType);
7150
7256
  }
7151
7257
  parameterBuilder.addGrantType(GrantType.AUTHORIZATION_CODE_GRANT);
@@ -7269,7 +7375,11 @@
7269
7375
  }
7270
7376
  else if (request.account) {
7271
7377
  const accountSid = this.extractAccountSid(request.account);
7272
- const accountLoginHintClaim = this.extractLoginHint(request.account);
7378
+ let accountLoginHintClaim = this.extractLoginHint(request.account);
7379
+ if (accountLoginHintClaim && request.domainHint) {
7380
+ this.logger.warning(`AuthorizationCodeClient.createAuthCodeUrlQueryString: "domainHint" param is set, skipping opaque "login_hint" claim. Please consider not passing domainHint`);
7381
+ accountLoginHintClaim = null;
7382
+ }
7273
7383
  // If login_hint claim is present, use it over sid/username
7274
7384
  if (accountLoginHintClaim) {
7275
7385
  this.logger.verbose("createAuthCodeUrlQueryString: login_hint claim present on account");
@@ -7389,7 +7499,7 @@
7389
7499
  }
7390
7500
  }
7391
7501
 
7392
- /*! @azure/msal-common v14.8.1 2024-03-27 */
7502
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
7393
7503
 
7394
7504
  /*
7395
7505
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7549,7 +7659,7 @@
7549
7659
  }
7550
7660
  if (this.config.clientCredentials.clientAssertion) {
7551
7661
  const clientAssertion = this.config.clientCredentials.clientAssertion;
7552
- parameterBuilder.addClientAssertion(clientAssertion.assertion);
7662
+ parameterBuilder.addClientAssertion(await getClientAssertion(clientAssertion.assertion, this.config.authOptions.clientId, request.resourceRequestUri));
7553
7663
  parameterBuilder.addClientAssertionType(clientAssertion.assertionType);
7554
7664
  }
7555
7665
  if (request.authenticationScheme === AuthenticationScheme.POP) {
@@ -7596,7 +7706,7 @@
7596
7706
  }
7597
7707
  }
7598
7708
 
7599
- /*! @azure/msal-common v14.8.1 2024-03-27 */
7709
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
7600
7710
 
7601
7711
  /*
7602
7712
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7732,7 +7842,7 @@
7732
7842
  }
7733
7843
  }
7734
7844
 
7735
- /*! @azure/msal-common v14.8.1 2024-03-27 */
7845
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
7736
7846
 
7737
7847
  /*
7738
7848
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7747,7 +7857,7 @@
7747
7857
  },
7748
7858
  };
7749
7859
 
7750
- /*! @azure/msal-common v14.8.1 2024-03-27 */
7860
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
7751
7861
  /*
7752
7862
  * Copyright (c) Microsoft Corporation. All rights reserved.
7753
7863
  * Licensed under the MIT License.
@@ -7755,7 +7865,7 @@
7755
7865
  const missingKidError = "missing_kid_error";
7756
7866
  const missingAlgError = "missing_alg_error";
7757
7867
 
7758
- /*! @azure/msal-common v14.8.1 2024-03-27 */
7868
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
7759
7869
 
7760
7870
  /*
7761
7871
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7780,7 +7890,7 @@
7780
7890
  return new JoseHeaderError(code, JoseHeaderErrorMessages[code]);
7781
7891
  }
7782
7892
 
7783
- /*! @azure/msal-common v14.8.1 2024-03-27 */
7893
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
7784
7894
 
7785
7895
  /*
7786
7896
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7820,7 +7930,7 @@
7820
7930
  }
7821
7931
  }
7822
7932
 
7823
- /*! @azure/msal-common v14.8.1 2024-03-27 */
7933
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
7824
7934
 
7825
7935
  /*
7826
7936
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7878,7 +7988,7 @@
7878
7988
  }
7879
7989
  }
7880
7990
 
7881
- /*! @azure/msal-common v14.8.1 2024-03-27 */
7991
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
7882
7992
 
7883
7993
  /*
7884
7994
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8082,7 +8192,7 @@
8082
8192
  }
8083
8193
  }
8084
8194
 
8085
- /*! @azure/msal-common v14.8.1 2024-03-27 */
8195
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
8086
8196
 
8087
8197
  /*
8088
8198
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8161,7 +8271,7 @@
8161
8271
  }
8162
8272
  }
8163
8273
 
8164
- /*! @azure/msal-common v14.8.1 2024-03-27 */
8274
+ /*! @azure/msal-common v14.10.0 2024-05-07 */
8165
8275
 
8166
8276
  /*
8167
8277
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8259,6 +8369,14 @@
8259
8369
  else if (error instanceof AuthError) {
8260
8370
  event.errorCode = error.errorCode;
8261
8371
  event.subErrorCode = error.subError;
8372
+ if (error instanceof ServerError ||
8373
+ error instanceof InteractionRequiredAuthError) {
8374
+ event.serverErrorNo = error.errorNo;
8375
+ }
8376
+ return;
8377
+ }
8378
+ else if (error instanceof CacheError) {
8379
+ event.errorCode = error.errorCode;
8262
8380
  return;
8263
8381
  }
8264
8382
  else if (event.errorStack?.length) {
@@ -8537,7 +8655,7 @@
8537
8655
  const context = JSON.stringify(endContext(event, this.abbreviations, this.eventStack.get(rootEvent.correlationId), error));
8538
8656
  if (isRoot) {
8539
8657
  queueInfo = this.getQueueInfo(event.correlationId);
8540
- this.discardCache(rootEvent.correlationId);
8658
+ this.discardMeasurements(rootEvent.correlationId);
8541
8659
  }
8542
8660
  else {
8543
8661
  rootEvent.incompleteSubMeasurements?.delete(event.eventId);
@@ -8659,21 +8777,13 @@
8659
8777
  };
8660
8778
  }
8661
8779
  /**
8662
- * Removes measurements for a given correlation id.
8780
+ * Removes measurements and aux data for a given correlation id.
8663
8781
  *
8664
8782
  * @param {string} correlationId
8665
8783
  */
8666
8784
  discardMeasurements(correlationId) {
8667
8785
  this.logger.trace("PerformanceClient: Performance measurements discarded", correlationId);
8668
8786
  this.eventsByCorrelationId.delete(correlationId);
8669
- }
8670
- /**
8671
- * Removes cache for a given correlation id.
8672
- *
8673
- * @param {string} correlationId correlation identifier
8674
- */
8675
- discardCache(correlationId) {
8676
- this.discardMeasurements(correlationId);
8677
8787
  this.logger.trace("PerformanceClient: QueueMeasurements discarded", correlationId);
8678
8788
  this.queueMeasurements.delete(correlationId);
8679
8789
  this.logger.trace("PerformanceClient: Pre-queue times discarded", correlationId);
@@ -8688,6 +8798,12 @@
8688
8798
  * @returns {string}
8689
8799
  */
8690
8800
  addPerformanceCallback(callback) {
8801
+ for (const [id, cb] of this.callbacks) {
8802
+ if (cb.toString() === callback.toString()) {
8803
+ this.logger.warning(`PerformanceClient: Performance callback is already registered with id: ${id}`);
8804
+ return id;
8805
+ }
8806
+ }
8691
8807
  const callbackId = this.generateId();
8692
8808
  this.callbacks.set(callbackId, callback);
8693
8809
  this.logger.verbose(`PerformanceClient: Performance callback registered with id: ${callbackId}`);
@@ -9737,6 +9853,8 @@
9737
9853
  createGuid: createGuid,
9738
9854
  getCurrentUri: getCurrentUri,
9739
9855
  getHomepage: getHomepage,
9856
+ invoke: invoke,
9857
+ invokeAsync: invokeAsync,
9740
9858
  isInIframe: isInIframe,
9741
9859
  isInPopup: isInPopup,
9742
9860
  preconnect: preconnect,
@@ -10017,7 +10135,7 @@
10017
10135
 
10018
10136
  /* eslint-disable header/header */
10019
10137
  const name = "@azure/msal-browser";
10020
- const version = "3.11.1";
10138
+ const version = "3.14.0";
10021
10139
 
10022
10140
  /*
10023
10141
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -10152,11 +10270,7 @@
10152
10270
  if (window.nestedAppAuthBridge === undefined) {
10153
10271
  throw new Error("window.nestedAppAuthBridge is undefined");
10154
10272
  }
10155
- if (window.crypto === undefined) {
10156
- throw new Error("window.crypto is undefined");
10157
- }
10158
10273
  try {
10159
- BridgeProxy.crypto = window.crypto;
10160
10274
  window.nestedAppAuthBridge.addEventListener("message", (response) => {
10161
10275
  const responsePayload = typeof response === "string" ? response : response.data;
10162
10276
  const responseEnvelope = JSON.parse(responsePayload);
@@ -10175,7 +10289,7 @@
10175
10289
  const message = {
10176
10290
  messageType: "NestedAppAuthRequest",
10177
10291
  method: "GetInitContext",
10178
- requestId: BridgeProxy.getRandomId(),
10292
+ requestId: createNewGuid(),
10179
10293
  };
10180
10294
  const request = {
10181
10295
  requestId: message.requestId,
@@ -10193,9 +10307,6 @@
10193
10307
  throw error;
10194
10308
  }
10195
10309
  }
10196
- static getRandomId() {
10197
- return BridgeProxy.crypto.randomUUID();
10198
- }
10199
10310
  /**
10200
10311
  * getTokenInteractive - Attempts to get a token interactively from the bridge
10201
10312
  * @param request A token request
@@ -10237,7 +10348,7 @@
10237
10348
  const message = {
10238
10349
  messageType: "NestedAppAuthRequest",
10239
10350
  method: method,
10240
- requestId: BridgeProxy.getRandomId(),
10351
+ requestId: createNewGuid(),
10241
10352
  ...requestParams,
10242
10353
  };
10243
10354
  const promise = new Promise((resolve, reject) => {
@@ -10327,6 +10438,9 @@
10327
10438
  * TODO: Add implementation to check for presence of inject Nested App Auth Bridge JavaScript interface
10328
10439
  *
10329
10440
  */
10441
+ if (!this.getConfig().auth.supportsNestedAppAuth) {
10442
+ return false;
10443
+ }
10330
10444
  try {
10331
10445
  if (typeof window !== "undefined") {
10332
10446
  const bridgeProxy = await BridgeProxy.create();
@@ -10341,22 +10455,18 @@
10341
10455
  await bridgeProxy.getActiveAccount();
10342
10456
  }
10343
10457
  }
10344
- catch (e) {
10345
- this.activeAccount = undefined;
10458
+ catch {
10459
+ // Ignore errors
10346
10460
  }
10347
10461
  this.bridgeProxy = bridgeProxy;
10348
10462
  this.available = bridgeProxy !== undefined;
10349
10463
  }
10350
- else {
10351
- this.available = false;
10352
- }
10353
- }
10354
- catch (e) {
10355
- this.available = false;
10356
10464
  }
10357
- finally {
10358
- return this.available;
10465
+ catch (ex) {
10466
+ this.logger.infoPii(`Could not initialize Nested App Auth bridge (${ex})`);
10359
10467
  }
10468
+ this.logger.info(`Nested App Auth Bridge available: ${this.available}`);
10469
+ return this.available;
10360
10470
  }
10361
10471
  }
10362
10472
  /*
@@ -10428,8 +10538,7 @@
10428
10538
  const teamsApp = new TeamsAppOperatingContext(config);
10429
10539
  const operatingContexts = [standard.initialize(), teamsApp.initialize()];
10430
10540
  await Promise.all(operatingContexts);
10431
- if (teamsApp.isAvailable() &&
10432
- teamsApp.getConfig().auth.supportsNestedAppAuth) {
10541
+ if (teamsApp.isAvailable()) {
10433
10542
  const controller = await Promise.resolve().then(function () { return NestedAppAuthController$1; });
10434
10543
  return controller.NestedAppAuthController.createController(teamsApp);
10435
10544
  }
@@ -11072,7 +11181,7 @@
11072
11181
  * parameters such as state and nonce, generally.
11073
11182
  */
11074
11183
  class BrowserCacheManager extends CacheManager {
11075
- constructor(clientId, cacheConfig, cryptoImpl, logger, staticAuthorityOptions) {
11184
+ constructor(clientId, cacheConfig, cryptoImpl, logger, staticAuthorityOptions, performanceClient) {
11076
11185
  super(clientId, cryptoImpl, logger, staticAuthorityOptions);
11077
11186
  // Cookie life calculation (hours * minutes * seconds * ms)
11078
11187
  this.COOKIE_LIFE_MULTIPLIER = 24 * 60 * 60 * 1000;
@@ -11086,6 +11195,7 @@
11086
11195
  this.migrateCacheEntries();
11087
11196
  this.createKeyMaps();
11088
11197
  }
11198
+ this.performanceClient = performanceClient;
11089
11199
  }
11090
11200
  /**
11091
11201
  * Returns a window storage class implementing the IWindowStorage interface that corresponds to the configured cacheLocation.
@@ -12306,6 +12416,33 @@
12306
12416
  const cacheRecord = new CacheRecord(undefined, idTokenEntity, accessTokenEntity);
12307
12417
  return this.saveCacheRecord(cacheRecord);
12308
12418
  }
12419
+ /**
12420
+ * saves a cache record
12421
+ * @param cacheRecord {CacheRecord}
12422
+ * @param storeInCache {?StoreInCache}
12423
+ * @param correlationId {?string} correlation id
12424
+ */
12425
+ async saveCacheRecord(cacheRecord, storeInCache, correlationId) {
12426
+ try {
12427
+ await super.saveCacheRecord(cacheRecord, storeInCache, correlationId);
12428
+ }
12429
+ catch (e) {
12430
+ if (e instanceof CacheError &&
12431
+ this.performanceClient &&
12432
+ correlationId) {
12433
+ try {
12434
+ const tokenKeys = this.getTokenKeys();
12435
+ this.performanceClient.addFields({
12436
+ cacheRtCount: tokenKeys.refreshToken.length,
12437
+ cacheIdCount: tokenKeys.idToken.length,
12438
+ cacheAtCount: tokenKeys.accessToken.length,
12439
+ }, correlationId);
12440
+ }
12441
+ catch (e) { }
12442
+ }
12443
+ throw e;
12444
+ }
12445
+ }
12309
12446
  }
12310
12447
  const DEFAULT_BROWSER_CACHE_MANAGER = (clientId, logger) => {
12311
12448
  const cacheOptions = {
@@ -14594,11 +14731,10 @@
14594
14731
  * Checks if navigateToLoginRequestUrl is set, and:
14595
14732
  * - if true, performs logic to cache and navigate
14596
14733
  * - if false, handles hash string and parses response
14597
- * @param hash {string?} url hash
14598
- * @param performanceClient {IPerformanceClient?}
14599
- * @param correlationId {string?} correlation identifier
14734
+ * @param hash {string} url hash
14735
+ * @param parentMeasurement {InProgressPerformanceEvent} parent measurement
14600
14736
  */
14601
- async handleRedirectPromise(hash, performanceClient, correlationId) {
14737
+ async handleRedirectPromise(hash = "", parentMeasurement) {
14602
14738
  const serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.handleRedirectPromise);
14603
14739
  try {
14604
14740
  if (!this.browserStorage.isInteractionInProgress(true)) {
@@ -14610,9 +14746,7 @@
14610
14746
  // Not a recognized server response hash or hash not associated with a redirect request
14611
14747
  this.logger.info("handleRedirectPromise did not detect a response as a result of a redirect. Cleaning temporary cache.");
14612
14748
  this.browserStorage.cleanRequestByInteractionType(exports.InteractionType.Redirect);
14613
- if (performanceClient && correlationId) {
14614
- performanceClient?.addFields({ errorCode: "no_server_response" }, correlationId);
14615
- }
14749
+ parentMeasurement.event.errorCode = "no_server_response";
14616
14750
  return null;
14617
14751
  }
14618
14752
  // If navigateToLoginRequestUrl is true, get the url where the redirect request was initiated
@@ -14964,6 +15098,7 @@
14964
15098
  */
14965
15099
  function createHiddenIframe() {
14966
15100
  const authFrame = document.createElement("iframe");
15101
+ authFrame.className = "msalSilentIframe";
14967
15102
  authFrame.style.visibility = "hidden";
14968
15103
  authFrame.style.position = "absolute";
14969
15104
  authFrame.style.width = authFrame.style.height = "0";
@@ -15427,6 +15562,19 @@
15427
15562
  * Copyright (c) Microsoft Corporation. All rights reserved.
15428
15563
  * Licensed under the MIT License.
15429
15564
  */
15565
+ function getAccountType(account) {
15566
+ const idTokenClaims = account?.idTokenClaims;
15567
+ if (idTokenClaims?.tfp || idTokenClaims?.acr) {
15568
+ return "B2C";
15569
+ }
15570
+ if (!idTokenClaims?.tid) {
15571
+ return undefined;
15572
+ }
15573
+ else if (idTokenClaims?.tid === "9188040d-6c67-4c5b-b112-36a304b66dad") {
15574
+ return "MSA";
15575
+ }
15576
+ return "AAD";
15577
+ }
15430
15578
  class StandardController {
15431
15579
  /**
15432
15580
  * @constructor
@@ -15475,7 +15623,7 @@
15475
15623
  this.eventHandler = new EventHandler(this.logger, this.browserCrypto);
15476
15624
  // Initialize the browser storage class.
15477
15625
  this.browserStorage = this.isBrowserEnvironment
15478
- ? new BrowserCacheManager(this.config.auth.clientId, this.config.cache, this.browserCrypto, this.logger, buildStaticAuthorityOptions(this.config.auth))
15626
+ ? new BrowserCacheManager(this.config.auth.clientId, this.config.cache, this.browserCrypto, this.logger, buildStaticAuthorityOptions(this.config.auth), this.performanceClient)
15479
15627
  : DEFAULT_BROWSER_CACHE_MANAGER(this.config.auth.clientId, this.logger);
15480
15628
  // initialize in memory storage for native flows
15481
15629
  const nativeCacheOptions = {
@@ -15486,7 +15634,7 @@
15486
15634
  cacheMigrationEnabled: false,
15487
15635
  claimsBasedCachingEnabled: false,
15488
15636
  };
15489
- this.nativeInternalStorage = new BrowserCacheManager(this.config.auth.clientId, nativeCacheOptions, this.browserCrypto, this.logger);
15637
+ this.nativeInternalStorage = new BrowserCacheManager(this.config.auth.clientId, nativeCacheOptions, this.browserCrypto, this.logger, undefined, this.performanceClient);
15490
15638
  // Initialize the token cache
15491
15639
  this.tokenCache = new TokenCache(this.config, this.browserStorage, this.logger, this.browserCrypto);
15492
15640
  this.activeSilentTokenRequests = new Map();
@@ -15549,7 +15697,6 @@
15549
15697
  this.logger.verbose("handleRedirectPromise called");
15550
15698
  // Block token acquisition before initialize has been called
15551
15699
  blockAPICallsBeforeInitialize(this.initialized);
15552
- const loggedInAccounts = this.getAllAccounts();
15553
15700
  if (this.isBrowserEnvironment) {
15554
15701
  /**
15555
15702
  * Store the promise on the PublicClientApplication instance if this is the first invocation of handleRedirectPromise,
@@ -15559,64 +15706,9 @@
15559
15706
  const redirectResponseKey = hash || "";
15560
15707
  let response = this.redirectResponse.get(redirectResponseKey);
15561
15708
  if (typeof response === "undefined") {
15562
- const request = this.browserStorage.getCachedNativeRequest();
15563
- const useNative = request &&
15564
- NativeMessageHandler.isNativeAvailable(this.config, this.logger, this.nativeExtensionProvider) &&
15565
- this.nativeExtensionProvider &&
15566
- !hash;
15567
- const correlationId = useNative
15568
- ? request?.correlationId
15569
- : this.browserStorage.getTemporaryCache(TemporaryCacheKeys.CORRELATION_ID, true) || "";
15570
- const rootMeasurement = this.performanceClient.startMeasurement("acquireTokenRedirect", correlationId);
15571
- this.eventHandler.emitEvent(EventType.HANDLE_REDIRECT_START, exports.InteractionType.Redirect);
15572
- this.logger.verbose("handleRedirectPromise has been called for the first time, storing the promise");
15573
- let redirectResponse;
15574
- if (useNative && this.nativeExtensionProvider) {
15575
- this.logger.trace("handleRedirectPromise - acquiring token from native platform");
15576
- const nativeClient = new NativeInteractionClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, ApiId.handleRedirectPromise, this.performanceClient, this.nativeExtensionProvider, request.accountId, this.nativeInternalStorage, request.correlationId);
15577
- redirectResponse = invokeAsync(nativeClient.handleRedirectPromise.bind(nativeClient), PerformanceEvents.HandleNativeRedirectPromiseMeasurement, this.logger, this.performanceClient, rootMeasurement.event.correlationId)(this.performanceClient, rootMeasurement.event.correlationId);
15578
- }
15579
- else {
15580
- this.logger.trace("handleRedirectPromise - acquiring token from web flow");
15581
- const redirectClient = this.createRedirectClient(correlationId);
15582
- redirectResponse = invokeAsync(redirectClient.handleRedirectPromise.bind(redirectClient), PerformanceEvents.HandleRedirectPromiseMeasurement, this.logger, this.performanceClient, rootMeasurement.event.correlationId)(hash, this.performanceClient, rootMeasurement.event.correlationId);
15583
- }
15584
- response = redirectResponse
15585
- .then((result) => {
15586
- if (result) {
15587
- // Emit login event if number of accounts change
15588
- const isLoggingIn = loggedInAccounts.length <
15589
- this.getAllAccounts().length;
15590
- if (isLoggingIn) {
15591
- this.eventHandler.emitEvent(EventType.LOGIN_SUCCESS, exports.InteractionType.Redirect, result);
15592
- this.logger.verbose("handleRedirectResponse returned result, login success");
15593
- }
15594
- else {
15595
- this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_SUCCESS, exports.InteractionType.Redirect, result);
15596
- this.logger.verbose("handleRedirectResponse returned result, acquire token success");
15597
- }
15598
- rootMeasurement.end({ success: true });
15599
- }
15600
- this.eventHandler.emitEvent(EventType.HANDLE_REDIRECT_END, exports.InteractionType.Redirect);
15601
- rootMeasurement.end({ success: false });
15602
- return result;
15603
- })
15604
- .catch((e) => {
15605
- const eventError = e;
15606
- // Emit login event if there is an account
15607
- if (loggedInAccounts.length > 0) {
15608
- this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_FAILURE, exports.InteractionType.Redirect, null, eventError);
15609
- }
15610
- else {
15611
- this.eventHandler.emitEvent(EventType.LOGIN_FAILURE, exports.InteractionType.Redirect, null, eventError);
15612
- }
15613
- this.eventHandler.emitEvent(EventType.HANDLE_REDIRECT_END, exports.InteractionType.Redirect);
15614
- rootMeasurement.end({
15615
- success: false,
15616
- }, eventError);
15617
- throw e;
15618
- });
15709
+ response = this.handleRedirectPromiseInternal(hash);
15619
15710
  this.redirectResponse.set(redirectResponseKey, response);
15711
+ this.logger.verbose("handleRedirectPromise has been called for the first time, storing the promise");
15620
15712
  }
15621
15713
  else {
15622
15714
  this.logger.verbose("handleRedirectPromise has been called previously, returning the result from the first call");
@@ -15626,6 +15718,83 @@
15626
15718
  this.logger.verbose("handleRedirectPromise returns null, not browser environment");
15627
15719
  return null;
15628
15720
  }
15721
+ /**
15722
+ * The internal details of handleRedirectPromise. This is separated out to a helper to allow handleRedirectPromise to memoize requests
15723
+ * @param hash
15724
+ * @returns
15725
+ */
15726
+ async handleRedirectPromiseInternal(hash) {
15727
+ const loggedInAccounts = this.getAllAccounts();
15728
+ const request = this.browserStorage.getCachedNativeRequest();
15729
+ const useNative = request &&
15730
+ NativeMessageHandler.isNativeAvailable(this.config, this.logger, this.nativeExtensionProvider) &&
15731
+ this.nativeExtensionProvider &&
15732
+ !hash;
15733
+ const correlationId = useNative
15734
+ ? request?.correlationId
15735
+ : this.browserStorage.getTemporaryCache(TemporaryCacheKeys.CORRELATION_ID, true) || "";
15736
+ const rootMeasurement = this.performanceClient.startMeasurement("acquireTokenRedirect", correlationId);
15737
+ this.eventHandler.emitEvent(EventType.HANDLE_REDIRECT_START, exports.InteractionType.Redirect);
15738
+ let redirectResponse;
15739
+ if (useNative && this.nativeExtensionProvider) {
15740
+ this.logger.trace("handleRedirectPromise - acquiring token from native platform");
15741
+ const nativeClient = new NativeInteractionClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, ApiId.handleRedirectPromise, this.performanceClient, this.nativeExtensionProvider, request.accountId, this.nativeInternalStorage, request.correlationId);
15742
+ redirectResponse = invokeAsync(nativeClient.handleRedirectPromise.bind(nativeClient), PerformanceEvents.HandleNativeRedirectPromiseMeasurement, this.logger, this.performanceClient, rootMeasurement.event.correlationId)(this.performanceClient, rootMeasurement.event.correlationId);
15743
+ }
15744
+ else {
15745
+ this.logger.trace("handleRedirectPromise - acquiring token from web flow");
15746
+ const redirectClient = this.createRedirectClient(correlationId);
15747
+ redirectResponse = invokeAsync(redirectClient.handleRedirectPromise.bind(redirectClient), PerformanceEvents.HandleRedirectPromiseMeasurement, this.logger, this.performanceClient, rootMeasurement.event.correlationId)(hash, rootMeasurement);
15748
+ }
15749
+ return redirectResponse
15750
+ .then((result) => {
15751
+ if (result) {
15752
+ // Emit login event if number of accounts change
15753
+ const isLoggingIn = loggedInAccounts.length < this.getAllAccounts().length;
15754
+ if (isLoggingIn) {
15755
+ this.eventHandler.emitEvent(EventType.LOGIN_SUCCESS, exports.InteractionType.Redirect, result);
15756
+ this.logger.verbose("handleRedirectResponse returned result, login success");
15757
+ }
15758
+ else {
15759
+ this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_SUCCESS, exports.InteractionType.Redirect, result);
15760
+ this.logger.verbose("handleRedirectResponse returned result, acquire token success");
15761
+ }
15762
+ rootMeasurement.end({
15763
+ success: true,
15764
+ accountType: getAccountType(result.account),
15765
+ });
15766
+ }
15767
+ else {
15768
+ /*
15769
+ * Instrument an event only if an error code is set. Otherwise, discard it when the redirect response
15770
+ * is empty and the error code is missing.
15771
+ */
15772
+ if (rootMeasurement.event.errorCode) {
15773
+ rootMeasurement.end({ success: false });
15774
+ }
15775
+ else {
15776
+ rootMeasurement.discard();
15777
+ }
15778
+ }
15779
+ this.eventHandler.emitEvent(EventType.HANDLE_REDIRECT_END, exports.InteractionType.Redirect);
15780
+ return result;
15781
+ })
15782
+ .catch((e) => {
15783
+ const eventError = e;
15784
+ // Emit login event if there is an account
15785
+ if (loggedInAccounts.length > 0) {
15786
+ this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_FAILURE, exports.InteractionType.Redirect, null, eventError);
15787
+ }
15788
+ else {
15789
+ this.eventHandler.emitEvent(EventType.LOGIN_FAILURE, exports.InteractionType.Redirect, null, eventError);
15790
+ }
15791
+ this.eventHandler.emitEvent(EventType.HANDLE_REDIRECT_END, exports.InteractionType.Redirect);
15792
+ rootMeasurement.end({
15793
+ success: false,
15794
+ }, eventError);
15795
+ throw e;
15796
+ });
15797
+ }
15629
15798
  /**
15630
15799
  * Use when you want to obtain an access_token for your API by redirecting the user's browser window to the authorization endpoint. This function redirects
15631
15800
  * the page, so any code that follows this function will not execute.
@@ -15697,6 +15866,10 @@
15697
15866
  acquireTokenPopup(request) {
15698
15867
  const correlationId = this.getRequestCorrelationId(request);
15699
15868
  const atPopupMeasurement = this.performanceClient.startMeasurement(PerformanceEvents.AcquireTokenPopup, correlationId);
15869
+ atPopupMeasurement.add({
15870
+ scenarioId: request.scenarioId,
15871
+ accountType: getAccountType(request.account),
15872
+ });
15700
15873
  try {
15701
15874
  this.logger.verbose("acquireTokenPopup called", correlationId);
15702
15875
  preflightCheck(this.initialized);
@@ -15726,6 +15899,7 @@
15726
15899
  success: true,
15727
15900
  isNativeBroker: true,
15728
15901
  requestId: response.requestId,
15902
+ accountType: getAccountType(response.account),
15729
15903
  });
15730
15904
  return response;
15731
15905
  })
@@ -15761,13 +15935,12 @@
15761
15935
  else {
15762
15936
  this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_SUCCESS, exports.InteractionType.Popup, result);
15763
15937
  }
15764
- atPopupMeasurement.add({
15765
- accessTokenSize: result.accessToken.length,
15766
- idTokenSize: result.idToken.length,
15767
- });
15768
15938
  atPopupMeasurement.end({
15769
15939
  success: true,
15770
15940
  requestId: result.requestId,
15941
+ accessTokenSize: result.accessToken.length,
15942
+ idTokenSize: result.idToken.length,
15943
+ accountType: getAccountType(result.account),
15771
15944
  });
15772
15945
  return result;
15773
15946
  })
@@ -15826,6 +15999,10 @@
15826
15999
  this.ssoSilentMeasurement?.increment({
15827
16000
  visibilityChangeCount: 0,
15828
16001
  });
16002
+ this.ssoSilentMeasurement?.add({
16003
+ scenarioId: request.scenarioId,
16004
+ accountType: getAccountType(request.account),
16005
+ });
15829
16006
  document.addEventListener("visibilitychange", this.trackPageVisibilityWithMeasurement);
15830
16007
  this.logger.verbose("ssoSilent called", correlationId);
15831
16008
  this.eventHandler.emitEvent(EventType.SSO_SILENT_START, exports.InteractionType.Silent, validRequest);
@@ -15848,14 +16025,13 @@
15848
16025
  return result
15849
16026
  .then((response) => {
15850
16027
  this.eventHandler.emitEvent(EventType.SSO_SILENT_SUCCESS, exports.InteractionType.Silent, response);
15851
- this.ssoSilentMeasurement?.add({
15852
- accessTokenSize: response.accessToken.length,
15853
- idTokenSize: response.idToken.length,
15854
- });
15855
16028
  this.ssoSilentMeasurement?.end({
15856
16029
  success: true,
15857
16030
  isNativeBroker: response.fromNativeBroker,
15858
16031
  requestId: response.requestId,
16032
+ accessTokenSize: response.accessToken.length,
16033
+ idTokenSize: response.idToken.length,
16034
+ accountType: getAccountType(response.account),
15859
16035
  });
15860
16036
  return response;
15861
16037
  })
@@ -15886,6 +16062,7 @@
15886
16062
  preflightCheck(this.initialized);
15887
16063
  this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_BY_CODE_START, exports.InteractionType.Silent, request);
15888
16064
  const atbcMeasurement = this.performanceClient.startMeasurement(PerformanceEvents.AcquireTokenByCode, correlationId);
16065
+ atbcMeasurement.add({ scenarioId: request.scenarioId });
15889
16066
  try {
15890
16067
  if (request.code && request.nativeAccountId) {
15891
16068
  // Throw error in case server returns both spa_code and spa_accountid in exchange for auth code.
@@ -15903,14 +16080,13 @@
15903
16080
  .then((result) => {
15904
16081
  this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_BY_CODE_SUCCESS, exports.InteractionType.Silent, result);
15905
16082
  this.hybridAuthCodeResponses.delete(hybridAuthCode);
15906
- atbcMeasurement.add({
15907
- accessTokenSize: result.accessToken.length,
15908
- idTokenSize: result.idToken.length,
15909
- });
15910
16083
  atbcMeasurement.end({
15911
16084
  success: true,
15912
16085
  isNativeBroker: result.fromNativeBroker,
15913
16086
  requestId: result.requestId,
16087
+ accessTokenSize: result.accessToken.length,
16088
+ idTokenSize: result.idToken.length,
16089
+ accountType: getAccountType(result.account),
15914
16090
  });
15915
16091
  return result;
15916
16092
  })
@@ -15932,7 +16108,7 @@
15932
16108
  }
15933
16109
  else if (request.nativeAccountId) {
15934
16110
  if (this.canUseNative(request, request.nativeAccountId)) {
15935
- return await this.acquireTokenNative({
16111
+ const result = await this.acquireTokenNative({
15936
16112
  ...request,
15937
16113
  correlationId,
15938
16114
  }, ApiId.acquireTokenByCode, request.nativeAccountId).catch((e) => {
@@ -15943,6 +16119,11 @@
15943
16119
  }
15944
16120
  throw e;
15945
16121
  });
16122
+ atbcMeasurement.end({
16123
+ accountType: getAccountType(result.account),
16124
+ success: true,
16125
+ });
16126
+ return result;
15946
16127
  }
15947
16128
  else {
15948
16129
  throw createBrowserAuthError(unableToAcquireTokenFromNativePlatform);
@@ -16505,6 +16686,7 @@
16505
16686
  const atsMeasurement = this.performanceClient.startMeasurement(PerformanceEvents.AcquireTokenSilent, correlationId);
16506
16687
  atsMeasurement.add({
16507
16688
  cacheLookupPolicy: request.cacheLookupPolicy,
16689
+ scenarioId: request.scenarioId,
16508
16690
  });
16509
16691
  preflightCheck(this.initialized);
16510
16692
  this.logger.verbose("acquireTokenSilent called", correlationId);
@@ -16512,6 +16694,7 @@
16512
16694
  if (!account) {
16513
16695
  throw createBrowserAuthError(noAccountError);
16514
16696
  }
16697
+ atsMeasurement.add({ accountType: getAccountType(account) });
16515
16698
  const thumbprint = {
16516
16699
  clientId: this.config.auth.clientId,
16517
16700
  authority: request.authority || Constants.EMPTY_STRING,
@@ -16535,16 +16718,14 @@
16535
16718
  }, account)
16536
16719
  .then((result) => {
16537
16720
  this.activeSilentTokenRequests.delete(silentRequestKey);
16538
- atsMeasurement.add({
16539
- accessTokenSize: result.accessToken.length,
16540
- idTokenSize: result.idToken.length,
16541
- });
16542
16721
  atsMeasurement.end({
16543
16722
  success: true,
16544
16723
  fromCache: result.fromCache,
16545
16724
  isNativeBroker: result.fromNativeBroker,
16546
16725
  cacheLookupPolicy: request.cacheLookupPolicy,
16547
16726
  requestId: result.requestId,
16727
+ accessTokenSize: result.accessToken.length,
16728
+ idTokenSize: result.idToken.length,
16548
16729
  });
16549
16730
  return result;
16550
16731
  })
@@ -16584,49 +16765,67 @@
16584
16765
  this.performanceClient.incrementFields({ visibilityChangeCount: 0 }, request.correlationId);
16585
16766
  }
16586
16767
  document.addEventListener("visibilitychange", () => this.trackPageVisibility(request.correlationId));
16587
- let result;
16588
- if (NativeMessageHandler.isNativeAvailable(this.config, this.logger, this.nativeExtensionProvider, request.authenticationScheme) &&
16589
- account.nativeAccountId) {
16590
- this.logger.verbose("acquireTokenSilent - attempting to acquire token from native platform");
16591
- const silentRequest = {
16592
- ...request,
16593
- account,
16594
- };
16595
- result = this.acquireTokenNative(silentRequest, ApiId.acquireTokenSilent_silentFlow).catch(async (e) => {
16596
- // If native token acquisition fails for availability reasons fallback to web flow
16597
- if (e instanceof NativeAuthError && isFatalNativeAuthError(e)) {
16598
- this.logger.verbose("acquireTokenSilent - native platform unavailable, falling back to web flow");
16599
- this.nativeExtensionProvider = undefined; // Prevent future requests from continuing to attempt
16600
- // Cache will not contain tokens, given that previous WAM requests succeeded. Skip cache and RT renewal and go straight to iframe renewal
16601
- const silentIframeClient = this.createSilentIframeClient(request.correlationId);
16602
- return silentIframeClient.acquireToken(request);
16603
- }
16604
- throw e;
16605
- });
16606
- }
16607
- else {
16608
- this.logger.verbose("acquireTokenSilent - attempting to acquire token from web flow");
16609
- const silentRequest = await invokeAsync(initializeSilentRequest, PerformanceEvents.InitializeSilentRequest, this.logger, this.performanceClient, request.correlationId)(request, account, this.config, this.performanceClient, this.logger);
16610
- const cacheLookupPolicy = request.cacheLookupPolicy || CacheLookupPolicy.Default;
16611
- result = invokeAsync(this.acquireTokenFromCache.bind(this), PerformanceEvents.AcquireTokenFromCache, this.logger, this.performanceClient, silentRequest.correlationId)(silentRequest, cacheLookupPolicy).catch((cacheError) => {
16612
- if (request.cacheLookupPolicy ===
16613
- CacheLookupPolicy.AccessToken) {
16614
- throw cacheError;
16768
+ const silentRequest = await invokeAsync(initializeSilentRequest, PerformanceEvents.InitializeSilentRequest, this.logger, this.performanceClient, request.correlationId)(request, account, this.config, this.performanceClient, this.logger);
16769
+ const cacheLookupPolicy = request.cacheLookupPolicy || CacheLookupPolicy.Default;
16770
+ const result = this.acquireTokenSilentNoIframe(silentRequest, cacheLookupPolicy).catch(async (refreshTokenError) => {
16771
+ const shouldTryToResolveSilently = checkIfRefreshTokenErrorCanBeResolvedSilently(refreshTokenError, cacheLookupPolicy);
16772
+ if (shouldTryToResolveSilently) {
16773
+ if (!this.activeIframeRequest) {
16774
+ let _resolve;
16775
+ // Always set the active request tracker immediately after checking it to prevent races
16776
+ this.activeIframeRequest = [
16777
+ new Promise((resolve) => {
16778
+ _resolve = resolve;
16779
+ }),
16780
+ silentRequest.correlationId,
16781
+ ];
16782
+ this.logger.verbose("Refresh token expired/invalid or CacheLookupPolicy is set to Skip, attempting acquire token by iframe.", silentRequest.correlationId);
16783
+ return invokeAsync(this.acquireTokenBySilentIframe.bind(this), PerformanceEvents.AcquireTokenBySilentIframe, this.logger, this.performanceClient, silentRequest.correlationId)(silentRequest)
16784
+ .then((iframeResult) => {
16785
+ _resolve(true);
16786
+ return iframeResult;
16787
+ })
16788
+ .catch((e) => {
16789
+ _resolve(false);
16790
+ throw e;
16791
+ })
16792
+ .finally(() => {
16793
+ this.activeIframeRequest = undefined;
16794
+ });
16615
16795
  }
16616
- this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_NETWORK_START, exports.InteractionType.Silent, silentRequest);
16617
- return invokeAsync(this.acquireTokenByRefreshToken.bind(this), PerformanceEvents.AcquireTokenByRefreshToken, this.logger, this.performanceClient, silentRequest.correlationId)(silentRequest, cacheLookupPolicy).catch((refreshTokenError) => {
16618
- const shouldTryToResolveSilently = checkIfRefreshTokenErrorCanBeResolvedSilently(refreshTokenError, silentRequest, cacheLookupPolicy);
16619
- if (shouldTryToResolveSilently) {
16620
- this.logger.verbose("Refresh token expired/invalid or CacheLookupPolicy is set to Skip, attempting acquire token by iframe.", silentRequest.correlationId);
16621
- return invokeAsync(this.acquireTokenBySilentIframe.bind(this), PerformanceEvents.AcquireTokenBySilentIframe, this.logger, this.performanceClient, silentRequest.correlationId)(silentRequest);
16796
+ else if (cacheLookupPolicy !== CacheLookupPolicy.Skip) {
16797
+ const [activePromise, activeCorrelationId] = this.activeIframeRequest;
16798
+ this.logger.verbose(`Iframe request is already in progress, awaiting resolution for request with correlationId: ${activeCorrelationId}`, silentRequest.correlationId);
16799
+ const awaitConcurrentIframeMeasure = this.performanceClient.startMeasurement(PerformanceEvents.AwaitConcurrentIframe, silentRequest.correlationId);
16800
+ awaitConcurrentIframeMeasure.add({
16801
+ awaitIframeCorrelationId: activeCorrelationId,
16802
+ });
16803
+ const activePromiseResult = await activePromise;
16804
+ awaitConcurrentIframeMeasure.end({
16805
+ success: activePromiseResult,
16806
+ });
16807
+ if (activePromiseResult) {
16808
+ this.logger.verbose(`Parallel iframe request with correlationId: ${activeCorrelationId} succeeded. Retrying cache and/or RT redemption`, silentRequest.correlationId);
16809
+ // Retry cache lookup and/or RT exchange after iframe completes
16810
+ return this.acquireTokenSilentNoIframe(silentRequest, cacheLookupPolicy);
16622
16811
  }
16623
16812
  else {
16624
- // Error cannot be silently resolved or iframe renewal is not allowed, interaction required
16813
+ this.logger.info(`Iframe request with correlationId: ${activeCorrelationId} failed. Interaction is required.`);
16814
+ // If previous iframe request failed, it's unlikely to succeed this time. Throw original error.
16625
16815
  throw refreshTokenError;
16626
16816
  }
16627
- });
16628
- });
16629
- }
16817
+ }
16818
+ else {
16819
+ // Cache policy set to skip and another iframe request is already in progress
16820
+ this.logger.warning("Another iframe request is currently in progress and CacheLookupPolicy is set to Skip. This may result in degraded performance and/or reliability for both calls. Please consider changing the CacheLookupPolicy to take advantage of request queuing and token cache.", silentRequest.correlationId);
16821
+ return invokeAsync(this.acquireTokenBySilentIframe.bind(this), PerformanceEvents.AcquireTokenBySilentIframe, this.logger, this.performanceClient, silentRequest.correlationId)(silentRequest);
16822
+ }
16823
+ }
16824
+ else {
16825
+ // Error cannot be silently resolved or iframe renewal is not allowed, interaction required
16826
+ throw refreshTokenError;
16827
+ }
16828
+ });
16630
16829
  return result
16631
16830
  .then((response) => {
16632
16831
  this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_SUCCESS, exports.InteractionType.Silent, response);
@@ -16647,6 +16846,38 @@
16647
16846
  document.removeEventListener("visibilitychange", () => this.trackPageVisibility(request.correlationId));
16648
16847
  });
16649
16848
  }
16849
+ /**
16850
+ * AcquireTokenSilent without the iframe fallback. This is used to enable the correct fallbacks in cases where there's a potential for multiple silent requests to be made in parallel and prevent those requests from making concurrent iframe requests.
16851
+ * @param silentRequest
16852
+ * @param cacheLookupPolicy
16853
+ * @returns
16854
+ */
16855
+ async acquireTokenSilentNoIframe(silentRequest, cacheLookupPolicy) {
16856
+ if (NativeMessageHandler.isNativeAvailable(this.config, this.logger, this.nativeExtensionProvider, silentRequest.authenticationScheme) &&
16857
+ silentRequest.account.nativeAccountId) {
16858
+ this.logger.verbose("acquireTokenSilent - attempting to acquire token from native platform");
16859
+ return this.acquireTokenNative(silentRequest, ApiId.acquireTokenSilent_silentFlow).catch(async (e) => {
16860
+ // If native token acquisition fails for availability reasons fallback to web flow
16861
+ if (e instanceof NativeAuthError && isFatalNativeAuthError(e)) {
16862
+ this.logger.verbose("acquireTokenSilent - native platform unavailable, falling back to web flow");
16863
+ this.nativeExtensionProvider = undefined; // Prevent future requests from continuing to attempt
16864
+ // Cache will not contain tokens, given that previous WAM requests succeeded. Skip cache and RT renewal and go straight to iframe renewal
16865
+ throw createClientAuthError(tokenRefreshRequired);
16866
+ }
16867
+ throw e;
16868
+ });
16869
+ }
16870
+ else {
16871
+ this.logger.verbose("acquireTokenSilent - attempting to acquire token from web flow");
16872
+ return invokeAsync(this.acquireTokenFromCache.bind(this), PerformanceEvents.AcquireTokenFromCache, this.logger, this.performanceClient, silentRequest.correlationId)(silentRequest, cacheLookupPolicy).catch((cacheError) => {
16873
+ if (cacheLookupPolicy === CacheLookupPolicy.AccessToken) {
16874
+ throw cacheError;
16875
+ }
16876
+ this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_NETWORK_START, exports.InteractionType.Silent, silentRequest);
16877
+ return invokeAsync(this.acquireTokenByRefreshToken.bind(this), PerformanceEvents.AcquireTokenByRefreshToken, this.logger, this.performanceClient, silentRequest.correlationId)(silentRequest, cacheLookupPolicy);
16878
+ });
16879
+ }
16880
+ }
16650
16881
  }
16651
16882
  /**
16652
16883
  * Determines whether an error thrown by the refresh token endpoint can be resolved without interaction
@@ -16655,7 +16886,7 @@
16655
16886
  * @param cacheLookupPolicy
16656
16887
  * @returns
16657
16888
  */
16658
- function checkIfRefreshTokenErrorCanBeResolvedSilently(refreshTokenError, silentRequest, cacheLookupPolicy) {
16889
+ function checkIfRefreshTokenErrorCanBeResolvedSilently(refreshTokenError, cacheLookupPolicy) {
16659
16890
  const noInteractionRequired = !(refreshTokenError instanceof InteractionRequiredAuthError &&
16660
16891
  // For refresh token errors, bad_token does not always require interaction (silently resolvable)
16661
16892
  refreshTokenError.subError !==
@@ -17049,7 +17280,7 @@
17049
17280
  : DEFAULT_CRYPTO_IMPLEMENTATION;
17050
17281
  // Initialize the browser storage class.
17051
17282
  this.browserStorage = this.isBrowserEnvironment
17052
- ? new BrowserCacheManager(this.config.auth.clientId, this.config.cache, this.browserCrypto, this.logger)
17283
+ ? new BrowserCacheManager(this.config.auth.clientId, this.config.cache, this.browserCrypto, this.logger, undefined, this.performanceClient)
17053
17284
  : DEFAULT_BROWSER_CACHE_MANAGER(this.config.auth.clientId, this.logger);
17054
17285
  this.eventHandler = new EventHandler(this.logger, this.browserCrypto);
17055
17286
  }
@@ -17689,6 +17920,9 @@
17689
17920
  getAllAccounts: () => {
17690
17921
  return [];
17691
17922
  },
17923
+ getAccount: () => {
17924
+ return null;
17925
+ },
17692
17926
  getAccountByHomeId: () => {
17693
17927
  return null;
17694
17928
  },
@@ -18548,12 +18782,7 @@
18548
18782
  }
18549
18783
  loginPopup(request // eslint-disable-line @typescript-eslint/no-unused-vars
18550
18784
  ) {
18551
- if (request !== undefined) {
18552
- return this.acquireTokenInteractive(request);
18553
- }
18554
- else {
18555
- throw NestedAppAuthError.createUnsupportedError();
18556
- }
18785
+ return this.acquireTokenInteractive(request || DEFAULT_REQUEST);
18557
18786
  }
18558
18787
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
18559
18788
  loginRedirect(request) {