@azure/msal-browser 2.26.0 → 2.28.1

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 (102) 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 +2 -1
  5. package/dist/app/ClientApplication.d.ts.map +1 -1
  6. package/dist/app/ClientApplication.js +49 -15
  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 +40 -9
  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.d.ts.map +1 -1
  25. package/dist/cache/TokenCache.js +2 -1
  26. package/dist/cache/TokenCache.js.map +1 -1
  27. package/dist/config/Configuration.d.ts +4 -0
  28. package/dist/config/Configuration.d.ts.map +1 -1
  29. package/dist/config/Configuration.js +2 -1
  30. package/dist/config/Configuration.js.map +1 -1
  31. package/dist/crypto/BrowserCrypto.js +1 -1
  32. package/dist/crypto/CryptoOps.js +1 -1
  33. package/dist/crypto/GuidGenerator.js +1 -1
  34. package/dist/crypto/PkceGenerator.js +1 -1
  35. package/dist/crypto/SignedHttpRequest.js +1 -1
  36. package/dist/encode/Base64Decode.js +1 -1
  37. package/dist/encode/Base64Encode.js +1 -1
  38. package/dist/error/BrowserAuthError.js +1 -1
  39. package/dist/error/BrowserConfigurationAuthError.js +1 -1
  40. package/dist/error/NativeAuthError.d.ts +11 -1
  41. package/dist/error/NativeAuthError.d.ts.map +1 -1
  42. package/dist/error/NativeAuthError.js +15 -1
  43. package/dist/error/NativeAuthError.js.map +1 -1
  44. package/dist/event/EventHandler.js +1 -1
  45. package/dist/event/EventMessage.js +1 -1
  46. package/dist/event/EventType.js +1 -1
  47. package/dist/index.cjs.js +811 -411
  48. package/dist/index.cjs.js.map +1 -1
  49. package/dist/index.js +1 -1
  50. package/dist/interaction_client/BaseInteractionClient.js +1 -1
  51. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.js +1 -1
  52. package/dist/interaction_client/NativeInteractionClient.d.ts +18 -1
  53. package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
  54. package/dist/interaction_client/NativeInteractionClient.js +123 -33
  55. package/dist/interaction_client/NativeInteractionClient.js.map +1 -1
  56. package/dist/interaction_client/PopupClient.d.ts +2 -1
  57. package/dist/interaction_client/PopupClient.d.ts.map +1 -1
  58. package/dist/interaction_client/PopupClient.js +4 -3
  59. package/dist/interaction_client/PopupClient.js.map +1 -1
  60. package/dist/interaction_client/RedirectClient.d.ts +8 -1
  61. package/dist/interaction_client/RedirectClient.d.ts.map +1 -1
  62. package/dist/interaction_client/RedirectClient.js +6 -4
  63. package/dist/interaction_client/RedirectClient.js.map +1 -1
  64. package/dist/interaction_client/SilentAuthCodeClient.js +1 -1
  65. package/dist/interaction_client/SilentAuthCodeClient.js.map +1 -1
  66. package/dist/interaction_client/SilentCacheClient.d.ts.map +1 -1
  67. package/dist/interaction_client/SilentCacheClient.js +2 -2
  68. package/dist/interaction_client/SilentCacheClient.js.map +1 -1
  69. package/dist/interaction_client/SilentIframeClient.d.ts +2 -1
  70. package/dist/interaction_client/SilentIframeClient.d.ts.map +1 -1
  71. package/dist/interaction_client/SilentIframeClient.js +4 -3
  72. package/dist/interaction_client/SilentIframeClient.js.map +1 -1
  73. package/dist/interaction_client/SilentRefreshClient.d.ts.map +1 -1
  74. package/dist/interaction_client/SilentRefreshClient.js +2 -2
  75. package/dist/interaction_client/SilentRefreshClient.js.map +1 -1
  76. package/dist/interaction_client/StandardInteractionClient.d.ts.map +1 -1
  77. package/dist/interaction_client/StandardInteractionClient.js +2 -1
  78. package/dist/interaction_client/StandardInteractionClient.js.map +1 -1
  79. package/dist/interaction_handler/InteractionHandler.js +1 -1
  80. package/dist/interaction_handler/RedirectHandler.js +1 -1
  81. package/dist/interaction_handler/SilentHandler.js +1 -1
  82. package/dist/internals.js +1 -1
  83. package/dist/navigation/NavigationClient.js +1 -1
  84. package/dist/network/FetchClient.js +1 -1
  85. package/dist/network/XhrClient.js +1 -1
  86. package/dist/packageMetadata.d.ts +1 -1
  87. package/dist/packageMetadata.js +2 -2
  88. package/dist/packageMetadata.js.map +1 -1
  89. package/dist/request/PopupRequest.d.ts +1 -1
  90. package/dist/request/RedirectRequest.d.ts +1 -1
  91. package/dist/request/SsoSilentRequest.d.ts +1 -1
  92. package/dist/telemetry/BrowserPerformanceClient.js +1 -1
  93. package/dist/telemetry/BrowserPerformanceMeasurement.js +1 -1
  94. package/dist/utils/BrowserConstants.js +1 -1
  95. package/dist/utils/BrowserProtocolUtils.js +1 -1
  96. package/dist/utils/BrowserStringUtils.js +1 -1
  97. package/dist/utils/BrowserUtils.js +1 -1
  98. package/dist/utils/MathUtils.js +1 -1
  99. package/lib/msal-browser.js +811 -411
  100. package/lib/msal-browser.js.map +1 -1
  101. package/lib/msal-browser.min.js +43 -41
  102. package/package.json +3 -4
@@ -1,4 +1,4 @@
1
- /*! @azure/msal-browser v2.26.0 2022-06-13 */
1
+ /*! @azure/msal-browser v2.28.1 2022-08-01 */
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.0.0 2022-06-13 */
122
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
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.0.0 2022-06-13 */
209
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
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
@@ -478,6 +492,7 @@
478
492
  AuthorityMetadataSource["CONFIG"] = "config";
479
493
  AuthorityMetadataSource["CACHE"] = "cache";
480
494
  AuthorityMetadataSource["NETWORK"] = "network";
495
+ AuthorityMetadataSource["HARDCODED_VALUES"] = "hardcoded_values";
481
496
  })(AuthorityMetadataSource || (AuthorityMetadataSource = {}));
482
497
  var SERVER_TELEM_CONSTANTS = {
483
498
  SCHEMA_VERSION: 5,
@@ -568,7 +583,7 @@
568
583
  JsonTypes["Jwk"] = "JWK";
569
584
  })(JsonTypes || (JsonTypes = {}));
570
585
 
571
- /*! @azure/msal-common v7.0.0 2022-06-13 */
586
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
572
587
 
573
588
  /*
574
589
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -581,6 +596,10 @@
581
596
  unexpectedError: {
582
597
  code: "unexpected_error",
583
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."
584
603
  }
585
604
  };
586
605
  /**
@@ -609,10 +628,18 @@
609
628
  AuthError.createUnexpectedError = function (errDesc) {
610
629
  return new AuthError(AuthErrorMessage.unexpectedError.code, AuthErrorMessage.unexpectedError.desc + ": " + errDesc);
611
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
+ };
612
639
  return AuthError;
613
640
  }(Error));
614
641
 
615
- /*! @azure/msal-common v7.0.0 2022-06-13 */
642
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
616
643
 
617
644
  /*
618
645
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -687,7 +714,7 @@
687
714
  }
688
715
  };
689
716
 
690
- /*! @azure/msal-common v7.0.0 2022-06-13 */
717
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
691
718
 
692
719
  /*
693
720
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1159,7 +1186,7 @@
1159
1186
  return ClientAuthError;
1160
1187
  }(AuthError));
1161
1188
 
1162
- /*! @azure/msal-common v7.0.0 2022-06-13 */
1189
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
1163
1190
 
1164
1191
  /*
1165
1192
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1284,7 +1311,7 @@
1284
1311
  return StringUtils;
1285
1312
  }());
1286
1313
 
1287
- /*! @azure/msal-common v7.0.0 2022-06-13 */
1314
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
1288
1315
 
1289
1316
  /*
1290
1317
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1464,12 +1491,12 @@
1464
1491
  return Logger;
1465
1492
  }());
1466
1493
 
1467
- /*! @azure/msal-common v7.0.0 2022-06-13 */
1494
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
1468
1495
  /* eslint-disable header/header */
1469
1496
  var name$1 = "@azure/msal-common";
1470
- var version$1 = "7.0.0";
1497
+ var version$1 = "7.3.0";
1471
1498
 
1472
- /*! @azure/msal-common v7.0.0 2022-06-13 */
1499
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
1473
1500
  /*
1474
1501
  * Copyright (c) Microsoft Corporation. All rights reserved.
1475
1502
  * Licensed under the MIT License.
@@ -1490,7 +1517,7 @@
1490
1517
  AzureCloudInstance["AzureUsGovernment"] = "https://login.microsoftonline.us";
1491
1518
  })(exports.AzureCloudInstance || (exports.AzureCloudInstance = {}));
1492
1519
 
1493
- /*! @azure/msal-common v7.0.0 2022-06-13 */
1520
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
1494
1521
 
1495
1522
  /*
1496
1523
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1649,7 +1676,7 @@
1649
1676
  return CredentialEntity;
1650
1677
  }());
1651
1678
 
1652
- /*! @azure/msal-common v7.0.0 2022-06-13 */
1679
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
1653
1680
 
1654
1681
  /*
1655
1682
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1904,7 +1931,7 @@
1904
1931
  return ClientConfigurationError;
1905
1932
  }(ClientAuthError));
1906
1933
 
1907
- /*! @azure/msal-common v7.0.0 2022-06-13 */
1934
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
1908
1935
 
1909
1936
  /*
1910
1937
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2088,7 +2115,7 @@
2088
2115
  return ScopeSet;
2089
2116
  }());
2090
2117
 
2091
- /*! @azure/msal-common v7.0.0 2022-06-13 */
2118
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
2092
2119
 
2093
2120
  /*
2094
2121
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2126,7 +2153,7 @@
2126
2153
  };
2127
2154
  }
2128
2155
 
2129
- /*! @azure/msal-common v7.0.0 2022-06-13 */
2156
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
2130
2157
  /*
2131
2158
  * Copyright (c) Microsoft Corporation. All rights reserved.
2132
2159
  * Licensed under the MIT License.
@@ -2140,7 +2167,7 @@
2140
2167
  AuthorityType[AuthorityType["Adfs"] = 1] = "Adfs";
2141
2168
  })(AuthorityType || (AuthorityType = {}));
2142
2169
 
2143
- /*! @azure/msal-common v7.0.0 2022-06-13 */
2170
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
2144
2171
 
2145
2172
  /*
2146
2173
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2375,7 +2402,7 @@
2375
2402
  return AccountEntity;
2376
2403
  }());
2377
2404
 
2378
- /*! @azure/msal-common v7.0.0 2022-06-13 */
2405
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
2379
2406
 
2380
2407
  /*
2381
2408
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2413,7 +2440,7 @@
2413
2440
  return AuthToken;
2414
2441
  }());
2415
2442
 
2416
- /*! @azure/msal-common v7.0.0 2022-06-13 */
2443
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
2417
2444
 
2418
2445
  /*
2419
2446
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2535,7 +2562,7 @@
2535
2562
  * @param realm
2536
2563
  */
2537
2564
  CacheManager.prototype.getAccountsFilteredBy = function (accountFilter) {
2538
- return this.getAccountsFilteredByInternal(accountFilter ? accountFilter.homeAccountId : Constants.EMPTY_STRING, accountFilter ? accountFilter.environment : Constants.EMPTY_STRING, accountFilter ? accountFilter.realm : Constants.EMPTY_STRING);
2565
+ 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);
2539
2566
  };
2540
2567
  /**
2541
2568
  * retrieve accounts matching all provided filters; if no filter is set, get all accounts
@@ -2544,7 +2571,7 @@
2544
2571
  * @param environment
2545
2572
  * @param realm
2546
2573
  */
2547
- CacheManager.prototype.getAccountsFilteredByInternal = function (homeAccountId, environment, realm) {
2574
+ CacheManager.prototype.getAccountsFilteredByInternal = function (homeAccountId, environment, realm, nativeAccountId) {
2548
2575
  var _this = this;
2549
2576
  var allCacheKeys = this.getKeys();
2550
2577
  var matchingAccounts = {};
@@ -2562,6 +2589,9 @@
2562
2589
  if (!!realm && !_this.matchRealm(entity, realm)) {
2563
2590
  return;
2564
2591
  }
2592
+ if (!!nativeAccountId && !_this.matchNativeAccountId(entity, nativeAccountId)) {
2593
+ return;
2594
+ }
2565
2595
  matchingAccounts[cacheKey] = entity;
2566
2596
  });
2567
2597
  return matchingAccounts;
@@ -2890,6 +2920,26 @@
2890
2920
  var accountKey = AccountEntity.generateAccountCacheKey(account);
2891
2921
  return this.getAccount(accountKey);
2892
2922
  };
2923
+ /**
2924
+ * Retrieve AccountEntity from cache
2925
+ * @param nativeAccountId
2926
+ * @returns AccountEntity or Null
2927
+ */
2928
+ CacheManager.prototype.readAccountFromCacheWithNativeAccountId = function (nativeAccountId) {
2929
+ // fetch account from memory
2930
+ var accountFilter = {
2931
+ nativeAccountId: nativeAccountId
2932
+ };
2933
+ var accountCache = this.getAccountsFilteredBy(accountFilter);
2934
+ var accounts = Object.keys(accountCache).map(function (key) { return accountCache[key]; });
2935
+ if (accounts.length < 1) {
2936
+ return null;
2937
+ }
2938
+ else if (accounts.length > 1) {
2939
+ throw ClientAuthError.createMultipleMatchingAccountsInCacheError();
2940
+ }
2941
+ return accountCache[0];
2942
+ };
2893
2943
  /**
2894
2944
  * Retrieve IdTokenEntity from cache
2895
2945
  * @param clientId
@@ -3064,6 +3114,15 @@
3064
3114
  CacheManager.prototype.matchRealm = function (entity, realm) {
3065
3115
  return !!(entity.realm && realm === entity.realm);
3066
3116
  };
3117
+ /**
3118
+ * helper to match nativeAccountId
3119
+ * @param entity
3120
+ * @param nativeAccountId
3121
+ * @returns boolean indicating the match result
3122
+ */
3123
+ CacheManager.prototype.matchNativeAccountId = function (entity, nativeAccountId) {
3124
+ return !!(entity.nativeAccountId && nativeAccountId === entity.nativeAccountId);
3125
+ };
3067
3126
  /**
3068
3127
  * Returns true if the target scopes are a subset of the current entity's scopes, false otherwise.
3069
3128
  * @param entity
@@ -3255,7 +3314,7 @@
3255
3314
  return DefaultStorageClass;
3256
3315
  }(CacheManager));
3257
3316
 
3258
- /*! @azure/msal-common v7.0.0 2022-06-13 */
3317
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
3259
3318
 
3260
3319
  /*
3261
3320
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3338,7 +3397,7 @@
3338
3397
  telemetry: __assign(__assign({}, DEFAULT_TELEMETRY_OPTIONS), telemetry),
3339
3398
  serverTelemetryManager: serverTelemetryManager || null,
3340
3399
  persistencePlugin: persistencePlugin || null,
3341
- serializableCache: serializableCache || null
3400
+ serializableCache: serializableCache || null,
3342
3401
  };
3343
3402
  }
3344
3403
  /**
@@ -3346,10 +3405,10 @@
3346
3405
  * @param authOptions
3347
3406
  */
3348
3407
  function buildAuthOptions(authOptions) {
3349
- return __assign({ clientCapabilities: [], azureCloudOptions: DEFAULT_AZURE_CLOUD_OPTIONS }, authOptions);
3408
+ return __assign({ clientCapabilities: [], azureCloudOptions: DEFAULT_AZURE_CLOUD_OPTIONS, skipAuthorityMetadataCache: false }, authOptions);
3350
3409
  }
3351
3410
 
3352
- /*! @azure/msal-common v7.0.0 2022-06-13 */
3411
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
3353
3412
 
3354
3413
  /*
3355
3414
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3369,7 +3428,7 @@
3369
3428
  return ServerError;
3370
3429
  }(AuthError));
3371
3430
 
3372
- /*! @azure/msal-common v7.0.0 2022-06-13 */
3431
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
3373
3432
 
3374
3433
  /*
3375
3434
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3465,7 +3524,7 @@
3465
3524
  return ThrottlingUtils;
3466
3525
  }());
3467
3526
 
3468
- /*! @azure/msal-common v7.0.0 2022-06-13 */
3527
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
3469
3528
 
3470
3529
  /*
3471
3530
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3514,7 +3573,7 @@
3514
3573
  return NetworkManager;
3515
3574
  }());
3516
3575
 
3517
- /*! @azure/msal-common v7.0.0 2022-06-13 */
3576
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
3518
3577
  /*
3519
3578
  * Copyright (c) Microsoft Corporation. All rights reserved.
3520
3579
  * Licensed under the MIT License.
@@ -3525,7 +3584,7 @@
3525
3584
  CcsCredentialType["UPN"] = "UPN";
3526
3585
  })(CcsCredentialType || (CcsCredentialType = {}));
3527
3586
 
3528
- /*! @azure/msal-common v7.0.0 2022-06-13 */
3587
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
3529
3588
 
3530
3589
  /*
3531
3590
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3535,7 +3594,7 @@
3535
3594
  * Base application class which will construct requests to send to and handle responses from the Microsoft STS using the authorization code flow.
3536
3595
  */
