@azure/msal-browser 2.24.0 → 2.25.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 (104) hide show
  1. package/README.md +1 -1
  2. package/dist/_virtual/_tslib.js +1 -1
  3. package/dist/app/ClientApplication.js +2 -2
  4. package/dist/app/ClientApplication.js.map +1 -1
  5. package/dist/app/IPublicClientApplication.js +1 -1
  6. package/dist/app/PublicClientApplication.js +1 -1
  7. package/dist/broker/nativeBroker/NativeMessageHandler.js +1 -1
  8. package/dist/broker/nativeBroker/NativeRequest.d.ts +3 -3
  9. package/dist/broker/nativeBroker/NativeRequest.d.ts.map +1 -1
  10. package/dist/cache/AsyncMemoryStorage.js +1 -1
  11. package/dist/cache/BrowserCacheManager.js +1 -1
  12. package/dist/cache/BrowserStorage.js +1 -1
  13. package/dist/cache/DatabaseStorage.js +1 -1
  14. package/dist/cache/MemoryStorage.js +1 -1
  15. package/dist/cache/TokenCache.d.ts +1 -0
  16. package/dist/cache/TokenCache.d.ts.map +1 -1
  17. package/dist/cache/TokenCache.js +2 -2
  18. package/dist/cache/TokenCache.js.map +1 -1
  19. package/dist/config/Configuration.js +1 -1
  20. package/dist/crypto/BrowserCrypto.js +1 -1
  21. package/dist/crypto/CryptoOps.d.ts.map +1 -1
  22. package/dist/crypto/CryptoOps.js +7 -10
  23. package/dist/crypto/CryptoOps.js.map +1 -1
  24. package/dist/crypto/GuidGenerator.js +1 -1
  25. package/dist/crypto/PkceGenerator.js +1 -1
  26. package/dist/crypto/SignedHttpRequest.js +1 -1
  27. package/dist/encode/Base64Decode.js +1 -1
  28. package/dist/encode/Base64Encode.js +1 -1
  29. package/dist/error/BrowserAuthError.js +3 -3
  30. package/dist/error/BrowserAuthError.js.map +1 -1
  31. package/dist/error/BrowserConfigurationAuthError.js +1 -1
  32. package/dist/error/NativeAuthError.d.ts +2 -1
  33. package/dist/error/NativeAuthError.d.ts.map +1 -1
  34. package/dist/error/NativeAuthError.js +3 -2
  35. package/dist/error/NativeAuthError.js.map +1 -1
  36. package/dist/event/EventHandler.js +1 -1
  37. package/dist/event/EventMessage.js +1 -1
  38. package/dist/event/EventType.js +1 -1
  39. package/dist/index.cjs.js +535 -435
  40. package/dist/index.cjs.js.map +1 -1
  41. package/dist/index.js +1 -1
  42. package/dist/interaction_client/BaseInteractionClient.js +1 -1
  43. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.js +1 -1
  44. package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
  45. package/dist/interaction_client/NativeInteractionClient.js +20 -17
  46. package/dist/interaction_client/NativeInteractionClient.js.map +1 -1
  47. package/dist/interaction_client/PopupClient.d.ts +75 -2
  48. package/dist/interaction_client/PopupClient.d.ts.map +1 -1
  49. package/dist/interaction_client/PopupClient.js +281 -41
  50. package/dist/interaction_client/PopupClient.js.map +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.d.ts +3 -8
  58. package/dist/interaction_handler/InteractionHandler.d.ts.map +1 -1
  59. package/dist/interaction_handler/InteractionHandler.js +5 -5
  60. package/dist/interaction_handler/InteractionHandler.js.map +1 -1
  61. package/dist/interaction_handler/RedirectHandler.d.ts +1 -1
  62. package/dist/interaction_handler/RedirectHandler.d.ts.map +1 -1
  63. package/dist/interaction_handler/RedirectHandler.js +12 -12
  64. package/dist/interaction_handler/RedirectHandler.js.map +1 -1
  65. package/dist/interaction_handler/SilentHandler.d.ts +1 -1
  66. package/dist/interaction_handler/SilentHandler.d.ts.map +1 -1
  67. package/dist/interaction_handler/SilentHandler.js +5 -5
  68. package/dist/interaction_handler/SilentHandler.js.map +1 -1
  69. package/dist/internals.d.ts +0 -1
  70. package/dist/internals.d.ts.map +1 -1
  71. package/dist/internals.js +1 -2
  72. package/dist/internals.js.map +1 -1
  73. package/dist/navigation/NavigationClient.js +1 -1
  74. package/dist/network/FetchClient.js +1 -1
  75. package/dist/network/XhrClient.js +1 -1
  76. package/dist/packageMetadata.d.ts +1 -1
  77. package/dist/packageMetadata.js +2 -2
  78. package/dist/packageMetadata.js.map +1 -1
  79. package/dist/request/EndSessionPopupRequest.d.ts +1 -1
  80. package/dist/request/EndSessionPopupRequest.d.ts.map +1 -1
  81. package/dist/request/PopupRequest.d.ts +1 -1
  82. package/dist/request/PopupRequest.d.ts.map +1 -1
  83. package/dist/request/PopupWindowAttributes.d.ts +16 -0
  84. package/dist/request/PopupWindowAttributes.d.ts.map +1 -0
  85. package/dist/request/SsoSilentRequest.d.ts +1 -1
  86. package/dist/telemetry/BrowserPerformanceClient.js +1 -1
  87. package/dist/telemetry/BrowserPerformanceMeasurement.js +1 -1
  88. package/dist/utils/BrowserConstants.js +1 -1
  89. package/dist/utils/BrowserProtocolUtils.js +1 -1
  90. package/dist/utils/BrowserStringUtils.js +1 -1
  91. package/dist/utils/BrowserUtils.js +1 -1
  92. package/dist/utils/MathUtils.js +1 -1
  93. package/lib/msal-browser.js +535 -435
  94. package/lib/msal-browser.js.map +1 -1
  95. package/lib/msal-browser.min.js +40 -40
  96. package/package.json +2 -2
  97. package/dist/interaction_handler/PopupHandler.d.ts +0 -29
  98. package/dist/interaction_handler/PopupHandler.d.ts.map +0 -1
  99. package/dist/interaction_handler/PopupHandler.js +0 -69
  100. package/dist/interaction_handler/PopupHandler.js.map +0 -1
  101. package/dist/utils/PopupUtils.d.ts +0 -73
  102. package/dist/utils/PopupUtils.d.ts.map +0 -1
  103. package/dist/utils/PopupUtils.js +0 -185
  104. package/dist/utils/PopupUtils.js.map +0 -1
package/dist/index.cjs.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! @azure/msal-browser v2.24.0 2022-05-02 */
1
+ /*! @azure/msal-browser v2.25.0 2022-06-06 */
2
2
  'use strict';
3
3
  'use strict';
4
4
 
@@ -105,7 +105,7 @@ function __spread() {
105
105
  return ar;
106
106
  }
107
107
 
108
- /*! @azure/msal-common v6.3.0 2022-05-02 */
108
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
109
109
  /*! *****************************************************************************
110
110
  Copyright (c) Microsoft Corporation.
111
111
 
@@ -192,7 +192,7 @@ function __spreadArrays() {
192
192
  return r;
193
193
  }
194
194
 
195
- /*! @azure/msal-common v6.3.0 2022-05-02 */
195
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
196
196
 
197
197
  /*
198
198
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -559,9 +559,14 @@ var CacheOutcome;
559
559
  CacheOutcome["NO_CACHED_ACCESS_TOKEN"] = "2";
560
560
  CacheOutcome["CACHED_ACCESS_TOKEN_EXPIRED"] = "3";
561
561
  CacheOutcome["REFRESH_CACHED_ACCESS_TOKEN"] = "4";
562
- })(CacheOutcome || (CacheOutcome = {}));
562
+ })(CacheOutcome || (CacheOutcome = {}));
563
+ var JsonTypes;
564
+ (function (JsonTypes) {
565
+ JsonTypes["Jwt"] = "JWT";
566
+ JsonTypes["Jwk"] = "JWK";
567
+ })(JsonTypes || (JsonTypes = {}));
563
568
 
564
- /*! @azure/msal-common v6.3.0 2022-05-02 */
569
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
565
570
 
566
571
  /*
567
572
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -605,7 +610,7 @@ var AuthError = /** @class */ (function (_super) {
605
610
  return AuthError;
606
611
  }(Error));
607
612
 
608
- /*! @azure/msal-common v6.3.0 2022-05-02 */
613
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
609
614
 
610
615
  /*
611
616
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -680,7 +685,7 @@ var DEFAULT_CRYPTO_IMPLEMENTATION = {
680
685
  }
681
686
  };
682
687
 
683
- /*! @azure/msal-common v6.3.0 2022-05-02 */
688
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
684
689
 
685
690
  /*
686
691
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -870,6 +875,10 @@ var ClientAuthErrorMessage = {
870
875
  logoutNotSupported: {
871
876
  code: "end_session_endpoint_not_supported",
872
877
  desc: "Provided authority does not support logout."
878
+ },
879
+ keyIdMissing: {
880
+ code: "key_id_missing",
881
+ 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."
873
882
  }
874
883
  };
875
884
  /**
@@ -1139,10 +1148,16 @@ var ClientAuthError = /** @class */ (function (_super) {
1139
1148
  ClientAuthError.createLogoutNotSupportedError = function () {
1140
1149
  return new ClientAuthError(ClientAuthErrorMessage.logoutNotSupported.code, ClientAuthErrorMessage.logoutNotSupported.desc);
1141
1150
  };
1151
+ /**
1152
+ * Create an error when kid attribute is missing from a PoP token's cache record
1153
+ */
1154
+ ClientAuthError.createKeyIdMissingError = function () {
1155
+ return new ClientAuthError(ClientAuthErrorMessage.keyIdMissing.code, ClientAuthErrorMessage.keyIdMissing.desc);
1156
+ };
1142
1157
  return ClientAuthError;
1143
1158
  }(AuthError));
1144
1159
 
1145
- /*! @azure/msal-common v6.3.0 2022-05-02 */
1160
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
1146
1161
 
1147
1162
  /*
1148
1163
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1267,7 +1282,7 @@ var StringUtils = /** @class */ (function () {
1267
1282
  return StringUtils;
1268
1283
  }());
1269
1284
 
1270
- /*! @azure/msal-common v6.3.0 2022-05-02 */
1285
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
1271
1286
 
1272
1287
  /*
1273
1288
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1447,12 +1462,12 @@ var Logger = /** @class */ (function () {
1447
1462
  return Logger;
1448
1463
  }());
1449
1464
 
1450
- /*! @azure/msal-common v6.3.0 2022-05-02 */
1465
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
1451
1466
  /* eslint-disable header/header */
1452
1467
  var name$1 = "@azure/msal-common";
1453
- var version$1 = "6.3.0";
1468
+ var version$1 = "6.4.0";
1454
1469
 
1455
- /*! @azure/msal-common v6.3.0 2022-05-02 */
1470
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
1456
1471
  /*
1457
1472
  * Copyright (c) Microsoft Corporation. All rights reserved.
1458
1473
  * Licensed under the MIT License.
@@ -1473,7 +1488,7 @@ exports.AzureCloudInstance = void 0;
1473
1488
  AzureCloudInstance["AzureUsGovernment"] = "https://login.microsoftonline.us";
1474
1489
  })(exports.AzureCloudInstance || (exports.AzureCloudInstance = {}));
1475
1490
 
1476
- /*! @azure/msal-common v6.3.0 2022-05-02 */
1491
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
1477
1492
 
1478
1493
  /*
1479
1494
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1632,7 +1647,7 @@ var CredentialEntity = /** @class */ (function () {
1632
1647
  return CredentialEntity;
1633
1648
  }());
1634
1649
 
1635
- /*! @azure/msal-common v6.3.0 2022-05-02 */
1650
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
1636
1651
 
1637
1652
  /*
1638
1653
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1887,7 +1902,7 @@ var ClientConfigurationError = /** @class */ (function (_super) {
1887
1902
  return ClientConfigurationError;
1888
1903
  }(ClientAuthError));
1889
1904
 
1890
- /*! @azure/msal-common v6.3.0 2022-05-02 */
1905
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
1891
1906
 
1892
1907
  /*
1893
1908
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2071,7 +2086,7 @@ var ScopeSet = /** @class */ (function () {
2071
2086
  return ScopeSet;
2072
2087
  }());
2073
2088
 
2074
- /*! @azure/msal-common v6.3.0 2022-05-02 */
2089
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
2075
2090
 
2076
2091
  /*
2077
2092
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2109,7 +2124,7 @@ function buildClientInfoFromHomeAccountId(homeAccountId) {
2109
2124
  };
2110
2125
  }
2111
2126
 
2112
- /*! @azure/msal-common v6.3.0 2022-05-02 */
2127
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
2113
2128
  /*
2114
2129
  * Copyright (c) Microsoft Corporation. All rights reserved.
2115
2130
  * Licensed under the MIT License.
@@ -2123,7 +2138,7 @@ var AuthorityType;
2123
2138
  AuthorityType[AuthorityType["Adfs"] = 1] = "Adfs";
2124
2139
  })(AuthorityType || (AuthorityType = {}));
2125
2140
 
2126
- /*! @azure/msal-common v6.3.0 2022-05-02 */
2141
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
2127
2142
 
