@azure/msal-browser 2.22.1 → 2.23.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 (122) hide show
  1. package/README.md +1 -1
  2. package/dist/_virtual/_tslib.js +1 -1
  3. package/dist/app/ClientApplication.d.ts +24 -1
  4. package/dist/app/ClientApplication.d.ts.map +1 -1
  5. package/dist/app/ClientApplication.js +137 -36
  6. package/dist/app/ClientApplication.js.map +1 -1
  7. package/dist/app/IPublicClientApplication.d.ts +3 -1
  8. package/dist/app/IPublicClientApplication.d.ts.map +1 -1
  9. package/dist/app/IPublicClientApplication.js +7 -1
  10. package/dist/app/IPublicClientApplication.js.map +1 -1
  11. package/dist/app/PublicClientApplication.d.ts.map +1 -1
  12. package/dist/app/PublicClientApplication.js +51 -15
  13. package/dist/app/PublicClientApplication.js.map +1 -1
  14. package/dist/cache/AsyncMemoryStorage.d.ts +3 -2
  15. package/dist/cache/AsyncMemoryStorage.d.ts.map +1 -1
  16. package/dist/cache/AsyncMemoryStorage.js +17 -6
  17. package/dist/cache/AsyncMemoryStorage.js.map +1 -1
  18. package/dist/cache/BrowserCacheManager.js +7 -7
  19. package/dist/cache/BrowserCacheManager.js.map +1 -1
  20. package/dist/cache/BrowserStorage.js +1 -1
  21. package/dist/cache/DatabaseStorage.d.ts +5 -0
  22. package/dist/cache/DatabaseStorage.d.ts.map +1 -1
  23. package/dist/cache/DatabaseStorage.js +65 -13
  24. package/dist/cache/DatabaseStorage.js.map +1 -1
  25. package/dist/cache/MemoryStorage.js +1 -1
  26. package/dist/cache/TokenCache.js +1 -1
  27. package/dist/config/Configuration.d.ts +14 -2
  28. package/dist/config/Configuration.d.ts.map +1 -1
  29. package/dist/config/Configuration.js +16 -9
  30. package/dist/config/Configuration.js.map +1 -1
  31. package/dist/crypto/BrowserCrypto.d.ts.map +1 -1
  32. package/dist/crypto/BrowserCrypto.js +7 -6
  33. package/dist/crypto/BrowserCrypto.js.map +1 -1
  34. package/dist/crypto/CryptoOps.d.ts +12 -3
  35. package/dist/crypto/CryptoOps.d.ts.map +1 -1
  36. package/dist/crypto/CryptoOps.js +71 -36
  37. package/dist/crypto/CryptoOps.js.map +1 -1
  38. package/dist/crypto/GuidGenerator.d.ts +3 -2
  39. package/dist/crypto/GuidGenerator.d.ts.map +1 -1
  40. package/dist/crypto/GuidGenerator.js +4 -3
  41. package/dist/crypto/GuidGenerator.js.map +1 -1
  42. package/dist/crypto/PkceGenerator.js +1 -1
  43. package/dist/crypto/SignedHttpRequest.js +1 -1
  44. package/dist/encode/Base64Decode.d.ts.map +1 -1
  45. package/dist/encode/Base64Decode.js +3 -2
  46. package/dist/encode/Base64Decode.js.map +1 -1
  47. package/dist/encode/Base64Encode.d.ts.map +1 -1
  48. package/dist/encode/Base64Encode.js +5 -4
  49. package/dist/encode/Base64Encode.js.map +1 -1
  50. package/dist/error/BrowserAuthError.js +1 -1
  51. package/dist/error/BrowserConfigurationAuthError.js +1 -1
  52. package/dist/event/EventHandler.js +1 -1
  53. package/dist/event/EventMessage.js +1 -1
  54. package/dist/event/EventType.js +1 -1
  55. package/dist/index.cjs.js +1071 -258
  56. package/dist/index.cjs.js.map +1 -1
  57. package/dist/index.d.ts +2 -1
  58. package/dist/index.d.ts.map +1 -1
  59. package/dist/index.js +3 -2
  60. package/dist/index.js.map +1 -1
  61. package/dist/interaction_client/BaseInteractionClient.d.ts +3 -2
  62. package/dist/interaction_client/BaseInteractionClient.d.ts.map +1 -1
  63. package/dist/interaction_client/BaseInteractionClient.js +4 -3
  64. package/dist/interaction_client/BaseInteractionClient.js.map +1 -1
  65. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.js +1 -1
  66. package/dist/interaction_client/PopupClient.d.ts.map +1 -1
  67. package/dist/interaction_client/PopupClient.js +3 -3
  68. package/dist/interaction_client/PopupClient.js.map +1 -1
  69. package/dist/interaction_client/RedirectClient.d.ts.map +1 -1
  70. package/dist/interaction_client/RedirectClient.js +4 -4
  71. package/dist/interaction_client/RedirectClient.js.map +1 -1
  72. package/dist/interaction_client/SilentAuthCodeClient.d.ts +2 -2
  73. package/dist/interaction_client/SilentAuthCodeClient.d.ts.map +1 -1
  74. package/dist/interaction_client/SilentAuthCodeClient.js +5 -5
  75. package/dist/interaction_client/SilentAuthCodeClient.js.map +1 -1
  76. package/dist/interaction_client/SilentCacheClient.d.ts.map +1 -1
  77. package/dist/interaction_client/SilentCacheClient.js +11 -3
  78. package/dist/interaction_client/SilentCacheClient.js.map +1 -1
  79. package/dist/interaction_client/SilentIframeClient.d.ts +2 -2
  80. package/dist/interaction_client/SilentIframeClient.d.ts.map +1 -1
  81. package/dist/interaction_client/SilentIframeClient.js +21 -7
  82. package/dist/interaction_client/SilentIframeClient.js.map +1 -1
  83. package/dist/interaction_client/SilentRefreshClient.d.ts.map +1 -1
  84. package/dist/interaction_client/SilentRefreshClient.js +16 -4
  85. package/dist/interaction_client/SilentRefreshClient.js.map +1 -1
  86. package/dist/interaction_client/StandardInteractionClient.d.ts +2 -2
  87. package/dist/interaction_client/StandardInteractionClient.d.ts.map +1 -1
  88. package/dist/interaction_client/StandardInteractionClient.js +30 -16
  89. package/dist/interaction_client/StandardInteractionClient.js.map +1 -1
  90. package/dist/interaction_handler/InteractionHandler.js +1 -1
  91. package/dist/interaction_handler/PopupHandler.js +1 -1
  92. package/dist/interaction_handler/RedirectHandler.js +1 -1
  93. package/dist/interaction_handler/SilentHandler.js +1 -1
  94. package/dist/navigation/NavigationClient.js +1 -1
  95. package/dist/network/FetchClient.d.ts.map +1 -1
  96. package/dist/network/FetchClient.js +3 -2
  97. package/dist/network/FetchClient.js.map +1 -1
  98. package/dist/network/XhrClient.js +1 -1
  99. package/dist/packageMetadata.d.ts +1 -1
  100. package/dist/packageMetadata.js +2 -2
  101. package/dist/packageMetadata.js.map +1 -1
  102. package/dist/telemetry/BrowserPerformanceClient.d.ts +19 -0
  103. package/dist/telemetry/BrowserPerformanceClient.d.ts.map +1 -0
  104. package/dist/telemetry/BrowserPerformanceClient.js +52 -0
  105. package/dist/telemetry/BrowserPerformanceClient.js.map +1 -0
  106. package/dist/telemetry/BrowserPerformanceMeasurement.d.ts +13 -0
  107. package/dist/telemetry/BrowserPerformanceMeasurement.d.ts.map +1 -0
  108. package/dist/telemetry/BrowserPerformanceMeasurement.js +66 -0
  109. package/dist/telemetry/BrowserPerformanceMeasurement.js.map +1 -0
  110. package/dist/utils/BrowserConstants.js +1 -1
  111. package/dist/utils/BrowserProtocolUtils.js +1 -1
  112. package/dist/utils/BrowserStringUtils.d.ts.map +1 -1
  113. package/dist/utils/BrowserStringUtils.js +4 -2
  114. package/dist/utils/BrowserStringUtils.js.map +1 -1
  115. package/dist/utils/BrowserUtils.js +2 -2
  116. package/dist/utils/BrowserUtils.js.map +1 -1
  117. package/dist/utils/MathUtils.js +1 -1
  118. package/dist/utils/PopupUtils.js +1 -1
  119. package/lib/msal-browser.js +1071 -258
  120. package/lib/msal-browser.js.map +1 -1
  121. package/lib/msal-browser.min.js +41 -36
  122. package/package.json +2 -2
@@ -1,4 +1,4 @@
1
- /*! @azure/msal-browser v2.22.1 2022-03-07 */
1
+ /*! @azure/msal-browser v2.23.0 2022-04-04 */
2
2
  'use strict';
3
3
  (function (global, factory) {
4
4
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
@@ -107,7 +107,7 @@
107
107
  return ar;
108
108
  }
109
109
 
110
- /*! @azure/msal-common v6.1.0 2022-03-07 */
110
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
111
111
  /*! *****************************************************************************
112
112
  Copyright (c) Microsoft Corporation.
113
113
 
@@ -194,7 +194,7 @@
194
194
  return r;
195
195
  }
196
196
 
197
- /*! @azure/msal-common v6.1.0 2022-03-07 */
197
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
198
198
 
199
199
  /*
200
200
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -319,6 +319,8 @@
319
319
  AADServerParamKeys["X_CLIENT_CURR_TELEM"] = "x-client-current-telemetry";
320
320
  AADServerParamKeys["X_CLIENT_LAST_TELEM"] = "x-client-last-telemetry";
321
321
  AADServerParamKeys["X_MS_LIB_CAPABILITY"] = "x-ms-lib-capability";
322
+ AADServerParamKeys["X_APP_NAME"] = "x-app-name";
323
+ AADServerParamKeys["X_APP_VER"] = "x-app-ver";
322
324
  AADServerParamKeys["POST_LOGOUT_URI"] = "post_logout_redirect_uri";
323
325
  AADServerParamKeys["ID_TOKEN_HINT"] = "id_token_hint";
324
326
  AADServerParamKeys["DEVICE_CODE"] = "device_code";
@@ -558,7 +560,7 @@
558
560
  CacheOutcome["REFRESH_CACHED_ACCESS_TOKEN"] = "4";
559
561
  })(CacheOutcome || (CacheOutcome = {}));
560
562
 
561
- /*! @azure/msal-common v6.1.0 2022-03-07 */
563
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
562
564
 
563
565
  /*
564
566
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -584,8 +586,8 @@
584
586
  _this = _super.call(this, errorString) || this;
585
587
  Object.setPrototypeOf(_this, AuthError.prototype);
586
588
  _this.errorCode = errorCode || Constants.EMPTY_STRING;
587
- _this.errorMessage = errorMessage || "";
588
- _this.subError = suberror || "";
589
+ _this.errorMessage = errorMessage || Constants.EMPTY_STRING;
590
+ _this.subError = suberror || Constants.EMPTY_STRING;
589
591
  _this.name = "AuthError";
590
592
  return _this;
591
593
  }
@@ -602,7 +604,7 @@
602
604
  return AuthError;
603
605
  }(Error));
604
606
 
605
- /*! @azure/msal-common v6.1.0 2022-03-07 */
607
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
606
608
 
607
609
  /*
608
610
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -677,7 +679,7 @@
677
679
  }
678
680
  };
679
681
 
680
- /*! @azure/msal-common v6.1.0 2022-03-07 */
682
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
681
683
 
682
684
  /*
683
685
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1139,7 +1141,7 @@
1139
1141
  return ClientAuthError;
1140
1142
  }(AuthError));
1141
1143
 
1142
- /*! @azure/msal-common v6.1.0 2022-03-07 */
1144
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
1143
1145
 
1144
1146
  /*
1145
1147
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1264,7 +1266,7 @@
1264
1266
  return StringUtils;
1265
1267
  }());
1266
1268
 
1267
- /*! @azure/msal-common v6.1.0 2022-03-07 */
1269
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
1268
1270
 
1269
1271
  /*
1270
1272
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1294,7 +1296,7 @@
1294
1296
  this.localCallback = loggerOptions.loggerCallback || defaultLoggerCallback;
1295
1297
  this.piiLoggingEnabled = loggerOptions.piiLoggingEnabled || false;
1296
1298
  this.level = typeof (loggerOptions.logLevel) === "number" ? loggerOptions.logLevel : exports.LogLevel.Info;
1297
- this.correlationId = loggerOptions.correlationId || "";
1299
+ this.correlationId = loggerOptions.correlationId || Constants.EMPTY_STRING;
1298
1300
  this.packageName = packageName || Constants.EMPTY_STRING;
1299
1301
  this.packageVersion = packageVersion || Constants.EMPTY_STRING;
1300
1302
  }
@@ -1324,7 +1326,7 @@
1324
1326
  logHeader = "[" + timestamp + "]";
1325
1327
  }
1326
1328
  var log = logHeader + " : " + this.packageName + "@" + this.packageVersion + " : " + exports.LogLevel[options.logLevel] + " - " + logMessage;
1327
- // debug(`msal:${LogLevel[options.logLevel]}${options.containsPii ? "-Pii": ""}${options.context ? `:${options.context}` : ""}`)(logMessage);
1329
+ // debug(`msal:${LogLevel[options.logLevel]}${options.containsPii ? "-Pii": Constants.EMPTY_STRING}${options.context ? `:${options.context}` : Constants.EMPTY_STRING}`)(logMessage);
1328
1330
  this.executeCallback(options.logLevel, log, options.containsPii || false);
1329
1331
  };
1330
1332
  /**
@@ -1342,7 +1344,7 @@
1342
1344
  this.logMessage(message, {
1343
1345
  logLevel: exports.LogLevel.Error,
1344
1346
  containsPii: false,
1345
- correlationId: correlationId || ""
1347
+ correlationId: correlationId || Constants.EMPTY_STRING
1346
1348
  });
1347
1349
  };
1348
1350
  /**
@@ -1352,7 +1354,7 @@
1352
1354
  this.logMessage(message, {
1353
1355
  logLevel: exports.LogLevel.Error,
1354
1356
  containsPii: true,
1355
- correlationId: correlationId || ""
1357
+ correlationId: correlationId || Constants.EMPTY_STRING
1356
1358
  });
1357
1359
  };
1358
1360
  /**
@@ -1362,7 +1364,7 @@
1362
1364
  this.logMessage(message, {
1363
1365
  logLevel: exports.LogLevel.Warning,
1364
1366
  containsPii: false,
1365
- correlationId: correlationId || ""
1367
+ correlationId: correlationId || Constants.EMPTY_STRING
1366
1368
  });
1367
1369
  };
1368
1370
  /**
@@ -1372,7 +1374,7 @@
1372
1374
  this.logMessage(message, {
1373
1375
  logLevel: exports.LogLevel.Warning,
1374
1376
  containsPii: true,
1375
- correlationId: correlationId || ""
1377
+ correlationId: correlationId || Constants.EMPTY_STRING
1376
1378
  });
1377
1379
  };
1378
1380
  /**
@@ -1382,7 +1384,7 @@
1382
1384
  this.logMessage(message, {
1383
1385
  logLevel: exports.LogLevel.Info,
1384
1386
  containsPii: false,
1385
- correlationId: correlationId || ""
1387
+ correlationId: correlationId || Constants.EMPTY_STRING
1386
1388
  });
1387
1389
  };
1388
1390
  /**
@@ -1392,7 +1394,7 @@
1392
1394
  this.logMessage(message, {
1393
1395
  logLevel: exports.LogLevel.Info,
1394
1396
  containsPii: true,
1395
- correlationId: correlationId || ""
1397
+ correlationId: correlationId || Constants.EMPTY_STRING
1396
1398
  });
1397
1399
  };
1398
1400
  /**
@@ -1402,7 +1404,7 @@
1402
1404
  this.logMessage(message, {
1403
1405
  logLevel: exports.LogLevel.Verbose,
1404
1406
  containsPii: false,
1405
- correlationId: correlationId || ""
1407
+ correlationId: correlationId || Constants.EMPTY_STRING
1406
1408
  });
1407
1409
  };
1408
1410
  /**
@@ -1412,7 +1414,7 @@
1412
1414
  this.logMessage(message, {
1413
1415
  logLevel: exports.LogLevel.Verbose,
1414
1416
  containsPii: true,
1415
- correlationId: correlationId || ""
1417
+ correlationId: correlationId || Constants.EMPTY_STRING
1416
1418
  });
1417
1419
  };
1418
1420
  /**
@@ -1422,7 +1424,7 @@
1422
1424
  this.logMessage(message, {
1423
1425
  logLevel: exports.LogLevel.Trace,
1424
1426
  containsPii: false,
1425
- correlationId: correlationId || ""
1427
+ correlationId: correlationId || Constants.EMPTY_STRING
1426
1428
  });
1427
1429
  };
1428
1430
  /**
@@ -1432,7 +1434,7 @@
1432
1434
  this.logMessage(message, {
1433
1435
  logLevel: exports.LogLevel.Trace,
1434
1436
  containsPii: true,
1435
- correlationId: correlationId || ""
1437
+ correlationId: correlationId || Constants.EMPTY_STRING
1436
1438
  });
1437
1439
  };
1438
1440
  /**
@@ -1444,12 +1446,12 @@
1444
1446
  return Logger;
1445
1447
  }());
1446
1448
 
1447
- /*! @azure/msal-common v6.1.0 2022-03-07 */
1449
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
1448
1450
  /* eslint-disable header/header */
1449
1451
  var name$1 = "@azure/msal-common";
1450
- var version$1 = "6.1.0";
1452
+ var version$1 = "6.2.0";
1451
1453
 
1452
- /*! @azure/msal-common v6.1.0 2022-03-07 */
1454
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
1453
1455
  /*
1454
1456
  * Copyright (c) Microsoft Corporation. All rights reserved.
1455
1457
  * Licensed under the MIT License.
@@ -1460,6 +1462,8 @@
1460
1462
  AzureCloudInstance[AzureCloudInstance["None"] = 0] = "None";
1461
1463
  // Microsoft Azure public cloud
1462
1464
  AzureCloudInstance["AzurePublic"] = "https://login.microsoftonline.com";
1465
+ // Microsoft PPE
1466
+ AzureCloudInstance["AzurePpe"] = "https://login.windows-ppe.net";
1463
1467
  // Microsoft Chinese national cloud
1464
1468
  AzureCloudInstance["AzureChina"] = "https://login.chinacloudapi.cn";
1465
1469
  // Microsoft German national cloud ("Black Forest")
@@ -1468,7 +1472,7 @@
1468
1472
  AzureCloudInstance["AzureUsGovernment"] = "https://login.microsoftonline.us";
1469
1473
  })(exports.AzureCloudInstance || (exports.AzureCloudInstance = {}));
1470
1474
 
1471
- /*! @azure/msal-common v6.1.0 2022-03-07 */
1475
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
1472
1476
 
1473
1477
  /*
1474
1478
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1598,7 +1602,7 @@
1598
1602
  var credentialId = [
1599
1603
  credentialType,
1600
1604
  clientOrFamilyId,
1601
- realm || "",
1605
+ realm || Constants.EMPTY_STRING,
1602
1606
  ];
1603
1607
  return credentialId.join(Separators.CACHE_KEY_SEPARATOR).toLowerCase();
1604
1608
  };
@@ -1606,13 +1610,13 @@
1606
1610
  * Generate target key component as per schema: <target>
1607
1611
  */
1608
1612
  CredentialEntity.generateTargetForCacheKey = function (scopes) {
1609
- return (scopes || "").toLowerCase();
1613
+ return (scopes || Constants.EMPTY_STRING).toLowerCase();
1610
1614
  };
1611
1615
  /**
1612
1616
  * Generate requested claims key component as per schema: <requestedClaims>
1613
1617
  */
1614
1618
  CredentialEntity.generateClaimsHashForCacheKey = function (requestedClaimsHash) {
1615
- return (requestedClaimsHash || "").toLowerCase();
1619
+ return (requestedClaimsHash || Constants.EMPTY_STRING).toLowerCase();
1616
1620
  };
1617
1621
  /**
1618
1622
  * Generate scheme key componenet as per schema: <scheme>
@@ -1622,12 +1626,12 @@
1622
1626
  * PoP Tokens and SSH certs include scheme in cache key
1623
1627
  * Cast to lowercase to handle "bearer" from ADFS
1624
1628
  */
1625
- return (tokenType && tokenType.toLowerCase() !== exports.AuthenticationScheme.BEARER.toLowerCase()) ? tokenType.toLowerCase() : "";
1629
+ return (tokenType && tokenType.toLowerCase() !== exports.AuthenticationScheme.BEARER.toLowerCase()) ? tokenType.toLowerCase() : Constants.EMPTY_STRING;
1626
1630
  };
