@azure/msal-browser 3.0.0-beta.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -21
- package/dist/app/IPublicClientApplication.d.ts +3 -1
- package/dist/app/IPublicClientApplication.d.ts.map +1 -1
- package/dist/app/IPublicClientApplication.js +4 -1
- package/dist/app/IPublicClientApplication.js.map +1 -1
- package/dist/app/PublicClientApplication.d.ts +9 -1
- package/dist/app/PublicClientApplication.d.ts.map +1 -1
- package/dist/app/PublicClientApplication.js +10 -1
- package/dist/app/PublicClientApplication.js.map +1 -1
- package/dist/broker/nativeBroker/NativeMessageHandler.d.ts.map +1 -1
- package/dist/broker/nativeBroker/NativeMessageHandler.js +5 -5
- package/dist/broker/nativeBroker/NativeMessageHandler.js.map +1 -1
- package/dist/broker/nativeBroker/NativeRequest.d.ts +2 -1
- package/dist/broker/nativeBroker/NativeRequest.d.ts.map +1 -1
- package/dist/cache/AsyncMemoryStorage.js +1 -1
- package/dist/cache/BrowserCacheManager.d.ts +8 -0
- package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
- package/dist/cache/BrowserCacheManager.js +20 -2
- package/dist/cache/BrowserCacheManager.js.map +1 -1
- package/dist/cache/BrowserStorage.js +1 -1
- package/dist/cache/CryptoKeyStore.d.ts +1 -1
- package/dist/cache/CryptoKeyStore.d.ts.map +1 -1
- package/dist/cache/CryptoKeyStore.js +1 -1
- package/dist/cache/CryptoKeyStore.js.map +1 -1
- package/dist/cache/DatabaseStorage.js +1 -1
- package/dist/cache/ITokenCache.d.ts +2 -1
- package/dist/cache/ITokenCache.d.ts.map +1 -1
- package/dist/cache/MemoryStorage.js +1 -1
- package/dist/cache/TokenCache.d.ts +2 -1
- package/dist/cache/TokenCache.d.ts.map +1 -1
- package/dist/cache/TokenCache.js +20 -19
- package/dist/cache/TokenCache.js.map +1 -1
- package/dist/cache/entities/CacheRecord.d.ts +6 -0
- package/dist/cache/entities/CacheRecord.d.ts.map +1 -0
- package/dist/config/Configuration.d.ts +14 -2
- package/dist/config/Configuration.d.ts.map +1 -1
- package/dist/config/Configuration.js +39 -5
- package/dist/config/Configuration.js.map +1 -1
- package/dist/controllers/ControllerFactory.js +1 -1
- package/dist/controllers/IController.d.ts +3 -1
- package/dist/controllers/IController.d.ts.map +1 -1
- package/dist/controllers/StandardController.d.ts +9 -1
- package/dist/controllers/StandardController.d.ts.map +1 -1
- package/dist/controllers/StandardController.js +59 -41
- package/dist/controllers/StandardController.js.map +1 -1
- package/dist/crypto/BrowserCrypto.js +1 -1
- package/dist/crypto/CryptoOps.d.ts.map +1 -1
- package/dist/crypto/CryptoOps.js +4 -4
- package/dist/crypto/CryptoOps.js.map +1 -1
- package/dist/crypto/GuidGenerator.js +1 -1
- package/dist/crypto/ModernBrowserCrypto.js +1 -1
- package/dist/crypto/PkceGenerator.js +1 -1
- package/dist/crypto/SignedHttpRequest.js +1 -1
- package/dist/encode/Base64Decode.js +1 -1
- package/dist/encode/Base64Encode.js +1 -1
- package/dist/error/BrowserAuthError.d.ts +2 -2
- package/dist/error/BrowserAuthError.d.ts.map +1 -1
- package/dist/error/BrowserAuthError.js +6 -6
- package/dist/error/BrowserAuthError.js.map +1 -1
- package/dist/error/BrowserConfigurationAuthError.js +1 -1
- package/dist/error/NativeAuthError.d.ts +1 -1
- package/dist/error/NativeAuthError.d.ts.map +1 -1
- package/dist/error/NativeAuthError.js +1 -1
- package/dist/error/NativeAuthError.js.map +1 -1
- package/dist/event/EventHandler.js +1 -1
- package/dist/event/EventMessage.d.ts +2 -2
- package/dist/event/EventMessage.d.ts.map +1 -1
- package/dist/event/EventMessage.js +1 -1
- package/dist/event/EventMessage.js.map +1 -1
- package/dist/event/EventType.d.ts +1 -1
- package/dist/event/EventType.d.ts.map +1 -1
- package/dist/event/EventType.js +2 -2
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/interaction_client/BaseInteractionClient.d.ts +2 -1
- package/dist/interaction_client/BaseInteractionClient.d.ts.map +1 -1
- package/dist/interaction_client/BaseInteractionClient.js +7 -3
- package/dist/interaction_client/BaseInteractionClient.js.map +1 -1
- package/dist/interaction_client/HybridSpaAuthorizationCodeClient.js +1 -1
- package/dist/interaction_client/NativeInteractionClient.d.ts +3 -11
- package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
- package/dist/interaction_client/NativeInteractionClient.js +21 -25
- package/dist/interaction_client/NativeInteractionClient.js.map +1 -1
- package/dist/interaction_client/PopupClient.d.ts +6 -1
- package/dist/interaction_client/PopupClient.d.ts.map +1 -1
- package/dist/interaction_client/PopupClient.js +48 -9
- package/dist/interaction_client/PopupClient.js.map +1 -1
- package/dist/interaction_client/RedirectClient.d.ts +2 -1
- package/dist/interaction_client/RedirectClient.d.ts.map +1 -1
- package/dist/interaction_client/RedirectClient.js +14 -2
- package/dist/interaction_client/RedirectClient.js.map +1 -1
- package/dist/interaction_client/SilentAuthCodeClient.d.ts +2 -1
- package/dist/interaction_client/SilentAuthCodeClient.d.ts.map +1 -1
- package/dist/interaction_client/SilentAuthCodeClient.js +1 -1
- package/dist/interaction_client/SilentCacheClient.d.ts +2 -1
- package/dist/interaction_client/SilentCacheClient.d.ts.map +1 -1
- package/dist/interaction_client/SilentCacheClient.js +5 -5
- package/dist/interaction_client/SilentCacheClient.js.map +1 -1
- package/dist/interaction_client/SilentIframeClient.d.ts +2 -1
- package/dist/interaction_client/SilentIframeClient.d.ts.map +1 -1
- package/dist/interaction_client/SilentIframeClient.js +4 -4
- package/dist/interaction_client/SilentIframeClient.js.map +1 -1
- package/dist/interaction_client/SilentRefreshClient.d.ts +2 -1
- package/dist/interaction_client/SilentRefreshClient.d.ts.map +1 -1
- package/dist/interaction_client/SilentRefreshClient.js +5 -4
- package/dist/interaction_client/SilentRefreshClient.js.map +1 -1
- package/dist/interaction_client/StandardInteractionClient.d.ts.map +1 -1
- package/dist/interaction_client/StandardInteractionClient.js +10 -5
- package/dist/interaction_client/StandardInteractionClient.js.map +1 -1
- package/dist/interaction_handler/InteractionHandler.d.ts +2 -1
- package/dist/interaction_handler/InteractionHandler.d.ts.map +1 -1
- package/dist/interaction_handler/InteractionHandler.js +2 -2
- package/dist/interaction_handler/InteractionHandler.js.map +1 -1
- package/dist/interaction_handler/RedirectHandler.d.ts +2 -1
- package/dist/interaction_handler/RedirectHandler.d.ts.map +1 -1
- package/dist/interaction_handler/RedirectHandler.js +2 -2
- package/dist/interaction_handler/RedirectHandler.js.map +1 -1
- package/dist/interaction_handler/SilentHandler.js +1 -1
- package/dist/internals.d.ts +1 -2
- package/dist/internals.d.ts.map +1 -1
- package/dist/internals.js +7 -3
- package/dist/internals.js.map +1 -1
- package/dist/navigation/NavigationClient.js +1 -1
- package/dist/network/FetchClient.js +1 -1
- package/dist/network/XhrClient.js +1 -1
- package/dist/operatingcontext/BaseOperatingContext.js +1 -1
- package/dist/operatingcontext/StandardOperatingContext.js +1 -1
- package/dist/operatingcontext/TeamsAppOperatingContext.js +1 -1
- package/dist/packageMetadata.d.ts +1 -1
- package/dist/packageMetadata.d.ts.map +1 -1
- package/dist/packageMetadata.js +2 -2
- package/dist/response/AuthenticationResult.d.ts +5 -0
- package/dist/response/AuthenticationResult.d.ts.map +1 -0
- package/dist/telemetry/BrowserPerformanceClient.d.ts +3 -2
- package/dist/telemetry/BrowserPerformanceClient.d.ts.map +1 -1
- package/dist/telemetry/BrowserPerformanceClient.js +12 -8
- package/dist/telemetry/BrowserPerformanceClient.js.map +1 -1
- package/dist/telemetry/BrowserPerformanceMeasurement.js +1 -1
- package/dist/utils/BrowserConstants.d.ts +10 -10
- package/dist/utils/BrowserConstants.d.ts.map +1 -1
- package/dist/utils/BrowserConstants.js +1 -1
- package/dist/utils/BrowserConstants.js.map +1 -1
- package/dist/utils/BrowserProtocolUtils.js +1 -1
- package/dist/utils/BrowserStringUtils.d.ts +0 -5
- package/dist/utils/BrowserStringUtils.d.ts.map +1 -1
- package/dist/utils/BrowserStringUtils.js +1 -13
- package/dist/utils/BrowserStringUtils.js.map +1 -1
- package/dist/utils/BrowserUtils.d.ts +2 -3
- package/dist/utils/BrowserUtils.d.ts.map +1 -1
- package/dist/utils/BrowserUtils.js +5 -6
- package/dist/utils/BrowserUtils.js.map +1 -1
- package/dist/utils/MathUtils.js +1 -1
- package/lib/msal-browser.cjs.js +971 -687
- package/lib/msal-browser.cjs.js.map +1 -1
- package/lib/msal-browser.js +971 -687
- package/lib/msal-browser.js.map +1 -1
- package/lib/msal-browser.min.js +62 -62
- package/package.json +20 -18
package/lib/msal-browser.cjs.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/*! @azure/msal-browser v3.0.0
|
|
1
|
+
/*! @azure/msal-browser v3.0.0 2023-08-08 */
|
|
2
2
|
'use strict';
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
|
-
/*! @azure/msal-common v14.0.0
|
|
5
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
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.0
|
|
365
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
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.0
|
|
419
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
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.0
|
|
464
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
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.0
|
|
986
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
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.0
|
|
1113
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
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.0
|
|
1313
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
1308
1314
|
/* eslint-disable header/header */
|
|
1309
1315
|
const name$1 = "@azure/msal-common";
|
|
1310
|
-
const version$1 = "14.0.0
|
|
1316
|
+
const version$1 = "14.0.0";
|
|
1311
1317
|
|
|
1312
|
-
/*! @azure/msal-common v14.0.0
|
|
1318
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
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.0
|
|
1338
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
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.0
|
|
1620
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
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.0
|
|
1820
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
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.0
|
|
1860
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
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.0 2023-08-08 */
|
|
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.0
|
|
1888
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
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.0
|
|
2111
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
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.0
|
|
2162
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
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) {
|
|
@@ -3162,7 +3174,7 @@ class DefaultStorageClass extends CacheManager {
|
|
|
3162
3174
|
}
|
|
3163
3175
|
}
|
|
3164
3176
|
|
|
3165
|
-
/*! @azure/msal-common v14.0.0
|
|
3177
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
3166
3178
|
|
|
3167
3179
|
/*
|
|
3168
3180
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3182,6 +3194,9 @@ const DEFAULT_LOGGER_IMPLEMENTATION = {
|
|
|
3182
3194
|
logLevel: exports.LogLevel.Info,
|
|
3183
3195
|
correlationId: Constants.EMPTY_STRING,
|
|
3184
3196
|
};
|
|
3197
|
+
const DEFAULT_CACHE_OPTIONS = {
|
|
3198
|
+
claimsBasedCachingEnabled: false,
|
|
3199
|
+
};
|
|
3185
3200
|
const DEFAULT_NETWORK_IMPLEMENTATION = {
|
|
3186
3201
|
async sendGetRequestAsync() {
|
|
3187
3202
|
const notImplErr = "Network interface - sendGetRequestAsync() has not been implemented";
|
|
@@ -3219,7 +3234,7 @@ const DEFAULT_TELEMETRY_OPTIONS = {
|
|
|
3219
3234
|
*
|
|
3220
3235
|
* @returns Configuration
|
|
3221
3236
|
*/
|
|
3222
|
-
function buildClientConfiguration({ authOptions: userAuthOptions, systemOptions: userSystemOptions, loggerOptions: userLoggerOption, storageInterface: storageImplementation, networkInterface: networkImplementation, cryptoInterface: cryptoImplementation, clientCredentials: clientCredentials, libraryInfo: libraryInfo, telemetry: telemetry, serverTelemetryManager: serverTelemetryManager, persistencePlugin: persistencePlugin, serializableCache: serializableCache, }) {
|
|
3237
|
+
function buildClientConfiguration({ authOptions: userAuthOptions, systemOptions: userSystemOptions, loggerOptions: userLoggerOption, cacheOptions: userCacheOptions, storageInterface: storageImplementation, networkInterface: networkImplementation, cryptoInterface: cryptoImplementation, clientCredentials: clientCredentials, libraryInfo: libraryInfo, telemetry: telemetry, serverTelemetryManager: serverTelemetryManager, persistencePlugin: persistencePlugin, serializableCache: serializableCache, }) {
|
|
3223
3238
|
const loggerOptions = {
|
|
3224
3239
|
...DEFAULT_LOGGER_IMPLEMENTATION,
|
|
3225
3240
|
...userLoggerOption,
|
|
@@ -3228,6 +3243,7 @@ function buildClientConfiguration({ authOptions: userAuthOptions, systemOptions:
|
|
|
3228
3243
|
authOptions: buildAuthOptions(userAuthOptions),
|
|
3229
3244
|
systemOptions: { ...DEFAULT_SYSTEM_OPTIONS, ...userSystemOptions },
|
|
3230
3245
|
loggerOptions: loggerOptions,
|
|
3246
|
+
cacheOptions: { ...DEFAULT_CACHE_OPTIONS, ...userCacheOptions },
|
|
3231
3247
|
storageInterface: storageImplementation ||
|
|
3232
3248
|
new DefaultStorageClass(userAuthOptions.clientId, DEFAULT_CRYPTO_IMPLEMENTATION, new Logger(loggerOptions)),
|
|
3233
3249
|
networkInterface: networkImplementation || DEFAULT_NETWORK_IMPLEMENTATION,
|
|
@@ -3252,8 +3268,15 @@ function buildAuthOptions(authOptions) {
|
|
|
3252
3268
|
...authOptions,
|
|
3253
3269
|
};
|
|
3254
3270
|
}
|
|
3271
|
+
/**
|
|
3272
|
+
* Returns true if config has protocolMode set to ProtocolMode.OIDC, false otherwise
|
|
3273
|
+
* @param ClientConfiguration
|
|
3274
|
+
*/
|
|
3275
|
+
function isOidcProtocolMode(config) {
|
|
3276
|
+
return (config.authOptions.authority.options.protocolMode === ProtocolMode.OIDC);
|
|
3277
|
+
}
|
|
3255
3278
|
|
|
3256
|
-
/*! @azure/msal-common v14.0.0
|
|
3279
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
3257
3280
|
|
|
3258
3281
|
/*
|
|
3259
3282
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3270,7 +3293,7 @@ class ServerError extends AuthError {
|
|
|
3270
3293
|
}
|
|
3271
3294
|
}
|
|
3272
3295
|
|
|
3273
|
-
/*! @azure/msal-common v14.0.0
|
|
3296
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
3274
3297
|
|
|
3275
3298
|
/*
|
|
3276
3299
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3367,7 +3390,7 @@ class ThrottlingUtils {
|
|
|
3367
3390
|
}
|
|
3368
3391
|
}
|
|
3369
3392
|
|
|
3370
|
-
/*! @azure/msal-common v14.0.0
|
|
3393
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
3371
3394
|
|
|
3372
3395
|
/*
|
|
3373
3396
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3403,7 +3426,7 @@ class NetworkManager {
|
|
|
3403
3426
|
}
|
|
3404
3427
|
}
|
|
3405
3428
|
|
|
3406
|
-
/*! @azure/msal-common v14.0.0
|
|
3429
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
3407
3430
|
/*
|
|
3408
3431
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3409
3432
|
* Licensed under the MIT License.
|
|
@@ -3413,7 +3436,7 @@ const CcsCredentialType = {
|
|
|
3413
3436
|
UPN: "UPN",
|
|
3414
3437
|
};
|
|
3415
3438
|
|
|
3416
|
-
/*! @azure/msal-common v14.0.0
|
|
3439
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
3417
3440
|
|
|
3418
3441
|
/*
|
|
3419
3442
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3494,11 +3517,11 @@ class RequestValidator {
|
|
|
3494
3517
|
}
|
|
3495
3518
|
});
|
|
3496
3519
|
// remove empty string parameters
|
|
3497
|
-
return Object.fromEntries(Object.entries(eQParams).filter(kv => kv[1] !== ""));
|
|
3520
|
+
return Object.fromEntries(Object.entries(eQParams).filter((kv) => kv[1] !== ""));
|
|
3498
3521
|
}
|
|
3499
3522
|
}
|
|
3500
3523
|
|
|
3501
|
-
/*! @azure/msal-common v14.0.0
|
|
3524
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
3502
3525
|
|
|
3503
3526
|
/*
|
|
3504
3527
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3538,9 +3561,15 @@ class RequestParameterBuilder {
|
|
|
3538
3561
|
* @param scopeSet
|
|
3539
3562
|
* @param addOidcScopes
|
|
3540
3563
|
*/
|
|
3541
|
-
addScopes(scopes, addOidcScopes = true) {
|
|
3564
|
+
addScopes(scopes, addOidcScopes = true, defaultScopes = OIDC_DEFAULT_SCOPES) {
|
|
3565
|
+
// Always add openid to the scopes when adding OIDC scopes
|
|
3566
|
+
if (addOidcScopes &&
|
|
3567
|
+
!defaultScopes.includes("openid") &&
|
|
3568
|
+
!scopes.includes("openid")) {
|
|
3569
|
+
defaultScopes.push("openid");
|
|
3570
|
+
}
|
|
3542
3571
|
const requestScopes = addOidcScopes
|
|
3543
|
-
? [...(scopes || []), ...
|
|
3572
|
+
? [...(scopes || []), ...defaultScopes]
|
|
3544
3573
|
: scopes || [];
|
|
3545
3574
|
const scopeSet = new ScopeSet(requestScopes);
|
|
3546
3575
|
this.parameters.set(AADServerParamKeys.SCOPE, encodeURIComponent(scopeSet.printScopes()));
|
|
@@ -3875,7 +3904,7 @@ class RequestParameterBuilder {
|
|
|
3875
3904
|
}
|
|
3876
3905
|
}
|
|
3877
3906
|
|
|
3878
|
-
/*! @azure/msal-common v14.0.0
|
|
3907
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
3879
3908
|
|
|
3880
3909
|
/*
|
|
3881
3910
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3970,7 +3999,7 @@ class BaseClient {
|
|
|
3970
3999
|
}
|
|
3971
4000
|
}
|
|
3972
4001
|
|
|
3973
|
-
/*! @azure/msal-common v14.0.0
|
|
4002
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
3974
4003
|
|
|
3975
4004
|
/*
|
|
3976
4005
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4109,7 +4138,7 @@ class CredentialEntity {
|
|
|
4109
4138
|
}
|
|
4110
4139
|
}
|
|
4111
4140
|
|
|
4112
|
-
/*! @azure/msal-common v14.0.0
|
|
4141
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
4113
4142
|
|
|
4114
4143
|
/*
|
|
4115
4144
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4168,7 +4197,7 @@ class IdTokenEntity extends CredentialEntity {
|
|
|
4168
4197
|
}
|
|
4169
4198
|
}
|
|
4170
4199
|
|
|
4171
|
-
/*! @azure/msal-common v14.0.0
|
|
4200
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
4172
4201
|
/*
|
|
4173
4202
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4174
4203
|
* Licensed under the MIT License.
|
|
@@ -4215,7 +4244,7 @@ class TimeUtils {
|
|
|
4215
4244
|
}
|
|
4216
4245
|
}
|
|
4217
4246
|
|
|
4218
|
-
/*! @azure/msal-common v14.0.0
|
|
4247
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
4219
4248
|
|
|
4220
4249
|
/*
|
|
4221
4250
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4329,7 +4358,7 @@ class AccessTokenEntity extends CredentialEntity {
|
|
|
4329
4358
|
}
|
|
4330
4359
|
}
|
|
4331
4360
|
|
|
4332
|
-
/*! @azure/msal-common v14.0.0
|
|
4361
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
4333
4362
|
|
|
4334
4363
|
/*
|
|
4335
4364
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4391,7 +4420,7 @@ class RefreshTokenEntity extends CredentialEntity {
|
|
|
4391
4420
|
}
|
|
4392
4421
|
}
|
|
4393
4422
|
|
|
4394
|
-
/*! @azure/msal-common v14.0.0
|
|
4423
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
4395
4424
|
|
|
4396
4425
|
/*
|
|
4397
4426
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4472,7 +4501,7 @@ class InteractionRequiredAuthError extends AuthError {
|
|
|
4472
4501
|
}
|
|
4473
4502
|
}
|
|
4474
4503
|
|
|
4475
|
-
/*! @azure/msal-common v14.0.0
|
|
4504
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
4476
4505
|
/*
|
|
4477
4506
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4478
4507
|
* Licensed under the MIT License.
|
|
@@ -4487,7 +4516,7 @@ class CacheRecord {
|
|
|
4487
4516
|
}
|
|
4488
4517
|
}
|
|
4489
4518
|
|
|
4490
|
-
/*! @azure/msal-common v14.0.0
|
|
4519
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
4491
4520
|
|
|
4492
4521
|
/*
|
|
4493
4522
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4561,7 +4590,7 @@ class ProtocolUtils {
|
|
|
4561
4590
|
}
|
|
4562
4591
|
}
|
|
4563
4592
|
|
|
4564
|
-
/*! @azure/msal-common v14.0.0
|
|
4593
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
4565
4594
|
|
|
4566
4595
|
/*
|
|
4567
4596
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4745,6 +4774,30 @@ class UrlString {
|
|
|
4745
4774
|
}
|
|
4746
4775
|
return Constants.EMPTY_STRING;
|
|
4747
4776
|
}
|
|
4777
|
+
/**
|
|
4778
|
+
* Parses query server response string from given string.
|
|
4779
|
+
* Extract hash between '?code=' and '#' if trailing '# is present.
|
|
4780
|
+
* Returns empty string if no query symbol is found.
|
|
4781
|
+
* @param queryString
|
|
4782
|
+
*/
|
|
4783
|
+
static parseQueryServerResponse(queryString) {
|
|
4784
|
+
const queryIndex1 = queryString.indexOf("?code");
|
|
4785
|
+
const queryIndex2 = queryString.indexOf("/?code");
|
|
4786
|
+
const hashIndex = queryString.indexOf("#");
|
|
4787
|
+
if (queryIndex2 > -1 && hashIndex > -1) {
|
|
4788
|
+
return queryString.substring(queryIndex2 + 2, hashIndex);
|
|
4789
|
+
}
|
|
4790
|
+
else if (queryIndex2 > -1) {
|
|
4791
|
+
return queryString.substring(queryIndex2 + 2);
|
|
4792
|
+
}
|
|
4793
|
+
else if (queryIndex1 > -1 && hashIndex > -1) {
|
|
4794
|
+
return queryString.substring(queryIndex1 + 1, hashIndex);
|
|
4795
|
+
}
|
|
4796
|
+
else if (queryIndex1 > -1) {
|
|
4797
|
+
return queryString.substring(queryIndex1 + 1);
|
|
4798
|
+
}
|
|
4799
|
+
return Constants.EMPTY_STRING;
|
|
4800
|
+
}
|
|
4748
4801
|
static constructAuthorityUriFromObject(urlObject) {
|
|
4749
4802
|
return new UrlString(urlObject.Protocol +
|
|
4750
4803
|
"//" +
|
|
@@ -4790,6 +4843,21 @@ class UrlString {
|
|
|
4790
4843
|
}
|
|
4791
4844
|
return deserializedQueryString;
|
|
4792
4845
|
}
|
|
4846
|
+
/**
|
|
4847
|
+
* Returns either deserialized query string or deserialized hash, depending on the serverResponseType
|
|
4848
|
+
* as a server auth code response object.
|
|
4849
|
+
*/
|
|
4850
|
+
static getDeserializedCodeResponse(serverResponseType, hashFragment) {
|
|
4851
|
+
const hashUrlString = new UrlString(hashFragment);
|
|
4852
|
+
let serverParams;
|
|
4853
|
+
if (serverResponseType === ServerResponseType.QUERY) {
|
|
4854
|
+
serverParams = UrlString.getDeserializedQueryString(hashFragment);
|
|
4855
|
+
}
|
|
4856
|
+
else {
|
|
4857
|
+
serverParams = UrlString.getDeserializedHash(hashUrlString.getHash());
|
|
4858
|
+
}
|
|
4859
|
+
return serverParams;
|
|
4860
|
+
}
|
|
4793
4861
|
/**
|
|
4794
4862
|
* Check if the hash of the URL string contains known properties
|
|
4795
4863
|
*/
|
|
@@ -4806,7 +4874,7 @@ class UrlString {
|
|
|
4806
4874
|
}
|
|
4807
4875
|
}
|
|
4808
4876
|
|
|
4809
|
-
/*! @azure/msal-common v14.0.0
|
|
4877
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
4810
4878
|
/*
|
|
4811
4879
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4812
4880
|
* Licensed under the MIT License.
|
|
@@ -5009,6 +5077,7 @@ const PerformanceEvents = {
|
|
|
5009
5077
|
UpdateCloudDiscoveryMetadataMeasurement: "updateCloudDiscoveryMetadataMeasurement",
|
|
5010
5078
|
UsernamePasswordClientAcquireToken: "usernamePasswordClientAcquireToken",
|
|
5011
5079
|
NativeMessageHandlerHandshake: "nativeMessageHandlerHandshake",
|
|
5080
|
+
NativeGenerateAuthResult: "nativeGenerateAuthResult",
|
|
5012
5081
|
};
|
|
5013
5082
|
/**
|
|
5014
5083
|
* State of the performance event.
|
|
@@ -5033,7 +5102,7 @@ const IntFields = new Set([
|
|
|
5033
5102
|
"status",
|
|
5034
5103
|
]);
|
|
5035
5104
|
|
|
5036
|
-
/*! @azure/msal-common v14.0.0
|
|
5105
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
5037
5106
|
|
|
5038
5107
|
/*
|
|
5039
5108
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -5118,7 +5187,7 @@ class PopTokenGenerator {
|
|
|
5118
5187
|
}
|
|
5119
5188
|
}
|
|
5120
5189
|
|
|
5121
|
-
/*! @azure/msal-common v14.0.0
|
|
5190
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
5122
5191
|
|
|
5123
5192
|
/*
|
|
5124
5193
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -5187,7 +5256,7 @@ class AppMetadataEntity {
|
|
|
5187
5256
|
}
|
|
5188
5257
|
}
|
|
5189
5258
|
|
|
5190
|
-
/*! @azure/msal-common v14.0.0
|
|
5259
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
5191
5260
|
/*
|
|
5192
5261
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
5193
5262
|
* Licensed under the MIT License.
|
|
@@ -5214,7 +5283,7 @@ class AppMetadataEntity {
|
|
|
5214
5283
|
}
|
|
5215
5284
|
}
|
|
5216
5285
|
|
|
5217
|
-
/*! @azure/msal-common v14.0.0
|
|
5286
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
5218
5287
|
|
|
5219
5288
|
/*
|
|
5220
5289
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -5241,12 +5310,25 @@ class ResponseHandler {
|
|
|
5241
5310
|
*/
|
|
5242
5311
|
validateServerAuthorizationCodeResponse(serverResponseHash, cachedState, cryptoObj) {
|
|
5243
5312
|
if (!serverResponseHash.state || !cachedState) {
|
|
5244
|
-
throw
|
|
5245
|
-
? ClientAuthError.createStateNotFoundError("
|
|
5246
|
-
: ClientAuthError.createStateNotFoundError("
|
|
5313
|
+
throw serverResponseHash.state
|
|
5314
|
+
? ClientAuthError.createStateNotFoundError("Cached State")
|
|
5315
|
+
: ClientAuthError.createStateNotFoundError("Server State");
|
|
5316
|
+
}
|
|
5317
|
+
let decodedServerResponseHash;
|
|
5318
|
+
let decodedCachedState;
|
|
5319
|
+
try {
|
|
5320
|
+
decodedServerResponseHash = decodeURIComponent(serverResponseHash.state);
|
|
5321
|
+
}
|
|
5322
|
+
catch (e) {
|
|
5323
|
+
throw ClientAuthError.createInvalidStateError(serverResponseHash.state, `Server response hash URI could not be decoded`);
|
|
5324
|
+
}
|
|
5325
|
+
try {
|
|
5326
|
+
decodedCachedState = decodeURIComponent(cachedState);
|
|
5327
|
+
}
|
|
5328
|
+
catch (e) {
|
|
5329
|
+
throw ClientAuthError.createInvalidStateError(serverResponseHash.state, `Cached state URI could not be decoded`);
|
|
5247
5330
|
}
|
|
5248
|
-
if (
|
|
5249
|
-
decodeURIComponent(cachedState)) {
|
|
5331
|
+
if (decodedServerResponseHash !== decodedCachedState) {
|
|
5250
5332
|
throw ClientAuthError.createStateMismatchError();
|
|
5251
5333
|
}
|
|
5252
5334
|
// Check for error
|
|
@@ -5306,7 +5388,7 @@ class ResponseHandler {
|
|
|
5306
5388
|
}
|
|
5307
5389
|
}
|
|
5308
5390
|
// generate homeAccountId
|
|
5309
|
-
this.homeAccountIdentifier = AccountEntity.generateHomeAccountId(serverTokenResponse.client_info || Constants.EMPTY_STRING, authority.authorityType, this.logger, this.cryptoObj, idTokenObj);
|
|
5391
|
+
this.homeAccountIdentifier = AccountEntity.generateHomeAccountId(serverTokenResponse.client_info || Constants.EMPTY_STRING, authority.authorityType, this.logger, this.cryptoObj, idTokenObj?.claims);
|
|
5310
5392
|
// save the response tokens
|
|
5311
5393
|
let requestStateObj;
|
|
5312
5394
|
if (!!authCodePayload && !!authCodePayload.state) {
|
|
@@ -5339,7 +5421,7 @@ class ResponseHandler {
|
|
|
5339
5421
|
return ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenObj, requestStateObj, undefined, serverRequestId);
|
|
5340
5422
|
}
|
|
5341
5423
|
}
|
|
5342
|
-
await this.cacheStorage.saveCacheRecord(cacheRecord);
|
|
5424
|
+
await this.cacheStorage.saveCacheRecord(cacheRecord, request.storeInCache);
|
|
5343
5425
|
}
|
|
5344
5426
|
finally {
|
|
5345
5427
|
if (this.persistencePlugin &&
|
|
@@ -5368,7 +5450,13 @@ class ResponseHandler {
|
|
|
5368
5450
|
if (!StringUtils.isEmpty(serverTokenResponse.id_token) &&
|
|
5369
5451
|
!!idTokenObj) {
|
|
5370
5452
|
cachedIdToken = IdTokenEntity.createIdTokenEntity(this.homeAccountIdentifier, env, serverTokenResponse.id_token || Constants.EMPTY_STRING, this.clientId, idTokenObj.claims.tid || Constants.EMPTY_STRING);
|
|
5371
|
-
cachedAccount =
|
|
5453
|
+
cachedAccount = AccountEntity.createAccount({
|
|
5454
|
+
homeAccountId: this.homeAccountIdentifier,
|
|
5455
|
+
idTokenClaims: idTokenObj.claims,
|
|
5456
|
+
clientInfo: serverTokenResponse.client_info,
|
|
5457
|
+
cloudGraphHostName: authCodePayload?.cloud_graph_host_name,
|
|
5458
|
+
msGraphHost: authCodePayload?.msgraph_host,
|
|
5459
|
+
}, authority);
|
|
5372
5460
|
}
|
|
5373
5461
|
// AccessToken
|
|
5374
5462
|
let cachedAccessToken = null;
|
|
@@ -5412,34 +5500,6 @@ class ResponseHandler {
|
|
|
5412
5500
|
}
|
|
5413
5501
|
return new CacheRecord(cachedAccount, cachedIdToken, cachedAccessToken, cachedRefreshToken, cachedAppMetadata);
|
|
5414
5502
|
}
|
|
5415
|
-
/**
|
|
5416
|
-
* Generate Account
|
|
5417
|
-
* @param serverTokenResponse
|
|
5418
|
-
* @param idToken
|
|
5419
|
-
* @param authority
|
|
5420
|
-
*/
|
|
5421
|
-
generateAccountEntity(serverTokenResponse, idToken, authority, authCodePayload) {
|
|
5422
|
-
const authorityType = authority.authorityType;
|
|
5423
|
-
const cloudGraphHostName = authCodePayload
|
|
5424
|
-
? authCodePayload.cloud_graph_host_name
|
|
5425
|
-
: Constants.EMPTY_STRING;
|
|
5426
|
-
const msGraphhost = authCodePayload
|
|
5427
|
-
? authCodePayload.msgraph_host
|
|
5428
|
-
: Constants.EMPTY_STRING;
|
|
5429
|
-
// ADFS does not require client_info in the response
|
|
5430
|
-
if (authorityType === AuthorityType.Adfs) {
|
|
5431
|
-
this.logger.verbose("Authority type is ADFS, creating ADFS account");
|
|
5432
|
-
return AccountEntity.createGenericAccount(this.homeAccountIdentifier, idToken, authority, cloudGraphHostName, msGraphhost);
|
|
5433
|
-
}
|
|
5434
|
-
// This fallback applies to B2C as well as they fall under an AAD account type.
|
|
5435
|
-
if (StringUtils.isEmpty(serverTokenResponse.client_info) &&
|
|
5436
|
-
authority.protocolMode === "AAD") {
|
|
5437
|
-
throw ClientAuthError.createClientInfoEmptyError();
|
|
5438
|
-
}
|
|
5439
|
-
return serverTokenResponse.client_info
|
|
5440
|
-
? AccountEntity.createAccount(serverTokenResponse.client_info, this.homeAccountIdentifier, idToken, authority, cloudGraphHostName, msGraphhost)
|
|
5441
|
-
: AccountEntity.createGenericAccount(this.homeAccountIdentifier, idToken, authority, cloudGraphHostName, msGraphhost);
|
|
5442
|
-
}
|
|
5443
5503
|
/**
|
|
5444
5504
|
* Creates an @AuthenticationResult from @CacheRecord , @IdToken , and a boolean that states whether or not the result is from cache.
|
|
5445
5505
|
*
|
|
@@ -5517,7 +5577,7 @@ class ResponseHandler {
|
|
|
5517
5577
|
}
|
|
5518
5578
|
}
|
|
5519
5579
|
|
|
5520
|
-
/*! @azure/msal-common v14.0.0
|
|
5580
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
5521
5581
|
|
|
5522
5582
|
/*
|
|
5523
5583
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -5531,6 +5591,8 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
5531
5591
|
super(configuration, performanceClient);
|
|
5532
5592
|
// Flag to indicate if client is for hybrid spa auth code redemption
|
|
5533
5593
|
this.includeRedirectUri = true;
|
|
5594
|
+
this.oidcDefaultScopes =
|
|
5595
|
+
this.config.authOptions.authority.options.OIDCOptions?.defaultScopes;
|
|
5534
5596
|
}
|
|
5535
5597
|
/**
|
|
5536
5598
|
* Creates the URL of the authorization request letting the user input credentials and consent to the
|
|
@@ -5569,7 +5631,7 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
5569
5631
|
const requestId = response.headers?.[HeaderNames.X_MS_REQUEST_ID];
|
|
5570
5632
|
const httpVerAuthority = response.headers?.[HeaderNames.X_MS_HTTP_VERSION];
|
|
5571
5633
|
if (httpVerAuthority) {
|
|
5572
|
-
atsMeasurement?.
|
|
5634
|
+
atsMeasurement?.add({
|
|
5573
5635
|
httpVerAuthority,
|
|
5574
5636
|
});
|
|
5575
5637
|
}
|
|
@@ -5580,14 +5642,14 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
5580
5642
|
return responseHandler
|
|
5581
5643
|
.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request, authCodePayload, undefined, undefined, undefined, requestId)
|
|
5582
5644
|
.then((result) => {
|
|
5583
|
-
atsMeasurement?.
|
|
5645
|
+
atsMeasurement?.end({
|
|
5584
5646
|
success: true,
|
|
5585
5647
|
});
|
|
5586
5648
|
return result;
|
|
5587
5649
|
})
|
|
5588
5650
|
.catch((error) => {
|
|
5589
5651
|
this.logger.verbose("Error in fetching token in ACC", request.correlationId);
|
|
5590
|
-
atsMeasurement?.
|
|
5652
|
+
atsMeasurement?.end({
|
|
5591
5653
|
errorCode: error.errorCode,
|
|
5592
5654
|
subErrorCode: error.subError,
|
|
5593
5655
|
success: false,
|
|
@@ -5603,10 +5665,8 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
5603
5665
|
handleFragmentResponse(hashFragment, cachedState) {
|
|
5604
5666
|
// Handle responses.
|
|
5605
5667
|
const responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, null, null);
|
|
5606
|
-
|
|
5607
|
-
|
|
5608
|
-
// Deserialize hash fragment response parameters.
|
|
5609
|
-
const serverParams = UrlString.getDeserializedHash(hashUrlString.getHash());
|
|
5668
|
+
const serverParams = UrlString.getDeserializedCodeResponse(this.config.authOptions.authority.options.OIDCOptions
|
|
5669
|
+
?.serverResponseType, hashFragment);
|
|
5610
5670
|
// Get code response
|
|
5611
5671
|
responseHandler.validateServerAuthorizationCodeResponse(serverParams, cachedState, this.cryptoUtils);
|
|
5612
5672
|
// throw when there is no auth code in the response
|
|
@@ -5692,14 +5752,14 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
5692
5752
|
parameterBuilder.addRedirectUri(request.redirectUri);
|
|
5693
5753
|
}
|
|
5694
5754
|
// Add scope array, parameter builder will add default scopes and dedupe
|
|
5695
|
-
parameterBuilder.addScopes(request.scopes);
|
|
5755
|
+
parameterBuilder.addScopes(request.scopes, true, this.oidcDefaultScopes);
|
|
5696
5756
|
// add code: user set, not validated
|
|
5697
5757
|
parameterBuilder.addAuthorizationCode(request.code);
|
|
5698
5758
|
// Add library metadata
|
|
5699
5759
|
parameterBuilder.addLibraryInfo(this.config.libraryInfo);
|
|
5700
5760
|
parameterBuilder.addApplicationTelemetry(this.config.telemetry.application);
|
|
5701
5761
|
parameterBuilder.addThrottling();
|
|
5702
|
-
if (this.serverTelemetryManager) {
|
|
5762
|
+
if (this.serverTelemetryManager && !isOidcProtocolMode(this.config)) {
|
|
5703
5763
|
parameterBuilder.addServerTelemetry(this.serverTelemetryManager);
|
|
5704
5764
|
}
|
|
5705
5765
|
// add code_verifier if passed
|
|
@@ -5798,7 +5858,7 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
5798
5858
|
...(request.scopes || []),
|
|
5799
5859
|
...(request.extraScopesToConsent || []),
|
|
5800
5860
|
];
|
|
5801
|
-
parameterBuilder.addScopes(requestScopes);
|
|
5861
|
+
parameterBuilder.addScopes(requestScopes, true, this.oidcDefaultScopes);
|
|
5802
5862
|
// validate the redirectUri (to be a non null value)
|
|
5803
5863
|
parameterBuilder.addRedirectUri(request.redirectUri);
|
|
5804
5864
|
// generate the correlationId if not set by the user and add
|
|
@@ -5811,7 +5871,9 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
5811
5871
|
parameterBuilder.addResponseTypeCode();
|
|
5812
5872
|
// add library info parameters
|
|
5813
5873
|
parameterBuilder.addLibraryInfo(this.config.libraryInfo);
|
|
5814
|
-
|
|
5874
|
+
if (!isOidcProtocolMode(this.config)) {
|
|
5875
|
+
parameterBuilder.addApplicationTelemetry(this.config.telemetry.application);
|
|
5876
|
+
}
|
|
5815
5877
|
// add client_info=1
|
|
5816
5878
|
parameterBuilder.addClientInfo();
|
|
5817
5879
|
if (request.codeChallenge && request.codeChallengeMethod) {
|
|
@@ -5953,7 +6015,7 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
5953
6015
|
}
|
|
5954
6016
|
}
|
|
5955
6017
|
|
|
5956
|
-
/*! @azure/msal-common v14.0.0
|
|
6018
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
5957
6019
|
|
|
5958
6020
|
/*
|
|
5959
6021
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -5974,11 +6036,11 @@ class RefreshTokenClient extends BaseClient {
|
|
|
5974
6036
|
this.performanceClient?.setPreQueueTime(PerformanceEvents.RefreshTokenClientExecuteTokenRequest, request.correlationId);
|
|
5975
6037
|
const response = await this.executeTokenRequest(request, this.authority);
|
|
5976
6038
|
const httpVerToken = response.headers?.[HeaderNames.X_MS_HTTP_VERSION];
|
|
5977
|
-
atsMeasurement?.
|
|
6039
|
+
atsMeasurement?.add({
|
|
5978
6040
|
refreshTokenSize: response.body.refresh_token?.length || 0,
|
|
5979
6041
|
});
|
|
5980
6042
|
if (httpVerToken) {
|
|
5981
|
-
atsMeasurement?.
|
|
6043
|
+
atsMeasurement?.add({
|
|
5982
6044
|
httpVerToken,
|
|
5983
6045
|
});
|
|
5984
6046
|
}
|
|
@@ -5990,14 +6052,14 @@ class RefreshTokenClient extends BaseClient {
|
|
|
5990
6052
|
return responseHandler
|
|
5991
6053
|
.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request, undefined, undefined, true, request.forceCache, requestId)
|
|
5992
6054
|
.then((result) => {
|
|
5993
|
-
atsMeasurement?.
|
|
6055
|
+
atsMeasurement?.end({
|
|
5994
6056
|
success: true,
|
|
5995
6057
|
});
|
|
5996
6058
|
return result;
|
|
5997
6059
|
})
|
|
5998
6060
|
.catch((error) => {
|
|
5999
6061
|
this.logger.verbose("Error in fetching refresh token", request.correlationId);
|
|
6000
|
-
atsMeasurement?.
|
|
6062
|
+
atsMeasurement?.end({
|
|
6001
6063
|
errorCode: error.errorCode,
|
|
6002
6064
|
subErrorCode: error.subError,
|
|
6003
6065
|
success: false,
|
|
@@ -6061,11 +6123,11 @@ class RefreshTokenClient extends BaseClient {
|
|
|
6061
6123
|
this.logger.verbose("RefreshTokenClientAcquireTokenWithCachedRefreshToken called", request.correlationId);
|
|
6062
6124
|
const refreshToken = this.cacheManager.getRefreshToken(request.account, foci);
|
|
6063
6125
|
if (!refreshToken) {
|
|
6064
|
-
atsMeasurement?.
|
|
6126
|
+
atsMeasurement?.discard();
|
|
6065
6127
|
throw InteractionRequiredAuthError.createNoTokensFoundError();
|
|
6066
6128
|
}
|
|
6067
6129
|
// attach cached RT size to the current measurement
|
|
6068
|
-
atsMeasurement?.
|
|
6130
|
+
atsMeasurement?.end({
|
|
6069
6131
|
success: true,
|
|
6070
6132
|
});
|
|
6071
6133
|
const refreshTokenRequest = {
|
|
@@ -6106,13 +6168,13 @@ class RefreshTokenClient extends BaseClient {
|
|
|
6106
6168
|
};
|
|
6107
6169
|
return this.executePostToTokenEndpoint(endpoint, requestBody, headers, thumbprint)
|
|
6108
6170
|
.then((result) => {
|
|
6109
|
-
acquireTokenMeasurement?.
|
|
6171
|
+
acquireTokenMeasurement?.end({
|
|
6110
6172
|
success: true,
|
|
6111
6173
|
});
|
|
6112
6174
|
return result;
|
|
6113
6175
|
})
|
|
6114
6176
|
.catch((error) => {
|
|
6115
|
-
acquireTokenMeasurement?.
|
|
6177
|
+
acquireTokenMeasurement?.end({
|
|
6116
6178
|
success: false,
|
|
6117
6179
|
});
|
|
6118
6180
|
throw error;
|
|
@@ -6128,13 +6190,13 @@ class RefreshTokenClient extends BaseClient {
|
|
|
6128
6190
|
const acquireTokenMeasurement = this.performanceClient?.startMeasurement(PerformanceEvents.BaseClientCreateTokenRequestHeaders, correlationId);
|
|
6129
6191
|
const parameterBuilder = new RequestParameterBuilder();
|
|
6130
6192
|
parameterBuilder.addClientId(this.config.authOptions.clientId);
|
|
6131
|
-
parameterBuilder.addScopes(request.scopes);
|
|
6193
|
+
parameterBuilder.addScopes(request.scopes, true, this.config.authOptions.authority.options.OIDCOptions?.defaultScopes);
|
|
6132
6194
|
parameterBuilder.addGrantType(GrantType.REFRESH_TOKEN_GRANT);
|
|
6133
6195
|
parameterBuilder.addClientInfo();
|
|
6134
6196
|
parameterBuilder.addLibraryInfo(this.config.libraryInfo);
|
|
6135
6197
|
parameterBuilder.addApplicationTelemetry(this.config.telemetry.application);
|
|
6136
6198
|
parameterBuilder.addThrottling();
|
|
6137
|
-
if (this.serverTelemetryManager) {
|
|
6199
|
+
if (this.serverTelemetryManager && !isOidcProtocolMode(this.config)) {
|
|
6138
6200
|
parameterBuilder.addServerTelemetry(this.serverTelemetryManager);
|
|
6139
6201
|
}
|
|
6140
6202
|
parameterBuilder.addCorrelationId(correlationId);
|
|
@@ -6159,7 +6221,7 @@ class RefreshTokenClient extends BaseClient {
|
|
|
6159
6221
|
parameterBuilder.addSshJwk(request.sshJwk);
|
|
6160
6222
|
}
|
|
6161
6223
|
else {
|
|
6162
|
-
acquireTokenMeasurement?.
|
|
6224
|
+
acquireTokenMeasurement?.end({
|
|
6163
6225
|
success: false,
|
|
6164
6226
|
});
|
|
6165
6227
|
throw ClientConfigurationError.createMissingSshJwkError();
|
|
@@ -6188,14 +6250,14 @@ class RefreshTokenClient extends BaseClient {
|
|
|
6188
6250
|
break;
|
|
6189
6251
|
}
|
|
6190
6252
|
}
|
|
6191
|
-
acquireTokenMeasurement?.
|
|
6253
|
+
acquireTokenMeasurement?.end({
|
|
6192
6254
|
success: true,
|
|
6193
6255
|
});
|
|
6194
6256
|
return parameterBuilder.createQueryString();
|
|
6195
6257
|
}
|
|
6196
6258
|
}
|
|
6197
6259
|
|
|
6198
|
-
/*! @azure/msal-common v14.0.0
|
|
6260
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
6199
6261
|
|
|
6200
6262
|
/*
|
|
6201
6263
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6240,6 +6302,12 @@ class SilentFlowClient extends BaseClient {
|
|
|
6240
6302
|
this.logger.info("SilentFlowClient:acquireCachedToken - Skipping cache because forceRefresh is true.");
|
|
6241
6303
|
throw ClientAuthError.createRefreshRequiredError();
|
|
6242
6304
|
}
|
|
6305
|
+
else if (!this.config.cacheOptions.claimsBasedCachingEnabled &&
|
|
6306
|
+
!StringUtils.isEmptyObj(request.claims)) {
|
|
6307
|
+
// Must refresh due to request parameters.
|
|
6308
|
+
this.logger.info("SilentFlowClient:acquireCachedToken - Skipping cache because claims-based caching is disabled and claims were requested.");
|
|
6309
|
+
throw ClientAuthError.createRefreshRequiredError();
|
|
6310
|
+
}
|
|
6243
6311
|
// We currently do not support silent flow for account === null use cases; This will be revisited for confidential flow usecases
|
|
6244
6312
|
if (!request.account) {
|
|
6245
6313
|
throw ClientAuthError.createNoAccountInSilentRequestError();
|
|
@@ -6292,7 +6360,7 @@ class SilentFlowClient extends BaseClient {
|
|
|
6292
6360
|
}
|
|
6293
6361
|
}
|
|
6294
6362
|
|
|
6295
|
-
/*! @azure/msal-common v14.0.0
|
|
6363
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
6296
6364
|
/*
|
|
6297
6365
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6298
6366
|
* Licensed under the MIT License.
|
|
@@ -6304,7 +6372,7 @@ function isOpenIdConfigResponse(response) {
|
|
|
6304
6372
|
response.hasOwnProperty("jwks_uri"));
|
|
6305
6373
|
}
|
|
6306
6374
|
|
|
6307
|
-
/*! @azure/msal-common v14.0.0
|
|
6375
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
6308
6376
|
/*
|
|
6309
6377
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6310
6378
|
* Licensed under the MIT License.
|
|
@@ -7181,21 +7249,16 @@ const rawMetdataJSON = {
|
|
|
7181
7249
|
};
|
|
7182
7250
|
const EndpointMetadata = rawMetdataJSON.endpointMetadata;
|
|
7183
7251
|
const InstanceDiscoveryMetadata = rawMetdataJSON.instanceDiscoveryMetadata;
|
|
7252
|
+
const InstanceDiscoveryMetadataAliases = new Set();
|
|
7253
|
+
for (const key in InstanceDiscoveryMetadata) {
|
|
7254
|
+
for (const metadata of InstanceDiscoveryMetadata[key].metadata) {
|
|
7255
|
+
for (const alias of metadata.aliases) {
|
|
7256
|
+
InstanceDiscoveryMetadataAliases.add(alias);
|
|
7257
|
+
}
|
|
7258
|
+
}
|
|
7259
|
+
}
|
|
7184
7260
|
|
|
7185
|
-
/*! @azure/msal-common v14.0.0
|
|
7186
|
-
/*
|
|
7187
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
7188
|
-
* Licensed under the MIT License.
|
|
7189
|
-
*/
|
|
7190
|
-
/**
|
|
7191
|
-
* Protocol modes supported by MSAL.
|
|
7192
|
-
*/
|
|
7193
|
-
const ProtocolMode = {
|
|
7194
|
-
AAD: "AAD",
|
|
7195
|
-
OIDC: "OIDC",
|
|
7196
|
-
};
|
|
7197
|
-
|
|
7198
|
-
/*! @azure/msal-common v14.0.0-beta.0 2023-06-19 */
|
|
7261
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
7199
7262
|
|
|
7200
7263
|
/*
|
|
7201
7264
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7275,7 +7338,7 @@ class AuthorityMetadataEntity {
|
|
|
7275
7338
|
}
|
|
7276
7339
|
}
|
|
7277
7340
|
|
|
7278
|
-
/*! @azure/msal-common v14.0.0
|
|
7341
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
7279
7342
|
/*
|
|
7280
7343
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
7281
7344
|
* Licensed under the MIT License.
|
|
@@ -7285,7 +7348,7 @@ function isCloudInstanceDiscoveryResponse(response) {
|
|
|
7285
7348
|
response.hasOwnProperty("metadata"));
|
|
7286
7349
|
}
|
|
7287
7350
|
|
|
7288
|
-
/*! @azure/msal-common v14.0.0
|
|
7351
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
7289
7352
|
/*
|
|
7290
7353
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
7291
7354
|
* Licensed under the MIT License.
|
|
@@ -7295,7 +7358,7 @@ function isCloudInstanceDiscoveryErrorResponse(response) {
|
|
|
7295
7358
|
response.hasOwnProperty("error_description"));
|
|
7296
7359
|
}
|
|
7297
7360
|
|
|
7298
|
-
/*! @azure/msal-common v14.0.0
|
|
7361
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
7299
7362
|
|
|
7300
7363
|
/*
|
|
7301
7364
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7406,7 +7469,7 @@ RegionDiscovery.IMDS_OPTIONS = {
|
|
|
7406
7469
|
},
|
|
7407
7470
|
};
|
|
7408
7471
|
|
|
7409
|
-
/*! @azure/msal-common v14.0.0
|
|
7472
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
7410
7473
|
|
|
7411
7474
|
/*
|
|
7412
7475
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7579,10 +7642,10 @@ class Authority {
|
|
|
7579
7642
|
* @private
|
|
7580
7643
|
*/
|
|
7581
7644
|
canReplaceTenant(authorityUri) {
|
|
7582
|
-
return authorityUri.PathSegments.length === 1
|
|
7583
|
-
|
|
7584
|
-
|
|
7585
|
-
|
|
7645
|
+
return (authorityUri.PathSegments.length === 1 &&
|
|
7646
|
+
!Authority.reservedTenantDomains.has(authorityUri.PathSegments[0]) &&
|
|
7647
|
+
this.getAuthorityType(authorityUri) === AuthorityType.Default &&
|
|
7648
|
+
this.protocolMode === ProtocolMode.AAD);
|
|
7586
7649
|
}
|
|
7587
7650
|
/**
|
|
7588
7651
|
* Replaces tenant in url path with current tenant. Defaults to common.
|
|
@@ -7603,8 +7666,9 @@ class Authority {
|
|
|
7603
7666
|
const currentAuthorityParts = this.canonicalAuthorityUrlComponents.PathSegments;
|
|
7604
7667
|
currentAuthorityParts.forEach((currentPart, index) => {
|
|
7605
7668
|
let cachedPart = cachedAuthorityParts[index];
|
|
7606
|
-
if (index === 0 &&
|
|
7607
|
-
|
|
7669
|
+
if (index === 0 &&
|
|
7670
|
+
this.canReplaceTenant(cachedAuthorityUrlComponents)) {
|
|
7671
|
+
const tenantId = new UrlString(this.metadata.authorization_endpoint).getUrlComponents().PathSegments[0];
|
|
7608
7672
|
/**
|
|
7609
7673
|
* Check if AAD canonical authority contains tenant domain name, for example "testdomain.onmicrosoft.com",
|
|
7610
7674
|
* by comparing its first path segment to the corresponding authorization endpoint path segment, which is
|
|
@@ -7625,8 +7689,9 @@ class Authority {
|
|
|
7625
7689
|
* The default open id configuration endpoint for any canonical authority.
|
|
7626
7690
|
*/
|
|
7627
7691
|
get defaultOpenIdConfigurationEndpoint() {
|
|
7692
|
+
const canonicalAuthorityHost = this.hostnameAndPort;
|
|
7628
7693
|
if (this.authorityType === AuthorityType.Adfs ||
|
|
7629
|
-
this.
|
|
7694
|
+
!this.isAliasOfKnownMicrosoftAuthority(canonicalAuthorityHost)) {
|
|
7630
7695
|
return `${this.canonicalAuthority}.well-known/openid-configuration`;
|
|
7631
7696
|
}
|
|
7632
7697
|
return `${this.canonicalAuthority}v2.0/.well-known/openid-configuration`;
|
|
@@ -7669,41 +7734,65 @@ class Authority {
|
|
|
7669
7734
|
*/
|
|
7670
7735
|
async updateEndpointMetadata(metadataEntity) {
|
|
7671
7736
|
this.performanceClient?.addQueueMeasurement(PerformanceEvents.AuthorityUpdateEndpointMetadata, this.correlationId);
|
|
7737
|
+
this.logger.verbose("Attempting to get endpoint metadata from authority configuration");
|
|
7672
7738
|
let metadata = this.getEndpointMetadataFromConfig();
|
|
7673
7739
|
if (metadata) {
|
|
7740
|
+
this.logger.verbose("Found endpoint metadata in authority configuration");
|
|
7674
7741
|
metadataEntity.updateEndpointMetadata(metadata, false);
|
|
7675
7742
|
return AuthorityMetadataSource.CONFIG;
|
|
7676
7743
|
}
|
|
7744
|
+
this.logger.verbose("Did not find endpoint metadata in the config... Attempting to get endpoint metadata from the hardcoded values.");
|
|
7745
|
+
// 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.
|
|
7746
|
+
if (this.authorityOptions.skipAuthorityMetadataCache) {
|
|
7747
|
+
this.logger.verbose("Skipping hardcoded metadata cache since skipAuthorityMetadataCache is set to true. Attempting to get endpoint metadata from the network metadata cache.");
|
|
7748
|
+
}
|
|
7749
|
+
else {
|
|
7750
|
+
let hardcodedMetadata = this.getEndpointMetadataFromHardcodedValues();
|
|
7751
|
+
if (hardcodedMetadata) {
|
|
7752
|
+
this.logger.verbose("Found endpoint metadata from hardcoded values.");
|
|
7753
|
+
// If the user prefers to use an azure region replace the global endpoints with regional information.
|
|
7754
|
+
if (this.authorityOptions.azureRegionConfiguration?.azureRegion) {
|
|
7755
|
+
this.performanceClient?.setPreQueueTime(PerformanceEvents.AuthorityUpdateMetadataWithRegionalInformation, this.correlationId);
|
|
7756
|
+
this.logger.verbose("Found azure region configuration. Updating endpoints with regional information.");
|
|
7757
|
+
hardcodedMetadata =
|
|
7758
|
+
await this.updateMetadataWithRegionalInformation(hardcodedMetadata);
|
|
7759
|
+
}
|
|
7760
|
+
metadataEntity.updateEndpointMetadata(hardcodedMetadata, false);
|
|
7761
|
+
return AuthorityMetadataSource.HARDCODED_VALUES;
|
|
7762
|
+
}
|
|
7763
|
+
else {
|
|
7764
|
+
this.logger.verbose("Did not find endpoint metadata in hardcoded values... Attempting to get endpoint metadata from the network metadata cache.");
|
|
7765
|
+
}
|
|
7766
|
+
}
|
|
7767
|
+
// Check cached metadata entity expiration status
|
|
7768
|
+
const metadataEntityExpired = metadataEntity.isExpired();
|
|
7677
7769
|
if (this.isAuthoritySameType(metadataEntity) &&
|
|
7678
7770
|
metadataEntity.endpointsFromNetwork &&
|
|
7679
|
-
!
|
|
7771
|
+
!metadataEntityExpired) {
|
|
7680
7772
|
// No need to update
|
|
7773
|
+
this.logger.verbose("Found endpoint metadata in the cache.");
|
|
7681
7774
|
return AuthorityMetadataSource.CACHE;
|
|
7682
7775
|
}
|
|
7776
|
+
else if (metadataEntityExpired) {
|
|
7777
|
+
this.logger.verbose("The metadata entity is expired.");
|
|
7778
|
+
}
|
|
7779
|
+
this.logger.verbose("Did not find cached endpoint metadata... Attempting to get endpoint metadata from the network.");
|
|
7683
7780
|
this.performanceClient?.setPreQueueTime(PerformanceEvents.AuthorityGetEndpointMetadataFromNetwork, this.correlationId);
|
|
7684
7781
|
metadata = await this.getEndpointMetadataFromNetwork();
|
|
7685
7782
|
if (metadata) {
|
|
7783
|
+
this.logger.verbose("Endpoint metadata was successfully returned from getEndpointMetadataFromNetwork()");
|
|
7686
7784
|
// If the user prefers to use an azure region replace the global endpoints with regional information.
|
|
7687
7785
|
if (this.authorityOptions.azureRegionConfiguration?.azureRegion) {
|
|
7688
7786
|
this.performanceClient?.setPreQueueTime(PerformanceEvents.AuthorityUpdateMetadataWithRegionalInformation, this.correlationId);
|
|
7787
|
+
this.logger.verbose("Found azure region configuration. Updating endpoints with regional information.");
|
|
7689
7788
|
metadata = await this.updateMetadataWithRegionalInformation(metadata);
|
|
7690
7789
|
}
|
|
7691
7790
|
metadataEntity.updateEndpointMetadata(metadata, true);
|
|
7692
7791
|
return AuthorityMetadataSource.NETWORK;
|
|
7693
7792
|
}
|
|
7694
|
-
let harcodedMetadata = this.getEndpointMetadataFromHardcodedValues();
|
|
7695
|
-
if (harcodedMetadata &&
|
|
7696
|
-
!this.authorityOptions.skipAuthorityMetadataCache) {
|
|
7697
|
-
// If the user prefers to use an azure region replace the global endpoints with regional information.
|
|
7698
|
-
if (this.authorityOptions.azureRegionConfiguration?.azureRegion) {
|
|
7699
|
-
this.performanceClient?.setPreQueueTime(PerformanceEvents.AuthorityUpdateMetadataWithRegionalInformation, this.correlationId);
|
|
7700
|
-
harcodedMetadata =
|
|
7701
|
-
await this.updateMetadataWithRegionalInformation(harcodedMetadata);
|
|
7702
|
-
}
|
|
7703
|
-
metadataEntity.updateEndpointMetadata(harcodedMetadata, false);
|
|
7704
|
-
return AuthorityMetadataSource.HARDCODED_VALUES;
|
|
7705
|
-
}
|
|
7706
7793
|
else {
|
|
7794
|
+
// Metadata could not be obtained from the config, cache, network or hardcoded values
|
|
7795
|
+
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.");
|
|
7707
7796
|
throw ClientAuthError.createUnableToGetOpenidConfigError(this.defaultOpenIdConfigurationEndpoint);
|
|
7708
7797
|
}
|
|
7709
7798
|
}
|
|
@@ -7752,17 +7841,23 @@ class Authority {
|
|
|
7752
7841
|
const response = await this.networkInterface.sendGetRequestAsync(openIdConfigurationEndpoint, options);
|
|
7753
7842
|
const isValidResponse = isOpenIdConfigResponse(response.body);
|
|
7754
7843
|
if (isValidResponse) {
|
|
7755
|
-
perfEvent?.
|
|
7844
|
+
perfEvent?.end({ success: true });
|
|
7756
7845
|
return response.body;
|
|
7757
7846
|
}
|
|
7758
7847
|
else {
|
|
7759
|
-
perfEvent?.
|
|
7848
|
+
perfEvent?.end({
|
|
7849
|
+
success: false,
|
|
7850
|
+
errorCode: "invalid_response",
|
|
7851
|
+
});
|
|
7760
7852
|
this.logger.verbose(`Authority.getEndpointMetadataFromNetwork: could not parse response as OpenID configuration`);
|
|
7761
7853
|
return null;
|
|
7762
7854
|
}
|
|
7763
7855
|
}
|
|
7764
7856
|
catch (e) {
|
|
7765
|
-
perfEvent?.
|
|
7857
|
+
perfEvent?.end({
|
|
7858
|
+
success: false,
|
|
7859
|
+
errorCode: "request_failure",
|
|
7860
|
+
});
|
|
7766
7861
|
this.logger.verbose(`Authority.getEndpointMetadataFromNetwork: ${e}`);
|
|
7767
7862
|
return null;
|
|
7768
7863
|
}
|
|
@@ -7778,37 +7873,32 @@ class Authority {
|
|
|
7778
7873
|
}
|
|
7779
7874
|
/**
|
|
7780
7875
|
* Update the retrieved metadata with regional information.
|
|
7876
|
+
* User selected Azure region will be used if configured.
|
|
7781
7877
|
*/
|
|
7782
7878
|
async updateMetadataWithRegionalInformation(metadata) {
|
|
7783
7879
|
this.performanceClient?.addQueueMeasurement(PerformanceEvents.AuthorityUpdateMetadataWithRegionalInformation, this.correlationId);
|
|
7784
|
-
this.
|
|
7785
|
-
|
|
7786
|
-
|
|
7787
|
-
|
|
7788
|
-
? autodetectedRegionName
|
|
7789
|
-
: this.authorityOptions.azureRegionConfiguration?.azureRegion;
|
|
7790
|
-
if (this.authorityOptions.azureRegionConfiguration?.azureRegion ===
|
|
7791
|
-
Constants.AZURE_REGION_AUTO_DISCOVER_FLAG) {
|
|
7792
|
-
this.regionDiscoveryMetadata.region_outcome = autodetectedRegionName
|
|
7793
|
-
? RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_SUCCESSFUL
|
|
7794
|
-
: RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_FAILED;
|
|
7795
|
-
}
|
|
7796
|
-
else {
|
|
7797
|
-
if (autodetectedRegionName) {
|
|
7880
|
+
const userConfiguredAzureRegion = this.authorityOptions.azureRegionConfiguration?.azureRegion;
|
|
7881
|
+
if (userConfiguredAzureRegion) {
|
|
7882
|
+
if (userConfiguredAzureRegion !==
|
|
7883
|
+
Constants.AZURE_REGION_AUTO_DISCOVER_FLAG) {
|
|
7798
7884
|
this.regionDiscoveryMetadata.region_outcome =
|
|
7799
|
-
|
|
7800
|
-
|
|
7801
|
-
|
|
7802
|
-
|
|
7885
|
+
RegionDiscoveryOutcomes.CONFIGURED_NO_AUTO_DETECTION;
|
|
7886
|
+
this.regionDiscoveryMetadata.region_used =
|
|
7887
|
+
userConfiguredAzureRegion;
|
|
7888
|
+
return Authority.replaceWithRegionalInformation(metadata, userConfiguredAzureRegion);
|
|
7803
7889
|
}
|
|
7804
|
-
|
|
7890
|
+
this.performanceClient?.setPreQueueTime(PerformanceEvents.RegionDiscoveryDetectRegion, this.correlationId);
|
|
7891
|
+
const autodetectedRegionName = await this.regionDiscovery.detectRegion(this.authorityOptions.azureRegionConfiguration
|
|
7892
|
+
?.environmentRegion, this.regionDiscoveryMetadata);
|
|
7893
|
+
if (autodetectedRegionName) {
|
|
7805
7894
|
this.regionDiscoveryMetadata.region_outcome =
|
|
7806
|
-
RegionDiscoveryOutcomes.
|
|
7895
|
+
RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_SUCCESSFUL;
|
|
7896
|
+
this.regionDiscoveryMetadata.region_used =
|
|
7897
|
+
autodetectedRegionName;
|
|
7898
|
+
return Authority.replaceWithRegionalInformation(metadata, autodetectedRegionName);
|
|
7807
7899
|
}
|
|
7808
|
-
|
|
7809
|
-
|
|
7810
|
-
this.regionDiscoveryMetadata.region_used = azureRegion;
|
|
7811
|
-
return Authority.replaceWithRegionalInformation(metadata, azureRegion);
|
|
7900
|
+
this.regionDiscoveryMetadata.region_outcome =
|
|
7901
|
+
RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_FAILED;
|
|
7812
7902
|
}
|
|
7813
7903
|
return metadata;
|
|
7814
7904
|
}
|
|
@@ -7820,7 +7910,7 @@ class Authority {
|
|
|
7820
7910
|
*/
|
|
7821
7911
|
async updateCloudDiscoveryMetadata(metadataEntity) {
|
|
7822
7912
|
this.performanceClient?.addQueueMeasurement(PerformanceEvents.AuthorityUpdateCloudDiscoveryMetadata, this.correlationId);
|
|
7823
|
-
this.logger.verbose("Attempting to get cloud discovery metadata
|
|
7913
|
+
this.logger.verbose("Attempting to get cloud discovery metadata from authority configuration");
|
|
7824
7914
|
this.logger.verbosePii(`Known Authorities: ${this.authorityOptions.knownAuthorities ||
|
|
7825
7915
|
Constants.NOT_APPLICABLE}`);
|
|
7826
7916
|
this.logger.verbosePii(`Authority Metadata: ${this.authorityOptions.authorityMetadata ||
|
|
@@ -7828,17 +7918,29 @@ class Authority {
|
|
|
7828
7918
|
this.logger.verbosePii(`Canonical Authority: ${metadataEntity.canonical_authority || Constants.NOT_APPLICABLE}`);
|
|
7829
7919
|
let metadata = this.getCloudDiscoveryMetadataFromConfig();
|
|
7830
7920
|
if (metadata) {
|
|
7831
|
-
this.logger.verbose("Found cloud discovery metadata in
|
|
7921
|
+
this.logger.verbose("Found cloud discovery metadata in authority configuration");
|
|
7832
7922
|
metadataEntity.updateCloudDiscoveryMetadata(metadata, false);
|
|
7833
7923
|
return AuthorityMetadataSource.CONFIG;
|
|
7834
7924
|
}
|
|
7835
|
-
// If the cached metadata came from config but that config was not passed to this instance, we must go to
|
|
7836
|
-
this.logger.verbose("Did not find cloud discovery metadata in the config... Attempting to get cloud discovery metadata from the
|
|
7925
|
+
// If the cached metadata came from config but that config was not passed to this instance, we must go to hardcoded values
|
|
7926
|
+
this.logger.verbose("Did not find cloud discovery metadata in the config... Attempting to get cloud discovery metadata from the hardcoded values.");
|
|
7927
|
+
if (this.options.skipAuthorityMetadataCache) {
|
|
7928
|
+
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.");
|
|
7929
|
+
}
|
|
7930
|
+
else {
|
|
7931
|
+
const hardcodedMetadata = this.getCloudDiscoveryMetadataFromHardcodedValues();
|
|
7932
|
+
if (hardcodedMetadata) {
|
|
7933
|
+
this.logger.verbose("Found cloud discovery metadata from hardcoded values.");
|
|
7934
|
+
metadataEntity.updateCloudDiscoveryMetadata(hardcodedMetadata, false);
|
|
7935
|
+
return AuthorityMetadataSource.HARDCODED_VALUES;
|
|
7936
|
+
}
|
|
7937
|
+
this.logger.verbose("Did not find cloud discovery metadata in hardcoded values... Attempting to get cloud discovery metadata from the network metadata cache.");
|
|
7938
|
+
}
|
|
7837
7939
|
const metadataEntityExpired = metadataEntity.isExpired();
|
|
7838
7940
|
if (this.isAuthoritySameType(metadataEntity) &&
|
|
7839
7941
|
metadataEntity.aliasesFromNetwork &&
|
|
7840
7942
|
!metadataEntityExpired) {
|
|
7841
|
-
this.logger.verbose("Found metadata in the cache.");
|
|
7943
|
+
this.logger.verbose("Found cloud discovery metadata in the cache.");
|
|
7842
7944
|
// No need to update
|
|
7843
7945
|
return AuthorityMetadataSource.CACHE;
|
|
7844
7946
|
}
|
|
@@ -7853,15 +7955,8 @@ class Authority {
|
|
|
7853
7955
|
metadataEntity.updateCloudDiscoveryMetadata(metadata, true);
|
|
7854
7956
|
return AuthorityMetadataSource.NETWORK;
|
|
7855
7957
|
}
|
|
7856
|
-
this.logger.verbose("Did not find cloud discovery metadata from the network... Attempting to get cloud discovery metadata from hardcoded values.");
|
|
7857
|
-
const harcodedMetadata = this.getCloudDiscoveryMetadataFromHarcodedValues();
|
|
7858
|
-
if (harcodedMetadata && !this.options.skipAuthorityMetadataCache) {
|
|
7859
|
-
this.logger.verbose("Found cloud discovery metadata from hardcoded values.");
|
|
7860
|
-
metadataEntity.updateCloudDiscoveryMetadata(harcodedMetadata, false);
|
|
7861
|
-
return AuthorityMetadataSource.HARDCODED_VALUES;
|
|
7862
|
-
}
|
|
7863
7958
|
// Metadata could not be obtained from the config, cache, network or hardcoded values
|
|
7864
|
-
this.logger.error("Did not find cloud discovery metadata from
|
|
7959
|
+
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.");
|
|
7865
7960
|
throw ClientConfigurationError.createUntrustedAuthorityError();
|
|
7866
7961
|
}
|
|
7867
7962
|
/**
|
|
@@ -7966,9 +8061,11 @@ class Authority {
|
|
|
7966
8061
|
/**
|
|
7967
8062
|
* Get cloud discovery metadata for common authorities
|
|
7968
8063
|
*/
|
|
7969
|
-
|
|
8064
|
+
getCloudDiscoveryMetadataFromHardcodedValues() {
|
|
7970
8065
|
if (this.canonicalAuthority in InstanceDiscoveryMetadata) {
|
|
7971
|
-
|
|
8066
|
+
const hardcodedMetadataResponse = InstanceDiscoveryMetadata[this.canonicalAuthority];
|
|
8067
|
+
const metadata = Authority.getCloudDiscoveryMetadataFromNetworkResponse(hardcodedMetadataResponse.metadata, this.hostnameAndPort);
|
|
8068
|
+
return metadata;
|
|
7972
8069
|
}
|
|
7973
8070
|
return null;
|
|
7974
8071
|
}
|
|
@@ -8043,6 +8140,13 @@ class Authority {
|
|
|
8043
8140
|
isAlias(host) {
|
|
8044
8141
|
return this.metadata.aliases.indexOf(host) > -1;
|
|
8045
8142
|
}
|
|
8143
|
+
/**
|
|
8144
|
+
* Returns whether or not the provided host is an alias of a known Microsoft authority for purposes of endpoint discovery
|
|
8145
|
+
* @param host
|
|
8146
|
+
*/
|
|
8147
|
+
isAliasOfKnownMicrosoftAuthority(host) {
|
|
8148
|
+
return InstanceDiscoveryMetadataAliases.has(host);
|
|
8149
|
+
}
|
|
8046
8150
|
/**
|
|
8047
8151
|
* Checks whether the provided host is that of a public cloud authority
|
|
8048
8152
|
*
|
|
@@ -8084,15 +8188,17 @@ class Authority {
|
|
|
8084
8188
|
* @param azureRegion string
|
|
8085
8189
|
*/
|
|
8086
8190
|
static replaceWithRegionalInformation(metadata, azureRegion) {
|
|
8087
|
-
metadata
|
|
8088
|
-
|
|
8191
|
+
const regionalMetadata = { ...metadata };
|
|
8192
|
+
regionalMetadata.authorization_endpoint =
|
|
8193
|
+
Authority.buildRegionalAuthorityString(regionalMetadata.authorization_endpoint, azureRegion);
|
|
8089
8194
|
// TODO: Enquire on whether we should leave the query string or remove it before releasing the feature
|
|
8090
|
-
|
|
8091
|
-
|
|
8092
|
-
|
|
8093
|
-
|
|
8195
|
+
regionalMetadata.token_endpoint =
|
|
8196
|
+
Authority.buildRegionalAuthorityString(regionalMetadata.token_endpoint, azureRegion, Constants.REGIONAL_AUTH_NON_MSI_QUERY_STRING);
|
|
8197
|
+
if (regionalMetadata.end_session_endpoint) {
|
|
8198
|
+
regionalMetadata.end_session_endpoint =
|
|
8199
|
+
Authority.buildRegionalAuthorityString(regionalMetadata.end_session_endpoint, azureRegion);
|
|
8094
8200
|
}
|
|
8095
|
-
return
|
|
8201
|
+
return regionalMetadata;
|
|
8096
8202
|
}
|
|
8097
8203
|
/**
|
|
8098
8204
|
* Transform CIAM_AUTHORIY as per the below rules:
|
|
@@ -8104,11 +8210,14 @@ class Authority {
|
|
|
8104
8210
|
* @param authority
|
|
8105
8211
|
*/
|
|
8106
8212
|
static transformCIAMAuthority(authority) {
|
|
8107
|
-
let ciamAuthority = authority.endsWith(Constants.FORWARD_SLASH)
|
|
8213
|
+
let ciamAuthority = authority.endsWith(Constants.FORWARD_SLASH)
|
|
8214
|
+
? authority
|
|
8215
|
+
: `${authority}${Constants.FORWARD_SLASH}`;
|
|
8108
8216
|
const authorityUrl = new UrlString(authority);
|
|
8109
8217
|
const authorityUrlComponents = authorityUrl.getUrlComponents();
|
|
8110
8218
|
// check if transformation is needed
|
|
8111
|
-
if (authorityUrlComponents.PathSegments.length === 0 &&
|
|
8219
|
+
if (authorityUrlComponents.PathSegments.length === 0 &&
|
|
8220
|
+
authorityUrlComponents.HostNameAndPort.endsWith(Constants.CIAM_AUTH_URL)) {
|
|
8112
8221
|
const tenantIdOrDomain = authorityUrlComponents.HostNameAndPort.split(".")[0];
|
|
8113
8222
|
ciamAuthority = `${ciamAuthority}${tenantIdOrDomain}${Constants.AAD_TENANT_DOMAIN_SUFFIX}`;
|
|
8114
8223
|
}
|
|
@@ -8116,15 +8225,15 @@ class Authority {
|
|
|
8116
8225
|
}
|
|
8117
8226
|
}
|
|
8118
8227
|
// Reserved tenant domain names that will not be replaced with tenant id
|
|
8119
|
-
Authority.reservedTenantDomains =
|
|
8228
|
+
Authority.reservedTenantDomains = new Set([
|
|
8120
8229
|
"{tenant}",
|
|
8121
8230
|
"{tenantid}",
|
|
8122
8231
|
AADAuthorityConstants.COMMON,
|
|
8123
8232
|
AADAuthorityConstants.CONSUMERS,
|
|
8124
|
-
AADAuthorityConstants.ORGANIZATIONS
|
|
8125
|
-
])
|
|
8233
|
+
AADAuthorityConstants.ORGANIZATIONS,
|
|
8234
|
+
]);
|
|
8126
8235
|
|
|
8127
|
-
/*! @azure/msal-common v14.0.0
|
|
8236
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
8128
8237
|
|
|
8129
8238
|
/*
|
|
8130
8239
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8174,7 +8283,7 @@ class AuthorityFactory {
|
|
|
8174
8283
|
}
|
|
8175
8284
|
}
|
|
8176
8285
|
|
|
8177
|
-
/*! @azure/msal-common v14.0.0
|
|
8286
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
8178
8287
|
|
|
8179
8288
|
/*
|
|
8180
8289
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8204,7 +8313,7 @@ class ServerTelemetryEntity {
|
|
|
8204
8313
|
}
|
|
8205
8314
|
}
|
|
8206
8315
|
|
|
8207
|
-
/*! @azure/msal-common v14.0.0
|
|
8316
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
8208
8317
|
|
|
8209
8318
|
/*
|
|
8210
8319
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8230,7 +8339,7 @@ class ThrottlingEntity {
|
|
|
8230
8339
|
}
|
|
8231
8340
|
}
|
|
8232
8341
|
|
|
8233
|
-
/*! @azure/msal-common v14.0.0
|
|
8342
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
8234
8343
|
|
|
8235
8344
|
/*
|
|
8236
8345
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8247,7 +8356,7 @@ const StubbedNetworkModule = {
|
|
|
8247
8356
|
},
|
|
8248
8357
|
};
|
|
8249
8358
|
|
|
8250
|
-
/*! @azure/msal-common v14.0.0
|
|
8359
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
8251
8360
|
|
|
8252
8361
|
/*
|
|
8253
8362
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8289,7 +8398,7 @@ class JoseHeaderError extends AuthError {
|
|
|
8289
8398
|
}
|
|
8290
8399
|
}
|
|
8291
8400
|
|
|
8292
|
-
/*! @azure/msal-common v14.0.0
|
|
8401
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
8293
8402
|
|
|
8294
8403
|
/*
|
|
8295
8404
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8328,7 +8437,7 @@ class JoseHeader {
|
|
|
8328
8437
|
}
|
|
8329
8438
|
}
|
|
8330
8439
|
|
|
8331
|
-
/*! @azure/msal-common v14.0.0
|
|
8440
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
8332
8441
|
|
|
8333
8442
|
/*
|
|
8334
8443
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8386,7 +8495,7 @@ class AuthenticationHeaderParser {
|
|
|
8386
8495
|
}
|
|
8387
8496
|
}
|
|
8388
8497
|
|
|
8389
|
-
/*! @azure/msal-common v14.0.0
|
|
8498
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
8390
8499
|
|
|
8391
8500
|
/*
|
|
8392
8501
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8585,7 +8694,7 @@ class ServerTelemetryManager {
|
|
|
8585
8694
|
}
|
|
8586
8695
|
}
|
|
8587
8696
|
|
|
8588
|
-
/*! @azure/msal-common v14.0.0
|
|
8697
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
8589
8698
|
|
|
8590
8699
|
/*
|
|
8591
8700
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8602,8 +8711,10 @@ class PerformanceClient {
|
|
|
8602
8711
|
* @param {Logger} logger Logger used by the application
|
|
8603
8712
|
* @param {string} libraryName Name of the library
|
|
8604
8713
|
* @param {string} libraryVersion Version of the library
|
|
8714
|
+
* @param {ApplicationTelemetry} applicationTelemetry application name and version
|
|
8715
|
+
* @param {Set<String>} intFields integer fields to be truncated
|
|
8605
8716
|
*/
|
|
8606
|
-
constructor(clientId, authority, logger, libraryName, libraryVersion, applicationTelemetry) {
|
|
8717
|
+
constructor(clientId, authority, logger, libraryName, libraryVersion, applicationTelemetry, intFields) {
|
|
8607
8718
|
this.authority = authority;
|
|
8608
8719
|
this.libraryName = libraryName;
|
|
8609
8720
|
this.libraryVersion = libraryVersion;
|
|
@@ -8614,6 +8725,10 @@ class PerformanceClient {
|
|
|
8614
8725
|
this.eventsByCorrelationId = new Map();
|
|
8615
8726
|
this.queueMeasurements = new Map();
|
|
8616
8727
|
this.preQueueTimeByCorrelationId = new Map();
|
|
8728
|
+
this.intFields = intFields || new Set();
|
|
8729
|
+
for (const item of IntFields) {
|
|
8730
|
+
this.intFields.add(item);
|
|
8731
|
+
}
|
|
8617
8732
|
}
|
|
8618
8733
|
/**
|
|
8619
8734
|
* Starts and returns an platform-specific implementation of IPerformanceMeasurement.
|
|
@@ -8628,13 +8743,6 @@ class PerformanceClient {
|
|
|
8628
8743
|
) {
|
|
8629
8744
|
return {};
|
|
8630
8745
|
}
|
|
8631
|
-
/**
|
|
8632
|
-
* Get integral fields.
|
|
8633
|
-
* Override to change the set.
|
|
8634
|
-
*/
|
|
8635
|
-
getIntFields() {
|
|
8636
|
-
return IntFields;
|
|
8637
|
-
}
|
|
8638
8746
|
/**
|
|
8639
8747
|
* Gets map of pre-queue times by correlation Id
|
|
8640
8748
|
*
|
|
@@ -8752,7 +8860,7 @@ class PerformanceClient {
|
|
|
8752
8860
|
this.cacheEventByCorrelationId(inProgressEvent);
|
|
8753
8861
|
// Return the event and functions the caller can use to properly end/flush the measurement
|
|
8754
8862
|
return {
|
|
8755
|
-
|
|
8863
|
+
end: (event) => {
|
|
8756
8864
|
return this.endMeasurement({
|
|
8757
8865
|
// Initial set of event properties
|
|
8758
8866
|
...inProgressEvent,
|
|
@@ -8760,14 +8868,14 @@ class PerformanceClient {
|
|
|
8760
8868
|
...event,
|
|
8761
8869
|
}, performanceMeasurement);
|
|
8762
8870
|
},
|
|
8763
|
-
|
|
8871
|
+
discard: () => {
|
|
8764
8872
|
return this.discardMeasurements(inProgressEvent.correlationId);
|
|
8765
8873
|
},
|
|
8766
|
-
|
|
8767
|
-
return this.
|
|
8874
|
+
add: (fields) => {
|
|
8875
|
+
return this.addFields(fields, inProgressEvent.correlationId);
|
|
8768
8876
|
},
|
|
8769
|
-
increment: (
|
|
8770
|
-
return this.
|
|
8877
|
+
increment: (fields) => {
|
|
8878
|
+
return this.incrementFields(fields, inProgressEvent.correlationId);
|
|
8771
8879
|
},
|
|
8772
8880
|
measurement: performanceMeasurement,
|
|
8773
8881
|
event: inProgressEvent,
|
|
@@ -8832,7 +8940,7 @@ class PerformanceClient {
|
|
|
8832
8940
|
status: PerformanceEventStatus.Completed,
|
|
8833
8941
|
incompleteSubsCount,
|
|
8834
8942
|
};
|
|
8835
|
-
this.truncateIntegralFields(finalEvent
|
|
8943
|
+
this.truncateIntegralFields(finalEvent);
|
|
8836
8944
|
this.emitEvents([finalEvent], event.correlationId);
|
|
8837
8945
|
return finalEvent;
|
|
8838
8946
|
}
|
|
@@ -8841,7 +8949,7 @@ class PerformanceClient {
|
|
|
8841
8949
|
* @param fields
|
|
8842
8950
|
* @param correlationId
|
|
8843
8951
|
*/
|
|
8844
|
-
|
|
8952
|
+
addFields(fields, correlationId) {
|
|
8845
8953
|
this.logger.trace("PerformanceClient: Updating static fields");
|
|
8846
8954
|
const event = this.eventsByCorrelationId.get(correlationId);
|
|
8847
8955
|
if (event) {
|
|
@@ -8856,18 +8964,21 @@ class PerformanceClient {
|
|
|
8856
8964
|
}
|
|
8857
8965
|
/**
|
|
8858
8966
|
* Increment counters to be emitted when the measurements are flushed
|
|
8859
|
-
* @param
|
|
8967
|
+
* @param fields {string[]}
|
|
8860
8968
|
* @param correlationId {string} correlation identifier
|
|
8861
8969
|
*/
|
|
8862
|
-
|
|
8970
|
+
incrementFields(fields, correlationId) {
|
|
8863
8971
|
this.logger.trace("PerformanceClient: Updating counters");
|
|
8864
8972
|
const event = this.eventsByCorrelationId.get(correlationId);
|
|
8865
8973
|
if (event) {
|
|
8866
|
-
for (const counter in
|
|
8974
|
+
for (const counter in fields) {
|
|
8867
8975
|
if (!event.hasOwnProperty(counter)) {
|
|
8868
8976
|
event[counter] = 0;
|
|
8869
8977
|
}
|
|
8870
|
-
event[counter]
|
|
8978
|
+
else if (isNaN(Number(event[counter]))) {
|
|
8979
|
+
return;
|
|
8980
|
+
}
|
|
8981
|
+
event[counter] += fields[counter];
|
|
8871
8982
|
}
|
|
8872
8983
|
}
|
|
8873
8984
|
else {
|
|
@@ -8985,8 +9096,8 @@ class PerformanceClient {
|
|
|
8985
9096
|
* @param {PerformanceEvent} event performance event to update.
|
|
8986
9097
|
* @param {Set<string>} intFields integral fields.
|
|
8987
9098
|
*/
|
|
8988
|
-
truncateIntegralFields(event
|
|
8989
|
-
intFields.forEach((key) => {
|
|
9099
|
+
truncateIntegralFields(event) {
|
|
9100
|
+
this.intFields.forEach((key) => {
|
|
8990
9101
|
if (key in event && typeof event[key] === "number") {
|
|
8991
9102
|
event[key] = Math.floor(event[key]);
|
|
8992
9103
|
}
|
|
@@ -8994,16 +9105,22 @@ class PerformanceClient {
|
|
|
8994
9105
|
}
|
|
8995
9106
|
}
|
|
8996
9107
|
|
|
8997
|
-
/*! @azure/msal-common v14.0.0
|
|
9108
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
8998
9109
|
|
|
8999
9110
|
/*
|
|
9000
9111
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
9001
9112
|
* Licensed under the MIT License.
|
|
9002
9113
|
*/
|
|
9003
9114
|
class StubPerformanceMeasurement {
|
|
9004
|
-
startMeasurement() {
|
|
9005
|
-
|
|
9006
|
-
|
|
9115
|
+
startMeasurement() {
|
|
9116
|
+
return;
|
|
9117
|
+
}
|
|
9118
|
+
endMeasurement() {
|
|
9119
|
+
return;
|
|
9120
|
+
}
|
|
9121
|
+
flushMeasurement() {
|
|
9122
|
+
return null;
|
|
9123
|
+
}
|
|
9007
9124
|
}
|
|
9008
9125
|
class StubPerformanceClient extends PerformanceClient {
|
|
9009
9126
|
generateId() {
|
|
@@ -9015,8 +9132,36 @@ class StubPerformanceClient extends PerformanceClient {
|
|
|
9015
9132
|
calculateQueuedTime() {
|
|
9016
9133
|
return 0;
|
|
9017
9134
|
}
|
|
9018
|
-
addQueueMeasurement() {
|
|
9019
|
-
|
|
9135
|
+
addQueueMeasurement() {
|
|
9136
|
+
return;
|
|
9137
|
+
}
|
|
9138
|
+
setPreQueueTime() {
|
|
9139
|
+
return;
|
|
9140
|
+
}
|
|
9141
|
+
endMeasurement() {
|
|
9142
|
+
return null;
|
|
9143
|
+
}
|
|
9144
|
+
discardMeasurements() {
|
|
9145
|
+
return;
|
|
9146
|
+
}
|
|
9147
|
+
removePerformanceCallback() {
|
|
9148
|
+
return true;
|
|
9149
|
+
}
|
|
9150
|
+
addPerformanceCallback() {
|
|
9151
|
+
return "";
|
|
9152
|
+
}
|
|
9153
|
+
emitEvents() {
|
|
9154
|
+
return;
|
|
9155
|
+
}
|
|
9156
|
+
addFields() {
|
|
9157
|
+
return;
|
|
9158
|
+
}
|
|
9159
|
+
incrementFields() {
|
|
9160
|
+
return;
|
|
9161
|
+
}
|
|
9162
|
+
cacheEventByCorrelationId() {
|
|
9163
|
+
return;
|
|
9164
|
+
}
|
|
9020
9165
|
}
|
|
9021
9166
|
|
|
9022
9167
|
/*
|
|
@@ -9199,9 +9344,9 @@ const BrowserAuthErrorMessage = {
|
|
|
9199
9344
|
code: "native_connection_not_established",
|
|
9200
9345
|
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.",
|
|
9201
9346
|
},
|
|
9202
|
-
|
|
9203
|
-
code: "
|
|
9204
|
-
desc: "You must call and await the initialize function before attempting to call any other MSAL API
|
|
9347
|
+
uninitializedPublicClientApplication: {
|
|
9348
|
+
code: "uninitialized_public_client_application",
|
|
9349
|
+
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.",
|
|
9205
9350
|
},
|
|
9206
9351
|
nativePromptNotSupported: {
|
|
9207
9352
|
code: "native_prompt_not_supported",
|
|
@@ -9491,8 +9636,8 @@ class BrowserAuthError extends AuthError {
|
|
|
9491
9636
|
/**
|
|
9492
9637
|
* Create an error thrown when the initialize function hasn't been called
|
|
9493
9638
|
*/
|
|
9494
|
-
static
|
|
9495
|
-
return new BrowserAuthError(BrowserAuthErrorMessage.
|
|
9639
|
+
static createUninitializedPublicClientApplication() {
|
|
9640
|
+
return new BrowserAuthError(BrowserAuthErrorMessage.uninitializedPublicClientApplication.code, BrowserAuthErrorMessage.uninitializedPublicClientApplication.desc);
|
|
9496
9641
|
}
|
|
9497
9642
|
/**
|
|
9498
9643
|
* 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
|
|
@@ -11173,6 +11318,23 @@ class BrowserCacheManager extends CacheManager {
|
|
|
11173
11318
|
setRedirectRequestContext(value) {
|
|
11174
11319
|
this.setTemporaryCache(TemporaryCacheKeys.REDIRECT_CONTEXT, value, true);
|
|
11175
11320
|
}
|
|
11321
|
+
/**
|
|
11322
|
+
* Builds credential entities from AuthenticationResult object and saves the resulting credentials to the cache
|
|
11323
|
+
* @param result
|
|
11324
|
+
* @param request
|
|
11325
|
+
*/
|
|
11326
|
+
async hydrateCache(result, request) {
|
|
11327
|
+
const idTokenEntity = IdTokenEntity.createIdTokenEntity(result.account?.homeAccountId, result.account?.environment, result.idToken, this.clientId, result.tenantId);
|
|
11328
|
+
let claimsHash;
|
|
11329
|
+
if (request.claims) {
|
|
11330
|
+
claimsHash = await this.cryptoImpl.hashString(request.claims);
|
|
11331
|
+
}
|
|
11332
|
+
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
|
|
11333
|
+
result.tokenType, undefined, // userAssertionHash
|
|
11334
|
+
request.sshKid, request.claims, claimsHash);
|
|
11335
|
+
const cacheRecord = new CacheRecord(undefined, idTokenEntity, accessTokenEntity);
|
|
11336
|
+
return this.saveCacheRecord(cacheRecord);
|
|
11337
|
+
}
|
|
11176
11338
|
}
|
|
11177
11339
|
const DEFAULT_BROWSER_CACHE_MANAGER = (clientId, logger) => {
|
|
11178
11340
|
const cacheOptions = {
|
|
@@ -11181,13 +11343,14 @@ const DEFAULT_BROWSER_CACHE_MANAGER = (clientId, logger) => {
|
|
|
11181
11343
|
storeAuthStateInCookie: false,
|
|
11182
11344
|
secureCookies: false,
|
|
11183
11345
|
cacheMigrationEnabled: false,
|
|
11346
|
+
claimsBasedCachingEnabled: false,
|
|
11184
11347
|
};
|
|
11185
11348
|
return new BrowserCacheManager(clientId, cacheOptions, DEFAULT_CRYPTO_IMPLEMENTATION, logger);
|
|
11186
11349
|
};
|
|
11187
11350
|
|
|
11188
11351
|
/* eslint-disable header/header */
|
|
11189
11352
|
const name = "@azure/msal-browser";
|
|
11190
|
-
const version = "3.0.0
|
|
11353
|
+
const version = "3.0.0";
|
|
11191
11354
|
|
|
11192
11355
|
/*
|
|
11193
11356
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -11523,13 +11686,12 @@ class BrowserUtils {
|
|
|
11523
11686
|
}
|
|
11524
11687
|
}
|
|
11525
11688
|
/**
|
|
11526
|
-
* Throws error if
|
|
11527
|
-
* @param allowNativeBroker
|
|
11689
|
+
* Throws error if initialize hasn't been called
|
|
11528
11690
|
* @param initialized
|
|
11529
11691
|
*/
|
|
11530
|
-
static
|
|
11531
|
-
if (
|
|
11532
|
-
throw BrowserAuthError.
|
|
11692
|
+
static blockAPICallsBeforeInitialize(initialized) {
|
|
11693
|
+
if (!initialized) {
|
|
11694
|
+
throw BrowserAuthError.createUninitializedPublicClientApplication();
|
|
11533
11695
|
}
|
|
11534
11696
|
}
|
|
11535
11697
|
/**
|
|
@@ -11627,8 +11789,11 @@ class BaseInteractionClient {
|
|
|
11627
11789
|
}
|
|
11628
11790
|
this.logger.verbose(`Authentication Scheme set to "${validatedRequest.authenticationScheme}" as configured in Auth request`);
|
|
11629
11791
|
}
|
|
11630
|
-
// Set requested claims hash if claims were requested
|
|
11631
|
-
if (
|
|
11792
|
+
// Set requested claims hash if claims-based caching is enabled and claims were requested
|
|
11793
|
+
if (this.config.cache.claimsBasedCachingEnabled &&
|
|
11794
|
+
request.claims &&
|
|
11795
|
+
// Checks for empty stringified object "{}" which doesn't qualify as requested claims
|
|
11796
|
+
!StringUtils.isEmptyObj(request.claims)) {
|
|
11632
11797
|
validatedRequest.requestedClaimsHash =
|
|
11633
11798
|
await this.browserCrypto.hashString(request.claims);
|
|
11634
11799
|
}
|
|
@@ -11685,6 +11850,7 @@ class BaseInteractionClient {
|
|
|
11685
11850
|
this.logger.verbose("getDiscoveredAuthority called");
|
|
11686
11851
|
const authorityOptions = {
|
|
11687
11852
|
protocolMode: this.config.auth.protocolMode,
|
|
11853
|
+
OIDCOptions: this.config.auth.OIDCOptions,
|
|
11688
11854
|
knownAuthorities: this.config.auth.knownAuthorities,
|
|
11689
11855
|
cloudDiscoveryMetadata: this.config.auth.cloudDiscoveryMetadata,
|
|
11690
11856
|
authorityMetadata: this.config.auth.authorityMetadata,
|
|
@@ -11848,6 +12014,9 @@ class StandardInteractionClient extends BaseInteractionClient {
|
|
|
11848
12014
|
logLevel: logger.logLevel,
|
|
11849
12015
|
correlationId: this.correlationId,
|
|
11850
12016
|
},
|
|
12017
|
+
cacheOptions: {
|
|
12018
|
+
claimsBasedCachingEnabled: this.config.cache.claimsBasedCachingEnabled,
|
|
12019
|
+
},
|
|
11851
12020
|
cryptoInterface: this.browserCrypto,
|
|
11852
12021
|
networkInterface: this.networkClient,
|
|
11853
12022
|
storageInterface: this.browserStorage,
|
|
@@ -11891,6 +12060,7 @@ class StandardInteractionClient extends BaseInteractionClient {
|
|
|
11891
12060
|
const getAuthorityMeasurement = this.performanceClient?.startMeasurement(PerformanceEvents.StandardInteractionClientGetDiscoveredAuthority, this.correlationId);
|
|
11892
12061
|
const authorityOptions = {
|
|
11893
12062
|
protocolMode: this.config.auth.protocolMode,
|
|
12063
|
+
OIDCOptions: this.config.auth.OIDCOptions,
|
|
11894
12064
|
knownAuthorities: this.config.auth.knownAuthorities,
|
|
11895
12065
|
cloudDiscoveryMetadata: this.config.auth.cloudDiscoveryMetadata,
|
|
11896
12066
|
authorityMetadata: this.config.auth.authorityMetadata,
|
|
@@ -11906,13 +12076,13 @@ class StandardInteractionClient extends BaseInteractionClient {
|
|
|
11906
12076
|
this.performanceClient.setPreQueueTime(PerformanceEvents.AuthorityFactoryCreateDiscoveredInstance, this.correlationId);
|
|
11907
12077
|
return await AuthorityFactory.createDiscoveredInstance(builtAuthority, this.config.system.networkClient, this.browserStorage, authorityOptions, this.logger, this.performanceClient, this.correlationId)
|
|
11908
12078
|
.then((result) => {
|
|
11909
|
-
getAuthorityMeasurement.
|
|
12079
|
+
getAuthorityMeasurement.end({
|
|
11910
12080
|
success: true,
|
|
11911
12081
|
});
|
|
11912
12082
|
return result;
|
|
11913
12083
|
})
|
|
11914
12084
|
.catch((error) => {
|
|
11915
|
-
getAuthorityMeasurement.
|
|
12085
|
+
getAuthorityMeasurement.end({
|
|
11916
12086
|
errorCode: error.errorCode,
|
|
11917
12087
|
subErrorCode: error.subError,
|
|
11918
12088
|
success: false,
|
|
@@ -11939,7 +12109,8 @@ class StandardInteractionClient extends BaseInteractionClient {
|
|
|
11939
12109
|
redirectUri: redirectUri,
|
|
11940
12110
|
state: state,
|
|
11941
12111
|
nonce: request.nonce || this.browserCrypto.createNewGuid(),
|
|
11942
|
-
responseMode:
|
|
12112
|
+
responseMode: this.config.auth.OIDCOptions
|
|
12113
|
+
.serverResponseType,
|
|
11943
12114
|
};
|
|
11944
12115
|
const account = request.account || this.browserStorage.getActiveAccount();
|
|
11945
12116
|
if (account) {
|
|
@@ -12051,7 +12222,7 @@ class InteractionHandler {
|
|
|
12051
12222
|
}
|
|
12052
12223
|
// Acquire token with retrieved code.
|
|
12053
12224
|
this.performanceClient.setPreQueueTime(PerformanceEvents.AuthClientAcquireToken, this.authCodeRequest.correlationId);
|
|
12054
|
-
const tokenResponse = await this.authModule.acquireToken(this.authCodeRequest, authCodeResponse);
|
|
12225
|
+
const tokenResponse = (await this.authModule.acquireToken(this.authCodeRequest, authCodeResponse));
|
|
12055
12226
|
this.browserStorage.cleanRequestByState(state);
|
|
12056
12227
|
return tokenResponse;
|
|
12057
12228
|
}
|
|
@@ -12199,7 +12370,7 @@ class RedirectHandler extends InteractionHandler {
|
|
|
12199
12370
|
}
|
|
12200
12371
|
}
|
|
12201
12372
|
// Acquire token with retrieved code.
|
|
12202
|
-
const tokenResponse = await this.authModule.acquireToken(this.authCodeRequest, authCodeResponse);
|
|
12373
|
+
const tokenResponse = (await this.authModule.acquireToken(this.authCodeRequest, authCodeResponse));
|
|
12203
12374
|
this.browserStorage.cleanRequestByState(state);
|
|
12204
12375
|
return tokenResponse;
|
|
12205
12376
|
}
|
|
@@ -12234,7 +12405,7 @@ const EventType = {
|
|
|
12234
12405
|
LOGOUT_SUCCESS: "msal:logoutSuccess",
|
|
12235
12406
|
LOGOUT_FAILURE: "msal:logoutFailure",
|
|
12236
12407
|
LOGOUT_END: "msal:logoutEnd",
|
|
12237
|
-
RESTORE_FROM_BFCACHE: "msal:restoreFromBFCache"
|
|
12408
|
+
RESTORE_FROM_BFCACHE: "msal:restoreFromBFCache",
|
|
12238
12409
|
};
|
|
12239
12410
|
|
|
12240
12411
|
/*
|
|
@@ -12347,8 +12518,8 @@ class SilentCacheClient extends StandardInteractionClient {
|
|
|
12347
12518
|
const silentAuthClient = await this.createSilentFlowClient(serverTelemetryManager, silentRequest.authority, silentRequest.azureCloudOptions);
|
|
12348
12519
|
this.logger.verbose("Silent auth client created");
|
|
12349
12520
|
try {
|
|
12350
|
-
const cachedToken = await silentAuthClient.acquireCachedToken(silentRequest);
|
|
12351
|
-
acquireTokenMeasurement.
|
|
12521
|
+
const cachedToken = (await silentAuthClient.acquireCachedToken(silentRequest));
|
|
12522
|
+
acquireTokenMeasurement.end({
|
|
12352
12523
|
success: true,
|
|
12353
12524
|
fromCache: true,
|
|
12354
12525
|
});
|
|
@@ -12360,7 +12531,7 @@ class SilentCacheClient extends StandardInteractionClient {
|
|
|
12360
12531
|
BrowserAuthErrorMessage.signingKeyNotFoundInStorage.code) {
|
|
12361
12532
|
this.logger.verbose("Signing keypair for bound access token not found. Refreshing bound access token and generating a new crypto keypair.");
|
|
12362
12533
|
}
|
|
12363
|
-
acquireTokenMeasurement.
|
|
12534
|
+
acquireTokenMeasurement.end({
|
|
12364
12535
|
errorCode: (error instanceof AuthError && error.errorCode) ||
|
|
12365
12536
|
undefined,
|
|
12366
12537
|
subErrorCode: (error instanceof AuthError && error.subError) || undefined,
|
|
@@ -12392,7 +12563,7 @@ class SilentCacheClient extends StandardInteractionClient {
|
|
|
12392
12563
|
this.performanceClient.setPreQueueTime(PerformanceEvents.InitializeBaseRequest, this.correlationId);
|
|
12393
12564
|
return {
|
|
12394
12565
|
...request,
|
|
12395
|
-
...await this.initializeBaseRequest(request, account),
|
|
12566
|
+
...(await this.initializeBaseRequest(request, account)),
|
|
12396
12567
|
account: account,
|
|
12397
12568
|
forceRefresh: request.forceRefresh || false,
|
|
12398
12569
|
};
|
|
@@ -12426,7 +12597,7 @@ class NativeInteractionClient extends BaseInteractionClient {
|
|
|
12426
12597
|
// check if the tokens can be retrieved from internal cache
|
|
12427
12598
|
try {
|
|
12428
12599
|
const result = await this.acquireTokensFromCache(this.accountId, nativeRequest);
|
|
12429
|
-
nativeATMeasurement.
|
|
12600
|
+
nativeATMeasurement.end({
|
|
12430
12601
|
success: true,
|
|
12431
12602
|
isNativeBroker: false,
|
|
12432
12603
|
fromCache: true,
|
|
@@ -12446,7 +12617,7 @@ class NativeInteractionClient extends BaseInteractionClient {
|
|
|
12446
12617
|
const validatedResponse = this.validateNativeResponse(response);
|
|
12447
12618
|
return this.handleNativeResponse(validatedResponse, nativeRequest, reqTimestamp)
|
|
12448
12619
|
.then((result) => {
|
|
12449
|
-
nativeATMeasurement.
|
|
12620
|
+
nativeATMeasurement.end({
|
|
12450
12621
|
success: true,
|
|
12451
12622
|
isNativeBroker: true,
|
|
12452
12623
|
requestId: result.requestId,
|
|
@@ -12454,7 +12625,7 @@ class NativeInteractionClient extends BaseInteractionClient {
|
|
|
12454
12625
|
return result;
|
|
12455
12626
|
})
|
|
12456
12627
|
.catch((error) => {
|
|
12457
|
-
nativeATMeasurement.
|
|
12628
|
+
nativeATMeasurement.end({
|
|
12458
12629
|
success: false,
|
|
12459
12630
|
errorCode: error.errorCode,
|
|
12460
12631
|
subErrorCode: error.subError,
|
|
@@ -12500,7 +12671,10 @@ class NativeInteractionClient extends BaseInteractionClient {
|
|
|
12500
12671
|
try {
|
|
12501
12672
|
const silentRequest = this.createSilentCacheRequest(request, account);
|
|
12502
12673
|
const result = await this.silentCacheClient.acquireToken(silentRequest);
|
|
12503
|
-
return
|
|
12674
|
+
return {
|
|
12675
|
+
...result,
|
|
12676
|
+
account,
|
|
12677
|
+
};
|
|
12504
12678
|
}
|
|
12505
12679
|
catch (e) {
|
|
12506
12680
|
throw e;
|
|
@@ -12598,16 +12772,20 @@ class NativeInteractionClient extends BaseInteractionClient {
|
|
|
12598
12772
|
}
|
|
12599
12773
|
// Get the preferred_cache domain for the given authority
|
|
12600
12774
|
const authority = await this.getDiscoveredAuthority(request.authority);
|
|
12601
|
-
const authorityPreferredCache = authority.getPreferredCache();
|
|
12602
12775
|
// generate identifiers
|
|
12603
12776
|
const idTokenObj = this.createIdTokenObj(response);
|
|
12604
12777
|
const homeAccountIdentifier = this.createHomeAccountIdentifier(response, idTokenObj);
|
|
12605
|
-
const accountEntity =
|
|
12778
|
+
const accountEntity = AccountEntity.createAccount({
|
|
12779
|
+
homeAccountId: homeAccountIdentifier,
|
|
12780
|
+
idTokenClaims: idTokenObj.claims,
|
|
12781
|
+
clientInfo: response.client_info,
|
|
12782
|
+
nativeAccountId: response.account.id,
|
|
12783
|
+
}, authority);
|
|
12606
12784
|
// generate authenticationResult
|
|
12607
12785
|
const result = await this.generateAuthenticationResult(response, request, idTokenObj, accountEntity, authority.canonicalAuthority, reqTimestamp);
|
|
12608
12786
|
// cache accounts and tokens in the appropriate storage
|
|
12609
12787
|
this.cacheAccount(accountEntity);
|
|
12610
|
-
this.cacheNativeTokens(response, request, homeAccountIdentifier,
|
|
12788
|
+
this.cacheNativeTokens(response, request, homeAccountIdentifier, idTokenObj, result.accessToken, result.tenantId, reqTimestamp);
|
|
12611
12789
|
return result;
|
|
12612
12790
|
}
|
|
12613
12791
|
/**
|
|
@@ -12626,20 +12804,9 @@ class NativeInteractionClient extends BaseInteractionClient {
|
|
|
12626
12804
|
*/
|
|
12627
12805
|
createHomeAccountIdentifier(response, idTokenObj) {
|
|
12628
12806
|
// Save account in browser storage
|
|
12629
|
-
const homeAccountIdentifier = AccountEntity.generateHomeAccountId(response.client_info || Constants.EMPTY_STRING, AuthorityType.Default, this.logger, this.browserCrypto, idTokenObj);
|
|
12807
|
+
const homeAccountIdentifier = AccountEntity.generateHomeAccountId(response.client_info || Constants.EMPTY_STRING, AuthorityType.Default, this.logger, this.browserCrypto, idTokenObj.claims);
|
|
12630
12808
|
return homeAccountIdentifier;
|
|
12631
12809
|
}
|
|
12632
|
-
/**
|
|
12633
|
-
* Creates account entity
|
|
12634
|
-
* @param response
|
|
12635
|
-
* @param homeAccountIdentifier
|
|
12636
|
-
* @param idTokenObj
|
|
12637
|
-
* @param authority
|
|
12638
|
-
* @returns
|
|
12639
|
-
*/
|
|
12640
|
-
createAccountEntity(response, homeAccountIdentifier, idTokenObj, authority) {
|
|
12641
|
-
return AccountEntity.createAccount(response.client_info, homeAccountIdentifier, idTokenObj, undefined, undefined, undefined, authority, response.account.id);
|
|
12642
|
-
}
|
|
12643
12810
|
/**
|
|
12644
12811
|
* Helper to generate scopes
|
|
12645
12812
|
* @param response
|
|
@@ -12758,7 +12925,7 @@ class NativeInteractionClient extends BaseInteractionClient {
|
|
|
12758
12925
|
* @param tenantId
|
|
12759
12926
|
* @param reqTimestamp
|
|
12760
12927
|
*/
|
|
12761
|
-
cacheNativeTokens(response, request, homeAccountIdentifier,
|
|
12928
|
+
cacheNativeTokens(response, request, homeAccountIdentifier, idTokenObj, responseAccessToken, tenantId, reqTimestamp) {
|
|
12762
12929
|
const cachedIdToken = IdTokenEntity.createIdTokenEntity(homeAccountIdentifier, request.authority, response.id_token || Constants.EMPTY_STRING, request.clientId, idTokenObj.claims.tid || Constants.EMPTY_STRING);
|
|
12763
12930
|
// cache accessToken in inmemory storage
|
|
12764
12931
|
const expiresIn = request.tokenType === AuthenticationScheme.POP
|
|
@@ -12771,15 +12938,15 @@ class NativeInteractionClient extends BaseInteractionClient {
|
|
|
12771
12938
|
const cachedAccessToken = AccessTokenEntity.createAccessTokenEntity(homeAccountIdentifier, request.authority, responseAccessToken, request.clientId, idTokenObj
|
|
12772
12939
|
? idTokenObj.claims.tid || Constants.EMPTY_STRING
|
|
12773
12940
|
: tenantId, responseScopes.printScopes(), tokenExpirationSeconds, 0, this.browserCrypto);
|
|
12774
|
-
const nativeCacheRecord = new CacheRecord(
|
|
12775
|
-
this.nativeStorageManager.saveCacheRecord(nativeCacheRecord);
|
|
12941
|
+
const nativeCacheRecord = new CacheRecord(undefined, cachedIdToken, cachedAccessToken);
|
|
12942
|
+
this.nativeStorageManager.saveCacheRecord(nativeCacheRecord, request.storeInCache);
|
|
12776
12943
|
}
|
|
12777
12944
|
addTelemetryFromNativeResponse(response) {
|
|
12778
12945
|
const mats = this.getMATSFromResponse(response);
|
|
12779
12946
|
if (!mats) {
|
|
12780
12947
|
return null;
|
|
12781
12948
|
}
|
|
12782
|
-
this.performanceClient.
|
|
12949
|
+
this.performanceClient.addFields({
|
|
12783
12950
|
extensionId: this.nativeMessageHandler.getExtensionId(),
|
|
12784
12951
|
extensionVersion: this.nativeMessageHandler.getExtensionVersion(),
|
|
12785
12952
|
matsBrokerVersion: mats.broker_version,
|
|
@@ -12992,7 +13159,7 @@ class NativeMessageHandler {
|
|
|
12992
13159
|
method: NativeExtensionMethod.HandshakeRequest,
|
|
12993
13160
|
},
|
|
12994
13161
|
};
|
|
12995
|
-
this.handshakeEvent.
|
|
13162
|
+
this.handshakeEvent.add({
|
|
12996
13163
|
extensionId: this.extensionId,
|
|
12997
13164
|
extensionHandshakeTimeoutMs: this.handshakeTimeoutMs,
|
|
12998
13165
|
});
|
|
@@ -13010,7 +13177,7 @@ class NativeMessageHandler {
|
|
|
13010
13177
|
window.removeEventListener("message", this.windowListener, false);
|
|
13011
13178
|
this.messageChannel.port1.close();
|
|
13012
13179
|
this.messageChannel.port2.close();
|
|
13013
|
-
this.handshakeEvent.
|
|
13180
|
+
this.handshakeEvent.end({
|
|
13014
13181
|
extensionHandshakeTimedOut: true,
|
|
13015
13182
|
success: false,
|
|
13016
13183
|
});
|
|
@@ -13055,7 +13222,7 @@ class NativeMessageHandler {
|
|
|
13055
13222
|
this.messageChannel.port1.close();
|
|
13056
13223
|
this.messageChannel.port2.close();
|
|
13057
13224
|
window.removeEventListener("message", this.windowListener, false);
|
|
13058
|
-
this.handshakeEvent.
|
|
13225
|
+
this.handshakeEvent.end({
|
|
13059
13226
|
success: false,
|
|
13060
13227
|
extensionInstalled: false,
|
|
13061
13228
|
});
|
|
@@ -13107,7 +13274,7 @@ class NativeMessageHandler {
|
|
|
13107
13274
|
this.extensionId = request.extensionId;
|
|
13108
13275
|
this.extensionVersion = request.body.version;
|
|
13109
13276
|
this.logger.verbose(`NativeMessageHandler - Received HandshakeResponse from extension: ${this.extensionId}`);
|
|
13110
|
-
this.handshakeEvent.
|
|
13277
|
+
this.handshakeEvent.end({
|
|
13111
13278
|
extensionInstalled: true,
|
|
13112
13279
|
success: true,
|
|
13113
13280
|
});
|
|
@@ -13416,6 +13583,18 @@ class RedirectClient extends StandardInteractionClient {
|
|
|
13416
13583
|
this.performanceClient.setPreQueueTime(PerformanceEvents.StandardInteractionClientCreateAuthCodeClient, validLogoutRequest.correlationId);
|
|
13417
13584
|
const authClient = await this.createAuthCodeClient(serverTelemetryManager, logoutRequest && logoutRequest.authority);
|
|
13418
13585
|
this.logger.verbose("Auth code client created");
|
|
13586
|
+
if (authClient.authority.protocolMode === ProtocolMode.OIDC) {
|
|
13587
|
+
try {
|
|
13588
|
+
authClient.authority.endSessionEndpoint;
|
|
13589
|
+
}
|
|
13590
|
+
catch {
|
|
13591
|
+
if (validLogoutRequest.account?.homeAccountId) {
|
|
13592
|
+
this.browserStorage.removeAccount(validLogoutRequest.account?.homeAccountId);
|
|
13593
|
+
this.eventHandler.emitEvent(EventType.LOGOUT_SUCCESS, exports.InteractionType.Redirect, validLogoutRequest);
|
|
13594
|
+
return;
|
|
13595
|
+
}
|
|
13596
|
+
}
|
|
13597
|
+
}
|
|
13419
13598
|
// Create logout string and navigate user window to logout.
|
|
13420
13599
|
const logoutUri = authClient.getLogoutUri(validLogoutRequest);
|
|
13421
13600
|
this.eventHandler.emitEvent(EventType.LOGOUT_SUCCESS, exports.InteractionType.Redirect, validLogoutRequest);
|
|
@@ -13590,7 +13769,7 @@ class PopupClient extends StandardInteractionClient {
|
|
|
13590
13769
|
this.logger.verbose("Account id found in hash, calling WAM for token");
|
|
13591
13770
|
// end measurement for server call with native brokering enabled
|
|
13592
13771
|
if (fetchNativeAccountIdMeasurement) {
|
|
13593
|
-
fetchNativeAccountIdMeasurement.
|
|
13772
|
+
fetchNativeAccountIdMeasurement.end({
|
|
13594
13773
|
success: true,
|
|
13595
13774
|
isNativeBroker: true,
|
|
13596
13775
|
});
|
|
@@ -13647,6 +13826,30 @@ class PopupClient extends StandardInteractionClient {
|
|
|
13647
13826
|
this.performanceClient.setPreQueueTime(PerformanceEvents.StandardInteractionClientCreateAuthCodeClient, validRequest.correlationId);
|
|
13648
13827
|
const authClient = await this.createAuthCodeClient(serverTelemetryManager, requestAuthority);
|
|
13649
13828
|
this.logger.verbose("Auth code client created");
|
|
13829
|
+
try {
|
|
13830
|
+
authClient.authority.endSessionEndpoint;
|
|
13831
|
+
}
|
|
13832
|
+
catch {
|
|
13833
|
+
if (validRequest.account?.homeAccountId &&
|
|
13834
|
+
validRequest.postLogoutRedirectUri &&
|
|
13835
|
+
authClient.authority.protocolMode === ProtocolMode.OIDC) {
|
|
13836
|
+
this.browserStorage.removeAccount(validRequest.account?.homeAccountId);
|
|
13837
|
+
this.eventHandler.emitEvent(EventType.LOGOUT_SUCCESS, exports.InteractionType.Popup, validRequest);
|
|
13838
|
+
if (mainWindowRedirectUri) {
|
|
13839
|
+
const navigationOptions = {
|
|
13840
|
+
apiId: ApiId.logoutPopup,
|
|
13841
|
+
timeout: this.config.system.redirectNavigationTimeout,
|
|
13842
|
+
noHistory: false,
|
|
13843
|
+
};
|
|
13844
|
+
const absoluteUrl = UrlString.getAbsoluteUrl(mainWindowRedirectUri, BrowserUtils.getCurrentUri());
|
|
13845
|
+
await this.navigationClient.navigateInternal(absoluteUrl, navigationOptions);
|
|
13846
|
+
}
|
|
13847
|
+
if (popup) {
|
|
13848
|
+
popup.close();
|
|
13849
|
+
}
|
|
13850
|
+
return;
|
|
13851
|
+
}
|
|
13852
|
+
}
|
|
13650
13853
|
// Create logout string and navigate user window to logout.
|
|
13651
13854
|
const logoutUri = authClient.getLogoutUri(validRequest);
|
|
13652
13855
|
this.eventHandler.emitEvent(EventType.LOGOUT_SUCCESS, exports.InteractionType.Popup, validRequest);
|
|
@@ -13731,7 +13934,7 @@ class PopupClient extends StandardInteractionClient {
|
|
|
13731
13934
|
return;
|
|
13732
13935
|
}
|
|
13733
13936
|
let href = Constants.EMPTY_STRING;
|
|
13734
|
-
let
|
|
13937
|
+
let serverResponseString = Constants.EMPTY_STRING;
|
|
13735
13938
|
try {
|
|
13736
13939
|
/*
|
|
13737
13940
|
* Will throw if cross origin,
|
|
@@ -13739,7 +13942,8 @@ class PopupClient extends StandardInteractionClient {
|
|
|
13739
13942
|
* since we need the interval to keep running while on STS UI.
|
|
13740
13943
|
*/
|
|
13741
13944
|
href = popupWindow.location.href;
|
|
13742
|
-
|
|
13945
|
+
serverResponseString =
|
|
13946
|
+
this.extractServerResponseStringFromPopup(popupWindow, href);
|
|
13743
13947
|
}
|
|
13744
13948
|
catch (e) { }
|
|
13745
13949
|
// Don't process blank pages or cross domain
|
|
@@ -13752,17 +13956,17 @@ class PopupClient extends StandardInteractionClient {
|
|
|
13752
13956
|
* as popup operations can take a long time.
|
|
13753
13957
|
*/
|
|
13754
13958
|
ticks++;
|
|
13755
|
-
if (
|
|
13959
|
+
if (serverResponseString) {
|
|
13756
13960
|
this.logger.verbose("PopupHandler.monitorPopupForHash - found hash in url");
|
|
13757
13961
|
clearInterval(intervalId);
|
|
13758
13962
|
this.cleanPopup(popupWindow);
|
|
13759
|
-
if (UrlString.hashContainsKnownProperties(
|
|
13963
|
+
if (UrlString.hashContainsKnownProperties(serverResponseString)) {
|
|
13760
13964
|
this.logger.verbose("PopupHandler.monitorPopupForHash - hash contains known properties, returning.");
|
|
13761
|
-
resolve(
|
|
13965
|
+
resolve(serverResponseString);
|
|
13762
13966
|
}
|
|
13763
13967
|
else {
|
|
13764
13968
|
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.");
|
|
13765
|
-
this.logger.errorPii(`PopupHandler.monitorPopupForHash - hash found: ${
|
|
13969
|
+
this.logger.errorPii(`PopupHandler.monitorPopupForHash - hash found: ${serverResponseString}`);
|
|
13766
13970
|
reject(BrowserAuthError.createHashDoesNotContainKnownPropertiesError());
|
|
13767
13971
|
}
|
|
13768
13972
|
}
|
|
@@ -13943,6 +14147,20 @@ class PopupClient extends StandardInteractionClient {
|
|
|
13943
14147
|
const homeAccountId = request.account && request.account.homeAccountId;
|
|
13944
14148
|
return `${BrowserConstants.POPUP_NAME_PREFIX}.${this.config.auth.clientId}.${homeAccountId}.${this.correlationId}`;
|
|
13945
14149
|
}
|
|
14150
|
+
/**
|
|
14151
|
+
* Extracts the server response from the popup window
|
|
14152
|
+
*/
|
|
14153
|
+
extractServerResponseStringFromPopup(popupWindow, href) {
|
|
14154
|
+
let serverResponseString;
|
|
14155
|
+
if (this.config.auth.OIDCOptions?.serverResponseType ===
|
|
14156
|
+
ServerResponseType.QUERY) {
|
|
14157
|
+
serverResponseString = UrlString.parseQueryServerResponse(href);
|
|
14158
|
+
}
|
|
14159
|
+
else {
|
|
14160
|
+
serverResponseString = popupWindow.location.hash;
|
|
14161
|
+
}
|
|
14162
|
+
return serverResponseString;
|
|
14163
|
+
}
|
|
13946
14164
|
}
|
|
13947
14165
|
|
|
13948
14166
|
/*
|
|
@@ -14017,6 +14235,14 @@ function buildConfiguration({ auth: userInputAuth, cache: userInputCache, system
|
|
|
14017
14235
|
navigateToLoginRequestUrl: true,
|
|
14018
14236
|
clientCapabilities: [],
|
|
14019
14237
|
protocolMode: ProtocolMode.AAD,
|
|
14238
|
+
OIDCOptions: {
|
|
14239
|
+
serverResponseType: ServerResponseType.FRAGMENT,
|
|
14240
|
+
defaultScopes: [
|
|
14241
|
+
Constants.OPENID_SCOPE,
|
|
14242
|
+
Constants.PROFILE_SCOPE,
|
|
14243
|
+
Constants.OFFLINE_ACCESS_SCOPE,
|
|
14244
|
+
],
|
|
14245
|
+
},
|
|
14020
14246
|
azureCloudOptions: {
|
|
14021
14247
|
azureCloudInstance: AzureCloudInstance.None,
|
|
14022
14248
|
tenant: Constants.EMPTY_STRING,
|
|
@@ -14034,6 +14260,7 @@ function buildConfiguration({ auth: userInputAuth, cache: userInputCache, system
|
|
|
14034
14260
|
userInputCache.cacheLocation === BrowserCacheLocation.LocalStorage
|
|
14035
14261
|
? true
|
|
14036
14262
|
: false,
|
|
14263
|
+
claimsBasedCachingEnabled: false,
|
|
14037
14264
|
};
|
|
14038
14265
|
// Default logger options for browser
|
|
14039
14266
|
const DEFAULT_LOGGER_OPTIONS = {
|
|
@@ -14060,10 +14287,10 @@ function buildConfiguration({ auth: userInputAuth, cache: userInputCache, system
|
|
|
14060
14287
|
redirectNavigationTimeout: DEFAULT_REDIRECT_TIMEOUT_MS,
|
|
14061
14288
|
asyncPopups: false,
|
|
14062
14289
|
allowRedirectInIframe: false,
|
|
14063
|
-
allowNativeBroker:
|
|
14290
|
+
allowNativeBroker: false,
|
|
14064
14291
|
nativeBrokerHandshakeTimeout: userInputSystem?.nativeBrokerHandshakeTimeout ||
|
|
14065
14292
|
DEFAULT_NATIVE_BROKER_HANDSHAKE_TIMEOUT_MS,
|
|
14066
|
-
pollIntervalMilliseconds: BrowserConstants.DEFAULT_POLL_INTERVAL_MS
|
|
14293
|
+
pollIntervalMilliseconds: BrowserConstants.DEFAULT_POLL_INTERVAL_MS,
|
|
14067
14294
|
};
|
|
14068
14295
|
const providedSystemOptions = {
|
|
14069
14296
|
...userInputSystem,
|
|
@@ -14074,9 +14301,33 @@ function buildConfiguration({ auth: userInputAuth, cache: userInputCache, system
|
|
|
14074
14301
|
appName: Constants.EMPTY_STRING,
|
|
14075
14302
|
appVersion: Constants.EMPTY_STRING,
|
|
14076
14303
|
},
|
|
14304
|
+
client: new StubPerformanceClient(DEFAULT_AUTH_OPTIONS.clientId, DEFAULT_AUTH_OPTIONS.authority, new Logger(DEFAULT_LOGGER_OPTIONS, name, version), name, version, {
|
|
14305
|
+
appName: Constants.EMPTY_STRING,
|
|
14306
|
+
appVersion: Constants.EMPTY_STRING,
|
|
14307
|
+
}),
|
|
14077
14308
|
};
|
|
14309
|
+
// Throw an error if user has set OIDCOptions without being in OIDC protocol mode
|
|
14310
|
+
if (userInputAuth?.protocolMode !== ProtocolMode.OIDC &&
|
|
14311
|
+
userInputAuth?.OIDCOptions) {
|
|
14312
|
+
// Logger has not been created yet
|
|
14313
|
+
// eslint-disable-next-line no-console
|
|
14314
|
+
console.warn(ClientConfigurationError.createCannotSetOIDCOptionsError());
|
|
14315
|
+
}
|
|
14316
|
+
// Throw an error if user has set allowNativeBroker to true without being in AAD protocol mode
|
|
14317
|
+
if (userInputAuth?.protocolMode &&
|
|
14318
|
+
userInputAuth.protocolMode !== ProtocolMode.AAD &&
|
|
14319
|
+
providedSystemOptions?.allowNativeBroker) {
|
|
14320
|
+
throw ClientConfigurationError.createCannotAllowNativeBrokerError();
|
|
14321
|
+
}
|
|
14078
14322
|
const overlayedConfig = {
|
|
14079
|
-
auth: {
|
|
14323
|
+
auth: {
|
|
14324
|
+
...DEFAULT_AUTH_OPTIONS,
|
|
14325
|
+
...userInputAuth,
|
|
14326
|
+
OIDCOptions: {
|
|
14327
|
+
...DEFAULT_AUTH_OPTIONS.OIDCOptions,
|
|
14328
|
+
...userInputAuth?.OIDCOptions,
|
|
14329
|
+
},
|
|
14330
|
+
},
|
|
14080
14331
|
cache: { ...DEFAULT_CACHE_OPTIONS, ...userInputCache },
|
|
14081
14332
|
system: { ...DEFAULT_BROWSER_SYSTEM_OPTIONS, ...providedSystemOptions },
|
|
14082
14333
|
telemetry: { ...DEFAULT_TELEMETRY_OPTIONS, ...userInputTelemetry },
|
|
@@ -14275,7 +14526,7 @@ class SilentIframeClient extends StandardInteractionClient {
|
|
|
14275
14526
|
if (request.prompt &&
|
|
14276
14527
|
request.prompt !== PromptValue.NONE &&
|
|
14277
14528
|
request.prompt !== PromptValue.NO_SESSION) {
|
|
14278
|
-
acquireTokenMeasurement.
|
|
14529
|
+
acquireTokenMeasurement.end({
|
|
14279
14530
|
success: false,
|
|
14280
14531
|
});
|
|
14281
14532
|
throw BrowserAuthError.createSilentPromptValueError(request.prompt);
|
|
@@ -14295,7 +14546,7 @@ class SilentIframeClient extends StandardInteractionClient {
|
|
|
14295
14546
|
this.logger.verbose("Auth code client created");
|
|
14296
14547
|
this.performanceClient.setPreQueueTime(PerformanceEvents.SilentIframeClientTokenHelper, request.correlationId);
|
|
14297
14548
|
return await this.silentTokenHelper(authClient, silentRequest).then((result) => {
|
|
14298
|
-
acquireTokenMeasurement.
|
|
14549
|
+
acquireTokenMeasurement.end({
|
|
14299
14550
|
success: true,
|
|
14300
14551
|
fromCache: false,
|
|
14301
14552
|
requestId: result.requestId,
|
|
@@ -14309,7 +14560,7 @@ class SilentIframeClient extends StandardInteractionClient {
|
|
|
14309
14560
|
serverTelemetryManager.cacheFailedRequest(e);
|
|
14310
14561
|
}
|
|
14311
14562
|
this.browserStorage.cleanRequestByState(silentRequest.state);
|
|
14312
|
-
acquireTokenMeasurement.
|
|
14563
|
+
acquireTokenMeasurement.end({
|
|
14313
14564
|
errorCode: (e instanceof AuthError && e.errorCode) || undefined,
|
|
14314
14565
|
subErrorCode: (e instanceof AuthError && e.subError) || undefined,
|
|
14315
14566
|
success: false,
|
|
@@ -14389,7 +14640,7 @@ class SilentRefreshClient extends StandardInteractionClient {
|
|
|
14389
14640
|
this.performanceClient.setPreQueueTime(PerformanceEvents.InitializeBaseRequest, request.correlationId);
|
|
14390
14641
|
const silentRequest = {
|
|
14391
14642
|
...request,
|
|
14392
|
-
...await this.initializeBaseRequest(request, request.account)
|
|
14643
|
+
...(await this.initializeBaseRequest(request, request.account)),
|
|
14393
14644
|
};
|
|
14394
14645
|
const acquireTokenMeasurement = this.performanceClient.startMeasurement(PerformanceEvents.SilentRefreshClientAcquireToken, silentRequest.correlationId);
|
|
14395
14646
|
const serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenSilent_silentFlow);
|
|
@@ -14399,8 +14650,9 @@ class SilentRefreshClient extends StandardInteractionClient {
|
|
|
14399
14650
|
this.performanceClient.setPreQueueTime(PerformanceEvents.RefreshTokenClientAcquireTokenByRefreshToken, request.correlationId);
|
|
14400
14651
|
return refreshTokenClient
|
|
14401
14652
|
.acquireTokenByRefreshToken(silentRequest)
|
|
14653
|
+
.then((result) => result)
|
|
14402
14654
|
.then((result) => {
|
|
14403
|
-
acquireTokenMeasurement.
|
|
14655
|
+
acquireTokenMeasurement.end({
|
|
14404
14656
|
success: true,
|
|
14405
14657
|
fromCache: result.fromCache,
|
|
14406
14658
|
requestId: result.requestId,
|
|
@@ -14410,7 +14662,7 @@ class SilentRefreshClient extends StandardInteractionClient {
|
|
|
14410
14662
|
.catch((e) => {
|
|
14411
14663
|
e.setCorrelationId(this.correlationId);
|
|
14412
14664
|
serverTelemetryManager.cacheFailedRequest(e);
|
|
14413
|
-
acquireTokenMeasurement.
|
|
14665
|
+
acquireTokenMeasurement.end({
|
|
14414
14666
|
errorCode: e.errorCode,
|
|
14415
14667
|
subErrorCode: e.subError,
|
|
14416
14668
|
success: false,
|
|
@@ -14756,18 +15008,6 @@ class BrowserStringUtils {
|
|
|
14756
15008
|
}
|
|
14757
15009
|
return aBytes;
|
|
14758
15010
|
}
|
|
14759
|
-
/**
|
|
14760
|
-
* Converst string to ArrayBuffer
|
|
14761
|
-
* @param dataString
|
|
14762
|
-
*/
|
|
14763
|
-
static stringToArrayBuffer(dataString) {
|
|
14764
|
-
const data = new ArrayBuffer(dataString.length);
|
|
14765
|
-
const dataView = new Uint8Array(data);
|
|
14766
|
-
for (let i = 0; i < dataString.length; i++) {
|
|
14767
|
-
dataView[i] = dataString.charCodeAt(i);
|
|
14768
|
-
}
|
|
14769
|
-
return data;
|
|
14770
|
-
}
|
|
14771
15011
|
/**
|
|
14772
15012
|
* Converts Uint8Array to a string
|
|
14773
15013
|
* @param aBytes
|
|
@@ -15600,7 +15840,7 @@ class CryptoOps {
|
|
|
15600
15840
|
requestUri: request.resourceRequestUri,
|
|
15601
15841
|
});
|
|
15602
15842
|
if (publicKeyThumbMeasurement) {
|
|
15603
|
-
publicKeyThumbMeasurement.
|
|
15843
|
+
publicKeyThumbMeasurement.end({
|
|
15604
15844
|
success: true,
|
|
15605
15845
|
});
|
|
15606
15846
|
}
|
|
@@ -15651,12 +15891,12 @@ class CryptoOps {
|
|
|
15651
15891
|
// Form token string
|
|
15652
15892
|
const tokenString = `${encodedShrHeader}.${encodedPayload}`;
|
|
15653
15893
|
// Sign token
|
|
15654
|
-
const tokenBuffer = BrowserStringUtils.
|
|
15894
|
+
const tokenBuffer = BrowserStringUtils.stringToUtf8Arr(tokenString);
|
|
15655
15895
|
const signatureBuffer = await this.browserCrypto.sign(cachedKeyPair.privateKey, tokenBuffer);
|
|
15656
15896
|
const encodedSignature = this.b64Encode.urlEncodeArr(new Uint8Array(signatureBuffer));
|
|
15657
15897
|
const signedJwt = `${tokenString}.${encodedSignature}`;
|
|
15658
15898
|
if (signJwtMeasurement) {
|
|
15659
|
-
signJwtMeasurement.
|
|
15899
|
+
signJwtMeasurement.end({
|
|
15660
15900
|
success: true,
|
|
15661
15901
|
});
|
|
15662
15902
|
}
|
|
@@ -15679,231 +15919,17 @@ CryptoOps.EXTRACTABLE = true;
|
|
|
15679
15919
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
15680
15920
|
* Licensed under the MIT License.
|
|
15681
15921
|
*/
|
|
15682
|
-
|
|
15683
|
-
|
|
15684
|
-
|
|
15685
|
-
this.measureName = BrowserPerformanceMeasurement.makeMeasureName(name, correlationId);
|
|
15686
|
-
this.startMark = BrowserPerformanceMeasurement.makeStartMark(name, correlationId);
|
|
15687
|
-
this.endMark = BrowserPerformanceMeasurement.makeEndMark(name, correlationId);
|
|
15688
|
-
}
|
|
15689
|
-
static makeMeasureName(name, correlationId) {
|
|
15690
|
-
return `msal.measure.${name}.${correlationId}`;
|
|
15691
|
-
}
|
|
15692
|
-
static makeStartMark(name, correlationId) {
|
|
15693
|
-
return `msal.start.${name}.${correlationId}`;
|
|
15694
|
-
}
|
|
15695
|
-
static makeEndMark(name, correlationId) {
|
|
15696
|
-
return `msal.end.${name}.${correlationId}`;
|
|
15697
|
-
}
|
|
15698
|
-
static supportsBrowserPerformance() {
|
|
15699
|
-
return (typeof window !== "undefined" &&
|
|
15700
|
-
typeof window.performance !== "undefined" &&
|
|
15701
|
-
typeof window.performance.mark === "function" &&
|
|
15702
|
-
typeof window.performance.measure === "function" &&
|
|
15703
|
-
typeof window.performance.clearMarks === "function" &&
|
|
15704
|
-
typeof window.performance.clearMeasures === "function" &&
|
|
15705
|
-
typeof window.performance.getEntriesByName === "function");
|
|
15706
|
-
}
|
|
15707
|
-
/**
|
|
15708
|
-
* Flush browser marks and measurements.
|
|
15709
|
-
* @param {string} correlationId
|
|
15710
|
-
* @param {SubMeasurement} measurements
|
|
15711
|
-
*/
|
|
15712
|
-
static flushMeasurements(correlationId, measurements) {
|
|
15713
|
-
if (BrowserPerformanceMeasurement.supportsBrowserPerformance()) {
|
|
15714
|
-
try {
|
|
15715
|
-
measurements.forEach((measurement) => {
|
|
15716
|
-
const measureName = BrowserPerformanceMeasurement.makeMeasureName(measurement.name, correlationId);
|
|
15717
|
-
const entriesForMeasurement = window.performance.getEntriesByName(measureName, "measure");
|
|
15718
|
-
if (entriesForMeasurement.length > 0) {
|
|
15719
|
-
window.performance.clearMeasures(measureName);
|
|
15720
|
-
window.performance.clearMarks(BrowserPerformanceMeasurement.makeStartMark(measureName, correlationId));
|
|
15721
|
-
window.performance.clearMarks(BrowserPerformanceMeasurement.makeEndMark(measureName, correlationId));
|
|
15722
|
-
}
|
|
15723
|
-
});
|
|
15724
|
-
}
|
|
15725
|
-
catch (e) {
|
|
15726
|
-
// Silently catch and return null
|
|
15727
|
-
}
|
|
15728
|
-
}
|
|
15729
|
-
}
|
|
15730
|
-
startMeasurement() {
|
|
15731
|
-
if (BrowserPerformanceMeasurement.supportsBrowserPerformance()) {
|
|
15732
|
-
try {
|
|
15733
|
-
window.performance.mark(this.startMark);
|
|
15734
|
-
}
|
|
15735
|
-
catch (e) {
|
|
15736
|
-
// Silently catch
|
|
15737
|
-
}
|
|
15738
|
-
}
|
|
15739
|
-
}
|
|
15740
|
-
endMeasurement() {
|
|
15741
|
-
if (BrowserPerformanceMeasurement.supportsBrowserPerformance()) {
|
|
15742
|
-
try {
|
|
15743
|
-
window.performance.mark(this.endMark);
|
|
15744
|
-
window.performance.measure(this.measureName, this.startMark, this.endMark);
|
|
15745
|
-
}
|
|
15746
|
-
catch (e) {
|
|
15747
|
-
// Silently catch
|
|
15748
|
-
}
|
|
15749
|
-
}
|
|
15750
|
-
}
|
|
15751
|
-
flushMeasurement() {
|
|
15752
|
-
if (BrowserPerformanceMeasurement.supportsBrowserPerformance()) {
|
|
15753
|
-
try {
|
|
15754
|
-
const entriesForMeasurement = window.performance.getEntriesByName(this.measureName, "measure");
|
|
15755
|
-
if (entriesForMeasurement.length > 0) {
|
|
15756
|
-
const durationMs = entriesForMeasurement[0].duration;
|
|
15757
|
-
window.performance.clearMeasures(this.measureName);
|
|
15758
|
-
window.performance.clearMarks(this.startMark);
|
|
15759
|
-
window.performance.clearMarks(this.endMark);
|
|
15760
|
-
return durationMs;
|
|
15761
|
-
}
|
|
15762
|
-
}
|
|
15763
|
-
catch (e) {
|
|
15764
|
-
// Silently catch and return null
|
|
15765
|
-
}
|
|
15766
|
-
}
|
|
15767
|
-
return null;
|
|
15768
|
-
}
|
|
15769
|
-
}
|
|
15770
|
-
|
|
15771
|
-
/*
|
|
15772
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
15773
|
-
* Licensed under the MIT License.
|
|
15774
|
-
*/
|
|
15775
|
-
class BrowserPerformanceClient extends PerformanceClient {
|
|
15776
|
-
constructor(clientId, authority, logger, libraryName, libraryVersion, applicationTelemetry) {
|
|
15777
|
-
super(clientId, authority, logger, libraryName, libraryVersion, applicationTelemetry);
|
|
15778
|
-
this.browserCrypto = new BrowserCrypto(this.logger);
|
|
15779
|
-
this.guidGenerator = new GuidGenerator(this.browserCrypto);
|
|
15780
|
-
}
|
|
15781
|
-
startPerformanceMeasurement(measureName, correlationId) {
|
|
15782
|
-
return new BrowserPerformanceMeasurement(measureName, correlationId);
|
|
15783
|
-
}
|
|
15784
|
-
generateId() {
|
|
15785
|
-
return this.guidGenerator.generateGuid();
|
|
15786
|
-
}
|
|
15787
|
-
getPageVisibility() {
|
|
15788
|
-
return document.visibilityState?.toString() || null;
|
|
15789
|
-
}
|
|
15790
|
-
deleteIncompleteSubMeasurements(inProgressEvent) {
|
|
15791
|
-
const rootEvent = this.eventsByCorrelationId.get(inProgressEvent.event.correlationId);
|
|
15792
|
-
const isRootEvent = rootEvent && rootEvent.eventId === inProgressEvent.event.eventId;
|
|
15793
|
-
const incompleteMeasurements = [];
|
|
15794
|
-
if (isRootEvent && rootEvent?.incompleteSubMeasurements) {
|
|
15795
|
-
rootEvent.incompleteSubMeasurements.forEach((subMeasurement) => {
|
|
15796
|
-
incompleteMeasurements.push({ ...subMeasurement });
|
|
15797
|
-
});
|
|
15798
|
-
}
|
|
15799
|
-
// Clean up remaining marks for incomplete sub-measurements
|
|
15800
|
-
if (incompleteMeasurements.length > 0) {
|
|
15801
|
-
BrowserPerformanceMeasurement.flushMeasurements(inProgressEvent.event.correlationId, incompleteMeasurements);
|
|
15802
|
-
}
|
|
15803
|
-
}
|
|
15804
|
-
supportsBrowserPerformanceNow() {
|
|
15805
|
-
return (typeof window !== "undefined" &&
|
|
15806
|
-
typeof window.performance !== "undefined" &&
|
|
15807
|
-
typeof window.performance.now === "function");
|
|
15808
|
-
}
|
|
15809
|
-
/**
|
|
15810
|
-
* Starts measuring performance for a given operation. Returns a function that should be used to end the measurement.
|
|
15811
|
-
* Also captures browser page visibilityState.
|
|
15812
|
-
*
|
|
15813
|
-
* @param {PerformanceEvents} measureName
|
|
15814
|
-
* @param {?string} [correlationId]
|
|
15815
|
-
* @returns {((event?: Partial<PerformanceEvent>) => PerformanceEvent| null)}
|
|
15816
|
-
*/
|
|
15817
|
-
startMeasurement(measureName, correlationId) {
|
|
15818
|
-
// Capture page visibilityState and then invoke start/end measurement
|
|
15819
|
-
const startPageVisibility = this.getPageVisibility();
|
|
15820
|
-
const inProgressEvent = super.startMeasurement(measureName, correlationId);
|
|
15821
|
-
return {
|
|
15822
|
-
...inProgressEvent,
|
|
15823
|
-
endMeasurement: (event) => {
|
|
15824
|
-
const res = inProgressEvent.endMeasurement({
|
|
15825
|
-
startPageVisibility,
|
|
15826
|
-
endPageVisibility: this.getPageVisibility(),
|
|
15827
|
-
...event,
|
|
15828
|
-
});
|
|
15829
|
-
this.deleteIncompleteSubMeasurements(inProgressEvent);
|
|
15830
|
-
return res;
|
|
15831
|
-
},
|
|
15832
|
-
discardMeasurement: () => {
|
|
15833
|
-
inProgressEvent.discardMeasurement();
|
|
15834
|
-
this.deleteIncompleteSubMeasurements(inProgressEvent);
|
|
15835
|
-
inProgressEvent.measurement.flushMeasurement();
|
|
15836
|
-
},
|
|
15837
|
-
};
|
|
15838
|
-
}
|
|
15839
|
-
/**
|
|
15840
|
-
* Adds pre-queue time to preQueueTimeByCorrelationId map.
|
|
15841
|
-
* @param {PerformanceEvents} eventName
|
|
15842
|
-
* @param {?string} correlationId
|
|
15843
|
-
* @returns
|
|
15844
|
-
*/
|
|
15845
|
-
setPreQueueTime(eventName, correlationId) {
|
|
15846
|
-
if (!this.supportsBrowserPerformanceNow()) {
|
|
15847
|
-
this.logger.trace(`BrowserPerformanceClient: window performance API not available, unable to set telemetry queue time for ${eventName}`);
|
|
15848
|
-
return;
|
|
15849
|
-
}
|
|
15850
|
-
if (!correlationId) {
|
|
15851
|
-
this.logger.trace(`BrowserPerformanceClient: correlationId for ${eventName} not provided, unable to set telemetry queue time`);
|
|
15852
|
-
return;
|
|
15853
|
-
}
|
|
15854
|
-
const preQueueEvent = this.preQueueTimeByCorrelationId.get(correlationId);
|
|
15855
|
-
/**
|
|
15856
|
-
* Manually complete queue measurement if there is an incomplete pre-queue event.
|
|
15857
|
-
* Incomplete pre-queue events are instrumentation bugs that should be fixed.
|
|
15858
|
-
*/
|
|
15859
|
-
if (preQueueEvent) {
|
|
15860
|
-
this.logger.trace(`BrowserPerformanceClient: Incomplete pre-queue ${preQueueEvent.name} found`, correlationId);
|
|
15861
|
-
this.addQueueMeasurement(preQueueEvent.name, correlationId, undefined, true);
|
|
15862
|
-
}
|
|
15863
|
-
this.preQueueTimeByCorrelationId.set(correlationId, {
|
|
15864
|
-
name: eventName,
|
|
15865
|
-
time: window.performance.now(),
|
|
15866
|
-
});
|
|
15867
|
-
}
|
|
15868
|
-
/**
|
|
15869
|
-
* Calculates and adds queue time measurement for given performance event.
|
|
15870
|
-
*
|
|
15871
|
-
* @param {PerformanceEvents} eventName
|
|
15872
|
-
* @param {?string} correlationId
|
|
15873
|
-
* @param {?number} queueTime
|
|
15874
|
-
* @param {?boolean} manuallyCompleted - indicator for manually completed queue measurements
|
|
15875
|
-
* @returns
|
|
15876
|
-
*/
|
|
15877
|
-
addQueueMeasurement(eventName, correlationId, queueTime, manuallyCompleted) {
|
|
15878
|
-
if (!this.supportsBrowserPerformanceNow()) {
|
|
15879
|
-
this.logger.trace(`BrowserPerformanceClient: window performance API not available, unable to add queue measurement for ${eventName}`);
|
|
15880
|
-
return;
|
|
15881
|
-
}
|
|
15882
|
-
if (!correlationId) {
|
|
15883
|
-
this.logger.trace(`BrowserPerformanceClient: correlationId for ${eventName} not provided, unable to add queue measurement`);
|
|
15884
|
-
return;
|
|
15885
|
-
}
|
|
15886
|
-
const preQueueTime = super.getPreQueueTime(eventName, correlationId);
|
|
15887
|
-
if (!preQueueTime) {
|
|
15888
|
-
return;
|
|
15889
|
-
}
|
|
15890
|
-
const currentTime = window.performance.now();
|
|
15891
|
-
const resQueueTime = queueTime || super.calculateQueuedTime(preQueueTime, currentTime);
|
|
15892
|
-
return super.addQueueMeasurement(eventName, correlationId, resQueueTime, manuallyCompleted);
|
|
15893
|
-
}
|
|
15894
|
-
}
|
|
15895
|
-
|
|
15896
|
-
/*
|
|
15897
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
15898
|
-
* Licensed under the MIT License.
|
|
15922
|
+
/**
|
|
15923
|
+
* 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.
|
|
15924
|
+
* Breaking changes to these APIs will be shipped under a minor version, instead of a major version.
|
|
15899
15925
|
*/
|
|
15926
|
+
// Cache Manager
|
|
15900
15927
|
|
|
15901
15928
|
var internals = /*#__PURE__*/Object.freeze({
|
|
15902
15929
|
__proto__: null,
|
|
15903
15930
|
BrowserCacheManager: BrowserCacheManager,
|
|
15904
15931
|
BrowserConstants: BrowserConstants,
|
|
15905
|
-
|
|
15906
|
-
BrowserPerformanceMeasurement: BrowserPerformanceMeasurement,
|
|
15932
|
+
CacheRecord: CacheRecord,
|
|
15907
15933
|
CryptoOps: CryptoOps,
|
|
15908
15934
|
EventHandler: EventHandler,
|
|
15909
15935
|
NativeAuthError: NativeAuthError,
|
|
@@ -16120,8 +16146,9 @@ class TokenCache {
|
|
|
16120
16146
|
const idToken = new AuthToken(response.id_token, this.cryptoObj);
|
|
16121
16147
|
let cacheRecord;
|
|
16122
16148
|
let authority;
|
|
16149
|
+
let cacheRecordAccount;
|
|
16123
16150
|
if (request.account) {
|
|
16124
|
-
|
|
16151
|
+
cacheRecordAccount = AccountEntity.createFromAccountInfo(request.account);
|
|
16125
16152
|
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));
|
|
16126
16153
|
}
|
|
16127
16154
|
else if (request.authority) {
|
|
@@ -16137,12 +16164,12 @@ class TokenCache {
|
|
|
16137
16164
|
// "clientInfo" from options takes precedence over "clientInfo" in response
|
|
16138
16165
|
if (options.clientInfo) {
|
|
16139
16166
|
this.logger.trace("TokenCache - homeAccountId from options");
|
|
16140
|
-
|
|
16167
|
+
cacheRecordAccount = this.loadAccount(idToken, authority, options.clientInfo);
|
|
16141
16168
|
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));
|
|
16142
16169
|
}
|
|
16143
16170
|
else if (response.client_info) {
|
|
16144
16171
|
this.logger.trace("TokenCache - homeAccountId from response");
|
|
16145
|
-
|
|
16172
|
+
cacheRecordAccount = this.loadAccount(idToken, authority, response.client_info);
|
|
16146
16173
|
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));
|
|
16147
16174
|
}
|
|
16148
16175
|
else {
|
|
@@ -16152,7 +16179,7 @@ class TokenCache {
|
|
|
16152
16179
|
else {
|
|
16153
16180
|
throw BrowserAuthError.createUnableToLoadTokenError("Please provide a request with an account or a request with authority.");
|
|
16154
16181
|
}
|
|
16155
|
-
return this.generateAuthenticationResult(request, idToken, cacheRecord, authority);
|
|
16182
|
+
return this.generateAuthenticationResult(request, idToken, cacheRecord, cacheRecordAccount, authority);
|
|
16156
16183
|
}
|
|
16157
16184
|
/**
|
|
16158
16185
|
* Helper function to load account to msal-browser cache
|
|
@@ -16163,20 +16190,23 @@ class TokenCache {
|
|
|
16163
16190
|
* @param requestHomeAccountId
|
|
16164
16191
|
* @returns `AccountEntity`
|
|
16165
16192
|
*/
|
|
16166
|
-
loadAccount(idToken,
|
|
16193
|
+
loadAccount(idToken, authority, clientInfo, requestHomeAccountId) {
|
|
16167
16194
|
let homeAccountId;
|
|
16168
16195
|
if (requestHomeAccountId) {
|
|
16169
16196
|
homeAccountId = requestHomeAccountId;
|
|
16170
16197
|
}
|
|
16171
|
-
else if (authorityType !== undefined && clientInfo) {
|
|
16172
|
-
homeAccountId = AccountEntity.generateHomeAccountId(clientInfo, authorityType, this.logger, this.cryptoObj, idToken);
|
|
16198
|
+
else if (authority.authorityType !== undefined && clientInfo) {
|
|
16199
|
+
homeAccountId = AccountEntity.generateHomeAccountId(clientInfo, authority.authorityType, this.logger, this.cryptoObj, idToken.claims);
|
|
16173
16200
|
}
|
|
16174
16201
|
if (!homeAccountId) {
|
|
16175
16202
|
throw BrowserAuthError.createUnableToLoadTokenError("Unexpected missing homeAccountId");
|
|
16176
16203
|
}
|
|
16177
|
-
const accountEntity =
|
|
16178
|
-
|
|
16179
|
-
:
|
|
16204
|
+
const accountEntity = AccountEntity.createAccount({
|
|
16205
|
+
homeAccountId,
|
|
16206
|
+
idTokenClaims: idToken.claims,
|
|
16207
|
+
clientInfo,
|
|
16208
|
+
environment: authority.hostnameAndPort,
|
|
16209
|
+
}, authority);
|
|
16180
16210
|
if (this.isBrowserEnvironment) {
|
|
16181
16211
|
this.logger.verbose("TokenCache - loading account");
|
|
16182
16212
|
this.storage.setAccount(accountEntity);
|
|
@@ -16270,7 +16300,7 @@ class TokenCache {
|
|
|
16270
16300
|
* @param authority
|
|
16271
16301
|
* @returns `AuthenticationResult`
|
|
16272
16302
|
*/
|
|
16273
|
-
generateAuthenticationResult(request, idTokenObj, cacheRecord, authority) {
|
|
16303
|
+
generateAuthenticationResult(request, idTokenObj, cacheRecord, accountEntity, authority) {
|
|
16274
16304
|
let accessToken = Constants.EMPTY_STRING;
|
|
16275
16305
|
let responseScopes = [];
|
|
16276
16306
|
let expiresOn = null;
|
|
@@ -16292,9 +16322,7 @@ class TokenCache {
|
|
|
16292
16322
|
uniqueId: uid,
|
|
16293
16323
|
tenantId: tid,
|
|
16294
16324
|
scopes: responseScopes,
|
|
16295
|
-
account:
|
|
16296
|
-
? cacheRecord.account.getAccountInfo()
|
|
16297
|
-
: null,
|
|
16325
|
+
account: accountEntity.getAccountInfo(),
|
|
16298
16326
|
idToken: idTokenObj ? idTokenObj.rawToken : Constants.EMPTY_STRING,
|
|
16299
16327
|
idTokenClaims: idTokenObj ? idTokenObj.claims : {},
|
|
16300
16328
|
accessToken: accessToken,
|
|
@@ -16306,9 +16334,8 @@ class TokenCache {
|
|
|
16306
16334
|
familyId: Constants.EMPTY_STRING,
|
|
16307
16335
|
tokenType: cacheRecord?.accessToken?.tokenType || Constants.EMPTY_STRING,
|
|
16308
16336
|
state: Constants.EMPTY_STRING,
|
|
16309
|
-
cloudGraphHostName:
|
|
16310
|
-
|
|
16311
|
-
msGraphHost: cacheRecord?.account?.msGraphHost || Constants.EMPTY_STRING,
|
|
16337
|
+
cloudGraphHostName: accountEntity.cloudGraphHostName || Constants.EMPTY_STRING,
|
|
16338
|
+
msGraphHost: accountEntity.msGraphHost || Constants.EMPTY_STRING,
|
|
16312
16339
|
code: undefined,
|
|
16313
16340
|
fromNativeBroker: false,
|
|
16314
16341
|
};
|
|
@@ -16434,9 +16461,7 @@ class StandardController {
|
|
|
16434
16461
|
// Initial hybrid spa map
|
|
16435
16462
|
this.hybridAuthCodeResponses = new Map();
|
|
16436
16463
|
// Initialize performance client
|
|
16437
|
-
this.performanceClient = this.
|
|
16438
|
-
? new BrowserPerformanceClient(this.config.auth.clientId, this.config.auth.authority, this.logger, name, version, this.config.telemetry.application)
|
|
16439
|
-
: new StubPerformanceClient(this.config.auth.clientId, this.config.auth.authority, this.logger, name, version, this.config.telemetry.application);
|
|
16464
|
+
this.performanceClient = this.config.telemetry.client;
|
|
16440
16465
|
// Initialize the crypto class.
|
|
16441
16466
|
this.browserCrypto = this.isBrowserEnvironment
|
|
16442
16467
|
? new CryptoOps(this.logger, this.performanceClient)
|
|
@@ -16453,6 +16478,7 @@ class StandardController {
|
|
|
16453
16478
|
storeAuthStateInCookie: false,
|
|
16454
16479
|
secureCookies: false,
|
|
16455
16480
|
cacheMigrationEnabled: false,
|
|
16481
|
+
claimsBasedCachingEnabled: false,
|
|
16456
16482
|
};
|
|
16457
16483
|
this.nativeInternalStorage = new BrowserCacheManager(this.config.auth.clientId, nativeCacheOptions, this.browserCrypto, this.logger);
|
|
16458
16484
|
// Initialize the token cache
|
|
@@ -16501,7 +16527,7 @@ class StandardController {
|
|
|
16501
16527
|
}
|
|
16502
16528
|
this.initialized = true;
|
|
16503
16529
|
this.eventHandler.emitEvent(EventType.INITIALIZE_END);
|
|
16504
|
-
initMeasurement.
|
|
16530
|
+
initMeasurement.end({ allowNativeBroker, success: true });
|
|
16505
16531
|
}
|
|
16506
16532
|
// #region Redirect Flow
|
|
16507
16533
|
/**
|
|
@@ -16513,8 +16539,14 @@ class StandardController {
|
|
|
16513
16539
|
*/
|
|
16514
16540
|
async handleRedirectPromise(hash) {
|
|
16515
16541
|
this.logger.verbose("handleRedirectPromise called");
|
|
16516
|
-
// Block token acquisition before initialize has been called
|
|
16517
|
-
BrowserUtils.
|
|
16542
|
+
// Block token acquisition before initialize has been called
|
|
16543
|
+
BrowserUtils.blockAPICallsBeforeInitialize(this.initialized);
|
|
16544
|
+
let foundServerResponse = hash;
|
|
16545
|
+
if (this.config.auth.OIDCOptions?.serverResponseType ===
|
|
16546
|
+
ServerResponseType.QUERY) {
|
|
16547
|
+
const url = window.location.href;
|
|
16548
|
+
foundServerResponse = UrlString.parseQueryServerResponse(url);
|
|
16549
|
+
}
|
|
16518
16550
|
const loggedInAccounts = this.getAllAccounts();
|
|
16519
16551
|
if (this.isBrowserEnvironment) {
|
|
16520
16552
|
/**
|
|
@@ -16522,7 +16554,7 @@ class StandardController {
|
|
|
16522
16554
|
* otherwise return the promise from the first invocation. Prevents race conditions when handleRedirectPromise is called
|
|
16523
16555
|
* several times concurrently.
|
|
16524
16556
|
*/
|
|
16525
|
-
const redirectResponseKey =
|
|
16557
|
+
const redirectResponseKey = foundServerResponse || Constants.EMPTY_STRING;
|
|
16526
16558
|
let response = this.redirectResponse.get(redirectResponseKey);
|
|
16527
16559
|
if (typeof response === "undefined") {
|
|
16528
16560
|
this.eventHandler.emitEvent(EventType.HANDLE_REDIRECT_START, exports.InteractionType.Redirect);
|
|
@@ -16532,7 +16564,7 @@ class StandardController {
|
|
|
16532
16564
|
if (request &&
|
|
16533
16565
|
NativeMessageHandler.isNativeAvailable(this.config, this.logger, this.nativeExtensionProvider) &&
|
|
16534
16566
|
this.nativeExtensionProvider &&
|
|
16535
|
-
!
|
|
16567
|
+
!foundServerResponse) {
|
|
16536
16568
|
this.logger.trace("handleRedirectPromise - acquiring token from native platform");
|
|
16537
16569
|
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);
|
|
16538
16570
|
redirectResponse = nativeClient.handleRedirectPromise();
|
|
@@ -16542,7 +16574,7 @@ class StandardController {
|
|
|
16542
16574
|
const correlationId = this.browserStorage.getTemporaryCache(TemporaryCacheKeys.CORRELATION_ID, true) || Constants.EMPTY_STRING;
|
|
16543
16575
|
const redirectClient = this.createRedirectClient(correlationId);
|
|
16544
16576
|
redirectResponse =
|
|
16545
|
-
redirectClient.handleRedirectPromise(
|
|
16577
|
+
redirectClient.handleRedirectPromise(foundServerResponse);
|
|
16546
16578
|
}
|
|
16547
16579
|
response = redirectResponse
|
|
16548
16580
|
.then((result) => {
|
|
@@ -16673,7 +16705,7 @@ class StandardController {
|
|
|
16673
16705
|
result = this.acquireTokenNative(request, ApiId.acquireTokenPopup)
|
|
16674
16706
|
.then((response) => {
|
|
16675
16707
|
this.browserStorage.setInteractionInProgress(false);
|
|
16676
|
-
atPopupMeasurement.
|
|
16708
|
+
atPopupMeasurement.end({
|
|
16677
16709
|
success: true,
|
|
16678
16710
|
isNativeBroker: true,
|
|
16679
16711
|
requestId: response.requestId,
|
|
@@ -16711,11 +16743,11 @@ class StandardController {
|
|
|
16711
16743
|
else {
|
|
16712
16744
|
this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_SUCCESS, exports.InteractionType.Popup, result);
|
|
16713
16745
|
}
|
|
16714
|
-
atPopupMeasurement.
|
|
16746
|
+
atPopupMeasurement.add({
|
|
16715
16747
|
accessTokenSize: result.accessToken.length,
|
|
16716
16748
|
idTokenSize: result.idToken.length,
|
|
16717
16749
|
});
|
|
16718
|
-
atPopupMeasurement.
|
|
16750
|
+
atPopupMeasurement.end({
|
|
16719
16751
|
success: true,
|
|
16720
16752
|
requestId: result.requestId,
|
|
16721
16753
|
});
|
|
@@ -16728,7 +16760,7 @@ class StandardController {
|
|
|
16728
16760
|
else {
|
|
16729
16761
|
this.eventHandler.emitEvent(EventType.LOGIN_FAILURE, exports.InteractionType.Popup, null, e);
|
|
16730
16762
|
}
|
|
16731
|
-
atPopupMeasurement.
|
|
16763
|
+
atPopupMeasurement.end({
|
|
16732
16764
|
errorCode: e.errorCode,
|
|
16733
16765
|
subErrorCode: e.subError,
|
|
16734
16766
|
success: false,
|
|
@@ -16800,11 +16832,11 @@ class StandardController {
|
|
|
16800
16832
|
return result
|
|
16801
16833
|
.then((response) => {
|
|
16802
16834
|
this.eventHandler.emitEvent(EventType.SSO_SILENT_SUCCESS, exports.InteractionType.Silent, response);
|
|
16803
|
-
this.ssoSilentMeasurement?.
|
|
16835
|
+
this.ssoSilentMeasurement?.add({
|
|
16804
16836
|
accessTokenSize: response.accessToken.length,
|
|
16805
16837
|
idTokenSize: response.idToken.length,
|
|
16806
16838
|
});
|
|
16807
|
-
this.ssoSilentMeasurement?.
|
|
16839
|
+
this.ssoSilentMeasurement?.end({
|
|
16808
16840
|
success: true,
|
|
16809
16841
|
isNativeBroker: response.fromNativeBroker,
|
|
16810
16842
|
requestId: response.requestId,
|
|
@@ -16813,7 +16845,7 @@ class StandardController {
|
|
|
16813
16845
|
})
|
|
16814
16846
|
.catch((e) => {
|
|
16815
16847
|
this.eventHandler.emitEvent(EventType.SSO_SILENT_FAILURE, exports.InteractionType.Silent, null, e);
|
|
16816
|
-
this.ssoSilentMeasurement?.
|
|
16848
|
+
this.ssoSilentMeasurement?.end({
|
|
16817
16849
|
errorCode: e.errorCode,
|
|
16818
16850
|
subErrorCode: e.subError,
|
|
16819
16851
|
success: false,
|
|
@@ -16857,11 +16889,11 @@ class StandardController {
|
|
|
16857
16889
|
.then((result) => {
|
|
16858
16890
|
this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_BY_CODE_SUCCESS, exports.InteractionType.Silent, result);
|
|
16859
16891
|
this.hybridAuthCodeResponses.delete(hybridAuthCode);
|
|
16860
|
-
atbcMeasurement.
|
|
16892
|
+
atbcMeasurement.add({
|
|
16861
16893
|
accessTokenSize: result.accessToken.length,
|
|
16862
16894
|
idTokenSize: result.idToken.length,
|
|
16863
16895
|
});
|
|
16864
|
-
atbcMeasurement.
|
|
16896
|
+
atbcMeasurement.end({
|
|
16865
16897
|
success: true,
|
|
16866
16898
|
isNativeBroker: result.fromNativeBroker,
|
|
16867
16899
|
requestId: result.requestId,
|
|
@@ -16871,7 +16903,7 @@ class StandardController {
|
|
|
16871
16903
|
.catch((error) => {
|
|
16872
16904
|
this.hybridAuthCodeResponses.delete(hybridAuthCode);
|
|
16873
16905
|
this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_BY_CODE_FAILURE, exports.InteractionType.Silent, null, error);
|
|
16874
|
-
atbcMeasurement.
|
|
16906
|
+
atbcMeasurement.end({
|
|
16875
16907
|
errorCode: error.errorCode,
|
|
16876
16908
|
subErrorCode: error.subError,
|
|
16877
16909
|
success: false,
|
|
@@ -16882,7 +16914,7 @@ class StandardController {
|
|
|
16882
16914
|
}
|
|
16883
16915
|
else {
|
|
16884
16916
|
this.logger.verbose("Existing acquireTokenByCode request found", request.correlationId);
|
|
16885
|
-
atbcMeasurement.
|
|
16917
|
+
atbcMeasurement.discard();
|
|
16886
16918
|
}
|
|
16887
16919
|
return response;
|
|
16888
16920
|
}
|
|
@@ -16906,7 +16938,7 @@ class StandardController {
|
|
|
16906
16938
|
}
|
|
16907
16939
|
catch (e) {
|
|
16908
16940
|
this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_BY_CODE_FAILURE, exports.InteractionType.Silent, null, e);
|
|
16909
|
-
atbcMeasurement.
|
|
16941
|
+
atbcMeasurement.end({
|
|
16910
16942
|
errorCode: (e instanceof AuthError && e.errorCode) || undefined,
|
|
16911
16943
|
subErrorCode: (e instanceof AuthError && e.subError) || undefined,
|
|
16912
16944
|
success: false,
|
|
@@ -16931,7 +16963,7 @@ class StandardController {
|
|
|
16931
16963
|
const silentTokenResult = await silentAuthCodeClient
|
|
16932
16964
|
.acquireToken(request)
|
|
16933
16965
|
.then((response) => {
|
|
16934
|
-
this.acquireTokenByCodeAsyncMeasurement?.
|
|
16966
|
+
this.acquireTokenByCodeAsyncMeasurement?.end({
|
|
16935
16967
|
success: true,
|
|
16936
16968
|
fromCache: response.fromCache,
|
|
16937
16969
|
isNativeBroker: response.fromNativeBroker,
|
|
@@ -16940,7 +16972,7 @@ class StandardController {
|
|
|
16940
16972
|
return response;
|
|
16941
16973
|
})
|
|
16942
16974
|
.catch((tokenRenewalError) => {
|
|
16943
|
-
this.acquireTokenByCodeAsyncMeasurement?.
|
|
16975
|
+
this.acquireTokenByCodeAsyncMeasurement?.end({
|
|
16944
16976
|
errorCode: tokenRenewalError.errorCode,
|
|
16945
16977
|
subErrorCode: tokenRenewalError.subError,
|
|
16946
16978
|
success: false,
|
|
@@ -17150,6 +17182,26 @@ class StandardController {
|
|
|
17150
17182
|
return this.browserStorage.getActiveAccount();
|
|
17151
17183
|
}
|
|
17152
17184
|
// #endregion
|
|
17185
|
+
/**
|
|
17186
|
+
* Hydrates the cache with the tokens from an AuthenticationResult
|
|
17187
|
+
* @param result
|
|
17188
|
+
* @param request
|
|
17189
|
+
* @returns
|
|
17190
|
+
*/
|
|
17191
|
+
async hydrateCache(result, request) {
|
|
17192
|
+
this.logger.verbose("hydrateCache called");
|
|
17193
|
+
// Account gets saved to browser storage regardless of native or not
|
|
17194
|
+
const accountEntity = AccountEntity.createFromAccountInfo(result.account, result.cloudGraphHostName, result.msGraphHost);
|
|
17195
|
+
this.browserStorage.setAccount(accountEntity);
|
|
17196
|
+
if (result.fromNativeBroker) {
|
|
17197
|
+
this.logger.verbose("Response was from native broker, storing in-memory");
|
|
17198
|
+
// Tokens from native broker are stored in-memory
|
|
17199
|
+
return this.nativeInternalStorage.hydrateCache(result, request);
|
|
17200
|
+
}
|
|
17201
|
+
else {
|
|
17202
|
+
return this.browserStorage.hydrateCache(result, request);
|
|
17203
|
+
}
|
|
17204
|
+
}
|
|
17153
17205
|
// #region Helpers
|
|
17154
17206
|
/**
|
|
17155
17207
|
* Helper to validate app environment before making an auth request
|
|
@@ -17168,13 +17220,8 @@ class StandardController {
|
|
|
17168
17220
|
BrowserUtils.blockReloadInHiddenIframes();
|
|
17169
17221
|
// Block redirectUri opened in a popup from calling MSAL APIs
|
|
17170
17222
|
BrowserUtils.blockAcquireTokenInPopups();
|
|
17171
|
-
|
|
17172
|
-
|
|
17173
|
-
* Skip check if application is embedded.
|
|
17174
|
-
*/
|
|
17175
|
-
if (!isAppEmbedded) {
|
|
17176
|
-
BrowserUtils.blockNativeBrokerCalledBeforeInitialized(this.config.system.allowNativeBroker, this.initialized);
|
|
17177
|
-
}
|
|
17223
|
+
// Block token acquisition before initialize has been called
|
|
17224
|
+
BrowserUtils.blockAPICallsBeforeInitialize(this.initialized);
|
|
17178
17225
|
// Block redirects if memory storage is enabled but storeAuthStateInCookie is not
|
|
17179
17226
|
if (interactionType === exports.InteractionType.Redirect &&
|
|
17180
17227
|
this.config.cache.cacheLocation ===
|
|
@@ -17500,7 +17547,7 @@ class StandardController {
|
|
|
17500
17547
|
async acquireTokenSilent(request) {
|
|
17501
17548
|
const correlationId = this.getRequestCorrelationId(request);
|
|
17502
17549
|
const atsMeasurement = this.performanceClient.startMeasurement(PerformanceEvents.AcquireTokenSilent, correlationId);
|
|
17503
|
-
atsMeasurement.
|
|
17550
|
+
atsMeasurement.add({
|
|
17504
17551
|
cacheLookupPolicy: request.cacheLookupPolicy,
|
|
17505
17552
|
});
|
|
17506
17553
|
this.preflightBrowserEnvironmentCheck(exports.InteractionType.Silent);
|
|
@@ -17532,11 +17579,11 @@ class StandardController {
|
|
|
17532
17579
|
}, account)
|
|
17533
17580
|
.then((result) => {
|
|
17534
17581
|
this.activeSilentTokenRequests.delete(silentRequestKey);
|
|
17535
|
-
atsMeasurement.
|
|
17582
|
+
atsMeasurement.add({
|
|
17536
17583
|
accessTokenSize: result.accessToken.length,
|
|
17537
17584
|
idTokenSize: result.idToken.length,
|
|
17538
17585
|
});
|
|
17539
|
-
atsMeasurement.
|
|
17586
|
+
atsMeasurement.end({
|
|
17540
17587
|
success: true,
|
|
17541
17588
|
fromCache: result.fromCache,
|
|
17542
17589
|
isNativeBroker: result.fromNativeBroker,
|
|
@@ -17547,7 +17594,7 @@ class StandardController {
|
|
|
17547
17594
|
})
|
|
17548
17595
|
.catch((error) => {
|
|
17549
17596
|
this.activeSilentTokenRequests.delete(silentRequestKey);
|
|
17550
|
-
atsMeasurement.
|
|
17597
|
+
atsMeasurement.end({
|
|
17551
17598
|
errorCode: error.errorCode,
|
|
17552
17599
|
subErrorCode: error.subError,
|
|
17553
17600
|
success: false,
|
|
@@ -17560,7 +17607,7 @@ class StandardController {
|
|
|
17560
17607
|
else {
|
|
17561
17608
|
this.logger.verbose("acquireTokenSilent has been called previously, returning the result from the first call", correlationId);
|
|
17562
17609
|
// Discard measurements for memoized calls, as they are usually only a couple of ms and will artificially deflate metrics
|
|
17563
|
-
atsMeasurement.
|
|
17610
|
+
atsMeasurement.discard();
|
|
17564
17611
|
return cachedResponse;
|
|
17565
17612
|
}
|
|
17566
17613
|
}
|
|
@@ -17644,7 +17691,7 @@ class StandardController {
|
|
|
17644
17691
|
return result
|
|
17645
17692
|
.then((response) => {
|
|
17646
17693
|
this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_SUCCESS, exports.InteractionType.Silent, response);
|
|
17647
|
-
this.atsAsyncMeasurement?.
|
|
17694
|
+
this.atsAsyncMeasurement?.end({
|
|
17648
17695
|
success: true,
|
|
17649
17696
|
fromCache: response.fromCache,
|
|
17650
17697
|
isNativeBroker: response.fromNativeBroker,
|
|
@@ -17654,7 +17701,7 @@ class StandardController {
|
|
|
17654
17701
|
})
|
|
17655
17702
|
.catch((tokenRenewalError) => {
|
|
17656
17703
|
this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_FAILURE, exports.InteractionType.Silent, null, tokenRenewalError);
|
|
17657
|
-
this.atsAsyncMeasurement?.
|
|
17704
|
+
this.atsAsyncMeasurement?.end({
|
|
17658
17705
|
errorCode: tokenRenewalError.errorCode,
|
|
17659
17706
|
subErrorCode: tokenRenewalError.subError,
|
|
17660
17707
|
success: false,
|
|
@@ -17978,6 +18025,15 @@ class PublicClientApplication {
|
|
|
17978
18025
|
getConfiguration() {
|
|
17979
18026
|
return this.controller.getConfiguration();
|
|
17980
18027
|
}
|
|
18028
|
+
/**
|
|
18029
|
+
* Hydrates cache with the tokens and account in the AuthenticationResult object
|
|
18030
|
+
* @param result
|
|
18031
|
+
* @param request - The request object that was used to obtain the AuthenticationResult
|
|
18032
|
+
* @returns
|
|
18033
|
+
*/
|
|
18034
|
+
async hydrateCache(result, request) {
|
|
18035
|
+
return this.controller.hydrateCache(result, request);
|
|
18036
|
+
}
|
|
17981
18037
|
}
|
|
17982
18038
|
|
|
17983
18039
|
/*
|
|
@@ -18075,6 +18131,9 @@ const stubbedPublicClientApplication = {
|
|
|
18075
18131
|
getConfiguration: () => {
|
|
18076
18132
|
throw BrowserConfigurationAuthError.createStubPcaInstanceCalledError();
|
|
18077
18133
|
},
|
|
18134
|
+
hydrateCache: () => {
|
|
18135
|
+
return Promise.reject(BrowserConfigurationAuthError.createStubPcaInstanceCalledError());
|
|
18136
|
+
},
|
|
18078
18137
|
};
|
|
18079
18138
|
|
|
18080
18139
|
/*
|
|
@@ -18186,6 +18245,227 @@ class SignedHttpRequest {
|
|
|
18186
18245
|
}
|
|
18187
18246
|
}
|
|
18188
18247
|
|
|
18248
|
+
/*
|
|
18249
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
18250
|
+
* Licensed under the MIT License.
|
|
18251
|
+
*/
|
|
18252
|
+
class BrowserPerformanceMeasurement {
|
|
18253
|
+
constructor(name, correlationId) {
|
|
18254
|
+
this.correlationId = correlationId;
|
|
18255
|
+
this.measureName = BrowserPerformanceMeasurement.makeMeasureName(name, correlationId);
|
|
18256
|
+
this.startMark = BrowserPerformanceMeasurement.makeStartMark(name, correlationId);
|
|
18257
|
+
this.endMark = BrowserPerformanceMeasurement.makeEndMark(name, correlationId);
|
|
18258
|
+
}
|
|
18259
|
+
static makeMeasureName(name, correlationId) {
|
|
18260
|
+
return `msal.measure.${name}.${correlationId}`;
|
|
18261
|
+
}
|
|
18262
|
+
static makeStartMark(name, correlationId) {
|
|
18263
|
+
return `msal.start.${name}.${correlationId}`;
|
|
18264
|
+
}
|
|
18265
|
+
static makeEndMark(name, correlationId) {
|
|
18266
|
+
return `msal.end.${name}.${correlationId}`;
|
|
18267
|
+
}
|
|
18268
|
+
static supportsBrowserPerformance() {
|
|
18269
|
+
return (typeof window !== "undefined" &&
|
|
18270
|
+
typeof window.performance !== "undefined" &&
|
|
18271
|
+
typeof window.performance.mark === "function" &&
|
|
18272
|
+
typeof window.performance.measure === "function" &&
|
|
18273
|
+
typeof window.performance.clearMarks === "function" &&
|
|
18274
|
+
typeof window.performance.clearMeasures === "function" &&
|
|
18275
|
+
typeof window.performance.getEntriesByName === "function");
|
|
18276
|
+
}
|
|
18277
|
+
/**
|
|
18278
|
+
* Flush browser marks and measurements.
|
|
18279
|
+
* @param {string} correlationId
|
|
18280
|
+
* @param {SubMeasurement} measurements
|
|
18281
|
+
*/
|
|
18282
|
+
static flushMeasurements(correlationId, measurements) {
|
|
18283
|
+
if (BrowserPerformanceMeasurement.supportsBrowserPerformance()) {
|
|
18284
|
+
try {
|
|
18285
|
+
measurements.forEach((measurement) => {
|
|
18286
|
+
const measureName = BrowserPerformanceMeasurement.makeMeasureName(measurement.name, correlationId);
|
|
18287
|
+
const entriesForMeasurement = window.performance.getEntriesByName(measureName, "measure");
|
|
18288
|
+
if (entriesForMeasurement.length > 0) {
|
|
18289
|
+
window.performance.clearMeasures(measureName);
|
|
18290
|
+
window.performance.clearMarks(BrowserPerformanceMeasurement.makeStartMark(measureName, correlationId));
|
|
18291
|
+
window.performance.clearMarks(BrowserPerformanceMeasurement.makeEndMark(measureName, correlationId));
|
|
18292
|
+
}
|
|
18293
|
+
});
|
|
18294
|
+
}
|
|
18295
|
+
catch (e) {
|
|
18296
|
+
// Silently catch and return null
|
|
18297
|
+
}
|
|
18298
|
+
}
|
|
18299
|
+
}
|
|
18300
|
+
startMeasurement() {
|
|
18301
|
+
if (BrowserPerformanceMeasurement.supportsBrowserPerformance()) {
|
|
18302
|
+
try {
|
|
18303
|
+
window.performance.mark(this.startMark);
|
|
18304
|
+
}
|
|
18305
|
+
catch (e) {
|
|
18306
|
+
// Silently catch
|
|
18307
|
+
}
|
|
18308
|
+
}
|
|
18309
|
+
}
|
|
18310
|
+
endMeasurement() {
|
|
18311
|
+
if (BrowserPerformanceMeasurement.supportsBrowserPerformance()) {
|
|
18312
|
+
try {
|
|
18313
|
+
window.performance.mark(this.endMark);
|
|
18314
|
+
window.performance.measure(this.measureName, this.startMark, this.endMark);
|
|
18315
|
+
}
|
|
18316
|
+
catch (e) {
|
|
18317
|
+
// Silently catch
|
|
18318
|
+
}
|
|
18319
|
+
}
|
|
18320
|
+
}
|
|
18321
|
+
flushMeasurement() {
|
|
18322
|
+
if (BrowserPerformanceMeasurement.supportsBrowserPerformance()) {
|
|
18323
|
+
try {
|
|
18324
|
+
const entriesForMeasurement = window.performance.getEntriesByName(this.measureName, "measure");
|
|
18325
|
+
if (entriesForMeasurement.length > 0) {
|
|
18326
|
+
const durationMs = entriesForMeasurement[0].duration;
|
|
18327
|
+
window.performance.clearMeasures(this.measureName);
|
|
18328
|
+
window.performance.clearMarks(this.startMark);
|
|
18329
|
+
window.performance.clearMarks(this.endMark);
|
|
18330
|
+
return durationMs;
|
|
18331
|
+
}
|
|
18332
|
+
}
|
|
18333
|
+
catch (e) {
|
|
18334
|
+
// Silently catch and return null
|
|
18335
|
+
}
|
|
18336
|
+
}
|
|
18337
|
+
return null;
|
|
18338
|
+
}
|
|
18339
|
+
}
|
|
18340
|
+
|
|
18341
|
+
/*
|
|
18342
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
18343
|
+
* Licensed under the MIT License.
|
|
18344
|
+
*/
|
|
18345
|
+
class BrowserPerformanceClient extends PerformanceClient {
|
|
18346
|
+
constructor(configuration, intFields) {
|
|
18347
|
+
super(configuration.auth.clientId, configuration.auth.authority || `${Constants.DEFAULT_AUTHORITY}`, new Logger(configuration.system?.loggerOptions || {}, name, version), name, version, configuration.telemetry?.application || {
|
|
18348
|
+
appName: "",
|
|
18349
|
+
appVersion: "",
|
|
18350
|
+
}, intFields);
|
|
18351
|
+
this.browserCrypto = new BrowserCrypto(this.logger);
|
|
18352
|
+
this.guidGenerator = new GuidGenerator(this.browserCrypto);
|
|
18353
|
+
}
|
|
18354
|
+
startPerformanceMeasurement(measureName, correlationId) {
|
|
18355
|
+
return new BrowserPerformanceMeasurement(measureName, correlationId);
|
|
18356
|
+
}
|
|
18357
|
+
generateId() {
|
|
18358
|
+
return this.guidGenerator.generateGuid();
|
|
18359
|
+
}
|
|
18360
|
+
getPageVisibility() {
|
|
18361
|
+
return document.visibilityState?.toString() || null;
|
|
18362
|
+
}
|
|
18363
|
+
deleteIncompleteSubMeasurements(inProgressEvent) {
|
|
18364
|
+
const rootEvent = this.eventsByCorrelationId.get(inProgressEvent.event.correlationId);
|
|
18365
|
+
const isRootEvent = rootEvent && rootEvent.eventId === inProgressEvent.event.eventId;
|
|
18366
|
+
const incompleteMeasurements = [];
|
|
18367
|
+
if (isRootEvent && rootEvent?.incompleteSubMeasurements) {
|
|
18368
|
+
rootEvent.incompleteSubMeasurements.forEach((subMeasurement) => {
|
|
18369
|
+
incompleteMeasurements.push({ ...subMeasurement });
|
|
18370
|
+
});
|
|
18371
|
+
}
|
|
18372
|
+
// Clean up remaining marks for incomplete sub-measurements
|
|
18373
|
+
if (incompleteMeasurements.length > 0) {
|
|
18374
|
+
BrowserPerformanceMeasurement.flushMeasurements(inProgressEvent.event.correlationId, incompleteMeasurements);
|
|
18375
|
+
}
|
|
18376
|
+
}
|
|
18377
|
+
supportsBrowserPerformanceNow() {
|
|
18378
|
+
return (typeof window !== "undefined" &&
|
|
18379
|
+
typeof window.performance !== "undefined" &&
|
|
18380
|
+
typeof window.performance.now === "function");
|
|
18381
|
+
}
|
|
18382
|
+
/**
|
|
18383
|
+
* Starts measuring performance for a given operation. Returns a function that should be used to end the measurement.
|
|
18384
|
+
* Also captures browser page visibilityState.
|
|
18385
|
+
*
|
|
18386
|
+
* @param {PerformanceEvents} measureName
|
|
18387
|
+
* @param {?string} [correlationId]
|
|
18388
|
+
* @returns {((event?: Partial<PerformanceEvent>) => PerformanceEvent| null)}
|
|
18389
|
+
*/
|
|
18390
|
+
startMeasurement(measureName, correlationId) {
|
|
18391
|
+
// Capture page visibilityState and then invoke start/end measurement
|
|
18392
|
+
const startPageVisibility = this.getPageVisibility();
|
|
18393
|
+
const inProgressEvent = super.startMeasurement(measureName, correlationId);
|
|
18394
|
+
return {
|
|
18395
|
+
...inProgressEvent,
|
|
18396
|
+
end: (event) => {
|
|
18397
|
+
const res = inProgressEvent.end({
|
|
18398
|
+
startPageVisibility,
|
|
18399
|
+
endPageVisibility: this.getPageVisibility(),
|
|
18400
|
+
...event,
|
|
18401
|
+
});
|
|
18402
|
+
this.deleteIncompleteSubMeasurements(inProgressEvent);
|
|
18403
|
+
return res;
|
|
18404
|
+
},
|
|
18405
|
+
discard: () => {
|
|
18406
|
+
inProgressEvent.discard();
|
|
18407
|
+
this.deleteIncompleteSubMeasurements(inProgressEvent);
|
|
18408
|
+
inProgressEvent.measurement.flushMeasurement();
|
|
18409
|
+
},
|
|
18410
|
+
};
|
|
18411
|
+
}
|
|
18412
|
+
/**
|
|
18413
|
+
* Adds pre-queue time to preQueueTimeByCorrelationId map.
|
|
18414
|
+
* @param {PerformanceEvents} eventName
|
|
18415
|
+
* @param {?string} correlationId
|
|
18416
|
+
* @returns
|
|
18417
|
+
*/
|
|
18418
|
+
setPreQueueTime(eventName, correlationId) {
|
|
18419
|
+
if (!this.supportsBrowserPerformanceNow()) {
|
|
18420
|
+
this.logger.trace(`BrowserPerformanceClient: window performance API not available, unable to set telemetry queue time for ${eventName}`);
|
|
18421
|
+
return;
|
|
18422
|
+
}
|
|
18423
|
+
if (!correlationId) {
|
|
18424
|
+
this.logger.trace(`BrowserPerformanceClient: correlationId for ${eventName} not provided, unable to set telemetry queue time`);
|
|
18425
|
+
return;
|
|
18426
|
+
}
|
|
18427
|
+
const preQueueEvent = this.preQueueTimeByCorrelationId.get(correlationId);
|
|
18428
|
+
/**
|
|
18429
|
+
* Manually complete queue measurement if there is an incomplete pre-queue event.
|
|
18430
|
+
* Incomplete pre-queue events are instrumentation bugs that should be fixed.
|
|
18431
|
+
*/
|
|
18432
|
+
if (preQueueEvent) {
|
|
18433
|
+
this.logger.trace(`BrowserPerformanceClient: Incomplete pre-queue ${preQueueEvent.name} found`, correlationId);
|
|
18434
|
+
this.addQueueMeasurement(preQueueEvent.name, correlationId, undefined, true);
|
|
18435
|
+
}
|
|
18436
|
+
this.preQueueTimeByCorrelationId.set(correlationId, {
|
|
18437
|
+
name: eventName,
|
|
18438
|
+
time: window.performance.now(),
|
|
18439
|
+
});
|
|
18440
|
+
}
|
|
18441
|
+
/**
|
|
18442
|
+
* Calculates and adds queue time measurement for given performance event.
|
|
18443
|
+
*
|
|
18444
|
+
* @param {PerformanceEvents} eventName
|
|
18445
|
+
* @param {?string} correlationId
|
|
18446
|
+
* @param {?number} queueTime
|
|
18447
|
+
* @param {?boolean} manuallyCompleted - indicator for manually completed queue measurements
|
|
18448
|
+
* @returns
|
|
18449
|
+
*/
|
|
18450
|
+
addQueueMeasurement(eventName, correlationId, queueTime, manuallyCompleted) {
|
|
18451
|
+
if (!this.supportsBrowserPerformanceNow()) {
|
|
18452
|
+
this.logger.trace(`BrowserPerformanceClient: window performance API not available, unable to add queue measurement for ${eventName}`);
|
|
18453
|
+
return;
|
|
18454
|
+
}
|
|
18455
|
+
if (!correlationId) {
|
|
18456
|
+
this.logger.trace(`BrowserPerformanceClient: correlationId for ${eventName} not provided, unable to add queue measurement`);
|
|
18457
|
+
return;
|
|
18458
|
+
}
|
|
18459
|
+
const preQueueTime = super.getPreQueueTime(eventName, correlationId);
|
|
18460
|
+
if (!preQueueTime) {
|
|
18461
|
+
return;
|
|
18462
|
+
}
|
|
18463
|
+
const currentTime = window.performance.now();
|
|
18464
|
+
const resQueueTime = queueTime || super.calculateQueuedTime(preQueueTime, currentTime);
|
|
18465
|
+
return super.addQueueMeasurement(eventName, correlationId, resQueueTime, manuallyCompleted);
|
|
18466
|
+
}
|
|
18467
|
+
}
|
|
18468
|
+
|
|
18189
18469
|
exports.AccountEntity = AccountEntity;
|
|
18190
18470
|
exports.ApiId = ApiId;
|
|
18191
18471
|
exports.AuthError = AuthError;
|
|
@@ -18198,6 +18478,8 @@ exports.BrowserAuthErrorMessage = BrowserAuthErrorMessage;
|
|
|
18198
18478
|
exports.BrowserCacheLocation = BrowserCacheLocation;
|
|
18199
18479
|
exports.BrowserConfigurationAuthError = BrowserConfigurationAuthError;
|
|
18200
18480
|
exports.BrowserConfigurationAuthErrorMessage = BrowserConfigurationAuthErrorMessage;
|
|
18481
|
+
exports.BrowserPerformanceClient = BrowserPerformanceClient;
|
|
18482
|
+
exports.BrowserPerformanceMeasurement = BrowserPerformanceMeasurement;
|
|
18201
18483
|
exports.BrowserUtils = BrowserUtils;
|
|
18202
18484
|
exports.CacheLookupPolicy = CacheLookupPolicy;
|
|
18203
18485
|
exports.ClientAuthError = ClientAuthError;
|
|
@@ -18214,9 +18496,11 @@ exports.Logger = Logger;
|
|
|
18214
18496
|
exports.NavigationClient = NavigationClient;
|
|
18215
18497
|
exports.OIDC_DEFAULT_SCOPES = OIDC_DEFAULT_SCOPES;
|
|
18216
18498
|
exports.PerformanceEvents = PerformanceEvents;
|
|
18499
|
+
exports.PromptValue = PromptValue;
|
|
18217
18500
|
exports.ProtocolMode = ProtocolMode;
|
|
18218
18501
|
exports.PublicClientApplication = PublicClientApplication;
|
|
18219
18502
|
exports.ServerError = ServerError;
|
|
18503
|
+
exports.ServerResponseType = ServerResponseType;
|
|
18220
18504
|
exports.SignedHttpRequest = SignedHttpRequest;
|
|
18221
18505
|
exports.StringUtils = StringUtils;
|
|
18222
18506
|
exports.UrlString = UrlString;
|