2128
2143
  /*
2129
2144
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2361,7 +2376,7 @@ var AccountEntity = /** @class */ (function () {
2361
2376
  return AccountEntity;
2362
2377
  }());
2363
2378
 
2364
- /*! @azure/msal-common v6.3.0 2022-05-02 */
2379
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
2365
2380
 
2366
2381
  /*
2367
2382
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2399,7 +2414,7 @@ var AuthToken = /** @class */ (function () {
2399
2414
  return AuthToken;
2400
2415
  }());
2401
2416
 
2402
- /*! @azure/msal-common v6.3.0 2022-05-02 */
2417
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
2403
2418
 
2404
2419
  /*
2405
2420
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3241,7 +3256,7 @@ var DefaultStorageClass = /** @class */ (function (_super) {
3241
3256
  return DefaultStorageClass;
3242
3257
  }(CacheManager));
3243
3258
 
3244
- /*! @azure/msal-common v6.3.0 2022-05-02 */
3259
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
3245
3260
 
3246
3261
  /*
3247
3262
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3335,7 +3350,7 @@ function buildAuthOptions(authOptions) {
3335
3350
  return __assign({ clientCapabilities: [], azureCloudOptions: DEFAULT_AZURE_CLOUD_OPTIONS }, authOptions);
3336
3351
  }
3337
3352
 
3338
- /*! @azure/msal-common v6.3.0 2022-05-02 */
3353
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
3339
3354
 
3340
3355
  /*
3341
3356
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3355,7 +3370,7 @@ var ServerError = /** @class */ (function (_super) {
3355
3370
  return ServerError;
3356
3371
  }(AuthError));
3357
3372
 
3358
- /*! @azure/msal-common v6.3.0 2022-05-02 */
3373
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
3359
3374
 
3360
3375
  /*
3361
3376
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3451,7 +3466,7 @@ var ThrottlingUtils = /** @class */ (function () {
3451
3466
  return ThrottlingUtils;
3452
3467
  }());
3453
3468
 
3454
- /*! @azure/msal-common v6.3.0 2022-05-02 */
3469
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
3455
3470
 
3456
3471
  /*
3457
3472
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3500,7 +3515,7 @@ var NetworkManager = /** @class */ (function () {
3500
3515
  return NetworkManager;
3501
3516
  }());
3502
3517
 
3503
- /*! @azure/msal-common v6.3.0 2022-05-02 */
3518
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
3504
3519
  /*
3505
3520
  * Copyright (c) Microsoft Corporation. All rights reserved.
3506
3521
  * Licensed under the MIT License.
@@ -3511,7 +3526,7 @@ var CcsCredentialType;
3511
3526
  CcsCredentialType["UPN"] = "UPN";
3512
3527
  })(CcsCredentialType || (CcsCredentialType = {}));
3513
3528
 
3514
- /*! @azure/msal-common v6.3.0 2022-05-02 */
3529
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
3515
3530
 
3516
3531
  /*
3517
3532
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3600,7 +3615,7 @@ var BaseClient = /** @class */ (function () {
3600
3615
  return BaseClient;
3601
3616
  }());
3602
3617
 
3603
- /*! @azure/msal-common v6.3.0 2022-05-02 */
3618
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
3604
3619
 
3605
3620
  /*
3606
3621
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3686,7 +3701,7 @@ var RequestValidator = /** @class */ (function () {
3686
3701
  return RequestValidator;
3687
3702
  }());
3688
3703
 
3689
- /*! @azure/msal-common v6.3.0 2022-05-02 */
3704
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
3690
3705
 
