@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
@@ -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
  (function (global, factory) {
4
4
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
@@ -107,7 +107,7 @@
107
107
  return ar;
108
108
  }
109
109
 
110
- /*! @azure/msal-common v6.3.0 2022-05-02 */
110
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
111
111
  /*! *****************************************************************************
112
112
  Copyright (c) Microsoft Corporation.
113
113
 
@@ -194,7 +194,7 @@
194
194
  return r;
195
195
  }
196
196
 
197
- /*! @azure/msal-common v6.3.0 2022-05-02 */
197
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
198
198
 
199
199
  /*
200
200
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -561,9 +561,14 @@
561
561
  CacheOutcome["NO_CACHED_ACCESS_TOKEN"] = "2";
562
562
  CacheOutcome["CACHED_ACCESS_TOKEN_EXPIRED"] = "3";
563
563
  CacheOutcome["REFRESH_CACHED_ACCESS_TOKEN"] = "4";
564
- })(CacheOutcome || (CacheOutcome = {}));
564
+ })(CacheOutcome || (CacheOutcome = {}));
565
+ var JsonTypes;
566
+ (function (JsonTypes) {
567
+ JsonTypes["Jwt"] = "JWT";
568
+ JsonTypes["Jwk"] = "JWK";
569
+ })(JsonTypes || (JsonTypes = {}));
565
570
 
566
- /*! @azure/msal-common v6.3.0 2022-05-02 */
571
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
567
572
 
568
573
  /*
569
574
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -607,7 +612,7 @@
607
612
  return AuthError;
608
613
  }(Error));
609
614
 
610
- /*! @azure/msal-common v6.3.0 2022-05-02 */
615
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
611
616
 
612
617
  /*
613
618
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -682,7 +687,7 @@
682
687
  }
683
688
  };
684
689
 
685
- /*! @azure/msal-common v6.3.0 2022-05-02 */
690
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
686
691
 
687
692
  /*
688
693
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -872,6 +877,10 @@
872
877
  logoutNotSupported: {
873
878
  code: "end_session_endpoint_not_supported",
874
879
  desc: "Provided authority does not support logout."
880
+ },
881
+ keyIdMissing: {
882
+ code: "key_id_missing",
883
+ 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."
875
884
  }
876
885
  };
877
886
  /**
@@ -1141,10 +1150,16 @@
1141
1150
  ClientAuthError.createLogoutNotSupportedError = function () {
1142
1151
  return new ClientAuthError(ClientAuthErrorMessage.logoutNotSupported.code, ClientAuthErrorMessage.logoutNotSupported.desc);
1143
1152
  };
1153
+ /**
1154
+ * Create an error when kid attribute is missing from a PoP token's cache record
1155
+ */
1156
+ ClientAuthError.createKeyIdMissingError = function () {
1157
+ return new ClientAuthError(ClientAuthErrorMessage.keyIdMissing.code, ClientAuthErrorMessage.keyIdMissing.desc);
1158
+ };
1144
1159
  return ClientAuthError;
1145
1160
  }(AuthError));
1146
1161
 
1147
- /*! @azure/msal-common v6.3.0 2022-05-02 */
1162
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
1148
1163
 
1149
1164
  /*
1150
1165
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1269,7 +1284,7 @@
1269
1284
  return StringUtils;
1270
1285
  }());
1271
1286
 
1272
- /*! @azure/msal-common v6.3.0 2022-05-02 */
1287
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
1273
1288
 
1274
1289
  /*
1275
1290
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1449,12 +1464,12 @@
1449
1464
  return Logger;
1450
1465
  }());
1451
1466
 
1452
- /*! @azure/msal-common v6.3.0 2022-05-02 */
1467
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
1453
1468
  /* eslint-disable header/header */
1454
1469
  var name$1 = "@azure/msal-common";
1455
- var version$1 = "6.3.0";
1470
+ var version$1 = "6.4.0";
1456
1471
 
1457
- /*! @azure/msal-common v6.3.0 2022-05-02 */
1472
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
1458
1473
  /*
1459
1474
  * Copyright (c) Microsoft Corporation. All rights reserved.
1460
1475
  * Licensed under the MIT License.
@@ -1475,7 +1490,7 @@
1475
1490
  AzureCloudInstance["AzureUsGovernment"] = "https://login.microsoftonline.us";
1476
1491
  })(exports.AzureCloudInstance || (exports.AzureCloudInstance = {}));
1477
1492
 
1478
- /*! @azure/msal-common v6.3.0 2022-05-02 */
1493
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
1479
1494
 
1480
1495
  /*
1481
1496
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1634,7 +1649,7 @@
1634
1649
  return CredentialEntity;
1635
1650
  }());
1636
1651
 
1637
- /*! @azure/msal-common v6.3.0 2022-05-02 */
1652
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
1638
1653
 
1639
1654
  /*
1640
1655
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1889,7 +1904,7 @@
1889
1904
  return ClientConfigurationError;
1890
1905
  }(ClientAuthError));
1891
1906
 
1892
- /*! @azure/msal-common v6.3.0 2022-05-02 */
1907
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
1893
1908
 
1894
1909
  /*
1895
1910
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2073,7 +2088,7 @@
2073
2088
  return ScopeSet;
2074
2089
  }());
2075
2090
 
2076
- /*! @azure/msal-common v6.3.0 2022-05-02 */
2091
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
2077
2092
 
2078
2093
  /*
2079
2094
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2111,7 +2126,7 @@
2111
2126
  };
2112
2127
  }
2113
2128
 
2114
- /*! @azure/msal-common v6.3.0 2022-05-02 */
2129
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
2115
2130
  /*
2116
2131
  * Copyright (c) Microsoft Corporation. All rights reserved.
2117
2132
  * Licensed under the MIT License.
@@ -2125,7 +2140,7 @@
2125
2140
  AuthorityType[AuthorityType["Adfs"] = 1] = "Adfs";
2126
2141
  })(AuthorityType || (AuthorityType = {}));
2127
2142
 
2128
- /*! @azure/msal-common v6.3.0 2022-05-02 */
2143
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
2129
2144
 
2130
2145
  /*
2131
2146
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2363,7 +2378,7 @@
2363
2378
  return AccountEntity;
2364
2379
  }());
2365
2380
 
2366
- /*! @azure/msal-common v6.3.0 2022-05-02 */
2381
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
2367
2382
 
2368
2383
  /*
2369
2384
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2401,7 +2416,7 @@
2401
2416
  return AuthToken;
2402
2417
  }());
2403
2418
 
2404
- /*! @azure/msal-common v6.3.0 2022-05-02 */
2419
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
2405
2420
 
2406
2421
  /*
2407
2422
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3243,7 +3258,7 @@
3243
3258
  return DefaultStorageClass;
3244
3259
  }(CacheManager));
3245
3260
 
3246
- /*! @azure/msal-common v6.3.0 2022-05-02 */
3261
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
3247
3262
 
3248
3263
  /*
3249
3264
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3337,7 +3352,7 @@
3337
3352
  return __assign({ clientCapabilities: [], azureCloudOptions: DEFAULT_AZURE_CLOUD_OPTIONS }, authOptions);
3338
3353
  }
3339
3354
 
3340
- /*! @azure/msal-common v6.3.0 2022-05-02 */
3355
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
3341
3356
 
3342
3357
  /*
3343
3358
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3357,7 +3372,7 @@
3357
3372
  return ServerError;
3358
3373
  }(AuthError));
3359
3374
 
3360
- /*! @azure/msal-common v6.3.0 2022-05-02 */
3375
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
3361
3376
 
3362
3377
  /*
3363
3378
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3453,7 +3468,7 @@
3453
3468
  return ThrottlingUtils;
3454
3469
  }());
3455
3470
 
3456
- /*! @azure/msal-common v6.3.0 2022-05-02 */
3471
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
3457
3472
 
3458
3473
  /*
3459
3474
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3502,7 +3517,7 @@
3502
3517
  return NetworkManager;
3503
3518
  }());
3504
3519
 
3505
- /*! @azure/msal-common v6.3.0 2022-05-02 */
3520
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
3506
3521
  /*
3507
3522
  * Copyright (c) Microsoft Corporation. All rights reserved.
3508
3523
  * Licensed under the MIT License.
@@ -3513,7 +3528,7 @@
3513
3528
  CcsCredentialType["UPN"] = "UPN";
3514
3529
  })(CcsCredentialType || (CcsCredentialType = {}));
3515
3530
 
3516
- /*! @azure/msal-common v6.3.0 2022-05-02 */
3531
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
3517
3532
 
3518
3533
  /*
3519
3534
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3602,7 +3617,7 @@
3602
3617
  return BaseClient;
3603
3618
  }());
3604
3619
 
3605
- /*! @azure/msal-common v6.3.0 2022-05-02 */
3620
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
3606
3621
 
3607
3622
  /*
3608
3623
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3688,7 +3703,7 @@
3688
3703
  return RequestValidator;
3689
3704
  }());
3690
3705
 
3691
- /*! @azure/msal-common v6.3.0 2022-05-02 */
3706
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
3692
3707
 
3693
3708
  /*
3694
3709
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4001,14 +4016,14 @@
4001
4016
  * @param username
4002
4017
  */
4003
4018
  RequestParameterBuilder.prototype.addUsername = function (username) {
4004
- this.parameters.set(PasswordGrantConstants.username, username);
4019
+ this.parameters.set(PasswordGrantConstants.username, encodeURIComponent(username));
4005
4020
  };
4006
4021
  /**
4007
4022
  * adds `password` for Password Grant flow
4008
4023
  * @param password
4009
4024
  */
4010
4025
  RequestParameterBuilder.prototype.addPassword = function (password) {
4011
- this.parameters.set(PasswordGrantConstants.password, password);
4026
+ this.parameters.set(PasswordGrantConstants.password, encodeURIComponent(password));
4012
4027
  };
4013
4028
  /**
4014
4029
  * add pop_jwk to query params
@@ -4062,7 +4077,7 @@
4062
4077
  return RequestParameterBuilder;
4063
4078
  }());
4064
4079
 
4065
- /*! @azure/msal-common v6.3.0 2022-05-02 */
4080
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
4066
4081
 
4067
4082
  /*
4068
4083
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4127,7 +4142,7 @@
4127
4142
  return IdTokenEntity;
4128
4143
  }(CredentialEntity));
4129
4144
 
4130
- /*! @azure/msal-common v6.3.0 2022-05-02 */
4145
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
4131
4146
  /*
4132
4147
  * Copyright (c) Microsoft Corporation. All rights reserved.
4133
4148
  * Licensed under the MIT License.
@@ -4177,7 +4192,7 @@
4177
4192
  return TimeUtils;
4178
4193
  }());
4179
4194
 
4180
- /*! @azure/msal-common v6.3.0 2022-05-02 */
4195
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
4181
4196
 
4182
4197
  /*
4183
4198
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4291,7 +4306,7 @@
4291
4306
  return AccessTokenEntity;
4292
4307
  }(CredentialEntity));
4293
4308
 
4294
- /*! @azure/msal-common v6.3.0 2022-05-02 */
4309
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
4295
4310
 
4296
4311
  /*
4297
4312
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4358,7 +4373,7 @@
4358
4373
  return RefreshTokenEntity;
4359
4374
  }(CredentialEntity));
4360
4375
 
4361
- /*! @azure/msal-common v6.3.0 2022-05-02 */
4376
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
4362
4377
 
