@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
@@ -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
  (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 v7.1.0 2022-07-05 */
110
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
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 v7.1.0 2022-07-05 */
197
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
198
198
 
199
199
  /*
200
200
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -244,7 +244,8 @@
244
244
  REGIONAL_AUTH_PUBLIC_CLOUD_SUFFIX: "login.microsoft.com",
245
245
  KNOWN_PUBLIC_CLOUDS: ["login.microsoftonline.com", "login.windows.net", "login.microsoft.com", "sts.windows.net"],
246
246
  TOKEN_RESPONSE_TYPE: "token",
247
- ID_TOKEN_RESPONSE_TYPE: "id_token"
247
+ ID_TOKEN_RESPONSE_TYPE: "id_token",
248
+ SHR_NONCE_VALIDITY: 240,
248
249
  };
249
250
  var OIDC_DEFAULT_SCOPES = [
250
251
  Constants.OPENID_SCOPE,
@@ -276,6 +277,7 @@
276
277
  PersistentCacheKeys["ERROR"] = "error";
277
278
  PersistentCacheKeys["ERROR_DESC"] = "error.description";
278
279
  PersistentCacheKeys["ACTIVE_ACCOUNT"] = "active-account";
280
+ PersistentCacheKeys["ACTIVE_ACCOUNT_FILTERS"] = "active-account-filters"; // new cache entry for active_account for a more robust version for browser
279
281
  })(PersistentCacheKeys || (PersistentCacheKeys = {}));
280
282
  /**
281
283
  * String constants related to AAD Authority
@@ -569,7 +571,7 @@
569
571
  JsonTypes["Jwk"] = "JWK";
570
572
  })(JsonTypes || (JsonTypes = {}));
571
573
 
572
- /*! @azure/msal-common v7.1.0 2022-07-05 */
574
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
573
575
 
574
576
  /*
575
577
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -613,7 +615,7 @@
613
615
  return AuthError;
614
616
  }(Error));
615
617
 
616
- /*! @azure/msal-common v7.1.0 2022-07-05 */
618
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
617
619
 
618
620
  /*
619
621
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -688,7 +690,7 @@
688
690
  }
689
691
  };
690
692
 
691
- /*! @azure/msal-common v7.1.0 2022-07-05 */
693
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
692
694
 
693
695
  /*
694
696
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1160,7 +1162,7 @@
1160
1162
  return ClientAuthError;
1161
1163
  }(AuthError));
1162
1164
 
1163
- /*! @azure/msal-common v7.1.0 2022-07-05 */
1165
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
1164
1166
 
1165
1167
  /*
1166
1168
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1285,7 +1287,7 @@
1285
1287
  return StringUtils;
1286
1288
  }());
1287
1289
 
1288
- /*! @azure/msal-common v7.1.0 2022-07-05 */
1290
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
1289
1291
 
1290
1292
  /*
1291
1293
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1465,12 +1467,12 @@
1465
1467
  return Logger;
1466
1468
  }());
1467
1469
 
1468
- /*! @azure/msal-common v7.1.0 2022-07-05 */
1470
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
1469
1471
  /* eslint-disable header/header */
1470
1472
  var name$1 = "@azure/msal-common";
1471
- var version$1 = "7.1.0";
1473
+ var version$1 = "7.2.0";
1472
1474
 
1473
- /*! @azure/msal-common v7.1.0 2022-07-05 */
1475
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
1474
1476
  /*
1475
1477
  * Copyright (c) Microsoft Corporation. All rights reserved.
1476
1478
  * Licensed under the MIT License.
@@ -1491,7 +1493,7 @@
1491
1493
  AzureCloudInstance["AzureUsGovernment"] = "https://login.microsoftonline.us";
1492
1494
  })(exports.AzureCloudInstance || (exports.AzureCloudInstance = {}));
1493
1495
 
1494
- /*! @azure/msal-common v7.1.0 2022-07-05 */
1496
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
1495
1497
 
1496
1498
  /*
1497
1499
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1650,7 +1652,7 @@
1650
1652
  return CredentialEntity;
1651
1653
  }());
1652
1654
 
1653
- /*! @azure/msal-common v7.1.0 2022-07-05 */
1655
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
1654
1656
 
1655
1657
  /*
1656
1658
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1905,7 +1907,7 @@
1905
1907
  return ClientConfigurationError;
1906
1908
  }(ClientAuthError));
1907
1909
 
1908
- /*! @azure/msal-common v7.1.0 2022-07-05 */
1910
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
1909
1911
 
1910
1912
  /*
1911
1913
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2089,7 +2091,7 @@
2089
2091
  return ScopeSet;
2090
2092
  }());
2091
2093
 
2092
- /*! @azure/msal-common v7.1.0 2022-07-05 */
2094
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
2093
2095
 
2094
2096
  /*
2095
2097
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2127,7 +2129,7 @@
2127
2129
  };
2128
2130
  }
2129
2131
 
2130
- /*! @azure/msal-common v7.1.0 2022-07-05 */
2132
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
2131
2133
  /*
2132
2134
  * Copyright (c) Microsoft Corporation. All rights reserved.
2133
2135
  * Licensed under the MIT License.
@@ -2141,7 +2143,7 @@
2141
2143
  AuthorityType[AuthorityType["Adfs"] = 1] = "Adfs";
2142
2144
  })(AuthorityType || (AuthorityType = {}));
2143
2145
 
2144
- /*! @azure/msal-common v7.1.0 2022-07-05 */
2146
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
2145
2147
 
2146
2148
  /*
2147
2149
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2376,7 +2378,7 @@
2376
2378
  return AccountEntity;
2377
2379
  }());
2378
2380
 
2379
- /*! @azure/msal-common v7.1.0 2022-07-05 */
2381
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
2380
2382
 
2381
2383
  /*
2382
2384
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2414,7 +2416,7 @@
2414
2416
  return AuthToken;
2415
2417
  }());
2416
2418
 
2417
- /*! @azure/msal-common v7.1.0 2022-07-05 */
2419
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
2418
2420
 
2419
2421
  /*
2420
2422
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2536,7 +2538,7 @@
2536
2538
  * @param realm
2537
2539
  */
2538
2540
  CacheManager.prototype.getAccountsFilteredBy = function (accountFilter) {
2539
- return this.getAccountsFilteredByInternal(accountFilter ? accountFilter.homeAccountId : Constants.EMPTY_STRING, accountFilter ? accountFilter.environment : Constants.EMPTY_STRING, accountFilter ? accountFilter.realm : Constants.EMPTY_STRING);
2541
+ 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);
2540
2542
  };
2541
2543
  /**
2542
2544
  * retrieve accounts matching all provided filters; if no filter is set, get all accounts
@@ -2545,7 +2547,7 @@
2545
2547
  * @param environment
2546
2548
  * @param realm
2547
2549
  */
2548
- CacheManager.prototype.getAccountsFilteredByInternal = function (homeAccountId, environment, realm) {
2550
+ CacheManager.prototype.getAccountsFilteredByInternal = function (homeAccountId, environment, realm, nativeAccountId) {
2549
2551
  var _this = this;
2550
2552
  var allCacheKeys = this.getKeys();
2551
2553
  var matchingAccounts = {};
@@ -2563,6 +2565,9 @@
2563
2565
  if (!!realm && !_this.matchRealm(entity, realm)) {
2564
2566
  return;
2565
2567
  }
2568
+ if (!!nativeAccountId && !_this.matchNativeAccountId(entity, nativeAccountId)) {
2569
+ return;
2570
+ }
2566
2571
  matchingAccounts[cacheKey] = entity;
2567
2572
  });
2568
2573
  return matchingAccounts;
@@ -2891,6 +2896,26 @@
2891
2896
  var accountKey = AccountEntity.generateAccountCacheKey(account);
2892
2897
  return this.getAccount(accountKey);
2893
2898
  };
