@azure/msal-browser 2.27.0 → 2.28.2

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 (97) hide show
  1. package/README.md +1 -1
  2. package/dist/_virtual/_tslib.js +14 -2
  3. package/dist/_virtual/_tslib.js.map +1 -1
  4. package/dist/app/ClientApplication.d.ts +1 -0
  5. package/dist/app/ClientApplication.d.ts.map +1 -1
  6. package/dist/app/ClientApplication.js +34 -13
  7. package/dist/app/ClientApplication.js.map +1 -1
  8. package/dist/app/IPublicClientApplication.js +1 -1
  9. package/dist/app/PublicClientApplication.d.ts.map +1 -1
  10. package/dist/app/PublicClientApplication.js +5 -3
  11. package/dist/app/PublicClientApplication.js.map +1 -1
  12. package/dist/broker/nativeBroker/NativeMessageHandler.js +1 -1
  13. package/dist/broker/nativeBroker/NativeRequest.d.ts +1 -1
  14. package/dist/broker/nativeBroker/NativeRequest.d.ts.map +1 -1
  15. package/dist/broker/nativeBroker/NativeResponse.d.ts +1 -1
  16. package/dist/broker/nativeBroker/NativeResponse.d.ts.map +1 -1
  17. package/dist/cache/AsyncMemoryStorage.js +1 -1
  18. package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
  19. package/dist/cache/BrowserCacheManager.js +39 -8
  20. package/dist/cache/BrowserCacheManager.js.map +1 -1
  21. package/dist/cache/BrowserStorage.js +1 -1
  22. package/dist/cache/DatabaseStorage.js +1 -1
  23. package/dist/cache/MemoryStorage.js +1 -1
  24. package/dist/cache/TokenCache.js +1 -1
  25. package/dist/config/Configuration.js +1 -1
  26. package/dist/crypto/BrowserCrypto.js +1 -1
  27. package/dist/crypto/CryptoOps.js +1 -1
  28. package/dist/crypto/GuidGenerator.js +1 -1
  29. package/dist/crypto/PkceGenerator.js +1 -1
  30. package/dist/crypto/SignedHttpRequest.js +1 -1
  31. package/dist/encode/Base64Decode.js +1 -1
  32. package/dist/encode/Base64Encode.js +1 -1
  33. package/dist/error/BrowserAuthError.js +1 -1
  34. package/dist/error/BrowserConfigurationAuthError.js +1 -1
  35. package/dist/error/NativeAuthError.d.ts +9 -0
  36. package/dist/error/NativeAuthError.d.ts.map +1 -1
  37. package/dist/error/NativeAuthError.js +12 -1
  38. package/dist/error/NativeAuthError.js.map +1 -1
  39. package/dist/event/EventHandler.js +1 -1
  40. package/dist/event/EventMessage.js +1 -1
  41. package/dist/event/EventType.js +1 -1
  42. package/dist/index.cjs.js +676 -369
  43. package/dist/index.cjs.js.map +1 -1
  44. package/dist/index.js +1 -1
  45. package/dist/interaction_client/BaseInteractionClient.d.ts.map +1 -1
  46. package/dist/interaction_client/BaseInteractionClient.js +2 -3
  47. package/dist/interaction_client/BaseInteractionClient.js.map +1 -1
  48. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.js +1 -1
  49. package/dist/interaction_client/NativeInteractionClient.d.ts +18 -1
  50. package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
  51. package/dist/interaction_client/NativeInteractionClient.js +101 -22
  52. package/dist/interaction_client/NativeInteractionClient.js.map +1 -1
  53. package/dist/interaction_client/PopupClient.d.ts +2 -1
  54. package/dist/interaction_client/PopupClient.d.ts.map +1 -1
  55. package/dist/interaction_client/PopupClient.js +4 -3
  56. package/dist/interaction_client/PopupClient.js.map +1 -1
  57. package/dist/interaction_client/RedirectClient.d.ts +8 -1
  58. package/dist/interaction_client/RedirectClient.d.ts.map +1 -1
  59. package/dist/interaction_client/RedirectClient.js +6 -4
  60. package/dist/interaction_client/RedirectClient.js.map +1 -1
  61. package/dist/interaction_client/SilentAuthCodeClient.js +1 -1
  62. package/dist/interaction_client/SilentAuthCodeClient.js.map +1 -1
  63. package/dist/interaction_client/SilentCacheClient.d.ts.map +1 -1
  64. package/dist/interaction_client/SilentCacheClient.js +2 -2
  65. package/dist/interaction_client/SilentCacheClient.js.map +1 -1
  66. package/dist/interaction_client/SilentIframeClient.d.ts +2 -1
  67. package/dist/interaction_client/SilentIframeClient.d.ts.map +1 -1
  68. package/dist/interaction_client/SilentIframeClient.js +4 -3
  69. package/dist/interaction_client/SilentIframeClient.js.map +1 -1
  70. package/dist/interaction_client/SilentRefreshClient.d.ts.map +1 -1
  71. package/dist/interaction_client/SilentRefreshClient.js +2 -2
  72. package/dist/interaction_client/SilentRefreshClient.js.map +1 -1
  73. package/dist/interaction_client/StandardInteractionClient.js +1 -1
  74. package/dist/interaction_handler/InteractionHandler.js +1 -1
  75. package/dist/interaction_handler/RedirectHandler.js +1 -1
  76. package/dist/interaction_handler/SilentHandler.js +1 -1
  77. package/dist/internals.js +1 -1
  78. package/dist/navigation/NavigationClient.js +1 -1
  79. package/dist/network/FetchClient.js +1 -1
  80. package/dist/network/XhrClient.js +1 -1
  81. package/dist/packageMetadata.d.ts +1 -1
  82. package/dist/packageMetadata.js +2 -2
  83. package/dist/packageMetadata.js.map +1 -1
  84. package/dist/request/PopupRequest.d.ts +1 -1
  85. package/dist/request/RedirectRequest.d.ts +1 -1
  86. package/dist/request/SsoSilentRequest.d.ts +1 -1
  87. package/dist/telemetry/BrowserPerformanceClient.js +1 -1
  88. package/dist/telemetry/BrowserPerformanceMeasurement.js +1 -1
  89. package/dist/utils/BrowserConstants.js +1 -1
  90. package/dist/utils/BrowserProtocolUtils.js +1 -1
  91. package/dist/utils/BrowserStringUtils.js +1 -1
  92. package/dist/utils/BrowserUtils.js +1 -1
  93. package/dist/utils/MathUtils.js +1 -1
  94. package/lib/msal-browser.js +676 -369
  95. package/lib/msal-browser.js.map +1 -1
  96. package/lib/msal-browser.min.js +42 -42
  97. package/package.json +3 -4
@@ -1,4 +1,4 @@
1
- /*! @azure/msal-browser v2.27.0 2022-07-05 */
1
+ /*! @azure/msal-browser v2.28.2 2022-09-06 */
2
2
  'use strict';
3
3
  (function (global, factory) {
4
4
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
@@ -46,6 +46,18 @@
46
46
  return __assign$1.apply(this, arguments);
47
47
  };
48
48
 
49
+ function __rest(s, e) {
50
+ var t = {};
51
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
52
+ t[p] = s[p];
53
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
54
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
55
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
56
+ t[p[i]] = s[p[i]];
57
+ }
58
+ return t;
59
+ }
60
+
49
61
  function __awaiter$1(thisArg, _arguments, P, generator) {
50
62
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
51
63
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -107,7 +119,7 @@
107
119
  return ar;
108
120
  }
109
121
 
110
- /*! @azure/msal-common v7.1.0 2022-07-05 */
122
+ /*! @azure/msal-common v7.4.0 2022-09-06 */
111
123
  /*! *****************************************************************************
112
124
  Copyright (c) Microsoft Corporation.
113
125
 
@@ -194,7 +206,7 @@
194
206
  return r;
195
207
  }
196
208
 
197
- /*! @azure/msal-common v7.1.0 2022-07-05 */
209
+ /*! @azure/msal-common v7.4.0 2022-09-06 */
198
210
 
199
211
  /*
200
212
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -244,7 +256,8 @@
244
256
  REGIONAL_AUTH_PUBLIC_CLOUD_SUFFIX: "login.microsoft.com",
245
257
  KNOWN_PUBLIC_CLOUDS: ["login.microsoftonline.com", "login.windows.net", "login.microsoft.com", "sts.windows.net"],
246
258
  TOKEN_RESPONSE_TYPE: "token",
247
- ID_TOKEN_RESPONSE_TYPE: "id_token"
259
+ ID_TOKEN_RESPONSE_TYPE: "id_token",
260
+ SHR_NONCE_VALIDITY: 240
248
261
  };
249
262
  var OIDC_DEFAULT_SCOPES = [
250
263
  Constants.OPENID_SCOPE,
@@ -276,6 +289,7 @@
276
289
  PersistentCacheKeys["ERROR"] = "error";
277
290
  PersistentCacheKeys["ERROR_DESC"] = "error.description";
278
291
  PersistentCacheKeys["ACTIVE_ACCOUNT"] = "active-account";
292
+ PersistentCacheKeys["ACTIVE_ACCOUNT_FILTERS"] = "active-account-filters"; // new cache entry for active_account for a more robust version for browser
279
293
  })(PersistentCacheKeys || (PersistentCacheKeys = {}));
280
294
  /**
281
295
  * String constants related to AAD Authority
@@ -569,7 +583,7 @@
569
583
  JsonTypes["Jwk"] = "JWK";
570
584
  })(JsonTypes || (JsonTypes = {}));
571
585
 
572
- /*! @azure/msal-common v7.1.0 2022-07-05 */
586
+ /*! @azure/msal-common v7.4.0 2022-09-06 */
573
587
 
574
588
  /*
575
589
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -582,6 +596,10 @@
582
596
  unexpectedError: {
583
597
  code: "unexpected_error",
584
598
  desc: "Unexpected error in authentication."
599
+ },
600
+ postRequestFailed: {
601
+ code: "post_request_failed",
602
+ desc: "Post request failed from the network, could be a 4xx/5xx or a network unavailability. Please check the exact error code for details."
585
603
  }
586
604
  };
587
605
  /**
@@ -610,10 +628,18 @@
610
628
  AuthError.createUnexpectedError = function (errDesc) {
611
629
  return new AuthError(AuthErrorMessage.unexpectedError.code, AuthErrorMessage.unexpectedError.desc + ": " + errDesc);
612
630
  };
631
+ /**
632
+ * Creates an error for post request failures.
633
+ * @param errDesc
634
+ * @returns
635
+ */
636
+ AuthError.createPostRequestFailed = function (errDesc) {
637
+ return new AuthError(AuthErrorMessage.postRequestFailed.code, AuthErrorMessage.postRequestFailed.desc + ": " + errDesc);
638
+ };
613
639
  return AuthError;
614
640
  }(Error));
615
641
 
616
- /*! @azure/msal-common v7.1.0 2022-07-05 */
642
+ /*! @azure/msal-common v7.4.0 2022-09-06 */
617
643
 
618
644
  /*
619
645
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -688,7 +714,7 @@
688
714
  }
689
715
  };
690
716
 
691
- /*! @azure/msal-common v7.1.0 2022-07-05 */
717
+ /*! @azure/msal-common v7.4.0 2022-09-06 */
692
718
 
693
719
  /*
694
720
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1160,7 +1186,7 @@
1160
1186
  return ClientAuthError;
1161
1187
  }(AuthError));
1162
1188
 
1163
- /*! @azure/msal-common v7.1.0 2022-07-05 */
1189
+ /*! @azure/msal-common v7.4.0 2022-09-06 */
1164
1190
 
1165
1191
  /*
1166
1192
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1285,7 +1311,7 @@
1285
1311
  return StringUtils;
1286
1312
  }());
1287
1313
 
1288
- /*! @azure/msal-common v7.1.0 2022-07-05 */
1314
+ /*! @azure/msal-common v7.4.0 2022-09-06 */
1289
1315
 
1290
1316
  /*
1291
1317
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1465,12 +1491,12 @@
1465
1491
  return Logger;
1466
1492
  }());
1467
1493
 
1468
- /*! @azure/msal-common v7.1.0 2022-07-05 */
1494
+ /*! @azure/msal-common v7.4.0 2022-09-06 */
1469
1495
  /* eslint-disable header/header */
1470
1496
  var name$1 = "@azure/msal-common";
1471
- var version$1 = "7.1.0";
1497
+ var version$1 = "7.4.0";
1472
1498
 
1473
- /*! @azure/msal-common v7.1.0 2022-07-05 */
1499
+ /*! @azure/msal-common v7.4.0 2022-09-06 */
1474
1500
  /*
1475
1501
  * Copyright (c) Microsoft Corporation. All rights reserved.
1476
1502
  * Licensed under the MIT License.
@@ -1491,7 +1517,7 @@
1491
1517
  AzureCloudInstance["AzureUsGovernment"] = "https://login.microsoftonline.us";
1492
1518
  })(exports.AzureCloudInstance || (exports.AzureCloudInstance = {}));
1493
1519
 
1494
- /*! @azure/msal-common v7.1.0 2022-07-05 */
1520
+ /*! @azure/msal-common v7.4.0 2022-09-06 */
1495
1521
 
