@azure/msal-browser 2.32.2 → 2.34.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 (117) hide show
  1. package/README.md +1 -1
  2. package/dist/_virtual/_tslib.js +1 -1
  3. package/dist/app/ClientApplication.d.ts +3 -0
  4. package/dist/app/ClientApplication.d.ts.map +1 -1
  5. package/dist/app/ClientApplication.js +75 -26
  6. package/dist/app/ClientApplication.js.map +1 -1
  7. package/dist/app/IPublicClientApplication.js +1 -1
  8. package/dist/app/PublicClientApplication.d.ts +2 -0
  9. package/dist/app/PublicClientApplication.d.ts.map +1 -1
  10. package/dist/app/PublicClientApplication.js +37 -15
  11. package/dist/app/PublicClientApplication.js.map +1 -1
  12. package/dist/broker/nativeBroker/NativeMessageHandler.d.ts +10 -7
  13. package/dist/broker/nativeBroker/NativeMessageHandler.d.ts.map +1 -1
  14. package/dist/broker/nativeBroker/NativeMessageHandler.js +18 -8
  15. package/dist/broker/nativeBroker/NativeMessageHandler.js.map +1 -1
  16. package/dist/cache/AsyncMemoryStorage.js +1 -1
  17. package/dist/cache/BrowserCacheManager.js +1 -1
  18. package/dist/cache/BrowserStorage.js +1 -1
  19. package/dist/cache/CryptoKeyStore.js +1 -1
  20. package/dist/cache/DatabaseStorage.js +1 -1
  21. package/dist/cache/MemoryStorage.js +1 -1
  22. package/dist/cache/TokenCache.js +1 -1
  23. package/dist/config/Configuration.js +1 -1
  24. package/dist/crypto/BrowserCrypto.js +1 -1
  25. package/dist/crypto/CryptoOps.js +1 -1
  26. package/dist/crypto/GuidGenerator.js +1 -1
  27. package/dist/crypto/ModernBrowserCrypto.js +1 -1
  28. package/dist/crypto/MsBrowserCrypto.js +1 -1
  29. package/dist/crypto/MsrBrowserCrypto.js +1 -1
  30. package/dist/crypto/PkceGenerator.js +1 -1
  31. package/dist/crypto/SignedHttpRequest.js +1 -1
  32. package/dist/encode/Base64Decode.js +1 -1
  33. package/dist/encode/Base64Encode.js +1 -1
  34. package/dist/error/BrowserAuthError.d.ts +8 -0
  35. package/dist/error/BrowserAuthError.d.ts.map +1 -1
  36. package/dist/error/BrowserAuthError.js +11 -1
  37. package/dist/error/BrowserAuthError.js.map +1 -1
  38. package/dist/error/BrowserConfigurationAuthError.js +1 -1
  39. package/dist/error/NativeAuthError.js +1 -1
  40. package/dist/event/EventHandler.js +1 -1
  41. package/dist/event/EventMessage.js +1 -1
  42. package/dist/event/EventType.js +1 -1
  43. package/dist/index.cjs.js +1683 -979
  44. package/dist/index.cjs.js.map +1 -1
  45. package/dist/index.js +1 -1
  46. package/dist/interaction_client/BaseInteractionClient.d.ts.map +1 -1
  47. package/dist/interaction_client/BaseInteractionClient.js +3 -2
  48. package/dist/interaction_client/BaseInteractionClient.js.map +1 -1
  49. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.js +1 -1
  50. package/dist/interaction_client/NativeInteractionClient.d.ts +66 -3
  51. package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
  52. package/dist/interaction_client/NativeInteractionClient.js +174 -68
  53. package/dist/interaction_client/NativeInteractionClient.js.map +1 -1
  54. package/dist/interaction_client/PopupClient.d.ts.map +1 -1
  55. package/dist/interaction_client/PopupClient.js +9 -2
  56. package/dist/interaction_client/PopupClient.js.map +1 -1
  57. package/dist/interaction_client/RedirectClient.d.ts.map +1 -1
  58. package/dist/interaction_client/RedirectClient.js +13 -5
  59. package/dist/interaction_client/RedirectClient.js.map +1 -1
  60. package/dist/interaction_client/SilentAuthCodeClient.d.ts.map +1 -1
  61. package/dist/interaction_client/SilentAuthCodeClient.js +7 -3
  62. package/dist/interaction_client/SilentAuthCodeClient.js.map +1 -1
  63. package/dist/interaction_client/SilentCacheClient.d.ts.map +1 -1
  64. package/dist/interaction_client/SilentCacheClient.js +7 -2
  65. package/dist/interaction_client/SilentCacheClient.js.map +1 -1
  66. package/dist/interaction_client/SilentIframeClient.d.ts.map +1 -1
  67. package/dist/interaction_client/SilentIframeClient.js +21 -4
  68. package/dist/interaction_client/SilentIframeClient.js.map +1 -1
  69. package/dist/interaction_client/SilentRefreshClient.d.ts.map +1 -1
  70. package/dist/interaction_client/SilentRefreshClient.js +9 -3
  71. package/dist/interaction_client/SilentRefreshClient.js.map +1 -1
  72. package/dist/interaction_client/StandardInteractionClient.d.ts.map +1 -1
  73. package/dist/interaction_client/StandardInteractionClient.js +16 -5
  74. package/dist/interaction_client/StandardInteractionClient.js.map +1 -1
  75. package/dist/interaction_handler/InteractionHandler.d.ts +3 -2
  76. package/dist/interaction_handler/InteractionHandler.d.ts.map +1 -1
  77. package/dist/interaction_handler/InteractionHandler.js +12 -4
  78. package/dist/interaction_handler/InteractionHandler.js.map +1 -1
  79. package/dist/interaction_handler/RedirectHandler.d.ts +2 -2
  80. package/dist/interaction_handler/RedirectHandler.d.ts.map +1 -1
  81. package/dist/interaction_handler/RedirectHandler.js +3 -3
  82. package/dist/interaction_handler/RedirectHandler.js.map +1 -1
  83. package/dist/interaction_handler/SilentHandler.d.ts +2 -2
  84. package/dist/interaction_handler/SilentHandler.d.ts.map +1 -1
  85. package/dist/interaction_handler/SilentHandler.js +13 -15
  86. package/dist/interaction_handler/SilentHandler.js.map +1 -1
  87. package/dist/internals.d.ts +5 -0
  88. package/dist/internals.d.ts.map +1 -1
  89. package/dist/internals.js +4 -1
  90. package/dist/internals.js.map +1 -1
  91. package/dist/navigation/NavigationClient.js +1 -1
  92. package/dist/network/FetchClient.js +1 -1
  93. package/dist/network/XhrClient.js +1 -1
  94. package/dist/packageMetadata.d.ts +1 -1
  95. package/dist/packageMetadata.js +2 -2
  96. package/dist/packageMetadata.js.map +1 -1
  97. package/dist/request/EndSessionPopupRequest.d.ts +1 -1
  98. package/dist/request/EndSessionPopupRequest.d.ts.map +1 -1
  99. package/dist/request/EndSessionRequest.d.ts +1 -1
  100. package/dist/request/EndSessionRequest.d.ts.map +1 -1
  101. package/dist/telemetry/BrowserPerformanceClient.d.ts +20 -1
  102. package/dist/telemetry/BrowserPerformanceClient.d.ts.map +1 -1
  103. package/dist/telemetry/BrowserPerformanceClient.js +80 -3
  104. package/dist/telemetry/BrowserPerformanceClient.js.map +1 -1
  105. package/dist/telemetry/BrowserPerformanceMeasurement.d.ts +14 -5
  106. package/dist/telemetry/BrowserPerformanceMeasurement.d.ts.map +1 -1
  107. package/dist/telemetry/BrowserPerformanceMeasurement.js +36 -4
  108. package/dist/telemetry/BrowserPerformanceMeasurement.js.map +1 -1
  109. package/dist/utils/BrowserConstants.js +1 -1
  110. package/dist/utils/BrowserProtocolUtils.js +1 -1
  111. package/dist/utils/BrowserStringUtils.js +1 -1
  112. package/dist/utils/BrowserUtils.js +1 -1
  113. package/dist/utils/MathUtils.js +1 -1
  114. package/lib/msal-browser.js +1683 -979
  115. package/lib/msal-browser.js.map +1 -1
  116. package/lib/msal-browser.min.js +43 -44
  117. package/package.json +2 -2
package/dist/index.cjs.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! @azure/msal-browser v2.32.2 2023-01-10 */
1
+ /*! @azure/msal-browser v2.34.0 2023-03-07 */
2
2
  'use strict';
3
3
  'use strict';
4
4
 
@@ -117,7 +117,7 @@ function __spread() {
117
117
  return ar;
118
118
  }
119
119
 
120
- /*! @azure/msal-common v9.0.2 2023-01-10 */
120
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
121
121
  /*! *****************************************************************************
122
122
  Copyright (c) Microsoft Corporation.
123
123
 
@@ -204,7 +204,7 @@ function __spreadArrays() {
204
204
  return r;
205
205
  }
206
206
 
207
- /*! @azure/msal-common v9.0.2 2023-01-10 */
207
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
208
208
 
209
209
  /*
210
210
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -586,9 +586,10 @@ var JsonTypes;
586
586
  (function (JsonTypes) {
587
587
  JsonTypes["Jwt"] = "JWT";
588
588
  JsonTypes["Jwk"] = "JWK";
589
+ JsonTypes["Pop"] = "pop";
589
590
  })(JsonTypes || (JsonTypes = {}));
590
591
 
591
- /*! @azure/msal-common v9.0.2 2023-01-10 */
592
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
592
593
 
593
594
  /*
594
595
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -644,7 +645,7 @@ var AuthError = /** @class */ (function (_super) {
644
645
  return AuthError;
645
646
  }(Error));
646
647
 
647
- /*! @azure/msal-common v9.0.2 2023-01-10 */
648
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
648
649
 
649
650
  /*
650
651
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -719,7 +720,7 @@ var DEFAULT_CRYPTO_IMPLEMENTATION = {
719
720
  }
720
721
  };
721
722
 
722
- /*! @azure/msal-common v9.0.2 2023-01-10 */
723
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
723
724
 
724
725
  /*
725
726
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -923,6 +924,14 @@ var ClientAuthErrorMessage = {
923
924
  keyIdMissing: {
924
925
  code: "key_id_missing",
925
926
  desc: "A keyId value is missing from the requested bound token's cache record and is required to match the token to it's stored binding key."
927
+ },
928
+ noNetworkConnectivity: {
929
+ code: "no_network_connectivity",
930
+ desc: "No network connectivity. Check your internet connection."
931
+ },
932
+ userCanceledError: {
933
+ code: "user_canceled",
934
+ desc: "User canceled the flow."
926
935
  }
927
936
  };
928
937
  /**
@@ -1211,10 +1220,22 @@ var ClientAuthError = /** @class */ (function (_super) {
1211
1220
  ClientAuthError.createKeyIdMissingError = function () {
1212
1221
  return new ClientAuthError(ClientAuthErrorMessage.keyIdMissing.code, ClientAuthErrorMessage.keyIdMissing.desc);
1213
1222
  };
1223
+ /**
1224
+ * Create an error when the client does not have network connectivity
1225
+ */
1226
+ ClientAuthError.createNoNetworkConnectivityError = function () {
1227
+ return new ClientAuthError(ClientAuthErrorMessage.noNetworkConnectivity.code, ClientAuthErrorMessage.noNetworkConnectivity.desc);
1228
+ };
1229
+ /**
1230
+ * Create an error when the user cancels the flow
1231
+ */
1232
+ ClientAuthError.createUserCanceledError = function () {
1233
+ return new ClientAuthError(ClientAuthErrorMessage.userCanceledError.code, ClientAuthErrorMessage.userCanceledError.desc);
1234
+ };
1214
1235
  return ClientAuthError;
1215
1236
  }(AuthError));
1216
1237
 
1217
- /*! @azure/msal-common v9.0.2 2023-01-10 */
1238
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
1218
1239
 
1219
1240
  /*
1220
1241
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1339,7 +1360,7 @@ var StringUtils = /** @class */ (function () {
1339
1360
  return StringUtils;
1340
1361
  }());
1341
1362
 
1342
- /*! @azure/msal-common v9.0.2 2023-01-10 */
1363
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
1343
1364
 
1344
1365
  /*
1345
1366
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1529,12 +1550,12 @@ var Logger = /** @class */ (function () {
1529
1550
  return Logger;
1530
1551
  }());
1531
1552
 
1532
- /*! @azure/msal-common v9.0.2 2023-01-10 */
1553
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
1533
1554
  /* eslint-disable header/header */
1534
1555
  var name$1 = "@azure/msal-common";
1535
- var version$1 = "9.0.2";
1556
+ var version$1 = "11.0.0";
1536
1557
 
1537
- /*! @azure/msal-common v9.0.2 2023-01-10 */
1558
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
1538
1559
  /*
1539
1560
  * Copyright (c) Microsoft Corporation. All rights reserved.
1540
1561
  * Licensed under the MIT License.
@@ -1555,7 +1576,7 @@ exports.AzureCloudInstance = void 0;
1555
1576
  AzureCloudInstance["AzureUsGovernment"] = "https://login.microsoftonline.us";
1556
1577
  })(exports.AzureCloudInstance || (exports.AzureCloudInstance = {}));
1557
1578
 
1558
- /*! @azure/msal-common v9.0.2 2023-01-10 */
1579
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
1559
1580
 