4363
4378
  /*
4364
4379
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4422,7 +4437,7 @@
4422
4437
  return InteractionRequiredAuthError;
4423
4438
  }(AuthError));
4424
4439
 
4425
- /*! @azure/msal-common v6.3.0 2022-05-02 */
4440
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
4426
4441
  /*
4427
4442
  * Copyright (c) Microsoft Corporation. All rights reserved.
4428
4443
  * Licensed under the MIT License.
@@ -4438,7 +4453,7 @@
4438
4453
  return CacheRecord;
4439
4454
  }());
4440
4455
 
4441
- /*! @azure/msal-common v6.3.0 2022-05-02 */
4456
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
4442
4457
 
4443
4458
  /*
4444
4459
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4509,7 +4524,7 @@
4509
4524
  return ProtocolUtils;
4510
4525
  }());
4511
4526
 
4512
- /*! @azure/msal-common v6.3.0 2022-05-02 */
4527
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
4513
4528
 
4514
4529
  /*
4515
4530
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4710,7 +4725,7 @@
4710
4725
  return UrlString;
4711
4726
  }());
4712
4727
 
4713
- /*! @azure/msal-common v6.3.0 2022-05-02 */
4728
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
4714
4729
 
4715
4730
  /*
4716
4731
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4727,34 +4742,30 @@
4727
4742
  }
4728
4743
  /**
4729
4744
  * Generates the req_cnf validated at the RP in the POP protocol for SHR parameters
4745
+ * and returns an object containing the keyid, the full req_cnf string and the req_cnf string hash
4730
4746
  * @param request
4731
4747
  * @returns
4732
4748
  */
