@azure/msal-browser 2.21.0 → 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 (147) hide show
  1. package/README.md +1 -1
  2. package/dist/_virtual/_tslib.js +1 -1
  3. package/dist/app/ClientApplication.d.ts +31 -2
  4. package/dist/app/ClientApplication.d.ts.map +1 -1
  5. package/dist/app/ClientApplication.js +152 -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 +2 -2
  12. package/dist/app/PublicClientApplication.d.ts.map +1 -1
  13. package/dist/app/PublicClientApplication.js +51 -15
  14. package/dist/app/PublicClientApplication.js.map +1 -1
  15. package/dist/cache/AsyncMemoryStorage.d.ts +3 -2
  16. package/dist/cache/AsyncMemoryStorage.d.ts.map +1 -1
  17. package/dist/cache/AsyncMemoryStorage.js +17 -6
  18. package/dist/cache/AsyncMemoryStorage.js.map +1 -1
  19. package/dist/cache/BrowserCacheManager.d.ts +14 -12
  20. package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
  21. package/dist/cache/BrowserCacheManager.js +16 -12
  22. package/dist/cache/BrowserCacheManager.js.map +1 -1
  23. package/dist/cache/BrowserStorage.js +1 -1
  24. package/dist/cache/DatabaseStorage.d.ts +5 -0
  25. package/dist/cache/DatabaseStorage.d.ts.map +1 -1
  26. package/dist/cache/DatabaseStorage.js +65 -13
  27. package/dist/cache/DatabaseStorage.js.map +1 -1
  28. package/dist/cache/MemoryStorage.js +1 -1
  29. package/dist/cache/TokenCache.d.ts.map +1 -1
  30. package/dist/cache/TokenCache.js +4 -3
  31. package/dist/cache/TokenCache.js.map +1 -1
  32. package/dist/config/Configuration.d.ts +23 -10
  33. package/dist/config/Configuration.d.ts.map +1 -1
  34. package/dist/config/Configuration.js +21 -10
  35. package/dist/config/Configuration.js.map +1 -1
  36. package/dist/crypto/BrowserCrypto.d.ts.map +1 -1
  37. package/dist/crypto/BrowserCrypto.js +7 -6
  38. package/dist/crypto/BrowserCrypto.js.map +1 -1
  39. package/dist/crypto/CryptoOps.d.ts +12 -3
  40. package/dist/crypto/CryptoOps.d.ts.map +1 -1
  41. package/dist/crypto/CryptoOps.js +71 -36
  42. package/dist/crypto/CryptoOps.js.map +1 -1
  43. package/dist/crypto/GuidGenerator.d.ts +3 -2
  44. package/dist/crypto/GuidGenerator.d.ts.map +1 -1
  45. package/dist/crypto/GuidGenerator.js +4 -3
  46. package/dist/crypto/GuidGenerator.js.map +1 -1
  47. package/dist/crypto/PkceGenerator.js +1 -1
  48. package/dist/crypto/SignedHttpRequest.js +1 -1
  49. package/dist/encode/Base64Decode.d.ts.map +1 -1
  50. package/dist/encode/Base64Decode.js +3 -2
  51. package/dist/encode/Base64Decode.js.map +1 -1
  52. package/dist/encode/Base64Encode.d.ts.map +1 -1
  53. package/dist/encode/Base64Encode.js +5 -4
  54. package/dist/encode/Base64Encode.js.map +1 -1
  55. package/dist/error/BrowserAuthError.js +1 -1
  56. package/dist/error/BrowserConfigurationAuthError.js +1 -1
  57. package/dist/event/EventHandler.js +1 -1
  58. package/dist/event/EventMessage.js +1 -1
  59. package/dist/event/EventType.js +1 -1
  60. package/dist/index.cjs.js +1380 -436
  61. package/dist/index.cjs.js.map +1 -1
  62. package/dist/index.d.ts +15 -2
  63. package/dist/index.d.ts.map +1 -1
  64. package/dist/index.js +15 -3
  65. package/dist/index.js.map +1 -1
  66. package/dist/interaction_client/BaseInteractionClient.d.ts +4 -3
  67. package/dist/interaction_client/BaseInteractionClient.d.ts.map +1 -1
  68. package/dist/interaction_client/BaseInteractionClient.js +14 -14
  69. package/dist/interaction_client/BaseInteractionClient.js.map +1 -1
  70. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.js +1 -1
  71. package/dist/interaction_client/PopupClient.d.ts +4 -3
  72. package/dist/interaction_client/PopupClient.d.ts.map +1 -1
  73. package/dist/interaction_client/PopupClient.js +52 -60
  74. package/dist/interaction_client/PopupClient.js.map +1 -1
  75. package/dist/interaction_client/RedirectClient.d.ts +3 -3
  76. package/dist/interaction_client/RedirectClient.d.ts.map +1 -1
  77. package/dist/interaction_client/RedirectClient.js +22 -10
  78. package/dist/interaction_client/RedirectClient.js.map +1 -1
  79. package/dist/interaction_client/SilentAuthCodeClient.d.ts +2 -2
  80. package/dist/interaction_client/SilentAuthCodeClient.d.ts.map +1 -1
  81. package/dist/interaction_client/SilentAuthCodeClient.js +5 -4
  82. package/dist/interaction_client/SilentAuthCodeClient.js.map +1 -1
  83. package/dist/interaction_client/SilentCacheClient.d.ts +2 -2
  84. package/dist/interaction_client/SilentCacheClient.d.ts.map +1 -1
  85. package/dist/interaction_client/SilentCacheClient.js +14 -6
  86. package/dist/interaction_client/SilentCacheClient.js.map +1 -1
  87. package/dist/interaction_client/SilentIframeClient.d.ts +4 -4
  88. package/dist/interaction_client/SilentIframeClient.d.ts.map +1 -1
  89. package/dist/interaction_client/SilentIframeClient.js +22 -7
  90. package/dist/interaction_client/SilentIframeClient.js.map +1 -1
  91. package/dist/interaction_client/SilentRefreshClient.d.ts +2 -2
  92. package/dist/interaction_client/SilentRefreshClient.d.ts.map +1 -1
  93. package/dist/interaction_client/SilentRefreshClient.js +19 -7
  94. package/dist/interaction_client/SilentRefreshClient.js.map +1 -1
  95. package/dist/interaction_client/StandardInteractionClient.d.ts +11 -11
  96. package/dist/interaction_client/StandardInteractionClient.d.ts.map +1 -1
  97. package/dist/interaction_client/StandardInteractionClient.js +84 -56
  98. package/dist/interaction_client/StandardInteractionClient.js.map +1 -1
  99. package/dist/interaction_handler/InteractionHandler.js +1 -1
  100. package/dist/interaction_handler/PopupHandler.d.ts.map +1 -1
  101. package/dist/interaction_handler/PopupHandler.js +1 -3
  102. package/dist/interaction_handler/PopupHandler.js.map +1 -1
  103. package/dist/interaction_handler/RedirectHandler.d.ts.map +1 -1
  104. package/dist/interaction_handler/RedirectHandler.js +1 -2
  105. package/dist/interaction_handler/RedirectHandler.js.map +1 -1
  106. package/dist/interaction_handler/SilentHandler.js +1 -1
  107. package/dist/navigation/NavigationClient.js +1 -1
  108. package/dist/network/FetchClient.d.ts.map +1 -1
  109. package/dist/network/FetchClient.js +3 -2
  110. package/dist/network/FetchClient.js.map +1 -1
  111. package/dist/network/XhrClient.js +1 -1
  112. package/dist/packageMetadata.d.ts +1 -1
  113. package/dist/packageMetadata.js +2 -2
  114. package/dist/packageMetadata.js.map +1 -1
  115. package/dist/request/EndSessionPopupRequest.d.ts +1 -0
  116. package/dist/request/EndSessionPopupRequest.d.ts.map +1 -1
  117. package/dist/request/EndSessionRequest.d.ts +1 -0
  118. package/dist/request/EndSessionRequest.d.ts.map +1 -1
  119. package/dist/telemetry/BrowserPerformanceClient.d.ts +19 -0
  120. package/dist/telemetry/BrowserPerformanceClient.d.ts.map +1 -0
  121. package/dist/telemetry/BrowserPerformanceClient.js +52 -0
  122. package/dist/telemetry/BrowserPerformanceClient.js.map +1 -0
  123. package/dist/telemetry/BrowserPerformanceMeasurement.d.ts +13 -0
  124. package/dist/telemetry/BrowserPerformanceMeasurement.d.ts.map +1 -0
  125. package/dist/telemetry/BrowserPerformanceMeasurement.js +66 -0
  126. package/dist/telemetry/BrowserPerformanceMeasurement.js.map +1 -0
  127. package/dist/utils/BrowserConstants.d.ts +2 -1
  128. package/dist/utils/BrowserConstants.d.ts.map +1 -1
  129. package/dist/utils/BrowserConstants.js +2 -1
  130. package/dist/utils/BrowserConstants.js.map +1 -1
  131. package/dist/utils/BrowserProtocolUtils.js +1 -1
  132. package/dist/utils/BrowserStringUtils.d.ts.map +1 -1
  133. package/dist/utils/BrowserStringUtils.js +4 -2
  134. package/dist/utils/BrowserStringUtils.js.map +1 -1
  135. package/dist/utils/BrowserUtils.js +2 -2
  136. package/dist/utils/BrowserUtils.js.map +1 -1
  137. package/dist/utils/MathUtils.js +1 -1
  138. package/dist/utils/PopupUtils.d.ts +1 -2
  139. package/dist/utils/PopupUtils.d.ts.map +1 -1
  140. package/dist/utils/PopupUtils.js +3 -3
  141. package/dist/utils/PopupUtils.js.map +1 -1
  142. package/lib/msal-browser.js +1380 -436
  143. package/lib/msal-browser.js.map +1 -1
  144. package/lib/msal-browser.min.js +41 -31
  145. package/package.json +2 -2
  146. package/CHANGELOG.json +0 -1685
  147. package/CHANGELOG.md +0 -536
@@ -1,4 +1,4 @@
1
- /*! @azure/msal-browser v2.21.0 2022-01-04 */
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.0.0 2022-01-04 */
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.0.0 2022-01-04 */
197
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
198
198
 
199
199
  /*
200
200
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -208,6 +208,7 @@
208
208
  // default authority
209
209
  DEFAULT_AUTHORITY: "https://login.microsoftonline.com/common/",
210
210
  DEFAULT_AUTHORITY_HOST: "login.microsoftonline.com",
211
+ DEFAULT_COMMON_TENANT: "common",
211
212
  // ADFS String
212
213
  ADFS: "adfs",
213
214
  // Default AAD Instance Discovery Endpoint
@@ -318,6 +319,8 @@
318
319
  AADServerParamKeys["X_CLIENT_CURR_TELEM"] = "x-client-current-telemetry";
319
320
  AADServerParamKeys["X_CLIENT_LAST_TELEM"] = "x-client-last-telemetry";
320
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";
321
324
  AADServerParamKeys["POST_LOGOUT_URI"] = "post_logout_redirect_uri";
322
325
  AADServerParamKeys["ID_TOKEN_HINT"] = "id_token_hint";
323
326
  AADServerParamKeys["DEVICE_CODE"] = "device_code";
@@ -332,6 +335,7 @@
332
335
  AADServerParamKeys["FOCI"] = "foci";
333
336
  AADServerParamKeys["CCS_HEADER"] = "X-AnchorMailbox";
334
337
  AADServerParamKeys["RETURN_SPA_CODE"] = "return_spa_code";
338
+ AADServerParamKeys["LOGOUT_HINT"] = "logout_hint";
335
339
  })(AADServerParamKeys || (AADServerParamKeys = {}));
336
340
  /**
337
341
  * Claims request keys
@@ -556,7 +560,7 @@
556
560
  CacheOutcome["REFRESH_CACHED_ACCESS_TOKEN"] = "4";
557
561
  })(CacheOutcome || (CacheOutcome = {}));
558
562
 
559
- /*! @azure/msal-common v6.0.0 2022-01-04 */
563
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
560
564
 
561
565
  /*
562
566
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -582,8 +586,8 @@
582
586
  _this = _super.call(this, errorString) || this;
583
587
  Object.setPrototypeOf(_this, AuthError.prototype);
584
588
  _this.errorCode = errorCode || Constants.EMPTY_STRING;
585
- _this.errorMessage = errorMessage || "";
586
- _this.subError = suberror || "";
589
+ _this.errorMessage = errorMessage || Constants.EMPTY_STRING;
590
+ _this.subError = suberror || Constants.EMPTY_STRING;
587
591
  _this.name = "AuthError";
588
592
  return _this;
589
593
  }
@@ -600,7 +604,7 @@
600
604
  return AuthError;
601
605
  }(Error));
602
606
 
603
- /*! @azure/msal-common v6.0.0 2022-01-04 */
607
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
604
608
 
605
609
  /*
606
610
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -675,7 +679,7 @@
675
679
  }
676
680
  };
677
681
 
678
- /*! @azure/msal-common v6.0.0 2022-01-04 */
682
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
679
683
 
680
684
  /*
681
685
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1137,7 +1141,7 @@
1137
1141
  return ClientAuthError;
1138
1142
  }(AuthError));
1139
1143
 
1140
- /*! @azure/msal-common v6.0.0 2022-01-04 */
1144
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
1141
1145
 
1142
1146
  /*
1143
1147
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1262,7 +1266,7 @@
1262
1266
  return StringUtils;
1263
1267
  }());
1264
1268
 
1265
- /*! @azure/msal-common v6.0.0 2022-01-04 */
1269
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
1266
1270
 
1267
1271
  /*
1268
1272
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1292,7 +1296,7 @@
1292
1296
  this.localCallback = loggerOptions.loggerCallback || defaultLoggerCallback;
1293
1297
  this.piiLoggingEnabled = loggerOptions.piiLoggingEnabled || false;
1294
1298
  this.level = typeof (loggerOptions.logLevel) === "number" ? loggerOptions.logLevel : exports.LogLevel.Info;
1295
- this.correlationId = loggerOptions.correlationId || "";
1299
+ this.correlationId = loggerOptions.correlationId || Constants.EMPTY_STRING;
1296
1300
  this.packageName = packageName || Constants.EMPTY_STRING;
1297
1301
  this.packageVersion = packageVersion || Constants.EMPTY_STRING;
1298
1302
  }
@@ -1322,7 +1326,7 @@
1322
1326
  logHeader = "[" + timestamp + "]";
1323
1327
  }
1324
1328
  var log = logHeader + " : " + this.packageName + "@" + this.packageVersion + " : " + exports.LogLevel[options.logLevel] + " - " + logMessage;
1325
- // 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);
1326
1330
  this.executeCallback(options.logLevel, log, options.containsPii || false);
1327
1331
  };
1328
1332
  /**
@@ -1340,7 +1344,7 @@
1340
1344
  this.logMessage(message, {
1341
1345
  logLevel: exports.LogLevel.Error,
1342
1346
  containsPii: false,
1343
- correlationId: correlationId || ""
1347
+ correlationId: correlationId || Constants.EMPTY_STRING
1344
1348
  });
1345
1349
  };
1346
1350
  /**
@@ -1350,7 +1354,7 @@
1350
1354
  this.logMessage(message, {
1351
1355
  logLevel: exports.LogLevel.Error,
1352
1356
  containsPii: true,
1353
- correlationId: correlationId || ""
1357
+ correlationId: correlationId || Constants.EMPTY_STRING
1354
1358
  });
1355
1359
  };
1356
1360
  /**
@@ -1360,7 +1364,7 @@
1360
1364
  this.logMessage(message, {
1361
1365
  logLevel: exports.LogLevel.Warning,
1362
1366
  containsPii: false,
1363
- correlationId: correlationId || ""
1367
+ correlationId: correlationId || Constants.EMPTY_STRING
1364
1368
  });
1365
1369
  };
1366
1370
  /**
@@ -1370,7 +1374,7 @@
1370
1374
  this.logMessage(message, {
1371
1375
  logLevel: exports.LogLevel.Warning,
1372
1376
  containsPii: true,
1373
- correlationId: correlationId || ""
1377
+ correlationId: correlationId || Constants.EMPTY_STRING
1374
1378
  });
1375
1379
  };
1376
1380
  /**
@@ -1380,7 +1384,7 @@
1380
1384
  this.logMessage(message, {
1381
1385
  logLevel: exports.LogLevel.Info,
1382
1386
  containsPii: false,
1383
- correlationId: correlationId || ""
1387
+ correlationId: correlationId || Constants.EMPTY_STRING
1384
1388
  });
1385
1389
  };
1386
1390
  /**
@@ -1390,7 +1394,7 @@
1390
1394
  this.logMessage(message, {
1391
1395
  logLevel: exports.LogLevel.Info,
1392
1396
  containsPii: true,
1393
- correlationId: correlationId || ""
1397
+ correlationId: correlationId || Constants.EMPTY_STRING
1394
1398
  });
1395
1399
  };
1396
1400
  /**
@@ -1400,7 +1404,7 @@
1400
1404
  this.logMessage(message, {
1401
1405
  logLevel: exports.LogLevel.Verbose,
1402
1406
  containsPii: false,
1403
- correlationId: correlationId || ""
1407
+ correlationId: correlationId || Constants.EMPTY_STRING
1404
1408
  });
1405
1409
  };
1406
1410
  /**
@@ -1410,7 +1414,7 @@
1410
1414
  this.logMessage(message, {
1411
1415
  logLevel: exports.LogLevel.Verbose,
1412
1416
  containsPii: true,
1413
- correlationId: correlationId || ""
1417
+ correlationId: correlationId || Constants.EMPTY_STRING
1414
1418
  });
1415
1419
  };
1416
1420
  /**
@@ -1420,7 +1424,7 @@
1420
1424
  this.logMessage(message, {
1421
1425
  logLevel: exports.LogLevel.Trace,
1422
1426
  containsPii: false,
1423
- correlationId: correlationId || ""
1427
+ correlationId: correlationId || Constants.EMPTY_STRING
1424
1428
  });
1425
1429
  };
1426
1430
  /**
@@ -1430,7 +1434,7 @@
1430
1434
  this.logMessage(message, {
1431
1435
  logLevel: exports.LogLevel.Trace,
1432
1436
  containsPii: true,
1433
- correlationId: correlationId || ""
1437
+ correlationId: correlationId || Constants.EMPTY_STRING
1434
1438
  });
1435
1439
  };
1436
1440
  /**
@@ -1442,12 +1446,33 @@
1442
1446
  return Logger;
1443
1447
  }());
1444
1448
 
1445
- /*! @azure/msal-common v6.0.0 2022-01-04 */
1449
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
1446
1450
  /* eslint-disable header/header */
1447
1451
  var name$1 = "@azure/msal-common";
1448
- var version$1 = "6.0.0";
1452
+ var version$1 = "6.2.0";
1449
1453
 
1450
- /*! @azure/msal-common v6.0.0 2022-01-04 */
1454
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
1455
+ /*
1456
+ * Copyright (c) Microsoft Corporation. All rights reserved.
1457
+ * Licensed under the MIT License.
1458
+ */
1459
+ exports.AzureCloudInstance = void 0;
1460
+ (function (AzureCloudInstance) {
1461
+ // AzureCloudInstance is not specified.
1462
+ AzureCloudInstance[AzureCloudInstance["None"] = 0] = "None";
1463
+ // Microsoft Azure public cloud
1464
+ AzureCloudInstance["AzurePublic"] = "https://login.microsoftonline.com";
1465
+ // Microsoft PPE
1466
+ AzureCloudInstance["AzurePpe"] = "https://login.windows-ppe.net";
1467
+ // Microsoft Chinese national cloud
1468
+ AzureCloudInstance["AzureChina"] = "https://login.chinacloudapi.cn";
1469
+ // Microsoft German national cloud ("Black Forest")
1470
+ AzureCloudInstance["AzureGermany"] = "https://login.microsoftonline.de";
1471
+ // US Government cloud
1472
+ AzureCloudInstance["AzureUsGovernment"] = "https://login.microsoftonline.us";
1473
+ })(exports.AzureCloudInstance || (exports.AzureCloudInstance = {}));
1474
+
1475
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
1451
1476
 
1452
1477
  /*
1453
1478
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1577,7 +1602,7 @@
1577
1602
  var credentialId = [
1578
1603
  credentialType,
1579
1604
  clientOrFamilyId,
1580
- realm || "",
1605
+ realm || Constants.EMPTY_STRING,
1581
1606
  ];
1582
1607
  return credentialId.join(Separators.CACHE_KEY_SEPARATOR).toLowerCase();
1583
1608
  };
@@ -1585,13 +1610,13 @@
1585
1610
  * Generate target key component as per schema: <target>
1586
1611
  */
1587
1612
  CredentialEntity.generateTargetForCacheKey = function (scopes) {
1588
- return (scopes || "").toLowerCase();
1613
+ return (scopes || Constants.EMPTY_STRING).toLowerCase();
1589
1614
  };
1590
1615
  /**
1591
1616
  * Generate requested claims key component as per schema: <requestedClaims>
1592
1617
  */
1593
1618
  CredentialEntity.generateClaimsHashForCacheKey = function (requestedClaimsHash) {
1594
- return (requestedClaimsHash || "").toLowerCase();
1619
+ return (requestedClaimsHash || Constants.EMPTY_STRING).toLowerCase();
1595
1620
  };
1596
1621
  /**
1597
1622
  * Generate scheme key componenet as per schema: <scheme>
@@ -1601,12 +1626,12 @@
1601
1626
  * PoP Tokens and SSH certs include scheme in cache key
1602
1627
  * Cast to lowercase to handle "bearer" from ADFS
1603
1628
  */
