@azure/msal-browser 2.32.1 → 2.33.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/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 +65 -13
  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 +39 -11
  11. package/dist/app/PublicClientApplication.js.map +1 -1
  12. package/dist/broker/nativeBroker/NativeMessageHandler.js +1 -1
  13. package/dist/cache/AsyncMemoryStorage.js +1 -1
  14. package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
  15. package/dist/cache/BrowserCacheManager.js +8 -7
  16. package/dist/cache/BrowserCacheManager.js.map +1 -1
  17. package/dist/cache/BrowserStorage.js +1 -1
  18. package/dist/cache/CryptoKeyStore.js +1 -1
  19. package/dist/cache/DatabaseStorage.js +1 -1
  20. package/dist/cache/MemoryStorage.js +1 -1
  21. package/dist/cache/TokenCache.js +1 -1
  22. package/dist/config/Configuration.d.ts.map +1 -1
  23. package/dist/config/Configuration.js +6 -3
  24. package/dist/config/Configuration.js.map +1 -1
  25. package/dist/crypto/BrowserCrypto.js +1 -1
  26. package/dist/crypto/CryptoOps.js +1 -1
  27. package/dist/crypto/GuidGenerator.js +1 -1
  28. package/dist/crypto/ModernBrowserCrypto.js +1 -1
  29. package/dist/crypto/MsBrowserCrypto.js +1 -1
  30. package/dist/crypto/MsrBrowserCrypto.js +1 -1
  31. package/dist/crypto/PkceGenerator.js +1 -1
  32. package/dist/crypto/SignedHttpRequest.js +1 -1
  33. package/dist/encode/Base64Decode.js +1 -1
  34. package/dist/encode/Base64Encode.js +1 -1
  35. package/dist/error/BrowserAuthError.js +1 -1
  36. package/dist/error/BrowserConfigurationAuthError.js +1 -1
  37. package/dist/error/NativeAuthError.js +1 -1
  38. package/dist/event/EventHandler.js +1 -1
  39. package/dist/event/EventMessage.js +1 -1
  40. package/dist/event/EventType.js +1 -1
  41. package/dist/index.cjs.js +1519 -886
  42. package/dist/index.cjs.js.map +1 -1
  43. package/dist/index.js +1 -1
  44. package/dist/interaction_client/BaseInteractionClient.d.ts.map +1 -1
  45. package/dist/interaction_client/BaseInteractionClient.js +3 -2
  46. package/dist/interaction_client/BaseInteractionClient.js.map +1 -1
  47. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.js +1 -1
  48. package/dist/interaction_client/NativeInteractionClient.js +1 -1
  49. package/dist/interaction_client/NativeInteractionClient.js.map +1 -1
  50. package/dist/interaction_client/PopupClient.d.ts.map +1 -1
  51. package/dist/interaction_client/PopupClient.js +9 -2
  52. package/dist/interaction_client/PopupClient.js.map +1 -1
  53. package/dist/interaction_client/RedirectClient.d.ts.map +1 -1
  54. package/dist/interaction_client/RedirectClient.js +13 -5
  55. package/dist/interaction_client/RedirectClient.js.map +1 -1
  56. package/dist/interaction_client/SilentAuthCodeClient.d.ts.map +1 -1
  57. package/dist/interaction_client/SilentAuthCodeClient.js +7 -3
  58. package/dist/interaction_client/SilentAuthCodeClient.js.map +1 -1
  59. package/dist/interaction_client/SilentCacheClient.d.ts.map +1 -1
  60. package/dist/interaction_client/SilentCacheClient.js +7 -2
  61. package/dist/interaction_client/SilentCacheClient.js.map +1 -1
  62. package/dist/interaction_client/SilentIframeClient.d.ts.map +1 -1
  63. package/dist/interaction_client/SilentIframeClient.js +21 -4
  64. package/dist/interaction_client/SilentIframeClient.js.map +1 -1
  65. package/dist/interaction_client/SilentRefreshClient.d.ts.map +1 -1
  66. package/dist/interaction_client/SilentRefreshClient.js +9 -3
  67. package/dist/interaction_client/SilentRefreshClient.js.map +1 -1
  68. package/dist/interaction_client/StandardInteractionClient.d.ts.map +1 -1
  69. package/dist/interaction_client/StandardInteractionClient.js +27 -14
  70. package/dist/interaction_client/StandardInteractionClient.js.map +1 -1
  71. package/dist/interaction_handler/InteractionHandler.d.ts +3 -2
  72. package/dist/interaction_handler/InteractionHandler.d.ts.map +1 -1
  73. package/dist/interaction_handler/InteractionHandler.js +12 -4
  74. package/dist/interaction_handler/InteractionHandler.js.map +1 -1
  75. package/dist/interaction_handler/RedirectHandler.d.ts +2 -2
  76. package/dist/interaction_handler/RedirectHandler.d.ts.map +1 -1
  77. package/dist/interaction_handler/RedirectHandler.js +3 -3
  78. package/dist/interaction_handler/RedirectHandler.js.map +1 -1
  79. package/dist/interaction_handler/SilentHandler.d.ts +2 -2
  80. package/dist/interaction_handler/SilentHandler.d.ts.map +1 -1
  81. package/dist/interaction_handler/SilentHandler.js +13 -15
  82. package/dist/interaction_handler/SilentHandler.js.map +1 -1
  83. package/dist/internals.d.ts +4 -0
  84. package/dist/internals.d.ts.map +1 -1
  85. package/dist/internals.js +5 -1
  86. package/dist/internals.js.map +1 -1
  87. package/dist/navigation/NavigationClient.js +1 -1
  88. package/dist/network/FetchClient.js +1 -1
  89. package/dist/network/XhrClient.js +1 -1
  90. package/dist/packageMetadata.d.ts +1 -1
  91. package/dist/packageMetadata.js +2 -2
  92. package/dist/packageMetadata.js.map +1 -1
  93. package/dist/request/EndSessionPopupRequest.d.ts +1 -1
  94. package/dist/request/EndSessionPopupRequest.d.ts.map +1 -1
  95. package/dist/request/EndSessionRequest.d.ts +1 -1
  96. package/dist/request/EndSessionRequest.d.ts.map +1 -1
  97. package/dist/telemetry/BrowserPerformanceClient.d.ts +17 -0
  98. package/dist/telemetry/BrowserPerformanceClient.d.ts.map +1 -1
  99. package/dist/telemetry/BrowserPerformanceClient.js +57 -1
  100. package/dist/telemetry/BrowserPerformanceClient.js.map +1 -1
  101. package/dist/telemetry/BrowserPerformanceMeasurement.js +1 -1
  102. package/dist/utils/BrowserConstants.js +1 -1
  103. package/dist/utils/BrowserProtocolUtils.js +1 -1
  104. package/dist/utils/BrowserStringUtils.js +1 -1
  105. package/dist/utils/BrowserUtils.js +1 -1
  106. package/dist/utils/MathUtils.js +1 -1
  107. package/lib/msal-browser.js +1519 -886
  108. package/lib/msal-browser.js.map +1 -1
  109. package/lib/msal-browser.min.js +43 -44
  110. package/package.json +2 -2
@@ -1,4 +1,4 @@
1
- /*! @azure/msal-browser v2.32.1 2022-12-07 */
1
+ /*! @azure/msal-browser v2.33.0 2023-02-06 */
2
2
  'use strict';
3
3
  (function (global, factory) {
4
4
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
@@ -119,7 +119,7 @@
119
119
  return ar;
120
120
  }
121
121
 
122
- /*! @azure/msal-common v9.0.1 2022-12-07 */
122
+ /*! @azure/msal-common v10.0.0 2023-02-06 */
123
123
  /*! *****************************************************************************
124
124
  Copyright (c) Microsoft Corporation.
125
125
 
@@ -206,7 +206,7 @@
206
206
  return r;
207
207
  }
208
208
 
209
- /*! @azure/msal-common v9.0.1 2022-12-07 */
209
+ /*! @azure/msal-common v10.0.0 2023-02-06 */
210
210
 
211
211
  /*
212
212
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -282,6 +282,7 @@
282
282
  HeaderNames["WWWAuthenticate"] = "WWW-Authenticate";
283
283
  HeaderNames["AuthenticationInfo"] = "Authentication-Info";
284
284
  HeaderNames["X_MS_REQUEST_ID"] = "x-ms-request-id";
285
+ HeaderNames["X_MS_HTTP_VERSION"] = "x-ms-httpver";
285
286
  })(HeaderNames || (HeaderNames = {}));
286
287
  /**
287
288
  * Persistent cache keys MSAL which stay while user is logged in.
@@ -589,7 +590,7 @@
589
590
  JsonTypes["Jwk"] = "JWK";
590
591
  })(JsonTypes || (JsonTypes = {}));
591
592
 
592
- /*! @azure/msal-common v9.0.1 2022-12-07 */
593
+ /*! @azure/msal-common v10.0.0 2023-02-06 */
593
594
 
594
595
  /*
595
596
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -645,7 +646,7 @@
645
646
  return AuthError;
646
647
  }(Error));
647
648
 
648
- /*! @azure/msal-common v9.0.1 2022-12-07 */
649
+ /*! @azure/msal-common v10.0.0 2023-02-06 */
649
650
 
650
651
  /*
651
652
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -720,7 +721,7 @@
720
721
  }
721
722
  };
722
723
 
723
- /*! @azure/msal-common v9.0.1 2022-12-07 */
724
+ /*! @azure/msal-common v10.0.0 2023-02-06 */
724
725
 
725
726
  /*
726
727
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1215,7 +1216,7 @@
1215
1216
  return ClientAuthError;
1216
1217
  }(AuthError));
1217
1218
 
1218
- /*! @azure/msal-common v9.0.1 2022-12-07 */
1219
+ /*! @azure/msal-common v10.0.0 2023-02-06 */
1219
1220
 
1220
1221
  /*
1221
1222
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1340,7 +1341,7 @@
1340
1341
  return StringUtils;
1341
1342
  }());
1342
1343
 
1343
- /*! @azure/msal-common v9.0.1 2022-12-07 */
1344
+ /*! @azure/msal-common v10.0.0 2023-02-06 */
1344
1345
 
1345
1346
  /*
1346
1347
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1367,13 +1368,23 @@
1367
1368
  var defaultLoggerCallback = function () {
1368
1369
  return;
1369
1370
  };
1370
- this.localCallback = loggerOptions.loggerCallback || defaultLoggerCallback;
1371
- this.piiLoggingEnabled = loggerOptions.piiLoggingEnabled || false;
1372
- this.level = typeof (loggerOptions.logLevel) === "number" ? loggerOptions.logLevel : exports.LogLevel.Info;
1373
- this.correlationId = loggerOptions.correlationId || Constants.EMPTY_STRING;
1371
+ var setLoggerOptions = loggerOptions || Logger.createDefaultLoggerOptions();
1372
+ this.localCallback = setLoggerOptions.loggerCallback || defaultLoggerCallback;
1373
+ this.piiLoggingEnabled = setLoggerOptions.piiLoggingEnabled || false;
1374
+ this.level = typeof (setLoggerOptions.logLevel) === "number" ? setLoggerOptions.logLevel : exports.LogLevel.Info;
1375
+ this.correlationId = setLoggerOptions.correlationId || Constants.EMPTY_STRING;
1374
1376
  this.packageName = packageName || Constants.EMPTY_STRING;
1375
1377
  this.packageVersion = packageVersion || Constants.EMPTY_STRING;
1376
1378
  }
1379
+ Logger.createDefaultLoggerOptions = function () {
1380
+ return {
1381
+ loggerCallback: function () {
1382
+ // allow users to not set loggerCallback
1383
+ },
1384
+ piiLoggingEnabled: false,
1385
+ logLevel: exports.LogLevel.Info
1386
+ };
1387
+ };
1377
1388
  /**
1378
1389
  * Create new Logger with existing configurations.
1379
1390
  */
@@ -1520,12 +1531,12 @@
1520
1531
  return Logger;
1521
1532
  }());
1522
1533
 
1523
- /*! @azure/msal-common v9.0.1 2022-12-07 */
1534
+ /*! @azure/msal-common v10.0.0 2023-02-06 */
1524
1535
  /* eslint-disable header/header */
1525
1536
  var name$1 = "@azure/msal-common";
1526
- var version$1 = "9.0.1";
1537
+ var version$1 = "10.0.0";
1527
1538
 
1528
- /*! @azure/msal-common v9.0.1 2022-12-07 */
1539
+ /*! @azure/msal-common v10.0.0 2023-02-06 */
1529
1540
  /*
1530
1541
  * Copyright (c) Microsoft Corporation. All rights reserved.
1531
1542
  * Licensed under the MIT License.
@@ -1546,7 +1557,7 @@
1546
1557
  AzureCloudInstance["AzureUsGovernment"] = "https://login.microsoftonline.us";
1547
1558
  })(exports.AzureCloudInstance || (exports.AzureCloudInstance = {}));
1548
1559
 
1549
- /*! @azure/msal-common v9.0.1 2022-12-07 */
1560
+ /*! @azure/msal-common v10.0.0 2023-02-06 */
1550
1561
 
1551
1562
  /*
1552
1563
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1577,6 +1588,25 @@
1577
1588
  var CredentialEntity = /** @class */ (function () {
1578
1589
  function CredentialEntity() {
1579
1590
  }
1591
+ /**
1592
+ * Initializes a map with credential {CredentialType} regular expressions.
1593
+ */
1594
+ CredentialEntity._initRegex = function () {
1595
+ var separator = Separators.CACHE_KEY_SEPARATOR;
1596
+ CredentialEntity.credentialRegexMap = new Map();
1597
+ for (var _i = 0, _a = Object.keys(CredentialType); _i < _a.length; _i++) {
1598
+ var credKey = _a[_i];
1599
+ var credVal = CredentialType[credKey].toLowerCase();
1600
+ try {
1601
+ // Verify credential type is preceded by a valid host name (environment) using lookbehind
1602
+ CredentialEntity.credentialRegexMap.set(CredentialType[credKey], new RegExp("(?<=" + separator + CredentialEntity.credentialDomainRegex + ")" + separator + credVal + separator));
1603
+ }
1604
+ catch (err) {
1605
+ // Lookbehind is not supported (Safari or older versions of IE) - removing it
1606
+ CredentialEntity.credentialRegexMap.set(CredentialType[credKey], new RegExp("" + separator + CredentialEntity.credentialDomainRegex + separator + credVal + separator));
1607
+ }
1608
+ }
1609
+ };
1580
1610
  /**
1581
1611
  * Generate Account Id key component as per the schema: <home_account_id>-<environment>
1582
1612
  */
@@ -1623,19 +1653,12 @@
1623
1653
  * @param key
1624
1654
  */
1625
1655
  CredentialEntity.getCredentialType = function (key) {
1626
- // First keyword search will match all "AccessToken" and "AccessToken_With_AuthScheme" credentials
1627
- if (key.indexOf(CredentialType.ACCESS_TOKEN.toLowerCase()) !== -1) {
1628
- // Perform second search to differentiate between "AccessToken" and "AccessToken_With_AuthScheme" credential types
1629
- if (key.indexOf(CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME.toLowerCase()) !== -1) {
1630
- return CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME;
1656
+ var _a;
1657
+ for (var _i = 0, _b = Object.keys(CredentialType); _i < _b.length; _i++) {
1658
+ var credKey = _b[_i];
1659
+ if ((_a = this.credentialRegexMap.get(CredentialType[credKey])) === null || _a === void 0 ? void 0 : _a.test(key.toLowerCase())) {
1660
+ return CredentialType[credKey];
1631
1661
  }
1632
- return CredentialType.ACCESS_TOKEN;
1633
- }
1634
- else if (key.indexOf(CredentialType.ID_TOKEN.toLowerCase()) !== -1) {
1635
- return CredentialType.ID_TOKEN;
1636
- }
1637
- else if (key.indexOf(CredentialType.REFRESH_TOKEN.toLowerCase()) !== -1) {
1638
- return CredentialType.REFRESH_TOKEN;
1639
1662
  }
1640
1663
  return Constants.NOT_DEFINED;
1641
1664
  };
@@ -1702,10 +1725,13 @@
1702
1725
  */
1703
1726
  return (tokenType && tokenType.toLowerCase() !== exports.AuthenticationScheme.BEARER.toLowerCase()) ? tokenType.toLowerCase() : Constants.EMPTY_STRING;
1704
1727
  };
1728
+ // Match host names like "login.microsoftonline.com", "https://accounts.google.com:4000", https://localhost:5000, etc.
1729
+ CredentialEntity.credentialDomainRegex = "(https?:\\/\\/)?((([\\w-]+\\.)*([\\w-]{1,63})(\\.(\\w{2,63})))|(localhost))(\\:[0-9]{4,5})?";
1705
1730
  return CredentialEntity;
1706
- }());
1731
+ }());
1732
+ CredentialEntity._initRegex();
1707
1733
 
1708
- /*! @azure/msal-common v9.0.1 2022-12-07 */
1734
+ /*! @azure/msal-common v10.0.0 2023-02-06 */
1709
1735
 
1710
1736
  /*
1711
1737
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1960,7 +1986,7 @@
1960
1986
  return ClientConfigurationError;
1961
1987
  }(ClientAuthError));
1962
1988
 
1963
- /*! @azure/msal-common v9.0.1 2022-12-07 */
1989
+ /*! @azure/msal-common v10.0.0 2023-02-06 */
1964
1990
 
1965
1991
  /*
1966
1992
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2144,7 +2170,7 @@
2144
2170
  return ScopeSet;
2145
2171
  }());
2146
2172
 
2147
- /*! @azure/msal-common v9.0.1 2022-12-07 */
2173
+ /*! @azure/msal-common v10.0.0 2023-02-06 */
2148
2174
 
2149
2175
  /*
2150
2176
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2182,7 +2208,7 @@
2182
2208
  };
2183
2209
  }
2184
2210
 
2185
- /*! @azure/msal-common v9.0.1 2022-12-07 */
2211
+ /*! @azure/msal-common v10.0.0 2023-02-06 */
2186
2212
  /*
2187
2213
  * Copyright (c) Microsoft Corporation. All rights reserved.
2188
2214
  * Licensed under the MIT License.
@@ -2197,7 +2223,7 @@
2197
2223
  AuthorityType[AuthorityType["Dsts"] = 2] = "Dsts";
2198
2224
  })(AuthorityType || (AuthorityType = {}));
2199
2225
 
2200
- /*! @azure/msal-common v9.0.1 2022-12-07 */
2226
+ /*! @azure/msal-common v10.0.0 2023-02-06 */
2201
2227
 
2202
2228
  /*
2203
2229
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2436,7 +2462,7 @@
2436
2462
  return AccountEntity;
2437
2463
  }());
2438
2464
 
2439
- /*! @azure/msal-common v9.0.1 2022-12-07 */
2465
+ /*! @azure/msal-common v10.0.0 2023-02-06 */
2440
2466
 
2441
2467
  /*
2442
2468
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2488,7 +2514,7 @@
2488
2514
  return AuthToken;
2489
2515
  }());
2490
2516
 
2491
- /*! @azure/msal-common v9.0.1 2022-12-07 */
2517
+ /*! @azure/msal-common v10.0.0 2023-02-06 */
2492
2518
 
2493
2519
  /*
2494
2520
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3367,7 +3393,7 @@
3367
3393
  return DefaultStorageClass;
3368
3394
  }(CacheManager));
3369
3395
 
3370
- /*! @azure/msal-common v9.0.1 2022-12-07 */
3396
+ /*! @azure/msal-common v10.0.0 2023-02-06 */
3371
3397
 
3372
3398
  /*
3373
3399
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3377,8 +3403,7 @@
3377
3403
  var DEFAULT_TOKEN_RENEWAL_OFFSET_SEC = 300;
3378
3404
  var DEFAULT_SYSTEM_OPTIONS = {
3379
3405
  tokenRenewalOffsetSeconds: DEFAULT_TOKEN_RENEWAL_OFFSET_SEC,
3380
- preventCorsPreflight: false,
3381
- proxyUrl: Constants.EMPTY_STRING
3406
+ preventCorsPreflight: false
3382
3407
  };
3383
3408
  var DEFAULT_LOGGER_IMPLEMENTATION = {
3384
3409
  loggerCallback: function () {
@@ -3461,7 +3486,7 @@
3461
3486
  return __assign({ clientCapabilities: [], azureCloudOptions: DEFAULT_AZURE_CLOUD_OPTIONS, skipAuthorityMetadataCache: false }, authOptions);
3462
3487
  }
3463
3488
 
3464
- /*! @azure/msal-common v9.0.1 2022-12-07 */
3489
+ /*! @azure/msal-common v10.0.0 2023-02-06 */
3465
3490
 
3466
3491
  /*
3467
3492
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3481,7 +3506,7 @@
3481
3506
  return ServerError;
3482
3507
  }(AuthError));
3483
3508
 
3484
- /*! @azure/msal-common v9.0.1 2022-12-07 */
3509
+ /*! @azure/msal-common v10.0.0 2023-02-06 */
3485
3510
 
3486
3511
  /*
3487
3512
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3577,7 +3602,7 @@
3577
3602
  return ThrottlingUtils;
3578
3603
  }());
3579
3604
 
3580
- /*! @azure/msal-common v9.0.1 2022-12-07 */
3605
+ /*! @azure/msal-common v10.0.0 2023-02-06 */
3581
3606
 
3582
3607
  /*
3583
3608
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3626,7 +3651,7 @@
3626
3651
  return NetworkManager;
3627
3652
  }());
3628
3653
 
3629
- /*! @azure/msal-common v9.0.1 2022-12-07 */
3654
+ /*! @azure/msal-common v10.0.0 2023-02-06 */
3630
3655
  /*
3631
3656
  * Copyright (c) Microsoft Corporation. All rights reserved.
3632
3657
  * Licensed under the MIT License.
@@ -3637,98 +3662,7 @@
3637
3662
  CcsCredentialType["UPN"] = "UPN";
3638
3663
  })(CcsCredentialType || (CcsCredentialType = {}));
3639
3664
 
3640
- /*! @azure/msal-common v9.0.1 2022-12-07 */
3641
-
3642
- /*
3643
- * Copyright (c) Microsoft Corporation. All rights reserved.
3644
- * Licensed under the MIT License.
3645
- */
3646
- /**
3647
- * Base application class which will construct requests to send to and handle responses from the Microsoft STS using the authorization code flow.
3648
- */
3649
- var BaseClient = /** @class */ (function () {
3650
- function BaseClient(configuration, performanceClient) {
3651
- // Set the configuration
3652
- this.config = buildClientConfiguration(configuration);
3653
- // Initialize the logger
3654
- this.logger = new Logger(this.config.loggerOptions, name$1, version$1);
3655
- // Initialize crypto
3656
- this.cryptoUtils = this.config.cryptoInterface;
3657
- // Initialize storage interface
3658
- this.cacheManager = this.config.storageInterface;
3659
- // Set the network interface
3660
- this.networkClient = this.config.networkInterface;
3661
- // Set the NetworkManager
3662
- this.networkManager = new NetworkManager(this.networkClient, this.cacheManager);
3663
- // Set TelemetryManager
3664
- this.serverTelemetryManager = this.config.serverTelemetryManager;
3665
- // set Authority
3666
- this.authority = this.config.authOptions.authority;
3667
- // set performance telemetry client
3668
- this.performanceClient = performanceClient;
3669
- }
3670
- /**
3671
- * Creates default headers for requests to token endpoint
3672
- */
3673
- BaseClient.prototype.createTokenRequestHeaders = function (ccsCred) {
3674
- var headers = {};
3675
- headers[HeaderNames.CONTENT_TYPE] = Constants.URL_FORM_CONTENT_TYPE;
3676
- if (!this.config.systemOptions.preventCorsPreflight && ccsCred) {
3677
- switch (ccsCred.type) {
3678
- case CcsCredentialType.HOME_ACCOUNT_ID:
3679
- try {
3680
- var clientInfo = buildClientInfoFromHomeAccountId(ccsCred.credential);
3681
- headers[HeaderNames.CCS_HEADER] = "Oid:" + clientInfo.uid + "@" + clientInfo.utid;
3682
- }
3683
- catch (e) {
3684
- this.logger.verbose("Could not parse home account ID for CCS Header: " + e);
3685
- }
3686
- break;
3687
- case CcsCredentialType.UPN:
3688
- headers[HeaderNames.CCS_HEADER] = "UPN: " + ccsCred.credential;
3689
- break;
3690
- }
3691
- }
3692
- return headers;
3693
- };
3694
- /**
3695
- * Http post to token endpoint
3696
- * @param tokenEndpoint
3697
- * @param queryString
3698
- * @param headers
3699
- * @param thumbprint
3700
- */
3701
- BaseClient.prototype.executePostToTokenEndpoint = function (tokenEndpoint, queryString, headers, thumbprint) {
3702
- return __awaiter(this, void 0, void 0, function () {
3703
- var response;
3704
- return __generator(this, function (_a) {
3705
- switch (_a.label) {
3706
- case 0: return [4 /*yield*/, this.networkManager.sendPostRequest(thumbprint, tokenEndpoint, { body: queryString, headers: headers, proxyUrl: this.config.systemOptions.proxyUrl })];
3707
- case 1:
3708
- response = _a.sent();
3709
- if (this.config.serverTelemetryManager && response.status < 500 && response.status !== 429) {
3710
- // Telemetry data successfully logged by server, clear Telemetry cache
3711
- this.config.serverTelemetryManager.clearTelemetryCache();
3712
- }
3713
- return [2 /*return*/, response];
3714
- }
3715
- });
3716
- });
3717
- };
3718
- /**
3719
- * Updates the authority object of the client. Endpoint discovery must be completed.
3720
- * @param updatedAuthority
3721
- */
3722
- BaseClient.prototype.updateAuthority = function (updatedAuthority) {
3723
- if (!updatedAuthority.discoveryComplete()) {
3724
- throw ClientAuthError.createEndpointDiscoveryIncompleteError("Updated authority has not completed endpoint discovery.");
3725
- }
3726
- this.authority = updatedAuthority;
3727
- };
3728
- return BaseClient;
3729
- }());
3730
-
3731
- /*! @azure/msal-common v9.0.1 2022-12-07 */
3665
+ /*! @azure/msal-common v10.0.0 2023-02-06 */
3732
3666
 
3733
3667
  /*
3734
3668
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3796,7 +3730,7 @@
3796
3730
  }
3797
3731
  };
3798
3732
  /**
3799
- * Removes unnecessary or duplicate query parameters from extraQueryParameters
3733
+ * Removes unnecessary, duplicate, and empty string query parameters from extraQueryParameters
3800
3734
  * @param request
3801
3735
  */
3802
3736
  RequestValidator.sanitizeEQParams = function (eQParams, queryParams) {
@@ -3809,12 +3743,17 @@
3809
3743
  delete eQParams[key];
3810
3744
  }
3811
3745
  });
3812
- return eQParams;
3746
+ // remove empty string parameters
3747
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
3748
+ return Object.fromEntries(Object.entries(eQParams).filter(function (_a) {
3749
+ var value = _a[1];
3750
+ return value !== "";
3751
+ }));
3813
3752
  };
3814
3753
  return RequestValidator;
3815
3754
  }());
3816
3755
 
3817
- /*! @azure/msal-common v9.0.1 2022-12-07 */
3756
+ /*! @azure/msal-common v10.0.0 2023-02-06 */
3818
3757
 
3819
3758
  /*
3820
3759
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4091,13 +4030,13 @@
4091
4030
  };
4092
4031
  /**
4093
4032
  * add extraQueryParams
4094
- * @param eQparams
4033
+ * @param eQParams
4095
4034
  */