1627
1631
  return CredentialEntity;
1628
1632
  }());
1629
1633
 
1630
- /*! @azure/msal-common v6.1.0 2022-03-07 */
1634
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
1631
1635
 
1632
1636
  /*
1633
1637
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1882,7 +1886,7 @@
1882
1886
  return ClientConfigurationError;
1883
1887
  }(ClientAuthError));
1884
1888
 
1885
- /*! @azure/msal-common v6.1.0 2022-03-07 */
1889
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
1886
1890
 
1887
1891
  /*
1888
1892
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1911,7 +1915,7 @@
1911
1915
  * @param scopesRequired
1912
1916
  */
1913
1917
  ScopeSet.fromString = function (inputScopeString) {
1914
- var scopeString = inputScopeString || "";
1918
+ var scopeString = inputScopeString || Constants.EMPTY_STRING;
1915
1919
  var inputScopes = scopeString.split(" ");
1916
1920
  return new ScopeSet(inputScopes);
1917
1921
  };
@@ -2055,7 +2059,7 @@
2055
2059
  var scopeArr = this.asArray();
2056
2060
  return scopeArr.join(" ");
2057
2061
  }
2058
- return "";
2062
+ return Constants.EMPTY_STRING;
2059
2063
  };
2060
2064
  /**
2061
2065
  * Prints scopes into a space-delimited lower-case string (used for caching)
@@ -2066,7 +2070,7 @@
2066
2070
  return ScopeSet;
2067
2071
  }());
2068
2072
 
2069
- /*! @azure/msal-common v6.1.0 2022-03-07 */
2073
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
2070
2074
 
2071
2075
  /*
2072
2076
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2104,7 +2108,7 @@
2104
2108
  };
2105
2109
  }
2106
2110
 
2107
- /*! @azure/msal-common v6.1.0 2022-03-07 */
2111
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
2108
2112
  /*
2109
2113
  * Copyright (c) Microsoft Corporation. All rights reserved.
2110
2114
  * Licensed under the MIT License.
@@ -2118,7 +2122,7 @@
2118
2122
  AuthorityType[AuthorityType["Adfs"] = 1] = "Adfs";
2119
2123
  })(AuthorityType || (AuthorityType = {}));
2120
2124
 
2121
- /*! @azure/msal-common v6.1.0 2022-03-07 */
2125
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
2122
2126
 
2123
2127
  /*
2124
2128
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2208,8 +2212,8 @@
2208
2212
  AccountEntity.generateAccountCacheKey = function (accountInterface) {
2209
2213
  var accountKey = [
2210
2214
  accountInterface.homeAccountId,
2211
- accountInterface.environment || "",
2212
- accountInterface.tenantId || "",
2215
+ accountInterface.environment || Constants.EMPTY_STRING,
2216
+ accountInterface.tenantId || Constants.EMPTY_STRING,
2213
2217
  ];
2214
2218
  return accountKey.join(Separators.CACHE_KEY_SEPARATOR).toLowerCase();
2215
2219
  };
@@ -2232,17 +2236,17 @@
2232
2236
  }
2233
2237
  account.environment = env;
2234
2238
  // non AAD scenarios can have empty realm
2235
- account.realm = ((_a = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _a === void 0 ? void 0 : _a.tid) || "";
2239
+ account.realm = ((_a = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _a === void 0 ? void 0 : _a.tid) || Constants.EMPTY_STRING;
2236
2240
  account.oboAssertion = oboAssertion;
2237
2241
  if (idToken) {
2238
2242
  account.idTokenClaims = idToken.claims;
2239
2243
  // How do you account for MSA CID here?
2240
- account.localAccountId = ((_b = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _b === void 0 ? void 0 : _b.oid) || ((_c = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _c === void 0 ? void 0 : _c.sub) || "";
2244
+ account.localAccountId = ((_b = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _b === void 0 ? void 0 : _b.oid) || ((_c = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _c === void 0 ? void 0 : _c.sub) || Constants.EMPTY_STRING;
2241
2245
  /*
2242
2246
  * In B2C scenarios the emails claim is used instead of preferred_username and it is an array. In most cases it will contain a single email.
2243
2247
  * This field should not be relied upon if a custom policy is configured to return more than 1 email.
2244
2248
  */
