@azure/msal-browser 3.0.0-beta.1 → 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 +1 -0
- 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 +7 -0
- 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 +19 -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.map +1 -1
- package/dist/cache/MemoryStorage.js +1 -1
- package/dist/cache/TokenCache.d.ts.map +1 -1
- package/dist/cache/TokenCache.js +20 -18
- package/dist/cache/TokenCache.js.map +1 -1
- package/dist/config/Configuration.d.ts +10 -2
- package/dist/config/Configuration.d.ts.map +1 -1
- package/dist/config/Configuration.js +37 -4
- package/dist/config/Configuration.js.map +1 -1
- package/dist/controllers/ControllerFactory.js +1 -1
- package/dist/controllers/IController.d.ts +1 -0
- package/dist/controllers/IController.d.ts.map +1 -1
- package/dist/controllers/StandardController.d.ts +7 -0
- package/dist/controllers/StandardController.d.ts.map +1 -1
- package/dist/controllers/StandardController.js +58 -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 +3 -3
- 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.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 +3 -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.map +1 -1
- package/dist/interaction_client/BaseInteractionClient.js +2 -1
- package/dist/interaction_client/BaseInteractionClient.js.map +1 -1
- package/dist/interaction_client/HybridSpaAuthorizationCodeClient.js +1 -1
- package/dist/interaction_client/NativeInteractionClient.d.ts +1 -10
- package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
- package/dist/interaction_client/NativeInteractionClient.js +21 -26
- package/dist/interaction_client/NativeInteractionClient.js.map +1 -1
- package/dist/interaction_client/PopupClient.d.ts +4 -0
- package/dist/interaction_client/PopupClient.d.ts.map +1 -1
- package/dist/interaction_client/PopupClient.js +48 -9
- package/dist/interaction_client/PopupClient.js.map +1 -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.js +1 -1
- package/dist/interaction_client/SilentCacheClient.js +5 -5
- package/dist/interaction_client/SilentCacheClient.js.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.js +4 -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 +7 -5
- package/dist/interaction_client/StandardInteractionClient.js.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.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 -3
- package/dist/internals.d.ts.map +1 -1
- package/dist/internals.js +7 -4
- 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.map +1 -1
- package/dist/telemetry/BrowserPerformanceClient.d.ts +3 -2
- package/dist/telemetry/BrowserPerformanceClient.d.ts.map +1 -1
- package/dist/telemetry/BrowserPerformanceClient.js +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.js +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 +942 -665
- package/lib/msal-browser.cjs.js.map +1 -1
- package/lib/msal-browser.js +942 -665
- package/lib/msal-browser.js.map +1 -1
- package/lib/msal-browser.min.js +62 -62
- package/package.json +16 -11
- package/dist/cache/entities/CacheRecord.js +0 -17
- package/dist/cache/entities/CacheRecord.js.map +0 -1
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.
|
|
@@ -3256,8 +3268,15 @@ function buildAuthOptions(authOptions) {
|
|
|
3256
3268
|
...authOptions,
|
|
3257
3269
|
};
|
|
3258
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
|
+
}
|
|
3259
3278
|
|
|
3260
|
-
/*! @azure/msal-common v14.0.0
|
|
3279
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
3261
3280
|
|
|
3262
3281
|
/*
|
|
3263
3282
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3274,7 +3293,7 @@ class ServerError extends AuthError {
|
|
|
3274
3293
|
}
|
|
3275
3294
|
}
|
|
3276
3295
|
|
|
3277
|
-
/*! @azure/msal-common v14.0.0
|
|
3296
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
3278
3297
|
|
|
3279
3298
|
/*
|
|
3280
3299
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3371,7 +3390,7 @@ class ThrottlingUtils {
|
|
|
3371
3390
|
}
|
|
3372
3391
|
}
|
|
3373
3392
|
|
|
3374
|
-
/*! @azure/msal-common v14.0.0
|
|
3393
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
3375
3394
|
|
|
3376
3395
|
/*
|
|
3377
3396
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3407,7 +3426,7 @@ class NetworkManager {
|
|
|
3407
3426
|
}
|
|
3408
3427
|
}
|
|
3409
3428
|
|
|
3410
|
-
/*! @azure/msal-common v14.0.0
|
|
3429
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
3411
3430
|
/*
|
|
3412
3431
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3413
3432
|
* Licensed under the MIT License.
|
|
@@ -3417,7 +3436,7 @@ const CcsCredentialType = {
|
|
|
3417
3436
|
UPN: "UPN",
|
|
3418
3437
|
};
|
|
3419
3438
|
|
|
3420
|
-
/*! @azure/msal-common v14.0.0
|
|
3439
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
3421
3440
|
|
|
3422
3441
|
/*
|
|
3423
3442
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3498,11 +3517,11 @@ class RequestValidator {
|
|
|
3498
3517
|
}
|
|
3499
3518
|
});
|
|
3500
3519
|
// remove empty string parameters
|
|
3501
|
-
return Object.fromEntries(Object.entries(eQParams).filter(kv => kv[1] !== ""));
|
|
3520
|
+
return Object.fromEntries(Object.entries(eQParams).filter((kv) => kv[1] !== ""));
|
|
3502
3521
|
}
|
|
3503
3522
|
}
|
|
3504
3523
|
|
|
3505
|
-
/*! @azure/msal-common v14.0.0
|
|
3524
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
3506
3525
|
|
|
3507
3526
|
/*
|
|
3508
3527
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3542,9 +3561,15 @@ class RequestParameterBuilder {
|
|
|
3542
3561
|
* @param scopeSet
|
|
3543
3562
|
* @param addOidcScopes
|
|
3544
3563
|
*/
|
|
3545
|
-
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
|
+
}
|
|
3546
3571
|
const requestScopes = addOidcScopes
|
|
3547
|
-
? [...(scopes || []), ...
|
|
3572
|
+
? [...(scopes || []), ...defaultScopes]
|
|
3548
3573
|
: scopes || [];
|
|
3549
3574
|
const scopeSet = new ScopeSet(requestScopes);
|
|
3550
3575
|
this.parameters.set(AADServerParamKeys.SCOPE, encodeURIComponent(scopeSet.printScopes()));
|
|
@@ -3879,7 +3904,7 @@ class RequestParameterBuilder {
|
|
|
3879
3904
|
}
|
|
3880
3905
|
}
|
|
3881
3906
|
|
|
3882
|
-
/*! @azure/msal-common v14.0.0
|
|
3907
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
3883
3908
|
|
|
3884
3909
|
/*
|
|
3885
3910
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3974,7 +3999,7 @@ class BaseClient {
|
|
|
3974
3999
|
}
|
|
3975
4000
|
}
|
|
3976
4001
|
|
|
3977
|
-
/*! @azure/msal-common v14.0.0
|
|
4002
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
3978
4003
|
|
|
3979
4004
|
/*
|
|
3980
4005
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4113,7 +4138,7 @@ class CredentialEntity {
|
|
|
4113
4138
|
}
|
|
4114
4139
|
}
|
|
4115
4140
|
|
|
4116
|
-
/*! @azure/msal-common v14.0.0
|
|
4141
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
4117
4142
|
|
|
4118
4143
|
/*
|
|
4119
4144
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4172,7 +4197,7 @@ class IdTokenEntity extends CredentialEntity {
|
|
|
4172
4197
|
}
|
|
4173
4198
|
}
|
|
4174
4199
|
|
|
4175
|
-
/*! @azure/msal-common v14.0.0
|
|
4200
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
4176
4201
|
/*
|
|
4177
4202
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4178
4203
|
* Licensed under the MIT License.
|
|
@@ -4219,7 +4244,7 @@ class TimeUtils {
|
|
|
4219
4244
|
}
|
|
4220
4245
|
}
|
|
4221
4246
|
|
|
4222
|
-
/*! @azure/msal-common v14.0.0
|
|
4247
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
4223
4248
|
|
|
4224
4249
|
/*
|
|
4225
4250
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4333,7 +4358,7 @@ class AccessTokenEntity extends CredentialEntity {
|
|
|
4333
4358
|
}
|
|
4334
4359
|
}
|
|
4335
4360
|
|
|
4336
|
-
/*! @azure/msal-common v14.0.0
|
|
4361
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
4337
4362
|
|
|
4338
4363
|
/*
|
|
4339
4364
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4395,7 +4420,7 @@ class RefreshTokenEntity extends CredentialEntity {
|
|
|
4395
4420
|
}
|
|
4396
4421
|
}
|
|
4397
4422
|
|
|
4398
|
-
/*! @azure/msal-common v14.0.0
|
|
4423
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
4399
4424
|
|
|
4400
4425
|
/*
|
|
4401
4426
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4476,12 +4501,12 @@ class InteractionRequiredAuthError extends AuthError {
|
|
|
4476
4501
|
}
|
|
4477
4502
|
}
|
|
4478
4503
|
|
|
4479
|
-
/*! @azure/msal-common v14.0.0
|
|
4504
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
4480
4505
|
/*
|
|
4481
4506
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4482
4507
|
* Licensed under the MIT License.
|
|
4483
4508
|
*/
|
|
4484
|
-
|
|
4509
|
+
class CacheRecord {
|
|
4485
4510
|
constructor(accountEntity, idTokenEntity, accessTokenEntity, refreshTokenEntity, appMetadataEntity) {
|
|
4486
4511
|
this.account = accountEntity || null;
|
|
4487
4512
|
this.idToken = idTokenEntity || null;
|
|
@@ -4489,9 +4514,9 @@ let CacheRecord$1 = class CacheRecord {
|
|
|
4489
4514
|
this.refreshToken = refreshTokenEntity || null;
|
|
4490
4515
|
this.appMetadata = appMetadataEntity || null;
|
|
4491
4516
|
}
|
|
4492
|
-
}
|
|
4517
|
+
}
|
|
4493
4518
|
|
|
4494
|
-
/*! @azure/msal-common v14.0.0
|
|
4519
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
4495
4520
|
|
|
4496
4521
|
/*
|
|
4497
4522
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4565,7 +4590,7 @@ class ProtocolUtils {
|
|
|
4565
4590
|
}
|
|
4566
4591
|
}
|
|
4567
4592
|
|
|
4568
|
-
/*! @azure/msal-common v14.0.0
|
|
4593
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
4569
4594
|
|
|
4570
4595
|
/*
|
|
4571
4596
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4749,6 +4774,30 @@ class UrlString {
|
|
|
4749
4774
|
}
|
|
4750
4775
|
return Constants.EMPTY_STRING;
|
|
4751
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
|
+
}
|
|
4752
4801
|
static constructAuthorityUriFromObject(urlObject) {
|
|
4753
4802
|
return new UrlString(urlObject.Protocol +
|
|
4754
4803
|
"//" +
|
|
@@ -4794,6 +4843,21 @@ class UrlString {
|
|
|
4794
4843
|
}
|
|
4795
4844
|
return deserializedQueryString;
|
|
4796
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
|
+
}
|
|
4797
4861
|
/**
|
|
4798
4862
|
* Check if the hash of the URL string contains known properties
|
|
4799
4863
|
*/
|
|
@@ -4810,7 +4874,7 @@ class UrlString {
|
|
|
4810
4874
|
}
|
|
4811
4875
|
}
|
|
4812
4876
|
|
|
4813
|
-
/*! @azure/msal-common v14.0.0
|
|
4877
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
4814
4878
|
/*
|
|
4815
4879
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4816
4880
|
* Licensed under the MIT License.
|
|
@@ -5013,6 +5077,7 @@ const PerformanceEvents = {
|
|
|
5013
5077
|
UpdateCloudDiscoveryMetadataMeasurement: "updateCloudDiscoveryMetadataMeasurement",
|
|
5014
5078
|
UsernamePasswordClientAcquireToken: "usernamePasswordClientAcquireToken",
|
|
5015
5079
|
NativeMessageHandlerHandshake: "nativeMessageHandlerHandshake",
|
|
5080
|
+
NativeGenerateAuthResult: "nativeGenerateAuthResult",
|
|
5016
5081
|
};
|
|
5017
5082
|
/**
|
|
5018
5083
|
* State of the performance event.
|
|
@@ -5037,7 +5102,7 @@ const IntFields = new Set([
|
|
|
5037
5102
|
"status",
|
|
5038
5103
|
]);
|
|
5039
5104
|
|
|
5040
|
-
/*! @azure/msal-common v14.0.0
|
|
5105
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
5041
5106
|
|
|
5042
5107
|
/*
|
|
5043
5108
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -5122,7 +5187,7 @@ class PopTokenGenerator {
|
|
|
5122
5187
|
}
|
|
5123
5188
|
}
|
|
5124
5189
|
|
|
5125
|
-
/*! @azure/msal-common v14.0.0
|
|
5190
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
5126
5191
|
|
|
5127
5192
|
/*
|
|
5128
5193
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -5191,7 +5256,7 @@ class AppMetadataEntity {
|
|
|
5191
5256
|
}
|
|
5192
5257
|
}
|
|
5193
5258
|
|
|
5194
|
-
/*! @azure/msal-common v14.0.0
|
|
5259
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
5195
5260
|
/*
|
|
5196
5261
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
5197
5262
|
* Licensed under the MIT License.
|
|
@@ -5218,7 +5283,7 @@ class AppMetadataEntity {
|
|
|
5218
5283
|
}
|
|
5219
5284
|
}
|
|
5220
5285
|
|
|
5221
|
-
/*! @azure/msal-common v14.0.0
|
|
5286
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
5222
5287
|
|
|
5223
5288
|
/*
|
|
5224
5289
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -5245,12 +5310,25 @@ class ResponseHandler {
|
|
|
5245
5310
|
*/
|
|
5246
5311
|
validateServerAuthorizationCodeResponse(serverResponseHash, cachedState, cryptoObj) {
|
|
5247
5312
|
if (!serverResponseHash.state || !cachedState) {
|
|
5248
|
-
throw
|
|
5249
|
-
? ClientAuthError.createStateNotFoundError("
|
|
5250
|
-
: 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);
|
|
5251
5327
|
}
|
|
5252
|
-
|
|
5253
|
-
|
|
5328
|
+
catch (e) {
|
|
5329
|
+
throw ClientAuthError.createInvalidStateError(serverResponseHash.state, `Cached state URI could not be decoded`);
|
|
5330
|
+
}
|
|
5331
|
+
if (decodedServerResponseHash !== decodedCachedState) {
|
|
5254
5332
|
throw ClientAuthError.createStateMismatchError();
|
|
5255
5333
|
}
|
|
5256
5334
|
// Check for error
|
|
@@ -5310,7 +5388,7 @@ class ResponseHandler {
|
|
|
5310
5388
|
}
|
|
5311
5389
|
}
|
|
5312
5390
|
// generate homeAccountId
|
|
5313
|
-
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);
|
|
5314
5392
|
// save the response tokens
|
|
5315
5393
|
let requestStateObj;
|
|
5316
5394
|
if (!!authCodePayload && !!authCodePayload.state) {
|
|
@@ -5343,7 +5421,7 @@ class ResponseHandler {
|
|
|
5343
5421
|
return ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenObj, requestStateObj, undefined, serverRequestId);
|
|
5344
5422
|
}
|
|
5345
5423
|
}
|
|
5346
|
-
await this.cacheStorage.saveCacheRecord(cacheRecord);
|
|
5424
|
+
await this.cacheStorage.saveCacheRecord(cacheRecord, request.storeInCache);
|
|
5347
5425
|
}
|
|
5348
5426
|
finally {
|
|
5349
5427
|
if (this.persistencePlugin &&
|
|
@@ -5372,7 +5450,13 @@ class ResponseHandler {
|
|
|
5372
5450
|
if (!StringUtils.isEmpty(serverTokenResponse.id_token) &&
|
|
5373
5451
|
!!idTokenObj) {
|
|
5374
5452
|
cachedIdToken = IdTokenEntity.createIdTokenEntity(this.homeAccountIdentifier, env, serverTokenResponse.id_token || Constants.EMPTY_STRING, this.clientId, idTokenObj.claims.tid || Constants.EMPTY_STRING);
|
|
5375
|
-
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);
|
|
5376
5460
|
}
|
|
5377
5461
|
// AccessToken
|
|
5378
5462
|
let cachedAccessToken = null;
|
|
@@ -5414,35 +5498,7 @@ class ResponseHandler {
|
|
|
5414
5498
|
if (!StringUtils.isEmpty(serverTokenResponse.foci)) {
|
|
5415
5499
|
cachedAppMetadata = AppMetadataEntity.createAppMetadataEntity(this.clientId, env, serverTokenResponse.foci);
|
|
5416
5500
|
}
|
|
5417
|
-
return new CacheRecord
|
|
5418
|
-
}
|
|
5419
|
-
/**
|
|
5420
|
-
* Generate Account
|
|
5421
|
-
* @param serverTokenResponse
|
|
5422
|
-
* @param idToken
|
|
5423
|
-
* @param authority
|
|
5424
|
-
*/
|
|
5425
|
-
generateAccountEntity(serverTokenResponse, idToken, authority, authCodePayload) {
|
|
5426
|
-
const authorityType = authority.authorityType;
|
|
5427
|
-
const cloudGraphHostName = authCodePayload
|
|
5428
|
-
? authCodePayload.cloud_graph_host_name
|
|
5429
|
-
: Constants.EMPTY_STRING;
|
|
5430
|
-
const msGraphhost = authCodePayload
|
|
5431
|
-
? authCodePayload.msgraph_host
|
|
5432
|
-
: Constants.EMPTY_STRING;
|
|
5433
|
-
// ADFS does not require client_info in the response
|
|
5434
|
-
if (authorityType === AuthorityType.Adfs) {
|
|
5435
|
-
this.logger.verbose("Authority type is ADFS, creating ADFS account");
|
|
5436
|
-
return AccountEntity.createGenericAccount(this.homeAccountIdentifier, idToken, authority, cloudGraphHostName, msGraphhost);
|
|
5437
|
-
}
|
|
5438
|
-
// This fallback applies to B2C as well as they fall under an AAD account type.
|
|
5439
|
-
if (StringUtils.isEmpty(serverTokenResponse.client_info) &&
|
|
5440
|
-
authority.protocolMode === "AAD") {
|
|
5441
|
-
throw ClientAuthError.createClientInfoEmptyError();
|
|
5442
|
-
}
|
|
5443
|
-
return serverTokenResponse.client_info
|
|
5444
|
-
? AccountEntity.createAccount(serverTokenResponse.client_info, this.homeAccountIdentifier, idToken, authority, cloudGraphHostName, msGraphhost)
|
|
5445
|
-
: AccountEntity.createGenericAccount(this.homeAccountIdentifier, idToken, authority, cloudGraphHostName, msGraphhost);
|
|
5501
|
+
return new CacheRecord(cachedAccount, cachedIdToken, cachedAccessToken, cachedRefreshToken, cachedAppMetadata);
|
|
5446
5502
|
}
|
|
5447
5503
|
/**
|
|
5448
5504
|
* Creates an @AuthenticationResult from @CacheRecord , @IdToken , and a boolean that states whether or not the result is from cache.
|
|
@@ -5521,7 +5577,7 @@ class ResponseHandler {
|
|
|
5521
5577
|
}
|
|
5522
5578
|
}
|
|
5523
5579
|
|
|
5524
|
-
/*! @azure/msal-common v14.0.0
|
|
5580
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
5525
5581
|
|
|
5526
5582
|
/*
|
|
5527
5583
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -5535,6 +5591,8 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
5535
5591
|
super(configuration, performanceClient);
|
|
5536
5592
|
// Flag to indicate if client is for hybrid spa auth code redemption
|
|
5537
5593
|
this.includeRedirectUri = true;
|
|
5594
|
+
this.oidcDefaultScopes =
|
|
5595
|
+
this.config.authOptions.authority.options.OIDCOptions?.defaultScopes;
|
|
5538
5596
|
}
|
|
5539
5597
|
/**
|
|
5540
5598
|
* Creates the URL of the authorization request letting the user input credentials and consent to the
|
|
@@ -5573,7 +5631,7 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
5573
5631
|
const requestId = response.headers?.[HeaderNames.X_MS_REQUEST_ID];
|
|
5574
5632
|
const httpVerAuthority = response.headers?.[HeaderNames.X_MS_HTTP_VERSION];
|
|
5575
5633
|
if (httpVerAuthority) {
|
|
5576
|
-
atsMeasurement?.
|
|
5634
|
+
atsMeasurement?.add({
|
|
5577
5635
|
httpVerAuthority,
|
|
5578
5636
|
});
|
|
5579
5637
|
}
|
|
@@ -5584,14 +5642,14 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
5584
5642
|
return responseHandler
|
|
5585
5643
|
.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request, authCodePayload, undefined, undefined, undefined, requestId)
|
|
5586
5644
|
.then((result) => {
|
|
5587
|
-
atsMeasurement?.
|
|
5645
|
+
atsMeasurement?.end({
|
|
5588
5646
|
success: true,
|
|
5589
5647
|
});
|
|
5590
5648
|
return result;
|
|
5591
5649
|
})
|
|
5592
5650
|
.catch((error) => {
|
|
5593
5651
|
this.logger.verbose("Error in fetching token in ACC", request.correlationId);
|
|
5594
|
-
atsMeasurement?.
|
|
5652
|
+
atsMeasurement?.end({
|
|
5595
5653
|
errorCode: error.errorCode,
|
|
5596
5654
|
subErrorCode: error.subError,
|
|
5597
5655
|
success: false,
|
|
@@ -5607,10 +5665,8 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
5607
5665
|
handleFragmentResponse(hashFragment, cachedState) {
|
|
5608
5666
|
// Handle responses.
|
|
5609
5667
|
const responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, null, null);
|
|
5610
|
-
|
|
5611
|
-
|
|
5612
|
-
// Deserialize hash fragment response parameters.
|
|
5613
|
-
const serverParams = UrlString.getDeserializedHash(hashUrlString.getHash());
|
|
5668
|
+
const serverParams = UrlString.getDeserializedCodeResponse(this.config.authOptions.authority.options.OIDCOptions
|
|
5669
|
+
?.serverResponseType, hashFragment);
|
|
5614
5670
|
// Get code response
|
|
5615
5671
|
responseHandler.validateServerAuthorizationCodeResponse(serverParams, cachedState, this.cryptoUtils);
|
|
5616
5672
|
// throw when there is no auth code in the response
|
|
@@ -5696,14 +5752,14 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
5696
5752
|
parameterBuilder.addRedirectUri(request.redirectUri);
|
|
5697
5753
|
}
|
|
5698
5754
|
// Add scope array, parameter builder will add default scopes and dedupe
|
|
5699
|
-
parameterBuilder.addScopes(request.scopes);
|
|
5755
|
+
parameterBuilder.addScopes(request.scopes, true, this.oidcDefaultScopes);
|
|
5700
5756
|
// add code: user set, not validated
|
|
5701
5757
|
parameterBuilder.addAuthorizationCode(request.code);
|
|
5702
5758
|
// Add library metadata
|
|
5703
5759
|
parameterBuilder.addLibraryInfo(this.config.libraryInfo);
|
|
5704
5760
|
parameterBuilder.addApplicationTelemetry(this.config.telemetry.application);
|
|
5705
5761
|
parameterBuilder.addThrottling();
|
|
5706
|
-
if (this.serverTelemetryManager) {
|
|
5762
|
+
if (this.serverTelemetryManager && !isOidcProtocolMode(this.config)) {
|
|
5707
5763
|
parameterBuilder.addServerTelemetry(this.serverTelemetryManager);
|
|
5708
5764
|
}
|
|
5709
5765
|
// add code_verifier if passed
|
|
@@ -5802,7 +5858,7 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
5802
5858
|
...(request.scopes || []),
|
|
5803
5859
|
...(request.extraScopesToConsent || []),
|
|
5804
5860
|
];
|
|
5805
|
-
parameterBuilder.addScopes(requestScopes);
|
|
5861
|
+
parameterBuilder.addScopes(requestScopes, true, this.oidcDefaultScopes);
|
|
5806
5862
|
// validate the redirectUri (to be a non null value)
|
|
5807
5863
|
parameterBuilder.addRedirectUri(request.redirectUri);
|
|
5808
5864
|
// generate the correlationId if not set by the user and add
|
|
@@ -5815,7 +5871,9 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
5815
5871
|
parameterBuilder.addResponseTypeCode();
|
|
5816
5872
|
// add library info parameters
|
|
5817
5873
|
parameterBuilder.addLibraryInfo(this.config.libraryInfo);
|
|
5818
|
-
|
|
5874
|
+
if (!isOidcProtocolMode(this.config)) {
|
|
5875
|
+
parameterBuilder.addApplicationTelemetry(this.config.telemetry.application);
|
|
5876
|
+
}
|
|
5819
5877
|
// add client_info=1
|
|
5820
5878
|
parameterBuilder.addClientInfo();
|
|
5821
5879
|
if (request.codeChallenge && request.codeChallengeMethod) {
|
|
@@ -5957,7 +6015,7 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
5957
6015
|
}
|
|
5958
6016
|
}
|
|
5959
6017
|
|
|
5960
|
-
/*! @azure/msal-common v14.0.0
|
|
6018
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
5961
6019
|
|
|
5962
6020
|
/*
|
|
5963
6021
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -5978,11 +6036,11 @@ class RefreshTokenClient extends BaseClient {
|
|
|
5978
6036
|
this.performanceClient?.setPreQueueTime(PerformanceEvents.RefreshTokenClientExecuteTokenRequest, request.correlationId);
|
|
5979
6037
|
const response = await this.executeTokenRequest(request, this.authority);
|
|
5980
6038
|
const httpVerToken = response.headers?.[HeaderNames.X_MS_HTTP_VERSION];
|
|
5981
|
-
atsMeasurement?.
|
|
6039
|
+
atsMeasurement?.add({
|
|
5982
6040
|
refreshTokenSize: response.body.refresh_token?.length || 0,
|
|
5983
6041
|
});
|
|
5984
6042
|
if (httpVerToken) {
|
|
5985
|
-
atsMeasurement?.
|
|
6043
|
+
atsMeasurement?.add({
|
|
5986
6044
|
httpVerToken,
|
|
5987
6045
|
});
|
|
5988
6046
|
}
|
|
@@ -5994,14 +6052,14 @@ class RefreshTokenClient extends BaseClient {
|
|
|
5994
6052
|
return responseHandler
|
|
5995
6053
|
.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request, undefined, undefined, true, request.forceCache, requestId)
|
|
5996
6054
|
.then((result) => {
|
|
5997
|
-
atsMeasurement?.
|
|
6055
|
+
atsMeasurement?.end({
|
|
5998
6056
|
success: true,
|
|
5999
6057
|
});
|
|
6000
6058
|
return result;
|
|
6001
6059
|
})
|
|
6002
6060
|
.catch((error) => {
|
|
6003
6061
|
this.logger.verbose("Error in fetching refresh token", request.correlationId);
|
|
6004
|
-
atsMeasurement?.
|
|
6062
|
+
atsMeasurement?.end({
|
|
6005
6063
|
errorCode: error.errorCode,
|
|
6006
6064
|
subErrorCode: error.subError,
|
|
6007
6065
|
success: false,
|
|
@@ -6065,11 +6123,11 @@ class RefreshTokenClient extends BaseClient {
|
|
|
6065
6123
|
this.logger.verbose("RefreshTokenClientAcquireTokenWithCachedRefreshToken called", request.correlationId);
|
|
6066
6124
|
const refreshToken = this.cacheManager.getRefreshToken(request.account, foci);
|
|
6067
6125
|
if (!refreshToken) {
|
|
6068
|
-
atsMeasurement?.
|
|
6126
|
+
atsMeasurement?.discard();
|
|
6069
6127
|
throw InteractionRequiredAuthError.createNoTokensFoundError();
|
|
6070
6128
|
}
|
|
6071
6129
|
// attach cached RT size to the current measurement
|
|
6072
|
-
atsMeasurement?.
|
|
6130
|
+
atsMeasurement?.end({
|
|
6073
6131
|
success: true,
|
|
6074
6132
|
});
|
|
6075
6133
|
const refreshTokenRequest = {
|
|
@@ -6110,13 +6168,13 @@ class RefreshTokenClient extends BaseClient {
|
|
|
6110
6168
|
};
|
|
6111
6169
|
return this.executePostToTokenEndpoint(endpoint, requestBody, headers, thumbprint)
|
|
6112
6170
|
.then((result) => {
|
|
6113
|
-
acquireTokenMeasurement?.
|
|
6171
|
+
acquireTokenMeasurement?.end({
|
|
6114
6172
|
success: true,
|
|
6115
6173
|
});
|
|
6116
6174
|
return result;
|
|
6117
6175
|
})
|
|
6118
6176
|
.catch((error) => {
|
|
6119
|
-
acquireTokenMeasurement?.
|
|
6177
|
+
acquireTokenMeasurement?.end({
|
|
6120
6178
|
success: false,
|
|
6121
6179
|
});
|
|
6122
6180
|
throw error;
|
|
@@ -6132,13 +6190,13 @@ class RefreshTokenClient extends BaseClient {
|
|
|
6132
6190
|
const acquireTokenMeasurement = this.performanceClient?.startMeasurement(PerformanceEvents.BaseClientCreateTokenRequestHeaders, correlationId);
|
|
6133
6191
|
const parameterBuilder = new RequestParameterBuilder();
|
|
6134
6192
|
parameterBuilder.addClientId(this.config.authOptions.clientId);
|
|
6135
|
-
parameterBuilder.addScopes(request.scopes);
|
|
6193
|
+
parameterBuilder.addScopes(request.scopes, true, this.config.authOptions.authority.options.OIDCOptions?.defaultScopes);
|
|
6136
6194
|
parameterBuilder.addGrantType(GrantType.REFRESH_TOKEN_GRANT);
|
|
6137
6195
|
parameterBuilder.addClientInfo();
|
|
6138
6196
|
parameterBuilder.addLibraryInfo(this.config.libraryInfo);
|
|
6139
6197
|
parameterBuilder.addApplicationTelemetry(this.config.telemetry.application);
|
|
6140
6198
|
parameterBuilder.addThrottling();
|
|
6141
|
-
if (this.serverTelemetryManager) {
|
|
6199
|
+
if (this.serverTelemetryManager && !isOidcProtocolMode(this.config)) {
|
|
6142
6200
|
parameterBuilder.addServerTelemetry(this.serverTelemetryManager);
|
|
6143
6201
|
}
|
|
6144
6202
|
parameterBuilder.addCorrelationId(correlationId);
|
|
@@ -6163,7 +6221,7 @@ class RefreshTokenClient extends BaseClient {
|
|
|
6163
6221
|
parameterBuilder.addSshJwk(request.sshJwk);
|
|
6164
6222
|
}
|
|
6165
6223
|
else {
|
|
6166
|
-
acquireTokenMeasurement?.
|
|
6224
|
+
acquireTokenMeasurement?.end({
|
|
6167
6225
|
success: false,
|
|
6168
6226
|
});
|
|
6169
6227
|
throw ClientConfigurationError.createMissingSshJwkError();
|
|
@@ -6192,14 +6250,14 @@ class RefreshTokenClient extends BaseClient {
|
|
|
6192
6250
|
break;
|
|
6193
6251
|
}
|
|
6194
6252
|
}
|
|
6195
|
-
acquireTokenMeasurement?.
|
|
6253
|
+
acquireTokenMeasurement?.end({
|
|
6196
6254
|
success: true,
|
|
6197
6255
|
});
|
|
6198
6256
|
return parameterBuilder.createQueryString();
|
|
6199
6257
|
}
|
|
6200
6258
|
}
|
|
6201
6259
|
|
|
6202
|
-
/*! @azure/msal-common v14.0.0
|
|
6260
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
6203
6261
|
|
|
6204
6262
|
/*
|
|
6205
6263
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6302,7 +6360,7 @@ class SilentFlowClient extends BaseClient {
|
|
|
6302
6360
|
}
|
|
6303
6361
|
}
|
|
6304
6362
|
|
|
6305
|
-
/*! @azure/msal-common v14.0.0
|
|
6363
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
6306
6364
|
/*
|
|
6307
6365
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6308
6366
|
* Licensed under the MIT License.
|
|
@@ -6314,7 +6372,7 @@ function isOpenIdConfigResponse(response) {
|
|
|
6314
6372
|
response.hasOwnProperty("jwks_uri"));
|
|
6315
6373
|
}
|
|
6316
6374
|
|
|
6317
|
-
/*! @azure/msal-common v14.0.0
|
|
6375
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
6318
6376
|
/*
|
|
6319
6377
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6320
6378
|
* Licensed under the MIT License.
|
|
@@ -7191,21 +7249,16 @@ const rawMetdataJSON = {
|
|
|
7191
7249
|
};
|
|
7192
7250
|
const EndpointMetadata = rawMetdataJSON.endpointMetadata;
|
|
7193
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
|
+
}
|
|
7194
7260
|
|
|
7195
|
-
/*! @azure/msal-common v14.0.0
|
|
7196
|
-
/*
|
|
7197
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
7198
|
-
* Licensed under the MIT License.
|
|
7199
|
-
*/
|
|
7200
|
-
/**
|
|
7201
|
-
* Protocol modes supported by MSAL.
|
|
7202
|
-
*/
|
|
7203
|
-
const ProtocolMode = {
|
|
7204
|
-
AAD: "AAD",
|
|
7205
|
-
OIDC: "OIDC",
|
|
7206
|
-
};
|
|
7207
|
-
|
|
7208
|
-
/*! @azure/msal-common v14.0.0-beta.1 2023-07-06 */
|
|
7261
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
7209
7262
|
|
|
7210
7263
|
/*
|
|
7211
7264
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7285,7 +7338,7 @@ class AuthorityMetadataEntity {
|
|
|
7285
7338
|
}
|
|
7286
7339
|
}
|
|
7287
7340
|
|
|
7288
|
-
/*! @azure/msal-common v14.0.0
|
|
7341
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
7289
7342
|
/*
|
|
7290
7343
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
7291
7344
|
* Licensed under the MIT License.
|
|
@@ -7295,7 +7348,7 @@ function isCloudInstanceDiscoveryResponse(response) {
|
|
|
7295
7348
|
response.hasOwnProperty("metadata"));
|
|
7296
7349
|
}
|
|
7297
7350
|
|
|
7298
|
-
/*! @azure/msal-common v14.0.0
|
|
7351
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
7299
7352
|
/*
|
|
7300
7353
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
7301
7354
|
* Licensed under the MIT License.
|
|
@@ -7305,7 +7358,7 @@ function isCloudInstanceDiscoveryErrorResponse(response) {
|
|
|
7305
7358
|
response.hasOwnProperty("error_description"));
|
|
7306
7359
|
}
|
|
7307
7360
|
|
|
7308
|
-
/*! @azure/msal-common v14.0.0
|
|
7361
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
7309
7362
|
|
|
7310
7363
|
/*
|
|
7311
7364
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7416,7 +7469,7 @@ RegionDiscovery.IMDS_OPTIONS = {
|
|
|
7416
7469
|
},
|
|
7417
7470
|
};
|
|
7418
7471
|
|
|
7419
|
-
/*! @azure/msal-common v14.0.0
|
|
7472
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
7420
7473
|
|
|
7421
7474
|
/*
|
|
7422
7475
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7589,10 +7642,10 @@ class Authority {
|
|
|
7589
7642
|
* @private
|
|
7590
7643
|
*/
|
|
7591
7644
|
canReplaceTenant(authorityUri) {
|
|
7592
|
-
return authorityUri.PathSegments.length === 1
|
|
7593
|
-
|
|
7594
|
-
|
|
7595
|
-
|
|
7645
|
+
return (authorityUri.PathSegments.length === 1 &&
|
|
7646
|
+
!Authority.reservedTenantDomains.has(authorityUri.PathSegments[0]) &&
|
|
7647
|
+
this.getAuthorityType(authorityUri) === AuthorityType.Default &&
|
|
7648
|
+
this.protocolMode === ProtocolMode.AAD);
|
|
7596
7649
|
}
|
|
7597
7650
|
/**
|
|
7598
7651
|
* Replaces tenant in url path with current tenant. Defaults to common.
|
|
@@ -7613,8 +7666,9 @@ class Authority {
|
|
|
7613
7666
|
const currentAuthorityParts = this.canonicalAuthorityUrlComponents.PathSegments;
|
|
7614
7667
|
currentAuthorityParts.forEach((currentPart, index) => {
|
|
7615
7668
|
let cachedPart = cachedAuthorityParts[index];
|
|
7616
|
-
if (index === 0 &&
|
|
7617
|
-
|
|
7669
|
+
if (index === 0 &&
|
|
7670
|
+
this.canReplaceTenant(cachedAuthorityUrlComponents)) {
|
|
7671
|
+
const tenantId = new UrlString(this.metadata.authorization_endpoint).getUrlComponents().PathSegments[0];
|
|
7618
7672
|
/**
|
|
7619
7673
|
* Check if AAD canonical authority contains tenant domain name, for example "testdomain.onmicrosoft.com",
|
|
7620
7674
|
* by comparing its first path segment to the corresponding authorization endpoint path segment, which is
|
|
@@ -7635,8 +7689,9 @@ class Authority {
|
|
|
7635
7689
|
* The default open id configuration endpoint for any canonical authority.
|
|
7636
7690
|
*/
|
|
7637
7691
|
get defaultOpenIdConfigurationEndpoint() {
|
|
7692
|
+
const canonicalAuthorityHost = this.hostnameAndPort;
|
|
7638
7693
|
if (this.authorityType === AuthorityType.Adfs ||
|
|
7639
|
-
this.
|
|
7694
|
+
!this.isAliasOfKnownMicrosoftAuthority(canonicalAuthorityHost)) {
|
|
7640
7695
|
return `${this.canonicalAuthority}.well-known/openid-configuration`;
|
|
7641
7696
|
}
|
|
7642
7697
|
return `${this.canonicalAuthority}v2.0/.well-known/openid-configuration`;
|
|
@@ -7679,41 +7734,65 @@ class Authority {
|
|
|
7679
7734
|
*/
|
|
7680
7735
|
async updateEndpointMetadata(metadataEntity) {
|
|
7681
7736
|
this.performanceClient?.addQueueMeasurement(PerformanceEvents.AuthorityUpdateEndpointMetadata, this.correlationId);
|
|
7737
|
+
this.logger.verbose("Attempting to get endpoint metadata from authority configuration");
|
|
7682
7738
|
let metadata = this.getEndpointMetadataFromConfig();
|
|
7683
7739
|
if (metadata) {
|
|
7740
|
+
this.logger.verbose("Found endpoint metadata in authority configuration");
|
|
7684
7741
|
metadataEntity.updateEndpointMetadata(metadata, false);
|
|
7685
7742
|
return AuthorityMetadataSource.CONFIG;
|
|
7686
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();
|
|
7687
7769
|
if (this.isAuthoritySameType(metadataEntity) &&
|
|
7688
7770
|
metadataEntity.endpointsFromNetwork &&
|
|
7689
|
-
!
|
|
7771
|
+
!metadataEntityExpired) {
|
|
7690
7772
|
// No need to update
|
|
7773
|
+
this.logger.verbose("Found endpoint metadata in the cache.");
|
|
7691
7774
|
return AuthorityMetadataSource.CACHE;
|
|
7692
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.");
|
|
7693
7780
|
this.performanceClient?.setPreQueueTime(PerformanceEvents.AuthorityGetEndpointMetadataFromNetwork, this.correlationId);
|
|
7694
7781
|
metadata = await this.getEndpointMetadataFromNetwork();
|
|
7695
7782
|
if (metadata) {
|
|
7783
|
+
this.logger.verbose("Endpoint metadata was successfully returned from getEndpointMetadataFromNetwork()");
|
|
7696
7784
|
// If the user prefers to use an azure region replace the global endpoints with regional information.
|
|
7697
7785
|
if (this.authorityOptions.azureRegionConfiguration?.azureRegion) {
|
|
7698
7786
|
this.performanceClient?.setPreQueueTime(PerformanceEvents.AuthorityUpdateMetadataWithRegionalInformation, this.correlationId);
|
|
7787
|
+
this.logger.verbose("Found azure region configuration. Updating endpoints with regional information.");
|
|
7699
7788
|
metadata = await this.updateMetadataWithRegionalInformation(metadata);
|
|
7700
7789
|
}
|
|
7701
7790
|
metadataEntity.updateEndpointMetadata(metadata, true);
|
|
7702
7791
|
return AuthorityMetadataSource.NETWORK;
|
|
7703
7792
|
}
|
|
7704
|
-
let harcodedMetadata = this.getEndpointMetadataFromHardcodedValues();
|
|
7705
|
-
if (harcodedMetadata &&
|
|
7706
|
-
!this.authorityOptions.skipAuthorityMetadataCache) {
|
|
7707
|
-
// If the user prefers to use an azure region replace the global endpoints with regional information.
|
|
7708
|
-
if (this.authorityOptions.azureRegionConfiguration?.azureRegion) {
|
|
7709
|
-
this.performanceClient?.setPreQueueTime(PerformanceEvents.AuthorityUpdateMetadataWithRegionalInformation, this.correlationId);
|
|
7710
|
-
harcodedMetadata =
|
|
7711
|
-
await this.updateMetadataWithRegionalInformation(harcodedMetadata);
|
|
7712
|
-
}
|
|
7713
|
-
metadataEntity.updateEndpointMetadata(harcodedMetadata, false);
|
|
7714
|
-
return AuthorityMetadataSource.HARDCODED_VALUES;
|
|
7715
|
-
}
|
|
7716
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.");
|
|
7717
7796
|
throw ClientAuthError.createUnableToGetOpenidConfigError(this.defaultOpenIdConfigurationEndpoint);
|
|
7718
7797
|
}
|
|
7719
7798
|
}
|
|
@@ -7762,17 +7841,23 @@ class Authority {
|
|
|
7762
7841
|
const response = await this.networkInterface.sendGetRequestAsync(openIdConfigurationEndpoint, options);
|
|
7763
7842
|
const isValidResponse = isOpenIdConfigResponse(response.body);
|
|
7764
7843
|
if (isValidResponse) {
|
|
7765
|
-
perfEvent?.
|
|
7844
|
+
perfEvent?.end({ success: true });
|
|
7766
7845
|
return response.body;
|
|
7767
7846
|
}
|
|
7768
7847
|
else {
|
|
7769
|
-
perfEvent?.
|
|
7848
|
+
perfEvent?.end({
|
|
7849
|
+
success: false,
|
|
7850
|
+
errorCode: "invalid_response",
|
|
7851
|
+
});
|
|
7770
7852
|
this.logger.verbose(`Authority.getEndpointMetadataFromNetwork: could not parse response as OpenID configuration`);
|
|
7771
7853
|
return null;
|
|
7772
7854
|
}
|
|
7773
7855
|
}
|
|
7774
7856
|
catch (e) {
|
|
7775
|
-
perfEvent?.
|
|
7857
|
+
perfEvent?.end({
|
|
7858
|
+
success: false,
|
|
7859
|
+
errorCode: "request_failure",
|
|
7860
|
+
});
|
|
7776
7861
|
this.logger.verbose(`Authority.getEndpointMetadataFromNetwork: ${e}`);
|
|
7777
7862
|
return null;
|
|
7778
7863
|
}
|
|
@@ -7794,19 +7879,26 @@ class Authority {
|
|
|
7794
7879
|
this.performanceClient?.addQueueMeasurement(PerformanceEvents.AuthorityUpdateMetadataWithRegionalInformation, this.correlationId);
|
|
7795
7880
|
const userConfiguredAzureRegion = this.authorityOptions.azureRegionConfiguration?.azureRegion;
|
|
7796
7881
|
if (userConfiguredAzureRegion) {
|
|
7797
|
-
if (userConfiguredAzureRegion !==
|
|
7798
|
-
|
|
7799
|
-
this.regionDiscoveryMetadata.
|
|
7882
|
+
if (userConfiguredAzureRegion !==
|
|
7883
|
+
Constants.AZURE_REGION_AUTO_DISCOVER_FLAG) {
|
|
7884
|
+
this.regionDiscoveryMetadata.region_outcome =
|
|
7885
|
+
RegionDiscoveryOutcomes.CONFIGURED_NO_AUTO_DETECTION;
|
|
7886
|
+
this.regionDiscoveryMetadata.region_used =
|
|
7887
|
+
userConfiguredAzureRegion;
|
|
7800
7888
|
return Authority.replaceWithRegionalInformation(metadata, userConfiguredAzureRegion);
|
|
7801
7889
|
}
|
|
7802
7890
|
this.performanceClient?.setPreQueueTime(PerformanceEvents.RegionDiscoveryDetectRegion, this.correlationId);
|
|
7803
|
-
const autodetectedRegionName = await this.regionDiscovery.detectRegion(this.authorityOptions.azureRegionConfiguration
|
|
7891
|
+
const autodetectedRegionName = await this.regionDiscovery.detectRegion(this.authorityOptions.azureRegionConfiguration
|
|
7892
|
+
?.environmentRegion, this.regionDiscoveryMetadata);
|
|
7804
7893
|
if (autodetectedRegionName) {
|
|
7805
|
-
this.regionDiscoveryMetadata.region_outcome =
|
|
7806
|
-
|
|
7894
|
+
this.regionDiscoveryMetadata.region_outcome =
|
|
7895
|
+
RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_SUCCESSFUL;
|
|
7896
|
+
this.regionDiscoveryMetadata.region_used =
|
|
7897
|
+
autodetectedRegionName;
|
|
7807
7898
|
return Authority.replaceWithRegionalInformation(metadata, autodetectedRegionName);
|
|
7808
7899
|
}
|
|
7809
|
-
this.regionDiscoveryMetadata.region_outcome =
|
|
7900
|
+
this.regionDiscoveryMetadata.region_outcome =
|
|
7901
|
+
RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_FAILED;
|
|
7810
7902
|
}
|
|
7811
7903
|
return metadata;
|
|
7812
7904
|
}
|
|
@@ -7818,7 +7910,7 @@ class Authority {
|
|
|
7818
7910
|
*/
|
|
7819
7911
|
async updateCloudDiscoveryMetadata(metadataEntity) {
|
|
7820
7912
|
this.performanceClient?.addQueueMeasurement(PerformanceEvents.AuthorityUpdateCloudDiscoveryMetadata, this.correlationId);
|
|
7821
|
-
this.logger.verbose("Attempting to get cloud discovery metadata
|
|
7913
|
+
this.logger.verbose("Attempting to get cloud discovery metadata from authority configuration");
|
|
7822
7914
|
this.logger.verbosePii(`Known Authorities: ${this.authorityOptions.knownAuthorities ||
|
|
7823
7915
|
Constants.NOT_APPLICABLE}`);
|
|
7824
7916
|
this.logger.verbosePii(`Authority Metadata: ${this.authorityOptions.authorityMetadata ||
|
|
@@ -7826,17 +7918,29 @@ class Authority {
|
|
|
7826
7918
|
this.logger.verbosePii(`Canonical Authority: ${metadataEntity.canonical_authority || Constants.NOT_APPLICABLE}`);
|
|
7827
7919
|
let metadata = this.getCloudDiscoveryMetadataFromConfig();
|
|
7828
7920
|
if (metadata) {
|
|
7829
|
-
this.logger.verbose("Found cloud discovery metadata in
|
|
7921
|
+
this.logger.verbose("Found cloud discovery metadata in authority configuration");
|
|
7830
7922
|
metadataEntity.updateCloudDiscoveryMetadata(metadata, false);
|
|
7831
7923
|
return AuthorityMetadataSource.CONFIG;
|
|
7832
7924
|
}
|
|
7833
|
-
// If the cached metadata came from config but that config was not passed to this instance, we must go to
|
|
7834
|
-
this.logger.verbose("Did not find cloud discovery metadata in the config... Attempting to get cloud discovery metadata from the
|
|
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
|
+
}
|
|
7835
7939
|
const metadataEntityExpired = metadataEntity.isExpired();
|
|
7836
7940
|
if (this.isAuthoritySameType(metadataEntity) &&
|
|
7837
7941
|
metadataEntity.aliasesFromNetwork &&
|
|
7838
7942
|
!metadataEntityExpired) {
|
|
7839
|
-
this.logger.verbose("Found metadata in the cache.");
|
|
7943
|
+
this.logger.verbose("Found cloud discovery metadata in the cache.");
|
|
7840
7944
|
// No need to update
|
|
7841
7945
|
return AuthorityMetadataSource.CACHE;
|
|
7842
7946
|
}
|
|
@@ -7851,15 +7955,8 @@ class Authority {
|
|
|
7851
7955
|
metadataEntity.updateCloudDiscoveryMetadata(metadata, true);
|
|
7852
7956
|
return AuthorityMetadataSource.NETWORK;
|
|
7853
7957
|
}
|
|
7854
|
-
this.logger.verbose("Did not find cloud discovery metadata from the network... Attempting to get cloud discovery metadata from hardcoded values.");
|
|
7855
|
-
const harcodedMetadata = this.getCloudDiscoveryMetadataFromHarcodedValues();
|
|
7856
|
-
if (harcodedMetadata && !this.options.skipAuthorityMetadataCache) {
|
|
7857
|
-
this.logger.verbose("Found cloud discovery metadata from hardcoded values.");
|
|
7858
|
-
metadataEntity.updateCloudDiscoveryMetadata(harcodedMetadata, false);
|
|
7859
|
-
return AuthorityMetadataSource.HARDCODED_VALUES;
|
|
7860
|
-
}
|
|
7861
7958
|
// Metadata could not be obtained from the config, cache, network or hardcoded values
|
|
7862
|
-
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.");
|
|
7863
7960
|
throw ClientConfigurationError.createUntrustedAuthorityError();
|
|
7864
7961
|
}
|
|
7865
7962
|
/**
|
|
@@ -7964,9 +8061,11 @@ class Authority {
|
|
|
7964
8061
|
/**
|
|
7965
8062
|
* Get cloud discovery metadata for common authorities
|
|
7966
8063
|
*/
|
|
7967
|
-
|
|
8064
|
+
getCloudDiscoveryMetadataFromHardcodedValues() {
|
|
7968
8065
|
if (this.canonicalAuthority in InstanceDiscoveryMetadata) {
|
|
7969
|
-
|
|
8066
|
+
const hardcodedMetadataResponse = InstanceDiscoveryMetadata[this.canonicalAuthority];
|
|
8067
|
+
const metadata = Authority.getCloudDiscoveryMetadataFromNetworkResponse(hardcodedMetadataResponse.metadata, this.hostnameAndPort);
|
|
8068
|
+
return metadata;
|
|
7970
8069
|
}
|
|
7971
8070
|
return null;
|
|
7972
8071
|
}
|
|
@@ -8041,6 +8140,13 @@ class Authority {
|
|
|
8041
8140
|
isAlias(host) {
|
|
8042
8141
|
return this.metadata.aliases.indexOf(host) > -1;
|
|
8043
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
|
+
}
|
|
8044
8150
|
/**
|
|
8045
8151
|
* Checks whether the provided host is that of a public cloud authority
|
|
8046
8152
|
*
|
|
@@ -8082,15 +8188,17 @@ class Authority {
|
|
|
8082
8188
|
* @param azureRegion string
|
|
8083
8189
|
*/
|
|
8084
8190
|
static replaceWithRegionalInformation(metadata, azureRegion) {
|
|
8085
|
-
metadata
|
|
8086
|
-
|
|
8191
|
+
const regionalMetadata = { ...metadata };
|
|
8192
|
+
regionalMetadata.authorization_endpoint =
|
|
8193
|
+
Authority.buildRegionalAuthorityString(regionalMetadata.authorization_endpoint, azureRegion);
|
|
8087
8194
|
// TODO: Enquire on whether we should leave the query string or remove it before releasing the feature
|
|
8088
|
-
|
|
8089
|
-
|
|
8090
|
-
|
|
8091
|
-
|
|
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);
|
|
8092
8200
|
}
|
|
8093
|
-
return
|
|
8201
|
+
return regionalMetadata;
|
|
8094
8202
|
}
|
|
8095
8203
|
/**
|
|
8096
8204
|
* Transform CIAM_AUTHORIY as per the below rules:
|
|
@@ -8102,11 +8210,14 @@ class Authority {
|
|
|
8102
8210
|
* @param authority
|
|
8103
8211
|
*/
|
|
8104
8212
|
static transformCIAMAuthority(authority) {
|
|
8105
|
-
let ciamAuthority = authority.endsWith(Constants.FORWARD_SLASH)
|
|
8213
|
+
let ciamAuthority = authority.endsWith(Constants.FORWARD_SLASH)
|
|
8214
|
+
? authority
|
|
8215
|
+
: `${authority}${Constants.FORWARD_SLASH}`;
|
|
8106
8216
|
const authorityUrl = new UrlString(authority);
|
|
8107
8217
|
const authorityUrlComponents = authorityUrl.getUrlComponents();
|
|
8108
8218
|
// check if transformation is needed
|
|
8109
|
-
if (authorityUrlComponents.PathSegments.length === 0 &&
|
|
8219
|
+
if (authorityUrlComponents.PathSegments.length === 0 &&
|
|
8220
|
+
authorityUrlComponents.HostNameAndPort.endsWith(Constants.CIAM_AUTH_URL)) {
|
|
8110
8221
|
const tenantIdOrDomain = authorityUrlComponents.HostNameAndPort.split(".")[0];
|
|
8111
8222
|
ciamAuthority = `${ciamAuthority}${tenantIdOrDomain}${Constants.AAD_TENANT_DOMAIN_SUFFIX}`;
|
|
8112
8223
|
}
|
|
@@ -8114,15 +8225,15 @@ class Authority {
|
|
|
8114
8225
|
}
|
|
8115
8226
|
}
|
|
8116
8227
|
// Reserved tenant domain names that will not be replaced with tenant id
|
|
8117
|
-
Authority.reservedTenantDomains =
|
|
8228
|
+
Authority.reservedTenantDomains = new Set([
|
|
8118
8229
|
"{tenant}",
|
|
8119
8230
|
"{tenantid}",
|
|
8120
8231
|
AADAuthorityConstants.COMMON,
|
|
8121
8232
|
AADAuthorityConstants.CONSUMERS,
|
|
8122
|
-
AADAuthorityConstants.ORGANIZATIONS
|
|
8123
|
-
])
|
|
8233
|
+
AADAuthorityConstants.ORGANIZATIONS,
|
|
8234
|
+
]);
|
|
8124
8235
|
|
|
8125
|
-
/*! @azure/msal-common v14.0.0
|
|
8236
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
8126
8237
|
|
|
8127
8238
|
/*
|
|
8128
8239
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8172,7 +8283,7 @@ class AuthorityFactory {
|
|
|
8172
8283
|
}
|
|
8173
8284
|
}
|
|
8174
8285
|
|
|
8175
|
-
/*! @azure/msal-common v14.0.0
|
|
8286
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
8176
8287
|
|
|
8177
8288
|
/*
|
|
8178
8289
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8202,7 +8313,7 @@ class ServerTelemetryEntity {
|
|
|
8202
8313
|
}
|
|
8203
8314
|
}
|
|
8204
8315
|
|
|
8205
|
-
/*! @azure/msal-common v14.0.0
|
|
8316
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
8206
8317
|
|
|
8207
8318
|
/*
|
|
8208
8319
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8228,7 +8339,7 @@ class ThrottlingEntity {
|
|
|
8228
8339
|
}
|
|
8229
8340
|
}
|
|
8230
8341
|
|
|
8231
|
-
/*! @azure/msal-common v14.0.0
|
|
8342
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
8232
8343
|
|
|
8233
8344
|
/*
|
|
8234
8345
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8245,7 +8356,7 @@ const StubbedNetworkModule = {
|
|
|
8245
8356
|
},
|
|
8246
8357
|
};
|
|
8247
8358
|
|
|
8248
|
-
/*! @azure/msal-common v14.0.0
|
|
8359
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
8249
8360
|
|
|
8250
8361
|
/*
|
|
8251
8362
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8287,7 +8398,7 @@ class JoseHeaderError extends AuthError {
|
|
|
8287
8398
|
}
|
|
8288
8399
|
}
|
|
8289
8400
|
|
|
8290
|
-
/*! @azure/msal-common v14.0.0
|
|
8401
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
8291
8402
|
|
|
8292
8403
|
/*
|
|
8293
8404
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8326,7 +8437,7 @@ class JoseHeader {
|
|
|
8326
8437
|
}
|
|
8327
8438
|
}
|
|
8328
8439
|
|
|
8329
|
-
/*! @azure/msal-common v14.0.0
|
|
8440
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
8330
8441
|
|
|
8331
8442
|
/*
|
|
8332
8443
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8384,7 +8495,7 @@ class AuthenticationHeaderParser {
|
|
|
8384
8495
|
}
|
|
8385
8496
|
}
|
|
8386
8497
|
|
|
8387
|
-
/*! @azure/msal-common v14.0.0
|
|
8498
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
8388
8499
|
|
|
8389
8500
|
/*
|
|
8390
8501
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8583,7 +8694,7 @@ class ServerTelemetryManager {
|
|
|
8583
8694
|
}
|
|
8584
8695
|
}
|
|
8585
8696
|
|
|
8586
|
-
/*! @azure/msal-common v14.0.0
|
|
8697
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
8587
8698
|
|
|
8588
8699
|
/*
|
|
8589
8700
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8600,8 +8711,10 @@ class PerformanceClient {
|
|
|
8600
8711
|
* @param {Logger} logger Logger used by the application
|
|
8601
8712
|
* @param {string} libraryName Name of the library
|
|
8602
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
|
|
8603
8716
|
*/
|
|
8604
|
-
constructor(clientId, authority, logger, libraryName, libraryVersion, applicationTelemetry) {
|
|
8717
|
+
constructor(clientId, authority, logger, libraryName, libraryVersion, applicationTelemetry, intFields) {
|
|
8605
8718
|
this.authority = authority;
|
|
8606
8719
|
this.libraryName = libraryName;
|
|
8607
8720
|
this.libraryVersion = libraryVersion;
|
|
@@ -8612,6 +8725,10 @@ class PerformanceClient {
|
|
|
8612
8725
|
this.eventsByCorrelationId = new Map();
|
|
8613
8726
|
this.queueMeasurements = new Map();
|
|
8614
8727
|
this.preQueueTimeByCorrelationId = new Map();
|
|
8728
|
+
this.intFields = intFields || new Set();
|
|
8729
|
+
for (const item of IntFields) {
|
|
8730
|
+
this.intFields.add(item);
|
|
8731
|
+
}
|
|
8615
8732
|
}
|
|
8616
8733
|
/**
|
|
8617
8734
|
* Starts and returns an platform-specific implementation of IPerformanceMeasurement.
|
|
@@ -8626,13 +8743,6 @@ class PerformanceClient {
|
|
|
8626
8743
|
) {
|
|
8627
8744
|
return {};
|
|
8628
8745
|
}
|
|
8629
|
-
/**
|
|
8630
|
-
* Get integral fields.
|
|
8631
|
-
* Override to change the set.
|
|
8632
|
-
*/
|
|
8633
|
-
getIntFields() {
|
|
8634
|
-
return IntFields;
|
|
8635
|
-
}
|
|
8636
8746
|
/**
|
|
8637
8747
|
* Gets map of pre-queue times by correlation Id
|
|
8638
8748
|
*
|
|
@@ -8750,7 +8860,7 @@ class PerformanceClient {
|
|
|
8750
8860
|
this.cacheEventByCorrelationId(inProgressEvent);
|
|
8751
8861
|
// Return the event and functions the caller can use to properly end/flush the measurement
|
|
8752
8862
|
return {
|
|
8753
|
-
|
|
8863
|
+
end: (event) => {
|
|
8754
8864
|
return this.endMeasurement({
|
|
8755
8865
|
// Initial set of event properties
|
|
8756
8866
|
...inProgressEvent,
|
|
@@ -8758,14 +8868,14 @@ class PerformanceClient {
|
|
|
8758
8868
|
...event,
|
|
8759
8869
|
}, performanceMeasurement);
|
|
8760
8870
|
},
|
|
8761
|
-
|
|
8871
|
+
discard: () => {
|
|
8762
8872
|
return this.discardMeasurements(inProgressEvent.correlationId);
|
|
8763
8873
|
},
|
|
8764
|
-
|
|
8765
|
-
return this.
|
|
8874
|
+
add: (fields) => {
|
|
8875
|
+
return this.addFields(fields, inProgressEvent.correlationId);
|
|
8766
8876
|
},
|
|
8767
|
-
increment: (
|
|
8768
|
-
return this.
|
|
8877
|
+
increment: (fields) => {
|
|
8878
|
+
return this.incrementFields(fields, inProgressEvent.correlationId);
|
|
8769
8879
|
},
|
|
8770
8880
|
measurement: performanceMeasurement,
|
|
8771
8881
|
event: inProgressEvent,
|
|
@@ -8830,7 +8940,7 @@ class PerformanceClient {
|
|
|
8830
8940
|
status: PerformanceEventStatus.Completed,
|
|
8831
8941
|
incompleteSubsCount,
|
|
8832
8942
|
};
|
|
8833
|
-
this.truncateIntegralFields(finalEvent
|
|
8943
|
+
this.truncateIntegralFields(finalEvent);
|
|
8834
8944
|
this.emitEvents([finalEvent], event.correlationId);
|
|
8835
8945
|
return finalEvent;
|
|
8836
8946
|
}
|
|
@@ -8839,7 +8949,7 @@ class PerformanceClient {
|
|
|
8839
8949
|
* @param fields
|
|
8840
8950
|
* @param correlationId
|
|
8841
8951
|
*/
|
|
8842
|
-
|
|
8952
|
+
addFields(fields, correlationId) {
|
|
8843
8953
|
this.logger.trace("PerformanceClient: Updating static fields");
|
|
8844
8954
|
const event = this.eventsByCorrelationId.get(correlationId);
|
|
8845
8955
|
if (event) {
|
|
@@ -8854,18 +8964,21 @@ class PerformanceClient {
|
|
|
8854
8964
|
}
|
|
8855
8965
|
/**
|
|
8856
8966
|
* Increment counters to be emitted when the measurements are flushed
|
|
8857
|
-
* @param
|
|
8967
|
+
* @param fields {string[]}
|
|
8858
8968
|
* @param correlationId {string} correlation identifier
|
|
8859
8969
|
*/
|
|
8860
|
-
|
|
8970
|
+
incrementFields(fields, correlationId) {
|
|
8861
8971
|
this.logger.trace("PerformanceClient: Updating counters");
|
|
8862
8972
|
const event = this.eventsByCorrelationId.get(correlationId);
|
|
8863
8973
|
if (event) {
|
|
8864
|
-
for (const counter in
|
|
8974
|
+
for (const counter in fields) {
|
|
8865
8975
|
if (!event.hasOwnProperty(counter)) {
|
|
8866
8976
|
event[counter] = 0;
|
|
8867
8977
|
}
|
|
8868
|
-
event[counter]
|
|
8978
|
+
else if (isNaN(Number(event[counter]))) {
|
|
8979
|
+
return;
|
|
8980
|
+
}
|
|
8981
|
+
event[counter] += fields[counter];
|
|
8869
8982
|
}
|
|
8870
8983
|
}
|
|
8871
8984
|
else {
|
|
@@ -8983,8 +9096,8 @@ class PerformanceClient {
|
|
|
8983
9096
|
* @param {PerformanceEvent} event performance event to update.
|
|
8984
9097
|
* @param {Set<string>} intFields integral fields.
|
|
8985
9098
|
*/
|
|
8986
|
-
truncateIntegralFields(event
|
|
8987
|
-
intFields.forEach((key) => {
|
|
9099
|
+
truncateIntegralFields(event) {
|
|
9100
|
+
this.intFields.forEach((key) => {
|
|
8988
9101
|
if (key in event && typeof event[key] === "number") {
|
|
8989
9102
|
event[key] = Math.floor(event[key]);
|
|
8990
9103
|
}
|
|
@@ -8992,16 +9105,22 @@ class PerformanceClient {
|
|
|
8992
9105
|
}
|
|
8993
9106
|
}
|
|
8994
9107
|
|
|
8995
|
-
/*! @azure/msal-common v14.0.0
|
|
9108
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
8996
9109
|
|
|
8997
9110
|
/*
|
|
8998
9111
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
8999
9112
|
* Licensed under the MIT License.
|
|
9000
9113
|
*/
|
|
9001
9114
|
class StubPerformanceMeasurement {
|
|
9002
|
-
startMeasurement() {
|
|
9003
|
-
|
|
9004
|
-
|
|
9115
|
+
startMeasurement() {
|
|
9116
|
+
return;
|
|
9117
|
+
}
|
|
9118
|
+
endMeasurement() {
|
|
9119
|
+
return;
|
|
9120
|
+
}
|
|
9121
|
+
flushMeasurement() {
|
|
9122
|
+
return null;
|
|
9123
|
+
}
|
|
9005
9124
|
}
|
|
9006
9125
|
class StubPerformanceClient extends PerformanceClient {
|
|
9007
9126
|
generateId() {
|
|
@@ -9013,8 +9132,36 @@ class StubPerformanceClient extends PerformanceClient {
|
|
|
9013
9132
|
calculateQueuedTime() {
|
|
9014
9133
|
return 0;
|
|
9015
9134
|
}
|
|
9016
|
-
addQueueMeasurement() {
|
|
9017
|
-
|
|
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
|
+
}
|
|
9018
9165
|
}
|
|
9019
9166
|
|
|
9020
9167
|
/*
|
|
@@ -9197,9 +9344,9 @@ const BrowserAuthErrorMessage = {
|
|
|
9197
9344
|
code: "native_connection_not_established",
|
|
9198
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.",
|
|
9199
9346
|
},
|
|
9200
|
-
|
|
9201
|
-
code: "
|
|
9202
|
-
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.",
|
|
9203
9350
|
},
|
|
9204
9351
|
nativePromptNotSupported: {
|
|
9205
9352
|
code: "native_prompt_not_supported",
|
|
@@ -9489,8 +9636,8 @@ class BrowserAuthError extends AuthError {
|
|
|
9489
9636
|
/**
|
|
9490
9637
|
* Create an error thrown when the initialize function hasn't been called
|
|
9491
9638
|
*/
|
|
9492
|
-
static
|
|
9493
|
-
return new BrowserAuthError(BrowserAuthErrorMessage.
|
|
9639
|
+
static createUninitializedPublicClientApplication() {
|
|
9640
|
+
return new BrowserAuthError(BrowserAuthErrorMessage.uninitializedPublicClientApplication.code, BrowserAuthErrorMessage.uninitializedPublicClientApplication.desc);
|
|
9494
9641
|
}
|
|
9495
9642
|
/**
|
|
9496
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
|
|
@@ -11171,6 +11318,23 @@ class BrowserCacheManager extends CacheManager {
|
|
|
11171
11318
|
setRedirectRequestContext(value) {
|
|
11172
11319
|
this.setTemporaryCache(TemporaryCacheKeys.REDIRECT_CONTEXT, value, true);
|
|
11173
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
|
+
}
|
|
11174
11338
|
}
|
|
11175
11339
|
const DEFAULT_BROWSER_CACHE_MANAGER = (clientId, logger) => {
|
|
11176
11340
|
const cacheOptions = {
|
|
@@ -11184,20 +11348,9 @@ const DEFAULT_BROWSER_CACHE_MANAGER = (clientId, logger) => {
|
|
|
11184
11348
|
return new BrowserCacheManager(clientId, cacheOptions, DEFAULT_CRYPTO_IMPLEMENTATION, logger);
|
|
11185
11349
|
};
|
|
11186
11350
|
|
|
11187
|
-
/*
|
|
11188
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
11189
|
-
* Licensed under the MIT License.
|
|
11190
|
-
*/
|
|
11191
|
-
class CacheRecord extends CacheRecord$1 {
|
|
11192
|
-
constructor(accountEntity, idTokenEntity, accessTokenEntity, refreshTokenEntity, appMetadataEntity) {
|
|
11193
|
-
super(accountEntity, idTokenEntity, accessTokenEntity, refreshTokenEntity, appMetadataEntity);
|
|
11194
|
-
this.account = accountEntity;
|
|
11195
|
-
}
|
|
11196
|
-
}
|
|
11197
|
-
|
|
11198
11351
|
/* eslint-disable header/header */
|
|
11199
11352
|
const name = "@azure/msal-browser";
|
|
11200
|
-
const version = "3.0.0
|
|
11353
|
+
const version = "3.0.0";
|
|
11201
11354
|
|
|
11202
11355
|
/*
|
|
11203
11356
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -11533,13 +11686,12 @@ class BrowserUtils {
|
|
|
11533
11686
|
}
|
|
11534
11687
|
}
|
|
11535
11688
|
/**
|
|
11536
|
-
* Throws error if
|
|
11537
|
-
* @param allowNativeBroker
|
|
11689
|
+
* Throws error if initialize hasn't been called
|
|
11538
11690
|
* @param initialized
|
|
11539
11691
|
*/
|
|
11540
|
-
static
|
|
11541
|
-
if (
|
|
11542
|
-
throw BrowserAuthError.
|
|
11692
|
+
static blockAPICallsBeforeInitialize(initialized) {
|
|
11693
|
+
if (!initialized) {
|
|
11694
|
+
throw BrowserAuthError.createUninitializedPublicClientApplication();
|
|
11543
11695
|
}
|
|
11544
11696
|
}
|
|
11545
11697
|
/**
|
|
@@ -11698,6 +11850,7 @@ class BaseInteractionClient {
|
|
|
11698
11850
|
this.logger.verbose("getDiscoveredAuthority called");
|
|
11699
11851
|
const authorityOptions = {
|
|
11700
11852
|
protocolMode: this.config.auth.protocolMode,
|
|
11853
|
+
OIDCOptions: this.config.auth.OIDCOptions,
|
|
11701
11854
|
knownAuthorities: this.config.auth.knownAuthorities,
|
|
11702
11855
|
cloudDiscoveryMetadata: this.config.auth.cloudDiscoveryMetadata,
|
|
11703
11856
|
authorityMetadata: this.config.auth.authorityMetadata,
|
|
@@ -11907,6 +12060,7 @@ class StandardInteractionClient extends BaseInteractionClient {
|
|
|
11907
12060
|
const getAuthorityMeasurement = this.performanceClient?.startMeasurement(PerformanceEvents.StandardInteractionClientGetDiscoveredAuthority, this.correlationId);
|
|
11908
12061
|
const authorityOptions = {
|
|
11909
12062
|
protocolMode: this.config.auth.protocolMode,
|
|
12063
|
+
OIDCOptions: this.config.auth.OIDCOptions,
|
|
11910
12064
|
knownAuthorities: this.config.auth.knownAuthorities,
|
|
11911
12065
|
cloudDiscoveryMetadata: this.config.auth.cloudDiscoveryMetadata,
|
|
11912
12066
|
authorityMetadata: this.config.auth.authorityMetadata,
|
|
@@ -11922,13 +12076,13 @@ class StandardInteractionClient extends BaseInteractionClient {
|
|
|
11922
12076
|
this.performanceClient.setPreQueueTime(PerformanceEvents.AuthorityFactoryCreateDiscoveredInstance, this.correlationId);
|
|
11923
12077
|
return await AuthorityFactory.createDiscoveredInstance(builtAuthority, this.config.system.networkClient, this.browserStorage, authorityOptions, this.logger, this.performanceClient, this.correlationId)
|
|
11924
12078
|
.then((result) => {
|
|
11925
|
-
getAuthorityMeasurement.
|
|
12079
|
+
getAuthorityMeasurement.end({
|
|
11926
12080
|
success: true,
|
|
11927
12081
|
});
|
|
11928
12082
|
return result;
|
|
11929
12083
|
})
|
|
11930
12084
|
.catch((error) => {
|
|
11931
|
-
getAuthorityMeasurement.
|
|
12085
|
+
getAuthorityMeasurement.end({
|
|
11932
12086
|
errorCode: error.errorCode,
|
|
11933
12087
|
subErrorCode: error.subError,
|
|
11934
12088
|
success: false,
|
|
@@ -11955,7 +12109,8 @@ class StandardInteractionClient extends BaseInteractionClient {
|
|
|
11955
12109
|
redirectUri: redirectUri,
|
|
11956
12110
|
state: state,
|
|
11957
12111
|
nonce: request.nonce || this.browserCrypto.createNewGuid(),
|
|
11958
|
-
responseMode:
|
|
12112
|
+
responseMode: this.config.auth.OIDCOptions
|
|
12113
|
+
.serverResponseType,
|
|
11959
12114
|
};
|
|
11960
12115
|
const account = request.account || this.browserStorage.getActiveAccount();
|
|
11961
12116
|
if (account) {
|
|
@@ -12067,7 +12222,7 @@ class InteractionHandler {
|
|
|
12067
12222
|
}
|
|
12068
12223
|
// Acquire token with retrieved code.
|
|
12069
12224
|
this.performanceClient.setPreQueueTime(PerformanceEvents.AuthClientAcquireToken, this.authCodeRequest.correlationId);
|
|
12070
|
-
const tokenResponse = await this.authModule.acquireToken(this.authCodeRequest, authCodeResponse);
|
|
12225
|
+
const tokenResponse = (await this.authModule.acquireToken(this.authCodeRequest, authCodeResponse));
|
|
12071
12226
|
this.browserStorage.cleanRequestByState(state);
|
|
12072
12227
|
return tokenResponse;
|
|
12073
12228
|
}
|
|
@@ -12215,7 +12370,7 @@ class RedirectHandler extends InteractionHandler {
|
|
|
12215
12370
|
}
|
|
12216
12371
|
}
|
|
12217
12372
|
// Acquire token with retrieved code.
|
|
12218
|
-
const tokenResponse = await this.authModule.acquireToken(this.authCodeRequest, authCodeResponse);
|
|
12373
|
+
const tokenResponse = (await this.authModule.acquireToken(this.authCodeRequest, authCodeResponse));
|
|
12219
12374
|
this.browserStorage.cleanRequestByState(state);
|
|
12220
12375
|
return tokenResponse;
|
|
12221
12376
|
}
|
|
@@ -12250,7 +12405,7 @@ const EventType = {
|
|
|
12250
12405
|
LOGOUT_SUCCESS: "msal:logoutSuccess",
|
|
12251
12406
|
LOGOUT_FAILURE: "msal:logoutFailure",
|
|
12252
12407
|
LOGOUT_END: "msal:logoutEnd",
|
|
12253
|
-
RESTORE_FROM_BFCACHE: "msal:restoreFromBFCache"
|
|
12408
|
+
RESTORE_FROM_BFCACHE: "msal:restoreFromBFCache",
|
|
12254
12409
|
};
|
|
12255
12410
|
|
|
12256
12411
|
/*
|
|
@@ -12363,8 +12518,8 @@ class SilentCacheClient extends StandardInteractionClient {
|
|
|
12363
12518
|
const silentAuthClient = await this.createSilentFlowClient(serverTelemetryManager, silentRequest.authority, silentRequest.azureCloudOptions);
|
|
12364
12519
|
this.logger.verbose("Silent auth client created");
|
|
12365
12520
|
try {
|
|
12366
|
-
const cachedToken = await silentAuthClient.acquireCachedToken(silentRequest);
|
|
12367
|
-
acquireTokenMeasurement.
|
|
12521
|
+
const cachedToken = (await silentAuthClient.acquireCachedToken(silentRequest));
|
|
12522
|
+
acquireTokenMeasurement.end({
|
|
12368
12523
|
success: true,
|
|
12369
12524
|
fromCache: true,
|
|
12370
12525
|
});
|
|
@@ -12376,7 +12531,7 @@ class SilentCacheClient extends StandardInteractionClient {
|
|
|
12376
12531
|
BrowserAuthErrorMessage.signingKeyNotFoundInStorage.code) {
|
|
12377
12532
|
this.logger.verbose("Signing keypair for bound access token not found. Refreshing bound access token and generating a new crypto keypair.");
|
|
12378
12533
|
}
|
|
12379
|
-
acquireTokenMeasurement.
|
|
12534
|
+
acquireTokenMeasurement.end({
|
|
12380
12535
|
errorCode: (error instanceof AuthError && error.errorCode) ||
|
|
12381
12536
|
undefined,
|
|
12382
12537
|
subErrorCode: (error instanceof AuthError && error.subError) || undefined,
|
|
@@ -12408,7 +12563,7 @@ class SilentCacheClient extends StandardInteractionClient {
|
|
|
12408
12563
|
this.performanceClient.setPreQueueTime(PerformanceEvents.InitializeBaseRequest, this.correlationId);
|
|
12409
12564
|
return {
|
|
12410
12565
|
...request,
|
|
12411
|
-
...await this.initializeBaseRequest(request, account),
|
|
12566
|
+
...(await this.initializeBaseRequest(request, account)),
|
|
12412
12567
|
account: account,
|
|
12413
12568
|
forceRefresh: request.forceRefresh || false,
|
|
12414
12569
|
};
|
|
@@ -12442,7 +12597,7 @@ class NativeInteractionClient extends BaseInteractionClient {
|
|
|
12442
12597
|
// check if the tokens can be retrieved from internal cache
|
|
12443
12598
|
try {
|
|
12444
12599
|
const result = await this.acquireTokensFromCache(this.accountId, nativeRequest);
|
|
12445
|
-
nativeATMeasurement.
|
|
12600
|
+
nativeATMeasurement.end({
|
|
12446
12601
|
success: true,
|
|
12447
12602
|
isNativeBroker: false,
|
|
12448
12603
|
fromCache: true,
|
|
@@ -12462,7 +12617,7 @@ class NativeInteractionClient extends BaseInteractionClient {
|
|
|
12462
12617
|
const validatedResponse = this.validateNativeResponse(response);
|
|
12463
12618
|
return this.handleNativeResponse(validatedResponse, nativeRequest, reqTimestamp)
|
|
12464
12619
|
.then((result) => {
|
|
12465
|
-
nativeATMeasurement.
|
|
12620
|
+
nativeATMeasurement.end({
|
|
12466
12621
|
success: true,
|
|
12467
12622
|
isNativeBroker: true,
|
|
12468
12623
|
requestId: result.requestId,
|
|
@@ -12470,7 +12625,7 @@ class NativeInteractionClient extends BaseInteractionClient {
|
|
|
12470
12625
|
return result;
|
|
12471
12626
|
})
|
|
12472
12627
|
.catch((error) => {
|
|
12473
|
-
nativeATMeasurement.
|
|
12628
|
+
nativeATMeasurement.end({
|
|
12474
12629
|
success: false,
|
|
12475
12630
|
errorCode: error.errorCode,
|
|
12476
12631
|
subErrorCode: error.subError,
|
|
@@ -12516,7 +12671,10 @@ class NativeInteractionClient extends BaseInteractionClient {
|
|
|
12516
12671
|
try {
|
|
12517
12672
|
const silentRequest = this.createSilentCacheRequest(request, account);
|
|
12518
12673
|
const result = await this.silentCacheClient.acquireToken(silentRequest);
|
|
12519
|
-
return
|
|
12674
|
+
return {
|
|
12675
|
+
...result,
|
|
12676
|
+
account,
|
|
12677
|
+
};
|
|
12520
12678
|
}
|
|
12521
12679
|
catch (e) {
|
|
12522
12680
|
throw e;
|
|
@@ -12614,16 +12772,20 @@ class NativeInteractionClient extends BaseInteractionClient {
|
|
|
12614
12772
|
}
|
|
12615
12773
|
// Get the preferred_cache domain for the given authority
|
|
12616
12774
|
const authority = await this.getDiscoveredAuthority(request.authority);
|
|
12617
|
-
const authorityPreferredCache = authority.getPreferredCache();
|
|
12618
12775
|
// generate identifiers
|
|
12619
12776
|
const idTokenObj = this.createIdTokenObj(response);
|
|
12620
12777
|
const homeAccountIdentifier = this.createHomeAccountIdentifier(response, idTokenObj);
|
|
12621
|
-
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);
|
|
12622
12784
|
// generate authenticationResult
|
|
12623
12785
|
const result = await this.generateAuthenticationResult(response, request, idTokenObj, accountEntity, authority.canonicalAuthority, reqTimestamp);
|
|
12624
12786
|
// cache accounts and tokens in the appropriate storage
|
|
12625
12787
|
this.cacheAccount(accountEntity);
|
|
12626
|
-
this.cacheNativeTokens(response, request, homeAccountIdentifier,
|
|
12788
|
+
this.cacheNativeTokens(response, request, homeAccountIdentifier, idTokenObj, result.accessToken, result.tenantId, reqTimestamp);
|
|
12627
12789
|
return result;
|
|
12628
12790
|
}
|
|
12629
12791
|
/**
|
|
@@ -12642,20 +12804,9 @@ class NativeInteractionClient extends BaseInteractionClient {
|
|
|
12642
12804
|
*/
|
|
12643
12805
|
createHomeAccountIdentifier(response, idTokenObj) {
|
|
12644
12806
|
// Save account in browser storage
|
|
12645
|
-
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);
|
|
12646
12808
|
return homeAccountIdentifier;
|
|
12647
12809
|
}
|
|
12648
|
-
/**
|
|
12649
|
-
* Creates account entity
|
|
12650
|
-
* @param response
|
|
12651
|
-
* @param homeAccountIdentifier
|
|
12652
|
-
* @param idTokenObj
|
|
12653
|
-
* @param authority
|
|
12654
|
-
* @returns
|
|
12655
|
-
*/
|
|
12656
|
-
createAccountEntity(response, homeAccountIdentifier, idTokenObj, authority) {
|
|
12657
|
-
return AccountEntity.createAccount(response.client_info, homeAccountIdentifier, idTokenObj, undefined, undefined, undefined, authority, response.account.id);
|
|
12658
|
-
}
|
|
12659
12810
|
/**
|
|
12660
12811
|
* Helper to generate scopes
|
|
12661
12812
|
* @param response
|
|
@@ -12774,7 +12925,7 @@ class NativeInteractionClient extends BaseInteractionClient {
|
|
|
12774
12925
|
* @param tenantId
|
|
12775
12926
|
* @param reqTimestamp
|
|
12776
12927
|
*/
|
|
12777
|
-
cacheNativeTokens(response, request, homeAccountIdentifier,
|
|
12928
|
+
cacheNativeTokens(response, request, homeAccountIdentifier, idTokenObj, responseAccessToken, tenantId, reqTimestamp) {
|
|
12778
12929
|
const cachedIdToken = IdTokenEntity.createIdTokenEntity(homeAccountIdentifier, request.authority, response.id_token || Constants.EMPTY_STRING, request.clientId, idTokenObj.claims.tid || Constants.EMPTY_STRING);
|
|
12779
12930
|
// cache accessToken in inmemory storage
|
|
12780
12931
|
const expiresIn = request.tokenType === AuthenticationScheme.POP
|
|
@@ -12787,15 +12938,15 @@ class NativeInteractionClient extends BaseInteractionClient {
|
|
|
12787
12938
|
const cachedAccessToken = AccessTokenEntity.createAccessTokenEntity(homeAccountIdentifier, request.authority, responseAccessToken, request.clientId, idTokenObj
|
|
12788
12939
|
? idTokenObj.claims.tid || Constants.EMPTY_STRING
|
|
12789
12940
|
: tenantId, responseScopes.printScopes(), tokenExpirationSeconds, 0, this.browserCrypto);
|
|
12790
|
-
const nativeCacheRecord = new CacheRecord(
|
|
12791
|
-
this.nativeStorageManager.saveCacheRecord(nativeCacheRecord);
|
|
12941
|
+
const nativeCacheRecord = new CacheRecord(undefined, cachedIdToken, cachedAccessToken);
|
|
12942
|
+
this.nativeStorageManager.saveCacheRecord(nativeCacheRecord, request.storeInCache);
|
|
12792
12943
|
}
|
|
12793
12944
|
addTelemetryFromNativeResponse(response) {
|
|
12794
12945
|
const mats = this.getMATSFromResponse(response);
|
|
12795
12946
|
if (!mats) {
|
|
12796
12947
|
return null;
|
|
12797
12948
|
}
|
|
12798
|
-
this.performanceClient.
|
|
12949
|
+
this.performanceClient.addFields({
|
|
12799
12950
|
extensionId: this.nativeMessageHandler.getExtensionId(),
|
|
12800
12951
|
extensionVersion: this.nativeMessageHandler.getExtensionVersion(),
|
|
12801
12952
|
matsBrokerVersion: mats.broker_version,
|
|
@@ -13008,7 +13159,7 @@ class NativeMessageHandler {
|
|
|
13008
13159
|
method: NativeExtensionMethod.HandshakeRequest,
|
|
13009
13160
|
},
|
|
13010
13161
|
};
|
|
13011
|
-
this.handshakeEvent.
|
|
13162
|
+
this.handshakeEvent.add({
|
|
13012
13163
|
extensionId: this.extensionId,
|
|
13013
13164
|
extensionHandshakeTimeoutMs: this.handshakeTimeoutMs,
|
|
13014
13165
|
});
|
|
@@ -13026,7 +13177,7 @@ class NativeMessageHandler {
|
|
|
13026
13177
|
window.removeEventListener("message", this.windowListener, false);
|
|
13027
13178
|
this.messageChannel.port1.close();
|
|
13028
13179
|
this.messageChannel.port2.close();
|
|
13029
|
-
this.handshakeEvent.
|
|
13180
|
+
this.handshakeEvent.end({
|
|
13030
13181
|
extensionHandshakeTimedOut: true,
|
|
13031
13182
|
success: false,
|
|
13032
13183
|
});
|
|
@@ -13071,7 +13222,7 @@ class NativeMessageHandler {
|
|
|
13071
13222
|
this.messageChannel.port1.close();
|
|
13072
13223
|
this.messageChannel.port2.close();
|
|
13073
13224
|
window.removeEventListener("message", this.windowListener, false);
|
|
13074
|
-
this.handshakeEvent.
|
|
13225
|
+
this.handshakeEvent.end({
|
|
13075
13226
|
success: false,
|
|
13076
13227
|
extensionInstalled: false,
|
|
13077
13228
|
});
|
|
@@ -13123,7 +13274,7 @@ class NativeMessageHandler {
|
|
|
13123
13274
|
this.extensionId = request.extensionId;
|
|
13124
13275
|
this.extensionVersion = request.body.version;
|
|
13125
13276
|
this.logger.verbose(`NativeMessageHandler - Received HandshakeResponse from extension: ${this.extensionId}`);
|
|
13126
|
-
this.handshakeEvent.
|
|
13277
|
+
this.handshakeEvent.end({
|
|
13127
13278
|
extensionInstalled: true,
|
|
13128
13279
|
success: true,
|
|
13129
13280
|
});
|
|
@@ -13432,6 +13583,18 @@ class RedirectClient extends StandardInteractionClient {
|
|
|
13432
13583
|
this.performanceClient.setPreQueueTime(PerformanceEvents.StandardInteractionClientCreateAuthCodeClient, validLogoutRequest.correlationId);
|
|
13433
13584
|
const authClient = await this.createAuthCodeClient(serverTelemetryManager, logoutRequest && logoutRequest.authority);
|
|
13434
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
|
+
}
|
|
13435
13598
|
// Create logout string and navigate user window to logout.
|
|
13436
13599
|
const logoutUri = authClient.getLogoutUri(validLogoutRequest);
|
|
13437
13600
|
this.eventHandler.emitEvent(EventType.LOGOUT_SUCCESS, exports.InteractionType.Redirect, validLogoutRequest);
|
|
@@ -13606,7 +13769,7 @@ class PopupClient extends StandardInteractionClient {
|
|
|
13606
13769
|
this.logger.verbose("Account id found in hash, calling WAM for token");
|
|
13607
13770
|
// end measurement for server call with native brokering enabled
|
|
13608
13771
|
if (fetchNativeAccountIdMeasurement) {
|
|
13609
|
-
fetchNativeAccountIdMeasurement.
|
|
13772
|
+
fetchNativeAccountIdMeasurement.end({
|
|
13610
13773
|
success: true,
|
|
13611
13774
|
isNativeBroker: true,
|
|
13612
13775
|
});
|
|
@@ -13663,6 +13826,30 @@ class PopupClient extends StandardInteractionClient {
|
|
|
13663
13826
|
this.performanceClient.setPreQueueTime(PerformanceEvents.StandardInteractionClientCreateAuthCodeClient, validRequest.correlationId);
|
|
13664
13827
|
const authClient = await this.createAuthCodeClient(serverTelemetryManager, requestAuthority);
|
|
13665
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
|
+
}
|
|
13666
13853
|
// Create logout string and navigate user window to logout.
|
|
13667
13854
|
const logoutUri = authClient.getLogoutUri(validRequest);
|
|
13668
13855
|
this.eventHandler.emitEvent(EventType.LOGOUT_SUCCESS, exports.InteractionType.Popup, validRequest);
|
|
@@ -13747,7 +13934,7 @@ class PopupClient extends StandardInteractionClient {
|
|
|
13747
13934
|
return;
|
|
13748
13935
|
}
|
|
13749
13936
|
let href = Constants.EMPTY_STRING;
|
|
13750
|
-
let
|
|
13937
|
+
let serverResponseString = Constants.EMPTY_STRING;
|
|
13751
13938
|
try {
|
|
13752
13939
|
/*
|
|
13753
13940
|
* Will throw if cross origin,
|
|
@@ -13755,7 +13942,8 @@ class PopupClient extends StandardInteractionClient {
|
|
|
13755
13942
|
* since we need the interval to keep running while on STS UI.
|
|
13756
13943
|
*/
|
|
13757
13944
|
href = popupWindow.location.href;
|
|
13758
|
-
|
|
13945
|
+
serverResponseString =
|
|
13946
|
+
this.extractServerResponseStringFromPopup(popupWindow, href);
|
|
13759
13947
|
}
|
|
13760
13948
|
catch (e) { }
|
|
13761
13949
|
// Don't process blank pages or cross domain
|
|
@@ -13768,17 +13956,17 @@ class PopupClient extends StandardInteractionClient {
|
|
|
13768
13956
|
* as popup operations can take a long time.
|
|
13769
13957
|
*/
|
|
13770
13958
|
ticks++;
|
|
13771
|
-
if (
|
|
13959
|
+
if (serverResponseString) {
|
|
13772
13960
|
this.logger.verbose("PopupHandler.monitorPopupForHash - found hash in url");
|
|
13773
13961
|
clearInterval(intervalId);
|
|
13774
13962
|
this.cleanPopup(popupWindow);
|
|
13775
|
-
if (UrlString.hashContainsKnownProperties(
|
|
13963
|
+
if (UrlString.hashContainsKnownProperties(serverResponseString)) {
|
|
13776
13964
|
this.logger.verbose("PopupHandler.monitorPopupForHash - hash contains known properties, returning.");
|
|
13777
|
-
resolve(
|
|
13965
|
+
resolve(serverResponseString);
|
|
13778
13966
|
}
|
|
13779
13967
|
else {
|
|
13780
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.");
|
|
13781
|
-
this.logger.errorPii(`PopupHandler.monitorPopupForHash - hash found: ${
|
|
13969
|
+
this.logger.errorPii(`PopupHandler.monitorPopupForHash - hash found: ${serverResponseString}`);
|
|
13782
13970
|
reject(BrowserAuthError.createHashDoesNotContainKnownPropertiesError());
|
|
13783
13971
|
}
|
|
13784
13972
|
}
|
|
@@ -13959,6 +14147,20 @@ class PopupClient extends StandardInteractionClient {
|
|
|
13959
14147
|
const homeAccountId = request.account && request.account.homeAccountId;
|
|
13960
14148
|
return `${BrowserConstants.POPUP_NAME_PREFIX}.${this.config.auth.clientId}.${homeAccountId}.${this.correlationId}`;
|
|
13961
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
|
+
}
|
|
13962
14164
|
}
|
|
13963
14165
|
|
|
13964
14166
|
/*
|
|
@@ -14033,6 +14235,14 @@ function buildConfiguration({ auth: userInputAuth, cache: userInputCache, system
|
|
|
14033
14235
|
navigateToLoginRequestUrl: true,
|
|
14034
14236
|
clientCapabilities: [],
|
|
14035
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
|
+
},
|
|
14036
14246
|
azureCloudOptions: {
|
|
14037
14247
|
azureCloudInstance: AzureCloudInstance.None,
|
|
14038
14248
|
tenant: Constants.EMPTY_STRING,
|
|
@@ -14077,7 +14287,7 @@ function buildConfiguration({ auth: userInputAuth, cache: userInputCache, system
|
|
|
14077
14287
|
redirectNavigationTimeout: DEFAULT_REDIRECT_TIMEOUT_MS,
|
|
14078
14288
|
asyncPopups: false,
|
|
14079
14289
|
allowRedirectInIframe: false,
|
|
14080
|
-
allowNativeBroker:
|
|
14290
|
+
allowNativeBroker: false,
|
|
14081
14291
|
nativeBrokerHandshakeTimeout: userInputSystem?.nativeBrokerHandshakeTimeout ||
|
|
14082
14292
|
DEFAULT_NATIVE_BROKER_HANDSHAKE_TIMEOUT_MS,
|
|
14083
14293
|
pollIntervalMilliseconds: BrowserConstants.DEFAULT_POLL_INTERVAL_MS,
|
|
@@ -14091,9 +14301,33 @@ function buildConfiguration({ auth: userInputAuth, cache: userInputCache, system
|
|
|
14091
14301
|
appName: Constants.EMPTY_STRING,
|
|
14092
14302
|
appVersion: Constants.EMPTY_STRING,
|
|
14093
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
|
+
}),
|
|
14094
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
|
+
}
|
|
14095
14322
|
const overlayedConfig = {
|
|
14096
|
-
auth: {
|
|
14323
|
+
auth: {
|
|
14324
|
+
...DEFAULT_AUTH_OPTIONS,
|
|
14325
|
+
...userInputAuth,
|
|
14326
|
+
OIDCOptions: {
|
|
14327
|
+
...DEFAULT_AUTH_OPTIONS.OIDCOptions,
|
|
14328
|
+
...userInputAuth?.OIDCOptions,
|
|
14329
|
+
},
|
|
14330
|
+
},
|
|
14097
14331
|
cache: { ...DEFAULT_CACHE_OPTIONS, ...userInputCache },
|
|
14098
14332
|
system: { ...DEFAULT_BROWSER_SYSTEM_OPTIONS, ...providedSystemOptions },
|
|
14099
14333
|
telemetry: { ...DEFAULT_TELEMETRY_OPTIONS, ...userInputTelemetry },
|
|
@@ -14292,7 +14526,7 @@ class SilentIframeClient extends StandardInteractionClient {
|
|
|
14292
14526
|
if (request.prompt &&
|
|
14293
14527
|
request.prompt !== PromptValue.NONE &&
|
|
14294
14528
|
request.prompt !== PromptValue.NO_SESSION) {
|
|
14295
|
-
acquireTokenMeasurement.
|
|
14529
|
+
acquireTokenMeasurement.end({
|
|
14296
14530
|
success: false,
|
|
14297
14531
|
});
|
|
14298
14532
|
throw BrowserAuthError.createSilentPromptValueError(request.prompt);
|
|
@@ -14312,7 +14546,7 @@ class SilentIframeClient extends StandardInteractionClient {
|
|
|
14312
14546
|
this.logger.verbose("Auth code client created");
|
|
14313
14547
|
this.performanceClient.setPreQueueTime(PerformanceEvents.SilentIframeClientTokenHelper, request.correlationId);
|
|
14314
14548
|
return await this.silentTokenHelper(authClient, silentRequest).then((result) => {
|
|
14315
|
-
acquireTokenMeasurement.
|
|
14549
|
+
acquireTokenMeasurement.end({
|
|
14316
14550
|
success: true,
|
|
14317
14551
|
fromCache: false,
|
|
14318
14552
|
requestId: result.requestId,
|
|
@@ -14326,7 +14560,7 @@ class SilentIframeClient extends StandardInteractionClient {
|
|
|
14326
14560
|
serverTelemetryManager.cacheFailedRequest(e);
|
|
14327
14561
|
}
|
|
14328
14562
|
this.browserStorage.cleanRequestByState(silentRequest.state);
|
|
14329
|
-
acquireTokenMeasurement.
|
|
14563
|
+
acquireTokenMeasurement.end({
|
|
14330
14564
|
errorCode: (e instanceof AuthError && e.errorCode) || undefined,
|
|
14331
14565
|
subErrorCode: (e instanceof AuthError && e.subError) || undefined,
|
|
14332
14566
|
success: false,
|
|
@@ -14406,7 +14640,7 @@ class SilentRefreshClient extends StandardInteractionClient {
|
|
|
14406
14640
|
this.performanceClient.setPreQueueTime(PerformanceEvents.InitializeBaseRequest, request.correlationId);
|
|
14407
14641
|
const silentRequest = {
|
|
14408
14642
|
...request,
|
|
14409
|
-
...await this.initializeBaseRequest(request, request.account)
|
|
14643
|
+
...(await this.initializeBaseRequest(request, request.account)),
|
|
14410
14644
|
};
|
|
14411
14645
|
const acquireTokenMeasurement = this.performanceClient.startMeasurement(PerformanceEvents.SilentRefreshClientAcquireToken, silentRequest.correlationId);
|
|
14412
14646
|
const serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenSilent_silentFlow);
|
|
@@ -14418,7 +14652,7 @@ class SilentRefreshClient extends StandardInteractionClient {
|
|
|
14418
14652
|
.acquireTokenByRefreshToken(silentRequest)
|
|
14419
14653
|
.then((result) => result)
|
|
14420
14654
|
.then((result) => {
|
|
14421
|
-
acquireTokenMeasurement.
|
|
14655
|
+
acquireTokenMeasurement.end({
|
|
14422
14656
|
success: true,
|
|
14423
14657
|
fromCache: result.fromCache,
|
|
14424
14658
|
requestId: result.requestId,
|
|
@@ -14428,7 +14662,7 @@ class SilentRefreshClient extends StandardInteractionClient {
|
|
|
14428
14662
|
.catch((e) => {
|
|
14429
14663
|
e.setCorrelationId(this.correlationId);
|
|
14430
14664
|
serverTelemetryManager.cacheFailedRequest(e);
|
|
14431
|
-
acquireTokenMeasurement.
|
|
14665
|
+
acquireTokenMeasurement.end({
|
|
14432
14666
|
errorCode: e.errorCode,
|
|
14433
14667
|
subErrorCode: e.subError,
|
|
14434
14668
|
success: false,
|
|
@@ -15606,7 +15840,7 @@ class CryptoOps {
|
|
|
15606
15840
|
requestUri: request.resourceRequestUri,
|
|
15607
15841
|
});
|
|
15608
15842
|
if (publicKeyThumbMeasurement) {
|
|
15609
|
-
publicKeyThumbMeasurement.
|
|
15843
|
+
publicKeyThumbMeasurement.end({
|
|
15610
15844
|
success: true,
|
|
15611
15845
|
});
|
|
15612
15846
|
}
|
|
@@ -15662,7 +15896,7 @@ class CryptoOps {
|
|
|
15662
15896
|
const encodedSignature = this.b64Encode.urlEncodeArr(new Uint8Array(signatureBuffer));
|
|
15663
15897
|
const signedJwt = `${tokenString}.${encodedSignature}`;
|
|
15664
15898
|
if (signJwtMeasurement) {
|
|
15665
|
-
signJwtMeasurement.
|
|
15899
|
+
signJwtMeasurement.end({
|
|
15666
15900
|
success: true,
|
|
15667
15901
|
});
|
|
15668
15902
|
}
|
|
@@ -15685,231 +15919,16 @@ CryptoOps.EXTRACTABLE = true;
|
|
|
15685
15919
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
15686
15920
|
* Licensed under the MIT License.
|
|
15687
15921
|
*/
|
|
15688
|
-
|
|
15689
|
-
|
|
15690
|
-
|
|
15691
|
-
this.measureName = BrowserPerformanceMeasurement.makeMeasureName(name, correlationId);
|
|
15692
|
-
this.startMark = BrowserPerformanceMeasurement.makeStartMark(name, correlationId);
|
|
15693
|
-
this.endMark = BrowserPerformanceMeasurement.makeEndMark(name, correlationId);
|
|
15694
|
-
}
|
|
15695
|
-
static makeMeasureName(name, correlationId) {
|
|
15696
|
-
return `msal.measure.${name}.${correlationId}`;
|
|
15697
|
-
}
|
|
15698
|
-
static makeStartMark(name, correlationId) {
|
|
15699
|
-
return `msal.start.${name}.${correlationId}`;
|
|
15700
|
-
}
|
|
15701
|
-
static makeEndMark(name, correlationId) {
|
|
15702
|
-
return `msal.end.${name}.${correlationId}`;
|
|
15703
|
-
}
|
|
15704
|
-
static supportsBrowserPerformance() {
|
|
15705
|
-
return (typeof window !== "undefined" &&
|
|
15706
|
-
typeof window.performance !== "undefined" &&
|
|
15707
|
-
typeof window.performance.mark === "function" &&
|
|
15708
|
-
typeof window.performance.measure === "function" &&
|
|
15709
|
-
typeof window.performance.clearMarks === "function" &&
|
|
15710
|
-
typeof window.performance.clearMeasures === "function" &&
|
|
15711
|
-
typeof window.performance.getEntriesByName === "function");
|
|
15712
|
-
}
|
|
15713
|
-
/**
|
|
15714
|
-
* Flush browser marks and measurements.
|
|
15715
|
-
* @param {string} correlationId
|
|
15716
|
-
* @param {SubMeasurement} measurements
|
|
15717
|
-
*/
|
|
15718
|
-
static flushMeasurements(correlationId, measurements) {
|
|
15719
|
-
if (BrowserPerformanceMeasurement.supportsBrowserPerformance()) {
|
|
15720
|
-
try {
|
|
15721
|
-
measurements.forEach((measurement) => {
|
|
15722
|
-
const measureName = BrowserPerformanceMeasurement.makeMeasureName(measurement.name, correlationId);
|
|
15723
|
-
const entriesForMeasurement = window.performance.getEntriesByName(measureName, "measure");
|
|
15724
|
-
if (entriesForMeasurement.length > 0) {
|
|
15725
|
-
window.performance.clearMeasures(measureName);
|
|
15726
|
-
window.performance.clearMarks(BrowserPerformanceMeasurement.makeStartMark(measureName, correlationId));
|
|
15727
|
-
window.performance.clearMarks(BrowserPerformanceMeasurement.makeEndMark(measureName, correlationId));
|
|
15728
|
-
}
|
|
15729
|
-
});
|
|
15730
|
-
}
|
|
15731
|
-
catch (e) {
|
|
15732
|
-
// Silently catch and return null
|
|
15733
|
-
}
|
|
15734
|
-
}
|
|
15735
|
-
}
|
|
15736
|
-
startMeasurement() {
|
|
15737
|
-
if (BrowserPerformanceMeasurement.supportsBrowserPerformance()) {
|
|
15738
|
-
try {
|
|
15739
|
-
window.performance.mark(this.startMark);
|
|
15740
|
-
}
|
|
15741
|
-
catch (e) {
|
|
15742
|
-
// Silently catch
|
|
15743
|
-
}
|
|
15744
|
-
}
|
|
15745
|
-
}
|
|
15746
|
-
endMeasurement() {
|
|
15747
|
-
if (BrowserPerformanceMeasurement.supportsBrowserPerformance()) {
|
|
15748
|
-
try {
|
|
15749
|
-
window.performance.mark(this.endMark);
|
|
15750
|
-
window.performance.measure(this.measureName, this.startMark, this.endMark);
|
|
15751
|
-
}
|
|
15752
|
-
catch (e) {
|
|
15753
|
-
// Silently catch
|
|
15754
|
-
}
|
|
15755
|
-
}
|
|
15756
|
-
}
|
|
15757
|
-
flushMeasurement() {
|
|
15758
|
-
if (BrowserPerformanceMeasurement.supportsBrowserPerformance()) {
|
|
15759
|
-
try {
|
|
15760
|
-
const entriesForMeasurement = window.performance.getEntriesByName(this.measureName, "measure");
|
|
15761
|
-
if (entriesForMeasurement.length > 0) {
|
|
15762
|
-
const durationMs = entriesForMeasurement[0].duration;
|
|
15763
|
-
window.performance.clearMeasures(this.measureName);
|
|
15764
|
-
window.performance.clearMarks(this.startMark);
|
|
15765
|
-
window.performance.clearMarks(this.endMark);
|
|
15766
|
-
return durationMs;
|
|
15767
|
-
}
|
|
15768
|
-
}
|
|
15769
|
-
catch (e) {
|
|
15770
|
-
// Silently catch and return null
|
|
15771
|
-
}
|
|
15772
|
-
}
|
|
15773
|
-
return null;
|
|
15774
|
-
}
|
|
15775
|
-
}
|
|
15776
|
-
|
|
15777
|
-
/*
|
|
15778
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
15779
|
-
* Licensed under the MIT License.
|
|
15780
|
-
*/
|
|
15781
|
-
class BrowserPerformanceClient extends PerformanceClient {
|
|
15782
|
-
constructor(clientId, authority, logger, libraryName, libraryVersion, applicationTelemetry) {
|
|
15783
|
-
super(clientId, authority, logger, libraryName, libraryVersion, applicationTelemetry);
|
|
15784
|
-
this.browserCrypto = new BrowserCrypto(this.logger);
|
|
15785
|
-
this.guidGenerator = new GuidGenerator(this.browserCrypto);
|
|
15786
|
-
}
|
|
15787
|
-
startPerformanceMeasurement(measureName, correlationId) {
|
|
15788
|
-
return new BrowserPerformanceMeasurement(measureName, correlationId);
|
|
15789
|
-
}
|
|
15790
|
-
generateId() {
|
|
15791
|
-
return this.guidGenerator.generateGuid();
|
|
15792
|
-
}
|
|
15793
|
-
getPageVisibility() {
|
|
15794
|
-
return document.visibilityState?.toString() || null;
|
|
15795
|
-
}
|
|
15796
|
-
deleteIncompleteSubMeasurements(inProgressEvent) {
|
|
15797
|
-
const rootEvent = this.eventsByCorrelationId.get(inProgressEvent.event.correlationId);
|
|
15798
|
-
const isRootEvent = rootEvent && rootEvent.eventId === inProgressEvent.event.eventId;
|
|
15799
|
-
const incompleteMeasurements = [];
|
|
15800
|
-
if (isRootEvent && rootEvent?.incompleteSubMeasurements) {
|
|
15801
|
-
rootEvent.incompleteSubMeasurements.forEach((subMeasurement) => {
|
|
15802
|
-
incompleteMeasurements.push({ ...subMeasurement });
|
|
15803
|
-
});
|
|
15804
|
-
}
|
|
15805
|
-
// Clean up remaining marks for incomplete sub-measurements
|
|
15806
|
-
if (incompleteMeasurements.length > 0) {
|
|
15807
|
-
BrowserPerformanceMeasurement.flushMeasurements(inProgressEvent.event.correlationId, incompleteMeasurements);
|
|
15808
|
-
}
|
|
15809
|
-
}
|
|
15810
|
-
supportsBrowserPerformanceNow() {
|
|
15811
|
-
return (typeof window !== "undefined" &&
|
|
15812
|
-
typeof window.performance !== "undefined" &&
|
|
15813
|
-
typeof window.performance.now === "function");
|
|
15814
|
-
}
|
|
15815
|
-
/**
|
|
15816
|
-
* Starts measuring performance for a given operation. Returns a function that should be used to end the measurement.
|
|
15817
|
-
* Also captures browser page visibilityState.
|
|
15818
|
-
*
|
|
15819
|
-
* @param {PerformanceEvents} measureName
|
|
15820
|
-
* @param {?string} [correlationId]
|
|
15821
|
-
* @returns {((event?: Partial<PerformanceEvent>) => PerformanceEvent| null)}
|
|
15822
|
-
*/
|
|
15823
|
-
startMeasurement(measureName, correlationId) {
|
|
15824
|
-
// Capture page visibilityState and then invoke start/end measurement
|
|
15825
|
-
const startPageVisibility = this.getPageVisibility();
|
|
15826
|
-
const inProgressEvent = super.startMeasurement(measureName, correlationId);
|
|
15827
|
-
return {
|
|
15828
|
-
...inProgressEvent,
|
|
15829
|
-
endMeasurement: (event) => {
|
|
15830
|
-
const res = inProgressEvent.endMeasurement({
|
|
15831
|
-
startPageVisibility,
|
|
15832
|
-
endPageVisibility: this.getPageVisibility(),
|
|
15833
|
-
...event,
|
|
15834
|
-
});
|
|
15835
|
-
this.deleteIncompleteSubMeasurements(inProgressEvent);
|
|
15836
|
-
return res;
|
|
15837
|
-
},
|
|
15838
|
-
discardMeasurement: () => {
|
|
15839
|
-
inProgressEvent.discardMeasurement();
|
|
15840
|
-
this.deleteIncompleteSubMeasurements(inProgressEvent);
|
|
15841
|
-
inProgressEvent.measurement.flushMeasurement();
|
|
15842
|
-
},
|
|
15843
|
-
};
|
|
15844
|
-
}
|
|
15845
|
-
/**
|
|
15846
|
-
* Adds pre-queue time to preQueueTimeByCorrelationId map.
|
|
15847
|
-
* @param {PerformanceEvents} eventName
|
|
15848
|
-
* @param {?string} correlationId
|
|
15849
|
-
* @returns
|
|
15850
|
-
*/
|
|
15851
|
-
setPreQueueTime(eventName, correlationId) {
|
|
15852
|
-
if (!this.supportsBrowserPerformanceNow()) {
|
|
15853
|
-
this.logger.trace(`BrowserPerformanceClient: window performance API not available, unable to set telemetry queue time for ${eventName}`);
|
|
15854
|
-
return;
|
|
15855
|
-
}
|
|
15856
|
-
if (!correlationId) {
|
|
15857
|
-
this.logger.trace(`BrowserPerformanceClient: correlationId for ${eventName} not provided, unable to set telemetry queue time`);
|
|
15858
|
-
return;
|
|
15859
|
-
}
|
|
15860
|
-
const preQueueEvent = this.preQueueTimeByCorrelationId.get(correlationId);
|
|
15861
|
-
/**
|
|
15862
|
-
* Manually complete queue measurement if there is an incomplete pre-queue event.
|
|
15863
|
-
* Incomplete pre-queue events are instrumentation bugs that should be fixed.
|
|
15864
|
-
*/
|
|
15865
|
-
if (preQueueEvent) {
|
|
15866
|
-
this.logger.trace(`BrowserPerformanceClient: Incomplete pre-queue ${preQueueEvent.name} found`, correlationId);
|
|
15867
|
-
this.addQueueMeasurement(preQueueEvent.name, correlationId, undefined, true);
|
|
15868
|
-
}
|
|
15869
|
-
this.preQueueTimeByCorrelationId.set(correlationId, {
|
|
15870
|
-
name: eventName,
|
|
15871
|
-
time: window.performance.now(),
|
|
15872
|
-
});
|
|
15873
|
-
}
|
|
15874
|
-
/**
|
|
15875
|
-
* Calculates and adds queue time measurement for given performance event.
|
|
15876
|
-
*
|
|
15877
|
-
* @param {PerformanceEvents} eventName
|
|
15878
|
-
* @param {?string} correlationId
|
|
15879
|
-
* @param {?number} queueTime
|
|
15880
|
-
* @param {?boolean} manuallyCompleted - indicator for manually completed queue measurements
|
|
15881
|
-
* @returns
|
|
15882
|
-
*/
|
|
15883
|
-
addQueueMeasurement(eventName, correlationId, queueTime, manuallyCompleted) {
|
|
15884
|
-
if (!this.supportsBrowserPerformanceNow()) {
|
|
15885
|
-
this.logger.trace(`BrowserPerformanceClient: window performance API not available, unable to add queue measurement for ${eventName}`);
|
|
15886
|
-
return;
|
|
15887
|
-
}
|
|
15888
|
-
if (!correlationId) {
|
|
15889
|
-
this.logger.trace(`BrowserPerformanceClient: correlationId for ${eventName} not provided, unable to add queue measurement`);
|
|
15890
|
-
return;
|
|
15891
|
-
}
|
|
15892
|
-
const preQueueTime = super.getPreQueueTime(eventName, correlationId);
|
|
15893
|
-
if (!preQueueTime) {
|
|
15894
|
-
return;
|
|
15895
|
-
}
|
|
15896
|
-
const currentTime = window.performance.now();
|
|
15897
|
-
const resQueueTime = queueTime || super.calculateQueuedTime(preQueueTime, currentTime);
|
|
15898
|
-
return super.addQueueMeasurement(eventName, correlationId, resQueueTime, manuallyCompleted);
|
|
15899
|
-
}
|
|
15900
|
-
}
|
|
15901
|
-
|
|
15902
|
-
/*
|
|
15903
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
15904
|
-
* Licensed under the MIT License.
|
|
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.
|
|
15905
15925
|
*/
|
|
15926
|
+
// Cache Manager
|
|
15906
15927
|
|
|
15907
15928
|
var internals = /*#__PURE__*/Object.freeze({
|
|
15908
15929
|
__proto__: null,
|
|
15909
15930
|
BrowserCacheManager: BrowserCacheManager,
|
|
15910
15931
|
BrowserConstants: BrowserConstants,
|
|
15911
|
-
BrowserPerformanceClient: BrowserPerformanceClient,
|
|
15912
|
-
BrowserPerformanceMeasurement: BrowserPerformanceMeasurement,
|
|
15913
15932
|
CacheRecord: CacheRecord,
|
|
15914
15933
|
CryptoOps: CryptoOps,
|
|
15915
15934
|
EventHandler: EventHandler,
|
|
@@ -16127,8 +16146,9 @@ class TokenCache {
|
|
|
16127
16146
|
const idToken = new AuthToken(response.id_token, this.cryptoObj);
|
|
16128
16147
|
let cacheRecord;
|
|
16129
16148
|
let authority;
|
|
16149
|
+
let cacheRecordAccount;
|
|
16130
16150
|
if (request.account) {
|
|
16131
|
-
|
|
16151
|
+
cacheRecordAccount = AccountEntity.createFromAccountInfo(request.account);
|
|
16132
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));
|
|
16133
16153
|
}
|
|
16134
16154
|
else if (request.authority) {
|
|
@@ -16144,12 +16164,12 @@ class TokenCache {
|
|
|
16144
16164
|
// "clientInfo" from options takes precedence over "clientInfo" in response
|
|
16145
16165
|
if (options.clientInfo) {
|
|
16146
16166
|
this.logger.trace("TokenCache - homeAccountId from options");
|
|
16147
|
-
|
|
16167
|
+
cacheRecordAccount = this.loadAccount(idToken, authority, options.clientInfo);
|
|
16148
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));
|
|
16149
16169
|
}
|
|
16150
16170
|
else if (response.client_info) {
|
|
16151
16171
|
this.logger.trace("TokenCache - homeAccountId from response");
|
|
16152
|
-
|
|
16172
|
+
cacheRecordAccount = this.loadAccount(idToken, authority, response.client_info);
|
|
16153
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));
|
|
16154
16174
|
}
|
|
16155
16175
|
else {
|
|
@@ -16159,7 +16179,7 @@ class TokenCache {
|
|
|
16159
16179
|
else {
|
|
16160
16180
|
throw BrowserAuthError.createUnableToLoadTokenError("Please provide a request with an account or a request with authority.");
|
|
16161
16181
|
}
|
|
16162
|
-
return this.generateAuthenticationResult(request, idToken, cacheRecord, authority);
|
|
16182
|
+
return this.generateAuthenticationResult(request, idToken, cacheRecord, cacheRecordAccount, authority);
|
|
16163
16183
|
}
|
|
16164
16184
|
/**
|
|
16165
16185
|
* Helper function to load account to msal-browser cache
|
|
@@ -16170,20 +16190,23 @@ class TokenCache {
|
|
|
16170
16190
|
* @param requestHomeAccountId
|
|
16171
16191
|
* @returns `AccountEntity`
|
|
16172
16192
|
*/
|
|
16173
|
-
loadAccount(idToken,
|
|
16193
|
+
loadAccount(idToken, authority, clientInfo, requestHomeAccountId) {
|
|
16174
16194
|
let homeAccountId;
|
|
16175
16195
|
if (requestHomeAccountId) {
|
|
16176
16196
|
homeAccountId = requestHomeAccountId;
|
|
16177
16197
|
}
|
|
16178
|
-
else if (authorityType !== undefined && clientInfo) {
|
|
16179
|
-
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);
|
|
16180
16200
|
}
|
|
16181
16201
|
if (!homeAccountId) {
|
|
16182
16202
|
throw BrowserAuthError.createUnableToLoadTokenError("Unexpected missing homeAccountId");
|
|
16183
16203
|
}
|
|
16184
|
-
const accountEntity =
|
|
16185
|
-
|
|
16186
|
-
:
|
|
16204
|
+
const accountEntity = AccountEntity.createAccount({
|
|
16205
|
+
homeAccountId,
|
|
16206
|
+
idTokenClaims: idToken.claims,
|
|
16207
|
+
clientInfo,
|
|
16208
|
+
environment: authority.hostnameAndPort,
|
|
16209
|
+
}, authority);
|
|
16187
16210
|
if (this.isBrowserEnvironment) {
|
|
16188
16211
|
this.logger.verbose("TokenCache - loading account");
|
|
16189
16212
|
this.storage.setAccount(accountEntity);
|
|
@@ -16277,7 +16300,7 @@ class TokenCache {
|
|
|
16277
16300
|
* @param authority
|
|
16278
16301
|
* @returns `AuthenticationResult`
|
|
16279
16302
|
*/
|
|
16280
|
-
generateAuthenticationResult(request, idTokenObj, cacheRecord, authority) {
|
|
16303
|
+
generateAuthenticationResult(request, idTokenObj, cacheRecord, accountEntity, authority) {
|
|
16281
16304
|
let accessToken = Constants.EMPTY_STRING;
|
|
16282
16305
|
let responseScopes = [];
|
|
16283
16306
|
let expiresOn = null;
|
|
@@ -16299,7 +16322,7 @@ class TokenCache {
|
|
|
16299
16322
|
uniqueId: uid,
|
|
16300
16323
|
tenantId: tid,
|
|
16301
16324
|
scopes: responseScopes,
|
|
16302
|
-
account:
|
|
16325
|
+
account: accountEntity.getAccountInfo(),
|
|
16303
16326
|
idToken: idTokenObj ? idTokenObj.rawToken : Constants.EMPTY_STRING,
|
|
16304
16327
|
idTokenClaims: idTokenObj ? idTokenObj.claims : {},
|
|
16305
16328
|
accessToken: accessToken,
|
|
@@ -16311,9 +16334,8 @@ class TokenCache {
|
|
|
16311
16334
|
familyId: Constants.EMPTY_STRING,
|
|
16312
16335
|
tokenType: cacheRecord?.accessToken?.tokenType || Constants.EMPTY_STRING,
|
|
16313
16336
|
state: Constants.EMPTY_STRING,
|
|
16314
|
-
cloudGraphHostName:
|
|
16315
|
-
|
|
16316
|
-
msGraphHost: cacheRecord?.account?.msGraphHost || Constants.EMPTY_STRING,
|
|
16337
|
+
cloudGraphHostName: accountEntity.cloudGraphHostName || Constants.EMPTY_STRING,
|
|
16338
|
+
msGraphHost: accountEntity.msGraphHost || Constants.EMPTY_STRING,
|
|
16317
16339
|
code: undefined,
|
|
16318
16340
|
fromNativeBroker: false,
|
|
16319
16341
|
};
|
|
@@ -16439,9 +16461,7 @@ class StandardController {
|
|
|
16439
16461
|
// Initial hybrid spa map
|
|
16440
16462
|
this.hybridAuthCodeResponses = new Map();
|
|
16441
16463
|
// Initialize performance client
|
|
16442
|
-
this.performanceClient = this.
|
|
16443
|
-
? new BrowserPerformanceClient(this.config.auth.clientId, this.config.auth.authority, this.logger, name, version, this.config.telemetry.application)
|
|
16444
|
-
: new StubPerformanceClient(this.config.auth.clientId, this.config.auth.authority, this.logger, name, version, this.config.telemetry.application);
|
|
16464
|
+
this.performanceClient = this.config.telemetry.client;
|
|
16445
16465
|
// Initialize the crypto class.
|
|
16446
16466
|
this.browserCrypto = this.isBrowserEnvironment
|
|
16447
16467
|
? new CryptoOps(this.logger, this.performanceClient)
|
|
@@ -16507,7 +16527,7 @@ class StandardController {
|
|
|
16507
16527
|
}
|
|
16508
16528
|
this.initialized = true;
|
|
16509
16529
|
this.eventHandler.emitEvent(EventType.INITIALIZE_END);
|
|
16510
|
-
initMeasurement.
|
|
16530
|
+
initMeasurement.end({ allowNativeBroker, success: true });
|
|
16511
16531
|
}
|
|
16512
16532
|
// #region Redirect Flow
|
|
16513
16533
|
/**
|
|
@@ -16519,8 +16539,14 @@ class StandardController {
|
|
|
16519
16539
|
*/
|
|
16520
16540
|
async handleRedirectPromise(hash) {
|
|
16521
16541
|
this.logger.verbose("handleRedirectPromise called");
|
|
16522
|
-
// Block token acquisition before initialize has been called
|
|
16523
|
-
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
|
+
}
|
|
16524
16550
|
const loggedInAccounts = this.getAllAccounts();
|
|
16525
16551
|
if (this.isBrowserEnvironment) {
|
|
16526
16552
|
/**
|
|
@@ -16528,7 +16554,7 @@ class StandardController {
|
|
|
16528
16554
|
* otherwise return the promise from the first invocation. Prevents race conditions when handleRedirectPromise is called
|
|
16529
16555
|
* several times concurrently.
|
|
16530
16556
|
*/
|
|
16531
|
-
const redirectResponseKey =
|
|
16557
|
+
const redirectResponseKey = foundServerResponse || Constants.EMPTY_STRING;
|
|
16532
16558
|
let response = this.redirectResponse.get(redirectResponseKey);
|
|
16533
16559
|
if (typeof response === "undefined") {
|
|
16534
16560
|
this.eventHandler.emitEvent(EventType.HANDLE_REDIRECT_START, exports.InteractionType.Redirect);
|
|
@@ -16538,7 +16564,7 @@ class StandardController {
|
|
|
16538
16564
|
if (request &&
|
|
16539
16565
|
NativeMessageHandler.isNativeAvailable(this.config, this.logger, this.nativeExtensionProvider) &&
|
|
16540
16566
|
this.nativeExtensionProvider &&
|
|
16541
|
-
!
|
|
16567
|
+
!foundServerResponse) {
|
|
16542
16568
|
this.logger.trace("handleRedirectPromise - acquiring token from native platform");
|
|
16543
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);
|
|
16544
16570
|
redirectResponse = nativeClient.handleRedirectPromise();
|
|
@@ -16548,7 +16574,7 @@ class StandardController {
|
|
|
16548
16574
|
const correlationId = this.browserStorage.getTemporaryCache(TemporaryCacheKeys.CORRELATION_ID, true) || Constants.EMPTY_STRING;
|
|
16549
16575
|
const redirectClient = this.createRedirectClient(correlationId);
|
|
16550
16576
|
redirectResponse =
|
|
16551
|
-
redirectClient.handleRedirectPromise(
|
|
16577
|
+
redirectClient.handleRedirectPromise(foundServerResponse);
|
|
16552
16578
|
}
|
|
16553
16579
|
response = redirectResponse
|
|
16554
16580
|
.then((result) => {
|
|
@@ -16679,7 +16705,7 @@ class StandardController {
|
|
|
16679
16705
|
result = this.acquireTokenNative(request, ApiId.acquireTokenPopup)
|
|
16680
16706
|
.then((response) => {
|
|
16681
16707
|
this.browserStorage.setInteractionInProgress(false);
|
|
16682
|
-
atPopupMeasurement.
|
|
16708
|
+
atPopupMeasurement.end({
|
|
16683
16709
|
success: true,
|
|
16684
16710
|
isNativeBroker: true,
|
|
16685
16711
|
requestId: response.requestId,
|
|
@@ -16717,11 +16743,11 @@ class StandardController {
|
|
|
16717
16743
|
else {
|
|
16718
16744
|
this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_SUCCESS, exports.InteractionType.Popup, result);
|
|
16719
16745
|
}
|
|
16720
|
-
atPopupMeasurement.
|
|
16746
|
+
atPopupMeasurement.add({
|
|
16721
16747
|
accessTokenSize: result.accessToken.length,
|
|
16722
16748
|
idTokenSize: result.idToken.length,
|
|
16723
16749
|
});
|
|
16724
|
-
atPopupMeasurement.
|
|
16750
|
+
atPopupMeasurement.end({
|
|
16725
16751
|
success: true,
|
|
16726
16752
|
requestId: result.requestId,
|
|
16727
16753
|
});
|
|
@@ -16734,7 +16760,7 @@ class StandardController {
|
|
|
16734
16760
|
else {
|
|
16735
16761
|
this.eventHandler.emitEvent(EventType.LOGIN_FAILURE, exports.InteractionType.Popup, null, e);
|
|
16736
16762
|
}
|
|
16737
|
-
atPopupMeasurement.
|
|
16763
|
+
atPopupMeasurement.end({
|
|
16738
16764
|
errorCode: e.errorCode,
|
|
16739
16765
|
subErrorCode: e.subError,
|
|
16740
16766
|
success: false,
|
|
@@ -16806,11 +16832,11 @@ class StandardController {
|
|
|
16806
16832
|
return result
|
|
16807
16833
|
.then((response) => {
|
|
16808
16834
|
this.eventHandler.emitEvent(EventType.SSO_SILENT_SUCCESS, exports.InteractionType.Silent, response);
|
|
16809
|
-
this.ssoSilentMeasurement?.
|
|
16835
|
+
this.ssoSilentMeasurement?.add({
|
|
16810
16836
|
accessTokenSize: response.accessToken.length,
|
|
16811
16837
|
idTokenSize: response.idToken.length,
|
|
16812
16838
|
});
|
|
16813
|
-
this.ssoSilentMeasurement?.
|
|
16839
|
+
this.ssoSilentMeasurement?.end({
|
|
16814
16840
|
success: true,
|
|
16815
16841
|
isNativeBroker: response.fromNativeBroker,
|
|
16816
16842
|
requestId: response.requestId,
|
|
@@ -16819,7 +16845,7 @@ class StandardController {
|
|
|
16819
16845
|
})
|
|
16820
16846
|
.catch((e) => {
|
|
16821
16847
|
this.eventHandler.emitEvent(EventType.SSO_SILENT_FAILURE, exports.InteractionType.Silent, null, e);
|
|
16822
|
-
this.ssoSilentMeasurement?.
|
|
16848
|
+
this.ssoSilentMeasurement?.end({
|
|
16823
16849
|
errorCode: e.errorCode,
|
|
16824
16850
|
subErrorCode: e.subError,
|
|
16825
16851
|
success: false,
|
|
@@ -16863,11 +16889,11 @@ class StandardController {
|
|
|
16863
16889
|
.then((result) => {
|
|
16864
16890
|
this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_BY_CODE_SUCCESS, exports.InteractionType.Silent, result);
|
|
16865
16891
|
this.hybridAuthCodeResponses.delete(hybridAuthCode);
|
|
16866
|
-
atbcMeasurement.
|
|
16892
|
+
atbcMeasurement.add({
|
|
16867
16893
|
accessTokenSize: result.accessToken.length,
|
|
16868
16894
|
idTokenSize: result.idToken.length,
|
|
16869
16895
|
});
|
|
16870
|
-
atbcMeasurement.
|
|
16896
|
+
atbcMeasurement.end({
|
|
16871
16897
|
success: true,
|
|
16872
16898
|
isNativeBroker: result.fromNativeBroker,
|
|
16873
16899
|
requestId: result.requestId,
|
|
@@ -16877,7 +16903,7 @@ class StandardController {
|
|
|
16877
16903
|
.catch((error) => {
|
|
16878
16904
|
this.hybridAuthCodeResponses.delete(hybridAuthCode);
|
|
16879
16905
|
this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_BY_CODE_FAILURE, exports.InteractionType.Silent, null, error);
|
|
16880
|
-
atbcMeasurement.
|
|
16906
|
+
atbcMeasurement.end({
|
|
16881
16907
|
errorCode: error.errorCode,
|
|
16882
16908
|
subErrorCode: error.subError,
|
|
16883
16909
|
success: false,
|
|
@@ -16888,7 +16914,7 @@ class StandardController {
|
|
|
16888
16914
|
}
|
|
16889
16915
|
else {
|
|
16890
16916
|
this.logger.verbose("Existing acquireTokenByCode request found", request.correlationId);
|
|
16891
|
-
atbcMeasurement.
|
|
16917
|
+
atbcMeasurement.discard();
|
|
16892
16918
|
}
|
|
16893
16919
|
return response;
|
|
16894
16920
|
}
|
|
@@ -16912,7 +16938,7 @@ class StandardController {
|
|
|
16912
16938
|
}
|
|
16913
16939
|
catch (e) {
|
|
16914
16940
|
this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_BY_CODE_FAILURE, exports.InteractionType.Silent, null, e);
|
|
16915
|
-
atbcMeasurement.
|
|
16941
|
+
atbcMeasurement.end({
|
|
16916
16942
|
errorCode: (e instanceof AuthError && e.errorCode) || undefined,
|
|
16917
16943
|
subErrorCode: (e instanceof AuthError && e.subError) || undefined,
|
|
16918
16944
|
success: false,
|
|
@@ -16937,7 +16963,7 @@ class StandardController {
|
|
|
16937
16963
|
const silentTokenResult = await silentAuthCodeClient
|
|
16938
16964
|
.acquireToken(request)
|
|
16939
16965
|
.then((response) => {
|
|
16940
|
-
this.acquireTokenByCodeAsyncMeasurement?.
|
|
16966
|
+
this.acquireTokenByCodeAsyncMeasurement?.end({
|
|
16941
16967
|
success: true,
|
|
16942
16968
|
fromCache: response.fromCache,
|
|
16943
16969
|
isNativeBroker: response.fromNativeBroker,
|
|
@@ -16946,7 +16972,7 @@ class StandardController {
|
|
|
16946
16972
|
return response;
|
|
16947
16973
|
})
|
|
16948
16974
|
.catch((tokenRenewalError) => {
|
|
16949
|
-
this.acquireTokenByCodeAsyncMeasurement?.
|
|
16975
|
+
this.acquireTokenByCodeAsyncMeasurement?.end({
|
|
16950
16976
|
errorCode: tokenRenewalError.errorCode,
|
|
16951
16977
|
subErrorCode: tokenRenewalError.subError,
|
|
16952
16978
|
success: false,
|
|
@@ -17156,6 +17182,26 @@ class StandardController {
|
|
|
17156
17182
|
return this.browserStorage.getActiveAccount();
|
|
17157
17183
|
}
|
|
17158
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
|
+
}
|
|
17159
17205
|
// #region Helpers
|
|
17160
17206
|
/**
|
|
17161
17207
|
* Helper to validate app environment before making an auth request
|
|
@@ -17174,13 +17220,8 @@ class StandardController {
|
|
|
17174
17220
|
BrowserUtils.blockReloadInHiddenIframes();
|
|
17175
17221
|
// Block redirectUri opened in a popup from calling MSAL APIs
|
|
17176
17222
|
BrowserUtils.blockAcquireTokenInPopups();
|
|
17177
|
-
|
|
17178
|
-
|
|
17179
|
-
* Skip check if application is embedded.
|
|
17180
|
-
*/
|
|
17181
|
-
if (!isAppEmbedded) {
|
|
17182
|
-
BrowserUtils.blockNativeBrokerCalledBeforeInitialized(this.config.system.allowNativeBroker, this.initialized);
|
|
17183
|
-
}
|
|
17223
|
+
// Block token acquisition before initialize has been called
|
|
17224
|
+
BrowserUtils.blockAPICallsBeforeInitialize(this.initialized);
|
|
17184
17225
|
// Block redirects if memory storage is enabled but storeAuthStateInCookie is not
|
|
17185
17226
|
if (interactionType === exports.InteractionType.Redirect &&
|
|
17186
17227
|
this.config.cache.cacheLocation ===
|
|
@@ -17506,7 +17547,7 @@ class StandardController {
|
|
|
17506
17547
|
async acquireTokenSilent(request) {
|
|
17507
17548
|
const correlationId = this.getRequestCorrelationId(request);
|
|
17508
17549
|
const atsMeasurement = this.performanceClient.startMeasurement(PerformanceEvents.AcquireTokenSilent, correlationId);
|
|
17509
|
-
atsMeasurement.
|
|
17550
|
+
atsMeasurement.add({
|
|
17510
17551
|
cacheLookupPolicy: request.cacheLookupPolicy,
|
|
17511
17552
|
});
|
|
17512
17553
|
this.preflightBrowserEnvironmentCheck(exports.InteractionType.Silent);
|
|
@@ -17538,11 +17579,11 @@ class StandardController {
|
|
|
17538
17579
|
}, account)
|
|
17539
17580
|
.then((result) => {
|
|
17540
17581
|
this.activeSilentTokenRequests.delete(silentRequestKey);
|
|
17541
|
-
atsMeasurement.
|
|
17582
|
+
atsMeasurement.add({
|
|
17542
17583
|
accessTokenSize: result.accessToken.length,
|
|
17543
17584
|
idTokenSize: result.idToken.length,
|
|
17544
17585
|
});
|
|
17545
|
-
atsMeasurement.
|
|
17586
|
+
atsMeasurement.end({
|
|
17546
17587
|
success: true,
|
|
17547
17588
|
fromCache: result.fromCache,
|
|
17548
17589
|
isNativeBroker: result.fromNativeBroker,
|
|
@@ -17553,7 +17594,7 @@ class StandardController {
|
|
|
17553
17594
|
})
|
|
17554
17595
|
.catch((error) => {
|
|
17555
17596
|
this.activeSilentTokenRequests.delete(silentRequestKey);
|
|
17556
|
-
atsMeasurement.
|
|
17597
|
+
atsMeasurement.end({
|
|
17557
17598
|
errorCode: error.errorCode,
|
|
17558
17599
|
subErrorCode: error.subError,
|
|
17559
17600
|
success: false,
|
|
@@ -17566,7 +17607,7 @@ class StandardController {
|
|
|
17566
17607
|
else {
|
|
17567
17608
|
this.logger.verbose("acquireTokenSilent has been called previously, returning the result from the first call", correlationId);
|
|
17568
17609
|
// Discard measurements for memoized calls, as they are usually only a couple of ms and will artificially deflate metrics
|
|
17569
|
-
atsMeasurement.
|
|
17610
|
+
atsMeasurement.discard();
|
|
17570
17611
|
return cachedResponse;
|
|
17571
17612
|
}
|
|
17572
17613
|
}
|
|
@@ -17650,7 +17691,7 @@ class StandardController {
|
|
|
17650
17691
|
return result
|
|
17651
17692
|
.then((response) => {
|
|
17652
17693
|
this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_SUCCESS, exports.InteractionType.Silent, response);
|
|
17653
|
-
this.atsAsyncMeasurement?.
|
|
17694
|
+
this.atsAsyncMeasurement?.end({
|
|
17654
17695
|
success: true,
|
|
17655
17696
|
fromCache: response.fromCache,
|
|
17656
17697
|
isNativeBroker: response.fromNativeBroker,
|
|
@@ -17660,7 +17701,7 @@ class StandardController {
|
|
|
17660
17701
|
})
|
|
17661
17702
|
.catch((tokenRenewalError) => {
|
|
17662
17703
|
this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_FAILURE, exports.InteractionType.Silent, null, tokenRenewalError);
|
|
17663
|
-
this.atsAsyncMeasurement?.
|
|
17704
|
+
this.atsAsyncMeasurement?.end({
|
|
17664
17705
|
errorCode: tokenRenewalError.errorCode,
|
|
17665
17706
|
subErrorCode: tokenRenewalError.subError,
|
|
17666
17707
|
success: false,
|
|
@@ -17984,6 +18025,15 @@ class PublicClientApplication {
|
|
|
17984
18025
|
getConfiguration() {
|
|
17985
18026
|
return this.controller.getConfiguration();
|
|
17986
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
|
+
}
|
|
17987
18037
|
}
|
|
17988
18038
|
|
|
17989
18039
|
/*
|
|
@@ -18081,6 +18131,9 @@ const stubbedPublicClientApplication = {
|
|
|
18081
18131
|
getConfiguration: () => {
|
|
18082
18132
|
throw BrowserConfigurationAuthError.createStubPcaInstanceCalledError();
|
|
18083
18133
|
},
|
|
18134
|
+
hydrateCache: () => {
|
|
18135
|
+
return Promise.reject(BrowserConfigurationAuthError.createStubPcaInstanceCalledError());
|
|
18136
|
+
},
|
|
18084
18137
|
};
|
|
18085
18138
|
|
|
18086
18139
|
/*
|
|
@@ -18192,6 +18245,227 @@ class SignedHttpRequest {
|
|
|
18192
18245
|
}
|
|
18193
18246
|
}
|
|
18194
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
|
+
|
|
18195
18469
|
exports.AccountEntity = AccountEntity;
|
|
18196
18470
|
exports.ApiId = ApiId;
|
|
18197
18471
|
exports.AuthError = AuthError;
|
|
@@ -18204,6 +18478,8 @@ exports.BrowserAuthErrorMessage = BrowserAuthErrorMessage;
|
|
|
18204
18478
|
exports.BrowserCacheLocation = BrowserCacheLocation;
|
|
18205
18479
|
exports.BrowserConfigurationAuthError = BrowserConfigurationAuthError;
|
|
18206
18480
|
exports.BrowserConfigurationAuthErrorMessage = BrowserConfigurationAuthErrorMessage;
|
|
18481
|
+
exports.BrowserPerformanceClient = BrowserPerformanceClient;
|
|
18482
|
+
exports.BrowserPerformanceMeasurement = BrowserPerformanceMeasurement;
|
|
18207
18483
|
exports.BrowserUtils = BrowserUtils;
|
|
18208
18484
|
exports.CacheLookupPolicy = CacheLookupPolicy;
|
|
18209
18485
|
exports.ClientAuthError = ClientAuthError;
|
|
@@ -18224,6 +18500,7 @@ exports.PromptValue = PromptValue;
|
|
|
18224
18500
|
exports.ProtocolMode = ProtocolMode;
|
|
18225
18501
|
exports.PublicClientApplication = PublicClientApplication;
|
|
18226
18502
|
exports.ServerError = ServerError;
|
|
18503
|
+
exports.ServerResponseType = ServerResponseType;
|
|
18227
18504
|
exports.SignedHttpRequest = SignedHttpRequest;
|
|
18228
18505
|
exports.StringUtils = StringUtils;
|
|
18229
18506
|
exports.UrlString = UrlString;
|