@azure/msal-browser 3.28.0 → 3.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app/IPublicClientApplication.mjs +1 -1
- package/dist/app/PublicClientApplication.mjs +1 -1
- package/dist/app/PublicClientNext.mjs +1 -1
- package/dist/broker/nativeBroker/NativeMessageHandler.mjs +1 -1
- package/dist/broker/nativeBroker/NativeStatusCodes.mjs +1 -1
- package/dist/cache/AccountManager.d.ts +7 -7
- package/dist/cache/AccountManager.d.ts.map +1 -1
- package/dist/cache/AccountManager.mjs +17 -15
- package/dist/cache/AccountManager.mjs.map +1 -1
- package/dist/cache/AsyncMemoryStorage.mjs +1 -1
- package/dist/cache/BrowserCacheManager.d.ts +35 -27
- package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
- package/dist/cache/BrowserCacheManager.mjs +187 -91
- package/dist/cache/BrowserCacheManager.mjs.map +1 -1
- package/dist/cache/BrowserStorage.mjs +1 -1
- package/dist/cache/CookieStorage.mjs +1 -1
- package/dist/cache/DatabaseStorage.mjs +1 -1
- package/dist/cache/LocalStorage.mjs +1 -1
- package/dist/cache/MemoryStorage.mjs +1 -1
- package/dist/cache/SessionStorage.mjs +1 -1
- package/dist/cache/TokenCache.d.ts.map +1 -1
- package/dist/cache/TokenCache.mjs +16 -15
- package/dist/cache/TokenCache.mjs.map +1 -1
- package/dist/config/Configuration.mjs +1 -1
- package/dist/controllers/ControllerFactory.mjs +1 -1
- package/dist/controllers/NestedAppAuthController.d.ts.map +1 -1
- package/dist/controllers/NestedAppAuthController.mjs +29 -19
- package/dist/controllers/NestedAppAuthController.mjs.map +1 -1
- package/dist/controllers/StandardController.d.ts.map +1 -1
- package/dist/controllers/StandardController.mjs +16 -9
- package/dist/controllers/StandardController.mjs.map +1 -1
- package/dist/controllers/UnknownOperatingContextController.mjs +1 -1
- package/dist/crypto/BrowserCrypto.d.ts +1 -1
- package/dist/crypto/BrowserCrypto.d.ts.map +1 -1
- package/dist/crypto/BrowserCrypto.mjs +3 -3
- package/dist/crypto/BrowserCrypto.mjs.map +1 -1
- package/dist/crypto/CryptoOps.d.ts +1 -1
- package/dist/crypto/CryptoOps.d.ts.map +1 -1
- package/dist/crypto/CryptoOps.mjs +3 -3
- package/dist/crypto/CryptoOps.mjs.map +1 -1
- package/dist/crypto/PkceGenerator.mjs +1 -1
- package/dist/crypto/SignedHttpRequest.mjs +1 -1
- package/dist/encode/Base64Decode.mjs +1 -1
- package/dist/encode/Base64Encode.mjs +1 -1
- package/dist/error/BrowserAuthError.mjs +1 -1
- package/dist/error/BrowserAuthErrorCodes.mjs +1 -1
- package/dist/error/BrowserConfigurationAuthError.mjs +1 -1
- package/dist/error/BrowserConfigurationAuthErrorCodes.mjs +1 -1
- package/dist/error/NativeAuthError.mjs +1 -1
- package/dist/error/NativeAuthErrorCodes.mjs +1 -1
- package/dist/error/NestedAppAuthError.mjs +1 -1
- package/dist/event/EventHandler.mjs +1 -1
- package/dist/event/EventMessage.mjs +1 -1
- package/dist/event/EventType.mjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/interaction_client/BaseInteractionClient.d.ts.map +1 -1
- package/dist/interaction_client/BaseInteractionClient.mjs +5 -5
- package/dist/interaction_client/BaseInteractionClient.mjs.map +1 -1
- package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
- package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
- package/dist/interaction_client/NativeInteractionClient.mjs +9 -7
- package/dist/interaction_client/NativeInteractionClient.mjs.map +1 -1
- package/dist/interaction_client/PopupClient.d.ts.map +1 -1
- package/dist/interaction_client/PopupClient.mjs +2 -2
- package/dist/interaction_client/PopupClient.mjs.map +1 -1
- package/dist/interaction_client/RedirectClient.d.ts.map +1 -1
- package/dist/interaction_client/RedirectClient.mjs +2 -2
- package/dist/interaction_client/RedirectClient.mjs.map +1 -1
- package/dist/interaction_client/SilentAuthCodeClient.mjs +1 -1
- package/dist/interaction_client/SilentCacheClient.mjs +1 -1
- package/dist/interaction_client/SilentIframeClient.mjs +1 -1
- package/dist/interaction_client/SilentRefreshClient.mjs +1 -1
- package/dist/interaction_client/StandardInteractionClient.d.ts.map +1 -1
- package/dist/interaction_client/StandardInteractionClient.mjs +3 -2
- package/dist/interaction_client/StandardInteractionClient.mjs.map +1 -1
- package/dist/interaction_handler/InteractionHandler.mjs +1 -1
- package/dist/interaction_handler/RedirectHandler.mjs +1 -1
- package/dist/interaction_handler/SilentHandler.mjs +1 -1
- package/dist/naa/BridgeError.mjs +1 -1
- package/dist/naa/BridgeProxy.mjs +1 -1
- package/dist/naa/BridgeStatusCode.mjs +1 -1
- package/dist/naa/mapping/NestedAppAuthAdapter.mjs +1 -1
- package/dist/navigation/NavigationClient.mjs +1 -1
- package/dist/network/FetchClient.mjs +1 -1
- package/dist/operatingcontext/BaseOperatingContext.mjs +1 -1
- package/dist/operatingcontext/NestedAppOperatingContext.mjs +1 -1
- package/dist/operatingcontext/StandardOperatingContext.mjs +1 -1
- package/dist/operatingcontext/UnknownOperatingContext.mjs +1 -1
- package/dist/packageMetadata.d.ts +1 -1
- package/dist/packageMetadata.mjs +2 -2
- package/dist/request/RequestHelpers.mjs +1 -1
- package/dist/response/ResponseHandler.mjs +1 -1
- package/dist/telemetry/BrowserPerformanceClient.mjs +1 -1
- package/dist/telemetry/BrowserPerformanceMeasurement.mjs +1 -1
- package/dist/utils/BrowserConstants.d.ts +1 -0
- package/dist/utils/BrowserConstants.d.ts.map +1 -1
- package/dist/utils/BrowserConstants.mjs +2 -1
- package/dist/utils/BrowserConstants.mjs.map +1 -1
- package/dist/utils/BrowserProtocolUtils.mjs +1 -1
- package/dist/utils/BrowserUtils.d.ts.map +1 -1
- package/dist/utils/BrowserUtils.mjs +4 -2
- package/dist/utils/BrowserUtils.mjs.map +1 -1
- package/lib/msal-browser.cjs +472 -349
- package/lib/msal-browser.cjs.map +1 -1
- package/lib/msal-browser.js +472 -349
- package/lib/msal-browser.js.map +1 -1
- package/lib/msal-browser.min.js +65 -66
- package/lib/types/cache/AccountManager.d.ts +7 -7
- package/lib/types/cache/AccountManager.d.ts.map +1 -1
- package/lib/types/cache/BrowserCacheManager.d.ts +35 -27
- package/lib/types/cache/BrowserCacheManager.d.ts.map +1 -1
- package/lib/types/cache/TokenCache.d.ts.map +1 -1
- package/lib/types/controllers/NestedAppAuthController.d.ts.map +1 -1
- package/lib/types/controllers/StandardController.d.ts.map +1 -1
- package/lib/types/crypto/BrowserCrypto.d.ts +1 -1
- package/lib/types/crypto/BrowserCrypto.d.ts.map +1 -1
- package/lib/types/crypto/CryptoOps.d.ts +1 -1
- package/lib/types/crypto/CryptoOps.d.ts.map +1 -1
- package/lib/types/interaction_client/BaseInteractionClient.d.ts.map +1 -1
- package/lib/types/interaction_client/NativeInteractionClient.d.ts.map +1 -1
- package/lib/types/interaction_client/PopupClient.d.ts.map +1 -1
- package/lib/types/interaction_client/RedirectClient.d.ts.map +1 -1
- package/lib/types/interaction_client/StandardInteractionClient.d.ts.map +1 -1
- package/lib/types/packageMetadata.d.ts +1 -1
- package/lib/types/utils/BrowserConstants.d.ts +1 -0
- package/lib/types/utils/BrowserConstants.d.ts.map +1 -1
- package/lib/types/utils/BrowserUtils.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/cache/AccountManager.ts +40 -20
- package/src/cache/BrowserCacheManager.ts +332 -109
- package/src/cache/TokenCache.ts +25 -11
- package/src/controllers/NestedAppAuthController.ts +52 -19
- package/src/controllers/StandardController.ts +26 -7
- package/src/crypto/BrowserCrypto.ts +4 -2
- package/src/crypto/CryptoOps.ts +8 -2
- package/src/interaction_client/BaseInteractionClient.ts +5 -4
- package/src/interaction_client/NativeInteractionClient.ts +22 -12
- package/src/interaction_client/PopupClient.ts +2 -1
- package/src/interaction_client/RedirectClient.ts +2 -1
- package/src/interaction_client/StandardInteractionClient.ts +2 -1
- package/src/packageMetadata.ts +1 -1
- package/src/utils/BrowserConstants.ts +1 -0
- package/src/utils/BrowserUtils.ts +3 -1
package/lib/msal-browser.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/*! @azure/msal-browser v3.
|
|
1
|
+
/*! @azure/msal-browser v3.30.0 2025-08-05 */
|
|
2
2
|
'use strict';
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
|
-
/*! @azure/msal-common v14.16.
|
|
5
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
6
6
|
/*
|
|
7
7
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
8
8
|
* Licensed under the MIT License.
|
|
@@ -312,7 +312,7 @@ const JsonWebTokenTypes = {
|
|
|
312
312
|
// Token renewal offset default in seconds
|
|
313
313
|
const DEFAULT_TOKEN_RENEWAL_OFFSET_SEC = 300;
|
|
314
314
|
|
|
315
|
-
/*! @azure/msal-common v14.16.
|
|
315
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
316
316
|
/*
|
|
317
317
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
318
318
|
* Licensed under the MIT License.
|
|
@@ -329,7 +329,7 @@ var AuthErrorCodes = /*#__PURE__*/Object.freeze({
|
|
|
329
329
|
unexpectedError: unexpectedError
|
|
330
330
|
});
|
|
331
331
|
|
|
332
|
-
/*! @azure/msal-common v14.16.
|
|
332
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
333
333
|
|
|
334
334
|
/*
|
|
335
335
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -378,7 +378,7 @@ function createAuthError(code, additionalMessage) {
|
|
|
378
378
|
: AuthErrorMessages[code]);
|
|
379
379
|
}
|
|
380
380
|
|
|
381
|
-
/*! @azure/msal-common v14.16.
|
|
381
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
382
382
|
/*
|
|
383
383
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
384
384
|
* Licensed under the MIT License.
|
|
@@ -476,7 +476,7 @@ var ClientAuthErrorCodes = /*#__PURE__*/Object.freeze({
|
|
|
476
476
|
userTimeoutReached: userTimeoutReached
|
|
477
477
|
});
|
|
478
478
|
|
|
479
|
-
/*! @azure/msal-common v14.16.
|
|
479
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
480
480
|
|
|
481
481
|
/*
|
|
482
482
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -728,7 +728,7 @@ function createClientAuthError(errorCode, additionalMessage) {
|
|
|
728
728
|
return new ClientAuthError(errorCode, additionalMessage);
|
|
729
729
|
}
|
|
730
730
|
|
|
731
|
-
/*! @azure/msal-common v14.16.
|
|
731
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
732
732
|
|
|
733
733
|
/*
|
|
734
734
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -767,7 +767,7 @@ const DEFAULT_CRYPTO_IMPLEMENTATION = {
|
|
|
767
767
|
},
|
|
768
768
|
};
|
|
769
769
|
|
|
770
|
-
/*! @azure/msal-common v14.16.
|
|
770
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
771
771
|
|
|
772
772
|
/*
|
|
773
773
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -958,12 +958,12 @@ class Logger {
|
|
|
958
958
|
}
|
|
959
959
|
}
|
|
960
960
|
|
|
961
|
-
/*! @azure/msal-common v14.16.
|
|
961
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
962
962
|
/* eslint-disable header/header */
|
|
963
963
|
const name$1 = "@azure/msal-common";
|
|
964
|
-
const version$1 = "14.16.
|
|
964
|
+
const version$1 = "14.16.1";
|
|
965
965
|
|
|
966
|
-
/*! @azure/msal-common v14.16.
|
|
966
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
967
967
|
/*
|
|
968
968
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
969
969
|
* Licensed under the MIT License.
|
|
@@ -983,7 +983,7 @@ const AzureCloudInstance = {
|
|
|
983
983
|
AzureUsGovernment: "https://login.microsoftonline.us",
|
|
984
984
|
};
|
|
985
985
|
|
|
986
|
-
/*! @azure/msal-common v14.16.
|
|
986
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
987
987
|
|
|
988
988
|
/*
|
|
989
989
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1044,7 +1044,7 @@ function checkMaxAge(authTime, maxAge) {
|
|
|
1044
1044
|
}
|
|
1045
1045
|
}
|
|
1046
1046
|
|
|
1047
|
-
/*! @azure/msal-common v14.16.
|
|
1047
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
1048
1048
|
/*
|
|
1049
1049
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1050
1050
|
* Licensed under the MIT License.
|
|
@@ -1081,7 +1081,7 @@ function wasClockTurnedBack(cachedAt) {
|
|
|
1081
1081
|
return cachedAtSec > nowSeconds();
|
|
1082
1082
|
}
|
|
1083
1083
|
|
|
1084
|
-
/*! @azure/msal-common v14.16.
|
|
1084
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
1085
1085
|
|
|
1086
1086
|
/*
|
|
1087
1087
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1408,7 +1408,7 @@ function isAuthorityMetadataExpired(metadata) {
|
|
|
1408
1408
|
return metadata.expiresAt <= nowSeconds();
|
|
1409
1409
|
}
|
|
1410
1410
|
|
|
1411
|
-
/*! @azure/msal-common v14.16.
|
|
1411
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
1412
1412
|
/*
|
|
1413
1413
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1414
1414
|
* Licensed under the MIT License.
|
|
@@ -1462,7 +1462,7 @@ var ClientConfigurationErrorCodes = /*#__PURE__*/Object.freeze({
|
|
|
1462
1462
|
urlParseError: urlParseError
|
|
1463
1463
|
});
|
|
1464
1464
|
|
|
1465
|
-
/*! @azure/msal-common v14.16.
|
|
1465
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
1466
1466
|
|
|
1467
1467
|
/*
|
|
1468
1468
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1600,7 +1600,7 @@ function createClientConfigurationError(errorCode) {
|
|
|
1600
1600
|
return new ClientConfigurationError(errorCode);
|
|
1601
1601
|
}
|
|
1602
1602
|
|
|
1603
|
-
/*! @azure/msal-common v14.16.
|
|
1603
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
1604
1604
|
/*
|
|
1605
1605
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1606
1606
|
* Licensed under the MIT License.
|
|
@@ -1697,7 +1697,7 @@ class StringUtils {
|
|
|
1697
1697
|
}
|
|
1698
1698
|
}
|
|
1699
1699
|
|
|
1700
|
-
/*! @azure/msal-common v14.16.
|
|
1700
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
1701
1701
|
|
|
1702
1702
|
/*
|
|
1703
1703
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1897,7 +1897,7 @@ class ScopeSet {
|
|
|
1897
1897
|
}
|
|
1898
1898
|
}
|
|
1899
1899
|
|
|
1900
|
-
/*! @azure/msal-common v14.16.
|
|
1900
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
1901
1901
|
|
|
1902
1902
|
/*
|
|
1903
1903
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1937,7 +1937,7 @@ function buildClientInfoFromHomeAccountId(homeAccountId) {
|
|
|
1937
1937
|
};
|
|
1938
1938
|
}
|
|
1939
1939
|
|
|
1940
|
-
/*! @azure/msal-common v14.16.
|
|
1940
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
1941
1941
|
/*
|
|
1942
1942
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1943
1943
|
* Licensed under the MIT License.
|
|
@@ -2016,7 +2016,7 @@ function updateAccountTenantProfileData(baseAccountInfo, tenantProfile, idTokenC
|
|
|
2016
2016
|
return updatedAccountInfo;
|
|
2017
2017
|
}
|
|
2018
2018
|
|
|
2019
|
-
/*! @azure/msal-common v14.16.
|
|
2019
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
2020
2020
|
/*
|
|
2021
2021
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2022
2022
|
* Licensed under the MIT License.
|
|
@@ -2031,7 +2031,7 @@ const AuthorityType = {
|
|
|
2031
2031
|
Ciam: 3,
|
|
2032
2032
|
};
|
|
2033
2033
|
|
|
2034
|
-
/*! @azure/msal-common v14.16.
|
|
2034
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
2035
2035
|
/*
|
|
2036
2036
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2037
2037
|
* Licensed under the MIT License.
|
|
@@ -2053,7 +2053,7 @@ function getTenantIdFromIdTokenClaims(idTokenClaims) {
|
|
|
2053
2053
|
return null;
|
|
2054
2054
|
}
|
|
2055
2055
|
|
|
2056
|
-
/*! @azure/msal-common v14.16.
|
|
2056
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
2057
2057
|
/*
|
|
2058
2058
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2059
2059
|
* Licensed under the MIT License.
|
|
@@ -2066,7 +2066,7 @@ const ProtocolMode = {
|
|
|
2066
2066
|
OIDC: "OIDC",
|
|
2067
2067
|
};
|
|
2068
2068
|
|
|
2069
|
-
/*! @azure/msal-common v14.16.
|
|
2069
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
2070
2070
|
|
|
2071
2071
|
/*
|
|
2072
2072
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2309,7 +2309,7 @@ class AccountEntity {
|
|
|
2309
2309
|
}
|
|
2310
2310
|
}
|
|
2311
2311
|
|
|
2312
|
-
/*! @azure/msal-common v14.16.
|
|
2312
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
2313
2313
|
|
|
2314
2314
|
/*
|
|
2315
2315
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2356,7 +2356,7 @@ function getDeserializedResponse(responseString) {
|
|
|
2356
2356
|
return null;
|
|
2357
2357
|
}
|
|
2358
2358
|
|
|
2359
|
-
/*! @azure/msal-common v14.16.
|
|
2359
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
2360
2360
|
|
|
2361
2361
|
/*
|
|
2362
2362
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2520,7 +2520,7 @@ class UrlString {
|
|
|
2520
2520
|
}
|
|
2521
2521
|
}
|
|
2522
2522
|
|
|
2523
|
-
/*! @azure/msal-common v14.16.
|
|
2523
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
2524
2524
|
|
|
2525
2525
|
/*
|
|
2526
2526
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2660,23 +2660,23 @@ function getCloudDiscoveryMetadataFromNetworkResponse(response, authorityHost) {
|
|
|
2660
2660
|
return null;
|
|
2661
2661
|
}
|
|
2662
2662
|
|
|
2663
|
-
/*! @azure/msal-common v14.16.
|
|
2663
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
2664
2664
|
/*
|
|
2665
2665
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2666
2666
|
* Licensed under the MIT License.
|
|
2667
2667
|
*/
|
|
2668
|
-
const
|
|
2669
|
-
const
|
|
2668
|
+
const cacheQuotaExceeded = "cache_quota_exceeded";
|
|
2669
|
+
const cacheErrorUnknown = "cache_error_unknown";
|
|
2670
2670
|
|
|
2671
|
-
/*! @azure/msal-common v14.16.
|
|
2671
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
2672
2672
|
|
|
2673
2673
|
/*
|
|
2674
2674
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2675
2675
|
* Licensed under the MIT License.
|
|
2676
2676
|
*/
|
|
2677
2677
|
const CacheErrorMessages = {
|
|
2678
|
-
[
|
|
2679
|
-
[
|
|
2678
|
+
[cacheQuotaExceeded]: "Exceeded cache storage capacity.",
|
|
2679
|
+
[cacheErrorUnknown]: "Unexpected error occurred when using cache storage.",
|
|
2680
2680
|
};
|
|
2681
2681
|
/**
|
|
2682
2682
|
* Error thrown when there is an error with the cache
|
|
@@ -2686,16 +2686,34 @@ class CacheError extends Error {
|
|
|
2686
2686
|
const message = errorMessage ||
|
|
2687
2687
|
(CacheErrorMessages[errorCode]
|
|
2688
2688
|
? CacheErrorMessages[errorCode]
|
|
2689
|
-
: CacheErrorMessages[
|
|
2689
|
+
: CacheErrorMessages[cacheErrorUnknown]);
|
|
2690
2690
|
super(`${errorCode}: ${message}`);
|
|
2691
2691
|
Object.setPrototypeOf(this, CacheError.prototype);
|
|
2692
2692
|
this.name = "CacheError";
|
|
2693
2693
|
this.errorCode = errorCode;
|
|
2694
2694
|
this.errorMessage = message;
|
|
2695
2695
|
}
|
|
2696
|
+
}
|
|
2697
|
+
/**
|
|
2698
|
+
* Helper function to wrap browser errors in a CacheError object
|
|
2699
|
+
* @param e
|
|
2700
|
+
* @returns
|
|
2701
|
+
*/
|
|
2702
|
+
function createCacheError(e) {
|
|
2703
|
+
if (!(e instanceof Error)) {
|
|
2704
|
+
return new CacheError(cacheErrorUnknown);
|
|
2705
|
+
}
|
|
2706
|
+
if (e.name === "QuotaExceededError" ||
|
|
2707
|
+
e.name === "NS_ERROR_DOM_QUOTA_REACHED" ||
|
|
2708
|
+
e.message.includes("exceeded the quota")) {
|
|
2709
|
+
return new CacheError(cacheQuotaExceeded);
|
|
2710
|
+
}
|
|
2711
|
+
else {
|
|
2712
|
+
return new CacheError(e.name, e.message);
|
|
2713
|
+
}
|
|
2696
2714
|
}
|
|
2697
2715
|
|
|
2698
|
-
/*! @azure/msal-common v14.16.
|
|
2716
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
2699
2717
|
|
|
2700
2718
|
/*
|
|
2701
2719
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2717,14 +2735,14 @@ class CacheManager {
|
|
|
2717
2735
|
* @param accountFilter - (Optional) filter to narrow down the accounts returned
|
|
2718
2736
|
* @returns Array of AccountInfo objects in cache
|
|
2719
2737
|
*/
|
|
2720
|
-
getAllAccounts(accountFilter) {
|
|
2721
|
-
return this.buildTenantProfiles(this.getAccountsFilteredBy(accountFilter || {}), accountFilter);
|
|
2738
|
+
getAllAccounts(correlationId, accountFilter) {
|
|
2739
|
+
return this.buildTenantProfiles(this.getAccountsFilteredBy(accountFilter || {}, correlationId), correlationId, accountFilter);
|
|
2722
2740
|
}
|
|
2723
2741
|
/**
|
|
2724
2742
|
* Gets first tenanted AccountInfo object found based on provided filters
|
|
2725
2743
|
*/
|
|
2726
|
-
getAccountInfoFilteredBy(accountFilter) {
|
|
2727
|
-
const allAccounts = this.getAllAccounts(accountFilter);
|
|
2744
|
+
getAccountInfoFilteredBy(accountFilter, correlationId) {
|
|
2745
|
+
const allAccounts = this.getAllAccounts(correlationId, accountFilter);
|
|
2728
2746
|
if (allAccounts.length > 1) {
|
|
2729
2747
|
// If one or more accounts are found, prioritize accounts that have an ID token
|
|
2730
2748
|
const sortedAccounts = allAccounts.sort((account) => {
|
|
@@ -2745,8 +2763,8 @@ class CacheManager {
|
|
|
2745
2763
|
* @param accountFilter
|
|
2746
2764
|
* @returns
|
|
2747
2765
|
*/
|
|
2748
|
-
getBaseAccountInfo(accountFilter) {
|
|
2749
|
-
const accountEntities = this.getAccountsFilteredBy(accountFilter);
|
|
2766
|
+
getBaseAccountInfo(accountFilter, correlationId) {
|
|
2767
|
+
const accountEntities = this.getAccountsFilteredBy(accountFilter, correlationId);
|
|
2750
2768
|
if (accountEntities.length > 0) {
|
|
2751
2769
|
return accountEntities[0].getAccountInfo();
|
|
2752
2770
|
}
|
|
@@ -2761,12 +2779,12 @@ class CacheManager {
|
|
|
2761
2779
|
* @param accountFilter
|
|
2762
2780
|
* @returns Array of AccountInfo objects that match account and tenant profile filters
|
|
2763
2781
|
*/
|
|
2764
|
-
buildTenantProfiles(cachedAccounts, accountFilter) {
|
|
2782
|
+
buildTenantProfiles(cachedAccounts, correlationId, accountFilter) {
|
|
2765
2783
|
return cachedAccounts.flatMap((accountEntity) => {
|
|
2766
|
-
return this.getTenantProfilesFromAccountEntity(accountEntity, accountFilter?.tenantId, accountFilter);
|
|
2784
|
+
return this.getTenantProfilesFromAccountEntity(accountEntity, correlationId, accountFilter?.tenantId, accountFilter);
|
|
2767
2785
|
});
|
|
2768
2786
|
}
|
|
2769
|
-
getTenantedAccountInfoByFilter(accountInfo, tokenKeys, tenantProfile, tenantProfileFilter) {
|
|
2787
|
+
getTenantedAccountInfoByFilter(accountInfo, tokenKeys, tenantProfile, correlationId, tenantProfileFilter) {
|
|
2770
2788
|
let tenantedAccountInfo = null;
|
|
2771
2789
|
let idTokenClaims;
|
|
2772
2790
|
if (tenantProfileFilter) {
|
|
@@ -2774,7 +2792,7 @@ class CacheManager {
|
|
|
2774
2792
|
return null;
|
|
2775
2793
|
}
|
|
2776
2794
|
}
|
|
2777
|
-
const idToken = this.getIdToken(accountInfo, tokenKeys, tenantProfile.tenantId);
|
|
2795
|
+
const idToken = this.getIdToken(accountInfo, correlationId, tokenKeys, tenantProfile.tenantId);
|
|
2778
2796
|
if (idToken) {
|
|
2779
2797
|
idTokenClaims = extractTokenClaims(idToken.secret, this.cryptoImpl.base64Decode);
|
|
2780
2798
|
if (!this.idTokenClaimsMatchTenantProfileFilter(idTokenClaims, tenantProfileFilter)) {
|
|
@@ -2786,7 +2804,7 @@ class CacheManager {
|
|
|
2786
2804
|
tenantedAccountInfo = updateAccountTenantProfileData(accountInfo, tenantProfile, idTokenClaims, idToken?.secret);
|
|
2787
2805
|
return tenantedAccountInfo;
|
|
2788
2806
|
}
|
|
2789
|
-
getTenantProfilesFromAccountEntity(accountEntity, targetTenantId, tenantProfileFilter) {
|
|
2807
|
+
getTenantProfilesFromAccountEntity(accountEntity, correlationId, targetTenantId, tenantProfileFilter) {
|
|
2790
2808
|
const accountInfo = accountEntity.getAccountInfo();
|
|
2791
2809
|
let searchTenantProfiles = accountInfo.tenantProfiles || new Map();
|
|
2792
2810
|
const tokenKeys = this.getTokenKeys();
|
|
@@ -2806,7 +2824,7 @@ class CacheManager {
|
|
|
2806
2824
|
}
|
|
2807
2825
|
const matchingTenantProfiles = [];
|
|
2808
2826
|
searchTenantProfiles.forEach((tenantProfile) => {
|
|
2809
|
-
const tenantedAccountInfo = this.getTenantedAccountInfoByFilter(accountInfo, tokenKeys, tenantProfile, tenantProfileFilter);
|
|
2827
|
+
const tenantedAccountInfo = this.getTenantedAccountInfoByFilter(accountInfo, tokenKeys, tenantProfile, correlationId, tenantProfileFilter);
|
|
2810
2828
|
if (tenantedAccountInfo) {
|
|
2811
2829
|
matchingTenantProfiles.push(tenantedAccountInfo);
|
|
2812
2830
|
}
|
|
@@ -2860,46 +2878,36 @@ class CacheManager {
|
|
|
2860
2878
|
* @param storeInCache {?StoreInCache}
|
|
2861
2879
|
* @param correlationId {?string} correlation id
|
|
2862
2880
|
*/
|
|
2863
|
-
async saveCacheRecord(cacheRecord,
|
|
2881
|
+
async saveCacheRecord(cacheRecord, correlationId, storeInCache) {
|
|
2864
2882
|
if (!cacheRecord) {
|
|
2865
2883
|
throw createClientAuthError(invalidCacheRecord);
|
|
2866
2884
|
}
|
|
2867
2885
|
try {
|
|
2868
2886
|
if (!!cacheRecord.account) {
|
|
2869
|
-
this.setAccount(cacheRecord.account);
|
|
2887
|
+
this.setAccount(cacheRecord.account, correlationId);
|
|
2870
2888
|
}
|
|
2871
2889
|
if (!!cacheRecord.idToken && storeInCache?.idToken !== false) {
|
|
2872
|
-
this.setIdTokenCredential(cacheRecord.idToken);
|
|
2890
|
+
this.setIdTokenCredential(cacheRecord.idToken, correlationId);
|
|
2873
2891
|
}
|
|
2874
2892
|
if (!!cacheRecord.accessToken &&
|
|
2875
2893
|
storeInCache?.accessToken !== false) {
|
|
2876
|
-
await this.saveAccessToken(cacheRecord.accessToken);
|
|
2894
|
+
await this.saveAccessToken(cacheRecord.accessToken, correlationId);
|
|
2877
2895
|
}
|
|
2878
2896
|
if (!!cacheRecord.refreshToken &&
|
|
2879
2897
|
storeInCache?.refreshToken !== false) {
|
|
2880
|
-
this.setRefreshTokenCredential(cacheRecord.refreshToken);
|
|
2898
|
+
this.setRefreshTokenCredential(cacheRecord.refreshToken, correlationId);
|
|
2881
2899
|
}
|
|
2882
2900
|
if (!!cacheRecord.appMetadata) {
|
|
2883
|
-
this.setAppMetadata(cacheRecord.appMetadata);
|
|
2901
|
+
this.setAppMetadata(cacheRecord.appMetadata, correlationId);
|
|
2884
2902
|
}
|
|
2885
2903
|
}
|
|
2886
2904
|
catch (e) {
|
|
2887
2905
|
this.commonLogger?.error(`CacheManager.saveCacheRecord: failed`);
|
|
2888
|
-
if (e instanceof
|
|
2889
|
-
|
|
2890
|
-
if (e.name === "QuotaExceededError" ||
|
|
2891
|
-
e.name === "NS_ERROR_DOM_QUOTA_REACHED" ||
|
|
2892
|
-
e.message.includes("exceeded the quota")) {
|
|
2893
|
-
this.commonLogger?.error(`CacheManager.saveCacheRecord: exceeded storage quota`, correlationId);
|
|
2894
|
-
throw new CacheError(cacheQuotaExceededErrorCode);
|
|
2895
|
-
}
|
|
2896
|
-
else {
|
|
2897
|
-
throw new CacheError(e.name, e.message);
|
|
2898
|
-
}
|
|
2906
|
+
if (e instanceof AuthError) {
|
|
2907
|
+
throw e;
|
|
2899
2908
|
}
|
|
2900
2909
|
else {
|
|
2901
|
-
|
|
2902
|
-
throw new CacheError(cacheUnknownErrorCode);
|
|
2910
|
+
throw createCacheError(e);
|
|
2903
2911
|
}
|
|
2904
2912
|
}
|
|
2905
2913
|
}
|
|
@@ -2907,7 +2915,7 @@ class CacheManager {
|
|
|
2907
2915
|
* saves access token credential
|
|
2908
2916
|
* @param credential
|
|
2909
2917
|
*/
|
|
2910
|
-
async saveAccessToken(credential) {
|
|
2918
|
+
async saveAccessToken(credential, correlationId) {
|
|
2911
2919
|
const accessTokenFilter = {
|
|
2912
2920
|
clientId: credential.clientId,
|
|
2913
2921
|
credentialType: credential.credentialType,
|
|
@@ -2919,29 +2927,27 @@ class CacheManager {
|
|
|
2919
2927
|
};
|
|
2920
2928
|
const tokenKeys = this.getTokenKeys();
|
|
2921
2929
|
const currentScopes = ScopeSet.fromString(credential.target);
|
|
2922
|
-
const removedAccessTokens = [];
|
|
2923
2930
|
tokenKeys.accessToken.forEach((key) => {
|
|
2924
2931
|
if (!this.accessTokenKeyMatchesFilter(key, accessTokenFilter, false)) {
|
|
2925
2932
|
return;
|
|
2926
2933
|
}
|
|
2927
|
-
const tokenEntity = this.getAccessTokenCredential(key);
|
|
2934
|
+
const tokenEntity = this.getAccessTokenCredential(key, correlationId);
|
|
2928
2935
|
if (tokenEntity &&
|
|
2929
2936
|
this.credentialMatchesFilter(tokenEntity, accessTokenFilter)) {
|
|
2930
2937
|
const tokenScopeSet = ScopeSet.fromString(tokenEntity.target);
|
|
2931
2938
|
if (tokenScopeSet.intersectingScopeSets(currentScopes)) {
|
|
2932
|
-
|
|
2939
|
+
this.removeAccessToken(key, correlationId);
|
|
2933
2940
|
}
|
|
2934
2941
|
}
|
|
2935
2942
|
});
|
|
2936
|
-
|
|
2937
|
-
this.setAccessTokenCredential(credential);
|
|
2943
|
+
this.setAccessTokenCredential(credential, correlationId);
|
|
2938
2944
|
}
|
|
2939
2945
|
/**
|
|
2940
2946
|
* Retrieve account entities matching all provided tenant-agnostic filters; if no filter is set, get all account entities in the cache
|
|
2941
2947
|
* Not checking for casing as keys are all generated in lower case, remember to convert to lower case if object properties are compared
|
|
2942
2948
|
* @param accountFilter - An object containing Account properties to filter by
|
|
2943
2949
|
*/
|
|
2944
|
-
getAccountsFilteredBy(accountFilter) {
|
|
2950
|
+
getAccountsFilteredBy(accountFilter, correlationId) {
|
|
2945
2951
|
const allAccountKeys = this.getAccountKeys();
|
|
2946
2952
|
const matchingAccounts = [];
|
|
2947
2953
|
allAccountKeys.forEach((cacheKey) => {
|
|
@@ -2949,7 +2955,7 @@ class CacheManager {
|
|
|
2949
2955
|
// Don't parse value if the key doesn't match the account filters
|
|
2950
2956
|
return;
|
|
2951
2957
|
}
|
|
2952
|
-
const entity = this.getAccount(cacheKey, this.commonLogger);
|
|
2958
|
+
const entity = this.getAccount(cacheKey, correlationId, this.commonLogger);
|
|
2953
2959
|
// Match base account fields
|
|
2954
2960
|
if (!entity) {
|
|
2955
2961
|
return;
|
|
@@ -3175,11 +3181,11 @@ class CacheManager {
|
|
|
3175
3181
|
/**
|
|
3176
3182
|
* Removes all accounts and related tokens from cache.
|
|
3177
3183
|
*/
|
|
3178
|
-
async removeAllAccounts() {
|
|
3184
|
+
async removeAllAccounts(correlationId) {
|
|
3179
3185
|
const allAccountKeys = this.getAccountKeys();
|
|
3180
3186
|
const removedAccounts = [];
|
|
3181
3187
|
allAccountKeys.forEach((cacheKey) => {
|
|
3182
|
-
removedAccounts.push(this.removeAccount(cacheKey));
|
|
3188
|
+
removedAccounts.push(this.removeAccount(cacheKey, correlationId));
|
|
3183
3189
|
});
|
|
3184
3190
|
await Promise.all(removedAccounts);
|
|
3185
3191
|
}
|
|
@@ -3187,38 +3193,41 @@ class CacheManager {
|
|
|
3187
3193
|
* Removes the account and related tokens for a given account key
|
|
3188
3194
|
* @param account
|
|
3189
3195
|
*/
|
|
3190
|
-
async removeAccount(accountKey) {
|
|
3191
|
-
const account = this.getAccount(accountKey, this.commonLogger);
|
|
3196
|
+
async removeAccount(accountKey, correlationId) {
|
|
3197
|
+
const account = this.getAccount(accountKey, correlationId, this.commonLogger);
|
|
3192
3198
|
if (!account) {
|
|
3193
3199
|
return;
|
|
3194
3200
|
}
|
|
3195
|
-
await this.removeAccountContext(account);
|
|
3196
|
-
this.removeItem(accountKey);
|
|
3201
|
+
await this.removeAccountContext(account, correlationId);
|
|
3202
|
+
this.removeItem(accountKey, correlationId);
|
|
3197
3203
|
}
|
|
3198
3204
|
/**
|
|
3199
3205
|
* Removes credentials associated with the provided account
|
|
3200
3206
|
* @param account
|
|
3201
3207
|
*/
|
|
3202
|
-
async removeAccountContext(account) {
|
|
3208
|
+
async removeAccountContext(account, correlationId) {
|
|
3203
3209
|
const allTokenKeys = this.getTokenKeys();
|
|
3204
3210
|
const accountId = account.generateAccountId();
|
|
3205
|
-
const removedCredentials = [];
|
|
3206
3211
|
allTokenKeys.idToken.forEach((key) => {
|
|
3207
3212
|
if (key.indexOf(accountId) === 0) {
|
|
3208
|
-
this.removeIdToken(key);
|
|
3213
|
+
this.removeIdToken(key, correlationId);
|
|
3209
3214
|
}
|
|
3210
3215
|
});
|
|
3211
3216
|
allTokenKeys.accessToken.forEach((key) => {
|
|
3212
3217
|
if (key.indexOf(accountId) === 0) {
|
|
3213
|
-
|
|
3218
|
+
this.removeAccessToken(key, correlationId);
|
|
3214
3219
|
}
|
|
3215
3220
|
});
|
|
3216
3221
|
allTokenKeys.refreshToken.forEach((key) => {
|
|
3217
3222
|
if (key.indexOf(accountId) === 0) {
|
|
3218
|
-
this.removeRefreshToken(key);
|
|
3223
|
+
this.removeRefreshToken(key, correlationId);
|
|
3224
|
+
}
|
|
3225
|
+
});
|
|
3226
|
+
this.getKeys().forEach((key) => {
|
|
3227
|
+
if (key.includes(accountId)) {
|
|
3228
|
+
this.removeItem(key, correlationId);
|
|
3219
3229
|
}
|
|
3220
3230
|
});
|
|
3221
|
-
await Promise.all(removedCredentials);
|
|
3222
3231
|
}
|
|
3223
3232
|
/**
|
|
3224
3233
|
* Migrates a single-tenant account and all it's associated alternate cross-tenant account objects in the
|
|
@@ -3228,7 +3237,7 @@ class CacheManager {
|
|
|
3228
3237
|
* @param logger
|
|
3229
3238
|
* @returns
|
|
3230
3239
|
*/
|
|
3231
|
-
updateOutdatedCachedAccount(accountKey, accountEntity, logger) {
|
|
3240
|
+
updateOutdatedCachedAccount(accountKey, accountEntity, correlationId, logger) {
|
|
3232
3241
|
// Only update if account entity is defined and has no tenantProfiles object (is outdated)
|
|
3233
3242
|
if (accountEntity && accountEntity.isSingleTenant()) {
|
|
3234
3243
|
this.commonLogger?.verbose("updateOutdatedCachedAccount: Found a single-tenant (outdated) account entity in the cache, migrating to multi-tenant account entity");
|
|
@@ -3239,7 +3248,7 @@ class CacheManager {
|
|
|
3239
3248
|
// Get all account entities belonging to user
|
|
3240
3249
|
const accountsToMerge = [];
|
|
3241
3250
|
matchingAccountKeys.forEach((key) => {
|
|
3242
|
-
const account = this.getCachedAccountEntity(key);
|
|
3251
|
+
const account = this.getCachedAccountEntity(key, correlationId);
|
|
3243
3252
|
if (account) {
|
|
3244
3253
|
accountsToMerge.push(account);
|
|
3245
3254
|
}
|
|
@@ -3264,11 +3273,11 @@ class CacheManager {
|
|
|
3264
3273
|
// Clear cache of legacy account objects that have been collpsed into tenant profiles
|
|
3265
3274
|
matchingAccountKeys.forEach((key) => {
|
|
3266
3275
|
if (key !== newAccountKey) {
|
|
3267
|
-
this.removeOutdatedAccount(accountKey);
|
|
3276
|
+
this.removeOutdatedAccount(accountKey, correlationId);
|
|
3268
3277
|
}
|
|
3269
3278
|
});
|
|
3270
3279
|
// Cache updated account object
|
|
3271
|
-
this.setAccount(updatedAccount);
|
|
3280
|
+
this.setAccount(updatedAccount, correlationId);
|
|
3272
3281
|
logger?.verbose("Updated an outdated account entity in the cache");
|
|
3273
3282
|
return updatedAccount;
|
|
3274
3283
|
}
|
|
@@ -3279,37 +3288,31 @@ class CacheManager {
|
|
|
3279
3288
|
* returns a boolean if the given credential is removed
|
|
3280
3289
|
* @param credential
|
|
3281
3290
|
*/
|
|
3282
|
-
|
|
3283
|
-
const credential = this.getAccessTokenCredential(key);
|
|
3284
|
-
|
|
3291
|
+
removeAccessToken(key, correlationId) {
|
|
3292
|
+
const credential = this.getAccessTokenCredential(key, correlationId);
|
|
3293
|
+
this.removeItem(key, correlationId);
|
|
3294
|
+
if (!credential ||
|
|
3295
|
+
credential.credentialType.toLowerCase() !==
|
|
3296
|
+
CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME.toLowerCase() ||
|
|
3297
|
+
credential.tokenType !== AuthenticationScheme.POP) {
|
|
3285
3298
|
return;
|
|
3286
3299
|
}
|
|
3287
3300
|
// Remove Token Binding Key from key store for PoP Tokens Credentials
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
if (kid) {
|
|
3294
|
-
try {
|
|
3295
|
-
await this.cryptoImpl.removeTokenBindingKey(kid);
|
|
3296
|
-
}
|
|
3297
|
-
catch (error) {
|
|
3298
|
-
throw createClientAuthError(bindingKeyNotRemoved);
|
|
3299
|
-
}
|
|
3300
|
-
}
|
|
3301
|
-
}
|
|
3301
|
+
const kid = credential.keyId;
|
|
3302
|
+
if (kid) {
|
|
3303
|
+
void this.cryptoImpl.removeTokenBindingKey(kid).catch(() => {
|
|
3304
|
+
this.commonLogger.error("Binding key could not be removed");
|
|
3305
|
+
});
|
|
3302
3306
|
}
|
|
3303
|
-
return this.removeItem(key);
|
|
3304
3307
|
}
|
|
3305
3308
|
/**
|
|
3306
3309
|
* Removes all app metadata objects from cache.
|
|
3307
3310
|
*/
|
|
3308
|
-
removeAppMetadata() {
|
|
3311
|
+
removeAppMetadata(correlationId) {
|
|
3309
3312
|
const allCacheKeys = this.getKeys();
|
|
3310
3313
|
allCacheKeys.forEach((cacheKey) => {
|
|
3311
3314
|
if (this.isAppMetadata(cacheKey)) {
|
|
3312
|
-
this.removeItem(cacheKey);
|
|
3315
|
+
this.removeItem(cacheKey, correlationId);
|
|
3313
3316
|
}
|
|
3314
3317
|
});
|
|
3315
3318
|
return true;
|
|
@@ -3318,9 +3321,9 @@ class CacheManager {
|
|
|
3318
3321
|
* Retrieve AccountEntity from cache
|
|
3319
3322
|
* @param account
|
|
3320
3323
|
*/
|
|
3321
|
-
readAccountFromCache(account) {
|
|
3324
|
+
readAccountFromCache(account, correlationId) {
|
|
3322
3325
|
const accountKey = AccountEntity.generateAccountCacheKey(account);
|
|
3323
|
-
return this.getAccount(accountKey, this.commonLogger);
|
|
3326
|
+
return this.getAccount(accountKey, correlationId, this.commonLogger);
|
|
3324
3327
|
}
|
|
3325
3328
|
/**
|
|
3326
3329
|
* Retrieve IdTokenEntity from cache
|
|
@@ -3330,7 +3333,7 @@ class CacheManager {
|
|
|
3330
3333
|
* @param performanceClient {?IPerformanceClient}
|
|
3331
3334
|
* @param correlationId {?string}
|
|
3332
3335
|
*/
|
|
3333
|
-
getIdToken(account, tokenKeys, targetRealm, performanceClient
|
|
3336
|
+
getIdToken(account, correlationId, tokenKeys, targetRealm, performanceClient) {
|
|
3334
3337
|
this.commonLogger.trace("CacheManager - getIdToken called");
|
|
3335
3338
|
const idTokenFilter = {
|
|
3336
3339
|
homeAccountId: account.homeAccountId,
|
|
@@ -3339,7 +3342,7 @@ class CacheManager {
|
|
|
3339
3342
|
clientId: this.clientId,
|
|
3340
3343
|
realm: targetRealm,
|
|
3341
3344
|
};
|
|
3342
|
-
const idTokenMap = this.getIdTokensByFilter(idTokenFilter, tokenKeys);
|
|
3345
|
+
const idTokenMap = this.getIdTokensByFilter(idTokenFilter, correlationId, tokenKeys);
|
|
3343
3346
|
const numIdTokens = idTokenMap.size;
|
|
3344
3347
|
if (numIdTokens < 1) {
|
|
3345
3348
|
this.commonLogger.info("CacheManager:getIdToken - No token found");
|
|
@@ -3372,7 +3375,7 @@ class CacheManager {
|
|
|
3372
3375
|
// Multiple tokens for a single tenant profile, remove all and return null
|
|
3373
3376
|
this.commonLogger.info("CacheManager:getIdToken - Multiple matching ID tokens found, clearing them");
|
|
3374
3377
|
tokensToBeRemoved.forEach((idToken, key) => {
|
|
3375
|
-
this.removeIdToken(key);
|
|
3378
|
+
this.removeIdToken(key, correlationId);
|
|
3376
3379
|
});
|
|
3377
3380
|
if (performanceClient && correlationId) {
|
|
3378
3381
|
performanceClient.addFields({ multiMatchedID: idTokenMap.size }, correlationId);
|
|
@@ -3387,7 +3390,7 @@ class CacheManager {
|
|
|
3387
3390
|
* @param filter
|
|
3388
3391
|
* @returns
|
|
3389
3392
|
*/
|
|
3390
|
-
getIdTokensByFilter(filter, tokenKeys) {
|
|
3393
|
+
getIdTokensByFilter(filter, correlationId, tokenKeys) {
|
|
3391
3394
|
const idTokenKeys = (tokenKeys && tokenKeys.idToken) || this.getTokenKeys().idToken;
|
|
3392
3395
|
const idTokens = new Map();
|
|
3393
3396
|
idTokenKeys.forEach((key) => {
|
|
@@ -3397,7 +3400,7 @@ class CacheManager {
|
|
|
3397
3400
|
})) {
|
|
3398
3401
|
return;
|
|
3399
3402
|
}
|
|
3400
|
-
const idToken = this.getIdTokenCredential(key);
|
|
3403
|
+
const idToken = this.getIdTokenCredential(key, correlationId);
|
|
3401
3404
|
if (idToken && this.credentialMatchesFilter(idToken, filter)) {
|
|
3402
3405
|
idTokens.set(key, idToken);
|
|
3403
3406
|
}
|
|
@@ -3426,15 +3429,15 @@ class CacheManager {
|
|
|
3426
3429
|
* Removes idToken from the cache
|
|
3427
3430
|
* @param key
|
|
3428
3431
|
*/
|
|
3429
|
-
removeIdToken(key) {
|
|
3430
|
-
this.removeItem(key);
|
|
3432
|
+
removeIdToken(key, correlationId) {
|
|
3433
|
+
this.removeItem(key, correlationId);
|
|
3431
3434
|
}
|
|
3432
3435
|
/**
|
|
3433
3436
|
* Removes refresh token from the cache
|
|
3434
3437
|
* @param key
|
|
3435
3438
|
*/
|
|
3436
|
-
removeRefreshToken(key) {
|
|
3437
|
-
this.removeItem(key);
|
|
3439
|
+
removeRefreshToken(key, correlationId) {
|
|
3440
|
+
this.removeItem(key, correlationId);
|
|
3438
3441
|
}
|
|
3439
3442
|
/**
|
|
3440
3443
|
* Retrieve AccessTokenEntity from cache
|
|
@@ -3444,7 +3447,7 @@ class CacheManager {
|
|
|
3444
3447
|
* @param performanceClient {?IPerformanceClient}
|
|
3445
3448
|
* @param correlationId {?string}
|
|
3446
3449
|
*/
|
|
3447
|
-
getAccessToken(account, request, tokenKeys, targetRealm, performanceClient
|
|
3450
|
+
getAccessToken(account, request, tokenKeys, targetRealm, performanceClient) {
|
|
3448
3451
|
this.commonLogger.trace("CacheManager - getAccessToken called");
|
|
3449
3452
|
const scopes = ScopeSet.createSearchScopes(request.scopes);
|
|
3450
3453
|
const authScheme = request.authenticationScheme || AuthenticationScheme.BEARER;
|
|
@@ -3474,7 +3477,7 @@ class CacheManager {
|
|
|
3474
3477
|
accessTokenKeys.forEach((key) => {
|
|
3475
3478
|
// Validate key
|
|
3476
3479
|
if (this.accessTokenKeyMatchesFilter(key, accessTokenFilter, true)) {
|
|
3477
|
-
const accessToken = this.getAccessTokenCredential(key);
|
|
3480
|
+
const accessToken = this.getAccessTokenCredential(key, request.correlationId);
|
|
3478
3481
|
// Validate value
|
|
3479
3482
|
if (accessToken &&
|
|
3480
3483
|
this.credentialMatchesFilter(accessToken, accessTokenFilter)) {
|
|
@@ -3490,10 +3493,10 @@ class CacheManager {
|
|
|
3490
3493
|
else if (numAccessTokens > 1) {
|
|
3491
3494
|
this.commonLogger.info("CacheManager:getAccessToken - Multiple access tokens found, clearing them");
|
|
3492
3495
|
accessTokens.forEach((accessToken) => {
|
|
3493
|
-
void this.removeAccessToken(generateCredentialKey(accessToken));
|
|
3496
|
+
void this.removeAccessToken(generateCredentialKey(accessToken), request.correlationId);
|
|
3494
3497
|
});
|
|
3495
|
-
if (performanceClient && correlationId) {
|
|
3496
|
-
performanceClient.addFields({ multiMatchedAT: accessTokens.length }, correlationId);
|
|
3498
|
+
if (performanceClient && request.correlationId) {
|
|
3499
|
+
performanceClient.addFields({ multiMatchedAT: accessTokens.length }, request.correlationId);
|
|
3497
3500
|
}
|
|
3498
3501
|
return null;
|
|
3499
3502
|
}
|
|
@@ -3546,14 +3549,14 @@ class CacheManager {
|
|
|
3546
3549
|
* @param filter
|
|
3547
3550
|
* @returns
|
|
3548
3551
|
*/
|
|
3549
|
-
getAccessTokensByFilter(filter) {
|
|
3552
|
+
getAccessTokensByFilter(filter, correlationId) {
|
|
3550
3553
|
const tokenKeys = this.getTokenKeys();
|
|
3551
3554
|
const accessTokens = [];
|
|
3552
3555
|
tokenKeys.accessToken.forEach((key) => {
|
|
3553
3556
|
if (!this.accessTokenKeyMatchesFilter(key, filter, true)) {
|
|
3554
3557
|
return;
|
|
3555
3558
|
}
|
|
3556
|
-
const accessToken = this.getAccessTokenCredential(key);
|
|
3559
|
+
const accessToken = this.getAccessTokenCredential(key, correlationId);
|
|
3557
3560
|
if (accessToken &&
|
|
3558
3561
|
this.credentialMatchesFilter(accessToken, filter)) {
|
|
3559
3562
|
accessTokens.push(accessToken);
|
|
@@ -3569,7 +3572,7 @@ class CacheManager {
|
|
|
3569
3572
|
* @param performanceClient {?IPerformanceClient}
|
|
3570
3573
|
* @param correlationId {?string}
|
|
3571
3574
|
*/
|
|
3572
|
-
getRefreshToken(account, familyRT, tokenKeys, performanceClient
|
|
3575
|
+
getRefreshToken(account, familyRT, correlationId, tokenKeys, performanceClient) {
|
|
3573
3576
|
this.commonLogger.trace("CacheManager - getRefreshToken called");
|
|
3574
3577
|
const id = familyRT ? THE_FAMILY_ID : undefined;
|
|
3575
3578
|
const refreshTokenFilter = {
|
|
@@ -3585,7 +3588,7 @@ class CacheManager {
|
|
|
3585
3588
|
refreshTokenKeys.forEach((key) => {
|
|
3586
3589
|
// Validate key
|
|
3587
3590
|
if (this.refreshTokenKeyMatchesFilter(key, refreshTokenFilter)) {
|
|
3588
|
-
const refreshToken = this.getRefreshTokenCredential(key);
|
|
3591
|
+
const refreshToken = this.getRefreshTokenCredential(key, correlationId);
|
|
3589
3592
|
// Validate value
|
|
3590
3593
|
if (refreshToken &&
|
|
3591
3594
|
this.credentialMatchesFilter(refreshToken, refreshTokenFilter)) {
|
|
@@ -3944,7 +3947,7 @@ class DefaultStorageClass extends CacheManager {
|
|
|
3944
3947
|
}
|
|
3945
3948
|
}
|
|
3946
3949
|
|
|
3947
|
-
/*! @azure/msal-common v14.16.
|
|
3950
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
3948
3951
|
|
|
3949
3952
|
/*
|
|
3950
3953
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4043,7 +4046,7 @@ function isOidcProtocolMode(config) {
|
|
|
4043
4046
|
return (config.authOptions.authority.options.protocolMode === ProtocolMode.OIDC);
|
|
4044
4047
|
}
|
|
4045
4048
|
|
|
4046
|
-
/*! @azure/msal-common v14.16.
|
|
4049
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
4047
4050
|
/*
|
|
4048
4051
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4049
4052
|
* Licensed under the MIT License.
|
|
@@ -4053,7 +4056,7 @@ const CcsCredentialType = {
|
|
|
4053
4056
|
UPN: "UPN",
|
|
4054
4057
|
};
|
|
4055
4058
|
|
|
4056
|
-
/*! @azure/msal-common v14.16.
|
|
4059
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
4057
4060
|
/*
|
|
4058
4061
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4059
4062
|
* Licensed under the MIT License.
|
|
@@ -4103,7 +4106,7 @@ const X_CLIENT_EXTRA_SKU = "x-client-xtra-sku";
|
|
|
4103
4106
|
const BROKER_CLIENT_ID = "brk_client_id";
|
|
4104
4107
|
const BROKER_REDIRECT_URI = "brk_redirect_uri";
|
|
4105
4108
|
|
|
4106
|
-
/*! @azure/msal-common v14.16.
|
|
4109
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
4107
4110
|
|
|
4108
4111
|
/*
|
|
4109
4112
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4170,7 +4173,7 @@ class RequestValidator {
|
|
|
4170
4173
|
}
|
|
4171
4174
|
}
|
|
4172
4175
|
|
|
4173
|
-
/*! @azure/msal-common v14.16.
|
|
4176
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
4174
4177
|
|
|
4175
4178
|
/*
|
|
4176
4179
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4578,7 +4581,7 @@ class RequestParameterBuilder {
|
|
|
4578
4581
|
}
|
|
4579
4582
|
}
|
|
4580
4583
|
|
|
4581
|
-
/*! @azure/msal-common v14.16.
|
|
4584
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
4582
4585
|
/*
|
|
4583
4586
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4584
4587
|
* Licensed under the MIT License.
|
|
@@ -4590,7 +4593,7 @@ function isOpenIdConfigResponse(response) {
|
|
|
4590
4593
|
response.hasOwnProperty("jwks_uri"));
|
|
4591
4594
|
}
|
|
4592
4595
|
|
|
4593
|
-
/*! @azure/msal-common v14.16.
|
|
4596
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
4594
4597
|
/*
|
|
4595
4598
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4596
4599
|
* Licensed under the MIT License.
|
|
@@ -4600,7 +4603,7 @@ function isCloudInstanceDiscoveryResponse(response) {
|
|
|
4600
4603
|
response.hasOwnProperty("metadata"));
|
|
4601
4604
|
}
|
|
4602
4605
|
|
|
4603
|
-
/*! @azure/msal-common v14.16.
|
|
4606
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
4604
4607
|
/*
|
|
4605
4608
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4606
4609
|
* Licensed under the MIT License.
|
|
@@ -4610,7 +4613,7 @@ function isCloudInstanceDiscoveryErrorResponse(response) {
|
|
|
4610
4613
|
response.hasOwnProperty("error_description"));
|
|
4611
4614
|
}
|
|
4612
4615
|
|
|
4613
|
-
/*! @azure/msal-common v14.16.
|
|
4616
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
4614
4617
|
/*
|
|
4615
4618
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4616
4619
|
* Licensed under the MIT License.
|
|
@@ -5097,7 +5100,7 @@ const IntFields = new Set([
|
|
|
5097
5100
|
"multiMatchedRT",
|
|
5098
5101
|
]);
|
|
5099
5102
|
|
|
5100
|
-
/*! @azure/msal-common v14.16.
|
|
5103
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
5101
5104
|
/*
|
|
5102
5105
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
5103
5106
|
* Licensed under the MIT License.
|
|
@@ -5193,7 +5196,7 @@ const invokeAsync = (callback, eventName, logger, telemetryClient, correlationId
|
|
|
5193
5196
|
};
|
|
5194
5197
|
};
|
|
5195
5198
|
|
|
5196
|
-
/*! @azure/msal-common v14.16.
|
|
5199
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
5197
5200
|
|
|
5198
5201
|
/*
|
|
5199
5202
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -5302,7 +5305,7 @@ RegionDiscovery.IMDS_OPTIONS = {
|
|
|
5302
5305
|
},
|
|
5303
5306
|
};
|
|
5304
5307
|
|
|
5305
|
-
/*! @azure/msal-common v14.16.
|
|
5308
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
5306
5309
|
|
|
5307
5310
|
/*
|
|
5308
5311
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6141,7 +6144,7 @@ function buildStaticAuthorityOptions(authOptions) {
|
|
|
6141
6144
|
};
|
|
6142
6145
|
}
|
|
6143
6146
|
|
|
6144
|
-
/*! @azure/msal-common v14.16.
|
|
6147
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
6145
6148
|
|
|
6146
6149
|
/*
|
|
6147
6150
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6172,7 +6175,7 @@ async function createDiscoveredInstance(authorityUri, networkClient, cacheManage
|
|
|
6172
6175
|
}
|
|
6173
6176
|
}
|
|
6174
6177
|
|
|
6175
|
-
/*! @azure/msal-common v14.16.
|
|
6178
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
6176
6179
|
|
|
6177
6180
|
/*
|
|
6178
6181
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6191,7 +6194,7 @@ class ServerError extends AuthError {
|
|
|
6191
6194
|
}
|
|
6192
6195
|
}
|
|
6193
6196
|
|
|
6194
|
-
/*! @azure/msal-common v14.16.
|
|
6197
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
6195
6198
|
|
|
6196
6199
|
/*
|
|
6197
6200
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6211,12 +6214,12 @@ class ThrottlingUtils {
|
|
|
6211
6214
|
* @param cacheManager
|
|
6212
6215
|
* @param thumbprint
|
|
6213
6216
|
*/
|
|
6214
|
-
static preProcess(cacheManager, thumbprint) {
|
|
6217
|
+
static preProcess(cacheManager, thumbprint, correlationId) {
|
|
6215
6218
|
const key = ThrottlingUtils.generateThrottlingStorageKey(thumbprint);
|
|
6216
6219
|
const value = cacheManager.getThrottlingCache(key);
|
|
6217
6220
|
if (value) {
|
|
6218
6221
|
if (value.throttleTime < Date.now()) {
|
|
6219
|
-
cacheManager.removeItem(key);
|
|
6222
|
+
cacheManager.removeItem(key, correlationId);
|
|
6220
6223
|
return;
|
|
6221
6224
|
}
|
|
6222
6225
|
throw new ServerError(value.errorCodes?.join(" ") || Constants.EMPTY_STRING, value.errorMessage, value.subError);
|
|
@@ -6228,7 +6231,7 @@ class ThrottlingUtils {
|
|
|
6228
6231
|
* @param thumbprint
|
|
6229
6232
|
* @param response
|
|
6230
6233
|
*/
|
|
6231
|
-
static postProcess(cacheManager, thumbprint, response) {
|
|
6234
|
+
static postProcess(cacheManager, thumbprint, response, correlationId) {
|
|
6232
6235
|
if (ThrottlingUtils.checkResponseStatus(response) ||
|
|
6233
6236
|
ThrottlingUtils.checkResponseForRetryAfter(response)) {
|
|
6234
6237
|
const thumbprintValue = {
|
|
@@ -6238,7 +6241,7 @@ class ThrottlingUtils {
|
|
|
6238
6241
|
errorMessage: response.body.error_description,
|
|
6239
6242
|
subError: response.body.suberror,
|
|
6240
6243
|
};
|
|
6241
|
-
cacheManager.setThrottlingCache(ThrottlingUtils.generateThrottlingStorageKey(thumbprint), thumbprintValue);
|
|
6244
|
+
cacheManager.setThrottlingCache(ThrottlingUtils.generateThrottlingStorageKey(thumbprint), thumbprintValue, correlationId);
|
|
6242
6245
|
}
|
|
6243
6246
|
}
|
|
6244
6247
|
/**
|
|
@@ -6285,11 +6288,11 @@ class ThrottlingUtils {
|
|
|
6285
6288
|
sshKid: request.sshKid,
|
|
6286
6289
|
};
|
|
6287
6290
|
const key = this.generateThrottlingStorageKey(thumbprint);
|
|
6288
|
-
cacheManager.removeItem(key);
|
|
6291
|
+
cacheManager.removeItem(key, request.correlationId);
|
|
6289
6292
|
}
|
|
6290
6293
|
}
|
|
6291
6294
|
|
|
6292
|
-
/*! @azure/msal-common v14.16.
|
|
6295
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
6293
6296
|
|
|
6294
6297
|
/*
|
|
6295
6298
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6319,7 +6322,7 @@ function createNetworkError(error, httpStatus, responseHeaders) {
|
|
|
6319
6322
|
return new NetworkError(error, httpStatus, responseHeaders);
|
|
6320
6323
|
}
|
|
6321
6324
|
|
|
6322
|
-
/*! @azure/msal-common v14.16.
|
|
6325
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
6323
6326
|
|
|
6324
6327
|
/*
|
|
6325
6328
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6401,7 +6404,7 @@ class BaseClient {
|
|
|
6401
6404
|
* @param correlationId - CorrelationId for telemetry
|
|
6402
6405
|
*/
|
|
6403
6406
|
async sendPostRequest(thumbprint, tokenEndpoint, options, correlationId) {
|
|
6404
|
-
ThrottlingUtils.preProcess(this.cacheManager, thumbprint);
|
|
6407
|
+
ThrottlingUtils.preProcess(this.cacheManager, thumbprint, correlationId);
|
|
6405
6408
|
let response;
|
|
6406
6409
|
try {
|
|
6407
6410
|
response = await invokeAsync((this.networkClient.sendPostRequestAsync.bind(this.networkClient)), PerformanceEvents.NetworkClientSendPostRequestAsync, this.logger, this.performanceClient, correlationId)(tokenEndpoint, options);
|
|
@@ -6436,7 +6439,7 @@ class BaseClient {
|
|
|
6436
6439
|
throw createClientAuthError(networkError);
|
|
6437
6440
|
}
|
|
6438
6441
|
}
|
|
6439
|
-
ThrottlingUtils.postProcess(this.cacheManager, thumbprint, response);
|
|
6442
|
+
ThrottlingUtils.postProcess(this.cacheManager, thumbprint, response, correlationId);
|
|
6440
6443
|
return response;
|
|
6441
6444
|
}
|
|
6442
6445
|
/**
|
|
@@ -6469,7 +6472,7 @@ class BaseClient {
|
|
|
6469
6472
|
}
|
|
6470
6473
|
}
|
|
6471
6474
|
|
|
6472
|
-
/*! @azure/msal-common v14.16.
|
|
6475
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
6473
6476
|
/*
|
|
6474
6477
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6475
6478
|
* Licensed under the MIT License.
|
|
@@ -6495,7 +6498,7 @@ var InteractionRequiredAuthErrorCodes = /*#__PURE__*/Object.freeze({
|
|
|
6495
6498
|
refreshTokenExpired: refreshTokenExpired
|
|
6496
6499
|
});
|
|
6497
6500
|
|
|
6498
|
-
/*! @azure/msal-common v14.16.
|
|
6501
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
6499
6502
|
|
|
6500
6503
|
/*
|
|
6501
6504
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6583,7 +6586,7 @@ function createInteractionRequiredAuthError(errorCode) {
|
|
|
6583
6586
|
return new InteractionRequiredAuthError(errorCode, InteractionRequiredAuthErrorMessages[errorCode]);
|
|
6584
6587
|
}
|
|
6585
6588
|
|
|
6586
|
-
/*! @azure/msal-common v14.16.
|
|
6589
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
6587
6590
|
|
|
6588
6591
|
/*
|
|
6589
6592
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6655,7 +6658,7 @@ class ProtocolUtils {
|
|
|
6655
6658
|
}
|
|
6656
6659
|
}
|
|
6657
6660
|
|
|
6658
|
-
/*! @azure/msal-common v14.16.
|
|
6661
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
6659
6662
|
|
|
6660
6663
|
/*
|
|
6661
6664
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6739,7 +6742,7 @@ class PopTokenGenerator {
|
|
|
6739
6742
|
}
|
|
6740
6743
|
}
|
|
6741
6744
|
|
|
6742
|
-
/*! @azure/msal-common v14.16.
|
|
6745
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
6743
6746
|
/*
|
|
6744
6747
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6745
6748
|
* Licensed under the MIT License.
|
|
@@ -6766,7 +6769,7 @@ class PopTokenGenerator {
|
|
|
6766
6769
|
}
|
|
6767
6770
|
}
|
|
6768
6771
|
|
|
6769
|
-
/*! @azure/msal-common v14.16.
|
|
6772
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
6770
6773
|
|
|
6771
6774
|
/*
|
|
6772
6775
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6926,13 +6929,13 @@ class ResponseHandler {
|
|
|
6926
6929
|
!forceCacheRefreshTokenResponse &&
|
|
6927
6930
|
cacheRecord.account) {
|
|
6928
6931
|
const key = cacheRecord.account.generateAccountKey();
|
|
6929
|
-
const account = this.cacheStorage.getAccount(key, this.logger);
|
|
6932
|
+
const account = this.cacheStorage.getAccount(key, request.correlationId, this.logger);
|
|
6930
6933
|
if (!account) {
|
|
6931
6934
|
this.logger.warning("Account used to refresh tokens not in persistence, refreshed tokens will not be stored in the cache");
|
|
6932
6935
|
return await ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenClaims, requestStateObj, undefined, serverRequestId);
|
|
6933
6936
|
}
|
|
6934
6937
|
}
|
|
6935
|
-
await this.cacheStorage.saveCacheRecord(cacheRecord, request.
|
|
6938
|
+
await this.cacheStorage.saveCacheRecord(cacheRecord, request.correlationId, request.storeInCache);
|
|
6936
6939
|
}
|
|
6937
6940
|
finally {
|
|
6938
6941
|
if (this.persistencePlugin &&
|
|
@@ -6961,7 +6964,7 @@ class ResponseHandler {
|
|
|
6961
6964
|
let cachedAccount;
|
|
6962
6965
|
if (serverTokenResponse.id_token && !!idTokenClaims) {
|
|
6963
6966
|
cachedIdToken = createIdTokenEntity(this.homeAccountIdentifier, env, serverTokenResponse.id_token, this.clientId, claimsTenantId || "");
|
|
6964
|
-
cachedAccount = buildAccountToCache(this.cacheStorage, authority, this.homeAccountIdentifier, this.cryptoObj.base64Decode, idTokenClaims, serverTokenResponse.client_info, env, claimsTenantId, authCodePayload, undefined, // nativeAccountId
|
|
6967
|
+
cachedAccount = buildAccountToCache(this.cacheStorage, authority, this.homeAccountIdentifier, this.cryptoObj.base64Decode, request.correlationId, idTokenClaims, serverTokenResponse.client_info, env, claimsTenantId, authCodePayload, undefined, // nativeAccountId
|
|
6965
6968
|
this.logger);
|
|
6966
6969
|
}
|
|
6967
6970
|
// AccessToken
|
|
@@ -7109,7 +7112,7 @@ class ResponseHandler {
|
|
|
7109
7112
|
};
|
|
7110
7113
|
}
|
|
7111
7114
|
}
|
|
7112
|
-
function buildAccountToCache(cacheStorage, authority, homeAccountId, base64Decode, idTokenClaims, clientInfo, environment, claimsTenantId, authCodePayload, nativeAccountId, logger) {
|
|
7115
|
+
function buildAccountToCache(cacheStorage, authority, homeAccountId, base64Decode, correlationId, idTokenClaims, clientInfo, environment, claimsTenantId, authCodePayload, nativeAccountId, logger) {
|
|
7113
7116
|
logger?.verbose("setCachedAccount called");
|
|
7114
7117
|
// Check if base account is already cached
|
|
7115
7118
|
const accountKeys = cacheStorage.getAccountKeys();
|
|
@@ -7118,7 +7121,7 @@ function buildAccountToCache(cacheStorage, authority, homeAccountId, base64Decod
|
|
|
7118
7121
|
});
|
|
7119
7122
|
let cachedAccount = null;
|
|
7120
7123
|
if (baseAccountKey) {
|
|
7121
|
-
cachedAccount = cacheStorage.getAccount(baseAccountKey, logger);
|
|
7124
|
+
cachedAccount = cacheStorage.getAccount(baseAccountKey, correlationId, logger);
|
|
7122
7125
|
}
|
|
7123
7126
|
const baseAccount = cachedAccount ||
|
|
7124
7127
|
AccountEntity.createAccount({
|
|
@@ -7143,7 +7146,7 @@ function buildAccountToCache(cacheStorage, authority, homeAccountId, base64Decod
|
|
|
7143
7146
|
return baseAccount;
|
|
7144
7147
|
}
|
|
7145
7148
|
|
|
7146
|
-
/*! @azure/msal-common v14.16.
|
|
7149
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
7147
7150
|
/*
|
|
7148
7151
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
7149
7152
|
* Licensed under the MIT License.
|
|
@@ -7161,7 +7164,7 @@ async function getClientAssertion(clientAssertion, clientId, tokenEndpoint) {
|
|
|
7161
7164
|
}
|
|
7162
7165
|
}
|
|
7163
7166
|
|
|
7164
|
-
/*! @azure/msal-common v14.16.
|
|
7167
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
7165
7168
|
|
|
7166
7169
|
/*
|
|
7167
7170
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7603,7 +7606,7 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
7603
7606
|
}
|
|
7604
7607
|
}
|
|
7605
7608
|
|
|
7606
|
-
/*! @azure/msal-common v14.16.
|
|
7609
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
7607
7610
|
|
|
7608
7611
|
/*
|
|
7609
7612
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7676,7 +7679,7 @@ class RefreshTokenClient extends BaseClient {
|
|
|
7676
7679
|
async acquireTokenWithCachedRefreshToken(request, foci) {
|
|
7677
7680
|
this.performanceClient?.addQueueMeasurement(PerformanceEvents.RefreshTokenClientAcquireTokenWithCachedRefreshToken, request.correlationId);
|
|
7678
7681
|
// fetches family RT or application RT based on FOCI value
|
|
7679
|
-
const refreshToken = invoke(this.cacheManager.getRefreshToken.bind(this.cacheManager), PerformanceEvents.CacheManagerGetRefreshToken, this.logger, this.performanceClient, request.correlationId)(request.account, foci, undefined, this.performanceClient
|
|
7682
|
+
const refreshToken = invoke(this.cacheManager.getRefreshToken.bind(this.cacheManager), PerformanceEvents.CacheManagerGetRefreshToken, this.logger, this.performanceClient, request.correlationId)(request.account, foci, request.correlationId, undefined, this.performanceClient);
|
|
7680
7683
|
if (!refreshToken) {
|
|
7681
7684
|
throw createInteractionRequiredAuthError(noTokensFound);
|
|
7682
7685
|
}
|
|
@@ -7704,7 +7707,7 @@ class RefreshTokenClient extends BaseClient {
|
|
|
7704
7707
|
// Remove bad refresh token from cache
|
|
7705
7708
|
this.logger.verbose("acquireTokenWithRefreshToken: bad refresh token, removing from cache");
|
|
7706
7709
|
const badRefreshTokenKey = generateCredentialKey(refreshToken);
|
|
7707
|
-
this.cacheManager.removeRefreshToken(badRefreshTokenKey);
|
|
7710
|
+
this.cacheManager.removeRefreshToken(badRefreshTokenKey, request.correlationId);
|
|
7708
7711
|
}
|
|
7709
7712
|
throw e;
|
|
7710
7713
|
}
|
|
@@ -7823,7 +7826,7 @@ class RefreshTokenClient extends BaseClient {
|
|
|
7823
7826
|
}
|
|
7824
7827
|
}
|
|
7825
7828
|
|
|
7826
|
-
/*! @azure/msal-common v14.16.
|
|
7829
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
7827
7830
|
|
|
7828
7831
|
/*
|
|
7829
7832
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7893,7 +7896,7 @@ class SilentFlowClient extends BaseClient {
|
|
|
7893
7896
|
const requestTenantId = request.account.tenantId ||
|
|
7894
7897
|
getTenantFromAuthorityString(request.authority);
|
|
7895
7898
|
const tokenKeys = this.cacheManager.getTokenKeys();
|
|
7896
|
-
const cachedAccessToken = this.cacheManager.getAccessToken(request.account, request, tokenKeys, requestTenantId, this.performanceClient
|
|
7899
|
+
const cachedAccessToken = this.cacheManager.getAccessToken(request.account, request, tokenKeys, requestTenantId, this.performanceClient);
|
|
7897
7900
|
if (!cachedAccessToken) {
|
|
7898
7901
|
// must refresh due to non-existent access_token
|
|
7899
7902
|
this.setCacheOutcome(CacheOutcome.NO_CACHED_ACCESS_TOKEN, request.correlationId);
|
|
@@ -7913,9 +7916,9 @@ class SilentFlowClient extends BaseClient {
|
|
|
7913
7916
|
}
|
|
7914
7917
|
const environment = request.authority || this.authority.getPreferredCache();
|
|
7915
7918
|
const cacheRecord = {
|
|
7916
|
-
account: this.cacheManager.readAccountFromCache(request.account),
|
|
7919
|
+
account: this.cacheManager.readAccountFromCache(request.account, request.correlationId),
|
|
7917
7920
|
accessToken: cachedAccessToken,
|
|
7918
|
-
idToken: this.cacheManager.getIdToken(request.account, tokenKeys, requestTenantId, this.performanceClient
|
|
7921
|
+
idToken: this.cacheManager.getIdToken(request.account, request.correlationId, tokenKeys, requestTenantId, this.performanceClient),
|
|
7919
7922
|
refreshToken: null,
|
|
7920
7923
|
appMetadata: this.cacheManager.readAppMetadataFromCache(environment),
|
|
7921
7924
|
};
|
|
@@ -7959,7 +7962,7 @@ class SilentFlowClient extends BaseClient {
|
|
|
7959
7962
|
}
|
|
7960
7963
|
}
|
|
7961
7964
|
|
|
7962
|
-
/*! @azure/msal-common v14.16.
|
|
7965
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
7963
7966
|
|
|
7964
7967
|
/*
|
|
7965
7968
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7974,7 +7977,7 @@ const StubbedNetworkModule = {
|
|
|
7974
7977
|
},
|
|
7975
7978
|
};
|
|
7976
7979
|
|
|
7977
|
-
/*! @azure/msal-common v14.16.
|
|
7980
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
7978
7981
|
|
|
7979
7982
|
/*
|
|
7980
7983
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8032,7 +8035,7 @@ class AuthenticationHeaderParser {
|
|
|
8032
8035
|
}
|
|
8033
8036
|
}
|
|
8034
8037
|
|
|
8035
|
-
/*! @azure/msal-common v14.16.
|
|
8038
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
8036
8039
|
|
|
8037
8040
|
/*
|
|
8038
8041
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8171,7 +8174,7 @@ class ServerTelemetryManager {
|
|
|
8171
8174
|
else {
|
|
8172
8175
|
lastRequests.errors.push(SERVER_TELEM_CONSTANTS.UNKNOWN_ERROR);
|
|
8173
8176
|
}
|
|
8174
|
-
this.cacheManager.setServerTelemetry(this.telemetryCacheKey, lastRequests);
|
|
8177
|
+
this.cacheManager.setServerTelemetry(this.telemetryCacheKey, lastRequests, this.correlationId);
|
|
8175
8178
|
return;
|
|
8176
8179
|
}
|
|
8177
8180
|
/**
|
|
@@ -8180,7 +8183,7 @@ class ServerTelemetryManager {
|
|
|
8180
8183
|
incrementCacheHits() {
|
|
8181
8184
|
const lastRequests = this.getLastRequests();
|
|
8182
8185
|
lastRequests.cacheHits += 1;
|
|
8183
|
-
this.cacheManager.setServerTelemetry(this.telemetryCacheKey, lastRequests);
|
|
8186
|
+
this.cacheManager.setServerTelemetry(this.telemetryCacheKey, lastRequests, this.correlationId);
|
|
8184
8187
|
return lastRequests.cacheHits;
|
|
8185
8188
|
}
|
|
8186
8189
|
/**
|
|
@@ -8204,7 +8207,7 @@ class ServerTelemetryManager {
|
|
|
8204
8207
|
const errorCount = lastRequests.errors.length;
|
|
8205
8208
|
if (numErrorsFlushed === errorCount) {
|
|
8206
8209
|
// All errors were sent on last request, clear Telemetry cache
|
|
8207
|
-
this.cacheManager.removeItem(this.telemetryCacheKey);
|
|
8210
|
+
this.cacheManager.removeItem(this.telemetryCacheKey, this.correlationId);
|
|
8208
8211
|
}
|
|
8209
8212
|
else {
|
|
8210
8213
|
// Partial data was flushed to server, construct a new telemetry cache item with errors that were not flushed
|
|
@@ -8213,7 +8216,7 @@ class ServerTelemetryManager {
|
|
|
8213
8216
|
errors: lastRequests.errors.slice(numErrorsFlushed),
|
|
8214
8217
|
cacheHits: 0,
|
|
8215
8218
|
};
|
|
8216
|
-
this.cacheManager.setServerTelemetry(this.telemetryCacheKey, serverTelemEntity);
|
|
8219
|
+
this.cacheManager.setServerTelemetry(this.telemetryCacheKey, serverTelemEntity, this.correlationId);
|
|
8217
8220
|
}
|
|
8218
8221
|
}
|
|
8219
8222
|
/**
|
|
@@ -8280,7 +8283,7 @@ class ServerTelemetryManager {
|
|
|
8280
8283
|
setNativeBrokerErrorCode(errorCode) {
|
|
8281
8284
|
const lastRequests = this.getLastRequests();
|
|
8282
8285
|
lastRequests.nativeBrokerErrorCode = errorCode;
|
|
8283
|
-
this.cacheManager.setServerTelemetry(this.telemetryCacheKey, lastRequests);
|
|
8286
|
+
this.cacheManager.setServerTelemetry(this.telemetryCacheKey, lastRequests, this.correlationId);
|
|
8284
8287
|
}
|
|
8285
8288
|
getNativeBrokerErrorCode() {
|
|
8286
8289
|
return this.getLastRequests().nativeBrokerErrorCode;
|
|
@@ -8288,14 +8291,14 @@ class ServerTelemetryManager {
|
|
|
8288
8291
|
clearNativeBrokerErrorCode() {
|
|
8289
8292
|
const lastRequests = this.getLastRequests();
|
|
8290
8293
|
delete lastRequests.nativeBrokerErrorCode;
|
|
8291
|
-
this.cacheManager.setServerTelemetry(this.telemetryCacheKey, lastRequests);
|
|
8294
|
+
this.cacheManager.setServerTelemetry(this.telemetryCacheKey, lastRequests, this.correlationId);
|
|
8292
8295
|
}
|
|
8293
8296
|
static makeExtraSkuString(params) {
|
|
8294
8297
|
return makeExtraSkuString(params);
|
|
8295
8298
|
}
|
|
8296
8299
|
}
|
|
8297
8300
|
|
|
8298
|
-
/*! @azure/msal-common v14.16.
|
|
8301
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
8299
8302
|
/*
|
|
8300
8303
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
8301
8304
|
* Licensed under the MIT License.
|
|
@@ -8303,7 +8306,7 @@ class ServerTelemetryManager {
|
|
|
8303
8306
|
const missingKidError = "missing_kid_error";
|
|
8304
8307
|
const missingAlgError = "missing_alg_error";
|
|
8305
8308
|
|
|
8306
|
-
/*! @azure/msal-common v14.16.
|
|
8309
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
8307
8310
|
|
|
8308
8311
|
/*
|
|
8309
8312
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8328,7 +8331,7 @@ function createJoseHeaderError(code) {
|
|
|
8328
8331
|
return new JoseHeaderError(code, JoseHeaderErrorMessages[code]);
|
|
8329
8332
|
}
|
|
8330
8333
|
|
|
8331
|
-
/*! @azure/msal-common v14.16.
|
|
8334
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
8332
8335
|
|
|
8333
8336
|
/*
|
|
8334
8337
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8368,7 +8371,7 @@ class JoseHeader {
|
|
|
8368
8371
|
}
|
|
8369
8372
|
}
|
|
8370
8373
|
|
|
8371
|
-
/*! @azure/msal-common v14.16.
|
|
8374
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
8372
8375
|
|
|
8373
8376
|
/*
|
|
8374
8377
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8447,7 +8450,7 @@ class StubPerformanceClient {
|
|
|
8447
8450
|
}
|
|
8448
8451
|
}
|
|
8449
8452
|
|
|
8450
|
-
/*! @azure/msal-common v14.16.
|
|
8453
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
8451
8454
|
|
|
8452
8455
|
/*
|
|
8453
8456
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -9510,6 +9513,7 @@ const TemporaryCacheKeys = {
|
|
|
9510
9513
|
const StaticCacheKeys = {
|
|
9511
9514
|
ACCOUNT_KEYS: "msal.account.keys",
|
|
9512
9515
|
TOKEN_KEYS: "msal.token.keys",
|
|
9516
|
+
VERSION: "msal.version",
|
|
9513
9517
|
};
|
|
9514
9518
|
/**
|
|
9515
9519
|
* Cache keys stored in-memory
|
|
@@ -9717,14 +9721,14 @@ const keygenAlgorithmOptions = {
|
|
|
9717
9721
|
/**
|
|
9718
9722
|
* Check whether browser crypto is available.
|
|
9719
9723
|
*/
|
|
9720
|
-
function validateCryptoAvailable() {
|
|
9724
|
+
function validateCryptoAvailable(skipValidateSubtleCrypto) {
|
|
9721
9725
|
if (!window) {
|
|
9722
9726
|
throw createBrowserAuthError(nonBrowserEnvironment);
|
|
9723
9727
|
}
|
|
9724
9728
|
if (!window.crypto) {
|
|
9725
9729
|
throw createBrowserAuthError(cryptoNonExistent);
|
|
9726
9730
|
}
|
|
9727
|
-
if (!window.crypto.subtle) {
|
|
9731
|
+
if (!skipValidateSubtleCrypto && !window.crypto.subtle) {
|
|
9728
9732
|
throw createBrowserAuthError(cryptoNonExistent, SUBTLE_SUBERROR);
|
|
9729
9733
|
}
|
|
9730
9734
|
}
|
|
@@ -9939,7 +9943,9 @@ function isInPopup() {
|
|
|
9939
9943
|
* Returns current window URL as redirect uri
|
|
9940
9944
|
*/
|
|
9941
9945
|
function getCurrentUri() {
|
|
9942
|
-
return window
|
|
9946
|
+
return typeof window !== "undefined" && window.location
|
|
9947
|
+
? window.location.href.split("?")[0].split("#")[0]
|
|
9948
|
+
: "";
|
|
9943
9949
|
}
|
|
9944
9950
|
/**
|
|
9945
9951
|
* Gets the homepage url for the current window location.
|
|
@@ -10366,7 +10372,7 @@ function buildConfiguration({ auth: userInputAuth, cache: userInputCache, system
|
|
|
10366
10372
|
|
|
10367
10373
|
/* eslint-disable header/header */
|
|
10368
10374
|
const name = "@azure/msal-browser";
|
|
10369
|
-
const version = "3.
|
|
10375
|
+
const version = "3.30.0";
|
|
10370
10376
|
|
|
10371
10377
|
/*
|
|
10372
10378
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -11153,10 +11159,10 @@ class AsyncMemoryStorage {
|
|
|
11153
11159
|
* implementing Proof Key for Code Exchange specs for the OAuth Authorization Code Flow using PKCE (rfc here: https://tools.ietf.org/html/rfc7636).
|
|
11154
11160
|
*/
|
|
11155
11161
|
class CryptoOps {
|
|
11156
|
-
constructor(logger, performanceClient) {
|
|
11162
|
+
constructor(logger, performanceClient, skipValidateSubtleCrypto) {
|
|
11157
11163
|
this.logger = logger;
|
|
11158
11164
|
// Browser crypto needs to be validated first before any other classes can be set.
|
|
11159
|
-
validateCryptoAvailable();
|
|
11165
|
+
validateCryptoAvailable(skipValidateSubtleCrypto ?? false);
|
|
11160
11166
|
this.cache = new AsyncMemoryStorage(this.logger);
|
|
11161
11167
|
this.performanceClient = performanceClient;
|
|
11162
11168
|
}
|
|
@@ -11507,6 +11513,13 @@ class BrowserCacheManager extends CacheManager {
|
|
|
11507
11513
|
* @param storeAuthStateInCookie
|
|
11508
11514
|
*/
|
|
11509
11515
|
migrateCacheEntries() {
|
|
11516
|
+
const previousVersion = this.browserStorage.getItem(StaticCacheKeys.VERSION);
|
|
11517
|
+
if (previousVersion) {
|
|
11518
|
+
this.logger.info(`MSAL.js was last initialized with version ${previousVersion}`);
|
|
11519
|
+
}
|
|
11520
|
+
if (previousVersion !== version) {
|
|
11521
|
+
this.browserStorage.setItem(StaticCacheKeys.VERSION, version);
|
|
11522
|
+
}
|
|
11510
11523
|
const idTokenKey = `${Constants.CACHE_PREFIX}.${PersistentCacheKeys.ID_TOKEN}`;
|
|
11511
11524
|
const clientInfoKey = `${Constants.CACHE_PREFIX}.${PersistentCacheKeys.CLIENT_INFO}`;
|
|
11512
11525
|
const errorKey = `${Constants.CACHE_PREFIX}.${PersistentCacheKeys.ERROR}`;
|
|
@@ -11541,6 +11554,7 @@ class BrowserCacheManager extends CacheManager {
|
|
|
11541
11554
|
*/
|
|
11542
11555
|
createKeyMaps() {
|
|
11543
11556
|
this.logger.trace("BrowserCacheManager - createKeyMaps called.");
|
|
11557
|
+
const correlationId = this.cryptoImpl.createNewGuid();
|
|
11544
11558
|
const accountKeys = this.getItem(StaticCacheKeys.ACCOUNT_KEYS);
|
|
11545
11559
|
const tokenKeys = this.getItem(`${StaticCacheKeys.TOKEN_KEYS}.${this.clientId}`);
|
|
11546
11560
|
if (accountKeys && tokenKeys) {
|
|
@@ -11562,8 +11576,8 @@ class BrowserCacheManager extends CacheManager {
|
|
|
11562
11576
|
this.logger.trace("BrowserCacheManager:createKeyMaps - idToken found, saving key to token key map");
|
|
11563
11577
|
this.logger.tracePii(`BrowserCacheManager:createKeyMaps - idToken with key: ${key} found, saving key to token key map`);
|
|
11564
11578
|
const idTokenEntity = credObj;
|
|
11565
|
-
const newKey = this.updateCredentialCacheKey(key, idTokenEntity);
|
|
11566
|
-
this.addTokenKey(newKey, CredentialType.ID_TOKEN);
|
|
11579
|
+
const newKey = this.updateCredentialCacheKey(key, idTokenEntity, correlationId);
|
|
11580
|
+
this.addTokenKey(newKey, CredentialType.ID_TOKEN, correlationId);
|
|
11567
11581
|
return;
|
|
11568
11582
|
}
|
|
11569
11583
|
else {
|
|
@@ -11577,8 +11591,8 @@ class BrowserCacheManager extends CacheManager {
|
|
|
11577
11591
|
this.logger.trace("BrowserCacheManager:createKeyMaps - accessToken found, saving key to token key map");
|
|
11578
11592
|
this.logger.tracePii(`BrowserCacheManager:createKeyMaps - accessToken with key: ${key} found, saving key to token key map`);
|
|
11579
11593
|
const accessTokenEntity = credObj;
|
|
11580
|
-
const newKey = this.updateCredentialCacheKey(key, accessTokenEntity);
|
|
11581
|
-
this.addTokenKey(newKey, CredentialType.ACCESS_TOKEN);
|
|
11594
|
+
const newKey = this.updateCredentialCacheKey(key, accessTokenEntity, correlationId);
|
|
11595
|
+
this.addTokenKey(newKey, CredentialType.ACCESS_TOKEN, correlationId);
|
|
11582
11596
|
return;
|
|
11583
11597
|
}
|
|
11584
11598
|
else {
|
|
@@ -11591,8 +11605,8 @@ class BrowserCacheManager extends CacheManager {
|
|
|
11591
11605
|
this.logger.trace("BrowserCacheManager:createKeyMaps - refreshToken found, saving key to token key map");
|
|
11592
11606
|
this.logger.tracePii(`BrowserCacheManager:createKeyMaps - refreshToken with key: ${key} found, saving key to token key map`);
|
|
11593
11607
|
const refreshTokenEntity = credObj;
|
|
11594
|
-
const newKey = this.updateCredentialCacheKey(key, refreshTokenEntity);
|
|
11595
|
-
this.addTokenKey(newKey, CredentialType.REFRESH_TOKEN);
|
|
11608
|
+
const newKey = this.updateCredentialCacheKey(key, refreshTokenEntity, correlationId);
|
|
11609
|
+
this.addTokenKey(newKey, CredentialType.REFRESH_TOKEN, correlationId);
|
|
11596
11610
|
return;
|
|
11597
11611
|
}
|
|
11598
11612
|
else {
|
|
@@ -11613,7 +11627,7 @@ class BrowserCacheManager extends CacheManager {
|
|
|
11613
11627
|
AccountEntity.isAccountEntity(accountObj)) {
|
|
11614
11628
|
this.logger.trace("BrowserCacheManager:createKeyMaps - account found, saving key to account key map");
|
|
11615
11629
|
this.logger.tracePii(`BrowserCacheManager:createKeyMaps - account with key: ${key} found, saving key to account key map`);
|
|
11616
|
-
this.addAccountKeyToMap(key);
|
|
11630
|
+
this.addAccountKeyToMap(key, correlationId);
|
|
11617
11631
|
}
|
|
11618
11632
|
}
|
|
11619
11633
|
}
|
|
@@ -11652,17 +11666,58 @@ class BrowserCacheManager extends CacheManager {
|
|
|
11652
11666
|
* @param key
|
|
11653
11667
|
* @param value
|
|
11654
11668
|
*/
|
|
11655
|
-
setItem(key, value) {
|
|
11656
|
-
|
|
11669
|
+
setItem(key, value, correlationId) {
|
|
11670
|
+
let accessTokenKeys = [];
|
|
11671
|
+
const maxRetries = 20;
|
|
11672
|
+
for (let i = 0; i <= maxRetries; i++) {
|
|
11673
|
+
try {
|
|
11674
|
+
this.browserStorage.setItem(key, value);
|
|
11675
|
+
if (i > 0) {
|
|
11676
|
+
// Finally update the token keys array with the tokens removed
|
|
11677
|
+
this.removeAccessTokenKeys(accessTokenKeys.slice(0, i), correlationId);
|
|
11678
|
+
}
|
|
11679
|
+
break; // If setItem succeeds, exit the loop
|
|
11680
|
+
}
|
|
11681
|
+
catch (e) {
|
|
11682
|
+
const cacheError = createCacheError(e);
|
|
11683
|
+
if (cacheError.errorCode ===
|
|
11684
|
+
cacheQuotaExceeded &&
|
|
11685
|
+
i < maxRetries) {
|
|
11686
|
+
if (!accessTokenKeys.length) {
|
|
11687
|
+
if (key ===
|
|
11688
|
+
`${StaticCacheKeys.TOKEN_KEYS}.${this.clientId}`) {
|
|
11689
|
+
// If we are currently trying to set the token keys, use the value we're trying to set
|
|
11690
|
+
accessTokenKeys = JSON.parse(value)
|
|
11691
|
+
.accessToken;
|
|
11692
|
+
}
|
|
11693
|
+
else {
|
|
11694
|
+
// If token keys have not been initialized, get them
|
|
11695
|
+
accessTokenKeys = this.getTokenKeys().accessToken;
|
|
11696
|
+
}
|
|
11697
|
+
}
|
|
11698
|
+
if (accessTokenKeys.length <= i) {
|
|
11699
|
+
// Nothing to remove, rethrow the error
|
|
11700
|
+
throw cacheError;
|
|
11701
|
+
}
|
|
11702
|
+
// When cache quota is exceeded, start removing access tokens until we can successfully set the item
|
|
11703
|
+
this.removeAccessToken(accessTokenKeys[i], correlationId, false // Don't save token keys yet, do it at the end
|
|
11704
|
+
);
|
|
11705
|
+
}
|
|
11706
|
+
else {
|
|
11707
|
+
// If the error is not a quota exceeded error, rethrow it
|
|
11708
|
+
throw cacheError;
|
|
11709
|
+
}
|
|
11710
|
+
}
|
|
11711
|
+
}
|
|
11657
11712
|
}
|
|
11658
11713
|
/**
|
|
11659
11714
|
* fetch the account entity from the platform cache
|
|
11660
11715
|
* @param accountKey
|
|
11661
11716
|
*/
|
|
11662
|
-
getAccount(accountKey, logger) {
|
|
11717
|
+
getAccount(accountKey, correlationId, logger) {
|
|
11663
11718
|
this.logger.trace("BrowserCacheManager.getAccount called");
|
|
11664
|
-
const accountEntity = this.getCachedAccountEntity(accountKey);
|
|
11665
|
-
return this.updateOutdatedCachedAccount(accountKey, accountEntity, logger);
|
|
11719
|
+
const accountEntity = this.getCachedAccountEntity(accountKey, correlationId);
|
|
11720
|
+
return this.updateOutdatedCachedAccount(accountKey, accountEntity, correlationId, logger);
|
|
11666
11721
|
}
|
|
11667
11722
|
/**
|
|
11668
11723
|
* Reads account from cache, deserializes it into an account entity and returns it.
|
|
@@ -11670,15 +11725,14 @@ class BrowserCacheManager extends CacheManager {
|
|
|
11670
11725
|
* @param accountKey
|
|
11671
11726
|
* @returns
|
|
11672
11727
|
*/
|
|
11673
|
-
getCachedAccountEntity(accountKey) {
|
|
11728
|
+
getCachedAccountEntity(accountKey, correlationId) {
|
|
11674
11729
|
const serializedAccount = this.getItem(accountKey);
|
|
11675
11730
|
if (!serializedAccount) {
|
|
11676
|
-
this.removeAccountKeyFromMap(accountKey);
|
|
11731
|
+
this.removeAccountKeyFromMap(accountKey, correlationId);
|
|
11677
11732
|
return null;
|
|
11678
11733
|
}
|
|
11679
11734
|
const parsedAccount = this.validateAndParseJson(serializedAccount);
|
|
11680
11735
|
if (!parsedAccount || !AccountEntity.isAccountEntity(parsedAccount)) {
|
|
11681
|
-
this.removeAccountKeyFromMap(accountKey);
|
|
11682
11736
|
return null;
|
|
11683
11737
|
}
|
|
11684
11738
|
return CacheManager.toObject(new AccountEntity(), parsedAccount);
|
|
@@ -11687,11 +11741,12 @@ class BrowserCacheManager extends CacheManager {
|
|
|
11687
11741
|
* set account entity in the platform cache
|
|
11688
11742
|
* @param account
|
|
11689
11743
|
*/
|
|
11690
|
-
setAccount(account) {
|
|
11744
|
+
setAccount(account, correlationId) {
|
|
11691
11745
|
this.logger.trace("BrowserCacheManager.setAccount called");
|
|
11692
11746
|
const key = account.generateAccountKey();
|
|
11693
|
-
|
|
11694
|
-
this.
|
|
11747
|
+
account.lastUpdatedAt = Date.now().toString();
|
|
11748
|
+
this.setItem(key, JSON.stringify(account), correlationId);
|
|
11749
|
+
this.addAccountKeyToMap(key, correlationId);
|
|
11695
11750
|
}
|
|
11696
11751
|
/**
|
|
11697
11752
|
* Returns the array of account keys currently cached
|
|
@@ -11710,14 +11765,14 @@ class BrowserCacheManager extends CacheManager {
|
|
|
11710
11765
|
* Add a new account to the key map
|
|
11711
11766
|
* @param key
|
|
11712
11767
|
*/
|
|
11713
|
-
addAccountKeyToMap(key) {
|
|
11768
|
+
addAccountKeyToMap(key, correlationId) {
|
|
11714
11769
|
this.logger.trace("BrowserCacheManager.addAccountKeyToMap called");
|
|
11715
11770
|
this.logger.tracePii(`BrowserCacheManager.addAccountKeyToMap called with key: ${key}`);
|
|
11716
11771
|
const accountKeys = this.getAccountKeys();
|
|
11717
11772
|
if (accountKeys.indexOf(key) === -1) {
|
|
11718
11773
|
// Only add key if it does not already exist in the map
|
|
11719
11774
|
accountKeys.push(key);
|
|
11720
|
-
this.setItem(StaticCacheKeys.ACCOUNT_KEYS, JSON.stringify(accountKeys));
|
|
11775
|
+
this.setItem(StaticCacheKeys.ACCOUNT_KEYS, JSON.stringify(accountKeys), correlationId);
|
|
11721
11776
|
this.logger.verbose("BrowserCacheManager.addAccountKeyToMap account key added");
|
|
11722
11777
|
}
|
|
11723
11778
|
else {
|
|
@@ -11728,14 +11783,21 @@ class BrowserCacheManager extends CacheManager {
|
|
|
11728
11783
|
* Remove an account from the key map
|
|
11729
11784
|
* @param key
|
|
11730
11785
|
*/
|
|
11731
|
-
removeAccountKeyFromMap(key) {
|
|
11786
|
+
removeAccountKeyFromMap(key, correlationId) {
|
|
11732
11787
|
this.logger.trace("BrowserCacheManager.removeAccountKeyFromMap called");
|
|
11733
11788
|
this.logger.tracePii(`BrowserCacheManager.removeAccountKeyFromMap called with key: ${key}`);
|
|
11734
11789
|
const accountKeys = this.getAccountKeys();
|
|
11735
11790
|
const removalIndex = accountKeys.indexOf(key);
|
|
11736
11791
|
if (removalIndex > -1) {
|
|
11737
11792
|
accountKeys.splice(removalIndex, 1);
|
|
11738
|
-
|
|
11793
|
+
if (accountKeys.length === 0) {
|
|
11794
|
+
// If no keys left, remove the map
|
|
11795
|
+
this.removeItem(StaticCacheKeys.ACCOUNT_KEYS);
|
|
11796
|
+
return;
|
|
11797
|
+
}
|
|
11798
|
+
else {
|
|
11799
|
+
this.setItem(StaticCacheKeys.ACCOUNT_KEYS, JSON.stringify(accountKeys), correlationId);
|
|
11800
|
+
}
|
|
11739
11801
|
this.logger.trace("BrowserCacheManager.removeAccountKeyFromMap account key removed");
|
|
11740
11802
|
}
|
|
11741
11803
|
else {
|
|
@@ -11746,41 +11808,60 @@ class BrowserCacheManager extends CacheManager {
|
|
|
11746
11808
|
* Extends inherited removeAccount function to include removal of the account key from the map
|
|
11747
11809
|
* @param key
|
|
11748
11810
|
*/
|
|
11749
|
-
async removeAccount(key) {
|
|
11750
|
-
void super.removeAccount(key);
|
|
11751
|
-
this.removeAccountKeyFromMap(key);
|
|
11811
|
+
async removeAccount(key, correlationId) {
|
|
11812
|
+
void super.removeAccount(key, correlationId);
|
|
11813
|
+
this.removeAccountKeyFromMap(key, correlationId);
|
|
11752
11814
|
}
|
|
11753
11815
|
/**
|
|
11754
11816
|
* Remove account entity from the platform cache if it's outdated
|
|
11755
11817
|
* @param accountKey
|
|
11756
11818
|
*/
|
|
11757
|
-
removeOutdatedAccount(accountKey) {
|
|
11819
|
+
removeOutdatedAccount(accountKey, correlationId) {
|
|
11758
11820
|
this.removeItem(accountKey);
|
|
11759
|
-
this.removeAccountKeyFromMap(accountKey);
|
|
11821
|
+
this.removeAccountKeyFromMap(accountKey, correlationId);
|
|
11760
11822
|
}
|
|
11761
11823
|
/**
|
|
11762
11824
|
* Removes given idToken from the cache and from the key map
|
|
11763
11825
|
* @param key
|
|
11764
11826
|
*/
|
|
11765
|
-
removeIdToken(key) {
|
|
11766
|
-
super.removeIdToken(key);
|
|
11767
|
-
this.removeTokenKey(key, CredentialType.ID_TOKEN);
|
|
11827
|
+
removeIdToken(key, correlationId) {
|
|
11828
|
+
super.removeIdToken(key, correlationId);
|
|
11829
|
+
this.removeTokenKey(key, CredentialType.ID_TOKEN, correlationId);
|
|
11768
11830
|
}
|
|
11769
11831
|
/**
|
|
11770
11832
|
* Removes given accessToken from the cache and from the key map
|
|
11771
11833
|
* @param key
|
|
11772
11834
|
*/
|
|
11773
|
-
|
|
11774
|
-
|
|
11775
|
-
this.
|
|
11835
|
+
removeAccessToken(key, correlationId, updateTokenKeys = true) {
|
|
11836
|
+
super.removeAccessToken(key, correlationId);
|
|
11837
|
+
this.performanceClient?.incrementFields({ accessTokensRemoved: 1 }, correlationId);
|
|
11838
|
+
updateTokenKeys &&
|
|
11839
|
+
this.removeTokenKey(key, CredentialType.ACCESS_TOKEN, correlationId);
|
|
11840
|
+
}
|
|
11841
|
+
removeAccessTokenKeys(keys, correlationId) {
|
|
11842
|
+
this.logger.trace("removeAccessTokenKey called");
|
|
11843
|
+
const tokenKeys = this.getTokenKeys();
|
|
11844
|
+
let keysRemoved = 0;
|
|
11845
|
+
keys.forEach((key) => {
|
|
11846
|
+
const accessRemoval = tokenKeys.accessToken.indexOf(key);
|
|
11847
|
+
if (accessRemoval > -1) {
|
|
11848
|
+
tokenKeys.accessToken.splice(accessRemoval, 1);
|
|
11849
|
+
keysRemoved++;
|
|
11850
|
+
}
|
|
11851
|
+
});
|
|
11852
|
+
if (keysRemoved > 0) {
|
|
11853
|
+
this.logger.info(`removed ${keysRemoved} accessToken keys from tokenKeys map`);
|
|
11854
|
+
this.setTokenKeys(tokenKeys, correlationId);
|
|
11855
|
+
return;
|
|
11856
|
+
}
|
|
11776
11857
|
}
|
|
11777
11858
|
/**
|
|
11778
11859
|
* Removes given refreshToken from the cache and from the key map
|
|
11779
11860
|
* @param key
|
|
11780
11861
|
*/
|
|
11781
|
-
removeRefreshToken(key) {
|
|
11782
|
-
super.removeRefreshToken(key);
|
|
11783
|
-
this.removeTokenKey(key, CredentialType.REFRESH_TOKEN);
|
|
11862
|
+
removeRefreshToken(key, correlationId) {
|
|
11863
|
+
super.removeRefreshToken(key, correlationId);
|
|
11864
|
+
this.removeTokenKey(key, CredentialType.REFRESH_TOKEN, correlationId);
|
|
11784
11865
|
}
|
|
11785
11866
|
/**
|
|
11786
11867
|
* Gets the keys for the cached tokens associated with this clientId
|
|
@@ -11810,12 +11891,30 @@ class BrowserCacheManager extends CacheManager {
|
|
|
11810
11891
|
refreshToken: [],
|
|
11811
11892
|
};
|
|
11812
11893
|
}
|
|
11894
|
+
/**
|
|
11895
|
+
* Stores the token keys in the cache
|
|
11896
|
+
* @param tokenKeys
|
|
11897
|
+
* @param correlationId
|
|
11898
|
+
* @returns
|
|
11899
|
+
*/
|
|
11900
|
+
setTokenKeys(tokenKeys, correlationId) {
|
|
11901
|
+
if (tokenKeys.idToken.length === 0 &&
|
|
11902
|
+
tokenKeys.accessToken.length === 0 &&
|
|
11903
|
+
tokenKeys.refreshToken.length === 0) {
|
|
11904
|
+
// If no keys left, remove the map
|
|
11905
|
+
this.removeItem(`${StaticCacheKeys.TOKEN_KEYS}.${this.clientId}`);
|
|
11906
|
+
return;
|
|
11907
|
+
}
|
|
11908
|
+
else {
|
|
11909
|
+
this.setItem(`${StaticCacheKeys.TOKEN_KEYS}.${this.clientId}`, JSON.stringify(tokenKeys), correlationId);
|
|
11910
|
+
}
|
|
11911
|
+
}
|
|
11813
11912
|
/**
|
|
11814
11913
|
* Adds the given key to the token key map
|
|
11815
11914
|
* @param key
|
|
11816
11915
|
* @param type
|
|
11817
11916
|
*/
|
|
11818
|
-
addTokenKey(key, type) {
|
|
11917
|
+
addTokenKey(key, type, correlationId) {
|
|
11819
11918
|
this.logger.trace("BrowserCacheManager addTokenKey called");
|
|
11820
11919
|
const tokenKeys = this.getTokenKeys();
|
|
11821
11920
|
switch (type) {
|
|
@@ -11826,10 +11925,12 @@ class BrowserCacheManager extends CacheManager {
|
|
|
11826
11925
|
}
|
|
11827
11926
|
break;
|
|
11828
11927
|
case CredentialType.ACCESS_TOKEN:
|
|
11829
|
-
|
|
11830
|
-
|
|
11831
|
-
tokenKeys.accessToken.
|
|
11928
|
+
const index = tokenKeys.accessToken.indexOf(key);
|
|
11929
|
+
if (index !== -1) {
|
|
11930
|
+
tokenKeys.accessToken.splice(index, 1); // Remove existing key before pushing to the end
|
|
11832
11931
|
}
|
|
11932
|
+
this.logger.trace(`access token ${index === -1 ? "added to" : "updated in"} map`);
|
|
11933
|
+
tokenKeys.accessToken.push(key);
|
|
11833
11934
|
break;
|
|
11834
11935
|
case CredentialType.REFRESH_TOKEN:
|
|
11835
11936
|
if (tokenKeys.refreshToken.indexOf(key) === -1) {
|
|
@@ -11841,16 +11942,15 @@ class BrowserCacheManager extends CacheManager {
|
|
|
11841
11942
|
this.logger.error(`BrowserCacheManager:addTokenKey - CredentialType provided invalid. CredentialType: ${type}`);
|
|
11842
11943
|
throw createClientAuthError(unexpectedCredentialType);
|
|
11843
11944
|
}
|
|
11844
|
-
this.
|
|
11945
|
+
this.setTokenKeys(tokenKeys, correlationId);
|
|
11845
11946
|
}
|
|
11846
11947
|
/**
|
|
11847
11948
|
* Removes the given key from the token key map
|
|
11848
11949
|
* @param key
|
|
11849
11950
|
* @param type
|
|
11850
11951
|
*/
|
|
11851
|
-
removeTokenKey(key, type) {
|
|
11952
|
+
removeTokenKey(key, type, correlationId, tokenKeys = this.getTokenKeys()) {
|
|
11852
11953
|
this.logger.trace("BrowserCacheManager removeTokenKey called");
|
|
11853
|
-
const tokenKeys = this.getTokenKeys();
|
|
11854
11954
|
switch (type) {
|
|
11855
11955
|
case CredentialType.ID_TOKEN:
|
|
11856
11956
|
this.logger.infoPii(`BrowserCacheManager: removeTokenKey - attempting to remove idToken with key: ${key} from map`);
|
|
@@ -11889,23 +11989,22 @@ class BrowserCacheManager extends CacheManager {
|
|
|
11889
11989
|
this.logger.error(`BrowserCacheManager:removeTokenKey - CredentialType provided invalid. CredentialType: ${type}`);
|
|
11890
11990
|
throw createClientAuthError(unexpectedCredentialType);
|
|
11891
11991
|
}
|
|
11892
|
-
this.
|
|
11992
|
+
this.setTokenKeys(tokenKeys, correlationId);
|
|
11893
11993
|
}
|
|
11894
11994
|
/**
|
|
11895
11995
|
* generates idToken entity from a string
|
|
11896
11996
|
* @param idTokenKey
|
|
11897
11997
|
*/
|
|
11898
|
-
getIdTokenCredential(idTokenKey) {
|
|
11998
|
+
getIdTokenCredential(idTokenKey, correlationId) {
|
|
11899
11999
|
const value = this.getItem(idTokenKey);
|
|
11900
12000
|
if (!value) {
|
|
11901
12001
|
this.logger.trace("BrowserCacheManager.getIdTokenCredential: called, no cache hit");
|
|
11902
|
-
this.
|
|
12002
|
+
this.removeIdToken(idTokenKey, correlationId);
|
|
11903
12003
|
return null;
|
|
11904
12004
|
}
|
|
11905
12005
|
const parsedIdToken = this.validateAndParseJson(value);
|
|
11906
12006
|
if (!parsedIdToken || !isIdTokenEntity(parsedIdToken)) {
|
|
11907
12007
|
this.logger.trace("BrowserCacheManager.getIdTokenCredential: called, no cache hit");
|
|
11908
|
-
this.removeTokenKey(idTokenKey, CredentialType.ID_TOKEN);
|
|
11909
12008
|
return null;
|
|
11910
12009
|
}
|
|
11911
12010
|
this.logger.trace("BrowserCacheManager.getIdTokenCredential: cache hit");
|
|
@@ -11915,28 +12014,28 @@ class BrowserCacheManager extends CacheManager {
|
|
|
11915
12014
|
* set IdToken credential to the platform cache
|
|
11916
12015
|
* @param idToken
|
|
11917
12016
|
*/
|
|
11918
|
-
setIdTokenCredential(idToken) {
|
|
12017
|
+
setIdTokenCredential(idToken, correlationId) {
|
|
11919
12018
|
this.logger.trace("BrowserCacheManager.setIdTokenCredential called");
|
|
11920
12019
|
const idTokenKey = generateCredentialKey(idToken);
|
|
11921
|
-
|
|
11922
|
-
this.
|
|
12020
|
+
idToken.lastUpdatedAt = Date.now().toString();
|
|
12021
|
+
this.setItem(idTokenKey, JSON.stringify(idToken), correlationId);
|
|
12022
|
+
this.addTokenKey(idTokenKey, CredentialType.ID_TOKEN, correlationId);
|
|
11923
12023
|
}
|
|
11924
12024
|
/**
|
|
11925
12025
|
* generates accessToken entity from a string
|
|
11926
12026
|
* @param key
|
|
11927
12027
|
*/
|
|
11928
|
-
getAccessTokenCredential(accessTokenKey) {
|
|
12028
|
+
getAccessTokenCredential(accessTokenKey, correlationId) {
|
|
11929
12029
|
const value = this.getItem(accessTokenKey);
|
|
11930
12030
|
if (!value) {
|
|
11931
12031
|
this.logger.trace("BrowserCacheManager.getAccessTokenCredential: called, no cache hit");
|
|
11932
|
-
this.removeTokenKey(accessTokenKey, CredentialType.ACCESS_TOKEN);
|
|
12032
|
+
this.removeTokenKey(accessTokenKey, CredentialType.ACCESS_TOKEN, correlationId);
|
|
11933
12033
|
return null;
|
|
11934
12034
|
}
|
|
11935
12035
|
const parsedAccessToken = this.validateAndParseJson(value);
|
|
11936
12036
|
if (!parsedAccessToken ||
|
|
11937
12037
|
!isAccessTokenEntity(parsedAccessToken)) {
|
|
11938
12038
|
this.logger.trace("BrowserCacheManager.getAccessTokenCredential: called, no cache hit");
|
|
11939
|
-
this.removeTokenKey(accessTokenKey, CredentialType.ACCESS_TOKEN);
|
|
11940
12039
|
return null;
|
|
11941
12040
|
}
|
|
11942
12041
|
this.logger.trace("BrowserCacheManager.getAccessTokenCredential: cache hit");
|
|
@@ -11946,28 +12045,28 @@ class BrowserCacheManager extends CacheManager {
|
|
|
11946
12045
|
* set accessToken credential to the platform cache
|
|
11947
12046
|
* @param accessToken
|
|
11948
12047
|
*/
|
|
11949
|
-
setAccessTokenCredential(accessToken) {
|
|
12048
|
+
setAccessTokenCredential(accessToken, correlationId) {
|
|
11950
12049
|
this.logger.trace("BrowserCacheManager.setAccessTokenCredential called");
|
|
11951
12050
|
const accessTokenKey = generateCredentialKey(accessToken);
|
|
11952
|
-
|
|
11953
|
-
this.
|
|
12051
|
+
accessToken.lastUpdatedAt = Date.now().toString();
|
|
12052
|
+
this.setItem(accessTokenKey, JSON.stringify(accessToken), correlationId);
|
|
12053
|
+
this.addTokenKey(accessTokenKey, CredentialType.ACCESS_TOKEN, correlationId);
|
|
11954
12054
|
}
|
|
11955
12055
|
/**
|
|
11956
12056
|
* generates refreshToken entity from a string
|
|
11957
12057
|
* @param refreshTokenKey
|
|
11958
12058
|
*/
|
|
11959
|
-
getRefreshTokenCredential(refreshTokenKey) {
|
|
12059
|
+
getRefreshTokenCredential(refreshTokenKey, correlationId) {
|
|
11960
12060
|
const value = this.getItem(refreshTokenKey);
|
|
11961
12061
|
if (!value) {
|
|
11962
12062
|
this.logger.trace("BrowserCacheManager.getRefreshTokenCredential: called, no cache hit");
|
|
11963
|
-
this.removeTokenKey(refreshTokenKey, CredentialType.REFRESH_TOKEN);
|
|
12063
|
+
this.removeTokenKey(refreshTokenKey, CredentialType.REFRESH_TOKEN, correlationId);
|
|
11964
12064
|
return null;
|
|
11965
12065
|
}
|
|
11966
12066
|
const parsedRefreshToken = this.validateAndParseJson(value);
|
|
11967
12067
|
if (!parsedRefreshToken ||
|
|
11968
12068
|
!isRefreshTokenEntity(parsedRefreshToken)) {
|
|
11969
12069
|
this.logger.trace("BrowserCacheManager.getRefreshTokenCredential: called, no cache hit");
|
|
11970
|
-
this.removeTokenKey(refreshTokenKey, CredentialType.REFRESH_TOKEN);
|
|
11971
12070
|
return null;
|
|
11972
12071
|
}
|
|
11973
12072
|
this.logger.trace("BrowserCacheManager.getRefreshTokenCredential: cache hit");
|
|
@@ -11977,11 +12076,12 @@ class BrowserCacheManager extends CacheManager {
|
|
|
11977
12076
|
* set refreshToken credential to the platform cache
|
|
11978
12077
|
* @param refreshToken
|
|
11979
12078
|
*/
|
|
11980
|
-
setRefreshTokenCredential(refreshToken) {
|
|
12079
|
+
setRefreshTokenCredential(refreshToken, correlationId) {
|
|
11981
12080
|
this.logger.trace("BrowserCacheManager.setRefreshTokenCredential called");
|
|
11982
12081
|
const refreshTokenKey = generateCredentialKey(refreshToken);
|
|
11983
|
-
|
|
11984
|
-
this.
|
|
12082
|
+
refreshToken.lastUpdatedAt = Date.now().toString();
|
|
12083
|
+
this.setItem(refreshTokenKey, JSON.stringify(refreshToken), correlationId);
|
|
12084
|
+
this.addTokenKey(refreshTokenKey, CredentialType.REFRESH_TOKEN, correlationId);
|
|
11985
12085
|
}
|
|
11986
12086
|
/**
|
|
11987
12087
|
* fetch appMetadata entity from the platform cache
|
|
@@ -12006,10 +12106,10 @@ class BrowserCacheManager extends CacheManager {
|
|
|
12006
12106
|
* set appMetadata entity to the platform cache
|
|
12007
12107
|
* @param appMetadata
|
|
12008
12108
|
*/
|
|
12009
|
-
setAppMetadata(appMetadata) {
|
|
12109
|
+
setAppMetadata(appMetadata, correlationId) {
|
|
12010
12110
|
this.logger.trace("BrowserCacheManager.setAppMetadata called");
|
|
12011
12111
|
const appMetadataKey = generateAppMetadataKey(appMetadata);
|
|
12012
|
-
this.setItem(appMetadataKey, JSON.stringify(appMetadata));
|
|
12112
|
+
this.setItem(appMetadataKey, JSON.stringify(appMetadata), correlationId);
|
|
12013
12113
|
}
|
|
12014
12114
|
/**
|
|
12015
12115
|
* fetch server telemetry entity from the platform cache
|
|
@@ -12035,9 +12135,9 @@ class BrowserCacheManager extends CacheManager {
|
|
|
12035
12135
|
* @param serverTelemetryKey
|
|
12036
12136
|
* @param serverTelemetry
|
|
12037
12137
|
*/
|
|
12038
|
-
setServerTelemetry(serverTelemetryKey, serverTelemetry) {
|
|
12138
|
+
setServerTelemetry(serverTelemetryKey, serverTelemetry, correlationId) {
|
|
12039
12139
|
this.logger.trace("BrowserCacheManager.setServerTelemetry called");
|
|
12040
|
-
this.setItem(serverTelemetryKey, JSON.stringify(serverTelemetry));
|
|
12140
|
+
this.setItem(serverTelemetryKey, JSON.stringify(serverTelemetry), correlationId);
|
|
12041
12141
|
}
|
|
12042
12142
|
/**
|
|
12043
12143
|
*
|
|
@@ -12095,7 +12195,7 @@ class BrowserCacheManager extends CacheManager {
|
|
|
12095
12195
|
/**
|
|
12096
12196
|
* Gets the active account
|
|
12097
12197
|
*/
|
|
12098
|
-
getActiveAccount() {
|
|
12198
|
+
getActiveAccount(correlationId) {
|
|
12099
12199
|
const activeAccountKeyFilters = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT_FILTERS);
|
|
12100
12200
|
const activeAccountValueFilters = this.getItem(activeAccountKeyFilters);
|
|
12101
12201
|
if (!activeAccountValueFilters) {
|
|
@@ -12109,11 +12209,11 @@ class BrowserCacheManager extends CacheManager {
|
|
|
12109
12209
|
}
|
|
12110
12210
|
const activeAccount = this.getAccountInfoFilteredBy({
|
|
12111
12211
|
localAccountId: activeAccountValueLocal,
|
|
12112
|
-
});
|
|
12212
|
+
}, correlationId);
|
|
12113
12213
|
if (activeAccount) {
|
|
12114
12214
|
this.logger.trace("BrowserCacheManager.getActiveAccount: Legacy active account cache schema found");
|
|
12115
12215
|
this.logger.trace("BrowserCacheManager.getActiveAccount: Adding active account filters cache schema");
|
|
12116
|
-
this.setActiveAccount(activeAccount);
|
|
12216
|
+
this.setActiveAccount(activeAccount, correlationId);
|
|
12117
12217
|
return activeAccount;
|
|
12118
12218
|
}
|
|
12119
12219
|
return null;
|
|
@@ -12125,7 +12225,7 @@ class BrowserCacheManager extends CacheManager {
|
|
|
12125
12225
|
homeAccountId: activeAccountValueObj.homeAccountId,
|
|
12126
12226
|
localAccountId: activeAccountValueObj.localAccountId,
|
|
12127
12227
|
tenantId: activeAccountValueObj.tenantId,
|
|
12128
|
-
});
|
|
12228
|
+
}, correlationId);
|
|
12129
12229
|
}
|
|
12130
12230
|
this.logger.trace("BrowserCacheManager.getActiveAccount: No active account found");
|
|
12131
12231
|
return null;
|
|
@@ -12134,7 +12234,7 @@ class BrowserCacheManager extends CacheManager {
|
|
|
12134
12234
|
* Sets the active account's localAccountId in cache
|
|
12135
12235
|
* @param account
|
|
12136
12236
|
*/
|
|
12137
|
-
setActiveAccount(account) {
|
|
12237
|
+
setActiveAccount(account, correlationId) {
|
|
12138
12238
|
const activeAccountKey = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT_FILTERS);
|
|
12139
12239
|
const activeAccountKeyLocal = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT);
|
|
12140
12240
|
if (account) {
|
|
@@ -12143,9 +12243,10 @@ class BrowserCacheManager extends CacheManager {
|
|
|
12143
12243
|
homeAccountId: account.homeAccountId,
|
|
12144
12244
|
localAccountId: account.localAccountId,
|
|
12145
12245
|
tenantId: account.tenantId,
|
|
12246
|
+
lastUpdatedAt: Date.now().toString(),
|
|
12146
12247
|
};
|
|
12147
|
-
this.
|
|
12148
|
-
this.
|
|
12248
|
+
this.setItem(activeAccountKey, JSON.stringify(activeAccountValue), correlationId);
|
|
12249
|
+
this.setItem(activeAccountKeyLocal, account.localAccountId, correlationId);
|
|
12149
12250
|
}
|
|
12150
12251
|
else {
|
|
12151
12252
|
this.logger.verbose("setActiveAccount: No account passed, active account not set");
|
|
@@ -12177,9 +12278,9 @@ class BrowserCacheManager extends CacheManager {
|
|
|
12177
12278
|
* @param throttlingCacheKey
|
|
12178
12279
|
* @param throttlingCache
|
|
12179
12280
|
*/
|
|
12180
|
-
setThrottlingCache(throttlingCacheKey, throttlingCache) {
|
|
12281
|
+
setThrottlingCache(throttlingCacheKey, throttlingCache, correlationId) {
|
|
12181
12282
|
this.logger.trace("BrowserCacheManager.setThrottlingCache called");
|
|
12182
|
-
this.setItem(throttlingCacheKey, JSON.stringify(throttlingCache));
|
|
12283
|
+
this.setItem(throttlingCacheKey, JSON.stringify(throttlingCache), correlationId);
|
|
12183
12284
|
}
|
|
12184
12285
|
/**
|
|
12185
12286
|
* Gets cache item with given key.
|
|
@@ -12255,10 +12356,10 @@ class BrowserCacheManager extends CacheManager {
|
|
|
12255
12356
|
/**
|
|
12256
12357
|
* Clears all cache entries created by MSAL.
|
|
12257
12358
|
*/
|
|
12258
|
-
async clear() {
|
|
12359
|
+
async clear(correlationId) {
|
|
12259
12360
|
// Removes all accounts and their credentials
|
|
12260
|
-
await this.removeAllAccounts();
|
|
12261
|
-
this.removeAppMetadata();
|
|
12361
|
+
await this.removeAllAccounts(correlationId);
|
|
12362
|
+
this.removeAppMetadata(correlationId);
|
|
12262
12363
|
// Remove temp storage first to make sure any cookies are cleared
|
|
12263
12364
|
this.temporaryCacheStorage.getKeys().forEach((cacheKey) => {
|
|
12264
12365
|
if (cacheKey.indexOf(Constants.CACHE_PREFIX) !== -1 ||
|
|
@@ -12284,19 +12385,19 @@ class BrowserCacheManager extends CacheManager {
|
|
|
12284
12385
|
async clearTokensAndKeysWithClaims(performanceClient, correlationId) {
|
|
12285
12386
|
performanceClient.addQueueMeasurement(PerformanceEvents.ClearTokensAndKeysWithClaims, correlationId);
|
|
12286
12387
|
const tokenKeys = this.getTokenKeys();
|
|
12287
|
-
|
|
12388
|
+
let removedAccessTokens = 0;
|
|
12288
12389
|
tokenKeys.accessToken.forEach((key) => {
|
|
12289
12390
|
// if the access token has claims in its key, remove the token key and the token
|
|
12290
|
-
const credential = this.getAccessTokenCredential(key);
|
|
12391
|
+
const credential = this.getAccessTokenCredential(key, correlationId);
|
|
12291
12392
|
if (credential?.requestedClaimsHash &&
|
|
12292
12393
|
key.includes(credential.requestedClaimsHash.toLowerCase())) {
|
|
12293
|
-
|
|
12394
|
+
this.removeAccessToken(key, correlationId);
|
|
12395
|
+
removedAccessTokens++;
|
|
12294
12396
|
}
|
|
12295
12397
|
});
|
|
12296
|
-
await Promise.all(removedAccessTokens);
|
|
12297
12398
|
// warn if any access tokens are removed
|
|
12298
|
-
if (removedAccessTokens
|
|
12299
|
-
this.logger.warning(`${removedAccessTokens
|
|
12399
|
+
if (removedAccessTokens > 0) {
|
|
12400
|
+
this.logger.warning(`${removedAccessTokens} access tokens with claims in the cache keys have been removed from the cache.`);
|
|
12300
12401
|
}
|
|
12301
12402
|
}
|
|
12302
12403
|
/**
|
|
@@ -12571,13 +12672,13 @@ class BrowserCacheManager extends CacheManager {
|
|
|
12571
12672
|
/**
|
|
12572
12673
|
* Updates a credential's cache key if the current cache key is outdated
|
|
12573
12674
|
*/
|
|
12574
|
-
updateCredentialCacheKey(currentCacheKey, credential) {
|
|
12675
|
+
updateCredentialCacheKey(currentCacheKey, credential, correlationId) {
|
|
12575
12676
|
const updatedCacheKey = generateCredentialKey(credential);
|
|
12576
12677
|
if (currentCacheKey !== updatedCacheKey) {
|
|
12577
12678
|
const cacheItem = this.getItem(currentCacheKey);
|
|
12578
12679
|
if (cacheItem) {
|
|
12579
12680
|
this.browserStorage.removeItem(currentCacheKey);
|
|
12580
|
-
this.setItem(updatedCacheKey, cacheItem);
|
|
12681
|
+
this.setItem(updatedCacheKey, cacheItem, correlationId);
|
|
12581
12682
|
this.logger.verbose(`Updated an outdated ${credential.credentialType} cache key`);
|
|
12582
12683
|
return updatedCacheKey;
|
|
12583
12684
|
}
|
|
@@ -12612,7 +12713,7 @@ class BrowserCacheManager extends CacheManager {
|
|
|
12612
12713
|
idToken: idTokenEntity,
|
|
12613
12714
|
accessToken: accessTokenEntity,
|
|
12614
12715
|
};
|
|
12615
|
-
return this.saveCacheRecord(cacheRecord);
|
|
12716
|
+
return this.saveCacheRecord(cacheRecord, result.correlationId);
|
|
12616
12717
|
}
|
|
12617
12718
|
/**
|
|
12618
12719
|
* saves a cache record
|
|
@@ -12620,9 +12721,9 @@ class BrowserCacheManager extends CacheManager {
|
|
|
12620
12721
|
* @param storeInCache {?StoreInCache}
|
|
12621
12722
|
* @param correlationId {?string} correlation id
|
|
12622
12723
|
*/
|
|
12623
|
-
async saveCacheRecord(cacheRecord,
|
|
12724
|
+
async saveCacheRecord(cacheRecord, correlationId, storeInCache) {
|
|
12624
12725
|
try {
|
|
12625
|
-
await super.saveCacheRecord(cacheRecord,
|
|
12726
|
+
await super.saveCacheRecord(cacheRecord, correlationId, storeInCache);
|
|
12626
12727
|
}
|
|
12627
12728
|
catch (e) {
|
|
12628
12729
|
if (e instanceof CacheError &&
|
|
@@ -12663,22 +12764,24 @@ const DEFAULT_BROWSER_CACHE_MANAGER = (clientId, logger) => {
|
|
|
12663
12764
|
* @param accountFilter - (Optional) filter to narrow down the accounts returned
|
|
12664
12765
|
* @returns Array of AccountInfo objects in cache
|
|
12665
12766
|
*/
|
|
12666
|
-
function getAllAccounts(logger, browserStorage, isInBrowser, accountFilter) {
|
|
12767
|
+
function getAllAccounts(logger, browserStorage, isInBrowser, correlationId, accountFilter) {
|
|
12667
12768
|
logger.verbose("getAllAccounts called");
|
|
12668
|
-
return isInBrowser
|
|
12769
|
+
return isInBrowser
|
|
12770
|
+
? browserStorage.getAllAccounts(correlationId, accountFilter)
|
|
12771
|
+
: [];
|
|
12669
12772
|
}
|
|
12670
12773
|
/**
|
|
12671
12774
|
* Returns the first account found in the cache that matches the account filter passed in.
|
|
12672
12775
|
* @param accountFilter
|
|
12673
12776
|
* @returns The first account found in the cache matching the provided filter or null if no account could be found.
|
|
12674
12777
|
*/
|
|
12675
|
-
function getAccount(accountFilter, logger, browserStorage) {
|
|
12778
|
+
function getAccount(accountFilter, logger, browserStorage, correlationId) {
|
|
12676
12779
|
logger.trace("getAccount called");
|
|
12677
12780
|
if (Object.keys(accountFilter).length === 0) {
|
|
12678
12781
|
logger.warning("getAccount: No accountFilter provided");
|
|
12679
12782
|
return null;
|
|
12680
12783
|
}
|
|
12681
|
-
const account = browserStorage.getAccountInfoFilteredBy(accountFilter);
|
|
12784
|
+
const account = browserStorage.getAccountInfoFilteredBy(accountFilter, correlationId);
|
|
12682
12785
|
if (account) {
|
|
12683
12786
|
logger.verbose("getAccount: Account matching provided filter found, returning");
|
|
12684
12787
|
return account;
|
|
@@ -12696,7 +12799,7 @@ function getAccount(accountFilter, logger, browserStorage) {
|
|
|
12696
12799
|
* @param username
|
|
12697
12800
|
* @returns The account object stored in MSAL
|
|
12698
12801
|
*/
|
|
12699
|
-
function getAccountByUsername(username, logger, browserStorage) {
|
|
12802
|
+
function getAccountByUsername(username, logger, browserStorage, correlationId) {
|
|
12700
12803
|
logger.trace("getAccountByUsername called");
|
|
12701
12804
|
if (!username) {
|
|
12702
12805
|
logger.warning("getAccountByUsername: No username provided");
|
|
@@ -12704,7 +12807,7 @@ function getAccountByUsername(username, logger, browserStorage) {
|
|
|
12704
12807
|
}
|
|
12705
12808
|
const account = browserStorage.getAccountInfoFilteredBy({
|
|
12706
12809
|
username,
|
|
12707
|
-
});
|
|
12810
|
+
}, correlationId);
|
|
12708
12811
|
if (account) {
|
|
12709
12812
|
logger.verbose("getAccountByUsername: Account matching username found, returning");
|
|
12710
12813
|
logger.verbosePii(`getAccountByUsername: Returning signed-in accounts matching username: ${username}`);
|
|
@@ -12722,7 +12825,7 @@ function getAccountByUsername(username, logger, browserStorage) {
|
|
|
12722
12825
|
* @param homeAccountId
|
|
12723
12826
|
* @returns The account object stored in MSAL
|
|
12724
12827
|
*/
|
|
12725
|
-
function getAccountByHomeId(homeAccountId, logger, browserStorage) {
|
|
12828
|
+
function getAccountByHomeId(homeAccountId, logger, browserStorage, correlationId) {
|
|
12726
12829
|
logger.trace("getAccountByHomeId called");
|
|
12727
12830
|
if (!homeAccountId) {
|
|
12728
12831
|
logger.warning("getAccountByHomeId: No homeAccountId provided");
|
|
@@ -12730,7 +12833,7 @@ function getAccountByHomeId(homeAccountId, logger, browserStorage) {
|
|
|
12730
12833
|
}
|
|
12731
12834
|
const account = browserStorage.getAccountInfoFilteredBy({
|
|
12732
12835
|
homeAccountId,
|
|
12733
|
-
});
|
|
12836
|
+
}, correlationId);
|
|
12734
12837
|
if (account) {
|
|
12735
12838
|
logger.verbose("getAccountByHomeId: Account matching homeAccountId found, returning");
|
|
12736
12839
|
logger.verbosePii(`getAccountByHomeId: Returning signed-in accounts matching homeAccountId: ${homeAccountId}`);
|
|
@@ -12748,7 +12851,7 @@ function getAccountByHomeId(homeAccountId, logger, browserStorage) {
|
|
|
12748
12851
|
* @param localAccountId
|
|
12749
12852
|
* @returns The account object stored in MSAL
|
|
12750
12853
|
*/
|
|
12751
|
-
function getAccountByLocalId(localAccountId, logger, browserStorage) {
|
|
12854
|
+
function getAccountByLocalId(localAccountId, logger, browserStorage, correlationId) {
|
|
12752
12855
|
logger.trace("getAccountByLocalId called");
|
|
12753
12856
|
if (!localAccountId) {
|
|
12754
12857
|
logger.warning("getAccountByLocalId: No localAccountId provided");
|
|
@@ -12756,7 +12859,7 @@ function getAccountByLocalId(localAccountId, logger, browserStorage) {
|
|
|
12756
12859
|
}
|
|
12757
12860
|
const account = browserStorage.getAccountInfoFilteredBy({
|
|
12758
12861
|
localAccountId,
|
|
12759
|
-
});
|
|
12862
|
+
}, correlationId);
|
|
12760
12863
|
if (account) {
|
|
12761
12864
|
logger.verbose("getAccountByLocalId: Account matching localAccountId found, returning");
|
|
12762
12865
|
logger.verbosePii(`getAccountByLocalId: Returning signed-in accounts matching localAccountId: ${localAccountId}`);
|
|
@@ -12771,14 +12874,14 @@ function getAccountByLocalId(localAccountId, logger, browserStorage) {
|
|
|
12771
12874
|
* Sets the account to use as the active account. If no account is passed to the acquireToken APIs, then MSAL will use this active account.
|
|
12772
12875
|
* @param account
|
|
12773
12876
|
*/
|
|
12774
|
-
function setActiveAccount(account, browserStorage) {
|
|
12775
|
-
browserStorage.setActiveAccount(account);
|
|
12877
|
+
function setActiveAccount(account, browserStorage, correlationId) {
|
|
12878
|
+
browserStorage.setActiveAccount(account, correlationId);
|
|
12776
12879
|
}
|
|
12777
12880
|
/**
|
|
12778
12881
|
* Gets the currently active account
|
|
12779
12882
|
*/
|
|
12780
|
-
function getActiveAccount(browserStorage) {
|
|
12781
|
-
return browserStorage.getActiveAccount();
|
|
12883
|
+
function getActiveAccount(browserStorage, correlationId) {
|
|
12884
|
+
return browserStorage.getActiveAccount(correlationId);
|
|
12782
12885
|
}
|
|
12783
12886
|
|
|
12784
12887
|
/*
|
|
@@ -12896,13 +12999,13 @@ class BaseInteractionClient {
|
|
|
12896
12999
|
}
|
|
12897
13000
|
async clearCacheOnLogout(account) {
|
|
12898
13001
|
if (account) {
|
|
12899
|
-
if (AccountEntity.accountInfoIsEqual(account, this.browserStorage.getActiveAccount(), false)) {
|
|
13002
|
+
if (AccountEntity.accountInfoIsEqual(account, this.browserStorage.getActiveAccount(this.correlationId), false)) {
|
|
12900
13003
|
this.logger.verbose("Setting active account to null");
|
|
12901
|
-
this.browserStorage.setActiveAccount(null);
|
|
13004
|
+
this.browserStorage.setActiveAccount(null, this.correlationId);
|
|
12902
13005
|
}
|
|
12903
13006
|
// Clear given account.
|
|
12904
13007
|
try {
|
|
12905
|
-
await this.browserStorage.removeAccount(AccountEntity.generateAccountCacheKey(account));
|
|
13008
|
+
await this.browserStorage.removeAccount(AccountEntity.generateAccountCacheKey(account), this.correlationId);
|
|
12906
13009
|
this.logger.verbose("Cleared cache items belonging to the account provided in the logout request.");
|
|
12907
13010
|
}
|
|
12908
13011
|
catch (error) {
|
|
@@ -12913,7 +13016,7 @@ class BaseInteractionClient {
|
|
|
12913
13016
|
try {
|
|
12914
13017
|
this.logger.verbose("No account provided in logout request, clearing all cache items.", this.correlationId);
|
|
12915
13018
|
// Clear all accounts and tokens
|
|
12916
|
-
await this.browserStorage.clear();
|
|
13019
|
+
await this.browserStorage.clear(this.correlationId);
|
|
12917
13020
|
// Clear any stray keys from IndexedDB
|
|
12918
13021
|
await this.browserCrypto.clearKeystore();
|
|
12919
13022
|
}
|
|
@@ -13307,7 +13410,8 @@ class StandardInteractionClient extends BaseInteractionClient {
|
|
|
13307
13410
|
if (request.loginHint || request.sid) {
|
|
13308
13411
|
return validatedRequest;
|
|
13309
13412
|
}
|
|
13310
|
-
const account = request.account ||
|
|
13413
|
+
const account = request.account ||
|
|
13414
|
+
this.browserStorage.getActiveAccount(this.correlationId);
|
|
13311
13415
|
if (account) {
|
|
13312
13416
|
this.logger.verbose("Setting validated request account", this.correlationId);
|
|
13313
13417
|
this.logger.verbosePii(`Setting validated request account: ${account.homeAccountId}`, this.correlationId);
|
|
@@ -13580,7 +13684,7 @@ class NativeInteractionClient extends BaseInteractionClient {
|
|
|
13580
13684
|
// fetch the account from browser cache
|
|
13581
13685
|
const account = this.browserStorage.getBaseAccountInfo({
|
|
13582
13686
|
nativeAccountId,
|
|
13583
|
-
});
|
|
13687
|
+
}, request.correlationId);
|
|
13584
13688
|
if (!account) {
|
|
13585
13689
|
throw createClientAuthError(noAccountFound);
|
|
13586
13690
|
}
|
|
@@ -13707,7 +13811,7 @@ class NativeInteractionClient extends BaseInteractionClient {
|
|
|
13707
13811
|
const homeAccountIdentifier = this.createHomeAccountIdentifier(response, idTokenClaims);
|
|
13708
13812
|
const cachedhomeAccountId = this.browserStorage.getAccountInfoFilteredBy({
|
|
13709
13813
|
nativeAccountId: request.accountId,
|
|
13710
|
-
})?.homeAccountId;
|
|
13814
|
+
}, this.correlationId)?.homeAccountId;
|
|
13711
13815
|
if (homeAccountIdentifier !== cachedhomeAccountId &&
|
|
13712
13816
|
response.account.id !== request.accountId) {
|
|
13713
13817
|
// User switch in native broker prompt is not supported. All users must first sign in through web flow to ensure server state is in sync
|
|
@@ -13717,7 +13821,7 @@ class NativeInteractionClient extends BaseInteractionClient {
|
|
|
13717
13821
|
const authority = await this.getDiscoveredAuthority({
|
|
13718
13822
|
requestAuthority: request.authority,
|
|
13719
13823
|
});
|
|
13720
|
-
const baseAccount = buildAccountToCache(this.browserStorage, authority, homeAccountIdentifier, base64Decode, idTokenClaims, response.client_info, undefined, // environment
|
|
13824
|
+
const baseAccount = buildAccountToCache(this.browserStorage, authority, homeAccountIdentifier, base64Decode, this.correlationId, idTokenClaims, response.client_info, undefined, // environment
|
|
13721
13825
|
idTokenClaims.tid, undefined, // auth code payload
|
|
13722
13826
|
response.account.id, this.logger);
|
|
13723
13827
|
// generate authenticationResult
|
|
@@ -13850,9 +13954,11 @@ class NativeInteractionClient extends BaseInteractionClient {
|
|
|
13850
13954
|
*/
|
|
13851
13955
|
cacheAccount(accountEntity) {
|
|
13852
13956
|
// Store the account info and hence `nativeAccountId` in browser cache
|
|
13853
|
-
this.browserStorage.setAccount(accountEntity);
|
|
13957
|
+
this.browserStorage.setAccount(accountEntity, this.correlationId);
|
|
13854
13958
|
// Remove any existing cached tokens for this account in browser storage
|
|
13855
|
-
this.browserStorage
|
|
13959
|
+
this.browserStorage
|
|
13960
|
+
.removeAccountContext(accountEntity, this.correlationId)
|
|
13961
|
+
.catch((e) => {
|
|
13856
13962
|
this.logger.error(`Error occurred while removing account context from browser storage. ${e}`);
|
|
13857
13963
|
});
|
|
13858
13964
|
}
|
|
@@ -13881,7 +13987,7 @@ class NativeInteractionClient extends BaseInteractionClient {
|
|
|
13881
13987
|
idToken: cachedIdToken,
|
|
13882
13988
|
accessToken: cachedAccessToken,
|
|
13883
13989
|
};
|
|
13884
|
-
void this.nativeStorageManager.saveCacheRecord(nativeCacheRecord, request.storeInCache);
|
|
13990
|
+
void this.nativeStorageManager.saveCacheRecord(nativeCacheRecord, request.correlationId, request.storeInCache);
|
|
13885
13991
|
}
|
|
13886
13992
|
addTelemetryFromNativeResponse(response) {
|
|
13887
13993
|
const mats = this.getMATSFromResponse(response);
|
|
@@ -14657,7 +14763,7 @@ class PopupClient extends StandardInteractionClient {
|
|
|
14657
14763
|
if (validRequest.account?.homeAccountId &&
|
|
14658
14764
|
validRequest.postLogoutRedirectUri &&
|
|
14659
14765
|
authClient.authority.protocolMode === ProtocolMode.OIDC) {
|
|
14660
|
-
void this.browserStorage.removeAccount(validRequest.account?.homeAccountId);
|
|
14766
|
+
void this.browserStorage.removeAccount(validRequest.account?.homeAccountId, this.correlationId);
|
|
14661
14767
|
this.eventHandler.emitEvent(EventType.LOGOUT_SUCCESS, exports.InteractionType.Popup, validRequest);
|
|
14662
14768
|
if (mainWindowRedirectUri) {
|
|
14663
14769
|
const navigationOptions = {
|
|
@@ -15332,7 +15438,7 @@ class RedirectClient extends StandardInteractionClient {
|
|
|
15332
15438
|
}
|
|
15333
15439
|
catch {
|
|
15334
15440
|
if (validLogoutRequest.account?.homeAccountId) {
|
|
15335
|
-
void this.browserStorage.removeAccount(validLogoutRequest.account?.homeAccountId);
|
|
15441
|
+
void this.browserStorage.removeAccount(validLogoutRequest.account?.homeAccountId, this.correlationId);
|
|
15336
15442
|
this.eventHandler.emitEvent(EventType.LOGOUT_SUCCESS, exports.InteractionType.Redirect, validLogoutRequest);
|
|
15337
15443
|
return;
|
|
15338
15444
|
}
|
|
@@ -15732,6 +15838,7 @@ class TokenCache {
|
|
|
15732
15838
|
if (!this.isBrowserEnvironment) {
|
|
15733
15839
|
throw createBrowserAuthError(nonBrowserEnvironment);
|
|
15734
15840
|
}
|
|
15841
|
+
const correlationId = request.correlationId || createNewGuid();
|
|
15735
15842
|
const idTokenClaims = response.id_token
|
|
15736
15843
|
? extractTokenClaims(response.id_token, base64Decode)
|
|
15737
15844
|
: undefined;
|
|
@@ -15745,10 +15852,10 @@ class TokenCache {
|
|
|
15745
15852
|
const authority = request.authority
|
|
15746
15853
|
? new Authority(Authority.generateAuthority(request.authority, request.azureCloudOptions), this.config.system.networkClient, this.storage, authorityOptions, this.logger, request.correlationId || createNewGuid())
|
|
15747
15854
|
: undefined;
|
|
15748
|
-
const cacheRecordAccount = this.loadAccount(request, options.clientInfo || response.client_info || "", idTokenClaims, authority);
|
|
15749
|
-
const idToken = this.loadIdToken(response, cacheRecordAccount.homeAccountId, cacheRecordAccount.environment, cacheRecordAccount.realm);
|
|
15750
|
-
const accessToken = this.loadAccessToken(request, response, cacheRecordAccount.homeAccountId, cacheRecordAccount.environment, cacheRecordAccount.realm, options);
|
|
15751
|
-
const refreshToken = this.loadRefreshToken(response, cacheRecordAccount.homeAccountId, cacheRecordAccount.environment);
|
|
15855
|
+
const cacheRecordAccount = this.loadAccount(request, options.clientInfo || response.client_info || "", correlationId, idTokenClaims, authority);
|
|
15856
|
+
const idToken = this.loadIdToken(response, cacheRecordAccount.homeAccountId, cacheRecordAccount.environment, cacheRecordAccount.realm, correlationId);
|
|
15857
|
+
const accessToken = this.loadAccessToken(request, response, cacheRecordAccount.homeAccountId, cacheRecordAccount.environment, cacheRecordAccount.realm, options, correlationId);
|
|
15858
|
+
const refreshToken = this.loadRefreshToken(response, cacheRecordAccount.homeAccountId, cacheRecordAccount.environment, correlationId);
|
|
15752
15859
|
return this.generateAuthenticationResult(request, {
|
|
15753
15860
|
account: cacheRecordAccount,
|
|
15754
15861
|
idToken,
|
|
@@ -15765,11 +15872,11 @@ class TokenCache {
|
|
|
15765
15872
|
* @param requestHomeAccountId
|
|
15766
15873
|
* @returns `AccountEntity`
|
|
15767
15874
|
*/
|
|
15768
|
-
loadAccount(request, clientInfo, idTokenClaims, authority) {
|
|
15875
|
+
loadAccount(request, clientInfo, correlationId, idTokenClaims, authority) {
|
|
15769
15876
|
this.logger.verbose("TokenCache - loading account");
|
|
15770
15877
|
if (request.account) {
|
|
15771
15878
|
const accountEntity = AccountEntity.createFromAccountInfo(request.account);
|
|
15772
|
-
this.storage.setAccount(accountEntity);
|
|
15879
|
+
this.storage.setAccount(accountEntity, correlationId);
|
|
15773
15880
|
return accountEntity;
|
|
15774
15881
|
}
|
|
15775
15882
|
else if (!authority || (!clientInfo && !idTokenClaims)) {
|
|
@@ -15778,10 +15885,10 @@ class TokenCache {
|
|
|
15778
15885
|
}
|
|
15779
15886
|
const homeAccountId = AccountEntity.generateHomeAccountId(clientInfo, authority.authorityType, this.logger, this.cryptoObj, idTokenClaims);
|
|
15780
15887
|
const claimsTenantId = idTokenClaims?.tid;
|
|
15781
|
-
const cachedAccount = buildAccountToCache(this.storage, authority, homeAccountId, base64Decode, idTokenClaims, clientInfo, authority.hostnameAndPort, claimsTenantId, undefined, // authCodePayload
|
|
15888
|
+
const cachedAccount = buildAccountToCache(this.storage, authority, homeAccountId, base64Decode, correlationId, idTokenClaims, clientInfo, authority.hostnameAndPort, claimsTenantId, undefined, // authCodePayload
|
|
15782
15889
|
undefined, // nativeAccountId
|
|
15783
15890
|
this.logger);
|
|
15784
|
-
this.storage.setAccount(cachedAccount);
|
|
15891
|
+
this.storage.setAccount(cachedAccount, correlationId);
|
|
15785
15892
|
return cachedAccount;
|
|
15786
15893
|
}
|
|
15787
15894
|
/**
|
|
@@ -15792,14 +15899,14 @@ class TokenCache {
|
|
|
15792
15899
|
* @param tenantId
|
|
15793
15900
|
* @returns `IdTokenEntity`
|
|
15794
15901
|
*/
|
|
15795
|
-
loadIdToken(response, homeAccountId, environment, tenantId) {
|
|
15902
|
+
loadIdToken(response, homeAccountId, environment, tenantId, correlationId) {
|
|
15796
15903
|
if (!response.id_token) {
|
|
15797
15904
|
this.logger.verbose("TokenCache - no id token found in response");
|
|
15798
15905
|
return null;
|
|
15799
15906
|
}
|
|
15800
15907
|
this.logger.verbose("TokenCache - loading id token");
|
|
15801
15908
|
const idTokenEntity = createIdTokenEntity(homeAccountId, environment, response.id_token, this.config.auth.clientId, tenantId);
|
|
15802
|
-
this.storage.setIdTokenCredential(idTokenEntity);
|
|
15909
|
+
this.storage.setIdTokenCredential(idTokenEntity, correlationId);
|
|
15803
15910
|
return idTokenEntity;
|
|
15804
15911
|
}
|
|
15805
15912
|
/**
|
|
@@ -15811,7 +15918,7 @@ class TokenCache {
|
|
|
15811
15918
|
* @param tenantId
|
|
15812
15919
|
* @returns `AccessTokenEntity`
|
|
15813
15920
|
*/
|
|
15814
|
-
loadAccessToken(request, response, homeAccountId, environment, tenantId, options) {
|
|
15921
|
+
loadAccessToken(request, response, homeAccountId, environment, tenantId, options, correlationId) {
|
|
15815
15922
|
if (!response.access_token) {
|
|
15816
15923
|
this.logger.verbose("TokenCache - no access token found in response");
|
|
15817
15924
|
return null;
|
|
@@ -15835,7 +15942,7 @@ class TokenCache {
|
|
|
15835
15942
|
(response.ext_expires_in || response.expires_in) +
|
|
15836
15943
|
new Date().getTime() / 1000;
|
|
15837
15944
|
const accessTokenEntity = createAccessTokenEntity(homeAccountId, environment, response.access_token, this.config.auth.clientId, tenantId, scopes.printScopes(), expiresOn, extendedExpiresOn, base64Decode);
|
|
15838
|
-
this.storage.setAccessTokenCredential(accessTokenEntity);
|
|
15945
|
+
this.storage.setAccessTokenCredential(accessTokenEntity, correlationId);
|
|
15839
15946
|
return accessTokenEntity;
|
|
15840
15947
|
}
|
|
15841
15948
|
/**
|
|
@@ -15846,7 +15953,7 @@ class TokenCache {
|
|
|
15846
15953
|
* @param environment
|
|
15847
15954
|
* @returns `RefreshTokenEntity`
|
|
15848
15955
|
*/
|
|
15849
|
-
loadRefreshToken(response, homeAccountId, environment) {
|
|
15956
|
+
loadRefreshToken(response, homeAccountId, environment, correlationId) {
|
|
15850
15957
|
if (!response.refresh_token) {
|
|
15851
15958
|
this.logger.verbose("TokenCache - no refresh token found in response");
|
|
15852
15959
|
return null;
|
|
@@ -15854,7 +15961,7 @@ class TokenCache {
|
|
|
15854
15961
|
this.logger.verbose("TokenCache - loading refresh token");
|
|
15855
15962
|
const refreshTokenEntity = createRefreshTokenEntity(homeAccountId, environment, response.refresh_token, this.config.auth.clientId, response.foci, undefined, // userAssertionHash
|
|
15856
15963
|
response.refresh_token_expires_in);
|
|
15857
|
-
this.storage.setRefreshTokenCredential(refreshTokenEntity);
|
|
15964
|
+
this.storage.setRefreshTokenCredential(refreshTokenEntity, correlationId);
|
|
15858
15965
|
return refreshTokenEntity;
|
|
15859
15966
|
}
|
|
15860
15967
|
/**
|
|
@@ -16763,7 +16870,8 @@ class StandardController {
|
|
|
16763
16870
|
* @returns Array of AccountInfo objects in cache
|
|
16764
16871
|
*/
|
|
16765
16872
|
getAllAccounts(accountFilter) {
|
|
16766
|
-
|
|
16873
|
+
const correlationId = this.getRequestCorrelationId();
|
|
16874
|
+
return getAllAccounts(this.logger, this.browserStorage, this.isBrowserEnvironment, correlationId, accountFilter);
|
|
16767
16875
|
}
|
|
16768
16876
|
/**
|
|
16769
16877
|
* Returns the first account found in the cache that matches the account filter passed in.
|
|
@@ -16771,7 +16879,8 @@ class StandardController {
|
|
|
16771
16879
|
* @returns The first account found in the cache matching the provided filter or null if no account could be found.
|
|
16772
16880
|
*/
|
|
16773
16881
|
getAccount(accountFilter) {
|
|
16774
|
-
|
|
16882
|
+
const correlationId = this.getRequestCorrelationId();
|
|
16883
|
+
return getAccount(accountFilter, this.logger, this.browserStorage, correlationId);
|
|
16775
16884
|
}
|
|
16776
16885
|
/**
|
|
16777
16886
|
* Returns the signed in account matching username.
|
|
@@ -16782,7 +16891,8 @@ class StandardController {
|
|
|
16782
16891
|
* @returns The account object stored in MSAL
|
|
16783
16892
|
*/
|
|
16784
16893
|
getAccountByUsername(username) {
|
|
16785
|
-
|
|
16894
|
+
const correlationId = this.getRequestCorrelationId();
|
|
16895
|
+
return getAccountByUsername(username, this.logger, this.browserStorage, correlationId);
|
|
16786
16896
|
}
|
|
16787
16897
|
/**
|
|
16788
16898
|
* Returns the signed in account matching homeAccountId.
|
|
@@ -16792,7 +16902,8 @@ class StandardController {
|
|
|
16792
16902
|
* @returns The account object stored in MSAL
|
|
16793
16903
|
*/
|
|
16794
16904
|
getAccountByHomeId(homeAccountId) {
|
|
16795
|
-
|
|
16905
|
+
const correlationId = this.getRequestCorrelationId();
|
|
16906
|
+
return getAccountByHomeId(homeAccountId, this.logger, this.browserStorage, correlationId);
|
|
16796
16907
|
}
|
|
16797
16908
|
/**
|
|
16798
16909
|
* Returns the signed in account matching localAccountId.
|
|
@@ -16802,20 +16913,23 @@ class StandardController {
|
|
|
16802
16913
|
* @returns The account object stored in MSAL
|
|
16803
16914
|
*/
|
|
16804
16915
|
getAccountByLocalId(localAccountId) {
|
|
16805
|
-
|
|
16916
|
+
const correlationId = this.getRequestCorrelationId();
|
|
16917
|
+
return getAccountByLocalId(localAccountId, this.logger, this.browserStorage, correlationId);
|
|
16806
16918
|
}
|
|
16807
16919
|
/**
|
|
16808
16920
|
* Sets the account to use as the active account. If no account is passed to the acquireToken APIs, then MSAL will use this active account.
|
|
16809
16921
|
* @param account
|
|
16810
16922
|
*/
|
|
16811
16923
|
setActiveAccount(account) {
|
|
16812
|
-
|
|
16924
|
+
const correlationId = this.getRequestCorrelationId();
|
|
16925
|
+
setActiveAccount(account, this.browserStorage, correlationId);
|
|
16813
16926
|
}
|
|
16814
16927
|
/**
|
|
16815
16928
|
* Gets the currently active account
|
|
16816
16929
|
*/
|
|
16817
16930
|
getActiveAccount() {
|
|
16818
|
-
|
|
16931
|
+
const correlationId = this.getRequestCorrelationId();
|
|
16932
|
+
return getActiveAccount(this.browserStorage, correlationId);
|
|
16819
16933
|
}
|
|
16820
16934
|
// #endregion
|
|
16821
16935
|
/**
|
|
@@ -16828,7 +16942,7 @@ class StandardController {
|
|
|
16828
16942
|
this.logger.verbose("hydrateCache called");
|
|
16829
16943
|
// Account gets saved to browser storage regardless of native or not
|
|
16830
16944
|
const accountEntity = AccountEntity.createFromAccountInfo(result.account, result.cloudGraphHostName, result.msGraphHost);
|
|
16831
|
-
this.browserStorage.setAccount(accountEntity);
|
|
16945
|
+
this.browserStorage.setAccount(accountEntity, result.correlationId);
|
|
16832
16946
|
if (result.fromNativeBroker) {
|
|
16833
16947
|
this.logger.verbose("Response was from native broker, storing in-memory");
|
|
16834
16948
|
// Tokens from native broker are stored in-memory
|
|
@@ -17601,7 +17715,7 @@ class NestedAppAuthController {
|
|
|
17601
17715
|
this.performanceClient = this.config.telemetry.client;
|
|
17602
17716
|
// Initialize the crypto class.
|
|
17603
17717
|
this.browserCrypto = operatingContext.isBrowserEnvironment()
|
|
17604
|
-
? new CryptoOps(this.logger, this.performanceClient)
|
|
17718
|
+
? new CryptoOps(this.logger, this.performanceClient, true)
|
|
17605
17719
|
: DEFAULT_CRYPTO_IMPLEMENTATION;
|
|
17606
17720
|
// Initialize the browser storage class.
|
|
17607
17721
|
this.browserStorage = this.operatingContext.isBrowserEnvironment()
|
|
@@ -17612,8 +17726,9 @@ class NestedAppAuthController {
|
|
|
17612
17726
|
// Set the active account if available
|
|
17613
17727
|
const accountContext = this.bridgeProxy.getAccountContext();
|
|
17614
17728
|
if (accountContext) {
|
|
17615
|
-
const
|
|
17616
|
-
|
|
17729
|
+
const correlationId = createNewGuid();
|
|
17730
|
+
const cachedAccount = getAccount(accountContext, this.logger, this.browserStorage, correlationId);
|
|
17731
|
+
setActiveAccount(cachedAccount, this.browserStorage, correlationId);
|
|
17617
17732
|
}
|
|
17618
17733
|
}
|
|
17619
17734
|
/**
|
|
@@ -17666,7 +17781,7 @@ class NestedAppAuthController {
|
|
|
17666
17781
|
};
|
|
17667
17782
|
// cache the tokens in the response
|
|
17668
17783
|
await this.hydrateCache(result, request);
|
|
17669
|
-
this.browserStorage.setActiveAccount(result.account);
|
|
17784
|
+
this.browserStorage.setActiveAccount(result.account, result.correlationId);
|
|
17670
17785
|
this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_SUCCESS, exports.InteractionType.Popup, result);
|
|
17671
17786
|
atPopupMeasurement.add({
|
|
17672
17787
|
accessTokenSize: result.accessToken.length,
|
|
@@ -17716,7 +17831,7 @@ class NestedAppAuthController {
|
|
|
17716
17831
|
const result = this.nestedAppAuthAdapter.fromNaaTokenResponse(naaRequest, response, reqTimestamp);
|
|
17717
17832
|
// cache the tokens in the response
|
|
17718
17833
|
await this.hydrateCache(result, request);
|
|
17719
|
-
this.browserStorage.setActiveAccount(result.account);
|
|
17834
|
+
this.browserStorage.setActiveAccount(result.account, result.correlationId);
|
|
17720
17835
|
this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_SUCCESS, exports.InteractionType.Silent, result);
|
|
17721
17836
|
ssoSilentMeasurement?.add({
|
|
17722
17837
|
accessTokenSize: result.accessToken.length,
|
|
@@ -17787,10 +17902,11 @@ class NestedAppAuthController {
|
|
|
17787
17902
|
* @returns
|
|
17788
17903
|
*/
|
|
17789
17904
|
async acquireTokenFromCacheInternal(request) {
|
|
17905
|
+
const correlationId = request.correlationId || createNewGuid();
|
|
17790
17906
|
const accountContext = this.bridgeProxy.getAccountContext();
|
|
17791
17907
|
let currentAccount = null;
|
|
17792
17908
|
if (accountContext) {
|
|
17793
|
-
const hubAccount = getAccount(accountContext, this.logger, this.browserStorage);
|
|
17909
|
+
const hubAccount = getAccount(accountContext, this.logger, this.browserStorage, correlationId);
|
|
17794
17910
|
// always prioritize for hub account context, the reqirement of `request.account` will be removed soon
|
|
17795
17911
|
currentAccount = hubAccount || request.account;
|
|
17796
17912
|
}
|
|
@@ -17802,7 +17918,7 @@ class NestedAppAuthController {
|
|
|
17802
17918
|
this.logger.verbose("active account found, attempting to acquire token silently");
|
|
17803
17919
|
const authRequest = {
|
|
17804
17920
|
...request,
|
|
17805
|
-
correlationId:
|
|
17921
|
+
correlationId: correlationId,
|
|
17806
17922
|
authority: request.authority || currentAccount.environment,
|
|
17807
17923
|
scopes: request.scopes?.length
|
|
17808
17924
|
? request.scopes
|
|
@@ -17810,7 +17926,7 @@ class NestedAppAuthController {
|
|
|
17810
17926
|
};
|
|
17811
17927
|
// fetch access token and check for expiry
|
|
17812
17928
|
const tokenKeys = this.browserStorage.getTokenKeys();
|
|
17813
|
-
const cachedAccessToken = this.browserStorage.getAccessToken(currentAccount, authRequest, tokenKeys, currentAccount.tenantId, this.performanceClient
|
|
17929
|
+
const cachedAccessToken = this.browserStorage.getAccessToken(currentAccount, authRequest, tokenKeys, currentAccount.tenantId, this.performanceClient);
|
|
17814
17930
|
// If there is no access token, log it and return null
|
|
17815
17931
|
if (!cachedAccessToken) {
|
|
17816
17932
|
this.logger.verbose("No cached access token found");
|
|
@@ -17821,7 +17937,7 @@ class NestedAppAuthController {
|
|
|
17821
17937
|
this.logger.verbose("Cached access token has expired");
|
|
17822
17938
|
return Promise.resolve(null);
|
|
17823
17939
|
}
|
|
17824
|
-
const cachedIdToken = this.browserStorage.getIdToken(currentAccount, tokenKeys, currentAccount.tenantId, this.performanceClient
|
|
17940
|
+
const cachedIdToken = this.browserStorage.getIdToken(currentAccount, authRequest.correlationId, tokenKeys, currentAccount.tenantId, this.performanceClient);
|
|
17825
17941
|
if (!cachedIdToken) {
|
|
17826
17942
|
this.logger.verbose("No cached id token found");
|
|
17827
17943
|
return Promise.resolve(null);
|
|
@@ -17918,7 +18034,8 @@ class NestedAppAuthController {
|
|
|
17918
18034
|
* @returns Array of AccountInfo objects in cache
|
|
17919
18035
|
*/
|
|
17920
18036
|
getAllAccounts(accountFilter) {
|
|
17921
|
-
|
|
18037
|
+
const correlationId = createNewGuid();
|
|
18038
|
+
return getAllAccounts(this.logger, this.browserStorage, this.isBrowserEnv(), correlationId, accountFilter);
|
|
17922
18039
|
}
|
|
17923
18040
|
/**
|
|
17924
18041
|
* Returns the first account found in the cache that matches the account filter passed in.
|
|
@@ -17926,7 +18043,8 @@ class NestedAppAuthController {
|
|
|
17926
18043
|
* @returns The first account found in the cache matching the provided filter or null if no account could be found.
|
|
17927
18044
|
*/
|
|
17928
18045
|
getAccount(accountFilter) {
|
|
17929
|
-
|
|
18046
|
+
const correlationId = createNewGuid();
|
|
18047
|
+
return getAccount(accountFilter, this.logger, this.browserStorage, correlationId);
|
|
17930
18048
|
}
|
|
17931
18049
|
/**
|
|
17932
18050
|
* Returns the signed in account matching username.
|
|
@@ -17937,7 +18055,8 @@ class NestedAppAuthController {
|
|
|
17937
18055
|
* @returns The account object stored in MSAL
|
|
17938
18056
|
*/
|
|
17939
18057
|
getAccountByUsername(username) {
|
|
17940
|
-
|
|
18058
|
+
const correlationId = createNewGuid();
|
|
18059
|
+
return getAccountByUsername(username, this.logger, this.browserStorage, correlationId);
|
|
17941
18060
|
}
|
|
17942
18061
|
/**
|
|
17943
18062
|
* Returns the signed in account matching homeAccountId.
|
|
@@ -17947,7 +18066,8 @@ class NestedAppAuthController {
|
|
|
17947
18066
|
* @returns The account object stored in MSAL
|
|
17948
18067
|
*/
|
|
17949
18068
|
getAccountByHomeId(homeAccountId) {
|
|
17950
|
-
|
|
18069
|
+
const correlationId = createNewGuid();
|
|
18070
|
+
return getAccountByHomeId(homeAccountId, this.logger, this.browserStorage, correlationId);
|
|
17951
18071
|
}
|
|
17952
18072
|
/**
|
|
17953
18073
|
* Returns the signed in account matching localAccountId.
|
|
@@ -17957,7 +18077,8 @@ class NestedAppAuthController {
|
|
|
17957
18077
|
* @returns The account object stored in MSAL
|
|
17958
18078
|
*/
|
|
17959
18079
|
getAccountByLocalId(localAccountId) {
|
|
17960
|
-
|
|
18080
|
+
const correlationId = createNewGuid();
|
|
18081
|
+
return getAccountByLocalId(localAccountId, this.logger, this.browserStorage, correlationId);
|
|
17961
18082
|
}
|
|
17962
18083
|
/**
|
|
17963
18084
|
* Sets the account to use as the active account. If no account is passed to the acquireToken APIs, then MSAL will use this active account.
|
|
@@ -17968,13 +18089,15 @@ class NestedAppAuthController {
|
|
|
17968
18089
|
* StandardController uses this to allow the developer to set the active account
|
|
17969
18090
|
* in the nested app auth scenario the active account is controlled by the app hosting the nested app
|
|
17970
18091
|
*/
|
|
17971
|
-
|
|
18092
|
+
const correlationId = createNewGuid();
|
|
18093
|
+
return setActiveAccount(account, this.browserStorage, correlationId);
|
|
17972
18094
|
}
|
|
17973
18095
|
/**
|
|
17974
18096
|
* Gets the currently active account
|
|
17975
18097
|
*/
|
|
17976
18098
|
getActiveAccount() {
|
|
17977
|
-
|
|
18099
|
+
const correlationId = createNewGuid();
|
|
18100
|
+
return getActiveAccount(this.browserStorage, correlationId);
|
|
17978
18101
|
}
|
|
17979
18102
|
// #endregion
|
|
17980
18103
|
handleRedirectPromise(hash // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
@@ -18056,7 +18179,7 @@ class NestedAppAuthController {
|
|
|
18056
18179
|
async hydrateCache(result, request) {
|
|
18057
18180
|
this.logger.verbose("hydrateCache called");
|
|
18058
18181
|
const accountEntity = AccountEntity.createFromAccountInfo(result.account, result.cloudGraphHostName, result.msGraphHost);
|
|
18059
|
-
this.browserStorage.setAccount(accountEntity);
|
|
18182
|
+
this.browserStorage.setAccount(accountEntity, result.correlationId);
|
|
18060
18183
|
return this.browserStorage.hydrateCache(result, request);
|
|
18061
18184
|
}
|
|
18062
18185
|
}
|