@azure/msal-browser 2.33.0 → 2.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/README.md +1 -1
  2. package/dist/_virtual/_tslib.js +1 -1
  3. package/dist/app/ClientApplication.d.ts.map +1 -1
  4. package/dist/app/ClientApplication.js +15 -18
  5. package/dist/app/ClientApplication.js.map +1 -1
  6. package/dist/app/IPublicClientApplication.js +1 -1
  7. package/dist/app/PublicClientApplication.d.ts.map +1 -1
  8. package/dist/app/PublicClientApplication.js +1 -6
  9. package/dist/app/PublicClientApplication.js.map +1 -1
  10. package/dist/broker/nativeBroker/NativeMessageHandler.d.ts +10 -7
  11. package/dist/broker/nativeBroker/NativeMessageHandler.d.ts.map +1 -1
  12. package/dist/broker/nativeBroker/NativeMessageHandler.js +18 -8
  13. package/dist/broker/nativeBroker/NativeMessageHandler.js.map +1 -1
  14. package/dist/cache/AsyncMemoryStorage.js +1 -1
  15. package/dist/cache/BrowserCacheManager.js +1 -1
  16. package/dist/cache/BrowserStorage.js +1 -1
  17. package/dist/cache/CryptoKeyStore.js +1 -1
  18. package/dist/cache/DatabaseStorage.js +1 -1
  19. package/dist/cache/MemoryStorage.js +1 -1
  20. package/dist/cache/TokenCache.js +1 -1
  21. package/dist/config/Configuration.js +1 -1
  22. package/dist/crypto/BrowserCrypto.js +1 -1
  23. package/dist/crypto/CryptoOps.js +1 -1
  24. package/dist/crypto/GuidGenerator.js +1 -1
  25. package/dist/crypto/ModernBrowserCrypto.js +1 -1
  26. package/dist/crypto/MsBrowserCrypto.js +1 -1
  27. package/dist/crypto/MsrBrowserCrypto.js +1 -1
  28. package/dist/crypto/PkceGenerator.js +1 -1
  29. package/dist/crypto/SignedHttpRequest.js +1 -1
  30. package/dist/encode/Base64Decode.js +1 -1
  31. package/dist/encode/Base64Encode.js +1 -1
  32. package/dist/error/BrowserAuthError.d.ts +8 -0
  33. package/dist/error/BrowserAuthError.d.ts.map +1 -1
  34. package/dist/error/BrowserAuthError.js +11 -1
  35. package/dist/error/BrowserAuthError.js.map +1 -1
  36. package/dist/error/BrowserConfigurationAuthError.js +1 -1
  37. package/dist/error/NativeAuthError.js +1 -1
  38. package/dist/event/EventHandler.js +1 -1
  39. package/dist/event/EventMessage.js +1 -1
  40. package/dist/event/EventType.js +1 -1
  41. package/dist/index.cjs.js +475 -355
  42. package/dist/index.cjs.js.map +1 -1
  43. package/dist/index.js +1 -1
  44. package/dist/interaction_client/BaseInteractionClient.js +1 -1
  45. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.js +1 -1
  46. package/dist/interaction_client/NativeInteractionClient.d.ts +66 -3
  47. package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
  48. package/dist/interaction_client/NativeInteractionClient.js +174 -68
  49. package/dist/interaction_client/NativeInteractionClient.js.map +1 -1
  50. package/dist/interaction_client/PopupClient.js +1 -1
  51. package/dist/interaction_client/RedirectClient.js +1 -1
  52. package/dist/interaction_client/SilentAuthCodeClient.js +1 -1
  53. package/dist/interaction_client/SilentCacheClient.js +1 -1
  54. package/dist/interaction_client/SilentIframeClient.js +1 -1
  55. package/dist/interaction_client/SilentRefreshClient.js +1 -1
  56. package/dist/interaction_client/StandardInteractionClient.js +1 -1
  57. package/dist/interaction_handler/InteractionHandler.js +1 -1
  58. package/dist/interaction_handler/RedirectHandler.js +1 -1
  59. package/dist/interaction_handler/SilentHandler.js +1 -1
  60. package/dist/internals.d.ts +3 -0
  61. package/dist/internals.d.ts.map +1 -1
  62. package/dist/internals.js +2 -1
  63. package/dist/internals.js.map +1 -1
  64. package/dist/navigation/NavigationClient.js +1 -1
  65. package/dist/network/FetchClient.js +1 -1
  66. package/dist/network/XhrClient.js +1 -1
  67. package/dist/packageMetadata.d.ts +1 -1
  68. package/dist/packageMetadata.js +2 -2
  69. package/dist/packageMetadata.js.map +1 -1
  70. package/dist/telemetry/BrowserPerformanceClient.d.ts +5 -3
  71. package/dist/telemetry/BrowserPerformanceClient.d.ts.map +1 -1
  72. package/dist/telemetry/BrowserPerformanceClient.js +37 -16
  73. package/dist/telemetry/BrowserPerformanceClient.js.map +1 -1
  74. package/dist/telemetry/BrowserPerformanceMeasurement.d.ts +14 -5
  75. package/dist/telemetry/BrowserPerformanceMeasurement.d.ts.map +1 -1
  76. package/dist/telemetry/BrowserPerformanceMeasurement.js +36 -4
  77. package/dist/telemetry/BrowserPerformanceMeasurement.js.map +1 -1
  78. package/dist/utils/BrowserConstants.js +1 -1
  79. package/dist/utils/BrowserProtocolUtils.js +1 -1
  80. package/dist/utils/BrowserStringUtils.js +1 -1
  81. package/dist/utils/BrowserUtils.js +1 -1
  82. package/dist/utils/MathUtils.js +1 -1
  83. package/lib/msal-browser.js +475 -355
  84. package/lib/msal-browser.js.map +1 -1
  85. package/lib/msal-browser.min.js +33 -33
  86. package/package.json +2 -2
package/dist/index.cjs.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! @azure/msal-browser v2.33.0 2023-02-06 */
1
+ /*! @azure/msal-browser v2.34.0 2023-03-07 */
2
2
  'use strict';
3
3
  'use strict';
4
4
 
@@ -117,7 +117,7 @@ function __spread() {
117
117
  return ar;
118
118
  }
119
119
 
120
- /*! @azure/msal-common v10.0.0 2023-02-06 */
120
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
121
121
  /*! *****************************************************************************
122
122
  Copyright (c) Microsoft Corporation.
123
123
 
@@ -204,7 +204,7 @@ function __spreadArrays() {
204
204
  return r;
205
205
  }
206
206
 
207
- /*! @azure/msal-common v10.0.0 2023-02-06 */
207
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
208
208
 
209
209
  /*
210
210
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -586,9 +586,10 @@ var JsonTypes;
586
586
  (function (JsonTypes) {
587
587
  JsonTypes["Jwt"] = "JWT";
588
588
  JsonTypes["Jwk"] = "JWK";
589
+ JsonTypes["Pop"] = "pop";
589
590
  })(JsonTypes || (JsonTypes = {}));
590
591
 
591
- /*! @azure/msal-common v10.0.0 2023-02-06 */
592
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
592
593
 
593
594
  /*
594
595
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -644,7 +645,7 @@ var AuthError = /** @class */ (function (_super) {
644
645
  return AuthError;
645
646
  }(Error));
646
647
 
647
- /*! @azure/msal-common v10.0.0 2023-02-06 */
648
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
648
649
 
649
650
  /*
650
651
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -719,7 +720,7 @@ var DEFAULT_CRYPTO_IMPLEMENTATION = {
719
720
  }
720
721
  };
721
722
 
722
- /*! @azure/msal-common v10.0.0 2023-02-06 */
723
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
723
724
 
724
725
  /*
725
726
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -923,6 +924,14 @@ var ClientAuthErrorMessage = {
923
924
  keyIdMissing: {
924
925
  code: "key_id_missing",
925
926
  desc: "A keyId value is missing from the requested bound token's cache record and is required to match the token to it's stored binding key."
927
+ },
928
+ noNetworkConnectivity: {
929
+ code: "no_network_connectivity",
930
+ desc: "No network connectivity. Check your internet connection."
931
+ },
932
+ userCanceledError: {
933
+ code: "user_canceled",
934
+ desc: "User canceled the flow."
926
935
  }
927
936
  };
928
937
  /**
@@ -1211,10 +1220,22 @@ var ClientAuthError = /** @class */ (function (_super) {
1211
1220
  ClientAuthError.createKeyIdMissingError = function () {
1212
1221
  return new ClientAuthError(ClientAuthErrorMessage.keyIdMissing.code, ClientAuthErrorMessage.keyIdMissing.desc);
1213
1222
  };
1223
+ /**
1224
+ * Create an error when the client does not have network connectivity
1225
+ */
1226
+ ClientAuthError.createNoNetworkConnectivityError = function () {
1227
+ return new ClientAuthError(ClientAuthErrorMessage.noNetworkConnectivity.code, ClientAuthErrorMessage.noNetworkConnectivity.desc);
1228
+ };
1229
+ /**
1230
+ * Create an error when the user cancels the flow
1231
+ */
1232
+ ClientAuthError.createUserCanceledError = function () {
1233
+ return new ClientAuthError(ClientAuthErrorMessage.userCanceledError.code, ClientAuthErrorMessage.userCanceledError.desc);
1234
+ };
1214
1235
  return ClientAuthError;
1215
1236
  }(AuthError));
1216
1237
 
1217
- /*! @azure/msal-common v10.0.0 2023-02-06 */
1238
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
1218
1239
 
1219
1240
  /*
1220
1241
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1339,7 +1360,7 @@ var StringUtils = /** @class */ (function () {
1339
1360
  return StringUtils;
1340
1361
  }());
1341
1362
 
1342
- /*! @azure/msal-common v10.0.0 2023-02-06 */
1363
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
1343
1364
 
1344
1365
  /*
1345
1366
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1529,12 +1550,12 @@ var Logger = /** @class */ (function () {
1529
1550
  return Logger;
1530
1551
  }());
1531
1552
 
1532
- /*! @azure/msal-common v10.0.0 2023-02-06 */
1553
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
1533
1554
  /* eslint-disable header/header */
1534
1555
  var name$1 = "@azure/msal-common";
1535
- var version$1 = "10.0.0";
1556
+ var version$1 = "11.0.0";
1536
1557
 
1537
- /*! @azure/msal-common v10.0.0 2023-02-06 */
1558
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
1538
1559
  /*
1539
1560
  * Copyright (c) Microsoft Corporation. All rights reserved.
1540
1561
  * Licensed under the MIT License.
@@ -1555,7 +1576,7 @@ exports.AzureCloudInstance = void 0;
1555
1576
  AzureCloudInstance["AzureUsGovernment"] = "https://login.microsoftonline.us";
1556
1577
  })(exports.AzureCloudInstance || (exports.AzureCloudInstance = {}));
1557
1578
 
1558
- /*! @azure/msal-common v10.0.0 2023-02-06 */
1579
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
1559
1580
 
1560
1581
  /*
1561
1582
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1723,13 +1744,16 @@ var CredentialEntity = /** @class */ (function () {
1723
1744
  */
1724
1745
  return (tokenType && tokenType.toLowerCase() !== exports.AuthenticationScheme.BEARER.toLowerCase()) ? tokenType.toLowerCase() : Constants.EMPTY_STRING;
1725
1746
  };
1726
- // Match host names like "login.microsoftonline.com", "https://accounts.google.com:4000", https://localhost:5000, etc.
1727
- CredentialEntity.credentialDomainRegex = "(https?:\\/\\/)?((([\\w-]+\\.)*([\\w-]{1,63})(\\.(\\w{2,63})))|(localhost))(\\:[0-9]{4,5})?";
1747
+ /*
1748
+ * Match host names like "login.microsoftonline.com", "https://accounts.google.com:4000", https://localhost:5000,
1749
+ * "login.microsoftonline.com/common", "login.microsoftonline.com:4000/common", etc
1750
+ */
1751
+ CredentialEntity.credentialDomainRegex = "(https?:\\/\\/)?((([\\w-]+\\.)*([\\w-]{1,63})(\\.(\\w{2,63})))|(localhost))(\\:[0-9]{4,5})?(\\/[\\w-]+)?";
1728
1752
  return CredentialEntity;
1729
1753
  }());
1730
1754
  CredentialEntity._initRegex();
1731
1755
 
1732
- /*! @azure/msal-common v10.0.0 2023-02-06 */
1756
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
1733
1757
 
1734
1758
  /*
1735
1759
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1984,7 +2008,7 @@ var ClientConfigurationError = /** @class */ (function (_super) {
1984
2008
  return ClientConfigurationError;
1985
2009
  }(ClientAuthError));
1986
2010
 
1987
- /*! @azure/msal-common v10.0.0 2023-02-06 */
2011
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
1988
2012
 