2899
+ /**
2900
+ * Retrieve AccountEntity from cache
2901
+ * @param nativeAccountId
2902
+ * @returns AccountEntity or Null
2903
+ */
2904
+ CacheManager.prototype.readAccountFromCacheWithNativeAccountId = function (nativeAccountId) {
2905
+ // fetch account from memory
2906
+ var accountFilter = {
2907
+ nativeAccountId: nativeAccountId
2908
+ };
2909
+ var accountCache = this.getAccountsFilteredBy(accountFilter);
2910
+ var accounts = Object.keys(accountCache).map(function (key) { return accountCache[key]; });
2911
+ if (accounts.length < 1) {
2912
+ return null;
2913
+ }
2914
+ else if (accounts.length > 1) {
2915
+ throw ClientAuthError.createMultipleMatchingAccountsInCacheError();
2916
+ }
2917
+ return accountCache[0];
2918
+ };
2894
2919
  /**
2895
2920
  * Retrieve IdTokenEntity from cache
2896
2921
  * @param clientId
@@ -3065,6 +3090,15 @@
3065
3090
  CacheManager.prototype.matchRealm = function (entity, realm) {
3066
3091
  return !!(entity.realm && realm === entity.realm);
3067
3092
  };
3093
+ /**
3094
+ * helper to match nativeAccountId
3095
+ * @param entity
3096
+ * @param nativeAccountId
3097
+ * @returns boolean indicating the match result
3098
+ */
3099
+ CacheManager.prototype.matchNativeAccountId = function (entity, nativeAccountId) {
3100
+ return !!(entity.nativeAccountId && nativeAccountId === entity.nativeAccountId);
3101
+ };
3068
3102
  /**
3069
3103
  * Returns true if the target scopes are a subset of the current entity's scopes, false otherwise.
3070
3104
  * @param entity
@@ -3256,7 +3290,7 @@
3256
3290
  return DefaultStorageClass;
3257
3291
  }(CacheManager));
3258
3292
 
3259
- /*! @azure/msal-common v7.1.0 2022-07-05 */
3293
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
3260
3294
 
3261
3295
  /*
3262
3296
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3339,7 +3373,7 @@
3339
3373
  telemetry: __assign(__assign({}, DEFAULT_TELEMETRY_OPTIONS), telemetry),
3340
3374
  serverTelemetryManager: serverTelemetryManager || null,
3341
3375
  persistencePlugin: persistencePlugin || null,
3342
- serializableCache: serializableCache || null
3376
+ serializableCache: serializableCache || null,
3343
3377
  };
3344
3378
  }
3345
3379
  /**
@@ -3350,7 +3384,7 @@
3350
3384
  return __assign({ clientCapabilities: [], azureCloudOptions: DEFAULT_AZURE_CLOUD_OPTIONS, skipAuthorityMetadataCache: false }, authOptions);
3351
3385
  }
3352
3386
 
3353
- /*! @azure/msal-common v7.1.0 2022-07-05 */
3387
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
3354
3388
 
3355
3389
  /*
3356
3390
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3370,7 +3404,7 @@
3370
3404
  return ServerError;
3371
3405
  }(AuthError));
3372
3406
 
3373
- /*! @azure/msal-common v7.1.0 2022-07-05 */
3407
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
3374
3408
 
3375
3409
  /*
3376
3410
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3466,7 +3500,7 @@
3466
3500
  return ThrottlingUtils;
3467
3501
  }());
3468
3502
 
3469
- /*! @azure/msal-common v7.1.0 2022-07-05 */
3503
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
3470
3504
 
3471
3505
  /*
3472
3506
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3515,7 +3549,7 @@
3515
3549
  return NetworkManager;
3516
3550
  }());
3517
3551
 
3518
- /*! @azure/msal-common v7.1.0 2022-07-05 */
3552
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
3519
3553
  /*
3520
3554
  * Copyright (c) Microsoft Corporation. All rights reserved.
3521
3555
  * Licensed under the MIT License.
@@ -3526,7 +3560,7 @@
3526
3560
  CcsCredentialType["UPN"] = "UPN";
3527
3561
  })(CcsCredentialType || (CcsCredentialType = {}));
3528
3562
 
3529
- /*! @azure/msal-common v7.1.0 2022-07-05 */
3563
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
3530
3564
 
3531
3565
  /*
3532
3566
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3615,7 +3649,7 @@
3615
3649
  return BaseClient;
3616
3650
  }());
3617
3651
 
3618
- /*! @azure/msal-common v7.1.0 2022-07-05 */
3652
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
3619
3653
 
3620
3654
  /*
3621
3655
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3701,7 +3735,7 @@
3701
3735
  return RequestValidator;
3702
3736
  }());
3703
3737
 
3704
- /*! @azure/msal-common v7.1.0 2022-07-05 */
3738
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
3705
3739
 
3706
3740
  /*
3707
3741
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4079,7 +4113,7 @@
4079
4113
  return RequestParameterBuilder;
4080
4114
  }());
4081
4115
 
4082
- /*! @azure/msal-common v7.1.0 2022-07-05 */
4116
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
4083
4117
 
4084
4118
  /*
4085
4119
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4143,7 +4177,7 @@
4143
4177
  return IdTokenEntity;
4144
4178
  }(CredentialEntity));
4145
4179
 
4146
- /*! @azure/msal-common v7.1.0 2022-07-05 */
4180
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
4147
4181
  /*
4148
4182
  * Copyright (c) Microsoft Corporation. All rights reserved.
4149
4183
  * Licensed under the MIT License.
@@ -4193,7 +4227,7 @@
4193
4227
  return TimeUtils;
4194
4228
  }());
4195
4229
 
4196
- /*! @azure/msal-common v7.1.0 2022-07-05 */
4230
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
4197
4231
 
4198
4232
  /*
4199
4233
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4307,7 +4341,7 @@
4307
4341
  return AccessTokenEntity;
4308
4342
  }(CredentialEntity));
4309
4343
 
4310
- /*! @azure/msal-common v7.1.0 2022-07-05 */
4344
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
4311
4345
 
4312
4346
  /*
4313
4347
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4374,7 +4408,7 @@
4374
4408
  return RefreshTokenEntity;
4375
4409
  }(CredentialEntity));
4376
4410
 
4377
- /*! @azure/msal-common v7.1.0 2022-07-05 */
4411
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
4378
4412
 
4379
4413
  /*
4380
4414
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4449,7 +4483,7 @@
4449
4483
  return InteractionRequiredAuthError;
4450
4484
  }(AuthError));
4451
4485
 
4452
- /*! @azure/msal-common v7.1.0 2022-07-05 */
4486
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
4453
4487
  /*
4454
4488
  * Copyright (c) Microsoft Corporation. All rights reserved.
4455
4489
  * Licensed under the MIT License.
@@ -4465,7 +4499,7 @@
4465
4499
  return CacheRecord;
4466
4500
  }());
4467
4501
 
4468
- /*! @azure/msal-common v7.1.0 2022-07-05 */
4502
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
4469
4503
 
4470
4504
  /*
4471
4505
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4536,7 +4570,7 @@
4536
4570
  return ProtocolUtils;
4537
4571
  }());
4538
4572
 
4539
- /*! @azure/msal-common v7.1.0 2022-07-05 */
4573
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
4540
4574
 
4541
4575
  /*
4542
4576
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4737,7 +4771,7 @@
4737
4771
  return UrlString;
4738
4772
  }());
4739
4773
 
4740
- /*! @azure/msal-common v7.1.0 2022-07-05 */
4774
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
4741
4775
 
4742
4776
  /*
4743
4777
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4838,7 +4872,7 @@
4838
4872
  return PopTokenGenerator;
4839
4873
  }());
4840
4874
 
4841
- /*! @azure/msal-common v7.1.0 2022-07-05 */
4875
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
4842
4876
 
4843
4877
  /*
4844
4878
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4908,7 +4942,7 @@
4908
4942
  return AppMetadataEntity;
4909
4943
  }());
4910
4944
 
4911
- /*! @azure/msal-common v7.1.0 2022-07-05 */
4945
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
4912
4946
  /*
4913
4947
  * Copyright (c) Microsoft Corporation. All rights reserved.
4914
4948
  * Licensed under the MIT License.
@@ -4944,7 +4978,7 @@
4944
4978
  return TokenCacheContext;
4945
4979
  }());
4946
4980
 
4947
- /*! @azure/msal-common v7.1.0 2022-07-05 */
4981
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
4948
4982
 
4949
4983
  /*
4950
4984
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5005,7 +5039,7 @@
5005
5039
  * @param serverTokenResponse
5006
5040
  * @param authority
5007
5041
  */
