@azure/msal-browser 3.28.0 → 4.0.0-alpha.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.mjs +1 -1
- package/dist/cache/AsyncMemoryStorage.mjs +1 -1
- package/dist/cache/BrowserCacheManager.d.ts +7 -47
- package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
- package/dist/cache/BrowserCacheManager.mjs +36 -285
- package/dist/cache/BrowserCacheManager.mjs.map +1 -1
- package/dist/cache/CacheHelpers.d.ts +16 -0
- package/dist/cache/CacheHelpers.d.ts.map +1 -0
- package/dist/cache/CacheHelpers.mjs +46 -0
- package/dist/cache/CacheHelpers.mjs.map +1 -0
- package/dist/cache/CookieStorage.d.ts +3 -0
- package/dist/cache/CookieStorage.d.ts.map +1 -1
- package/dist/cache/CookieStorage.mjs +12 -1
- package/dist/cache/CookieStorage.mjs.map +1 -1
- package/dist/cache/DatabaseStorage.mjs +1 -1
- package/dist/cache/ITokenCache.d.ts +1 -1
- package/dist/cache/ITokenCache.d.ts.map +1 -1
- package/dist/cache/IWindowStorage.d.ts +12 -0
- package/dist/cache/IWindowStorage.d.ts.map +1 -1
- package/dist/cache/LocalStorage.d.ts +34 -1
- package/dist/cache/LocalStorage.d.ts.map +1 -1
- package/dist/cache/LocalStorage.mjs +169 -2
- package/dist/cache/LocalStorage.mjs.map +1 -1
- package/dist/cache/MemoryStorage.d.ts +3 -0
- package/dist/cache/MemoryStorage.d.ts.map +1 -1
- package/dist/cache/MemoryStorage.mjs +10 -1
- package/dist/cache/MemoryStorage.mjs.map +1 -1
- package/dist/cache/SessionStorage.d.ts +3 -0
- package/dist/cache/SessionStorage.d.ts.map +1 -1
- package/dist/cache/SessionStorage.mjs +10 -1
- package/dist/cache/SessionStorage.mjs.map +1 -1
- package/dist/cache/TokenCache.d.ts +1 -1
- package/dist/cache/TokenCache.d.ts.map +1 -1
- package/dist/cache/TokenCache.mjs +15 -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 +4 -4
- package/dist/controllers/NestedAppAuthController.mjs.map +1 -1
- package/dist/controllers/StandardController.d.ts.map +1 -1
- package/dist/controllers/StandardController.mjs +3 -2
- package/dist/controllers/StandardController.mjs.map +1 -1
- package/dist/controllers/UnknownOperatingContextController.mjs +1 -1
- package/dist/crypto/BrowserCrypto.d.ts +27 -0
- package/dist/crypto/BrowserCrypto.d.ts.map +1 -1
- package/dist/crypto/BrowserCrypto.mjs +83 -3
- package/dist/crypto/BrowserCrypto.mjs.map +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.d.ts +5 -0
- package/dist/encode/Base64Decode.d.ts.map +1 -1
- package/dist/encode/Base64Decode.mjs +2 -2
- package/dist/encode/Base64Decode.mjs.map +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.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +1 -2
- package/dist/index.mjs.map +1 -1
- package/dist/interaction_client/BaseInteractionClient.mjs +1 -1
- package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
- package/dist/interaction_client/NativeInteractionClient.d.ts +1 -1
- package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
- package/dist/interaction_client/NativeInteractionClient.mjs +4 -4
- package/dist/interaction_client/NativeInteractionClient.mjs.map +1 -1
- package/dist/interaction_client/PopupClient.mjs +1 -1
- package/dist/interaction_client/RedirectClient.mjs +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 +1 -8
- 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.d.ts.map +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.mjs +1 -1
- package/dist/utils/BrowserProtocolUtils.mjs +1 -1
- package/dist/utils/BrowserUtils.mjs +1 -1
- package/lib/msal-browser.cjs +532 -591
- package/lib/msal-browser.cjs.map +1 -1
- package/lib/msal-browser.js +532 -591
- package/lib/msal-browser.js.map +1 -1
- package/lib/msal-browser.min.js +65 -66
- package/lib/types/cache/BrowserCacheManager.d.ts +7 -47
- package/lib/types/cache/BrowserCacheManager.d.ts.map +1 -1
- package/lib/types/cache/CacheHelpers.d.ts +16 -0
- package/lib/types/cache/CacheHelpers.d.ts.map +1 -0
- package/lib/types/cache/CookieStorage.d.ts +3 -0
- package/lib/types/cache/CookieStorage.d.ts.map +1 -1
- package/lib/types/cache/ITokenCache.d.ts +1 -1
- package/lib/types/cache/ITokenCache.d.ts.map +1 -1
- package/lib/types/cache/IWindowStorage.d.ts +12 -0
- package/lib/types/cache/IWindowStorage.d.ts.map +1 -1
- package/lib/types/cache/LocalStorage.d.ts +34 -1
- package/lib/types/cache/LocalStorage.d.ts.map +1 -1
- package/lib/types/cache/MemoryStorage.d.ts +3 -0
- package/lib/types/cache/MemoryStorage.d.ts.map +1 -1
- package/lib/types/cache/SessionStorage.d.ts +3 -0
- package/lib/types/cache/SessionStorage.d.ts.map +1 -1
- package/lib/types/cache/TokenCache.d.ts +1 -1
- package/lib/types/cache/TokenCache.d.ts.map +1 -1
- package/lib/types/controllers/NestedAppAuthController.d.ts.map +1 -1
- package/lib/types/controllers/StandardController.d.ts.map +1 -1
- package/lib/types/crypto/BrowserCrypto.d.ts +27 -0
- package/lib/types/crypto/BrowserCrypto.d.ts.map +1 -1
- package/lib/types/encode/Base64Decode.d.ts +5 -0
- package/lib/types/encode/Base64Decode.d.ts.map +1 -1
- package/lib/types/index.d.ts +0 -1
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/interaction_client/NativeInteractionClient.d.ts +1 -1
- package/lib/types/interaction_client/NativeInteractionClient.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/packageMetadata.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/cache/BrowserCacheManager.ts +59 -412
- package/src/cache/CacheHelpers.ts +52 -0
- package/src/cache/CookieStorage.ts +18 -0
- package/src/cache/ITokenCache.ts +1 -1
- package/src/cache/IWindowStorage.ts +14 -0
- package/src/cache/LocalStorage.ts +231 -1
- package/src/cache/MemoryStorage.ts +12 -0
- package/src/cache/SessionStorage.ts +12 -0
- package/src/cache/TokenCache.ts +19 -19
- package/src/controllers/NestedAppAuthController.ts +3 -3
- package/src/controllers/StandardController.ts +3 -1
- package/src/crypto/BrowserCrypto.ts +120 -1
- package/src/encode/Base64Decode.ts +1 -1
- package/src/index.ts +0 -1
- package/src/interaction_client/NativeInteractionClient.ts +3 -3
- package/src/interaction_client/StandardInteractionClient.ts +0 -8
- package/src/packageMetadata.ts +1 -1
- package/dist/cache/BrowserStorage.d.ts +0 -14
- package/dist/cache/BrowserStorage.d.ts.map +0 -1
- package/dist/cache/BrowserStorage.mjs +0 -46
- package/dist/cache/BrowserStorage.mjs.map +0 -1
- package/lib/types/cache/BrowserStorage.d.ts +0 -14
- package/lib/types/cache/BrowserStorage.d.ts.map +0 -1
- package/src/cache/BrowserStorage.ts +0 -52
package/lib/msal-browser.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/*! @azure/msal-browser
|
|
1
|
+
/*! @azure/msal-browser v4.0.0-alpha.0 2024-12-18 */
|
|
2
2
|
'use strict';
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
|
-
/*! @azure/msal-common
|
|
5
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
6
6
|
/*
|
|
7
7
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
8
8
|
* Licensed under the MIT License.
|
|
@@ -109,12 +109,6 @@ const HeaderNames = {
|
|
|
109
109
|
* Persistent cache keys MSAL which stay while user is logged in.
|
|
110
110
|
*/
|
|
111
111
|
const PersistentCacheKeys = {
|
|
112
|
-
ID_TOKEN: "idtoken",
|
|
113
|
-
CLIENT_INFO: "client.info",
|
|
114
|
-
ADAL_ID_TOKEN: "adal.idtoken",
|
|
115
|
-
ERROR: "error",
|
|
116
|
-
ERROR_DESC: "error.description",
|
|
117
|
-
ACTIVE_ACCOUNT: "active-account",
|
|
118
112
|
ACTIVE_ACCOUNT_FILTERS: "active-account-filters", // new cache entry for active_account for a more robust version for browser
|
|
119
113
|
};
|
|
120
114
|
/**
|
|
@@ -312,7 +306,7 @@ const JsonWebTokenTypes = {
|
|
|
312
306
|
// Token renewal offset default in seconds
|
|
313
307
|
const DEFAULT_TOKEN_RENEWAL_OFFSET_SEC = 300;
|
|
314
308
|
|
|
315
|
-
/*! @azure/msal-common
|
|
309
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
316
310
|
/*
|
|
317
311
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
318
312
|
* Licensed under the MIT License.
|
|
@@ -329,7 +323,7 @@ var AuthErrorCodes = /*#__PURE__*/Object.freeze({
|
|
|
329
323
|
unexpectedError: unexpectedError
|
|
330
324
|
});
|
|
331
325
|
|
|
332
|
-
/*! @azure/msal-common
|
|
326
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
333
327
|
|
|
334
328
|
/*
|
|
335
329
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -378,7 +372,7 @@ function createAuthError(code, additionalMessage) {
|
|
|
378
372
|
: AuthErrorMessages[code]);
|
|
379
373
|
}
|
|
380
374
|
|
|
381
|
-
/*! @azure/msal-common
|
|
375
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
382
376
|
/*
|
|
383
377
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
384
378
|
* Licensed under the MIT License.
|
|
@@ -476,7 +470,7 @@ var ClientAuthErrorCodes = /*#__PURE__*/Object.freeze({
|
|
|
476
470
|
userTimeoutReached: userTimeoutReached
|
|
477
471
|
});
|
|
478
472
|
|
|
479
|
-
/*! @azure/msal-common
|
|
473
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
480
474
|
|
|
481
475
|
/*
|
|
482
476
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -728,7 +722,7 @@ function createClientAuthError(errorCode, additionalMessage) {
|
|
|
728
722
|
return new ClientAuthError(errorCode, additionalMessage);
|
|
729
723
|
}
|
|
730
724
|
|
|
731
|
-
/*! @azure/msal-common
|
|
725
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
732
726
|
|
|
733
727
|
/*
|
|
734
728
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -767,7 +761,7 @@ const DEFAULT_CRYPTO_IMPLEMENTATION = {
|
|
|
767
761
|
},
|
|
768
762
|
};
|
|
769
763
|
|
|
770
|
-
/*! @azure/msal-common
|
|
764
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
771
765
|
|
|
772
766
|
/*
|
|
773
767
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -958,12 +952,12 @@ class Logger {
|
|
|
958
952
|
}
|
|
959
953
|
}
|
|
960
954
|
|
|
961
|
-
/*! @azure/msal-common
|
|
955
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
962
956
|
/* eslint-disable header/header */
|
|
963
957
|
const name$1 = "@azure/msal-common";
|
|
964
|
-
const version$1 = "
|
|
958
|
+
const version$1 = "15.0.0-alpha.0";
|
|
965
959
|
|
|
966
|
-
/*! @azure/msal-common
|
|
960
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
967
961
|
/*
|
|
968
962
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
969
963
|
* Licensed under the MIT License.
|
|
@@ -983,7 +977,7 @@ const AzureCloudInstance = {
|
|
|
983
977
|
AzureUsGovernment: "https://login.microsoftonline.us",
|
|
984
978
|
};
|
|
985
979
|
|
|
986
|
-
/*! @azure/msal-common
|
|
980
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
987
981
|
|
|
988
982
|
/*
|
|
989
983
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1044,7 +1038,7 @@ function checkMaxAge(authTime, maxAge) {
|
|
|
1044
1038
|
}
|
|
1045
1039
|
}
|
|
1046
1040
|
|
|
1047
|
-
/*! @azure/msal-common
|
|
1041
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
1048
1042
|
/*
|
|
1049
1043
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1050
1044
|
* Licensed under the MIT License.
|
|
@@ -1081,7 +1075,7 @@ function wasClockTurnedBack(cachedAt) {
|
|
|
1081
1075
|
return cachedAtSec > nowSeconds();
|
|
1082
1076
|
}
|
|
1083
1077
|
|
|
1084
|
-
/*! @azure/msal-common
|
|
1078
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
1085
1079
|
|
|
1086
1080
|
/*
|
|
1087
1081
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1408,7 +1402,7 @@ function isAuthorityMetadataExpired(metadata) {
|
|
|
1408
1402
|
return metadata.expiresAt <= nowSeconds();
|
|
1409
1403
|
}
|
|
1410
1404
|
|
|
1411
|
-
/*! @azure/msal-common
|
|
1405
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
1412
1406
|
/*
|
|
1413
1407
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1414
1408
|
* Licensed under the MIT License.
|
|
@@ -1462,7 +1456,7 @@ var ClientConfigurationErrorCodes = /*#__PURE__*/Object.freeze({
|
|
|
1462
1456
|
urlParseError: urlParseError
|
|
1463
1457
|
});
|
|
1464
1458
|
|
|
1465
|
-
/*! @azure/msal-common
|
|
1459
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
1466
1460
|
|
|
1467
1461
|
/*
|
|
1468
1462
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1600,7 +1594,7 @@ function createClientConfigurationError(errorCode) {
|
|
|
1600
1594
|
return new ClientConfigurationError(errorCode);
|
|
1601
1595
|
}
|
|
1602
1596
|
|
|
1603
|
-
/*! @azure/msal-common
|
|
1597
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
1604
1598
|
/*
|
|
1605
1599
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1606
1600
|
* Licensed under the MIT License.
|
|
@@ -1697,7 +1691,7 @@ class StringUtils {
|
|
|
1697
1691
|
}
|
|
1698
1692
|
}
|
|
1699
1693
|
|
|
1700
|
-
/*! @azure/msal-common
|
|
1694
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
1701
1695
|
|
|
1702
1696
|
/*
|
|
1703
1697
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1897,7 +1891,7 @@ class ScopeSet {
|
|
|
1897
1891
|
}
|
|
1898
1892
|
}
|
|
1899
1893
|
|
|
1900
|
-
/*! @azure/msal-common
|
|
1894
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
1901
1895
|
|
|
1902
1896
|
/*
|
|
1903
1897
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1937,7 +1931,7 @@ function buildClientInfoFromHomeAccountId(homeAccountId) {
|
|
|
1937
1931
|
};
|
|
1938
1932
|
}
|
|
1939
1933
|
|
|
1940
|
-
/*! @azure/msal-common
|
|
1934
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
1941
1935
|
/*
|
|
1942
1936
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1943
1937
|
* Licensed under the MIT License.
|
|
@@ -2016,7 +2010,7 @@ function updateAccountTenantProfileData(baseAccountInfo, tenantProfile, idTokenC
|
|
|
2016
2010
|
return updatedAccountInfo;
|
|
2017
2011
|
}
|
|
2018
2012
|
|
|
2019
|
-
/*! @azure/msal-common
|
|
2013
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
2020
2014
|
/*
|
|
2021
2015
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2022
2016
|
* Licensed under the MIT License.
|
|
@@ -2031,7 +2025,7 @@ const AuthorityType = {
|
|
|
2031
2025
|
Ciam: 3,
|
|
2032
2026
|
};
|
|
2033
2027
|
|
|
2034
|
-
/*! @azure/msal-common
|
|
2028
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
2035
2029
|
/*
|
|
2036
2030
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2037
2031
|
* Licensed under the MIT License.
|
|
@@ -2053,7 +2047,7 @@ function getTenantIdFromIdTokenClaims(idTokenClaims) {
|
|
|
2053
2047
|
return null;
|
|
2054
2048
|
}
|
|
2055
2049
|
|
|
2056
|
-
/*! @azure/msal-common
|
|
2050
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
2057
2051
|
/*
|
|
2058
2052
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2059
2053
|
* Licensed under the MIT License.
|
|
@@ -2066,7 +2060,7 @@ const ProtocolMode = {
|
|
|
2066
2060
|
OIDC: "OIDC",
|
|
2067
2061
|
};
|
|
2068
2062
|
|
|
2069
|
-
/*! @azure/msal-common
|
|
2063
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
2070
2064
|
|
|
2071
2065
|
/*
|
|
2072
2066
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2309,7 +2303,7 @@ class AccountEntity {
|
|
|
2309
2303
|
}
|
|
2310
2304
|
}
|
|
2311
2305
|
|
|
2312
|
-
/*! @azure/msal-common
|
|
2306
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
2313
2307
|
|
|
2314
2308
|
/*
|
|
2315
2309
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2356,7 +2350,7 @@ function getDeserializedResponse(responseString) {
|
|
|
2356
2350
|
return null;
|
|
2357
2351
|
}
|
|
2358
2352
|
|
|
2359
|
-
/*! @azure/msal-common
|
|
2353
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
2360
2354
|
|
|
2361
2355
|
/*
|
|
2362
2356
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2520,7 +2514,7 @@ class UrlString {
|
|
|
2520
2514
|
}
|
|
2521
2515
|
}
|
|
2522
2516
|
|
|
2523
|
-
/*! @azure/msal-common
|
|
2517
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
2524
2518
|
|
|
2525
2519
|
/*
|
|
2526
2520
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2660,7 +2654,7 @@ function getCloudDiscoveryMetadataFromNetworkResponse(response, authorityHost) {
|
|
|
2660
2654
|
return null;
|
|
2661
2655
|
}
|
|
2662
2656
|
|
|
2663
|
-
/*! @azure/msal-common
|
|
2657
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
2664
2658
|
/*
|
|
2665
2659
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2666
2660
|
* Licensed under the MIT License.
|
|
@@ -2668,7 +2662,7 @@ function getCloudDiscoveryMetadataFromNetworkResponse(response, authorityHost) {
|
|
|
2668
2662
|
const cacheQuotaExceededErrorCode = "cache_quota_exceeded";
|
|
2669
2663
|
const cacheUnknownErrorCode = "cache_error_unknown";
|
|
2670
2664
|
|
|
2671
|
-
/*! @azure/msal-common
|
|
2665
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
2672
2666
|
|
|
2673
2667
|
/*
|
|
2674
2668
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2695,7 +2689,7 @@ class CacheError extends Error {
|
|
|
2695
2689
|
}
|
|
2696
2690
|
}
|
|
2697
2691
|
|
|
2698
|
-
/*! @azure/msal-common
|
|
2692
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
2699
2693
|
|
|
2700
2694
|
/*
|
|
2701
2695
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2866,10 +2860,10 @@ class CacheManager {
|
|
|
2866
2860
|
}
|
|
2867
2861
|
try {
|
|
2868
2862
|
if (!!cacheRecord.account) {
|
|
2869
|
-
this.setAccount(cacheRecord.account);
|
|
2863
|
+
await this.setAccount(cacheRecord.account);
|
|
2870
2864
|
}
|
|
2871
2865
|
if (!!cacheRecord.idToken && storeInCache?.idToken !== false) {
|
|
2872
|
-
this.setIdTokenCredential(cacheRecord.idToken);
|
|
2866
|
+
await this.setIdTokenCredential(cacheRecord.idToken);
|
|
2873
2867
|
}
|
|
2874
2868
|
if (!!cacheRecord.accessToken &&
|
|
2875
2869
|
storeInCache?.accessToken !== false) {
|
|
@@ -2877,7 +2871,7 @@ class CacheManager {
|
|
|
2877
2871
|
}
|
|
2878
2872
|
if (!!cacheRecord.refreshToken &&
|
|
2879
2873
|
storeInCache?.refreshToken !== false) {
|
|
2880
|
-
this.setRefreshTokenCredential(cacheRecord.refreshToken);
|
|
2874
|
+
await this.setRefreshTokenCredential(cacheRecord.refreshToken);
|
|
2881
2875
|
}
|
|
2882
2876
|
if (!!cacheRecord.appMetadata) {
|
|
2883
2877
|
this.setAppMetadata(cacheRecord.appMetadata);
|
|
@@ -2934,7 +2928,7 @@ class CacheManager {
|
|
|
2934
2928
|
}
|
|
2935
2929
|
});
|
|
2936
2930
|
await Promise.all(removedAccessTokens);
|
|
2937
|
-
this.setAccessTokenCredential(credential);
|
|
2931
|
+
await this.setAccessTokenCredential(credential);
|
|
2938
2932
|
}
|
|
2939
2933
|
/**
|
|
2940
2934
|
* Retrieve account entities matching all provided tenant-agnostic filters; if no filter is set, get all account entities in the cache
|
|
@@ -3220,61 +3214,6 @@ class CacheManager {
|
|
|
3220
3214
|
});
|
|
3221
3215
|
await Promise.all(removedCredentials);
|
|
3222
3216
|
}
|
|
3223
|
-
/**
|
|
3224
|
-
* Migrates a single-tenant account and all it's associated alternate cross-tenant account objects in the
|
|
3225
|
-
* cache into a condensed multi-tenant account object with tenant profiles.
|
|
3226
|
-
* @param accountKey
|
|
3227
|
-
* @param accountEntity
|
|
3228
|
-
* @param logger
|
|
3229
|
-
* @returns
|
|
3230
|
-
*/
|
|
3231
|
-
updateOutdatedCachedAccount(accountKey, accountEntity, logger) {
|
|
3232
|
-
// Only update if account entity is defined and has no tenantProfiles object (is outdated)
|
|
3233
|
-
if (accountEntity && accountEntity.isSingleTenant()) {
|
|
3234
|
-
this.commonLogger?.verbose("updateOutdatedCachedAccount: Found a single-tenant (outdated) account entity in the cache, migrating to multi-tenant account entity");
|
|
3235
|
-
// Get keys of all accounts belonging to user
|
|
3236
|
-
const matchingAccountKeys = this.getAccountKeys().filter((key) => {
|
|
3237
|
-
return key.startsWith(accountEntity.homeAccountId);
|
|
3238
|
-
});
|
|
3239
|
-
// Get all account entities belonging to user
|
|
3240
|
-
const accountsToMerge = [];
|
|
3241
|
-
matchingAccountKeys.forEach((key) => {
|
|
3242
|
-
const account = this.getCachedAccountEntity(key);
|
|
3243
|
-
if (account) {
|
|
3244
|
-
accountsToMerge.push(account);
|
|
3245
|
-
}
|
|
3246
|
-
});
|
|
3247
|
-
// Set base account to home account if available, any account if not
|
|
3248
|
-
const baseAccount = accountsToMerge.find((account) => {
|
|
3249
|
-
return tenantIdMatchesHomeTenant(account.realm, account.homeAccountId);
|
|
3250
|
-
}) || accountsToMerge[0];
|
|
3251
|
-
// Populate tenant profiles built from each account entity belonging to the user
|
|
3252
|
-
baseAccount.tenantProfiles = accountsToMerge.map((account) => {
|
|
3253
|
-
return {
|
|
3254
|
-
tenantId: account.realm,
|
|
3255
|
-
localAccountId: account.localAccountId,
|
|
3256
|
-
name: account.name,
|
|
3257
|
-
isHomeTenant: tenantIdMatchesHomeTenant(account.realm, account.homeAccountId),
|
|
3258
|
-
};
|
|
3259
|
-
});
|
|
3260
|
-
const updatedAccount = CacheManager.toObject(new AccountEntity(), {
|
|
3261
|
-
...baseAccount,
|
|
3262
|
-
});
|
|
3263
|
-
const newAccountKey = updatedAccount.generateAccountKey();
|
|
3264
|
-
// Clear cache of legacy account objects that have been collpsed into tenant profiles
|
|
3265
|
-
matchingAccountKeys.forEach((key) => {
|
|
3266
|
-
if (key !== newAccountKey) {
|
|
3267
|
-
this.removeOutdatedAccount(accountKey);
|
|
3268
|
-
}
|
|
3269
|
-
});
|
|
3270
|
-
// Cache updated account object
|
|
3271
|
-
this.setAccount(updatedAccount);
|
|
3272
|
-
logger?.verbose("Updated an outdated account entity in the cache");
|
|
3273
|
-
return updatedAccount;
|
|
3274
|
-
}
|
|
3275
|
-
// No update is necessary
|
|
3276
|
-
return accountEntity;
|
|
3277
|
-
}
|
|
3278
3217
|
/**
|
|
3279
3218
|
* returns a boolean if the given credential is removed
|
|
3280
3219
|
* @param credential
|
|
@@ -3870,28 +3809,25 @@ class CacheManager {
|
|
|
3870
3809
|
}
|
|
3871
3810
|
/** @internal */
|
|
3872
3811
|
class DefaultStorageClass extends CacheManager {
|
|
3873
|
-
setAccount() {
|
|
3812
|
+
async setAccount() {
|
|
3874
3813
|
throw createClientAuthError(methodNotImplemented);
|
|
3875
3814
|
}
|
|
3876
3815
|
getAccount() {
|
|
3877
3816
|
throw createClientAuthError(methodNotImplemented);
|
|
3878
3817
|
}
|
|
3879
|
-
|
|
3880
|
-
throw createClientAuthError(methodNotImplemented);
|
|
3881
|
-
}
|
|
3882
|
-
setIdTokenCredential() {
|
|
3818
|
+
async setIdTokenCredential() {
|
|
3883
3819
|
throw createClientAuthError(methodNotImplemented);
|
|
3884
3820
|
}
|
|
3885
3821
|
getIdTokenCredential() {
|
|
3886
3822
|
throw createClientAuthError(methodNotImplemented);
|
|
3887
3823
|
}
|
|
3888
|
-
setAccessTokenCredential() {
|
|
3824
|
+
async setAccessTokenCredential() {
|
|
3889
3825
|
throw createClientAuthError(methodNotImplemented);
|
|
3890
3826
|
}
|
|
3891
3827
|
getAccessTokenCredential() {
|
|
3892
3828
|
throw createClientAuthError(methodNotImplemented);
|
|
3893
3829
|
}
|
|
3894
|
-
setRefreshTokenCredential() {
|
|
3830
|
+
async setRefreshTokenCredential() {
|
|
3895
3831
|
throw createClientAuthError(methodNotImplemented);
|
|
3896
3832
|
}
|
|
3897
3833
|
getRefreshTokenCredential() {
|
|
@@ -3936,15 +3872,9 @@ class DefaultStorageClass extends CacheManager {
|
|
|
3936
3872
|
getTokenKeys() {
|
|
3937
3873
|
throw createClientAuthError(methodNotImplemented);
|
|
3938
3874
|
}
|
|
3939
|
-
updateCredentialCacheKey() {
|
|
3940
|
-
throw createClientAuthError(methodNotImplemented);
|
|
3941
|
-
}
|
|
3942
|
-
removeOutdatedAccount() {
|
|
3943
|
-
throw createClientAuthError(methodNotImplemented);
|
|
3944
|
-
}
|
|
3945
3875
|
}
|
|
3946
3876
|
|
|
3947
|
-
/*! @azure/msal-common
|
|
3877
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
3948
3878
|
|
|
3949
3879
|
/*
|
|
3950
3880
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4043,7 +3973,7 @@ function isOidcProtocolMode(config) {
|
|
|
4043
3973
|
return (config.authOptions.authority.options.protocolMode === ProtocolMode.OIDC);
|
|
4044
3974
|
}
|
|
4045
3975
|
|
|
4046
|
-
/*! @azure/msal-common
|
|
3976
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
4047
3977
|
/*
|
|
4048
3978
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4049
3979
|
* Licensed under the MIT License.
|
|
@@ -4053,7 +3983,7 @@ const CcsCredentialType = {
|
|
|
4053
3983
|
UPN: "UPN",
|
|
4054
3984
|
};
|
|
4055
3985
|
|
|
4056
|
-
/*! @azure/msal-common
|
|
3986
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
4057
3987
|
/*
|
|
4058
3988
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4059
3989
|
* Licensed under the MIT License.
|
|
@@ -4103,7 +4033,7 @@ const X_CLIENT_EXTRA_SKU = "x-client-xtra-sku";
|
|
|
4103
4033
|
const BROKER_CLIENT_ID = "brk_client_id";
|
|
4104
4034
|
const BROKER_REDIRECT_URI = "brk_redirect_uri";
|
|
4105
4035
|
|
|
4106
|
-
/*! @azure/msal-common
|
|
4036
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
4107
4037
|
|
|
4108
4038
|
/*
|
|
4109
4039
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4170,7 +4100,7 @@ class RequestValidator {
|
|
|
4170
4100
|
}
|
|
4171
4101
|
}
|
|
4172
4102
|
|
|
4173
|
-
/*! @azure/msal-common
|
|
4103
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
4174
4104
|
|
|
4175
4105
|
/*
|
|
4176
4106
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4578,7 +4508,7 @@ class RequestParameterBuilder {
|
|
|
4578
4508
|
}
|
|
4579
4509
|
}
|
|
4580
4510
|
|
|
4581
|
-
/*! @azure/msal-common
|
|
4511
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
4582
4512
|
/*
|
|
4583
4513
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4584
4514
|
* Licensed under the MIT License.
|
|
@@ -4590,7 +4520,7 @@ function isOpenIdConfigResponse(response) {
|
|
|
4590
4520
|
response.hasOwnProperty("jwks_uri"));
|
|
4591
4521
|
}
|
|
4592
4522
|
|
|
4593
|
-
/*! @azure/msal-common
|
|
4523
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
4594
4524
|
/*
|
|
4595
4525
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4596
4526
|
* Licensed under the MIT License.
|
|
@@ -4600,7 +4530,7 @@ function isCloudInstanceDiscoveryResponse(response) {
|
|
|
4600
4530
|
response.hasOwnProperty("metadata"));
|
|
4601
4531
|
}
|
|
4602
4532
|
|
|
4603
|
-
/*! @azure/msal-common
|
|
4533
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
4604
4534
|
/*
|
|
4605
4535
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4606
4536
|
* Licensed under the MIT License.
|
|
@@ -4610,7 +4540,7 @@ function isCloudInstanceDiscoveryErrorResponse(response) {
|
|
|
4610
4540
|
response.hasOwnProperty("error_description"));
|
|
4611
4541
|
}
|
|
4612
4542
|
|
|
4613
|
-
/*! @azure/msal-common
|
|
4543
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
4614
4544
|
/*
|
|
4615
4545
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4616
4546
|
* Licensed under the MIT License.
|
|
@@ -5097,7 +5027,7 @@ const IntFields = new Set([
|
|
|
5097
5027
|
"multiMatchedRT",
|
|
5098
5028
|
]);
|
|
5099
5029
|
|
|
5100
|
-
/*! @azure/msal-common
|
|
5030
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
5101
5031
|
/*
|
|
5102
5032
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
5103
5033
|
* Licensed under the MIT License.
|
|
@@ -5193,7 +5123,7 @@ const invokeAsync = (callback, eventName, logger, telemetryClient, correlationId
|
|
|
5193
5123
|
};
|
|
5194
5124
|
};
|
|
5195
5125
|
|
|
5196
|
-
/*! @azure/msal-common
|
|
5126
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
5197
5127
|
|
|
5198
5128
|
/*
|
|
5199
5129
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -5302,7 +5232,7 @@ RegionDiscovery.IMDS_OPTIONS = {
|
|
|
5302
5232
|
},
|
|
5303
5233
|
};
|
|
5304
5234
|
|
|
5305
|
-
/*! @azure/msal-common
|
|
5235
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
5306
5236
|
|
|
5307
5237
|
/*
|
|
5308
5238
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6141,7 +6071,7 @@ function buildStaticAuthorityOptions(authOptions) {
|
|
|
6141
6071
|
};
|
|
6142
6072
|
}
|
|
6143
6073
|
|
|
6144
|
-
/*! @azure/msal-common
|
|
6074
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
6145
6075
|
|
|
6146
6076
|
/*
|
|
6147
6077
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6172,7 +6102,7 @@ async function createDiscoveredInstance(authorityUri, networkClient, cacheManage
|
|
|
6172
6102
|
}
|
|
6173
6103
|
}
|
|
6174
6104
|
|
|
6175
|
-
/*! @azure/msal-common
|
|
6105
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
6176
6106
|
|
|
6177
6107
|
/*
|
|
6178
6108
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6191,7 +6121,7 @@ class ServerError extends AuthError {
|
|
|
6191
6121
|
}
|
|
6192
6122
|
}
|
|
6193
6123
|
|
|
6194
|
-
/*! @azure/msal-common
|
|
6124
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
6195
6125
|
|
|
6196
6126
|
/*
|
|
6197
6127
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6289,7 +6219,7 @@ class ThrottlingUtils {
|
|
|
6289
6219
|
}
|
|
6290
6220
|
}
|
|
6291
6221
|
|
|
6292
|
-
/*! @azure/msal-common
|
|
6222
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
6293
6223
|
|
|
6294
6224
|
/*
|
|
6295
6225
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6319,7 +6249,7 @@ function createNetworkError(error, httpStatus, responseHeaders) {
|
|
|
6319
6249
|
return new NetworkError(error, httpStatus, responseHeaders);
|
|
6320
6250
|
}
|
|
6321
6251
|
|
|
6322
|
-
/*! @azure/msal-common
|
|
6252
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
6323
6253
|
|
|
6324
6254
|
/*
|
|
6325
6255
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6469,7 +6399,7 @@ class BaseClient {
|
|
|
6469
6399
|
}
|
|
6470
6400
|
}
|
|
6471
6401
|
|
|
6472
|
-
/*! @azure/msal-common
|
|
6402
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
6473
6403
|
/*
|
|
6474
6404
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6475
6405
|
* Licensed under the MIT License.
|
|
@@ -6495,7 +6425,7 @@ var InteractionRequiredAuthErrorCodes = /*#__PURE__*/Object.freeze({
|
|
|
6495
6425
|
refreshTokenExpired: refreshTokenExpired
|
|
6496
6426
|
});
|
|
6497
6427
|
|
|
6498
|
-
/*! @azure/msal-common
|
|
6428
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
6499
6429
|
|
|
6500
6430
|
/*
|
|
6501
6431
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6583,7 +6513,7 @@ function createInteractionRequiredAuthError(errorCode) {
|
|
|
6583
6513
|
return new InteractionRequiredAuthError(errorCode, InteractionRequiredAuthErrorMessages[errorCode]);
|
|
6584
6514
|
}
|
|
6585
6515
|
|
|
6586
|
-
/*! @azure/msal-common
|
|
6516
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
6587
6517
|
|
|
6588
6518
|
/*
|
|
6589
6519
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6655,7 +6585,7 @@ class ProtocolUtils {
|
|
|
6655
6585
|
}
|
|
6656
6586
|
}
|
|
6657
6587
|
|
|
6658
|
-
/*! @azure/msal-common
|
|
6588
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
6659
6589
|
|
|
6660
6590
|
/*
|
|
6661
6591
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6739,7 +6669,7 @@ class PopTokenGenerator {
|
|
|
6739
6669
|
}
|
|
6740
6670
|
}
|
|
6741
6671
|
|
|
6742
|
-
/*! @azure/msal-common
|
|
6672
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
6743
6673
|
/*
|
|
6744
6674
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6745
6675
|
* Licensed under the MIT License.
|
|
@@ -6766,7 +6696,7 @@ class PopTokenGenerator {
|
|
|
6766
6696
|
}
|
|
6767
6697
|
}
|
|
6768
6698
|
|
|
6769
|
-
/*! @azure/msal-common
|
|
6699
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
6770
6700
|
|
|
6771
6701
|
/*
|
|
6772
6702
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6926,7 +6856,7 @@ class ResponseHandler {
|
|
|
6926
6856
|
!forceCacheRefreshTokenResponse &&
|
|
6927
6857
|
cacheRecord.account) {
|
|
6928
6858
|
const key = cacheRecord.account.generateAccountKey();
|
|
6929
|
-
const account = this.cacheStorage.getAccount(key
|
|
6859
|
+
const account = this.cacheStorage.getAccount(key);
|
|
6930
6860
|
if (!account) {
|
|
6931
6861
|
this.logger.warning("Account used to refresh tokens not in persistence, refreshed tokens will not be stored in the cache");
|
|
6932
6862
|
return await ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenClaims, requestStateObj, undefined, serverRequestId);
|
|
@@ -7118,7 +7048,7 @@ function buildAccountToCache(cacheStorage, authority, homeAccountId, base64Decod
|
|
|
7118
7048
|
});
|
|
7119
7049
|
let cachedAccount = null;
|
|
7120
7050
|
if (baseAccountKey) {
|
|
7121
|
-
cachedAccount = cacheStorage.getAccount(baseAccountKey
|
|
7051
|
+
cachedAccount = cacheStorage.getAccount(baseAccountKey);
|
|
7122
7052
|
}
|
|
7123
7053
|
const baseAccount = cachedAccount ||
|
|
7124
7054
|
AccountEntity.createAccount({
|
|
@@ -7143,7 +7073,7 @@ function buildAccountToCache(cacheStorage, authority, homeAccountId, base64Decod
|
|
|
7143
7073
|
return baseAccount;
|
|
7144
7074
|
}
|
|
7145
7075
|
|
|
7146
|
-
/*! @azure/msal-common
|
|
7076
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
7147
7077
|
/*
|
|
7148
7078
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
7149
7079
|
* Licensed under the MIT License.
|
|
@@ -7161,7 +7091,7 @@ async function getClientAssertion(clientAssertion, clientId, tokenEndpoint) {
|
|
|
7161
7091
|
}
|
|
7162
7092
|
}
|
|
7163
7093
|
|
|
7164
|
-
/*! @azure/msal-common
|
|
7094
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
7165
7095
|
|
|
7166
7096
|
/*
|
|
7167
7097
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7603,7 +7533,7 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
7603
7533
|
}
|
|
7604
7534
|
}
|
|
7605
7535
|
|
|
7606
|
-
/*! @azure/msal-common
|
|
7536
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
7607
7537
|
|
|
7608
7538
|
/*
|
|
7609
7539
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7823,7 +7753,7 @@ class RefreshTokenClient extends BaseClient {
|
|
|
7823
7753
|
}
|
|
7824
7754
|
}
|
|
7825
7755
|
|
|
7826
|
-
/*! @azure/msal-common
|
|
7756
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
7827
7757
|
|
|
7828
7758
|
/*
|
|
7829
7759
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7959,7 +7889,7 @@ class SilentFlowClient extends BaseClient {
|
|
|
7959
7889
|
}
|
|
7960
7890
|
}
|
|
7961
7891
|
|
|
7962
|
-
/*! @azure/msal-common
|
|
7892
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
7963
7893
|
|
|
7964
7894
|
/*
|
|
7965
7895
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7974,7 +7904,7 @@ const StubbedNetworkModule = {
|
|
|
7974
7904
|
},
|
|
7975
7905
|
};
|
|
7976
7906
|
|
|
7977
|
-
/*! @azure/msal-common
|
|
7907
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
7978
7908
|
|
|
7979
7909
|
/*
|
|
7980
7910
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8032,7 +7962,7 @@ class AuthenticationHeaderParser {
|
|
|
8032
7962
|
}
|
|
8033
7963
|
}
|
|
8034
7964
|
|
|
8035
|
-
/*! @azure/msal-common
|
|
7965
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
8036
7966
|
|
|
8037
7967
|
/*
|
|
8038
7968
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8295,7 +8225,7 @@ class ServerTelemetryManager {
|
|
|
8295
8225
|
}
|
|
8296
8226
|
}
|
|
8297
8227
|
|
|
8298
|
-
/*! @azure/msal-common
|
|
8228
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
8299
8229
|
/*
|
|
8300
8230
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
8301
8231
|
* Licensed under the MIT License.
|
|
@@ -8303,7 +8233,7 @@ class ServerTelemetryManager {
|
|
|
8303
8233
|
const missingKidError = "missing_kid_error";
|
|
8304
8234
|
const missingAlgError = "missing_alg_error";
|
|
8305
8235
|
|
|
8306
|
-
/*! @azure/msal-common
|
|
8236
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
8307
8237
|
|
|
8308
8238
|
/*
|
|
8309
8239
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8328,7 +8258,7 @@ function createJoseHeaderError(code) {
|
|
|
8328
8258
|
return new JoseHeaderError(code, JoseHeaderErrorMessages[code]);
|
|
8329
8259
|
}
|
|
8330
8260
|
|
|
8331
|
-
/*! @azure/msal-common
|
|
8261
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
8332
8262
|
|
|
8333
8263
|
/*
|
|
8334
8264
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8368,7 +8298,7 @@ class JoseHeader {
|
|
|
8368
8298
|
}
|
|
8369
8299
|
}
|
|
8370
8300
|
|
|
8371
|
-
/*! @azure/msal-common
|
|
8301
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
8372
8302
|
|
|
8373
8303
|
/*
|
|
8374
8304
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8447,7 +8377,7 @@ class StubPerformanceClient {
|
|
|
8447
8377
|
}
|
|
8448
8378
|
}
|
|
8449
8379
|
|
|
8450
|
-
/*! @azure/msal-common
|
|
8380
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
8451
8381
|
|
|
8452
8382
|
/*
|
|
8453
8383
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -9684,6 +9614,43 @@ function base64EncArr(aBytes) {
|
|
|
9684
9614
|
return btoa(binString);
|
|
9685
9615
|
}
|
|
9686
9616
|
|
|
9617
|
+
/*
|
|
9618
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
9619
|
+
* Licensed under the MIT License.
|
|
9620
|
+
*/
|
|
9621
|
+
/**
|
|
9622
|
+
* Class which exposes APIs to decode base64 strings to plaintext. See here for implementation details:
|
|
9623
|
+
* https://developer.mozilla.org/en-US/docs/Glossary/Base64#the_unicode_problem
|
|
9624
|
+
*/
|
|
9625
|
+
/**
|
|
9626
|
+
* Returns a URL-safe plaintext decoded string from b64 encoded input.
|
|
9627
|
+
* @param input
|
|
9628
|
+
*/
|
|
9629
|
+
function base64Decode(input) {
|
|
9630
|
+
return new TextDecoder().decode(base64DecToArr(input));
|
|
9631
|
+
}
|
|
9632
|
+
/**
|
|
9633
|
+
* Decodes base64 into Uint8Array
|
|
9634
|
+
* @param base64String
|
|
9635
|
+
*/
|
|
9636
|
+
function base64DecToArr(base64String) {
|
|
9637
|
+
let encodedString = base64String.replace(/-/g, "+").replace(/_/g, "/");
|
|
9638
|
+
switch (encodedString.length % 4) {
|
|
9639
|
+
case 0:
|
|
9640
|
+
break;
|
|
9641
|
+
case 2:
|
|
9642
|
+
encodedString += "==";
|
|
9643
|
+
break;
|
|
9644
|
+
case 3:
|
|
9645
|
+
encodedString += "=";
|
|
9646
|
+
break;
|
|
9647
|
+
default:
|
|
9648
|
+
throw createBrowserAuthError(invalidBase64String);
|
|
9649
|
+
}
|
|
9650
|
+
const binString = atob(encodedString);
|
|
9651
|
+
return Uint8Array.from(binString, (m) => m.codePointAt(0) || 0);
|
|
9652
|
+
}
|
|
9653
|
+
|
|
9687
9654
|
/*
|
|
9688
9655
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
9689
9656
|
* Licensed under the MIT License.
|
|
@@ -9695,8 +9662,10 @@ function base64EncArr(aBytes) {
|
|
|
9695
9662
|
/**
|
|
9696
9663
|
* See here for more info on RsaHashedKeyGenParams: https://developer.mozilla.org/en-US/docs/Web/API/RsaHashedKeyGenParams
|
|
9697
9664
|
*/
|
|
9698
|
-
//
|
|
9665
|
+
// Algorithms
|
|
9699
9666
|
const PKCS1_V15_KEYGEN_ALG = "RSASSA-PKCS1-v1_5";
|
|
9667
|
+
const AES_GCM = "AES-GCM";
|
|
9668
|
+
const HKDF = "HKDF";
|
|
9700
9669
|
// SHA-256 hashing algorithm
|
|
9701
9670
|
const S256_HASH_ALG = "SHA-256";
|
|
9702
9671
|
// MOD length for PoP tokens
|
|
@@ -9707,6 +9676,13 @@ const PUBLIC_EXPONENT = new Uint8Array([0x01, 0x00, 0x01]);
|
|
|
9707
9676
|
const UUID_CHARS = "0123456789abcdef";
|
|
9708
9677
|
// Array to store UINT32 random value
|
|
9709
9678
|
const UINT32_ARR = new Uint32Array(1);
|
|
9679
|
+
// Key Format
|
|
9680
|
+
const RAW = "raw";
|
|
9681
|
+
// Key Usages
|
|
9682
|
+
const ENCRYPT = "encrypt";
|
|
9683
|
+
const DECRYPT = "decrypt";
|
|
9684
|
+
const DERIVE_KEY = "deriveKey";
|
|
9685
|
+
// Suberror
|
|
9710
9686
|
const SUBTLE_SUBERROR = "crypto_subtle_undefined";
|
|
9711
9687
|
const keygenAlgorithmOptions = {
|
|
9712
9688
|
name: PKCS1_V15_KEYGEN_ALG,
|
|
@@ -9829,6 +9805,76 @@ async function importJwk(key, extractable, usages) {
|
|
|
9829
9805
|
async function sign(key, data) {
|
|
9830
9806
|
return window.crypto.subtle.sign(keygenAlgorithmOptions, key, data);
|
|
9831
9807
|
}
|
|
9808
|
+
/**
|
|
9809
|
+
* Generates symmetric base encryption key. This may be stored as all encryption/decryption keys will be derived from this one.
|
|
9810
|
+
*/
|
|
9811
|
+
async function generateBaseKey() {
|
|
9812
|
+
const key = await window.crypto.subtle.generateKey({
|
|
9813
|
+
name: AES_GCM,
|
|
9814
|
+
length: 256,
|
|
9815
|
+
}, true, [ENCRYPT, DECRYPT]);
|
|
9816
|
+
return window.crypto.subtle.exportKey(RAW, key);
|
|
9817
|
+
}
|
|
9818
|
+
/**
|
|
9819
|
+
* Returns the raw key to be passed into the key derivation function
|
|
9820
|
+
* @param baseKey
|
|
9821
|
+
* @returns
|
|
9822
|
+
*/
|
|
9823
|
+
async function generateHKDF(baseKey) {
|
|
9824
|
+
return window.crypto.subtle.importKey(RAW, baseKey, HKDF, false, [
|
|
9825
|
+
DERIVE_KEY,
|
|
9826
|
+
]);
|
|
9827
|
+
}
|
|
9828
|
+
/**
|
|
9829
|
+
* Given a base key and a nonce generates a derived key to be used in encryption and decryption.
|
|
9830
|
+
* Note: every time we encrypt a new key is derived
|
|
9831
|
+
* @param baseKey
|
|
9832
|
+
* @param nonce
|
|
9833
|
+
* @returns
|
|
9834
|
+
*/
|
|
9835
|
+
async function deriveKey(baseKey, nonce, context) {
|
|
9836
|
+
return window.crypto.subtle.deriveKey({
|
|
9837
|
+
name: HKDF,
|
|
9838
|
+
salt: nonce,
|
|
9839
|
+
hash: S256_HASH_ALG,
|
|
9840
|
+
info: new TextEncoder().encode(context),
|
|
9841
|
+
}, baseKey, { name: AES_GCM, length: 256 }, false, [ENCRYPT, DECRYPT]);
|
|
9842
|
+
}
|
|
9843
|
+
/**
|
|
9844
|
+
* Encrypt the given data given a base key. Returns encrypted data and a nonce that must be provided during decryption
|
|
9845
|
+
* @param key
|
|
9846
|
+
* @param rawData
|
|
9847
|
+
*/
|
|
9848
|
+
async function encrypt(baseKey, rawData, context) {
|
|
9849
|
+
const encodedData = new TextEncoder().encode(rawData);
|
|
9850
|
+
// The nonce must never be reused with a given key.
|
|
9851
|
+
const nonce = window.crypto.getRandomValues(new Uint8Array(16));
|
|
9852
|
+
const derivedKey = await deriveKey(baseKey, nonce, context);
|
|
9853
|
+
const encryptedData = await window.crypto.subtle.encrypt({
|
|
9854
|
+
name: AES_GCM,
|
|
9855
|
+
iv: new Uint8Array(12), // New key is derived for every encrypt so we don't need a new nonce
|
|
9856
|
+
}, derivedKey, encodedData);
|
|
9857
|
+
return {
|
|
9858
|
+
data: urlEncodeArr(new Uint8Array(encryptedData)),
|
|
9859
|
+
nonce: urlEncodeArr(nonce),
|
|
9860
|
+
};
|
|
9861
|
+
}
|
|
9862
|
+
/**
|
|
9863
|
+
* Decrypt data with the given key and nonce
|
|
9864
|
+
* @param key
|
|
9865
|
+
* @param nonce
|
|
9866
|
+
* @param encryptedData
|
|
9867
|
+
* @returns
|
|
9868
|
+
*/
|
|
9869
|
+
async function decrypt(baseKey, nonce, context, encryptedData) {
|
|
9870
|
+
const encodedData = base64DecToArr(encryptedData);
|
|
9871
|
+
const derivedKey = await deriveKey(baseKey, base64DecToArr(nonce), context);
|
|
9872
|
+
const decryptedData = await window.crypto.subtle.decrypt({
|
|
9873
|
+
name: AES_GCM,
|
|
9874
|
+
iv: new Uint8Array(12), // New key is derived for every encrypt so we don't need a new nonce
|
|
9875
|
+
}, derivedKey, encodedData);
|
|
9876
|
+
return new TextDecoder().decode(decryptedData);
|
|
9877
|
+
}
|
|
9832
9878
|
/**
|
|
9833
9879
|
* Returns the SHA-256 hash of an input string
|
|
9834
9880
|
* @param plainText
|
|
@@ -10366,7 +10412,7 @@ function buildConfiguration({ auth: userInputAuth, cache: userInputCache, system
|
|
|
10366
10412
|
|
|
10367
10413
|
/* eslint-disable header/header */
|
|
10368
10414
|
const name = "@azure/msal-browser";
|
|
10369
|
-
const version = "
|
|
10415
|
+
const version = "4.0.0-alpha.0";
|
|
10370
10416
|
|
|
10371
10417
|
/*
|
|
10372
10418
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -10742,43 +10788,6 @@ StandardOperatingContext.MODULE_NAME = "";
|
|
|
10742
10788
|
*/
|
|
10743
10789
|
StandardOperatingContext.ID = "StandardOperatingContext";
|
|
10744
10790
|
|
|
10745
|
-
/*
|
|
10746
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
10747
|
-
* Licensed under the MIT License.
|
|
10748
|
-
*/
|
|
10749
|
-
/**
|
|
10750
|
-
* Class which exposes APIs to decode base64 strings to plaintext. See here for implementation details:
|
|
10751
|
-
* https://developer.mozilla.org/en-US/docs/Glossary/Base64#the_unicode_problem
|
|
10752
|
-
*/
|
|
10753
|
-
/**
|
|
10754
|
-
* Returns a URL-safe plaintext decoded string from b64 encoded input.
|
|
10755
|
-
* @param input
|
|
10756
|
-
*/
|
|
10757
|
-
function base64Decode(input) {
|
|
10758
|
-
return new TextDecoder().decode(base64DecToArr(input));
|
|
10759
|
-
}
|
|
10760
|
-
/**
|
|
10761
|
-
* Decodes base64 into Uint8Array
|
|
10762
|
-
* @param base64String
|
|
10763
|
-
*/
|
|
10764
|
-
function base64DecToArr(base64String) {
|
|
10765
|
-
let encodedString = base64String.replace(/-/g, "+").replace(/_/g, "/");
|
|
10766
|
-
switch (encodedString.length % 4) {
|
|
10767
|
-
case 0:
|
|
10768
|
-
break;
|
|
10769
|
-
case 2:
|
|
10770
|
-
encodedString += "==";
|
|
10771
|
-
break;
|
|
10772
|
-
case 3:
|
|
10773
|
-
encodedString += "=";
|
|
10774
|
-
break;
|
|
10775
|
-
default:
|
|
10776
|
-
throw createBrowserAuthError(invalidBase64String);
|
|
10777
|
-
}
|
|
10778
|
-
const binString = atob(encodedString);
|
|
10779
|
-
return Uint8Array.from(binString, (m) => m.codePointAt(0) || 0);
|
|
10780
|
-
}
|
|
10781
|
-
|
|
10782
10791
|
/*
|
|
10783
10792
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
10784
10793
|
* Licensed under the MIT License.
|
|
@@ -10988,12 +10997,21 @@ class MemoryStorage {
|
|
|
10988
10997
|
constructor() {
|
|
10989
10998
|
this.cache = new Map();
|
|
10990
10999
|
}
|
|
11000
|
+
async initialize() {
|
|
11001
|
+
// Memory storage does not require initialization
|
|
11002
|
+
}
|
|
10991
11003
|
getItem(key) {
|
|
10992
11004
|
return this.cache.get(key) || null;
|
|
10993
11005
|
}
|
|
11006
|
+
getUserData(key) {
|
|
11007
|
+
return this.getItem(key);
|
|
11008
|
+
}
|
|
10994
11009
|
setItem(key, value) {
|
|
10995
11010
|
this.cache.set(key, value);
|
|
10996
11011
|
}
|
|
11012
|
+
async setUserData(key, value) {
|
|
11013
|
+
this.setItem(key, value);
|
|
11014
|
+
}
|
|
10997
11015
|
removeItem(key) {
|
|
10998
11016
|
this.cache.delete(key);
|
|
10999
11017
|
}
|
|
@@ -11325,19 +11343,188 @@ function getSortedObjectString(obj) {
|
|
|
11325
11343
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
11326
11344
|
* Licensed under the MIT License.
|
|
11327
11345
|
*/
|
|
11346
|
+
// Cookie life calculation (hours * minutes * seconds * ms)
|
|
11347
|
+
const COOKIE_LIFE_MULTIPLIER = 24 * 60 * 60 * 1000;
|
|
11348
|
+
class CookieStorage {
|
|
11349
|
+
initialize() {
|
|
11350
|
+
return Promise.resolve();
|
|
11351
|
+
}
|
|
11352
|
+
getItem(key) {
|
|
11353
|
+
const name = `${encodeURIComponent(key)}`;
|
|
11354
|
+
const cookieList = document.cookie.split(";");
|
|
11355
|
+
for (let i = 0; i < cookieList.length; i++) {
|
|
11356
|
+
const cookie = cookieList[i];
|
|
11357
|
+
const [key, ...rest] = decodeURIComponent(cookie).trim().split("=");
|
|
11358
|
+
const value = rest.join("=");
|
|
11359
|
+
if (key === name) {
|
|
11360
|
+
return value;
|
|
11361
|
+
}
|
|
11362
|
+
}
|
|
11363
|
+
return "";
|
|
11364
|
+
}
|
|
11365
|
+
getUserData() {
|
|
11366
|
+
throw createClientAuthError(methodNotImplemented);
|
|
11367
|
+
}
|
|
11368
|
+
setItem(key, value, cookieLifeDays, secure = true) {
|
|
11369
|
+
let cookieStr = `${encodeURIComponent(key)}=${encodeURIComponent(value)};path=/;SameSite=Lax;`;
|
|
11370
|
+
if (cookieLifeDays) {
|
|
11371
|
+
const expireTime = getCookieExpirationTime(cookieLifeDays);
|
|
11372
|
+
cookieStr += `expires=${expireTime};`;
|
|
11373
|
+
}
|
|
11374
|
+
if (secure) {
|
|
11375
|
+
cookieStr += "Secure;";
|
|
11376
|
+
}
|
|
11377
|
+
document.cookie = cookieStr;
|
|
11378
|
+
}
|
|
11379
|
+
async setUserData() {
|
|
11380
|
+
return Promise.reject(createClientAuthError(methodNotImplemented));
|
|
11381
|
+
}
|
|
11382
|
+
removeItem(key) {
|
|
11383
|
+
// Setting expiration to -1 removes it
|
|
11384
|
+
this.setItem(key, "", -1);
|
|
11385
|
+
}
|
|
11386
|
+
getKeys() {
|
|
11387
|
+
const cookieList = document.cookie.split(";");
|
|
11388
|
+
const keys = [];
|
|
11389
|
+
cookieList.forEach((cookie) => {
|
|
11390
|
+
const cookieParts = decodeURIComponent(cookie).trim().split("=");
|
|
11391
|
+
keys.push(cookieParts[0]);
|
|
11392
|
+
});
|
|
11393
|
+
return keys;
|
|
11394
|
+
}
|
|
11395
|
+
containsKey(key) {
|
|
11396
|
+
return this.getKeys().includes(key);
|
|
11397
|
+
}
|
|
11398
|
+
}
|
|
11399
|
+
/**
|
|
11400
|
+
* Get cookie expiration time
|
|
11401
|
+
* @param cookieLifeDays
|
|
11402
|
+
*/
|
|
11403
|
+
function getCookieExpirationTime(cookieLifeDays) {
|
|
11404
|
+
const today = new Date();
|
|
11405
|
+
const expr = new Date(today.getTime() + cookieLifeDays * COOKIE_LIFE_MULTIPLIER);
|
|
11406
|
+
return expr.toUTCString();
|
|
11407
|
+
}
|
|
11408
|
+
|
|
11409
|
+
/*
|
|
11410
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
11411
|
+
* Licensed under the MIT License.
|
|
11412
|
+
*/
|
|
11413
|
+
/**
|
|
11414
|
+
* Returns a list of cache keys for all known accounts
|
|
11415
|
+
* @param storage
|
|
11416
|
+
* @returns
|
|
11417
|
+
*/
|
|
11418
|
+
function getAccountKeys(storage) {
|
|
11419
|
+
const accountKeys = storage.getItem(StaticCacheKeys.ACCOUNT_KEYS);
|
|
11420
|
+
if (accountKeys) {
|
|
11421
|
+
return JSON.parse(accountKeys);
|
|
11422
|
+
}
|
|
11423
|
+
return [];
|
|
11424
|
+
}
|
|
11425
|
+
/**
|
|
11426
|
+
* Returns a list of cache keys for all known tokens
|
|
11427
|
+
* @param clientId
|
|
11428
|
+
* @param storage
|
|
11429
|
+
* @returns
|
|
11430
|
+
*/
|
|
11431
|
+
function getTokenKeys(clientId, storage) {
|
|
11432
|
+
const item = storage.getItem(`${StaticCacheKeys.TOKEN_KEYS}.${clientId}`);
|
|
11433
|
+
if (item) {
|
|
11434
|
+
const tokenKeys = JSON.parse(item);
|
|
11435
|
+
if (tokenKeys &&
|
|
11436
|
+
tokenKeys.hasOwnProperty("idToken") &&
|
|
11437
|
+
tokenKeys.hasOwnProperty("accessToken") &&
|
|
11438
|
+
tokenKeys.hasOwnProperty("refreshToken")) {
|
|
11439
|
+
return tokenKeys;
|
|
11440
|
+
}
|
|
11441
|
+
}
|
|
11442
|
+
return {
|
|
11443
|
+
idToken: [],
|
|
11444
|
+
accessToken: [],
|
|
11445
|
+
refreshToken: [],
|
|
11446
|
+
};
|
|
11447
|
+
}
|
|
11448
|
+
|
|
11449
|
+
/*
|
|
11450
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
11451
|
+
* Licensed under the MIT License.
|
|
11452
|
+
*/
|
|
11453
|
+
const ENCRYPTION_KEY = "msal.cache.encryption";
|
|
11328
11454
|
class LocalStorage {
|
|
11329
|
-
constructor() {
|
|
11455
|
+
constructor(clientId) {
|
|
11330
11456
|
if (!window.localStorage) {
|
|
11331
11457
|
throw createBrowserConfigurationAuthError(storageNotSupported);
|
|
11332
11458
|
}
|
|
11459
|
+
this.memoryStorage = new MemoryStorage();
|
|
11460
|
+
this.initialized = false;
|
|
11461
|
+
this.clientId = clientId;
|
|
11462
|
+
}
|
|
11463
|
+
async initialize() {
|
|
11464
|
+
this.initialized = true;
|
|
11465
|
+
const cookies = new CookieStorage();
|
|
11466
|
+
const cookieString = cookies.getItem(ENCRYPTION_KEY);
|
|
11467
|
+
let parsedCookie = { key: "", id: "" };
|
|
11468
|
+
if (cookieString) {
|
|
11469
|
+
try {
|
|
11470
|
+
parsedCookie = JSON.parse(cookieString);
|
|
11471
|
+
}
|
|
11472
|
+
catch (e) {
|
|
11473
|
+
// TODO: Log telemetry but don't throw
|
|
11474
|
+
}
|
|
11475
|
+
}
|
|
11476
|
+
if (parsedCookie.key && parsedCookie.id) {
|
|
11477
|
+
// Encryption key already exists, import
|
|
11478
|
+
this.encryptionCookie = {
|
|
11479
|
+
id: parsedCookie.id,
|
|
11480
|
+
key: await generateHKDF(base64DecToArr(parsedCookie.key)),
|
|
11481
|
+
};
|
|
11482
|
+
await this.importExistingCache();
|
|
11483
|
+
}
|
|
11484
|
+
else {
|
|
11485
|
+
// Encryption key doesn't exist or is invalid, generate a new one and clear existing cache
|
|
11486
|
+
this.clear();
|
|
11487
|
+
const id = createNewGuid();
|
|
11488
|
+
const baseKey = await generateBaseKey();
|
|
11489
|
+
const keyStr = urlEncodeArr(new Uint8Array(baseKey));
|
|
11490
|
+
this.encryptionCookie = {
|
|
11491
|
+
id: id,
|
|
11492
|
+
key: await generateHKDF(baseKey),
|
|
11493
|
+
};
|
|
11494
|
+
const cookieData = {
|
|
11495
|
+
id: id,
|
|
11496
|
+
key: keyStr,
|
|
11497
|
+
};
|
|
11498
|
+
cookies.setItem(ENCRYPTION_KEY, JSON.stringify(cookieData));
|
|
11499
|
+
}
|
|
11333
11500
|
}
|
|
11334
11501
|
getItem(key) {
|
|
11335
11502
|
return window.localStorage.getItem(key);
|
|
11336
11503
|
}
|
|
11504
|
+
getUserData(key) {
|
|
11505
|
+
if (!this.initialized) {
|
|
11506
|
+
throw createBrowserAuthError(uninitializedPublicClientApplication);
|
|
11507
|
+
}
|
|
11508
|
+
return this.memoryStorage.getItem(key);
|
|
11509
|
+
}
|
|
11337
11510
|
setItem(key, value) {
|
|
11338
11511
|
window.localStorage.setItem(key, value);
|
|
11339
11512
|
}
|
|
11513
|
+
async setUserData(key, value) {
|
|
11514
|
+
if (!this.initialized || !this.encryptionCookie) {
|
|
11515
|
+
throw createBrowserAuthError(uninitializedPublicClientApplication);
|
|
11516
|
+
}
|
|
11517
|
+
const { data, nonce } = await encrypt(this.encryptionCookie.key, value, this.getContext(key));
|
|
11518
|
+
const encryptedData = {
|
|
11519
|
+
id: this.encryptionCookie.id,
|
|
11520
|
+
nonce: nonce,
|
|
11521
|
+
data: data,
|
|
11522
|
+
};
|
|
11523
|
+
this.memoryStorage.setItem(key, value);
|
|
11524
|
+
this.setItem(key, JSON.stringify(encryptedData));
|
|
11525
|
+
}
|
|
11340
11526
|
removeItem(key) {
|
|
11527
|
+
this.memoryStorage.removeItem(key);
|
|
11341
11528
|
window.localStorage.removeItem(key);
|
|
11342
11529
|
}
|
|
11343
11530
|
getKeys() {
|
|
@@ -11346,6 +11533,102 @@ class LocalStorage {
|
|
|
11346
11533
|
containsKey(key) {
|
|
11347
11534
|
return window.localStorage.hasOwnProperty(key);
|
|
11348
11535
|
}
|
|
11536
|
+
/**
|
|
11537
|
+
* Removes all known MSAL keys from the cache
|
|
11538
|
+
*/
|
|
11539
|
+
clear() {
|
|
11540
|
+
// Removes all remaining MSAL cache items
|
|
11541
|
+
this.memoryStorage.clear();
|
|
11542
|
+
const accountKeys = getAccountKeys(this);
|
|
11543
|
+
accountKeys.forEach((key) => this.removeItem(key));
|
|
11544
|
+
const tokenKeys = getTokenKeys(this.clientId, this);
|
|
11545
|
+
tokenKeys.idToken.forEach((key) => this.removeItem(key));
|
|
11546
|
+
tokenKeys.accessToken.forEach((key) => this.removeItem(key));
|
|
11547
|
+
tokenKeys.refreshToken.forEach((key) => this.removeItem(key));
|
|
11548
|
+
// Clean up anything left
|
|
11549
|
+
this.getKeys().forEach((cacheKey) => {
|
|
11550
|
+
if (cacheKey.startsWith(Constants.CACHE_PREFIX) ||
|
|
11551
|
+
cacheKey.indexOf(this.clientId) !== -1) {
|
|
11552
|
+
this.removeItem(cacheKey);
|
|
11553
|
+
}
|
|
11554
|
+
});
|
|
11555
|
+
}
|
|
11556
|
+
/**
|
|
11557
|
+
* Helper to decrypt all known MSAL keys in localStorage and save them to inMemory storage
|
|
11558
|
+
* @returns
|
|
11559
|
+
*/
|
|
11560
|
+
async importExistingCache() {
|
|
11561
|
+
if (!this.encryptionCookie) {
|
|
11562
|
+
return;
|
|
11563
|
+
}
|
|
11564
|
+
const accountKeys = getAccountKeys(this);
|
|
11565
|
+
await this.importArray(accountKeys);
|
|
11566
|
+
const tokenKeys = getTokenKeys(this.clientId, this);
|
|
11567
|
+
await Promise.all([
|
|
11568
|
+
this.importArray(tokenKeys.idToken),
|
|
11569
|
+
this.importArray(tokenKeys.accessToken),
|
|
11570
|
+
this.importArray(tokenKeys.refreshToken),
|
|
11571
|
+
]);
|
|
11572
|
+
}
|
|
11573
|
+
/**
|
|
11574
|
+
* Helper to decrypt and save cache entries
|
|
11575
|
+
* @param key
|
|
11576
|
+
* @returns
|
|
11577
|
+
*/
|
|
11578
|
+
async getItemFromEncryptedCache(key) {
|
|
11579
|
+
if (!this.encryptionCookie) {
|
|
11580
|
+
return null;
|
|
11581
|
+
}
|
|
11582
|
+
const rawCache = this.getItem(key);
|
|
11583
|
+
if (!rawCache) {
|
|
11584
|
+
return null;
|
|
11585
|
+
}
|
|
11586
|
+
let encObj;
|
|
11587
|
+
try {
|
|
11588
|
+
encObj = JSON.parse(rawCache);
|
|
11589
|
+
if (!encObj.id || !encObj.nonce || !encObj.data) {
|
|
11590
|
+
throw "Not encrypted!"; // TODO: Typed error
|
|
11591
|
+
}
|
|
11592
|
+
if (encObj.id !== this.encryptionCookie.id) {
|
|
11593
|
+
throw "Old item!"; // TODO: Typed error
|
|
11594
|
+
}
|
|
11595
|
+
}
|
|
11596
|
+
catch (e) {
|
|
11597
|
+
// Not a valid encrypted object, remove
|
|
11598
|
+
this.removeItem(key);
|
|
11599
|
+
// TODO: Log to telemetry
|
|
11600
|
+
return null;
|
|
11601
|
+
}
|
|
11602
|
+
return decrypt(this.encryptionCookie.key, encObj.nonce, this.getContext(key), encObj.data);
|
|
11603
|
+
}
|
|
11604
|
+
/**
|
|
11605
|
+
* Helper to decrypt and save an array of cache keys
|
|
11606
|
+
* @param arr
|
|
11607
|
+
*/
|
|
11608
|
+
async importArray(arr) {
|
|
11609
|
+
const promiseArr = [];
|
|
11610
|
+
arr.forEach((key) => {
|
|
11611
|
+
const promise = this.getItemFromEncryptedCache(key).then((value) => {
|
|
11612
|
+
if (value) {
|
|
11613
|
+
this.memoryStorage.setItem(key, value);
|
|
11614
|
+
}
|
|
11615
|
+
});
|
|
11616
|
+
promiseArr.push(promise);
|
|
11617
|
+
});
|
|
11618
|
+
await Promise.all(promiseArr);
|
|
11619
|
+
}
|
|
11620
|
+
/**
|
|
11621
|
+
* Gets encryption context for a given cache entry. This is clientId for app specific entries, empty string for shared entries
|
|
11622
|
+
* @param key
|
|
11623
|
+
* @returns
|
|
11624
|
+
*/
|
|
11625
|
+
getContext(key) {
|
|
11626
|
+
let context = "";
|
|
11627
|
+
if (key.includes(this.clientId)) {
|
|
11628
|
+
context = this.clientId; // Used to bind encryption key to this appId
|
|
11629
|
+
}
|
|
11630
|
+
return context;
|
|
11631
|
+
}
|
|
11349
11632
|
}
|
|
11350
11633
|
|
|
11351
11634
|
/*
|
|
@@ -11358,12 +11641,21 @@ class SessionStorage {
|
|
|
11358
11641
|
throw createBrowserConfigurationAuthError(storageNotSupported);
|
|
11359
11642
|
}
|
|
11360
11643
|
}
|
|
11644
|
+
async initialize() {
|
|
11645
|
+
// Session storage does not require initialization
|
|
11646
|
+
}
|
|
11361
11647
|
getItem(key) {
|
|
11362
11648
|
return window.sessionStorage.getItem(key);
|
|
11363
11649
|
}
|
|
11650
|
+
getUserData(key) {
|
|
11651
|
+
return this.getItem(key);
|
|
11652
|
+
}
|
|
11364
11653
|
setItem(key, value) {
|
|
11365
11654
|
window.sessionStorage.setItem(key, value);
|
|
11366
11655
|
}
|
|
11656
|
+
async setUserData(key, value) {
|
|
11657
|
+
this.setItem(key, value);
|
|
11658
|
+
}
|
|
11367
11659
|
removeItem(key) {
|
|
11368
11660
|
window.sessionStorage.removeItem(key);
|
|
11369
11661
|
}
|
|
@@ -11397,64 +11689,6 @@ function extractBrowserRequestState(browserCrypto, state) {
|
|
|
11397
11689
|
}
|
|
11398
11690
|
}
|
|
11399
11691
|
|
|
11400
|
-
/*
|
|
11401
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
11402
|
-
* Licensed under the MIT License.
|
|
11403
|
-
*/
|
|
11404
|
-
// Cookie life calculation (hours * minutes * seconds * ms)
|
|
11405
|
-
const COOKIE_LIFE_MULTIPLIER = 24 * 60 * 60 * 1000;
|
|
11406
|
-
class CookieStorage {
|
|
11407
|
-
getItem(key) {
|
|
11408
|
-
const name = `${encodeURIComponent(key)}`;
|
|
11409
|
-
const cookieList = document.cookie.split(";");
|
|
11410
|
-
for (let i = 0; i < cookieList.length; i++) {
|
|
11411
|
-
const cookie = cookieList[i];
|
|
11412
|
-
const [key, ...rest] = decodeURIComponent(cookie).trim().split("=");
|
|
11413
|
-
const value = rest.join("=");
|
|
11414
|
-
if (key === name) {
|
|
11415
|
-
return value;
|
|
11416
|
-
}
|
|
11417
|
-
}
|
|
11418
|
-
return "";
|
|
11419
|
-
}
|
|
11420
|
-
setItem(key, value, cookieLifeDays, secure = true) {
|
|
11421
|
-
let cookieStr = `${encodeURIComponent(key)}=${encodeURIComponent(value)};path=/;SameSite=Lax;`;
|
|
11422
|
-
if (cookieLifeDays) {
|
|
11423
|
-
const expireTime = getCookieExpirationTime(cookieLifeDays);
|
|
11424
|
-
cookieStr += `expires=${expireTime};`;
|
|
11425
|
-
}
|
|
11426
|
-
if (secure) {
|
|
11427
|
-
cookieStr += "Secure;";
|
|
11428
|
-
}
|
|
11429
|
-
document.cookie = cookieStr;
|
|
11430
|
-
}
|
|
11431
|
-
removeItem(key) {
|
|
11432
|
-
// Setting expiration to -1 removes it
|
|
11433
|
-
this.setItem(key, "", -1);
|
|
11434
|
-
}
|
|
11435
|
-
getKeys() {
|
|
11436
|
-
const cookieList = document.cookie.split(";");
|
|
11437
|
-
const keys = [];
|
|
11438
|
-
cookieList.forEach((cookie) => {
|
|
11439
|
-
const cookieParts = decodeURIComponent(cookie).trim().split("=");
|
|
11440
|
-
keys.push(cookieParts[0]);
|
|
11441
|
-
});
|
|
11442
|
-
return keys;
|
|
11443
|
-
}
|
|
11444
|
-
containsKey(key) {
|
|
11445
|
-
return this.getKeys().includes(key);
|
|
11446
|
-
}
|
|
11447
|
-
}
|
|
11448
|
-
/**
|
|
11449
|
-
* Get cookie expiration time
|
|
11450
|
-
* @param cookieLifeDays
|
|
11451
|
-
*/
|
|
11452
|
-
function getCookieExpirationTime(cookieLifeDays) {
|
|
11453
|
-
const today = new Date();
|
|
11454
|
-
const expr = new Date(today.getTime() + cookieLifeDays * COOKIE_LIFE_MULTIPLIER);
|
|
11455
|
-
return expr.toUTCString();
|
|
11456
|
-
}
|
|
11457
|
-
|
|
11458
11692
|
/*
|
|
11459
11693
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
11460
11694
|
* Licensed under the MIT License.
|
|
@@ -11473,13 +11707,11 @@ class BrowserCacheManager extends CacheManager {
|
|
|
11473
11707
|
this.browserStorage = this.setupBrowserStorage(this.cacheConfig.cacheLocation);
|
|
11474
11708
|
this.temporaryCacheStorage = this.setupBrowserStorage(this.cacheConfig.temporaryCacheLocation);
|
|
11475
11709
|
this.cookieStorage = new CookieStorage();
|
|
11476
|
-
// Migrate cache entries from older versions of MSAL.
|
|
11477
|
-
if (cacheConfig.cacheMigrationEnabled) {
|
|
11478
|
-
this.migrateCacheEntries();
|
|
11479
|
-
this.createKeyMaps();
|
|
11480
|
-
}
|
|
11481
11710
|
this.performanceClient = performanceClient;
|
|
11482
11711
|
}
|
|
11712
|
+
async initialize() {
|
|
11713
|
+
await this.browserStorage.initialize();
|
|
11714
|
+
}
|
|
11483
11715
|
/**
|
|
11484
11716
|
* Returns a window storage class implementing the IWindowStorage interface that corresponds to the configured cacheLocation.
|
|
11485
11717
|
* @param cacheLocation
|
|
@@ -11488,7 +11720,7 @@ class BrowserCacheManager extends CacheManager {
|
|
|
11488
11720
|
try {
|
|
11489
11721
|
switch (cacheLocation) {
|
|
11490
11722
|
case BrowserCacheLocation.LocalStorage:
|
|
11491
|
-
return new LocalStorage();
|
|
11723
|
+
return new LocalStorage(this.clientId);
|
|
11492
11724
|
case BrowserCacheLocation.SessionStorage:
|
|
11493
11725
|
return new SessionStorage();
|
|
11494
11726
|
case BrowserCacheLocation.MemoryStorage:
|
|
@@ -11502,123 +11734,6 @@ class BrowserCacheManager extends CacheManager {
|
|
|
11502
11734
|
this.cacheConfig.cacheLocation = BrowserCacheLocation.MemoryStorage;
|
|
11503
11735
|
return new MemoryStorage();
|
|
11504
11736
|
}
|
|
11505
|
-
/**
|
|
11506
|
-
* Migrate all old cache entries to new schema. No rollback supported.
|
|
11507
|
-
* @param storeAuthStateInCookie
|
|
11508
|
-
*/
|
|
11509
|
-
migrateCacheEntries() {
|
|
11510
|
-
const idTokenKey = `${Constants.CACHE_PREFIX}.${PersistentCacheKeys.ID_TOKEN}`;
|
|
11511
|
-
const clientInfoKey = `${Constants.CACHE_PREFIX}.${PersistentCacheKeys.CLIENT_INFO}`;
|
|
11512
|
-
const errorKey = `${Constants.CACHE_PREFIX}.${PersistentCacheKeys.ERROR}`;
|
|
11513
|
-
const errorDescKey = `${Constants.CACHE_PREFIX}.${PersistentCacheKeys.ERROR_DESC}`;
|
|
11514
|
-
const idTokenValue = this.browserStorage.getItem(idTokenKey);
|
|
11515
|
-
const clientInfoValue = this.browserStorage.getItem(clientInfoKey);
|
|
11516
|
-
const errorValue = this.browserStorage.getItem(errorKey);
|
|
11517
|
-
const errorDescValue = this.browserStorage.getItem(errorDescKey);
|
|
11518
|
-
const values = [
|
|
11519
|
-
idTokenValue,
|
|
11520
|
-
clientInfoValue,
|
|
11521
|
-
errorValue,
|
|
11522
|
-
errorDescValue,
|
|
11523
|
-
];
|
|
11524
|
-
const keysToMigrate = [
|
|
11525
|
-
PersistentCacheKeys.ID_TOKEN,
|
|
11526
|
-
PersistentCacheKeys.CLIENT_INFO,
|
|
11527
|
-
PersistentCacheKeys.ERROR,
|
|
11528
|
-
PersistentCacheKeys.ERROR_DESC,
|
|
11529
|
-
];
|
|
11530
|
-
keysToMigrate.forEach((cacheKey, index) => {
|
|
11531
|
-
const value = values[index];
|
|
11532
|
-
if (value) {
|
|
11533
|
-
this.setTemporaryCache(cacheKey, value, true);
|
|
11534
|
-
}
|
|
11535
|
-
});
|
|
11536
|
-
}
|
|
11537
|
-
/**
|
|
11538
|
-
* Searches all cache entries for MSAL accounts and creates the account key map
|
|
11539
|
-
* This is used to migrate users from older versions of MSAL which did not create the map.
|
|
11540
|
-
* @returns
|
|
11541
|
-
*/
|
|
11542
|
-
createKeyMaps() {
|
|
11543
|
-
this.logger.trace("BrowserCacheManager - createKeyMaps called.");
|
|
11544
|
-
const accountKeys = this.getItem(StaticCacheKeys.ACCOUNT_KEYS);
|
|
11545
|
-
const tokenKeys = this.getItem(`${StaticCacheKeys.TOKEN_KEYS}.${this.clientId}`);
|
|
11546
|
-
if (accountKeys && tokenKeys) {
|
|
11547
|
-
this.logger.verbose("BrowserCacheManager:createKeyMaps - account and token key maps already exist, skipping migration.");
|
|
11548
|
-
// Key maps already exist, no need to iterate through cache
|
|
11549
|
-
return;
|
|
11550
|
-
}
|
|
11551
|
-
const allKeys = this.browserStorage.getKeys();
|
|
11552
|
-
allKeys.forEach((key) => {
|
|
11553
|
-
if (this.isCredentialKey(key)) {
|
|
11554
|
-
// Get item, parse, validate and write key to map
|
|
11555
|
-
const value = this.getItem(key);
|
|
11556
|
-
if (value) {
|
|
11557
|
-
const credObj = this.validateAndParseJson(value);
|
|
11558
|
-
if (credObj && credObj.hasOwnProperty("credentialType")) {
|
|
11559
|
-
switch (credObj["credentialType"]) {
|
|
11560
|
-
case CredentialType.ID_TOKEN:
|
|
11561
|
-
if (isIdTokenEntity(credObj)) {
|
|
11562
|
-
this.logger.trace("BrowserCacheManager:createKeyMaps - idToken found, saving key to token key map");
|
|
11563
|
-
this.logger.tracePii(`BrowserCacheManager:createKeyMaps - idToken with key: ${key} found, saving key to token key map`);
|
|
11564
|
-
const idTokenEntity = credObj;
|
|
11565
|
-
const newKey = this.updateCredentialCacheKey(key, idTokenEntity);
|
|
11566
|
-
this.addTokenKey(newKey, CredentialType.ID_TOKEN);
|
|
11567
|
-
return;
|
|
11568
|
-
}
|
|
11569
|
-
else {
|
|
11570
|
-
this.logger.trace("BrowserCacheManager:createKeyMaps - key found matching idToken schema with value containing idToken credentialType field but value failed IdTokenEntity validation, skipping.");
|
|
11571
|
-
this.logger.tracePii(`BrowserCacheManager:createKeyMaps - failed idToken validation on key: ${key}`);
|
|
11572
|
-
}
|
|
11573
|
-
break;
|
|
11574
|
-
case CredentialType.ACCESS_TOKEN:
|
|
11575
|
-
case CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME:
|
|
11576
|
-
if (isAccessTokenEntity(credObj)) {
|
|
11577
|
-
this.logger.trace("BrowserCacheManager:createKeyMaps - accessToken found, saving key to token key map");
|
|
11578
|
-
this.logger.tracePii(`BrowserCacheManager:createKeyMaps - accessToken with key: ${key} found, saving key to token key map`);
|
|
11579
|
-
const accessTokenEntity = credObj;
|
|
11580
|
-
const newKey = this.updateCredentialCacheKey(key, accessTokenEntity);
|
|
11581
|
-
this.addTokenKey(newKey, CredentialType.ACCESS_TOKEN);
|
|
11582
|
-
return;
|
|
11583
|
-
}
|
|
11584
|
-
else {
|
|
11585
|
-
this.logger.trace("BrowserCacheManager:createKeyMaps - key found matching accessToken schema with value containing accessToken credentialType field but value failed AccessTokenEntity validation, skipping.");
|
|
11586
|
-
this.logger.tracePii(`BrowserCacheManager:createKeyMaps - failed accessToken validation on key: ${key}`);
|
|
11587
|
-
}
|
|
11588
|
-
break;
|
|
11589
|
-
case CredentialType.REFRESH_TOKEN:
|
|
11590
|
-
if (isRefreshTokenEntity(credObj)) {
|
|
11591
|
-
this.logger.trace("BrowserCacheManager:createKeyMaps - refreshToken found, saving key to token key map");
|
|
11592
|
-
this.logger.tracePii(`BrowserCacheManager:createKeyMaps - refreshToken with key: ${key} found, saving key to token key map`);
|
|
11593
|
-
const refreshTokenEntity = credObj;
|
|
11594
|
-
const newKey = this.updateCredentialCacheKey(key, refreshTokenEntity);
|
|
11595
|
-
this.addTokenKey(newKey, CredentialType.REFRESH_TOKEN);
|
|
11596
|
-
return;
|
|
11597
|
-
}
|
|
11598
|
-
else {
|
|
11599
|
-
this.logger.trace("BrowserCacheManager:createKeyMaps - key found matching refreshToken schema with value containing refreshToken credentialType field but value failed RefreshTokenEntity validation, skipping.");
|
|
11600
|
-
this.logger.tracePii(`BrowserCacheManager:createKeyMaps - failed refreshToken validation on key: ${key}`);
|
|
11601
|
-
}
|
|
11602
|
-
break;
|
|
11603
|
-
// If credentialType isn't one of our predefined ones, it may not be an MSAL cache value. Ignore.
|
|
11604
|
-
}
|
|
11605
|
-
}
|
|
11606
|
-
}
|
|
11607
|
-
}
|
|
11608
|
-
if (this.isAccountKey(key)) {
|
|
11609
|
-
const value = this.getItem(key);
|
|
11610
|
-
if (value) {
|
|
11611
|
-
const accountObj = this.validateAndParseJson(value);
|
|
11612
|
-
if (accountObj &&
|
|
11613
|
-
AccountEntity.isAccountEntity(accountObj)) {
|
|
11614
|
-
this.logger.trace("BrowserCacheManager:createKeyMaps - account found, saving key to account key map");
|
|
11615
|
-
this.logger.tracePii(`BrowserCacheManager:createKeyMaps - account with key: ${key} found, saving key to account key map`);
|
|
11616
|
-
this.addAccountKeyToMap(key);
|
|
11617
|
-
}
|
|
11618
|
-
}
|
|
11619
|
-
}
|
|
11620
|
-
});
|
|
11621
|
-
}
|
|
11622
11737
|
/**
|
|
11623
11738
|
* Parses passed value as JSON object, JSON.parse() will throw an error.
|
|
11624
11739
|
* @param input
|
|
@@ -11640,38 +11755,15 @@ class BrowserCacheManager extends CacheManager {
|
|
|
11640
11755
|
return null;
|
|
11641
11756
|
}
|
|
11642
11757
|
}
|
|
11643
|
-
/**
|
|
11644
|
-
* fetches the entry from the browser storage based off the key
|
|
11645
|
-
* @param key
|
|
11646
|
-
*/
|
|
11647
|
-
getItem(key) {
|
|
11648
|
-
return this.browserStorage.getItem(key);
|
|
11649
|
-
}
|
|
11650
|
-
/**
|
|
11651
|
-
* sets the entry in the browser storage
|
|
11652
|
-
* @param key
|
|
11653
|
-
* @param value
|
|
11654
|
-
*/
|
|
11655
|
-
setItem(key, value) {
|
|
11656
|
-
this.browserStorage.setItem(key, value);
|
|
11657
|
-
}
|
|
11658
|
-
/**
|
|
11659
|
-
* fetch the account entity from the platform cache
|
|
11660
|
-
* @param accountKey
|
|
11661
|
-
*/
|
|
11662
|
-
getAccount(accountKey, logger) {
|
|
11663
|
-
this.logger.trace("BrowserCacheManager.getAccount called");
|
|
11664
|
-
const accountEntity = this.getCachedAccountEntity(accountKey);
|
|
11665
|
-
return this.updateOutdatedCachedAccount(accountKey, accountEntity, logger);
|
|
11666
|
-
}
|
|
11667
11758
|
/**
|
|
11668
11759
|
* Reads account from cache, deserializes it into an account entity and returns it.
|
|
11669
11760
|
* If account is not found from the key, returns null and removes key from map.
|
|
11670
11761
|
* @param accountKey
|
|
11671
11762
|
* @returns
|
|
11672
11763
|
*/
|
|
11673
|
-
|
|
11674
|
-
|
|
11764
|
+
getAccount(accountKey) {
|
|
11765
|
+
this.logger.trace("BrowserCacheManager.getAccount called");
|
|
11766
|
+
const serializedAccount = this.browserStorage.getUserData(accountKey);
|
|
11675
11767
|
if (!serializedAccount) {
|
|
11676
11768
|
this.removeAccountKeyFromMap(accountKey);
|
|
11677
11769
|
return null;
|
|
@@ -11687,10 +11779,10 @@ class BrowserCacheManager extends CacheManager {
|
|
|
11687
11779
|
* set account entity in the platform cache
|
|
11688
11780
|
* @param account
|
|
11689
11781
|
*/
|
|
11690
|
-
setAccount(account) {
|
|
11782
|
+
async setAccount(account) {
|
|
11691
11783
|
this.logger.trace("BrowserCacheManager.setAccount called");
|
|
11692
11784
|
const key = account.generateAccountKey();
|
|
11693
|
-
this.
|
|
11785
|
+
await this.browserStorage.setUserData(key, JSON.stringify(account));
|
|
11694
11786
|
this.addAccountKeyToMap(key);
|
|
11695
11787
|
}
|
|
11696
11788
|
/**
|
|
@@ -11698,13 +11790,7 @@ class BrowserCacheManager extends CacheManager {
|
|
|
11698
11790
|
* @returns
|
|
11699
11791
|
*/
|
|
11700
11792
|
getAccountKeys() {
|
|
11701
|
-
this.
|
|
11702
|
-
const accountKeys = this.getItem(StaticCacheKeys.ACCOUNT_KEYS);
|
|
11703
|
-
if (accountKeys) {
|
|
11704
|
-
return JSON.parse(accountKeys);
|
|
11705
|
-
}
|
|
11706
|
-
this.logger.verbose("BrowserCacheManager.getAccountKeys - No account keys found");
|
|
11707
|
-
return [];
|
|
11793
|
+
return getAccountKeys(this.browserStorage);
|
|
11708
11794
|
}
|
|
11709
11795
|
/**
|
|
11710
11796
|
* Add a new account to the key map
|
|
@@ -11717,7 +11803,7 @@ class BrowserCacheManager extends CacheManager {
|
|
|
11717
11803
|
if (accountKeys.indexOf(key) === -1) {
|
|
11718
11804
|
// Only add key if it does not already exist in the map
|
|
11719
11805
|
accountKeys.push(key);
|
|
11720
|
-
this.setItem(StaticCacheKeys.ACCOUNT_KEYS, JSON.stringify(accountKeys));
|
|
11806
|
+
this.browserStorage.setItem(StaticCacheKeys.ACCOUNT_KEYS, JSON.stringify(accountKeys));
|
|
11721
11807
|
this.logger.verbose("BrowserCacheManager.addAccountKeyToMap account key added");
|
|
11722
11808
|
}
|
|
11723
11809
|
else {
|
|
@@ -11735,7 +11821,7 @@ class BrowserCacheManager extends CacheManager {
|
|
|
11735
11821
|
const removalIndex = accountKeys.indexOf(key);
|
|
11736
11822
|
if (removalIndex > -1) {
|
|
11737
11823
|
accountKeys.splice(removalIndex, 1);
|
|
11738
|
-
this.setItem(StaticCacheKeys.ACCOUNT_KEYS, JSON.stringify(accountKeys));
|
|
11824
|
+
this.browserStorage.setItem(StaticCacheKeys.ACCOUNT_KEYS, JSON.stringify(accountKeys));
|
|
11739
11825
|
this.logger.trace("BrowserCacheManager.removeAccountKeyFromMap account key removed");
|
|
11740
11826
|
}
|
|
11741
11827
|
else {
|
|
@@ -11750,14 +11836,6 @@ class BrowserCacheManager extends CacheManager {
|
|
|
11750
11836
|
void super.removeAccount(key);
|
|
11751
11837
|
this.removeAccountKeyFromMap(key);
|
|
11752
11838
|
}
|
|
11753
|
-
/**
|
|
11754
|
-
* Remove account entity from the platform cache if it's outdated
|
|
11755
|
-
* @param accountKey
|
|
11756
|
-
*/
|
|
11757
|
-
removeOutdatedAccount(accountKey) {
|
|
11758
|
-
this.removeItem(accountKey);
|
|
11759
|
-
this.removeAccountKeyFromMap(accountKey);
|
|
11760
|
-
}
|
|
11761
11839
|
/**
|
|
11762
11840
|
* Removes given idToken from the cache and from the key map
|
|
11763
11841
|
* @param key
|
|
@@ -11787,28 +11865,7 @@ class BrowserCacheManager extends CacheManager {
|
|
|
11787
11865
|
* @returns
|
|
11788
11866
|
*/
|
|
11789
11867
|
getTokenKeys() {
|
|
11790
|
-
this.
|
|
11791
|
-
const item = this.getItem(`${StaticCacheKeys.TOKEN_KEYS}.${this.clientId}`);
|
|
11792
|
-
if (item) {
|
|
11793
|
-
const tokenKeys = this.validateAndParseJson(item);
|
|
11794
|
-
if (tokenKeys &&
|
|
11795
|
-
tokenKeys.hasOwnProperty("idToken") &&
|
|
11796
|
-
tokenKeys.hasOwnProperty("accessToken") &&
|
|
11797
|
-
tokenKeys.hasOwnProperty("refreshToken")) {
|
|
11798
|
-
return tokenKeys;
|
|
11799
|
-
}
|
|
11800
|
-
else {
|
|
11801
|
-
this.logger.error("BrowserCacheManager.getTokenKeys - Token keys found but in an unknown format. Returning empty key map.");
|
|
11802
|
-
}
|
|
11803
|
-
}
|
|
11804
|
-
else {
|
|
11805
|
-
this.logger.verbose("BrowserCacheManager.getTokenKeys - No token keys found");
|
|
11806
|
-
}
|
|
11807
|
-
return {
|
|
11808
|
-
idToken: [],
|
|
11809
|
-
accessToken: [],
|
|
11810
|
-
refreshToken: [],
|
|
11811
|
-
};
|
|
11868
|
+
return getTokenKeys(this.clientId, this.browserStorage);
|
|
11812
11869
|
}
|
|
11813
11870
|
/**
|
|
11814
11871
|
* Adds the given key to the token key map
|
|
@@ -11841,7 +11898,7 @@ class BrowserCacheManager extends CacheManager {
|
|
|
11841
11898
|
this.logger.error(`BrowserCacheManager:addTokenKey - CredentialType provided invalid. CredentialType: ${type}`);
|
|
11842
11899
|
throw createClientAuthError(unexpectedCredentialType);
|
|
11843
11900
|
}
|
|
11844
|
-
this.setItem(`${StaticCacheKeys.TOKEN_KEYS}.${this.clientId}`, JSON.stringify(tokenKeys));
|
|
11901
|
+
this.browserStorage.setItem(`${StaticCacheKeys.TOKEN_KEYS}.${this.clientId}`, JSON.stringify(tokenKeys));
|
|
11845
11902
|
}
|
|
11846
11903
|
/**
|
|
11847
11904
|
* Removes the given key from the token key map
|
|
@@ -11889,14 +11946,14 @@ class BrowserCacheManager extends CacheManager {
|
|
|
11889
11946
|
this.logger.error(`BrowserCacheManager:removeTokenKey - CredentialType provided invalid. CredentialType: ${type}`);
|
|
11890
11947
|
throw createClientAuthError(unexpectedCredentialType);
|
|
11891
11948
|
}
|
|
11892
|
-
this.setItem(`${StaticCacheKeys.TOKEN_KEYS}.${this.clientId}`, JSON.stringify(tokenKeys));
|
|
11949
|
+
this.browserStorage.setItem(`${StaticCacheKeys.TOKEN_KEYS}.${this.clientId}`, JSON.stringify(tokenKeys));
|
|
11893
11950
|
}
|
|
11894
11951
|
/**
|
|
11895
11952
|
* generates idToken entity from a string
|
|
11896
11953
|
* @param idTokenKey
|
|
11897
11954
|
*/
|
|
11898
11955
|
getIdTokenCredential(idTokenKey) {
|
|
11899
|
-
const value = this.
|
|
11956
|
+
const value = this.browserStorage.getUserData(idTokenKey);
|
|
11900
11957
|
if (!value) {
|
|
11901
11958
|
this.logger.trace("BrowserCacheManager.getIdTokenCredential: called, no cache hit");
|
|
11902
11959
|
this.removeTokenKey(idTokenKey, CredentialType.ID_TOKEN);
|
|
@@ -11915,10 +11972,10 @@ class BrowserCacheManager extends CacheManager {
|
|
|
11915
11972
|
* set IdToken credential to the platform cache
|
|
11916
11973
|
* @param idToken
|
|
11917
11974
|
*/
|
|
11918
|
-
setIdTokenCredential(idToken) {
|
|
11975
|
+
async setIdTokenCredential(idToken) {
|
|
11919
11976
|
this.logger.trace("BrowserCacheManager.setIdTokenCredential called");
|
|
11920
11977
|
const idTokenKey = generateCredentialKey(idToken);
|
|
11921
|
-
this.
|
|
11978
|
+
await this.browserStorage.setUserData(idTokenKey, JSON.stringify(idToken));
|
|
11922
11979
|
this.addTokenKey(idTokenKey, CredentialType.ID_TOKEN);
|
|
11923
11980
|
}
|
|
11924
11981
|
/**
|
|
@@ -11926,7 +11983,7 @@ class BrowserCacheManager extends CacheManager {
|
|
|
11926
11983
|
* @param key
|
|
11927
11984
|
*/
|
|
11928
11985
|
getAccessTokenCredential(accessTokenKey) {
|
|
11929
|
-
const value = this.
|
|
11986
|
+
const value = this.browserStorage.getUserData(accessTokenKey);
|
|
11930
11987
|
if (!value) {
|
|
11931
11988
|
this.logger.trace("BrowserCacheManager.getAccessTokenCredential: called, no cache hit");
|
|
11932
11989
|
this.removeTokenKey(accessTokenKey, CredentialType.ACCESS_TOKEN);
|
|
@@ -11946,10 +12003,10 @@ class BrowserCacheManager extends CacheManager {
|
|
|
11946
12003
|
* set accessToken credential to the platform cache
|
|
11947
12004
|
* @param accessToken
|
|
11948
12005
|
*/
|
|
11949
|
-
setAccessTokenCredential(accessToken) {
|
|
12006
|
+
async setAccessTokenCredential(accessToken) {
|
|
11950
12007
|
this.logger.trace("BrowserCacheManager.setAccessTokenCredential called");
|
|
11951
12008
|
const accessTokenKey = generateCredentialKey(accessToken);
|
|
11952
|
-
this.
|
|
12009
|
+
await this.browserStorage.setUserData(accessTokenKey, JSON.stringify(accessToken));
|
|
11953
12010
|
this.addTokenKey(accessTokenKey, CredentialType.ACCESS_TOKEN);
|
|
11954
12011
|
}
|
|
11955
12012
|
/**
|
|
@@ -11957,7 +12014,7 @@ class BrowserCacheManager extends CacheManager {
|
|
|
11957
12014
|
* @param refreshTokenKey
|
|
11958
12015
|
*/
|
|
11959
12016
|
getRefreshTokenCredential(refreshTokenKey) {
|
|
11960
|
-
const value = this.
|
|
12017
|
+
const value = this.browserStorage.getUserData(refreshTokenKey);
|
|
11961
12018
|
if (!value) {
|
|
11962
12019
|
this.logger.trace("BrowserCacheManager.getRefreshTokenCredential: called, no cache hit");
|
|
11963
12020
|
this.removeTokenKey(refreshTokenKey, CredentialType.REFRESH_TOKEN);
|
|
@@ -11977,10 +12034,10 @@ class BrowserCacheManager extends CacheManager {
|
|
|
11977
12034
|
* set refreshToken credential to the platform cache
|
|
11978
12035
|
* @param refreshToken
|
|
11979
12036
|
*/
|
|
11980
|
-
setRefreshTokenCredential(refreshToken) {
|
|
12037
|
+
async setRefreshTokenCredential(refreshToken) {
|
|
11981
12038
|
this.logger.trace("BrowserCacheManager.setRefreshTokenCredential called");
|
|
11982
12039
|
const refreshTokenKey = generateCredentialKey(refreshToken);
|
|
11983
|
-
this.
|
|
12040
|
+
await this.browserStorage.setUserData(refreshTokenKey, JSON.stringify(refreshToken));
|
|
11984
12041
|
this.addTokenKey(refreshTokenKey, CredentialType.REFRESH_TOKEN);
|
|
11985
12042
|
}
|
|
11986
12043
|
/**
|
|
@@ -11988,7 +12045,7 @@ class BrowserCacheManager extends CacheManager {
|
|
|
11988
12045
|
* @param appMetadataKey
|
|
11989
12046
|
*/
|
|
11990
12047
|
getAppMetadata(appMetadataKey) {
|
|
11991
|
-
const value = this.getItem(appMetadataKey);
|
|
12048
|
+
const value = this.browserStorage.getItem(appMetadataKey);
|
|
11992
12049
|
if (!value) {
|
|
11993
12050
|
this.logger.trace("BrowserCacheManager.getAppMetadata: called, no cache hit");
|
|
11994
12051
|
return null;
|
|
@@ -12009,14 +12066,14 @@ class BrowserCacheManager extends CacheManager {
|
|
|
12009
12066
|
setAppMetadata(appMetadata) {
|
|
12010
12067
|
this.logger.trace("BrowserCacheManager.setAppMetadata called");
|
|
12011
12068
|
const appMetadataKey = generateAppMetadataKey(appMetadata);
|
|
12012
|
-
this.setItem(appMetadataKey, JSON.stringify(appMetadata));
|
|
12069
|
+
this.browserStorage.setItem(appMetadataKey, JSON.stringify(appMetadata));
|
|
12013
12070
|
}
|
|
12014
12071
|
/**
|
|
12015
12072
|
* fetch server telemetry entity from the platform cache
|
|
12016
12073
|
* @param serverTelemetryKey
|
|
12017
12074
|
*/
|
|
12018
12075
|
getServerTelemetry(serverTelemetryKey) {
|
|
12019
|
-
const value = this.getItem(serverTelemetryKey);
|
|
12076
|
+
const value = this.browserStorage.getItem(serverTelemetryKey);
|
|
12020
12077
|
if (!value) {
|
|
12021
12078
|
this.logger.trace("BrowserCacheManager.getServerTelemetry: called, no cache hit");
|
|
12022
12079
|
return null;
|
|
@@ -12037,7 +12094,7 @@ class BrowserCacheManager extends CacheManager {
|
|
|
12037
12094
|
*/
|
|
12038
12095
|
setServerTelemetry(serverTelemetryKey, serverTelemetry) {
|
|
12039
12096
|
this.logger.trace("BrowserCacheManager.setServerTelemetry called");
|
|
12040
|
-
this.setItem(serverTelemetryKey, JSON.stringify(serverTelemetry));
|
|
12097
|
+
this.browserStorage.setItem(serverTelemetryKey, JSON.stringify(serverTelemetry));
|
|
12041
12098
|
}
|
|
12042
12099
|
/**
|
|
12043
12100
|
*
|
|
@@ -12097,25 +12154,9 @@ class BrowserCacheManager extends CacheManager {
|
|
|
12097
12154
|
*/
|
|
12098
12155
|
getActiveAccount() {
|
|
12099
12156
|
const activeAccountKeyFilters = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT_FILTERS);
|
|
12100
|
-
const activeAccountValueFilters = this.getItem(activeAccountKeyFilters);
|
|
12157
|
+
const activeAccountValueFilters = this.browserStorage.getItem(activeAccountKeyFilters);
|
|
12101
12158
|
if (!activeAccountValueFilters) {
|
|
12102
|
-
|
|
12103
|
-
this.logger.trace("BrowserCacheManager.getActiveAccount: No active account filters cache schema found, looking for legacy schema");
|
|
12104
|
-
const activeAccountKeyLocal = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT);
|
|
12105
|
-
const activeAccountValueLocal = this.getItem(activeAccountKeyLocal);
|
|
12106
|
-
if (!activeAccountValueLocal) {
|
|
12107
|
-
this.logger.trace("BrowserCacheManager.getActiveAccount: No active account found");
|
|
12108
|
-
return null;
|
|
12109
|
-
}
|
|
12110
|
-
const activeAccount = this.getAccountInfoFilteredBy({
|
|
12111
|
-
localAccountId: activeAccountValueLocal,
|
|
12112
|
-
});
|
|
12113
|
-
if (activeAccount) {
|
|
12114
|
-
this.logger.trace("BrowserCacheManager.getActiveAccount: Legacy active account cache schema found");
|
|
12115
|
-
this.logger.trace("BrowserCacheManager.getActiveAccount: Adding active account filters cache schema");
|
|
12116
|
-
this.setActiveAccount(activeAccount);
|
|
12117
|
-
return activeAccount;
|
|
12118
|
-
}
|
|
12159
|
+
this.logger.trace("BrowserCacheManager.getActiveAccount: No active account filters found");
|
|
12119
12160
|
return null;
|
|
12120
12161
|
}
|
|
12121
12162
|
const activeAccountValueObj = this.validateAndParseJson(activeAccountValueFilters);
|
|
@@ -12136,7 +12177,6 @@ class BrowserCacheManager extends CacheManager {
|
|
|
12136
12177
|
*/
|
|
12137
12178
|
setActiveAccount(account) {
|
|
12138
12179
|
const activeAccountKey = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT_FILTERS);
|
|
12139
|
-
const activeAccountKeyLocal = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT);
|
|
12140
12180
|
if (account) {
|
|
12141
12181
|
this.logger.verbose("setActiveAccount: Active account set");
|
|
12142
12182
|
const activeAccountValue = {
|
|
@@ -12145,12 +12185,10 @@ class BrowserCacheManager extends CacheManager {
|
|
|
12145
12185
|
tenantId: account.tenantId,
|
|
12146
12186
|
};
|
|
12147
12187
|
this.browserStorage.setItem(activeAccountKey, JSON.stringify(activeAccountValue));
|
|
12148
|
-
this.browserStorage.setItem(activeAccountKeyLocal, account.localAccountId);
|
|
12149
12188
|
}
|
|
12150
12189
|
else {
|
|
12151
12190
|
this.logger.verbose("setActiveAccount: No account passed, active account not set");
|
|
12152
12191
|
this.browserStorage.removeItem(activeAccountKey);
|
|
12153
|
-
this.browserStorage.removeItem(activeAccountKeyLocal);
|
|
12154
12192
|
}
|
|
12155
12193
|
}
|
|
12156
12194
|
/**
|
|
@@ -12158,7 +12196,7 @@ class BrowserCacheManager extends CacheManager {
|
|
|
12158
12196
|
* @param throttlingCacheKey
|
|
12159
12197
|
*/
|
|
12160
12198
|
getThrottlingCache(throttlingCacheKey) {
|
|
12161
|
-
const value = this.getItem(throttlingCacheKey);
|
|
12199
|
+
const value = this.browserStorage.getItem(throttlingCacheKey);
|
|
12162
12200
|
if (!value) {
|
|
12163
12201
|
this.logger.trace("BrowserCacheManager.getThrottlingCache: called, no cache hit");
|
|
12164
12202
|
return null;
|
|
@@ -12179,7 +12217,7 @@ class BrowserCacheManager extends CacheManager {
|
|
|
12179
12217
|
*/
|
|
12180
12218
|
setThrottlingCache(throttlingCacheKey, throttlingCache) {
|
|
12181
12219
|
this.logger.trace("BrowserCacheManager.setThrottlingCache called");
|
|
12182
|
-
this.setItem(throttlingCacheKey, JSON.stringify(throttlingCache));
|
|
12220
|
+
this.browserStorage.setItem(throttlingCacheKey, JSON.stringify(throttlingCache));
|
|
12183
12221
|
}
|
|
12184
12222
|
/**
|
|
12185
12223
|
* Gets cache item with given key.
|
|
@@ -12307,8 +12345,7 @@ class BrowserCacheManager extends CacheManager {
|
|
|
12307
12345
|
generateCacheKey(key) {
|
|
12308
12346
|
const generatedKey = this.validateAndParseJson(key);
|
|
12309
12347
|
if (!generatedKey) {
|
|
12310
|
-
if (StringUtils.startsWith(key, Constants.CACHE_PREFIX)
|
|
12311
|
-
StringUtils.startsWith(key, PersistentCacheKeys.ADAL_ID_TOKEN)) {
|
|
12348
|
+
if (StringUtils.startsWith(key, Constants.CACHE_PREFIX)) {
|
|
12312
12349
|
return key;
|
|
12313
12350
|
}
|
|
12314
12351
|
return `${Constants.CACHE_PREFIX}.${this.clientId}.${key}`;
|
|
@@ -12534,59 +12571,6 @@ class BrowserCacheManager extends CacheManager {
|
|
|
12534
12571
|
this.removeTemporaryItem(key);
|
|
12535
12572
|
}
|
|
12536
12573
|
}
|
|
12537
|
-
/**
|
|
12538
|
-
* Returns username retrieved from ADAL or MSAL v1 idToken
|
|
12539
|
-
* @deprecated
|
|
12540
|
-
*/
|
|
12541
|
-
getLegacyLoginHint() {
|
|
12542
|
-
// Only check for adal/msal token if no SSO params are being used
|
|
12543
|
-
const adalIdTokenString = this.getTemporaryCache(PersistentCacheKeys.ADAL_ID_TOKEN);
|
|
12544
|
-
if (adalIdTokenString) {
|
|
12545
|
-
this.browserStorage.removeItem(PersistentCacheKeys.ADAL_ID_TOKEN);
|
|
12546
|
-
this.logger.verbose("Cached ADAL id token retrieved.");
|
|
12547
|
-
}
|
|
12548
|
-
// Check for cached MSAL v1 id token
|
|
12549
|
-
const msalIdTokenString = this.getTemporaryCache(PersistentCacheKeys.ID_TOKEN, true);
|
|
12550
|
-
if (msalIdTokenString) {
|
|
12551
|
-
this.browserStorage.removeItem(this.generateCacheKey(PersistentCacheKeys.ID_TOKEN));
|
|
12552
|
-
this.logger.verbose("Cached MSAL.js v1 id token retrieved");
|
|
12553
|
-
}
|
|
12554
|
-
const cachedIdTokenString = msalIdTokenString || adalIdTokenString;
|
|
12555
|
-
if (cachedIdTokenString) {
|
|
12556
|
-
const idTokenClaims = extractTokenClaims(cachedIdTokenString, base64Decode);
|
|
12557
|
-
if (idTokenClaims.preferred_username) {
|
|
12558
|
-
this.logger.verbose("No SSO params used and ADAL/MSAL v1 token retrieved, setting ADAL/MSAL v1 preferred_username as loginHint");
|
|
12559
|
-
return idTokenClaims.preferred_username;
|
|
12560
|
-
}
|
|
12561
|
-
else if (idTokenClaims.upn) {
|
|
12562
|
-
this.logger.verbose("No SSO params used and ADAL/MSAL v1 token retrieved, setting ADAL/MSAL v1 upn as loginHint");
|
|
12563
|
-
return idTokenClaims.upn;
|
|
12564
|
-
}
|
|
12565
|
-
else {
|
|
12566
|
-
this.logger.verbose("No SSO params used and ADAL/MSAL v1 token retrieved, however, no account hint claim found. Enable preferred_username or upn id token claim to get SSO.");
|
|
12567
|
-
}
|
|
12568
|
-
}
|
|
12569
|
-
return null;
|
|
12570
|
-
}
|
|
12571
|
-
/**
|
|
12572
|
-
* Updates a credential's cache key if the current cache key is outdated
|
|
12573
|
-
*/
|
|
12574
|
-
updateCredentialCacheKey(currentCacheKey, credential) {
|
|
12575
|
-
const updatedCacheKey = generateCredentialKey(credential);
|
|
12576
|
-
if (currentCacheKey !== updatedCacheKey) {
|
|
12577
|
-
const cacheItem = this.getItem(currentCacheKey);
|
|
12578
|
-
if (cacheItem) {
|
|
12579
|
-
this.browserStorage.removeItem(currentCacheKey);
|
|
12580
|
-
this.setItem(updatedCacheKey, cacheItem);
|
|
12581
|
-
this.logger.verbose(`Updated an outdated ${credential.credentialType} cache key`);
|
|
12582
|
-
return updatedCacheKey;
|
|
12583
|
-
}
|
|
12584
|
-
else {
|
|
12585
|
-
this.logger.error(`Attempted to update an outdated ${credential.credentialType} cache key but no item matching the outdated key was found in storage`);
|
|
12586
|
-
}
|
|
12587
|
-
}
|
|
12588
|
-
return currentCacheKey;
|
|
12589
|
-
}
|
|
12590
12574
|
/**
|
|
12591
12575
|
* Builds credential entities from AuthenticationResult object and saves the resulting credentials to the cache
|
|
12592
12576
|
* @param result
|
|
@@ -13313,13 +13297,6 @@ class StandardInteractionClient extends BaseInteractionClient {
|
|
|
13313
13297
|
this.logger.verbosePii(`Setting validated request account: ${account.homeAccountId}`, this.correlationId);
|
|
13314
13298
|
validatedRequest.account = account;
|
|
13315
13299
|
}
|
|
13316
|
-
// Check for ADAL/MSAL v1 SSO
|
|
13317
|
-
if (!validatedRequest.loginHint && !account) {
|
|
13318
|
-
const legacyLoginHint = this.browserStorage.getLegacyLoginHint();
|
|
13319
|
-
if (legacyLoginHint) {
|
|
13320
|
-
validatedRequest.loginHint = legacyLoginHint;
|
|
13321
|
-
}
|
|
13322
|
-
}
|
|
13323
13300
|
return validatedRequest;
|
|
13324
13301
|
}
|
|
13325
13302
|
}
|
|
@@ -13723,7 +13700,7 @@ class NativeInteractionClient extends BaseInteractionClient {
|
|
|
13723
13700
|
// generate authenticationResult
|
|
13724
13701
|
const result = await this.generateAuthenticationResult(response, request, idTokenClaims, baseAccount, authority.canonicalAuthority, reqTimestamp);
|
|
13725
13702
|
// cache accounts and tokens in the appropriate storage
|
|
13726
|
-
this.cacheAccount(baseAccount);
|
|
13703
|
+
await this.cacheAccount(baseAccount);
|
|
13727
13704
|
this.cacheNativeTokens(response, request, homeAccountIdentifier, idTokenClaims, response.access_token, result.tenantId, reqTimestamp);
|
|
13728
13705
|
return result;
|
|
13729
13706
|
}
|
|
@@ -13848,9 +13825,9 @@ class NativeInteractionClient extends BaseInteractionClient {
|
|
|
13848
13825
|
* cache the account entity in browser storage
|
|
13849
13826
|
* @param accountEntity
|
|
13850
13827
|
*/
|
|
13851
|
-
cacheAccount(accountEntity) {
|
|
13828
|
+
async cacheAccount(accountEntity) {
|
|
13852
13829
|
// Store the account info and hence `nativeAccountId` in browser cache
|
|
13853
|
-
this.browserStorage.setAccount(accountEntity);
|
|
13830
|
+
await this.browserStorage.setAccount(accountEntity);
|
|
13854
13831
|
// Remove any existing cached tokens for this account in browser storage
|
|
13855
13832
|
this.browserStorage.removeAccountContext(accountEntity).catch((e) => {
|
|
13856
13833
|
this.logger.error(`Error occurred while removing account context from browser storage. ${e}`);
|
|
@@ -15728,7 +15705,7 @@ class TokenCache {
|
|
|
15728
15705
|
* @param options
|
|
15729
15706
|
* @returns `AuthenticationResult` for the response that was loaded.
|
|
15730
15707
|
*/
|
|
15731
|
-
loadExternalTokens(request, response, options) {
|
|
15708
|
+
async loadExternalTokens(request, response, options) {
|
|
15732
15709
|
if (!this.isBrowserEnvironment) {
|
|
15733
15710
|
throw createBrowserAuthError(nonBrowserEnvironment);
|
|
15734
15711
|
}
|
|
@@ -15745,10 +15722,10 @@ class TokenCache {
|
|
|
15745
15722
|
const authority = request.authority
|
|
15746
15723
|
? new Authority(Authority.generateAuthority(request.authority, request.azureCloudOptions), this.config.system.networkClient, this.storage, authorityOptions, this.logger, request.correlationId || createNewGuid())
|
|
15747
15724
|
: undefined;
|
|
15748
|
-
const cacheRecordAccount = this.loadAccount(request, options.clientInfo || response.client_info || "", idTokenClaims, authority);
|
|
15749
|
-
const idToken = this.loadIdToken(response, cacheRecordAccount.homeAccountId, cacheRecordAccount.environment, cacheRecordAccount.realm);
|
|
15750
|
-
const accessToken = this.loadAccessToken(request, response, cacheRecordAccount.homeAccountId, cacheRecordAccount.environment, cacheRecordAccount.realm, options);
|
|
15751
|
-
const refreshToken = this.loadRefreshToken(response, cacheRecordAccount.homeAccountId, cacheRecordAccount.environment);
|
|
15725
|
+
const cacheRecordAccount = await this.loadAccount(request, options.clientInfo || response.client_info || "", idTokenClaims, authority);
|
|
15726
|
+
const idToken = await this.loadIdToken(response, cacheRecordAccount.homeAccountId, cacheRecordAccount.environment, cacheRecordAccount.realm);
|
|
15727
|
+
const accessToken = await this.loadAccessToken(request, response, cacheRecordAccount.homeAccountId, cacheRecordAccount.environment, cacheRecordAccount.realm, options);
|
|
15728
|
+
const refreshToken = await this.loadRefreshToken(response, cacheRecordAccount.homeAccountId, cacheRecordAccount.environment);
|
|
15752
15729
|
return this.generateAuthenticationResult(request, {
|
|
15753
15730
|
account: cacheRecordAccount,
|
|
15754
15731
|
idToken,
|
|
@@ -15765,11 +15742,11 @@ class TokenCache {
|
|
|
15765
15742
|
* @param requestHomeAccountId
|
|
15766
15743
|
* @returns `AccountEntity`
|
|
15767
15744
|
*/
|
|
15768
|
-
loadAccount(request, clientInfo, idTokenClaims, authority) {
|
|
15745
|
+
async loadAccount(request, clientInfo, idTokenClaims, authority) {
|
|
15769
15746
|
this.logger.verbose("TokenCache - loading account");
|
|
15770
15747
|
if (request.account) {
|
|
15771
15748
|
const accountEntity = AccountEntity.createFromAccountInfo(request.account);
|
|
15772
|
-
this.storage.setAccount(accountEntity);
|
|
15749
|
+
await this.storage.setAccount(accountEntity);
|
|
15773
15750
|
return accountEntity;
|
|
15774
15751
|
}
|
|
15775
15752
|
else if (!authority || (!clientInfo && !idTokenClaims)) {
|
|
@@ -15781,7 +15758,7 @@ class TokenCache {
|
|
|
15781
15758
|
const cachedAccount = buildAccountToCache(this.storage, authority, homeAccountId, base64Decode, idTokenClaims, clientInfo, authority.hostnameAndPort, claimsTenantId, undefined, // authCodePayload
|
|
15782
15759
|
undefined, // nativeAccountId
|
|
15783
15760
|
this.logger);
|
|
15784
|
-
this.storage.setAccount(cachedAccount);
|
|
15761
|
+
await this.storage.setAccount(cachedAccount);
|
|
15785
15762
|
return cachedAccount;
|
|
15786
15763
|
}
|
|
15787
15764
|
/**
|
|
@@ -15792,14 +15769,14 @@ class TokenCache {
|
|
|
15792
15769
|
* @param tenantId
|
|
15793
15770
|
* @returns `IdTokenEntity`
|
|
15794
15771
|
*/
|
|
15795
|
-
loadIdToken(response, homeAccountId, environment, tenantId) {
|
|
15772
|
+
async loadIdToken(response, homeAccountId, environment, tenantId) {
|
|
15796
15773
|
if (!response.id_token) {
|
|
15797
15774
|
this.logger.verbose("TokenCache - no id token found in response");
|
|
15798
15775
|
return null;
|
|
15799
15776
|
}
|
|
15800
15777
|
this.logger.verbose("TokenCache - loading id token");
|
|
15801
15778
|
const idTokenEntity = createIdTokenEntity(homeAccountId, environment, response.id_token, this.config.auth.clientId, tenantId);
|
|
15802
|
-
this.storage.setIdTokenCredential(idTokenEntity);
|
|
15779
|
+
await this.storage.setIdTokenCredential(idTokenEntity);
|
|
15803
15780
|
return idTokenEntity;
|
|
15804
15781
|
}
|
|
15805
15782
|
/**
|
|
@@ -15811,7 +15788,7 @@ class TokenCache {
|
|
|
15811
15788
|
* @param tenantId
|
|
15812
15789
|
* @returns `AccessTokenEntity`
|
|
15813
15790
|
*/
|
|
15814
|
-
loadAccessToken(request, response, homeAccountId, environment, tenantId, options) {
|
|
15791
|
+
async loadAccessToken(request, response, homeAccountId, environment, tenantId, options) {
|
|
15815
15792
|
if (!response.access_token) {
|
|
15816
15793
|
this.logger.verbose("TokenCache - no access token found in response");
|
|
15817
15794
|
return null;
|
|
@@ -15835,7 +15812,7 @@ class TokenCache {
|
|
|
15835
15812
|
(response.ext_expires_in || response.expires_in) +
|
|
15836
15813
|
new Date().getTime() / 1000;
|
|
15837
15814
|
const accessTokenEntity = createAccessTokenEntity(homeAccountId, environment, response.access_token, this.config.auth.clientId, tenantId, scopes.printScopes(), expiresOn, extendedExpiresOn, base64Decode);
|
|
15838
|
-
this.storage.setAccessTokenCredential(accessTokenEntity);
|
|
15815
|
+
await this.storage.setAccessTokenCredential(accessTokenEntity);
|
|
15839
15816
|
return accessTokenEntity;
|
|
15840
15817
|
}
|
|
15841
15818
|
/**
|
|
@@ -15846,7 +15823,7 @@ class TokenCache {
|
|
|
15846
15823
|
* @param environment
|
|
15847
15824
|
* @returns `RefreshTokenEntity`
|
|
15848
15825
|
*/
|
|
15849
|
-
loadRefreshToken(response, homeAccountId, environment) {
|
|
15826
|
+
async loadRefreshToken(response, homeAccountId, environment) {
|
|
15850
15827
|
if (!response.refresh_token) {
|
|
15851
15828
|
this.logger.verbose("TokenCache - no refresh token found in response");
|
|
15852
15829
|
return null;
|
|
@@ -15854,7 +15831,7 @@ class TokenCache {
|
|
|
15854
15831
|
this.logger.verbose("TokenCache - loading refresh token");
|
|
15855
15832
|
const refreshTokenEntity = createRefreshTokenEntity(homeAccountId, environment, response.refresh_token, this.config.auth.clientId, response.foci, undefined, // userAssertionHash
|
|
15856
15833
|
response.refresh_token_expires_in);
|
|
15857
|
-
this.storage.setRefreshTokenCredential(refreshTokenEntity);
|
|
15834
|
+
await this.storage.setRefreshTokenCredential(refreshTokenEntity);
|
|
15858
15835
|
return refreshTokenEntity;
|
|
15859
15836
|
}
|
|
15860
15837
|
/**
|
|
@@ -16103,6 +16080,7 @@ class StandardController {
|
|
|
16103
16080
|
this.eventHandler.emitEvent(EventType.INITIALIZE_END);
|
|
16104
16081
|
return;
|
|
16105
16082
|
}
|
|
16083
|
+
await this.browserStorage.initialize();
|
|
16106
16084
|
const initCorrelationId = request?.correlationId || this.getRequestCorrelationId();
|
|
16107
16085
|
const allowNativeBroker = this.config.system.allowNativeBroker;
|
|
16108
16086
|
const initMeasurement = this.performanceClient.startMeasurement(PerformanceEvents.InitializeClientApplication, initCorrelationId);
|
|
@@ -16828,7 +16806,7 @@ class StandardController {
|
|
|
16828
16806
|
this.logger.verbose("hydrateCache called");
|
|
16829
16807
|
// Account gets saved to browser storage regardless of native or not
|
|
16830
16808
|
const accountEntity = AccountEntity.createFromAccountInfo(result.account, result.cloudGraphHostName, result.msGraphHost);
|
|
16831
|
-
this.browserStorage.setAccount(accountEntity);
|
|
16809
|
+
await this.browserStorage.setAccount(accountEntity);
|
|
16832
16810
|
if (result.fromNativeBroker) {
|
|
16833
16811
|
this.logger.verbose("Response was from native broker, storing in-memory");
|
|
16834
16812
|
// Tokens from native broker are stored in-memory
|
|
@@ -17629,8 +17607,8 @@ class NestedAppAuthController {
|
|
|
17629
17607
|
* Specific implementation of initialize function for NestedAppAuthController
|
|
17630
17608
|
* @returns
|
|
17631
17609
|
*/
|
|
17632
|
-
initialize() {
|
|
17633
|
-
|
|
17610
|
+
async initialize() {
|
|
17611
|
+
await this.browserStorage.initialize();
|
|
17634
17612
|
return Promise.resolve();
|
|
17635
17613
|
}
|
|
17636
17614
|
/**
|
|
@@ -18056,7 +18034,7 @@ class NestedAppAuthController {
|
|
|
18056
18034
|
async hydrateCache(result, request) {
|
|
18057
18035
|
this.logger.verbose("hydrateCache called");
|
|
18058
18036
|
const accountEntity = AccountEntity.createFromAccountInfo(result.account, result.cloudGraphHostName, result.msGraphHost);
|
|
18059
|
-
this.browserStorage.setAccount(accountEntity);
|
|
18037
|
+
await this.browserStorage.setAccount(accountEntity);
|
|
18060
18038
|
return this.browserStorage.hydrateCache(result, request);
|
|
18061
18039
|
}
|
|
18062
18040
|
}
|
|
@@ -19214,42 +19192,6 @@ const stubbedPublicClientApplication = {
|
|
|
19214
19192
|
},
|
|
19215
19193
|
};
|
|
19216
19194
|
|
|
19217
|
-
/*
|
|
19218
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
19219
|
-
* Licensed under the MIT License.
|
|
19220
|
-
*/
|
|
19221
|
-
/**
|
|
19222
|
-
* @deprecated This class will be removed in a future major version
|
|
19223
|
-
*/
|
|
19224
|
-
class BrowserStorage {
|
|
19225
|
-
constructor(cacheLocation) {
|
|
19226
|
-
if (cacheLocation === BrowserCacheLocation.LocalStorage) {
|
|
19227
|
-
this.windowStorage = new LocalStorage();
|
|
19228
|
-
}
|
|
19229
|
-
else if (cacheLocation === BrowserCacheLocation.SessionStorage) {
|
|
19230
|
-
this.windowStorage = new SessionStorage();
|
|
19231
|
-
}
|
|
19232
|
-
else {
|
|
19233
|
-
throw createBrowserConfigurationAuthError(storageNotSupported);
|
|
19234
|
-
}
|
|
19235
|
-
}
|
|
19236
|
-
getItem(key) {
|
|
19237
|
-
return this.windowStorage.getItem(key);
|
|
19238
|
-
}
|
|
19239
|
-
setItem(key, value) {
|
|
19240
|
-
this.windowStorage.setItem(key, value);
|
|
19241
|
-
}
|
|
19242
|
-
removeItem(key) {
|
|
19243
|
-
this.windowStorage.removeItem(key);
|
|
19244
|
-
}
|
|
19245
|
-
getKeys() {
|
|
19246
|
-
return Object.keys(this.windowStorage);
|
|
19247
|
-
}
|
|
19248
|
-
containsKey(key) {
|
|
19249
|
-
return this.windowStorage.hasOwnProperty(key);
|
|
19250
|
-
}
|
|
19251
|
-
}
|
|
19252
|
-
|
|
19253
19195
|
/*
|
|
19254
19196
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
19255
19197
|
* Licensed under the MIT License.
|
|
@@ -19637,7 +19579,6 @@ exports.BrowserConfigurationAuthErrorCodes = BrowserConfigurationAuthErrorCodes;
|
|
|
19637
19579
|
exports.BrowserConfigurationAuthErrorMessage = BrowserConfigurationAuthErrorMessage;
|
|
19638
19580
|
exports.BrowserPerformanceClient = BrowserPerformanceClient;
|
|
19639
19581
|
exports.BrowserPerformanceMeasurement = BrowserPerformanceMeasurement;
|
|
19640
|
-
exports.BrowserStorage = BrowserStorage;
|
|
19641
19582
|
exports.BrowserUtils = BrowserUtils;
|
|
19642
19583
|
exports.CacheLookupPolicy = CacheLookupPolicy;
|
|
19643
19584
|
exports.ClientAuthError = ClientAuthError;
|