@azure/msal-browser 3.28.1 → 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 +28 -18
- 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.mjs +1 -1
- package/dist/crypto/CryptoOps.mjs +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.mjs +1 -1
- package/lib/msal-browser.cjs +464 -343
- package/lib/msal-browser.cjs.map +1 -1
- package/lib/msal-browser.js +464 -343
- 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/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/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 +51 -18
- package/src/controllers/StandardController.ts +26 -7
- 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/lib/msal-browser.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @azure/msal-browser v3.
|
|
1
|
+
/*! @azure/msal-browser v3.30.0 2025-08-05 */
|
|
2
2
|
'use strict';
|
|
3
3
|
(function (global, factory) {
|
|
4
4
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.msal = {}));
|
|
7
7
|
})(this, (function (exports) { 'use strict';
|
|
8
8
|
|
|
9
|
-
/*! @azure/msal-common v14.16.
|
|
9
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
10
10
|
/*
|
|
11
11
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
12
12
|
* Licensed under the MIT License.
|
|
@@ -316,7 +316,7 @@
|
|
|
316
316
|
// Token renewal offset default in seconds
|
|
317
317
|
const DEFAULT_TOKEN_RENEWAL_OFFSET_SEC = 300;
|
|
318
318
|
|
|
319
|
-
/*! @azure/msal-common v14.16.
|
|
319
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
320
320
|
/*
|
|
321
321
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
322
322
|
* Licensed under the MIT License.
|
|
@@ -333,7 +333,7 @@
|
|
|
333
333
|
unexpectedError: unexpectedError
|
|
334
334
|
});
|
|
335
335
|
|
|
336
|
-
/*! @azure/msal-common v14.16.
|
|
336
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
337
337
|
|
|
338
338
|
/*
|
|
339
339
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -382,7 +382,7 @@
|
|
|
382
382
|
: AuthErrorMessages[code]);
|
|
383
383
|
}
|
|
384
384
|
|
|
385
|
-
/*! @azure/msal-common v14.16.
|
|
385
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
386
386
|
/*
|
|
387
387
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
388
388
|
* Licensed under the MIT License.
|
|
@@ -480,7 +480,7 @@
|
|
|
480
480
|
userTimeoutReached: userTimeoutReached
|
|
481
481
|
});
|
|
482
482
|
|
|
483
|
-
/*! @azure/msal-common v14.16.
|
|
483
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
484
484
|
|
|
485
485
|
/*
|
|
486
486
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -732,7 +732,7 @@
|
|
|
732
732
|
return new ClientAuthError(errorCode, additionalMessage);
|
|
733
733
|
}
|
|
734
734
|
|
|
735
|
-
/*! @azure/msal-common v14.16.
|
|
735
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
736
736
|
|
|
737
737
|
/*
|
|
738
738
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -771,7 +771,7 @@
|
|
|
771
771
|
},
|
|
772
772
|
};
|
|
773
773
|
|
|
774
|
-
/*! @azure/msal-common v14.16.
|
|
774
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
775
775
|
|
|
776
776
|
/*
|
|
777
777
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -962,12 +962,12 @@
|
|
|
962
962
|
}
|
|
963
963
|
}
|
|
964
964
|
|
|
965
|
-
/*! @azure/msal-common v14.16.
|
|
965
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
966
966
|
/* eslint-disable header/header */
|
|
967
967
|
const name$1 = "@azure/msal-common";
|
|
968
|
-
const version$1 = "14.16.
|
|
968
|
+
const version$1 = "14.16.1";
|
|
969
969
|
|
|
970
|
-
/*! @azure/msal-common v14.16.
|
|
970
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
971
971
|
/*
|
|
972
972
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
973
973
|
* Licensed under the MIT License.
|
|
@@ -987,7 +987,7 @@
|
|
|
987
987
|
AzureUsGovernment: "https://login.microsoftonline.us",
|
|
988
988
|
};
|
|
989
989
|
|
|
990
|
-
/*! @azure/msal-common v14.16.
|
|
990
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
991
991
|
|
|
992
992
|
/*
|
|
993
993
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1048,7 +1048,7 @@
|
|
|
1048
1048
|
}
|
|
1049
1049
|
}
|
|
1050
1050
|
|
|
1051
|
-
/*! @azure/msal-common v14.16.
|
|
1051
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
1052
1052
|
/*
|
|
1053
1053
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1054
1054
|
* Licensed under the MIT License.
|
|
@@ -1085,7 +1085,7 @@
|
|
|
1085
1085
|
return cachedAtSec > nowSeconds();
|
|
1086
1086
|
}
|
|
1087
1087
|
|
|
1088
|
-
/*! @azure/msal-common v14.16.
|
|
1088
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
1089
1089
|
|
|
1090
1090
|
/*
|
|
1091
1091
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1412,7 +1412,7 @@
|
|
|
1412
1412
|
return metadata.expiresAt <= nowSeconds();
|
|
1413
1413
|
}
|
|
1414
1414
|
|
|
1415
|
-
/*! @azure/msal-common v14.16.
|
|
1415
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
1416
1416
|
/*
|
|
1417
1417
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1418
1418
|
* Licensed under the MIT License.
|
|
@@ -1466,7 +1466,7 @@
|
|
|
1466
1466
|
urlParseError: urlParseError
|
|
1467
1467
|
});
|
|
1468
1468
|
|
|
1469
|
-
/*! @azure/msal-common v14.16.
|
|
1469
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
1470
1470
|
|
|
1471
1471
|
/*
|
|
1472
1472
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1604,7 +1604,7 @@
|
|
|
1604
1604
|
return new ClientConfigurationError(errorCode);
|
|
1605
1605
|
}
|
|
1606
1606
|
|
|
1607
|
-
/*! @azure/msal-common v14.16.
|
|
1607
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
1608
1608
|
/*
|
|
1609
1609
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1610
1610
|
* Licensed under the MIT License.
|
|
@@ -1701,7 +1701,7 @@
|
|
|
1701
1701
|
}
|
|
1702
1702
|
}
|
|
1703
1703
|
|
|
1704
|
-
/*! @azure/msal-common v14.16.
|
|
1704
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
1705
1705
|
|
|
1706
1706
|
/*
|
|
1707
1707
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1901,7 +1901,7 @@
|
|
|
1901
1901
|
}
|
|
1902
1902
|
}
|
|
1903
1903
|
|
|
1904
|
-
/*! @azure/msal-common v14.16.
|
|
1904
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
1905
1905
|
|
|
1906
1906
|
/*
|
|
1907
1907
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1941,7 +1941,7 @@
|
|
|
1941
1941
|
};
|
|
1942
1942
|
}
|
|
1943
1943
|
|
|
1944
|
-
/*! @azure/msal-common v14.16.
|
|
1944
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
1945
1945
|
/*
|
|
1946
1946
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1947
1947
|
* Licensed under the MIT License.
|
|
@@ -2020,7 +2020,7 @@
|
|
|
2020
2020
|
return updatedAccountInfo;
|
|
2021
2021
|
}
|
|
2022
2022
|
|
|
2023
|
-
/*! @azure/msal-common v14.16.
|
|
2023
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
2024
2024
|
/*
|
|
2025
2025
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2026
2026
|
* Licensed under the MIT License.
|
|
@@ -2035,7 +2035,7 @@
|
|
|
2035
2035
|
Ciam: 3,
|
|
2036
2036
|
};
|
|
2037
2037
|
|
|
2038
|
-
/*! @azure/msal-common v14.16.
|
|
2038
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
2039
2039
|
/*
|
|
2040
2040
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2041
2041
|
* Licensed under the MIT License.
|
|
@@ -2057,7 +2057,7 @@
|
|
|
2057
2057
|
return null;
|
|
2058
2058
|
}
|
|
2059
2059
|
|
|
2060
|
-
/*! @azure/msal-common v14.16.
|
|
2060
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
2061
2061
|
/*
|
|
2062
2062
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2063
2063
|
* Licensed under the MIT License.
|
|
@@ -2070,7 +2070,7 @@
|
|
|
2070
2070
|
OIDC: "OIDC",
|
|
2071
2071
|
};
|
|
2072
2072
|
|
|
2073
|
-
/*! @azure/msal-common v14.16.
|
|
2073
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
2074
2074
|
|
|
2075
2075
|
/*
|
|
2076
2076
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2313,7 +2313,7 @@
|
|
|
2313
2313
|
}
|
|
2314
2314
|
}
|
|
2315
2315
|
|
|
2316
|
-
/*! @azure/msal-common v14.16.
|
|
2316
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
2317
2317
|
|
|
2318
2318
|
/*
|
|
2319
2319
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2360,7 +2360,7 @@
|
|
|
2360
2360
|
return null;
|
|
2361
2361
|
}
|
|
2362
2362
|
|
|
2363
|
-
/*! @azure/msal-common v14.16.
|
|
2363
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
2364
2364
|
|
|
2365
2365
|
/*
|
|
2366
2366
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2524,7 +2524,7 @@
|
|
|
2524
2524
|
}
|
|
2525
2525
|
}
|
|
2526
2526
|
|
|
2527
|
-
/*! @azure/msal-common v14.16.
|
|
2527
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
2528
2528
|
|
|
2529
2529
|
/*
|
|
2530
2530
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2664,23 +2664,23 @@
|
|
|
2664
2664
|
return null;
|
|
2665
2665
|
}
|
|
2666
2666
|
|
|
2667
|
-
/*! @azure/msal-common v14.16.
|
|
2667
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
2668
2668
|
/*
|
|
2669
2669
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2670
2670
|
* Licensed under the MIT License.
|
|
2671
2671
|
*/
|
|
2672
|
-
const
|
|
2673
|
-
const
|
|
2672
|
+
const cacheQuotaExceeded = "cache_quota_exceeded";
|
|
2673
|
+
const cacheErrorUnknown = "cache_error_unknown";
|
|
2674
2674
|
|
|
2675
|
-
/*! @azure/msal-common v14.16.
|
|
2675
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
2676
2676
|
|
|
2677
2677
|
/*
|
|
2678
2678
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2679
2679
|
* Licensed under the MIT License.
|
|
2680
2680
|
*/
|
|
2681
2681
|
const CacheErrorMessages = {
|
|
2682
|
-
[
|
|
2683
|
-
[
|
|
2682
|
+
[cacheQuotaExceeded]: "Exceeded cache storage capacity.",
|
|
2683
|
+
[cacheErrorUnknown]: "Unexpected error occurred when using cache storage.",
|
|
2684
2684
|
};
|
|
2685
2685
|
/**
|
|
2686
2686
|
* Error thrown when there is an error with the cache
|
|
@@ -2690,16 +2690,34 @@
|
|
|
2690
2690
|
const message = errorMessage ||
|
|
2691
2691
|
(CacheErrorMessages[errorCode]
|
|
2692
2692
|
? CacheErrorMessages[errorCode]
|
|
2693
|
-
: CacheErrorMessages[
|
|
2693
|
+
: CacheErrorMessages[cacheErrorUnknown]);
|
|
2694
2694
|
super(`${errorCode}: ${message}`);
|
|
2695
2695
|
Object.setPrototypeOf(this, CacheError.prototype);
|
|
2696
2696
|
this.name = "CacheError";
|
|
2697
2697
|
this.errorCode = errorCode;
|
|
2698
2698
|
this.errorMessage = message;
|
|
2699
2699
|
}
|
|
2700
|
+
}
|
|
2701
|
+
/**
|
|
2702
|
+
* Helper function to wrap browser errors in a CacheError object
|
|
2703
|
+
* @param e
|
|
2704
|
+
* @returns
|
|
2705
|
+
*/
|
|
2706
|
+
function createCacheError(e) {
|
|
2707
|
+
if (!(e instanceof Error)) {
|
|
2708
|
+
return new CacheError(cacheErrorUnknown);
|
|
2709
|
+
}
|
|
2710
|
+
if (e.name === "QuotaExceededError" ||
|
|
2711
|
+
e.name === "NS_ERROR_DOM_QUOTA_REACHED" ||
|
|
2712
|
+
e.message.includes("exceeded the quota")) {
|
|
2713
|
+
return new CacheError(cacheQuotaExceeded);
|
|
2714
|
+
}
|
|
2715
|
+
else {
|
|
2716
|
+
return new CacheError(e.name, e.message);
|
|
2717
|
+
}
|
|
2700
2718
|
}
|
|
2701
2719
|
|
|
2702
|
-
/*! @azure/msal-common v14.16.
|
|
2720
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
2703
2721
|
|
|
2704
2722
|
/*
|
|
2705
2723
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2721,14 +2739,14 @@
|
|
|
2721
2739
|
* @param accountFilter - (Optional) filter to narrow down the accounts returned
|
|
2722
2740
|
* @returns Array of AccountInfo objects in cache
|
|
2723
2741
|
*/
|
|
2724
|
-
getAllAccounts(accountFilter) {
|
|
2725
|
-
return this.buildTenantProfiles(this.getAccountsFilteredBy(accountFilter || {}), accountFilter);
|
|
2742
|
+
getAllAccounts(correlationId, accountFilter) {
|
|
2743
|
+
return this.buildTenantProfiles(this.getAccountsFilteredBy(accountFilter || {}, correlationId), correlationId, accountFilter);
|
|
2726
2744
|
}
|
|
2727
2745
|
/**
|
|
2728
2746
|
* Gets first tenanted AccountInfo object found based on provided filters
|
|
2729
2747
|
*/
|
|
2730
|
-
getAccountInfoFilteredBy(accountFilter) {
|
|
2731
|
-
const allAccounts = this.getAllAccounts(accountFilter);
|
|
2748
|
+
getAccountInfoFilteredBy(accountFilter, correlationId) {
|
|
2749
|
+
const allAccounts = this.getAllAccounts(correlationId, accountFilter);
|
|
2732
2750
|
if (allAccounts.length > 1) {
|
|
2733
2751
|
// If one or more accounts are found, prioritize accounts that have an ID token
|
|
2734
2752
|
const sortedAccounts = allAccounts.sort((account) => {
|
|
@@ -2749,8 +2767,8 @@
|
|
|
2749
2767
|
* @param accountFilter
|
|
2750
2768
|
* @returns
|
|
2751
2769
|
*/
|
|
2752
|
-
getBaseAccountInfo(accountFilter) {
|
|
2753
|
-
const accountEntities = this.getAccountsFilteredBy(accountFilter);
|
|
2770
|
+
getBaseAccountInfo(accountFilter, correlationId) {
|
|
2771
|
+
const accountEntities = this.getAccountsFilteredBy(accountFilter, correlationId);
|
|
2754
2772
|
if (accountEntities.length > 0) {
|
|
2755
2773
|
return accountEntities[0].getAccountInfo();
|
|
2756
2774
|
}
|
|
@@ -2765,12 +2783,12 @@
|
|
|
2765
2783
|
* @param accountFilter
|
|
2766
2784
|
* @returns Array of AccountInfo objects that match account and tenant profile filters
|
|
2767
2785
|
*/
|
|
2768
|
-
buildTenantProfiles(cachedAccounts, accountFilter) {
|
|
2786
|
+
buildTenantProfiles(cachedAccounts, correlationId, accountFilter) {
|
|
2769
2787
|
return cachedAccounts.flatMap((accountEntity) => {
|
|
2770
|
-
return this.getTenantProfilesFromAccountEntity(accountEntity, accountFilter?.tenantId, accountFilter);
|
|
2788
|
+
return this.getTenantProfilesFromAccountEntity(accountEntity, correlationId, accountFilter?.tenantId, accountFilter);
|
|
2771
2789
|
});
|
|
2772
2790
|
}
|
|
2773
|
-
getTenantedAccountInfoByFilter(accountInfo, tokenKeys, tenantProfile, tenantProfileFilter) {
|
|
2791
|
+
getTenantedAccountInfoByFilter(accountInfo, tokenKeys, tenantProfile, correlationId, tenantProfileFilter) {
|
|
2774
2792
|
let tenantedAccountInfo = null;
|
|
2775
2793
|
let idTokenClaims;
|
|
2776
2794
|
if (tenantProfileFilter) {
|
|
@@ -2778,7 +2796,7 @@
|
|
|
2778
2796
|
return null;
|
|
2779
2797
|
}
|
|
2780
2798
|
}
|
|
2781
|
-
const idToken = this.getIdToken(accountInfo, tokenKeys, tenantProfile.tenantId);
|
|
2799
|
+
const idToken = this.getIdToken(accountInfo, correlationId, tokenKeys, tenantProfile.tenantId);
|
|
2782
2800
|
if (idToken) {
|
|
2783
2801
|
idTokenClaims = extractTokenClaims(idToken.secret, this.cryptoImpl.base64Decode);
|
|
2784
2802
|
if (!this.idTokenClaimsMatchTenantProfileFilter(idTokenClaims, tenantProfileFilter)) {
|
|
@@ -2790,7 +2808,7 @@
|
|
|
2790
2808
|
tenantedAccountInfo = updateAccountTenantProfileData(accountInfo, tenantProfile, idTokenClaims, idToken?.secret);
|
|
2791
2809
|
return tenantedAccountInfo;
|
|
2792
2810
|
}
|
|
2793
|
-
getTenantProfilesFromAccountEntity(accountEntity, targetTenantId, tenantProfileFilter) {
|
|
2811
|
+
getTenantProfilesFromAccountEntity(accountEntity, correlationId, targetTenantId, tenantProfileFilter) {
|
|
2794
2812
|
const accountInfo = accountEntity.getAccountInfo();
|
|
2795
2813
|
let searchTenantProfiles = accountInfo.tenantProfiles || new Map();
|
|
2796
2814
|
const tokenKeys = this.getTokenKeys();
|
|
@@ -2810,7 +2828,7 @@
|
|
|
2810
2828
|
}
|
|
2811
2829
|
const matchingTenantProfiles = [];
|
|
2812
2830
|
searchTenantProfiles.forEach((tenantProfile) => {
|
|
2813
|
-
const tenantedAccountInfo = this.getTenantedAccountInfoByFilter(accountInfo, tokenKeys, tenantProfile, tenantProfileFilter);
|
|
2831
|
+
const tenantedAccountInfo = this.getTenantedAccountInfoByFilter(accountInfo, tokenKeys, tenantProfile, correlationId, tenantProfileFilter);
|
|
2814
2832
|
if (tenantedAccountInfo) {
|
|
2815
2833
|
matchingTenantProfiles.push(tenantedAccountInfo);
|
|
2816
2834
|
}
|
|
@@ -2864,46 +2882,36 @@
|
|
|
2864
2882
|
* @param storeInCache {?StoreInCache}
|
|
2865
2883
|
* @param correlationId {?string} correlation id
|
|
2866
2884
|
*/
|
|
2867
|
-
async saveCacheRecord(cacheRecord,
|
|
2885
|
+
async saveCacheRecord(cacheRecord, correlationId, storeInCache) {
|
|
2868
2886
|
if (!cacheRecord) {
|
|
2869
2887
|
throw createClientAuthError(invalidCacheRecord);
|
|
2870
2888
|
}
|
|
2871
2889
|
try {
|
|
2872
2890
|
if (!!cacheRecord.account) {
|
|
2873
|
-
this.setAccount(cacheRecord.account);
|
|
2891
|
+
this.setAccount(cacheRecord.account, correlationId);
|
|
2874
2892
|
}
|
|
2875
2893
|
if (!!cacheRecord.idToken && storeInCache?.idToken !== false) {
|
|
2876
|
-
this.setIdTokenCredential(cacheRecord.idToken);
|
|
2894
|
+
this.setIdTokenCredential(cacheRecord.idToken, correlationId);
|
|
2877
2895
|
}
|
|
2878
2896
|
if (!!cacheRecord.accessToken &&
|
|
2879
2897
|
storeInCache?.accessToken !== false) {
|
|
2880
|
-
await this.saveAccessToken(cacheRecord.accessToken);
|
|
2898
|
+
await this.saveAccessToken(cacheRecord.accessToken, correlationId);
|
|
2881
2899
|
}
|
|
2882
2900
|
if (!!cacheRecord.refreshToken &&
|
|
2883
2901
|
storeInCache?.refreshToken !== false) {
|
|
2884
|
-
this.setRefreshTokenCredential(cacheRecord.refreshToken);
|
|
2902
|
+
this.setRefreshTokenCredential(cacheRecord.refreshToken, correlationId);
|
|
2885
2903
|
}
|
|
2886
2904
|
if (!!cacheRecord.appMetadata) {
|
|
2887
|
-
this.setAppMetadata(cacheRecord.appMetadata);
|
|
2905
|
+
this.setAppMetadata(cacheRecord.appMetadata, correlationId);
|
|
2888
2906
|
}
|
|
2889
2907
|
}
|
|
2890
2908
|
catch (e) {
|
|
2891
2909
|
this.commonLogger?.error(`CacheManager.saveCacheRecord: failed`);
|
|
2892
|
-
if (e instanceof
|
|
2893
|
-
|
|
2894
|
-
if (e.name === "QuotaExceededError" ||
|
|
2895
|
-
e.name === "NS_ERROR_DOM_QUOTA_REACHED" ||
|
|
2896
|
-
e.message.includes("exceeded the quota")) {
|
|
2897
|
-
this.commonLogger?.error(`CacheManager.saveCacheRecord: exceeded storage quota`, correlationId);
|
|
2898
|
-
throw new CacheError(cacheQuotaExceededErrorCode);
|
|
2899
|
-
}
|
|
2900
|
-
else {
|
|
2901
|
-
throw new CacheError(e.name, e.message);
|
|
2902
|
-
}
|
|
2910
|
+
if (e instanceof AuthError) {
|
|
2911
|
+
throw e;
|
|
2903
2912
|
}
|
|
2904
2913
|
else {
|
|
2905
|
-
|
|
2906
|
-
throw new CacheError(cacheUnknownErrorCode);
|
|
2914
|
+
throw createCacheError(e);
|
|
2907
2915
|
}
|
|
2908
2916
|
}
|
|
2909
2917
|
}
|
|
@@ -2911,7 +2919,7 @@
|
|
|
2911
2919
|
* saves access token credential
|
|
2912
2920
|
* @param credential
|
|
2913
2921
|
*/
|
|
2914
|
-
async saveAccessToken(credential) {
|
|
2922
|
+
async saveAccessToken(credential, correlationId) {
|
|
2915
2923
|
const accessTokenFilter = {
|
|
2916
2924
|
clientId: credential.clientId,
|
|
2917
2925
|
credentialType: credential.credentialType,
|
|
@@ -2923,29 +2931,27 @@
|
|
|
2923
2931
|
};
|
|
2924
2932
|
const tokenKeys = this.getTokenKeys();
|
|
2925
2933
|
const currentScopes = ScopeSet.fromString(credential.target);
|
|
2926
|
-
const removedAccessTokens = [];
|
|
2927
2934
|
tokenKeys.accessToken.forEach((key) => {
|
|
2928
2935
|
if (!this.accessTokenKeyMatchesFilter(key, accessTokenFilter, false)) {
|
|
2929
2936
|
return;
|
|
2930
2937
|
}
|
|
2931
|
-
const tokenEntity = this.getAccessTokenCredential(key);
|
|
2938
|
+
const tokenEntity = this.getAccessTokenCredential(key, correlationId);
|
|
2932
2939
|
if (tokenEntity &&
|
|
2933
2940
|
this.credentialMatchesFilter(tokenEntity, accessTokenFilter)) {
|
|
2934
2941
|
const tokenScopeSet = ScopeSet.fromString(tokenEntity.target);
|
|
2935
2942
|
if (tokenScopeSet.intersectingScopeSets(currentScopes)) {
|
|
2936
|
-
|
|
2943
|
+
this.removeAccessToken(key, correlationId);
|
|
2937
2944
|
}
|
|
2938
2945
|
}
|
|
2939
2946
|
});
|
|
2940
|
-
|
|
2941
|
-
this.setAccessTokenCredential(credential);
|
|
2947
|
+
this.setAccessTokenCredential(credential, correlationId);
|
|
2942
2948
|
}
|
|
2943
2949
|
/**
|
|
2944
2950
|
* Retrieve account entities matching all provided tenant-agnostic filters; if no filter is set, get all account entities in the cache
|
|
2945
2951
|
* Not checking for casing as keys are all generated in lower case, remember to convert to lower case if object properties are compared
|
|
2946
2952
|
* @param accountFilter - An object containing Account properties to filter by
|
|
2947
2953
|
*/
|
|
2948
|
-
getAccountsFilteredBy(accountFilter) {
|
|
2954
|
+
getAccountsFilteredBy(accountFilter, correlationId) {
|
|
2949
2955
|
const allAccountKeys = this.getAccountKeys();
|
|
2950
2956
|
const matchingAccounts = [];
|
|
2951
2957
|
allAccountKeys.forEach((cacheKey) => {
|
|
@@ -2953,7 +2959,7 @@
|
|
|
2953
2959
|
// Don't parse value if the key doesn't match the account filters
|
|
2954
2960
|
return;
|
|
2955
2961
|
}
|
|
2956
|
-
const entity = this.getAccount(cacheKey, this.commonLogger);
|
|
2962
|
+
const entity = this.getAccount(cacheKey, correlationId, this.commonLogger);
|
|
2957
2963
|
// Match base account fields
|
|
2958
2964
|
if (!entity) {
|
|
2959
2965
|
return;
|
|
@@ -3179,11 +3185,11 @@
|
|
|
3179
3185
|
/**
|
|
3180
3186
|
* Removes all accounts and related tokens from cache.
|
|
3181
3187
|
*/
|
|
3182
|
-
async removeAllAccounts() {
|
|
3188
|
+
async removeAllAccounts(correlationId) {
|
|
3183
3189
|
const allAccountKeys = this.getAccountKeys();
|
|
3184
3190
|
const removedAccounts = [];
|
|
3185
3191
|
allAccountKeys.forEach((cacheKey) => {
|
|
3186
|
-
removedAccounts.push(this.removeAccount(cacheKey));
|
|
3192
|
+
removedAccounts.push(this.removeAccount(cacheKey, correlationId));
|
|
3187
3193
|
});
|
|
3188
3194
|
await Promise.all(removedAccounts);
|
|
3189
3195
|
}
|
|
@@ -3191,38 +3197,41 @@
|
|
|
3191
3197
|
* Removes the account and related tokens for a given account key
|
|
3192
3198
|
* @param account
|
|
3193
3199
|
*/
|
|
3194
|
-
async removeAccount(accountKey) {
|
|
3195
|
-
const account = this.getAccount(accountKey, this.commonLogger);
|
|
3200
|
+
async removeAccount(accountKey, correlationId) {
|
|
3201
|
+
const account = this.getAccount(accountKey, correlationId, this.commonLogger);
|
|
3196
3202
|
if (!account) {
|
|
3197
3203
|
return;
|
|
3198
3204
|
}
|
|
3199
|
-
await this.removeAccountContext(account);
|
|
3200
|
-
this.removeItem(accountKey);
|
|
3205
|
+
await this.removeAccountContext(account, correlationId);
|
|
3206
|
+
this.removeItem(accountKey, correlationId);
|
|
3201
3207
|
}
|
|
3202
3208
|
/**
|
|
3203
3209
|
* Removes credentials associated with the provided account
|
|
3204
3210
|
* @param account
|
|
3205
3211
|
*/
|
|
3206
|
-
async removeAccountContext(account) {
|
|
3212
|
+
async removeAccountContext(account, correlationId) {
|
|
3207
3213
|
const allTokenKeys = this.getTokenKeys();
|
|
3208
3214
|
const accountId = account.generateAccountId();
|
|
3209
|
-
const removedCredentials = [];
|
|
3210
3215
|
allTokenKeys.idToken.forEach((key) => {
|
|
3211
3216
|
if (key.indexOf(accountId) === 0) {
|
|
3212
|
-
this.removeIdToken(key);
|
|
3217
|
+
this.removeIdToken(key, correlationId);
|
|
3213
3218
|
}
|
|
3214
3219
|
});
|
|
3215
3220
|
allTokenKeys.accessToken.forEach((key) => {
|
|
3216
3221
|
if (key.indexOf(accountId) === 0) {
|
|
3217
|
-
|
|
3222
|
+
this.removeAccessToken(key, correlationId);
|
|
3218
3223
|
}
|
|
3219
3224
|
});
|
|
3220
3225
|
allTokenKeys.refreshToken.forEach((key) => {
|
|
3221
3226
|
if (key.indexOf(accountId) === 0) {
|
|
3222
|
-
this.removeRefreshToken(key);
|
|
3227
|
+
this.removeRefreshToken(key, correlationId);
|
|
3228
|
+
}
|
|
3229
|
+
});
|
|
3230
|
+
this.getKeys().forEach((key) => {
|
|
3231
|
+
if (key.includes(accountId)) {
|
|
3232
|
+
this.removeItem(key, correlationId);
|
|
3223
3233
|
}
|
|
3224
3234
|
});
|
|
3225
|
-
await Promise.all(removedCredentials);
|
|
3226
3235
|
}
|
|
3227
3236
|
/**
|
|
3228
3237
|
* Migrates a single-tenant account and all it's associated alternate cross-tenant account objects in the
|
|
@@ -3232,7 +3241,7 @@
|
|
|
3232
3241
|
* @param logger
|
|
3233
3242
|
* @returns
|
|
3234
3243
|
*/
|
|
3235
|
-
updateOutdatedCachedAccount(accountKey, accountEntity, logger) {
|
|
3244
|
+
updateOutdatedCachedAccount(accountKey, accountEntity, correlationId, logger) {
|
|
3236
3245
|
// Only update if account entity is defined and has no tenantProfiles object (is outdated)
|
|
3237
3246
|
if (accountEntity && accountEntity.isSingleTenant()) {
|
|
3238
3247
|
this.commonLogger?.verbose("updateOutdatedCachedAccount: Found a single-tenant (outdated) account entity in the cache, migrating to multi-tenant account entity");
|
|
@@ -3243,7 +3252,7 @@
|
|
|
3243
3252
|
// Get all account entities belonging to user
|
|
3244
3253
|
const accountsToMerge = [];
|
|
3245
3254
|
matchingAccountKeys.forEach((key) => {
|
|
3246
|
-
const account = this.getCachedAccountEntity(key);
|
|
3255
|
+
const account = this.getCachedAccountEntity(key, correlationId);
|
|
3247
3256
|
if (account) {
|
|
3248
3257
|
accountsToMerge.push(account);
|
|
3249
3258
|
}
|
|
@@ -3268,11 +3277,11 @@
|
|
|
3268
3277
|
// Clear cache of legacy account objects that have been collpsed into tenant profiles
|
|
3269
3278
|
matchingAccountKeys.forEach((key) => {
|
|
3270
3279
|
if (key !== newAccountKey) {
|
|
3271
|
-
this.removeOutdatedAccount(accountKey);
|
|
3280
|
+
this.removeOutdatedAccount(accountKey, correlationId);
|
|
3272
3281
|
}
|
|
3273
3282
|
});
|
|
3274
3283
|
// Cache updated account object
|
|
3275
|
-
this.setAccount(updatedAccount);
|
|
3284
|
+
this.setAccount(updatedAccount, correlationId);
|
|
3276
3285
|
logger?.verbose("Updated an outdated account entity in the cache");
|
|
3277
3286
|
return updatedAccount;
|
|
3278
3287
|
}
|
|
@@ -3283,37 +3292,31 @@
|
|
|
3283
3292
|
* returns a boolean if the given credential is removed
|
|
3284
3293
|
* @param credential
|
|
3285
3294
|
*/
|
|
3286
|
-
|
|
3287
|
-
const credential = this.getAccessTokenCredential(key);
|
|
3288
|
-
|
|
3295
|
+
removeAccessToken(key, correlationId) {
|
|
3296
|
+
const credential = this.getAccessTokenCredential(key, correlationId);
|
|
3297
|
+
this.removeItem(key, correlationId);
|
|
3298
|
+
if (!credential ||
|
|
3299
|
+
credential.credentialType.toLowerCase() !==
|
|
3300
|
+
CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME.toLowerCase() ||
|
|
3301
|
+
credential.tokenType !== AuthenticationScheme.POP) {
|
|
3289
3302
|
return;
|
|
3290
3303
|
}
|
|
3291
3304
|
// Remove Token Binding Key from key store for PoP Tokens Credentials
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
if (kid) {
|
|
3298
|
-
try {
|
|
3299
|
-
await this.cryptoImpl.removeTokenBindingKey(kid);
|
|
3300
|
-
}
|
|
3301
|
-
catch (error) {
|
|
3302
|
-
throw createClientAuthError(bindingKeyNotRemoved);
|
|
3303
|
-
}
|
|
3304
|
-
}
|
|
3305
|
-
}
|
|
3305
|
+
const kid = credential.keyId;
|
|
3306
|
+
if (kid) {
|
|
3307
|
+
void this.cryptoImpl.removeTokenBindingKey(kid).catch(() => {
|
|
3308
|
+
this.commonLogger.error("Binding key could not be removed");
|
|
3309
|
+
});
|
|
3306
3310
|
}
|
|
3307
|
-
return this.removeItem(key);
|
|
3308
3311
|
}
|
|
3309
3312
|
/**
|
|
3310
3313
|
* Removes all app metadata objects from cache.
|
|
3311
3314
|
*/
|
|
3312
|
-
removeAppMetadata() {
|
|
3315
|
+
removeAppMetadata(correlationId) {
|
|
3313
3316
|
const allCacheKeys = this.getKeys();
|
|
3314
3317
|
allCacheKeys.forEach((cacheKey) => {
|
|
3315
3318
|
if (this.isAppMetadata(cacheKey)) {
|
|
3316
|
-
this.removeItem(cacheKey);
|
|
3319
|
+
this.removeItem(cacheKey, correlationId);
|
|
3317
3320
|
}
|
|
3318
3321
|
});
|
|
3319
3322
|
return true;
|
|
@@ -3322,9 +3325,9 @@
|
|
|
3322
3325
|
* Retrieve AccountEntity from cache
|
|
3323
3326
|
* @param account
|
|
3324
3327
|
*/
|
|
3325
|
-
readAccountFromCache(account) {
|
|
3328
|
+
readAccountFromCache(account, correlationId) {
|
|
3326
3329
|
const accountKey = AccountEntity.generateAccountCacheKey(account);
|
|
3327
|
-
return this.getAccount(accountKey, this.commonLogger);
|
|
3330
|
+
return this.getAccount(accountKey, correlationId, this.commonLogger);
|
|
3328
3331
|
}
|
|
3329
3332
|
/**
|
|
3330
3333
|
* Retrieve IdTokenEntity from cache
|
|
@@ -3334,7 +3337,7 @@
|
|
|
3334
3337
|
* @param performanceClient {?IPerformanceClient}
|
|
3335
3338
|
* @param correlationId {?string}
|
|
3336
3339
|
*/
|
|
3337
|
-
getIdToken(account, tokenKeys, targetRealm, performanceClient
|
|
3340
|
+
getIdToken(account, correlationId, tokenKeys, targetRealm, performanceClient) {
|
|
3338
3341
|
this.commonLogger.trace("CacheManager - getIdToken called");
|
|
3339
3342
|
const idTokenFilter = {
|
|
3340
3343
|
homeAccountId: account.homeAccountId,
|
|
@@ -3343,7 +3346,7 @@
|
|
|
3343
3346
|
clientId: this.clientId,
|
|
3344
3347
|
realm: targetRealm,
|
|
3345
3348
|
};
|
|
3346
|
-
const idTokenMap = this.getIdTokensByFilter(idTokenFilter, tokenKeys);
|
|
3349
|
+
const idTokenMap = this.getIdTokensByFilter(idTokenFilter, correlationId, tokenKeys);
|
|
3347
3350
|
const numIdTokens = idTokenMap.size;
|
|
3348
3351
|
if (numIdTokens < 1) {
|
|
3349
3352
|
this.commonLogger.info("CacheManager:getIdToken - No token found");
|
|
@@ -3376,7 +3379,7 @@
|
|
|
3376
3379
|
// Multiple tokens for a single tenant profile, remove all and return null
|
|
3377
3380
|
this.commonLogger.info("CacheManager:getIdToken - Multiple matching ID tokens found, clearing them");
|
|
3378
3381
|
tokensToBeRemoved.forEach((idToken, key) => {
|
|
3379
|
-
this.removeIdToken(key);
|
|
3382
|
+
this.removeIdToken(key, correlationId);
|
|
3380
3383
|
});
|
|
3381
3384
|
if (performanceClient && correlationId) {
|
|
3382
3385
|
performanceClient.addFields({ multiMatchedID: idTokenMap.size }, correlationId);
|
|
@@ -3391,7 +3394,7 @@
|
|
|
3391
3394
|
* @param filter
|
|
3392
3395
|
* @returns
|
|
3393
3396
|
*/
|
|
3394
|
-
getIdTokensByFilter(filter, tokenKeys) {
|
|
3397
|
+
getIdTokensByFilter(filter, correlationId, tokenKeys) {
|
|
3395
3398
|
const idTokenKeys = (tokenKeys && tokenKeys.idToken) || this.getTokenKeys().idToken;
|
|
3396
3399
|
const idTokens = new Map();
|
|
3397
3400
|
idTokenKeys.forEach((key) => {
|
|
@@ -3401,7 +3404,7 @@
|
|
|
3401
3404
|
})) {
|
|
3402
3405
|
return;
|
|
3403
3406
|
}
|
|
3404
|
-
const idToken = this.getIdTokenCredential(key);
|
|
3407
|
+
const idToken = this.getIdTokenCredential(key, correlationId);
|
|
3405
3408
|
if (idToken && this.credentialMatchesFilter(idToken, filter)) {
|
|
3406
3409
|
idTokens.set(key, idToken);
|
|
3407
3410
|
}
|
|
@@ -3430,15 +3433,15 @@
|
|
|
3430
3433
|
* Removes idToken from the cache
|
|
3431
3434
|
* @param key
|
|
3432
3435
|
*/
|
|
3433
|
-
removeIdToken(key) {
|
|
3434
|
-
this.removeItem(key);
|
|
3436
|
+
removeIdToken(key, correlationId) {
|
|
3437
|
+
this.removeItem(key, correlationId);
|
|
3435
3438
|
}
|
|
3436
3439
|
/**
|
|
3437
3440
|
* Removes refresh token from the cache
|
|
3438
3441
|
* @param key
|
|
3439
3442
|
*/
|
|
3440
|
-
removeRefreshToken(key) {
|
|
3441
|
-
this.removeItem(key);
|
|
3443
|
+
removeRefreshToken(key, correlationId) {
|
|
3444
|
+
this.removeItem(key, correlationId);
|
|
3442
3445
|
}
|
|
3443
3446
|
/**
|
|
3444
3447
|
* Retrieve AccessTokenEntity from cache
|
|
@@ -3448,7 +3451,7 @@
|
|
|
3448
3451
|
* @param performanceClient {?IPerformanceClient}
|
|
3449
3452
|
* @param correlationId {?string}
|
|
3450
3453
|
*/
|
|
3451
|
-
getAccessToken(account, request, tokenKeys, targetRealm, performanceClient
|
|
3454
|
+
getAccessToken(account, request, tokenKeys, targetRealm, performanceClient) {
|
|
3452
3455
|
this.commonLogger.trace("CacheManager - getAccessToken called");
|
|
3453
3456
|
const scopes = ScopeSet.createSearchScopes(request.scopes);
|
|
3454
3457
|
const authScheme = request.authenticationScheme || AuthenticationScheme.BEARER;
|
|
@@ -3478,7 +3481,7 @@
|
|
|
3478
3481
|
accessTokenKeys.forEach((key) => {
|
|
3479
3482
|
// Validate key
|
|
3480
3483
|
if (this.accessTokenKeyMatchesFilter(key, accessTokenFilter, true)) {
|
|
3481
|
-
const accessToken = this.getAccessTokenCredential(key);
|
|
3484
|
+
const accessToken = this.getAccessTokenCredential(key, request.correlationId);
|
|
3482
3485
|
// Validate value
|
|
3483
3486
|
if (accessToken &&
|
|
3484
3487
|
this.credentialMatchesFilter(accessToken, accessTokenFilter)) {
|
|
@@ -3494,10 +3497,10 @@
|
|
|
3494
3497
|
else if (numAccessTokens > 1) {
|
|
3495
3498
|
this.commonLogger.info("CacheManager:getAccessToken - Multiple access tokens found, clearing them");
|
|
3496
3499
|
accessTokens.forEach((accessToken) => {
|
|
3497
|
-
void this.removeAccessToken(generateCredentialKey(accessToken));
|
|
3500
|
+
void this.removeAccessToken(generateCredentialKey(accessToken), request.correlationId);
|
|
3498
3501
|
});
|
|
3499
|
-
if (performanceClient && correlationId) {
|
|
3500
|
-
performanceClient.addFields({ multiMatchedAT: accessTokens.length }, correlationId);
|
|
3502
|
+
if (performanceClient && request.correlationId) {
|
|
3503
|
+
performanceClient.addFields({ multiMatchedAT: accessTokens.length }, request.correlationId);
|
|
3501
3504
|
}
|
|
3502
3505
|
return null;
|
|
3503
3506
|
}
|
|
@@ -3550,14 +3553,14 @@
|
|
|
3550
3553
|
* @param filter
|
|
3551
3554
|
* @returns
|
|
3552
3555
|
*/
|
|
3553
|
-
getAccessTokensByFilter(filter) {
|
|
3556
|
+
getAccessTokensByFilter(filter, correlationId) {
|
|
3554
3557
|
const tokenKeys = this.getTokenKeys();
|
|
3555
3558
|
const accessTokens = [];
|
|
3556
3559
|
tokenKeys.accessToken.forEach((key) => {
|
|
3557
3560
|
if (!this.accessTokenKeyMatchesFilter(key, filter, true)) {
|
|
3558
3561
|
return;
|
|
3559
3562
|
}
|
|
3560
|
-
const accessToken = this.getAccessTokenCredential(key);
|
|
3563
|
+
const accessToken = this.getAccessTokenCredential(key, correlationId);
|
|
3561
3564
|
if (accessToken &&
|
|
3562
3565
|
this.credentialMatchesFilter(accessToken, filter)) {
|
|
3563
3566
|
accessTokens.push(accessToken);
|
|
@@ -3573,7 +3576,7 @@
|
|
|
3573
3576
|
* @param performanceClient {?IPerformanceClient}
|
|
3574
3577
|
* @param correlationId {?string}
|
|
3575
3578
|
*/
|
|
3576
|
-
getRefreshToken(account, familyRT, tokenKeys, performanceClient
|
|
3579
|
+
getRefreshToken(account, familyRT, correlationId, tokenKeys, performanceClient) {
|
|
3577
3580
|
this.commonLogger.trace("CacheManager - getRefreshToken called");
|
|
3578
3581
|
const id = familyRT ? THE_FAMILY_ID : undefined;
|
|
3579
3582
|
const refreshTokenFilter = {
|
|
@@ -3589,7 +3592,7 @@
|
|
|
3589
3592
|
refreshTokenKeys.forEach((key) => {
|
|
3590
3593
|
// Validate key
|
|
3591
3594
|
if (this.refreshTokenKeyMatchesFilter(key, refreshTokenFilter)) {
|
|
3592
|
-
const refreshToken = this.getRefreshTokenCredential(key);
|
|
3595
|
+
const refreshToken = this.getRefreshTokenCredential(key, correlationId);
|
|
3593
3596
|
// Validate value
|
|
3594
3597
|
if (refreshToken &&
|
|
3595
3598
|
this.credentialMatchesFilter(refreshToken, refreshTokenFilter)) {
|
|
@@ -3948,7 +3951,7 @@
|
|
|
3948
3951
|
}
|
|
3949
3952
|
}
|
|
3950
3953
|
|
|
3951
|
-
/*! @azure/msal-common v14.16.
|
|
3954
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
3952
3955
|
|
|
3953
3956
|
/*
|
|
3954
3957
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4047,7 +4050,7 @@
|
|
|
4047
4050
|
return (config.authOptions.authority.options.protocolMode === ProtocolMode.OIDC);
|
|
4048
4051
|
}
|
|
4049
4052
|
|
|
4050
|
-
/*! @azure/msal-common v14.16.
|
|
4053
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
4051
4054
|
/*
|
|
4052
4055
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4053
4056
|
* Licensed under the MIT License.
|
|
@@ -4057,7 +4060,7 @@
|
|
|
4057
4060
|
UPN: "UPN",
|
|
4058
4061
|
};
|
|
4059
4062
|
|
|
4060
|
-
/*! @azure/msal-common v14.16.
|
|
4063
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
4061
4064
|
/*
|
|
4062
4065
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4063
4066
|
* Licensed under the MIT License.
|
|
@@ -4107,7 +4110,7 @@
|
|
|
4107
4110
|
const BROKER_CLIENT_ID = "brk_client_id";
|
|
4108
4111
|
const BROKER_REDIRECT_URI = "brk_redirect_uri";
|
|
4109
4112
|
|
|
4110
|
-
/*! @azure/msal-common v14.16.
|
|
4113
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
4111
4114
|
|
|
4112
4115
|
/*
|
|
4113
4116
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4174,7 +4177,7 @@
|
|
|
4174
4177
|
}
|
|
4175
4178
|
}
|
|
4176
4179
|
|
|
4177
|
-
/*! @azure/msal-common v14.16.
|
|
4180
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
4178
4181
|
|
|
4179
4182
|
/*
|
|
4180
4183
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4582,7 +4585,7 @@
|
|
|
4582
4585
|
}
|
|
4583
4586
|
}
|
|
4584
4587
|
|
|
4585
|
-
/*! @azure/msal-common v14.16.
|
|
4588
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
4586
4589
|
/*
|
|
4587
4590
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4588
4591
|
* Licensed under the MIT License.
|
|
@@ -4594,7 +4597,7 @@
|
|
|
4594
4597
|
response.hasOwnProperty("jwks_uri"));
|
|
4595
4598
|
}
|
|
4596
4599
|
|
|
4597
|
-
/*! @azure/msal-common v14.16.
|
|
4600
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
4598
4601
|
/*
|
|
4599
4602
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4600
4603
|
* Licensed under the MIT License.
|
|
@@ -4604,7 +4607,7 @@
|
|
|
4604
4607
|
response.hasOwnProperty("metadata"));
|
|
4605
4608
|
}
|
|
4606
4609
|
|
|
4607
|
-
/*! @azure/msal-common v14.16.
|
|
4610
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
4608
4611
|
/*
|
|
4609
4612
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4610
4613
|
* Licensed under the MIT License.
|
|
@@ -4614,7 +4617,7 @@
|
|
|
4614
4617
|
response.hasOwnProperty("error_description"));
|
|
4615
4618
|
}
|
|
4616
4619
|
|
|
4617
|
-
/*! @azure/msal-common v14.16.
|
|
4620
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
4618
4621
|
/*
|
|
4619
4622
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4620
4623
|
* Licensed under the MIT License.
|
|
@@ -5101,7 +5104,7 @@
|
|
|
5101
5104
|
"multiMatchedRT",
|
|
5102
5105
|
]);
|
|
5103
5106
|
|
|
5104
|
-
/*! @azure/msal-common v14.16.
|
|
5107
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
5105
5108
|
/*
|
|
5106
5109
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
5107
5110
|
* Licensed under the MIT License.
|
|
@@ -5197,7 +5200,7 @@
|
|
|
5197
5200
|
};
|
|
5198
5201
|
};
|
|
5199
5202
|
|
|
5200
|
-
/*! @azure/msal-common v14.16.
|
|
5203
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
5201
5204
|
|
|
5202
5205
|
/*
|
|
5203
5206
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -5306,7 +5309,7 @@
|
|
|
5306
5309
|
},
|
|
5307
5310
|
};
|
|
5308
5311
|
|
|
5309
|
-
/*! @azure/msal-common v14.16.
|
|
5312
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
5310
5313
|
|
|
5311
5314
|
/*
|
|
5312
5315
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6145,7 +6148,7 @@
|
|
|
6145
6148
|
};
|
|
6146
6149
|
}
|
|
6147
6150
|
|
|
6148
|
-
/*! @azure/msal-common v14.16.
|
|
6151
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
6149
6152
|
|
|
6150
6153
|
/*
|
|
6151
6154
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6176,7 +6179,7 @@
|
|
|
6176
6179
|
}
|
|
6177
6180
|
}
|
|
6178
6181
|
|
|
6179
|
-
/*! @azure/msal-common v14.16.
|
|
6182
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
6180
6183
|
|
|
6181
6184
|
/*
|
|
6182
6185
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6195,7 +6198,7 @@
|
|
|
6195
6198
|
}
|
|
6196
6199
|
}
|
|
6197
6200
|
|
|
6198
|
-
/*! @azure/msal-common v14.16.
|
|
6201
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
6199
6202
|
|
|
6200
6203
|
/*
|
|
6201
6204
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6215,12 +6218,12 @@
|
|
|
6215
6218
|
* @param cacheManager
|
|
6216
6219
|
* @param thumbprint
|
|
6217
6220
|
*/
|
|
6218
|
-
static preProcess(cacheManager, thumbprint) {
|
|
6221
|
+
static preProcess(cacheManager, thumbprint, correlationId) {
|
|
6219
6222
|
const key = ThrottlingUtils.generateThrottlingStorageKey(thumbprint);
|
|
6220
6223
|
const value = cacheManager.getThrottlingCache(key);
|
|
6221
6224
|
if (value) {
|
|
6222
6225
|
if (value.throttleTime < Date.now()) {
|
|
6223
|
-
cacheManager.removeItem(key);
|
|
6226
|
+
cacheManager.removeItem(key, correlationId);
|
|
6224
6227
|
return;
|
|
6225
6228
|
}
|
|
6226
6229
|
throw new ServerError(value.errorCodes?.join(" ") || Constants.EMPTY_STRING, value.errorMessage, value.subError);
|
|
@@ -6232,7 +6235,7 @@
|
|
|
6232
6235
|
* @param thumbprint
|
|
6233
6236
|
* @param response
|
|
6234
6237
|
*/
|
|
6235
|
-
static postProcess(cacheManager, thumbprint, response) {
|
|
6238
|
+
static postProcess(cacheManager, thumbprint, response, correlationId) {
|
|
6236
6239
|
if (ThrottlingUtils.checkResponseStatus(response) ||
|
|
6237
6240
|
ThrottlingUtils.checkResponseForRetryAfter(response)) {
|
|
6238
6241
|
const thumbprintValue = {
|
|
@@ -6242,7 +6245,7 @@
|
|
|
6242
6245
|
errorMessage: response.body.error_description,
|
|
6243
6246
|
subError: response.body.suberror,
|
|
6244
6247
|
};
|
|
6245
|
-
cacheManager.setThrottlingCache(ThrottlingUtils.generateThrottlingStorageKey(thumbprint), thumbprintValue);
|
|
6248
|
+
cacheManager.setThrottlingCache(ThrottlingUtils.generateThrottlingStorageKey(thumbprint), thumbprintValue, correlationId);
|
|
6246
6249
|
}
|
|
6247
6250
|
}
|
|
6248
6251
|
/**
|
|
@@ -6289,11 +6292,11 @@
|
|
|
6289
6292
|
sshKid: request.sshKid,
|
|
6290
6293
|
};
|
|
6291
6294
|
const key = this.generateThrottlingStorageKey(thumbprint);
|
|
6292
|
-
cacheManager.removeItem(key);
|
|
6295
|
+
cacheManager.removeItem(key, request.correlationId);
|
|
6293
6296
|
}
|
|
6294
6297
|
}
|
|
6295
6298
|
|
|
6296
|
-
/*! @azure/msal-common v14.16.
|
|
6299
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
6297
6300
|
|
|
6298
6301
|
/*
|
|
6299
6302
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6323,7 +6326,7 @@
|
|
|
6323
6326
|
return new NetworkError(error, httpStatus, responseHeaders);
|
|
6324
6327
|
}
|
|
6325
6328
|
|
|
6326
|
-
/*! @azure/msal-common v14.16.
|
|
6329
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
6327
6330
|
|
|
6328
6331
|
/*
|
|
6329
6332
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6405,7 +6408,7 @@
|
|
|
6405
6408
|
* @param correlationId - CorrelationId for telemetry
|
|
6406
6409
|
*/
|
|
6407
6410
|
async sendPostRequest(thumbprint, tokenEndpoint, options, correlationId) {
|
|
6408
|
-
ThrottlingUtils.preProcess(this.cacheManager, thumbprint);
|
|
6411
|
+
ThrottlingUtils.preProcess(this.cacheManager, thumbprint, correlationId);
|
|
6409
6412
|
let response;
|
|
6410
6413
|
try {
|
|
6411
6414
|
response = await invokeAsync((this.networkClient.sendPostRequestAsync.bind(this.networkClient)), PerformanceEvents.NetworkClientSendPostRequestAsync, this.logger, this.performanceClient, correlationId)(tokenEndpoint, options);
|
|
@@ -6440,7 +6443,7 @@
|
|
|
6440
6443
|
throw createClientAuthError(networkError);
|
|
6441
6444
|
}
|
|
6442
6445
|
}
|
|
6443
|
-
ThrottlingUtils.postProcess(this.cacheManager, thumbprint, response);
|
|
6446
|
+
ThrottlingUtils.postProcess(this.cacheManager, thumbprint, response, correlationId);
|
|
6444
6447
|
return response;
|
|
6445
6448
|
}
|
|
6446
6449
|
/**
|
|
@@ -6473,7 +6476,7 @@
|
|
|
6473
6476
|
}
|
|
6474
6477
|
}
|
|
6475
6478
|
|
|
6476
|
-
/*! @azure/msal-common v14.16.
|
|
6479
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
6477
6480
|
/*
|
|
6478
6481
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6479
6482
|
* Licensed under the MIT License.
|
|
@@ -6499,7 +6502,7 @@
|
|
|
6499
6502
|
refreshTokenExpired: refreshTokenExpired
|
|
6500
6503
|
});
|
|
6501
6504
|
|
|
6502
|
-
/*! @azure/msal-common v14.16.
|
|
6505
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
6503
6506
|
|
|
6504
6507
|
/*
|
|
6505
6508
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6587,7 +6590,7 @@
|
|
|
6587
6590
|
return new InteractionRequiredAuthError(errorCode, InteractionRequiredAuthErrorMessages[errorCode]);
|
|
6588
6591
|
}
|
|
6589
6592
|
|
|
6590
|
-
/*! @azure/msal-common v14.16.
|
|
6593
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
6591
6594
|
|
|
6592
6595
|
/*
|
|
6593
6596
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6659,7 +6662,7 @@
|
|
|
6659
6662
|
}
|
|
6660
6663
|
}
|
|
6661
6664
|
|
|
6662
|
-
/*! @azure/msal-common v14.16.
|
|
6665
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
6663
6666
|
|
|
6664
6667
|
/*
|
|
6665
6668
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6743,7 +6746,7 @@
|
|
|
6743
6746
|
}
|
|
6744
6747
|
}
|
|
6745
6748
|
|
|
6746
|
-
/*! @azure/msal-common v14.16.
|
|
6749
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
6747
6750
|
/*
|
|
6748
6751
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6749
6752
|
* Licensed under the MIT License.
|
|
@@ -6770,7 +6773,7 @@
|
|
|
6770
6773
|
}
|
|
6771
6774
|
}
|
|
6772
6775
|
|
|
6773
|
-
/*! @azure/msal-common v14.16.
|
|
6776
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
6774
6777
|
|
|
6775
6778
|
/*
|
|
6776
6779
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6930,13 +6933,13 @@
|
|
|
6930
6933
|
!forceCacheRefreshTokenResponse &&
|
|
6931
6934
|
cacheRecord.account) {
|
|
6932
6935
|
const key = cacheRecord.account.generateAccountKey();
|
|
6933
|
-
const account = this.cacheStorage.getAccount(key, this.logger);
|
|
6936
|
+
const account = this.cacheStorage.getAccount(key, request.correlationId, this.logger);
|
|
6934
6937
|
if (!account) {
|
|
6935
6938
|
this.logger.warning("Account used to refresh tokens not in persistence, refreshed tokens will not be stored in the cache");
|
|
6936
6939
|
return await ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenClaims, requestStateObj, undefined, serverRequestId);
|
|
6937
6940
|
}
|
|
6938
6941
|
}
|
|
6939
|
-
await this.cacheStorage.saveCacheRecord(cacheRecord, request.
|
|
6942
|
+
await this.cacheStorage.saveCacheRecord(cacheRecord, request.correlationId, request.storeInCache);
|
|
6940
6943
|
}
|
|
6941
6944
|
finally {
|
|
6942
6945
|
if (this.persistencePlugin &&
|
|
@@ -6965,7 +6968,7 @@
|
|
|
6965
6968
|
let cachedAccount;
|
|
6966
6969
|
if (serverTokenResponse.id_token && !!idTokenClaims) {
|
|
6967
6970
|
cachedIdToken = createIdTokenEntity(this.homeAccountIdentifier, env, serverTokenResponse.id_token, this.clientId, claimsTenantId || "");
|
|
6968
|
-
cachedAccount = buildAccountToCache(this.cacheStorage, authority, this.homeAccountIdentifier, this.cryptoObj.base64Decode, idTokenClaims, serverTokenResponse.client_info, env, claimsTenantId, authCodePayload, undefined, // nativeAccountId
|
|
6971
|
+
cachedAccount = buildAccountToCache(this.cacheStorage, authority, this.homeAccountIdentifier, this.cryptoObj.base64Decode, request.correlationId, idTokenClaims, serverTokenResponse.client_info, env, claimsTenantId, authCodePayload, undefined, // nativeAccountId
|
|
6969
6972
|
this.logger);
|
|
6970
6973
|
}
|
|
6971
6974
|
// AccessToken
|
|
@@ -7113,7 +7116,7 @@
|
|
|
7113
7116
|
};
|
|
7114
7117
|
}
|
|
7115
7118
|
}
|
|
7116
|
-
function buildAccountToCache(cacheStorage, authority, homeAccountId, base64Decode, idTokenClaims, clientInfo, environment, claimsTenantId, authCodePayload, nativeAccountId, logger) {
|
|
7119
|
+
function buildAccountToCache(cacheStorage, authority, homeAccountId, base64Decode, correlationId, idTokenClaims, clientInfo, environment, claimsTenantId, authCodePayload, nativeAccountId, logger) {
|
|
7117
7120
|
logger?.verbose("setCachedAccount called");
|
|
7118
7121
|
// Check if base account is already cached
|
|
7119
7122
|
const accountKeys = cacheStorage.getAccountKeys();
|
|
@@ -7122,7 +7125,7 @@
|
|
|
7122
7125
|
});
|
|
7123
7126
|
let cachedAccount = null;
|
|
7124
7127
|
if (baseAccountKey) {
|
|
7125
|
-
cachedAccount = cacheStorage.getAccount(baseAccountKey, logger);
|
|
7128
|
+
cachedAccount = cacheStorage.getAccount(baseAccountKey, correlationId, logger);
|
|
7126
7129
|
}
|
|
7127
7130
|
const baseAccount = cachedAccount ||
|
|
7128
7131
|
AccountEntity.createAccount({
|
|
@@ -7147,7 +7150,7 @@
|
|
|
7147
7150
|
return baseAccount;
|
|
7148
7151
|
}
|
|
7149
7152
|
|
|
7150
|
-
/*! @azure/msal-common v14.16.
|
|
7153
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
7151
7154
|
/*
|
|
7152
7155
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
7153
7156
|
* Licensed under the MIT License.
|
|
@@ -7165,7 +7168,7 @@
|
|
|
7165
7168
|
}
|
|
7166
7169
|
}
|
|
7167
7170
|
|
|
7168
|
-
/*! @azure/msal-common v14.16.
|
|
7171
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
7169
7172
|
|
|
7170
7173
|
/*
|
|
7171
7174
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7607,7 +7610,7 @@
|
|
|
7607
7610
|
}
|
|
7608
7611
|
}
|
|
7609
7612
|
|
|
7610
|
-
/*! @azure/msal-common v14.16.
|
|
7613
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
7611
7614
|
|
|
7612
7615
|
/*
|
|
7613
7616
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7680,7 +7683,7 @@
|
|
|
7680
7683
|
async acquireTokenWithCachedRefreshToken(request, foci) {
|
|
7681
7684
|
this.performanceClient?.addQueueMeasurement(PerformanceEvents.RefreshTokenClientAcquireTokenWithCachedRefreshToken, request.correlationId);
|
|
7682
7685
|
// fetches family RT or application RT based on FOCI value
|
|
7683
|
-
const refreshToken = invoke(this.cacheManager.getRefreshToken.bind(this.cacheManager), PerformanceEvents.CacheManagerGetRefreshToken, this.logger, this.performanceClient, request.correlationId)(request.account, foci, undefined, this.performanceClient
|
|
7686
|
+
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);
|
|
7684
7687
|
if (!refreshToken) {
|
|
7685
7688
|
throw createInteractionRequiredAuthError(noTokensFound);
|
|
7686
7689
|
}
|
|
@@ -7708,7 +7711,7 @@
|
|
|
7708
7711
|
// Remove bad refresh token from cache
|
|
7709
7712
|
this.logger.verbose("acquireTokenWithRefreshToken: bad refresh token, removing from cache");
|
|
7710
7713
|
const badRefreshTokenKey = generateCredentialKey(refreshToken);
|
|
7711
|
-
this.cacheManager.removeRefreshToken(badRefreshTokenKey);
|
|
7714
|
+
this.cacheManager.removeRefreshToken(badRefreshTokenKey, request.correlationId);
|
|
7712
7715
|
}
|
|
7713
7716
|
throw e;
|
|
7714
7717
|
}
|
|
@@ -7827,7 +7830,7 @@
|
|
|
7827
7830
|
}
|
|
7828
7831
|
}
|
|
7829
7832
|
|
|
7830
|
-
/*! @azure/msal-common v14.16.
|
|
7833
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
7831
7834
|
|
|
7832
7835
|
/*
|
|
7833
7836
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7897,7 +7900,7 @@
|
|
|
7897
7900
|
const requestTenantId = request.account.tenantId ||
|
|
7898
7901
|
getTenantFromAuthorityString(request.authority);
|
|
7899
7902
|
const tokenKeys = this.cacheManager.getTokenKeys();
|
|
7900
|
-
const cachedAccessToken = this.cacheManager.getAccessToken(request.account, request, tokenKeys, requestTenantId, this.performanceClient
|
|
7903
|
+
const cachedAccessToken = this.cacheManager.getAccessToken(request.account, request, tokenKeys, requestTenantId, this.performanceClient);
|
|
7901
7904
|
if (!cachedAccessToken) {
|
|
7902
7905
|
// must refresh due to non-existent access_token
|
|
7903
7906
|
this.setCacheOutcome(CacheOutcome.NO_CACHED_ACCESS_TOKEN, request.correlationId);
|
|
@@ -7917,9 +7920,9 @@
|
|
|
7917
7920
|
}
|
|
7918
7921
|
const environment = request.authority || this.authority.getPreferredCache();
|
|
7919
7922
|
const cacheRecord = {
|
|
7920
|
-
account: this.cacheManager.readAccountFromCache(request.account),
|
|
7923
|
+
account: this.cacheManager.readAccountFromCache(request.account, request.correlationId),
|
|
7921
7924
|
accessToken: cachedAccessToken,
|
|
7922
|
-
idToken: this.cacheManager.getIdToken(request.account, tokenKeys, requestTenantId, this.performanceClient
|
|
7925
|
+
idToken: this.cacheManager.getIdToken(request.account, request.correlationId, tokenKeys, requestTenantId, this.performanceClient),
|
|
7923
7926
|
refreshToken: null,
|
|
7924
7927
|
appMetadata: this.cacheManager.readAppMetadataFromCache(environment),
|
|
7925
7928
|
};
|
|
@@ -7963,7 +7966,7 @@
|
|
|
7963
7966
|
}
|
|
7964
7967
|
}
|
|
7965
7968
|
|
|
7966
|
-
/*! @azure/msal-common v14.16.
|
|
7969
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
7967
7970
|
|
|
7968
7971
|
/*
|
|
7969
7972
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7978,7 +7981,7 @@
|
|
|
7978
7981
|
},
|
|
7979
7982
|
};
|
|
7980
7983
|
|
|
7981
|
-
/*! @azure/msal-common v14.16.
|
|
7984
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
7982
7985
|
|
|
7983
7986
|
/*
|
|
7984
7987
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8036,7 +8039,7 @@
|
|
|
8036
8039
|
}
|
|
8037
8040
|
}
|
|
8038
8041
|
|
|
8039
|
-
/*! @azure/msal-common v14.16.
|
|
8042
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
8040
8043
|
|
|
8041
8044
|
/*
|
|
8042
8045
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8175,7 +8178,7 @@
|
|
|
8175
8178
|
else {
|
|
8176
8179
|
lastRequests.errors.push(SERVER_TELEM_CONSTANTS.UNKNOWN_ERROR);
|
|
8177
8180
|
}
|
|
8178
|
-
this.cacheManager.setServerTelemetry(this.telemetryCacheKey, lastRequests);
|
|
8181
|
+
this.cacheManager.setServerTelemetry(this.telemetryCacheKey, lastRequests, this.correlationId);
|
|
8179
8182
|
return;
|
|
8180
8183
|
}
|
|
8181
8184
|
/**
|
|
@@ -8184,7 +8187,7 @@
|
|
|
8184
8187
|
incrementCacheHits() {
|
|
8185
8188
|
const lastRequests = this.getLastRequests();
|
|
8186
8189
|
lastRequests.cacheHits += 1;
|
|
8187
|
-
this.cacheManager.setServerTelemetry(this.telemetryCacheKey, lastRequests);
|
|
8190
|
+
this.cacheManager.setServerTelemetry(this.telemetryCacheKey, lastRequests, this.correlationId);
|
|
8188
8191
|
return lastRequests.cacheHits;
|
|
8189
8192
|
}
|
|
8190
8193
|
/**
|
|
@@ -8208,7 +8211,7 @@
|
|
|
8208
8211
|
const errorCount = lastRequests.errors.length;
|
|
8209
8212
|
if (numErrorsFlushed === errorCount) {
|
|
8210
8213
|
// All errors were sent on last request, clear Telemetry cache
|
|
8211
|
-
this.cacheManager.removeItem(this.telemetryCacheKey);
|
|
8214
|
+
this.cacheManager.removeItem(this.telemetryCacheKey, this.correlationId);
|
|
8212
8215
|
}
|
|
8213
8216
|
else {
|
|
8214
8217
|
// Partial data was flushed to server, construct a new telemetry cache item with errors that were not flushed
|
|
@@ -8217,7 +8220,7 @@
|
|
|
8217
8220
|
errors: lastRequests.errors.slice(numErrorsFlushed),
|
|
8218
8221
|
cacheHits: 0,
|
|
8219
8222
|
};
|
|
8220
|
-
this.cacheManager.setServerTelemetry(this.telemetryCacheKey, serverTelemEntity);
|
|
8223
|
+
this.cacheManager.setServerTelemetry(this.telemetryCacheKey, serverTelemEntity, this.correlationId);
|
|
8221
8224
|
}
|
|
8222
8225
|
}
|
|
8223
8226
|
/**
|
|
@@ -8284,7 +8287,7 @@
|
|
|
8284
8287
|
setNativeBrokerErrorCode(errorCode) {
|
|
8285
8288
|
const lastRequests = this.getLastRequests();
|
|
8286
8289
|
lastRequests.nativeBrokerErrorCode = errorCode;
|
|
8287
|
-
this.cacheManager.setServerTelemetry(this.telemetryCacheKey, lastRequests);
|
|
8290
|
+
this.cacheManager.setServerTelemetry(this.telemetryCacheKey, lastRequests, this.correlationId);
|
|
8288
8291
|
}
|
|
8289
8292
|
getNativeBrokerErrorCode() {
|
|
8290
8293
|
return this.getLastRequests().nativeBrokerErrorCode;
|
|
@@ -8292,14 +8295,14 @@
|
|
|
8292
8295
|
clearNativeBrokerErrorCode() {
|
|
8293
8296
|
const lastRequests = this.getLastRequests();
|
|
8294
8297
|
delete lastRequests.nativeBrokerErrorCode;
|
|
8295
|
-
this.cacheManager.setServerTelemetry(this.telemetryCacheKey, lastRequests);
|
|
8298
|
+
this.cacheManager.setServerTelemetry(this.telemetryCacheKey, lastRequests, this.correlationId);
|
|
8296
8299
|
}
|
|
8297
8300
|
static makeExtraSkuString(params) {
|
|
8298
8301
|
return makeExtraSkuString(params);
|
|
8299
8302
|
}
|
|
8300
8303
|
}
|
|
8301
8304
|
|
|
8302
|
-
/*! @azure/msal-common v14.16.
|
|
8305
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
8303
8306
|
/*
|
|
8304
8307
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
8305
8308
|
* Licensed under the MIT License.
|
|
@@ -8307,7 +8310,7 @@
|
|
|
8307
8310
|
const missingKidError = "missing_kid_error";
|
|
8308
8311
|
const missingAlgError = "missing_alg_error";
|
|
8309
8312
|
|
|
8310
|
-
/*! @azure/msal-common v14.16.
|
|
8313
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
8311
8314
|
|
|
8312
8315
|
/*
|
|
8313
8316
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8332,7 +8335,7 @@
|
|
|
8332
8335
|
return new JoseHeaderError(code, JoseHeaderErrorMessages[code]);
|
|
8333
8336
|
}
|
|
8334
8337
|
|
|
8335
|
-
/*! @azure/msal-common v14.16.
|
|
8338
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
8336
8339
|
|
|
8337
8340
|
/*
|
|
8338
8341
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8372,7 +8375,7 @@
|
|
|
8372
8375
|
}
|
|
8373
8376
|
}
|
|
8374
8377
|
|
|
8375
|
-
/*! @azure/msal-common v14.16.
|
|
8378
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
8376
8379
|
|
|
8377
8380
|
/*
|
|
8378
8381
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8451,7 +8454,7 @@
|
|
|
8451
8454
|
}
|
|
8452
8455
|
}
|
|
8453
8456
|
|
|
8454
|
-
/*! @azure/msal-common v14.16.
|
|
8457
|
+
/*! @azure/msal-common v14.16.1 2025-08-05 */
|
|
8455
8458
|
|
|
8456
8459
|
/*
|
|
8457
8460
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -9514,6 +9517,7 @@
|
|
|
9514
9517
|
const StaticCacheKeys = {
|
|
9515
9518
|
ACCOUNT_KEYS: "msal.account.keys",
|
|
9516
9519
|
TOKEN_KEYS: "msal.token.keys",
|
|
9520
|
+
VERSION: "msal.version",
|
|
9517
9521
|
};
|
|
9518
9522
|
/**
|
|
9519
9523
|
* Cache keys stored in-memory
|
|
@@ -10372,7 +10376,7 @@
|
|
|
10372
10376
|
|
|
10373
10377
|
/* eslint-disable header/header */
|
|
10374
10378
|
const name = "@azure/msal-browser";
|
|
10375
|
-
const version = "3.
|
|
10379
|
+
const version = "3.30.0";
|
|
10376
10380
|
|
|
10377
10381
|
/*
|
|
10378
10382
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -11513,6 +11517,13 @@
|
|
|
11513
11517
|
* @param storeAuthStateInCookie
|
|
11514
11518
|
*/
|
|
11515
11519
|
migrateCacheEntries() {
|
|
11520
|
+
const previousVersion = this.browserStorage.getItem(StaticCacheKeys.VERSION);
|
|
11521
|
+
if (previousVersion) {
|
|
11522
|
+
this.logger.info(`MSAL.js was last initialized with version ${previousVersion}`);
|
|
11523
|
+
}
|
|
11524
|
+
if (previousVersion !== version) {
|
|
11525
|
+
this.browserStorage.setItem(StaticCacheKeys.VERSION, version);
|
|
11526
|
+
}
|
|
11516
11527
|
const idTokenKey = `${Constants.CACHE_PREFIX}.${PersistentCacheKeys.ID_TOKEN}`;
|
|
11517
11528
|
const clientInfoKey = `${Constants.CACHE_PREFIX}.${PersistentCacheKeys.CLIENT_INFO}`;
|
|
11518
11529
|
const errorKey = `${Constants.CACHE_PREFIX}.${PersistentCacheKeys.ERROR}`;
|
|
@@ -11547,6 +11558,7 @@
|
|
|
11547
11558
|
*/
|
|
11548
11559
|
createKeyMaps() {
|
|
11549
11560
|
this.logger.trace("BrowserCacheManager - createKeyMaps called.");
|
|
11561
|
+
const correlationId = this.cryptoImpl.createNewGuid();
|
|
11550
11562
|
const accountKeys = this.getItem(StaticCacheKeys.ACCOUNT_KEYS);
|
|
11551
11563
|
const tokenKeys = this.getItem(`${StaticCacheKeys.TOKEN_KEYS}.${this.clientId}`);
|
|
11552
11564
|
if (accountKeys && tokenKeys) {
|
|
@@ -11568,8 +11580,8 @@
|
|
|
11568
11580
|
this.logger.trace("BrowserCacheManager:createKeyMaps - idToken found, saving key to token key map");
|
|
11569
11581
|
this.logger.tracePii(`BrowserCacheManager:createKeyMaps - idToken with key: ${key} found, saving key to token key map`);
|
|
11570
11582
|
const idTokenEntity = credObj;
|
|
11571
|
-
const newKey = this.updateCredentialCacheKey(key, idTokenEntity);
|
|
11572
|
-
this.addTokenKey(newKey, CredentialType.ID_TOKEN);
|
|
11583
|
+
const newKey = this.updateCredentialCacheKey(key, idTokenEntity, correlationId);
|
|
11584
|
+
this.addTokenKey(newKey, CredentialType.ID_TOKEN, correlationId);
|
|
11573
11585
|
return;
|
|
11574
11586
|
}
|
|
11575
11587
|
else {
|
|
@@ -11583,8 +11595,8 @@
|
|
|
11583
11595
|
this.logger.trace("BrowserCacheManager:createKeyMaps - accessToken found, saving key to token key map");
|
|
11584
11596
|
this.logger.tracePii(`BrowserCacheManager:createKeyMaps - accessToken with key: ${key} found, saving key to token key map`);
|
|
11585
11597
|
const accessTokenEntity = credObj;
|
|
11586
|
-
const newKey = this.updateCredentialCacheKey(key, accessTokenEntity);
|
|
11587
|
-
this.addTokenKey(newKey, CredentialType.ACCESS_TOKEN);
|
|
11598
|
+
const newKey = this.updateCredentialCacheKey(key, accessTokenEntity, correlationId);
|
|
11599
|
+
this.addTokenKey(newKey, CredentialType.ACCESS_TOKEN, correlationId);
|
|
11588
11600
|
return;
|
|
11589
11601
|
}
|
|
11590
11602
|
else {
|
|
@@ -11597,8 +11609,8 @@
|
|
|
11597
11609
|
this.logger.trace("BrowserCacheManager:createKeyMaps - refreshToken found, saving key to token key map");
|
|
11598
11610
|
this.logger.tracePii(`BrowserCacheManager:createKeyMaps - refreshToken with key: ${key} found, saving key to token key map`);
|
|
11599
11611
|
const refreshTokenEntity = credObj;
|
|
11600
|
-
const newKey = this.updateCredentialCacheKey(key, refreshTokenEntity);
|
|
11601
|
-
this.addTokenKey(newKey, CredentialType.REFRESH_TOKEN);
|
|
11612
|
+
const newKey = this.updateCredentialCacheKey(key, refreshTokenEntity, correlationId);
|
|
11613
|
+
this.addTokenKey(newKey, CredentialType.REFRESH_TOKEN, correlationId);
|
|
11602
11614
|
return;
|
|
11603
11615
|
}
|
|
11604
11616
|
else {
|
|
@@ -11619,7 +11631,7 @@
|
|
|
11619
11631
|
AccountEntity.isAccountEntity(accountObj)) {
|
|
11620
11632
|
this.logger.trace("BrowserCacheManager:createKeyMaps - account found, saving key to account key map");
|
|
11621
11633
|
this.logger.tracePii(`BrowserCacheManager:createKeyMaps - account with key: ${key} found, saving key to account key map`);
|
|
11622
|
-
this.addAccountKeyToMap(key);
|
|
11634
|
+
this.addAccountKeyToMap(key, correlationId);
|
|
11623
11635
|
}
|
|
11624
11636
|
}
|
|
11625
11637
|
}
|
|
@@ -11658,17 +11670,58 @@
|
|
|
11658
11670
|
* @param key
|
|
11659
11671
|
* @param value
|
|
11660
11672
|
*/
|
|
11661
|
-
setItem(key, value) {
|
|
11662
|
-
|
|
11673
|
+
setItem(key, value, correlationId) {
|
|
11674
|
+
let accessTokenKeys = [];
|
|
11675
|
+
const maxRetries = 20;
|
|
11676
|
+
for (let i = 0; i <= maxRetries; i++) {
|
|
11677
|
+
try {
|
|
11678
|
+
this.browserStorage.setItem(key, value);
|
|
11679
|
+
if (i > 0) {
|
|
11680
|
+
// Finally update the token keys array with the tokens removed
|
|
11681
|
+
this.removeAccessTokenKeys(accessTokenKeys.slice(0, i), correlationId);
|
|
11682
|
+
}
|
|
11683
|
+
break; // If setItem succeeds, exit the loop
|
|
11684
|
+
}
|
|
11685
|
+
catch (e) {
|
|
11686
|
+
const cacheError = createCacheError(e);
|
|
11687
|
+
if (cacheError.errorCode ===
|
|
11688
|
+
cacheQuotaExceeded &&
|
|
11689
|
+
i < maxRetries) {
|
|
11690
|
+
if (!accessTokenKeys.length) {
|
|
11691
|
+
if (key ===
|
|
11692
|
+
`${StaticCacheKeys.TOKEN_KEYS}.${this.clientId}`) {
|
|
11693
|
+
// If we are currently trying to set the token keys, use the value we're trying to set
|
|
11694
|
+
accessTokenKeys = JSON.parse(value)
|
|
11695
|
+
.accessToken;
|
|
11696
|
+
}
|
|
11697
|
+
else {
|
|
11698
|
+
// If token keys have not been initialized, get them
|
|
11699
|
+
accessTokenKeys = this.getTokenKeys().accessToken;
|
|
11700
|
+
}
|
|
11701
|
+
}
|
|
11702
|
+
if (accessTokenKeys.length <= i) {
|
|
11703
|
+
// Nothing to remove, rethrow the error
|
|
11704
|
+
throw cacheError;
|
|
11705
|
+
}
|
|
11706
|
+
// When cache quota is exceeded, start removing access tokens until we can successfully set the item
|
|
11707
|
+
this.removeAccessToken(accessTokenKeys[i], correlationId, false // Don't save token keys yet, do it at the end
|
|
11708
|
+
);
|
|
11709
|
+
}
|
|
11710
|
+
else {
|
|
11711
|
+
// If the error is not a quota exceeded error, rethrow it
|
|
11712
|
+
throw cacheError;
|
|
11713
|
+
}
|
|
11714
|
+
}
|
|
11715
|
+
}
|
|
11663
11716
|
}
|
|
11664
11717
|
/**
|
|
11665
11718
|
* fetch the account entity from the platform cache
|
|
11666
11719
|
* @param accountKey
|
|
11667
11720
|
*/
|
|
11668
|
-
getAccount(accountKey, logger) {
|
|
11721
|
+
getAccount(accountKey, correlationId, logger) {
|
|
11669
11722
|
this.logger.trace("BrowserCacheManager.getAccount called");
|
|
11670
|
-
const accountEntity = this.getCachedAccountEntity(accountKey);
|
|
11671
|
-
return this.updateOutdatedCachedAccount(accountKey, accountEntity, logger);
|
|
11723
|
+
const accountEntity = this.getCachedAccountEntity(accountKey, correlationId);
|
|
11724
|
+
return this.updateOutdatedCachedAccount(accountKey, accountEntity, correlationId, logger);
|
|
11672
11725
|
}
|
|
11673
11726
|
/**
|
|
11674
11727
|
* Reads account from cache, deserializes it into an account entity and returns it.
|
|
@@ -11676,15 +11729,14 @@
|
|
|
11676
11729
|
* @param accountKey
|
|
11677
11730
|
* @returns
|
|
11678
11731
|
*/
|
|
11679
|
-
getCachedAccountEntity(accountKey) {
|
|
11732
|
+
getCachedAccountEntity(accountKey, correlationId) {
|
|
11680
11733
|
const serializedAccount = this.getItem(accountKey);
|
|
11681
11734
|
if (!serializedAccount) {
|
|
11682
|
-
this.removeAccountKeyFromMap(accountKey);
|
|
11735
|
+
this.removeAccountKeyFromMap(accountKey, correlationId);
|
|
11683
11736
|
return null;
|
|
11684
11737
|
}
|
|
11685
11738
|
const parsedAccount = this.validateAndParseJson(serializedAccount);
|
|
11686
11739
|
if (!parsedAccount || !AccountEntity.isAccountEntity(parsedAccount)) {
|
|
11687
|
-
this.removeAccountKeyFromMap(accountKey);
|
|
11688
11740
|
return null;
|
|
11689
11741
|
}
|
|
11690
11742
|
return CacheManager.toObject(new AccountEntity(), parsedAccount);
|
|
@@ -11693,11 +11745,12 @@
|
|
|
11693
11745
|
* set account entity in the platform cache
|
|
11694
11746
|
* @param account
|
|
11695
11747
|
*/
|
|
11696
|
-
setAccount(account) {
|
|
11748
|
+
setAccount(account, correlationId) {
|
|
11697
11749
|
this.logger.trace("BrowserCacheManager.setAccount called");
|
|
11698
11750
|
const key = account.generateAccountKey();
|
|
11699
|
-
|
|
11700
|
-
this.
|
|
11751
|
+
account.lastUpdatedAt = Date.now().toString();
|
|
11752
|
+
this.setItem(key, JSON.stringify(account), correlationId);
|
|
11753
|
+
this.addAccountKeyToMap(key, correlationId);
|
|
11701
11754
|
}
|
|
11702
11755
|
/**
|
|
11703
11756
|
* Returns the array of account keys currently cached
|
|
@@ -11716,14 +11769,14 @@
|
|
|
11716
11769
|
* Add a new account to the key map
|
|
11717
11770
|
* @param key
|
|
11718
11771
|
*/
|
|
11719
|
-
addAccountKeyToMap(key) {
|
|
11772
|
+
addAccountKeyToMap(key, correlationId) {
|
|
11720
11773
|
this.logger.trace("BrowserCacheManager.addAccountKeyToMap called");
|
|
11721
11774
|
this.logger.tracePii(`BrowserCacheManager.addAccountKeyToMap called with key: ${key}`);
|
|
11722
11775
|
const accountKeys = this.getAccountKeys();
|
|
11723
11776
|
if (accountKeys.indexOf(key) === -1) {
|
|
11724
11777
|
// Only add key if it does not already exist in the map
|
|
11725
11778
|
accountKeys.push(key);
|
|
11726
|
-
this.setItem(StaticCacheKeys.ACCOUNT_KEYS, JSON.stringify(accountKeys));
|
|
11779
|
+
this.setItem(StaticCacheKeys.ACCOUNT_KEYS, JSON.stringify(accountKeys), correlationId);
|
|
11727
11780
|
this.logger.verbose("BrowserCacheManager.addAccountKeyToMap account key added");
|
|
11728
11781
|
}
|
|
11729
11782
|
else {
|
|
@@ -11734,14 +11787,21 @@
|
|
|
11734
11787
|
* Remove an account from the key map
|
|
11735
11788
|
* @param key
|
|
11736
11789
|
*/
|
|
11737
|
-
removeAccountKeyFromMap(key) {
|
|
11790
|
+
removeAccountKeyFromMap(key, correlationId) {
|
|
11738
11791
|
this.logger.trace("BrowserCacheManager.removeAccountKeyFromMap called");
|
|
11739
11792
|
this.logger.tracePii(`BrowserCacheManager.removeAccountKeyFromMap called with key: ${key}`);
|
|
11740
11793
|
const accountKeys = this.getAccountKeys();
|
|
11741
11794
|
const removalIndex = accountKeys.indexOf(key);
|
|
11742
11795
|
if (removalIndex > -1) {
|
|
11743
11796
|
accountKeys.splice(removalIndex, 1);
|
|
11744
|
-
|
|
11797
|
+
if (accountKeys.length === 0) {
|
|
11798
|
+
// If no keys left, remove the map
|
|
11799
|
+
this.removeItem(StaticCacheKeys.ACCOUNT_KEYS);
|
|
11800
|
+
return;
|
|
11801
|
+
}
|
|
11802
|
+
else {
|
|
11803
|
+
this.setItem(StaticCacheKeys.ACCOUNT_KEYS, JSON.stringify(accountKeys), correlationId);
|
|
11804
|
+
}
|
|
11745
11805
|
this.logger.trace("BrowserCacheManager.removeAccountKeyFromMap account key removed");
|
|
11746
11806
|
}
|
|
11747
11807
|
else {
|
|
@@ -11752,41 +11812,60 @@
|
|
|
11752
11812
|
* Extends inherited removeAccount function to include removal of the account key from the map
|
|
11753
11813
|
* @param key
|
|
11754
11814
|
*/
|
|
11755
|
-
async removeAccount(key) {
|
|
11756
|
-
void super.removeAccount(key);
|
|
11757
|
-
this.removeAccountKeyFromMap(key);
|
|
11815
|
+
async removeAccount(key, correlationId) {
|
|
11816
|
+
void super.removeAccount(key, correlationId);
|
|
11817
|
+
this.removeAccountKeyFromMap(key, correlationId);
|
|
11758
11818
|
}
|
|
11759
11819
|
/**
|
|
11760
11820
|
* Remove account entity from the platform cache if it's outdated
|
|
11761
11821
|
* @param accountKey
|
|
11762
11822
|
*/
|
|
11763
|
-
removeOutdatedAccount(accountKey) {
|
|
11823
|
+
removeOutdatedAccount(accountKey, correlationId) {
|
|
11764
11824
|
this.removeItem(accountKey);
|
|
11765
|
-
this.removeAccountKeyFromMap(accountKey);
|
|
11825
|
+
this.removeAccountKeyFromMap(accountKey, correlationId);
|
|
11766
11826
|
}
|
|
11767
11827
|
/**
|
|
11768
11828
|
* Removes given idToken from the cache and from the key map
|
|
11769
11829
|
* @param key
|
|
11770
11830
|
*/
|
|
11771
|
-
removeIdToken(key) {
|
|
11772
|
-
super.removeIdToken(key);
|
|
11773
|
-
this.removeTokenKey(key, CredentialType.ID_TOKEN);
|
|
11831
|
+
removeIdToken(key, correlationId) {
|
|
11832
|
+
super.removeIdToken(key, correlationId);
|
|
11833
|
+
this.removeTokenKey(key, CredentialType.ID_TOKEN, correlationId);
|
|
11774
11834
|
}
|
|
11775
11835
|
/**
|
|
11776
11836
|
* Removes given accessToken from the cache and from the key map
|
|
11777
11837
|
* @param key
|
|
11778
11838
|
*/
|
|
11779
|
-
|
|
11780
|
-
|
|
11781
|
-
this.
|
|
11839
|
+
removeAccessToken(key, correlationId, updateTokenKeys = true) {
|
|
11840
|
+
super.removeAccessToken(key, correlationId);
|
|
11841
|
+
this.performanceClient?.incrementFields({ accessTokensRemoved: 1 }, correlationId);
|
|
11842
|
+
updateTokenKeys &&
|
|
11843
|
+
this.removeTokenKey(key, CredentialType.ACCESS_TOKEN, correlationId);
|
|
11844
|
+
}
|
|
11845
|
+
removeAccessTokenKeys(keys, correlationId) {
|
|
11846
|
+
this.logger.trace("removeAccessTokenKey called");
|
|
11847
|
+
const tokenKeys = this.getTokenKeys();
|
|
11848
|
+
let keysRemoved = 0;
|
|
11849
|
+
keys.forEach((key) => {
|
|
11850
|
+
const accessRemoval = tokenKeys.accessToken.indexOf(key);
|
|
11851
|
+
if (accessRemoval > -1) {
|
|
11852
|
+
tokenKeys.accessToken.splice(accessRemoval, 1);
|
|
11853
|
+
keysRemoved++;
|
|
11854
|
+
}
|
|
11855
|
+
});
|
|
11856
|
+
if (keysRemoved > 0) {
|
|
11857
|
+
this.logger.info(`removed ${keysRemoved} accessToken keys from tokenKeys map`);
|
|
11858
|
+
this.setTokenKeys(tokenKeys, correlationId);
|
|
11859
|
+
return;
|
|
11860
|
+
}
|
|
11782
11861
|
}
|
|
11783
11862
|
/**
|
|
11784
11863
|
* Removes given refreshToken from the cache and from the key map
|
|
11785
11864
|
* @param key
|
|
11786
11865
|
*/
|
|
11787
|
-
removeRefreshToken(key) {
|
|
11788
|
-
super.removeRefreshToken(key);
|
|
11789
|
-
this.removeTokenKey(key, CredentialType.REFRESH_TOKEN);
|
|
11866
|
+
removeRefreshToken(key, correlationId) {
|
|
11867
|
+
super.removeRefreshToken(key, correlationId);
|
|
11868
|
+
this.removeTokenKey(key, CredentialType.REFRESH_TOKEN, correlationId);
|
|
11790
11869
|
}
|
|
11791
11870
|
/**
|
|
11792
11871
|
* Gets the keys for the cached tokens associated with this clientId
|
|
@@ -11816,12 +11895,30 @@
|
|
|
11816
11895
|
refreshToken: [],
|
|
11817
11896
|
};
|
|
11818
11897
|
}
|
|
11898
|
+
/**
|
|
11899
|
+
* Stores the token keys in the cache
|
|
11900
|
+
* @param tokenKeys
|
|
11901
|
+
* @param correlationId
|
|
11902
|
+
* @returns
|
|
11903
|
+
*/
|
|
11904
|
+
setTokenKeys(tokenKeys, correlationId) {
|
|
11905
|
+
if (tokenKeys.idToken.length === 0 &&
|
|
11906
|
+
tokenKeys.accessToken.length === 0 &&
|
|
11907
|
+
tokenKeys.refreshToken.length === 0) {
|
|
11908
|
+
// If no keys left, remove the map
|
|
11909
|
+
this.removeItem(`${StaticCacheKeys.TOKEN_KEYS}.${this.clientId}`);
|
|
11910
|
+
return;
|
|
11911
|
+
}
|
|
11912
|
+
else {
|
|
11913
|
+
this.setItem(`${StaticCacheKeys.TOKEN_KEYS}.${this.clientId}`, JSON.stringify(tokenKeys), correlationId);
|
|
11914
|
+
}
|
|
11915
|
+
}
|
|
11819
11916
|
/**
|
|
11820
11917
|
* Adds the given key to the token key map
|
|
11821
11918
|
* @param key
|
|
11822
11919
|
* @param type
|
|
11823
11920
|
*/
|
|
11824
|
-
addTokenKey(key, type) {
|
|
11921
|
+
addTokenKey(key, type, correlationId) {
|
|
11825
11922
|
this.logger.trace("BrowserCacheManager addTokenKey called");
|
|
11826
11923
|
const tokenKeys = this.getTokenKeys();
|
|
11827
11924
|
switch (type) {
|
|
@@ -11832,10 +11929,12 @@
|
|
|
11832
11929
|
}
|
|
11833
11930
|
break;
|
|
11834
11931
|
case CredentialType.ACCESS_TOKEN:
|
|
11835
|
-
|
|
11836
|
-
|
|
11837
|
-
tokenKeys.accessToken.
|
|
11932
|
+
const index = tokenKeys.accessToken.indexOf(key);
|
|
11933
|
+
if (index !== -1) {
|
|
11934
|
+
tokenKeys.accessToken.splice(index, 1); // Remove existing key before pushing to the end
|
|
11838
11935
|
}
|
|
11936
|
+
this.logger.trace(`access token ${index === -1 ? "added to" : "updated in"} map`);
|
|
11937
|
+
tokenKeys.accessToken.push(key);
|
|
11839
11938
|
break;
|
|
11840
11939
|
case CredentialType.REFRESH_TOKEN:
|
|
11841
11940
|
if (tokenKeys.refreshToken.indexOf(key) === -1) {
|
|
@@ -11847,16 +11946,15 @@
|
|
|
11847
11946
|
this.logger.error(`BrowserCacheManager:addTokenKey - CredentialType provided invalid. CredentialType: ${type}`);
|
|
11848
11947
|
throw createClientAuthError(unexpectedCredentialType);
|
|
11849
11948
|
}
|
|
11850
|
-
this.
|
|
11949
|
+
this.setTokenKeys(tokenKeys, correlationId);
|
|
11851
11950
|
}
|
|
11852
11951
|
/**
|
|
11853
11952
|
* Removes the given key from the token key map
|
|
11854
11953
|
* @param key
|
|
11855
11954
|
* @param type
|
|
11856
11955
|
*/
|
|
11857
|
-
removeTokenKey(key, type) {
|
|
11956
|
+
removeTokenKey(key, type, correlationId, tokenKeys = this.getTokenKeys()) {
|
|
11858
11957
|
this.logger.trace("BrowserCacheManager removeTokenKey called");
|
|
11859
|
-
const tokenKeys = this.getTokenKeys();
|
|
11860
11958
|
switch (type) {
|
|
11861
11959
|
case CredentialType.ID_TOKEN:
|
|
11862
11960
|
this.logger.infoPii(`BrowserCacheManager: removeTokenKey - attempting to remove idToken with key: ${key} from map`);
|
|
@@ -11895,23 +11993,22 @@
|
|
|
11895
11993
|
this.logger.error(`BrowserCacheManager:removeTokenKey - CredentialType provided invalid. CredentialType: ${type}`);
|
|
11896
11994
|
throw createClientAuthError(unexpectedCredentialType);
|
|
11897
11995
|
}
|
|
11898
|
-
this.
|
|
11996
|
+
this.setTokenKeys(tokenKeys, correlationId);
|
|
11899
11997
|
}
|
|
11900
11998
|
/**
|
|
11901
11999
|
* generates idToken entity from a string
|
|
11902
12000
|
* @param idTokenKey
|
|
11903
12001
|
*/
|
|
11904
|
-
getIdTokenCredential(idTokenKey) {
|
|
12002
|
+
getIdTokenCredential(idTokenKey, correlationId) {
|
|
11905
12003
|
const value = this.getItem(idTokenKey);
|
|
11906
12004
|
if (!value) {
|
|
11907
12005
|
this.logger.trace("BrowserCacheManager.getIdTokenCredential: called, no cache hit");
|
|
11908
|
-
this.
|
|
12006
|
+
this.removeIdToken(idTokenKey, correlationId);
|
|
11909
12007
|
return null;
|
|
11910
12008
|
}
|
|
11911
12009
|
const parsedIdToken = this.validateAndParseJson(value);
|
|
11912
12010
|
if (!parsedIdToken || !isIdTokenEntity(parsedIdToken)) {
|
|
11913
12011
|
this.logger.trace("BrowserCacheManager.getIdTokenCredential: called, no cache hit");
|
|
11914
|
-
this.removeTokenKey(idTokenKey, CredentialType.ID_TOKEN);
|
|
11915
12012
|
return null;
|
|
11916
12013
|
}
|
|
11917
12014
|
this.logger.trace("BrowserCacheManager.getIdTokenCredential: cache hit");
|
|
@@ -11921,28 +12018,28 @@
|
|
|
11921
12018
|
* set IdToken credential to the platform cache
|
|
11922
12019
|
* @param idToken
|
|
11923
12020
|
*/
|
|
11924
|
-
setIdTokenCredential(idToken) {
|
|
12021
|
+
setIdTokenCredential(idToken, correlationId) {
|
|
11925
12022
|
this.logger.trace("BrowserCacheManager.setIdTokenCredential called");
|
|
11926
12023
|
const idTokenKey = generateCredentialKey(idToken);
|
|
11927
|
-
|
|
11928
|
-
this.
|
|
12024
|
+
idToken.lastUpdatedAt = Date.now().toString();
|
|
12025
|
+
this.setItem(idTokenKey, JSON.stringify(idToken), correlationId);
|
|
12026
|
+
this.addTokenKey(idTokenKey, CredentialType.ID_TOKEN, correlationId);
|
|
11929
12027
|
}
|
|
11930
12028
|
/**
|
|
11931
12029
|
* generates accessToken entity from a string
|
|
11932
12030
|
* @param key
|
|
11933
12031
|
*/
|
|
11934
|
-
getAccessTokenCredential(accessTokenKey) {
|
|
12032
|
+
getAccessTokenCredential(accessTokenKey, correlationId) {
|
|
11935
12033
|
const value = this.getItem(accessTokenKey);
|
|
11936
12034
|
if (!value) {
|
|
11937
12035
|
this.logger.trace("BrowserCacheManager.getAccessTokenCredential: called, no cache hit");
|
|
11938
|
-
this.removeTokenKey(accessTokenKey, CredentialType.ACCESS_TOKEN);
|
|
12036
|
+
this.removeTokenKey(accessTokenKey, CredentialType.ACCESS_TOKEN, correlationId);
|
|
11939
12037
|
return null;
|
|
11940
12038
|
}
|
|
11941
12039
|
const parsedAccessToken = this.validateAndParseJson(value);
|
|
11942
12040
|
if (!parsedAccessToken ||
|
|
11943
12041
|
!isAccessTokenEntity(parsedAccessToken)) {
|
|
11944
12042
|
this.logger.trace("BrowserCacheManager.getAccessTokenCredential: called, no cache hit");
|
|
11945
|
-
this.removeTokenKey(accessTokenKey, CredentialType.ACCESS_TOKEN);
|
|
11946
12043
|
return null;
|
|
11947
12044
|
}
|
|
11948
12045
|
this.logger.trace("BrowserCacheManager.getAccessTokenCredential: cache hit");
|
|
@@ -11952,28 +12049,28 @@
|
|
|
11952
12049
|
* set accessToken credential to the platform cache
|
|
11953
12050
|
* @param accessToken
|
|
11954
12051
|
*/
|
|
11955
|
-
setAccessTokenCredential(accessToken) {
|
|
12052
|
+
setAccessTokenCredential(accessToken, correlationId) {
|
|
11956
12053
|
this.logger.trace("BrowserCacheManager.setAccessTokenCredential called");
|
|
11957
12054
|
const accessTokenKey = generateCredentialKey(accessToken);
|
|
11958
|
-
|
|
11959
|
-
this.
|
|
12055
|
+
accessToken.lastUpdatedAt = Date.now().toString();
|
|
12056
|
+
this.setItem(accessTokenKey, JSON.stringify(accessToken), correlationId);
|
|
12057
|
+
this.addTokenKey(accessTokenKey, CredentialType.ACCESS_TOKEN, correlationId);
|
|
11960
12058
|
}
|
|
11961
12059
|
/**
|
|
11962
12060
|
* generates refreshToken entity from a string
|
|
11963
12061
|
* @param refreshTokenKey
|
|
11964
12062
|
*/
|
|
11965
|
-
getRefreshTokenCredential(refreshTokenKey) {
|
|
12063
|
+
getRefreshTokenCredential(refreshTokenKey, correlationId) {
|
|
11966
12064
|
const value = this.getItem(refreshTokenKey);
|
|
11967
12065
|
if (!value) {
|
|
11968
12066
|
this.logger.trace("BrowserCacheManager.getRefreshTokenCredential: called, no cache hit");
|
|
11969
|
-
this.removeTokenKey(refreshTokenKey, CredentialType.REFRESH_TOKEN);
|
|
12067
|
+
this.removeTokenKey(refreshTokenKey, CredentialType.REFRESH_TOKEN, correlationId);
|
|
11970
12068
|
return null;
|
|
11971
12069
|
}
|
|
11972
12070
|
const parsedRefreshToken = this.validateAndParseJson(value);
|
|
11973
12071
|
if (!parsedRefreshToken ||
|
|
11974
12072
|
!isRefreshTokenEntity(parsedRefreshToken)) {
|
|
11975
12073
|
this.logger.trace("BrowserCacheManager.getRefreshTokenCredential: called, no cache hit");
|
|
11976
|
-
this.removeTokenKey(refreshTokenKey, CredentialType.REFRESH_TOKEN);
|
|
11977
12074
|
return null;
|
|
11978
12075
|
}
|
|
11979
12076
|
this.logger.trace("BrowserCacheManager.getRefreshTokenCredential: cache hit");
|
|
@@ -11983,11 +12080,12 @@
|
|
|
11983
12080
|
* set refreshToken credential to the platform cache
|
|
11984
12081
|
* @param refreshToken
|
|
11985
12082
|
*/
|
|
11986
|
-
setRefreshTokenCredential(refreshToken) {
|
|
12083
|
+
setRefreshTokenCredential(refreshToken, correlationId) {
|
|
11987
12084
|
this.logger.trace("BrowserCacheManager.setRefreshTokenCredential called");
|
|
11988
12085
|
const refreshTokenKey = generateCredentialKey(refreshToken);
|
|
11989
|
-
|
|
11990
|
-
this.
|
|
12086
|
+
refreshToken.lastUpdatedAt = Date.now().toString();
|
|
12087
|
+
this.setItem(refreshTokenKey, JSON.stringify(refreshToken), correlationId);
|
|
12088
|
+
this.addTokenKey(refreshTokenKey, CredentialType.REFRESH_TOKEN, correlationId);
|
|
11991
12089
|
}
|
|
11992
12090
|
/**
|
|
11993
12091
|
* fetch appMetadata entity from the platform cache
|
|
@@ -12012,10 +12110,10 @@
|
|
|
12012
12110
|
* set appMetadata entity to the platform cache
|
|
12013
12111
|
* @param appMetadata
|
|
12014
12112
|
*/
|
|
12015
|
-
setAppMetadata(appMetadata) {
|
|
12113
|
+
setAppMetadata(appMetadata, correlationId) {
|
|
12016
12114
|
this.logger.trace("BrowserCacheManager.setAppMetadata called");
|
|
12017
12115
|
const appMetadataKey = generateAppMetadataKey(appMetadata);
|
|
12018
|
-
this.setItem(appMetadataKey, JSON.stringify(appMetadata));
|
|
12116
|
+
this.setItem(appMetadataKey, JSON.stringify(appMetadata), correlationId);
|
|
12019
12117
|
}
|
|
12020
12118
|
/**
|
|
12021
12119
|
* fetch server telemetry entity from the platform cache
|
|
@@ -12041,9 +12139,9 @@
|
|
|
12041
12139
|
* @param serverTelemetryKey
|
|
12042
12140
|
* @param serverTelemetry
|
|
12043
12141
|
*/
|
|
12044
|
-
setServerTelemetry(serverTelemetryKey, serverTelemetry) {
|
|
12142
|
+
setServerTelemetry(serverTelemetryKey, serverTelemetry, correlationId) {
|
|
12045
12143
|
this.logger.trace("BrowserCacheManager.setServerTelemetry called");
|
|
12046
|
-
this.setItem(serverTelemetryKey, JSON.stringify(serverTelemetry));
|
|
12144
|
+
this.setItem(serverTelemetryKey, JSON.stringify(serverTelemetry), correlationId);
|
|
12047
12145
|
}
|
|
12048
12146
|
/**
|
|
12049
12147
|
*
|
|
@@ -12101,7 +12199,7 @@
|
|
|
12101
12199
|
/**
|
|
12102
12200
|
* Gets the active account
|
|
12103
12201
|
*/
|
|
12104
|
-
getActiveAccount() {
|
|
12202
|
+
getActiveAccount(correlationId) {
|
|
12105
12203
|
const activeAccountKeyFilters = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT_FILTERS);
|
|
12106
12204
|
const activeAccountValueFilters = this.getItem(activeAccountKeyFilters);
|
|
12107
12205
|
if (!activeAccountValueFilters) {
|
|
@@ -12115,11 +12213,11 @@
|
|
|
12115
12213
|
}
|
|
12116
12214
|
const activeAccount = this.getAccountInfoFilteredBy({
|
|
12117
12215
|
localAccountId: activeAccountValueLocal,
|
|
12118
|
-
});
|
|
12216
|
+
}, correlationId);
|
|
12119
12217
|
if (activeAccount) {
|
|
12120
12218
|
this.logger.trace("BrowserCacheManager.getActiveAccount: Legacy active account cache schema found");
|
|
12121
12219
|
this.logger.trace("BrowserCacheManager.getActiveAccount: Adding active account filters cache schema");
|
|
12122
|
-
this.setActiveAccount(activeAccount);
|
|
12220
|
+
this.setActiveAccount(activeAccount, correlationId);
|
|
12123
12221
|
return activeAccount;
|
|
12124
12222
|
}
|
|
12125
12223
|
return null;
|
|
@@ -12131,7 +12229,7 @@
|
|
|
12131
12229
|
homeAccountId: activeAccountValueObj.homeAccountId,
|
|
12132
12230
|
localAccountId: activeAccountValueObj.localAccountId,
|
|
12133
12231
|
tenantId: activeAccountValueObj.tenantId,
|
|
12134
|
-
});
|
|
12232
|
+
}, correlationId);
|
|
12135
12233
|
}
|
|
12136
12234
|
this.logger.trace("BrowserCacheManager.getActiveAccount: No active account found");
|
|
12137
12235
|
return null;
|
|
@@ -12140,7 +12238,7 @@
|
|
|
12140
12238
|
* Sets the active account's localAccountId in cache
|
|
12141
12239
|
* @param account
|
|
12142
12240
|
*/
|
|
12143
|
-
setActiveAccount(account) {
|
|
12241
|
+
setActiveAccount(account, correlationId) {
|
|
12144
12242
|
const activeAccountKey = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT_FILTERS);
|
|
12145
12243
|
const activeAccountKeyLocal = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT);
|
|
12146
12244
|
if (account) {
|
|
@@ -12149,9 +12247,10 @@
|
|
|
12149
12247
|
homeAccountId: account.homeAccountId,
|
|
12150
12248
|
localAccountId: account.localAccountId,
|
|
12151
12249
|
tenantId: account.tenantId,
|
|
12250
|
+
lastUpdatedAt: Date.now().toString(),
|
|
12152
12251
|
};
|
|
12153
|
-
this.
|
|
12154
|
-
this.
|
|
12252
|
+
this.setItem(activeAccountKey, JSON.stringify(activeAccountValue), correlationId);
|
|
12253
|
+
this.setItem(activeAccountKeyLocal, account.localAccountId, correlationId);
|
|
12155
12254
|
}
|
|
12156
12255
|
else {
|
|
12157
12256
|
this.logger.verbose("setActiveAccount: No account passed, active account not set");
|
|
@@ -12183,9 +12282,9 @@
|
|
|
12183
12282
|
* @param throttlingCacheKey
|
|
12184
12283
|
* @param throttlingCache
|
|
12185
12284
|
*/
|
|
12186
|
-
setThrottlingCache(throttlingCacheKey, throttlingCache) {
|
|
12285
|
+
setThrottlingCache(throttlingCacheKey, throttlingCache, correlationId) {
|
|
12187
12286
|
this.logger.trace("BrowserCacheManager.setThrottlingCache called");
|
|
12188
|
-
this.setItem(throttlingCacheKey, JSON.stringify(throttlingCache));
|
|
12287
|
+
this.setItem(throttlingCacheKey, JSON.stringify(throttlingCache), correlationId);
|
|
12189
12288
|
}
|
|
12190
12289
|
/**
|
|
12191
12290
|
* Gets cache item with given key.
|
|
@@ -12261,10 +12360,10 @@
|
|
|
12261
12360
|
/**
|
|
12262
12361
|
* Clears all cache entries created by MSAL.
|
|
12263
12362
|
*/
|
|
12264
|
-
async clear() {
|
|
12363
|
+
async clear(correlationId) {
|
|
12265
12364
|
// Removes all accounts and their credentials
|
|
12266
|
-
await this.removeAllAccounts();
|
|
12267
|
-
this.removeAppMetadata();
|
|
12365
|
+
await this.removeAllAccounts(correlationId);
|
|
12366
|
+
this.removeAppMetadata(correlationId);
|
|
12268
12367
|
// Remove temp storage first to make sure any cookies are cleared
|
|
12269
12368
|
this.temporaryCacheStorage.getKeys().forEach((cacheKey) => {
|
|
12270
12369
|
if (cacheKey.indexOf(Constants.CACHE_PREFIX) !== -1 ||
|
|
@@ -12290,19 +12389,19 @@
|
|
|
12290
12389
|
async clearTokensAndKeysWithClaims(performanceClient, correlationId) {
|
|
12291
12390
|
performanceClient.addQueueMeasurement(PerformanceEvents.ClearTokensAndKeysWithClaims, correlationId);
|
|
12292
12391
|
const tokenKeys = this.getTokenKeys();
|
|
12293
|
-
|
|
12392
|
+
let removedAccessTokens = 0;
|
|
12294
12393
|
tokenKeys.accessToken.forEach((key) => {
|
|
12295
12394
|
// if the access token has claims in its key, remove the token key and the token
|
|
12296
|
-
const credential = this.getAccessTokenCredential(key);
|
|
12395
|
+
const credential = this.getAccessTokenCredential(key, correlationId);
|
|
12297
12396
|
if (credential?.requestedClaimsHash &&
|
|
12298
12397
|
key.includes(credential.requestedClaimsHash.toLowerCase())) {
|
|
12299
|
-
|
|
12398
|
+
this.removeAccessToken(key, correlationId);
|
|
12399
|
+
removedAccessTokens++;
|
|
12300
12400
|
}
|
|
12301
12401
|
});
|
|
12302
|
-
await Promise.all(removedAccessTokens);
|
|
12303
12402
|
// warn if any access tokens are removed
|
|
12304
|
-
if (removedAccessTokens
|
|
12305
|
-
this.logger.warning(`${removedAccessTokens
|
|
12403
|
+
if (removedAccessTokens > 0) {
|
|
12404
|
+
this.logger.warning(`${removedAccessTokens} access tokens with claims in the cache keys have been removed from the cache.`);
|
|
12306
12405
|
}
|
|
12307
12406
|
}
|
|
12308
12407
|
/**
|
|
@@ -12577,13 +12676,13 @@
|
|
|
12577
12676
|
/**
|
|
12578
12677
|
* Updates a credential's cache key if the current cache key is outdated
|
|
12579
12678
|
*/
|
|
12580
|
-
updateCredentialCacheKey(currentCacheKey, credential) {
|
|
12679
|
+
updateCredentialCacheKey(currentCacheKey, credential, correlationId) {
|
|
12581
12680
|
const updatedCacheKey = generateCredentialKey(credential);
|
|
12582
12681
|
if (currentCacheKey !== updatedCacheKey) {
|
|
12583
12682
|
const cacheItem = this.getItem(currentCacheKey);
|
|
12584
12683
|
if (cacheItem) {
|
|
12585
12684
|
this.browserStorage.removeItem(currentCacheKey);
|
|
12586
|
-
this.setItem(updatedCacheKey, cacheItem);
|
|
12685
|
+
this.setItem(updatedCacheKey, cacheItem, correlationId);
|
|
12587
12686
|
this.logger.verbose(`Updated an outdated ${credential.credentialType} cache key`);
|
|
12588
12687
|
return updatedCacheKey;
|
|
12589
12688
|
}
|
|
@@ -12618,7 +12717,7 @@
|
|
|
12618
12717
|
idToken: idTokenEntity,
|
|
12619
12718
|
accessToken: accessTokenEntity,
|
|
12620
12719
|
};
|
|
12621
|
-
return this.saveCacheRecord(cacheRecord);
|
|
12720
|
+
return this.saveCacheRecord(cacheRecord, result.correlationId);
|
|
12622
12721
|
}
|
|
12623
12722
|
/**
|
|
12624
12723
|
* saves a cache record
|
|
@@ -12626,9 +12725,9 @@
|
|
|
12626
12725
|
* @param storeInCache {?StoreInCache}
|
|
12627
12726
|
* @param correlationId {?string} correlation id
|
|
12628
12727
|
*/
|
|
12629
|
-
async saveCacheRecord(cacheRecord,
|
|
12728
|
+
async saveCacheRecord(cacheRecord, correlationId, storeInCache) {
|
|
12630
12729
|
try {
|
|
12631
|
-
await super.saveCacheRecord(cacheRecord,
|
|
12730
|
+
await super.saveCacheRecord(cacheRecord, correlationId, storeInCache);
|
|
12632
12731
|
}
|
|
12633
12732
|
catch (e) {
|
|
12634
12733
|
if (e instanceof CacheError &&
|
|
@@ -12669,22 +12768,24 @@
|
|
|
12669
12768
|
* @param accountFilter - (Optional) filter to narrow down the accounts returned
|
|
12670
12769
|
* @returns Array of AccountInfo objects in cache
|
|
12671
12770
|
*/
|
|
12672
|
-
function getAllAccounts(logger, browserStorage, isInBrowser, accountFilter) {
|
|
12771
|
+
function getAllAccounts(logger, browserStorage, isInBrowser, correlationId, accountFilter) {
|
|
12673
12772
|
logger.verbose("getAllAccounts called");
|
|
12674
|
-
return isInBrowser
|
|
12773
|
+
return isInBrowser
|
|
12774
|
+
? browserStorage.getAllAccounts(correlationId, accountFilter)
|
|
12775
|
+
: [];
|
|
12675
12776
|
}
|
|
12676
12777
|
/**
|
|
12677
12778
|
* Returns the first account found in the cache that matches the account filter passed in.
|
|
12678
12779
|
* @param accountFilter
|
|
12679
12780
|
* @returns The first account found in the cache matching the provided filter or null if no account could be found.
|
|
12680
12781
|
*/
|
|
12681
|
-
function getAccount(accountFilter, logger, browserStorage) {
|
|
12782
|
+
function getAccount(accountFilter, logger, browserStorage, correlationId) {
|
|
12682
12783
|
logger.trace("getAccount called");
|
|
12683
12784
|
if (Object.keys(accountFilter).length === 0) {
|
|
12684
12785
|
logger.warning("getAccount: No accountFilter provided");
|
|
12685
12786
|
return null;
|
|
12686
12787
|
}
|
|
12687
|
-
const account = browserStorage.getAccountInfoFilteredBy(accountFilter);
|
|
12788
|
+
const account = browserStorage.getAccountInfoFilteredBy(accountFilter, correlationId);
|
|
12688
12789
|
if (account) {
|
|
12689
12790
|
logger.verbose("getAccount: Account matching provided filter found, returning");
|
|
12690
12791
|
return account;
|
|
@@ -12702,7 +12803,7 @@
|
|
|
12702
12803
|
* @param username
|
|
12703
12804
|
* @returns The account object stored in MSAL
|
|
12704
12805
|
*/
|
|
12705
|
-
function getAccountByUsername(username, logger, browserStorage) {
|
|
12806
|
+
function getAccountByUsername(username, logger, browserStorage, correlationId) {
|
|
12706
12807
|
logger.trace("getAccountByUsername called");
|
|
12707
12808
|
if (!username) {
|
|
12708
12809
|
logger.warning("getAccountByUsername: No username provided");
|
|
@@ -12710,7 +12811,7 @@
|
|
|
12710
12811
|
}
|
|
12711
12812
|
const account = browserStorage.getAccountInfoFilteredBy({
|
|
12712
12813
|
username,
|
|
12713
|
-
});
|
|
12814
|
+
}, correlationId);
|
|
12714
12815
|
if (account) {
|
|
12715
12816
|
logger.verbose("getAccountByUsername: Account matching username found, returning");
|
|
12716
12817
|
logger.verbosePii(`getAccountByUsername: Returning signed-in accounts matching username: ${username}`);
|
|
@@ -12728,7 +12829,7 @@
|
|
|
12728
12829
|
* @param homeAccountId
|
|
12729
12830
|
* @returns The account object stored in MSAL
|
|
12730
12831
|
*/
|
|
12731
|
-
function getAccountByHomeId(homeAccountId, logger, browserStorage) {
|
|
12832
|
+
function getAccountByHomeId(homeAccountId, logger, browserStorage, correlationId) {
|
|
12732
12833
|
logger.trace("getAccountByHomeId called");
|
|
12733
12834
|
if (!homeAccountId) {
|
|
12734
12835
|
logger.warning("getAccountByHomeId: No homeAccountId provided");
|
|
@@ -12736,7 +12837,7 @@
|
|
|
12736
12837
|
}
|
|
12737
12838
|
const account = browserStorage.getAccountInfoFilteredBy({
|
|
12738
12839
|
homeAccountId,
|
|
12739
|
-
});
|
|
12840
|
+
}, correlationId);
|
|
12740
12841
|
if (account) {
|
|
12741
12842
|
logger.verbose("getAccountByHomeId: Account matching homeAccountId found, returning");
|
|
12742
12843
|
logger.verbosePii(`getAccountByHomeId: Returning signed-in accounts matching homeAccountId: ${homeAccountId}`);
|
|
@@ -12754,7 +12855,7 @@
|
|
|
12754
12855
|
* @param localAccountId
|
|
12755
12856
|
* @returns The account object stored in MSAL
|
|
12756
12857
|
*/
|
|
12757
|
-
function getAccountByLocalId(localAccountId, logger, browserStorage) {
|
|
12858
|
+
function getAccountByLocalId(localAccountId, logger, browserStorage, correlationId) {
|
|
12758
12859
|
logger.trace("getAccountByLocalId called");
|
|
12759
12860
|
if (!localAccountId) {
|
|
12760
12861
|
logger.warning("getAccountByLocalId: No localAccountId provided");
|
|
@@ -12762,7 +12863,7 @@
|
|
|
12762
12863
|
}
|
|
12763
12864
|
const account = browserStorage.getAccountInfoFilteredBy({
|
|
12764
12865
|
localAccountId,
|
|
12765
|
-
});
|
|
12866
|
+
}, correlationId);
|
|
12766
12867
|
if (account) {
|
|
12767
12868
|
logger.verbose("getAccountByLocalId: Account matching localAccountId found, returning");
|
|
12768
12869
|
logger.verbosePii(`getAccountByLocalId: Returning signed-in accounts matching localAccountId: ${localAccountId}`);
|
|
@@ -12777,14 +12878,14 @@
|
|
|
12777
12878
|
* 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.
|
|
12778
12879
|
* @param account
|
|
12779
12880
|
*/
|
|
12780
|
-
function setActiveAccount(account, browserStorage) {
|
|
12781
|
-
browserStorage.setActiveAccount(account);
|
|
12881
|
+
function setActiveAccount(account, browserStorage, correlationId) {
|
|
12882
|
+
browserStorage.setActiveAccount(account, correlationId);
|
|
12782
12883
|
}
|
|
12783
12884
|
/**
|
|
12784
12885
|
* Gets the currently active account
|
|
12785
12886
|
*/
|
|
12786
|
-
function getActiveAccount(browserStorage) {
|
|
12787
|
-
return browserStorage.getActiveAccount();
|
|
12887
|
+
function getActiveAccount(browserStorage, correlationId) {
|
|
12888
|
+
return browserStorage.getActiveAccount(correlationId);
|
|
12788
12889
|
}
|
|
12789
12890
|
|
|
12790
12891
|
/*
|
|
@@ -12902,13 +13003,13 @@
|
|
|
12902
13003
|
}
|
|
12903
13004
|
async clearCacheOnLogout(account) {
|
|
12904
13005
|
if (account) {
|
|
12905
|
-
if (AccountEntity.accountInfoIsEqual(account, this.browserStorage.getActiveAccount(), false)) {
|
|
13006
|
+
if (AccountEntity.accountInfoIsEqual(account, this.browserStorage.getActiveAccount(this.correlationId), false)) {
|
|
12906
13007
|
this.logger.verbose("Setting active account to null");
|
|
12907
|
-
this.browserStorage.setActiveAccount(null);
|
|
13008
|
+
this.browserStorage.setActiveAccount(null, this.correlationId);
|
|
12908
13009
|
}
|
|
12909
13010
|
// Clear given account.
|
|
12910
13011
|
try {
|
|
12911
|
-
await this.browserStorage.removeAccount(AccountEntity.generateAccountCacheKey(account));
|
|
13012
|
+
await this.browserStorage.removeAccount(AccountEntity.generateAccountCacheKey(account), this.correlationId);
|
|
12912
13013
|
this.logger.verbose("Cleared cache items belonging to the account provided in the logout request.");
|
|
12913
13014
|
}
|
|
12914
13015
|
catch (error) {
|
|
@@ -12919,7 +13020,7 @@
|
|
|
12919
13020
|
try {
|
|
12920
13021
|
this.logger.verbose("No account provided in logout request, clearing all cache items.", this.correlationId);
|
|
12921
13022
|
// Clear all accounts and tokens
|
|
12922
|
-
await this.browserStorage.clear();
|
|
13023
|
+
await this.browserStorage.clear(this.correlationId);
|
|
12923
13024
|
// Clear any stray keys from IndexedDB
|
|
12924
13025
|
await this.browserCrypto.clearKeystore();
|
|
12925
13026
|
}
|
|
@@ -13313,7 +13414,8 @@
|
|
|
13313
13414
|
if (request.loginHint || request.sid) {
|
|
13314
13415
|
return validatedRequest;
|
|
13315
13416
|
}
|
|
13316
|
-
const account = request.account ||
|
|
13417
|
+
const account = request.account ||
|
|
13418
|
+
this.browserStorage.getActiveAccount(this.correlationId);
|
|
13317
13419
|
if (account) {
|
|
13318
13420
|
this.logger.verbose("Setting validated request account", this.correlationId);
|
|
13319
13421
|
this.logger.verbosePii(`Setting validated request account: ${account.homeAccountId}`, this.correlationId);
|
|
@@ -13586,7 +13688,7 @@
|
|
|
13586
13688
|
// fetch the account from browser cache
|
|
13587
13689
|
const account = this.browserStorage.getBaseAccountInfo({
|
|
13588
13690
|
nativeAccountId,
|
|
13589
|
-
});
|
|
13691
|
+
}, request.correlationId);
|
|
13590
13692
|
if (!account) {
|
|
13591
13693
|
throw createClientAuthError(noAccountFound);
|
|
13592
13694
|
}
|
|
@@ -13713,7 +13815,7 @@
|
|
|
13713
13815
|
const homeAccountIdentifier = this.createHomeAccountIdentifier(response, idTokenClaims);
|
|
13714
13816
|
const cachedhomeAccountId = this.browserStorage.getAccountInfoFilteredBy({
|
|
13715
13817
|
nativeAccountId: request.accountId,
|
|
13716
|
-
})?.homeAccountId;
|
|
13818
|
+
}, this.correlationId)?.homeAccountId;
|
|
13717
13819
|
if (homeAccountIdentifier !== cachedhomeAccountId &&
|
|
13718
13820
|
response.account.id !== request.accountId) {
|
|
13719
13821
|
// 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
|
|
@@ -13723,7 +13825,7 @@
|
|
|
13723
13825
|
const authority = await this.getDiscoveredAuthority({
|
|
13724
13826
|
requestAuthority: request.authority,
|
|
13725
13827
|
});
|
|
13726
|
-
const baseAccount = buildAccountToCache(this.browserStorage, authority, homeAccountIdentifier, base64Decode, idTokenClaims, response.client_info, undefined, // environment
|
|
13828
|
+
const baseAccount = buildAccountToCache(this.browserStorage, authority, homeAccountIdentifier, base64Decode, this.correlationId, idTokenClaims, response.client_info, undefined, // environment
|
|
13727
13829
|
idTokenClaims.tid, undefined, // auth code payload
|
|
13728
13830
|
response.account.id, this.logger);
|
|
13729
13831
|
// generate authenticationResult
|
|
@@ -13856,9 +13958,11 @@
|
|
|
13856
13958
|
*/
|
|
13857
13959
|
cacheAccount(accountEntity) {
|
|
13858
13960
|
// Store the account info and hence `nativeAccountId` in browser cache
|
|
13859
|
-
this.browserStorage.setAccount(accountEntity);
|
|
13961
|
+
this.browserStorage.setAccount(accountEntity, this.correlationId);
|
|
13860
13962
|
// Remove any existing cached tokens for this account in browser storage
|
|
13861
|
-
this.browserStorage
|
|
13963
|
+
this.browserStorage
|
|
13964
|
+
.removeAccountContext(accountEntity, this.correlationId)
|
|
13965
|
+
.catch((e) => {
|
|
13862
13966
|
this.logger.error(`Error occurred while removing account context from browser storage. ${e}`);
|
|
13863
13967
|
});
|
|
13864
13968
|
}
|
|
@@ -13887,7 +13991,7 @@
|
|
|
13887
13991
|
idToken: cachedIdToken,
|
|
13888
13992
|
accessToken: cachedAccessToken,
|
|
13889
13993
|
};
|
|
13890
|
-
void this.nativeStorageManager.saveCacheRecord(nativeCacheRecord, request.storeInCache);
|
|
13994
|
+
void this.nativeStorageManager.saveCacheRecord(nativeCacheRecord, request.correlationId, request.storeInCache);
|
|
13891
13995
|
}
|
|
13892
13996
|
addTelemetryFromNativeResponse(response) {
|
|
13893
13997
|
const mats = this.getMATSFromResponse(response);
|
|
@@ -14663,7 +14767,7 @@
|
|
|
14663
14767
|
if (validRequest.account?.homeAccountId &&
|
|
14664
14768
|
validRequest.postLogoutRedirectUri &&
|
|
14665
14769
|
authClient.authority.protocolMode === ProtocolMode.OIDC) {
|
|
14666
|
-
void this.browserStorage.removeAccount(validRequest.account?.homeAccountId);
|
|
14770
|
+
void this.browserStorage.removeAccount(validRequest.account?.homeAccountId, this.correlationId);
|
|
14667
14771
|
this.eventHandler.emitEvent(EventType.LOGOUT_SUCCESS, exports.InteractionType.Popup, validRequest);
|
|
14668
14772
|
if (mainWindowRedirectUri) {
|
|
14669
14773
|
const navigationOptions = {
|
|
@@ -15338,7 +15442,7 @@
|
|
|
15338
15442
|
}
|
|
15339
15443
|
catch {
|
|
15340
15444
|
if (validLogoutRequest.account?.homeAccountId) {
|
|
15341
|
-
void this.browserStorage.removeAccount(validLogoutRequest.account?.homeAccountId);
|
|
15445
|
+
void this.browserStorage.removeAccount(validLogoutRequest.account?.homeAccountId, this.correlationId);
|
|
15342
15446
|
this.eventHandler.emitEvent(EventType.LOGOUT_SUCCESS, exports.InteractionType.Redirect, validLogoutRequest);
|
|
15343
15447
|
return;
|
|
15344
15448
|
}
|
|
@@ -15738,6 +15842,7 @@
|
|
|
15738
15842
|
if (!this.isBrowserEnvironment) {
|
|
15739
15843
|
throw createBrowserAuthError(nonBrowserEnvironment);
|
|
15740
15844
|
}
|
|
15845
|
+
const correlationId = request.correlationId || createNewGuid();
|
|
15741
15846
|
const idTokenClaims = response.id_token
|
|
15742
15847
|
? extractTokenClaims(response.id_token, base64Decode)
|
|
15743
15848
|
: undefined;
|
|
@@ -15751,10 +15856,10 @@
|
|
|
15751
15856
|
const authority = request.authority
|
|
15752
15857
|
? new Authority(Authority.generateAuthority(request.authority, request.azureCloudOptions), this.config.system.networkClient, this.storage, authorityOptions, this.logger, request.correlationId || createNewGuid())
|
|
15753
15858
|
: undefined;
|
|
15754
|
-
const cacheRecordAccount = this.loadAccount(request, options.clientInfo || response.client_info || "", idTokenClaims, authority);
|
|
15755
|
-
const idToken = this.loadIdToken(response, cacheRecordAccount.homeAccountId, cacheRecordAccount.environment, cacheRecordAccount.realm);
|
|
15756
|
-
const accessToken = this.loadAccessToken(request, response, cacheRecordAccount.homeAccountId, cacheRecordAccount.environment, cacheRecordAccount.realm, options);
|
|
15757
|
-
const refreshToken = this.loadRefreshToken(response, cacheRecordAccount.homeAccountId, cacheRecordAccount.environment);
|
|
15859
|
+
const cacheRecordAccount = this.loadAccount(request, options.clientInfo || response.client_info || "", correlationId, idTokenClaims, authority);
|
|
15860
|
+
const idToken = this.loadIdToken(response, cacheRecordAccount.homeAccountId, cacheRecordAccount.environment, cacheRecordAccount.realm, correlationId);
|
|
15861
|
+
const accessToken = this.loadAccessToken(request, response, cacheRecordAccount.homeAccountId, cacheRecordAccount.environment, cacheRecordAccount.realm, options, correlationId);
|
|
15862
|
+
const refreshToken = this.loadRefreshToken(response, cacheRecordAccount.homeAccountId, cacheRecordAccount.environment, correlationId);
|
|
15758
15863
|
return this.generateAuthenticationResult(request, {
|
|
15759
15864
|
account: cacheRecordAccount,
|
|
15760
15865
|
idToken,
|
|
@@ -15771,11 +15876,11 @@
|
|
|
15771
15876
|
* @param requestHomeAccountId
|
|
15772
15877
|
* @returns `AccountEntity`
|
|
15773
15878
|
*/
|
|
15774
|
-
loadAccount(request, clientInfo, idTokenClaims, authority) {
|
|
15879
|
+
loadAccount(request, clientInfo, correlationId, idTokenClaims, authority) {
|
|
15775
15880
|
this.logger.verbose("TokenCache - loading account");
|
|
15776
15881
|
if (request.account) {
|
|
15777
15882
|
const accountEntity = AccountEntity.createFromAccountInfo(request.account);
|
|
15778
|
-
this.storage.setAccount(accountEntity);
|
|
15883
|
+
this.storage.setAccount(accountEntity, correlationId);
|
|
15779
15884
|
return accountEntity;
|
|
15780
15885
|
}
|
|
15781
15886
|
else if (!authority || (!clientInfo && !idTokenClaims)) {
|
|
@@ -15784,10 +15889,10 @@
|
|
|
15784
15889
|
}
|
|
15785
15890
|
const homeAccountId = AccountEntity.generateHomeAccountId(clientInfo, authority.authorityType, this.logger, this.cryptoObj, idTokenClaims);
|
|
15786
15891
|
const claimsTenantId = idTokenClaims?.tid;
|
|
15787
|
-
const cachedAccount = buildAccountToCache(this.storage, authority, homeAccountId, base64Decode, idTokenClaims, clientInfo, authority.hostnameAndPort, claimsTenantId, undefined, // authCodePayload
|
|
15892
|
+
const cachedAccount = buildAccountToCache(this.storage, authority, homeAccountId, base64Decode, correlationId, idTokenClaims, clientInfo, authority.hostnameAndPort, claimsTenantId, undefined, // authCodePayload
|
|
15788
15893
|
undefined, // nativeAccountId
|
|
15789
15894
|
this.logger);
|
|
15790
|
-
this.storage.setAccount(cachedAccount);
|
|
15895
|
+
this.storage.setAccount(cachedAccount, correlationId);
|
|
15791
15896
|
return cachedAccount;
|
|
15792
15897
|
}
|
|
15793
15898
|
/**
|
|
@@ -15798,14 +15903,14 @@
|
|
|
15798
15903
|
* @param tenantId
|
|
15799
15904
|
* @returns `IdTokenEntity`
|
|
15800
15905
|
*/
|
|
15801
|
-
loadIdToken(response, homeAccountId, environment, tenantId) {
|
|
15906
|
+
loadIdToken(response, homeAccountId, environment, tenantId, correlationId) {
|
|
15802
15907
|
if (!response.id_token) {
|
|
15803
15908
|
this.logger.verbose("TokenCache - no id token found in response");
|
|
15804
15909
|
return null;
|
|
15805
15910
|
}
|
|
15806
15911
|
this.logger.verbose("TokenCache - loading id token");
|
|
15807
15912
|
const idTokenEntity = createIdTokenEntity(homeAccountId, environment, response.id_token, this.config.auth.clientId, tenantId);
|
|
15808
|
-
this.storage.setIdTokenCredential(idTokenEntity);
|
|
15913
|
+
this.storage.setIdTokenCredential(idTokenEntity, correlationId);
|
|
15809
15914
|
return idTokenEntity;
|
|
15810
15915
|
}
|
|
15811
15916
|
/**
|
|
@@ -15817,7 +15922,7 @@
|
|
|
15817
15922
|
* @param tenantId
|
|
15818
15923
|
* @returns `AccessTokenEntity`
|
|
15819
15924
|
*/
|
|
15820
|
-
loadAccessToken(request, response, homeAccountId, environment, tenantId, options) {
|
|
15925
|
+
loadAccessToken(request, response, homeAccountId, environment, tenantId, options, correlationId) {
|
|
15821
15926
|
if (!response.access_token) {
|
|
15822
15927
|
this.logger.verbose("TokenCache - no access token found in response");
|
|
15823
15928
|
return null;
|
|
@@ -15841,7 +15946,7 @@
|
|
|
15841
15946
|
(response.ext_expires_in || response.expires_in) +
|
|
15842
15947
|
new Date().getTime() / 1000;
|
|
15843
15948
|
const accessTokenEntity = createAccessTokenEntity(homeAccountId, environment, response.access_token, this.config.auth.clientId, tenantId, scopes.printScopes(), expiresOn, extendedExpiresOn, base64Decode);
|
|
15844
|
-
this.storage.setAccessTokenCredential(accessTokenEntity);
|
|
15949
|
+
this.storage.setAccessTokenCredential(accessTokenEntity, correlationId);
|
|
15845
15950
|
return accessTokenEntity;
|
|
15846
15951
|
}
|
|
15847
15952
|
/**
|
|
@@ -15852,7 +15957,7 @@
|
|
|
15852
15957
|
* @param environment
|
|
15853
15958
|
* @returns `RefreshTokenEntity`
|
|
15854
15959
|
*/
|
|
15855
|
-
loadRefreshToken(response, homeAccountId, environment) {
|
|
15960
|
+
loadRefreshToken(response, homeAccountId, environment, correlationId) {
|
|
15856
15961
|
if (!response.refresh_token) {
|
|
15857
15962
|
this.logger.verbose("TokenCache - no refresh token found in response");
|
|
15858
15963
|
return null;
|
|
@@ -15860,7 +15965,7 @@
|
|
|
15860
15965
|
this.logger.verbose("TokenCache - loading refresh token");
|
|
15861
15966
|
const refreshTokenEntity = createRefreshTokenEntity(homeAccountId, environment, response.refresh_token, this.config.auth.clientId, response.foci, undefined, // userAssertionHash
|
|
15862
15967
|
response.refresh_token_expires_in);
|
|
15863
|
-
this.storage.setRefreshTokenCredential(refreshTokenEntity);
|
|
15968
|
+
this.storage.setRefreshTokenCredential(refreshTokenEntity, correlationId);
|
|
15864
15969
|
return refreshTokenEntity;
|
|
15865
15970
|
}
|
|
15866
15971
|
/**
|
|
@@ -16769,7 +16874,8 @@
|
|
|
16769
16874
|
* @returns Array of AccountInfo objects in cache
|
|
16770
16875
|
*/
|
|
16771
16876
|
getAllAccounts(accountFilter) {
|
|
16772
|
-
|
|
16877
|
+
const correlationId = this.getRequestCorrelationId();
|
|
16878
|
+
return getAllAccounts(this.logger, this.browserStorage, this.isBrowserEnvironment, correlationId, accountFilter);
|
|
16773
16879
|
}
|
|
16774
16880
|
/**
|
|
16775
16881
|
* Returns the first account found in the cache that matches the account filter passed in.
|
|
@@ -16777,7 +16883,8 @@
|
|
|
16777
16883
|
* @returns The first account found in the cache matching the provided filter or null if no account could be found.
|
|
16778
16884
|
*/
|
|
16779
16885
|
getAccount(accountFilter) {
|
|
16780
|
-
|
|
16886
|
+
const correlationId = this.getRequestCorrelationId();
|
|
16887
|
+
return getAccount(accountFilter, this.logger, this.browserStorage, correlationId);
|
|
16781
16888
|
}
|
|
16782
16889
|
/**
|
|
16783
16890
|
* Returns the signed in account matching username.
|
|
@@ -16788,7 +16895,8 @@
|
|
|
16788
16895
|
* @returns The account object stored in MSAL
|
|
16789
16896
|
*/
|
|
16790
16897
|
getAccountByUsername(username) {
|
|
16791
|
-
|
|
16898
|
+
const correlationId = this.getRequestCorrelationId();
|
|
16899
|
+
return getAccountByUsername(username, this.logger, this.browserStorage, correlationId);
|
|
16792
16900
|
}
|
|
16793
16901
|
/**
|
|
16794
16902
|
* Returns the signed in account matching homeAccountId.
|
|
@@ -16798,7 +16906,8 @@
|
|
|
16798
16906
|
* @returns The account object stored in MSAL
|
|
16799
16907
|
*/
|
|
16800
16908
|
getAccountByHomeId(homeAccountId) {
|
|
16801
|
-
|
|
16909
|
+
const correlationId = this.getRequestCorrelationId();
|
|
16910
|
+
return getAccountByHomeId(homeAccountId, this.logger, this.browserStorage, correlationId);
|
|
16802
16911
|
}
|
|
16803
16912
|
/**
|
|
16804
16913
|
* Returns the signed in account matching localAccountId.
|
|
@@ -16808,20 +16917,23 @@
|
|
|
16808
16917
|
* @returns The account object stored in MSAL
|
|
16809
16918
|
*/
|
|
16810
16919
|
getAccountByLocalId(localAccountId) {
|
|
16811
|
-
|
|
16920
|
+
const correlationId = this.getRequestCorrelationId();
|
|
16921
|
+
return getAccountByLocalId(localAccountId, this.logger, this.browserStorage, correlationId);
|
|
16812
16922
|
}
|
|
16813
16923
|
/**
|
|
16814
16924
|
* 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.
|
|
16815
16925
|
* @param account
|
|
16816
16926
|
*/
|
|
16817
16927
|
setActiveAccount(account) {
|
|
16818
|
-
|
|
16928
|
+
const correlationId = this.getRequestCorrelationId();
|
|
16929
|
+
setActiveAccount(account, this.browserStorage, correlationId);
|
|
16819
16930
|
}
|
|
16820
16931
|
/**
|
|
16821
16932
|
* Gets the currently active account
|
|
16822
16933
|
*/
|
|
16823
16934
|
getActiveAccount() {
|
|
16824
|
-
|
|
16935
|
+
const correlationId = this.getRequestCorrelationId();
|
|
16936
|
+
return getActiveAccount(this.browserStorage, correlationId);
|
|
16825
16937
|
}
|
|
16826
16938
|
// #endregion
|
|
16827
16939
|
/**
|
|
@@ -16834,7 +16946,7 @@
|
|
|
16834
16946
|
this.logger.verbose("hydrateCache called");
|
|
16835
16947
|
// Account gets saved to browser storage regardless of native or not
|
|
16836
16948
|
const accountEntity = AccountEntity.createFromAccountInfo(result.account, result.cloudGraphHostName, result.msGraphHost);
|
|
16837
|
-
this.browserStorage.setAccount(accountEntity);
|
|
16949
|
+
this.browserStorage.setAccount(accountEntity, result.correlationId);
|
|
16838
16950
|
if (result.fromNativeBroker) {
|
|
16839
16951
|
this.logger.verbose("Response was from native broker, storing in-memory");
|
|
16840
16952
|
// Tokens from native broker are stored in-memory
|
|
@@ -17618,8 +17730,9 @@
|
|
|
17618
17730
|
// Set the active account if available
|
|
17619
17731
|
const accountContext = this.bridgeProxy.getAccountContext();
|
|
17620
17732
|
if (accountContext) {
|
|
17621
|
-
const
|
|
17622
|
-
|
|
17733
|
+
const correlationId = createNewGuid();
|
|
17734
|
+
const cachedAccount = getAccount(accountContext, this.logger, this.browserStorage, correlationId);
|
|
17735
|
+
setActiveAccount(cachedAccount, this.browserStorage, correlationId);
|
|
17623
17736
|
}
|
|
17624
17737
|
}
|
|
17625
17738
|
/**
|
|
@@ -17672,7 +17785,7 @@
|
|
|
17672
17785
|
};
|
|
17673
17786
|
// cache the tokens in the response
|
|
17674
17787
|
await this.hydrateCache(result, request);
|
|
17675
|
-
this.browserStorage.setActiveAccount(result.account);
|
|
17788
|
+
this.browserStorage.setActiveAccount(result.account, result.correlationId);
|
|
17676
17789
|
this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_SUCCESS, exports.InteractionType.Popup, result);
|
|
17677
17790
|
atPopupMeasurement.add({
|
|
17678
17791
|
accessTokenSize: result.accessToken.length,
|
|
@@ -17722,7 +17835,7 @@
|
|
|
17722
17835
|
const result = this.nestedAppAuthAdapter.fromNaaTokenResponse(naaRequest, response, reqTimestamp);
|
|
17723
17836
|
// cache the tokens in the response
|
|
17724
17837
|
await this.hydrateCache(result, request);
|
|
17725
|
-
this.browserStorage.setActiveAccount(result.account);
|
|
17838
|
+
this.browserStorage.setActiveAccount(result.account, result.correlationId);
|
|
17726
17839
|
this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_SUCCESS, exports.InteractionType.Silent, result);
|
|
17727
17840
|
ssoSilentMeasurement?.add({
|
|
17728
17841
|
accessTokenSize: result.accessToken.length,
|
|
@@ -17793,10 +17906,11 @@
|
|
|
17793
17906
|
* @returns
|
|
17794
17907
|
*/
|
|
17795
17908
|
async acquireTokenFromCacheInternal(request) {
|
|
17909
|
+
const correlationId = request.correlationId || createNewGuid();
|
|
17796
17910
|
const accountContext = this.bridgeProxy.getAccountContext();
|
|
17797
17911
|
let currentAccount = null;
|
|
17798
17912
|
if (accountContext) {
|
|
17799
|
-
const hubAccount = getAccount(accountContext, this.logger, this.browserStorage);
|
|
17913
|
+
const hubAccount = getAccount(accountContext, this.logger, this.browserStorage, correlationId);
|
|
17800
17914
|
// always prioritize for hub account context, the reqirement of `request.account` will be removed soon
|
|
17801
17915
|
currentAccount = hubAccount || request.account;
|
|
17802
17916
|
}
|
|
@@ -17808,7 +17922,7 @@
|
|
|
17808
17922
|
this.logger.verbose("active account found, attempting to acquire token silently");
|
|
17809
17923
|
const authRequest = {
|
|
17810
17924
|
...request,
|
|
17811
|
-
correlationId:
|
|
17925
|
+
correlationId: correlationId,
|
|
17812
17926
|
authority: request.authority || currentAccount.environment,
|
|
17813
17927
|
scopes: request.scopes?.length
|
|
17814
17928
|
? request.scopes
|
|
@@ -17816,7 +17930,7 @@
|
|
|
17816
17930
|
};
|
|
17817
17931
|
// fetch access token and check for expiry
|
|
17818
17932
|
const tokenKeys = this.browserStorage.getTokenKeys();
|
|
17819
|
-
const cachedAccessToken = this.browserStorage.getAccessToken(currentAccount, authRequest, tokenKeys, currentAccount.tenantId, this.performanceClient
|
|
17933
|
+
const cachedAccessToken = this.browserStorage.getAccessToken(currentAccount, authRequest, tokenKeys, currentAccount.tenantId, this.performanceClient);
|
|
17820
17934
|
// If there is no access token, log it and return null
|
|
17821
17935
|
if (!cachedAccessToken) {
|
|
17822
17936
|
this.logger.verbose("No cached access token found");
|
|
@@ -17827,7 +17941,7 @@
|
|
|
17827
17941
|
this.logger.verbose("Cached access token has expired");
|
|
17828
17942
|
return Promise.resolve(null);
|
|
17829
17943
|
}
|
|
17830
|
-
const cachedIdToken = this.browserStorage.getIdToken(currentAccount, tokenKeys, currentAccount.tenantId, this.performanceClient
|
|
17944
|
+
const cachedIdToken = this.browserStorage.getIdToken(currentAccount, authRequest.correlationId, tokenKeys, currentAccount.tenantId, this.performanceClient);
|
|
17831
17945
|
if (!cachedIdToken) {
|
|
17832
17946
|
this.logger.verbose("No cached id token found");
|
|
17833
17947
|
return Promise.resolve(null);
|
|
@@ -17924,7 +18038,8 @@
|
|
|
17924
18038
|
* @returns Array of AccountInfo objects in cache
|
|
17925
18039
|
*/
|
|
17926
18040
|
getAllAccounts(accountFilter) {
|
|
17927
|
-
|
|
18041
|
+
const correlationId = createNewGuid();
|
|
18042
|
+
return getAllAccounts(this.logger, this.browserStorage, this.isBrowserEnv(), correlationId, accountFilter);
|
|
17928
18043
|
}
|
|
17929
18044
|
/**
|
|
17930
18045
|
* Returns the first account found in the cache that matches the account filter passed in.
|
|
@@ -17932,7 +18047,8 @@
|
|
|
17932
18047
|
* @returns The first account found in the cache matching the provided filter or null if no account could be found.
|
|
17933
18048
|
*/
|
|
17934
18049
|
getAccount(accountFilter) {
|
|
17935
|
-
|
|
18050
|
+
const correlationId = createNewGuid();
|
|
18051
|
+
return getAccount(accountFilter, this.logger, this.browserStorage, correlationId);
|
|
17936
18052
|
}
|
|
17937
18053
|
/**
|
|
17938
18054
|
* Returns the signed in account matching username.
|
|
@@ -17943,7 +18059,8 @@
|
|
|
17943
18059
|
* @returns The account object stored in MSAL
|
|
17944
18060
|
*/
|
|
17945
18061
|
getAccountByUsername(username) {
|
|
17946
|
-
|
|
18062
|
+
const correlationId = createNewGuid();
|
|
18063
|
+
return getAccountByUsername(username, this.logger, this.browserStorage, correlationId);
|
|
17947
18064
|
}
|
|
17948
18065
|
/**
|
|
17949
18066
|
* Returns the signed in account matching homeAccountId.
|
|
@@ -17953,7 +18070,8 @@
|
|
|
17953
18070
|
* @returns The account object stored in MSAL
|
|
17954
18071
|
*/
|
|
17955
18072
|
getAccountByHomeId(homeAccountId) {
|
|
17956
|
-
|
|
18073
|
+
const correlationId = createNewGuid();
|
|
18074
|
+
return getAccountByHomeId(homeAccountId, this.logger, this.browserStorage, correlationId);
|
|
17957
18075
|
}
|
|
17958
18076
|
/**
|
|
17959
18077
|
* Returns the signed in account matching localAccountId.
|
|
@@ -17963,7 +18081,8 @@
|
|
|
17963
18081
|
* @returns The account object stored in MSAL
|
|
17964
18082
|
*/
|
|
17965
18083
|
getAccountByLocalId(localAccountId) {
|
|
17966
|
-
|
|
18084
|
+
const correlationId = createNewGuid();
|
|
18085
|
+
return getAccountByLocalId(localAccountId, this.logger, this.browserStorage, correlationId);
|
|
17967
18086
|
}
|
|
17968
18087
|
/**
|
|
17969
18088
|
* 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.
|
|
@@ -17974,13 +18093,15 @@
|
|
|
17974
18093
|
* StandardController uses this to allow the developer to set the active account
|
|
17975
18094
|
* in the nested app auth scenario the active account is controlled by the app hosting the nested app
|
|
17976
18095
|
*/
|
|
17977
|
-
|
|
18096
|
+
const correlationId = createNewGuid();
|
|
18097
|
+
return setActiveAccount(account, this.browserStorage, correlationId);
|
|
17978
18098
|
}
|
|
17979
18099
|
/**
|
|
17980
18100
|
* Gets the currently active account
|
|
17981
18101
|
*/
|
|
17982
18102
|
getActiveAccount() {
|
|
17983
|
-
|
|
18103
|
+
const correlationId = createNewGuid();
|
|
18104
|
+
return getActiveAccount(this.browserStorage, correlationId);
|
|
17984
18105
|
}
|
|
17985
18106
|
// #endregion
|
|
17986
18107
|
handleRedirectPromise(hash // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
@@ -18062,7 +18183,7 @@
|
|
|
18062
18183
|
async hydrateCache(result, request) {
|
|
18063
18184
|
this.logger.verbose("hydrateCache called");
|
|
18064
18185
|
const accountEntity = AccountEntity.createFromAccountInfo(result.account, result.cloudGraphHostName, result.msGraphHost);
|
|
18065
|
-
this.browserStorage.setAccount(accountEntity);
|
|
18186
|
+
this.browserStorage.setAccount(accountEntity, result.correlationId);
|
|
18066
18187
|
return this.browserStorage.hydrateCache(result, request);
|
|
18067
18188
|
}
|
|
18068
18189
|
}
|