5008
- ResponseHandler.prototype.handleServerTokenResponse = function (serverTokenResponse, authority, reqTimestamp, request, authCodePayload, userAssertionHash, handlingRefreshTokenResponse) {
5042
+ ResponseHandler.prototype.handleServerTokenResponse = function (serverTokenResponse, authority, reqTimestamp, request, authCodePayload, userAssertionHash, handlingRefreshTokenResponse, forceCacheRefreshTokenResponse) {
5009
5043
  return __awaiter(this, void 0, void 0, function () {
5010
5044
  var idTokenObj, requestStateObj, cacheRecord, cacheContext, key, account;
5011
5045
  return __generator(this, function (_a) {
@@ -5042,14 +5076,15 @@
5042
5076
  /*
5043
5077
  * When saving a refreshed tokens to the cache, it is expected that the account that was used is present in the cache.
5044
5078
  * If not present, we should return null, as it's the case that another application called removeAccount in between
5045
- * the calls to getAllAccounts and acquireTokenSilent. We should not overwrite that removal.
5079
+ * the calls to getAllAccounts and acquireTokenSilent. We should not overwrite that removal, unless explicitly flagged by
5080
+ * the developer, as in the case of refresh token flow used in ADAL Node to MSAL Node migration.
5046
5081
  */
5047
- if (handlingRefreshTokenResponse && cacheRecord.account) {
5082
+ if (handlingRefreshTokenResponse && !forceCacheRefreshTokenResponse && cacheRecord.account) {
5048
5083
  key = cacheRecord.account.generateAccountKey();
5049
5084
  account = this.cacheStorage.getAccount(key);
5050
5085
  if (!account) {
5051
5086
  this.logger.warning("Account used to refresh tokens not in persistence, refreshed tokens will not be stored in the cache");
5052
- return [2 /*return*/, ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenObj, requestStateObj)];
5087
+ return [2 /*return*/, ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenObj, requestStateObj, undefined)];
5053
5088
  }
5054
5089
  }
5055
5090
  return [4 /*yield*/, this.cacheStorage.saveCacheRecord(cacheRecord)];
@@ -5214,7 +5249,7 @@
5214
5249
  return ResponseHandler;
5215
5250
  }());
5216
5251
 
5217
- /*! @azure/msal-common v7.1.0 2022-07-05 */
5252
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
5218
5253
 
5219
5254
  /*
5220
5255
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5315,7 +5350,7 @@
5315
5350
  throw ClientConfigurationError.createEmptyLogoutRequestError();
5316
5351
  }
5317
5352
  var queryString = this.createLogoutUrlQueryString(logoutRequest);
5318
- // Construct logout URI.
5353
+ // Construct logout URI
5319
5354
  return UrlString.appendQueryString(this.authority.endSessionEndpoint, queryString);
5320
5355
  };
5321
5356
  /**
@@ -5649,7 +5684,7 @@
5649
5684
  return AuthorizationCodeClient;
5650
5685
  }(BaseClient));
5651
5686
 
5652
- /*! @azure/msal-common v7.1.0 2022-07-05 */
5687
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
5653
5688
 
5654
5689
  /*
5655
5690
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5675,7 +5710,7 @@
5675
5710
  response = _a.sent();
5676
5711
  responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, this.config.serializableCache, this.config.persistencePlugin);
5677
5712
  responseHandler.validateTokenResponse(response.body);
5678
- return [2 /*return*/, responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request, undefined, undefined, true)];
5713
+ return [2 /*return*/, responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request, undefined, undefined, true, request.forceCache)];
5679
5714
  }
5680
5715
  });
5681
5716
  });
@@ -5862,7 +5897,7 @@
5862
5897
  return RefreshTokenClient;
5863
5898
  }(BaseClient));
5864
5899
 
5865
- /*! @azure/msal-common v7.1.0 2022-07-05 */
5900
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
5866
5901
 
5867
5902
  /*
5868
5903
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5978,7 +6013,7 @@
5978
6013
  return SilentFlowClient;
5979
6014
  }(BaseClient));
5980
6015
 
5981
- /*! @azure/msal-common v7.1.0 2022-07-05 */
6016
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
5982
6017
  /*
5983
6018
  * Copyright (c) Microsoft Corporation. All rights reserved.
5984
6019
  * Licensed under the MIT License.
@@ -5990,7 +6025,7 @@
5990
6025
  response.hasOwnProperty("jwks_uri"));
5991
6026
  }
5992
6027
 
5993
- /*! @azure/msal-common v7.1.0 2022-07-05 */
6028
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
5994
6029
  /*
5995
6030
  * Copyright (c) Microsoft Corporation. All rights reserved.
5996
6031
  * Licensed under the MIT License.
@@ -5999,7 +6034,7 @@
5999
6034
  var EndpointMetadata = rawMetdataJSON.endpointMetadata;
6000
6035
  var InstanceDiscoveryMetadata = rawMetdataJSON.instanceDiscoveryMetadata;
6001
6036
 
6002
- /*! @azure/msal-common v7.1.0 2022-07-05 */
6037
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
6003
6038
  /*
6004
6039
  * Copyright (c) Microsoft Corporation. All rights reserved.
6005
6040
  * Licensed under the MIT License.
@@ -6013,7 +6048,7 @@
6013
6048
  ProtocolMode["OIDC"] = "OIDC";
6014
6049
  })(exports.ProtocolMode || (exports.ProtocolMode = {}));
6015
6050
 
6016
- /*! @azure/msal-common v7.1.0 2022-07-05 */
6051
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
6017
6052
 
6018
6053
  /*
6019
6054
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6090,7 +6125,7 @@
6090
6125
  return AuthorityMetadataEntity;
6091
6126
  }());
6092
6127
 
6093
- /*! @azure/msal-common v7.1.0 2022-07-05 */
6128
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
6094
6129
  /*
6095
6130
  * Copyright (c) Microsoft Corporation. All rights reserved.
6096
6131
  * Licensed under the MIT License.
@@ -6100,7 +6135,7 @@
6100
6135
  response.hasOwnProperty("metadata"));
6101
6136
  }
6102
6137
 
6103
- /*! @azure/msal-common v7.1.0 2022-07-05 */
6138
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
6104
6139
 
6105
6140
  /*
6106
6141
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6222,7 +6257,7 @@
6222
6257
  return RegionDiscovery;
6223
6258
  }());
6224
6259
 
6225
- /*! @azure/msal-common v7.1.0 2022-07-05 */
6260
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
6226
6261
 
6227
6262
  /*
6228
6263
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6884,7 +6919,7 @@
6884
6919
  return Authority;
6885
6920
  }());
6886
6921
 
6887
- /*! @azure/msal-common v7.1.0 2022-07-05 */
6922
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
6888
6923
 
6889
6924
  /*
6890
6925
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6945,7 +6980,7 @@
6945
6980
  return AuthorityFactory;
6946
6981
  }());
6947
6982
 
6948
- /*! @azure/msal-common v7.1.0 2022-07-05 */
6983
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
6949
6984
 
6950
6985
  /*
6951
6986
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6976,7 +7011,7 @@
6976
7011
  return ServerTelemetryEntity;
6977
7012
  }());
6978
7013
 
6979
- /*! @azure/msal-common v7.1.0 2022-07-05 */
7014
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
6980
7015
 
6981
7016
  /*
6982
7017
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7004,7 +7039,7 @@
7004
7039
  return ThrottlingEntity;
7005
7040
  }());
7006
7041
 
7007
- /*! @azure/msal-common v7.1.0 2022-07-05 */
7042
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
7008
7043
 
7009
7044
  /*
7010
7045
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7021,7 +7056,7 @@
7021
7056
  }
7022
7057
  };
7023
7058
 
7024
- /*! @azure/msal-common v7.1.0 2022-07-05 */
7059
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
7025
7060
 
7026
7061
  /*
7027
7062
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7066,7 +7101,7 @@
7066
7101
  return JoseHeaderError;
7067
7102
  }(AuthError));
7068
7103
 
7069
- /*! @azure/msal-common v7.1.0 2022-07-05 */
7104
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
7070
7105
 
7071
7106
  /*
7072
7107
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7106,7 +7141,7 @@
7106
7141
  return JoseHeader;
7107
7142
  }());
7108
7143
 
7109
- /*! @azure/msal-common v7.1.0 2022-07-05 */
7144
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
7110
7145
 
7111
7146
  /*
7112
7147
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7165,7 +7200,7 @@
7165
7200
  return AuthenticationHeaderParser;
7166
7201
  }());
7167
7202
 
7168
- /*! @azure/msal-common v7.1.0 2022-07-05 */
7203
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
7169
7204
 