1604
- return (tokenType && tokenType.toLowerCase() !== exports.AuthenticationScheme.BEARER.toLowerCase()) ? tokenType.toLowerCase() : "";
1629
+ return (tokenType && tokenType.toLowerCase() !== exports.AuthenticationScheme.BEARER.toLowerCase()) ? tokenType.toLowerCase() : Constants.EMPTY_STRING;
1605
1630
  };
1606
1631
  return CredentialEntity;
1607
1632
  }());
1608
1633
 
1609
- /*! @azure/msal-common v6.0.0 2022-01-04 */
1634
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
1610
1635
 
1611
1636
  /*
1612
1637
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1688,6 +1713,10 @@
1688
1713
  code: "untrusted_authority",
1689
1714
  desc: "The provided authority is not a trusted authority. Please include this authority in the knownAuthorities config parameter."
1690
1715
  },
1716
+ invalidAzureCloudInstance: {
1717
+ code: "invalid_azure_cloud_instance",
1718
+ desc: "Invalid AzureCloudInstance provided. Please refer MSAL JS docs: aks.ms/msaljs/azure_cloud_instance for valid values"
1719
+ },
1691
1720
  missingSshJwk: {
1692
1721
  code: "missing_ssh_jwk",
1693
1722
  desc: "Missing sshJwk in SSH certificate request. A stringified JSON Web Key is required when using the SSH authentication scheme."
@@ -1824,7 +1853,13 @@
1824
1853
  ClientConfigurationError.createUntrustedAuthorityError = function () {
1825
1854
  return new ClientConfigurationError(ClientConfigurationErrorMessage.untrustedAuthority.code, ClientConfigurationErrorMessage.untrustedAuthority.desc);
1826
1855
  };
1827
- /*
1856
+ /**
1857
+ * Throws error when the AzureCloudInstance is set to an invalid value
1858
+ */
1859
+ ClientConfigurationError.createInvalidAzureCloudInstanceError = function () {
1860
+ return new ClientConfigurationError(ClientConfigurationErrorMessage.invalidAzureCloudInstance.code, ClientConfigurationErrorMessage.invalidAzureCloudInstance.desc);
1861
+ };
1862
+ /**
1828
1863
  * Throws an error when the authentication scheme is set to SSH but the SSH public key is omitted from the request
1829
1864
  */
1830
1865
  ClientConfigurationError.createMissingSshJwkError = function () {
@@ -1851,7 +1886,7 @@
1851
1886
  return ClientConfigurationError;
1852
1887
  }(ClientAuthError));
1853
1888
 
1854
- /*! @azure/msal-common v6.0.0 2022-01-04 */
1889
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
1855
1890
 
1856
1891
  /*
1857
1892
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1880,7 +1915,7 @@
1880
1915
  * @param scopesRequired
1881
1916
  */
1882
1917
  ScopeSet.fromString = function (inputScopeString) {
1883
- var scopeString = inputScopeString || "";
1918
+ var scopeString = inputScopeString || Constants.EMPTY_STRING;
1884
1919
  var inputScopes = scopeString.split(" ");
1885
1920
  return new ScopeSet(inputScopes);
1886
1921
  };
@@ -2024,7 +2059,7 @@
2024
2059
  var scopeArr = this.asArray();
2025
2060
  return scopeArr.join(" ");
2026
2061
  }
2027
- return "";
2062
+ return Constants.EMPTY_STRING;
2028
2063
  };
2029
2064
  /**
2030
2065
  * Prints scopes into a space-delimited lower-case string (used for caching)
@@ -2035,7 +2070,7 @@
2035
2070
  return ScopeSet;
2036
2071
  }());
2037
2072
 
2038
- /*! @azure/msal-common v6.0.0 2022-01-04 */
2073
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
2039
2074
 
2040
2075
  /*
2041
2076
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2073,7 +2108,7 @@
2073
2108
  };
2074
2109
  }
2075
2110
 
2076
- /*! @azure/msal-common v6.0.0 2022-01-04 */
2111
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
2077
2112
  /*
2078
2113
  * Copyright (c) Microsoft Corporation. All rights reserved.
2079
2114
  * Licensed under the MIT License.
@@ -2087,7 +2122,7 @@
2087
2122
  AuthorityType[AuthorityType["Adfs"] = 1] = "Adfs";
2088
2123
  })(AuthorityType || (AuthorityType = {}));
2089
2124
 
2090
- /*! @azure/msal-common v6.0.0 2022-01-04 */
2125
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
2091
2126
 
2092
2127
  /*
2093
2128
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2177,8 +2212,8 @@
2177
2212
  AccountEntity.generateAccountCacheKey = function (accountInterface) {
2178
2213
  var accountKey = [
2179
2214
  accountInterface.homeAccountId,
2180
- accountInterface.environment || "",
2181
- accountInterface.tenantId || "",
2215
+ accountInterface.environment || Constants.EMPTY_STRING,
2216
+ accountInterface.tenantId || Constants.EMPTY_STRING,
2182
2217
  ];
2183
2218
  return accountKey.join(Separators.CACHE_KEY_SEPARATOR).toLowerCase();
2184
2219
  };
@@ -2201,17 +2236,17 @@
2201
2236
  }
2202
2237
  account.environment = env;
2203
2238
  // non AAD scenarios can have empty realm
2204
- 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;
2205
2240
  account.oboAssertion = oboAssertion;
2206
2241
  if (idToken) {
2207
2242
  account.idTokenClaims = idToken.claims;
2208
2243
  // How do you account for MSA CID here?
2209
- 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;
2210
2245
  /*
2211
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.
2212
2247
  * This field should not be relied upon if a custom policy is configured to return more than 1 email.
2213
2248
  */
2214
- 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);
2215
2250
  account.name = (_f = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _f === void 0 ? void 0 : _f.name;
2216
2251
  }
2217
2252
  account.cloudGraphHostName = cloudGraphHostName;
@@ -2229,7 +2264,7 @@
2229
2264
  account.authorityType = (authority && authority.authorityType === AuthorityType.Adfs) ? CacheAccountType.ADFS_ACCOUNT_TYPE : CacheAccountType.GENERIC_ACCOUNT_TYPE;
2230
2265
  account.homeAccountId = homeAccountId;
2231
2266
  // non AAD scenarios can have empty realm
2232
- account.realm = "";
2267
+ account.realm = Constants.EMPTY_STRING;
2233
2268
  account.oboAssertion = oboAssertion;
2234
2269
  var env = environment || authority && authority.getPreferredCache();
2235
2270
  if (!env) {
@@ -2237,10 +2272,10 @@
2237
2272
  }
2238
2273
  if (idToken) {
2239
2274
  // How do you account for MSA CID here?
2240
- 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;
2241
2276
  // upn claim for most ADFS scenarios
2242
- account.username = ((_c = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _c === void 0 ? void 0 : _c.upn) || "";
2243
- 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;
2244
2279
  account.idTokenClaims = idToken === null || idToken === void 0 ? void 0 : idToken.claims;
2245
2280
  }
2246
2281
  account.environment = env;
@@ -2321,7 +2356,7 @@
2321
2356
  return AccountEntity;
2322
2357
  }());
2323
2358
 
2324
- /*! @azure/msal-common v6.0.0 2022-01-04 */
2359
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
2325
2360
 
2326
2361
  /*
2327
2362
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2359,7 +2394,7 @@
2359
2394
  return AuthToken;
2360
2395
  }());
2361
2396
 
2362
- /*! @azure/msal-common v6.0.0 2022-01-04 */
2397
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
2363
2398
 
2364
2399
  /*
2365
2400
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2481,7 +2516,7 @@
2481
2516
  * @param realm
2482
2517
  */
2483
2518
  CacheManager.prototype.getAccountsFilteredBy = function (accountFilter) {
2484
- 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);
2485
2520
  };
2486
2521
  /**
2487
2522
  * retrieve accounts matching all provided filters; if no filter is set, get all accounts
@@ -3201,7 +3236,7 @@
3201
3236
  return DefaultStorageClass;
3202
3237
  }(CacheManager));
3203
3238
 
3204
- /*! @azure/msal-common v6.0.0 2022-01-04 */
3239
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
3205
3240
 
3206
3241
  /*
3207
3242
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3211,7 +3246,8 @@
3211
3246
  var DEFAULT_TOKEN_RENEWAL_OFFSET_SEC = 300;
3212
3247
  var DEFAULT_SYSTEM_OPTIONS = {
3213
3248
  tokenRenewalOffsetSeconds: DEFAULT_TOKEN_RENEWAL_OFFSET_SEC,
3214
- preventCorsPreflight: false
3249
+ preventCorsPreflight: false,
3250
+ proxyUrl: Constants.EMPTY_STRING
3215
3251
  };
3216
3252
  var DEFAULT_LOGGER_IMPLEMENTATION = {
3217
3253
  loggerCallback: function () {
@@ -3219,7 +3255,7 @@
3219
3255
  },
3220
3256
  piiLoggingEnabled: false,
3221
3257
  logLevel: exports.LogLevel.Info,
3222
- correlationId: ""
3258
+ correlationId: Constants.EMPTY_STRING
3223
3259
  };
3224
3260
  var DEFAULT_NETWORK_IMPLEMENTATION = {
3225
3261
  sendGetRequestAsync: function () {
@@ -3244,13 +3280,23 @@
3244
3280
  var DEFAULT_LIBRARY_INFO = {
3245
3281
  sku: Constants.SKU,
3246
3282
  version: version$1,
3247
- cpu: "",
3248
- os: ""
3283
+ cpu: Constants.EMPTY_STRING,
3284
+ os: Constants.EMPTY_STRING
3249
3285
  };
3250
3286
  var DEFAULT_CLIENT_CREDENTIALS = {
3251
- clientSecret: "",
3287
+ clientSecret: Constants.EMPTY_STRING,
3252
3288
  clientAssertion: undefined
3253
3289
  };
3290
+ var DEFAULT_AZURE_CLOUD_OPTIONS = {
3291
+ azureCloudInstance: exports.AzureCloudInstance.None,
3292
+ tenant: "" + Constants.DEFAULT_COMMON_TENANT
3293
+ };
3294
+ var DEFAULT_TELEMETRY_OPTIONS = {
3295
+ application: {
3296
+ appName: "",
3297
+ appVersion: ""
3298
+ }
3299
+ };
3254
3300
  /**
3255
3301
  * Function that sets the default options when not explicitly configured from app developer
3256
3302
  *
@@ -3259,7 +3305,7 @@
3259
3305
  * @returns Configuration
3260
3306
  */
3261
3307
  function buildClientConfiguration(_a) {
3262
- 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;
3263
3309
  var loggerOptions = __assign(__assign({}, DEFAULT_LOGGER_IMPLEMENTATION), userLoggerOption);
3264
3310
  return {
3265
3311
  authOptions: buildAuthOptions(userAuthOptions),
@@ -3270,6 +3316,7 @@
3270
3316
  cryptoInterface: cryptoImplementation || DEFAULT_CRYPTO_IMPLEMENTATION,
3271
3317
  clientCredentials: clientCredentials || DEFAULT_CLIENT_CREDENTIALS,
3272
3318
  libraryInfo: __assign(__assign({}, DEFAULT_LIBRARY_INFO), libraryInfo),
3319
+ telemetry: __assign(__assign({}, DEFAULT_TELEMETRY_OPTIONS), telemetry),
3273
3320
  serverTelemetryManager: serverTelemetryManager || null,
3274
3321
  persistencePlugin: persistencePlugin || null,
3275
3322
  serializableCache: serializableCache || null
@@ -3280,10 +3327,10 @@
3280
3327
  * @param authOptions
3281
3328
  */
3282
3329
  function buildAuthOptions(authOptions) {
3283
- return __assign({ clientCapabilities: [] }, authOptions);
3330
+ return __assign({ clientCapabilities: [], azureCloudOptions: DEFAULT_AZURE_CLOUD_OPTIONS }, authOptions);
3284
3331
  }
3285
3332
 
3286
- /*! @azure/msal-common v6.0.0 2022-01-04 */
3333
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
3287
3334
 
3288
3335
  /*
3289
3336
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3303,7 +3350,7 @@
3303
3350
  return ServerError;
3304
3351
  }(AuthError));
3305
3352
 
3306
- /*! @azure/msal-common v6.0.0 2022-01-04 */
3353
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
3307
3354
 
3308
3355
  /*
3309
3356
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3399,7 +3446,7 @@
3399
3446
  return ThrottlingUtils;
3400
3447
  }());
3401
3448
 
3402
- /*! @azure/msal-common v6.0.0 2022-01-04 */
3449
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
3403
3450
 
3404
3451
  /*
3405
3452
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3448,7 +3495,7 @@
3448
3495
  return NetworkManager;
3449
3496
  }());
3450
3497
 
3451
- /*! @azure/msal-common v6.0.0 2022-01-04 */
3498
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
3452
3499
  /*
3453
3500
  * Copyright (c) Microsoft Corporation. All rights reserved.
3454
3501
  * Licensed under the MIT License.
@@ -3459,7 +3506,7 @@
3459
3506
  CcsCredentialType["UPN"] = "UPN";
3460
3507
  })(CcsCredentialType || (CcsCredentialType = {}));
3461
3508
 
3462
- /*! @azure/msal-common v6.0.0 2022-01-04 */
3509
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
3463
3510
 
3464
3511
  /*
3465
3512
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3523,7 +3570,7 @@
3523
3570
  var response;
3524
3571
  return __generator(this, function (_a) {
3525
3572
  switch (_a.label) {
3526
- case 0: return [4 /*yield*/, this.networkManager.sendPostRequest(thumbprint, tokenEndpoint, { body: queryString, headers: headers })];
3573
+ case 0: return [4 /*yield*/, this.networkManager.sendPostRequest(thumbprint, tokenEndpoint, { body: queryString, headers: headers, proxyUrl: this.config.systemOptions.proxyUrl })];
3527
3574
  case 1:
3528
3575
  response = _a.sent();
3529
3576
  if (this.config.serverTelemetryManager && response.status < 500 && response.status !== 429) {
@@ -3548,7 +3595,7 @@
3548
3595
  return BaseClient;
3549
3596
  }());
3550
3597
 
3551
- /*! @azure/msal-common v6.0.0 2022-01-04 */
3598
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
3552
3599
 
3553
3600
  /*
3554
3601
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3634,7 +3681,7 @@
3634
3681
  return RequestValidator;
3635
3682
  }());
3636
3683
 
3637
- /*! @azure/msal-common v6.0.0 2022-01-04 */
3684
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
3638
3685
 
3639
3686
  /*
3640
3687
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3757,8 +3804,24 @@
3757
3804
  // Telemetry Info
3758
3805
  this.parameters.set(AADServerParamKeys.X_CLIENT_SKU, libraryInfo.sku);
3759
3806
  this.parameters.set(AADServerParamKeys.X_CLIENT_VER, libraryInfo.version);
3760
- this.parameters.set(AADServerParamKeys.X_CLIENT_OS, libraryInfo.os);
3761
- 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
+ }
3762
3825
  };
3763
3826
  /**
3764
3827
  * add prompt
@@ -3961,6 +4024,12 @@
3961
4024
  RequestParameterBuilder.prototype.addThrottling = function () {
3962
4025
  this.parameters.set(AADServerParamKeys.X_MS_LIB_CAPABILITY, ThrottlingConstants.X_MS_LIB_CAPABILITY_VALUE);
3963
4026
  };
4027
+ /**
4028
+ * Adds logout_hint parameter for "silent" logout which prevent server account picker
4029
+ */
4030
+ RequestParameterBuilder.prototype.addLogoutHint = function (logoutHint) {
4031
+ this.parameters.set(AADServerParamKeys.LOGOUT_HINT, encodeURIComponent(logoutHint));
4032
+ };
3964
4033
  /**
3965
4034
  * Utility to create a URL from the params map
3966
4035
  */
@@ -3974,7 +4043,7 @@
3974
4043
  return RequestParameterBuilder;
3975
4044
  }());
3976
4045
 
3977
- /*! @azure/msal-common v6.0.0 2022-01-04 */
4046
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
3978
4047
 
3979
4048
  /*
3980
4049
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4039,7 +4108,7 @@
4039
4108
  return IdTokenEntity;
4040
4109
  }(CredentialEntity));
4041
4110
 
4042
- /*! @azure/msal-common v6.0.0 2022-01-04 */
4111
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
4043
4112
  /*
4044
4113
  * Copyright (c) Microsoft Corporation. All rights reserved.
4045
4114
  * Licensed under the MIT License.
@@ -4089,7 +4158,7 @@
4089
4158
  return TimeUtils;
4090
4159
  }());
4091
4160
 
4092
- /*! @azure/msal-common v6.0.0 2022-01-04 */
4161
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
4093
4162
 
4094
4163
  /*
4095
4164
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4203,7 +4272,7 @@
4203
4272
  return AccessTokenEntity;
4204
4273
  }(CredentialEntity));
4205
4274
 
4206
- /*! @azure/msal-common v6.0.0 2022-01-04 */
4275
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
4207
4276
 
4208
4277
  /*
4209
4278
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4270,7 +4339,7 @@
4270
4339
  return RefreshTokenEntity;
4271
4340
  }(CredentialEntity));
4272
4341
 
4273
- /*! @azure/msal-common v6.0.0 2022-01-04 */
4342
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
4274
4343
 
4275
4344
  /*
4276
4345
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4334,7 +4403,7 @@
4334
4403
  return InteractionRequiredAuthError;
4335
4404
  }(AuthError));
4336
4405
 
4337
- /*! @azure/msal-common v6.0.0 2022-01-04 */
4406
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
4338
4407
  /*
4339
4408
  * Copyright (c) Microsoft Corporation. All rights reserved.
4340
4409
  * Licensed under the MIT License.
@@ -4350,7 +4419,7 @@
4350
4419
  return CacheRecord;
4351
4420
  }());
4352
4421
 
4353
- /*! @azure/msal-common v6.0.0 2022-01-04 */
4422
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
4354
4423
 
4355
4424
  /*
4356
4425
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4406,11 +4475,11 @@
4406
4475
  // Split the state between library state and user passed state and decode them separately
4407
4476
  var splitState = state.split(Constants.RESOURCE_DELIM);
4408
4477
  var libraryState = splitState[0];
4409
- 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;
4410
4479
  var libraryStateString = cryptoObj.base64Decode(libraryState);
4411
4480
  var libraryStateObj = JSON.parse(libraryStateString);
4412
4481
  return {
4413
- userRequestState: !StringUtils.isEmpty(userState) ? userState : "",
4482
+ userRequestState: !StringUtils.isEmpty(userState) ? userState : Constants.EMPTY_STRING,
4414
4483
  libraryState: libraryStateObj
4415
4484
  };
4416
4485
  }
@@ -4421,7 +4490,7 @@
4421
4490
  return ProtocolUtils;
4422
4491
  }());
4423
4492
 
4424
- /*! @azure/msal-common v6.0.0 2022-01-04 */
4493
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
4425
4494
 
4426
4495
  /*
4427
4496
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4582,7 +4651,7 @@
4582
4651
  else if (hashIndex1 > -1) {
4583
4652
  return hashString.substring(hashIndex1 + 1);
4584
4653
  }
4585
- return "";
4654
+ return Constants.EMPTY_STRING;
4586
4655
  };
4587
4656
  UrlString.constructAuthorityUriFromObject = function (urlObject) {
4588
4657
  return new UrlString(urlObject.Protocol + "//" + urlObject.HostNameAndPort + "/" + urlObject.PathSegments.join("/"));
@@ -4622,7 +4691,7 @@
4622
4691
  return UrlString;
4623
4692
  }());
4624
4693
 
4625
- /*! @azure/msal-common v6.0.0 2022-01-04 */
4694
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
4626
4695
 
4627
4696
  /*
4628
4697
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4688,7 +4757,7 @@
4688
4757
  resourceRequestMethod = request.resourceRequestMethod, resourceRequestUri = request.resourceRequestUri, shrClaims = request.shrClaims, shrNonce = request.shrNonce;
4689
4758
  resourceUrlString = (resourceRequestUri) ? new UrlString(resourceRequestUri) : undefined;
4690
4759
  resourceUrlComponents = resourceUrlString === null || resourceUrlString === void 0 ? void 0 : resourceUrlString.getUrlComponents();
4691
- 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)];
4692
4761
  case 1: return [2 /*return*/, _a.sent()];
4693
4762
  }
4694
4763
  });
@@ -4697,7 +4766,7 @@
4697
4766
  return PopTokenGenerator;
4698
4767
  }());
4699
4768
 
4700
- /*! @azure/msal-common v6.0.0 2022-01-04 */
4769
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
4701
4770
 
4702
4771
  /*
4703
4772
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4767,7 +4836,7 @@
4767
4836
  return AppMetadataEntity;
4768
4837
  }());
4769
4838
 
4770
- /*! @azure/msal-common v6.0.0 2022-01-04 */
4839
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
4771
4840
  /*
4772
4841
  * Copyright (c) Microsoft Corporation. All rights reserved.
4773
4842
  * Licensed under the MIT License.
@@ -4803,7 +4872,7 @@
4803
4872
  return TokenCacheContext;
4804
4873
  }());
4805
4874
 
4806
- /*! @azure/msal-common v6.0.0 2022-01-04 */
4875
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
4807
4876
 
4808
4877
  /*
4809
4878
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4984,8 +5053,8 @@
4984
5053
  */