1560
1581
  /*
1561
1582
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1586,6 +1607,25 @@ exports.AzureCloudInstance = void 0;
1586
1607
  var CredentialEntity = /** @class */ (function () {
1587
1608
  function CredentialEntity() {
1588
1609
  }
1610
+ /**
1611
+ * Initializes a map with credential {CredentialType} regular expressions.
1612
+ */
1613
+ CredentialEntity._initRegex = function () {
1614
+ var separator = Separators.CACHE_KEY_SEPARATOR;
1615
+ CredentialEntity.credentialRegexMap = new Map();
1616
+ for (var _i = 0, _a = Object.keys(CredentialType); _i < _a.length; _i++) {
1617
+ var credKey = _a[_i];
1618
+ var credVal = CredentialType[credKey].toLowerCase();
1619
+ try {
1620
+ // Verify credential type is preceded by a valid host name (environment) using lookbehind
1621
+ CredentialEntity.credentialRegexMap.set(CredentialType[credKey], new RegExp("(?<=" + separator + CredentialEntity.credentialDomainRegex + ")" + separator + credVal + separator));
1622
+ }
1623
+ catch (err) {
1624
+ // Lookbehind is not supported (Safari or older versions of IE) - removing it
1625
+ CredentialEntity.credentialRegexMap.set(CredentialType[credKey], new RegExp("" + separator + CredentialEntity.credentialDomainRegex + separator + credVal + separator));
1626
+ }
1627
+ }
1628
+ };
1589
1629
  /**
1590
1630
  * Generate Account Id key component as per the schema: <home_account_id>-<environment>
1591
1631
  */
@@ -1632,14 +1672,10 @@ var CredentialEntity = /** @class */ (function () {
1632
1672
  * @param key
1633
1673
  */
1634
1674
  CredentialEntity.getCredentialType = function (key) {
1635
- var separator = Separators.CACHE_KEY_SEPARATOR;
1636
- // Match host names like "login.microsoftonline.com", "https://accounts.google.com:4000", etc.
1637
- var domainRe = "(https?:\\/\\/)?([\\w-]+\\.)*([\\w-]{1,63})(\\.(\\w{2,3}))(\\:[0-9]{4,5})?";
1638
- for (var _i = 0, _a = Object.keys(CredentialType); _i < _a.length; _i++) {
1639
- var credKey = _a[_i];
1640
- var credVal = CredentialType[credKey].toLowerCase();
1641
- // Verify credential type is preceded by a valid host name (environment)
1642
- if (key.toLowerCase().search("(?<=" + separator + domainRe + ")" + separator + credVal + separator) !== -1) {
1675
+ var _a;
1676
+ for (var _i = 0, _b = Object.keys(CredentialType); _i < _b.length; _i++) {
1677
+ var credKey = _b[_i];
1678
+ if ((_a = this.credentialRegexMap.get(CredentialType[credKey])) === null || _a === void 0 ? void 0 : _a.test(key.toLowerCase())) {
1643
1679
  return CredentialType[credKey];
1644
1680
  }
1645
1681
  }
@@ -1708,10 +1744,16 @@ var CredentialEntity = /** @class */ (function () {
1708
1744
  */
1709
1745
  return (tokenType && tokenType.toLowerCase() !== exports.AuthenticationScheme.BEARER.toLowerCase()) ? tokenType.toLowerCase() : Constants.EMPTY_STRING;
1710
1746
  };
1747
+ /*
1748
+ * Match host names like "login.microsoftonline.com", "https://accounts.google.com:4000", https://localhost:5000,
1749
+ * "login.microsoftonline.com/common", "login.microsoftonline.com:4000/common", etc
1750
+ */
1751
+ CredentialEntity.credentialDomainRegex = "(https?:\\/\\/)?((([\\w-]+\\.)*([\\w-]{1,63})(\\.(\\w{2,63})))|(localhost))(\\:[0-9]{4,5})?(\\/[\\w-]+)?";
1711
1752
  return CredentialEntity;
1712
- }());
1753
+ }());
1754
+ CredentialEntity._initRegex();
1713
1755
 
1714
- /*! @azure/msal-common v9.0.2 2023-01-10 */
1756
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
1715
1757
 
1716
1758
  /*
1717
1759
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1966,7 +2008,7 @@ var ClientConfigurationError = /** @class */ (function (_super) {
1966
2008
  return ClientConfigurationError;
1967
2009
  }(ClientAuthError));
1968
2010
 
1969
- /*! @azure/msal-common v9.0.2 2023-01-10 */
2011
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
1970
2012
 
1971
2013
  /*
1972
2014
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2150,7 +2192,7 @@ var ScopeSet = /** @class */ (function () {
2150
2192
  return ScopeSet;
2151
2193
  }());
2152
2194
 
2153
- /*! @azure/msal-common v9.0.2 2023-01-10 */
2195
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
2154
2196
 
2155
2197
  /*
2156
2198
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2188,7 +2230,7 @@ function buildClientInfoFromHomeAccountId(homeAccountId) {
2188
2230
  };
2189
2231
  }
2190
2232
 
2191
- /*! @azure/msal-common v9.0.2 2023-01-10 */
2233
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
2192
2234
  /*
2193
2235
  * Copyright (c) Microsoft Corporation. All rights reserved.
2194
2236
  * Licensed under the MIT License.
@@ -2203,7 +2245,7 @@ var AuthorityType;
2203
2245
  AuthorityType[AuthorityType["Dsts"] = 2] = "Dsts";
2204
2246
  })(AuthorityType || (AuthorityType = {}));
2205
2247
 
2206
- /*! @azure/msal-common v9.0.2 2023-01-10 */
2248
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
2207
2249
 
2208
2250
  /*
2209
2251
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2442,7 +2484,7 @@ var AccountEntity = /** @class */ (function () {
2442
2484
  return AccountEntity;
2443
2485
  }());
2444
2486
 
2445
- /*! @azure/msal-common v9.0.2 2023-01-10 */
2487
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
2446
2488
 
2447
2489
  /*
2448
2490
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2494,7 +2536,7 @@ var AuthToken = /** @class */ (function () {
2494
2536
  return AuthToken;
2495
2537
  }());
2496
2538
 
2497
- /*! @azure/msal-common v9.0.2 2023-01-10 */
2539
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
2498
2540
 
2499
2541
  /*
2500
2542
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2997,7 +3039,7 @@ var CacheManager = /** @class */ (function () {
2997
3039
  else if (accounts.length > 1) {
2998
3040
  throw ClientAuthError.createMultipleMatchingAccountsInCacheError();
2999
3041
  }
3000
- return accountCache[0];
3042
+ return accounts[0];
3001
3043
  };
3002
3044
  /**
3003
3045
  * Retrieve IdTokenEntity from cache
@@ -3373,7 +3415,7 @@ var DefaultStorageClass = /** @class */ (function (_super) {
3373
3415
  return DefaultStorageClass;
3374
3416
  }(CacheManager));
3375
3417
 
3376
- /*! @azure/msal-common v9.0.2 2023-01-10 */
3418
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
3377
3419
 
3378
3420
  /*
3379
3421
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3383,8 +3425,7 @@ var DefaultStorageClass = /** @class */ (function (_super) {
3383
3425
  var DEFAULT_TOKEN_RENEWAL_OFFSET_SEC = 300;
3384
3426
  var DEFAULT_SYSTEM_OPTIONS = {
3385
3427
  tokenRenewalOffsetSeconds: DEFAULT_TOKEN_RENEWAL_OFFSET_SEC,
3386
- preventCorsPreflight: false,
3387
- proxyUrl: Constants.EMPTY_STRING
3428
+ preventCorsPreflight: false
3388
3429
  };
3389
3430
  var DEFAULT_LOGGER_IMPLEMENTATION = {
3390
3431
  loggerCallback: function () {
@@ -3467,7 +3508,7 @@ function buildAuthOptions(authOptions) {
3467
3508
  return __assign({ clientCapabilities: [], azureCloudOptions: DEFAULT_AZURE_CLOUD_OPTIONS, skipAuthorityMetadataCache: false }, authOptions);
3468
3509
  }
3469
3510
 
3470
- /*! @azure/msal-common v9.0.2 2023-01-10 */
3511
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
3471
3512
 
3472
3513
  /*
3473
3514
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3487,7 +3528,7 @@ var ServerError = /** @class */ (function (_super) {
3487
3528
  return ServerError;
3488
3529
  }(AuthError));
3489
3530
 
3490
- /*! @azure/msal-common v9.0.2 2023-01-10 */
3531
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
3491
3532
 
3492
3533
  /*
3493
3534
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3583,7 +3624,7 @@ var ThrottlingUtils = /** @class */ (function () {
3583
3624
  return ThrottlingUtils;
3584
3625
  }());
3585
3626
 
3586
- /*! @azure/msal-common v9.0.2 2023-01-10 */
3627
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
3587
3628
 
3588
3629
  /*
3589
3630
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3632,7 +3673,7 @@ var NetworkManager = /** @class */ (function () {
3632
3673
  return NetworkManager;
3633
3674
  }());
3634
3675
 
3635
- /*! @azure/msal-common v9.0.2 2023-01-10 */
3676
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
3636
3677
  /*
3637
3678
  * Copyright (c) Microsoft Corporation. All rights reserved.
3638
3679
  * Licensed under the MIT License.
@@ -3643,98 +3684,7 @@ var CcsCredentialType;
3643
3684
  CcsCredentialType["UPN"] = "UPN";
3644
3685
  })(CcsCredentialType || (CcsCredentialType = {}));
3645
3686
 
3646
- /*! @azure/msal-common v9.0.2 2023-01-10 */
3647
-
3648
- /*
3649
- * Copyright (c) Microsoft Corporation. All rights reserved.
3650
- * Licensed under the MIT License.
3651
- */
3652
- /**
3653
- * Base application class which will construct requests to send to and handle responses from the Microsoft STS using the authorization code flow.
3654
- */
3655
- var BaseClient = /** @class */ (function () {
3656
- function BaseClient(configuration, performanceClient) {
3657
- // Set the configuration
3658
- this.config = buildClientConfiguration(configuration);
3659
- // Initialize the logger
3660
- this.logger = new Logger(this.config.loggerOptions, name$1, version$1);
3661
- // Initialize crypto
3662
- this.cryptoUtils = this.config.cryptoInterface;
3663
- // Initialize storage interface
3664
- this.cacheManager = this.config.storageInterface;
3665
- // Set the network interface
3666
- this.networkClient = this.config.networkInterface;
3667
- // Set the NetworkManager
3668
- this.networkManager = new NetworkManager(this.networkClient, this.cacheManager);
3669
- // Set TelemetryManager
3670
- this.serverTelemetryManager = this.config.serverTelemetryManager;
3671
- // set Authority
3672
- this.authority = this.config.authOptions.authority;
3673
- // set performance telemetry client
3674
- this.performanceClient = performanceClient;
3675
- }
3676
- /**
3677
- * Creates default headers for requests to token endpoint
3678
- */
3679
- BaseClient.prototype.createTokenRequestHeaders = function (ccsCred) {
3680
- var headers = {};
3681
- headers[HeaderNames.CONTENT_TYPE] = Constants.URL_FORM_CONTENT_TYPE;
3682
- if (!this.config.systemOptions.preventCorsPreflight && ccsCred) {
3683
- switch (ccsCred.type) {
3684
- case CcsCredentialType.HOME_ACCOUNT_ID:
3685
- try {
3686
- var clientInfo = buildClientInfoFromHomeAccountId(ccsCred.credential);
3687
- headers[HeaderNames.CCS_HEADER] = "Oid:" + clientInfo.uid + "@" + clientInfo.utid;
3688
- }
3689
- catch (e) {
3690
- this.logger.verbose("Could not parse home account ID for CCS Header: " + e);
3691
- }
3692
- break;
3693
- case CcsCredentialType.UPN:
3694
- headers[HeaderNames.CCS_HEADER] = "UPN: " + ccsCred.credential;
3695
- break;
3696
- }
3697
- }
3698
- return headers;
3699
- };
3700
- /**
3701
- * Http post to token endpoint
3702
- * @param tokenEndpoint
3703
- * @param queryString
3704
- * @param headers
3705
- * @param thumbprint
3706
- */
3707
- BaseClient.prototype.executePostToTokenEndpoint = function (tokenEndpoint, queryString, headers, thumbprint) {
3708
- return __awaiter(this, void 0, void 0, function () {
3709
- var response;
3710
- return __generator(this, function (_a) {
3711
- switch (_a.label) {
3712
- case 0: return [4 /*yield*/, this.networkManager.sendPostRequest(thumbprint, tokenEndpoint, { body: queryString, headers: headers, proxyUrl: this.config.systemOptions.proxyUrl })];
3713
- case 1:
3714
- response = _a.sent();
3715
- if (this.config.serverTelemetryManager && response.status < 500 && response.status !== 429) {
3716
- // Telemetry data successfully logged by server, clear Telemetry cache
3717
- this.config.serverTelemetryManager.clearTelemetryCache();
3718
- }
3719
- return [2 /*return*/, response];
3720
- }
3721
- });
3722
- });
3723
- };
3724
- /**
3725
- * Updates the authority object of the client. Endpoint discovery must be completed.
3726
- * @param updatedAuthority
3727
- */
3728
- BaseClient.prototype.updateAuthority = function (updatedAuthority) {
3729
- if (!updatedAuthority.discoveryComplete()) {
3730
- throw ClientAuthError.createEndpointDiscoveryIncompleteError("Updated authority has not completed endpoint discovery.");
3731
- }
3732
- this.authority = updatedAuthority;
3733
- };
3734
- return BaseClient;
3735
- }());
3736
-
3737
- /*! @azure/msal-common v9.0.2 2023-01-10 */
3687
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
3738
3688
 
3739
3689
  /*
3740
3690
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3802,7 +3752,7 @@ var RequestValidator = /** @class */ (function () {
3802
3752
  }
3803
3753
  };
3804
3754
  /**
3805
- * Removes unnecessary or duplicate query parameters from extraQueryParameters
3755
+ * Removes unnecessary, duplicate, and empty string query parameters from extraQueryParameters
3806
3756
  * @param request
3807
3757
  */
3808
3758
  RequestValidator.sanitizeEQParams = function (eQParams, queryParams) {
@@ -3815,12 +3765,17 @@ var RequestValidator = /** @class */ (function () {
3815
3765
  delete eQParams[key];
3816
3766
  }
3817
3767
  });
3818
- return eQParams;
3768
+ // remove empty string parameters
3769
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
3770
+ return Object.fromEntries(Object.entries(eQParams).filter(function (_a) {
3771
+ var value = _a[1];
3772
+ return value !== "";
3773
+ }));
3819
3774
  };
3820
3775
  return RequestValidator;
3821
3776
  }());
3822
3777
 
3823
- /*! @azure/msal-common v9.0.2 2023-01-10 */
3778
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
3824
3779
 
3825
3780
  /*
3826
3781
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4097,13 +4052,13 @@ var RequestParameterBuilder = /** @class */ (function () {
4097
4052
  };
4098
4053
  /**
4099
4054
  * add extraQueryParams
4100
- * @param eQparams
4055
+ * @param eQParams
4101
4056
  */
4102
- RequestParameterBuilder.prototype.addExtraQueryParameters = function (eQparams) {
4057
+ RequestParameterBuilder.prototype.addExtraQueryParameters = function (eQParams) {
4103
4058
  var _this = this;
4104
- RequestValidator.sanitizeEQParams(eQparams, this.parameters);
4105
- Object.keys(eQparams).forEach(function (key) {
4106
- _this.parameters.set(key, eQparams[key]);
4059
+ var sanitizedEQParams = RequestValidator.sanitizeEQParams(eQParams, this.parameters);
4060
+ Object.keys(sanitizedEQParams).forEach(function (key) {
4061
+ _this.parameters.set(key, eQParams[key]);
4107
4062
  });
4108
4063
  };
4109
4064
  RequestParameterBuilder.prototype.addClientCapabilitiesToClaims = function (claims, clientCapabilities) {
@@ -4198,7 +4153,109 @@ var RequestParameterBuilder = /** @class */ (function () {
4198
4153
  return RequestParameterBuilder;
4199
4154
  }());
4200
4155
 
4201
- /*! @azure/msal-common v9.0.2 2023-01-10 */
4156
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
4157
+
4158
+ /*
4159
+ * Copyright (c) Microsoft Corporation. All rights reserved.
4160
+ * Licensed under the MIT License.
4161
+ */
4162
+ /**
4163
+ * Base application class which will construct requests to send to and handle responses from the Microsoft STS using the authorization code flow.
4164
+ */
4165
+ var BaseClient = /** @class */ (function () {
4166
+ function BaseClient(configuration, performanceClient) {
4167
+ // Set the configuration
4168
+ this.config = buildClientConfiguration(configuration);
4169
+ // Initialize the logger
4170
+ this.logger = new Logger(this.config.loggerOptions, name$1, version$1);
4171
+ // Initialize crypto
4172
+ this.cryptoUtils = this.config.cryptoInterface;
4173
+ // Initialize storage interface
4174
+ this.cacheManager = this.config.storageInterface;
4175
+ // Set the network interface
4176
+ this.networkClient = this.config.networkInterface;
4177
+ // Set the NetworkManager
4178
+ this.networkManager = new NetworkManager(this.networkClient, this.cacheManager);
4179
+ // Set TelemetryManager
4180
+ this.serverTelemetryManager = this.config.serverTelemetryManager;
4181
+ // set Authority
4182
+ this.authority = this.config.authOptions.authority;
4183
+ // set performance telemetry client
4184
+ this.performanceClient = performanceClient;
4185
+ }
4186
+ /**
4187
+ * Creates default headers for requests to token endpoint
4188
+ */
4189
+ BaseClient.prototype.createTokenRequestHeaders = function (ccsCred) {
4190
+ var headers = {};
4191
+ headers[HeaderNames.CONTENT_TYPE] = Constants.URL_FORM_CONTENT_TYPE;
4192
+ if (!this.config.systemOptions.preventCorsPreflight && ccsCred) {
4193
+ switch (ccsCred.type) {
4194
+ case CcsCredentialType.HOME_ACCOUNT_ID:
4195
+ try {
4196
+ var clientInfo = buildClientInfoFromHomeAccountId(ccsCred.credential);
4197
+ headers[HeaderNames.CCS_HEADER] = "Oid:" + clientInfo.uid + "@" + clientInfo.utid;
4198
+ }
4199
+ catch (e) {
4200
+ this.logger.verbose("Could not parse home account ID for CCS Header: " + e);
4201
+ }
4202
+ break;
4203
+ case CcsCredentialType.UPN:
4204
+ headers[HeaderNames.CCS_HEADER] = "UPN: " + ccsCred.credential;
4205
+ break;
4206
+ }
4207
+ }
4208
+ return headers;
4209
+ };
4210
+ /**
4211
+ * Http post to token endpoint
4212
+ * @param tokenEndpoint
4213
+ * @param queryString
4214
+ * @param headers
4215
+ * @param thumbprint
4216
+ */
4217
+ BaseClient.prototype.executePostToTokenEndpoint = function (tokenEndpoint, queryString, headers, thumbprint) {
4218
+ return __awaiter(this, void 0, void 0, function () {
4219
+ var response;
4220
+ return __generator(this, function (_a) {
4221
+ switch (_a.label) {
4222
+ case 0: return [4 /*yield*/, this.networkManager.sendPostRequest(thumbprint, tokenEndpoint, { body: queryString, headers: headers })];
4223
+ case 1:
4224
+ response = _a.sent();
4225
+ if (this.config.serverTelemetryManager && response.status < 500 && response.status !== 429) {
4226
+ // Telemetry data successfully logged by server, clear Telemetry cache
4227
+ this.config.serverTelemetryManager.clearTelemetryCache();
4228
+ }
4229
+ return [2 /*return*/, response];
4230
+ }
4231
+ });
4232
+ });
4233
+ };
4234
+ /**
4235
+ * Updates the authority object of the client. Endpoint discovery must be completed.
4236
+ * @param updatedAuthority
4237
+ */
4238
+ BaseClient.prototype.updateAuthority = function (updatedAuthority) {
4239
+ if (!updatedAuthority.discoveryComplete()) {
4240
+ throw ClientAuthError.createEndpointDiscoveryIncompleteError("Updated authority has not completed endpoint discovery.");
4241
+ }
4242
+ this.authority = updatedAuthority;
4243
+ };
4244
+ /**
4245
+ * Creates query string for the /token request
4246
+ * @param request
4247
+ */
4248
+ BaseClient.prototype.createTokenQueryParameters = function (request) {
4249
+ var parameterBuilder = new RequestParameterBuilder();
4250
+ if (request.tokenQueryParameters) {
4251
+ parameterBuilder.addExtraQueryParameters(request.tokenQueryParameters);
4252
+ }
4253
+ return parameterBuilder.createQueryString();
4254
+ };
4255
+ return BaseClient;
4256
+ }());
4257
+
4258
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
4202
4259
 
4203
4260
  /*
4204
4261
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4262,7 +4319,7 @@ var IdTokenEntity = /** @class */ (function (_super) {
4262
4319
  return IdTokenEntity;
4263
4320
  }(CredentialEntity));
4264
4321
 
4265
- /*! @azure/msal-common v9.0.2 2023-01-10 */
4322
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
4266
4323
  /*
4267
4324
  * Copyright (c) Microsoft Corporation. All rights reserved.
4268
4325
  * Licensed under the MIT License.
@@ -4312,7 +4369,7 @@ var TimeUtils = /** @class */ (function () {
4312
4369
  return TimeUtils;
4313
4370
  }());
4314
4371
 
4315
- /*! @azure/msal-common v9.0.2 2023-01-10 */
4372
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
4316
4373
 
4317
4374
  /*
4318
4375
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4426,7 +4483,7 @@ var AccessTokenEntity = /** @class */ (function (_super) {
4426
4483
  return AccessTokenEntity;
4427
4484
  }(CredentialEntity));
4428
4485
 
4429
- /*! @azure/msal-common v9.0.2 2023-01-10 */
4486
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
4430
4487
 
4431
4488
  /*
4432
4489
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4493,7 +4550,7 @@ var RefreshTokenEntity = /** @class */ (function (_super) {
4493
4550
  return RefreshTokenEntity;
4494
4551
  }(CredentialEntity));
4495
4552
 
4496
- /*! @azure/msal-common v9.0.2 2023-01-10 */
4553
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
4497
4554
 
4498
4555
  /*
4499
4556
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4532,10 +4589,14 @@ var InteractionRequiredAuthErrorMessage = {
4532
4589
  */
4533
4590
  var InteractionRequiredAuthError = /** @class */ (function (_super) {
4534
4591
  __extends(InteractionRequiredAuthError, _super);
4535
- function InteractionRequiredAuthError(errorCode, errorMessage, subError) {
4592
+ function InteractionRequiredAuthError(errorCode, errorMessage, subError, timestamp, traceId, correlationId, claims) {
4536
4593
  var _this = _super.call(this, errorCode, errorMessage, subError) || this;
4537
- _this.name = "InteractionRequiredAuthError";
4538
4594
  Object.setPrototypeOf(_this, InteractionRequiredAuthError.prototype);
4595
+ _this.timestamp = timestamp || Constants.EMPTY_STRING;
4596
+ _this.traceId = traceId || Constants.EMPTY_STRING;
4597
+ _this.correlationId = correlationId || Constants.EMPTY_STRING;
4598
+ _this.claims = claims || Constants.EMPTY_STRING;
4599
+ _this.name = "InteractionRequiredAuthError";
4539
4600
  return _this;
4540
4601
  }
4541
4602
  /**
@@ -4568,7 +4629,7 @@ var InteractionRequiredAuthError = /** @class */ (function (_super) {
4568
4629
  return InteractionRequiredAuthError;
4569
4630
  }(AuthError));
4570
4631
 
4571
- /*! @azure/msal-common v9.0.2 2023-01-10 */
4632
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
4572
4633
  /*
4573
4634
  * Copyright (c) Microsoft Corporation. All rights reserved.
4574
4635
  * Licensed under the MIT License.
@@ -4584,7 +4645,7 @@ var CacheRecord = /** @class */ (function () {
4584
4645
  return CacheRecord;
4585
4646
  }());
4586
4647
 
4587
- /*! @azure/msal-common v9.0.2 2023-01-10 */
4648
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
4588
4649
 
4589
4650
  /*
4590
4651
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4655,7 +4716,7 @@ var ProtocolUtils = /** @class */ (function () {
4655
4716
  return ProtocolUtils;
4656
4717
  }());
4657
4718
 
4658
- /*! @azure/msal-common v9.0.2 2023-01-10 */
4719
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
4659
4720
 
4660
4721
  /*
4661
4722
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4889,43 +4950,277 @@ var UrlString = /** @class */ (function () {
4889
4950
  return UrlString;
4890
4951
  }());
4891
4952
 
4892
- /*! @azure/msal-common v9.0.2 2023-01-10 */
4893
-
4953
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
4894
4954
  /*
4895
4955
  * Copyright (c) Microsoft Corporation. All rights reserved.
4896
4956
  * Licensed under the MIT License.
4897
4957
  */
4898
- var KeyLocation;
4899
- (function (KeyLocation) {
4900
- KeyLocation["SW"] = "sw";
4901
- KeyLocation["UHW"] = "uhw";
4902
- })(KeyLocation || (KeyLocation = {}));
4903
- var PopTokenGenerator = /** @class */ (function () {
4904
- function PopTokenGenerator(cryptoUtils) {
4905
- this.cryptoUtils = cryptoUtils;
4906
- }
4958
+ /**
4959
+ * Enumeration of operations that are instrumented by have their performance measured by the PerformanceClient.
4960
+ *
4961
+ * @export
4962
+ * @enum {number}
4963
+ */
4964
+ exports.PerformanceEvents = void 0;
4965
+ (function (PerformanceEvents) {
4907
4966
  /**
4908
- * Generates the req_cnf validated at the RP in the POP protocol for SHR parameters
4909
- * and returns an object containing the keyid, the full req_cnf string and the req_cnf string hash
4910
- * @param request
4911
- * @returns
4967
+ * acquireTokenByCode API (msal-browser and msal-node).
4968
+ * Used to acquire tokens by trading an authorization code against the token endpoint.
4912
4969
  */
4913
- PopTokenGenerator.prototype.generateCnf = function (request) {
4914
- return __awaiter(this, void 0, void 0, function () {
4915
- var reqCnf, reqCnfString, _a;
4916
- return __generator(this, function (_b) {
4917
- switch (_b.label) {
4918
- case 0: return [4 /*yield*/, this.generateKid(request)];
4919
- case 1:
4920
- reqCnf = _b.sent();
4921
- reqCnfString = this.cryptoUtils.base64Encode(JSON.stringify(reqCnf));
4922
- _a = {
4923
- kid: reqCnf.kid,
4924
- reqCnfString: reqCnfString
4925
- };
4926
- return [4 /*yield*/, this.cryptoUtils.hashString(reqCnfString)];
4927
- case 2: return [2 /*return*/, (_a.reqCnfHash = _b.sent(),
4928
- _a)];
4970
+ PerformanceEvents["AcquireTokenByCode"] = "acquireTokenByCode";
4971
+ /**
4972
+ * acquireTokenByRefreshToken API (msal-browser and msal-node).
4973
+ * Used to renew an access token using a refresh token against the token endpoint.
4974
+ */
4975
+ PerformanceEvents["AcquireTokenByRefreshToken"] = "acquireTokenByRefreshToken";
4976
+ /**
4977
+ * acquireTokenSilent API (msal-browser and msal-node).
4978
+ * Used to silently acquire a new access token (from the cache or the network).
4979
+ */
4980
+ PerformanceEvents["AcquireTokenSilent"] = "acquireTokenSilent";
4981
+ /**
4982
+ * acquireTokenSilentAsync (msal-browser).
4983
+ * Internal API for acquireTokenSilent.
4984
+ */
4985
+ PerformanceEvents["AcquireTokenSilentAsync"] = "acquireTokenSilentAsync";
4986
+ /**
4987
+ * acquireTokenPopup (msal-browser).
4988
+ * Used to acquire a new access token interactively through pop ups
4989
+ */
4990
+ PerformanceEvents["AcquireTokenPopup"] = "acquireTokenPopup";
4991
+ /**
4992
+ * getPublicKeyThumbprint API in CryptoOpts class (msal-browser).
4993
+ * Used to generate a public/private keypair and generate a public key thumbprint for pop requests.
4994
+ */
4995
+ PerformanceEvents["CryptoOptsGetPublicKeyThumbprint"] = "cryptoOptsGetPublicKeyThumbprint";
4996
+ /**
4997
+ * signJwt API in CryptoOpts class (msal-browser).
4998
+ * Used to signed a pop token.
4999
+ */
5000
+ PerformanceEvents["CryptoOptsSignJwt"] = "cryptoOptsSignJwt";
5001
+ /**
5002
+ * acquireToken API in the SilentCacheClient class (msal-browser).
5003
+ * Used to read access tokens from the cache.
5004
+ */
5005
+ PerformanceEvents["SilentCacheClientAcquireToken"] = "silentCacheClientAcquireToken";
5006
+ /**
5007
+ * acquireToken API in the SilentIframeClient class (msal-browser).
5008
+ * Used to acquire a new set of tokens from the authorize endpoint in a hidden iframe.
5009
+ */
5010
+ PerformanceEvents["SilentIframeClientAcquireToken"] = "silentIframeClientAcquireToken";
5011
+ /**
5012
+ * acquireToken API in SilentRereshClient (msal-browser).
5013
+ * Used to acquire a new set of tokens from the token endpoint using a refresh token.
5014
+ */
5015
+ PerformanceEvents["SilentRefreshClientAcquireToken"] = "silentRefreshClientAcquireToken";
5016
+ /**
5017
+ * ssoSilent API (msal-browser).
5018
+ * Used to silently acquire an authorization code and set of tokens using a hidden iframe.
5019
+ */
5020
+ PerformanceEvents["SsoSilent"] = "ssoSilent";
5021
+ /**
5022
+ * getDiscoveredAuthority API in StandardInteractionClient class (msal-browser).
5023
+ * Used to load authority metadata for a request.
5024
+ */
5025
+ PerformanceEvents["StandardInteractionClientGetDiscoveredAuthority"] = "standardInteractionClientGetDiscoveredAuthority";
5026
+ /**
5027
+ * acquireToken APIs in msal-browser.
5028
+ * Used to make an /authorize endpoint call with native brokering enabled.
5029
+ */
5030
+ PerformanceEvents["FetchAccountIdWithNativeBroker"] = "fetchAccountIdWithNativeBroker";
5031
+ /**
5032
+ * acquireToken API in NativeInteractionClient class (msal-browser).
5033
+ * Used to acquire a token from Native component when native brokering is enabled.
5034
+ */
5035
+ PerformanceEvents["NativeInteractionClientAcquireToken"] = "nativeInteractionClientAcquireToken";
5036
+ /**
5037
+ * Time spent creating default headers for requests to token endpoint
5038
+ */
5039
+ PerformanceEvents["BaseClientCreateTokenRequestHeaders"] = "baseClientCreateTokenRequestHeaders";
5040
+ /**
5041
+ * Used to measure the time taken for completing embedded-broker handshake (PW-Broker).
5042
+ */
5043
+ PerformanceEvents["BrokerHandhshake"] = "brokerHandshake";
5044
+ /**
5045
+ * acquireTokenByRefreshToken API in BrokerClientApplication (PW-Broker) .
5046
+ */
5047
+ PerformanceEvents["AcquireTokenByRefreshTokenInBroker"] = "acquireTokenByRefreshTokenInBroker";
5048
+ /**
5049
+ * Time taken for token acquisition by broker
5050
+ */
5051
+ PerformanceEvents["AcquireTokenByBroker"] = "acquireTokenByBroker";
5052
+ /**
5053
+ * Time spent on the network for refresh token acquisition
5054
+ */
5055
+ PerformanceEvents["RefreshTokenClientExecuteTokenRequest"] = "refreshTokenClientExecuteTokenRequest";
5056
+ /**
5057
+ * Time taken for acquiring refresh token , records RT size
5058
+ */
5059
+ PerformanceEvents["RefreshTokenClientAcquireToken"] = "refreshTokenClientAcquireToken";
5060
+ /**
5061
+ * Time taken for acquiring cached refresh token
5062
+ */
5063
+ PerformanceEvents["RefreshTokenClientAcquireTokenWithCachedRefreshToken"] = "refreshTokenClientAcquireTokenWithCachedRefreshToken";
5064
+ /**
5065
+ * acquireTokenByRefreshToken API in RefreshTokenClient (msal-common).
5066
+ */
5067
+ PerformanceEvents["RefreshTokenClientAcquireTokenByRefreshToken"] = "refreshTokenClientAcquireTokenByRefreshToken";
5068
+ /**
5069
+ * Helper function to create token request body in RefreshTokenClient (msal-common).
5070
+ */
5071
+ PerformanceEvents["RefreshTokenClientCreateTokenRequestBody"] = "refreshTokenClientCreateTokenRequestBody";
5072
+ /**
5073
+ * acquireTokenFromCache (msal-browser).
5074
+ * Internal API for acquiring token from cache
5075
+ */
5076
+ PerformanceEvents["AcquireTokenFromCache"] = "acquireTokenFromCache";
5077
+ /**
5078
+ * acquireTokenBySilentIframe (msal-browser).
5079
+ * Internal API for acquiring token by silent Iframe
5080
+ */
5081
+ PerformanceEvents["AcquireTokenBySilentIframe"] = "acquireTokenBySilentIframe";
5082
+ /**
5083
+ * Internal API for initializing base request in BaseInteractionClient (msal-browser)
5084
+ */
5085
+ PerformanceEvents["InitializeBaseRequest"] = "initializeBaseRequest";
5086
+ /**
5087
+ * Internal API for initializing silent request in SilentCacheClient (msal-browser)
5088
+ */
5089
+ PerformanceEvents["InitializeSilentRequest"] = "initializeSilentRequest";
5090
+ PerformanceEvents["InitializeClientApplication"] = "initializeClientApplication";
5091
+ /**
5092
+ * Helper function in SilentIframeClient class (msal-browser).
5093
+ */
5094
+ PerformanceEvents["SilentIframeClientTokenHelper"] = "silentIframeClientTokenHelper";
5095
+ /**
5096
+ * SilentHandler
5097
+ */
5098
+ PerformanceEvents["SilentHandlerInitiateAuthRequest"] = "silentHandlerInitiateAuthRequest";
5099
+ PerformanceEvents["SilentHandlerMonitorIframeForHash"] = "silentHandlerMonitorIframeForHash";
5100
+ PerformanceEvents["SilentHandlerLoadFrame"] = "silentHandlerLoadFrame";
5101
+ /**
5102
+ * Helper functions in StandardInteractionClient class (msal-browser)
5103
+ */
5104
+ PerformanceEvents["StandardInteractionClientCreateAuthCodeClient"] = "standardInteractionClientCreateAuthCodeClient";
5105
+ PerformanceEvents["StandardInteractionClientGetClientConfiguration"] = "standardInteractionClientGetClientConfiguration";
5106
+ PerformanceEvents["StandardInteractionClientInitializeAuthorizationRequest"] = "standardInteractionClientInitializeAuthorizationRequest";
5107
+ PerformanceEvents["StandardInteractionClientInitializeAuthorizationCodeRequest"] = "standardInteractionClientInitializeAuthorizationCodeRequest";
5108
+ /**
5109
+ * getAuthCodeUrl API (msal-browser and msal-node).
5110
+ */
5111
+ PerformanceEvents["GetAuthCodeUrl"] = "getAuthCodeUrl";
5112
+ /**
5113
+ * Functions from InteractionHandler (msal-browser)
5114
+ */
5115
+ PerformanceEvents["HandleCodeResponseFromServer"] = "handleCodeResponseFromServer";
5116
+ PerformanceEvents["HandleCodeResponseFromHash"] = "handleCodeResponseFromHash";
5117
+ PerformanceEvents["UpdateTokenEndpointAuthority"] = "updateTokenEndpointAuthority";
5118
+ /**
5119
+ * APIs in Authorization Code Client (msal-common)
5120
+ */
5121
+ PerformanceEvents["AuthClientAcquireToken"] = "authClientAcquireToken";
5122
+ PerformanceEvents["AuthClientExecuteTokenRequest"] = "authClientExecuteTokenRequest";
5123
+ PerformanceEvents["AuthClientCreateTokenRequestBody"] = "authClientCreateTokenRequestBody";
5124
+ PerformanceEvents["AuthClientCreateQueryString"] = "authClientCreateQueryString";
5125
+ /**
5126
+ * Generate functions in PopTokenGenerator (msal-common)
5127
+ */
5128
+ PerformanceEvents["PopTokenGenerateCnf"] = "popTokenGenerateCnf";
5129
+ PerformanceEvents["PopTokenGenerateKid"] = "popTokenGenerateKid";
5130
+ /**
5131
+ * handleServerTokenResponse API in ResponseHandler (msal-common)
5132
+ */
5133
+ PerformanceEvents["HandleServerTokenResponse"] = "handleServerTokenResponse";
5134
+ /**
5135
+ * Authority functions
5136
+ */
5137
+ PerformanceEvents["AuthorityFactoryCreateDiscoveredInstance"] = "authorityFactoryCreateDiscoveredInstance";
5138
+ PerformanceEvents["AuthorityResolveEndpointsAsync"] = "authorityResolveEndpointsAsync";
5139
+ PerformanceEvents["AuthorityGetCloudDiscoveryMetadataFromNetwork"] = "authorityGetCloudDiscoveryMetadataFromNetwork";
5140
+ PerformanceEvents["AuthorityUpdateCloudDiscoveryMetadata"] = "authorityUpdateCloudDiscoveryMetadata";
5141
+ PerformanceEvents["AuthorityGetEndpointMetadataFromNetwork"] = "authorityGetEndpointMetadataFromNetwork";
5142
+ PerformanceEvents["AuthorityUpdateEndpointMetadata"] = "authorityUpdateEndpointMetadata";
5143
+ PerformanceEvents["AuthorityUpdateMetadataWithRegionalInformation"] = "authorityUpdateMetadataWithRegionalInformation";
5144
+ /**
5145
+ * Region Discovery functions
5146
+ */
5147
+ PerformanceEvents["RegionDiscoveryDetectRegion"] = "regionDiscoveryDetectRegion";
5148
+ PerformanceEvents["RegionDiscoveryGetRegionFromIMDS"] = "regionDiscoveryGetRegionFromIMDS";
5149
+ PerformanceEvents["RegionDiscoveryGetCurrentVersion"] = "regionDiscoveryGetCurrentVersion";
5150
+ PerformanceEvents["AcquireTokenByCodeAsync"] = "acquireTokenByCodeAsync";
5151
+ PerformanceEvents["GetEndpointMetadataFromNetwork"] = "getEndpointMetadataFromNetwork";
5152
+ PerformanceEvents["GetCloudDiscoveryMetadataFromNetworkMeasurement"] = "getCloudDiscoveryMetadataFromNetworkMeasurement";
5153
+ PerformanceEvents["HandleRedirectPromiseMeasurement"] = "handleRedirectPromiseMeasurement";
5154
+ PerformanceEvents["UpdateCloudDiscoveryMetadataMeasurement"] = "updateCloudDiscoveryMetadataMeasurement";
5155
+ PerformanceEvents["UsernamePasswordClientAcquireToken"] = "usernamePasswordClientAcquireToken";
5156
+ PerformanceEvents["NativeMessageHandlerHandshake"] = "nativeMessageHandlerHandshake";
5157
+ })(exports.PerformanceEvents || (exports.PerformanceEvents = {}));
5158
+ /**
5159
+ * State of the performance event.
5160
+ *
5161
+ * @export
5162
+ * @enum {number}
5163
+ */
5164
+ var PerformanceEventStatus;
5165
+ (function (PerformanceEventStatus) {
5166
+ PerformanceEventStatus[PerformanceEventStatus["NotStarted"] = 0] = "NotStarted";
5167
+ PerformanceEventStatus[PerformanceEventStatus["InProgress"] = 1] = "InProgress";
5168
+ PerformanceEventStatus[PerformanceEventStatus["Completed"] = 2] = "Completed";
5169
+ })(PerformanceEventStatus || (PerformanceEventStatus = {}));
5170
+ var IntFields = new Set([
5171
+ "accessTokenSize",
5172
+ "durationMs",
5173
+ "idTokenSize",
5174
+ "matsSilentStatus",
5175
+ "matsHttpStatus",
5176
+ "refreshTokenSize",
5177
+ "queuedTimeMs",
5178
+ "startTimeMs",
5179
+ "status",
5180
+ ]);
5181
+
5182
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
5183
+
5184
+ /*
5185
+ * Copyright (c) Microsoft Corporation. All rights reserved.
5186
+ * Licensed under the MIT License.
5187
+ */
5188
+ var KeyLocation;
5189
+ (function (KeyLocation) {
5190
+ KeyLocation["SW"] = "sw";
5191
+ KeyLocation["UHW"] = "uhw";
5192
+ })(KeyLocation || (KeyLocation = {}));
5193
+ var PopTokenGenerator = /** @class */ (function () {
5194
+ function PopTokenGenerator(cryptoUtils, performanceClient) {
5195
+ this.cryptoUtils = cryptoUtils;
5196
+ this.performanceClient = performanceClient;
5197
+ }
5198
+ /**
5199
+ * Generates the req_cnf validated at the RP in the POP protocol for SHR parameters
5200
+ * and returns an object containing the keyid, the full req_cnf string and the req_cnf string hash
5201
+ * @param request
5202
+ * @returns
5203
+ */
5204
+ PopTokenGenerator.prototype.generateCnf = function (request) {
5205
+ var _a, _b;
5206
+ return __awaiter(this, void 0, void 0, function () {
5207
+ var reqCnf, reqCnfString, _c;
5208
+ return __generator(this, function (_d) {
5209
+ switch (_d.label) {
5210
+ case 0:
5211
+ (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.PopTokenGenerateCnf, request.correlationId);
5212
+ (_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.setPreQueueTime(exports.PerformanceEvents.PopTokenGenerateKid, request.correlationId);
5213
+ return [4 /*yield*/, this.generateKid(request)];
5214
+ case 1:
5215
+ reqCnf = _d.sent();
5216
+ reqCnfString = this.cryptoUtils.base64Encode(JSON.stringify(reqCnf));
5217
+ _c = {
5218
+ kid: reqCnf.kid,
5219
+ reqCnfString: reqCnfString
5220
+ };
5221
+ return [4 /*yield*/, this.cryptoUtils.hashString(reqCnfString)];
5222
+ case 2: return [2 /*return*/, (_c.reqCnfHash = _d.sent(),
5223
+ _c)];
4929
5224
  }
4930
5225
  });
4931
5226
  });
@@ -4936,13 +5231,16 @@ var PopTokenGenerator = /** @class */ (function () {
4936
5231
  * @returns
4937
5232
  */
4938
5233
  PopTokenGenerator.prototype.generateKid = function (request) {
5234
+ var _a;
4939
5235
  return __awaiter(this, void 0, void 0, function () {
4940
5236
  var kidThumbprint;
4941
- return __generator(this, function (_a) {
4942
- switch (_a.label) {
4943
- case 0: return [4 /*yield*/, this.cryptoUtils.getPublicKeyThumbprint(request)];
5237
+ return __generator(this, function (_b) {
5238
+ switch (_b.label) {
5239
+ case 0:
5240
+ (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.PopTokenGenerateKid, request.correlationId);
5241
+ return [4 /*yield*/, this.cryptoUtils.getPublicKeyThumbprint(request)];
4944
5242
  case 1:
4945
- kidThumbprint = _a.sent();
5243
+ kidThumbprint = _b.sent();
4946
5244
  return [2 /*return*/, {
4947
5245
  kid: kidThumbprint,
4948
5246
  xms_ksl: KeyLocation.SW
@@ -4990,7 +5288,7 @@ var PopTokenGenerator = /** @class */ (function () {
4990
5288
  return PopTokenGenerator;
4991
5289
  }());
4992
5290
 
4993
- /*! @azure/msal-common v9.0.2 2023-01-10 */
5291
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
4994
5292
 
4995
5293
  /*
4996
5294
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5060,7 +5358,7 @@ var AppMetadataEntity = /** @class */ (function () {
5060
5358
  return AppMetadataEntity;
5061
5359
  }());
5062
5360
 
5063
- /*! @azure/msal-common v9.0.2 2023-01-10 */
5361
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
5064
5362
  /*
5065
5363
  * Copyright (c) Microsoft Corporation. All rights reserved.
5066
5364
  * Licensed under the MIT License.
@@ -5096,7 +5394,7 @@ var AppMetadataEntity = /** @class */ (function () {
5096
5394
  return TokenCacheContext;
5097
5395
  }());
5098
5396
 
5099
- /*! @azure/msal-common v9.0.2 2023-01-10 */
5397
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
5100
5398
 
5101
5399
  /*
5102
5400
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5106,13 +5404,14 @@ var AppMetadataEntity = /** @class */ (function () {
5106
5404
  * Class that handles response parsing.
5107
5405
  */
5108
5406
  var ResponseHandler = /** @class */ (function () {
5109
- function ResponseHandler(clientId, cacheStorage, cryptoObj, logger, serializableCache, persistencePlugin) {
5407
+ function ResponseHandler(clientId, cacheStorage, cryptoObj, logger, serializableCache, persistencePlugin, performanceClient) {
5110
5408
  this.clientId = clientId;
5111
5409
  this.cacheStorage = cacheStorage;
5112
5410
  this.cryptoObj = cryptoObj;
5113
5411
  this.logger = logger;
5114
5412
  this.serializableCache = serializableCache;
5115
5413
  this.persistencePlugin = persistencePlugin;
5414
+ this.performanceClient = performanceClient;
5116
5415
  }
5117
5416
  /**
5118
5417
  * Function which validates server authorization code response.
@@ -5130,7 +5429,7 @@ var ResponseHandler = /** @class */ (function () {
5130
5429
  // Check for error
5131
5430
  if (serverResponseHash.error || serverResponseHash.error_description || serverResponseHash.suberror) {
5132
5431
  if (InteractionRequiredAuthError.isInteractionRequiredError(serverResponseHash.error, serverResponseHash.error_description, serverResponseHash.suberror)) {
5133
- throw new InteractionRequiredAuthError(serverResponseHash.error || Constants.EMPTY_STRING, serverResponseHash.error_description, serverResponseHash.suberror);
5432
+ throw new InteractionRequiredAuthError(serverResponseHash.error || Constants.EMPTY_STRING, serverResponseHash.error_description, serverResponseHash.suberror, serverResponseHash.timestamp || Constants.EMPTY_STRING, serverResponseHash.trace_id || Constants.EMPTY_STRING, serverResponseHash.correlation_id || Constants.EMPTY_STRING, serverResponseHash.claims || Constants.EMPTY_STRING);
5134
5433
  }
5135
5434
  throw new ServerError(serverResponseHash.error || Constants.EMPTY_STRING, serverResponseHash.error_description, serverResponseHash.suberror);
5136
5435
  }
@@ -5146,7 +5445,7 @@ var ResponseHandler = /** @class */ (function () {
5146
5445
  // Check for error
5147
5446
  if (serverResponse.error || serverResponse.error_description || serverResponse.suberror) {
5148
5447
  if (InteractionRequiredAuthError.isInteractionRequiredError(serverResponse.error, serverResponse.error_description, serverResponse.suberror)) {
5149
- throw new InteractionRequiredAuthError(serverResponse.error, serverResponse.error_description, serverResponse.suberror);
5448
+ 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);
5150
5449
  }
5151
5450
  var errString = serverResponse.error_codes + " - [" + serverResponse.timestamp + "]: " + serverResponse.error_description + " - Correlation ID: " + serverResponse.correlation_id + " - Trace ID: " + serverResponse.trace_id;
5152
5451
  throw new ServerError(serverResponse.error, errString, serverResponse.suberror);
@@ -5158,11 +5457,13 @@ var ResponseHandler = /** @class */ (function () {
5158
5457
  * @param authority
5159
5458
  */
5160
5459
  ResponseHandler.prototype.handleServerTokenResponse = function (serverTokenResponse, authority, reqTimestamp, request, authCodePayload, userAssertionHash, handlingRefreshTokenResponse, forceCacheRefreshTokenResponse, serverRequestId) {
5460
+ var _a;
5161
5461
  return __awaiter(this, void 0, void 0, function () {
5162
5462
  var idTokenObj, authTime, requestStateObj, cacheRecord, cacheContext, key, account;
5163
- return __generator(this, function (_a) {
5164
- switch (_a.label) {
5463
+ return __generator(this, function (_b) {
5464
+ switch (_b.label) {
5165
5465
  case 0:
5466
+ (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.HandleServerTokenResponse, serverTokenResponse.correlation_id);
5166
5467
  if (serverTokenResponse.id_token) {
5167
5468
  idTokenObj = new AuthToken(serverTokenResponse.id_token || Constants.EMPTY_STRING, this.cryptoObj);
5168
5469
  // token nonce check (TODO: Add a warning if no nonce is given?)
@@ -5188,16 +5489,16 @@ var ResponseHandler = /** @class */ (function () {
5188
5489
  // Add keyId from request to serverTokenResponse if defined
5189
5490
  serverTokenResponse.key_id = serverTokenResponse.key_id || request.sshKid || undefined;
5190
5491
  cacheRecord = this.generateCacheRecord(serverTokenResponse, authority, reqTimestamp, request, idTokenObj, userAssertionHash, authCodePayload);
5191
- _a.label = 1;
5492
+ _b.label = 1;
5192
5493
  case 1:
5193
- _a.trys.push([1, , 5, 8]);
5494
+ _b.trys.push([1, , 5, 8]);
5194
5495
  if (!(this.persistencePlugin && this.serializableCache)) return [3 /*break*/, 3];
5195
5496
  this.logger.verbose("Persistence enabled, calling beforeCacheAccess");
5196
5497
  cacheContext = new TokenCacheContext(this.serializableCache, true);
5197
5498
  return [4 /*yield*/, this.persistencePlugin.beforeCacheAccess(cacheContext)];
5198
5499
  case 2:
5199
- _a.sent();
5200
- _a.label = 3;
5500
+ _b.sent();
5501
+ _b.label = 3;
5201
5502
  case 3:
5202
5503
  /*
5203
5504
  * When saving a refreshed tokens to the cache, it is expected that the account that was used is present in the cache.
@@ -5215,17 +5516,17 @@ var ResponseHandler = /** @class */ (function () {
5215
5516
  }
5216
5517
  return [4 /*yield*/, this.cacheStorage.saveCacheRecord(cacheRecord)];
5217
5518
  case 4:
5218
- _a.sent();
5519
+ _b.sent();
5219
5520
  return [3 /*break*/, 8];
5220
5521
  case 5:
5221
5522
  if (!(this.persistencePlugin && this.serializableCache && cacheContext)) return [3 /*break*/, 7];
5222
5523
  this.logger.verbose("Persistence enabled, calling afterCacheAccess");
5223
5524
  return [4 /*yield*/, this.persistencePlugin.afterCacheAccess(cacheContext)];
5224
5525
  case 6:
5225
- _a.sent();
5226
- _a.label = 7;
5526
+ _b.sent();
5527
+ _b.label = 7;
5227
5528
  case 7: return [7 /*endfinally*/];
5228
- case 8: return [2 /*return*/, ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenObj, requestStateObj, serverTokenResponse.spa_code, serverRequestId)];
5529
+ case 8: return [2 /*return*/, ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenObj, requestStateObj, serverTokenResponse, serverRequestId)];
5229
5530
  }
5230
5531
  });
5231
5532
  });
@@ -5311,7 +5612,7 @@ var ResponseHandler = /** @class */ (function () {
5311
5612
  * @param fromTokenCache
5312
5613
  * @param stateString
5313
5614
  */
5314
- ResponseHandler.generateAuthenticationResult = function (cryptoObj, authority, cacheRecord, fromTokenCache, request, idTokenObj, requestState, code, requestId) {
5615
+ ResponseHandler.generateAuthenticationResult = function (cryptoObj, authority, cacheRecord, fromTokenCache, request, idTokenObj, requestState, serverTokenResponse, requestId) {
5315
5616
  var _a, _b, _c;
5316
5617
  return __awaiter(this, void 0, void 0, function () {
5317
5618
  var accessToken, responseScopes, expiresOn, extExpiresOn, familyId, popTokenGenerator, _d, secret, keyId, uid, tid;
@@ -5347,6 +5648,10 @@ var ResponseHandler = /** @class */ (function () {
5347
5648
  }
5348
5649
  uid = (idTokenObj === null || idTokenObj === void 0 ? void 0 : idTokenObj.claims.oid) || (idTokenObj === null || idTokenObj === void 0 ? void 0 : idTokenObj.claims.sub) || Constants.EMPTY_STRING;
5349
5650
  tid = (idTokenObj === null || idTokenObj === void 0 ? void 0 : idTokenObj.claims.tid) || Constants.EMPTY_STRING;
5651
+ // for hybrid + native bridge enablement, send back the native account Id
5652
+ if ((serverTokenResponse === null || serverTokenResponse === void 0 ? void 0 : serverTokenResponse.spa_accountid) && !!cacheRecord.account) {
5653
+ cacheRecord.account.nativeAccountId = serverTokenResponse === null || serverTokenResponse === void 0 ? void 0 : serverTokenResponse.spa_accountid;
5654
+ }
5350
5655
  return [2 /*return*/, {
5351
5656
  authority: authority.canonicalAuthority,
5352
5657
  uniqueId: uid,
@@ -5366,7 +5671,7 @@ var ResponseHandler = /** @class */ (function () {
5366
5671
  state: requestState ? requestState.userRequestState : Constants.EMPTY_STRING,
5367
5672
  cloudGraphHostName: ((_b = cacheRecord.account) === null || _b === void 0 ? void 0 : _b.cloudGraphHostName) || Constants.EMPTY_STRING,
5368
5673
  msGraphHost: ((_c = cacheRecord.account) === null || _c === void 0 ? void 0 : _c.msGraphHost) || Constants.EMPTY_STRING,
5369
- code: code,
5674
+ code: serverTokenResponse === null || serverTokenResponse === void 0 ? void 0 : serverTokenResponse.spa_code,
5370
5675
  fromNativeBroker: false,
5371
5676
  }];
5372
5677
  }
@@ -5376,7 +5681,7 @@ var ResponseHandler = /** @class */ (function () {
5376
5681
  return ResponseHandler;
5377
5682
  }());
5378
5683
 
5379
- /*! @azure/msal-common v9.0.2 2023-01-10 */
5684
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
5380
5685
 
5381
5686
  /*
5382
5687
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5404,13 +5709,17 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
5404
5709
  * @param request
5405
5710
  */
5406
5711
  AuthorizationCodeClient.prototype.getAuthCodeUrl = function (request) {
5712
+ var _a, _b;
5407
5713
  return __awaiter(this, void 0, void 0, function () {
5408
5714
  var queryString;
5409
- return __generator(this, function (_a) {
5410
- switch (_a.label) {
5411
- case 0: return [4 /*yield*/, this.createAuthCodeUrlQueryString(request)];
5715
+ return __generator(this, function (_c) {
5716
+ switch (_c.label) {
5717
+ case 0:
5718
+ (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.GetAuthCodeUrl, request.correlationId);
5719
+ (_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.setPreQueueTime(exports.PerformanceEvents.AuthClientCreateQueryString, request.correlationId);
5720
+ return [4 /*yield*/, this.createAuthCodeUrlQueryString(request)];
5412
5721
  case 1:
5413
- queryString = _a.sent();
5722
+ queryString = _c.sent();
5414
5723
  return [2 /*return*/, UrlString.appendQueryString(this.authority.authorizationEndpoint, queryString)];
5415
5724
  }
5416
5725
  });
@@ -5422,32 +5731,35 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
5422
5731
  * @param request
5423
5732
  */
5424
5733
  AuthorizationCodeClient.prototype.acquireToken = function (request, authCodePayload) {
5425
- var _a, _b, _c;
5734
+ var _a, _b, _c, _d, _e, _f;
5426
5735
  return __awaiter(this, void 0, void 0, function () {
5427
5736
  var atsMeasurement, reqTimestamp, response, requestId, httpVerAuthority, responseHandler;
5428
5737
  var _this = this;
5429
- return __generator(this, function (_d) {
5430
- switch (_d.label) {
5738
+ return __generator(this, function (_g) {
5739
+ switch (_g.label) {
5431
5740
  case 0:
5432
- atsMeasurement = (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.startMeasurement("AuthCodeClientAcquireToken", request.correlationId);
5433
- this.logger.info("in acquireToken call in auth-code client");
5434
- if (!request || StringUtils.isEmpty(request.code)) {
5741
+ if (!request || !request.code) {
5435
5742
  throw ClientAuthError.createTokenRequestCannotBeMadeError();
5436
5743
  }
5744
+ (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.AuthClientAcquireToken, request.correlationId);
5745
+ atsMeasurement = (_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.startMeasurement("AuthCodeClientAcquireToken", request.correlationId);
5746
+ this.logger.info("in acquireToken call in auth-code client");
5437
5747
  reqTimestamp = TimeUtils.nowSeconds();
5748
+ (_c = this.performanceClient) === null || _c === void 0 ? void 0 : _c.setPreQueueTime(exports.PerformanceEvents.AuthClientExecuteTokenRequest, request.correlationId);
5438
5749
  return [4 /*yield*/, this.executeTokenRequest(this.authority, request)];
5439
5750
  case 1:
5440
- response = _d.sent();
5441
- requestId = (_b = response.headers) === null || _b === void 0 ? void 0 : _b[HeaderNames.X_MS_REQUEST_ID];
5442
- httpVerAuthority = (_c = response.headers) === null || _c === void 0 ? void 0 : _c[HeaderNames.X_MS_HTTP_VERSION];
5751
+ response = _g.sent();
5752
+ requestId = (_d = response.headers) === null || _d === void 0 ? void 0 : _d[HeaderNames.X_MS_REQUEST_ID];
5753
+ httpVerAuthority = (_e = response.headers) === null || _e === void 0 ? void 0 : _e[HeaderNames.X_MS_HTTP_VERSION];
5443
5754
  if (httpVerAuthority) {
5444
5755
  atsMeasurement === null || atsMeasurement === void 0 ? void 0 : atsMeasurement.addStaticFields({
5445
5756
  httpVerAuthority: httpVerAuthority
5446
5757
  });
5447
5758
  }
5448
- responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, this.config.serializableCache, this.config.persistencePlugin);
5759
+ responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, this.config.serializableCache, this.config.persistencePlugin, this.performanceClient);
5449
5760
  // Validate response. This function throws a server error if an error is returned by the server.
5450
5761
  responseHandler.validateTokenResponse(response.body);
5762
+ (_f = this.performanceClient) === null || _f === void 0 ? void 0 : _f.setPreQueueTime(exports.PerformanceEvents.HandleServerTokenResponse, request.correlationId);
5451
5763
  return [2 /*return*/, responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request, authCodePayload, undefined, undefined, undefined, requestId).then(function (result) {
5452
5764
  atsMeasurement === null || atsMeasurement === void 0 ? void 0 : atsMeasurement.endMeasurement({
5453
5765
  success: true
@@ -5509,26 +5821,19 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
5509
5821
  * @param request
5510
5822
  */
5511
5823
  AuthorizationCodeClient.prototype.executeTokenRequest = function (authority, request) {
5824
+ var _a, _b;
5512
5825
  return __awaiter(this, void 0, void 0, function () {
5513
- var thumbprint, requestBody, queryParameters, ccsCredential, clientInfo, headers, endpoint;
5514
- return __generator(this, function (_a) {
5515
- switch (_a.label) {
5826
+ var queryParametersString, endpoint, requestBody, ccsCredential, clientInfo, headers, thumbprint;
5827
+ return __generator(this, function (_c) {
5828
+ switch (_c.label) {
5516
5829
  case 0:
5517
- thumbprint = {
5518
- clientId: this.config.authOptions.clientId,
5519
- authority: authority.canonicalAuthority,
5520
- scopes: request.scopes,
5521
- claims: request.claims,
5522
- authenticationScheme: request.authenticationScheme,
5523
- resourceRequestMethod: request.resourceRequestMethod,
5524
- resourceRequestUri: request.resourceRequestUri,
5525
- shrClaims: request.shrClaims,
5526
- sshKid: request.sshKid
5527
- };
5830
+ (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.AuthClientExecuteTokenRequest, request.correlationId);
5831
+ (_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.setPreQueueTime(exports.PerformanceEvents.AuthClientCreateTokenRequestBody, request.correlationId);
5832
+ queryParametersString = this.createTokenQueryParameters(request);
5833
+ endpoint = UrlString.appendQueryString(authority.tokenEndpoint, queryParametersString);
5528
5834
  return [4 /*yield*/, this.createTokenRequestBody(request)];
5529
5835
  case 1:
5530
- requestBody = _a.sent();
5531
- queryParameters = this.createTokenQueryParameters(request);
5836
+ requestBody = _c.sent();
5532
5837
  ccsCredential = undefined;
5533
5838
  if (request.clientInfo) {
5534
5839
  try {
@@ -5543,34 +5848,35 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
5543
5848
  }
5544
5849
  }
5545
5850
  headers = this.createTokenRequestHeaders(ccsCredential || request.ccsCredential);
5546
- endpoint = StringUtils.isEmpty(queryParameters) ? authority.tokenEndpoint : authority.tokenEndpoint + "?" + queryParameters;
5851
+ thumbprint = {
5852
+ clientId: this.config.authOptions.clientId,
5853
+ authority: authority.canonicalAuthority,
5854
+ scopes: request.scopes,
5855
+ claims: request.claims,
5856
+ authenticationScheme: request.authenticationScheme,
5857
+ resourceRequestMethod: request.resourceRequestMethod,
5858
+ resourceRequestUri: request.resourceRequestUri,
5859
+ shrClaims: request.shrClaims,
5860
+ sshKid: request.sshKid
5861
+ };
5547
5862
  return [2 /*return*/, this.executePostToTokenEndpoint(endpoint, requestBody, headers, thumbprint)];
5548
5863
  }
5549
5864
  });
5550
5865
  });
5551
5866
  };
5552
- /**
5553
- * Creates query string for the /token request
5554
- * @param request
5555
- */
5556
- AuthorizationCodeClient.prototype.createTokenQueryParameters = function (request) {
5557
- var parameterBuilder = new RequestParameterBuilder();
5558
- if (request.tokenQueryParameters) {
5559
- parameterBuilder.addExtraQueryParameters(request.tokenQueryParameters);
5560
- }
5561
- return parameterBuilder.createQueryString();
5562
- };
5563
5867
  /**
5564
5868
  * Generates a map for all the params to be sent to the service
5565
5869
  * @param request
5566
5870
  */
5567
5871
  AuthorizationCodeClient.prototype.createTokenRequestBody = function (request) {
5872
+ var _a, _b;
5568
5873
  return __awaiter(this, void 0, void 0, function () {
5569
5874
  var parameterBuilder, clientAssertion, popTokenGenerator, reqCnfData, correlationId, ccsCred, clientInfo, clientInfo;
5570
- var _a;
5571
- return __generator(this, function (_b) {
5572
- switch (_b.label) {
5875
+ var _c;
5876
+ return __generator(this, function (_d) {
5877
+ switch (_d.label) {
5573
5878
  case 0:
5879
+ (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.AuthClientCreateTokenRequestBody, request.correlationId);
5574
5880
  parameterBuilder = new RequestParameterBuilder();
5575
5881
  parameterBuilder.addClientId(this.config.authOptions.clientId);
5576
5882
  /*
@@ -5611,10 +5917,11 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
5611
5917
  parameterBuilder.addGrantType(GrantType.AUTHORIZATION_CODE_GRANT);
5612
5918
  parameterBuilder.addClientInfo();
5613
5919
  if (!(request.authenticationScheme === exports.AuthenticationScheme.POP)) return [3 /*break*/, 2];
5614
- popTokenGenerator = new PopTokenGenerator(this.cryptoUtils);
5920
+ popTokenGenerator = new PopTokenGenerator(this.cryptoUtils, this.performanceClient);
5921
+ (_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.setPreQueueTime(exports.PerformanceEvents.PopTokenGenerateCnf, request.correlationId);
5615
5922
  return [4 /*yield*/, popTokenGenerator.generateCnf(request)];
5616
5923
  case 1:
5617
- reqCnfData = _b.sent();
5924
+ reqCnfData = _d.sent();
5618
5925
  // SPA PoP requires full Base64Url encoded req_cnf string (unhashed)
5619
5926
  parameterBuilder.addPopToken(reqCnfData.reqCnfString);
5620
5927
  return [3 /*break*/, 3];
@@ -5627,7 +5934,7 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
5627
5934
  throw ClientConfigurationError.createMissingSshJwkError();
5628
5935
  }
5629
5936
  }
5630
- _b.label = 3;
5937
+ _d.label = 3;
5631
5938
  case 3:
5632
5939
  correlationId = request.correlationId || this.config.cryptoInterface.createNewGuid();
5633
5940
  parameterBuilder.addCorrelationId(correlationId);
@@ -5672,9 +5979,9 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
5672
5979
  }
5673
5980
  // Add hybrid spa parameters if not already provided
5674
5981
  if (request.enableSpaAuthorizationCode && (!request.tokenBodyParameters || !request.tokenBodyParameters[AADServerParamKeys.RETURN_SPA_CODE])) {
5675
- parameterBuilder.addExtraQueryParameters((_a = {},
5676
- _a[AADServerParamKeys.RETURN_SPA_CODE] = "1",
5677
- _a));
5982
+ parameterBuilder.addExtraQueryParameters((_c = {},
5983
+ _c[AADServerParamKeys.RETURN_SPA_CODE] = "1",
5984
+ _c));
5678
5985
  }
5679
5986
  return [2 /*return*/, parameterBuilder.createQueryString()];
5680
5987
  }
@@ -5686,11 +5993,13 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
5686
5993
  * @param request
5687
5994
  */
5688
5995
  AuthorizationCodeClient.prototype.createAuthCodeUrlQueryString = function (request) {
5996
+ var _a;
5689
5997
  return __awaiter(this, void 0, void 0, function () {
5690
5998
  var parameterBuilder, requestScopes, correlationId, accountSid, accountLoginHintClaim, clientInfo, clientInfo, clientInfo, popTokenGenerator, reqCnfData;
5691
- return __generator(this, function (_a) {
5692
- switch (_a.label) {
5999
+ return __generator(this, function (_b) {
6000
+ switch (_b.label) {
5693
6001
  case 0:
6002
+ (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.AuthClientCreateQueryString, request.correlationId);
5694
6003
  parameterBuilder = new RequestParameterBuilder();
5695
6004
  parameterBuilder.addClientId(this.config.authOptions.clientId);
5696
6005
  requestScopes = __spreadArrays(request.scopes || [], request.extraScopesToConsent || []);
@@ -5801,9 +6110,9 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
5801
6110
  popTokenGenerator = new PopTokenGenerator(this.cryptoUtils);
5802
6111
  return [4 /*yield*/, popTokenGenerator.generateCnf(request)];
5803
6112
  case 1:
5804
- reqCnfData = _a.sent();
6113
+ reqCnfData = _b.sent();
5805
6114
  parameterBuilder.addPopToken(reqCnfData.reqCnfHash);
5806
- _a.label = 2;
6115
+ _b.label = 2;
5807
6116
  case 2: return [2 /*return*/, parameterBuilder.createQueryString()];
5808
6117
  }
5809
6118
  });
@@ -5850,137 +6159,7 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
5850
6159
  return AuthorizationCodeClient;
5851
6160
  }(BaseClient));
5852
6161
 
5853
- /*! @azure/msal-common v9.0.2 2023-01-10 */
5854
- /*
5855
- * Copyright (c) Microsoft Corporation. All rights reserved.
5856
- * Licensed under the MIT License.
5857
- */
5858
- /**
5859
- * Enumeration of operations that are instrumented by have their performance measured by the PerformanceClient.
5860
- *
5861
- * @export
5862
- * @enum {number}
5863
- */
5864
- exports.PerformanceEvents = void 0;
5865
- (function (PerformanceEvents) {
5866
- /**
5867
- * acquireTokenByCode API (msal-browser and msal-node).
5868
- * Used to acquire tokens by trading an authorization code against the token endpoint.
5869
- */
5870
- PerformanceEvents["AcquireTokenByCode"] = "acquireTokenByCode";
5871
- /**
5872
- * acquireTokenByRefreshToken API (msal-browser and msal-node).
5873
- * Used to renew an access token using a refresh token against the token endpoint.
5874
- */
5875
- PerformanceEvents["AcquireTokenByRefreshToken"] = "acquireTokenByRefreshToken";
5876
- /**
5877
- * acquireTokenSilent API (msal-browser and msal-node).
5878
- * Used to silently acquire a new access token (from the cache or the network).
5879
- */
5880
- PerformanceEvents["AcquireTokenSilent"] = "acquireTokenSilent";
5881
- /**
5882
- * acquireTokenSilentAsync (msal-browser).
5883
- * Internal API for acquireTokenSilent.
5884
- */
5885
- PerformanceEvents["AcquireTokenSilentAsync"] = "acquireTokenSilentAsync";
5886
- /**
5887
- * acquireTokenPopup (msal-browser).
5888
- * Used to acquire a new access token interactively through pop ups
5889
- */
5890
- PerformanceEvents["AcquireTokenPopup"] = "acquireTokenPopup";
5891
- /**
5892
- * getPublicKeyThumbprint API in CryptoOpts class (msal-browser).
5893
- * Used to generate a public/private keypair and generate a public key thumbprint for pop requests.
5894
- */
5895
- PerformanceEvents["CryptoOptsGetPublicKeyThumbprint"] = "cryptoOptsGetPublicKeyThumbprint";
5896
- /**
5897
- * signJwt API in CryptoOpts class (msal-browser).
5898
- * Used to signed a pop token.
5899
- */
5900
- PerformanceEvents["CryptoOptsSignJwt"] = "cryptoOptsSignJwt";
5901
- /**
5902
- * acquireToken API in the SilentCacheClient class (msal-browser).
5903
- * Used to read access tokens from the cache.
5904
- */
5905
- PerformanceEvents["SilentCacheClientAcquireToken"] = "silentCacheClientAcquireToken";
5906
- /**
5907
- * acquireToken API in the SilentIframeClient class (msal-browser).
5908
- * Used to acquire a new set of tokens from the authorize endpoint in a hidden iframe.
5909
- */
5910
- PerformanceEvents["SilentIframeClientAcquireToken"] = "silentIframeClientAcquireToken";
5911
- /**
5912
- * acquireToken API in SilentRereshClient (msal-browser).
5913
- * Used to acquire a new set of tokens from the token endpoint using a refresh token.
5914
- */
5915
- PerformanceEvents["SilentRefreshClientAcquireToken"] = "silentRefreshClientAcquireToken";
5916
- /**
5917
- * ssoSilent API (msal-browser).
5918
- * Used to silently acquire an authorization code and set of tokens using a hidden iframe.
5919
- */
5920
- PerformanceEvents["SsoSilent"] = "ssoSilent";
5921
- /**
5922
- * getDiscoveredAuthority API in StandardInteractionClient class (msal-browser).
5923
- * Used to load authority metadata for a request.
5924
- */
5925
- PerformanceEvents["StandardInteractionClientGetDiscoveredAuthority"] = "standardInteractionClientGetDiscoveredAuthority";
5926
- /**
5927
- * acquireToken APIs in msal-browser.
5928
- * Used to make an /authorize endpoint call with native brokering enabled.
5929
- */
5930
- PerformanceEvents["FetchAccountIdWithNativeBroker"] = "fetchAccountIdWithNativeBroker";
5931
- /**
5932
- * acquireToken API in NativeInteractionClient class (msal-browser).
5933
- * Used to acquire a token from Native component when native brokering is enabled.
5934
- */
5935
- PerformanceEvents["NativeInteractionClientAcquireToken"] = "nativeInteractionClientAcquireToken";
5936
- /**
5937
- * Time spent creating default headers for requests to token endpoint
5938
- */
5939
- PerformanceEvents["BaseClientCreateTokenRequestHeaders"] = "baseClientCreateTokenRequestHeaders";
5940
- /**
5941
- * Used to measure the time taken for completing embedded-broker handshake (PW-Broker).
5942
- */
5943
- PerformanceEvents["BrokerHandhshake"] = "brokerHandshake";
5944
- /**
5945
- * acquireTokenByRefreshToken API in BrokerClientApplication (PW-Broker) .
5946
- */
5947
- PerformanceEvents["AcquireTokenByRefreshTokenInBroker"] = "acquireTokenByRefreshTokenInBroker";
5948
- /**
5949
- * Time taken for token acquisition by broker
5950
- */
5951
- PerformanceEvents["AcquireTokenByBroker"] = "acquireTokenByBroker";
5952
- /**
5953
- * Time spent on the network for refresh token acquisition
5954
- */
5955
- PerformanceEvents["RefreshTokenClientExecuteTokenRequest"] = "refreshTokenClientExecuteTokenRequest";
5956
- /**
5957
- * Time taken for acquiring refresh token , records RT size
5958
- */
5959
- PerformanceEvents["RefreshTokenClientAcquireToken"] = "refreshTokenClientAcquireToken";
5960
- /**
5961
- * Time taken for acquiring cached refresh token
5962
- */
5963
- PerformanceEvents["RefreshTokenClientAcquireTokenWithCachedRefreshToken"] = "refreshTokenClientAcquireTokenWithCachedRefreshToken";
5964
- PerformanceEvents["GetEndpointMetadataFromNetwork"] = "getEndpointMetadataFromNetwork";
5965
- PerformanceEvents["GetCloudDiscoveryMetadataFromNetworkMeasurement"] = "getCloudDiscoveryMetadataFromNetworkMeasurement";
5966
- PerformanceEvents["HandleRedirectPromiseMeasurement"] = "handleRedirectPromiseMeasurement";
5967
- PerformanceEvents["UpdateCloudDiscoveryMetadataMeasurement"] = "updateCloudDiscoveryMetadataMeasurement";
5968
- PerformanceEvents["UsernamePasswordClientAcquireToken"] = "usernamePasswordClientAcquireToken";
5969
- })(exports.PerformanceEvents || (exports.PerformanceEvents = {}));
5970
- /**
5971
- * State of the performance event.
5972
- *
5973
- * @export
5974
- * @enum {number}
5975
- */
5976
- var PerformanceEventStatus;
5977
- (function (PerformanceEventStatus) {
5978
- PerformanceEventStatus[PerformanceEventStatus["NotStarted"] = 0] = "NotStarted";
5979
- PerformanceEventStatus[PerformanceEventStatus["InProgress"] = 1] = "InProgress";
5980
- PerformanceEventStatus[PerformanceEventStatus["Completed"] = 2] = "Completed";
5981
- })(PerformanceEventStatus || (PerformanceEventStatus = {}));
5982
-
5983
- /*! @azure/msal-common v9.0.2 2023-01-10 */
6162
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
5984
6163
 
5985
6164
  /*
5986
6165
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5995,31 +6174,34 @@ var RefreshTokenClient = /** @class */ (function (_super) {
5995
6174
  return _super.call(this, configuration, performanceClient) || this;
5996
6175
  }
5997
6176
  RefreshTokenClient.prototype.acquireToken = function (request) {
5998
- var _a, _b, _c, _d;
6177
+ var _a, _b, _c, _d, _e, _f, _g;
5999
6178
  return __awaiter(this, void 0, void 0, function () {
6000
6179
  var atsMeasurement, reqTimestamp, response, httpVerToken, requestId, responseHandler;
6001
6180
  var _this = this;
6002
- return __generator(this, function (_e) {
6003
- switch (_e.label) {
6181
+ return __generator(this, function (_h) {
6182
+ switch (_h.label) {
6004
6183
  case 0:
6005
- atsMeasurement = (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.startMeasurement(exports.PerformanceEvents.RefreshTokenClientAcquireToken, request.correlationId);
6184
+ (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.RefreshTokenClientAcquireToken, request.correlationId);
6185
+ atsMeasurement = (_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.startMeasurement(exports.PerformanceEvents.RefreshTokenClientAcquireToken, request.correlationId);
6006
6186
  this.logger.verbose("RefreshTokenClientAcquireToken called", request.correlationId);
6007
6187
  reqTimestamp = TimeUtils.nowSeconds();
6188
+ (_c = this.performanceClient) === null || _c === void 0 ? void 0 : _c.setPreQueueTime(exports.PerformanceEvents.RefreshTokenClientExecuteTokenRequest, request.correlationId);
6008
6189
  return [4 /*yield*/, this.executeTokenRequest(request, this.authority)];
6009
6190
  case 1:
6010
- response = _e.sent();
6011
- httpVerToken = (_b = response.headers) === null || _b === void 0 ? void 0 : _b[HeaderNames.X_MS_HTTP_VERSION];
6191
+ response = _h.sent();
6192
+ httpVerToken = (_d = response.headers) === null || _d === void 0 ? void 0 : _d[HeaderNames.X_MS_HTTP_VERSION];
6012
6193
  atsMeasurement === null || atsMeasurement === void 0 ? void 0 : atsMeasurement.addStaticFields({
6013
- refreshTokenSize: ((_c = response.body.refresh_token) === null || _c === void 0 ? void 0 : _c.length) || 0,
6194
+ refreshTokenSize: ((_e = response.body.refresh_token) === null || _e === void 0 ? void 0 : _e.length) || 0,
6014
6195
  });
6015
6196
  if (httpVerToken) {
6016
6197
  atsMeasurement === null || atsMeasurement === void 0 ? void 0 : atsMeasurement.addStaticFields({
6017
6198
  httpVerToken: httpVerToken,
6018
6199
  });
6019
6200
  }
6020
- requestId = (_d = response.headers) === null || _d === void 0 ? void 0 : _d[HeaderNames.X_MS_REQUEST_ID];
6201
+ requestId = (_f = response.headers) === null || _f === void 0 ? void 0 : _f[HeaderNames.X_MS_REQUEST_ID];
6021
6202
  responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, this.config.serializableCache, this.config.persistencePlugin);
6022
6203
  responseHandler.validateTokenResponse(response.body);
6204
+ (_g = this.performanceClient) === null || _g === void 0 ? void 0 : _g.setPreQueueTime(exports.PerformanceEvents.HandleServerTokenResponse, request.correlationId);
6023
6205
  return [2 /*return*/, responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request, undefined, undefined, true, request.forceCache, requestId).then(function (result) {
6024
6206
  atsMeasurement === null || atsMeasurement === void 0 ? void 0 : atsMeasurement.endMeasurement({
6025
6207
  success: true
@@ -6044,13 +6226,15 @@ var RefreshTokenClient = /** @class */ (function (_super) {
6044
6226
  * @param request
6045
6227
  */
6046
6228
  RefreshTokenClient.prototype.acquireTokenByRefreshToken = function (request) {
6229
+ var _a, _b, _c, _d;
6047
6230
  return __awaiter(this, void 0, void 0, function () {
6048
6231
  var isFOCI, noFamilyRTInCache, clientMismatchErrorWithFamilyRT;
6049
- return __generator(this, function (_a) {
6232
+ return __generator(this, function (_e) {
6050
6233
  // Cannot renew token if no request object is given.
6051
6234
  if (!request) {
6052
6235
  throw ClientConfigurationError.createEmptyTokenRequestError();
6053
6236
  }
6237
+ (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.RefreshTokenClientAcquireTokenByRefreshToken, request.correlationId);
6054
6238
  // We currently do not support silent flow for account === null use cases; This will be revisited for confidential flow usecases
6055
6239
  if (!request.account) {
6056
6240
  throw ClientAuthError.createNoAccountInSilentRequestError();
@@ -6059,6 +6243,7 @@ var RefreshTokenClient = /** @class */ (function (_super) {
6059
6243
  // if the app is part of the family, retrive a Family refresh token if present and make a refreshTokenRequest
6060
6244
  if (isFOCI) {
6061
6245
  try {
6246
+ (_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.setPreQueueTime(exports.PerformanceEvents.RefreshTokenClientAcquireTokenWithCachedRefreshToken, request.correlationId);
6062
6247
  return [2 /*return*/, this.acquireTokenWithCachedRefreshToken(request, true)];
6063
6248
  }
6064
6249
  catch (e) {
@@ -6066,6 +6251,7 @@ var RefreshTokenClient = /** @class */ (function (_super) {
6066
6251
  clientMismatchErrorWithFamilyRT = e instanceof ServerError && e.errorCode === Errors.INVALID_GRANT_ERROR && e.subError === Errors.CLIENT_MISMATCH_ERROR;
6067
6252
  // if family Refresh Token (FRT) cache acquisition fails or if client_mismatch error is seen with FRT, reattempt with application Refresh Token (ART)
6068
6253
  if (noFamilyRTInCache || clientMismatchErrorWithFamilyRT) {
6254
+ (_c = this.performanceClient) === null || _c === void 0 ? void 0 : _c.setPreQueueTime(exports.PerformanceEvents.RefreshTokenClientAcquireTokenWithCachedRefreshToken, request.correlationId);
6069
6255
  return [2 /*return*/, this.acquireTokenWithCachedRefreshToken(request, false)];
6070
6256
  // throw in all other cases
6071
6257
  }
@@ -6075,6 +6261,7 @@ var RefreshTokenClient = /** @class */ (function (_super) {
6075
6261
  }
6076
6262
  }
6077
6263
  // fall back to application refresh token acquisition
6264
+ (_d = this.performanceClient) === null || _d === void 0 ? void 0 : _d.setPreQueueTime(exports.PerformanceEvents.RefreshTokenClientAcquireTokenWithCachedRefreshToken, request.correlationId);
6078
6265
  return [2 /*return*/, this.acquireTokenWithCachedRefreshToken(request, false)];
6079
6266
  });
6080
6267
  });
@@ -6084,11 +6271,12 @@ var RefreshTokenClient = /** @class */ (function (_super) {
6084
6271
  * @param request
6085
6272
  */
6086
6273
  RefreshTokenClient.prototype.acquireTokenWithCachedRefreshToken = function (request, foci) {
6087
- var _a;
6274
+ var _a, _b, _c;
6088
6275
  return __awaiter(this, void 0, void 0, function () {
6089
6276
  var atsMeasurement, refreshToken, refreshTokenRequest;
6090
- return __generator(this, function (_b) {
6091
- atsMeasurement = (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.startMeasurement(exports.PerformanceEvents.RefreshTokenClientAcquireTokenWithCachedRefreshToken, request.correlationId);
6277
+ return __generator(this, function (_d) {
6278
+ (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.RefreshTokenClientAcquireTokenWithCachedRefreshToken, request.correlationId);
6279
+ atsMeasurement = (_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.startMeasurement(exports.PerformanceEvents.RefreshTokenClientAcquireTokenWithCachedRefreshToken, request.correlationId);
6092
6280
  this.logger.verbose("RefreshTokenClientAcquireTokenWithCachedRefreshToken called", request.correlationId);
6093
6281
  refreshToken = this.cacheManager.readRefreshTokenFromCache(this.config.authOptions.clientId, request.account, foci);
6094
6282
  if (!refreshToken) {
@@ -6103,6 +6291,7 @@ var RefreshTokenClient = /** @class */ (function (_super) {
6103
6291
  credential: request.account.homeAccountId,
6104
6292
  type: CcsCredentialType.HOME_ACCOUNT_ID
6105
6293
  } });
6294
+ (_c = this.performanceClient) === null || _c === void 0 ? void 0 : _c.setPreQueueTime(exports.PerformanceEvents.RefreshTokenClientAcquireToken, request.correlationId);
6106
6295
  return [2 /*return*/, this.acquireToken(refreshTokenRequest)];
6107
6296
  });
6108
6297
  });
@@ -6113,17 +6302,20 @@ var RefreshTokenClient = /** @class */ (function (_super) {
6113
6302
  * @param authority
6114
6303
  */
6115
6304
  RefreshTokenClient.prototype.executeTokenRequest = function (request, authority) {
6116
- var _a;
6305
+ var _a, _b, _c;
6117
6306
  return __awaiter(this, void 0, void 0, function () {
6118
- var acquireTokenMeasurement, requestBody, queryParameters, headers, thumbprint, endpoint;
6119
- return __generator(this, function (_b) {
6120
- switch (_b.label) {
6307
+ var acquireTokenMeasurement, queryParametersString, endpoint, requestBody, headers, thumbprint;
6308
+ return __generator(this, function (_d) {
6309
+ switch (_d.label) {
6121
6310
  case 0:
6122
- acquireTokenMeasurement = (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.startMeasurement(exports.PerformanceEvents.RefreshTokenClientExecuteTokenRequest, request.correlationId);
6311
+ (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.RefreshTokenClientExecuteTokenRequest, request.correlationId);
6312
+ acquireTokenMeasurement = (_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.startMeasurement(exports.PerformanceEvents.RefreshTokenClientExecuteTokenRequest, request.correlationId);
6313
+ (_c = this.performanceClient) === null || _c === void 0 ? void 0 : _c.setPreQueueTime(exports.PerformanceEvents.RefreshTokenClientCreateTokenRequestBody, request.correlationId);
6314
+ queryParametersString = this.createTokenQueryParameters(request);
6315
+ endpoint = UrlString.appendQueryString(authority.tokenEndpoint, queryParametersString);
6123
6316
  return [4 /*yield*/, this.createTokenRequestBody(request)];
6124
6317
  case 1:
6125
- requestBody = _b.sent();
6126
- queryParameters = this.createTokenQueryParameters(request);
6318
+ requestBody = _d.sent();
6127
6319
  headers = this.createTokenRequestHeaders(request.ccsCredential);
6128
6320
  thumbprint = {
6129
6321
  clientId: this.config.authOptions.clientId,
@@ -6136,7 +6328,6 @@ var RefreshTokenClient = /** @class */ (function (_super) {
6136
6328
  shrClaims: request.shrClaims,
6137
6329
  sshKid: request.sshKid
6138
6330
  };
6139
- endpoint = UrlString.appendQueryString(authority.tokenEndpoint, queryParameters);
6140
6331
  return [2 /*return*/, this.executePostToTokenEndpoint(endpoint, requestBody, headers, thumbprint)
6141
6332
  .then(function (result) {
6142
6333
  acquireTokenMeasurement === null || acquireTokenMeasurement === void 0 ? void 0 : acquireTokenMeasurement.endMeasurement({
@@ -6154,30 +6345,20 @@ var RefreshTokenClient = /** @class */ (function (_super) {
6154
6345
  });
6155
6346
  });
6156
6347
  };
6157
- /**
6158
- * Creates query string for the /token request
6159
- * @param request
6160
- */
6161
- RefreshTokenClient.prototype.createTokenQueryParameters = function (request) {
6162
- var parameterBuilder = new RequestParameterBuilder();
6163
- if (request.tokenQueryParameters) {
6164
- parameterBuilder.addExtraQueryParameters(request.tokenQueryParameters);
6165
- }
6166
- return parameterBuilder.createQueryString();
6167
- };
6168
6348
  /**
6169
6349
  * Helper function to create the token request body
6170
6350
  * @param request
6171
6351
  */
6172
6352
  RefreshTokenClient.prototype.createTokenRequestBody = function (request) {
6173
- var _a;
6353
+ var _a, _b, _c;
6174
6354
  return __awaiter(this, void 0, void 0, function () {
6175
6355
  var correlationId, acquireTokenMeasurement, parameterBuilder, clientAssertion, popTokenGenerator, reqCnfData, clientInfo;
6176
- return __generator(this, function (_b) {
6177
- switch (_b.label) {
6356
+ return __generator(this, function (_d) {
6357
+ switch (_d.label) {
6178
6358
  case 0:
6359
+ (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.RefreshTokenClientCreateTokenRequestBody, request.correlationId);
6179
6360
  correlationId = request.correlationId;
6180
- acquireTokenMeasurement = (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.startMeasurement(exports.PerformanceEvents.BaseClientCreateTokenRequestHeaders, correlationId);
6361
+ acquireTokenMeasurement = (_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.startMeasurement(exports.PerformanceEvents.BaseClientCreateTokenRequestHeaders, correlationId);
6181
6362
  parameterBuilder = new RequestParameterBuilder();
6182
6363
  parameterBuilder.addClientId(this.config.authOptions.clientId);
6183
6364
  parameterBuilder.addScopes(request.scopes);
@@ -6200,10 +6381,11 @@ var RefreshTokenClient = /** @class */ (function (_super) {
6200
6381
  parameterBuilder.addClientAssertionType(clientAssertion.assertionType);
6201
6382
  }
6202
6383
  if (!(request.authenticationScheme === exports.AuthenticationScheme.POP)) return [3 /*break*/, 2];
6203
- popTokenGenerator = new PopTokenGenerator(this.cryptoUtils);
6384
+ popTokenGenerator = new PopTokenGenerator(this.cryptoUtils, this.performanceClient);
6385
+ (_c = this.performanceClient) === null || _c === void 0 ? void 0 : _c.setPreQueueTime(exports.PerformanceEvents.PopTokenGenerateCnf, request.correlationId);
6204
6386
  return [4 /*yield*/, popTokenGenerator.generateCnf(request)];
6205
6387
  case 1:
6206
- reqCnfData = _b.sent();
6388
+ reqCnfData = _d.sent();
6207
6389
  // SPA PoP requires full Base64Url encoded req_cnf string (unhashed)
6208
6390
  parameterBuilder.addPopToken(reqCnfData.reqCnfString);
6209
6391
  return [3 /*break*/, 3];
@@ -6219,7 +6401,7 @@ var RefreshTokenClient = /** @class */ (function (_super) {
6219
6401
  throw ClientConfigurationError.createMissingSshJwkError();
6220
6402
  }
6221
6403
  }
6222
- _b.label = 3;
6404
+ _d.label = 3;
6223
6405
  case 3:
6224
6406
  if (!StringUtils.isEmptyObj(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {
6225
6407
  parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);
@@ -6251,7 +6433,7 @@ var RefreshTokenClient = /** @class */ (function (_super) {
6251
6433
  return RefreshTokenClient;
6252
6434
  }(BaseClient));
6253
6435
 
6254
- /*! @azure/msal-common v9.0.2 2023-01-10 */
6436
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
6255
6437
 
6256
6438
  /*
6257
6439
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6375,7 +6557,7 @@ var SilentFlowClient = /** @class */ (function (_super) {
6375
6557
  return SilentFlowClient;
6376
6558
  }(BaseClient));
6377
6559
 
6378
- /*! @azure/msal-common v9.0.2 2023-01-10 */
6560
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
6379
6561
  /*
6380
6562
  * Copyright (c) Microsoft Corporation. All rights reserved.
6381
6563
  * Licensed under the MIT License.
@@ -6387,7 +6569,7 @@ function isOpenIdConfigResponse(response) {
6387
6569
  response.hasOwnProperty("jwks_uri"));
6388
6570
  }
6389
6571
 
6390
- /*! @azure/msal-common v9.0.2 2023-01-10 */
6572
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
6391
6573
  /*
6392
6574
  * Copyright (c) Microsoft Corporation. All rights reserved.
6393
6575
  * Licensed under the MIT License.
@@ -6396,7 +6578,7 @@ var rawMetdataJSON = { "endpointMetadata": { "https://login.microsoftonline.com/
6396
6578
  var EndpointMetadata = rawMetdataJSON.endpointMetadata;
6397
6579
  var InstanceDiscoveryMetadata = rawMetdataJSON.instanceDiscoveryMetadata;
6398
6580
 
6399
- /*! @azure/msal-common v9.0.2 2023-01-10 */
6581
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
6400
6582
  /*
6401
6583
  * Copyright (c) Microsoft Corporation. All rights reserved.
6402
6584
  * Licensed under the MIT License.
@@ -6410,7 +6592,7 @@ exports.ProtocolMode = void 0;
6410
6592
  ProtocolMode["OIDC"] = "OIDC";
6411
6593
  })(exports.ProtocolMode || (exports.ProtocolMode = {}));
6412
6594
 
6413
- /*! @azure/msal-common v9.0.2 2023-01-10 */
6595
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
6414
6596
 
6415
6597
  /*
6416
6598
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6487,7 +6669,7 @@ var AuthorityMetadataEntity = /** @class */ (function () {
6487
6669
  return AuthorityMetadataEntity;
6488
6670
  }());
6489
6671
 
6490
- /*! @azure/msal-common v9.0.2 2023-01-10 */
6672
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
6491
6673
  /*
6492
6674
  * Copyright (c) Microsoft Corporation. All rights reserved.
6493
6675
  * Licensed under the MIT License.
@@ -6497,7 +6679,7 @@ function isCloudInstanceDiscoveryResponse(response) {
6497
6679
  response.hasOwnProperty("metadata"));
6498
6680
  }
6499
6681
 
6500
- /*! @azure/msal-common v9.0.2 2023-01-10 */
6682
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
6501
6683
  /*
6502
6684
  * Copyright (c) Microsoft Corporation. All rights reserved.
6503
6685
  * Licensed under the MIT License.
@@ -6507,68 +6689,72 @@ function isCloudInstanceDiscoveryErrorResponse(response) {
6507
6689
  response.hasOwnProperty("error_description"));
6508
6690
  }
6509
6691
 
6510
- /*! @azure/msal-common v9.0.2 2023-01-10 */
6692
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
6511
6693
 
6512
6694
  /*
6513
6695
  * Copyright (c) Microsoft Corporation. All rights reserved.
6514
6696
  * Licensed under the MIT License.
6515
6697
  */
6516
6698
  var RegionDiscovery = /** @class */ (function () {
6517
- function RegionDiscovery(networkInterface) {
6699
+ function RegionDiscovery(networkInterface, performanceClient, correlationId) {
6518
6700
  this.networkInterface = networkInterface;
6701
+ this.performanceClient = performanceClient;
6702
+ this.correlationId = correlationId;
6519
6703
  }
6520
6704
  /**
6521
6705
  * Detect the region from the application's environment.
6522
6706
  *
6523
6707
  * @returns Promise<string | null>
6524
6708
  */
6525
- RegionDiscovery.prototype.detectRegion = function (environmentRegion, regionDiscoveryMetadata, proxyUrl) {
6709
+ RegionDiscovery.prototype.detectRegion = function (environmentRegion, regionDiscoveryMetadata) {
6710
+ var _a, _b, _c, _d;
6526
6711
  return __awaiter(this, void 0, void 0, function () {
6527
6712
  var autodetectedRegionName, options, localIMDSVersionResponse, currentIMDSVersion, currentIMDSVersionResponse;
6528
- return __generator(this, function (_a) {
6529
- switch (_a.label) {
6713
+ return __generator(this, function (_e) {
6714
+ switch (_e.label) {
6530
6715
  case 0:
6716
+ (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.RegionDiscoveryDetectRegion, this.correlationId);
6531
6717
  autodetectedRegionName = environmentRegion;
6532
6718
  if (!!autodetectedRegionName) return [3 /*break*/, 8];
6533
6719
  options = RegionDiscovery.IMDS_OPTIONS;
6534
- if (proxyUrl) {
6535
- options.proxyUrl = proxyUrl;
6536
- }
6537
- _a.label = 1;
6720
+ _e.label = 1;
6538
6721
  case 1:
6539
- _a.trys.push([1, 6, , 7]);
6722
+ _e.trys.push([1, 6, , 7]);
6723
+ (_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.setPreQueueTime(exports.PerformanceEvents.RegionDiscoveryGetRegionFromIMDS, this.correlationId);
6540
6724
  return [4 /*yield*/, this.getRegionFromIMDS(Constants.IMDS_VERSION, options)];
6541
6725
  case 2:
6542
- localIMDSVersionResponse = _a.sent();
6726
+ localIMDSVersionResponse = _e.sent();
6543
6727
  if (localIMDSVersionResponse.status === ResponseCodes.httpSuccess) {
6544
6728
  autodetectedRegionName = localIMDSVersionResponse.body;
6545
6729
  regionDiscoveryMetadata.region_source = RegionDiscoverySources.IMDS;
6546
6730
  }
6547
6731
  if (!(localIMDSVersionResponse.status === ResponseCodes.httpBadRequest)) return [3 /*break*/, 5];
6732
+ (_c = this.performanceClient) === null || _c === void 0 ? void 0 : _c.setPreQueueTime(exports.PerformanceEvents.RegionDiscoveryGetCurrentVersion, this.correlationId);
6548
6733
  return [4 /*yield*/, this.getCurrentVersion(options)];
6549
6734
  case 3:
6550
- currentIMDSVersion = _a.sent();
6735
+ currentIMDSVersion = _e.sent();
6551
6736
  if (!currentIMDSVersion) {
6552
6737
  regionDiscoveryMetadata.region_source = RegionDiscoverySources.FAILED_AUTO_DETECTION;
6553
6738
  return [2 /*return*/, null];
6554
6739
  }
6740
+ (_d = this.performanceClient) === null || _d === void 0 ? void 0 : _d.setPreQueueTime(exports.PerformanceEvents.RegionDiscoveryGetRegionFromIMDS, this.correlationId);
6555
6741
  return [4 /*yield*/, this.getRegionFromIMDS(currentIMDSVersion, options)];
6556
6742
  case 4:
6557
- currentIMDSVersionResponse = _a.sent();
6743
+ currentIMDSVersionResponse = _e.sent();
6558
6744
  if (currentIMDSVersionResponse.status === ResponseCodes.httpSuccess) {
6559
6745
  autodetectedRegionName = currentIMDSVersionResponse.body;
6560
6746
  regionDiscoveryMetadata.region_source = RegionDiscoverySources.IMDS;
6561
6747
  }
6562
- _a.label = 5;
6748
+ _e.label = 5;
6563
6749
  case 5: return [3 /*break*/, 7];
6564
6750
  case 6:
6565
- _a.sent();
6751
+ _e.sent();
6566
6752
  regionDiscoveryMetadata.region_source = RegionDiscoverySources.FAILED_AUTO_DETECTION;
6567
6753
  return [2 /*return*/, null];
6568
6754
  case 7: return [3 /*break*/, 9];
6569
6755
  case 8:
6570
6756
  regionDiscoveryMetadata.region_source = RegionDiscoverySources.ENVIRONMENT_VARIABLE;
6571
- _a.label = 9;
6757
+ _e.label = 9;
6572
6758
  case 9:
6573
6759
  // If no region was auto detected from the environment or from the IMDS endpoint, mark the attempt as a FAILED_AUTO_DETECTION
6574
6760
  if (!autodetectedRegionName) {
@@ -6586,8 +6772,10 @@ var RegionDiscovery = /** @class */ (function () {
6586
6772
  * @returns Promise<NetworkResponse<string>>
6587
6773
  */
6588
6774
  RegionDiscovery.prototype.getRegionFromIMDS = function (version, options) {
6775
+ var _a;
6589
6776
  return __awaiter(this, void 0, void 0, function () {
6590
- return __generator(this, function (_a) {
6777
+ return __generator(this, function (_b) {
6778
+ (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.RegionDiscoveryGetRegionFromIMDS, this.correlationId);
6591
6779
  return [2 /*return*/, this.networkInterface.sendGetRequestAsync(Constants.IMDS_ENDPOINT + "?api-version=" + version + "&format=text", options, Constants.IMDS_TIMEOUT)];
6592
6780
  });
6593
6781
  });
@@ -6598,24 +6786,28 @@ var RegionDiscovery = /** @class */ (function () {
6598
6786
  * @returns Promise<string | null>
6599
6787
  */
6600
6788
  RegionDiscovery.prototype.getCurrentVersion = function (options) {
6789
+ var _a;
6601
6790
  return __awaiter(this, void 0, void 0, function () {
6602
6791
  var response;
6603
- return __generator(this, function (_a) {
6604
- switch (_a.label) {
6792
+ return __generator(this, function (_b) {
6793
+ switch (_b.label) {
6605
6794
  case 0:
6606
- _a.trys.push([0, 2, , 3]);
6607
- return [4 /*yield*/, this.networkInterface.sendGetRequestAsync(Constants.IMDS_ENDPOINT + "?format=json", options)];
6795
+ (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.RegionDiscoveryGetCurrentVersion, this.correlationId);
6796
+ _b.label = 1;
6608
6797
  case 1:
6609
- response = _a.sent();
6798
+ _b.trys.push([1, 3, , 4]);
6799
+ return [4 /*yield*/, this.networkInterface.sendGetRequestAsync(Constants.IMDS_ENDPOINT + "?format=json", options)];
6800
+ case 2:
6801
+ response = _b.sent();
6610
6802
  // When IMDS endpoint is called without the api version query param, bad request response comes back with latest version.
6611
6803
  if (response.status === ResponseCodes.httpBadRequest && response.body && response.body["newest-versions"] && response.body["newest-versions"].length > 0) {
6612
6804
  return [2 /*return*/, response.body["newest-versions"][0]];
6613
6805
  }
6614
6806
  return [2 /*return*/, null];
6615
- case 2:
6616
- _a.sent();
6807
+ case 3:
6808
+ _b.sent();
6617
6809
  return [2 /*return*/, null];
6618
- case 3: return [2 /*return*/];
6810
+ case 4: return [2 /*return*/];
6619
6811
  }
6620
6812
  });
6621
6813
  });
@@ -6629,7 +6821,7 @@ var RegionDiscovery = /** @class */ (function () {
6629
6821
  return RegionDiscovery;
6630
6822
  }());
6631
6823
 
6632
- /*! @azure/msal-common v9.0.2 2023-01-10 */
6824
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
6633
6825
 
6634
6826
  /*
6635
6827
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6640,16 +6832,17 @@ var RegionDiscovery = /** @class */ (function () {
6640
6832
  * endpoint. It will store the pertinent config data in this object for use during token calls.
6641
6833
  */
6642
6834
  var Authority = /** @class */ (function () {
6643
- function Authority(authority, networkInterface, cacheManager, authorityOptions, logger, proxyUrl) {
6835
+ function Authority(authority, networkInterface, cacheManager, authorityOptions, logger, performanceClient, correlationId) {
6644
6836
  this.canonicalAuthority = authority;
6645
6837
  this._canonicalAuthority.validateAsUri();
6646
6838
  this.networkInterface = networkInterface;
6647
6839
  this.cacheManager = cacheManager;
6648
6840
  this.authorityOptions = authorityOptions;
6649
- this.regionDiscovery = new RegionDiscovery(networkInterface);
6650
6841
  this.regionDiscoveryMetadata = { region_used: undefined, region_source: undefined, region_outcome: undefined };
6651
- this.proxyUrl = proxyUrl || Constants.EMPTY_STRING;
6652
6842
  this.logger = logger;
6843
+ this.performanceClient = performanceClient;
6844
+ this.correlationId = correlationId;
6845
+ this.regionDiscovery = new RegionDiscovery(networkInterface, this.performanceClient, this.correlationId);
6653
6846
  }
6654
6847
  Object.defineProperty(Authority.prototype, "authorityType", {
6655
6848
  // See above for AuthorityType
@@ -6886,23 +7079,27 @@ var Authority = /** @class */ (function () {
6886
7079
  * and the /authorize, /token and logout endpoints.
6887
7080
  */
6888
7081
  Authority.prototype.resolveEndpointsAsync = function () {
7082
+ var _a, _b, _c;
6889
7083
  return __awaiter(this, void 0, void 0, function () {
6890
7084
  var metadataEntity, cloudDiscoverySource, endpointSource, cacheKey;
6891
- return __generator(this, function (_a) {
6892
- switch (_a.label) {
7085
+ return __generator(this, function (_d) {
7086
+ switch (_d.label) {
6893
7087
  case 0:
7088
+ (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.AuthorityResolveEndpointsAsync, this.correlationId);
6894
7089
  metadataEntity = this.cacheManager.getAuthorityMetadataByAlias(this.hostnameAndPort);
6895
7090
  if (!metadataEntity) {
6896
7091
  metadataEntity = new AuthorityMetadataEntity();
6897
7092
  metadataEntity.updateCanonicalAuthority(this.canonicalAuthority);
6898
7093
  }
7094
+ (_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.setPreQueueTime(exports.PerformanceEvents.AuthorityUpdateCloudDiscoveryMetadata, this.correlationId);
6899
7095
  return [4 /*yield*/, this.updateCloudDiscoveryMetadata(metadataEntity)];
6900
7096
  case 1:
6901
- cloudDiscoverySource = _a.sent();
7097
+ cloudDiscoverySource = _d.sent();
6902
7098
  this.canonicalAuthority = this.canonicalAuthority.replace(this.hostnameAndPort, metadataEntity.preferred_network);
7099
+ (_c = this.performanceClient) === null || _c === void 0 ? void 0 : _c.setPreQueueTime(exports.PerformanceEvents.AuthorityUpdateEndpointMetadata, this.correlationId);
6903
7100
  return [4 /*yield*/, this.updateEndpointMetadata(metadataEntity)];
6904
7101
  case 2:
6905
- endpointSource = _a.sent();
7102
+ endpointSource = _d.sent();
6906
7103
  if (cloudDiscoverySource !== AuthorityMetadataSource.CACHE && endpointSource !== AuthorityMetadataSource.CACHE) {
6907
7104
  // Reset the expiration time unless both values came from a successful cache lookup
6908
7105
  metadataEntity.resetExpiresAt();
@@ -6921,12 +7118,13 @@ var Authority = /** @class */ (function () {
6921
7118
  * @param metadataEntity
6922
7119
  */
6923
7120
  Authority.prototype.updateEndpointMetadata = function (metadataEntity) {
6924
- var _a, _b;
7121
+ var _a, _b, _c, _d, _e, _f;
6925
7122
  return __awaiter(this, void 0, void 0, function () {
6926
7123
  var metadata, harcodedMetadata;
6927
- return __generator(this, function (_c) {
6928
- switch (_c.label) {
7124
+ return __generator(this, function (_g) {
7125
+ switch (_g.label) {
6929
7126
  case 0:
7127
+ (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.AuthorityUpdateEndpointMetadata, this.correlationId);
6930
7128
  metadata = this.getEndpointMetadataFromConfig();
6931
7129
  if (metadata) {
6932
7130
  metadataEntity.updateEndpointMetadata(metadata, false);
@@ -6937,25 +7135,28 @@ var Authority = /** @class */ (function () {
6937
7135
  return [2 /*return*/, AuthorityMetadataSource.CACHE];
6938
7136
  }
6939
7137
  harcodedMetadata = this.getEndpointMetadataFromHardcodedValues();
7138
+ (_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.setPreQueueTime(exports.PerformanceEvents.AuthorityGetEndpointMetadataFromNetwork, this.correlationId);
6940
7139
  return [4 /*yield*/, this.getEndpointMetadataFromNetwork()];
6941
7140
  case 1:
6942
- metadata = _c.sent();
7141
+ metadata = _g.sent();
6943
7142
  if (!metadata) return [3 /*break*/, 4];
6944
- if (!((_a = this.authorityOptions.azureRegionConfiguration) === null || _a === void 0 ? void 0 : _a.azureRegion)) return [3 /*break*/, 3];
7143
+ if (!((_c = this.authorityOptions.azureRegionConfiguration) === null || _c === void 0 ? void 0 : _c.azureRegion)) return [3 /*break*/, 3];
7144
+ (_d = this.performanceClient) === null || _d === void 0 ? void 0 : _d.setPreQueueTime(exports.PerformanceEvents.AuthorityUpdateMetadataWithRegionalInformation, this.correlationId);
6945
7145
  return [4 /*yield*/, this.updateMetadataWithRegionalInformation(metadata)];
6946
7146
  case 2:
6947
- metadata = _c.sent();
6948
- _c.label = 3;
7147
+ metadata = _g.sent();
7148
+ _g.label = 3;
6949
7149
  case 3:
6950
7150
  metadataEntity.updateEndpointMetadata(metadata, true);
6951
7151
  return [2 /*return*/, AuthorityMetadataSource.NETWORK];
6952
7152
  case 4:
6953
7153
  if (!(harcodedMetadata && !this.authorityOptions.skipAuthorityMetadataCache)) return [3 /*break*/, 7];
6954
- if (!((_b = this.authorityOptions.azureRegionConfiguration) === null || _b === void 0 ? void 0 : _b.azureRegion)) return [3 /*break*/, 6];
7154
+ if (!((_e = this.authorityOptions.azureRegionConfiguration) === null || _e === void 0 ? void 0 : _e.azureRegion)) return [3 /*break*/, 6];
7155
+ (_f = this.performanceClient) === null || _f === void 0 ? void 0 : _f.setPreQueueTime(exports.PerformanceEvents.AuthorityUpdateMetadataWithRegionalInformation, this.correlationId);
6955
7156
  return [4 /*yield*/, this.updateMetadataWithRegionalInformation(harcodedMetadata)];
6956
7157
  case 5:
6957
- harcodedMetadata = _c.sent();
6958
- _c.label = 6;
7158
+ harcodedMetadata = _g.sent();
7159
+ _g.label = 6;
6959
7160
  case 6:
6960
7161
  metadataEntity.updateEndpointMetadata(harcodedMetadata, false);
6961
7162
  return [2 /*return*/, AuthorityMetadataSource.HARDCODED_VALUES];
@@ -6995,25 +7196,24 @@ var Authority = /** @class */ (function () {
6995
7196
  * @param hasHardcodedMetadata boolean
6996
7197
  */
6997
7198
  Authority.prototype.getEndpointMetadataFromNetwork = function () {
7199
+ var _a;
6998
7200
  return __awaiter(this, void 0, void 0, function () {
6999
7201
  var options, response;
7000
- return __generator(this, function (_a) {
7001
- switch (_a.label) {
7202
+ return __generator(this, function (_b) {
7203
+ switch (_b.label) {
7002
7204
  case 0:
7205
+ (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.AuthorityGetEndpointMetadataFromNetwork, this.correlationId);
7003
7206
  options = {};
7004
- if (this.proxyUrl) {
7005
- options.proxyUrl = this.proxyUrl;
7006
- }
7007
- _a.label = 1;
7207
+ _b.label = 1;
7008
7208
  case 1:
7009
- _a.trys.push([1, 3, , 4]);
7209
+ _b.trys.push([1, 3, , 4]);
7010
7210
  return [4 /*yield*/, this.networkInterface.
7011
7211
  sendGetRequestAsync(this.defaultOpenIdConfigurationEndpoint, options)];
7012
7212
  case 2:
7013
- response = _a.sent();
7213
+ response = _b.sent();
7014
7214
  return [2 /*return*/, isOpenIdConfigResponse(response.body) ? response.body : null];
7015
7215
  case 3:
7016
- _a.sent();
7216
+ _b.sent();
7017
7217
  return [2 /*return*/, null];
7018
7218
  case 4: return [2 /*return*/];
7019
7219
  }
@@ -7033,25 +7233,28 @@ var Authority = /** @class */ (function () {
7033
7233
  * Update the retrieved metadata with regional information.
7034
7234
  */
7035
7235
  Authority.prototype.updateMetadataWithRegionalInformation = function (metadata) {
7036
- var _a, _b, _c, _d, _e;
7236
+ var _a, _b, _c, _d, _e, _f, _g;
7037
7237
  return __awaiter(this, void 0, void 0, function () {
7038
7238
  var autodetectedRegionName, azureRegion;
7039
- return __generator(this, function (_f) {
7040
- switch (_f.label) {
7041
- case 0: return [4 /*yield*/, this.regionDiscovery.detectRegion((_a = this.authorityOptions.azureRegionConfiguration) === null || _a === void 0 ? void 0 : _a.environmentRegion, this.regionDiscoveryMetadata, this.proxyUrl)];
7239
+ return __generator(this, function (_h) {
7240
+ switch (_h.label) {
7241
+ case 0:
7242
+ (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.AuthorityUpdateMetadataWithRegionalInformation, this.correlationId);
7243
+ (_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.setPreQueueTime(exports.PerformanceEvents.RegionDiscoveryDetectRegion, this.correlationId);
7244
+ return [4 /*yield*/, this.regionDiscovery.detectRegion((_c = this.authorityOptions.azureRegionConfiguration) === null || _c === void 0 ? void 0 : _c.environmentRegion, this.regionDiscoveryMetadata)];
7042
7245
  case 1:
7043
- autodetectedRegionName = _f.sent();
7044
- azureRegion = ((_b = this.authorityOptions.azureRegionConfiguration) === null || _b === void 0 ? void 0 : _b.azureRegion) === Constants.AZURE_REGION_AUTO_DISCOVER_FLAG
7246
+ autodetectedRegionName = _h.sent();
7247
+ azureRegion = ((_d = this.authorityOptions.azureRegionConfiguration) === null || _d === void 0 ? void 0 : _d.azureRegion) === Constants.AZURE_REGION_AUTO_DISCOVER_FLAG
7045
7248
  ? autodetectedRegionName
7046
- : (_c = this.authorityOptions.azureRegionConfiguration) === null || _c === void 0 ? void 0 : _c.azureRegion;
7047
- if (((_d = this.authorityOptions.azureRegionConfiguration) === null || _d === void 0 ? void 0 : _d.azureRegion) === Constants.AZURE_REGION_AUTO_DISCOVER_FLAG) {
7249
+ : (_e = this.authorityOptions.azureRegionConfiguration) === null || _e === void 0 ? void 0 : _e.azureRegion;
7250
+ if (((_f = this.authorityOptions.azureRegionConfiguration) === null || _f === void 0 ? void 0 : _f.azureRegion) === Constants.AZURE_REGION_AUTO_DISCOVER_FLAG) {
7048
7251
  this.regionDiscoveryMetadata.region_outcome = autodetectedRegionName ?
7049
7252
  RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_SUCCESSFUL :
7050
7253
  RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_FAILED;
7051
7254
  }
7052
7255
  else {
7053
7256
  if (autodetectedRegionName) {
7054
- this.regionDiscoveryMetadata.region_outcome = (((_e = this.authorityOptions.azureRegionConfiguration) === null || _e === void 0 ? void 0 : _e.azureRegion) === autodetectedRegionName) ?
7257
+ this.regionDiscoveryMetadata.region_outcome = (((_g = this.authorityOptions.azureRegionConfiguration) === null || _g === void 0 ? void 0 : _g.azureRegion) === autodetectedRegionName) ?
7055
7258
  RegionDiscoveryOutcomes.CONFIGURED_MATCHES_DETECTED :
7056
7259
  RegionDiscoveryOutcomes.CONFIGURED_NOT_DETECTED;
7057
7260
  }
@@ -7075,11 +7278,13 @@ var Authority = /** @class */ (function () {
7075
7278
  * @param newMetadata
7076
7279
  */
7077
7280
  Authority.prototype.updateCloudDiscoveryMetadata = function (metadataEntity) {
7281
+ var _a, _b;
7078
7282
  return __awaiter(this, void 0, void 0, function () {
7079
7283
  var metadata, metadataEntityExpired, harcodedMetadata;
7080
- return __generator(this, function (_a) {
7081
- switch (_a.label) {
7284
+ return __generator(this, function (_c) {
7285
+ switch (_c.label) {
7082
7286
  case 0:
7287
+ (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.AuthorityUpdateCloudDiscoveryMetadata, this.correlationId);
7083
7288
  this.logger.verbose("Attempting to get cloud discovery metadata in the config");
7084
7289
  this.logger.verbosePii("Known Authorities: " + (this.authorityOptions.knownAuthorities || Constants.NOT_APPLICABLE));
7085
7290
  this.logger.verbosePii("Authority Metadata: " + (this.authorityOptions.authorityMetadata || Constants.NOT_APPLICABLE));
@@ -7102,9 +7307,10 @@ var Authority = /** @class */ (function () {
7102
7307
  this.logger.verbose("The metadata entity is expired.");
7103
7308
  }
7104
7309
  this.logger.verbose("Did not find cloud discovery metadata in the cache... Attempting to get cloud discovery metadata from the network.");
7310
+ (_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.setPreQueueTime(exports.PerformanceEvents.AuthorityGetCloudDiscoveryMetadataFromNetwork, this.correlationId);
7105
7311
  return [4 /*yield*/, this.getCloudDiscoveryMetadataFromNetwork()];
7106
7312
  case 1:
7107
- metadata = _a.sent();
7313
+ metadata = _c.sent();
7108
7314
  if (metadata) {
7109
7315
  this.logger.verbose("cloud discovery metadata was successfully returned from getCloudDiscoveryMetadataFromNetwork()");
7110
7316
  metadataEntity.updateCloudDiscoveryMetadata(metadata, true);
@@ -7162,23 +7368,22 @@ var Authority = /** @class */ (function () {
7162
7368
  * @param hasHardcodedMetadata boolean
7163
7369
  */
7164
7370
  Authority.prototype.getCloudDiscoveryMetadataFromNetwork = function () {
7371
+ var _a;
7165
7372
  return __awaiter(this, void 0, void 0, function () {
7166
7373
  var instanceDiscoveryEndpoint, options, match, response, typedResponseBody, metadata, error_1, typedError;
7167
- return __generator(this, function (_a) {
7168
- switch (_a.label) {
7374
+ return __generator(this, function (_b) {
7375
+ switch (_b.label) {
7169
7376
  case 0:
7377
+ (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.AuthorityGetCloudDiscoveryMetadataFromNetwork, this.correlationId);
7170
7378
  instanceDiscoveryEndpoint = "" + Constants.AAD_INSTANCE_DISCOVERY_ENDPT + this.canonicalAuthority + "oauth2/v2.0/authorize";
7171
7379
  options = {};
7172
- if (this.proxyUrl) {
7173
- options.proxyUrl = this.proxyUrl;
7174
- }
7175
7380
  match = null;
7176
- _a.label = 1;
7381
+ _b.label = 1;
7177
7382
  case 1:
7178
- _a.trys.push([1, 3, , 4]);
7383
+ _b.trys.push([1, 3, , 4]);
7179
7384
  return [4 /*yield*/, this.networkInterface.sendGetRequestAsync(instanceDiscoveryEndpoint, options)];
7180
7385
  case 2:
7181
- response = _a.sent();
7386
+ response = _b.sent();
7182
7387
  typedResponseBody = void 0;
7183
7388
  metadata = void 0;
7184
7389
  if (isCloudInstanceDiscoveryResponse(response.body)) {
@@ -7206,7 +7411,7 @@ var Authority = /** @class */ (function () {
7206
7411
  match = Authority.getCloudDiscoveryMetadataFromNetworkResponse(metadata, this.hostnameAndPort);
7207
7412
  return [3 /*break*/, 4];
7208
7413
  case 3:
7209
- error_1 = _a.sent();
7414
+ error_1 = _b.sent();
7210
7415
  if (error_1 instanceof AuthError) {
7211
7416
  this.logger.error("There was a network error while attempting to get the cloud discovery instance metadata.\nError: " + error_1.errorCode + "\nError Description: " + error_1.errorMessage);
7212
7417
  }
@@ -7351,7 +7556,7 @@ var Authority = /** @class */ (function () {
7351
7556
  return Authority;
7352
7557
  }());
7353
7558
 
7354
- /*! @azure/msal-common v9.0.2 2023-01-10 */
7559
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
7355
7560
 
7356
7561
  /*
7357
7562
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7370,16 +7575,18 @@ var AuthorityFactory = /** @class */ (function () {
7370
7575
  * @param networkClient
7371
7576
  * @param protocolMode
7372
7577
  */
7373
- AuthorityFactory.createDiscoveredInstance = function (authorityUri, networkClient, cacheManager, authorityOptions, logger, proxyUrl) {
7578
+ AuthorityFactory.createDiscoveredInstance = function (authorityUri, networkClient, cacheManager, authorityOptions, logger, performanceClient, correlationId) {
7374
7579
  return __awaiter(this, void 0, void 0, function () {
7375
7580
  var acquireTokenAuthority, e_1;
7376
7581
  return __generator(this, function (_a) {
7377
7582
  switch (_a.label) {
7378
7583
  case 0:
7379
- acquireTokenAuthority = AuthorityFactory.createInstance(authorityUri, networkClient, cacheManager, authorityOptions, logger, proxyUrl);
7584
+ performanceClient === null || performanceClient === void 0 ? void 0 : performanceClient.addQueueMeasurement(exports.PerformanceEvents.AuthorityFactoryCreateDiscoveredInstance, correlationId);
7585
+ acquireTokenAuthority = AuthorityFactory.createInstance(authorityUri, networkClient, cacheManager, authorityOptions, logger, performanceClient, correlationId);
7380
7586
  _a.label = 1;
7381
7587
  case 1:
7382
7588
  _a.trys.push([1, 3, , 4]);
7589
+ performanceClient === null || performanceClient === void 0 ? void 0 : performanceClient.setPreQueueTime(exports.PerformanceEvents.AuthorityResolveEndpointsAsync, correlationId);
7383
7590
  return [4 /*yield*/, acquireTokenAuthority.resolveEndpointsAsync()];
7384
7591
  case 2:
7385
7592
  _a.sent();
@@ -7402,17 +7609,17 @@ var AuthorityFactory = /** @class */ (function () {
7402
7609
  * @param networkInterface
7403
7610
  * @param protocolMode
7404
7611
  */
7405
- AuthorityFactory.createInstance = function (authorityUrl, networkInterface, cacheManager, authorityOptions, logger, proxyUrl) {
7612
+ AuthorityFactory.createInstance = function (authorityUrl, networkInterface, cacheManager, authorityOptions, logger, performanceClient, correlationId) {
7406
7613
  // Throw error if authority url is empty
7407
7614
  if (StringUtils.isEmpty(authorityUrl)) {
7408
7615
  throw ClientConfigurationError.createUrlEmptyError();
7409
7616
  }
7410
- return new Authority(authorityUrl, networkInterface, cacheManager, authorityOptions, logger, proxyUrl);
7617
+ return new Authority(authorityUrl, networkInterface, cacheManager, authorityOptions, logger, performanceClient, correlationId);
7411
7618
  };
7412
7619
  return AuthorityFactory;
7413
7620
  }());
7414
7621
 
7415
- /*! @azure/msal-common v9.0.2 2023-01-10 */
7622
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
7416
7623
 
7417
7624
  /*
7418
7625
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7443,7 +7650,7 @@ var ServerTelemetryEntity = /** @class */ (function () {
7443
7650
  return ServerTelemetryEntity;
7444
7651
  }());
7445
7652
 
7446
- /*! @azure/msal-common v9.0.2 2023-01-10 */
7653
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
7447
7654
 
7448
7655
  /*
7449
7656
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7471,7 +7678,7 @@ var ThrottlingEntity = /** @class */ (function () {
7471
7678
  return ThrottlingEntity;
7472
7679
  }());
7473
7680
 
7474
- /*! @azure/msal-common v9.0.2 2023-01-10 */
7681
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
7475
7682
 
7476
7683
  /*
7477
7684
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7488,7 +7695,7 @@ var StubbedNetworkModule = {
7488
7695
  }
7489
7696
  };
7490
7697
 
7491
- /*! @azure/msal-common v9.0.2 2023-01-10 */
7698
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
7492
7699
 
7493
7700
  /*
7494
7701
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7533,7 +7740,7 @@ var JoseHeaderError = /** @class */ (function (_super) {
7533
7740
  return JoseHeaderError;
7534
7741
  }(AuthError));
7535
7742
 
7536
- /*! @azure/msal-common v9.0.2 2023-01-10 */
7743
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
7537
7744
 
7538
7745
  /*
7539
7746
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7563,8 +7770,8 @@ var JoseHeader = /** @class */ (function () {
7563
7770
  throw JoseHeaderError.createMissingAlgError();
7564
7771
  }
7565
7772
  var shrHeader = new JoseHeader({
7566
- // Access Token PoP headers must have type JWT, but the type header can be overriden for special cases
7567
- typ: shrHeaderOptions.typ || JsonTypes.Jwt,
7773
+ // Access Token PoP headers must have type pop, but the type header can be overriden for special cases
7774
+ typ: shrHeaderOptions.typ || JsonTypes.Pop,
7568
7775
  kid: shrHeaderOptions.kid,
7569
7776
  alg: shrHeaderOptions.alg
7570
7777
  });
@@ -7573,7 +7780,7 @@ var JoseHeader = /** @class */ (function () {
7573
7780
  return JoseHeader;
7574
7781
  }());
7575
7782
 
7576
- /*! @azure/msal-common v9.0.2 2023-01-10 */
7783
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
7577
7784
 
7578
7785
  /*
7579
7786
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7632,7 +7839,7 @@ var AuthenticationHeaderParser = /** @class */ (function () {
7632
7839
  return AuthenticationHeaderParser;
7633
7840
  }());
7634
7841
 
7635
- /*! @azure/msal-common v9.0.2 2023-01-10 */
7842
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
7636
7843
 
7637
7844
  /*
7638
7845
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7794,7 +8001,7 @@ var ServerTelemetryManager = /** @class */ (function () {
7794
8001
  return ServerTelemetryManager;
7795
8002
  }());
7796
8003
 
7797
- /*! @azure/msal-common v9.0.2 2023-01-10 */
8004
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
7798
8005
 
7799
8006
  /*
7800
8007
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7821,9 +8028,120 @@ var PerformanceClient = /** @class */ (function () {
7821
8028
  this.logger = logger;
7822
8029
  this.callbacks = new Map();
7823
8030
  this.eventsByCorrelationId = new Map();
7824
- this.staticFieldsByCorrelationId = new Map();
7825
- this.measurementsById = new Map();
8031
+ this.queueMeasurements = new Map();
8032
+ this.preQueueTimeByCorrelationId = new Map();
7826
8033
  }
8034
+ /**
8035
+ * Starts and returns an platform-specific implementation of IPerformanceMeasurement.
8036
+ * Note: this function can be changed to abstract at the next major version bump.
8037
+ *
8038
+ * @param {string} measureName
8039
+ * @param {string} correlationId
8040
+ * @returns {IPerformanceMeasurement}
8041
+ */
8042
+ /* eslint-disable-next-line @typescript-eslint/no-unused-vars */
8043
+ PerformanceClient.prototype.startPerformanceMeasurement = function (measureName, correlationId) {
8044
+ return {};
8045
+ };
8046
+ /**
8047
+ * Starts and returns an platform-specific implementation of IPerformanceMeasurement.
8048
+ * Note: this incorrectly-named function will be removed at the next major version bump.
8049
+ *
8050
+ * @param {string} measureName
8051
+ * @param {string} correlationId
8052
+ * @returns {IPerformanceMeasurement}
8053
+ */
8054
+ /* eslint-disable-next-line @typescript-eslint/no-unused-vars */
8055
+ PerformanceClient.prototype.startPerformanceMeasuremeant = function (measureName, correlationId) {
8056
+ return {};
8057
+ };
8058
+ /**
8059
+ * Get integral fields.
8060
+ * Override to change the set.
8061
+ */
8062
+ PerformanceClient.prototype.getIntFields = function () {
8063
+ return IntFields;
8064
+ };
8065
+ /**
8066
+ * Gets map of pre-queue times by correlation Id
8067
+ *
8068
+ * @param {PerformanceEvents} eventName
8069
+ * @param {string} correlationId
8070
+ * @returns {number}
8071
+ */
8072
+ PerformanceClient.prototype.getPreQueueTime = function (eventName, correlationId) {
8073
+ var preQueueEvent = this.preQueueTimeByCorrelationId.get(correlationId);
8074
+ if (!preQueueEvent) {
8075
+ this.logger.trace("PerformanceClient.getPreQueueTime: no pre-queue times found for correlationId: " + correlationId + ", unable to add queue measurement");
8076
+ return;
8077
+ }
8078
+ else if (preQueueEvent.name !== eventName) {
8079
+ this.logger.trace("PerformanceClient.getPreQueueTime: no pre-queue time found for " + eventName + ", unable to add queue measurement");
8080
+ return;
8081
+ }
8082
+ return preQueueEvent.time;
8083
+ };
8084
+ /**
8085
+ * Calculates the difference between current time and time when function was queued.
8086
+ * Note: It is possible to have 0 as the queue time if the current time and the queued time was the same.
8087
+ *
8088
+ * @param {number} preQueueTime
8089
+ * @param {number} currentTime
8090
+ * @returns {number}
8091
+ */
8092
+ PerformanceClient.prototype.calculateQueuedTime = function (preQueueTime, currentTime) {
8093
+ if (preQueueTime < 1) {
8094
+ this.logger.trace("PerformanceClient: preQueueTime should be a positive integer and not " + preQueueTime);
8095
+ return 0;
8096
+ }
8097
+ if (currentTime < 1) {
8098
+ this.logger.trace("PerformanceClient: currentTime should be a positive integer and not " + currentTime);
8099
+ return 0;
8100
+ }
8101
+ if (currentTime < preQueueTime) {
8102
+ this.logger.trace("PerformanceClient: currentTime is less than preQueueTime, check how time is being retrieved");
8103
+ return 0;
8104
+ }
8105
+ return currentTime - preQueueTime;
8106
+ };
8107
+ /**
8108
+ * Adds queue measurement time to QueueMeasurements array for given correlation ID.
8109
+ *
8110
+ * @param {PerformanceEvents} eventName
8111
+ * @param {?string} correlationId
8112
+ * @param {?number} queueTime
8113
+ * @param {?boolean} manuallyCompleted - indicator for manually completed queue measurements
8114
+ * @returns
8115
+ */
8116
+ PerformanceClient.prototype.addQueueMeasurement = function (eventName, correlationId, queueTime, manuallyCompleted) {
8117
+ if (!correlationId) {
8118
+ this.logger.trace("PerformanceClient.addQueueMeasurement: correlationId not provided for " + eventName + ", cannot add queue measurement");
8119
+ return;
8120
+ }
8121
+ if (queueTime === 0) {
8122
+ // Possible for there to be no queue time after calculation
8123
+ this.logger.trace("PerformanceClient.addQueueMeasurement: queue time provided for " + eventName + " is " + queueTime);
8124
+ }
8125
+ else if (!queueTime) {
8126
+ this.logger.trace("PerformanceClient.addQueueMeasurement: no queue time provided for " + eventName);
8127
+ return;
8128
+ }
8129
+ var queueMeasurement = { eventName: eventName, queueTime: queueTime, manuallyCompleted: manuallyCompleted };
8130
+ // Adds to existing correlation Id if present in queueMeasurements
8131
+ var existingMeasurements = this.queueMeasurements.get(correlationId);
8132
+ if (existingMeasurements) {
8133
+ existingMeasurements.push(queueMeasurement);
8134
+ this.queueMeasurements.set(correlationId, existingMeasurements);
8135
+ }
8136
+ else {
8137
+ // Sets new correlation Id if not present in queueMeasurements
8138
+ this.logger.trace("PerformanceClient.addQueueMeasurement: adding correlationId " + correlationId + " to queue measurements");
8139
+ var measurementArray = [queueMeasurement];
8140
+ this.queueMeasurements.set(correlationId, measurementArray);
8141
+ }
8142
+ // Delete processed pre-queue event.
8143
+ this.preQueueTimeByCorrelationId.delete(correlationId);
8144
+ };
7827
8145
  /**
7828
8146
  * Starts measuring performance for a given operation. Returns a function that should be used to end the measurement.
7829
8147
  *
@@ -7839,8 +8157,9 @@ var PerformanceClient = /** @class */ (function () {
7839
8157
  if (!correlationId) {
7840
8158
  this.logger.info("PerformanceClient: No correlation id provided for " + measureName + ", generating", eventCorrelationId);
7841
8159
  }
8160
+ // Duplicate code to address spelling error will be removed at the next major version bump.
7842
8161
  this.logger.trace("PerformanceClient: Performance measurement started for " + measureName, eventCorrelationId);
7843
- var performanceMeasurement = this.startPerformanceMeasurement(measureName, eventCorrelationId);
8162
+ var performanceMeasurement = this.startPerformanceMeasuremeant(measureName, eventCorrelationId);
7844
8163
  performanceMeasurement.startMeasurement();
7845
8164
  var inProgressEvent = {
7846
8165
  eventId: this.generateId(),
@@ -7852,27 +8171,15 @@ var PerformanceClient = /** @class */ (function () {
7852
8171
  name: measureName,
7853
8172
  startTimeMs: Date.now(),
7854
8173
  correlationId: eventCorrelationId,
7855
- };
7856
- // Store in progress events so they can be discarded if not ended properly
7857
- this.cacheEventByCorrelationId(inProgressEvent);
7858
- var staticFields = {
7859
8174
  appName: (_a = this.applicationTelemetry) === null || _a === void 0 ? void 0 : _a.appName,
7860
8175
  appVersion: (_b = this.applicationTelemetry) === null || _b === void 0 ? void 0 : _b.appVersion,
7861
8176
  };
7862
- this.addStaticFields(staticFields, eventCorrelationId);
7863
- this.cacheMeasurement(inProgressEvent, performanceMeasurement);
8177
+ // Store in progress events so they can be discarded if not ended properly
8178
+ this.cacheEventByCorrelationId(inProgressEvent);
7864
8179
  // Return the event and functions the caller can use to properly end/flush the measurement
7865
8180
  return {
7866
8181
  endMeasurement: function (event) {
7867
- var completedEvent = _this.endMeasurement(__assign(__assign({}, inProgressEvent), event));
7868
- if (completedEvent) {
7869
- // Cache event so that submeasurements can be added downstream
7870
- _this.cacheEventByCorrelationId(completedEvent);
7871
- }
7872
- return completedEvent;
7873
- },
7874
- flushMeasurement: function () {
7875
- return _this.flushMeasurements(inProgressEvent.name, inProgressEvent.correlationId);
8182
+ return _this.endMeasurement(__assign(__assign({}, inProgressEvent), event), performanceMeasurement);
7876
8183
  },
7877
8184
  discardMeasurement: function () {
7878
8185
  return _this.discardMeasurements(inProgressEvent.correlationId);
@@ -7880,6 +8187,9 @@ var PerformanceClient = /** @class */ (function () {
7880
8187
  addStaticFields: function (fields) {
7881
8188
  return _this.addStaticFields(fields, inProgressEvent.correlationId);
7882
8189
  },
8190
+ increment: function (counters) {
8191
+ return _this.increment(counters, inProgressEvent.correlationId);
8192
+ },
7883
8193
  measurement: performanceMeasurement,
7884
8194
  event: inProgressEvent
7885
8195
  };
@@ -7887,33 +8197,59 @@ var PerformanceClient = /** @class */ (function () {
7887
8197
  /**
7888
8198
  * Stops measuring the performance for an operation. Should only be called directly by PerformanceClient classes,
7889
8199
  * as consumers should instead use the function returned by startMeasurement.
8200
+ * Adds a new field named as "[event name]DurationMs" for sub-measurements, completes and emits an event
8201
+ * otherwise.
7890
8202
  *
7891
8203
  * @param {PerformanceEvent} event
8204
+ * @param {IPerformanceMeasurement} measurement
7892
8205
  * @returns {(PerformanceEvent | null)}
7893
8206
  */
7894
- PerformanceClient.prototype.endMeasurement = function (event) {
7895
- var performanceMeasurement = this.measurementsById.get(event.eventId);
7896
- if (performanceMeasurement) {
7897
- // Immediately delete so that the same event isnt ended twice
7898
- this.measurementsById.delete(event.eventId);
7899
- performanceMeasurement.endMeasurement();
7900
- var durationMs = performanceMeasurement.flushMeasurement();
7901
- // null indicates no measurement was taken (e.g. needed performance APIs not present)
7902
- if (durationMs !== null) {
7903
- this.logger.trace("PerformanceClient: Performance measurement ended for " + event.name + ": " + durationMs + " ms", event.correlationId);
7904
- var completedEvent = __assign(__assign({
7905
- // Allow duration to be overwritten when event ends (e.g. testing), but not status
7906
- durationMs: Math.round(durationMs) }, event), { status: PerformanceEventStatus.Completed });
7907
- return completedEvent;
7908
- }
7909
- else {
7910
- this.logger.trace("PerformanceClient: Performance measurement not taken", event.correlationId);
7911
- }
8207
+ PerformanceClient.prototype.endMeasurement = function (event, measurement) {
8208
+ var _this = this;
8209
+ var _a, _b;
8210
+ var rootEvent = this.eventsByCorrelationId.get(event.correlationId);
8211
+ if (!rootEvent) {
8212
+ this.logger.trace("PerformanceClient: Measurement not found for " + event.eventId, event.correlationId);
8213
+ return null;
8214
+ }
8215
+ var isRoot = event.eventId === rootEvent.eventId;
8216
+ var queueInfo = {
8217
+ totalQueueTime: 0,
8218
+ totalQueueCount: 0,
8219
+ manuallyCompletedCount: 0
8220
+ };
8221
+ if (isRoot) {
8222
+ queueInfo = this.getQueueInfo(event.correlationId);
8223
+ this.discardCache(rootEvent.correlationId);
7912
8224
  }
7913
8225
  else {
7914
- this.logger.trace("PerformanceClient: Measurement not found for " + event.eventId, event.correlationId);
8226
+ (_a = rootEvent.incompleteSubMeasurements) === null || _a === void 0 ? void 0 : _a.delete(event.eventId);
7915
8227
  }
7916
- return null;
8228
+ measurement === null || measurement === void 0 ? void 0 : measurement.endMeasurement();
8229
+ var durationMs = measurement === null || measurement === void 0 ? void 0 : measurement.flushMeasurement();
8230
+ // null indicates no measurement was taken (e.g. needed performance APIs not present)
8231
+ if (!durationMs) {
8232
+ this.logger.trace("PerformanceClient: Performance measurement not taken", rootEvent.correlationId);
8233
+ return null;
8234
+ }
8235
+ this.logger.trace("PerformanceClient: Performance measurement ended for " + event.name + ": " + durationMs + " ms", event.correlationId);
8236
+ // Add sub-measurement attribute to root event.
8237
+ if (!isRoot) {
8238
+ rootEvent[event.name + "DurationMs"] = Math.floor(durationMs);
8239
+ return __assign({}, rootEvent);
8240
+ }
8241
+ var finalEvent = __assign(__assign({}, rootEvent), event);
8242
+ var incompleteSubsCount = 0;
8243
+ // Incomplete sub-measurements are discarded. They are likely an instrumentation bug that should be fixed.
8244
+ (_b = finalEvent.incompleteSubMeasurements) === null || _b === void 0 ? void 0 : _b.forEach(function (subMeasurement) {
8245
+ _this.logger.trace("PerformanceClient: Incomplete submeasurement " + subMeasurement.name + " found for " + event.name, finalEvent.correlationId);
8246
+ incompleteSubsCount++;
8247
+ });
8248
+ finalEvent.incompleteSubMeasurements = undefined;
8249
+ finalEvent = __assign(__assign({}, finalEvent), { durationMs: Math.round(durationMs), queuedTimeMs: queueInfo.totalQueueTime, queuedCount: queueInfo.totalQueueCount, queuedManuallyCompletedCount: queueInfo.manuallyCompletedCount, status: PerformanceEventStatus.Completed, incompleteSubsCount: incompleteSubsCount });
8250
+ this.truncateIntegralFields(finalEvent, this.getIntFields());
8251
+ this.emitEvents([finalEvent], event.correlationId);
8252
+ return finalEvent;
7917
8253
  };
7918
8254
  /**
7919
8255
  * Saves extra information to be emitted when the measurements are flushed
@@ -7921,14 +8257,33 @@ var PerformanceClient = /** @class */ (function () {
7921
8257
  * @param correlationId
7922
8258
  */
7923
8259
  PerformanceClient.prototype.addStaticFields = function (fields, correlationId) {
7924
- var existingStaticFields = this.staticFieldsByCorrelationId.get(correlationId);
7925
- if (existingStaticFields) {
7926
- this.logger.trace("PerformanceClient: Updating static fields");
7927
- this.staticFieldsByCorrelationId.set(correlationId, __assign(__assign({}, existingStaticFields), fields));
8260
+ this.logger.trace("PerformanceClient: Updating static fields");
8261
+ var event = this.eventsByCorrelationId.get(correlationId);
8262
+ if (event) {
8263
+ this.eventsByCorrelationId.set(correlationId, __assign(__assign({}, event), fields));
8264
+ }
8265
+ else {
8266
+ this.logger.trace("PerformanceClient: Event not found for", correlationId);
8267
+ }
8268
+ };
8269
+ /**
8270
+ * Increment counters to be emitted when the measurements are flushed
8271
+ * @param counters {Counters}
8272
+ * @param correlationId {string} correlation identifier
8273
+ */
8274
+ PerformanceClient.prototype.increment = function (counters, correlationId) {
8275
+ this.logger.trace("PerformanceClient: Updating counters");
8276
+ var event = this.eventsByCorrelationId.get(correlationId);
8277
+ if (event) {
8278
+ for (var counter in counters) {
8279
+ if (!event.hasOwnProperty(counter)) {
8280
+ event[counter] = 0;
8281
+ }
8282
+ event[counter] += counters[counter];
8283
+ }
7928
8284
  }
7929
8285
  else {
7930
- this.logger.trace("PerformanceClient: Adding static fields");
7931
- this.staticFieldsByCorrelationId.set(correlationId, fields);
8286
+ this.logger.trace("PerformanceClient: Event not found for", correlationId);
7932
8287
  }
7933
8288
  };
7934
8289
  /**
@@ -7941,99 +8296,35 @@ var PerformanceClient = /** @class */ (function () {
7941
8296
  * @param {PerformanceEvent} event
7942
8297
  */
7943
8298
  PerformanceClient.prototype.cacheEventByCorrelationId = function (event) {
7944
- var existingEvents = this.eventsByCorrelationId.get(event.correlationId);
7945
- if (existingEvents) {
8299
+ var rootEvent = this.eventsByCorrelationId.get(event.correlationId);
8300
+ if (rootEvent) {
7946
8301
  this.logger.trace("PerformanceClient: Performance measurement for " + event.name + " added/updated", event.correlationId);
7947
- existingEvents.set(event.eventId, event);
8302
+ rootEvent.incompleteSubMeasurements = rootEvent.incompleteSubMeasurements || new Map();
8303
+ rootEvent.incompleteSubMeasurements.set(event.eventId, { name: event.name, startTimeMs: event.startTimeMs });
7948
8304
  }
7949
8305
  else {
7950
8306
  this.logger.trace("PerformanceClient: Performance measurement for " + event.name + " started", event.correlationId);
7951
- this.eventsByCorrelationId.set(event.correlationId, new Map().set(event.eventId, event));
8307
+ this.eventsByCorrelationId.set(event.correlationId, __assign({}, event));
7952
8308
  }
7953
8309
  };
7954
- /**
7955
- * Cache measurements by their id.
7956
- *
7957
- * @private
7958
- * @param {PerformanceEvent} event
7959
- * @param {IPerformanceMeasurement} measurement
7960
- */
7961
- PerformanceClient.prototype.cacheMeasurement = function (event, measurement) {
7962
- this.measurementsById.set(event.eventId, measurement);
7963
- };
7964
- /**
7965
- * Gathers and emits performance events for measurements taked for the given top-level API and correlation ID.
7966
- *
7967
- * @param {PerformanceEvents} measureName
7968
- * @param {string} correlationId
7969
- */
7970
- PerformanceClient.prototype.flushMeasurements = function (measureName, correlationId) {
7971
- var _this = this;
7972
- this.logger.trace("PerformanceClient: Performance measurements flushed for " + measureName, correlationId);
7973
- var eventsForCorrelationId = this.eventsByCorrelationId.get(correlationId);
7974
- if (eventsForCorrelationId) {
7975
- this.discardMeasurements(correlationId);
7976
- /*
7977
- * Manually end incomplete submeasurements to ensure there arent orphaned/never ending events.
7978
- * Incomplete submeasurements are likely an instrumentation bug that should be fixed.
7979
- * IE only supports Map.forEach.
7980
- */
7981
- var completedEvents_1 = [];
7982
- eventsForCorrelationId.forEach(function (event) {
7983
- if (event.name !== measureName && event.status !== PerformanceEventStatus.Completed) {
7984
- _this.logger.trace("PerformanceClient: Incomplete submeasurement " + event.name + " found for " + measureName, correlationId);
7985
- var completedEvent = _this.endMeasurement(event);
7986
- if (completedEvent) {
7987
- completedEvents_1.push(completedEvent);
7988
- }
7989
- }
7990
- completedEvents_1.push(event);
7991
- });
7992
- // Sort events by start time (earliest first)
7993
- var sortedCompletedEvents = completedEvents_1.sort(function (eventA, eventB) { return eventA.startTimeMs - eventB.startTimeMs; });
7994
- // Take completed top level event and add completed submeasurements durations as properties
7995
- var topLevelEvents = sortedCompletedEvents.filter(function (event) { return event.name === measureName && event.status === PerformanceEventStatus.Completed; });
7996
- if (topLevelEvents.length > 0) {
7997
- /*
7998
- * Only take the first top-level event if there are multiple events with the same correlation id.
7999
- * This greatly simplifies logic for submeasurements.
8000
- */
8001
- if (topLevelEvents.length > 1) {
8002
- this.logger.verbose("PerformanceClient: Multiple distinct top-level performance events found, using the first", correlationId);
8003
- }
8004
- var topLevelEvent = topLevelEvents[0];
8005
- this.logger.verbose("PerformanceClient: Measurement found for " + measureName, correlationId);
8006
- // Build event object with top level and sub measurements
8007
- var eventToEmit = sortedCompletedEvents.reduce(function (previous, current) {
8008
- if (current.name !== measureName) {
8009
- _this.logger.trace("PerformanceClient: Complete submeasurement found for " + current.name, correlationId);
8010
- // TODO: Emit additional properties for each subMeasurement
8011
- var subMeasurementName = current.name + "DurationMs";
8012
- /*
8013
- * Some code paths, such as resolving an authority, can occur multiple times.
8014
- * Only take the first measurement, since the second could be read from the cache,
8015
- * or due to the same correlation id being used for two distinct requests.
8016
- */
8017
- if (!previous[subMeasurementName]) {
8018
- previous[subMeasurementName] = current.durationMs;
8019
- }
8020
- else {
8021
- _this.logger.verbose("PerformanceClient: Submeasurement for " + measureName + " already exists for " + current.name + ", ignoring", correlationId);
8022
- }
8023
- }
8024
- return previous;
8025
- }, topLevelEvent);
8026
- var staticFields = this.staticFieldsByCorrelationId.get(correlationId);
8027
- var finalEvent = __assign(__assign({}, eventToEmit), staticFields);
8028
- this.emitEvents([finalEvent], eventToEmit.correlationId);
8029
- }
8030
- else {
8031
- this.logger.verbose("PerformanceClient: No completed top-level measurements found for " + measureName, correlationId);
8032
- }
8033
- }
8034
- else {
8035
- this.logger.verbose("PerformanceClient: No measurements found", correlationId);
8310
+ PerformanceClient.prototype.getQueueInfo = function (correlationId) {
8311
+ var queueMeasurementForCorrelationId = this.queueMeasurements.get(correlationId);
8312
+ if (!queueMeasurementForCorrelationId) {
8313
+ this.logger.trace("PerformanceClient: no queue measurements found for for correlationId: " + correlationId);
8036
8314
  }
8315
+ var totalQueueTime = 0;
8316
+ var totalQueueCount = 0;
8317
+ var manuallyCompletedCount = 0;
8318
+ queueMeasurementForCorrelationId === null || queueMeasurementForCorrelationId === void 0 ? void 0 : queueMeasurementForCorrelationId.forEach(function (measurement) {
8319
+ totalQueueTime += measurement.queueTime;
8320
+ totalQueueCount++;
8321
+ manuallyCompletedCount += measurement.manuallyCompleted ? 1 : 0;
8322
+ });
8323
+ return {
8324
+ totalQueueTime: totalQueueTime,
8325
+ totalQueueCount: totalQueueCount,
8326
+ manuallyCompletedCount: manuallyCompletedCount
8327
+ };
8037
8328
  };
8038
8329
  /**
8039
8330
  * Removes measurements for a given correlation id.
@@ -8044,6 +8335,18 @@ var PerformanceClient = /** @class */ (function () {
8044
8335
  this.logger.trace("PerformanceClient: Performance measurements discarded", correlationId);
8045
8336
  this.eventsByCorrelationId.delete(correlationId);
8046
8337
  };
8338
+ /**
8339
+ * Removes cache for a given correlation id.
8340
+ *
8341
+ * @param {string} correlationId correlation identifier
8342
+ */
8343
+ PerformanceClient.prototype.discardCache = function (correlationId) {
8344
+ this.discardMeasurements(correlationId);
8345
+ this.logger.trace("PerformanceClient: QueueMeasurements discarded", correlationId);
8346
+ this.queueMeasurements.delete(correlationId);
8347
+ this.logger.trace("PerformanceClient: Pre-queue times discarded", correlationId);
8348
+ this.preQueueTimeByCorrelationId.delete(correlationId);
8349
+ };
8047
8350
  /**
8048
8351
  * Registers a callback function to receive performance events.
8049
8352
  *
@@ -8086,10 +8389,22 @@ var PerformanceClient = /** @class */ (function () {
8086
8389
  callback.apply(null, [events]);
8087
8390
  });
8088
8391
  };
8392
+ /**
8393
+ * Enforce truncation of integral fields in performance event.
8394
+ * @param {PerformanceEvent} event performance event to update.
8395
+ * @param {Set<string>} intFields integral fields.
8396
+ */
8397
+ PerformanceClient.prototype.truncateIntegralFields = function (event, intFields) {
8398
+ intFields.forEach(function (key) {
8399
+ if (key in event && typeof event[key] === "number") {
8400
+ event[key] = Math.floor(event[key]);
8401
+ }
8402
+ });
8403
+ };
8089
8404
  return PerformanceClient;
8090
8405
  }());
8091
8406
 
8092
- /*! @azure/msal-common v9.0.2 2023-01-10 */
8407
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
8093
8408
 
8094
8409
  /*
8095
8410
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8115,9 +8430,24 @@ var StubPerformanceClient = /** @class */ (function (_super) {
8115
8430
  StubPerformanceClient.prototype.generateId = function () {
8116
8431
  return "callback-id";
8117
8432
  };
8433
+ StubPerformanceClient.prototype.startPerformanceMeasuremeant = function () {
8434
+ return new StubPerformanceMeasurement();
8435
+ };
8118
8436
  StubPerformanceClient.prototype.startPerformanceMeasurement = function () {
8119
8437
  return new StubPerformanceMeasurement();
8120
8438
  };
8439
+ /* eslint-disable-next-line @typescript-eslint/no-unused-vars */
8440
+ StubPerformanceClient.prototype.calculateQueuedTime = function (preQueueTime, currentTime) {
8441
+ return 0;
8442
+ };
8443
+ /* eslint-disable-next-line @typescript-eslint/no-unused-vars */
8444
+ StubPerformanceClient.prototype.addQueueMeasurement = function (eventName, correlationId, queueTime) {
8445
+ return;
8446
+ };
8447
+ /* eslint-disable-next-line @typescript-eslint/no-unused-vars */
8448
+ StubPerformanceClient.prototype.setPreQueueTime = function (eventName, correlationId) {
8449
+ return;
8450
+ };
8121
8451
  return StubPerformanceClient;
8122
8452
  }(PerformanceClient));
8123
8453
 
@@ -8277,6 +8607,10 @@ var BrowserAuthErrorMessage = {
8277
8607
  code: "auth_code_or_nativeAccountId_required",
8278
8608
  desc: "An authorization code or nativeAccountId must be provided to this flow."
8279
8609
  },
8610
+ spaCodeAndNativeAccountPresent: {
8611
+ code: "spa_code_and_nativeAccountId_present",
8612
+ desc: "Request cannot contain both spa code and native account id."
8613
+ },
8280
8614
  databaseUnavailable: {
8281
8615
  code: "database_unavailable",
8282
8616
  desc: "IndexedDB, which is required for persistent cryptographic key storage, is unavailable. This may be caused by browser privacy features which block persistent storage in third-party contexts."
@@ -8549,6 +8883,12 @@ var BrowserAuthError = /** @class */ (function (_super) {
8549
8883
  BrowserAuthError.createAuthCodeOrNativeAccountIdRequiredError = function () {
8550
8884
  return new BrowserAuthError(BrowserAuthErrorMessage.authCodeOrNativeAccountRequired.code, BrowserAuthErrorMessage.authCodeOrNativeAccountRequired.desc);
8551
8885
  };
8886
+ /**
8887
+ * Create an error when both authorization code and native account ID are provided
8888
+ */
8889
+ BrowserAuthError.createSpaCodeAndNativeAccountIdPresentError = function () {
8890
+ return new BrowserAuthError(BrowserAuthErrorMessage.spaCodeAndNativeAccountPresent.code, BrowserAuthErrorMessage.spaCodeAndNativeAccountPresent.desc);
8891
+ };
8552
8892
  /**
8553
8893
  * Create an error when IndexedDB is unavailable
8554
8894
  */
@@ -9979,7 +10319,7 @@ var DEFAULT_BROWSER_CACHE_MANAGER = function (clientId, logger) {
9979
10319
 
9980
10320
  /* eslint-disable header/header */
9981
10321
  var name = "@azure/msal-browser";
9982
- var version = "2.32.2";
10322
+ var version = "2.34.0";
9983
10323
 
9984
10324
  /*
9985
10325
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -10450,6 +10790,7 @@ var BaseInteractionClient = /** @class */ (function () {
10450
10790
  return __generator$1(this, function (_b) {
10451
10791
  switch (_b.label) {
10452
10792
  case 0:
10793
+ this.performanceClient.addQueueMeasurement(exports.PerformanceEvents.InitializeBaseRequest, request.correlationId);
10453
10794
  this.logger.verbose("Initializing BaseAuthRequest");
10454
10795
  authority = request.authority || this.config.auth.authority;
10455
10796
  scopes = __spread(((request && request.scopes) || []));
@@ -10567,6 +10908,7 @@ var StandardInteractionClient = /** @class */ (function (_super) {
10567
10908
  return __generator$1(this, function (_a) {
10568
10909
  switch (_a.label) {
10569
10910
  case 0:
10911
+ this.performanceClient.addQueueMeasurement(exports.PerformanceEvents.StandardInteractionClientInitializeAuthorizationCodeRequest, request.correlationId);
10570
10912
  this.logger.verbose("initializeAuthorizationRequest called", request.correlationId);
10571
10913
  return [4 /*yield*/, this.browserCrypto.generatePkceCodes()];
10572
10914
  case 1:
@@ -10667,10 +11009,14 @@ var StandardInteractionClient = /** @class */ (function (_super) {
10667
11009
  var clientConfig;
10668
11010
  return __generator$1(this, function (_a) {
10669
11011
  switch (_a.label) {
10670
- case 0: return [4 /*yield*/, this.getClientConfiguration(serverTelemetryManager, authorityUrl, requestAzureCloudOptions)];
11012
+ case 0:
11013
+ this.performanceClient.addQueueMeasurement(exports.PerformanceEvents.StandardInteractionClientCreateAuthCodeClient, this.correlationId);
11014
+ // Create auth module.
11015
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.StandardInteractionClientGetClientConfiguration, this.correlationId);
11016
+ return [4 /*yield*/, this.getClientConfiguration(serverTelemetryManager, authorityUrl, requestAzureCloudOptions)];
10671
11017
  case 1:
10672
11018
  clientConfig = _a.sent();
10673
- return [2 /*return*/, new AuthorizationCodeClient(clientConfig)];
11019
+ return [2 /*return*/, new AuthorizationCodeClient(clientConfig, this.performanceClient)];
10674
11020
  }
10675
11021
  });
10676
11022
  });
@@ -10687,7 +11033,9 @@ var StandardInteractionClient = /** @class */ (function (_super) {
10687
11033
  return __generator$1(this, function (_a) {
10688
11034
  switch (_a.label) {
10689
11035
  case 0:
11036
+ this.performanceClient.addQueueMeasurement(exports.PerformanceEvents.StandardInteractionClientGetClientConfiguration, this.correlationId);
10690
11037
  this.logger.verbose("getClientConfiguration called", this.correlationId);
11038
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.StandardInteractionClientGetDiscoveredAuthority, this.correlationId);
10691
11039
  return [4 /*yield*/, this.getDiscoveredAuthority(requestAuthority, requestAzureCloudOptions)];
10692
11040
  case 1:
10693
11041
  discoveredAuthority = _a.sent();
@@ -10755,6 +11103,7 @@ var StandardInteractionClient = /** @class */ (function (_super) {
10755
11103
  return __generator$1(this, function (_b) {
10756
11104
  switch (_b.label) {
10757
11105
  case 0:
11106
+ this.performanceClient.addQueueMeasurement(exports.PerformanceEvents.StandardInteractionClientGetDiscoveredAuthority, this.correlationId);
10758
11107
  this.logger.verbose("getDiscoveredAuthority called", this.correlationId);
10759
11108
  getAuthorityMeasurement = (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.startMeasurement(exports.PerformanceEvents.StandardInteractionClientGetDiscoveredAuthority, this.correlationId);
10760
11109
  authorityOptions = {
@@ -10767,7 +11116,8 @@ var StandardInteractionClient = /** @class */ (function (_super) {
10767
11116
  userAuthority = requestAuthority ? requestAuthority : this.config.auth.authority;
10768
11117
  builtAuthority = Authority.generateAuthority(userAuthority, requestAzureCloudOptions || this.config.auth.azureCloudOptions);
10769
11118
  this.logger.verbose("Creating discovered authority with configured authority", this.correlationId);
10770
- return [4 /*yield*/, AuthorityFactory.createDiscoveredInstance(builtAuthority, this.config.system.networkClient, this.browserStorage, authorityOptions, this.logger)
11119
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.AuthorityFactoryCreateDiscoveredInstance, this.correlationId);
11120
+ return [4 /*yield*/, AuthorityFactory.createDiscoveredInstance(builtAuthority, this.config.system.networkClient, this.browserStorage, authorityOptions, this.logger, this.performanceClient, this.correlationId)
10771
11121
  .then(function (result) {
10772
11122
  getAuthorityMeasurement.endMeasurement({
10773
11123
  success: true,
@@ -10798,12 +11148,14 @@ var StandardInteractionClient = /** @class */ (function (_super) {
10798
11148
  return __generator$1(this, function (_b) {
10799
11149
  switch (_b.label) {
10800
11150
  case 0:
11151
+ this.performanceClient.addQueueMeasurement(exports.PerformanceEvents.StandardInteractionClientInitializeAuthorizationRequest, this.correlationId);
10801
11152
  this.logger.verbose("initializeAuthorizationRequest called", this.correlationId);
10802
11153
  redirectUri = this.getRedirectUri(request.redirectUri);
10803
11154
  browserState = {
10804
11155
  interactionType: interactionType
10805
11156
  };
10806
11157
  state = ProtocolUtils.setRequestState(this.browserCrypto, (request && request.state) || Constants.EMPTY_STRING, browserState);
11158
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.InitializeBaseRequest, this.correlationId);
10807
11159
  _a = [{}];
10808
11160
  return [4 /*yield*/, this.initializeBaseRequest(request)];
10809
11161
  case 1:
@@ -10837,11 +11189,12 @@ var StandardInteractionClient = /** @class */ (function (_super) {
10837
11189
  * Abstract class which defines operations for a browser interaction handling class.
10838
11190
  */
10839
11191
  var InteractionHandler = /** @class */ (function () {
10840
- function InteractionHandler(authCodeModule, storageImpl, authCodeRequest, logger) {
11192
+ function InteractionHandler(authCodeModule, storageImpl, authCodeRequest, logger, performanceClient) {
10841
11193
  this.authModule = authCodeModule;
10842
11194
  this.browserStorage = storageImpl;
10843
11195
  this.authCodeRequest = authCodeRequest;
10844
11196
  this.logger = logger;
11197
+ this.performanceClient = performanceClient;
10845
11198
  }
10846
11199
  /**
10847
11200
  * Function to handle response parameters from hash.
@@ -10851,6 +11204,7 @@ var InteractionHandler = /** @class */ (function () {
10851
11204
  return __awaiter$1(this, void 0, void 0, function () {
10852
11205
  var stateKey, requestState, authCodeResponse;
10853
11206
  return __generator$1(this, function (_a) {
11207
+ this.performanceClient.addQueueMeasurement(exports.PerformanceEvents.HandleCodeResponseFromHash, this.authCodeRequest.correlationId);
10854
11208
  this.logger.verbose("InteractionHandler.handleCodeResponse called");
10855
11209
  // Check that location hash isn't empty.
10856
11210
  if (StringUtils.isEmpty(locationHash)) {
@@ -10873,6 +11227,7 @@ var InteractionHandler = /** @class */ (function () {
10873
11227
  throw e;
10874
11228
  }
10875
11229
  }
11230
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.HandleCodeResponseFromServer, this.authCodeRequest.correlationId);
10876
11231
  return [2 /*return*/, this.handleCodeResponseFromServer(authCodeResponse, state, authority, networkModule)];
10877
11232
  });
10878
11233
  });
@@ -10892,6 +11247,7 @@ var InteractionHandler = /** @class */ (function () {
10892
11247
  return __generator$1(this, function (_a) {
10893
11248
  switch (_a.label) {
10894
11249
  case 0:
11250
+ this.performanceClient.addQueueMeasurement(exports.PerformanceEvents.HandleCodeResponseFromServer, this.authCodeRequest.correlationId);
10895
11251
  this.logger.trace("InteractionHandler.handleCodeResponseFromServer called");
10896
11252
  stateKey = this.browserStorage.generateStateKey(state);
10897
11253
  requestState = this.browserStorage.getTemporaryCache(stateKey);
@@ -10903,6 +11259,7 @@ var InteractionHandler = /** @class */ (function () {
10903
11259
  // Assign code to request
10904
11260
  this.authCodeRequest.code = authCodeResponse.code;
10905
11261
  if (!authCodeResponse.cloud_instance_host_name) return [3 /*break*/, 2];
11262
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.UpdateTokenEndpointAuthority, this.authCodeRequest.correlationId);
10906
11263
  return [4 /*yield*/, this.updateTokenEndpointAuthority(authCodeResponse.cloud_instance_host_name, authority, networkModule)];
10907
11264
  case 1:
10908
11265
  _a.sent();
@@ -10923,6 +11280,8 @@ var InteractionHandler = /** @class */ (function () {
10923
11280
  this.authCodeRequest.ccsCredential = cachedCcsCred;
10924
11281
  }
10925
11282
  }
11283
+ // Acquire token with retrieved code.
11284
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.AuthClientAcquireToken, this.authCodeRequest.correlationId);
10926
11285
  return [4 /*yield*/, this.authModule.acquireToken(this.authCodeRequest, authCodeResponse)];
10927
11286
  case 3:
10928
11287
  tokenResponse = _a.sent();
@@ -10944,8 +11303,9 @@ var InteractionHandler = /** @class */ (function () {
10944
11303
  return __generator$1(this, function (_a) {
10945
11304
  switch (_a.label) {
10946
11305
  case 0:
11306
+ this.performanceClient.addQueueMeasurement(exports.PerformanceEvents.UpdateTokenEndpointAuthority, this.authCodeRequest.correlationId);
10947
11307
  cloudInstanceAuthorityUri = "https://" + cloudInstanceHostname + "/" + authority.tenant + "/";
10948
- return [4 /*yield*/, AuthorityFactory.createDiscoveredInstance(cloudInstanceAuthorityUri, networkModule, this.browserStorage, authority.options, this.logger)];
11308
+ return [4 /*yield*/, AuthorityFactory.createDiscoveredInstance(cloudInstanceAuthorityUri, networkModule, this.browserStorage, authority.options, this.logger, this.performanceClient, this.authCodeRequest.correlationId)];
10949
11309
  case 1:
10950
11310
  cloudInstanceAuthority = _a.sent();
10951
11311
  this.authModule.updateAuthority(cloudInstanceAuthority);
@@ -10980,8 +11340,8 @@ var InteractionHandler = /** @class */ (function () {
10980
11340
  */
10981
11341
  var RedirectHandler = /** @class */ (function (_super) {
10982
11342
  __extends$1(RedirectHandler, _super);
10983
- function RedirectHandler(authCodeModule, storageImpl, authCodeRequest, logger, browserCrypto) {
10984
- var _this = _super.call(this, authCodeModule, storageImpl, authCodeRequest, logger) || this;
11343
+ function RedirectHandler(authCodeModule, storageImpl, authCodeRequest, logger, browserCrypto, performanceClient) {
11344
+ var _this = _super.call(this, authCodeModule, storageImpl, authCodeRequest, logger, performanceClient) || this;
10985
11345
  _this.browserCrypto = browserCrypto;
10986
11346
  return _this;
10987
11347
  }
@@ -11299,7 +11659,10 @@ var SilentCacheClient = /** @class */ (function (_super) {
11299
11659
  var clientConfig;
11300
11660
  return __generator$1(this, function (_a) {
11301
11661
  switch (_a.label) {
11302
- case 0: return [4 /*yield*/, this.getClientConfiguration(serverTelemetryManager, authorityUrl, azureCloudOptions)];
11662
+ case 0:
11663
+ // Create auth module.
11664
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.StandardInteractionClientGetClientConfiguration, this.correlationId);
11665
+ return [4 /*yield*/, this.getClientConfiguration(serverTelemetryManager, authorityUrl, azureCloudOptions)];
11303
11666
  case 1:
11304
11667
  clientConfig = _a.sent();
11305
11668
  return [2 /*return*/, new SilentFlowClient(clientConfig, this.performanceClient)];
@@ -11313,6 +11676,8 @@ var SilentCacheClient = /** @class */ (function (_super) {
11313
11676
  return __generator$1(this, function (_b) {
11314
11677
  switch (_b.label) {
11315
11678
  case 0:
11679
+ this.performanceClient.addQueueMeasurement(exports.PerformanceEvents.InitializeSilentRequest, this.correlationId);
11680
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.InitializeBaseRequest, this.correlationId);
11316
11681
  _a = [__assign$1({}, request)];
11317
11682
  return [4 /*yield*/, this.initializeBaseRequest(request)];
11318
11683
  case 1: return [2 /*return*/, __assign$1.apply(void 0, [__assign$1.apply(void 0, _a.concat([_b.sent()])), { account: account, forceRefresh: request.forceRefresh || false }])];
@@ -11564,60 +11929,96 @@ var NativeInteractionClient = /** @class */ (function (_super) {
11564
11929
  */
11565
11930
  NativeInteractionClient.prototype.handleNativeResponse = function (response, request, reqTimestamp) {
11566
11931
  return __awaiter$1(this, void 0, void 0, function () {
11567
- var mats, idTokenObj, authority, authorityPreferredCache, homeAccountIdentifier, accountEntity, responseScopes, accountProperties, uid, tid, responseAccessToken, responseTokenType, _a, popTokenGenerator, shrParameters, result, idTokenEntity, expiresIn, tokenExpirationSeconds, accessTokenEntity;
11568
- var _this = this;
11569
- return __generator$1(this, function (_b) {
11570
- switch (_b.label) {
11932
+ var authority, authorityPreferredCache, idTokenObj, homeAccountIdentifier, accountEntity, result;
11933
+ return __generator$1(this, function (_a) {
11934
+ switch (_a.label) {
11935
+ case 0:
11936
+ this.logger.trace("NativeInteractionClient - handleNativeResponse called.");
11937
+ if (response.account.id !== request.accountId) {
11938
+ // User switch in native broker prompt is not supported. All users must first sign in through web flow to ensure server state is in sync
11939
+ throw NativeAuthError.createUserSwitchError();
11940
+ }
11941
+ if (response.account.id !== request.accountId) {
11942
+ // User switch in native broker prompt is not supported. All users must first sign in through web flow to ensure server state is in sync
11943
+ throw NativeAuthError.createUserSwitchError();
11944
+ }
11945
+ return [4 /*yield*/, this.getDiscoveredAuthority(request.authority)];
11946
+ case 1:
11947
+ authority = _a.sent();
11948
+ authorityPreferredCache = authority.getPreferredCache();
11949
+ idTokenObj = this.createIdTokenObj(response);
11950
+ homeAccountIdentifier = this.createHomeAccountIdentifier(response, idTokenObj);
11951
+ accountEntity = this.createAccountEntity(response, homeAccountIdentifier, idTokenObj, authorityPreferredCache);
11952
+ return [4 /*yield*/, this.generateAuthenticationResult(response, request, idTokenObj, accountEntity, authority.canonicalAuthority, reqTimestamp)];
11953
+ case 2:
11954
+ result = _a.sent();
11955
+ // cache accounts and tokens in the appropriate storage
11956
+ this.cacheAccount(accountEntity);
11957
+ this.cacheNativeTokens(response, request, homeAccountIdentifier, idTokenObj, result.accessToken, result.tenantId, reqTimestamp);
11958
+ return [2 /*return*/, result];
11959
+ }
11960
+ });
11961
+ });
11962
+ };
11963
+ /**
11964
+ * Create an idToken Object (not entity)
11965
+ * @param response
11966
+ * @returns
11967
+ */
11968
+ NativeInteractionClient.prototype.createIdTokenObj = function (response) {
11969
+ return new AuthToken(response.id_token || Constants.EMPTY_STRING, this.browserCrypto);
11970
+ };
11971
+ /**
11972
+ * creates an homeAccountIdentifier for the account
11973
+ * @param response
11974
+ * @param idTokenObj
11975
+ * @returns
11976
+ */
11977
+ NativeInteractionClient.prototype.createHomeAccountIdentifier = function (response, idTokenObj) {
11978
+ // Save account in browser storage
11979
+ var homeAccountIdentifier = AccountEntity.generateHomeAccountId(response.client_info || Constants.EMPTY_STRING, AuthorityType.Default, this.logger, this.browserCrypto, idTokenObj);
11980
+ return homeAccountIdentifier;
11981
+ };
11982
+ /**
11983
+ * Creates account entity
11984
+ * @param response
11985
+ * @param homeAccountIdentifier
11986
+ * @param idTokenObj
11987
+ * @param authority
11988
+ * @returns
11989
+ */
11990
+ NativeInteractionClient.prototype.createAccountEntity = function (response, homeAccountIdentifier, idTokenObj, authority) {
11991
+ return AccountEntity.createAccount(response.client_info, homeAccountIdentifier, idTokenObj, undefined, undefined, undefined, authority, response.account.id);
11992
+ };
11993
+ /**
11994
+ * Helper to generate scopes
11995
+ * @param response
11996
+ * @param request
11997
+ * @returns
11998
+ */
11999
+ NativeInteractionClient.prototype.generateScopes = function (response, request) {
12000
+ return response.scope ? ScopeSet.fromString(response.scope) : ScopeSet.fromString(request.scope);
12001
+ };
12002
+ /**
12003
+ * If PoP token is requesred, records the PoP token if returned from the WAM, else generates one in the browser
12004
+ * @param request
12005
+ * @param response
12006
+ */
12007
+ NativeInteractionClient.prototype.generatePopAccessToken = function (response, request) {
12008
+ return __awaiter$1(this, void 0, void 0, function () {
12009
+ var popTokenGenerator, shrParameters;
12010
+ return __generator$1(this, function (_a) {
12011
+ switch (_a.label) {
11571
12012
  case 0:
11572
- this.logger.trace("NativeInteractionClient - handleNativeResponse called.");
11573
- mats = this.getMATSFromResponse(response);
11574
- this.performanceClient.addStaticFields({
11575
- extensionId: this.nativeMessageHandler.getExtensionId(),
11576
- extensionVersion: this.nativeMessageHandler.getExtensionVersion(),
11577
- matsBrokerVersion: mats ? mats.broker_version : undefined,
11578
- matsAccountJoinOnStart: mats ? mats.account_join_on_start : undefined,
11579
- matsAccountJoinOnEnd: mats ? mats.account_join_on_end : undefined,
11580
- matsDeviceJoin: mats ? mats.device_join : undefined,
11581
- matsPromptBehavior: mats ? mats.prompt_behavior : undefined,
11582
- matsApiErrorCode: mats ? mats.api_error_code : undefined,
11583
- matsUiVisible: mats ? mats.ui_visible : undefined,
11584
- matsSilentCode: mats ? mats.silent_code : undefined,
11585
- matsSilentBiSubCode: mats ? mats.silent_bi_sub_code : undefined,
11586
- matsSilentMessage: mats ? mats.silent_message : undefined,
11587
- matsSilentStatus: mats ? mats.silent_status : undefined,
11588
- matsHttpStatus: mats ? mats.http_status : undefined,
11589
- matsHttpEventCount: mats ? mats.http_event_count : undefined
11590
- }, this.correlationId);
11591
- if (response.account.id !== request.accountId) {
11592
- // User switch in native broker prompt is not supported. All users must first sign in through web flow to ensure server state is in sync
11593
- throw NativeAuthError.createUserSwitchError();
11594
- }
11595
- idTokenObj = new AuthToken(response.id_token || Constants.EMPTY_STRING, this.browserCrypto);
11596
- return [4 /*yield*/, this.getDiscoveredAuthority(request.authority)];
11597
- case 1:
11598
- authority = _b.sent();
11599
- authorityPreferredCache = authority.getPreferredCache();
11600
- homeAccountIdentifier = AccountEntity.generateHomeAccountId(response.client_info || Constants.EMPTY_STRING, AuthorityType.Default, this.logger, this.browserCrypto, idTokenObj);
11601
- accountEntity = AccountEntity.createAccount(response.client_info, homeAccountIdentifier, idTokenObj, undefined, undefined, undefined, authorityPreferredCache, response.account.id);
11602
- this.browserStorage.setAccount(accountEntity);
11603
- responseScopes = response.scope ? ScopeSet.fromString(response.scope) : ScopeSet.fromString(request.scope);
11604
- accountProperties = response.account.properties || {};
11605
- uid = accountProperties["UID"] || idTokenObj.claims.oid || idTokenObj.claims.sub || Constants.EMPTY_STRING;
11606
- tid = accountProperties["TenantId"] || idTokenObj.claims.tid || Constants.EMPTY_STRING;
11607
- responseTokenType = exports.AuthenticationScheme.BEARER;
11608
- _a = request.tokenType;
11609
- switch (_a) {
11610
- case exports.AuthenticationScheme.POP: return [3 /*break*/, 2];
11611
- }
11612
- return [3 /*break*/, 4];
11613
- case 2:
11614
- // Set the token type to POP in the response
11615
- responseTokenType = exports.AuthenticationScheme.POP;
12013
+ if (!(request.tokenType === exports.AuthenticationScheme.POP)) return [3 /*break*/, 2];
12014
+ /**
12015
+ * This code prioritizes SHR returned from the native layer. In case of error/SHR not calculated from WAM and the AT
12016
+ * is still received, SHR is calculated locally
12017
+ */
11616
12018
  // Check if native layer returned an SHR token
11617
12019
  if (response.shr) {
11618
12020
  this.logger.trace("handleNativeServerResponse: SHR is enabled in native layer");
11619
- responseAccessToken = response.shr;
11620
- return [3 /*break*/, 5];
12021
+ return [2 /*return*/, response.shr];
11621
12022
  }
11622
12023
  popTokenGenerator = new PopTokenGenerator(this.browserCrypto);
11623
12024
  shrParameters = {
@@ -11634,17 +12035,39 @@ var NativeInteractionClient = /** @class */ (function (_super) {
11634
12035
  throw ClientAuthError.createKeyIdMissingError();
11635
12036
  }
11636
12037
  return [4 /*yield*/, popTokenGenerator.signPopToken(response.access_token, request.keyId, shrParameters)];
11637
- case 3:
11638
- responseAccessToken = _b.sent();
11639
- return [3 /*break*/, 5];
11640
- case 4:
11641
- {
11642
- responseAccessToken = response.access_token;
11643
- }
11644
- _b.label = 5;
11645
- case 5:
12038
+ case 1: return [2 /*return*/, _a.sent()];
12039
+ case 2: return [2 /*return*/, response.access_token];
12040
+ }
12041
+ });
12042
+ });
12043
+ };
12044
+ /**
12045
+ * Generates authentication result
12046
+ * @param response
12047
+ * @param request
12048
+ * @param idTokenObj
12049
+ * @param accountEntity
12050
+ * @param authority
12051
+ * @param reqTimestamp
12052
+ * @returns
12053
+ */
12054
+ NativeInteractionClient.prototype.generateAuthenticationResult = function (response, request, idTokenObj, accountEntity, authority, reqTimestamp) {
12055
+ return __awaiter$1(this, void 0, void 0, function () {
12056
+ var mats, responseScopes, accountProperties, uid, tid, responseAccessToken, tokenType, result;
12057
+ return __generator$1(this, function (_a) {
12058
+ switch (_a.label) {
12059
+ case 0:
12060
+ mats = this.addTelemetryFromNativeResponse(response);
12061
+ responseScopes = response.scope ? ScopeSet.fromString(response.scope) : ScopeSet.fromString(request.scope);
12062
+ accountProperties = response.account.properties || {};
12063
+ uid = accountProperties["UID"] || idTokenObj.claims.oid || idTokenObj.claims.sub || Constants.EMPTY_STRING;
12064
+ tid = accountProperties["TenantId"] || idTokenObj.claims.tid || Constants.EMPTY_STRING;
12065
+ return [4 /*yield*/, this.generatePopAccessToken(response, request)];
12066
+ case 1:
12067
+ responseAccessToken = _a.sent();
12068
+ tokenType = (request.tokenType === exports.AuthenticationScheme.POP) ? exports.AuthenticationScheme.POP : exports.AuthenticationScheme.BEARER;
11646
12069
  result = {
11647
- authority: authority.canonicalAuthority,
12070
+ authority: authority,
11648
12071
  uniqueId: uid,
11649
12072
  tenantId: tid,
11650
12073
  scopes: responseScopes.asArray(),
@@ -11654,30 +12077,78 @@ var NativeInteractionClient = /** @class */ (function (_super) {
11654
12077
  accessToken: responseAccessToken,
11655
12078
  fromCache: mats ? this.isResponseFromCache(mats) : false,
11656
12079
  expiresOn: new Date(Number(reqTimestamp + response.expires_in) * 1000),
11657
- tokenType: responseTokenType,
12080
+ tokenType: tokenType,
11658
12081
  correlationId: this.correlationId,
11659
12082
  state: response.state,
11660
12083
  fromNativeBroker: true
11661
12084
  };
11662
- idTokenEntity = IdTokenEntity.createIdTokenEntity(homeAccountIdentifier, request.authority, response.id_token || Constants.EMPTY_STRING, request.clientId, idTokenObj.claims.tid || Constants.EMPTY_STRING);
11663
- this.nativeStorageManager.setIdTokenCredential(idTokenEntity);
11664
- expiresIn = (responseTokenType === exports.AuthenticationScheme.POP)
11665
- ? Constants.SHR_NONCE_VALIDITY
11666
- : (typeof response.expires_in === "string"
11667
- ? parseInt(response.expires_in, 10)
11668
- : response.expires_in) || 0;
11669
- tokenExpirationSeconds = reqTimestamp + expiresIn;
11670
- accessTokenEntity = AccessTokenEntity.createAccessTokenEntity(homeAccountIdentifier, request.authority, responseAccessToken, request.clientId, tid, responseScopes.printScopes(), tokenExpirationSeconds, 0, this.browserCrypto);
11671
- this.nativeStorageManager.setAccessTokenCredential(accessTokenEntity);
11672
- // Remove any existing cached tokens for this account in browser storage
11673
- this.browserStorage.removeAccountContext(accountEntity).catch(function (e) {
11674
- _this.logger.error("Error occurred while removing account context from browser storage. " + e);
11675
- });
11676
12085
  return [2 /*return*/, result];
11677
12086
  }
11678
12087
  });
11679
12088
  });
11680
12089
  };
12090
+ /**
12091
+ * cache the account entity in browser storage
12092
+ * @param accountEntity
12093
+ */
12094
+ NativeInteractionClient.prototype.cacheAccount = function (accountEntity) {
12095
+ var _this = this;
12096
+ // Store the account info and hence `nativeAccountId` in browser cache
12097
+ this.browserStorage.setAccount(accountEntity);
12098
+ // Remove any existing cached tokens for this account in browser storage
12099
+ this.browserStorage.removeAccountContext(accountEntity).catch(function (e) {
12100
+ _this.logger.error("Error occurred while removing account context from browser storage. " + e);
12101
+ });
12102
+ };
12103
+ /**
12104
+ * Stores the access_token and id_token in inmemory storage
12105
+ * @param response
12106
+ * @param request
12107
+ * @param homeAccountIdentifier
12108
+ * @param idTokenObj
12109
+ * @param responseAccessToken
12110
+ * @param tenantId
12111
+ * @param reqTimestamp
12112
+ */
12113
+ NativeInteractionClient.prototype.cacheNativeTokens = function (response, request, homeAccountIdentifier, idTokenObj, responseAccessToken, tenantId, reqTimestamp) {
12114
+ // cache idToken in inmemory storage
12115
+ var idTokenEntity = IdTokenEntity.createIdTokenEntity(homeAccountIdentifier, request.authority, response.id_token || Constants.EMPTY_STRING, request.clientId, idTokenObj.claims.tid || Constants.EMPTY_STRING);
12116
+ this.nativeStorageManager.setIdTokenCredential(idTokenEntity);
12117
+ // cache accessToken in inmemory storage
12118
+ var expiresIn = (request.tokenType === exports.AuthenticationScheme.POP)
12119
+ ? Constants.SHR_NONCE_VALIDITY
12120
+ : (typeof response.expires_in === "string"
12121
+ ? parseInt(response.expires_in, 10)
12122
+ : response.expires_in) || 0;
12123
+ var tokenExpirationSeconds = reqTimestamp + expiresIn;
12124
+ var responseScopes = this.generateScopes(response, request);
12125
+ var accessTokenEntity = AccessTokenEntity.createAccessTokenEntity(homeAccountIdentifier, request.authority, responseAccessToken, request.clientId, tenantId, responseScopes.printScopes(), tokenExpirationSeconds, 0, this.browserCrypto);
12126
+ this.nativeStorageManager.setAccessTokenCredential(accessTokenEntity);
12127
+ };
12128
+ NativeInteractionClient.prototype.addTelemetryFromNativeResponse = function (response) {
12129
+ var mats = this.getMATSFromResponse(response);
12130
+ if (!mats) {
12131
+ return null;
12132
+ }
12133
+ this.performanceClient.addStaticFields({
12134
+ extensionId: this.nativeMessageHandler.getExtensionId(),
12135
+ extensionVersion: this.nativeMessageHandler.getExtensionVersion(),
12136
+ matsBrokerVersion: mats.broker_version,
12137
+ matsAccountJoinOnStart: mats.account_join_on_start,
12138
+ matsAccountJoinOnEnd: mats.account_join_on_end,
12139
+ matsDeviceJoin: mats.device_join,
12140
+ matsPromptBehavior: mats.prompt_behavior,
12141
+ matsApiErrorCode: mats.api_error_code,
12142
+ matsUiVisible: mats.ui_visible,
12143
+ matsSilentCode: mats.silent_code,
12144
+ matsSilentBiSubCode: mats.silent_bi_sub_code,
12145
+ matsSilentMessage: mats.silent_message,
12146
+ matsSilentStatus: mats.silent_status,
12147
+ matsHttpStatus: mats.http_status,
12148
+ matsHttpEventCount: mats.http_event_count
12149
+ }, this.correlationId);
12150
+ return mats;
12151
+ };
11681
12152
  /**
11682
12153
  * Validates native platform response before processing
11683
12154
  * @param response
@@ -11796,7 +12267,7 @@ var NativeInteractionClient = /** @class */ (function (_super) {
11796
12267
  * Licensed under the MIT License.
11797
12268
  */
11798
12269
  var NativeMessageHandler = /** @class */ (function () {
11799
- function NativeMessageHandler(logger, handshakeTimeoutMs, extensionId) {
12270
+ function NativeMessageHandler(logger, handshakeTimeoutMs, performanceClient, extensionId) {
11800
12271
  this.logger = logger;
11801
12272
  this.handshakeTimeoutMs = handshakeTimeoutMs;
11802
12273
  this.extensionId = extensionId;
@@ -11805,6 +12276,8 @@ var NativeMessageHandler = /** @class */ (function () {
11805
12276
  this.responseId = 0;
11806
12277
  this.messageChannel = new MessageChannel();
11807
12278
  this.windowListener = this.onWindowMessage.bind(this); // Window event callback doesn't have access to 'this' unless it's bound
12279
+ this.performanceClient = performanceClient;
12280
+ this.handshakeEvent = performanceClient.startMeasurement(exports.PerformanceEvents.NativeMessageHandlerHandshake);
11808
12281
  }
11809
12282
  /**
11810
12283
  * Sends a given message to the extension and resolves with the extension response
@@ -11833,10 +12306,11 @@ var NativeMessageHandler = /** @class */ (function () {
11833
12306
  };
11834
12307
  /**
11835
12308
  * Returns an instance of the MessageHandler that has successfully established a connection with an extension
11836
- * @param logger
11837
- * @param handshakeTimeoutMs
12309
+ * @param {Logger} logger
12310
+ * @param {number} handshakeTimeoutMs
12311
+ * @param {IPerformanceClient} performanceClient
11838
12312
  */
11839
- NativeMessageHandler.createProvider = function (logger, handshakeTimeoutMs) {
12313
+ NativeMessageHandler.createProvider = function (logger, handshakeTimeoutMs, performanceClient) {
11840
12314
  return __awaiter$1(this, void 0, void 0, function () {
11841
12315
  var preferredProvider, backupProvider;
11842
12316
  return __generator$1(this, function (_a) {
@@ -11846,14 +12320,14 @@ var NativeMessageHandler = /** @class */ (function () {
11846
12320
  _a.label = 1;
11847
12321
  case 1:
11848
12322
  _a.trys.push([1, 3, , 5]);
11849
- preferredProvider = new NativeMessageHandler(logger, handshakeTimeoutMs, NativeConstants.PREFERRED_EXTENSION_ID);
12323
+ preferredProvider = new NativeMessageHandler(logger, handshakeTimeoutMs, performanceClient, NativeConstants.PREFERRED_EXTENSION_ID);
11850
12324
  return [4 /*yield*/, preferredProvider.sendHandshakeRequest()];
11851
12325
  case 2:
11852
12326
  _a.sent();
11853
12327
  return [2 /*return*/, preferredProvider];
11854
12328
  case 3:
11855
12329
  _a.sent();
11856
- backupProvider = new NativeMessageHandler(logger, handshakeTimeoutMs);
12330
+ backupProvider = new NativeMessageHandler(logger, handshakeTimeoutMs, performanceClient);
11857
12331
  return [4 /*yield*/, backupProvider.sendHandshakeRequest()];
11858
12332
  case 4:
11859
12333
  _a.sent();
@@ -11882,6 +12356,10 @@ var NativeMessageHandler = /** @class */ (function () {
11882
12356
  method: NativeExtensionMethod.HandshakeRequest
11883
12357
  }
11884
12358
  };
12359
+ this.handshakeEvent.addStaticFields({
12360
+ extensionId: this.extensionId,
12361
+ extensionHandshakeTimeoutMs: this.handshakeTimeoutMs
12362
+ });
11885
12363
  this.messageChannel.port1.onmessage = function (event) {
11886
12364
  _this.onChannelMessage(event);
11887
12365
  };
@@ -11896,6 +12374,7 @@ var NativeMessageHandler = /** @class */ (function () {
11896
12374
  window.removeEventListener("message", _this.windowListener, false);
11897
12375
  _this.messageChannel.port1.close();
11898
12376
  _this.messageChannel.port2.close();
12377
+ _this.handshakeEvent.endMeasurement({ extensionHandshakeTimedOut: true, success: false });
11899
12378
  reject(BrowserAuthError.createNativeHandshakeTimeoutError());
11900
12379
  _this.handshakeResolvers.delete(req.responseId);
11901
12380
  }, _this.handshakeTimeoutMs); // Use a reasonable timeout in milliseconds here
@@ -11929,6 +12408,7 @@ var NativeMessageHandler = /** @class */ (function () {
11929
12408
  window.removeEventListener("message", this.windowListener, false);
11930
12409
  var handshakeResolver = this.handshakeResolvers.get(request.responseId);
11931
12410
  if (handshakeResolver) {
12411
+ this.handshakeEvent.endMeasurement({ success: false, extensionInstalled: false });
11932
12412
  handshakeResolver.reject(BrowserAuthError.createNativeExtensionNotInstalledError());
11933
12413
  }
11934
12414
  }
@@ -11976,6 +12456,7 @@ var NativeMessageHandler = /** @class */ (function () {
11976
12456
  this.extensionId = request.extensionId;
11977
12457
  this.extensionVersion = request.body.version;
11978
12458
  this.logger.verbose("NativeMessageHandler - Received HandshakeResponse from extension: " + this.extensionId);
12459
+ this.handshakeEvent.endMeasurement({ extensionInstalled: true, success: true });
11979
12460
  handshakeResolver.resolve();
11980
12461
  this.handshakeResolvers.delete(request.responseId);
11981
12462
  }
@@ -12063,7 +12544,9 @@ var RedirectClient = /** @class */ (function (_super) {
12063
12544
  var _this = this;
12064
12545
  return __generator$1(this, function (_a) {
12065
12546
  switch (_a.label) {
12066
- case 0: return [4 /*yield*/, this.initializeAuthorizationRequest(request, exports.InteractionType.Redirect)];
12547
+ case 0:
12548
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.StandardInteractionClientInitializeAuthorizationRequest, request.correlationId);
12549
+ return [4 /*yield*/, this.initializeAuthorizationRequest(request, exports.InteractionType.Redirect)];
12067
12550
  case 1:
12068
12551
  validRequest = _a.sent();
12069
12552
  this.browserStorage.updateCacheEntries(validRequest.state, validRequest.nonce, validRequest.authority, validRequest.loginHint || Constants.EMPTY_STRING, validRequest.account || null);
@@ -12078,14 +12561,18 @@ var RedirectClient = /** @class */ (function (_super) {
12078
12561
  _a.label = 2;
12079
12562
  case 2:
12080
12563
  _a.trys.push([2, 7, , 8]);
12564
+ // Create auth code request and generate PKCE params
12565
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.StandardInteractionClientInitializeAuthorizationCodeRequest, request.correlationId);
12081
12566
  return [4 /*yield*/, this.initializeAuthorizationCodeRequest(validRequest)];
12082
12567
  case 3:
12083
12568
  authCodeRequest = _a.sent();
12569
+ // Initialize the client
12570
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.StandardInteractionClientCreateAuthCodeClient, request.correlationId);
12084
12571
  return [4 /*yield*/, this.createAuthCodeClient(serverTelemetryManager, validRequest.authority, validRequest.azureCloudOptions)];
12085
12572
  case 4:
12086
12573
  authClient = _a.sent();
12087
12574
  this.logger.verbose("Auth code client created");
12088
- interactionHandler = new RedirectHandler(authClient, this.browserStorage, authCodeRequest, this.logger, this.browserCrypto);
12575
+ interactionHandler = new RedirectHandler(authClient, this.browserStorage, authCodeRequest, this.logger, this.browserCrypto, this.performanceClient);
12089
12576
  return [4 /*yield*/, authClient.getAuthCodeUrl(__assign$1(__assign$1({}, validRequest), { nativeBroker: NativeMessageHandler.isNativeAvailable(this.config, this.logger, this.nativeMessageHandler, request.authenticationScheme) }))];
12090
12577
  case 5:
12091
12578
  navigateUrl = _a.sent();
@@ -12271,12 +12758,13 @@ var RedirectClient = /** @class */ (function (_super) {
12271
12758
  if (!currentAuthority) {
12272
12759
  throw BrowserAuthError.createNoCachedAuthorityError();
12273
12760
  }
12761
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.StandardInteractionClientCreateAuthCodeClient, cachedRequest.correlationId);
12274
12762
  return [4 /*yield*/, this.createAuthCodeClient(serverTelemetryManager, currentAuthority)];
12275
12763
  case 1:
12276
12764
  authClient = _a.sent();
12277
12765
  this.logger.verbose("Auth code client created");
12278
12766
  ThrottlingUtils.removeThrottle(this.browserStorage, this.config.auth.clientId, cachedRequest);
12279
- interactionHandler = new RedirectHandler(authClient, this.browserStorage, cachedRequest, this.logger, this.browserCrypto);
12767
+ interactionHandler = new RedirectHandler(authClient, this.browserStorage, cachedRequest, this.logger, this.browserCrypto, this.performanceClient);
12280
12768
  return [4 /*yield*/, interactionHandler.handleCodeResponseFromHash(hash, state, authClient.authority, this.networkClient)];
12281
12769
  case 2: return [2 /*return*/, _a.sent()];
12282
12770
  }
@@ -12311,6 +12799,7 @@ var RedirectClient = /** @class */ (function (_super) {
12311
12799
  timeout: this.config.system.redirectNavigationTimeout,
12312
12800
  noHistory: false
12313
12801
  };
12802
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.StandardInteractionClientCreateAuthCodeClient, validLogoutRequest.correlationId);
12314
12803
  return [4 /*yield*/, this.createAuthCodeClient(serverTelemetryManager, logoutRequest && logoutRequest.authority)];
12315
12804
  case 3:
12316
12805
  authClient = _a.sent();
@@ -12458,6 +12947,7 @@ var PopupClient = /** @class */ (function (_super) {
12458
12947
  case 0:
12459
12948
  this.logger.verbose("acquireTokenPopupAsync called");
12460
12949
  serverTelemetryManager = this.initializeServerTelemetryManager(exports.ApiId.acquireTokenPopup);
12950
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.StandardInteractionClientInitializeAuthorizationRequest, request.correlationId);
12461
12951
  return [4 /*yield*/, this.initializeAuthorizationRequest(request, exports.InteractionType.Popup)];
12462
12952
  case 1:
12463
12953
  validRequest = _a.sent();
@@ -12465,9 +12955,13 @@ var PopupClient = /** @class */ (function (_super) {
12465
12955
  _a.label = 2;
12466
12956
  case 2:
12467
12957
  _a.trys.push([2, 8, , 9]);
12958
+ // Create auth code request and generate PKCE params
12959
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.StandardInteractionClientInitializeAuthorizationCodeRequest, request.correlationId);
12468
12960
  return [4 /*yield*/, this.initializeAuthorizationCodeRequest(validRequest)];
12469
12961
  case 3:
12470
12962
  authCodeRequest = _a.sent();
12963
+ // Initialize the client
12964
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.StandardInteractionClientCreateAuthCodeClient, request.correlationId);
12471
12965
  return [4 /*yield*/, this.createAuthCodeClient(serverTelemetryManager, validRequest.authority, validRequest.azureCloudOptions)];
12472
12966
  case 4:
12473
12967
  authClient = _a.sent();
@@ -12480,7 +12974,7 @@ var PopupClient = /** @class */ (function (_super) {
12480
12974
  return [4 /*yield*/, authClient.getAuthCodeUrl(__assign$1(__assign$1({}, validRequest), { nativeBroker: isNativeBroker }))];
12481
12975
  case 5:
12482
12976
  navigateUrl = _a.sent();
12483
- interactionHandler = new InteractionHandler(authClient, this.browserStorage, authCodeRequest, this.logger);
12977
+ interactionHandler = new InteractionHandler(authClient, this.browserStorage, authCodeRequest, this.logger, this.performanceClient);
12484
12978
  popupParameters = {
12485
12979
  popup: popup,
12486
12980
  popupName: popupName,
@@ -12561,6 +13055,8 @@ var PopupClient = /** @class */ (function (_super) {
12561
13055
  case 2:
12562
13056
  // Clear cache on logout
12563
13057
  _a.sent();
13058
+ // Initialize the client
13059
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.StandardInteractionClientCreateAuthCodeClient, validRequest.correlationId);
12564
13060
  return [4 /*yield*/, this.createAuthCodeClient(serverTelemetryManager, requestAuthority)];
12565
13061
  case 3:
12566
13062
  authClient = _a.sent();
@@ -12989,8 +13485,8 @@ function buildConfiguration(_a, isBrowserEnvironment) {
12989
13485
  */
12990
13486
  var SilentHandler = /** @class */ (function (_super) {
12991
13487
  __extends$1(SilentHandler, _super);
12992
- function SilentHandler(authCodeModule, storageImpl, authCodeRequest, logger, systemOptions) {
12993
- var _this = _super.call(this, authCodeModule, storageImpl, authCodeRequest, logger) || this;
13488
+ function SilentHandler(authCodeModule, storageImpl, authCodeRequest, logger, systemOptions, performanceClient) {
13489
+ var _this = _super.call(this, authCodeModule, storageImpl, authCodeRequest, logger, performanceClient) || this;
12994
13490
  _this.navigateFrameWait = systemOptions.navigateFrameWait;
12995
13491
  _this.pollIntervalMilliseconds = systemOptions.pollIntervalMilliseconds;
12996
13492
  return _this;
@@ -13002,24 +13498,20 @@ var SilentHandler = /** @class */ (function (_super) {
13002
13498
  */
13003
13499
  SilentHandler.prototype.initiateAuthRequest = function (requestUrl) {
13004
13500
  return __awaiter$1(this, void 0, void 0, function () {
13005
- var _a;
13006
- return __generator$1(this, function (_b) {
13007
- switch (_b.label) {
13501
+ return __generator$1(this, function (_a) {
13502
+ switch (_a.label) {
13008
13503
  case 0:
13504
+ this.performanceClient.addQueueMeasurement(exports.PerformanceEvents.SilentHandlerInitiateAuthRequest, this.authCodeRequest.correlationId);
13009
13505
  if (StringUtils.isEmpty(requestUrl)) {
13010
13506
  // Throw error if request URL is empty.
13011
13507
  this.logger.info("Navigate url is empty");
13012
13508
  throw BrowserAuthError.createEmptyNavigationUriError();
13013
13509
  }
13014
13510
  if (!this.navigateFrameWait) return [3 /*break*/, 2];
13511
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.SilentHandlerLoadFrame, this.authCodeRequest.correlationId);
13015
13512
  return [4 /*yield*/, this.loadFrame(requestUrl)];
13016
- case 1:
13017
- _a = _b.sent();
13018
- return [3 /*break*/, 3];
13019
- case 2:
13020
- _a = this.loadFrameSync(requestUrl);
13021
- _b.label = 3;
13022
- case 3: return [2 /*return*/, _a];
13513
+ case 1: return [2 /*return*/, _a.sent()];
13514
+ case 2: return [2 /*return*/, this.loadFrameSync(requestUrl)];
13023
13515
  }
13024
13516
  });
13025
13517
  });
@@ -13031,6 +13523,7 @@ var SilentHandler = /** @class */ (function (_super) {
13031
13523
  */
13032
13524
  SilentHandler.prototype.monitorIframeForHash = function (iframe, timeout) {
13033
13525
  var _this = this;
13526
+ this.performanceClient.addQueueMeasurement(exports.PerformanceEvents.SilentHandlerMonitorIframeForHash, this.authCodeRequest.correlationId);
13034
13527
  return new Promise(function (resolve, reject) {
13035
13528
  if (timeout < DEFAULT_IFRAME_TIMEOUT_MS) {
13036
13529
  _this.logger.warning("system.loadFrameTimeout or system.iframeHashTimeout set to lower (" + timeout + "ms) than the default (" + DEFAULT_IFRAME_TIMEOUT_MS + "ms). This may result in timeouts.");
@@ -13079,11 +13572,12 @@ var SilentHandler = /** @class */ (function (_super) {
13079
13572
  * @ignore
13080
13573
  */
13081
13574
  SilentHandler.prototype.loadFrame = function (urlNavigate) {
13575
+ var _this = this;
13576
+ this.performanceClient.addQueueMeasurement(exports.PerformanceEvents.SilentHandlerLoadFrame, this.authCodeRequest.correlationId);
13082
13577
  /*
13083
13578
  * This trick overcomes iframe navigation in IE
13084
13579
  * IE does not load the page consistently in iframe
13085
13580
  */
13086
- var _this = this;
13087
13581
  return new Promise(function (resolve, reject) {
13088
13582
  var frameHandle = _this.createHiddenIframe();
13089
13583
  setTimeout(function () {
@@ -13158,6 +13652,7 @@ var SilentIframeClient = /** @class */ (function (_super) {
13158
13652
  return __generator$1(this, function (_a) {
13159
13653
  switch (_a.label) {
13160
13654
  case 0:
13655
+ this.performanceClient.addQueueMeasurement(exports.PerformanceEvents.SilentIframeClientAcquireToken, request.correlationId);
13161
13656
  this.logger.verbose("acquireTokenByIframe called");
13162
13657
  acquireTokenMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.SilentIframeClientAcquireToken, request.correlationId);
13163
13658
  // Check that we have some SSO data
@@ -13171,6 +13666,8 @@ var SilentIframeClient = /** @class */ (function (_super) {
13171
13666
  });
13172
13667
  throw BrowserAuthError.createSilentPromptValueError(request.prompt);
13173
13668
  }
13669
+ // Create silent request
13670
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.StandardInteractionClientInitializeAuthorizationRequest, request.correlationId);
13174
13671
  return [4 /*yield*/, this.initializeAuthorizationRequest(__assign$1(__assign$1({}, request), { prompt: request.prompt || PromptValue.NONE }), exports.InteractionType.Silent)];
13175
13672
  case 1:
13176
13673
  silentRequest = _a.sent();
@@ -13179,10 +13676,13 @@ var SilentIframeClient = /** @class */ (function (_super) {
13179
13676
  _a.label = 2;
13180
13677
  case 2:
13181
13678
  _a.trys.push([2, 5, , 6]);
13679
+ // Initialize the client
13680
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.StandardInteractionClientCreateAuthCodeClient, request.correlationId);
13182
13681
  return [4 /*yield*/, this.createAuthCodeClient(serverTelemetryManager, silentRequest.authority, silentRequest.azureCloudOptions)];
13183
13682
  case 3:
13184
13683
  authClient = _a.sent();
13185
13684
  this.logger.verbose("Auth code client created");
13685
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.SilentIframeClientTokenHelper, request.correlationId);
13186
13686
  return [4 /*yield*/, this.silentTokenHelper(authClient, silentRequest).then(function (result) {
13187
13687
  acquireTokenMeasurement.endMeasurement({
13188
13688
  success: true,
@@ -13229,16 +13729,26 @@ var SilentIframeClient = /** @class */ (function (_super) {
13229
13729
  var _this = this;
13230
13730
  return __generator$1(this, function (_a) {
13231
13731
  switch (_a.label) {
13232
- case 0: return [4 /*yield*/, this.initializeAuthorizationCodeRequest(silentRequest)];
13732
+ case 0:
13733
+ this.performanceClient.addQueueMeasurement(exports.PerformanceEvents.SilentIframeClientTokenHelper, silentRequest.correlationId);
13734
+ // Create auth code request and generate PKCE params
13735
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.StandardInteractionClientInitializeAuthorizationCodeRequest, silentRequest.correlationId);
13736
+ return [4 /*yield*/, this.initializeAuthorizationCodeRequest(silentRequest)];
13233
13737
  case 1:
13234
13738
  authCodeRequest = _a.sent();
13739
+ // Create authorize request url
13740
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.GetAuthCodeUrl, silentRequest.correlationId);
13235
13741
  return [4 /*yield*/, authClient.getAuthCodeUrl(__assign$1(__assign$1({}, silentRequest), { nativeBroker: NativeMessageHandler.isNativeAvailable(this.config, this.logger, this.nativeMessageHandler, silentRequest.authenticationScheme) }))];
13236
13742
  case 2:
13237
13743
  navigateUrl = _a.sent();
13238
- silentHandler = new SilentHandler(authClient, this.browserStorage, authCodeRequest, this.logger, this.config.system);
13744
+ silentHandler = new SilentHandler(authClient, this.browserStorage, authCodeRequest, this.logger, this.config.system, this.performanceClient);
13745
+ // Get the frame handle for the silent request
13746
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.SilentHandlerInitiateAuthRequest, silentRequest.correlationId);
13239
13747
  return [4 /*yield*/, silentHandler.initiateAuthRequest(navigateUrl)];
13240
13748
  case 3:
13241
13749
  msalFrame = _a.sent();
13750
+ // Monitor the window for the hash. Return the string value and close the popup when the hash is received. Default timeout is 60 seconds.
13751
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.SilentHandlerMonitorIframeForHash, silentRequest.correlationId);
13242
13752
  return [4 /*yield*/, silentHandler.monitorIframeForHash(msalFrame, this.config.system.iframeHashTimeout)];
13243
13753
  case 4:
13244
13754
  hash = _a.sent();
@@ -13256,6 +13766,7 @@ var SilentIframeClient = /** @class */ (function (_super) {
13256
13766
  })];
13257
13767
  }
13258
13768
  // Handle response from hash string
13769
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.HandleCodeResponseFromHash, silentRequest.correlationId);
13259
13770
  return [2 /*return*/, silentHandler.handleCodeResponseFromHash(hash, state, authClient.authority, this.networkClient)];
13260
13771
  }
13261
13772
  });
@@ -13284,6 +13795,8 @@ var SilentRefreshClient = /** @class */ (function (_super) {
13284
13795
  return __generator$1(this, function (_b) {
13285
13796
  switch (_b.label) {
13286
13797
  case 0:
13798
+ this.performanceClient.addQueueMeasurement(exports.PerformanceEvents.SilentRefreshClientAcquireToken, request.correlationId);
13799
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.InitializeBaseRequest, request.correlationId);
13287
13800
  _a = [__assign$1({}, request)];
13288
13801
  return [4 /*yield*/, this.initializeBaseRequest(request)];
13289
13802
  case 1:
@@ -13295,6 +13808,7 @@ var SilentRefreshClient = /** @class */ (function (_super) {
13295
13808
  refreshTokenClient = _b.sent();
13296
13809
  this.logger.verbose("Refresh token client created");
13297
13810
  // Send request to renew token. Auth module will throw errors if token cannot be renewed.
13811
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.RefreshTokenClientAcquireTokenByRefreshToken, request.correlationId);
13298
13812
  return [2 /*return*/, refreshTokenClient.acquireTokenByRefreshToken(silentRequest)
13299
13813
  .then(function (result) {
13300
13814
  acquireTokenMeasurement.endMeasurement({
@@ -13337,7 +13851,10 @@ var SilentRefreshClient = /** @class */ (function (_super) {
13337
13851
  var clientConfig;
13338
13852
  return __generator$1(this, function (_a) {
13339
13853
  switch (_a.label) {
13340
- case 0: return [4 /*yield*/, this.getClientConfiguration(serverTelemetryManager, authorityUrl, azureCloudOptions)];
13854
+ case 0:
13855
+ // Create auth module.
13856
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.StandardInteractionClientGetClientConfiguration, this.correlationId);
13857
+ return [4 /*yield*/, this.getClientConfiguration(serverTelemetryManager, authorityUrl, azureCloudOptions)];
13341
13858
  case 1:
13342
13859
  clientConfig = _a.sent();
13343
13860
  return [2 /*return*/, new RefreshTokenClient(clientConfig, this.performanceClient)];
@@ -14916,91 +15433,304 @@ var CryptoOps = /** @class */ (function () {
14916
15433
  return [2 /*return*/, !keyFound];
14917
15434
  }
14918
15435
  });
14919
- });
15436
+ });
15437
+ };
15438
+ /**
15439
+ * Removes all cryptographic keys from IndexedDB storage
15440
+ */
15441
+ CryptoOps.prototype.clearKeystore = function () {
15442
+ return __awaiter$1(this, void 0, void 0, function () {
15443
+ return __generator$1(this, function (_a) {
15444
+ switch (_a.label) {
15445
+ case 0: return [4 /*yield*/, this.cache.clear()];
15446
+ case 1: return [2 /*return*/, _a.sent()];
15447
+ }
15448
+ });
15449
+ });
15450
+ };
15451
+ /**
15452
+ * Signs the given object as a jwt payload with private key retrieved by given kid.
15453
+ * @param payload
15454
+ * @param kid
15455
+ */
15456
+ CryptoOps.prototype.signJwt = function (payload, kid, correlationId) {
15457
+ var _a;
15458
+ return __awaiter$1(this, void 0, void 0, function () {
15459
+ var signJwtMeasurement, cachedKeyPair, publicKeyJwk, publicKeyJwkString, encodedKeyIdThumbprint, shrHeader, encodedShrHeader, encodedPayload, tokenString, tokenBuffer, signatureBuffer, encodedSignature, signedJwt;
15460
+ return __generator$1(this, function (_b) {
15461
+ switch (_b.label) {
15462
+ case 0:
15463
+ signJwtMeasurement = (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.startMeasurement(exports.PerformanceEvents.CryptoOptsSignJwt, correlationId);
15464
+ return [4 /*yield*/, this.cache.asymmetricKeys.getItem(kid)];
15465
+ case 1:
15466
+ cachedKeyPair = _b.sent();
15467
+ if (!cachedKeyPair) {
15468
+ throw BrowserAuthError.createSigningKeyNotFoundInStorageError(kid);
15469
+ }
15470
+ return [4 /*yield*/, this.browserCrypto.exportJwk(cachedKeyPair.publicKey)];
15471
+ case 2:
15472
+ publicKeyJwk = _b.sent();
15473
+ publicKeyJwkString = BrowserStringUtils.getSortedObjectString(publicKeyJwk);
15474
+ encodedKeyIdThumbprint = this.b64Encode.urlEncode(JSON.stringify({ kid: kid }));
15475
+ shrHeader = JoseHeader.getShrHeaderString({ kid: encodedKeyIdThumbprint, alg: publicKeyJwk.alg });
15476
+ encodedShrHeader = this.b64Encode.urlEncode(shrHeader);
15477
+ // Generate payload
15478
+ payload.cnf = {
15479
+ jwk: JSON.parse(publicKeyJwkString)
15480
+ };
15481
+ encodedPayload = this.b64Encode.urlEncode(JSON.stringify(payload));
15482
+ tokenString = encodedShrHeader + "." + encodedPayload;
15483
+ tokenBuffer = BrowserStringUtils.stringToArrayBuffer(tokenString);
15484
+ return [4 /*yield*/, this.browserCrypto.sign(cachedKeyPair.privateKey, tokenBuffer)];
15485
+ case 3:
15486
+ signatureBuffer = _b.sent();
15487
+ encodedSignature = this.b64Encode.urlEncodeArr(new Uint8Array(signatureBuffer));
15488
+ signedJwt = tokenString + "." + encodedSignature;
15489
+ if (signJwtMeasurement) {
15490
+ signJwtMeasurement.endMeasurement({
15491
+ success: true
15492
+ });
15493
+ }
15494
+ return [2 /*return*/, signedJwt];
15495
+ }
15496
+ });
15497
+ });
15498
+ };
15499
+ /**
15500
+ * Returns the SHA-256 hash of an input string
15501
+ * @param plainText
15502
+ */
15503
+ CryptoOps.prototype.hashString = function (plainText) {
15504
+ return __awaiter$1(this, void 0, void 0, function () {
15505
+ var hashBuffer, hashBytes;
15506
+ return __generator$1(this, function (_a) {
15507
+ switch (_a.label) {
15508
+ case 0: return [4 /*yield*/, this.browserCrypto.sha256Digest(plainText)];
15509
+ case 1:
15510
+ hashBuffer = _a.sent();
15511
+ hashBytes = new Uint8Array(hashBuffer);
15512
+ return [2 /*return*/, this.b64Encode.urlEncodeArr(hashBytes)];
15513
+ }
15514
+ });
15515
+ });
15516
+ };
15517
+ CryptoOps.POP_KEY_USAGES = ["sign", "verify"];
15518
+ CryptoOps.EXTRACTABLE = true;
15519
+ return CryptoOps;
15520
+ }());
15521
+
15522
+ /*
15523
+ * Copyright (c) Microsoft Corporation. All rights reserved.
15524
+ * Licensed under the MIT License.
15525
+ */
15526
+ var BrowserPerformanceMeasurement = /** @class */ (function () {
15527
+ function BrowserPerformanceMeasurement(name, correlationId) {
15528
+ this.correlationId = correlationId;
15529
+ this.measureName = BrowserPerformanceMeasurement.makeMeasureName(name, correlationId);
15530
+ this.startMark = BrowserPerformanceMeasurement.makeStartMark(name, correlationId);
15531
+ this.endMark = BrowserPerformanceMeasurement.makeEndMark(name, correlationId);
15532
+ }
15533
+ BrowserPerformanceMeasurement.makeMeasureName = function (name, correlationId) {
15534
+ return "msal.measure." + name + "." + correlationId;
15535
+ };
15536
+ BrowserPerformanceMeasurement.makeStartMark = function (name, correlationId) {
15537
+ return "msal.start." + name + "." + correlationId;
15538
+ };
15539
+ BrowserPerformanceMeasurement.makeEndMark = function (name, correlationId) {
15540
+ return "msal.end." + name + "." + correlationId;
15541
+ };
15542
+ BrowserPerformanceMeasurement.supportsBrowserPerformance = function () {
15543
+ return typeof window !== "undefined" &&
15544
+ typeof window.performance !== "undefined" &&
15545
+ typeof window.performance.mark === "function" &&
15546
+ typeof window.performance.measure === "function" &&
15547
+ typeof window.performance.clearMarks === "function" &&
15548
+ typeof window.performance.clearMeasures === "function" &&
15549
+ typeof window.performance.getEntriesByName === "function";
15550
+ };
15551
+ /**
15552
+ * Flush browser marks and measurements.
15553
+ * @param {string} correlationId
15554
+ * @param {SubMeasurement} measurements
15555
+ */
15556
+ BrowserPerformanceMeasurement.flushMeasurements = function (correlationId, measurements) {
15557
+ if (BrowserPerformanceMeasurement.supportsBrowserPerformance()) {
15558
+ try {
15559
+ measurements.forEach(function (measurement) {
15560
+ var measureName = BrowserPerformanceMeasurement.makeMeasureName(measurement.name, correlationId);
15561
+ var entriesForMeasurement = window.performance.getEntriesByName(measureName, "measure");
15562
+ if (entriesForMeasurement.length > 0) {
15563
+ window.performance.clearMeasures(measureName);
15564
+ window.performance.clearMarks(BrowserPerformanceMeasurement.makeStartMark(measureName, correlationId));
15565
+ window.performance.clearMarks(BrowserPerformanceMeasurement.makeEndMark(measureName, correlationId));
15566
+ }
15567
+ });
15568
+ }
15569
+ catch (e) {
15570
+ // Silently catch and return null
15571
+ }
15572
+ }
15573
+ };
15574
+ BrowserPerformanceMeasurement.prototype.startMeasurement = function () {
15575
+ if (BrowserPerformanceMeasurement.supportsBrowserPerformance()) {
15576
+ try {
15577
+ window.performance.mark(this.startMark);
15578
+ }
15579
+ catch (e) {
15580
+ // Silently catch
15581
+ }
15582
+ }
15583
+ };
15584
+ BrowserPerformanceMeasurement.prototype.endMeasurement = function () {
15585
+ if (BrowserPerformanceMeasurement.supportsBrowserPerformance()) {
15586
+ try {
15587
+ window.performance.mark(this.endMark);
15588
+ window.performance.measure(this.measureName, this.startMark, this.endMark);
15589
+ }
15590
+ catch (e) {
15591
+ // Silently catch
15592
+ }
15593
+ }
15594
+ };
15595
+ BrowserPerformanceMeasurement.prototype.flushMeasurement = function () {
15596
+ if (BrowserPerformanceMeasurement.supportsBrowserPerformance()) {
15597
+ try {
15598
+ var entriesForMeasurement = window.performance.getEntriesByName(this.measureName, "measure");
15599
+ if (entriesForMeasurement.length > 0) {
15600
+ var durationMs = entriesForMeasurement[0].duration;
15601
+ window.performance.clearMeasures(this.measureName);
15602
+ window.performance.clearMarks(this.startMark);
15603
+ window.performance.clearMarks(this.endMark);
15604
+ return durationMs;
15605
+ }
15606
+ }
15607
+ catch (e) {
15608
+ // Silently catch and return null
15609
+ }
15610
+ }
15611
+ return null;
15612
+ };
15613
+ return BrowserPerformanceMeasurement;
15614
+ }());
15615
+
15616
+ /*
15617
+ * Copyright (c) Microsoft Corporation. All rights reserved.
15618
+ * Licensed under the MIT License.
15619
+ */
15620
+ var BrowserPerformanceClient = /** @class */ (function (_super) {
15621
+ __extends$1(BrowserPerformanceClient, _super);
15622
+ function BrowserPerformanceClient(clientId, authority, logger, libraryName, libraryVersion, applicationTelemetry, cryptoOptions) {
15623
+ var _this = _super.call(this, clientId, authority, logger, libraryName, libraryVersion, applicationTelemetry) || this;
15624
+ _this.browserCrypto = new BrowserCrypto(_this.logger, cryptoOptions);
15625
+ _this.guidGenerator = new GuidGenerator(_this.browserCrypto);
15626
+ return _this;
15627
+ }
15628
+ BrowserPerformanceClient.prototype.startPerformanceMeasuremeant = function (measureName, correlationId) {
15629
+ return new BrowserPerformanceMeasurement(measureName, correlationId);
15630
+ };
15631
+ BrowserPerformanceClient.prototype.generateId = function () {
15632
+ return this.guidGenerator.generateGuid();
15633
+ };
15634
+ BrowserPerformanceClient.prototype.getPageVisibility = function () {
15635
+ var _a;
15636
+ return ((_a = document.visibilityState) === null || _a === void 0 ? void 0 : _a.toString()) || null;
15637
+ };
15638
+ BrowserPerformanceClient.prototype.deleteIncompleteSubMeasurements = function (inProgressEvent) {
15639
+ var rootEvent = this.eventsByCorrelationId.get(inProgressEvent.event.correlationId);
15640
+ var isRootEvent = rootEvent && rootEvent.eventId === inProgressEvent.event.eventId;
15641
+ var incompleteMeasurements = [];
15642
+ if (isRootEvent && (rootEvent === null || rootEvent === void 0 ? void 0 : rootEvent.incompleteSubMeasurements)) {
15643
+ rootEvent.incompleteSubMeasurements.forEach(function (subMeasurement) {
15644
+ incompleteMeasurements.push(__assign$1({}, subMeasurement));
15645
+ });
15646
+ }
15647
+ // Clean up remaining marks for incomplete sub-measurements
15648
+ if (incompleteMeasurements.length > 0) {
15649
+ BrowserPerformanceMeasurement.flushMeasurements(inProgressEvent.event.correlationId, incompleteMeasurements);
15650
+ }
15651
+ };
15652
+ BrowserPerformanceClient.prototype.supportsBrowserPerformanceNow = function () {
15653
+ return typeof window !== "undefined" &&
15654
+ typeof window.performance !== "undefined" &&
15655
+ typeof window.performance.now === "function";
14920
15656
  };
14921
15657
  /**
14922
- * Removes all cryptographic keys from IndexedDB storage
15658
+ * Starts measuring performance for a given operation. Returns a function that should be used to end the measurement.
15659
+ * Also captures browser page visibilityState.
15660
+ *
15661
+ * @param {PerformanceEvents} measureName
15662
+ * @param {?string} [correlationId]
15663
+ * @returns {((event?: Partial<PerformanceEvent>) => PerformanceEvent| null)}
14923
15664
  */
14924
- CryptoOps.prototype.clearKeystore = function () {
14925
- return __awaiter$1(this, void 0, void 0, function () {
14926
- return __generator$1(this, function (_a) {
14927
- switch (_a.label) {
14928
- case 0: return [4 /*yield*/, this.cache.clear()];
14929
- case 1: return [2 /*return*/, _a.sent()];
14930
- }
14931
- });
14932
- });
15665
+ BrowserPerformanceClient.prototype.startMeasurement = function (measureName, correlationId) {
15666
+ var _this = this;
15667
+ // Capture page visibilityState and then invoke start/end measurement
15668
+ var startPageVisibility = this.getPageVisibility();
15669
+ var inProgressEvent = _super.prototype.startMeasurement.call(this, measureName, correlationId);
15670
+ return __assign$1(__assign$1({}, inProgressEvent), { endMeasurement: function (event) {
15671
+ var res = inProgressEvent.endMeasurement(__assign$1({ startPageVisibility: startPageVisibility, endPageVisibility: _this.getPageVisibility() }, event));
15672
+ _this.deleteIncompleteSubMeasurements(inProgressEvent);
15673
+ return res;
15674
+ }, discardMeasurement: function () {
15675
+ inProgressEvent.discardMeasurement();
15676
+ _this.deleteIncompleteSubMeasurements(inProgressEvent);
15677
+ inProgressEvent.measurement.flushMeasurement();
15678
+ } });
14933
15679
  };
14934
15680
  /**
14935
- * Signs the given object as a jwt payload with private key retrieved by given kid.
14936
- * @param payload
14937
- * @param kid
15681
+ * Adds pre-queue time to preQueueTimeByCorrelationId map.
15682
+ * @param {PerformanceEvents} eventName
15683
+ * @param {?string} correlationId
15684
+ * @returns
14938
15685
  */
14939
- CryptoOps.prototype.signJwt = function (payload, kid, correlationId) {
14940
- var _a;
14941
- return __awaiter$1(this, void 0, void 0, function () {
14942
- var signJwtMeasurement, cachedKeyPair, publicKeyJwk, publicKeyJwkString, encodedKeyIdThumbprint, shrHeader, encodedShrHeader, encodedPayload, tokenString, tokenBuffer, signatureBuffer, encodedSignature, signedJwt;
14943
- return __generator$1(this, function (_b) {
14944
- switch (_b.label) {
14945
- case 0:
14946
- signJwtMeasurement = (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.startMeasurement(exports.PerformanceEvents.CryptoOptsSignJwt, correlationId);
14947
- return [4 /*yield*/, this.cache.asymmetricKeys.getItem(kid)];
14948
- case 1:
14949
- cachedKeyPair = _b.sent();
14950
- if (!cachedKeyPair) {
14951
- throw BrowserAuthError.createSigningKeyNotFoundInStorageError(kid);
14952
- }
14953
- return [4 /*yield*/, this.browserCrypto.exportJwk(cachedKeyPair.publicKey)];
14954
- case 2:
14955
- publicKeyJwk = _b.sent();
14956
- publicKeyJwkString = BrowserStringUtils.getSortedObjectString(publicKeyJwk);
14957
- encodedKeyIdThumbprint = this.b64Encode.urlEncode(JSON.stringify({ kid: kid }));
14958
- shrHeader = JoseHeader.getShrHeaderString({ kid: encodedKeyIdThumbprint, alg: publicKeyJwk.alg });
14959
- encodedShrHeader = this.b64Encode.urlEncode(shrHeader);
14960
- // Generate payload
14961
- payload.cnf = {
14962
- jwk: JSON.parse(publicKeyJwkString)
14963
- };
14964
- encodedPayload = this.b64Encode.urlEncode(JSON.stringify(payload));
14965
- tokenString = encodedShrHeader + "." + encodedPayload;
14966
- tokenBuffer = BrowserStringUtils.stringToArrayBuffer(tokenString);
14967
- return [4 /*yield*/, this.browserCrypto.sign(cachedKeyPair.privateKey, tokenBuffer)];
14968
- case 3:
14969
- signatureBuffer = _b.sent();
14970
- encodedSignature = this.b64Encode.urlEncodeArr(new Uint8Array(signatureBuffer));
14971
- signedJwt = tokenString + "." + encodedSignature;
14972
- if (signJwtMeasurement) {
14973
- signJwtMeasurement.endMeasurement({
14974
- success: true
14975
- });
14976
- }
14977
- return [2 /*return*/, signedJwt];
14978
- }
14979
- });
14980
- });
15686
+ BrowserPerformanceClient.prototype.setPreQueueTime = function (eventName, correlationId) {
15687
+ if (!this.supportsBrowserPerformanceNow()) {
15688
+ this.logger.trace("BrowserPerformanceClient: window performance API not available, unable to set telemetry queue time for " + eventName);
15689
+ return;
15690
+ }
15691
+ if (!correlationId) {
15692
+ this.logger.trace("BrowserPerformanceClient: correlationId for " + eventName + " not provided, unable to set telemetry queue time");
15693
+ return;
15694
+ }
15695
+ var preQueueEvent = this.preQueueTimeByCorrelationId.get(correlationId);
15696
+ /**
15697
+ * Manually complete queue measurement if there is an incomplete pre-queue event.
15698
+ * Incomplete pre-queue events are instrumentation bugs that should be fixed.
15699
+ */
15700
+ if (preQueueEvent) {
15701
+ this.logger.trace("BrowserPerformanceClient: Incomplete pre-queue " + preQueueEvent.name + " found", correlationId);
15702
+ this.addQueueMeasurement(preQueueEvent.name, correlationId, undefined, true);
15703
+ }
15704
+ this.preQueueTimeByCorrelationId.set(eventName, { name: eventName, time: window.performance.now() });
14981
15705
  };
14982
15706
  /**
14983
- * Returns the SHA-256 hash of an input string
14984
- * @param plainText
15707
+ * Calculates and adds queue time measurement for given performance event.
15708
+ *
15709
+ * @param {PerformanceEvents} eventName
15710
+ * @param {?string} correlationId
15711
+ * @param {?number} queueTime
15712
+ * @param {?boolean} manuallyCompleted - indicator for manually completed queue measurements
15713
+ * @returns
14985
15714
  */
14986
- CryptoOps.prototype.hashString = function (plainText) {
14987
- return __awaiter$1(this, void 0, void 0, function () {
14988
- var hashBuffer, hashBytes;
14989
- return __generator$1(this, function (_a) {
14990
- switch (_a.label) {
14991
- case 0: return [4 /*yield*/, this.browserCrypto.sha256Digest(plainText)];
14992
- case 1:
14993
- hashBuffer = _a.sent();
14994
- hashBytes = new Uint8Array(hashBuffer);
14995
- return [2 /*return*/, this.b64Encode.urlEncodeArr(hashBytes)];
14996
- }
14997
- });
14998
- });
15715
+ BrowserPerformanceClient.prototype.addQueueMeasurement = function (eventName, correlationId, queueTime, manuallyCompleted) {
15716
+ if (!this.supportsBrowserPerformanceNow()) {
15717
+ this.logger.trace("BrowserPerformanceClient: window performance API not available, unable to add queue measurement for " + eventName);
15718
+ return;
15719
+ }
15720
+ if (!correlationId) {
15721
+ this.logger.trace("BrowserPerformanceClient: correlationId for " + eventName + " not provided, unable to add queue measurement");
15722
+ return;
15723
+ }
15724
+ var preQueueTime = _super.prototype.getPreQueueTime.call(this, eventName, correlationId);
15725
+ if (!preQueueTime) {
15726
+ return;
15727
+ }
15728
+ var currentTime = window.performance.now();
15729
+ var resQueueTime = queueTime || _super.prototype.calculateQueuedTime.call(this, preQueueTime, currentTime);
15730
+ return _super.prototype.addQueueMeasurement.call(this, eventName, correlationId, resQueueTime, manuallyCompleted);
14999
15731
  };
15000
- CryptoOps.POP_KEY_USAGES = ["sign", "verify"];
15001
- CryptoOps.EXTRACTABLE = true;
15002
- return CryptoOps;
15003
- }());
15732
+ return BrowserPerformanceClient;
15733
+ }(PerformanceClient));
15004
15734
 
15005
15735
  /*
15006
15736
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -15016,13 +15746,16 @@ var internals = /*#__PURE__*/Object.freeze({
15016
15746
  SilentIframeClient: SilentIframeClient,
15017
15747
  SilentCacheClient: SilentCacheClient,
15018
15748
  SilentRefreshClient: SilentRefreshClient,
15749
+ NativeInteractionClient: NativeInteractionClient,
15019
15750
  RedirectHandler: RedirectHandler,
15020
15751
  EventHandler: EventHandler,
15021
15752
  NativeMessageHandler: NativeMessageHandler,
15022
15753
  BrowserConstants: BrowserConstants,
15023
15754
  get TemporaryCacheKeys () { return TemporaryCacheKeys; },
15024
15755
  CryptoOps: CryptoOps,
15025
- NativeAuthError: NativeAuthError
15756
+ NativeAuthError: NativeAuthError,
15757
+ BrowserPerformanceClient: BrowserPerformanceClient,
15758
+ BrowserPerformanceMeasurement: BrowserPerformanceMeasurement
15026
15759
  });
15027
15760
 
15028
15761
  /*
@@ -15285,6 +16018,8 @@ var SilentAuthCodeClient = /** @class */ (function (_super) {
15285
16018
  if (!request.code) {
15286
16019
  throw BrowserAuthError.createAuthCodeRequiredError();
15287
16020
  }
16021
+ // Create silent request
16022
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.StandardInteractionClientInitializeAuthorizationRequest, request.correlationId);
15288
16023
  return [4 /*yield*/, this.initializeAuthorizationRequest(request, exports.InteractionType.Silent)];
15289
16024
  case 1:
15290
16025
  silentRequest = _a.sent();
@@ -15294,12 +16029,14 @@ var SilentAuthCodeClient = /** @class */ (function (_super) {
15294
16029
  case 2:
15295
16030
  _a.trys.push([2, 4, , 5]);
15296
16031
  authCodeRequest = __assign$1(__assign$1({}, silentRequest), { code: request.code });
16032
+ // Initialize the client
16033
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.StandardInteractionClientGetClientConfiguration, request.correlationId);
15297
16034
  return [4 /*yield*/, this.getClientConfiguration(serverTelemetryManager, silentRequest.authority)];
15298
16035
  case 3:
15299
16036
  clientConfig = _a.sent();
15300
16037
  authClient = new HybridSpaAuthorizationCodeClient(clientConfig);
15301
16038
  this.logger.verbose("Auth code client created");
15302
- silentHandler = new SilentHandler(authClient, this.browserStorage, authCodeRequest, this.logger, this.config.system);
16039
+ silentHandler = new SilentHandler(authClient, this.browserStorage, authCodeRequest, this.logger, this.config.system, this.performanceClient);
15303
16040
  // Handle auth code parameters from request
15304
16041
  return [2 /*return*/, silentHandler.handleCodeResponseFromServer({
15305
16042
  code: request.code,
@@ -15330,110 +16067,6 @@ var SilentAuthCodeClient = /** @class */ (function (_super) {
15330
16067
  return SilentAuthCodeClient;
15331
16068
  }(StandardInteractionClient));
15332
16069
 
15333
- /*
15334
- * Copyright (c) Microsoft Corporation. All rights reserved.
15335
- * Licensed under the MIT License.
15336
- */
15337
- var BrowserPerformanceMeasurement = /** @class */ (function () {
15338
- function BrowserPerformanceMeasurement(name, correlationId) {
15339
- this.correlationId = correlationId;
15340
- this.measureName = "msal.measure." + name + "." + this.correlationId;
15341
- this.startMark = "msal.start." + name + "." + this.correlationId;
15342
- this.endMark = "msal.end." + name + "." + this.correlationId;
15343
- }
15344
- BrowserPerformanceMeasurement.supportsBrowserPerformance = function () {
15345
- return typeof window !== "undefined" &&
15346
- typeof window.performance !== "undefined" &&
15347
- typeof window.performance.mark === "function" &&
15348
- typeof window.performance.measure === "function" &&
15349
- typeof window.performance.clearMarks === "function" &&
15350
- typeof window.performance.clearMeasures === "function" &&
15351
- typeof window.performance.getEntriesByName === "function";
15352
- };
15353
- BrowserPerformanceMeasurement.prototype.startMeasurement = function () {
15354
- if (BrowserPerformanceMeasurement.supportsBrowserPerformance()) {
15355
- try {
15356
- window.performance.mark(this.startMark);
15357
- }
15358
- catch (e) {
15359
- // Silently catch
15360
- }
15361
- }
15362
- };
15363
- BrowserPerformanceMeasurement.prototype.endMeasurement = function () {
15364
- if (BrowserPerformanceMeasurement.supportsBrowserPerformance()) {
15365
- try {
15366
- window.performance.mark(this.endMark);
15367
- window.performance.measure(this.measureName, this.startMark, this.endMark);
15368
- }
15369
- catch (e) {
15370
- // Silently catch
15371
- }
15372
- }
15373
- };
15374
- BrowserPerformanceMeasurement.prototype.flushMeasurement = function () {
15375
- if (BrowserPerformanceMeasurement.supportsBrowserPerformance()) {
15376
- try {
15377
- var entriesForMeasurement = window.performance.getEntriesByName(this.measureName, "measure");
15378
- if (entriesForMeasurement.length > 0) {
15379
- var durationMs = entriesForMeasurement[0].duration;
15380
- window.performance.clearMeasures(this.measureName);
15381
- window.performance.clearMarks(this.startMark);
15382
- window.performance.clearMarks(this.endMark);
15383
- return durationMs;
15384
- }
15385
- }
15386
- catch (e) {
15387
- // Silently catch and return null
15388
- }
15389
- }
15390
- return null;
15391
- };
15392
- return BrowserPerformanceMeasurement;
15393
- }());
15394
-
15395
- /*
15396
- * Copyright (c) Microsoft Corporation. All rights reserved.
15397
- * Licensed under the MIT License.
15398
- */
15399
- var BrowserPerformanceClient = /** @class */ (function (_super) {
15400
- __extends$1(BrowserPerformanceClient, _super);
15401
- function BrowserPerformanceClient(clientId, authority, logger, libraryName, libraryVersion, applicationTelemetry, cryptoOptions) {
15402
- var _this = _super.call(this, clientId, authority, logger, libraryName, libraryVersion, applicationTelemetry) || this;
15403
- _this.browserCrypto = new BrowserCrypto(_this.logger, cryptoOptions);
15404
- _this.guidGenerator = new GuidGenerator(_this.browserCrypto);
15405
- return _this;
15406
- }
15407
- BrowserPerformanceClient.prototype.startPerformanceMeasurement = function (measureName, correlationId) {
15408
- return new BrowserPerformanceMeasurement(measureName, correlationId);
15409
- };
15410
- BrowserPerformanceClient.prototype.generateId = function () {
15411
- return this.guidGenerator.generateGuid();
15412
- };
15413
- BrowserPerformanceClient.prototype.getPageVisibility = function () {
15414
- var _a;
15415
- return ((_a = document.visibilityState) === null || _a === void 0 ? void 0 : _a.toString()) || null;
15416
- };
15417
- /**
15418
- * Starts measuring performance for a given operation. Returns a function that should be used to end the measurement.
15419
- * Also captures browser page visibilityState.
15420
- *
15421
- * @param {PerformanceEvents} measureName
15422
- * @param {?string} [correlationId]
15423
- * @returns {((event?: Partial<PerformanceEvent>) => PerformanceEvent| null)}
15424
- */
15425
- BrowserPerformanceClient.prototype.startMeasurement = function (measureName, correlationId) {
15426
- var _this = this;
15427
- // Capture page visibilityState and then invoke start/end measurement
15428
- var startPageVisibility = this.getPageVisibility();
15429
- var inProgressEvent = _super.prototype.startMeasurement.call(this, measureName, correlationId);
15430
- return __assign$1(__assign$1({}, inProgressEvent), { endMeasurement: function (event) {
15431
- return inProgressEvent.endMeasurement(__assign$1({ startPageVisibility: startPageVisibility, endPageVisibility: _this.getPageVisibility() }, event));
15432
- } });
15433
- };
15434
- return BrowserPerformanceClient;
15435
- }(PerformanceClient));
15436
-
15437
16070
  /*
15438
16071
  * Copyright (c) Microsoft Corporation. All rights reserved.
15439
16072
  * Licensed under the MIT License.
@@ -15500,13 +16133,15 @@ var ClientApplication = /** @class */ (function () {
15500
16133
  this.nativeInternalStorage = new BrowserCacheManager(this.config.auth.clientId, nativeCacheOptions, this.browserCrypto, this.logger);
15501
16134
  // Initialize the token cache
15502
16135
  this.tokenCache = new TokenCache(this.config, this.browserStorage, this.logger, this.browserCrypto);
16136
+ // Register listener functions
16137
+ this.trackPageVisibilityWithMeasurement = this.trackPageVisibilityWithMeasurement.bind(this);
15503
16138
  }
15504
16139
  /**
15505
16140
  * Initializer function to perform async startup tasks such as connecting to WAM extension
15506
16141
  */
15507
16142
  ClientApplication.prototype.initialize = function () {
15508
16143
  return __awaiter$1(this, void 0, void 0, function () {
15509
- var _a, e_1;
16144
+ var allowNativeBroker, initMeasurement, _a, e_1;
15510
16145
  return __generator$1(this, function (_b) {
15511
16146
  switch (_b.label) {
15512
16147
  case 0:
@@ -15515,13 +16150,15 @@ var ClientApplication = /** @class */ (function () {
15515
16150
  this.logger.info("initialize has already been called, exiting early.");
15516
16151
  return [2 /*return*/];
15517
16152
  }
16153
+ allowNativeBroker = this.config.system.allowNativeBroker;
16154
+ initMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.InitializeClientApplication);
15518
16155
  this.eventHandler.emitEvent(exports.EventType.INITIALIZE_START);
15519
- if (!this.config.system.allowNativeBroker) return [3 /*break*/, 4];
16156
+ if (!allowNativeBroker) return [3 /*break*/, 4];
15520
16157
  _b.label = 1;
15521
16158
  case 1:
15522
16159
  _b.trys.push([1, 3, , 4]);
15523
16160
  _a = this;
15524
- return [4 /*yield*/, NativeMessageHandler.createProvider(this.logger, this.config.system.nativeBrokerHandshakeTimeout)];
16161
+ return [4 /*yield*/, NativeMessageHandler.createProvider(this.logger, this.config.system.nativeBrokerHandshakeTimeout, this.performanceClient)];
15525
16162
  case 2:
15526
16163
  _a.nativeExtensionProvider = _b.sent();
15527
16164
  return [3 /*break*/, 4];
@@ -15532,6 +16169,7 @@ var ClientApplication = /** @class */ (function () {
15532
16169
  case 4:
15533
16170
  this.initialized = true;
15534
16171
  this.eventHandler.emitEvent(exports.EventType.INITIALIZE_END);
16172
+ initMeasurement.endMeasurement({ allowNativeBroker: allowNativeBroker, success: true });
15535
16173
  return [2 /*return*/];
15536
16174
  }
15537
16175
  });
@@ -15707,7 +16345,6 @@ var ClientApplication = /** @class */ (function () {
15707
16345
  isNativeBroker: true,
15708
16346
  requestId: response.requestId
15709
16347
  });
15710
- atPopupMeasurement.flushMeasurement();
15711
16348
  return response;
15712
16349
  }).catch(function (e) {
15713
16350
  if (e instanceof NativeAuthError && e.isFatal()) {
@@ -15747,7 +16384,6 @@ var ClientApplication = /** @class */ (function () {
15747
16384
  success: true,
15748
16385
  requestId: result.requestId
15749
16386
  });
15750
- atPopupMeasurement.flushMeasurement();
15751
16387
  return result;
15752
16388
  }).catch(function (e) {
15753
16389
  if (loggedInAccounts.length > 0) {
@@ -15761,11 +16397,20 @@ var ClientApplication = /** @class */ (function () {
15761
16397
  subErrorCode: e.subError,
15762
16398
  success: false
15763
16399
  });
15764
- atPopupMeasurement.flushMeasurement();
15765
16400
  // Since this function is syncronous we need to reject
15766
16401
  return Promise.reject(e);
15767
16402
  });
15768
16403
  };
16404
+ ClientApplication.prototype.trackPageVisibilityWithMeasurement = function () {
16405
+ var measurement = this.ssoSilentMeasurement || this.acquireTokenByCodeAsyncMeasurement;
16406
+ if (!measurement) {
16407
+ return;
16408
+ }
16409
+ this.logger.info("Perf: Visibility change detected in ", measurement.event.name);
16410
+ measurement.increment({
16411
+ visibilityChangeCount: 1,
16412
+ });
16413
+ };
15769
16414
  // #endregion
15770
16415
  // #region Silent Flow
15771
16416
  /**
@@ -15784,16 +16429,21 @@ var ClientApplication = /** @class */ (function () {
15784
16429
  * @returns A promise that is fulfilled when this function has completed, or rejected if an error was raised.
15785
16430
  */
15786
16431
  ClientApplication.prototype.ssoSilent = function (request) {
16432
+ var _a;
15787
16433
  return __awaiter$1(this, void 0, void 0, function () {
15788
- var correlationId, validRequest, ssoSilentMeasurement, result, silentIframeClient;
16434
+ var correlationId, validRequest, result, silentIframeClient;
15789
16435
  var _this = this;
15790
- return __generator$1(this, function (_a) {
16436
+ return __generator$1(this, function (_b) {
15791
16437
  correlationId = this.getRequestCorrelationId(request);
15792
16438
  validRequest = __assign$1(__assign$1({}, request), {
15793
16439
  // will be PromptValue.NONE or PromptValue.NO_SESSION
15794
16440
  prompt: request.prompt, correlationId: correlationId });
15795
16441
  this.preflightBrowserEnvironmentCheck(exports.InteractionType.Silent);
15796
- ssoSilentMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.SsoSilent, correlationId);
16442
+ this.ssoSilentMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.SsoSilent, correlationId);
16443
+ (_a = this.ssoSilentMeasurement) === null || _a === void 0 ? void 0 : _a.increment({
16444
+ visibilityChangeCount: 0
16445
+ });
16446
+ document.addEventListener("visibilitychange", this.trackPageVisibilityWithMeasurement);
15797
16447
  this.logger.verbose("ssoSilent called", correlationId);
15798
16448
  this.eventHandler.emitEvent(exports.EventType.SSO_SILENT_START, exports.InteractionType.Silent, validRequest);
15799
16449
  if (this.canUseNative(validRequest)) {
@@ -15812,27 +16462,29 @@ var ClientApplication = /** @class */ (function () {
15812
16462
  result = silentIframeClient.acquireToken(validRequest);
15813
16463
  }
15814
16464
  return [2 /*return*/, result.then(function (response) {
16465
+ var _a, _b;
15815
16466
  _this.eventHandler.emitEvent(exports.EventType.SSO_SILENT_SUCCESS, exports.InteractionType.Silent, response);
15816
- ssoSilentMeasurement.addStaticFields({
16467
+ (_a = _this.ssoSilentMeasurement) === null || _a === void 0 ? void 0 : _a.addStaticFields({
15817
16468
  accessTokenSize: response.accessToken.length,
15818
16469
  idTokenSize: response.idToken.length
15819
16470
  });
15820
- ssoSilentMeasurement.endMeasurement({
16471
+ (_b = _this.ssoSilentMeasurement) === null || _b === void 0 ? void 0 : _b.endMeasurement({
15821
16472
  success: true,
15822
16473
  isNativeBroker: response.fromNativeBroker,
15823
16474
  requestId: response.requestId
15824
16475
  });
15825
- ssoSilentMeasurement.flushMeasurement();
15826
16476
  return response;
15827
16477
  }).catch(function (e) {
16478
+ var _a;
15828
16479
  _this.eventHandler.emitEvent(exports.EventType.SSO_SILENT_FAILURE, exports.InteractionType.Silent, null, e);
15829
- ssoSilentMeasurement.endMeasurement({
16480
+ (_a = _this.ssoSilentMeasurement) === null || _a === void 0 ? void 0 : _a.endMeasurement({
15830
16481
  errorCode: e.errorCode,
15831
16482
  subErrorCode: e.subError,
15832
16483
  success: false
15833
16484
  });
15834
- ssoSilentMeasurement.flushMeasurement();
15835
16485
  throw e;
16486
+ }).finally(function () {
16487
+ document.removeEventListener("visibilitychange", _this.trackPageVisibilityWithMeasurement);
15836
16488
  })];
15837
16489
  });
15838
16490
  });
@@ -15858,7 +16510,11 @@ var ClientApplication = /** @class */ (function () {
15858
16510
  this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_BY_CODE_START, exports.InteractionType.Silent, request);
15859
16511
  atbcMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.AcquireTokenByCode, request.correlationId);
15860
16512
  try {
15861
- if (request.code) {
16513
+ if (request.code && request.nativeAccountId) {
16514
+ // Throw error in case server returns both spa_code and spa_accountid in exchange for auth code.
16515
+ throw BrowserAuthError.createSpaCodeAndNativeAccountIdPresentError();
16516
+ }
16517
+ else if (request.code) {
15862
16518
  hybridAuthCode_1 = request.code;
15863
16519
  response = this.hybridAuthCodeResponses.get(hybridAuthCode_1);
15864
16520
  if (!response) {
@@ -15876,7 +16532,6 @@ var ClientApplication = /** @class */ (function () {
15876
16532
  isNativeBroker: result.fromNativeBroker,
15877
16533
  requestId: result.requestId
15878
16534
  });
15879
- atbcMeasurement.flushMeasurement();
15880
16535
  return result;
15881
16536
  })
15882
16537
  .catch(function (error) {
@@ -15887,16 +16542,12 @@ var ClientApplication = /** @class */ (function () {
15887
16542
  subErrorCode: error.subError,
15888
16543
  success: false
15889
16544
  });
15890
- atbcMeasurement.flushMeasurement();
15891
16545
  throw error;
15892
16546
  });
15893
16547
  this.hybridAuthCodeResponses.set(hybridAuthCode_1, response);
15894
16548
  }
15895
16549
  else {
15896
16550
  this.logger.verbose("Existing acquireTokenByCode request found", request.correlationId);
15897
- atbcMeasurement.endMeasurement({
15898
- success: true
15899
- });
15900
16551
  atbcMeasurement.discardMeasurement();
15901
16552
  }
15902
16553
  return [2 /*return*/, response];
@@ -15938,16 +16589,42 @@ var ClientApplication = /** @class */ (function () {
15938
16589
  * @returns Result of the operation to redeem the authorization code
15939
16590
  */
15940
16591
  ClientApplication.prototype.acquireTokenByCodeAsync = function (request) {
16592
+ var _a;
15941
16593
  return __awaiter$1(this, void 0, void 0, function () {
15942
16594
  var silentAuthCodeClient, silentTokenResult;
15943
- return __generator$1(this, function (_a) {
15944
- switch (_a.label) {
16595
+ var _this = this;
16596
+ return __generator$1(this, function (_b) {
16597
+ switch (_b.label) {
15945
16598
  case 0:
15946
16599
  this.logger.trace("acquireTokenByCodeAsync called", request.correlationId);
16600
+ this.acquireTokenByCodeAsyncMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.AcquireTokenByCodeAsync, request.correlationId);
16601
+ (_a = this.acquireTokenByCodeAsyncMeasurement) === null || _a === void 0 ? void 0 : _a.increment({
16602
+ visibilityChangeCount: 0
16603
+ });
16604
+ document.addEventListener("visibilitychange", this.trackPageVisibilityWithMeasurement);
15947
16605
  silentAuthCodeClient = this.createSilentAuthCodeClient(request.correlationId);
15948
- return [4 /*yield*/, silentAuthCodeClient.acquireToken(request)];
16606
+ return [4 /*yield*/, silentAuthCodeClient.acquireToken(request).then(function (response) {
16607
+ var _a;
16608
+ (_a = _this.acquireTokenByCodeAsyncMeasurement) === null || _a === void 0 ? void 0 : _a.endMeasurement({
16609
+ success: true,
16610
+ fromCache: response.fromCache,
16611
+ isNativeBroker: response.fromNativeBroker,
16612
+ requestId: response.requestId
16613
+ });
16614
+ return response;
16615
+ }).catch(function (tokenRenewalError) {
16616
+ var _a;
16617
+ (_a = _this.acquireTokenByCodeAsyncMeasurement) === null || _a === void 0 ? void 0 : _a.endMeasurement({
16618
+ errorCode: tokenRenewalError.errorCode,
16619
+ subErrorCode: tokenRenewalError.subError,
16620
+ success: false
16621
+ });
16622
+ throw tokenRenewalError;
16623
+ }).finally(function () {
16624
+ document.removeEventListener("visibilitychange", _this.trackPageVisibilityWithMeasurement);
16625
+ })];
15949
16626
  case 1:
15950
- silentTokenResult = _a.sent();
16627
+ silentTokenResult = _b.sent();
15951
16628
  return [2 /*return*/, silentTokenResult];
15952
16629
  }
15953
16630
  });
@@ -15963,6 +16640,7 @@ var ClientApplication = /** @class */ (function () {
15963
16640
  ClientApplication.prototype.acquireTokenFromCache = function (silentCacheClient, commonRequest, silentRequest) {
15964
16641
  return __awaiter$1(this, void 0, void 0, function () {
15965
16642
  return __generator$1(this, function (_a) {
16643
+ this.performanceClient.addQueueMeasurement(exports.PerformanceEvents.AcquireTokenFromCache, commonRequest.correlationId);
15966
16644
  switch (silentRequest.cacheLookupPolicy) {
15967
16645
  case exports.CacheLookupPolicy.Default:
15968
16646
  case exports.CacheLookupPolicy.AccessToken:
@@ -15985,12 +16663,14 @@ var ClientApplication = /** @class */ (function () {
15985
16663
  return __awaiter$1(this, void 0, void 0, function () {
15986
16664
  var silentRefreshClient;
15987
16665
  return __generator$1(this, function (_a) {
16666
+ this.performanceClient.addQueueMeasurement(exports.PerformanceEvents.AcquireTokenByRefreshToken, commonRequest.correlationId);
15988
16667
  switch (silentRequest.cacheLookupPolicy) {
15989
16668
  case exports.CacheLookupPolicy.Default:
15990
16669
  case exports.CacheLookupPolicy.AccessTokenAndRefreshToken:
15991
16670
  case exports.CacheLookupPolicy.RefreshToken:
15992
16671
  case exports.CacheLookupPolicy.RefreshTokenAndNetwork:
15993
16672
  silentRefreshClient = this.createSilentRefreshClient(commonRequest.correlationId);
16673
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.SilentRefreshClientAcquireToken, commonRequest.correlationId);
15994
16674
  return [2 /*return*/, silentRefreshClient.acquireToken(commonRequest)];
15995
16675
  default:
15996
16676
  throw ClientAuthError.createRefreshRequiredError();
@@ -16008,7 +16688,9 @@ var ClientApplication = /** @class */ (function () {
16008
16688
  return __awaiter$1(this, void 0, void 0, function () {
16009
16689
  var silentIframeClient;
16010
16690
  return __generator$1(this, function (_a) {
16691
+ this.performanceClient.addQueueMeasurement(exports.PerformanceEvents.AcquireTokenBySilentIframe, request.correlationId);
16011
16692
  silentIframeClient = this.createSilentIframeClient(request.correlationId);
16693
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.SilentIframeClientAcquireToken, request.correlationId);
16012
16694
  return [2 /*return*/, silentIframeClient.acquireToken(request)];
16013
16695
  });
16014
16696
  });
@@ -16426,7 +17108,10 @@ var PublicClientApplication = /** @class */ (function (_super) {
16426
17108
  */
16427
17109
  function PublicClientApplication(configuration) {
16428
17110
  var _this = _super.call(this, configuration) || this;
17111
+ _this.astsAsyncMeasurement = undefined;
16429
17112
  _this.activeSilentTokenRequests = new Map();
17113
+ // Register listener functions
17114
+ _this.trackPageVisibility = _this.trackPageVisibility.bind(_this);
16430
17115
  return _this;
16431
17116
  }
16432
17117
  /**
@@ -16498,6 +17183,7 @@ var PublicClientApplication = /** @class */ (function (_super) {
16498
17183
  cachedResponse = this.activeSilentTokenRequests.get(silentRequestKey);
16499
17184
  if (typeof cachedResponse === "undefined") {
16500
17185
  this.logger.verbose("acquireTokenSilent called for the first time, storing active request", correlationId);
17186
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.AcquireTokenSilentAsync, correlationId);
16501
17187
  response = this.acquireTokenSilentAsync(__assign$1(__assign$1({}, request), { correlationId: correlationId }), account)
16502
17188
  .then(function (result) {
16503
17189
  _this.activeSilentTokenRequests.delete(silentRequestKey);
@@ -16512,7 +17198,6 @@ var PublicClientApplication = /** @class */ (function (_super) {
16512
17198
  cacheLookupPolicy: request.cacheLookupPolicy,
16513
17199
  requestId: result.requestId,
16514
17200
  });
16515
- atsMeasurement.flushMeasurement();
16516
17201
  return result;
16517
17202
  })
16518
17203
  .catch(function (error) {
@@ -16522,7 +17207,6 @@ var PublicClientApplication = /** @class */ (function (_super) {
16522
17207
  subErrorCode: error.subError,
16523
17208
  success: false
16524
17209
  });
16525
- atsMeasurement.flushMeasurement();
16526
17210
  throw error;
16527
17211
  });
16528
17212
  this.activeSilentTokenRequests.set(silentRequestKey, response);
@@ -16530,9 +17214,6 @@ var PublicClientApplication = /** @class */ (function (_super) {
16530
17214
  }
16531
17215
  else {
16532
17216
  this.logger.verbose("acquireTokenSilent has been called previously, returning the result from the first call", correlationId);
16533
- atsMeasurement.endMeasurement({
16534
- success: true
16535
- });
16536
17217
  // Discard measurements for memoized calls, as they are usually only a couple of ms and will artificially deflate metrics
16537
17218
  atsMeasurement.discardMeasurement();
16538
17219
  return [2 /*return*/, cachedResponse];
@@ -16540,6 +17221,15 @@ var PublicClientApplication = /** @class */ (function (_super) {
16540
17221
  });
16541
17222
  });
16542
17223
  };
17224
+ PublicClientApplication.prototype.trackPageVisibility = function () {
17225
+ if (!this.astsAsyncMeasurement) {
17226
+ return;
17227
+ }
17228
+ this.logger.info("Perf: Visibility change detected");
17229
+ this.astsAsyncMeasurement.increment({
17230
+ visibilityChangeCount: 1,
17231
+ });
17232
+ };
16543
17233
  /**
16544
17234
  * Silently acquire an access token for a given set of scopes. Will use cached token if available, otherwise will attempt to acquire a new token from the network via refresh token.
16545
17235
  * @param {@link (SilentRequest:type)}
@@ -16547,14 +17237,20 @@ var PublicClientApplication = /** @class */ (function (_super) {
16547
17237
  * @returns {Promise.<AuthenticationResult>} - a promise that is fulfilled when this function has completed, or rejected if an error was raised. Returns the {@link AuthResponse}
16548
17238
  */
16549
17239
  PublicClientApplication.prototype.acquireTokenSilentAsync = function (request, account) {
17240
+ var _a;
16550
17241
  return __awaiter$1(this, void 0, void 0, function () {
16551
- var atsAsyncMeasurement, result, silentRequest, silentCacheClient, silentRequest_1, requestWithCLP_1;
17242
+ var result, silentRequest, silentCacheClient, silentRequest_1, requestWithCLP_1;
16552
17243
  var _this = this;
16553
- return __generator$1(this, function (_a) {
16554
- switch (_a.label) {
17244
+ return __generator$1(this, function (_b) {
17245
+ switch (_b.label) {
16555
17246
  case 0:
17247
+ this.performanceClient.addQueueMeasurement(exports.PerformanceEvents.AcquireTokenSilentAsync, request.correlationId);
16556
17248
  this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_START, exports.InteractionType.Silent, request);
16557
- atsAsyncMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.AcquireTokenSilentAsync, request.correlationId);
17249
+ this.astsAsyncMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.AcquireTokenSilentAsync, request.correlationId);
17250
+ (_a = this.astsAsyncMeasurement) === null || _a === void 0 ? void 0 : _a.increment({
17251
+ visibilityChangeCount: 0
17252
+ });
17253
+ document.addEventListener("visibilitychange", this.trackPageVisibility);
16558
17254
  if (!(NativeMessageHandler.isNativeAvailable(this.config, this.logger, this.nativeExtensionProvider, request.authenticationScheme) && account.nativeAccountId)) return [3 /*break*/, 1];
16559
17255
  this.logger.verbose("acquireTokenSilent - attempting to acquire token from native platform");
16560
17256
  silentRequest = __assign$1(__assign$1({}, request), { account: account });
@@ -16564,7 +17260,7 @@ var PublicClientApplication = /** @class */ (function (_super) {
16564
17260
  // If native token acquisition fails for availability reasons fallback to web flow
16565
17261
  if (e instanceof NativeAuthError && e.isFatal()) {
16566
17262
  this.logger.verbose("acquireTokenSilent - native platform unavailable, falling back to web flow");
16567
- this.nativeExtensionProvider = undefined; // Prevent future requests from continuing to attempt
17263
+ this.nativeExtensionProvider = undefined; // Prevent future requests from continuing to attempt
16568
17264
  silentIframeClient = this.createSilentIframeClient(request.correlationId);
16569
17265
  return [2 /*return*/, silentIframeClient.acquireToken(request)];
16570
17266
  }
@@ -16575,12 +17271,14 @@ var PublicClientApplication = /** @class */ (function (_super) {
16575
17271
  case 1:
16576
17272
  this.logger.verbose("acquireTokenSilent - attempting to acquire token from web flow");
16577
17273
  silentCacheClient = this.createSilentCacheClient(request.correlationId);
17274
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.InitializeSilentRequest, request.correlationId);
16578
17275
  return [4 /*yield*/, silentCacheClient.initializeSilentRequest(request, account)];
16579
17276
  case 2:
16580
- silentRequest_1 = _a.sent();
17277
+ silentRequest_1 = _b.sent();
16581
17278
  requestWithCLP_1 = __assign$1(__assign$1({}, request), {
16582
17279
  // set the request's CacheLookupPolicy to Default if it was not optionally passed in
16583
17280
  cacheLookupPolicy: request.cacheLookupPolicy || exports.CacheLookupPolicy.Default });
17281
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.AcquireTokenFromCache, silentRequest_1.correlationId);
16584
17282
  result = this.acquireTokenFromCache(silentCacheClient, silentRequest_1, requestWithCLP_1).catch(function (cacheError) {
16585
17283
  if (requestWithCLP_1.cacheLookupPolicy === exports.CacheLookupPolicy.AccessToken) {
16586
17284
  throw cacheError;
@@ -16588,6 +17286,7 @@ var PublicClientApplication = /** @class */ (function (_super) {
16588
17286
  // block the reload if it occurred inside a hidden iframe
16589
17287
  BrowserUtils.blockReloadInHiddenIframes();
16590
17288
  _this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_NETWORK_START, exports.InteractionType.Silent, silentRequest_1);
17289
+ _this.performanceClient.setPreQueueTime(exports.PerformanceEvents.AcquireTokenByRefreshToken, silentRequest_1.correlationId);
16591
17290
  return _this.acquireTokenByRefreshToken(silentRequest_1, requestWithCLP_1).catch(function (refreshTokenError) {
16592
17291
  var isServerError = refreshTokenError instanceof ServerError;
16593
17292
  var isInteractionRequiredError = refreshTokenError instanceof InteractionRequiredAuthError;
@@ -16601,13 +17300,15 @@ var PublicClientApplication = /** @class */ (function (_super) {
16601
17300
  throw refreshTokenError;
16602
17301
  }
16603
17302
  _this.logger.verbose("Refresh token expired/invalid or CacheLookupPolicy is set to Skip, attempting acquire token by iframe.", request.correlationId);
17303
+ _this.performanceClient.setPreQueueTime(exports.PerformanceEvents.AcquireTokenBySilentIframe, silentRequest_1.correlationId);
16604
17304
  return _this.acquireTokenBySilentIframe(silentRequest_1);
16605
17305
  });
16606
17306
  });
16607
- _a.label = 3;
17307
+ _b.label = 3;
16608
17308
  case 3: return [2 /*return*/, result.then(function (response) {
17309
+ var _a;
16609
17310
  _this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_SUCCESS, exports.InteractionType.Silent, response);
16610
- atsAsyncMeasurement.endMeasurement({
17311
+ (_a = _this.astsAsyncMeasurement) === null || _a === void 0 ? void 0 : _a.endMeasurement({
16611
17312
  success: true,
16612
17313
  fromCache: response.fromCache,
16613
17314
  isNativeBroker: response.fromNativeBroker,
@@ -16615,13 +17316,16 @@ var PublicClientApplication = /** @class */ (function (_super) {
16615
17316
  });
16616
17317
  return response;
16617
17318
  }).catch(function (tokenRenewalError) {
17319
+ var _a;
16618
17320
  _this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_FAILURE, exports.InteractionType.Silent, null, tokenRenewalError);
16619
- atsAsyncMeasurement.endMeasurement({
17321
+ (_a = _this.astsAsyncMeasurement) === null || _a === void 0 ? void 0 : _a.endMeasurement({
16620
17322
  errorCode: tokenRenewalError.errorCode,
16621
17323
  subErrorCode: tokenRenewalError.subError,
16622
17324
  success: false
16623
17325
  });
16624
17326
  throw tokenRenewalError;
17327
+ }).finally(function () {
17328
+ document.removeEventListener("visibilitychange", _this.trackPageVisibility);
16625
17329
  })];
16626
17330
  }
16627
17331
  });