1496
1522
  /*
1497
1523
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1650,7 +1676,7 @@
1650
1676
  return CredentialEntity;
1651
1677
  }());
1652
1678
 
1653
- /*! @azure/msal-common v7.1.0 2022-07-05 */
1679
+ /*! @azure/msal-common v7.4.0 2022-09-06 */
1654
1680
 
1655
1681
  /*
1656
1682
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1905,7 +1931,7 @@
1905
1931
  return ClientConfigurationError;
1906
1932
  }(ClientAuthError));
1907
1933
 
1908
- /*! @azure/msal-common v7.1.0 2022-07-05 */
1934
+ /*! @azure/msal-common v7.4.0 2022-09-06 */
1909
1935
 
1910
1936
  /*
1911
1937
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2089,7 +2115,7 @@
2089
2115
  return ScopeSet;
2090
2116
  }());
2091
2117
 
2092
- /*! @azure/msal-common v7.1.0 2022-07-05 */
2118
+ /*! @azure/msal-common v7.4.0 2022-09-06 */
2093
2119
 
2094
2120
  /*
2095
2121
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2109,7 +2135,7 @@
2109
2135
  return JSON.parse(decodedClientInfo);
2110
2136
  }
2111
2137
  catch (e) {
2112
- throw ClientAuthError.createClientInfoDecodingError(e);
2138
+ throw ClientAuthError.createClientInfoDecodingError(e.message);
2113
2139
  }
2114
2140
  }
2115
2141
  /**
@@ -2127,7 +2153,7 @@
2127
2153
  };
2128
2154
  }
2129
2155
 
2130
- /*! @azure/msal-common v7.1.0 2022-07-05 */
2156
+ /*! @azure/msal-common v7.4.0 2022-09-06 */
2131
2157
  /*
2132
2158
  * Copyright (c) Microsoft Corporation. All rights reserved.
2133
2159
  * Licensed under the MIT License.
@@ -2141,7 +2167,7 @@
2141
2167
  AuthorityType[AuthorityType["Adfs"] = 1] = "Adfs";
2142
2168
  })(AuthorityType || (AuthorityType = {}));
2143
2169
 
2144
- /*! @azure/msal-common v7.1.0 2022-07-05 */
2170
+ /*! @azure/msal-common v7.4.0 2022-09-06 */
2145
2171
 
2146
2172
  /*
2147
2173
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2376,7 +2402,7 @@
2376
2402
  return AccountEntity;
2377
2403
  }());
2378
2404
 
2379
- /*! @azure/msal-common v7.1.0 2022-07-05 */
2405
+ /*! @azure/msal-common v7.4.0 2022-09-06 */
2380
2406
 
2381
2407
  /*
2382
2408
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2414,7 +2440,7 @@
2414
2440
  return AuthToken;
2415
2441
  }());
2416
2442
 
2417
- /*! @azure/msal-common v7.1.0 2022-07-05 */
2443
+ /*! @azure/msal-common v7.4.0 2022-09-06 */
2418
2444
 
2419
2445
  /*
2420
2446
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2445,6 +2471,7 @@
2445
2471
  var accountInfo = accountEntity.getAccountInfo();
2446
2472
  var idToken = _this.readIdTokenFromCache(_this.clientId, accountInfo);
2447
2473
  if (idToken && !accountInfo.idTokenClaims) {
2474
+ accountInfo.idToken = idToken.secret;
2448
2475
  accountInfo.idTokenClaims = new AuthToken(idToken.secret, _this.cryptoImpl).claims;
2449
2476
  }
2450
2477
  return accountInfo;
@@ -2536,7 +2563,7 @@
2536
2563
  * @param realm
2537
2564
  */
2538
2565
  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);
2566
+ 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
2567
  };
2541
2568
  /**
2542
2569
  * retrieve accounts matching all provided filters; if no filter is set, get all accounts
@@ -2545,7 +2572,7 @@
2545
2572
  * @param environment
2546
2573
  * @param realm
2547
2574
  */
2548
- CacheManager.prototype.getAccountsFilteredByInternal = function (homeAccountId, environment, realm) {
2575
+ CacheManager.prototype.getAccountsFilteredByInternal = function (homeAccountId, environment, realm, nativeAccountId) {
2549
2576
  var _this = this;
2550
2577
  var allCacheKeys = this.getKeys();
2551
2578
  var matchingAccounts = {};
@@ -2563,6 +2590,9 @@
2563
2590
  if (!!realm && !_this.matchRealm(entity, realm)) {
2564
2591
  return;
2565
2592
  }
2593
+ if (!!nativeAccountId && !_this.matchNativeAccountId(entity, nativeAccountId)) {
2594
+ return;
2595
+ }
2566
2596
  matchingAccounts[cacheKey] = entity;
2567
2597
  });
2568
2598
  return matchingAccounts;
@@ -2891,6 +2921,26 @@
2891
2921
  var accountKey = AccountEntity.generateAccountCacheKey(account);
2892
2922
  return this.getAccount(accountKey);
2893
2923
  };
2924
+ /**
2925
+ * Retrieve AccountEntity from cache
2926
+ * @param nativeAccountId
2927
+ * @returns AccountEntity or Null
2928
+ */
2929
+ CacheManager.prototype.readAccountFromCacheWithNativeAccountId = function (nativeAccountId) {
2930
+ // fetch account from memory
2931
+ var accountFilter = {
2932
+ nativeAccountId: nativeAccountId
2933
+ };
2934
+ var accountCache = this.getAccountsFilteredBy(accountFilter);
2935
+ var accounts = Object.keys(accountCache).map(function (key) { return accountCache[key]; });
2936
+ if (accounts.length < 1) {
2937
+ return null;
2938
+ }
2939
+ else if (accounts.length > 1) {
2940
+ throw ClientAuthError.createMultipleMatchingAccountsInCacheError();
2941
+ }
2942
+ return accountCache[0];
2943
+ };
2894
2944
  /**
2895
2945
  * Retrieve IdTokenEntity from cache
2896
2946
  * @param clientId
@@ -3065,6 +3115,15 @@
3065
3115
  CacheManager.prototype.matchRealm = function (entity, realm) {
3066
3116
  return !!(entity.realm && realm === entity.realm);
3067
3117
  };
3118
+ /**
3119
+ * helper to match nativeAccountId
3120
+ * @param entity
3121
+ * @param nativeAccountId
3122
+ * @returns boolean indicating the match result
3123
+ */
3124
+ CacheManager.prototype.matchNativeAccountId = function (entity, nativeAccountId) {
3125
+ return !!(entity.nativeAccountId && nativeAccountId === entity.nativeAccountId);
3126
+ };
3068
3127
  /**
3069
3128
  * Returns true if the target scopes are a subset of the current entity's scopes, false otherwise.
3070
3129
  * @param entity
@@ -3256,7 +3315,7 @@
3256
3315
  return DefaultStorageClass;
3257
3316
  }(CacheManager));
3258
3317
 
3259
- /*! @azure/msal-common v7.1.0 2022-07-05 */
3318
+ /*! @azure/msal-common v7.4.0 2022-09-06 */
3260
3319
 
3261
3320
  /*
3262
3321
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3339,7 +3398,7 @@
3339
3398
  telemetry: __assign(__assign({}, DEFAULT_TELEMETRY_OPTIONS), telemetry),
3340
3399
  serverTelemetryManager: serverTelemetryManager || null,
3341
3400
  persistencePlugin: persistencePlugin || null,
3342
- serializableCache: serializableCache || null
3401
+ serializableCache: serializableCache || null,
3343
3402
  };
3344
3403
  }
3345
3404
  /**
@@ -3350,7 +3409,7 @@
3350
3409
  return __assign({ clientCapabilities: [], azureCloudOptions: DEFAULT_AZURE_CLOUD_OPTIONS, skipAuthorityMetadataCache: false }, authOptions);
3351
3410
  }
3352
3411
 
3353
- /*! @azure/msal-common v7.1.0 2022-07-05 */
3412
+ /*! @azure/msal-common v7.4.0 2022-09-06 */
3354
3413
 
3355
3414
  /*
3356
3415
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3370,7 +3429,7 @@
3370
3429
  return ServerError;
3371
3430
  }(AuthError));
3372
3431
 
3373
- /*! @azure/msal-common v7.1.0 2022-07-05 */
3432
+ /*! @azure/msal-common v7.4.0 2022-09-06 */
3374
3433
 
3375
3434
  /*
3376
3435
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3466,7 +3525,7 @@
3466
3525
  return ThrottlingUtils;
3467
3526
  }());
3468
3527
 
3469
- /*! @azure/msal-common v7.1.0 2022-07-05 */
3528
+ /*! @azure/msal-common v7.4.0 2022-09-06 */
3470
3529
 
3471
3530
  /*
3472
3531
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3515,7 +3574,7 @@
3515
3574
  return NetworkManager;
3516
3575
  }());
3517
3576
 
3518
- /*! @azure/msal-common v7.1.0 2022-07-05 */
3577
+ /*! @azure/msal-common v7.4.0 2022-09-06 */
3519
3578
  /*
3520
3579
  * Copyright (c) Microsoft Corporation. All rights reserved.
3521
3580
  * Licensed under the MIT License.
@@ -3526,7 +3585,7 @@
3526
3585
  CcsCredentialType["UPN"] = "UPN";
3527
3586
  })(CcsCredentialType || (CcsCredentialType = {}));
3528
3587
 
3529
- /*! @azure/msal-common v7.1.0 2022-07-05 */
3588
+ /*! @azure/msal-common v7.4.0 2022-09-06 */
3530
3589
 
3531
3590
  /*
3532
3591
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3536,7 +3595,7 @@
3536
3595
  * Base application class which will construct requests to send to and handle responses from the Microsoft STS using the authorization code flow.
3537
3596
  */
3538
3597
  var BaseClient = /** @class */ (function () {
3539
- function BaseClient(configuration) {
3598
+ function BaseClient(configuration, performanceClient) {
3540
3599
  // Set the configuration
3541
3600
  this.config = buildClientConfiguration(configuration);
3542
3601
  // Initialize the logger
@@ -3553,6 +3612,8 @@
3553
3612
  this.serverTelemetryManager = this.config.serverTelemetryManager;
3554
3613
  // set Authority
3555
3614
  this.authority = this.config.authOptions.authority;
3615
+ // set performance telemetry client
3616
+ this.performanceClient = performanceClient;
3556
3617
  }
3557
3618
  /**
3558
3619
  * Creates default headers for requests to token endpoint
@@ -3615,7 +3676,7 @@
3615
3676
  return BaseClient;
3616
3677
  }());
3617
3678
 
3618
- /*! @azure/msal-common v7.1.0 2022-07-05 */
3679
+ /*! @azure/msal-common v7.4.0 2022-09-06 */
3619
3680
 
3620
3681
  /*
3621
3682
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3701,7 +3762,7 @@
3701
3762
  return RequestValidator;
3702
3763
  }());
3703
3764
 
3704
- /*! @azure/msal-common v7.1.0 2022-07-05 */
3765
+ /*! @azure/msal-common v7.4.0 2022-09-06 */
3705
3766
 
3706
3767
  /*
3707
3768
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4079,7 +4140,7 @@
4079
4140
  return RequestParameterBuilder;
4080
4141
  }());
4081
4142
 
4082
- /*! @azure/msal-common v7.1.0 2022-07-05 */
4143
+ /*! @azure/msal-common v7.4.0 2022-09-06 */
4083
4144
 
4084
4145
  /*
4085
4146
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4143,7 +4204,7 @@
4143
4204
  return IdTokenEntity;
4144
4205
  }(CredentialEntity));
4145
4206
 
4146
- /*! @azure/msal-common v7.1.0 2022-07-05 */
4207
+ /*! @azure/msal-common v7.4.0 2022-09-06 */
4147
4208
  /*
4148
4209
  * Copyright (c) Microsoft Corporation. All rights reserved.
4149
4210
  * Licensed under the MIT License.
@@ -4193,7 +4254,7 @@
4193
4254
  return TimeUtils;
4194
4255
  }());
4195
4256
 
4196
- /*! @azure/msal-common v7.1.0 2022-07-05 */
4257
+ /*! @azure/msal-common v7.4.0 2022-09-06 */
4197
4258
 
4198
4259
  /*
4199
4260
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4307,7 +4368,7 @@
4307
4368
  return AccessTokenEntity;
4308
4369
  }(CredentialEntity));
4309
4370
 
4310
- /*! @azure/msal-common v7.1.0 2022-07-05 */
4371
+ /*! @azure/msal-common v7.4.0 2022-09-06 */
4311
4372
 
4312
4373
  /*
4313
4374
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4374,7 +4435,7 @@
4374
4435
  return RefreshTokenEntity;
4375
4436
  }(CredentialEntity));
4376
4437
 
4377
- /*! @azure/msal-common v7.1.0 2022-07-05 */
4438
+ /*! @azure/msal-common v7.4.0 2022-09-06 */
4378
4439
 
4379
4440
  /*
4380
4441
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4449,7 +4510,7 @@
4449
4510
  return InteractionRequiredAuthError;
4450
4511
  }(AuthError));
4451
4512
 
4452
- /*! @azure/msal-common v7.1.0 2022-07-05 */
4513
+ /*! @azure/msal-common v7.4.0 2022-09-06 */
4453
4514
  /*
4454
4515
  * Copyright (c) Microsoft Corporation. All rights reserved.
4455
4516
  * Licensed under the MIT License.
@@ -4465,7 +4526,7 @@
4465
4526
  return CacheRecord;
4466
4527
  }());
4467
4528
 
4468
- /*! @azure/msal-common v7.1.0 2022-07-05 */
4529
+ /*! @azure/msal-common v7.4.0 2022-09-06 */
4469
4530
 
4470
4531
  /*
4471
4532
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4536,7 +4597,7 @@
4536
4597
  return ProtocolUtils;
4537
4598
  }());
4538
4599
 
4539
- /*! @azure/msal-common v7.1.0 2022-07-05 */
4600
+ /*! @azure/msal-common v7.4.0 2022-09-06 */
4540
4601
 
4541
4602
  /*
4542
4603
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4699,6 +4760,21 @@
4699
4760
  }
4700
4761
  return Constants.EMPTY_STRING;
4701
4762
  };
4763
+ /**
4764
+ * Parses query string from given string. Returns empty string if no query symbol is found.
4765
+ * @param queryString
4766
+ */
4767
+ UrlString.parseQueryString = function (queryString) {
4768
+ var queryIndex1 = queryString.indexOf("?");
4769
+ var queryIndex2 = queryString.indexOf("/?");
4770
+ if (queryIndex2 > -1) {
4771
+ return queryString.substring(queryIndex2 + 2);
4772
+ }
4773
+ else if (queryIndex1 > -1) {
4774
+ return queryString.substring(queryIndex1 + 1);
4775
+ }
4776
+ return Constants.EMPTY_STRING;
4777
+ };
4702
4778
  UrlString.constructAuthorityUriFromObject = function (urlObject) {
4703
4779
  return new UrlString(urlObject.Protocol + "//" + urlObject.HostNameAndPort + "/" + urlObject.PathSegments.join("/"));
4704
4780
  };
@@ -4720,6 +4796,24 @@
4720
4796
  }
4721
4797
  return deserializedHash;
4722
4798
  };
4799
+ /**
4800
+ * Returns URL query string as server auth code response object.
4801
+ */
4802
+ UrlString.getDeserializedQueryString = function (query) {
4803
+ // Check if given query is empty
4804
+ if (StringUtils.isEmpty(query)) {
4805
+ return {};
4806
+ }
4807
+ // Strip the ? symbol if present
4808
+ var parsedQueryString = UrlString.parseQueryString(query);
4809
+ // If ? symbol was not present, above will return empty string, so give original query value
4810
+ var deserializedQueryString = StringUtils.queryStringToObject(StringUtils.isEmpty(parsedQueryString) ? query : parsedQueryString);
4811
+ // Check if deserialization didn't work
4812
+ if (!deserializedQueryString) {
4813
+ throw ClientAuthError.createHashNotDeserializedError(JSON.stringify(deserializedQueryString));
4814
+ }
4815
+ return deserializedQueryString;
4816
+ };
4723
4817
  /**
4724
4818
  * Check if the hash of the URL string contains known properties
4725
4819
  */
@@ -4737,7 +4831,7 @@
4737
4831
  return UrlString;
4738
4832
  }());