2245
- account.username = ((_d = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _d === void 0 ? void 0 : _d.preferred_username) || (((_e = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _e === void 0 ? void 0 : _e.emails) ? idToken.claims.emails[0] : "");
2249
+ account.username = ((_d = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _d === void 0 ? void 0 : _d.preferred_username) || (((_e = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _e === void 0 ? void 0 : _e.emails) ? idToken.claims.emails[0] : Constants.EMPTY_STRING);
2246
2250
  account.name = (_f = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _f === void 0 ? void 0 : _f.name;
2247
2251
  }
2248
2252
  account.cloudGraphHostName = cloudGraphHostName;
@@ -2260,7 +2264,7 @@
2260
2264
  account.authorityType = (authority && authority.authorityType === AuthorityType.Adfs) ? CacheAccountType.ADFS_ACCOUNT_TYPE : CacheAccountType.GENERIC_ACCOUNT_TYPE;
2261
2265
  account.homeAccountId = homeAccountId;
2262
2266
  // non AAD scenarios can have empty realm
2263
- account.realm = "";
2267
+ account.realm = Constants.EMPTY_STRING;
2264
2268
  account.oboAssertion = oboAssertion;
2265
2269
  var env = environment || authority && authority.getPreferredCache();
2266
2270
  if (!env) {
@@ -2268,10 +2272,10 @@
2268
2272
  }
2269
2273
  if (idToken) {
2270
2274
  // How do you account for MSA CID here?
2271
- account.localAccountId = ((_a = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _a === void 0 ? void 0 : _a.oid) || ((_b = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _b === void 0 ? void 0 : _b.sub) || "";
2275
+ account.localAccountId = ((_a = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _a === void 0 ? void 0 : _a.oid) || ((_b = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _b === void 0 ? void 0 : _b.sub) || Constants.EMPTY_STRING;
2272
2276
  // upn claim for most ADFS scenarios
2273
- account.username = ((_c = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _c === void 0 ? void 0 : _c.upn) || "";
2274
- account.name = ((_d = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _d === void 0 ? void 0 : _d.name) || "";
2277
+ account.username = ((_c = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _c === void 0 ? void 0 : _c.upn) || Constants.EMPTY_STRING;
2278
+ account.name = ((_d = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _d === void 0 ? void 0 : _d.name) || Constants.EMPTY_STRING;
2275
2279
  account.idTokenClaims = idToken === null || idToken === void 0 ? void 0 : idToken.claims;
2276
2280
  }
2277
2281
  account.environment = env;
@@ -2352,7 +2356,7 @@
2352
2356
  return AccountEntity;
2353
2357
  }());
2354
2358
 
2355
- /*! @azure/msal-common v6.1.0 2022-03-07 */
2359
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
2356
2360
 
2357
2361
  /*
2358
2362
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2390,7 +2394,7 @@
2390
2394
  return AuthToken;
2391
2395
  }());
2392
2396
 
2393
- /*! @azure/msal-common v6.1.0 2022-03-07 */
2397
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
2394
2398
 
2395
2399
  /*
2396
2400
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2512,7 +2516,7 @@
2512
2516
  * @param realm
2513
2517
  */
2514
2518
  CacheManager.prototype.getAccountsFilteredBy = function (accountFilter) {
2515
- return this.getAccountsFilteredByInternal(accountFilter ? accountFilter.homeAccountId : "", accountFilter ? accountFilter.environment : "", accountFilter ? accountFilter.realm : "");
2519
+ return this.getAccountsFilteredByInternal(accountFilter ? accountFilter.homeAccountId : Constants.EMPTY_STRING, accountFilter ? accountFilter.environment : Constants.EMPTY_STRING, accountFilter ? accountFilter.realm : Constants.EMPTY_STRING);
2516
2520
  };
2517
2521
  /**
2518
2522
  * retrieve accounts matching all provided filters; if no filter is set, get all accounts
@@ -3232,7 +3236,7 @@
3232
3236
  return DefaultStorageClass;
3233
3237
  }(CacheManager));
3234
3238
 
3235
- /*! @azure/msal-common v6.1.0 2022-03-07 */
3239
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
3236
3240
 
3237
3241
  /*
3238
3242
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3243,7 +3247,7 @@
3243
3247
  var DEFAULT_SYSTEM_OPTIONS = {
3244
3248
  tokenRenewalOffsetSeconds: DEFAULT_TOKEN_RENEWAL_OFFSET_SEC,
3245
3249
  preventCorsPreflight: false,
3246
- proxyUrl: "",
3250
+ proxyUrl: Constants.EMPTY_STRING
3247
3251
  };
3248
3252
  var DEFAULT_LOGGER_IMPLEMENTATION = {
3249
3253
  loggerCallback: function () {
@@ -3251,7 +3255,7 @@
3251
3255
  },
3252
3256
  piiLoggingEnabled: false,
3253
3257
  logLevel: exports.LogLevel.Info,
3254
- correlationId: ""
3258
+ correlationId: Constants.EMPTY_STRING
3255
3259
  };
3256
3260
  var DEFAULT_NETWORK_IMPLEMENTATION = {
3257
3261
  sendGetRequestAsync: function () {
@@ -3276,17 +3280,23 @@
3276
3280
  var DEFAULT_LIBRARY_INFO = {
3277
3281
  sku: Constants.SKU,
3278
3282
  version: version$1,
3279
- cpu: "",
3280
- os: ""
3283
+ cpu: Constants.EMPTY_STRING,
3284
+ os: Constants.EMPTY_STRING
3281
3285
  };
3282
3286
  var DEFAULT_CLIENT_CREDENTIALS = {
3283
- clientSecret: "",
3287
+ clientSecret: Constants.EMPTY_STRING,
3284
3288
  clientAssertion: undefined
3285
3289
  };
3286
3290
  var DEFAULT_AZURE_CLOUD_OPTIONS = {
3287
3291
  azureCloudInstance: exports.AzureCloudInstance.None,
3288
3292
  tenant: "" + Constants.DEFAULT_COMMON_TENANT
3289
3293
  };
3294
+ var DEFAULT_TELEMETRY_OPTIONS = {
3295
+ application: {
3296
+ appName: "",
3297
+ appVersion: ""
3298
+ }
3299
+ };
3290
3300
  /**
3291
3301
  * Function that sets the default options when not explicitly configured from app developer
3292
3302
  *
@@ -3295,7 +3305,7 @@
3295
3305
  * @returns Configuration
3296
3306
  */
3297
3307
  function buildClientConfiguration(_a) {
3298
- var userAuthOptions = _a.authOptions, userSystemOptions = _a.systemOptions, userLoggerOption = _a.loggerOptions, storageImplementation = _a.storageInterface, networkImplementation = _a.networkInterface, cryptoImplementation = _a.cryptoInterface, clientCredentials = _a.clientCredentials, libraryInfo = _a.libraryInfo, serverTelemetryManager = _a.serverTelemetryManager, persistencePlugin = _a.persistencePlugin, serializableCache = _a.serializableCache;
3308
+ var userAuthOptions = _a.authOptions, userSystemOptions = _a.systemOptions, userLoggerOption = _a.loggerOptions, storageImplementation = _a.storageInterface, networkImplementation = _a.networkInterface, cryptoImplementation = _a.cryptoInterface, clientCredentials = _a.clientCredentials, libraryInfo = _a.libraryInfo, telemetry = _a.telemetry, serverTelemetryManager = _a.serverTelemetryManager, persistencePlugin = _a.persistencePlugin, serializableCache = _a.serializableCache;
3299
3309
  var loggerOptions = __assign(__assign({}, DEFAULT_LOGGER_IMPLEMENTATION), userLoggerOption);
3300
3310
  return {
3301
3311
  authOptions: buildAuthOptions(userAuthOptions),
@@ -3306,6 +3316,7 @@
3306
3316
  cryptoInterface: cryptoImplementation || DEFAULT_CRYPTO_IMPLEMENTATION,
3307
3317
  clientCredentials: clientCredentials || DEFAULT_CLIENT_CREDENTIALS,
3308
3318
  libraryInfo: __assign(__assign({}, DEFAULT_LIBRARY_INFO), libraryInfo),
3319
+ telemetry: __assign(__assign({}, DEFAULT_TELEMETRY_OPTIONS), telemetry),
3309
3320
  serverTelemetryManager: serverTelemetryManager || null,
3310
3321
  persistencePlugin: persistencePlugin || null,
3311
3322
  serializableCache: serializableCache || null
@@ -3319,7 +3330,7 @@
3319
3330
  return __assign({ clientCapabilities: [], azureCloudOptions: DEFAULT_AZURE_CLOUD_OPTIONS }, authOptions);
3320
3331
  }
3321
3332
 
3322
- /*! @azure/msal-common v6.1.0 2022-03-07 */
3333
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
3323
3334
 
3324
3335
  /*
3325
3336
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3339,7 +3350,7 @@
3339
3350
  return ServerError;
3340
3351
  }(AuthError));
3341
3352
 
3342
- /*! @azure/msal-common v6.1.0 2022-03-07 */
3353
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
3343
3354
 
3344
3355
  /*
3345
3356
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3435,7 +3446,7 @@
3435
3446
  return ThrottlingUtils;
3436
3447
  }());
3437
3448
 
3438
- /*! @azure/msal-common v6.1.0 2022-03-07 */
3449
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
3439
3450
 
3440
3451
  /*
3441
3452
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3484,7 +3495,7 @@
3484
3495
  return NetworkManager;
3485
3496
  }());
3486
3497
 
3487
- /*! @azure/msal-common v6.1.0 2022-03-07 */
3498
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
3488
3499
  /*
3489
3500
  * Copyright (c) Microsoft Corporation. All rights reserved.
3490
3501
  * Licensed under the MIT License.
@@ -3495,7 +3506,7 @@
3495
3506
  CcsCredentialType["UPN"] = "UPN";
3496
3507
  })(CcsCredentialType || (CcsCredentialType = {}));
3497
3508
 
3498
- /*! @azure/msal-common v6.1.0 2022-03-07 */
3509
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
3499
3510
 
3500
3511
  /*
3501
3512
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3584,7 +3595,7 @@
3584
3595
  return BaseClient;
3585
3596
  }());
3586
3597
 
3587
- /*! @azure/msal-common v6.1.0 2022-03-07 */
3598
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
3588
3599
 
3589
3600
  /*
3590
3601
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3670,7 +3681,7 @@
3670
3681
  return RequestValidator;
3671
3682
  }());
3672
3683
 
3673
- /*! @azure/msal-common v6.1.0 2022-03-07 */
3684
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
3674
3685
 
3675
3686
  /*
3676
3687
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3793,8 +3804,24 @@
3793
3804
  // Telemetry Info
3794
3805
  this.parameters.set(AADServerParamKeys.X_CLIENT_SKU, libraryInfo.sku);
3795
3806
  this.parameters.set(AADServerParamKeys.X_CLIENT_VER, libraryInfo.version);
3796
- this.parameters.set(AADServerParamKeys.X_CLIENT_OS, libraryInfo.os);
3797
- this.parameters.set(AADServerParamKeys.X_CLIENT_CPU, libraryInfo.cpu);
3807
+ if (libraryInfo.os) {
3808
+ this.parameters.set(AADServerParamKeys.X_CLIENT_OS, libraryInfo.os);
3809
+ }
3810
+ if (libraryInfo.cpu) {
3811
+ this.parameters.set(AADServerParamKeys.X_CLIENT_CPU, libraryInfo.cpu);
3812
+ }
3813
+ };
3814
+ /**
3815
+ * Add client telemetry parameters
3816
+ * @param appTelemetry
3817
+ */
3818
+ RequestParameterBuilder.prototype.addApplicationTelemetry = function (appTelemetry) {
3819
+ if (appTelemetry === null || appTelemetry === void 0 ? void 0 : appTelemetry.appName) {
3820
+ this.parameters.set(AADServerParamKeys.X_APP_NAME, appTelemetry.appName);
3821
+ }
3822
+ if (appTelemetry === null || appTelemetry === void 0 ? void 0 : appTelemetry.appVersion) {
3823
+ this.parameters.set(AADServerParamKeys.X_APP_VER, appTelemetry.appVersion);
3824
+ }
3798
3825
  };
3799
3826
  /**
3800
3827
  * add prompt
@@ -4016,7 +4043,7 @@
4016
4043
  return RequestParameterBuilder;
4017
4044
  }());
4018
4045
 
4019
- /*! @azure/msal-common v6.1.0 2022-03-07 */
4046
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
4020
4047
 
4021
4048
  /*
4022
4049
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4081,7 +4108,7 @@
4081
4108
  return IdTokenEntity;
4082
4109
  }(CredentialEntity));
4083
4110
 
4084
- /*! @azure/msal-common v6.1.0 2022-03-07 */
4111
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
4085
4112
  /*
4086
4113
  * Copyright (c) Microsoft Corporation. All rights reserved.
4087
4114
  * Licensed under the MIT License.
@@ -4131,7 +4158,7 @@
4131
4158
  return TimeUtils;
4132
4159
  }());
4133
4160
 
4134
- /*! @azure/msal-common v6.1.0 2022-03-07 */
4161
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
4135
4162
 
4136
4163
  /*
4137
4164
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4245,7 +4272,7 @@
4245
4272
  return AccessTokenEntity;
4246
4273
  }(CredentialEntity));
4247
4274
 
4248
- /*! @azure/msal-common v6.1.0 2022-03-07 */
4275
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
4249
4276
 
4250
4277
  /*
4251
4278
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4312,7 +4339,7 @@
4312
4339
  return RefreshTokenEntity;
4313
4340
  }(CredentialEntity));
4314
4341
 
4315
- /*! @azure/msal-common v6.1.0 2022-03-07 */
4342
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
4316
4343
 
4317
4344
  /*
4318
4345
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4376,7 +4403,7 @@
4376
4403
  return InteractionRequiredAuthError;
4377
4404
  }(AuthError));
4378
4405
 
4379
- /*! @azure/msal-common v6.1.0 2022-03-07 */
4406
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
4380
4407
  /*
4381
4408
  * Copyright (c) Microsoft Corporation. All rights reserved.
4382
4409
  * Licensed under the MIT License.
@@ -4392,7 +4419,7 @@
4392
4419
  return CacheRecord;
4393
4420
  }());
4394
4421
 
4395
- /*! @azure/msal-common v6.1.0 2022-03-07 */
4422
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
4396
4423
 
4397
4424
  /*
4398
4425
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4448,11 +4475,11 @@
4448
4475
  // Split the state between library state and user passed state and decode them separately
4449
4476
  var splitState = state.split(Constants.RESOURCE_DELIM);
4450
4477
  var libraryState = splitState[0];
4451
- var userState = splitState.length > 1 ? splitState.slice(1).join(Constants.RESOURCE_DELIM) : "";
4478
+ var userState = splitState.length > 1 ? splitState.slice(1).join(Constants.RESOURCE_DELIM) : Constants.EMPTY_STRING;
4452
4479
  var libraryStateString = cryptoObj.base64Decode(libraryState);
4453
4480
  var libraryStateObj = JSON.parse(libraryStateString);
4454
4481
  return {
4455
- userRequestState: !StringUtils.isEmpty(userState) ? userState : "",
4482
+ userRequestState: !StringUtils.isEmpty(userState) ? userState : Constants.EMPTY_STRING,
4456
4483
  libraryState: libraryStateObj
4457
4484
  };
4458
4485
  }
@@ -4463,7 +4490,7 @@
4463
4490
  return ProtocolUtils;
4464
4491
  }());
4465
4492
 
4466
- /*! @azure/msal-common v6.1.0 2022-03-07 */
4493
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
4467
4494
 
4468
4495
  /*
4469
4496
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4624,7 +4651,7 @@
4624
4651
  else if (hashIndex1 > -1) {
4625
4652
  return hashString.substring(hashIndex1 + 1);
4626
4653
  }
4627
- return "";
4654
+ return Constants.EMPTY_STRING;
4628
4655
  };
4629
4656
  UrlString.constructAuthorityUriFromObject = function (urlObject) {
4630
4657
  return new UrlString(urlObject.Protocol + "//" + urlObject.HostNameAndPort + "/" + urlObject.PathSegments.join("/"));
@@ -4664,7 +4691,7 @@
4664
4691
  return UrlString;
4665
4692
  }());
4666
4693
 
4667
- /*! @azure/msal-common v6.1.0 2022-03-07 */
4694
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
4668
4695
 
4669
4696
  /*
4670
4697
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4730,7 +4757,7 @@
4730
4757
  resourceRequestMethod = request.resourceRequestMethod, resourceRequestUri = request.resourceRequestUri, shrClaims = request.shrClaims, shrNonce = request.shrNonce;
4731
4758
  resourceUrlString = (resourceRequestUri) ? new UrlString(resourceRequestUri) : undefined;
4732
4759
  resourceUrlComponents = resourceUrlString === null || resourceUrlString === void 0 ? void 0 : resourceUrlString.getUrlComponents();
4733
- return [4 /*yield*/, this.cryptoUtils.signJwt(__assign({ at: payload, ts: TimeUtils.nowSeconds(), m: resourceRequestMethod === null || resourceRequestMethod === void 0 ? void 0 : resourceRequestMethod.toUpperCase(), u: resourceUrlComponents === null || resourceUrlComponents === void 0 ? void 0 : resourceUrlComponents.HostNameAndPort, nonce: shrNonce || this.cryptoUtils.createNewGuid(), p: resourceUrlComponents === null || resourceUrlComponents === void 0 ? void 0 : resourceUrlComponents.AbsolutePath, q: (resourceUrlComponents === null || resourceUrlComponents === void 0 ? void 0 : resourceUrlComponents.QueryString) ? [[], resourceUrlComponents.QueryString] : undefined, client_claims: shrClaims || undefined }, claims), kid)];
4760
+ return [4 /*yield*/, this.cryptoUtils.signJwt(__assign({ at: payload, ts: TimeUtils.nowSeconds(), m: resourceRequestMethod === null || resourceRequestMethod === void 0 ? void 0 : resourceRequestMethod.toUpperCase(), u: resourceUrlComponents === null || resourceUrlComponents === void 0 ? void 0 : resourceUrlComponents.HostNameAndPort, nonce: shrNonce || this.cryptoUtils.createNewGuid(), p: resourceUrlComponents === null || resourceUrlComponents === void 0 ? void 0 : resourceUrlComponents.AbsolutePath, q: (resourceUrlComponents === null || resourceUrlComponents === void 0 ? void 0 : resourceUrlComponents.QueryString) ? [[], resourceUrlComponents.QueryString] : undefined, client_claims: shrClaims || undefined }, claims), kid, request.correlationId)];
4734
4761
  case 1: return [2 /*return*/, _a.sent()];
4735
4762
  }
4736
4763
  });
@@ -4739,7 +4766,7 @@
4739
4766
  return PopTokenGenerator;
4740
4767
  }());
4741
4768
 
4742
- /*! @azure/msal-common v6.1.0 2022-03-07 */
4769
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
4743
4770
 
4744
4771
  /*
4745
4772
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4809,7 +4836,7 @@
4809
4836
  return AppMetadataEntity;
4810
4837
  }());
4811
4838
 
4812
- /*! @azure/msal-common v6.1.0 2022-03-07 */
4839
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
4813
4840
  /*
4814
4841
  * Copyright (c) Microsoft Corporation. All rights reserved.
4815
4842
  * Licensed under the MIT License.
@@ -4845,7 +4872,7 @@
4845
4872
  return TokenCacheContext;
4846
4873
  }());
4847
4874
 
4848
- /*! @azure/msal-common v6.1.0 2022-03-07 */
4875
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
4849
4876
 
4850
4877
  /*
4851
4878
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5026,8 +5053,8 @@
5026
5053
  */
5027
5054
  ResponseHandler.prototype.generateAccountEntity = function (serverTokenResponse, idToken, authority, oboAssertion, authCodePayload) {
5028
5055
  var authorityType = authority.authorityType;
5029
- var cloudGraphHostName = authCodePayload ? authCodePayload.cloud_graph_host_name : "";
5030
- var msGraphhost = authCodePayload ? authCodePayload.msgraph_host : "";
5056
+ var cloudGraphHostName = authCodePayload ? authCodePayload.cloud_graph_host_name : Constants.EMPTY_STRING;
5057
+ var msGraphhost = authCodePayload ? authCodePayload.msgraph_host : Constants.EMPTY_STRING;
5031
5058
  // ADFS does not require client_info in the response
5032
5059
  if (authorityType === AuthorityType.Adfs) {
5033
5060
  this.logger.verbose("Authority type is ADFS, creating ADFS account");
@@ -5058,7 +5085,7 @@
5058
5085
  return __generator(this, function (_d) {
5059
5086
  switch (_d.label) {
5060
5087
  case 0:
5061
- accessToken = "";
5088
+ accessToken = Constants.EMPTY_STRING;
5062
5089
  responseScopes = [];
5063
5090
  expiresOn = null;
5064
5091
  familyId = Constants.EMPTY_STRING;
@@ -5110,7 +5137,7 @@
5110
5137
  return ResponseHandler;
5111
5138
  }());
5112
5139
 
5113
- /*! @azure/msal-common v6.1.0 2022-03-07 */
5140
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
5114
5141
 
5115
5142
  /*
5116
5143
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5298,6 +5325,7 @@
5298
5325
  parameterBuilder.addAuthorizationCode(request.code);
5299
5326
  // Add library metadata
5300
5327
  parameterBuilder.addLibraryInfo(this.config.libraryInfo);
5328
+ parameterBuilder.addApplicationTelemetry(this.config.telemetry.application);
5301
5329
  parameterBuilder.addThrottling();
5302
5330
  if (this.serverTelemetryManager) {
5303
5331
  parameterBuilder.addServerTelemetry(this.serverTelemetryManager);
@@ -5406,6 +5434,7 @@
5406
5434
  parameterBuilder.addResponseTypeCode();
5407
5435
  // add library info parameters
5408
5436
  parameterBuilder.addLibraryInfo(this.config.libraryInfo);
5437
+ parameterBuilder.addApplicationTelemetry(this.config.telemetry.application);
5409
5438
  // add client_info=1
5410
5439
  parameterBuilder.addClientInfo();
5411
5440
  if (request.codeChallenge && request.codeChallengeMethod) {
@@ -5521,7 +5550,7 @@
5521
5550
  return AuthorizationCodeClient;
5522
5551
  }(BaseClient));
5523
5552
 
5524
- /*! @azure/msal-common v6.1.0 2022-03-07 */
5553
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
5525
5554
 
5526
5555
  /*
5527
5556
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5672,6 +5701,7 @@
5672
5701
  parameterBuilder.addGrantType(GrantType.REFRESH_TOKEN_GRANT);
5673
5702
  parameterBuilder.addClientInfo();
5674
5703
  parameterBuilder.addLibraryInfo(this.config.libraryInfo);
5704
+ parameterBuilder.addApplicationTelemetry(this.config.telemetry.application);
5675
5705
  parameterBuilder.addThrottling();
5676
5706
  if (this.serverTelemetryManager) {
5677
5707
  parameterBuilder.addServerTelemetry(this.serverTelemetryManager);
@@ -5732,7 +5762,7 @@
5732
5762
  return RefreshTokenClient;
5733
5763
  }(BaseClient));
5734
5764
 
5735
- /*! @azure/msal-common v6.1.0 2022-03-07 */
5765
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
5736
5766
 
5737
5767
  /*
5738
5768
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5848,7 +5878,7 @@
5848
5878
  return SilentFlowClient;
5849
5879
  }(BaseClient));
5850
5880
 
5851
- /*! @azure/msal-common v6.1.0 2022-03-07 */
5881
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
5852
5882
  /*
5853
5883
  * Copyright (c) Microsoft Corporation. All rights reserved.
5854
5884
  * Licensed under the MIT License.
@@ -5859,7 +5889,7 @@
5859
5889
  response.hasOwnProperty("issuer"));
5860
5890
  }
5861
5891
 
5862
- /*! @azure/msal-common v6.1.0 2022-03-07 */
5892
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
5863
5893
  /*
5864
5894
  * Copyright (c) Microsoft Corporation. All rights reserved.
5865
5895
  * Licensed under the MIT License.
@@ -5873,7 +5903,7 @@
5873
5903
  ProtocolMode["OIDC"] = "OIDC";
5874
5904
  })(exports.ProtocolMode || (exports.ProtocolMode = {}));
5875
5905
 
5876
- /*! @azure/msal-common v6.1.0 2022-03-07 */
5906
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
5877
5907
 
5878
5908
  /*
5879
5909
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5948,7 +5978,7 @@
5948
5978
  return AuthorityMetadataEntity;
5949
5979
  }());
5950
5980
 
5951
- /*! @azure/msal-common v6.1.0 2022-03-07 */
5981
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
5952
5982
  /*
5953
5983
  * Copyright (c) Microsoft Corporation. All rights reserved.
5954
5984
  * Licensed under the MIT License.
@@ -5958,7 +5988,7 @@
5958
5988
  response.hasOwnProperty("metadata"));
5959
5989
  }
5960
5990
 
5961
- /*! @azure/msal-common v6.1.0 2022-03-07 */
5991
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
5962
5992
 
5963
5993
  /*
5964
5994
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6080,7 +6110,7 @@
6080
6110
  return RegionDiscovery;
6081
6111
  }());
6082
6112
 
6083
- /*! @azure/msal-common v6.1.0 2022-03-07 */
6113
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
6084
6114
 
6085
6115
  /*
6086
6116
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6670,7 +6700,7 @@
6670
6700
  return Authority;
6671
6701
  }());
6672
6702
 
6673
- /*! @azure/msal-common v6.1.0 2022-03-07 */
6703
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
6674
6704
 
6675
6705
  /*
6676
6706
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6731,7 +6761,7 @@
6731
6761
  return AuthorityFactory;
6732
6762
  }());
6733
6763
 
6734
- /*! @azure/msal-common v6.1.0 2022-03-07 */
6764
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
6735
6765
 
6736
6766
  /*
6737
6767
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6762,7 +6792,7 @@
6762
6792
  return ServerTelemetryEntity;
6763
6793
  }());
6764
6794
 
6765
- /*! @azure/msal-common v6.1.0 2022-03-07 */
6795
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
6766
6796
 
6767
6797
  /*
6768
6798
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6790,7 +6820,7 @@
6790
6820
  return ThrottlingEntity;
6791
6821
  }());
6792
6822
 
6793
- /*! @azure/msal-common v6.1.0 2022-03-07 */
6823
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
6794
6824
 
6795
6825
  /*
6796
6826
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6807,7 +6837,7 @@
6807
6837
  }
6808
6838
  };
6809
6839
 
6810
- /*! @azure/msal-common v6.1.0 2022-03-07 */
6840
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
6811
6841
 
6812
6842
  /*
6813
6843
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6859,14 +6889,14 @@
6859
6889
  challenges.forEach(function (challenge) {
6860
6890
  var _a = challenge.split("="), key = _a[0], value = _a[1];
6861
6891
  // Remove escaped quotation marks (', ") from challenge string to keep only the challenge value
6862
- challengeMap[key] = unescape(value.replace(/['"]+/g, ""));
6892
+ challengeMap[key] = unescape(value.replace(/['"]+/g, Constants.EMPTY_STRING));
6863
6893
  });
6864
6894
  return challengeMap;
6865
6895
  };
6866
6896
  return AuthenticationHeaderParser;
6867
6897
  }());
6868
6898
 
6869
- /*! @azure/msal-common v6.1.0 2022-03-07 */
6899
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
6870
6900
 
6871
6901
  /*
6872
6902
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7003,9 +7033,9 @@
7003
7033
  */
7004
7034
  ServerTelemetryManager.prototype.getRegionDiscoveryFields = function () {
7005
7035
  var regionDiscoveryFields = [];
7006
- regionDiscoveryFields.push(this.regionUsed || "");
7007
- regionDiscoveryFields.push(this.regionSource || "");
7008
- regionDiscoveryFields.push(this.regionOutcome || "");
7036
+ regionDiscoveryFields.push(this.regionUsed || Constants.EMPTY_STRING);
7037
+ regionDiscoveryFields.push(this.regionSource || Constants.EMPTY_STRING);
7038
+ regionDiscoveryFields.push(this.regionOutcome || Constants.EMPTY_STRING);
7009
7039
  return regionDiscoveryFields.join(",");
7010
7040
  };
7011
7041
  /**
@@ -7028,6 +7058,390 @@
7028
7058
  return ServerTelemetryManager;
7029
7059
  }());
7030
7060
 
7061
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
7062
+ /*
7063
+ * Copyright (c) Microsoft Corporation. All rights reserved.
7064
+ * Licensed under the MIT License.
7065
+ */
7066
+ /**
7067
+ * Enumeration of operations that are instrumented by have their performance measured by the PerformanceClient.
7068
+ *
7069
+ * @export
7070
+ * @enum {number}
7071
+ */
7072
+ exports.PerformanceEvents = void 0;
7073
+ (function (PerformanceEvents) {
7074
+ /**
7075
+ * acquireTokenByCode API (msal-browser and msal-node).
7076
+ * Used to acquire tokens by trading an authorization code against the token endpoint.
7077
+ */
7078
+ PerformanceEvents["AcquireTokenByCode"] = "acquireTokenByCode";
7079
+ /**
7080
+ * acquireTokenByRefreshToken API (msal-browser and msal-node).
7081
+ * Used to renew an access token using a refresh token against the token endpoint.
7082
+ */
7083
+ PerformanceEvents["AcquireTokenByRefreshToken"] = "acquireTokenByRefreshToken";
7084
+ /**
7085
+ * acquireTokenSilent API (msal-browser and msal-node).
7086
+ * Used to silently acquire a new access token (from the cache or the network).
7087
+ */
7088
+ PerformanceEvents["AcquireTokenSilent"] = "acquireTokenSilent";
7089
+ /**
7090
+ * acquireTokenSilentAsync (msal-browser).
7091
+ * Internal API for acquireTokenSilent.
7092
+ */
7093
+ PerformanceEvents["AcquireTokenSilentAsync"] = "acquireTokenSilentAsync";
7094
+ /**
7095
+ * getPublicKeyThumbprint API in CryptoOpts class (msal-browser).
7096
+ * Used to generate a public/private keypair and generate a public key thumbprint for pop requests.
7097
+ */
7098
+ PerformanceEvents["CryptoOptsGetPublicKeyThumbprint"] = "cryptoOptsGetPublicKeyThumbprint";
7099
+ /**
7100
+ * signJwt API in CryptoOpts class (msal-browser).
7101
+ * Used to signed a pop token.
7102
+ */
7103
+ PerformanceEvents["CryptoOptsSignJwt"] = "cryptoOptsSignJwt";
7104
+ /**
7105
+ * acquireToken API in the SilentCacheClient class (msal-browser).
7106
+ * Used to read access tokens from the cache.
7107
+ */
7108
+ PerformanceEvents["SilentCacheClientAcquireToken"] = "silentCacheClientAcquireToken";
7109
+ /**
7110
+ * acquireToken API in the SilentIframeClient class (msal-browser).
7111
+ * Used to acquire a new set of tokens from the authorize endpoint in a hidden iframe.
7112
+ */
7113
+ PerformanceEvents["SilentIframeClientAcquireToken"] = "silentIframeClientAcquireToken";
7114
+ /**
7115
+ * acquireToken API in SilentRereshClient (msal-browser).
7116
+ * Used to acquire a new set of tokens from the token endpoint using a refresh token.
7117
+ */
7118
+ PerformanceEvents["SilentRefreshClientAcquireToken"] = "silentRefreshClientAcquireToken";
7119
+ /**
7120
+ * ssoSilent API (msal-browser).
7121
+ * Used to silently acquire an authorization code and set of tokens using a hidden iframe.
7122
+ */
7123
+ PerformanceEvents["SsoSilent"] = "ssoSilent";
7124
+ /**
7125
+ * getDiscoveredAuthority API in StandardInteractionClient class (msal-browser).
7126
+ * Used to load authority metadata for a request.
7127
+ */
7128
+ PerformanceEvents["StandardInteractionClientGetDiscoveredAuthority"] = "standardInteractionClientGetDiscoveredAuthority";
7129
+ })(exports.PerformanceEvents || (exports.PerformanceEvents = {}));
7130
+ /**
7131
+ * State of the performance event.
7132
+ *
7133
+ * @export
7134
+ * @enum {number}
7135
+ */
7136
+ var PerformanceEventStatus;
7137
+ (function (PerformanceEventStatus) {
7138
+ PerformanceEventStatus[PerformanceEventStatus["NotStarted"] = 0] = "NotStarted";
7139
+ PerformanceEventStatus[PerformanceEventStatus["InProgress"] = 1] = "InProgress";
7140
+ PerformanceEventStatus[PerformanceEventStatus["Completed"] = 2] = "Completed";
7141
+ })(PerformanceEventStatus || (PerformanceEventStatus = {}));
7142
+
7143
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
7144
+
7145
+ /*
7146
+ * Copyright (c) Microsoft Corporation. All rights reserved.
7147
+ * Licensed under the MIT License.
7148
+ */
7149
+ var PerformanceClient = /** @class */ (function () {
7150
+ /**
7151
+ * Creates an instance of PerformanceClient,
7152
+ * an abstract class containing core performance telemetry logic.
7153
+ *
7154
+ * @constructor
7155
+ * @param {string} clientId Client ID of the application
7156
+ * @param {string} authority Authority used by the application
7157
+ * @param {Logger} logger Logger used by the application
7158
+ * @param {string} libraryName Name of the library
7159
+ * @param {string} libraryVersion Version of the library
7160
+ */
7161
+ function PerformanceClient(clientId, authority, logger, libraryName, libraryVersion, applicationTelemetry) {
7162
+ this.authority = authority;
7163
+ this.libraryName = libraryName;
7164
+ this.libraryVersion = libraryVersion;
7165
+ this.applicationTelemetry = applicationTelemetry;
7166
+ this.clientId = clientId;
7167
+ this.logger = logger;
7168
+ this.callbacks = new Map();
7169
+ this.eventsByCorrelationId = new Map();
7170
+ this.measurementsById = new Map();
7171
+ }
7172
+ /**
7173
+ * Starts measuring performance for a given operation. Returns a function that should be used to end the measurement.
7174
+ *
7175
+ * @param {PerformanceEvents} measureName
7176
+ * @param {?string} [correlationId]
7177
+ * @returns {InProgressPerformanceEvent}
7178
+ */
7179
+ PerformanceClient.prototype.startMeasurement = function (measureName, correlationId) {
7180
+ var _this = this;
7181
+ var _a, _b;
7182
+ // Generate a placeholder correlation if the request does not provide one
7183
+ var eventCorrelationId = correlationId || this.generateId();
7184
+ if (!correlationId) {
7185
+ this.logger.info("PerformanceClient: No correlation id provided for " + measureName + ", generating", eventCorrelationId);
7186
+ }
7187
+ this.logger.trace("PerformanceClient: Performance measurement started for " + measureName, eventCorrelationId);
7188
+ var performanceMeasurement = this.startPerformanceMeasuremeant(measureName, eventCorrelationId);
7189
+ performanceMeasurement.startMeasurement();
7190
+ var inProgressEvent = {
7191
+ eventId: this.generateId(),
7192
+ status: PerformanceEventStatus.InProgress,
7193
+ authority: this.authority,
7194
+ libraryName: this.libraryName,
7195
+ libraryVersion: this.libraryVersion,
7196
+ appName: (_a = this.applicationTelemetry) === null || _a === void 0 ? void 0 : _a.appName,
7197
+ appVersion: (_b = this.applicationTelemetry) === null || _b === void 0 ? void 0 : _b.appVersion,
7198
+ clientId: this.clientId,
7199
+ name: measureName,
7200
+ startTimeMs: Date.now(),
7201
+ correlationId: eventCorrelationId
7202
+ };
7203
+ // Store in progress events so they can be discarded if not ended properly
7204
+ this.cacheEventByCorrelationId(inProgressEvent);
7205
+ this.cacheMeasurement(inProgressEvent, performanceMeasurement);
7206
+ // Return the event and functions the caller can use to properly end/flush the measurement
7207
+ return {
7208
+ endMeasurement: function (event) {
7209
+ var completedEvent = _this.endMeasurement(__assign(__assign({}, inProgressEvent), event));
7210
+ if (completedEvent) {
7211
+ // Cache event so that submeasurements can be added downstream
7212
+ _this.cacheEventByCorrelationId(completedEvent);
7213
+ }
7214
+ return completedEvent;
7215
+ },
7216
+ flushMeasurement: function () {
7217
+ return _this.flushMeasurements(inProgressEvent.name, inProgressEvent.correlationId);
7218
+ },
7219
+ discardMeasurement: function () {
7220
+ return _this.discardMeasurements(inProgressEvent.correlationId);
7221
+ },
7222
+ measurement: performanceMeasurement,
7223
+ event: inProgressEvent
7224
+ };
7225
+ };
7226
+ /**
7227
+ * Stops measuring the performance for an operation. Should only be called directly by PerformanceClient classes,
7228
+ * as consumers should instead use the function returned by startMeasurement.
7229
+ *
7230
+ * @param {PerformanceEvent} event
7231
+ * @returns {(PerformanceEvent | null)}
7232
+ */
7233
+ PerformanceClient.prototype.endMeasurement = function (event) {
7234
+ var performanceMeasurement = this.measurementsById.get(event.eventId);
7235
+ if (performanceMeasurement) {
7236
+ // Immediately delete so that the same event isnt ended twice
7237
+ this.measurementsById.delete(event.eventId);
7238
+ performanceMeasurement.endMeasurement();
7239
+ var durationMs = performanceMeasurement.flushMeasurement();
7240
+ // null indicates no measurement was taken (e.g. needed performance APIs not present)
7241
+ if (durationMs !== null) {
7242
+ this.logger.trace("PerformanceClient: Performance measurement ended for " + event.name + ": " + durationMs + " ms", event.correlationId);
7243
+ var completedEvent = __assign(__assign({
7244
+ // Allow duration to be overwritten when event ends (e.g. testing), but not status
7245
+ durationMs: Math.round(durationMs) }, event), { status: PerformanceEventStatus.Completed });
7246
+ return completedEvent;
7247
+ }
7248
+ else {
7249
+ this.logger.trace("PerformanceClient: Performance measurement not taken", event.correlationId);
7250
+ }
7251
+ }
7252
+ else {
7253
+ this.logger.trace("PerformanceClient: Measurement not found for " + event.eventId, event.correlationId);
7254
+ }
7255
+ return null;
7256
+ };
7257
+ /**
7258
+ * Upserts event into event cache.
7259
+ * First key is the correlation id, second key is the event id.
7260
+ * Allows for events to be grouped by correlation id,
7261
+ * and to easily allow for properties on them to be updated.
7262
+ *
7263
+ * @private
7264
+ * @param {PerformanceEvent} event
7265
+ */
7266
+ PerformanceClient.prototype.cacheEventByCorrelationId = function (event) {
7267
+ var existingEvents = this.eventsByCorrelationId.get(event.correlationId);
7268
+ if (existingEvents) {
7269
+ this.logger.trace("PerformanceClient: Performance measurement for " + event.name + " added/updated", event.correlationId);
7270
+ existingEvents.set(event.eventId, event);
7271
+ }
7272
+ else {
7273
+ this.logger.trace("PerformanceClient: Performance measurement for " + event.name + " started", event.correlationId);
7274
+ this.eventsByCorrelationId.set(event.correlationId, new Map().set(event.eventId, event));
7275
+ }
7276
+ };
7277
+ /**
7278
+ * Cache measurements by their id.
7279
+ *
7280
+ * @private
7281
+ * @param {PerformanceEvent} event
7282
+ * @param {IPerformanceMeasurement} measurement
7283
+ */
7284
+ PerformanceClient.prototype.cacheMeasurement = function (event, measurement) {
7285
+ this.measurementsById.set(event.eventId, measurement);
7286
+ };
7287
+ /**
7288
+ * Gathers and emits performance events for measurements taked for the given top-level API and correlation ID.
7289
+ *
7290
+ * @param {PerformanceEvents} measureName
7291
+ * @param {string} correlationId
7292
+ */
7293
+ PerformanceClient.prototype.flushMeasurements = function (measureName, correlationId) {
7294
+ var _this = this;
7295
+ this.logger.trace("PerformanceClient: Performance measurements flushed for " + measureName, correlationId);
7296
+ var eventsForCorrelationId = this.eventsByCorrelationId.get(correlationId);
7297
+ if (eventsForCorrelationId) {
7298
+ this.discardMeasurements(correlationId);
7299
+ /*
7300
+ * Manually end incomplete submeasurements to ensure there arent orphaned/never ending events.
7301
+ * Incomplete submeasurements are likely an instrumentation bug that should be fixed.
7302
+ * IE only supports Map.forEach.
7303
+ */
7304
+ var completedEvents_1 = [];
7305
+ eventsForCorrelationId.forEach(function (event) {
7306
+ if (event.name !== measureName && event.status !== PerformanceEventStatus.Completed) {
7307
+ _this.logger.trace("PerformanceClient: Incomplete submeasurement " + event.name + " found for " + measureName, correlationId);
7308
+ var completedEvent = _this.endMeasurement(event);
7309
+ if (completedEvent) {
7310
+ completedEvents_1.push(completedEvent);
7311
+ }
7312
+ }
7313
+ completedEvents_1.push(event);
7314
+ });
7315
+ // Sort events by start time (earliest first)
7316
+ var sortedCompletedEvents = completedEvents_1.sort(function (eventA, eventB) { return eventA.startTimeMs - eventB.startTimeMs; });
7317
+ // Take completed top level event and add completed submeasurements durations as properties
7318
+ var topLevelEvents = sortedCompletedEvents.filter(function (event) { return event.name === measureName && event.status === PerformanceEventStatus.Completed; });
7319
+ if (topLevelEvents.length > 0) {
7320
+ /*
7321
+ * Only take the first top-level event if there are multiple events with the same correlation id.
7322
+ * This greatly simplifies logic for submeasurements.
7323
+ */
7324
+ if (topLevelEvents.length > 1) {
7325
+ this.logger.verbose("PerformanceClient: Multiple distinct top-level performance events found, using the first", correlationId);
7326
+ }
7327
+ var topLevelEvent = topLevelEvents[0];
7328
+ this.logger.verbose("PerformanceClient: Measurement found for " + measureName, correlationId);
7329
+ // Build event object with top level and sub measurements
7330
+ var eventToEmit = sortedCompletedEvents.reduce(function (previous, current) {
7331
+ if (current.name !== measureName) {
7332
+ _this.logger.trace("PerformanceClient: Complete submeasurement found for " + current.name, correlationId);
7333
+ // TODO: Emit additional properties for each subMeasurement
7334
+ var subMeasurementName = current.name + "DurationMs";
7335
+ /*
7336
+ * Some code paths, such as resolving an authority, can occur multiple times.
7337
+ * Only take the first measurement, since the second could be read from the cache,
7338
+ * or due to the same correlation id being used for two distinct requests.
7339
+ */
7340
+ if (!previous[subMeasurementName]) {
7341
+ previous[subMeasurementName] = current.durationMs;
7342
+ }
7343
+ else {
7344
+ _this.logger.verbose("PerformanceClient: Submeasurement for " + measureName + " already exists for " + current.name + ", ignoring", correlationId);
7345
+ }
7346
+ }
7347
+ return previous;
7348
+ }, topLevelEvent);
7349
+ this.emitEvents([eventToEmit], eventToEmit.correlationId);
7350
+ }
7351
+ else {
7352
+ this.logger.verbose("PerformanceClient: No completed top-level measurements found for " + measureName, correlationId);
7353
+ }
7354
+ }
7355
+ else {
7356
+ this.logger.verbose("PerformanceClient: No measurements found", correlationId);
7357
+ }
7358
+ };
7359
+ /**
7360
+ * Removes measurements for a given correlation id.
7361
+ *
7362
+ * @param {string} correlationId
7363
+ */
7364
+ PerformanceClient.prototype.discardMeasurements = function (correlationId) {
7365
+ this.logger.trace("PerformanceClient: Performance measurements discarded", correlationId);
7366
+ this.eventsByCorrelationId.delete(correlationId);
7367
+ };
7368
+ /**
7369
+ * Registers a callback function to receive performance events.
7370
+ *
7371
+ * @param {PerformanceCallbackFunction} callback
7372
+ * @returns {string}
7373
+ */
7374
+ PerformanceClient.prototype.addPerformanceCallback = function (callback) {
7375
+ var callbackId = this.generateId();
7376
+ this.callbacks.set(callbackId, callback);
7377
+ this.logger.verbose("PerformanceClient: Performance callback registered with id: " + callbackId);
7378
+ return callbackId;
7379
+ };
7380
+ /**
7381
+ * Removes a callback registered with addPerformanceCallback.
7382
+ *
7383
+ * @param {string} callbackId
7384
+ * @returns {boolean}
7385
+ */
7386
+ PerformanceClient.prototype.removePerformanceCallback = function (callbackId) {
7387
+ var result = this.callbacks.delete(callbackId);
7388
+ if (result) {
7389
+ this.logger.verbose("PerformanceClient: Performance callback " + callbackId + " removed.");
7390
+ }
7391
+ else {
7392
+ this.logger.verbose("PerformanceClient: Performance callback " + callbackId + " not removed.");
7393
+ }
7394
+ return result;
7395
+ };
7396
+ /**
7397
+ * Emits events to all registered callbacks.
7398
+ *
7399
+ * @param {PerformanceEvent[]} events
7400
+ * @param {?string} [correlationId]
7401
+ */
7402
+ PerformanceClient.prototype.emitEvents = function (events, correlationId) {
7403
+ var _this = this;
7404
+ this.logger.verbose("PerformanceClient: Emitting performance events", correlationId);
7405
+ this.callbacks.forEach(function (callback, callbackId) {
7406
+ _this.logger.trace("PerformanceClient: Emitting event to callback " + callbackId, correlationId);
7407
+ callback.apply(null, [events]);
7408
+ });
7409
+ };
7410
+ return PerformanceClient;
7411
+ }());
7412
+
7413
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
7414
+
7415
+ /*
7416
+ * Copyright (c) Microsoft Corporation. All rights reserved.
7417
+ * Licensed under the MIT License.
7418
+ */
7419
+ var StubPerformanceMeasurement = /** @class */ (function () {
7420
+ function StubPerformanceMeasurement() {
7421
+ }
7422
+ /* eslint-disable-next-line @typescript-eslint/no-empty-function */
7423
+ StubPerformanceMeasurement.prototype.startMeasurement = function () { };
7424
+ /* eslint-disable-next-line @typescript-eslint/no-empty-function */
7425
+ StubPerformanceMeasurement.prototype.endMeasurement = function () { };
7426
+ StubPerformanceMeasurement.prototype.flushMeasurement = function () {
7427
+ return null;
7428
+ };
7429
+ return StubPerformanceMeasurement;
7430
+ }());
7431
+ var StubPerformanceClient = /** @class */ (function (_super) {
7432
+ __extends(StubPerformanceClient, _super);
7433
+ function StubPerformanceClient() {
7434
+ return _super !== null && _super.apply(this, arguments) || this;
7435
+ }
7436
+ StubPerformanceClient.prototype.generateId = function () {
7437
+ return "callback-id";
7438
+ };
7439
+ StubPerformanceClient.prototype.startPerformanceMeasuremeant = function () {
7440
+ return new StubPerformanceMeasurement();
7441
+ };
7442
+ return StubPerformanceClient;
7443
+ }(PerformanceClient));
7444
+
7031
7445
  /*
7032
7446
  * Copyright (c) Microsoft Corporation. All rights reserved.
7033
7447
  * Licensed under the MIT License.
@@ -7265,7 +7679,7 @@
7265
7679
  var guidHolder = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx";
7266
7680
  var hex = "0123456789abcdef";
7267
7681
  var r = 0;
7268
- var guidResponse = "";
7682
+ var guidResponse = Constants.EMPTY_STRING;
7269
7683
  for (var i = 0; i < 36; i++) {
7270
7684
  if (guidHolder[i] !== "-" && guidHolder[i] !== "4") {
7271
7685
  // each x and y needs to be random
@@ -7291,7 +7705,7 @@
7291
7705
  * verifies if a string is GUID
7292
7706
  * @param guid
7293
7707
  */
7294
- GuidGenerator.isGuid = function (guid) {
7708
+ GuidGenerator.prototype.isGuid = function (guid) {
7295
7709
  var regexGuid = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
7296
7710
  return regexGuid.test(guid);
7297
7711
  };
@@ -7385,7 +7799,7 @@
7385
7799
  * @param aBytes
7386
7800
  */
7387
7801
  BrowserStringUtils.utf8ArrToString = function (aBytes) {
7388
- var sView = "";
7802
+ var sView = Constants.EMPTY_STRING;
7389
7803
  for (var nPart = void 0, nLen = aBytes.length, nIdx = 0; nIdx < nLen; nIdx++) {
7390
7804
  nPart = aBytes[nIdx];
7391
7805
  sView += String.fromCharCode(nPart > 251 && nPart < 254 && nIdx + 5 < nLen ? /* six bytes */
@@ -7424,7 +7838,7 @@
7424
7838
  */
7425
7839
  Base64Encode.prototype.urlEncode = function (input) {
7426
7840
  return encodeURIComponent(this.encode(input)
7427
- .replace(/=/g, "")
7841
+ .replace(/=/g, Constants.EMPTY_STRING)
7428
7842
  .replace(/\+/g, "-")
7429
7843
  .replace(/\//g, "_"));
7430
7844
  };
@@ -7434,7 +7848,7 @@
7434
7848
  */
7435
7849
  Base64Encode.prototype.urlEncodeArr = function (inputArr) {
7436
7850
  return this.base64EncArr(inputArr)
7437
- .replace(/=/g, "")
7851
+ .replace(/=/g, Constants.EMPTY_STRING)
7438
7852
  .replace(/\+/g, "-")
7439
7853
  .replace(/\//g, "_");
7440
7854
  };
@@ -7452,7 +7866,7 @@
7452
7866
  */
7453
7867
  Base64Encode.prototype.base64EncArr = function (aBytes) {
7454
7868
  var eqLen = (3 - (aBytes.length % 3)) % 3;
7455
- var sB64Enc = "";
7869
+ var sB64Enc = Constants.EMPTY_STRING;
7456
7870
  for (var nMod3 = void 0, nLen = aBytes.length, nUint24 = 0, nIdx = 0; nIdx < nLen; nIdx++) {
7457
7871
  nMod3 = nIdx % 3;
7458
7872
  /* Uncomment the following line in order to split the output in lines 76-character long: */
@@ -7526,7 +7940,7 @@
7526
7940
  * @param nBlockSize
7527
7941
  */
7528
7942
  Base64Decode.prototype.base64DecToArr = function (base64String, nBlockSize) {
7529
- var sB64Enc = base64String.replace(/[^A-Za-z0-9\+\/]/g, "");
7943
+ var sB64Enc = base64String.replace(/[^A-Za-z0-9\+\/]/g, Constants.EMPTY_STRING);
7530
7944
  var nInLen = sB64Enc.length;
7531
7945
  var nOutLen = nBlockSize ? Math.ceil((nInLen * 3 + 1 >>> 2) / nBlockSize) * nBlockSize : nInLen * 3 + 1 >>> 2;
7532
7946
  var aBytes = new Uint8Array(nOutLen);
@@ -8244,11 +8658,11 @@
8244
8658
  msExportKey.addEventListener("complete", function (e) {
8245
8659
  var resultBuffer = e.target.result;
8246
8660
  var resultString = BrowserStringUtils.utf8ArrToString(new Uint8Array(resultBuffer))
8247
- .replace(/\r/g, "")
8248
- .replace(/\n/g, "")
8249
- .replace(/\t/g, "")
8250
- .split(" ").join("")
8251
- .replace("\u0000", "");
8661
+ .replace(/\r/g, Constants.EMPTY_STRING)
8662
+ .replace(/\n/g, Constants.EMPTY_STRING)
8663
+ .replace(/\t/g, Constants.EMPTY_STRING)
8664
+ .split(" ").join(Constants.EMPTY_STRING)
8665
+ .replace("\u0000", Constants.EMPTY_STRING);
8252
8666
  try {
8253
8667
  resolve(JSON.parse(resultString));
8254
8668
  }
@@ -8355,6 +8769,17 @@
8355
8769
  });
8356
8770
  });
8357
8771
  };
8772
+ /**
8773
+ * Closes the connection to IndexedDB database when all pending transactions
8774
+ * complete.
8775
+ */
8776
+ DatabaseStorage.prototype.closeConnection = function () {
8777
+ var db = this.db;
8778
+ if (db && this.dbOpen) {
8779
+ db.close();
8780
+ this.dbOpen = false;
8781
+ }
8782
+ };
8358
8783
  /**
8359
8784
  * Opens database if it's not already open
8360
8785
  */
@@ -8393,9 +8818,13 @@
8393
8818
  var dbGet = objectStore.get(key);
8394
8819
  dbGet.addEventListener("success", function (e) {
8395
8820
  var event = e;
8821
+ _this.closeConnection();
8396
8822
  resolve(event.target.result);
8397
8823
  });
8398
- dbGet.addEventListener("error", function (e) { return reject(e); });
8824
+ dbGet.addEventListener("error", function (e) {
8825
+ _this.closeConnection();
8826
+ reject(e);
8827
+ });
8399
8828
  })];
8400
8829
  }
8401
8830
  });
@@ -8422,8 +8851,14 @@
8422
8851
  var transaction = _this.db.transaction([_this.tableName], "readwrite");
8423
8852
  var objectStore = transaction.objectStore(_this.tableName);
8424
8853
  var dbPut = objectStore.put(payload, key);
8425
- dbPut.addEventListener("success", function () { return resolve(); });
8426
- dbPut.addEventListener("error", function (e) { return reject(e); });
8854
+ dbPut.addEventListener("success", function () {
8855
+ _this.closeConnection();
8856
+ resolve();
8857
+ });
8858
+ dbPut.addEventListener("error", function (e) {
8859
+ _this.closeConnection();
8860
+ reject(e);
8861
+ });
8427
8862
  })];
8428
8863
  }
8429
8864
  });
@@ -8448,8 +8883,14 @@
8448
8883
  var transaction = _this.db.transaction([_this.tableName], "readwrite");
8449
8884
  var objectStore = transaction.objectStore(_this.tableName);
8450
8885
  var dbDelete = objectStore.delete(key);
8451
- dbDelete.addEventListener("success", function () { return resolve(); });
8452
- dbDelete.addEventListener("error", function (e) { return reject(e); });
8886
+ dbDelete.addEventListener("success", function () {
8887
+ _this.closeConnection();
8888
+ resolve();
8889
+ });
8890
+ dbDelete.addEventListener("error", function (e) {
8891
+ _this.closeConnection();
8892
+ reject(e);
8893
+ });
8453
8894
  })];