4733
4749
  PopTokenGenerator.prototype.generateCnf = function (request) {
4734
4750
  return __awaiter(this, void 0, void 0, function () {
4735
- var reqCnf;
4736
- return __generator(this, function (_a) {
4737
- switch (_a.label) {
4751
+ var reqCnf, reqCnfString, _a;
4752
+ return __generator(this, function (_b) {
4753
+ switch (_b.label) {
4738
4754
  case 0: return [4 /*yield*/, this.generateKid(request)];
4739
4755
  case 1:
4740
- reqCnf = _a.sent();
4741
- return [2 /*return*/, this.cryptoUtils.base64Encode(JSON.stringify(reqCnf))];
4756
+ reqCnf = _b.sent();
4757
+ reqCnfString = this.cryptoUtils.base64Encode(JSON.stringify(reqCnf));
4758
+ _a = {
4759
+ kid: reqCnf.kid,
4760
+ reqCnfString: reqCnfString
4761
+ };
4762
+ return [4 /*yield*/, this.cryptoUtils.hashString(reqCnfString)];
4763
+ case 2: return [2 /*return*/, (_a.reqCnfHash = _b.sent(),
4764
+ _a)];
4742
4765
  }
4743
4766
  });
4744
4767
  });
4745
4768
  };
4746
- /**
4747
- * Generates the hash of the req_cnf
4748
- * @param cnf
4749
- * @returns
4750
- */
4751
- PopTokenGenerator.prototype.generateCnfHash = function (cnf) {
4752
- return __awaiter(this, void 0, void 0, function () {
4753
- return __generator(this, function (_a) {
4754
- return [2 /*return*/, this.cryptoUtils.hashString(cnf)];
4755
- });
4756
- });
4757
- };
4758
4769
  /**
4759
4770
  * Generates key_id for a SHR token request
4760
4771
  * @param request
@@ -4782,16 +4793,10 @@
4782
4793
  * @param request
4783
4794
  * @returns
4784
4795
  */
4785
- PopTokenGenerator.prototype.signPopToken = function (accessToken, request) {
4786
- var _a;
4796
+ PopTokenGenerator.prototype.signPopToken = function (accessToken, keyId, request) {
4787
4797
  return __awaiter(this, void 0, void 0, function () {
4788
- var tokenClaims;
4789
- return __generator(this, function (_b) {
4790
- tokenClaims = AuthToken.extractTokenClaims(accessToken, this.cryptoUtils);
4791
- if (!((_a = tokenClaims === null || tokenClaims === void 0 ? void 0 : tokenClaims.cnf) === null || _a === void 0 ? void 0 : _a.kid)) {
4792
- throw ClientAuthError.createTokenClaimsRequiredError();
4793
- }
4794
- return [2 /*return*/, this.signPayload(accessToken, tokenClaims.cnf.kid, request)];
4798
+ return __generator(this, function (_a) {
4799
+ return [2 /*return*/, this.signPayload(accessToken, keyId, request)];
4795
4800
  });
4796
4801
  });
4797
4802
  };
@@ -4803,7 +4808,7 @@
4803
4808
  * @param claims
4804
4809
  * @returns
4805
4810
  */
4806
- PopTokenGenerator.prototype.signPayload = function (payload, kid, request, claims) {
4811
+ PopTokenGenerator.prototype.signPayload = function (payload, keyId, request, claims) {
4807
4812
  return __awaiter(this, void 0, void 0, function () {
4808
4813
  var resourceRequestMethod, resourceRequestUri, shrClaims, shrNonce, resourceUrlString, resourceUrlComponents;
4809
4814
  return __generator(this, function (_a) {
@@ -4812,7 +4817,7 @@
4812
4817
  resourceRequestMethod = request.resourceRequestMethod, resourceRequestUri = request.resourceRequestUri, shrClaims = request.shrClaims, shrNonce = request.shrNonce;
4813
4818
  resourceUrlString = (resourceRequestUri) ? new UrlString(resourceRequestUri) : undefined;
4814
4819
  resourceUrlComponents = resourceUrlString === null || resourceUrlString === void 0 ? void 0 : resourceUrlString.getUrlComponents();
4815
- 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)];
4820
+ 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)];
4816
4821
  case 1: return [2 /*return*/, _a.sent()];
4817
4822
  }
4818
4823
  });
@@ -4821,7 +4826,7 @@
4821
4826
  return PopTokenGenerator;
4822
4827
  }());
4823
4828
 
4824
- /*! @azure/msal-common v6.3.0 2022-05-02 */
4829
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
4825
4830
 
4826
4831
  /*
4827
4832
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4891,7 +4896,7 @@
4891
4896
  return AppMetadataEntity;
4892
4897
  }());
4893
4898
 
4894
- /*! @azure/msal-common v6.3.0 2022-05-02 */
4899
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
4895
4900
  /*
4896
4901
  * Copyright (c) Microsoft Corporation. All rights reserved.
4897
4902
  * Licensed under the MIT License.
@@ -4927,7 +4932,7 @@
4927
4932
  return TokenCacheContext;
4928
4933
  }());
4929
4934
 
4930
- /*! @azure/msal-common v6.3.0 2022-05-02 */
4935
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
4931
4936
 
4932
4937
  /*
4933
4938
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5136,9 +5141,9 @@
5136
5141
  ResponseHandler.generateAuthenticationResult = function (cryptoObj, authority, cacheRecord, fromTokenCache, request, idTokenObj, requestState, code) {
5137
5142
  var _a, _b, _c;
5138
5143
  return __awaiter(this, void 0, void 0, function () {
5139
- var accessToken, responseScopes, expiresOn, extExpiresOn, familyId, popTokenGenerator, uid, tid;
5140
- return __generator(this, function (_d) {
5141
- switch (_d.label) {
5144
+ var accessToken, responseScopes, expiresOn, extExpiresOn, familyId, popTokenGenerator, _d, secret, keyId, uid, tid;
5145
+ return __generator(this, function (_e) {
5146
+ switch (_e.label) {
5142
5147
  case 0:
5143
5148
  accessToken = Constants.EMPTY_STRING;
5144
5149
  responseScopes = [];
@@ -5147,18 +5152,22 @@
5147
5152
  if (!cacheRecord.accessToken) return [3 /*break*/, 4];
5148
5153
  if (!(cacheRecord.accessToken.tokenType === exports.AuthenticationScheme.POP)) return [3 /*break*/, 2];
5149
5154
  popTokenGenerator = new PopTokenGenerator(cryptoObj);
5150
- return [4 /*yield*/, popTokenGenerator.signPopToken(cacheRecord.accessToken.secret, request)];
5155
+ _d = cacheRecord.accessToken, secret = _d.secret, keyId = _d.keyId;
5156
+ if (!keyId) {
5157
+ throw ClientAuthError.createKeyIdMissingError();
5158
+ }
5159
+ return [4 /*yield*/, popTokenGenerator.signPopToken(secret, keyId, request)];
5151
5160
  case 1:
5152
- accessToken = _d.sent();
5161
+ accessToken = _e.sent();
5153
5162
  return [3 /*break*/, 3];
5154
5163
  case 2:
5155
5164
  accessToken = cacheRecord.accessToken.secret;
5156
- _d.label = 3;
5165
+ _e.label = 3;
5157
5166
  case 3:
5158
5167
  responseScopes = ScopeSet.fromString(cacheRecord.accessToken.target).asArray();
5159
5168
  expiresOn = new Date(Number(cacheRecord.accessToken.expiresOn) * 1000);
5160
5169
  extExpiresOn = new Date(Number(cacheRecord.accessToken.extendedExpiresOn) * 1000);
5161
- _d.label = 4;
5170
+ _e.label = 4;
5162
5171
  case 4:
5163
5172
  if (cacheRecord.appMetadata) {
5164
5173
  familyId = cacheRecord.appMetadata.familyId === THE_FAMILY_ID ? THE_FAMILY_ID : Constants.EMPTY_STRING;
@@ -5193,7 +5202,7 @@
5193
5202
  return ResponseHandler;
5194
5203
  }());
5195
5204
 
5196
- /*! @azure/msal-common v6.3.0 2022-05-02 */
5205
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
5197
5206
 
5198
5207
  /*
5199
5208
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5360,7 +5369,7 @@
5360
5369
  */
5361
5370
  AuthorizationCodeClient.prototype.createTokenRequestBody = function (request) {
5362
5371
  return __awaiter(this, void 0, void 0, function () {
5363
- var parameterBuilder, clientAssertion, popTokenGenerator, cnfString, correlationId, ccsCred, clientInfo, clientInfo;
5372
+ var parameterBuilder, clientAssertion, popTokenGenerator, reqCnfData, correlationId, ccsCred, clientInfo, clientInfo;
5364
5373
  var _a;
5365
5374
  return __generator(this, function (_b) {
5366
5375
  switch (_b.label) {
@@ -5397,8 +5406,8 @@
5397
5406
  if (this.config.clientCredentials.clientSecret) {
5398
5407
  parameterBuilder.addClientSecret(this.config.clientCredentials.clientSecret);
5399
5408
  }
5400
- if (this.config.clientCredentials.clientAssertion) {
5401
- clientAssertion = this.config.clientCredentials.clientAssertion;
5409
+ clientAssertion = request.clientAssertion || this.config.clientCredentials.clientAssertion;
5410
+ if (clientAssertion) {
5402
5411
  parameterBuilder.addClientAssertion(clientAssertion.assertion);
5403
5412
  parameterBuilder.addClientAssertionType(clientAssertion.assertionType);
5404
5413
  }
@@ -5408,8 +5417,9 @@
5408
5417
  popTokenGenerator = new PopTokenGenerator(this.cryptoUtils);
5409
5418
  return [4 /*yield*/, popTokenGenerator.generateCnf(request)];
5410
5419
  case 1:
5411
- cnfString = _b.sent();
5412
- parameterBuilder.addPopToken(cnfString);
5420
+ reqCnfData = _b.sent();
5421
+ // SPA PoP requires full Base64Url encoded req_cnf string (unhashed)
5422
+ parameterBuilder.addPopToken(reqCnfData.reqCnfString);
5413
5423
  return [3 /*break*/, 3];
5414
5424
  case 2:
5415
5425
  if (request.authenticationScheme === exports.AuthenticationScheme.SSH) {
@@ -5480,7 +5490,7 @@
5480
5490
  */
5481
5491
  AuthorizationCodeClient.prototype.createAuthCodeUrlQueryString = function (request) {
5482
5492
  return __awaiter(this, void 0, void 0, function () {
5483
- var parameterBuilder, requestScopes, correlationId, accountSid, clientInfo, clientInfo, popTokenGenerator, cnf, cnfHash;
5493
+ var parameterBuilder, requestScopes, correlationId, accountSid, clientInfo, clientInfo, popTokenGenerator, reqCnfData;
5484
5494
  return __generator(this, function (_a) {
5485
5495
  switch (_a.label) {
5486
5496
  case 0:
@@ -5572,20 +5582,17 @@
5572
5582
  if (request.extraQueryParameters) {
5573
5583
  parameterBuilder.addExtraQueryParameters(request.extraQueryParameters);
5574
5584
  }
5575
- if (!request.nativeBroker) return [3 /*break*/, 3];
5585
+ if (!request.nativeBroker) return [3 /*break*/, 2];
5576
5586
  // signal ests that this is a WAM call
5577
5587
  parameterBuilder.addNativeBroker();
5578
- if (!(request.authenticationScheme === exports.AuthenticationScheme.POP)) return [3 /*break*/, 3];
5588
+ if (!(request.authenticationScheme === exports.AuthenticationScheme.POP)) return [3 /*break*/, 2];
5579
5589
  popTokenGenerator = new PopTokenGenerator(this.cryptoUtils);
5580
5590
  return [4 /*yield*/, popTokenGenerator.generateCnf(request)];
5581
5591
  case 1:
5582
- cnf = _a.sent();
5583
- return [4 /*yield*/, popTokenGenerator.generateCnfHash(cnf)];
5584
- case 2:
5585
- cnfHash = _a.sent();
5586
- parameterBuilder.addPopToken(cnfHash);
5587
- _a.label = 3;
5588
- case 3: return [2 /*return*/, parameterBuilder.createQueryString()];
5592
+ reqCnfData = _a.sent();
5593
+ parameterBuilder.addPopToken(reqCnfData.reqCnfHash);
5594
+ _a.label = 2;
5595
+ case 2: return [2 /*return*/, parameterBuilder.createQueryString()];
5589
5596
  }
5590
5597
  });
5591
5598
  });
@@ -5630,7 +5637,7 @@
5630
5637
  return AuthorizationCodeClient;
5631
5638
  }(BaseClient));
5632
5639
 
5633
- /*! @azure/msal-common v6.3.0 2022-05-02 */
5640
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
5634
5641
 
5635
5642
  /*
5636
5643
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5771,7 +5778,7 @@
5771
5778
  */
5772
5779
  RefreshTokenClient.prototype.createTokenRequestBody = function (request) {
5773
5780
  return __awaiter(this, void 0, void 0, function () {
5774
- var parameterBuilder, correlationId, clientAssertion, popTokenGenerator, cnfString, clientInfo;
5781
+ var parameterBuilder, correlationId, clientAssertion, popTokenGenerator, reqCnfData, clientInfo;
5775
5782
  return __generator(this, function (_a) {
5776
5783
  switch (_a.label) {
5777
5784
  case 0:
@@ -5792,8 +5799,8 @@
5792
5799
  if (this.config.clientCredentials.clientSecret) {
5793
5800
  parameterBuilder.addClientSecret(this.config.clientCredentials.clientSecret);
5794
5801
  }
5795
- if (this.config.clientCredentials.clientAssertion) {
5796
- clientAssertion = this.config.clientCredentials.clientAssertion;
5802
+ clientAssertion = request.clientAssertion || this.config.clientCredentials.clientAssertion;
5803
+ if (clientAssertion) {
5797
5804
  parameterBuilder.addClientAssertion(clientAssertion.assertion);
5798
5805
  parameterBuilder.addClientAssertionType(clientAssertion.assertionType);
5799
5806
  }
@@ -5801,8 +5808,9 @@
5801
5808
  popTokenGenerator = new PopTokenGenerator(this.cryptoUtils);
5802
5809
  return [4 /*yield*/, popTokenGenerator.generateCnf(request)];
5803
5810
  case 1:
5804
- cnfString = _a.sent();
5805
- parameterBuilder.addPopToken(cnfString);
5811
+ reqCnfData = _a.sent();
5812
+ // SPA PoP requires full Base64Url encoded req_cnf string (unhashed)
5813
+ parameterBuilder.addPopToken(reqCnfData.reqCnfString);
5806
5814
  return [3 /*break*/, 3];
5807
5815
  case 2:
5808
5816
  if (request.authenticationScheme === exports.AuthenticationScheme.SSH) {
@@ -5842,7 +5850,7 @@
5842
5850
  return RefreshTokenClient;
5843
5851
  }(BaseClient));
5844
5852
 
5845
- /*! @azure/msal-common v6.3.0 2022-05-02 */
5853
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
5846
5854
 
5847
5855
  /*
5848
5856
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5958,7 +5966,7 @@
5958
5966
  return SilentFlowClient;
5959
5967
  }(BaseClient));
5960
5968
 
5961
- /*! @azure/msal-common v6.3.0 2022-05-02 */
5969
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
5962
5970
  /*
5963
5971
  * Copyright (c) Microsoft Corporation. All rights reserved.
5964
5972
  * Licensed under the MIT License.
@@ -5969,7 +5977,7 @@
5969
5977
  response.hasOwnProperty("issuer"));
5970
5978
  }
5971
5979
 
5972
- /*! @azure/msal-common v6.3.0 2022-05-02 */
5980
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
5973
5981
  /*
5974
5982
  * Copyright (c) Microsoft Corporation. All rights reserved.
5975
5983
  * Licensed under the MIT License.
@@ -5983,7 +5991,7 @@
5983
5991
  ProtocolMode["OIDC"] = "OIDC";
5984
5992
  })(exports.ProtocolMode || (exports.ProtocolMode = {}));
5985
5993
 
5986
- /*! @azure/msal-common v6.3.0 2022-05-02 */
5994
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
5987
5995
 
5988
5996
  /*
5989
5997
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6058,7 +6066,7 @@
6058
6066
  return AuthorityMetadataEntity;
6059
6067
  }());
6060
6068
 
6061
- /*! @azure/msal-common v6.3.0 2022-05-02 */
6069
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
6062
6070
  /*
6063
6071
  * Copyright (c) Microsoft Corporation. All rights reserved.
6064
6072
  * Licensed under the MIT License.
@@ -6068,7 +6076,7 @@
6068
6076
  response.hasOwnProperty("metadata"));
6069
6077
  }
6070
6078
 
6071
- /*! @azure/msal-common v6.3.0 2022-05-02 */
6079
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
6072
6080
 
6073
6081
  /*
6074
6082
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6190,7 +6198,7 @@
6190
6198
  return RegionDiscovery;
6191
6199
  }());
6192
6200
 
6193
- /*! @azure/msal-common v6.3.0 2022-05-02 */
6201
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
6194
6202
 
6195
6203
  /*
6196
6204
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6780,7 +6788,7 @@
6780
6788
  return Authority;
6781
6789
  }());
6782
6790
 
6783
- /*! @azure/msal-common v6.3.0 2022-05-02 */
6791
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
6784
6792
 
6785
6793
  /*
6786
6794
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6841,7 +6849,7 @@
6841
6849
  return AuthorityFactory;
6842
6850
  }());
6843
6851
 
6844
- /*! @azure/msal-common v6.3.0 2022-05-02 */
6852
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
6845
6853
 
6846
6854
  /*
6847
6855
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6872,7 +6880,7 @@
6872
6880
  return ServerTelemetryEntity;
6873
6881
  }());
6874
6882
 
6875
- /*! @azure/msal-common v6.3.0 2022-05-02 */
6883
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
6876
6884
 
6877
6885
  /*
6878
6886
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6900,7 +6908,7 @@
6900
6908
  return ThrottlingEntity;
6901
6909
  }());
6902
6910
 
6903
- /*! @azure/msal-common v6.3.0 2022-05-02 */
6911
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
6904
6912
 
6905
6913
  /*
6906
6914
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6917,7 +6925,92 @@
6917
6925
  }
6918
6926
  };
6919
6927
 
6920
- /*! @azure/msal-common v6.3.0 2022-05-02 */
6928
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
6929
+
6930
+ /*
6931
+ * Copyright (c) Microsoft Corporation. All rights reserved.
6932
+ * Licensed under the MIT License.
6933
+ */
6934
+ /**
6935
+ * ClientAuthErrorMessage class containing string constants used by error codes and messages.
6936
+ */
6937
+ var JoseHeaderErrorMessage = {
6938
+ missingKidError: {
6939
+ code: "missing_kid_error",
6940
+ 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."
6941
+ },
6942
+ missingAlgError: {
6943
+ code: "missing_alg_error",
6944
+ 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."
6945
+ },
6946
+ };
6947
+ /**
6948
+ * Error thrown when there is an error in the client code running on the browser.
6949
+ */
6950
+ var JoseHeaderError = /** @class */ (function (_super) {
6951
+ __extends(JoseHeaderError, _super);
6952
+ function JoseHeaderError(errorCode, errorMessage) {
6953
+ var _this = _super.call(this, errorCode, errorMessage) || this;
6954
+ _this.name = "JoseHeaderError";
6955
+ Object.setPrototypeOf(_this, JoseHeaderError.prototype);
6956
+ return _this;
6957
+ }
6958
+ /**
6959
+ * Creates an error thrown when keyId isn't set on JOSE header.
6960
+ */
6961
+ JoseHeaderError.createMissingKidError = function () {
6962
+ return new JoseHeaderError(JoseHeaderErrorMessage.missingKidError.code, JoseHeaderErrorMessage.missingKidError.desc);
6963
+ };
6964
+ /**
6965
+ * Creates an error thrown when algorithm isn't set on JOSE header.
6966
+ */
6967
+ JoseHeaderError.createMissingAlgError = function () {
6968
+ return new JoseHeaderError(JoseHeaderErrorMessage.missingAlgError.code, JoseHeaderErrorMessage.missingAlgError.desc);
6969
+ };
6970
+ return JoseHeaderError;
6971
+ }(AuthError));
6972
+
6973
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
6974
+
6975
+ /*
6976
+ * Copyright (c) Microsoft Corporation. All rights reserved.
6977
+ * Licensed under the MIT License.
6978
+ */
6979
+ var JoseHeader = /** @class */ (function () {
6980
+ function JoseHeader(options) {
6981
+ this.typ = options.typ;
6982
+ this.alg = options.alg;
6983
+ this.kid = options.kid;
6984
+ }
6985
+ /**
6986
+ * Builds SignedHttpRequest formatted JOSE Header from the
6987
+ * JOSE Header options provided or previously set on the object and returns
6988
+ * the stringified header object.
6989
+ * Throws if keyId or algorithm aren't provided since they are required for Access Token Binding.
6990
+ * @param shrHeaderOptions
6991
+ * @returns
6992
+ */
6993
+ JoseHeader.getShrHeaderString = function (shrHeaderOptions) {
6994
+ // KeyID is required on the SHR header
6995
+ if (!shrHeaderOptions.kid) {
6996
+ throw JoseHeaderError.createMissingKidError();
6997
+ }
6998
+ // Alg is required on the SHR header
6999
+ if (!shrHeaderOptions.alg) {
7000
+ throw JoseHeaderError.createMissingAlgError();
7001
+ }
7002
+ var shrHeader = new JoseHeader({
7003
+ // Access Token PoP headers must have type JWT, but the type header can be overriden for special cases
7004
+ typ: shrHeaderOptions.typ || JsonTypes.Jwt,
7005
+ kid: shrHeaderOptions.kid,
7006
+ alg: shrHeaderOptions.alg
7007
+ });
7008
+ return JSON.stringify(shrHeader);
7009
+ };
7010
+ return JoseHeader;
7011
+ }());
7012
+
7013
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
6921
7014
 
6922
7015
  /*
6923
7016
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6976,7 +7069,7 @@
6976
7069
  return AuthenticationHeaderParser;
6977
7070
  }());
6978
7071
 
6979
- /*! @azure/msal-common v6.3.0 2022-05-02 */
7072
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
6980
7073
 
6981
7074
  /*
6982
7075
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7138,7 +7231,7 @@
7138
7231
  return ServerTelemetryManager;
7139
7232
  }());
7140
7233
 
7141
- /*! @azure/msal-common v6.3.0 2022-05-02 */
7234
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
7142
7235
  /*
7143
7236
  * Copyright (c) Microsoft Corporation. All rights reserved.
7144
7237
  * Licensed under the MIT License.
@@ -7235,7 +7328,7 @@
7235
7328
  PerformanceEventStatus[PerformanceEventStatus["Completed"] = 2] = "Completed";
7236
7329
  })(PerformanceEventStatus || (PerformanceEventStatus = {}));
7237
7330
 
7238
- /*! @azure/msal-common v6.3.0 2022-05-02 */
7331
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
7239
7332
 
7240
7333
  /*
7241
7334
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7505,7 +7598,7 @@
7505
7598
  return PerformanceClient;
7506
7599
  }());
7507
7600
 
7508
- /*! @azure/msal-common v6.3.0 2022-05-02 */
7601
+ /*! @azure/msal-common v6.4.0 2022-06-06 */
7509
7602
 
7510
7603
  /*
7511
7604
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7563,7 +7656,7 @@
7563
7656
  },
7564
7657
  hashEmptyError: {
7565
7658
  code: "hash_empty_error",
7566
- desc: "Hash value cannot be processed because it is empty. Please verify that your redirectUri is not clearing the hash."
7659
+ 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."
7567
7660
  },
7568
7661
  hashDoesNotContainStateError: {
7569
7662
  code: "no_state_in_hash",
@@ -7571,7 +7664,7 @@
7571
7664
  },
7572
7665
  hashDoesNotContainKnownPropertiesError: {
7573
7666
  code: "hash_does_not_contain_known_properties",
7574
- desc: "Hash does not contain known properites. Please verify that your redirectUri is not changing the hash."
7667
+ 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."
7575
7668
  },
7576
7669
  unableToParseStateError: {
7577
7670
  code: "unable_to_parse_state",
@@ -9301,7 +9394,7 @@
9301
9394
 
9302
9395
  /* eslint-disable header/header */
9303
9396
  var name = "@azure/msal-browser";
9304
- var version = "2.24.0";
9397
+ var version = "2.25.0";
9305
9398
 
9306
9399
  /*
9307
9400
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -10154,11 +10247,11 @@
10154
10247
  * Abstract class which defines operations for a browser interaction handling class.
10155
10248
  */
10156
10249
  var InteractionHandler = /** @class */ (function () {
10157
- function InteractionHandler(authCodeModule, storageImpl, authCodeRequest, browserRequestLogger) {
10250
+ function InteractionHandler(authCodeModule, storageImpl, authCodeRequest, logger) {
10158
10251
  this.authModule = authCodeModule;
10159
10252
  this.browserStorage = storageImpl;
10160
10253
  this.authCodeRequest = authCodeRequest;
10161
- this.browserRequestLogger = browserRequestLogger;
10254
+ this.logger = logger;
10162
10255
  }
10163
10256
  /**
10164
10257
  * Function to handle response parameters from hash.
@@ -10168,7 +10261,7 @@
10168
10261
  return __awaiter$1(this, void 0, void 0, function () {
10169
10262
  var stateKey, requestState, authCodeResponse;
10170
10263
  return __generator$1(this, function (_a) {
10171
- this.browserRequestLogger.verbose("InteractionHandler.handleCodeResponse called");
10264
+ this.logger.verbose("InteractionHandler.handleCodeResponse called");
10172
10265
  // Check that location hash isn't empty.
10173
10266
  if (StringUtils.isEmpty(locationHash)) {
10174
10267
  throw BrowserAuthError.createEmptyHashError(locationHash);
@@ -10209,7 +10302,7 @@
10209
10302
  return __generator$1(this, function (_a) {
10210
10303
  switch (_a.label) {
10211
10304
  case 0:
10212
- this.browserRequestLogger.trace("InteractionHandler.handleCodeResponseFromServer called");
10305
+ this.logger.trace("InteractionHandler.handleCodeResponseFromServer called");
10213
10306
  stateKey = this.browserStorage.generateStateKey(state);
10214
10307
  requestState = this.browserStorage.getTemporaryCache(stateKey);
10215
10308
  if (!requestState) {
@@ -10297,8 +10390,8 @@
10297
10390
  */
10298
10391
  var RedirectHandler = /** @class */ (function (_super) {
10299
10392
  __extends$1(RedirectHandler, _super);
10300
- function RedirectHandler(authCodeModule, storageImpl, authCodeRequest, browserRequestLogger, browserCrypto) {
10301
- var _this = _super.call(this, authCodeModule, storageImpl, authCodeRequest, browserRequestLogger) || this;
10393
+ function RedirectHandler(authCodeModule, storageImpl, authCodeRequest, logger, browserCrypto) {
10394
+ var _this = _super.call(this, authCodeModule, storageImpl, authCodeRequest, logger) || this;
10302
10395
  _this.browserCrypto = browserCrypto;
10303
10396
  return _this;
10304
10397
  }
@@ -10312,38 +10405,38 @@
10312
10405
  return __generator$1(this, function (_a) {
10313
10406
  switch (_a.label) {
10314
10407
  case 0:
10315
- this.browserRequestLogger.verbose("RedirectHandler.initiateAuthRequest called");
10408
+ this.logger.verbose("RedirectHandler.initiateAuthRequest called");
10316
10409
  if (!!StringUtils.isEmpty(requestUrl)) return [3 /*break*/, 7];
10317
10410
  // Cache start page, returns to this page after redirectUri if navigateToLoginRequestUrl is true
10318
10411
  if (params.redirectStartPage) {
10319
- this.browserRequestLogger.verbose("RedirectHandler.initiateAuthRequest: redirectStartPage set, caching start page");
10412
+ this.logger.verbose("RedirectHandler.initiateAuthRequest: redirectStartPage set, caching start page");
10320
10413
  this.browserStorage.setTemporaryCache(TemporaryCacheKeys.ORIGIN_URI, params.redirectStartPage, true);
10321
10414
  }
10322
10415
  // Set interaction status in the library.
10323
10416
  this.browserStorage.setTemporaryCache(TemporaryCacheKeys.CORRELATION_ID, this.authCodeRequest.correlationId, true);
10324
10417
  this.browserStorage.cacheCodeRequest(this.authCodeRequest, this.browserCrypto);
10325
- this.browserRequestLogger.infoPii("RedirectHandler.initiateAuthRequest: Navigate to: " + requestUrl);
10418
+ this.logger.infoPii("RedirectHandler.initiateAuthRequest: Navigate to: " + requestUrl);
10326
10419
  navigationOptions = {
10327
10420
  apiId: exports.ApiId.acquireTokenRedirect,
10328
10421
  timeout: params.redirectTimeout,
10329
10422
  noHistory: false
10330
10423
  };
10331
10424
  if (!(typeof params.onRedirectNavigate === "function")) return [3 /*break*/, 4];
10332
- this.browserRequestLogger.verbose("RedirectHandler.initiateAuthRequest: Invoking onRedirectNavigate callback");
10425
+ this.logger.verbose("RedirectHandler.initiateAuthRequest: Invoking onRedirectNavigate callback");
10333
10426
  navigate = params.onRedirectNavigate(requestUrl);
10334
10427
  if (!(navigate !== false)) return [3 /*break*/, 2];
10335
- this.browserRequestLogger.verbose("RedirectHandler.initiateAuthRequest: onRedirectNavigate did not return false, navigating");
10428
+ this.logger.verbose("RedirectHandler.initiateAuthRequest: onRedirectNavigate did not return false, navigating");
10336
10429
  return [4 /*yield*/, params.navigationClient.navigateExternal(requestUrl, navigationOptions)];
10337
10430
  case 1:
10338
10431
  _a.sent();
10339
10432
  return [2 /*return*/];
10340
10433
  case 2:
10341
- this.browserRequestLogger.verbose("RedirectHandler.initiateAuthRequest: onRedirectNavigate returned false, stopping navigation");
10434
+ this.logger.verbose("RedirectHandler.initiateAuthRequest: onRedirectNavigate returned false, stopping navigation");
10342
10435
  return [2 /*return*/];
10343
10436
  case 3: return [3 /*break*/, 6];
10344
10437
  case 4:
10345
10438
  // Navigate window to request URL
10346
- this.browserRequestLogger.verbose("RedirectHandler.initiateAuthRequest: Navigating window to navigate url");
10439
+ this.logger.verbose("RedirectHandler.initiateAuthRequest: Navigating window to navigate url");
10347
10440
  return [4 /*yield*/, params.navigationClient.navigateExternal(requestUrl, navigationOptions)];
10348
10441
  case 5:
10349
10442
  _a.sent();
@@ -10351,7 +10444,7 @@
10351
10444
  case 6: return [3 /*break*/, 8];
10352
10445
  case 7:
10353
10446
  // Throw error if request URL is empty.
10354
- this.browserRequestLogger.info("RedirectHandler.initiateAuthRequest: Navigate url is empty");
10447
+ this.logger.info("RedirectHandler.initiateAuthRequest: Navigate url is empty");
10355
10448
  throw BrowserAuthError.createEmptyNavigationUriError();
10356
10449
  case 8: return [2 /*return*/];
10357
10450
  }
@@ -10368,7 +10461,7 @@
10368
10461
  return __generator$1(this, function (_a) {
10369
10462
  switch (_a.label) {
10370
10463
  case 0:
10371
- this.browserRequestLogger.verbose("RedirectHandler.handleCodeResponse called");
10464
+ this.logger.verbose("RedirectHandler.handleCodeResponse called");
10372
10465
  // Check that location hash isn't empty.
10373
10466
  if (StringUtils.isEmpty(locationHash)) {
10374
10467
  throw BrowserAuthError.createEmptyHashError(locationHash);
@@ -10469,6 +10562,7 @@
10469
10562
  NativeStatusCode["NO_NETWORK"] = "NO_NETWORK";
10470
10563
  NativeStatusCode["TRANSIENT_ERROR"] = "TRANSIENT_ERROR";
10471
10564
  NativeStatusCode["PERSISTENT_ERROR"] = "PERSISTENT_ERROR";
10565
+ NativeStatusCode["DISABLED"] = "DISABLED";
10472
10566
  })(NativeStatusCode || (NativeStatusCode = {}));
10473
10567
  var NativeAuthErrorMessage = {
10474
10568
  extensionError: {
@@ -10492,7 +10586,7 @@
10492
10586
  * These errors should result in a fallback to the 'standard' browser based auth flow.
10493
10587
  */
10494
10588
  NativeAuthError.prototype.isFatal = function () {
10495
- if (this.ext && this.ext.status && this.ext.status === NativeStatusCode.PERSISTENT_ERROR) {
10589
+ if (this.ext && this.ext.status && (this.ext.status === NativeStatusCode.PERSISTENT_ERROR || this.ext.status === NativeStatusCode.DISABLED)) {
10496
10590
  return true;
10497
10591
  }
10498
10592
  switch (this.errorCode) {
@@ -10721,7 +10815,7 @@
10721
10815
  uid = accountProperties["UID"] || idTokenObj.claims.oid || idTokenObj.claims.sub || Constants.EMPTY_STRING;
10722
10816
  tid = accountProperties["TenantId"] || idTokenObj.claims.tid || Constants.EMPTY_STRING;
10723
10817
  responseTokenType = exports.AuthenticationScheme.BEARER;
10724
- _a = request.token_type;
10818
+ _a = request.tokenType;
10725
10819
  switch (_a) {
10726
10820
  case exports.AuthenticationScheme.POP: return [3 /*break*/, 2];
10727
10821
  }
@@ -10742,7 +10836,14 @@
10742
10836
  shrClaims: request.shrClaims,
10743
10837
  shrNonce: request.shrNonce
10744
10838
  };
10745
- return [4 /*yield*/, popTokenGenerator.signPopToken(response.access_token, shrParameters)];
10839
+ /**
10840
+ * KeyID must be present in the native request from when the PoP key was generated in order for
10841
+ * PopTokenGenerator to query the full key for signing
10842
+ */
10843
+ if (!request.keyId) {
10844
+ throw ClientAuthError.createKeyIdMissingError();
10845
+ }
10846
+ return [4 /*yield*/, popTokenGenerator.signPopToken(response.access_token, request.keyId, shrParameters)];
10746
10847
  case 3:
10747
10848
  responseAccessToken = _b.sent();
10748
10849
  return [3 /*break*/, 5];
@@ -10800,9 +10901,9 @@
10800
10901
  */
10801
10902
  NativeInteractionClient.prototype.initializeNativeRequest = function (request) {
10802
10903
  return __awaiter$1(this, void 0, void 0, function () {
10803
- var authority, canonicalAuthority, scopes, scopeSet, instanceAware, validatedRequest, shrParameters, popTokenGenerator, cnf, _a;
10804
- return __generator$1(this, function (_b) {
10805
- switch (_b.label) {
10904
+ var authority, canonicalAuthority, scopes, scopeSet, validatedRequest, shrParameters, popTokenGenerator, reqCnfData;
10905
+ return __generator$1(this, function (_a) {
10906
+ switch (_a.label) {
10806
10907
  case 0:
10807
10908
  this.logger.trace("NativeInteractionClient - initializeNativeRequest called");
10808
10909
  authority = request.authority || this.config.auth.authority;
@@ -10822,10 +10923,9 @@
10822
10923
  throw BrowserAuthError.createNativePromptParameterNotSupportedError();
10823
10924
  }
10824
10925
  }
10825
- instanceAware = !!(request.extraQueryParameters && request.extraQueryParameters.instance_aware);
10826
- 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?
10926
+ 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?
10827
10927
  });
10828
- if (!(request.authenticationScheme === exports.AuthenticationScheme.POP)) return [3 /*break*/, 3];
10928
+ if (!(request.authenticationScheme === exports.AuthenticationScheme.POP)) return [3 /*break*/, 2];
10829
10929
  shrParameters = {
10830
10930
  resourceRequestUri: request.resourceRequestUri,
10831
10931
  resourceRequestMethod: request.resourceRequestMethod,
@@ -10835,15 +10935,12 @@
10835
10935
  popTokenGenerator = new PopTokenGenerator(this.browserCrypto);
10836
10936
  return [4 /*yield*/, popTokenGenerator.generateCnf(shrParameters)];
10837
10937
  case 1:
10838
- cnf = _b.sent();
10938
+ reqCnfData = _a.sent();
10839
10939
  // to reduce the URL length, it is recommended to send the hash of the req_cnf instead of the whole string
10840
- _a = validatedRequest;
10841
- return [4 /*yield*/, popTokenGenerator.generateCnfHash(cnf)];
10940
+ validatedRequest.reqCnf = reqCnfData.reqCnfHash;
10941
+ validatedRequest.keyId = reqCnfData.kid;
10942
+ _a.label = 2;
10842
10943
  case 2:
10843
- // to reduce the URL length, it is recommended to send the hash of the req_cnf instead of the whole string
10844
- _a.req_cnf = _b.sent();
10845
- _b.label = 3;
10846
- case 3:
10847
10944
  if (this.apiId === exports.ApiId.ssoSilent || this.apiId === exports.ApiId.acquireTokenSilent_silentFlow) {
10848
10945
  validatedRequest.prompt = PromptValue.NONE;
10849
10946
  }
@@ -11419,249 +11516,17 @@
11419
11516
  return RedirectClient;
11420
11517
  }(StandardInteractionClient));
11421
11518
 
11422
- /*
11423
- * Copyright (c) Microsoft Corporation. All rights reserved.
11424
- * Licensed under the MIT License.
11425
- */
11426
- var PopupUtils = /** @class */ (function () {
11427
- function PopupUtils(storageImpl, logger) {
11428
- this.browserStorage = storageImpl;
11429
- this.logger = logger;
11430
- // Properly sets this reference for the unload event.
11431
- this.unloadWindow = this.unloadWindow.bind(this);
11432
- }
11433
- /**
11434
- * @hidden
11435
- *
11436
- * Configures popup window for login.
11437
- *
11438
- * @param urlNavigate
11439
- * @param title
11440
- * @param popUpWidth
11441
- * @param popUpHeight
11442
- * @param popupWindowAttributes
11443
- * @ignore
11444
- * @hidden
11445
- */
11446
- PopupUtils.prototype.openPopup = function (urlNavigate, popupParams) {
11447
- try {
11448
- var popupWindow = void 0;
11449
- // Popup window passed in, setting url to navigate to
11450
- if (popupParams.popup) {
11451
- popupWindow = popupParams.popup;
11452
- this.logger.verbosePii("Navigating popup window to: " + urlNavigate);
11453
- popupWindow.location.assign(urlNavigate);
11454
- }
11455
- else if (typeof popupParams.popup === "undefined") {
11456
- // Popup will be undefined if it was not passed in
11457
- this.logger.verbosePii("Opening popup window to: " + urlNavigate);
11458
- popupWindow = PopupUtils.openSizedPopup(urlNavigate, popupParams.popupName, popupParams.popupWindowAttributes, this.logger);
11459
- }
11460
- // Popup will be null if popups are blocked
11461
- if (!popupWindow) {
11462
- throw BrowserAuthError.createEmptyWindowCreatedError();
11463
- }
11464
- if (popupWindow.focus) {
11465
- popupWindow.focus();
11466
- }
11467
- this.currentWindow = popupWindow;
11468
- window.addEventListener("beforeunload", this.unloadWindow);
11469
- return popupWindow;
11470
- }
11471
- catch (e) {
11472
- this.logger.error("error opening popup " + e.message);
11473
- this.browserStorage.setInteractionInProgress(false);
11474
- throw BrowserAuthError.createPopupWindowError(e.toString());
11475
- }
11476
- };
11477
- /**
11478
- * Helper function to set popup window dimensions and position
11479
- * @param urlNavigate
11480
- * @param popupName
11481
- * @param popupWindowAttributes
11482
- * @returns
11483
- */
11484
- PopupUtils.openSizedPopup = function (urlNavigate, popupName, popupWindowAttributes, logger) {
11485
- var _a, _b, _c, _d;
11486
- /**
11487
- * adding winLeft and winTop to account for dual monitor
11488
- * using screenLeft and screenTop for IE8 and earlier
11489
- */
11490
- var winLeft = window.screenLeft ? window.screenLeft : window.screenX;
11491
- var winTop = window.screenTop ? window.screenTop : window.screenY;
11492
- /**
11493
- * window.innerWidth displays browser window"s height and width excluding toolbars
11494
- * using document.documentElement.clientWidth for IE8 and earlier
11495
- */
11496
- var winWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
11497
- var winHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
11498
- var width = (_a = popupWindowAttributes.popupSize) === null || _a === void 0 ? void 0 : _a.width;
11499
- var height = (_b = popupWindowAttributes.popupSize) === null || _b === void 0 ? void 0 : _b.height;
11500
- var top = (_c = popupWindowAttributes.popupPosition) === null || _c === void 0 ? void 0 : _c.top;
11501
- var left = (_d = popupWindowAttributes.popupPosition) === null || _d === void 0 ? void 0 : _d.left;
11502
- if (!width || width < 0 || width > winWidth) {
11503
- logger.verbose("Default popup window width used. Window width not configured or invalid.");
11504
- width = BrowserConstants.POPUP_WIDTH;
11505
- }
11506
- if (!height || height < 0 || height > winHeight) {
11507
- logger.verbose("Default popup window height used. Window height not configured or invalid.");
11508
- height = BrowserConstants.POPUP_HEIGHT;
11509
- }
11510
- if (!top || top < 0 || top > winHeight) {
11511
- logger.verbose("Default popup window top position used. Window top not configured or invalid.");
11512
- top = Math.max(0, ((winHeight / 2) - (BrowserConstants.POPUP_HEIGHT / 2)) + winTop);
11513
- }
11514
- if (!left || left < 0 || left > winWidth) {
11515
- logger.verbose("Default popup window left position used. Window left not configured or invalid.");
11516
- left = Math.max(0, ((winWidth / 2) - (BrowserConstants.POPUP_WIDTH / 2)) + winLeft);
11517
- }
11518
- return window.open(urlNavigate, popupName, "width=" + width + ", height=" + height + ", top=" + top + ", left=" + left + ", scrollbars=yes");
11519
- };
11520
- /**
11521
- * Event callback to unload main window.
11522
- */
11523
- PopupUtils.prototype.unloadWindow = function (e) {
11524
- this.browserStorage.cleanRequestByInteractionType(exports.InteractionType.Popup);
11525
- if (this.currentWindow) {
11526
- this.currentWindow.close();
11527
- }
11528
- // Guarantees browser unload will happen, so no other errors will be thrown.
11529
- e.preventDefault();
11530
- };
11531
- /**
11532
- * Closes popup, removes any state vars created during popup calls.
11533
- * @param popupWindow
11534
- */
11535
- PopupUtils.prototype.cleanPopup = function (popupWindow) {
11536
- if (popupWindow) {
11537
- // Close window.
11538
- popupWindow.close();
11539
- }
11540
- // Remove window unload function
11541
- window.removeEventListener("beforeunload", this.unloadWindow);
11542
- // Interaction is completed - remove interaction status.
11543
- this.browserStorage.setInteractionInProgress(false);
11544
- };
11545
- /**
11546
- * Monitors a window until it loads a url with the same origin.
11547
- * @param popupWindow - window that is being monitored
11548
- */
11549
- PopupUtils.prototype.monitorPopupForSameOrigin = function (popupWindow) {
11550
- var _this = this;
11551
- return new Promise(function (resolve, reject) {
11552
- var intervalId = setInterval(function () {
11553
- if (popupWindow.closed) {
11554
- // Window is closed
11555
- _this.cleanPopup();
11556
- clearInterval(intervalId);
11557
- reject(BrowserAuthError.createUserCancelledError());
11558
- return;
11559
- }
11560
- var href = Constants.EMPTY_STRING;
11561
- try {
11562
- /*
11563
- * Will throw if cross origin,
11564
- * which should be caught and ignored
11565
- * since we need the interval to keep running while on STS UI.
11566
- */
11567
- href = popupWindow.location.href;
11568
- }
11569
- catch (e) { }
11570
- // Don't process blank pages or cross domain
11571
- if (StringUtils.isEmpty(href) || href === "about:blank") {
11572
- return;
11573
- }
11574
- clearInterval(intervalId);
11575
- resolve();
11576
- }, BrowserConstants.POLL_INTERVAL_MS);
11577
- });
11578
- };
11579
- /**
11580
- * Generates the name for the popup based on the client id and request
11581
- * @param clientId
11582
- * @param request
11583
- */
11584
- PopupUtils.generatePopupName = function (clientId, scopes, authority, correlationId) {
11585
- return BrowserConstants.POPUP_NAME_PREFIX + "." + clientId + "." + scopes.join("-") + "." + authority + "." + correlationId;
11586
- };
11587
- /**
11588
- * Generates the name for the popup based on the client id and request for logouts
11589
- * @param clientId
11590
- * @param request
11591
- */
11592
- PopupUtils.generateLogoutPopupName = function (clientId, request) {
11593
- var homeAccountId = request.account && request.account.homeAccountId;
11594
- return BrowserConstants.POPUP_NAME_PREFIX + "." + clientId + "." + homeAccountId + "." + request.correlationId;
11595
- };
11596
- return PopupUtils;
11597
- }());
11598
-
11599
- /*
11600
- * Copyright (c) Microsoft Corporation. All rights reserved.
11601
- * Licensed under the MIT License.
11602
- */
11603
- /**
11604
- * This class implements the interaction handler base class for browsers. It is written specifically for handling
11605
- * popup window scenarios. It includes functions for monitoring the popup window for a hash.
11606
- */
11607
- var PopupHandler = /** @class */ (function (_super) {
11608
- __extends$1(PopupHandler, _super);
11609
- function PopupHandler(authCodeModule, storageImpl, authCodeRequest, browserRequestLogger) {
11610
- var _this = _super.call(this, authCodeModule, storageImpl, authCodeRequest, browserRequestLogger) || this;
11611
- // Properly sets this reference for the unload event.
11612
- _this.popupUtils = new PopupUtils(storageImpl, browserRequestLogger);
11613
- return _this;
11614
- }
11615
- /**
11616
- * Opens a popup window with given request Url.
11617
- * @param requestUrl
11618
- */
11619
- PopupHandler.prototype.initiateAuthRequest = function (requestUrl, params) {
11620
- // Check that request url is not empty.
11621
- if (!StringUtils.isEmpty(requestUrl)) {
11622
- this.browserRequestLogger.infoPii("Navigate to: " + requestUrl);
11623
- // Open the popup window to requestUrl.
11624
- return this.popupUtils.openPopup(requestUrl, params);
11625
- }
11626
- else {
11627
- // Throw error if request URL is empty.
11628
- this.browserRequestLogger.error("Navigate url is empty");
11629
- throw BrowserAuthError.createEmptyNavigationUriError();
11630
- }
11631
- };
11632
- /**
11633
- * Monitors a window until it loads a url with a known hash, or hits a specified timeout.
11634
- * @param popupWindow - window that is being monitored
11635
- * @param timeout - milliseconds until timeout
11636
- */
11637
- PopupHandler.prototype.monitorPopupForHash = function (popupWindow) {
11638
- var _this = this;
11639
- return this.popupUtils.monitorPopupForSameOrigin(popupWindow).then(function () {
11640
- var contentHash = popupWindow.location.hash;
11641
- BrowserUtils.clearHash(popupWindow);
11642
- _this.popupUtils.cleanPopup(popupWindow);
11643
- if (!contentHash) {
11644
- throw BrowserAuthError.createEmptyHashError(popupWindow.location.href);
11645
- }
11646
- if (UrlString.hashContainsKnownProperties(contentHash)) {
11647
- return contentHash;
11648
- }
11649
- else {
11650
- throw BrowserAuthError.createHashDoesNotContainKnownPropertiesError();
11651
- }
11652
- });
11653
- };
11654
- return PopupHandler;
11655
- }(InteractionHandler));
11656
-
11657
11519
  /*
11658
11520
  * Copyright (c) Microsoft Corporation. All rights reserved.
11659
11521
  * Licensed under the MIT License.
11660
11522
  */
11661
11523
  var PopupClient = /** @class */ (function (_super) {
11662
11524
  __extends$1(PopupClient, _super);
11663
- function PopupClient() {
11664
- return _super !== null && _super.apply(this, arguments) || this;
11525
+ function PopupClient(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, performanceClient, nativeMessageHandler, correlationId) {
11526
+ var _this = _super.call(this, config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, performanceClient, nativeMessageHandler, correlationId) || this;
11527
+ // Properly sets this reference for the unload event.
11528
+ _this.unloadWindow = _this.unloadWindow.bind(_this);
11529
+ return _this;
11665
11530
  }
11666
11531
  /**
11667
11532
  * Acquires tokens by opening a popup window to the /authorize endpoint of the authority
@@ -11669,7 +11534,7 @@
11669
11534
  */
11670
11535
  PopupClient.prototype.acquireToken = function (request) {
11671
11536
  try {
11672
- var popupName = PopupUtils.generatePopupName(this.config.auth.clientId, request.scopes || OIDC_DEFAULT_SCOPES, request.authority || this.config.auth.authority, this.correlationId);
11537
+ var popupName = this.generatePopupName(request.scopes || OIDC_DEFAULT_SCOPES, request.authority || this.config.auth.authority);
11673
11538
  var popupWindowAttributes = request.popupWindowAttributes || {};
11674
11539
  // asyncPopups flag is true. Acquires token without first opening popup. Popup will be opened later asynchronously.
11675
11540
  if (this.config.system.asyncPopups) {
@@ -11680,7 +11545,7 @@
11680
11545
  else {
11681
11546
  // asyncPopups flag is set to false. Opens popup before acquiring token.
11682
11547
  this.logger.verbose("asyncPopup set to false, opening popup before acquiring token");
11683
- var popup = PopupUtils.openSizedPopup("about:blank", popupName, popupWindowAttributes, this.logger);
11548
+ var popup = this.openSizedPopup("about:blank", popupName, popupWindowAttributes);
11684
11549
  return this.acquireTokenPopupAsync(request, popupName, popupWindowAttributes, popup);
11685
11550
  }
11686
11551
  }
@@ -11696,7 +11561,7 @@
11696
11561
  try {
11697
11562
  this.logger.verbose("logoutPopup called");
11698
11563
  var validLogoutRequest = this.initializeLogoutRequest(logoutRequest);
11699
- var popupName = PopupUtils.generateLogoutPopupName(this.config.auth.clientId, validLogoutRequest);
11564
+ var popupName = this.generateLogoutPopupName(validLogoutRequest);
11700
11565
  var authority = logoutRequest && logoutRequest.authority;
11701
11566
  var mainWindowRedirectUri = logoutRequest && logoutRequest.mainWindowRedirectUri;
11702
11567
  var popupWindowAttributes = (logoutRequest === null || logoutRequest === void 0 ? void 0 : logoutRequest.popupWindowAttributes) || {};
@@ -11709,7 +11574,7 @@
11709
11574
  else {
11710
11575
  // asyncPopups flag is set to false. Opens popup before logging out.
11711
11576
  this.logger.verbose("asyncPopup set to false, opening popup");
11712
- var popup = PopupUtils.openSizedPopup("about:blank", popupName, popupWindowAttributes, this.logger);
11577
+ var popup = this.openSizedPopup("about:blank", popupName, popupWindowAttributes);
11713
11578
  return this.logoutPopupAsync(validLogoutRequest, popupName, popupWindowAttributes, authority, popup, mainWindowRedirectUri);
11714
11579
  }
11715
11580
  }
@@ -11758,15 +11623,15 @@
11758
11623
  return [4 /*yield*/, authClient.getAuthCodeUrl(__assign$1(__assign$1({}, validRequest), { nativeBroker: isNativeBroker }))];
11759
11624
  case 5:
11760
11625
  navigateUrl = _a.sent();
11761
- interactionHandler = new PopupHandler(authClient, this.browserStorage, authCodeRequest, this.logger);
11626
+ interactionHandler = new InteractionHandler(authClient, this.browserStorage, authCodeRequest, this.logger);
11762
11627
  popupParameters = {
11763
11628
  popup: popup,
11764
11629
  popupName: popupName,
11765
11630
  popupWindowAttributes: popupWindowAttributes
11766
11631
  };
11767
- popupWindow = interactionHandler.initiateAuthRequest(navigateUrl, popupParameters);
11632
+ popupWindow = this.initiateAuthRequest(navigateUrl, popupParameters);
11768
11633
  this.eventHandler.emitEvent(exports.EventType.POPUP_OPENED, exports.InteractionType.Popup, { popupWindow: popupWindow }, null);
11769
- return [4 /*yield*/, interactionHandler.monitorPopupForHash(popupWindow)];
11634
+ return [4 /*yield*/, this.monitorPopupForHash(popupWindow)];
11770
11635
  case 6:
11771
11636
  hash = _a.sent();
11772
11637
  serverParams = UrlString.getDeserializedHash(hash);
@@ -11824,7 +11689,7 @@
11824
11689
  */
11825
11690
  PopupClient.prototype.logoutPopupAsync = function (validRequest, popupName, popupWindowAttributes, requestAuthority, popup, mainWindowRedirectUri) {
11826
11691
  return __awaiter$1(this, void 0, void 0, function () {
11827
- var serverTelemetryManager, authClient, logoutUri, popupUtils, popupWindow, e_2, navigationOptions, absoluteUrl, e_3;
11692
+ var serverTelemetryManager, authClient, logoutUri, popupWindow, navigationOptions, absoluteUrl, e_2;
11828
11693
  return __generator$1(this, function (_a) {
11829
11694
  switch (_a.label) {
11830
11695
  case 0:
@@ -11833,7 +11698,7 @@
11833
11698
  serverTelemetryManager = this.initializeServerTelemetryManager(exports.ApiId.logoutPopup);
11834
11699
  _a.label = 1;
11835
11700
  case 1:
11836
- _a.trys.push([1, 8, , 9]);
11701
+ _a.trys.push([1, 5, , 6]);
11837
11702
  // Clear cache on logout
11838
11703
  return [4 /*yield*/, this.clearCacheOnLogout(validRequest.account)];
11839
11704
  case 2:
@@ -11845,25 +11710,11 @@
11845
11710
  this.logger.verbose("Auth code client created");
11846
11711
  logoutUri = authClient.getLogoutUri(validRequest);
11847
11712
  this.eventHandler.emitEvent(exports.EventType.LOGOUT_SUCCESS, exports.InteractionType.Popup, validRequest);
11848
- popupUtils = new PopupUtils(this.browserStorage, this.logger);
11849
- popupWindow = popupUtils.openPopup(logoutUri, { popupName: popupName, popupWindowAttributes: popupWindowAttributes, popup: popup });
11713
+ popupWindow = this.openPopup(logoutUri, { popupName: popupName, popupWindowAttributes: popupWindowAttributes, popup: popup });
11850
11714
  this.eventHandler.emitEvent(exports.EventType.POPUP_OPENED, exports.InteractionType.Popup, { popupWindow: popupWindow }, null);
11851
- _a.label = 4;
11715
+ return [4 /*yield*/, this.waitForLogoutPopup(popupWindow)];
11852
11716
  case 4:
11853
- _a.trys.push([4, 6, , 7]);
11854
- // Don't care if this throws an error (User Cancelled)
11855
- return [4 /*yield*/, popupUtils.monitorPopupForSameOrigin(popupWindow)];
11856
- case 5:
11857
- // Don't care if this throws an error (User Cancelled)
11858
11717
  _a.sent();
11859
- this.logger.verbose("Popup successfully redirected to postLogoutRedirectUri");
11860
- return [3 /*break*/, 7];
11861
- case 6:
11862
- e_2 = _a.sent();
11863
- this.logger.verbose("Error occurred while monitoring popup for same origin. Session on server may remain active. Error: " + e_2);
11864
- return [3 /*break*/, 7];
11865
- case 7:
11866
- popupUtils.cleanPopup(popupWindow);
11867
11718
  if (mainWindowRedirectUri) {
11868
11719
  navigationOptions = {
11869
11720
  apiId: exports.ApiId.logoutPopup,
@@ -11878,28 +11729,280 @@
11878
11729
  else {
11879
11730
  this.logger.verbose("No main window navigation requested");
11880
11731
  }
11881
- return [3 /*break*/, 9];
11882
- case 8:
11883
- e_3 = _a.sent();
11732
+ return [3 /*break*/, 6];
11733
+ case 5:
11734
+ e_2 = _a.sent();
11884
11735
  if (popup) {
11885
11736
  // Close the synchronous popup if an error is thrown before the window unload event is registered
11886
11737
  popup.close();
11887
11738
  }
11888
- if (e_3 instanceof AuthError) {
11889
- e_3.setCorrelationId(this.correlationId);
11739
+ if (e_2 instanceof AuthError) {
11740
+ e_2.setCorrelationId(this.correlationId);
11890
11741
  }
11891
11742
  this.browserStorage.setInteractionInProgress(false);
11892
- this.eventHandler.emitEvent(exports.EventType.LOGOUT_FAILURE, exports.InteractionType.Popup, null, e_3);
11743
+ this.eventHandler.emitEvent(exports.EventType.LOGOUT_FAILURE, exports.InteractionType.Popup, null, e_2);
11893
11744
  this.eventHandler.emitEvent(exports.EventType.LOGOUT_END, exports.InteractionType.Popup);
11894
- serverTelemetryManager.cacheFailedRequest(e_3);
11895
- throw e_3;
11896
- case 9:
11745
+ serverTelemetryManager.cacheFailedRequest(e_2);
11746
+ throw e_2;
11747
+ case 6:
11897
11748
  this.eventHandler.emitEvent(exports.EventType.LOGOUT_END, exports.InteractionType.Popup);
11898
11749
  return [2 /*return*/];
11899
11750
  }
11900
11751
  });
11901
11752
  });
11902
11753
  };
11754
+ /**
11755
+ * Opens a popup window with given request Url.
11756
+ * @param requestUrl
11757
+ */
11758
+ PopupClient.prototype.initiateAuthRequest = function (requestUrl, params) {
11759
+ // Check that request url is not empty.
11760
+ if (!StringUtils.isEmpty(requestUrl)) {
11761
+ this.logger.infoPii("Navigate to: " + requestUrl);
11762
+ // Open the popup window to requestUrl.
11763
+ return this.openPopup(requestUrl, params);
11764
+ }
11765
+ else {
11766
+ // Throw error if request URL is empty.
11767
+ this.logger.error("Navigate url is empty");
11768
+ throw BrowserAuthError.createEmptyNavigationUriError();
11769
+ }
11770
+ };
11771
+ /**
11772
+ * Monitors a window until it loads a url with the same origin.
11773
+ * @param popupWindow - window that is being monitored
11774
+ * @param timeout - timeout for processing hash once popup is redirected back to application
11775
+ */
11776
+ PopupClient.prototype.monitorPopupForHash = function (popupWindow) {
11777
+ var _this = this;
11778
+ return new Promise(function (resolve, reject) {
11779
+ /*
11780
+ * Polling for popups needs to be tick-based,
11781
+ * since a non-trivial amount of time can be spent on interaction (which should not count against the timeout).
11782
+ */
11783
+ var maxTicks = _this.config.system.windowHashTimeout / BrowserConstants.POLL_INTERVAL_MS;
11784
+ var ticks = 0;
11785
+ _this.logger.verbose("PopupHandler.monitorPopupForHash - polling started");
11786
+ var intervalId = setInterval(function () {
11787
+ // Window is closed
11788
+ if (popupWindow.closed) {
11789
+ _this.logger.error("PopupHandler.monitorPopupForHash - window closed");
11790
+ _this.cleanPopup();
11791
+ clearInterval(intervalId);
11792
+ reject(BrowserAuthError.createUserCancelledError());
11793
+ return;
11794
+ }
11795
+ var href = Constants.EMPTY_STRING;
11796
+ var hash = Constants.EMPTY_STRING;
11797
+ try {
11798
+ /*
11799
+ * Will throw if cross origin,
11800
+ * which should be caught and ignored
11801
+ * since we need the interval to keep running while on STS UI.
11802
+ */
11803
+ href = popupWindow.location.href;
11804
+ hash = popupWindow.location.hash;
11805
+ }
11806
+ catch (e) { }
11807
+ // Don't process blank pages or cross domain
11808
+ if (StringUtils.isEmpty(href) || href === "about:blank") {
11809
+ return;
11810
+ }
11811
+ _this.logger.verbose("PopupHandler.monitorPopupForHash - popup window is on same origin as caller");
11812
+ /*
11813
+ * Only run clock when we are on same domain for popups
11814
+ * as popup operations can take a long time.
11815
+ */
11816
+ ticks++;
11817
+ if (hash) {
11818
+ _this.logger.verbose("PopupHandler.monitorPopupForHash - found hash in url");
11819
+ clearInterval(intervalId);
11820
+ _this.cleanPopup(popupWindow);
11821
+ if (UrlString.hashContainsKnownProperties(hash)) {
11822
+ _this.logger.verbose("PopupHandler.monitorPopupForHash - hash contains known properties, returning.");
11823
+ resolve(hash);
11824
+ }
11825
+ else {
11826
+ _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.");
11827
+ _this.logger.errorPii("PopupHandler.monitorPopupForHash - hash found: " + hash);
11828
+ reject(BrowserAuthError.createHashDoesNotContainKnownPropertiesError());
11829
+ }
11830
+ }
11831
+ else if (ticks > maxTicks) {
11832
+ _this.logger.error("PopupHandler.monitorPopupForHash - unable to find hash in url, timing out");
11833
+ clearInterval(intervalId);
11834
+ reject(BrowserAuthError.createMonitorPopupTimeoutError());
11835
+ }
11836
+ }, BrowserConstants.POLL_INTERVAL_MS);
11837
+ });
11838
+ };
11839
+ /**
11840
+ * Waits for user interaction in logout popup window
11841
+ * @param popupWindow
11842
+ * @returns
11843
+ */
11844
+ PopupClient.prototype.waitForLogoutPopup = function (popupWindow) {
11845
+ var _this = this;
11846
+ return new Promise(function (resolve) {
11847
+ _this.logger.verbose("PopupHandler.waitForLogoutPopup - polling started");
11848
+ var intervalId = setInterval(function () {
11849
+ // Window is closed
11850
+ if (popupWindow.closed) {
11851
+ _this.logger.error("PopupHandler.waitForLogoutPopup - window closed");
11852
+ _this.cleanPopup();
11853
+ clearInterval(intervalId);
11854
+ resolve();
11855
+ }
11856
+ var href = Constants.EMPTY_STRING;
11857
+ try {
11858
+ /*
11859
+ * Will throw if cross origin,
11860
+ * which should be caught and ignored
11861
+ * since we need the interval to keep running while on STS UI.
11862
+ */
11863
+ href = popupWindow.location.href;
11864
+ }
11865
+ catch (e) { }
11866
+ // Don't process blank pages or cross domain
11867
+ if (StringUtils.isEmpty(href) || href === "about:blank") {
11868
+ return;
11869
+ }
11870
+ _this.logger.verbose("PopupHandler.waitForLogoutPopup - popup window is on same origin as caller, closing.");
11871
+ clearInterval(intervalId);
11872
+ _this.cleanPopup(popupWindow);
11873
+ resolve();
11874
+ }, BrowserConstants.POLL_INTERVAL_MS);
11875
+ });
11876
+ };
11877
+ /**
11878
+ * @hidden
11879
+ *
11880
+ * Configures popup window for login.
11881
+ *
11882
+ * @param urlNavigate
11883
+ * @param title
11884
+ * @param popUpWidth
11885
+ * @param popUpHeight
11886
+ * @param popupWindowAttributes
11887
+ * @ignore
11888
+ * @hidden
11889
+ */
11890
+ PopupClient.prototype.openPopup = function (urlNavigate, popupParams) {
11891
+ try {
11892
+ var popupWindow = void 0;
11893
+ // Popup window passed in, setting url to navigate to
11894
+ if (popupParams.popup) {
11895
+ popupWindow = popupParams.popup;
11896
+ this.logger.verbosePii("Navigating popup window to: " + urlNavigate);
11897
+ popupWindow.location.assign(urlNavigate);
11898
+ }
11899
+ else if (typeof popupParams.popup === "undefined") {
11900
+ // Popup will be undefined if it was not passed in
11901
+ this.logger.verbosePii("Opening popup window to: " + urlNavigate);
11902
+ popupWindow = this.openSizedPopup(urlNavigate, popupParams.popupName, popupParams.popupWindowAttributes);
11903
+ }
11904
+ // Popup will be null if popups are blocked
11905
+ if (!popupWindow) {
11906
+ throw BrowserAuthError.createEmptyWindowCreatedError();
11907
+ }
11908
+ if (popupWindow.focus) {
11909
+ popupWindow.focus();
11910
+ }
11911
+ this.currentWindow = popupWindow;
11912
+ window.addEventListener("beforeunload", this.unloadWindow);
11913
+ return popupWindow;
11914
+ }
11915
+ catch (e) {
11916
+ this.logger.error("error opening popup " + e.message);
11917
+ this.browserStorage.setInteractionInProgress(false);
11918
+ throw BrowserAuthError.createPopupWindowError(e.toString());
11919
+ }
11920
+ };
11921
+ /**
11922
+ * Helper function to set popup window dimensions and position
11923
+ * @param urlNavigate
11924
+ * @param popupName
11925
+ * @param popupWindowAttributes
11926
+ * @returns
11927
+ */
11928
+ PopupClient.prototype.openSizedPopup = function (urlNavigate, popupName, popupWindowAttributes) {
11929
+ var _a, _b, _c, _d;
11930
+ /**
11931
+ * adding winLeft and winTop to account for dual monitor
11932
+ * using screenLeft and screenTop for IE8 and earlier
11933
+ */
11934
+ var winLeft = window.screenLeft ? window.screenLeft : window.screenX;
11935
+ var winTop = window.screenTop ? window.screenTop : window.screenY;
11936
+ /**
11937
+ * window.innerWidth displays browser window"s height and width excluding toolbars
11938
+ * using document.documentElement.clientWidth for IE8 and earlier
11939
+ */
11940
+ var winWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
11941
+ var winHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
11942
+ var width = (_a = popupWindowAttributes.popupSize) === null || _a === void 0 ? void 0 : _a.width;
11943
+ var height = (_b = popupWindowAttributes.popupSize) === null || _b === void 0 ? void 0 : _b.height;
11944
+ var top = (_c = popupWindowAttributes.popupPosition) === null || _c === void 0 ? void 0 : _c.top;
11945
+ var left = (_d = popupWindowAttributes.popupPosition) === null || _d === void 0 ? void 0 : _d.left;
11946
+ if (!width || width < 0 || width > winWidth) {
11947
+ this.logger.verbose("Default popup window width used. Window width not configured or invalid.");
11948
+ width = BrowserConstants.POPUP_WIDTH;
11949
+ }
11950
+ if (!height || height < 0 || height > winHeight) {
11951
+ this.logger.verbose("Default popup window height used. Window height not configured or invalid.");
11952
+ height = BrowserConstants.POPUP_HEIGHT;
11953
+ }
11954
+ if (!top || top < 0 || top > winHeight) {
11955
+ this.logger.verbose("Default popup window top position used. Window top not configured or invalid.");
11956
+ top = Math.max(0, ((winHeight / 2) - (BrowserConstants.POPUP_HEIGHT / 2)) + winTop);
11957
+ }
11958
+ if (!left || left < 0 || left > winWidth) {
11959
+ this.logger.verbose("Default popup window left position used. Window left not configured or invalid.");
11960
+ left = Math.max(0, ((winWidth / 2) - (BrowserConstants.POPUP_WIDTH / 2)) + winLeft);
11961
+ }
11962
+ return window.open(urlNavigate, popupName, "width=" + width + ", height=" + height + ", top=" + top + ", left=" + left + ", scrollbars=yes");
11963
+ };
11964
+ /**
11965
+ * Event callback to unload main window.
11966
+ */
11967
+ PopupClient.prototype.unloadWindow = function (e) {
11968
+ this.browserStorage.cleanRequestByInteractionType(exports.InteractionType.Popup);
11969
+ if (this.currentWindow) {
11970
+ this.currentWindow.close();
11971
+ }
11972
+ // Guarantees browser unload will happen, so no other errors will be thrown.
11973
+ e.preventDefault();
11974
+ };
11975
+ /**
11976
+ * Closes popup, removes any state vars created during popup calls.
11977
+ * @param popupWindow
11978
+ */
11979
+ PopupClient.prototype.cleanPopup = function (popupWindow) {
11980
+ if (popupWindow) {
11981
+ // Close window.
11982
+ popupWindow.close();
11983
+ }
11984
+ // Remove window unload function
11985
+ window.removeEventListener("beforeunload", this.unloadWindow);
11986
+ // Interaction is completed - remove interaction status.
11987
+ this.browserStorage.setInteractionInProgress(false);
11988
+ };
11989
+ /**
11990
+ * Generates the name for the popup based on the client id and request
11991
+ * @param clientId
11992
+ * @param request
11993
+ */
11994
+ PopupClient.prototype.generatePopupName = function (scopes, authority) {
11995
+ return BrowserConstants.POPUP_NAME_PREFIX + "." + this.config.auth.clientId + "." + scopes.join("-") + "." + authority + "." + this.correlationId;
11996
+ };
11997
+ /**
11998
+ * Generates the name for the popup based on the client id and request for logouts
11999
+ * @param clientId
12000
+ * @param request
12001
+ */
12002
+ PopupClient.prototype.generateLogoutPopupName = function (request) {
12003
+ var homeAccountId = request.account && request.account.homeAccountId;
12004
+ return BrowserConstants.POPUP_NAME_PREFIX + "." + this.config.auth.clientId + "." + homeAccountId + "." + this.correlationId;
12005
+ };
11903
12006
  return PopupClient;
11904
12007
  }(StandardInteractionClient));
11905
12008
 
@@ -12022,8 +12125,8 @@
12022
12125
  */
12023
12126
  var SilentHandler = /** @class */ (function (_super) {
12024
12127
  __extends$1(SilentHandler, _super);
12025
- function SilentHandler(authCodeModule, storageImpl, authCodeRequest, browserRequestLogger, navigateFrameWait) {
12026
- var _this = _super.call(this, authCodeModule, storageImpl, authCodeRequest, browserRequestLogger) || this;
12128
+ function SilentHandler(authCodeModule, storageImpl, authCodeRequest, logger, navigateFrameWait) {
12129
+ var _this = _super.call(this, authCodeModule, storageImpl, authCodeRequest, logger) || this;
12027
12130
  _this.navigateFrameWait = navigateFrameWait;
12028
12131
  return _this;
12029
12132
  }
@@ -12040,7 +12143,7 @@
12040
12143
  case 0:
12041
12144
  if (StringUtils.isEmpty(requestUrl)) {
12042
12145
  // Throw error if request URL is empty.
12043
- this.browserRequestLogger.info("Navigate url is empty");
12146
+ this.logger.info("Navigate url is empty");
12044
12147
  throw BrowserAuthError.createEmptyNavigationUriError();
12045
12148
  }
12046
12149
  if (!this.navigateFrameWait) return [3 /*break*/, 2];
@@ -12065,7 +12168,7 @@
12065
12168
  var _this = this;
12066
12169
  return new Promise(function (resolve, reject) {
12067
12170
  if (timeout < DEFAULT_IFRAME_TIMEOUT_MS) {
12068
- _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.");
12171
+ _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.");
12069
12172
  }
12070
12173
  /*
12071
12174
  * Polling for iframes can be purely timing based,
@@ -12602,8 +12705,7 @@
12602
12705
  EventHandler: EventHandler,
12603
12706
  NativeMessageHandler: NativeMessageHandler,
12604
12707
  BrowserConstants: BrowserConstants,
12605
- get TemporaryCacheKeys () { return TemporaryCacheKeys; },
12606
- PopupUtils: PopupUtils
12708
+ get TemporaryCacheKeys () { return TemporaryCacheKeys; }
12607
12709
  });
12608
12710
 
12609
12711
  /*
@@ -13971,7 +14073,7 @@
13971
14073
  CryptoOps.prototype.signJwt = function (payload, kid, correlationId) {
13972
14074
  var _a;
13973
14075
  return __awaiter$1(this, void 0, void 0, function () {
13974
- var signJwtMeasurement, cachedKeyPair, publicKeyJwk, publicKeyJwkString, header, encodedHeader, encodedPayload, tokenString, tokenBuffer, signatureBuffer, encodedSignature, signedJwt;
14076
+ var signJwtMeasurement, cachedKeyPair, publicKeyJwk, publicKeyJwkString, encodedKeyIdThumbprint, shrHeader, encodedShrHeader, encodedPayload, tokenString, tokenBuffer, signatureBuffer, encodedSignature, signedJwt;
13975
14077
  return __generator$1(this, function (_b) {
13976
14078
  switch (_b.label) {
13977
14079
  case 0:
@@ -13986,17 +14088,15 @@
13986
14088
  case 2:
13987
14089
  publicKeyJwk = _b.sent();
13988
14090
  publicKeyJwkString = BrowserCrypto.getJwkString(publicKeyJwk);
13989
- header = {
13990
- alg: publicKeyJwk.alg,
13991
- type: KEY_FORMAT_JWK
13992
- };
13993
- encodedHeader = this.b64Encode.urlEncode(JSON.stringify(header));
14091
+ encodedKeyIdThumbprint = this.b64Encode.urlEncode(JSON.stringify({ kid: kid }));
14092
+ shrHeader = JoseHeader.getShrHeaderString({ kid: encodedKeyIdThumbprint, alg: publicKeyJwk.alg });
14093
+ encodedShrHeader = this.b64Encode.urlEncode(shrHeader);
13994
14094
  // Generate payload
13995
14095
  payload.cnf = {
13996
14096
  jwk: JSON.parse(publicKeyJwkString)
13997
14097
  };
13998
14098
  encodedPayload = this.b64Encode.urlEncode(JSON.stringify(payload));
13999
- tokenString = encodedHeader + "." + encodedPayload;
14099
+ tokenString = encodedShrHeader + "." + encodedPayload;
14000
14100
  tokenBuffer = BrowserStringUtils.stringToArrayBuffer(tokenString);
14001
14101
  return [4 /*yield*/, this.browserCrypto.sign(cachedKeyPair.privateKey, tokenBuffer)];
14002
14102
  case 3:
@@ -14140,7 +14240,7 @@
14140
14240
  throw BrowserAuthError.createUnableToLoadTokenError("Please provide an extendedExpiresOn value in the options.");
14141
14241
  }
14142
14242
  var scopes = new ScopeSet(request.scopes).printScopes();
14143
- var expiresOn = response.expires_in;
14243
+ var expiresOn = options.expiresOn || (response.expires_in + new Date().getTime() / 1000);
14144
14244
  var extendedExpiresOn = options.extendedExpiresOn;
14145
14245
  var accessTokenEntity = AccessTokenEntity.createAccessTokenEntity(homeAccountId, environment, response.access_token, this.config.auth.clientId, tenantId, scopes, expiresOn, extendedExpiresOn, this.cryptoObj);
14146
14246
  if (this.isBrowserEnvironment) {
@@ -14414,7 +14514,7 @@
14414
14514
  case 0:
14415
14515
  this.logger.trace("initialize called");
14416
14516
  if (this.initialized) {
14417
- this.logger.warning("initialize has already been called. This function only needs to be run once.");
14517
+ this.logger.info("initialize has already been called, exiting early.");
14418
14518
  return [2 /*return*/];
14419
14519
  }
14420
14520
  this.eventHandler.emitEvent(exports.EventType.INITIALIZE_START);