7170
7205
  /*
7171
7206
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7327,7 +7362,7 @@
7327
7362
  return ServerTelemetryManager;
7328
7363
  }());
7329
7364
 
7330
- /*! @azure/msal-common v7.1.0 2022-07-05 */
7365
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
7331
7366
  /*
7332
7367
  * Copyright (c) Microsoft Corporation. All rights reserved.
7333
7368
  * Licensed under the MIT License.
@@ -7410,6 +7445,19 @@
7410
7445
  * Used to acquire a token from Native component when native brokering is enabled.
7411
7446
  */
7412
7447
  PerformanceEvents["NativeInteractionClientAcquireToken"] = "nativeInteractionClientAcquireToken";
7448
+ /**
7449
+ * Used to measure the time taken for completing embedded-broker handshake (PW-Broker).
7450
+ */
7451
+ PerformanceEvents["BrokerHandhshake"] = "brokerHandshake";
7452
+ /**
7453
+ * acquireTokenByRefreshToken API in BrokerClientApplication (PW-Broker) .
7454
+ */
7455
+ PerformanceEvents["AcquireTokenByRefreshTokenInBroker"] = "acquireTokenByRefreshTokenInBroker";
7456
+ /**
7457
+ * acquireToken API in BrokerClientApplication.
7458
+ * Used to acquire a token on behalf of the embedded application (PW-Broker).
7459
+ */
7460
+ PerformanceEvents["AcquireTokenByBroker"] = "acquireTokenByBroker";
7413
7461
  })(exports.PerformanceEvents || (exports.PerformanceEvents = {}));
7414
7462
  /**
7415
7463
  * State of the performance event.
@@ -7424,7 +7472,7 @@
7424
7472
  PerformanceEventStatus[PerformanceEventStatus["Completed"] = 2] = "Completed";
7425
7473
  })(PerformanceEventStatus || (PerformanceEventStatus = {}));
7426
7474
 
7427
- /*! @azure/msal-common v7.1.0 2022-07-05 */
7475
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
7428
7476
 
7429
7477
  /*
7430
7478
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7482,7 +7530,7 @@
7482
7530
  clientId: this.clientId,
7483
7531
  name: measureName,
7484
7532
  startTimeMs: Date.now(),
7485
- correlationId: eventCorrelationId
7533
+ correlationId: eventCorrelationId,
7486
7534
  };
7487
7535
  // Store in progress events so they can be discarded if not ended properly
7488
7536
  this.cacheEventByCorrelationId(inProgressEvent);
@@ -7627,6 +7675,12 @@
7627
7675
  else {
7628
7676
  _this.logger.verbose("PerformanceClient: Submeasurement for " + measureName + " already exists for " + current.name + ", ignoring", correlationId);
7629
7677
  }
7678
+ if (current.accessTokenSize) {
7679
+ previous.accessTokenSize = current.accessTokenSize;
7680
+ }
7681
+ if (current.idTokenSize) {
7682
+ previous.idTokenSize = current.idTokenSize;
7683
+ }
7630
7684
  }
7631
7685
  return previous;
7632
7686
  }, topLevelEvent);
@@ -7694,7 +7748,7 @@
7694
7748
  return PerformanceClient;
7695
7749
  }());
7696
7750
 
7697
- /*! @azure/msal-common v7.1.0 2022-07-05 */
7751
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
7698
7752
 
7699
7753
  /*
7700
7754
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8914,26 +8968,57 @@
8914
8968
  * Gets the active account
8915
8969
  */
8916
8970
  BrowserCacheManager.prototype.getActiveAccount = function () {
8917
- var activeAccountIdKey = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT);
8918
- var activeAccountId = this.browserStorage.getItem(activeAccountIdKey);
8919
- if (!activeAccountId) {
8971
+ var activeAccountKeyFilters = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT_FILTERS);
8972
+ var activeAccountValueFilters = this.getItem(activeAccountKeyFilters);
8973
+ if (!activeAccountValueFilters) {
8974
+ // if new active account cache type isn't found, it's an old version, so look for that instead
8975
+ this.logger.trace("No active account filters cache schema found, looking for legacy schema");
8976
+ var activeAccountKeyLocal = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT);
8977
+ var activeAccountValueLocal = this.getItem(activeAccountKeyLocal);
8978
+ if (!activeAccountValueLocal) {
8979
+ this.logger.trace("No active account found");
8980
+ return null;
8981
+ }
8982
+ var activeAccount = this.getAccountInfoByFilter({ localAccountId: activeAccountValueLocal })[0] || null;
8983
+ if (activeAccount) {
8984
+ this.logger.trace("Legacy active account cache schema found");
8985
+ this.logger.trace("Adding active account filters cache schema");
8986
+ this.setActiveAccount(activeAccount);
8987
+ return activeAccount;
8988
+ }
8920
8989
  return null;
8921
8990
  }
8922
- return this.getAccountInfoByFilter({ localAccountId: activeAccountId })[0] || null;
8991
+ var activeAccountValueObj = this.validateAndParseJson(activeAccountValueFilters);
8992
+ if (activeAccountValueObj) {
8993
+ this.logger.trace("Active account filters schema found");
8994
+ return this.getAccountInfoByFilter({
8995
+ homeAccountId: activeAccountValueObj.homeAccountId,
8996
+ localAccountId: activeAccountValueObj.localAccountId
8997
+ })[0] || null;
8998
+ }
8999
+ this.logger.trace("No active account found");
9000
+ return null;
8923
9001
  };
8924
9002
  /**
8925
9003
  * Sets the active account's localAccountId in cache
8926
9004
  * @param account
8927
9005
  */
8928
9006
  BrowserCacheManager.prototype.setActiveAccount = function (account) {
8929
- var activeAccountIdKey = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT);
9007
+ var activeAccountKey = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT_FILTERS);
9008
+ var activeAccountKeyLocal = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT);
8930
9009
  if (account) {
8931
9010
  this.logger.verbose("setActiveAccount: Active account set");
8932
- this.browserStorage.setItem(activeAccountIdKey, account.localAccountId);
9011
+ var activeAccountValue = {
9012
+ homeAccountId: account.homeAccountId,
9013
+ localAccountId: account.localAccountId
9014
+ };
9015
+ this.browserStorage.setItem(activeAccountKey, JSON.stringify(activeAccountValue));
9016
+ this.browserStorage.setItem(activeAccountKeyLocal, account.localAccountId);
8933
9017
  }
8934
9018
  else {
8935
9019
  this.logger.verbose("setActiveAccount: No account passed, active account not set");
8936
- this.browserStorage.removeItem(activeAccountIdKey);
9020
+ this.browserStorage.removeItem(activeAccountKey);
9021
+ this.browserStorage.removeItem(activeAccountKeyLocal);
8937
9022
  }
8938
9023
  };
8939
9024
  /**
@@ -9491,7 +9576,7 @@
9491
9576
 
9492
9577
  /* eslint-disable header/header */
9493
9578
  var name = "@azure/msal-browser";
9494
- var version = "2.27.0";
9579
+ var version = "2.28.0";
9495
9580
 
9496
9581
  /*
9497
9582
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -10040,8 +10125,7 @@
10040
10125
  protocolMode: this.config.auth.protocolMode,
10041
10126
  knownAuthorities: this.config.auth.knownAuthorities,
10042
10127
  cloudDiscoveryMetadata: this.config.auth.cloudDiscoveryMetadata,
10043
- authorityMetadata: this.config.auth.authorityMetadata,
10044
- skipAuthorityMetadataCache: this.config.auth.skipAuthorityMetadataCache,
10128
+ authorityMetadata: this.config.auth.authorityMetadata
10045
10129
  };
10046
10130
  if (!requestAuthority) return [3 /*break*/, 2];
10047
10131
  this.logger.verbose("Creating discovered authority with request authority");
@@ -10673,6 +10757,10 @@
10673
10757
  userSwitch: {
10674
10758
  code: "user_switch",
10675
10759
  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."
10760
+ },
10761
+ tokensNotFoundInCache: {
10762
+ code: "tokens_not_found_in_internal_memory_cache",
10763
+ desc: "Tokens not cached in MSAL JS internal memory, please make the WAM request"
10676
10764
  }
10677
10765
  };