8454
8895
  }
8455
8896
  });
@@ -8475,9 +8916,13 @@
8475
8916
  var dbGetKeys = objectStore.getAllKeys();
8476
8917
  dbGetKeys.addEventListener("success", function (e) {
8477
8918
  var event = e;
8919
+ _this.closeConnection();
8478
8920
  resolve(event.target.result);
8479
8921
  });
8480
- dbGetKeys.addEventListener("error", function (e) { return reject(e); });
8922
+ dbGetKeys.addEventListener("error", function (e) {
8923
+ _this.closeConnection();
8924
+ reject(e);
8925
+ });
8481
8926
  })];
8482
8927
  }
8483
8928
  });
@@ -8504,9 +8949,13 @@
8504
8949
  var dbContainsKey = objectStore.count(key);
8505
8950
  dbContainsKey.addEventListener("success", function (e) {
8506
8951
  var event = e;
8952
+ _this.closeConnection();
8507
8953
  resolve(event.target.result === 1);
8508
8954
  });
8509
- dbContainsKey.addEventListener("error", function (e) { return reject(e); });
8955
+ dbContainsKey.addEventListener("error", function (e) {
8956
+ _this.closeConnection();
8957
+ reject(e);
8958
+ });
8510
8959
  })];
8511
8960
  }