1989
2013
  /*
1990
2014
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2168,7 +2192,7 @@ var ScopeSet = /** @class */ (function () {
2168
2192
  return ScopeSet;
2169
2193
  }());
2170
2194
 
2171
- /*! @azure/msal-common v10.0.0 2023-02-06 */
2195
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
2172
2196
 
2173
2197
  /*
2174
2198
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2206,7 +2230,7 @@ function buildClientInfoFromHomeAccountId(homeAccountId) {
2206
2230
  };
2207
2231
  }
2208
2232
 
2209
- /*! @azure/msal-common v10.0.0 2023-02-06 */
2233
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
2210
2234
  /*
2211
2235
  * Copyright (c) Microsoft Corporation. All rights reserved.
2212
2236
  * Licensed under the MIT License.
@@ -2221,7 +2245,7 @@ var AuthorityType;
2221
2245
  AuthorityType[AuthorityType["Dsts"] = 2] = "Dsts";
2222
2246
  })(AuthorityType || (AuthorityType = {}));
2223
2247
 
2224
- /*! @azure/msal-common v10.0.0 2023-02-06 */
2248
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
2225
2249
 
2226
2250
  /*
2227
2251
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2460,7 +2484,7 @@ var AccountEntity = /** @class */ (function () {
2460
2484
  return AccountEntity;
2461
2485
  }());
2462
2486
 
2463
- /*! @azure/msal-common v10.0.0 2023-02-06 */
2487
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
2464
2488
 
2465
2489
  /*
2466
2490
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2512,7 +2536,7 @@ var AuthToken = /** @class */ (function () {
2512
2536
  return AuthToken;
2513
2537
  }());
2514
2538
 
2515
- /*! @azure/msal-common v10.0.0 2023-02-06 */
2539
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
2516
2540
 
2517
2541
  /*
2518
2542
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3015,7 +3039,7 @@ var CacheManager = /** @class */ (function () {
3015
3039
  else if (accounts.length > 1) {
3016
3040
  throw ClientAuthError.createMultipleMatchingAccountsInCacheError();
3017
3041
  }
3018
- return accountCache[0];
3042
+ return accounts[0];
3019
3043
  };
3020
3044
  /**
3021
3045
  * Retrieve IdTokenEntity from cache
@@ -3391,7 +3415,7 @@ var DefaultStorageClass = /** @class */ (function (_super) {
3391
3415
  return DefaultStorageClass;
3392
3416
  }(CacheManager));
3393
3417
 
3394
- /*! @azure/msal-common v10.0.0 2023-02-06 */
3418
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
3395
3419
 
3396
3420
  /*
3397
3421
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3484,7 +3508,7 @@ function buildAuthOptions(authOptions) {
3484
3508
  return __assign({ clientCapabilities: [], azureCloudOptions: DEFAULT_AZURE_CLOUD_OPTIONS, skipAuthorityMetadataCache: false }, authOptions);
3485
3509
  }
3486
3510
 
3487
- /*! @azure/msal-common v10.0.0 2023-02-06 */
3511
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
3488
3512
 
3489
3513
  /*
3490
3514
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3504,7 +3528,7 @@ var ServerError = /** @class */ (function (_super) {
3504
3528
  return ServerError;
3505
3529
  }(AuthError));
3506
3530
 
3507
- /*! @azure/msal-common v10.0.0 2023-02-06 */
3531
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
3508
3532
 
3509
3533
  /*
3510
3534
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3600,7 +3624,7 @@ var ThrottlingUtils = /** @class */ (function () {
3600
3624
  return ThrottlingUtils;
3601
3625
  }());
3602
3626
 
3603
- /*! @azure/msal-common v10.0.0 2023-02-06 */
3627
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
3604
3628
 
3605
3629
  /*
3606
3630
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3649,7 +3673,7 @@ var NetworkManager = /** @class */ (function () {
3649
3673
  return NetworkManager;
3650
3674
  }());
3651
3675
 
3652
- /*! @azure/msal-common v10.0.0 2023-02-06 */
3676
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
3653
3677
  /*
3654
3678
  * Copyright (c) Microsoft Corporation. All rights reserved.
3655
3679
  * Licensed under the MIT License.
@@ -3660,7 +3684,7 @@ var CcsCredentialType;
3660
3684
  CcsCredentialType["UPN"] = "UPN";
3661
3685
  })(CcsCredentialType || (CcsCredentialType = {}));
3662
3686
 
3663
- /*! @azure/msal-common v10.0.0 2023-02-06 */
3687
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
3664
3688
 
3665
3689
  /*
3666
3690
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3751,7 +3775,7 @@ var RequestValidator = /** @class */ (function () {
3751
3775
  return RequestValidator;
3752
3776
  }());
3753
3777
 
3754
- /*! @azure/msal-common v10.0.0 2023-02-06 */
3778
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
3755
3779
 
3756
3780
  /*
3757
3781
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4129,7 +4153,7 @@ var RequestParameterBuilder = /** @class */ (function () {
4129
4153
  return RequestParameterBuilder;
4130
4154
  }());
4131
4155
 
4132
- /*! @azure/msal-common v10.0.0 2023-02-06 */
4156
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
4133
4157
 
4134
4158
  /*
4135
4159
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4231,7 +4255,7 @@ var BaseClient = /** @class */ (function () {
4231
4255
  return BaseClient;
4232
4256
  }());
4233
4257
 
4234
- /*! @azure/msal-common v10.0.0 2023-02-06 */
4258
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
4235
4259
 
4236
4260
  /*
4237
4261
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4295,7 +4319,7 @@ var IdTokenEntity = /** @class */ (function (_super) {
4295
4319
  return IdTokenEntity;
4296
4320
  }(CredentialEntity));
4297
4321
 
4298
- /*! @azure/msal-common v10.0.0 2023-02-06 */
4322
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
4299
4323
  /*
4300
4324
  * Copyright (c) Microsoft Corporation. All rights reserved.
4301
4325
  * Licensed under the MIT License.
@@ -4345,7 +4369,7 @@ var TimeUtils = /** @class */ (function () {
4345
4369
  return TimeUtils;
4346
4370
  }());
4347
4371
 
4348
- /*! @azure/msal-common v10.0.0 2023-02-06 */
4372
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
4349
4373
 
4350
4374
  /*
4351
4375
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4459,7 +4483,7 @@ var AccessTokenEntity = /** @class */ (function (_super) {
4459
4483
  return AccessTokenEntity;
4460
4484
  }(CredentialEntity));
4461
4485
 
4462
- /*! @azure/msal-common v10.0.0 2023-02-06 */
4486
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
4463
4487
 
4464
4488
  /*
4465
4489
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4526,7 +4550,7 @@ var RefreshTokenEntity = /** @class */ (function (_super) {
4526
4550
  return RefreshTokenEntity;
4527
4551
  }(CredentialEntity));
4528
4552
 
4529
- /*! @azure/msal-common v10.0.0 2023-02-06 */
4553
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
4530
4554
 
4531
4555
  /*
4532
4556
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4605,7 +4629,7 @@ var InteractionRequiredAuthError = /** @class */ (function (_super) {
4605
4629
  return InteractionRequiredAuthError;
4606
4630
  }(AuthError));
4607
4631
 
4608
- /*! @azure/msal-common v10.0.0 2023-02-06 */
4632
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
4609
4633
  /*
4610
4634
  * Copyright (c) Microsoft Corporation. All rights reserved.
4611
4635
  * Licensed under the MIT License.
@@ -4621,7 +4645,7 @@ var CacheRecord = /** @class */ (function () {
4621
4645
  return CacheRecord;
4622
4646
  }());
4623
4647
 
4624
- /*! @azure/msal-common v10.0.0 2023-02-06 */
4648
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
4625
4649
 
4626
4650
  /*
4627
4651
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4692,7 +4716,7 @@ var ProtocolUtils = /** @class */ (function () {
4692
4716
  return ProtocolUtils;
4693
4717
  }());
4694
4718
 
4695
- /*! @azure/msal-common v10.0.0 2023-02-06 */
4719
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
4696
4720
 
4697
4721
  /*
4698
4722
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4926,7 +4950,7 @@ var UrlString = /** @class */ (function () {
4926
4950
  return UrlString;
4927
4951
  }());
4928
4952
 
4929
- /*! @azure/msal-common v10.0.0 2023-02-06 */
4953
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
4930
4954
  /*
4931
4955
  * Copyright (c) Microsoft Corporation. All rights reserved.
4932
4956
  * Licensed under the MIT License.
@@ -5063,6 +5087,7 @@ exports.PerformanceEvents = void 0;
5063
5087
  * Internal API for initializing silent request in SilentCacheClient (msal-browser)
5064
5088
  */
5065
5089
  PerformanceEvents["InitializeSilentRequest"] = "initializeSilentRequest";
5090
+ PerformanceEvents["InitializeClientApplication"] = "initializeClientApplication";
5066
5091
  /**
5067
5092
  * Helper function in SilentIframeClient class (msal-browser).
5068
5093
  */
@@ -5128,6 +5153,7 @@ exports.PerformanceEvents = void 0;
5128
5153
  PerformanceEvents["HandleRedirectPromiseMeasurement"] = "handleRedirectPromiseMeasurement";
5129
5154
  PerformanceEvents["UpdateCloudDiscoveryMetadataMeasurement"] = "updateCloudDiscoveryMetadataMeasurement";
5130
5155
  PerformanceEvents["UsernamePasswordClientAcquireToken"] = "usernamePasswordClientAcquireToken";
5156
+ PerformanceEvents["NativeMessageHandlerHandshake"] = "nativeMessageHandlerHandshake";
5131
5157
  })(exports.PerformanceEvents || (exports.PerformanceEvents = {}));
5132
5158
  /**
5133
5159
  * State of the performance event.
@@ -5153,7 +5179,7 @@ var IntFields = new Set([
5153
5179
  "status",
5154
5180
  ]);
5155
5181
 
5156
- /*! @azure/msal-common v10.0.0 2023-02-06 */
5182
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
5157
5183
 
5158
5184
  /*
5159
5185
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5262,7 +5288,7 @@ var PopTokenGenerator = /** @class */ (function () {
5262
5288
  return PopTokenGenerator;
5263
5289
  }());
5264
5290
 
5265
- /*! @azure/msal-common v10.0.0 2023-02-06 */
5291
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
5266
5292
 
5267
5293
  /*
5268
5294
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5332,7 +5358,7 @@ var AppMetadataEntity = /** @class */ (function () {
5332
5358
  return AppMetadataEntity;
5333
5359
  }());
5334
5360
 
5335
- /*! @azure/msal-common v10.0.0 2023-02-06 */
5361
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
5336
5362
  /*
5337
5363
  * Copyright (c) Microsoft Corporation. All rights reserved.
5338
5364
  * Licensed under the MIT License.
@@ -5368,7 +5394,7 @@ var AppMetadataEntity = /** @class */ (function () {
5368
5394
  return TokenCacheContext;
5369
5395
  }());
5370
5396
 
5371
- /*! @azure/msal-common v10.0.0 2023-02-06 */
5397
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
5372
5398
 
5373
5399
  /*
5374
5400
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5500,7 +5526,7 @@ var ResponseHandler = /** @class */ (function () {
5500
5526
  _b.sent();
5501
5527
  _b.label = 7;
5502
5528
  case 7: return [7 /*endfinally*/];
5503
- case 8: return [2 /*return*/, ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenObj, requestStateObj, serverTokenResponse.spa_code, serverRequestId)];
5529
+ case 8: return [2 /*return*/, ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenObj, requestStateObj, serverTokenResponse, serverRequestId)];
5504
5530
  }
5505
5531
  });
5506
5532
  });