4739
4833
 
4740
- /*! @azure/msal-common v7.1.0 2022-07-05 */
4834
+ /*! @azure/msal-common v7.4.0 2022-09-06 */
4741
4835
 
4742
4836
  /*
4743
4837
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4838,7 +4932,7 @@
4838
4932
  return PopTokenGenerator;
4839
4933
  }());
4840
4934
 
4841
- /*! @azure/msal-common v7.1.0 2022-07-05 */
4935
+ /*! @azure/msal-common v7.4.0 2022-09-06 */
4842
4936
 
4843
4937
  /*
4844
4938
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4908,7 +5002,7 @@
4908
5002
  return AppMetadataEntity;
4909
5003
  }());
4910
5004
 
4911
- /*! @azure/msal-common v7.1.0 2022-07-05 */
5005
+ /*! @azure/msal-common v7.4.0 2022-09-06 */
4912
5006
  /*
4913
5007
  * Copyright (c) Microsoft Corporation. All rights reserved.
4914
5008
  * Licensed under the MIT License.
@@ -4944,7 +5038,7 @@
4944
5038
  return TokenCacheContext;
4945
5039
  }());
4946
5040
 
4947
- /*! @azure/msal-common v7.1.0 2022-07-05 */
5041
+ /*! @azure/msal-common v7.4.0 2022-09-06 */
4948
5042
 
4949
5043
  /*
4950
5044
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5005,7 +5099,7 @@
5005
5099
  * @param serverTokenResponse
5006
5100
  * @param authority
5007
5101
  */