3691
3706
  /*
3692
3707
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3999,14 +4014,14 @@ var RequestParameterBuilder = /** @class */ (function () {
3999
4014
  * @param username
4000
4015
  */
4001
4016
  RequestParameterBuilder.prototype.addUsername = function (username) {
4002
- this.parameters.set(PasswordGrantConstants.username, username);
4017
+ this.parameters.set(PasswordGrantConstants.username, encodeURIComponent(username));
4003
4018
  };
4004
4019
  /**
4005
4020
  * adds `password` for Password Grant flow
4006
4021
  * @param password
4007
4022
  */
4008
4023
  RequestParameterBuilder.prototype.addPassword = function (password) {
4009
- this.parameters.set(PasswordGrantConstants.password, password);
4024
+ this.parameters.set(PasswordGrantConstants.password, encodeURIComponent(password));
4010
4025
  };
4011
4026
  /**
4012
4027
  * add pop_jwk to query params
@@ -4060,7 +4075,7 @@ var RequestParameterBuilder = /** @class */ (function () {
4060
4075
  return RequestParameterBuilder;
4061
4076
  }());
4062
4077
 
4063
- /*! @azure/msal-common v6.3.0 2022-05-02 */
4078
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
4064
4079
 
4065
4080
  /*
4066
4081
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4125,7 +4140,7 @@ var IdTokenEntity = /** @class */ (function (_super) {
4125
4140
  return IdTokenEntity;
4126
4141
  }(CredentialEntity));
4127
4142
 
4128
- /*! @azure/msal-common v6.3.0 2022-05-02 */
4143
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
4129
4144
  /*
4130
4145
  * Copyright (c) Microsoft Corporation. All rights reserved.
4131
4146
  * Licensed under the MIT License.
@@ -4175,7 +4190,7 @@ var TimeUtils = /** @class */ (function () {
4175
4190
  return TimeUtils;
4176
4191
  }());
4177
4192
 
4178
- /*! @azure/msal-common v6.3.0 2022-05-02 */
4193
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
4179
4194
 
4180
4195
  /*
4181
4196
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4289,7 +4304,7 @@ var AccessTokenEntity = /** @class */ (function (_super) {
4289
4304
  return AccessTokenEntity;
4290
4305
  }(CredentialEntity));
4291
4306
 
4292
- /*! @azure/msal-common v6.3.0 2022-05-02 */
4307
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
4293
4308
 
4294
4309
  /*
4295
4310
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4356,7 +4371,7 @@ var RefreshTokenEntity = /** @class */ (function (_super) {
4356
4371
  return RefreshTokenEntity;
4357
4372
  }(CredentialEntity));
4358
4373
 
4359
- /*! @azure/msal-common v6.3.0 2022-05-02 */
4374
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
4360
4375
 
4361
4376
  /*
4362
4377
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4420,7 +4435,7 @@ var InteractionRequiredAuthError = /** @class */ (function (_super) {
4420
4435
  return InteractionRequiredAuthError;
4421
4436
  }(AuthError));
4422
4437
 
4423
- /*! @azure/msal-common v6.3.0 2022-05-02 */
4438
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
4424
4439
  /*
4425
4440
  * Copyright (c) Microsoft Corporation. All rights reserved.
4426
4441
  * Licensed under the MIT License.
@@ -4436,7 +4451,7 @@ var CacheRecord = /** @class */ (function () {
4436
4451
  return CacheRecord;
4437
4452
  }());
4438
4453
 
4439
- /*! @azure/msal-common v6.3.0 2022-05-02 */
4454
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
4440
4455
 
4441
4456
  /*
4442
4457
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4507,7 +4522,7 @@ var ProtocolUtils = /** @class */ (function () {
4507
4522
  return ProtocolUtils;
4508
4523
  }());
4509
4524
 
4510
- /*! @azure/msal-common v6.3.0 2022-05-02 */
4525
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
4511
4526
 
4512
4527
  /*
4513
4528
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4708,7 +4723,7 @@ var UrlString = /** @class */ (function () {
4708
4723
  return UrlString;
4709
4724
  }());
4710
4725
 
4711
- /*! @azure/msal-common v6.3.0 2022-05-02 */
4726
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
4712
4727
 
4713
4728
  /*
4714
4729
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4725,34 +4740,30 @@ var PopTokenGenerator = /** @class */ (function () {
4725
4740
  }
4726
4741
  /**
4727
4742
  * Generates the req_cnf validated at the RP in the POP protocol for SHR parameters
4743
+ * and returns an object containing the keyid, the full req_cnf string and the req_cnf string hash
4728
4744
  * @param request
4729
4745
  * @returns
4730
4746
  */
4731
4747
  PopTokenGenerator.prototype.generateCnf = function (request) {
4732
4748
  return __awaiter(this, void 0, void 0, function () {
4733
- var reqCnf;
4734
- return __generator(this, function (_a) {
4735
- switch (_a.label) {
4749
+ var reqCnf, reqCnfString, _a;
4750
+ return __generator(this, function (_b) {
4751
+ switch (_b.label) {
4736
4752
  case 0: return [4 /*yield*/, this.generateKid(request)];
4737
4753
  case 1:
4738
- reqCnf = _a.sent();
4739
- return [2 /*return*/, this.cryptoUtils.base64Encode(JSON.stringify(reqCnf))];
4754
+ reqCnf = _b.sent();
4755
+ reqCnfString = this.cryptoUtils.base64Encode(JSON.stringify(reqCnf));
4756
+ _a = {
4757
+ kid: reqCnf.kid,
4758
+ reqCnfString: reqCnfString
4759
+ };
4760
+ return [4 /*yield*/, this.cryptoUtils.hashString(reqCnfString)];
4761
+ case 2: return [2 /*return*/, (_a.reqCnfHash = _b.sent(),
4762
+ _a)];
4740
4763
  }
4741
4764
  });
4742
4765
  });
4743
4766
  };
4744
- /**
4745
- * Generates the hash of the req_cnf
4746
- * @param cnf
4747
- * @returns
4748
- */
4749
- PopTokenGenerator.prototype.generateCnfHash = function (cnf) {
4750
- return __awaiter(this, void 0, void 0, function () {
4751
- return __generator(this, function (_a) {
4752
- return [2 /*return*/, this.cryptoUtils.hashString(cnf)];
4753
- });
4754
- });
4755
- };
4756
4767
  /**
4757
4768
  * Generates key_id for a SHR token request
4758
4769
  * @param request
@@ -4780,16 +4791,10 @@ var PopTokenGenerator = /** @class */ (function () {
4780
4791
  * @param request
4781
4792
  * @returns
4782
4793
  */
4783
- PopTokenGenerator.prototype.signPopToken = function (accessToken, request) {
4784
- var _a;
4794
+ PopTokenGenerator.prototype.signPopToken = function (accessToken, keyId, request) {
4785
4795
  return __awaiter(this, void 0, void 0, function () {
4786
- var tokenClaims;
4787
- return __generator(this, function (_b) {
4788
- tokenClaims = AuthToken.extractTokenClaims(accessToken, this.cryptoUtils);
4789
- if (!((_a = tokenClaims === null || tokenClaims === void 0 ? void 0 : tokenClaims.cnf) === null || _a === void 0 ? void 0 : _a.kid)) {
4790
- throw ClientAuthError.createTokenClaimsRequiredError();
4791
- }
4792
- return [2 /*return*/, this.signPayload(accessToken, tokenClaims.cnf.kid, request)];
4796
+ return __generator(this, function (_a) {
4797
+ return [2 /*return*/, this.signPayload(accessToken, keyId, request)];
4793
4798
  });
4794
4799
  });
4795
4800
  };
@@ -4801,7 +4806,7 @@ var PopTokenGenerator = /** @class */ (function () {
4801
4806
  * @param claims
4802
4807
  * @returns
4803
4808
  */
4804
- PopTokenGenerator.prototype.signPayload = function (payload, kid, request, claims) {
4809
+ PopTokenGenerator.prototype.signPayload = function (payload, keyId, request, claims) {
4805
4810
  return __awaiter(this, void 0, void 0, function () {
4806
4811
  var resourceRequestMethod, resourceRequestUri, shrClaims, shrNonce, resourceUrlString, resourceUrlComponents;
4807
4812
  return __generator(this, function (_a) {
@@ -4810,7 +4815,7 @@ var PopTokenGenerator = /** @class */ (function () {
4810
4815
  resourceRequestMethod = request.resourceRequestMethod, resourceRequestUri = request.resourceRequestUri, shrClaims = request.shrClaims, shrNonce = request.shrNonce;
4811
4816
  resourceUrlString = (resourceRequestUri) ? new UrlString(resourceRequestUri) : undefined;
4812
4817
  resourceUrlComponents = resourceUrlString === null || resourceUrlString === void 0 ? void 0 : resourceUrlString.getUrlComponents();
4813
- return [4 /*yield*/, this.cryptoUtils.signJwt(__assign({ at: payload, ts: TimeUtils.nowSeconds(), m: resourceRequestMethod === null || resourceRequestMethod === void 0 ? void 0 : resourceRequestMethod.toUpperCase(), u: resourceUrlComponents === null || resourceUrlComponents === void 0 ? void 0 : resourceUrlComponents.HostNameAndPort, nonce: shrNonce || this.cryptoUtils.createNewGuid(), p: resourceUrlComponents === null || resourceUrlComponents === void 0 ? void 0 : resourceUrlComponents.AbsolutePath, q: (resourceUrlComponents === null || resourceUrlComponents === void 0 ? void 0 : resourceUrlComponents.QueryString) ? [[], resourceUrlComponents.QueryString] : undefined, client_claims: shrClaims || undefined }, claims), kid, request.correlationId)];
4818
+ return [4 /*yield*/, this.cryptoUtils.signJwt(__assign({ at: payload, ts: TimeUtils.nowSeconds(), m: resourceRequestMethod === null || resourceRequestMethod === void 0 ? void 0 : resourceRequestMethod.toUpperCase(), u: resourceUrlComponents === null || resourceUrlComponents === void 0 ? void 0 : resourceUrlComponents.HostNameAndPort, nonce: shrNonce || this.cryptoUtils.createNewGuid(), p: resourceUrlComponents === null || resourceUrlComponents === void 0 ? void 0 : resourceUrlComponents.AbsolutePath, q: (resourceUrlComponents === null || resourceUrlComponents === void 0 ? void 0 : resourceUrlComponents.QueryString) ? [[], resourceUrlComponents.QueryString] : undefined, client_claims: shrClaims || undefined }, claims), keyId, request.correlationId)];
4814
4819
  case 1: return [2 /*return*/, _a.sent()];
4815
4820
  }
4816
4821
  });
@@ -4819,7 +4824,7 @@ var PopTokenGenerator = /** @class */ (function () {
4819
4824
  return PopTokenGenerator;
4820
4825
  }());
4821
4826
 
4822
- /*! @azure/msal-common v6.3.0 2022-05-02 */
4827
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
4823
4828
 
4824
4829
  /*
4825
4830
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4889,7 +4894,7 @@ var AppMetadataEntity = /** @class */ (function () {
4889
4894
  return AppMetadataEntity;
4890
4895
  }());
4891
4896
 
4892
- /*! @azure/msal-common v6.3.0 2022-05-02 */
4897
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
4893
4898
  /*
4894
4899
  * Copyright (c) Microsoft Corporation. All rights reserved.
4895
4900
  * Licensed under the MIT License.
@@ -4925,7 +4930,7 @@ var AppMetadataEntity = /** @class */ (function () {
4925
4930
  return TokenCacheContext;
4926
4931
  }());
4927
4932
 
4928
- /*! @azure/msal-common v6.3.0 2022-05-02 */
4933
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
4929
4934
 
4930
4935
  /*
4931
4936
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5134,9 +5139,9 @@ var ResponseHandler = /** @class */ (function () {
5134
5139
  ResponseHandler.generateAuthenticationResult = function (cryptoObj, authority, cacheRecord, fromTokenCache, request, idTokenObj, requestState, code) {
5135
5140
  var _a, _b, _c;
5136
5141
  return __awaiter(this, void 0, void 0, function () {
5137
- var accessToken, responseScopes, expiresOn, extExpiresOn, familyId, popTokenGenerator, uid, tid;
5138
- return __generator(this, function (_d) {
5139
- switch (_d.label) {
5142
+ var accessToken, responseScopes, expiresOn, extExpiresOn, familyId, popTokenGenerator, _d, secret, keyId, uid, tid;
5143
+ return __generator(this, function (_e) {
5144
+ switch (_e.label) {
5140
5145
  case 0:
5141
5146
  accessToken = Constants.EMPTY_STRING;
5142
5147
  responseScopes = [];
@@ -5145,18 +5150,22 @@ var ResponseHandler = /** @class */ (function () {
5145
5150
  if (!cacheRecord.accessToken) return [3 /*break*/, 4];
5146
5151
  if (!(cacheRecord.accessToken.tokenType === exports.AuthenticationScheme.POP)) return [3 /*break*/, 2];
5147
5152
  popTokenGenerator = new PopTokenGenerator(cryptoObj);
5148
- return [4 /*yield*/, popTokenGenerator.signPopToken(cacheRecord.accessToken.secret, request)];
5153
+ _d = cacheRecord.accessToken, secret = _d.secret, keyId = _d.keyId;
5154
+ if (!keyId) {
5155
+ throw ClientAuthError.createKeyIdMissingError();
5156
+ }
5157
+ return [4 /*yield*/, popTokenGenerator.signPopToken(secret, keyId, request)];
5149
5158
  case 1:
5150
- accessToken = _d.sent();
5159
+ accessToken = _e.sent();
5151
5160
  return [3 /*break*/, 3];
5152
5161
  case 2:
5153
5162
  accessToken = cacheRecord.accessToken.secret;
5154
- _d.label = 3;
5163
+ _e.label = 3;
5155
5164
  case 3:
5156
5165
  responseScopes = ScopeSet.fromString(cacheRecord.accessToken.target).asArray();
5157
5166
  expiresOn = new Date(Number(cacheRecord.accessToken.expiresOn) * 1000);
5158
5167
  extExpiresOn = new Date(Number(cacheRecord.accessToken.extendedExpiresOn) * 1000);
5159
- _d.label = 4;
5168
+ _e.label = 4;
5160
5169
  case 4:
5161
5170
  if (cacheRecord.appMetadata) {
5162
5171
  familyId = cacheRecord.appMetadata.familyId === THE_FAMILY_ID ? THE_FAMILY_ID : Constants.EMPTY_STRING;
@@ -5191,7 +5200,7 @@ var ResponseHandler = /** @class */ (function () {
5191
5200
  return ResponseHandler;
5192
5201
  }());
5193
5202
 
5194
- /*! @azure/msal-common v6.3.0 2022-05-02 */
5203
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
5195
5204
 
5196
5205
  /*
5197
5206
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5358,7 +5367,7 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
5358
5367
  */
5359
5368
  AuthorizationCodeClient.prototype.createTokenRequestBody = function (request) {
5360
5369
  return __awaiter(this, void 0, void 0, function () {
5361
- var parameterBuilder, clientAssertion, popTokenGenerator, cnfString, correlationId, ccsCred, clientInfo, clientInfo;
5370
+ var parameterBuilder, clientAssertion, popTokenGenerator, reqCnfData, correlationId, ccsCred, clientInfo, clientInfo;
5362
5371
  var _a;
5363
5372
  return __generator(this, function (_b) {
5364
5373
  switch (_b.label) {
@@ -5395,8 +5404,8 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
5395
5404
  if (this.config.clientCredentials.clientSecret) {
5396
5405
  parameterBuilder.addClientSecret(this.config.clientCredentials.clientSecret);
5397
5406
  }
5398
- if (this.config.clientCredentials.clientAssertion) {
5399
- clientAssertion = this.config.clientCredentials.clientAssertion;
5407
+ clientAssertion = request.clientAssertion || this.config.clientCredentials.clientAssertion;
5408
+ if (clientAssertion) {
5400
5409
  parameterBuilder.addClientAssertion(clientAssertion.assertion);
5401
5410
  parameterBuilder.addClientAssertionType(clientAssertion.assertionType);
5402
5411
  }
@@ -5406,8 +5415,9 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
5406
5415
  popTokenGenerator = new PopTokenGenerator(this.cryptoUtils);
5407
5416
  return [4 /*yield*/, popTokenGenerator.generateCnf(request)];
5408
5417
  case 1:
5409
- cnfString = _b.sent();
5410
- parameterBuilder.addPopToken(cnfString);
5418
+ reqCnfData = _b.sent();
5419
+ // SPA PoP requires full Base64Url encoded req_cnf string (unhashed)
5420
+ parameterBuilder.addPopToken(reqCnfData.reqCnfString);
5411
5421
  return [3 /*break*/, 3];
5412
5422
  case 2:
5413
5423
  if (request.authenticationScheme === exports.AuthenticationScheme.SSH) {
@@ -5478,7 +5488,7 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
5478
5488
  */
5479
5489
  AuthorizationCodeClient.prototype.createAuthCodeUrlQueryString = function (request) {
5480
5490
  return __awaiter(this, void 0, void 0, function () {
5481
- var parameterBuilder, requestScopes, correlationId, accountSid, clientInfo, clientInfo, popTokenGenerator, cnf, cnfHash;
5491
+ var parameterBuilder, requestScopes, correlationId, accountSid, clientInfo, clientInfo, popTokenGenerator, reqCnfData;
5482
5492
  return __generator(this, function (_a) {
5483
5493
  switch (_a.label) {
5484
5494
  case 0:
@@ -5570,20 +5580,17 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
5570
5580
  if (request.extraQueryParameters) {
5571
5581
  parameterBuilder.addExtraQueryParameters(request.extraQueryParameters);
5572
5582
  }
5573
- if (!request.nativeBroker) return [3 /*break*/, 3];
5583
+ if (!request.nativeBroker) return [3 /*break*/, 2];
5574
5584
  // signal ests that this is a WAM call
5575
5585
  parameterBuilder.addNativeBroker();
5576
- if (!(request.authenticationScheme === exports.AuthenticationScheme.POP)) return [3 /*break*/, 3];
5586
+ if (!(request.authenticationScheme === exports.AuthenticationScheme.POP)) return [3 /*break*/, 2];
5577
5587
  popTokenGenerator = new PopTokenGenerator(this.cryptoUtils);
5578
5588
  return [4 /*yield*/, popTokenGenerator.generateCnf(request)];
5579
5589
  case 1:
5580
- cnf = _a.sent();
5581
- return [4 /*yield*/, popTokenGenerator.generateCnfHash(cnf)];
5582
- case 2:
5583
- cnfHash = _a.sent();
5584
- parameterBuilder.addPopToken(cnfHash);
5585
- _a.label = 3;
5586
- case 3: return [2 /*return*/, parameterBuilder.createQueryString()];
5590
+ reqCnfData = _a.sent();
5591
+ parameterBuilder.addPopToken(reqCnfData.reqCnfHash);
5592
+ _a.label = 2;
5593
+ case 2: return [2 /*return*/, parameterBuilder.createQueryString()];
5587
5594
  }
5588
5595
  });
5589
5596
  });
@@ -5628,7 +5635,7 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
5628
5635
  return AuthorizationCodeClient;
5629
5636
  }(BaseClient));
5630
5637
 
5631
- /*! @azure/msal-common v6.3.0 2022-05-02 */
5638
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
5632
5639
 
5633
5640
  /*
5634
5641
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5769,7 +5776,7 @@ var RefreshTokenClient = /** @class */ (function (_super) {
5769
5776
  */
5770
5777
  RefreshTokenClient.prototype.createTokenRequestBody = function (request) {
5771
5778
  return __awaiter(this, void 0, void 0, function () {
5772
- var parameterBuilder, correlationId, clientAssertion, popTokenGenerator, cnfString, clientInfo;
5779
+ var parameterBuilder, correlationId, clientAssertion, popTokenGenerator, reqCnfData, clientInfo;
5773
5780
  return __generator(this, function (_a) {
5774
5781
  switch (_a.label) {
5775
5782
  case 0:
@@ -5790,8 +5797,8 @@ var RefreshTokenClient = /** @class */ (function (_super) {
5790
5797
  if (this.config.clientCredentials.clientSecret) {
5791
5798
  parameterBuilder.addClientSecret(this.config.clientCredentials.clientSecret);
5792
5799
  }
5793
- if (this.config.clientCredentials.clientAssertion) {
5794
- clientAssertion = this.config.clientCredentials.clientAssertion;
5800
+ clientAssertion = request.clientAssertion || this.config.clientCredentials.clientAssertion;
5801
+ if (clientAssertion) {
5795
5802
  parameterBuilder.addClientAssertion(clientAssertion.assertion);
5796
5803
  parameterBuilder.addClientAssertionType(clientAssertion.assertionType);
5797
5804
  }
@@ -5799,8 +5806,9 @@ var RefreshTokenClient = /** @class */ (function (_super) {
5799
5806
  popTokenGenerator = new PopTokenGenerator(this.cryptoUtils);
5800
5807
  return [4 /*yield*/, popTokenGenerator.generateCnf(request)];
5801
5808
  case 1:
5802
- cnfString = _a.sent();
5803
- parameterBuilder.addPopToken(cnfString);
5809
+ reqCnfData = _a.sent();
5810
+ // SPA PoP requires full Base64Url encoded req_cnf string (unhashed)
5811
+ parameterBuilder.addPopToken(reqCnfData.reqCnfString);
5804
5812
  return [3 /*break*/, 3];
5805
5813
  case 2:
5806
5814
  if (request.authenticationScheme === exports.AuthenticationScheme.SSH) {
@@ -5840,7 +5848,7 @@ var RefreshTokenClient = /** @class */ (function (_super) {
5840
5848
  return RefreshTokenClient;
5841
5849
  }(BaseClient));
5842
5850
 
5843
- /*! @azure/msal-common v6.3.0 2022-05-02 */
5851
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
5844
5852
 
5845
5853
  /*
5846
5854
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5956,7 +5964,7 @@ var SilentFlowClient = /** @class */ (function (_super) {
5956
5964
  return SilentFlowClient;
5957
5965
  }(BaseClient));
5958
5966
 
5959
- /*! @azure/msal-common v6.3.0 2022-05-02 */
5967
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
5960
5968
  /*
5961
5969
  * Copyright (c) Microsoft Corporation. All rights reserved.
5962
5970
  * Licensed under the MIT License.
@@ -5967,7 +5975,7 @@ function isOpenIdConfigResponse(response) {
5967
5975
  response.hasOwnProperty("issuer"));
5968
5976
  }
5969
5977
 
5970
- /*! @azure/msal-common v6.3.0 2022-05-02 */
5978
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
5971
5979
  /*
5972
5980
  * Copyright (c) Microsoft Corporation. All rights reserved.
5973
5981
  * Licensed under the MIT License.
@@ -5981,7 +5989,7 @@ exports.ProtocolMode = void 0;
5981
5989
  ProtocolMode["OIDC"] = "OIDC";
5982
5990
  })(exports.ProtocolMode || (exports.ProtocolMode = {}));
5983
5991
 
5984
- /*! @azure/msal-common v6.3.0 2022-05-02 */
5992
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
5985
5993
 
5986
5994
  /*
5987
5995
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6056,7 +6064,7 @@ var AuthorityMetadataEntity = /** @class */ (function () {
6056
6064
  return AuthorityMetadataEntity;
6057
6065
  }());
6058
6066
 
6059
- /*! @azure/msal-common v6.3.0 2022-05-02 */
6067
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
6060
6068
  /*
6061
6069
  * Copyright (c) Microsoft Corporation. All rights reserved.
6062
6070
  * Licensed under the MIT License.
@@ -6066,7 +6074,7 @@ function isCloudInstanceDiscoveryResponse(response) {
6066
6074
  response.hasOwnProperty("metadata"));
6067
6075
  }
6068
6076
 
6069
- /*! @azure/msal-common v6.3.0 2022-05-02 */
6077
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
6070
6078
 
6071
6079
  /*
6072
6080
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6188,7 +6196,7 @@ var RegionDiscovery = /** @class */ (function () {
6188
6196
  return RegionDiscovery;
6189
6197
  }());
6190
6198
 
6191
- /*! @azure/msal-common v6.3.0 2022-05-02 */
6199
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
6192
6200
 
6193
6201
  /*
6194
6202
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6778,7 +6786,7 @@ var Authority = /** @class */ (function () {
6778
6786
  return Authority;
6779
6787
  }());
6780
6788
 
6781
- /*! @azure/msal-common v6.3.0 2022-05-02 */
6789
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
6782
6790
 
6783
6791
  /*
6784
6792
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6839,7 +6847,7 @@ var AuthorityFactory = /** @class */ (function () {
6839
6847
  return AuthorityFactory;
6840
6848
  }());
6841
6849
 
6842
- /*! @azure/msal-common v6.3.0 2022-05-02 */
6850
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
6843
6851
 
6844
6852
  /*
6845
6853
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6870,7 +6878,7 @@ var ServerTelemetryEntity = /** @class */ (function () {
6870
6878
  return ServerTelemetryEntity;
6871
6879
  }());
6872
6880
 
6873
- /*! @azure/msal-common v6.3.0 2022-05-02 */
6881
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
6874
6882
 
6875
6883
  /*
6876
6884
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6898,7 +6906,7 @@ var ThrottlingEntity = /** @class */ (function () {
6898
6906
  return ThrottlingEntity;
6899
6907
  }());
6900
6908
 
6901
- /*! @azure/msal-common v6.3.0 2022-05-02 */
6909
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
6902
6910
 
6903
6911
  /*
6904
6912
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6915,7 +6923,92 @@ var StubbedNetworkModule = {
6915
6923
  }
6916
6924
  };
6917
6925
 
6918
- /*! @azure/msal-common v6.3.0 2022-05-02 */
6926
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
6927
+
6928
+ /*
6929
+ * Copyright (c) Microsoft Corporation. All rights reserved.
6930
+ * Licensed under the MIT License.
6931
+ */
6932
+ /**
6933
+ * ClientAuthErrorMessage class containing string constants used by error codes and messages.
6934
+ */
6935
+ var JoseHeaderErrorMessage = {
6936
+ missingKidError: {
6937
+ code: "missing_kid_error",
6938
+ desc: "The JOSE Header for the requested JWT, JWS or JWK object requires a keyId to be configured as the 'kid' header claim. No 'kid' value was provided."
6939
+ },
6940
+ missingAlgError: {
6941
+ code: "missing_alg_error",
6942
+ desc: "The JOSE Header for the requested JWT, JWS or JWK object requires an algorithm to be specified as the 'alg' header claim. No 'alg' value was provided."
6943
+ },
6944
+ };
6945
+ /**
6946
+ * Error thrown when there is an error in the client code running on the browser.
6947
+ */
6948
+ var JoseHeaderError = /** @class */ (function (_super) {
6949
+ __extends(JoseHeaderError, _super);
6950
+ function JoseHeaderError(errorCode, errorMessage) {
6951
+ var _this = _super.call(this, errorCode, errorMessage) || this;
6952
+ _this.name = "JoseHeaderError";
6953
+ Object.setPrototypeOf(_this, JoseHeaderError.prototype);
6954
+ return _this;
6955
+ }
6956
+ /**
6957
+ * Creates an error thrown when keyId isn't set on JOSE header.
6958
+ */
6959
+ JoseHeaderError.createMissingKidError = function () {
6960
+ return new JoseHeaderError(JoseHeaderErrorMessage.missingKidError.code, JoseHeaderErrorMessage.missingKidError.desc);
6961
+ };
6962
+ /**
6963
+ * Creates an error thrown when algorithm isn't set on JOSE header.
6964
+ */
6965
+ JoseHeaderError.createMissingAlgError = function () {
6966
+ return new JoseHeaderError(JoseHeaderErrorMessage.missingAlgError.code, JoseHeaderErrorMessage.missingAlgError.desc);
6967
+ };
6968
+ return JoseHeaderError;
6969
+ }(AuthError));
6970
+
6971
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
6972
+
6973
+ /*
6974
+ * Copyright (c) Microsoft Corporation. All rights reserved.
6975
+ * Licensed under the MIT License.
6976
+ */
6977
+ var JoseHeader = /** @class */ (function () {
6978
+ function JoseHeader(options) {
6979
+ this.typ = options.typ;
6980
+ this.alg = options.alg;
6981
+ this.kid = options.kid;
6982
+ }
6983
+ /**
6984
+ * Builds SignedHttpRequest formatted JOSE Header from the
6985
+ * JOSE Header options provided or previously set on the object and returns
6986
+ * the stringified header object.
6987
+ * Throws if keyId or algorithm aren't provided since they are required for Access Token Binding.
6988
+ * @param shrHeaderOptions
6989
+ * @returns
6990
+ */
6991
+ JoseHeader.getShrHeaderString = function (shrHeaderOptions) {
6992
+ // KeyID is required on the SHR header
6993
+ if (!shrHeaderOptions.kid) {
6994
+ throw JoseHeaderError.createMissingKidError();
6995
+ }
6996
+ // Alg is required on the SHR header
6997
+ if (!shrHeaderOptions.alg) {
6998
+ throw JoseHeaderError.createMissingAlgError();
6999
+ }
7000
+ var shrHeader = new JoseHeader({
7001
+ // Access Token PoP headers must have type JWT, but the type header can be overriden for special cases
7002
+ typ: shrHeaderOptions.typ || JsonTypes.Jwt,
7003
+ kid: shrHeaderOptions.kid,
7004
+ alg: shrHeaderOptions.alg
7005
+ });
7006
+ return JSON.stringify(shrHeader);
7007
+ };
7008
+ return JoseHeader;
7009
+ }());
7010
+
7011
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
6919
7012
 
6920
7013
  /*
6921
7014
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6974,7 +7067,7 @@ var AuthenticationHeaderParser = /** @class */ (function () {
6974
7067
  return AuthenticationHeaderParser;
6975
7068
  }());
6976
7069
 
6977
- /*! @azure/msal-common v6.3.0 2022-05-02 */
7070
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
6978
7071
 
6979
7072
  /*
6980
7073
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7136,7 +7229,7 @@ var ServerTelemetryManager = /** @class */ (function () {
7136
7229
  return ServerTelemetryManager;
7137
7230
  }());
7138
7231
 
7139
- /*! @azure/msal-common v6.3.0 2022-05-02 */
7232
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
7140
7233
  /*
7141
7234
  * Copyright (c) Microsoft Corporation. All rights reserved.
7142
7235
  * Licensed under the MIT License.
@@ -7233,7 +7326,7 @@ var PerformanceEventStatus;
7233
7326
  PerformanceEventStatus[PerformanceEventStatus["Completed"] = 2] = "Completed";
7234
7327
  })(PerformanceEventStatus || (PerformanceEventStatus = {}));
7235
7328
 
7236
- /*! @azure/msal-common v6.3.0 2022-05-02 */
7329
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
7237
7330
 
7238
7331
  /*
7239
7332
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7503,7 +7596,7 @@ var PerformanceClient = /** @class */ (function () {
7503
7596
  return PerformanceClient;
7504
7597
  }());
7505
7598
 
7506
- /*! @azure/msal-common v6.3.0 2022-05-02 */
7599
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
7507
7600
 
7508
7601
  /*
7509
7602
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7561,7 +7654,7 @@ var BrowserAuthErrorMessage = {
7561
7654
  },
7562
7655
  hashEmptyError: {
7563
7656
  code: "hash_empty_error",
7564
- desc: "Hash value cannot be processed because it is empty. Please verify that your redirectUri is not clearing the hash."
7657
+ desc: "Hash value cannot be processed because it is empty. Please verify that your redirectUri is not clearing the hash. For more visit: aka.ms/msaljs/browser-errors."
7565
7658
  },
7566
7659
  hashDoesNotContainStateError: {
7567
7660
  code: "no_state_in_hash",
@@ -7569,7 +7662,7 @@ var BrowserAuthErrorMessage = {
7569
7662
  },
7570
7663
  hashDoesNotContainKnownPropertiesError: {
7571
7664
  code: "hash_does_not_contain_known_properties",
7572
- desc: "Hash does not contain known properites. Please verify that your redirectUri is not changing the hash."
7665
+ desc: "Hash does not contain known properites. Please verify that your redirectUri is not changing the hash. For more visit: aka.ms/msaljs/browser-errors."
7573
7666
  },
7574
7667
  unableToParseStateError: {
7575
7668
  code: "unable_to_parse_state",
@@ -9299,7 +9392,7 @@ var DEFAULT_BROWSER_CACHE_MANAGER = function (clientId, logger) {
9299
9392
 
9300
9393
  /* eslint-disable header/header */
9301
9394
  var name = "@azure/msal-browser";
9302
- var version = "2.24.0";
9395
+ var version = "2.25.0";
9303
9396
 
9304
9397
  /*
9305
9398
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -10152,11 +10245,11 @@ var StandardInteractionClient = /** @class */ (function (_super) {
10152
10245
  * Abstract class which defines operations for a browser interaction handling class.
10153
10246
  */
10154
10247
  var InteractionHandler = /** @class */ (function () {
10155
- function InteractionHandler(authCodeModule, storageImpl, authCodeRequest, browserRequestLogger) {
10248
+ function InteractionHandler(authCodeModule, storageImpl, authCodeRequest, logger) {
10156
10249
  this.authModule = authCodeModule;
10157
10250
  this.browserStorage = storageImpl;
10158
10251
  this.authCodeRequest = authCodeRequest;
10159
- this.browserRequestLogger = browserRequestLogger;
10252
+ this.logger = logger;
10160
10253
  }
10161
10254
  /**
10162
10255
  * Function to handle response parameters from hash.
@@ -10166,7 +10259,7 @@ var InteractionHandler = /** @class */ (function () {
10166
10259
  return __awaiter$1(this, void 0, void 0, function () {
10167
10260
  var stateKey, requestState, authCodeResponse;
10168
10261
  return __generator$1(this, function (_a) {
10169
- this.browserRequestLogger.verbose("InteractionHandler.handleCodeResponse called");
10262
+ this.logger.verbose("InteractionHandler.handleCodeResponse called");
10170
10263
  // Check that location hash isn't empty.
10171
10264
  if (StringUtils.isEmpty(locationHash)) {
10172
10265
  throw BrowserAuthError.createEmptyHashError(locationHash);
@@ -10207,7 +10300,7 @@ var InteractionHandler = /** @class */ (function () {
10207
10300
  return __generator$1(this, function (_a) {
10208
10301
  switch (_a.label) {
10209
10302
  case 0:
10210
- this.browserRequestLogger.trace("InteractionHandler.handleCodeResponseFromServer called");
10303
+ this.logger.trace("InteractionHandler.handleCodeResponseFromServer called");
10211
10304
  stateKey = this.browserStorage.generateStateKey(state);
10212
10305
  requestState = this.browserStorage.getTemporaryCache(stateKey);
10213
10306
  if (!requestState) {
@@ -10295,8 +10388,8 @@ var InteractionHandler = /** @class */ (function () {
10295
10388
  */
10296
10389
  var RedirectHandler = /** @class */ (function (_super) {
10297
10390
  __extends$1(RedirectHandler, _super);
10298
- function RedirectHandler(authCodeModule, storageImpl, authCodeRequest, browserRequestLogger, browserCrypto) {
10299
- var _this = _super.call(this, authCodeModule, storageImpl, authCodeRequest, browserRequestLogger) || this;
10391
+ function RedirectHandler(authCodeModule, storageImpl, authCodeRequest, logger, browserCrypto) {
10392
+ var _this = _super.call(this, authCodeModule, storageImpl, authCodeRequest, logger) || this;
10300
10393
  _this.browserCrypto = browserCrypto;
10301
10394
  return _this;
10302
10395
  }
@@ -10310,38 +10403,38 @@ var RedirectHandler = /** @class */ (function (_super) {
10310
10403
  return __generator$1(this, function (_a) {
10311
10404
  switch (_a.label) {
10312
10405
  case 0:
10313
- this.browserRequestLogger.verbose("RedirectHandler.initiateAuthRequest called");
10406
+ this.logger.verbose("RedirectHandler.initiateAuthRequest called");
10314
10407
  if (!!StringUtils.isEmpty(requestUrl)) return [3 /*break*/, 7];
10315
10408
  // Cache start page, returns to this page after redirectUri if navigateToLoginRequestUrl is true
10316
10409
  if (params.redirectStartPage) {
10317
- this.browserRequestLogger.verbose("RedirectHandler.initiateAuthRequest: redirectStartPage set, caching start page");
10410
+ this.logger.verbose("RedirectHandler.initiateAuthRequest: redirectStartPage set, caching start page");
10318
10411
  this.browserStorage.setTemporaryCache(TemporaryCacheKeys.ORIGIN_URI, params.redirectStartPage, true);
10319
10412
  }
10320
10413
  // Set interaction status in the library.
10321
10414
  this.browserStorage.setTemporaryCache(TemporaryCacheKeys.CORRELATION_ID, this.authCodeRequest.correlationId, true);
10322
10415
  this.browserStorage.cacheCodeRequest(this.authCodeRequest, this.browserCrypto);
10323
- this.browserRequestLogger.infoPii("RedirectHandler.initiateAuthRequest: Navigate to: " + requestUrl);
10416
+ this.logger.infoPii("RedirectHandler.initiateAuthRequest: Navigate to: " + requestUrl);
10324
10417
  navigationOptions = {
10325
10418
  apiId: exports.ApiId.acquireTokenRedirect,
10326
10419
  timeout: params.redirectTimeout,
10327
10420
  noHistory: false
10328
10421
  };
10329
10422
  if (!(typeof params.onRedirectNavigate === "function")) return [3 /*break*/, 4];
10330
- this.browserRequestLogger.verbose("RedirectHandler.initiateAuthRequest: Invoking onRedirectNavigate callback");
10423
+ this.logger.verbose("RedirectHandler.initiateAuthRequest: Invoking onRedirectNavigate callback");
10331
10424
  navigate = params.onRedirectNavigate(requestUrl);
10332
10425
  if (!(navigate !== false)) return [3 /*break*/, 2];
10333
- this.browserRequestLogger.verbose("RedirectHandler.initiateAuthRequest: onRedirectNavigate did not return false, navigating");
10426
+ this.logger.verbose("RedirectHandler.initiateAuthRequest: onRedirectNavigate did not return false, navigating");
10334
10427
  return [4 /*yield*/, params.navigationClient.navigateExternal(requestUrl, navigationOptions)];
10335
10428
  case 1:
10336
10429
  _a.sent();
10337
10430
  return [2 /*return*/];
10338
10431
  case 2:
10339
- this.browserRequestLogger.verbose("RedirectHandler.initiateAuthRequest: onRedirectNavigate returned false, stopping navigation");
10432
+ this.logger.verbose("RedirectHandler.initiateAuthRequest: onRedirectNavigate returned false, stopping navigation");
10340
10433
  return [2 /*return*/];
10341
10434
  case 3: return [3 /*break*/, 6];
10342
10435
  case 4:
10343
10436
  // Navigate window to request URL
10344
- this.browserRequestLogger.verbose("RedirectHandler.initiateAuthRequest: Navigating window to navigate url");
10437
+ this.logger.verbose("RedirectHandler.initiateAuthRequest: Navigating window to navigate url");
10345
10438
  return [4 /*yield*/, params.navigationClient.navigateExternal(requestUrl, navigationOptions)];
10346
10439
  case 5:
10347
10440
  _a.sent();
@@ -10349,7 +10442,7 @@ var RedirectHandler = /** @class */ (function (_super) {
10349
10442
  case 6: return [3 /*break*/, 8];
10350
10443
  case 7:
10351
10444
  // Throw error if request URL is empty.
10352
- this.browserRequestLogger.info("RedirectHandler.initiateAuthRequest: Navigate url is empty");
10445
+ this.logger.info("RedirectHandler.initiateAuthRequest: Navigate url is empty");
10353
10446
  throw BrowserAuthError.createEmptyNavigationUriError();
10354
10447
  case 8: return [2 /*return*/];
10355
10448
  }
@@ -10366,7 +10459,7 @@ var RedirectHandler = /** @class */ (function (_super) {
10366
10459
  return __generator$1(this, function (_a) {
10367
10460
  switch (_a.label) {
10368
10461
  case 0:
10369
- this.browserRequestLogger.verbose("RedirectHandler.handleCodeResponse called");
10462
+ this.logger.verbose("RedirectHandler.handleCodeResponse called");
10370
10463
  // Check that location hash isn't empty.
10371
10464
  if (StringUtils.isEmpty(locationHash)) {
10372
10465
  throw BrowserAuthError.createEmptyHashError(locationHash);
@@ -10467,6 +10560,7 @@ var NativeStatusCode;
10467
10560
  NativeStatusCode["NO_NETWORK"] = "NO_NETWORK";
10468
10561
  NativeStatusCode["TRANSIENT_ERROR"] = "TRANSIENT_ERROR";
10469
10562
  NativeStatusCode["PERSISTENT_ERROR"] = "PERSISTENT_ERROR";
10563
+ NativeStatusCode["DISABLED"] = "DISABLED";
10470
10564
  })(NativeStatusCode || (NativeStatusCode = {}));
10471
10565
  var NativeAuthErrorMessage = {
10472
10566
  extensionError: {
@@ -10490,7 +10584,7 @@ var NativeAuthError = /** @class */ (function (_super) {
10490
10584
  * These errors should result in a fallback to the 'standard' browser based auth flow.
10491
10585
  */
10492
10586
  NativeAuthError.prototype.isFatal = function () {
10493
- if (this.ext && this.ext.status && this.ext.status === NativeStatusCode.PERSISTENT_ERROR) {
10587
+ if (this.ext && this.ext.status && (this.ext.status === NativeStatusCode.PERSISTENT_ERROR || this.ext.status === NativeStatusCode.DISABLED)) {
10494
10588
  return true;
10495
10589
  }
10496
10590
  switch (this.errorCode) {
@@ -10719,7 +10813,7 @@ var NativeInteractionClient = /** @class */ (function (_super) {
10719
10813
  uid = accountProperties["UID"] || idTokenObj.claims.oid || idTokenObj.claims.sub || Constants.EMPTY_STRING;
10720
10814
  tid = accountProperties["TenantId"] || idTokenObj.claims.tid || Constants.EMPTY_STRING;
10721
10815
  responseTokenType = exports.AuthenticationScheme.BEARER;
10722
- _a = request.token_type;
10816
+ _a = request.tokenType;
10723
10817
  switch (_a) {
10724
10818
  case exports.AuthenticationScheme.POP: return [3 /*break*/, 2];
10725
10819
  }
@@ -10740,7 +10834,14 @@ var NativeInteractionClient = /** @class */ (function (_super) {
10740
10834
  shrClaims: request.shrClaims,
10741
10835
  shrNonce: request.shrNonce
10742
10836
  };
10743
- return [4 /*yield*/, popTokenGenerator.signPopToken(response.access_token, shrParameters)];
10837
+ /**
10838
+ * KeyID must be present in the native request from when the PoP key was generated in order for
10839
+ * PopTokenGenerator to query the full key for signing
10840
+ */
10841
+ if (!request.keyId) {
10842
+ throw ClientAuthError.createKeyIdMissingError();
10843
+ }
10844
+ return [4 /*yield*/, popTokenGenerator.signPopToken(response.access_token, request.keyId, shrParameters)];
10744
10845
  case 3:
10745
10846
  responseAccessToken = _b.sent();
10746
10847
  return [3 /*break*/, 5];
@@ -10798,9 +10899,9 @@ var NativeInteractionClient = /** @class */ (function (_super) {
10798
10899
  */
10799
10900
  NativeInteractionClient.prototype.initializeNativeRequest = function (request) {
10800
10901
  return __awaiter$1(this, void 0, void 0, function () {
10801
- var authority, canonicalAuthority, scopes, scopeSet, instanceAware, validatedRequest, shrParameters, popTokenGenerator, cnf, _a;
10802
- return __generator$1(this, function (_b) {
10803
- switch (_b.label) {
10902
+ var authority, canonicalAuthority, scopes, scopeSet, validatedRequest, shrParameters, popTokenGenerator, reqCnfData;
10903
+ return __generator$1(this, function (_a) {
10904
+ switch (_a.label) {
10804
10905
  case 0:
10805
10906
  this.logger.trace("NativeInteractionClient - initializeNativeRequest called");
10806
10907
  authority = request.authority || this.config.auth.authority;
@@ -10820,10 +10921,9 @@ var NativeInteractionClient = /** @class */ (function (_super) {
10820
10921
  throw BrowserAuthError.createNativePromptParameterNotSupportedError();
10821
10922
  }
10822
10923
  }
10823
- instanceAware = !!(request.extraQueryParameters && request.extraQueryParameters.instance_aware);
10824
- validatedRequest = __assign$1(__assign$1({}, request), { accountId: this.accountId, clientId: this.config.auth.clientId, authority: canonicalAuthority.urlString, scopes: scopeSet.printScopes(), redirectUri: this.getRedirectUri(request.redirectUri), correlationId: this.correlationId, instance_aware: instanceAware, token_type: request.authenticationScheme, windowTitleSubstring: document.title, extraParameters: __assign$1(__assign$1({}, request.extraQueryParameters), request.tokenQueryParameters), extendedExpiryToken: false // Make this configurable?
10924
+ validatedRequest = __assign$1(__assign$1({}, request), { accountId: this.accountId, clientId: this.config.auth.clientId, authority: canonicalAuthority.urlString, scopes: scopeSet.printScopes(), redirectUri: this.getRedirectUri(request.redirectUri), correlationId: this.correlationId, tokenType: request.authenticationScheme, windowTitleSubstring: document.title, extraParameters: __assign$1(__assign$1({}, request.extraQueryParameters), request.tokenQueryParameters), extendedExpiryToken: false // Make this configurable?
10825
10925
  });
10826
- if (!(request.authenticationScheme === exports.AuthenticationScheme.POP)) return [3 /*break*/, 3];
10926
+ if (!(request.authenticationScheme === exports.AuthenticationScheme.POP)) return [3 /*break*/, 2];
10827
10927
  shrParameters = {
10828
10928
  resourceRequestUri: request.resourceRequestUri,
10829
10929
  resourceRequestMethod: request.resourceRequestMethod,
@@ -10833,15 +10933,12 @@ var NativeInteractionClient = /** @class */ (function (_super) {
10833
10933
  popTokenGenerator = new PopTokenGenerator(this.browserCrypto);
10834
10934
  return [4 /*yield*/, popTokenGenerator.generateCnf(shrParameters)];
10835
10935
  case 1:
10836
- cnf = _b.sent();
10936
+ reqCnfData = _a.sent();
10837
10937
  // to reduce the URL length, it is recommended to send the hash of the req_cnf instead of the whole string
10838
- _a = validatedRequest;
10839
- return [4 /*yield*/, popTokenGenerator.generateCnfHash(cnf)];
10938
+ validatedRequest.reqCnf = reqCnfData.reqCnfHash;
10939
+ validatedRequest.keyId = reqCnfData.kid;
10940
+ _a.label = 2;
10840
10941
  case 2:
10841
- // to reduce the URL length, it is recommended to send the hash of the req_cnf instead of the whole string
10842
- _a.req_cnf = _b.sent();
10843
- _b.label = 3;
10844
- case 3:
10845
10942
  if (this.apiId === exports.ApiId.ssoSilent || this.apiId === exports.ApiId.acquireTokenSilent_silentFlow) {
10846
10943
  validatedRequest.prompt = PromptValue.NONE;
10847
10944
  }
@@ -11417,249 +11514,17 @@ var RedirectClient = /** @class */ (function (_super) {
11417
11514
  return RedirectClient;
11418
11515
  }(StandardInteractionClient));
11419
11516
 
11420
- /*
11421
- * Copyright (c) Microsoft Corporation. All rights reserved.
11422
- * Licensed under the MIT License.
11423
- */
11424
- var PopupUtils = /** @class */ (function () {
11425
- function PopupUtils(storageImpl, logger) {
11426
- this.browserStorage = storageImpl;
11427
- this.logger = logger;
11428
- // Properly sets this reference for the unload event.
11429
- this.unloadWindow = this.unloadWindow.bind(this);
11430
- }
11431
- /**
11432
- * @hidden
11433
- *
11434
- * Configures popup window for login.
11435
- *
11436
- * @param urlNavigate
11437
- * @param title
11438
- * @param popUpWidth
11439
- * @param popUpHeight
11440
- * @param popupWindowAttributes
11441
- * @ignore
11442
- * @hidden
11443
- */
11444
- PopupUtils.prototype.openPopup = function (urlNavigate, popupParams) {
11445
- try {
11446
- var popupWindow = void 0;
11447
- // Popup window passed in, setting url to navigate to
11448
- if (popupParams.popup) {
11449
- popupWindow = popupParams.popup;
11450
- this.logger.verbosePii("Navigating popup window to: " + urlNavigate);
11451
- popupWindow.location.assign(urlNavigate);
11452
- }
11453
- else if (typeof popupParams.popup === "undefined") {
11454
- // Popup will be undefined if it was not passed in
11455
- this.logger.verbosePii("Opening popup window to: " + urlNavigate);
11456
- popupWindow = PopupUtils.openSizedPopup(urlNavigate, popupParams.popupName, popupParams.popupWindowAttributes, this.logger);
11457
- }
11458
- // Popup will be null if popups are blocked
11459
- if (!popupWindow) {
11460
- throw BrowserAuthError.createEmptyWindowCreatedError();
11461
- }
11462
- if (popupWindow.focus) {
11463
- popupWindow.focus();
11464
- }
11465
- this.currentWindow = popupWindow;
11466
- window.addEventListener("beforeunload", this.unloadWindow);
11467
- return popupWindow;
11468
- }
11469
- catch (e) {
11470
- this.logger.error("error opening popup " + e.message);
11471
- this.browserStorage.setInteractionInProgress(false);
11472
- throw BrowserAuthError.createPopupWindowError(e.toString());
11473
- }
11474
- };
11475
- /**
11476
- * Helper function to set popup window dimensions and position
11477
- * @param urlNavigate
11478
- * @param popupName
11479
- * @param popupWindowAttributes
11480
- * @returns
11481
- */
11482
- PopupUtils.openSizedPopup = function (urlNavigate, popupName, popupWindowAttributes, logger) {
11483
- var _a, _b, _c, _d;
11484
- /**
11485
- * adding winLeft and winTop to account for dual monitor
11486
- * using screenLeft and screenTop for IE8 and earlier
11487
- */
11488
- var winLeft = window.screenLeft ? window.screenLeft : window.screenX;
11489
- var winTop = window.screenTop ? window.screenTop : window.screenY;
11490
- /**
11491
- * window.innerWidth displays browser window"s height and width excluding toolbars
11492
- * using document.documentElement.clientWidth for IE8 and earlier
11493
- */
11494
- var winWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
11495
- var winHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
11496
- var width = (_a = popupWindowAttributes.popupSize) === null || _a === void 0 ? void 0 : _a.width;
11497
- var height = (_b = popupWindowAttributes.popupSize) === null || _b === void 0 ? void 0 : _b.height;
11498
- var top = (_c = popupWindowAttributes.popupPosition) === null || _c === void 0 ? void 0 : _c.top;
11499
- var left = (_d = popupWindowAttributes.popupPosition) === null || _d === void 0 ? void 0 : _d.left;
11500
- if (!width || width < 0 || width > winWidth) {
11501
- logger.verbose("Default popup window width used. Window width not configured or invalid.");
11502
- width = BrowserConstants.POPUP_WIDTH;
11503
- }
11504
- if (!height || height < 0 || height > winHeight) {
11505
- logger.verbose("Default popup window height used. Window height not configured or invalid.");
11506
- height = BrowserConstants.POPUP_HEIGHT;
11507
- }
11508
- if (!top || top < 0 || top > winHeight) {
11509
- logger.verbose("Default popup window top position used. Window top not configured or invalid.");
11510
- top = Math.max(0, ((winHeight / 2) - (BrowserConstants.POPUP_HEIGHT / 2)) + winTop);
11511
- }
11512
- if (!left || left < 0 || left > winWidth) {
11513
- logger.verbose("Default popup window left position used. Window left not configured or invalid.");
11514
- left = Math.max(0, ((winWidth / 2) - (BrowserConstants.POPUP_WIDTH / 2)) + winLeft);
11515
- }
11516
- return window.open(urlNavigate, popupName, "width=" + width + ", height=" + height + ", top=" + top + ", left=" + left + ", scrollbars=yes");
11517
- };
11518
- /**
11519
- * Event callback to unload main window.
11520
- */
11521
- PopupUtils.prototype.unloadWindow = function (e) {
11522
- this.browserStorage.cleanRequestByInteractionType(exports.InteractionType.Popup);
11523
- if (this.currentWindow) {
11524
- this.currentWindow.close();
11525
- }
11526
- // Guarantees browser unload will happen, so no other errors will be thrown.
11527
- e.preventDefault();
11528
- };
11529
- /**
11530
- * Closes popup, removes any state vars created during popup calls.
11531
- * @param popupWindow
11532
- */
11533
- PopupUtils.prototype.cleanPopup = function (popupWindow) {
11534
- if (popupWindow) {
11535
- // Close window.
11536
- popupWindow.close();
11537
- }
11538
- // Remove window unload function
11539
- window.removeEventListener("beforeunload", this.unloadWindow);
11540
- // Interaction is completed - remove interaction status.
11541
- this.browserStorage.setInteractionInProgress(false);
11542
- };
11543
- /**
11544
- * Monitors a window until it loads a url with the same origin.
11545
- * @param popupWindow - window that is being monitored
11546
- */
11547
- PopupUtils.prototype.monitorPopupForSameOrigin = function (popupWindow) {
11548
- var _this = this;
11549
- return new Promise(function (resolve, reject) {
11550
- var intervalId = setInterval(function () {
11551
- if (popupWindow.closed) {
11552
- // Window is closed
11553
- _this.cleanPopup();
11554
- clearInterval(intervalId);
11555
- reject(BrowserAuthError.createUserCancelledError());
11556
- return;
11557
- }
11558
- var href = Constants.EMPTY_STRING;
11559
- try {
11560
- /*
11561
- * Will throw if cross origin,
11562
- * which should be caught and ignored
11563
- * since we need the interval to keep running while on STS UI.
11564
- */
11565
- href = popupWindow.location.href;
11566
- }
11567
- catch (e) { }
11568
- // Don't process blank pages or cross domain
11569
- if (StringUtils.isEmpty(href) || href === "about:blank") {
11570
- return;
11571
- }
11572
- clearInterval(intervalId);
11573
- resolve();
11574
- }, BrowserConstants.POLL_INTERVAL_MS);
11575
- });
11576
- };
11577
- /**
11578
- * Generates the name for the popup based on the client id and request
11579
- * @param clientId
11580
- * @param request
11581
- */
11582
- PopupUtils.generatePopupName = function (clientId, scopes, authority, correlationId) {
11583
- return BrowserConstants.POPUP_NAME_PREFIX + "." + clientId + "." + scopes.join("-") + "." + authority + "." + correlationId;
11584
- };
11585
- /**
11586
- * Generates the name for the popup based on the client id and request for logouts
11587
- * @param clientId
11588
- * @param request
11589
- */
11590
- PopupUtils.generateLogoutPopupName = function (clientId, request) {
11591
- var homeAccountId = request.account && request.account.homeAccountId;
11592
- return BrowserConstants.POPUP_NAME_PREFIX + "." + clientId + "." + homeAccountId + "." + request.correlationId;
11593
- };
11594
- return PopupUtils;
11595
- }());
11596
-
11597
- /*
11598
- * Copyright (c) Microsoft Corporation. All rights reserved.
11599
- * Licensed under the MIT License.
11600
- */
11601
- /**
11602
- * This class implements the interaction handler base class for browsers. It is written specifically for handling
11603
- * popup window scenarios. It includes functions for monitoring the popup window for a hash.
11604
- */
11605
- var PopupHandler = /** @class */ (function (_super) {
11606
- __extends$1(PopupHandler, _super);
11607
- function PopupHandler(authCodeModule, storageImpl, authCodeRequest, browserRequestLogger) {
11608
- var _this = _super.call(this, authCodeModule, storageImpl, authCodeRequest, browserRequestLogger) || this;
11609
- // Properly sets this reference for the unload event.
11610
- _this.popupUtils = new PopupUtils(storageImpl, browserRequestLogger);
11611
- return _this;
11612
- }
11613
- /**
11614
- * Opens a popup window with given request Url.
11615
- * @param requestUrl
11616
- */
11617
- PopupHandler.prototype.initiateAuthRequest = function (requestUrl, params) {
11618
- // Check that request url is not empty.
11619
- if (!StringUtils.isEmpty(requestUrl)) {
11620
- this.browserRequestLogger.infoPii("Navigate to: " + requestUrl);
11621
- // Open the popup window to requestUrl.
11622
- return this.popupUtils.openPopup(requestUrl, params);
11623
- }
11624
- else {
11625
- // Throw error if request URL is empty.
11626
- this.browserRequestLogger.error("Navigate url is empty");
11627
- throw BrowserAuthError.createEmptyNavigationUriError();
11628
- }
11629
- };
11630
- /**
11631
- * Monitors a window until it loads a url with a known hash, or hits a specified timeout.
11632
- * @param popupWindow - window that is being monitored
11633
- * @param timeout - milliseconds until timeout
11634
- */
11635
- PopupHandler.prototype.monitorPopupForHash = function (popupWindow) {
11636
- var _this = this;
11637
- return this.popupUtils.monitorPopupForSameOrigin(popupWindow).then(function () {
11638
- var contentHash = popupWindow.location.hash;
11639
- BrowserUtils.clearHash(popupWindow);
11640
- _this.popupUtils.cleanPopup(popupWindow);
11641
- if (!contentHash) {
11642
- throw BrowserAuthError.createEmptyHashError(popupWindow.location.href);
11643
- }
11644
- if (UrlString.hashContainsKnownProperties(contentHash)) {
11645
- return contentHash;
11646
- }
11647
- else {
11648
- throw BrowserAuthError.createHashDoesNotContainKnownPropertiesError();
11649
- }
11650
- });
11651
- };
11652
- return PopupHandler;
11653
- }(InteractionHandler));
11654
-
11655
11517
  /*
11656
11518
  * Copyright (c) Microsoft Corporation. All rights reserved.
11657
11519
  * Licensed under the MIT License.
11658
11520
  */
11659
11521
  var PopupClient = /** @class */ (function (_super) {
11660
11522
  __extends$1(PopupClient, _super);
11661
- function PopupClient() {
11662
- return _super !== null && _super.apply(this, arguments) || this;
11523
+ function PopupClient(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, performanceClient, nativeMessageHandler, correlationId) {
11524
+ var _this = _super.call(this, config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, performanceClient, nativeMessageHandler, correlationId) || this;
11525
+ // Properly sets this reference for the unload event.
11526
+ _this.unloadWindow = _this.unloadWindow.bind(_this);
11527
+ return _this;
11663
11528
  }
11664
11529
  /**
11665
11530
  * Acquires tokens by opening a popup window to the /authorize endpoint of the authority
@@ -11667,7 +11532,7 @@ var PopupClient = /** @class */ (function (_super) {
11667
11532
  */
11668
11533
  PopupClient.prototype.acquireToken = function (request) {
11669
11534
  try {
11670
- var popupName = PopupUtils.generatePopupName(this.config.auth.clientId, request.scopes || OIDC_DEFAULT_SCOPES, request.authority || this.config.auth.authority, this.correlationId);
11535
+ var popupName = this.generatePopupName(request.scopes || OIDC_DEFAULT_SCOPES, request.authority || this.config.auth.authority);
11671
11536
  var popupWindowAttributes = request.popupWindowAttributes || {};
11672
11537
  // asyncPopups flag is true. Acquires token without first opening popup. Popup will be opened later asynchronously.
11673
11538
  if (this.config.system.asyncPopups) {
@@ -11678,7 +11543,7 @@ var PopupClient = /** @class */ (function (_super) {
11678
11543
  else {
11679
11544
  // asyncPopups flag is set to false. Opens popup before acquiring token.
11680
11545
  this.logger.verbose("asyncPopup set to false, opening popup before acquiring token");
11681
- var popup = PopupUtils.openSizedPopup("about:blank", popupName, popupWindowAttributes, this.logger);
11546
+ var popup = this.openSizedPopup("about:blank", popupName, popupWindowAttributes);
11682
11547
  return this.acquireTokenPopupAsync(request, popupName, popupWindowAttributes, popup);
11683
11548
  }
11684
11549
  }
@@ -11694,7 +11559,7 @@ var PopupClient = /** @class */ (function (_super) {
11694
11559
  try {
11695
11560
  this.logger.verbose("logoutPopup called");
11696
11561
  var validLogoutRequest = this.initializeLogoutRequest(logoutRequest);
11697
- var popupName = PopupUtils.generateLogoutPopupName(this.config.auth.clientId, validLogoutRequest);
11562
+ var popupName = this.generateLogoutPopupName(validLogoutRequest);
11698
11563
  var authority = logoutRequest && logoutRequest.authority;
11699
11564
  var mainWindowRedirectUri = logoutRequest && logoutRequest.mainWindowRedirectUri;
11700
11565
  var popupWindowAttributes = (logoutRequest === null || logoutRequest === void 0 ? void 0 : logoutRequest.popupWindowAttributes) || {};
@@ -11707,7 +11572,7 @@ var PopupClient = /** @class */ (function (_super) {
11707
11572
  else {
11708
11573
  // asyncPopups flag is set to false. Opens popup before logging out.
11709
11574
  this.logger.verbose("asyncPopup set to false, opening popup");
11710
- var popup = PopupUtils.openSizedPopup("about:blank", popupName, popupWindowAttributes, this.logger);
11575
+ var popup = this.openSizedPopup("about:blank", popupName, popupWindowAttributes);
11711
11576
  return this.logoutPopupAsync(validLogoutRequest, popupName, popupWindowAttributes, authority, popup, mainWindowRedirectUri);
11712
11577
  }
11713
11578
  }
@@ -11756,15 +11621,15 @@ var PopupClient = /** @class */ (function (_super) {
11756
11621
  return [4 /*yield*/, authClient.getAuthCodeUrl(__assign$1(__assign$1({}, validRequest), { nativeBroker: isNativeBroker }))];
11757
11622
  case 5:
11758
11623
  navigateUrl = _a.sent();
11759
- interactionHandler = new PopupHandler(authClient, this.browserStorage, authCodeRequest, this.logger);
11624
+ interactionHandler = new InteractionHandler(authClient, this.browserStorage, authCodeRequest, this.logger);
11760
11625
  popupParameters = {
11761
11626
  popup: popup,
11762
11627
  popupName: popupName,
11763
11628
  popupWindowAttributes: popupWindowAttributes
11764
11629
  };
11765
- popupWindow = interactionHandler.initiateAuthRequest(navigateUrl, popupParameters);
11630
+ popupWindow = this.initiateAuthRequest(navigateUrl, popupParameters);
11766
11631
  this.eventHandler.emitEvent(exports.EventType.POPUP_OPENED, exports.InteractionType.Popup, { popupWindow: popupWindow }, null);
11767
- return [4 /*yield*/, interactionHandler.monitorPopupForHash(popupWindow)];
11632
+ return [4 /*yield*/, this.monitorPopupForHash(popupWindow)];
11768
11633
  case 6:
11769
11634
  hash = _a.sent();
11770
11635
  serverParams = UrlString.getDeserializedHash(hash);
@@ -11822,7 +11687,7 @@ var PopupClient = /** @class */ (function (_super) {
11822
11687
  */
11823
11688
  PopupClient.prototype.logoutPopupAsync = function (validRequest, popupName, popupWindowAttributes, requestAuthority, popup, mainWindowRedirectUri) {
11824
11689
  return __awaiter$1(this, void 0, void 0, function () {
11825
- var serverTelemetryManager, authClient, logoutUri, popupUtils, popupWindow, e_2, navigationOptions, absoluteUrl, e_3;
11690
+ var serverTelemetryManager, authClient, logoutUri, popupWindow, navigationOptions, absoluteUrl, e_2;
11826
11691
  return __generator$1(this, function (_a) {
11827
11692
  switch (_a.label) {
11828
11693
  case 0:
@@ -11831,7 +11696,7 @@ var PopupClient = /** @class */ (function (_super) {
11831
11696
  serverTelemetryManager = this.initializeServerTelemetryManager(exports.ApiId.logoutPopup);
11832
11697
  _a.label = 1;
11833
11698
  case 1:
11834
- _a.trys.push([1, 8, , 9]);
11699
+ _a.trys.push([1, 5, , 6]);
11835
11700
  // Clear cache on logout
11836
11701
  return [4 /*yield*/, this.clearCacheOnLogout(validRequest.account)];
11837
11702
  case 2:
@@ -11843,25 +11708,11 @@ var PopupClient = /** @class */ (function (_super) {
11843
11708
  this.logger.verbose("Auth code client created");
11844
11709
  logoutUri = authClient.getLogoutUri(validRequest);
11845
11710
  this.eventHandler.emitEvent(exports.EventType.LOGOUT_SUCCESS, exports.InteractionType.Popup, validRequest);
11846
- popupUtils = new PopupUtils(this.browserStorage, this.logger);
11847
- popupWindow = popupUtils.openPopup(logoutUri, { popupName: popupName, popupWindowAttributes: popupWindowAttributes, popup: popup });
11711
+ popupWindow = this.openPopup(logoutUri, { popupName: popupName, popupWindowAttributes: popupWindowAttributes, popup: popup });
11848
11712
  this.eventHandler.emitEvent(exports.EventType.POPUP_OPENED, exports.InteractionType.Popup, { popupWindow: popupWindow }, null);
11849
- _a.label = 4;
11713
+ return [4 /*yield*/, this.waitForLogoutPopup(popupWindow)];
11850
11714
  case 4:
11851
- _a.trys.push([4, 6, , 7]);
11852
- // Don't care if this throws an error (User Cancelled)
11853
- return [4 /*yield*/, popupUtils.monitorPopupForSameOrigin(popupWindow)];
11854
- case 5:
11855
- // Don't care if this throws an error (User Cancelled)
11856
11715
  _a.sent();
11857
- this.logger.verbose("Popup successfully redirected to postLogoutRedirectUri");
11858
- return [3 /*break*/, 7];
11859
- case 6:
11860
- e_2 = _a.sent();
11861
- this.logger.verbose("Error occurred while monitoring popup for same origin. Session on server may remain active. Error: " + e_2);
11862
- return [3 /*break*/, 7];
11863
- case 7:
11864
- popupUtils.cleanPopup(popupWindow);
11865
11716
  if (mainWindowRedirectUri) {
11866
11717
  navigationOptions = {
11867
11718
  apiId: exports.ApiId.logoutPopup,
@@ -11876,28 +11727,280 @@ var PopupClient = /** @class */ (function (_super) {
11876
11727
  else {
11877
11728
  this.logger.verbose("No main window navigation requested");
11878
11729
  }
11879
- return [3 /*break*/, 9];
11880
- case 8:
11881
- e_3 = _a.sent();
11730
+ return [3 /*break*/, 6];
11731
+ case 5:
11732
+ e_2 = _a.sent();
11882
11733
  if (popup) {
11883
11734
  // Close the synchronous popup if an error is thrown before the window unload event is registered
11884
11735
  popup.close();
11885
11736
  }
11886
- if (e_3 instanceof AuthError) {
11887
- e_3.setCorrelationId(this.correlationId);
11737
+ if (e_2 instanceof AuthError) {
11738
+ e_2.setCorrelationId(this.correlationId);
11888
11739
  }
11889
11740
  this.browserStorage.setInteractionInProgress(false);
11890
- this.eventHandler.emitEvent(exports.EventType.LOGOUT_FAILURE, exports.InteractionType.Popup, null, e_3);
11741
+ this.eventHandler.emitEvent(exports.EventType.LOGOUT_FAILURE, exports.InteractionType.Popup, null, e_2);
11891
11742
  this.eventHandler.emitEvent(exports.EventType.LOGOUT_END, exports.InteractionType.Popup);
11892
- serverTelemetryManager.cacheFailedRequest(e_3);
11893
- throw e_3;
11894
- case 9:
11743
+ serverTelemetryManager.cacheFailedRequest(e_2);
11744
+ throw e_2;
11745
+ case 6:
11895
11746
  this.eventHandler.emitEvent(exports.EventType.LOGOUT_END, exports.InteractionType.Popup);
11896
11747
  return [2 /*return*/];
11897
11748
  }
11898
11749
  });
11899
11750
  });
11900
11751
  };
11752
+ /**
11753
+ * Opens a popup window with given request Url.
11754
+ * @param requestUrl
11755
+ */
11756
+ PopupClient.prototype.initiateAuthRequest = function (requestUrl, params) {
11757
+ // Check that request url is not empty.
11758
+ if (!StringUtils.isEmpty(requestUrl)) {
11759
+ this.logger.infoPii("Navigate to: " + requestUrl);
11760
+ // Open the popup window to requestUrl.
11761
+ return this.openPopup(requestUrl, params);
11762
+ }
11763
+ else {
11764
+ // Throw error if request URL is empty.
11765
+ this.logger.error("Navigate url is empty");
11766
+ throw BrowserAuthError.createEmptyNavigationUriError();
11767
+ }
11768
+ };
11769
+ /**
11770
+ * Monitors a window until it loads a url with the same origin.
11771
+ * @param popupWindow - window that is being monitored
11772
+ * @param timeout - timeout for processing hash once popup is redirected back to application
11773
+ */
11774
+ PopupClient.prototype.monitorPopupForHash = function (popupWindow) {
11775
+ var _this = this;
11776
+ return new Promise(function (resolve, reject) {
11777
+ /*
11778
+ * Polling for popups needs to be tick-based,
11779
+ * since a non-trivial amount of time can be spent on interaction (which should not count against the timeout).
11780
+ */
11781
+ var maxTicks = _this.config.system.windowHashTimeout / BrowserConstants.POLL_INTERVAL_MS;
11782
+ var ticks = 0;
11783
+ _this.logger.verbose("PopupHandler.monitorPopupForHash - polling started");
11784
+ var intervalId = setInterval(function () {
11785
+ // Window is closed
11786
+ if (popupWindow.closed) {
11787
+ _this.logger.error("PopupHandler.monitorPopupForHash - window closed");
11788
+ _this.cleanPopup();
11789
+ clearInterval(intervalId);
11790
+ reject(BrowserAuthError.createUserCancelledError());
11791
+ return;
11792
+ }
11793
+ var href = Constants.EMPTY_STRING;
11794
+ var hash = Constants.EMPTY_STRING;
11795
+ try {
11796
+ /*
11797
+ * Will throw if cross origin,
11798
+ * which should be caught and ignored
11799
+ * since we need the interval to keep running while on STS UI.
11800
+ */
11801
+ href = popupWindow.location.href;
11802
+ hash = popupWindow.location.hash;
11803
+ }
11804
+ catch (e) { }
11805
+ // Don't process blank pages or cross domain
11806
+ if (StringUtils.isEmpty(href) || href === "about:blank") {
11807
+ return;
11808
+ }
11809
+ _this.logger.verbose("PopupHandler.monitorPopupForHash - popup window is on same origin as caller");
11810
+ /*
11811
+ * Only run clock when we are on same domain for popups
11812
+ * as popup operations can take a long time.
11813
+ */
11814
+ ticks++;
11815
+ if (hash) {
11816
+ _this.logger.verbose("PopupHandler.monitorPopupForHash - found hash in url");
11817
+ clearInterval(intervalId);
11818
+ _this.cleanPopup(popupWindow);
11819
+ if (UrlString.hashContainsKnownProperties(hash)) {
11820
+ _this.logger.verbose("PopupHandler.monitorPopupForHash - hash contains known properties, returning.");
11821
+ resolve(hash);
11822
+ }
11823
+ else {
11824
+ _this.logger.error("PopupHandler.monitorPopupForHash - found hash in url but it does not contain known properties. Check that your router is not changing the hash prematurely.");
11825
+ _this.logger.errorPii("PopupHandler.monitorPopupForHash - hash found: " + hash);
11826
+ reject(BrowserAuthError.createHashDoesNotContainKnownPropertiesError());
11827
+ }
11828
+ }
11829
+ else if (ticks > maxTicks) {
11830
+ _this.logger.error("PopupHandler.monitorPopupForHash - unable to find hash in url, timing out");
11831
+ clearInterval(intervalId);
11832
+ reject(BrowserAuthError.createMonitorPopupTimeoutError());
11833
+ }
11834
+ }, BrowserConstants.POLL_INTERVAL_MS);
11835
+ });
11836
+ };
11837
+ /**
11838
+ * Waits for user interaction in logout popup window
11839
+ * @param popupWindow
11840
+ * @returns
11841
+ */
11842
+ PopupClient.prototype.waitForLogoutPopup = function (popupWindow) {
11843
+ var _this = this;
11844
+ return new Promise(function (resolve) {
11845
+ _this.logger.verbose("PopupHandler.waitForLogoutPopup - polling started");
11846
+ var intervalId = setInterval(function () {
11847
+ // Window is closed
11848
+ if (popupWindow.closed) {
11849
+ _this.logger.error("PopupHandler.waitForLogoutPopup - window closed");
11850
+ _this.cleanPopup();
11851
+ clearInterval(intervalId);
11852
+ resolve();
11853
+ }
11854
+ var href = Constants.EMPTY_STRING;
11855
+ try {
11856
+ /*
11857
+ * Will throw if cross origin,
11858
+ * which should be caught and ignored
11859
+ * since we need the interval to keep running while on STS UI.
11860
+ */
11861
+ href = popupWindow.location.href;
11862
+ }
11863
+ catch (e) { }
11864
+ // Don't process blank pages or cross domain
11865
+ if (StringUtils.isEmpty(href) || href === "about:blank") {
11866
+ return;
11867
+ }
11868
+ _this.logger.verbose("PopupHandler.waitForLogoutPopup - popup window is on same origin as caller, closing.");
11869
+ clearInterval(intervalId);
11870
+ _this.cleanPopup(popupWindow);
11871
+ resolve();
11872
+ }, BrowserConstants.POLL_INTERVAL_MS);
11873
+ });
11874
+ };
11875
+ /**
11876
+ * @hidden
11877
+ *
11878
+ * Configures popup window for login.
11879
+ *
11880
+ * @param urlNavigate
11881
+ * @param title
11882
+ * @param popUpWidth
11883
+ * @param popUpHeight
11884
+ * @param popupWindowAttributes
11885
+ * @ignore
11886
+ * @hidden
11887
+ */
11888
+ PopupClient.prototype.openPopup = function (urlNavigate, popupParams) {
11889
+ try {
11890
+ var popupWindow = void 0;
11891
+ // Popup window passed in, setting url to navigate to
11892
+ if (popupParams.popup) {
11893
+ popupWindow = popupParams.popup;
11894
+ this.logger.verbosePii("Navigating popup window to: " + urlNavigate);
11895
+ popupWindow.location.assign(urlNavigate);
11896
+ }
11897
+ else if (typeof popupParams.popup === "undefined") {
11898
+ // Popup will be undefined if it was not passed in
11899
+ this.logger.verbosePii("Opening popup window to: " + urlNavigate);
11900
+ popupWindow = this.openSizedPopup(urlNavigate, popupParams.popupName, popupParams.popupWindowAttributes);
11901
+ }
11902
+ // Popup will be null if popups are blocked
11903
+ if (!popupWindow) {
11904
+ throw BrowserAuthError.createEmptyWindowCreatedError();
11905
+ }
11906
+ if (popupWindow.focus) {
11907
+ popupWindow.focus();
11908
+ }
11909
+ this.currentWindow = popupWindow;
11910
+ window.addEventListener("beforeunload", this.unloadWindow);
11911
+ return popupWindow;
11912
+ }
11913
+ catch (e) {
11914
+ this.logger.error("error opening popup " + e.message);
11915
+ this.browserStorage.setInteractionInProgress(false);
11916
+ throw BrowserAuthError.createPopupWindowError(e.toString());
11917
+ }
11918
+ };
11919
+ /**
11920
+ * Helper function to set popup window dimensions and position
11921
+ * @param urlNavigate
11922
+ * @param popupName
11923
+ * @param popupWindowAttributes
11924
+ * @returns
11925
+ */
11926
+ PopupClient.prototype.openSizedPopup = function (urlNavigate, popupName, popupWindowAttributes) {
11927
+ var _a, _b, _c, _d;
11928
+ /**
11929
+ * adding winLeft and winTop to account for dual monitor
11930
+ * using screenLeft and screenTop for IE8 and earlier
11931
+ */
11932
+ var winLeft = window.screenLeft ? window.screenLeft : window.screenX;
11933
+ var winTop = window.screenTop ? window.screenTop : window.screenY;
11934
+ /**
11935
+ * window.innerWidth displays browser window"s height and width excluding toolbars
11936
+ * using document.documentElement.clientWidth for IE8 and earlier
11937
+ */
11938
+ var winWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
11939
+ var winHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
11940
+ var width = (_a = popupWindowAttributes.popupSize) === null || _a === void 0 ? void 0 : _a.width;
11941
+ var height = (_b = popupWindowAttributes.popupSize) === null || _b === void 0 ? void 0 : _b.height;
11942
+ var top = (_c = popupWindowAttributes.popupPosition) === null || _c === void 0 ? void 0 : _c.top;
11943
+ var left = (_d = popupWindowAttributes.popupPosition) === null || _d === void 0 ? void 0 : _d.left;
11944
+ if (!width || width < 0 || width > winWidth) {
11945
+ this.logger.verbose("Default popup window width used. Window width not configured or invalid.");
11946
+ width = BrowserConstants.POPUP_WIDTH;
11947
+ }
11948
+ if (!height || height < 0 || height > winHeight) {
11949
+ this.logger.verbose("Default popup window height used. Window height not configured or invalid.");
11950
+ height = BrowserConstants.POPUP_HEIGHT;
11951
+ }
11952
+ if (!top || top < 0 || top > winHeight) {
11953
+ this.logger.verbose("Default popup window top position used. Window top not configured or invalid.");
11954
+ top = Math.max(0, ((winHeight / 2) - (BrowserConstants.POPUP_HEIGHT / 2)) + winTop);
11955
+ }
11956
+ if (!left || left < 0 || left > winWidth) {
11957
+ this.logger.verbose("Default popup window left position used. Window left not configured or invalid.");
11958
+ left = Math.max(0, ((winWidth / 2) - (BrowserConstants.POPUP_WIDTH / 2)) + winLeft);
11959
+ }
11960
+ return window.open(urlNavigate, popupName, "width=" + width + ", height=" + height + ", top=" + top + ", left=" + left + ", scrollbars=yes");
11961
+ };
11962
+ /**
11963
+ * Event callback to unload main window.
11964
+ */
11965
+ PopupClient.prototype.unloadWindow = function (e) {
11966
+ this.browserStorage.cleanRequestByInteractionType(exports.InteractionType.Popup);
11967
+ if (this.currentWindow) {
11968
+ this.currentWindow.close();
11969
+ }
11970
+ // Guarantees browser unload will happen, so no other errors will be thrown.
11971
+ e.preventDefault();
11972
+ };
11973
+ /**
11974
+ * Closes popup, removes any state vars created during popup calls.
11975
+ * @param popupWindow
11976
+ */
11977
+ PopupClient.prototype.cleanPopup = function (popupWindow) {
11978
+ if (popupWindow) {
11979
+ // Close window.
11980
+ popupWindow.close();
11981
+ }
11982
+ // Remove window unload function
11983
+ window.removeEventListener("beforeunload", this.unloadWindow);
11984
+ // Interaction is completed - remove interaction status.
11985
+ this.browserStorage.setInteractionInProgress(false);
11986
+ };
11987
+ /**
11988
+ * Generates the name for the popup based on the client id and request
11989
+ * @param clientId
11990
+ * @param request
11991
+ */
11992
+ PopupClient.prototype.generatePopupName = function (scopes, authority) {
11993
+ return BrowserConstants.POPUP_NAME_PREFIX + "." + this.config.auth.clientId + "." + scopes.join("-") + "." + authority + "." + this.correlationId;
11994
+ };
11995
+ /**
11996
+ * Generates the name for the popup based on the client id and request for logouts
11997
+ * @param clientId
11998
+ * @param request
11999
+ */
12000
+ PopupClient.prototype.generateLogoutPopupName = function (request) {
12001
+ var homeAccountId = request.account && request.account.homeAccountId;
12002
+ return BrowserConstants.POPUP_NAME_PREFIX + "." + this.config.auth.clientId + "." + homeAccountId + "." + this.correlationId;
12003
+ };
11901
12004
  return PopupClient;
11902
12005
  }(StandardInteractionClient));
11903
12006
 
@@ -12020,8 +12123,8 @@ function buildConfiguration(_a, isBrowserEnvironment) {
12020
12123
  */
12021
12124
  var SilentHandler = /** @class */ (function (_super) {
12022
12125
  __extends$1(SilentHandler, _super);
12023
- function SilentHandler(authCodeModule, storageImpl, authCodeRequest, browserRequestLogger, navigateFrameWait) {
12024
- var _this = _super.call(this, authCodeModule, storageImpl, authCodeRequest, browserRequestLogger) || this;
12126
+ function SilentHandler(authCodeModule, storageImpl, authCodeRequest, logger, navigateFrameWait) {
12127
+ var _this = _super.call(this, authCodeModule, storageImpl, authCodeRequest, logger) || this;
12025
12128
  _this.navigateFrameWait = navigateFrameWait;
12026
12129
  return _this;
12027
12130
  }
@@ -12038,7 +12141,7 @@ var SilentHandler = /** @class */ (function (_super) {
12038
12141
  case 0:
12039
12142
  if (StringUtils.isEmpty(requestUrl)) {
12040
12143
  // Throw error if request URL is empty.
12041
- this.browserRequestLogger.info("Navigate url is empty");
12144
+ this.logger.info("Navigate url is empty");
12042
12145
  throw BrowserAuthError.createEmptyNavigationUriError();
12043
12146
  }
12044
12147
  if (!this.navigateFrameWait) return [3 /*break*/, 2];
@@ -12063,7 +12166,7 @@ var SilentHandler = /** @class */ (function (_super) {
12063
12166
  var _this = this;
12064
12167
  return new Promise(function (resolve, reject) {
12065
12168
  if (timeout < DEFAULT_IFRAME_TIMEOUT_MS) {
12066
- _this.browserRequestLogger.warning("system.loadFrameTimeout or system.iframeHashTimeout set to lower (" + timeout + "ms) than the default (" + DEFAULT_IFRAME_TIMEOUT_MS + "ms). This may result in timeouts.");
12169
+ _this.logger.warning("system.loadFrameTimeout or system.iframeHashTimeout set to lower (" + timeout + "ms) than the default (" + DEFAULT_IFRAME_TIMEOUT_MS + "ms). This may result in timeouts.");
12067
12170
  }
12068
12171
  /*
12069
12172
  * Polling for iframes can be purely timing based,
@@ -12600,8 +12703,7 @@ var internals = /*#__PURE__*/Object.freeze({
12600
12703
  EventHandler: EventHandler,
12601
12704
  NativeMessageHandler: NativeMessageHandler,
12602
12705
  BrowserConstants: BrowserConstants,
12603
- get TemporaryCacheKeys () { return TemporaryCacheKeys; },
12604
- PopupUtils: PopupUtils
12706
+ get TemporaryCacheKeys () { return TemporaryCacheKeys; }
12605
12707
  });
12606
12708
 
12607
12709
  /*
@@ -13969,7 +14071,7 @@ var CryptoOps = /** @class */ (function () {
13969
14071
  CryptoOps.prototype.signJwt = function (payload, kid, correlationId) {
13970
14072
  var _a;
13971
14073
  return __awaiter$1(this, void 0, void 0, function () {
13972
- var signJwtMeasurement, cachedKeyPair, publicKeyJwk, publicKeyJwkString, header, encodedHeader, encodedPayload, tokenString, tokenBuffer, signatureBuffer, encodedSignature, signedJwt;
14074
+ var signJwtMeasurement, cachedKeyPair, publicKeyJwk, publicKeyJwkString, encodedKeyIdThumbprint, shrHeader, encodedShrHeader, encodedPayload, tokenString, tokenBuffer, signatureBuffer, encodedSignature, signedJwt;
13973
14075
  return __generator$1(this, function (_b) {
13974
14076
  switch (_b.label) {
13975
14077
  case 0:
@@ -13984,17 +14086,15 @@ var CryptoOps = /** @class */ (function () {
13984
14086
  case 2:
13985
14087
  publicKeyJwk = _b.sent();
13986
14088
  publicKeyJwkString = BrowserCrypto.getJwkString(publicKeyJwk);
13987
- header = {
13988
- alg: publicKeyJwk.alg,
13989
- type: KEY_FORMAT_JWK
13990
- };
13991
- encodedHeader = this.b64Encode.urlEncode(JSON.stringify(header));
14089
+ encodedKeyIdThumbprint = this.b64Encode.urlEncode(JSON.stringify({ kid: kid }));
14090
+ shrHeader = JoseHeader.getShrHeaderString({ kid: encodedKeyIdThumbprint, alg: publicKeyJwk.alg });
14091
+ encodedShrHeader = this.b64Encode.urlEncode(shrHeader);
13992
14092
  // Generate payload
13993
14093
  payload.cnf = {
13994
14094
  jwk: JSON.parse(publicKeyJwkString)
13995
14095
  };
13996
14096
  encodedPayload = this.b64Encode.urlEncode(JSON.stringify(payload));
13997
- tokenString = encodedHeader + "." + encodedPayload;
14097
+ tokenString = encodedShrHeader + "." + encodedPayload;
13998
14098
  tokenBuffer = BrowserStringUtils.stringToArrayBuffer(tokenString);
13999
14099
  return [4 /*yield*/, this.browserCrypto.sign(cachedKeyPair.privateKey, tokenBuffer)];
14000
14100
  case 3:
@@ -14138,7 +14238,7 @@ var TokenCache = /** @class */ (function () {
14138
14238
  throw BrowserAuthError.createUnableToLoadTokenError("Please provide an extendedExpiresOn value in the options.");
14139
14239
  }
14140
14240
  var scopes = new ScopeSet(request.scopes).printScopes();
14141
- var expiresOn = response.expires_in;
14241
+ var expiresOn = options.expiresOn || (response.expires_in + new Date().getTime() / 1000);
14142
14242
  var extendedExpiresOn = options.extendedExpiresOn;
14143
14243
  var accessTokenEntity = AccessTokenEntity.createAccessTokenEntity(homeAccountId, environment, response.access_token, this.config.auth.clientId, tenantId, scopes, expiresOn, extendedExpiresOn, this.cryptoObj);
14144
14244
  if (this.isBrowserEnvironment) {
@@ -14412,7 +14512,7 @@ var ClientApplication = /** @class */ (function () {
14412
14512
  case 0:
14413
14513
  this.logger.trace("initialize called");
14414
14514
  if (this.initialized) {
14415
- this.logger.warning("initialize has already been called. This function only needs to be run once.");
14515
+ this.logger.info("initialize has already been called, exiting early.");
14416
14516
  return [2 /*return*/];
14417
14517
  }
14418
14518
  this.eventHandler.emitEvent(exports.EventType.INITIALIZE_START);