@@ -5586,7 +5612,7 @@ var ResponseHandler = /** @class */ (function () {
5586
5612
  * @param fromTokenCache
5587
5613
  * @param stateString
5588
5614
  */
5589
- ResponseHandler.generateAuthenticationResult = function (cryptoObj, authority, cacheRecord, fromTokenCache, request, idTokenObj, requestState, code, requestId) {
5615
+ ResponseHandler.generateAuthenticationResult = function (cryptoObj, authority, cacheRecord, fromTokenCache, request, idTokenObj, requestState, serverTokenResponse, requestId) {
5590
5616
  var _a, _b, _c;
5591
5617
  return __awaiter(this, void 0, void 0, function () {
5592
5618
  var accessToken, responseScopes, expiresOn, extExpiresOn, familyId, popTokenGenerator, _d, secret, keyId, uid, tid;
@@ -5622,6 +5648,10 @@ var ResponseHandler = /** @class */ (function () {
5622
5648
  }
5623
5649
  uid = (idTokenObj === null || idTokenObj === void 0 ? void 0 : idTokenObj.claims.oid) || (idTokenObj === null || idTokenObj === void 0 ? void 0 : idTokenObj.claims.sub) || Constants.EMPTY_STRING;
5624
5650
  tid = (idTokenObj === null || idTokenObj === void 0 ? void 0 : idTokenObj.claims.tid) || Constants.EMPTY_STRING;
5651
+ // for hybrid + native bridge enablement, send back the native account Id
5652
+ if ((serverTokenResponse === null || serverTokenResponse === void 0 ? void 0 : serverTokenResponse.spa_accountid) && !!cacheRecord.account) {
5653
+ cacheRecord.account.nativeAccountId = serverTokenResponse === null || serverTokenResponse === void 0 ? void 0 : serverTokenResponse.spa_accountid;
5654
+ }
5625
5655
  return [2 /*return*/, {
5626
5656
  authority: authority.canonicalAuthority,
5627
5657
  uniqueId: uid,
@@ -5641,7 +5671,7 @@ var ResponseHandler = /** @class */ (function () {
5641
5671
  state: requestState ? requestState.userRequestState : Constants.EMPTY_STRING,
5642
5672
  cloudGraphHostName: ((_b = cacheRecord.account) === null || _b === void 0 ? void 0 : _b.cloudGraphHostName) || Constants.EMPTY_STRING,
5643
5673
  msGraphHost: ((_c = cacheRecord.account) === null || _c === void 0 ? void 0 : _c.msGraphHost) || Constants.EMPTY_STRING,
5644
- code: code,
5674
+ code: serverTokenResponse === null || serverTokenResponse === void 0 ? void 0 : serverTokenResponse.spa_code,
5645
5675
  fromNativeBroker: false,
5646
5676
  }];
5647
5677
  }
@@ -5651,7 +5681,7 @@ var ResponseHandler = /** @class */ (function () {
5651
5681
  return ResponseHandler;
5652
5682
  }());
5653
5683
 
5654
- /*! @azure/msal-common v10.0.0 2023-02-06 */
5684
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
5655
5685
 
5656
5686
  /*
5657
5687
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6129,7 +6159,7 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
6129
6159
  return AuthorizationCodeClient;
6130
6160
  }(BaseClient));
6131
6161
 
6132
- /*! @azure/msal-common v10.0.0 2023-02-06 */
6162
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
6133
6163
 
6134
6164
  /*
6135
6165
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6403,7 +6433,7 @@ var RefreshTokenClient = /** @class */ (function (_super) {
6403
6433
  return RefreshTokenClient;
6404
6434
  }(BaseClient));
6405
6435
 
6406
- /*! @azure/msal-common v10.0.0 2023-02-06 */
6436
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
6407
6437
 
6408
6438
  /*
6409
6439
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6527,7 +6557,7 @@ var SilentFlowClient = /** @class */ (function (_super) {
6527
6557
  return SilentFlowClient;
6528
6558
  }(BaseClient));
6529
6559
 
6530
- /*! @azure/msal-common v10.0.0 2023-02-06 */
6560
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
6531
6561
  /*
6532
6562
  * Copyright (c) Microsoft Corporation. All rights reserved.
6533
6563
  * Licensed under the MIT License.
@@ -6539,7 +6569,7 @@ function isOpenIdConfigResponse(response) {
6539
6569
  response.hasOwnProperty("jwks_uri"));
6540
6570
  }
6541
6571
 
6542
- /*! @azure/msal-common v10.0.0 2023-02-06 */
6572
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
6543
6573
  /*
6544
6574
  * Copyright (c) Microsoft Corporation. All rights reserved.
6545
6575
  * Licensed under the MIT License.
@@ -6548,7 +6578,7 @@ var rawMetdataJSON = { "endpointMetadata": { "https://login.microsoftonline.com/
6548
6578
  var EndpointMetadata = rawMetdataJSON.endpointMetadata;
6549
6579
  var InstanceDiscoveryMetadata = rawMetdataJSON.instanceDiscoveryMetadata;
6550
6580
 
6551
- /*! @azure/msal-common v10.0.0 2023-02-06 */
6581
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
6552
6582
  /*
6553
6583
  * Copyright (c) Microsoft Corporation. All rights reserved.
6554
6584
  * Licensed under the MIT License.
@@ -6562,7 +6592,7 @@ exports.ProtocolMode = void 0;
6562
6592
  ProtocolMode["OIDC"] = "OIDC";
6563
6593
  })(exports.ProtocolMode || (exports.ProtocolMode = {}));
6564
6594
 
6565
- /*! @azure/msal-common v10.0.0 2023-02-06 */
6595
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
6566
6596
 
6567
6597
  /*
6568
6598
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6639,7 +6669,7 @@ var AuthorityMetadataEntity = /** @class */ (function () {
6639
6669
  return AuthorityMetadataEntity;
6640
6670
  }());
6641
6671
 
6642
- /*! @azure/msal-common v10.0.0 2023-02-06 */
6672
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
6643
6673
  /*
6644
6674
  * Copyright (c) Microsoft Corporation. All rights reserved.
6645
6675
  * Licensed under the MIT License.
@@ -6649,7 +6679,7 @@ function isCloudInstanceDiscoveryResponse(response) {
6649
6679
  response.hasOwnProperty("metadata"));
6650
6680
  }
6651
6681
 
6652
- /*! @azure/msal-common v10.0.0 2023-02-06 */
6682
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
6653
6683
  /*
6654
6684
  * Copyright (c) Microsoft Corporation. All rights reserved.
6655
6685
  * Licensed under the MIT License.
@@ -6659,7 +6689,7 @@ function isCloudInstanceDiscoveryErrorResponse(response) {
6659
6689
  response.hasOwnProperty("error_description"));
6660
6690
  }
6661
6691
 
6662
- /*! @azure/msal-common v10.0.0 2023-02-06 */
6692
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
6663
6693
 
6664
6694
  /*
6665
6695
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6791,7 +6821,7 @@ var RegionDiscovery = /** @class */ (function () {
6791
6821
  return RegionDiscovery;
6792
6822
  }());
6793
6823
 
6794
- /*! @azure/msal-common v10.0.0 2023-02-06 */
6824
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
6795
6825
 
6796
6826
  /*
6797
6827
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7526,7 +7556,7 @@ var Authority = /** @class */ (function () {
7526
7556
  return Authority;
7527
7557
  }());
7528
7558
 
7529
- /*! @azure/msal-common v10.0.0 2023-02-06 */
7559
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
7530
7560
 
7531
7561
  /*
7532
7562
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7589,7 +7619,7 @@ var AuthorityFactory = /** @class */ (function () {
7589
7619
  return AuthorityFactory;
7590
7620
  }());
7591
7621
 
7592
- /*! @azure/msal-common v10.0.0 2023-02-06 */
7622
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
7593
7623
 
7594
7624
  /*
7595
7625
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7620,7 +7650,7 @@ var ServerTelemetryEntity = /** @class */ (function () {
7620
7650
  return ServerTelemetryEntity;
7621
7651
  }());
7622
7652
 
7623
- /*! @azure/msal-common v10.0.0 2023-02-06 */
7653
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
7624
7654
 
7625
7655
  /*
7626
7656
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7648,7 +7678,7 @@ var ThrottlingEntity = /** @class */ (function () {
7648
7678
  return ThrottlingEntity;
7649
7679
  }());
7650
7680
 
7651
- /*! @azure/msal-common v10.0.0 2023-02-06 */
7681
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
7652
7682
 
7653
7683
  /*
7654
7684
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7665,7 +7695,7 @@ var StubbedNetworkModule = {
7665
7695
  }
7666
7696
  };
7667
7697
 
7668
- /*! @azure/msal-common v10.0.0 2023-02-06 */
7698
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
7669
7699
 
7670
7700
  /*
7671
7701
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7710,7 +7740,7 @@ var JoseHeaderError = /** @class */ (function (_super) {
7710
7740
  return JoseHeaderError;
7711
7741
  }(AuthError));
7712
7742
 
7713
- /*! @azure/msal-common v10.0.0 2023-02-06 */
7743
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
7714
7744
 
7715
7745
  /*
7716
7746
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7740,8 +7770,8 @@ var JoseHeader = /** @class */ (function () {
7740
7770
  throw JoseHeaderError.createMissingAlgError();
7741
7771
  }
7742
7772
  var shrHeader = new JoseHeader({
7743
- // Access Token PoP headers must have type JWT, but the type header can be overriden for special cases
7744
- typ: shrHeaderOptions.typ || JsonTypes.Jwt,
7773
+ // Access Token PoP headers must have type pop, but the type header can be overriden for special cases
7774
+ typ: shrHeaderOptions.typ || JsonTypes.Pop,
7745
7775
  kid: shrHeaderOptions.kid,
7746
7776
  alg: shrHeaderOptions.alg
7747
7777
  });
@@ -7750,7 +7780,7 @@ var JoseHeader = /** @class */ (function () {
7750
7780
  return JoseHeader;
7751
7781
  }());
7752
7782
 
7753
- /*! @azure/msal-common v10.0.0 2023-02-06 */
7783
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
7754
7784
 
7755
7785
  /*
7756
7786
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7809,7 +7839,7 @@ var AuthenticationHeaderParser = /** @class */ (function () {
7809
7839
  return AuthenticationHeaderParser;
7810
7840
  }());
7811
7841
 
7812
- /*! @azure/msal-common v10.0.0 2023-02-06 */
7842
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
7813
7843
 
7814
7844
  /*
7815
7845
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7971,7 +8001,7 @@ var ServerTelemetryManager = /** @class */ (function () {
7971
8001
  return ServerTelemetryManager;
7972
8002
  }());
7973
8003
 
7974
- /*! @azure/msal-common v10.0.0 2023-02-06 */
8004
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
7975
8005
 
7976
8006
  /*
7977
8007
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7998,11 +8028,8 @@ var PerformanceClient = /** @class */ (function () {
7998
8028
  this.logger = logger;
7999
8029
  this.callbacks = new Map();
8000
8030
  this.eventsByCorrelationId = new Map();
8001
- this.staticFieldsByCorrelationId = new Map();
8002
- this.measurementsById = new Map();
8003
8031
  this.queueMeasurements = new Map();
8004
8032
  this.preQueueTimeByCorrelationId = new Map();
8005
- this.countersByCorrelationId = new Map();
8006
8033
  }
8007
8034
  /**
8008
8035
  * Starts and returns an platform-specific implementation of IPerformanceMeasurement.
@@ -8043,16 +8070,16 @@ var PerformanceClient = /** @class */ (function () {
8043
8070
  * @returns {number}
8044
8071
  */
8045
8072
  PerformanceClient.prototype.getPreQueueTime = function (eventName, correlationId) {
8046
- var preQueueTimesByEvents = this.preQueueTimeByCorrelationId.get(correlationId);
8047
- if (!preQueueTimesByEvents) {
8073
+ var preQueueEvent = this.preQueueTimeByCorrelationId.get(correlationId);
8074
+ if (!preQueueEvent) {
8048
8075
  this.logger.trace("PerformanceClient.getPreQueueTime: no pre-queue times found for correlationId: " + correlationId + ", unable to add queue measurement");
8049
8076
  return;
8050
8077
  }
8051
- else if (!preQueueTimesByEvents.get(eventName)) {
8078
+ else if (preQueueEvent.name !== eventName) {
8052
8079
  this.logger.trace("PerformanceClient.getPreQueueTime: no pre-queue time found for " + eventName + ", unable to add queue measurement");
8053
8080
  return;
8054
8081
  }
8055
- return preQueueTimesByEvents.get(eventName);
8082
+ return preQueueEvent.time;
8056
8083
  };
8057
8084
  /**
8058
8085
  * Calculates the difference between current time and time when function was queued.
@@ -8080,12 +8107,13 @@ var PerformanceClient = /** @class */ (function () {
8080
8107
  /**
8081
8108
  * Adds queue measurement time to QueueMeasurements array for given correlation ID.
8082
8109
  *
8083
- * @param {PerformanceEvents} name
8110
+ * @param {PerformanceEvents} eventName
8084
8111
  * @param {?string} correlationId
8085
- * @param {?number} time
8112
+ * @param {?number} queueTime
8113
+ * @param {?boolean} manuallyCompleted - indicator for manually completed queue measurements
8086
8114
  * @returns
8087
8115
  */
8088
- PerformanceClient.prototype.addQueueMeasurement = function (eventName, correlationId, queueTime) {
8116
+ PerformanceClient.prototype.addQueueMeasurement = function (eventName, correlationId, queueTime, manuallyCompleted) {
8089
8117
  if (!correlationId) {
8090
8118
  this.logger.trace("PerformanceClient.addQueueMeasurement: correlationId not provided for " + eventName + ", cannot add queue measurement");
8091
8119
  return;
@@ -8098,7 +8126,7 @@ var PerformanceClient = /** @class */ (function () {
8098
8126
  this.logger.trace("PerformanceClient.addQueueMeasurement: no queue time provided for " + eventName);
8099
8127
  return;
8100
8128
  }
8101
- var queueMeasurement = { eventName: eventName, queueTime: queueTime };
8129
+ var queueMeasurement = { eventName: eventName, queueTime: queueTime, manuallyCompleted: manuallyCompleted };
8102
8130
  // Adds to existing correlation Id if present in queueMeasurements
8103
8131
  var existingMeasurements = this.queueMeasurements.get(correlationId);
8104
8132
  if (existingMeasurements) {
@@ -8111,6 +8139,8 @@ var PerformanceClient = /** @class */ (function () {
8111
8139
  var measurementArray = [queueMeasurement];
8112
8140
  this.queueMeasurements.set(correlationId, measurementArray);
8113
8141
  }
8142
+ // Delete processed pre-queue event.
8143
+ this.preQueueTimeByCorrelationId.delete(correlationId);
8114
8144
  };
8115
8145
  /**
8116
8146
  * Starts measuring performance for a given operation. Returns a function that should be used to end the measurement.
@@ -8129,17 +8159,8 @@ var PerformanceClient = /** @class */ (function () {
8129
8159
  }
8130
8160
  // Duplicate code to address spelling error will be removed at the next major version bump.
8131
8161
  this.logger.trace("PerformanceClient: Performance measurement started for " + measureName, eventCorrelationId);
8132
- var validMeasurement;
8133
- var performanceMeasuremeant = this.startPerformanceMeasuremeant(measureName, eventCorrelationId);
8134
- if (performanceMeasuremeant.startMeasurement) {
8135
- performanceMeasuremeant.startMeasurement();
8136
- validMeasurement = performanceMeasuremeant;
8137
- }
8138
- else {
8139
- var performanceMeasurement = this.startPerformanceMeasurement(measureName, eventCorrelationId);
8140
- performanceMeasurement.startMeasurement();
8141
- validMeasurement = performanceMeasurement;
8142
- }
8162
+ var performanceMeasurement = this.startPerformanceMeasuremeant(measureName, eventCorrelationId);
8163
+ performanceMeasurement.startMeasurement();
8143
8164
  var inProgressEvent = {
8144
8165
  eventId: this.generateId(),
8145
8166
  status: PerformanceEventStatus.InProgress,
@@ -8150,27 +8171,15 @@ var PerformanceClient = /** @class */ (function () {
8150
8171
  name: measureName,
8151
8172
  startTimeMs: Date.now(),
8152
8173
  correlationId: eventCorrelationId,
8153
- };
8154
- // Store in progress events so they can be discarded if not ended properly
8155
- this.cacheEventByCorrelationId(inProgressEvent);
8156
- var staticFields = {
8157
8174
  appName: (_a = this.applicationTelemetry) === null || _a === void 0 ? void 0 : _a.appName,
8158
8175
  appVersion: (_b = this.applicationTelemetry) === null || _b === void 0 ? void 0 : _b.appVersion,
8159
8176
  };
8160
- this.addStaticFields(staticFields, eventCorrelationId);
8161
- this.cacheMeasurement(inProgressEvent, validMeasurement);
8177
+ // Store in progress events so they can be discarded if not ended properly
8178
+ this.cacheEventByCorrelationId(inProgressEvent);
8162
8179
  // Return the event and functions the caller can use to properly end/flush the measurement
8163
8180
  return {
8164
8181
  endMeasurement: function (event) {
8165
- var completedEvent = _this.endMeasurement(__assign(__assign({}, inProgressEvent), event));
8166
- if (completedEvent) {
8167
- // Cache event so that submeasurements can be added downstream
8168
- _this.cacheEventByCorrelationId(completedEvent);
8169
- }
8170
- return completedEvent;
8171
- },
8172
- flushMeasurement: function () {
8173
- return _this.flushMeasurements(inProgressEvent.name, inProgressEvent.correlationId);
8182
+ return _this.endMeasurement(__assign(__assign({}, inProgressEvent), event), performanceMeasurement);
8174
8183
  },
8175
8184
  discardMeasurement: function () {
8176
8185
  return _this.discardMeasurements(inProgressEvent.correlationId);
@@ -8181,40 +8190,66 @@ var PerformanceClient = /** @class */ (function () {
8181
8190
  increment: function (counters) {
8182
8191
  return _this.increment(counters, inProgressEvent.correlationId);
8183
8192
  },
8184
- measurement: validMeasurement,
8193
+ measurement: performanceMeasurement,
8185
8194
  event: inProgressEvent
8186
8195
  };
8187
8196
  };
8188
8197
  /**
8189
8198
  * Stops measuring the performance for an operation. Should only be called directly by PerformanceClient classes,
8190
8199
  * as consumers should instead use the function returned by startMeasurement.
8200
+ * Adds a new field named as "[event name]DurationMs" for sub-measurements, completes and emits an event
8201
+ * otherwise.
8191
8202
  *
8192
8203
  * @param {PerformanceEvent} event
8204
+ * @param {IPerformanceMeasurement} measurement
8193
8205
  * @returns {(PerformanceEvent | null)}
8194
8206
  */
8195
- PerformanceClient.prototype.endMeasurement = function (event) {
8196
- var performanceMeasurement = this.measurementsById.get(event.eventId);
8197
- if (performanceMeasurement) {
8198
- // Immediately delete so that the same event isnt ended twice
8199
- this.measurementsById.delete(event.eventId);
8200
- performanceMeasurement.endMeasurement();
8201
- var durationMs = performanceMeasurement.flushMeasurement();
8202
- // null indicates no measurement was taken (e.g. needed performance APIs not present)
8203
- if (durationMs !== null) {
8204
- this.logger.trace("PerformanceClient: Performance measurement ended for " + event.name + ": " + durationMs + " ms", event.correlationId);
8205
- var completedEvent = __assign(__assign({
8206
- // Allow duration to be overwritten when event ends (e.g. testing), but not status
8207
- durationMs: Math.round(durationMs) }, event), { status: PerformanceEventStatus.Completed });
8208
- return completedEvent;
8209
- }
8210
- else {
8211
- this.logger.trace("PerformanceClient: Performance measurement not taken", event.correlationId);
8212
- }
8207
+ PerformanceClient.prototype.endMeasurement = function (event, measurement) {
8208
+ var _this = this;
8209
+ var _a, _b;
8210
+ var rootEvent = this.eventsByCorrelationId.get(event.correlationId);
8211
+ if (!rootEvent) {
8212
+ this.logger.trace("PerformanceClient: Measurement not found for " + event.eventId, event.correlationId);
8213
+ return null;
8214
+ }
8215
+ var isRoot = event.eventId === rootEvent.eventId;
8216
+ var queueInfo = {
8217
+ totalQueueTime: 0,
8218
+ totalQueueCount: 0,
8219
+ manuallyCompletedCount: 0
8220
+ };
8221
+ if (isRoot) {
8222
+ queueInfo = this.getQueueInfo(event.correlationId);
8223
+ this.discardCache(rootEvent.correlationId);
8213
8224
  }
8214
8225
  else {
8215
- this.logger.trace("PerformanceClient: Measurement not found for " + event.eventId, event.correlationId);
8226
+ (_a = rootEvent.incompleteSubMeasurements) === null || _a === void 0 ? void 0 : _a.delete(event.eventId);
8216
8227
  }
8217
- return null;
8228
+ measurement === null || measurement === void 0 ? void 0 : measurement.endMeasurement();
8229
+ var durationMs = measurement === null || measurement === void 0 ? void 0 : measurement.flushMeasurement();
8230
+ // null indicates no measurement was taken (e.g. needed performance APIs not present)
8231
+ if (!durationMs) {
8232
+ this.logger.trace("PerformanceClient: Performance measurement not taken", rootEvent.correlationId);
8233
+ return null;
8234
+ }
8235
+ this.logger.trace("PerformanceClient: Performance measurement ended for " + event.name + ": " + durationMs + " ms", event.correlationId);
8236
+ // Add sub-measurement attribute to root event.
8237
+ if (!isRoot) {
8238
+ rootEvent[event.name + "DurationMs"] = Math.floor(durationMs);
8239
+ return __assign({}, rootEvent);
8240
+ }
8241
+ var finalEvent = __assign(__assign({}, rootEvent), event);
8242
+ var incompleteSubsCount = 0;
8243
+ // Incomplete sub-measurements are discarded. They are likely an instrumentation bug that should be fixed.
8244
+ (_b = finalEvent.incompleteSubMeasurements) === null || _b === void 0 ? void 0 : _b.forEach(function (subMeasurement) {
8245
+ _this.logger.trace("PerformanceClient: Incomplete submeasurement " + subMeasurement.name + " found for " + event.name, finalEvent.correlationId);
8246
+ incompleteSubsCount++;
8247
+ });
8248
+ finalEvent.incompleteSubMeasurements = undefined;
8249
+ finalEvent = __assign(__assign({}, finalEvent), { durationMs: Math.round(durationMs), queuedTimeMs: queueInfo.totalQueueTime, queuedCount: queueInfo.totalQueueCount, queuedManuallyCompletedCount: queueInfo.manuallyCompletedCount, status: PerformanceEventStatus.Completed, incompleteSubsCount: incompleteSubsCount });
8250
+ this.truncateIntegralFields(finalEvent, this.getIntFields());
8251
+ this.emitEvents([finalEvent], event.correlationId);
8252
+ return finalEvent;
8218
8253
  };
8219
8254
  /**
8220
8255
  * Saves extra information to be emitted when the measurements are flushed
@@ -8222,14 +8257,13 @@ var PerformanceClient = /** @class */ (function () {
8222
8257
  * @param correlationId
8223
8258
  */
8224
8259
  PerformanceClient.prototype.addStaticFields = function (fields, correlationId) {
8225
- var existingStaticFields = this.staticFieldsByCorrelationId.get(correlationId);
8226
- if (existingStaticFields) {
8227
- this.logger.trace("PerformanceClient: Updating static fields");
8228
- this.staticFieldsByCorrelationId.set(correlationId, __assign(__assign({}, existingStaticFields), fields));
8260
+ this.logger.trace("PerformanceClient: Updating static fields");
8261
+ var event = this.eventsByCorrelationId.get(correlationId);
8262
+ if (event) {
8263
+ this.eventsByCorrelationId.set(correlationId, __assign(__assign({}, event), fields));
8229
8264
  }
8230
8265
  else {
8231
- this.logger.trace("PerformanceClient: Adding static fields");
8232
- this.staticFieldsByCorrelationId.set(correlationId, fields);
8266
+ this.logger.trace("PerformanceClient: Event not found for", correlationId);
8233
8267
  }
8234
8268
  };
8235
8269
  /**
@@ -8238,18 +8272,18 @@ var PerformanceClient = /** @class */ (function () {
8238
8272
  * @param correlationId {string} correlation identifier
8239
8273
  */
8240
8274
  PerformanceClient.prototype.increment = function (counters, correlationId) {
8241
- var existing = this.countersByCorrelationId.get(correlationId);
8242
- if (!existing) {
8243
- this.logger.trace("PerformanceClient: Setting counters");
8244
- this.countersByCorrelationId.set(correlationId, __assign({}, counters));
8245
- return;
8246
- }
8247
8275
  this.logger.trace("PerformanceClient: Updating counters");
8248
- for (var counter in counters) {
8249
- if (!existing.hasOwnProperty(counter)) {
8250
- existing[counter] = 0;
8276
+ var event = this.eventsByCorrelationId.get(correlationId);
8277
+ if (event) {
8278
+ for (var counter in counters) {
8279
+ if (!event.hasOwnProperty(counter)) {
8280
+ event[counter] = 0;
8281
+ }
8282
+ event[counter] += counters[counter];
8251
8283
  }
8252
- existing[counter] += counters[counter];
8284
+ }
8285
+ else {
8286
+ this.logger.trace("PerformanceClient: Event not found for", correlationId);
8253
8287
  }
8254
8288
  };
8255
8289
  /**
@@ -8262,117 +8296,35 @@ var PerformanceClient = /** @class */ (function () {
8262
8296
  * @param {PerformanceEvent} event
8263
8297
  */
8264
8298
  PerformanceClient.prototype.cacheEventByCorrelationId = function (event) {
8265
- var existingEvents = this.eventsByCorrelationId.get(event.correlationId);
8266
- if (existingEvents) {
8299
+ var rootEvent = this.eventsByCorrelationId.get(event.correlationId);
8300
+ if (rootEvent) {
8267
8301
  this.logger.trace("PerformanceClient: Performance measurement for " + event.name + " added/updated", event.correlationId);
8268
- existingEvents.set(event.eventId, event);
8302
+ rootEvent.incompleteSubMeasurements = rootEvent.incompleteSubMeasurements || new Map();
8303
+ rootEvent.incompleteSubMeasurements.set(event.eventId, { name: event.name, startTimeMs: event.startTimeMs });
8269
8304
  }
8270
8305
  else {
8271
8306
  this.logger.trace("PerformanceClient: Performance measurement for " + event.name + " started", event.correlationId);
8272
- this.eventsByCorrelationId.set(event.correlationId, new Map().set(event.eventId, event));
8307
+ this.eventsByCorrelationId.set(event.correlationId, __assign({}, event));
8273
8308
  }
8274
8309
  };
8275
- /**
8276
- * Cache measurements by their id.
8277
- *
8278
- * @private
8279
- * @param {PerformanceEvent} event
8280
- * @param {IPerformanceMeasurement} measurement
8281
- */
8282
- PerformanceClient.prototype.cacheMeasurement = function (event, measurement) {
8283
- this.measurementsById.set(event.eventId, measurement);
8284
- };
8285
- /**
8286
- * Gathers and emits performance events for measurements taked for the given top-level API and correlation ID.
8287
- *
8288
- * @param {PerformanceEvents} measureName
8289
- * @param {string} correlationId
8290
- */
8291
- PerformanceClient.prototype.flushMeasurements = function (measureName, correlationId) {
8292
- var _this = this;
8293
- this.logger.trace("PerformanceClient: Performance measurements flushed for " + measureName, correlationId);
8294
- /**
8295
- * Adds all queue time and count measurements for given correlation ID
8296
- * then deletes queue times for given correlation ID from queueMeasurements map.
8297
- */
8310
+ PerformanceClient.prototype.getQueueInfo = function (correlationId) {
8298
8311
  var queueMeasurementForCorrelationId = this.queueMeasurements.get(correlationId);
8299
8312
  if (!queueMeasurementForCorrelationId) {
8300
8313
  this.logger.trace("PerformanceClient: no queue measurements found for for correlationId: " + correlationId);
8301
8314
  }
8302
8315
  var totalQueueTime = 0;
8303
8316
  var totalQueueCount = 0;
8317
+ var manuallyCompletedCount = 0;
8304
8318
  queueMeasurementForCorrelationId === null || queueMeasurementForCorrelationId === void 0 ? void 0 : queueMeasurementForCorrelationId.forEach(function (measurement) {
8305
8319
  totalQueueTime += measurement.queueTime;
8306
8320
  totalQueueCount++;
8321
+ manuallyCompletedCount += measurement.manuallyCompleted ? 1 : 0;
8307
8322
  });
8308
- var eventsForCorrelationId = this.eventsByCorrelationId.get(correlationId);
8309
- var staticFields = this.staticFieldsByCorrelationId.get(correlationId);
8310
- var counters = this.countersByCorrelationId.get(correlationId);
8311
- if (eventsForCorrelationId) {
8312
- this.discardCache(correlationId);
8313
- /*
8314
- * Manually end incomplete submeasurements to ensure there arent orphaned/never ending events.
8315
- * Incomplete submeasurements are likely an instrumentation bug that should be fixed.
8316
- * IE only supports Map.forEach.
8317
- */
8318
- var completedEvents_1 = [];
8319
- var incompleteSubsCount_1 = 0;
8320
- eventsForCorrelationId.forEach(function (event) {
8321
- if (event.name !== measureName && event.status !== PerformanceEventStatus.Completed) {
8322
- _this.logger.trace("PerformanceClient: Incomplete submeasurement " + event.name + " found for " + measureName, correlationId);
8323
- incompleteSubsCount_1++;
8324
- var completedEvent = _this.endMeasurement(event);
8325
- if (completedEvent) {
8326
- completedEvents_1.push(completedEvent);
8327
- }
8328
- }
8329
- completedEvents_1.push(event);
8330
- });
8331
- // Sort events by start time (earliest first)
8332
- var sortedCompletedEvents = completedEvents_1.sort(function (eventA, eventB) { return eventA.startTimeMs - eventB.startTimeMs; });
8333
- // Take completed top level event and add completed submeasurements durations as properties
8334
- var topLevelEvents = sortedCompletedEvents.filter(function (event) { return event.name === measureName && event.status === PerformanceEventStatus.Completed; });
8335
- if (topLevelEvents.length > 0) {
8336
- /*
8337
- * Only take the first top-level event if there are multiple events with the same correlation id.
8338
- * This greatly simplifies logic for submeasurements.
8339
- */
8340
- if (topLevelEvents.length > 1) {
8341
- this.logger.verbose("PerformanceClient: Multiple distinct top-level performance events found, using the first", correlationId);
8342
- }
8343
- var topLevelEvent = topLevelEvents[0];
8344
- this.logger.verbose("PerformanceClient: Measurement found for " + measureName, correlationId);
8345
- // Build event object with top level and sub measurements
8346
- var eventToEmit = sortedCompletedEvents.reduce(function (previous, current) {
8347
- if (current.name !== measureName) {
8348
- _this.logger.trace("PerformanceClient: Complete submeasurement found for " + current.name, correlationId);
8349
- // TODO: Emit additional properties for each subMeasurement
8350
- var subMeasurementName = current.name + "DurationMs";
8351
- /*
8352
- * Some code paths, such as resolving an authority, can occur multiple times.
8353
- * Only take the first measurement, since the second could be read from the cache,
8354
- * or due to the same correlation id being used for two distinct requests.
8355
- */
8356
- if (!previous[subMeasurementName]) {
8357
- previous[subMeasurementName] = current.durationMs;
8358
- }
8359
- else {
8360
- _this.logger.verbose("PerformanceClient: Submeasurement for " + measureName + " already exists for " + current.name + ", ignoring", correlationId);
8361
- }
8362
- }
8363
- return previous;
8364
- }, topLevelEvent);
8365
- var finalEvent = __assign(__assign(__assign(__assign({}, eventToEmit), staticFields), counters), { queuedTimeMs: totalQueueTime, queuedCount: totalQueueCount, incompleteSubsCount: incompleteSubsCount_1 });
8366
- this.truncateIntegralFields(finalEvent, this.getIntFields());
8367
- this.emitEvents([finalEvent], eventToEmit.correlationId);
8368
- }
8369
- else {
8370
- this.logger.verbose("PerformanceClient: No completed top-level measurements found for " + measureName, correlationId);
8371
- }
8372
- }
8373
- else {
8374
- this.logger.verbose("PerformanceClient: No measurements found", correlationId);
8375
- }
8323
+ return {
8324
+ totalQueueTime: totalQueueTime,
8325
+ totalQueueCount: totalQueueCount,
8326
+ manuallyCompletedCount: manuallyCompletedCount
8327
+ };
8376
8328
  };
8377
8329
  /**
8378
8330
  * Removes measurements for a given correlation id.
@@ -8386,14 +8338,10 @@ var PerformanceClient = /** @class */ (function () {
8386
8338
  /**
8387
8339
  * Removes cache for a given correlation id.
8388
8340
  *
8389
- * @param {string} correlation identifier
8341
+ * @param {string} correlationId correlation identifier
8390
8342
  */
8391
8343
  PerformanceClient.prototype.discardCache = function (correlationId) {
8392
8344
  this.discardMeasurements(correlationId);
8393
- this.logger.trace("PerformanceClient: Static fields discarded", correlationId);
8394
- this.staticFieldsByCorrelationId.delete(correlationId);
8395
- this.logger.trace("PerformanceClient: Counters discarded", correlationId);
8396
- this.countersByCorrelationId.delete(correlationId);
8397
8345
  this.logger.trace("PerformanceClient: QueueMeasurements discarded", correlationId);
8398
8346
  this.queueMeasurements.delete(correlationId);
8399
8347
  this.logger.trace("PerformanceClient: Pre-queue times discarded", correlationId);
@@ -8456,7 +8404,7 @@ var PerformanceClient = /** @class */ (function () {
8456
8404
  return PerformanceClient;
8457
8405
  }());
8458
8406
 
8459
- /*! @azure/msal-common v10.0.0 2023-02-06 */
8407
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
8460
8408
 
8461
8409
  /*
8462
8410
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8659,6 +8607,10 @@ var BrowserAuthErrorMessage = {
8659
8607
  code: "auth_code_or_nativeAccountId_required",
8660
8608
  desc: "An authorization code or nativeAccountId must be provided to this flow."
8661
8609
  },
8610
+ spaCodeAndNativeAccountPresent: {
8611
+ code: "spa_code_and_nativeAccountId_present",
8612
+ desc: "Request cannot contain both spa code and native account id."
8613
+ },
8662
8614
  databaseUnavailable: {
8663
8615
  code: "database_unavailable",
8664
8616
  desc: "IndexedDB, which is required for persistent cryptographic key storage, is unavailable. This may be caused by browser privacy features which block persistent storage in third-party contexts."
@@ -8931,6 +8883,12 @@ var BrowserAuthError = /** @class */ (function (_super) {
8931
8883
  BrowserAuthError.createAuthCodeOrNativeAccountIdRequiredError = function () {
8932
8884
  return new BrowserAuthError(BrowserAuthErrorMessage.authCodeOrNativeAccountRequired.code, BrowserAuthErrorMessage.authCodeOrNativeAccountRequired.desc);
8933
8885
  };
8886
+ /**
8887
+ * Create an error when both authorization code and native account ID are provided
8888
+ */
8889
+ BrowserAuthError.createSpaCodeAndNativeAccountIdPresentError = function () {
8890
+ return new BrowserAuthError(BrowserAuthErrorMessage.spaCodeAndNativeAccountPresent.code, BrowserAuthErrorMessage.spaCodeAndNativeAccountPresent.desc);
8891
+ };
8934
8892
  /**
8935
8893
  * Create an error when IndexedDB is unavailable
8936
8894
  */
@@ -10361,7 +10319,7 @@ var DEFAULT_BROWSER_CACHE_MANAGER = function (clientId, logger) {
10361
10319
 
10362
10320
  /* eslint-disable header/header */
10363
10321
  var name = "@azure/msal-browser";
10364
- var version = "2.33.0";
10322
+ var version = "2.34.0";
10365
10323
 
10366
10324
  /*
10367
10325
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -11971,60 +11929,96 @@ var NativeInteractionClient = /** @class */ (function (_super) {
11971
11929
  */
11972
11930
  NativeInteractionClient.prototype.handleNativeResponse = function (response, request, reqTimestamp) {
11973
11931
  return __awaiter$1(this, void 0, void 0, function () {
11974
- var mats, idTokenObj, authority, authorityPreferredCache, homeAccountIdentifier, accountEntity, responseScopes, accountProperties, uid, tid, responseAccessToken, responseTokenType, _a, popTokenGenerator, shrParameters, result, idTokenEntity, expiresIn, tokenExpirationSeconds, accessTokenEntity;
11975
- var _this = this;
11976
- return __generator$1(this, function (_b) {
11977
- switch (_b.label) {
11932
+ var authority, authorityPreferredCache, idTokenObj, homeAccountIdentifier, accountEntity, result;
11933
+ return __generator$1(this, function (_a) {
11934
+ switch (_a.label) {
11978
11935
  case 0:
11979
11936
  this.logger.trace("NativeInteractionClient - handleNativeResponse called.");
11980
- mats = this.getMATSFromResponse(response);
11981
- this.performanceClient.addStaticFields({
11982
- extensionId: this.nativeMessageHandler.getExtensionId(),
11983
- extensionVersion: this.nativeMessageHandler.getExtensionVersion(),
11984
- matsBrokerVersion: mats ? mats.broker_version : undefined,
11985
- matsAccountJoinOnStart: mats ? mats.account_join_on_start : undefined,
11986
- matsAccountJoinOnEnd: mats ? mats.account_join_on_end : undefined,
11987
- matsDeviceJoin: mats ? mats.device_join : undefined,
11988
- matsPromptBehavior: mats ? mats.prompt_behavior : undefined,
11989
- matsApiErrorCode: mats ? mats.api_error_code : undefined,
11990
- matsUiVisible: mats ? mats.ui_visible : undefined,
11991
- matsSilentCode: mats ? mats.silent_code : undefined,
11992
- matsSilentBiSubCode: mats ? mats.silent_bi_sub_code : undefined,
11993
- matsSilentMessage: mats ? mats.silent_message : undefined,
11994
- matsSilentStatus: mats ? mats.silent_status : undefined,
11995
- matsHttpStatus: mats ? mats.http_status : undefined,
11996
- matsHttpEventCount: mats ? mats.http_event_count : undefined
11997
- }, this.correlationId);
11998
11937
  if (response.account.id !== request.accountId) {
11999
11938
  // User switch in native broker prompt is not supported. All users must first sign in through web flow to ensure server state is in sync
12000
11939
  throw NativeAuthError.createUserSwitchError();
12001
11940
  }
12002
- idTokenObj = new AuthToken(response.id_token || Constants.EMPTY_STRING, this.browserCrypto);
11941
+ if (response.account.id !== request.accountId) {
11942
+ // User switch in native broker prompt is not supported. All users must first sign in through web flow to ensure server state is in sync
11943
+ throw NativeAuthError.createUserSwitchError();
11944
+ }
12003
11945
  return [4 /*yield*/, this.getDiscoveredAuthority(request.authority)];
12004
11946
  case 1:
12005
- authority = _b.sent();
11947
+ authority = _a.sent();
12006
11948
  authorityPreferredCache = authority.getPreferredCache();
12007
- homeAccountIdentifier = AccountEntity.generateHomeAccountId(response.client_info || Constants.EMPTY_STRING, AuthorityType.Default, this.logger, this.browserCrypto, idTokenObj);
12008
- accountEntity = AccountEntity.createAccount(response.client_info, homeAccountIdentifier, idTokenObj, undefined, undefined, undefined, authorityPreferredCache, response.account.id);
12009
- this.browserStorage.setAccount(accountEntity);
12010
- responseScopes = response.scope ? ScopeSet.fromString(response.scope) : ScopeSet.fromString(request.scope);
12011
- accountProperties = response.account.properties || {};
12012
- uid = accountProperties["UID"] || idTokenObj.claims.oid || idTokenObj.claims.sub || Constants.EMPTY_STRING;
12013
- tid = accountProperties["TenantId"] || idTokenObj.claims.tid || Constants.EMPTY_STRING;
12014
- responseTokenType = exports.AuthenticationScheme.BEARER;
12015
- _a = request.tokenType;
12016
- switch (_a) {
12017
- case exports.AuthenticationScheme.POP: return [3 /*break*/, 2];
12018
- }
12019
- return [3 /*break*/, 4];
11949
+ idTokenObj = this.createIdTokenObj(response);
11950
+ homeAccountIdentifier = this.createHomeAccountIdentifier(response, idTokenObj);
11951
+ accountEntity = this.createAccountEntity(response, homeAccountIdentifier, idTokenObj, authorityPreferredCache);
11952
+ return [4 /*yield*/, this.generateAuthenticationResult(response, request, idTokenObj, accountEntity, authority.canonicalAuthority, reqTimestamp)];
12020
11953
  case 2:
12021
- // Set the token type to POP in the response
12022
- responseTokenType = exports.AuthenticationScheme.POP;
11954
+ result = _a.sent();
11955
+ // cache accounts and tokens in the appropriate storage
11956
+ this.cacheAccount(accountEntity);
11957
+ this.cacheNativeTokens(response, request, homeAccountIdentifier, idTokenObj, result.accessToken, result.tenantId, reqTimestamp);
11958
+ return [2 /*return*/, result];
11959
+ }
11960
+ });
11961
+ });
11962
+ };
11963
+ /**
11964
+ * Create an idToken Object (not entity)
11965
+ * @param response
11966
+ * @returns
11967
+ */
11968
+ NativeInteractionClient.prototype.createIdTokenObj = function (response) {
11969
+ return new AuthToken(response.id_token || Constants.EMPTY_STRING, this.browserCrypto);
11970
+ };
11971
+ /**
11972
+ * creates an homeAccountIdentifier for the account
11973
+ * @param response
11974
+ * @param idTokenObj
11975
+ * @returns
11976
+ */
11977
+ NativeInteractionClient.prototype.createHomeAccountIdentifier = function (response, idTokenObj) {
11978
+ // Save account in browser storage
11979
+ var homeAccountIdentifier = AccountEntity.generateHomeAccountId(response.client_info || Constants.EMPTY_STRING, AuthorityType.Default, this.logger, this.browserCrypto, idTokenObj);
11980
+ return homeAccountIdentifier;
11981
+ };
11982
+ /**
11983
+ * Creates account entity
11984
+ * @param response
11985
+ * @param homeAccountIdentifier
11986
+ * @param idTokenObj
11987
+ * @param authority
11988
+ * @returns
11989
+ */
11990
+ NativeInteractionClient.prototype.createAccountEntity = function (response, homeAccountIdentifier, idTokenObj, authority) {
11991
+ return AccountEntity.createAccount(response.client_info, homeAccountIdentifier, idTokenObj, undefined, undefined, undefined, authority, response.account.id);
11992
+ };
11993
+ /**
11994
+ * Helper to generate scopes
11995
+ * @param response
11996
+ * @param request
11997
+ * @returns
11998
+ */
11999
+ NativeInteractionClient.prototype.generateScopes = function (response, request) {
12000
+ return response.scope ? ScopeSet.fromString(response.scope) : ScopeSet.fromString(request.scope);
12001
+ };
12002
+ /**
12003
+ * If PoP token is requesred, records the PoP token if returned from the WAM, else generates one in the browser
12004
+ * @param request
12005
+ * @param response
12006
+ */
12007
+ NativeInteractionClient.prototype.generatePopAccessToken = function (response, request) {
12008
+ return __awaiter$1(this, void 0, void 0, function () {
12009
+ var popTokenGenerator, shrParameters;
12010
+ return __generator$1(this, function (_a) {
12011
+ switch (_a.label) {
12012
+ case 0:
12013
+ if (!(request.tokenType === exports.AuthenticationScheme.POP)) return [3 /*break*/, 2];
12014
+ /**
12015
+ * This code prioritizes SHR returned from the native layer. In case of error/SHR not calculated from WAM and the AT
12016
+ * is still received, SHR is calculated locally
12017
+ */
12023
12018
  // Check if native layer returned an SHR token
12024
12019
  if (response.shr) {
12025
12020
  this.logger.trace("handleNativeServerResponse: SHR is enabled in native layer");
12026
- responseAccessToken = response.shr;
12027
- return [3 /*break*/, 5];
12021
+ return [2 /*return*/, response.shr];
12028
12022
  }
12029
12023
  popTokenGenerator = new PopTokenGenerator(this.browserCrypto);
12030
12024
  shrParameters = {
@@ -12041,17 +12035,39 @@ var NativeInteractionClient = /** @class */ (function (_super) {
12041
12035
  throw ClientAuthError.createKeyIdMissingError();
12042
12036
  }
12043
12037
  return [4 /*yield*/, popTokenGenerator.signPopToken(response.access_token, request.keyId, shrParameters)];
12044
- case 3:
12045
- responseAccessToken = _b.sent();
12046
- return [3 /*break*/, 5];
12047
- case 4:
12048
- {
12049
- responseAccessToken = response.access_token;
12050
- }
12051
- _b.label = 5;
12052
- case 5:
12038
+ case 1: return [2 /*return*/, _a.sent()];
12039
+ case 2: return [2 /*return*/, response.access_token];
12040
+ }
12041
+ });
12042
+ });
12043
+ };
12044
+ /**
12045
+ * Generates authentication result
12046
+ * @param response
12047
+ * @param request
12048
+ * @param idTokenObj
12049
+ * @param accountEntity
12050
+ * @param authority
12051
+ * @param reqTimestamp
12052
+ * @returns
12053
+ */
12054
+ NativeInteractionClient.prototype.generateAuthenticationResult = function (response, request, idTokenObj, accountEntity, authority, reqTimestamp) {
12055
+ return __awaiter$1(this, void 0, void 0, function () {
12056
+ var mats, responseScopes, accountProperties, uid, tid, responseAccessToken, tokenType, result;
12057
+ return __generator$1(this, function (_a) {
12058
+ switch (_a.label) {
12059
+ case 0:
12060
+ mats = this.addTelemetryFromNativeResponse(response);
12061
+ responseScopes = response.scope ? ScopeSet.fromString(response.scope) : ScopeSet.fromString(request.scope);
12062
+ accountProperties = response.account.properties || {};
12063
+ uid = accountProperties["UID"] || idTokenObj.claims.oid || idTokenObj.claims.sub || Constants.EMPTY_STRING;
12064
+ tid = accountProperties["TenantId"] || idTokenObj.claims.tid || Constants.EMPTY_STRING;
12065
+ return [4 /*yield*/, this.generatePopAccessToken(response, request)];
12066
+ case 1:
12067
+ responseAccessToken = _a.sent();
12068
+ tokenType = (request.tokenType === exports.AuthenticationScheme.POP) ? exports.AuthenticationScheme.POP : exports.AuthenticationScheme.BEARER;
12053
12069
  result = {
12054
- authority: authority.canonicalAuthority,
12070
+ authority: authority,
12055
12071
  uniqueId: uid,
12056
12072
  tenantId: tid,
12057
12073
  scopes: responseScopes.asArray(),
@@ -12061,30 +12077,78 @@ var NativeInteractionClient = /** @class */ (function (_super) {
12061
12077
  accessToken: responseAccessToken,
12062
12078
  fromCache: mats ? this.isResponseFromCache(mats) : false,
12063
12079
  expiresOn: new Date(Number(reqTimestamp + response.expires_in) * 1000),
12064
- tokenType: responseTokenType,
12080
+ tokenType: tokenType,
12065
12081
  correlationId: this.correlationId,
12066
12082
  state: response.state,
12067
12083
  fromNativeBroker: true
12068
12084
  };
12069
- idTokenEntity = IdTokenEntity.createIdTokenEntity(homeAccountIdentifier, request.authority, response.id_token || Constants.EMPTY_STRING, request.clientId, idTokenObj.claims.tid || Constants.EMPTY_STRING);
12070
- this.nativeStorageManager.setIdTokenCredential(idTokenEntity);
12071
- expiresIn = (responseTokenType === exports.AuthenticationScheme.POP)
12072
- ? Constants.SHR_NONCE_VALIDITY
12073
- : (typeof response.expires_in === "string"
12074
- ? parseInt(response.expires_in, 10)
12075
- : response.expires_in) || 0;
12076
- tokenExpirationSeconds = reqTimestamp + expiresIn;
12077
- accessTokenEntity = AccessTokenEntity.createAccessTokenEntity(homeAccountIdentifier, request.authority, responseAccessToken, request.clientId, tid, responseScopes.printScopes(), tokenExpirationSeconds, 0, this.browserCrypto);
12078
- this.nativeStorageManager.setAccessTokenCredential(accessTokenEntity);
12079
- // Remove any existing cached tokens for this account in browser storage
12080
- this.browserStorage.removeAccountContext(accountEntity).catch(function (e) {
12081
- _this.logger.error("Error occurred while removing account context from browser storage. " + e);
12082
- });
12083
12085
  return [2 /*return*/, result];
12084
12086
  }
12085
12087
  });
12086
12088
  });
12087
12089
  };
12090
+ /**
12091
+ * cache the account entity in browser storage
12092
+ * @param accountEntity
12093
+ */
12094
+ NativeInteractionClient.prototype.cacheAccount = function (accountEntity) {
12095
+ var _this = this;
12096
+ // Store the account info and hence `nativeAccountId` in browser cache
12097
+ this.browserStorage.setAccount(accountEntity);
12098
+ // Remove any existing cached tokens for this account in browser storage
12099
+ this.browserStorage.removeAccountContext(accountEntity).catch(function (e) {
12100
+ _this.logger.error("Error occurred while removing account context from browser storage. " + e);
12101
+ });
12102
+ };
12103
+ /**
12104
+ * Stores the access_token and id_token in inmemory storage
12105
+ * @param response
12106
+ * @param request
12107
+ * @param homeAccountIdentifier
12108
+ * @param idTokenObj
12109
+ * @param responseAccessToken
12110
+ * @param tenantId
12111
+ * @param reqTimestamp
12112
+ */
12113
+ NativeInteractionClient.prototype.cacheNativeTokens = function (response, request, homeAccountIdentifier, idTokenObj, responseAccessToken, tenantId, reqTimestamp) {
12114
+ // cache idToken in inmemory storage
12115
+ var idTokenEntity = IdTokenEntity.createIdTokenEntity(homeAccountIdentifier, request.authority, response.id_token || Constants.EMPTY_STRING, request.clientId, idTokenObj.claims.tid || Constants.EMPTY_STRING);
12116
+ this.nativeStorageManager.setIdTokenCredential(idTokenEntity);
12117
+ // cache accessToken in inmemory storage
12118
+ var expiresIn = (request.tokenType === exports.AuthenticationScheme.POP)
12119
+ ? Constants.SHR_NONCE_VALIDITY
12120
+ : (typeof response.expires_in === "string"
12121
+ ? parseInt(response.expires_in, 10)
12122
+ : response.expires_in) || 0;
12123
+ var tokenExpirationSeconds = reqTimestamp + expiresIn;
12124
+ var responseScopes = this.generateScopes(response, request);
12125
+ var accessTokenEntity = AccessTokenEntity.createAccessTokenEntity(homeAccountIdentifier, request.authority, responseAccessToken, request.clientId, tenantId, responseScopes.printScopes(), tokenExpirationSeconds, 0, this.browserCrypto);
12126
+ this.nativeStorageManager.setAccessTokenCredential(accessTokenEntity);
12127
+ };
12128
+ NativeInteractionClient.prototype.addTelemetryFromNativeResponse = function (response) {
12129
+ var mats = this.getMATSFromResponse(response);
12130
+ if (!mats) {
12131
+ return null;
12132
+ }
12133
+ this.performanceClient.addStaticFields({
12134
+ extensionId: this.nativeMessageHandler.getExtensionId(),
12135
+ extensionVersion: this.nativeMessageHandler.getExtensionVersion(),
12136
+ matsBrokerVersion: mats.broker_version,
12137
+ matsAccountJoinOnStart: mats.account_join_on_start,
12138
+ matsAccountJoinOnEnd: mats.account_join_on_end,
12139
+ matsDeviceJoin: mats.device_join,
12140
+ matsPromptBehavior: mats.prompt_behavior,
12141
+ matsApiErrorCode: mats.api_error_code,
12142
+ matsUiVisible: mats.ui_visible,
12143
+ matsSilentCode: mats.silent_code,
12144
+ matsSilentBiSubCode: mats.silent_bi_sub_code,
12145
+ matsSilentMessage: mats.silent_message,
12146
+ matsSilentStatus: mats.silent_status,
12147
+ matsHttpStatus: mats.http_status,
12148
+ matsHttpEventCount: mats.http_event_count
12149
+ }, this.correlationId);
12150
+ return mats;
12151
+ };
12088
12152
  /**
12089
12153
  * Validates native platform response before processing
12090
12154
  * @param response
@@ -12203,7 +12267,7 @@ var NativeInteractionClient = /** @class */ (function (_super) {
12203
12267
  * Licensed under the MIT License.
12204
12268
  */
12205
12269
  var NativeMessageHandler = /** @class */ (function () {
12206
- function NativeMessageHandler(logger, handshakeTimeoutMs, extensionId) {
12270
+ function NativeMessageHandler(logger, handshakeTimeoutMs, performanceClient, extensionId) {
12207
12271
  this.logger = logger;
12208
12272
  this.handshakeTimeoutMs = handshakeTimeoutMs;
12209
12273
  this.extensionId = extensionId;
@@ -12212,6 +12276,8 @@ var NativeMessageHandler = /** @class */ (function () {
12212
12276
  this.responseId = 0;
12213
12277
  this.messageChannel = new MessageChannel();
12214
12278
  this.windowListener = this.onWindowMessage.bind(this); // Window event callback doesn't have access to 'this' unless it's bound
12279
+ this.performanceClient = performanceClient;
12280
+ this.handshakeEvent = performanceClient.startMeasurement(exports.PerformanceEvents.NativeMessageHandlerHandshake);
12215
12281
  }
12216
12282
  /**
12217
12283
  * Sends a given message to the extension and resolves with the extension response
@@ -12240,10 +12306,11 @@ var NativeMessageHandler = /** @class */ (function () {
12240
12306
  };
12241
12307
  /**
12242
12308
  * Returns an instance of the MessageHandler that has successfully established a connection with an extension
12243
- * @param logger
12244
- * @param handshakeTimeoutMs
12309
+ * @param {Logger} logger
12310
+ * @param {number} handshakeTimeoutMs
12311
+ * @param {IPerformanceClient} performanceClient
12245
12312
  */
12246
- NativeMessageHandler.createProvider = function (logger, handshakeTimeoutMs) {
12313
+ NativeMessageHandler.createProvider = function (logger, handshakeTimeoutMs, performanceClient) {
12247
12314
  return __awaiter$1(this, void 0, void 0, function () {
12248
12315
  var preferredProvider, backupProvider;
12249
12316
  return __generator$1(this, function (_a) {
@@ -12253,14 +12320,14 @@ var NativeMessageHandler = /** @class */ (function () {
12253
12320
  _a.label = 1;
12254
12321
  case 1:
12255
12322
  _a.trys.push([1, 3, , 5]);
12256
- preferredProvider = new NativeMessageHandler(logger, handshakeTimeoutMs, NativeConstants.PREFERRED_EXTENSION_ID);
12323
+ preferredProvider = new NativeMessageHandler(logger, handshakeTimeoutMs, performanceClient, NativeConstants.PREFERRED_EXTENSION_ID);
12257
12324
  return [4 /*yield*/, preferredProvider.sendHandshakeRequest()];
12258
12325
  case 2:
12259
12326
  _a.sent();
12260
12327
  return [2 /*return*/, preferredProvider];
12261
12328
  case 3:
12262
12329
  _a.sent();
12263
- backupProvider = new NativeMessageHandler(logger, handshakeTimeoutMs);
12330
+ backupProvider = new NativeMessageHandler(logger, handshakeTimeoutMs, performanceClient);
12264
12331
  return [4 /*yield*/, backupProvider.sendHandshakeRequest()];
12265
12332
  case 4:
12266
12333
  _a.sent();
@@ -12289,6 +12356,10 @@ var NativeMessageHandler = /** @class */ (function () {
12289
12356
  method: NativeExtensionMethod.HandshakeRequest
12290
12357
  }
12291
12358
  };
12359
+ this.handshakeEvent.addStaticFields({
12360
+ extensionId: this.extensionId,
12361
+ extensionHandshakeTimeoutMs: this.handshakeTimeoutMs
12362
+ });
12292
12363
  this.messageChannel.port1.onmessage = function (event) {
12293
12364
  _this.onChannelMessage(event);
12294
12365
  };
@@ -12303,6 +12374,7 @@ var NativeMessageHandler = /** @class */ (function () {
12303
12374
  window.removeEventListener("message", _this.windowListener, false);
12304
12375
  _this.messageChannel.port1.close();
12305
12376
  _this.messageChannel.port2.close();
12377
+ _this.handshakeEvent.endMeasurement({ extensionHandshakeTimedOut: true, success: false });
12306
12378
  reject(BrowserAuthError.createNativeHandshakeTimeoutError());
12307
12379
  _this.handshakeResolvers.delete(req.responseId);
12308
12380
  }, _this.handshakeTimeoutMs); // Use a reasonable timeout in milliseconds here
@@ -12336,6 +12408,7 @@ var NativeMessageHandler = /** @class */ (function () {
12336
12408
  window.removeEventListener("message", this.windowListener, false);
12337
12409
  var handshakeResolver = this.handshakeResolvers.get(request.responseId);
12338
12410
  if (handshakeResolver) {
12411
+ this.handshakeEvent.endMeasurement({ success: false, extensionInstalled: false });
12339
12412
  handshakeResolver.reject(BrowserAuthError.createNativeExtensionNotInstalledError());
12340
12413
  }
12341
12414
  }
@@ -12383,6 +12456,7 @@ var NativeMessageHandler = /** @class */ (function () {
12383
12456
  this.extensionId = request.extensionId;
12384
12457
  this.extensionVersion = request.body.version;
12385
12458
  this.logger.verbose("NativeMessageHandler - Received HandshakeResponse from extension: " + this.extensionId);
12459
+ this.handshakeEvent.endMeasurement({ extensionInstalled: true, success: true });
12386
12460
  handshakeResolver.resolve();
12387
12461
  this.handshakeResolvers.delete(request.responseId);
12388
12462
  }
@@ -15452,10 +15526,19 @@ var CryptoOps = /** @class */ (function () {
15452
15526
  var BrowserPerformanceMeasurement = /** @class */ (function () {
15453
15527
  function BrowserPerformanceMeasurement(name, correlationId) {
15454
15528
  this.correlationId = correlationId;
15455
- this.measureName = "msal.measure." + name + "." + this.correlationId;
15456
- this.startMark = "msal.start." + name + "." + this.correlationId;
15457
- this.endMark = "msal.end." + name + "." + this.correlationId;
15529
+ this.measureName = BrowserPerformanceMeasurement.makeMeasureName(name, correlationId);
15530
+ this.startMark = BrowserPerformanceMeasurement.makeStartMark(name, correlationId);
15531
+ this.endMark = BrowserPerformanceMeasurement.makeEndMark(name, correlationId);
15458
15532
  }
15533
+ BrowserPerformanceMeasurement.makeMeasureName = function (name, correlationId) {
15534
+ return "msal.measure." + name + "." + correlationId;
15535
+ };
15536
+ BrowserPerformanceMeasurement.makeStartMark = function (name, correlationId) {
15537
+ return "msal.start." + name + "." + correlationId;
15538
+ };
15539
+ BrowserPerformanceMeasurement.makeEndMark = function (name, correlationId) {
15540
+ return "msal.end." + name + "." + correlationId;
15541
+ };
15459
15542
  BrowserPerformanceMeasurement.supportsBrowserPerformance = function () {
15460
15543
  return typeof window !== "undefined" &&
15461
15544
  typeof window.performance !== "undefined" &&
@@ -15465,6 +15548,29 @@ var BrowserPerformanceMeasurement = /** @class */ (function () {
15465
15548
  typeof window.performance.clearMeasures === "function" &&
15466
15549
  typeof window.performance.getEntriesByName === "function";
15467
15550
  };
15551
+ /**
15552
+ * Flush browser marks and measurements.
15553
+ * @param {string} correlationId
15554
+ * @param {SubMeasurement} measurements
15555
+ */
15556
+ BrowserPerformanceMeasurement.flushMeasurements = function (correlationId, measurements) {
15557
+ if (BrowserPerformanceMeasurement.supportsBrowserPerformance()) {
15558
+ try {
15559
+ measurements.forEach(function (measurement) {
15560
+ var measureName = BrowserPerformanceMeasurement.makeMeasureName(measurement.name, correlationId);
15561
+ var entriesForMeasurement = window.performance.getEntriesByName(measureName, "measure");
15562
+ if (entriesForMeasurement.length > 0) {
15563
+ window.performance.clearMeasures(measureName);
15564
+ window.performance.clearMarks(BrowserPerformanceMeasurement.makeStartMark(measureName, correlationId));
15565
+ window.performance.clearMarks(BrowserPerformanceMeasurement.makeEndMark(measureName, correlationId));
15566
+ }
15567
+ });
15568
+ }
15569
+ catch (e) {
15570
+ // Silently catch and return null
15571
+ }
15572
+ }
15573
+ };
15468
15574
  BrowserPerformanceMeasurement.prototype.startMeasurement = function () {
15469
15575
  if (BrowserPerformanceMeasurement.supportsBrowserPerformance()) {
15470
15576
  try {
@@ -15529,6 +15635,20 @@ var BrowserPerformanceClient = /** @class */ (function (_super) {
15529
15635
  var _a;
15530
15636
  return ((_a = document.visibilityState) === null || _a === void 0 ? void 0 : _a.toString()) || null;
15531
15637
  };
15638
+ BrowserPerformanceClient.prototype.deleteIncompleteSubMeasurements = function (inProgressEvent) {
15639
+ var rootEvent = this.eventsByCorrelationId.get(inProgressEvent.event.correlationId);
15640
+ var isRootEvent = rootEvent && rootEvent.eventId === inProgressEvent.event.eventId;
15641
+ var incompleteMeasurements = [];
15642
+ if (isRootEvent && (rootEvent === null || rootEvent === void 0 ? void 0 : rootEvent.incompleteSubMeasurements)) {
15643
+ rootEvent.incompleteSubMeasurements.forEach(function (subMeasurement) {
15644
+ incompleteMeasurements.push(__assign$1({}, subMeasurement));
15645
+ });
15646
+ }
15647
+ // Clean up remaining marks for incomplete sub-measurements
15648
+ if (incompleteMeasurements.length > 0) {
15649
+ BrowserPerformanceMeasurement.flushMeasurements(inProgressEvent.event.correlationId, incompleteMeasurements);
15650
+ }
15651
+ };
15532
15652
  BrowserPerformanceClient.prototype.supportsBrowserPerformanceNow = function () {
15533
15653
  return typeof window !== "undefined" &&
15534
15654
  typeof window.performance !== "undefined" &&
@@ -15548,7 +15668,13 @@ var BrowserPerformanceClient = /** @class */ (function (_super) {
15548
15668
  var startPageVisibility = this.getPageVisibility();
15549
15669
  var inProgressEvent = _super.prototype.startMeasurement.call(this, measureName, correlationId);
15550
15670
  return __assign$1(__assign$1({}, inProgressEvent), { endMeasurement: function (event) {
15551
- return inProgressEvent.endMeasurement(__assign$1({ startPageVisibility: startPageVisibility, endPageVisibility: _this.getPageVisibility() }, event));
15671
+ var res = inProgressEvent.endMeasurement(__assign$1({ startPageVisibility: startPageVisibility, endPageVisibility: _this.getPageVisibility() }, event));
15672
+ _this.deleteIncompleteSubMeasurements(inProgressEvent);
15673
+ return res;
15674
+ }, discardMeasurement: function () {
15675
+ inProgressEvent.discardMeasurement();
15676
+ _this.deleteIncompleteSubMeasurements(inProgressEvent);
15677
+ inProgressEvent.measurement.flushMeasurement();
15552
15678
  } });
15553
15679
  };
15554
15680
  /**
@@ -15566,26 +15692,27 @@ var BrowserPerformanceClient = /** @class */ (function (_super) {
15566
15692
  this.logger.trace("BrowserPerformanceClient: correlationId for " + eventName + " not provided, unable to set telemetry queue time");
15567
15693
  return;
15568
15694
  }
15569
- var preQueueTimesByEvents = this.preQueueTimeByCorrelationId.get(correlationId);
15570
- if (preQueueTimesByEvents) {
15571
- preQueueTimesByEvents.set(eventName, window.performance.now());
15572
- this.preQueueTimeByCorrelationId.set(correlationId, preQueueTimesByEvents);
15573
- }
15574
- else {
15575
- var preQueueTimes = new Map();
15576
- preQueueTimes.set(eventName, window.performance.now());
15577
- this.preQueueTimeByCorrelationId.set(correlationId, preQueueTimes);
15695
+ var preQueueEvent = this.preQueueTimeByCorrelationId.get(correlationId);
15696
+ /**
15697
+ * Manually complete queue measurement if there is an incomplete pre-queue event.
15698
+ * Incomplete pre-queue events are instrumentation bugs that should be fixed.
15699
+ */
15700
+ if (preQueueEvent) {
15701
+ this.logger.trace("BrowserPerformanceClient: Incomplete pre-queue " + preQueueEvent.name + " found", correlationId);
15702
+ this.addQueueMeasurement(preQueueEvent.name, correlationId, undefined, true);
15578
15703
  }
15704
+ this.preQueueTimeByCorrelationId.set(eventName, { name: eventName, time: window.performance.now() });
15579
15705
  };
15580
15706
  /**
15581
15707
  * Calculates and adds queue time measurement for given performance event.
15582
15708
  *
15583
- * @param {PerformanceEvents} name
15709
+ * @param {PerformanceEvents} eventName
15584
15710
  * @param {?string} correlationId
15585
- * @param {?number} preQueueTime
15711
+ * @param {?number} queueTime
15712
+ * @param {?boolean} manuallyCompleted - indicator for manually completed queue measurements
15586
15713
  * @returns
15587
15714
  */
15588
- BrowserPerformanceClient.prototype.addQueueMeasurement = function (eventName, correlationId) {
15715
+ BrowserPerformanceClient.prototype.addQueueMeasurement = function (eventName, correlationId, queueTime, manuallyCompleted) {
15589
15716
  if (!this.supportsBrowserPerformanceNow()) {
15590
15717
  this.logger.trace("BrowserPerformanceClient: window performance API not available, unable to add queue measurement for " + eventName);
15591
15718
  return;
@@ -15599,8 +15726,8 @@ var BrowserPerformanceClient = /** @class */ (function (_super) {
15599
15726
  return;
15600
15727
  }
15601
15728
  var currentTime = window.performance.now();
15602
- var queueTime = _super.prototype.calculateQueuedTime.call(this, preQueueTime, currentTime);
15603
- return _super.prototype.addQueueMeasurement.call(this, eventName, correlationId, queueTime);
15729
+ var resQueueTime = queueTime || _super.prototype.calculateQueuedTime.call(this, preQueueTime, currentTime);
15730
+ return _super.prototype.addQueueMeasurement.call(this, eventName, correlationId, resQueueTime, manuallyCompleted);
15604
15731
  };
15605
15732
  return BrowserPerformanceClient;
15606
15733
  }(PerformanceClient));
@@ -15619,6 +15746,7 @@ var internals = /*#__PURE__*/Object.freeze({
15619
15746
  SilentIframeClient: SilentIframeClient,
15620
15747
  SilentCacheClient: SilentCacheClient,
15621
15748
  SilentRefreshClient: SilentRefreshClient,
15749
+ NativeInteractionClient: NativeInteractionClient,
15622
15750
  RedirectHandler: RedirectHandler,
15623
15751
  EventHandler: EventHandler,
15624
15752
  NativeMessageHandler: NativeMessageHandler,
@@ -16013,7 +16141,7 @@ var ClientApplication = /** @class */ (function () {
16013
16141
  */
16014
16142
  ClientApplication.prototype.initialize = function () {
16015
16143
  return __awaiter$1(this, void 0, void 0, function () {
16016
- var _a, e_1;
16144
+ var allowNativeBroker, initMeasurement, _a, e_1;
16017
16145
  return __generator$1(this, function (_b) {
16018
16146
  switch (_b.label) {
16019
16147
  case 0:
@@ -16022,13 +16150,15 @@ var ClientApplication = /** @class */ (function () {
16022
16150
  this.logger.info("initialize has already been called, exiting early.");
16023
16151
  return [2 /*return*/];
16024
16152
  }
16153
+ allowNativeBroker = this.config.system.allowNativeBroker;
16154
+ initMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.InitializeClientApplication);
16025
16155
  this.eventHandler.emitEvent(exports.EventType.INITIALIZE_START);
16026
- if (!this.config.system.allowNativeBroker) return [3 /*break*/, 4];
16156
+ if (!allowNativeBroker) return [3 /*break*/, 4];
16027
16157
  _b.label = 1;
16028
16158
  case 1:
16029
16159
  _b.trys.push([1, 3, , 4]);
16030
16160
  _a = this;
16031
- return [4 /*yield*/, NativeMessageHandler.createProvider(this.logger, this.config.system.nativeBrokerHandshakeTimeout)];
16161
+ return [4 /*yield*/, NativeMessageHandler.createProvider(this.logger, this.config.system.nativeBrokerHandshakeTimeout, this.performanceClient)];
16032
16162
  case 2:
16033
16163
  _a.nativeExtensionProvider = _b.sent();
16034
16164
  return [3 /*break*/, 4];
@@ -16039,6 +16169,7 @@ var ClientApplication = /** @class */ (function () {
16039
16169
  case 4:
16040
16170
  this.initialized = true;
16041
16171
  this.eventHandler.emitEvent(exports.EventType.INITIALIZE_END);
16172
+ initMeasurement.endMeasurement({ allowNativeBroker: allowNativeBroker, success: true });
16042
16173
  return [2 /*return*/];
16043
16174
  }
16044
16175
  });
@@ -16214,7 +16345,6 @@ var ClientApplication = /** @class */ (function () {
16214
16345
  isNativeBroker: true,
16215
16346
  requestId: response.requestId
16216
16347
  });
16217
- atPopupMeasurement.flushMeasurement();
16218
16348
  return response;
16219
16349
  }).catch(function (e) {
16220
16350
  if (e instanceof NativeAuthError && e.isFatal()) {
@@ -16254,7 +16384,6 @@ var ClientApplication = /** @class */ (function () {
16254
16384
  success: true,
16255
16385
  requestId: result.requestId
16256
16386
  });
16257
- atPopupMeasurement.flushMeasurement();
16258
16387
  return result;
16259
16388
  }).catch(function (e) {
16260
16389
  if (loggedInAccounts.length > 0) {
@@ -16268,7 +16397,6 @@ var ClientApplication = /** @class */ (function () {
16268
16397
  subErrorCode: e.subError,
16269
16398
  success: false
16270
16399
  });
16271
- atPopupMeasurement.flushMeasurement();
16272
16400
  // Since this function is syncronous we need to reject
16273
16401
  return Promise.reject(e);
16274
16402
  });
@@ -16334,7 +16462,7 @@ var ClientApplication = /** @class */ (function () {
16334
16462
  result = silentIframeClient.acquireToken(validRequest);
16335
16463
  }
16336
16464
  return [2 /*return*/, result.then(function (response) {
16337
- var _a, _b, _c;
16465
+ var _a, _b;
16338
16466
  _this.eventHandler.emitEvent(exports.EventType.SSO_SILENT_SUCCESS, exports.InteractionType.Silent, response);
16339
16467
  (_a = _this.ssoSilentMeasurement) === null || _a === void 0 ? void 0 : _a.addStaticFields({
16340
16468
  accessTokenSize: response.accessToken.length,
@@ -16345,17 +16473,15 @@ var ClientApplication = /** @class */ (function () {
16345
16473
  isNativeBroker: response.fromNativeBroker,
16346
16474
  requestId: response.requestId
16347
16475
  });
16348
- (_c = _this.ssoSilentMeasurement) === null || _c === void 0 ? void 0 : _c.flushMeasurement();
16349
16476
  return response;
16350
16477
  }).catch(function (e) {
16351
- var _a, _b;
16478
+ var _a;
16352
16479
  _this.eventHandler.emitEvent(exports.EventType.SSO_SILENT_FAILURE, exports.InteractionType.Silent, null, e);
16353
16480
  (_a = _this.ssoSilentMeasurement) === null || _a === void 0 ? void 0 : _a.endMeasurement({
16354
16481
  errorCode: e.errorCode,
16355
16482
  subErrorCode: e.subError,
16356
16483
  success: false
16357
16484
  });
16358
- (_b = _this.ssoSilentMeasurement) === null || _b === void 0 ? void 0 : _b.flushMeasurement();
16359
16485
  throw e;
16360
16486
  }).finally(function () {
16361
16487
  document.removeEventListener("visibilitychange", _this.trackPageVisibilityWithMeasurement);
@@ -16384,7 +16510,11 @@ var ClientApplication = /** @class */ (function () {
16384
16510
  this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_BY_CODE_START, exports.InteractionType.Silent, request);
16385
16511
  atbcMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.AcquireTokenByCode, request.correlationId);
16386
16512
  try {
16387
- if (request.code) {
16513
+ if (request.code && request.nativeAccountId) {
16514
+ // Throw error in case server returns both spa_code and spa_accountid in exchange for auth code.
16515
+ throw BrowserAuthError.createSpaCodeAndNativeAccountIdPresentError();
16516
+ }
16517
+ else if (request.code) {
16388
16518
  hybridAuthCode_1 = request.code;
16389
16519
  response = this.hybridAuthCodeResponses.get(hybridAuthCode_1);
16390
16520
  if (!response) {
@@ -16402,7 +16532,6 @@ var ClientApplication = /** @class */ (function () {
16402
16532
  isNativeBroker: result.fromNativeBroker,
16403
16533
  requestId: result.requestId
16404
16534
  });
16405
- atbcMeasurement.flushMeasurement();
16406
16535
  return result;
16407
16536
  })
16408
16537
  .catch(function (error) {
@@ -16413,16 +16542,12 @@ var ClientApplication = /** @class */ (function () {
16413
16542
  subErrorCode: error.subError,
16414
16543
  success: false
16415
16544
  });
16416
- atbcMeasurement.flushMeasurement();
16417
16545
  throw error;
16418
16546
  });
16419
16547
  this.hybridAuthCodeResponses.set(hybridAuthCode_1, response);
16420
16548
  }
16421
16549
  else {
16422
16550
  this.logger.verbose("Existing acquireTokenByCode request found", request.correlationId);
16423
- atbcMeasurement.endMeasurement({
16424
- success: true
16425
- });
16426
16551
  atbcMeasurement.discardMeasurement();
16427
16552
  }
16428
16553
  return [2 /*return*/, response];
@@ -17073,7 +17198,6 @@ var PublicClientApplication = /** @class */ (function (_super) {
17073
17198
  cacheLookupPolicy: request.cacheLookupPolicy,
17074
17199
  requestId: result.requestId,
17075
17200
  });
17076
- atsMeasurement.flushMeasurement();
17077
17201
  return result;
17078
17202
  })
17079
17203
  .catch(function (error) {
@@ -17083,7 +17207,6 @@ var PublicClientApplication = /** @class */ (function (_super) {
17083
17207
  subErrorCode: error.subError,
17084
17208
  success: false
17085
17209
  });
17086
- atsMeasurement.flushMeasurement();
17087
17210
  throw error;
17088
17211
  });
17089
17212
  this.activeSilentTokenRequests.set(silentRequestKey, response);
@@ -17091,9 +17214,6 @@ var PublicClientApplication = /** @class */ (function (_super) {
17091
17214
  }
17092
17215
  else {
17093
17216
  this.logger.verbose("acquireTokenSilent has been called previously, returning the result from the first call", correlationId);
17094
- atsMeasurement.endMeasurement({
17095
- success: true
17096
- });
17097
17217
  // Discard measurements for memoized calls, as they are usually only a couple of ms and will artificially deflate metrics
17098
17218
  atsMeasurement.discardMeasurement();
17099
17219
  return [2 /*return*/, cachedResponse];