@azure/msal-browser 2.27.0 → 2.28.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 (89) hide show
  1. package/README.md +1 -1
  2. package/dist/_virtual/_tslib.js +1 -1
  3. package/dist/app/ClientApplication.d.ts +1 -0
  4. package/dist/app/ClientApplication.d.ts.map +1 -1
  5. package/dist/app/ClientApplication.js +34 -13
  6. package/dist/app/ClientApplication.js.map +1 -1
  7. package/dist/app/IPublicClientApplication.js +1 -1
  8. package/dist/app/PublicClientApplication.d.ts.map +1 -1
  9. package/dist/app/PublicClientApplication.js +5 -3
  10. package/dist/app/PublicClientApplication.js.map +1 -1
  11. package/dist/broker/nativeBroker/NativeMessageHandler.js +1 -1
  12. package/dist/cache/AsyncMemoryStorage.js +1 -1
  13. package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
  14. package/dist/cache/BrowserCacheManager.js +39 -8
  15. package/dist/cache/BrowserCacheManager.js.map +1 -1
  16. package/dist/cache/BrowserStorage.js +1 -1
  17. package/dist/cache/DatabaseStorage.js +1 -1
  18. package/dist/cache/MemoryStorage.js +1 -1
  19. package/dist/cache/TokenCache.js +1 -1
  20. package/dist/config/Configuration.js +1 -1
  21. package/dist/crypto/BrowserCrypto.js +1 -1
  22. package/dist/crypto/CryptoOps.js +1 -1
  23. package/dist/crypto/GuidGenerator.js +1 -1
  24. package/dist/crypto/PkceGenerator.js +1 -1
  25. package/dist/crypto/SignedHttpRequest.js +1 -1
  26. package/dist/encode/Base64Decode.js +1 -1
  27. package/dist/encode/Base64Encode.js +1 -1
  28. package/dist/error/BrowserAuthError.js +1 -1
  29. package/dist/error/BrowserConfigurationAuthError.js +1 -1
  30. package/dist/error/NativeAuthError.d.ts +9 -0
  31. package/dist/error/NativeAuthError.d.ts.map +1 -1
  32. package/dist/error/NativeAuthError.js +12 -1
  33. package/dist/error/NativeAuthError.js.map +1 -1
  34. package/dist/event/EventHandler.js +1 -1
  35. package/dist/event/EventMessage.js +1 -1
  36. package/dist/event/EventType.js +1 -1
  37. package/dist/index.cjs.js +408 -208
  38. package/dist/index.cjs.js.map +1 -1
  39. package/dist/index.js +1 -1
  40. package/dist/interaction_client/BaseInteractionClient.d.ts.map +1 -1
  41. package/dist/interaction_client/BaseInteractionClient.js +2 -3
  42. package/dist/interaction_client/BaseInteractionClient.js.map +1 -1
  43. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.js +1 -1
  44. package/dist/interaction_client/NativeInteractionClient.d.ts +18 -1
  45. package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
  46. package/dist/interaction_client/NativeInteractionClient.js +94 -15
  47. package/dist/interaction_client/NativeInteractionClient.js.map +1 -1
  48. package/dist/interaction_client/PopupClient.d.ts +2 -1
  49. package/dist/interaction_client/PopupClient.d.ts.map +1 -1
  50. package/dist/interaction_client/PopupClient.js +4 -3
  51. package/dist/interaction_client/PopupClient.js.map +1 -1
  52. package/dist/interaction_client/RedirectClient.d.ts +8 -1
  53. package/dist/interaction_client/RedirectClient.d.ts.map +1 -1
  54. package/dist/interaction_client/RedirectClient.js +6 -4
  55. package/dist/interaction_client/RedirectClient.js.map +1 -1
  56. package/dist/interaction_client/SilentAuthCodeClient.js +1 -1
  57. package/dist/interaction_client/SilentAuthCodeClient.js.map +1 -1
  58. package/dist/interaction_client/SilentCacheClient.d.ts.map +1 -1
  59. package/dist/interaction_client/SilentCacheClient.js +1 -1
  60. package/dist/interaction_client/SilentCacheClient.js.map +1 -1
  61. package/dist/interaction_client/SilentIframeClient.d.ts +2 -1
  62. package/dist/interaction_client/SilentIframeClient.d.ts.map +1 -1
  63. package/dist/interaction_client/SilentIframeClient.js +4 -3
  64. package/dist/interaction_client/SilentIframeClient.js.map +1 -1
  65. package/dist/interaction_client/SilentRefreshClient.d.ts.map +1 -1
  66. package/dist/interaction_client/SilentRefreshClient.js +1 -1
  67. package/dist/interaction_client/SilentRefreshClient.js.map +1 -1
  68. package/dist/interaction_client/StandardInteractionClient.js +1 -1
  69. package/dist/interaction_handler/InteractionHandler.js +1 -1
  70. package/dist/interaction_handler/RedirectHandler.js +1 -1
  71. package/dist/interaction_handler/SilentHandler.js +1 -1
  72. package/dist/internals.js +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/telemetry/BrowserPerformanceClient.js +1 -1
  80. package/dist/telemetry/BrowserPerformanceMeasurement.js +1 -1
  81. package/dist/utils/BrowserConstants.js +1 -1
  82. package/dist/utils/BrowserProtocolUtils.js +1 -1
  83. package/dist/utils/BrowserStringUtils.js +1 -1
  84. package/dist/utils/BrowserUtils.js +1 -1
  85. package/dist/utils/MathUtils.js +1 -1
  86. package/lib/msal-browser.js +408 -208
  87. package/lib/msal-browser.js.map +1 -1
  88. package/lib/msal-browser.min.js +32 -32
  89. package/package.json +2 -2
package/dist/index.cjs.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! @azure/msal-browser v2.27.0 2022-07-05 */
1
+ /*! @azure/msal-browser v2.28.0 2022-07-18 */
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 v7.1.0 2022-07-05 */
108
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
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 v7.1.0 2022-07-05 */
195
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
196
196
 
197
197
  /*
198
198
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -242,7 +242,8 @@ var Constants = {
242
242
  REGIONAL_AUTH_PUBLIC_CLOUD_SUFFIX: "login.microsoft.com",
243
243
  KNOWN_PUBLIC_CLOUDS: ["login.microsoftonline.com", "login.windows.net", "login.microsoft.com", "sts.windows.net"],
244
244
  TOKEN_RESPONSE_TYPE: "token",
245
- ID_TOKEN_RESPONSE_TYPE: "id_token"
245
+ ID_TOKEN_RESPONSE_TYPE: "id_token",
246
+ SHR_NONCE_VALIDITY: 240,
246
247
  };
247
248
  var OIDC_DEFAULT_SCOPES = [
248
249
  Constants.OPENID_SCOPE,
@@ -274,6 +275,7 @@ var PersistentCacheKeys;
274
275
  PersistentCacheKeys["ERROR"] = "error";
275
276
  PersistentCacheKeys["ERROR_DESC"] = "error.description";
276
277
  PersistentCacheKeys["ACTIVE_ACCOUNT"] = "active-account";
278
+ PersistentCacheKeys["ACTIVE_ACCOUNT_FILTERS"] = "active-account-filters"; // new cache entry for active_account for a more robust version for browser
277
279
  })(PersistentCacheKeys || (PersistentCacheKeys = {}));
278
280
  /**
279
281
  * String constants related to AAD Authority
@@ -567,7 +569,7 @@ var JsonTypes;
567
569
  JsonTypes["Jwk"] = "JWK";
568
570
  })(JsonTypes || (JsonTypes = {}));
569
571
 
570
- /*! @azure/msal-common v7.1.0 2022-07-05 */
572
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
571
573
 
572
574
  /*
573
575
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -611,7 +613,7 @@ var AuthError = /** @class */ (function (_super) {
611
613
  return AuthError;
612
614
  }(Error));
613
615
 
614
- /*! @azure/msal-common v7.1.0 2022-07-05 */
616
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
615
617
 
616
618
  /*
617
619
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -686,7 +688,7 @@ var DEFAULT_CRYPTO_IMPLEMENTATION = {
686
688
  }
687
689
  };
688
690
 
689
- /*! @azure/msal-common v7.1.0 2022-07-05 */
691
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
690
692
 
691
693
  /*
692
694
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1158,7 +1160,7 @@ var ClientAuthError = /** @class */ (function (_super) {
1158
1160
  return ClientAuthError;
1159
1161
  }(AuthError));
1160
1162
 
1161
- /*! @azure/msal-common v7.1.0 2022-07-05 */
1163
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
1162
1164
 
1163
1165
  /*
1164
1166
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1283,7 +1285,7 @@ var StringUtils = /** @class */ (function () {
1283
1285
  return StringUtils;
1284
1286
  }());
1285
1287
 
1286
- /*! @azure/msal-common v7.1.0 2022-07-05 */
1288
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
1287
1289
 
1288
1290
  /*
1289
1291
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1463,12 +1465,12 @@ var Logger = /** @class */ (function () {
1463
1465
  return Logger;
1464
1466
  }());
1465
1467
 
1466
- /*! @azure/msal-common v7.1.0 2022-07-05 */
1468
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
1467
1469
  /* eslint-disable header/header */
1468
1470
  var name$1 = "@azure/msal-common";
1469
- var version$1 = "7.1.0";
1471
+ var version$1 = "7.2.0";
1470
1472
 
1471
- /*! @azure/msal-common v7.1.0 2022-07-05 */
1473
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
1472
1474
  /*
1473
1475
  * Copyright (c) Microsoft Corporation. All rights reserved.
1474
1476
  * Licensed under the MIT License.
@@ -1489,7 +1491,7 @@ exports.AzureCloudInstance = void 0;
1489
1491
  AzureCloudInstance["AzureUsGovernment"] = "https://login.microsoftonline.us";
1490
1492
  })(exports.AzureCloudInstance || (exports.AzureCloudInstance = {}));
1491
1493
 
1492
- /*! @azure/msal-common v7.1.0 2022-07-05 */
1494
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
1493
1495
 
1494
1496
  /*
1495
1497
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1648,7 +1650,7 @@ var CredentialEntity = /** @class */ (function () {
1648
1650
  return CredentialEntity;
1649
1651
  }());