10678
10766
  var NativeAuthError = /** @class */ (function (_super) {
@@ -10727,20 +10815,122 @@
10727
10815
  NativeAuthError.createUserSwitchError = function () {
10728
10816
  return new NativeAuthError(NativeAuthErrorMessage.userSwitch.code, NativeAuthErrorMessage.userSwitch.desc);
10729
10817
  };
10818
+ /**
10819
+ * Creates a tokens not found error when the internal cache look up fails
10820
+ * @returns NativeAuthError: tokensNotFoundInCache
10821
+ */
10822
+ NativeAuthError.createTokensNotFoundInCacheError = function () {
10823
+ return new NativeAuthError(NativeAuthErrorMessage.tokensNotFoundInCache.code, NativeAuthErrorMessage.tokensNotFoundInCache.desc);
10824
+ };
10730
10825
  return NativeAuthError;
10731
10826
  }(AuthError));
10732
10827
 
10828
+ /*
10829
+ * Copyright (c) Microsoft Corporation. All rights reserved.
10830
+ * Licensed under the MIT License.
10831
+ */
10832
+ var SilentCacheClient = /** @class */ (function (_super) {
10833
+ __extends$1(SilentCacheClient, _super);
10834
+ function SilentCacheClient() {
10835
+ return _super !== null && _super.apply(this, arguments) || this;
10836
+ }
10837
+ /**
10838
+ * Returns unexpired tokens from the cache, if available
10839
+ * @param silentRequest
10840
+ */
10841
+ SilentCacheClient.prototype.acquireToken = function (silentRequest) {
10842
+ return __awaiter$1(this, void 0, void 0, function () {
10843
+ var acquireTokenMeasurement, serverTelemetryManager, silentAuthClient, cachedToken, error_1;
10844
+ return __generator$1(this, function (_a) {
10845
+ switch (_a.label) {
10846
+ case 0:
10847
+ acquireTokenMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.SilentCacheClientAcquireToken, silentRequest.correlationId);
10848
+ serverTelemetryManager = this.initializeServerTelemetryManager(exports.ApiId.acquireTokenSilent_silentFlow);
10849
+ return [4 /*yield*/, this.createSilentFlowClient(serverTelemetryManager, silentRequest.authority, silentRequest.azureCloudOptions)];
10850
+ case 1:
10851
+ silentAuthClient = _a.sent();
10852
+ this.logger.verbose("Silent auth client created");
10853
+ _a.label = 2;
10854
+ case 2:
10855
+ _a.trys.push([2, 4, , 5]);
10856
+ return [4 /*yield*/, silentAuthClient.acquireCachedToken(silentRequest)];
10857
+ case 3:
10858
+ cachedToken = _a.sent();
10859
+ acquireTokenMeasurement.endMeasurement({
10860
+ success: true,
10861
+ fromCache: true
10862
+ });
10863
+ return [2 /*return*/, cachedToken];
10864
+ case 4:
10865
+ error_1 = _a.sent();
10866
+ if (error_1 instanceof BrowserAuthError && error_1.errorCode === BrowserAuthErrorMessage.signingKeyNotFoundInStorage.code) {
10867
+ this.logger.verbose("Signing keypair for bound access token not found. Refreshing bound access token and generating a new crypto keypair.");
10868
+ }
10869
+ acquireTokenMeasurement.endMeasurement({
10870
+ errorCode: error_1 instanceof AuthError && error_1.errorCode || undefined,
10871
+ subErrorCode: error_1 instanceof AuthError && error_1.subError || undefined,
10872
+ success: false
10873
+ });
10874
+ throw error_1;
10875
+ case 5: return [2 /*return*/];
10876
+ }
10877
+ });
10878
+ });
10879
+ };
10880
+ /**
10881
+ * Currently Unsupported
10882
+ */
10883
+ SilentCacheClient.prototype.logout = function () {
10884
+ // Synchronous so we must reject
10885
+ return Promise.reject(BrowserAuthError.createSilentLogoutUnsupportedError());
10886
+ };
10887
+ /**
10888
+ * Creates an Silent Flow Client with the given authority, or the default authority.
10889
+ * @param serverTelemetryManager
10890
+ * @param authorityUrl
10891
+ */
10892
+ SilentCacheClient.prototype.createSilentFlowClient = function (serverTelemetryManager, authorityUrl, azureCloudOptions) {
10893
+ return __awaiter$1(this, void 0, void 0, function () {
10894
+ var clientConfig;
10895
+ return __generator$1(this, function (_a) {
10896
+ switch (_a.label) {
10897
+ case 0: return [4 /*yield*/, this.getClientConfiguration(serverTelemetryManager, authorityUrl, azureCloudOptions)];
10898
+ case 1:
10899
+ clientConfig = _a.sent();
10900
+ return [2 /*return*/, new SilentFlowClient(clientConfig)];
10901
+ }
10902
+ });
10903
+ });
10904
+ };
10905
+ SilentCacheClient.prototype.initializeSilentRequest = function (request, account) {
10906
+ return __awaiter$1(this, void 0, void 0, function () {
10907
+ var _a;
10908
+ return __generator$1(this, function (_b) {
10909
+ switch (_b.label) {
10910
+ case 0:
10911
+ _a = [__assign$1({}, request)];
10912
+ return [4 /*yield*/, this.initializeBaseRequest(request)];
10913
+ 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 }])];
10914
+ }
10915
+ });
10916
+ });
10917
+ };
10918
+ return SilentCacheClient;
10919
+ }(StandardInteractionClient));
10920
+
10733
10921
  /*
10734
10922
  * Copyright (c) Microsoft Corporation. All rights reserved.
10735
10923
  * Licensed under the MIT License.
10736
10924
  */