4985
5054
  ResponseHandler.prototype.generateAccountEntity = function (serverTokenResponse, idToken, authority, oboAssertion, authCodePayload) {
4986
5055
  var authorityType = authority.authorityType;
4987
- var cloudGraphHostName = authCodePayload ? authCodePayload.cloud_graph_host_name : "";
4988
- 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;
4989
5058
  // ADFS does not require client_info in the response
4990
5059
  if (authorityType === AuthorityType.Adfs) {
4991
5060
  this.logger.verbose("Authority type is ADFS, creating ADFS account");
@@ -5016,7 +5085,7 @@
5016
5085
  return __generator(this, function (_d) {
5017
5086
  switch (_d.label) {
5018
5087
  case 0:
5019
- accessToken = "";
5088
+ accessToken = Constants.EMPTY_STRING;
5020
5089
  responseScopes = [];
5021
5090
  expiresOn = null;
5022
5091
  familyId = Constants.EMPTY_STRING;
@@ -5068,7 +5137,7 @@
5068
5137
  return ResponseHandler;
5069
5138
  }());
5070
5139
 
5071
- /*! @azure/msal-common v6.0.0 2022-01-04 */
5140
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
5072
5141
 
5073
5142
  /*
5074
5143
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5256,6 +5325,7 @@
5256
5325
  parameterBuilder.addAuthorizationCode(request.code);
5257
5326
  // Add library metadata
5258
5327
  parameterBuilder.addLibraryInfo(this.config.libraryInfo);
5328
+ parameterBuilder.addApplicationTelemetry(this.config.telemetry.application);
5259
5329
  parameterBuilder.addThrottling();
5260
5330
  if (this.serverTelemetryManager) {
5261
5331
  parameterBuilder.addServerTelemetry(this.serverTelemetryManager);
@@ -5364,6 +5434,7 @@
5364
5434
  parameterBuilder.addResponseTypeCode();
5365
5435
  // add library info parameters
5366
5436
  parameterBuilder.addLibraryInfo(this.config.libraryInfo);
5437
+ parameterBuilder.addApplicationTelemetry(this.config.telemetry.application);
5367
5438
  // add client_info=1
5368
5439
  parameterBuilder.addClientInfo();
5369
5440
  if (request.codeChallenge && request.codeChallengeMethod) {
@@ -5457,6 +5528,9 @@
5457
5528
  if (request.state) {
5458
5529
  parameterBuilder.addState(request.state);
5459
5530
  }
5531
+ if (request.logoutHint) {
5532
+ parameterBuilder.addLogoutHint(request.logoutHint);
5533
+ }
5460
5534
  if (request.extraQueryParameters) {
5461
5535
  parameterBuilder.addExtraQueryParameters(request.extraQueryParameters);
5462
5536
  }
@@ -5476,7 +5550,7 @@
5476
5550
  return AuthorizationCodeClient;
5477
5551
  }(BaseClient));
5478
5552
 
5479
- /*! @azure/msal-common v6.0.0 2022-01-04 */
5553
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
5480
5554
 
5481
5555
  /*
5482
5556
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5627,6 +5701,7 @@
5627
5701
  parameterBuilder.addGrantType(GrantType.REFRESH_TOKEN_GRANT);
5628
5702
  parameterBuilder.addClientInfo();
5629
5703
  parameterBuilder.addLibraryInfo(this.config.libraryInfo);
5704
+ parameterBuilder.addApplicationTelemetry(this.config.telemetry.application);
5630
5705
  parameterBuilder.addThrottling();
5631
5706
  if (this.serverTelemetryManager) {
5632
5707
  parameterBuilder.addServerTelemetry(this.serverTelemetryManager);
@@ -5687,7 +5762,7 @@
5687
5762
  return RefreshTokenClient;
5688
5763
  }(BaseClient));
5689
5764
 
5690
- /*! @azure/msal-common v6.0.0 2022-01-04 */
5765
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
5691
5766
 
5692
5767
  /*
5693
5768
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5803,7 +5878,7 @@
5803
5878
  return SilentFlowClient;
5804
5879
  }(BaseClient));
5805
5880
 
5806
- /*! @azure/msal-common v6.0.0 2022-01-04 */
5881
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
5807
5882
  /*
5808
5883
  * Copyright (c) Microsoft Corporation. All rights reserved.
5809
5884
  * Licensed under the MIT License.
@@ -5814,7 +5889,7 @@
5814
5889
  response.hasOwnProperty("issuer"));
5815
5890
  }
5816
5891
 
5817
- /*! @azure/msal-common v6.0.0 2022-01-04 */
5892
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
5818
5893
  /*
5819
5894
  * Copyright (c) Microsoft Corporation. All rights reserved.
5820
5895
  * Licensed under the MIT License.
@@ -5828,7 +5903,7 @@
5828
5903
  ProtocolMode["OIDC"] = "OIDC";
5829
5904
  })(exports.ProtocolMode || (exports.ProtocolMode = {}));
5830
5905
 
5831
- /*! @azure/msal-common v6.0.0 2022-01-04 */
5906
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
5832
5907
 
5833
5908
  /*
5834
5909
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5903,7 +5978,7 @@
5903
5978
  return AuthorityMetadataEntity;
5904
5979
  }());
5905
5980
 
5906
- /*! @azure/msal-common v6.0.0 2022-01-04 */
5981
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
5907
5982
  /*
5908
5983
  * Copyright (c) Microsoft Corporation. All rights reserved.
5909
5984
  * Licensed under the MIT License.
@@ -5913,7 +5988,7 @@
5913
5988
  response.hasOwnProperty("metadata"));
5914
5989
  }
5915
5990
 
5916
- /*! @azure/msal-common v6.0.0 2022-01-04 */
5991
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
5917
5992
 
5918
5993
  /*
5919
5994
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5928,18 +6003,22 @@
5928
6003
  *
5929
6004
  * @returns Promise<string | null>
5930
6005
  */
5931
- RegionDiscovery.prototype.detectRegion = function (environmentRegion, regionDiscoveryMetadata) {
6006
+ RegionDiscovery.prototype.detectRegion = function (environmentRegion, regionDiscoveryMetadata, proxyUrl) {
5932
6007
  return __awaiter(this, void 0, void 0, function () {
5933
- var autodetectedRegionName, localIMDSVersionResponse, currentIMDSVersion, currentIMDSVersionResponse;
6008
+ var autodetectedRegionName, options, localIMDSVersionResponse, currentIMDSVersion, currentIMDSVersionResponse;
5934
6009
  return __generator(this, function (_a) {
5935
6010
  switch (_a.label) {
5936
6011
  case 0:
5937
6012
  autodetectedRegionName = environmentRegion;
5938
6013
  if (!!autodetectedRegionName) return [3 /*break*/, 8];
6014
+ options = RegionDiscovery.IMDS_OPTIONS;
6015
+ if (proxyUrl) {
6016
+ options.proxyUrl = proxyUrl;
6017
+ }
5939
6018
  _a.label = 1;
5940
6019
  case 1:
5941
6020
  _a.trys.push([1, 6, , 7]);
5942
- return [4 /*yield*/, this.getRegionFromIMDS(Constants.IMDS_VERSION)];
6021
+ return [4 /*yield*/, this.getRegionFromIMDS(Constants.IMDS_VERSION, options)];
5943
6022
  case 2:
5944
6023
  localIMDSVersionResponse = _a.sent();
5945
6024
  if (localIMDSVersionResponse.status === ResponseCodes.httpSuccess) {
@@ -5947,14 +6026,14 @@
5947
6026
  regionDiscoveryMetadata.region_source = RegionDiscoverySources.IMDS;
5948
6027
  }
5949
6028
  if (!(localIMDSVersionResponse.status === ResponseCodes.httpBadRequest)) return [3 /*break*/, 5];
5950
- return [4 /*yield*/, this.getCurrentVersion()];
6029
+ return [4 /*yield*/, this.getCurrentVersion(options)];
5951
6030
  case 3:
5952
6031
  currentIMDSVersion = _a.sent();
5953
6032
  if (!currentIMDSVersion) {
5954
6033
  regionDiscoveryMetadata.region_source = RegionDiscoverySources.FAILED_AUTO_DETECTION;
5955
6034
  return [2 /*return*/, null];
5956
6035
  }
5957
- return [4 /*yield*/, this.getRegionFromIMDS(currentIMDSVersion)];
6036
+ return [4 /*yield*/, this.getRegionFromIMDS(currentIMDSVersion, options)];
5958
6037
  case 4:
5959
6038
  currentIMDSVersionResponse = _a.sent();
5960
6039
  if (currentIMDSVersionResponse.status === ResponseCodes.httpSuccess) {
@@ -5987,10 +6066,10 @@
5987
6066
  * @param imdsEndpointUrl
5988
6067
  * @returns Promise<NetworkResponse<string>>
5989
6068
  */
5990
- RegionDiscovery.prototype.getRegionFromIMDS = function (version) {
6069
+ RegionDiscovery.prototype.getRegionFromIMDS = function (version, options) {
5991
6070
  return __awaiter(this, void 0, void 0, function () {
5992
6071
  return __generator(this, function (_a) {
5993
- return [2 /*return*/, this.networkInterface.sendGetRequestAsync(Constants.IMDS_ENDPOINT + "?api-version=" + version + "&format=text", RegionDiscovery.IMDS_OPTIONS, Constants.IMDS_TIMEOUT)];
6072
+ return [2 /*return*/, this.networkInterface.sendGetRequestAsync(Constants.IMDS_ENDPOINT + "?api-version=" + version + "&format=text", options, Constants.IMDS_TIMEOUT)];
5994
6073
  });
5995
6074
  });
5996
6075
  };
@@ -5999,14 +6078,14 @@
5999
6078
  *
6000
6079
  * @returns Promise<string | null>
6001
6080
  */
6002
- RegionDiscovery.prototype.getCurrentVersion = function () {
6081
+ RegionDiscovery.prototype.getCurrentVersion = function (options) {
6003
6082
  return __awaiter(this, void 0, void 0, function () {
6004
6083
  var response;
6005
6084
  return __generator(this, function (_a) {
6006
6085
  switch (_a.label) {
6007
6086
  case 0:
6008
6087
  _a.trys.push([0, 2, , 3]);
6009
- return [4 /*yield*/, this.networkInterface.sendGetRequestAsync(Constants.IMDS_ENDPOINT + "?format=json", RegionDiscovery.IMDS_OPTIONS)];
6088
+ return [4 /*yield*/, this.networkInterface.sendGetRequestAsync(Constants.IMDS_ENDPOINT + "?format=json", options)];
6010
6089
  case 1:
6011
6090
  response = _a.sent();
6012
6091
  // When IMDS endpoint is called without the api version query param, bad request response comes back with latest version.
@@ -6023,11 +6102,15 @@
6023
6102
  });
6024
6103
  };
6025
6104
  // Options for the IMDS endpoint request
6026
- RegionDiscovery.IMDS_OPTIONS = { headers: { "Metadata": "true" } };
6105
+ RegionDiscovery.IMDS_OPTIONS = {
6106
+ headers: {
6107
+ Metadata: "true",
6108
+ },
6109
+ };
6027
6110
  return RegionDiscovery;
6028
6111
  }());
6029
6112
 
6030
- /*! @azure/msal-common v6.0.0 2022-01-04 */
6113
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
6031
6114
 
6032
6115
  /*
6033
6116
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6038,7 +6121,7 @@
6038
6121
  * endpoint. It will store the pertinent config data in this object for use during token calls.
6039
6122
  */
6040
6123
  var Authority = /** @class */ (function () {
6041
- function Authority(authority, networkInterface, cacheManager, authorityOptions) {
6124
+ function Authority(authority, networkInterface, cacheManager, authorityOptions, proxyUrl) {
6042
6125
  this.canonicalAuthority = authority;
6043
6126
  this._canonicalAuthority.validateAsUri();
6044
6127
  this.networkInterface = networkInterface;
@@ -6046,6 +6129,7 @@
6046
6129
  this.authorityOptions = authorityOptions;
6047
6130
  this.regionDiscovery = new RegionDiscovery(networkInterface);
6048
6131
  this.regionDiscoveryMetadata = { region_used: undefined, region_source: undefined, region_outcome: undefined };
6132
+ this.proxyUrl = proxyUrl || Constants.EMPTY_STRING;
6049
6133
  }
6050
6134
  Object.defineProperty(Authority.prototype, "authorityType", {
6051
6135
  // See above for AuthorityType
@@ -6314,7 +6398,7 @@
6314
6398
  metadata = _b.sent();
6315
6399
  if (!metadata) return [3 /*break*/, 4];
6316
6400
  if (!((_a = this.authorityOptions.azureRegionConfiguration) === null || _a === void 0 ? void 0 : _a.azureRegion)) return [3 /*break*/, 3];
6317
- return [4 /*yield*/, this.regionDiscovery.detectRegion(this.authorityOptions.azureRegionConfiguration.environmentRegion, this.regionDiscoveryMetadata)];
6401
+ return [4 /*yield*/, this.regionDiscovery.detectRegion(this.authorityOptions.azureRegionConfiguration.environmentRegion, this.regionDiscoveryMetadata, this.proxyUrl)];
6318
6402
  case 2:
6319
6403
  autodetectedRegionName = _b.sent();
6320
6404
  azureRegion = this.authorityOptions.azureRegionConfiguration.azureRegion === Constants.AZURE_REGION_AUTO_DISCOVER_FLAG
@@ -6377,19 +6461,25 @@
6377
6461
  */
6378
6462
  Authority.prototype.getEndpointMetadataFromNetwork = function () {
6379
6463
  return __awaiter(this, void 0, void 0, function () {
6380
- var response;
6464
+ var options, response;
6381
6465
  return __generator(this, function (_a) {
6382
6466
  switch (_a.label) {
6383
6467
  case 0:
6384
- _a.trys.push([0, 2, , 3]);
6385
- return [4 /*yield*/, this.networkInterface.sendGetRequestAsync(this.defaultOpenIdConfigurationEndpoint)];
6468
+ options = {};
6469
+ if (this.proxyUrl) {
6470
+ options.proxyUrl = this.proxyUrl;
6471
+ }
6472
+ _a.label = 1;
6386
6473
  case 1:
6474
+ _a.trys.push([1, 3, , 4]);
6475
+ return [4 /*yield*/, this.networkInterface.sendGetRequestAsync(this.defaultOpenIdConfigurationEndpoint, options)];
6476
+ case 2:
6387
6477
  response = _a.sent();
6388
6478
  return [2 /*return*/, isOpenIdConfigResponse(response.body) ? response.body : null];
6389
- case 2:
6479
+ case 3:
6390
6480
  _a.sent();
6391
6481
  return [2 /*return*/, null];
6392
- case 3: return [2 /*return*/];
6482
+ case 4: return [2 /*return*/];
6393
6483
  }
6394
6484
  });
6395
6485
  });
@@ -6459,16 +6549,20 @@
6459
6549
  */
6460
6550
  Authority.prototype.getCloudDiscoveryMetadataFromNetwork = function () {
6461
6551
  return __awaiter(this, void 0, void 0, function () {
6462
- var instanceDiscoveryEndpoint, match, response, metadata;
6552
+ var instanceDiscoveryEndpoint, options, match, response, metadata;
6463
6553
  return __generator(this, function (_a) {
6464
6554
  switch (_a.label) {
6465
6555
  case 0:
6466
6556
  instanceDiscoveryEndpoint = "" + Constants.AAD_INSTANCE_DISCOVERY_ENDPT + this.canonicalAuthority + "oauth2/v2.0/authorize";
6557
+ options = {};
6558
+ if (this.proxyUrl) {
6559
+ options.proxyUrl = this.proxyUrl;
6560
+ }
6467
6561
  match = null;
6468
6562
  _a.label = 1;
6469
6563
  case 1:
6470
6564
  _a.trys.push([1, 3, , 4]);
6471
- return [4 /*yield*/, this.networkInterface.sendGetRequestAsync(instanceDiscoveryEndpoint)];
6565
+ return [4 /*yield*/, this.networkInterface.sendGetRequestAsync(instanceDiscoveryEndpoint, options)];
6472
6566
  case 2:
6473
6567
  response = _a.sent();
6474
6568
  metadata = isCloudInstanceDiscoveryResponse(response.body) ? response.body.metadata : [];
@@ -6483,7 +6577,7 @@
6483
6577
  return [2 /*return*/, null];
6484
6578
  case 4:
6485
6579
  if (!match) {
6486
- // Custom Domain scenario, host is trusted because Instance Discovery call succeeded
6580
+ // Custom Domain scenario, host is trusted because Instance Discovery call succeeded
6487
6581
  match = Authority.createCloudDiscoveryMetadataFromHost(this.hostnameAndPort);
6488
6582
  }
6489
6583
  return [2 /*return*/, match];
@@ -6501,6 +6595,19 @@
6501
6595
  });
6502
6596
  return matches.length > 0;
6503
6597
  };
6598
+ /**
6599
+ * helper function to populate the authority based on azureCloudOptions
6600
+ * @param authorityString
6601
+ * @param azureCloudOptions
6602
+ */
6603
+ Authority.generateAuthority = function (authorityString, azureCloudOptions) {
6604
+ var authorityAzureCloudInstance;
6605
+ if (azureCloudOptions && azureCloudOptions.azureCloudInstance !== exports.AzureCloudInstance.None) {
6606
+ var tenant = azureCloudOptions.tenant ? azureCloudOptions.tenant : Constants.DEFAULT_COMMON_TENANT;
6607
+ authorityAzureCloudInstance = azureCloudOptions.azureCloudInstance + "/" + tenant + "/";
6608
+ }
6609
+ return authorityAzureCloudInstance ? authorityAzureCloudInstance : authorityString;
6610
+ };
6504
6611
  /**
6505
6612
  * Creates cloud discovery metadata object from a given host
6506
6613
  * @param host
@@ -6593,7 +6700,7 @@
6593
6700
  return Authority;
6594
6701
  }());
6595
6702
 
6596
- /*! @azure/msal-common v6.0.0 2022-01-04 */
6703
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
6597
6704
 
6598
6705
  /*
6599
6706
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6612,13 +6719,13 @@
6612
6719
  * @param networkClient
6613
6720
  * @param protocolMode
6614
6721
  */
6615
- AuthorityFactory.createDiscoveredInstance = function (authorityUri, networkClient, cacheManager, authorityOptions) {
6722
+ AuthorityFactory.createDiscoveredInstance = function (authorityUri, networkClient, cacheManager, authorityOptions, proxyUrl) {
6616
6723
  return __awaiter(this, void 0, void 0, function () {
6617
6724
  var acquireTokenAuthority, e_1;
6618
6725
  return __generator(this, function (_a) {
6619
6726
  switch (_a.label) {
6620
6727
  case 0:
6621
- acquireTokenAuthority = AuthorityFactory.createInstance(authorityUri, networkClient, cacheManager, authorityOptions);
6728
+ acquireTokenAuthority = AuthorityFactory.createInstance(authorityUri, networkClient, cacheManager, authorityOptions, proxyUrl);
6622
6729
  _a.label = 1;
6623
6730
  case 1:
6624
6731
  _a.trys.push([1, 3, , 4]);
@@ -6644,17 +6751,17 @@
6644
6751
  * @param networkInterface
6645
6752
  * @param protocolMode
6646
6753
  */
6647
- AuthorityFactory.createInstance = function (authorityUrl, networkInterface, cacheManager, authorityOptions) {
6754
+ AuthorityFactory.createInstance = function (authorityUrl, networkInterface, cacheManager, authorityOptions, proxyUrl) {
6648
6755
  // Throw error if authority url is empty
6649
6756
  if (StringUtils.isEmpty(authorityUrl)) {
6650
6757
  throw ClientConfigurationError.createUrlEmptyError();
6651
6758
  }
6652
- return new Authority(authorityUrl, networkInterface, cacheManager, authorityOptions);
6759
+ return new Authority(authorityUrl, networkInterface, cacheManager, authorityOptions, proxyUrl);
6653
6760
  };
6654
6761
  return AuthorityFactory;
6655
6762
  }());
6656
6763
 
6657
- /*! @azure/msal-common v6.0.0 2022-01-04 */
6764
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
6658
6765
 
6659
6766
  /*
6660
6767
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6685,7 +6792,7 @@
6685
6792
  return ServerTelemetryEntity;
6686
6793
  }());
6687
6794
 
6688
- /*! @azure/msal-common v6.0.0 2022-01-04 */
6795
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
6689
6796
 
6690
6797
  /*
6691
6798
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6713,7 +6820,7 @@
6713
6820
  return ThrottlingEntity;
6714
6821
  }());
6715
6822
 
6716
- /*! @azure/msal-common v6.0.0 2022-01-04 */
6823
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
6717
6824
 
6718
6825
  /*
6719
6826
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6730,7 +6837,7 @@
6730
6837
  }
6731
6838
  };
6732
6839
 
6733
- /*! @azure/msal-common v6.0.0 2022-01-04 */
6840
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
6734
6841
 
6735
6842
  /*
6736
6843
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6782,14 +6889,14 @@
6782
6889
  challenges.forEach(function (challenge) {
6783
6890
  var _a = challenge.split("="), key = _a[0], value = _a[1];
6784
6891
  // Remove escaped quotation marks (', ") from challenge string to keep only the challenge value
6785
- challengeMap[key] = unescape(value.replace(/['"]+/g, ""));
6892
+ challengeMap[key] = unescape(value.replace(/['"]+/g, Constants.EMPTY_STRING));
6786
6893
  });
6787
6894
  return challengeMap;
6788
6895
  };
6789
6896
  return AuthenticationHeaderParser;
6790
6897
  }());
6791
6898
 
6792
- /*! @azure/msal-common v6.0.0 2022-01-04 */
6899
+ /*! @azure/msal-common v6.2.0 2022-04-04 */
6793
6900
 
6794
6901
  /*
6795
6902
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6926,9 +7033,9 @@
6926
7033
  */
6927
7034
  ServerTelemetryManager.prototype.getRegionDiscoveryFields = function () {
6928
7035
  var regionDiscoveryFields = [];
6929
- regionDiscoveryFields.push(this.regionUsed || "");
6930
- regionDiscoveryFields.push(this.regionSource || "");
6931
- 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);
6932
7039
  return regionDiscoveryFields.join(",");
6933
7040
  };
6934
7041
  /**
@@ -6951,6 +7058,390 @@
6951
7058
  return ServerTelemetryManager;
6952
7059
  }());
6953
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
+
6954
7445
  /*
6955
7446
  * Copyright (c) Microsoft Corporation. All rights reserved.
6956
7447
  * Licensed under the MIT License.
@@ -7005,7 +7496,7 @@
7005
7496
  /**
7006
7497
  * Temporary cache keys for MSAL, deleted after any request.
7007
7498
  */
7008
- var TemporaryCacheKeys;
7499
+ exports.TemporaryCacheKeys = void 0;
7009
7500
  (function (TemporaryCacheKeys) {
7010
7501
  TemporaryCacheKeys["AUTHORITY"] = "authority";
7011
7502
  TemporaryCacheKeys["ACQUIRE_TOKEN_ACCOUNT"] = "acquireToken.account";
@@ -7020,7 +7511,7 @@
7020
7511
  TemporaryCacheKeys["INTERACTION_STATUS_KEY"] = "interaction.status";
7021
7512
  TemporaryCacheKeys["CCS_CREDENTIAL"] = "ccs.credential";
7022
7513
  TemporaryCacheKeys["CORRELATION_ID"] = "request.correlationId";
7023
- })(TemporaryCacheKeys || (TemporaryCacheKeys = {}));
7514
+ })(exports.TemporaryCacheKeys || (exports.TemporaryCacheKeys = {}));
7024
7515
  /**
7025
7516
  * Cache keys stored in-memory
7026
7517
  */
@@ -7055,6 +7546,7 @@
7055
7546
  InteractionType["Redirect"] = "redirect";
7056
7547
  InteractionType["Popup"] = "popup";
7057
7548
  InteractionType["Silent"] = "silent";
7549
+ InteractionType["None"] = "none";
7058
7550
  })(exports.InteractionType || (exports.InteractionType = {}));
7059
7551
  /**
7060
7552
  * Types of interaction currently in progress.
@@ -7187,7 +7679,7 @@
7187
7679
  var guidHolder = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx";
7188
7680
  var hex = "0123456789abcdef";
7189
7681
  var r = 0;
7190
- var guidResponse = "";
7682
+ var guidResponse = Constants.EMPTY_STRING;
7191
7683
  for (var i = 0; i < 36; i++) {
7192
7684
  if (guidHolder[i] !== "-" && guidHolder[i] !== "4") {
7193
7685
  // each x and y needs to be random
@@ -7213,7 +7705,7 @@
7213
7705
  * verifies if a string is GUID
7214
7706
  * @param guid
7215
7707
  */
7216
- GuidGenerator.isGuid = function (guid) {
7708
+ GuidGenerator.prototype.isGuid = function (guid) {
7217
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;
7218
7710
  return regexGuid.test(guid);
7219
7711
  };
@@ -7307,7 +7799,7 @@
7307
7799
  * @param aBytes
7308
7800
  */
7309
7801
  BrowserStringUtils.utf8ArrToString = function (aBytes) {
7310
- var sView = "";
7802
+ var sView = Constants.EMPTY_STRING;
7311
7803
  for (var nPart = void 0, nLen = aBytes.length, nIdx = 0; nIdx < nLen; nIdx++) {
7312
7804
  nPart = aBytes[nIdx];
7313
7805
  sView += String.fromCharCode(nPart > 251 && nPart < 254 && nIdx + 5 < nLen ? /* six bytes */
@@ -7346,7 +7838,7 @@
7346
7838
  */
7347
7839
  Base64Encode.prototype.urlEncode = function (input) {
7348
7840
  return encodeURIComponent(this.encode(input)
7349
- .replace(/=/g, "")
7841
+ .replace(/=/g, Constants.EMPTY_STRING)
7350
7842
  .replace(/\+/g, "-")
7351
7843
  .replace(/\//g, "_"));
7352
7844
  };
@@ -7356,7 +7848,7 @@
7356
7848
  */
7357
7849
  Base64Encode.prototype.urlEncodeArr = function (inputArr) {
7358
7850
  return this.base64EncArr(inputArr)
7359
- .replace(/=/g, "")
7851
+ .replace(/=/g, Constants.EMPTY_STRING)
7360
7852
  .replace(/\+/g, "-")
7361
7853
  .replace(/\//g, "_");
7362
7854
  };
@@ -7374,7 +7866,7 @@
7374
7866
  */
7375
7867
  Base64Encode.prototype.base64EncArr = function (aBytes) {
7376
7868
  var eqLen = (3 - (aBytes.length % 3)) % 3;
7377
- var sB64Enc = "";
7869
+ var sB64Enc = Constants.EMPTY_STRING;
7378
7870
  for (var nMod3 = void 0, nLen = aBytes.length, nUint24 = 0, nIdx = 0; nIdx < nLen; nIdx++) {
7379
7871
  nMod3 = nIdx % 3;
7380
7872
  /* Uncomment the following line in order to split the output in lines 76-character long: */
@@ -7448,7 +7940,7 @@
7448
7940
  * @param nBlockSize
7449
7941
  */
7450
7942
  Base64Decode.prototype.base64DecToArr = function (base64String, nBlockSize) {
7451
- var sB64Enc = base64String.replace(/[^A-Za-z0-9\+\/]/g, "");
7943
+ var sB64Enc = base64String.replace(/[^A-Za-z0-9\+\/]/g, Constants.EMPTY_STRING);
7452
7944
  var nInLen = sB64Enc.length;
7453
7945
  var nOutLen = nBlockSize ? Math.ceil((nInLen * 3 + 1 >>> 2) / nBlockSize) * nBlockSize : nInLen * 3 + 1 >>> 2;
7454
7946
  var aBytes = new Uint8Array(nOutLen);
@@ -8166,11 +8658,11 @@
8166
8658
  msExportKey.addEventListener("complete", function (e) {
8167
8659
  var resultBuffer = e.target.result;
8168
8660
  var resultString = BrowserStringUtils.utf8ArrToString(new Uint8Array(resultBuffer))
8169
- .replace(/\r/g, "")
8170
- .replace(/\n/g, "")
8171
- .replace(/\t/g, "")
8172
- .split(" ").join("")
8173
- .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);
8174
8666
  try {
8175
8667
  resolve(JSON.parse(resultString));
8176
8668
  }
@@ -8277,6 +8769,17 @@
8277
8769
  });
8278
8770
  });
8279
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
+ };
8280
8783
  /**
8281
8784
  * Opens database if it's not already open
8282
8785
  */
@@ -8315,9 +8818,13 @@
8315
8818
  var dbGet = objectStore.get(key);
8316
8819
  dbGet.addEventListener("success", function (e) {
8317
8820
  var event = e;
8821
+ _this.closeConnection();
8318
8822
  resolve(event.target.result);
8319
8823
  });
8320
- dbGet.addEventListener("error", function (e) { return reject(e); });
8824
+ dbGet.addEventListener("error", function (e) {
8825
+ _this.closeConnection();
8826
+ reject(e);
8827
+ });
8321
8828
  })];
8322
8829
  }
8323
8830
  });
@@ -8344,8 +8851,14 @@
8344
8851
  var transaction = _this.db.transaction([_this.tableName], "readwrite");
8345
8852
  var objectStore = transaction.objectStore(_this.tableName);
8346
8853
  var dbPut = objectStore.put(payload, key);
8347
- dbPut.addEventListener("success", function () { return resolve(); });
8348
- 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
+ });
8349
8862
  })];
8350
8863
  }
8351
8864
  });
@@ -8370,8 +8883,14 @@
8370
8883
  var transaction = _this.db.transaction([_this.tableName], "readwrite");
8371
8884
  var objectStore = transaction.objectStore(_this.tableName);
8372
8885
  var dbDelete = objectStore.delete(key);
8373
- dbDelete.addEventListener("success", function () { return resolve(); });
8374
- 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
+ });
8375
8894
  })];
8376
8895
  }
8377
8896
  });
@@ -8397,9 +8916,13 @@
8397
8916
  var dbGetKeys = objectStore.getAllKeys();
8398
8917
  dbGetKeys.addEventListener("success", function (e) {
8399
8918
  var event = e;
8919
+ _this.closeConnection();
8400
8920
  resolve(event.target.result);
8401
8921
  });
8402
- dbGetKeys.addEventListener("error", function (e) { return reject(e); });
8922
+ dbGetKeys.addEventListener("error", function (e) {
8923
+ _this.closeConnection();
8924
+ reject(e);
8925
+ });
8403
8926
  })];
8404
8927
  }
8405
8928
  });
@@ -8426,9 +8949,13 @@
8426
8949
  var dbContainsKey = objectStore.count(key);
8427
8950
  dbContainsKey.addEventListener("success", function (e) {
8428
8951
  var event = e;
8952
+ _this.closeConnection();
8429
8953
  resolve(event.target.result === 1);
8430
8954
  });
8431
- dbContainsKey.addEventListener("error", function (e) { return reject(e); });
8955
+ dbContainsKey.addEventListener("error", function (e) {
8956
+ _this.closeConnection();
8957
+ reject(e);
8958
+ });
8432
8959
  })];