8512
8961
  });
@@ -8519,12 +8968,29 @@
8519
8968
  */
8520
8969
  DatabaseStorage.prototype.deleteDatabase = function () {
8521
8970
  return __awaiter$1(this, void 0, void 0, function () {
8971
+ var existingDatabases, database;
8522
8972
  return __generator$1(this, function (_a) {
8523
- return [2 /*return*/, new Promise(function (resolve, reject) {
8524
- var deleteDbRequest = window.indexedDB.deleteDatabase(DB_NAME);
8525
- deleteDbRequest.addEventListener("success", function () { return resolve(true); });
8526
- deleteDbRequest.addEventListener("error", function () { return reject(false); });
8527
- })];
8973
+ switch (_a.label) {
8974
+ case 0:
8975
+ // Check if database being deleted exists
8976
+ if (this.db && this.dbOpen) {
8977
+ this.closeConnection();
8978
+ }
8979
+ return [4 /*yield*/, window.indexedDB.databases()];
8980
+ case 1:
8981
+ existingDatabases = _a.sent();
8982
+ database = existingDatabases.find(function (database) { return database.name === DB_NAME; });
8983
+ // If database exists, delete it
8984
+ if (database) {
8985
+ return [2 /*return*/, new Promise(function (resolve, reject) {
8986
+ var deleteDbRequest = window.indexedDB.deleteDatabase(DB_NAME);
8987
+ deleteDbRequest.addEventListener("success", function () { return resolve(true); });
8988
+ deleteDbRequest.addEventListener("error", function () { return reject(false); });
8989
+ })];
8990
+ }
8991
+ // Database doesn't exist, return true
8992
+ return [2 /*return*/, true];
8993
+ }
8528
8994
  });
8529
8995
  });
8530
8996
  };
@@ -8573,15 +9039,19 @@
8573
9039
  * backed up with the more volatile MemoryStorage object for cases in which IndexedDB may be unavailable.
8574
9040
  */
