@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.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @azure/msal-browser
|
|
1
|
+
/*! @azure/msal-browser v4.0.0-alpha.0 2024-12-18 */
|
|
2
2
|
'use strict';
|
|
3
3
|
(function (global, factory) {
|
|
4
4
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.msal = {}));
|
|
7
7
|
})(this, (function (exports) { 'use strict';
|
|
8
8
|
|
|
9
|
-
/*! @azure/msal-common
|
|
9
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
10
10
|
/*
|
|
11
11
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
12
12
|
* Licensed under the MIT License.
|
|
@@ -113,12 +113,6 @@
|
|
|
113
113
|
* Persistent cache keys MSAL which stay while user is logged in.
|
|
114
114
|
*/
|
|
115
115
|
const PersistentCacheKeys = {
|
|
116
|
-
ID_TOKEN: "idtoken",
|
|
117
|
-
CLIENT_INFO: "client.info",
|
|
118
|
-
ADAL_ID_TOKEN: "adal.idtoken",
|
|
119
|
-
ERROR: "error",
|
|
120
|
-
ERROR_DESC: "error.description",
|
|
121
|
-
ACTIVE_ACCOUNT: "active-account",
|
|
122
116
|
ACTIVE_ACCOUNT_FILTERS: "active-account-filters", // new cache entry for active_account for a more robust version for browser
|
|
123
117
|
};
|
|
124
118
|
/**
|
|
@@ -316,7 +310,7 @@
|
|
|
316
310
|
// Token renewal offset default in seconds
|
|
317
311
|
const DEFAULT_TOKEN_RENEWAL_OFFSET_SEC = 300;
|
|
318
312
|
|
|
319
|
-
/*! @azure/msal-common
|
|
313
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
320
314
|
/*
|
|
321
315
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
322
316
|
* Licensed under the MIT License.
|
|
@@ -333,7 +327,7 @@
|
|
|
333
327
|
unexpectedError: unexpectedError
|
|
334
328
|
});
|
|
335
329
|
|
|
336
|
-
/*! @azure/msal-common
|
|
330
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
337
331
|
|
|
338
332
|
/*
|
|
339
333
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -382,7 +376,7 @@
|
|
|
382
376
|
: AuthErrorMessages[code]);
|
|
383
377
|
}
|
|
384
378
|
|
|
385
|
-
/*! @azure/msal-common
|
|
379
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
386
380
|
/*
|
|
387
381
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
388
382
|
* Licensed under the MIT License.
|
|
@@ -480,7 +474,7 @@
|
|
|
480
474
|
userTimeoutReached: userTimeoutReached
|
|
481
475
|
});
|
|
482
476
|
|
|
483
|
-
/*! @azure/msal-common
|
|
477
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
484
478
|
|
|
485
479
|
/*
|
|
486
480
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -732,7 +726,7 @@
|
|
|
732
726
|
return new ClientAuthError(errorCode, additionalMessage);
|
|
733
727
|
}
|
|
734
728
|
|
|
735
|
-
/*! @azure/msal-common
|
|
729
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
736
730
|
|
|
737
731
|
/*
|
|
738
732
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -771,7 +765,7 @@
|
|
|
771
765
|
},
|
|
772
766
|
};
|
|
773
767
|
|
|
774
|
-
/*! @azure/msal-common
|
|
768
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
775
769
|
|
|
776
770
|
/*
|
|
777
771
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -962,12 +956,12 @@
|
|
|
962
956
|
}
|
|
963
957
|
}
|
|
964
958
|
|
|
965
|
-
/*! @azure/msal-common
|
|
959
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
966
960
|
/* eslint-disable header/header */
|
|
967
961
|
const name$1 = "@azure/msal-common";
|
|
968
|
-
const version$1 = "
|
|
962
|
+
const version$1 = "15.0.0-alpha.0";
|
|
969
963
|
|
|
970
|
-
/*! @azure/msal-common
|
|
964
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
971
965
|
/*
|
|
972
966
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
973
967
|
* Licensed under the MIT License.
|
|
@@ -987,7 +981,7 @@
|
|
|
987
981
|
AzureUsGovernment: "https://login.microsoftonline.us",
|
|
988
982
|
};
|
|
989
983
|
|
|
990
|
-
/*! @azure/msal-common
|
|
984
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
991
985
|
|
|
992
986
|
/*
|
|
993
987
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1048,7 +1042,7 @@
|
|
|
1048
1042
|
}
|
|
1049
1043
|
}
|
|
1050
1044
|
|
|
1051
|
-
/*! @azure/msal-common
|
|
1045
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
1052
1046
|
/*
|
|
1053
1047
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1054
1048
|
* Licensed under the MIT License.
|
|
@@ -1085,7 +1079,7 @@
|
|
|
1085
1079
|
return cachedAtSec > nowSeconds();
|
|
1086
1080
|
}
|
|
1087
1081
|
|
|
1088
|
-
/*! @azure/msal-common
|
|
1082
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
1089
1083
|
|
|
1090
1084
|
/*
|
|
1091
1085
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1412,7 +1406,7 @@
|
|
|
1412
1406
|
return metadata.expiresAt <= nowSeconds();
|
|
1413
1407
|
}
|
|
1414
1408
|
|
|
1415
|
-
/*! @azure/msal-common
|
|
1409
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
1416
1410
|
/*
|
|
1417
1411
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1418
1412
|
* Licensed under the MIT License.
|
|
@@ -1466,7 +1460,7 @@
|
|
|
1466
1460
|
urlParseError: urlParseError
|
|
1467
1461
|
});
|
|
1468
1462
|
|
|
1469
|
-
/*! @azure/msal-common
|
|
1463
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
1470
1464
|
|
|
1471
1465
|
/*
|
|
1472
1466
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1604,7 +1598,7 @@
|
|
|
1604
1598
|
return new ClientConfigurationError(errorCode);
|
|
1605
1599
|
}
|
|
1606
1600
|
|
|
1607
|
-
/*! @azure/msal-common
|
|
1601
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
1608
1602
|
/*
|
|
1609
1603
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1610
1604
|
* Licensed under the MIT License.
|
|
@@ -1701,7 +1695,7 @@
|
|
|
1701
1695
|
}
|
|
1702
1696
|
}
|
|
1703
1697
|
|
|
1704
|
-
/*! @azure/msal-common
|
|
1698
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
1705
1699
|
|
|
1706
1700
|
/*
|
|
1707
1701
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1901,7 +1895,7 @@
|
|
|
1901
1895
|
}
|
|
1902
1896
|
}
|
|
1903
1897
|
|
|
1904
|
-
/*! @azure/msal-common
|
|
1898
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
1905
1899
|
|
|
1906
1900
|
/*
|
|
1907
1901
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1941,7 +1935,7 @@
|
|
|
1941
1935
|
};
|
|
1942
1936
|
}
|
|
1943
1937
|
|
|
1944
|
-
/*! @azure/msal-common
|
|
1938
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
1945
1939
|
/*
|
|
1946
1940
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1947
1941
|
* Licensed under the MIT License.
|
|
@@ -2020,7 +2014,7 @@
|
|
|
2020
2014
|
return updatedAccountInfo;
|
|
2021
2015
|
}
|
|
2022
2016
|
|
|
2023
|
-
/*! @azure/msal-common
|
|
2017
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
2024
2018
|
/*
|
|
2025
2019
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2026
2020
|
* Licensed under the MIT License.
|
|
@@ -2035,7 +2029,7 @@
|
|
|
2035
2029
|
Ciam: 3,
|
|
2036
2030
|
};
|
|
2037
2031
|
|
|
2038
|
-
/*! @azure/msal-common
|
|
2032
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
2039
2033
|
/*
|
|
2040
2034
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2041
2035
|
* Licensed under the MIT License.
|
|
@@ -2057,7 +2051,7 @@
|
|
|
2057
2051
|
return null;
|
|
2058
2052
|
}
|
|
2059
2053
|
|
|
2060
|
-
/*! @azure/msal-common
|
|
2054
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
2061
2055
|
/*
|
|
2062
2056
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2063
2057
|
* Licensed under the MIT License.
|
|
@@ -2070,7 +2064,7 @@
|
|
|
2070
2064
|
OIDC: "OIDC",
|
|
2071
2065
|
};
|
|
2072
2066
|
|
|
2073
|
-
/*! @azure/msal-common
|
|
2067
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
2074
2068
|
|
|
2075
2069
|
/*
|
|
2076
2070
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2313,7 +2307,7 @@
|
|
|
2313
2307
|
}
|
|
2314
2308
|
}
|
|
2315
2309
|
|
|
2316
|
-
/*! @azure/msal-common
|
|
2310
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
2317
2311
|
|
|
2318
2312
|
/*
|
|
2319
2313
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2360,7 +2354,7 @@
|
|
|
2360
2354
|
return null;
|
|
2361
2355
|
}
|
|
2362
2356
|
|
|
2363
|
-
/*! @azure/msal-common
|
|
2357
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
2364
2358
|
|
|
2365
2359
|
/*
|
|
2366
2360
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2524,7 +2518,7 @@
|
|
|
2524
2518
|
}
|
|
2525
2519
|
}
|
|
2526
2520
|
|
|
2527
|
-
/*! @azure/msal-common
|
|
2521
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
2528
2522
|
|
|
2529
2523
|
/*
|
|
2530
2524
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2664,7 +2658,7 @@
|
|
|
2664
2658
|
return null;
|
|
2665
2659
|
}
|
|
2666
2660
|
|
|
2667
|
-
/*! @azure/msal-common
|
|
2661
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
2668
2662
|
/*
|
|
2669
2663
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2670
2664
|
* Licensed under the MIT License.
|
|
@@ -2672,7 +2666,7 @@
|
|
|
2672
2666
|
const cacheQuotaExceededErrorCode = "cache_quota_exceeded";
|
|
2673
2667
|
const cacheUnknownErrorCode = "cache_error_unknown";
|
|
2674
2668
|
|
|
2675
|
-
/*! @azure/msal-common
|
|
2669
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
2676
2670
|
|
|
2677
2671
|
/*
|
|
2678
2672
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2699,7 +2693,7 @@
|
|
|
2699
2693
|
}
|
|
2700
2694
|
}
|
|
2701
2695
|
|
|
2702
|
-
/*! @azure/msal-common
|
|
2696
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
2703
2697
|
|
|
2704
2698
|
/*
|
|
2705
2699
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2870,10 +2864,10 @@
|
|
|
2870
2864
|
}
|
|
2871
2865
|
try {
|
|
2872
2866
|
if (!!cacheRecord.account) {
|
|
2873
|
-
this.setAccount(cacheRecord.account);
|
|
2867
|
+
await this.setAccount(cacheRecord.account);
|
|
2874
2868
|
}
|
|
2875
2869
|
if (!!cacheRecord.idToken && storeInCache?.idToken !== false) {
|
|
2876
|
-
this.setIdTokenCredential(cacheRecord.idToken);
|
|
2870
|
+
await this.setIdTokenCredential(cacheRecord.idToken);
|
|
2877
2871
|
}
|
|
2878
2872
|
if (!!cacheRecord.accessToken &&
|
|
2879
2873
|
storeInCache?.accessToken !== false) {
|
|
@@ -2881,7 +2875,7 @@
|
|
|
2881
2875
|
}
|
|
2882
2876
|
if (!!cacheRecord.refreshToken &&
|
|
2883
2877
|
storeInCache?.refreshToken !== false) {
|
|
2884
|
-
this.setRefreshTokenCredential(cacheRecord.refreshToken);
|
|
2878
|
+
await this.setRefreshTokenCredential(cacheRecord.refreshToken);
|
|
2885
2879
|
}
|
|
2886
2880
|
if (!!cacheRecord.appMetadata) {
|
|
2887
2881
|
this.setAppMetadata(cacheRecord.appMetadata);
|
|
@@ -2938,7 +2932,7 @@
|
|
|
2938
2932
|
}
|
|
2939
2933
|
});
|
|
2940
2934
|
await Promise.all(removedAccessTokens);
|
|
2941
|
-
this.setAccessTokenCredential(credential);
|
|
2935
|
+
await this.setAccessTokenCredential(credential);
|
|
2942
2936
|
}
|
|
2943
2937
|
/**
|
|
2944
2938
|
* Retrieve account entities matching all provided tenant-agnostic filters; if no filter is set, get all account entities in the cache
|
|
@@ -3224,61 +3218,6 @@
|
|
|
3224
3218
|
});
|
|
3225
3219
|
await Promise.all(removedCredentials);
|
|
3226
3220
|
}
|
|
3227
|
-
/**
|
|
3228
|
-
* Migrates a single-tenant account and all it's associated alternate cross-tenant account objects in the
|
|
3229
|
-
* cache into a condensed multi-tenant account object with tenant profiles.
|
|
3230
|
-
* @param accountKey
|
|
3231
|
-
* @param accountEntity
|
|
3232
|
-
* @param logger
|
|
3233
|
-
* @returns
|
|
3234
|
-
*/
|
|
3235
|
-
updateOutdatedCachedAccount(accountKey, accountEntity, logger) {
|
|
3236
|
-
// Only update if account entity is defined and has no tenantProfiles object (is outdated)
|
|
3237
|
-
if (accountEntity && accountEntity.isSingleTenant()) {
|
|
3238
|
-
this.commonLogger?.verbose("updateOutdatedCachedAccount: Found a single-tenant (outdated) account entity in the cache, migrating to multi-tenant account entity");
|
|
3239
|
-
// Get keys of all accounts belonging to user
|
|
3240
|
-
const matchingAccountKeys = this.getAccountKeys().filter((key) => {
|
|
3241
|
-
return key.startsWith(accountEntity.homeAccountId);
|
|
3242
|
-
});
|
|
3243
|
-
// Get all account entities belonging to user
|
|
3244
|
-
const accountsToMerge = [];
|
|
3245
|
-
matchingAccountKeys.forEach((key) => {
|
|
3246
|
-
const account = this.getCachedAccountEntity(key);
|
|
3247
|
-
if (account) {
|
|
3248
|
-
accountsToMerge.push(account);
|
|
3249
|
-
}
|
|
3250
|
-
});
|
|
3251
|
-
// Set base account to home account if available, any account if not
|
|
3252
|
-
const baseAccount = accountsToMerge.find((account) => {
|
|
3253
|
-
return tenantIdMatchesHomeTenant(account.realm, account.homeAccountId);
|
|
3254
|
-
}) || accountsToMerge[0];
|
|
3255
|
-
// Populate tenant profiles built from each account entity belonging to the user
|
|
3256
|
-
baseAccount.tenantProfiles = accountsToMerge.map((account) => {
|
|
3257
|
-
return {
|
|
3258
|
-
tenantId: account.realm,
|
|
3259
|
-
localAccountId: account.localAccountId,
|
|
3260
|
-
name: account.name,
|
|
3261
|
-
isHomeTenant: tenantIdMatchesHomeTenant(account.realm, account.homeAccountId),
|
|
3262
|
-
};
|
|
3263
|
-
});
|
|
3264
|
-
const updatedAccount = CacheManager.toObject(new AccountEntity(), {
|
|
3265
|
-
...baseAccount,
|
|
3266
|
-
});
|
|
3267
|
-
const newAccountKey = updatedAccount.generateAccountKey();
|
|
3268
|
-
// Clear cache of legacy account objects that have been collpsed into tenant profiles
|
|
3269
|
-
matchingAccountKeys.forEach((key) => {
|
|
3270
|
-
if (key !== newAccountKey) {
|
|
3271
|
-
this.removeOutdatedAccount(accountKey);
|
|
3272
|
-
}
|
|
3273
|
-
});
|
|
3274
|
-
// Cache updated account object
|
|
3275
|
-
this.setAccount(updatedAccount);
|
|
3276
|
-
logger?.verbose("Updated an outdated account entity in the cache");
|
|
3277
|
-
return updatedAccount;
|
|
3278
|
-
}
|
|
3279
|
-
// No update is necessary
|
|
3280
|
-
return accountEntity;
|
|
3281
|
-
}
|
|
3282
3221
|
/**
|
|
3283
3222
|
* returns a boolean if the given credential is removed
|
|
3284
3223
|
* @param credential
|
|
@@ -3874,28 +3813,25 @@
|
|
|
3874
3813
|
}
|
|
3875
3814
|
/** @internal */
|
|
3876
3815
|
class DefaultStorageClass extends CacheManager {
|
|
3877
|
-
setAccount() {
|
|
3816
|
+
async setAccount() {
|
|
3878
3817
|
throw createClientAuthError(methodNotImplemented);
|
|
3879
3818
|
}
|
|
3880
3819
|
getAccount() {
|
|
3881
3820
|
throw createClientAuthError(methodNotImplemented);
|
|
3882
3821
|
}
|
|
3883
|
-
|
|
3884
|
-
throw createClientAuthError(methodNotImplemented);
|
|
3885
|
-
}
|
|
3886
|
-
setIdTokenCredential() {
|
|
3822
|
+
async setIdTokenCredential() {
|
|
3887
3823
|
throw createClientAuthError(methodNotImplemented);
|
|
3888
3824
|
}
|
|
3889
3825
|
getIdTokenCredential() {
|
|
3890
3826
|
throw createClientAuthError(methodNotImplemented);
|
|
3891
3827
|
}
|
|
3892
|
-
setAccessTokenCredential() {
|
|
3828
|
+
async setAccessTokenCredential() {
|
|
3893
3829
|
throw createClientAuthError(methodNotImplemented);
|
|
3894
3830
|
}
|
|
3895
3831
|
getAccessTokenCredential() {
|
|
3896
3832
|
throw createClientAuthError(methodNotImplemented);
|
|
3897
3833
|
}
|
|
3898
|
-
setRefreshTokenCredential() {
|
|
3834
|
+
async setRefreshTokenCredential() {
|
|
3899
3835
|
throw createClientAuthError(methodNotImplemented);
|
|
3900
3836
|
}
|
|
3901
3837
|
getRefreshTokenCredential() {
|
|
@@ -3940,15 +3876,9 @@
|
|
|
3940
3876
|
getTokenKeys() {
|
|
3941
3877
|
throw createClientAuthError(methodNotImplemented);
|
|
3942
3878
|
}
|
|
3943
|
-
updateCredentialCacheKey() {
|
|
3944
|
-
throw createClientAuthError(methodNotImplemented);
|
|
3945
|
-
}
|
|
3946
|
-
removeOutdatedAccount() {
|
|
3947
|
-
throw createClientAuthError(methodNotImplemented);
|
|
3948
|
-
}
|
|
3949
3879
|
}
|
|
3950
3880
|
|
|
3951
|
-
/*! @azure/msal-common
|
|
3881
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
3952
3882
|
|
|
3953
3883
|
/*
|
|
3954
3884
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4047,7 +3977,7 @@
|
|
|
4047
3977
|
return (config.authOptions.authority.options.protocolMode === ProtocolMode.OIDC);
|
|
4048
3978
|
}
|
|
4049
3979
|
|
|
4050
|
-
/*! @azure/msal-common
|
|
3980
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
4051
3981
|
/*
|
|
4052
3982
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4053
3983
|
* Licensed under the MIT License.
|
|
@@ -4057,7 +3987,7 @@
|
|
|
4057
3987
|
UPN: "UPN",
|
|
4058
3988
|
};
|
|
4059
3989
|
|
|
4060
|
-
/*! @azure/msal-common
|
|
3990
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
4061
3991
|
/*
|
|
4062
3992
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4063
3993
|
* Licensed under the MIT License.
|
|
@@ -4107,7 +4037,7 @@
|
|
|
4107
4037
|
const BROKER_CLIENT_ID = "brk_client_id";
|
|
4108
4038
|
const BROKER_REDIRECT_URI = "brk_redirect_uri";
|
|
4109
4039
|
|
|
4110
|
-
/*! @azure/msal-common
|
|
4040
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
4111
4041
|
|
|
4112
4042
|
/*
|
|
4113
4043
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4174,7 +4104,7 @@
|
|
|
4174
4104
|
}
|
|
4175
4105
|
}
|
|
4176
4106
|
|
|
4177
|
-
/*! @azure/msal-common
|
|
4107
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
4178
4108
|
|
|
4179
4109
|
/*
|
|
4180
4110
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4582,7 +4512,7 @@
|
|
|
4582
4512
|
}
|
|
4583
4513
|
}
|
|
4584
4514
|
|
|
4585
|
-
/*! @azure/msal-common
|
|
4515
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
4586
4516
|
/*
|
|
4587
4517
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4588
4518
|
* Licensed under the MIT License.
|
|
@@ -4594,7 +4524,7 @@
|
|
|
4594
4524
|
response.hasOwnProperty("jwks_uri"));
|
|
4595
4525
|
}
|
|
4596
4526
|
|
|
4597
|
-
/*! @azure/msal-common
|
|
4527
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
4598
4528
|
/*
|
|
4599
4529
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4600
4530
|
* Licensed under the MIT License.
|
|
@@ -4604,7 +4534,7 @@
|
|
|
4604
4534
|
response.hasOwnProperty("metadata"));
|
|
4605
4535
|
}
|
|
4606
4536
|
|
|
4607
|
-
/*! @azure/msal-common
|
|
4537
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
4608
4538
|
/*
|
|
4609
4539
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4610
4540
|
* Licensed under the MIT License.
|
|
@@ -4614,7 +4544,7 @@
|
|
|
4614
4544
|
response.hasOwnProperty("error_description"));
|
|
4615
4545
|
}
|
|
4616
4546
|
|
|
4617
|
-
/*! @azure/msal-common
|
|
4547
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
4618
4548
|
/*
|
|
4619
4549
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4620
4550
|
* Licensed under the MIT License.
|
|
@@ -5101,7 +5031,7 @@
|
|
|
5101
5031
|
"multiMatchedRT",
|
|
5102
5032
|
]);
|
|
5103
5033
|
|
|
5104
|
-
/*! @azure/msal-common
|
|
5034
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
5105
5035
|
/*
|
|
5106
5036
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
5107
5037
|
* Licensed under the MIT License.
|
|
@@ -5197,7 +5127,7 @@
|
|
|
5197
5127
|
};
|
|
5198
5128
|
};
|
|
5199
5129
|
|
|
5200
|
-
/*! @azure/msal-common
|
|
5130
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
5201
5131
|
|
|
5202
5132
|
/*
|
|
5203
5133
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -5306,7 +5236,7 @@
|
|
|
5306
5236
|
},
|
|
5307
5237
|
};
|
|
5308
5238
|
|
|
5309
|
-
/*! @azure/msal-common
|
|
5239
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
5310
5240
|
|
|
5311
5241
|
/*
|
|
5312
5242
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6145,7 +6075,7 @@
|
|
|
6145
6075
|
};
|
|
6146
6076
|
}
|
|
6147
6077
|
|
|
6148
|
-
/*! @azure/msal-common
|
|
6078
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
6149
6079
|
|
|
6150
6080
|
/*
|
|
6151
6081
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6176,7 +6106,7 @@
|
|
|
6176
6106
|
}
|
|
6177
6107
|
}
|
|
6178
6108
|
|
|
6179
|
-
/*! @azure/msal-common
|
|
6109
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
6180
6110
|
|
|
6181
6111
|
/*
|
|
6182
6112
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6195,7 +6125,7 @@
|
|
|
6195
6125
|
}
|
|
6196
6126
|
}
|
|
6197
6127
|
|
|
6198
|
-
/*! @azure/msal-common
|
|
6128
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
6199
6129
|
|
|
6200
6130
|
/*
|
|
6201
6131
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6293,7 +6223,7 @@
|
|
|
6293
6223
|
}
|
|
6294
6224
|
}
|
|
6295
6225
|
|
|
6296
|
-
/*! @azure/msal-common
|
|
6226
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
6297
6227
|
|
|
6298
6228
|
/*
|
|
6299
6229
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6323,7 +6253,7 @@
|
|
|
6323
6253
|
return new NetworkError(error, httpStatus, responseHeaders);
|
|
6324
6254
|
}
|
|
6325
6255
|
|
|
6326
|
-
/*! @azure/msal-common
|
|
6256
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
6327
6257
|
|
|
6328
6258
|
/*
|
|
6329
6259
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6473,7 +6403,7 @@
|
|
|
6473
6403
|
}
|
|
6474
6404
|
}
|
|
6475
6405
|
|
|
6476
|
-
/*! @azure/msal-common
|
|
6406
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
6477
6407
|
/*
|
|
6478
6408
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6479
6409
|
* Licensed under the MIT License.
|
|
@@ -6499,7 +6429,7 @@
|
|
|
6499
6429
|
refreshTokenExpired: refreshTokenExpired
|
|
6500
6430
|
});
|
|
6501
6431
|
|
|
6502
|
-
/*! @azure/msal-common
|
|
6432
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
6503
6433
|
|
|
6504
6434
|
/*
|
|
6505
6435
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6587,7 +6517,7 @@
|
|
|
6587
6517
|
return new InteractionRequiredAuthError(errorCode, InteractionRequiredAuthErrorMessages[errorCode]);
|
|
6588
6518
|
}
|
|
6589
6519
|
|
|
6590
|
-
/*! @azure/msal-common
|
|
6520
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
6591
6521
|
|
|
6592
6522
|
/*
|
|
6593
6523
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6659,7 +6589,7 @@
|
|
|
6659
6589
|
}
|
|
6660
6590
|
}
|
|
6661
6591
|
|
|
6662
|
-
/*! @azure/msal-common
|
|
6592
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
6663
6593
|
|
|
6664
6594
|
/*
|
|
6665
6595
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6743,7 +6673,7 @@
|
|
|
6743
6673
|
}
|
|
6744
6674
|
}
|
|
6745
6675
|
|
|
6746
|
-
/*! @azure/msal-common
|
|
6676
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
6747
6677
|
/*
|
|
6748
6678
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6749
6679
|
* Licensed under the MIT License.
|
|
@@ -6770,7 +6700,7 @@
|
|
|
6770
6700
|
}
|
|
6771
6701
|
}
|
|
6772
6702
|
|
|
6773
|
-
/*! @azure/msal-common
|
|
6703
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
6774
6704
|
|
|
6775
6705
|
/*
|
|
6776
6706
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6930,7 +6860,7 @@
|
|
|
6930
6860
|
!forceCacheRefreshTokenResponse &&
|
|
6931
6861
|
cacheRecord.account) {
|
|
6932
6862
|
const key = cacheRecord.account.generateAccountKey();
|
|
6933
|
-
const account = this.cacheStorage.getAccount(key
|
|
6863
|
+
const account = this.cacheStorage.getAccount(key);
|
|
6934
6864
|
if (!account) {
|
|
6935
6865
|
this.logger.warning("Account used to refresh tokens not in persistence, refreshed tokens will not be stored in the cache");
|
|
6936
6866
|
return await ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenClaims, requestStateObj, undefined, serverRequestId);
|
|
@@ -7122,7 +7052,7 @@
|
|
|
7122
7052
|
});
|
|
7123
7053
|
let cachedAccount = null;
|
|
7124
7054
|
if (baseAccountKey) {
|
|
7125
|
-
cachedAccount = cacheStorage.getAccount(baseAccountKey
|
|
7055
|
+
cachedAccount = cacheStorage.getAccount(baseAccountKey);
|
|
7126
7056
|
}
|
|
7127
7057
|
const baseAccount = cachedAccount ||
|
|
7128
7058
|
AccountEntity.createAccount({
|
|
@@ -7147,7 +7077,7 @@
|
|
|
7147
7077
|
return baseAccount;
|
|
7148
7078
|
}
|
|
7149
7079
|
|
|
7150
|
-
/*! @azure/msal-common
|
|
7080
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
7151
7081
|
/*
|
|
7152
7082
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
7153
7083
|
* Licensed under the MIT License.
|
|
@@ -7165,7 +7095,7 @@
|
|
|
7165
7095
|
}
|
|
7166
7096
|
}
|
|
7167
7097
|
|
|
7168
|
-
/*! @azure/msal-common
|
|
7098
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
7169
7099
|
|
|
7170
7100
|
/*
|
|
7171
7101
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7607,7 +7537,7 @@
|
|
|
7607
7537
|
}
|
|
7608
7538
|
}
|
|
7609
7539
|
|
|
7610
|
-
/*! @azure/msal-common
|
|
7540
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
7611
7541
|
|
|
7612
7542
|
/*
|
|
7613
7543
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7827,7 +7757,7 @@
|
|
|
7827
7757
|
}
|
|
7828
7758
|
}
|
|
7829
7759
|
|
|
7830
|
-
/*! @azure/msal-common
|
|
7760
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
7831
7761
|
|
|
7832
7762
|
/*
|
|
7833
7763
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7963,7 +7893,7 @@
|
|
|
7963
7893
|
}
|
|
7964
7894
|
}
|
|
7965
7895
|
|
|
7966
|
-
/*! @azure/msal-common
|
|
7896
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
7967
7897
|
|
|
7968
7898
|
/*
|
|
7969
7899
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7978,7 +7908,7 @@
|
|
|
7978
7908
|
},
|
|
7979
7909
|
};
|
|
7980
7910
|
|
|
7981
|
-
/*! @azure/msal-common
|
|
7911
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
7982
7912
|
|
|
7983
7913
|
/*
|
|
7984
7914
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8036,7 +7966,7 @@
|
|
|
8036
7966
|
}
|
|
8037
7967
|
}
|
|
8038
7968
|
|
|
8039
|
-
/*! @azure/msal-common
|
|
7969
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
8040
7970
|
|
|
8041
7971
|
/*
|
|
8042
7972
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8299,7 +8229,7 @@
|
|
|
8299
8229
|
}
|
|
8300
8230
|
}
|
|
8301
8231
|
|
|
8302
|
-
/*! @azure/msal-common
|
|
8232
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
8303
8233
|
/*
|
|
8304
8234
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
8305
8235
|
* Licensed under the MIT License.
|
|
@@ -8307,7 +8237,7 @@
|
|
|
8307
8237
|
const missingKidError = "missing_kid_error";
|
|
8308
8238
|
const missingAlgError = "missing_alg_error";
|
|
8309
8239
|
|
|
8310
|
-
/*! @azure/msal-common
|
|
8240
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
8311
8241
|
|
|
8312
8242
|
/*
|
|
8313
8243
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8332,7 +8262,7 @@
|
|
|
8332
8262
|
return new JoseHeaderError(code, JoseHeaderErrorMessages[code]);
|
|
8333
8263
|
}
|
|
8334
8264
|
|
|
8335
|
-
/*! @azure/msal-common
|
|
8265
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
8336
8266
|
|
|
8337
8267
|
/*
|
|
8338
8268
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8372,7 +8302,7 @@
|
|
|
8372
8302
|
}
|
|
8373
8303
|
}
|
|
8374
8304
|
|
|
8375
|
-
/*! @azure/msal-common
|
|
8305
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
8376
8306
|
|
|
8377
8307
|
/*
|
|
8378
8308
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8451,7 +8381,7 @@
|
|
|
8451
8381
|
}
|
|
8452
8382
|
}
|
|
8453
8383
|
|
|
8454
|
-
/*! @azure/msal-common
|
|
8384
|
+
/*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
|
|
8455
8385
|
|
|
8456
8386
|
/*
|
|
8457
8387
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -9688,6 +9618,43 @@
|
|
|
9688
9618
|
return btoa(binString);
|
|
9689
9619
|
}
|
|
9690
9620
|
|
|
9621
|
+
/*
|
|
9622
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
9623
|
+
* Licensed under the MIT License.
|
|
9624
|
+
*/
|
|
9625
|
+
/**
|
|
9626
|
+
* Class which exposes APIs to decode base64 strings to plaintext. See here for implementation details:
|
|
9627
|
+
* https://developer.mozilla.org/en-US/docs/Glossary/Base64#the_unicode_problem
|
|
9628
|
+
*/
|
|
9629
|
+
/**
|
|
9630
|
+
* Returns a URL-safe plaintext decoded string from b64 encoded input.
|
|
9631
|
+
* @param input
|
|
9632
|
+
*/
|
|
9633
|
+
function base64Decode(input) {
|
|
9634
|
+
return new TextDecoder().decode(base64DecToArr(input));
|
|
9635
|
+
}
|
|
9636
|
+
/**
|
|
9637
|
+
* Decodes base64 into Uint8Array
|
|
9638
|
+
* @param base64String
|
|
9639
|
+
*/
|
|
9640
|
+
function base64DecToArr(base64String) {
|
|
9641
|
+
let encodedString = base64String.replace(/-/g, "+").replace(/_/g, "/");
|
|
9642
|
+
switch (encodedString.length % 4) {
|
|
9643
|
+
case 0:
|
|
9644
|
+
break;
|
|
9645
|
+
case 2:
|
|
9646
|
+
encodedString += "==";
|
|
9647
|
+
break;
|
|
9648
|
+
case 3:
|
|
9649
|
+
encodedString += "=";
|
|
9650
|
+
break;
|
|
9651
|
+
default:
|
|
9652
|
+
throw createBrowserAuthError(invalidBase64String);
|
|
9653
|
+
}
|
|
9654
|
+
const binString = atob(encodedString);
|
|
9655
|
+
return Uint8Array.from(binString, (m) => m.codePointAt(0) || 0);
|
|
9656
|
+
}
|
|
9657
|
+
|
|
9691
9658
|
/*
|
|
9692
9659
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
9693
9660
|
* Licensed under the MIT License.
|
|
@@ -9699,8 +9666,10 @@
|
|
|
9699
9666
|
/**
|
|
9700
9667
|
* See here for more info on RsaHashedKeyGenParams: https://developer.mozilla.org/en-US/docs/Web/API/RsaHashedKeyGenParams
|
|
9701
9668
|
*/
|
|
9702
|
-
//
|
|
9669
|
+
// Algorithms
|
|
9703
9670
|
const PKCS1_V15_KEYGEN_ALG = "RSASSA-PKCS1-v1_5";
|
|
9671
|
+
const AES_GCM = "AES-GCM";
|
|
9672
|
+
const HKDF = "HKDF";
|
|
9704
9673
|
// SHA-256 hashing algorithm
|
|
9705
9674
|
const S256_HASH_ALG = "SHA-256";
|
|
9706
9675
|
// MOD length for PoP tokens
|
|
@@ -9711,6 +9680,13 @@
|
|
|
9711
9680
|
const UUID_CHARS = "0123456789abcdef";
|
|
9712
9681
|
// Array to store UINT32 random value
|
|
9713
9682
|
const UINT32_ARR = new Uint32Array(1);
|
|
9683
|
+
// Key Format
|
|
9684
|
+
const RAW = "raw";
|
|
9685
|
+
// Key Usages
|
|
9686
|
+
const ENCRYPT = "encrypt";
|
|
9687
|
+
const DECRYPT = "decrypt";
|
|
9688
|
+
const DERIVE_KEY = "deriveKey";
|
|
9689
|
+
// Suberror
|
|
9714
9690
|
const SUBTLE_SUBERROR = "crypto_subtle_undefined";
|
|
9715
9691
|
const keygenAlgorithmOptions = {
|
|
9716
9692
|
name: PKCS1_V15_KEYGEN_ALG,
|
|
@@ -9833,6 +9809,76 @@
|
|
|
9833
9809
|
async function sign(key, data) {
|
|
9834
9810
|
return window.crypto.subtle.sign(keygenAlgorithmOptions, key, data);
|
|
9835
9811
|
}
|
|
9812
|
+
/**
|
|
9813
|
+
* Generates symmetric base encryption key. This may be stored as all encryption/decryption keys will be derived from this one.
|
|
9814
|
+
*/
|
|
9815
|
+
async function generateBaseKey() {
|
|
9816
|
+
const key = await window.crypto.subtle.generateKey({
|
|
9817
|
+
name: AES_GCM,
|
|
9818
|
+
length: 256,
|
|
9819
|
+
}, true, [ENCRYPT, DECRYPT]);
|
|
9820
|
+
return window.crypto.subtle.exportKey(RAW, key);
|
|
9821
|
+
}
|
|
9822
|
+
/**
|
|
9823
|
+
* Returns the raw key to be passed into the key derivation function
|
|
9824
|
+
* @param baseKey
|
|
9825
|
+
* @returns
|
|
9826
|
+
*/
|
|
9827
|
+
async function generateHKDF(baseKey) {
|
|
9828
|
+
return window.crypto.subtle.importKey(RAW, baseKey, HKDF, false, [
|
|
9829
|
+
DERIVE_KEY,
|
|
9830
|
+
]);
|
|
9831
|
+
}
|
|
9832
|
+
/**
|
|
9833
|
+
* Given a base key and a nonce generates a derived key to be used in encryption and decryption.
|
|
9834
|
+
* Note: every time we encrypt a new key is derived
|
|
9835
|
+
* @param baseKey
|
|
9836
|
+
* @param nonce
|
|
9837
|
+
* @returns
|
|
9838
|
+
*/
|
|
9839
|
+
async function deriveKey(baseKey, nonce, context) {
|
|
9840
|
+
return window.crypto.subtle.deriveKey({
|
|
9841
|
+
name: HKDF,
|
|
9842
|
+
salt: nonce,
|
|
9843
|
+
hash: S256_HASH_ALG,
|
|
9844
|
+
info: new TextEncoder().encode(context),
|
|
9845
|
+
}, baseKey, { name: AES_GCM, length: 256 }, false, [ENCRYPT, DECRYPT]);
|
|
9846
|
+
}
|
|
9847
|
+
/**
|
|
9848
|
+
* Encrypt the given data given a base key. Returns encrypted data and a nonce that must be provided during decryption
|
|
9849
|
+
* @param key
|
|
9850
|
+
* @param rawData
|
|
9851
|
+
*/
|
|
9852
|
+
async function encrypt(baseKey, rawData, context) {
|
|
9853
|
+
const encodedData = new TextEncoder().encode(rawData);
|
|
9854
|
+
// The nonce must never be reused with a given key.
|
|
9855
|
+
const nonce = window.crypto.getRandomValues(new Uint8Array(16));
|
|
9856
|
+
const derivedKey = await deriveKey(baseKey, nonce, context);
|
|
9857
|
+
const encryptedData = await window.crypto.subtle.encrypt({
|
|
9858
|
+
name: AES_GCM,
|
|
9859
|
+
iv: new Uint8Array(12), // New key is derived for every encrypt so we don't need a new nonce
|
|
9860
|
+
}, derivedKey, encodedData);
|
|
9861
|
+
return {
|
|
9862
|
+
data: urlEncodeArr(new Uint8Array(encryptedData)),
|
|
9863
|
+
nonce: urlEncodeArr(nonce),
|
|
9864
|
+
};
|
|
9865
|
+
}
|
|
9866
|
+
/**
|
|
9867
|
+
* Decrypt data with the given key and nonce
|
|
9868
|
+
* @param key
|
|
9869
|
+
* @param nonce
|
|
9870
|
+
* @param encryptedData
|
|
9871
|
+
* @returns
|
|
9872
|
+
*/
|
|
9873
|
+
async function decrypt(baseKey, nonce, context, encryptedData) {
|
|
9874
|
+
const encodedData = base64DecToArr(encryptedData);
|
|
9875
|
+
const derivedKey = await deriveKey(baseKey, base64DecToArr(nonce), context);
|
|
9876
|
+
const decryptedData = await window.crypto.subtle.decrypt({
|
|
9877
|
+
name: AES_GCM,
|
|
9878
|
+
iv: new Uint8Array(12), // New key is derived for every encrypt so we don't need a new nonce
|
|
9879
|
+
}, derivedKey, encodedData);
|
|
9880
|
+
return new TextDecoder().decode(decryptedData);
|
|
9881
|
+
}
|
|
9836
9882
|
/**
|
|
9837
9883
|
* Returns the SHA-256 hash of an input string
|
|
9838
9884
|
* @param plainText
|
|
@@ -10370,7 +10416,7 @@
|
|
|
10370
10416
|
|
|
10371
10417
|
/* eslint-disable header/header */
|
|
10372
10418
|
const name = "@azure/msal-browser";
|
|
10373
|
-
const version = "
|
|
10419
|
+
const version = "4.0.0-alpha.0";
|
|
10374
10420
|
|
|
10375
10421
|
/*
|
|
10376
10422
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -10746,43 +10792,6 @@
|
|
|
10746
10792
|
*/
|
|
10747
10793
|
StandardOperatingContext.ID = "StandardOperatingContext";
|
|
10748
10794
|
|
|
10749
|
-
/*
|
|
10750
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
10751
|
-
* Licensed under the MIT License.
|
|
10752
|
-
*/
|
|
10753
|
-
/**
|
|
10754
|
-
* Class which exposes APIs to decode base64 strings to plaintext. See here for implementation details:
|
|
10755
|
-
* https://developer.mozilla.org/en-US/docs/Glossary/Base64#the_unicode_problem
|
|
10756
|
-
*/
|
|
10757
|
-
/**
|
|
10758
|
-
* Returns a URL-safe plaintext decoded string from b64 encoded input.
|
|
10759
|
-
* @param input
|
|
10760
|
-
*/
|
|
10761
|
-
function base64Decode(input) {
|
|
10762
|
-
return new TextDecoder().decode(base64DecToArr(input));
|
|
10763
|
-
}
|
|
10764
|
-
/**
|
|
10765
|
-
* Decodes base64 into Uint8Array
|
|
10766
|
-
* @param base64String
|
|
10767
|
-
*/
|
|
10768
|
-
function base64DecToArr(base64String) {
|
|
10769
|
-
let encodedString = base64String.replace(/-/g, "+").replace(/_/g, "/");
|
|
10770
|
-
switch (encodedString.length % 4) {
|
|
10771
|
-
case 0:
|
|
10772
|
-
break;
|
|
10773
|
-
case 2:
|
|
10774
|
-
encodedString += "==";
|
|
10775
|
-
break;
|
|
10776
|
-
case 3:
|
|
10777
|
-
encodedString += "=";
|
|
10778
|
-
break;
|
|
10779
|
-
default:
|
|
10780
|
-
throw createBrowserAuthError(invalidBase64String);
|
|
10781
|
-
}
|
|
10782
|
-
const binString = atob(encodedString);
|
|
10783
|
-
return Uint8Array.from(binString, (m) => m.codePointAt(0) || 0);
|
|
10784
|
-
}
|
|
10785
|
-
|
|
10786
10795
|
/*
|
|
10787
10796
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
10788
10797
|
* Licensed under the MIT License.
|
|
@@ -10992,12 +11001,21 @@
|
|
|
10992
11001
|
constructor() {
|
|
10993
11002
|
this.cache = new Map();
|
|
10994
11003
|
}
|
|
11004
|
+
async initialize() {
|
|
11005
|
+
// Memory storage does not require initialization
|
|
11006
|
+
}
|
|
10995
11007
|
getItem(key) {
|
|
10996
11008
|
return this.cache.get(key) || null;
|
|
10997
11009
|
}
|
|
11010
|
+
getUserData(key) {
|
|
11011
|
+
return this.getItem(key);
|
|
11012
|
+
}
|
|
10998
11013
|
setItem(key, value) {
|
|
10999
11014
|
this.cache.set(key, value);
|
|
11000
11015
|
}
|
|
11016
|
+
async setUserData(key, value) {
|
|
11017
|
+
this.setItem(key, value);
|
|
11018
|
+
}
|
|
11001
11019
|
removeItem(key) {
|
|
11002
11020
|
this.cache.delete(key);
|
|
11003
11021
|
}
|
|
@@ -11329,19 +11347,188 @@
|
|
|
11329
11347
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
11330
11348
|
* Licensed under the MIT License.
|
|
11331
11349
|
*/
|
|
11350
|
+
// Cookie life calculation (hours * minutes * seconds * ms)
|
|
11351
|
+
const COOKIE_LIFE_MULTIPLIER = 24 * 60 * 60 * 1000;
|
|
11352
|
+
class CookieStorage {
|
|
11353
|
+
initialize() {
|
|
11354
|
+
return Promise.resolve();
|
|
11355
|
+
}
|
|
11356
|
+
getItem(key) {
|
|
11357
|
+
const name = `${encodeURIComponent(key)}`;
|
|
11358
|
+
const cookieList = document.cookie.split(";");
|
|
11359
|
+
for (let i = 0; i < cookieList.length; i++) {
|
|
11360
|
+
const cookie = cookieList[i];
|
|
11361
|
+
const [key, ...rest] = decodeURIComponent(cookie).trim().split("=");
|
|
11362
|
+
const value = rest.join("=");
|
|
11363
|
+
if (key === name) {
|
|
11364
|
+
return value;
|
|
11365
|
+
}
|
|
11366
|
+
}
|
|
11367
|
+
return "";
|
|
11368
|
+
}
|
|
11369
|
+
getUserData() {
|
|
11370
|
+
throw createClientAuthError(methodNotImplemented);
|
|
11371
|
+
}
|
|
11372
|
+
setItem(key, value, cookieLifeDays, secure = true) {
|
|
11373
|
+
let cookieStr = `${encodeURIComponent(key)}=${encodeURIComponent(value)};path=/;SameSite=Lax;`;
|
|
11374
|
+
if (cookieLifeDays) {
|
|
11375
|
+
const expireTime = getCookieExpirationTime(cookieLifeDays);
|
|
11376
|
+
cookieStr += `expires=${expireTime};`;
|
|
11377
|
+
}
|
|
11378
|
+
if (secure) {
|
|
11379
|
+
cookieStr += "Secure;";
|
|
11380
|
+
}
|
|
11381
|
+
document.cookie = cookieStr;
|
|
11382
|
+
}
|
|
11383
|
+
async setUserData() {
|
|
11384
|
+
return Promise.reject(createClientAuthError(methodNotImplemented));
|
|
11385
|
+
}
|
|
11386
|
+
removeItem(key) {
|
|
11387
|
+
// Setting expiration to -1 removes it
|
|
11388
|
+
this.setItem(key, "", -1);
|
|
11389
|
+
}
|
|
11390
|
+
getKeys() {
|
|
11391
|
+
const cookieList = document.cookie.split(";");
|
|
11392
|
+
const keys = [];
|
|
11393
|
+
cookieList.forEach((cookie) => {
|
|
11394
|
+
const cookieParts = decodeURIComponent(cookie).trim().split("=");
|
|
11395
|
+
keys.push(cookieParts[0]);
|
|
11396
|
+
});
|
|
11397
|
+
return keys;
|
|
11398
|
+
}
|
|
11399
|
+
containsKey(key) {
|
|
11400
|
+
return this.getKeys().includes(key);
|
|
11401
|
+
}
|
|
11402
|
+
}
|
|
11403
|
+
/**
|
|
11404
|
+
* Get cookie expiration time
|
|
11405
|
+
* @param cookieLifeDays
|
|
11406
|
+
*/
|
|
11407
|
+
function getCookieExpirationTime(cookieLifeDays) {
|
|
11408
|
+
const today = new Date();
|
|
11409
|
+
const expr = new Date(today.getTime() + cookieLifeDays * COOKIE_LIFE_MULTIPLIER);
|
|
11410
|
+
return expr.toUTCString();
|
|
11411
|
+
}
|
|
11412
|
+
|
|
11413
|
+
/*
|
|
11414
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
11415
|
+
* Licensed under the MIT License.
|
|
11416
|
+
*/
|
|
11417
|
+
/**
|
|
11418
|
+
* Returns a list of cache keys for all known accounts
|
|
11419
|
+
* @param storage
|
|
11420
|
+
* @returns
|
|
11421
|
+
*/
|
|
11422
|
+
function getAccountKeys(storage) {
|
|
11423
|
+
const accountKeys = storage.getItem(StaticCacheKeys.ACCOUNT_KEYS);
|
|
11424
|
+
if (accountKeys) {
|
|
11425
|
+
return JSON.parse(accountKeys);
|
|
11426
|
+
}
|
|
11427
|
+
return [];
|
|
11428
|
+
}
|
|
11429
|
+
/**
|
|
11430
|
+
* Returns a list of cache keys for all known tokens
|
|
11431
|
+
* @param clientId
|
|
11432
|
+
* @param storage
|
|
11433
|
+
* @returns
|
|
11434
|
+
*/
|
|
11435
|
+
function getTokenKeys(clientId, storage) {
|
|
11436
|
+
const item = storage.getItem(`${StaticCacheKeys.TOKEN_KEYS}.${clientId}`);
|
|
11437
|
+
if (item) {
|
|
11438
|
+
const tokenKeys = JSON.parse(item);
|
|
11439
|
+
if (tokenKeys &&
|
|
11440
|
+
tokenKeys.hasOwnProperty("idToken") &&
|
|
11441
|
+
tokenKeys.hasOwnProperty("accessToken") &&
|
|
11442
|
+
tokenKeys.hasOwnProperty("refreshToken")) {
|
|
11443
|
+
return tokenKeys;
|
|
11444
|
+
}
|
|
11445
|
+
}
|
|
11446
|
+
return {
|
|
11447
|
+
idToken: [],
|
|
11448
|
+
accessToken: [],
|
|
11449
|
+
refreshToken: [],
|
|
11450
|
+
};
|
|
11451
|
+
}
|
|
11452
|
+
|
|
11453
|
+
/*
|
|
11454
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
11455
|
+
* Licensed under the MIT License.
|
|
11456
|
+
*/
|
|
11457
|
+
const ENCRYPTION_KEY = "msal.cache.encryption";
|
|
11332
11458
|
class LocalStorage {
|
|
11333
|
-
constructor() {
|
|
11459
|
+
constructor(clientId) {
|
|
11334
11460
|
if (!window.localStorage) {
|
|
11335
11461
|
throw createBrowserConfigurationAuthError(storageNotSupported);
|
|
11336
11462
|
}
|
|
11463
|
+
this.memoryStorage = new MemoryStorage();
|
|
11464
|
+
this.initialized = false;
|
|
11465
|
+
this.clientId = clientId;
|
|
11466
|
+
}
|
|
11467
|
+
async initialize() {
|
|
11468
|
+
this.initialized = true;
|
|
11469
|
+
const cookies = new CookieStorage();
|
|
11470
|
+
const cookieString = cookies.getItem(ENCRYPTION_KEY);
|
|
11471
|
+
let parsedCookie = { key: "", id: "" };
|
|
11472
|
+
if (cookieString) {
|
|
11473
|
+
try {
|
|
11474
|
+
parsedCookie = JSON.parse(cookieString);
|
|
11475
|
+
}
|
|
11476
|
+
catch (e) {
|
|
11477
|
+
// TODO: Log telemetry but don't throw
|
|
11478
|
+
}
|
|
11479
|
+
}
|
|
11480
|
+
if (parsedCookie.key && parsedCookie.id) {
|
|
11481
|
+
// Encryption key already exists, import
|
|
11482
|
+
this.encryptionCookie = {
|
|
11483
|
+
id: parsedCookie.id,
|
|
11484
|
+
key: await generateHKDF(base64DecToArr(parsedCookie.key)),
|
|
11485
|
+
};
|
|
11486
|
+
await this.importExistingCache();
|
|
11487
|
+
}
|
|
11488
|
+
else {
|
|
11489
|
+
// Encryption key doesn't exist or is invalid, generate a new one and clear existing cache
|
|
11490
|
+
this.clear();
|
|
11491
|
+
const id = createNewGuid();
|
|
11492
|
+
const baseKey = await generateBaseKey();
|
|
11493
|
+
const keyStr = urlEncodeArr(new Uint8Array(baseKey));
|
|
11494
|
+
this.encryptionCookie = {
|
|
11495
|
+
id: id,
|
|
11496
|
+
key: await generateHKDF(baseKey),
|
|
11497
|
+
};
|
|
11498
|
+
const cookieData = {
|
|
11499
|
+
id: id,
|
|
11500
|
+
key: keyStr,
|
|
11501
|
+
};
|
|
11502
|
+
cookies.setItem(ENCRYPTION_KEY, JSON.stringify(cookieData));
|
|
11503
|
+
}
|
|
11337
11504
|
}
|
|
11338
11505
|
getItem(key) {
|
|
11339
11506
|
return window.localStorage.getItem(key);
|
|
11340
11507
|
}
|
|
11508
|
+
getUserData(key) {
|
|
11509
|
+
if (!this.initialized) {
|
|
11510
|
+
throw createBrowserAuthError(uninitializedPublicClientApplication);
|
|
11511
|
+
}
|
|
11512
|
+
return this.memoryStorage.getItem(key);
|
|
11513
|
+
}
|
|
11341
11514
|
setItem(key, value) {
|
|
11342
11515
|
window.localStorage.setItem(key, value);
|
|
11343
11516
|
}
|
|
11517
|
+
async setUserData(key, value) {
|
|
11518
|
+
if (!this.initialized || !this.encryptionCookie) {
|
|
11519
|
+
throw createBrowserAuthError(uninitializedPublicClientApplication);
|
|
11520
|
+
}
|
|
11521
|
+
const { data, nonce } = await encrypt(this.encryptionCookie.key, value, this.getContext(key));
|
|
11522
|
+
const encryptedData = {
|
|
11523
|
+
id: this.encryptionCookie.id,
|
|
11524
|
+
nonce: nonce,
|
|
11525
|
+
data: data,
|
|
11526
|
+
};
|
|
11527
|
+
this.memoryStorage.setItem(key, value);
|
|
11528
|
+
this.setItem(key, JSON.stringify(encryptedData));
|
|
11529
|
+
}
|
|
11344
11530
|
removeItem(key) {
|
|
11531
|
+
this.memoryStorage.removeItem(key);
|
|
11345
11532
|
window.localStorage.removeItem(key);
|
|
11346
11533
|
}
|
|
11347
11534
|
getKeys() {
|
|
@@ -11350,6 +11537,102 @@
|
|
|
11350
11537
|
containsKey(key) {
|
|
11351
11538
|
return window.localStorage.hasOwnProperty(key);
|
|
11352
11539
|
}
|
|
11540
|
+
/**
|
|
11541
|
+
* Removes all known MSAL keys from the cache
|
|
11542
|
+
*/
|
|
11543
|
+
clear() {
|
|
11544
|
+
// Removes all remaining MSAL cache items
|
|
11545
|
+
this.memoryStorage.clear();
|
|
11546
|
+
const accountKeys = getAccountKeys(this);
|
|
11547
|
+
accountKeys.forEach((key) => this.removeItem(key));
|
|
11548
|
+
const tokenKeys = getTokenKeys(this.clientId, this);
|
|
11549
|
+
tokenKeys.idToken.forEach((key) => this.removeItem(key));
|
|
11550
|
+
tokenKeys.accessToken.forEach((key) => this.removeItem(key));
|
|
11551
|
+
tokenKeys.refreshToken.forEach((key) => this.removeItem(key));
|
|
11552
|
+
// Clean up anything left
|
|
11553
|
+
this.getKeys().forEach((cacheKey) => {
|
|
11554
|
+
if (cacheKey.startsWith(Constants.CACHE_PREFIX) ||
|
|
11555
|
+
cacheKey.indexOf(this.clientId) !== -1) {
|
|
11556
|
+
this.removeItem(cacheKey);
|
|
11557
|
+
}
|
|
11558
|
+
});
|
|
11559
|
+
}
|
|
11560
|
+
/**
|
|
11561
|
+
* Helper to decrypt all known MSAL keys in localStorage and save them to inMemory storage
|
|
11562
|
+
* @returns
|
|
11563
|
+
*/
|
|
11564
|
+
async importExistingCache() {
|
|
11565
|
+
if (!this.encryptionCookie) {
|
|
11566
|
+
return;
|
|
11567
|
+
}
|
|
11568
|
+
const accountKeys = getAccountKeys(this);
|
|
11569
|
+
await this.importArray(accountKeys);
|
|
11570
|
+
const tokenKeys = getTokenKeys(this.clientId, this);
|
|
11571
|
+
await Promise.all([
|
|
11572
|
+
this.importArray(tokenKeys.idToken),
|
|
11573
|
+
this.importArray(tokenKeys.accessToken),
|
|
11574
|
+
this.importArray(tokenKeys.refreshToken),
|
|
11575
|
+
]);
|
|
11576
|
+
}
|
|
11577
|
+
/**
|
|
11578
|
+
* Helper to decrypt and save cache entries
|
|
11579
|
+
* @param key
|
|
11580
|
+
* @returns
|
|
11581
|
+
*/
|
|
11582
|
+
async getItemFromEncryptedCache(key) {
|
|
11583
|
+
if (!this.encryptionCookie) {
|
|
11584
|
+
return null;
|
|
11585
|
+
}
|
|
11586
|
+
const rawCache = this.getItem(key);
|
|
11587
|
+
if (!rawCache) {
|
|
11588
|
+
return null;
|
|
11589
|
+
}
|
|
11590
|
+
let encObj;
|
|
11591
|
+
try {
|
|
11592
|
+
encObj = JSON.parse(rawCache);
|
|
11593
|
+
if (!encObj.id || !encObj.nonce || !encObj.data) {
|
|
11594
|
+
throw "Not encrypted!"; // TODO: Typed error
|
|
11595
|
+
}
|
|
11596
|
+
if (encObj.id !== this.encryptionCookie.id) {
|
|
11597
|
+
throw "Old item!"; // TODO: Typed error
|
|
11598
|
+
}
|
|
11599
|
+
}
|
|
11600
|
+
catch (e) {
|
|
11601
|
+
// Not a valid encrypted object, remove
|
|
11602
|
+
this.removeItem(key);
|
|
11603
|
+
// TODO: Log to telemetry
|
|
11604
|
+
return null;
|
|
11605
|
+
}
|
|
11606
|
+
return decrypt(this.encryptionCookie.key, encObj.nonce, this.getContext(key), encObj.data);
|
|
11607
|
+
}
|
|
11608
|
+
/**
|
|
11609
|
+
* Helper to decrypt and save an array of cache keys
|
|
11610
|
+
* @param arr
|
|
11611
|
+
*/
|
|
11612
|
+
async importArray(arr) {
|
|
11613
|
+
const promiseArr = [];
|
|
11614
|
+
arr.forEach((key) => {
|
|
11615
|
+
const promise = this.getItemFromEncryptedCache(key).then((value) => {
|
|
11616
|
+
if (value) {
|
|
11617
|
+
this.memoryStorage.setItem(key, value);
|
|
11618
|
+
}
|
|
11619
|
+
});
|
|
11620
|
+
promiseArr.push(promise);
|
|
11621
|
+
});
|
|
11622
|
+
await Promise.all(promiseArr);
|
|
11623
|
+
}
|
|
11624
|
+
/**
|
|
11625
|
+
* Gets encryption context for a given cache entry. This is clientId for app specific entries, empty string for shared entries
|
|
11626
|
+
* @param key
|
|
11627
|
+
* @returns
|
|
11628
|
+
*/
|
|
11629
|
+
getContext(key) {
|
|
11630
|
+
let context = "";
|
|
11631
|
+
if (key.includes(this.clientId)) {
|
|
11632
|
+
context = this.clientId; // Used to bind encryption key to this appId
|
|
11633
|
+
}
|
|
11634
|
+
return context;
|
|
11635
|
+
}
|
|
11353
11636
|
}
|
|
11354
11637
|
|
|
11355
11638
|
/*
|
|
@@ -11362,12 +11645,21 @@
|
|
|
11362
11645
|
throw createBrowserConfigurationAuthError(storageNotSupported);
|
|
11363
11646
|
}
|
|
11364
11647
|
}
|
|
11648
|
+
async initialize() {
|
|
11649
|
+
// Session storage does not require initialization
|
|
11650
|
+
}
|
|
11365
11651
|
getItem(key) {
|
|
11366
11652
|
return window.sessionStorage.getItem(key);
|
|
11367
11653
|
}
|
|
11654
|
+
getUserData(key) {
|
|
11655
|
+
return this.getItem(key);
|
|
11656
|
+
}
|
|
11368
11657
|
setItem(key, value) {
|
|
11369
11658
|
window.sessionStorage.setItem(key, value);
|
|
11370
11659
|
}
|
|
11660
|
+
async setUserData(key, value) {
|
|
11661
|
+
this.setItem(key, value);
|
|
11662
|
+
}
|
|
11371
11663
|
removeItem(key) {
|
|
11372
11664
|
window.sessionStorage.removeItem(key);
|
|
11373
11665
|
}
|
|
@@ -11401,64 +11693,6 @@
|
|
|
11401
11693
|
}
|
|
11402
11694
|
}
|
|
11403
11695
|
|
|
11404
|
-
/*
|
|
11405
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
11406
|
-
* Licensed under the MIT License.
|
|
11407
|
-
*/
|
|
11408
|
-
// Cookie life calculation (hours * minutes * seconds * ms)
|
|
11409
|
-
const COOKIE_LIFE_MULTIPLIER = 24 * 60 * 60 * 1000;
|
|
11410
|
-
class CookieStorage {
|
|
11411
|
-
getItem(key) {
|
|
11412
|
-
const name = `${encodeURIComponent(key)}`;
|
|
11413
|
-
const cookieList = document.cookie.split(";");
|
|
11414
|
-
for (let i = 0; i < cookieList.length; i++) {
|
|
11415
|
-
const cookie = cookieList[i];
|
|
11416
|
-
const [key, ...rest] = decodeURIComponent(cookie).trim().split("=");
|
|
11417
|
-
const value = rest.join("=");
|
|
11418
|
-
if (key === name) {
|
|
11419
|
-
return value;
|
|
11420
|
-
}
|
|
11421
|
-
}
|
|
11422
|
-
return "";
|
|
11423
|
-
}
|
|
11424
|
-
setItem(key, value, cookieLifeDays, secure = true) {
|
|
11425
|
-
let cookieStr = `${encodeURIComponent(key)}=${encodeURIComponent(value)};path=/;SameSite=Lax;`;
|
|
11426
|
-
if (cookieLifeDays) {
|
|
11427
|
-
const expireTime = getCookieExpirationTime(cookieLifeDays);
|
|
11428
|
-
cookieStr += `expires=${expireTime};`;
|
|
11429
|
-
}
|
|
11430
|
-
if (secure) {
|
|
11431
|
-
cookieStr += "Secure;";
|
|
11432
|
-
}
|
|
11433
|
-
document.cookie = cookieStr;
|
|
11434
|
-
}
|
|
11435
|
-
removeItem(key) {
|
|
11436
|
-
// Setting expiration to -1 removes it
|
|
11437
|
-
this.setItem(key, "", -1);
|
|
11438
|
-
}
|
|
11439
|
-
getKeys() {
|
|
11440
|
-
const cookieList = document.cookie.split(";");
|
|
11441
|
-
const keys = [];
|
|
11442
|
-
cookieList.forEach((cookie) => {
|
|
11443
|
-
const cookieParts = decodeURIComponent(cookie).trim().split("=");
|
|
11444
|
-
keys.push(cookieParts[0]);
|
|
11445
|
-
});
|
|
11446
|
-
return keys;
|
|
11447
|
-
}
|
|
11448
|
-
containsKey(key) {
|
|
11449
|
-
return this.getKeys().includes(key);
|
|
11450
|
-
}
|
|
11451
|
-
}
|
|
11452
|
-
/**
|
|
11453
|
-
* Get cookie expiration time
|
|
11454
|
-
* @param cookieLifeDays
|
|
11455
|
-
*/
|
|
11456
|
-
function getCookieExpirationTime(cookieLifeDays) {
|
|
11457
|
-
const today = new Date();
|
|
11458
|
-
const expr = new Date(today.getTime() + cookieLifeDays * COOKIE_LIFE_MULTIPLIER);
|
|
11459
|
-
return expr.toUTCString();
|
|
11460
|
-
}
|
|
11461
|
-
|
|
11462
11696
|
/*
|
|
11463
11697
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
11464
11698
|
* Licensed under the MIT License.
|
|
@@ -11477,13 +11711,11 @@
|
|
|
11477
11711
|
this.browserStorage = this.setupBrowserStorage(this.cacheConfig.cacheLocation);
|
|
11478
11712
|
this.temporaryCacheStorage = this.setupBrowserStorage(this.cacheConfig.temporaryCacheLocation);
|
|
11479
11713
|
this.cookieStorage = new CookieStorage();
|
|
11480
|
-
// Migrate cache entries from older versions of MSAL.
|
|
11481
|
-
if (cacheConfig.cacheMigrationEnabled) {
|
|
11482
|
-
this.migrateCacheEntries();
|
|
11483
|
-
this.createKeyMaps();
|
|
11484
|
-
}
|
|
11485
11714
|
this.performanceClient = performanceClient;
|
|
11486
11715
|
}
|
|
11716
|
+
async initialize() {
|
|
11717
|
+
await this.browserStorage.initialize();
|
|
11718
|
+
}
|
|
11487
11719
|
/**
|
|
11488
11720
|
* Returns a window storage class implementing the IWindowStorage interface that corresponds to the configured cacheLocation.
|
|
11489
11721
|
* @param cacheLocation
|
|
@@ -11492,7 +11724,7 @@
|
|
|
11492
11724
|
try {
|
|
11493
11725
|
switch (cacheLocation) {
|
|
11494
11726
|
case BrowserCacheLocation.LocalStorage:
|
|
11495
|
-
return new LocalStorage();
|
|
11727
|
+
return new LocalStorage(this.clientId);
|
|
11496
11728
|
case BrowserCacheLocation.SessionStorage:
|
|
11497
11729
|
return new SessionStorage();
|
|
11498
11730
|
case BrowserCacheLocation.MemoryStorage:
|
|
@@ -11506,123 +11738,6 @@
|
|
|
11506
11738
|
this.cacheConfig.cacheLocation = BrowserCacheLocation.MemoryStorage;
|
|
11507
11739
|
return new MemoryStorage();
|
|
11508
11740
|
}
|
|
11509
|
-
/**
|
|
11510
|
-
* Migrate all old cache entries to new schema. No rollback supported.
|
|
11511
|
-
* @param storeAuthStateInCookie
|
|
11512
|
-
*/
|
|
11513
|
-
migrateCacheEntries() {
|
|
11514
|
-
const idTokenKey = `${Constants.CACHE_PREFIX}.${PersistentCacheKeys.ID_TOKEN}`;
|
|
11515
|
-
const clientInfoKey = `${Constants.CACHE_PREFIX}.${PersistentCacheKeys.CLIENT_INFO}`;
|
|
11516
|
-
const errorKey = `${Constants.CACHE_PREFIX}.${PersistentCacheKeys.ERROR}`;
|
|
11517
|
-
const errorDescKey = `${Constants.CACHE_PREFIX}.${PersistentCacheKeys.ERROR_DESC}`;
|
|
11518
|
-
const idTokenValue = this.browserStorage.getItem(idTokenKey);
|
|
11519
|
-
const clientInfoValue = this.browserStorage.getItem(clientInfoKey);
|
|
11520
|
-
const errorValue = this.browserStorage.getItem(errorKey);
|
|
11521
|
-
const errorDescValue = this.browserStorage.getItem(errorDescKey);
|
|
11522
|
-
const values = [
|
|
11523
|
-
idTokenValue,
|
|
11524
|
-
clientInfoValue,
|
|
11525
|
-
errorValue,
|
|
11526
|
-
errorDescValue,
|
|
11527
|
-
];
|
|
11528
|
-
const keysToMigrate = [
|
|
11529
|
-
PersistentCacheKeys.ID_TOKEN,
|
|
11530
|
-
PersistentCacheKeys.CLIENT_INFO,
|
|
11531
|
-
PersistentCacheKeys.ERROR,
|
|
11532
|
-
PersistentCacheKeys.ERROR_DESC,
|
|
11533
|
-
];
|
|
11534
|
-
keysToMigrate.forEach((cacheKey, index) => {
|
|
11535
|
-
const value = values[index];
|
|
11536
|
-
if (value) {
|
|
11537
|
-
this.setTemporaryCache(cacheKey, value, true);
|
|
11538
|
-
}
|
|
11539
|
-
});
|
|
11540
|
-
}
|
|
11541
|
-
/**
|
|
11542
|
-
* Searches all cache entries for MSAL accounts and creates the account key map
|
|
11543
|
-
* This is used to migrate users from older versions of MSAL which did not create the map.
|
|
11544
|
-
* @returns
|
|
11545
|
-
*/
|
|
11546
|
-
createKeyMaps() {
|
|
11547
|
-
this.logger.trace("BrowserCacheManager - createKeyMaps called.");
|
|
11548
|
-
const accountKeys = this.getItem(StaticCacheKeys.ACCOUNT_KEYS);
|
|
11549
|
-
const tokenKeys = this.getItem(`${StaticCacheKeys.TOKEN_KEYS}.${this.clientId}`);
|
|
11550
|
-
if (accountKeys && tokenKeys) {
|
|
11551
|
-
this.logger.verbose("BrowserCacheManager:createKeyMaps - account and token key maps already exist, skipping migration.");
|
|
11552
|
-
// Key maps already exist, no need to iterate through cache
|
|
11553
|
-
return;
|
|
11554
|
-
}
|
|
11555
|
-
const allKeys = this.browserStorage.getKeys();
|
|
11556
|
-
allKeys.forEach((key) => {
|
|
11557
|
-
if (this.isCredentialKey(key)) {
|
|
11558
|
-
// Get item, parse, validate and write key to map
|
|
11559
|
-
const value = this.getItem(key);
|
|
11560
|
-
if (value) {
|
|
11561
|
-
const credObj = this.validateAndParseJson(value);
|
|
11562
|
-
if (credObj && credObj.hasOwnProperty("credentialType")) {
|
|
11563
|
-
switch (credObj["credentialType"]) {
|
|
11564
|
-
case CredentialType.ID_TOKEN:
|
|
11565
|
-
if (isIdTokenEntity(credObj)) {
|
|
11566
|
-
this.logger.trace("BrowserCacheManager:createKeyMaps - idToken found, saving key to token key map");
|
|
11567
|
-
this.logger.tracePii(`BrowserCacheManager:createKeyMaps - idToken with key: ${key} found, saving key to token key map`);
|
|
11568
|
-
const idTokenEntity = credObj;
|
|
11569
|
-
const newKey = this.updateCredentialCacheKey(key, idTokenEntity);
|
|
11570
|
-
this.addTokenKey(newKey, CredentialType.ID_TOKEN);
|
|
11571
|
-
return;
|
|
11572
|
-
}
|
|
11573
|
-
else {
|
|
11574
|
-
this.logger.trace("BrowserCacheManager:createKeyMaps - key found matching idToken schema with value containing idToken credentialType field but value failed IdTokenEntity validation, skipping.");
|
|
11575
|
-
this.logger.tracePii(`BrowserCacheManager:createKeyMaps - failed idToken validation on key: ${key}`);
|
|
11576
|
-
}
|
|
11577
|
-
break;
|
|
11578
|
-
case CredentialType.ACCESS_TOKEN:
|
|
11579
|
-
case CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME:
|
|
11580
|
-
if (isAccessTokenEntity(credObj)) {
|
|
11581
|
-
this.logger.trace("BrowserCacheManager:createKeyMaps - accessToken found, saving key to token key map");
|
|
11582
|
-
this.logger.tracePii(`BrowserCacheManager:createKeyMaps - accessToken with key: ${key} found, saving key to token key map`);
|
|
11583
|
-
const accessTokenEntity = credObj;
|
|
11584
|
-
const newKey = this.updateCredentialCacheKey(key, accessTokenEntity);
|
|
11585
|
-
this.addTokenKey(newKey, CredentialType.ACCESS_TOKEN);
|
|
11586
|
-
return;
|
|
11587
|
-
}
|
|
11588
|
-
else {
|
|
11589
|
-
this.logger.trace("BrowserCacheManager:createKeyMaps - key found matching accessToken schema with value containing accessToken credentialType field but value failed AccessTokenEntity validation, skipping.");
|
|
11590
|
-
this.logger.tracePii(`BrowserCacheManager:createKeyMaps - failed accessToken validation on key: ${key}`);
|
|
11591
|
-
}
|
|
11592
|
-
break;
|
|
11593
|
-
case CredentialType.REFRESH_TOKEN:
|
|
11594
|
-
if (isRefreshTokenEntity(credObj)) {
|
|
11595
|
-
this.logger.trace("BrowserCacheManager:createKeyMaps - refreshToken found, saving key to token key map");
|
|
11596
|
-
this.logger.tracePii(`BrowserCacheManager:createKeyMaps - refreshToken with key: ${key} found, saving key to token key map`);
|
|
11597
|
-
const refreshTokenEntity = credObj;
|
|
11598
|
-
const newKey = this.updateCredentialCacheKey(key, refreshTokenEntity);
|
|
11599
|
-
this.addTokenKey(newKey, CredentialType.REFRESH_TOKEN);
|
|
11600
|
-
return;
|
|
11601
|
-
}
|
|
11602
|
-
else {
|
|
11603
|
-
this.logger.trace("BrowserCacheManager:createKeyMaps - key found matching refreshToken schema with value containing refreshToken credentialType field but value failed RefreshTokenEntity validation, skipping.");
|
|
11604
|
-
this.logger.tracePii(`BrowserCacheManager:createKeyMaps - failed refreshToken validation on key: ${key}`);
|
|
11605
|
-
}
|
|
11606
|
-
break;
|
|
11607
|
-
// If credentialType isn't one of our predefined ones, it may not be an MSAL cache value. Ignore.
|
|
11608
|
-
}
|
|
11609
|
-
}
|
|
11610
|
-
}
|
|
11611
|
-
}
|
|
11612
|
-
if (this.isAccountKey(key)) {
|
|
11613
|
-
const value = this.getItem(key);
|
|
11614
|
-
if (value) {
|
|
11615
|
-
const accountObj = this.validateAndParseJson(value);
|
|
11616
|
-
if (accountObj &&
|
|
11617
|
-
AccountEntity.isAccountEntity(accountObj)) {
|
|
11618
|
-
this.logger.trace("BrowserCacheManager:createKeyMaps - account found, saving key to account key map");
|
|
11619
|
-
this.logger.tracePii(`BrowserCacheManager:createKeyMaps - account with key: ${key} found, saving key to account key map`);
|
|
11620
|
-
this.addAccountKeyToMap(key);
|
|
11621
|
-
}
|
|
11622
|
-
}
|
|
11623
|
-
}
|
|
11624
|
-
});
|
|
11625
|
-
}
|
|
11626
11741
|
/**
|
|
11627
11742
|
* Parses passed value as JSON object, JSON.parse() will throw an error.
|
|
11628
11743
|
* @param input
|
|
@@ -11644,38 +11759,15 @@
|
|
|
11644
11759
|
return null;
|
|
11645
11760
|
}
|
|
11646
11761
|
}
|
|
11647
|
-
/**
|
|
11648
|
-
* fetches the entry from the browser storage based off the key
|
|
11649
|
-
* @param key
|
|
11650
|
-
*/
|
|
11651
|
-
getItem(key) {
|
|
11652
|
-
return this.browserStorage.getItem(key);
|
|
11653
|
-
}
|
|
11654
|
-
/**
|
|
11655
|
-
* sets the entry in the browser storage
|
|
11656
|
-
* @param key
|
|
11657
|
-
* @param value
|
|
11658
|
-
*/
|
|
11659
|
-
setItem(key, value) {
|
|
11660
|
-
this.browserStorage.setItem(key, value);
|
|
11661
|
-
}
|
|
11662
|
-
/**
|
|
11663
|
-
* fetch the account entity from the platform cache
|
|
11664
|
-
* @param accountKey
|
|
11665
|
-
*/
|
|
11666
|
-
getAccount(accountKey, logger) {
|
|
11667
|
-
this.logger.trace("BrowserCacheManager.getAccount called");
|
|
11668
|
-
const accountEntity = this.getCachedAccountEntity(accountKey);
|
|
11669
|
-
return this.updateOutdatedCachedAccount(accountKey, accountEntity, logger);
|
|
11670
|
-
}
|
|
11671
11762
|
/**
|
|
11672
11763
|
* Reads account from cache, deserializes it into an account entity and returns it.
|
|
11673
11764
|
* If account is not found from the key, returns null and removes key from map.
|
|
11674
11765
|
* @param accountKey
|
|
11675
11766
|
* @returns
|
|
11676
11767
|
*/
|
|
11677
|
-
|
|
11678
|
-
|
|
11768
|
+
getAccount(accountKey) {
|
|
11769
|
+
this.logger.trace("BrowserCacheManager.getAccount called");
|
|
11770
|
+
const serializedAccount = this.browserStorage.getUserData(accountKey);
|
|
11679
11771
|
if (!serializedAccount) {
|
|
11680
11772
|
this.removeAccountKeyFromMap(accountKey);
|
|
11681
11773
|
return null;
|
|
@@ -11691,10 +11783,10 @@
|
|
|
11691
11783
|
* set account entity in the platform cache
|
|
11692
11784
|
* @param account
|
|
11693
11785
|
*/
|
|
11694
|
-
setAccount(account) {
|
|
11786
|
+
async setAccount(account) {
|
|
11695
11787
|
this.logger.trace("BrowserCacheManager.setAccount called");
|
|
11696
11788
|
const key = account.generateAccountKey();
|
|
11697
|
-
this.
|
|
11789
|
+
await this.browserStorage.setUserData(key, JSON.stringify(account));
|
|
11698
11790
|
this.addAccountKeyToMap(key);
|
|
11699
11791
|
}
|
|
11700
11792
|
/**
|
|
@@ -11702,13 +11794,7 @@
|
|
|
11702
11794
|
* @returns
|
|
11703
11795
|
*/
|
|
11704
11796
|
getAccountKeys() {
|
|
11705
|
-
this.
|
|
11706
|
-
const accountKeys = this.getItem(StaticCacheKeys.ACCOUNT_KEYS);
|
|
11707
|
-
if (accountKeys) {
|
|
11708
|
-
return JSON.parse(accountKeys);
|
|
11709
|
-
}
|
|
11710
|
-
this.logger.verbose("BrowserCacheManager.getAccountKeys - No account keys found");
|
|
11711
|
-
return [];
|
|
11797
|
+
return getAccountKeys(this.browserStorage);
|
|
11712
11798
|
}
|
|
11713
11799
|
/**
|
|
11714
11800
|
* Add a new account to the key map
|
|
@@ -11721,7 +11807,7 @@
|
|
|
11721
11807
|
if (accountKeys.indexOf(key) === -1) {
|
|
11722
11808
|
// Only add key if it does not already exist in the map
|
|
11723
11809
|
accountKeys.push(key);
|
|
11724
|
-
this.setItem(StaticCacheKeys.ACCOUNT_KEYS, JSON.stringify(accountKeys));
|
|
11810
|
+
this.browserStorage.setItem(StaticCacheKeys.ACCOUNT_KEYS, JSON.stringify(accountKeys));
|
|
11725
11811
|
this.logger.verbose("BrowserCacheManager.addAccountKeyToMap account key added");
|
|
11726
11812
|
}
|
|
11727
11813
|
else {
|
|
@@ -11739,7 +11825,7 @@
|
|
|
11739
11825
|
const removalIndex = accountKeys.indexOf(key);
|
|
11740
11826
|
if (removalIndex > -1) {
|
|
11741
11827
|
accountKeys.splice(removalIndex, 1);
|
|
11742
|
-
this.setItem(StaticCacheKeys.ACCOUNT_KEYS, JSON.stringify(accountKeys));
|
|
11828
|
+
this.browserStorage.setItem(StaticCacheKeys.ACCOUNT_KEYS, JSON.stringify(accountKeys));
|
|
11743
11829
|
this.logger.trace("BrowserCacheManager.removeAccountKeyFromMap account key removed");
|
|
11744
11830
|
}
|
|
11745
11831
|
else {
|
|
@@ -11754,14 +11840,6 @@
|
|
|
11754
11840
|
void super.removeAccount(key);
|
|
11755
11841
|
this.removeAccountKeyFromMap(key);
|
|
11756
11842
|
}
|
|
11757
|
-
/**
|
|
11758
|
-
* Remove account entity from the platform cache if it's outdated
|
|
11759
|
-
* @param accountKey
|
|
11760
|
-
*/
|
|
11761
|
-
removeOutdatedAccount(accountKey) {
|
|
11762
|
-
this.removeItem(accountKey);
|
|
11763
|
-
this.removeAccountKeyFromMap(accountKey);
|
|
11764
|
-
}
|
|
11765
11843
|
/**
|
|
11766
11844
|
* Removes given idToken from the cache and from the key map
|
|
11767
11845
|
* @param key
|
|
@@ -11791,28 +11869,7 @@
|
|
|
11791
11869
|
* @returns
|
|
11792
11870
|
*/
|
|
11793
11871
|
getTokenKeys() {
|
|
11794
|
-
this.
|
|
11795
|
-
const item = this.getItem(`${StaticCacheKeys.TOKEN_KEYS}.${this.clientId}`);
|
|
11796
|
-
if (item) {
|
|
11797
|
-
const tokenKeys = this.validateAndParseJson(item);
|
|
11798
|
-
if (tokenKeys &&
|
|
11799
|
-
tokenKeys.hasOwnProperty("idToken") &&
|
|
11800
|
-
tokenKeys.hasOwnProperty("accessToken") &&
|
|
11801
|
-
tokenKeys.hasOwnProperty("refreshToken")) {
|
|
11802
|
-
return tokenKeys;
|
|
11803
|
-
}
|
|
11804
|
-
else {
|
|
11805
|
-
this.logger.error("BrowserCacheManager.getTokenKeys - Token keys found but in an unknown format. Returning empty key map.");
|
|
11806
|
-
}
|
|
11807
|
-
}
|
|
11808
|
-
else {
|
|
11809
|
-
this.logger.verbose("BrowserCacheManager.getTokenKeys - No token keys found");
|
|
11810
|
-
}
|
|
11811
|
-
return {
|
|
11812
|
-
idToken: [],
|
|
11813
|
-
accessToken: [],
|
|
11814
|
-
refreshToken: [],
|
|
11815
|
-
};
|
|
11872
|
+
return getTokenKeys(this.clientId, this.browserStorage);
|
|
11816
11873
|
}
|
|
11817
11874
|
/**
|
|
11818
11875
|
* Adds the given key to the token key map
|
|
@@ -11845,7 +11902,7 @@
|
|
|
11845
11902
|
this.logger.error(`BrowserCacheManager:addTokenKey - CredentialType provided invalid. CredentialType: ${type}`);
|
|
11846
11903
|
throw createClientAuthError(unexpectedCredentialType);
|
|
11847
11904
|
}
|
|
11848
|
-
this.setItem(`${StaticCacheKeys.TOKEN_KEYS}.${this.clientId}`, JSON.stringify(tokenKeys));
|
|
11905
|
+
this.browserStorage.setItem(`${StaticCacheKeys.TOKEN_KEYS}.${this.clientId}`, JSON.stringify(tokenKeys));
|
|
11849
11906
|
}
|
|
11850
11907
|
/**
|
|
11851
11908
|
* Removes the given key from the token key map
|
|
@@ -11893,14 +11950,14 @@
|
|
|
11893
11950
|
this.logger.error(`BrowserCacheManager:removeTokenKey - CredentialType provided invalid. CredentialType: ${type}`);
|
|
11894
11951
|
throw createClientAuthError(unexpectedCredentialType);
|
|
11895
11952
|
}
|
|
11896
|
-
this.setItem(`${StaticCacheKeys.TOKEN_KEYS}.${this.clientId}`, JSON.stringify(tokenKeys));
|
|
11953
|
+
this.browserStorage.setItem(`${StaticCacheKeys.TOKEN_KEYS}.${this.clientId}`, JSON.stringify(tokenKeys));
|
|
11897
11954
|
}
|
|
11898
11955
|
/**
|
|
11899
11956
|
* generates idToken entity from a string
|
|
11900
11957
|
* @param idTokenKey
|
|
11901
11958
|
*/
|
|
11902
11959
|
getIdTokenCredential(idTokenKey) {
|
|
11903
|
-
const value = this.
|
|
11960
|
+
const value = this.browserStorage.getUserData(idTokenKey);
|
|
11904
11961
|
if (!value) {
|
|
11905
11962
|
this.logger.trace("BrowserCacheManager.getIdTokenCredential: called, no cache hit");
|
|
11906
11963
|
this.removeTokenKey(idTokenKey, CredentialType.ID_TOKEN);
|
|
@@ -11919,10 +11976,10 @@
|
|
|
11919
11976
|
* set IdToken credential to the platform cache
|
|
11920
11977
|
* @param idToken
|
|
11921
11978
|
*/
|
|
11922
|
-
setIdTokenCredential(idToken) {
|
|
11979
|
+
async setIdTokenCredential(idToken) {
|
|
11923
11980
|
this.logger.trace("BrowserCacheManager.setIdTokenCredential called");
|
|
11924
11981
|
const idTokenKey = generateCredentialKey(idToken);
|
|
11925
|
-
this.
|
|
11982
|
+
await this.browserStorage.setUserData(idTokenKey, JSON.stringify(idToken));
|
|
11926
11983
|
this.addTokenKey(idTokenKey, CredentialType.ID_TOKEN);
|
|
11927
11984
|
}
|
|
11928
11985
|
/**
|
|
@@ -11930,7 +11987,7 @@
|
|
|
11930
11987
|
* @param key
|
|
11931
11988
|
*/
|
|
11932
11989
|
getAccessTokenCredential(accessTokenKey) {
|
|
11933
|
-
const value = this.
|
|
11990
|
+
const value = this.browserStorage.getUserData(accessTokenKey);
|
|
11934
11991
|
if (!value) {
|
|
11935
11992
|
this.logger.trace("BrowserCacheManager.getAccessTokenCredential: called, no cache hit");
|
|
11936
11993
|
this.removeTokenKey(accessTokenKey, CredentialType.ACCESS_TOKEN);
|
|
@@ -11950,10 +12007,10 @@
|
|
|
11950
12007
|
* set accessToken credential to the platform cache
|
|
11951
12008
|
* @param accessToken
|
|
11952
12009
|
*/
|
|
11953
|
-
setAccessTokenCredential(accessToken) {
|
|
12010
|
+
async setAccessTokenCredential(accessToken) {
|
|
11954
12011
|
this.logger.trace("BrowserCacheManager.setAccessTokenCredential called");
|
|
11955
12012
|
const accessTokenKey = generateCredentialKey(accessToken);
|
|
11956
|
-
this.
|
|
12013
|
+
await this.browserStorage.setUserData(accessTokenKey, JSON.stringify(accessToken));
|
|
11957
12014
|
this.addTokenKey(accessTokenKey, CredentialType.ACCESS_TOKEN);
|
|
11958
12015
|
}
|
|
11959
12016
|
/**
|
|
@@ -11961,7 +12018,7 @@
|
|
|
11961
12018
|
* @param refreshTokenKey
|
|
11962
12019
|
*/
|
|
11963
12020
|
getRefreshTokenCredential(refreshTokenKey) {
|
|
11964
|
-
const value = this.
|
|
12021
|
+
const value = this.browserStorage.getUserData(refreshTokenKey);
|
|
11965
12022
|
if (!value) {
|
|
11966
12023
|
this.logger.trace("BrowserCacheManager.getRefreshTokenCredential: called, no cache hit");
|
|
11967
12024
|
this.removeTokenKey(refreshTokenKey, CredentialType.REFRESH_TOKEN);
|
|
@@ -11981,10 +12038,10 @@
|
|
|
11981
12038
|
* set refreshToken credential to the platform cache
|
|
11982
12039
|
* @param refreshToken
|
|
11983
12040
|
*/
|
|
11984
|
-
setRefreshTokenCredential(refreshToken) {
|
|
12041
|
+
async setRefreshTokenCredential(refreshToken) {
|
|
11985
12042
|
this.logger.trace("BrowserCacheManager.setRefreshTokenCredential called");
|
|
11986
12043
|
const refreshTokenKey = generateCredentialKey(refreshToken);
|
|
11987
|
-
this.
|
|
12044
|
+
await this.browserStorage.setUserData(refreshTokenKey, JSON.stringify(refreshToken));
|
|
11988
12045
|
this.addTokenKey(refreshTokenKey, CredentialType.REFRESH_TOKEN);
|
|
11989
12046
|
}
|
|
11990
12047
|
/**
|
|
@@ -11992,7 +12049,7 @@
|
|
|
11992
12049
|
* @param appMetadataKey
|
|
11993
12050
|
*/
|
|
11994
12051
|
getAppMetadata(appMetadataKey) {
|
|
11995
|
-
const value = this.getItem(appMetadataKey);
|
|
12052
|
+
const value = this.browserStorage.getItem(appMetadataKey);
|
|
11996
12053
|
if (!value) {
|
|
11997
12054
|
this.logger.trace("BrowserCacheManager.getAppMetadata: called, no cache hit");
|
|
11998
12055
|
return null;
|
|
@@ -12013,14 +12070,14 @@
|
|
|
12013
12070
|
setAppMetadata(appMetadata) {
|
|
12014
12071
|
this.logger.trace("BrowserCacheManager.setAppMetadata called");
|
|
12015
12072
|
const appMetadataKey = generateAppMetadataKey(appMetadata);
|
|
12016
|
-
this.setItem(appMetadataKey, JSON.stringify(appMetadata));
|
|
12073
|
+
this.browserStorage.setItem(appMetadataKey, JSON.stringify(appMetadata));
|
|
12017
12074
|
}
|
|
12018
12075
|
/**
|
|
12019
12076
|
* fetch server telemetry entity from the platform cache
|
|
12020
12077
|
* @param serverTelemetryKey
|
|
12021
12078
|
*/
|
|
12022
12079
|
getServerTelemetry(serverTelemetryKey) {
|
|
12023
|
-
const value = this.getItem(serverTelemetryKey);
|
|
12080
|
+
const value = this.browserStorage.getItem(serverTelemetryKey);
|
|
12024
12081
|
if (!value) {
|
|
12025
12082
|
this.logger.trace("BrowserCacheManager.getServerTelemetry: called, no cache hit");
|
|
12026
12083
|
return null;
|
|
@@ -12041,7 +12098,7 @@
|
|
|
12041
12098
|
*/
|
|
12042
12099
|
setServerTelemetry(serverTelemetryKey, serverTelemetry) {
|
|
12043
12100
|
this.logger.trace("BrowserCacheManager.setServerTelemetry called");
|
|
12044
|
-
this.setItem(serverTelemetryKey, JSON.stringify(serverTelemetry));
|
|
12101
|
+
this.browserStorage.setItem(serverTelemetryKey, JSON.stringify(serverTelemetry));
|
|
12045
12102
|
}
|
|
12046
12103
|
/**
|
|
12047
12104
|
*
|
|
@@ -12101,25 +12158,9 @@
|
|
|
12101
12158
|
*/
|
|
12102
12159
|
getActiveAccount() {
|
|
12103
12160
|
const activeAccountKeyFilters = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT_FILTERS);
|
|
12104
|
-
const activeAccountValueFilters = this.getItem(activeAccountKeyFilters);
|
|
12161
|
+
const activeAccountValueFilters = this.browserStorage.getItem(activeAccountKeyFilters);
|
|
12105
12162
|
if (!activeAccountValueFilters) {
|
|
12106
|
-
|
|
12107
|
-
this.logger.trace("BrowserCacheManager.getActiveAccount: No active account filters cache schema found, looking for legacy schema");
|
|
12108
|
-
const activeAccountKeyLocal = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT);
|
|
12109
|
-
const activeAccountValueLocal = this.getItem(activeAccountKeyLocal);
|
|
12110
|
-
if (!activeAccountValueLocal) {
|
|
12111
|
-
this.logger.trace("BrowserCacheManager.getActiveAccount: No active account found");
|
|
12112
|
-
return null;
|
|
12113
|
-
}
|
|
12114
|
-
const activeAccount = this.getAccountInfoFilteredBy({
|
|
12115
|
-
localAccountId: activeAccountValueLocal,
|
|
12116
|
-
});
|
|
12117
|
-
if (activeAccount) {
|
|
12118
|
-
this.logger.trace("BrowserCacheManager.getActiveAccount: Legacy active account cache schema found");
|
|
12119
|
-
this.logger.trace("BrowserCacheManager.getActiveAccount: Adding active account filters cache schema");
|
|
12120
|
-
this.setActiveAccount(activeAccount);
|
|
12121
|
-
return activeAccount;
|
|
12122
|
-
}
|
|
12163
|
+
this.logger.trace("BrowserCacheManager.getActiveAccount: No active account filters found");
|
|
12123
12164
|
return null;
|
|
12124
12165
|
}
|
|
12125
12166
|
const activeAccountValueObj = this.validateAndParseJson(activeAccountValueFilters);
|
|
@@ -12140,7 +12181,6 @@
|
|
|
12140
12181
|
*/
|
|
12141
12182
|
setActiveAccount(account) {
|
|
12142
12183
|
const activeAccountKey = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT_FILTERS);
|
|
12143
|
-
const activeAccountKeyLocal = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT);
|
|
12144
12184
|
if (account) {
|
|
12145
12185
|
this.logger.verbose("setActiveAccount: Active account set");
|
|
12146
12186
|
const activeAccountValue = {
|
|
@@ -12149,12 +12189,10 @@
|
|
|
12149
12189
|
tenantId: account.tenantId,
|
|
12150
12190
|
};
|
|
12151
12191
|
this.browserStorage.setItem(activeAccountKey, JSON.stringify(activeAccountValue));
|
|
12152
|
-
this.browserStorage.setItem(activeAccountKeyLocal, account.localAccountId);
|
|
12153
12192
|
}
|
|
12154
12193
|
else {
|
|
12155
12194
|
this.logger.verbose("setActiveAccount: No account passed, active account not set");
|
|
12156
12195
|
this.browserStorage.removeItem(activeAccountKey);
|
|
12157
|
-
this.browserStorage.removeItem(activeAccountKeyLocal);
|
|
12158
12196
|
}
|
|
12159
12197
|
}
|
|
12160
12198
|
/**
|
|
@@ -12162,7 +12200,7 @@
|
|
|
12162
12200
|
* @param throttlingCacheKey
|
|
12163
12201
|
*/
|
|
12164
12202
|
getThrottlingCache(throttlingCacheKey) {
|
|
12165
|
-
const value = this.getItem(throttlingCacheKey);
|
|
12203
|
+
const value = this.browserStorage.getItem(throttlingCacheKey);
|
|
12166
12204
|
if (!value) {
|
|
12167
12205
|
this.logger.trace("BrowserCacheManager.getThrottlingCache: called, no cache hit");
|
|
12168
12206
|
return null;
|
|
@@ -12183,7 +12221,7 @@
|
|
|
12183
12221
|
*/
|
|
12184
12222
|
setThrottlingCache(throttlingCacheKey, throttlingCache) {
|
|
12185
12223
|
this.logger.trace("BrowserCacheManager.setThrottlingCache called");
|
|
12186
|
-
this.setItem(throttlingCacheKey, JSON.stringify(throttlingCache));
|
|
12224
|
+
this.browserStorage.setItem(throttlingCacheKey, JSON.stringify(throttlingCache));
|
|
12187
12225
|
}
|
|
12188
12226
|
/**
|
|
12189
12227
|
* Gets cache item with given key.
|
|
@@ -12311,8 +12349,7 @@
|
|
|
12311
12349
|
generateCacheKey(key) {
|
|
12312
12350
|
const generatedKey = this.validateAndParseJson(key);
|
|
12313
12351
|
if (!generatedKey) {
|
|
12314
|
-
if (StringUtils.startsWith(key, Constants.CACHE_PREFIX)
|
|
12315
|
-
StringUtils.startsWith(key, PersistentCacheKeys.ADAL_ID_TOKEN)) {
|
|
12352
|
+
if (StringUtils.startsWith(key, Constants.CACHE_PREFIX)) {
|
|
12316
12353
|
return key;
|
|
12317
12354
|
}
|
|
12318
12355
|
return `${Constants.CACHE_PREFIX}.${this.clientId}.${key}`;
|
|
@@ -12538,59 +12575,6 @@
|
|
|
12538
12575
|
this.removeTemporaryItem(key);
|
|
12539
12576
|
}
|
|
12540
12577
|
}
|
|
12541
|
-
/**
|
|
12542
|
-
* Returns username retrieved from ADAL or MSAL v1 idToken
|
|
12543
|
-
* @deprecated
|
|
12544
|
-
*/
|
|
12545
|
-
getLegacyLoginHint() {
|
|
12546
|
-
// Only check for adal/msal token if no SSO params are being used
|
|
12547
|
-
const adalIdTokenString = this.getTemporaryCache(PersistentCacheKeys.ADAL_ID_TOKEN);
|
|
12548
|
-
if (adalIdTokenString) {
|
|
12549
|
-
this.browserStorage.removeItem(PersistentCacheKeys.ADAL_ID_TOKEN);
|
|
12550
|
-
this.logger.verbose("Cached ADAL id token retrieved.");
|
|
12551
|
-
}
|
|
12552
|
-
// Check for cached MSAL v1 id token
|
|
12553
|
-
const msalIdTokenString = this.getTemporaryCache(PersistentCacheKeys.ID_TOKEN, true);
|
|
12554
|
-
if (msalIdTokenString) {
|
|
12555
|
-
this.browserStorage.removeItem(this.generateCacheKey(PersistentCacheKeys.ID_TOKEN));
|
|
12556
|
-
this.logger.verbose("Cached MSAL.js v1 id token retrieved");
|
|
12557
|
-
}
|
|
12558
|
-
const cachedIdTokenString = msalIdTokenString || adalIdTokenString;
|
|
12559
|
-
if (cachedIdTokenString) {
|
|
12560
|
-
const idTokenClaims = extractTokenClaims(cachedIdTokenString, base64Decode);
|
|
12561
|
-
if (idTokenClaims.preferred_username) {
|
|
12562
|
-
this.logger.verbose("No SSO params used and ADAL/MSAL v1 token retrieved, setting ADAL/MSAL v1 preferred_username as loginHint");
|
|
12563
|
-
return idTokenClaims.preferred_username;
|
|
12564
|
-
}
|
|
12565
|
-
else if (idTokenClaims.upn) {
|
|
12566
|
-
this.logger.verbose("No SSO params used and ADAL/MSAL v1 token retrieved, setting ADAL/MSAL v1 upn as loginHint");
|
|
12567
|
-
return idTokenClaims.upn;
|
|
12568
|
-
}
|
|
12569
|
-
else {
|
|
12570
|
-
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.");
|
|
12571
|
-
}
|
|
12572
|
-
}
|
|
12573
|
-
return null;
|
|
12574
|
-
}
|
|
12575
|
-
/**
|
|
12576
|
-
* Updates a credential's cache key if the current cache key is outdated
|
|
12577
|
-
*/
|
|
12578
|
-
updateCredentialCacheKey(currentCacheKey, credential) {
|
|
12579
|
-
const updatedCacheKey = generateCredentialKey(credential);
|
|
12580
|
-
if (currentCacheKey !== updatedCacheKey) {
|
|
12581
|
-
const cacheItem = this.getItem(currentCacheKey);
|
|
12582
|
-
if (cacheItem) {
|
|
12583
|
-
this.browserStorage.removeItem(currentCacheKey);
|
|
12584
|
-
this.setItem(updatedCacheKey, cacheItem);
|
|
12585
|
-
this.logger.verbose(`Updated an outdated ${credential.credentialType} cache key`);
|
|
12586
|
-
return updatedCacheKey;
|
|
12587
|
-
}
|
|
12588
|
-
else {
|
|
12589
|
-
this.logger.error(`Attempted to update an outdated ${credential.credentialType} cache key but no item matching the outdated key was found in storage`);
|
|
12590
|
-
}
|
|
12591
|
-
}
|
|
12592
|
-
return currentCacheKey;
|
|
12593
|
-
}
|
|
12594
12578
|
/**
|
|
12595
12579
|
* Builds credential entities from AuthenticationResult object and saves the resulting credentials to the cache
|
|
12596
12580
|
* @param result
|
|
@@ -13317,13 +13301,6 @@
|
|
|
13317
13301
|
this.logger.verbosePii(`Setting validated request account: ${account.homeAccountId}`, this.correlationId);
|
|
13318
13302
|
validatedRequest.account = account;
|
|
13319
13303
|
}
|
|
13320
|
-
// Check for ADAL/MSAL v1 SSO
|
|
13321
|
-
if (!validatedRequest.loginHint && !account) {
|
|
13322
|
-
const legacyLoginHint = this.browserStorage.getLegacyLoginHint();
|
|
13323
|
-
if (legacyLoginHint) {
|
|
13324
|
-
validatedRequest.loginHint = legacyLoginHint;
|
|
13325
|
-
}
|
|
13326
|
-
}
|
|
13327
13304
|
return validatedRequest;
|
|
13328
13305
|
}
|
|
13329
13306
|
}
|
|
@@ -13727,7 +13704,7 @@
|
|
|
13727
13704
|
// generate authenticationResult
|
|
13728
13705
|
const result = await this.generateAuthenticationResult(response, request, idTokenClaims, baseAccount, authority.canonicalAuthority, reqTimestamp);
|
|
13729
13706
|
// cache accounts and tokens in the appropriate storage
|
|
13730
|
-
this.cacheAccount(baseAccount);
|
|
13707
|
+
await this.cacheAccount(baseAccount);
|
|
13731
13708
|
this.cacheNativeTokens(response, request, homeAccountIdentifier, idTokenClaims, response.access_token, result.tenantId, reqTimestamp);
|
|
13732
13709
|
return result;
|
|
13733
13710
|
}
|
|
@@ -13852,9 +13829,9 @@
|
|
|
13852
13829
|
* cache the account entity in browser storage
|
|
13853
13830
|
* @param accountEntity
|
|
13854
13831
|
*/
|
|
13855
|
-
cacheAccount(accountEntity) {
|
|
13832
|
+
async cacheAccount(accountEntity) {
|
|
13856
13833
|
// Store the account info and hence `nativeAccountId` in browser cache
|
|
13857
|
-
this.browserStorage.setAccount(accountEntity);
|
|
13834
|
+
await this.browserStorage.setAccount(accountEntity);
|
|
13858
13835
|
// Remove any existing cached tokens for this account in browser storage
|
|
13859
13836
|
this.browserStorage.removeAccountContext(accountEntity).catch((e) => {
|
|
13860
13837
|
this.logger.error(`Error occurred while removing account context from browser storage. ${e}`);
|
|
@@ -15732,7 +15709,7 @@
|
|
|
15732
15709
|
* @param options
|
|
15733
15710
|
* @returns `AuthenticationResult` for the response that was loaded.
|
|
15734
15711
|
*/
|
|
15735
|
-
loadExternalTokens(request, response, options) {
|
|
15712
|
+
async loadExternalTokens(request, response, options) {
|
|
15736
15713
|
if (!this.isBrowserEnvironment) {
|
|
15737
15714
|
throw createBrowserAuthError(nonBrowserEnvironment);
|
|
15738
15715
|
}
|
|
@@ -15749,10 +15726,10 @@
|
|
|
15749
15726
|
const authority = request.authority
|
|
15750
15727
|
? new Authority(Authority.generateAuthority(request.authority, request.azureCloudOptions), this.config.system.networkClient, this.storage, authorityOptions, this.logger, request.correlationId || createNewGuid())
|
|
15751
15728
|
: undefined;
|
|
15752
|
-
const cacheRecordAccount = this.loadAccount(request, options.clientInfo || response.client_info || "", idTokenClaims, authority);
|
|
15753
|
-
const idToken = this.loadIdToken(response, cacheRecordAccount.homeAccountId, cacheRecordAccount.environment, cacheRecordAccount.realm);
|
|
15754
|
-
const accessToken = this.loadAccessToken(request, response, cacheRecordAccount.homeAccountId, cacheRecordAccount.environment, cacheRecordAccount.realm, options);
|
|
15755
|
-
const refreshToken = this.loadRefreshToken(response, cacheRecordAccount.homeAccountId, cacheRecordAccount.environment);
|
|
15729
|
+
const cacheRecordAccount = await this.loadAccount(request, options.clientInfo || response.client_info || "", idTokenClaims, authority);
|
|
15730
|
+
const idToken = await this.loadIdToken(response, cacheRecordAccount.homeAccountId, cacheRecordAccount.environment, cacheRecordAccount.realm);
|
|
15731
|
+
const accessToken = await this.loadAccessToken(request, response, cacheRecordAccount.homeAccountId, cacheRecordAccount.environment, cacheRecordAccount.realm, options);
|
|
15732
|
+
const refreshToken = await this.loadRefreshToken(response, cacheRecordAccount.homeAccountId, cacheRecordAccount.environment);
|
|
15756
15733
|
return this.generateAuthenticationResult(request, {
|
|
15757
15734
|
account: cacheRecordAccount,
|
|
15758
15735
|
idToken,
|
|
@@ -15769,11 +15746,11 @@
|
|
|
15769
15746
|
* @param requestHomeAccountId
|
|
15770
15747
|
* @returns `AccountEntity`
|
|
15771
15748
|
*/
|
|
15772
|
-
loadAccount(request, clientInfo, idTokenClaims, authority) {
|
|
15749
|
+
async loadAccount(request, clientInfo, idTokenClaims, authority) {
|
|
15773
15750
|
this.logger.verbose("TokenCache - loading account");
|
|
15774
15751
|
if (request.account) {
|
|
15775
15752
|
const accountEntity = AccountEntity.createFromAccountInfo(request.account);
|
|
15776
|
-
this.storage.setAccount(accountEntity);
|
|
15753
|
+
await this.storage.setAccount(accountEntity);
|
|
15777
15754
|
return accountEntity;
|
|
15778
15755
|
}
|
|
15779
15756
|
else if (!authority || (!clientInfo && !idTokenClaims)) {
|
|
@@ -15785,7 +15762,7 @@
|
|
|
15785
15762
|
const cachedAccount = buildAccountToCache(this.storage, authority, homeAccountId, base64Decode, idTokenClaims, clientInfo, authority.hostnameAndPort, claimsTenantId, undefined, // authCodePayload
|
|
15786
15763
|
undefined, // nativeAccountId
|
|
15787
15764
|
this.logger);
|
|
15788
|
-
this.storage.setAccount(cachedAccount);
|
|
15765
|
+
await this.storage.setAccount(cachedAccount);
|
|
15789
15766
|
return cachedAccount;
|
|
15790
15767
|
}
|
|
15791
15768
|
/**
|
|
@@ -15796,14 +15773,14 @@
|
|
|
15796
15773
|
* @param tenantId
|
|
15797
15774
|
* @returns `IdTokenEntity`
|
|
15798
15775
|
*/
|
|
15799
|
-
loadIdToken(response, homeAccountId, environment, tenantId) {
|
|
15776
|
+
async loadIdToken(response, homeAccountId, environment, tenantId) {
|
|
15800
15777
|
if (!response.id_token) {
|
|
15801
15778
|
this.logger.verbose("TokenCache - no id token found in response");
|
|
15802
15779
|
return null;
|
|
15803
15780
|
}
|
|
15804
15781
|
this.logger.verbose("TokenCache - loading id token");
|
|
15805
15782
|
const idTokenEntity = createIdTokenEntity(homeAccountId, environment, response.id_token, this.config.auth.clientId, tenantId);
|
|
15806
|
-
this.storage.setIdTokenCredential(idTokenEntity);
|
|
15783
|
+
await this.storage.setIdTokenCredential(idTokenEntity);
|
|
15807
15784
|
return idTokenEntity;
|
|
15808
15785
|
}
|
|
15809
15786
|
/**
|
|
@@ -15815,7 +15792,7 @@
|
|
|
15815
15792
|
* @param tenantId
|
|
15816
15793
|
* @returns `AccessTokenEntity`
|
|
15817
15794
|
*/
|
|
15818
|
-
loadAccessToken(request, response, homeAccountId, environment, tenantId, options) {
|
|
15795
|
+
async loadAccessToken(request, response, homeAccountId, environment, tenantId, options) {
|
|
15819
15796
|
if (!response.access_token) {
|
|
15820
15797
|
this.logger.verbose("TokenCache - no access token found in response");
|
|
15821
15798
|
return null;
|
|
@@ -15839,7 +15816,7 @@
|
|
|
15839
15816
|
(response.ext_expires_in || response.expires_in) +
|
|
15840
15817
|
new Date().getTime() / 1000;
|
|
15841
15818
|
const accessTokenEntity = createAccessTokenEntity(homeAccountId, environment, response.access_token, this.config.auth.clientId, tenantId, scopes.printScopes(), expiresOn, extendedExpiresOn, base64Decode);
|
|
15842
|
-
this.storage.setAccessTokenCredential(accessTokenEntity);
|
|
15819
|
+
await this.storage.setAccessTokenCredential(accessTokenEntity);
|
|
15843
15820
|
return accessTokenEntity;
|
|
15844
15821
|
}
|
|
15845
15822
|
/**
|
|
@@ -15850,7 +15827,7 @@
|
|
|
15850
15827
|
* @param environment
|
|
15851
15828
|
* @returns `RefreshTokenEntity`
|
|
15852
15829
|
*/
|
|
15853
|
-
loadRefreshToken(response, homeAccountId, environment) {
|
|
15830
|
+
async loadRefreshToken(response, homeAccountId, environment) {
|
|
15854
15831
|
if (!response.refresh_token) {
|
|
15855
15832
|
this.logger.verbose("TokenCache - no refresh token found in response");
|
|
15856
15833
|
return null;
|
|
@@ -15858,7 +15835,7 @@
|
|
|
15858
15835
|
this.logger.verbose("TokenCache - loading refresh token");
|
|
15859
15836
|
const refreshTokenEntity = createRefreshTokenEntity(homeAccountId, environment, response.refresh_token, this.config.auth.clientId, response.foci, undefined, // userAssertionHash
|
|
15860
15837
|
response.refresh_token_expires_in);
|
|
15861
|
-
this.storage.setRefreshTokenCredential(refreshTokenEntity);
|
|
15838
|
+
await this.storage.setRefreshTokenCredential(refreshTokenEntity);
|
|
15862
15839
|
return refreshTokenEntity;
|
|
15863
15840
|
}
|
|
15864
15841
|
/**
|
|
@@ -16107,6 +16084,7 @@
|
|
|
16107
16084
|
this.eventHandler.emitEvent(EventType.INITIALIZE_END);
|
|
16108
16085
|
return;
|
|
16109
16086
|
}
|
|
16087
|
+
await this.browserStorage.initialize();
|
|
16110
16088
|
const initCorrelationId = request?.correlationId || this.getRequestCorrelationId();
|
|
16111
16089
|
const allowNativeBroker = this.config.system.allowNativeBroker;
|
|
16112
16090
|
const initMeasurement = this.performanceClient.startMeasurement(PerformanceEvents.InitializeClientApplication, initCorrelationId);
|
|
@@ -16832,7 +16810,7 @@
|
|
|
16832
16810
|
this.logger.verbose("hydrateCache called");
|
|
16833
16811
|
// Account gets saved to browser storage regardless of native or not
|
|
16834
16812
|
const accountEntity = AccountEntity.createFromAccountInfo(result.account, result.cloudGraphHostName, result.msGraphHost);
|
|
16835
|
-
this.browserStorage.setAccount(accountEntity);
|
|
16813
|
+
await this.browserStorage.setAccount(accountEntity);
|
|
16836
16814
|
if (result.fromNativeBroker) {
|
|
16837
16815
|
this.logger.verbose("Response was from native broker, storing in-memory");
|
|
16838
16816
|
// Tokens from native broker are stored in-memory
|
|
@@ -17633,8 +17611,8 @@
|
|
|
17633
17611
|
* Specific implementation of initialize function for NestedAppAuthController
|
|
17634
17612
|
* @returns
|
|
17635
17613
|
*/
|
|
17636
|
-
initialize() {
|
|
17637
|
-
|
|
17614
|
+
async initialize() {
|
|
17615
|
+
await this.browserStorage.initialize();
|
|
17638
17616
|
return Promise.resolve();
|
|
17639
17617
|
}
|
|
17640
17618
|
/**
|
|
@@ -18060,7 +18038,7 @@
|
|
|
18060
18038
|
async hydrateCache(result, request) {
|
|
18061
18039
|
this.logger.verbose("hydrateCache called");
|
|
18062
18040
|
const accountEntity = AccountEntity.createFromAccountInfo(result.account, result.cloudGraphHostName, result.msGraphHost);
|
|
18063
|
-
this.browserStorage.setAccount(accountEntity);
|
|
18041
|
+
await this.browserStorage.setAccount(accountEntity);
|
|
18064
18042
|
return this.browserStorage.hydrateCache(result, request);
|
|
18065
18043
|
}
|
|
18066
18044
|
}
|
|
@@ -19218,42 +19196,6 @@
|
|
|
19218
19196
|
},
|
|
19219
19197
|
};
|
|
19220
19198
|
|
|
19221
|
-
/*
|
|
19222
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
19223
|
-
* Licensed under the MIT License.
|
|
19224
|
-
*/
|
|
19225
|
-
/**
|
|
19226
|
-
* @deprecated This class will be removed in a future major version
|
|
19227
|
-
*/
|
|
19228
|
-
class BrowserStorage {
|
|
19229
|
-
constructor(cacheLocation) {
|
|
19230
|
-
if (cacheLocation === BrowserCacheLocation.LocalStorage) {
|
|
19231
|
-
this.windowStorage = new LocalStorage();
|
|
19232
|
-
}
|
|
19233
|
-
else if (cacheLocation === BrowserCacheLocation.SessionStorage) {
|
|
19234
|
-
this.windowStorage = new SessionStorage();
|
|
19235
|
-
}
|
|
19236
|
-
else {
|
|
19237
|
-
throw createBrowserConfigurationAuthError(storageNotSupported);
|
|
19238
|
-
}
|
|
19239
|
-
}
|
|
19240
|
-
getItem(key) {
|
|
19241
|
-
return this.windowStorage.getItem(key);
|
|
19242
|
-
}
|
|
19243
|
-
setItem(key, value) {
|
|
19244
|
-
this.windowStorage.setItem(key, value);
|
|
19245
|
-
}
|
|
19246
|
-
removeItem(key) {
|
|
19247
|
-
this.windowStorage.removeItem(key);
|
|
19248
|
-
}
|
|
19249
|
-
getKeys() {
|
|
19250
|
-
return Object.keys(this.windowStorage);
|
|
19251
|
-
}
|
|
19252
|
-
containsKey(key) {
|
|
19253
|
-
return this.windowStorage.hasOwnProperty(key);
|
|
19254
|
-
}
|
|
19255
|
-
}
|
|
19256
|
-
|
|
19257
19199
|
/*
|
|
19258
19200
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
19259
19201
|
* Licensed under the MIT License.
|
|
@@ -19641,7 +19583,6 @@
|
|
|
19641
19583
|
exports.BrowserConfigurationAuthErrorMessage = BrowserConfigurationAuthErrorMessage;
|
|
19642
19584
|
exports.BrowserPerformanceClient = BrowserPerformanceClient;
|
|
19643
19585
|
exports.BrowserPerformanceMeasurement = BrowserPerformanceMeasurement;
|
|
19644
|
-
exports.BrowserStorage = BrowserStorage;
|
|
19645
19586
|
exports.BrowserUtils = BrowserUtils;
|
|
19646
19587
|
exports.CacheLookupPolicy = CacheLookupPolicy;
|
|
19647
19588
|
exports.ClientAuthError = ClientAuthError;
|