8433
8960
  }
8434
8961
  });
@@ -8441,12 +8968,29 @@
8441
8968
  */
8442
8969
  DatabaseStorage.prototype.deleteDatabase = function () {
8443
8970
  return __awaiter$1(this, void 0, void 0, function () {
8971
+ var existingDatabases, database;
8444
8972
  return __generator$1(this, function (_a) {
8445
- return [2 /*return*/, new Promise(function (resolve, reject) {
8446
- var deleteDbRequest = window.indexedDB.deleteDatabase(DB_NAME);
8447
- deleteDbRequest.addEventListener("success", function () { return resolve(true); });
8448
- deleteDbRequest.addEventListener("error", function () { return reject(false); });
8449
- })];
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
+ }
8450
8994
  });
8451
8995
  });
8452
8996
  };
@@ -8495,15 +9039,19 @@
8495
9039
  * backed up with the more volatile MemoryStorage object for cases in which IndexedDB may be unavailable.
8496
9040
  */
8497
9041
  var AsyncMemoryStorage = /** @class */ (function () {
8498
- function AsyncMemoryStorage(logger) {
9042
+ function AsyncMemoryStorage(logger, storeName) {
8499
9043
  this.inMemoryCache = new MemoryStorage();
8500
9044
  this.indexedDBCache = new DatabaseStorage();
8501
9045
  this.logger = logger;
9046
+ this.storeName = storeName;
8502
9047
  }
8503
9048
  AsyncMemoryStorage.prototype.handleDatabaseAccessError = function (error) {
8504
9049
  if (error instanceof BrowserAuthError && error.errorCode === BrowserAuthErrorMessage.databaseUnavailable.code) {
8505
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.");
8506
9051
  }
9052
+ else {
9053
+ throw error;
9054
+ }
8507
9055
  };
8508
9056
  /**
8509
9057
  * Get the item matching the given key. Tries in-memory cache first, then in the asynchronous
@@ -8648,22 +9196,29 @@
8648
9196
  */
8649
9197
  AsyncMemoryStorage.prototype.clear = function () {
8650
9198
  return __awaiter$1(this, void 0, void 0, function () {
8651
- var e_6;
9199
+ var dbDeleted, e_6;
8652
9200
  return __generator$1(this, function (_a) {
8653
9201
  switch (_a.label) {
8654
9202
  case 0:
9203
+ // InMemory cache is a Map instance, clear is straightforward
9204
+ this.logger.verbose("Deleting in-memory keystore " + this.storeName);
8655
9205
  this.inMemoryCache.clear();
9206
+ this.logger.verbose("In-memory keystore " + this.storeName + " deleted");
9207
+ this.logger.verbose("Deleting persistent keystore " + this.storeName);
8656
9208
  _a.label = 1;
8657
9209
  case 1:
8658
9210
  _a.trys.push([1, 3, , 4]);
8659
9211
  return [4 /*yield*/, this.indexedDBCache.deleteDatabase()];
8660
9212
  case 2:
8661
- _a.sent();
8662
- 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];
8663
9218
  case 3:
8664
9219
  e_6 = _a.sent();
8665
9220
  this.handleDatabaseAccessError(e_6);
8666
- return [3 /*break*/, 4];
9221
+ return [2 /*return*/, false];
8667
9222
  case 4: return [2 /*return*/];
8668
9223
  }
8669
9224
  });
@@ -8676,12 +9231,17 @@
8676
9231
  * Copyright (c) Microsoft Corporation. All rights reserved.
8677
9232
  * Licensed under the MIT License.
8678
9233
  */
9234
+ var CryptoKeyStoreNames;
9235
+ (function (CryptoKeyStoreNames) {
9236
+ CryptoKeyStoreNames["asymmetricKeys"] = "asymmetricKeys";
9237
+ CryptoKeyStoreNames["symmetricKeys"] = "symmetricKeys";
9238
+ })(CryptoKeyStoreNames || (CryptoKeyStoreNames = {}));
8679
9239
  /**
8680
9240
  * This class implements MSAL's crypto interface, which allows it to perform base64 encoding and decoding, generating cryptographically random GUIDs and
8681
9241
  * implementing Proof Key for Code Exchange specs for the OAuth Authorization Code Flow using PKCE (rfc here: https://tools.ietf.org/html/rfc7636).
8682
9242
  */
8683
9243
  var CryptoOps = /** @class */ (function () {
8684
- function CryptoOps(logger) {
9244
+ function CryptoOps(logger, performanceClient) {
8685
9245
  this.logger = logger;
8686
9246
  // Browser crypto needs to be validated first before any other classes can be set.
8687
9247
  this.browserCrypto = new BrowserCrypto(this.logger);
@@ -8690,9 +9250,10 @@
8690
9250
  this.guidGenerator = new GuidGenerator(this.browserCrypto);
8691
9251
  this.pkceGenerator = new PkceGenerator(this.browserCrypto);
8692
9252
  this.cache = {
8693
- asymmetricKeys: new AsyncMemoryStorage(this.logger),
8694
- symmetricKeys: new AsyncMemoryStorage(this.logger)
9253
+ asymmetricKeys: new AsyncMemoryStorage(this.logger, CryptoKeyStoreNames.asymmetricKeys),
9254
+ symmetricKeys: new AsyncMemoryStorage(this.logger, CryptoKeyStoreNames.symmetricKeys)
8695
9255
  };
9256
+ this.performanceClient = performanceClient;
8696
9257
  }
8697
9258
  /**
8698
9259
  * Creates a new random GUID - used to populate state and nonce.
@@ -8730,16 +9291,19 @@
8730
9291
  * @param request
8731
9292
  */
8732
9293
  CryptoOps.prototype.getPublicKeyThumbprint = function (request) {
9294
+ var _a;
8733
9295
  return __awaiter$1(this, void 0, void 0, function () {
8734
- var keyPair, publicKeyJwk, pubKeyThumprintObj, publicJwkString, publicJwkHash, privateKeyJwk, unextractablePrivateKey;
8735
- return __generator$1(this, function (_a) {
8736
- switch (_a.label) {
8737
- 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)];
8738
9302
  case 1:
8739
- keyPair = _a.sent();
9303
+ keyPair = _b.sent();
8740
9304
  return [4 /*yield*/, this.browserCrypto.exportJwk(keyPair.publicKey)];
8741
9305
  case 2:
8742
- publicKeyJwk = _a.sent();
9306
+ publicKeyJwk = _b.sent();
8743
9307
  pubKeyThumprintObj = {
8744
9308
  e: publicKeyJwk.e,
8745
9309
  kty: publicKeyJwk.kty,
@@ -8748,13 +9312,13 @@
8748
9312
  publicJwkString = BrowserCrypto.getJwkString(pubKeyThumprintObj);
8749
9313
  return [4 /*yield*/, this.hashString(publicJwkString)];
8750
9314
  case 3:
8751
- publicJwkHash = _a.sent();
9315
+ publicJwkHash = _b.sent();
8752
9316
  return [4 /*yield*/, this.browserCrypto.exportJwk(keyPair.privateKey)];
8753
9317
  case 4:
8754
- privateKeyJwk = _a.sent();
9318
+ privateKeyJwk = _b.sent();
8755
9319
  return [4 /*yield*/, this.browserCrypto.importJwk(privateKeyJwk, false, ["sign"])];
8756
9320
  case 5:
8757
- unextractablePrivateKey = _a.sent();
9321
+ unextractablePrivateKey = _b.sent();
8758
9322
  // Store Keypair data in keystore
8759
9323
  return [4 /*yield*/, this.cache.asymmetricKeys.setItem(publicJwkHash, {
8760
9324
  privateKey: unextractablePrivateKey,
@@ -8764,7 +9328,12 @@
8764
9328
  })];
8765
9329
  case 6:
8766
9330
  // Store Keypair data in keystore
8767
- _a.sent();
9331
+ _b.sent();
9332
+ if (publicKeyThumbMeasurement) {
9333
+ publicKeyThumbMeasurement.endMeasurement({
9334
+ success: true
9335
+ });
9336
+ }
8768
9337
  return [2 /*return*/, publicJwkHash];
8769
9338
  }
8770
9339
  });
@@ -8795,21 +9364,32 @@
8795
9364
  */
8796
9365
  CryptoOps.prototype.clearKeystore = function () {
8797
9366
  return __awaiter$1(this, void 0, void 0, function () {
8798
- var dataStoreNames, databaseStorage, _a;
8799
- return __generator$1(this, function (_b) {
8800
- switch (_b.label) {
9367
+ var e_1;
9368
+ return __generator$1(this, function (_a) {
9369
+ switch (_a.label) {
8801
9370
  case 0:
8802
- dataStoreNames = Object.keys(this.cache);
8803
- databaseStorage = this.cache[dataStoreNames[0]];
8804
- if (!databaseStorage) return [3 /*break*/, 2];
8805
- 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()];
8806
9374
  case 1:
8807
- _a = _b.sent();
8808
- 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()];
8809
9379
  case 2:
8810
- _a = false;
8811
- _b.label = 3;
8812
- 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*/];
8813
9393
  }
8814
9394
  });
8815
9395
  });
@@ -8819,20 +9399,23 @@
8819
9399
  * @param payload
8820
9400
  * @param kid
8821
9401
  */
8822
- CryptoOps.prototype.signJwt = function (payload, kid) {
9402
+ CryptoOps.prototype.signJwt = function (payload, kid, correlationId) {
9403
+ var _a;
8823
9404
  return __awaiter$1(this, void 0, void 0, function () {
8824
- var cachedKeyPair, publicKeyJwk, publicKeyJwkString, header, encodedHeader, encodedPayload, tokenString, tokenBuffer, signatureBuffer, encodedSignature;
8825
- return __generator$1(this, function (_a) {
8826
- switch (_a.label) {
8827
- 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)];
8828
9411
  case 1:
8829
- cachedKeyPair = _a.sent();
9412
+ cachedKeyPair = _b.sent();
8830
9413
  if (!cachedKeyPair) {
8831
9414
  throw BrowserAuthError.createSigningKeyNotFoundInStorageError(kid);
8832
9415
  }
8833
9416
  return [4 /*yield*/, this.browserCrypto.exportJwk(cachedKeyPair.publicKey)];
8834
9417
  case 2:
8835
- publicKeyJwk = _a.sent();
9418
+ publicKeyJwk = _b.sent();
8836
9419
  publicKeyJwkString = BrowserCrypto.getJwkString(publicKeyJwk);
8837
9420
  header = {
8838
9421
  alg: publicKeyJwk.alg,
@@ -8848,9 +9431,15 @@
8848
9431
  tokenBuffer = BrowserStringUtils.stringToArrayBuffer(tokenString);
8849
9432
  return [4 /*yield*/, this.browserCrypto.sign(cachedKeyPair.privateKey, tokenBuffer)];
8850
9433
  case 3:
8851
- signatureBuffer = _a.sent();
9434
+ signatureBuffer = _b.sent();
8852
9435
  encodedSignature = this.b64Encode.urlEncodeArr(new Uint8Array(signatureBuffer));
8853
- 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];
8854
9443
  }
8855
9444
  });
8856
9445
  });
@@ -9370,8 +9959,8 @@
9370
9959
  * Returns wrapper metadata from in-memory storage
9371
9960
  */
9372
9961
  BrowserCacheManager.prototype.getWrapperMetadata = function () {
9373
- var sku = this.internalStorage.getItem(InMemoryCacheKeys.WRAPPER_SKU) || "";
9374
- 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;
9375
9964
  return [sku, version];
9376
9965
  };
9377
9966
  /**
@@ -9593,7 +10182,7 @@
9593
10182
  return decodeURIComponent(cookie.substring(name.length, cookie.length));
9594
10183
  }
9595
10184
  }
9596
- return "";
10185
+ return Constants.EMPTY_STRING;
9597
10186
  };
9598
10187
  /**
9599
10188
  * Clear all msal-related cookies currently set in the browser. Should only be used to clear temporary cache items.
@@ -9618,7 +10207,7 @@
9618
10207
  * @param cookieName
9619
10208
  */
9620
10209
  BrowserCacheManager.prototype.clearItemCookie = function (cookieName) {
9621
- this.setItemCookie(cookieName, "", -1);
10210
+ this.setItemCookie(cookieName, Constants.EMPTY_STRING, -1);
9622
10211
  };
9623
10212
  /**
9624
10213
  * Get cookie expiration time
@@ -9662,7 +10251,7 @@
9662
10251
  */
9663
10252
  BrowserCacheManager.prototype.generateAuthorityKey = function (stateString) {
9664
10253
  var stateId = ProtocolUtils.parseRequestState(this.cryptoImpl, stateString).libraryState.id;
9665
- return this.generateCacheKey(TemporaryCacheKeys.AUTHORITY + "." + stateId);
10254
+ return this.generateCacheKey(exports.TemporaryCacheKeys.AUTHORITY + "." + stateId);
9666
10255
  };
9667
10256
  /**
9668
10257
  * Create Nonce key to cache nonce
@@ -9670,7 +10259,7 @@
9670
10259
  */
9671
10260
  BrowserCacheManager.prototype.generateNonceKey = function (stateString) {
9672
10261
  var stateId = ProtocolUtils.parseRequestState(this.cryptoImpl, stateString).libraryState.id;
9673
- return this.generateCacheKey(TemporaryCacheKeys.NONCE_IDTOKEN + "." + stateId);
10262
+ return this.generateCacheKey(exports.TemporaryCacheKeys.NONCE_IDTOKEN + "." + stateId);
9674
10263
  };
9675
10264
  /**
9676
10265
  * Creates full cache key for the request state
@@ -9679,7 +10268,7 @@
9679
10268
  BrowserCacheManager.prototype.generateStateKey = function (stateString) {
9680
10269
  // Use the library state id to key temp storage for uniqueness for multiple concurrent requests
9681
10270
  var stateId = ProtocolUtils.parseRequestState(this.cryptoImpl, stateString).libraryState.id;
9682
- return this.generateCacheKey(TemporaryCacheKeys.REQUEST_STATE + "." + stateId);
10271
+ return this.generateCacheKey(exports.TemporaryCacheKeys.REQUEST_STATE + "." + stateId);
9683
10272
  };
9684
10273
  /**
9685
10274
  * Gets the cached authority based on the cached state. Returns empty if no cached state found.
@@ -9714,14 +10303,14 @@
9714
10303
  credential: account.homeAccountId,
9715
10304
  type: CcsCredentialType.HOME_ACCOUNT_ID
9716
10305
  };
9717
- this.setTemporaryCache(TemporaryCacheKeys.CCS_CREDENTIAL, JSON.stringify(ccsCredential), true);
10306
+ this.setTemporaryCache(exports.TemporaryCacheKeys.CCS_CREDENTIAL, JSON.stringify(ccsCredential), true);
9718
10307
  }
9719
10308
  else if (!StringUtils.isEmpty(loginHint)) {
9720
10309
  var ccsCredential = {
9721
10310
  credential: loginHint,
9722
10311
  type: CcsCredentialType.UPN
9723
10312
  };
9724
- this.setTemporaryCache(TemporaryCacheKeys.CCS_CREDENTIAL, JSON.stringify(ccsCredential), true);
10313
+ this.setTemporaryCache(exports.TemporaryCacheKeys.CCS_CREDENTIAL, JSON.stringify(ccsCredential), true);
9725
10314
  }
9726
10315
  };
9727
10316
  /**
@@ -9745,11 +10334,11 @@
9745
10334
  this.removeItem(this.generateNonceKey(state));
9746
10335
  this.removeItem(this.generateAuthorityKey(state));
9747
10336
  }
9748
- this.removeItem(this.generateCacheKey(TemporaryCacheKeys.REQUEST_PARAMS));
9749
- this.removeItem(this.generateCacheKey(TemporaryCacheKeys.ORIGIN_URI));
9750
- this.removeItem(this.generateCacheKey(TemporaryCacheKeys.URL_HASH));
9751
- this.removeItem(this.generateCacheKey(TemporaryCacheKeys.CORRELATION_ID));
9752
- this.removeItem(this.generateCacheKey(TemporaryCacheKeys.CCS_CREDENTIAL));
10337
+ this.removeItem(this.generateCacheKey(exports.TemporaryCacheKeys.REQUEST_PARAMS));
10338
+ this.removeItem(this.generateCacheKey(exports.TemporaryCacheKeys.ORIGIN_URI));
10339
+ this.removeItem(this.generateCacheKey(exports.TemporaryCacheKeys.URL_HASH));
10340
+ this.removeItem(this.generateCacheKey(exports.TemporaryCacheKeys.CORRELATION_ID));
10341
+ this.removeItem(this.generateCacheKey(exports.TemporaryCacheKeys.CCS_CREDENTIAL));
9753
10342
  this.setInteractionInProgress(false);
9754
10343
  };
9755
10344
  /**
@@ -9763,7 +10352,7 @@
9763
10352
  var stateKey = this.generateStateKey(stateString);
9764
10353
  var cachedState = this.temporaryCacheStorage.getItem(stateKey);
9765
10354
  this.logger.infoPii("BrowserCacheManager.cleanRequestByState: Removing temporary cache items for state: " + cachedState);
9766
- this.resetRequestCache(cachedState || "");
10355
+ this.resetRequestCache(cachedState || Constants.EMPTY_STRING);
9767
10356
  }
9768
10357
  this.clearMsalCookies();
9769
10358
  };
@@ -9778,7 +10367,7 @@
9778
10367
  // Loop through all keys to find state key
9779
10368
  this.getKeys().forEach(function (key) {
9780
10369
  // If this key is not the state key, move on
9781
- if (key.indexOf(TemporaryCacheKeys.REQUEST_STATE) === -1) {
10370
+ if (key.indexOf(exports.TemporaryCacheKeys.REQUEST_STATE) === -1) {
9782
10371
  return;
9783
10372
  }
9784
10373
  // Retrieve state value, return if not a valid value
@@ -9799,7 +10388,7 @@
9799
10388
  BrowserCacheManager.prototype.cacheCodeRequest = function (authCodeRequest, browserCrypto) {
9800
10389
  this.logger.trace("BrowserCacheManager.cacheCodeRequest called");
9801
10390
  var encodedValue = browserCrypto.base64Encode(JSON.stringify(authCodeRequest));
9802
- this.setTemporaryCache(TemporaryCacheKeys.REQUEST_PARAMS, encodedValue, true);
10391
+ this.setTemporaryCache(exports.TemporaryCacheKeys.REQUEST_PARAMS, encodedValue, true);
9803
10392
  };
9804
10393
  /**
9805
10394
  * Gets the token exchange parameters from the cache. Throws an error if nothing is found.
@@ -9807,7 +10396,7 @@
9807
10396
  BrowserCacheManager.prototype.getCachedRequest = function (state, browserCrypto) {
9808
10397
  this.logger.trace("BrowserCacheManager.getCachedRequest called");
9809
10398
  // Get token request from cache and parse as TokenExchangeParameters.
9810
- var encodedTokenRequest = this.getTemporaryCache(TemporaryCacheKeys.REQUEST_PARAMS, true);
10399
+ var encodedTokenRequest = this.getTemporaryCache(exports.TemporaryCacheKeys.REQUEST_PARAMS, true);
9811
10400
  if (!encodedTokenRequest) {
9812
10401
  throw BrowserAuthError.createNoTokenRequestCacheError();
9813
10402
  }
@@ -9815,7 +10404,7 @@
9815
10404
  if (!parsedRequest) {
9816
10405
  throw BrowserAuthError.createUnableToParseTokenRequestCacheError();
9817
10406
  }
9818
- this.removeItem(this.generateCacheKey(TemporaryCacheKeys.REQUEST_PARAMS));
10407
+ this.removeItem(this.generateCacheKey(exports.TemporaryCacheKeys.REQUEST_PARAMS));
9819
10408
  // Get cached authority and use if no authority is cached with request.
9820
10409
  if (StringUtils.isEmpty(parsedRequest.authority)) {
9821
10410
  var authorityCacheKey = this.generateAuthorityKey(state);
@@ -9837,18 +10426,22 @@
9837
10426
  }
9838
10427
  };
9839
10428
  BrowserCacheManager.prototype.getInteractionInProgress = function () {
9840
- var key = Constants.CACHE_PREFIX + "." + TemporaryCacheKeys.INTERACTION_STATUS_KEY;
10429
+ var key = Constants.CACHE_PREFIX + "." + exports.TemporaryCacheKeys.INTERACTION_STATUS_KEY;
9841
10430
  return this.getTemporaryCache(key, false);
9842
10431
  };
9843
10432
  BrowserCacheManager.prototype.setInteractionInProgress = function (inProgress) {
9844
- var clientId = this.getInteractionInProgress();
9845
10433
  // Ensure we don't overwrite interaction in progress for a different clientId
9846
- var key = Constants.CACHE_PREFIX + "." + TemporaryCacheKeys.INTERACTION_STATUS_KEY;
9847
- if (inProgress && !clientId) {
9848
- // No interaction is in progress
9849
- this.setTemporaryCache(key, this.clientId, false);
10434
+ var key = Constants.CACHE_PREFIX + "." + exports.TemporaryCacheKeys.INTERACTION_STATUS_KEY;
10435
+ if (inProgress) {
10436
+ if (this.getInteractionInProgress()) {
10437
+ throw BrowserAuthError.createInteractionInProgressError();
10438
+ }
10439
+ else {
10440
+ // No interaction is in progress
10441
+ this.setTemporaryCache(key, this.clientId, false);
10442
+ }
9850
10443
  }
9851
- else if (!inProgress && clientId === this.clientId) {
10444
+ else if (!inProgress && this.getInteractionInProgress() === this.clientId) {
9852
10445
  this.removeItem(key);
9853
10446
  }
9854
10447
  };
@@ -9982,7 +10575,7 @@
9982
10575
  return __generator$1(this, function (_b) {
9983
10576
  switch (_b.label) {
9984
10577
  case 0:
9985
- reqBody = (options && options.body) || "";
10578
+ reqBody = (options && options.body) || Constants.EMPTY_STRING;
9986
10579
  _b.label = 1;
9987
10580
  case 1:
9988
10581
  _b.trys.push([1, 3, , 4]);
@@ -10202,7 +10795,7 @@
10202
10795
  BrowserUtils.replaceHash = function (url) {
10203
10796
  var urlParts = url.split("#");
10204
10797
  urlParts.shift(); // Remove part before the hash
10205
- window.location.hash = urlParts.length > 0 ? urlParts.join("#") : "";
10798
+ window.location.hash = urlParts.length > 0 ? urlParts.join("#") : Constants.EMPTY_STRING;
10206
10799
  };
10207
10800
  /**
10208
10801
  * Returns boolean of whether the current window is in an iframe or not.
@@ -10363,19 +10956,23 @@
10363
10956
  * @returns Configuration object
10364
10957
  */
10365
10958
  function buildConfiguration(_a, isBrowserEnvironment) {
10366
- var userInputAuth = _a.auth, userInputCache = _a.cache, userInputSystem = _a.system;
10959
+ var userInputAuth = _a.auth, userInputCache = _a.cache, userInputSystem = _a.system, userInputTelemetry = _a.telemetry;
10367
10960
  // Default auth options for browser
10368
10961
  var DEFAULT_AUTH_OPTIONS = {
10369
- clientId: "",
10962
+ clientId: Constants.EMPTY_STRING,
10370
10963
  authority: "" + Constants.DEFAULT_AUTHORITY,
10371
10964
  knownAuthorities: [],
10372
- cloudDiscoveryMetadata: "",
10373
- authorityMetadata: "",
10374
- redirectUri: "",
10375
- postLogoutRedirectUri: "",
10965
+ cloudDiscoveryMetadata: Constants.EMPTY_STRING,
10966
+ authorityMetadata: Constants.EMPTY_STRING,
10967
+ redirectUri: Constants.EMPTY_STRING,
10968
+ postLogoutRedirectUri: Constants.EMPTY_STRING,
10376
10969
  navigateToLoginRequestUrl: true,
10377
10970
  clientCapabilities: [],
10378
- protocolMode: exports.ProtocolMode.AAD
10971
+ protocolMode: exports.ProtocolMode.AAD,
10972
+ azureCloudOptions: {
10973
+ azureCloudInstance: exports.AzureCloudInstance.None,
10974
+ tenant: Constants.EMPTY_STRING
10975
+ },
10379
10976
  };
10380
10977
  // Default cache options for browser
10381
10978
  var DEFAULT_CACHE_OPTIONS = {
@@ -10394,17 +10991,24 @@
10394
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,
10395
10992
  // If loadFrameTimeout is provided, use that as default.
10396
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
+ };
10397
11000
  var overlayedConfig = {
10398
11001
  auth: __assign$1(__assign$1({}, DEFAULT_AUTH_OPTIONS), userInputAuth),
10399
11002
  cache: __assign$1(__assign$1({}, DEFAULT_CACHE_OPTIONS), userInputCache),
10400
- 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)
10401
11005
  };
10402
11006
  return overlayedConfig;
10403
11007
  }
10404
11008
 
10405
11009
  /* eslint-disable header/header */
10406
11010
  var name = "@azure/msal-browser";
10407
- var version = "2.21.0";
11011
+ var version = "2.23.0";
10408
11012
 
10409
11013
  /*
10410
11014
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -10561,7 +11165,7 @@
10561
11165
  * Licensed under the MIT License.
10562
11166
  */
10563
11167
  var BaseInteractionClient = /** @class */ (function () {
10564
- function BaseInteractionClient(config, storageImpl, browserCrypto, logger, eventHandler, correlationId) {
11168
+ function BaseInteractionClient(config, storageImpl, browserCrypto, logger, eventHandler, performanceClient, correlationId) {
10565
11169
  this.config = config;
10566
11170
  this.browserStorage = storageImpl;
10567
11171
  this.browserCrypto = browserCrypto;
@@ -10569,6 +11173,7 @@
10569
11173
  this.eventHandler = eventHandler;
10570
11174
  this.correlationId = correlationId || this.browserCrypto.createNewGuid();
10571
11175
  this.logger = logger.clone(BrowserConstants.MSAL_SKU, version, this.correlationId);
11176
+ this.performanceClient = performanceClient;
10572
11177
  }
10573
11178
  BaseInteractionClient.prototype.clearCacheOnLogout = function (account) {
10574
11179
  return __awaiter$1(this, void 0, void 0, function () {
@@ -10595,6 +11200,7 @@
10595
11200
  case 4: return [3 /*break*/, 9];
10596
11201
  case 5:
10597
11202
  _a.trys.push([5, 8, , 9]);
11203
+ this.logger.verbose("No account provided in logout request, clearing all cache items.", this.correlationId);
10598
11204
  // Clear all accounts and tokens
10599
11205
  return [4 /*yield*/, this.browserStorage.clear()];
10600
11206
  case 6:
@@ -10605,7 +11211,6 @@
10605
11211
  case 7:
10606
11212
  // Clear any stray keys from IndexedDB
10607
11213
  _a.sent();
10608
- this.logger.verbose("No account provided in logout request, clearing all cache items.");
10609
11214
  return [3 /*break*/, 9];
10610
11215
  case 8:
10611
11216
  _a.sent();
@@ -10622,20 +11227,22 @@
10622
11227
  */
10623
11228
  BaseInteractionClient.prototype.initializeBaseRequest = function (request) {
10624
11229
  return __awaiter$1(this, void 0, void 0, function () {
10625
- var authority, scopes, _a, validatedRequest;
11230
+ var authority, scopes, validatedRequest, _a;
10626
11231
  return __generator$1(this, function (_b) {
10627
11232
  switch (_b.label) {
10628
11233
  case 0:
10629
11234
  this.logger.verbose("Initializing BaseAuthRequest");
10630
11235
  authority = request.authority || this.config.auth.authority;
10631
11236
  scopes = __spread(((request && request.scopes) || []));
11237
+ validatedRequest = __assign$1(__assign$1({}, request), { correlationId: this.correlationId, authority: authority,
11238
+ scopes: scopes });
10632
11239
  // Set authenticationScheme to BEARER if not explicitly set in the request
10633
- if (!request.authenticationScheme) {
10634
- request.authenticationScheme = exports.AuthenticationScheme.BEARER;
11240
+ if (!validatedRequest.authenticationScheme) {
11241
+ validatedRequest.authenticationScheme = exports.AuthenticationScheme.BEARER;
10635
11242
  this.logger.verbose("Authentication Scheme wasn't explicitly set in request, defaulting to \"Bearer\" request");
10636
11243
  }
10637
11244
  else {
10638
- if (request.authenticationScheme === exports.AuthenticationScheme.SSH) {
11245
+ if (validatedRequest.authenticationScheme === exports.AuthenticationScheme.SSH) {
10639
11246
  if (!request.sshJwk) {
10640
11247
  throw ClientConfigurationError.createMissingSshJwkError();
10641
11248
  }
@@ -10643,18 +11250,15 @@
10643
11250
  throw ClientConfigurationError.createMissingSshKidError();
10644
11251
  }
10645
11252
  }
10646
- this.logger.verbose("Authentication Scheme set to \"" + request.authenticationScheme + "\" as configured in Auth request");
11253
+ this.logger.verbose("Authentication Scheme set to \"" + validatedRequest.authenticationScheme + "\" as configured in Auth request");
10647
11254
  }
10648
11255
  if (!(request.claims && !StringUtils.isEmpty(request.claims))) return [3 /*break*/, 2];
10649
- _a = request;
11256
+ _a = validatedRequest;
10650
11257
  return [4 /*yield*/, this.browserCrypto.hashString(request.claims)];
10651
11258
  case 1:
10652
11259
  _a.requestedClaimsHash = _b.sent();
10653
11260
  _b.label = 2;
10654
- case 2:
10655
- validatedRequest = __assign$1(__assign$1({}, request), { correlationId: this.correlationId, authority: authority,
10656
- scopes: scopes });
10657
- return [2 /*return*/, validatedRequest];
11261
+ case 2: return [2 /*return*/, validatedRequest];
10658
11262
  }
10659
11263
  });
10660
11264
  });
@@ -10701,8 +11305,8 @@
10701
11305
  */
10702
11306
  var StandardInteractionClient = /** @class */ (function (_super) {
10703
11307
  __extends$1(StandardInteractionClient, _super);
10704
- function StandardInteractionClient(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, correlationId) {
10705
- 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;
10706
11310
  _this.navigationClient = navigationClient;
10707
11311
  return _this;
10708
11312
  }
@@ -10720,7 +11324,7 @@
10720
11324
  return [4 /*yield*/, this.browserCrypto.generatePkceCodes()];
10721
11325
  case 1:
10722
11326
  generatedPkceParams = _a.sent();
10723
- 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 });
10724
11328
  request.codeChallenge = generatedPkceParams.challenge;
10725
11329
  request.codeChallengeMethod = Constants.S256_CODE_CHALLENGE_METHOD;
10726
11330
  return [2 /*return*/, authCodeRequest];
@@ -10734,11 +11338,32 @@
10734
11338
  */
10735
11339
  StandardInteractionClient.prototype.initializeLogoutRequest = function (logoutRequest) {
10736
11340
  this.logger.verbose("initializeLogoutRequest called", logoutRequest === null || logoutRequest === void 0 ? void 0 : logoutRequest.correlationId);
10737
- // Check if interaction is in progress. Throw error if true.
10738
- if (this.browserStorage.isInteractionInProgress()) {
10739
- throw BrowserAuthError.createInteractionInProgressError();
10740
- }
10741
11341
  var validLogoutRequest = __assign$1({ correlationId: this.browserCrypto.createNewGuid() }, logoutRequest);
11342
+ /**
11343
+ * Set logout_hint to be login_hint from ID Token Claims if present
11344
+ * and logoutHint attribute wasn't manually set in logout request
11345
+ */
11346
+ if (logoutRequest) {
11347
+ // If logoutHint isn't set and an account was passed in, try to extract logoutHint from ID Token Claims
11348
+ if (!logoutRequest.logoutHint) {
11349
+ if (logoutRequest.account) {
11350
+ var logoutHint = this.getLogoutHintFromIdTokenClaims(logoutRequest.account);
11351
+ if (logoutHint) {
11352
+ this.logger.verbose("Setting logoutHint to login_hint ID Token Claim value for the account provided");
11353
+ validLogoutRequest.logoutHint = logoutHint;
11354
+ }
11355
+ }
11356
+ else {
11357
+ this.logger.verbose("logoutHint was not set and account was not passed into logout request, logoutHint will not be set");
11358
+ }
11359
+ }
11360
+ else {
11361
+ this.logger.verbose("logoutHint has already been set in logoutRequest");
11362
+ }
11363
+ }
11364
+ else {
11365
+ this.logger.verbose("logoutHint will not be set since no logout request was configured");
11366
+ }
10742
11367
  /*
10743
11368
  * Only set redirect uri if logout request isn't provided or the set uri isn't null.
10744
11369
  * Otherwise, use passed uri, config, or current page.
@@ -10765,17 +11390,37 @@
10765
11390
  }
10766
11391
  return validLogoutRequest;
10767
11392
  };
11393
+ /**
11394
+ * Parses login_hint ID Token Claim out of AccountInfo object to be used as
11395
+ * logout_hint in end session request.
11396
+ * @param account
11397
+ */
11398
+ StandardInteractionClient.prototype.getLogoutHintFromIdTokenClaims = function (account) {
11399
+ var idTokenClaims = account.idTokenClaims;
11400
+ if (idTokenClaims) {
11401
+ if (idTokenClaims.login_hint) {
11402
+ return idTokenClaims.login_hint;
11403
+ }
11404
+ else {
11405
+ this.logger.verbose("The ID Token Claims tied to the provided account do not contain a login_hint claim, logoutHint will not be added to logout request");
11406
+ }
11407
+ }
11408
+ else {
11409
+ this.logger.verbose("The provided account does not contain ID Token Claims, logoutHint will not be added to logout request");
11410
+ }
11411
+ return null;
11412
+ };
10768
11413
  /**
10769
11414
  * Creates an Authorization Code Client with the given authority, or the default authority.
10770
11415
  * @param serverTelemetryManager
10771
11416
  * @param authorityUrl
10772
11417
  */
10773
- StandardInteractionClient.prototype.createAuthCodeClient = function (serverTelemetryManager, authorityUrl) {
11418
+ StandardInteractionClient.prototype.createAuthCodeClient = function (serverTelemetryManager, authorityUrl, requestAzureCloudOptions) {
10774
11419
  return __awaiter$1(this, void 0, void 0, function () {
10775
11420
  var clientConfig;
10776
11421
  return __generator$1(this, function (_a) {
10777
11422
  switch (_a.label) {
10778
- case 0: return [4 /*yield*/, this.getClientConfiguration(serverTelemetryManager, authorityUrl)];
11423
+ case 0: return [4 /*yield*/, this.getClientConfiguration(serverTelemetryManager, authorityUrl, requestAzureCloudOptions)];
10779
11424
  case 1:
10780
11425
  clientConfig = _a.sent();
10781
11426
  return [2 /*return*/, new AuthorizationCodeClient(clientConfig)];
@@ -10789,14 +11434,14 @@
10789
11434
  * @param requestAuthority
10790
11435
  * @param requestCorrelationId
10791
11436
  */
10792
- StandardInteractionClient.prototype.getClientConfiguration = function (serverTelemetryManager, requestAuthority) {
11437
+ StandardInteractionClient.prototype.getClientConfiguration = function (serverTelemetryManager, requestAuthority, requestAzureCloudOptions) {
10793
11438
  return __awaiter$1(this, void 0, void 0, function () {
10794
11439
  var discoveredAuthority;
10795
11440
  return __generator$1(this, function (_a) {
10796
11441
  switch (_a.label) {
10797
11442
  case 0:
10798
- this.logger.verbose("getClientConfiguration called");
10799
- return [4 /*yield*/, this.getDiscoveredAuthority(requestAuthority)];
11443
+ this.logger.verbose("getClientConfiguration called", this.correlationId);
11444
+ return [4 /*yield*/, this.getDiscoveredAuthority(requestAuthority, requestAzureCloudOptions)];
10800
11445
  case 1:
10801
11446
  discoveredAuthority = _a.sent();
10802
11447
  return [2 /*return*/, {
@@ -10822,9 +11467,10 @@
10822
11467
  libraryInfo: {
10823
11468
  sku: BrowserConstants.MSAL_SKU,
10824
11469
  version: version,
10825
- cpu: "",
10826
- os: ""
10827
- }
11470
+ cpu: Constants.EMPTY_STRING,
11471
+ os: Constants.EMPTY_STRING
11472
+ },
11473
+ telemetry: this.config.telemetry
10828
11474
  }];
10829
11475
  }
10830
11476
  });
@@ -10856,49 +11502,36 @@
10856
11502
  * @param requestAuthority
10857
11503
  * @param requestCorrelationId
10858
11504
  */
10859
- StandardInteractionClient.prototype.getDiscoveredAuthority = function (requestAuthority) {
11505
+ StandardInteractionClient.prototype.getDiscoveredAuthority = function (requestAuthority, requestAzureCloudOptions) {
10860
11506
  return __awaiter$1(this, void 0, void 0, function () {
10861
- var authorityOptions;
11507
+ var getAuthorityMeasurement, authorityOptions, userAuthority, builtAuthority;
10862
11508
  return __generator$1(this, function (_a) {
10863
11509
  switch (_a.label) {
10864
11510
  case 0:
10865
- this.logger.verbose("getDiscoveredAuthority called");
11511
+ this.logger.verbose("getDiscoveredAuthority called", this.correlationId);
11512
+ getAuthorityMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.StandardInteractionClientGetDiscoveredAuthority, this.correlationId);
10866
11513
  authorityOptions = {
10867
11514
  protocolMode: this.config.auth.protocolMode,
10868
11515
  knownAuthorities: this.config.auth.knownAuthorities,
10869
11516
  cloudDiscoveryMetadata: this.config.auth.cloudDiscoveryMetadata,
10870
- authorityMetadata: this.config.auth.authorityMetadata
11517
+ authorityMetadata: this.config.auth.authorityMetadata,
10871
11518
  };
10872
- if (!requestAuthority) return [3 /*break*/, 2];
10873
- this.logger.verbose("Creating discovered authority with request authority");
10874
- return [4 /*yield*/, AuthorityFactory.createDiscoveredInstance(requestAuthority, this.config.system.networkClient, this.browserStorage, authorityOptions)];
10875
- case 1: return [2 /*return*/, _a.sent()];
10876
- case 2:
10877
- this.logger.verbose("Creating discovered authority with configured authority");
10878
- return [4 /*yield*/, AuthorityFactory.createDiscoveredInstance(this.config.auth.authority, this.config.system.networkClient, this.browserStorage, authorityOptions)];
10879
- case 3: return [2 /*return*/, _a.sent()];
10880
- }
10881
- });
10882
- });
10883
- };
10884
- /**
10885
- * Helper to validate app environment before making a request.
10886
- * @param request
10887
- * @param interactionType
10888
- */
10889
- StandardInteractionClient.prototype.preflightInteractiveRequest = function (request, interactionType) {
10890
- return __awaiter$1(this, void 0, void 0, function () {
10891
- return __generator$1(this, function (_a) {
10892
- switch (_a.label) {
10893
- case 0:
10894
- this.logger.verbose("preflightInteractiveRequest called, validating app environment", request === null || request === void 0 ? void 0 : request.correlationId);
10895
- // block the reload if it occurred inside a hidden iframe
10896
- BrowserUtils.blockReloadInHiddenIframes();
10897
- // Check if interaction is in progress. Throw error if true.
10898
- if (this.browserStorage.isInteractionInProgress(false)) {
10899
- throw BrowserAuthError.createInteractionInProgressError();
10900
- }
10901
- return [4 /*yield*/, this.initializeAuthorizationRequest(request, interactionType)];
11519
+ userAuthority = requestAuthority ? requestAuthority : this.config.auth.authority;
11520
+ builtAuthority = Authority.generateAuthority(userAuthority, requestAzureCloudOptions || this.config.auth.azureCloudOptions);
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
+ })];
10902
11535
  case 1: return [2 /*return*/, _a.sent()];
10903
11536
  }
10904
11537
  });
@@ -10915,20 +11548,20 @@
10915
11548
  return __generator$1(this, function (_b) {
10916
11549
  switch (_b.label) {
10917
11550
  case 0:
10918
- this.logger.verbose("initializeAuthorizationRequest called");
11551
+ this.logger.verbose("initializeAuthorizationRequest called", this.correlationId);
10919
11552
  redirectUri = this.getRedirectUri(request.redirectUri);
10920
11553
  browserState = {
10921
11554
  interactionType: interactionType
10922
11555
  };
10923
- state = ProtocolUtils.setRequestState(this.browserCrypto, (request && request.state) || "", browserState);
11556
+ state = ProtocolUtils.setRequestState(this.browserCrypto, (request && request.state) || Constants.EMPTY_STRING, browserState);
10924
11557
  _a = [{}];
10925
11558
  return [4 /*yield*/, this.initializeBaseRequest(request)];
10926
11559
  case 1:
10927
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 }]);
10928
11561
  account = request.account || this.browserStorage.getActiveAccount();
10929
11562
  if (account) {
10930
- this.logger.verbose("Setting validated request account");
10931
- 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);
10932
11565
  validatedRequest.account = account;
10933
11566
  }
10934
11567
  // Check for ADAL/MSAL v1 SSO
@@ -10938,7 +11571,6 @@
10938
11571
  validatedRequest.loginHint = legacyLoginHint;
10939
11572
  }
10940
11573
  }
10941
- this.browserStorage.updateCacheEntries(validatedRequest.state, validatedRequest.nonce, validatedRequest.authority, validatedRequest.loginHint || "", validatedRequest.account || null);
10942
11574
  return [2 /*return*/, validatedRequest];
10943
11575
  }
10944
11576
  });
@@ -11109,8 +11741,8 @@
11109
11741
  * @param clientId
11110
11742
  * @param request
11111
11743
  */
11112
- PopupUtils.generatePopupName = function (clientId, request) {
11113
- return BrowserConstants.POPUP_NAME_PREFIX + "." + clientId + "." + request.scopes.join("-") + "." + request.authority + "." + request.correlationId;
11744
+ PopupUtils.generatePopupName = function (clientId, scopes, authority, correlationId) {
11745
+ return BrowserConstants.POPUP_NAME_PREFIX + "." + clientId + "." + scopes.join("-") + "." + authority + "." + correlationId;
11114
11746
  };
11115
11747
  /**
11116
11748
  * Generates the name for the popup based on the client id and request for logouts
@@ -11243,7 +11875,7 @@
11243
11875
  */
11244
11876
  InteractionHandler.prototype.checkCcsCredentials = function () {
11245
11877
  // Look up ccs credential in temp cache
11246
- var cachedCcsCred = this.browserStorage.getTemporaryCache(TemporaryCacheKeys.CCS_CREDENTIAL, true);
11878
+ var cachedCcsCred = this.browserStorage.getTemporaryCache(exports.TemporaryCacheKeys.CCS_CREDENTIAL, true);
11247
11879
  if (cachedCcsCred) {
11248
11880
  try {
11249
11881
  return JSON.parse(cachedCcsCred);
@@ -11281,8 +11913,6 @@
11281
11913
  PopupHandler.prototype.initiateAuthRequest = function (requestUrl, params) {
11282
11914
  // Check that request url is not empty.
11283
11915
  if (!StringUtils.isEmpty(requestUrl)) {
11284
- // Set interaction status in the library.
11285
- this.browserStorage.setInteractionInProgress(true);
11286
11916
  this.browserRequestLogger.infoPii("Navigate to: " + requestUrl);
11287
11917
  // Open the popup window to requestUrl.
11288
11918
  return this.popupUtils.openPopup(requestUrl, params);
@@ -11332,36 +11962,25 @@
11332
11962
  * @param request
11333
11963
  */
11334
11964
  PopupClient.prototype.acquireToken = function (request) {
11335
- return __awaiter$1(this, void 0, void 0, function () {
11336
- var validRequest, popupName, popupWindowAttributes, popup, e_1;
11337
- return __generator$1(this, function (_a) {
11338
- switch (_a.label) {
11339
- case 0:
11340
- _a.trys.push([0, 2, , 3]);
11341
- return [4 /*yield*/, this.preflightInteractiveRequest(request, exports.InteractionType.Popup)];
11342
- case 1:
11343
- validRequest = _a.sent();
11344
- popupName = PopupUtils.generatePopupName(this.config.auth.clientId, validRequest);
11345
- popupWindowAttributes = request.popupWindowAttributes || {};
11346
- // asyncPopups flag is true. Acquires token without first opening popup. Popup will be opened later asynchronously.
11347
- if (this.config.system.asyncPopups) {
11348
- this.logger.verbose("asyncPopups set to true, acquiring token");
11349
- // Passes on popup position and dimensions if in request
11350
- return [2 /*return*/, this.acquireTokenPopupAsync(validRequest, popupName, popupWindowAttributes)];
11351
- }
11352
- else {
11353
- // asyncPopups flag is set to false. Opens popup before acquiring token.
11354
- this.logger.verbose("asyncPopup set to false, opening popup before acquiring token");
11355
- popup = PopupUtils.openSizedPopup("about:blank", popupName, popupWindowAttributes, this.logger);
11356
- return [2 /*return*/, this.acquireTokenPopupAsync(validRequest, popupName, popupWindowAttributes, popup)];
11357
- }
11358
- case 2:
11359
- e_1 = _a.sent();
11360
- return [2 /*return*/, Promise.reject(e_1)];
11361
- case 3: return [2 /*return*/];
11362
- }
11363
- });
11364
- });
11965
+ try {
11966
+ var popupName = PopupUtils.generatePopupName(this.config.auth.clientId, request.scopes || OIDC_DEFAULT_SCOPES, request.authority || this.config.auth.authority, this.correlationId);
11967
+ var popupWindowAttributes = request.popupWindowAttributes || {};
11968
+ // asyncPopups flag is true. Acquires token without first opening popup. Popup will be opened later asynchronously.
11969
+ if (this.config.system.asyncPopups) {
11970
+ this.logger.verbose("asyncPopups set to true, acquiring token");
11971
+ // Passes on popup position and dimensions if in request
11972
+ return this.acquireTokenPopupAsync(request, popupName, popupWindowAttributes);
11973
+ }
11974
+ else {
11975
+ // asyncPopups flag is set to false. Opens popup before acquiring token.
11976
+ this.logger.verbose("asyncPopup set to false, opening popup before acquiring token");
11977
+ var popup = PopupUtils.openSizedPopup("about:blank", popupName, popupWindowAttributes, this.logger);
11978
+ return this.acquireTokenPopupAsync(request, popupName, popupWindowAttributes, popup);
11979
+ }
11980
+ }
11981
+ catch (e) {
11982
+ return Promise.reject(e);
11983
+ }
11365
11984
  };
11366
11985
  /**
11367
11986
  * Clears local cache for the current user then opens a popup window prompting the user to sign-out of the server
@@ -11402,26 +12021,30 @@
11402
12021
  *
11403
12022
  * @returns A promise that is fulfilled when this function has completed, or rejected if an error was raised.
11404
12023
  */
11405
- PopupClient.prototype.acquireTokenPopupAsync = function (validRequest, popupName, popupWindowAttributes, popup) {
12024
+ PopupClient.prototype.acquireTokenPopupAsync = function (request, popupName, popupWindowAttributes, popup) {
11406
12025
  return __awaiter$1(this, void 0, void 0, function () {
11407
- var serverTelemetryManager, authCodeRequest, authClient, navigateUrl, interactionHandler, popupParameters, popupWindow, hash, state, result, e_2;
12026
+ var serverTelemetryManager, validRequest, authCodeRequest, authClient, navigateUrl, interactionHandler, popupParameters, popupWindow, hash, state, result, e_1;
11408
12027
  return __generator$1(this, function (_a) {
11409
12028
  switch (_a.label) {
11410
12029
  case 0:
11411
12030
  this.logger.verbose("acquireTokenPopupAsync called");
11412
12031
  serverTelemetryManager = this.initializeServerTelemetryManager(exports.ApiId.acquireTokenPopup);
11413
- _a.label = 1;
12032
+ return [4 /*yield*/, this.initializeAuthorizationRequest(request, exports.InteractionType.Popup)];
11414
12033
  case 1:
11415
- _a.trys.push([1, 7, , 8]);
11416
- return [4 /*yield*/, this.initializeAuthorizationCodeRequest(validRequest)];
12034
+ validRequest = _a.sent();
12035
+ this.browserStorage.updateCacheEntries(validRequest.state, validRequest.nonce, validRequest.authority, validRequest.loginHint || Constants.EMPTY_STRING, validRequest.account || null);
12036
+ _a.label = 2;
11417
12037
  case 2:
11418
- authCodeRequest = _a.sent();
11419
- return [4 /*yield*/, this.createAuthCodeClient(serverTelemetryManager, validRequest.authority)];
12038
+ _a.trys.push([2, 8, , 9]);
12039
+ return [4 /*yield*/, this.initializeAuthorizationCodeRequest(validRequest)];
11420
12040
  case 3:
12041
+ authCodeRequest = _a.sent();
12042
+ return [4 /*yield*/, this.createAuthCodeClient(serverTelemetryManager, validRequest.authority, validRequest.azureCloudOptions)];
12043
+ case 4:
11421
12044
  authClient = _a.sent();
11422
12045
  this.logger.verbose("Auth code client created");
11423
12046
  return [4 /*yield*/, authClient.getAuthCodeUrl(validRequest)];
11424
- case 4:
12047
+ case 5:
11425
12048
  navigateUrl = _a.sent();
11426
12049
  interactionHandler = new PopupHandler(authClient, this.browserStorage, authCodeRequest, this.logger);
11427
12050
  popupParameters = {
@@ -11432,28 +12055,28 @@
11432
12055
  popupWindow = interactionHandler.initiateAuthRequest(navigateUrl, popupParameters);
11433
12056
  this.eventHandler.emitEvent(exports.EventType.POPUP_OPENED, exports.InteractionType.Popup, { popupWindow: popupWindow }, null);
11434
12057
  return [4 /*yield*/, interactionHandler.monitorPopupForHash(popupWindow)];
11435
- case 5:
12058
+ case 6:
11436
12059
  hash = _a.sent();
11437
12060
  state = this.validateAndExtractStateFromHash(hash, exports.InteractionType.Popup, validRequest.correlationId);
11438
12061
  // Remove throttle if it exists
11439
12062
  ThrottlingUtils.removeThrottle(this.browserStorage, this.config.auth.clientId, authCodeRequest);
11440
12063
  return [4 /*yield*/, interactionHandler.handleCodeResponseFromHash(hash, state, authClient.authority, this.networkClient)];
11441
- case 6:
12064
+ case 7:
11442
12065
  result = _a.sent();
11443
12066
  return [2 /*return*/, result];
11444
- case 7:
11445
- e_2 = _a.sent();
12067
+ case 8:
12068
+ e_1 = _a.sent();
11446
12069
  if (popup) {
11447
12070
  // Close the synchronous popup if an error is thrown before the window unload event is registered
11448
12071
  popup.close();
11449
12072
  }
11450
- if (e_2 instanceof AuthError) {
11451
- e_2.setCorrelationId(this.correlationId);
12073
+ if (e_1 instanceof AuthError) {
12074
+ e_1.setCorrelationId(this.correlationId);
11452
12075
  }
11453
- serverTelemetryManager.cacheFailedRequest(e_2);
12076
+ serverTelemetryManager.cacheFailedRequest(e_1);
11454
12077
  this.browserStorage.cleanRequestByState(validRequest.state);
11455
- throw e_2;
11456
- case 8: return [2 /*return*/];
12078
+ throw e_1;
12079
+ case 9: return [2 /*return*/];
11457
12080
  }
11458
12081
  });
11459
12082
  });
@@ -11469,7 +12092,7 @@
11469
12092
  */
11470
12093
  PopupClient.prototype.logoutPopupAsync = function (validRequest, popupName, popupWindowAttributes, requestAuthority, popup, mainWindowRedirectUri) {
11471
12094
  return __awaiter$1(this, void 0, void 0, function () {
11472
- var serverTelemetryManager, authClient, logoutUri, popupUtils, popupWindow, e_3, navigationOptions, absoluteUrl, e_4;
12095
+ var serverTelemetryManager, authClient, logoutUri, popupUtils, popupWindow, e_2, navigationOptions, absoluteUrl, e_3;
11473
12096
  return __generator$1(this, function (_a) {
11474
12097
  switch (_a.label) {
11475
12098
  case 0:
@@ -11484,7 +12107,6 @@
11484
12107
  case 2:
11485
12108
  // Clear cache on logout
11486
12109
  _a.sent();
11487
- this.browserStorage.setInteractionInProgress(true);
11488
12110
  return [4 /*yield*/, this.createAuthCodeClient(serverTelemetryManager, requestAuthority)];
11489
12111
  case 3:
11490
12112
  authClient = _a.sent();
@@ -11505,8 +12127,8 @@
11505
12127
  this.logger.verbose("Popup successfully redirected to postLogoutRedirectUri");
11506
12128
  return [3 /*break*/, 7];
11507
12129
  case 6:
11508
- e_3 = _a.sent();
11509
- this.logger.verbose("Error occurred while monitoring popup for same origin. Session on server may remain active. Error: " + e_3);
12130
+ e_2 = _a.sent();
12131
+ this.logger.verbose("Error occurred while monitoring popup for same origin. Session on server may remain active. Error: " + e_2);
11510
12132
  return [3 /*break*/, 7];
11511
12133
  case 7:
11512
12134
  popupUtils.cleanPopup(popupWindow);
@@ -11518,7 +12140,7 @@
11518
12140
  };
11519
12141
  absoluteUrl = UrlString.getAbsoluteUrl(mainWindowRedirectUri, BrowserUtils.getCurrentUri());
11520
12142
  this.logger.verbose("Redirecting main window to url specified in the request");
11521
- this.logger.verbosePii("Redirecing main window to: " + absoluteUrl);
12143
+ this.logger.verbosePii("Redirecting main window to: " + absoluteUrl);
11522
12144
  this.navigationClient.navigateInternal(absoluteUrl, navigationOptions);
11523
12145
  }
11524
12146
  else {
@@ -11526,19 +12148,19 @@
11526
12148
  }
11527
12149
  return [3 /*break*/, 9];
11528
12150
  case 8:
11529
- e_4 = _a.sent();
12151
+ e_3 = _a.sent();
11530
12152
  if (popup) {
11531
12153
  // Close the synchronous popup if an error is thrown before the window unload event is registered
11532
12154
  popup.close();
11533
12155
  }
11534
- if (e_4 instanceof AuthError) {
11535
- e_4.setCorrelationId(this.correlationId);
12156
+ if (e_3 instanceof AuthError) {
12157
+ e_3.setCorrelationId(this.correlationId);
11536
12158
  }
11537
12159
  this.browserStorage.setInteractionInProgress(false);
11538
- this.eventHandler.emitEvent(exports.EventType.LOGOUT_FAILURE, exports.InteractionType.Popup, null, e_4);
12160
+ this.eventHandler.emitEvent(exports.EventType.LOGOUT_FAILURE, exports.InteractionType.Popup, null, e_3);
11539
12161
  this.eventHandler.emitEvent(exports.EventType.LOGOUT_END, exports.InteractionType.Popup);
11540
- serverTelemetryManager.cacheFailedRequest(e_4);
11541
- throw e_4;
12162
+ serverTelemetryManager.cacheFailedRequest(e_3);
12163
+ throw e_3;
11542
12164
  case 9:
11543
12165
  this.eventHandler.emitEvent(exports.EventType.LOGOUT_END, exports.InteractionType.Popup);
11544
12166
  return [2 /*return*/];
@@ -11575,11 +12197,10 @@
11575
12197
  // Cache start page, returns to this page after redirectUri if navigateToLoginRequestUrl is true
11576
12198
  if (params.redirectStartPage) {
11577
12199
  this.browserRequestLogger.verbose("RedirectHandler.initiateAuthRequest: redirectStartPage set, caching start page");
11578
- this.browserStorage.setTemporaryCache(TemporaryCacheKeys.ORIGIN_URI, params.redirectStartPage, true);
12200
+ this.browserStorage.setTemporaryCache(exports.TemporaryCacheKeys.ORIGIN_URI, params.redirectStartPage, true);
11579
12201
  }
11580
12202
  // Set interaction status in the library.
11581
- this.browserStorage.setInteractionInProgress(true);
11582
- this.browserStorage.setTemporaryCache(TemporaryCacheKeys.CORRELATION_ID, this.authCodeRequest.correlationId, true);
12203
+ this.browserStorage.setTemporaryCache(exports.TemporaryCacheKeys.CORRELATION_ID, this.authCodeRequest.correlationId, true);
11583
12204
  this.browserStorage.cacheCodeRequest(this.authCodeRequest, this.browserCrypto);
11584
12205
  this.browserRequestLogger.infoPii("RedirectHandler.initiateAuthRequest: Navigate to: " + requestUrl);
11585
12206
  navigationOptions = {
@@ -11693,20 +12314,29 @@
11693
12314
  */
11694
12315
  RedirectClient.prototype.acquireToken = function (request) {
11695
12316
  return __awaiter$1(this, void 0, void 0, function () {
11696
- var validRequest, serverTelemetryManager, authCodeRequest, authClient, interactionHandler, navigateUrl, redirectStartPage, e_1;
12317
+ var validRequest, serverTelemetryManager, handleBackButton, authCodeRequest, authClient, interactionHandler, navigateUrl, redirectStartPage, e_1;
12318
+ var _this = this;
11697
12319
  return __generator$1(this, function (_a) {
11698
12320
  switch (_a.label) {
11699
- case 0: return [4 /*yield*/, this.preflightInteractiveRequest(request, exports.InteractionType.Redirect)];
12321
+ case 0: return [4 /*yield*/, this.initializeAuthorizationRequest(request, exports.InteractionType.Redirect)];
11700
12322
  case 1:
11701
12323
  validRequest = _a.sent();
12324
+ this.browserStorage.updateCacheEntries(validRequest.state, validRequest.nonce, validRequest.authority, validRequest.loginHint || Constants.EMPTY_STRING, validRequest.account || null);
11702
12325
  serverTelemetryManager = this.initializeServerTelemetryManager(exports.ApiId.acquireTokenRedirect);
12326
+ handleBackButton = function (event) {
12327
+ // Clear temporary cache if the back button is clicked during the redirect flow.
12328
+ if (event.persisted) {
12329
+ _this.logger.verbose("Page was restored from back/forward cache. Clearing temporary cache.");
12330
+ _this.browserStorage.cleanRequestByState(validRequest.state);
12331
+ }
12332
+ };
11703
12333
  _a.label = 2;
11704
12334
  case 2:
11705
12335
  _a.trys.push([2, 7, , 8]);
11706
12336
  return [4 /*yield*/, this.initializeAuthorizationCodeRequest(validRequest)];
11707
12337
  case 3:
11708
12338
  authCodeRequest = _a.sent();
11709
- return [4 /*yield*/, this.createAuthCodeClient(serverTelemetryManager, validRequest.authority)];
12339
+ return [4 /*yield*/, this.createAuthCodeClient(serverTelemetryManager, validRequest.authority, validRequest.azureCloudOptions)];
11710
12340
  case 4:
11711
12341
  authClient = _a.sent();
11712
12342
  this.logger.verbose("Auth code client created");
@@ -11716,6 +12346,8 @@
11716
12346
  navigateUrl = _a.sent();
11717
12347
  redirectStartPage = this.getRedirectStartPage(request.redirectStartPage);
11718
12348
  this.logger.verbosePii("Redirect start page: " + redirectStartPage);
12349
+ // Clear temporary cache if the back button is clicked during the redirect flow.
12350
+ window.addEventListener("pageshow", handleBackButton);
11719
12351
  return [4 /*yield*/, interactionHandler.initiateAuthRequest(navigateUrl, {
11720
12352
  navigationClient: this.navigationClient,
11721
12353
  redirectTimeout: this.config.system.redirectNavigationTimeout,
@@ -11730,6 +12362,7 @@
11730
12362
  if (e_1 instanceof AuthError) {
11731
12363
  e_1.setCorrelationId(this.correlationId);
11732
12364
  }
12365
+ window.removeEventListener("pageshow", handleBackButton);
11733
12366
  serverTelemetryManager.cacheFailedRequest(e_1);
11734
12367
  this.browserStorage.cleanRequestByState(validRequest.state);
11735
12368
  throw e_1;
@@ -11768,7 +12401,6 @@
11768
12401
  state = void 0;
11769
12402
  try {
11770
12403
  state = this.validateAndExtractStateFromHash(responseHash, exports.InteractionType.Redirect);
11771
- BrowserUtils.clearHash(window);
11772
12404
  this.logger.verbose("State extracted from hash");
11773
12405
  }
11774
12406
  catch (e) {
@@ -11776,7 +12408,7 @@
11776
12408
  this.browserStorage.cleanRequestByInteractionType(exports.InteractionType.Redirect);
11777
12409
  return [2 /*return*/, null];
11778
12410
  }
11779
- loginRequestUrl = this.browserStorage.getTemporaryCache(TemporaryCacheKeys.ORIGIN_URI, true) || "";
12411
+ loginRequestUrl = this.browserStorage.getTemporaryCache(exports.TemporaryCacheKeys.ORIGIN_URI, true) || Constants.EMPTY_STRING;
11780
12412
  loginRequestUrlNormalized = UrlString.removeHashFromUrl(loginRequestUrl);
11781
12413
  currentUrlNormalized = UrlString.removeHashFromUrl(window.location.href);
11782
12414
  if (!(loginRequestUrlNormalized === currentUrlNormalized && this.config.auth.navigateToLoginRequestUrl)) return [3 /*break*/, 3];
@@ -11800,7 +12432,7 @@
11800
12432
  * Returned from authority using redirect - need to perform navigation before processing response
11801
12433
  * Cache the hash to be retrieved after the next redirect
11802
12434
  */
11803
- this.browserStorage.setTemporaryCache(TemporaryCacheKeys.URL_HASH, responseHash, true);
12435
+ this.browserStorage.setTemporaryCache(exports.TemporaryCacheKeys.URL_HASH, responseHash, true);
11804
12436
  navigationOptions = {
11805
12437
  apiId: exports.ApiId.handleRedirectPromise,
11806
12438
  timeout: this.config.system.redirectNavigationTimeout,
@@ -11810,7 +12442,7 @@
11810
12442
  if (!(!loginRequestUrl || loginRequestUrl === "null")) return [3 /*break*/, 6];
11811
12443
  homepage = BrowserUtils.getHomepage();
11812
12444
  // Cache the homepage under ORIGIN_URI to ensure cached hash is processed on homepage
11813
- this.browserStorage.setTemporaryCache(TemporaryCacheKeys.ORIGIN_URI, homepage, true);
12445
+ this.browserStorage.setTemporaryCache(exports.TemporaryCacheKeys.ORIGIN_URI, homepage, true);
11814
12446
  this.logger.warning("Unable to get valid login request url from cache, redirecting to home page");
11815
12447
  return [4 /*yield*/, this.navigationClient.navigateInternal(homepage, navigationOptions)];
11816
12448
  case 5:
@@ -11852,12 +12484,13 @@
11852
12484
  this.logger.verbose("getRedirectResponseHash called");
11853
12485
  // Get current location hash from window or cache.
11854
12486
  var isResponseHash = UrlString.hashContainsKnownProperties(hash);
11855
- var cachedHash = this.browserStorage.getTemporaryCache(TemporaryCacheKeys.URL_HASH, true);
11856
- this.browserStorage.removeItem(this.browserStorage.generateCacheKey(TemporaryCacheKeys.URL_HASH));
11857
12487
  if (isResponseHash) {
12488
+ BrowserUtils.clearHash(window);
11858
12489
  this.logger.verbose("Hash contains known properties, returning response hash");
11859
12490
  return hash;
11860
12491
  }
12492
+ var cachedHash = this.browserStorage.getTemporaryCache(exports.TemporaryCacheKeys.URL_HASH, true);
12493
+ this.browserStorage.removeItem(this.browserStorage.generateCacheKey(exports.TemporaryCacheKeys.URL_HASH));
11861
12494
  this.logger.verbose("Hash does not contain known properties, returning cached hash");
11862
12495
  return cachedHash;
11863
12496
  };
@@ -12125,8 +12758,8 @@
12125
12758
  */
12126
12759
  var SilentIframeClient = /** @class */ (function (_super) {
12127
12760
  __extends$1(SilentIframeClient, _super);
12128
- function SilentIframeClient(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, apiId, correlationId) {
12129
- 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;
12130
12763
  _this.apiId = apiId;
12131
12764
  return _this;
12132
12765
  }
@@ -12136,22 +12769,27 @@
12136
12769
  */
12137
12770
  SilentIframeClient.prototype.acquireToken = function (request) {
12138
12771
  return __awaiter$1(this, void 0, void 0, function () {
12139
- var silentRequest, serverTelemetryManager, authCodeRequest, authClient, navigateUrl, e_1;
12772
+ var acquireTokenMeasurement, silentRequest, serverTelemetryManager, authCodeRequest, authClient, navigateUrl, e_1;
12140
12773
  return __generator$1(this, function (_a) {
12141
12774
  switch (_a.label) {
12142
12775
  case 0:
12143
12776
  this.logger.verbose("acquireTokenByIframe called");
12777
+ acquireTokenMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.SilentIframeClientAcquireToken, request.correlationId);
12144
12778
  // Check that we have some SSO data
12145
12779
  if (StringUtils.isEmpty(request.loginHint) && StringUtils.isEmpty(request.sid) && (!request.account || StringUtils.isEmpty(request.account.username))) {
12146
12780
  this.logger.warning("No user hint provided. The authorization server may need more information to complete this request.");
12147
12781
  }
12148
12782
  // Check that prompt is set to none, throw error if it is set to anything else.
12149
12783
  if (request.prompt && request.prompt !== PromptValue.NONE) {
12784
+ acquireTokenMeasurement.endMeasurement({
12785
+ success: false
12786
+ });
12150
12787
  throw BrowserAuthError.createSilentPromptValueError(request.prompt);
12151
12788
  }
12152
12789
  return [4 /*yield*/, this.initializeAuthorizationRequest(__assign$1(__assign$1({}, request), { prompt: PromptValue.NONE }), exports.InteractionType.Silent)];
12153
12790
  case 1:
12154
12791
  silentRequest = _a.sent();
12792
+ this.browserStorage.updateCacheEntries(silentRequest.state, silentRequest.nonce, silentRequest.authority, silentRequest.loginHint || Constants.EMPTY_STRING, silentRequest.account || null);
12155
12793
  serverTelemetryManager = this.initializeServerTelemetryManager(this.apiId);
12156
12794
  _a.label = 2;
12157
12795
  case 2:
@@ -12159,14 +12797,21 @@
12159
12797
  return [4 /*yield*/, this.initializeAuthorizationCodeRequest(silentRequest)];
12160
12798
  case 3:
12161
12799
  authCodeRequest = _a.sent();
12162
- return [4 /*yield*/, this.createAuthCodeClient(serverTelemetryManager, silentRequest.authority)];
12800
+ return [4 /*yield*/, this.createAuthCodeClient(serverTelemetryManager, silentRequest.authority, silentRequest.azureCloudOptions)];
12163
12801
  case 4:
12164
12802
  authClient = _a.sent();
12165
12803
  this.logger.verbose("Auth code client created");
12166
12804
  return [4 /*yield*/, authClient.getAuthCodeUrl(silentRequest)];
12167
12805
  case 5:
12168
12806
  navigateUrl = _a.sent();
12169
- 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
+ })];
12170
12815
  case 6: return [2 /*return*/, _a.sent()];
12171
12816
  case 7:
12172
12817
  e_1 = _a.sent();
@@ -12175,6 +12820,9 @@
12175
12820
  }
12176
12821
  serverTelemetryManager.cacheFailedRequest(e_1);
12177
12822
  this.browserStorage.cleanRequestByState(silentRequest.state);
12823
+ acquireTokenMeasurement.endMeasurement({
12824
+ success: false
12825
+ });
12178
12826
  throw e_1;
12179
12827
  case 8: return [2 /*return*/];
12180
12828
  }
@@ -12232,7 +12880,7 @@
12232
12880
  */
12233
12881
  SilentRefreshClient.prototype.acquireToken = function (request) {
12234
12882
  return __awaiter$1(this, void 0, void 0, function () {
12235
- var silentRequest, _a, serverTelemetryManager, refreshTokenClient;
12883
+ var silentRequest, _a, acquireTokenMeasurement, serverTelemetryManager, refreshTokenClient;
12236
12884
  var _this = this;
12237
12885
  return __generator$1(this, function (_b) {
12238
12886
  switch (_b.label) {
@@ -12241,17 +12889,29 @@
12241
12889
  return [4 /*yield*/, this.initializeBaseRequest(request)];
12242
12890
  case 1:
12243
12891
  silentRequest = __assign$1.apply(void 0, _a.concat([_b.sent()]));
12892
+ acquireTokenMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.SilentRefreshClientAcquireToken, silentRequest.correlationId);
12244
12893
  serverTelemetryManager = this.initializeServerTelemetryManager(exports.ApiId.acquireTokenSilent_silentFlow);
12245
- return [4 /*yield*/, this.createRefreshTokenClient(serverTelemetryManager, silentRequest.authority)];
12894
+ return [4 /*yield*/, this.createRefreshTokenClient(serverTelemetryManager, silentRequest.authority, silentRequest.azureCloudOptions)];
12246
12895
  case 2:
12247
12896
  refreshTokenClient = _b.sent();
12248
12897
  this.logger.verbose("Refresh token client created");
12249
12898
  // Send request to renew token. Auth module will throw errors if token cannot be renewed.
12250
- 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) {
12251
12908
  if (e instanceof AuthError) {
12252
12909
  e.setCorrelationId(_this.correlationId);
12253
12910
  }
12254
12911
  serverTelemetryManager.cacheFailedRequest(e);
12912
+ acquireTokenMeasurement.endMeasurement({
12913
+ success: false
12914
+ });
12255
12915
  throw e;
12256
12916
  })];
12257
12917
  }
@@ -12270,12 +12930,12 @@
12270
12930
  * @param serverTelemetryManager
12271
12931
  * @param authorityUrl
12272
12932
  */
12273
- SilentRefreshClient.prototype.createRefreshTokenClient = function (serverTelemetryManager, authorityUrl) {
12933
+ SilentRefreshClient.prototype.createRefreshTokenClient = function (serverTelemetryManager, authorityUrl, azureCloudOptions) {
12274
12934
  return __awaiter$1(this, void 0, void 0, function () {
12275
12935
  var clientConfig;
12276
12936
  return __generator$1(this, function (_a) {
12277
12937
  switch (_a.label) {
12278
- case 0: return [4 /*yield*/, this.getClientConfiguration(serverTelemetryManager, authorityUrl)];
12938
+ case 0: return [4 /*yield*/, this.getClientConfiguration(serverTelemetryManager, authorityUrl, azureCloudOptions)];
12279
12939
  case 1:
12280
12940
  clientConfig = _a.sent();
12281
12941
  return [2 /*return*/, new RefreshTokenClient(clientConfig)];
@@ -12318,13 +12978,14 @@
12318
12978
  this.loadAccessToken(request, response, request.account.homeAccountId, request.account.environment, request.account.tenantId, options);
12319
12979
  }
12320
12980
  else if (request.authority) {
12981
+ var authorityUrl = Authority.generateAuthority(request.authority, request.azureCloudOptions);
12321
12982
  var authorityOptions = {
12322
12983
  protocolMode: this.config.auth.protocolMode,
12323
12984
  knownAuthorities: this.config.auth.knownAuthorities,
12324
12985
  cloudDiscoveryMetadata: this.config.auth.cloudDiscoveryMetadata,
12325
- authorityMetadata: this.config.auth.authorityMetadata
12986
+ authorityMetadata: this.config.auth.authorityMetadata,
12326
12987
  };
12327
- var authority = new Authority(request.authority, this.config.system.networkClient, this.storage, authorityOptions);
12988
+ var authority = new Authority(authorityUrl, this.config.system.networkClient, this.storage, authorityOptions);
12328
12989
  // "clientInfo" from options takes precedence over "clientInfo" in response
12329
12990
  if (options.clientInfo) {
12330
12991
  this.logger.trace("TokenCache - homeAccountId from options");
@@ -12423,8 +13084,8 @@
12423
13084
  */
12424
13085
  var SilentAuthCodeClient = /** @class */ (function (_super) {
12425
13086
  __extends$1(SilentAuthCodeClient, _super);
12426
- function SilentAuthCodeClient(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, apiId, correlationId) {
12427
- 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;
12428
13089
  _this.apiId = apiId;
12429
13090
  return _this;
12430
13091
  }
@@ -12446,6 +13107,7 @@
12446
13107
  return [4 /*yield*/, this.initializeAuthorizationRequest(request, exports.InteractionType.Silent)];
12447
13108
  case 1:
12448
13109
  silentRequest = _a.sent();
13110
+ this.browserStorage.updateCacheEntries(silentRequest.state, silentRequest.nonce, silentRequest.authority, silentRequest.loginHint || Constants.EMPTY_STRING, silentRequest.account || null);
12449
13111
  serverTelemetryManager = this.initializeServerTelemetryManager(this.apiId);
12450
13112
  _a.label = 2;
12451
13113
  case 2:
@@ -12487,6 +13149,110 @@
12487
13149
  return SilentAuthCodeClient;
12488
13150
  }(StandardInteractionClient));
12489
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
+
12490
13256
  /*
12491
13257
  * Copyright (c) Microsoft Corporation. All rights reserved.
12492
13258
  * Licensed under the MIT License.
@@ -12532,8 +13298,12 @@
12532
13298
  this.redirectResponse = new Map();
12533
13299
  // Initial hybrid spa map
12534
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);
12535
13305
  // Initialize the crypto class.
12536
- 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;
12537
13307
  this.eventHandler = new EventHandler(this.logger, this.browserCrypto);
12538
13308
  // Initialize the browser storage class.
12539
13309
  this.browserStorage = this.isBrowserEnvironment ?
@@ -12563,8 +13333,8 @@
12563
13333
  if (typeof response === "undefined") {
12564
13334
  this.eventHandler.emitEvent(exports.EventType.HANDLE_REDIRECT_START, exports.InteractionType.Redirect);
12565
13335
  this.logger.verbose("handleRedirectPromise has been called for the first time, storing the promise");
12566
- correlationId = this.browserStorage.getTemporaryCache(TemporaryCacheKeys.CORRELATION_ID, true) || "";
12567
- 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);
12568
13338
  response = redirectClient.handleRedirectPromise(hash)
12569
13339
  .then(function (result) {
12570
13340
  if (result) {
@@ -12616,12 +13386,12 @@
12616
13386
  */
12617
13387
  ClientApplication.prototype.acquireTokenRedirect = function (request) {
12618
13388
  return __awaiter$1(this, void 0, void 0, function () {
12619
- var isLoggedIn, redirectClient;
13389
+ var correlationId, isLoggedIn, redirectClient;
12620
13390
  var _this = this;
12621
13391
  return __generator$1(this, function (_a) {
12622
- // Preflight request
13392
+ correlationId = this.getRequestCorrelationId(request);
13393
+ this.logger.verbose("acquireTokenRedirect called", correlationId);
12623
13394
  this.preflightBrowserEnvironmentCheck(exports.InteractionType.Redirect);
12624
- this.logger.verbose("acquireTokenRedirect called");
12625
13395
  isLoggedIn = this.getAllAccounts().length > 0;
12626
13396
  if (isLoggedIn) {
12627
13397
  this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_START, exports.InteractionType.Redirect, request);
@@ -12629,8 +13399,8 @@
12629
13399
  else {
12630
13400
  this.eventHandler.emitEvent(exports.EventType.LOGIN_START, exports.InteractionType.Redirect, request);
12631
13401
  }
12632
- redirectClient = new RedirectClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, request.correlationId);
12633
- 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) {
12634
13404
  // If logged in, emit acquire token events
12635
13405
  if (isLoggedIn) {
12636
13406
  _this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_FAILURE, exports.InteractionType.Redirect, null, e);
@@ -12654,9 +13424,10 @@
12654
13424
  */
12655
13425
  ClientApplication.prototype.acquireTokenPopup = function (request) {
12656
13426
  var _this = this;
13427
+ var correlationId = this.getRequestCorrelationId(request);
12657
13428
  try {
13429
+ this.logger.verbose("acquireTokenPopup called", correlationId);
12658
13430
  this.preflightBrowserEnvironmentCheck(exports.InteractionType.Popup);
12659
- this.logger.verbose("acquireTokenPopup called", request.correlationId);
12660
13431
  }
12661
13432
  catch (e) {
12662
13433
  // Since this function is syncronous we need to reject
@@ -12670,8 +13441,8 @@
12670
13441
  else {
12671
13442
  this.eventHandler.emitEvent(exports.EventType.LOGIN_START, exports.InteractionType.Popup, request);
12672
13443
  }
12673
- var popupClient = new PopupClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, request.correlationId);
12674
- 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) {
12675
13446
  // If logged in, emit acquire token events
12676
13447
  var isLoggingIn = loggedInAccounts.length < _this.getAllAccounts().length;
12677
13448
  if (isLoggingIn) {
@@ -12711,25 +13482,35 @@
12711
13482
  */
12712
13483
  ClientApplication.prototype.ssoSilent = function (request) {
12713
13484
  return __awaiter$1(this, void 0, void 0, function () {
12714
- var silentIframeClient, silentTokenResult, e_1;
13485
+ var correlationId, ssoSilentMeasurement, silentIframeClient, silentTokenResult, e_1;
12715
13486
  return __generator$1(this, function (_a) {
12716
13487
  switch (_a.label) {
12717
13488
  case 0:
13489
+ correlationId = this.getRequestCorrelationId(request);
12718
13490
  this.preflightBrowserEnvironmentCheck(exports.InteractionType.Silent);
12719
- this.logger.verbose("ssoSilent called", request.correlationId);
13491
+ ssoSilentMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.SsoSilent, correlationId);
13492
+ this.logger.verbose("ssoSilent called", correlationId);
12720
13493
  this.eventHandler.emitEvent(exports.EventType.SSO_SILENT_START, exports.InteractionType.Silent, request);
12721
13494
  _a.label = 1;
12722
13495
  case 1:
12723
13496
  _a.trys.push([1, 3, , 4]);
12724
- silentIframeClient = new SilentIframeClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, exports.ApiId.ssoSilent, request.correlationId);
12725
- 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 }))];
12726
13499
  case 2:
12727
13500
  silentTokenResult = _a.sent();
12728
13501
  this.eventHandler.emitEvent(exports.EventType.SSO_SILENT_SUCCESS, exports.InteractionType.Silent, silentTokenResult);
13502
+ ssoSilentMeasurement.endMeasurement({
13503
+ success: true
13504
+ });
13505
+ ssoSilentMeasurement.flushMeasurement();
12729
13506
  return [2 /*return*/, silentTokenResult];
12730
13507
  case 3:
12731
13508
  e_1 = _a.sent();
12732
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();
12733
13514
  throw e_1;
12734
13515
  case 4: return [2 /*return*/];
12735
13516
  }
@@ -12748,38 +13529,56 @@
12748
13529
  */
12749
13530
  ClientApplication.prototype.acquireTokenByCode = function (request) {
12750
13531
  return __awaiter$1(this, void 0, void 0, function () {
12751
- var response;
13532
+ var correlationId, atbcMeasurement, response;
12752
13533
  var _this = this;
12753
13534
  return __generator$1(this, function (_a) {
13535
+ correlationId = this.getRequestCorrelationId(request);
12754
13536
  this.preflightBrowserEnvironmentCheck(exports.InteractionType.Silent);
12755
- this.logger.trace("acquireTokenByCode called", request.correlationId);
13537
+ this.logger.trace("acquireTokenByCode called", correlationId);
12756
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);
12757
13540
  try {
12758
13541
  if (!request.code) {
12759
13542
  throw BrowserAuthError.createAuthCodeRequiredError();
12760
13543
  }
12761
13544
  response = this.hybridAuthCodeResponses.get(request.code);
12762
13545
  if (!response) {
12763
- this.logger.verbose("Initiating new acquireTokenByCode request", request.correlationId);
12764
- response = this.acquireTokenByCodeAsync(request)
13546
+ this.logger.verbose("Initiating new acquireTokenByCode request", correlationId);
13547
+ response = this.acquireTokenByCodeAsync(__assign$1(__assign$1({}, request), { correlationId: correlationId }))
12765
13548
  .then(function (result) {
12766
13549
  _this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_BY_CODE_SUCCESS, exports.InteractionType.Silent, result);
12767
13550
  _this.hybridAuthCodeResponses.delete(request.code);
13551
+ atbcMeasurement.endMeasurement({
13552
+ success: true
13553
+ });
13554
+ atbcMeasurement.flushMeasurement();
12768
13555
  return result;
12769
13556
  })
12770
13557
  .catch(function (error) {
12771
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();
12772
13564
  throw error;
12773
13565
  });
12774
13566
  this.hybridAuthCodeResponses.set(request.code, response);
12775
13567
  }
12776
13568
  else {
12777
13569
  this.logger.verbose("Existing acquireTokenByCode request found", request.correlationId);
13570
+ atbcMeasurement.endMeasurement({
13571
+ success: true
13572
+ });
13573
+ atbcMeasurement.discardMeasurement();
12778
13574
  }
12779
13575
  return [2 /*return*/, response];
12780
13576
  }
12781
13577
  catch (e) {
12782
13578
  this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_BY_CODE_FAILURE, exports.InteractionType.Silent, null, e);
13579
+ atbcMeasurement.endMeasurement({
13580
+ success: false
13581
+ });
12783
13582
  throw e;
12784
13583
  }
12785
13584
  return [2 /*return*/];
@@ -12798,7 +13597,7 @@
12798
13597
  switch (_a.label) {
12799
13598
  case 0:
12800
13599
  this.logger.trace("acquireTokenByCodeAsync called", request.correlationId);
12801
- 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);
12802
13601
  return [4 /*yield*/, silentAuthCodeClient.acquireToken(request)];
12803
13602
  case 1:
12804
13603
  silentTokenResult = _a.sent();
@@ -12820,22 +13619,47 @@
12820
13619
  */
12821
13620
  ClientApplication.prototype.acquireTokenByRefreshToken = function (request) {
12822
13621
  return __awaiter$1(this, void 0, void 0, function () {
12823
- var silentRefreshClient;
13622
+ var atbrtMeasurement, silentRefreshClient;
12824
13623
  var _this = this;
12825
13624
  return __generator$1(this, function (_a) {
12826
- this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_NETWORK_START, exports.InteractionType.Silent, request);
12827
13625
  // block the reload if it occurred inside a hidden iframe
12828
13626
  BrowserUtils.blockReloadInHiddenIframes();
12829
- silentRefreshClient = new SilentRefreshClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, request.correlationId);
12830
- 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) {
12831
13639
  var isServerError = e instanceof ServerError;
12832
13640
  var isInteractionRequiredError = e instanceof InteractionRequiredAuthError;
12833
13641
  var isInvalidGrantError = (e.errorCode === BrowserConstants.INVALID_GRANT_ERROR);
12834
13642
  if (isServerError && isInvalidGrantError && !isInteractionRequiredError) {
12835
13643
  _this.logger.verbose("Refresh token expired or invalid, attempting acquire token by iframe", request.correlationId);
12836
- var silentIframeClient = new SilentIframeClient(_this.config, _this.browserStorage, _this.browserCrypto, _this.logger, _this.eventHandler, _this.navigationClient, exports.ApiId.acquireTokenSilent_authCode, request.correlationId);
12837
- 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
+ });
12838
13659
  }
13660
+ atbrtMeasurement.endMeasurement({
13661
+ success: false
13662
+ });
12839
13663
  throw e;
12840
13664
  })];
12841
13665
  });
@@ -12850,9 +13674,11 @@
12850
13674
  */
12851
13675
  ClientApplication.prototype.logout = function (logoutRequest) {
12852
13676
  return __awaiter$1(this, void 0, void 0, function () {
13677
+ var correlationId;
12853
13678
  return __generator$1(this, function (_a) {
12854
- this.logger.warning("logout API is deprecated and will be removed in msal-browser v3.0.0. Use logoutRedirect instead.");
12855
- 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))];
12856
13682
  });
12857
13683
  });
12858
13684
  };
@@ -12863,11 +13689,12 @@
12863
13689
  */
12864
13690
  ClientApplication.prototype.logoutRedirect = function (logoutRequest) {
12865
13691
  return __awaiter$1(this, void 0, void 0, function () {
12866
- var redirectClient;
13692
+ var correlationId, redirectClient;
12867
13693
  return __generator$1(this, function (_a) {
13694
+ correlationId = this.getRequestCorrelationId(logoutRequest);
12868
13695
  this.preflightBrowserEnvironmentCheck(exports.InteractionType.Redirect);
12869
- redirectClient = new RedirectClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, logoutRequest === null || logoutRequest === void 0 ? void 0 : logoutRequest.correlationId);
12870
- 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))];
12871
13698
  });
12872
13699
  });
12873
13700
  };
@@ -12877,9 +13704,10 @@
12877
13704
  */
12878
13705
  ClientApplication.prototype.logoutPopup = function (logoutRequest) {
12879
13706
  try {
13707
+ var correlationId = this.getRequestCorrelationId(logoutRequest);
12880
13708
  this.preflightBrowserEnvironmentCheck(exports.InteractionType.Popup);
12881
- 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);
12882
- 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));
12883
13711
  }
12884
13712
  catch (e) {
12885
13713
  // Since this function is syncronous we need to reject
@@ -12991,6 +13819,21 @@
12991
13819
  !this.config.cache.storeAuthStateInCookie) {
12992
13820
  throw BrowserConfigurationAuthError.createInMemoryRedirectUnavailableError();
12993
13821
  }
13822
+ if (interactionType === exports.InteractionType.Redirect || interactionType === exports.InteractionType.Popup) {
13823
+ this.preflightInteractiveRequest();
13824
+ }
13825
+ };
13826
+ /**
13827
+ * Helper to validate app environment before making a request.
13828
+ * @param request
13829
+ * @param interactionType
13830
+ */
13831
+ ClientApplication.prototype.preflightInteractiveRequest = function () {
13832
+ this.logger.verbose("preflightInteractiveRequest called, validating app environment");
13833
+ // block the reload if it occurred inside a hidden iframe
13834
+ BrowserUtils.blockReloadInHiddenIframes();
13835
+ // Set interaction in progress temporary cache or throw if alread set.
13836
+ this.browserStorage.setInteractionInProgress(true);
12994
13837
  };
12995
13838
  /**
12996
13839
  * Adds event callbacks to array
@@ -13006,6 +13849,24 @@
13006
13849
  ClientApplication.prototype.removeEventCallback = function (callbackId) {
13007
13850
  this.eventHandler.removeEventCallback(callbackId);
13008
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
+ };
13009
13870
  /**
13010
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
13011
13872
  */
@@ -13059,6 +13920,26 @@
13059
13920
  ClientApplication.prototype.getConfiguration = function () {
13060
13921
  return this.config;
13061
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
+ };
13062
13943
  return ClientApplication;
13063
13944
  }());
13064
13945
 
@@ -13077,12 +13958,13 @@
13077
13958
  */
13078
13959
  SilentCacheClient.prototype.acquireToken = function (silentRequest) {
13079
13960
  return __awaiter$1(this, void 0, void 0, function () {
13080
- var serverTelemetryManager, silentAuthClient, cachedToken, error_1;
13961
+ var acquireTokenMeasurement, serverTelemetryManager, silentAuthClient, cachedToken, error_1;
13081
13962
  return __generator$1(this, function (_a) {
13082
13963
  switch (_a.label) {
13083
13964
  case 0:
13965
+ acquireTokenMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.SilentCacheClientAcquireToken, silentRequest.correlationId);
13084
13966
  serverTelemetryManager = this.initializeServerTelemetryManager(exports.ApiId.acquireTokenSilent_silentFlow);
13085
- return [4 /*yield*/, this.createSilentFlowClient(serverTelemetryManager, silentRequest.authority)];
13967
+ return [4 /*yield*/, this.createSilentFlowClient(serverTelemetryManager, silentRequest.authority, silentRequest.azureCloudOptions)];
13086
13968
  case 1:
13087
13969
  silentAuthClient = _a.sent();
13088
13970
  this.logger.verbose("Silent auth client created");
@@ -13093,12 +13975,19 @@
13093
13975
  case 3:
13094
13976
  cachedToken = _a.sent();
13095
13977
  this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_SUCCESS, exports.InteractionType.Silent, cachedToken);
13978
+ acquireTokenMeasurement.endMeasurement({
13979
+ success: true,
13980
+ fromCache: true
13981
+ });
13096
13982
  return [2 /*return*/, cachedToken];
13097
13983
  case 4:
13098
13984
  error_1 = _a.sent();
13099
13985
  if (error_1 instanceof BrowserAuthError && error_1.errorCode === BrowserAuthErrorMessage.signingKeyNotFoundInStorage.code) {
13100
13986
  this.logger.verbose("Signing keypair for bound access token not found. Refreshing bound access token and generating a new crypto keypair.");
13101
13987
  }
13988
+ acquireTokenMeasurement.endMeasurement({
13989
+ success: false
13990
+ });
13102
13991
  throw error_1;
13103
13992
  case 5: return [2 /*return*/];
13104
13993
  }
@@ -13117,12 +14006,12 @@
13117
14006
  * @param serverTelemetryManager
13118
14007
  * @param authorityUrl
13119
14008
  */
13120
- SilentCacheClient.prototype.createSilentFlowClient = function (serverTelemetryManager, authorityUrl) {
14009
+ SilentCacheClient.prototype.createSilentFlowClient = function (serverTelemetryManager, authorityUrl, azureCloudOptions) {
13121
14010
  return __awaiter$1(this, void 0, void 0, function () {
13122
14011
  var clientConfig;
13123
14012
  return __generator$1(this, function (_a) {
13124
14013
  switch (_a.label) {
13125
- case 0: return [4 /*yield*/, this.getClientConfiguration(serverTelemetryManager, authorityUrl)];
14014
+ case 0: return [4 /*yield*/, this.getClientConfiguration(serverTelemetryManager, authorityUrl, azureCloudOptions)];
13126
14015
  case 1:
13127
14016
  clientConfig = _a.sent();
13128
14017
  return [2 /*return*/, new SilentFlowClient(clientConfig)];
@@ -13193,9 +14082,11 @@
13193
14082
  */
13194
14083
  PublicClientApplication.prototype.loginRedirect = function (request) {
13195
14084
  return __awaiter$1(this, void 0, void 0, function () {
14085
+ var correlationId;
13196
14086
  return __generator$1(this, function (_a) {
13197
- this.logger.verbose("loginRedirect called");
13198
- 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)))];
13199
14090
  });
13200
14091
  });
13201
14092
  };
@@ -13207,8 +14098,9 @@
13207
14098
  * @returns A promise that is fulfilled when this function has completed, or rejected if an error was raised.
13208
14099
  */
13209
14100
  PublicClientApplication.prototype.loginPopup = function (request) {
13210
- this.logger.verbose("loginPopup called");
13211
- 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)));
13212
14104
  };
13213
14105
  /**
13214
14106
  * Silently acquire an access token for a given set of scopes. Returns currently processing promise if parallel requests are made.
@@ -13218,18 +14110,20 @@
13218
14110
  */
13219
14111
  PublicClientApplication.prototype.acquireTokenSilent = function (request) {
13220
14112
  return __awaiter$1(this, void 0, void 0, function () {
13221
- var account, thumbprint, silentRequestKey, cachedResponse, response;
14113
+ var correlationId, atsMeasurement, account, thumbprint, silentRequestKey, cachedResponse, response;
13222
14114
  var _this = this;
13223
14115
  return __generator$1(this, function (_a) {
14116
+ correlationId = this.getRequestCorrelationId(request);
14117
+ atsMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.AcquireTokenSilent, correlationId);
13224
14118
  this.preflightBrowserEnvironmentCheck(exports.InteractionType.Silent);
13225
- this.logger.verbose("acquireTokenSilent called", request.correlationId);
14119
+ this.logger.verbose("acquireTokenSilent called", correlationId);
13226
14120
  account = request.account || this.getActiveAccount();
13227
14121
  if (!account) {
13228
14122
  throw BrowserAuthError.createNoAccountError();
13229
14123
  }
13230
14124
  thumbprint = {
13231
14125
  clientId: this.config.auth.clientId,
13232
- authority: request.authority || "",
14126
+ authority: request.authority || Constants.EMPTY_STRING,
13233
14127
  scopes: request.scopes,
13234
14128
  homeAccountIdentifier: account.homeAccountId,
13235
14129
  claims: request.claims,
@@ -13242,21 +14136,35 @@
13242
14136
  silentRequestKey = JSON.stringify(thumbprint);
13243
14137
  cachedResponse = this.activeSilentTokenRequests.get(silentRequestKey);
13244
14138
  if (typeof cachedResponse === "undefined") {
13245
- this.logger.verbose("acquireTokenSilent called for the first time, storing active request", request.correlationId);
13246
- 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)
13247
14141
  .then(function (result) {
13248
14142
  _this.activeSilentTokenRequests.delete(silentRequestKey);
14143
+ atsMeasurement.endMeasurement({
14144
+ success: true,
14145
+ fromCache: result.fromCache
14146
+ });
14147
+ atsMeasurement.flushMeasurement();
13249
14148
  return result;
13250
14149
  })
13251
14150
  .catch(function (error) {
13252
14151
  _this.activeSilentTokenRequests.delete(silentRequestKey);
14152
+ atsMeasurement.endMeasurement({
14153
+ success: false
14154
+ });
14155
+ atsMeasurement.flushMeasurement();
13253
14156
  throw error;
13254
14157
  });
13255
14158
  this.activeSilentTokenRequests.set(silentRequestKey, response);
13256
14159
  return [2 /*return*/, response];
13257
14160
  }
13258
14161
  else {
13259
- 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();
13260
14168
  return [2 /*return*/, cachedResponse];
13261
14169
  }
13262
14170
  });
@@ -13270,17 +14178,26 @@
13270
14178
  */
13271
14179
  PublicClientApplication.prototype.acquireTokenSilentAsync = function (request, account) {
13272
14180
  return __awaiter$1(this, void 0, void 0, function () {
13273
- var silentCacheClient, silentRequest;
14181
+ var astsAsyncMeasurement, silentCacheClient, silentRequest;
13274
14182
  var _this = this;
13275
14183
  return __generator$1(this, function (_a) {
13276
14184
  switch (_a.label) {
13277
14185
  case 0:
13278
- 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);
13279
14188
  return [4 /*yield*/, silentCacheClient.initializeSilentRequest(request, account)];
13280
14189
  case 1:
13281
14190
  silentRequest = _a.sent();
13282
14191
  this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_START, exports.InteractionType.Silent, request);
13283
- 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 () {
13284
14201
  var tokenRenewalResult, tokenRenewalError_1;
13285
14202
  return __generator$1(this, function (_a) {
13286
14203
  switch (_a.label) {
@@ -13290,10 +14207,17 @@
13290
14207
  case 1:
13291
14208
  tokenRenewalResult = _a.sent();
13292
14209
  this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_SUCCESS, exports.InteractionType.Silent, tokenRenewalResult);
14210
+ astsAsyncMeasurement.endMeasurement({
14211
+ success: true,
14212
+ fromCache: tokenRenewalResult.fromCache
14213
+ });
13293
14214
  return [2 /*return*/, tokenRenewalResult];
13294
14215
  case 2:
13295
14216
  tokenRenewalError_1 = _a.sent();
13296
14217
  this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_FAILURE, exports.InteractionType.Silent, null, tokenRenewalError_1);
14218
+ astsAsyncMeasurement.endMeasurement({
14219
+ success: false
14220
+ });
13297
14221
  throw tokenRenewalError_1;
13298
14222
  case 3: return [2 /*return*/];
13299
14223
  }
@@ -13362,6 +14286,12 @@
13362
14286
  removeEventCallback: function () {
13363
14287
  return;
13364
14288
  },
14289
+ addPerformanceCallback: function () {
14290
+ return "";
14291
+ },
14292
+ removePerformanceCallback: function () {
14293
+ return false;
14294
+ },
13365
14295
  enableAccountStorageEvents: function () {
13366
14296
  return;
13367
14297
  },
@@ -13525,21 +14455,35 @@
13525
14455
  exports.AuthenticationHeaderParser = AuthenticationHeaderParser;
13526
14456
  exports.BrowserAuthError = BrowserAuthError;
13527
14457
  exports.BrowserAuthErrorMessage = BrowserAuthErrorMessage;
14458
+ exports.BrowserCacheManager = BrowserCacheManager;
13528
14459
  exports.BrowserConfigurationAuthError = BrowserConfigurationAuthError;
13529
14460
  exports.BrowserConfigurationAuthErrorMessage = BrowserConfigurationAuthErrorMessage;
14461
+ exports.BrowserConstants = BrowserConstants;
14462
+ exports.BrowserPerformanceClient = BrowserPerformanceClient;
13530
14463
  exports.BrowserUtils = BrowserUtils;
13531
14464
  exports.ClientAuthError = ClientAuthError;
13532
14465
  exports.ClientAuthErrorMessage = ClientAuthErrorMessage;
13533
14466
  exports.ClientConfigurationError = ClientConfigurationError;
13534
14467
  exports.ClientConfigurationErrorMessage = ClientConfigurationErrorMessage;
14468
+ exports.DEFAULT_IFRAME_TIMEOUT_MS = DEFAULT_IFRAME_TIMEOUT_MS;
14469
+ exports.EventHandler = EventHandler;
13535
14470
  exports.EventMessageUtils = EventMessageUtils;
13536
14471
  exports.InteractionRequiredAuthError = InteractionRequiredAuthError;
13537
14472
  exports.InteractionRequiredAuthErrorMessage = InteractionRequiredAuthErrorMessage;
13538
14473
  exports.Logger = Logger;
13539
14474
  exports.NavigationClient = NavigationClient;
14475
+ exports.OIDC_DEFAULT_SCOPES = OIDC_DEFAULT_SCOPES;
14476
+ exports.PopupClient = PopupClient;
14477
+ exports.PopupUtils = PopupUtils;
13540
14478
  exports.PublicClientApplication = PublicClientApplication;
14479
+ exports.RedirectClient = RedirectClient;
14480
+ exports.RedirectHandler = RedirectHandler;
13541
14481
  exports.ServerError = ServerError;
13542
14482
  exports.SignedHttpRequest = SignedHttpRequest;
14483
+ exports.SilentCacheClient = SilentCacheClient;
14484
+ exports.SilentIframeClient = SilentIframeClient;
14485
+ exports.SilentRefreshClient = SilentRefreshClient;
14486
+ exports.StandardInteractionClient = StandardInteractionClient;
13543
14487
  exports.StringUtils = StringUtils;
13544
14488
  exports.UrlString = UrlString;
13545
14489
  exports.stubbedPublicClientApplication = stubbedPublicClientApplication;