4096
- RequestParameterBuilder.prototype.addExtraQueryParameters = function (eQparams) {
4035
+ RequestParameterBuilder.prototype.addExtraQueryParameters = function (eQParams) {
4097
4036
  var _this = this;
4098
- RequestValidator.sanitizeEQParams(eQparams, this.parameters);
4099
- Object.keys(eQparams).forEach(function (key) {
4100
- _this.parameters.set(key, eQparams[key]);
4037
+ var sanitizedEQParams = RequestValidator.sanitizeEQParams(eQParams, this.parameters);
4038
+ Object.keys(sanitizedEQParams).forEach(function (key) {
4039
+ _this.parameters.set(key, eQParams[key]);
4101
4040
  });
4102
4041
  };
4103
4042
  RequestParameterBuilder.prototype.addClientCapabilitiesToClaims = function (claims, clientCapabilities) {
@@ -4192,7 +4131,109 @@
4192
4131
  return RequestParameterBuilder;
4193
4132
  }());
4194
4133
 
4195
- /*! @azure/msal-common v9.0.1 2022-12-07 */
4134
+ /*! @azure/msal-common v10.0.0 2023-02-06 */
4135
+
4136
+ /*
4137
+ * Copyright (c) Microsoft Corporation. All rights reserved.
4138
+ * Licensed under the MIT License.
4139
+ */
4140
+ /**
4141
+ * Base application class which will construct requests to send to and handle responses from the Microsoft STS using the authorization code flow.
4142
+ */
4143
+ var BaseClient = /** @class */ (function () {
4144
+ function BaseClient(configuration, performanceClient) {
4145
+ // Set the configuration
4146
+ this.config = buildClientConfiguration(configuration);
4147
+ // Initialize the logger
4148
+ this.logger = new Logger(this.config.loggerOptions, name$1, version$1);
4149
+ // Initialize crypto
4150
+ this.cryptoUtils = this.config.cryptoInterface;
4151
+ // Initialize storage interface
4152
+ this.cacheManager = this.config.storageInterface;
4153
+ // Set the network interface
4154
+ this.networkClient = this.config.networkInterface;
4155
+ // Set the NetworkManager
4156
+ this.networkManager = new NetworkManager(this.networkClient, this.cacheManager);
4157
+ // Set TelemetryManager
4158
+ this.serverTelemetryManager = this.config.serverTelemetryManager;
4159
+ // set Authority
4160
+ this.authority = this.config.authOptions.authority;
4161
+ // set performance telemetry client
4162
+ this.performanceClient = performanceClient;
4163
+ }
4164
+ /**
4165
+ * Creates default headers for requests to token endpoint
4166
+ */
4167
+ BaseClient.prototype.createTokenRequestHeaders = function (ccsCred) {
4168
+ var headers = {};
4169
+ headers[HeaderNames.CONTENT_TYPE] = Constants.URL_FORM_CONTENT_TYPE;
4170
+ if (!this.config.systemOptions.preventCorsPreflight && ccsCred) {
4171
+ switch (ccsCred.type) {
4172
+ case CcsCredentialType.HOME_ACCOUNT_ID:
4173
+ try {
4174
+ var clientInfo = buildClientInfoFromHomeAccountId(ccsCred.credential);
4175
+ headers[HeaderNames.CCS_HEADER] = "Oid:" + clientInfo.uid + "@" + clientInfo.utid;
4176
+ }
4177
+ catch (e) {
4178
+ this.logger.verbose("Could not parse home account ID for CCS Header: " + e);
4179
+ }
4180
+ break;
4181
+ case CcsCredentialType.UPN:
4182
+ headers[HeaderNames.CCS_HEADER] = "UPN: " + ccsCred.credential;
4183
+ break;
4184
+ }
4185
+ }
4186
+ return headers;
4187
+ };
4188
+ /**
4189
+ * Http post to token endpoint
4190
+ * @param tokenEndpoint
4191
+ * @param queryString
4192
+ * @param headers
4193
+ * @param thumbprint
4194
+ */
4195
+ BaseClient.prototype.executePostToTokenEndpoint = function (tokenEndpoint, queryString, headers, thumbprint) {
4196
+ return __awaiter(this, void 0, void 0, function () {
4197
+ var response;
4198
+ return __generator(this, function (_a) {
4199
+ switch (_a.label) {
4200
+ case 0: return [4 /*yield*/, this.networkManager.sendPostRequest(thumbprint, tokenEndpoint, { body: queryString, headers: headers })];
4201
+ case 1:
4202
+ response = _a.sent();
4203
+ if (this.config.serverTelemetryManager && response.status < 500 && response.status !== 429) {
4204
+ // Telemetry data successfully logged by server, clear Telemetry cache
4205
+ this.config.serverTelemetryManager.clearTelemetryCache();
4206
+ }
4207
+ return [2 /*return*/, response];
4208
+ }
4209
+ });
4210
+ });
4211
+ };
4212
+ /**
4213
+ * Updates the authority object of the client. Endpoint discovery must be completed.
4214
+ * @param updatedAuthority
4215
+ */
4216
+ BaseClient.prototype.updateAuthority = function (updatedAuthority) {
4217
+ if (!updatedAuthority.discoveryComplete()) {
4218
+ throw ClientAuthError.createEndpointDiscoveryIncompleteError("Updated authority has not completed endpoint discovery.");
4219
+ }
4220
+ this.authority = updatedAuthority;
4221
+ };
4222
+ /**
4223
+ * Creates query string for the /token request
4224
+ * @param request
4225
+ */
4226
+ BaseClient.prototype.createTokenQueryParameters = function (request) {
4227
+ var parameterBuilder = new RequestParameterBuilder();
4228
+ if (request.tokenQueryParameters) {
4229
+ parameterBuilder.addExtraQueryParameters(request.tokenQueryParameters);
4230
+ }
4231
+ return parameterBuilder.createQueryString();
4232
+ };
4233
+ return BaseClient;
4234
+ }());
4235
+
4236
+ /*! @azure/msal-common v10.0.0 2023-02-06 */
4196
4237
 
4197
4238
  /*
4198
4239
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4256,7 +4297,7 @@
4256
4297
  return IdTokenEntity;
4257
4298
  }(CredentialEntity));
4258
4299
 
4259
- /*! @azure/msal-common v9.0.1 2022-12-07 */
4300
+ /*! @azure/msal-common v10.0.0 2023-02-06 */
4260
4301
  /*
4261
4302
  * Copyright (c) Microsoft Corporation. All rights reserved.
4262
4303
  * Licensed under the MIT License.
@@ -4306,7 +4347,7 @@
4306
4347
  return TimeUtils;
4307
4348
  }());
4308
4349
 
4309
- /*! @azure/msal-common v9.0.1 2022-12-07 */
4350
+ /*! @azure/msal-common v10.0.0 2023-02-06 */
4310
4351
 
4311
4352
  /*
4312
4353
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4420,7 +4461,7 @@
4420
4461
  return AccessTokenEntity;
4421
4462
  }(CredentialEntity));
4422
4463
 
4423
- /*! @azure/msal-common v9.0.1 2022-12-07 */
4464
+ /*! @azure/msal-common v10.0.0 2023-02-06 */
4424
4465
 
4425
4466
  /*
4426
4467
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4487,7 +4528,7 @@
4487
4528
  return RefreshTokenEntity;
4488
4529
  }(CredentialEntity));
4489
4530
 
4490
- /*! @azure/msal-common v9.0.1 2022-12-07 */
4531
+ /*! @azure/msal-common v10.0.0 2023-02-06 */
4491
4532
 
4492
4533
  /*
4493
4534
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4526,10 +4567,14 @@
4526
4567
  */
4527
4568
  var InteractionRequiredAuthError = /** @class */ (function (_super) {
4528
4569
  __extends(InteractionRequiredAuthError, _super);
4529
- function InteractionRequiredAuthError(errorCode, errorMessage, subError) {
4570
+ function InteractionRequiredAuthError(errorCode, errorMessage, subError, timestamp, traceId, correlationId, claims) {
4530
4571
  var _this = _super.call(this, errorCode, errorMessage, subError) || this;
4531
- _this.name = "InteractionRequiredAuthError";
4532
4572
  Object.setPrototypeOf(_this, InteractionRequiredAuthError.prototype);
4573
+ _this.timestamp = timestamp || Constants.EMPTY_STRING;
4574
+ _this.traceId = traceId || Constants.EMPTY_STRING;
4575
+ _this.correlationId = correlationId || Constants.EMPTY_STRING;
4576
+ _this.claims = claims || Constants.EMPTY_STRING;
4577
+ _this.name = "InteractionRequiredAuthError";
4533
4578
  return _this;
4534
4579
  }
4535
4580
  /**
@@ -4562,7 +4607,7 @@
4562
4607
  return InteractionRequiredAuthError;
4563
4608
  }(AuthError));
4564
4609
 
4565
- /*! @azure/msal-common v9.0.1 2022-12-07 */
4610
+ /*! @azure/msal-common v10.0.0 2023-02-06 */
4566
4611
  /*
4567
4612
  * Copyright (c) Microsoft Corporation. All rights reserved.
4568
4613
  * Licensed under the MIT License.
@@ -4578,7 +4623,7 @@
4578
4623
  return CacheRecord;
4579
4624
  }());
4580
4625
 
4581
- /*! @azure/msal-common v9.0.1 2022-12-07 */
4626
+ /*! @azure/msal-common v10.0.0 2023-02-06 */
4582
4627
 
4583
4628
  /*
4584
4629
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4649,7 +4694,7 @@
4649
4694
  return ProtocolUtils;
4650
4695
  }());
4651
4696
 
4652
- /*! @azure/msal-common v9.0.1 2022-12-07 */
4697
+ /*! @azure/msal-common v10.0.0 2023-02-06 */
4653
4698
 
4654
4699
  /*
4655
4700
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4883,60 +4928,295 @@
4883
4928
  return UrlString;
4884
4929
  }());
4885
4930
 
4886
- /*! @azure/msal-common v9.0.1 2022-12-07 */
4887
-
4931
+ /*! @azure/msal-common v10.0.0 2023-02-06 */
4888
4932
  /*
4889
4933
  * Copyright (c) Microsoft Corporation. All rights reserved.
4890
4934
  * Licensed under the MIT License.
4891
4935
  */
4892
- var KeyLocation;
4893
- (function (KeyLocation) {
4894
- KeyLocation["SW"] = "sw";
4895
- KeyLocation["UHW"] = "uhw";
4896
- })(KeyLocation || (KeyLocation = {}));
4897
- var PopTokenGenerator = /** @class */ (function () {
4898
- function PopTokenGenerator(cryptoUtils) {
4899
- this.cryptoUtils = cryptoUtils;
4900
- }
4936
+ /**
4937
+ * Enumeration of operations that are instrumented by have their performance measured by the PerformanceClient.
4938
+ *
4939
+ * @export
4940
+ * @enum {number}
4941
+ */
4942
+ exports.PerformanceEvents = void 0;
4943
+ (function (PerformanceEvents) {
4901
4944
  /**
4902
- * Generates the req_cnf validated at the RP in the POP protocol for SHR parameters
4903
- * and returns an object containing the keyid, the full req_cnf string and the req_cnf string hash
4904
- * @param request
4905
- * @returns
4945
+ * acquireTokenByCode API (msal-browser and msal-node).
4946
+ * Used to acquire tokens by trading an authorization code against the token endpoint.
4906
4947
  */
4907
- PopTokenGenerator.prototype.generateCnf = function (request) {
4908
- return __awaiter(this, void 0, void 0, function () {
4909
- var reqCnf, reqCnfString, _a;
4910
- return __generator(this, function (_b) {
4911
- switch (_b.label) {
4912
- case 0: return [4 /*yield*/, this.generateKid(request)];
4913
- case 1:
4914
- reqCnf = _b.sent();
4915
- reqCnfString = this.cryptoUtils.base64Encode(JSON.stringify(reqCnf));
4916
- _a = {
4917
- kid: reqCnf.kid,
4918
- reqCnfString: reqCnfString
4919
- };
4920
- return [4 /*yield*/, this.cryptoUtils.hashString(reqCnfString)];
4921
- case 2: return [2 /*return*/, (_a.reqCnfHash = _b.sent(),
4922
- _a)];
4923
- }
4924
- });
4925
- });
4926
- };
4948
+ PerformanceEvents["AcquireTokenByCode"] = "acquireTokenByCode";
4927
4949
  /**
4928
- * Generates key_id for a SHR token request
4929
- * @param request
4930
- * @returns
4950
+ * acquireTokenByRefreshToken API (msal-browser and msal-node).
4951
+ * Used to renew an access token using a refresh token against the token endpoint.
4931
4952
  */
4932
- PopTokenGenerator.prototype.generateKid = function (request) {
4933
- return __awaiter(this, void 0, void 0, function () {
4934
- var kidThumbprint;
4935
- return __generator(this, function (_a) {
4936
- switch (_a.label) {
4937
- case 0: return [4 /*yield*/, this.cryptoUtils.getPublicKeyThumbprint(request)];
4953
+ PerformanceEvents["AcquireTokenByRefreshToken"] = "acquireTokenByRefreshToken";
4954
+ /**
4955
+ * acquireTokenSilent API (msal-browser and msal-node).
4956
+ * Used to silently acquire a new access token (from the cache or the network).
4957
+ */
4958
+ PerformanceEvents["AcquireTokenSilent"] = "acquireTokenSilent";
4959
+ /**
4960
+ * acquireTokenSilentAsync (msal-browser).
4961
+ * Internal API for acquireTokenSilent.
4962
+ */
4963
+ PerformanceEvents["AcquireTokenSilentAsync"] = "acquireTokenSilentAsync";
4964
+ /**
4965
+ * acquireTokenPopup (msal-browser).
4966
+ * Used to acquire a new access token interactively through pop ups
4967
+ */
4968
+ PerformanceEvents["AcquireTokenPopup"] = "acquireTokenPopup";
4969
+ /**
4970
+ * getPublicKeyThumbprint API in CryptoOpts class (msal-browser).
4971
+ * Used to generate a public/private keypair and generate a public key thumbprint for pop requests.
4972
+ */
4973
+ PerformanceEvents["CryptoOptsGetPublicKeyThumbprint"] = "cryptoOptsGetPublicKeyThumbprint";
4974
+ /**
4975
+ * signJwt API in CryptoOpts class (msal-browser).
4976
+ * Used to signed a pop token.
4977
+ */
4978
+ PerformanceEvents["CryptoOptsSignJwt"] = "cryptoOptsSignJwt";
4979
+ /**
4980
+ * acquireToken API in the SilentCacheClient class (msal-browser).
4981
+ * Used to read access tokens from the cache.
4982
+ */
4983
+ PerformanceEvents["SilentCacheClientAcquireToken"] = "silentCacheClientAcquireToken";
4984
+ /**
4985
+ * acquireToken API in the SilentIframeClient class (msal-browser).
4986
+ * Used to acquire a new set of tokens from the authorize endpoint in a hidden iframe.
4987
+ */
4988
+ PerformanceEvents["SilentIframeClientAcquireToken"] = "silentIframeClientAcquireToken";
4989
+ /**
4990
+ * acquireToken API in SilentRereshClient (msal-browser).
4991
+ * Used to acquire a new set of tokens from the token endpoint using a refresh token.
4992
+ */
4993
+ PerformanceEvents["SilentRefreshClientAcquireToken"] = "silentRefreshClientAcquireToken";
4994
+ /**
4995
+ * ssoSilent API (msal-browser).
4996
+ * Used to silently acquire an authorization code and set of tokens using a hidden iframe.
4997
+ */
4998
+ PerformanceEvents["SsoSilent"] = "ssoSilent";
4999
+ /**
5000
+ * getDiscoveredAuthority API in StandardInteractionClient class (msal-browser).
5001
+ * Used to load authority metadata for a request.
5002
+ */
5003
+ PerformanceEvents["StandardInteractionClientGetDiscoveredAuthority"] = "standardInteractionClientGetDiscoveredAuthority";
5004
+ /**
5005
+ * acquireToken APIs in msal-browser.
5006
+ * Used to make an /authorize endpoint call with native brokering enabled.
5007
+ */
5008
+ PerformanceEvents["FetchAccountIdWithNativeBroker"] = "fetchAccountIdWithNativeBroker";
5009
+ /**
5010
+ * acquireToken API in NativeInteractionClient class (msal-browser).
5011
+ * Used to acquire a token from Native component when native brokering is enabled.
5012
+ */
5013
+ PerformanceEvents["NativeInteractionClientAcquireToken"] = "nativeInteractionClientAcquireToken";
5014
+ /**
5015
+ * Time spent creating default headers for requests to token endpoint
5016
+ */
5017
+ PerformanceEvents["BaseClientCreateTokenRequestHeaders"] = "baseClientCreateTokenRequestHeaders";
5018
+ /**
5019
+ * Used to measure the time taken for completing embedded-broker handshake (PW-Broker).
5020
+ */
5021
+ PerformanceEvents["BrokerHandhshake"] = "brokerHandshake";
5022
+ /**
5023
+ * acquireTokenByRefreshToken API in BrokerClientApplication (PW-Broker) .
5024
+ */
5025
+ PerformanceEvents["AcquireTokenByRefreshTokenInBroker"] = "acquireTokenByRefreshTokenInBroker";
5026
+ /**
5027
+ * Time taken for token acquisition by broker
5028
+ */
5029
+ PerformanceEvents["AcquireTokenByBroker"] = "acquireTokenByBroker";
5030
+ /**
5031
+ * Time spent on the network for refresh token acquisition
5032
+ */
5033
+ PerformanceEvents["RefreshTokenClientExecuteTokenRequest"] = "refreshTokenClientExecuteTokenRequest";
5034
+ /**
5035
+ * Time taken for acquiring refresh token , records RT size
5036
+ */
5037
+ PerformanceEvents["RefreshTokenClientAcquireToken"] = "refreshTokenClientAcquireToken";
5038
+ /**
5039
+ * Time taken for acquiring cached refresh token
5040
+ */
5041
+ PerformanceEvents["RefreshTokenClientAcquireTokenWithCachedRefreshToken"] = "refreshTokenClientAcquireTokenWithCachedRefreshToken";
5042
+ /**
5043
+ * acquireTokenByRefreshToken API in RefreshTokenClient (msal-common).
5044
+ */
5045
+ PerformanceEvents["RefreshTokenClientAcquireTokenByRefreshToken"] = "refreshTokenClientAcquireTokenByRefreshToken";
5046
+ /**
5047
+ * Helper function to create token request body in RefreshTokenClient (msal-common).
5048
+ */
5049
+ PerformanceEvents["RefreshTokenClientCreateTokenRequestBody"] = "refreshTokenClientCreateTokenRequestBody";
5050
+ /**
5051
+ * acquireTokenFromCache (msal-browser).
5052
+ * Internal API for acquiring token from cache
5053
+ */
5054
+ PerformanceEvents["AcquireTokenFromCache"] = "acquireTokenFromCache";
5055
+ /**
5056
+ * acquireTokenBySilentIframe (msal-browser).
5057
+ * Internal API for acquiring token by silent Iframe
5058
+ */
5059
+ PerformanceEvents["AcquireTokenBySilentIframe"] = "acquireTokenBySilentIframe";
5060
+ /**
5061
+ * Internal API for initializing base request in BaseInteractionClient (msal-browser)
5062
+ */
5063
+ PerformanceEvents["InitializeBaseRequest"] = "initializeBaseRequest";
5064
+ /**
5065
+ * Internal API for initializing silent request in SilentCacheClient (msal-browser)
5066
+ */
5067
+ PerformanceEvents["InitializeSilentRequest"] = "initializeSilentRequest";
5068
+ /**
5069
+ * Helper function in SilentIframeClient class (msal-browser).
5070
+ */
5071
+ PerformanceEvents["SilentIframeClientTokenHelper"] = "silentIframeClientTokenHelper";
5072
+ /**
5073
+ * SilentHandler
5074
+ */
5075
+ PerformanceEvents["SilentHandlerInitiateAuthRequest"] = "silentHandlerInitiateAuthRequest";
5076
+ PerformanceEvents["SilentHandlerMonitorIframeForHash"] = "silentHandlerMonitorIframeForHash";
5077
+ PerformanceEvents["SilentHandlerLoadFrame"] = "silentHandlerLoadFrame";
5078
+ /**
5079
+ * Helper functions in StandardInteractionClient class (msal-browser)
5080
+ */
5081
+ PerformanceEvents["StandardInteractionClientCreateAuthCodeClient"] = "standardInteractionClientCreateAuthCodeClient";
5082
+ PerformanceEvents["StandardInteractionClientGetClientConfiguration"] = "standardInteractionClientGetClientConfiguration";
5083
+ PerformanceEvents["StandardInteractionClientInitializeAuthorizationRequest"] = "standardInteractionClientInitializeAuthorizationRequest";
5084
+ PerformanceEvents["StandardInteractionClientInitializeAuthorizationCodeRequest"] = "standardInteractionClientInitializeAuthorizationCodeRequest";
5085
+ /**
5086
+ * getAuthCodeUrl API (msal-browser and msal-node).
5087
+ */
5088
+ PerformanceEvents["GetAuthCodeUrl"] = "getAuthCodeUrl";
5089
+ /**
5090
+ * Functions from InteractionHandler (msal-browser)
5091
+ */
5092
+ PerformanceEvents["HandleCodeResponseFromServer"] = "handleCodeResponseFromServer";
5093
+ PerformanceEvents["HandleCodeResponseFromHash"] = "handleCodeResponseFromHash";
5094
+ PerformanceEvents["UpdateTokenEndpointAuthority"] = "updateTokenEndpointAuthority";
5095
+ /**
5096
+ * APIs in Authorization Code Client (msal-common)
5097
+ */
5098
+ PerformanceEvents["AuthClientAcquireToken"] = "authClientAcquireToken";
5099
+ PerformanceEvents["AuthClientExecuteTokenRequest"] = "authClientExecuteTokenRequest";
5100
+ PerformanceEvents["AuthClientCreateTokenRequestBody"] = "authClientCreateTokenRequestBody";
5101
+ PerformanceEvents["AuthClientCreateQueryString"] = "authClientCreateQueryString";
5102
+ /**
5103
+ * Generate functions in PopTokenGenerator (msal-common)
5104
+ */
5105
+ PerformanceEvents["PopTokenGenerateCnf"] = "popTokenGenerateCnf";
5106
+ PerformanceEvents["PopTokenGenerateKid"] = "popTokenGenerateKid";
5107
+ /**
5108
+ * handleServerTokenResponse API in ResponseHandler (msal-common)
5109
+ */
5110
+ PerformanceEvents["HandleServerTokenResponse"] = "handleServerTokenResponse";
5111
+ /**
5112
+ * Authority functions
5113
+ */
5114
+ PerformanceEvents["AuthorityFactoryCreateDiscoveredInstance"] = "authorityFactoryCreateDiscoveredInstance";
5115
+ PerformanceEvents["AuthorityResolveEndpointsAsync"] = "authorityResolveEndpointsAsync";
5116
+ PerformanceEvents["AuthorityGetCloudDiscoveryMetadataFromNetwork"] = "authorityGetCloudDiscoveryMetadataFromNetwork";
5117
+ PerformanceEvents["AuthorityUpdateCloudDiscoveryMetadata"] = "authorityUpdateCloudDiscoveryMetadata";
5118
+ PerformanceEvents["AuthorityGetEndpointMetadataFromNetwork"] = "authorityGetEndpointMetadataFromNetwork";
5119
+ PerformanceEvents["AuthorityUpdateEndpointMetadata"] = "authorityUpdateEndpointMetadata";
5120
+ PerformanceEvents["AuthorityUpdateMetadataWithRegionalInformation"] = "authorityUpdateMetadataWithRegionalInformation";
5121
+ /**
5122
+ * Region Discovery functions
5123
+ */
5124
+ PerformanceEvents["RegionDiscoveryDetectRegion"] = "regionDiscoveryDetectRegion";
5125
+ PerformanceEvents["RegionDiscoveryGetRegionFromIMDS"] = "regionDiscoveryGetRegionFromIMDS";
5126
+ PerformanceEvents["RegionDiscoveryGetCurrentVersion"] = "regionDiscoveryGetCurrentVersion";
5127
+ PerformanceEvents["AcquireTokenByCodeAsync"] = "acquireTokenByCodeAsync";
5128
+ PerformanceEvents["GetEndpointMetadataFromNetwork"] = "getEndpointMetadataFromNetwork";
5129
+ PerformanceEvents["GetCloudDiscoveryMetadataFromNetworkMeasurement"] = "getCloudDiscoveryMetadataFromNetworkMeasurement";
5130
+ PerformanceEvents["HandleRedirectPromiseMeasurement"] = "handleRedirectPromiseMeasurement";
5131
+ PerformanceEvents["UpdateCloudDiscoveryMetadataMeasurement"] = "updateCloudDiscoveryMetadataMeasurement";
5132
+ PerformanceEvents["UsernamePasswordClientAcquireToken"] = "usernamePasswordClientAcquireToken";
5133
+ })(exports.PerformanceEvents || (exports.PerformanceEvents = {}));
5134
+ /**
5135
+ * State of the performance event.
5136
+ *
5137
+ * @export
5138
+ * @enum {number}
5139
+ */
5140
+ var PerformanceEventStatus;
5141
+ (function (PerformanceEventStatus) {
5142
+ PerformanceEventStatus[PerformanceEventStatus["NotStarted"] = 0] = "NotStarted";
5143
+ PerformanceEventStatus[PerformanceEventStatus["InProgress"] = 1] = "InProgress";
5144
+ PerformanceEventStatus[PerformanceEventStatus["Completed"] = 2] = "Completed";
5145
+ })(PerformanceEventStatus || (PerformanceEventStatus = {}));
5146
+ var IntFields = new Set([
5147
+ "accessTokenSize",
5148
+ "durationMs",
5149
+ "idTokenSize",
5150
+ "matsSilentStatus",
5151
+ "matsHttpStatus",
5152
+ "refreshTokenSize",
5153
+ "queuedTimeMs",
5154
+ "startTimeMs",
5155
+ "status",
5156
+ ]);
5157
+
5158
+ /*! @azure/msal-common v10.0.0 2023-02-06 */
5159
+
5160
+ /*
5161
+ * Copyright (c) Microsoft Corporation. All rights reserved.
5162
+ * Licensed under the MIT License.
5163
+ */
5164
+ var KeyLocation;
5165
+ (function (KeyLocation) {
5166
+ KeyLocation["SW"] = "sw";
5167
+ KeyLocation["UHW"] = "uhw";
5168
+ })(KeyLocation || (KeyLocation = {}));
5169
+ var PopTokenGenerator = /** @class */ (function () {
5170
+ function PopTokenGenerator(cryptoUtils, performanceClient) {
5171
+ this.cryptoUtils = cryptoUtils;
5172
+ this.performanceClient = performanceClient;
5173
+ }
5174
+ /**
5175
+ * Generates the req_cnf validated at the RP in the POP protocol for SHR parameters
5176
+ * and returns an object containing the keyid, the full req_cnf string and the req_cnf string hash
5177
+ * @param request
5178
+ * @returns
5179
+ */
5180
+ PopTokenGenerator.prototype.generateCnf = function (request) {
5181
+ var _a, _b;
5182
+ return __awaiter(this, void 0, void 0, function () {
5183
+ var reqCnf, reqCnfString, _c;
5184
+ return __generator(this, function (_d) {
5185
+ switch (_d.label) {
5186
+ case 0:
5187
+ (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.PopTokenGenerateCnf, request.correlationId);
5188
+ (_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.setPreQueueTime(exports.PerformanceEvents.PopTokenGenerateKid, request.correlationId);
5189
+ return [4 /*yield*/, this.generateKid(request)];
4938
5190
  case 1:
4939
- kidThumbprint = _a.sent();
5191
+ reqCnf = _d.sent();
5192
+ reqCnfString = this.cryptoUtils.base64Encode(JSON.stringify(reqCnf));
5193
+ _c = {
5194
+ kid: reqCnf.kid,
5195
+ reqCnfString: reqCnfString
5196
+ };
5197
+ return [4 /*yield*/, this.cryptoUtils.hashString(reqCnfString)];
5198
+ case 2: return [2 /*return*/, (_c.reqCnfHash = _d.sent(),
5199
+ _c)];
5200
+ }
5201
+ });
5202
+ });
5203
+ };
5204
+ /**
5205
+ * Generates key_id for a SHR token request
5206
+ * @param request
5207
+ * @returns
5208
+ */
5209
+ PopTokenGenerator.prototype.generateKid = function (request) {
5210
+ var _a;
5211
+ return __awaiter(this, void 0, void 0, function () {
5212
+ var kidThumbprint;
5213
+ return __generator(this, function (_b) {
5214
+ switch (_b.label) {
5215
+ case 0:
5216
+ (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.PopTokenGenerateKid, request.correlationId);
5217
+ return [4 /*yield*/, this.cryptoUtils.getPublicKeyThumbprint(request)];
5218
+ case 1:
5219
+ kidThumbprint = _b.sent();
4940
5220
  return [2 /*return*/, {
4941
5221
  kid: kidThumbprint,
4942
5222
  xms_ksl: KeyLocation.SW
@@ -4984,7 +5264,7 @@
4984
5264
  return PopTokenGenerator;
4985
5265
  }());
4986
5266
 
4987
- /*! @azure/msal-common v9.0.1 2022-12-07 */
5267
+ /*! @azure/msal-common v10.0.0 2023-02-06 */
4988
5268
 
4989
5269
  /*
4990
5270
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5054,7 +5334,7 @@
5054
5334
  return AppMetadataEntity;
5055
5335
  }());
5056
5336
 
5057
- /*! @azure/msal-common v9.0.1 2022-12-07 */
5337
+ /*! @azure/msal-common v10.0.0 2023-02-06 */
5058
5338
  /*
5059
5339
  * Copyright (c) Microsoft Corporation. All rights reserved.
5060
5340
  * Licensed under the MIT License.
@@ -5090,7 +5370,7 @@
5090
5370
  return TokenCacheContext;
5091
5371
  }());
5092
5372
 
5093
- /*! @azure/msal-common v9.0.1 2022-12-07 */
5373
+ /*! @azure/msal-common v10.0.0 2023-02-06 */
5094
5374
 
5095
5375
  /*
5096
5376
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5100,13 +5380,14 @@
5100
5380
  * Class that handles response parsing.
5101
5381
  */
5102
5382
  var ResponseHandler = /** @class */ (function () {
5103
- function ResponseHandler(clientId, cacheStorage, cryptoObj, logger, serializableCache, persistencePlugin) {
5383
+ function ResponseHandler(clientId, cacheStorage, cryptoObj, logger, serializableCache, persistencePlugin, performanceClient) {
5104
5384
  this.clientId = clientId;
5105
5385
  this.cacheStorage = cacheStorage;
5106
5386
  this.cryptoObj = cryptoObj;
5107
5387
  this.logger = logger;
5108
5388
  this.serializableCache = serializableCache;
5109
5389
  this.persistencePlugin = persistencePlugin;
5390
+ this.performanceClient = performanceClient;
5110
5391
  }
5111
5392
  /**
5112
5393
  * Function which validates server authorization code response.
@@ -5124,7 +5405,7 @@
5124
5405
  // Check for error
5125
5406
  if (serverResponseHash.error || serverResponseHash.error_description || serverResponseHash.suberror) {
5126
5407
  if (InteractionRequiredAuthError.isInteractionRequiredError(serverResponseHash.error, serverResponseHash.error_description, serverResponseHash.suberror)) {
5127
- throw new InteractionRequiredAuthError(serverResponseHash.error || Constants.EMPTY_STRING, serverResponseHash.error_description, serverResponseHash.suberror);
5408
+ 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);
5128
5409
  }
5129
5410
  throw new ServerError(serverResponseHash.error || Constants.EMPTY_STRING, serverResponseHash.error_description, serverResponseHash.suberror);
5130
5411
  }
@@ -5140,7 +5421,7 @@
5140
5421
  // Check for error
5141
5422
  if (serverResponse.error || serverResponse.error_description || serverResponse.suberror) {
5142
5423
  if (InteractionRequiredAuthError.isInteractionRequiredError(serverResponse.error, serverResponse.error_description, serverResponse.suberror)) {
5143
- throw new InteractionRequiredAuthError(serverResponse.error, serverResponse.error_description, serverResponse.suberror);
5424
+ 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);
5144
5425
  }
5145
5426
  var errString = serverResponse.error_codes + " - [" + serverResponse.timestamp + "]: " + serverResponse.error_description + " - Correlation ID: " + serverResponse.correlation_id + " - Trace ID: " + serverResponse.trace_id;
5146
5427
  throw new ServerError(serverResponse.error, errString, serverResponse.suberror);
@@ -5152,11 +5433,13 @@
5152
5433
  * @param authority
5153
5434
  */
5154
5435
  ResponseHandler.prototype.handleServerTokenResponse = function (serverTokenResponse, authority, reqTimestamp, request, authCodePayload, userAssertionHash, handlingRefreshTokenResponse, forceCacheRefreshTokenResponse, serverRequestId) {
5436
+ var _a;
5155
5437
  return __awaiter(this, void 0, void 0, function () {
5156
5438
  var idTokenObj, authTime, requestStateObj, cacheRecord, cacheContext, key, account;
5157
- return __generator(this, function (_a) {
5158
- switch (_a.label) {
5439
+ return __generator(this, function (_b) {
5440
+ switch (_b.label) {
5159
5441
  case 0:
5442
+ (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.HandleServerTokenResponse, serverTokenResponse.correlation_id);
5160
5443
  if (serverTokenResponse.id_token) {
5161
5444
  idTokenObj = new AuthToken(serverTokenResponse.id_token || Constants.EMPTY_STRING, this.cryptoObj);
5162
5445
  // token nonce check (TODO: Add a warning if no nonce is given?)
@@ -5182,16 +5465,16 @@
5182
5465
  // Add keyId from request to serverTokenResponse if defined
5183
5466
  serverTokenResponse.key_id = serverTokenResponse.key_id || request.sshKid || undefined;
5184
5467
  cacheRecord = this.generateCacheRecord(serverTokenResponse, authority, reqTimestamp, request, idTokenObj, userAssertionHash, authCodePayload);
5185
- _a.label = 1;
5468
+ _b.label = 1;
5186
5469
  case 1:
5187
- _a.trys.push([1, , 5, 8]);
5470
+ _b.trys.push([1, , 5, 8]);
5188
5471
  if (!(this.persistencePlugin && this.serializableCache)) return [3 /*break*/, 3];
5189
5472
  this.logger.verbose("Persistence enabled, calling beforeCacheAccess");
5190
5473
  cacheContext = new TokenCacheContext(this.serializableCache, true);
5191
5474
  return [4 /*yield*/, this.persistencePlugin.beforeCacheAccess(cacheContext)];
5192
5475
  case 2:
5193
- _a.sent();
5194
- _a.label = 3;
5476
+ _b.sent();
5477
+ _b.label = 3;
5195
5478
  case 3:
5196
5479
  /*
5197
5480
  * When saving a refreshed tokens to the cache, it is expected that the account that was used is present in the cache.
@@ -5209,15 +5492,15 @@
5209
5492
  }
5210
5493
  return [4 /*yield*/, this.cacheStorage.saveCacheRecord(cacheRecord)];
5211
5494
  case 4:
5212
- _a.sent();
5495
+ _b.sent();
5213
5496
  return [3 /*break*/, 8];
5214
5497
  case 5:
5215
5498
  if (!(this.persistencePlugin && this.serializableCache && cacheContext)) return [3 /*break*/, 7];
5216
5499
  this.logger.verbose("Persistence enabled, calling afterCacheAccess");
5217
5500
  return [4 /*yield*/, this.persistencePlugin.afterCacheAccess(cacheContext)];
5218
5501
  case 6:
5219
- _a.sent();
5220
- _a.label = 7;
5502
+ _b.sent();
5503
+ _b.label = 7;
5221
5504
  case 7: return [7 /*endfinally*/];
5222
5505
  case 8: return [2 /*return*/, ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenObj, requestStateObj, serverTokenResponse.spa_code, serverRequestId)];
5223
5506
  }
@@ -5361,7 +5644,7 @@
5361
5644
  cloudGraphHostName: ((_b = cacheRecord.account) === null || _b === void 0 ? void 0 : _b.cloudGraphHostName) || Constants.EMPTY_STRING,
5362
5645
  msGraphHost: ((_c = cacheRecord.account) === null || _c === void 0 ? void 0 : _c.msGraphHost) || Constants.EMPTY_STRING,
5363
5646
  code: code,
5364
- fromNativeBroker: false
5647
+ fromNativeBroker: false,
5365
5648
  }];
5366
5649
  }
5367
5650
  });
@@ -5370,7 +5653,7 @@
5370
5653
  return ResponseHandler;
5371
5654
  }());
5372
5655
 
5373
- /*! @azure/msal-common v9.0.1 2022-12-07 */
5656
+ /*! @azure/msal-common v10.0.0 2023-02-06 */
5374
5657
 
5375
5658
  /*
5376
5659
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5381,8 +5664,8 @@
5381
5664
  */
5382
5665
  var AuthorizationCodeClient = /** @class */ (function (_super) {
5383
5666
  __extends(AuthorizationCodeClient, _super);
5384
- function AuthorizationCodeClient(configuration) {
5385
- var _this = _super.call(this, configuration) || this;
5667
+ function AuthorizationCodeClient(configuration, performanceClient) {
5668
+ var _this = _super.call(this, configuration, performanceClient) || this;
5386
5669
  // Flag to indicate if client is for hybrid spa auth code redemption
5387
5670
  _this.includeRedirectUri = true;
5388
5671
  return _this;
@@ -5398,13 +5681,17 @@
5398
5681
  * @param request
5399
5682
  */
5400
5683
  AuthorizationCodeClient.prototype.getAuthCodeUrl = function (request) {
5684
+ var _a, _b;
5401
5685
  return __awaiter(this, void 0, void 0, function () {
5402
5686
  var queryString;
5403
- return __generator(this, function (_a) {
5404
- switch (_a.label) {
5405
- case 0: return [4 /*yield*/, this.createAuthCodeUrlQueryString(request)];
5687
+ return __generator(this, function (_c) {
5688
+ switch (_c.label) {
5689
+ case 0:
5690
+ (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.GetAuthCodeUrl, request.correlationId);
5691
+ (_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.setPreQueueTime(exports.PerformanceEvents.AuthClientCreateQueryString, request.correlationId);
5692
+ return [4 /*yield*/, this.createAuthCodeUrlQueryString(request)];
5406
5693
  case 1:
5407
- queryString = _a.sent();
5694
+ queryString = _c.sent();
5408
5695
  return [2 /*return*/, UrlString.appendQueryString(this.authority.authorizationEndpoint, queryString)];
5409
5696
  }
5410
5697
  });
@@ -5416,26 +5703,50 @@
5416
5703
  * @param request
5417
5704
  */
5418
5705
  AuthorizationCodeClient.prototype.acquireToken = function (request, authCodePayload) {
5419
- var _a;
5706
+ var _a, _b, _c, _d, _e, _f;
5420
5707
  return __awaiter(this, void 0, void 0, function () {
5421
- var reqTimestamp, response, requestId, responseHandler;
5422
- return __generator(this, function (_b) {
5423
- switch (_b.label) {
5708
+ var atsMeasurement, reqTimestamp, response, requestId, httpVerAuthority, responseHandler;
5709
+ var _this = this;
5710
+ return __generator(this, function (_g) {
5711
+ switch (_g.label) {
5424
5712
  case 0:
5425
- this.logger.info("in acquireToken call");
5426
- if (!request || StringUtils.isEmpty(request.code)) {
5713
+ if (!request || !request.code) {
5427
5714
  throw ClientAuthError.createTokenRequestCannotBeMadeError();
5428
5715
  }
5716
+ (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.AuthClientAcquireToken, request.correlationId);
5717
+ atsMeasurement = (_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.startMeasurement("AuthCodeClientAcquireToken", request.correlationId);
5718
+ this.logger.info("in acquireToken call in auth-code client");
5429
5719
  reqTimestamp = TimeUtils.nowSeconds();
5720
+ (_c = this.performanceClient) === null || _c === void 0 ? void 0 : _c.setPreQueueTime(exports.PerformanceEvents.AuthClientExecuteTokenRequest, request.correlationId);
5430
5721
  return [4 /*yield*/, this.executeTokenRequest(this.authority, request)];
5431
5722
  case 1:
5432
- response = _b.sent();
5433
- requestId = (_a = response.headers) === null || _a === void 0 ? void 0 : _a[HeaderNames.X_MS_REQUEST_ID];
5434
- responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, this.config.serializableCache, this.config.persistencePlugin);
5723
+ response = _g.sent();
5724
+ requestId = (_d = response.headers) === null || _d === void 0 ? void 0 : _d[HeaderNames.X_MS_REQUEST_ID];
5725
+ httpVerAuthority = (_e = response.headers) === null || _e === void 0 ? void 0 : _e[HeaderNames.X_MS_HTTP_VERSION];
5726
+ if (httpVerAuthority) {
5727
+ atsMeasurement === null || atsMeasurement === void 0 ? void 0 : atsMeasurement.addStaticFields({
5728
+ httpVerAuthority: httpVerAuthority
5729
+ });
5730
+ }
5731
+ responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, this.config.serializableCache, this.config.persistencePlugin, this.performanceClient);
5435
5732
  // Validate response. This function throws a server error if an error is returned by the server.
5436
5733
  responseHandler.validateTokenResponse(response.body);
5437
- return [4 /*yield*/, responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request, authCodePayload, undefined, undefined, undefined, requestId)];
5438
- case 2: return [2 /*return*/, _b.sent()];
5734
+ (_f = this.performanceClient) === null || _f === void 0 ? void 0 : _f.setPreQueueTime(exports.PerformanceEvents.HandleServerTokenResponse, request.correlationId);
5735
+ return [2 /*return*/, responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request, authCodePayload, undefined, undefined, undefined, requestId).then(function (result) {
5736
+ atsMeasurement === null || atsMeasurement === void 0 ? void 0 : atsMeasurement.endMeasurement({
5737
+ success: true
5738
+ });
5739
+ return result;
5740
+ })
5741
+ .catch(function (error) {
5742
+ _this.logger.verbose("Error in fetching token in ACC", request.correlationId);
5743
+ atsMeasurement === null || atsMeasurement === void 0 ? void 0 : atsMeasurement.endMeasurement({
5744
+ errorCode: error.errorCode,
5745
+ subErrorCode: error.subError,
5746
+ success: false
5747
+ });
5748
+ throw error;
5749
+ })];
5439
5750
  }
5440
5751
  });
5441
5752
  });
@@ -5482,26 +5793,19 @@
5482
5793
  * @param request
5483
5794
  */
5484
5795
  AuthorizationCodeClient.prototype.executeTokenRequest = function (authority, request) {
5796
+ var _a, _b;
5485
5797
  return __awaiter(this, void 0, void 0, function () {
5486
- var thumbprint, requestBody, queryParameters, ccsCredential, clientInfo, headers, endpoint;
5487
- return __generator(this, function (_a) {
5488
- switch (_a.label) {
5798
+ var queryParametersString, endpoint, requestBody, ccsCredential, clientInfo, headers, thumbprint;
5799
+ return __generator(this, function (_c) {
5800
+ switch (_c.label) {
5489
5801
  case 0:
5490
- thumbprint = {
5491
- clientId: this.config.authOptions.clientId,
5492
- authority: authority.canonicalAuthority,
5493
- scopes: request.scopes,
5494
- claims: request.claims,
5495
- authenticationScheme: request.authenticationScheme,
5496
- resourceRequestMethod: request.resourceRequestMethod,
5497
- resourceRequestUri: request.resourceRequestUri,
5498
- shrClaims: request.shrClaims,
5499
- sshKid: request.sshKid
5500
- };
5802
+ (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.AuthClientExecuteTokenRequest, request.correlationId);
5803
+ (_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.setPreQueueTime(exports.PerformanceEvents.AuthClientCreateTokenRequestBody, request.correlationId);
5804
+ queryParametersString = this.createTokenQueryParameters(request);
5805
+ endpoint = UrlString.appendQueryString(authority.tokenEndpoint, queryParametersString);
5501
5806
  return [4 /*yield*/, this.createTokenRequestBody(request)];
5502
5807
  case 1:
5503
- requestBody = _a.sent();
5504
- queryParameters = this.createTokenQueryParameters(request);
5808
+ requestBody = _c.sent();
5505
5809
  ccsCredential = undefined;
5506
5810
  if (request.clientInfo) {
5507
5811
  try {
@@ -5516,34 +5820,35 @@
5516
5820
  }
5517
5821
  }
5518
5822
  headers = this.createTokenRequestHeaders(ccsCredential || request.ccsCredential);
5519
- endpoint = StringUtils.isEmpty(queryParameters) ? authority.tokenEndpoint : authority.tokenEndpoint + "?" + queryParameters;
5823
+ thumbprint = {
5824
+ clientId: this.config.authOptions.clientId,
5825
+ authority: authority.canonicalAuthority,
5826
+ scopes: request.scopes,
5827
+ claims: request.claims,
5828
+ authenticationScheme: request.authenticationScheme,
5829
+ resourceRequestMethod: request.resourceRequestMethod,
5830
+ resourceRequestUri: request.resourceRequestUri,
5831
+ shrClaims: request.shrClaims,
5832
+ sshKid: request.sshKid
5833
+ };
5520
5834
  return [2 /*return*/, this.executePostToTokenEndpoint(endpoint, requestBody, headers, thumbprint)];
5521
5835
  }
5522
5836
  });
5523
5837
  });
5524
5838
  };
5525
- /**
5526
- * Creates query string for the /token request
5527
- * @param request
5528
- */
5529
- AuthorizationCodeClient.prototype.createTokenQueryParameters = function (request) {
5530
- var parameterBuilder = new RequestParameterBuilder();
5531
- if (request.tokenQueryParameters) {
5532
- parameterBuilder.addExtraQueryParameters(request.tokenQueryParameters);
5533
- }
5534
- return parameterBuilder.createQueryString();
5535
- };
5536
5839
  /**
5537
5840
  * Generates a map for all the params to be sent to the service
5538
5841
  * @param request
5539
5842
  */
5540
5843
  AuthorizationCodeClient.prototype.createTokenRequestBody = function (request) {
5844
+ var _a, _b;
5541
5845
  return __awaiter(this, void 0, void 0, function () {
5542
5846
  var parameterBuilder, clientAssertion, popTokenGenerator, reqCnfData, correlationId, ccsCred, clientInfo, clientInfo;
5543
- var _a;
5544
- return __generator(this, function (_b) {
5545
- switch (_b.label) {
5847
+ var _c;
5848
+ return __generator(this, function (_d) {
5849
+ switch (_d.label) {
5546
5850
  case 0:
5851
+ (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.AuthClientCreateTokenRequestBody, request.correlationId);
5547
5852
  parameterBuilder = new RequestParameterBuilder();
5548
5853
  parameterBuilder.addClientId(this.config.authOptions.clientId);
5549
5854
  /*
@@ -5584,10 +5889,11 @@
5584
5889
  parameterBuilder.addGrantType(GrantType.AUTHORIZATION_CODE_GRANT);
5585
5890
  parameterBuilder.addClientInfo();
5586
5891
  if (!(request.authenticationScheme === exports.AuthenticationScheme.POP)) return [3 /*break*/, 2];
5587
- popTokenGenerator = new PopTokenGenerator(this.cryptoUtils);
5892
+ popTokenGenerator = new PopTokenGenerator(this.cryptoUtils, this.performanceClient);
5893
+ (_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.setPreQueueTime(exports.PerformanceEvents.PopTokenGenerateCnf, request.correlationId);
5588
5894
  return [4 /*yield*/, popTokenGenerator.generateCnf(request)];
5589
5895
  case 1:
5590
- reqCnfData = _b.sent();
5896
+ reqCnfData = _d.sent();
5591
5897
  // SPA PoP requires full Base64Url encoded req_cnf string (unhashed)
5592
5898
  parameterBuilder.addPopToken(reqCnfData.reqCnfString);
5593
5899
  return [3 /*break*/, 3];
@@ -5600,7 +5906,7 @@
5600
5906
  throw ClientConfigurationError.createMissingSshJwkError();
5601
5907
  }
5602
5908
  }
5603
- _b.label = 3;
5909
+ _d.label = 3;
5604
5910
  case 3:
5605
5911
  correlationId = request.correlationId || this.config.cryptoInterface.createNewGuid();
5606
5912
  parameterBuilder.addCorrelationId(correlationId);
@@ -5645,9 +5951,9 @@
5645
5951
  }
5646
5952
  // Add hybrid spa parameters if not already provided
5647
5953
  if (request.enableSpaAuthorizationCode && (!request.tokenBodyParameters || !request.tokenBodyParameters[AADServerParamKeys.RETURN_SPA_CODE])) {
5648
- parameterBuilder.addExtraQueryParameters((_a = {},
5649
- _a[AADServerParamKeys.RETURN_SPA_CODE] = "1",
5650
- _a));
5954
+ parameterBuilder.addExtraQueryParameters((_c = {},
5955
+ _c[AADServerParamKeys.RETURN_SPA_CODE] = "1",
5956
+ _c));
5651
5957
  }
5652
5958
  return [2 /*return*/, parameterBuilder.createQueryString()];
5653
5959
  }
@@ -5659,11 +5965,13 @@
5659
5965
  * @param request
5660
5966
  */
5661
5967
  AuthorizationCodeClient.prototype.createAuthCodeUrlQueryString = function (request) {
5968
+ var _a;
5662
5969
  return __awaiter(this, void 0, void 0, function () {
5663
5970
  var parameterBuilder, requestScopes, correlationId, accountSid, accountLoginHintClaim, clientInfo, clientInfo, clientInfo, popTokenGenerator, reqCnfData;
5664
- return __generator(this, function (_a) {
5665
- switch (_a.label) {
5971
+ return __generator(this, function (_b) {
5972
+ switch (_b.label) {
5666
5973
  case 0:
5974
+ (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.AuthClientCreateQueryString, request.correlationId);
5667
5975
  parameterBuilder = new RequestParameterBuilder();
5668
5976
  parameterBuilder.addClientId(this.config.authOptions.clientId);
5669
5977
  requestScopes = __spreadArrays(request.scopes || [], request.extraScopesToConsent || []);
@@ -5735,220 +6043,95 @@
5735
6043
  }
5736
6044
  else if (request.account.username) {
5737
6045
  // Fallback to account username if provided
5738
- this.logger.verbose("createAuthCodeUrlQueryString: Adding login_hint from account");
5739
- parameterBuilder.addLoginHint(request.account.username);
5740
- try {
5741
- clientInfo = buildClientInfoFromHomeAccountId(request.account.homeAccountId);
5742
- parameterBuilder.addCcsOid(clientInfo);
5743
- }
5744
- catch (e) {
5745
- this.logger.verbose("createAuthCodeUrlQueryString: Could not parse home account ID for CCS Header");
5746
- }
5747
- }
5748
- }
5749
- else if (request.loginHint) {
5750
- this.logger.verbose("createAuthCodeUrlQueryString: No account, adding login_hint from request");
5751
- parameterBuilder.addLoginHint(request.loginHint);
5752
- parameterBuilder.addCcsUpn(request.loginHint);
5753
- }
5754
- }
5755
- else {
5756
- this.logger.verbose("createAuthCodeUrlQueryString: Prompt is select_account, ignoring account hints");
5757
- }
5758
- if (request.nonce) {
5759
- parameterBuilder.addNonce(request.nonce);
5760
- }
5761
- if (request.state) {
5762
- parameterBuilder.addState(request.state);
5763
- }
5764
- if (!StringUtils.isEmpty(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {
5765
- parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);
5766
- }
5767
- if (request.extraQueryParameters) {
5768
- parameterBuilder.addExtraQueryParameters(request.extraQueryParameters);
5769
- }
5770
- if (!request.nativeBroker) return [3 /*break*/, 2];
5771
- // signal ests that this is a WAM call
5772
- parameterBuilder.addNativeBroker();
5773
- if (!(request.authenticationScheme === exports.AuthenticationScheme.POP)) return [3 /*break*/, 2];
5774
- popTokenGenerator = new PopTokenGenerator(this.cryptoUtils);
5775
- return [4 /*yield*/, popTokenGenerator.generateCnf(request)];
5776
- case 1:
5777
- reqCnfData = _a.sent();
5778
- parameterBuilder.addPopToken(reqCnfData.reqCnfHash);
5779
- _a.label = 2;
5780
- case 2: return [2 /*return*/, parameterBuilder.createQueryString()];
5781
- }
5782
- });
5783
- });
5784
- };
5785
- /**
5786
- * This API validates the `EndSessionRequest` and creates a URL
5787
- * @param request
5788
- */
5789
- AuthorizationCodeClient.prototype.createLogoutUrlQueryString = function (request) {
5790
- var parameterBuilder = new RequestParameterBuilder();
5791
- if (request.postLogoutRedirectUri) {
5792
- parameterBuilder.addPostLogoutRedirectUri(request.postLogoutRedirectUri);
5793
- }
5794
- if (request.correlationId) {
5795
- parameterBuilder.addCorrelationId(request.correlationId);
5796
- }
5797
- if (request.idTokenHint) {
5798
- parameterBuilder.addIdTokenHint(request.idTokenHint);
5799
- }
5800
- if (request.state) {
5801
- parameterBuilder.addState(request.state);
5802
- }
5803
- if (request.logoutHint) {
5804
- parameterBuilder.addLogoutHint(request.logoutHint);
5805
- }
5806
- if (request.extraQueryParameters) {
5807
- parameterBuilder.addExtraQueryParameters(request.extraQueryParameters);
5808
- }
5809
- return parameterBuilder.createQueryString();
5810
- };
5811
- /**
5812
- * Helper to get sid from account. Returns null if idTokenClaims are not present or sid is not present.
5813
- * @param account
5814
- */
5815
- AuthorizationCodeClient.prototype.extractAccountSid = function (account) {
5816
- var _a;
5817
- return ((_a = account.idTokenClaims) === null || _a === void 0 ? void 0 : _a.sid) || null;
5818
- };
5819
- AuthorizationCodeClient.prototype.extractLoginHint = function (account) {
5820
- var _a;
5821
- return ((_a = account.idTokenClaims) === null || _a === void 0 ? void 0 : _a.login_hint) || null;
5822
- };
5823
- return AuthorizationCodeClient;
5824
- }(BaseClient));
5825
-
5826
- /*! @azure/msal-common v9.0.1 2022-12-07 */
5827
- /*
5828
- * Copyright (c) Microsoft Corporation. All rights reserved.
5829
- * Licensed under the MIT License.
5830
- */
5831
- /**
5832
- * Enumeration of operations that are instrumented by have their performance measured by the PerformanceClient.
5833
- *
5834
- * @export
5835
- * @enum {number}
5836
- */
5837
- exports.PerformanceEvents = void 0;
5838
- (function (PerformanceEvents) {
5839
- /**
5840
- * acquireTokenByCode API (msal-browser and msal-node).
5841
- * Used to acquire tokens by trading an authorization code against the token endpoint.
5842
- */
5843
- PerformanceEvents["AcquireTokenByCode"] = "acquireTokenByCode";
5844
- /**
5845
- * acquireTokenByRefreshToken API (msal-browser and msal-node).
5846
- * Used to renew an access token using a refresh token against the token endpoint.
5847
- */
5848
- PerformanceEvents["AcquireTokenByRefreshToken"] = "acquireTokenByRefreshToken";
5849
- /**
5850
- * acquireTokenSilent API (msal-browser and msal-node).
5851
- * Used to silently acquire a new access token (from the cache or the network).
5852
- */
5853
- PerformanceEvents["AcquireTokenSilent"] = "acquireTokenSilent";
5854
- /**
5855
- * acquireTokenSilentAsync (msal-browser).
5856
- * Internal API for acquireTokenSilent.
5857
- */
5858
- PerformanceEvents["AcquireTokenSilentAsync"] = "acquireTokenSilentAsync";
5859
- /**
5860
- * acquireTokenPopup (msal-browser).
5861
- * Used to acquire a new access token interactively through pop ups
5862
- */
5863
- PerformanceEvents["AcquireTokenPopup"] = "acquireTokenPopup";
5864
- /**
5865
- * getPublicKeyThumbprint API in CryptoOpts class (msal-browser).
5866
- * Used to generate a public/private keypair and generate a public key thumbprint for pop requests.
5867
- */
5868
- PerformanceEvents["CryptoOptsGetPublicKeyThumbprint"] = "cryptoOptsGetPublicKeyThumbprint";
5869
- /**
5870
- * signJwt API in CryptoOpts class (msal-browser).
5871
- * Used to signed a pop token.
5872
- */
5873
- PerformanceEvents["CryptoOptsSignJwt"] = "cryptoOptsSignJwt";
5874
- /**
5875
- * acquireToken API in the SilentCacheClient class (msal-browser).
5876
- * Used to read access tokens from the cache.
5877
- */
5878
- PerformanceEvents["SilentCacheClientAcquireToken"] = "silentCacheClientAcquireToken";
5879
- /**
5880
- * acquireToken API in the SilentIframeClient class (msal-browser).
5881
- * Used to acquire a new set of tokens from the authorize endpoint in a hidden iframe.
5882
- */
5883
- PerformanceEvents["SilentIframeClientAcquireToken"] = "silentIframeClientAcquireToken";
5884
- /**
5885
- * acquireToken API in SilentRereshClient (msal-browser).
5886
- * Used to acquire a new set of tokens from the token endpoint using a refresh token.
5887
- */
5888
- PerformanceEvents["SilentRefreshClientAcquireToken"] = "silentRefreshClientAcquireToken";
5889
- /**
5890
- * ssoSilent API (msal-browser).
5891
- * Used to silently acquire an authorization code and set of tokens using a hidden iframe.
5892
- */
5893
- PerformanceEvents["SsoSilent"] = "ssoSilent";
5894
- /**
5895
- * getDiscoveredAuthority API in StandardInteractionClient class (msal-browser).
5896
- * Used to load authority metadata for a request.
5897
- */
5898
- PerformanceEvents["StandardInteractionClientGetDiscoveredAuthority"] = "standardInteractionClientGetDiscoveredAuthority";
5899
- /**
5900
- * acquireToken APIs in msal-browser.
5901
- * Used to make an /authorize endpoint call with native brokering enabled.
5902
- */
5903
- PerformanceEvents["FetchAccountIdWithNativeBroker"] = "fetchAccountIdWithNativeBroker";
5904
- /**
5905
- * acquireToken API in NativeInteractionClient class (msal-browser).
5906
- * Used to acquire a token from Native component when native brokering is enabled.
5907
- */
5908
- PerformanceEvents["NativeInteractionClientAcquireToken"] = "nativeInteractionClientAcquireToken";
5909
- /**
5910
- * Time spent creating default headers for requests to token endpoint
5911
- */
5912
- PerformanceEvents["BaseClientCreateTokenRequestHeaders"] = "baseClientCreateTokenRequestHeaders";
5913
- /**
5914
- * Used to measure the time taken for completing embedded-broker handshake (PW-Broker).
5915
- */
5916
- PerformanceEvents["BrokerHandhshake"] = "brokerHandshake";
5917
- /**
5918
- * acquireTokenByRefreshToken API in BrokerClientApplication (PW-Broker) .
5919
- */
5920
- PerformanceEvents["AcquireTokenByRefreshTokenInBroker"] = "acquireTokenByRefreshTokenInBroker";
5921
- /**
5922
- * Time taken for token acquisition by broker
5923
- */
5924
- PerformanceEvents["AcquireTokenByBroker"] = "acquireTokenByBroker";
5925
- /**
5926
- * Time spent on the network for refresh token acquisition
5927
- */
5928
- PerformanceEvents["RefreshTokenClientExecuteTokenRequest"] = "refreshTokenClientExecuteTokenRequest";
6046
+ this.logger.verbose("createAuthCodeUrlQueryString: Adding login_hint from account");
6047
+ parameterBuilder.addLoginHint(request.account.username);
6048
+ try {
6049
+ clientInfo = buildClientInfoFromHomeAccountId(request.account.homeAccountId);
6050
+ parameterBuilder.addCcsOid(clientInfo);
6051
+ }
6052
+ catch (e) {
6053
+ this.logger.verbose("createAuthCodeUrlQueryString: Could not parse home account ID for CCS Header");
6054
+ }
6055
+ }
6056
+ }
6057
+ else if (request.loginHint) {
6058
+ this.logger.verbose("createAuthCodeUrlQueryString: No account, adding login_hint from request");
6059
+ parameterBuilder.addLoginHint(request.loginHint);
6060
+ parameterBuilder.addCcsUpn(request.loginHint);
6061
+ }
6062
+ }
6063
+ else {
6064
+ this.logger.verbose("createAuthCodeUrlQueryString: Prompt is select_account, ignoring account hints");
6065
+ }
6066
+ if (request.nonce) {
6067
+ parameterBuilder.addNonce(request.nonce);
6068
+ }
6069
+ if (request.state) {
6070
+ parameterBuilder.addState(request.state);
6071
+ }
6072
+ if (!StringUtils.isEmpty(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {
6073
+ parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);
6074
+ }
6075
+ if (request.extraQueryParameters) {
6076
+ parameterBuilder.addExtraQueryParameters(request.extraQueryParameters);
6077
+ }
6078
+ if (!request.nativeBroker) return [3 /*break*/, 2];
6079
+ // signal ests that this is a WAM call
6080
+ parameterBuilder.addNativeBroker();
6081
+ if (!(request.authenticationScheme === exports.AuthenticationScheme.POP)) return [3 /*break*/, 2];
6082
+ popTokenGenerator = new PopTokenGenerator(this.cryptoUtils);
6083
+ return [4 /*yield*/, popTokenGenerator.generateCnf(request)];
6084
+ case 1:
6085
+ reqCnfData = _b.sent();
6086
+ parameterBuilder.addPopToken(reqCnfData.reqCnfHash);
6087
+ _b.label = 2;
6088
+ case 2: return [2 /*return*/, parameterBuilder.createQueryString()];
6089
+ }
6090
+ });
6091
+ });
6092
+ };
5929
6093
  /**
5930
- * Time taken for acquiring refresh token , records RT size
6094
+ * This API validates the `EndSessionRequest` and creates a URL
6095
+ * @param request
5931
6096
  */
5932
- PerformanceEvents["RefreshTokenClientAcquireToken"] = "refreshTokenClientAcquireToken";
6097
+ AuthorizationCodeClient.prototype.createLogoutUrlQueryString = function (request) {
6098
+ var parameterBuilder = new RequestParameterBuilder();
6099
+ if (request.postLogoutRedirectUri) {
6100
+ parameterBuilder.addPostLogoutRedirectUri(request.postLogoutRedirectUri);
6101
+ }
6102
+ if (request.correlationId) {
6103
+ parameterBuilder.addCorrelationId(request.correlationId);
6104
+ }
6105
+ if (request.idTokenHint) {
6106
+ parameterBuilder.addIdTokenHint(request.idTokenHint);
6107
+ }
6108
+ if (request.state) {
6109
+ parameterBuilder.addState(request.state);
6110
+ }
6111
+ if (request.logoutHint) {
6112
+ parameterBuilder.addLogoutHint(request.logoutHint);
6113
+ }
6114
+ if (request.extraQueryParameters) {
6115
+ parameterBuilder.addExtraQueryParameters(request.extraQueryParameters);
6116
+ }
6117
+ return parameterBuilder.createQueryString();
6118
+ };
5933
6119
  /**
5934
- * Time taken for acquiring cached refresh token
6120
+ * Helper to get sid from account. Returns null if idTokenClaims are not present or sid is not present.
6121
+ * @param account
5935
6122
  */
5936
- PerformanceEvents["RefreshTokenClientAcquireTokenWithCachedRefreshToken"] = "refreshTokenClientAcquireTokenWithCachedRefreshToken";
5937
- })(exports.PerformanceEvents || (exports.PerformanceEvents = {}));
5938
- /**
5939
- * State of the performance event.
5940
- *
5941
- * @export
5942
- * @enum {number}
5943
- */
5944
- var PerformanceEventStatus;
5945
- (function (PerformanceEventStatus) {
5946
- PerformanceEventStatus[PerformanceEventStatus["NotStarted"] = 0] = "NotStarted";
5947
- PerformanceEventStatus[PerformanceEventStatus["InProgress"] = 1] = "InProgress";
5948
- PerformanceEventStatus[PerformanceEventStatus["Completed"] = 2] = "Completed";
5949
- })(PerformanceEventStatus || (PerformanceEventStatus = {}));
6123
+ AuthorizationCodeClient.prototype.extractAccountSid = function (account) {
6124
+ var _a;
6125
+ return ((_a = account.idTokenClaims) === null || _a === void 0 ? void 0 : _a.sid) || null;
6126
+ };
6127
+ AuthorizationCodeClient.prototype.extractLoginHint = function (account) {
6128
+ var _a;
6129
+ return ((_a = account.idTokenClaims) === null || _a === void 0 ? void 0 : _a.login_hint) || null;
6130
+ };
6131
+ return AuthorizationCodeClient;
6132
+ }(BaseClient));
5950
6133
 
5951
- /*! @azure/msal-common v9.0.1 2022-12-07 */
6134
+ /*! @azure/msal-common v10.0.0 2023-02-06 */
5952
6135
 
5953
6136
  /*
5954
6137
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5963,25 +6146,34 @@
5963
6146
  return _super.call(this, configuration, performanceClient) || this;
5964
6147
  }
5965
6148
  RefreshTokenClient.prototype.acquireToken = function (request) {
5966
- var _a, _b, _c;
6149
+ var _a, _b, _c, _d, _e, _f, _g;
5967
6150
  return __awaiter(this, void 0, void 0, function () {
5968
- var atsMeasurement, reqTimestamp, response, requestId, responseHandler;
6151
+ var atsMeasurement, reqTimestamp, response, httpVerToken, requestId, responseHandler;
5969
6152
  var _this = this;
5970
- return __generator(this, function (_d) {
5971
- switch (_d.label) {
6153
+ return __generator(this, function (_h) {
6154
+ switch (_h.label) {
5972
6155
  case 0:
5973
- atsMeasurement = (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.startMeasurement(exports.PerformanceEvents.RefreshTokenClientAcquireToken, request.correlationId);
6156
+ (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.RefreshTokenClientAcquireToken, request.correlationId);
6157
+ atsMeasurement = (_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.startMeasurement(exports.PerformanceEvents.RefreshTokenClientAcquireToken, request.correlationId);
5974
6158
  this.logger.verbose("RefreshTokenClientAcquireToken called", request.correlationId);
5975
6159
  reqTimestamp = TimeUtils.nowSeconds();
6160
+ (_c = this.performanceClient) === null || _c === void 0 ? void 0 : _c.setPreQueueTime(exports.PerformanceEvents.RefreshTokenClientExecuteTokenRequest, request.correlationId);
5976
6161
  return [4 /*yield*/, this.executeTokenRequest(request, this.authority)];
5977
6162
  case 1:
5978
- response = _d.sent();
6163
+ response = _h.sent();
6164
+ httpVerToken = (_d = response.headers) === null || _d === void 0 ? void 0 : _d[HeaderNames.X_MS_HTTP_VERSION];
5979
6165
  atsMeasurement === null || atsMeasurement === void 0 ? void 0 : atsMeasurement.addStaticFields({
5980
- refreshTokenSize: ((_b = response.body.refresh_token) === null || _b === void 0 ? void 0 : _b.length) || 0
6166
+ refreshTokenSize: ((_e = response.body.refresh_token) === null || _e === void 0 ? void 0 : _e.length) || 0,
5981
6167
  });
5982
- requestId = (_c = response.headers) === null || _c === void 0 ? void 0 : _c[HeaderNames.X_MS_REQUEST_ID];
6168
+ if (httpVerToken) {
6169
+ atsMeasurement === null || atsMeasurement === void 0 ? void 0 : atsMeasurement.addStaticFields({
6170
+ httpVerToken: httpVerToken,
6171
+ });
6172
+ }
6173
+ requestId = (_f = response.headers) === null || _f === void 0 ? void 0 : _f[HeaderNames.X_MS_REQUEST_ID];
5983
6174
  responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, this.config.serializableCache, this.config.persistencePlugin);
5984
6175
  responseHandler.validateTokenResponse(response.body);
6176
+ (_g = this.performanceClient) === null || _g === void 0 ? void 0 : _g.setPreQueueTime(exports.PerformanceEvents.HandleServerTokenResponse, request.correlationId);
5985
6177
  return [2 /*return*/, responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request, undefined, undefined, true, request.forceCache, requestId).then(function (result) {
5986
6178
  atsMeasurement === null || atsMeasurement === void 0 ? void 0 : atsMeasurement.endMeasurement({
5987
6179
  success: true
@@ -6006,13 +6198,15 @@
6006
6198
  * @param request
6007
6199
  */
6008
6200
  RefreshTokenClient.prototype.acquireTokenByRefreshToken = function (request) {
6201
+ var _a, _b, _c, _d;
6009
6202
  return __awaiter(this, void 0, void 0, function () {
6010
6203
  var isFOCI, noFamilyRTInCache, clientMismatchErrorWithFamilyRT;
6011
- return __generator(this, function (_a) {
6204
+ return __generator(this, function (_e) {
6012
6205
  // Cannot renew token if no request object is given.
6013
6206
  if (!request) {
6014
6207
  throw ClientConfigurationError.createEmptyTokenRequestError();
6015
6208
  }
6209
+ (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.RefreshTokenClientAcquireTokenByRefreshToken, request.correlationId);
6016
6210
  // We currently do not support silent flow for account === null use cases; This will be revisited for confidential flow usecases
6017
6211
  if (!request.account) {
6018
6212
  throw ClientAuthError.createNoAccountInSilentRequestError();
@@ -6021,6 +6215,7 @@
6021
6215
  // if the app is part of the family, retrive a Family refresh token if present and make a refreshTokenRequest
6022
6216
  if (isFOCI) {
6023
6217
  try {
6218
+ (_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.setPreQueueTime(exports.PerformanceEvents.RefreshTokenClientAcquireTokenWithCachedRefreshToken, request.correlationId);
6024
6219
  return [2 /*return*/, this.acquireTokenWithCachedRefreshToken(request, true)];
6025
6220
  }
6026
6221
  catch (e) {
@@ -6028,6 +6223,7 @@
6028
6223
  clientMismatchErrorWithFamilyRT = e instanceof ServerError && e.errorCode === Errors.INVALID_GRANT_ERROR && e.subError === Errors.CLIENT_MISMATCH_ERROR;
6029
6224
  // if family Refresh Token (FRT) cache acquisition fails or if client_mismatch error is seen with FRT, reattempt with application Refresh Token (ART)
6030
6225
  if (noFamilyRTInCache || clientMismatchErrorWithFamilyRT) {
6226
+ (_c = this.performanceClient) === null || _c === void 0 ? void 0 : _c.setPreQueueTime(exports.PerformanceEvents.RefreshTokenClientAcquireTokenWithCachedRefreshToken, request.correlationId);
6031
6227
  return [2 /*return*/, this.acquireTokenWithCachedRefreshToken(request, false)];
6032
6228
  // throw in all other cases
6033
6229
  }
@@ -6037,6 +6233,7 @@
6037
6233
  }
6038
6234
  }
6039
6235
  // fall back to application refresh token acquisition
6236
+ (_d = this.performanceClient) === null || _d === void 0 ? void 0 : _d.setPreQueueTime(exports.PerformanceEvents.RefreshTokenClientAcquireTokenWithCachedRefreshToken, request.correlationId);
6040
6237
  return [2 /*return*/, this.acquireTokenWithCachedRefreshToken(request, false)];
6041
6238
  });
6042
6239
  });
@@ -6046,11 +6243,12 @@
6046
6243
  * @param request
6047
6244
  */
6048
6245
  RefreshTokenClient.prototype.acquireTokenWithCachedRefreshToken = function (request, foci) {
6049
- var _a;
6246
+ var _a, _b, _c;
6050
6247
  return __awaiter(this, void 0, void 0, function () {
6051
6248
  var atsMeasurement, refreshToken, refreshTokenRequest;
6052
- return __generator(this, function (_b) {
6053
- atsMeasurement = (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.startMeasurement(exports.PerformanceEvents.RefreshTokenClientAcquireTokenWithCachedRefreshToken, request.correlationId);
6249
+ return __generator(this, function (_d) {
6250
+ (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.RefreshTokenClientAcquireTokenWithCachedRefreshToken, request.correlationId);
6251
+ atsMeasurement = (_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.startMeasurement(exports.PerformanceEvents.RefreshTokenClientAcquireTokenWithCachedRefreshToken, request.correlationId);
6054
6252
  this.logger.verbose("RefreshTokenClientAcquireTokenWithCachedRefreshToken called", request.correlationId);
6055
6253
  refreshToken = this.cacheManager.readRefreshTokenFromCache(this.config.authOptions.clientId, request.account, foci);
6056
6254
  if (!refreshToken) {
@@ -6065,6 +6263,7 @@
6065
6263
  credential: request.account.homeAccountId,
6066
6264
  type: CcsCredentialType.HOME_ACCOUNT_ID
6067
6265
  } });
6266
+ (_c = this.performanceClient) === null || _c === void 0 ? void 0 : _c.setPreQueueTime(exports.PerformanceEvents.RefreshTokenClientAcquireToken, request.correlationId);
6068
6267
  return [2 /*return*/, this.acquireToken(refreshTokenRequest)];
6069
6268
  });
6070
6269
  });
@@ -6075,17 +6274,20 @@
6075
6274
  * @param authority
6076
6275
  */
6077
6276
  RefreshTokenClient.prototype.executeTokenRequest = function (request, authority) {
6078
- var _a;
6277
+ var _a, _b, _c;
6079
6278
  return __awaiter(this, void 0, void 0, function () {
6080
- var acquireTokenMeasurement, requestBody, queryParameters, headers, thumbprint, endpoint;
6081
- return __generator(this, function (_b) {
6082
- switch (_b.label) {
6279
+ var acquireTokenMeasurement, queryParametersString, endpoint, requestBody, headers, thumbprint;
6280
+ return __generator(this, function (_d) {
6281
+ switch (_d.label) {
6083
6282
  case 0:
6084
- acquireTokenMeasurement = (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.startMeasurement(exports.PerformanceEvents.RefreshTokenClientExecuteTokenRequest, request.correlationId);
6283
+ (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.RefreshTokenClientExecuteTokenRequest, request.correlationId);
6284
+ acquireTokenMeasurement = (_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.startMeasurement(exports.PerformanceEvents.RefreshTokenClientExecuteTokenRequest, request.correlationId);
6285
+ (_c = this.performanceClient) === null || _c === void 0 ? void 0 : _c.setPreQueueTime(exports.PerformanceEvents.RefreshTokenClientCreateTokenRequestBody, request.correlationId);
6286
+ queryParametersString = this.createTokenQueryParameters(request);
6287
+ endpoint = UrlString.appendQueryString(authority.tokenEndpoint, queryParametersString);
6085
6288
  return [4 /*yield*/, this.createTokenRequestBody(request)];
6086
6289
  case 1:
6087
- requestBody = _b.sent();
6088
- queryParameters = this.createTokenQueryParameters(request);
6290
+ requestBody = _d.sent();
6089
6291
  headers = this.createTokenRequestHeaders(request.ccsCredential);
6090
6292
  thumbprint = {
6091
6293
  clientId: this.config.authOptions.clientId,
@@ -6098,7 +6300,6 @@
6098
6300
  shrClaims: request.shrClaims,
6099
6301
  sshKid: request.sshKid
6100
6302
  };
6101
- endpoint = UrlString.appendQueryString(authority.tokenEndpoint, queryParameters);
6102
6303
  return [2 /*return*/, this.executePostToTokenEndpoint(endpoint, requestBody, headers, thumbprint)
6103
6304
  .then(function (result) {
6104
6305
  acquireTokenMeasurement === null || acquireTokenMeasurement === void 0 ? void 0 : acquireTokenMeasurement.endMeasurement({
@@ -6116,30 +6317,20 @@
6116
6317
  });
6117
6318
  });
6118
6319
  };
6119
- /**
6120
- * Creates query string for the /token request
6121
- * @param request
6122
- */
6123
- RefreshTokenClient.prototype.createTokenQueryParameters = function (request) {
6124
- var parameterBuilder = new RequestParameterBuilder();
6125
- if (request.tokenQueryParameters) {
6126
- parameterBuilder.addExtraQueryParameters(request.tokenQueryParameters);
6127
- }
6128
- return parameterBuilder.createQueryString();
6129
- };
6130
6320
  /**
6131
6321
  * Helper function to create the token request body
6132
6322
  * @param request
6133
6323
  */
6134
6324
  RefreshTokenClient.prototype.createTokenRequestBody = function (request) {
6135
- var _a;
6325
+ var _a, _b, _c;
6136
6326
  return __awaiter(this, void 0, void 0, function () {
6137
6327
  var correlationId, acquireTokenMeasurement, parameterBuilder, clientAssertion, popTokenGenerator, reqCnfData, clientInfo;
6138
- return __generator(this, function (_b) {
6139
- switch (_b.label) {
6328
+ return __generator(this, function (_d) {
6329
+ switch (_d.label) {
6140
6330
  case 0:
6331
+ (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.RefreshTokenClientCreateTokenRequestBody, request.correlationId);
6141
6332
  correlationId = request.correlationId;
6142
- acquireTokenMeasurement = (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.startMeasurement(exports.PerformanceEvents.BaseClientCreateTokenRequestHeaders, correlationId);
6333
+ acquireTokenMeasurement = (_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.startMeasurement(exports.PerformanceEvents.BaseClientCreateTokenRequestHeaders, correlationId);
6143
6334
  parameterBuilder = new RequestParameterBuilder();
6144
6335
  parameterBuilder.addClientId(this.config.authOptions.clientId);
6145
6336
  parameterBuilder.addScopes(request.scopes);
@@ -6162,10 +6353,11 @@
6162
6353
  parameterBuilder.addClientAssertionType(clientAssertion.assertionType);
6163
6354
  }
6164
6355
  if (!(request.authenticationScheme === exports.AuthenticationScheme.POP)) return [3 /*break*/, 2];
6165
- popTokenGenerator = new PopTokenGenerator(this.cryptoUtils);
6356
+ popTokenGenerator = new PopTokenGenerator(this.cryptoUtils, this.performanceClient);
6357
+ (_c = this.performanceClient) === null || _c === void 0 ? void 0 : _c.setPreQueueTime(exports.PerformanceEvents.PopTokenGenerateCnf, request.correlationId);
6166
6358
  return [4 /*yield*/, popTokenGenerator.generateCnf(request)];
6167
6359
  case 1:
6168
- reqCnfData = _b.sent();
6360
+ reqCnfData = _d.sent();
6169
6361
  // SPA PoP requires full Base64Url encoded req_cnf string (unhashed)
6170
6362
  parameterBuilder.addPopToken(reqCnfData.reqCnfString);
6171
6363
  return [3 /*break*/, 3];
@@ -6181,7 +6373,7 @@
6181
6373
  throw ClientConfigurationError.createMissingSshJwkError();
6182
6374
  }
6183
6375
  }
6184
- _b.label = 3;
6376
+ _d.label = 3;
6185
6377
  case 3:
6186
6378
  if (!StringUtils.isEmptyObj(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {
6187
6379
  parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);
@@ -6213,7 +6405,7 @@
6213
6405
  return RefreshTokenClient;
6214
6406
  }(BaseClient));
6215
6407
 
6216
- /*! @azure/msal-common v9.0.1 2022-12-07 */
6408
+ /*! @azure/msal-common v10.0.0 2023-02-06 */
6217
6409
 
6218
6410
  /*
6219
6411
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6337,7 +6529,7 @@
6337
6529
  return SilentFlowClient;
6338
6530
  }(BaseClient));
6339
6531
 
6340
- /*! @azure/msal-common v9.0.1 2022-12-07 */
6532
+ /*! @azure/msal-common v10.0.0 2023-02-06 */
6341
6533
  /*
6342
6534
  * Copyright (c) Microsoft Corporation. All rights reserved.
6343
6535
  * Licensed under the MIT License.
@@ -6349,7 +6541,7 @@
6349
6541
  response.hasOwnProperty("jwks_uri"));
6350
6542
  }
6351
6543
 
6352
- /*! @azure/msal-common v9.0.1 2022-12-07 */
6544
+ /*! @azure/msal-common v10.0.0 2023-02-06 */
6353
6545
  /*
6354
6546
  * Copyright (c) Microsoft Corporation. All rights reserved.
6355
6547
  * Licensed under the MIT License.
@@ -6358,7 +6550,7 @@
6358
6550
  var EndpointMetadata = rawMetdataJSON.endpointMetadata;
6359
6551
  var InstanceDiscoveryMetadata = rawMetdataJSON.instanceDiscoveryMetadata;
6360
6552
 
6361
- /*! @azure/msal-common v9.0.1 2022-12-07 */
6553
+ /*! @azure/msal-common v10.0.0 2023-02-06 */
6362
6554
  /*
6363
6555
  * Copyright (c) Microsoft Corporation. All rights reserved.
6364
6556
  * Licensed under the MIT License.
@@ -6372,7 +6564,7 @@
6372
6564
  ProtocolMode["OIDC"] = "OIDC";
6373
6565
  })(exports.ProtocolMode || (exports.ProtocolMode = {}));
6374
6566
 
6375
- /*! @azure/msal-common v9.0.1 2022-12-07 */
6567
+ /*! @azure/msal-common v10.0.0 2023-02-06 */
6376
6568
 
6377
6569
  /*
6378
6570
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6449,7 +6641,7 @@
6449
6641
  return AuthorityMetadataEntity;
6450
6642
  }());
6451
6643
 
6452
- /*! @azure/msal-common v9.0.1 2022-12-07 */
6644
+ /*! @azure/msal-common v10.0.0 2023-02-06 */
6453
6645
  /*
6454
6646
  * Copyright (c) Microsoft Corporation. All rights reserved.
6455
6647
  * Licensed under the MIT License.
@@ -6459,7 +6651,7 @@
6459
6651
  response.hasOwnProperty("metadata"));
6460
6652
  }
6461
6653
 
6462
- /*! @azure/msal-common v9.0.1 2022-12-07 */
6654
+ /*! @azure/msal-common v10.0.0 2023-02-06 */
6463
6655
  /*
6464
6656
  * Copyright (c) Microsoft Corporation. All rights reserved.
6465
6657
  * Licensed under the MIT License.
@@ -6469,68 +6661,72 @@
6469
6661
  response.hasOwnProperty("error_description"));
6470
6662
  }
6471
6663
 
6472
- /*! @azure/msal-common v9.0.1 2022-12-07 */
6664
+ /*! @azure/msal-common v10.0.0 2023-02-06 */
6473
6665
 
6474
6666
  /*
6475
6667
  * Copyright (c) Microsoft Corporation. All rights reserved.
6476
6668
  * Licensed under the MIT License.
6477
6669
  */
6478
6670
  var RegionDiscovery = /** @class */ (function () {
6479
- function RegionDiscovery(networkInterface) {
6671
+ function RegionDiscovery(networkInterface, performanceClient, correlationId) {
6480
6672
  this.networkInterface = networkInterface;
6673
+ this.performanceClient = performanceClient;
6674
+ this.correlationId = correlationId;
6481
6675
  }
6482
6676
  /**
6483
6677
  * Detect the region from the application's environment.
6484
6678
  *
6485
6679
  * @returns Promise<string | null>
6486
6680
  */
6487
- RegionDiscovery.prototype.detectRegion = function (environmentRegion, regionDiscoveryMetadata, proxyUrl) {
6681
+ RegionDiscovery.prototype.detectRegion = function (environmentRegion, regionDiscoveryMetadata) {
6682
+ var _a, _b, _c, _d;
6488
6683
  return __awaiter(this, void 0, void 0, function () {
6489
6684
  var autodetectedRegionName, options, localIMDSVersionResponse, currentIMDSVersion, currentIMDSVersionResponse;
6490
- return __generator(this, function (_a) {
6491
- switch (_a.label) {
6685
+ return __generator(this, function (_e) {
6686
+ switch (_e.label) {
6492
6687
  case 0:
6688
+ (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.RegionDiscoveryDetectRegion, this.correlationId);
6493
6689
  autodetectedRegionName = environmentRegion;
6494
6690
  if (!!autodetectedRegionName) return [3 /*break*/, 8];
6495
6691
  options = RegionDiscovery.IMDS_OPTIONS;
6496
- if (proxyUrl) {
6497
- options.proxyUrl = proxyUrl;
6498
- }
6499
- _a.label = 1;
6692
+ _e.label = 1;
6500
6693
  case 1:
6501
- _a.trys.push([1, 6, , 7]);
6694
+ _e.trys.push([1, 6, , 7]);
6695
+ (_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.setPreQueueTime(exports.PerformanceEvents.RegionDiscoveryGetRegionFromIMDS, this.correlationId);
6502
6696
  return [4 /*yield*/, this.getRegionFromIMDS(Constants.IMDS_VERSION, options)];
6503
6697
  case 2:
6504
- localIMDSVersionResponse = _a.sent();
6698
+ localIMDSVersionResponse = _e.sent();
6505
6699
  if (localIMDSVersionResponse.status === ResponseCodes.httpSuccess) {
6506
6700
  autodetectedRegionName = localIMDSVersionResponse.body;
6507
6701
  regionDiscoveryMetadata.region_source = RegionDiscoverySources.IMDS;
6508
6702
  }
6509
6703
  if (!(localIMDSVersionResponse.status === ResponseCodes.httpBadRequest)) return [3 /*break*/, 5];
6704
+ (_c = this.performanceClient) === null || _c === void 0 ? void 0 : _c.setPreQueueTime(exports.PerformanceEvents.RegionDiscoveryGetCurrentVersion, this.correlationId);
6510
6705
  return [4 /*yield*/, this.getCurrentVersion(options)];
6511
6706
  case 3:
6512
- currentIMDSVersion = _a.sent();
6707
+ currentIMDSVersion = _e.sent();
6513
6708
  if (!currentIMDSVersion) {
6514
6709
  regionDiscoveryMetadata.region_source = RegionDiscoverySources.FAILED_AUTO_DETECTION;
6515
6710
  return [2 /*return*/, null];
6516
6711
  }
6712
+ (_d = this.performanceClient) === null || _d === void 0 ? void 0 : _d.setPreQueueTime(exports.PerformanceEvents.RegionDiscoveryGetRegionFromIMDS, this.correlationId);
6517
6713
  return [4 /*yield*/, this.getRegionFromIMDS(currentIMDSVersion, options)];
6518
6714
  case 4:
6519
- currentIMDSVersionResponse = _a.sent();
6715
+ currentIMDSVersionResponse = _e.sent();
6520
6716
  if (currentIMDSVersionResponse.status === ResponseCodes.httpSuccess) {
6521
6717
  autodetectedRegionName = currentIMDSVersionResponse.body;
6522
6718
  regionDiscoveryMetadata.region_source = RegionDiscoverySources.IMDS;
6523
6719
  }
6524
- _a.label = 5;
6720
+ _e.label = 5;
6525
6721
  case 5: return [3 /*break*/, 7];
6526
6722
  case 6:
6527
- _a.sent();
6723
+ _e.sent();
6528
6724
  regionDiscoveryMetadata.region_source = RegionDiscoverySources.FAILED_AUTO_DETECTION;
6529
6725
  return [2 /*return*/, null];
6530
6726
  case 7: return [3 /*break*/, 9];
6531
6727
  case 8:
6532
6728
  regionDiscoveryMetadata.region_source = RegionDiscoverySources.ENVIRONMENT_VARIABLE;
6533
- _a.label = 9;
6729
+ _e.label = 9;
6534
6730
  case 9:
6535
6731
  // If no region was auto detected from the environment or from the IMDS endpoint, mark the attempt as a FAILED_AUTO_DETECTION
6536
6732
  if (!autodetectedRegionName) {
@@ -6548,8 +6744,10 @@
6548
6744
  * @returns Promise<NetworkResponse<string>>
6549
6745
  */
6550
6746
  RegionDiscovery.prototype.getRegionFromIMDS = function (version, options) {
6747
+ var _a;
6551
6748
  return __awaiter(this, void 0, void 0, function () {
6552
- return __generator(this, function (_a) {
6749
+ return __generator(this, function (_b) {
6750
+ (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.RegionDiscoveryGetRegionFromIMDS, this.correlationId);
6553
6751
  return [2 /*return*/, this.networkInterface.sendGetRequestAsync(Constants.IMDS_ENDPOINT + "?api-version=" + version + "&format=text", options, Constants.IMDS_TIMEOUT)];
6554
6752
  });
6555
6753
  });
@@ -6560,24 +6758,28 @@
6560
6758
  * @returns Promise<string | null>
6561
6759
  */
6562
6760
  RegionDiscovery.prototype.getCurrentVersion = function (options) {
6761
+ var _a;
6563
6762
  return __awaiter(this, void 0, void 0, function () {
6564
6763
  var response;
6565
- return __generator(this, function (_a) {
6566
- switch (_a.label) {
6764
+ return __generator(this, function (_b) {
6765
+ switch (_b.label) {
6567
6766
  case 0:
6568
- _a.trys.push([0, 2, , 3]);
6569
- return [4 /*yield*/, this.networkInterface.sendGetRequestAsync(Constants.IMDS_ENDPOINT + "?format=json", options)];
6767
+ (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.RegionDiscoveryGetCurrentVersion, this.correlationId);
6768
+ _b.label = 1;
6570
6769
  case 1:
6571
- response = _a.sent();
6770
+ _b.trys.push([1, 3, , 4]);
6771
+ return [4 /*yield*/, this.networkInterface.sendGetRequestAsync(Constants.IMDS_ENDPOINT + "?format=json", options)];
6772
+ case 2:
6773
+ response = _b.sent();
6572
6774
  // When IMDS endpoint is called without the api version query param, bad request response comes back with latest version.
6573
6775
  if (response.status === ResponseCodes.httpBadRequest && response.body && response.body["newest-versions"] && response.body["newest-versions"].length > 0) {
6574
6776
  return [2 /*return*/, response.body["newest-versions"][0]];
6575
6777
  }
6576
6778
  return [2 /*return*/, null];
6577
- case 2:
6578
- _a.sent();
6779
+ case 3:
6780
+ _b.sent();
6579
6781
  return [2 /*return*/, null];
6580
- case 3: return [2 /*return*/];
6782
+ case 4: return [2 /*return*/];
6581
6783
  }
6582
6784
  });
6583
6785
  });
@@ -6591,7 +6793,7 @@
6591
6793
  return RegionDiscovery;
6592
6794
  }());
6593
6795
 
6594
- /*! @azure/msal-common v9.0.1 2022-12-07 */
6796
+ /*! @azure/msal-common v10.0.0 2023-02-06 */
6595
6797
 
6596
6798
  /*
6597
6799
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6602,16 +6804,17 @@
6602
6804
  * endpoint. It will store the pertinent config data in this object for use during token calls.
6603
6805
  */
6604
6806
  var Authority = /** @class */ (function () {
6605
- function Authority(authority, networkInterface, cacheManager, authorityOptions, logger, proxyUrl) {
6807
+ function Authority(authority, networkInterface, cacheManager, authorityOptions, logger, performanceClient, correlationId) {
6606
6808
  this.canonicalAuthority = authority;
6607
6809
  this._canonicalAuthority.validateAsUri();
6608
6810
  this.networkInterface = networkInterface;
6609
6811
  this.cacheManager = cacheManager;
6610
6812
  this.authorityOptions = authorityOptions;
6611
- this.regionDiscovery = new RegionDiscovery(networkInterface);
6612
6813
  this.regionDiscoveryMetadata = { region_used: undefined, region_source: undefined, region_outcome: undefined };
6613
- this.proxyUrl = proxyUrl || Constants.EMPTY_STRING;
6614
6814
  this.logger = logger;
6815
+ this.performanceClient = performanceClient;
6816
+ this.correlationId = correlationId;
6817
+ this.regionDiscovery = new RegionDiscovery(networkInterface, this.performanceClient, this.correlationId);
6615
6818
  }
6616
6819
  Object.defineProperty(Authority.prototype, "authorityType", {
6617
6820
  // See above for AuthorityType
@@ -6848,23 +7051,27 @@
6848
7051
  * and the /authorize, /token and logout endpoints.
6849
7052
  */
6850
7053
  Authority.prototype.resolveEndpointsAsync = function () {
7054
+ var _a, _b, _c;
6851
7055
  return __awaiter(this, void 0, void 0, function () {
6852
7056
  var metadataEntity, cloudDiscoverySource, endpointSource, cacheKey;
6853
- return __generator(this, function (_a) {
6854
- switch (_a.label) {
7057
+ return __generator(this, function (_d) {
7058
+ switch (_d.label) {
6855
7059
  case 0:
7060
+ (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.AuthorityResolveEndpointsAsync, this.correlationId);
6856
7061
  metadataEntity = this.cacheManager.getAuthorityMetadataByAlias(this.hostnameAndPort);
6857
7062
  if (!metadataEntity) {
6858
7063
  metadataEntity = new AuthorityMetadataEntity();
6859
7064
  metadataEntity.updateCanonicalAuthority(this.canonicalAuthority);
6860
7065
  }
7066
+ (_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.setPreQueueTime(exports.PerformanceEvents.AuthorityUpdateCloudDiscoveryMetadata, this.correlationId);
6861
7067
  return [4 /*yield*/, this.updateCloudDiscoveryMetadata(metadataEntity)];
6862
7068
  case 1:
6863
- cloudDiscoverySource = _a.sent();
7069
+ cloudDiscoverySource = _d.sent();
6864
7070
  this.canonicalAuthority = this.canonicalAuthority.replace(this.hostnameAndPort, metadataEntity.preferred_network);
7071
+ (_c = this.performanceClient) === null || _c === void 0 ? void 0 : _c.setPreQueueTime(exports.PerformanceEvents.AuthorityUpdateEndpointMetadata, this.correlationId);
6865
7072
  return [4 /*yield*/, this.updateEndpointMetadata(metadataEntity)];
6866
7073
  case 2:
6867
- endpointSource = _a.sent();
7074
+ endpointSource = _d.sent();
6868
7075
  if (cloudDiscoverySource !== AuthorityMetadataSource.CACHE && endpointSource !== AuthorityMetadataSource.CACHE) {
6869
7076
  // Reset the expiration time unless both values came from a successful cache lookup
6870
7077
  metadataEntity.resetExpiresAt();
@@ -6883,12 +7090,13 @@
6883
7090
  * @param metadataEntity
6884
7091
  */
6885
7092
  Authority.prototype.updateEndpointMetadata = function (metadataEntity) {
6886
- var _a, _b;
7093
+ var _a, _b, _c, _d, _e, _f;
6887
7094
  return __awaiter(this, void 0, void 0, function () {
6888
7095
  var metadata, harcodedMetadata;
6889
- return __generator(this, function (_c) {
6890
- switch (_c.label) {
7096
+ return __generator(this, function (_g) {
7097
+ switch (_g.label) {
6891
7098
  case 0:
7099
+ (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.AuthorityUpdateEndpointMetadata, this.correlationId);
6892
7100
  metadata = this.getEndpointMetadataFromConfig();
6893
7101
  if (metadata) {
6894
7102
  metadataEntity.updateEndpointMetadata(metadata, false);
@@ -6899,25 +7107,28 @@
6899
7107
  return [2 /*return*/, AuthorityMetadataSource.CACHE];
6900
7108
  }
6901
7109
  harcodedMetadata = this.getEndpointMetadataFromHardcodedValues();
7110
+ (_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.setPreQueueTime(exports.PerformanceEvents.AuthorityGetEndpointMetadataFromNetwork, this.correlationId);
6902
7111
  return [4 /*yield*/, this.getEndpointMetadataFromNetwork()];
6903
7112
  case 1:
6904
- metadata = _c.sent();
7113
+ metadata = _g.sent();
6905
7114
  if (!metadata) return [3 /*break*/, 4];
6906
- if (!((_a = this.authorityOptions.azureRegionConfiguration) === null || _a === void 0 ? void 0 : _a.azureRegion)) return [3 /*break*/, 3];
7115
+ if (!((_c = this.authorityOptions.azureRegionConfiguration) === null || _c === void 0 ? void 0 : _c.azureRegion)) return [3 /*break*/, 3];
7116
+ (_d = this.performanceClient) === null || _d === void 0 ? void 0 : _d.setPreQueueTime(exports.PerformanceEvents.AuthorityUpdateMetadataWithRegionalInformation, this.correlationId);
6907
7117
  return [4 /*yield*/, this.updateMetadataWithRegionalInformation(metadata)];
6908
7118
  case 2:
6909
- metadata = _c.sent();
6910
- _c.label = 3;
7119
+ metadata = _g.sent();
7120
+ _g.label = 3;
6911
7121
  case 3:
6912
7122
  metadataEntity.updateEndpointMetadata(metadata, true);
6913
7123
  return [2 /*return*/, AuthorityMetadataSource.NETWORK];
6914
7124
  case 4:
6915
7125
  if (!(harcodedMetadata && !this.authorityOptions.skipAuthorityMetadataCache)) return [3 /*break*/, 7];
6916
- if (!((_b = this.authorityOptions.azureRegionConfiguration) === null || _b === void 0 ? void 0 : _b.azureRegion)) return [3 /*break*/, 6];
7126
+ if (!((_e = this.authorityOptions.azureRegionConfiguration) === null || _e === void 0 ? void 0 : _e.azureRegion)) return [3 /*break*/, 6];
7127
+ (_f = this.performanceClient) === null || _f === void 0 ? void 0 : _f.setPreQueueTime(exports.PerformanceEvents.AuthorityUpdateMetadataWithRegionalInformation, this.correlationId);
6917
7128
  return [4 /*yield*/, this.updateMetadataWithRegionalInformation(harcodedMetadata)];
6918
7129
  case 5:
6919
- harcodedMetadata = _c.sent();
6920
- _c.label = 6;
7130
+ harcodedMetadata = _g.sent();
7131
+ _g.label = 6;
6921
7132
  case 6:
6922
7133
  metadataEntity.updateEndpointMetadata(harcodedMetadata, false);
6923
7134
  return [2 /*return*/, AuthorityMetadataSource.HARDCODED_VALUES];
@@ -6957,25 +7168,24 @@
6957
7168
  * @param hasHardcodedMetadata boolean
6958
7169
  */
6959
7170
  Authority.prototype.getEndpointMetadataFromNetwork = function () {
7171
+ var _a;
6960
7172
  return __awaiter(this, void 0, void 0, function () {
6961
7173
  var options, response;
6962
- return __generator(this, function (_a) {
6963
- switch (_a.label) {
7174
+ return __generator(this, function (_b) {
7175
+ switch (_b.label) {
6964
7176
  case 0:
7177
+ (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.AuthorityGetEndpointMetadataFromNetwork, this.correlationId);
6965
7178
  options = {};
6966
- if (this.proxyUrl) {
6967
- options.proxyUrl = this.proxyUrl;
6968
- }
6969
- _a.label = 1;
7179
+ _b.label = 1;
6970
7180
  case 1:
6971
- _a.trys.push([1, 3, , 4]);
7181
+ _b.trys.push([1, 3, , 4]);
6972
7182
  return [4 /*yield*/, this.networkInterface.
6973
7183
  sendGetRequestAsync(this.defaultOpenIdConfigurationEndpoint, options)];
6974
7184
  case 2:
6975
- response = _a.sent();
7185
+ response = _b.sent();
6976
7186
  return [2 /*return*/, isOpenIdConfigResponse(response.body) ? response.body : null];
6977
7187
  case 3:
6978
- _a.sent();
7188
+ _b.sent();
6979
7189
  return [2 /*return*/, null];
6980
7190
  case 4: return [2 /*return*/];
6981
7191
  }
@@ -6995,25 +7205,28 @@
6995
7205
  * Update the retrieved metadata with regional information.
6996
7206
  */
6997
7207
  Authority.prototype.updateMetadataWithRegionalInformation = function (metadata) {
6998
- var _a, _b, _c, _d, _e;
7208
+ var _a, _b, _c, _d, _e, _f, _g;
6999
7209
  return __awaiter(this, void 0, void 0, function () {
7000
7210
  var autodetectedRegionName, azureRegion;
7001
- return __generator(this, function (_f) {
7002
- switch (_f.label) {
7003
- case 0: return [4 /*yield*/, this.regionDiscovery.detectRegion((_a = this.authorityOptions.azureRegionConfiguration) === null || _a === void 0 ? void 0 : _a.environmentRegion, this.regionDiscoveryMetadata, this.proxyUrl)];
7211
+ return __generator(this, function (_h) {
7212
+ switch (_h.label) {
7213
+ case 0:
7214
+ (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.AuthorityUpdateMetadataWithRegionalInformation, this.correlationId);
7215
+ (_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.setPreQueueTime(exports.PerformanceEvents.RegionDiscoveryDetectRegion, this.correlationId);
7216
+ return [4 /*yield*/, this.regionDiscovery.detectRegion((_c = this.authorityOptions.azureRegionConfiguration) === null || _c === void 0 ? void 0 : _c.environmentRegion, this.regionDiscoveryMetadata)];
7004
7217
  case 1:
7005
- autodetectedRegionName = _f.sent();
7006
- azureRegion = ((_b = this.authorityOptions.azureRegionConfiguration) === null || _b === void 0 ? void 0 : _b.azureRegion) === Constants.AZURE_REGION_AUTO_DISCOVER_FLAG
7218
+ autodetectedRegionName = _h.sent();
7219
+ azureRegion = ((_d = this.authorityOptions.azureRegionConfiguration) === null || _d === void 0 ? void 0 : _d.azureRegion) === Constants.AZURE_REGION_AUTO_DISCOVER_FLAG
7007
7220
  ? autodetectedRegionName
7008
- : (_c = this.authorityOptions.azureRegionConfiguration) === null || _c === void 0 ? void 0 : _c.azureRegion;
7009
- if (((_d = this.authorityOptions.azureRegionConfiguration) === null || _d === void 0 ? void 0 : _d.azureRegion) === Constants.AZURE_REGION_AUTO_DISCOVER_FLAG) {
7221
+ : (_e = this.authorityOptions.azureRegionConfiguration) === null || _e === void 0 ? void 0 : _e.azureRegion;
7222
+ if (((_f = this.authorityOptions.azureRegionConfiguration) === null || _f === void 0 ? void 0 : _f.azureRegion) === Constants.AZURE_REGION_AUTO_DISCOVER_FLAG) {
7010
7223
  this.regionDiscoveryMetadata.region_outcome = autodetectedRegionName ?
7011
7224
  RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_SUCCESSFUL :
7012
7225
  RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_FAILED;
7013
7226
  }
7014
7227
  else {
7015
7228
  if (autodetectedRegionName) {
7016
- this.regionDiscoveryMetadata.region_outcome = (((_e = this.authorityOptions.azureRegionConfiguration) === null || _e === void 0 ? void 0 : _e.azureRegion) === autodetectedRegionName) ?
7229
+ this.regionDiscoveryMetadata.region_outcome = (((_g = this.authorityOptions.azureRegionConfiguration) === null || _g === void 0 ? void 0 : _g.azureRegion) === autodetectedRegionName) ?
7017
7230
  RegionDiscoveryOutcomes.CONFIGURED_MATCHES_DETECTED :
7018
7231
  RegionDiscoveryOutcomes.CONFIGURED_NOT_DETECTED;
7019
7232
  }
@@ -7037,11 +7250,13 @@
7037
7250
  * @param newMetadata
7038
7251
  */
7039
7252
  Authority.prototype.updateCloudDiscoveryMetadata = function (metadataEntity) {
7253
+ var _a, _b;
7040
7254
  return __awaiter(this, void 0, void 0, function () {
7041
7255
  var metadata, metadataEntityExpired, harcodedMetadata;
7042
- return __generator(this, function (_a) {
7043
- switch (_a.label) {
7256
+ return __generator(this, function (_c) {
7257
+ switch (_c.label) {
7044
7258
  case 0:
7259
+ (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.AuthorityUpdateCloudDiscoveryMetadata, this.correlationId);
7045
7260
  this.logger.verbose("Attempting to get cloud discovery metadata in the config");
7046
7261
  this.logger.verbosePii("Known Authorities: " + (this.authorityOptions.knownAuthorities || Constants.NOT_APPLICABLE));
7047
7262
  this.logger.verbosePii("Authority Metadata: " + (this.authorityOptions.authorityMetadata || Constants.NOT_APPLICABLE));
@@ -7064,9 +7279,10 @@
7064
7279
  this.logger.verbose("The metadata entity is expired.");
7065
7280
  }
7066
7281
  this.logger.verbose("Did not find cloud discovery metadata in the cache... Attempting to get cloud discovery metadata from the network.");
7282
+ (_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.setPreQueueTime(exports.PerformanceEvents.AuthorityGetCloudDiscoveryMetadataFromNetwork, this.correlationId);
7067
7283
  return [4 /*yield*/, this.getCloudDiscoveryMetadataFromNetwork()];
7068
7284
  case 1:
7069
- metadata = _a.sent();
7285
+ metadata = _c.sent();
7070
7286
  if (metadata) {
7071
7287
  this.logger.verbose("cloud discovery metadata was successfully returned from getCloudDiscoveryMetadataFromNetwork()");
7072
7288
  metadataEntity.updateCloudDiscoveryMetadata(metadata, true);
@@ -7124,23 +7340,22 @@
7124
7340
  * @param hasHardcodedMetadata boolean
7125
7341
  */
7126
7342
  Authority.prototype.getCloudDiscoveryMetadataFromNetwork = function () {
7343
+ var _a;
7127
7344
  return __awaiter(this, void 0, void 0, function () {
7128
7345
  var instanceDiscoveryEndpoint, options, match, response, typedResponseBody, metadata, error_1, typedError;
7129
- return __generator(this, function (_a) {
7130
- switch (_a.label) {
7346
+ return __generator(this, function (_b) {
7347
+ switch (_b.label) {
7131
7348
  case 0:
7349
+ (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.AuthorityGetCloudDiscoveryMetadataFromNetwork, this.correlationId);
7132
7350
  instanceDiscoveryEndpoint = "" + Constants.AAD_INSTANCE_DISCOVERY_ENDPT + this.canonicalAuthority + "oauth2/v2.0/authorize";
7133
7351
  options = {};
7134
- if (this.proxyUrl) {
7135
- options.proxyUrl = this.proxyUrl;
7136
- }
7137
7352
  match = null;
7138
- _a.label = 1;
7353
+ _b.label = 1;
7139
7354
  case 1:
7140
- _a.trys.push([1, 3, , 4]);
7355
+ _b.trys.push([1, 3, , 4]);
7141
7356
  return [4 /*yield*/, this.networkInterface.sendGetRequestAsync(instanceDiscoveryEndpoint, options)];
7142
7357
  case 2:
7143
- response = _a.sent();
7358
+ response = _b.sent();
7144
7359
  typedResponseBody = void 0;
7145
7360
  metadata = void 0;
7146
7361
  if (isCloudInstanceDiscoveryResponse(response.body)) {
@@ -7168,7 +7383,7 @@
7168
7383
  match = Authority.getCloudDiscoveryMetadataFromNetworkResponse(metadata, this.hostnameAndPort);
7169
7384
  return [3 /*break*/, 4];
7170
7385
  case 3:
7171
- error_1 = _a.sent();
7386
+ error_1 = _b.sent();
7172
7387
  if (error_1 instanceof AuthError) {
7173
7388
  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);
7174
7389
  }
@@ -7313,7 +7528,7 @@
7313
7528
  return Authority;
7314
7529
  }());
7315
7530
 
7316
- /*! @azure/msal-common v9.0.1 2022-12-07 */
7531
+ /*! @azure/msal-common v10.0.0 2023-02-06 */
7317
7532
 
7318
7533
  /*
7319
7534
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7332,16 +7547,18 @@
7332
7547
  * @param networkClient
7333
7548
  * @param protocolMode
7334
7549
  */
7335
- AuthorityFactory.createDiscoveredInstance = function (authorityUri, networkClient, cacheManager, authorityOptions, logger, proxyUrl) {
7550
+ AuthorityFactory.createDiscoveredInstance = function (authorityUri, networkClient, cacheManager, authorityOptions, logger, performanceClient, correlationId) {
7336
7551
  return __awaiter(this, void 0, void 0, function () {
7337
7552
  var acquireTokenAuthority, e_1;
7338
7553
  return __generator(this, function (_a) {
7339
7554
  switch (_a.label) {
7340
7555
  case 0:
7341
- acquireTokenAuthority = AuthorityFactory.createInstance(authorityUri, networkClient, cacheManager, authorityOptions, logger, proxyUrl);
7556
+ performanceClient === null || performanceClient === void 0 ? void 0 : performanceClient.addQueueMeasurement(exports.PerformanceEvents.AuthorityFactoryCreateDiscoveredInstance, correlationId);
7557
+ acquireTokenAuthority = AuthorityFactory.createInstance(authorityUri, networkClient, cacheManager, authorityOptions, logger, performanceClient, correlationId);
7342
7558
  _a.label = 1;
7343
7559
  case 1:
7344
7560
  _a.trys.push([1, 3, , 4]);
7561
+ performanceClient === null || performanceClient === void 0 ? void 0 : performanceClient.setPreQueueTime(exports.PerformanceEvents.AuthorityResolveEndpointsAsync, correlationId);
7345
7562
  return [4 /*yield*/, acquireTokenAuthority.resolveEndpointsAsync()];
7346
7563
  case 2:
7347
7564
  _a.sent();
@@ -7364,17 +7581,17 @@
7364
7581
  * @param networkInterface
7365
7582
  * @param protocolMode
7366
7583
  */
7367
- AuthorityFactory.createInstance = function (authorityUrl, networkInterface, cacheManager, authorityOptions, logger, proxyUrl) {
7584
+ AuthorityFactory.createInstance = function (authorityUrl, networkInterface, cacheManager, authorityOptions, logger, performanceClient, correlationId) {
7368
7585
  // Throw error if authority url is empty
7369
7586
  if (StringUtils.isEmpty(authorityUrl)) {
7370
7587
  throw ClientConfigurationError.createUrlEmptyError();
7371
7588
  }
7372
- return new Authority(authorityUrl, networkInterface, cacheManager, authorityOptions, logger, proxyUrl);
7589
+ return new Authority(authorityUrl, networkInterface, cacheManager, authorityOptions, logger, performanceClient, correlationId);
7373
7590
  };
7374
7591
  return AuthorityFactory;
7375
7592
  }());
7376
7593
 
7377
- /*! @azure/msal-common v9.0.1 2022-12-07 */
7594
+ /*! @azure/msal-common v10.0.0 2023-02-06 */
7378
7595
 
7379
7596
  /*
7380
7597
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7405,7 +7622,7 @@
7405
7622
  return ServerTelemetryEntity;
7406
7623
  }());
7407
7624
 
7408
- /*! @azure/msal-common v9.0.1 2022-12-07 */
7625
+ /*! @azure/msal-common v10.0.0 2023-02-06 */
7409
7626
 
7410
7627
  /*
7411
7628
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7433,7 +7650,7 @@
7433
7650
  return ThrottlingEntity;
7434
7651
  }());
7435
7652
 
7436
- /*! @azure/msal-common v9.0.1 2022-12-07 */
7653
+ /*! @azure/msal-common v10.0.0 2023-02-06 */
7437
7654
 
7438
7655
  /*
7439
7656
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7450,7 +7667,7 @@
7450
7667
  }
7451
7668
  };
7452
7669
 
7453
- /*! @azure/msal-common v9.0.1 2022-12-07 */
7670
+ /*! @azure/msal-common v10.0.0 2023-02-06 */
7454
7671
 
7455
7672
  /*
7456
7673
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7495,7 +7712,7 @@
7495
7712
  return JoseHeaderError;
7496
7713
  }(AuthError));
7497
7714
 
7498
- /*! @azure/msal-common v9.0.1 2022-12-07 */
7715
+ /*! @azure/msal-common v10.0.0 2023-02-06 */
7499
7716
 
7500
7717
  /*
7501
7718
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7535,7 +7752,7 @@
7535
7752
  return JoseHeader;
7536
7753
  }());
7537
7754
 
7538
- /*! @azure/msal-common v9.0.1 2022-12-07 */
7755
+ /*! @azure/msal-common v10.0.0 2023-02-06 */
7539
7756
 
7540
7757
  /*
7541
7758
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7594,7 +7811,7 @@
7594
7811
  return AuthenticationHeaderParser;
7595
7812
  }());
7596
7813
 
7597
- /*! @azure/msal-common v9.0.1 2022-12-07 */
7814
+ /*! @azure/msal-common v10.0.0 2023-02-06 */
7598
7815
 
7599
7816
  /*
7600
7817
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7756,7 +7973,7 @@
7756
7973
  return ServerTelemetryManager;
7757
7974
  }());
7758
7975
 
7759
- /*! @azure/msal-common v9.0.1 2022-12-07 */
7976
+ /*! @azure/msal-common v10.0.0 2023-02-06 */
7760
7977
 
7761
7978
  /*
7762
7979
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7785,7 +8002,118 @@
7785
8002
  this.eventsByCorrelationId = new Map();
7786
8003
  this.staticFieldsByCorrelationId = new Map();
7787
8004
  this.measurementsById = new Map();
8005
+ this.queueMeasurements = new Map();
8006
+ this.preQueueTimeByCorrelationId = new Map();
8007
+ this.countersByCorrelationId = new Map();
7788
8008
  }
8009
+ /**
8010
+ * Starts and returns an platform-specific implementation of IPerformanceMeasurement.
8011
+ * Note: this function can be changed to abstract at the next major version bump.
8012
+ *
8013
+ * @param {string} measureName
8014
+ * @param {string} correlationId
8015
+ * @returns {IPerformanceMeasurement}
8016
+ */
8017
+ /* eslint-disable-next-line @typescript-eslint/no-unused-vars */
8018
+ PerformanceClient.prototype.startPerformanceMeasurement = function (measureName, correlationId) {
8019
+ return {};
8020
+ };
8021
+ /**
8022
+ * Starts and returns an platform-specific implementation of IPerformanceMeasurement.
8023
+ * Note: this incorrectly-named function will be removed at the next major version bump.
8024
+ *
8025
+ * @param {string} measureName
8026
+ * @param {string} correlationId
8027
+ * @returns {IPerformanceMeasurement}
8028
+ */
8029
+ /* eslint-disable-next-line @typescript-eslint/no-unused-vars */
8030
+ PerformanceClient.prototype.startPerformanceMeasuremeant = function (measureName, correlationId) {
8031
+ return {};
8032
+ };
8033
+ /**
8034
+ * Get integral fields.
8035
+ * Override to change the set.
8036
+ */
8037
+ PerformanceClient.prototype.getIntFields = function () {
8038
+ return IntFields;
8039
+ };
8040
+ /**
8041
+ * Gets map of pre-queue times by correlation Id
8042
+ *
8043
+ * @param {PerformanceEvents} eventName
8044
+ * @param {string} correlationId
8045
+ * @returns {number}
8046
+ */
8047
+ PerformanceClient.prototype.getPreQueueTime = function (eventName, correlationId) {
8048
+ var preQueueTimesByEvents = this.preQueueTimeByCorrelationId.get(correlationId);
8049
+ if (!preQueueTimesByEvents) {
8050
+ this.logger.trace("PerformanceClient.getPreQueueTime: no pre-queue times found for correlationId: " + correlationId + ", unable to add queue measurement");
8051
+ return;
8052
+ }
8053
+ else if (!preQueueTimesByEvents.get(eventName)) {
8054
+ this.logger.trace("PerformanceClient.getPreQueueTime: no pre-queue time found for " + eventName + ", unable to add queue measurement");
8055
+ return;
8056
+ }
8057
+ return preQueueTimesByEvents.get(eventName);
8058
+ };
8059
+ /**
8060
+ * Calculates the difference between current time and time when function was queued.
8061
+ * Note: It is possible to have 0 as the queue time if the current time and the queued time was the same.
8062
+ *
8063
+ * @param {number} preQueueTime
8064
+ * @param {number} currentTime
8065
+ * @returns {number}
8066
+ */
8067
+ PerformanceClient.prototype.calculateQueuedTime = function (preQueueTime, currentTime) {
8068
+ if (preQueueTime < 1) {
8069
+ this.logger.trace("PerformanceClient: preQueueTime should be a positive integer and not " + preQueueTime);
8070
+ return 0;
8071
+ }
8072
+ if (currentTime < 1) {
8073
+ this.logger.trace("PerformanceClient: currentTime should be a positive integer and not " + currentTime);
8074
+ return 0;
8075
+ }
8076
+ if (currentTime < preQueueTime) {
8077
+ this.logger.trace("PerformanceClient: currentTime is less than preQueueTime, check how time is being retrieved");
8078
+ return 0;
8079
+ }
8080
+ return currentTime - preQueueTime;
8081
+ };
8082
+ /**
8083
+ * Adds queue measurement time to QueueMeasurements array for given correlation ID.
8084
+ *
8085
+ * @param {PerformanceEvents} name
8086
+ * @param {?string} correlationId
8087
+ * @param {?number} time
8088
+ * @returns
8089
+ */
8090
+ PerformanceClient.prototype.addQueueMeasurement = function (eventName, correlationId, queueTime) {
8091
+ if (!correlationId) {
8092
+ this.logger.trace("PerformanceClient.addQueueMeasurement: correlationId not provided for " + eventName + ", cannot add queue measurement");
8093
+ return;
8094
+ }
8095
+ if (queueTime === 0) {
8096
+ // Possible for there to be no queue time after calculation
8097
+ this.logger.trace("PerformanceClient.addQueueMeasurement: queue time provided for " + eventName + " is " + queueTime);
8098
+ }
8099
+ else if (!queueTime) {
8100
+ this.logger.trace("PerformanceClient.addQueueMeasurement: no queue time provided for " + eventName);
8101
+ return;
8102
+ }
8103
+ var queueMeasurement = { eventName: eventName, queueTime: queueTime };
8104
+ // Adds to existing correlation Id if present in queueMeasurements
8105
+ var existingMeasurements = this.queueMeasurements.get(correlationId);
8106
+ if (existingMeasurements) {
8107
+ existingMeasurements.push(queueMeasurement);
8108
+ this.queueMeasurements.set(correlationId, existingMeasurements);
8109
+ }
8110
+ else {
8111
+ // Sets new correlation Id if not present in queueMeasurements
8112
+ this.logger.trace("PerformanceClient.addQueueMeasurement: adding correlationId " + correlationId + " to queue measurements");
8113
+ var measurementArray = [queueMeasurement];
8114
+ this.queueMeasurements.set(correlationId, measurementArray);
8115
+ }
8116
+ };
7789
8117
  /**
7790
8118
  * Starts measuring performance for a given operation. Returns a function that should be used to end the measurement.
7791
8119
  *
@@ -7801,9 +8129,19 @@
7801
8129
  if (!correlationId) {
7802
8130
  this.logger.info("PerformanceClient: No correlation id provided for " + measureName + ", generating", eventCorrelationId);
7803
8131
  }
8132
+ // Duplicate code to address spelling error will be removed at the next major version bump.
7804
8133
  this.logger.trace("PerformanceClient: Performance measurement started for " + measureName, eventCorrelationId);
7805
- var performanceMeasurement = this.startPerformanceMeasuremeant(measureName, eventCorrelationId);
7806
- performanceMeasurement.startMeasurement();
8134
+ var validMeasurement;
8135
+ var performanceMeasuremeant = this.startPerformanceMeasuremeant(measureName, eventCorrelationId);
8136
+ if (performanceMeasuremeant.startMeasurement) {
8137
+ performanceMeasuremeant.startMeasurement();
8138
+ validMeasurement = performanceMeasuremeant;
8139
+ }
8140
+ else {
8141
+ var performanceMeasurement = this.startPerformanceMeasurement(measureName, eventCorrelationId);
8142
+ performanceMeasurement.startMeasurement();
8143
+ validMeasurement = performanceMeasurement;
8144
+ }
7807
8145
  var inProgressEvent = {
7808
8146
  eventId: this.generateId(),
7809
8147
  status: PerformanceEventStatus.InProgress,
@@ -7822,7 +8160,7 @@
7822
8160
  appVersion: (_b = this.applicationTelemetry) === null || _b === void 0 ? void 0 : _b.appVersion,
7823
8161
  };
7824
8162
  this.addStaticFields(staticFields, eventCorrelationId);
7825
- this.cacheMeasurement(inProgressEvent, performanceMeasurement);
8163
+ this.cacheMeasurement(inProgressEvent, validMeasurement);
7826
8164
  // Return the event and functions the caller can use to properly end/flush the measurement
7827
8165
  return {
7828
8166
  endMeasurement: function (event) {
@@ -7842,7 +8180,10 @@
7842
8180
  addStaticFields: function (fields) {
7843
8181
  return _this.addStaticFields(fields, inProgressEvent.correlationId);
7844
8182
  },
7845
- measurement: performanceMeasurement,
8183
+ increment: function (counters) {
8184
+ return _this.increment(counters, inProgressEvent.correlationId);
8185
+ },
8186
+ measurement: validMeasurement,
7846
8187
  event: inProgressEvent
7847
8188
  };
7848
8189
  };
@@ -7893,6 +8234,26 @@
7893
8234
  this.staticFieldsByCorrelationId.set(correlationId, fields);
7894
8235
  }
7895
8236
  };
8237
+ /**
8238
+ * Increment counters to be emitted when the measurements are flushed
8239
+ * @param counters {Counters}
8240
+ * @param correlationId {string} correlation identifier
8241
+ */
8242
+ PerformanceClient.prototype.increment = function (counters, correlationId) {
8243
+ var existing = this.countersByCorrelationId.get(correlationId);
8244
+ if (!existing) {
8245
+ this.logger.trace("PerformanceClient: Setting counters");
8246
+ this.countersByCorrelationId.set(correlationId, __assign({}, counters));
8247
+ return;
8248
+ }
8249
+ this.logger.trace("PerformanceClient: Updating counters");
8250
+ for (var counter in counters) {
8251
+ if (!existing.hasOwnProperty(counter)) {
8252
+ existing[counter] = 0;
8253
+ }
8254
+ existing[counter] += counters[counter];
8255
+ }
8256
+ };
7896
8257
  /**
7897
8258
  * Upserts event into event cache.
7898
8259
  * First key is the correlation id, second key is the event id.
@@ -7932,18 +8293,36 @@
7932
8293
  PerformanceClient.prototype.flushMeasurements = function (measureName, correlationId) {
7933
8294
  var _this = this;
7934
8295
  this.logger.trace("PerformanceClient: Performance measurements flushed for " + measureName, correlationId);
8296
+ /**
8297
+ * Adds all queue time and count measurements for given correlation ID
8298
+ * then deletes queue times for given correlation ID from queueMeasurements map.
8299
+ */
8300
+ var queueMeasurementForCorrelationId = this.queueMeasurements.get(correlationId);
8301
+ if (!queueMeasurementForCorrelationId) {
8302
+ this.logger.trace("PerformanceClient: no queue measurements found for for correlationId: " + correlationId);
8303
+ }
8304
+ var totalQueueTime = 0;
8305
+ var totalQueueCount = 0;
8306
+ queueMeasurementForCorrelationId === null || queueMeasurementForCorrelationId === void 0 ? void 0 : queueMeasurementForCorrelationId.forEach(function (measurement) {
8307
+ totalQueueTime += measurement.queueTime;
8308
+ totalQueueCount++;
8309
+ });
7935
8310
  var eventsForCorrelationId = this.eventsByCorrelationId.get(correlationId);
8311
+ var staticFields = this.staticFieldsByCorrelationId.get(correlationId);
8312
+ var counters = this.countersByCorrelationId.get(correlationId);
7936
8313
  if (eventsForCorrelationId) {
7937
- this.discardMeasurements(correlationId);
8314
+ this.discardCache(correlationId);
7938
8315
  /*
7939
8316
  * Manually end incomplete submeasurements to ensure there arent orphaned/never ending events.
7940
8317
  * Incomplete submeasurements are likely an instrumentation bug that should be fixed.
7941
8318
  * IE only supports Map.forEach.
7942
8319
  */
7943
8320
  var completedEvents_1 = [];
8321
+ var incompleteSubsCount_1 = 0;
7944
8322
  eventsForCorrelationId.forEach(function (event) {
7945
8323
  if (event.name !== measureName && event.status !== PerformanceEventStatus.Completed) {
7946
8324
  _this.logger.trace("PerformanceClient: Incomplete submeasurement " + event.name + " found for " + measureName, correlationId);
8325
+ incompleteSubsCount_1++;
7947
8326
  var completedEvent = _this.endMeasurement(event);
7948
8327
  if (completedEvent) {
7949
8328
  completedEvents_1.push(completedEvent);
@@ -7985,8 +8364,8 @@
7985
8364
  }
7986
8365
  return previous;
7987
8366
  }, topLevelEvent);
7988
- var staticFields = this.staticFieldsByCorrelationId.get(correlationId);
7989
- var finalEvent = __assign(__assign({}, eventToEmit), staticFields);
8367
+ var finalEvent = __assign(__assign(__assign(__assign({}, eventToEmit), staticFields), counters), { queuedTimeMs: totalQueueTime, queuedCount: totalQueueCount, incompleteSubsCount: incompleteSubsCount_1 });
8368
+ this.truncateIntegralFields(finalEvent, this.getIntFields());
7990
8369
  this.emitEvents([finalEvent], eventToEmit.correlationId);
7991
8370
  }
7992
8371
  else {
@@ -8006,6 +8385,22 @@
8006
8385
  this.logger.trace("PerformanceClient: Performance measurements discarded", correlationId);
8007
8386
  this.eventsByCorrelationId.delete(correlationId);
8008
8387
  };
8388
+ /**
8389
+ * Removes cache for a given correlation id.
8390
+ *
8391
+ * @param {string} correlation identifier
8392
+ */
8393
+ PerformanceClient.prototype.discardCache = function (correlationId) {
8394
+ this.discardMeasurements(correlationId);
8395
+ this.logger.trace("PerformanceClient: Static fields discarded", correlationId);
8396
+ this.staticFieldsByCorrelationId.delete(correlationId);
8397
+ this.logger.trace("PerformanceClient: Counters discarded", correlationId);
8398
+ this.countersByCorrelationId.delete(correlationId);
8399
+ this.logger.trace("PerformanceClient: QueueMeasurements discarded", correlationId);
8400
+ this.queueMeasurements.delete(correlationId);
8401
+ this.logger.trace("PerformanceClient: Pre-queue times discarded", correlationId);
8402
+ this.preQueueTimeByCorrelationId.delete(correlationId);
8403
+ };
8009
8404
  /**
8010
8405
  * Registers a callback function to receive performance events.
8011
8406
  *
@@ -8048,10 +8443,22 @@
8048
8443
  callback.apply(null, [events]);
8049
8444
  });
8050
8445
  };
8446
+ /**
8447
+ * Enforce truncation of integral fields in performance event.
8448
+ * @param {PerformanceEvent} event performance event to update.
8449
+ * @param {Set<string>} intFields integral fields.
8450
+ */
8451
+ PerformanceClient.prototype.truncateIntegralFields = function (event, intFields) {
8452
+ intFields.forEach(function (key) {
8453
+ if (key in event && typeof event[key] === "number") {
8454
+ event[key] = Math.floor(event[key]);
8455
+ }
8456
+ });
8457
+ };
8051
8458
  return PerformanceClient;
8052
8459
  }());
8053
8460
 
8054
- /*! @azure/msal-common v9.0.1 2022-12-07 */
8461
+ /*! @azure/msal-common v10.0.0 2023-02-06 */
8055
8462
 
8056
8463
  /*
8057
8464
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8080,6 +8487,21 @@
8080
8487
  StubPerformanceClient.prototype.startPerformanceMeasuremeant = function () {
8081
8488
  return new StubPerformanceMeasurement();
8082
8489
  };
8490
+ StubPerformanceClient.prototype.startPerformanceMeasurement = function () {
8491
+ return new StubPerformanceMeasurement();
8492
+ };
8493
+ /* eslint-disable-next-line @typescript-eslint/no-unused-vars */
8494
+ StubPerformanceClient.prototype.calculateQueuedTime = function (preQueueTime, currentTime) {
8495
+ return 0;
8496
+ };
8497
+ /* eslint-disable-next-line @typescript-eslint/no-unused-vars */
8498
+ StubPerformanceClient.prototype.addQueueMeasurement = function (eventName, correlationId, queueTime) {
8499
+ return;
8500
+ };
8501
+ /* eslint-disable-next-line @typescript-eslint/no-unused-vars */
8502
+ StubPerformanceClient.prototype.setPreQueueTime = function (eventName, correlationId) {
8503
+ return;
8504
+ };
8083
8505
  return StubPerformanceClient;
8084
8506
  }(PerformanceClient));
8085
8507
 
@@ -9323,17 +9745,17 @@
9323
9745
  var activeAccountValueFilters = this.getItem(activeAccountKeyFilters);
9324
9746
  if (!activeAccountValueFilters) {
9325
9747
  // if new active account cache type isn't found, it's an old version, so look for that instead
9326
- this.logger.trace("No active account filters cache schema found, looking for legacy schema");
9748
+ this.logger.trace("BrowserCacheManager.getActiveAccount: No active account filters cache schema found, looking for legacy schema");
9327
9749
  var activeAccountKeyLocal = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT);
9328
9750
  var activeAccountValueLocal = this.getItem(activeAccountKeyLocal);
9329
9751
  if (!activeAccountValueLocal) {
9330
- this.logger.trace("No active account found");
9752
+ this.logger.trace("BrowserCacheManager.getActiveAccount: No active account found");
9331
9753
  return null;
9332
9754
  }
9333
9755
  var activeAccount = this.getAccountInfoByFilter({ localAccountId: activeAccountValueLocal })[0] || null;
9334
9756
  if (activeAccount) {
9335
- this.logger.trace("Legacy active account cache schema found");
9336
- this.logger.trace("Adding active account filters cache schema");
9757
+ this.logger.trace("BrowserCacheManager.getActiveAccount: Legacy active account cache schema found");
9758
+ this.logger.trace("BrowserCacheManager.getActiveAccount: Adding active account filters cache schema");
9337
9759
  this.setActiveAccount(activeAccount);
9338
9760
  return activeAccount;
9339
9761
  }
@@ -9341,13 +9763,13 @@
9341
9763
  }
9342
9764
  var activeAccountValueObj = this.validateAndParseJson(activeAccountValueFilters);
9343
9765
  if (activeAccountValueObj) {
9344
- this.logger.trace("Active account filters schema found");
9766
+ this.logger.trace("BrowserCacheManager.getActiveAccount: Active account filters schema found");
9345
9767
  return this.getAccountInfoByFilter({
9346
9768
  homeAccountId: activeAccountValueObj.homeAccountId,
9347
9769
  localAccountId: activeAccountValueObj.localAccountId
9348
9770
  })[0] || null;
9349
9771
  }
9350
- this.logger.trace("No active account found");
9772
+ this.logger.trace("BrowserCacheManager.getActiveAccount: No active account found");
9351
9773
  return null;
9352
9774
  };
9353
9775
  /**
@@ -9378,6 +9800,7 @@
9378
9800
  */
9379
9801
  BrowserCacheManager.prototype.getAccountInfoByFilter = function (accountFilter) {
9380
9802
  var allAccounts = this.getAllAccounts();
9803
+ this.logger.trace("BrowserCacheManager.getAccountInfoByFilter: total " + allAccounts.length + " accounts found");
9381
9804
  return allAccounts.filter(function (accountObj) {
9382
9805
  if (accountFilter.username && accountFilter.username.toLowerCase() !== accountObj.username.toLowerCase()) {
9383
9806
  return false;
@@ -9940,7 +10363,7 @@
9940
10363
 
9941
10364
  /* eslint-disable header/header */
9942
10365
  var name = "@azure/msal-browser";
9943
- var version = "2.32.1";
10366
+ var version = "2.33.0";
9944
10367
 
9945
10368
  /*
9946
10369
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -10411,6 +10834,7 @@
10411
10834
  return __generator$1(this, function (_b) {
10412
10835
  switch (_b.label) {
10413
10836
  case 0:
10837
+ this.performanceClient.addQueueMeasurement(exports.PerformanceEvents.InitializeBaseRequest, request.correlationId);
10414
10838
  this.logger.verbose("Initializing BaseAuthRequest");
10415
10839
  authority = request.authority || this.config.auth.authority;
10416
10840
  scopes = __spread(((request && request.scopes) || []));
@@ -10528,6 +10952,7 @@
10528
10952
  return __generator$1(this, function (_a) {
10529
10953
  switch (_a.label) {
10530
10954
  case 0:
10955
+ this.performanceClient.addQueueMeasurement(exports.PerformanceEvents.StandardInteractionClientInitializeAuthorizationCodeRequest, request.correlationId);
10531
10956
  this.logger.verbose("initializeAuthorizationRequest called", request.correlationId);
10532
10957
  return [4 /*yield*/, this.browserCrypto.generatePkceCodes()];
10533
10958
  case 1:
@@ -10628,10 +11053,14 @@
10628
11053
  var clientConfig;
10629
11054
  return __generator$1(this, function (_a) {
10630
11055
  switch (_a.label) {
10631
- case 0: return [4 /*yield*/, this.getClientConfiguration(serverTelemetryManager, authorityUrl, requestAzureCloudOptions)];
11056
+ case 0:
11057
+ this.performanceClient.addQueueMeasurement(exports.PerformanceEvents.StandardInteractionClientCreateAuthCodeClient, this.correlationId);
11058
+ // Create auth module.
11059
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.StandardInteractionClientGetClientConfiguration, this.correlationId);
11060
+ return [4 /*yield*/, this.getClientConfiguration(serverTelemetryManager, authorityUrl, requestAzureCloudOptions)];
10632
11061
  case 1:
10633
11062
  clientConfig = _a.sent();
10634
- return [2 /*return*/, new AuthorizationCodeClient(clientConfig)];
11063
+ return [2 /*return*/, new AuthorizationCodeClient(clientConfig, this.performanceClient)];
10635
11064
  }
10636
11065
  });
10637
11066
  });
@@ -10644,14 +11073,17 @@
10644
11073
  */
10645
11074
  StandardInteractionClient.prototype.getClientConfiguration = function (serverTelemetryManager, requestAuthority, requestAzureCloudOptions) {
10646
11075
  return __awaiter$1(this, void 0, void 0, function () {
10647
- var discoveredAuthority;
11076
+ var discoveredAuthority, logger;
10648
11077
  return __generator$1(this, function (_a) {
10649
11078
  switch (_a.label) {
10650
11079
  case 0:
11080
+ this.performanceClient.addQueueMeasurement(exports.PerformanceEvents.StandardInteractionClientGetClientConfiguration, this.correlationId);
10651
11081
  this.logger.verbose("getClientConfiguration called", this.correlationId);
11082
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.StandardInteractionClientGetDiscoveredAuthority, this.correlationId);
10652
11083
  return [4 /*yield*/, this.getDiscoveredAuthority(requestAuthority, requestAzureCloudOptions)];
10653
11084
  case 1:
10654
11085
  discoveredAuthority = _a.sent();
11086
+ logger = this.config.system.loggerOptions;
10655
11087
  return [2 /*return*/, {
10656
11088
  authOptions: {
10657
11089
  clientId: this.config.auth.clientId,
@@ -10663,9 +11095,9 @@
10663
11095
  preventCorsPreflight: true
10664
11096
  },
10665
11097
  loggerOptions: {
10666
- loggerCallback: this.config.system.loggerOptions.loggerCallback,
10667
- piiLoggingEnabled: this.config.system.loggerOptions.piiLoggingEnabled,
10668
- logLevel: this.config.system.loggerOptions.logLevel,
11098
+ loggerCallback: logger.loggerCallback,
11099
+ piiLoggingEnabled: logger.piiLoggingEnabled,
11100
+ logLevel: logger.logLevel,
10669
11101
  correlationId: this.correlationId
10670
11102
  },
10671
11103
  cryptoInterface: this.browserCrypto,
@@ -10709,13 +11141,15 @@
10709
11141
  * @param requestCorrelationId
10710
11142
  */
10711
11143
  StandardInteractionClient.prototype.getDiscoveredAuthority = function (requestAuthority, requestAzureCloudOptions) {
11144
+ var _a;
10712
11145
  return __awaiter$1(this, void 0, void 0, function () {
10713
11146
  var getAuthorityMeasurement, authorityOptions, userAuthority, builtAuthority;
10714
- return __generator$1(this, function (_a) {
10715
- switch (_a.label) {
11147
+ return __generator$1(this, function (_b) {
11148
+ switch (_b.label) {
10716
11149
  case 0:
11150
+ this.performanceClient.addQueueMeasurement(exports.PerformanceEvents.StandardInteractionClientGetDiscoveredAuthority, this.correlationId);
10717
11151
  this.logger.verbose("getDiscoveredAuthority called", this.correlationId);
10718
- getAuthorityMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.StandardInteractionClientGetDiscoveredAuthority, this.correlationId);
11152
+ getAuthorityMeasurement = (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.startMeasurement(exports.PerformanceEvents.StandardInteractionClientGetDiscoveredAuthority, this.correlationId);
10719
11153
  authorityOptions = {
10720
11154
  protocolMode: this.config.auth.protocolMode,
10721
11155
  knownAuthorities: this.config.auth.knownAuthorities,
@@ -10726,10 +11160,11 @@
10726
11160
  userAuthority = requestAuthority ? requestAuthority : this.config.auth.authority;
10727
11161
  builtAuthority = Authority.generateAuthority(userAuthority, requestAzureCloudOptions || this.config.auth.azureCloudOptions);
10728
11162
  this.logger.verbose("Creating discovered authority with configured authority", this.correlationId);
10729
- return [4 /*yield*/, AuthorityFactory.createDiscoveredInstance(builtAuthority, this.config.system.networkClient, this.browserStorage, authorityOptions, this.logger)
11163
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.AuthorityFactoryCreateDiscoveredInstance, this.correlationId);
11164
+ return [4 /*yield*/, AuthorityFactory.createDiscoveredInstance(builtAuthority, this.config.system.networkClient, this.browserStorage, authorityOptions, this.logger, this.performanceClient, this.correlationId)
10730
11165
  .then(function (result) {
10731
11166
  getAuthorityMeasurement.endMeasurement({
10732
- success: true
11167
+ success: true,
10733
11168
  });
10734
11169
  return result;
10735
11170
  })
@@ -10741,7 +11176,7 @@
10741
11176
  });
10742
11177
  throw error;
10743
11178
  })];
10744
- case 1: return [2 /*return*/, _a.sent()];
11179
+ case 1: return [2 /*return*/, _b.sent()];
10745
11180
  }
10746
11181
  });
10747
11182
  });
@@ -10757,12 +11192,14 @@
10757
11192
  return __generator$1(this, function (_b) {
10758
11193
  switch (_b.label) {
10759
11194
  case 0:
11195
+ this.performanceClient.addQueueMeasurement(exports.PerformanceEvents.StandardInteractionClientInitializeAuthorizationRequest, this.correlationId);
10760
11196
  this.logger.verbose("initializeAuthorizationRequest called", this.correlationId);
10761
11197
  redirectUri = this.getRedirectUri(request.redirectUri);
10762
11198
  browserState = {
10763
11199
  interactionType: interactionType
10764
11200
  };
10765
11201
  state = ProtocolUtils.setRequestState(this.browserCrypto, (request && request.state) || Constants.EMPTY_STRING, browserState);
11202
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.InitializeBaseRequest, this.correlationId);
10766
11203
  _a = [{}];
10767
11204
  return [4 /*yield*/, this.initializeBaseRequest(request)];
10768
11205
  case 1:
@@ -10796,11 +11233,12 @@
10796
11233
  * Abstract class which defines operations for a browser interaction handling class.
10797
11234
  */
10798
11235
  var InteractionHandler = /** @class */ (function () {
10799
- function InteractionHandler(authCodeModule, storageImpl, authCodeRequest, logger) {
11236
+ function InteractionHandler(authCodeModule, storageImpl, authCodeRequest, logger, performanceClient) {
10800
11237
  this.authModule = authCodeModule;
10801
11238
  this.browserStorage = storageImpl;
10802
11239
  this.authCodeRequest = authCodeRequest;
10803
11240
  this.logger = logger;
11241
+ this.performanceClient = performanceClient;
10804
11242
  }
10805
11243
  /**
10806
11244
  * Function to handle response parameters from hash.
@@ -10810,6 +11248,7 @@
10810
11248
  return __awaiter$1(this, void 0, void 0, function () {
10811
11249
  var stateKey, requestState, authCodeResponse;
10812
11250
  return __generator$1(this, function (_a) {
11251
+ this.performanceClient.addQueueMeasurement(exports.PerformanceEvents.HandleCodeResponseFromHash, this.authCodeRequest.correlationId);
10813
11252
  this.logger.verbose("InteractionHandler.handleCodeResponse called");
10814
11253
  // Check that location hash isn't empty.
10815
11254
  if (StringUtils.isEmpty(locationHash)) {
@@ -10832,6 +11271,7 @@
10832
11271
  throw e;
10833
11272
  }
10834
11273
  }
11274
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.HandleCodeResponseFromServer, this.authCodeRequest.correlationId);
10835
11275
  return [2 /*return*/, this.handleCodeResponseFromServer(authCodeResponse, state, authority, networkModule)];
10836
11276
  });
10837
11277
  });
@@ -10851,6 +11291,7 @@
10851
11291
  return __generator$1(this, function (_a) {
10852
11292
  switch (_a.label) {
10853
11293
  case 0:
11294
+ this.performanceClient.addQueueMeasurement(exports.PerformanceEvents.HandleCodeResponseFromServer, this.authCodeRequest.correlationId);
10854
11295
  this.logger.trace("InteractionHandler.handleCodeResponseFromServer called");
10855
11296
  stateKey = this.browserStorage.generateStateKey(state);
10856
11297
  requestState = this.browserStorage.getTemporaryCache(stateKey);
@@ -10862,6 +11303,7 @@
10862
11303
  // Assign code to request
10863
11304
  this.authCodeRequest.code = authCodeResponse.code;
10864
11305
  if (!authCodeResponse.cloud_instance_host_name) return [3 /*break*/, 2];
11306
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.UpdateTokenEndpointAuthority, this.authCodeRequest.correlationId);
10865
11307
  return [4 /*yield*/, this.updateTokenEndpointAuthority(authCodeResponse.cloud_instance_host_name, authority, networkModule)];
10866
11308
  case 1:
10867
11309
  _a.sent();
@@ -10882,6 +11324,8 @@
10882
11324
  this.authCodeRequest.ccsCredential = cachedCcsCred;
10883
11325
  }
10884
11326
  }
11327
+ // Acquire token with retrieved code.
11328
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.AuthClientAcquireToken, this.authCodeRequest.correlationId);
10885
11329
  return [4 /*yield*/, this.authModule.acquireToken(this.authCodeRequest, authCodeResponse)];
10886
11330
  case 3:
10887
11331
  tokenResponse = _a.sent();
@@ -10903,8 +11347,9 @@
10903
11347
  return __generator$1(this, function (_a) {
10904
11348
  switch (_a.label) {
10905
11349
  case 0:
11350
+ this.performanceClient.addQueueMeasurement(exports.PerformanceEvents.UpdateTokenEndpointAuthority, this.authCodeRequest.correlationId);
10906
11351
  cloudInstanceAuthorityUri = "https://" + cloudInstanceHostname + "/" + authority.tenant + "/";
10907
- return [4 /*yield*/, AuthorityFactory.createDiscoveredInstance(cloudInstanceAuthorityUri, networkModule, this.browserStorage, authority.options, this.logger)];
11352
+ return [4 /*yield*/, AuthorityFactory.createDiscoveredInstance(cloudInstanceAuthorityUri, networkModule, this.browserStorage, authority.options, this.logger, this.performanceClient, this.authCodeRequest.correlationId)];
10908
11353
  case 1:
10909
11354
  cloudInstanceAuthority = _a.sent();
10910
11355
  this.authModule.updateAuthority(cloudInstanceAuthority);
@@ -10939,8 +11384,8 @@
10939
11384
  */
10940
11385
  var RedirectHandler = /** @class */ (function (_super) {
10941
11386
  __extends$1(RedirectHandler, _super);
10942
- function RedirectHandler(authCodeModule, storageImpl, authCodeRequest, logger, browserCrypto) {
10943
- var _this = _super.call(this, authCodeModule, storageImpl, authCodeRequest, logger) || this;
11387
+ function RedirectHandler(authCodeModule, storageImpl, authCodeRequest, logger, browserCrypto, performanceClient) {
11388
+ var _this = _super.call(this, authCodeModule, storageImpl, authCodeRequest, logger, performanceClient) || this;
10944
11389
  _this.browserCrypto = browserCrypto;
10945
11390
  return _this;
10946
11391
  }
@@ -11258,7 +11703,10 @@
11258
11703
  var clientConfig;
11259
11704
  return __generator$1(this, function (_a) {
11260
11705
  switch (_a.label) {
11261
- case 0: return [4 /*yield*/, this.getClientConfiguration(serverTelemetryManager, authorityUrl, azureCloudOptions)];
11706
+ case 0:
11707
+ // Create auth module.
11708
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.StandardInteractionClientGetClientConfiguration, this.correlationId);
11709
+ return [4 /*yield*/, this.getClientConfiguration(serverTelemetryManager, authorityUrl, azureCloudOptions)];
11262
11710
  case 1:
11263
11711
  clientConfig = _a.sent();
11264
11712
  return [2 /*return*/, new SilentFlowClient(clientConfig, this.performanceClient)];
@@ -11272,6 +11720,8 @@
11272
11720
  return __generator$1(this, function (_b) {
11273
11721
  switch (_b.label) {
11274
11722
  case 0:
11723
+ this.performanceClient.addQueueMeasurement(exports.PerformanceEvents.InitializeSilentRequest, this.correlationId);
11724
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.InitializeBaseRequest, this.correlationId);
11275
11725
  _a = [__assign$1({}, request)];
11276
11726
  return [4 /*yield*/, this.initializeBaseRequest(request)];
11277
11727
  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 }])];
@@ -12022,7 +12472,9 @@
12022
12472
  var _this = this;
12023
12473
  return __generator$1(this, function (_a) {
12024
12474
  switch (_a.label) {
12025
- case 0: return [4 /*yield*/, this.initializeAuthorizationRequest(request, exports.InteractionType.Redirect)];
12475
+ case 0:
12476
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.StandardInteractionClientInitializeAuthorizationRequest, request.correlationId);
12477
+ return [4 /*yield*/, this.initializeAuthorizationRequest(request, exports.InteractionType.Redirect)];
12026
12478
  case 1:
12027
12479
  validRequest = _a.sent();
12028
12480
  this.browserStorage.updateCacheEntries(validRequest.state, validRequest.nonce, validRequest.authority, validRequest.loginHint || Constants.EMPTY_STRING, validRequest.account || null);
@@ -12037,14 +12489,18 @@
12037
12489
  _a.label = 2;
12038
12490
  case 2:
12039
12491
  _a.trys.push([2, 7, , 8]);
12492
+ // Create auth code request and generate PKCE params
12493
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.StandardInteractionClientInitializeAuthorizationCodeRequest, request.correlationId);
12040
12494
  return [4 /*yield*/, this.initializeAuthorizationCodeRequest(validRequest)];
12041
12495
  case 3:
12042
12496
  authCodeRequest = _a.sent();
12497
+ // Initialize the client
12498
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.StandardInteractionClientCreateAuthCodeClient, request.correlationId);
12043
12499
  return [4 /*yield*/, this.createAuthCodeClient(serverTelemetryManager, validRequest.authority, validRequest.azureCloudOptions)];
12044
12500
  case 4:
12045
12501
  authClient = _a.sent();
12046
12502
  this.logger.verbose("Auth code client created");
12047
- interactionHandler = new RedirectHandler(authClient, this.browserStorage, authCodeRequest, this.logger, this.browserCrypto);
12503
+ interactionHandler = new RedirectHandler(authClient, this.browserStorage, authCodeRequest, this.logger, this.browserCrypto, this.performanceClient);
12048
12504
  return [4 /*yield*/, authClient.getAuthCodeUrl(__assign$1(__assign$1({}, validRequest), { nativeBroker: NativeMessageHandler.isNativeAvailable(this.config, this.logger, this.nativeMessageHandler, request.authenticationScheme) }))];
12049
12505
  case 5:
12050
12506
  navigateUrl = _a.sent();
@@ -12230,12 +12686,13 @@
12230
12686
  if (!currentAuthority) {
12231
12687
  throw BrowserAuthError.createNoCachedAuthorityError();
12232
12688
  }
12689
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.StandardInteractionClientCreateAuthCodeClient, cachedRequest.correlationId);
12233
12690
  return [4 /*yield*/, this.createAuthCodeClient(serverTelemetryManager, currentAuthority)];
12234
12691
  case 1:
12235
12692
  authClient = _a.sent();
12236
12693
  this.logger.verbose("Auth code client created");
12237
12694
  ThrottlingUtils.removeThrottle(this.browserStorage, this.config.auth.clientId, cachedRequest);
12238
- interactionHandler = new RedirectHandler(authClient, this.browserStorage, cachedRequest, this.logger, this.browserCrypto);
12695
+ interactionHandler = new RedirectHandler(authClient, this.browserStorage, cachedRequest, this.logger, this.browserCrypto, this.performanceClient);
12239
12696
  return [4 /*yield*/, interactionHandler.handleCodeResponseFromHash(hash, state, authClient.authority, this.networkClient)];
12240
12697
  case 2: return [2 /*return*/, _a.sent()];
12241
12698
  }
@@ -12270,6 +12727,7 @@
12270
12727
  timeout: this.config.system.redirectNavigationTimeout,
12271
12728
  noHistory: false
12272
12729
  };
12730
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.StandardInteractionClientCreateAuthCodeClient, validLogoutRequest.correlationId);
12273
12731
  return [4 /*yield*/, this.createAuthCodeClient(serverTelemetryManager, logoutRequest && logoutRequest.authority)];
12274
12732
  case 3:
12275
12733
  authClient = _a.sent();
@@ -12417,6 +12875,7 @@
12417
12875
  case 0:
12418
12876
  this.logger.verbose("acquireTokenPopupAsync called");
12419
12877
  serverTelemetryManager = this.initializeServerTelemetryManager(exports.ApiId.acquireTokenPopup);
12878
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.StandardInteractionClientInitializeAuthorizationRequest, request.correlationId);
12420
12879
  return [4 /*yield*/, this.initializeAuthorizationRequest(request, exports.InteractionType.Popup)];
12421
12880
  case 1:
12422
12881
  validRequest = _a.sent();
@@ -12424,9 +12883,13 @@
12424
12883
  _a.label = 2;
12425
12884
  case 2:
12426
12885
  _a.trys.push([2, 8, , 9]);
12886
+ // Create auth code request and generate PKCE params
12887
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.StandardInteractionClientInitializeAuthorizationCodeRequest, request.correlationId);
12427
12888
  return [4 /*yield*/, this.initializeAuthorizationCodeRequest(validRequest)];
12428
12889
  case 3:
12429
12890
  authCodeRequest = _a.sent();
12891
+ // Initialize the client
12892
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.StandardInteractionClientCreateAuthCodeClient, request.correlationId);
12430
12893
  return [4 /*yield*/, this.createAuthCodeClient(serverTelemetryManager, validRequest.authority, validRequest.azureCloudOptions)];
12431
12894
  case 4:
12432
12895
  authClient = _a.sent();
@@ -12439,7 +12902,7 @@
12439
12902
  return [4 /*yield*/, authClient.getAuthCodeUrl(__assign$1(__assign$1({}, validRequest), { nativeBroker: isNativeBroker }))];
12440
12903
  case 5:
12441
12904
  navigateUrl = _a.sent();
12442
- interactionHandler = new InteractionHandler(authClient, this.browserStorage, authCodeRequest, this.logger);
12905
+ interactionHandler = new InteractionHandler(authClient, this.browserStorage, authCodeRequest, this.logger, this.performanceClient);
12443
12906
  popupParameters = {
12444
12907
  popup: popup,
12445
12908
  popupName: popupName,
@@ -12520,6 +12983,8 @@
12520
12983
  case 2:
12521
12984
  // Clear cache on logout
12522
12985
  _a.sent();
12986
+ // Initialize the client
12987
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.StandardInteractionClientCreateAuthCodeClient, validRequest.correlationId);
12523
12988
  return [4 /*yield*/, this.createAuthCodeClient(serverTelemetryManager, requestAuthority)];
12524
12989
  case 3:
12525
12990
  authClient = _a.sent();
@@ -12913,7 +13378,9 @@
12913
13378
  // Default logger options for browser
12914
13379
  var DEFAULT_LOGGER_OPTIONS = {
12915
13380
  // eslint-disable-next-line @typescript-eslint/no-empty-function
12916
- loggerCallback: function () { },
13381
+ loggerCallback: function () {
13382
+ // allow users to not set logger call back
13383
+ },
12917
13384
  logLevel: exports.LogLevel.Info,
12918
13385
  piiLoggingEnabled: false
12919
13386
  };
@@ -12924,6 +13391,7 @@
12924
13391
  useMsrCrypto: false,
12925
13392
  entropy: undefined
12926
13393
  } });
13394
+ var providedSystemOptions = __assign$1(__assign$1({}, userInputSystem), { loggerOptions: (userInputSystem === null || userInputSystem === void 0 ? void 0 : userInputSystem.loggerOptions) || DEFAULT_LOGGER_OPTIONS });
12927
13395
  var DEFAULT_TELEMETRY_OPTIONS = {
12928
13396
  application: {
12929
13397
  appName: Constants.EMPTY_STRING,
@@ -12933,7 +13401,7 @@
12933
13401
  var overlayedConfig = {
12934
13402
  auth: __assign$1(__assign$1({}, DEFAULT_AUTH_OPTIONS), userInputAuth),
12935
13403
  cache: __assign$1(__assign$1({}, DEFAULT_CACHE_OPTIONS), userInputCache),
12936
- system: __assign$1(__assign$1({}, DEFAULT_BROWSER_SYSTEM_OPTIONS), userInputSystem),
13404
+ system: __assign$1(__assign$1({}, DEFAULT_BROWSER_SYSTEM_OPTIONS), providedSystemOptions),
12937
13405
  telemetry: __assign$1(__assign$1({}, DEFAULT_TELEMETRY_OPTIONS), userInputTelemetry)
12938
13406
  };
12939
13407
  return overlayedConfig;
@@ -12945,8 +13413,8 @@
12945
13413
  */
12946
13414
  var SilentHandler = /** @class */ (function (_super) {
12947
13415
  __extends$1(SilentHandler, _super);
12948
- function SilentHandler(authCodeModule, storageImpl, authCodeRequest, logger, systemOptions) {
12949
- var _this = _super.call(this, authCodeModule, storageImpl, authCodeRequest, logger) || this;
13416
+ function SilentHandler(authCodeModule, storageImpl, authCodeRequest, logger, systemOptions, performanceClient) {
13417
+ var _this = _super.call(this, authCodeModule, storageImpl, authCodeRequest, logger, performanceClient) || this;
12950
13418
  _this.navigateFrameWait = systemOptions.navigateFrameWait;
12951
13419
  _this.pollIntervalMilliseconds = systemOptions.pollIntervalMilliseconds;
12952
13420
  return _this;
@@ -12958,24 +13426,20 @@
12958
13426
  */
12959
13427
  SilentHandler.prototype.initiateAuthRequest = function (requestUrl) {
12960
13428
  return __awaiter$1(this, void 0, void 0, function () {
12961
- var _a;
12962
- return __generator$1(this, function (_b) {
12963
- switch (_b.label) {
13429
+ return __generator$1(this, function (_a) {
13430
+ switch (_a.label) {
12964
13431
  case 0:
13432
+ this.performanceClient.addQueueMeasurement(exports.PerformanceEvents.SilentHandlerInitiateAuthRequest, this.authCodeRequest.correlationId);
12965
13433
  if (StringUtils.isEmpty(requestUrl)) {
12966
13434
  // Throw error if request URL is empty.
12967
13435
  this.logger.info("Navigate url is empty");
12968
13436
  throw BrowserAuthError.createEmptyNavigationUriError();
12969
13437
  }
12970
13438
  if (!this.navigateFrameWait) return [3 /*break*/, 2];
13439
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.SilentHandlerLoadFrame, this.authCodeRequest.correlationId);
12971
13440
  return [4 /*yield*/, this.loadFrame(requestUrl)];
12972
- case 1:
12973
- _a = _b.sent();
12974
- return [3 /*break*/, 3];
12975
- case 2:
12976
- _a = this.loadFrameSync(requestUrl);
12977
- _b.label = 3;
12978
- case 3: return [2 /*return*/, _a];
13441
+ case 1: return [2 /*return*/, _a.sent()];
13442
+ case 2: return [2 /*return*/, this.loadFrameSync(requestUrl)];
12979
13443
  }
12980
13444
  });
12981
13445
  });
@@ -12987,6 +13451,7 @@
12987
13451
  */
12988
13452
  SilentHandler.prototype.monitorIframeForHash = function (iframe, timeout) {
12989
13453
  var _this = this;
13454
+ this.performanceClient.addQueueMeasurement(exports.PerformanceEvents.SilentHandlerMonitorIframeForHash, this.authCodeRequest.correlationId);
12990
13455
  return new Promise(function (resolve, reject) {
12991
13456
  if (timeout < DEFAULT_IFRAME_TIMEOUT_MS) {
12992
13457
  _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.");
@@ -13035,11 +13500,12 @@
13035
13500
  * @ignore
13036
13501
  */
13037
13502
  SilentHandler.prototype.loadFrame = function (urlNavigate) {
13503
+ var _this = this;
13504
+ this.performanceClient.addQueueMeasurement(exports.PerformanceEvents.SilentHandlerLoadFrame, this.authCodeRequest.correlationId);
13038
13505
  /*
13039
13506
  * This trick overcomes iframe navigation in IE
13040
13507
  * IE does not load the page consistently in iframe
13041
13508
  */
13042
- var _this = this;
13043
13509
  return new Promise(function (resolve, reject) {
13044
13510
  var frameHandle = _this.createHiddenIframe();
13045
13511
  setTimeout(function () {
@@ -13114,6 +13580,7 @@
13114
13580
  return __generator$1(this, function (_a) {
13115
13581
  switch (_a.label) {
13116
13582
  case 0:
13583
+ this.performanceClient.addQueueMeasurement(exports.PerformanceEvents.SilentIframeClientAcquireToken, request.correlationId);
13117
13584
  this.logger.verbose("acquireTokenByIframe called");
13118
13585
  acquireTokenMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.SilentIframeClientAcquireToken, request.correlationId);
13119
13586
  // Check that we have some SSO data
@@ -13127,6 +13594,8 @@
13127
13594
  });
13128
13595
  throw BrowserAuthError.createSilentPromptValueError(request.prompt);
13129
13596
  }
13597
+ // Create silent request
13598
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.StandardInteractionClientInitializeAuthorizationRequest, request.correlationId);
13130
13599
  return [4 /*yield*/, this.initializeAuthorizationRequest(__assign$1(__assign$1({}, request), { prompt: request.prompt || PromptValue.NONE }), exports.InteractionType.Silent)];
13131
13600
  case 1:
13132
13601
  silentRequest = _a.sent();
@@ -13135,10 +13604,13 @@
13135
13604
  _a.label = 2;
13136
13605
  case 2:
13137
13606
  _a.trys.push([2, 5, , 6]);
13607
+ // Initialize the client
13608
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.StandardInteractionClientCreateAuthCodeClient, request.correlationId);
13138
13609
  return [4 /*yield*/, this.createAuthCodeClient(serverTelemetryManager, silentRequest.authority, silentRequest.azureCloudOptions)];
13139
13610
  case 3:
13140
13611
  authClient = _a.sent();
13141
13612
  this.logger.verbose("Auth code client created");
13613
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.SilentIframeClientTokenHelper, request.correlationId);
13142
13614
  return [4 /*yield*/, this.silentTokenHelper(authClient, silentRequest).then(function (result) {
13143
13615
  acquireTokenMeasurement.endMeasurement({
13144
13616
  success: true,
@@ -13185,16 +13657,26 @@
13185
13657
  var _this = this;
13186
13658
  return __generator$1(this, function (_a) {
13187
13659
  switch (_a.label) {
13188
- case 0: return [4 /*yield*/, this.initializeAuthorizationCodeRequest(silentRequest)];
13660
+ case 0:
13661
+ this.performanceClient.addQueueMeasurement(exports.PerformanceEvents.SilentIframeClientTokenHelper, silentRequest.correlationId);
13662
+ // Create auth code request and generate PKCE params
13663
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.StandardInteractionClientInitializeAuthorizationCodeRequest, silentRequest.correlationId);
13664
+ return [4 /*yield*/, this.initializeAuthorizationCodeRequest(silentRequest)];
13189
13665
  case 1:
13190
13666
  authCodeRequest = _a.sent();
13667
+ // Create authorize request url
13668
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.GetAuthCodeUrl, silentRequest.correlationId);
13191
13669
  return [4 /*yield*/, authClient.getAuthCodeUrl(__assign$1(__assign$1({}, silentRequest), { nativeBroker: NativeMessageHandler.isNativeAvailable(this.config, this.logger, this.nativeMessageHandler, silentRequest.authenticationScheme) }))];
13192
13670
  case 2:
13193
13671
  navigateUrl = _a.sent();
13194
- silentHandler = new SilentHandler(authClient, this.browserStorage, authCodeRequest, this.logger, this.config.system);
13672
+ silentHandler = new SilentHandler(authClient, this.browserStorage, authCodeRequest, this.logger, this.config.system, this.performanceClient);
13673
+ // Get the frame handle for the silent request
13674
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.SilentHandlerInitiateAuthRequest, silentRequest.correlationId);
13195
13675
  return [4 /*yield*/, silentHandler.initiateAuthRequest(navigateUrl)];
13196
13676
  case 3:
13197
13677
  msalFrame = _a.sent();
13678
+ // Monitor the window for the hash. Return the string value and close the popup when the hash is received. Default timeout is 60 seconds.
13679
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.SilentHandlerMonitorIframeForHash, silentRequest.correlationId);
13198
13680
  return [4 /*yield*/, silentHandler.monitorIframeForHash(msalFrame, this.config.system.iframeHashTimeout)];
13199
13681
  case 4:
13200
13682
  hash = _a.sent();
@@ -13212,6 +13694,7 @@
13212
13694
  })];
13213
13695
  }
13214
13696
  // Handle response from hash string
13697
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.HandleCodeResponseFromHash, silentRequest.correlationId);
13215
13698
  return [2 /*return*/, silentHandler.handleCodeResponseFromHash(hash, state, authClient.authority, this.networkClient)];
13216
13699
  }
13217
13700
  });
@@ -13240,6 +13723,8 @@
13240
13723
  return __generator$1(this, function (_b) {
13241
13724
  switch (_b.label) {
13242
13725
  case 0:
13726
+ this.performanceClient.addQueueMeasurement(exports.PerformanceEvents.SilentRefreshClientAcquireToken, request.correlationId);
13727
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.InitializeBaseRequest, request.correlationId);
13243
13728
  _a = [__assign$1({}, request)];
13244
13729
  return [4 /*yield*/, this.initializeBaseRequest(request)];
13245
13730
  case 1:
@@ -13251,6 +13736,7 @@
13251
13736
  refreshTokenClient = _b.sent();
13252
13737
  this.logger.verbose("Refresh token client created");
13253
13738
  // Send request to renew token. Auth module will throw errors if token cannot be renewed.
13739
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.RefreshTokenClientAcquireTokenByRefreshToken, request.correlationId);
13254
13740
  return [2 /*return*/, refreshTokenClient.acquireTokenByRefreshToken(silentRequest)
13255
13741
  .then(function (result) {
13256
13742
  acquireTokenMeasurement.endMeasurement({
@@ -13293,7 +13779,10 @@
13293
13779
  var clientConfig;
13294
13780
  return __generator$1(this, function (_a) {
13295
13781
  switch (_a.label) {
13296
- case 0: return [4 /*yield*/, this.getClientConfiguration(serverTelemetryManager, authorityUrl, azureCloudOptions)];
13782
+ case 0:
13783
+ // Create auth module.
13784
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.StandardInteractionClientGetClientConfiguration, this.correlationId);
13785
+ return [4 /*yield*/, this.getClientConfiguration(serverTelemetryManager, authorityUrl, azureCloudOptions)];
13297
13786
  case 1:
13298
13787
  clientConfig = _a.sent();
13299
13788
  return [2 /*return*/, new RefreshTokenClient(clientConfig, this.performanceClient)];
@@ -13424,27 +13913,6 @@
13424
13913
  return EventHandler;
13425
13914
  }());
13426
13915
 
13427
- /*
13428
- * Copyright (c) Microsoft Corporation. All rights reserved.
13429
- * Licensed under the MIT License.
13430
- */
13431
-
13432
- var internals = /*#__PURE__*/Object.freeze({
13433
- __proto__: null,
13434
- BrowserCacheManager: BrowserCacheManager,
13435
- StandardInteractionClient: StandardInteractionClient,
13436
- RedirectClient: RedirectClient,
13437
- PopupClient: PopupClient,
13438
- SilentIframeClient: SilentIframeClient,
13439
- SilentCacheClient: SilentCacheClient,
13440
- SilentRefreshClient: SilentRefreshClient,
13441
- RedirectHandler: RedirectHandler,
13442
- EventHandler: EventHandler,
13443
- NativeMessageHandler: NativeMessageHandler,
13444
- BrowserConstants: BrowserConstants,
13445
- get TemporaryCacheKeys () { return TemporaryCacheKeys; }
13446
- });
13447
-
13448
13916
  /*
13449
13917
  * Copyright (c) Microsoft Corporation. All rights reserved.
13450
13918
  * Licensed under the MIT License.
@@ -14898,86 +15366,271 @@
14898
15366
  /**
14899
15367
  * Removes all cryptographic keys from IndexedDB storage
14900
15368
  */
14901
- CryptoOps.prototype.clearKeystore = function () {
14902
- return __awaiter$1(this, void 0, void 0, function () {
14903
- return __generator$1(this, function (_a) {
14904
- switch (_a.label) {
14905
- case 0: return [4 /*yield*/, this.cache.clear()];
14906
- case 1: return [2 /*return*/, _a.sent()];
14907
- }
14908
- });
14909
- });
15369
+ CryptoOps.prototype.clearKeystore = function () {
15370
+ return __awaiter$1(this, void 0, void 0, function () {
15371
+ return __generator$1(this, function (_a) {
15372
+ switch (_a.label) {
15373
+ case 0: return [4 /*yield*/, this.cache.clear()];
15374
+ case 1: return [2 /*return*/, _a.sent()];
15375
+ }
15376
+ });
15377
+ });
15378
+ };
15379
+ /**
15380
+ * Signs the given object as a jwt payload with private key retrieved by given kid.
15381
+ * @param payload
15382
+ * @param kid
15383
+ */
15384
+ CryptoOps.prototype.signJwt = function (payload, kid, correlationId) {
15385
+ var _a;
15386
+ return __awaiter$1(this, void 0, void 0, function () {
15387
+ var signJwtMeasurement, cachedKeyPair, publicKeyJwk, publicKeyJwkString, encodedKeyIdThumbprint, shrHeader, encodedShrHeader, encodedPayload, tokenString, tokenBuffer, signatureBuffer, encodedSignature, signedJwt;
15388
+ return __generator$1(this, function (_b) {
15389
+ switch (_b.label) {
15390
+ case 0:
15391
+ signJwtMeasurement = (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.startMeasurement(exports.PerformanceEvents.CryptoOptsSignJwt, correlationId);
15392
+ return [4 /*yield*/, this.cache.asymmetricKeys.getItem(kid)];
15393
+ case 1:
15394
+ cachedKeyPair = _b.sent();
15395
+ if (!cachedKeyPair) {
15396
+ throw BrowserAuthError.createSigningKeyNotFoundInStorageError(kid);
15397
+ }
15398
+ return [4 /*yield*/, this.browserCrypto.exportJwk(cachedKeyPair.publicKey)];
15399
+ case 2:
15400
+ publicKeyJwk = _b.sent();
15401
+ publicKeyJwkString = BrowserStringUtils.getSortedObjectString(publicKeyJwk);
15402
+ encodedKeyIdThumbprint = this.b64Encode.urlEncode(JSON.stringify({ kid: kid }));
15403
+ shrHeader = JoseHeader.getShrHeaderString({ kid: encodedKeyIdThumbprint, alg: publicKeyJwk.alg });
15404
+ encodedShrHeader = this.b64Encode.urlEncode(shrHeader);
15405
+ // Generate payload
15406
+ payload.cnf = {
15407
+ jwk: JSON.parse(publicKeyJwkString)
15408
+ };
15409
+ encodedPayload = this.b64Encode.urlEncode(JSON.stringify(payload));
15410
+ tokenString = encodedShrHeader + "." + encodedPayload;
15411
+ tokenBuffer = BrowserStringUtils.stringToArrayBuffer(tokenString);
15412
+ return [4 /*yield*/, this.browserCrypto.sign(cachedKeyPair.privateKey, tokenBuffer)];
15413
+ case 3:
15414
+ signatureBuffer = _b.sent();
15415
+ encodedSignature = this.b64Encode.urlEncodeArr(new Uint8Array(signatureBuffer));
15416
+ signedJwt = tokenString + "." + encodedSignature;
15417
+ if (signJwtMeasurement) {
15418
+ signJwtMeasurement.endMeasurement({
15419
+ success: true
15420
+ });
15421
+ }
15422
+ return [2 /*return*/, signedJwt];
15423
+ }
15424
+ });
15425
+ });
15426
+ };
15427
+ /**
15428
+ * Returns the SHA-256 hash of an input string
15429
+ * @param plainText
15430
+ */
15431
+ CryptoOps.prototype.hashString = function (plainText) {
15432
+ return __awaiter$1(this, void 0, void 0, function () {
15433
+ var hashBuffer, hashBytes;
15434
+ return __generator$1(this, function (_a) {
15435
+ switch (_a.label) {
15436
+ case 0: return [4 /*yield*/, this.browserCrypto.sha256Digest(plainText)];
15437
+ case 1:
15438
+ hashBuffer = _a.sent();
15439
+ hashBytes = new Uint8Array(hashBuffer);
15440
+ return [2 /*return*/, this.b64Encode.urlEncodeArr(hashBytes)];
15441
+ }
15442
+ });
15443
+ });
15444
+ };
15445
+ CryptoOps.POP_KEY_USAGES = ["sign", "verify"];
15446
+ CryptoOps.EXTRACTABLE = true;
15447
+ return CryptoOps;
15448
+ }());
15449
+
15450
+ /*
15451
+ * Copyright (c) Microsoft Corporation. All rights reserved.
15452
+ * Licensed under the MIT License.
15453
+ */
15454
+ var BrowserPerformanceMeasurement = /** @class */ (function () {
15455
+ function BrowserPerformanceMeasurement(name, correlationId) {
15456
+ this.correlationId = correlationId;
15457
+ this.measureName = "msal.measure." + name + "." + this.correlationId;
15458
+ this.startMark = "msal.start." + name + "." + this.correlationId;
15459
+ this.endMark = "msal.end." + name + "." + this.correlationId;
15460
+ }
15461
+ BrowserPerformanceMeasurement.supportsBrowserPerformance = function () {
15462
+ return typeof window !== "undefined" &&
15463
+ typeof window.performance !== "undefined" &&
15464
+ typeof window.performance.mark === "function" &&
15465
+ typeof window.performance.measure === "function" &&
15466
+ typeof window.performance.clearMarks === "function" &&
15467
+ typeof window.performance.clearMeasures === "function" &&
15468
+ typeof window.performance.getEntriesByName === "function";
15469
+ };
15470
+ BrowserPerformanceMeasurement.prototype.startMeasurement = function () {
15471
+ if (BrowserPerformanceMeasurement.supportsBrowserPerformance()) {
15472
+ try {
15473
+ window.performance.mark(this.startMark);
15474
+ }
15475
+ catch (e) {
15476
+ // Silently catch
15477
+ }
15478
+ }
15479
+ };
15480
+ BrowserPerformanceMeasurement.prototype.endMeasurement = function () {
15481
+ if (BrowserPerformanceMeasurement.supportsBrowserPerformance()) {
15482
+ try {
15483
+ window.performance.mark(this.endMark);
15484
+ window.performance.measure(this.measureName, this.startMark, this.endMark);
15485
+ }
15486
+ catch (e) {
15487
+ // Silently catch
15488
+ }
15489
+ }
15490
+ };
15491
+ BrowserPerformanceMeasurement.prototype.flushMeasurement = function () {
15492
+ if (BrowserPerformanceMeasurement.supportsBrowserPerformance()) {
15493
+ try {
15494
+ var entriesForMeasurement = window.performance.getEntriesByName(this.measureName, "measure");
15495
+ if (entriesForMeasurement.length > 0) {
15496
+ var durationMs = entriesForMeasurement[0].duration;
15497
+ window.performance.clearMeasures(this.measureName);
15498
+ window.performance.clearMarks(this.startMark);
15499
+ window.performance.clearMarks(this.endMark);
15500
+ return durationMs;
15501
+ }
15502
+ }
15503
+ catch (e) {
15504
+ // Silently catch and return null
15505
+ }
15506
+ }
15507
+ return null;
15508
+ };
15509
+ return BrowserPerformanceMeasurement;
15510
+ }());
15511
+
15512
+ /*
15513
+ * Copyright (c) Microsoft Corporation. All rights reserved.
15514
+ * Licensed under the MIT License.
15515
+ */
15516
+ var BrowserPerformanceClient = /** @class */ (function (_super) {
15517
+ __extends$1(BrowserPerformanceClient, _super);
15518
+ function BrowserPerformanceClient(clientId, authority, logger, libraryName, libraryVersion, applicationTelemetry, cryptoOptions) {
15519
+ var _this = _super.call(this, clientId, authority, logger, libraryName, libraryVersion, applicationTelemetry) || this;
15520
+ _this.browserCrypto = new BrowserCrypto(_this.logger, cryptoOptions);
15521
+ _this.guidGenerator = new GuidGenerator(_this.browserCrypto);
15522
+ return _this;
15523
+ }
15524
+ BrowserPerformanceClient.prototype.startPerformanceMeasuremeant = function (measureName, correlationId) {
15525
+ return new BrowserPerformanceMeasurement(measureName, correlationId);
15526
+ };
15527
+ BrowserPerformanceClient.prototype.generateId = function () {
15528
+ return this.guidGenerator.generateGuid();
15529
+ };
15530
+ BrowserPerformanceClient.prototype.getPageVisibility = function () {
15531
+ var _a;
15532
+ return ((_a = document.visibilityState) === null || _a === void 0 ? void 0 : _a.toString()) || null;
15533
+ };
15534
+ BrowserPerformanceClient.prototype.supportsBrowserPerformanceNow = function () {
15535
+ return typeof window !== "undefined" &&
15536
+ typeof window.performance !== "undefined" &&
15537
+ typeof window.performance.now === "function";
15538
+ };
15539
+ /**
15540
+ * Starts measuring performance for a given operation. Returns a function that should be used to end the measurement.
15541
+ * Also captures browser page visibilityState.
15542
+ *
15543
+ * @param {PerformanceEvents} measureName
15544
+ * @param {?string} [correlationId]
15545
+ * @returns {((event?: Partial<PerformanceEvent>) => PerformanceEvent| null)}
15546
+ */
15547
+ BrowserPerformanceClient.prototype.startMeasurement = function (measureName, correlationId) {
15548
+ var _this = this;
15549
+ // Capture page visibilityState and then invoke start/end measurement
15550
+ var startPageVisibility = this.getPageVisibility();
15551
+ var inProgressEvent = _super.prototype.startMeasurement.call(this, measureName, correlationId);
15552
+ return __assign$1(__assign$1({}, inProgressEvent), { endMeasurement: function (event) {
15553
+ return inProgressEvent.endMeasurement(__assign$1({ startPageVisibility: startPageVisibility, endPageVisibility: _this.getPageVisibility() }, event));
15554
+ } });
14910
15555
  };
14911
15556
  /**
14912
- * Signs the given object as a jwt payload with private key retrieved by given kid.
14913
- * @param payload
14914
- * @param kid
15557
+ * Adds pre-queue time to preQueueTimeByCorrelationId map.
15558
+ * @param {PerformanceEvents} eventName
15559
+ * @param {?string} correlationId
15560
+ * @returns
14915
15561
  */
14916
- CryptoOps.prototype.signJwt = function (payload, kid, correlationId) {
14917
- var _a;
14918
- return __awaiter$1(this, void 0, void 0, function () {
14919
- var signJwtMeasurement, cachedKeyPair, publicKeyJwk, publicKeyJwkString, encodedKeyIdThumbprint, shrHeader, encodedShrHeader, encodedPayload, tokenString, tokenBuffer, signatureBuffer, encodedSignature, signedJwt;
14920
- return __generator$1(this, function (_b) {
14921
- switch (_b.label) {
14922
- case 0:
14923
- signJwtMeasurement = (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.startMeasurement(exports.PerformanceEvents.CryptoOptsSignJwt, correlationId);
14924
- return [4 /*yield*/, this.cache.asymmetricKeys.getItem(kid)];
14925
- case 1:
14926
- cachedKeyPair = _b.sent();
14927
- if (!cachedKeyPair) {
14928
- throw BrowserAuthError.createSigningKeyNotFoundInStorageError(kid);
14929
- }
14930
- return [4 /*yield*/, this.browserCrypto.exportJwk(cachedKeyPair.publicKey)];
14931
- case 2:
14932
- publicKeyJwk = _b.sent();
14933
- publicKeyJwkString = BrowserStringUtils.getSortedObjectString(publicKeyJwk);
14934
- encodedKeyIdThumbprint = this.b64Encode.urlEncode(JSON.stringify({ kid: kid }));
14935
- shrHeader = JoseHeader.getShrHeaderString({ kid: encodedKeyIdThumbprint, alg: publicKeyJwk.alg });
14936
- encodedShrHeader = this.b64Encode.urlEncode(shrHeader);
14937
- // Generate payload
14938
- payload.cnf = {
14939
- jwk: JSON.parse(publicKeyJwkString)
14940
- };
14941
- encodedPayload = this.b64Encode.urlEncode(JSON.stringify(payload));
14942
- tokenString = encodedShrHeader + "." + encodedPayload;
14943
- tokenBuffer = BrowserStringUtils.stringToArrayBuffer(tokenString);
14944
- return [4 /*yield*/, this.browserCrypto.sign(cachedKeyPair.privateKey, tokenBuffer)];
14945
- case 3:
14946
- signatureBuffer = _b.sent();
14947
- encodedSignature = this.b64Encode.urlEncodeArr(new Uint8Array(signatureBuffer));
14948
- signedJwt = tokenString + "." + encodedSignature;
14949
- if (signJwtMeasurement) {
14950
- signJwtMeasurement.endMeasurement({
14951
- success: true
14952
- });
14953
- }
14954
- return [2 /*return*/, signedJwt];
14955
- }
14956
- });
14957
- });
15562
+ BrowserPerformanceClient.prototype.setPreQueueTime = function (eventName, correlationId) {
15563
+ if (!this.supportsBrowserPerformanceNow()) {
15564
+ this.logger.trace("BrowserPerformanceClient: window performance API not available, unable to set telemetry queue time for " + eventName);
15565
+ return;
15566
+ }
15567
+ if (!correlationId) {
15568
+ this.logger.trace("BrowserPerformanceClient: correlationId for " + eventName + " not provided, unable to set telemetry queue time");
15569
+ return;
15570
+ }
15571
+ var preQueueTimesByEvents = this.preQueueTimeByCorrelationId.get(correlationId);
15572
+ if (preQueueTimesByEvents) {
15573
+ preQueueTimesByEvents.set(eventName, window.performance.now());
15574
+ this.preQueueTimeByCorrelationId.set(correlationId, preQueueTimesByEvents);
15575
+ }
15576
+ else {
15577
+ var preQueueTimes = new Map();
15578
+ preQueueTimes.set(eventName, window.performance.now());
15579
+ this.preQueueTimeByCorrelationId.set(correlationId, preQueueTimes);
15580
+ }
14958
15581
  };
14959
15582
  /**
14960
- * Returns the SHA-256 hash of an input string
14961
- * @param plainText
15583
+ * Calculates and adds queue time measurement for given performance event.
15584
+ *
15585
+ * @param {PerformanceEvents} name
15586
+ * @param {?string} correlationId
15587
+ * @param {?number} preQueueTime
15588
+ * @returns
14962
15589
  */
14963
- CryptoOps.prototype.hashString = function (plainText) {
14964
- return __awaiter$1(this, void 0, void 0, function () {
14965
- var hashBuffer, hashBytes;
14966
- return __generator$1(this, function (_a) {
14967
- switch (_a.label) {
14968
- case 0: return [4 /*yield*/, this.browserCrypto.sha256Digest(plainText)];
14969
- case 1:
14970
- hashBuffer = _a.sent();
14971
- hashBytes = new Uint8Array(hashBuffer);
14972
- return [2 /*return*/, this.b64Encode.urlEncodeArr(hashBytes)];
14973
- }
14974
- });
14975
- });
15590
+ BrowserPerformanceClient.prototype.addQueueMeasurement = function (eventName, correlationId) {
15591
+ if (!this.supportsBrowserPerformanceNow()) {
15592
+ this.logger.trace("BrowserPerformanceClient: window performance API not available, unable to add queue measurement for " + eventName);
15593
+ return;
15594
+ }
15595
+ if (!correlationId) {
15596
+ this.logger.trace("BrowserPerformanceClient: correlationId for " + eventName + " not provided, unable to add queue measurement");
15597
+ return;
15598
+ }
15599
+ var preQueueTime = _super.prototype.getPreQueueTime.call(this, eventName, correlationId);
15600
+ if (!preQueueTime) {
15601
+ return;
15602
+ }
15603
+ var currentTime = window.performance.now();
15604
+ var queueTime = _super.prototype.calculateQueuedTime.call(this, preQueueTime, currentTime);
15605
+ return _super.prototype.addQueueMeasurement.call(this, eventName, correlationId, queueTime);
14976
15606
  };
14977
- CryptoOps.POP_KEY_USAGES = ["sign", "verify"];
14978
- CryptoOps.EXTRACTABLE = true;
14979
- return CryptoOps;
14980
- }());
15607
+ return BrowserPerformanceClient;
15608
+ }(PerformanceClient));
15609
+
15610
+ /*
15611
+ * Copyright (c) Microsoft Corporation. All rights reserved.
15612
+ * Licensed under the MIT License.
15613
+ */
15614
+
15615
+ var internals = /*#__PURE__*/Object.freeze({
15616
+ __proto__: null,
15617
+ BrowserCacheManager: BrowserCacheManager,
15618
+ StandardInteractionClient: StandardInteractionClient,
15619
+ RedirectClient: RedirectClient,
15620
+ PopupClient: PopupClient,
15621
+ SilentIframeClient: SilentIframeClient,
15622
+ SilentCacheClient: SilentCacheClient,
15623
+ SilentRefreshClient: SilentRefreshClient,
15624
+ RedirectHandler: RedirectHandler,
15625
+ EventHandler: EventHandler,
15626
+ NativeMessageHandler: NativeMessageHandler,
15627
+ BrowserConstants: BrowserConstants,
15628
+ get TemporaryCacheKeys () { return TemporaryCacheKeys; },
15629
+ CryptoOps: CryptoOps,
15630
+ NativeAuthError: NativeAuthError,
15631
+ BrowserPerformanceClient: BrowserPerformanceClient,
15632
+ BrowserPerformanceMeasurement: BrowserPerformanceMeasurement
15633
+ });
14981
15634
 
14982
15635
  /*
14983
15636
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -15239,6 +15892,8 @@
15239
15892
  if (!request.code) {
15240
15893
  throw BrowserAuthError.createAuthCodeRequiredError();
15241
15894
  }
15895
+ // Create silent request
15896
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.StandardInteractionClientInitializeAuthorizationRequest, request.correlationId);
15242
15897
  return [4 /*yield*/, this.initializeAuthorizationRequest(request, exports.InteractionType.Silent)];
15243
15898
  case 1:
15244
15899
  silentRequest = _a.sent();
@@ -15248,12 +15903,14 @@
15248
15903
  case 2:
15249
15904
  _a.trys.push([2, 4, , 5]);
15250
15905
  authCodeRequest = __assign$1(__assign$1({}, silentRequest), { code: request.code });
15906
+ // Initialize the client
15907
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.StandardInteractionClientGetClientConfiguration, request.correlationId);
15251
15908
  return [4 /*yield*/, this.getClientConfiguration(serverTelemetryManager, silentRequest.authority)];
15252
15909
  case 3:
15253
15910
  clientConfig = _a.sent();
15254
15911
  authClient = new HybridSpaAuthorizationCodeClient(clientConfig);
15255
15912
  this.logger.verbose("Auth code client created");
15256
- silentHandler = new SilentHandler(authClient, this.browserStorage, authCodeRequest, this.logger, this.config.system);
15913
+ silentHandler = new SilentHandler(authClient, this.browserStorage, authCodeRequest, this.logger, this.config.system, this.performanceClient);
15257
15914
  // Handle auth code parameters from request
15258
15915
  return [2 /*return*/, silentHandler.handleCodeResponseFromServer({
15259
15916
  code: request.code,
@@ -15284,110 +15941,6 @@
15284
15941
  return SilentAuthCodeClient;
15285
15942
  }(StandardInteractionClient));
15286
15943
 
15287
- /*
15288
- * Copyright (c) Microsoft Corporation. All rights reserved.
15289
- * Licensed under the MIT License.
15290
- */
15291
- var BrowserPerformanceMeasurement = /** @class */ (function () {
15292
- function BrowserPerformanceMeasurement(name, correlationId) {
15293
- this.correlationId = correlationId;
15294
- this.measureName = "msal.measure." + name + "." + this.correlationId;
15295
- this.startMark = "msal.start." + name + "." + this.correlationId;
15296
- this.endMark = "msal.end." + name + "." + this.correlationId;
15297
- }
15298
- BrowserPerformanceMeasurement.supportsBrowserPerformance = function () {
15299
- return typeof window !== "undefined" &&
15300
- typeof window.performance !== "undefined" &&
15301
- typeof window.performance.mark === "function" &&
15302
- typeof window.performance.measure === "function" &&
15303
- typeof window.performance.clearMarks === "function" &&
15304
- typeof window.performance.clearMeasures === "function" &&
15305
- typeof window.performance.getEntriesByName === "function";
15306
- };
15307
- BrowserPerformanceMeasurement.prototype.startMeasurement = function () {
15308
- if (BrowserPerformanceMeasurement.supportsBrowserPerformance()) {
15309
- try {
15310
- window.performance.mark(this.startMark);
15311
- }
15312
- catch (e) {
15313
- // Silently catch
15314
- }
15315
- }
15316
- };
15317
- BrowserPerformanceMeasurement.prototype.endMeasurement = function () {
15318
- if (BrowserPerformanceMeasurement.supportsBrowserPerformance()) {
15319
- try {
15320
- window.performance.mark(this.endMark);
15321
- window.performance.measure(this.measureName, this.startMark, this.endMark);
15322
- }
15323
- catch (e) {
15324
- // Silently catch
15325
- }
15326
- }
15327
- };
15328
- BrowserPerformanceMeasurement.prototype.flushMeasurement = function () {
15329
- if (BrowserPerformanceMeasurement.supportsBrowserPerformance()) {
15330
- try {
15331
- var entriesForMeasurement = window.performance.getEntriesByName(this.measureName, "measure");
15332
- if (entriesForMeasurement.length > 0) {
15333
- var durationMs = entriesForMeasurement[0].duration;
15334
- window.performance.clearMeasures(this.measureName);
15335
- window.performance.clearMarks(this.startMark);
15336
- window.performance.clearMarks(this.endMark);
15337
- return durationMs;
15338
- }
15339
- }
15340
- catch (e) {
15341
- // Silently catch and return null
15342
- }
15343
- }
15344
- return null;
15345
- };
15346
- return BrowserPerformanceMeasurement;
15347
- }());
15348
-
15349
- /*
15350
- * Copyright (c) Microsoft Corporation. All rights reserved.
15351
- * Licensed under the MIT License.
15352
- */
15353
- var BrowserPerformanceClient = /** @class */ (function (_super) {
15354
- __extends$1(BrowserPerformanceClient, _super);
15355
- function BrowserPerformanceClient(clientId, authority, logger, libraryName, libraryVersion, applicationTelemetry, cryptoOptions) {
15356
- var _this = _super.call(this, clientId, authority, logger, libraryName, libraryVersion, applicationTelemetry) || this;
15357
- _this.browserCrypto = new BrowserCrypto(_this.logger, cryptoOptions);
15358
- _this.guidGenerator = new GuidGenerator(_this.browserCrypto);
15359
- return _this;
15360
- }
15361
- BrowserPerformanceClient.prototype.startPerformanceMeasuremeant = function (measureName, correlationId) {
15362
- return new BrowserPerformanceMeasurement(measureName, correlationId);
15363
- };
15364
- BrowserPerformanceClient.prototype.generateId = function () {
15365
- return this.guidGenerator.generateGuid();
15366
- };
15367
- BrowserPerformanceClient.prototype.getPageVisibility = function () {
15368
- var _a;
15369
- return ((_a = document.visibilityState) === null || _a === void 0 ? void 0 : _a.toString()) || null;
15370
- };
15371
- /**
15372
- * Starts measuring performance for a given operation. Returns a function that should be used to end the measurement.
15373
- * Also captures browser page visibilityState.
15374
- *
15375
- * @param {PerformanceEvents} measureName
15376
- * @param {?string} [correlationId]
15377
- * @returns {((event?: Partial<PerformanceEvent>) => PerformanceEvent| null)}
15378
- */
15379
- BrowserPerformanceClient.prototype.startMeasurement = function (measureName, correlationId) {
15380
- var _this = this;
15381
- // Capture page visibilityState and then invoke start/end measurement
15382
- var startPageVisibility = this.getPageVisibility();
15383
- var inProgressEvent = _super.prototype.startMeasurement.call(this, measureName, correlationId);
15384
- return __assign$1(__assign$1({}, inProgressEvent), { endMeasurement: function (event) {
15385
- return inProgressEvent.endMeasurement(__assign$1({ startPageVisibility: startPageVisibility, endPageVisibility: _this.getPageVisibility() }, event));
15386
- } });
15387
- };
15388
- return BrowserPerformanceClient;
15389
- }(PerformanceClient));
15390
-
15391
15944
  /*
15392
15945
  * Copyright (c) Microsoft Corporation. All rights reserved.
15393
15946
  * Licensed under the MIT License.
@@ -15454,6 +16007,8 @@
15454
16007
  this.nativeInternalStorage = new BrowserCacheManager(this.config.auth.clientId, nativeCacheOptions, this.browserCrypto, this.logger);
15455
16008
  // Initialize the token cache
15456
16009
  this.tokenCache = new TokenCache(this.config, this.browserStorage, this.logger, this.browserCrypto);
16010
+ // Register listener functions
16011
+ this.trackPageVisibilityWithMeasurement = this.trackPageVisibilityWithMeasurement.bind(this);
15457
16012
  }
15458
16013
  /**
15459
16014
  * Initializer function to perform async startup tasks such as connecting to WAM extension
@@ -15720,6 +16275,16 @@
15720
16275
  return Promise.reject(e);
15721
16276
  });
15722
16277
  };
16278
+ ClientApplication.prototype.trackPageVisibilityWithMeasurement = function () {
16279
+ var measurement = this.ssoSilentMeasurement || this.acquireTokenByCodeAsyncMeasurement;
16280
+ if (!measurement) {
16281
+ return;
16282
+ }
16283
+ this.logger.info("Perf: Visibility change detected in ", measurement.event.name);
16284
+ measurement.increment({
16285
+ visibilityChangeCount: 1,
16286
+ });
16287
+ };
15723
16288
  // #endregion
15724
16289
  // #region Silent Flow
15725
16290
  /**
@@ -15738,16 +16303,21 @@
15738
16303
  * @returns A promise that is fulfilled when this function has completed, or rejected if an error was raised.
15739
16304
  */
15740
16305
  ClientApplication.prototype.ssoSilent = function (request) {
16306
+ var _a;
15741
16307
  return __awaiter$1(this, void 0, void 0, function () {
15742
- var correlationId, validRequest, ssoSilentMeasurement, result, silentIframeClient;
16308
+ var correlationId, validRequest, result, silentIframeClient;
15743
16309
  var _this = this;
15744
- return __generator$1(this, function (_a) {
16310
+ return __generator$1(this, function (_b) {
15745
16311
  correlationId = this.getRequestCorrelationId(request);
15746
16312
  validRequest = __assign$1(__assign$1({}, request), {
15747
16313
  // will be PromptValue.NONE or PromptValue.NO_SESSION
15748
16314
  prompt: request.prompt, correlationId: correlationId });
15749
16315
  this.preflightBrowserEnvironmentCheck(exports.InteractionType.Silent);
15750
- ssoSilentMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.SsoSilent, correlationId);
16316
+ this.ssoSilentMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.SsoSilent, correlationId);
16317
+ (_a = this.ssoSilentMeasurement) === null || _a === void 0 ? void 0 : _a.increment({
16318
+ visibilityChangeCount: 0
16319
+ });
16320
+ document.addEventListener("visibilitychange", this.trackPageVisibilityWithMeasurement);
15751
16321
  this.logger.verbose("ssoSilent called", correlationId);
15752
16322
  this.eventHandler.emitEvent(exports.EventType.SSO_SILENT_START, exports.InteractionType.Silent, validRequest);
15753
16323
  if (this.canUseNative(validRequest)) {
@@ -15766,27 +16336,31 @@
15766
16336
  result = silentIframeClient.acquireToken(validRequest);
15767
16337
  }
15768
16338
  return [2 /*return*/, result.then(function (response) {
16339
+ var _a, _b, _c;
15769
16340
  _this.eventHandler.emitEvent(exports.EventType.SSO_SILENT_SUCCESS, exports.InteractionType.Silent, response);
15770
- ssoSilentMeasurement.addStaticFields({
16341
+ (_a = _this.ssoSilentMeasurement) === null || _a === void 0 ? void 0 : _a.addStaticFields({
15771
16342
  accessTokenSize: response.accessToken.length,
15772
16343
  idTokenSize: response.idToken.length
15773
16344
  });
15774
- ssoSilentMeasurement.endMeasurement({
16345
+ (_b = _this.ssoSilentMeasurement) === null || _b === void 0 ? void 0 : _b.endMeasurement({
15775
16346
  success: true,
15776
16347
  isNativeBroker: response.fromNativeBroker,
15777
16348
  requestId: response.requestId
15778
16349
  });
15779
- ssoSilentMeasurement.flushMeasurement();
16350
+ (_c = _this.ssoSilentMeasurement) === null || _c === void 0 ? void 0 : _c.flushMeasurement();
15780
16351
  return response;
15781
16352
  }).catch(function (e) {
16353
+ var _a, _b;
15782
16354
  _this.eventHandler.emitEvent(exports.EventType.SSO_SILENT_FAILURE, exports.InteractionType.Silent, null, e);
15783
- ssoSilentMeasurement.endMeasurement({
16355
+ (_a = _this.ssoSilentMeasurement) === null || _a === void 0 ? void 0 : _a.endMeasurement({
15784
16356
  errorCode: e.errorCode,
15785
16357
  subErrorCode: e.subError,
15786
16358
  success: false
15787
16359
  });
15788
- ssoSilentMeasurement.flushMeasurement();
16360
+ (_b = _this.ssoSilentMeasurement) === null || _b === void 0 ? void 0 : _b.flushMeasurement();
15789
16361
  throw e;
16362
+ }).finally(function () {
16363
+ document.removeEventListener("visibilitychange", _this.trackPageVisibilityWithMeasurement);
15790
16364
  })];
15791
16365
  });
15792
16366
  });
@@ -15892,16 +16466,42 @@
15892
16466
  * @returns Result of the operation to redeem the authorization code
15893
16467
  */
15894
16468
  ClientApplication.prototype.acquireTokenByCodeAsync = function (request) {
16469
+ var _a;
15895
16470
  return __awaiter$1(this, void 0, void 0, function () {
15896
16471
  var silentAuthCodeClient, silentTokenResult;
15897
- return __generator$1(this, function (_a) {
15898
- switch (_a.label) {
16472
+ var _this = this;
16473
+ return __generator$1(this, function (_b) {
16474
+ switch (_b.label) {
15899
16475
  case 0:
15900
16476
  this.logger.trace("acquireTokenByCodeAsync called", request.correlationId);
16477
+ this.acquireTokenByCodeAsyncMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.AcquireTokenByCodeAsync, request.correlationId);
16478
+ (_a = this.acquireTokenByCodeAsyncMeasurement) === null || _a === void 0 ? void 0 : _a.increment({
16479
+ visibilityChangeCount: 0
16480
+ });
16481
+ document.addEventListener("visibilitychange", this.trackPageVisibilityWithMeasurement);
15901
16482
  silentAuthCodeClient = this.createSilentAuthCodeClient(request.correlationId);
15902
- return [4 /*yield*/, silentAuthCodeClient.acquireToken(request)];
16483
+ return [4 /*yield*/, silentAuthCodeClient.acquireToken(request).then(function (response) {
16484
+ var _a;
16485
+ (_a = _this.acquireTokenByCodeAsyncMeasurement) === null || _a === void 0 ? void 0 : _a.endMeasurement({
16486
+ success: true,
16487
+ fromCache: response.fromCache,
16488
+ isNativeBroker: response.fromNativeBroker,
16489
+ requestId: response.requestId
16490
+ });
16491
+ return response;
16492
+ }).catch(function (tokenRenewalError) {
16493
+ var _a;
16494
+ (_a = _this.acquireTokenByCodeAsyncMeasurement) === null || _a === void 0 ? void 0 : _a.endMeasurement({
16495
+ errorCode: tokenRenewalError.errorCode,
16496
+ subErrorCode: tokenRenewalError.subError,
16497
+ success: false
16498
+ });
16499
+ throw tokenRenewalError;
16500
+ }).finally(function () {
16501
+ document.removeEventListener("visibilitychange", _this.trackPageVisibilityWithMeasurement);
16502
+ })];
15903
16503
  case 1:
15904
- silentTokenResult = _a.sent();
16504
+ silentTokenResult = _b.sent();
15905
16505
  return [2 /*return*/, silentTokenResult];
15906
16506
  }
15907
16507
  });
@@ -15917,6 +16517,7 @@
15917
16517
  ClientApplication.prototype.acquireTokenFromCache = function (silentCacheClient, commonRequest, silentRequest) {
15918
16518
  return __awaiter$1(this, void 0, void 0, function () {
15919
16519
  return __generator$1(this, function (_a) {
16520
+ this.performanceClient.addQueueMeasurement(exports.PerformanceEvents.AcquireTokenFromCache, commonRequest.correlationId);
15920
16521
  switch (silentRequest.cacheLookupPolicy) {
15921
16522
  case exports.CacheLookupPolicy.Default:
15922
16523
  case exports.CacheLookupPolicy.AccessToken:
@@ -15939,12 +16540,14 @@
15939
16540
  return __awaiter$1(this, void 0, void 0, function () {
15940
16541
  var silentRefreshClient;
15941
16542
  return __generator$1(this, function (_a) {
16543
+ this.performanceClient.addQueueMeasurement(exports.PerformanceEvents.AcquireTokenByRefreshToken, commonRequest.correlationId);
15942
16544
  switch (silentRequest.cacheLookupPolicy) {
15943
16545
  case exports.CacheLookupPolicy.Default:
15944
16546
  case exports.CacheLookupPolicy.AccessTokenAndRefreshToken:
15945
16547
  case exports.CacheLookupPolicy.RefreshToken:
15946
16548
  case exports.CacheLookupPolicy.RefreshTokenAndNetwork:
15947
16549
  silentRefreshClient = this.createSilentRefreshClient(commonRequest.correlationId);
16550
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.SilentRefreshClientAcquireToken, commonRequest.correlationId);
15948
16551
  return [2 /*return*/, silentRefreshClient.acquireToken(commonRequest)];
15949
16552
  default:
15950
16553
  throw ClientAuthError.createRefreshRequiredError();
@@ -15962,7 +16565,9 @@
15962
16565
  return __awaiter$1(this, void 0, void 0, function () {
15963
16566
  var silentIframeClient;
15964
16567
  return __generator$1(this, function (_a) {
16568
+ this.performanceClient.addQueueMeasurement(exports.PerformanceEvents.AcquireTokenBySilentIframe, request.correlationId);
15965
16569
  silentIframeClient = this.createSilentIframeClient(request.correlationId);
16570
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.SilentIframeClientAcquireToken, request.correlationId);
15966
16571
  return [2 /*return*/, silentIframeClient.acquireToken(request)];
15967
16572
  });
15968
16573
  });
@@ -16380,7 +16985,10 @@
16380
16985
  */
16381
16986
  function PublicClientApplication(configuration) {
16382
16987
  var _this = _super.call(this, configuration) || this;
16988
+ _this.astsAsyncMeasurement = undefined;
16383
16989
  _this.activeSilentTokenRequests = new Map();
16990
+ // Register listener functions
16991
+ _this.trackPageVisibility = _this.trackPageVisibility.bind(_this);
16384
16992
  return _this;
16385
16993
  }
16386
16994
  /**
@@ -16452,6 +17060,7 @@
16452
17060
  cachedResponse = this.activeSilentTokenRequests.get(silentRequestKey);
16453
17061
  if (typeof cachedResponse === "undefined") {
16454
17062
  this.logger.verbose("acquireTokenSilent called for the first time, storing active request", correlationId);
17063
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.AcquireTokenSilentAsync, correlationId);
16455
17064
  response = this.acquireTokenSilentAsync(__assign$1(__assign$1({}, request), { correlationId: correlationId }), account)
16456
17065
  .then(function (result) {
16457
17066
  _this.activeSilentTokenRequests.delete(silentRequestKey);
@@ -16463,7 +17072,8 @@
16463
17072
  success: true,
16464
17073
  fromCache: result.fromCache,
16465
17074
  isNativeBroker: result.fromNativeBroker,
16466
- requestId: result.requestId
17075
+ cacheLookupPolicy: request.cacheLookupPolicy,
17076
+ requestId: result.requestId,
16467
17077
  });
16468
17078
  atsMeasurement.flushMeasurement();
16469
17079
  return result;
@@ -16493,6 +17103,15 @@
16493
17103
  });
16494
17104
  });
16495
17105
  };
17106
+ PublicClientApplication.prototype.trackPageVisibility = function () {
17107
+ if (!this.astsAsyncMeasurement) {
17108
+ return;
17109
+ }
17110
+ this.logger.info("Perf: Visibility change detected");
17111
+ this.astsAsyncMeasurement.increment({
17112
+ visibilityChangeCount: 1,
17113
+ });
17114
+ };
16496
17115
  /**
16497
17116
  * 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.
16498
17117
  * @param {@link (SilentRequest:type)}
@@ -16500,14 +17119,20 @@
16500
17119
  * @returns {Promise.<AuthenticationResult>} - a promise that is fulfilled when this function has completed, or rejected if an error was raised. Returns the {@link AuthResponse}
16501
17120
  */
16502
17121
  PublicClientApplication.prototype.acquireTokenSilentAsync = function (request, account) {
17122
+ var _a;
16503
17123
  return __awaiter$1(this, void 0, void 0, function () {
16504
- var astsAsyncMeasurement, result, silentRequest, silentCacheClient, silentRequest_1, requestWithCLP_1;
17124
+ var result, silentRequest, silentCacheClient, silentRequest_1, requestWithCLP_1;
16505
17125
  var _this = this;
16506
- return __generator$1(this, function (_a) {
16507
- switch (_a.label) {
17126
+ return __generator$1(this, function (_b) {
17127
+ switch (_b.label) {
16508
17128
  case 0:
17129
+ this.performanceClient.addQueueMeasurement(exports.PerformanceEvents.AcquireTokenSilentAsync, request.correlationId);
16509
17130
  this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_START, exports.InteractionType.Silent, request);
16510
- astsAsyncMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.AcquireTokenSilentAsync, request.correlationId);
17131
+ this.astsAsyncMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.AcquireTokenSilentAsync, request.correlationId);
17132
+ (_a = this.astsAsyncMeasurement) === null || _a === void 0 ? void 0 : _a.increment({
17133
+ visibilityChangeCount: 0
17134
+ });
17135
+ document.addEventListener("visibilitychange", this.trackPageVisibility);
16511
17136
  if (!(NativeMessageHandler.isNativeAvailable(this.config, this.logger, this.nativeExtensionProvider, request.authenticationScheme) && account.nativeAccountId)) return [3 /*break*/, 1];
16512
17137
  this.logger.verbose("acquireTokenSilent - attempting to acquire token from native platform");
16513
17138
  silentRequest = __assign$1(__assign$1({}, request), { account: account });
@@ -16517,7 +17142,7 @@
16517
17142
  // If native token acquisition fails for availability reasons fallback to web flow
16518
17143
  if (e instanceof NativeAuthError && e.isFatal()) {
16519
17144
  this.logger.verbose("acquireTokenSilent - native platform unavailable, falling back to web flow");
16520
- this.nativeExtensionProvider = undefined; // Prevent future requests from continuing to attempt
17145
+ this.nativeExtensionProvider = undefined; // Prevent future requests from continuing to attempt
16521
17146
  silentIframeClient = this.createSilentIframeClient(request.correlationId);
16522
17147
  return [2 /*return*/, silentIframeClient.acquireToken(request)];
16523
17148
  }
@@ -16528,12 +17153,14 @@
16528
17153
  case 1:
16529
17154
  this.logger.verbose("acquireTokenSilent - attempting to acquire token from web flow");
16530
17155
  silentCacheClient = this.createSilentCacheClient(request.correlationId);
17156
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.InitializeSilentRequest, request.correlationId);
16531
17157
  return [4 /*yield*/, silentCacheClient.initializeSilentRequest(request, account)];
16532
17158
  case 2:
16533
- silentRequest_1 = _a.sent();
17159
+ silentRequest_1 = _b.sent();
16534
17160
  requestWithCLP_1 = __assign$1(__assign$1({}, request), {
16535
17161
  // set the request's CacheLookupPolicy to Default if it was not optionally passed in
16536
17162
  cacheLookupPolicy: request.cacheLookupPolicy || exports.CacheLookupPolicy.Default });
17163
+ this.performanceClient.setPreQueueTime(exports.PerformanceEvents.AcquireTokenFromCache, silentRequest_1.correlationId);
16537
17164
  result = this.acquireTokenFromCache(silentCacheClient, silentRequest_1, requestWithCLP_1).catch(function (cacheError) {
16538
17165
  if (requestWithCLP_1.cacheLookupPolicy === exports.CacheLookupPolicy.AccessToken) {
16539
17166
  throw cacheError;
@@ -16541,6 +17168,7 @@
16541
17168
  // block the reload if it occurred inside a hidden iframe
16542
17169
  BrowserUtils.blockReloadInHiddenIframes();
16543
17170
  _this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_NETWORK_START, exports.InteractionType.Silent, silentRequest_1);
17171
+ _this.performanceClient.setPreQueueTime(exports.PerformanceEvents.AcquireTokenByRefreshToken, silentRequest_1.correlationId);
16544
17172
  return _this.acquireTokenByRefreshToken(silentRequest_1, requestWithCLP_1).catch(function (refreshTokenError) {
16545
17173
  var isServerError = refreshTokenError instanceof ServerError;
16546
17174
  var isInteractionRequiredError = refreshTokenError instanceof InteractionRequiredAuthError;
@@ -16554,13 +17182,15 @@
16554
17182
  throw refreshTokenError;
16555
17183
  }
16556
17184
  _this.logger.verbose("Refresh token expired/invalid or CacheLookupPolicy is set to Skip, attempting acquire token by iframe.", request.correlationId);
17185
+ _this.performanceClient.setPreQueueTime(exports.PerformanceEvents.AcquireTokenBySilentIframe, silentRequest_1.correlationId);
16557
17186
  return _this.acquireTokenBySilentIframe(silentRequest_1);
16558
17187
  });
16559
17188
  });
16560
- _a.label = 3;
17189
+ _b.label = 3;
16561
17190
  case 3: return [2 /*return*/, result.then(function (response) {
17191
+ var _a;
16562
17192
  _this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_SUCCESS, exports.InteractionType.Silent, response);
16563
- astsAsyncMeasurement.endMeasurement({
17193
+ (_a = _this.astsAsyncMeasurement) === null || _a === void 0 ? void 0 : _a.endMeasurement({
16564
17194
  success: true,
16565
17195
  fromCache: response.fromCache,
16566
17196
  isNativeBroker: response.fromNativeBroker,
@@ -16568,13 +17198,16 @@
16568
17198
  });
16569
17199
  return response;
16570
17200
  }).catch(function (tokenRenewalError) {
17201
+ var _a;
16571
17202
  _this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_FAILURE, exports.InteractionType.Silent, null, tokenRenewalError);
16572
- astsAsyncMeasurement.endMeasurement({
17203
+ (_a = _this.astsAsyncMeasurement) === null || _a === void 0 ? void 0 : _a.endMeasurement({
16573
17204
  errorCode: tokenRenewalError.errorCode,
16574
17205
  subErrorCode: tokenRenewalError.subError,
16575
17206
  success: false
16576
17207
  });
16577
17208
  throw tokenRenewalError;
17209
+ }).finally(function () {
17210
+ document.removeEventListener("visibilitychange", _this.trackPageVisibility);
16578
17211
  })];
16579
17212
  }
16580
17213
  });