1650
1652
 
1651
- /*! @azure/msal-common v7.1.0 2022-07-05 */
1653
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
1652
1654
 
1653
1655
  /*
1654
1656
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1903,7 +1905,7 @@ var ClientConfigurationError = /** @class */ (function (_super) {
1903
1905
  return ClientConfigurationError;
1904
1906
  }(ClientAuthError));
1905
1907
 
1906
- /*! @azure/msal-common v7.1.0 2022-07-05 */
1908
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
1907
1909
 
1908
1910
  /*
1909
1911
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2087,7 +2089,7 @@ var ScopeSet = /** @class */ (function () {
2087
2089
  return ScopeSet;
2088
2090
  }());
2089
2091
 
2090
- /*! @azure/msal-common v7.1.0 2022-07-05 */
2092
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
2091
2093
 
2092
2094
  /*
2093
2095
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2125,7 +2127,7 @@ function buildClientInfoFromHomeAccountId(homeAccountId) {
2125
2127
  };
2126
2128
  }
2127
2129
 
2128
- /*! @azure/msal-common v7.1.0 2022-07-05 */
2130
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
2129
2131
  /*
2130
2132
  * Copyright (c) Microsoft Corporation. All rights reserved.
2131
2133
  * Licensed under the MIT License.
@@ -2139,7 +2141,7 @@ var AuthorityType;
2139
2141
  AuthorityType[AuthorityType["Adfs"] = 1] = "Adfs";
2140
2142
  })(AuthorityType || (AuthorityType = {}));
2141
2143
 
2142
- /*! @azure/msal-common v7.1.0 2022-07-05 */
2144
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
2143
2145
 
2144
2146
  /*
2145
2147
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2374,7 +2376,7 @@ var AccountEntity = /** @class */ (function () {
2374
2376
  return AccountEntity;
2375
2377
  }());
2376
2378
 
2377
- /*! @azure/msal-common v7.1.0 2022-07-05 */
2379
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
2378
2380
 
2379
2381
  /*
2380
2382
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2412,7 +2414,7 @@ var AuthToken = /** @class */ (function () {
2412
2414
  return AuthToken;
2413
2415
  }());
2414
2416
 
2415
- /*! @azure/msal-common v7.1.0 2022-07-05 */
2417
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
2416
2418
 