8575
9041
  var AsyncMemoryStorage = /** @class */ (function () {
8576
- function AsyncMemoryStorage(logger) {
9042
+ function AsyncMemoryStorage(logger, storeName) {
8577
9043
  this.inMemoryCache = new MemoryStorage();
8578
9044
  this.indexedDBCache = new DatabaseStorage();
8579
9045
  this.logger = logger;
9046
+ this.storeName = storeName;
8580
9047
  }
8581
9048
  AsyncMemoryStorage.prototype.handleDatabaseAccessError = function (error) {
8582
9049
  if (error instanceof BrowserAuthError && error.errorCode === BrowserAuthErrorMessage.databaseUnavailable.code) {
8583
9050
  this.logger.error("Could not access persistent storage. This may be caused by browser privacy features which block persistent storage in third-party contexts.");
8584
9051
  }
9052
+ else {
9053
+ throw error;
9054
+ }
8585
9055
  };
8586
9056
  /**
8587
9057
  * Get the item matching the given key. Tries in-memory cache first, then in the asynchronous
@@ -8726,22 +9196,29 @@
8726
9196
  */
8727
9197
  AsyncMemoryStorage.prototype.clear = function () {
8728
9198
  return __awaiter$1(this, void 0, void 0, function () {
8729
- var e_6;
9199
+ var dbDeleted, e_6;
8730
9200
  return __generator$1(this, function (_a) {
8731
9201
  switch (_a.label) {
8732
9202
  case 0:
9203
+ // InMemory cache is a Map instance, clear is straightforward
9204
+ this.logger.verbose("Deleting in-memory keystore " + this.storeName);
8733
9205
  this.inMemoryCache.clear();
9206
+ this.logger.verbose("In-memory keystore " + this.storeName + " deleted");
9207
+ this.logger.verbose("Deleting persistent keystore " + this.storeName);
8734
9208
  _a.label = 1;
8735
9209
  case 1:
8736
9210
  _a.trys.push([1, 3, , 4]);
8737
9211
  return [4 /*yield*/, this.indexedDBCache.deleteDatabase()];
8738
9212
  case 2:
8739
- _a.sent();
8740
- return [3 /*break*/, 4];
9213
+ dbDeleted = _a.sent();
9214
+ if (dbDeleted) {
9215
+ this.logger.verbose("Persistent keystore " + this.storeName + " deleted");
9216
+ }
9217
+ return [2 /*return*/, dbDeleted];
8741
9218
  case 3:
8742
9219
  e_6 = _a.sent();
8743
9220
  this.handleDatabaseAccessError(e_6);
8744
- return [3 /*break*/, 4];
9221
+ return [2 /*return*/, false];
8745
9222
  case 4: return [2 /*return*/];
8746
9223
  }
8747
9224
  });
@@ -8754,12 +9231,17 @@
8754
9231
  * Copyright (c) Microsoft Corporation. All rights reserved.
8755
9232
  * Licensed under the MIT License.
8756
9233
  */
9234
+ var CryptoKeyStoreNames;
9235
+ (function (CryptoKeyStoreNames) {
9236
+ CryptoKeyStoreNames["asymmetricKeys"] = "asymmetricKeys";
9237
+ CryptoKeyStoreNames["symmetricKeys"] = "symmetricKeys";
9238
+ })(CryptoKeyStoreNames || (CryptoKeyStoreNames = {}));
8757
9239
  /**
8758
9240
  * This class implements MSAL's crypto interface, which allows it to perform base64 encoding and decoding, generating cryptographically random GUIDs and
8759
9241
  * implementing Proof Key for Code Exchange specs for the OAuth Authorization Code Flow using PKCE (rfc here: https://tools.ietf.org/html/rfc7636).
8760
9242
  */
8761
9243
  var CryptoOps = /** @class */ (function () {
8762
- function CryptoOps(logger) {
9244
+ function CryptoOps(logger, performanceClient) {
8763
9245
  this.logger = logger;
8764
9246
  // Browser crypto needs to be validated first before any other classes can be set.
8765
9247
  this.browserCrypto = new BrowserCrypto(this.logger);
@@ -8768,9 +9250,10 @@
8768
9250
  this.guidGenerator = new GuidGenerator(this.browserCrypto);
8769
9251
  this.pkceGenerator = new PkceGenerator(this.browserCrypto);
8770
9252
  this.cache = {
8771
- asymmetricKeys: new AsyncMemoryStorage(this.logger),
8772
- symmetricKeys: new AsyncMemoryStorage(this.logger)
9253
+ asymmetricKeys: new AsyncMemoryStorage(this.logger, CryptoKeyStoreNames.asymmetricKeys),
9254
+ symmetricKeys: new AsyncMemoryStorage(this.logger, CryptoKeyStoreNames.symmetricKeys)
8773
9255
  };
9256
+ this.performanceClient = performanceClient;
8774
9257
  }
8775
9258
  /**
8776
9259
  * Creates a new random GUID - used to populate state and nonce.
@@ -8808,16 +9291,19 @@
8808
9291
  * @param request
8809
9292
  */
8810
9293
  CryptoOps.prototype.getPublicKeyThumbprint = function (request) {
9294
+ var _a;
8811
9295
  return __awaiter$1(this, void 0, void 0, function () {
8812
- var keyPair, publicKeyJwk, pubKeyThumprintObj, publicJwkString, publicJwkHash, privateKeyJwk, unextractablePrivateKey;
8813
- return __generator$1(this, function (_a) {
8814
- switch (_a.label) {
8815
- case 0: return [4 /*yield*/, this.browserCrypto.generateKeyPair(CryptoOps.EXTRACTABLE, CryptoOps.POP_KEY_USAGES)];
9296
+ var publicKeyThumbMeasurement, keyPair, publicKeyJwk, pubKeyThumprintObj, publicJwkString, publicJwkHash, privateKeyJwk, unextractablePrivateKey;
9297
+ return __generator$1(this, function (_b) {
9298
+ switch (_b.label) {
9299
+ case 0:
9300
+ publicKeyThumbMeasurement = (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.startMeasurement(exports.PerformanceEvents.CryptoOptsGetPublicKeyThumbprint, request.correlationId);
9301
+ return [4 /*yield*/, this.browserCrypto.generateKeyPair(CryptoOps.EXTRACTABLE, CryptoOps.POP_KEY_USAGES)];
8816
9302
  case 1:
8817
- keyPair = _a.sent();
9303
+ keyPair = _b.sent();
8818
9304
  return [4 /*yield*/, this.browserCrypto.exportJwk(keyPair.publicKey)];
8819
9305
  case 2:
8820
- publicKeyJwk = _a.sent();
9306
+ publicKeyJwk = _b.sent();
8821
9307
  pubKeyThumprintObj = {
8822
9308
  e: publicKeyJwk.e,
8823
9309
  kty: publicKeyJwk.kty,
@@ -8826,13 +9312,13 @@
8826
9312
  publicJwkString = BrowserCrypto.getJwkString(pubKeyThumprintObj);
8827
9313
  return [4 /*yield*/, this.hashString(publicJwkString)];
8828
9314
  case 3:
8829
- publicJwkHash = _a.sent();
9315
+ publicJwkHash = _b.sent();
8830
9316
  return [4 /*yield*/, this.browserCrypto.exportJwk(keyPair.privateKey)];
8831
9317
  case 4:
8832
- privateKeyJwk = _a.sent();
9318
+ privateKeyJwk = _b.sent();
8833
9319
  return [4 /*yield*/, this.browserCrypto.importJwk(privateKeyJwk, false, ["sign"])];
8834
9320
  case 5:
8835
- unextractablePrivateKey = _a.sent();
9321
+ unextractablePrivateKey = _b.sent();
8836
9322
  // Store Keypair data in keystore
8837
9323
  return [4 /*yield*/, this.cache.asymmetricKeys.setItem(publicJwkHash, {
8838
9324
  privateKey: unextractablePrivateKey,
@@ -8842,7 +9328,12 @@
8842
9328
  })];
8843
9329
  case 6:
8844
9330
  // Store Keypair data in keystore
8845
- _a.sent();
9331
+ _b.sent();
9332
+ if (publicKeyThumbMeasurement) {
9333
+ publicKeyThumbMeasurement.endMeasurement({
9334
+ success: true
9335
+ });
9336
+ }
8846
9337
  return [2 /*return*/, publicJwkHash];
8847
9338
  }
8848
9339
  });
@@ -8873,21 +9364,32 @@
8873
9364
  */
8874
9365
  CryptoOps.prototype.clearKeystore = function () {
8875
9366
  return __awaiter$1(this, void 0, void 0, function () {
8876
- var dataStoreNames, databaseStorage, _a;
8877
- return __generator$1(this, function (_b) {
8878
- switch (_b.label) {
9367
+ var e_1;
9368
+ return __generator$1(this, function (_a) {
9369
+ switch (_a.label) {
8879
9370
  case 0:
8880
- dataStoreNames = Object.keys(this.cache);
8881
- databaseStorage = this.cache[dataStoreNames[0]];
8882
- if (!databaseStorage) return [3 /*break*/, 2];
8883
- return [4 /*yield*/, databaseStorage.deleteDatabase()];
9371
+ _a.trys.push([0, 3, , 4]);
9372
+ this.logger.verbose("Deleting in-memory and persistent asymmetric key stores");
9373
+ return [4 /*yield*/, this.cache.asymmetricKeys.clear()];
8884
9374
  case 1:
8885
- _a = _b.sent();
8886
- return [3 /*break*/, 3];
9375
+ _a.sent();
9376
+ this.logger.verbose("Successfully deleted asymmetric key stores");
9377
+ this.logger.verbose("Deleting in-memory and persistent symmetric key stores");
9378
+ return [4 /*yield*/, this.cache.symmetricKeys.clear()];
8887
9379
  case 2:
8888
- _a = false;
8889
- _b.label = 3;
8890
- case 3: return [2 /*return*/, _a];
9380
+ _a.sent();
9381
+ this.logger.verbose("Successfully deleted symmetric key stores");
9382
+ return [2 /*return*/, true];
9383
+ case 3:
9384
+ e_1 = _a.sent();
9385
+ if (e_1 instanceof Error) {
9386
+ this.logger.error("Clearing keystore failed with error: " + e_1.message);
9387
+ }
9388
+ else {
9389
+ this.logger.error("Clearing keystore failed with unknown error");
9390
+ }
9391
+ return [2 /*return*/, false];
9392
+ case 4: return [2 /*return*/];
8891
9393
  }
8892
9394
  });
8893
9395
  });
@@ -8897,20 +9399,23 @@
8897
9399
  * @param payload
8898
9400
  * @param kid
8899
9401
  */
8900
- CryptoOps.prototype.signJwt = function (payload, kid) {
9402
+ CryptoOps.prototype.signJwt = function (payload, kid, correlationId) {
9403
+ var _a;
8901
9404
  return __awaiter$1(this, void 0, void 0, function () {
8902
- var cachedKeyPair, publicKeyJwk, publicKeyJwkString, header, encodedHeader, encodedPayload, tokenString, tokenBuffer, signatureBuffer, encodedSignature;
8903
- return __generator$1(this, function (_a) {
8904
- switch (_a.label) {
8905
- case 0: return [4 /*yield*/, this.cache.asymmetricKeys.getItem(kid)];
9405
+ var signJwtMeasurement, cachedKeyPair, publicKeyJwk, publicKeyJwkString, header, encodedHeader, encodedPayload, tokenString, tokenBuffer, signatureBuffer, encodedSignature, signedJwt;
9406
+ return __generator$1(this, function (_b) {
9407
+ switch (_b.label) {
9408
+ case 0:
9409
+ signJwtMeasurement = (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.startMeasurement(exports.PerformanceEvents.CryptoOptsSignJwt, correlationId);
9410
+ return [4 /*yield*/, this.cache.asymmetricKeys.getItem(kid)];
8906
9411
  case 1:
8907
- cachedKeyPair = _a.sent();
9412
+ cachedKeyPair = _b.sent();
8908
9413
  if (!cachedKeyPair) {
8909
9414
  throw BrowserAuthError.createSigningKeyNotFoundInStorageError(kid);
8910
9415
  }
8911
9416
  return [4 /*yield*/, this.browserCrypto.exportJwk(cachedKeyPair.publicKey)];
8912
9417
  case 2:
8913
- publicKeyJwk = _a.sent();
9418
+ publicKeyJwk = _b.sent();
8914
9419
  publicKeyJwkString = BrowserCrypto.getJwkString(publicKeyJwk);
8915
9420
  header = {
8916
9421
  alg: publicKeyJwk.alg,
@@ -8926,9 +9431,15 @@
8926
9431
  tokenBuffer = BrowserStringUtils.stringToArrayBuffer(tokenString);
8927
9432
  return [4 /*yield*/, this.browserCrypto.sign(cachedKeyPair.privateKey, tokenBuffer)];
8928
9433
  case 3:
8929
- signatureBuffer = _a.sent();
9434
+ signatureBuffer = _b.sent();
8930
9435
  encodedSignature = this.b64Encode.urlEncodeArr(new Uint8Array(signatureBuffer));
8931
- return [2 /*return*/, tokenString + "." + encodedSignature];
9436
+ signedJwt = tokenString + "." + encodedSignature;
9437
+ if (signJwtMeasurement) {
9438
+ signJwtMeasurement.endMeasurement({
9439
+ success: true
9440
+ });
9441
+ }
9442
+ return [2 /*return*/, signedJwt];
8932
9443
  }
8933
9444
  });
8934
9445
  });
@@ -9448,8 +9959,8 @@
9448
9959
  * Returns wrapper metadata from in-memory storage
9449
9960
  */
9450
9961
  BrowserCacheManager.prototype.getWrapperMetadata = function () {
9451
- var sku = this.internalStorage.getItem(InMemoryCacheKeys.WRAPPER_SKU) || "";
9452
- var version = this.internalStorage.getItem(InMemoryCacheKeys.WRAPPER_VER) || "";
9962
+ var sku = this.internalStorage.getItem(InMemoryCacheKeys.WRAPPER_SKU) || Constants.EMPTY_STRING;
9963
+ var version = this.internalStorage.getItem(InMemoryCacheKeys.WRAPPER_VER) || Constants.EMPTY_STRING;
9453
9964
  return [sku, version];
9454
9965
  };
9455
9966
  /**
@@ -9671,7 +10182,7 @@
9671
10182
  return decodeURIComponent(cookie.substring(name.length, cookie.length));
9672
10183
  }
9673
10184
  }
9674
- return "";
10185
+ return Constants.EMPTY_STRING;
9675
10186
  };
9676
10187
  /**
9677
10188
  * Clear all msal-related cookies currently set in the browser. Should only be used to clear temporary cache items.
@@ -9696,7 +10207,7 @@
9696
10207
  * @param cookieName
9697
10208
  */
9698
10209
  BrowserCacheManager.prototype.clearItemCookie = function (cookieName) {
9699
- this.setItemCookie(cookieName, "", -1);
10210
+ this.setItemCookie(cookieName, Constants.EMPTY_STRING, -1);
9700
10211
  };
9701
10212
  /**
9702
10213
  * Get cookie expiration time
@@ -9841,7 +10352,7 @@
9841
10352
  var stateKey = this.generateStateKey(stateString);
9842
10353
  var cachedState = this.temporaryCacheStorage.getItem(stateKey);
9843
10354
  this.logger.infoPii("BrowserCacheManager.cleanRequestByState: Removing temporary cache items for state: " + cachedState);
9844
- this.resetRequestCache(cachedState || "");
10355
+ this.resetRequestCache(cachedState || Constants.EMPTY_STRING);
9845
10356
  }
9846
10357
  this.clearMsalCookies();
9847
10358
  };
@@ -10064,7 +10575,7 @@
10064
10575
  return __generator$1(this, function (_b) {
10065
10576
  switch (_b.label) {
10066
10577
  case 0:
10067
- reqBody = (options && options.body) || "";
10578
+ reqBody = (options && options.body) || Constants.EMPTY_STRING;
10068
10579
  _b.label = 1;
10069
10580
  case 1:
10070
10581
  _b.trys.push([1, 3, , 4]);
@@ -10284,7 +10795,7 @@
10284
10795
  BrowserUtils.replaceHash = function (url) {
10285
10796
  var urlParts = url.split("#");
10286
10797
  urlParts.shift(); // Remove part before the hash
10287
- window.location.hash = urlParts.length > 0 ? urlParts.join("#") : "";
10798
+ window.location.hash = urlParts.length > 0 ? urlParts.join("#") : Constants.EMPTY_STRING;
10288
10799
  };
10289
10800
  /**
10290
10801
  * Returns boolean of whether the current window is in an iframe or not.
@@ -10445,22 +10956,22 @@
10445
10956
  * @returns Configuration object
10446
10957
  */
10447
10958
  function buildConfiguration(_a, isBrowserEnvironment) {
10448
- var userInputAuth = _a.auth, userInputCache = _a.cache, userInputSystem = _a.system;
10959
+ var userInputAuth = _a.auth, userInputCache = _a.cache, userInputSystem = _a.system, userInputTelemetry = _a.telemetry;
10449
10960
  // Default auth options for browser
10450
10961
  var DEFAULT_AUTH_OPTIONS = {
10451
- clientId: "",
10962
+ clientId: Constants.EMPTY_STRING,
10452
10963
  authority: "" + Constants.DEFAULT_AUTHORITY,
10453
10964
  knownAuthorities: [],
10454
- cloudDiscoveryMetadata: "",
10455
- authorityMetadata: "",
10456
- redirectUri: "",
10457
- postLogoutRedirectUri: "",
10965
+ cloudDiscoveryMetadata: Constants.EMPTY_STRING,
10966
+ authorityMetadata: Constants.EMPTY_STRING,
10967
+ redirectUri: Constants.EMPTY_STRING,
10968
+ postLogoutRedirectUri: Constants.EMPTY_STRING,
10458
10969
  navigateToLoginRequestUrl: true,
10459
10970
  clientCapabilities: [],
10460
10971
  protocolMode: exports.ProtocolMode.AAD,
10461
10972
  azureCloudOptions: {
10462
10973
  azureCloudInstance: exports.AzureCloudInstance.None,
10463
- tenant: ""
10974
+ tenant: Constants.EMPTY_STRING
10464
10975
  },
10465
10976
  };
10466
10977
  // Default cache options for browser
@@ -10480,17 +10991,24 @@
10480
10991
  var DEFAULT_BROWSER_SYSTEM_OPTIONS = __assign$1(__assign$1({}, DEFAULT_SYSTEM_OPTIONS), { loggerOptions: DEFAULT_LOGGER_OPTIONS, networkClient: isBrowserEnvironment ? BrowserUtils.getBrowserNetworkClient() : StubbedNetworkModule, navigationClient: new NavigationClient(), loadFrameTimeout: 0,
10481
10992
  // If loadFrameTimeout is provided, use that as default.
10482
10993
  windowHashTimeout: (userInputSystem && userInputSystem.loadFrameTimeout) || DEFAULT_POPUP_TIMEOUT_MS, iframeHashTimeout: (userInputSystem && userInputSystem.loadFrameTimeout) || DEFAULT_IFRAME_TIMEOUT_MS, navigateFrameWait: isBrowserEnvironment && BrowserUtils.detectIEOrEdge() ? 500 : 0, redirectNavigationTimeout: DEFAULT_REDIRECT_TIMEOUT_MS, asyncPopups: false, allowRedirectInIframe: false });
10994
+ var DEFAULT_TELEMETRY_OPTIONS = {
10995
+ application: {
10996
+ appName: Constants.EMPTY_STRING,
10997
+ appVersion: Constants.EMPTY_STRING
10998
+ }
10999
+ };
10483
11000
  var overlayedConfig = {
10484
11001
  auth: __assign$1(__assign$1({}, DEFAULT_AUTH_OPTIONS), userInputAuth),
10485
11002
  cache: __assign$1(__assign$1({}, DEFAULT_CACHE_OPTIONS), userInputCache),
10486
- system: __assign$1(__assign$1({}, DEFAULT_BROWSER_SYSTEM_OPTIONS), userInputSystem)
11003
+ system: __assign$1(__assign$1({}, DEFAULT_BROWSER_SYSTEM_OPTIONS), userInputSystem),
11004
+ telemetry: __assign$1(__assign$1({}, DEFAULT_TELEMETRY_OPTIONS), userInputTelemetry)
10487
11005
  };
10488
11006
  return overlayedConfig;
10489
11007
  }
10490
11008
 
10491
11009
  /* eslint-disable header/header */
10492
11010
  var name = "@azure/msal-browser";
10493
- var version = "2.22.1";
11011
+ var version = "2.23.0";
10494
11012
 
10495
11013
  /*
10496
11014
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -10647,7 +11165,7 @@
10647
11165
  * Licensed under the MIT License.
10648
11166
  */
10649
11167
  var BaseInteractionClient = /** @class */ (function () {
10650
- function BaseInteractionClient(config, storageImpl, browserCrypto, logger, eventHandler, correlationId) {
11168
+ function BaseInteractionClient(config, storageImpl, browserCrypto, logger, eventHandler, performanceClient, correlationId) {
10651
11169
  this.config = config;
10652
11170
  this.browserStorage = storageImpl;
10653
11171
  this.browserCrypto = browserCrypto;
@@ -10655,6 +11173,7 @@
10655
11173
  this.eventHandler = eventHandler;
10656
11174
  this.correlationId = correlationId || this.browserCrypto.createNewGuid();
10657
11175
  this.logger = logger.clone(BrowserConstants.MSAL_SKU, version, this.correlationId);
11176
+ this.performanceClient = performanceClient;
10658
11177
  }
10659
11178
  BaseInteractionClient.prototype.clearCacheOnLogout = function (account) {
10660
11179
  return __awaiter$1(this, void 0, void 0, function () {
@@ -10681,6 +11200,7 @@
10681
11200
  case 4: return [3 /*break*/, 9];
10682
11201
  case 5:
10683
11202
  _a.trys.push([5, 8, , 9]);
11203
+ this.logger.verbose("No account provided in logout request, clearing all cache items.", this.correlationId);
10684
11204
  // Clear all accounts and tokens
10685
11205
  return [4 /*yield*/, this.browserStorage.clear()];
10686
11206
  case 6:
@@ -10691,7 +11211,6 @@
10691
11211
  case 7:
10692
11212
  // Clear any stray keys from IndexedDB
10693
11213
  _a.sent();
10694
- this.logger.verbose("No account provided in logout request, clearing all cache items.");
10695
11214
  return [3 /*break*/, 9];
10696
11215
  case 8:
10697
11216
  _a.sent();
@@ -10786,8 +11305,8 @@
10786
11305
  */
10787
11306
  var StandardInteractionClient = /** @class */ (function (_super) {
10788
11307
  __extends$1(StandardInteractionClient, _super);
10789
- function StandardInteractionClient(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, correlationId) {
10790
- var _this = _super.call(this, config, storageImpl, browserCrypto, logger, eventHandler, correlationId) || this;
11308
+ function StandardInteractionClient(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, performanceClient, correlationId) {
11309
+ var _this = _super.call(this, config, storageImpl, browserCrypto, logger, eventHandler, performanceClient, correlationId) || this;
10791
11310
  _this.navigationClient = navigationClient;
10792
11311
  return _this;
10793
11312
  }
@@ -10805,7 +11324,7 @@
10805
11324
  return [4 /*yield*/, this.browserCrypto.generatePkceCodes()];
10806
11325
  case 1:
10807
11326
  generatedPkceParams = _a.sent();
10808
- authCodeRequest = __assign$1(__assign$1({}, request), { redirectUri: request.redirectUri, code: "", codeVerifier: generatedPkceParams.verifier });
11327
+ authCodeRequest = __assign$1(__assign$1({}, request), { redirectUri: request.redirectUri, code: Constants.EMPTY_STRING, codeVerifier: generatedPkceParams.verifier });
10809
11328
  request.codeChallenge = generatedPkceParams.challenge;
10810
11329
  request.codeChallengeMethod = Constants.S256_CODE_CHALLENGE_METHOD;
10811
11330
  return [2 /*return*/, authCodeRequest];
@@ -10921,7 +11440,7 @@
10921
11440
  return __generator$1(this, function (_a) {
10922
11441
  switch (_a.label) {
10923
11442
  case 0:
10924
- this.logger.verbose("getClientConfiguration called");
11443
+ this.logger.verbose("getClientConfiguration called", this.correlationId);
10925
11444
  return [4 /*yield*/, this.getDiscoveredAuthority(requestAuthority, requestAzureCloudOptions)];
10926
11445
  case 1:
10927
11446
  discoveredAuthority = _a.sent();
@@ -10948,9 +11467,10 @@
10948
11467
  libraryInfo: {
10949
11468
  sku: BrowserConstants.MSAL_SKU,
10950
11469
  version: version,
10951
- cpu: "",
10952
- os: ""
10953
- }
11470
+ cpu: Constants.EMPTY_STRING,
11471
+ os: Constants.EMPTY_STRING
11472
+ },
11473
+ telemetry: this.config.telemetry
10954
11474
  }];
10955
11475
  }
10956
11476
  });
@@ -10984,11 +11504,12 @@
10984
11504
  */
10985
11505
  StandardInteractionClient.prototype.getDiscoveredAuthority = function (requestAuthority, requestAzureCloudOptions) {
10986
11506
  return __awaiter$1(this, void 0, void 0, function () {
10987
- var authorityOptions, userAuthority, builtAuthority;
11507
+ var getAuthorityMeasurement, authorityOptions, userAuthority, builtAuthority;
10988
11508
  return __generator$1(this, function (_a) {
10989
11509
  switch (_a.label) {
10990
11510
  case 0:
10991
- this.logger.verbose("getDiscoveredAuthority called");
11511
+ this.logger.verbose("getDiscoveredAuthority called", this.correlationId);
11512
+ getAuthorityMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.StandardInteractionClientGetDiscoveredAuthority, this.correlationId);
10992
11513
  authorityOptions = {
10993
11514
  protocolMode: this.config.auth.protocolMode,
10994
11515
  knownAuthorities: this.config.auth.knownAuthorities,
@@ -10997,8 +11518,20 @@
10997
11518
  };
10998
11519
  userAuthority = requestAuthority ? requestAuthority : this.config.auth.authority;
10999
11520
  builtAuthority = Authority.generateAuthority(userAuthority, requestAzureCloudOptions || this.config.auth.azureCloudOptions);
11000
- this.logger.verbose("Creating discovered authority with configured authority");
11001
- return [4 /*yield*/, AuthorityFactory.createDiscoveredInstance(builtAuthority, this.config.system.networkClient, this.browserStorage, authorityOptions)];
11521
+ this.logger.verbose("Creating discovered authority with configured authority", this.correlationId);
11522
+ return [4 /*yield*/, AuthorityFactory.createDiscoveredInstance(builtAuthority, this.config.system.networkClient, this.browserStorage, authorityOptions)
11523
+ .then(function (result) {
11524
+ getAuthorityMeasurement.endMeasurement({
11525
+ success: true
11526
+ });
11527
+ return result;
11528
+ })
11529
+ .catch(function (error) {
11530
+ getAuthorityMeasurement.endMeasurement({
11531
+ success: false
11532
+ });
11533
+ throw error;
11534
+ })];
11002
11535
  case 1: return [2 /*return*/, _a.sent()];
11003
11536
  }
11004
11537
  });
@@ -11015,7 +11548,7 @@
11015
11548
  return __generator$1(this, function (_b) {
11016
11549
  switch (_b.label) {
11017
11550
  case 0:
11018
- this.logger.verbose("initializeAuthorizationRequest called");
11551
+ this.logger.verbose("initializeAuthorizationRequest called", this.correlationId);
11019
11552
  redirectUri = this.getRedirectUri(request.redirectUri);
11020
11553
  browserState = {
11021
11554
  interactionType: interactionType
@@ -11027,8 +11560,8 @@
11027
11560
  validatedRequest = __assign$1.apply(void 0, [__assign$1.apply(void 0, _a.concat([_b.sent()])), { redirectUri: redirectUri, state: state, nonce: request.nonce || this.browserCrypto.createNewGuid(), responseMode: ResponseMode.FRAGMENT }]);
11028
11561
  account = request.account || this.browserStorage.getActiveAccount();
11029
11562
  if (account) {
11030
- this.logger.verbose("Setting validated request account");
11031
- this.logger.verbosePii("Setting validated request account: " + account);
11563
+ this.logger.verbose("Setting validated request account", this.correlationId);
11564
+ this.logger.verbosePii("Setting validated request account: " + account.homeAccountId, this.correlationId);
11032
11565
  validatedRequest.account = account;
11033
11566
  }
11034
11567
  // Check for ADAL/MSAL v1 SSO
@@ -11499,7 +12032,7 @@
11499
12032
  return [4 /*yield*/, this.initializeAuthorizationRequest(request, exports.InteractionType.Popup)];
11500
12033
  case 1:
11501
12034
  validRequest = _a.sent();
11502
- this.browserStorage.updateCacheEntries(validRequest.state, validRequest.nonce, validRequest.authority, validRequest.loginHint || "", validRequest.account || null);
12035
+ this.browserStorage.updateCacheEntries(validRequest.state, validRequest.nonce, validRequest.authority, validRequest.loginHint || Constants.EMPTY_STRING, validRequest.account || null);
11503
12036
  _a.label = 2;
11504
12037
  case 2:
11505
12038
  _a.trys.push([2, 8, , 9]);
@@ -11788,7 +12321,7 @@
11788
12321
  case 0: return [4 /*yield*/, this.initializeAuthorizationRequest(request, exports.InteractionType.Redirect)];
11789
12322
  case 1:
11790
12323
  validRequest = _a.sent();
11791
- this.browserStorage.updateCacheEntries(validRequest.state, validRequest.nonce, validRequest.authority, validRequest.loginHint || "", validRequest.account || null);
12324
+ this.browserStorage.updateCacheEntries(validRequest.state, validRequest.nonce, validRequest.authority, validRequest.loginHint || Constants.EMPTY_STRING, validRequest.account || null);
11792
12325
  serverTelemetryManager = this.initializeServerTelemetryManager(exports.ApiId.acquireTokenRedirect);
11793
12326
  handleBackButton = function (event) {
11794
12327
  // Clear temporary cache if the back button is clicked during the redirect flow.
@@ -11875,7 +12408,7 @@
11875
12408
  this.browserStorage.cleanRequestByInteractionType(exports.InteractionType.Redirect);
11876
12409
  return [2 /*return*/, null];
11877
12410
  }
11878
- loginRequestUrl = this.browserStorage.getTemporaryCache(exports.TemporaryCacheKeys.ORIGIN_URI, true) || "";
12411
+ loginRequestUrl = this.browserStorage.getTemporaryCache(exports.TemporaryCacheKeys.ORIGIN_URI, true) || Constants.EMPTY_STRING;
11879
12412
  loginRequestUrlNormalized = UrlString.removeHashFromUrl(loginRequestUrl);
11880
12413
  currentUrlNormalized = UrlString.removeHashFromUrl(window.location.href);
11881
12414
  if (!(loginRequestUrlNormalized === currentUrlNormalized && this.config.auth.navigateToLoginRequestUrl)) return [3 /*break*/, 3];
@@ -12225,8 +12758,8 @@
12225
12758
  */
12226
12759
  var SilentIframeClient = /** @class */ (function (_super) {
12227
12760
  __extends$1(SilentIframeClient, _super);
12228
- function SilentIframeClient(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, apiId, correlationId) {
12229
- var _this = _super.call(this, config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, correlationId) || this;
12761
+ function SilentIframeClient(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, apiId, performanceClient, correlationId) {
12762
+ var _this = _super.call(this, config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, performanceClient, correlationId) || this;
12230
12763
  _this.apiId = apiId;
12231
12764
  return _this;
12232
12765
  }
@@ -12236,23 +12769,27 @@
12236
12769
  */
12237
12770
  SilentIframeClient.prototype.acquireToken = function (request) {
12238
12771
  return __awaiter$1(this, void 0, void 0, function () {
12239
- var silentRequest, serverTelemetryManager, authCodeRequest, authClient, navigateUrl, e_1;
12772
+ var acquireTokenMeasurement, silentRequest, serverTelemetryManager, authCodeRequest, authClient, navigateUrl, e_1;
12240
12773
  return __generator$1(this, function (_a) {
12241
12774
  switch (_a.label) {
12242
12775
  case 0:
12243
12776
  this.logger.verbose("acquireTokenByIframe called");
12777
+ acquireTokenMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.SilentIframeClientAcquireToken, request.correlationId);
12244
12778
  // Check that we have some SSO data
12245
12779
  if (StringUtils.isEmpty(request.loginHint) && StringUtils.isEmpty(request.sid) && (!request.account || StringUtils.isEmpty(request.account.username))) {
12246
12780
  this.logger.warning("No user hint provided. The authorization server may need more information to complete this request.");
12247
12781
  }
12248
12782
  // Check that prompt is set to none, throw error if it is set to anything else.
12249
12783
  if (request.prompt && request.prompt !== PromptValue.NONE) {
12784
+ acquireTokenMeasurement.endMeasurement({
12785
+ success: false
12786
+ });
12250
12787
  throw BrowserAuthError.createSilentPromptValueError(request.prompt);
12251
12788
  }
12252
12789
  return [4 /*yield*/, this.initializeAuthorizationRequest(__assign$1(__assign$1({}, request), { prompt: PromptValue.NONE }), exports.InteractionType.Silent)];
12253
12790
  case 1:
12254
12791
  silentRequest = _a.sent();
12255
- this.browserStorage.updateCacheEntries(silentRequest.state, silentRequest.nonce, silentRequest.authority, silentRequest.loginHint || "", silentRequest.account || null);
12792
+ this.browserStorage.updateCacheEntries(silentRequest.state, silentRequest.nonce, silentRequest.authority, silentRequest.loginHint || Constants.EMPTY_STRING, silentRequest.account || null);
12256
12793
  serverTelemetryManager = this.initializeServerTelemetryManager(this.apiId);
12257
12794
  _a.label = 2;
12258
12795
  case 2:
@@ -12267,7 +12804,14 @@
12267
12804
  return [4 /*yield*/, authClient.getAuthCodeUrl(silentRequest)];
12268
12805
  case 5:
12269
12806
  navigateUrl = _a.sent();
12270
- return [4 /*yield*/, this.silentTokenHelper(navigateUrl, authCodeRequest, authClient, this.logger)];
12807
+ return [4 /*yield*/, this.silentTokenHelper(navigateUrl, authCodeRequest, authClient, this.logger)
12808
+ .then(function (result) {
12809
+ acquireTokenMeasurement.endMeasurement({
12810
+ success: true,
12811
+ fromCache: false
12812
+ });
12813
+ return result;
12814
+ })];
12271
12815
  case 6: return [2 /*return*/, _a.sent()];
12272
12816
  case 7:
12273
12817
  e_1 = _a.sent();
@@ -12276,6 +12820,9 @@
12276
12820
  }
12277
12821
  serverTelemetryManager.cacheFailedRequest(e_1);
12278
12822
  this.browserStorage.cleanRequestByState(silentRequest.state);
12823
+ acquireTokenMeasurement.endMeasurement({
12824
+ success: false
12825
+ });
12279
12826
  throw e_1;
12280
12827
  case 8: return [2 /*return*/];
12281
12828
  }
@@ -12333,7 +12880,7 @@
12333
12880
  */
12334
12881
  SilentRefreshClient.prototype.acquireToken = function (request) {
12335
12882
  return __awaiter$1(this, void 0, void 0, function () {
12336
- var silentRequest, _a, serverTelemetryManager, refreshTokenClient;
12883
+ var silentRequest, _a, acquireTokenMeasurement, serverTelemetryManager, refreshTokenClient;
12337
12884
  var _this = this;
12338
12885
  return __generator$1(this, function (_b) {
12339
12886
  switch (_b.label) {
@@ -12342,17 +12889,29 @@
12342
12889
  return [4 /*yield*/, this.initializeBaseRequest(request)];
12343
12890
  case 1:
12344
12891
  silentRequest = __assign$1.apply(void 0, _a.concat([_b.sent()]));
12892
+ acquireTokenMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.SilentRefreshClientAcquireToken, silentRequest.correlationId);
12345
12893
  serverTelemetryManager = this.initializeServerTelemetryManager(exports.ApiId.acquireTokenSilent_silentFlow);
12346
12894
  return [4 /*yield*/, this.createRefreshTokenClient(serverTelemetryManager, silentRequest.authority, silentRequest.azureCloudOptions)];
12347
12895
  case 2:
12348
12896
  refreshTokenClient = _b.sent();
12349
12897
  this.logger.verbose("Refresh token client created");
12350
12898
  // Send request to renew token. Auth module will throw errors if token cannot be renewed.
12351
- return [2 /*return*/, refreshTokenClient.acquireTokenByRefreshToken(silentRequest).catch(function (e) {
12899
+ return [2 /*return*/, refreshTokenClient.acquireTokenByRefreshToken(silentRequest)
12900
+ .then(function (result) {
12901
+ acquireTokenMeasurement.endMeasurement({
12902
+ success: true,
12903
+ fromCache: result.fromCache
12904
+ });
12905
+ return result;
12906
+ })
12907
+ .catch(function (e) {
12352
12908
  if (e instanceof AuthError) {
12353
12909
  e.setCorrelationId(_this.correlationId);
12354
12910
  }
12355
12911
  serverTelemetryManager.cacheFailedRequest(e);
12912
+ acquireTokenMeasurement.endMeasurement({
12913
+ success: false
12914
+ });
12356
12915
  throw e;
12357
12916
  })];
12358
12917
  }
@@ -12525,8 +13084,8 @@
12525
13084
  */
12526
13085
  var SilentAuthCodeClient = /** @class */ (function (_super) {
12527
13086
  __extends$1(SilentAuthCodeClient, _super);
12528
- function SilentAuthCodeClient(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, apiId, correlationId) {
12529
- var _this = _super.call(this, config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, correlationId) || this;
13087
+ function SilentAuthCodeClient(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, apiId, performanceClient, correlationId) {
13088
+ var _this = _super.call(this, config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, performanceClient, correlationId) || this;
12530
13089
  _this.apiId = apiId;
12531
13090
  return _this;
12532
13091
  }
@@ -12548,7 +13107,7 @@
12548
13107
  return [4 /*yield*/, this.initializeAuthorizationRequest(request, exports.InteractionType.Silent)];
12549
13108
  case 1:
12550
13109
  silentRequest = _a.sent();
12551
- this.browserStorage.updateCacheEntries(silentRequest.state, silentRequest.nonce, silentRequest.authority, silentRequest.loginHint || "", silentRequest.account || null);
13110
+ this.browserStorage.updateCacheEntries(silentRequest.state, silentRequest.nonce, silentRequest.authority, silentRequest.loginHint || Constants.EMPTY_STRING, silentRequest.account || null);
12552
13111
  serverTelemetryManager = this.initializeServerTelemetryManager(this.apiId);
12553
13112
  _a.label = 2;
12554
13113
  case 2:
@@ -12590,6 +13149,110 @@
12590
13149
  return SilentAuthCodeClient;
12591
13150
  }(StandardInteractionClient));
12592
13151
 
13152
+ /*
13153
+ * Copyright (c) Microsoft Corporation. All rights reserved.
13154
+ * Licensed under the MIT License.
13155
+ */
13156
+ var BrowserPerformanceMeasurement = /** @class */ (function () {
13157
+ function BrowserPerformanceMeasurement(name, correlationId) {
13158
+ this.correlationId = correlationId;
13159
+ this.measureName = "msal.measure." + name + "." + this.correlationId;
13160
+ this.startMark = "msal.start." + name + "." + this.correlationId;
13161
+ this.endMark = "msal.end." + name + "." + this.correlationId;
13162
+ }
13163
+ BrowserPerformanceMeasurement.supportsBrowserPerformance = function () {
13164
+ return typeof window !== "undefined" &&
13165
+ typeof window.performance !== "undefined" &&
13166
+ typeof window.performance.mark === "function" &&
13167
+ typeof window.performance.measure === "function" &&
13168
+ typeof window.performance.clearMarks === "function" &&
13169
+ typeof window.performance.clearMeasures === "function" &&
13170
+ typeof window.performance.getEntriesByName === "function";
13171
+ };
13172
+ BrowserPerformanceMeasurement.prototype.startMeasurement = function () {
13173
+ if (BrowserPerformanceMeasurement.supportsBrowserPerformance()) {
13174
+ try {
13175
+ window.performance.mark(this.startMark);
13176
+ }
13177
+ catch (e) {
13178
+ // Silently catch
13179
+ }
13180
+ }
13181
+ };
13182
+ BrowserPerformanceMeasurement.prototype.endMeasurement = function () {
13183
+ if (BrowserPerformanceMeasurement.supportsBrowserPerformance()) {
13184
+ try {
13185
+ window.performance.mark(this.endMark);
13186
+ window.performance.measure(this.measureName, this.startMark, this.endMark);
13187
+ }
13188
+ catch (e) {
13189
+ // Silently catch
13190
+ }
13191
+ }
13192
+ };
13193
+ BrowserPerformanceMeasurement.prototype.flushMeasurement = function () {
13194
+ if (BrowserPerformanceMeasurement.supportsBrowserPerformance()) {
13195
+ try {
13196
+ var entriesForMeasurement = window.performance.getEntriesByName(this.measureName, "measure");
13197
+ if (entriesForMeasurement.length > 0) {
13198
+ var durationMs = entriesForMeasurement[0].duration;
13199
+ window.performance.clearMeasures(this.measureName);
13200
+ window.performance.clearMarks(this.startMark);
13201
+ window.performance.clearMarks(this.endMark);
13202
+ return durationMs;
13203
+ }
13204
+ }
13205
+ catch (e) {
13206
+ // Silently catch and return null
13207
+ }
13208
+ }
13209
+ return null;
13210
+ };
13211
+ return BrowserPerformanceMeasurement;
13212
+ }());
13213
+
13214
+ /*
13215
+ * Copyright (c) Microsoft Corporation. All rights reserved.
13216
+ * Licensed under the MIT License.
13217
+ */
13218
+ var BrowserPerformanceClient = /** @class */ (function (_super) {
13219
+ __extends$1(BrowserPerformanceClient, _super);
13220
+ function BrowserPerformanceClient(clientId, authority, logger, libraryName, libraryVersion, applicationTelemetry) {
13221
+ var _this = _super.call(this, clientId, authority, logger, libraryName, libraryVersion, applicationTelemetry) || this;
13222
+ _this.browserCrypto = new BrowserCrypto(_this.logger);
13223
+ _this.guidGenerator = new GuidGenerator(_this.browserCrypto);
13224
+ return _this;
13225
+ }
13226
+ BrowserPerformanceClient.prototype.startPerformanceMeasuremeant = function (measureName, correlationId) {
13227
+ return new BrowserPerformanceMeasurement(measureName, correlationId);
13228
+ };
13229
+ BrowserPerformanceClient.prototype.generateId = function () {
13230
+ return this.guidGenerator.generateGuid();
13231
+ };
13232
+ BrowserPerformanceClient.prototype.getPageVisibility = function () {
13233
+ var _a;
13234
+ return ((_a = document.visibilityState) === null || _a === void 0 ? void 0 : _a.toString()) || null;
13235
+ };
13236
+ /**
13237
+ * Starts measuring performance for a given operation. Returns a function that should be used to end the measurement.
13238
+ * Also captures browser page visibilityState.
13239
+ *
13240
+ * @param {PerformanceEvents} measureName
13241
+ * @param {?string} [correlationId]
13242
+ * @returns {((event?: Partial<PerformanceEvent>) => PerformanceEvent| null)}
13243
+ */
13244
+ BrowserPerformanceClient.prototype.startMeasurement = function (measureName, correlationId) {
13245
+ var _this = this;
13246
+ // Capture page visibilityState and then invoke start/end measurement
13247
+ var startPageVisibility = this.getPageVisibility();
13248
+ var inProgressEvent = _super.prototype.startMeasurement.call(this, measureName, correlationId);
13249
+ return __assign$1(__assign$1({}, inProgressEvent), { endMeasurement: function (event) {
13250
+ return inProgressEvent.endMeasurement(__assign$1({ startPageVisibility: startPageVisibility, endPageVisibility: _this.getPageVisibility() }, event));
13251
+ } });
13252
+ };
13253
+ return BrowserPerformanceClient;
13254
+ }(PerformanceClient));
13255
+
12593
13256
  /*
12594
13257
  * Copyright (c) Microsoft Corporation. All rights reserved.
12595
13258
  * Licensed under the MIT License.
@@ -12635,8 +13298,12 @@
12635
13298
  this.redirectResponse = new Map();
12636
13299
  // Initial hybrid spa map
12637
13300
  this.hybridAuthCodeResponses = new Map();
13301
+ // Initialize performance client
13302
+ this.performanceClient = this.isBrowserEnvironment ?
13303
+ new BrowserPerformanceClient(this.config.auth.clientId, this.config.auth.authority, this.logger, name, version, this.config.telemetry.application) :
13304
+ new StubPerformanceClient(this.config.auth.clientId, this.config.auth.authority, this.logger, name, version, this.config.telemetry.application);
12638
13305
  // Initialize the crypto class.
12639
- this.browserCrypto = this.isBrowserEnvironment ? new CryptoOps(this.logger) : DEFAULT_CRYPTO_IMPLEMENTATION;
13306
+ this.browserCrypto = this.isBrowserEnvironment ? new CryptoOps(this.logger, this.performanceClient) : DEFAULT_CRYPTO_IMPLEMENTATION;
12640
13307
  this.eventHandler = new EventHandler(this.logger, this.browserCrypto);
12641
13308
  // Initialize the browser storage class.
12642
13309
  this.browserStorage = this.isBrowserEnvironment ?
@@ -12666,8 +13333,8 @@
12666
13333
  if (typeof response === "undefined") {
12667
13334
  this.eventHandler.emitEvent(exports.EventType.HANDLE_REDIRECT_START, exports.InteractionType.Redirect);
12668
13335
  this.logger.verbose("handleRedirectPromise has been called for the first time, storing the promise");
12669
- correlationId = this.browserStorage.getTemporaryCache(exports.TemporaryCacheKeys.CORRELATION_ID, true) || "";
12670
- redirectClient = new RedirectClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, correlationId);
13336
+ correlationId = this.browserStorage.getTemporaryCache(exports.TemporaryCacheKeys.CORRELATION_ID, true) || Constants.EMPTY_STRING;
13337
+ redirectClient = new RedirectClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, this.performanceClient, correlationId);
12671
13338
  response = redirectClient.handleRedirectPromise(hash)
12672
13339
  .then(function (result) {
12673
13340
  if (result) {
@@ -12719,11 +13386,11 @@
12719
13386
  */
12720
13387
  ClientApplication.prototype.acquireTokenRedirect = function (request) {
12721
13388
  return __awaiter$1(this, void 0, void 0, function () {
12722
- var isLoggedIn, redirectClient;
13389
+ var correlationId, isLoggedIn, redirectClient;
12723
13390
  var _this = this;
12724
13391
  return __generator$1(this, function (_a) {
12725
- // Preflight request
12726
- this.logger.verbose("acquireTokenRedirect called");
13392
+ correlationId = this.getRequestCorrelationId(request);
13393
+ this.logger.verbose("acquireTokenRedirect called", correlationId);
12727
13394
  this.preflightBrowserEnvironmentCheck(exports.InteractionType.Redirect);
12728
13395
  isLoggedIn = this.getAllAccounts().length > 0;
12729
13396
  if (isLoggedIn) {
@@ -12732,8 +13399,8 @@
12732
13399
  else {
12733
13400
  this.eventHandler.emitEvent(exports.EventType.LOGIN_START, exports.InteractionType.Redirect, request);
12734
13401
  }
12735
- redirectClient = new RedirectClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, request.correlationId);
12736
- return [2 /*return*/, redirectClient.acquireToken(request).catch(function (e) {
13402
+ redirectClient = new RedirectClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, this.performanceClient, correlationId);
13403
+ return [2 /*return*/, redirectClient.acquireToken(__assign$1(__assign$1({}, request), { correlationId: correlationId })).catch(function (e) {
12737
13404
  // If logged in, emit acquire token events
12738
13405
  if (isLoggedIn) {
12739
13406
  _this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_FAILURE, exports.InteractionType.Redirect, null, e);
@@ -12757,8 +13424,9 @@
12757
13424
  */
12758
13425
  ClientApplication.prototype.acquireTokenPopup = function (request) {
12759
13426
  var _this = this;
13427
+ var correlationId = this.getRequestCorrelationId(request);
12760
13428
  try {
12761
- this.logger.verbose("acquireTokenPopup called", request.correlationId);
13429
+ this.logger.verbose("acquireTokenPopup called", correlationId);
12762
13430
  this.preflightBrowserEnvironmentCheck(exports.InteractionType.Popup);
12763
13431
  }
12764
13432
  catch (e) {
@@ -12773,8 +13441,8 @@
12773
13441
  else {
12774
13442
  this.eventHandler.emitEvent(exports.EventType.LOGIN_START, exports.InteractionType.Popup, request);
12775
13443
  }
12776
- var popupClient = new PopupClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, request.correlationId);
12777
- return popupClient.acquireToken(request).then(function (result) {
13444
+ var popupClient = new PopupClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, this.performanceClient, correlationId);
13445
+ return popupClient.acquireToken(__assign$1(__assign$1({}, request), { correlationId: correlationId })).then(function (result) {
12778
13446
  // If logged in, emit acquire token events
12779
13447
  var isLoggingIn = loggedInAccounts.length < _this.getAllAccounts().length;
12780
13448
  if (isLoggingIn) {
@@ -12814,25 +13482,35 @@
12814
13482
  */
12815
13483
  ClientApplication.prototype.ssoSilent = function (request) {
12816
13484
  return __awaiter$1(this, void 0, void 0, function () {
12817
- var silentIframeClient, silentTokenResult, e_1;
13485
+ var correlationId, ssoSilentMeasurement, silentIframeClient, silentTokenResult, e_1;
12818
13486
  return __generator$1(this, function (_a) {
12819
13487
  switch (_a.label) {
12820
13488
  case 0:
13489
+ correlationId = this.getRequestCorrelationId(request);
12821
13490
  this.preflightBrowserEnvironmentCheck(exports.InteractionType.Silent);
12822
- this.logger.verbose("ssoSilent called", request.correlationId);
13491
+ ssoSilentMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.SsoSilent, correlationId);
13492
+ this.logger.verbose("ssoSilent called", correlationId);
12823
13493
  this.eventHandler.emitEvent(exports.EventType.SSO_SILENT_START, exports.InteractionType.Silent, request);
12824
13494
  _a.label = 1;
12825
13495
  case 1:
12826
13496
  _a.trys.push([1, 3, , 4]);
12827
- silentIframeClient = new SilentIframeClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, exports.ApiId.ssoSilent, request.correlationId);
12828
- return [4 /*yield*/, silentIframeClient.acquireToken(request)];
13497
+ silentIframeClient = new SilentIframeClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, exports.ApiId.ssoSilent, this.performanceClient, correlationId);
13498
+ return [4 /*yield*/, silentIframeClient.acquireToken(__assign$1(__assign$1({}, request), { correlationId: correlationId }))];
12829
13499
  case 2:
12830
13500
  silentTokenResult = _a.sent();
12831
13501
  this.eventHandler.emitEvent(exports.EventType.SSO_SILENT_SUCCESS, exports.InteractionType.Silent, silentTokenResult);
13502
+ ssoSilentMeasurement.endMeasurement({
13503
+ success: true
13504
+ });
13505
+ ssoSilentMeasurement.flushMeasurement();
12832
13506
  return [2 /*return*/, silentTokenResult];
12833
13507
  case 3:
12834
13508
  e_1 = _a.sent();
12835
13509
  this.eventHandler.emitEvent(exports.EventType.SSO_SILENT_FAILURE, exports.InteractionType.Silent, null, e_1);
13510
+ ssoSilentMeasurement.endMeasurement({
13511
+ success: false
13512
+ });
13513
+ ssoSilentMeasurement.flushMeasurement();
12836
13514
  throw e_1;
12837
13515
  case 4: return [2 /*return*/];
12838
13516
  }
@@ -12851,38 +13529,56 @@
12851
13529
  */
12852
13530
  ClientApplication.prototype.acquireTokenByCode = function (request) {
12853
13531
  return __awaiter$1(this, void 0, void 0, function () {
12854
- var response;
13532
+ var correlationId, atbcMeasurement, response;
12855
13533
  var _this = this;
12856
13534
  return __generator$1(this, function (_a) {
13535
+ correlationId = this.getRequestCorrelationId(request);
12857
13536
  this.preflightBrowserEnvironmentCheck(exports.InteractionType.Silent);
12858
- this.logger.trace("acquireTokenByCode called", request.correlationId);
13537
+ this.logger.trace("acquireTokenByCode called", correlationId);
12859
13538
  this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_BY_CODE_START, exports.InteractionType.Silent, request);
13539
+ atbcMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.AcquireTokenByCode, request.correlationId);
12860
13540
  try {
12861
13541
  if (!request.code) {
12862
13542
  throw BrowserAuthError.createAuthCodeRequiredError();
12863
13543
  }
12864
13544
  response = this.hybridAuthCodeResponses.get(request.code);
12865
13545
  if (!response) {
12866
- this.logger.verbose("Initiating new acquireTokenByCode request", request.correlationId);
12867
- response = this.acquireTokenByCodeAsync(request)
13546
+ this.logger.verbose("Initiating new acquireTokenByCode request", correlationId);
13547
+ response = this.acquireTokenByCodeAsync(__assign$1(__assign$1({}, request), { correlationId: correlationId }))
12868
13548
  .then(function (result) {
12869
13549
  _this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_BY_CODE_SUCCESS, exports.InteractionType.Silent, result);
12870
13550
  _this.hybridAuthCodeResponses.delete(request.code);
13551
+ atbcMeasurement.endMeasurement({
13552
+ success: true
13553
+ });
13554
+ atbcMeasurement.flushMeasurement();
12871
13555
  return result;
12872
13556
  })
12873
13557
  .catch(function (error) {
12874
13558
  _this.hybridAuthCodeResponses.delete(request.code);
13559
+ _this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_BY_CODE_FAILURE, exports.InteractionType.Silent, null, error);
13560
+ atbcMeasurement.endMeasurement({
13561
+ success: false
13562
+ });
13563
+ atbcMeasurement.flushMeasurement();
12875
13564
  throw error;
12876
13565
  });
12877
13566
  this.hybridAuthCodeResponses.set(request.code, response);
12878
13567
  }
12879
13568
  else {
12880
13569
  this.logger.verbose("Existing acquireTokenByCode request found", request.correlationId);
13570
+ atbcMeasurement.endMeasurement({
13571
+ success: true
13572
+ });
13573
+ atbcMeasurement.discardMeasurement();
12881
13574
  }
12882
13575
  return [2 /*return*/, response];
12883
13576
  }
12884
13577
  catch (e) {
12885
13578
  this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_BY_CODE_FAILURE, exports.InteractionType.Silent, null, e);
13579
+ atbcMeasurement.endMeasurement({
13580
+ success: false
13581
+ });
12886
13582
  throw e;
12887
13583
  }
12888
13584
  return [2 /*return*/];
@@ -12901,7 +13597,7 @@
12901
13597
  switch (_a.label) {
12902
13598
  case 0:
12903
13599
  this.logger.trace("acquireTokenByCodeAsync called", request.correlationId);
12904
- silentAuthCodeClient = new SilentAuthCodeClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, exports.ApiId.acquireTokenByCode, request.correlationId);
13600
+ silentAuthCodeClient = new SilentAuthCodeClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, exports.ApiId.acquireTokenByCode, this.performanceClient, request.correlationId);
12905
13601
  return [4 /*yield*/, silentAuthCodeClient.acquireToken(request)];
12906
13602
  case 1:
12907
13603
  silentTokenResult = _a.sent();
@@ -12923,22 +13619,47 @@
12923
13619
  */
12924
13620
  ClientApplication.prototype.acquireTokenByRefreshToken = function (request) {
12925
13621
  return __awaiter$1(this, void 0, void 0, function () {
12926
- var silentRefreshClient;
13622
+ var atbrtMeasurement, silentRefreshClient;
12927
13623
  var _this = this;
12928
13624
  return __generator$1(this, function (_a) {
12929
- this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_NETWORK_START, exports.InteractionType.Silent, request);
12930
13625
  // block the reload if it occurred inside a hidden iframe
12931
13626
  BrowserUtils.blockReloadInHiddenIframes();
12932
- silentRefreshClient = new SilentRefreshClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, request.correlationId);
12933
- return [2 /*return*/, silentRefreshClient.acquireToken(request).catch(function (e) {
13627
+ atbrtMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.AcquireTokenByRefreshToken, request.correlationId);
13628
+ this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_NETWORK_START, exports.InteractionType.Silent, request);
13629
+ silentRefreshClient = new SilentRefreshClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, this.performanceClient, request.correlationId);
13630
+ return [2 /*return*/, silentRefreshClient.acquireToken(request)
13631
+ .then(function (result) {
13632
+ atbrtMeasurement.endMeasurement({
13633
+ success: true,
13634
+ fromCache: result.fromCache
13635
+ });
13636
+ return result;
13637
+ })
13638
+ .catch(function (e) {
12934
13639
  var isServerError = e instanceof ServerError;
12935
13640
  var isInteractionRequiredError = e instanceof InteractionRequiredAuthError;
12936
13641
  var isInvalidGrantError = (e.errorCode === BrowserConstants.INVALID_GRANT_ERROR);
12937
13642
  if (isServerError && isInvalidGrantError && !isInteractionRequiredError) {
12938
13643
  _this.logger.verbose("Refresh token expired or invalid, attempting acquire token by iframe", request.correlationId);
12939
- var silentIframeClient = new SilentIframeClient(_this.config, _this.browserStorage, _this.browserCrypto, _this.logger, _this.eventHandler, _this.navigationClient, exports.ApiId.acquireTokenSilent_authCode, request.correlationId);
12940
- return silentIframeClient.acquireToken(request);
13644
+ var silentIframeClient = new SilentIframeClient(_this.config, _this.browserStorage, _this.browserCrypto, _this.logger, _this.eventHandler, _this.navigationClient, exports.ApiId.acquireTokenSilent_authCode, _this.performanceClient, request.correlationId);
13645
+ return silentIframeClient.acquireToken(request)
13646
+ .then(function (result) {
13647
+ atbrtMeasurement.endMeasurement({
13648
+ success: true,
13649
+ fromCache: result.fromCache
13650
+ });
13651
+ return result;
13652
+ })
13653
+ .catch(function (error) {
13654
+ atbrtMeasurement.endMeasurement({
13655
+ success: false
13656
+ });
13657
+ throw error;
13658
+ });
12941
13659
  }
13660
+ atbrtMeasurement.endMeasurement({
13661
+ success: false
13662
+ });
12942
13663
  throw e;
12943
13664
  })];
12944
13665
  });
@@ -12953,9 +13674,11 @@
12953
13674
  */
12954
13675
  ClientApplication.prototype.logout = function (logoutRequest) {
12955
13676
  return __awaiter$1(this, void 0, void 0, function () {
13677
+ var correlationId;
12956
13678
  return __generator$1(this, function (_a) {
12957
- this.logger.warning("logout API is deprecated and will be removed in msal-browser v3.0.0. Use logoutRedirect instead.");
12958
- return [2 /*return*/, this.logoutRedirect(logoutRequest)];
13679
+ correlationId = this.getRequestCorrelationId(logoutRequest);
13680
+ this.logger.warning("logout API is deprecated and will be removed in msal-browser v3.0.0. Use logoutRedirect instead.", correlationId);
13681
+ return [2 /*return*/, this.logoutRedirect(__assign$1({ correlationId: correlationId }, logoutRequest))];
12959
13682
  });
12960
13683
  });
12961
13684
  };
@@ -12966,11 +13689,12 @@
12966
13689
  */
12967
13690
  ClientApplication.prototype.logoutRedirect = function (logoutRequest) {
12968
13691
  return __awaiter$1(this, void 0, void 0, function () {
12969
- var redirectClient;
13692
+ var correlationId, redirectClient;
12970
13693
  return __generator$1(this, function (_a) {
13694
+ correlationId = this.getRequestCorrelationId(logoutRequest);
12971
13695
  this.preflightBrowserEnvironmentCheck(exports.InteractionType.Redirect);
12972
- redirectClient = new RedirectClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, logoutRequest === null || logoutRequest === void 0 ? void 0 : logoutRequest.correlationId);
12973
- return [2 /*return*/, redirectClient.logout(logoutRequest)];
13696
+ redirectClient = new RedirectClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, this.performanceClient, correlationId);
13697
+ return [2 /*return*/, redirectClient.logout(__assign$1({ correlationId: correlationId }, logoutRequest))];
12974
13698
  });
12975
13699
  });
12976
13700
  };
@@ -12980,9 +13704,10 @@
12980
13704
  */
12981
13705
  ClientApplication.prototype.logoutPopup = function (logoutRequest) {
12982
13706
  try {
13707
+ var correlationId = this.getRequestCorrelationId(logoutRequest);
12983
13708
  this.preflightBrowserEnvironmentCheck(exports.InteractionType.Popup);
12984
- var popupClient = new PopupClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, logoutRequest === null || logoutRequest === void 0 ? void 0 : logoutRequest.correlationId);
12985
- return popupClient.logout(logoutRequest);
13709
+ var popupClient = new PopupClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, this.performanceClient, correlationId);
13710
+ return popupClient.logout(__assign$1({ correlationId: correlationId }, logoutRequest));
12986
13711
  }
12987
13712
  catch (e) {
12988
13713
  // Since this function is syncronous we need to reject
@@ -13124,6 +13849,24 @@
13124
13849
  ClientApplication.prototype.removeEventCallback = function (callbackId) {
13125
13850
  this.eventHandler.removeEventCallback(callbackId);
13126
13851
  };
13852
+ /**
13853
+ * Registers a callback to receive performance events.
13854
+ *
13855
+ * @param {PerformanceCallbackFunction} callback
13856
+ * @returns {string}
13857
+ */
13858
+ ClientApplication.prototype.addPerformanceCallback = function (callback) {
13859
+ return this.performanceClient.addPerformanceCallback(callback);
13860
+ };
13861
+ /**
13862
+ * Removes a callback registered with addPerformanceCallback.
13863
+ *
13864
+ * @param {string} callbackId
13865
+ * @returns {boolean}
13866
+ */
13867
+ ClientApplication.prototype.removePerformanceCallback = function (callbackId) {
13868
+ return this.performanceClient.removePerformanceCallback(callbackId);
13869
+ };
13127
13870
  /**
13128
13871
  * Adds event listener that emits an event when a user account is added or removed from localstorage in a different browser tab or window
13129
13872
  */
@@ -13177,6 +13920,26 @@
13177
13920
  ClientApplication.prototype.getConfiguration = function () {
13178
13921
  return this.config;
13179
13922
  };
13923
+ /**
13924
+ * Generates a correlation id for a request if none is provided.
13925
+ *
13926
+ * @protected
13927
+ * @param {?Partial<BaseAuthRequest>} [request]
13928
+ * @returns {string}
13929
+ */
13930
+ ClientApplication.prototype.getRequestCorrelationId = function (request) {
13931
+ if (request === null || request === void 0 ? void 0 : request.correlationId) {
13932
+ return request.correlationId;
13933
+ }
13934
+ if (this.isBrowserEnvironment) {
13935
+ return this.browserCrypto.createNewGuid();
13936
+ }
13937
+ /*
13938
+ * Included for fallback for non-browser environments,
13939
+ * and to ensure this method always returns a string.
13940
+ */
13941
+ return Constants.EMPTY_STRING;
13942
+ };
13180
13943
  return ClientApplication;
13181
13944
  }());
13182
13945
 
@@ -13195,10 +13958,11 @@
13195
13958
  */
13196
13959
  SilentCacheClient.prototype.acquireToken = function (silentRequest) {
13197
13960
  return __awaiter$1(this, void 0, void 0, function () {
13198
- var serverTelemetryManager, silentAuthClient, cachedToken, error_1;
13961
+ var acquireTokenMeasurement, serverTelemetryManager, silentAuthClient, cachedToken, error_1;
13199
13962
  return __generator$1(this, function (_a) {
13200
13963
  switch (_a.label) {
13201
13964
  case 0:
13965
+ acquireTokenMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.SilentCacheClientAcquireToken, silentRequest.correlationId);
13202
13966
  serverTelemetryManager = this.initializeServerTelemetryManager(exports.ApiId.acquireTokenSilent_silentFlow);
13203
13967
  return [4 /*yield*/, this.createSilentFlowClient(serverTelemetryManager, silentRequest.authority, silentRequest.azureCloudOptions)];
13204
13968
  case 1:
@@ -13211,12 +13975,19 @@
13211
13975
  case 3:
13212
13976
  cachedToken = _a.sent();
13213
13977
  this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_SUCCESS, exports.InteractionType.Silent, cachedToken);
13978
+ acquireTokenMeasurement.endMeasurement({
13979
+ success: true,
13980
+ fromCache: true
13981
+ });
13214
13982
  return [2 /*return*/, cachedToken];
13215
13983
  case 4:
13216
13984
  error_1 = _a.sent();
13217
13985
  if (error_1 instanceof BrowserAuthError && error_1.errorCode === BrowserAuthErrorMessage.signingKeyNotFoundInStorage.code) {
13218
13986
  this.logger.verbose("Signing keypair for bound access token not found. Refreshing bound access token and generating a new crypto keypair.");
13219
13987
  }
13988
+ acquireTokenMeasurement.endMeasurement({
13989
+ success: false
13990
+ });
13220
13991
  throw error_1;
13221
13992
  case 5: return [2 /*return*/];
13222
13993
  }
@@ -13311,9 +14082,11 @@
13311
14082
  */
13312
14083
  PublicClientApplication.prototype.loginRedirect = function (request) {
13313
14084
  return __awaiter$1(this, void 0, void 0, function () {
14085
+ var correlationId;
13314
14086
  return __generator$1(this, function (_a) {
13315
- this.logger.verbose("loginRedirect called");
13316
- return [2 /*return*/, this.acquireTokenRedirect(request || DEFAULT_REQUEST)];
14087
+ correlationId = this.getRequestCorrelationId(request);
14088
+ this.logger.verbose("loginRedirect called", correlationId);
14089
+ return [2 /*return*/, this.acquireTokenRedirect(__assign$1({ correlationId: correlationId }, (request || DEFAULT_REQUEST)))];
13317
14090
  });
13318
14091
  });
13319
14092
  };
@@ -13325,8 +14098,9 @@
13325
14098
  * @returns A promise that is fulfilled when this function has completed, or rejected if an error was raised.
13326
14099
  */
13327
14100
  PublicClientApplication.prototype.loginPopup = function (request) {
13328
- this.logger.verbose("loginPopup called");
13329
- return this.acquireTokenPopup(request || DEFAULT_REQUEST);
14101
+ var correlationId = this.getRequestCorrelationId(request);
14102
+ this.logger.verbose("loginPopup called", correlationId);
14103
+ return this.acquireTokenPopup(__assign$1({ correlationId: correlationId }, (request || DEFAULT_REQUEST)));
13330
14104
  };
13331
14105
  /**
13332
14106
  * Silently acquire an access token for a given set of scopes. Returns currently processing promise if parallel requests are made.
@@ -13336,18 +14110,20 @@
13336
14110
  */
13337
14111
  PublicClientApplication.prototype.acquireTokenSilent = function (request) {
13338
14112
  return __awaiter$1(this, void 0, void 0, function () {
13339
- var account, thumbprint, silentRequestKey, cachedResponse, response;
14113
+ var correlationId, atsMeasurement, account, thumbprint, silentRequestKey, cachedResponse, response;
13340
14114
  var _this = this;
13341
14115
  return __generator$1(this, function (_a) {
14116
+ correlationId = this.getRequestCorrelationId(request);
14117
+ atsMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.AcquireTokenSilent, correlationId);
13342
14118
  this.preflightBrowserEnvironmentCheck(exports.InteractionType.Silent);
13343
- this.logger.verbose("acquireTokenSilent called", request.correlationId);
14119
+ this.logger.verbose("acquireTokenSilent called", correlationId);
13344
14120
  account = request.account || this.getActiveAccount();
13345
14121
  if (!account) {
13346
14122
  throw BrowserAuthError.createNoAccountError();
13347
14123
  }
13348
14124
  thumbprint = {
13349
14125
  clientId: this.config.auth.clientId,
13350
- authority: request.authority || "",
14126
+ authority: request.authority || Constants.EMPTY_STRING,
13351
14127
  scopes: request.scopes,
13352
14128
  homeAccountIdentifier: account.homeAccountId,
13353
14129
  claims: request.claims,
@@ -13360,21 +14136,35 @@
13360
14136
  silentRequestKey = JSON.stringify(thumbprint);
13361
14137
  cachedResponse = this.activeSilentTokenRequests.get(silentRequestKey);
13362
14138
  if (typeof cachedResponse === "undefined") {
13363
- this.logger.verbose("acquireTokenSilent called for the first time, storing active request", request.correlationId);
13364
- response = this.acquireTokenSilentAsync(request, account)
14139
+ this.logger.verbose("acquireTokenSilent called for the first time, storing active request", correlationId);
14140
+ response = this.acquireTokenSilentAsync(__assign$1(__assign$1({}, request), { correlationId: correlationId }), account)
13365
14141
  .then(function (result) {
13366
14142
  _this.activeSilentTokenRequests.delete(silentRequestKey);
14143
+ atsMeasurement.endMeasurement({
14144
+ success: true,
14145
+ fromCache: result.fromCache
14146
+ });
14147
+ atsMeasurement.flushMeasurement();
13367
14148
  return result;
13368
14149
  })
13369
14150
  .catch(function (error) {
13370
14151
  _this.activeSilentTokenRequests.delete(silentRequestKey);
14152
+ atsMeasurement.endMeasurement({
14153
+ success: false
14154
+ });
14155
+ atsMeasurement.flushMeasurement();
13371
14156
  throw error;
13372
14157
  });
13373
14158
  this.activeSilentTokenRequests.set(silentRequestKey, response);
13374
14159
  return [2 /*return*/, response];
13375
14160
  }
13376
14161
  else {
13377
- this.logger.verbose("acquireTokenSilent has been called previously, returning the result from the first call", request.correlationId);
14162
+ this.logger.verbose("acquireTokenSilent has been called previously, returning the result from the first call", correlationId);
14163
+ atsMeasurement.endMeasurement({
14164
+ success: true
14165
+ });
14166
+ // Discard measurements for memoized calls, as they are usually only a couple of ms and will artificially deflate metrics
14167
+ atsMeasurement.discardMeasurement();
13378
14168
  return [2 /*return*/, cachedResponse];
13379
14169
  }
13380
14170
  });
@@ -13388,17 +14178,26 @@
13388
14178
  */
13389
14179
  PublicClientApplication.prototype.acquireTokenSilentAsync = function (request, account) {
13390
14180
  return __awaiter$1(this, void 0, void 0, function () {
13391
- var silentCacheClient, silentRequest;
14181
+ var astsAsyncMeasurement, silentCacheClient, silentRequest;
13392
14182
  var _this = this;
13393
14183
  return __generator$1(this, function (_a) {
13394
14184
  switch (_a.label) {
13395
14185
  case 0:
13396
- silentCacheClient = new SilentCacheClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, request.correlationId);
14186
+ astsAsyncMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.AcquireTokenSilentAsync, request.correlationId);
14187
+ silentCacheClient = new SilentCacheClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, this.performanceClient, request.correlationId);
13397
14188
  return [4 /*yield*/, silentCacheClient.initializeSilentRequest(request, account)];
13398
14189
  case 1:
13399
14190
  silentRequest = _a.sent();
13400
14191
  this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_START, exports.InteractionType.Silent, request);
13401
- return [2 /*return*/, silentCacheClient.acquireToken(silentRequest).catch(function () { return __awaiter$1(_this, void 0, void 0, function () {
14192
+ return [2 /*return*/, silentCacheClient.acquireToken(silentRequest)
14193
+ .then(function (result) {
14194
+ astsAsyncMeasurement.endMeasurement({
14195
+ success: true,
14196
+ fromCache: result.fromCache
14197
+ });
14198
+ return result;
14199
+ })
14200
+ .catch(function () { return __awaiter$1(_this, void 0, void 0, function () {
13402
14201
  var tokenRenewalResult, tokenRenewalError_1;
13403
14202
  return __generator$1(this, function (_a) {
13404
14203
  switch (_a.label) {
@@ -13408,10 +14207,17 @@
13408
14207
  case 1:
13409
14208
  tokenRenewalResult = _a.sent();
13410
14209
  this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_SUCCESS, exports.InteractionType.Silent, tokenRenewalResult);
14210
+ astsAsyncMeasurement.endMeasurement({
14211
+ success: true,
14212
+ fromCache: tokenRenewalResult.fromCache
14213
+ });
13411
14214
  return [2 /*return*/, tokenRenewalResult];
13412
14215
  case 2:
13413
14216
  tokenRenewalError_1 = _a.sent();
13414
14217
  this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_FAILURE, exports.InteractionType.Silent, null, tokenRenewalError_1);
14218
+ astsAsyncMeasurement.endMeasurement({
14219
+ success: false
14220
+ });
13415
14221
  throw tokenRenewalError_1;
13416
14222
  case 3: return [2 /*return*/];
13417
14223
  }
@@ -13480,6 +14286,12 @@
13480
14286
  removeEventCallback: function () {
13481
14287
  return;
13482
14288
  },
14289
+ addPerformanceCallback: function () {
14290
+ return "";
14291
+ },
14292
+ removePerformanceCallback: function () {
14293
+ return false;
14294
+ },
13483
14295
  enableAccountStorageEvents: function () {
13484
14296
  return;
13485
14297
  },
@@ -13647,6 +14459,7 @@
13647
14459
  exports.BrowserConfigurationAuthError = BrowserConfigurationAuthError;
13648
14460
  exports.BrowserConfigurationAuthErrorMessage = BrowserConfigurationAuthErrorMessage;
13649
14461
  exports.BrowserConstants = BrowserConstants;
14462
+ exports.BrowserPerformanceClient = BrowserPerformanceClient;
13650
14463
  exports.BrowserUtils = BrowserUtils;
13651
14464
  exports.ClientAuthError = ClientAuthError;
13652
14465
  exports.ClientAuthErrorMessage = ClientAuthErrorMessage;