3537
3596
  var BaseClient = /** @class */ (function () {
3538
- function BaseClient(configuration) {
3597
+ function BaseClient(configuration, performanceClient) {
3539
3598
  // Set the configuration
3540
3599
  this.config = buildClientConfiguration(configuration);
3541
3600
  // Initialize the logger
@@ -3552,6 +3611,8 @@
3552
3611
  this.serverTelemetryManager = this.config.serverTelemetryManager;
3553
3612
  // set Authority
3554
3613
  this.authority = this.config.authOptions.authority;
3614
+ // set performance telemetry client
3615
+ this.performanceClient = performanceClient;
3555
3616
  }
3556
3617
  /**
3557
3618
  * Creates default headers for requests to token endpoint
@@ -3614,7 +3675,7 @@
3614
3675
  return BaseClient;
3615
3676
  }());
3616
3677
 
3617
- /*! @azure/msal-common v7.0.0 2022-06-13 */
3678
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
3618
3679
 
3619
3680
  /*
3620
3681
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3700,7 +3761,7 @@
3700
3761
  return RequestValidator;
3701
3762
  }());
3702
3763
 
3703
- /*! @azure/msal-common v7.0.0 2022-06-13 */
3764
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
3704
3765
 
3705
3766
  /*
3706
3767
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4078,7 +4139,7 @@
4078
4139
  return RequestParameterBuilder;
4079
4140
  }());
4080
4141
 
4081
- /*! @azure/msal-common v7.0.0 2022-06-13 */
4142
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
4082
4143
 
4083
4144
  /*
4084
4145
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4142,7 +4203,7 @@
4142
4203
  return IdTokenEntity;
4143
4204
  }(CredentialEntity));
4144
4205
 
4145
- /*! @azure/msal-common v7.0.0 2022-06-13 */
4206
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
4146
4207
  /*
4147
4208
  * Copyright (c) Microsoft Corporation. All rights reserved.
4148
4209
  * Licensed under the MIT License.
@@ -4192,7 +4253,7 @@
4192
4253
  return TimeUtils;
4193
4254
  }());
4194
4255
 
4195
- /*! @azure/msal-common v7.0.0 2022-06-13 */
4256
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
4196
4257
 
4197
4258
  /*
4198
4259
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4306,7 +4367,7 @@
4306
4367
  return AccessTokenEntity;
4307
4368
  }(CredentialEntity));
4308
4369
 
4309
- /*! @azure/msal-common v7.0.0 2022-06-13 */
4370
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
4310
4371
 
4311
4372
  /*
4312
4373
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4373,7 +4434,7 @@
4373
4434
  return RefreshTokenEntity;
4374
4435
  }(CredentialEntity));
4375
4436
 
4376
- /*! @azure/msal-common v7.0.0 2022-06-13 */
4437
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
4377
4438
 
4378
4439
  /*
4379
4440
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4401,6 +4462,10 @@
4401
4462
  noTokensFoundError: {
4402
4463
  code: "no_tokens_found",
4403
4464
  desc: "No refresh token found in the cache. Please sign-in."
4465
+ },
4466
+ native_account_unavailable: {
4467
+ code: "native_account_unavailable",
4468
+ desc: "The requested account is not available in the native broker. It may have been deleted or logged out. Please sign-in again using an interactive API."
4404
4469
  }
4405
4470
  };
4406
4471
  /**
@@ -4434,10 +4499,17 @@
4434
4499
  InteractionRequiredAuthError.createNoTokensFoundError = function () {
4435
4500
  return new InteractionRequiredAuthError(InteractionRequiredAuthErrorMessage.noTokensFoundError.code, InteractionRequiredAuthErrorMessage.noTokensFoundError.desc);
4436
4501
  };
4502
+ /**
4503
+ * Creates an error thrown when the native broker returns ACCOUNT_UNAVAILABLE status, indicating that the account was removed and interactive sign-in is required
4504
+ * @returns
4505
+ */
4506
+ InteractionRequiredAuthError.createNativeAccountUnavailableError = function () {
4507
+ return new InteractionRequiredAuthError(InteractionRequiredAuthErrorMessage.native_account_unavailable.code, InteractionRequiredAuthErrorMessage.native_account_unavailable.desc);
4508
+ };
4437
4509
  return InteractionRequiredAuthError;
4438
4510
  }(AuthError));
4439
4511
 
4440
- /*! @azure/msal-common v7.0.0 2022-06-13 */
4512
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
4441
4513
  /*
4442
4514
  * Copyright (c) Microsoft Corporation. All rights reserved.
4443
4515
  * Licensed under the MIT License.
@@ -4453,7 +4525,7 @@
4453
4525
  return CacheRecord;
4454
4526
  }());
4455
4527
 
4456
- /*! @azure/msal-common v7.0.0 2022-06-13 */
4528
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
4457
4529
 
4458
4530
  /*
4459
4531
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4524,7 +4596,7 @@
4524
4596
  return ProtocolUtils;
4525
4597
  }());
4526
4598
 
4527
- /*! @azure/msal-common v7.0.0 2022-06-13 */
4599
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
4528
4600
 
4529
4601
  /*
4530
4602
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4725,7 +4797,7 @@
4725
4797
  return UrlString;
4726
4798
  }());
4727
4799
 
4728
- /*! @azure/msal-common v7.0.0 2022-06-13 */
4800
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
4729
4801
 
4730
4802
  /*
4731
4803
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4826,7 +4898,7 @@
4826
4898
  return PopTokenGenerator;
4827
4899
  }());
4828
4900
 
4829
- /*! @azure/msal-common v7.0.0 2022-06-13 */
4901
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
4830
4902
 
4831
4903
  /*
4832
4904
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4896,7 +4968,7 @@
4896
4968
  return AppMetadataEntity;
4897
4969
  }());
4898
4970
 
4899
- /*! @azure/msal-common v7.0.0 2022-06-13 */
4971
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
4900
4972
  /*
4901
4973
  * Copyright (c) Microsoft Corporation. All rights reserved.
4902
4974
  * Licensed under the MIT License.
@@ -4932,7 +5004,7 @@
4932
5004
  return TokenCacheContext;
4933
5005
  }());
4934
5006
 
4935
- /*! @azure/msal-common v7.0.0 2022-06-13 */
5007
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
4936
5008
 
4937
5009
  /*
4938
5010
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4993,7 +5065,7 @@
4993
5065
  * @param serverTokenResponse
4994
5066
  * @param authority
4995
5067
  */
4996
- ResponseHandler.prototype.handleServerTokenResponse = function (serverTokenResponse, authority, reqTimestamp, request, authCodePayload, userAssertionHash, handlingRefreshTokenResponse) {
5068
+ ResponseHandler.prototype.handleServerTokenResponse = function (serverTokenResponse, authority, reqTimestamp, request, authCodePayload, userAssertionHash, handlingRefreshTokenResponse, forceCacheRefreshTokenResponse) {
4997
5069
  return __awaiter(this, void 0, void 0, function () {
4998
5070
  var idTokenObj, requestStateObj, cacheRecord, cacheContext, key, account;
4999
5071
  return __generator(this, function (_a) {
@@ -5030,14 +5102,15 @@
5030
5102
  /*
5031
5103
  * When saving a refreshed tokens to the cache, it is expected that the account that was used is present in the cache.
5032
5104
  * If not present, we should return null, as it's the case that another application called removeAccount in between
5033
- * the calls to getAllAccounts and acquireTokenSilent. We should not overwrite that removal.
5105
+ * the calls to getAllAccounts and acquireTokenSilent. We should not overwrite that removal, unless explicitly flagged by
5106
+ * the developer, as in the case of refresh token flow used in ADAL Node to MSAL Node migration.
5034
5107
  */
5035
- if (handlingRefreshTokenResponse && cacheRecord.account) {
5108
+ if (handlingRefreshTokenResponse && !forceCacheRefreshTokenResponse && cacheRecord.account) {
5036
5109
  key = cacheRecord.account.generateAccountKey();
5037
5110
  account = this.cacheStorage.getAccount(key);
5038
5111
  if (!account) {
5039
5112
  this.logger.warning("Account used to refresh tokens not in persistence, refreshed tokens will not be stored in the cache");
5040
- return [2 /*return*/, ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenObj, requestStateObj)];
5113
+ return [2 /*return*/, ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenObj, requestStateObj, undefined)];
5041
5114
  }
5042
5115
  }
5043
5116
  return [4 /*yield*/, this.cacheStorage.saveCacheRecord(cacheRecord)];
@@ -5202,7 +5275,7 @@
5202
5275
  return ResponseHandler;
5203
5276
  }());
5204
5277
 
5205
- /*! @azure/msal-common v7.0.0 2022-06-13 */
5278
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
5206
5279
 
5207
5280
  /*
5208
5281
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5303,7 +5376,7 @@
5303
5376
  throw ClientConfigurationError.createEmptyLogoutRequestError();
5304
5377
  }
5305
5378
  var queryString = this.createLogoutUrlQueryString(logoutRequest);
5306
- // Construct logout URI.
5379
+ // Construct logout URI
5307
5380
  return UrlString.appendQueryString(this.authority.endSessionEndpoint, queryString);
5308
5381
  };
5309
5382
  /**
@@ -5490,7 +5563,7 @@
5490
5563
  */
5491
5564
  AuthorizationCodeClient.prototype.createAuthCodeUrlQueryString = function (request) {
5492
5565
  return __awaiter(this, void 0, void 0, function () {
5493
- var parameterBuilder, requestScopes, correlationId, accountSid, clientInfo, clientInfo, popTokenGenerator, reqCnfData;
5566
+ var parameterBuilder, requestScopes, correlationId, accountSid, accountLoginHintClaim, clientInfo, clientInfo, clientInfo, popTokenGenerator, reqCnfData;
5494
5567
  return __generator(this, function (_a) {
5495
5568
  switch (_a.label) {
5496
5569
  case 0:
@@ -5520,7 +5593,7 @@
5520
5593
  if (request.domainHint) {
5521
5594
  parameterBuilder.addDomainHint(request.domainHint);
5522
5595
  }
5523
- // Add sid or loginHint with preference for sid -> loginHint -> username of AccountInfo object
5596
+ // Add sid or loginHint with preference for login_hint claim (in request) -> sid -> loginHint (upn/email) -> username of AccountInfo object
5524
5597
  if (request.prompt !== PromptValue.SELECT_ACCOUNT) {
5525
5598
  // AAD will throw if prompt=select_account is passed with an account hint
5526
5599
  if (request.sid && request.prompt === PromptValue.NONE) {
@@ -5530,9 +5603,24 @@
5530
5603
  }
5531
5604
  else if (request.account) {
5532
5605
  accountSid = this.extractAccountSid(request.account);
5533
- // If account and loginHint are provided, we will check account first for sid before adding loginHint
5534
- if (accountSid && request.prompt === PromptValue.NONE) {
5535
- // SessionId is only used in silent calls
5606
+ accountLoginHintClaim = this.extractLoginHint(request.account);
5607
+ // If login_hint claim is present, use it over sid/username
5608
+ if (accountLoginHintClaim) {
5609
+ this.logger.verbose("createAuthCodeUrlQueryString: login_hint claim present on account");
5610
+ parameterBuilder.addLoginHint(accountLoginHintClaim);
5611
+ try {
5612
+ clientInfo = buildClientInfoFromHomeAccountId(request.account.homeAccountId);
5613
+ parameterBuilder.addCcsOid(clientInfo);
5614
+ }
5615
+ catch (e) {
5616
+ this.logger.verbose("createAuthCodeUrlQueryString: Could not parse home account ID for CCS Header");
5617
+ }
5618
+ }
5619
+ else if (accountSid && request.prompt === PromptValue.NONE) {
5620
+ /*
5621
+ * If account and loginHint are provided, we will check account first for sid before adding loginHint
5622
+ * SessionId is only used in silent calls
5623
+ */
5536
5624
  this.logger.verbose("createAuthCodeUrlQueryString: Prompt is none, adding sid from account");
5537
5625
  parameterBuilder.addSid(accountSid);
5538
5626
  try {
@@ -5540,7 +5628,7 @@
5540
5628
  parameterBuilder.addCcsOid(clientInfo);
5541
5629
  }
5542
5630
  catch (e) {
5543
- this.logger.verbose("Could not parse home account ID for CCS Header: " + e);
5631
+ this.logger.verbose("createAuthCodeUrlQueryString: Could not parse home account ID for CCS Header");
5544
5632
  }
5545
5633
  }
5546
5634
  else if (request.loginHint) {
@@ -5557,7 +5645,7 @@
5557
5645
  parameterBuilder.addCcsOid(clientInfo);
5558
5646
  }
5559
5647
  catch (e) {
5560
- this.logger.verbose("Could not parse home account ID for CCS Header: " + e);
5648
+ this.logger.verbose("createAuthCodeUrlQueryString: Could not parse home account ID for CCS Header");
5561
5649
  }
5562
5650
  }
5563
5651
  }
@@ -5628,16 +5716,135 @@
5628
5716
  * @param account
5629
5717
  */
5630
5718
  AuthorizationCodeClient.prototype.extractAccountSid = function (account) {
5631
- if (account.idTokenClaims) {
5632
- var tokenClaims = account.idTokenClaims;
5633
- return tokenClaims.sid || null;
5634
- }
5635
- return null;
5719
+ var _a;
5720
+ return ((_a = account.idTokenClaims) === null || _a === void 0 ? void 0 : _a.sid) || null;
5721
+ };
5722
+ AuthorizationCodeClient.prototype.extractLoginHint = function (account) {
5723
+ var _a;
5724
+ return ((_a = account.idTokenClaims) === null || _a === void 0 ? void 0 : _a.login_hint) || null;
5636
5725
  };
5637
5726
  return AuthorizationCodeClient;
5638
5727
  }(BaseClient));
5639
5728
 
5640
- /*! @azure/msal-common v7.0.0 2022-06-13 */
5729
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
5730
+ /*
5731
+ * Copyright (c) Microsoft Corporation. All rights reserved.
5732
+ * Licensed under the MIT License.
5733
+ */
5734
+ /**
5735
+ * Enumeration of operations that are instrumented by have their performance measured by the PerformanceClient.
5736
+ *
5737
+ * @export
5738
+ * @enum {number}
5739
+ */
5740
+ exports.PerformanceEvents = void 0;
5741
+ (function (PerformanceEvents) {
5742
+ /**
5743
+ * acquireTokenByCode API (msal-browser and msal-node).
5744
+ * Used to acquire tokens by trading an authorization code against the token endpoint.
5745
+ */
5746
+ PerformanceEvents["AcquireTokenByCode"] = "acquireTokenByCode";
5747
+ /**
5748
+ * acquireTokenByRefreshToken API (msal-browser and msal-node).
5749
+ * Used to renew an access token using a refresh token against the token endpoint.
5750
+ */
5751
+ PerformanceEvents["AcquireTokenByRefreshToken"] = "acquireTokenByRefreshToken";
5752
+ /**
5753
+ * acquireTokenSilent API (msal-browser and msal-node).
5754
+ * Used to silently acquire a new access token (from the cache or the network).
5755
+ */
5756
+ PerformanceEvents["AcquireTokenSilent"] = "acquireTokenSilent";
5757
+ /**
5758
+ * acquireTokenSilentAsync (msal-browser).
5759
+ * Internal API for acquireTokenSilent.
5760
+ */
5761
+ PerformanceEvents["AcquireTokenSilentAsync"] = "acquireTokenSilentAsync";
5762
+ /**
5763
+ * acquireTokenPopup (msal-browser).
5764
+ * Used to acquire a new access token interactively through pop ups
5765
+ */
5766
+ PerformanceEvents["AcquireTokenPopup"] = "acquireTokenPopup";
5767
+ /**
5768
+ * getPublicKeyThumbprint API in CryptoOpts class (msal-browser).
5769
+ * Used to generate a public/private keypair and generate a public key thumbprint for pop requests.
5770
+ */
5771
+ PerformanceEvents["CryptoOptsGetPublicKeyThumbprint"] = "cryptoOptsGetPublicKeyThumbprint";
5772
+ /**
5773
+ * signJwt API in CryptoOpts class (msal-browser).
5774
+ * Used to signed a pop token.
5775
+ */
5776
+ PerformanceEvents["CryptoOptsSignJwt"] = "cryptoOptsSignJwt";
5777
+ /**
5778
+ * acquireToken API in the SilentCacheClient class (msal-browser).
5779
+ * Used to read access tokens from the cache.
5780
+ */
5781
+ PerformanceEvents["SilentCacheClientAcquireToken"] = "silentCacheClientAcquireToken";
5782
+ /**
5783
+ * acquireToken API in the SilentIframeClient class (msal-browser).
5784
+ * Used to acquire a new set of tokens from the authorize endpoint in a hidden iframe.
5785
+ */
5786
+ PerformanceEvents["SilentIframeClientAcquireToken"] = "silentIframeClientAcquireToken";
5787
+ /**
5788
+ * acquireToken API in SilentRereshClient (msal-browser).
5789
+ * Used to acquire a new set of tokens from the token endpoint using a refresh token.
5790
+ */
5791
+ PerformanceEvents["SilentRefreshClientAcquireToken"] = "silentRefreshClientAcquireToken";
5792
+ /**
5793
+ * ssoSilent API (msal-browser).
5794
+ * Used to silently acquire an authorization code and set of tokens using a hidden iframe.
5795
+ */
5796
+ PerformanceEvents["SsoSilent"] = "ssoSilent";
5797
+ /**
5798
+ * getDiscoveredAuthority API in StandardInteractionClient class (msal-browser).
5799
+ * Used to load authority metadata for a request.
5800
+ */
5801
+ PerformanceEvents["StandardInteractionClientGetDiscoveredAuthority"] = "standardInteractionClientGetDiscoveredAuthority";
5802
+ /**
5803
+ * acquireToken APIs in msal-browser.
5804
+ * Used to make an /authorize endpoint call with native brokering enabled.
5805
+ */
5806
+ PerformanceEvents["FetchAccountIdWithNativeBroker"] = "fetchAccountIdWithNativeBroker";
5807
+ /**
5808
+ * acquireToken API in NativeInteractionClient class (msal-browser).
5809
+ * Used to acquire a token from Native component when native brokering is enabled.
5810
+ */
5811
+ PerformanceEvents["NativeInteractionClientAcquireToken"] = "nativeInteractionClientAcquireToken";
5812
+ /**
5813
+ * Time spent on the network for refresh token acquisition
5814
+ */
5815
+ PerformanceEvents["RefreshTokenClientExecuteTokenRequest"] = "refreshTokenClientExecuteTokenRequest";
5816
+ /**
5817
+ * Time spent creating default headers for requests to token endpoint
5818
+ */
5819
+ PerformanceEvents["BaseClientCreateTokenRequestHeaders"] = "baseClientCreateTokenRequestHeaders";
5820
+ /**
5821
+ * Used to measure the time taken for completing embedded-broker handshake (PW-Broker).
5822
+ */
5823
+ PerformanceEvents["BrokerHandhshake"] = "brokerHandshake";
5824
+ /**
5825
+ * acquireTokenByRefreshToken API in BrokerClientApplication (PW-Broker) .
5826
+ */
5827
+ PerformanceEvents["AcquireTokenByRefreshTokenInBroker"] = "acquireTokenByRefreshTokenInBroker";
5828
+ /**
5829
+ * acquireToken API in BrokerClientApplication.
5830
+ * Used to acquire a token on behalf of the embedded application (PW-Broker).
5831
+ */
5832
+ PerformanceEvents["AcquireTokenByBroker"] = "acquireTokenByBroker";
5833
+ })(exports.PerformanceEvents || (exports.PerformanceEvents = {}));
5834
+ /**
5835
+ * State of the performance event.
5836
+ *
5837
+ * @export
5838
+ * @enum {number}
5839
+ */
5840
+ var PerformanceEventStatus;
5841
+ (function (PerformanceEventStatus) {
5842
+ PerformanceEventStatus[PerformanceEventStatus["NotStarted"] = 0] = "NotStarted";
5843
+ PerformanceEventStatus[PerformanceEventStatus["InProgress"] = 1] = "InProgress";
5844
+ PerformanceEventStatus[PerformanceEventStatus["Completed"] = 2] = "Completed";
5845
+ })(PerformanceEventStatus || (PerformanceEventStatus = {}));
5846
+
5847
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
5641
5848
 
5642
5849
  /*
5643
5850
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5648,8 +5855,8 @@
5648
5855
  */
5649
5856
  var RefreshTokenClient = /** @class */ (function (_super) {
5650
5857
  __extends(RefreshTokenClient, _super);
5651
- function RefreshTokenClient(configuration) {
5652
- return _super.call(this, configuration) || this;
5858
+ function RefreshTokenClient(configuration, performanceClient) {
5859
+ return _super.call(this, configuration, performanceClient) || this;
5653
5860
  }
5654
5861
  RefreshTokenClient.prototype.acquireToken = function (request) {
5655
5862
  return __awaiter(this, void 0, void 0, function () {
@@ -5663,7 +5870,7 @@
5663
5870
  response = _a.sent();
5664
5871
  responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, this.config.serializableCache, this.config.persistencePlugin);
5665
5872
  responseHandler.validateTokenResponse(response.body);
5666
- return [2 /*return*/, responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request, undefined, undefined, true)];
5873
+ return [2 /*return*/, responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request, undefined, undefined, true, request.forceCache)];
5667
5874
  }
5668
5875
  });
5669
5876
  });
@@ -5735,13 +5942,16 @@
5735
5942
  * @param authority
5736
5943
  */
5737
5944
  RefreshTokenClient.prototype.executeTokenRequest = function (request, authority) {
5945
+ var _a;
5738
5946
  return __awaiter(this, void 0, void 0, function () {
5739
- var requestBody, queryParameters, headers, thumbprint, endpoint;
5740
- return __generator(this, function (_a) {
5741
- switch (_a.label) {
5742
- case 0: return [4 /*yield*/, this.createTokenRequestBody(request)];
5947
+ var acquireTokenMeasurement, requestBody, queryParameters, headers, thumbprint, endpoint;
5948
+ return __generator(this, function (_b) {
5949
+ switch (_b.label) {
5950
+ case 0:
5951
+ acquireTokenMeasurement = (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.startMeasurement(exports.PerformanceEvents.RefreshTokenClientExecuteTokenRequest, request.correlationId);
5952
+ return [4 /*yield*/, this.createTokenRequestBody(request)];
5743
5953
  case 1:
5744
- requestBody = _a.sent();
5954
+ requestBody = _b.sent();
5745
5955
  queryParameters = this.createTokenQueryParameters(request);
5746
5956
  headers = this.createTokenRequestHeaders(request.ccsCredential);
5747
5957
  thumbprint = {
@@ -5756,7 +5966,19 @@
5756
5966
  sshKid: request.sshKid
5757
5967
  };
5758
5968
  endpoint = UrlString.appendQueryString(authority.tokenEndpoint, queryParameters);
5759
- return [2 /*return*/, this.executePostToTokenEndpoint(endpoint, requestBody, headers, thumbprint)];
5969
+ return [2 /*return*/, this.executePostToTokenEndpoint(endpoint, requestBody, headers, thumbprint)
5970
+ .then(function (result) {
5971
+ acquireTokenMeasurement === null || acquireTokenMeasurement === void 0 ? void 0 : acquireTokenMeasurement.endMeasurement({
5972
+ success: true
5973
+ });
5974
+ return result;
5975
+ })
5976
+ .catch(function (error) {
5977
+ acquireTokenMeasurement === null || acquireTokenMeasurement === void 0 ? void 0 : acquireTokenMeasurement.endMeasurement({
5978
+ success: false
5979
+ });
5980
+ throw error;
5981
+ })];
5760
5982
  }
5761
5983
  });
5762
5984
  });
@@ -5777,11 +5999,14 @@
5777
5999
  * @param request
5778
6000
  */
5779
6001
  RefreshTokenClient.prototype.createTokenRequestBody = function (request) {
6002
+ var _a;
5780
6003
  return __awaiter(this, void 0, void 0, function () {
5781
- var parameterBuilder, correlationId, clientAssertion, popTokenGenerator, reqCnfData, clientInfo;
5782
- return __generator(this, function (_a) {
5783
- switch (_a.label) {
6004
+ var correlationId, acquireTokenMeasurement, parameterBuilder, clientAssertion, popTokenGenerator, reqCnfData, clientInfo;
6005
+ return __generator(this, function (_b) {
6006
+ switch (_b.label) {
5784
6007
  case 0:
6008
+ correlationId = request.correlationId;
6009
+ acquireTokenMeasurement = (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.startMeasurement(exports.PerformanceEvents.BaseClientCreateTokenRequestHeaders, correlationId);
5785
6010
  parameterBuilder = new RequestParameterBuilder();
5786
6011
  parameterBuilder.addClientId(this.config.authOptions.clientId);
5787
6012
  parameterBuilder.addScopes(request.scopes);
@@ -5793,7 +6018,6 @@
5793
6018
  if (this.serverTelemetryManager) {
5794
6019
  parameterBuilder.addServerTelemetry(this.serverTelemetryManager);
5795
6020
  }
5796
- correlationId = request.correlationId || this.config.cryptoInterface.createNewGuid();
5797
6021
  parameterBuilder.addCorrelationId(correlationId);
5798
6022
  parameterBuilder.addRefreshToken(request.refreshToken);
5799
6023
  if (this.config.clientCredentials.clientSecret) {
@@ -5808,7 +6032,7 @@
5808
6032
  popTokenGenerator = new PopTokenGenerator(this.cryptoUtils);
5809
6033
  return [4 /*yield*/, popTokenGenerator.generateCnf(request)];
5810
6034
  case 1:
5811
- reqCnfData = _a.sent();
6035
+ reqCnfData = _b.sent();
5812
6036
  // SPA PoP requires full Base64Url encoded req_cnf string (unhashed)
5813
6037
  parameterBuilder.addPopToken(reqCnfData.reqCnfString);
5814
6038
  return [3 /*break*/, 3];
@@ -5818,10 +6042,13 @@
5818
6042
  parameterBuilder.addSshJwk(request.sshJwk);
5819
6043
  }
5820
6044
  else {
6045
+ acquireTokenMeasurement === null || acquireTokenMeasurement === void 0 ? void 0 : acquireTokenMeasurement.endMeasurement({
6046
+ success: false
6047
+ });
5821
6048
  throw ClientConfigurationError.createMissingSshJwkError();
5822
6049
  }
5823
6050
  }
5824
- _a.label = 3;
6051
+ _b.label = 3;
5825
6052
  case 3:
5826
6053
  if (!StringUtils.isEmptyObj(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {
5827
6054
  parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);
@@ -5842,6 +6069,9 @@
5842
6069
  break;
5843
6070
  }
5844
6071
  }
6072
+ acquireTokenMeasurement === null || acquireTokenMeasurement === void 0 ? void 0 : acquireTokenMeasurement.endMeasurement({
6073
+ success: true
6074
+ });
5845
6075
  return [2 /*return*/, parameterBuilder.createQueryString()];
5846
6076
  }
5847
6077
  });
@@ -5850,7 +6080,7 @@
5850
6080
  return RefreshTokenClient;
5851
6081
  }(BaseClient));
5852
6082
 
5853
- /*! @azure/msal-common v7.0.0 2022-06-13 */
6083
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
5854
6084
 
5855
6085
  /*
5856
6086
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5858,8 +6088,8 @@
5858
6088
  */
5859
6089
  var SilentFlowClient = /** @class */ (function (_super) {
5860
6090
  __extends(SilentFlowClient, _super);
5861
- function SilentFlowClient(configuration) {
5862
- return _super.call(this, configuration) || this;
6091
+ function SilentFlowClient(configuration, performanceClient) {
6092
+ return _super.call(this, configuration, performanceClient) || this;
5863
6093
  }
5864
6094
  /**
5865
6095
  * Retrieves a token from cache if it is still valid, or uses the cached refresh token to renew
@@ -5878,7 +6108,7 @@
5878
6108
  case 2:
5879
6109
  e_1 = _a.sent();
5880
6110
  if (e_1 instanceof ClientAuthError && e_1.errorCode === ClientAuthErrorMessage.tokenRefreshRequired.code) {
5881
- refreshTokenClient = new RefreshTokenClient(this.config);
6111
+ refreshTokenClient = new RefreshTokenClient(this.config, this.performanceClient);
5882
6112
  return [2 /*return*/, refreshTokenClient.acquireTokenByRefreshToken(request)];
5883
6113
  }
5884
6114
  else {
@@ -5966,7 +6196,7 @@
5966
6196
  return SilentFlowClient;
5967
6197
  }(BaseClient));
5968
6198
 
5969
- /*! @azure/msal-common v7.0.0 2022-06-13 */
6199
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
5970
6200
  /*
5971
6201
  * Copyright (c) Microsoft Corporation. All rights reserved.
5972
6202
  * Licensed under the MIT License.
@@ -5974,10 +6204,20 @@
5974
6204
  function isOpenIdConfigResponse(response) {
5975
6205
  return (response.hasOwnProperty("authorization_endpoint") &&
5976
6206
  response.hasOwnProperty("token_endpoint") &&
5977
- response.hasOwnProperty("issuer"));
6207
+ response.hasOwnProperty("issuer") &&
6208
+ response.hasOwnProperty("jwks_uri"));
5978
6209
  }
5979
6210
 
5980
- /*! @azure/msal-common v7.0.0 2022-06-13 */
6211
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
6212
+ /*
6213
+ * Copyright (c) Microsoft Corporation. All rights reserved.
6214
+ * Licensed under the MIT License.
6215
+ */
6216
+ var rawMetdataJSON = { "endpointMetadata": { "https://login.microsoftonline.com/common/": { "token_endpoint": "https://login.microsoftonline.com/common/oauth2/v2.0/token", "token_endpoint_auth_methods_supported": ["client_secret_post", "private_key_jwt", "client_secret_basic"], "jwks_uri": "https://login.microsoftonline.com/common/discovery/v2.0/keys", "response_modes_supported": ["query", "fragment", "form_post"], "subject_types_supported": ["pairwise"], "id_token_signing_alg_values_supported": ["RS256"], "response_types_supported": ["code", "id_token", "code id_token", "id_token token"], "scopes_supported": ["openid", "profile", "email", "offline_access"], "issuer": "https://login.microsoftonline.com/{tenantid}/v2.0", "request_uri_parameter_supported": false, "userinfo_endpoint": "https://graph.microsoft.com/oidc/userinfo", "authorization_endpoint": "https://login.microsoftonline.com/common/oauth2/v2.0/authorize", "device_authorization_endpoint": "https://login.microsoftonline.com/common/oauth2/v2.0/devicecode", "http_logout_supported": true, "frontchannel_logout_supported": true, "end_session_endpoint": "https://login.microsoftonline.com/common/oauth2/v2.0/logout", "claims_supported": ["sub", "iss", "cloud_instance_name", "cloud_instance_host_name", "cloud_graph_host_name", "msgraph_host", "aud", "exp", "iat", "auth_time", "acr", "nonce", "preferred_username", "name", "tid", "ver", "at_hash", "c_hash", "email"], "kerberos_endpoint": "https://login.microsoftonline.com/common/kerberos", "tenant_region_scope": null, "cloud_instance_name": "microsoftonline.com", "cloud_graph_host_name": "graph.windows.net", "msgraph_host": "graph.microsoft.com", "rbac_url": "https://pas.windows.net" }, "https://login.chinacloudapi.cn/common/": { "token_endpoint": "https://login.chinacloudapi.cn/common/oauth2/v2.0/token", "token_endpoint_auth_methods_supported": ["client_secret_post", "private_key_jwt", "client_secret_basic"], "jwks_uri": "https://login.chinacloudapi.cn/common/discovery/v2.0/keys", "response_modes_supported": ["query", "fragment", "form_post"], "subject_types_supported": ["pairwise"], "id_token_signing_alg_values_supported": ["RS256"], "response_types_supported": ["code", "id_token", "code id_token", "id_token token"], "scopes_supported": ["openid", "profile", "email", "offline_access"], "issuer": "https://login.partner.microsoftonline.cn/{tenantid}/v2.0", "request_uri_parameter_supported": false, "userinfo_endpoint": "https://microsoftgraph.chinacloudapi.cn/oidc/userinfo", "authorization_endpoint": "https://login.chinacloudapi.cn/common/oauth2/v2.0/authorize", "device_authorization_endpoint": "https://login.chinacloudapi.cn/common/oauth2/v2.0/devicecode", "http_logout_supported": true, "frontchannel_logout_supported": true, "end_session_endpoint": "https://login.chinacloudapi.cn/common/oauth2/v2.0/logout", "claims_supported": ["sub", "iss", "cloud_instance_name", "cloud_instance_host_name", "cloud_graph_host_name", "msgraph_host", "aud", "exp", "iat", "auth_time", "acr", "nonce", "preferred_username", "name", "tid", "ver", "at_hash", "c_hash", "email"], "kerberos_endpoint": "https://login.chinacloudapi.cn/common/kerberos", "tenant_region_scope": null, "cloud_instance_name": "partner.microsoftonline.cn", "cloud_graph_host_name": "graph.chinacloudapi.cn", "msgraph_host": "microsoftgraph.chinacloudapi.cn", "rbac_url": "https://pas.chinacloudapi.cn" }, "https://login.microsoftonline.us/common/": { "token_endpoint": "https://login.microsoftonline.us/common/oauth2/v2.0/token", "token_endpoint_auth_methods_supported": ["client_secret_post", "private_key_jwt", "client_secret_basic"], "jwks_uri": "https://login.microsoftonline.us/common/discovery/v2.0/keys", "response_modes_supported": ["query", "fragment", "form_post"], "subject_types_supported": ["pairwise"], "id_token_signing_alg_values_supported": ["RS256"], "response_types_supported": ["code", "id_token", "code id_token", "id_token token"], "scopes_supported": ["openid", "profile", "email", "offline_access"], "issuer": "https://login.microsoftonline.us/{tenantid}/v2.0", "request_uri_parameter_supported": false, "userinfo_endpoint": "https://graph.microsoft.com/oidc/userinfo", "authorization_endpoint": "https://login.microsoftonline.us/common/oauth2/v2.0/authorize", "device_authorization_endpoint": "https://login.microsoftonline.us/common/oauth2/v2.0/devicecode", "http_logout_supported": true, "frontchannel_logout_supported": true, "end_session_endpoint": "https://login.microsoftonline.us/common/oauth2/v2.0/logout", "claims_supported": ["sub", "iss", "cloud_instance_name", "cloud_instance_host_name", "cloud_graph_host_name", "msgraph_host", "aud", "exp", "iat", "auth_time", "acr", "nonce", "preferred_username", "name", "tid", "ver", "at_hash", "c_hash", "email"], "kerberos_endpoint": "https://login.microsoftonline.us/common/kerberos", "tenant_region_scope": null, "cloud_instance_name": "microsoftonline.us", "cloud_graph_host_name": "graph.windows.net", "msgraph_host": "graph.microsoft.com", "rbac_url": "https://pasff.usgovcloudapi.net" }, "https://login.microsoftonline.com/consumers/": { "token_endpoint": "https://login.microsoftonline.com/consumers/oauth2/v2.0/token", "token_endpoint_auth_methods_supported": ["client_secret_post", "private_key_jwt", "client_secret_basic"], "jwks_uri": "https://login.microsoftonline.com/consumers/discovery/v2.0/keys", "response_modes_supported": ["query", "fragment", "form_post"], "subject_types_supported": ["pairwise"], "id_token_signing_alg_values_supported": ["RS256"], "response_types_supported": ["code", "id_token", "code id_token", "id_token token"], "scopes_supported": ["openid", "profile", "email", "offline_access"], "issuer": "https://login.microsoftonline.com/9188040d-6c67-4c5b-b112-36a304b66dad/v2.0", "request_uri_parameter_supported": false, "userinfo_endpoint": "https://graph.microsoft.com/oidc/userinfo", "authorization_endpoint": "https://login.microsoftonline.com/consumers/oauth2/v2.0/authorize", "device_authorization_endpoint": "https://login.microsoftonline.com/consumers/oauth2/v2.0/devicecode", "http_logout_supported": true, "frontchannel_logout_supported": true, "end_session_endpoint": "https://login.microsoftonline.com/consumers/oauth2/v2.0/logout", "claims_supported": ["sub", "iss", "cloud_instance_name", "cloud_instance_host_name", "cloud_graph_host_name", "msgraph_host", "aud", "exp", "iat", "auth_time", "acr", "nonce", "preferred_username", "name", "tid", "ver", "at_hash", "c_hash", "email"], "kerberos_endpoint": "https://login.microsoftonline.com/consumers/kerberos", "tenant_region_scope": null, "cloud_instance_name": "microsoftonline.com", "cloud_graph_host_name": "graph.windows.net", "msgraph_host": "graph.microsoft.com", "rbac_url": "https://pas.windows.net" }, "https://login.chinacloudapi.cn/consumers/": { "token_endpoint": "https://login.chinacloudapi.cn/consumers/oauth2/v2.0/token", "token_endpoint_auth_methods_supported": ["client_secret_post", "private_key_jwt", "client_secret_basic"], "jwks_uri": "https://login.chinacloudapi.cn/consumers/discovery/v2.0/keys", "response_modes_supported": ["query", "fragment", "form_post"], "subject_types_supported": ["pairwise"], "id_token_signing_alg_values_supported": ["RS256"], "response_types_supported": ["code", "id_token", "code id_token", "id_token token"], "scopes_supported": ["openid", "profile", "email", "offline_access"], "issuer": "https://login.partner.microsoftonline.cn/9188040d-6c67-4c5b-b112-36a304b66dad/v2.0", "request_uri_parameter_supported": false, "userinfo_endpoint": "https://microsoftgraph.chinacloudapi.cn/oidc/userinfo", "authorization_endpoint": "https://login.chinacloudapi.cn/consumers/oauth2/v2.0/authorize", "device_authorization_endpoint": "https://login.chinacloudapi.cn/consumers/oauth2/v2.0/devicecode", "http_logout_supported": true, "frontchannel_logout_supported": true, "end_session_endpoint": "https://login.chinacloudapi.cn/consumers/oauth2/v2.0/logout", "claims_supported": ["sub", "iss", "cloud_instance_name", "cloud_instance_host_name", "cloud_graph_host_name", "msgraph_host", "aud", "exp", "iat", "auth_time", "acr", "nonce", "preferred_username", "name", "tid", "ver", "at_hash", "c_hash", "email"], "kerberos_endpoint": "https://login.chinacloudapi.cn/consumers/kerberos", "tenant_region_scope": null, "cloud_instance_name": "partner.microsoftonline.cn", "cloud_graph_host_name": "graph.chinacloudapi.cn", "msgraph_host": "microsoftgraph.chinacloudapi.cn", "rbac_url": "https://pas.chinacloudapi.cn" }, "https://login.microsoftonline.us/consumers/": { "token_endpoint": "https://login.microsoftonline.us/consumers/oauth2/v2.0/token", "token_endpoint_auth_methods_supported": ["client_secret_post", "private_key_jwt", "client_secret_basic"], "jwks_uri": "https://login.microsoftonline.us/consumers/discovery/v2.0/keys", "response_modes_supported": ["query", "fragment", "form_post"], "subject_types_supported": ["pairwise"], "id_token_signing_alg_values_supported": ["RS256"], "response_types_supported": ["code", "id_token", "code id_token", "id_token token"], "scopes_supported": ["openid", "profile", "email", "offline_access"], "issuer": "https://login.microsoftonline.us/9188040d-6c67-4c5b-b112-36a304b66dad/v2.0", "request_uri_parameter_supported": false, "userinfo_endpoint": "https://graph.microsoft.com/oidc/userinfo", "authorization_endpoint": "https://login.microsoftonline.us/consumers/oauth2/v2.0/authorize", "device_authorization_endpoint": "https://login.microsoftonline.us/consumers/oauth2/v2.0/devicecode", "http_logout_supported": true, "frontchannel_logout_supported": true, "end_session_endpoint": "https://login.microsoftonline.us/consumers/oauth2/v2.0/logout", "claims_supported": ["sub", "iss", "cloud_instance_name", "cloud_instance_host_name", "cloud_graph_host_name", "msgraph_host", "aud", "exp", "iat", "auth_time", "acr", "nonce", "preferred_username", "name", "tid", "ver", "at_hash", "c_hash", "email"], "kerberos_endpoint": "https://login.microsoftonline.us/consumers/kerberos", "tenant_region_scope": null, "cloud_instance_name": "microsoftonline.us", "cloud_graph_host_name": "graph.windows.net", "msgraph_host": "graph.microsoft.com", "rbac_url": "https://pasff.usgovcloudapi.net" }, "https://login.microsoftonline.com/organizations/": { "token_endpoint": "https://login.microsoftonline.com/organizations/oauth2/v2.0/token", "token_endpoint_auth_methods_supported": ["client_secret_post", "private_key_jwt", "client_secret_basic"], "jwks_uri": "https://login.microsoftonline.com/organizations/discovery/v2.0/keys", "response_modes_supported": ["query", "fragment", "form_post"], "subject_types_supported": ["pairwise"], "id_token_signing_alg_values_supported": ["RS256"], "response_types_supported": ["code", "id_token", "code id_token", "id_token token"], "scopes_supported": ["openid", "profile", "email", "offline_access"], "issuer": "https://login.microsoftonline.com/{tenantid}/v2.0", "request_uri_parameter_supported": false, "userinfo_endpoint": "https://graph.microsoft.com/oidc/userinfo", "authorization_endpoint": "https://login.microsoftonline.com/organizations/oauth2/v2.0/authorize", "device_authorization_endpoint": "https://login.microsoftonline.com/organizations/oauth2/v2.0/devicecode", "http_logout_supported": true, "frontchannel_logout_supported": true, "end_session_endpoint": "https://login.microsoftonline.com/organizations/oauth2/v2.0/logout", "claims_supported": ["sub", "iss", "cloud_instance_name", "cloud_instance_host_name", "cloud_graph_host_name", "msgraph_host", "aud", "exp", "iat", "auth_time", "acr", "nonce", "preferred_username", "name", "tid", "ver", "at_hash", "c_hash", "email"], "kerberos_endpoint": "https://login.microsoftonline.com/organizations/kerberos", "tenant_region_scope": null, "cloud_instance_name": "microsoftonline.com", "cloud_graph_host_name": "graph.windows.net", "msgraph_host": "graph.microsoft.com", "rbac_url": "https://pas.windows.net" }, "https://login.chinacloudapi.cn/organizations/": { "token_endpoint": "https://login.chinacloudapi.cn/organizations/oauth2/v2.0/token", "token_endpoint_auth_methods_supported": ["client_secret_post", "private_key_jwt", "client_secret_basic"], "jwks_uri": "https://login.chinacloudapi.cn/organizations/discovery/v2.0/keys", "response_modes_supported": ["query", "fragment", "form_post"], "subject_types_supported": ["pairwise"], "id_token_signing_alg_values_supported": ["RS256"], "response_types_supported": ["code", "id_token", "code id_token", "id_token token"], "scopes_supported": ["openid", "profile", "email", "offline_access"], "issuer": "https://login.partner.microsoftonline.cn/{tenantid}/v2.0", "request_uri_parameter_supported": false, "userinfo_endpoint": "https://microsoftgraph.chinacloudapi.cn/oidc/userinfo", "authorization_endpoint": "https://login.chinacloudapi.cn/organizations/oauth2/v2.0/authorize", "device_authorization_endpoint": "https://login.chinacloudapi.cn/organizations/oauth2/v2.0/devicecode", "http_logout_supported": true, "frontchannel_logout_supported": true, "end_session_endpoint": "https://login.chinacloudapi.cn/organizations/oauth2/v2.0/logout", "claims_supported": ["sub", "iss", "cloud_instance_name", "cloud_instance_host_name", "cloud_graph_host_name", "msgraph_host", "aud", "exp", "iat", "auth_time", "acr", "nonce", "preferred_username", "name", "tid", "ver", "at_hash", "c_hash", "email"], "kerberos_endpoint": "https://login.chinacloudapi.cn/organizations/kerberos", "tenant_region_scope": null, "cloud_instance_name": "partner.microsoftonline.cn", "cloud_graph_host_name": "graph.chinacloudapi.cn", "msgraph_host": "microsoftgraph.chinacloudapi.cn", "rbac_url": "https://pas.chinacloudapi.cn" }, "https://login.microsoftonline.us/organizations/": { "token_endpoint": "https://login.microsoftonline.us/organizations/oauth2/v2.0/token", "token_endpoint_auth_methods_supported": ["client_secret_post", "private_key_jwt", "client_secret_basic"], "jwks_uri": "https://login.microsoftonline.us/organizations/discovery/v2.0/keys", "response_modes_supported": ["query", "fragment", "form_post"], "subject_types_supported": ["pairwise"], "id_token_signing_alg_values_supported": ["RS256"], "response_types_supported": ["code", "id_token", "code id_token", "id_token token"], "scopes_supported": ["openid", "profile", "email", "offline_access"], "issuer": "https://login.microsoftonline.us/{tenantid}/v2.0", "request_uri_parameter_supported": false, "userinfo_endpoint": "https://graph.microsoft.com/oidc/userinfo", "authorization_endpoint": "https://login.microsoftonline.us/organizations/oauth2/v2.0/authorize", "device_authorization_endpoint": "https://login.microsoftonline.us/organizations/oauth2/v2.0/devicecode", "http_logout_supported": true, "frontchannel_logout_supported": true, "end_session_endpoint": "https://login.microsoftonline.us/organizations/oauth2/v2.0/logout", "claims_supported": ["sub", "iss", "cloud_instance_name", "cloud_instance_host_name", "cloud_graph_host_name", "msgraph_host", "aud", "exp", "iat", "auth_time", "acr", "nonce", "preferred_username", "name", "tid", "ver", "at_hash", "c_hash", "email"], "kerberos_endpoint": "https://login.microsoftonline.us/organizations/kerberos", "tenant_region_scope": null, "cloud_instance_name": "microsoftonline.us", "cloud_graph_host_name": "graph.windows.net", "msgraph_host": "graph.microsoft.com", "rbac_url": "https://pasff.usgovcloudapi.net" } }, "instanceDiscoveryMetadata": { "https://login.microsoftonline.com/common/": { "tenant_discovery_endpoint": "https://login.microsoftonline.com/common/v2.0/.well-known/openid-configuration", "api-version": "1.1", "metadata": [{ "preferred_network": "login.microsoftonline.com", "preferred_cache": "login.windows.net", "aliases": ["login.microsoftonline.com", "login.windows.net", "login.microsoft.com", "sts.windows.net"] }, { "preferred_network": "login.partner.microsoftonline.cn", "preferred_cache": "login.partner.microsoftonline.cn", "aliases": ["login.partner.microsoftonline.cn", "login.chinacloudapi.cn"] }, { "preferred_network": "login.microsoftonline.de", "preferred_cache": "login.microsoftonline.de", "aliases": ["login.microsoftonline.de"] }, { "preferred_network": "login.microsoftonline.us", "preferred_cache": "login.microsoftonline.us", "aliases": ["login.microsoftonline.us", "login.usgovcloudapi.net"] }, { "preferred_network": "login-us.microsoftonline.com", "preferred_cache": "login-us.microsoftonline.com", "aliases": ["login-us.microsoftonline.com"] }] }, "https://login.chinacloudapi.cn/common/": { "tenant_discovery_endpoint": "https://login.chinacloudapi.cn/common/v2.0/.well-known/openid-configuration", "api-version": "1.1", "metadata": [{ "preferred_network": "login.microsoftonline.com", "preferred_cache": "login.windows.net", "aliases": ["login.microsoftonline.com", "login.windows.net", "login.microsoft.com", "sts.windows.net"] }, { "preferred_network": "login.partner.microsoftonline.cn", "preferred_cache": "login.partner.microsoftonline.cn", "aliases": ["login.partner.microsoftonline.cn", "login.chinacloudapi.cn"] }, { "preferred_network": "login.microsoftonline.de", "preferred_cache": "login.microsoftonline.de", "aliases": ["login.microsoftonline.de"] }, { "preferred_network": "login.microsoftonline.us", "preferred_cache": "login.microsoftonline.us", "aliases": ["login.microsoftonline.us", "login.usgovcloudapi.net"] }, { "preferred_network": "login-us.microsoftonline.com", "preferred_cache": "login-us.microsoftonline.com", "aliases": ["login-us.microsoftonline.com"] }] }, "https://login.microsoftonline.us/common/": { "tenant_discovery_endpoint": "https://login.microsoftonline.us/common/v2.0/.well-known/openid-configuration", "api-version": "1.1", "metadata": [{ "preferred_network": "login.microsoftonline.com", "preferred_cache": "login.windows.net", "aliases": ["login.microsoftonline.com", "login.windows.net", "login.microsoft.com", "sts.windows.net"] }, { "preferred_network": "login.partner.microsoftonline.cn", "preferred_cache": "login.partner.microsoftonline.cn", "aliases": ["login.partner.microsoftonline.cn", "login.chinacloudapi.cn"] }, { "preferred_network": "login.microsoftonline.de", "preferred_cache": "login.microsoftonline.de", "aliases": ["login.microsoftonline.de"] }, { "preferred_network": "login.microsoftonline.us", "preferred_cache": "login.microsoftonline.us", "aliases": ["login.microsoftonline.us", "login.usgovcloudapi.net"] }, { "preferred_network": "login-us.microsoftonline.com", "preferred_cache": "login-us.microsoftonline.com", "aliases": ["login-us.microsoftonline.com"] }] }, "https://login.microsoftonline.com/consumers/": { "tenant_discovery_endpoint": "https://login.microsoftonline.com/consumers/v2.0/.well-known/openid-configuration", "api-version": "1.1", "metadata": [{ "preferred_network": "login.microsoftonline.com", "preferred_cache": "login.windows.net", "aliases": ["login.microsoftonline.com", "login.windows.net", "login.microsoft.com", "sts.windows.net"] }, { "preferred_network": "login.partner.microsoftonline.cn", "preferred_cache": "login.partner.microsoftonline.cn", "aliases": ["login.partner.microsoftonline.cn", "login.chinacloudapi.cn"] }, { "preferred_network": "login.microsoftonline.de", "preferred_cache": "login.microsoftonline.de", "aliases": ["login.microsoftonline.de"] }, { "preferred_network": "login.microsoftonline.us", "preferred_cache": "login.microsoftonline.us", "aliases": ["login.microsoftonline.us", "login.usgovcloudapi.net"] }, { "preferred_network": "login-us.microsoftonline.com", "preferred_cache": "login-us.microsoftonline.com", "aliases": ["login-us.microsoftonline.com"] }] }, "https://login.chinacloudapi.cn/consumers/": { "tenant_discovery_endpoint": "https://login.chinacloudapi.cn/consumers/v2.0/.well-known/openid-configuration", "api-version": "1.1", "metadata": [{ "preferred_network": "login.microsoftonline.com", "preferred_cache": "login.windows.net", "aliases": ["login.microsoftonline.com", "login.windows.net", "login.microsoft.com", "sts.windows.net"] }, { "preferred_network": "login.partner.microsoftonline.cn", "preferred_cache": "login.partner.microsoftonline.cn", "aliases": ["login.partner.microsoftonline.cn", "login.chinacloudapi.cn"] }, { "preferred_network": "login.microsoftonline.de", "preferred_cache": "login.microsoftonline.de", "aliases": ["login.microsoftonline.de"] }, { "preferred_network": "login.microsoftonline.us", "preferred_cache": "login.microsoftonline.us", "aliases": ["login.microsoftonline.us", "login.usgovcloudapi.net"] }, { "preferred_network": "login-us.microsoftonline.com", "preferred_cache": "login-us.microsoftonline.com", "aliases": ["login-us.microsoftonline.com"] }] }, "https://login.microsoftonline.us/consumers/": { "tenant_discovery_endpoint": "https://login.microsoftonline.us/consumers/v2.0/.well-known/openid-configuration", "api-version": "1.1", "metadata": [{ "preferred_network": "login.microsoftonline.com", "preferred_cache": "login.windows.net", "aliases": ["login.microsoftonline.com", "login.windows.net", "login.microsoft.com", "sts.windows.net"] }, { "preferred_network": "login.partner.microsoftonline.cn", "preferred_cache": "login.partner.microsoftonline.cn", "aliases": ["login.partner.microsoftonline.cn", "login.chinacloudapi.cn"] }, { "preferred_network": "login.microsoftonline.de", "preferred_cache": "login.microsoftonline.de", "aliases": ["login.microsoftonline.de"] }, { "preferred_network": "login.microsoftonline.us", "preferred_cache": "login.microsoftonline.us", "aliases": ["login.microsoftonline.us", "login.usgovcloudapi.net"] }, { "preferred_network": "login-us.microsoftonline.com", "preferred_cache": "login-us.microsoftonline.com", "aliases": ["login-us.microsoftonline.com"] }] }, "https://login.microsoftonline.com/organizations/": { "tenant_discovery_endpoint": "https://login.microsoftonline.com/organizations/v2.0/.well-known/openid-configuration", "api-version": "1.1", "metadata": [{ "preferred_network": "login.microsoftonline.com", "preferred_cache": "login.windows.net", "aliases": ["login.microsoftonline.com", "login.windows.net", "login.microsoft.com", "sts.windows.net"] }, { "preferred_network": "login.partner.microsoftonline.cn", "preferred_cache": "login.partner.microsoftonline.cn", "aliases": ["login.partner.microsoftonline.cn", "login.chinacloudapi.cn"] }, { "preferred_network": "login.microsoftonline.de", "preferred_cache": "login.microsoftonline.de", "aliases": ["login.microsoftonline.de"] }, { "preferred_network": "login.microsoftonline.us", "preferred_cache": "login.microsoftonline.us", "aliases": ["login.microsoftonline.us", "login.usgovcloudapi.net"] }, { "preferred_network": "login-us.microsoftonline.com", "preferred_cache": "login-us.microsoftonline.com", "aliases": ["login-us.microsoftonline.com"] }] }, "https://login.chinacloudapi.cn/organizations/": { "tenant_discovery_endpoint": "https://login.chinacloudapi.cn/organizations/v2.0/.well-known/openid-configuration", "api-version": "1.1", "metadata": [{ "preferred_network": "login.microsoftonline.com", "preferred_cache": "login.windows.net", "aliases": ["login.microsoftonline.com", "login.windows.net", "login.microsoft.com", "sts.windows.net"] }, { "preferred_network": "login.partner.microsoftonline.cn", "preferred_cache": "login.partner.microsoftonline.cn", "aliases": ["login.partner.microsoftonline.cn", "login.chinacloudapi.cn"] }, { "preferred_network": "login.microsoftonline.de", "preferred_cache": "login.microsoftonline.de", "aliases": ["login.microsoftonline.de"] }, { "preferred_network": "login.microsoftonline.us", "preferred_cache": "login.microsoftonline.us", "aliases": ["login.microsoftonline.us", "login.usgovcloudapi.net"] }, { "preferred_network": "login-us.microsoftonline.com", "preferred_cache": "login-us.microsoftonline.com", "aliases": ["login-us.microsoftonline.com"] }] }, "https://login.microsoftonline.us/organizations/": { "tenant_discovery_endpoint": "https://login.microsoftonline.us/organizations/v2.0/.well-known/openid-configuration", "api-version": "1.1", "metadata": [{ "preferred_network": "login.microsoftonline.com", "preferred_cache": "login.windows.net", "aliases": ["login.microsoftonline.com", "login.windows.net", "login.microsoft.com", "sts.windows.net"] }, { "preferred_network": "login.partner.microsoftonline.cn", "preferred_cache": "login.partner.microsoftonline.cn", "aliases": ["login.partner.microsoftonline.cn", "login.chinacloudapi.cn"] }, { "preferred_network": "login.microsoftonline.de", "preferred_cache": "login.microsoftonline.de", "aliases": ["login.microsoftonline.de"] }, { "preferred_network": "login.microsoftonline.us", "preferred_cache": "login.microsoftonline.us", "aliases": ["login.microsoftonline.us", "login.usgovcloudapi.net"] }, { "preferred_network": "login-us.microsoftonline.com", "preferred_cache": "login-us.microsoftonline.com", "aliases": ["login-us.microsoftonline.com"] }] } } };
6217
+ var EndpointMetadata = rawMetdataJSON.endpointMetadata;
6218
+ var InstanceDiscoveryMetadata = rawMetdataJSON.instanceDiscoveryMetadata;
6219
+
6220
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
5981
6221
  /*
5982
6222
  * Copyright (c) Microsoft Corporation. All rights reserved.
5983
6223
  * Licensed under the MIT License.
@@ -5991,7 +6231,7 @@
5991
6231
  ProtocolMode["OIDC"] = "OIDC";
5992
6232
  })(exports.ProtocolMode || (exports.ProtocolMode = {}));
5993
6233
 
5994
- /*! @azure/msal-common v7.0.0 2022-06-13 */
6234
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
5995
6235
 
5996
6236
  /*
5997
6237
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6023,6 +6263,7 @@
6023
6263
  this.end_session_endpoint = metadata.end_session_endpoint;
6024
6264
  this.issuer = metadata.issuer;
6025
6265
  this.endpointsFromNetwork = fromNetwork;
6266
+ this.jwks_uri = metadata.jwks_uri;
6026
6267
  };
6027
6268
  /**
6028
6269
  * Save the authority that was used to create this cache entry
@@ -6061,12 +6302,13 @@
6061
6302
  entity.hasOwnProperty("issuer") &&
6062
6303
  entity.hasOwnProperty("aliasesFromNetwork") &&
6063
6304
  entity.hasOwnProperty("endpointsFromNetwork") &&
6064
- entity.hasOwnProperty("expiresAt"));
6305
+ entity.hasOwnProperty("expiresAt") &&
6306
+ entity.hasOwnProperty("jwks_uri"));
6065
6307
  };
6066
6308
  return AuthorityMetadataEntity;
6067
6309
  }());
6068
6310
 
6069
- /*! @azure/msal-common v7.0.0 2022-06-13 */
6311
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
6070
6312
  /*
6071
6313
  * Copyright (c) Microsoft Corporation. All rights reserved.
6072
6314
  * Licensed under the MIT License.
@@ -6076,7 +6318,7 @@
6076
6318
  response.hasOwnProperty("metadata"));
6077
6319
  }
6078
6320
 
6079
- /*! @azure/msal-common v7.0.0 2022-06-13 */
6321
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
6080
6322
 
6081
6323
  /*
6082
6324
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6198,7 +6440,7 @@
6198
6440
  return RegionDiscovery;
6199
6441
  }());
6200
6442
 
6201
- /*! @azure/msal-common v7.0.0 2022-06-13 */
6443
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
6202
6444
 
6203
6445
  /*
6204
6446
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6383,6 +6625,22 @@
6383
6625
  enumerable: false,
6384
6626
  configurable: true
6385
6627
  });
6628
+ Object.defineProperty(Authority.prototype, "jwksUri", {
6629
+ /**
6630
+ * Jwks_uri for token signing keys
6631
+ */
6632
+ get: function () {
6633
+ if (this.discoveryComplete()) {
6634
+ var endpoint = this.replacePath(this.metadata.jwks_uri);
6635
+ return this.replaceTenant(endpoint);
6636
+ }
6637
+ else {
6638
+ throw ClientAuthError.createEndpointDiscoveryIncompleteError("Discovery incomplete.");
6639
+ }
6640
+ },
6641
+ enumerable: false,
6642
+ configurable: true
6643
+ });
6386
6644
  /**
6387
6645
  * Replaces tenant in url path with current tenant. Defaults to common.
6388
6646
  * @param urlString
@@ -6466,11 +6724,11 @@
6466
6724
  * @param metadataEntity
6467
6725
  */
6468
6726
  Authority.prototype.updateEndpointMetadata = function (metadataEntity) {
6469
- var _a;
6727
+ var _a, _b;
6470
6728
  return __awaiter(this, void 0, void 0, function () {
6471
- var metadata, autodetectedRegionName, azureRegion;
6472
- return __generator(this, function (_b) {
6473
- switch (_b.label) {
6729
+ var metadata, harcodedMetadata;
6730
+ return __generator(this, function (_c) {
6731
+ switch (_c.label) {
6474
6732
  case 0:
6475
6733
  metadata = this.getEndpointMetadataFromConfig();
6476
6734
  if (metadata) {
@@ -6481,41 +6739,30 @@
6481
6739
  // No need to update
6482
6740
  return [2 /*return*/, AuthorityMetadataSource.CACHE];
6483
6741
  }
6742
+ harcodedMetadata = this.getEndpointMetadataFromHardcodedValues();
6484
6743
  return [4 /*yield*/, this.getEndpointMetadataFromNetwork()];
6485
6744
  case 1:
6486
- metadata = _b.sent();
6745
+ metadata = _c.sent();
6487
6746
  if (!metadata) return [3 /*break*/, 4];
6488
6747
  if (!((_a = this.authorityOptions.azureRegionConfiguration) === null || _a === void 0 ? void 0 : _a.azureRegion)) return [3 /*break*/, 3];
6489
- return [4 /*yield*/, this.regionDiscovery.detectRegion(this.authorityOptions.azureRegionConfiguration.environmentRegion, this.regionDiscoveryMetadata, this.proxyUrl)];
6748
+ return [4 /*yield*/, this.updateMetadataWithRegionalInformation(metadata)];
6490
6749
  case 2:
6491
- autodetectedRegionName = _b.sent();
6492
- azureRegion = this.authorityOptions.azureRegionConfiguration.azureRegion === Constants.AZURE_REGION_AUTO_DISCOVER_FLAG
6493
- ? autodetectedRegionName
6494
- : this.authorityOptions.azureRegionConfiguration.azureRegion;
6495
- if (this.authorityOptions.azureRegionConfiguration.azureRegion === Constants.AZURE_REGION_AUTO_DISCOVER_FLAG) {
6496
- this.regionDiscoveryMetadata.region_outcome = autodetectedRegionName ?
6497
- RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_SUCCESSFUL :
6498
- RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_FAILED;
6499
- }
6500
- else {
6501
- if (autodetectedRegionName) {
6502
- this.regionDiscoveryMetadata.region_outcome = (this.authorityOptions.azureRegionConfiguration.azureRegion === autodetectedRegionName) ?
6503
- RegionDiscoveryOutcomes.CONFIGURED_MATCHES_DETECTED :
6504
- RegionDiscoveryOutcomes.CONFIGURED_NOT_DETECTED;
6505
- }
6506
- else {
6507
- this.regionDiscoveryMetadata.region_outcome = RegionDiscoveryOutcomes.CONFIGURED_NO_AUTO_DETECTION;
6508
- }
6509
- }
6510
- if (azureRegion) {
6511
- this.regionDiscoveryMetadata.region_used = azureRegion;
6512
- metadata = Authority.replaceWithRegionalInformation(metadata, azureRegion);
6513
- }
6514
- _b.label = 3;
6750
+ metadata = _c.sent();
6751
+ _c.label = 3;
6515
6752
  case 3:
6516
6753
  metadataEntity.updateEndpointMetadata(metadata, true);
6517
6754
  return [2 /*return*/, AuthorityMetadataSource.NETWORK];
6518
- case 4: throw ClientAuthError.createUnableToGetOpenidConfigError(this.defaultOpenIdConfigurationEndpoint);
6755
+ case 4:
6756
+ if (!(harcodedMetadata && !this.authorityOptions.skipAuthorityMetadataCache)) return [3 /*break*/, 7];
6757
+ if (!((_b = this.authorityOptions.azureRegionConfiguration) === null || _b === void 0 ? void 0 : _b.azureRegion)) return [3 /*break*/, 6];
6758
+ return [4 /*yield*/, this.updateMetadataWithRegionalInformation(harcodedMetadata)];
6759
+ case 5:
6760
+ harcodedMetadata = _c.sent();
6761
+ _c.label = 6;
6762
+ case 6:
6763
+ metadataEntity.updateEndpointMetadata(harcodedMetadata, false);
6764
+ return [2 /*return*/, AuthorityMetadataSource.HARDCODED_VALUES];
6765
+ case 7: throw ClientAuthError.createUnableToGetOpenidConfigError(this.defaultOpenIdConfigurationEndpoint);
6519
6766
  }
6520
6767
  });
6521
6768
  });
@@ -6546,6 +6793,8 @@
6546
6793
  };
6547
6794
  /**
6548
6795
  * Gets OAuth endpoints from the given OpenID configuration endpoint.
6796
+ *
6797
+ * @param hasHardcodedMetadata boolean
6549
6798
  */
6550
6799
  Authority.prototype.getEndpointMetadataFromNetwork = function () {
6551
6800
  return __awaiter(this, void 0, void 0, function () {
@@ -6573,34 +6822,87 @@
6573
6822
  });
6574
6823
  };
6575
6824
  /**
6576
- * Updates the AuthorityMetadataEntity with new aliases, preferred_network and preferred_cache and returns where the information was retrived from
6577
- * @param cachedMetadata
6578
- * @param newMetadata
6825
+ * Get OAuth endpoints for common authorities.
6579
6826
  */
6580
- Authority.prototype.updateCloudDiscoveryMetadata = function (metadataEntity) {
6827
+ Authority.prototype.getEndpointMetadataFromHardcodedValues = function () {
6828
+ if (this.canonicalAuthority in EndpointMetadata) {
6829
+ return EndpointMetadata[this.canonicalAuthority];
6830
+ }
6831
+ return null;
6832
+ };
6833
+ /**
6834
+ * Update the retrieved metadata with regional information.
6835
+ */
6836
+ Authority.prototype.updateMetadataWithRegionalInformation = function (metadata) {
6837
+ var _a, _b, _c, _d, _e;
6581
6838
  return __awaiter(this, void 0, void 0, function () {
6582
- var metadata;
6583
- return __generator(this, function (_a) {
6584
- switch (_a.label) {
6585
- case 0:
6586
- metadata = this.getCloudDiscoveryMetadataFromConfig();
6587
- if (metadata) {
6588
- metadataEntity.updateCloudDiscoveryMetadata(metadata, false);
6589
- return [2 /*return*/, AuthorityMetadataSource.CONFIG];
6590
- }
6591
- // If The cached metadata came from config but that config was not passed to this instance, we must go to the network
6592
- if (this.isAuthoritySameType(metadataEntity) && metadataEntity.aliasesFromNetwork && !metadataEntity.isExpired()) {
6593
- // No need to update
6594
- return [2 /*return*/, AuthorityMetadataSource.CACHE];
6595
- }
6596
- return [4 /*yield*/, this.getCloudDiscoveryMetadataFromNetwork()];
6839
+ var autodetectedRegionName, azureRegion;
6840
+ return __generator(this, function (_f) {
6841
+ switch (_f.label) {
6842
+ case 0: return [4 /*yield*/, this.regionDiscovery.detectRegion((_a = this.authorityOptions.azureRegionConfiguration) === null || _a === void 0 ? void 0 : _a.environmentRegion, this.regionDiscoveryMetadata, this.proxyUrl)];
6597
6843
  case 1:
6598
- metadata = _a.sent();
6599
- if (metadata) {
6600
- metadataEntity.updateCloudDiscoveryMetadata(metadata, true);
6601
- return [2 /*return*/, AuthorityMetadataSource.NETWORK];
6602
- }
6603
- else {
6844
+ autodetectedRegionName = _f.sent();
6845
+ azureRegion = ((_b = this.authorityOptions.azureRegionConfiguration) === null || _b === void 0 ? void 0 : _b.azureRegion) === Constants.AZURE_REGION_AUTO_DISCOVER_FLAG
6846
+ ? autodetectedRegionName
6847
+ : (_c = this.authorityOptions.azureRegionConfiguration) === null || _c === void 0 ? void 0 : _c.azureRegion;
6848
+ if (((_d = this.authorityOptions.azureRegionConfiguration) === null || _d === void 0 ? void 0 : _d.azureRegion) === Constants.AZURE_REGION_AUTO_DISCOVER_FLAG) {
6849
+ this.regionDiscoveryMetadata.region_outcome = autodetectedRegionName ?
6850
+ RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_SUCCESSFUL :
6851
+ RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_FAILED;
6852
+ }
6853
+ else {
6854
+ if (autodetectedRegionName) {
6855
+ this.regionDiscoveryMetadata.region_outcome = (((_e = this.authorityOptions.azureRegionConfiguration) === null || _e === void 0 ? void 0 : _e.azureRegion) === autodetectedRegionName) ?
6856
+ RegionDiscoveryOutcomes.CONFIGURED_MATCHES_DETECTED :
6857
+ RegionDiscoveryOutcomes.CONFIGURED_NOT_DETECTED;
6858
+ }
6859
+ else {
6860
+ this.regionDiscoveryMetadata.region_outcome = RegionDiscoveryOutcomes.CONFIGURED_NO_AUTO_DETECTION;
6861
+ }
6862
+ }
6863
+ if (azureRegion) {
6864
+ this.regionDiscoveryMetadata.region_used = azureRegion;
6865
+ return [2 /*return*/, Authority.replaceWithRegionalInformation(metadata, azureRegion)];
6866
+ }
6867
+ return [2 /*return*/, metadata];
6868
+ }
6869
+ });
6870
+ });
6871
+ };
6872
+ /**
6873
+ * Updates the AuthorityMetadataEntity with new aliases, preferred_network and preferred_cache and returns where the information was retrived from
6874
+ * @param cachedMetadata
6875
+ * @param newMetadata
6876
+ */
6877
+ Authority.prototype.updateCloudDiscoveryMetadata = function (metadataEntity) {
6878
+ return __awaiter(this, void 0, void 0, function () {
6879
+ var metadata, harcodedMetadata;
6880
+ return __generator(this, function (_a) {
6881
+ switch (_a.label) {
6882
+ case 0:
6883
+ metadata = this.getCloudDiscoveryMetadataFromConfig();
6884
+ if (metadata) {
6885
+ metadataEntity.updateCloudDiscoveryMetadata(metadata, false);
6886
+ return [2 /*return*/, AuthorityMetadataSource.CONFIG];
6887
+ }
6888
+ // If The cached metadata came from config but that config was not passed to this instance, we must go to the network
6889
+ if (this.isAuthoritySameType(metadataEntity) && metadataEntity.aliasesFromNetwork && !metadataEntity.isExpired()) {
6890
+ // No need to update
6891
+ return [2 /*return*/, AuthorityMetadataSource.CACHE];
6892
+ }
6893
+ harcodedMetadata = this.getCloudDiscoveryMetadataFromHarcodedValues();
6894
+ return [4 /*yield*/, this.getCloudDiscoveryMetadataFromNetwork()];
6895
+ case 1:
6896
+ metadata = _a.sent();
6897
+ if (metadata) {
6898
+ metadataEntity.updateCloudDiscoveryMetadata(metadata, true);
6899
+ return [2 /*return*/, AuthorityMetadataSource.NETWORK];
6900
+ }
6901
+ if (harcodedMetadata && !this.options.skipAuthorityMetadataCache) {
6902
+ metadataEntity.updateCloudDiscoveryMetadata(harcodedMetadata, false);
6903
+ return [2 /*return*/, AuthorityMetadataSource.HARDCODED_VALUES];
6904
+ }
6905
+ else {
6604
6906
  // Metadata could not be obtained from config, cache or network
6605
6907
  throw ClientConfigurationError.createUntrustedAuthorityError();
6606
6908
  }
@@ -6633,7 +6935,8 @@
6633
6935
  };
6634
6936
  /**
6635
6937
  * Called to get metadata from network if CloudDiscoveryMetadata was not populated by config
6636
- * @param networkInterface
6938
+ *
6939
+ * @param hasHardcodedMetadata boolean
6637
6940
  */
6638
6941
  Authority.prototype.getCloudDiscoveryMetadataFromNetwork = function () {
6639
6942
  return __awaiter(this, void 0, void 0, function () {
@@ -6653,7 +6956,9 @@
6653
6956
  return [4 /*yield*/, this.networkInterface.sendGetRequestAsync(instanceDiscoveryEndpoint, options)];
6654
6957
  case 2:
6655
6958
  response = _a.sent();
6656
- metadata = isCloudInstanceDiscoveryResponse(response.body) ? response.body.metadata : [];
6959
+ metadata = isCloudInstanceDiscoveryResponse(response.body)
6960
+ ? response.body.metadata
6961
+ : [];
6657
6962
  if (metadata.length === 0) {
6658
6963
  // If no metadata is returned, authority is untrusted
6659
6964
  return [2 /*return*/, null];
@@ -6673,6 +6978,15 @@
6673
6978
  });
6674
6979
  });
6675
6980
  };
6981
+ /**
6982
+ * Get cloud discovery metadata for common authorities
6983
+ */
6984
+ Authority.prototype.getCloudDiscoveryMetadataFromHarcodedValues = function () {
6985
+ if (this.canonicalAuthority in InstanceDiscoveryMetadata) {
6986
+ return InstanceDiscoveryMetadata[this.canonicalAuthority];
6987
+ }
6988
+ return null;
6989
+ };
6676
6990
  /**
6677
6991
  * Helper function to determine if this host is included in the knownAuthorities config option
6678
6992
  */
@@ -6788,7 +7102,7 @@
6788
7102
  return Authority;
6789
7103
  }());
6790
7104
 
6791
- /*! @azure/msal-common v7.0.0 2022-06-13 */
7105
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
6792
7106
 
6793
7107
  /*
6794
7108
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6849,7 +7163,7 @@
6849
7163
  return AuthorityFactory;
6850
7164
  }());
6851
7165
 
6852
- /*! @azure/msal-common v7.0.0 2022-06-13 */
7166
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
6853
7167
 
6854
7168
  /*
6855
7169
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6880,7 +7194,7 @@
6880
7194
  return ServerTelemetryEntity;
6881
7195
  }());
6882
7196
 
6883
- /*! @azure/msal-common v7.0.0 2022-06-13 */
7197
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
6884
7198
 
6885
7199
  /*
6886
7200
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6908,7 +7222,7 @@
6908
7222
  return ThrottlingEntity;
6909
7223
  }());
6910
7224
 
6911
- /*! @azure/msal-common v7.0.0 2022-06-13 */
7225
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
6912
7226
 
6913
7227
  /*
6914
7228
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6925,7 +7239,7 @@
6925
7239
  }
6926
7240
  };
6927
7241
 
6928
- /*! @azure/msal-common v7.0.0 2022-06-13 */
7242
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
6929
7243
 
6930
7244
  /*
6931
7245
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6970,7 +7284,7 @@
6970
7284
  return JoseHeaderError;
6971
7285
  }(AuthError));
6972
7286
 
6973
- /*! @azure/msal-common v7.0.0 2022-06-13 */
7287
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
6974
7288
 
6975
7289
  /*
6976
7290
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7010,7 +7324,7 @@
7010
7324
  return JoseHeader;
7011
7325
  }());
7012
7326
 
7013
- /*! @azure/msal-common v7.0.0 2022-06-13 */
7327
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
7014
7328
 
7015
7329
  /*
7016
7330
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7069,7 +7383,7 @@
7069
7383
  return AuthenticationHeaderParser;
7070
7384
  }());
7071
7385
 
7072
- /*! @azure/msal-common v7.0.0 2022-06-13 */
7386
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
7073
7387
 
7074
7388
  /*
7075
7389
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7231,104 +7545,7 @@
7231
7545
  return ServerTelemetryManager;
7232
7546
  }());
7233
7547
 
7234
- /*! @azure/msal-common v7.0.0 2022-06-13 */
7235
- /*
7236
- * Copyright (c) Microsoft Corporation. All rights reserved.
7237
- * Licensed under the MIT License.
7238
- */
7239
- /**
7240
- * Enumeration of operations that are instrumented by have their performance measured by the PerformanceClient.
7241
- *
7242
- * @export
7243
- * @enum {number}
7244
- */
7245
- exports.PerformanceEvents = void 0;
7246
- (function (PerformanceEvents) {
7247
- /**
7248
- * acquireTokenByCode API (msal-browser and msal-node).
7249
- * Used to acquire tokens by trading an authorization code against the token endpoint.
7250
- */
7251
- PerformanceEvents["AcquireTokenByCode"] = "acquireTokenByCode";
7252
- /**
7253
- * acquireTokenByRefreshToken API (msal-browser and msal-node).
7254
- * Used to renew an access token using a refresh token against the token endpoint.
7255
- */
7256
- PerformanceEvents["AcquireTokenByRefreshToken"] = "acquireTokenByRefreshToken";
7257
- /**
7258
- * acquireTokenSilent API (msal-browser and msal-node).
7259
- * Used to silently acquire a new access token (from the cache or the network).
7260
- */
7261
- PerformanceEvents["AcquireTokenSilent"] = "acquireTokenSilent";
7262
- /**
7263
- * acquireTokenSilentAsync (msal-browser).
7264
- * Internal API for acquireTokenSilent.
7265
- */
7266
- PerformanceEvents["AcquireTokenSilentAsync"] = "acquireTokenSilentAsync";
7267
- /**
7268
- * acquireTokenPopup (msal-browser).
7269
- * Used to acquire a new access token interactively through pop ups
7270
- */
7271
- PerformanceEvents["AcquireTokenPopup"] = "acquireTokenPopup";
7272
- /**
7273
- * getPublicKeyThumbprint API in CryptoOpts class (msal-browser).
7274
- * Used to generate a public/private keypair and generate a public key thumbprint for pop requests.
7275
- */
7276
- PerformanceEvents["CryptoOptsGetPublicKeyThumbprint"] = "cryptoOptsGetPublicKeyThumbprint";
7277
- /**
7278
- * signJwt API in CryptoOpts class (msal-browser).
7279
- * Used to signed a pop token.
7280
- */
7281
- PerformanceEvents["CryptoOptsSignJwt"] = "cryptoOptsSignJwt";
7282
- /**
7283
- * acquireToken API in the SilentCacheClient class (msal-browser).
7284
- * Used to read access tokens from the cache.
7285
- */
7286
- PerformanceEvents["SilentCacheClientAcquireToken"] = "silentCacheClientAcquireToken";
7287
- /**
7288
- * acquireToken API in the SilentIframeClient class (msal-browser).
7289
- * Used to acquire a new set of tokens from the authorize endpoint in a hidden iframe.
7290
- */
7291
- PerformanceEvents["SilentIframeClientAcquireToken"] = "silentIframeClientAcquireToken";
7292
- /**
7293
- * acquireToken API in SilentRereshClient (msal-browser).
7294
- * Used to acquire a new set of tokens from the token endpoint using a refresh token.
7295
- */
7296
- PerformanceEvents["SilentRefreshClientAcquireToken"] = "silentRefreshClientAcquireToken";
7297
- /**
7298
- * ssoSilent API (msal-browser).
7299
- * Used to silently acquire an authorization code and set of tokens using a hidden iframe.
7300
- */
7301
- PerformanceEvents["SsoSilent"] = "ssoSilent";
7302
- /**
7303
- * getDiscoveredAuthority API in StandardInteractionClient class (msal-browser).
7304
- * Used to load authority metadata for a request.
7305
- */
7306
- PerformanceEvents["StandardInteractionClientGetDiscoveredAuthority"] = "standardInteractionClientGetDiscoveredAuthority";
7307
- /**
7308
- * acquireToken APIs in msal-browser.
7309
- * Used to make an /authorize endpoint call with native brokering enabled.
7310
- */
7311
- PerformanceEvents["FetchAccountIdWithNativeBroker"] = "fetchAccountIdWithNativeBroker";
7312
- /**
7313
- * acquireToken API in NativeInteractionClient class (msal-browser).
7314
- * Used to acquire a token from Native component when native brokering is enabled.
7315
- */
7316
- PerformanceEvents["NativeInteractionClientAcquireToken"] = "nativeInteractionClientAcquireToken";
7317
- })(exports.PerformanceEvents || (exports.PerformanceEvents = {}));
7318
- /**
7319
- * State of the performance event.
7320
- *
7321
- * @export
7322
- * @enum {number}
7323
- */
7324
- var PerformanceEventStatus;
7325
- (function (PerformanceEventStatus) {
7326
- PerformanceEventStatus[PerformanceEventStatus["NotStarted"] = 0] = "NotStarted";
7327
- PerformanceEventStatus[PerformanceEventStatus["InProgress"] = 1] = "InProgress";
7328
- PerformanceEventStatus[PerformanceEventStatus["Completed"] = 2] = "Completed";
7329
- })(PerformanceEventStatus || (PerformanceEventStatus = {}));
7330
-
7331
- /*! @azure/msal-common v7.0.0 2022-06-13 */
7548
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
7332
7549
 
7333
7550
  /*
7334
7551
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7386,7 +7603,7 @@
7386
7603
  clientId: this.clientId,
7387
7604
  name: measureName,
7388
7605
  startTimeMs: Date.now(),
7389
- correlationId: eventCorrelationId
7606
+ correlationId: eventCorrelationId,
7390
7607
  };
7391
7608
  // Store in progress events so they can be discarded if not ended properly
7392
7609
  this.cacheEventByCorrelationId(inProgressEvent);
@@ -7531,6 +7748,12 @@
7531
7748
  else {
7532
7749
  _this.logger.verbose("PerformanceClient: Submeasurement for " + measureName + " already exists for " + current.name + ", ignoring", correlationId);
7533
7750
  }
7751
+ if (current.accessTokenSize) {
7752
+ previous.accessTokenSize = current.accessTokenSize;
7753
+ }
7754
+ if (current.idTokenSize) {
7755
+ previous.idTokenSize = current.idTokenSize;
7756
+ }
7534
7757
  }
7535
7758
  return previous;
7536
7759
  }, topLevelEvent);
@@ -7598,7 +7821,7 @@
7598
7821
  return PerformanceClient;
7599
7822
  }());
7600
7823
 
7601
- /*! @azure/msal-common v7.0.0 2022-06-13 */
7824
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
7602
7825
 
7603
7826
  /*
7604
7827
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8818,26 +9041,57 @@
8818
9041
  * Gets the active account
8819
9042
  */
8820
9043
  BrowserCacheManager.prototype.getActiveAccount = function () {
8821
- var activeAccountIdKey = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT);
8822
- var activeAccountId = this.browserStorage.getItem(activeAccountIdKey);
8823
- if (!activeAccountId) {
9044
+ var activeAccountKeyFilters = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT_FILTERS);
9045
+ var activeAccountValueFilters = this.getItem(activeAccountKeyFilters);
9046
+ if (!activeAccountValueFilters) {
9047
+ // if new active account cache type isn't found, it's an old version, so look for that instead
9048
+ this.logger.trace("No active account filters cache schema found, looking for legacy schema");
9049
+ var activeAccountKeyLocal = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT);
9050
+ var activeAccountValueLocal = this.getItem(activeAccountKeyLocal);
9051
+ if (!activeAccountValueLocal) {
9052
+ this.logger.trace("No active account found");
9053
+ return null;
9054
+ }
9055
+ var activeAccount = this.getAccountInfoByFilter({ localAccountId: activeAccountValueLocal })[0] || null;
9056
+ if (activeAccount) {
9057
+ this.logger.trace("Legacy active account cache schema found");
9058
+ this.logger.trace("Adding active account filters cache schema");
9059
+ this.setActiveAccount(activeAccount);
9060
+ return activeAccount;
9061
+ }
8824
9062
  return null;
8825
9063
  }
8826
- return this.getAccountInfoByFilter({ localAccountId: activeAccountId })[0] || null;
9064
+ var activeAccountValueObj = this.validateAndParseJson(activeAccountValueFilters);
9065
+ if (activeAccountValueObj) {
9066
+ this.logger.trace("Active account filters schema found");
9067
+ return this.getAccountInfoByFilter({
9068
+ homeAccountId: activeAccountValueObj.homeAccountId,
9069
+ localAccountId: activeAccountValueObj.localAccountId
9070
+ })[0] || null;
9071
+ }
9072
+ this.logger.trace("No active account found");
9073
+ return null;
8827
9074
  };
8828
9075
  /**
8829
9076
  * Sets the active account's localAccountId in cache
8830
9077
  * @param account
8831
9078
  */
8832
9079
  BrowserCacheManager.prototype.setActiveAccount = function (account) {
8833
- var activeAccountIdKey = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT);
9080
+ var activeAccountKey = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT_FILTERS);
9081
+ var activeAccountKeyLocal = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT);
8834
9082
  if (account) {
8835
9083
  this.logger.verbose("setActiveAccount: Active account set");
8836
- this.browserStorage.setItem(activeAccountIdKey, account.localAccountId);
9084
+ var activeAccountValue = {
9085
+ homeAccountId: account.homeAccountId,
9086
+ localAccountId: account.localAccountId
9087
+ };
9088
+ this.browserStorage.setItem(activeAccountKey, JSON.stringify(activeAccountValue));
9089
+ this.browserStorage.setItem(activeAccountKeyLocal, account.localAccountId);
8837
9090
  }
8838
9091
  else {
8839
9092
  this.logger.verbose("setActiveAccount: No account passed, active account not set");
8840
- this.browserStorage.removeItem(activeAccountIdKey);
9093
+ this.browserStorage.removeItem(activeAccountKey);
9094
+ this.browserStorage.removeItem(activeAccountKeyLocal);
8841
9095
  }
8842
9096
  };
8843
9097
  /**
@@ -9023,7 +9277,7 @@
9023
9277
  * @param expires
9024
9278
  */
9025
9279
  BrowserCacheManager.prototype.setItemCookie = function (cookieName, cookieValue, expires) {
9026
- var cookieStr = encodeURIComponent(cookieName) + "=" + encodeURIComponent(cookieValue) + ";path=/;";
9280
+ var cookieStr = encodeURIComponent(cookieName) + "=" + encodeURIComponent(cookieValue) + ";path=/;SameSite=Lax;";
9027
9281
  if (expires) {
9028
9282
  var expireTime = this.getCookieExpirationTime(expires);
9029
9283
  cookieStr += "expires=" + expireTime + ";";
@@ -9395,7 +9649,7 @@
9395
9649
 
9396
9650
  /* eslint-disable header/header */
9397
9651
  var name = "@azure/msal-browser";
9398
- var version = "2.26.0";
9652
+ var version = "2.28.1";
9399
9653
 
9400
9654
  /*
9401
9655
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -10176,6 +10430,7 @@
10176
10430
  knownAuthorities: this.config.auth.knownAuthorities,
10177
10431
  cloudDiscoveryMetadata: this.config.auth.cloudDiscoveryMetadata,
10178
10432
  authorityMetadata: this.config.auth.authorityMetadata,
10433
+ skipAuthorityMetadataCache: this.config.auth.skipAuthorityMetadataCache
10179
10434
  };
10180
10435
  userAuthority = requestAuthority ? requestAuthority : this.config.auth.authority;
10181
10436
  builtAuthority = Authority.generateAuthority(userAuthority, requestAzureCloudOptions || this.config.auth.azureCloudOptions);
@@ -10566,6 +10821,7 @@
10566
10821
  NativeStatusCode["TRANSIENT_ERROR"] = "TRANSIENT_ERROR";
10567
10822
  NativeStatusCode["PERSISTENT_ERROR"] = "PERSISTENT_ERROR";
10568
10823
  NativeStatusCode["DISABLED"] = "DISABLED";
10824
+ NativeStatusCode["ACCOUNT_UNAVAILABLE"] = "ACCOUNT_UNAVAILABLE";
10569
10825
  })(NativeStatusCode || (NativeStatusCode = {}));
10570
10826
  var NativeAuthErrorMessage = {
10571
10827
  extensionError: {
@@ -10574,6 +10830,10 @@
10574
10830
  userSwitch: {
10575
10831
  code: "user_switch",
10576
10832
  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."
10833
+ },
10834
+ tokensNotFoundInCache: {
10835
+ code: "tokens_not_found_in_internal_memory_cache",
10836
+ desc: "Tokens not cached in MSAL JS internal memory, please make the WAM request"
10577
10837
  }
10578
10838
  };
10579
10839
  var NativeAuthError = /** @class */ (function (_super) {
@@ -10609,6 +10869,8 @@
10609
10869
  NativeAuthError.createError = function (code, description, ext) {
10610
10870
  if (ext && ext.status) {
10611
10871
  switch (ext.status) {
10872
+ case NativeStatusCode.ACCOUNT_UNAVAILABLE:
10873
+ return InteractionRequiredAuthError.createNativeAccountUnavailableError();
10612
10874
  case NativeStatusCode.USER_INTERACTION_REQUIRED:
10613
10875
  return new InteractionRequiredAuthError(code, description);
10614
10876
  case NativeStatusCode.USER_CANCEL:
@@ -10626,20 +10888,122 @@
10626
10888
  NativeAuthError.createUserSwitchError = function () {
10627
10889
  return new NativeAuthError(NativeAuthErrorMessage.userSwitch.code, NativeAuthErrorMessage.userSwitch.desc);
10628
10890
  };
10891
+ /**
10892
+ * Creates a tokens not found error when the internal cache look up fails
10893
+ * @returns NativeAuthError: tokensNotFoundInCache
10894
+ */
10895
+ NativeAuthError.createTokensNotFoundInCacheError = function () {
10896
+ return new NativeAuthError(NativeAuthErrorMessage.tokensNotFoundInCache.code, NativeAuthErrorMessage.tokensNotFoundInCache.desc);
10897
+ };
10629
10898
  return NativeAuthError;
10630
10899
  }(AuthError));
10631
10900
 
10901
+ /*
10902
+ * Copyright (c) Microsoft Corporation. All rights reserved.
10903
+ * Licensed under the MIT License.
10904
+ */
10905
+ var SilentCacheClient = /** @class */ (function (_super) {
10906
+ __extends$1(SilentCacheClient, _super);
10907
+ function SilentCacheClient() {
10908
+ return _super !== null && _super.apply(this, arguments) || this;
10909
+ }
10910
+ /**
10911
+ * Returns unexpired tokens from the cache, if available
10912
+ * @param silentRequest
10913
+ */
10914
+ SilentCacheClient.prototype.acquireToken = function (silentRequest) {
10915
+ return __awaiter$1(this, void 0, void 0, function () {
10916
+ var acquireTokenMeasurement, serverTelemetryManager, silentAuthClient, cachedToken, error_1;
10917
+ return __generator$1(this, function (_a) {
10918
+ switch (_a.label) {
10919
+ case 0:
10920
+ acquireTokenMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.SilentCacheClientAcquireToken, silentRequest.correlationId);
10921
+ serverTelemetryManager = this.initializeServerTelemetryManager(exports.ApiId.acquireTokenSilent_silentFlow);
10922
+ return [4 /*yield*/, this.createSilentFlowClient(serverTelemetryManager, silentRequest.authority, silentRequest.azureCloudOptions)];
10923
+ case 1:
10924
+ silentAuthClient = _a.sent();
10925
+ this.logger.verbose("Silent auth client created");
10926
+ _a.label = 2;
10927
+ case 2:
10928
+ _a.trys.push([2, 4, , 5]);
10929
+ return [4 /*yield*/, silentAuthClient.acquireCachedToken(silentRequest)];
10930
+ case 3:
10931
+ cachedToken = _a.sent();
10932
+ acquireTokenMeasurement.endMeasurement({
10933
+ success: true,
10934
+ fromCache: true
10935
+ });
10936
+ return [2 /*return*/, cachedToken];
10937
+ case 4:
10938
+ error_1 = _a.sent();
10939
+ if (error_1 instanceof BrowserAuthError && error_1.errorCode === BrowserAuthErrorMessage.signingKeyNotFoundInStorage.code) {
10940
+ this.logger.verbose("Signing keypair for bound access token not found. Refreshing bound access token and generating a new crypto keypair.");
10941
+ }
10942
+ acquireTokenMeasurement.endMeasurement({
10943
+ errorCode: error_1 instanceof AuthError && error_1.errorCode || undefined,
10944
+ subErrorCode: error_1 instanceof AuthError && error_1.subError || undefined,
10945
+ success: false
10946
+ });
10947
+ throw error_1;
10948
+ case 5: return [2 /*return*/];
10949
+ }
10950
+ });
10951
+ });
10952
+ };
10953
+ /**
10954
+ * Currently Unsupported
10955
+ */
10956
+ SilentCacheClient.prototype.logout = function () {
10957
+ // Synchronous so we must reject
10958
+ return Promise.reject(BrowserAuthError.createSilentLogoutUnsupportedError());
10959
+ };
10960
+ /**
10961
+ * Creates an Silent Flow Client with the given authority, or the default authority.
10962
+ * @param serverTelemetryManager
10963
+ * @param authorityUrl
10964
+ */
10965
+ SilentCacheClient.prototype.createSilentFlowClient = function (serverTelemetryManager, authorityUrl, azureCloudOptions) {
10966
+ return __awaiter$1(this, void 0, void 0, function () {
10967
+ var clientConfig;
10968
+ return __generator$1(this, function (_a) {
10969
+ switch (_a.label) {
10970
+ case 0: return [4 /*yield*/, this.getClientConfiguration(serverTelemetryManager, authorityUrl, azureCloudOptions)];
10971
+ case 1:
10972
+ clientConfig = _a.sent();
10973
+ return [2 /*return*/, new SilentFlowClient(clientConfig, this.performanceClient)];
10974
+ }
10975
+ });
10976
+ });
10977
+ };
10978
+ SilentCacheClient.prototype.initializeSilentRequest = function (request, account) {
10979
+ return __awaiter$1(this, void 0, void 0, function () {
10980
+ var _a;
10981
+ return __generator$1(this, function (_b) {
10982
+ switch (_b.label) {
10983
+ case 0:
10984
+ _a = [__assign$1({}, request)];
10985
+ return [4 /*yield*/, this.initializeBaseRequest(request)];
10986
+ 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 }])];
10987
+ }
10988
+ });
10989
+ });
10990
+ };
10991
+ return SilentCacheClient;
10992
+ }(StandardInteractionClient));
10993
+
10632
10994
  /*
10633
10995
  * Copyright (c) Microsoft Corporation. All rights reserved.
10634
10996
  * Licensed under the MIT License.
10635
10997
  */
10636
10998
  var NativeInteractionClient = /** @class */ (function (_super) {
10637
10999
  __extends$1(NativeInteractionClient, _super);
10638
- function NativeInteractionClient(config, browserStorage, browserCrypto, logger, eventHandler, navigationClient, apiId, performanceClient, provider, accountId, correlationId) {
11000
+ function NativeInteractionClient(config, browserStorage, browserCrypto, logger, eventHandler, navigationClient, apiId, performanceClient, provider, accountId, nativeStorageImpl, correlationId) {
10639
11001
  var _this = _super.call(this, config, browserStorage, browserCrypto, logger, eventHandler, navigationClient, performanceClient, provider, correlationId) || this;
10640
11002
  _this.apiId = apiId;
10641
11003
  _this.accountId = accountId;
10642
11004
  _this.nativeMessageHandler = provider;
11005
+ _this.nativeStorageManager = nativeStorageImpl;
11006
+ _this.silentCacheClient = new SilentCacheClient(config, _this.nativeStorageManager, browserCrypto, logger, eventHandler, navigationClient, performanceClient, provider, correlationId);
10643
11007
  return _this;
10644
11008
  }
10645
11009
  /**
@@ -10648,22 +11012,40 @@
10648
11012
  */
10649
11013
  NativeInteractionClient.prototype.acquireToken = function (request) {
10650
11014
  return __awaiter$1(this, void 0, void 0, function () {
10651
- var nativeATMeasurement, nativeRequest, messageBody, reqTimestamp, response, validatedResponse;
11015
+ var nativeATMeasurement, reqTimestamp, nativeRequest, result, messageBody, response, validatedResponse;
10652
11016
  return __generator$1(this, function (_a) {
10653
11017
  switch (_a.label) {
10654
11018
  case 0:
10655
11019
  this.logger.trace("NativeInteractionClient - acquireToken called.");
10656
11020
  nativeATMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.NativeInteractionClientAcquireToken, request.correlationId);
11021
+ reqTimestamp = TimeUtils.nowSeconds();
10657
11022
  return [4 /*yield*/, this.initializeNativeRequest(request)];
10658
11023
  case 1:
10659
11024
  nativeRequest = _a.sent();
11025
+ _a.label = 2;
11026
+ case 2:
11027
+ _a.trys.push([2, 4, , 5]);
11028
+ return [4 /*yield*/, this.acquireTokensFromCache(this.accountId, nativeRequest)];
11029
+ case 3:
11030
+ result = _a.sent();
11031
+ nativeATMeasurement.endMeasurement({
11032
+ success: true,
11033
+ isNativeBroker: true,
11034
+ fromCache: true
11035
+ });
11036
+ return [2 /*return*/, result];
11037
+ case 4:
11038
+ _a.sent();
11039
+ // continue with a native call for any and all errors
11040
+ this.logger.info("MSAL internal Cache does not contain tokens, proceed to make a native call");
11041
+ return [3 /*break*/, 5];
11042
+ case 5:
10660
11043
  messageBody = {
10661
11044
  method: NativeExtensionMethod.GetToken,
10662
11045
  request: nativeRequest
10663
11046
  };
10664
- reqTimestamp = TimeUtils.nowSeconds();
10665
11047
  return [4 /*yield*/, this.nativeMessageHandler.sendMessage(messageBody)];
10666
- case 2:
11048
+ case 6:
10667
11049
  response = _a.sent();
10668
11050
  validatedResponse = this.validateNativeResponse(response);
10669
11051
  return [2 /*return*/, this.handleNativeResponse(validatedResponse, nativeRequest, reqTimestamp)
@@ -10687,13 +11069,61 @@
10687
11069
  });
10688
11070
  });
10689
11071
  };
11072
+ /**
11073
+ * Creates silent flow request
11074
+ * @param request
11075
+ * @param cachedAccount
11076
+ * @returns CommonSilentFlowRequest
11077
+ */
11078
+ NativeInteractionClient.prototype.createSilentCacheRequest = function (request, cachedAccount) {
11079
+ return {
11080
+ authority: request.authority,
11081
+ correlationId: this.correlationId,
11082
+ scopes: ScopeSet.fromString(request.scope).asArray(),
11083
+ account: cachedAccount,
11084
+ forceRefresh: false,
11085
+ };
11086
+ };
11087
+ /**
11088
+ * Fetches the tokens from the cache if un-expired
11089
+ * @param nativeAccountId
11090
+ * @param request
11091
+ * @returns authenticationResult
11092
+ */
11093
+ NativeInteractionClient.prototype.acquireTokensFromCache = function (nativeAccountId, request) {
11094
+ return __awaiter$1(this, void 0, void 0, function () {
11095
+ var accountEntity, account, silentRequest, result, e_2;
11096
+ return __generator$1(this, function (_a) {
11097
+ switch (_a.label) {
11098
+ case 0:
11099
+ accountEntity = this.browserStorage.readAccountFromCacheWithNativeAccountId(nativeAccountId);
11100
+ if (!accountEntity) {
11101
+ throw ClientAuthError.createNoAccountFoundError();
11102
+ }
11103
+ account = accountEntity.getAccountInfo();
11104
+ _a.label = 1;
11105
+ case 1:
11106
+ _a.trys.push([1, 3, , 4]);
11107
+ silentRequest = this.createSilentCacheRequest(request, account);
11108
+ return [4 /*yield*/, this.silentCacheClient.acquireToken(silentRequest)];
11109
+ case 2:
11110
+ result = _a.sent();
11111
+ return [2 /*return*/, result];
11112
+ case 3:
11113
+ e_2 = _a.sent();
11114
+ throw e_2;
11115
+ case 4: return [2 /*return*/];
11116
+ }
11117
+ });
11118
+ });
11119
+ };
10690
11120
  /**
10691
11121
  * Acquires a token from native platform then redirects to the redirectUri instead of returning the response
10692
11122
  * @param request
10693
11123
  */
10694
11124
  NativeInteractionClient.prototype.acquireTokenRedirect = function (request) {
10695
11125
  return __awaiter$1(this, void 0, void 0, function () {
10696
- var nativeRequest, messageBody, response, e_1, navigationOptions, redirectUri;
11126
+ var nativeRequest, messageBody, response, e_3, navigationOptions, redirectUri;
10697
11127
  return __generator$1(this, function (_a) {
10698
11128
  switch (_a.label) {
10699
11129
  case 0:
@@ -10714,10 +11144,10 @@
10714
11144
  this.validateNativeResponse(response);
10715
11145
  return [3 /*break*/, 5];
10716
11146
  case 4:
10717
- e_1 = _a.sent();
11147
+ e_3 = _a.sent();
10718
11148
  // Only throw fatal errors here to allow application to fallback to regular redirect. Otherwise proceed and the error will be thrown in handleRedirectPromise
10719
- if (e_1 instanceof NativeAuthError && e_1.isFatal()) {
10720
- throw e_1;
11149
+ if (e_3 instanceof NativeAuthError && e_3.isFatal()) {
11150
+ throw e_3;
10721
11151
  }
10722
11152
  return [3 /*break*/, 5];
10723
11153
  case 5:
@@ -10741,7 +11171,7 @@
10741
11171
  */
10742
11172
  NativeInteractionClient.prototype.handleRedirectPromise = function () {
10743
11173
  return __awaiter$1(this, void 0, void 0, function () {
10744
- var cachedRequest, messageBody, reqTimestamp, response, result, e_2;
11174
+ var cachedRequest, messageBody, reqTimestamp, response, result, e_4;
10745
11175
  return __generator$1(this, function (_a) {
10746
11176
  switch (_a.label) {
10747
11177
  case 0:
@@ -10773,9 +11203,9 @@
10773
11203
  this.browserStorage.setInteractionInProgress(false);
10774
11204
  return [2 /*return*/, result];
10775
11205
  case 3:
10776
- e_2 = _a.sent();
11206
+ e_4 = _a.sent();
10777
11207
  this.browserStorage.setInteractionInProgress(false);
10778
- throw e_2;
11208
+ throw e_4;
10779
11209
  case 4: return [2 /*return*/];
10780
11210
  }
10781
11211
  });
@@ -10797,7 +11227,7 @@
10797
11227
  */
10798
11228
  NativeInteractionClient.prototype.handleNativeResponse = function (response, request, reqTimestamp) {
10799
11229
  return __awaiter$1(this, void 0, void 0, function () {
10800
- var idTokenObj, authority, authorityPreferredCache, homeAccountIdentifier, accountEntity, responseScopes, accountProperties, uid, tid, responseAccessToken, responseTokenType, _a, popTokenGenerator, shrParameters, mats, result;
11230
+ var idTokenObj, authority, authorityPreferredCache, homeAccountIdentifier, accountEntity, responseScopes, accountProperties, uid, tid, responseAccessToken, responseTokenType, _a, popTokenGenerator, shrParameters, mats, result, idTokenEntity, expiresIn, tokenExpirationSeconds, accessTokenEntity;
10801
11231
  var _this = this;
10802
11232
  return __generator$1(this, function (_b) {
10803
11233
  switch (_b.label) {
@@ -10815,7 +11245,7 @@
10815
11245
  homeAccountIdentifier = AccountEntity.generateHomeAccountId(response.client_info || Constants.EMPTY_STRING, AuthorityType.Default, this.logger, this.browserCrypto, idTokenObj);
10816
11246
  accountEntity = AccountEntity.createAccount(response.client_info, homeAccountIdentifier, idTokenObj, undefined, undefined, undefined, authorityPreferredCache, response.account.id);
10817
11247
  this.browserStorage.setAccount(accountEntity);
10818
- responseScopes = response.scopes ? ScopeSet.fromString(response.scopes) : ScopeSet.fromString(request.scopes);
11248
+ responseScopes = response.scope ? ScopeSet.fromString(response.scope) : ScopeSet.fromString(request.scope);
10819
11249
  accountProperties = response.account.properties || {};
10820
11250
  uid = accountProperties["UID"] || idTokenObj.claims.oid || idTokenObj.claims.sub || Constants.EMPTY_STRING;
10821
11251
  tid = accountProperties["TenantId"] || idTokenObj.claims.tid || Constants.EMPTY_STRING;
@@ -10875,7 +11305,17 @@
10875
11305
  state: response.state,
10876
11306
  fromNativeBroker: true
10877
11307
  };
10878
- // Remove any existing cached tokens for this account
11308
+ idTokenEntity = IdTokenEntity.createIdTokenEntity(homeAccountIdentifier, request.authority, response.id_token || Constants.EMPTY_STRING, request.clientId, idTokenObj.claims.tid || Constants.EMPTY_STRING);
11309
+ this.nativeStorageManager.setIdTokenCredential(idTokenEntity);
11310
+ expiresIn = (responseTokenType === exports.AuthenticationScheme.POP)
11311
+ ? Constants.SHR_NONCE_VALIDITY
11312
+ : (typeof response.expires_in === "string"
11313
+ ? parseInt(response.expires_in, 10)
11314
+ : response.expires_in) || 0;
11315
+ tokenExpirationSeconds = reqTimestamp + expiresIn;
11316
+ accessTokenEntity = AccessTokenEntity.createAccessTokenEntity(homeAccountIdentifier, request.authority, responseAccessToken, request.clientId, tid, responseScopes.printScopes(), tokenExpirationSeconds, 0, this.browserCrypto);
11317
+ this.nativeStorageManager.setAccessTokenCredential(accessTokenEntity);
11318
+ // Remove any existing cached tokens for this account in browser storage
10879
11319
  this.browserStorage.removeAccountContext(accountEntity).catch(function (e) {
10880
11320
  _this.logger.error("Error occurred while removing account context from browser storage. " + e);
10881
11321
  });
@@ -10893,7 +11333,7 @@
10893
11333
  response.hasOwnProperty("id_token") &&
10894
11334
  response.hasOwnProperty("client_info") &&
10895
11335
  response.hasOwnProperty("account") &&
10896
- response.hasOwnProperty("scopes") &&
11336
+ response.hasOwnProperty("scope") &&
10897
11337
  response.hasOwnProperty("expires_in")) {
10898
11338
  return response;
10899
11339
  }
@@ -10935,7 +11375,8 @@
10935
11375
  */
10936
11376
  NativeInteractionClient.prototype.initializeNativeRequest = function (request) {
10937
11377
  return __awaiter$1(this, void 0, void 0, function () {
10938
- var authority, canonicalAuthority, scopes, scopeSet, validatedRequest, shrParameters, popTokenGenerator, reqCnfData;
11378
+ var authority, canonicalAuthority, scopes, remainingProperties, scopeSet, getPrompt, validatedRequest, shrParameters, popTokenGenerator, reqCnfData;
11379
+ var _this = this;
10939
11380
  return __generator$1(this, function (_a) {
10940
11381
  switch (_a.label) {
10941
11382
  case 0:
@@ -10943,21 +11384,35 @@
10943
11384
  authority = request.authority || this.config.auth.authority;
10944
11385
  canonicalAuthority = new UrlString(authority);
10945
11386
  canonicalAuthority.validateAsUri();
10946
- scopes = request && request.scopes || [];
10947
- scopeSet = new ScopeSet(scopes);
11387
+ scopes = request.scopes, remainingProperties = __rest(request, ["scopes"]);
11388
+ scopeSet = new ScopeSet(scopes || []);
10948
11389
  scopeSet.appendScopes(OIDC_DEFAULT_SCOPES);
10949
- if (request.prompt) {
11390
+ getPrompt = function () {
11391
+ // If request is silent, prompt is always none
11392
+ switch (_this.apiId) {
11393
+ case exports.ApiId.ssoSilent:
11394
+ case exports.ApiId.acquireTokenSilent_silentFlow:
11395
+ _this.logger.trace("initializeNativeRequest: silent request sets prompt to none");
11396
+ return PromptValue.NONE;
11397
+ }
11398
+ // Prompt not provided, request may proceed and native broker decides if it needs to prompt
11399
+ if (!request.prompt) {
11400
+ _this.logger.trace("initializeNativeRequest: prompt was not provided");
11401
+ return undefined;
11402
+ }
11403
+ // If request is interactive, check if prompt provided is allowed to go directly to native broker
10950
11404
  switch (request.prompt) {
10951
11405
  case PromptValue.NONE:
10952
11406
  case PromptValue.CONSENT:
10953
- this.logger.trace("initializeNativeRequest: prompt is compatible with native flow");
10954
- break;
11407
+ case PromptValue.LOGIN:
11408
+ _this.logger.trace("initializeNativeRequest: prompt is compatible with native flow");
11409
+ return request.prompt;
10955
11410
  default:
10956
- this.logger.trace("initializeNativeRequest: prompt = " + request.prompt + " is not compatible with native flow");
11411
+ _this.logger.trace("initializeNativeRequest: prompt = " + request.prompt + " is not compatible with native flow");
10957
11412
  throw BrowserAuthError.createNativePromptParameterNotSupportedError();
10958
11413
  }
10959
- }
10960
- validatedRequest = __assign$1(__assign$1({}, request), { accountId: this.accountId, clientId: this.config.auth.clientId, authority: canonicalAuthority.urlString, scopes: scopeSet.printScopes(), redirectUri: this.getRedirectUri(request.redirectUri), correlationId: this.correlationId, tokenType: request.authenticationScheme, windowTitleSubstring: document.title, extraParameters: __assign$1(__assign$1(__assign$1({}, request.extraQueryParameters), request.tokenQueryParameters), { telemetry: NativeConstants.MATS_TELEMETRY }), extendedExpiryToken: false // Make this configurable?
11414
+ };
11415
+ 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?
10961
11416
  });
10962
11417
  if (!(request.authenticationScheme === exports.AuthenticationScheme.POP)) return [3 /*break*/, 2];
10963
11418
  shrParameters = {
@@ -10974,11 +11429,7 @@
10974
11429
  validatedRequest.reqCnf = reqCnfData.reqCnfHash;
10975
11430
  validatedRequest.keyId = reqCnfData.kid;
10976
11431
  _a.label = 2;
10977
- case 2:
10978
- if (this.apiId === exports.ApiId.ssoSilent || this.apiId === exports.ApiId.acquireTokenSilent_silentFlow) {
10979
- validatedRequest.prompt = PromptValue.NONE;
10980
- }
10981
- return [2 /*return*/, validatedRequest];
11432
+ case 2: return [2 /*return*/, validatedRequest];
10982
11433
  }
10983
11434
  });
10984
11435
  });
@@ -11228,8 +11679,10 @@
11228
11679
  */
11229
11680
  var RedirectClient = /** @class */ (function (_super) {
11230
11681
  __extends$1(RedirectClient, _super);
11231
- function RedirectClient() {
11232
- return _super !== null && _super.apply(this, arguments) || this;
11682
+ function RedirectClient(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, performanceClient, nativeStorageImpl, nativeMessageHandler, correlationId) {
11683
+ var _this = _super.call(this, config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, performanceClient, nativeMessageHandler, correlationId) || this;
11684
+ _this.nativeStorage = nativeStorageImpl;
11685
+ return _this;
11233
11686
  }
11234
11687
  /**
11235
11688
  * Redirects the page to the /authorize endpoint of the IDP
@@ -11438,7 +11891,7 @@
11438
11891
  if (!this.nativeMessageHandler) {
11439
11892
  throw BrowserAuthError.createNativeConnectionNotEstablishedError();
11440
11893
  }
11441
- 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);
11894
+ 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);
11442
11895
  userRequestState = ProtocolUtils.parseRequestState(this.browserCrypto, state).userRequestState;
11443
11896
  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
11444
11897
  })).finally(function () {
@@ -11556,10 +12009,11 @@
11556
12009
  */
11557
12010
  var PopupClient = /** @class */ (function (_super) {
11558
12011
  __extends$1(PopupClient, _super);
11559
- function PopupClient(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, performanceClient, nativeMessageHandler, correlationId) {
12012
+ function PopupClient(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, performanceClient, nativeStorageImpl, nativeMessageHandler, correlationId) {
11560
12013
  var _this = _super.call(this, config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, performanceClient, nativeMessageHandler, correlationId) || this;
11561
12014
  // Properly sets this reference for the unload event.
11562
12015
  _this.unloadWindow = _this.unloadWindow.bind(_this);
12016
+ _this.nativeStorage = nativeStorageImpl;
11563
12017
  return _this;
11564
12018
  }
11565
12019
  /**
@@ -11684,7 +12138,7 @@
11684
12138
  if (!this.nativeMessageHandler) {
11685
12139
  throw BrowserAuthError.createNativeConnectionNotEstablishedError();
11686
12140
  }
11687
- 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);
12141
+ 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);
11688
12142
  userRequestState = ProtocolUtils.parseRequestState(this.browserCrypto, state_1).userRequestState;
11689
12143
  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
11690
12144
  })).finally(function () {
@@ -12120,6 +12574,7 @@
12120
12574
  azureCloudInstance: exports.AzureCloudInstance.None,
12121
12575
  tenant: Constants.EMPTY_STRING
12122
12576
  },
12577
+ skipAuthorityMetadataCache: false,
12123
12578
  };
12124
12579
  // Default cache options for browser
12125
12580
  var DEFAULT_CACHE_OPTIONS = {
@@ -12311,9 +12766,10 @@
12311
12766
  */
12312
12767
  var SilentIframeClient = /** @class */ (function (_super) {
12313
12768
  __extends$1(SilentIframeClient, _super);
12314
- function SilentIframeClient(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, apiId, performanceClient, nativeMessageHandler, correlationId) {
12769
+ function SilentIframeClient(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, apiId, performanceClient, nativeStorageImpl, nativeMessageHandler, correlationId) {
12315
12770
  var _this = _super.call(this, config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, performanceClient, nativeMessageHandler, correlationId) || this;
12316
12771
  _this.apiId = apiId;
12772
+ _this.nativeStorage = nativeStorageImpl;
12317
12773
  return _this;
12318
12774
  }
12319
12775
  /**
@@ -12416,7 +12872,7 @@
12416
12872
  if (!this.nativeMessageHandler) {
12417
12873
  throw BrowserAuthError.createNativeConnectionNotEstablishedError();
12418
12874
  }
12419
- 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);
12875
+ 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);
12420
12876
  userRequestState = ProtocolUtils.parseRequestState(this.browserCrypto, state).userRequestState;
12421
12877
  return [2 /*return*/, nativeInteractionClient.acquireToken(__assign$1(__assign$1({}, silentRequest), { state: userRequestState, prompt: PromptValue.NONE })).finally(function () {
12422
12878
  _this.browserStorage.cleanRequestByState(state);
@@ -12431,99 +12887,6 @@
12431
12887
  return SilentIframeClient;
12432
12888
  }(StandardInteractionClient));
12433
12889
 
12434
- /*
12435
- * Copyright (c) Microsoft Corporation. All rights reserved.
12436
- * Licensed under the MIT License.
12437
- */
12438
- var SilentCacheClient = /** @class */ (function (_super) {
12439
- __extends$1(SilentCacheClient, _super);
12440
- function SilentCacheClient() {
12441
- return _super !== null && _super.apply(this, arguments) || this;
12442
- }
12443
- /**
12444
- * Returns unexpired tokens from the cache, if available
12445
- * @param silentRequest
12446
- */
12447
- SilentCacheClient.prototype.acquireToken = function (silentRequest) {
12448
- return __awaiter$1(this, void 0, void 0, function () {
12449
- var acquireTokenMeasurement, serverTelemetryManager, silentAuthClient, cachedToken, error_1;
12450
- return __generator$1(this, function (_a) {
12451
- switch (_a.label) {
12452
- case 0:
12453
- acquireTokenMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.SilentCacheClientAcquireToken, silentRequest.correlationId);
12454
- serverTelemetryManager = this.initializeServerTelemetryManager(exports.ApiId.acquireTokenSilent_silentFlow);
12455
- return [4 /*yield*/, this.createSilentFlowClient(serverTelemetryManager, silentRequest.authority, silentRequest.azureCloudOptions)];
12456
- case 1:
12457
- silentAuthClient = _a.sent();
12458
- this.logger.verbose("Silent auth client created");
12459
- _a.label = 2;
12460
- case 2:
12461
- _a.trys.push([2, 4, , 5]);
12462
- return [4 /*yield*/, silentAuthClient.acquireCachedToken(silentRequest)];
12463
- case 3:
12464
- cachedToken = _a.sent();
12465
- acquireTokenMeasurement.endMeasurement({
12466
- success: true,
12467
- fromCache: true
12468
- });
12469
- return [2 /*return*/, cachedToken];
12470
- case 4:
12471
- error_1 = _a.sent();
12472
- if (error_1 instanceof BrowserAuthError && error_1.errorCode === BrowserAuthErrorMessage.signingKeyNotFoundInStorage.code) {
12473
- this.logger.verbose("Signing keypair for bound access token not found. Refreshing bound access token and generating a new crypto keypair.");
12474
- }
12475
- acquireTokenMeasurement.endMeasurement({
12476
- errorCode: error_1 instanceof AuthError && error_1.errorCode || undefined,
12477
- subErrorCode: error_1 instanceof AuthError && error_1.subError || undefined,
12478
- success: false
12479
- });
12480
- throw error_1;
12481
- case 5: return [2 /*return*/];
12482
- }
12483
- });
12484
- });
12485
- };
12486
- /**
12487
- * Currently Unsupported
12488
- */
12489
- SilentCacheClient.prototype.logout = function () {
12490
- // Synchronous so we must reject
12491
- return Promise.reject(BrowserAuthError.createSilentLogoutUnsupportedError());
12492
- };
12493
- /**
12494
- * Creates an Silent Flow Client with the given authority, or the default authority.
12495
- * @param serverTelemetryManager
12496
- * @param authorityUrl
12497
- */
12498
- SilentCacheClient.prototype.createSilentFlowClient = function (serverTelemetryManager, authorityUrl, azureCloudOptions) {
12499
- return __awaiter$1(this, void 0, void 0, function () {
12500
- var clientConfig;
12501
- return __generator$1(this, function (_a) {
12502
- switch (_a.label) {
12503
- case 0: return [4 /*yield*/, this.getClientConfiguration(serverTelemetryManager, authorityUrl, azureCloudOptions)];
12504
- case 1:
12505
- clientConfig = _a.sent();
12506
- return [2 /*return*/, new SilentFlowClient(clientConfig)];
12507
- }
12508
- });
12509
- });
12510
- };
12511
- SilentCacheClient.prototype.initializeSilentRequest = function (request, account) {
12512
- return __awaiter$1(this, void 0, void 0, function () {
12513
- var _a;
12514
- return __generator$1(this, function (_b) {
12515
- switch (_b.label) {
12516
- case 0:
12517
- _a = [__assign$1({}, request)];
12518
- return [4 /*yield*/, this.initializeBaseRequest(request)];
12519
- 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 }])];
12520
- }
12521
- });
12522
- });
12523
- };
12524
- return SilentCacheClient;
12525
- }(StandardInteractionClient));
12526
-
12527
12890
  /*
12528
12891
  * Copyright (c) Microsoft Corporation. All rights reserved.
12529
12892
  * Licensed under the MIT License.
@@ -12599,7 +12962,7 @@
12599
12962
  case 0: return [4 /*yield*/, this.getClientConfiguration(serverTelemetryManager, authorityUrl, azureCloudOptions)];
12600
12963
  case 1:
12601
12964
  clientConfig = _a.sent();
12602
- return [2 /*return*/, new RefreshTokenClient(clientConfig)];
12965
+ return [2 /*return*/, new RefreshTokenClient(clientConfig, this.performanceClient)];
12603
12966
  }
12604
12967
  });
12605
12968
  });
@@ -14214,6 +14577,7 @@
14214
14577
  knownAuthorities: this.config.auth.knownAuthorities,
14215
14578
  cloudDiscoveryMetadata: this.config.auth.cloudDiscoveryMetadata,
14216
14579
  authorityMetadata: this.config.auth.authorityMetadata,
14580
+ skipAuthorityMetadataCache: this.config.auth.skipAuthorityMetadataCache,
14217
14581
  };
14218
14582
  var authority = new Authority(authorityUrl, this.config.system.networkClient, this.storage, authorityOptions);
14219
14583
  // "clientInfo" from options takes precedence over "clientInfo" in response
@@ -14540,6 +14904,13 @@
14540
14904
  this.browserStorage = this.isBrowserEnvironment ?
14541
14905
  new BrowserCacheManager(this.config.auth.clientId, this.config.cache, this.browserCrypto, this.logger) :
14542
14906
  DEFAULT_BROWSER_CACHE_MANAGER(this.config.auth.clientId, this.logger);
14907
+ // initialize in memory storage for native flows
14908
+ var nativeCacheOptions = {
14909
+ cacheLocation: exports.BrowserCacheLocation.MemoryStorage,
14910
+ storeAuthStateInCookie: false,
14911
+ secureCookies: false
14912
+ };
14913
+ this.nativeInternalStorage = new BrowserCacheManager(this.config.auth.clientId, nativeCacheOptions, this.browserCrypto, this.logger);
14543
14914
  // Initialize the token cache
14544
14915
  this.tokenCache = new TokenCache(this.config, this.browserStorage, this.logger, this.browserCrypto);
14545
14916
  }
@@ -14606,7 +14977,7 @@
14606
14977
  redirectResponse = void 0;
14607
14978
  if (request && NativeMessageHandler.isNativeAvailable(this.config, this.logger, this.nativeExtensionProvider) && this.nativeExtensionProvider && !hash) {
14608
14979
  this.logger.trace("handleRedirectPromise - acquiring token from native platform");
14609
- 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);
14980
+ 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);
14610
14981
  redirectResponse = nativeClient.handleRedirectPromise();
14611
14982
  }
14612
14983
  else {
@@ -14678,13 +15049,19 @@
14678
15049
  this.eventHandler.emitEvent(exports.EventType.LOGIN_START, exports.InteractionType.Redirect, request);
14679
15050
  }
14680
15051
  if (this.nativeExtensionProvider && this.canUseNative(request)) {
14681
- 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);
15052
+ 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);
14682
15053
  result = nativeClient.acquireTokenRedirect(request).catch(function (e) {
14683
15054
  if (e instanceof NativeAuthError && e.isFatal()) {
14684
15055
  _this.nativeExtensionProvider = undefined; // If extension gets uninstalled during session prevent future requests from continuing to attempt
14685
15056
  var redirectClient = _this.createRedirectClient(request.correlationId);
14686
15057
  return redirectClient.acquireToken(request);
14687
15058
  }
15059
+ else if (e instanceof InteractionRequiredAuthError) {
15060
+ _this.logger.verbose("acquireTokenRedirect - Resolving interaction required error thrown by native broker by falling back to web flow");
15061
+ var redirectClient = _this.createRedirectClient(request.correlationId);
15062
+ return redirectClient.acquireToken(request);
15063
+ }
15064
+ _this.browserStorage.setInteractionInProgress(false);
14688
15065
  throw e;
14689
15066
  });
14690
15067
  }
@@ -14740,7 +15117,9 @@
14740
15117
  _this.browserStorage.setInteractionInProgress(false);
14741
15118
  atPopupMeasurement.endMeasurement({
14742
15119
  success: true,
14743
- isNativeBroker: true
15120
+ isNativeBroker: true,
15121
+ accessTokenSize: response.accessToken.length,
15122
+ idTokenSize: response.idToken.length,
14744
15123
  });
14745
15124
  atPopupMeasurement.flushMeasurement();
14746
15125
  return response;
@@ -14750,6 +15129,12 @@
14750
15129
  var popupClient = _this.createPopupClient(request.correlationId);
14751
15130
  return popupClient.acquireToken(request);
14752
15131
  }
15132
+ else if (e instanceof InteractionRequiredAuthError) {
15133
+ _this.logger.verbose("acquireTokenPopup - Resolving interaction required error thrown by native broker by falling back to web flow");
15134
+ var popupClient = _this.createPopupClient(request.correlationId);
15135
+ return popupClient.acquireToken(request);
15136
+ }
15137
+ _this.browserStorage.setInteractionInProgress(false);
14753
15138
  throw e;
14754
15139
  });
14755
15140
  }
@@ -14758,7 +15143,9 @@
14758
15143
  result = popupClient.acquireToken(request);
14759
15144
  }
14760
15145
  return result.then(function (result) {
14761
- // If logged in, emit acquire token events
15146
+ /*
15147
+ * If logged in, emit acquire token events
15148
+ */
14762
15149
  var isLoggingIn = loggedInAccounts.length < _this.getAllAccounts().length;
14763
15150
  if (isLoggingIn) {
14764
15151
  _this.eventHandler.emitEvent(exports.EventType.LOGIN_SUCCESS, exports.InteractionType.Popup, result);
@@ -14767,7 +15154,9 @@
14767
15154
  _this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_SUCCESS, exports.InteractionType.Popup, result);
14768
15155
  }
14769
15156
  atPopupMeasurement.endMeasurement({
14770
- success: true
15157
+ success: true,
15158
+ accessTokenSize: result.accessToken.length,
15159
+ idTokenSize: result.idToken.length,
14771
15160
  });
14772
15161
  atPopupMeasurement.flushMeasurement();
14773
15162
  return result;
@@ -14835,7 +15224,9 @@
14835
15224
  _this.eventHandler.emitEvent(exports.EventType.SSO_SILENT_SUCCESS, exports.InteractionType.Silent, response);
14836
15225
  ssoSilentMeasurement.endMeasurement({
14837
15226
  success: true,
14838
- isNativeBroker: response.fromNativeBroker
15227
+ isNativeBroker: response.fromNativeBroker,
15228
+ accessTokenSize: response.accessToken.length,
15229
+ idTokenSize: response.idToken.length
14839
15230
  });
14840
15231
  ssoSilentMeasurement.flushMeasurement();
14841
15232
  return response;
@@ -14884,6 +15275,8 @@
14884
15275
  _this.hybridAuthCodeResponses.delete(hybridAuthCode_1);
14885
15276
  atbcMeasurement.endMeasurement({
14886
15277
  success: true,
15278
+ accessTokenSize: result.accessToken.length,
15279
+ idTokenSize: result.idToken.length,
14887
15280
  isNativeBroker: result.fromNativeBroker
14888
15281
  });
14889
15282
  atbcMeasurement.flushMeasurement();
@@ -14988,7 +15381,9 @@
14988
15381
  .then(function (result) {
14989
15382
  atbrtMeasurement.endMeasurement({
14990
15383
  success: true,
14991
- fromCache: result.fromCache
15384
+ fromCache: result.fromCache,
15385
+ accessTokenSize: result.accessToken.length,
15386
+ idTokenSize: result.idToken.length,
14992
15387
  });
14993
15388
  return result;
14994
15389
  })
@@ -15003,7 +15398,9 @@
15003
15398
  .then(function (result) {
15004
15399
  atbrtMeasurement.endMeasurement({
15005
15400
  success: true,
15006
- fromCache: result.fromCache
15401
+ fromCache: result.fromCache,
15402
+ accessTokenSize: result.accessToken.length,
15403
+ idTokenSize: result.idToken.length,
15007
15404
  });
15008
15405
  return result;
15009
15406
  })
@@ -15215,7 +15612,7 @@
15215
15612
  if (!this.nativeExtensionProvider) {
15216
15613
  throw BrowserAuthError.createNativeConnectionNotEstablishedError();
15217
15614
  }
15218
- 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);
15615
+ 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);
15219
15616
  return [2 /*return*/, nativeClient.acquireToken(request)];
15220
15617
  });
15221
15618
  });
@@ -15234,6 +15631,7 @@
15234
15631
  switch (request.prompt) {
15235
15632
  case PromptValue.NONE:
15236
15633
  case PromptValue.CONSENT:
15634
+ case PromptValue.LOGIN:
15237
15635
  this.logger.trace("canUseNative: prompt is compatible with native flow");
15238
15636
  break;
15239
15637
  default:
@@ -15261,21 +15659,21 @@
15261
15659
  * @param correlationId
15262
15660
  */
15263
15661
  ClientApplication.prototype.createPopupClient = function (correlationId) {
15264
- return new PopupClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, this.performanceClient, this.nativeExtensionProvider, correlationId);
15662
+ return new PopupClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, this.performanceClient, this.nativeInternalStorage, this.nativeExtensionProvider, correlationId);
15265
15663
  };
15266
15664
  /**
15267
- * Returns new instance of the Popup Interaction Client
15665
+ * Returns new instance of the Redirect Interaction Client
15268
15666
  * @param correlationId
15269
15667
  */
15270
15668
  ClientApplication.prototype.createRedirectClient = function (correlationId) {
15271
- return new RedirectClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, this.performanceClient, this.nativeExtensionProvider, correlationId);
15669
+ return new RedirectClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, this.performanceClient, this.nativeInternalStorage, this.nativeExtensionProvider, correlationId);
15272
15670
  };
15273
15671
  /**
15274
15672
  * Returns new instance of the Silent Iframe Interaction Client
15275
15673
  * @param correlationId
15276
15674
  */
15277
15675
  ClientApplication.prototype.createSilentIframeClient = function (correlationId) {
15278
- return new SilentIframeClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, exports.ApiId.ssoSilent, this.performanceClient, this.nativeExtensionProvider, correlationId);
15676
+ 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);
15279
15677
  };
15280
15678
  /**
15281
15679
  * Returns new instance of the Silent Cache Interaction Client
@@ -15511,6 +15909,8 @@
15511
15909
  atsMeasurement.endMeasurement({
15512
15910
  success: true,
15513
15911
  fromCache: result.fromCache,
15912
+ accessTokenSize: result.accessToken.length,
15913
+ idTokenSize: result.idToken.length,
15514
15914
  isNativeBroker: result.fromNativeBroker
15515
15915
  });
15516
15916
  atsMeasurement.flushMeasurement();
@@ -15519,8 +15919,6 @@
15519
15919
  .catch(function (error) {
15520
15920
  _this.activeSilentTokenRequests.delete(silentRequestKey);
15521
15921
  atsMeasurement.endMeasurement({
15522
- errorCode: error.errorCode,
15523
- subErrorCode: error.subError,
15524
15922
  success: false
15525
15923
  });
15526
15924
  atsMeasurement.flushMeasurement();
@@ -15590,6 +15988,8 @@
15590
15988
  astsAsyncMeasurement.endMeasurement({
15591
15989
  success: true,
15592
15990
  fromCache: response.fromCache,
15991
+ accessTokenSize: response.accessToken.length,
15992
+ idTokenSize: response.idToken.length,
15593
15993
  isNativeBroker: response.fromNativeBroker
15594
15994
  });
15595
15995
  return response;