5008
- ResponseHandler.prototype.handleServerTokenResponse = function (serverTokenResponse, authority, reqTimestamp, request, authCodePayload, userAssertionHash, handlingRefreshTokenResponse) {
5102
+ ResponseHandler.prototype.handleServerTokenResponse = function (serverTokenResponse, authority, reqTimestamp, request, authCodePayload, userAssertionHash, handlingRefreshTokenResponse, forceCacheRefreshTokenResponse) {
5009
5103
  return __awaiter(this, void 0, void 0, function () {
5010
5104
  var idTokenObj, requestStateObj, cacheRecord, cacheContext, key, account;
5011
5105
  return __generator(this, function (_a) {
@@ -5042,14 +5136,15 @@
5042
5136
  /*
5043
5137
  * When saving a refreshed tokens to the cache, it is expected that the account that was used is present in the cache.
5044
5138
  * 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.
5139
+ * the calls to getAllAccounts and acquireTokenSilent. We should not overwrite that removal, unless explicitly flagged by
5140
+ * the developer, as in the case of refresh token flow used in ADAL Node to MSAL Node migration.
5046
5141
  */
5047
- if (handlingRefreshTokenResponse && cacheRecord.account) {
5142
+ if (handlingRefreshTokenResponse && !forceCacheRefreshTokenResponse && cacheRecord.account) {
5048
5143
  key = cacheRecord.account.generateAccountKey();
5049
5144
  account = this.cacheStorage.getAccount(key);
5050
5145
  if (!account) {
5051
5146
  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)];
5147
+ return [2 /*return*/, ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenObj, requestStateObj, undefined)];
5053
5148
  }
5054
5149
  }
5055
5150
  return [4 /*yield*/, this.cacheStorage.saveCacheRecord(cacheRecord)];
@@ -5214,7 +5309,7 @@
5214
5309
  return ResponseHandler;
5215
5310
  }());
5216
5311
 
5217
- /*! @azure/msal-common v7.1.0 2022-07-05 */
5312
+ /*! @azure/msal-common v7.4.0 2022-09-06 */
5218
5313
 
5219
5314
  /*
5220
5315
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5315,7 +5410,7 @@
5315
5410
  throw ClientConfigurationError.createEmptyLogoutRequestError();
5316
5411
  }
5317
5412
  var queryString = this.createLogoutUrlQueryString(logoutRequest);
5318
- // Construct logout URI.
5413
+ // Construct logout URI
5319
5414
  return UrlString.appendQueryString(this.authority.endSessionEndpoint, queryString);
5320
5415
  };
5321
5416
  /**
@@ -5502,7 +5597,7 @@
5502
5597
  */
5503
5598
  AuthorizationCodeClient.prototype.createAuthCodeUrlQueryString = function (request) {
5504
5599
  return __awaiter(this, void 0, void 0, function () {
5505
- var parameterBuilder, requestScopes, correlationId, accountSid, clientInfo, clientInfo, popTokenGenerator, reqCnfData;
5600
+ var parameterBuilder, requestScopes, correlationId, accountSid, accountLoginHintClaim, clientInfo, clientInfo, clientInfo, popTokenGenerator, reqCnfData;
5506
5601
  return __generator(this, function (_a) {
5507
5602
  switch (_a.label) {
5508
5603
  case 0:
@@ -5532,7 +5627,7 @@
5532
5627
  if (request.domainHint) {
5533
5628
  parameterBuilder.addDomainHint(request.domainHint);
5534
5629
  }
5535
- // Add sid or loginHint with preference for sid -> loginHint -> username of AccountInfo object
5630
+ // Add sid or loginHint with preference for login_hint claim (in request) -> sid -> loginHint (upn/email) -> username of AccountInfo object
5536
5631
  if (request.prompt !== PromptValue.SELECT_ACCOUNT) {
5537
5632
  // AAD will throw if prompt=select_account is passed with an account hint
5538
5633
  if (request.sid && request.prompt === PromptValue.NONE) {
@@ -5542,9 +5637,24 @@
5542
5637
  }
5543
5638
  else if (request.account) {
5544
5639
  accountSid = this.extractAccountSid(request.account);
5545
- // If account and loginHint are provided, we will check account first for sid before adding loginHint
5546
- if (accountSid && request.prompt === PromptValue.NONE) {
5547
- // SessionId is only used in silent calls
5640
+ accountLoginHintClaim = this.extractLoginHint(request.account);
5641
+ // If login_hint claim is present, use it over sid/username
5642
+ if (accountLoginHintClaim) {
5643
+ this.logger.verbose("createAuthCodeUrlQueryString: login_hint claim present on account");
5644
+ parameterBuilder.addLoginHint(accountLoginHintClaim);
5645
+ try {
5646
+ clientInfo = buildClientInfoFromHomeAccountId(request.account.homeAccountId);
5647
+ parameterBuilder.addCcsOid(clientInfo);
5648
+ }
5649
+ catch (e) {
5650
+ this.logger.verbose("createAuthCodeUrlQueryString: Could not parse home account ID for CCS Header");
5651
+ }
5652
+ }
5653
+ else if (accountSid && request.prompt === PromptValue.NONE) {
5654
+ /*
5655
+ * If account and loginHint are provided, we will check account first for sid before adding loginHint
5656
+ * SessionId is only used in silent calls
5657
+ */
5548
5658
  this.logger.verbose("createAuthCodeUrlQueryString: Prompt is none, adding sid from account");
5549
5659
  parameterBuilder.addSid(accountSid);
5550
5660
  try {
@@ -5552,7 +5662,7 @@
5552
5662
  parameterBuilder.addCcsOid(clientInfo);
5553
5663
  }
5554
5664
  catch (e) {
5555
- this.logger.verbose("Could not parse home account ID for CCS Header: " + e);
5665
+ this.logger.verbose("createAuthCodeUrlQueryString: Could not parse home account ID for CCS Header");
5556
5666
  }
5557
5667
  }
5558
5668
  else if (request.loginHint) {
@@ -5569,7 +5679,7 @@
5569
5679
  parameterBuilder.addCcsOid(clientInfo);
5570
5680
  }
5571
5681
  catch (e) {
5572
- this.logger.verbose("Could not parse home account ID for CCS Header: " + e);
5682
+ this.logger.verbose("createAuthCodeUrlQueryString: Could not parse home account ID for CCS Header");
5573
5683
  }
5574
5684
  }
5575
5685
  }
@@ -5640,16 +5750,135 @@
5640
5750
  * @param account
5641
5751
  */
5642
5752
  AuthorizationCodeClient.prototype.extractAccountSid = function (account) {
5643
- if (account.idTokenClaims) {
5644
- var tokenClaims = account.idTokenClaims;
5645
- return tokenClaims.sid || null;
5646
- }
5647
- return null;
5753
+ var _a;
5754
+ return ((_a = account.idTokenClaims) === null || _a === void 0 ? void 0 : _a.sid) || null;
5755
+ };
5756
+ AuthorizationCodeClient.prototype.extractLoginHint = function (account) {
5757
+ var _a;
5758
+ return ((_a = account.idTokenClaims) === null || _a === void 0 ? void 0 : _a.login_hint) || null;
5648
5759
  };
5649
5760
  return AuthorizationCodeClient;
5650
5761
  }(BaseClient));
5651
5762
 
5652
- /*! @azure/msal-common v7.1.0 2022-07-05 */
5763
+ /*! @azure/msal-common v7.4.0 2022-09-06 */
5764
+ /*
5765
+ * Copyright (c) Microsoft Corporation. All rights reserved.
5766
+ * Licensed under the MIT License.
5767
+ */
5768
+ /**
5769
+ * Enumeration of operations that are instrumented by have their performance measured by the PerformanceClient.
5770
+ *
5771
+ * @export
5772
+ * @enum {number}
5773
+ */
5774
+ exports.PerformanceEvents = void 0;
5775
+ (function (PerformanceEvents) {
5776
+ /**
5777
+ * acquireTokenByCode API (msal-browser and msal-node).
5778
+ * Used to acquire tokens by trading an authorization code against the token endpoint.
5779
+ */
5780
+ PerformanceEvents["AcquireTokenByCode"] = "acquireTokenByCode";
5781
+ /**
5782
+ * acquireTokenByRefreshToken API (msal-browser and msal-node).
5783
+ * Used to renew an access token using a refresh token against the token endpoint.
5784
+ */
5785
+ PerformanceEvents["AcquireTokenByRefreshToken"] = "acquireTokenByRefreshToken";
5786
+ /**
5787
+ * acquireTokenSilent API (msal-browser and msal-node).
5788
+ * Used to silently acquire a new access token (from the cache or the network).
5789
+ */
5790
+ PerformanceEvents["AcquireTokenSilent"] = "acquireTokenSilent";
5791
+ /**
5792
+ * acquireTokenSilentAsync (msal-browser).
5793
+ * Internal API for acquireTokenSilent.
5794
+ */
5795
+ PerformanceEvents["AcquireTokenSilentAsync"] = "acquireTokenSilentAsync";
5796
+ /**
5797
+ * acquireTokenPopup (msal-browser).
5798
+ * Used to acquire a new access token interactively through pop ups
5799
+ */
5800
+ PerformanceEvents["AcquireTokenPopup"] = "acquireTokenPopup";
5801
+ /**
5802
+ * getPublicKeyThumbprint API in CryptoOpts class (msal-browser).
5803
+ * Used to generate a public/private keypair and generate a public key thumbprint for pop requests.
5804
+ */
5805
+ PerformanceEvents["CryptoOptsGetPublicKeyThumbprint"] = "cryptoOptsGetPublicKeyThumbprint";
5806
+ /**
5807
+ * signJwt API in CryptoOpts class (msal-browser).
5808
+ * Used to signed a pop token.
5809
+ */
5810
+ PerformanceEvents["CryptoOptsSignJwt"] = "cryptoOptsSignJwt";
5811
+ /**
5812
+ * acquireToken API in the SilentCacheClient class (msal-browser).
5813
+ * Used to read access tokens from the cache.
5814
+ */
5815
+ PerformanceEvents["SilentCacheClientAcquireToken"] = "silentCacheClientAcquireToken";
5816
+ /**
5817
+ * acquireToken API in the SilentIframeClient class (msal-browser).
5818
+ * Used to acquire a new set of tokens from the authorize endpoint in a hidden iframe.
5819
+ */
5820
+ PerformanceEvents["SilentIframeClientAcquireToken"] = "silentIframeClientAcquireToken";
5821
+ /**
5822
+ * acquireToken API in SilentRereshClient (msal-browser).
5823
+ * Used to acquire a new set of tokens from the token endpoint using a refresh token.
5824
+ */
5825
+ PerformanceEvents["SilentRefreshClientAcquireToken"] = "silentRefreshClientAcquireToken";
5826
+ /**
5827
+ * ssoSilent API (msal-browser).
5828
+ * Used to silently acquire an authorization code and set of tokens using a hidden iframe.
5829
+ */
5830
+ PerformanceEvents["SsoSilent"] = "ssoSilent";
5831
+ /**
5832
+ * getDiscoveredAuthority API in StandardInteractionClient class (msal-browser).
5833
+ * Used to load authority metadata for a request.
5834
+ */
5835
+ PerformanceEvents["StandardInteractionClientGetDiscoveredAuthority"] = "standardInteractionClientGetDiscoveredAuthority";
5836
+ /**
5837
+ * acquireToken APIs in msal-browser.
5838
+ * Used to make an /authorize endpoint call with native brokering enabled.
5839
+ */
5840
+ PerformanceEvents["FetchAccountIdWithNativeBroker"] = "fetchAccountIdWithNativeBroker";
5841
+ /**
5842
+ * acquireToken API in NativeInteractionClient class (msal-browser).
5843
+ * Used to acquire a token from Native component when native brokering is enabled.
5844
+ */
5845
+ PerformanceEvents["NativeInteractionClientAcquireToken"] = "nativeInteractionClientAcquireToken";
5846
+ /**
5847
+ * Time spent on the network for refresh token acquisition
5848
+ */
5849
+ PerformanceEvents["RefreshTokenClientExecuteTokenRequest"] = "refreshTokenClientExecuteTokenRequest";
5850
+ /**
5851
+ * Time spent creating default headers for requests to token endpoint
5852
+ */
5853
+ PerformanceEvents["BaseClientCreateTokenRequestHeaders"] = "baseClientCreateTokenRequestHeaders";
5854
+ /**
5855
+ * Used to measure the time taken for completing embedded-broker handshake (PW-Broker).
5856
+ */
5857
+ PerformanceEvents["BrokerHandhshake"] = "brokerHandshake";
5858
+ /**
5859
+ * acquireTokenByRefreshToken API in BrokerClientApplication (PW-Broker) .
5860
+ */
5861
+ PerformanceEvents["AcquireTokenByRefreshTokenInBroker"] = "acquireTokenByRefreshTokenInBroker";
5862
+ /**
5863
+ * acquireToken API in BrokerClientApplication.
5864
+ * Used to acquire a token on behalf of the embedded application (PW-Broker).
5865
+ */
5866
+ PerformanceEvents["AcquireTokenByBroker"] = "acquireTokenByBroker";
5867
+ })(exports.PerformanceEvents || (exports.PerformanceEvents = {}));
5868
+ /**
5869
+ * State of the performance event.
5870
+ *
5871
+ * @export
5872
+ * @enum {number}
5873
+ */
5874
+ var PerformanceEventStatus;
5875
+ (function (PerformanceEventStatus) {
5876
+ PerformanceEventStatus[PerformanceEventStatus["NotStarted"] = 0] = "NotStarted";
5877
+ PerformanceEventStatus[PerformanceEventStatus["InProgress"] = 1] = "InProgress";
5878
+ PerformanceEventStatus[PerformanceEventStatus["Completed"] = 2] = "Completed";
5879
+ })(PerformanceEventStatus || (PerformanceEventStatus = {}));
5880
+
5881
+ /*! @azure/msal-common v7.4.0 2022-09-06 */
5653
5882
 
5654
5883
  /*
5655
5884
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5660,8 +5889,8 @@
5660
5889
  */
5661
5890
  var RefreshTokenClient = /** @class */ (function (_super) {
5662
5891
  __extends(RefreshTokenClient, _super);
5663
- function RefreshTokenClient(configuration) {
5664
- return _super.call(this, configuration) || this;
5892
+ function RefreshTokenClient(configuration, performanceClient) {
5893
+ return _super.call(this, configuration, performanceClient) || this;
5665
5894
  }
5666
5895
  RefreshTokenClient.prototype.acquireToken = function (request) {
5667
5896
  return __awaiter(this, void 0, void 0, function () {
@@ -5675,7 +5904,7 @@
5675
5904
  response = _a.sent();
5676
5905
  responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, this.config.serializableCache, this.config.persistencePlugin);
5677
5906
  responseHandler.validateTokenResponse(response.body);
5678
- return [2 /*return*/, responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request, undefined, undefined, true)];
5907
+ return [2 /*return*/, responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request, undefined, undefined, true, request.forceCache)];
5679
5908
  }
5680
5909
  });
5681
5910
  });
@@ -5747,13 +5976,16 @@
5747
5976
  * @param authority
5748
5977
  */
5749
5978
  RefreshTokenClient.prototype.executeTokenRequest = function (request, authority) {
5979
+ var _a;
5750
5980
  return __awaiter(this, void 0, void 0, function () {
5751
- var requestBody, queryParameters, headers, thumbprint, endpoint;
5752
- return __generator(this, function (_a) {
5753
- switch (_a.label) {
5754
- case 0: return [4 /*yield*/, this.createTokenRequestBody(request)];
5981
+ var acquireTokenMeasurement, requestBody, queryParameters, headers, thumbprint, endpoint;
5982
+ return __generator(this, function (_b) {
5983
+ switch (_b.label) {
5984
+ case 0:
5985
+ acquireTokenMeasurement = (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.startMeasurement(exports.PerformanceEvents.RefreshTokenClientExecuteTokenRequest, request.correlationId);
5986
+ return [4 /*yield*/, this.createTokenRequestBody(request)];
5755
5987
  case 1:
5756
- requestBody = _a.sent();
5988
+ requestBody = _b.sent();
5757
5989
  queryParameters = this.createTokenQueryParameters(request);
5758
5990
  headers = this.createTokenRequestHeaders(request.ccsCredential);
5759
5991
  thumbprint = {
@@ -5768,7 +6000,19 @@
5768
6000
  sshKid: request.sshKid
5769
6001
  };
5770
6002
  endpoint = UrlString.appendQueryString(authority.tokenEndpoint, queryParameters);
5771
- return [2 /*return*/, this.executePostToTokenEndpoint(endpoint, requestBody, headers, thumbprint)];
6003
+ return [2 /*return*/, this.executePostToTokenEndpoint(endpoint, requestBody, headers, thumbprint)
6004
+ .then(function (result) {
6005
+ acquireTokenMeasurement === null || acquireTokenMeasurement === void 0 ? void 0 : acquireTokenMeasurement.endMeasurement({
6006
+ success: true
6007
+ });
6008
+ return result;
6009
+ })
6010
+ .catch(function (error) {
6011
+ acquireTokenMeasurement === null || acquireTokenMeasurement === void 0 ? void 0 : acquireTokenMeasurement.endMeasurement({
6012
+ success: false
6013
+ });
6014
+ throw error;
6015
+ })];
5772
6016
  }
5773
6017
  });
5774
6018
  });
@@ -5789,11 +6033,14 @@
5789
6033
  * @param request
5790
6034
  */
5791
6035
  RefreshTokenClient.prototype.createTokenRequestBody = function (request) {
6036
+ var _a;
5792
6037
  return __awaiter(this, void 0, void 0, function () {
5793
- var parameterBuilder, correlationId, clientAssertion, popTokenGenerator, reqCnfData, clientInfo;
5794
- return __generator(this, function (_a) {
5795
- switch (_a.label) {
6038
+ var correlationId, acquireTokenMeasurement, parameterBuilder, clientAssertion, popTokenGenerator, reqCnfData, clientInfo;
6039
+ return __generator(this, function (_b) {
6040
+ switch (_b.label) {
5796
6041
  case 0:
6042
+ correlationId = request.correlationId;
6043
+ acquireTokenMeasurement = (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.startMeasurement(exports.PerformanceEvents.BaseClientCreateTokenRequestHeaders, correlationId);
5797
6044
  parameterBuilder = new RequestParameterBuilder();
5798
6045
  parameterBuilder.addClientId(this.config.authOptions.clientId);
5799
6046
  parameterBuilder.addScopes(request.scopes);
@@ -5805,7 +6052,6 @@
5805
6052
  if (this.serverTelemetryManager) {
5806
6053
  parameterBuilder.addServerTelemetry(this.serverTelemetryManager);
5807
6054
  }
5808
- correlationId = request.correlationId || this.config.cryptoInterface.createNewGuid();
5809
6055
  parameterBuilder.addCorrelationId(correlationId);
5810
6056
  parameterBuilder.addRefreshToken(request.refreshToken);
5811
6057
  if (this.config.clientCredentials.clientSecret) {
@@ -5820,7 +6066,7 @@
5820
6066
  popTokenGenerator = new PopTokenGenerator(this.cryptoUtils);
5821
6067
  return [4 /*yield*/, popTokenGenerator.generateCnf(request)];
5822
6068
  case 1:
5823
- reqCnfData = _a.sent();
6069
+ reqCnfData = _b.sent();
5824
6070
  // SPA PoP requires full Base64Url encoded req_cnf string (unhashed)
5825
6071
  parameterBuilder.addPopToken(reqCnfData.reqCnfString);
5826
6072
  return [3 /*break*/, 3];
@@ -5830,10 +6076,13 @@
5830
6076
  parameterBuilder.addSshJwk(request.sshJwk);
5831
6077
  }
5832
6078
  else {
6079
+ acquireTokenMeasurement === null || acquireTokenMeasurement === void 0 ? void 0 : acquireTokenMeasurement.endMeasurement({
6080
+ success: false
6081
+ });
5833
6082
  throw ClientConfigurationError.createMissingSshJwkError();
5834
6083
  }
5835
6084
  }
5836
- _a.label = 3;
6085
+ _b.label = 3;
5837
6086
  case 3:
5838
6087
  if (!StringUtils.isEmptyObj(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {
5839
6088
  parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);
@@ -5854,6 +6103,9 @@
5854
6103
  break;
5855
6104
  }
5856
6105
  }
6106
+ acquireTokenMeasurement === null || acquireTokenMeasurement === void 0 ? void 0 : acquireTokenMeasurement.endMeasurement({
6107
+ success: true
6108
+ });
5857
6109
  return [2 /*return*/, parameterBuilder.createQueryString()];
5858
6110
  }
5859
6111
  });
@@ -5862,7 +6114,7 @@
5862
6114
  return RefreshTokenClient;
5863
6115
  }(BaseClient));
5864
6116
 
5865
- /*! @azure/msal-common v7.1.0 2022-07-05 */
6117
+ /*! @azure/msal-common v7.4.0 2022-09-06 */
5866
6118
 
5867
6119
  /*
5868
6120
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5870,8 +6122,8 @@
5870
6122
  */
5871
6123
  var SilentFlowClient = /** @class */ (function (_super) {
5872
6124
  __extends(SilentFlowClient, _super);
5873
- function SilentFlowClient(configuration) {
5874
- return _super.call(this, configuration) || this;
6125
+ function SilentFlowClient(configuration, performanceClient) {
6126
+ return _super.call(this, configuration, performanceClient) || this;
5875
6127
  }
5876
6128
  /**
5877
6129
  * Retrieves a token from cache if it is still valid, or uses the cached refresh token to renew
@@ -5890,7 +6142,7 @@
5890
6142
  case 2:
5891
6143
  e_1 = _a.sent();
5892
6144
  if (e_1 instanceof ClientAuthError && e_1.errorCode === ClientAuthErrorMessage.tokenRefreshRequired.code) {
5893
- refreshTokenClient = new RefreshTokenClient(this.config);
6145
+ refreshTokenClient = new RefreshTokenClient(this.config, this.performanceClient);
5894
6146
  return [2 /*return*/, refreshTokenClient.acquireTokenByRefreshToken(request)];
5895
6147
  }
5896
6148
  else {
@@ -5978,7 +6230,7 @@
5978
6230
  return SilentFlowClient;
5979
6231
  }(BaseClient));
5980
6232
 
5981
- /*! @azure/msal-common v7.1.0 2022-07-05 */
6233
+ /*! @azure/msal-common v7.4.0 2022-09-06 */
5982
6234
  /*
5983
6235
  * Copyright (c) Microsoft Corporation. All rights reserved.
5984
6236
  * Licensed under the MIT License.
@@ -5990,7 +6242,7 @@
5990
6242
  response.hasOwnProperty("jwks_uri"));
5991
6243
  }
5992
6244
 
5993
- /*! @azure/msal-common v7.1.0 2022-07-05 */
6245
+ /*! @azure/msal-common v7.4.0 2022-09-06 */
5994
6246
  /*
5995
6247
  * Copyright (c) Microsoft Corporation. All rights reserved.
5996
6248
  * Licensed under the MIT License.
@@ -5999,7 +6251,7 @@
5999
6251
  var EndpointMetadata = rawMetdataJSON.endpointMetadata;
6000
6252
  var InstanceDiscoveryMetadata = rawMetdataJSON.instanceDiscoveryMetadata;
6001
6253
 
6002
- /*! @azure/msal-common v7.1.0 2022-07-05 */
6254
+ /*! @azure/msal-common v7.4.0 2022-09-06 */
6003
6255
  /*
6004
6256
  * Copyright (c) Microsoft Corporation. All rights reserved.
6005
6257
  * Licensed under the MIT License.
@@ -6013,7 +6265,7 @@
6013
6265
  ProtocolMode["OIDC"] = "OIDC";
6014
6266
  })(exports.ProtocolMode || (exports.ProtocolMode = {}));
6015
6267
 
6016
- /*! @azure/msal-common v7.1.0 2022-07-05 */
6268
+ /*! @azure/msal-common v7.4.0 2022-09-06 */
6017
6269
 
6018
6270
  /*
6019
6271
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6090,7 +6342,7 @@
6090
6342
  return AuthorityMetadataEntity;
6091
6343
  }());
6092
6344
 
6093
- /*! @azure/msal-common v7.1.0 2022-07-05 */
6345
+ /*! @azure/msal-common v7.4.0 2022-09-06 */
6094
6346
  /*
6095
6347
  * Copyright (c) Microsoft Corporation. All rights reserved.
6096
6348
  * Licensed under the MIT License.
@@ -6100,7 +6352,7 @@
6100
6352
  response.hasOwnProperty("metadata"));
6101
6353
  }
6102
6354
 
6103
- /*! @azure/msal-common v7.1.0 2022-07-05 */
6355
+ /*! @azure/msal-common v7.4.0 2022-09-06 */
6104
6356
 
6105
6357
  /*
6106
6358
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6222,7 +6474,7 @@
6222
6474
  return RegionDiscovery;
6223
6475
  }());
6224
6476
 
6225
- /*! @azure/msal-common v7.1.0 2022-07-05 */
6477
+ /*! @azure/msal-common v7.4.0 2022-09-06 */
6226
6478
 
6227
6479
  /*
6228
6480
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6884,7 +7136,7 @@
6884
7136
  return Authority;
6885
7137
  }());
6886
7138
 
6887
- /*! @azure/msal-common v7.1.0 2022-07-05 */
7139
+ /*! @azure/msal-common v7.4.0 2022-09-06 */
6888
7140
 
6889
7141
  /*
6890
7142
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6945,7 +7197,7 @@
6945
7197
  return AuthorityFactory;
6946
7198
  }());
6947
7199
 
6948
- /*! @azure/msal-common v7.1.0 2022-07-05 */
7200
+ /*! @azure/msal-common v7.4.0 2022-09-06 */
6949
7201
 
6950
7202
  /*
6951
7203
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6976,7 +7228,7 @@
6976
7228
  return ServerTelemetryEntity;
6977
7229
  }());
6978
7230
 
6979
- /*! @azure/msal-common v7.1.0 2022-07-05 */
7231
+ /*! @azure/msal-common v7.4.0 2022-09-06 */
6980
7232
 
6981
7233
  /*
6982
7234
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7004,7 +7256,7 @@
7004
7256
  return ThrottlingEntity;
7005
7257
  }());
7006
7258
 
7007
- /*! @azure/msal-common v7.1.0 2022-07-05 */
7259
+ /*! @azure/msal-common v7.4.0 2022-09-06 */
7008
7260
 
7009
7261
  /*
7010
7262
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7021,7 +7273,7 @@
7021
7273
  }
7022
7274
  };
7023
7275
 
7024
- /*! @azure/msal-common v7.1.0 2022-07-05 */
7276
+ /*! @azure/msal-common v7.4.0 2022-09-06 */
7025
7277
 
7026
7278
  /*
7027
7279
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7066,7 +7318,7 @@
7066
7318
  return JoseHeaderError;
7067
7319
  }(AuthError));
7068
7320
 
7069
- /*! @azure/msal-common v7.1.0 2022-07-05 */
7321
+ /*! @azure/msal-common v7.4.0 2022-09-06 */
7070
7322
 
7071
7323
  /*
7072
7324
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7106,7 +7358,7 @@
7106
7358
  return JoseHeader;
7107
7359
  }());
7108
7360
 
7109
- /*! @azure/msal-common v7.1.0 2022-07-05 */
7361
+ /*! @azure/msal-common v7.4.0 2022-09-06 */
7110
7362
 
7111
7363
  /*
7112
7364
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7165,7 +7417,7 @@
7165
7417
  return AuthenticationHeaderParser;
7166
7418
  }());
7167
7419
 
7168
- /*! @azure/msal-common v7.1.0 2022-07-05 */
7420
+ /*! @azure/msal-common v7.4.0 2022-09-06 */
7169
7421
 
7170
7422
  /*
7171
7423
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7327,138 +7579,41 @@
7327
7579
  return ServerTelemetryManager;
7328
7580
  }());
7329
7581
 
7330
- /*! @azure/msal-common v7.1.0 2022-07-05 */
7582
+ /*! @azure/msal-common v7.4.0 2022-09-06 */
7583
+
7331
7584
  /*
7332
7585
  * Copyright (c) Microsoft Corporation. All rights reserved.
7333
7586
  * Licensed under the MIT License.
7334
7587
  */
7335
- /**
7336
- * Enumeration of operations that are instrumented by have their performance measured by the PerformanceClient.
7337
- *
7338
- * @export
7339
- * @enum {number}
7340
- */
7341
- exports.PerformanceEvents = void 0;
7342
- (function (PerformanceEvents) {
7343
- /**
7344
- * acquireTokenByCode API (msal-browser and msal-node).
7345
- * Used to acquire tokens by trading an authorization code against the token endpoint.
7346
- */
7347
- PerformanceEvents["AcquireTokenByCode"] = "acquireTokenByCode";
7348
- /**
7349
- * acquireTokenByRefreshToken API (msal-browser and msal-node).
7350
- * Used to renew an access token using a refresh token against the token endpoint.
7351
- */
7352
- PerformanceEvents["AcquireTokenByRefreshToken"] = "acquireTokenByRefreshToken";
7353
- /**
7354
- * acquireTokenSilent API (msal-browser and msal-node).
7355
- * Used to silently acquire a new access token (from the cache or the network).
7356
- */
7357
- PerformanceEvents["AcquireTokenSilent"] = "acquireTokenSilent";
7358
- /**
7359
- * acquireTokenSilentAsync (msal-browser).
7360
- * Internal API for acquireTokenSilent.
7361
- */
7362
- PerformanceEvents["AcquireTokenSilentAsync"] = "acquireTokenSilentAsync";
7588
+ var PerformanceClient = /** @class */ (function () {
7363
7589
  /**
7364
- * acquireTokenPopup (msal-browser).
7365
- * Used to acquire a new access token interactively through pop ups
7590
+ * Creates an instance of PerformanceClient,
7591
+ * an abstract class containing core performance telemetry logic.
7592
+ *
7593
+ * @constructor
7594
+ * @param {string} clientId Client ID of the application
7595
+ * @param {string} authority Authority used by the application
7596
+ * @param {Logger} logger Logger used by the application
7597
+ * @param {string} libraryName Name of the library
7598
+ * @param {string} libraryVersion Version of the library
7366
7599
  */
7367
- PerformanceEvents["AcquireTokenPopup"] = "acquireTokenPopup";
7600
+ function PerformanceClient(clientId, authority, logger, libraryName, libraryVersion, applicationTelemetry) {
7601
+ this.authority = authority;
7602
+ this.libraryName = libraryName;
7603
+ this.libraryVersion = libraryVersion;
7604
+ this.applicationTelemetry = applicationTelemetry;
7605
+ this.clientId = clientId;
7606
+ this.logger = logger;
7607
+ this.callbacks = new Map();
7608
+ this.eventsByCorrelationId = new Map();
7609
+ this.measurementsById = new Map();
7610
+ }
7368
7611
  /**
7369
- * getPublicKeyThumbprint API in CryptoOpts class (msal-browser).
7370
- * Used to generate a public/private keypair and generate a public key thumbprint for pop requests.
7371
- */
7372
- PerformanceEvents["CryptoOptsGetPublicKeyThumbprint"] = "cryptoOptsGetPublicKeyThumbprint";
7373
- /**
7374
- * signJwt API in CryptoOpts class (msal-browser).
7375
- * Used to signed a pop token.
7376
- */
7377
- PerformanceEvents["CryptoOptsSignJwt"] = "cryptoOptsSignJwt";
7378
- /**
7379
- * acquireToken API in the SilentCacheClient class (msal-browser).
7380
- * Used to read access tokens from the cache.
7381
- */
7382
- PerformanceEvents["SilentCacheClientAcquireToken"] = "silentCacheClientAcquireToken";
7383
- /**
7384
- * acquireToken API in the SilentIframeClient class (msal-browser).
7385
- * Used to acquire a new set of tokens from the authorize endpoint in a hidden iframe.
7386
- */
7387
- PerformanceEvents["SilentIframeClientAcquireToken"] = "silentIframeClientAcquireToken";
7388
- /**
7389
- * acquireToken API in SilentRereshClient (msal-browser).
7390
- * Used to acquire a new set of tokens from the token endpoint using a refresh token.
7391
- */
7392
- PerformanceEvents["SilentRefreshClientAcquireToken"] = "silentRefreshClientAcquireToken";
7393
- /**
7394
- * ssoSilent API (msal-browser).
7395
- * Used to silently acquire an authorization code and set of tokens using a hidden iframe.
7396
- */
7397
- PerformanceEvents["SsoSilent"] = "ssoSilent";
7398
- /**
7399
- * getDiscoveredAuthority API in StandardInteractionClient class (msal-browser).
7400
- * Used to load authority metadata for a request.
7401
- */
7402
- PerformanceEvents["StandardInteractionClientGetDiscoveredAuthority"] = "standardInteractionClientGetDiscoveredAuthority";
7403
- /**
7404
- * acquireToken APIs in msal-browser.
7405
- * Used to make an /authorize endpoint call with native brokering enabled.
7406
- */
7407
- PerformanceEvents["FetchAccountIdWithNativeBroker"] = "fetchAccountIdWithNativeBroker";
7408
- /**
7409
- * acquireToken API in NativeInteractionClient class (msal-browser).
7410
- * Used to acquire a token from Native component when native brokering is enabled.
7411
- */
7412
- PerformanceEvents["NativeInteractionClientAcquireToken"] = "nativeInteractionClientAcquireToken";
7413
- })(exports.PerformanceEvents || (exports.PerformanceEvents = {}));
7414
- /**
7415
- * State of the performance event.
7416
- *
7417
- * @export
7418
- * @enum {number}
7419
- */
7420
- var PerformanceEventStatus;
7421
- (function (PerformanceEventStatus) {
7422
- PerformanceEventStatus[PerformanceEventStatus["NotStarted"] = 0] = "NotStarted";
7423
- PerformanceEventStatus[PerformanceEventStatus["InProgress"] = 1] = "InProgress";
7424
- PerformanceEventStatus[PerformanceEventStatus["Completed"] = 2] = "Completed";
7425
- })(PerformanceEventStatus || (PerformanceEventStatus = {}));
7426
-
7427
- /*! @azure/msal-common v7.1.0 2022-07-05 */
7428
-
7429
- /*
7430
- * Copyright (c) Microsoft Corporation. All rights reserved.
7431
- * Licensed under the MIT License.
7432
- */
7433
- var PerformanceClient = /** @class */ (function () {
7434
- /**
7435
- * Creates an instance of PerformanceClient,
7436
- * an abstract class containing core performance telemetry logic.
7437
- *
7438
- * @constructor
7439
- * @param {string} clientId Client ID of the application
7440
- * @param {string} authority Authority used by the application
7441
- * @param {Logger} logger Logger used by the application
7442
- * @param {string} libraryName Name of the library
7443
- * @param {string} libraryVersion Version of the library
7444
- */
7445
- function PerformanceClient(clientId, authority, logger, libraryName, libraryVersion, applicationTelemetry) {
7446
- this.authority = authority;
7447
- this.libraryName = libraryName;
7448
- this.libraryVersion = libraryVersion;
7449
- this.applicationTelemetry = applicationTelemetry;
7450
- this.clientId = clientId;
7451
- this.logger = logger;
7452
- this.callbacks = new Map();
7453
- this.eventsByCorrelationId = new Map();
7454
- this.measurementsById = new Map();
7455
- }
7456
- /**
7457
- * Starts measuring performance for a given operation. Returns a function that should be used to end the measurement.
7458
- *
7459
- * @param {PerformanceEvents} measureName
7460
- * @param {?string} [correlationId]
7461
- * @returns {InProgressPerformanceEvent}
7612
+ * Starts measuring performance for a given operation. Returns a function that should be used to end the measurement.
7613
+ *
7614
+ * @param {PerformanceEvents} measureName
7615
+ * @param {?string} [correlationId]
7616
+ * @returns {InProgressPerformanceEvent}
7462
7617
  */
7463
7618
  PerformanceClient.prototype.startMeasurement = function (measureName, correlationId) {
7464
7619
  var _this = this;
@@ -7482,7 +7637,7 @@
7482
7637
  clientId: this.clientId,
7483
7638
  name: measureName,
7484
7639
  startTimeMs: Date.now(),
7485
- correlationId: eventCorrelationId
7640
+ correlationId: eventCorrelationId,
7486
7641
  };
7487
7642
  // Store in progress events so they can be discarded if not ended properly
7488
7643
  this.cacheEventByCorrelationId(inProgressEvent);
@@ -7627,6 +7782,12 @@
7627
7782
  else {
7628
7783
  _this.logger.verbose("PerformanceClient: Submeasurement for " + measureName + " already exists for " + current.name + ", ignoring", correlationId);
7629
7784
  }
7785
+ if (current.accessTokenSize) {
7786
+ previous.accessTokenSize = current.accessTokenSize;
7787
+ }
7788
+ if (current.idTokenSize) {
7789
+ previous.idTokenSize = current.idTokenSize;
7790
+ }
7630
7791
  }
7631
7792
  return previous;
7632
7793
  }, topLevelEvent);
@@ -7694,7 +7855,7 @@
7694
7855
  return PerformanceClient;
7695
7856
  }());
7696
7857
 
7697
- /*! @azure/msal-common v7.1.0 2022-07-05 */
7858
+ /*! @azure/msal-common v7.4.0 2022-09-06 */
7698
7859
 
7699
7860
  /*
7700
7861
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8914,26 +9075,57 @@
8914
9075
  * Gets the active account
8915
9076
  */
8916
9077
  BrowserCacheManager.prototype.getActiveAccount = function () {
8917
- var activeAccountIdKey = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT);
8918
- var activeAccountId = this.browserStorage.getItem(activeAccountIdKey);
8919
- if (!activeAccountId) {
9078
+ var activeAccountKeyFilters = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT_FILTERS);
9079
+ var activeAccountValueFilters = this.getItem(activeAccountKeyFilters);
9080
+ if (!activeAccountValueFilters) {
9081
+ // if new active account cache type isn't found, it's an old version, so look for that instead
9082
+ this.logger.trace("No active account filters cache schema found, looking for legacy schema");
9083
+ var activeAccountKeyLocal = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT);
9084
+ var activeAccountValueLocal = this.getItem(activeAccountKeyLocal);
9085
+ if (!activeAccountValueLocal) {
9086
+ this.logger.trace("No active account found");
9087
+ return null;
9088
+ }
9089
+ var activeAccount = this.getAccountInfoByFilter({ localAccountId: activeAccountValueLocal })[0] || null;
9090
+ if (activeAccount) {
9091
+ this.logger.trace("Legacy active account cache schema found");
9092
+ this.logger.trace("Adding active account filters cache schema");
9093
+ this.setActiveAccount(activeAccount);
9094
+ return activeAccount;
9095
+ }
8920
9096
  return null;
8921
9097
  }
8922
- return this.getAccountInfoByFilter({ localAccountId: activeAccountId })[0] || null;
9098
+ var activeAccountValueObj = this.validateAndParseJson(activeAccountValueFilters);
9099
+ if (activeAccountValueObj) {
9100
+ this.logger.trace("Active account filters schema found");
9101
+ return this.getAccountInfoByFilter({
9102
+ homeAccountId: activeAccountValueObj.homeAccountId,
9103
+ localAccountId: activeAccountValueObj.localAccountId
9104
+ })[0] || null;
9105
+ }
9106
+ this.logger.trace("No active account found");
9107
+ return null;
8923
9108
  };
8924
9109
  /**
8925
9110
  * Sets the active account's localAccountId in cache
8926
9111
  * @param account
8927
9112
  */
8928
9113
  BrowserCacheManager.prototype.setActiveAccount = function (account) {
8929
- var activeAccountIdKey = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT);
9114
+ var activeAccountKey = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT_FILTERS);
9115
+ var activeAccountKeyLocal = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT);
8930
9116
  if (account) {
8931
9117
  this.logger.verbose("setActiveAccount: Active account set");
8932
- this.browserStorage.setItem(activeAccountIdKey, account.localAccountId);
9118
+ var activeAccountValue = {
9119
+ homeAccountId: account.homeAccountId,
9120
+ localAccountId: account.localAccountId
9121
+ };
9122
+ this.browserStorage.setItem(activeAccountKey, JSON.stringify(activeAccountValue));
9123
+ this.browserStorage.setItem(activeAccountKeyLocal, account.localAccountId);
8933
9124
  }
8934
9125
  else {
8935
9126
  this.logger.verbose("setActiveAccount: No account passed, active account not set");
8936
- this.browserStorage.removeItem(activeAccountIdKey);
9127
+ this.browserStorage.removeItem(activeAccountKey);
9128
+ this.browserStorage.removeItem(activeAccountKeyLocal);
8937
9129
  }
8938
9130
  };
8939
9131
  /**
@@ -9491,7 +9683,7 @@
9491
9683
 
9492
9684
  /* eslint-disable header/header */
9493
9685
  var name = "@azure/msal-browser";
9494
- var version = "2.27.0";
9686
+ var version = "2.28.2";
9495
9687
 
9496
9688
  /*
9497
9689
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -10040,8 +10232,7 @@
10040
10232
  protocolMode: this.config.auth.protocolMode,
10041
10233
  knownAuthorities: this.config.auth.knownAuthorities,
10042
10234
  cloudDiscoveryMetadata: this.config.auth.cloudDiscoveryMetadata,
10043
- authorityMetadata: this.config.auth.authorityMetadata,
10044
- skipAuthorityMetadataCache: this.config.auth.skipAuthorityMetadataCache,
10235
+ authorityMetadata: this.config.auth.authorityMetadata
10045
10236
  };
10046
10237
  if (!requestAuthority) return [3 /*break*/, 2];
10047
10238
  this.logger.verbose("Creating discovered authority with request authority");
@@ -10673,6 +10864,10 @@
10673
10864
  userSwitch: {
10674
10865
  code: "user_switch",
10675
10866
  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."
10867
+ },
10868
+ tokensNotFoundInCache: {
10869
+ code: "tokens_not_found_in_internal_memory_cache",
10870
+ desc: "Tokens not cached in MSAL JS internal memory, please make the WAM request"
10676
10871
  }
10677
10872
  };
10678
10873
  var NativeAuthError = /** @class */ (function (_super) {
@@ -10727,20 +10922,122 @@
10727
10922
  NativeAuthError.createUserSwitchError = function () {
10728
10923
  return new NativeAuthError(NativeAuthErrorMessage.userSwitch.code, NativeAuthErrorMessage.userSwitch.desc);
10729
10924
  };
10925
+ /**
10926
+ * Creates a tokens not found error when the internal cache look up fails
10927
+ * @returns NativeAuthError: tokensNotFoundInCache
10928
+ */
10929
+ NativeAuthError.createTokensNotFoundInCacheError = function () {
10930
+ return new NativeAuthError(NativeAuthErrorMessage.tokensNotFoundInCache.code, NativeAuthErrorMessage.tokensNotFoundInCache.desc);
10931
+ };
10730
10932
  return NativeAuthError;
10731
10933
  }(AuthError));
10732
10934
 
10935
+ /*
10936
+ * Copyright (c) Microsoft Corporation. All rights reserved.
10937
+ * Licensed under the MIT License.
10938
+ */
10939
+ var SilentCacheClient = /** @class */ (function (_super) {
10940
+ __extends$1(SilentCacheClient, _super);
10941
+ function SilentCacheClient() {
10942
+ return _super !== null && _super.apply(this, arguments) || this;
10943
+ }
10944
+ /**
10945
+ * Returns unexpired tokens from the cache, if available
10946
+ * @param silentRequest
10947
+ */
10948
+ SilentCacheClient.prototype.acquireToken = function (silentRequest) {
10949
+ return __awaiter$1(this, void 0, void 0, function () {
10950
+ var acquireTokenMeasurement, serverTelemetryManager, silentAuthClient, cachedToken, error_1;
10951
+ return __generator$1(this, function (_a) {
10952
+ switch (_a.label) {
10953
+ case 0:
10954
+ acquireTokenMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.SilentCacheClientAcquireToken, silentRequest.correlationId);
10955
+ serverTelemetryManager = this.initializeServerTelemetryManager(exports.ApiId.acquireTokenSilent_silentFlow);
10956
+ return [4 /*yield*/, this.createSilentFlowClient(serverTelemetryManager, silentRequest.authority, silentRequest.azureCloudOptions)];
10957
+ case 1:
10958
+ silentAuthClient = _a.sent();
10959
+ this.logger.verbose("Silent auth client created");
10960
+ _a.label = 2;
10961
+ case 2:
10962
+ _a.trys.push([2, 4, , 5]);
10963
+ return [4 /*yield*/, silentAuthClient.acquireCachedToken(silentRequest)];
10964
+ case 3:
10965
+ cachedToken = _a.sent();
10966
+ acquireTokenMeasurement.endMeasurement({
10967
+ success: true,
10968
+ fromCache: true
10969
+ });
10970
+ return [2 /*return*/, cachedToken];
10971
+ case 4:
10972
+ error_1 = _a.sent();
10973
+ if (error_1 instanceof BrowserAuthError && error_1.errorCode === BrowserAuthErrorMessage.signingKeyNotFoundInStorage.code) {
10974
+ this.logger.verbose("Signing keypair for bound access token not found. Refreshing bound access token and generating a new crypto keypair.");
10975
+ }
10976
+ acquireTokenMeasurement.endMeasurement({
10977
+ errorCode: error_1 instanceof AuthError && error_1.errorCode || undefined,
10978
+ subErrorCode: error_1 instanceof AuthError && error_1.subError || undefined,
10979
+ success: false
10980
+ });
10981
+ throw error_1;
10982
+ case 5: return [2 /*return*/];
10983
+ }
10984
+ });
10985
+ });
10986
+ };
10987
+ /**
10988
+ * Currently Unsupported
10989
+ */
10990
+ SilentCacheClient.prototype.logout = function () {
10991
+ // Synchronous so we must reject
10992
+ return Promise.reject(BrowserAuthError.createSilentLogoutUnsupportedError());
10993
+ };
10994
+ /**
10995
+ * Creates an Silent Flow Client with the given authority, or the default authority.
10996
+ * @param serverTelemetryManager
10997
+ * @param authorityUrl
10998
+ */
10999
+ SilentCacheClient.prototype.createSilentFlowClient = function (serverTelemetryManager, authorityUrl, azureCloudOptions) {
11000
+ return __awaiter$1(this, void 0, void 0, function () {
11001
+ var clientConfig;
11002
+ return __generator$1(this, function (_a) {
11003
+ switch (_a.label) {
11004
+ case 0: return [4 /*yield*/, this.getClientConfiguration(serverTelemetryManager, authorityUrl, azureCloudOptions)];
11005
+ case 1:
11006
+ clientConfig = _a.sent();
11007
+ return [2 /*return*/, new SilentFlowClient(clientConfig, this.performanceClient)];
11008
+ }
11009
+ });
11010
+ });
11011
+ };
11012
+ SilentCacheClient.prototype.initializeSilentRequest = function (request, account) {
11013
+ return __awaiter$1(this, void 0, void 0, function () {
11014
+ var _a;
11015
+ return __generator$1(this, function (_b) {
11016
+ switch (_b.label) {
11017
+ case 0:
11018
+ _a = [__assign$1({}, request)];
11019
+ return [4 /*yield*/, this.initializeBaseRequest(request)];
11020
+ 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 }])];
11021
+ }
11022
+ });
11023
+ });
11024
+ };
11025
+ return SilentCacheClient;
11026
+ }(StandardInteractionClient));
11027
+
10733
11028
  /*
10734
11029
  * Copyright (c) Microsoft Corporation. All rights reserved.
10735
11030
  * Licensed under the MIT License.
10736
11031
  */
10737
11032
  var NativeInteractionClient = /** @class */ (function (_super) {
10738
11033
  __extends$1(NativeInteractionClient, _super);
10739
- function NativeInteractionClient(config, browserStorage, browserCrypto, logger, eventHandler, navigationClient, apiId, performanceClient, provider, accountId, correlationId) {
11034
+ function NativeInteractionClient(config, browserStorage, browserCrypto, logger, eventHandler, navigationClient, apiId, performanceClient, provider, accountId, nativeStorageImpl, correlationId) {
10740
11035
  var _this = _super.call(this, config, browserStorage, browserCrypto, logger, eventHandler, navigationClient, performanceClient, provider, correlationId) || this;
10741
11036
  _this.apiId = apiId;
10742
11037
  _this.accountId = accountId;
10743
11038
  _this.nativeMessageHandler = provider;
11039
+ _this.nativeStorageManager = nativeStorageImpl;
11040
+ _this.silentCacheClient = new SilentCacheClient(config, _this.nativeStorageManager, browserCrypto, logger, eventHandler, navigationClient, performanceClient, provider, correlationId);
10744
11041
  return _this;
10745
11042
  }
10746
11043
  /**
@@ -10749,22 +11046,40 @@
10749
11046
  */
10750
11047
  NativeInteractionClient.prototype.acquireToken = function (request) {
10751
11048
  return __awaiter$1(this, void 0, void 0, function () {
10752
- var nativeATMeasurement, nativeRequest, messageBody, reqTimestamp, response, validatedResponse;
11049
+ var nativeATMeasurement, reqTimestamp, nativeRequest, result, messageBody, response, validatedResponse;
10753
11050
  return __generator$1(this, function (_a) {
10754
11051
  switch (_a.label) {
10755
11052
  case 0:
10756
11053
  this.logger.trace("NativeInteractionClient - acquireToken called.");
10757
11054
  nativeATMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.NativeInteractionClientAcquireToken, request.correlationId);
11055
+ reqTimestamp = TimeUtils.nowSeconds();
10758
11056
  return [4 /*yield*/, this.initializeNativeRequest(request)];
10759
11057
  case 1:
10760
11058
  nativeRequest = _a.sent();
11059
+ _a.label = 2;
11060
+ case 2:
11061
+ _a.trys.push([2, 4, , 5]);
11062
+ return [4 /*yield*/, this.acquireTokensFromCache(this.accountId, nativeRequest)];
11063
+ case 3:
11064
+ result = _a.sent();
11065
+ nativeATMeasurement.endMeasurement({
11066
+ success: true,
11067
+ isNativeBroker: true,
11068
+ fromCache: true
11069
+ });
11070
+ return [2 /*return*/, result];
11071
+ case 4:
11072
+ _a.sent();
11073
+ // continue with a native call for any and all errors
11074
+ this.logger.info("MSAL internal Cache does not contain tokens, proceed to make a native call");
11075
+ return [3 /*break*/, 5];
11076
+ case 5:
10761
11077
  messageBody = {
10762
11078
  method: NativeExtensionMethod.GetToken,
10763
11079
  request: nativeRequest
10764
11080
  };
10765
- reqTimestamp = TimeUtils.nowSeconds();
10766
11081
  return [4 /*yield*/, this.nativeMessageHandler.sendMessage(messageBody)];
10767
- case 2:
11082
+ case 6:
10768
11083
  response = _a.sent();
10769
11084
  validatedResponse = this.validateNativeResponse(response);
10770
11085
  return [2 /*return*/, this.handleNativeResponse(validatedResponse, nativeRequest, reqTimestamp)
@@ -10788,13 +11103,61 @@
10788
11103
  });
10789
11104
  });
10790
11105
  };
11106
+ /**
11107
+ * Creates silent flow request
11108
+ * @param request
11109
+ * @param cachedAccount
11110
+ * @returns CommonSilentFlowRequest
11111
+ */
11112
+ NativeInteractionClient.prototype.createSilentCacheRequest = function (request, cachedAccount) {
11113
+ return {
11114
+ authority: request.authority,
11115
+ correlationId: this.correlationId,
11116
+ scopes: ScopeSet.fromString(request.scope).asArray(),
11117
+ account: cachedAccount,
11118
+ forceRefresh: false,
11119
+ };
11120
+ };
11121
+ /**
11122
+ * Fetches the tokens from the cache if un-expired
11123
+ * @param nativeAccountId
11124
+ * @param request
11125
+ * @returns authenticationResult
11126
+ */
11127
+ NativeInteractionClient.prototype.acquireTokensFromCache = function (nativeAccountId, request) {
11128
+ return __awaiter$1(this, void 0, void 0, function () {
11129
+ var accountEntity, account, silentRequest, result, e_2;
11130
+ return __generator$1(this, function (_a) {
11131
+ switch (_a.label) {
11132
+ case 0:
11133
+ accountEntity = this.browserStorage.readAccountFromCacheWithNativeAccountId(nativeAccountId);
11134
+ if (!accountEntity) {
11135
+ throw ClientAuthError.createNoAccountFoundError();
11136
+ }
11137
+ account = accountEntity.getAccountInfo();
11138
+ _a.label = 1;
11139
+ case 1:
11140
+ _a.trys.push([1, 3, , 4]);
11141
+ silentRequest = this.createSilentCacheRequest(request, account);
11142
+ return [4 /*yield*/, this.silentCacheClient.acquireToken(silentRequest)];
11143
+ case 2:
11144
+ result = _a.sent();
11145
+ return [2 /*return*/, result];
11146
+ case 3:
11147
+ e_2 = _a.sent();
11148
+ throw e_2;
11149
+ case 4: return [2 /*return*/];
11150
+ }
11151
+ });
11152
+ });
11153
+ };
10791
11154
  /**
10792
11155
  * Acquires a token from native platform then redirects to the redirectUri instead of returning the response
10793
11156
  * @param request
10794
11157
  */
10795
11158
  NativeInteractionClient.prototype.acquireTokenRedirect = function (request) {
10796
11159
  return __awaiter$1(this, void 0, void 0, function () {
10797
- var nativeRequest, messageBody, response, e_1, navigationOptions, redirectUri;
11160
+ var nativeRequest, messageBody, response, e_3, navigationOptions, redirectUri;
10798
11161
  return __generator$1(this, function (_a) {
10799
11162
  switch (_a.label) {
10800
11163
  case 0:
@@ -10815,10 +11178,10 @@
10815
11178
  this.validateNativeResponse(response);
10816
11179
  return [3 /*break*/, 5];
10817
11180
  case 4:
10818
- e_1 = _a.sent();
11181
+ e_3 = _a.sent();
10819
11182
  // 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;
11183
+ if (e_3 instanceof NativeAuthError && e_3.isFatal()) {
11184
+ throw e_3;
10822
11185
  }
10823
11186
  return [3 /*break*/, 5];
10824
11187
  case 5:
@@ -10842,7 +11205,7 @@
10842
11205
  */
10843
11206
  NativeInteractionClient.prototype.handleRedirectPromise = function () {
10844
11207
  return __awaiter$1(this, void 0, void 0, function () {
10845
- var cachedRequest, messageBody, reqTimestamp, response, result, e_2;
11208
+ var cachedRequest, messageBody, reqTimestamp, response, result, e_4;
10846
11209
  return __generator$1(this, function (_a) {
10847
11210
  switch (_a.label) {
10848
11211
  case 0:
@@ -10874,9 +11237,9 @@
10874
11237
  this.browserStorage.setInteractionInProgress(false);
10875
11238
  return [2 /*return*/, result];
10876
11239
  case 3:
10877
- e_2 = _a.sent();
11240
+ e_4 = _a.sent();
10878
11241
  this.browserStorage.setInteractionInProgress(false);
10879
- throw e_2;
11242
+ throw e_4;
10880
11243
  case 4: return [2 /*return*/];
10881
11244
  }
10882
11245
  });
@@ -10898,7 +11261,7 @@
10898
11261
  */
10899
11262
  NativeInteractionClient.prototype.handleNativeResponse = function (response, request, reqTimestamp) {
10900
11263
  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;
11264
+ var idTokenObj, authority, authorityPreferredCache, homeAccountIdentifier, accountEntity, responseScopes, accountProperties, uid, tid, responseAccessToken, responseTokenType, _a, popTokenGenerator, shrParameters, mats, result, idTokenEntity, expiresIn, tokenExpirationSeconds, accessTokenEntity;
10902
11265
  var _this = this;
10903
11266
  return __generator$1(this, function (_b) {
10904
11267
  switch (_b.label) {
@@ -10916,7 +11279,7 @@
10916
11279
  homeAccountIdentifier = AccountEntity.generateHomeAccountId(response.client_info || Constants.EMPTY_STRING, AuthorityType.Default, this.logger, this.browserCrypto, idTokenObj);
10917
11280
  accountEntity = AccountEntity.createAccount(response.client_info, homeAccountIdentifier, idTokenObj, undefined, undefined, undefined, authorityPreferredCache, response.account.id);
10918
11281
  this.browserStorage.setAccount(accountEntity);
10919
- responseScopes = response.scopes ? ScopeSet.fromString(response.scopes) : ScopeSet.fromString(request.scopes);
11282
+ responseScopes = response.scope ? ScopeSet.fromString(response.scope) : ScopeSet.fromString(request.scope);
10920
11283
  accountProperties = response.account.properties || {};
10921
11284
  uid = accountProperties["UID"] || idTokenObj.claims.oid || idTokenObj.claims.sub || Constants.EMPTY_STRING;
10922
11285
  tid = accountProperties["TenantId"] || idTokenObj.claims.tid || Constants.EMPTY_STRING;
@@ -10976,7 +11339,17 @@
10976
11339
  state: response.state,
10977
11340
  fromNativeBroker: true
10978
11341
  };
10979
- // Remove any existing cached tokens for this account
11342
+ idTokenEntity = IdTokenEntity.createIdTokenEntity(homeAccountIdentifier, request.authority, response.id_token || Constants.EMPTY_STRING, request.clientId, idTokenObj.claims.tid || Constants.EMPTY_STRING);
11343
+ this.nativeStorageManager.setIdTokenCredential(idTokenEntity);
11344
+ expiresIn = (responseTokenType === exports.AuthenticationScheme.POP)
11345
+ ? Constants.SHR_NONCE_VALIDITY
11346
+ : (typeof response.expires_in === "string"
11347
+ ? parseInt(response.expires_in, 10)
11348
+ : response.expires_in) || 0;
11349
+ tokenExpirationSeconds = reqTimestamp + expiresIn;
11350
+ accessTokenEntity = AccessTokenEntity.createAccessTokenEntity(homeAccountIdentifier, request.authority, responseAccessToken, request.clientId, tid, responseScopes.printScopes(), tokenExpirationSeconds, 0, this.browserCrypto);
11351
+ this.nativeStorageManager.setAccessTokenCredential(accessTokenEntity);
11352
+ // Remove any existing cached tokens for this account in browser storage
10980
11353
  this.browserStorage.removeAccountContext(accountEntity).catch(function (e) {
10981
11354
  _this.logger.error("Error occurred while removing account context from browser storage. " + e);
10982
11355
  });
@@ -10994,7 +11367,7 @@
10994
11367
  response.hasOwnProperty("id_token") &&
10995
11368
  response.hasOwnProperty("client_info") &&
10996
11369
  response.hasOwnProperty("account") &&
10997
- response.hasOwnProperty("scopes") &&
11370
+ response.hasOwnProperty("scope") &&
10998
11371
  response.hasOwnProperty("expires_in")) {
10999
11372
  return response;
11000
11373
  }
@@ -11036,7 +11409,7 @@
11036
11409
  */
11037
11410
  NativeInteractionClient.prototype.initializeNativeRequest = function (request) {
11038
11411
  return __awaiter$1(this, void 0, void 0, function () {
11039
- var authority, canonicalAuthority, scopes, scopeSet, getPrompt, validatedRequest, shrParameters, popTokenGenerator, reqCnfData;
11412
+ var authority, canonicalAuthority, scopes, remainingProperties, scopeSet, getPrompt, validatedRequest, shrParameters, popTokenGenerator, reqCnfData;
11040
11413
  var _this = this;
11041
11414
  return __generator$1(this, function (_a) {
11042
11415
  switch (_a.label) {
@@ -11045,8 +11418,8 @@
11045
11418
  authority = request.authority || this.config.auth.authority;
11046
11419
  canonicalAuthority = new UrlString(authority);
11047
11420
  canonicalAuthority.validateAsUri();
11048
- scopes = request && request.scopes || [];
11049
- scopeSet = new ScopeSet(scopes);
11421
+ scopes = request.scopes, remainingProperties = __rest(request, ["scopes"]);
11422
+ scopeSet = new ScopeSet(scopes || []);
11050
11423
  scopeSet.appendScopes(OIDC_DEFAULT_SCOPES);
11051
11424
  getPrompt = function () {
11052
11425
  // If request is silent, prompt is always none
@@ -11073,7 +11446,7 @@
11073
11446
  throw BrowserAuthError.createNativePromptParameterNotSupportedError();
11074
11447
  }
11075
11448
  };
11076
- validatedRequest = __assign$1(__assign$1({}, request), { accountId: this.accountId, clientId: this.config.auth.clientId, authority: canonicalAuthority.urlString, scopes: scopeSet.printScopes(), redirectUri: this.getRedirectUri(request.redirectUri), prompt: getPrompt(), correlationId: this.correlationId, tokenType: request.authenticationScheme, windowTitleSubstring: document.title, extraParameters: __assign$1(__assign$1(__assign$1({}, request.extraQueryParameters), request.tokenQueryParameters), { telemetry: NativeConstants.MATS_TELEMETRY }), extendedExpiryToken: false // Make this configurable?
11449
+ validatedRequest = __assign$1(__assign$1({}, remainingProperties), { accountId: this.accountId, clientId: this.config.auth.clientId, authority: canonicalAuthority.urlString, scope: scopeSet.printScopes(), redirectUri: this.getRedirectUri(request.redirectUri), prompt: getPrompt(), correlationId: this.correlationId, tokenType: request.authenticationScheme, windowTitleSubstring: document.title, extraParameters: __assign$1(__assign$1(__assign$1({}, request.extraQueryParameters), request.tokenQueryParameters), { telemetry: NativeConstants.MATS_TELEMETRY }), extendedExpiryToken: false // Make this configurable?
11077
11450
  });
11078
11451
  if (!(request.authenticationScheme === exports.AuthenticationScheme.POP)) return [3 /*break*/, 2];
11079
11452
  shrParameters = {
@@ -11340,8 +11713,10 @@
11340
11713
  */
11341
11714
  var RedirectClient = /** @class */ (function (_super) {
11342
11715
  __extends$1(RedirectClient, _super);
11343
- function RedirectClient() {
11344
- return _super !== null && _super.apply(this, arguments) || this;
11716
+ function RedirectClient(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, performanceClient, nativeStorageImpl, nativeMessageHandler, correlationId) {
11717
+ var _this = _super.call(this, config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, performanceClient, nativeMessageHandler, correlationId) || this;
11718
+ _this.nativeStorage = nativeStorageImpl;
11719
+ return _this;
11345
11720
  }
11346
11721
  /**
11347
11722
  * Redirects the page to the /authorize endpoint of the IDP
@@ -11550,7 +11925,7 @@
11550
11925
  if (!this.nativeMessageHandler) {
11551
11926
  throw BrowserAuthError.createNativeConnectionNotEstablishedError();
11552
11927
  }
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);
11928
+ 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
11929
  userRequestState = ProtocolUtils.parseRequestState(this.browserCrypto, state).userRequestState;
11555
11930
  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
11931
  })).finally(function () {
@@ -11668,10 +12043,11 @@
11668
12043
  */
11669
12044
  var PopupClient = /** @class */ (function (_super) {
11670
12045
  __extends$1(PopupClient, _super);
11671
- function PopupClient(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, performanceClient, nativeMessageHandler, correlationId) {
12046
+ function PopupClient(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, performanceClient, nativeStorageImpl, nativeMessageHandler, correlationId) {
11672
12047
  var _this = _super.call(this, config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, performanceClient, nativeMessageHandler, correlationId) || this;
11673
12048
  // Properly sets this reference for the unload event.
11674
12049
  _this.unloadWindow = _this.unloadWindow.bind(_this);
12050
+ _this.nativeStorage = nativeStorageImpl;
11675
12051
  return _this;
11676
12052
  }
11677
12053
  /**
@@ -11796,7 +12172,7 @@
11796
12172
  if (!this.nativeMessageHandler) {
11797
12173
  throw BrowserAuthError.createNativeConnectionNotEstablishedError();
11798
12174
  }
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);
12175
+ 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
12176
  userRequestState = ProtocolUtils.parseRequestState(this.browserCrypto, state_1).userRequestState;
11801
12177
  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
12178
  })).finally(function () {
@@ -12424,9 +12800,10 @@
12424
12800
  */
12425
12801
  var SilentIframeClient = /** @class */ (function (_super) {
12426
12802
  __extends$1(SilentIframeClient, _super);
12427
- function SilentIframeClient(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, apiId, performanceClient, nativeMessageHandler, correlationId) {
12803
+ function SilentIframeClient(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, apiId, performanceClient, nativeStorageImpl, nativeMessageHandler, correlationId) {
12428
12804
  var _this = _super.call(this, config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, performanceClient, nativeMessageHandler, correlationId) || this;
12429
12805
  _this.apiId = apiId;
12806
+ _this.nativeStorage = nativeStorageImpl;
12430
12807
  return _this;
12431
12808
  }
12432
12809
  /**
@@ -12529,7 +12906,7 @@
12529
12906
  if (!this.nativeMessageHandler) {
12530
12907
  throw BrowserAuthError.createNativeConnectionNotEstablishedError();
12531
12908
  }
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);
12909
+ 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
12910
  userRequestState = ProtocolUtils.parseRequestState(this.browserCrypto, state).userRequestState;
12534
12911
  return [2 /*return*/, nativeInteractionClient.acquireToken(__assign$1(__assign$1({}, silentRequest), { state: userRequestState, prompt: PromptValue.NONE })).finally(function () {
12535
12912
  _this.browserStorage.cleanRequestByState(state);
@@ -12544,99 +12921,6 @@
12544
12921
  return SilentIframeClient;
12545
12922
  }(StandardInteractionClient));
12546
12923
 
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
12924
  /*
12641
12925
  * Copyright (c) Microsoft Corporation. All rights reserved.
12642
12926
  * Licensed under the MIT License.
@@ -12712,7 +12996,7 @@
12712
12996
  case 0: return [4 /*yield*/, this.getClientConfiguration(serverTelemetryManager, authorityUrl, azureCloudOptions)];
12713
12997
  case 1:
12714
12998
  clientConfig = _a.sent();
12715
- return [2 /*return*/, new RefreshTokenClient(clientConfig)];
12999
+ return [2 /*return*/, new RefreshTokenClient(clientConfig, this.performanceClient)];
12716
13000
  }
12717
13001
  });
12718
13002
  });
@@ -14654,6 +14938,13 @@
14654
14938
  this.browserStorage = this.isBrowserEnvironment ?
14655
14939
  new BrowserCacheManager(this.config.auth.clientId, this.config.cache, this.browserCrypto, this.logger) :
14656
14940
  DEFAULT_BROWSER_CACHE_MANAGER(this.config.auth.clientId, this.logger);
14941
+ // initialize in memory storage for native flows
14942
+ var nativeCacheOptions = {
14943
+ cacheLocation: exports.BrowserCacheLocation.MemoryStorage,
14944
+ storeAuthStateInCookie: false,
14945
+ secureCookies: false
14946
+ };
14947
+ this.nativeInternalStorage = new BrowserCacheManager(this.config.auth.clientId, nativeCacheOptions, this.browserCrypto, this.logger);
14657
14948
  // Initialize the token cache
14658
14949
  this.tokenCache = new TokenCache(this.config, this.browserStorage, this.logger, this.browserCrypto);
14659
14950
  }
@@ -14720,7 +15011,7 @@
14720
15011
  redirectResponse = void 0;
14721
15012
  if (request && NativeMessageHandler.isNativeAvailable(this.config, this.logger, this.nativeExtensionProvider) && this.nativeExtensionProvider && !hash) {
14722
15013
  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);
15014
+ 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
15015
  redirectResponse = nativeClient.handleRedirectPromise();
14725
15016
  }
14726
15017
  else {
@@ -14792,7 +15083,7 @@
14792
15083
  this.eventHandler.emitEvent(exports.EventType.LOGIN_START, exports.InteractionType.Redirect, request);
14793
15084
  }
14794
15085
  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);
15086
+ 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
15087
  result = nativeClient.acquireTokenRedirect(request).catch(function (e) {
14797
15088
  if (e instanceof NativeAuthError && e.isFatal()) {
14798
15089
  _this.nativeExtensionProvider = undefined; // If extension gets uninstalled during session prevent future requests from continuing to attempt
@@ -14860,7 +15151,9 @@
14860
15151
  _this.browserStorage.setInteractionInProgress(false);
14861
15152
  atPopupMeasurement.endMeasurement({
14862
15153
  success: true,
14863
- isNativeBroker: true
15154
+ isNativeBroker: true,
15155
+ accessTokenSize: response.accessToken.length,
15156
+ idTokenSize: response.idToken.length,
14864
15157
  });
14865
15158
  atPopupMeasurement.flushMeasurement();
14866
15159
  return response;
@@ -14884,7 +15177,9 @@
14884
15177
  result = popupClient.acquireToken(request);
14885
15178
  }
14886
15179
  return result.then(function (result) {
14887
- // If logged in, emit acquire token events
15180
+ /*
15181
+ * If logged in, emit acquire token events
15182
+ */
14888
15183
  var isLoggingIn = loggedInAccounts.length < _this.getAllAccounts().length;
14889
15184
  if (isLoggingIn) {
14890
15185
  _this.eventHandler.emitEvent(exports.EventType.LOGIN_SUCCESS, exports.InteractionType.Popup, result);
@@ -14893,7 +15188,9 @@
14893
15188
  _this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_SUCCESS, exports.InteractionType.Popup, result);
14894
15189
  }
14895
15190
  atPopupMeasurement.endMeasurement({
14896
- success: true
15191
+ success: true,
15192
+ accessTokenSize: result.accessToken.length,
15193
+ idTokenSize: result.idToken.length,
14897
15194
  });
14898
15195
  atPopupMeasurement.flushMeasurement();
14899
15196
  return result;
@@ -14961,7 +15258,9 @@
14961
15258
  _this.eventHandler.emitEvent(exports.EventType.SSO_SILENT_SUCCESS, exports.InteractionType.Silent, response);
14962
15259
  ssoSilentMeasurement.endMeasurement({
14963
15260
  success: true,
14964
- isNativeBroker: response.fromNativeBroker
15261
+ isNativeBroker: response.fromNativeBroker,
15262
+ accessTokenSize: response.accessToken.length,
15263
+ idTokenSize: response.idToken.length
14965
15264
  });
14966
15265
  ssoSilentMeasurement.flushMeasurement();
14967
15266
  return response;
@@ -15010,6 +15309,8 @@
15010
15309
  _this.hybridAuthCodeResponses.delete(hybridAuthCode_1);
15011
15310
  atbcMeasurement.endMeasurement({
15012
15311
  success: true,
15312
+ accessTokenSize: result.accessToken.length,
15313
+ idTokenSize: result.idToken.length,
15013
15314
  isNativeBroker: result.fromNativeBroker
15014
15315
  });
15015
15316
  atbcMeasurement.flushMeasurement();
@@ -15114,7 +15415,9 @@
15114
15415
  .then(function (result) {
15115
15416
  atbrtMeasurement.endMeasurement({
15116
15417
  success: true,
15117
- fromCache: result.fromCache
15418
+ fromCache: result.fromCache,
15419
+ accessTokenSize: result.accessToken.length,
15420
+ idTokenSize: result.idToken.length,
15118
15421
  });
15119
15422
  return result;
15120
15423
  })
@@ -15129,7 +15432,9 @@
15129
15432
  .then(function (result) {
15130
15433
  atbrtMeasurement.endMeasurement({
15131
15434
  success: true,
15132
- fromCache: result.fromCache
15435
+ fromCache: result.fromCache,
15436
+ accessTokenSize: result.accessToken.length,
15437
+ idTokenSize: result.idToken.length,
15133
15438
  });
15134
15439
  return result;
15135
15440
  })
@@ -15341,7 +15646,7 @@
15341
15646
  if (!this.nativeExtensionProvider) {
15342
15647
  throw BrowserAuthError.createNativeConnectionNotEstablishedError();
15343
15648
  }
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);
15649
+ 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
15650
  return [2 /*return*/, nativeClient.acquireToken(request)];
15346
15651
  });
15347
15652
  });
@@ -15388,21 +15693,21 @@
15388
15693
  * @param correlationId
15389
15694
  */
15390
15695
  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);
15696
+ return new PopupClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, this.performanceClient, this.nativeInternalStorage, this.nativeExtensionProvider, correlationId);
15392
15697
  };
15393
15698
  /**
15394
15699
  * Returns new instance of the Redirect Interaction Client
15395
15700
  * @param correlationId
15396
15701
  */
15397
15702
  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);
15703
+ return new RedirectClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, this.performanceClient, this.nativeInternalStorage, this.nativeExtensionProvider, correlationId);
15399
15704
  };
15400
15705
  /**
15401
15706
  * Returns new instance of the Silent Iframe Interaction Client
15402
15707
  * @param correlationId
15403
15708
  */
15404
15709
  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);
15710
+ 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
15711
  };
15407
15712
  /**
15408
15713
  * Returns new instance of the Silent Cache Interaction Client
@@ -15638,6 +15943,8 @@
15638
15943
  atsMeasurement.endMeasurement({
15639
15944
  success: true,
15640
15945
  fromCache: result.fromCache,
15946
+ accessTokenSize: result.accessToken.length,
15947
+ idTokenSize: result.idToken.length,
15641
15948
  isNativeBroker: result.fromNativeBroker
15642
15949
  });
15643
15950
  atsMeasurement.flushMeasurement();
@@ -15646,8 +15953,6 @@
15646
15953
  .catch(function (error) {
15647
15954
  _this.activeSilentTokenRequests.delete(silentRequestKey);
15648
15955
  atsMeasurement.endMeasurement({
15649
- errorCode: error.errorCode,
15650
- subErrorCode: error.subError,
15651
15956
  success: false
15652
15957
  });
15653
15958
  atsMeasurement.flushMeasurement();
@@ -15717,6 +16022,8 @@
15717
16022
  astsAsyncMeasurement.endMeasurement({
15718
16023
  success: true,
15719
16024
  fromCache: response.fromCache,
16025
+ accessTokenSize: response.accessToken.length,
16026
+ idTokenSize: response.idToken.length,
15720
16027
  isNativeBroker: response.fromNativeBroker
15721
16028
  });
15722
16029
  return response;