2417
2419
  /*
2418
2420
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2534,7 +2536,7 @@ var CacheManager = /** @class */ (function () {
2534
2536
  * @param realm
2535
2537
  */
2536
2538
  CacheManager.prototype.getAccountsFilteredBy = function (accountFilter) {
2537
- return this.getAccountsFilteredByInternal(accountFilter ? accountFilter.homeAccountId : Constants.EMPTY_STRING, accountFilter ? accountFilter.environment : Constants.EMPTY_STRING, accountFilter ? accountFilter.realm : Constants.EMPTY_STRING);
2539
+ return this.getAccountsFilteredByInternal(accountFilter ? accountFilter.homeAccountId : Constants.EMPTY_STRING, accountFilter ? accountFilter.environment : Constants.EMPTY_STRING, accountFilter ? accountFilter.realm : Constants.EMPTY_STRING, accountFilter ? accountFilter.nativeAccountId : Constants.EMPTY_STRING);
2538
2540
  };
2539
2541
  /**
2540
2542
  * retrieve accounts matching all provided filters; if no filter is set, get all accounts
@@ -2543,7 +2545,7 @@ var CacheManager = /** @class */ (function () {
2543
2545
  * @param environment
2544
2546
  * @param realm
2545
2547
  */
2546
- CacheManager.prototype.getAccountsFilteredByInternal = function (homeAccountId, environment, realm) {
2548
+ CacheManager.prototype.getAccountsFilteredByInternal = function (homeAccountId, environment, realm, nativeAccountId) {
2547
2549
  var _this = this;
2548
2550
  var allCacheKeys = this.getKeys();
2549
2551
  var matchingAccounts = {};
@@ -2561,6 +2563,9 @@ var CacheManager = /** @class */ (function () {
2561
2563
  if (!!realm && !_this.matchRealm(entity, realm)) {
2562
2564
  return;
2563
2565
  }
2566
+ if (!!nativeAccountId && !_this.matchNativeAccountId(entity, nativeAccountId)) {
2567
+ return;
2568
+ }
2564
2569
  matchingAccounts[cacheKey] = entity;
2565
2570
  });
2566
2571
  return matchingAccounts;
@@ -2889,6 +2894,26 @@ var CacheManager = /** @class */ (function () {
2889
2894
  var accountKey = AccountEntity.generateAccountCacheKey(account);
2890
2895
  return this.getAccount(accountKey);
2891
2896
  };
2897
+ /**
2898
+ * Retrieve AccountEntity from cache
2899
+ * @param nativeAccountId
2900
+ * @returns AccountEntity or Null
2901
+ */
2902
+ CacheManager.prototype.readAccountFromCacheWithNativeAccountId = function (nativeAccountId) {
2903
+ // fetch account from memory
2904
+ var accountFilter = {
2905
+ nativeAccountId: nativeAccountId
2906
+ };
2907
+ var accountCache = this.getAccountsFilteredBy(accountFilter);
2908
+ var accounts = Object.keys(accountCache).map(function (key) { return accountCache[key]; });
2909
+ if (accounts.length < 1) {
2910
+ return null;
2911
+ }
2912
+ else if (accounts.length > 1) {
2913
+ throw ClientAuthError.createMultipleMatchingAccountsInCacheError();
2914
+ }
2915
+ return accountCache[0];
2916
+ };
2892
2917
  /**
2893
2918
  * Retrieve IdTokenEntity from cache
2894
2919
  * @param clientId
@@ -3063,6 +3088,15 @@ var CacheManager = /** @class */ (function () {
3063
3088
  CacheManager.prototype.matchRealm = function (entity, realm) {
3064
3089
  return !!(entity.realm && realm === entity.realm);
3065
3090
  };
3091
+ /**
3092
+ * helper to match nativeAccountId
3093
+ * @param entity
3094
+ * @param nativeAccountId
3095
+ * @returns boolean indicating the match result
3096
+ */
3097
+ CacheManager.prototype.matchNativeAccountId = function (entity, nativeAccountId) {
3098
+ return !!(entity.nativeAccountId && nativeAccountId === entity.nativeAccountId);
3099
+ };
3066
3100
  /**
3067
3101
  * Returns true if the target scopes are a subset of the current entity's scopes, false otherwise.
3068
3102
  * @param entity
@@ -3254,7 +3288,7 @@ var DefaultStorageClass = /** @class */ (function (_super) {
3254
3288
  return DefaultStorageClass;
3255
3289
  }(CacheManager));
3256
3290
 
3257
- /*! @azure/msal-common v7.1.0 2022-07-05 */
3291
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
3258
3292
 
3259
3293
  /*
3260
3294
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3337,7 +3371,7 @@ function buildClientConfiguration(_a) {
3337
3371
  telemetry: __assign(__assign({}, DEFAULT_TELEMETRY_OPTIONS), telemetry),
3338
3372
  serverTelemetryManager: serverTelemetryManager || null,
3339
3373
  persistencePlugin: persistencePlugin || null,
3340
- serializableCache: serializableCache || null
3374
+ serializableCache: serializableCache || null,
3341
3375
  };
3342
3376
  }
3343
3377
  /**
@@ -3348,7 +3382,7 @@ function buildAuthOptions(authOptions) {
3348
3382
  return __assign({ clientCapabilities: [], azureCloudOptions: DEFAULT_AZURE_CLOUD_OPTIONS, skipAuthorityMetadataCache: false }, authOptions);
3349
3383
  }
3350
3384
 
3351
- /*! @azure/msal-common v7.1.0 2022-07-05 */
3385
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
3352
3386
 
3353
3387
  /*
3354
3388
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3368,7 +3402,7 @@ var ServerError = /** @class */ (function (_super) {
3368
3402
  return ServerError;
3369
3403
  }(AuthError));
3370
3404
 
3371
- /*! @azure/msal-common v7.1.0 2022-07-05 */
3405
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
3372
3406
 
3373
3407
  /*
3374
3408
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3464,7 +3498,7 @@ var ThrottlingUtils = /** @class */ (function () {
3464
3498
  return ThrottlingUtils;
3465
3499
  }());
3466
3500
 
3467
- /*! @azure/msal-common v7.1.0 2022-07-05 */
3501
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
3468
3502
 
3469
3503
  /*
3470
3504
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3513,7 +3547,7 @@ var NetworkManager = /** @class */ (function () {
3513
3547
  return NetworkManager;
3514
3548
  }());
3515
3549
 
3516
- /*! @azure/msal-common v7.1.0 2022-07-05 */
3550
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
3517
3551
  /*
3518
3552
  * Copyright (c) Microsoft Corporation. All rights reserved.
3519
3553
  * Licensed under the MIT License.
@@ -3524,7 +3558,7 @@ var CcsCredentialType;
3524
3558
  CcsCredentialType["UPN"] = "UPN";
3525
3559
  })(CcsCredentialType || (CcsCredentialType = {}));
3526
3560
 
3527
- /*! @azure/msal-common v7.1.0 2022-07-05 */
3561
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
3528
3562
 
3529
3563
  /*
3530
3564
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3613,7 +3647,7 @@ var BaseClient = /** @class */ (function () {
3613
3647
  return BaseClient;
3614
3648
  }());
3615
3649
 
3616
- /*! @azure/msal-common v7.1.0 2022-07-05 */
3650
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
3617
3651
 
3618
3652
  /*
3619
3653
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3699,7 +3733,7 @@ var RequestValidator = /** @class */ (function () {
3699
3733
  return RequestValidator;
3700
3734
  }());
3701
3735
 
3702
- /*! @azure/msal-common v7.1.0 2022-07-05 */
3736
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
3703
3737
 
3704
3738
  /*
3705
3739
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4077,7 +4111,7 @@ var RequestParameterBuilder = /** @class */ (function () {
4077
4111
  return RequestParameterBuilder;
4078
4112
  }());
4079
4113
 
4080
- /*! @azure/msal-common v7.1.0 2022-07-05 */
4114
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
4081
4115
 
4082
4116
  /*
4083
4117
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4141,7 +4175,7 @@ var IdTokenEntity = /** @class */ (function (_super) {
4141
4175
  return IdTokenEntity;
4142
4176
  }(CredentialEntity));
4143
4177
 
4144
- /*! @azure/msal-common v7.1.0 2022-07-05 */
4178
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
4145
4179
  /*
4146
4180
  * Copyright (c) Microsoft Corporation. All rights reserved.
4147
4181
  * Licensed under the MIT License.
@@ -4191,7 +4225,7 @@ var TimeUtils = /** @class */ (function () {
4191
4225
  return TimeUtils;
4192
4226
  }());
4193
4227
 
4194
- /*! @azure/msal-common v7.1.0 2022-07-05 */
4228
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
4195
4229
 
4196
4230
  /*
4197
4231
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4305,7 +4339,7 @@ var AccessTokenEntity = /** @class */ (function (_super) {
4305
4339
  return AccessTokenEntity;
4306
4340
  }(CredentialEntity));
4307
4341
 
4308
- /*! @azure/msal-common v7.1.0 2022-07-05 */
4342
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
4309
4343
 
4310
4344
  /*
4311
4345
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4372,7 +4406,7 @@ var RefreshTokenEntity = /** @class */ (function (_super) {
4372
4406
  return RefreshTokenEntity;
4373
4407
  }(CredentialEntity));
4374
4408
 
4375
- /*! @azure/msal-common v7.1.0 2022-07-05 */
4409
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
4376
4410
 
4377
4411
  /*
4378
4412
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4447,7 +4481,7 @@ var InteractionRequiredAuthError = /** @class */ (function (_super) {
4447
4481
  return InteractionRequiredAuthError;
4448
4482
  }(AuthError));
4449
4483
 
4450
- /*! @azure/msal-common v7.1.0 2022-07-05 */
4484
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
4451
4485
  /*
4452
4486
  * Copyright (c) Microsoft Corporation. All rights reserved.
4453
4487
  * Licensed under the MIT License.
@@ -4463,7 +4497,7 @@ var CacheRecord = /** @class */ (function () {
4463
4497
  return CacheRecord;
4464
4498
  }());
4465
4499
 
4466
- /*! @azure/msal-common v7.1.0 2022-07-05 */
4500
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
4467
4501
 
4468
4502
  /*
4469
4503
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4534,7 +4568,7 @@ var ProtocolUtils = /** @class */ (function () {
4534
4568
  return ProtocolUtils;
4535
4569
  }());
4536
4570
 
4537
- /*! @azure/msal-common v7.1.0 2022-07-05 */
4571
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
4538
4572
 
4539
4573
  /*
4540
4574
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4735,7 +4769,7 @@ var UrlString = /** @class */ (function () {
4735
4769
  return UrlString;
4736
4770
  }());
4737
4771
 
4738
- /*! @azure/msal-common v7.1.0 2022-07-05 */
4772
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
4739
4773
 
4740
4774
  /*
4741
4775
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4836,7 +4870,7 @@ var PopTokenGenerator = /** @class */ (function () {
4836
4870
  return PopTokenGenerator;
4837
4871
  }());
4838
4872
 
4839
- /*! @azure/msal-common v7.1.0 2022-07-05 */
4873
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
4840
4874
 
4841
4875
  /*
4842
4876
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4906,7 +4940,7 @@ var AppMetadataEntity = /** @class */ (function () {
4906
4940
  return AppMetadataEntity;
4907
4941
  }());
4908
4942
 
4909
- /*! @azure/msal-common v7.1.0 2022-07-05 */
4943
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
4910
4944
  /*
4911
4945
  * Copyright (c) Microsoft Corporation. All rights reserved.
4912
4946
  * Licensed under the MIT License.
@@ -4942,7 +4976,7 @@ var AppMetadataEntity = /** @class */ (function () {
4942
4976
  return TokenCacheContext;
4943
4977
  }());
4944
4978
 
4945
- /*! @azure/msal-common v7.1.0 2022-07-05 */
4979
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
4946
4980
 
4947
4981
  /*
4948
4982
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5003,7 +5037,7 @@ var ResponseHandler = /** @class */ (function () {
5003
5037
  * @param serverTokenResponse
5004
5038
  * @param authority
5005
5039
  */
5006
- ResponseHandler.prototype.handleServerTokenResponse = function (serverTokenResponse, authority, reqTimestamp, request, authCodePayload, userAssertionHash, handlingRefreshTokenResponse) {
5040
+ ResponseHandler.prototype.handleServerTokenResponse = function (serverTokenResponse, authority, reqTimestamp, request, authCodePayload, userAssertionHash, handlingRefreshTokenResponse, forceCacheRefreshTokenResponse) {
5007
5041
  return __awaiter(this, void 0, void 0, function () {
5008
5042
  var idTokenObj, requestStateObj, cacheRecord, cacheContext, key, account;
5009
5043
  return __generator(this, function (_a) {
@@ -5040,14 +5074,15 @@ var ResponseHandler = /** @class */ (function () {
5040
5074
  /*
5041
5075
  * When saving a refreshed tokens to the cache, it is expected that the account that was used is present in the cache.
5042
5076
  * If not present, we should return null, as it's the case that another application called removeAccount in between
5043
- * the calls to getAllAccounts and acquireTokenSilent. We should not overwrite that removal.
5077
+ * the calls to getAllAccounts and acquireTokenSilent. We should not overwrite that removal, unless explicitly flagged by
5078
+ * the developer, as in the case of refresh token flow used in ADAL Node to MSAL Node migration.
5044
5079
  */
5045
- if (handlingRefreshTokenResponse && cacheRecord.account) {
5080
+ if (handlingRefreshTokenResponse && !forceCacheRefreshTokenResponse && cacheRecord.account) {
5046
5081
  key = cacheRecord.account.generateAccountKey();
5047
5082
  account = this.cacheStorage.getAccount(key);
5048
5083
  if (!account) {
5049
5084
  this.logger.warning("Account used to refresh tokens not in persistence, refreshed tokens will not be stored in the cache");
5050
- return [2 /*return*/, ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenObj, requestStateObj)];
5085
+ return [2 /*return*/, ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenObj, requestStateObj, undefined)];
5051
5086
  }
5052
5087
  }
5053
5088
  return [4 /*yield*/, this.cacheStorage.saveCacheRecord(cacheRecord)];
@@ -5212,7 +5247,7 @@ var ResponseHandler = /** @class */ (function () {
5212
5247
  return ResponseHandler;
5213
5248
  }());
5214
5249
 
5215
- /*! @azure/msal-common v7.1.0 2022-07-05 */
5250
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
5216
5251
 
5217
5252
  /*
5218
5253
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5313,7 +5348,7 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
5313
5348
  throw ClientConfigurationError.createEmptyLogoutRequestError();
5314
5349
  }
5315
5350
  var queryString = this.createLogoutUrlQueryString(logoutRequest);
5316
- // Construct logout URI.
5351
+ // Construct logout URI
5317
5352
  return UrlString.appendQueryString(this.authority.endSessionEndpoint, queryString);
5318
5353
  };
5319
5354
  /**
@@ -5647,7 +5682,7 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
5647
5682
  return AuthorizationCodeClient;
5648
5683
  }(BaseClient));
5649
5684
 
5650
- /*! @azure/msal-common v7.1.0 2022-07-05 */
5685
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
5651
5686
 
5652
5687
  /*
5653
5688
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5673,7 +5708,7 @@ var RefreshTokenClient = /** @class */ (function (_super) {
5673
5708
  response = _a.sent();
5674
5709
  responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, this.config.serializableCache, this.config.persistencePlugin);
5675
5710
  responseHandler.validateTokenResponse(response.body);
5676
- return [2 /*return*/, responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request, undefined, undefined, true)];
5711
+ return [2 /*return*/, responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request, undefined, undefined, true, request.forceCache)];
5677
5712
  }
5678
5713
  });
5679
5714
  });
@@ -5860,7 +5895,7 @@ var RefreshTokenClient = /** @class */ (function (_super) {
5860
5895
  return RefreshTokenClient;
5861
5896
  }(BaseClient));
5862
5897
 
5863
- /*! @azure/msal-common v7.1.0 2022-07-05 */
5898
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
5864
5899
 
5865
5900
  /*
5866
5901
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5976,7 +6011,7 @@ var SilentFlowClient = /** @class */ (function (_super) {
5976
6011
  return SilentFlowClient;
5977
6012
  }(BaseClient));
5978
6013
 
5979
- /*! @azure/msal-common v7.1.0 2022-07-05 */
6014
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
5980
6015
  /*
5981
6016
  * Copyright (c) Microsoft Corporation. All rights reserved.
5982
6017
  * Licensed under the MIT License.
@@ -5988,7 +6023,7 @@ function isOpenIdConfigResponse(response) {
5988
6023
  response.hasOwnProperty("jwks_uri"));
5989
6024
  }
5990
6025
 
5991
- /*! @azure/msal-common v7.1.0 2022-07-05 */
6026
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
5992
6027
  /*
5993
6028
  * Copyright (c) Microsoft Corporation. All rights reserved.
5994
6029
  * Licensed under the MIT License.
@@ -5997,7 +6032,7 @@ var rawMetdataJSON = { "endpointMetadata": { "https://login.microsoftonline.com/
5997
6032
  var EndpointMetadata = rawMetdataJSON.endpointMetadata;
5998
6033
  var InstanceDiscoveryMetadata = rawMetdataJSON.instanceDiscoveryMetadata;
5999
6034
 
6000
- /*! @azure/msal-common v7.1.0 2022-07-05 */
6035
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
6001
6036
  /*
6002
6037
  * Copyright (c) Microsoft Corporation. All rights reserved.
6003
6038
  * Licensed under the MIT License.
@@ -6011,7 +6046,7 @@ exports.ProtocolMode = void 0;
6011
6046
  ProtocolMode["OIDC"] = "OIDC";
6012
6047
  })(exports.ProtocolMode || (exports.ProtocolMode = {}));
6013
6048
 
6014
- /*! @azure/msal-common v7.1.0 2022-07-05 */
6049
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
6015
6050
 
6016
6051
  /*
6017
6052
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6088,7 +6123,7 @@ var AuthorityMetadataEntity = /** @class */ (function () {
6088
6123
  return AuthorityMetadataEntity;
6089
6124
  }());
6090
6125
 
6091
- /*! @azure/msal-common v7.1.0 2022-07-05 */
6126
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
6092
6127
  /*
6093
6128
  * Copyright (c) Microsoft Corporation. All rights reserved.
6094
6129
  * Licensed under the MIT License.
@@ -6098,7 +6133,7 @@ function isCloudInstanceDiscoveryResponse(response) {
6098
6133
  response.hasOwnProperty("metadata"));
6099
6134
  }
6100
6135
 
6101
- /*! @azure/msal-common v7.1.0 2022-07-05 */
6136
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
6102
6137
 
6103
6138
  /*
6104
6139
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6220,7 +6255,7 @@ var RegionDiscovery = /** @class */ (function () {
6220
6255
  return RegionDiscovery;
6221
6256
  }());
6222
6257
 
6223
- /*! @azure/msal-common v7.1.0 2022-07-05 */
6258
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
6224
6259
 
6225
6260
  /*
6226
6261
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6882,7 +6917,7 @@ var Authority = /** @class */ (function () {
6882
6917
  return Authority;
6883
6918
  }());
6884
6919
 
6885
- /*! @azure/msal-common v7.1.0 2022-07-05 */
6920
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
6886
6921
 
6887
6922
  /*
6888
6923
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6943,7 +6978,7 @@ var AuthorityFactory = /** @class */ (function () {
6943
6978
  return AuthorityFactory;
6944
6979
  }());
6945
6980
 
6946
- /*! @azure/msal-common v7.1.0 2022-07-05 */
6981
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
6947
6982
 
6948
6983
  /*
6949
6984
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6974,7 +7009,7 @@ var ServerTelemetryEntity = /** @class */ (function () {
6974
7009
  return ServerTelemetryEntity;
6975
7010
  }());
6976
7011
 
6977
- /*! @azure/msal-common v7.1.0 2022-07-05 */
7012
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
6978
7013
 
6979
7014
  /*
6980
7015
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7002,7 +7037,7 @@ var ThrottlingEntity = /** @class */ (function () {
7002
7037
  return ThrottlingEntity;
7003
7038
  }());
7004
7039
 
7005
- /*! @azure/msal-common v7.1.0 2022-07-05 */
7040
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
7006
7041
 
7007
7042
  /*
7008
7043
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7019,7 +7054,7 @@ var StubbedNetworkModule = {
7019
7054
  }
7020
7055
  };
7021
7056
 
7022
- /*! @azure/msal-common v7.1.0 2022-07-05 */
7057
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
7023
7058
 
7024
7059
  /*
7025
7060
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7064,7 +7099,7 @@ var JoseHeaderError = /** @class */ (function (_super) {
7064
7099
  return JoseHeaderError;
7065
7100
  }(AuthError));
7066
7101
 
7067
- /*! @azure/msal-common v7.1.0 2022-07-05 */
7102
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
7068
7103
 
7069
7104
  /*
7070
7105
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7104,7 +7139,7 @@ var JoseHeader = /** @class */ (function () {
7104
7139
  return JoseHeader;
7105
7140
  }());
7106
7141
 
7107
- /*! @azure/msal-common v7.1.0 2022-07-05 */
7142
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
7108
7143
 
7109
7144
  /*
7110
7145
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7163,7 +7198,7 @@ var AuthenticationHeaderParser = /** @class */ (function () {
7163
7198
  return AuthenticationHeaderParser;
7164
7199
  }());
7165
7200
 
7166
- /*! @azure/msal-common v7.1.0 2022-07-05 */
7201
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
7167
7202
 
7168
7203
  /*
7169
7204
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7325,7 +7360,7 @@ var ServerTelemetryManager = /** @class */ (function () {
7325
7360
  return ServerTelemetryManager;
7326
7361
  }());
7327
7362
 
7328
- /*! @azure/msal-common v7.1.0 2022-07-05 */
7363
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
7329
7364
  /*
7330
7365
  * Copyright (c) Microsoft Corporation. All rights reserved.
7331
7366
  * Licensed under the MIT License.
@@ -7408,6 +7443,19 @@ exports.PerformanceEvents = void 0;
7408
7443
  * Used to acquire a token from Native component when native brokering is enabled.
7409
7444
  */
7410
7445
  PerformanceEvents["NativeInteractionClientAcquireToken"] = "nativeInteractionClientAcquireToken";
7446
+ /**
7447
+ * Used to measure the time taken for completing embedded-broker handshake (PW-Broker).
7448
+ */
7449
+ PerformanceEvents["BrokerHandhshake"] = "brokerHandshake";
7450
+ /**
7451
+ * acquireTokenByRefreshToken API in BrokerClientApplication (PW-Broker) .
7452
+ */
7453
+ PerformanceEvents["AcquireTokenByRefreshTokenInBroker"] = "acquireTokenByRefreshTokenInBroker";
7454
+ /**
7455
+ * acquireToken API in BrokerClientApplication.
7456
+ * Used to acquire a token on behalf of the embedded application (PW-Broker).
7457
+ */
7458
+ PerformanceEvents["AcquireTokenByBroker"] = "acquireTokenByBroker";
7411
7459
  })(exports.PerformanceEvents || (exports.PerformanceEvents = {}));
7412
7460
  /**
7413
7461
  * State of the performance event.
@@ -7422,7 +7470,7 @@ var PerformanceEventStatus;
7422
7470
  PerformanceEventStatus[PerformanceEventStatus["Completed"] = 2] = "Completed";
7423
7471
  })(PerformanceEventStatus || (PerformanceEventStatus = {}));
7424
7472
 
7425
- /*! @azure/msal-common v7.1.0 2022-07-05 */
7473
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
7426
7474
 
7427
7475
  /*
7428
7476
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7480,7 +7528,7 @@ var PerformanceClient = /** @class */ (function () {
7480
7528
  clientId: this.clientId,
7481
7529
  name: measureName,
7482
7530
  startTimeMs: Date.now(),
7483
- correlationId: eventCorrelationId
7531
+ correlationId: eventCorrelationId,
7484
7532
  };
7485
7533
  // Store in progress events so they can be discarded if not ended properly
7486
7534
  this.cacheEventByCorrelationId(inProgressEvent);
@@ -7625,6 +7673,12 @@ var PerformanceClient = /** @class */ (function () {
7625
7673
  else {
7626
7674
  _this.logger.verbose("PerformanceClient: Submeasurement for " + measureName + " already exists for " + current.name + ", ignoring", correlationId);
7627
7675
  }
7676
+ if (current.accessTokenSize) {
7677
+ previous.accessTokenSize = current.accessTokenSize;
7678
+ }
7679
+ if (current.idTokenSize) {
7680
+ previous.idTokenSize = current.idTokenSize;
7681
+ }
7628
7682
  }
7629
7683
  return previous;
7630
7684
  }, topLevelEvent);
@@ -7692,7 +7746,7 @@ var PerformanceClient = /** @class */ (function () {
7692
7746
  return PerformanceClient;
7693
7747
  }());
7694
7748
 
7695
- /*! @azure/msal-common v7.1.0 2022-07-05 */
7749
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
7696
7750
 
7697
7751
  /*
7698
7752
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8912,26 +8966,57 @@ var BrowserCacheManager = /** @class */ (function (_super) {
8912
8966
  * Gets the active account
8913
8967
  */
8914
8968
  BrowserCacheManager.prototype.getActiveAccount = function () {
8915
- var activeAccountIdKey = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT);
8916
- var activeAccountId = this.browserStorage.getItem(activeAccountIdKey);
8917
- if (!activeAccountId) {
8969
+ var activeAccountKeyFilters = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT_FILTERS);
8970
+ var activeAccountValueFilters = this.getItem(activeAccountKeyFilters);
8971
+ if (!activeAccountValueFilters) {
8972
+ // if new active account cache type isn't found, it's an old version, so look for that instead
8973
+ this.logger.trace("No active account filters cache schema found, looking for legacy schema");
8974
+ var activeAccountKeyLocal = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT);
8975
+ var activeAccountValueLocal = this.getItem(activeAccountKeyLocal);
8976
+ if (!activeAccountValueLocal) {
8977
+ this.logger.trace("No active account found");
8978
+ return null;
8979
+ }
8980
+ var activeAccount = this.getAccountInfoByFilter({ localAccountId: activeAccountValueLocal })[0] || null;
8981
+ if (activeAccount) {
8982
+ this.logger.trace("Legacy active account cache schema found");
8983
+ this.logger.trace("Adding active account filters cache schema");
8984
+ this.setActiveAccount(activeAccount);
8985
+ return activeAccount;
8986
+ }
8918
8987
  return null;
8919
8988
  }
8920
- return this.getAccountInfoByFilter({ localAccountId: activeAccountId })[0] || null;
8989
+ var activeAccountValueObj = this.validateAndParseJson(activeAccountValueFilters);
8990
+ if (activeAccountValueObj) {
8991
+ this.logger.trace("Active account filters schema found");
8992
+ return this.getAccountInfoByFilter({
8993
+ homeAccountId: activeAccountValueObj.homeAccountId,
8994
+ localAccountId: activeAccountValueObj.localAccountId
8995
+ })[0] || null;
8996
+ }
8997
+ this.logger.trace("No active account found");
8998
+ return null;
8921
8999
  };
8922
9000
  /**
8923
9001
  * Sets the active account's localAccountId in cache
8924
9002
  * @param account
8925
9003
  */
8926
9004
  BrowserCacheManager.prototype.setActiveAccount = function (account) {
8927
- var activeAccountIdKey = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT);
9005
+ var activeAccountKey = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT_FILTERS);
9006
+ var activeAccountKeyLocal = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT);
8928
9007
  if (account) {
8929
9008
  this.logger.verbose("setActiveAccount: Active account set");
8930
- this.browserStorage.setItem(activeAccountIdKey, account.localAccountId);
9009
+ var activeAccountValue = {
9010
+ homeAccountId: account.homeAccountId,
9011
+ localAccountId: account.localAccountId
9012
+ };
9013
+ this.browserStorage.setItem(activeAccountKey, JSON.stringify(activeAccountValue));
9014
+ this.browserStorage.setItem(activeAccountKeyLocal, account.localAccountId);
8931
9015
  }
8932
9016
  else {
8933
9017
  this.logger.verbose("setActiveAccount: No account passed, active account not set");
8934
- this.browserStorage.removeItem(activeAccountIdKey);
9018
+ this.browserStorage.removeItem(activeAccountKey);
9019
+ this.browserStorage.removeItem(activeAccountKeyLocal);
8935
9020
  }
8936
9021
  };
8937
9022
  /**
@@ -9489,7 +9574,7 @@ var DEFAULT_BROWSER_CACHE_MANAGER = function (clientId, logger) {
9489
9574
 
9490
9575
  /* eslint-disable header/header */
9491
9576
  var name = "@azure/msal-browser";
9492
- var version = "2.27.0";
9577
+ var version = "2.28.0";
9493
9578
 
9494
9579
  /*
9495
9580
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -10038,8 +10123,7 @@ var BaseInteractionClient = /** @class */ (function () {
10038
10123
  protocolMode: this.config.auth.protocolMode,
10039
10124
  knownAuthorities: this.config.auth.knownAuthorities,
10040
10125
  cloudDiscoveryMetadata: this.config.auth.cloudDiscoveryMetadata,
10041
- authorityMetadata: this.config.auth.authorityMetadata,
10042
- skipAuthorityMetadataCache: this.config.auth.skipAuthorityMetadataCache,
10126
+ authorityMetadata: this.config.auth.authorityMetadata
10043
10127
  };
10044
10128
  if (!requestAuthority) return [3 /*break*/, 2];
10045
10129
  this.logger.verbose("Creating discovered authority with request authority");
@@ -10671,6 +10755,10 @@ var NativeAuthErrorMessage = {
10671
10755
  userSwitch: {
10672
10756
  code: "user_switch",
10673
10757
  desc: "User attempted to switch accounts in the native broker, which is not allowed. All new accounts must sign-in through the standard web flow first, please try again."
10758
+ },
10759
+ tokensNotFoundInCache: {
10760
+ code: "tokens_not_found_in_internal_memory_cache",
10761
+ desc: "Tokens not cached in MSAL JS internal memory, please make the WAM request"
10674
10762
  }
10675
10763
  };
10676
10764
  var NativeAuthError = /** @class */ (function (_super) {
@@ -10725,20 +10813,122 @@ var NativeAuthError = /** @class */ (function (_super) {
10725
10813
  NativeAuthError.createUserSwitchError = function () {
10726
10814
  return new NativeAuthError(NativeAuthErrorMessage.userSwitch.code, NativeAuthErrorMessage.userSwitch.desc);
10727
10815
  };
10816
+ /**
10817
+ * Creates a tokens not found error when the internal cache look up fails
10818
+ * @returns NativeAuthError: tokensNotFoundInCache
10819
+ */
10820
+ NativeAuthError.createTokensNotFoundInCacheError = function () {
10821
+ return new NativeAuthError(NativeAuthErrorMessage.tokensNotFoundInCache.code, NativeAuthErrorMessage.tokensNotFoundInCache.desc);
10822
+ };
10728
10823
  return NativeAuthError;
10729
10824
  }(AuthError));
10730
10825
 
10826
+ /*
10827
+ * Copyright (c) Microsoft Corporation. All rights reserved.
10828
+ * Licensed under the MIT License.
10829
+ */
10830
+ var SilentCacheClient = /** @class */ (function (_super) {
10831
+ __extends$1(SilentCacheClient, _super);
10832
+ function SilentCacheClient() {
10833
+ return _super !== null && _super.apply(this, arguments) || this;
10834
+ }
10835
+ /**
10836
+ * Returns unexpired tokens from the cache, if available
10837
+ * @param silentRequest
10838
+ */
10839
+ SilentCacheClient.prototype.acquireToken = function (silentRequest) {
10840
+ return __awaiter$1(this, void 0, void 0, function () {
10841
+ var acquireTokenMeasurement, serverTelemetryManager, silentAuthClient, cachedToken, error_1;
10842
+ return __generator$1(this, function (_a) {
10843
+ switch (_a.label) {
10844
+ case 0:
10845
+ acquireTokenMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.SilentCacheClientAcquireToken, silentRequest.correlationId);
10846
+ serverTelemetryManager = this.initializeServerTelemetryManager(exports.ApiId.acquireTokenSilent_silentFlow);
10847
+ return [4 /*yield*/, this.createSilentFlowClient(serverTelemetryManager, silentRequest.authority, silentRequest.azureCloudOptions)];
10848
+ case 1:
10849
+ silentAuthClient = _a.sent();
10850
+ this.logger.verbose("Silent auth client created");
10851
+ _a.label = 2;
10852
+ case 2:
10853
+ _a.trys.push([2, 4, , 5]);
10854
+ return [4 /*yield*/, silentAuthClient.acquireCachedToken(silentRequest)];
10855
+ case 3:
10856
+ cachedToken = _a.sent();
10857
+ acquireTokenMeasurement.endMeasurement({
10858
+ success: true,
10859
+ fromCache: true
10860
+ });
10861
+ return [2 /*return*/, cachedToken];
10862
+ case 4:
10863
+ error_1 = _a.sent();
10864
+ if (error_1 instanceof BrowserAuthError && error_1.errorCode === BrowserAuthErrorMessage.signingKeyNotFoundInStorage.code) {
10865
+ this.logger.verbose("Signing keypair for bound access token not found. Refreshing bound access token and generating a new crypto keypair.");
10866
+ }
10867
+ acquireTokenMeasurement.endMeasurement({
10868
+ errorCode: error_1 instanceof AuthError && error_1.errorCode || undefined,
10869
+ subErrorCode: error_1 instanceof AuthError && error_1.subError || undefined,
10870
+ success: false
10871
+ });
10872
+ throw error_1;
10873
+ case 5: return [2 /*return*/];
10874
+ }
10875
+ });
10876
+ });
10877
+ };
10878
+ /**
10879
+ * Currently Unsupported
10880
+ */
10881
+ SilentCacheClient.prototype.logout = function () {
10882
+ // Synchronous so we must reject
10883
+ return Promise.reject(BrowserAuthError.createSilentLogoutUnsupportedError());
10884
+ };
10885
+ /**
10886
+ * Creates an Silent Flow Client with the given authority, or the default authority.
10887
+ * @param serverTelemetryManager
10888
+ * @param authorityUrl
10889
+ */
10890
+ SilentCacheClient.prototype.createSilentFlowClient = function (serverTelemetryManager, authorityUrl, azureCloudOptions) {
10891
+ return __awaiter$1(this, void 0, void 0, function () {
10892
+ var clientConfig;
10893
+ return __generator$1(this, function (_a) {
10894
+ switch (_a.label) {
10895
+ case 0: return [4 /*yield*/, this.getClientConfiguration(serverTelemetryManager, authorityUrl, azureCloudOptions)];
10896
+ case 1:
10897
+ clientConfig = _a.sent();
10898
+ return [2 /*return*/, new SilentFlowClient(clientConfig)];
10899
+ }
10900
+ });
10901
+ });
10902
+ };
10903
+ SilentCacheClient.prototype.initializeSilentRequest = function (request, account) {
10904
+ return __awaiter$1(this, void 0, void 0, function () {
10905
+ var _a;
10906
+ return __generator$1(this, function (_b) {
10907
+ switch (_b.label) {
10908
+ case 0:
10909
+ _a = [__assign$1({}, request)];
10910
+ return [4 /*yield*/, this.initializeBaseRequest(request)];
10911
+ case 1: return [2 /*return*/, __assign$1.apply(void 0, [__assign$1.apply(void 0, _a.concat([_b.sent()])), { account: account, forceRefresh: request.forceRefresh || false }])];
10912
+ }
10913
+ });
10914
+ });
10915
+ };
10916
+ return SilentCacheClient;
10917
+ }(StandardInteractionClient));
10918
+
10731
10919
  /*
10732
10920
  * Copyright (c) Microsoft Corporation. All rights reserved.
10733
10921
  * Licensed under the MIT License.
10734
10922
  */
10735
10923
  var NativeInteractionClient = /** @class */ (function (_super) {
10736
10924
  __extends$1(NativeInteractionClient, _super);
10737
- function NativeInteractionClient(config, browserStorage, browserCrypto, logger, eventHandler, navigationClient, apiId, performanceClient, provider, accountId, correlationId) {
10925
+ function NativeInteractionClient(config, browserStorage, browserCrypto, logger, eventHandler, navigationClient, apiId, performanceClient, provider, accountId, nativeStorageImpl, correlationId) {
10738
10926
  var _this = _super.call(this, config, browserStorage, browserCrypto, logger, eventHandler, navigationClient, performanceClient, provider, correlationId) || this;
10739
10927
  _this.apiId = apiId;
10740
10928
  _this.accountId = accountId;
10741
10929
  _this.nativeMessageHandler = provider;
10930
+ _this.nativeStorageManager = nativeStorageImpl;
10931
+ _this.silentCacheClient = new SilentCacheClient(config, _this.nativeStorageManager, browserCrypto, logger, eventHandler, navigationClient, performanceClient, provider, correlationId);
10742
10932
  return _this;
10743
10933
  }
10744
10934
  /**
@@ -10747,22 +10937,40 @@ var NativeInteractionClient = /** @class */ (function (_super) {
10747
10937
  */
10748
10938
  NativeInteractionClient.prototype.acquireToken = function (request) {
10749
10939
  return __awaiter$1(this, void 0, void 0, function () {
10750
- var nativeATMeasurement, nativeRequest, messageBody, reqTimestamp, response, validatedResponse;
10940
+ var nativeATMeasurement, reqTimestamp, nativeRequest, result, messageBody, response, validatedResponse;
10751
10941
  return __generator$1(this, function (_a) {
10752
10942
  switch (_a.label) {
10753
10943
  case 0:
10754
10944
  this.logger.trace("NativeInteractionClient - acquireToken called.");
10755
10945
  nativeATMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.NativeInteractionClientAcquireToken, request.correlationId);
10946
+ reqTimestamp = TimeUtils.nowSeconds();
10756
10947
  return [4 /*yield*/, this.initializeNativeRequest(request)];
10757
10948
  case 1:
10758
10949
  nativeRequest = _a.sent();
10950
+ _a.label = 2;
10951
+ case 2:
10952
+ _a.trys.push([2, 4, , 5]);
10953
+ return [4 /*yield*/, this.acquireTokensFromCache(this.accountId, nativeRequest)];
10954
+ case 3:
10955
+ result = _a.sent();
10956
+ nativeATMeasurement.endMeasurement({
10957
+ success: true,
10958
+ isNativeBroker: true,
10959
+ fromCache: true
10960
+ });
10961
+ return [2 /*return*/, result];
10962
+ case 4:
10963
+ _a.sent();
10964
+ // continue with a native call for any and all errors
10965
+ this.logger.info("MSAL internal Cache does not contain tokens, proceed to make a native call");
10966
+ return [3 /*break*/, 5];
10967
+ case 5:
10759
10968
  messageBody = {
10760
10969
  method: NativeExtensionMethod.GetToken,
10761
10970
  request: nativeRequest
10762
10971
  };
10763
- reqTimestamp = TimeUtils.nowSeconds();
10764
10972
  return [4 /*yield*/, this.nativeMessageHandler.sendMessage(messageBody)];
10765
- case 2:
10973
+ case 6:
10766
10974
  response = _a.sent();
10767
10975
  validatedResponse = this.validateNativeResponse(response);
10768
10976
  return [2 /*return*/, this.handleNativeResponse(validatedResponse, nativeRequest, reqTimestamp)
@@ -10786,13 +10994,61 @@ var NativeInteractionClient = /** @class */ (function (_super) {
10786
10994
  });
10787
10995
  });
10788
10996
  };
10997
+ /**
10998
+ * Creates silent flow request
10999
+ * @param request
11000
+ * @param cachedAccount
11001
+ * @returns CommonSilentFlowRequest
11002
+ */
11003
+ NativeInteractionClient.prototype.createSilentCacheRequest = function (request, cachedAccount) {
11004
+ return {
11005
+ authority: request.authority,
11006
+ correlationId: this.correlationId,
11007
+ scopes: ScopeSet.fromString(request.scopes).asArray(),
11008
+ account: cachedAccount,
11009
+ forceRefresh: false,
11010
+ };
11011
+ };
11012
+ /**
11013
+ * Fetches the tokens from the cache if un-expired
11014
+ * @param nativeAccountId
11015
+ * @param request
11016
+ * @returns authenticationResult
11017
+ */
11018
+ NativeInteractionClient.prototype.acquireTokensFromCache = function (nativeAccountId, request) {
11019
+ return __awaiter$1(this, void 0, void 0, function () {
11020
+ var accountEntity, account, silentRequest, result, e_2;
11021
+ return __generator$1(this, function (_a) {
11022
+ switch (_a.label) {
11023
+ case 0:
11024
+ accountEntity = this.browserStorage.readAccountFromCacheWithNativeAccountId(nativeAccountId);
11025
+ if (!accountEntity) {
11026
+ throw ClientAuthError.createNoAccountFoundError();
11027
+ }
11028
+ account = accountEntity.getAccountInfo();
11029
+ _a.label = 1;
11030
+ case 1:
11031
+ _a.trys.push([1, 3, , 4]);
11032
+ silentRequest = this.createSilentCacheRequest(request, account);
11033
+ return [4 /*yield*/, this.silentCacheClient.acquireToken(silentRequest)];
11034
+ case 2:
11035
+ result = _a.sent();
11036
+ return [2 /*return*/, result];
11037
+ case 3:
11038
+ e_2 = _a.sent();
11039
+ throw e_2;
11040
+ case 4: return [2 /*return*/];
11041
+ }
11042
+ });
11043
+ });
11044
+ };
10789
11045
  /**
10790
11046
  * Acquires a token from native platform then redirects to the redirectUri instead of returning the response
10791
11047
  * @param request
10792
11048
  */
10793
11049
  NativeInteractionClient.prototype.acquireTokenRedirect = function (request) {
10794
11050
  return __awaiter$1(this, void 0, void 0, function () {
10795
- var nativeRequest, messageBody, response, e_1, navigationOptions, redirectUri;
11051
+ var nativeRequest, messageBody, response, e_3, navigationOptions, redirectUri;
10796
11052
  return __generator$1(this, function (_a) {
10797
11053
  switch (_a.label) {
10798
11054
  case 0:
@@ -10813,10 +11069,10 @@ var NativeInteractionClient = /** @class */ (function (_super) {
10813
11069
  this.validateNativeResponse(response);
10814
11070
  return [3 /*break*/, 5];
10815
11071
  case 4:
10816
- e_1 = _a.sent();
11072
+ e_3 = _a.sent();
10817
11073
  // Only throw fatal errors here to allow application to fallback to regular redirect. Otherwise proceed and the error will be thrown in handleRedirectPromise
10818
- if (e_1 instanceof NativeAuthError && e_1.isFatal()) {
10819
- throw e_1;
11074
+ if (e_3 instanceof NativeAuthError && e_3.isFatal()) {
11075
+ throw e_3;
10820
11076
  }
10821
11077
  return [3 /*break*/, 5];
10822
11078
  case 5:
@@ -10840,7 +11096,7 @@ var NativeInteractionClient = /** @class */ (function (_super) {
10840
11096
  */
10841
11097
  NativeInteractionClient.prototype.handleRedirectPromise = function () {
10842
11098
  return __awaiter$1(this, void 0, void 0, function () {
10843
- var cachedRequest, messageBody, reqTimestamp, response, result, e_2;
11099
+ var cachedRequest, messageBody, reqTimestamp, response, result, e_4;
10844
11100
  return __generator$1(this, function (_a) {
10845
11101
  switch (_a.label) {
10846
11102
  case 0:
@@ -10872,9 +11128,9 @@ var NativeInteractionClient = /** @class */ (function (_super) {
10872
11128
  this.browserStorage.setInteractionInProgress(false);
10873
11129
  return [2 /*return*/, result];
10874
11130
  case 3:
10875
- e_2 = _a.sent();
11131
+ e_4 = _a.sent();
10876
11132
  this.browserStorage.setInteractionInProgress(false);
10877
- throw e_2;
11133
+ throw e_4;
10878
11134
  case 4: return [2 /*return*/];
10879
11135
  }
10880
11136
  });
@@ -10896,7 +11152,7 @@ var NativeInteractionClient = /** @class */ (function (_super) {
10896
11152
  */
10897
11153
  NativeInteractionClient.prototype.handleNativeResponse = function (response, request, reqTimestamp) {
10898
11154
  return __awaiter$1(this, void 0, void 0, function () {
10899
- var idTokenObj, authority, authorityPreferredCache, homeAccountIdentifier, accountEntity, responseScopes, accountProperties, uid, tid, responseAccessToken, responseTokenType, _a, popTokenGenerator, shrParameters, mats, result;
11155
+ var idTokenObj, authority, authorityPreferredCache, homeAccountIdentifier, accountEntity, responseScopes, accountProperties, uid, tid, responseAccessToken, responseTokenType, _a, popTokenGenerator, shrParameters, mats, result, idTokenEntity, expiresIn, tokenExpirationSeconds, accessTokenEntity;
10900
11156
  var _this = this;
10901
11157
  return __generator$1(this, function (_b) {
10902
11158
  switch (_b.label) {
@@ -10974,7 +11230,17 @@ var NativeInteractionClient = /** @class */ (function (_super) {
10974
11230
  state: response.state,
10975
11231
  fromNativeBroker: true
10976
11232
  };
10977
- // Remove any existing cached tokens for this account
11233
+ idTokenEntity = IdTokenEntity.createIdTokenEntity(homeAccountIdentifier, request.authority, response.id_token || Constants.EMPTY_STRING, request.clientId, idTokenObj.claims.tid || Constants.EMPTY_STRING);
11234
+ this.nativeStorageManager.setIdTokenCredential(idTokenEntity);
11235
+ expiresIn = (responseTokenType === exports.AuthenticationScheme.POP)
11236
+ ? Constants.SHR_NONCE_VALIDITY
11237
+ : (typeof response.expires_in === "string"
11238
+ ? parseInt(response.expires_in, 10)
11239
+ : response.expires_in) || 0;
11240
+ tokenExpirationSeconds = reqTimestamp + expiresIn;
11241
+ accessTokenEntity = AccessTokenEntity.createAccessTokenEntity(homeAccountIdentifier, request.authority, responseAccessToken, request.clientId, tid, responseScopes.printScopes(), tokenExpirationSeconds, 0, this.browserCrypto);
11242
+ this.nativeStorageManager.setAccessTokenCredential(accessTokenEntity);
11243
+ // Remove any existing cached tokens for this account in browser storage
10978
11244
  this.browserStorage.removeAccountContext(accountEntity).catch(function (e) {
10979
11245
  _this.logger.error("Error occurred while removing account context from browser storage. " + e);
10980
11246
  });
@@ -11338,8 +11604,10 @@ var NativeMessageHandler = /** @class */ (function () {
11338
11604
  */
11339
11605
  var RedirectClient = /** @class */ (function (_super) {
11340
11606
  __extends$1(RedirectClient, _super);
11341
- function RedirectClient() {
11342
- return _super !== null && _super.apply(this, arguments) || this;
11607
+ function RedirectClient(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, performanceClient, nativeStorageImpl, nativeMessageHandler, correlationId) {
11608
+ var _this = _super.call(this, config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, performanceClient, nativeMessageHandler, correlationId) || this;
11609
+ _this.nativeStorage = nativeStorageImpl;
11610
+ return _this;
11343
11611
  }
11344
11612
  /**
11345
11613
  * Redirects the page to the /authorize endpoint of the IDP
@@ -11548,7 +11816,7 @@ var RedirectClient = /** @class */ (function (_super) {
11548
11816
  if (!this.nativeMessageHandler) {
11549
11817
  throw BrowserAuthError.createNativeConnectionNotEstablishedError();
11550
11818
  }
11551
- nativeInteractionClient = new NativeInteractionClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, exports.ApiId.acquireTokenPopup, this.performanceClient, this.nativeMessageHandler, serverParams.accountId, cachedRequest.correlationId);
11819
+ nativeInteractionClient = new NativeInteractionClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, exports.ApiId.acquireTokenPopup, this.performanceClient, this.nativeMessageHandler, serverParams.accountId, this.browserStorage, cachedRequest.correlationId);
11552
11820
  userRequestState = ProtocolUtils.parseRequestState(this.browserCrypto, state).userRequestState;
11553
11821
  return [2 /*return*/, nativeInteractionClient.acquireToken(__assign$1(__assign$1({}, cachedRequest), { state: userRequestState, prompt: undefined // Server should handle the prompt, ideally native broker can do this part silently
11554
11822
  })).finally(function () {
@@ -11666,10 +11934,11 @@ var RedirectClient = /** @class */ (function (_super) {
11666
11934
  */
11667
11935
  var PopupClient = /** @class */ (function (_super) {
11668
11936
  __extends$1(PopupClient, _super);
11669
- function PopupClient(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, performanceClient, nativeMessageHandler, correlationId) {
11937
+ function PopupClient(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, performanceClient, nativeStorageImpl, nativeMessageHandler, correlationId) {
11670
11938
  var _this = _super.call(this, config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, performanceClient, nativeMessageHandler, correlationId) || this;
11671
11939
  // Properly sets this reference for the unload event.
11672
11940
  _this.unloadWindow = _this.unloadWindow.bind(_this);
11941
+ _this.nativeStorage = nativeStorageImpl;
11673
11942
  return _this;
11674
11943
  }
11675
11944
  /**
@@ -11794,7 +12063,7 @@ var PopupClient = /** @class */ (function (_super) {
11794
12063
  if (!this.nativeMessageHandler) {
11795
12064
  throw BrowserAuthError.createNativeConnectionNotEstablishedError();
11796
12065
  }
11797
- nativeInteractionClient = new NativeInteractionClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, exports.ApiId.acquireTokenPopup, this.performanceClient, this.nativeMessageHandler, serverParams.accountId, validRequest.correlationId);
12066
+ nativeInteractionClient = new NativeInteractionClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, exports.ApiId.acquireTokenPopup, this.performanceClient, this.nativeMessageHandler, serverParams.accountId, this.nativeStorage, validRequest.correlationId);
11798
12067
  userRequestState = ProtocolUtils.parseRequestState(this.browserCrypto, state_1).userRequestState;
11799
12068
  return [2 /*return*/, nativeInteractionClient.acquireToken(__assign$1(__assign$1({}, validRequest), { state: userRequestState, prompt: undefined // Server should handle the prompt, ideally native broker can do this part silently
11800
12069
  })).finally(function () {
@@ -12422,9 +12691,10 @@ var SilentHandler = /** @class */ (function (_super) {
12422
12691
  */
12423
12692
  var SilentIframeClient = /** @class */ (function (_super) {
12424
12693
  __extends$1(SilentIframeClient, _super);
12425
- function SilentIframeClient(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, apiId, performanceClient, nativeMessageHandler, correlationId) {
12694
+ function SilentIframeClient(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, apiId, performanceClient, nativeStorageImpl, nativeMessageHandler, correlationId) {
12426
12695
  var _this = _super.call(this, config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, performanceClient, nativeMessageHandler, correlationId) || this;
12427
12696
  _this.apiId = apiId;
12697
+ _this.nativeStorage = nativeStorageImpl;
12428
12698
  return _this;
12429
12699
  }
12430
12700
  /**
@@ -12527,7 +12797,7 @@ var SilentIframeClient = /** @class */ (function (_super) {
12527
12797
  if (!this.nativeMessageHandler) {
12528
12798
  throw BrowserAuthError.createNativeConnectionNotEstablishedError();
12529
12799
  }
12530
- nativeInteractionClient = new NativeInteractionClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, this.apiId, this.performanceClient, this.nativeMessageHandler, serverParams.accountId, this.correlationId);
12800
+ nativeInteractionClient = new NativeInteractionClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, this.apiId, this.performanceClient, this.nativeMessageHandler, serverParams.accountId, this.browserStorage, this.correlationId);
12531
12801
  userRequestState = ProtocolUtils.parseRequestState(this.browserCrypto, state).userRequestState;
12532
12802
  return [2 /*return*/, nativeInteractionClient.acquireToken(__assign$1(__assign$1({}, silentRequest), { state: userRequestState, prompt: PromptValue.NONE })).finally(function () {
12533
12803
  _this.browserStorage.cleanRequestByState(state);
@@ -12542,99 +12812,6 @@ var SilentIframeClient = /** @class */ (function (_super) {
12542
12812
  return SilentIframeClient;
12543
12813
  }(StandardInteractionClient));
12544
12814
 
12545
- /*
12546
- * Copyright (c) Microsoft Corporation. All rights reserved.
12547
- * Licensed under the MIT License.
12548
- */
12549
- var SilentCacheClient = /** @class */ (function (_super) {
12550
- __extends$1(SilentCacheClient, _super);
12551
- function SilentCacheClient() {
12552
- return _super !== null && _super.apply(this, arguments) || this;
12553
- }
12554
- /**
12555
- * Returns unexpired tokens from the cache, if available
12556
- * @param silentRequest
12557
- */
12558
- SilentCacheClient.prototype.acquireToken = function (silentRequest) {
12559
- return __awaiter$1(this, void 0, void 0, function () {
12560
- var acquireTokenMeasurement, serverTelemetryManager, silentAuthClient, cachedToken, error_1;
12561
- return __generator$1(this, function (_a) {
12562
- switch (_a.label) {
12563
- case 0:
12564
- acquireTokenMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.SilentCacheClientAcquireToken, silentRequest.correlationId);
12565
- serverTelemetryManager = this.initializeServerTelemetryManager(exports.ApiId.acquireTokenSilent_silentFlow);
12566
- return [4 /*yield*/, this.createSilentFlowClient(serverTelemetryManager, silentRequest.authority, silentRequest.azureCloudOptions)];
12567
- case 1:
12568
- silentAuthClient = _a.sent();
12569
- this.logger.verbose("Silent auth client created");
12570
- _a.label = 2;
12571
- case 2:
12572
- _a.trys.push([2, 4, , 5]);
12573
- return [4 /*yield*/, silentAuthClient.acquireCachedToken(silentRequest)];
12574
- case 3:
12575
- cachedToken = _a.sent();
12576
- acquireTokenMeasurement.endMeasurement({
12577
- success: true,
12578
- fromCache: true
12579
- });
12580
- return [2 /*return*/, cachedToken];
12581
- case 4:
12582
- error_1 = _a.sent();
12583
- if (error_1 instanceof BrowserAuthError && error_1.errorCode === BrowserAuthErrorMessage.signingKeyNotFoundInStorage.code) {
12584
- this.logger.verbose("Signing keypair for bound access token not found. Refreshing bound access token and generating a new crypto keypair.");
12585
- }
12586
- acquireTokenMeasurement.endMeasurement({
12587
- errorCode: error_1 instanceof AuthError && error_1.errorCode || undefined,
12588
- subErrorCode: error_1 instanceof AuthError && error_1.subError || undefined,
12589
- success: false
12590
- });
12591
- throw error_1;
12592
- case 5: return [2 /*return*/];
12593
- }
12594
- });
12595
- });
12596
- };
12597
- /**
12598
- * Currently Unsupported
12599
- */
12600
- SilentCacheClient.prototype.logout = function () {
12601
- // Synchronous so we must reject
12602
- return Promise.reject(BrowserAuthError.createSilentLogoutUnsupportedError());
12603
- };
12604
- /**
12605
- * Creates an Silent Flow Client with the given authority, or the default authority.
12606
- * @param serverTelemetryManager
12607
- * @param authorityUrl
12608
- */
12609
- SilentCacheClient.prototype.createSilentFlowClient = function (serverTelemetryManager, authorityUrl, azureCloudOptions) {
12610
- return __awaiter$1(this, void 0, void 0, function () {
12611
- var clientConfig;
12612
- return __generator$1(this, function (_a) {
12613
- switch (_a.label) {
12614
- case 0: return [4 /*yield*/, this.getClientConfiguration(serverTelemetryManager, authorityUrl, azureCloudOptions)];
12615
- case 1:
12616
- clientConfig = _a.sent();
12617
- return [2 /*return*/, new SilentFlowClient(clientConfig)];
12618
- }
12619
- });
12620
- });
12621
- };
12622
- SilentCacheClient.prototype.initializeSilentRequest = function (request, account) {
12623
- return __awaiter$1(this, void 0, void 0, function () {
12624
- var _a;
12625
- return __generator$1(this, function (_b) {
12626
- switch (_b.label) {
12627
- case 0:
12628
- _a = [__assign$1({}, request)];
12629
- return [4 /*yield*/, this.initializeBaseRequest(request)];
12630
- case 1: return [2 /*return*/, __assign$1.apply(void 0, [__assign$1.apply(void 0, _a.concat([_b.sent()])), { account: account, forceRefresh: request.forceRefresh || false }])];
12631
- }
12632
- });
12633
- });
12634
- };
12635
- return SilentCacheClient;
12636
- }(StandardInteractionClient));
12637
-
12638
12815
  /*
12639
12816
  * Copyright (c) Microsoft Corporation. All rights reserved.
12640
12817
  * Licensed under the MIT License.
@@ -14652,6 +14829,13 @@ var ClientApplication = /** @class */ (function () {
14652
14829
  this.browserStorage = this.isBrowserEnvironment ?
14653
14830
  new BrowserCacheManager(this.config.auth.clientId, this.config.cache, this.browserCrypto, this.logger) :
14654
14831
  DEFAULT_BROWSER_CACHE_MANAGER(this.config.auth.clientId, this.logger);
14832
+ // initialize in memory storage for native flows
14833
+ var nativeCacheOptions = {
14834
+ cacheLocation: exports.BrowserCacheLocation.MemoryStorage,
14835
+ storeAuthStateInCookie: false,
14836
+ secureCookies: false
14837
+ };
14838
+ this.nativeInternalStorage = new BrowserCacheManager(this.config.auth.clientId, nativeCacheOptions, this.browserCrypto, this.logger);
14655
14839
  // Initialize the token cache
14656
14840
  this.tokenCache = new TokenCache(this.config, this.browserStorage, this.logger, this.browserCrypto);
14657
14841
  }
@@ -14718,7 +14902,7 @@ var ClientApplication = /** @class */ (function () {
14718
14902
  redirectResponse = void 0;
14719
14903
  if (request && NativeMessageHandler.isNativeAvailable(this.config, this.logger, this.nativeExtensionProvider) && this.nativeExtensionProvider && !hash) {
14720
14904
  this.logger.trace("handleRedirectPromise - acquiring token from native platform");
14721
- nativeClient = new NativeInteractionClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, exports.ApiId.handleRedirectPromise, this.performanceClient, this.nativeExtensionProvider, request.accountId, request.correlationId);
14905
+ nativeClient = new NativeInteractionClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, exports.ApiId.handleRedirectPromise, this.performanceClient, this.nativeExtensionProvider, request.accountId, this.nativeInternalStorage, request.correlationId);
14722
14906
  redirectResponse = nativeClient.handleRedirectPromise();
14723
14907
  }
14724
14908
  else {
@@ -14790,7 +14974,7 @@ var ClientApplication = /** @class */ (function () {
14790
14974
  this.eventHandler.emitEvent(exports.EventType.LOGIN_START, exports.InteractionType.Redirect, request);
14791
14975
  }
14792
14976
  if (this.nativeExtensionProvider && this.canUseNative(request)) {
14793
- nativeClient = new NativeInteractionClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, exports.ApiId.acquireTokenRedirect, this.performanceClient, this.nativeExtensionProvider, this.getNativeAccountId(request), request.correlationId);
14977
+ nativeClient = new NativeInteractionClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, exports.ApiId.acquireTokenRedirect, this.performanceClient, this.nativeExtensionProvider, this.getNativeAccountId(request), this.nativeInternalStorage, request.correlationId);
14794
14978
  result = nativeClient.acquireTokenRedirect(request).catch(function (e) {
14795
14979
  if (e instanceof NativeAuthError && e.isFatal()) {
14796
14980
  _this.nativeExtensionProvider = undefined; // If extension gets uninstalled during session prevent future requests from continuing to attempt
@@ -14858,7 +15042,9 @@ var ClientApplication = /** @class */ (function () {
14858
15042
  _this.browserStorage.setInteractionInProgress(false);
14859
15043
  atPopupMeasurement.endMeasurement({
14860
15044
  success: true,
14861
- isNativeBroker: true
15045
+ isNativeBroker: true,
15046
+ accessTokenSize: response.accessToken.length,
15047
+ idTokenSize: response.idToken.length,
14862
15048
  });
14863
15049
  atPopupMeasurement.flushMeasurement();
14864
15050
  return response;
@@ -14882,7 +15068,9 @@ var ClientApplication = /** @class */ (function () {
14882
15068
  result = popupClient.acquireToken(request);
14883
15069
  }
14884
15070
  return result.then(function (result) {
14885
- // If logged in, emit acquire token events
15071
+ /*
15072
+ * If logged in, emit acquire token events
15073
+ */
14886
15074
  var isLoggingIn = loggedInAccounts.length < _this.getAllAccounts().length;
14887
15075
  if (isLoggingIn) {
14888
15076
  _this.eventHandler.emitEvent(exports.EventType.LOGIN_SUCCESS, exports.InteractionType.Popup, result);
@@ -14891,7 +15079,9 @@ var ClientApplication = /** @class */ (function () {
14891
15079
  _this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_SUCCESS, exports.InteractionType.Popup, result);
14892
15080
  }
14893
15081
  atPopupMeasurement.endMeasurement({
14894
- success: true
15082
+ success: true,
15083
+ accessTokenSize: result.accessToken.length,
15084
+ idTokenSize: result.idToken.length,
14895
15085
  });
14896
15086
  atPopupMeasurement.flushMeasurement();
14897
15087
  return result;
@@ -14959,7 +15149,9 @@ var ClientApplication = /** @class */ (function () {
14959
15149
  _this.eventHandler.emitEvent(exports.EventType.SSO_SILENT_SUCCESS, exports.InteractionType.Silent, response);
14960
15150
  ssoSilentMeasurement.endMeasurement({
14961
15151
  success: true,
14962
- isNativeBroker: response.fromNativeBroker
15152
+ isNativeBroker: response.fromNativeBroker,
15153
+ accessTokenSize: response.accessToken.length,
15154
+ idTokenSize: response.idToken.length
14963
15155
  });
14964
15156
  ssoSilentMeasurement.flushMeasurement();
14965
15157
  return response;
@@ -15008,6 +15200,8 @@ var ClientApplication = /** @class */ (function () {
15008
15200
  _this.hybridAuthCodeResponses.delete(hybridAuthCode_1);
15009
15201
  atbcMeasurement.endMeasurement({
15010
15202
  success: true,
15203
+ accessTokenSize: result.accessToken.length,
15204
+ idTokenSize: result.idToken.length,
15011
15205
  isNativeBroker: result.fromNativeBroker
15012
15206
  });
15013
15207
  atbcMeasurement.flushMeasurement();
@@ -15112,7 +15306,9 @@ var ClientApplication = /** @class */ (function () {
15112
15306
  .then(function (result) {
15113
15307
  atbrtMeasurement.endMeasurement({
15114
15308
  success: true,
15115
- fromCache: result.fromCache
15309
+ fromCache: result.fromCache,
15310
+ accessTokenSize: result.accessToken.length,
15311
+ idTokenSize: result.idToken.length,
15116
15312
  });
15117
15313
  return result;
15118
15314
  })
@@ -15127,7 +15323,9 @@ var ClientApplication = /** @class */ (function () {
15127
15323
  .then(function (result) {
15128
15324
  atbrtMeasurement.endMeasurement({
15129
15325
  success: true,
15130
- fromCache: result.fromCache
15326
+ fromCache: result.fromCache,
15327
+ accessTokenSize: result.accessToken.length,
15328
+ idTokenSize: result.idToken.length,
15131
15329
  });
15132
15330
  return result;
15133
15331
  })
@@ -15339,7 +15537,7 @@ var ClientApplication = /** @class */ (function () {
15339
15537
  if (!this.nativeExtensionProvider) {
15340
15538
  throw BrowserAuthError.createNativeConnectionNotEstablishedError();
15341
15539
  }
15342
- nativeClient = new NativeInteractionClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, apiId, this.performanceClient, this.nativeExtensionProvider, accountId || this.getNativeAccountId(request), request.correlationId);
15540
+ nativeClient = new NativeInteractionClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, apiId, this.performanceClient, this.nativeExtensionProvider, accountId || this.getNativeAccountId(request), this.nativeInternalStorage, request.correlationId);
15343
15541
  return [2 /*return*/, nativeClient.acquireToken(request)];
15344
15542
  });
15345
15543
  });
@@ -15386,21 +15584,21 @@ var ClientApplication = /** @class */ (function () {
15386
15584
  * @param correlationId
15387
15585
  */
15388
15586
  ClientApplication.prototype.createPopupClient = function (correlationId) {
15389
- return new PopupClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, this.performanceClient, this.nativeExtensionProvider, correlationId);
15587
+ return new PopupClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, this.performanceClient, this.nativeInternalStorage, this.nativeExtensionProvider, correlationId);
15390
15588
  };
15391
15589
  /**
15392
15590
  * Returns new instance of the Redirect Interaction Client
15393
15591
  * @param correlationId
15394
15592
  */
15395
15593
  ClientApplication.prototype.createRedirectClient = function (correlationId) {
15396
- return new RedirectClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, this.performanceClient, this.nativeExtensionProvider, correlationId);
15594
+ return new RedirectClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, this.performanceClient, this.nativeInternalStorage, this.nativeExtensionProvider, correlationId);
15397
15595
  };
15398
15596
  /**
15399
15597
  * Returns new instance of the Silent Iframe Interaction Client
15400
15598
  * @param correlationId
15401
15599
  */
15402
15600
  ClientApplication.prototype.createSilentIframeClient = function (correlationId) {
15403
- return new SilentIframeClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, exports.ApiId.ssoSilent, this.performanceClient, this.nativeExtensionProvider, correlationId);
15601
+ return new SilentIframeClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, exports.ApiId.ssoSilent, this.performanceClient, this.nativeInternalStorage, this.nativeExtensionProvider, correlationId);
15404
15602
  };
15405
15603
  /**
15406
15604
  * Returns new instance of the Silent Cache Interaction Client
@@ -15636,6 +15834,8 @@ var PublicClientApplication = /** @class */ (function (_super) {
15636
15834
  atsMeasurement.endMeasurement({
15637
15835
  success: true,
15638
15836
  fromCache: result.fromCache,
15837
+ accessTokenSize: result.accessToken.length,
15838
+ idTokenSize: result.idToken.length,
15639
15839
  isNativeBroker: result.fromNativeBroker
15640
15840
  });
15641
15841
  atsMeasurement.flushMeasurement();
@@ -15644,8 +15844,6 @@ var PublicClientApplication = /** @class */ (function (_super) {
15644
15844
  .catch(function (error) {
15645
15845
  _this.activeSilentTokenRequests.delete(silentRequestKey);
15646
15846
  atsMeasurement.endMeasurement({
15647
- errorCode: error.errorCode,
15648
- subErrorCode: error.subError,
15649
15847
  success: false
15650
15848
  });
15651
15849
  atsMeasurement.flushMeasurement();
@@ -15715,6 +15913,8 @@ var PublicClientApplication = /** @class */ (function (_super) {
15715
15913
  astsAsyncMeasurement.endMeasurement({
15716
15914
  success: true,
15717
15915
  fromCache: response.fromCache,
15916
+ accessTokenSize: response.accessToken.length,
15917
+ idTokenSize: response.idToken.length,
15718
15918
  isNativeBroker: response.fromNativeBroker
15719
15919
  });
15720
15920
  return response;