@azure/msal-browser 3.28.1 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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.d.ts +1 -1
- package/dist/broker/nativeBroker/NativeMessageHandler.d.ts.map +1 -1
- package/dist/broker/nativeBroker/NativeMessageHandler.mjs +8 -8
- package/dist/broker/nativeBroker/NativeMessageHandler.mjs.map +1 -1
- package/dist/broker/nativeBroker/NativeResponse.d.ts +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 +11 -51
- package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
- package/dist/cache/BrowserCacheManager.mjs +42 -291
- 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 +38 -1
- package/dist/cache/LocalStorage.d.ts.map +1 -1
- package/dist/cache/LocalStorage.mjs +183 -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 +16 -15
- package/dist/cache/TokenCache.mjs.map +1 -1
- package/dist/config/Configuration.d.ts +2 -2
- package/dist/config/Configuration.d.ts.map +1 -1
- package/dist/config/Configuration.mjs +5 -5
- package/dist/config/Configuration.mjs.map +1 -1
- package/dist/controllers/ControllerFactory.mjs +1 -1
- package/dist/controllers/NestedAppAuthController.d.ts +4 -3
- package/dist/controllers/NestedAppAuthController.d.ts.map +1 -1
- package/dist/controllers/NestedAppAuthController.mjs +8 -6
- package/dist/controllers/NestedAppAuthController.mjs.map +1 -1
- package/dist/controllers/StandardController.d.ts +2 -2
- package/dist/controllers/StandardController.d.ts.map +1 -1
- package/dist/controllers/StandardController.mjs +27 -22
- package/dist/controllers/StandardController.mjs.map +1 -1
- package/dist/controllers/UnknownOperatingContextController.d.ts +2 -2
- package/dist/controllers/UnknownOperatingContextController.d.ts.map +1 -1
- package/dist/controllers/UnknownOperatingContextController.mjs +3 -3
- package/dist/controllers/UnknownOperatingContextController.mjs.map +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/NativeAuthError.mjs.map +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 +2 -2
- package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
- package/dist/interaction_client/NativeInteractionClient.mjs +6 -6
- package/dist/interaction_client/NativeInteractionClient.mjs.map +1 -1
- package/dist/interaction_client/PopupClient.d.ts.map +1 -1
- package/dist/interaction_client/PopupClient.mjs +4 -4
- package/dist/interaction_client/PopupClient.mjs.map +1 -1
- package/dist/interaction_client/RedirectClient.mjs +2 -2
- package/dist/interaction_client/RedirectClient.mjs.map +1 -1
- package/dist/interaction_client/SilentAuthCodeClient.mjs +1 -1
- package/dist/interaction_client/SilentCacheClient.mjs +1 -1
- package/dist/interaction_client/SilentIframeClient.mjs +2 -2
- package/dist/interaction_client/SilentIframeClient.mjs.map +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/AuthorizationUrlRequest.d.ts +1 -1
- package/dist/request/AuthorizationUrlRequest.d.ts.map +1 -1
- package/dist/request/PopupRequest.d.ts +1 -1
- package/dist/request/PopupRequest.d.ts.map +1 -1
- package/dist/request/RedirectRequest.d.ts +1 -1
- package/dist/request/RedirectRequest.d.ts.map +1 -1
- package/dist/request/RequestHelpers.mjs +1 -1
- package/dist/request/SsoSilentRequest.d.ts +1 -1
- package/dist/request/SsoSilentRequest.d.ts.map +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 +630 -650
- package/lib/msal-browser.cjs.map +1 -1
- package/lib/msal-browser.js +630 -650
- package/lib/msal-browser.js.map +1 -1
- package/lib/msal-browser.min.js +65 -66
- package/lib/types/broker/nativeBroker/NativeMessageHandler.d.ts +1 -1
- package/lib/types/broker/nativeBroker/NativeMessageHandler.d.ts.map +1 -1
- package/lib/types/broker/nativeBroker/NativeResponse.d.ts +1 -1
- package/lib/types/cache/BrowserCacheManager.d.ts +11 -51
- 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 +38 -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/config/Configuration.d.ts +2 -2
- package/lib/types/config/Configuration.d.ts.map +1 -1
- package/lib/types/controllers/NestedAppAuthController.d.ts +4 -3
- package/lib/types/controllers/NestedAppAuthController.d.ts.map +1 -1
- package/lib/types/controllers/StandardController.d.ts +2 -2
- package/lib/types/controllers/StandardController.d.ts.map +1 -1
- package/lib/types/controllers/UnknownOperatingContextController.d.ts +2 -2
- package/lib/types/controllers/UnknownOperatingContextController.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 +2 -2
- package/lib/types/interaction_client/NativeInteractionClient.d.ts.map +1 -1
- package/lib/types/interaction_client/PopupClient.d.ts.map +1 -1
- package/lib/types/interaction_client/StandardInteractionClient.d.ts.map +1 -1
- package/lib/types/packageMetadata.d.ts +1 -1
- package/lib/types/packageMetadata.d.ts.map +1 -1
- package/lib/types/request/AuthorizationUrlRequest.d.ts +1 -1
- package/lib/types/request/AuthorizationUrlRequest.d.ts.map +1 -1
- package/lib/types/request/PopupRequest.d.ts +1 -1
- package/lib/types/request/PopupRequest.d.ts.map +1 -1
- package/lib/types/request/RedirectRequest.d.ts +1 -1
- package/lib/types/request/RedirectRequest.d.ts.map +1 -1
- package/lib/types/request/SsoSilentRequest.d.ts +1 -1
- package/lib/types/request/SsoSilentRequest.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/broker/nativeBroker/NativeMessageHandler.ts +7 -7
- package/src/broker/nativeBroker/NativeResponse.ts +1 -1
- package/src/cache/BrowserCacheManager.ts +95 -422
- 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 +330 -1
- package/src/cache/MemoryStorage.ts +12 -0
- package/src/cache/SessionStorage.ts +12 -0
- package/src/cache/TokenCache.ts +42 -25
- package/src/config/Configuration.ts +6 -6
- package/src/controllers/NestedAppAuthController.ts +14 -6
- package/src/controllers/StandardController.ts +41 -22
- package/src/controllers/UnknownOperatingContextController.ts +6 -5
- 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 +7 -6
- package/src/interaction_client/PopupClient.ts +9 -8
- package/src/interaction_client/RedirectClient.ts +1 -1
- package/src/interaction_client/SilentIframeClient.ts +1 -1
- package/src/interaction_client/StandardInteractionClient.ts +0 -8
- package/src/packageMetadata.ts +1 -1
- package/src/request/AuthorizationUrlRequest.ts +1 -1
- package/src/request/PopupRequest.ts +1 -1
- package/src/request/RedirectRequest.ts +1 -1
- package/src/request/SsoSilentRequest.ts +1 -1
- package/dist/cache/BrowserStorage.d.ts +0 -14
- package/dist/cache/BrowserStorage.d.ts.map +0 -1
- package/dist/cache/BrowserStorage.mjs +0 -46
- package/dist/cache/BrowserStorage.mjs.map +0 -1
- package/lib/types/cache/BrowserStorage.d.ts +0 -14
- package/lib/types/cache/BrowserStorage.d.ts.map +0 -1
- package/src/cache/BrowserStorage.ts +0 -52
package/lib/msal-browser.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/*! @azure/msal-browser
|
|
1
|
+
/*! @azure/msal-browser v4.0.1 2025-01-15 */
|
|
2
2
|
'use strict';
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
|
-
/*! @azure/msal-common
|
|
5
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
6
6
|
/*
|
|
7
7
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
8
8
|
* Licensed under the MIT License.
|
|
@@ -109,12 +109,6 @@ const HeaderNames = {
|
|
|
109
109
|
* Persistent cache keys MSAL which stay while user is logged in.
|
|
110
110
|
*/
|
|
111
111
|
const PersistentCacheKeys = {
|
|
112
|
-
ID_TOKEN: "idtoken",
|
|
113
|
-
CLIENT_INFO: "client.info",
|
|
114
|
-
ADAL_ID_TOKEN: "adal.idtoken",
|
|
115
|
-
ERROR: "error",
|
|
116
|
-
ERROR_DESC: "error.description",
|
|
117
|
-
ACTIVE_ACCOUNT: "active-account",
|
|
118
112
|
ACTIVE_ACCOUNT_FILTERS: "active-account-filters", // new cache entry for active_account for a more robust version for browser
|
|
119
113
|
};
|
|
120
114
|
/**
|
|
@@ -312,7 +306,7 @@ const JsonWebTokenTypes = {
|
|
|
312
306
|
// Token renewal offset default in seconds
|
|
313
307
|
const DEFAULT_TOKEN_RENEWAL_OFFSET_SEC = 300;
|
|
314
308
|
|
|
315
|
-
/*! @azure/msal-common
|
|
309
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
316
310
|
/*
|
|
317
311
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
318
312
|
* Licensed under the MIT License.
|
|
@@ -329,7 +323,7 @@ var AuthErrorCodes = /*#__PURE__*/Object.freeze({
|
|
|
329
323
|
unexpectedError: unexpectedError
|
|
330
324
|
});
|
|
331
325
|
|
|
332
|
-
/*! @azure/msal-common
|
|
326
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
333
327
|
|
|
334
328
|
/*
|
|
335
329
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -378,7 +372,7 @@ function createAuthError(code, additionalMessage) {
|
|
|
378
372
|
: AuthErrorMessages[code]);
|
|
379
373
|
}
|
|
380
374
|
|
|
381
|
-
/*! @azure/msal-common
|
|
375
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
382
376
|
/*
|
|
383
377
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
384
378
|
* Licensed under the MIT License.
|
|
@@ -476,7 +470,7 @@ var ClientAuthErrorCodes = /*#__PURE__*/Object.freeze({
|
|
|
476
470
|
userTimeoutReached: userTimeoutReached
|
|
477
471
|
});
|
|
478
472
|
|
|
479
|
-
/*! @azure/msal-common
|
|
473
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
480
474
|
|
|
481
475
|
/*
|
|
482
476
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -728,7 +722,7 @@ function createClientAuthError(errorCode, additionalMessage) {
|
|
|
728
722
|
return new ClientAuthError(errorCode, additionalMessage);
|
|
729
723
|
}
|
|
730
724
|
|
|
731
|
-
/*! @azure/msal-common
|
|
725
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
732
726
|
|
|
733
727
|
/*
|
|
734
728
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -767,7 +761,7 @@ const DEFAULT_CRYPTO_IMPLEMENTATION = {
|
|
|
767
761
|
},
|
|
768
762
|
};
|
|
769
763
|
|
|
770
|
-
/*! @azure/msal-common
|
|
764
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
771
765
|
|
|
772
766
|
/*
|
|
773
767
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -958,12 +952,12 @@ class Logger {
|
|
|
958
952
|
}
|
|
959
953
|
}
|
|
960
954
|
|
|
961
|
-
/*! @azure/msal-common
|
|
955
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
962
956
|
/* eslint-disable header/header */
|
|
963
957
|
const name$1 = "@azure/msal-common";
|
|
964
|
-
const version$1 = "
|
|
958
|
+
const version$1 = "15.0.1";
|
|
965
959
|
|
|
966
|
-
/*! @azure/msal-common
|
|
960
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
967
961
|
/*
|
|
968
962
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
969
963
|
* Licensed under the MIT License.
|
|
@@ -983,7 +977,7 @@ const AzureCloudInstance = {
|
|
|
983
977
|
AzureUsGovernment: "https://login.microsoftonline.us",
|
|
984
978
|
};
|
|
985
979
|
|
|
986
|
-
/*! @azure/msal-common
|
|
980
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
987
981
|
|
|
988
982
|
/*
|
|
989
983
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1044,7 +1038,7 @@ function checkMaxAge(authTime, maxAge) {
|
|
|
1044
1038
|
}
|
|
1045
1039
|
}
|
|
1046
1040
|
|
|
1047
|
-
/*! @azure/msal-common
|
|
1041
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
1048
1042
|
/*
|
|
1049
1043
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1050
1044
|
* Licensed under the MIT License.
|
|
@@ -1081,7 +1075,7 @@ function wasClockTurnedBack(cachedAt) {
|
|
|
1081
1075
|
return cachedAtSec > nowSeconds();
|
|
1082
1076
|
}
|
|
1083
1077
|
|
|
1084
|
-
/*! @azure/msal-common
|
|
1078
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
1085
1079
|
|
|
1086
1080
|
/*
|
|
1087
1081
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1408,7 +1402,7 @@ function isAuthorityMetadataExpired(metadata) {
|
|
|
1408
1402
|
return metadata.expiresAt <= nowSeconds();
|
|
1409
1403
|
}
|
|
1410
1404
|
|
|
1411
|
-
/*! @azure/msal-common
|
|
1405
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
1412
1406
|
/*
|
|
1413
1407
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1414
1408
|
* Licensed under the MIT License.
|
|
@@ -1433,14 +1427,14 @@ const missingSshKid = "missing_ssh_kid";
|
|
|
1433
1427
|
const missingNonceAuthenticationHeader = "missing_nonce_authentication_header";
|
|
1434
1428
|
const invalidAuthenticationHeader = "invalid_authentication_header";
|
|
1435
1429
|
const cannotSetOIDCOptions = "cannot_set_OIDCOptions";
|
|
1436
|
-
const
|
|
1430
|
+
const cannotAllowPlatformBroker = "cannot_allow_platform_broker";
|
|
1437
1431
|
const authorityMismatch = "authority_mismatch";
|
|
1438
1432
|
|
|
1439
1433
|
var ClientConfigurationErrorCodes = /*#__PURE__*/Object.freeze({
|
|
1440
1434
|
__proto__: null,
|
|
1441
1435
|
authorityMismatch: authorityMismatch,
|
|
1442
1436
|
authorityUriInsecure: authorityUriInsecure,
|
|
1443
|
-
|
|
1437
|
+
cannotAllowPlatformBroker: cannotAllowPlatformBroker,
|
|
1444
1438
|
cannotSetOIDCOptions: cannotSetOIDCOptions,
|
|
1445
1439
|
claimsRequestParsingError: claimsRequestParsingError,
|
|
1446
1440
|
emptyInputScopesError: emptyInputScopesError,
|
|
@@ -1462,7 +1456,7 @@ var ClientConfigurationErrorCodes = /*#__PURE__*/Object.freeze({
|
|
|
1462
1456
|
urlParseError: urlParseError
|
|
1463
1457
|
});
|
|
1464
1458
|
|
|
1465
|
-
/*! @azure/msal-common
|
|
1459
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
1466
1460
|
|
|
1467
1461
|
/*
|
|
1468
1462
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1489,7 +1483,7 @@ const ClientConfigurationErrorMessages = {
|
|
|
1489
1483
|
[missingNonceAuthenticationHeader]: "Unable to find an authentication header containing server nonce. Either the Authentication-Info or WWW-Authenticate headers must be present in order to obtain a server nonce.",
|
|
1490
1484
|
[invalidAuthenticationHeader]: "Invalid authentication header provided",
|
|
1491
1485
|
[cannotSetOIDCOptions]: "Cannot set OIDCOptions parameter. Please change the protocol mode to OIDC or use a non-Microsoft authority.",
|
|
1492
|
-
[
|
|
1486
|
+
[cannotAllowPlatformBroker]: "Cannot set allowPlatformBroker parameter to true when not in AAD protocol mode.",
|
|
1493
1487
|
[authorityMismatch]: "Authority mismatch error. Authority provided in login request or PublicClientApplication config does not match the environment of the provided account. Please use a matching account or make an interactive request to login to this authority.",
|
|
1494
1488
|
};
|
|
1495
1489
|
/**
|
|
@@ -1577,9 +1571,9 @@ const ClientConfigurationErrorMessage = {
|
|
|
1577
1571
|
code: cannotSetOIDCOptions,
|
|
1578
1572
|
desc: ClientConfigurationErrorMessages[cannotSetOIDCOptions],
|
|
1579
1573
|
},
|
|
1580
|
-
|
|
1581
|
-
code:
|
|
1582
|
-
desc: ClientConfigurationErrorMessages[
|
|
1574
|
+
cannotAllowPlatformBroker: {
|
|
1575
|
+
code: cannotAllowPlatformBroker,
|
|
1576
|
+
desc: ClientConfigurationErrorMessages[cannotAllowPlatformBroker],
|
|
1583
1577
|
},
|
|
1584
1578
|
authorityMismatch: {
|
|
1585
1579
|
code: authorityMismatch,
|
|
@@ -1600,7 +1594,7 @@ function createClientConfigurationError(errorCode) {
|
|
|
1600
1594
|
return new ClientConfigurationError(errorCode);
|
|
1601
1595
|
}
|
|
1602
1596
|
|
|
1603
|
-
/*! @azure/msal-common
|
|
1597
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
1604
1598
|
/*
|
|
1605
1599
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1606
1600
|
* Licensed under the MIT License.
|
|
@@ -1697,7 +1691,7 @@ class StringUtils {
|
|
|
1697
1691
|
}
|
|
1698
1692
|
}
|
|
1699
1693
|
|
|
1700
|
-
/*! @azure/msal-common
|
|
1694
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
1701
1695
|
|
|
1702
1696
|
/*
|
|
1703
1697
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1897,7 +1891,7 @@ class ScopeSet {
|
|
|
1897
1891
|
}
|
|
1898
1892
|
}
|
|
1899
1893
|
|
|
1900
|
-
/*! @azure/msal-common
|
|
1894
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
1901
1895
|
|
|
1902
1896
|
/*
|
|
1903
1897
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1937,7 +1931,7 @@ function buildClientInfoFromHomeAccountId(homeAccountId) {
|
|
|
1937
1931
|
};
|
|
1938
1932
|
}
|
|
1939
1933
|
|
|
1940
|
-
/*! @azure/msal-common
|
|
1934
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
1941
1935
|
/*
|
|
1942
1936
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1943
1937
|
* Licensed under the MIT License.
|
|
@@ -2016,7 +2010,7 @@ function updateAccountTenantProfileData(baseAccountInfo, tenantProfile, idTokenC
|
|
|
2016
2010
|
return updatedAccountInfo;
|
|
2017
2011
|
}
|
|
2018
2012
|
|
|
2019
|
-
/*! @azure/msal-common
|
|
2013
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
2020
2014
|
/*
|
|
2021
2015
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2022
2016
|
* Licensed under the MIT License.
|
|
@@ -2031,7 +2025,7 @@ const AuthorityType = {
|
|
|
2031
2025
|
Ciam: 3,
|
|
2032
2026
|
};
|
|
2033
2027
|
|
|
2034
|
-
/*! @azure/msal-common
|
|
2028
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
2035
2029
|
/*
|
|
2036
2030
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2037
2031
|
* Licensed under the MIT License.
|
|
@@ -2053,7 +2047,7 @@ function getTenantIdFromIdTokenClaims(idTokenClaims) {
|
|
|
2053
2047
|
return null;
|
|
2054
2048
|
}
|
|
2055
2049
|
|
|
2056
|
-
/*! @azure/msal-common
|
|
2050
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
2057
2051
|
/*
|
|
2058
2052
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2059
2053
|
* Licensed under the MIT License.
|
|
@@ -2066,7 +2060,7 @@ const ProtocolMode = {
|
|
|
2066
2060
|
OIDC: "OIDC",
|
|
2067
2061
|
};
|
|
2068
2062
|
|
|
2069
|
-
/*! @azure/msal-common
|
|
2063
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
2070
2064
|
|
|
2071
2065
|
/*
|
|
2072
2066
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2309,7 +2303,7 @@ class AccountEntity {
|
|
|
2309
2303
|
}
|
|
2310
2304
|
}
|
|
2311
2305
|
|
|
2312
|
-
/*! @azure/msal-common
|
|
2306
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
2313
2307
|
|
|
2314
2308
|
/*
|
|
2315
2309
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2356,7 +2350,7 @@ function getDeserializedResponse(responseString) {
|
|
|
2356
2350
|
return null;
|
|
2357
2351
|
}
|
|
2358
2352
|
|
|
2359
|
-
/*! @azure/msal-common
|
|
2353
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
2360
2354
|
|
|
2361
2355
|
/*
|
|
2362
2356
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2520,7 +2514,7 @@ class UrlString {
|
|
|
2520
2514
|
}
|
|
2521
2515
|
}
|
|
2522
2516
|
|
|
2523
|
-
/*! @azure/msal-common
|
|
2517
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
2524
2518
|
|
|
2525
2519
|
/*
|
|
2526
2520
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2660,7 +2654,7 @@ function getCloudDiscoveryMetadataFromNetworkResponse(response, authorityHost) {
|
|
|
2660
2654
|
return null;
|
|
2661
2655
|
}
|
|
2662
2656
|
|
|
2663
|
-
/*! @azure/msal-common
|
|
2657
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
2664
2658
|
/*
|
|
2665
2659
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2666
2660
|
* Licensed under the MIT License.
|
|
@@ -2668,7 +2662,7 @@ function getCloudDiscoveryMetadataFromNetworkResponse(response, authorityHost) {
|
|
|
2668
2662
|
const cacheQuotaExceededErrorCode = "cache_quota_exceeded";
|
|
2669
2663
|
const cacheUnknownErrorCode = "cache_error_unknown";
|
|
2670
2664
|
|
|
2671
|
-
/*! @azure/msal-common
|
|
2665
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
2672
2666
|
|
|
2673
2667
|
/*
|
|
2674
2668
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2695,7 +2689,7 @@ class CacheError extends Error {
|
|
|
2695
2689
|
}
|
|
2696
2690
|
}
|
|
2697
2691
|
|
|
2698
|
-
/*! @azure/msal-common
|
|
2692
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
2699
2693
|
|
|
2700
2694
|
/*
|
|
2701
2695
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2860,24 +2854,24 @@ class CacheManager {
|
|
|
2860
2854
|
* @param storeInCache {?StoreInCache}
|
|
2861
2855
|
* @param correlationId {?string} correlation id
|
|
2862
2856
|
*/
|
|
2863
|
-
async saveCacheRecord(cacheRecord,
|
|
2857
|
+
async saveCacheRecord(cacheRecord, correlationId, storeInCache) {
|
|
2864
2858
|
if (!cacheRecord) {
|
|
2865
2859
|
throw createClientAuthError(invalidCacheRecord);
|
|
2866
2860
|
}
|
|
2867
2861
|
try {
|
|
2868
2862
|
if (!!cacheRecord.account) {
|
|
2869
|
-
this.setAccount(cacheRecord.account);
|
|
2863
|
+
await this.setAccount(cacheRecord.account, correlationId);
|
|
2870
2864
|
}
|
|
2871
2865
|
if (!!cacheRecord.idToken && storeInCache?.idToken !== false) {
|
|
2872
|
-
this.setIdTokenCredential(cacheRecord.idToken);
|
|
2866
|
+
await this.setIdTokenCredential(cacheRecord.idToken, correlationId);
|
|
2873
2867
|
}
|
|
2874
2868
|
if (!!cacheRecord.accessToken &&
|
|
2875
2869
|
storeInCache?.accessToken !== false) {
|
|
2876
|
-
await this.saveAccessToken(cacheRecord.accessToken);
|
|
2870
|
+
await this.saveAccessToken(cacheRecord.accessToken, correlationId);
|
|
2877
2871
|
}
|
|
2878
2872
|
if (!!cacheRecord.refreshToken &&
|
|
2879
2873
|
storeInCache?.refreshToken !== false) {
|
|
2880
|
-
this.setRefreshTokenCredential(cacheRecord.refreshToken);
|
|
2874
|
+
await this.setRefreshTokenCredential(cacheRecord.refreshToken, correlationId);
|
|
2881
2875
|
}
|
|
2882
2876
|
if (!!cacheRecord.appMetadata) {
|
|
2883
2877
|
this.setAppMetadata(cacheRecord.appMetadata);
|
|
@@ -2907,7 +2901,7 @@ class CacheManager {
|
|
|
2907
2901
|
* saves access token credential
|
|
2908
2902
|
* @param credential
|
|
2909
2903
|
*/
|
|
2910
|
-
async saveAccessToken(credential) {
|
|
2904
|
+
async saveAccessToken(credential, correlationId) {
|
|
2911
2905
|
const accessTokenFilter = {
|
|
2912
2906
|
clientId: credential.clientId,
|
|
2913
2907
|
credentialType: credential.credentialType,
|
|
@@ -2934,7 +2928,7 @@ class CacheManager {
|
|
|
2934
2928
|
}
|
|
2935
2929
|
});
|
|
2936
2930
|
await Promise.all(removedAccessTokens);
|
|
2937
|
-
this.setAccessTokenCredential(credential);
|
|
2931
|
+
await this.setAccessTokenCredential(credential, correlationId);
|
|
2938
2932
|
}
|
|
2939
2933
|
/**
|
|
2940
2934
|
* Retrieve account entities matching all provided tenant-agnostic filters; if no filter is set, get all account entities in the cache
|
|
@@ -3220,61 +3214,6 @@ class CacheManager {
|
|
|
3220
3214
|
});
|
|
3221
3215
|
await Promise.all(removedCredentials);
|
|
3222
3216
|
}
|
|
3223
|
-
/**
|
|
3224
|
-
* Migrates a single-tenant account and all it's associated alternate cross-tenant account objects in the
|
|
3225
|
-
* cache into a condensed multi-tenant account object with tenant profiles.
|
|
3226
|
-
* @param accountKey
|
|
3227
|
-
* @param accountEntity
|
|
3228
|
-
* @param logger
|
|
3229
|
-
* @returns
|
|
3230
|
-
*/
|
|
3231
|
-
updateOutdatedCachedAccount(accountKey, accountEntity, logger) {
|
|
3232
|
-
// Only update if account entity is defined and has no tenantProfiles object (is outdated)
|
|
3233
|
-
if (accountEntity && accountEntity.isSingleTenant()) {
|
|
3234
|
-
this.commonLogger?.verbose("updateOutdatedCachedAccount: Found a single-tenant (outdated) account entity in the cache, migrating to multi-tenant account entity");
|
|
3235
|
-
// Get keys of all accounts belonging to user
|
|
3236
|
-
const matchingAccountKeys = this.getAccountKeys().filter((key) => {
|
|
3237
|
-
return key.startsWith(accountEntity.homeAccountId);
|
|
3238
|
-
});
|
|
3239
|
-
// Get all account entities belonging to user
|
|
3240
|
-
const accountsToMerge = [];
|
|
3241
|
-
matchingAccountKeys.forEach((key) => {
|
|
3242
|
-
const account = this.getCachedAccountEntity(key);
|
|
3243
|
-
if (account) {
|
|
3244
|
-
accountsToMerge.push(account);
|
|
3245
|
-
}
|
|
3246
|
-
});
|
|
3247
|
-
// Set base account to home account if available, any account if not
|
|
3248
|
-
const baseAccount = accountsToMerge.find((account) => {
|
|
3249
|
-
return tenantIdMatchesHomeTenant(account.realm, account.homeAccountId);
|
|
3250
|
-
}) || accountsToMerge[0];
|
|
3251
|
-
// Populate tenant profiles built from each account entity belonging to the user
|
|
3252
|
-
baseAccount.tenantProfiles = accountsToMerge.map((account) => {
|
|
3253
|
-
return {
|
|
3254
|
-
tenantId: account.realm,
|
|
3255
|
-
localAccountId: account.localAccountId,
|
|
3256
|
-
name: account.name,
|
|
3257
|
-
isHomeTenant: tenantIdMatchesHomeTenant(account.realm, account.homeAccountId),
|
|
3258
|
-
};
|
|
3259
|
-
});
|
|
3260
|
-
const updatedAccount = CacheManager.toObject(new AccountEntity(), {
|
|
3261
|
-
...baseAccount,
|
|
3262
|
-
});
|
|
3263
|
-
const newAccountKey = updatedAccount.generateAccountKey();
|
|
3264
|
-
// Clear cache of legacy account objects that have been collpsed into tenant profiles
|
|
3265
|
-
matchingAccountKeys.forEach((key) => {
|
|
3266
|
-
if (key !== newAccountKey) {
|
|
3267
|
-
this.removeOutdatedAccount(accountKey);
|
|
3268
|
-
}
|
|
3269
|
-
});
|
|
3270
|
-
// Cache updated account object
|
|
3271
|
-
this.setAccount(updatedAccount);
|
|
3272
|
-
logger?.verbose("Updated an outdated account entity in the cache");
|
|
3273
|
-
return updatedAccount;
|
|
3274
|
-
}
|
|
3275
|
-
// No update is necessary
|
|
3276
|
-
return accountEntity;
|
|
3277
|
-
}
|
|
3278
3217
|
/**
|
|
3279
3218
|
* returns a boolean if the given credential is removed
|
|
3280
3219
|
* @param credential
|
|
@@ -3870,28 +3809,25 @@ class CacheManager {
|
|
|
3870
3809
|
}
|
|
3871
3810
|
/** @internal */
|
|
3872
3811
|
class DefaultStorageClass extends CacheManager {
|
|
3873
|
-
setAccount() {
|
|
3812
|
+
async setAccount() {
|
|
3874
3813
|
throw createClientAuthError(methodNotImplemented);
|
|
3875
3814
|
}
|
|
3876
3815
|
getAccount() {
|
|
3877
3816
|
throw createClientAuthError(methodNotImplemented);
|
|
3878
3817
|
}
|
|
3879
|
-
|
|
3880
|
-
throw createClientAuthError(methodNotImplemented);
|
|
3881
|
-
}
|
|
3882
|
-
setIdTokenCredential() {
|
|
3818
|
+
async setIdTokenCredential() {
|
|
3883
3819
|
throw createClientAuthError(methodNotImplemented);
|
|
3884
3820
|
}
|
|
3885
3821
|
getIdTokenCredential() {
|
|
3886
3822
|
throw createClientAuthError(methodNotImplemented);
|
|
3887
3823
|
}
|
|
3888
|
-
setAccessTokenCredential() {
|
|
3824
|
+
async setAccessTokenCredential() {
|
|
3889
3825
|
throw createClientAuthError(methodNotImplemented);
|
|
3890
3826
|
}
|
|
3891
3827
|
getAccessTokenCredential() {
|
|
3892
3828
|
throw createClientAuthError(methodNotImplemented);
|
|
3893
3829
|
}
|
|
3894
|
-
setRefreshTokenCredential() {
|
|
3830
|
+
async setRefreshTokenCredential() {
|
|
3895
3831
|
throw createClientAuthError(methodNotImplemented);
|
|
3896
3832
|
}
|
|
3897
3833
|
getRefreshTokenCredential() {
|
|
@@ -3936,15 +3872,9 @@ class DefaultStorageClass extends CacheManager {
|
|
|
3936
3872
|
getTokenKeys() {
|
|
3937
3873
|
throw createClientAuthError(methodNotImplemented);
|
|
3938
3874
|
}
|
|
3939
|
-
updateCredentialCacheKey() {
|
|
3940
|
-
throw createClientAuthError(methodNotImplemented);
|
|
3941
|
-
}
|
|
3942
|
-
removeOutdatedAccount() {
|
|
3943
|
-
throw createClientAuthError(methodNotImplemented);
|
|
3944
|
-
}
|
|
3945
3875
|
}
|
|
3946
3876
|
|
|
3947
|
-
/*! @azure/msal-common
|
|
3877
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
3948
3878
|
|
|
3949
3879
|
/*
|
|
3950
3880
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4043,7 +3973,7 @@ function isOidcProtocolMode(config) {
|
|
|
4043
3973
|
return (config.authOptions.authority.options.protocolMode === ProtocolMode.OIDC);
|
|
4044
3974
|
}
|
|
4045
3975
|
|
|
4046
|
-
/*! @azure/msal-common
|
|
3976
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
4047
3977
|
/*
|
|
4048
3978
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4049
3979
|
* Licensed under the MIT License.
|
|
@@ -4053,7 +3983,7 @@ const CcsCredentialType = {
|
|
|
4053
3983
|
UPN: "UPN",
|
|
4054
3984
|
};
|
|
4055
3985
|
|
|
4056
|
-
/*! @azure/msal-common
|
|
3986
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
4057
3987
|
/*
|
|
4058
3988
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4059
3989
|
* Licensed under the MIT License.
|
|
@@ -4103,7 +4033,7 @@ const X_CLIENT_EXTRA_SKU = "x-client-xtra-sku";
|
|
|
4103
4033
|
const BROKER_CLIENT_ID = "brk_client_id";
|
|
4104
4034
|
const BROKER_REDIRECT_URI = "brk_redirect_uri";
|
|
4105
4035
|
|
|
4106
|
-
/*! @azure/msal-common
|
|
4036
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
4107
4037
|
|
|
4108
4038
|
/*
|
|
4109
4039
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4170,7 +4100,7 @@ class RequestValidator {
|
|
|
4170
4100
|
}
|
|
4171
4101
|
}
|
|
4172
4102
|
|
|
4173
|
-
/*! @azure/msal-common
|
|
4103
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
4174
4104
|
|
|
4175
4105
|
/*
|
|
4176
4106
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4578,7 +4508,7 @@ class RequestParameterBuilder {
|
|
|
4578
4508
|
}
|
|
4579
4509
|
}
|
|
4580
4510
|
|
|
4581
|
-
/*! @azure/msal-common
|
|
4511
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
4582
4512
|
/*
|
|
4583
4513
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4584
4514
|
* Licensed under the MIT License.
|
|
@@ -4590,7 +4520,7 @@ function isOpenIdConfigResponse(response) {
|
|
|
4590
4520
|
response.hasOwnProperty("jwks_uri"));
|
|
4591
4521
|
}
|
|
4592
4522
|
|
|
4593
|
-
/*! @azure/msal-common
|
|
4523
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
4594
4524
|
/*
|
|
4595
4525
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4596
4526
|
* Licensed under the MIT License.
|
|
@@ -4600,7 +4530,7 @@ function isCloudInstanceDiscoveryResponse(response) {
|
|
|
4600
4530
|
response.hasOwnProperty("metadata"));
|
|
4601
4531
|
}
|
|
4602
4532
|
|
|
4603
|
-
/*! @azure/msal-common
|
|
4533
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
4604
4534
|
/*
|
|
4605
4535
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4606
4536
|
* Licensed under the MIT License.
|
|
@@ -4610,7 +4540,7 @@ function isCloudInstanceDiscoveryErrorResponse(response) {
|
|
|
4610
4540
|
response.hasOwnProperty("error_description"));
|
|
4611
4541
|
}
|
|
4612
4542
|
|
|
4613
|
-
/*! @azure/msal-common
|
|
4543
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
4614
4544
|
/*
|
|
4615
4545
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4616
4546
|
* Licensed under the MIT License.
|
|
@@ -4768,6 +4698,7 @@ const PerformanceEvents = {
|
|
|
4768
4698
|
*/
|
|
4769
4699
|
InitializeSilentRequest: "initializeSilentRequest",
|
|
4770
4700
|
InitializeClientApplication: "initializeClientApplication",
|
|
4701
|
+
InitializeCache: "initializeCache",
|
|
4771
4702
|
/**
|
|
4772
4703
|
* Helper function in SilentIframeClient class (msal-browser).
|
|
4773
4704
|
*/
|
|
@@ -4845,6 +4776,8 @@ const PerformanceEvents = {
|
|
|
4845
4776
|
*/
|
|
4846
4777
|
ClearTokensAndKeysWithClaims: "clearTokensAndKeysWithClaims",
|
|
4847
4778
|
CacheManagerGetRefreshToken: "cacheManagerGetRefreshToken",
|
|
4779
|
+
ImportExistingCache: "importExistingCache",
|
|
4780
|
+
SetUserData: "setUserData",
|
|
4848
4781
|
/**
|
|
4849
4782
|
* Crypto Operations
|
|
4850
4783
|
*/
|
|
@@ -4853,6 +4786,12 @@ const PerformanceEvents = {
|
|
|
4853
4786
|
GenerateCodeChallengeFromVerifier: "generateCodeChallengeFromVerifier",
|
|
4854
4787
|
Sha256Digest: "sha256Digest",
|
|
4855
4788
|
GetRandomValues: "getRandomValues",
|
|
4789
|
+
GenerateHKDF: "generateHKDF",
|
|
4790
|
+
GenerateBaseKey: "generateBaseKey",
|
|
4791
|
+
Base64Decode: "base64Decode",
|
|
4792
|
+
UrlEncodeArr: "urlEncodeArr",
|
|
4793
|
+
Encrypt: "encrypt",
|
|
4794
|
+
Decrypt: "decrypt",
|
|
4856
4795
|
};
|
|
4857
4796
|
const PerformanceEventAbbreviations = new Map([
|
|
4858
4797
|
[PerformanceEvents.AcquireTokenByCode, "ATByCode"],
|
|
@@ -4937,6 +4876,9 @@ const PerformanceEventAbbreviations = new Map([
|
|
|
4937
4876
|
PerformanceEvents.InitializeClientApplication,
|
|
4938
4877
|
"InitClientApplication",
|
|
4939
4878
|
],
|
|
4879
|
+
[PerformanceEvents.InitializeCache, "InitCache"],
|
|
4880
|
+
[PerformanceEvents.ImportExistingCache, "importCache"],
|
|
4881
|
+
[PerformanceEvents.SetUserData, "setUserData"],
|
|
4940
4882
|
[PerformanceEvents.SilentIframeClientTokenHelper, "SIClientTHelper"],
|
|
4941
4883
|
[
|
|
4942
4884
|
PerformanceEvents.SilentHandlerInitiateAuthRequest,
|
|
@@ -5070,6 +5012,12 @@ const PerformanceEventAbbreviations = new Map([
|
|
|
5070
5012
|
],
|
|
5071
5013
|
[PerformanceEvents.Sha256Digest, "Sha256Digest"],
|
|
5072
5014
|
[PerformanceEvents.GetRandomValues, "GetRandomValues"],
|
|
5015
|
+
[PerformanceEvents.GenerateHKDF, "genHKDF"],
|
|
5016
|
+
[PerformanceEvents.GenerateBaseKey, "genBaseKey"],
|
|
5017
|
+
[PerformanceEvents.Base64Decode, "b64Decode"],
|
|
5018
|
+
[PerformanceEvents.UrlEncodeArr, "urlEncArr"],
|
|
5019
|
+
[PerformanceEvents.Encrypt, "encrypt"],
|
|
5020
|
+
[PerformanceEvents.Decrypt, "decrypt"],
|
|
5073
5021
|
]);
|
|
5074
5022
|
/**
|
|
5075
5023
|
* State of the performance event.
|
|
@@ -5095,9 +5043,11 @@ const IntFields = new Set([
|
|
|
5095
5043
|
"multiMatchedAT",
|
|
5096
5044
|
"multiMatchedID",
|
|
5097
5045
|
"multiMatchedRT",
|
|
5046
|
+
"unencryptedCacheCount",
|
|
5047
|
+
"encryptedCacheExpiredCount",
|
|
5098
5048
|
]);
|
|
5099
5049
|
|
|
5100
|
-
/*! @azure/msal-common
|
|
5050
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
5101
5051
|
/*
|
|
5102
5052
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
5103
5053
|
* Licensed under the MIT License.
|
|
@@ -5193,7 +5143,7 @@ const invokeAsync = (callback, eventName, logger, telemetryClient, correlationId
|
|
|
5193
5143
|
};
|
|
5194
5144
|
};
|
|
5195
5145
|
|
|
5196
|
-
/*! @azure/msal-common
|
|
5146
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
5197
5147
|
|
|
5198
5148
|
/*
|
|
5199
5149
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -5302,7 +5252,7 @@ RegionDiscovery.IMDS_OPTIONS = {
|
|
|
5302
5252
|
},
|
|
5303
5253
|
};
|
|
5304
5254
|
|
|
5305
|
-
/*! @azure/msal-common
|
|
5255
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
5306
5256
|
|
|
5307
5257
|
/*
|
|
5308
5258
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6141,7 +6091,7 @@ function buildStaticAuthorityOptions(authOptions) {
|
|
|
6141
6091
|
};
|
|
6142
6092
|
}
|
|
6143
6093
|
|
|
6144
|
-
/*! @azure/msal-common
|
|
6094
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
6145
6095
|
|
|
6146
6096
|
/*
|
|
6147
6097
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6172,7 +6122,7 @@ async function createDiscoveredInstance(authorityUri, networkClient, cacheManage
|
|
|
6172
6122
|
}
|
|
6173
6123
|
}
|
|
6174
6124
|
|
|
6175
|
-
/*! @azure/msal-common
|
|
6125
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
6176
6126
|
|
|
6177
6127
|
/*
|
|
6178
6128
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6191,7 +6141,7 @@ class ServerError extends AuthError {
|
|
|
6191
6141
|
}
|
|
6192
6142
|
}
|
|
6193
6143
|
|
|
6194
|
-
/*! @azure/msal-common
|
|
6144
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
6195
6145
|
|
|
6196
6146
|
/*
|
|
6197
6147
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6289,7 +6239,7 @@ class ThrottlingUtils {
|
|
|
6289
6239
|
}
|
|
6290
6240
|
}
|
|
6291
6241
|
|
|
6292
|
-
/*! @azure/msal-common
|
|
6242
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
6293
6243
|
|
|
6294
6244
|
/*
|
|
6295
6245
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6319,7 +6269,7 @@ function createNetworkError(error, httpStatus, responseHeaders) {
|
|
|
6319
6269
|
return new NetworkError(error, httpStatus, responseHeaders);
|
|
6320
6270
|
}
|
|
6321
6271
|
|
|
6322
|
-
/*! @azure/msal-common
|
|
6272
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
6323
6273
|
|
|
6324
6274
|
/*
|
|
6325
6275
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6469,7 +6419,7 @@ class BaseClient {
|
|
|
6469
6419
|
}
|
|
6470
6420
|
}
|
|
6471
6421
|
|
|
6472
|
-
/*! @azure/msal-common
|
|
6422
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
6473
6423
|
/*
|
|
6474
6424
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6475
6425
|
* Licensed under the MIT License.
|
|
@@ -6495,7 +6445,7 @@ var InteractionRequiredAuthErrorCodes = /*#__PURE__*/Object.freeze({
|
|
|
6495
6445
|
refreshTokenExpired: refreshTokenExpired
|
|
6496
6446
|
});
|
|
6497
6447
|
|
|
6498
|
-
/*! @azure/msal-common
|
|
6448
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
6499
6449
|
|
|
6500
6450
|
/*
|
|
6501
6451
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6583,7 +6533,7 @@ function createInteractionRequiredAuthError(errorCode) {
|
|
|
6583
6533
|
return new InteractionRequiredAuthError(errorCode, InteractionRequiredAuthErrorMessages[errorCode]);
|
|
6584
6534
|
}
|
|
6585
6535
|
|
|
6586
|
-
/*! @azure/msal-common
|
|
6536
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
6587
6537
|
|
|
6588
6538
|
/*
|
|
6589
6539
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6655,7 +6605,7 @@ class ProtocolUtils {
|
|
|
6655
6605
|
}
|
|
6656
6606
|
}
|
|
6657
6607
|
|
|
6658
|
-
/*! @azure/msal-common
|
|
6608
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
6659
6609
|
|
|
6660
6610
|
/*
|
|
6661
6611
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6739,7 +6689,7 @@ class PopTokenGenerator {
|
|
|
6739
6689
|
}
|
|
6740
6690
|
}
|
|
6741
6691
|
|
|
6742
|
-
/*! @azure/msal-common
|
|
6692
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
6743
6693
|
/*
|
|
6744
6694
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6745
6695
|
* Licensed under the MIT License.
|
|
@@ -6766,7 +6716,7 @@ class PopTokenGenerator {
|
|
|
6766
6716
|
}
|
|
6767
6717
|
}
|
|
6768
6718
|
|
|
6769
|
-
/*! @azure/msal-common
|
|
6719
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
6770
6720
|
|
|
6771
6721
|
/*
|
|
6772
6722
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6926,13 +6876,13 @@ class ResponseHandler {
|
|
|
6926
6876
|
!forceCacheRefreshTokenResponse &&
|
|
6927
6877
|
cacheRecord.account) {
|
|
6928
6878
|
const key = cacheRecord.account.generateAccountKey();
|
|
6929
|
-
const account = this.cacheStorage.getAccount(key
|
|
6879
|
+
const account = this.cacheStorage.getAccount(key);
|
|
6930
6880
|
if (!account) {
|
|
6931
6881
|
this.logger.warning("Account used to refresh tokens not in persistence, refreshed tokens will not be stored in the cache");
|
|
6932
6882
|
return await ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenClaims, requestStateObj, undefined, serverRequestId);
|
|
6933
6883
|
}
|
|
6934
6884
|
}
|
|
6935
|
-
await this.cacheStorage.saveCacheRecord(cacheRecord, request.
|
|
6885
|
+
await this.cacheStorage.saveCacheRecord(cacheRecord, request.correlationId, request.storeInCache);
|
|
6936
6886
|
}
|
|
6937
6887
|
finally {
|
|
6938
6888
|
if (this.persistencePlugin &&
|
|
@@ -7118,7 +7068,7 @@ function buildAccountToCache(cacheStorage, authority, homeAccountId, base64Decod
|
|
|
7118
7068
|
});
|
|
7119
7069
|
let cachedAccount = null;
|
|
7120
7070
|
if (baseAccountKey) {
|
|
7121
|
-
cachedAccount = cacheStorage.getAccount(baseAccountKey
|
|
7071
|
+
cachedAccount = cacheStorage.getAccount(baseAccountKey);
|
|
7122
7072
|
}
|
|
7123
7073
|
const baseAccount = cachedAccount ||
|
|
7124
7074
|
AccountEntity.createAccount({
|
|
@@ -7143,7 +7093,7 @@ function buildAccountToCache(cacheStorage, authority, homeAccountId, base64Decod
|
|
|
7143
7093
|
return baseAccount;
|
|
7144
7094
|
}
|
|
7145
7095
|
|
|
7146
|
-
/*! @azure/msal-common
|
|
7096
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
7147
7097
|
/*
|
|
7148
7098
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
7149
7099
|
* Licensed under the MIT License.
|
|
@@ -7161,7 +7111,7 @@ async function getClientAssertion(clientAssertion, clientId, tokenEndpoint) {
|
|
|
7161
7111
|
}
|
|
7162
7112
|
}
|
|
7163
7113
|
|
|
7164
|
-
/*! @azure/msal-common
|
|
7114
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
7165
7115
|
|
|
7166
7116
|
/*
|
|
7167
7117
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7535,7 +7485,7 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
7535
7485
|
});
|
|
7536
7486
|
}
|
|
7537
7487
|
this.addExtraQueryParams(request, parameterBuilder);
|
|
7538
|
-
if (request.
|
|
7488
|
+
if (request.platformBroker) {
|
|
7539
7489
|
// signal ests that this is a WAM call
|
|
7540
7490
|
parameterBuilder.addNativeBroker();
|
|
7541
7491
|
// pass the req_cnf for POP
|
|
@@ -7603,7 +7553,7 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
7603
7553
|
}
|
|
7604
7554
|
}
|
|
7605
7555
|
|
|
7606
|
-
/*! @azure/msal-common
|
|
7556
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
7607
7557
|
|
|
7608
7558
|
/*
|
|
7609
7559
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7823,7 +7773,7 @@ class RefreshTokenClient extends BaseClient {
|
|
|
7823
7773
|
}
|
|
7824
7774
|
}
|
|
7825
7775
|
|
|
7826
|
-
/*! @azure/msal-common
|
|
7776
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
7827
7777
|
|
|
7828
7778
|
/*
|
|
7829
7779
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7959,7 +7909,7 @@ class SilentFlowClient extends BaseClient {
|
|
|
7959
7909
|
}
|
|
7960
7910
|
}
|
|
7961
7911
|
|
|
7962
|
-
/*! @azure/msal-common
|
|
7912
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
7963
7913
|
|
|
7964
7914
|
/*
|
|
7965
7915
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7974,7 +7924,7 @@ const StubbedNetworkModule = {
|
|
|
7974
7924
|
},
|
|
7975
7925
|
};
|
|
7976
7926
|
|
|
7977
|
-
/*! @azure/msal-common
|
|
7927
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
7978
7928
|
|
|
7979
7929
|
/*
|
|
7980
7930
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8032,7 +7982,7 @@ class AuthenticationHeaderParser {
|
|
|
8032
7982
|
}
|
|
8033
7983
|
}
|
|
8034
7984
|
|
|
8035
|
-
/*! @azure/msal-common
|
|
7985
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
8036
7986
|
|
|
8037
7987
|
/*
|
|
8038
7988
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8295,7 +8245,7 @@ class ServerTelemetryManager {
|
|
|
8295
8245
|
}
|
|
8296
8246
|
}
|
|
8297
8247
|
|
|
8298
|
-
/*! @azure/msal-common
|
|
8248
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
8299
8249
|
/*
|
|
8300
8250
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
8301
8251
|
* Licensed under the MIT License.
|
|
@@ -8303,7 +8253,7 @@ class ServerTelemetryManager {
|
|
|
8303
8253
|
const missingKidError = "missing_kid_error";
|
|
8304
8254
|
const missingAlgError = "missing_alg_error";
|
|
8305
8255
|
|
|
8306
|
-
/*! @azure/msal-common
|
|
8256
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
8307
8257
|
|
|
8308
8258
|
/*
|
|
8309
8259
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8328,7 +8278,7 @@ function createJoseHeaderError(code) {
|
|
|
8328
8278
|
return new JoseHeaderError(code, JoseHeaderErrorMessages[code]);
|
|
8329
8279
|
}
|
|
8330
8280
|
|
|
8331
|
-
/*! @azure/msal-common
|
|
8281
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
8332
8282
|
|
|
8333
8283
|
/*
|
|
8334
8284
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8368,7 +8318,7 @@ class JoseHeader {
|
|
|
8368
8318
|
}
|
|
8369
8319
|
}
|
|
8370
8320
|
|
|
8371
|
-
/*! @azure/msal-common
|
|
8321
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
8372
8322
|
|
|
8373
8323
|
/*
|
|
8374
8324
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8447,7 +8397,7 @@ class StubPerformanceClient {
|
|
|
8447
8397
|
}
|
|
8448
8398
|
}
|
|
8449
8399
|
|
|
8450
|
-
/*! @azure/msal-common
|
|
8400
|
+
/*! @azure/msal-common v15.0.1 2025-01-15 */
|
|
8451
8401
|
|
|
8452
8402
|
/*
|
|
8453
8403
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -9684,6 +9634,43 @@ function base64EncArr(aBytes) {
|
|
|
9684
9634
|
return btoa(binString);
|
|
9685
9635
|
}
|
|
9686
9636
|
|
|
9637
|
+
/*
|
|
9638
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
9639
|
+
* Licensed under the MIT License.
|
|
9640
|
+
*/
|
|
9641
|
+
/**
|
|
9642
|
+
* Class which exposes APIs to decode base64 strings to plaintext. See here for implementation details:
|
|
9643
|
+
* https://developer.mozilla.org/en-US/docs/Glossary/Base64#the_unicode_problem
|
|
9644
|
+
*/
|
|
9645
|
+
/**
|
|
9646
|
+
* Returns a URL-safe plaintext decoded string from b64 encoded input.
|
|
9647
|
+
* @param input
|
|
9648
|
+
*/
|
|
9649
|
+
function base64Decode(input) {
|
|
9650
|
+
return new TextDecoder().decode(base64DecToArr(input));
|
|
9651
|
+
}
|
|
9652
|
+
/**
|
|
9653
|
+
* Decodes base64 into Uint8Array
|
|
9654
|
+
* @param base64String
|
|
9655
|
+
*/
|
|
9656
|
+
function base64DecToArr(base64String) {
|
|
9657
|
+
let encodedString = base64String.replace(/-/g, "+").replace(/_/g, "/");
|
|
9658
|
+
switch (encodedString.length % 4) {
|
|
9659
|
+
case 0:
|
|
9660
|
+
break;
|
|
9661
|
+
case 2:
|
|
9662
|
+
encodedString += "==";
|
|
9663
|
+
break;
|
|
9664
|
+
case 3:
|
|
9665
|
+
encodedString += "=";
|
|
9666
|
+
break;
|
|
9667
|
+
default:
|
|
9668
|
+
throw createBrowserAuthError(invalidBase64String);
|
|
9669
|
+
}
|
|
9670
|
+
const binString = atob(encodedString);
|
|
9671
|
+
return Uint8Array.from(binString, (m) => m.codePointAt(0) || 0);
|
|
9672
|
+
}
|
|
9673
|
+
|
|
9687
9674
|
/*
|
|
9688
9675
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
9689
9676
|
* Licensed under the MIT License.
|
|
@@ -9695,8 +9682,10 @@ function base64EncArr(aBytes) {
|
|
|
9695
9682
|
/**
|
|
9696
9683
|
* See here for more info on RsaHashedKeyGenParams: https://developer.mozilla.org/en-US/docs/Web/API/RsaHashedKeyGenParams
|
|
9697
9684
|
*/
|
|
9698
|
-
//
|
|
9685
|
+
// Algorithms
|
|
9699
9686
|
const PKCS1_V15_KEYGEN_ALG = "RSASSA-PKCS1-v1_5";
|
|
9687
|
+
const AES_GCM = "AES-GCM";
|
|
9688
|
+
const HKDF = "HKDF";
|
|
9700
9689
|
// SHA-256 hashing algorithm
|
|
9701
9690
|
const S256_HASH_ALG = "SHA-256";
|
|
9702
9691
|
// MOD length for PoP tokens
|
|
@@ -9707,6 +9696,13 @@ const PUBLIC_EXPONENT = new Uint8Array([0x01, 0x00, 0x01]);
|
|
|
9707
9696
|
const UUID_CHARS = "0123456789abcdef";
|
|
9708
9697
|
// Array to store UINT32 random value
|
|
9709
9698
|
const UINT32_ARR = new Uint32Array(1);
|
|
9699
|
+
// Key Format
|
|
9700
|
+
const RAW = "raw";
|
|
9701
|
+
// Key Usages
|
|
9702
|
+
const ENCRYPT = "encrypt";
|
|
9703
|
+
const DECRYPT = "decrypt";
|
|
9704
|
+
const DERIVE_KEY = "deriveKey";
|
|
9705
|
+
// Suberror
|
|
9710
9706
|
const SUBTLE_SUBERROR = "crypto_subtle_undefined";
|
|
9711
9707
|
const keygenAlgorithmOptions = {
|
|
9712
9708
|
name: PKCS1_V15_KEYGEN_ALG,
|
|
@@ -9829,6 +9825,76 @@ async function importJwk(key, extractable, usages) {
|
|
|
9829
9825
|
async function sign(key, data) {
|
|
9830
9826
|
return window.crypto.subtle.sign(keygenAlgorithmOptions, key, data);
|
|
9831
9827
|
}
|
|
9828
|
+
/**
|
|
9829
|
+
* Generates symmetric base encryption key. This may be stored as all encryption/decryption keys will be derived from this one.
|
|
9830
|
+
*/
|
|
9831
|
+
async function generateBaseKey() {
|
|
9832
|
+
const key = await window.crypto.subtle.generateKey({
|
|
9833
|
+
name: AES_GCM,
|
|
9834
|
+
length: 256,
|
|
9835
|
+
}, true, [ENCRYPT, DECRYPT]);
|
|
9836
|
+
return window.crypto.subtle.exportKey(RAW, key);
|
|
9837
|
+
}
|
|
9838
|
+
/**
|
|
9839
|
+
* Returns the raw key to be passed into the key derivation function
|
|
9840
|
+
* @param baseKey
|
|
9841
|
+
* @returns
|
|
9842
|
+
*/
|
|
9843
|
+
async function generateHKDF(baseKey) {
|
|
9844
|
+
return window.crypto.subtle.importKey(RAW, baseKey, HKDF, false, [
|
|
9845
|
+
DERIVE_KEY,
|
|
9846
|
+
]);
|
|
9847
|
+
}
|
|
9848
|
+
/**
|
|
9849
|
+
* Given a base key and a nonce generates a derived key to be used in encryption and decryption.
|
|
9850
|
+
* Note: every time we encrypt a new key is derived
|
|
9851
|
+
* @param baseKey
|
|
9852
|
+
* @param nonce
|
|
9853
|
+
* @returns
|
|
9854
|
+
*/
|
|
9855
|
+
async function deriveKey(baseKey, nonce, context) {
|
|
9856
|
+
return window.crypto.subtle.deriveKey({
|
|
9857
|
+
name: HKDF,
|
|
9858
|
+
salt: nonce,
|
|
9859
|
+
hash: S256_HASH_ALG,
|
|
9860
|
+
info: new TextEncoder().encode(context),
|
|
9861
|
+
}, baseKey, { name: AES_GCM, length: 256 }, false, [ENCRYPT, DECRYPT]);
|
|
9862
|
+
}
|
|
9863
|
+
/**
|
|
9864
|
+
* Encrypt the given data given a base key. Returns encrypted data and a nonce that must be provided during decryption
|
|
9865
|
+
* @param key
|
|
9866
|
+
* @param rawData
|
|
9867
|
+
*/
|
|
9868
|
+
async function encrypt(baseKey, rawData, context) {
|
|
9869
|
+
const encodedData = new TextEncoder().encode(rawData);
|
|
9870
|
+
// The nonce must never be reused with a given key.
|
|
9871
|
+
const nonce = window.crypto.getRandomValues(new Uint8Array(16));
|
|
9872
|
+
const derivedKey = await deriveKey(baseKey, nonce, context);
|
|
9873
|
+
const encryptedData = await window.crypto.subtle.encrypt({
|
|
9874
|
+
name: AES_GCM,
|
|
9875
|
+
iv: new Uint8Array(12), // New key is derived for every encrypt so we don't need a new nonce
|
|
9876
|
+
}, derivedKey, encodedData);
|
|
9877
|
+
return {
|
|
9878
|
+
data: urlEncodeArr(new Uint8Array(encryptedData)),
|
|
9879
|
+
nonce: urlEncodeArr(nonce),
|
|
9880
|
+
};
|
|
9881
|
+
}
|
|
9882
|
+
/**
|
|
9883
|
+
* Decrypt data with the given key and nonce
|
|
9884
|
+
* @param key
|
|
9885
|
+
* @param nonce
|
|
9886
|
+
* @param encryptedData
|
|
9887
|
+
* @returns
|
|
9888
|
+
*/
|
|
9889
|
+
async function decrypt(baseKey, nonce, context, encryptedData) {
|
|
9890
|
+
const encodedData = base64DecToArr(encryptedData);
|
|
9891
|
+
const derivedKey = await deriveKey(baseKey, base64DecToArr(nonce), context);
|
|
9892
|
+
const decryptedData = await window.crypto.subtle.decrypt({
|
|
9893
|
+
name: AES_GCM,
|
|
9894
|
+
iv: new Uint8Array(12), // New key is derived for every encrypt so we don't need a new nonce
|
|
9895
|
+
}, derivedKey, encodedData);
|
|
9896
|
+
return new TextDecoder().decode(decryptedData);
|
|
9897
|
+
}
|
|
9832
9898
|
/**
|
|
9833
9899
|
* Returns the SHA-256 hash of an input string
|
|
9834
9900
|
* @param plainText
|
|
@@ -10321,7 +10387,7 @@ function buildConfiguration({ auth: userInputAuth, cache: userInputCache, system
|
|
|
10321
10387
|
redirectNavigationTimeout: DEFAULT_REDIRECT_TIMEOUT_MS,
|
|
10322
10388
|
asyncPopups: false,
|
|
10323
10389
|
allowRedirectInIframe: false,
|
|
10324
|
-
|
|
10390
|
+
allowPlatformBroker: false,
|
|
10325
10391
|
nativeBrokerHandshakeTimeout: userInputSystem?.nativeBrokerHandshakeTimeout ||
|
|
10326
10392
|
DEFAULT_NATIVE_BROKER_HANDSHAKE_TIMEOUT_MS,
|
|
10327
10393
|
pollIntervalMilliseconds: BrowserConstants.DEFAULT_POLL_INTERVAL_MS,
|
|
@@ -10344,11 +10410,11 @@ function buildConfiguration({ auth: userInputAuth, cache: userInputCache, system
|
|
|
10344
10410
|
const logger = new Logger(providedSystemOptions.loggerOptions);
|
|
10345
10411
|
logger.warning(JSON.stringify(createClientConfigurationError(cannotSetOIDCOptions)));
|
|
10346
10412
|
}
|
|
10347
|
-
// Throw an error if user has set
|
|
10413
|
+
// Throw an error if user has set allowPlatformBroker to true without being in AAD protocol mode
|
|
10348
10414
|
if (userInputAuth?.protocolMode &&
|
|
10349
10415
|
userInputAuth.protocolMode !== ProtocolMode.AAD &&
|
|
10350
|
-
providedSystemOptions?.
|
|
10351
|
-
throw createClientConfigurationError(
|
|
10416
|
+
providedSystemOptions?.allowPlatformBroker) {
|
|
10417
|
+
throw createClientConfigurationError(cannotAllowPlatformBroker);
|
|
10352
10418
|
}
|
|
10353
10419
|
const overlayedConfig = {
|
|
10354
10420
|
auth: {
|
|
@@ -10368,7 +10434,7 @@ function buildConfiguration({ auth: userInputAuth, cache: userInputCache, system
|
|
|
10368
10434
|
|
|
10369
10435
|
/* eslint-disable header/header */
|
|
10370
10436
|
const name = "@azure/msal-browser";
|
|
10371
|
-
const version = "
|
|
10437
|
+
const version = "4.0.1";
|
|
10372
10438
|
|
|
10373
10439
|
/*
|
|
10374
10440
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -10744,43 +10810,6 @@ StandardOperatingContext.MODULE_NAME = "";
|
|
|
10744
10810
|
*/
|
|
10745
10811
|
StandardOperatingContext.ID = "StandardOperatingContext";
|
|
10746
10812
|
|
|
10747
|
-
/*
|
|
10748
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
10749
|
-
* Licensed under the MIT License.
|
|
10750
|
-
*/
|
|
10751
|
-
/**
|
|
10752
|
-
* Class which exposes APIs to decode base64 strings to plaintext. See here for implementation details:
|
|
10753
|
-
* https://developer.mozilla.org/en-US/docs/Glossary/Base64#the_unicode_problem
|
|
10754
|
-
*/
|
|
10755
|
-
/**
|
|
10756
|
-
* Returns a URL-safe plaintext decoded string from b64 encoded input.
|
|
10757
|
-
* @param input
|
|
10758
|
-
*/
|
|
10759
|
-
function base64Decode(input) {
|
|
10760
|
-
return new TextDecoder().decode(base64DecToArr(input));
|
|
10761
|
-
}
|
|
10762
|
-
/**
|
|
10763
|
-
* Decodes base64 into Uint8Array
|
|
10764
|
-
* @param base64String
|
|
10765
|
-
*/
|
|
10766
|
-
function base64DecToArr(base64String) {
|
|
10767
|
-
let encodedString = base64String.replace(/-/g, "+").replace(/_/g, "/");
|
|
10768
|
-
switch (encodedString.length % 4) {
|
|
10769
|
-
case 0:
|
|
10770
|
-
break;
|
|
10771
|
-
case 2:
|
|
10772
|
-
encodedString += "==";
|
|
10773
|
-
break;
|
|
10774
|
-
case 3:
|
|
10775
|
-
encodedString += "=";
|
|
10776
|
-
break;
|
|
10777
|
-
default:
|
|
10778
|
-
throw createBrowserAuthError(invalidBase64String);
|
|
10779
|
-
}
|
|
10780
|
-
const binString = atob(encodedString);
|
|
10781
|
-
return Uint8Array.from(binString, (m) => m.codePointAt(0) || 0);
|
|
10782
|
-
}
|
|
10783
|
-
|
|
10784
10813
|
/*
|
|
10785
10814
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
10786
10815
|
* Licensed under the MIT License.
|
|
@@ -10990,12 +11019,21 @@ class MemoryStorage {
|
|
|
10990
11019
|
constructor() {
|
|
10991
11020
|
this.cache = new Map();
|
|
10992
11021
|
}
|
|
11022
|
+
async initialize() {
|
|
11023
|
+
// Memory storage does not require initialization
|
|
11024
|
+
}
|
|
10993
11025
|
getItem(key) {
|
|
10994
11026
|
return this.cache.get(key) || null;
|
|
10995
11027
|
}
|
|
11028
|
+
getUserData(key) {
|
|
11029
|
+
return this.getItem(key);
|
|
11030
|
+
}
|
|
10996
11031
|
setItem(key, value) {
|
|
10997
11032
|
this.cache.set(key, value);
|
|
10998
11033
|
}
|
|
11034
|
+
async setUserData(key, value) {
|
|
11035
|
+
this.setItem(key, value);
|
|
11036
|
+
}
|
|
10999
11037
|
removeItem(key) {
|
|
11000
11038
|
this.cache.delete(key);
|
|
11001
11039
|
}
|
|
@@ -11327,19 +11365,189 @@ function getSortedObjectString(obj) {
|
|
|
11327
11365
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
11328
11366
|
* Licensed under the MIT License.
|
|
11329
11367
|
*/
|
|
11368
|
+
// Cookie life calculation (hours * minutes * seconds * ms)
|
|
11369
|
+
const COOKIE_LIFE_MULTIPLIER = 24 * 60 * 60 * 1000;
|
|
11370
|
+
class CookieStorage {
|
|
11371
|
+
initialize() {
|
|
11372
|
+
return Promise.resolve();
|
|
11373
|
+
}
|
|
11374
|
+
getItem(key) {
|
|
11375
|
+
const name = `${encodeURIComponent(key)}`;
|
|
11376
|
+
const cookieList = document.cookie.split(";");
|
|
11377
|
+
for (let i = 0; i < cookieList.length; i++) {
|
|
11378
|
+
const cookie = cookieList[i];
|
|
11379
|
+
const [key, ...rest] = decodeURIComponent(cookie).trim().split("=");
|
|
11380
|
+
const value = rest.join("=");
|
|
11381
|
+
if (key === name) {
|
|
11382
|
+
return value;
|
|
11383
|
+
}
|
|
11384
|
+
}
|
|
11385
|
+
return "";
|
|
11386
|
+
}
|
|
11387
|
+
getUserData() {
|
|
11388
|
+
throw createClientAuthError(methodNotImplemented);
|
|
11389
|
+
}
|
|
11390
|
+
setItem(key, value, cookieLifeDays, secure = true) {
|
|
11391
|
+
let cookieStr = `${encodeURIComponent(key)}=${encodeURIComponent(value)};path=/;SameSite=Lax;`;
|
|
11392
|
+
if (cookieLifeDays) {
|
|
11393
|
+
const expireTime = getCookieExpirationTime(cookieLifeDays);
|
|
11394
|
+
cookieStr += `expires=${expireTime};`;
|
|
11395
|
+
}
|
|
11396
|
+
if (secure) {
|
|
11397
|
+
cookieStr += "Secure;";
|
|
11398
|
+
}
|
|
11399
|
+
document.cookie = cookieStr;
|
|
11400
|
+
}
|
|
11401
|
+
async setUserData() {
|
|
11402
|
+
return Promise.reject(createClientAuthError(methodNotImplemented));
|
|
11403
|
+
}
|
|
11404
|
+
removeItem(key) {
|
|
11405
|
+
// Setting expiration to -1 removes it
|
|
11406
|
+
this.setItem(key, "", -1);
|
|
11407
|
+
}
|
|
11408
|
+
getKeys() {
|
|
11409
|
+
const cookieList = document.cookie.split(";");
|
|
11410
|
+
const keys = [];
|
|
11411
|
+
cookieList.forEach((cookie) => {
|
|
11412
|
+
const cookieParts = decodeURIComponent(cookie).trim().split("=");
|
|
11413
|
+
keys.push(cookieParts[0]);
|
|
11414
|
+
});
|
|
11415
|
+
return keys;
|
|
11416
|
+
}
|
|
11417
|
+
containsKey(key) {
|
|
11418
|
+
return this.getKeys().includes(key);
|
|
11419
|
+
}
|
|
11420
|
+
}
|
|
11421
|
+
/**
|
|
11422
|
+
* Get cookie expiration time
|
|
11423
|
+
* @param cookieLifeDays
|
|
11424
|
+
*/
|
|
11425
|
+
function getCookieExpirationTime(cookieLifeDays) {
|
|
11426
|
+
const today = new Date();
|
|
11427
|
+
const expr = new Date(today.getTime() + cookieLifeDays * COOKIE_LIFE_MULTIPLIER);
|
|
11428
|
+
return expr.toUTCString();
|
|
11429
|
+
}
|
|
11430
|
+
|
|
11431
|
+
/*
|
|
11432
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
11433
|
+
* Licensed under the MIT License.
|
|
11434
|
+
*/
|
|
11435
|
+
/**
|
|
11436
|
+
* Returns a list of cache keys for all known accounts
|
|
11437
|
+
* @param storage
|
|
11438
|
+
* @returns
|
|
11439
|
+
*/
|
|
11440
|
+
function getAccountKeys(storage) {
|
|
11441
|
+
const accountKeys = storage.getItem(StaticCacheKeys.ACCOUNT_KEYS);
|
|
11442
|
+
if (accountKeys) {
|
|
11443
|
+
return JSON.parse(accountKeys);
|
|
11444
|
+
}
|
|
11445
|
+
return [];
|
|
11446
|
+
}
|
|
11447
|
+
/**
|
|
11448
|
+
* Returns a list of cache keys for all known tokens
|
|
11449
|
+
* @param clientId
|
|
11450
|
+
* @param storage
|
|
11451
|
+
* @returns
|
|
11452
|
+
*/
|
|
11453
|
+
function getTokenKeys(clientId, storage) {
|
|
11454
|
+
const item = storage.getItem(`${StaticCacheKeys.TOKEN_KEYS}.${clientId}`);
|
|
11455
|
+
if (item) {
|
|
11456
|
+
const tokenKeys = JSON.parse(item);
|
|
11457
|
+
if (tokenKeys &&
|
|
11458
|
+
tokenKeys.hasOwnProperty("idToken") &&
|
|
11459
|
+
tokenKeys.hasOwnProperty("accessToken") &&
|
|
11460
|
+
tokenKeys.hasOwnProperty("refreshToken")) {
|
|
11461
|
+
return tokenKeys;
|
|
11462
|
+
}
|
|
11463
|
+
}
|
|
11464
|
+
return {
|
|
11465
|
+
idToken: [],
|
|
11466
|
+
accessToken: [],
|
|
11467
|
+
refreshToken: [],
|
|
11468
|
+
};
|
|
11469
|
+
}
|
|
11470
|
+
|
|
11471
|
+
/*
|
|
11472
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
11473
|
+
* Licensed under the MIT License.
|
|
11474
|
+
*/
|
|
11475
|
+
const ENCRYPTION_KEY = "msal.cache.encryption";
|
|
11330
11476
|
class LocalStorage {
|
|
11331
|
-
constructor() {
|
|
11477
|
+
constructor(clientId, logger, performanceClient) {
|
|
11332
11478
|
if (!window.localStorage) {
|
|
11333
11479
|
throw createBrowserConfigurationAuthError(storageNotSupported);
|
|
11334
11480
|
}
|
|
11481
|
+
this.memoryStorage = new MemoryStorage();
|
|
11482
|
+
this.initialized = false;
|
|
11483
|
+
this.clientId = clientId;
|
|
11484
|
+
this.logger = logger;
|
|
11485
|
+
this.performanceClient = performanceClient;
|
|
11486
|
+
}
|
|
11487
|
+
async initialize(correlationId) {
|
|
11488
|
+
this.initialized = true;
|
|
11489
|
+
const cookies = new CookieStorage();
|
|
11490
|
+
const cookieString = cookies.getItem(ENCRYPTION_KEY);
|
|
11491
|
+
let parsedCookie = { key: "", id: "" };
|
|
11492
|
+
if (cookieString) {
|
|
11493
|
+
try {
|
|
11494
|
+
parsedCookie = JSON.parse(cookieString);
|
|
11495
|
+
}
|
|
11496
|
+
catch (e) { }
|
|
11497
|
+
}
|
|
11498
|
+
if (parsedCookie.key && parsedCookie.id) {
|
|
11499
|
+
// Encryption key already exists, import
|
|
11500
|
+
const baseKey = invoke(base64DecToArr, PerformanceEvents.Base64Decode, this.logger, this.performanceClient, correlationId)(parsedCookie.key);
|
|
11501
|
+
this.encryptionCookie = {
|
|
11502
|
+
id: parsedCookie.id,
|
|
11503
|
+
key: await invokeAsync(generateHKDF, PerformanceEvents.GenerateHKDF, this.logger, this.performanceClient, correlationId)(baseKey),
|
|
11504
|
+
};
|
|
11505
|
+
await invokeAsync(this.importExistingCache.bind(this), PerformanceEvents.ImportExistingCache, this.logger, this.performanceClient, correlationId)(correlationId);
|
|
11506
|
+
}
|
|
11507
|
+
else {
|
|
11508
|
+
// Encryption key doesn't exist or is invalid, generate a new one and clear existing cache
|
|
11509
|
+
this.clear();
|
|
11510
|
+
const id = createNewGuid();
|
|
11511
|
+
const baseKey = await invokeAsync(generateBaseKey, PerformanceEvents.GenerateBaseKey, this.logger, this.performanceClient, correlationId)();
|
|
11512
|
+
const keyStr = invoke(urlEncodeArr, PerformanceEvents.UrlEncodeArr, this.logger, this.performanceClient, correlationId)(new Uint8Array(baseKey));
|
|
11513
|
+
this.encryptionCookie = {
|
|
11514
|
+
id: id,
|
|
11515
|
+
key: await invokeAsync(generateHKDF, PerformanceEvents.GenerateHKDF, this.logger, this.performanceClient, correlationId)(baseKey),
|
|
11516
|
+
};
|
|
11517
|
+
const cookieData = {
|
|
11518
|
+
id: id,
|
|
11519
|
+
key: keyStr,
|
|
11520
|
+
};
|
|
11521
|
+
cookies.setItem(ENCRYPTION_KEY, JSON.stringify(cookieData));
|
|
11522
|
+
}
|
|
11335
11523
|
}
|
|
11336
11524
|
getItem(key) {
|
|
11337
11525
|
return window.localStorage.getItem(key);
|
|
11338
11526
|
}
|
|
11527
|
+
getUserData(key) {
|
|
11528
|
+
if (!this.initialized) {
|
|
11529
|
+
throw createBrowserAuthError(uninitializedPublicClientApplication);
|
|
11530
|
+
}
|
|
11531
|
+
return this.memoryStorage.getItem(key);
|
|
11532
|
+
}
|
|
11339
11533
|
setItem(key, value) {
|
|
11340
11534
|
window.localStorage.setItem(key, value);
|
|
11341
11535
|
}
|
|
11536
|
+
async setUserData(key, value, correlationId) {
|
|
11537
|
+
if (!this.initialized || !this.encryptionCookie) {
|
|
11538
|
+
throw createBrowserAuthError(uninitializedPublicClientApplication);
|
|
11539
|
+
}
|
|
11540
|
+
const { data, nonce } = await invokeAsync(encrypt, PerformanceEvents.Encrypt, this.logger, this.performanceClient, correlationId)(this.encryptionCookie.key, value, this.getContext(key));
|
|
11541
|
+
const encryptedData = {
|
|
11542
|
+
id: this.encryptionCookie.id,
|
|
11543
|
+
nonce: nonce,
|
|
11544
|
+
data: data,
|
|
11545
|
+
};
|
|
11546
|
+
this.memoryStorage.setItem(key, value);
|
|
11547
|
+
this.setItem(key, JSON.stringify(encryptedData));
|
|
11548
|
+
}
|
|
11342
11549
|
removeItem(key) {
|
|
11550
|
+
this.memoryStorage.removeItem(key);
|
|
11343
11551
|
window.localStorage.removeItem(key);
|
|
11344
11552
|
}
|
|
11345
11553
|
getKeys() {
|
|
@@ -11348,6 +11556,114 @@ class LocalStorage {
|
|
|
11348
11556
|
containsKey(key) {
|
|
11349
11557
|
return window.localStorage.hasOwnProperty(key);
|
|
11350
11558
|
}
|
|
11559
|
+
/**
|
|
11560
|
+
* Removes all known MSAL keys from the cache
|
|
11561
|
+
*/
|
|
11562
|
+
clear() {
|
|
11563
|
+
// Removes all remaining MSAL cache items
|
|
11564
|
+
this.memoryStorage.clear();
|
|
11565
|
+
const accountKeys = getAccountKeys(this);
|
|
11566
|
+
accountKeys.forEach((key) => this.removeItem(key));
|
|
11567
|
+
const tokenKeys = getTokenKeys(this.clientId, this);
|
|
11568
|
+
tokenKeys.idToken.forEach((key) => this.removeItem(key));
|
|
11569
|
+
tokenKeys.accessToken.forEach((key) => this.removeItem(key));
|
|
11570
|
+
tokenKeys.refreshToken.forEach((key) => this.removeItem(key));
|
|
11571
|
+
// Clean up anything left
|
|
11572
|
+
this.getKeys().forEach((cacheKey) => {
|
|
11573
|
+
if (cacheKey.startsWith(Constants.CACHE_PREFIX) ||
|
|
11574
|
+
cacheKey.indexOf(this.clientId) !== -1) {
|
|
11575
|
+
this.removeItem(cacheKey);
|
|
11576
|
+
}
|
|
11577
|
+
});
|
|
11578
|
+
}
|
|
11579
|
+
/**
|
|
11580
|
+
* Helper to decrypt all known MSAL keys in localStorage and save them to inMemory storage
|
|
11581
|
+
* @returns
|
|
11582
|
+
*/
|
|
11583
|
+
async importExistingCache(correlationId) {
|
|
11584
|
+
if (!this.encryptionCookie) {
|
|
11585
|
+
return;
|
|
11586
|
+
}
|
|
11587
|
+
let accountKeys = getAccountKeys(this);
|
|
11588
|
+
accountKeys = await this.importArray(accountKeys, correlationId);
|
|
11589
|
+
// Write valid account keys back to map
|
|
11590
|
+
this.setItem(StaticCacheKeys.ACCOUNT_KEYS, JSON.stringify(accountKeys));
|
|
11591
|
+
const tokenKeys = getTokenKeys(this.clientId, this);
|
|
11592
|
+
tokenKeys.idToken = await this.importArray(tokenKeys.idToken, correlationId);
|
|
11593
|
+
tokenKeys.accessToken = await this.importArray(tokenKeys.accessToken, correlationId);
|
|
11594
|
+
tokenKeys.refreshToken = await this.importArray(tokenKeys.refreshToken, correlationId);
|
|
11595
|
+
// Write valid token keys back to map
|
|
11596
|
+
this.setItem(`${StaticCacheKeys.TOKEN_KEYS}.${this.clientId}`, JSON.stringify(tokenKeys));
|
|
11597
|
+
}
|
|
11598
|
+
/**
|
|
11599
|
+
* Helper to decrypt and save cache entries
|
|
11600
|
+
* @param key
|
|
11601
|
+
* @returns
|
|
11602
|
+
*/
|
|
11603
|
+
async getItemFromEncryptedCache(key, correlationId) {
|
|
11604
|
+
if (!this.encryptionCookie) {
|
|
11605
|
+
return null;
|
|
11606
|
+
}
|
|
11607
|
+
const rawCache = this.getItem(key);
|
|
11608
|
+
if (!rawCache) {
|
|
11609
|
+
return null;
|
|
11610
|
+
}
|
|
11611
|
+
let encObj;
|
|
11612
|
+
try {
|
|
11613
|
+
encObj = JSON.parse(rawCache);
|
|
11614
|
+
}
|
|
11615
|
+
catch (e) {
|
|
11616
|
+
// Not a valid encrypted object, remove
|
|
11617
|
+
return null;
|
|
11618
|
+
}
|
|
11619
|
+
if (!encObj.id || !encObj.nonce || !encObj.data) {
|
|
11620
|
+
// Data is not encrypted, likely from old version of MSAL. It must be removed because we don't know how old it is.
|
|
11621
|
+
this.performanceClient.incrementFields({ unencryptedCacheCount: 1 }, correlationId);
|
|
11622
|
+
return null;
|
|
11623
|
+
}
|
|
11624
|
+
if (encObj.id !== this.encryptionCookie.id) {
|
|
11625
|
+
// Data was encrypted with a different key. It must be removed because it is from a previous session.
|
|
11626
|
+
this.performanceClient.incrementFields({ encryptedCacheExpiredCount: 1 }, correlationId);
|
|
11627
|
+
return null;
|
|
11628
|
+
}
|
|
11629
|
+
return invokeAsync(decrypt, PerformanceEvents.Decrypt, this.logger, this.performanceClient, correlationId)(this.encryptionCookie.key, encObj.nonce, this.getContext(key), encObj.data);
|
|
11630
|
+
}
|
|
11631
|
+
/**
|
|
11632
|
+
* Helper to decrypt and save an array of cache keys
|
|
11633
|
+
* @param arr
|
|
11634
|
+
* @returns Array of keys successfully imported
|
|
11635
|
+
*/
|
|
11636
|
+
async importArray(arr, correlationId) {
|
|
11637
|
+
const importedArr = [];
|
|
11638
|
+
const promiseArr = [];
|
|
11639
|
+
arr.forEach((key) => {
|
|
11640
|
+
const promise = this.getItemFromEncryptedCache(key, correlationId).then((value) => {
|
|
11641
|
+
if (value) {
|
|
11642
|
+
this.memoryStorage.setItem(key, value);
|
|
11643
|
+
importedArr.push(key);
|
|
11644
|
+
}
|
|
11645
|
+
else {
|
|
11646
|
+
// If value is empty, unencrypted or expired remove
|
|
11647
|
+
this.removeItem(key);
|
|
11648
|
+
}
|
|
11649
|
+
});
|
|
11650
|
+
promiseArr.push(promise);
|
|
11651
|
+
});
|
|
11652
|
+
await Promise.all(promiseArr);
|
|
11653
|
+
return importedArr;
|
|
11654
|
+
}
|
|
11655
|
+
/**
|
|
11656
|
+
* Gets encryption context for a given cache entry. This is clientId for app specific entries, empty string for shared entries
|
|
11657
|
+
* @param key
|
|
11658
|
+
* @returns
|
|
11659
|
+
*/
|
|
11660
|
+
getContext(key) {
|
|
11661
|
+
let context = "";
|
|
11662
|
+
if (key.includes(this.clientId)) {
|
|
11663
|
+
context = this.clientId; // Used to bind encryption key to this appId
|
|
11664
|
+
}
|
|
11665
|
+
return context;
|
|
11666
|
+
}
|
|
11351
11667
|
}
|
|
11352
11668
|
|
|
11353
11669
|
/*
|
|
@@ -11360,12 +11676,21 @@ class SessionStorage {
|
|
|
11360
11676
|
throw createBrowserConfigurationAuthError(storageNotSupported);
|
|
11361
11677
|
}
|
|
11362
11678
|
}
|
|
11679
|
+
async initialize() {
|
|
11680
|
+
// Session storage does not require initialization
|
|
11681
|
+
}
|
|
11363
11682
|
getItem(key) {
|
|
11364
11683
|
return window.sessionStorage.getItem(key);
|
|
11365
11684
|
}
|
|
11685
|
+
getUserData(key) {
|
|
11686
|
+
return this.getItem(key);
|
|
11687
|
+
}
|
|
11366
11688
|
setItem(key, value) {
|
|
11367
11689
|
window.sessionStorage.setItem(key, value);
|
|
11368
11690
|
}
|
|
11691
|
+
async setUserData(key, value) {
|
|
11692
|
+
this.setItem(key, value);
|
|
11693
|
+
}
|
|
11369
11694
|
removeItem(key) {
|
|
11370
11695
|
window.sessionStorage.removeItem(key);
|
|
11371
11696
|
}
|
|
@@ -11399,64 +11724,6 @@ function extractBrowserRequestState(browserCrypto, state) {
|
|
|
11399
11724
|
}
|
|
11400
11725
|
}
|
|
11401
11726
|
|
|
11402
|
-
/*
|
|
11403
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
11404
|
-
* Licensed under the MIT License.
|
|
11405
|
-
*/
|
|
11406
|
-
// Cookie life calculation (hours * minutes * seconds * ms)
|
|
11407
|
-
const COOKIE_LIFE_MULTIPLIER = 24 * 60 * 60 * 1000;
|
|
11408
|
-
class CookieStorage {
|
|
11409
|
-
getItem(key) {
|
|
11410
|
-
const name = `${encodeURIComponent(key)}`;
|
|
11411
|
-
const cookieList = document.cookie.split(";");
|
|
11412
|
-
for (let i = 0; i < cookieList.length; i++) {
|
|
11413
|
-
const cookie = cookieList[i];
|
|
11414
|
-
const [key, ...rest] = decodeURIComponent(cookie).trim().split("=");
|
|
11415
|
-
const value = rest.join("=");
|
|
11416
|
-
if (key === name) {
|
|
11417
|
-
return value;
|
|
11418
|
-
}
|
|
11419
|
-
}
|
|
11420
|
-
return "";
|
|
11421
|
-
}
|
|
11422
|
-
setItem(key, value, cookieLifeDays, secure = true) {
|
|
11423
|
-
let cookieStr = `${encodeURIComponent(key)}=${encodeURIComponent(value)};path=/;SameSite=Lax;`;
|
|
11424
|
-
if (cookieLifeDays) {
|
|
11425
|
-
const expireTime = getCookieExpirationTime(cookieLifeDays);
|
|
11426
|
-
cookieStr += `expires=${expireTime};`;
|
|
11427
|
-
}
|
|
11428
|
-
if (secure) {
|
|
11429
|
-
cookieStr += "Secure;";
|
|
11430
|
-
}
|
|
11431
|
-
document.cookie = cookieStr;
|
|
11432
|
-
}
|
|
11433
|
-
removeItem(key) {
|
|
11434
|
-
// Setting expiration to -1 removes it
|
|
11435
|
-
this.setItem(key, "", -1);
|
|
11436
|
-
}
|
|
11437
|
-
getKeys() {
|
|
11438
|
-
const cookieList = document.cookie.split(";");
|
|
11439
|
-
const keys = [];
|
|
11440
|
-
cookieList.forEach((cookie) => {
|
|
11441
|
-
const cookieParts = decodeURIComponent(cookie).trim().split("=");
|
|
11442
|
-
keys.push(cookieParts[0]);
|
|
11443
|
-
});
|
|
11444
|
-
return keys;
|
|
11445
|
-
}
|
|
11446
|
-
containsKey(key) {
|
|
11447
|
-
return this.getKeys().includes(key);
|
|
11448
|
-
}
|
|
11449
|
-
}
|
|
11450
|
-
/**
|
|
11451
|
-
* Get cookie expiration time
|
|
11452
|
-
* @param cookieLifeDays
|
|
11453
|
-
*/
|
|
11454
|
-
function getCookieExpirationTime(cookieLifeDays) {
|
|
11455
|
-
const today = new Date();
|
|
11456
|
-
const expr = new Date(today.getTime() + cookieLifeDays * COOKIE_LIFE_MULTIPLIER);
|
|
11457
|
-
return expr.toUTCString();
|
|
11458
|
-
}
|
|
11459
|
-
|
|
11460
11727
|
/*
|
|
11461
11728
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
11462
11729
|
* Licensed under the MIT License.
|
|
@@ -11467,7 +11734,7 @@ function getCookieExpirationTime(cookieLifeDays) {
|
|
|
11467
11734
|
* parameters such as state and nonce, generally.
|
|
11468
11735
|
*/
|
|
11469
11736
|
class BrowserCacheManager extends CacheManager {
|
|
11470
|
-
constructor(clientId, cacheConfig, cryptoImpl, logger,
|
|
11737
|
+
constructor(clientId, cacheConfig, cryptoImpl, logger, performanceClient, staticAuthorityOptions) {
|
|
11471
11738
|
super(clientId, cryptoImpl, logger, staticAuthorityOptions);
|
|
11472
11739
|
this.cacheConfig = cacheConfig;
|
|
11473
11740
|
this.logger = logger;
|
|
@@ -11475,13 +11742,11 @@ class BrowserCacheManager extends CacheManager {
|
|
|
11475
11742
|
this.browserStorage = this.setupBrowserStorage(this.cacheConfig.cacheLocation);
|
|
11476
11743
|
this.temporaryCacheStorage = this.setupBrowserStorage(this.cacheConfig.temporaryCacheLocation);
|
|
11477
11744
|
this.cookieStorage = new CookieStorage();
|
|
11478
|
-
// Migrate cache entries from older versions of MSAL.
|
|
11479
|
-
if (cacheConfig.cacheMigrationEnabled) {
|
|
11480
|
-
this.migrateCacheEntries();
|
|
11481
|
-
this.createKeyMaps();
|
|
11482
|
-
}
|
|
11483
11745
|
this.performanceClient = performanceClient;
|
|
11484
11746
|
}
|
|
11747
|
+
async initialize(correlationId) {
|
|
11748
|
+
await this.browserStorage.initialize(correlationId);
|
|
11749
|
+
}
|
|
11485
11750
|
/**
|
|
11486
11751
|
* Returns a window storage class implementing the IWindowStorage interface that corresponds to the configured cacheLocation.
|
|
11487
11752
|
* @param cacheLocation
|
|
@@ -11490,7 +11755,7 @@ class BrowserCacheManager extends CacheManager {
|
|
|
11490
11755
|
try {
|
|
11491
11756
|
switch (cacheLocation) {
|
|
11492
11757
|
case BrowserCacheLocation.LocalStorage:
|
|
11493
|
-
return new LocalStorage();
|
|
11758
|
+
return new LocalStorage(this.clientId, this.logger, this.performanceClient);
|
|
11494
11759
|
case BrowserCacheLocation.SessionStorage:
|
|
11495
11760
|
return new SessionStorage();
|
|
11496
11761
|
case BrowserCacheLocation.MemoryStorage:
|
|
@@ -11504,123 +11769,6 @@ class BrowserCacheManager extends CacheManager {
|
|
|
11504
11769
|
this.cacheConfig.cacheLocation = BrowserCacheLocation.MemoryStorage;
|
|
11505
11770
|
return new MemoryStorage();
|
|
11506
11771
|
}
|
|
11507
|
-
/**
|
|
11508
|
-
* Migrate all old cache entries to new schema. No rollback supported.
|
|
11509
|
-
* @param storeAuthStateInCookie
|
|
11510
|
-
*/
|
|
11511
|
-
migrateCacheEntries() {
|
|
11512
|
-
const idTokenKey = `${Constants.CACHE_PREFIX}.${PersistentCacheKeys.ID_TOKEN}`;
|
|
11513
|
-
const clientInfoKey = `${Constants.CACHE_PREFIX}.${PersistentCacheKeys.CLIENT_INFO}`;
|
|
11514
|
-
const errorKey = `${Constants.CACHE_PREFIX}.${PersistentCacheKeys.ERROR}`;
|
|
11515
|
-
const errorDescKey = `${Constants.CACHE_PREFIX}.${PersistentCacheKeys.ERROR_DESC}`;
|
|
11516
|
-
const idTokenValue = this.browserStorage.getItem(idTokenKey);
|
|
11517
|
-
const clientInfoValue = this.browserStorage.getItem(clientInfoKey);
|
|
11518
|
-
const errorValue = this.browserStorage.getItem(errorKey);
|
|
11519
|
-
const errorDescValue = this.browserStorage.getItem(errorDescKey);
|
|
11520
|
-
const values = [
|
|
11521
|
-
idTokenValue,
|
|
11522
|
-
clientInfoValue,
|
|
11523
|
-
errorValue,
|
|
11524
|
-
errorDescValue,
|
|
11525
|
-
];
|
|
11526
|
-
const keysToMigrate = [
|
|
11527
|
-
PersistentCacheKeys.ID_TOKEN,
|
|
11528
|
-
PersistentCacheKeys.CLIENT_INFO,
|
|
11529
|
-
PersistentCacheKeys.ERROR,
|
|
11530
|
-
PersistentCacheKeys.ERROR_DESC,
|
|
11531
|
-
];
|
|
11532
|
-
keysToMigrate.forEach((cacheKey, index) => {
|
|
11533
|
-
const value = values[index];
|
|
11534
|
-
if (value) {
|
|
11535
|
-
this.setTemporaryCache(cacheKey, value, true);
|
|
11536
|
-
}
|
|
11537
|
-
});
|
|
11538
|
-
}
|
|
11539
|
-
/**
|
|
11540
|
-
* Searches all cache entries for MSAL accounts and creates the account key map
|
|
11541
|
-
* This is used to migrate users from older versions of MSAL which did not create the map.
|
|
11542
|
-
* @returns
|
|
11543
|
-
*/
|
|
11544
|
-
createKeyMaps() {
|
|
11545
|
-
this.logger.trace("BrowserCacheManager - createKeyMaps called.");
|
|
11546
|
-
const accountKeys = this.getItem(StaticCacheKeys.ACCOUNT_KEYS);
|
|
11547
|
-
const tokenKeys = this.getItem(`${StaticCacheKeys.TOKEN_KEYS}.${this.clientId}`);
|
|
11548
|
-
if (accountKeys && tokenKeys) {
|
|
11549
|
-
this.logger.verbose("BrowserCacheManager:createKeyMaps - account and token key maps already exist, skipping migration.");
|
|
11550
|
-
// Key maps already exist, no need to iterate through cache
|
|
11551
|
-
return;
|
|
11552
|
-
}
|
|
11553
|
-
const allKeys = this.browserStorage.getKeys();
|
|
11554
|
-
allKeys.forEach((key) => {
|
|
11555
|
-
if (this.isCredentialKey(key)) {
|
|
11556
|
-
// Get item, parse, validate and write key to map
|
|
11557
|
-
const value = this.getItem(key);
|
|
11558
|
-
if (value) {
|
|
11559
|
-
const credObj = this.validateAndParseJson(value);
|
|
11560
|
-
if (credObj && credObj.hasOwnProperty("credentialType")) {
|
|
11561
|
-
switch (credObj["credentialType"]) {
|
|
11562
|
-
case CredentialType.ID_TOKEN:
|
|
11563
|
-
if (isIdTokenEntity(credObj)) {
|
|
11564
|
-
this.logger.trace("BrowserCacheManager:createKeyMaps - idToken found, saving key to token key map");
|
|
11565
|
-
this.logger.tracePii(`BrowserCacheManager:createKeyMaps - idToken with key: ${key} found, saving key to token key map`);
|
|
11566
|
-
const idTokenEntity = credObj;
|
|
11567
|
-
const newKey = this.updateCredentialCacheKey(key, idTokenEntity);
|
|
11568
|
-
this.addTokenKey(newKey, CredentialType.ID_TOKEN);
|
|
11569
|
-
return;
|
|
11570
|
-
}
|
|
11571
|
-
else {
|
|
11572
|
-
this.logger.trace("BrowserCacheManager:createKeyMaps - key found matching idToken schema with value containing idToken credentialType field but value failed IdTokenEntity validation, skipping.");
|
|
11573
|
-
this.logger.tracePii(`BrowserCacheManager:createKeyMaps - failed idToken validation on key: ${key}`);
|
|
11574
|
-
}
|
|
11575
|
-
break;
|
|
11576
|
-
case CredentialType.ACCESS_TOKEN:
|
|
11577
|
-
case CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME:
|
|
11578
|
-
if (isAccessTokenEntity(credObj)) {
|
|
11579
|
-
this.logger.trace("BrowserCacheManager:createKeyMaps - accessToken found, saving key to token key map");
|
|
11580
|
-
this.logger.tracePii(`BrowserCacheManager:createKeyMaps - accessToken with key: ${key} found, saving key to token key map`);
|
|
11581
|
-
const accessTokenEntity = credObj;
|
|
11582
|
-
const newKey = this.updateCredentialCacheKey(key, accessTokenEntity);
|
|
11583
|
-
this.addTokenKey(newKey, CredentialType.ACCESS_TOKEN);
|
|
11584
|
-
return;
|
|
11585
|
-
}
|
|
11586
|
-
else {
|
|
11587
|
-
this.logger.trace("BrowserCacheManager:createKeyMaps - key found matching accessToken schema with value containing accessToken credentialType field but value failed AccessTokenEntity validation, skipping.");
|
|
11588
|
-
this.logger.tracePii(`BrowserCacheManager:createKeyMaps - failed accessToken validation on key: ${key}`);
|
|
11589
|
-
}
|
|
11590
|
-
break;
|
|
11591
|
-
case CredentialType.REFRESH_TOKEN:
|
|
11592
|
-
if (isRefreshTokenEntity(credObj)) {
|
|
11593
|
-
this.logger.trace("BrowserCacheManager:createKeyMaps - refreshToken found, saving key to token key map");
|
|
11594
|
-
this.logger.tracePii(`BrowserCacheManager:createKeyMaps - refreshToken with key: ${key} found, saving key to token key map`);
|
|
11595
|
-
const refreshTokenEntity = credObj;
|
|
11596
|
-
const newKey = this.updateCredentialCacheKey(key, refreshTokenEntity);
|
|
11597
|
-
this.addTokenKey(newKey, CredentialType.REFRESH_TOKEN);
|
|
11598
|
-
return;
|
|
11599
|
-
}
|
|
11600
|
-
else {
|
|
11601
|
-
this.logger.trace("BrowserCacheManager:createKeyMaps - key found matching refreshToken schema with value containing refreshToken credentialType field but value failed RefreshTokenEntity validation, skipping.");
|
|
11602
|
-
this.logger.tracePii(`BrowserCacheManager:createKeyMaps - failed refreshToken validation on key: ${key}`);
|
|
11603
|
-
}
|
|
11604
|
-
break;
|
|
11605
|
-
// If credentialType isn't one of our predefined ones, it may not be an MSAL cache value. Ignore.
|
|
11606
|
-
}
|
|
11607
|
-
}
|
|
11608
|
-
}
|
|
11609
|
-
}
|
|
11610
|
-
if (this.isAccountKey(key)) {
|
|
11611
|
-
const value = this.getItem(key);
|
|
11612
|
-
if (value) {
|
|
11613
|
-
const accountObj = this.validateAndParseJson(value);
|
|
11614
|
-
if (accountObj &&
|
|
11615
|
-
AccountEntity.isAccountEntity(accountObj)) {
|
|
11616
|
-
this.logger.trace("BrowserCacheManager:createKeyMaps - account found, saving key to account key map");
|
|
11617
|
-
this.logger.tracePii(`BrowserCacheManager:createKeyMaps - account with key: ${key} found, saving key to account key map`);
|
|
11618
|
-
this.addAccountKeyToMap(key);
|
|
11619
|
-
}
|
|
11620
|
-
}
|
|
11621
|
-
}
|
|
11622
|
-
});
|
|
11623
|
-
}
|
|
11624
11772
|
/**
|
|
11625
11773
|
* Parses passed value as JSON object, JSON.parse() will throw an error.
|
|
11626
11774
|
* @param input
|
|
@@ -11642,38 +11790,15 @@ class BrowserCacheManager extends CacheManager {
|
|
|
11642
11790
|
return null;
|
|
11643
11791
|
}
|
|
11644
11792
|
}
|
|
11645
|
-
/**
|
|
11646
|
-
* fetches the entry from the browser storage based off the key
|
|
11647
|
-
* @param key
|
|
11648
|
-
*/
|
|
11649
|
-
getItem(key) {
|
|
11650
|
-
return this.browserStorage.getItem(key);
|
|
11651
|
-
}
|
|
11652
|
-
/**
|
|
11653
|
-
* sets the entry in the browser storage
|
|
11654
|
-
* @param key
|
|
11655
|
-
* @param value
|
|
11656
|
-
*/
|
|
11657
|
-
setItem(key, value) {
|
|
11658
|
-
this.browserStorage.setItem(key, value);
|
|
11659
|
-
}
|
|
11660
|
-
/**
|
|
11661
|
-
* fetch the account entity from the platform cache
|
|
11662
|
-
* @param accountKey
|
|
11663
|
-
*/
|
|
11664
|
-
getAccount(accountKey, logger) {
|
|
11665
|
-
this.logger.trace("BrowserCacheManager.getAccount called");
|
|
11666
|
-
const accountEntity = this.getCachedAccountEntity(accountKey);
|
|
11667
|
-
return this.updateOutdatedCachedAccount(accountKey, accountEntity, logger);
|
|
11668
|
-
}
|
|
11669
11793
|
/**
|
|
11670
11794
|
* Reads account from cache, deserializes it into an account entity and returns it.
|
|
11671
11795
|
* If account is not found from the key, returns null and removes key from map.
|
|
11672
11796
|
* @param accountKey
|
|
11673
11797
|
* @returns
|
|
11674
11798
|
*/
|
|
11675
|
-
|
|
11676
|
-
|
|
11799
|
+
getAccount(accountKey) {
|
|
11800
|
+
this.logger.trace("BrowserCacheManager.getAccount called");
|
|
11801
|
+
const serializedAccount = this.browserStorage.getUserData(accountKey);
|
|
11677
11802
|
if (!serializedAccount) {
|
|
11678
11803
|
this.removeAccountKeyFromMap(accountKey);
|
|
11679
11804
|
return null;
|
|
@@ -11689,10 +11814,10 @@ class BrowserCacheManager extends CacheManager {
|
|
|
11689
11814
|
* set account entity in the platform cache
|
|
11690
11815
|
* @param account
|
|
11691
11816
|
*/
|
|
11692
|
-
setAccount(account) {
|
|
11817
|
+
async setAccount(account, correlationId) {
|
|
11693
11818
|
this.logger.trace("BrowserCacheManager.setAccount called");
|
|
11694
11819
|
const key = account.generateAccountKey();
|
|
11695
|
-
this.
|
|
11820
|
+
await invokeAsync(this.browserStorage.setUserData.bind(this.browserStorage), PerformanceEvents.SetUserData, this.logger, this.performanceClient)(key, JSON.stringify(account), correlationId);
|
|
11696
11821
|
this.addAccountKeyToMap(key);
|
|
11697
11822
|
}
|
|
11698
11823
|
/**
|
|
@@ -11700,13 +11825,7 @@ class BrowserCacheManager extends CacheManager {
|
|
|
11700
11825
|
* @returns
|
|
11701
11826
|
*/
|
|
11702
11827
|
getAccountKeys() {
|
|
11703
|
-
this.
|
|
11704
|
-
const accountKeys = this.getItem(StaticCacheKeys.ACCOUNT_KEYS);
|
|
11705
|
-
if (accountKeys) {
|
|
11706
|
-
return JSON.parse(accountKeys);
|
|
11707
|
-
}
|
|
11708
|
-
this.logger.verbose("BrowserCacheManager.getAccountKeys - No account keys found");
|
|
11709
|
-
return [];
|
|
11828
|
+
return getAccountKeys(this.browserStorage);
|
|
11710
11829
|
}
|
|
11711
11830
|
/**
|
|
11712
11831
|
* Add a new account to the key map
|
|
@@ -11719,7 +11838,7 @@ class BrowserCacheManager extends CacheManager {
|
|
|
11719
11838
|
if (accountKeys.indexOf(key) === -1) {
|
|
11720
11839
|
// Only add key if it does not already exist in the map
|
|
11721
11840
|
accountKeys.push(key);
|
|
11722
|
-
this.setItem(StaticCacheKeys.ACCOUNT_KEYS, JSON.stringify(accountKeys));
|
|
11841
|
+
this.browserStorage.setItem(StaticCacheKeys.ACCOUNT_KEYS, JSON.stringify(accountKeys));
|
|
11723
11842
|
this.logger.verbose("BrowserCacheManager.addAccountKeyToMap account key added");
|
|
11724
11843
|
}
|
|
11725
11844
|
else {
|
|
@@ -11737,7 +11856,7 @@ class BrowserCacheManager extends CacheManager {
|
|
|
11737
11856
|
const removalIndex = accountKeys.indexOf(key);
|
|
11738
11857
|
if (removalIndex > -1) {
|
|
11739
11858
|
accountKeys.splice(removalIndex, 1);
|
|
11740
|
-
this.setItem(StaticCacheKeys.ACCOUNT_KEYS, JSON.stringify(accountKeys));
|
|
11859
|
+
this.browserStorage.setItem(StaticCacheKeys.ACCOUNT_KEYS, JSON.stringify(accountKeys));
|
|
11741
11860
|
this.logger.trace("BrowserCacheManager.removeAccountKeyFromMap account key removed");
|
|
11742
11861
|
}
|
|
11743
11862
|
else {
|
|
@@ -11752,14 +11871,6 @@ class BrowserCacheManager extends CacheManager {
|
|
|
11752
11871
|
void super.removeAccount(key);
|
|
11753
11872
|
this.removeAccountKeyFromMap(key);
|
|
11754
11873
|
}
|
|
11755
|
-
/**
|
|
11756
|
-
* Remove account entity from the platform cache if it's outdated
|
|
11757
|
-
* @param accountKey
|
|
11758
|
-
*/
|
|
11759
|
-
removeOutdatedAccount(accountKey) {
|
|
11760
|
-
this.removeItem(accountKey);
|
|
11761
|
-
this.removeAccountKeyFromMap(accountKey);
|
|
11762
|
-
}
|
|
11763
11874
|
/**
|
|
11764
11875
|
* Removes given idToken from the cache and from the key map
|
|
11765
11876
|
* @param key
|
|
@@ -11789,28 +11900,7 @@ class BrowserCacheManager extends CacheManager {
|
|
|
11789
11900
|
* @returns
|
|
11790
11901
|
*/
|
|
11791
11902
|
getTokenKeys() {
|
|
11792
|
-
this.
|
|
11793
|
-
const item = this.getItem(`${StaticCacheKeys.TOKEN_KEYS}.${this.clientId}`);
|
|
11794
|
-
if (item) {
|
|
11795
|
-
const tokenKeys = this.validateAndParseJson(item);
|
|
11796
|
-
if (tokenKeys &&
|
|
11797
|
-
tokenKeys.hasOwnProperty("idToken") &&
|
|
11798
|
-
tokenKeys.hasOwnProperty("accessToken") &&
|
|
11799
|
-
tokenKeys.hasOwnProperty("refreshToken")) {
|
|
11800
|
-
return tokenKeys;
|
|
11801
|
-
}
|
|
11802
|
-
else {
|
|
11803
|
-
this.logger.error("BrowserCacheManager.getTokenKeys - Token keys found but in an unknown format. Returning empty key map.");
|
|
11804
|
-
}
|
|
11805
|
-
}
|
|
11806
|
-
else {
|
|
11807
|
-
this.logger.verbose("BrowserCacheManager.getTokenKeys - No token keys found");
|
|
11808
|
-
}
|
|
11809
|
-
return {
|
|
11810
|
-
idToken: [],
|
|
11811
|
-
accessToken: [],
|
|
11812
|
-
refreshToken: [],
|
|
11813
|
-
};
|
|
11903
|
+
return getTokenKeys(this.clientId, this.browserStorage);
|
|
11814
11904
|
}
|
|
11815
11905
|
/**
|
|
11816
11906
|
* Adds the given key to the token key map
|
|
@@ -11843,7 +11933,7 @@ class BrowserCacheManager extends CacheManager {
|
|
|
11843
11933
|
this.logger.error(`BrowserCacheManager:addTokenKey - CredentialType provided invalid. CredentialType: ${type}`);
|
|
11844
11934
|
throw createClientAuthError(unexpectedCredentialType);
|
|
11845
11935
|
}
|
|
11846
|
-
this.setItem(`${StaticCacheKeys.TOKEN_KEYS}.${this.clientId}`, JSON.stringify(tokenKeys));
|
|
11936
|
+
this.browserStorage.setItem(`${StaticCacheKeys.TOKEN_KEYS}.${this.clientId}`, JSON.stringify(tokenKeys));
|
|
11847
11937
|
}
|
|
11848
11938
|
/**
|
|
11849
11939
|
* Removes the given key from the token key map
|
|
@@ -11891,14 +11981,14 @@ class BrowserCacheManager extends CacheManager {
|
|
|
11891
11981
|
this.logger.error(`BrowserCacheManager:removeTokenKey - CredentialType provided invalid. CredentialType: ${type}`);
|
|
11892
11982
|
throw createClientAuthError(unexpectedCredentialType);
|
|
11893
11983
|
}
|
|
11894
|
-
this.setItem(`${StaticCacheKeys.TOKEN_KEYS}.${this.clientId}`, JSON.stringify(tokenKeys));
|
|
11984
|
+
this.browserStorage.setItem(`${StaticCacheKeys.TOKEN_KEYS}.${this.clientId}`, JSON.stringify(tokenKeys));
|
|
11895
11985
|
}
|
|
11896
11986
|
/**
|
|
11897
11987
|
* generates idToken entity from a string
|
|
11898
11988
|
* @param idTokenKey
|
|
11899
11989
|
*/
|
|
11900
11990
|
getIdTokenCredential(idTokenKey) {
|
|
11901
|
-
const value = this.
|
|
11991
|
+
const value = this.browserStorage.getUserData(idTokenKey);
|
|
11902
11992
|
if (!value) {
|
|
11903
11993
|
this.logger.trace("BrowserCacheManager.getIdTokenCredential: called, no cache hit");
|
|
11904
11994
|
this.removeTokenKey(idTokenKey, CredentialType.ID_TOKEN);
|
|
@@ -11917,10 +12007,10 @@ class BrowserCacheManager extends CacheManager {
|
|
|
11917
12007
|
* set IdToken credential to the platform cache
|
|
11918
12008
|
* @param idToken
|
|
11919
12009
|
*/
|
|
11920
|
-
setIdTokenCredential(idToken) {
|
|
12010
|
+
async setIdTokenCredential(idToken, correlationId) {
|
|
11921
12011
|
this.logger.trace("BrowserCacheManager.setIdTokenCredential called");
|
|
11922
12012
|
const idTokenKey = generateCredentialKey(idToken);
|
|
11923
|
-
this.
|
|
12013
|
+
await invokeAsync(this.browserStorage.setUserData.bind(this.browserStorage), PerformanceEvents.SetUserData, this.logger, this.performanceClient)(idTokenKey, JSON.stringify(idToken), correlationId);
|
|
11924
12014
|
this.addTokenKey(idTokenKey, CredentialType.ID_TOKEN);
|
|
11925
12015
|
}
|
|
11926
12016
|
/**
|
|
@@ -11928,7 +12018,7 @@ class BrowserCacheManager extends CacheManager {
|
|
|
11928
12018
|
* @param key
|
|
11929
12019
|
*/
|
|
11930
12020
|
getAccessTokenCredential(accessTokenKey) {
|
|
11931
|
-
const value = this.
|
|
12021
|
+
const value = this.browserStorage.getUserData(accessTokenKey);
|
|
11932
12022
|
if (!value) {
|
|
11933
12023
|
this.logger.trace("BrowserCacheManager.getAccessTokenCredential: called, no cache hit");
|
|
11934
12024
|
this.removeTokenKey(accessTokenKey, CredentialType.ACCESS_TOKEN);
|
|
@@ -11948,10 +12038,10 @@ class BrowserCacheManager extends CacheManager {
|
|
|
11948
12038
|
* set accessToken credential to the platform cache
|
|
11949
12039
|
* @param accessToken
|
|
11950
12040
|
*/
|
|
11951
|
-
setAccessTokenCredential(accessToken) {
|
|
12041
|
+
async setAccessTokenCredential(accessToken, correlationId) {
|
|
11952
12042
|
this.logger.trace("BrowserCacheManager.setAccessTokenCredential called");
|
|
11953
12043
|
const accessTokenKey = generateCredentialKey(accessToken);
|
|
11954
|
-
this.
|
|
12044
|
+
await invokeAsync(this.browserStorage.setUserData.bind(this.browserStorage), PerformanceEvents.SetUserData, this.logger, this.performanceClient)(accessTokenKey, JSON.stringify(accessToken), correlationId);
|
|
11955
12045
|
this.addTokenKey(accessTokenKey, CredentialType.ACCESS_TOKEN);
|
|
11956
12046
|
}
|
|
11957
12047
|
/**
|
|
@@ -11959,7 +12049,7 @@ class BrowserCacheManager extends CacheManager {
|
|
|
11959
12049
|
* @param refreshTokenKey
|
|
11960
12050
|
*/
|
|
11961
12051
|
getRefreshTokenCredential(refreshTokenKey) {
|
|
11962
|
-
const value = this.
|
|
12052
|
+
const value = this.browserStorage.getUserData(refreshTokenKey);
|
|
11963
12053
|
if (!value) {
|
|
11964
12054
|
this.logger.trace("BrowserCacheManager.getRefreshTokenCredential: called, no cache hit");
|
|
11965
12055
|
this.removeTokenKey(refreshTokenKey, CredentialType.REFRESH_TOKEN);
|
|
@@ -11979,10 +12069,10 @@ class BrowserCacheManager extends CacheManager {
|
|
|
11979
12069
|
* set refreshToken credential to the platform cache
|
|
11980
12070
|
* @param refreshToken
|
|
11981
12071
|
*/
|
|
11982
|
-
setRefreshTokenCredential(refreshToken) {
|
|
12072
|
+
async setRefreshTokenCredential(refreshToken, correlationId) {
|
|
11983
12073
|
this.logger.trace("BrowserCacheManager.setRefreshTokenCredential called");
|
|
11984
12074
|
const refreshTokenKey = generateCredentialKey(refreshToken);
|
|
11985
|
-
this.
|
|
12075
|
+
await invokeAsync(this.browserStorage.setUserData.bind(this.browserStorage), PerformanceEvents.SetUserData, this.logger, this.performanceClient)(refreshTokenKey, JSON.stringify(refreshToken), correlationId);
|
|
11986
12076
|
this.addTokenKey(refreshTokenKey, CredentialType.REFRESH_TOKEN);
|
|
11987
12077
|
}
|
|
11988
12078
|
/**
|
|
@@ -11990,7 +12080,7 @@ class BrowserCacheManager extends CacheManager {
|
|
|
11990
12080
|
* @param appMetadataKey
|
|
11991
12081
|
*/
|
|
11992
12082
|
getAppMetadata(appMetadataKey) {
|
|
11993
|
-
const value = this.getItem(appMetadataKey);
|
|
12083
|
+
const value = this.browserStorage.getItem(appMetadataKey);
|
|
11994
12084
|
if (!value) {
|
|
11995
12085
|
this.logger.trace("BrowserCacheManager.getAppMetadata: called, no cache hit");
|
|
11996
12086
|
return null;
|
|
@@ -12011,14 +12101,14 @@ class BrowserCacheManager extends CacheManager {
|
|
|
12011
12101
|
setAppMetadata(appMetadata) {
|
|
12012
12102
|
this.logger.trace("BrowserCacheManager.setAppMetadata called");
|
|
12013
12103
|
const appMetadataKey = generateAppMetadataKey(appMetadata);
|
|
12014
|
-
this.setItem(appMetadataKey, JSON.stringify(appMetadata));
|
|
12104
|
+
this.browserStorage.setItem(appMetadataKey, JSON.stringify(appMetadata));
|
|
12015
12105
|
}
|
|
12016
12106
|
/**
|
|
12017
12107
|
* fetch server telemetry entity from the platform cache
|
|
12018
12108
|
* @param serverTelemetryKey
|
|
12019
12109
|
*/
|
|
12020
12110
|
getServerTelemetry(serverTelemetryKey) {
|
|
12021
|
-
const value = this.getItem(serverTelemetryKey);
|
|
12111
|
+
const value = this.browserStorage.getItem(serverTelemetryKey);
|
|
12022
12112
|
if (!value) {
|
|
12023
12113
|
this.logger.trace("BrowserCacheManager.getServerTelemetry: called, no cache hit");
|
|
12024
12114
|
return null;
|
|
@@ -12039,7 +12129,7 @@ class BrowserCacheManager extends CacheManager {
|
|
|
12039
12129
|
*/
|
|
12040
12130
|
setServerTelemetry(serverTelemetryKey, serverTelemetry) {
|
|
12041
12131
|
this.logger.trace("BrowserCacheManager.setServerTelemetry called");
|
|
12042
|
-
this.setItem(serverTelemetryKey, JSON.stringify(serverTelemetry));
|
|
12132
|
+
this.browserStorage.setItem(serverTelemetryKey, JSON.stringify(serverTelemetry));
|
|
12043
12133
|
}
|
|
12044
12134
|
/**
|
|
12045
12135
|
*
|
|
@@ -12099,25 +12189,9 @@ class BrowserCacheManager extends CacheManager {
|
|
|
12099
12189
|
*/
|
|
12100
12190
|
getActiveAccount() {
|
|
12101
12191
|
const activeAccountKeyFilters = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT_FILTERS);
|
|
12102
|
-
const activeAccountValueFilters = this.getItem(activeAccountKeyFilters);
|
|
12192
|
+
const activeAccountValueFilters = this.browserStorage.getItem(activeAccountKeyFilters);
|
|
12103
12193
|
if (!activeAccountValueFilters) {
|
|
12104
|
-
|
|
12105
|
-
this.logger.trace("BrowserCacheManager.getActiveAccount: No active account filters cache schema found, looking for legacy schema");
|
|
12106
|
-
const activeAccountKeyLocal = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT);
|
|
12107
|
-
const activeAccountValueLocal = this.getItem(activeAccountKeyLocal);
|
|
12108
|
-
if (!activeAccountValueLocal) {
|
|
12109
|
-
this.logger.trace("BrowserCacheManager.getActiveAccount: No active account found");
|
|
12110
|
-
return null;
|
|
12111
|
-
}
|
|
12112
|
-
const activeAccount = this.getAccountInfoFilteredBy({
|
|
12113
|
-
localAccountId: activeAccountValueLocal,
|
|
12114
|
-
});
|
|
12115
|
-
if (activeAccount) {
|
|
12116
|
-
this.logger.trace("BrowserCacheManager.getActiveAccount: Legacy active account cache schema found");
|
|
12117
|
-
this.logger.trace("BrowserCacheManager.getActiveAccount: Adding active account filters cache schema");
|
|
12118
|
-
this.setActiveAccount(activeAccount);
|
|
12119
|
-
return activeAccount;
|
|
12120
|
-
}
|
|
12194
|
+
this.logger.trace("BrowserCacheManager.getActiveAccount: No active account filters found");
|
|
12121
12195
|
return null;
|
|
12122
12196
|
}
|
|
12123
12197
|
const activeAccountValueObj = this.validateAndParseJson(activeAccountValueFilters);
|
|
@@ -12138,7 +12212,6 @@ class BrowserCacheManager extends CacheManager {
|
|
|
12138
12212
|
*/
|
|
12139
12213
|
setActiveAccount(account) {
|
|
12140
12214
|
const activeAccountKey = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT_FILTERS);
|
|
12141
|
-
const activeAccountKeyLocal = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT);
|
|
12142
12215
|
if (account) {
|
|
12143
12216
|
this.logger.verbose("setActiveAccount: Active account set");
|
|
12144
12217
|
const activeAccountValue = {
|
|
@@ -12147,12 +12220,10 @@ class BrowserCacheManager extends CacheManager {
|
|
|
12147
12220
|
tenantId: account.tenantId,
|
|
12148
12221
|
};
|
|
12149
12222
|
this.browserStorage.setItem(activeAccountKey, JSON.stringify(activeAccountValue));
|
|
12150
|
-
this.browserStorage.setItem(activeAccountKeyLocal, account.localAccountId);
|
|
12151
12223
|
}
|
|
12152
12224
|
else {
|
|
12153
12225
|
this.logger.verbose("setActiveAccount: No account passed, active account not set");
|
|
12154
12226
|
this.browserStorage.removeItem(activeAccountKey);
|
|
12155
|
-
this.browserStorage.removeItem(activeAccountKeyLocal);
|
|
12156
12227
|
}
|
|
12157
12228
|
}
|
|
12158
12229
|
/**
|
|
@@ -12160,7 +12231,7 @@ class BrowserCacheManager extends CacheManager {
|
|
|
12160
12231
|
* @param throttlingCacheKey
|
|
12161
12232
|
*/
|
|
12162
12233
|
getThrottlingCache(throttlingCacheKey) {
|
|
12163
|
-
const value = this.getItem(throttlingCacheKey);
|
|
12234
|
+
const value = this.browserStorage.getItem(throttlingCacheKey);
|
|
12164
12235
|
if (!value) {
|
|
12165
12236
|
this.logger.trace("BrowserCacheManager.getThrottlingCache: called, no cache hit");
|
|
12166
12237
|
return null;
|
|
@@ -12181,7 +12252,7 @@ class BrowserCacheManager extends CacheManager {
|
|
|
12181
12252
|
*/
|
|
12182
12253
|
setThrottlingCache(throttlingCacheKey, throttlingCache) {
|
|
12183
12254
|
this.logger.trace("BrowserCacheManager.setThrottlingCache called");
|
|
12184
|
-
this.setItem(throttlingCacheKey, JSON.stringify(throttlingCache));
|
|
12255
|
+
this.browserStorage.setItem(throttlingCacheKey, JSON.stringify(throttlingCache));
|
|
12185
12256
|
}
|
|
12186
12257
|
/**
|
|
12187
12258
|
* Gets cache item with given key.
|
|
@@ -12309,8 +12380,7 @@ class BrowserCacheManager extends CacheManager {
|
|
|
12309
12380
|
generateCacheKey(key) {
|
|
12310
12381
|
const generatedKey = this.validateAndParseJson(key);
|
|
12311
12382
|
if (!generatedKey) {
|
|
12312
|
-
if (StringUtils.startsWith(key, Constants.CACHE_PREFIX)
|
|
12313
|
-
StringUtils.startsWith(key, PersistentCacheKeys.ADAL_ID_TOKEN)) {
|
|
12383
|
+
if (StringUtils.startsWith(key, Constants.CACHE_PREFIX)) {
|
|
12314
12384
|
return key;
|
|
12315
12385
|
}
|
|
12316
12386
|
return `${Constants.CACHE_PREFIX}.${this.clientId}.${key}`;
|
|
@@ -12536,59 +12606,6 @@ class BrowserCacheManager extends CacheManager {
|
|
|
12536
12606
|
this.removeTemporaryItem(key);
|
|
12537
12607
|
}
|
|
12538
12608
|
}
|
|
12539
|
-
/**
|
|
12540
|
-
* Returns username retrieved from ADAL or MSAL v1 idToken
|
|
12541
|
-
* @deprecated
|
|
12542
|
-
*/
|
|
12543
|
-
getLegacyLoginHint() {
|
|
12544
|
-
// Only check for adal/msal token if no SSO params are being used
|
|
12545
|
-
const adalIdTokenString = this.getTemporaryCache(PersistentCacheKeys.ADAL_ID_TOKEN);
|
|
12546
|
-
if (adalIdTokenString) {
|
|
12547
|
-
this.browserStorage.removeItem(PersistentCacheKeys.ADAL_ID_TOKEN);
|
|
12548
|
-
this.logger.verbose("Cached ADAL id token retrieved.");
|
|
12549
|
-
}
|
|
12550
|
-
// Check for cached MSAL v1 id token
|
|
12551
|
-
const msalIdTokenString = this.getTemporaryCache(PersistentCacheKeys.ID_TOKEN, true);
|
|
12552
|
-
if (msalIdTokenString) {
|
|
12553
|
-
this.browserStorage.removeItem(this.generateCacheKey(PersistentCacheKeys.ID_TOKEN));
|
|
12554
|
-
this.logger.verbose("Cached MSAL.js v1 id token retrieved");
|
|
12555
|
-
}
|
|
12556
|
-
const cachedIdTokenString = msalIdTokenString || adalIdTokenString;
|
|
12557
|
-
if (cachedIdTokenString) {
|
|
12558
|
-
const idTokenClaims = extractTokenClaims(cachedIdTokenString, base64Decode);
|
|
12559
|
-
if (idTokenClaims.preferred_username) {
|
|
12560
|
-
this.logger.verbose("No SSO params used and ADAL/MSAL v1 token retrieved, setting ADAL/MSAL v1 preferred_username as loginHint");
|
|
12561
|
-
return idTokenClaims.preferred_username;
|
|
12562
|
-
}
|
|
12563
|
-
else if (idTokenClaims.upn) {
|
|
12564
|
-
this.logger.verbose("No SSO params used and ADAL/MSAL v1 token retrieved, setting ADAL/MSAL v1 upn as loginHint");
|
|
12565
|
-
return idTokenClaims.upn;
|
|
12566
|
-
}
|
|
12567
|
-
else {
|
|
12568
|
-
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.");
|
|
12569
|
-
}
|
|
12570
|
-
}
|
|
12571
|
-
return null;
|
|
12572
|
-
}
|
|
12573
|
-
/**
|
|
12574
|
-
* Updates a credential's cache key if the current cache key is outdated
|
|
12575
|
-
*/
|
|
12576
|
-
updateCredentialCacheKey(currentCacheKey, credential) {
|
|
12577
|
-
const updatedCacheKey = generateCredentialKey(credential);
|
|
12578
|
-
if (currentCacheKey !== updatedCacheKey) {
|
|
12579
|
-
const cacheItem = this.getItem(currentCacheKey);
|
|
12580
|
-
if (cacheItem) {
|
|
12581
|
-
this.browserStorage.removeItem(currentCacheKey);
|
|
12582
|
-
this.setItem(updatedCacheKey, cacheItem);
|
|
12583
|
-
this.logger.verbose(`Updated an outdated ${credential.credentialType} cache key`);
|
|
12584
|
-
return updatedCacheKey;
|
|
12585
|
-
}
|
|
12586
|
-
else {
|
|
12587
|
-
this.logger.error(`Attempted to update an outdated ${credential.credentialType} cache key but no item matching the outdated key was found in storage`);
|
|
12588
|
-
}
|
|
12589
|
-
}
|
|
12590
|
-
return currentCacheKey;
|
|
12591
|
-
}
|
|
12592
12609
|
/**
|
|
12593
12610
|
* Builds credential entities from AuthenticationResult object and saves the resulting credentials to the cache
|
|
12594
12611
|
* @param result
|
|
@@ -12614,7 +12631,7 @@ class BrowserCacheManager extends CacheManager {
|
|
|
12614
12631
|
idToken: idTokenEntity,
|
|
12615
12632
|
accessToken: accessTokenEntity,
|
|
12616
12633
|
};
|
|
12617
|
-
return this.saveCacheRecord(cacheRecord);
|
|
12634
|
+
return this.saveCacheRecord(cacheRecord, result.correlationId);
|
|
12618
12635
|
}
|
|
12619
12636
|
/**
|
|
12620
12637
|
* saves a cache record
|
|
@@ -12622,9 +12639,9 @@ class BrowserCacheManager extends CacheManager {
|
|
|
12622
12639
|
* @param storeInCache {?StoreInCache}
|
|
12623
12640
|
* @param correlationId {?string} correlation id
|
|
12624
12641
|
*/
|
|
12625
|
-
async saveCacheRecord(cacheRecord,
|
|
12642
|
+
async saveCacheRecord(cacheRecord, correlationId, storeInCache) {
|
|
12626
12643
|
try {
|
|
12627
|
-
await super.saveCacheRecord(cacheRecord,
|
|
12644
|
+
await super.saveCacheRecord(cacheRecord, correlationId, storeInCache);
|
|
12628
12645
|
}
|
|
12629
12646
|
catch (e) {
|
|
12630
12647
|
if (e instanceof CacheError &&
|
|
@@ -12644,7 +12661,7 @@ class BrowserCacheManager extends CacheManager {
|
|
|
12644
12661
|
}
|
|
12645
12662
|
}
|
|
12646
12663
|
}
|
|
12647
|
-
const DEFAULT_BROWSER_CACHE_MANAGER = (clientId, logger) => {
|
|
12664
|
+
const DEFAULT_BROWSER_CACHE_MANAGER = (clientId, logger, performanceClient) => {
|
|
12648
12665
|
const cacheOptions = {
|
|
12649
12666
|
cacheLocation: BrowserCacheLocation.MemoryStorage,
|
|
12650
12667
|
temporaryCacheLocation: BrowserCacheLocation.MemoryStorage,
|
|
@@ -12653,7 +12670,7 @@ const DEFAULT_BROWSER_CACHE_MANAGER = (clientId, logger) => {
|
|
|
12653
12670
|
cacheMigrationEnabled: false,
|
|
12654
12671
|
claimsBasedCachingEnabled: false,
|
|
12655
12672
|
};
|
|
12656
|
-
return new BrowserCacheManager(clientId, cacheOptions, DEFAULT_CRYPTO_IMPLEMENTATION, logger);
|
|
12673
|
+
return new BrowserCacheManager(clientId, cacheOptions, DEFAULT_CRYPTO_IMPLEMENTATION, logger, performanceClient);
|
|
12657
12674
|
};
|
|
12658
12675
|
|
|
12659
12676
|
/*
|
|
@@ -13315,13 +13332,6 @@ class StandardInteractionClient extends BaseInteractionClient {
|
|
|
13315
13332
|
this.logger.verbosePii(`Setting validated request account: ${account.homeAccountId}`, this.correlationId);
|
|
13316
13333
|
validatedRequest.account = account;
|
|
13317
13334
|
}
|
|
13318
|
-
// Check for ADAL/MSAL v1 SSO
|
|
13319
|
-
if (!validatedRequest.loginHint && !account) {
|
|
13320
|
-
const legacyLoginHint = this.browserStorage.getLegacyLoginHint();
|
|
13321
|
-
if (legacyLoginHint) {
|
|
13322
|
-
validatedRequest.loginHint = legacyLoginHint;
|
|
13323
|
-
}
|
|
13324
|
-
}
|
|
13325
13335
|
return validatedRequest;
|
|
13326
13336
|
}
|
|
13327
13337
|
}
|
|
@@ -13725,8 +13735,8 @@ class NativeInteractionClient extends BaseInteractionClient {
|
|
|
13725
13735
|
// generate authenticationResult
|
|
13726
13736
|
const result = await this.generateAuthenticationResult(response, request, idTokenClaims, baseAccount, authority.canonicalAuthority, reqTimestamp);
|
|
13727
13737
|
// cache accounts and tokens in the appropriate storage
|
|
13728
|
-
this.cacheAccount(baseAccount);
|
|
13729
|
-
this.cacheNativeTokens(response, request, homeAccountIdentifier, idTokenClaims, response.access_token, result.tenantId, reqTimestamp);
|
|
13738
|
+
await this.cacheAccount(baseAccount);
|
|
13739
|
+
await this.cacheNativeTokens(response, request, homeAccountIdentifier, idTokenClaims, response.access_token, result.tenantId, reqTimestamp);
|
|
13730
13740
|
return result;
|
|
13731
13741
|
}
|
|
13732
13742
|
/**
|
|
@@ -13850,9 +13860,9 @@ class NativeInteractionClient extends BaseInteractionClient {
|
|
|
13850
13860
|
* cache the account entity in browser storage
|
|
13851
13861
|
* @param accountEntity
|
|
13852
13862
|
*/
|
|
13853
|
-
cacheAccount(accountEntity) {
|
|
13863
|
+
async cacheAccount(accountEntity) {
|
|
13854
13864
|
// Store the account info and hence `nativeAccountId` in browser cache
|
|
13855
|
-
this.browserStorage.setAccount(accountEntity);
|
|
13865
|
+
await this.browserStorage.setAccount(accountEntity, this.correlationId);
|
|
13856
13866
|
// Remove any existing cached tokens for this account in browser storage
|
|
13857
13867
|
this.browserStorage.removeAccountContext(accountEntity).catch((e) => {
|
|
13858
13868
|
this.logger.error(`Error occurred while removing account context from browser storage. ${e}`);
|
|
@@ -13883,7 +13893,7 @@ class NativeInteractionClient extends BaseInteractionClient {
|
|
|
13883
13893
|
idToken: cachedIdToken,
|
|
13884
13894
|
accessToken: cachedAccessToken,
|
|
13885
13895
|
};
|
|
13886
|
-
|
|
13896
|
+
return this.nativeStorageManager.saveCacheRecord(nativeCacheRecord, this.correlationId, request.storeInCache);
|
|
13887
13897
|
}
|
|
13888
13898
|
addTelemetryFromNativeResponse(response) {
|
|
13889
13899
|
const mats = this.getMATSFromResponse(response);
|
|
@@ -14318,15 +14328,15 @@ class NativeMessageHandler {
|
|
|
14318
14328
|
* @param nativeExtensionProvider
|
|
14319
14329
|
* @param authenticationScheme
|
|
14320
14330
|
*/
|
|
14321
|
-
static
|
|
14322
|
-
logger.trace("
|
|
14323
|
-
if (!config.system.
|
|
14324
|
-
logger.trace("
|
|
14331
|
+
static isPlatformBrokerAvailable(config, logger, nativeExtensionProvider, authenticationScheme) {
|
|
14332
|
+
logger.trace("isPlatformBrokerAvailable called");
|
|
14333
|
+
if (!config.system.allowPlatformBroker) {
|
|
14334
|
+
logger.trace("isPlatformBrokerAvailable: allowPlatformBroker is not enabled, returning false");
|
|
14325
14335
|
// Developer disabled WAM
|
|
14326
14336
|
return false;
|
|
14327
14337
|
}
|
|
14328
14338
|
if (!nativeExtensionProvider) {
|
|
14329
|
-
logger.trace("
|
|
14339
|
+
logger.trace("isPlatformBrokerAvailable: Platform extension provider is not initialized, returning false");
|
|
14330
14340
|
// Extension is not available
|
|
14331
14341
|
return false;
|
|
14332
14342
|
}
|
|
@@ -14334,10 +14344,10 @@ class NativeMessageHandler {
|
|
|
14334
14344
|
switch (authenticationScheme) {
|
|
14335
14345
|
case AuthenticationScheme.BEARER:
|
|
14336
14346
|
case AuthenticationScheme.POP:
|
|
14337
|
-
logger.trace("
|
|
14347
|
+
logger.trace("isPlatformBrokerAvailable: authenticationScheme is supported, returning true");
|
|
14338
14348
|
return true;
|
|
14339
14349
|
default:
|
|
14340
|
-
logger.trace("
|
|
14350
|
+
logger.trace("isPlatformBrokerAvailable: authenticationScheme is not supported, returning false");
|
|
14341
14351
|
return false;
|
|
14342
14352
|
}
|
|
14343
14353
|
}
|
|
@@ -14574,17 +14584,17 @@ class PopupClient extends StandardInteractionClient {
|
|
|
14574
14584
|
requestExtraQueryParameters: validRequest.extraQueryParameters,
|
|
14575
14585
|
account: validRequest.account,
|
|
14576
14586
|
});
|
|
14577
|
-
const
|
|
14587
|
+
const isPlatformBroker = NativeMessageHandler.isPlatformBrokerAvailable(this.config, this.logger, this.nativeMessageHandler, request.authenticationScheme);
|
|
14578
14588
|
// Start measurement for server calls with native brokering enabled
|
|
14579
14589
|
let fetchNativeAccountIdMeasurement;
|
|
14580
|
-
if (
|
|
14590
|
+
if (isPlatformBroker) {
|
|
14581
14591
|
fetchNativeAccountIdMeasurement =
|
|
14582
14592
|
this.performanceClient.startMeasurement(PerformanceEvents.FetchAccountIdWithNativeBroker, request.correlationId);
|
|
14583
14593
|
}
|
|
14584
14594
|
// Create acquire token url.
|
|
14585
14595
|
const navigateUrl = await authClient.getAuthCodeUrl({
|
|
14586
14596
|
...validRequest,
|
|
14587
|
-
|
|
14597
|
+
platformBroker: isPlatformBroker,
|
|
14588
14598
|
});
|
|
14589
14599
|
// Create popup interaction handler.
|
|
14590
14600
|
const interactionHandler = new InteractionHandler(authClient, this.browserStorage, authCodeRequest, this.logger, this.performanceClient);
|
|
@@ -15101,7 +15111,7 @@ class RedirectClient extends StandardInteractionClient {
|
|
|
15101
15111
|
// Create acquire token url.
|
|
15102
15112
|
const navigateUrl = await authClient.getAuthCodeUrl({
|
|
15103
15113
|
...validRequest,
|
|
15104
|
-
|
|
15114
|
+
platformBroker: NativeMessageHandler.isPlatformBrokerAvailable(this.config, this.logger, this.nativeMessageHandler, request.authenticationScheme),
|
|
15105
15115
|
});
|
|
15106
15116
|
const redirectStartPage = this.getRedirectStartPage(request.redirectStartPage);
|
|
15107
15117
|
this.logger.verbosePii(`Redirect start page: ${redirectStartPage}`);
|
|
@@ -15615,7 +15625,7 @@ class SilentIframeClient extends StandardInteractionClient {
|
|
|
15615
15625
|
// Create authorize request url
|
|
15616
15626
|
const navigateUrl = await invokeAsync(authClient.getAuthCodeUrl.bind(authClient), PerformanceEvents.GetAuthCodeUrl, this.logger, this.performanceClient, correlationId)({
|
|
15617
15627
|
...silentRequest,
|
|
15618
|
-
|
|
15628
|
+
platformBroker: NativeMessageHandler.isPlatformBrokerAvailable(this.config, this.logger, this.nativeMessageHandler, silentRequest.authenticationScheme),
|
|
15619
15629
|
});
|
|
15620
15630
|
// Create silent handler
|
|
15621
15631
|
const interactionHandler = new InteractionHandler(authClient, this.browserStorage, authCodeRequest, this.logger, this.performanceClient);
|
|
@@ -15730,10 +15740,11 @@ class TokenCache {
|
|
|
15730
15740
|
* @param options
|
|
15731
15741
|
* @returns `AuthenticationResult` for the response that was loaded.
|
|
15732
15742
|
*/
|
|
15733
|
-
loadExternalTokens(request, response, options) {
|
|
15743
|
+
async loadExternalTokens(request, response, options) {
|
|
15734
15744
|
if (!this.isBrowserEnvironment) {
|
|
15735
15745
|
throw createBrowserAuthError(nonBrowserEnvironment);
|
|
15736
15746
|
}
|
|
15747
|
+
const correlationId = request.correlationId || createNewGuid();
|
|
15737
15748
|
const idTokenClaims = response.id_token
|
|
15738
15749
|
? extractTokenClaims(response.id_token, base64Decode)
|
|
15739
15750
|
: undefined;
|
|
@@ -15747,10 +15758,10 @@ class TokenCache {
|
|
|
15747
15758
|
const authority = request.authority
|
|
15748
15759
|
? new Authority(Authority.generateAuthority(request.authority, request.azureCloudOptions), this.config.system.networkClient, this.storage, authorityOptions, this.logger, request.correlationId || createNewGuid())
|
|
15749
15760
|
: undefined;
|
|
15750
|
-
const cacheRecordAccount = this.loadAccount(request, options.clientInfo || response.client_info || "", idTokenClaims, authority);
|
|
15751
|
-
const idToken = this.loadIdToken(response, cacheRecordAccount.homeAccountId, cacheRecordAccount.environment, cacheRecordAccount.realm);
|
|
15752
|
-
const accessToken = this.loadAccessToken(request, response, cacheRecordAccount.homeAccountId, cacheRecordAccount.environment, cacheRecordAccount.realm, options);
|
|
15753
|
-
const refreshToken = this.loadRefreshToken(response, cacheRecordAccount.homeAccountId, cacheRecordAccount.environment);
|
|
15761
|
+
const cacheRecordAccount = await this.loadAccount(request, options.clientInfo || response.client_info || "", correlationId, idTokenClaims, authority);
|
|
15762
|
+
const idToken = await this.loadIdToken(response, cacheRecordAccount.homeAccountId, cacheRecordAccount.environment, cacheRecordAccount.realm, correlationId);
|
|
15763
|
+
const accessToken = await this.loadAccessToken(request, response, cacheRecordAccount.homeAccountId, cacheRecordAccount.environment, cacheRecordAccount.realm, options, correlationId);
|
|
15764
|
+
const refreshToken = await this.loadRefreshToken(response, cacheRecordAccount.homeAccountId, cacheRecordAccount.environment, correlationId);
|
|
15754
15765
|
return this.generateAuthenticationResult(request, {
|
|
15755
15766
|
account: cacheRecordAccount,
|
|
15756
15767
|
idToken,
|
|
@@ -15767,11 +15778,11 @@ class TokenCache {
|
|
|
15767
15778
|
* @param requestHomeAccountId
|
|
15768
15779
|
* @returns `AccountEntity`
|
|
15769
15780
|
*/
|
|
15770
|
-
loadAccount(request, clientInfo, idTokenClaims, authority) {
|
|
15781
|
+
async loadAccount(request, clientInfo, correlationId, idTokenClaims, authority) {
|
|
15771
15782
|
this.logger.verbose("TokenCache - loading account");
|
|
15772
15783
|
if (request.account) {
|
|
15773
15784
|
const accountEntity = AccountEntity.createFromAccountInfo(request.account);
|
|
15774
|
-
this.storage.setAccount(accountEntity);
|
|
15785
|
+
await this.storage.setAccount(accountEntity, correlationId);
|
|
15775
15786
|
return accountEntity;
|
|
15776
15787
|
}
|
|
15777
15788
|
else if (!authority || (!clientInfo && !idTokenClaims)) {
|
|
@@ -15783,7 +15794,7 @@ class TokenCache {
|
|
|
15783
15794
|
const cachedAccount = buildAccountToCache(this.storage, authority, homeAccountId, base64Decode, idTokenClaims, clientInfo, authority.hostnameAndPort, claimsTenantId, undefined, // authCodePayload
|
|
15784
15795
|
undefined, // nativeAccountId
|
|
15785
15796
|
this.logger);
|
|
15786
|
-
this.storage.setAccount(cachedAccount);
|
|
15797
|
+
await this.storage.setAccount(cachedAccount, correlationId);
|
|
15787
15798
|
return cachedAccount;
|
|
15788
15799
|
}
|
|
15789
15800
|
/**
|
|
@@ -15794,14 +15805,14 @@ class TokenCache {
|
|
|
15794
15805
|
* @param tenantId
|
|
15795
15806
|
* @returns `IdTokenEntity`
|
|
15796
15807
|
*/
|
|
15797
|
-
loadIdToken(response, homeAccountId, environment, tenantId) {
|
|
15808
|
+
async loadIdToken(response, homeAccountId, environment, tenantId, correlationId) {
|
|
15798
15809
|
if (!response.id_token) {
|
|
15799
15810
|
this.logger.verbose("TokenCache - no id token found in response");
|
|
15800
15811
|
return null;
|
|
15801
15812
|
}
|
|
15802
15813
|
this.logger.verbose("TokenCache - loading id token");
|
|
15803
15814
|
const idTokenEntity = createIdTokenEntity(homeAccountId, environment, response.id_token, this.config.auth.clientId, tenantId);
|
|
15804
|
-
this.storage.setIdTokenCredential(idTokenEntity);
|
|
15815
|
+
await this.storage.setIdTokenCredential(idTokenEntity, correlationId);
|
|
15805
15816
|
return idTokenEntity;
|
|
15806
15817
|
}
|
|
15807
15818
|
/**
|
|
@@ -15813,7 +15824,7 @@ class TokenCache {
|
|
|
15813
15824
|
* @param tenantId
|
|
15814
15825
|
* @returns `AccessTokenEntity`
|
|
15815
15826
|
*/
|
|
15816
|
-
loadAccessToken(request, response, homeAccountId, environment, tenantId, options) {
|
|
15827
|
+
async loadAccessToken(request, response, homeAccountId, environment, tenantId, options, correlationId) {
|
|
15817
15828
|
if (!response.access_token) {
|
|
15818
15829
|
this.logger.verbose("TokenCache - no access token found in response");
|
|
15819
15830
|
return null;
|
|
@@ -15837,7 +15848,7 @@ class TokenCache {
|
|
|
15837
15848
|
(response.ext_expires_in || response.expires_in) +
|
|
15838
15849
|
new Date().getTime() / 1000;
|
|
15839
15850
|
const accessTokenEntity = createAccessTokenEntity(homeAccountId, environment, response.access_token, this.config.auth.clientId, tenantId, scopes.printScopes(), expiresOn, extendedExpiresOn, base64Decode);
|
|
15840
|
-
this.storage.setAccessTokenCredential(accessTokenEntity);
|
|
15851
|
+
await this.storage.setAccessTokenCredential(accessTokenEntity, correlationId);
|
|
15841
15852
|
return accessTokenEntity;
|
|
15842
15853
|
}
|
|
15843
15854
|
/**
|
|
@@ -15848,7 +15859,7 @@ class TokenCache {
|
|
|
15848
15859
|
* @param environment
|
|
15849
15860
|
* @returns `RefreshTokenEntity`
|
|
15850
15861
|
*/
|
|
15851
|
-
loadRefreshToken(response, homeAccountId, environment) {
|
|
15862
|
+
async loadRefreshToken(response, homeAccountId, environment, correlationId) {
|
|
15852
15863
|
if (!response.refresh_token) {
|
|
15853
15864
|
this.logger.verbose("TokenCache - no refresh token found in response");
|
|
15854
15865
|
return null;
|
|
@@ -15856,7 +15867,7 @@ class TokenCache {
|
|
|
15856
15867
|
this.logger.verbose("TokenCache - loading refresh token");
|
|
15857
15868
|
const refreshTokenEntity = createRefreshTokenEntity(homeAccountId, environment, response.refresh_token, this.config.auth.clientId, response.foci, undefined, // userAssertionHash
|
|
15858
15869
|
response.refresh_token_expires_in);
|
|
15859
|
-
this.storage.setRefreshTokenCredential(refreshTokenEntity);
|
|
15870
|
+
await this.storage.setRefreshTokenCredential(refreshTokenEntity, correlationId);
|
|
15860
15871
|
return refreshTokenEntity;
|
|
15861
15872
|
}
|
|
15862
15873
|
/**
|
|
@@ -16052,8 +16063,8 @@ class StandardController {
|
|
|
16052
16063
|
this.eventHandler = new EventHandler(this.logger);
|
|
16053
16064
|
// Initialize the browser storage class.
|
|
16054
16065
|
this.browserStorage = this.isBrowserEnvironment
|
|
16055
|
-
? new BrowserCacheManager(this.config.auth.clientId, this.config.cache, this.browserCrypto, this.logger, buildStaticAuthorityOptions(this.config.auth)
|
|
16056
|
-
: DEFAULT_BROWSER_CACHE_MANAGER(this.config.auth.clientId, this.logger);
|
|
16066
|
+
? new BrowserCacheManager(this.config.auth.clientId, this.config.cache, this.browserCrypto, this.logger, this.performanceClient, buildStaticAuthorityOptions(this.config.auth))
|
|
16067
|
+
: DEFAULT_BROWSER_CACHE_MANAGER(this.config.auth.clientId, this.logger, this.performanceClient);
|
|
16057
16068
|
// initialize in memory storage for native flows
|
|
16058
16069
|
const nativeCacheOptions = {
|
|
16059
16070
|
cacheLocation: BrowserCacheLocation.MemoryStorage,
|
|
@@ -16063,7 +16074,7 @@ class StandardController {
|
|
|
16063
16074
|
cacheMigrationEnabled: false,
|
|
16064
16075
|
claimsBasedCachingEnabled: false,
|
|
16065
16076
|
};
|
|
16066
|
-
this.nativeInternalStorage = new BrowserCacheManager(this.config.auth.clientId, nativeCacheOptions, this.browserCrypto, this.logger,
|
|
16077
|
+
this.nativeInternalStorage = new BrowserCacheManager(this.config.auth.clientId, nativeCacheOptions, this.browserCrypto, this.logger, this.performanceClient);
|
|
16067
16078
|
// Initialize the token cache
|
|
16068
16079
|
this.tokenCache = new TokenCache(this.config, this.browserStorage, this.logger, this.browserCrypto);
|
|
16069
16080
|
this.activeSilentTokenRequests = new Map();
|
|
@@ -16106,10 +16117,11 @@ class StandardController {
|
|
|
16106
16117
|
return;
|
|
16107
16118
|
}
|
|
16108
16119
|
const initCorrelationId = request?.correlationId || this.getRequestCorrelationId();
|
|
16109
|
-
const
|
|
16120
|
+
const allowPlatformBroker = this.config.system.allowPlatformBroker;
|
|
16110
16121
|
const initMeasurement = this.performanceClient.startMeasurement(PerformanceEvents.InitializeClientApplication, initCorrelationId);
|
|
16111
16122
|
this.eventHandler.emitEvent(EventType.INITIALIZE_START);
|
|
16112
|
-
|
|
16123
|
+
await invokeAsync(this.browserStorage.initialize.bind(this.browserStorage), PerformanceEvents.InitializeCache, this.logger, this.performanceClient, initCorrelationId)(initCorrelationId);
|
|
16124
|
+
if (allowPlatformBroker) {
|
|
16113
16125
|
try {
|
|
16114
16126
|
this.nativeExtensionProvider =
|
|
16115
16127
|
await NativeMessageHandler.createProvider(this.logger, this.config.system.nativeBrokerHandshakeTimeout, this.performanceClient);
|
|
@@ -16124,7 +16136,10 @@ class StandardController {
|
|
|
16124
16136
|
}
|
|
16125
16137
|
this.initialized = true;
|
|
16126
16138
|
this.eventHandler.emitEvent(EventType.INITIALIZE_END);
|
|
16127
|
-
initMeasurement.end({
|
|
16139
|
+
initMeasurement.end({
|
|
16140
|
+
allowPlatformBroker: allowPlatformBroker,
|
|
16141
|
+
success: true,
|
|
16142
|
+
});
|
|
16128
16143
|
}
|
|
16129
16144
|
// #region Redirect Flow
|
|
16130
16145
|
/**
|
|
@@ -16168,7 +16183,7 @@ class StandardController {
|
|
|
16168
16183
|
const loggedInAccounts = this.getAllAccounts();
|
|
16169
16184
|
const request = this.browserStorage.getCachedNativeRequest();
|
|
16170
16185
|
const useNative = request &&
|
|
16171
|
-
NativeMessageHandler.
|
|
16186
|
+
NativeMessageHandler.isPlatformBrokerAvailable(this.config, this.logger, this.nativeExtensionProvider) &&
|
|
16172
16187
|
this.nativeExtensionProvider &&
|
|
16173
16188
|
!hash;
|
|
16174
16189
|
const correlationId = useNative
|
|
@@ -16297,7 +16312,8 @@ class StandardController {
|
|
|
16297
16312
|
this.eventHandler.emitEvent(EventType.LOGIN_START, exports.InteractionType.Redirect, request);
|
|
16298
16313
|
}
|
|
16299
16314
|
let result;
|
|
16300
|
-
if (this.nativeExtensionProvider &&
|
|
16315
|
+
if (this.nativeExtensionProvider &&
|
|
16316
|
+
this.canUsePlatformBroker(request)) {
|
|
16301
16317
|
const nativeClient = new NativeInteractionClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, ApiId.acquireTokenRedirect, this.performanceClient, this.nativeExtensionProvider, this.getNativeAccountId(request), this.nativeInternalStorage, correlationId);
|
|
16302
16318
|
result = nativeClient
|
|
16303
16319
|
.acquireTokenRedirect(request, atrMeasurement)
|
|
@@ -16368,7 +16384,7 @@ class StandardController {
|
|
|
16368
16384
|
this.eventHandler.emitEvent(EventType.LOGIN_START, exports.InteractionType.Popup, request);
|
|
16369
16385
|
}
|
|
16370
16386
|
let result;
|
|
16371
|
-
if (this.
|
|
16387
|
+
if (this.canUsePlatformBroker(request)) {
|
|
16372
16388
|
result = this.acquireTokenNative({
|
|
16373
16389
|
...request,
|
|
16374
16390
|
correlationId,
|
|
@@ -16485,7 +16501,7 @@ class StandardController {
|
|
|
16485
16501
|
this.logger.verbose("ssoSilent called", correlationId);
|
|
16486
16502
|
this.eventHandler.emitEvent(EventType.SSO_SILENT_START, exports.InteractionType.Silent, validRequest);
|
|
16487
16503
|
let result;
|
|
16488
|
-
if (this.
|
|
16504
|
+
if (this.canUsePlatformBroker(validRequest)) {
|
|
16489
16505
|
result = this.acquireTokenNative(validRequest, ApiId.ssoSilent).catch((e) => {
|
|
16490
16506
|
// If native token acquisition fails for availability reasons fallback to standard flow
|
|
16491
16507
|
if (e instanceof NativeAuthError && isFatalNativeAuthError(e)) {
|
|
@@ -16583,7 +16599,7 @@ class StandardController {
|
|
|
16583
16599
|
return await response;
|
|
16584
16600
|
}
|
|
16585
16601
|
else if (request.nativeAccountId) {
|
|
16586
|
-
if (this.
|
|
16602
|
+
if (this.canUsePlatformBroker(request, request.nativeAccountId)) {
|
|
16587
16603
|
const result = await this.acquireTokenNative({
|
|
16588
16604
|
...request,
|
|
16589
16605
|
correlationId,
|
|
@@ -16830,7 +16846,7 @@ class StandardController {
|
|
|
16830
16846
|
this.logger.verbose("hydrateCache called");
|
|
16831
16847
|
// Account gets saved to browser storage regardless of native or not
|
|
16832
16848
|
const accountEntity = AccountEntity.createFromAccountInfo(result.account, result.cloudGraphHostName, result.msGraphHost);
|
|
16833
|
-
this.browserStorage.setAccount(accountEntity);
|
|
16849
|
+
await this.browserStorage.setAccount(accountEntity, result.correlationId);
|
|
16834
16850
|
if (result.fromNativeBroker) {
|
|
16835
16851
|
this.logger.verbose("Response was from native broker, storing in-memory");
|
|
16836
16852
|
// Tokens from native broker are stored in-memory
|
|
@@ -16854,13 +16870,13 @@ class StandardController {
|
|
|
16854
16870
|
return nativeClient.acquireToken(request);
|
|
16855
16871
|
}
|
|
16856
16872
|
/**
|
|
16857
|
-
* Returns boolean indicating if this request can use the
|
|
16873
|
+
* Returns boolean indicating if this request can use the platform broker
|
|
16858
16874
|
* @param request
|
|
16859
16875
|
*/
|
|
16860
|
-
|
|
16861
|
-
this.logger.trace("
|
|
16862
|
-
if (!NativeMessageHandler.
|
|
16863
|
-
this.logger.trace("
|
|
16876
|
+
canUsePlatformBroker(request, accountId) {
|
|
16877
|
+
this.logger.trace("canUsePlatformBroker called");
|
|
16878
|
+
if (!NativeMessageHandler.isPlatformBrokerAvailable(this.config, this.logger, this.nativeExtensionProvider, request.authenticationScheme)) {
|
|
16879
|
+
this.logger.trace("canUsePlatformBroker: isPlatformBrokerAvailable returned false, returning false");
|
|
16864
16880
|
return false;
|
|
16865
16881
|
}
|
|
16866
16882
|
if (request.prompt) {
|
|
@@ -16868,15 +16884,15 @@ class StandardController {
|
|
|
16868
16884
|
case PromptValue.NONE:
|
|
16869
16885
|
case PromptValue.CONSENT:
|
|
16870
16886
|
case PromptValue.LOGIN:
|
|
16871
|
-
this.logger.trace("
|
|
16887
|
+
this.logger.trace("canUsePlatformBroker: prompt is compatible with platform broker flow");
|
|
16872
16888
|
break;
|
|
16873
16889
|
default:
|
|
16874
|
-
this.logger.trace(`
|
|
16890
|
+
this.logger.trace(`canUsePlatformBroker: prompt = ${request.prompt} is not compatible with platform broker flow, returning false`);
|
|
16875
16891
|
return false;
|
|
16876
16892
|
}
|
|
16877
16893
|
}
|
|
16878
16894
|
if (!accountId && !this.getNativeAccountId(request)) {
|
|
16879
|
-
this.logger.trace("
|
|
16895
|
+
this.logger.trace("canUsePlatformBroker: nativeAccountId is not available, returning false");
|
|
16880
16896
|
return false;
|
|
16881
16897
|
}
|
|
16882
16898
|
return true;
|
|
@@ -17317,7 +17333,7 @@ class StandardController {
|
|
|
17317
17333
|
* @returns
|
|
17318
17334
|
*/
|
|
17319
17335
|
async acquireTokenSilentNoIframe(silentRequest, cacheLookupPolicy) {
|
|
17320
|
-
if (NativeMessageHandler.
|
|
17336
|
+
if (NativeMessageHandler.isPlatformBrokerAvailable(this.config, this.logger, this.nativeExtensionProvider, silentRequest.authenticationScheme) &&
|
|
17321
17337
|
silentRequest.account.nativeAccountId) {
|
|
17322
17338
|
this.logger.verbose("acquireTokenSilent - attempting to acquire token from native platform");
|
|
17323
17339
|
return this.acquireTokenNative(silentRequest, ApiId.acquireTokenSilent_silentFlow).catch(async (e) => {
|
|
@@ -17607,8 +17623,8 @@ class NestedAppAuthController {
|
|
|
17607
17623
|
: DEFAULT_CRYPTO_IMPLEMENTATION;
|
|
17608
17624
|
// Initialize the browser storage class.
|
|
17609
17625
|
this.browserStorage = this.operatingContext.isBrowserEnvironment()
|
|
17610
|
-
? new BrowserCacheManager(this.config.auth.clientId, this.config.cache, this.browserCrypto, this.logger, buildStaticAuthorityOptions(this.config.auth))
|
|
17611
|
-
: DEFAULT_BROWSER_CACHE_MANAGER(this.config.auth.clientId, this.logger);
|
|
17626
|
+
? new BrowserCacheManager(this.config.auth.clientId, this.config.cache, this.browserCrypto, this.logger, this.performanceClient, buildStaticAuthorityOptions(this.config.auth))
|
|
17627
|
+
: DEFAULT_BROWSER_CACHE_MANAGER(this.config.auth.clientId, this.logger, this.performanceClient);
|
|
17612
17628
|
this.eventHandler = new EventHandler(this.logger);
|
|
17613
17629
|
this.nestedAppAuthAdapter = new NestedAppAuthAdapter(this.config.auth.clientId, this.config.auth.clientCapabilities, this.browserCrypto, this.logger);
|
|
17614
17630
|
// Set the active account if available
|
|
@@ -17631,8 +17647,9 @@ class NestedAppAuthController {
|
|
|
17631
17647
|
* Specific implementation of initialize function for NestedAppAuthController
|
|
17632
17648
|
* @returns
|
|
17633
17649
|
*/
|
|
17634
|
-
initialize() {
|
|
17635
|
-
|
|
17650
|
+
async initialize(request) {
|
|
17651
|
+
const initCorrelationId = request?.correlationId || createNewGuid();
|
|
17652
|
+
await this.browserStorage.initialize(initCorrelationId);
|
|
17636
17653
|
return Promise.resolve();
|
|
17637
17654
|
}
|
|
17638
17655
|
/**
|
|
@@ -18058,7 +18075,7 @@ class NestedAppAuthController {
|
|
|
18058
18075
|
async hydrateCache(result, request) {
|
|
18059
18076
|
this.logger.verbose("hydrateCache called");
|
|
18060
18077
|
const accountEntity = AccountEntity.createFromAccountInfo(result.account, result.cloudGraphHostName, result.msGraphHost);
|
|
18061
|
-
this.browserStorage.setAccount(accountEntity);
|
|
18078
|
+
await this.browserStorage.setAccount(accountEntity, result.correlationId);
|
|
18062
18079
|
return this.browserStorage.hydrateCache(result, request);
|
|
18063
18080
|
}
|
|
18064
18081
|
}
|
|
@@ -18490,8 +18507,8 @@ class UnknownOperatingContextController {
|
|
|
18490
18507
|
: DEFAULT_CRYPTO_IMPLEMENTATION;
|
|
18491
18508
|
// Initialize the browser storage class.
|
|
18492
18509
|
this.browserStorage = this.isBrowserEnvironment
|
|
18493
|
-
? new BrowserCacheManager(this.config.auth.clientId, this.config.cache, this.browserCrypto, this.logger,
|
|
18494
|
-
: DEFAULT_BROWSER_CACHE_MANAGER(this.config.auth.clientId, this.logger);
|
|
18510
|
+
? new BrowserCacheManager(this.config.auth.clientId, this.config.cache, this.browserCrypto, this.logger, this.performanceClient, undefined)
|
|
18511
|
+
: DEFAULT_BROWSER_CACHE_MANAGER(this.config.auth.clientId, this.logger, this.performanceClient);
|
|
18495
18512
|
}
|
|
18496
18513
|
getBrowserStorage() {
|
|
18497
18514
|
return this.browserStorage;
|
|
@@ -19216,42 +19233,6 @@ const stubbedPublicClientApplication = {
|
|
|
19216
19233
|
},
|
|
19217
19234
|
};
|
|
19218
19235
|
|
|
19219
|
-
/*
|
|
19220
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
19221
|
-
* Licensed under the MIT License.
|
|
19222
|
-
*/
|
|
19223
|
-
/**
|
|
19224
|
-
* @deprecated This class will be removed in a future major version
|
|
19225
|
-
*/
|
|
19226
|
-
class BrowserStorage {
|
|
19227
|
-
constructor(cacheLocation) {
|
|
19228
|
-
if (cacheLocation === BrowserCacheLocation.LocalStorage) {
|
|
19229
|
-
this.windowStorage = new LocalStorage();
|
|
19230
|
-
}
|
|
19231
|
-
else if (cacheLocation === BrowserCacheLocation.SessionStorage) {
|
|
19232
|
-
this.windowStorage = new SessionStorage();
|
|
19233
|
-
}
|
|
19234
|
-
else {
|
|
19235
|
-
throw createBrowserConfigurationAuthError(storageNotSupported);
|
|
19236
|
-
}
|
|
19237
|
-
}
|
|
19238
|
-
getItem(key) {
|
|
19239
|
-
return this.windowStorage.getItem(key);
|
|
19240
|
-
}
|
|
19241
|
-
setItem(key, value) {
|
|
19242
|
-
this.windowStorage.setItem(key, value);
|
|
19243
|
-
}
|
|
19244
|
-
removeItem(key) {
|
|
19245
|
-
this.windowStorage.removeItem(key);
|
|
19246
|
-
}
|
|
19247
|
-
getKeys() {
|
|
19248
|
-
return Object.keys(this.windowStorage);
|
|
19249
|
-
}
|
|
19250
|
-
containsKey(key) {
|
|
19251
|
-
return this.windowStorage.hasOwnProperty(key);
|
|
19252
|
-
}
|
|
19253
|
-
}
|
|
19254
|
-
|
|
19255
19236
|
/*
|
|
19256
19237
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
19257
19238
|
* Licensed under the MIT License.
|
|
@@ -19639,7 +19620,6 @@ exports.BrowserConfigurationAuthErrorCodes = BrowserConfigurationAuthErrorCodes;
|
|
|
19639
19620
|
exports.BrowserConfigurationAuthErrorMessage = BrowserConfigurationAuthErrorMessage;
|
|
19640
19621
|
exports.BrowserPerformanceClient = BrowserPerformanceClient;
|
|
19641
19622
|
exports.BrowserPerformanceMeasurement = BrowserPerformanceMeasurement;
|
|
19642
|
-
exports.BrowserStorage = BrowserStorage;
|
|
19643
19623
|
exports.BrowserUtils = BrowserUtils;
|
|
19644
19624
|
exports.CacheLookupPolicy = CacheLookupPolicy;
|
|
19645
19625
|
exports.ClientAuthError = ClientAuthError;
|