10737
10925
  var NativeInteractionClient = /** @class */ (function (_super) {
10738
10926
  __extends$1(NativeInteractionClient, _super);
10739
- function NativeInteractionClient(config, browserStorage, browserCrypto, logger, eventHandler, navigationClient, apiId, performanceClient, provider, accountId, correlationId) {
10927
+ function NativeInteractionClient(config, browserStorage, browserCrypto, logger, eventHandler, navigationClient, apiId, performanceClient, provider, accountId, nativeStorageImpl, correlationId) {
10740
10928
  var _this = _super.call(this, config, browserStorage, browserCrypto, logger, eventHandler, navigationClient, performanceClient, provider, correlationId) || this;
10741
10929
  _this.apiId = apiId;
10742
10930
  _this.accountId = accountId;
10743
10931
  _this.nativeMessageHandler = provider;
10932
+ _this.nativeStorageManager = nativeStorageImpl;
10933
+ _this.silentCacheClient = new SilentCacheClient(config, _this.nativeStorageManager, browserCrypto, logger, eventHandler, navigationClient, performanceClient, provider, correlationId);
10744
10934
  return _this;
10745
10935
  }
10746
10936
  /**
@@ -10749,22 +10939,40 @@
10749
10939
  */
10750
10940
  NativeInteractionClient.prototype.acquireToken = function (request) {
10751
10941
  return __awaiter$1(this, void 0, void 0, function () {
10752
- var nativeATMeasurement, nativeRequest, messageBody, reqTimestamp, response, validatedResponse;
10942
+ var nativeATMeasurement, reqTimestamp, nativeRequest, result, messageBody, response, validatedResponse;
10753
10943
  return __generator$1(this, function (_a) {
10754
10944
  switch (_a.label) {
10755
10945
  case 0:
10756
10946
  this.logger.trace("NativeInteractionClient - acquireToken called.");
10757
10947
  nativeATMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.NativeInteractionClientAcquireToken, request.correlationId);
10948
+ reqTimestamp = TimeUtils.nowSeconds();
10758
10949
  return [4 /*yield*/, this.initializeNativeRequest(request)];
10759
10950
  case 1:
10760
10951
  nativeRequest = _a.sent();
10952
+ _a.label = 2;
10953
+ case 2:
10954
+ _a.trys.push([2, 4, , 5]);
10955
+ return [4 /*yield*/, this.acquireTokensFromCache(this.accountId, nativeRequest)];
10956
+ case 3:
10957
+ result = _a.sent();
10958
+ nativeATMeasurement.endMeasurement({
10959
+ success: true,
10960
+ isNativeBroker: true,
10961
+ fromCache: true
10962
+ });
10963
+ return [2 /*return*/, result];
10964
+ case 4:
10965
+ _a.sent();
10966
+ // continue with a native call for any and all errors
10967
+ this.logger.info("MSAL internal Cache does not contain tokens, proceed to make a native call");
10968
+ return [3 /*break*/, 5];
10969
+ case 5:
10761
10970
  messageBody = {
10762
10971
  method: NativeExtensionMethod.GetToken,
10763
10972
  request: nativeRequest
10764
10973
  };
10765
- reqTimestamp = TimeUtils.nowSeconds();
10766
10974
  return [4 /*yield*/, this.nativeMessageHandler.sendMessage(messageBody)];
10767
- case 2:
10975
+ case 6:
10768
10976
  response = _a.sent();
10769
10977
  validatedResponse = this.validateNativeResponse(response);
10770
10978
  return [2 /*return*/, this.handleNativeResponse(validatedResponse, nativeRequest, reqTimestamp)
@@ -10788,13 +10996,61 @@
10788
10996
  });
10789
10997
  });
10790
10998
  };
10999
+ /**
11000
+ * Creates silent flow request
11001
+ * @param request
11002
+ * @param cachedAccount
11003
+ * @returns CommonSilentFlowRequest
11004
+ */
11005
+ NativeInteractionClient.prototype.createSilentCacheRequest = function (request, cachedAccount) {
11006
+ return {
11007
+ authority: request.authority,
11008
+ correlationId: this.correlationId,
11009
+ scopes: ScopeSet.fromString(request.scopes).asArray(),
11010
+ account: cachedAccount,
11011
+ forceRefresh: false,
11012
+ };
11013
+ };
11014
+ /**
11015
+ * Fetches the tokens from the cache if un-expired
11016
+ * @param nativeAccountId
11017
+ * @param request
11018
+ * @returns authenticationResult
11019
+ */
11020
+ NativeInteractionClient.prototype.acquireTokensFromCache = function (nativeAccountId, request) {
11021
+ return __awaiter$1(this, void 0, void 0, function () {
11022
+ var accountEntity, account, silentRequest, result, e_2;
11023
+ return __generator$1(this, function (_a) {
11024
+ switch (_a.label) {
11025
+ case 0:
11026
+ accountEntity = this.browserStorage.readAccountFromCacheWithNativeAccountId(nativeAccountId);
11027
+ if (!accountEntity) {
11028
+ throw ClientAuthError.createNoAccountFoundError();
11029
+ }
11030
+ account = accountEntity.getAccountInfo();
11031
+ _a.label = 1;
11032
+ case 1:
11033
+ _a.trys.push([1, 3, , 4]);
11034
+ silentRequest = this.createSilentCacheRequest(request, account);
11035
+ return [4 /*yield*/, this.silentCacheClient.acquireToken(silentRequest)];
11036
+ case 2:
11037
+ result = _a.sent();
11038
+ return [2 /*return*/, result];
11039
+ case 3:
11040
+ e_2 = _a.sent();
11041
+ throw e_2;
11042
+ case 4: return [2 /*return*/];
11043
+ }
11044
+ });
11045
+ });
11046
+ };
10791
11047
  /**
10792
11048
  * Acquires a token from native platform then redirects to the redirectUri instead of returning the response
10793
11049
  * @param request
10794
11050
  */
10795
11051
  NativeInteractionClient.prototype.acquireTokenRedirect = function (request) {
10796
11052
  return __awaiter$1(this, void 0, void 0, function () {
10797
- var nativeRequest, messageBody, response, e_1, navigationOptions, redirectUri;
11053
+ var nativeRequest, messageBody, response, e_3, navigationOptions, redirectUri;
10798
11054
  return __generator$1(this, function (_a) {
10799
11055
  switch (_a.label) {
10800
11056
  case 0:
@@ -10815,10 +11071,10 @@
10815
11071
  this.validateNativeResponse(response);
10816
11072
  return [3 /*break*/, 5];
10817
11073
  case 4:
10818
- e_1 = _a.sent();
11074
+ e_3 = _a.sent();
10819
11075
  // Only throw fatal errors here to allow application to fallback to regular redirect. Otherwise proceed and the error will be thrown in handleRedirectPromise
10820
- if (e_1 instanceof NativeAuthError && e_1.isFatal()) {
10821
- throw e_1;
11076
+ if (e_3 instanceof NativeAuthError && e_3.isFatal()) {
11077
+ throw e_3;
10822
11078
  }
10823
11079
  return [3 /*break*/, 5];
10824
11080
  case 5:
@@ -10842,7 +11098,7 @@
10842
11098
  */
10843
11099
  NativeInteractionClient.prototype.handleRedirectPromise = function () {
10844
11100
  return __awaiter$1(this, void 0, void 0, function () {
10845
- var cachedRequest, messageBody, reqTimestamp, response, result, e_2;
11101
+ var cachedRequest, messageBody, reqTimestamp, response, result, e_4;
10846
11102
  return __generator$1(this, function (_a) {
10847
11103
  switch (_a.label) {
10848
11104
  case 0:
@@ -10874,9 +11130,9 @@
10874
11130
  this.browserStorage.setInteractionInProgress(false);
10875
11131
  return [2 /*return*/, result];
10876
11132
  case 3:
10877
- e_2 = _a.sent();
11133
+ e_4 = _a.sent();
10878
11134
  this.browserStorage.setInteractionInProgress(false);
10879
- throw e_2;
11135
+ throw e_4;
10880
11136
  case 4: return [2 /*return*/];
10881
11137
  }
10882
11138
  });
@@ -10898,7 +11154,7 @@
10898
11154
  */
10899
11155
  NativeInteractionClient.prototype.handleNativeResponse = function (response, request, reqTimestamp) {
10900
11156
  return __awaiter$1(this, void 0, void 0, function () {
10901
- var idTokenObj, authority, authorityPreferredCache, homeAccountIdentifier, accountEntity, responseScopes, accountProperties, uid, tid, responseAccessToken, responseTokenType, _a, popTokenGenerator, shrParameters, mats, result;
11157
+ var idTokenObj, authority, authorityPreferredCache, homeAccountIdentifier, accountEntity, responseScopes, accountProperties, uid, tid, responseAccessToken, responseTokenType, _a, popTokenGenerator, shrParameters, mats, result, idTokenEntity, expiresIn, tokenExpirationSeconds, accessTokenEntity;
10902
11158
  var _this = this;
10903
11159
  return __generator$1(this, function (_b) {
10904
11160
  switch (_b.label) {
@@ -10976,7 +11232,17 @@
10976
11232
  state: response.state,
10977
11233
  fromNativeBroker: true
10978
11234
  };
10979
- // Remove any existing cached tokens for this account
11235
+ idTokenEntity = IdTokenEntity.createIdTokenEntity(homeAccountIdentifier, request.authority, response.id_token || Constants.EMPTY_STRING, request.clientId, idTokenObj.claims.tid || Constants.EMPTY_STRING);
11236
+ this.nativeStorageManager.setIdTokenCredential(idTokenEntity);
11237
+ expiresIn = (responseTokenType === exports.AuthenticationScheme.POP)
11238
+ ? Constants.SHR_NONCE_VALIDITY
11239
+ : (typeof response.expires_in === "string"
11240
+ ? parseInt(response.expires_in, 10)
11241
+ : response.expires_in) || 0;
11242
+ tokenExpirationSeconds = reqTimestamp + expiresIn;
11243
+ accessTokenEntity = AccessTokenEntity.createAccessTokenEntity(homeAccountIdentifier, request.authority, responseAccessToken, request.clientId, tid, responseScopes.printScopes(), tokenExpirationSeconds, 0, this.browserCrypto);
11244
+ this.nativeStorageManager.setAccessTokenCredential(accessTokenEntity);
11245
+ // Remove any existing cached tokens for this account in browser storage
10980
11246
  this.browserStorage.removeAccountContext(accountEntity).catch(function (e) {
10981
11247
  _this.logger.error("Error occurred while removing account context from browser storage. " + e);
10982
11248
  });
@@ -11340,8 +11606,10 @@
11340
11606
  */
11341
11607
  var RedirectClient = /** @class */ (function (_super) {
11342
11608
  __extends$1(RedirectClient, _super);
11343
- function RedirectClient() {
11344
- return _super !== null && _super.apply(this, arguments) || this;
11609
+ function RedirectClient(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, performanceClient, nativeStorageImpl, nativeMessageHandler, correlationId) {
11610
+ var _this = _super.call(this, config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, performanceClient, nativeMessageHandler, correlationId) || this;
11611
+ _this.nativeStorage = nativeStorageImpl;
11612
+ return _this;
11345
11613
  }
11346
11614
  /**
11347
11615
  * Redirects the page to the /authorize endpoint of the IDP
@@ -11550,7 +11818,7 @@
11550
11818
  if (!this.nativeMessageHandler) {
11551
11819
  throw BrowserAuthError.createNativeConnectionNotEstablishedError();
11552
11820
  }
11553
- 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);
11821
+ 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);
11554
11822
  userRequestState = ProtocolUtils.parseRequestState(this.browserCrypto, state).userRequestState;
11555
11823
  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
11556
11824
  })).finally(function () {
@@ -11668,10 +11936,11 @@
11668
11936
  */
11669
11937
  var PopupClient = /** @class */ (function (_super) {
11670
11938
  __extends$1(PopupClient, _super);
11671
- function PopupClient(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, performanceClient, nativeMessageHandler, correlationId) {
11939
+ function PopupClient(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, performanceClient, nativeStorageImpl, nativeMessageHandler, correlationId) {
11672
11940
  var _this = _super.call(this, config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, performanceClient, nativeMessageHandler, correlationId) || this;
11673
11941
  // Properly sets this reference for the unload event.
11674
11942
  _this.unloadWindow = _this.unloadWindow.bind(_this);
11943
+ _this.nativeStorage = nativeStorageImpl;
11675
11944
  return _this;
11676
11945
  }
11677
11946
  /**
@@ -11796,7 +12065,7 @@
11796
12065
  if (!this.nativeMessageHandler) {
11797
12066
  throw BrowserAuthError.createNativeConnectionNotEstablishedError();
11798
12067
  }
11799
- 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);
12068
+ 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);
11800
12069
  userRequestState = ProtocolUtils.parseRequestState(this.browserCrypto, state_1).userRequestState;
11801
12070
  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
11802
12071
  })).finally(function () {
@@ -12424,9 +12693,10 @@
12424
12693
  */
12425
12694
  var SilentIframeClient = /** @class */ (function (_super) {
12426
12695
  __extends$1(SilentIframeClient, _super);
12427
- function SilentIframeClient(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, apiId, performanceClient, nativeMessageHandler, correlationId) {
12696
+ function SilentIframeClient(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, apiId, performanceClient, nativeStorageImpl, nativeMessageHandler, correlationId) {
12428
12697
  var _this = _super.call(this, config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, performanceClient, nativeMessageHandler, correlationId) || this;
12429
12698
  _this.apiId = apiId;
12699
+ _this.nativeStorage = nativeStorageImpl;
12430
12700
  return _this;
12431
12701
  }
12432
12702
  /**
@@ -12529,7 +12799,7 @@
12529
12799
  if (!this.nativeMessageHandler) {
12530
12800
  throw BrowserAuthError.createNativeConnectionNotEstablishedError();
12531
12801
  }
12532
- 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);
12802
+ 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);
12533
12803
  userRequestState = ProtocolUtils.parseRequestState(this.browserCrypto, state).userRequestState;
12534
12804
  return [2 /*return*/, nativeInteractionClient.acquireToken(__assign$1(__assign$1({}, silentRequest), { state: userRequestState, prompt: PromptValue.NONE })).finally(function () {
12535
12805
  _this.browserStorage.cleanRequestByState(state);
@@ -12544,99 +12814,6 @@
12544
12814
  return SilentIframeClient;
12545
12815
  }(StandardInteractionClient));
12546
12816
 
12547
- /*
12548
- * Copyright (c) Microsoft Corporation. All rights reserved.
12549
- * Licensed under the MIT License.
12550
- */
12551
- var SilentCacheClient = /** @class */ (function (_super) {
12552
- __extends$1(SilentCacheClient, _super);
12553
- function SilentCacheClient() {
12554
- return _super !== null && _super.apply(this, arguments) || this;
12555
- }
12556
- /**
12557
- * Returns unexpired tokens from the cache, if available
12558
- * @param silentRequest
12559
- */
12560
- SilentCacheClient.prototype.acquireToken = function (silentRequest) {
12561
- return __awaiter$1(this, void 0, void 0, function () {
12562
- var acquireTokenMeasurement, serverTelemetryManager, silentAuthClient, cachedToken, error_1;
12563
- return __generator$1(this, function (_a) {
12564
- switch (_a.label) {
12565
- case 0:
12566
- acquireTokenMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.SilentCacheClientAcquireToken, silentRequest.correlationId);
12567
- serverTelemetryManager = this.initializeServerTelemetryManager(exports.ApiId.acquireTokenSilent_silentFlow);
12568
- return [4 /*yield*/, this.createSilentFlowClient(serverTelemetryManager, silentRequest.authority, silentRequest.azureCloudOptions)];
12569
- case 1:
12570
- silentAuthClient = _a.sent();
12571
- this.logger.verbose("Silent auth client created");
12572
- _a.label = 2;
12573
- case 2:
12574
- _a.trys.push([2, 4, , 5]);
12575
- return [4 /*yield*/, silentAuthClient.acquireCachedToken(silentRequest)];
12576
- case 3:
12577
- cachedToken = _a.sent();
12578
- acquireTokenMeasurement.endMeasurement({
12579
- success: true,
12580
- fromCache: true
12581
- });
12582
- return [2 /*return*/, cachedToken];
12583
- case 4:
12584
- error_1 = _a.sent();
12585
- if (error_1 instanceof BrowserAuthError && error_1.errorCode === BrowserAuthErrorMessage.signingKeyNotFoundInStorage.code) {
12586
- this.logger.verbose("Signing keypair for bound access token not found. Refreshing bound access token and generating a new crypto keypair.");
12587
- }
12588
- acquireTokenMeasurement.endMeasurement({
12589
- errorCode: error_1 instanceof AuthError && error_1.errorCode || undefined,
12590
- subErrorCode: error_1 instanceof AuthError && error_1.subError || undefined,
12591
- success: false
12592
- });
12593
- throw error_1;
12594
- case 5: return [2 /*return*/];
12595
- }
12596
- });
12597
- });
12598
- };
12599
- /**
12600
- * Currently Unsupported
12601
- */
12602
- SilentCacheClient.prototype.logout = function () {
12603
- // Synchronous so we must reject
12604
- return Promise.reject(BrowserAuthError.createSilentLogoutUnsupportedError());
12605
- };
12606
- /**
12607
- * Creates an Silent Flow Client with the given authority, or the default authority.
12608
- * @param serverTelemetryManager
12609
- * @param authorityUrl
12610
- */
12611
- SilentCacheClient.prototype.createSilentFlowClient = function (serverTelemetryManager, authorityUrl, azureCloudOptions) {
12612
- return __awaiter$1(this, void 0, void 0, function () {
12613
- var clientConfig;
12614
- return __generator$1(this, function (_a) {
12615
- switch (_a.label) {
12616
- case 0: return [4 /*yield*/, this.getClientConfiguration(serverTelemetryManager, authorityUrl, azureCloudOptions)];
12617
- case 1:
12618
- clientConfig = _a.sent();
12619
- return [2 /*return*/, new SilentFlowClient(clientConfig)];
12620
- }
12621
- });
12622
- });
12623
- };
12624
- SilentCacheClient.prototype.initializeSilentRequest = function (request, account) {
12625
- return __awaiter$1(this, void 0, void 0, function () {
12626
- var _a;
12627
- return __generator$1(this, function (_b) {
12628
- switch (_b.label) {
12629
- case 0:
12630
- _a = [__assign$1({}, request)];
12631
- return [4 /*yield*/, this.initializeBaseRequest(request)];
12632
- 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 }])];
12633
- }
12634
- });
12635
- });
12636
- };
12637
- return SilentCacheClient;
12638
- }(StandardInteractionClient));
12639
-
12640
12817
  /*
12641
12818
  * Copyright (c) Microsoft Corporation. All rights reserved.
12642
12819
  * Licensed under the MIT License.
@@ -14654,6 +14831,13 @@
14654
14831
  this.browserStorage = this.isBrowserEnvironment ?
14655
14832
  new BrowserCacheManager(this.config.auth.clientId, this.config.cache, this.browserCrypto, this.logger) :
14656
14833
  DEFAULT_BROWSER_CACHE_MANAGER(this.config.auth.clientId, this.logger);
14834
+ // initialize in memory storage for native flows
14835
+ var nativeCacheOptions = {
14836
+ cacheLocation: exports.BrowserCacheLocation.MemoryStorage,
14837
+ storeAuthStateInCookie: false,
14838
+ secureCookies: false
14839
+ };
14840
+ this.nativeInternalStorage = new BrowserCacheManager(this.config.auth.clientId, nativeCacheOptions, this.browserCrypto, this.logger);
14657
14841
  // Initialize the token cache
14658
14842
  this.tokenCache = new TokenCache(this.config, this.browserStorage, this.logger, this.browserCrypto);
14659
14843
  }
@@ -14720,7 +14904,7 @@
14720
14904
  redirectResponse = void 0;
14721
14905
  if (request && NativeMessageHandler.isNativeAvailable(this.config, this.logger, this.nativeExtensionProvider) && this.nativeExtensionProvider && !hash) {
14722
14906
  this.logger.trace("handleRedirectPromise - acquiring token from native platform");
14723
- 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);
14907
+ 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);
14724
14908
  redirectResponse = nativeClient.handleRedirectPromise();
14725
14909
  }
14726
14910
  else {
@@ -14792,7 +14976,7 @@
14792
14976
  this.eventHandler.emitEvent(exports.EventType.LOGIN_START, exports.InteractionType.Redirect, request);
14793
14977
  }
14794
14978
  if (this.nativeExtensionProvider && this.canUseNative(request)) {
14795
- 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);
14979
+ 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);
14796
14980
  result = nativeClient.acquireTokenRedirect(request).catch(function (e) {
14797
14981
  if (e instanceof NativeAuthError && e.isFatal()) {
14798
14982
  _this.nativeExtensionProvider = undefined; // If extension gets uninstalled during session prevent future requests from continuing to attempt
@@ -14860,7 +15044,9 @@
14860
15044
  _this.browserStorage.setInteractionInProgress(false);
14861
15045
  atPopupMeasurement.endMeasurement({
14862
15046
  success: true,
14863
- isNativeBroker: true
15047
+ isNativeBroker: true,
15048
+ accessTokenSize: response.accessToken.length,
15049
+ idTokenSize: response.idToken.length,
14864
15050
  });
14865
15051
  atPopupMeasurement.flushMeasurement();
14866
15052
  return response;
@@ -14884,7 +15070,9 @@
14884
15070
  result = popupClient.acquireToken(request);
14885
15071
  }
14886
15072
  return result.then(function (result) {
14887
- // If logged in, emit acquire token events
15073
+ /*
15074
+ * If logged in, emit acquire token events
15075
+ */
14888
15076
  var isLoggingIn = loggedInAccounts.length < _this.getAllAccounts().length;
14889
15077
  if (isLoggingIn) {
14890
15078
  _this.eventHandler.emitEvent(exports.EventType.LOGIN_SUCCESS, exports.InteractionType.Popup, result);
@@ -14893,7 +15081,9 @@
14893
15081
  _this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_SUCCESS, exports.InteractionType.Popup, result);
14894
15082
  }
14895
15083
  atPopupMeasurement.endMeasurement({
14896
- success: true
15084
+ success: true,
15085
+ accessTokenSize: result.accessToken.length,
15086
+ idTokenSize: result.idToken.length,
14897
15087
  });
14898
15088
  atPopupMeasurement.flushMeasurement();
14899
15089
  return result;
@@ -14961,7 +15151,9 @@
14961
15151
  _this.eventHandler.emitEvent(exports.EventType.SSO_SILENT_SUCCESS, exports.InteractionType.Silent, response);
14962
15152
  ssoSilentMeasurement.endMeasurement({
14963
15153
  success: true,
14964
- isNativeBroker: response.fromNativeBroker
15154
+ isNativeBroker: response.fromNativeBroker,
15155
+ accessTokenSize: response.accessToken.length,
15156
+ idTokenSize: response.idToken.length
14965
15157
  });
14966
15158
  ssoSilentMeasurement.flushMeasurement();
14967
15159
  return response;
@@ -15010,6 +15202,8 @@
15010
15202
  _this.hybridAuthCodeResponses.delete(hybridAuthCode_1);
15011
15203
  atbcMeasurement.endMeasurement({
15012
15204
  success: true,
15205
+ accessTokenSize: result.accessToken.length,
15206
+ idTokenSize: result.idToken.length,
15013
15207
  isNativeBroker: result.fromNativeBroker
15014
15208
  });
15015
15209
  atbcMeasurement.flushMeasurement();
@@ -15114,7 +15308,9 @@
15114
15308
  .then(function (result) {
15115
15309
  atbrtMeasurement.endMeasurement({
15116
15310
  success: true,
15117
- fromCache: result.fromCache
15311
+ fromCache: result.fromCache,
15312
+ accessTokenSize: result.accessToken.length,
15313
+ idTokenSize: result.idToken.length,
15118
15314
  });
15119
15315
  return result;
15120
15316
  })
@@ -15129,7 +15325,9 @@
15129
15325
  .then(function (result) {
15130
15326
  atbrtMeasurement.endMeasurement({
15131
15327
  success: true,
15132
- fromCache: result.fromCache
15328
+ fromCache: result.fromCache,
15329
+ accessTokenSize: result.accessToken.length,
15330
+ idTokenSize: result.idToken.length,
15133
15331
  });
15134
15332
  return result;
15135
15333
  })
@@ -15341,7 +15539,7 @@
15341
15539
  if (!this.nativeExtensionProvider) {
15342
15540
  throw BrowserAuthError.createNativeConnectionNotEstablishedError();
15343
15541
  }
15344
- 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);
15542
+ 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);
15345
15543
  return [2 /*return*/, nativeClient.acquireToken(request)];
15346
15544
  });
15347
15545
  });
@@ -15388,21 +15586,21 @@
15388
15586
  * @param correlationId
15389
15587
  */
15390
15588
  ClientApplication.prototype.createPopupClient = function (correlationId) {
15391
- return new PopupClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, this.performanceClient, this.nativeExtensionProvider, correlationId);
15589
+ return new PopupClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, this.performanceClient, this.nativeInternalStorage, this.nativeExtensionProvider, correlationId);
15392
15590
  };
15393
15591
  /**
15394
15592
  * Returns new instance of the Redirect Interaction Client
15395
15593
  * @param correlationId
15396
15594
  */
15397
15595
  ClientApplication.prototype.createRedirectClient = function (correlationId) {
15398
- return new RedirectClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, this.performanceClient, this.nativeExtensionProvider, correlationId);
15596
+ return new RedirectClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, this.performanceClient, this.nativeInternalStorage, this.nativeExtensionProvider, correlationId);
15399
15597
  };
15400
15598
  /**
15401
15599
  * Returns new instance of the Silent Iframe Interaction Client
15402
15600
  * @param correlationId
15403
15601
  */
15404
15602
  ClientApplication.prototype.createSilentIframeClient = function (correlationId) {
15405
- return new SilentIframeClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, exports.ApiId.ssoSilent, this.performanceClient, this.nativeExtensionProvider, correlationId);
15603
+ 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);
15406
15604
  };
15407
15605
  /**
15408
15606
  * Returns new instance of the Silent Cache Interaction Client
@@ -15638,6 +15836,8 @@
15638
15836
  atsMeasurement.endMeasurement({
15639
15837
  success: true,
15640
15838
  fromCache: result.fromCache,
15839
+ accessTokenSize: result.accessToken.length,
15840
+ idTokenSize: result.idToken.length,
15641
15841
  isNativeBroker: result.fromNativeBroker
15642
15842
  });
15643
15843
  atsMeasurement.flushMeasurement();
@@ -15646,8 +15846,6 @@
15646
15846
  .catch(function (error) {
15647
15847
  _this.activeSilentTokenRequests.delete(silentRequestKey);
15648
15848
  atsMeasurement.endMeasurement({
15649
- errorCode: error.errorCode,
15650
- subErrorCode: error.subError,
15651
15849
  success: false
15652
15850
  });
15653
15851
  atsMeasurement.flushMeasurement();
@@ -15717,6 +15915,8 @@
15717
15915
  astsAsyncMeasurement.endMeasurement({
15718
15916
  success: true,
15719
15917
  fromCache: response.fromCache,
15918
+ accessTokenSize: response.accessToken.length,
15919
+ idTokenSize: response.idToken.length,
15720
15920
  isNativeBroker: response.fromNativeBroker
15721
15921
  });
15722
15922
  return response;