@azure/msal-browser 3.0.0-beta.1 → 3.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/README.md +19 -80
- package/dist/app/IPublicClientApplication.d.ts +1 -0
- package/dist/app/IPublicClientApplication.d.ts.map +1 -1
- package/dist/app/{IPublicClientApplication.js → IPublicClientApplication.mjs} +6 -3
- package/dist/app/IPublicClientApplication.mjs.map +1 -0
- package/dist/app/PublicClientApplication.d.ts +7 -0
- package/dist/app/PublicClientApplication.d.ts.map +1 -1
- package/dist/app/{PublicClientApplication.js → PublicClientApplication.mjs} +14 -5
- package/dist/app/PublicClientApplication.mjs.map +1 -0
- package/dist/broker/nativeBroker/NativeMessageHandler.d.ts.map +1 -1
- package/dist/broker/nativeBroker/{NativeMessageHandler.js → NativeMessageHandler.mjs} +9 -9
- package/dist/broker/nativeBroker/NativeMessageHandler.mjs.map +1 -0
- package/dist/broker/nativeBroker/NativeRequest.d.ts +2 -1
- package/dist/broker/nativeBroker/NativeRequest.d.ts.map +1 -1
- package/dist/cache/{AsyncMemoryStorage.js → AsyncMemoryStorage.mjs} +5 -5
- package/dist/cache/AsyncMemoryStorage.mjs.map +1 -0
- package/dist/cache/BrowserCacheManager.d.ts +8 -0
- package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
- package/dist/cache/{BrowserCacheManager.js → BrowserCacheManager.mjs} +25 -8
- package/dist/cache/BrowserCacheManager.mjs.map +1 -0
- package/dist/cache/{BrowserStorage.js → BrowserStorage.mjs} +4 -4
- package/dist/cache/BrowserStorage.mjs.map +1 -0
- package/dist/cache/CryptoKeyStore.d.ts +1 -1
- package/dist/cache/CryptoKeyStore.d.ts.map +1 -1
- package/dist/cache/{CryptoKeyStore.js → CryptoKeyStore.mjs} +3 -3
- package/dist/cache/CryptoKeyStore.mjs.map +1 -0
- package/dist/cache/{DatabaseStorage.js → DatabaseStorage.mjs} +4 -4
- package/dist/cache/DatabaseStorage.mjs.map +1 -0
- package/dist/cache/ITokenCache.d.ts.map +1 -1
- package/dist/cache/{MemoryStorage.js → MemoryStorage.mjs} +2 -2
- package/dist/cache/MemoryStorage.mjs.map +1 -0
- package/dist/cache/TokenCache.d.ts.map +1 -1
- package/dist/cache/{TokenCache.js → TokenCache.mjs} +22 -20
- package/dist/cache/TokenCache.mjs.map +1 -0
- package/dist/config/Configuration.d.ts +10 -2
- package/dist/config/Configuration.d.ts.map +1 -1
- package/dist/config/{Configuration.js → Configuration.mjs} +41 -8
- package/dist/config/Configuration.mjs.map +1 -0
- package/dist/controllers/{ControllerFactory.js → ControllerFactory.mjs} +7 -7
- package/dist/controllers/ControllerFactory.mjs.map +1 -0
- package/dist/controllers/IController.d.ts +1 -0
- package/dist/controllers/IController.d.ts.map +1 -1
- package/dist/controllers/StandardController.d.ts +7 -0
- package/dist/controllers/StandardController.d.ts.map +1 -1
- package/dist/controllers/{StandardController.js → StandardController.mjs} +77 -60
- package/dist/controllers/StandardController.mjs.map +1 -0
- package/dist/crypto/{BrowserCrypto.js → BrowserCrypto.mjs} +5 -5
- package/dist/crypto/BrowserCrypto.mjs.map +1 -0
- package/dist/crypto/CryptoOps.d.ts.map +1 -1
- package/dist/crypto/{CryptoOps.js → CryptoOps.mjs} +12 -12
- package/dist/crypto/CryptoOps.mjs.map +1 -0
- package/dist/crypto/{GuidGenerator.js → GuidGenerator.mjs} +3 -3
- package/dist/crypto/GuidGenerator.mjs.map +1 -0
- package/dist/crypto/{ModernBrowserCrypto.js → ModernBrowserCrypto.mjs} +3 -3
- package/dist/crypto/ModernBrowserCrypto.mjs.map +1 -0
- package/dist/crypto/{PkceGenerator.js → PkceGenerator.mjs} +4 -4
- package/dist/crypto/PkceGenerator.mjs.map +1 -0
- package/dist/crypto/{SignedHttpRequest.js → SignedHttpRequest.mjs} +4 -4
- package/dist/crypto/SignedHttpRequest.mjs.map +1 -0
- package/dist/encode/{Base64Decode.js → Base64Decode.mjs} +3 -3
- package/dist/encode/Base64Decode.mjs.map +1 -0
- package/dist/encode/{Base64Encode.js → Base64Encode.mjs} +3 -3
- package/dist/encode/Base64Encode.mjs.map +1 -0
- package/dist/error/BrowserAuthError.d.ts +2 -2
- package/dist/error/BrowserAuthError.d.ts.map +1 -1
- package/dist/error/{BrowserAuthError.js → BrowserAuthError.mjs} +7 -7
- package/dist/error/BrowserAuthError.mjs.map +1 -0
- package/dist/error/{BrowserConfigurationAuthError.js → BrowserConfigurationAuthError.mjs} +2 -2
- package/dist/error/BrowserConfigurationAuthError.mjs.map +1 -0
- package/dist/error/NativeAuthError.d.ts +1 -1
- package/dist/error/NativeAuthError.d.ts.map +1 -1
- package/dist/error/{NativeAuthError.js → NativeAuthError.mjs} +3 -3
- package/dist/error/NativeAuthError.mjs.map +1 -0
- package/dist/event/{EventHandler.js → EventHandler.mjs} +3 -3
- package/dist/event/EventHandler.mjs.map +1 -0
- package/dist/event/EventMessage.d.ts.map +1 -1
- package/dist/event/{EventMessage.js → EventMessage.mjs} +4 -4
- package/dist/event/EventMessage.mjs.map +1 -0
- package/dist/event/EventType.d.ts +1 -1
- package/dist/event/EventType.d.ts.map +1 -1
- package/dist/event/{EventType.js → EventType.mjs} +3 -3
- package/dist/event/EventType.mjs.map +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/{index.js → index.mjs} +18 -16
- package/dist/index.mjs.map +1 -0
- package/dist/interaction_client/BaseInteractionClient.d.ts.map +1 -1
- package/dist/interaction_client/{BaseInteractionClient.js → BaseInteractionClient.mjs} +6 -5
- package/dist/interaction_client/BaseInteractionClient.mjs.map +1 -0
- package/dist/interaction_client/{HybridSpaAuthorizationCodeClient.js → HybridSpaAuthorizationCodeClient.mjs} +2 -2
- package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs.map +1 -0
- package/dist/interaction_client/NativeInteractionClient.d.ts +7 -10
- package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
- package/dist/interaction_client/{NativeInteractionClient.js → NativeInteractionClient.mjs} +58 -33
- package/dist/interaction_client/NativeInteractionClient.mjs.map +1 -0
- package/dist/interaction_client/PopupClient.d.ts +4 -0
- package/dist/interaction_client/PopupClient.d.ts.map +1 -1
- package/dist/interaction_client/{PopupClient.js → PopupClient.mjs} +57 -18
- package/dist/interaction_client/PopupClient.mjs.map +1 -0
- package/dist/interaction_client/RedirectClient.d.ts.map +1 -1
- package/dist/interaction_client/{RedirectClient.js → RedirectClient.mjs} +23 -11
- package/dist/interaction_client/RedirectClient.mjs.map +1 -0
- package/dist/interaction_client/{SilentAuthCodeClient.js → SilentAuthCodeClient.mjs} +7 -7
- package/dist/interaction_client/SilentAuthCodeClient.mjs.map +1 -0
- package/dist/interaction_client/{SilentCacheClient.js → SilentCacheClient.mjs} +9 -9
- package/dist/interaction_client/SilentCacheClient.mjs.map +1 -0
- package/dist/interaction_client/{SilentIframeClient.js → SilentIframeClient.mjs} +11 -11
- package/dist/interaction_client/SilentIframeClient.mjs.map +1 -0
- package/dist/interaction_client/{SilentRefreshClient.js → SilentRefreshClient.mjs} +8 -8
- package/dist/interaction_client/SilentRefreshClient.mjs.map +1 -0
- package/dist/interaction_client/StandardInteractionClient.d.ts.map +1 -1
- package/dist/interaction_client/{StandardInteractionClient.js → StandardInteractionClient.mjs} +14 -12
- package/dist/interaction_client/StandardInteractionClient.mjs.map +1 -0
- package/dist/interaction_handler/{InteractionHandler.js → InteractionHandler.mjs} +5 -5
- package/dist/interaction_handler/InteractionHandler.mjs.map +1 -0
- package/dist/interaction_handler/{RedirectHandler.js → RedirectHandler.mjs} +6 -6
- package/dist/interaction_handler/RedirectHandler.mjs.map +1 -0
- package/dist/interaction_handler/{SilentHandler.js → SilentHandler.mjs} +5 -5
- package/dist/interaction_handler/SilentHandler.mjs.map +1 -0
- package/dist/internals.d.ts +1 -3
- package/dist/internals.d.ts.map +1 -1
- package/dist/internals.mjs +28 -0
- package/dist/internals.mjs.map +1 -0
- package/dist/navigation/{NavigationClient.js → NavigationClient.mjs} +2 -2
- package/dist/navigation/NavigationClient.mjs.map +1 -0
- package/dist/network/{FetchClient.js → FetchClient.mjs} +4 -4
- package/dist/network/FetchClient.mjs.map +1 -0
- package/dist/network/{XhrClient.js → XhrClient.mjs} +4 -4
- package/dist/network/XhrClient.mjs.map +1 -0
- package/dist/operatingcontext/{BaseOperatingContext.js → BaseOperatingContext.mjs} +4 -4
- package/dist/operatingcontext/BaseOperatingContext.mjs.map +1 -0
- package/dist/operatingcontext/{StandardOperatingContext.js → StandardOperatingContext.mjs} +3 -3
- package/dist/operatingcontext/StandardOperatingContext.mjs.map +1 -0
- package/dist/operatingcontext/{TeamsAppOperatingContext.js → TeamsAppOperatingContext.mjs} +3 -3
- package/dist/operatingcontext/TeamsAppOperatingContext.mjs.map +1 -0
- package/dist/packageMetadata.d.ts +1 -1
- package/dist/packageMetadata.d.ts.map +1 -1
- package/dist/packageMetadata.mjs +8 -0
- package/dist/packageMetadata.mjs.map +1 -0
- package/dist/request/PopupRequest.d.ts +3 -1
- package/dist/request/PopupRequest.d.ts.map +1 -1
- package/dist/request/RedirectRequest.d.ts +3 -1
- package/dist/request/RedirectRequest.d.ts.map +1 -1
- package/dist/request/SilentRequest.d.ts +2 -0
- package/dist/request/SilentRequest.d.ts.map +1 -1
- package/dist/request/SsoSilentRequest.d.ts +5 -2
- package/dist/request/SsoSilentRequest.d.ts.map +1 -1
- package/dist/response/AuthenticationResult.d.ts.map +1 -1
- package/dist/telemetry/BrowserPerformanceClient.d.ts +3 -2
- package/dist/telemetry/BrowserPerformanceClient.d.ts.map +1 -1
- package/dist/telemetry/{BrowserPerformanceClient.js → BrowserPerformanceClient.mjs} +16 -12
- package/dist/telemetry/BrowserPerformanceClient.mjs.map +1 -0
- package/dist/telemetry/{BrowserPerformanceMeasurement.js → BrowserPerformanceMeasurement.mjs} +2 -2
- package/dist/telemetry/BrowserPerformanceMeasurement.mjs.map +1 -0
- package/dist/utils/BrowserConstants.d.ts +10 -10
- package/dist/utils/BrowserConstants.d.ts.map +1 -1
- package/dist/utils/{BrowserConstants.js → BrowserConstants.mjs} +2 -2
- package/dist/utils/BrowserConstants.mjs.map +1 -0
- package/dist/utils/{BrowserProtocolUtils.js → BrowserProtocolUtils.mjs} +2 -2
- package/dist/utils/BrowserProtocolUtils.mjs.map +1 -0
- package/dist/utils/{BrowserStringUtils.js → BrowserStringUtils.mjs} +2 -2
- package/dist/utils/BrowserStringUtils.mjs.map +1 -0
- package/dist/utils/BrowserUtils.d.ts +2 -3
- package/dist/utils/BrowserUtils.d.ts.map +1 -1
- package/dist/utils/{BrowserUtils.js → BrowserUtils.mjs} +10 -11
- package/dist/utils/BrowserUtils.mjs.map +1 -0
- package/dist/utils/{MathUtils.js → MathUtils.mjs} +2 -2
- package/dist/utils/MathUtils.mjs.map +1 -0
- package/lib/{msal-browser.cjs.js → msal-browser.cjs} +989 -672
- package/lib/msal-browser.cjs.map +1 -0
- package/lib/msal-browser.js +988 -671
- package/lib/msal-browser.js.map +1 -1
- package/lib/msal-browser.min.js +62 -62
- package/package.json +19 -15
- package/dist/app/IPublicClientApplication.js.map +0 -1
- package/dist/app/PublicClientApplication.js.map +0 -1
- package/dist/broker/nativeBroker/NativeMessageHandler.js.map +0 -1
- package/dist/cache/AsyncMemoryStorage.js.map +0 -1
- package/dist/cache/BrowserCacheManager.js.map +0 -1
- package/dist/cache/BrowserStorage.js.map +0 -1
- package/dist/cache/CryptoKeyStore.js.map +0 -1
- package/dist/cache/DatabaseStorage.js.map +0 -1
- package/dist/cache/MemoryStorage.js.map +0 -1
- package/dist/cache/TokenCache.js.map +0 -1
- package/dist/cache/entities/CacheRecord.d.ts +0 -6
- package/dist/cache/entities/CacheRecord.d.ts.map +0 -1
- package/dist/cache/entities/CacheRecord.js +0 -17
- package/dist/cache/entities/CacheRecord.js.map +0 -1
- package/dist/config/Configuration.js.map +0 -1
- package/dist/controllers/ControllerFactory.js.map +0 -1
- package/dist/controllers/StandardController.js.map +0 -1
- package/dist/crypto/BrowserCrypto.js.map +0 -1
- package/dist/crypto/CryptoOps.js.map +0 -1
- package/dist/crypto/GuidGenerator.js.map +0 -1
- package/dist/crypto/ModernBrowserCrypto.js.map +0 -1
- package/dist/crypto/PkceGenerator.js.map +0 -1
- package/dist/crypto/SignedHttpRequest.js.map +0 -1
- package/dist/encode/Base64Decode.js.map +0 -1
- package/dist/encode/Base64Encode.js.map +0 -1
- package/dist/error/BrowserAuthError.js.map +0 -1
- package/dist/error/BrowserConfigurationAuthError.js.map +0 -1
- package/dist/error/NativeAuthError.js.map +0 -1
- package/dist/event/EventHandler.js.map +0 -1
- package/dist/event/EventMessage.js.map +0 -1
- package/dist/event/EventType.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/interaction_client/BaseInteractionClient.js.map +0 -1
- package/dist/interaction_client/HybridSpaAuthorizationCodeClient.js.map +0 -1
- package/dist/interaction_client/NativeInteractionClient.js.map +0 -1
- package/dist/interaction_client/PopupClient.js.map +0 -1
- package/dist/interaction_client/RedirectClient.js.map +0 -1
- package/dist/interaction_client/SilentAuthCodeClient.js.map +0 -1
- package/dist/interaction_client/SilentCacheClient.js.map +0 -1
- package/dist/interaction_client/SilentIframeClient.js.map +0 -1
- package/dist/interaction_client/SilentRefreshClient.js.map +0 -1
- package/dist/interaction_client/StandardInteractionClient.js.map +0 -1
- package/dist/interaction_handler/InteractionHandler.js.map +0 -1
- package/dist/interaction_handler/RedirectHandler.js.map +0 -1
- package/dist/interaction_handler/SilentHandler.js.map +0 -1
- package/dist/internals.js +0 -25
- package/dist/internals.js.map +0 -1
- package/dist/navigation/NavigationClient.js.map +0 -1
- package/dist/network/FetchClient.js.map +0 -1
- package/dist/network/XhrClient.js.map +0 -1
- package/dist/operatingcontext/BaseOperatingContext.js.map +0 -1
- package/dist/operatingcontext/StandardOperatingContext.js.map +0 -1
- package/dist/operatingcontext/TeamsAppOperatingContext.js.map +0 -1
- package/dist/packageMetadata.js +0 -8
- package/dist/packageMetadata.js.map +0 -1
- package/dist/telemetry/BrowserPerformanceClient.js.map +0 -1
- package/dist/telemetry/BrowserPerformanceMeasurement.js.map +0 -1
- package/dist/utils/BrowserConstants.js.map +0 -1
- package/dist/utils/BrowserProtocolUtils.js.map +0 -1
- package/dist/utils/BrowserStringUtils.js.map +0 -1
- package/dist/utils/BrowserUtils.js.map +0 -1
- package/dist/utils/MathUtils.js.map +0 -1
- package/lib/msal-browser.cjs.js.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/*! @azure/msal-browser v3.0.
|
|
1
|
+
/*! @azure/msal-browser v3.0.1 2023-08-11 */
|
|
2
2
|
'use strict';
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
|
-
/*! @azure/msal-common v14.0.
|
|
5
|
+
/*! @azure/msal-common v14.0.1 2023-08-11 */
|
|
6
6
|
/*
|
|
7
7
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
8
8
|
* Licensed under the MIT License.
|
|
@@ -199,11 +199,17 @@ const CodeChallengeMethodValues = {
|
|
|
199
199
|
S256: "S256",
|
|
200
200
|
};
|
|
201
201
|
/**
|
|
202
|
-
* allowed values for
|
|
202
|
+
* allowed values for server response type
|
|
203
203
|
*/
|
|
204
|
-
const
|
|
204
|
+
const ServerResponseType = {
|
|
205
205
|
QUERY: "query",
|
|
206
206
|
FRAGMENT: "fragment",
|
|
207
|
+
};
|
|
208
|
+
/**
|
|
209
|
+
* allowed values for response_mode
|
|
210
|
+
*/
|
|
211
|
+
const ResponseMode = {
|
|
212
|
+
...ServerResponseType,
|
|
207
213
|
FORM_POST: "form_post",
|
|
208
214
|
};
|
|
209
215
|
/**
|
|
@@ -356,7 +362,7 @@ const JsonTypes = {
|
|
|
356
362
|
Pop: "pop",
|
|
357
363
|
};
|
|
358
364
|
|
|
359
|
-
/*! @azure/msal-common v14.0.
|
|
365
|
+
/*! @azure/msal-common v14.0.1 2023-08-11 */
|
|
360
366
|
|
|
361
367
|
/*
|
|
362
368
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -410,7 +416,7 @@ class AuthError extends Error {
|
|
|
410
416
|
}
|
|
411
417
|
}
|
|
412
418
|
|
|
413
|
-
/*! @azure/msal-common v14.0.
|
|
419
|
+
/*! @azure/msal-common v14.0.1 2023-08-11 */
|
|
414
420
|
|
|
415
421
|
/*
|
|
416
422
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -455,7 +461,7 @@ const DEFAULT_CRYPTO_IMPLEMENTATION = {
|
|
|
455
461
|
},
|
|
456
462
|
};
|
|
457
463
|
|
|
458
|
-
/*! @azure/msal-common v14.0.
|
|
464
|
+
/*! @azure/msal-common v14.0.1 2023-08-11 */
|
|
459
465
|
|
|
460
466
|
/*
|
|
461
467
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -977,7 +983,7 @@ class ClientAuthError extends AuthError {
|
|
|
977
983
|
}
|
|
978
984
|
}
|
|
979
985
|
|
|
980
|
-
/*! @azure/msal-common v14.0.
|
|
986
|
+
/*! @azure/msal-common v14.0.1 2023-08-11 */
|
|
981
987
|
|
|
982
988
|
/*
|
|
983
989
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1104,7 +1110,7 @@ class StringUtils {
|
|
|
1104
1110
|
}
|
|
1105
1111
|
}
|
|
1106
1112
|
|
|
1107
|
-
/*! @azure/msal-common v14.0.
|
|
1113
|
+
/*! @azure/msal-common v14.0.1 2023-08-11 */
|
|
1108
1114
|
|
|
1109
1115
|
/*
|
|
1110
1116
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1304,12 +1310,12 @@ class Logger {
|
|
|
1304
1310
|
}
|
|
1305
1311
|
}
|
|
1306
1312
|
|
|
1307
|
-
/*! @azure/msal-common v14.0.
|
|
1313
|
+
/*! @azure/msal-common v14.0.1 2023-08-11 */
|
|
1308
1314
|
/* eslint-disable header/header */
|
|
1309
1315
|
const name$1 = "@azure/msal-common";
|
|
1310
|
-
const version$1 = "14.0.
|
|
1316
|
+
const version$1 = "14.0.1";
|
|
1311
1317
|
|
|
1312
|
-
/*! @azure/msal-common v14.0.
|
|
1318
|
+
/*! @azure/msal-common v14.0.1 2023-08-11 */
|
|
1313
1319
|
/*
|
|
1314
1320
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1315
1321
|
* Licensed under the MIT License.
|
|
@@ -1321,15 +1327,15 @@ const AzureCloudInstance = {
|
|
|
1321
1327
|
AzurePublic: "https://login.microsoftonline.com",
|
|
1322
1328
|
// Microsoft PPE
|
|
1323
1329
|
AzurePpe: "https://login.windows-ppe.net",
|
|
1324
|
-
// Microsoft Chinese national cloud
|
|
1330
|
+
// Microsoft Chinese national/regional cloud
|
|
1325
1331
|
AzureChina: "https://login.chinacloudapi.cn",
|
|
1326
|
-
// Microsoft German national cloud ("Black Forest")
|
|
1332
|
+
// Microsoft German national/regional cloud ("Black Forest")
|
|
1327
1333
|
AzureGermany: "https://login.microsoftonline.de",
|
|
1328
1334
|
// US Government cloud
|
|
1329
1335
|
AzureUsGovernment: "https://login.microsoftonline.us",
|
|
1330
1336
|
};
|
|
1331
1337
|
|
|
1332
|
-
/*! @azure/msal-common v14.0.
|
|
1338
|
+
/*! @azure/msal-common v14.0.1 2023-08-11 */
|
|
1333
1339
|
|
|
1334
1340
|
/*
|
|
1335
1341
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1429,12 +1435,20 @@ const ClientConfigurationErrorMessage = {
|
|
|
1429
1435
|
},
|
|
1430
1436
|
invalidAuthenticationHeader: {
|
|
1431
1437
|
code: "invalid_authentication_header",
|
|
1432
|
-
desc: "Invalid authentication header provided"
|
|
1438
|
+
desc: "Invalid authentication header provided",
|
|
1439
|
+
},
|
|
1440
|
+
cannotSetOIDCOptions: {
|
|
1441
|
+
code: "cannot_set_OIDCOptions",
|
|
1442
|
+
desc: "Cannot set OIDCOptions parameter. Please change the protocol mode to OIDC or use a non-Microsoft authority.",
|
|
1443
|
+
},
|
|
1444
|
+
cannotAllowNativeBroker: {
|
|
1445
|
+
code: "cannot_allow_native_broker",
|
|
1446
|
+
desc: "Cannot set allowNativeBroker parameter to true when not in AAD protocol mode.",
|
|
1433
1447
|
},
|
|
1434
1448
|
authorityMismatch: {
|
|
1435
1449
|
code: "authority_mismatch",
|
|
1436
|
-
desc: "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."
|
|
1437
|
-
}
|
|
1450
|
+
desc: "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.",
|
|
1451
|
+
},
|
|
1438
1452
|
};
|
|
1439
1453
|
/**
|
|
1440
1454
|
* Error thrown when there is an error in configuration of the MSAL.js library.
|
|
@@ -1583,6 +1597,18 @@ class ClientConfigurationError extends ClientAuthError {
|
|
|
1583
1597
|
static createInvalidAuthenticationHeaderError(invalidHeaderName, details) {
|
|
1584
1598
|
return new ClientConfigurationError(ClientConfigurationErrorMessage.invalidAuthenticationHeader.code, `${ClientConfigurationErrorMessage.invalidAuthenticationHeader.desc}. Invalid header: ${invalidHeaderName}. Details: ${details}`);
|
|
1585
1599
|
}
|
|
1600
|
+
/**
|
|
1601
|
+
* Throws error when provided non-default OIDCOptions when not in OIDC protocol mode
|
|
1602
|
+
*/
|
|
1603
|
+
static createCannotSetOIDCOptionsError() {
|
|
1604
|
+
return new ClientConfigurationError(ClientConfigurationErrorMessage.cannotSetOIDCOptions.code, ClientConfigurationErrorMessage.cannotSetOIDCOptions.desc);
|
|
1605
|
+
}
|
|
1606
|
+
/**
|
|
1607
|
+
* Throws error when allowNativeBroker is set to true when not in AAD protocol mode
|
|
1608
|
+
*/
|
|
1609
|
+
static createCannotAllowNativeBrokerError() {
|
|
1610
|
+
return new ClientConfigurationError(ClientConfigurationErrorMessage.cannotAllowNativeBroker.code, ClientConfigurationErrorMessage.cannotAllowNativeBroker.desc);
|
|
1611
|
+
}
|
|
1586
1612
|
/**
|
|
1587
1613
|
* Create an error when the authority provided in request does not match authority provided in account or MSAL.js configuration.
|
|
1588
1614
|
*/
|
|
@@ -1591,7 +1617,7 @@ class ClientConfigurationError extends ClientAuthError {
|
|
|
1591
1617
|
}
|
|
1592
1618
|
}
|
|
1593
1619
|
|
|
1594
|
-
/*! @azure/msal-common v14.0.
|
|
1620
|
+
/*! @azure/msal-common v14.0.1 2023-08-11 */
|
|
1595
1621
|
|
|
1596
1622
|
/*
|
|
1597
1623
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1791,7 +1817,7 @@ class ScopeSet {
|
|
|
1791
1817
|
}
|
|
1792
1818
|
}
|
|
1793
1819
|
|
|
1794
|
-
/*! @azure/msal-common v14.0.
|
|
1820
|
+
/*! @azure/msal-common v14.0.1 2023-08-11 */
|
|
1795
1821
|
|
|
1796
1822
|
/*
|
|
1797
1823
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1831,7 +1857,7 @@ function buildClientInfoFromHomeAccountId(homeAccountId) {
|
|
|
1831
1857
|
};
|
|
1832
1858
|
}
|
|
1833
1859
|
|
|
1834
|
-
/*! @azure/msal-common v14.0.
|
|
1860
|
+
/*! @azure/msal-common v14.0.1 2023-08-11 */
|
|
1835
1861
|
/*
|
|
1836
1862
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1837
1863
|
* Licensed under the MIT License.
|
|
@@ -1843,10 +1869,23 @@ const AuthorityType = {
|
|
|
1843
1869
|
Default: 0,
|
|
1844
1870
|
Adfs: 1,
|
|
1845
1871
|
Dsts: 2,
|
|
1846
|
-
Ciam: 3
|
|
1872
|
+
Ciam: 3,
|
|
1873
|
+
};
|
|
1874
|
+
|
|
1875
|
+
/*! @azure/msal-common v14.0.1 2023-08-11 */
|
|
1876
|
+
/*
|
|
1877
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1878
|
+
* Licensed under the MIT License.
|
|
1879
|
+
*/
|
|
1880
|
+
/**
|
|
1881
|
+
* Protocol modes supported by MSAL.
|
|
1882
|
+
*/
|
|
1883
|
+
const ProtocolMode = {
|
|
1884
|
+
AAD: "AAD",
|
|
1885
|
+
OIDC: "OIDC",
|
|
1847
1886
|
};
|
|
1848
1887
|
|
|
1849
|
-
/*! @azure/msal-common v14.0.
|
|
1888
|
+
/*! @azure/msal-common v14.0.1 2023-08-11 */
|
|
1850
1889
|
|
|
1851
1890
|
/*
|
|
1852
1891
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1868,7 +1907,6 @@ const AuthorityType = {
|
|
|
1868
1907
|
* username: primary username that represents the user, usually corresponds to preferred_username in the v2 endpt
|
|
1869
1908
|
* authorityType: Accounts authority type as a string
|
|
1870
1909
|
* name: Full name for the account, including given name and family name,
|
|
1871
|
-
* clientInfo: Full base64 encoded client info received from ESTS
|
|
1872
1910
|
* lastModificationTime: last time this entity was modified in the cache
|
|
1873
1911
|
* lastModificationApp:
|
|
1874
1912
|
* idTokenClaims: Object containing claims parsed from ID token
|
|
@@ -1895,24 +1933,6 @@ class AccountEntity {
|
|
|
1895
1933
|
localAccountId: this.localAccountId,
|
|
1896
1934
|
});
|
|
1897
1935
|
}
|
|
1898
|
-
/**
|
|
1899
|
-
* returns the type of the cache (in this case account)
|
|
1900
|
-
*/
|
|
1901
|
-
generateType() {
|
|
1902
|
-
switch (this.authorityType) {
|
|
1903
|
-
case CacheAccountType.ADFS_ACCOUNT_TYPE:
|
|
1904
|
-
return CacheType.ADFS;
|
|
1905
|
-
case CacheAccountType.MSAV1_ACCOUNT_TYPE:
|
|
1906
|
-
return CacheType.MSA;
|
|
1907
|
-
case CacheAccountType.MSSTS_ACCOUNT_TYPE:
|
|
1908
|
-
return CacheType.MSSTS;
|
|
1909
|
-
case CacheAccountType.GENERIC_ACCOUNT_TYPE:
|
|
1910
|
-
return CacheType.GENERIC;
|
|
1911
|
-
default: {
|
|
1912
|
-
throw ClientAuthError.createUnexpectedAccountTypeError();
|
|
1913
|
-
}
|
|
1914
|
-
}
|
|
1915
|
-
}
|
|
1916
1936
|
/**
|
|
1917
1937
|
* Returns the AccountInfo interface for this account.
|
|
1918
1938
|
*/
|
|
@@ -1926,6 +1946,7 @@ class AccountEntity {
|
|
|
1926
1946
|
name: this.name,
|
|
1927
1947
|
idTokenClaims: this.idTokenClaims,
|
|
1928
1948
|
nativeAccountId: this.nativeAccountId,
|
|
1949
|
+
authorityType: this.authorityType,
|
|
1929
1950
|
};
|
|
1930
1951
|
}
|
|
1931
1952
|
/**
|
|
@@ -1942,84 +1963,74 @@ class AccountEntity {
|
|
|
1942
1963
|
}
|
|
1943
1964
|
/**
|
|
1944
1965
|
* Build Account cache from IdToken, clientInfo and authority/policy. Associated with AAD.
|
|
1945
|
-
* @param
|
|
1946
|
-
* @param authority
|
|
1947
|
-
* @param idToken
|
|
1948
|
-
* @param policy
|
|
1966
|
+
* @param accountDetails
|
|
1949
1967
|
*/
|
|
1950
|
-
static createAccount(
|
|
1968
|
+
static createAccount(accountDetails, authority) {
|
|
1951
1969
|
const account = new AccountEntity();
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1970
|
+
if (authority.authorityType === AuthorityType.Adfs) {
|
|
1971
|
+
account.authorityType = CacheAccountType.ADFS_ACCOUNT_TYPE;
|
|
1972
|
+
}
|
|
1973
|
+
else if (authority.protocolMode === ProtocolMode.AAD) {
|
|
1974
|
+
account.authorityType = CacheAccountType.MSSTS_ACCOUNT_TYPE;
|
|
1975
|
+
}
|
|
1976
|
+
else {
|
|
1977
|
+
account.authorityType = CacheAccountType.GENERIC_ACCOUNT_TYPE;
|
|
1978
|
+
}
|
|
1979
|
+
account.clientInfo = accountDetails.clientInfo;
|
|
1980
|
+
account.homeAccountId = accountDetails.homeAccountId;
|
|
1981
|
+
account.nativeAccountId = accountDetails.nativeAccountId;
|
|
1982
|
+
const env = accountDetails.environment ||
|
|
1983
|
+
(authority && authority.getPreferredCache());
|
|
1957
1984
|
if (!env) {
|
|
1958
1985
|
throw ClientAuthError.createInvalidCacheEnvironmentError();
|
|
1959
1986
|
}
|
|
1960
1987
|
account.environment = env;
|
|
1961
1988
|
// non AAD scenarios can have empty realm
|
|
1962
|
-
account.realm =
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
account.
|
|
1984
|
-
account.msGraphHost = msGraphHost;
|
|
1989
|
+
account.realm =
|
|
1990
|
+
accountDetails.idTokenClaims.tid || Constants.EMPTY_STRING;
|
|
1991
|
+
account.idTokenClaims = accountDetails.idTokenClaims;
|
|
1992
|
+
// How do you account for MSA CID here?
|
|
1993
|
+
account.localAccountId =
|
|
1994
|
+
accountDetails.idTokenClaims.oid ||
|
|
1995
|
+
accountDetails.idTokenClaims.sub ||
|
|
1996
|
+
Constants.EMPTY_STRING;
|
|
1997
|
+
/*
|
|
1998
|
+
* In B2C scenarios the emails claim is used instead of preferred_username and it is an array.
|
|
1999
|
+
* In most cases it will contain a single email. This field should not be relied upon if a custom
|
|
2000
|
+
* policy is configured to return more than 1 email.
|
|
2001
|
+
*/
|
|
2002
|
+
const preferredUsername = accountDetails.idTokenClaims.preferred_username ||
|
|
2003
|
+
accountDetails.idTokenClaims.upn;
|
|
2004
|
+
const email = accountDetails.idTokenClaims.emails
|
|
2005
|
+
? accountDetails.idTokenClaims.emails[0]
|
|
2006
|
+
: null;
|
|
2007
|
+
account.username = preferredUsername || email || Constants.EMPTY_STRING;
|
|
2008
|
+
account.name = accountDetails.idTokenClaims.name;
|
|
2009
|
+
account.cloudGraphHostName = accountDetails.cloudGraphHostName;
|
|
2010
|
+
account.msGraphHost = accountDetails.msGraphHost;
|
|
1985
2011
|
return account;
|
|
1986
2012
|
}
|
|
1987
2013
|
/**
|
|
1988
|
-
*
|
|
1989
|
-
* @param
|
|
1990
|
-
* @param
|
|
2014
|
+
* Creates an AccountEntity object from AccountInfo
|
|
2015
|
+
* @param accountInfo
|
|
2016
|
+
* @param cloudGraphHostName
|
|
2017
|
+
* @param msGraphHost
|
|
2018
|
+
* @returns
|
|
1991
2019
|
*/
|
|
1992
|
-
static
|
|
2020
|
+
static createFromAccountInfo(accountInfo, cloudGraphHostName, msGraphHost) {
|
|
1993
2021
|
const account = new AccountEntity();
|
|
1994
2022
|
account.authorityType =
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
account.
|
|
1999
|
-
|
|
2000
|
-
account.
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
}
|
|
2005
|
-
if (idToken) {
|
|
2006
|
-
// How do you account for MSA CID here?
|
|
2007
|
-
account.localAccountId =
|
|
2008
|
-
idToken?.claims?.oid ||
|
|
2009
|
-
idToken?.claims?.sub ||
|
|
2010
|
-
Constants.EMPTY_STRING;
|
|
2011
|
-
// upn claim for most ADFS scenarios
|
|
2012
|
-
account.username = idToken?.claims?.upn || Constants.EMPTY_STRING;
|
|
2013
|
-
account.name = idToken?.claims?.name || Constants.EMPTY_STRING;
|
|
2014
|
-
account.idTokenClaims = idToken?.claims;
|
|
2015
|
-
}
|
|
2016
|
-
account.environment = env;
|
|
2023
|
+
accountInfo.authorityType || CacheAccountType.GENERIC_ACCOUNT_TYPE;
|
|
2024
|
+
account.homeAccountId = accountInfo.homeAccountId;
|
|
2025
|
+
account.localAccountId = accountInfo.localAccountId;
|
|
2026
|
+
account.nativeAccountId = accountInfo.nativeAccountId;
|
|
2027
|
+
account.realm = accountInfo.tenantId;
|
|
2028
|
+
account.environment = accountInfo.environment;
|
|
2029
|
+
account.username = accountInfo.username;
|
|
2030
|
+
account.name = accountInfo.name;
|
|
2031
|
+
account.idTokenClaims = accountInfo.idTokenClaims;
|
|
2017
2032
|
account.cloudGraphHostName = cloudGraphHostName;
|
|
2018
2033
|
account.msGraphHost = msGraphHost;
|
|
2019
|
-
/*
|
|
2020
|
-
* add uniqueName to claims
|
|
2021
|
-
* account.name = idToken.claims.uniqueName;
|
|
2022
|
-
*/
|
|
2023
2034
|
return account;
|
|
2024
2035
|
}
|
|
2025
2036
|
/**
|
|
@@ -2027,9 +2038,9 @@ class AccountEntity {
|
|
|
2027
2038
|
* @param serverClientInfo
|
|
2028
2039
|
* @param authType
|
|
2029
2040
|
*/
|
|
2030
|
-
static generateHomeAccountId(serverClientInfo, authType, logger, cryptoObj,
|
|
2031
|
-
const accountId =
|
|
2032
|
-
?
|
|
2041
|
+
static generateHomeAccountId(serverClientInfo, authType, logger, cryptoObj, idTokenClaims) {
|
|
2042
|
+
const accountId = idTokenClaims?.sub
|
|
2043
|
+
? idTokenClaims.sub
|
|
2033
2044
|
: Constants.EMPTY_STRING;
|
|
2034
2045
|
// since ADFS does not have tid and does not set client_info
|
|
2035
2046
|
if (authType === AuthorityType.Adfs ||
|
|
@@ -2097,7 +2108,7 @@ class AccountEntity {
|
|
|
2097
2108
|
}
|
|
2098
2109
|
}
|
|
2099
2110
|
|
|
2100
|
-
/*! @azure/msal-common v14.0.
|
|
2111
|
+
/*! @azure/msal-common v14.0.1 2023-08-11 */
|
|
2101
2112
|
|
|
2102
2113
|
/*
|
|
2103
2114
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2148,7 +2159,7 @@ class AuthToken {
|
|
|
2148
2159
|
}
|
|
2149
2160
|
}
|
|
2150
2161
|
|
|
2151
|
-
/*! @azure/msal-common v14.0.
|
|
2162
|
+
/*! @azure/msal-common v14.0.1 2023-08-11 */
|
|
2152
2163
|
|
|
2153
2164
|
/*
|
|
2154
2165
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2214,20 +2225,21 @@ class CacheManager {
|
|
|
2214
2225
|
* saves a cache record
|
|
2215
2226
|
* @param cacheRecord
|
|
2216
2227
|
*/
|
|
2217
|
-
async saveCacheRecord(cacheRecord) {
|
|
2228
|
+
async saveCacheRecord(cacheRecord, storeInCache) {
|
|
2218
2229
|
if (!cacheRecord) {
|
|
2219
2230
|
throw ClientAuthError.createNullOrUndefinedCacheRecord();
|
|
2220
2231
|
}
|
|
2221
2232
|
if (!!cacheRecord.account) {
|
|
2222
2233
|
this.setAccount(cacheRecord.account);
|
|
2223
2234
|
}
|
|
2224
|
-
if (!!cacheRecord.idToken) {
|
|
2235
|
+
if (!!cacheRecord.idToken && storeInCache?.idToken !== false) {
|
|
2225
2236
|
this.setIdTokenCredential(cacheRecord.idToken);
|
|
2226
2237
|
}
|
|
2227
|
-
if (!!cacheRecord.accessToken) {
|
|
2238
|
+
if (!!cacheRecord.accessToken && storeInCache?.accessToken !== false) {
|
|
2228
2239
|
await this.saveAccessToken(cacheRecord.accessToken);
|
|
2229
2240
|
}
|
|
2230
|
-
if (!!cacheRecord.refreshToken
|
|
2241
|
+
if (!!cacheRecord.refreshToken &&
|
|
2242
|
+
storeInCache?.refreshToken !== false) {
|
|
2231
2243
|
this.setRefreshTokenCredential(cacheRecord.refreshToken);
|
|
2232
2244
|
}
|
|
2233
2245
|
if (!!cacheRecord.appMetadata) {
|
|
@@ -2641,7 +2653,11 @@ class CacheManager {
|
|
|
2641
2653
|
return null;
|
|
2642
2654
|
}
|
|
2643
2655
|
else if (numIdTokens > 1) {
|
|
2644
|
-
|
|
2656
|
+
this.commonLogger.info("CacheManager:getIdToken - Multiple id tokens found, clearing them");
|
|
2657
|
+
idTokens.forEach((idToken) => {
|
|
2658
|
+
this.removeIdToken(idToken.generateCredentialKey());
|
|
2659
|
+
});
|
|
2660
|
+
return null;
|
|
2645
2661
|
}
|
|
2646
2662
|
this.commonLogger.info("CacheManager:getIdToken - Returning id token");
|
|
2647
2663
|
return idTokens[0];
|
|
@@ -2751,7 +2767,11 @@ class CacheManager {
|
|
|
2751
2767
|
return null;
|
|
2752
2768
|
}
|
|
2753
2769
|
else if (numAccessTokens > 1) {
|
|
2754
|
-
|
|
2770
|
+
this.commonLogger.info("CacheManager:getAccessToken - Multiple access tokens found, clearing them");
|
|
2771
|
+
accessTokens.forEach((accessToken) => {
|
|
2772
|
+
this.removeAccessToken(accessToken.generateCredentialKey());
|
|
2773
|
+
});
|
|
2774
|
+
return null;
|
|
2755
2775
|
}
|
|
2756
2776
|
this.commonLogger.info("CacheManager:getAccessToken - Returning access token");
|
|
2757
2777
|
return accessTokens[0];
|
|
@@ -3162,7 +3182,7 @@ class DefaultStorageClass extends CacheManager {
|
|
|
3162
3182
|
}
|
|
3163
3183
|
}
|
|
3164
3184
|
|
|
3165
|
-
/*! @azure/msal-common v14.0.
|
|
3185
|
+
/*! @azure/msal-common v14.0.1 2023-08-11 */
|
|
3166
3186
|
|
|
3167
3187
|
/*
|
|
3168
3188
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3256,8 +3276,15 @@ function buildAuthOptions(authOptions) {
|
|
|
3256
3276
|
...authOptions,
|
|
3257
3277
|
};
|
|
3258
3278
|
}
|
|
3279
|
+
/**
|
|
3280
|
+
* Returns true if config has protocolMode set to ProtocolMode.OIDC, false otherwise
|
|
3281
|
+
* @param ClientConfiguration
|
|
3282
|
+
*/
|
|
3283
|
+
function isOidcProtocolMode(config) {
|
|
3284
|
+
return (config.authOptions.authority.options.protocolMode === ProtocolMode.OIDC);
|
|
3285
|
+
}
|
|
3259
3286
|
|
|
3260
|
-
/*! @azure/msal-common v14.0.
|
|
3287
|
+
/*! @azure/msal-common v14.0.1 2023-08-11 */
|
|
3261
3288
|
|
|
3262
3289
|
/*
|
|
3263
3290
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3274,7 +3301,7 @@ class ServerError extends AuthError {
|
|
|
3274
3301
|
}
|
|
3275
3302
|
}
|
|
3276
3303
|
|
|
3277
|
-
/*! @azure/msal-common v14.0.
|
|
3304
|
+
/*! @azure/msal-common v14.0.1 2023-08-11 */
|
|
3278
3305
|
|
|
3279
3306
|
/*
|
|
3280
3307
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3371,7 +3398,7 @@ class ThrottlingUtils {
|
|
|
3371
3398
|
}
|
|
3372
3399
|
}
|
|
3373
3400
|
|
|
3374
|
-
/*! @azure/msal-common v14.0.
|
|
3401
|
+
/*! @azure/msal-common v14.0.1 2023-08-11 */
|
|
3375
3402
|
|
|
3376
3403
|
/*
|
|
3377
3404
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3407,7 +3434,7 @@ class NetworkManager {
|
|
|
3407
3434
|
}
|
|
3408
3435
|
}
|
|
3409
3436
|
|
|
3410
|
-
/*! @azure/msal-common v14.0.
|
|
3437
|
+
/*! @azure/msal-common v14.0.1 2023-08-11 */
|
|
3411
3438
|
/*
|
|
3412
3439
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3413
3440
|
* Licensed under the MIT License.
|
|
@@ -3417,7 +3444,7 @@ const CcsCredentialType = {
|
|
|
3417
3444
|
UPN: "UPN",
|
|
3418
3445
|
};
|
|
3419
3446
|
|
|
3420
|
-
/*! @azure/msal-common v14.0.
|
|
3447
|
+
/*! @azure/msal-common v14.0.1 2023-08-11 */
|
|
3421
3448
|
|
|
3422
3449
|
/*
|
|
3423
3450
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3498,11 +3525,11 @@ class RequestValidator {
|
|
|
3498
3525
|
}
|
|
3499
3526
|
});
|
|
3500
3527
|
// remove empty string parameters
|
|
3501
|
-
return Object.fromEntries(Object.entries(eQParams).filter(kv => kv[1] !== ""));
|
|
3528
|
+
return Object.fromEntries(Object.entries(eQParams).filter((kv) => kv[1] !== ""));
|
|
3502
3529
|
}
|
|
3503
3530
|
}
|
|
3504
3531
|
|
|
3505
|
-
/*! @azure/msal-common v14.0.
|
|
3532
|
+
/*! @azure/msal-common v14.0.1 2023-08-11 */
|
|
3506
3533
|
|
|
3507
3534
|
/*
|
|
3508
3535
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3542,9 +3569,15 @@ class RequestParameterBuilder {
|
|
|
3542
3569
|
* @param scopeSet
|
|
3543
3570
|
* @param addOidcScopes
|
|
3544
3571
|
*/
|
|
3545
|
-
addScopes(scopes, addOidcScopes = true) {
|
|
3572
|
+
addScopes(scopes, addOidcScopes = true, defaultScopes = OIDC_DEFAULT_SCOPES) {
|
|
3573
|
+
// Always add openid to the scopes when adding OIDC scopes
|
|
3574
|
+
if (addOidcScopes &&
|
|
3575
|
+
!defaultScopes.includes("openid") &&
|
|
3576
|
+
!scopes.includes("openid")) {
|
|
3577
|
+
defaultScopes.push("openid");
|
|
3578
|
+
}
|
|
3546
3579
|
const requestScopes = addOidcScopes
|
|
3547
|
-
? [...(scopes || []), ...
|
|
3580
|
+
? [...(scopes || []), ...defaultScopes]
|
|
3548
3581
|
: scopes || [];
|
|
3549
3582
|
const scopeSet = new ScopeSet(requestScopes);
|
|
3550
3583
|
this.parameters.set(AADServerParamKeys.SCOPE, encodeURIComponent(scopeSet.printScopes()));
|
|
@@ -3879,7 +3912,7 @@ class RequestParameterBuilder {
|
|
|
3879
3912
|
}
|
|
3880
3913
|
}
|
|
3881
3914
|
|
|
3882
|
-
/*! @azure/msal-common v14.0.
|
|
3915
|
+
/*! @azure/msal-common v14.0.1 2023-08-11 */
|
|
3883
3916
|
|
|
3884
3917
|
/*
|
|
3885
3918
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3974,7 +4007,7 @@ class BaseClient {
|
|
|
3974
4007
|
}
|
|
3975
4008
|
}
|
|
3976
4009
|
|
|
3977
|
-
/*! @azure/msal-common v14.0.
|
|
4010
|
+
/*! @azure/msal-common v14.0.1 2023-08-11 */
|
|
3978
4011
|
|
|
3979
4012
|
/*
|
|
3980
4013
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4113,7 +4146,7 @@ class CredentialEntity {
|
|
|
4113
4146
|
}
|
|
4114
4147
|
}
|
|
4115
4148
|
|
|
4116
|
-
/*! @azure/msal-common v14.0.
|
|
4149
|
+
/*! @azure/msal-common v14.0.1 2023-08-11 */
|
|
4117
4150
|
|
|
4118
4151
|
/*
|
|
4119
4152
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4172,7 +4205,7 @@ class IdTokenEntity extends CredentialEntity {
|
|
|
4172
4205
|
}
|
|
4173
4206
|
}
|
|
4174
4207
|
|
|
4175
|
-
/*! @azure/msal-common v14.0.
|
|
4208
|
+
/*! @azure/msal-common v14.0.1 2023-08-11 */
|
|
4176
4209
|
/*
|
|
4177
4210
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4178
4211
|
* Licensed under the MIT License.
|
|
@@ -4219,7 +4252,7 @@ class TimeUtils {
|
|
|
4219
4252
|
}
|
|
4220
4253
|
}
|
|
4221
4254
|
|
|
4222
|
-
/*! @azure/msal-common v14.0.
|
|
4255
|
+
/*! @azure/msal-common v14.0.1 2023-08-11 */
|
|
4223
4256
|
|
|
4224
4257
|
/*
|
|
4225
4258
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4333,7 +4366,7 @@ class AccessTokenEntity extends CredentialEntity {
|
|
|
4333
4366
|
}
|
|
4334
4367
|
}
|
|
4335
4368
|
|
|
4336
|
-
/*! @azure/msal-common v14.0.
|
|
4369
|
+
/*! @azure/msal-common v14.0.1 2023-08-11 */
|
|
4337
4370
|
|
|
4338
4371
|
/*
|
|
4339
4372
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4395,7 +4428,7 @@ class RefreshTokenEntity extends CredentialEntity {
|
|
|
4395
4428
|
}
|
|
4396
4429
|
}
|
|
4397
4430
|
|
|
4398
|
-
/*! @azure/msal-common v14.0.
|
|
4431
|
+
/*! @azure/msal-common v14.0.1 2023-08-11 */
|
|
4399
4432
|
|
|
4400
4433
|
/*
|
|
4401
4434
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4476,12 +4509,12 @@ class InteractionRequiredAuthError extends AuthError {
|
|
|
4476
4509
|
}
|
|
4477
4510
|
}
|
|
4478
4511
|
|
|
4479
|
-
/*! @azure/msal-common v14.0.
|
|
4512
|
+
/*! @azure/msal-common v14.0.1 2023-08-11 */
|
|
4480
4513
|
/*
|
|
4481
4514
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4482
4515
|
* Licensed under the MIT License.
|
|
4483
4516
|
*/
|
|
4484
|
-
|
|
4517
|
+
class CacheRecord {
|
|
4485
4518
|
constructor(accountEntity, idTokenEntity, accessTokenEntity, refreshTokenEntity, appMetadataEntity) {
|
|
4486
4519
|
this.account = accountEntity || null;
|
|
4487
4520
|
this.idToken = idTokenEntity || null;
|
|
@@ -4489,9 +4522,9 @@ let CacheRecord$1 = class CacheRecord {
|
|
|
4489
4522
|
this.refreshToken = refreshTokenEntity || null;
|
|
4490
4523
|
this.appMetadata = appMetadataEntity || null;
|
|
4491
4524
|
}
|
|
4492
|
-
}
|
|
4525
|
+
}
|
|
4493
4526
|
|
|
4494
|
-
/*! @azure/msal-common v14.0.
|
|
4527
|
+
/*! @azure/msal-common v14.0.1 2023-08-11 */
|
|
4495
4528
|
|
|
4496
4529
|
/*
|
|
4497
4530
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4565,7 +4598,7 @@ class ProtocolUtils {
|
|
|
4565
4598
|
}
|
|
4566
4599
|
}
|
|
4567
4600
|
|
|
4568
|
-
/*! @azure/msal-common v14.0.
|
|
4601
|
+
/*! @azure/msal-common v14.0.1 2023-08-11 */
|
|
4569
4602
|
|
|
4570
4603
|
/*
|
|
4571
4604
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4749,6 +4782,30 @@ class UrlString {
|
|
|
4749
4782
|
}
|
|
4750
4783
|
return Constants.EMPTY_STRING;
|
|
4751
4784
|
}
|
|
4785
|
+
/**
|
|
4786
|
+
* Parses query server response string from given string.
|
|
4787
|
+
* Extract hash between '?code=' and '#' if trailing '# is present.
|
|
4788
|
+
* Returns empty string if no query symbol is found.
|
|
4789
|
+
* @param queryString
|
|
4790
|
+
*/
|
|
4791
|
+
static parseQueryServerResponse(queryString) {
|
|
4792
|
+
const queryIndex1 = queryString.indexOf("?code");
|
|
4793
|
+
const queryIndex2 = queryString.indexOf("/?code");
|
|
4794
|
+
const hashIndex = queryString.indexOf("#");
|
|
4795
|
+
if (queryIndex2 > -1 && hashIndex > -1) {
|
|
4796
|
+
return queryString.substring(queryIndex2 + 2, hashIndex);
|
|
4797
|
+
}
|
|
4798
|
+
else if (queryIndex2 > -1) {
|
|
4799
|
+
return queryString.substring(queryIndex2 + 2);
|
|
4800
|
+
}
|
|
4801
|
+
else if (queryIndex1 > -1 && hashIndex > -1) {
|
|
4802
|
+
return queryString.substring(queryIndex1 + 1, hashIndex);
|
|
4803
|
+
}
|
|
4804
|
+
else if (queryIndex1 > -1) {
|
|
4805
|
+
return queryString.substring(queryIndex1 + 1);
|
|
4806
|
+
}
|
|
4807
|
+
return Constants.EMPTY_STRING;
|
|
4808
|
+
}
|
|
4752
4809
|
static constructAuthorityUriFromObject(urlObject) {
|
|
4753
4810
|
return new UrlString(urlObject.Protocol +
|
|
4754
4811
|
"//" +
|
|
@@ -4794,6 +4851,21 @@ class UrlString {
|
|
|
4794
4851
|
}
|
|
4795
4852
|
return deserializedQueryString;
|
|
4796
4853
|
}
|
|
4854
|
+
/**
|
|
4855
|
+
* Returns either deserialized query string or deserialized hash, depending on the serverResponseType
|
|
4856
|
+
* as a server auth code response object.
|
|
4857
|
+
*/
|
|
4858
|
+
static getDeserializedCodeResponse(serverResponseType, hashFragment) {
|
|
4859
|
+
const hashUrlString = new UrlString(hashFragment);
|
|
4860
|
+
let serverParams;
|
|
4861
|
+
if (serverResponseType === ServerResponseType.QUERY) {
|
|
4862
|
+
serverParams = UrlString.getDeserializedQueryString(hashFragment);
|
|
4863
|
+
}
|
|
4864
|
+
else {
|
|
4865
|
+
serverParams = UrlString.getDeserializedHash(hashUrlString.getHash());
|
|
4866
|
+
}
|
|
4867
|
+
return serverParams;
|
|
4868
|
+
}
|
|
4797
4869
|
/**
|
|
4798
4870
|
* Check if the hash of the URL string contains known properties
|
|
4799
4871
|
*/
|
|
@@ -4810,7 +4882,7 @@ class UrlString {
|
|
|
4810
4882
|
}
|
|
4811
4883
|
}
|
|
4812
4884
|
|
|
4813
|
-
/*! @azure/msal-common v14.0.
|
|
4885
|
+
/*! @azure/msal-common v14.0.1 2023-08-11 */
|
|
4814
4886
|
/*
|
|
4815
4887
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4816
4888
|
* Licensed under the MIT License.
|
|
@@ -5013,6 +5085,7 @@ const PerformanceEvents = {
|
|
|
5013
5085
|
UpdateCloudDiscoveryMetadataMeasurement: "updateCloudDiscoveryMetadataMeasurement",
|
|
5014
5086
|
UsernamePasswordClientAcquireToken: "usernamePasswordClientAcquireToken",
|
|
5015
5087
|
NativeMessageHandlerHandshake: "nativeMessageHandlerHandshake",
|
|
5088
|
+
NativeGenerateAuthResult: "nativeGenerateAuthResult",
|
|
5016
5089
|
};
|
|
5017
5090
|
/**
|
|
5018
5091
|
* State of the performance event.
|
|
@@ -5037,7 +5110,7 @@ const IntFields = new Set([
|
|
|
5037
5110
|
"status",
|
|
5038
5111
|
]);
|
|
5039
5112
|
|
|
5040
|
-
/*! @azure/msal-common v14.0.
|
|
5113
|
+
/*! @azure/msal-common v14.0.1 2023-08-11 */
|
|
5041
5114
|
|
|
5042
5115
|
/*
|
|
5043
5116
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -5122,7 +5195,7 @@ class PopTokenGenerator {
|
|
|
5122
5195
|
}
|
|
5123
5196
|
}
|
|
5124
5197
|
|
|
5125
|
-
/*! @azure/msal-common v14.0.
|
|
5198
|
+
/*! @azure/msal-common v14.0.1 2023-08-11 */
|
|
5126
5199
|
|
|
5127
5200
|
/*
|
|
5128
5201
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -5191,7 +5264,7 @@ class AppMetadataEntity {
|
|
|
5191
5264
|
}
|
|
5192
5265
|
}
|
|
5193
5266
|
|
|
5194
|
-
/*! @azure/msal-common v14.0.
|
|
5267
|
+
/*! @azure/msal-common v14.0.1 2023-08-11 */
|
|
5195
5268
|
/*
|
|
5196
5269
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
5197
5270
|
* Licensed under the MIT License.
|
|
@@ -5218,7 +5291,7 @@ class AppMetadataEntity {
|
|
|
5218
5291
|
}
|
|
5219
5292
|
}
|
|
5220
5293
|
|
|
5221
|
-
/*! @azure/msal-common v14.0.
|
|
5294
|
+
/*! @azure/msal-common v14.0.1 2023-08-11 */
|
|
5222
5295
|
|
|
5223
5296
|
/*
|
|
5224
5297
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -5245,12 +5318,25 @@ class ResponseHandler {
|
|
|
5245
5318
|
*/
|
|
5246
5319
|
validateServerAuthorizationCodeResponse(serverResponseHash, cachedState, cryptoObj) {
|
|
5247
5320
|
if (!serverResponseHash.state || !cachedState) {
|
|
5248
|
-
throw
|
|
5249
|
-
? ClientAuthError.createStateNotFoundError("
|
|
5250
|
-
: ClientAuthError.createStateNotFoundError("
|
|
5321
|
+
throw serverResponseHash.state
|
|
5322
|
+
? ClientAuthError.createStateNotFoundError("Cached State")
|
|
5323
|
+
: ClientAuthError.createStateNotFoundError("Server State");
|
|
5324
|
+
}
|
|
5325
|
+
let decodedServerResponseHash;
|
|
5326
|
+
let decodedCachedState;
|
|
5327
|
+
try {
|
|
5328
|
+
decodedServerResponseHash = decodeURIComponent(serverResponseHash.state);
|
|
5251
5329
|
}
|
|
5252
|
-
|
|
5253
|
-
|
|
5330
|
+
catch (e) {
|
|
5331
|
+
throw ClientAuthError.createInvalidStateError(serverResponseHash.state, `Server response hash URI could not be decoded`);
|
|
5332
|
+
}
|
|
5333
|
+
try {
|
|
5334
|
+
decodedCachedState = decodeURIComponent(cachedState);
|
|
5335
|
+
}
|
|
5336
|
+
catch (e) {
|
|
5337
|
+
throw ClientAuthError.createInvalidStateError(serverResponseHash.state, `Cached state URI could not be decoded`);
|
|
5338
|
+
}
|
|
5339
|
+
if (decodedServerResponseHash !== decodedCachedState) {
|
|
5254
5340
|
throw ClientAuthError.createStateMismatchError();
|
|
5255
5341
|
}
|
|
5256
5342
|
// Check for error
|
|
@@ -5310,7 +5396,7 @@ class ResponseHandler {
|
|
|
5310
5396
|
}
|
|
5311
5397
|
}
|
|
5312
5398
|
// generate homeAccountId
|
|
5313
|
-
this.homeAccountIdentifier = AccountEntity.generateHomeAccountId(serverTokenResponse.client_info || Constants.EMPTY_STRING, authority.authorityType, this.logger, this.cryptoObj, idTokenObj);
|
|
5399
|
+
this.homeAccountIdentifier = AccountEntity.generateHomeAccountId(serverTokenResponse.client_info || Constants.EMPTY_STRING, authority.authorityType, this.logger, this.cryptoObj, idTokenObj?.claims);
|
|
5314
5400
|
// save the response tokens
|
|
5315
5401
|
let requestStateObj;
|
|
5316
5402
|
if (!!authCodePayload && !!authCodePayload.state) {
|
|
@@ -5343,7 +5429,7 @@ class ResponseHandler {
|
|
|
5343
5429
|
return ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenObj, requestStateObj, undefined, serverRequestId);
|
|
5344
5430
|
}
|
|
5345
5431
|
}
|
|
5346
|
-
await this.cacheStorage.saveCacheRecord(cacheRecord);
|
|
5432
|
+
await this.cacheStorage.saveCacheRecord(cacheRecord, request.storeInCache);
|
|
5347
5433
|
}
|
|
5348
5434
|
finally {
|
|
5349
5435
|
if (this.persistencePlugin &&
|
|
@@ -5372,7 +5458,13 @@ class ResponseHandler {
|
|
|
5372
5458
|
if (!StringUtils.isEmpty(serverTokenResponse.id_token) &&
|
|
5373
5459
|
!!idTokenObj) {
|
|
5374
5460
|
cachedIdToken = IdTokenEntity.createIdTokenEntity(this.homeAccountIdentifier, env, serverTokenResponse.id_token || Constants.EMPTY_STRING, this.clientId, idTokenObj.claims.tid || Constants.EMPTY_STRING);
|
|
5375
|
-
cachedAccount =
|
|
5461
|
+
cachedAccount = AccountEntity.createAccount({
|
|
5462
|
+
homeAccountId: this.homeAccountIdentifier,
|
|
5463
|
+
idTokenClaims: idTokenObj.claims,
|
|
5464
|
+
clientInfo: serverTokenResponse.client_info,
|
|
5465
|
+
cloudGraphHostName: authCodePayload?.cloud_graph_host_name,
|
|
5466
|
+
msGraphHost: authCodePayload?.msgraph_host,
|
|
5467
|
+
}, authority);
|
|
5376
5468
|
}
|
|
5377
5469
|
// AccessToken
|
|
5378
5470
|
let cachedAccessToken = null;
|
|
@@ -5414,35 +5506,7 @@ class ResponseHandler {
|
|
|
5414
5506
|
if (!StringUtils.isEmpty(serverTokenResponse.foci)) {
|
|
5415
5507
|
cachedAppMetadata = AppMetadataEntity.createAppMetadataEntity(this.clientId, env, serverTokenResponse.foci);
|
|
5416
5508
|
}
|
|
5417
|
-
return new CacheRecord
|
|
5418
|
-
}
|
|
5419
|
-
/**
|
|
5420
|
-
* Generate Account
|
|
5421
|
-
* @param serverTokenResponse
|
|
5422
|
-
* @param idToken
|
|
5423
|
-
* @param authority
|
|
5424
|
-
*/
|
|
5425
|
-
generateAccountEntity(serverTokenResponse, idToken, authority, authCodePayload) {
|
|
5426
|
-
const authorityType = authority.authorityType;
|
|
5427
|
-
const cloudGraphHostName = authCodePayload
|
|
5428
|
-
? authCodePayload.cloud_graph_host_name
|
|
5429
|
-
: Constants.EMPTY_STRING;
|
|
5430
|
-
const msGraphhost = authCodePayload
|
|
5431
|
-
? authCodePayload.msgraph_host
|
|
5432
|
-
: Constants.EMPTY_STRING;
|
|
5433
|
-
// ADFS does not require client_info in the response
|
|
5434
|
-
if (authorityType === AuthorityType.Adfs) {
|
|
5435
|
-
this.logger.verbose("Authority type is ADFS, creating ADFS account");
|
|
5436
|
-
return AccountEntity.createGenericAccount(this.homeAccountIdentifier, idToken, authority, cloudGraphHostName, msGraphhost);
|
|
5437
|
-
}
|
|
5438
|
-
// This fallback applies to B2C as well as they fall under an AAD account type.
|
|
5439
|
-
if (StringUtils.isEmpty(serverTokenResponse.client_info) &&
|
|
5440
|
-
authority.protocolMode === "AAD") {
|
|
5441
|
-
throw ClientAuthError.createClientInfoEmptyError();
|
|
5442
|
-
}
|
|
5443
|
-
return serverTokenResponse.client_info
|
|
5444
|
-
? AccountEntity.createAccount(serverTokenResponse.client_info, this.homeAccountIdentifier, idToken, authority, cloudGraphHostName, msGraphhost)
|
|
5445
|
-
: AccountEntity.createGenericAccount(this.homeAccountIdentifier, idToken, authority, cloudGraphHostName, msGraphhost);
|
|
5509
|
+
return new CacheRecord(cachedAccount, cachedIdToken, cachedAccessToken, cachedRefreshToken, cachedAppMetadata);
|
|
5446
5510
|
}
|
|
5447
5511
|
/**
|
|
5448
5512
|
* Creates an @AuthenticationResult from @CacheRecord , @IdToken , and a boolean that states whether or not the result is from cache.
|
|
@@ -5521,7 +5585,7 @@ class ResponseHandler {
|
|
|
5521
5585
|
}
|
|
5522
5586
|
}
|
|
5523
5587
|
|
|
5524
|
-
/*! @azure/msal-common v14.0.
|
|
5588
|
+
/*! @azure/msal-common v14.0.1 2023-08-11 */
|
|
5525
5589
|
|
|
5526
5590
|
/*
|
|
5527
5591
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -5535,6 +5599,8 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
5535
5599
|
super(configuration, performanceClient);
|
|
5536
5600
|
// Flag to indicate if client is for hybrid spa auth code redemption
|
|
5537
5601
|
this.includeRedirectUri = true;
|
|
5602
|
+
this.oidcDefaultScopes =
|
|
5603
|
+
this.config.authOptions.authority.options.OIDCOptions?.defaultScopes;
|
|
5538
5604
|
}
|
|
5539
5605
|
/**
|
|
5540
5606
|
* Creates the URL of the authorization request letting the user input credentials and consent to the
|
|
@@ -5573,7 +5639,7 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
5573
5639
|
const requestId = response.headers?.[HeaderNames.X_MS_REQUEST_ID];
|
|
5574
5640
|
const httpVerAuthority = response.headers?.[HeaderNames.X_MS_HTTP_VERSION];
|
|
5575
5641
|
if (httpVerAuthority) {
|
|
5576
|
-
atsMeasurement?.
|
|
5642
|
+
atsMeasurement?.add({
|
|
5577
5643
|
httpVerAuthority,
|
|
5578
5644
|
});
|
|
5579
5645
|
}
|
|
@@ -5584,14 +5650,14 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
5584
5650
|
return responseHandler
|
|
5585
5651
|
.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request, authCodePayload, undefined, undefined, undefined, requestId)
|
|
5586
5652
|
.then((result) => {
|
|
5587
|
-
atsMeasurement?.
|
|
5653
|
+
atsMeasurement?.end({
|
|
5588
5654
|
success: true,
|
|
5589
5655
|
});
|
|
5590
5656
|
return result;
|
|
5591
5657
|
})
|
|
5592
5658
|
.catch((error) => {
|
|
5593
5659
|
this.logger.verbose("Error in fetching token in ACC", request.correlationId);
|
|
5594
|
-
atsMeasurement?.
|
|
5660
|
+
atsMeasurement?.end({
|
|
5595
5661
|
errorCode: error.errorCode,
|
|
5596
5662
|
subErrorCode: error.subError,
|
|
5597
5663
|
success: false,
|
|
@@ -5607,10 +5673,8 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
5607
5673
|
handleFragmentResponse(hashFragment, cachedState) {
|
|
5608
5674
|
// Handle responses.
|
|
5609
5675
|
const responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, null, null);
|
|
5610
|
-
|
|
5611
|
-
|
|
5612
|
-
// Deserialize hash fragment response parameters.
|
|
5613
|
-
const serverParams = UrlString.getDeserializedHash(hashUrlString.getHash());
|
|
5676
|
+
const serverParams = UrlString.getDeserializedCodeResponse(this.config.authOptions.authority.options.OIDCOptions
|
|
5677
|
+
?.serverResponseType, hashFragment);
|
|
5614
5678
|
// Get code response
|
|
5615
5679
|
responseHandler.validateServerAuthorizationCodeResponse(serverParams, cachedState, this.cryptoUtils);
|
|
5616
5680
|
// throw when there is no auth code in the response
|
|
@@ -5682,7 +5746,8 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
5682
5746
|
async createTokenRequestBody(request) {
|
|
5683
5747
|
this.performanceClient?.addQueueMeasurement(PerformanceEvents.AuthClientCreateTokenRequestBody, request.correlationId);
|
|
5684
5748
|
const parameterBuilder = new RequestParameterBuilder();
|
|
5685
|
-
parameterBuilder.addClientId(
|
|
5749
|
+
parameterBuilder.addClientId(request.tokenBodyParameters?.[AADServerParamKeys.CLIENT_ID] ||
|
|
5750
|
+
this.config.authOptions.clientId);
|
|
5686
5751
|
/*
|
|
5687
5752
|
* For hybrid spa flow, there will be a code but no verifier
|
|
5688
5753
|
* In this scenario, don't include redirect uri as auth code will not be bound to redirect URI
|
|
@@ -5696,14 +5761,14 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
5696
5761
|
parameterBuilder.addRedirectUri(request.redirectUri);
|
|
5697
5762
|
}
|
|
5698
5763
|
// Add scope array, parameter builder will add default scopes and dedupe
|
|
5699
|
-
parameterBuilder.addScopes(request.scopes);
|
|
5764
|
+
parameterBuilder.addScopes(request.scopes, true, this.oidcDefaultScopes);
|
|
5700
5765
|
// add code: user set, not validated
|
|
5701
5766
|
parameterBuilder.addAuthorizationCode(request.code);
|
|
5702
5767
|
// Add library metadata
|
|
5703
5768
|
parameterBuilder.addLibraryInfo(this.config.libraryInfo);
|
|
5704
5769
|
parameterBuilder.addApplicationTelemetry(this.config.telemetry.application);
|
|
5705
5770
|
parameterBuilder.addThrottling();
|
|
5706
|
-
if (this.serverTelemetryManager) {
|
|
5771
|
+
if (this.serverTelemetryManager && !isOidcProtocolMode(this.config)) {
|
|
5707
5772
|
parameterBuilder.addServerTelemetry(this.serverTelemetryManager);
|
|
5708
5773
|
}
|
|
5709
5774
|
// add code_verifier if passed
|
|
@@ -5797,12 +5862,13 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
5797
5862
|
async createAuthCodeUrlQueryString(request) {
|
|
5798
5863
|
this.performanceClient?.addQueueMeasurement(PerformanceEvents.AuthClientCreateQueryString, request.correlationId);
|
|
5799
5864
|
const parameterBuilder = new RequestParameterBuilder();
|
|
5800
|
-
parameterBuilder.addClientId(
|
|
5865
|
+
parameterBuilder.addClientId(request.extraQueryParameters?.[AADServerParamKeys.CLIENT_ID] ||
|
|
5866
|
+
this.config.authOptions.clientId);
|
|
5801
5867
|
const requestScopes = [
|
|
5802
5868
|
...(request.scopes || []),
|
|
5803
5869
|
...(request.extraScopesToConsent || []),
|
|
5804
5870
|
];
|
|
5805
|
-
parameterBuilder.addScopes(requestScopes);
|
|
5871
|
+
parameterBuilder.addScopes(requestScopes, true, this.oidcDefaultScopes);
|
|
5806
5872
|
// validate the redirectUri (to be a non null value)
|
|
5807
5873
|
parameterBuilder.addRedirectUri(request.redirectUri);
|
|
5808
5874
|
// generate the correlationId if not set by the user and add
|
|
@@ -5815,7 +5881,9 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
5815
5881
|
parameterBuilder.addResponseTypeCode();
|
|
5816
5882
|
// add library info parameters
|
|
5817
5883
|
parameterBuilder.addLibraryInfo(this.config.libraryInfo);
|
|
5818
|
-
|
|
5884
|
+
if (!isOidcProtocolMode(this.config)) {
|
|
5885
|
+
parameterBuilder.addApplicationTelemetry(this.config.telemetry.application);
|
|
5886
|
+
}
|
|
5819
5887
|
// add client_info=1
|
|
5820
5888
|
parameterBuilder.addClientInfo();
|
|
5821
5889
|
if (request.codeChallenge && request.codeChallengeMethod) {
|
|
@@ -5957,7 +6025,7 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
5957
6025
|
}
|
|
5958
6026
|
}
|
|
5959
6027
|
|
|
5960
|
-
/*! @azure/msal-common v14.0.
|
|
6028
|
+
/*! @azure/msal-common v14.0.1 2023-08-11 */
|
|
5961
6029
|
|
|
5962
6030
|
/*
|
|
5963
6031
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -5978,11 +6046,11 @@ class RefreshTokenClient extends BaseClient {
|
|
|
5978
6046
|
this.performanceClient?.setPreQueueTime(PerformanceEvents.RefreshTokenClientExecuteTokenRequest, request.correlationId);
|
|
5979
6047
|
const response = await this.executeTokenRequest(request, this.authority);
|
|
5980
6048
|
const httpVerToken = response.headers?.[HeaderNames.X_MS_HTTP_VERSION];
|
|
5981
|
-
atsMeasurement?.
|
|
6049
|
+
atsMeasurement?.add({
|
|
5982
6050
|
refreshTokenSize: response.body.refresh_token?.length || 0,
|
|
5983
6051
|
});
|
|
5984
6052
|
if (httpVerToken) {
|
|
5985
|
-
atsMeasurement?.
|
|
6053
|
+
atsMeasurement?.add({
|
|
5986
6054
|
httpVerToken,
|
|
5987
6055
|
});
|
|
5988
6056
|
}
|
|
@@ -5994,14 +6062,14 @@ class RefreshTokenClient extends BaseClient {
|
|
|
5994
6062
|
return responseHandler
|
|
5995
6063
|
.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request, undefined, undefined, true, request.forceCache, requestId)
|
|
5996
6064
|
.then((result) => {
|
|
5997
|
-
atsMeasurement?.
|
|
6065
|
+
atsMeasurement?.end({
|
|
5998
6066
|
success: true,
|
|
5999
6067
|
});
|
|
6000
6068
|
return result;
|
|
6001
6069
|
})
|
|
6002
6070
|
.catch((error) => {
|
|
6003
6071
|
this.logger.verbose("Error in fetching refresh token", request.correlationId);
|
|
6004
|
-
atsMeasurement?.
|
|
6072
|
+
atsMeasurement?.end({
|
|
6005
6073
|
errorCode: error.errorCode,
|
|
6006
6074
|
subErrorCode: error.subError,
|
|
6007
6075
|
success: false,
|
|
@@ -6065,11 +6133,11 @@ class RefreshTokenClient extends BaseClient {
|
|
|
6065
6133
|
this.logger.verbose("RefreshTokenClientAcquireTokenWithCachedRefreshToken called", request.correlationId);
|
|
6066
6134
|
const refreshToken = this.cacheManager.getRefreshToken(request.account, foci);
|
|
6067
6135
|
if (!refreshToken) {
|
|
6068
|
-
atsMeasurement?.
|
|
6136
|
+
atsMeasurement?.discard();
|
|
6069
6137
|
throw InteractionRequiredAuthError.createNoTokensFoundError();
|
|
6070
6138
|
}
|
|
6071
6139
|
// attach cached RT size to the current measurement
|
|
6072
|
-
atsMeasurement?.
|
|
6140
|
+
atsMeasurement?.end({
|
|
6073
6141
|
success: true,
|
|
6074
6142
|
});
|
|
6075
6143
|
const refreshTokenRequest = {
|
|
@@ -6110,13 +6178,13 @@ class RefreshTokenClient extends BaseClient {
|
|
|
6110
6178
|
};
|
|
6111
6179
|
return this.executePostToTokenEndpoint(endpoint, requestBody, headers, thumbprint)
|
|
6112
6180
|
.then((result) => {
|
|
6113
|
-
acquireTokenMeasurement?.
|
|
6181
|
+
acquireTokenMeasurement?.end({
|
|
6114
6182
|
success: true,
|
|
6115
6183
|
});
|
|
6116
6184
|
return result;
|
|
6117
6185
|
})
|
|
6118
6186
|
.catch((error) => {
|
|
6119
|
-
acquireTokenMeasurement?.
|
|
6187
|
+
acquireTokenMeasurement?.end({
|
|
6120
6188
|
success: false,
|
|
6121
6189
|
});
|
|
6122
6190
|
throw error;
|
|
@@ -6132,13 +6200,13 @@ class RefreshTokenClient extends BaseClient {
|
|
|
6132
6200
|
const acquireTokenMeasurement = this.performanceClient?.startMeasurement(PerformanceEvents.BaseClientCreateTokenRequestHeaders, correlationId);
|
|
6133
6201
|
const parameterBuilder = new RequestParameterBuilder();
|
|
6134
6202
|
parameterBuilder.addClientId(this.config.authOptions.clientId);
|
|
6135
|
-
parameterBuilder.addScopes(request.scopes);
|
|
6203
|
+
parameterBuilder.addScopes(request.scopes, true, this.config.authOptions.authority.options.OIDCOptions?.defaultScopes);
|
|
6136
6204
|
parameterBuilder.addGrantType(GrantType.REFRESH_TOKEN_GRANT);
|
|
6137
6205
|
parameterBuilder.addClientInfo();
|
|
6138
6206
|
parameterBuilder.addLibraryInfo(this.config.libraryInfo);
|
|
6139
6207
|
parameterBuilder.addApplicationTelemetry(this.config.telemetry.application);
|
|
6140
6208
|
parameterBuilder.addThrottling();
|
|
6141
|
-
if (this.serverTelemetryManager) {
|
|
6209
|
+
if (this.serverTelemetryManager && !isOidcProtocolMode(this.config)) {
|
|
6142
6210
|
parameterBuilder.addServerTelemetry(this.serverTelemetryManager);
|
|
6143
6211
|
}
|
|
6144
6212
|
parameterBuilder.addCorrelationId(correlationId);
|
|
@@ -6163,7 +6231,7 @@ class RefreshTokenClient extends BaseClient {
|
|
|
6163
6231
|
parameterBuilder.addSshJwk(request.sshJwk);
|
|
6164
6232
|
}
|
|
6165
6233
|
else {
|
|
6166
|
-
acquireTokenMeasurement?.
|
|
6234
|
+
acquireTokenMeasurement?.end({
|
|
6167
6235
|
success: false,
|
|
6168
6236
|
});
|
|
6169
6237
|
throw ClientConfigurationError.createMissingSshJwkError();
|
|
@@ -6192,14 +6260,14 @@ class RefreshTokenClient extends BaseClient {
|
|
|
6192
6260
|
break;
|
|
6193
6261
|
}
|
|
6194
6262
|
}
|
|
6195
|
-
acquireTokenMeasurement?.
|
|
6263
|
+
acquireTokenMeasurement?.end({
|
|
6196
6264
|
success: true,
|
|
6197
6265
|
});
|
|
6198
6266
|
return parameterBuilder.createQueryString();
|
|
6199
6267
|
}
|
|
6200
6268
|
}
|
|
6201
6269
|
|
|
6202
|
-
/*! @azure/msal-common v14.0.
|
|
6270
|
+
/*! @azure/msal-common v14.0.1 2023-08-11 */
|
|
6203
6271
|
|
|
6204
6272
|
/*
|
|
6205
6273
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6302,7 +6370,7 @@ class SilentFlowClient extends BaseClient {
|
|
|
6302
6370
|
}
|
|
6303
6371
|
}
|
|
6304
6372
|
|
|
6305
|
-
/*! @azure/msal-common v14.0.
|
|
6373
|
+
/*! @azure/msal-common v14.0.1 2023-08-11 */
|
|
6306
6374
|
/*
|
|
6307
6375
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6308
6376
|
* Licensed under the MIT License.
|
|
@@ -6314,7 +6382,7 @@ function isOpenIdConfigResponse(response) {
|
|
|
6314
6382
|
response.hasOwnProperty("jwks_uri"));
|
|
6315
6383
|
}
|
|
6316
6384
|
|
|
6317
|
-
/*! @azure/msal-common v14.0.
|
|
6385
|
+
/*! @azure/msal-common v14.0.1 2023-08-11 */
|
|
6318
6386
|
/*
|
|
6319
6387
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6320
6388
|
* Licensed under the MIT License.
|
|
@@ -7191,21 +7259,16 @@ const rawMetdataJSON = {
|
|
|
7191
7259
|
};
|
|
7192
7260
|
const EndpointMetadata = rawMetdataJSON.endpointMetadata;
|
|
7193
7261
|
const InstanceDiscoveryMetadata = rawMetdataJSON.instanceDiscoveryMetadata;
|
|
7262
|
+
const InstanceDiscoveryMetadataAliases = new Set();
|
|
7263
|
+
for (const key in InstanceDiscoveryMetadata) {
|
|
7264
|
+
for (const metadata of InstanceDiscoveryMetadata[key].metadata) {
|
|
7265
|
+
for (const alias of metadata.aliases) {
|
|
7266
|
+
InstanceDiscoveryMetadataAliases.add(alias);
|
|
7267
|
+
}
|
|
7268
|
+
}
|
|
7269
|
+
}
|
|
7194
7270
|
|
|
7195
|
-
/*! @azure/msal-common v14.0.
|
|
7196
|
-
/*
|
|
7197
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
7198
|
-
* Licensed under the MIT License.
|
|
7199
|
-
*/
|
|
7200
|
-
/**
|
|
7201
|
-
* Protocol modes supported by MSAL.
|
|
7202
|
-
*/
|
|
7203
|
-
const ProtocolMode = {
|
|
7204
|
-
AAD: "AAD",
|
|
7205
|
-
OIDC: "OIDC",
|
|
7206
|
-
};
|
|
7207
|
-
|
|
7208
|
-
/*! @azure/msal-common v14.0.0-beta.1 2023-07-06 */
|
|
7271
|
+
/*! @azure/msal-common v14.0.1 2023-08-11 */
|
|
7209
7272
|
|
|
7210
7273
|
/*
|
|
7211
7274
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7285,7 +7348,7 @@ class AuthorityMetadataEntity {
|
|
|
7285
7348
|
}
|
|
7286
7349
|
}
|
|
7287
7350
|
|
|
7288
|
-
/*! @azure/msal-common v14.0.
|
|
7351
|
+
/*! @azure/msal-common v14.0.1 2023-08-11 */
|
|
7289
7352
|
/*
|
|
7290
7353
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
7291
7354
|
* Licensed under the MIT License.
|
|
@@ -7295,7 +7358,7 @@ function isCloudInstanceDiscoveryResponse(response) {
|
|
|
7295
7358
|
response.hasOwnProperty("metadata"));
|
|
7296
7359
|
}
|
|
7297
7360
|
|
|
7298
|
-
/*! @azure/msal-common v14.0.
|
|
7361
|
+
/*! @azure/msal-common v14.0.1 2023-08-11 */
|
|
7299
7362
|
/*
|
|
7300
7363
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
7301
7364
|
* Licensed under the MIT License.
|
|
@@ -7305,7 +7368,7 @@ function isCloudInstanceDiscoveryErrorResponse(response) {
|
|
|
7305
7368
|
response.hasOwnProperty("error_description"));
|
|
7306
7369
|
}
|
|
7307
7370
|
|
|
7308
|
-
/*! @azure/msal-common v14.0.
|
|
7371
|
+
/*! @azure/msal-common v14.0.1 2023-08-11 */
|
|
7309
7372
|
|
|
7310
7373
|
/*
|
|
7311
7374
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7416,7 +7479,7 @@ RegionDiscovery.IMDS_OPTIONS = {
|
|
|
7416
7479
|
},
|
|
7417
7480
|
};
|
|
7418
7481
|
|
|
7419
|
-
/*! @azure/msal-common v14.0.
|
|
7482
|
+
/*! @azure/msal-common v14.0.1 2023-08-11 */
|
|
7420
7483
|
|
|
7421
7484
|
/*
|
|
7422
7485
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7589,10 +7652,10 @@ class Authority {
|
|
|
7589
7652
|
* @private
|
|
7590
7653
|
*/
|
|
7591
7654
|
canReplaceTenant(authorityUri) {
|
|
7592
|
-
return authorityUri.PathSegments.length === 1
|
|
7593
|
-
|
|
7594
|
-
|
|
7595
|
-
|
|
7655
|
+
return (authorityUri.PathSegments.length === 1 &&
|
|
7656
|
+
!Authority.reservedTenantDomains.has(authorityUri.PathSegments[0]) &&
|
|
7657
|
+
this.getAuthorityType(authorityUri) === AuthorityType.Default &&
|
|
7658
|
+
this.protocolMode === ProtocolMode.AAD);
|
|
7596
7659
|
}
|
|
7597
7660
|
/**
|
|
7598
7661
|
* Replaces tenant in url path with current tenant. Defaults to common.
|
|
@@ -7613,8 +7676,9 @@ class Authority {
|
|
|
7613
7676
|
const currentAuthorityParts = this.canonicalAuthorityUrlComponents.PathSegments;
|
|
7614
7677
|
currentAuthorityParts.forEach((currentPart, index) => {
|
|
7615
7678
|
let cachedPart = cachedAuthorityParts[index];
|
|
7616
|
-
if (index === 0 &&
|
|
7617
|
-
|
|
7679
|
+
if (index === 0 &&
|
|
7680
|
+
this.canReplaceTenant(cachedAuthorityUrlComponents)) {
|
|
7681
|
+
const tenantId = new UrlString(this.metadata.authorization_endpoint).getUrlComponents().PathSegments[0];
|
|
7618
7682
|
/**
|
|
7619
7683
|
* Check if AAD canonical authority contains tenant domain name, for example "testdomain.onmicrosoft.com",
|
|
7620
7684
|
* by comparing its first path segment to the corresponding authorization endpoint path segment, which is
|
|
@@ -7635,8 +7699,9 @@ class Authority {
|
|
|
7635
7699
|
* The default open id configuration endpoint for any canonical authority.
|
|
7636
7700
|
*/
|
|
7637
7701
|
get defaultOpenIdConfigurationEndpoint() {
|
|
7702
|
+
const canonicalAuthorityHost = this.hostnameAndPort;
|
|
7638
7703
|
if (this.authorityType === AuthorityType.Adfs ||
|
|
7639
|
-
this.
|
|
7704
|
+
!this.isAliasOfKnownMicrosoftAuthority(canonicalAuthorityHost)) {
|
|
7640
7705
|
return `${this.canonicalAuthority}.well-known/openid-configuration`;
|
|
7641
7706
|
}
|
|
7642
7707
|
return `${this.canonicalAuthority}v2.0/.well-known/openid-configuration`;
|
|
@@ -7679,41 +7744,65 @@ class Authority {
|
|
|
7679
7744
|
*/
|
|
7680
7745
|
async updateEndpointMetadata(metadataEntity) {
|
|
7681
7746
|
this.performanceClient?.addQueueMeasurement(PerformanceEvents.AuthorityUpdateEndpointMetadata, this.correlationId);
|
|
7747
|
+
this.logger.verbose("Attempting to get endpoint metadata from authority configuration");
|
|
7682
7748
|
let metadata = this.getEndpointMetadataFromConfig();
|
|
7683
7749
|
if (metadata) {
|
|
7750
|
+
this.logger.verbose("Found endpoint metadata in authority configuration");
|
|
7684
7751
|
metadataEntity.updateEndpointMetadata(metadata, false);
|
|
7685
7752
|
return AuthorityMetadataSource.CONFIG;
|
|
7686
7753
|
}
|
|
7754
|
+
this.logger.verbose("Did not find endpoint metadata in the config... Attempting to get endpoint metadata from the hardcoded values.");
|
|
7755
|
+
// skipAuthorityMetadataCache is used to bypass hardcoded authority metadata and force a network metadata cache lookup and network metadata request if no cached response is available.
|
|
7756
|
+
if (this.authorityOptions.skipAuthorityMetadataCache) {
|
|
7757
|
+
this.logger.verbose("Skipping hardcoded metadata cache since skipAuthorityMetadataCache is set to true. Attempting to get endpoint metadata from the network metadata cache.");
|
|
7758
|
+
}
|
|
7759
|
+
else {
|
|
7760
|
+
let hardcodedMetadata = this.getEndpointMetadataFromHardcodedValues();
|
|
7761
|
+
if (hardcodedMetadata) {
|
|
7762
|
+
this.logger.verbose("Found endpoint metadata from hardcoded values.");
|
|
7763
|
+
// If the user prefers to use an azure region replace the global endpoints with regional information.
|
|
7764
|
+
if (this.authorityOptions.azureRegionConfiguration?.azureRegion) {
|
|
7765
|
+
this.performanceClient?.setPreQueueTime(PerformanceEvents.AuthorityUpdateMetadataWithRegionalInformation, this.correlationId);
|
|
7766
|
+
this.logger.verbose("Found azure region configuration. Updating endpoints with regional information.");
|
|
7767
|
+
hardcodedMetadata =
|
|
7768
|
+
await this.updateMetadataWithRegionalInformation(hardcodedMetadata);
|
|
7769
|
+
}
|
|
7770
|
+
metadataEntity.updateEndpointMetadata(hardcodedMetadata, false);
|
|
7771
|
+
return AuthorityMetadataSource.HARDCODED_VALUES;
|
|
7772
|
+
}
|
|
7773
|
+
else {
|
|
7774
|
+
this.logger.verbose("Did not find endpoint metadata in hardcoded values... Attempting to get endpoint metadata from the network metadata cache.");
|
|
7775
|
+
}
|
|
7776
|
+
}
|
|
7777
|
+
// Check cached metadata entity expiration status
|
|
7778
|
+
const metadataEntityExpired = metadataEntity.isExpired();
|
|
7687
7779
|
if (this.isAuthoritySameType(metadataEntity) &&
|
|
7688
7780
|
metadataEntity.endpointsFromNetwork &&
|
|
7689
|
-
!
|
|
7781
|
+
!metadataEntityExpired) {
|
|
7690
7782
|
// No need to update
|
|
7783
|
+
this.logger.verbose("Found endpoint metadata in the cache.");
|
|
7691
7784
|
return AuthorityMetadataSource.CACHE;
|
|
7692
7785
|
}
|
|
7786
|
+
else if (metadataEntityExpired) {
|
|
7787
|
+
this.logger.verbose("The metadata entity is expired.");
|
|
7788
|
+
}
|
|
7789
|
+
this.logger.verbose("Did not find cached endpoint metadata... Attempting to get endpoint metadata from the network.");
|
|
7693
7790
|
this.performanceClient?.setPreQueueTime(PerformanceEvents.AuthorityGetEndpointMetadataFromNetwork, this.correlationId);
|
|
7694
7791
|
metadata = await this.getEndpointMetadataFromNetwork();
|
|
7695
7792
|
if (metadata) {
|
|
7793
|
+
this.logger.verbose("Endpoint metadata was successfully returned from getEndpointMetadataFromNetwork()");
|
|
7696
7794
|
// If the user prefers to use an azure region replace the global endpoints with regional information.
|
|
7697
7795
|
if (this.authorityOptions.azureRegionConfiguration?.azureRegion) {
|
|
7698
7796
|
this.performanceClient?.setPreQueueTime(PerformanceEvents.AuthorityUpdateMetadataWithRegionalInformation, this.correlationId);
|
|
7797
|
+
this.logger.verbose("Found azure region configuration. Updating endpoints with regional information.");
|
|
7699
7798
|
metadata = await this.updateMetadataWithRegionalInformation(metadata);
|
|
7700
7799
|
}
|
|
7701
7800
|
metadataEntity.updateEndpointMetadata(metadata, true);
|
|
7702
7801
|
return AuthorityMetadataSource.NETWORK;
|
|
7703
7802
|
}
|
|
7704
|
-
let harcodedMetadata = this.getEndpointMetadataFromHardcodedValues();
|
|
7705
|
-
if (harcodedMetadata &&
|
|
7706
|
-
!this.authorityOptions.skipAuthorityMetadataCache) {
|
|
7707
|
-
// If the user prefers to use an azure region replace the global endpoints with regional information.
|
|
7708
|
-
if (this.authorityOptions.azureRegionConfiguration?.azureRegion) {
|
|
7709
|
-
this.performanceClient?.setPreQueueTime(PerformanceEvents.AuthorityUpdateMetadataWithRegionalInformation, this.correlationId);
|
|
7710
|
-
harcodedMetadata =
|
|
7711
|
-
await this.updateMetadataWithRegionalInformation(harcodedMetadata);
|
|
7712
|
-
}
|
|
7713
|
-
metadataEntity.updateEndpointMetadata(harcodedMetadata, false);
|
|
7714
|
-
return AuthorityMetadataSource.HARDCODED_VALUES;
|
|
7715
|
-
}
|
|
7716
7803
|
else {
|
|
7804
|
+
// Metadata could not be obtained from the config, cache, network or hardcoded values
|
|
7805
|
+
this.logger.error("Did not find endpoint metadata from network... Metadata could not be obtained from config, cache, network or hardcoded values. Throwing Untrusted Authority Error.");
|
|
7717
7806
|
throw ClientAuthError.createUnableToGetOpenidConfigError(this.defaultOpenIdConfigurationEndpoint);
|
|
7718
7807
|
}
|
|
7719
7808
|
}
|
|
@@ -7762,17 +7851,23 @@ class Authority {
|
|
|
7762
7851
|
const response = await this.networkInterface.sendGetRequestAsync(openIdConfigurationEndpoint, options);
|
|
7763
7852
|
const isValidResponse = isOpenIdConfigResponse(response.body);
|
|
7764
7853
|
if (isValidResponse) {
|
|
7765
|
-
perfEvent?.
|
|
7854
|
+
perfEvent?.end({ success: true });
|
|
7766
7855
|
return response.body;
|
|
7767
7856
|
}
|
|
7768
7857
|
else {
|
|
7769
|
-
perfEvent?.
|
|
7858
|
+
perfEvent?.end({
|
|
7859
|
+
success: false,
|
|
7860
|
+
errorCode: "invalid_response",
|
|
7861
|
+
});
|
|
7770
7862
|
this.logger.verbose(`Authority.getEndpointMetadataFromNetwork: could not parse response as OpenID configuration`);
|
|
7771
7863
|
return null;
|
|
7772
7864
|
}
|
|
7773
7865
|
}
|
|
7774
7866
|
catch (e) {
|
|
7775
|
-
perfEvent?.
|
|
7867
|
+
perfEvent?.end({
|
|
7868
|
+
success: false,
|
|
7869
|
+
errorCode: "request_failure",
|
|
7870
|
+
});
|
|
7776
7871
|
this.logger.verbose(`Authority.getEndpointMetadataFromNetwork: ${e}`);
|
|
7777
7872
|
return null;
|
|
7778
7873
|
}
|
|
@@ -7794,19 +7889,26 @@ class Authority {
|
|
|
7794
7889
|
this.performanceClient?.addQueueMeasurement(PerformanceEvents.AuthorityUpdateMetadataWithRegionalInformation, this.correlationId);
|
|
7795
7890
|
const userConfiguredAzureRegion = this.authorityOptions.azureRegionConfiguration?.azureRegion;
|
|
7796
7891
|
if (userConfiguredAzureRegion) {
|
|
7797
|
-
if (userConfiguredAzureRegion !==
|
|
7798
|
-
|
|
7799
|
-
this.regionDiscoveryMetadata.
|
|
7892
|
+
if (userConfiguredAzureRegion !==
|
|
7893
|
+
Constants.AZURE_REGION_AUTO_DISCOVER_FLAG) {
|
|
7894
|
+
this.regionDiscoveryMetadata.region_outcome =
|
|
7895
|
+
RegionDiscoveryOutcomes.CONFIGURED_NO_AUTO_DETECTION;
|
|
7896
|
+
this.regionDiscoveryMetadata.region_used =
|
|
7897
|
+
userConfiguredAzureRegion;
|
|
7800
7898
|
return Authority.replaceWithRegionalInformation(metadata, userConfiguredAzureRegion);
|
|
7801
7899
|
}
|
|
7802
7900
|
this.performanceClient?.setPreQueueTime(PerformanceEvents.RegionDiscoveryDetectRegion, this.correlationId);
|
|
7803
|
-
const autodetectedRegionName = await this.regionDiscovery.detectRegion(this.authorityOptions.azureRegionConfiguration
|
|
7901
|
+
const autodetectedRegionName = await this.regionDiscovery.detectRegion(this.authorityOptions.azureRegionConfiguration
|
|
7902
|
+
?.environmentRegion, this.regionDiscoveryMetadata);
|
|
7804
7903
|
if (autodetectedRegionName) {
|
|
7805
|
-
this.regionDiscoveryMetadata.region_outcome =
|
|
7806
|
-
|
|
7904
|
+
this.regionDiscoveryMetadata.region_outcome =
|
|
7905
|
+
RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_SUCCESSFUL;
|
|
7906
|
+
this.regionDiscoveryMetadata.region_used =
|
|
7907
|
+
autodetectedRegionName;
|
|
7807
7908
|
return Authority.replaceWithRegionalInformation(metadata, autodetectedRegionName);
|
|
7808
7909
|
}
|
|
7809
|
-
this.regionDiscoveryMetadata.region_outcome =
|
|
7910
|
+
this.regionDiscoveryMetadata.region_outcome =
|
|
7911
|
+
RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_FAILED;
|
|
7810
7912
|
}
|
|
7811
7913
|
return metadata;
|
|
7812
7914
|
}
|
|
@@ -7818,7 +7920,7 @@ class Authority {
|
|
|
7818
7920
|
*/
|
|
7819
7921
|
async updateCloudDiscoveryMetadata(metadataEntity) {
|
|
7820
7922
|
this.performanceClient?.addQueueMeasurement(PerformanceEvents.AuthorityUpdateCloudDiscoveryMetadata, this.correlationId);
|
|
7821
|
-
this.logger.verbose("Attempting to get cloud discovery metadata
|
|
7923
|
+
this.logger.verbose("Attempting to get cloud discovery metadata from authority configuration");
|
|
7822
7924
|
this.logger.verbosePii(`Known Authorities: ${this.authorityOptions.knownAuthorities ||
|
|
7823
7925
|
Constants.NOT_APPLICABLE}`);
|
|
7824
7926
|
this.logger.verbosePii(`Authority Metadata: ${this.authorityOptions.authorityMetadata ||
|
|
@@ -7826,17 +7928,29 @@ class Authority {
|
|
|
7826
7928
|
this.logger.verbosePii(`Canonical Authority: ${metadataEntity.canonical_authority || Constants.NOT_APPLICABLE}`);
|
|
7827
7929
|
let metadata = this.getCloudDiscoveryMetadataFromConfig();
|
|
7828
7930
|
if (metadata) {
|
|
7829
|
-
this.logger.verbose("Found cloud discovery metadata in
|
|
7931
|
+
this.logger.verbose("Found cloud discovery metadata in authority configuration");
|
|
7830
7932
|
metadataEntity.updateCloudDiscoveryMetadata(metadata, false);
|
|
7831
7933
|
return AuthorityMetadataSource.CONFIG;
|
|
7832
7934
|
}
|
|
7833
|
-
// If the cached metadata came from config but that config was not passed to this instance, we must go to
|
|
7834
|
-
this.logger.verbose("Did not find cloud discovery metadata in the config... Attempting to get cloud discovery metadata from the
|
|
7935
|
+
// If the cached metadata came from config but that config was not passed to this instance, we must go to hardcoded values
|
|
7936
|
+
this.logger.verbose("Did not find cloud discovery metadata in the config... Attempting to get cloud discovery metadata from the hardcoded values.");
|
|
7937
|
+
if (this.options.skipAuthorityMetadataCache) {
|
|
7938
|
+
this.logger.verbose("Skipping hardcoded cloud discovery metadata cache since skipAuthorityMetadataCache is set to true. Attempting to get cloud discovery metadata from the network metadata cache.");
|
|
7939
|
+
}
|
|
7940
|
+
else {
|
|
7941
|
+
const hardcodedMetadata = this.getCloudDiscoveryMetadataFromHardcodedValues();
|
|
7942
|
+
if (hardcodedMetadata) {
|
|
7943
|
+
this.logger.verbose("Found cloud discovery metadata from hardcoded values.");
|
|
7944
|
+
metadataEntity.updateCloudDiscoveryMetadata(hardcodedMetadata, false);
|
|
7945
|
+
return AuthorityMetadataSource.HARDCODED_VALUES;
|
|
7946
|
+
}
|
|
7947
|
+
this.logger.verbose("Did not find cloud discovery metadata in hardcoded values... Attempting to get cloud discovery metadata from the network metadata cache.");
|
|
7948
|
+
}
|
|
7835
7949
|
const metadataEntityExpired = metadataEntity.isExpired();
|
|
7836
7950
|
if (this.isAuthoritySameType(metadataEntity) &&
|
|
7837
7951
|
metadataEntity.aliasesFromNetwork &&
|
|
7838
7952
|
!metadataEntityExpired) {
|
|
7839
|
-
this.logger.verbose("Found metadata in the cache.");
|
|
7953
|
+
this.logger.verbose("Found cloud discovery metadata in the cache.");
|
|
7840
7954
|
// No need to update
|
|
7841
7955
|
return AuthorityMetadataSource.CACHE;
|
|
7842
7956
|
}
|
|
@@ -7851,15 +7965,8 @@ class Authority {
|
|
|
7851
7965
|
metadataEntity.updateCloudDiscoveryMetadata(metadata, true);
|
|
7852
7966
|
return AuthorityMetadataSource.NETWORK;
|
|
7853
7967
|
}
|
|
7854
|
-
this.logger.verbose("Did not find cloud discovery metadata from the network... Attempting to get cloud discovery metadata from hardcoded values.");
|
|
7855
|
-
const harcodedMetadata = this.getCloudDiscoveryMetadataFromHarcodedValues();
|
|
7856
|
-
if (harcodedMetadata && !this.options.skipAuthorityMetadataCache) {
|
|
7857
|
-
this.logger.verbose("Found cloud discovery metadata from hardcoded values.");
|
|
7858
|
-
metadataEntity.updateCloudDiscoveryMetadata(harcodedMetadata, false);
|
|
7859
|
-
return AuthorityMetadataSource.HARDCODED_VALUES;
|
|
7860
|
-
}
|
|
7861
7968
|
// Metadata could not be obtained from the config, cache, network or hardcoded values
|
|
7862
|
-
this.logger.error("Did not find cloud discovery metadata from
|
|
7969
|
+
this.logger.error("Did not find cloud discovery metadata from network... Metadata could not be obtained from config, cache, network or hardcoded values. Throwing Untrusted Authority Error.");
|
|
7863
7970
|
throw ClientConfigurationError.createUntrustedAuthorityError();
|
|
7864
7971
|
}
|
|
7865
7972
|
/**
|
|
@@ -7964,9 +8071,11 @@ class Authority {
|
|
|
7964
8071
|
/**
|
|
7965
8072
|
* Get cloud discovery metadata for common authorities
|
|
7966
8073
|
*/
|
|
7967
|
-
|
|
8074
|
+
getCloudDiscoveryMetadataFromHardcodedValues() {
|
|
7968
8075
|
if (this.canonicalAuthority in InstanceDiscoveryMetadata) {
|
|
7969
|
-
|
|
8076
|
+
const hardcodedMetadataResponse = InstanceDiscoveryMetadata[this.canonicalAuthority];
|
|
8077
|
+
const metadata = Authority.getCloudDiscoveryMetadataFromNetworkResponse(hardcodedMetadataResponse.metadata, this.hostnameAndPort);
|
|
8078
|
+
return metadata;
|
|
7970
8079
|
}
|
|
7971
8080
|
return null;
|
|
7972
8081
|
}
|
|
@@ -8041,6 +8150,13 @@ class Authority {
|
|
|
8041
8150
|
isAlias(host) {
|
|
8042
8151
|
return this.metadata.aliases.indexOf(host) > -1;
|
|
8043
8152
|
}
|
|
8153
|
+
/**
|
|
8154
|
+
* Returns whether or not the provided host is an alias of a known Microsoft authority for purposes of endpoint discovery
|
|
8155
|
+
* @param host
|
|
8156
|
+
*/
|
|
8157
|
+
isAliasOfKnownMicrosoftAuthority(host) {
|
|
8158
|
+
return InstanceDiscoveryMetadataAliases.has(host);
|
|
8159
|
+
}
|
|
8044
8160
|
/**
|
|
8045
8161
|
* Checks whether the provided host is that of a public cloud authority
|
|
8046
8162
|
*
|
|
@@ -8082,15 +8198,17 @@ class Authority {
|
|
|
8082
8198
|
* @param azureRegion string
|
|
8083
8199
|
*/
|
|
8084
8200
|
static replaceWithRegionalInformation(metadata, azureRegion) {
|
|
8085
|
-
metadata
|
|
8086
|
-
|
|
8201
|
+
const regionalMetadata = { ...metadata };
|
|
8202
|
+
regionalMetadata.authorization_endpoint =
|
|
8203
|
+
Authority.buildRegionalAuthorityString(regionalMetadata.authorization_endpoint, azureRegion);
|
|
8087
8204
|
// TODO: Enquire on whether we should leave the query string or remove it before releasing the feature
|
|
8088
|
-
|
|
8089
|
-
|
|
8090
|
-
|
|
8091
|
-
|
|
8205
|
+
regionalMetadata.token_endpoint =
|
|
8206
|
+
Authority.buildRegionalAuthorityString(regionalMetadata.token_endpoint, azureRegion, Constants.REGIONAL_AUTH_NON_MSI_QUERY_STRING);
|
|
8207
|
+
if (regionalMetadata.end_session_endpoint) {
|
|
8208
|
+
regionalMetadata.end_session_endpoint =
|
|
8209
|
+
Authority.buildRegionalAuthorityString(regionalMetadata.end_session_endpoint, azureRegion);
|
|
8092
8210
|
}
|
|
8093
|
-
return
|
|
8211
|
+
return regionalMetadata;
|
|
8094
8212
|
}
|
|
8095
8213
|
/**
|
|
8096
8214
|
* Transform CIAM_AUTHORIY as per the below rules:
|
|
@@ -8102,11 +8220,14 @@ class Authority {
|
|
|
8102
8220
|
* @param authority
|
|
8103
8221
|
*/
|
|
8104
8222
|
static transformCIAMAuthority(authority) {
|
|
8105
|
-
let ciamAuthority = authority.endsWith(Constants.FORWARD_SLASH)
|
|
8223
|
+
let ciamAuthority = authority.endsWith(Constants.FORWARD_SLASH)
|
|
8224
|
+
? authority
|
|
8225
|
+
: `${authority}${Constants.FORWARD_SLASH}`;
|
|
8106
8226
|
const authorityUrl = new UrlString(authority);
|
|
8107
8227
|
const authorityUrlComponents = authorityUrl.getUrlComponents();
|
|
8108
8228
|
// check if transformation is needed
|
|
8109
|
-
if (authorityUrlComponents.PathSegments.length === 0 &&
|
|
8229
|
+
if (authorityUrlComponents.PathSegments.length === 0 &&
|
|
8230
|
+
authorityUrlComponents.HostNameAndPort.endsWith(Constants.CIAM_AUTH_URL)) {
|
|
8110
8231
|
const tenantIdOrDomain = authorityUrlComponents.HostNameAndPort.split(".")[0];
|
|
8111
8232
|
ciamAuthority = `${ciamAuthority}${tenantIdOrDomain}${Constants.AAD_TENANT_DOMAIN_SUFFIX}`;
|
|
8112
8233
|
}
|
|
@@ -8114,15 +8235,15 @@ class Authority {
|
|
|
8114
8235
|
}
|
|
8115
8236
|
}
|
|
8116
8237
|
// Reserved tenant domain names that will not be replaced with tenant id
|
|
8117
|
-
Authority.reservedTenantDomains =
|
|
8238
|
+
Authority.reservedTenantDomains = new Set([
|
|
8118
8239
|
"{tenant}",
|
|
8119
8240
|
"{tenantid}",
|
|
8120
8241
|
AADAuthorityConstants.COMMON,
|
|
8121
8242
|
AADAuthorityConstants.CONSUMERS,
|
|
8122
|
-
AADAuthorityConstants.ORGANIZATIONS
|
|
8123
|
-
])
|
|
8243
|
+
AADAuthorityConstants.ORGANIZATIONS,
|
|
8244
|
+
]);
|
|
8124
8245
|
|
|
8125
|
-
/*! @azure/msal-common v14.0.
|
|
8246
|
+
/*! @azure/msal-common v14.0.1 2023-08-11 */
|
|
8126
8247
|
|
|
8127
8248
|
/*
|
|
8128
8249
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8172,7 +8293,7 @@ class AuthorityFactory {
|
|
|
8172
8293
|
}
|
|
8173
8294
|
}
|
|
8174
8295
|
|
|
8175
|
-
/*! @azure/msal-common v14.0.
|
|
8296
|
+
/*! @azure/msal-common v14.0.1 2023-08-11 */
|
|
8176
8297
|
|
|
8177
8298
|
/*
|
|
8178
8299
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8202,7 +8323,7 @@ class ServerTelemetryEntity {
|
|
|
8202
8323
|
}
|
|
8203
8324
|
}
|
|
8204
8325
|
|
|
8205
|
-
/*! @azure/msal-common v14.0.
|
|
8326
|
+
/*! @azure/msal-common v14.0.1 2023-08-11 */
|
|
8206
8327
|
|
|
8207
8328
|
/*
|
|
8208
8329
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8228,7 +8349,7 @@ class ThrottlingEntity {
|
|
|
8228
8349
|
}
|
|
8229
8350
|
}
|
|
8230
8351
|
|
|
8231
|
-
/*! @azure/msal-common v14.0.
|
|
8352
|
+
/*! @azure/msal-common v14.0.1 2023-08-11 */
|
|
8232
8353
|
|
|
8233
8354
|
/*
|
|
8234
8355
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8245,7 +8366,7 @@ const StubbedNetworkModule = {
|
|
|
8245
8366
|
},
|
|
8246
8367
|
};
|
|
8247
8368
|
|
|
8248
|
-
/*! @azure/msal-common v14.0.
|
|
8369
|
+
/*! @azure/msal-common v14.0.1 2023-08-11 */
|
|
8249
8370
|
|
|
8250
8371
|
/*
|
|
8251
8372
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8287,7 +8408,7 @@ class JoseHeaderError extends AuthError {
|
|
|
8287
8408
|
}
|
|
8288
8409
|
}
|
|
8289
8410
|
|
|
8290
|
-
/*! @azure/msal-common v14.0.
|
|
8411
|
+
/*! @azure/msal-common v14.0.1 2023-08-11 */
|
|
8291
8412
|
|
|
8292
8413
|
/*
|
|
8293
8414
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8326,7 +8447,7 @@ class JoseHeader {
|
|
|
8326
8447
|
}
|
|
8327
8448
|
}
|
|
8328
8449
|
|
|
8329
|
-
/*! @azure/msal-common v14.0.
|
|
8450
|
+
/*! @azure/msal-common v14.0.1 2023-08-11 */
|
|
8330
8451
|
|
|
8331
8452
|
/*
|
|
8332
8453
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8384,7 +8505,7 @@ class AuthenticationHeaderParser {
|
|
|
8384
8505
|
}
|
|
8385
8506
|
}
|
|
8386
8507
|
|
|
8387
|
-
/*! @azure/msal-common v14.0.
|
|
8508
|
+
/*! @azure/msal-common v14.0.1 2023-08-11 */
|
|
8388
8509
|
|
|
8389
8510
|
/*
|
|
8390
8511
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8583,7 +8704,7 @@ class ServerTelemetryManager {
|
|
|
8583
8704
|
}
|
|
8584
8705
|
}
|
|
8585
8706
|
|
|
8586
|
-
/*! @azure/msal-common v14.0.
|
|
8707
|
+
/*! @azure/msal-common v14.0.1 2023-08-11 */
|
|
8587
8708
|
|
|
8588
8709
|
/*
|
|
8589
8710
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8600,8 +8721,10 @@ class PerformanceClient {
|
|
|
8600
8721
|
* @param {Logger} logger Logger used by the application
|
|
8601
8722
|
* @param {string} libraryName Name of the library
|
|
8602
8723
|
* @param {string} libraryVersion Version of the library
|
|
8724
|
+
* @param {ApplicationTelemetry} applicationTelemetry application name and version
|
|
8725
|
+
* @param {Set<String>} intFields integer fields to be truncated
|
|
8603
8726
|
*/
|
|
8604
|
-
constructor(clientId, authority, logger, libraryName, libraryVersion, applicationTelemetry) {
|
|
8727
|
+
constructor(clientId, authority, logger, libraryName, libraryVersion, applicationTelemetry, intFields) {
|
|
8605
8728
|
this.authority = authority;
|
|
8606
8729
|
this.libraryName = libraryName;
|
|
8607
8730
|
this.libraryVersion = libraryVersion;
|
|
@@ -8612,6 +8735,10 @@ class PerformanceClient {
|
|
|
8612
8735
|
this.eventsByCorrelationId = new Map();
|
|
8613
8736
|
this.queueMeasurements = new Map();
|
|
8614
8737
|
this.preQueueTimeByCorrelationId = new Map();
|
|
8738
|
+
this.intFields = intFields || new Set();
|
|
8739
|
+
for (const item of IntFields) {
|
|
8740
|
+
this.intFields.add(item);
|
|
8741
|
+
}
|
|
8615
8742
|
}
|
|
8616
8743
|
/**
|
|
8617
8744
|
* Starts and returns an platform-specific implementation of IPerformanceMeasurement.
|
|
@@ -8626,13 +8753,6 @@ class PerformanceClient {
|
|
|
8626
8753
|
) {
|
|
8627
8754
|
return {};
|
|
8628
8755
|
}
|
|
8629
|
-
/**
|
|
8630
|
-
* Get integral fields.
|
|
8631
|
-
* Override to change the set.
|
|
8632
|
-
*/
|
|
8633
|
-
getIntFields() {
|
|
8634
|
-
return IntFields;
|
|
8635
|
-
}
|
|
8636
8756
|
/**
|
|
8637
8757
|
* Gets map of pre-queue times by correlation Id
|
|
8638
8758
|
*
|
|
@@ -8750,7 +8870,7 @@ class PerformanceClient {
|
|
|
8750
8870
|
this.cacheEventByCorrelationId(inProgressEvent);
|
|
8751
8871
|
// Return the event and functions the caller can use to properly end/flush the measurement
|
|
8752
8872
|
return {
|
|
8753
|
-
|
|
8873
|
+
end: (event) => {
|
|
8754
8874
|
return this.endMeasurement({
|
|
8755
8875
|
// Initial set of event properties
|
|
8756
8876
|
...inProgressEvent,
|
|
@@ -8758,14 +8878,14 @@ class PerformanceClient {
|
|
|
8758
8878
|
...event,
|
|
8759
8879
|
}, performanceMeasurement);
|
|
8760
8880
|
},
|
|
8761
|
-
|
|
8881
|
+
discard: () => {
|
|
8762
8882
|
return this.discardMeasurements(inProgressEvent.correlationId);
|
|
8763
8883
|
},
|
|
8764
|
-
|
|
8765
|
-
return this.
|
|
8884
|
+
add: (fields) => {
|
|
8885
|
+
return this.addFields(fields, inProgressEvent.correlationId);
|
|
8766
8886
|
},
|
|
8767
|
-
increment: (
|
|
8768
|
-
return this.
|
|
8887
|
+
increment: (fields) => {
|
|
8888
|
+
return this.incrementFields(fields, inProgressEvent.correlationId);
|
|
8769
8889
|
},
|
|
8770
8890
|
measurement: performanceMeasurement,
|
|
8771
8891
|
event: inProgressEvent,
|
|
@@ -8830,7 +8950,7 @@ class PerformanceClient {
|
|
|
8830
8950
|
status: PerformanceEventStatus.Completed,
|
|
8831
8951
|
incompleteSubsCount,
|
|
8832
8952
|
};
|
|
8833
|
-
this.truncateIntegralFields(finalEvent
|
|
8953
|
+
this.truncateIntegralFields(finalEvent);
|
|
8834
8954
|
this.emitEvents([finalEvent], event.correlationId);
|
|
8835
8955
|
return finalEvent;
|
|
8836
8956
|
}
|
|
@@ -8839,7 +8959,7 @@ class PerformanceClient {
|
|
|
8839
8959
|
* @param fields
|
|
8840
8960
|
* @param correlationId
|
|
8841
8961
|
*/
|
|
8842
|
-
|
|
8962
|
+
addFields(fields, correlationId) {
|
|
8843
8963
|
this.logger.trace("PerformanceClient: Updating static fields");
|
|
8844
8964
|
const event = this.eventsByCorrelationId.get(correlationId);
|
|
8845
8965
|
if (event) {
|
|
@@ -8854,18 +8974,21 @@ class PerformanceClient {
|
|
|
8854
8974
|
}
|
|
8855
8975
|
/**
|
|
8856
8976
|
* Increment counters to be emitted when the measurements are flushed
|
|
8857
|
-
* @param
|
|
8977
|
+
* @param fields {string[]}
|
|
8858
8978
|
* @param correlationId {string} correlation identifier
|
|
8859
8979
|
*/
|
|
8860
|
-
|
|
8980
|
+
incrementFields(fields, correlationId) {
|
|
8861
8981
|
this.logger.trace("PerformanceClient: Updating counters");
|
|
8862
8982
|
const event = this.eventsByCorrelationId.get(correlationId);
|
|
8863
8983
|
if (event) {
|
|
8864
|
-
for (const counter in
|
|
8984
|
+
for (const counter in fields) {
|
|
8865
8985
|
if (!event.hasOwnProperty(counter)) {
|
|
8866
8986
|
event[counter] = 0;
|
|
8867
8987
|
}
|
|
8868
|
-
event[counter]
|
|
8988
|
+
else if (isNaN(Number(event[counter]))) {
|
|
8989
|
+
return;
|
|
8990
|
+
}
|
|
8991
|
+
event[counter] += fields[counter];
|
|
8869
8992
|
}
|
|
8870
8993
|
}
|
|
8871
8994
|
else {
|
|
@@ -8983,8 +9106,8 @@ class PerformanceClient {
|
|
|
8983
9106
|
* @param {PerformanceEvent} event performance event to update.
|
|
8984
9107
|
* @param {Set<string>} intFields integral fields.
|
|
8985
9108
|
*/
|
|
8986
|
-
truncateIntegralFields(event
|
|
8987
|
-
intFields.forEach((key) => {
|
|
9109
|
+
truncateIntegralFields(event) {
|
|
9110
|
+
this.intFields.forEach((key) => {
|
|
8988
9111
|
if (key in event && typeof event[key] === "number") {
|
|
8989
9112
|
event[key] = Math.floor(event[key]);
|
|
8990
9113
|
}
|
|
@@ -8992,16 +9115,22 @@ class PerformanceClient {
|
|
|
8992
9115
|
}
|
|
8993
9116
|
}
|
|
8994
9117
|
|
|
8995
|
-
/*! @azure/msal-common v14.0.
|
|
9118
|
+
/*! @azure/msal-common v14.0.1 2023-08-11 */
|
|
8996
9119
|
|
|
8997
9120
|
/*
|
|
8998
9121
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
8999
9122
|
* Licensed under the MIT License.
|
|
9000
9123
|
*/
|
|
9001
9124
|
class StubPerformanceMeasurement {
|
|
9002
|
-
startMeasurement() {
|
|
9003
|
-
|
|
9004
|
-
|
|
9125
|
+
startMeasurement() {
|
|
9126
|
+
return;
|
|
9127
|
+
}
|
|
9128
|
+
endMeasurement() {
|
|
9129
|
+
return;
|
|
9130
|
+
}
|
|
9131
|
+
flushMeasurement() {
|
|
9132
|
+
return null;
|
|
9133
|
+
}
|
|
9005
9134
|
}
|
|
9006
9135
|
class StubPerformanceClient extends PerformanceClient {
|
|
9007
9136
|
generateId() {
|
|
@@ -9013,8 +9142,36 @@ class StubPerformanceClient extends PerformanceClient {
|
|
|
9013
9142
|
calculateQueuedTime() {
|
|
9014
9143
|
return 0;
|
|
9015
9144
|
}
|
|
9016
|
-
addQueueMeasurement() {
|
|
9017
|
-
|
|
9145
|
+
addQueueMeasurement() {
|
|
9146
|
+
return;
|
|
9147
|
+
}
|
|
9148
|
+
setPreQueueTime() {
|
|
9149
|
+
return;
|
|
9150
|
+
}
|
|
9151
|
+
endMeasurement() {
|
|
9152
|
+
return null;
|
|
9153
|
+
}
|
|
9154
|
+
discardMeasurements() {
|
|
9155
|
+
return;
|
|
9156
|
+
}
|
|
9157
|
+
removePerformanceCallback() {
|
|
9158
|
+
return true;
|
|
9159
|
+
}
|
|
9160
|
+
addPerformanceCallback() {
|
|
9161
|
+
return "";
|
|
9162
|
+
}
|
|
9163
|
+
emitEvents() {
|
|
9164
|
+
return;
|
|
9165
|
+
}
|
|
9166
|
+
addFields() {
|
|
9167
|
+
return;
|
|
9168
|
+
}
|
|
9169
|
+
incrementFields() {
|
|
9170
|
+
return;
|
|
9171
|
+
}
|
|
9172
|
+
cacheEventByCorrelationId() {
|
|
9173
|
+
return;
|
|
9174
|
+
}
|
|
9018
9175
|
}
|
|
9019
9176
|
|
|
9020
9177
|
/*
|
|
@@ -9197,9 +9354,9 @@ const BrowserAuthErrorMessage = {
|
|
|
9197
9354
|
code: "native_connection_not_established",
|
|
9198
9355
|
desc: "Connection to native platform has not been established. Please install a compatible browser extension and run initialize(). For more please visit aka.ms/msaljs/browser-errors.",
|
|
9199
9356
|
},
|
|
9200
|
-
|
|
9201
|
-
code: "
|
|
9202
|
-
desc: "You must call and await the initialize function before attempting to call any other MSAL API
|
|
9357
|
+
uninitializedPublicClientApplication: {
|
|
9358
|
+
code: "uninitialized_public_client_application",
|
|
9359
|
+
desc: "You must call and await the initialize function before attempting to call any other MSAL API. For more please visit aka.ms/msaljs/browser-errors.",
|
|
9203
9360
|
},
|
|
9204
9361
|
nativePromptNotSupported: {
|
|
9205
9362
|
code: "native_prompt_not_supported",
|
|
@@ -9489,8 +9646,8 @@ class BrowserAuthError extends AuthError {
|
|
|
9489
9646
|
/**
|
|
9490
9647
|
* Create an error thrown when the initialize function hasn't been called
|
|
9491
9648
|
*/
|
|
9492
|
-
static
|
|
9493
|
-
return new BrowserAuthError(BrowserAuthErrorMessage.
|
|
9649
|
+
static createUninitializedPublicClientApplication() {
|
|
9650
|
+
return new BrowserAuthError(BrowserAuthErrorMessage.uninitializedPublicClientApplication.code, BrowserAuthErrorMessage.uninitializedPublicClientApplication.desc);
|
|
9494
9651
|
}
|
|
9495
9652
|
/**
|
|
9496
9653
|
* Create an error thrown when requesting a token directly from the native platform with an unsupported prompt parameter e.g. select_account, login or create
|
|
@@ -11171,6 +11328,23 @@ class BrowserCacheManager extends CacheManager {
|
|
|
11171
11328
|
setRedirectRequestContext(value) {
|
|
11172
11329
|
this.setTemporaryCache(TemporaryCacheKeys.REDIRECT_CONTEXT, value, true);
|
|
11173
11330
|
}
|
|
11331
|
+
/**
|
|
11332
|
+
* Builds credential entities from AuthenticationResult object and saves the resulting credentials to the cache
|
|
11333
|
+
* @param result
|
|
11334
|
+
* @param request
|
|
11335
|
+
*/
|
|
11336
|
+
async hydrateCache(result, request) {
|
|
11337
|
+
const idTokenEntity = IdTokenEntity.createIdTokenEntity(result.account?.homeAccountId, result.account?.environment, result.idToken, this.clientId, result.tenantId);
|
|
11338
|
+
let claimsHash;
|
|
11339
|
+
if (request.claims) {
|
|
11340
|
+
claimsHash = await this.cryptoImpl.hashString(request.claims);
|
|
11341
|
+
}
|
|
11342
|
+
const accessTokenEntity = AccessTokenEntity.createAccessTokenEntity(result.account?.homeAccountId, result.account.environment, result.accessToken, this.clientId, result.tenantId, result.scopes.join(" "), result.expiresOn?.getTime() || 0, result.extExpiresOn?.getTime() || 0, this.cryptoImpl, undefined, // refreshOn
|
|
11343
|
+
result.tokenType, undefined, // userAssertionHash
|
|
11344
|
+
request.sshKid, request.claims, claimsHash);
|
|
11345
|
+
const cacheRecord = new CacheRecord(undefined, idTokenEntity, accessTokenEntity);
|
|
11346
|
+
return this.saveCacheRecord(cacheRecord);
|
|
11347
|
+
}
|
|
11174
11348
|
}
|
|
11175
11349
|
const DEFAULT_BROWSER_CACHE_MANAGER = (clientId, logger) => {
|
|
11176
11350
|
const cacheOptions = {
|
|
@@ -11184,20 +11358,9 @@ const DEFAULT_BROWSER_CACHE_MANAGER = (clientId, logger) => {
|
|
|
11184
11358
|
return new BrowserCacheManager(clientId, cacheOptions, DEFAULT_CRYPTO_IMPLEMENTATION, logger);
|
|
11185
11359
|
};
|
|
11186
11360
|
|
|
11187
|
-
/*
|
|
11188
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
11189
|
-
* Licensed under the MIT License.
|
|
11190
|
-
*/
|
|
11191
|
-
class CacheRecord extends CacheRecord$1 {
|
|
11192
|
-
constructor(accountEntity, idTokenEntity, accessTokenEntity, refreshTokenEntity, appMetadataEntity) {
|
|
11193
|
-
super(accountEntity, idTokenEntity, accessTokenEntity, refreshTokenEntity, appMetadataEntity);
|
|
11194
|
-
this.account = accountEntity;
|
|
11195
|
-
}
|
|
11196
|
-
}
|
|
11197
|
-
|
|
11198
11361
|
/* eslint-disable header/header */
|
|
11199
11362
|
const name = "@azure/msal-browser";
|
|
11200
|
-
const version = "3.0.
|
|
11363
|
+
const version = "3.0.1";
|
|
11201
11364
|
|
|
11202
11365
|
/*
|
|
11203
11366
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -11533,13 +11696,12 @@ class BrowserUtils {
|
|
|
11533
11696
|
}
|
|
11534
11697
|
}
|
|
11535
11698
|
/**
|
|
11536
|
-
* Throws error if
|
|
11537
|
-
* @param allowNativeBroker
|
|
11699
|
+
* Throws error if initialize hasn't been called
|
|
11538
11700
|
* @param initialized
|
|
11539
11701
|
*/
|
|
11540
|
-
static
|
|
11541
|
-
if (
|
|
11542
|
-
throw BrowserAuthError.
|
|
11702
|
+
static blockAPICallsBeforeInitialize(initialized) {
|
|
11703
|
+
if (!initialized) {
|
|
11704
|
+
throw BrowserAuthError.createUninitializedPublicClientApplication();
|
|
11543
11705
|
}
|
|
11544
11706
|
}
|
|
11545
11707
|
/**
|
|
@@ -11698,6 +11860,7 @@ class BaseInteractionClient {
|
|
|
11698
11860
|
this.logger.verbose("getDiscoveredAuthority called");
|
|
11699
11861
|
const authorityOptions = {
|
|
11700
11862
|
protocolMode: this.config.auth.protocolMode,
|
|
11863
|
+
OIDCOptions: this.config.auth.OIDCOptions,
|
|
11701
11864
|
knownAuthorities: this.config.auth.knownAuthorities,
|
|
11702
11865
|
cloudDiscoveryMetadata: this.config.auth.cloudDiscoveryMetadata,
|
|
11703
11866
|
authorityMetadata: this.config.auth.authorityMetadata,
|
|
@@ -11907,6 +12070,7 @@ class StandardInteractionClient extends BaseInteractionClient {
|
|
|
11907
12070
|
const getAuthorityMeasurement = this.performanceClient?.startMeasurement(PerformanceEvents.StandardInteractionClientGetDiscoveredAuthority, this.correlationId);
|
|
11908
12071
|
const authorityOptions = {
|
|
11909
12072
|
protocolMode: this.config.auth.protocolMode,
|
|
12073
|
+
OIDCOptions: this.config.auth.OIDCOptions,
|
|
11910
12074
|
knownAuthorities: this.config.auth.knownAuthorities,
|
|
11911
12075
|
cloudDiscoveryMetadata: this.config.auth.cloudDiscoveryMetadata,
|
|
11912
12076
|
authorityMetadata: this.config.auth.authorityMetadata,
|
|
@@ -11922,13 +12086,13 @@ class StandardInteractionClient extends BaseInteractionClient {
|
|
|
11922
12086
|
this.performanceClient.setPreQueueTime(PerformanceEvents.AuthorityFactoryCreateDiscoveredInstance, this.correlationId);
|
|
11923
12087
|
return await AuthorityFactory.createDiscoveredInstance(builtAuthority, this.config.system.networkClient, this.browserStorage, authorityOptions, this.logger, this.performanceClient, this.correlationId)
|
|
11924
12088
|
.then((result) => {
|
|
11925
|
-
getAuthorityMeasurement.
|
|
12089
|
+
getAuthorityMeasurement.end({
|
|
11926
12090
|
success: true,
|
|
11927
12091
|
});
|
|
11928
12092
|
return result;
|
|
11929
12093
|
})
|
|
11930
12094
|
.catch((error) => {
|
|
11931
|
-
getAuthorityMeasurement.
|
|
12095
|
+
getAuthorityMeasurement.end({
|
|
11932
12096
|
errorCode: error.errorCode,
|
|
11933
12097
|
subErrorCode: error.subError,
|
|
11934
12098
|
success: false,
|
|
@@ -11955,7 +12119,8 @@ class StandardInteractionClient extends BaseInteractionClient {
|
|
|
11955
12119
|
redirectUri: redirectUri,
|
|
11956
12120
|
state: state,
|
|
11957
12121
|
nonce: request.nonce || this.browserCrypto.createNewGuid(),
|
|
11958
|
-
responseMode:
|
|
12122
|
+
responseMode: this.config.auth.OIDCOptions
|
|
12123
|
+
.serverResponseType,
|
|
11959
12124
|
};
|
|
11960
12125
|
const account = request.account || this.browserStorage.getActiveAccount();
|
|
11961
12126
|
if (account) {
|
|
@@ -12067,7 +12232,7 @@ class InteractionHandler {
|
|
|
12067
12232
|
}
|
|
12068
12233
|
// Acquire token with retrieved code.
|
|
12069
12234
|
this.performanceClient.setPreQueueTime(PerformanceEvents.AuthClientAcquireToken, this.authCodeRequest.correlationId);
|
|
12070
|
-
const tokenResponse = await this.authModule.acquireToken(this.authCodeRequest, authCodeResponse);
|
|
12235
|
+
const tokenResponse = (await this.authModule.acquireToken(this.authCodeRequest, authCodeResponse));
|
|
12071
12236
|
this.browserStorage.cleanRequestByState(state);
|
|
12072
12237
|
return tokenResponse;
|
|
12073
12238
|
}
|
|
@@ -12215,7 +12380,7 @@ class RedirectHandler extends InteractionHandler {
|
|
|
12215
12380
|
}
|
|
12216
12381
|
}
|
|
12217
12382
|
// Acquire token with retrieved code.
|
|
12218
|
-
const tokenResponse = await this.authModule.acquireToken(this.authCodeRequest, authCodeResponse);
|
|
12383
|
+
const tokenResponse = (await this.authModule.acquireToken(this.authCodeRequest, authCodeResponse));
|
|
12219
12384
|
this.browserStorage.cleanRequestByState(state);
|
|
12220
12385
|
return tokenResponse;
|
|
12221
12386
|
}
|
|
@@ -12250,7 +12415,7 @@ const EventType = {
|
|
|
12250
12415
|
LOGOUT_SUCCESS: "msal:logoutSuccess",
|
|
12251
12416
|
LOGOUT_FAILURE: "msal:logoutFailure",
|
|
12252
12417
|
LOGOUT_END: "msal:logoutEnd",
|
|
12253
|
-
RESTORE_FROM_BFCACHE: "msal:restoreFromBFCache"
|
|
12418
|
+
RESTORE_FROM_BFCACHE: "msal:restoreFromBFCache",
|
|
12254
12419
|
};
|
|
12255
12420
|
|
|
12256
12421
|
/*
|
|
@@ -12363,8 +12528,8 @@ class SilentCacheClient extends StandardInteractionClient {
|
|
|
12363
12528
|
const silentAuthClient = await this.createSilentFlowClient(serverTelemetryManager, silentRequest.authority, silentRequest.azureCloudOptions);
|
|
12364
12529
|
this.logger.verbose("Silent auth client created");
|
|
12365
12530
|
try {
|
|
12366
|
-
const cachedToken = await silentAuthClient.acquireCachedToken(silentRequest);
|
|
12367
|
-
acquireTokenMeasurement.
|
|
12531
|
+
const cachedToken = (await silentAuthClient.acquireCachedToken(silentRequest));
|
|
12532
|
+
acquireTokenMeasurement.end({
|
|
12368
12533
|
success: true,
|
|
12369
12534
|
fromCache: true,
|
|
12370
12535
|
});
|
|
@@ -12376,7 +12541,7 @@ class SilentCacheClient extends StandardInteractionClient {
|
|
|
12376
12541
|
BrowserAuthErrorMessage.signingKeyNotFoundInStorage.code) {
|
|
12377
12542
|
this.logger.verbose("Signing keypair for bound access token not found. Refreshing bound access token and generating a new crypto keypair.");
|
|
12378
12543
|
}
|
|
12379
|
-
acquireTokenMeasurement.
|
|
12544
|
+
acquireTokenMeasurement.end({
|
|
12380
12545
|
errorCode: (error instanceof AuthError && error.errorCode) ||
|
|
12381
12546
|
undefined,
|
|
12382
12547
|
subErrorCode: (error instanceof AuthError && error.subError) || undefined,
|
|
@@ -12408,7 +12573,7 @@ class SilentCacheClient extends StandardInteractionClient {
|
|
|
12408
12573
|
this.performanceClient.setPreQueueTime(PerformanceEvents.InitializeBaseRequest, this.correlationId);
|
|
12409
12574
|
return {
|
|
12410
12575
|
...request,
|
|
12411
|
-
...await this.initializeBaseRequest(request, account),
|
|
12576
|
+
...(await this.initializeBaseRequest(request, account)),
|
|
12412
12577
|
account: account,
|
|
12413
12578
|
forceRefresh: request.forceRefresh || false,
|
|
12414
12579
|
};
|
|
@@ -12419,6 +12584,10 @@ class SilentCacheClient extends StandardInteractionClient {
|
|
|
12419
12584
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
12420
12585
|
* Licensed under the MIT License.
|
|
12421
12586
|
*/
|
|
12587
|
+
const BrokerServerParamKeys = {
|
|
12588
|
+
BROKER_CLIENT_ID: "brk_client_id",
|
|
12589
|
+
BROKER_REDIRECT_URI: "brk_redirect_uri",
|
|
12590
|
+
};
|
|
12422
12591
|
class NativeInteractionClient extends BaseInteractionClient {
|
|
12423
12592
|
constructor(config, browserStorage, browserCrypto, logger, eventHandler, navigationClient, apiId, performanceClient, provider, accountId, nativeStorageImpl, correlationId) {
|
|
12424
12593
|
super(config, browserStorage, browserCrypto, logger, eventHandler, navigationClient, performanceClient, provider, correlationId);
|
|
@@ -12442,7 +12611,7 @@ class NativeInteractionClient extends BaseInteractionClient {
|
|
|
12442
12611
|
// check if the tokens can be retrieved from internal cache
|
|
12443
12612
|
try {
|
|
12444
12613
|
const result = await this.acquireTokensFromCache(this.accountId, nativeRequest);
|
|
12445
|
-
nativeATMeasurement.
|
|
12614
|
+
nativeATMeasurement.end({
|
|
12446
12615
|
success: true,
|
|
12447
12616
|
isNativeBroker: false,
|
|
12448
12617
|
fromCache: true,
|
|
@@ -12462,7 +12631,7 @@ class NativeInteractionClient extends BaseInteractionClient {
|
|
|
12462
12631
|
const validatedResponse = this.validateNativeResponse(response);
|
|
12463
12632
|
return this.handleNativeResponse(validatedResponse, nativeRequest, reqTimestamp)
|
|
12464
12633
|
.then((result) => {
|
|
12465
|
-
nativeATMeasurement.
|
|
12634
|
+
nativeATMeasurement.end({
|
|
12466
12635
|
success: true,
|
|
12467
12636
|
isNativeBroker: true,
|
|
12468
12637
|
requestId: result.requestId,
|
|
@@ -12470,7 +12639,7 @@ class NativeInteractionClient extends BaseInteractionClient {
|
|
|
12470
12639
|
return result;
|
|
12471
12640
|
})
|
|
12472
12641
|
.catch((error) => {
|
|
12473
|
-
nativeATMeasurement.
|
|
12642
|
+
nativeATMeasurement.end({
|
|
12474
12643
|
success: false,
|
|
12475
12644
|
errorCode: error.errorCode,
|
|
12476
12645
|
subErrorCode: error.subError,
|
|
@@ -12516,7 +12685,10 @@ class NativeInteractionClient extends BaseInteractionClient {
|
|
|
12516
12685
|
try {
|
|
12517
12686
|
const silentRequest = this.createSilentCacheRequest(request, account);
|
|
12518
12687
|
const result = await this.silentCacheClient.acquireToken(silentRequest);
|
|
12519
|
-
return
|
|
12688
|
+
return {
|
|
12689
|
+
...result,
|
|
12690
|
+
account,
|
|
12691
|
+
};
|
|
12520
12692
|
}
|
|
12521
12693
|
catch (e) {
|
|
12522
12694
|
throw e;
|
|
@@ -12614,16 +12786,20 @@ class NativeInteractionClient extends BaseInteractionClient {
|
|
|
12614
12786
|
}
|
|
12615
12787
|
// Get the preferred_cache domain for the given authority
|
|
12616
12788
|
const authority = await this.getDiscoveredAuthority(request.authority);
|
|
12617
|
-
const authorityPreferredCache = authority.getPreferredCache();
|
|
12618
12789
|
// generate identifiers
|
|
12619
12790
|
const idTokenObj = this.createIdTokenObj(response);
|
|
12620
12791
|
const homeAccountIdentifier = this.createHomeAccountIdentifier(response, idTokenObj);
|
|
12621
|
-
const accountEntity =
|
|
12792
|
+
const accountEntity = AccountEntity.createAccount({
|
|
12793
|
+
homeAccountId: homeAccountIdentifier,
|
|
12794
|
+
idTokenClaims: idTokenObj.claims,
|
|
12795
|
+
clientInfo: response.client_info,
|
|
12796
|
+
nativeAccountId: response.account.id,
|
|
12797
|
+
}, authority);
|
|
12622
12798
|
// generate authenticationResult
|
|
12623
12799
|
const result = await this.generateAuthenticationResult(response, request, idTokenObj, accountEntity, authority.canonicalAuthority, reqTimestamp);
|
|
12624
12800
|
// cache accounts and tokens in the appropriate storage
|
|
12625
12801
|
this.cacheAccount(accountEntity);
|
|
12626
|
-
this.cacheNativeTokens(response, request, homeAccountIdentifier,
|
|
12802
|
+
this.cacheNativeTokens(response, request, homeAccountIdentifier, idTokenObj, result.accessToken, result.tenantId, reqTimestamp);
|
|
12627
12803
|
return result;
|
|
12628
12804
|
}
|
|
12629
12805
|
/**
|
|
@@ -12642,20 +12818,9 @@ class NativeInteractionClient extends BaseInteractionClient {
|
|
|
12642
12818
|
*/
|
|
12643
12819
|
createHomeAccountIdentifier(response, idTokenObj) {
|
|
12644
12820
|
// Save account in browser storage
|
|
12645
|
-
const homeAccountIdentifier = AccountEntity.generateHomeAccountId(response.client_info || Constants.EMPTY_STRING, AuthorityType.Default, this.logger, this.browserCrypto, idTokenObj);
|
|
12821
|
+
const homeAccountIdentifier = AccountEntity.generateHomeAccountId(response.client_info || Constants.EMPTY_STRING, AuthorityType.Default, this.logger, this.browserCrypto, idTokenObj.claims);
|
|
12646
12822
|
return homeAccountIdentifier;
|
|
12647
12823
|
}
|
|
12648
|
-
/**
|
|
12649
|
-
* Creates account entity
|
|
12650
|
-
* @param response
|
|
12651
|
-
* @param homeAccountIdentifier
|
|
12652
|
-
* @param idTokenObj
|
|
12653
|
-
* @param authority
|
|
12654
|
-
* @returns
|
|
12655
|
-
*/
|
|
12656
|
-
createAccountEntity(response, homeAccountIdentifier, idTokenObj, authority) {
|
|
12657
|
-
return AccountEntity.createAccount(response.client_info, homeAccountIdentifier, idTokenObj, undefined, undefined, undefined, authority, response.account.id);
|
|
12658
|
-
}
|
|
12659
12824
|
/**
|
|
12660
12825
|
* Helper to generate scopes
|
|
12661
12826
|
* @param response
|
|
@@ -12774,7 +12939,7 @@ class NativeInteractionClient extends BaseInteractionClient {
|
|
|
12774
12939
|
* @param tenantId
|
|
12775
12940
|
* @param reqTimestamp
|
|
12776
12941
|
*/
|
|
12777
|
-
cacheNativeTokens(response, request, homeAccountIdentifier,
|
|
12942
|
+
cacheNativeTokens(response, request, homeAccountIdentifier, idTokenObj, responseAccessToken, tenantId, reqTimestamp) {
|
|
12778
12943
|
const cachedIdToken = IdTokenEntity.createIdTokenEntity(homeAccountIdentifier, request.authority, response.id_token || Constants.EMPTY_STRING, request.clientId, idTokenObj.claims.tid || Constants.EMPTY_STRING);
|
|
12779
12944
|
// cache accessToken in inmemory storage
|
|
12780
12945
|
const expiresIn = request.tokenType === AuthenticationScheme.POP
|
|
@@ -12787,15 +12952,15 @@ class NativeInteractionClient extends BaseInteractionClient {
|
|
|
12787
12952
|
const cachedAccessToken = AccessTokenEntity.createAccessTokenEntity(homeAccountIdentifier, request.authority, responseAccessToken, request.clientId, idTokenObj
|
|
12788
12953
|
? idTokenObj.claims.tid || Constants.EMPTY_STRING
|
|
12789
12954
|
: tenantId, responseScopes.printScopes(), tokenExpirationSeconds, 0, this.browserCrypto);
|
|
12790
|
-
const nativeCacheRecord = new CacheRecord(
|
|
12791
|
-
this.nativeStorageManager.saveCacheRecord(nativeCacheRecord);
|
|
12955
|
+
const nativeCacheRecord = new CacheRecord(undefined, cachedIdToken, cachedAccessToken);
|
|
12956
|
+
this.nativeStorageManager.saveCacheRecord(nativeCacheRecord, request.storeInCache);
|
|
12792
12957
|
}
|
|
12793
12958
|
addTelemetryFromNativeResponse(response) {
|
|
12794
12959
|
const mats = this.getMATSFromResponse(response);
|
|
12795
12960
|
if (!mats) {
|
|
12796
12961
|
return null;
|
|
12797
12962
|
}
|
|
12798
|
-
this.performanceClient.
|
|
12963
|
+
this.performanceClient.addFields({
|
|
12799
12964
|
extensionId: this.nativeMessageHandler.getExtensionId(),
|
|
12800
12965
|
extensionVersion: this.nativeMessageHandler.getExtensionVersion(),
|
|
12801
12966
|
matsBrokerVersion: mats.broker_version,
|
|
@@ -12914,10 +13079,14 @@ class NativeInteractionClient extends BaseInteractionClient {
|
|
|
12914
13079
|
extraParameters: {
|
|
12915
13080
|
...request.extraQueryParameters,
|
|
12916
13081
|
...request.tokenQueryParameters,
|
|
12917
|
-
telemetry: NativeConstants.MATS_TELEMETRY,
|
|
12918
13082
|
},
|
|
12919
13083
|
extendedExpiryToken: false, // Make this configurable?
|
|
12920
13084
|
};
|
|
13085
|
+
this.handleExtraBrokerParams(validatedRequest);
|
|
13086
|
+
validatedRequest.extraParameters =
|
|
13087
|
+
validatedRequest.extraParameters || {};
|
|
13088
|
+
validatedRequest.extraParameters.telemetry =
|
|
13089
|
+
NativeConstants.MATS_TELEMETRY;
|
|
12921
13090
|
if (request.authenticationScheme === AuthenticationScheme.POP) {
|
|
12922
13091
|
// add POP request type
|
|
12923
13092
|
const shrParameters = {
|
|
@@ -12934,6 +13103,28 @@ class NativeInteractionClient extends BaseInteractionClient {
|
|
|
12934
13103
|
}
|
|
12935
13104
|
return validatedRequest;
|
|
12936
13105
|
}
|
|
13106
|
+
/**
|
|
13107
|
+
* Handles extra broker request parameters
|
|
13108
|
+
* @param request {NativeTokenRequest}
|
|
13109
|
+
* @private
|
|
13110
|
+
*/
|
|
13111
|
+
handleExtraBrokerParams(request) {
|
|
13112
|
+
if (!request.extraParameters) {
|
|
13113
|
+
return;
|
|
13114
|
+
}
|
|
13115
|
+
if (request.extraParameters.hasOwnProperty(BrokerServerParamKeys.BROKER_CLIENT_ID) &&
|
|
13116
|
+
request.extraParameters.hasOwnProperty(BrokerServerParamKeys.BROKER_REDIRECT_URI) &&
|
|
13117
|
+
request.extraParameters.hasOwnProperty(AADServerParamKeys.CLIENT_ID)) {
|
|
13118
|
+
const child_client_id = request.extraParameters[AADServerParamKeys.CLIENT_ID];
|
|
13119
|
+
const child_redirect_uri = request.redirectUri;
|
|
13120
|
+
const brk_redirect_uri = request.extraParameters[BrokerServerParamKeys.BROKER_REDIRECT_URI];
|
|
13121
|
+
request.extraParameters = {
|
|
13122
|
+
child_client_id,
|
|
13123
|
+
child_redirect_uri,
|
|
13124
|
+
};
|
|
13125
|
+
request.redirectUri = brk_redirect_uri;
|
|
13126
|
+
}
|
|
13127
|
+
}
|
|
12937
13128
|
}
|
|
12938
13129
|
|
|
12939
13130
|
/*
|
|
@@ -13008,7 +13199,7 @@ class NativeMessageHandler {
|
|
|
13008
13199
|
method: NativeExtensionMethod.HandshakeRequest,
|
|
13009
13200
|
},
|
|
13010
13201
|
};
|
|
13011
|
-
this.handshakeEvent.
|
|
13202
|
+
this.handshakeEvent.add({
|
|
13012
13203
|
extensionId: this.extensionId,
|
|
13013
13204
|
extensionHandshakeTimeoutMs: this.handshakeTimeoutMs,
|
|
13014
13205
|
});
|
|
@@ -13026,7 +13217,7 @@ class NativeMessageHandler {
|
|
|
13026
13217
|
window.removeEventListener("message", this.windowListener, false);
|
|
13027
13218
|
this.messageChannel.port1.close();
|
|
13028
13219
|
this.messageChannel.port2.close();
|
|
13029
|
-
this.handshakeEvent.
|
|
13220
|
+
this.handshakeEvent.end({
|
|
13030
13221
|
extensionHandshakeTimedOut: true,
|
|
13031
13222
|
success: false,
|
|
13032
13223
|
});
|
|
@@ -13071,7 +13262,7 @@ class NativeMessageHandler {
|
|
|
13071
13262
|
this.messageChannel.port1.close();
|
|
13072
13263
|
this.messageChannel.port2.close();
|
|
13073
13264
|
window.removeEventListener("message", this.windowListener, false);
|
|
13074
|
-
this.handshakeEvent.
|
|
13265
|
+
this.handshakeEvent.end({
|
|
13075
13266
|
success: false,
|
|
13076
13267
|
extensionInstalled: false,
|
|
13077
13268
|
});
|
|
@@ -13123,7 +13314,7 @@ class NativeMessageHandler {
|
|
|
13123
13314
|
this.extensionId = request.extensionId;
|
|
13124
13315
|
this.extensionVersion = request.body.version;
|
|
13125
13316
|
this.logger.verbose(`NativeMessageHandler - Received HandshakeResponse from extension: ${this.extensionId}`);
|
|
13126
|
-
this.handshakeEvent.
|
|
13317
|
+
this.handshakeEvent.end({
|
|
13127
13318
|
extensionInstalled: true,
|
|
13128
13319
|
success: true,
|
|
13129
13320
|
});
|
|
@@ -13432,6 +13623,18 @@ class RedirectClient extends StandardInteractionClient {
|
|
|
13432
13623
|
this.performanceClient.setPreQueueTime(PerformanceEvents.StandardInteractionClientCreateAuthCodeClient, validLogoutRequest.correlationId);
|
|
13433
13624
|
const authClient = await this.createAuthCodeClient(serverTelemetryManager, logoutRequest && logoutRequest.authority);
|
|
13434
13625
|
this.logger.verbose("Auth code client created");
|
|
13626
|
+
if (authClient.authority.protocolMode === ProtocolMode.OIDC) {
|
|
13627
|
+
try {
|
|
13628
|
+
authClient.authority.endSessionEndpoint;
|
|
13629
|
+
}
|
|
13630
|
+
catch {
|
|
13631
|
+
if (validLogoutRequest.account?.homeAccountId) {
|
|
13632
|
+
this.browserStorage.removeAccount(validLogoutRequest.account?.homeAccountId);
|
|
13633
|
+
this.eventHandler.emitEvent(EventType.LOGOUT_SUCCESS, exports.InteractionType.Redirect, validLogoutRequest);
|
|
13634
|
+
return;
|
|
13635
|
+
}
|
|
13636
|
+
}
|
|
13637
|
+
}
|
|
13435
13638
|
// Create logout string and navigate user window to logout.
|
|
13436
13639
|
const logoutUri = authClient.getLogoutUri(validLogoutRequest);
|
|
13437
13640
|
this.eventHandler.emitEvent(EventType.LOGOUT_SUCCESS, exports.InteractionType.Redirect, validLogoutRequest);
|
|
@@ -13606,7 +13809,7 @@ class PopupClient extends StandardInteractionClient {
|
|
|
13606
13809
|
this.logger.verbose("Account id found in hash, calling WAM for token");
|
|
13607
13810
|
// end measurement for server call with native brokering enabled
|
|
13608
13811
|
if (fetchNativeAccountIdMeasurement) {
|
|
13609
|
-
fetchNativeAccountIdMeasurement.
|
|
13812
|
+
fetchNativeAccountIdMeasurement.end({
|
|
13610
13813
|
success: true,
|
|
13611
13814
|
isNativeBroker: true,
|
|
13612
13815
|
});
|
|
@@ -13663,6 +13866,30 @@ class PopupClient extends StandardInteractionClient {
|
|
|
13663
13866
|
this.performanceClient.setPreQueueTime(PerformanceEvents.StandardInteractionClientCreateAuthCodeClient, validRequest.correlationId);
|
|
13664
13867
|
const authClient = await this.createAuthCodeClient(serverTelemetryManager, requestAuthority);
|
|
13665
13868
|
this.logger.verbose("Auth code client created");
|
|
13869
|
+
try {
|
|
13870
|
+
authClient.authority.endSessionEndpoint;
|
|
13871
|
+
}
|
|
13872
|
+
catch {
|
|
13873
|
+
if (validRequest.account?.homeAccountId &&
|
|
13874
|
+
validRequest.postLogoutRedirectUri &&
|
|
13875
|
+
authClient.authority.protocolMode === ProtocolMode.OIDC) {
|
|
13876
|
+
this.browserStorage.removeAccount(validRequest.account?.homeAccountId);
|
|
13877
|
+
this.eventHandler.emitEvent(EventType.LOGOUT_SUCCESS, exports.InteractionType.Popup, validRequest);
|
|
13878
|
+
if (mainWindowRedirectUri) {
|
|
13879
|
+
const navigationOptions = {
|
|
13880
|
+
apiId: ApiId.logoutPopup,
|
|
13881
|
+
timeout: this.config.system.redirectNavigationTimeout,
|
|
13882
|
+
noHistory: false,
|
|
13883
|
+
};
|
|
13884
|
+
const absoluteUrl = UrlString.getAbsoluteUrl(mainWindowRedirectUri, BrowserUtils.getCurrentUri());
|
|
13885
|
+
await this.navigationClient.navigateInternal(absoluteUrl, navigationOptions);
|
|
13886
|
+
}
|
|
13887
|
+
if (popup) {
|
|
13888
|
+
popup.close();
|
|
13889
|
+
}
|
|
13890
|
+
return;
|
|
13891
|
+
}
|
|
13892
|
+
}
|
|
13666
13893
|
// Create logout string and navigate user window to logout.
|
|
13667
13894
|
const logoutUri = authClient.getLogoutUri(validRequest);
|
|
13668
13895
|
this.eventHandler.emitEvent(EventType.LOGOUT_SUCCESS, exports.InteractionType.Popup, validRequest);
|
|
@@ -13747,7 +13974,7 @@ class PopupClient extends StandardInteractionClient {
|
|
|
13747
13974
|
return;
|
|
13748
13975
|
}
|
|
13749
13976
|
let href = Constants.EMPTY_STRING;
|
|
13750
|
-
let
|
|
13977
|
+
let serverResponseString = Constants.EMPTY_STRING;
|
|
13751
13978
|
try {
|
|
13752
13979
|
/*
|
|
13753
13980
|
* Will throw if cross origin,
|
|
@@ -13755,7 +13982,8 @@ class PopupClient extends StandardInteractionClient {
|
|
|
13755
13982
|
* since we need the interval to keep running while on STS UI.
|
|
13756
13983
|
*/
|
|
13757
13984
|
href = popupWindow.location.href;
|
|
13758
|
-
|
|
13985
|
+
serverResponseString =
|
|
13986
|
+
this.extractServerResponseStringFromPopup(popupWindow, href);
|
|
13759
13987
|
}
|
|
13760
13988
|
catch (e) { }
|
|
13761
13989
|
// Don't process blank pages or cross domain
|
|
@@ -13768,17 +13996,17 @@ class PopupClient extends StandardInteractionClient {
|
|
|
13768
13996
|
* as popup operations can take a long time.
|
|
13769
13997
|
*/
|
|
13770
13998
|
ticks++;
|
|
13771
|
-
if (
|
|
13999
|
+
if (serverResponseString) {
|
|
13772
14000
|
this.logger.verbose("PopupHandler.monitorPopupForHash - found hash in url");
|
|
13773
14001
|
clearInterval(intervalId);
|
|
13774
14002
|
this.cleanPopup(popupWindow);
|
|
13775
|
-
if (UrlString.hashContainsKnownProperties(
|
|
14003
|
+
if (UrlString.hashContainsKnownProperties(serverResponseString)) {
|
|
13776
14004
|
this.logger.verbose("PopupHandler.monitorPopupForHash - hash contains known properties, returning.");
|
|
13777
|
-
resolve(
|
|
14005
|
+
resolve(serverResponseString);
|
|
13778
14006
|
}
|
|
13779
14007
|
else {
|
|
13780
14008
|
this.logger.error("PopupHandler.monitorPopupForHash - found hash in url but it does not contain known properties. Check that your router is not changing the hash prematurely.");
|
|
13781
|
-
this.logger.errorPii(`PopupHandler.monitorPopupForHash - hash found: ${
|
|
14009
|
+
this.logger.errorPii(`PopupHandler.monitorPopupForHash - hash found: ${serverResponseString}`);
|
|
13782
14010
|
reject(BrowserAuthError.createHashDoesNotContainKnownPropertiesError());
|
|
13783
14011
|
}
|
|
13784
14012
|
}
|
|
@@ -13959,6 +14187,20 @@ class PopupClient extends StandardInteractionClient {
|
|
|
13959
14187
|
const homeAccountId = request.account && request.account.homeAccountId;
|
|
13960
14188
|
return `${BrowserConstants.POPUP_NAME_PREFIX}.${this.config.auth.clientId}.${homeAccountId}.${this.correlationId}`;
|
|
13961
14189
|
}
|
|
14190
|
+
/**
|
|
14191
|
+
* Extracts the server response from the popup window
|
|
14192
|
+
*/
|
|
14193
|
+
extractServerResponseStringFromPopup(popupWindow, href) {
|
|
14194
|
+
let serverResponseString;
|
|
14195
|
+
if (this.config.auth.OIDCOptions?.serverResponseType ===
|
|
14196
|
+
ServerResponseType.QUERY) {
|
|
14197
|
+
serverResponseString = UrlString.parseQueryServerResponse(href);
|
|
14198
|
+
}
|
|
14199
|
+
else {
|
|
14200
|
+
serverResponseString = popupWindow.location.hash;
|
|
14201
|
+
}
|
|
14202
|
+
return serverResponseString;
|
|
14203
|
+
}
|
|
13962
14204
|
}
|
|
13963
14205
|
|
|
13964
14206
|
/*
|
|
@@ -14033,7 +14275,15 @@ function buildConfiguration({ auth: userInputAuth, cache: userInputCache, system
|
|
|
14033
14275
|
navigateToLoginRequestUrl: true,
|
|
14034
14276
|
clientCapabilities: [],
|
|
14035
14277
|
protocolMode: ProtocolMode.AAD,
|
|
14036
|
-
|
|
14278
|
+
OIDCOptions: {
|
|
14279
|
+
serverResponseType: ServerResponseType.FRAGMENT,
|
|
14280
|
+
defaultScopes: [
|
|
14281
|
+
Constants.OPENID_SCOPE,
|
|
14282
|
+
Constants.PROFILE_SCOPE,
|
|
14283
|
+
Constants.OFFLINE_ACCESS_SCOPE,
|
|
14284
|
+
],
|
|
14285
|
+
},
|
|
14286
|
+
azureCloudOptions: {
|
|
14037
14287
|
azureCloudInstance: AzureCloudInstance.None,
|
|
14038
14288
|
tenant: Constants.EMPTY_STRING,
|
|
14039
14289
|
},
|
|
@@ -14077,7 +14327,7 @@ function buildConfiguration({ auth: userInputAuth, cache: userInputCache, system
|
|
|
14077
14327
|
redirectNavigationTimeout: DEFAULT_REDIRECT_TIMEOUT_MS,
|
|
14078
14328
|
asyncPopups: false,
|
|
14079
14329
|
allowRedirectInIframe: false,
|
|
14080
|
-
allowNativeBroker:
|
|
14330
|
+
allowNativeBroker: false,
|
|
14081
14331
|
nativeBrokerHandshakeTimeout: userInputSystem?.nativeBrokerHandshakeTimeout ||
|
|
14082
14332
|
DEFAULT_NATIVE_BROKER_HANDSHAKE_TIMEOUT_MS,
|
|
14083
14333
|
pollIntervalMilliseconds: BrowserConstants.DEFAULT_POLL_INTERVAL_MS,
|
|
@@ -14091,9 +14341,33 @@ function buildConfiguration({ auth: userInputAuth, cache: userInputCache, system
|
|
|
14091
14341
|
appName: Constants.EMPTY_STRING,
|
|
14092
14342
|
appVersion: Constants.EMPTY_STRING,
|
|
14093
14343
|
},
|
|
14344
|
+
client: new StubPerformanceClient(DEFAULT_AUTH_OPTIONS.clientId, DEFAULT_AUTH_OPTIONS.authority, new Logger(DEFAULT_LOGGER_OPTIONS, name, version), name, version, {
|
|
14345
|
+
appName: Constants.EMPTY_STRING,
|
|
14346
|
+
appVersion: Constants.EMPTY_STRING,
|
|
14347
|
+
}),
|
|
14094
14348
|
};
|
|
14349
|
+
// Throw an error if user has set OIDCOptions without being in OIDC protocol mode
|
|
14350
|
+
if (userInputAuth?.protocolMode !== ProtocolMode.OIDC &&
|
|
14351
|
+
userInputAuth?.OIDCOptions) {
|
|
14352
|
+
// Logger has not been created yet
|
|
14353
|
+
// eslint-disable-next-line no-console
|
|
14354
|
+
console.warn(ClientConfigurationError.createCannotSetOIDCOptionsError());
|
|
14355
|
+
}
|
|
14356
|
+
// Throw an error if user has set allowNativeBroker to true without being in AAD protocol mode
|
|
14357
|
+
if (userInputAuth?.protocolMode &&
|
|
14358
|
+
userInputAuth.protocolMode !== ProtocolMode.AAD &&
|
|
14359
|
+
providedSystemOptions?.allowNativeBroker) {
|
|
14360
|
+
throw ClientConfigurationError.createCannotAllowNativeBrokerError();
|
|
14361
|
+
}
|
|
14095
14362
|
const overlayedConfig = {
|
|
14096
|
-
auth: {
|
|
14363
|
+
auth: {
|
|
14364
|
+
...DEFAULT_AUTH_OPTIONS,
|
|
14365
|
+
...userInputAuth,
|
|
14366
|
+
OIDCOptions: {
|
|
14367
|
+
...DEFAULT_AUTH_OPTIONS.OIDCOptions,
|
|
14368
|
+
...userInputAuth?.OIDCOptions,
|
|
14369
|
+
},
|
|
14370
|
+
},
|
|
14097
14371
|
cache: { ...DEFAULT_CACHE_OPTIONS, ...userInputCache },
|
|
14098
14372
|
system: { ...DEFAULT_BROWSER_SYSTEM_OPTIONS, ...providedSystemOptions },
|
|
14099
14373
|
telemetry: { ...DEFAULT_TELEMETRY_OPTIONS, ...userInputTelemetry },
|
|
@@ -14292,7 +14566,7 @@ class SilentIframeClient extends StandardInteractionClient {
|
|
|
14292
14566
|
if (request.prompt &&
|
|
14293
14567
|
request.prompt !== PromptValue.NONE &&
|
|
14294
14568
|
request.prompt !== PromptValue.NO_SESSION) {
|
|
14295
|
-
acquireTokenMeasurement.
|
|
14569
|
+
acquireTokenMeasurement.end({
|
|
14296
14570
|
success: false,
|
|
14297
14571
|
});
|
|
14298
14572
|
throw BrowserAuthError.createSilentPromptValueError(request.prompt);
|
|
@@ -14312,7 +14586,7 @@ class SilentIframeClient extends StandardInteractionClient {
|
|
|
14312
14586
|
this.logger.verbose("Auth code client created");
|
|
14313
14587
|
this.performanceClient.setPreQueueTime(PerformanceEvents.SilentIframeClientTokenHelper, request.correlationId);
|
|
14314
14588
|
return await this.silentTokenHelper(authClient, silentRequest).then((result) => {
|
|
14315
|
-
acquireTokenMeasurement.
|
|
14589
|
+
acquireTokenMeasurement.end({
|
|
14316
14590
|
success: true,
|
|
14317
14591
|
fromCache: false,
|
|
14318
14592
|
requestId: result.requestId,
|
|
@@ -14326,7 +14600,7 @@ class SilentIframeClient extends StandardInteractionClient {
|
|
|
14326
14600
|
serverTelemetryManager.cacheFailedRequest(e);
|
|
14327
14601
|
}
|
|
14328
14602
|
this.browserStorage.cleanRequestByState(silentRequest.state);
|
|
14329
|
-
acquireTokenMeasurement.
|
|
14603
|
+
acquireTokenMeasurement.end({
|
|
14330
14604
|
errorCode: (e instanceof AuthError && e.errorCode) || undefined,
|
|
14331
14605
|
subErrorCode: (e instanceof AuthError && e.subError) || undefined,
|
|
14332
14606
|
success: false,
|
|
@@ -14406,7 +14680,7 @@ class SilentRefreshClient extends StandardInteractionClient {
|
|
|
14406
14680
|
this.performanceClient.setPreQueueTime(PerformanceEvents.InitializeBaseRequest, request.correlationId);
|
|
14407
14681
|
const silentRequest = {
|
|
14408
14682
|
...request,
|
|
14409
|
-
...await this.initializeBaseRequest(request, request.account)
|
|
14683
|
+
...(await this.initializeBaseRequest(request, request.account)),
|
|
14410
14684
|
};
|
|
14411
14685
|
const acquireTokenMeasurement = this.performanceClient.startMeasurement(PerformanceEvents.SilentRefreshClientAcquireToken, silentRequest.correlationId);
|
|
14412
14686
|
const serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenSilent_silentFlow);
|
|
@@ -14418,7 +14692,7 @@ class SilentRefreshClient extends StandardInteractionClient {
|
|
|
14418
14692
|
.acquireTokenByRefreshToken(silentRequest)
|
|
14419
14693
|
.then((result) => result)
|
|
14420
14694
|
.then((result) => {
|
|
14421
|
-
acquireTokenMeasurement.
|
|
14695
|
+
acquireTokenMeasurement.end({
|
|
14422
14696
|
success: true,
|
|
14423
14697
|
fromCache: result.fromCache,
|
|
14424
14698
|
requestId: result.requestId,
|
|
@@ -14428,7 +14702,7 @@ class SilentRefreshClient extends StandardInteractionClient {
|
|
|
14428
14702
|
.catch((e) => {
|
|
14429
14703
|
e.setCorrelationId(this.correlationId);
|
|
14430
14704
|
serverTelemetryManager.cacheFailedRequest(e);
|
|
14431
|
-
acquireTokenMeasurement.
|
|
14705
|
+
acquireTokenMeasurement.end({
|
|
14432
14706
|
errorCode: e.errorCode,
|
|
14433
14707
|
subErrorCode: e.subError,
|
|
14434
14708
|
success: false,
|
|
@@ -15606,7 +15880,7 @@ class CryptoOps {
|
|
|
15606
15880
|
requestUri: request.resourceRequestUri,
|
|
15607
15881
|
});
|
|
15608
15882
|
if (publicKeyThumbMeasurement) {
|
|
15609
|
-
publicKeyThumbMeasurement.
|
|
15883
|
+
publicKeyThumbMeasurement.end({
|
|
15610
15884
|
success: true,
|
|
15611
15885
|
});
|
|
15612
15886
|
}
|
|
@@ -15662,7 +15936,7 @@ class CryptoOps {
|
|
|
15662
15936
|
const encodedSignature = this.b64Encode.urlEncodeArr(new Uint8Array(signatureBuffer));
|
|
15663
15937
|
const signedJwt = `${tokenString}.${encodedSignature}`;
|
|
15664
15938
|
if (signJwtMeasurement) {
|
|
15665
|
-
signJwtMeasurement.
|
|
15939
|
+
signJwtMeasurement.end({
|
|
15666
15940
|
success: true,
|
|
15667
15941
|
});
|
|
15668
15942
|
}
|
|
@@ -15685,231 +15959,16 @@ CryptoOps.EXTRACTABLE = true;
|
|
|
15685
15959
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
15686
15960
|
* Licensed under the MIT License.
|
|
15687
15961
|
*/
|
|
15688
|
-
|
|
15689
|
-
|
|
15690
|
-
|
|
15691
|
-
this.measureName = BrowserPerformanceMeasurement.makeMeasureName(name, correlationId);
|
|
15692
|
-
this.startMark = BrowserPerformanceMeasurement.makeStartMark(name, correlationId);
|
|
15693
|
-
this.endMark = BrowserPerformanceMeasurement.makeEndMark(name, correlationId);
|
|
15694
|
-
}
|
|
15695
|
-
static makeMeasureName(name, correlationId) {
|
|
15696
|
-
return `msal.measure.${name}.${correlationId}`;
|
|
15697
|
-
}
|
|
15698
|
-
static makeStartMark(name, correlationId) {
|
|
15699
|
-
return `msal.start.${name}.${correlationId}`;
|
|
15700
|
-
}
|
|
15701
|
-
static makeEndMark(name, correlationId) {
|
|
15702
|
-
return `msal.end.${name}.${correlationId}`;
|
|
15703
|
-
}
|
|
15704
|
-
static supportsBrowserPerformance() {
|
|
15705
|
-
return (typeof window !== "undefined" &&
|
|
15706
|
-
typeof window.performance !== "undefined" &&
|
|
15707
|
-
typeof window.performance.mark === "function" &&
|
|
15708
|
-
typeof window.performance.measure === "function" &&
|
|
15709
|
-
typeof window.performance.clearMarks === "function" &&
|
|
15710
|
-
typeof window.performance.clearMeasures === "function" &&
|
|
15711
|
-
typeof window.performance.getEntriesByName === "function");
|
|
15712
|
-
}
|
|
15713
|
-
/**
|
|
15714
|
-
* Flush browser marks and measurements.
|
|
15715
|
-
* @param {string} correlationId
|
|
15716
|
-
* @param {SubMeasurement} measurements
|
|
15717
|
-
*/
|
|
15718
|
-
static flushMeasurements(correlationId, measurements) {
|
|
15719
|
-
if (BrowserPerformanceMeasurement.supportsBrowserPerformance()) {
|
|
15720
|
-
try {
|
|
15721
|
-
measurements.forEach((measurement) => {
|
|
15722
|
-
const measureName = BrowserPerformanceMeasurement.makeMeasureName(measurement.name, correlationId);
|
|
15723
|
-
const entriesForMeasurement = window.performance.getEntriesByName(measureName, "measure");
|
|
15724
|
-
if (entriesForMeasurement.length > 0) {
|
|
15725
|
-
window.performance.clearMeasures(measureName);
|
|
15726
|
-
window.performance.clearMarks(BrowserPerformanceMeasurement.makeStartMark(measureName, correlationId));
|
|
15727
|
-
window.performance.clearMarks(BrowserPerformanceMeasurement.makeEndMark(measureName, correlationId));
|
|
15728
|
-
}
|
|
15729
|
-
});
|
|
15730
|
-
}
|
|
15731
|
-
catch (e) {
|
|
15732
|
-
// Silently catch and return null
|
|
15733
|
-
}
|
|
15734
|
-
}
|
|
15735
|
-
}
|
|
15736
|
-
startMeasurement() {
|
|
15737
|
-
if (BrowserPerformanceMeasurement.supportsBrowserPerformance()) {
|
|
15738
|
-
try {
|
|
15739
|
-
window.performance.mark(this.startMark);
|
|
15740
|
-
}
|
|
15741
|
-
catch (e) {
|
|
15742
|
-
// Silently catch
|
|
15743
|
-
}
|
|
15744
|
-
}
|
|
15745
|
-
}
|
|
15746
|
-
endMeasurement() {
|
|
15747
|
-
if (BrowserPerformanceMeasurement.supportsBrowserPerformance()) {
|
|
15748
|
-
try {
|
|
15749
|
-
window.performance.mark(this.endMark);
|
|
15750
|
-
window.performance.measure(this.measureName, this.startMark, this.endMark);
|
|
15751
|
-
}
|
|
15752
|
-
catch (e) {
|
|
15753
|
-
// Silently catch
|
|
15754
|
-
}
|
|
15755
|
-
}
|
|
15756
|
-
}
|
|
15757
|
-
flushMeasurement() {
|
|
15758
|
-
if (BrowserPerformanceMeasurement.supportsBrowserPerformance()) {
|
|
15759
|
-
try {
|
|
15760
|
-
const entriesForMeasurement = window.performance.getEntriesByName(this.measureName, "measure");
|
|
15761
|
-
if (entriesForMeasurement.length > 0) {
|
|
15762
|
-
const durationMs = entriesForMeasurement[0].duration;
|
|
15763
|
-
window.performance.clearMeasures(this.measureName);
|
|
15764
|
-
window.performance.clearMarks(this.startMark);
|
|
15765
|
-
window.performance.clearMarks(this.endMark);
|
|
15766
|
-
return durationMs;
|
|
15767
|
-
}
|
|
15768
|
-
}
|
|
15769
|
-
catch (e) {
|
|
15770
|
-
// Silently catch and return null
|
|
15771
|
-
}
|
|
15772
|
-
}
|
|
15773
|
-
return null;
|
|
15774
|
-
}
|
|
15775
|
-
}
|
|
15776
|
-
|
|
15777
|
-
/*
|
|
15778
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
15779
|
-
* Licensed under the MIT License.
|
|
15780
|
-
*/
|
|
15781
|
-
class BrowserPerformanceClient extends PerformanceClient {
|
|
15782
|
-
constructor(clientId, authority, logger, libraryName, libraryVersion, applicationTelemetry) {
|
|
15783
|
-
super(clientId, authority, logger, libraryName, libraryVersion, applicationTelemetry);
|
|
15784
|
-
this.browserCrypto = new BrowserCrypto(this.logger);
|
|
15785
|
-
this.guidGenerator = new GuidGenerator(this.browserCrypto);
|
|
15786
|
-
}
|
|
15787
|
-
startPerformanceMeasurement(measureName, correlationId) {
|
|
15788
|
-
return new BrowserPerformanceMeasurement(measureName, correlationId);
|
|
15789
|
-
}
|
|
15790
|
-
generateId() {
|
|
15791
|
-
return this.guidGenerator.generateGuid();
|
|
15792
|
-
}
|
|
15793
|
-
getPageVisibility() {
|
|
15794
|
-
return document.visibilityState?.toString() || null;
|
|
15795
|
-
}
|
|
15796
|
-
deleteIncompleteSubMeasurements(inProgressEvent) {
|
|
15797
|
-
const rootEvent = this.eventsByCorrelationId.get(inProgressEvent.event.correlationId);
|
|
15798
|
-
const isRootEvent = rootEvent && rootEvent.eventId === inProgressEvent.event.eventId;
|
|
15799
|
-
const incompleteMeasurements = [];
|
|
15800
|
-
if (isRootEvent && rootEvent?.incompleteSubMeasurements) {
|
|
15801
|
-
rootEvent.incompleteSubMeasurements.forEach((subMeasurement) => {
|
|
15802
|
-
incompleteMeasurements.push({ ...subMeasurement });
|
|
15803
|
-
});
|
|
15804
|
-
}
|
|
15805
|
-
// Clean up remaining marks for incomplete sub-measurements
|
|
15806
|
-
if (incompleteMeasurements.length > 0) {
|
|
15807
|
-
BrowserPerformanceMeasurement.flushMeasurements(inProgressEvent.event.correlationId, incompleteMeasurements);
|
|
15808
|
-
}
|
|
15809
|
-
}
|
|
15810
|
-
supportsBrowserPerformanceNow() {
|
|
15811
|
-
return (typeof window !== "undefined" &&
|
|
15812
|
-
typeof window.performance !== "undefined" &&
|
|
15813
|
-
typeof window.performance.now === "function");
|
|
15814
|
-
}
|
|
15815
|
-
/**
|
|
15816
|
-
* Starts measuring performance for a given operation. Returns a function that should be used to end the measurement.
|
|
15817
|
-
* Also captures browser page visibilityState.
|
|
15818
|
-
*
|
|
15819
|
-
* @param {PerformanceEvents} measureName
|
|
15820
|
-
* @param {?string} [correlationId]
|
|
15821
|
-
* @returns {((event?: Partial<PerformanceEvent>) => PerformanceEvent| null)}
|
|
15822
|
-
*/
|
|
15823
|
-
startMeasurement(measureName, correlationId) {
|
|
15824
|
-
// Capture page visibilityState and then invoke start/end measurement
|
|
15825
|
-
const startPageVisibility = this.getPageVisibility();
|
|
15826
|
-
const inProgressEvent = super.startMeasurement(measureName, correlationId);
|
|
15827
|
-
return {
|
|
15828
|
-
...inProgressEvent,
|
|
15829
|
-
endMeasurement: (event) => {
|
|
15830
|
-
const res = inProgressEvent.endMeasurement({
|
|
15831
|
-
startPageVisibility,
|
|
15832
|
-
endPageVisibility: this.getPageVisibility(),
|
|
15833
|
-
...event,
|
|
15834
|
-
});
|
|
15835
|
-
this.deleteIncompleteSubMeasurements(inProgressEvent);
|
|
15836
|
-
return res;
|
|
15837
|
-
},
|
|
15838
|
-
discardMeasurement: () => {
|
|
15839
|
-
inProgressEvent.discardMeasurement();
|
|
15840
|
-
this.deleteIncompleteSubMeasurements(inProgressEvent);
|
|
15841
|
-
inProgressEvent.measurement.flushMeasurement();
|
|
15842
|
-
},
|
|
15843
|
-
};
|
|
15844
|
-
}
|
|
15845
|
-
/**
|
|
15846
|
-
* Adds pre-queue time to preQueueTimeByCorrelationId map.
|
|
15847
|
-
* @param {PerformanceEvents} eventName
|
|
15848
|
-
* @param {?string} correlationId
|
|
15849
|
-
* @returns
|
|
15850
|
-
*/
|
|
15851
|
-
setPreQueueTime(eventName, correlationId) {
|
|
15852
|
-
if (!this.supportsBrowserPerformanceNow()) {
|
|
15853
|
-
this.logger.trace(`BrowserPerformanceClient: window performance API not available, unable to set telemetry queue time for ${eventName}`);
|
|
15854
|
-
return;
|
|
15855
|
-
}
|
|
15856
|
-
if (!correlationId) {
|
|
15857
|
-
this.logger.trace(`BrowserPerformanceClient: correlationId for ${eventName} not provided, unable to set telemetry queue time`);
|
|
15858
|
-
return;
|
|
15859
|
-
}
|
|
15860
|
-
const preQueueEvent = this.preQueueTimeByCorrelationId.get(correlationId);
|
|
15861
|
-
/**
|
|
15862
|
-
* Manually complete queue measurement if there is an incomplete pre-queue event.
|
|
15863
|
-
* Incomplete pre-queue events are instrumentation bugs that should be fixed.
|
|
15864
|
-
*/
|
|
15865
|
-
if (preQueueEvent) {
|
|
15866
|
-
this.logger.trace(`BrowserPerformanceClient: Incomplete pre-queue ${preQueueEvent.name} found`, correlationId);
|
|
15867
|
-
this.addQueueMeasurement(preQueueEvent.name, correlationId, undefined, true);
|
|
15868
|
-
}
|
|
15869
|
-
this.preQueueTimeByCorrelationId.set(correlationId, {
|
|
15870
|
-
name: eventName,
|
|
15871
|
-
time: window.performance.now(),
|
|
15872
|
-
});
|
|
15873
|
-
}
|
|
15874
|
-
/**
|
|
15875
|
-
* Calculates and adds queue time measurement for given performance event.
|
|
15876
|
-
*
|
|
15877
|
-
* @param {PerformanceEvents} eventName
|
|
15878
|
-
* @param {?string} correlationId
|
|
15879
|
-
* @param {?number} queueTime
|
|
15880
|
-
* @param {?boolean} manuallyCompleted - indicator for manually completed queue measurements
|
|
15881
|
-
* @returns
|
|
15882
|
-
*/
|
|
15883
|
-
addQueueMeasurement(eventName, correlationId, queueTime, manuallyCompleted) {
|
|
15884
|
-
if (!this.supportsBrowserPerformanceNow()) {
|
|
15885
|
-
this.logger.trace(`BrowserPerformanceClient: window performance API not available, unable to add queue measurement for ${eventName}`);
|
|
15886
|
-
return;
|
|
15887
|
-
}
|
|
15888
|
-
if (!correlationId) {
|
|
15889
|
-
this.logger.trace(`BrowserPerformanceClient: correlationId for ${eventName} not provided, unable to add queue measurement`);
|
|
15890
|
-
return;
|
|
15891
|
-
}
|
|
15892
|
-
const preQueueTime = super.getPreQueueTime(eventName, correlationId);
|
|
15893
|
-
if (!preQueueTime) {
|
|
15894
|
-
return;
|
|
15895
|
-
}
|
|
15896
|
-
const currentTime = window.performance.now();
|
|
15897
|
-
const resQueueTime = queueTime || super.calculateQueuedTime(preQueueTime, currentTime);
|
|
15898
|
-
return super.addQueueMeasurement(eventName, correlationId, resQueueTime, manuallyCompleted);
|
|
15899
|
-
}
|
|
15900
|
-
}
|
|
15901
|
-
|
|
15902
|
-
/*
|
|
15903
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
15904
|
-
* Licensed under the MIT License.
|
|
15962
|
+
/**
|
|
15963
|
+
* Warning: This set of exports is purely intended to be used by other MSAL libraries, and should be considered potentially unstable. We strongly discourage using them directly, you do so at your own risk.
|
|
15964
|
+
* Breaking changes to these APIs will be shipped under a minor version, instead of a major version.
|
|
15905
15965
|
*/
|
|
15966
|
+
// Cache Manager
|
|
15906
15967
|
|
|
15907
15968
|
var internals = /*#__PURE__*/Object.freeze({
|
|
15908
15969
|
__proto__: null,
|
|
15909
15970
|
BrowserCacheManager: BrowserCacheManager,
|
|
15910
15971
|
BrowserConstants: BrowserConstants,
|
|
15911
|
-
BrowserPerformanceClient: BrowserPerformanceClient,
|
|
15912
|
-
BrowserPerformanceMeasurement: BrowserPerformanceMeasurement,
|
|
15913
15972
|
CacheRecord: CacheRecord,
|
|
15914
15973
|
CryptoOps: CryptoOps,
|
|
15915
15974
|
EventHandler: EventHandler,
|
|
@@ -16127,8 +16186,9 @@ class TokenCache {
|
|
|
16127
16186
|
const idToken = new AuthToken(response.id_token, this.cryptoObj);
|
|
16128
16187
|
let cacheRecord;
|
|
16129
16188
|
let authority;
|
|
16189
|
+
let cacheRecordAccount;
|
|
16130
16190
|
if (request.account) {
|
|
16131
|
-
|
|
16191
|
+
cacheRecordAccount = AccountEntity.createFromAccountInfo(request.account);
|
|
16132
16192
|
cacheRecord = new CacheRecord(cacheRecordAccount, this.loadIdToken(idToken, cacheRecordAccount.homeAccountId, request.account.environment, request.account.tenantId), this.loadAccessToken(request, response, cacheRecordAccount.homeAccountId, request.account.environment, request.account.tenantId, options), this.loadRefreshToken(request, response, cacheRecordAccount.homeAccountId, request.account.environment));
|
|
16133
16193
|
}
|
|
16134
16194
|
else if (request.authority) {
|
|
@@ -16144,12 +16204,12 @@ class TokenCache {
|
|
|
16144
16204
|
// "clientInfo" from options takes precedence over "clientInfo" in response
|
|
16145
16205
|
if (options.clientInfo) {
|
|
16146
16206
|
this.logger.trace("TokenCache - homeAccountId from options");
|
|
16147
|
-
|
|
16207
|
+
cacheRecordAccount = this.loadAccount(idToken, authority, options.clientInfo);
|
|
16148
16208
|
cacheRecord = new CacheRecord(cacheRecordAccount, this.loadIdToken(idToken, cacheRecordAccount.homeAccountId, authority.hostnameAndPort, authority.tenant), this.loadAccessToken(request, response, cacheRecordAccount.homeAccountId, authority.hostnameAndPort, authority.tenant, options), this.loadRefreshToken(request, response, cacheRecordAccount.homeAccountId, authority.hostnameAndPort));
|
|
16149
16209
|
}
|
|
16150
16210
|
else if (response.client_info) {
|
|
16151
16211
|
this.logger.trace("TokenCache - homeAccountId from response");
|
|
16152
|
-
|
|
16212
|
+
cacheRecordAccount = this.loadAccount(idToken, authority, response.client_info);
|
|
16153
16213
|
cacheRecord = new CacheRecord(cacheRecordAccount, this.loadIdToken(idToken, cacheRecordAccount.homeAccountId, authority.hostnameAndPort, authority.tenant), this.loadAccessToken(request, response, cacheRecordAccount.homeAccountId, authority.hostnameAndPort, authority.tenant, options), this.loadRefreshToken(request, response, cacheRecordAccount.homeAccountId, authority.hostnameAndPort));
|
|
16154
16214
|
}
|
|
16155
16215
|
else {
|
|
@@ -16159,7 +16219,7 @@ class TokenCache {
|
|
|
16159
16219
|
else {
|
|
16160
16220
|
throw BrowserAuthError.createUnableToLoadTokenError("Please provide a request with an account or a request with authority.");
|
|
16161
16221
|
}
|
|
16162
|
-
return this.generateAuthenticationResult(request, idToken, cacheRecord, authority);
|
|
16222
|
+
return this.generateAuthenticationResult(request, idToken, cacheRecord, cacheRecordAccount, authority);
|
|
16163
16223
|
}
|
|
16164
16224
|
/**
|
|
16165
16225
|
* Helper function to load account to msal-browser cache
|
|
@@ -16170,20 +16230,23 @@ class TokenCache {
|
|
|
16170
16230
|
* @param requestHomeAccountId
|
|
16171
16231
|
* @returns `AccountEntity`
|
|
16172
16232
|
*/
|
|
16173
|
-
loadAccount(idToken,
|
|
16233
|
+
loadAccount(idToken, authority, clientInfo, requestHomeAccountId) {
|
|
16174
16234
|
let homeAccountId;
|
|
16175
16235
|
if (requestHomeAccountId) {
|
|
16176
16236
|
homeAccountId = requestHomeAccountId;
|
|
16177
16237
|
}
|
|
16178
|
-
else if (authorityType !== undefined && clientInfo) {
|
|
16179
|
-
homeAccountId = AccountEntity.generateHomeAccountId(clientInfo, authorityType, this.logger, this.cryptoObj, idToken);
|
|
16238
|
+
else if (authority.authorityType !== undefined && clientInfo) {
|
|
16239
|
+
homeAccountId = AccountEntity.generateHomeAccountId(clientInfo, authority.authorityType, this.logger, this.cryptoObj, idToken.claims);
|
|
16180
16240
|
}
|
|
16181
16241
|
if (!homeAccountId) {
|
|
16182
16242
|
throw BrowserAuthError.createUnableToLoadTokenError("Unexpected missing homeAccountId");
|
|
16183
16243
|
}
|
|
16184
|
-
const accountEntity =
|
|
16185
|
-
|
|
16186
|
-
:
|
|
16244
|
+
const accountEntity = AccountEntity.createAccount({
|
|
16245
|
+
homeAccountId,
|
|
16246
|
+
idTokenClaims: idToken.claims,
|
|
16247
|
+
clientInfo,
|
|
16248
|
+
environment: authority.hostnameAndPort,
|
|
16249
|
+
}, authority);
|
|
16187
16250
|
if (this.isBrowserEnvironment) {
|
|
16188
16251
|
this.logger.verbose("TokenCache - loading account");
|
|
16189
16252
|
this.storage.setAccount(accountEntity);
|
|
@@ -16277,7 +16340,7 @@ class TokenCache {
|
|
|
16277
16340
|
* @param authority
|
|
16278
16341
|
* @returns `AuthenticationResult`
|
|
16279
16342
|
*/
|
|
16280
|
-
generateAuthenticationResult(request, idTokenObj, cacheRecord, authority) {
|
|
16343
|
+
generateAuthenticationResult(request, idTokenObj, cacheRecord, accountEntity, authority) {
|
|
16281
16344
|
let accessToken = Constants.EMPTY_STRING;
|
|
16282
16345
|
let responseScopes = [];
|
|
16283
16346
|
let expiresOn = null;
|
|
@@ -16299,7 +16362,7 @@ class TokenCache {
|
|
|
16299
16362
|
uniqueId: uid,
|
|
16300
16363
|
tenantId: tid,
|
|
16301
16364
|
scopes: responseScopes,
|
|
16302
|
-
account:
|
|
16365
|
+
account: accountEntity.getAccountInfo(),
|
|
16303
16366
|
idToken: idTokenObj ? idTokenObj.rawToken : Constants.EMPTY_STRING,
|
|
16304
16367
|
idTokenClaims: idTokenObj ? idTokenObj.claims : {},
|
|
16305
16368
|
accessToken: accessToken,
|
|
@@ -16311,9 +16374,8 @@ class TokenCache {
|
|
|
16311
16374
|
familyId: Constants.EMPTY_STRING,
|
|
16312
16375
|
tokenType: cacheRecord?.accessToken?.tokenType || Constants.EMPTY_STRING,
|
|
16313
16376
|
state: Constants.EMPTY_STRING,
|
|
16314
|
-
cloudGraphHostName:
|
|
16315
|
-
|
|
16316
|
-
msGraphHost: cacheRecord?.account?.msGraphHost || Constants.EMPTY_STRING,
|
|
16377
|
+
cloudGraphHostName: accountEntity.cloudGraphHostName || Constants.EMPTY_STRING,
|
|
16378
|
+
msGraphHost: accountEntity.msGraphHost || Constants.EMPTY_STRING,
|
|
16317
16379
|
code: undefined,
|
|
16318
16380
|
fromNativeBroker: false,
|
|
16319
16381
|
};
|
|
@@ -16439,9 +16501,7 @@ class StandardController {
|
|
|
16439
16501
|
// Initial hybrid spa map
|
|
16440
16502
|
this.hybridAuthCodeResponses = new Map();
|
|
16441
16503
|
// Initialize performance client
|
|
16442
|
-
this.performanceClient = this.
|
|
16443
|
-
? new BrowserPerformanceClient(this.config.auth.clientId, this.config.auth.authority, this.logger, name, version, this.config.telemetry.application)
|
|
16444
|
-
: new StubPerformanceClient(this.config.auth.clientId, this.config.auth.authority, this.logger, name, version, this.config.telemetry.application);
|
|
16504
|
+
this.performanceClient = this.config.telemetry.client;
|
|
16445
16505
|
// Initialize the crypto class.
|
|
16446
16506
|
this.browserCrypto = this.isBrowserEnvironment
|
|
16447
16507
|
? new CryptoOps(this.logger, this.performanceClient)
|
|
@@ -16507,7 +16567,7 @@ class StandardController {
|
|
|
16507
16567
|
}
|
|
16508
16568
|
this.initialized = true;
|
|
16509
16569
|
this.eventHandler.emitEvent(EventType.INITIALIZE_END);
|
|
16510
|
-
initMeasurement.
|
|
16570
|
+
initMeasurement.end({ allowNativeBroker, success: true });
|
|
16511
16571
|
}
|
|
16512
16572
|
// #region Redirect Flow
|
|
16513
16573
|
/**
|
|
@@ -16519,8 +16579,14 @@ class StandardController {
|
|
|
16519
16579
|
*/
|
|
16520
16580
|
async handleRedirectPromise(hash) {
|
|
16521
16581
|
this.logger.verbose("handleRedirectPromise called");
|
|
16522
|
-
// Block token acquisition before initialize has been called
|
|
16523
|
-
BrowserUtils.
|
|
16582
|
+
// Block token acquisition before initialize has been called
|
|
16583
|
+
BrowserUtils.blockAPICallsBeforeInitialize(this.initialized);
|
|
16584
|
+
let foundServerResponse = hash;
|
|
16585
|
+
if (this.config.auth.OIDCOptions?.serverResponseType ===
|
|
16586
|
+
ServerResponseType.QUERY) {
|
|
16587
|
+
const url = window.location.href;
|
|
16588
|
+
foundServerResponse = UrlString.parseQueryServerResponse(url);
|
|
16589
|
+
}
|
|
16524
16590
|
const loggedInAccounts = this.getAllAccounts();
|
|
16525
16591
|
if (this.isBrowserEnvironment) {
|
|
16526
16592
|
/**
|
|
@@ -16528,7 +16594,7 @@ class StandardController {
|
|
|
16528
16594
|
* otherwise return the promise from the first invocation. Prevents race conditions when handleRedirectPromise is called
|
|
16529
16595
|
* several times concurrently.
|
|
16530
16596
|
*/
|
|
16531
|
-
const redirectResponseKey =
|
|
16597
|
+
const redirectResponseKey = foundServerResponse || Constants.EMPTY_STRING;
|
|
16532
16598
|
let response = this.redirectResponse.get(redirectResponseKey);
|
|
16533
16599
|
if (typeof response === "undefined") {
|
|
16534
16600
|
this.eventHandler.emitEvent(EventType.HANDLE_REDIRECT_START, exports.InteractionType.Redirect);
|
|
@@ -16538,7 +16604,7 @@ class StandardController {
|
|
|
16538
16604
|
if (request &&
|
|
16539
16605
|
NativeMessageHandler.isNativeAvailable(this.config, this.logger, this.nativeExtensionProvider) &&
|
|
16540
16606
|
this.nativeExtensionProvider &&
|
|
16541
|
-
!
|
|
16607
|
+
!foundServerResponse) {
|
|
16542
16608
|
this.logger.trace("handleRedirectPromise - acquiring token from native platform");
|
|
16543
16609
|
const nativeClient = new NativeInteractionClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, ApiId.handleRedirectPromise, this.performanceClient, this.nativeExtensionProvider, request.accountId, this.nativeInternalStorage, request.correlationId);
|
|
16544
16610
|
redirectResponse = nativeClient.handleRedirectPromise();
|
|
@@ -16548,7 +16614,7 @@ class StandardController {
|
|
|
16548
16614
|
const correlationId = this.browserStorage.getTemporaryCache(TemporaryCacheKeys.CORRELATION_ID, true) || Constants.EMPTY_STRING;
|
|
16549
16615
|
const redirectClient = this.createRedirectClient(correlationId);
|
|
16550
16616
|
redirectResponse =
|
|
16551
|
-
redirectClient.handleRedirectPromise(
|
|
16617
|
+
redirectClient.handleRedirectPromise(foundServerResponse);
|
|
16552
16618
|
}
|
|
16553
16619
|
response = redirectResponse
|
|
16554
16620
|
.then((result) => {
|
|
@@ -16679,7 +16745,7 @@ class StandardController {
|
|
|
16679
16745
|
result = this.acquireTokenNative(request, ApiId.acquireTokenPopup)
|
|
16680
16746
|
.then((response) => {
|
|
16681
16747
|
this.browserStorage.setInteractionInProgress(false);
|
|
16682
|
-
atPopupMeasurement.
|
|
16748
|
+
atPopupMeasurement.end({
|
|
16683
16749
|
success: true,
|
|
16684
16750
|
isNativeBroker: true,
|
|
16685
16751
|
requestId: response.requestId,
|
|
@@ -16717,11 +16783,11 @@ class StandardController {
|
|
|
16717
16783
|
else {
|
|
16718
16784
|
this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_SUCCESS, exports.InteractionType.Popup, result);
|
|
16719
16785
|
}
|
|
16720
|
-
atPopupMeasurement.
|
|
16786
|
+
atPopupMeasurement.add({
|
|
16721
16787
|
accessTokenSize: result.accessToken.length,
|
|
16722
16788
|
idTokenSize: result.idToken.length,
|
|
16723
16789
|
});
|
|
16724
|
-
atPopupMeasurement.
|
|
16790
|
+
atPopupMeasurement.end({
|
|
16725
16791
|
success: true,
|
|
16726
16792
|
requestId: result.requestId,
|
|
16727
16793
|
});
|
|
@@ -16734,7 +16800,7 @@ class StandardController {
|
|
|
16734
16800
|
else {
|
|
16735
16801
|
this.eventHandler.emitEvent(EventType.LOGIN_FAILURE, exports.InteractionType.Popup, null, e);
|
|
16736
16802
|
}
|
|
16737
|
-
atPopupMeasurement.
|
|
16803
|
+
atPopupMeasurement.end({
|
|
16738
16804
|
errorCode: e.errorCode,
|
|
16739
16805
|
subErrorCode: e.subError,
|
|
16740
16806
|
success: false,
|
|
@@ -16806,11 +16872,11 @@ class StandardController {
|
|
|
16806
16872
|
return result
|
|
16807
16873
|
.then((response) => {
|
|
16808
16874
|
this.eventHandler.emitEvent(EventType.SSO_SILENT_SUCCESS, exports.InteractionType.Silent, response);
|
|
16809
|
-
this.ssoSilentMeasurement?.
|
|
16875
|
+
this.ssoSilentMeasurement?.add({
|
|
16810
16876
|
accessTokenSize: response.accessToken.length,
|
|
16811
16877
|
idTokenSize: response.idToken.length,
|
|
16812
16878
|
});
|
|
16813
|
-
this.ssoSilentMeasurement?.
|
|
16879
|
+
this.ssoSilentMeasurement?.end({
|
|
16814
16880
|
success: true,
|
|
16815
16881
|
isNativeBroker: response.fromNativeBroker,
|
|
16816
16882
|
requestId: response.requestId,
|
|
@@ -16819,7 +16885,7 @@ class StandardController {
|
|
|
16819
16885
|
})
|
|
16820
16886
|
.catch((e) => {
|
|
16821
16887
|
this.eventHandler.emitEvent(EventType.SSO_SILENT_FAILURE, exports.InteractionType.Silent, null, e);
|
|
16822
|
-
this.ssoSilentMeasurement?.
|
|
16888
|
+
this.ssoSilentMeasurement?.end({
|
|
16823
16889
|
errorCode: e.errorCode,
|
|
16824
16890
|
subErrorCode: e.subError,
|
|
16825
16891
|
success: false,
|
|
@@ -16863,11 +16929,11 @@ class StandardController {
|
|
|
16863
16929
|
.then((result) => {
|
|
16864
16930
|
this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_BY_CODE_SUCCESS, exports.InteractionType.Silent, result);
|
|
16865
16931
|
this.hybridAuthCodeResponses.delete(hybridAuthCode);
|
|
16866
|
-
atbcMeasurement.
|
|
16932
|
+
atbcMeasurement.add({
|
|
16867
16933
|
accessTokenSize: result.accessToken.length,
|
|
16868
16934
|
idTokenSize: result.idToken.length,
|
|
16869
16935
|
});
|
|
16870
|
-
atbcMeasurement.
|
|
16936
|
+
atbcMeasurement.end({
|
|
16871
16937
|
success: true,
|
|
16872
16938
|
isNativeBroker: result.fromNativeBroker,
|
|
16873
16939
|
requestId: result.requestId,
|
|
@@ -16877,7 +16943,7 @@ class StandardController {
|
|
|
16877
16943
|
.catch((error) => {
|
|
16878
16944
|
this.hybridAuthCodeResponses.delete(hybridAuthCode);
|
|
16879
16945
|
this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_BY_CODE_FAILURE, exports.InteractionType.Silent, null, error);
|
|
16880
|
-
atbcMeasurement.
|
|
16946
|
+
atbcMeasurement.end({
|
|
16881
16947
|
errorCode: error.errorCode,
|
|
16882
16948
|
subErrorCode: error.subError,
|
|
16883
16949
|
success: false,
|
|
@@ -16888,7 +16954,7 @@ class StandardController {
|
|
|
16888
16954
|
}
|
|
16889
16955
|
else {
|
|
16890
16956
|
this.logger.verbose("Existing acquireTokenByCode request found", request.correlationId);
|
|
16891
|
-
atbcMeasurement.
|
|
16957
|
+
atbcMeasurement.discard();
|
|
16892
16958
|
}
|
|
16893
16959
|
return response;
|
|
16894
16960
|
}
|
|
@@ -16912,7 +16978,7 @@ class StandardController {
|
|
|
16912
16978
|
}
|
|
16913
16979
|
catch (e) {
|
|
16914
16980
|
this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_BY_CODE_FAILURE, exports.InteractionType.Silent, null, e);
|
|
16915
|
-
atbcMeasurement.
|
|
16981
|
+
atbcMeasurement.end({
|
|
16916
16982
|
errorCode: (e instanceof AuthError && e.errorCode) || undefined,
|
|
16917
16983
|
subErrorCode: (e instanceof AuthError && e.subError) || undefined,
|
|
16918
16984
|
success: false,
|
|
@@ -16937,7 +17003,7 @@ class StandardController {
|
|
|
16937
17003
|
const silentTokenResult = await silentAuthCodeClient
|
|
16938
17004
|
.acquireToken(request)
|
|
16939
17005
|
.then((response) => {
|
|
16940
|
-
this.acquireTokenByCodeAsyncMeasurement?.
|
|
17006
|
+
this.acquireTokenByCodeAsyncMeasurement?.end({
|
|
16941
17007
|
success: true,
|
|
16942
17008
|
fromCache: response.fromCache,
|
|
16943
17009
|
isNativeBroker: response.fromNativeBroker,
|
|
@@ -16946,7 +17012,7 @@ class StandardController {
|
|
|
16946
17012
|
return response;
|
|
16947
17013
|
})
|
|
16948
17014
|
.catch((tokenRenewalError) => {
|
|
16949
|
-
this.acquireTokenByCodeAsyncMeasurement?.
|
|
17015
|
+
this.acquireTokenByCodeAsyncMeasurement?.end({
|
|
16950
17016
|
errorCode: tokenRenewalError.errorCode,
|
|
16951
17017
|
subErrorCode: tokenRenewalError.subError,
|
|
16952
17018
|
success: false,
|
|
@@ -17156,6 +17222,26 @@ class StandardController {
|
|
|
17156
17222
|
return this.browserStorage.getActiveAccount();
|
|
17157
17223
|
}
|
|
17158
17224
|
// #endregion
|
|
17225
|
+
/**
|
|
17226
|
+
* Hydrates the cache with the tokens from an AuthenticationResult
|
|
17227
|
+
* @param result
|
|
17228
|
+
* @param request
|
|
17229
|
+
* @returns
|
|
17230
|
+
*/
|
|
17231
|
+
async hydrateCache(result, request) {
|
|
17232
|
+
this.logger.verbose("hydrateCache called");
|
|
17233
|
+
// Account gets saved to browser storage regardless of native or not
|
|
17234
|
+
const accountEntity = AccountEntity.createFromAccountInfo(result.account, result.cloudGraphHostName, result.msGraphHost);
|
|
17235
|
+
this.browserStorage.setAccount(accountEntity);
|
|
17236
|
+
if (result.fromNativeBroker) {
|
|
17237
|
+
this.logger.verbose("Response was from native broker, storing in-memory");
|
|
17238
|
+
// Tokens from native broker are stored in-memory
|
|
17239
|
+
return this.nativeInternalStorage.hydrateCache(result, request);
|
|
17240
|
+
}
|
|
17241
|
+
else {
|
|
17242
|
+
return this.browserStorage.hydrateCache(result, request);
|
|
17243
|
+
}
|
|
17244
|
+
}
|
|
17159
17245
|
// #region Helpers
|
|
17160
17246
|
/**
|
|
17161
17247
|
* Helper to validate app environment before making an auth request
|
|
@@ -17174,13 +17260,8 @@ class StandardController {
|
|
|
17174
17260
|
BrowserUtils.blockReloadInHiddenIframes();
|
|
17175
17261
|
// Block redirectUri opened in a popup from calling MSAL APIs
|
|
17176
17262
|
BrowserUtils.blockAcquireTokenInPopups();
|
|
17177
|
-
|
|
17178
|
-
|
|
17179
|
-
* Skip check if application is embedded.
|
|
17180
|
-
*/
|
|
17181
|
-
if (!isAppEmbedded) {
|
|
17182
|
-
BrowserUtils.blockNativeBrokerCalledBeforeInitialized(this.config.system.allowNativeBroker, this.initialized);
|
|
17183
|
-
}
|
|
17263
|
+
// Block token acquisition before initialize has been called
|
|
17264
|
+
BrowserUtils.blockAPICallsBeforeInitialize(this.initialized);
|
|
17184
17265
|
// Block redirects if memory storage is enabled but storeAuthStateInCookie is not
|
|
17185
17266
|
if (interactionType === exports.InteractionType.Redirect &&
|
|
17186
17267
|
this.config.cache.cacheLocation ===
|
|
@@ -17506,7 +17587,7 @@ class StandardController {
|
|
|
17506
17587
|
async acquireTokenSilent(request) {
|
|
17507
17588
|
const correlationId = this.getRequestCorrelationId(request);
|
|
17508
17589
|
const atsMeasurement = this.performanceClient.startMeasurement(PerformanceEvents.AcquireTokenSilent, correlationId);
|
|
17509
|
-
atsMeasurement.
|
|
17590
|
+
atsMeasurement.add({
|
|
17510
17591
|
cacheLookupPolicy: request.cacheLookupPolicy,
|
|
17511
17592
|
});
|
|
17512
17593
|
this.preflightBrowserEnvironmentCheck(exports.InteractionType.Silent);
|
|
@@ -17538,11 +17619,11 @@ class StandardController {
|
|
|
17538
17619
|
}, account)
|
|
17539
17620
|
.then((result) => {
|
|
17540
17621
|
this.activeSilentTokenRequests.delete(silentRequestKey);
|
|
17541
|
-
atsMeasurement.
|
|
17622
|
+
atsMeasurement.add({
|
|
17542
17623
|
accessTokenSize: result.accessToken.length,
|
|
17543
17624
|
idTokenSize: result.idToken.length,
|
|
17544
17625
|
});
|
|
17545
|
-
atsMeasurement.
|
|
17626
|
+
atsMeasurement.end({
|
|
17546
17627
|
success: true,
|
|
17547
17628
|
fromCache: result.fromCache,
|
|
17548
17629
|
isNativeBroker: result.fromNativeBroker,
|
|
@@ -17553,7 +17634,7 @@ class StandardController {
|
|
|
17553
17634
|
})
|
|
17554
17635
|
.catch((error) => {
|
|
17555
17636
|
this.activeSilentTokenRequests.delete(silentRequestKey);
|
|
17556
|
-
atsMeasurement.
|
|
17637
|
+
atsMeasurement.end({
|
|
17557
17638
|
errorCode: error.errorCode,
|
|
17558
17639
|
subErrorCode: error.subError,
|
|
17559
17640
|
success: false,
|
|
@@ -17566,7 +17647,7 @@ class StandardController {
|
|
|
17566
17647
|
else {
|
|
17567
17648
|
this.logger.verbose("acquireTokenSilent has been called previously, returning the result from the first call", correlationId);
|
|
17568
17649
|
// Discard measurements for memoized calls, as they are usually only a couple of ms and will artificially deflate metrics
|
|
17569
|
-
atsMeasurement.
|
|
17650
|
+
atsMeasurement.discard();
|
|
17570
17651
|
return cachedResponse;
|
|
17571
17652
|
}
|
|
17572
17653
|
}
|
|
@@ -17650,7 +17731,7 @@ class StandardController {
|
|
|
17650
17731
|
return result
|
|
17651
17732
|
.then((response) => {
|
|
17652
17733
|
this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_SUCCESS, exports.InteractionType.Silent, response);
|
|
17653
|
-
this.atsAsyncMeasurement?.
|
|
17734
|
+
this.atsAsyncMeasurement?.end({
|
|
17654
17735
|
success: true,
|
|
17655
17736
|
fromCache: response.fromCache,
|
|
17656
17737
|
isNativeBroker: response.fromNativeBroker,
|
|
@@ -17660,7 +17741,7 @@ class StandardController {
|
|
|
17660
17741
|
})
|
|
17661
17742
|
.catch((tokenRenewalError) => {
|
|
17662
17743
|
this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_FAILURE, exports.InteractionType.Silent, null, tokenRenewalError);
|
|
17663
|
-
this.atsAsyncMeasurement?.
|
|
17744
|
+
this.atsAsyncMeasurement?.end({
|
|
17664
17745
|
errorCode: tokenRenewalError.errorCode,
|
|
17665
17746
|
subErrorCode: tokenRenewalError.subError,
|
|
17666
17747
|
success: false,
|
|
@@ -17984,6 +18065,15 @@ class PublicClientApplication {
|
|
|
17984
18065
|
getConfiguration() {
|
|
17985
18066
|
return this.controller.getConfiguration();
|
|
17986
18067
|
}
|
|
18068
|
+
/**
|
|
18069
|
+
* Hydrates cache with the tokens and account in the AuthenticationResult object
|
|
18070
|
+
* @param result
|
|
18071
|
+
* @param request - The request object that was used to obtain the AuthenticationResult
|
|
18072
|
+
* @returns
|
|
18073
|
+
*/
|
|
18074
|
+
async hydrateCache(result, request) {
|
|
18075
|
+
return this.controller.hydrateCache(result, request);
|
|
18076
|
+
}
|
|
17987
18077
|
}
|
|
17988
18078
|
|
|
17989
18079
|
/*
|
|
@@ -18081,6 +18171,9 @@ const stubbedPublicClientApplication = {
|
|
|
18081
18171
|
getConfiguration: () => {
|
|
18082
18172
|
throw BrowserConfigurationAuthError.createStubPcaInstanceCalledError();
|
|
18083
18173
|
},
|
|
18174
|
+
hydrateCache: () => {
|
|
18175
|
+
return Promise.reject(BrowserConfigurationAuthError.createStubPcaInstanceCalledError());
|
|
18176
|
+
},
|
|
18084
18177
|
};
|
|
18085
18178
|
|
|
18086
18179
|
/*
|
|
@@ -18192,6 +18285,227 @@ class SignedHttpRequest {
|
|
|
18192
18285
|
}
|
|
18193
18286
|
}
|
|
18194
18287
|
|
|
18288
|
+
/*
|
|
18289
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
18290
|
+
* Licensed under the MIT License.
|
|
18291
|
+
*/
|
|
18292
|
+
class BrowserPerformanceMeasurement {
|
|
18293
|
+
constructor(name, correlationId) {
|
|
18294
|
+
this.correlationId = correlationId;
|
|
18295
|
+
this.measureName = BrowserPerformanceMeasurement.makeMeasureName(name, correlationId);
|
|
18296
|
+
this.startMark = BrowserPerformanceMeasurement.makeStartMark(name, correlationId);
|
|
18297
|
+
this.endMark = BrowserPerformanceMeasurement.makeEndMark(name, correlationId);
|
|
18298
|
+
}
|
|
18299
|
+
static makeMeasureName(name, correlationId) {
|
|
18300
|
+
return `msal.measure.${name}.${correlationId}`;
|
|
18301
|
+
}
|
|
18302
|
+
static makeStartMark(name, correlationId) {
|
|
18303
|
+
return `msal.start.${name}.${correlationId}`;
|
|
18304
|
+
}
|
|
18305
|
+
static makeEndMark(name, correlationId) {
|
|
18306
|
+
return `msal.end.${name}.${correlationId}`;
|
|
18307
|
+
}
|
|
18308
|
+
static supportsBrowserPerformance() {
|
|
18309
|
+
return (typeof window !== "undefined" &&
|
|
18310
|
+
typeof window.performance !== "undefined" &&
|
|
18311
|
+
typeof window.performance.mark === "function" &&
|
|
18312
|
+
typeof window.performance.measure === "function" &&
|
|
18313
|
+
typeof window.performance.clearMarks === "function" &&
|
|
18314
|
+
typeof window.performance.clearMeasures === "function" &&
|
|
18315
|
+
typeof window.performance.getEntriesByName === "function");
|
|
18316
|
+
}
|
|
18317
|
+
/**
|
|
18318
|
+
* Flush browser marks and measurements.
|
|
18319
|
+
* @param {string} correlationId
|
|
18320
|
+
* @param {SubMeasurement} measurements
|
|
18321
|
+
*/
|
|
18322
|
+
static flushMeasurements(correlationId, measurements) {
|
|
18323
|
+
if (BrowserPerformanceMeasurement.supportsBrowserPerformance()) {
|
|
18324
|
+
try {
|
|
18325
|
+
measurements.forEach((measurement) => {
|
|
18326
|
+
const measureName = BrowserPerformanceMeasurement.makeMeasureName(measurement.name, correlationId);
|
|
18327
|
+
const entriesForMeasurement = window.performance.getEntriesByName(measureName, "measure");
|
|
18328
|
+
if (entriesForMeasurement.length > 0) {
|
|
18329
|
+
window.performance.clearMeasures(measureName);
|
|
18330
|
+
window.performance.clearMarks(BrowserPerformanceMeasurement.makeStartMark(measureName, correlationId));
|
|
18331
|
+
window.performance.clearMarks(BrowserPerformanceMeasurement.makeEndMark(measureName, correlationId));
|
|
18332
|
+
}
|
|
18333
|
+
});
|
|
18334
|
+
}
|
|
18335
|
+
catch (e) {
|
|
18336
|
+
// Silently catch and return null
|
|
18337
|
+
}
|
|
18338
|
+
}
|
|
18339
|
+
}
|
|
18340
|
+
startMeasurement() {
|
|
18341
|
+
if (BrowserPerformanceMeasurement.supportsBrowserPerformance()) {
|
|
18342
|
+
try {
|
|
18343
|
+
window.performance.mark(this.startMark);
|
|
18344
|
+
}
|
|
18345
|
+
catch (e) {
|
|
18346
|
+
// Silently catch
|
|
18347
|
+
}
|
|
18348
|
+
}
|
|
18349
|
+
}
|
|
18350
|
+
endMeasurement() {
|
|
18351
|
+
if (BrowserPerformanceMeasurement.supportsBrowserPerformance()) {
|
|
18352
|
+
try {
|
|
18353
|
+
window.performance.mark(this.endMark);
|
|
18354
|
+
window.performance.measure(this.measureName, this.startMark, this.endMark);
|
|
18355
|
+
}
|
|
18356
|
+
catch (e) {
|
|
18357
|
+
// Silently catch
|
|
18358
|
+
}
|
|
18359
|
+
}
|
|
18360
|
+
}
|
|
18361
|
+
flushMeasurement() {
|
|
18362
|
+
if (BrowserPerformanceMeasurement.supportsBrowserPerformance()) {
|
|
18363
|
+
try {
|
|
18364
|
+
const entriesForMeasurement = window.performance.getEntriesByName(this.measureName, "measure");
|
|
18365
|
+
if (entriesForMeasurement.length > 0) {
|
|
18366
|
+
const durationMs = entriesForMeasurement[0].duration;
|
|
18367
|
+
window.performance.clearMeasures(this.measureName);
|
|
18368
|
+
window.performance.clearMarks(this.startMark);
|
|
18369
|
+
window.performance.clearMarks(this.endMark);
|
|
18370
|
+
return durationMs;
|
|
18371
|
+
}
|
|
18372
|
+
}
|
|
18373
|
+
catch (e) {
|
|
18374
|
+
// Silently catch and return null
|
|
18375
|
+
}
|
|
18376
|
+
}
|
|
18377
|
+
return null;
|
|
18378
|
+
}
|
|
18379
|
+
}
|
|
18380
|
+
|
|
18381
|
+
/*
|
|
18382
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
18383
|
+
* Licensed under the MIT License.
|
|
18384
|
+
*/
|
|
18385
|
+
class BrowserPerformanceClient extends PerformanceClient {
|
|
18386
|
+
constructor(configuration, intFields) {
|
|
18387
|
+
super(configuration.auth.clientId, configuration.auth.authority || `${Constants.DEFAULT_AUTHORITY}`, new Logger(configuration.system?.loggerOptions || {}, name, version), name, version, configuration.telemetry?.application || {
|
|
18388
|
+
appName: "",
|
|
18389
|
+
appVersion: "",
|
|
18390
|
+
}, intFields);
|
|
18391
|
+
this.browserCrypto = new BrowserCrypto(this.logger);
|
|
18392
|
+
this.guidGenerator = new GuidGenerator(this.browserCrypto);
|
|
18393
|
+
}
|
|
18394
|
+
startPerformanceMeasurement(measureName, correlationId) {
|
|
18395
|
+
return new BrowserPerformanceMeasurement(measureName, correlationId);
|
|
18396
|
+
}
|
|
18397
|
+
generateId() {
|
|
18398
|
+
return this.guidGenerator.generateGuid();
|
|
18399
|
+
}
|
|
18400
|
+
getPageVisibility() {
|
|
18401
|
+
return document.visibilityState?.toString() || null;
|
|
18402
|
+
}
|
|
18403
|
+
deleteIncompleteSubMeasurements(inProgressEvent) {
|
|
18404
|
+
const rootEvent = this.eventsByCorrelationId.get(inProgressEvent.event.correlationId);
|
|
18405
|
+
const isRootEvent = rootEvent && rootEvent.eventId === inProgressEvent.event.eventId;
|
|
18406
|
+
const incompleteMeasurements = [];
|
|
18407
|
+
if (isRootEvent && rootEvent?.incompleteSubMeasurements) {
|
|
18408
|
+
rootEvent.incompleteSubMeasurements.forEach((subMeasurement) => {
|
|
18409
|
+
incompleteMeasurements.push({ ...subMeasurement });
|
|
18410
|
+
});
|
|
18411
|
+
}
|
|
18412
|
+
// Clean up remaining marks for incomplete sub-measurements
|
|
18413
|
+
if (incompleteMeasurements.length > 0) {
|
|
18414
|
+
BrowserPerformanceMeasurement.flushMeasurements(inProgressEvent.event.correlationId, incompleteMeasurements);
|
|
18415
|
+
}
|
|
18416
|
+
}
|
|
18417
|
+
supportsBrowserPerformanceNow() {
|
|
18418
|
+
return (typeof window !== "undefined" &&
|
|
18419
|
+
typeof window.performance !== "undefined" &&
|
|
18420
|
+
typeof window.performance.now === "function");
|
|
18421
|
+
}
|
|
18422
|
+
/**
|
|
18423
|
+
* Starts measuring performance for a given operation. Returns a function that should be used to end the measurement.
|
|
18424
|
+
* Also captures browser page visibilityState.
|
|
18425
|
+
*
|
|
18426
|
+
* @param {PerformanceEvents} measureName
|
|
18427
|
+
* @param {?string} [correlationId]
|
|
18428
|
+
* @returns {((event?: Partial<PerformanceEvent>) => PerformanceEvent| null)}
|
|
18429
|
+
*/
|
|
18430
|
+
startMeasurement(measureName, correlationId) {
|
|
18431
|
+
// Capture page visibilityState and then invoke start/end measurement
|
|
18432
|
+
const startPageVisibility = this.getPageVisibility();
|
|
18433
|
+
const inProgressEvent = super.startMeasurement(measureName, correlationId);
|
|
18434
|
+
return {
|
|
18435
|
+
...inProgressEvent,
|
|
18436
|
+
end: (event) => {
|
|
18437
|
+
const res = inProgressEvent.end({
|
|
18438
|
+
startPageVisibility,
|
|
18439
|
+
endPageVisibility: this.getPageVisibility(),
|
|
18440
|
+
...event,
|
|
18441
|
+
});
|
|
18442
|
+
this.deleteIncompleteSubMeasurements(inProgressEvent);
|
|
18443
|
+
return res;
|
|
18444
|
+
},
|
|
18445
|
+
discard: () => {
|
|
18446
|
+
inProgressEvent.discard();
|
|
18447
|
+
this.deleteIncompleteSubMeasurements(inProgressEvent);
|
|
18448
|
+
inProgressEvent.measurement.flushMeasurement();
|
|
18449
|
+
},
|
|
18450
|
+
};
|
|
18451
|
+
}
|
|
18452
|
+
/**
|
|
18453
|
+
* Adds pre-queue time to preQueueTimeByCorrelationId map.
|
|
18454
|
+
* @param {PerformanceEvents} eventName
|
|
18455
|
+
* @param {?string} correlationId
|
|
18456
|
+
* @returns
|
|
18457
|
+
*/
|
|
18458
|
+
setPreQueueTime(eventName, correlationId) {
|
|
18459
|
+
if (!this.supportsBrowserPerformanceNow()) {
|
|
18460
|
+
this.logger.trace(`BrowserPerformanceClient: window performance API not available, unable to set telemetry queue time for ${eventName}`);
|
|
18461
|
+
return;
|
|
18462
|
+
}
|
|
18463
|
+
if (!correlationId) {
|
|
18464
|
+
this.logger.trace(`BrowserPerformanceClient: correlationId for ${eventName} not provided, unable to set telemetry queue time`);
|
|
18465
|
+
return;
|
|
18466
|
+
}
|
|
18467
|
+
const preQueueEvent = this.preQueueTimeByCorrelationId.get(correlationId);
|
|
18468
|
+
/**
|
|
18469
|
+
* Manually complete queue measurement if there is an incomplete pre-queue event.
|
|
18470
|
+
* Incomplete pre-queue events are instrumentation bugs that should be fixed.
|
|
18471
|
+
*/
|
|
18472
|
+
if (preQueueEvent) {
|
|
18473
|
+
this.logger.trace(`BrowserPerformanceClient: Incomplete pre-queue ${preQueueEvent.name} found`, correlationId);
|
|
18474
|
+
this.addQueueMeasurement(preQueueEvent.name, correlationId, undefined, true);
|
|
18475
|
+
}
|
|
18476
|
+
this.preQueueTimeByCorrelationId.set(correlationId, {
|
|
18477
|
+
name: eventName,
|
|
18478
|
+
time: window.performance.now(),
|
|
18479
|
+
});
|
|
18480
|
+
}
|
|
18481
|
+
/**
|
|
18482
|
+
* Calculates and adds queue time measurement for given performance event.
|
|
18483
|
+
*
|
|
18484
|
+
* @param {PerformanceEvents} eventName
|
|
18485
|
+
* @param {?string} correlationId
|
|
18486
|
+
* @param {?number} queueTime
|
|
18487
|
+
* @param {?boolean} manuallyCompleted - indicator for manually completed queue measurements
|
|
18488
|
+
* @returns
|
|
18489
|
+
*/
|
|
18490
|
+
addQueueMeasurement(eventName, correlationId, queueTime, manuallyCompleted) {
|
|
18491
|
+
if (!this.supportsBrowserPerformanceNow()) {
|
|
18492
|
+
this.logger.trace(`BrowserPerformanceClient: window performance API not available, unable to add queue measurement for ${eventName}`);
|
|
18493
|
+
return;
|
|
18494
|
+
}
|
|
18495
|
+
if (!correlationId) {
|
|
18496
|
+
this.logger.trace(`BrowserPerformanceClient: correlationId for ${eventName} not provided, unable to add queue measurement`);
|
|
18497
|
+
return;
|
|
18498
|
+
}
|
|
18499
|
+
const preQueueTime = super.getPreQueueTime(eventName, correlationId);
|
|
18500
|
+
if (!preQueueTime) {
|
|
18501
|
+
return;
|
|
18502
|
+
}
|
|
18503
|
+
const currentTime = window.performance.now();
|
|
18504
|
+
const resQueueTime = queueTime || super.calculateQueuedTime(preQueueTime, currentTime);
|
|
18505
|
+
return super.addQueueMeasurement(eventName, correlationId, resQueueTime, manuallyCompleted);
|
|
18506
|
+
}
|
|
18507
|
+
}
|
|
18508
|
+
|
|
18195
18509
|
exports.AccountEntity = AccountEntity;
|
|
18196
18510
|
exports.ApiId = ApiId;
|
|
18197
18511
|
exports.AuthError = AuthError;
|
|
@@ -18204,6 +18518,8 @@ exports.BrowserAuthErrorMessage = BrowserAuthErrorMessage;
|
|
|
18204
18518
|
exports.BrowserCacheLocation = BrowserCacheLocation;
|
|
18205
18519
|
exports.BrowserConfigurationAuthError = BrowserConfigurationAuthError;
|
|
18206
18520
|
exports.BrowserConfigurationAuthErrorMessage = BrowserConfigurationAuthErrorMessage;
|
|
18521
|
+
exports.BrowserPerformanceClient = BrowserPerformanceClient;
|
|
18522
|
+
exports.BrowserPerformanceMeasurement = BrowserPerformanceMeasurement;
|
|
18207
18523
|
exports.BrowserUtils = BrowserUtils;
|
|
18208
18524
|
exports.CacheLookupPolicy = CacheLookupPolicy;
|
|
18209
18525
|
exports.ClientAuthError = ClientAuthError;
|
|
@@ -18224,6 +18540,7 @@ exports.PromptValue = PromptValue;
|
|
|
18224
18540
|
exports.ProtocolMode = ProtocolMode;
|
|
18225
18541
|
exports.PublicClientApplication = PublicClientApplication;
|
|
18226
18542
|
exports.ServerError = ServerError;
|
|
18543
|
+
exports.ServerResponseType = ServerResponseType;
|
|
18227
18544
|
exports.SignedHttpRequest = SignedHttpRequest;
|
|
18228
18545
|
exports.StringUtils = StringUtils;
|
|
18229
18546
|
exports.UrlString = UrlString;
|
|
@@ -18231,4 +18548,4 @@ exports.WrapperSKU = WrapperSKU;
|
|
|
18231
18548
|
exports.internals = internals;
|
|
18232
18549
|
exports.stubbedPublicClientApplication = stubbedPublicClientApplication;
|
|
18233
18550
|
exports.version = version;
|
|
18234
|
-
//# sourceMappingURL=msal-browser.cjs.
|
|
18551
|
+
//# sourceMappingURL=msal-browser.cjs.map
|