@azure/msal-common 14.0.0-beta.1 → 14.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/dist/account/AccountInfo.d.ts +1 -0
- package/dist/account/AccountInfo.d.ts.map +1 -1
- package/dist/account/AuthToken.js +1 -1
- package/dist/account/CcsCredential.d.ts +1 -1
- package/dist/account/CcsCredential.d.ts.map +1 -1
- package/dist/account/CcsCredential.js +1 -1
- package/dist/account/ClientInfo.js +1 -1
- package/dist/authority/Authority.d.ts +6 -1
- package/dist/authority/Authority.d.ts.map +1 -1
- package/dist/authority/Authority.js +117 -59
- package/dist/authority/Authority.js.map +1 -1
- package/dist/authority/AuthorityFactory.d.ts.map +1 -1
- package/dist/authority/AuthorityFactory.js +1 -1
- package/dist/authority/AuthorityFactory.js.map +1 -1
- package/dist/authority/AuthorityMetadata.d.ts +1 -0
- package/dist/authority/AuthorityMetadata.d.ts.map +1 -1
- package/dist/authority/AuthorityMetadata.js +10 -2
- package/dist/authority/AuthorityMetadata.js.map +1 -1
- package/dist/authority/AuthorityOptions.d.ts +3 -1
- package/dist/authority/AuthorityOptions.d.ts.map +1 -1
- package/dist/authority/AuthorityOptions.js +3 -3
- package/dist/authority/AuthorityOptions.js.map +1 -1
- package/dist/authority/AuthorityType.d.ts +1 -1
- package/dist/authority/AuthorityType.d.ts.map +1 -1
- package/dist/authority/AuthorityType.js +2 -2
- package/dist/authority/CloudInstanceDiscoveryErrorResponse.js +1 -1
- package/dist/authority/CloudInstanceDiscoveryResponse.js +1 -1
- package/dist/authority/OIDCOptions.d.ts +9 -0
- package/dist/authority/OIDCOptions.d.ts.map +1 -0
- package/dist/authority/OpenIdConfigResponse.js +1 -1
- package/dist/authority/ProtocolMode.d.ts +1 -1
- package/dist/authority/ProtocolMode.d.ts.map +1 -1
- package/dist/authority/ProtocolMode.js +1 -1
- package/dist/authority/RegionDiscovery.js +1 -1
- package/dist/cache/CacheManager.d.ts +2 -1
- package/dist/cache/CacheManager.d.ts.map +1 -1
- package/dist/cache/CacheManager.js +6 -5
- package/dist/cache/CacheManager.js.map +1 -1
- package/dist/cache/entities/AccessTokenEntity.js +1 -1
- package/dist/cache/entities/AccountEntity.d.ts +18 -17
- package/dist/cache/entities/AccountEntity.d.ts.map +1 -1
- package/dist/cache/entities/AccountEntity.js +60 -87
- package/dist/cache/entities/AccountEntity.js.map +1 -1
- package/dist/cache/entities/AppMetadataEntity.js +1 -1
- package/dist/cache/entities/AuthorityMetadataEntity.js +1 -1
- package/dist/cache/entities/CacheRecord.js +1 -1
- package/dist/cache/entities/CredentialEntity.js +1 -1
- package/dist/cache/entities/IdTokenEntity.js +1 -1
- package/dist/cache/entities/RefreshTokenEntity.js +1 -1
- package/dist/cache/entities/ServerTelemetryEntity.js +1 -1
- package/dist/cache/entities/ThrottlingEntity.js +1 -1
- package/dist/cache/interface/ICacheManager.d.ts +2 -1
- package/dist/cache/interface/ICacheManager.d.ts.map +1 -1
- package/dist/cache/persistence/TokenCacheContext.js +1 -1
- package/dist/client/AuthorizationCodeClient.d.ts +1 -0
- package/dist/client/AuthorizationCodeClient.d.ts.map +1 -1
- package/dist/client/AuthorizationCodeClient.js +15 -12
- package/dist/client/AuthorizationCodeClient.js.map +1 -1
- package/dist/client/BaseClient.js +1 -1
- package/dist/client/RefreshTokenClient.d.ts.map +1 -1
- package/dist/client/RefreshTokenClient.js +14 -13
- package/dist/client/RefreshTokenClient.js.map +1 -1
- package/dist/client/SilentFlowClient.js +1 -1
- package/dist/config/ClientConfiguration.d.ts +5 -0
- package/dist/config/ClientConfiguration.d.ts.map +1 -1
- package/dist/config/ClientConfiguration.js +10 -2
- package/dist/config/ClientConfiguration.js.map +1 -1
- package/dist/crypto/ICrypto.js +1 -1
- package/dist/crypto/JoseHeader.js +1 -1
- package/dist/crypto/PopTokenGenerator.d.ts +1 -1
- package/dist/crypto/PopTokenGenerator.d.ts.map +1 -1
- package/dist/crypto/PopTokenGenerator.js +1 -1
- package/dist/error/AuthError.js +1 -1
- package/dist/error/ClientAuthError.js +1 -1
- package/dist/error/ClientConfigurationError.d.ts +16 -0
- package/dist/error/ClientConfigurationError.d.ts.map +1 -1
- package/dist/error/ClientConfigurationError.js +24 -4
- package/dist/error/ClientConfigurationError.js.map +1 -1
- package/dist/error/InteractionRequiredAuthError.js +1 -1
- package/dist/error/JoseHeaderError.js +1 -1
- package/dist/error/ServerError.js +1 -1
- package/dist/index.cjs.js +405 -257
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/logger/Logger.js +1 -1
- package/dist/network/INetworkModule.js +1 -1
- package/dist/network/NetworkManager.js +1 -1
- package/dist/network/ThrottlingUtils.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/request/AuthenticationHeaderParser.js +1 -1
- package/dist/request/BaseAuthRequest.d.ts +3 -0
- package/dist/request/BaseAuthRequest.d.ts.map +1 -1
- package/dist/request/RequestParameterBuilder.d.ts +1 -1
- package/dist/request/RequestParameterBuilder.d.ts.map +1 -1
- package/dist/request/RequestParameterBuilder.js +10 -4
- package/dist/request/RequestParameterBuilder.js.map +1 -1
- package/dist/request/RequestValidator.js +2 -2
- package/dist/request/RequestValidator.js.map +1 -1
- package/dist/request/ScopeSet.js +1 -1
- package/dist/request/StoreInCache.d.ts +9 -0
- package/dist/request/StoreInCache.d.ts.map +1 -0
- package/dist/response/ResponseHandler.d.ts +0 -7
- package/dist/response/ResponseHandler.d.ts.map +1 -1
- package/dist/response/ResponseHandler.js +28 -38
- package/dist/response/ResponseHandler.js.map +1 -1
- package/dist/telemetry/performance/IPerformanceClient.d.ts +16 -7
- package/dist/telemetry/performance/IPerformanceClient.d.ts.map +1 -1
- package/dist/telemetry/performance/PerformanceClient.d.ts +14 -12
- package/dist/telemetry/performance/PerformanceClient.d.ts.map +1 -1
- package/dist/telemetry/performance/PerformanceClient.js +25 -23
- package/dist/telemetry/performance/PerformanceClient.js.map +1 -1
- package/dist/telemetry/performance/PerformanceEvent.d.ts +80 -95
- package/dist/telemetry/performance/PerformanceEvent.d.ts.map +1 -1
- package/dist/telemetry/performance/PerformanceEvent.js +2 -1
- package/dist/telemetry/performance/PerformanceEvent.js.map +1 -1
- package/dist/telemetry/performance/StubPerformanceClient.d.ts +9 -0
- package/dist/telemetry/performance/StubPerformanceClient.d.ts.map +1 -1
- package/dist/telemetry/performance/StubPerformanceClient.js +40 -6
- package/dist/telemetry/performance/StubPerformanceClient.js.map +1 -1
- package/dist/telemetry/server/ServerTelemetryManager.js +1 -1
- package/dist/url/UrlString.d.ts +13 -0
- package/dist/url/UrlString.d.ts.map +1 -1
- package/dist/url/UrlString.js +41 -2
- package/dist/url/UrlString.js.map +1 -1
- package/dist/utils/Constants.d.ts +29 -21
- package/dist/utils/Constants.d.ts.map +1 -1
- package/dist/utils/Constants.js +10 -4
- package/dist/utils/Constants.js.map +1 -1
- package/dist/utils/ProtocolUtils.js +1 -1
- package/dist/utils/StringUtils.js +1 -1
- package/dist/utils/TimeUtils.js +1 -1
- package/package.json +12 -7
package/dist/index.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @azure/msal-common v14.0.0
|
|
1
|
+
/*! @azure/msal-common v14.0.0 2023-08-08 */
|
|
2
2
|
'use strict';
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
@@ -198,11 +198,17 @@ const CodeChallengeMethodValues = {
|
|
|
198
198
|
S256: "S256",
|
|
199
199
|
};
|
|
200
200
|
/**
|
|
201
|
-
* allowed values for
|
|
201
|
+
* allowed values for server response type
|
|
202
202
|
*/
|
|
203
|
-
const
|
|
203
|
+
const ServerResponseType = {
|
|
204
204
|
QUERY: "query",
|
|
205
205
|
FRAGMENT: "fragment",
|
|
206
|
+
};
|
|
207
|
+
/**
|
|
208
|
+
* allowed values for response_mode
|
|
209
|
+
*/
|
|
210
|
+
const ResponseMode = {
|
|
211
|
+
...ServerResponseType,
|
|
206
212
|
FORM_POST: "form_post",
|
|
207
213
|
};
|
|
208
214
|
/**
|
|
@@ -1296,7 +1302,7 @@ class Logger {
|
|
|
1296
1302
|
|
|
1297
1303
|
/* eslint-disable header/header */
|
|
1298
1304
|
const name = "@azure/msal-common";
|
|
1299
|
-
const version = "14.0.0
|
|
1305
|
+
const version = "14.0.0";
|
|
1300
1306
|
|
|
1301
1307
|
/*
|
|
1302
1308
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1309,9 +1315,9 @@ const AzureCloudInstance = {
|
|
|
1309
1315
|
AzurePublic: "https://login.microsoftonline.com",
|
|
1310
1316
|
// Microsoft PPE
|
|
1311
1317
|
AzurePpe: "https://login.windows-ppe.net",
|
|
1312
|
-
// Microsoft Chinese national cloud
|
|
1318
|
+
// Microsoft Chinese national/regional cloud
|
|
1313
1319
|
AzureChina: "https://login.chinacloudapi.cn",
|
|
1314
|
-
// Microsoft German national cloud ("Black Forest")
|
|
1320
|
+
// Microsoft German national/regional cloud ("Black Forest")
|
|
1315
1321
|
AzureGermany: "https://login.microsoftonline.de",
|
|
1316
1322
|
// US Government cloud
|
|
1317
1323
|
AzureUsGovernment: "https://login.microsoftonline.us",
|
|
@@ -1415,12 +1421,20 @@ const ClientConfigurationErrorMessage = {
|
|
|
1415
1421
|
},
|
|
1416
1422
|
invalidAuthenticationHeader: {
|
|
1417
1423
|
code: "invalid_authentication_header",
|
|
1418
|
-
desc: "Invalid authentication header provided"
|
|
1424
|
+
desc: "Invalid authentication header provided",
|
|
1425
|
+
},
|
|
1426
|
+
cannotSetOIDCOptions: {
|
|
1427
|
+
code: "cannot_set_OIDCOptions",
|
|
1428
|
+
desc: "Cannot set OIDCOptions parameter. Please change the protocol mode to OIDC or use a non-Microsoft authority.",
|
|
1429
|
+
},
|
|
1430
|
+
cannotAllowNativeBroker: {
|
|
1431
|
+
code: "cannot_allow_native_broker",
|
|
1432
|
+
desc: "Cannot set allowNativeBroker parameter to true when not in AAD protocol mode.",
|
|
1419
1433
|
},
|
|
1420
1434
|
authorityMismatch: {
|
|
1421
1435
|
code: "authority_mismatch",
|
|
1422
|
-
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."
|
|
1423
|
-
}
|
|
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
|
+
},
|
|
1424
1438
|
};
|
|
1425
1439
|
/**
|
|
1426
1440
|
* Error thrown when there is an error in configuration of the MSAL.js library.
|
|
@@ -1569,6 +1583,18 @@ class ClientConfigurationError extends ClientAuthError {
|
|
|
1569
1583
|
static createInvalidAuthenticationHeaderError(invalidHeaderName, details) {
|
|
1570
1584
|
return new ClientConfigurationError(ClientConfigurationErrorMessage.invalidAuthenticationHeader.code, `${ClientConfigurationErrorMessage.invalidAuthenticationHeader.desc}. Invalid header: ${invalidHeaderName}. Details: ${details}`);
|
|
1571
1585
|
}
|
|
1586
|
+
/**
|
|
1587
|
+
* Throws error when provided non-default OIDCOptions when not in OIDC protocol mode
|
|
1588
|
+
*/
|
|
1589
|
+
static createCannotSetOIDCOptionsError() {
|
|
1590
|
+
return new ClientConfigurationError(ClientConfigurationErrorMessage.cannotSetOIDCOptions.code, ClientConfigurationErrorMessage.cannotSetOIDCOptions.desc);
|
|
1591
|
+
}
|
|
1592
|
+
/**
|
|
1593
|
+
* Throws error when allowNativeBroker is set to true when not in AAD protocol mode
|
|
1594
|
+
*/
|
|
1595
|
+
static createCannotAllowNativeBrokerError() {
|
|
1596
|
+
return new ClientConfigurationError(ClientConfigurationErrorMessage.cannotAllowNativeBroker.code, ClientConfigurationErrorMessage.cannotAllowNativeBroker.desc);
|
|
1597
|
+
}
|
|
1572
1598
|
/**
|
|
1573
1599
|
* Create an error when the authority provided in request does not match authority provided in account or MSAL.js configuration.
|
|
1574
1600
|
*/
|
|
@@ -1824,7 +1850,19 @@ const AuthorityType = {
|
|
|
1824
1850
|
Default: 0,
|
|
1825
1851
|
Adfs: 1,
|
|
1826
1852
|
Dsts: 2,
|
|
1827
|
-
Ciam: 3
|
|
1853
|
+
Ciam: 3,
|
|
1854
|
+
};
|
|
1855
|
+
|
|
1856
|
+
/*
|
|
1857
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1858
|
+
* Licensed under the MIT License.
|
|
1859
|
+
*/
|
|
1860
|
+
/**
|
|
1861
|
+
* Protocol modes supported by MSAL.
|
|
1862
|
+
*/
|
|
1863
|
+
const ProtocolMode = {
|
|
1864
|
+
AAD: "AAD",
|
|
1865
|
+
OIDC: "OIDC",
|
|
1828
1866
|
};
|
|
1829
1867
|
|
|
1830
1868
|
/*
|
|
@@ -1847,7 +1885,6 @@ const AuthorityType = {
|
|
|
1847
1885
|
* username: primary username that represents the user, usually corresponds to preferred_username in the v2 endpt
|
|
1848
1886
|
* authorityType: Accounts authority type as a string
|
|
1849
1887
|
* name: Full name for the account, including given name and family name,
|
|
1850
|
-
* clientInfo: Full base64 encoded client info received from ESTS
|
|
1851
1888
|
* lastModificationTime: last time this entity was modified in the cache
|
|
1852
1889
|
* lastModificationApp:
|
|
1853
1890
|
* idTokenClaims: Object containing claims parsed from ID token
|
|
@@ -1874,24 +1911,6 @@ class AccountEntity {
|
|
|
1874
1911
|
localAccountId: this.localAccountId,
|
|
1875
1912
|
});
|
|
1876
1913
|
}
|
|
1877
|
-
/**
|
|
1878
|
-
* returns the type of the cache (in this case account)
|
|
1879
|
-
*/
|
|
1880
|
-
generateType() {
|
|
1881
|
-
switch (this.authorityType) {
|
|
1882
|
-
case CacheAccountType.ADFS_ACCOUNT_TYPE:
|
|
1883
|
-
return CacheType.ADFS;
|
|
1884
|
-
case CacheAccountType.MSAV1_ACCOUNT_TYPE:
|
|
1885
|
-
return CacheType.MSA;
|
|
1886
|
-
case CacheAccountType.MSSTS_ACCOUNT_TYPE:
|
|
1887
|
-
return CacheType.MSSTS;
|
|
1888
|
-
case CacheAccountType.GENERIC_ACCOUNT_TYPE:
|
|
1889
|
-
return CacheType.GENERIC;
|
|
1890
|
-
default: {
|
|
1891
|
-
throw ClientAuthError.createUnexpectedAccountTypeError();
|
|
1892
|
-
}
|
|
1893
|
-
}
|
|
1894
|
-
}
|
|
1895
1914
|
/**
|
|
1896
1915
|
* Returns the AccountInfo interface for this account.
|
|
1897
1916
|
*/
|
|
@@ -1905,6 +1924,7 @@ class AccountEntity {
|
|
|
1905
1924
|
name: this.name,
|
|
1906
1925
|
idTokenClaims: this.idTokenClaims,
|
|
1907
1926
|
nativeAccountId: this.nativeAccountId,
|
|
1927
|
+
authorityType: this.authorityType,
|
|
1908
1928
|
};
|
|
1909
1929
|
}
|
|
1910
1930
|
/**
|
|
@@ -1921,84 +1941,74 @@ class AccountEntity {
|
|
|
1921
1941
|
}
|
|
1922
1942
|
/**
|
|
1923
1943
|
* Build Account cache from IdToken, clientInfo and authority/policy. Associated with AAD.
|
|
1924
|
-
* @param
|
|
1925
|
-
* @param authority
|
|
1926
|
-
* @param idToken
|
|
1927
|
-
* @param policy
|
|
1944
|
+
* @param accountDetails
|
|
1928
1945
|
*/
|
|
1929
|
-
static createAccount(
|
|
1946
|
+
static createAccount(accountDetails, authority) {
|
|
1930
1947
|
const account = new AccountEntity();
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1948
|
+
if (authority.authorityType === AuthorityType.Adfs) {
|
|
1949
|
+
account.authorityType = CacheAccountType.ADFS_ACCOUNT_TYPE;
|
|
1950
|
+
}
|
|
1951
|
+
else if (authority.protocolMode === ProtocolMode.AAD) {
|
|
1952
|
+
account.authorityType = CacheAccountType.MSSTS_ACCOUNT_TYPE;
|
|
1953
|
+
}
|
|
1954
|
+
else {
|
|
1955
|
+
account.authorityType = CacheAccountType.GENERIC_ACCOUNT_TYPE;
|
|
1956
|
+
}
|
|
1957
|
+
account.clientInfo = accountDetails.clientInfo;
|
|
1958
|
+
account.homeAccountId = accountDetails.homeAccountId;
|
|
1959
|
+
account.nativeAccountId = accountDetails.nativeAccountId;
|
|
1960
|
+
const env = accountDetails.environment ||
|
|
1961
|
+
(authority && authority.getPreferredCache());
|
|
1936
1962
|
if (!env) {
|
|
1937
1963
|
throw ClientAuthError.createInvalidCacheEnvironmentError();
|
|
1938
1964
|
}
|
|
1939
1965
|
account.environment = env;
|
|
1940
1966
|
// non AAD scenarios can have empty realm
|
|
1941
|
-
account.realm =
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
account.
|
|
1963
|
-
account.msGraphHost = msGraphHost;
|
|
1967
|
+
account.realm =
|
|
1968
|
+
accountDetails.idTokenClaims.tid || Constants.EMPTY_STRING;
|
|
1969
|
+
account.idTokenClaims = accountDetails.idTokenClaims;
|
|
1970
|
+
// How do you account for MSA CID here?
|
|
1971
|
+
account.localAccountId =
|
|
1972
|
+
accountDetails.idTokenClaims.oid ||
|
|
1973
|
+
accountDetails.idTokenClaims.sub ||
|
|
1974
|
+
Constants.EMPTY_STRING;
|
|
1975
|
+
/*
|
|
1976
|
+
* In B2C scenarios the emails claim is used instead of preferred_username and it is an array.
|
|
1977
|
+
* In most cases it will contain a single email. This field should not be relied upon if a custom
|
|
1978
|
+
* policy is configured to return more than 1 email.
|
|
1979
|
+
*/
|
|
1980
|
+
const preferredUsername = accountDetails.idTokenClaims.preferred_username ||
|
|
1981
|
+
accountDetails.idTokenClaims.upn;
|
|
1982
|
+
const email = accountDetails.idTokenClaims.emails
|
|
1983
|
+
? accountDetails.idTokenClaims.emails[0]
|
|
1984
|
+
: null;
|
|
1985
|
+
account.username = preferredUsername || email || Constants.EMPTY_STRING;
|
|
1986
|
+
account.name = accountDetails.idTokenClaims.name;
|
|
1987
|
+
account.cloudGraphHostName = accountDetails.cloudGraphHostName;
|
|
1988
|
+
account.msGraphHost = accountDetails.msGraphHost;
|
|
1964
1989
|
return account;
|
|
1965
1990
|
}
|
|
1966
1991
|
/**
|
|
1967
|
-
*
|
|
1968
|
-
* @param
|
|
1969
|
-
* @param
|
|
1992
|
+
* Creates an AccountEntity object from AccountInfo
|
|
1993
|
+
* @param accountInfo
|
|
1994
|
+
* @param cloudGraphHostName
|
|
1995
|
+
* @param msGraphHost
|
|
1996
|
+
* @returns
|
|
1970
1997
|
*/
|
|
1971
|
-
static
|
|
1998
|
+
static createFromAccountInfo(accountInfo, cloudGraphHostName, msGraphHost) {
|
|
1972
1999
|
const account = new AccountEntity();
|
|
1973
2000
|
account.authorityType =
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
account.
|
|
1978
|
-
|
|
1979
|
-
account.
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
}
|
|
1984
|
-
if (idToken) {
|
|
1985
|
-
// How do you account for MSA CID here?
|
|
1986
|
-
account.localAccountId =
|
|
1987
|
-
idToken?.claims?.oid ||
|
|
1988
|
-
idToken?.claims?.sub ||
|
|
1989
|
-
Constants.EMPTY_STRING;
|
|
1990
|
-
// upn claim for most ADFS scenarios
|
|
1991
|
-
account.username = idToken?.claims?.upn || Constants.EMPTY_STRING;
|
|
1992
|
-
account.name = idToken?.claims?.name || Constants.EMPTY_STRING;
|
|
1993
|
-
account.idTokenClaims = idToken?.claims;
|
|
1994
|
-
}
|
|
1995
|
-
account.environment = env;
|
|
2001
|
+
accountInfo.authorityType || CacheAccountType.GENERIC_ACCOUNT_TYPE;
|
|
2002
|
+
account.homeAccountId = accountInfo.homeAccountId;
|
|
2003
|
+
account.localAccountId = accountInfo.localAccountId;
|
|
2004
|
+
account.nativeAccountId = accountInfo.nativeAccountId;
|
|
2005
|
+
account.realm = accountInfo.tenantId;
|
|
2006
|
+
account.environment = accountInfo.environment;
|
|
2007
|
+
account.username = accountInfo.username;
|
|
2008
|
+
account.name = accountInfo.name;
|
|
2009
|
+
account.idTokenClaims = accountInfo.idTokenClaims;
|
|
1996
2010
|
account.cloudGraphHostName = cloudGraphHostName;
|
|
1997
2011
|
account.msGraphHost = msGraphHost;
|
|
1998
|
-
/*
|
|
1999
|
-
* add uniqueName to claims
|
|
2000
|
-
* account.name = idToken.claims.uniqueName;
|
|
2001
|
-
*/
|
|
2002
2012
|
return account;
|
|
2003
2013
|
}
|
|
2004
2014
|
/**
|
|
@@ -2006,9 +2016,9 @@ class AccountEntity {
|
|
|
2006
2016
|
* @param serverClientInfo
|
|
2007
2017
|
* @param authType
|
|
2008
2018
|
*/
|
|
2009
|
-
static generateHomeAccountId(serverClientInfo, authType, logger, cryptoObj,
|
|
2010
|
-
const accountId =
|
|
2011
|
-
?
|
|
2019
|
+
static generateHomeAccountId(serverClientInfo, authType, logger, cryptoObj, idTokenClaims) {
|
|
2020
|
+
const accountId = idTokenClaims?.sub
|
|
2021
|
+
? idTokenClaims.sub
|
|
2012
2022
|
: Constants.EMPTY_STRING;
|
|
2013
2023
|
// since ADFS does not have tid and does not set client_info
|
|
2014
2024
|
if (authType === AuthorityType.Adfs ||
|
|
@@ -2189,20 +2199,21 @@ class CacheManager {
|
|
|
2189
2199
|
* saves a cache record
|
|
2190
2200
|
* @param cacheRecord
|
|
2191
2201
|
*/
|
|
2192
|
-
async saveCacheRecord(cacheRecord) {
|
|
2202
|
+
async saveCacheRecord(cacheRecord, storeInCache) {
|
|
2193
2203
|
if (!cacheRecord) {
|
|
2194
2204
|
throw ClientAuthError.createNullOrUndefinedCacheRecord();
|
|
2195
2205
|
}
|
|
2196
2206
|
if (!!cacheRecord.account) {
|
|
2197
2207
|
this.setAccount(cacheRecord.account);
|
|
2198
2208
|
}
|
|
2199
|
-
if (!!cacheRecord.idToken) {
|
|
2209
|
+
if (!!cacheRecord.idToken && storeInCache?.idToken !== false) {
|
|
2200
2210
|
this.setIdTokenCredential(cacheRecord.idToken);
|
|
2201
2211
|
}
|
|
2202
|
-
if (!!cacheRecord.accessToken) {
|
|
2212
|
+
if (!!cacheRecord.accessToken && storeInCache?.accessToken !== false) {
|
|
2203
2213
|
await this.saveAccessToken(cacheRecord.accessToken);
|
|
2204
2214
|
}
|
|
2205
|
-
if (!!cacheRecord.refreshToken
|
|
2215
|
+
if (!!cacheRecord.refreshToken &&
|
|
2216
|
+
storeInCache?.refreshToken !== false) {
|
|
2206
2217
|
this.setRefreshTokenCredential(cacheRecord.refreshToken);
|
|
2207
2218
|
}
|
|
2208
2219
|
if (!!cacheRecord.appMetadata) {
|
|
@@ -3229,6 +3240,13 @@ function buildAuthOptions(authOptions) {
|
|
|
3229
3240
|
...authOptions,
|
|
3230
3241
|
};
|
|
3231
3242
|
}
|
|
3243
|
+
/**
|
|
3244
|
+
* Returns true if config has protocolMode set to ProtocolMode.OIDC, false otherwise
|
|
3245
|
+
* @param ClientConfiguration
|
|
3246
|
+
*/
|
|
3247
|
+
function isOidcProtocolMode(config) {
|
|
3248
|
+
return (config.authOptions.authority.options.protocolMode === ProtocolMode.OIDC);
|
|
3249
|
+
}
|
|
3232
3250
|
|
|
3233
3251
|
/*
|
|
3234
3252
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3462,7 +3480,7 @@ class RequestValidator {
|
|
|
3462
3480
|
}
|
|
3463
3481
|
});
|
|
3464
3482
|
// remove empty string parameters
|
|
3465
|
-
return Object.fromEntries(Object.entries(eQParams).filter(kv => kv[1] !== ""));
|
|
3483
|
+
return Object.fromEntries(Object.entries(eQParams).filter((kv) => kv[1] !== ""));
|
|
3466
3484
|
}
|
|
3467
3485
|
}
|
|
3468
3486
|
|
|
@@ -3504,9 +3522,15 @@ class RequestParameterBuilder {
|
|
|
3504
3522
|
* @param scopeSet
|
|
3505
3523
|
* @param addOidcScopes
|
|
3506
3524
|
*/
|
|
3507
|
-
addScopes(scopes, addOidcScopes = true) {
|
|
3525
|
+
addScopes(scopes, addOidcScopes = true, defaultScopes = OIDC_DEFAULT_SCOPES) {
|
|
3526
|
+
// Always add openid to the scopes when adding OIDC scopes
|
|
3527
|
+
if (addOidcScopes &&
|
|
3528
|
+
!defaultScopes.includes("openid") &&
|
|
3529
|
+
!scopes.includes("openid")) {
|
|
3530
|
+
defaultScopes.push("openid");
|
|
3531
|
+
}
|
|
3508
3532
|
const requestScopes = addOidcScopes
|
|
3509
|
-
? [...(scopes || []), ...
|
|
3533
|
+
? [...(scopes || []), ...defaultScopes]
|
|
3510
3534
|
: scopes || [];
|
|
3511
3535
|
const scopeSet = new ScopeSet(requestScopes);
|
|
3512
3536
|
this.parameters.set(AADServerParamKeys.SCOPE, encodeURIComponent(scopeSet.printScopes()));
|
|
@@ -4693,6 +4717,30 @@ class UrlString {
|
|
|
4693
4717
|
}
|
|
4694
4718
|
return Constants.EMPTY_STRING;
|
|
4695
4719
|
}
|
|
4720
|
+
/**
|
|
4721
|
+
* Parses query server response string from given string.
|
|
4722
|
+
* Extract hash between '?code=' and '#' if trailing '# is present.
|
|
4723
|
+
* Returns empty string if no query symbol is found.
|
|
4724
|
+
* @param queryString
|
|
4725
|
+
*/
|
|
4726
|
+
static parseQueryServerResponse(queryString) {
|
|
4727
|
+
const queryIndex1 = queryString.indexOf("?code");
|
|
4728
|
+
const queryIndex2 = queryString.indexOf("/?code");
|
|
4729
|
+
const hashIndex = queryString.indexOf("#");
|
|
4730
|
+
if (queryIndex2 > -1 && hashIndex > -1) {
|
|
4731
|
+
return queryString.substring(queryIndex2 + 2, hashIndex);
|
|
4732
|
+
}
|
|
4733
|
+
else if (queryIndex2 > -1) {
|
|
4734
|
+
return queryString.substring(queryIndex2 + 2);
|
|
4735
|
+
}
|
|
4736
|
+
else if (queryIndex1 > -1 && hashIndex > -1) {
|
|
4737
|
+
return queryString.substring(queryIndex1 + 1, hashIndex);
|
|
4738
|
+
}
|
|
4739
|
+
else if (queryIndex1 > -1) {
|
|
4740
|
+
return queryString.substring(queryIndex1 + 1);
|
|
4741
|
+
}
|
|
4742
|
+
return Constants.EMPTY_STRING;
|
|
4743
|
+
}
|
|
4696
4744
|
static constructAuthorityUriFromObject(urlObject) {
|
|
4697
4745
|
return new UrlString(urlObject.Protocol +
|
|
4698
4746
|
"//" +
|
|
@@ -4738,6 +4786,21 @@ class UrlString {
|
|
|
4738
4786
|
}
|
|
4739
4787
|
return deserializedQueryString;
|
|
4740
4788
|
}
|
|
4789
|
+
/**
|
|
4790
|
+
* Returns either deserialized query string or deserialized hash, depending on the serverResponseType
|
|
4791
|
+
* as a server auth code response object.
|
|
4792
|
+
*/
|
|
4793
|
+
static getDeserializedCodeResponse(serverResponseType, hashFragment) {
|
|
4794
|
+
const hashUrlString = new UrlString(hashFragment);
|
|
4795
|
+
let serverParams;
|
|
4796
|
+
if (serverResponseType === ServerResponseType.QUERY) {
|
|
4797
|
+
serverParams = UrlString.getDeserializedQueryString(hashFragment);
|
|
4798
|
+
}
|
|
4799
|
+
else {
|
|
4800
|
+
serverParams = UrlString.getDeserializedHash(hashUrlString.getHash());
|
|
4801
|
+
}
|
|
4802
|
+
return serverParams;
|
|
4803
|
+
}
|
|
4741
4804
|
/**
|
|
4742
4805
|
* Check if the hash of the URL string contains known properties
|
|
4743
4806
|
*/
|
|
@@ -4956,6 +5019,7 @@ const PerformanceEvents = {
|
|
|
4956
5019
|
UpdateCloudDiscoveryMetadataMeasurement: "updateCloudDiscoveryMetadataMeasurement",
|
|
4957
5020
|
UsernamePasswordClientAcquireToken: "usernamePasswordClientAcquireToken",
|
|
4958
5021
|
NativeMessageHandlerHandshake: "nativeMessageHandlerHandshake",
|
|
5022
|
+
NativeGenerateAuthResult: "nativeGenerateAuthResult",
|
|
4959
5023
|
};
|
|
4960
5024
|
/**
|
|
4961
5025
|
* State of the performance event.
|
|
@@ -5181,12 +5245,25 @@ class ResponseHandler {
|
|
|
5181
5245
|
*/
|
|
5182
5246
|
validateServerAuthorizationCodeResponse(serverResponseHash, cachedState, cryptoObj) {
|
|
5183
5247
|
if (!serverResponseHash.state || !cachedState) {
|
|
5184
|
-
throw
|
|
5185
|
-
? ClientAuthError.createStateNotFoundError("
|
|
5186
|
-
: ClientAuthError.createStateNotFoundError("
|
|
5248
|
+
throw serverResponseHash.state
|
|
5249
|
+
? ClientAuthError.createStateNotFoundError("Cached State")
|
|
5250
|
+
: ClientAuthError.createStateNotFoundError("Server State");
|
|
5251
|
+
}
|
|
5252
|
+
let decodedServerResponseHash;
|
|
5253
|
+
let decodedCachedState;
|
|
5254
|
+
try {
|
|
5255
|
+
decodedServerResponseHash = decodeURIComponent(serverResponseHash.state);
|
|
5187
5256
|
}
|
|
5188
|
-
|
|
5189
|
-
|
|
5257
|
+
catch (e) {
|
|
5258
|
+
throw ClientAuthError.createInvalidStateError(serverResponseHash.state, `Server response hash URI could not be decoded`);
|
|
5259
|
+
}
|
|
5260
|
+
try {
|
|
5261
|
+
decodedCachedState = decodeURIComponent(cachedState);
|
|
5262
|
+
}
|
|
5263
|
+
catch (e) {
|
|
5264
|
+
throw ClientAuthError.createInvalidStateError(serverResponseHash.state, `Cached state URI could not be decoded`);
|
|
5265
|
+
}
|
|
5266
|
+
if (decodedServerResponseHash !== decodedCachedState) {
|
|
5190
5267
|
throw ClientAuthError.createStateMismatchError();
|
|
5191
5268
|
}
|
|
5192
5269
|
// Check for error
|
|
@@ -5246,7 +5323,7 @@ class ResponseHandler {
|
|
|
5246
5323
|
}
|
|
5247
5324
|
}
|
|
5248
5325
|
// generate homeAccountId
|
|
5249
|
-
this.homeAccountIdentifier = AccountEntity.generateHomeAccountId(serverTokenResponse.client_info || Constants.EMPTY_STRING, authority.authorityType, this.logger, this.cryptoObj, idTokenObj);
|
|
5326
|
+
this.homeAccountIdentifier = AccountEntity.generateHomeAccountId(serverTokenResponse.client_info || Constants.EMPTY_STRING, authority.authorityType, this.logger, this.cryptoObj, idTokenObj?.claims);
|
|
5250
5327
|
// save the response tokens
|
|
5251
5328
|
let requestStateObj;
|
|
5252
5329
|
if (!!authCodePayload && !!authCodePayload.state) {
|
|
@@ -5279,7 +5356,7 @@ class ResponseHandler {
|
|
|
5279
5356
|
return ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenObj, requestStateObj, undefined, serverRequestId);
|
|
5280
5357
|
}
|
|
5281
5358
|
}
|
|
5282
|
-
await this.cacheStorage.saveCacheRecord(cacheRecord);
|
|
5359
|
+
await this.cacheStorage.saveCacheRecord(cacheRecord, request.storeInCache);
|
|
5283
5360
|
}
|
|
5284
5361
|
finally {
|
|
5285
5362
|
if (this.persistencePlugin &&
|
|
@@ -5308,7 +5385,13 @@ class ResponseHandler {
|
|
|
5308
5385
|
if (!StringUtils.isEmpty(serverTokenResponse.id_token) &&
|
|
5309
5386
|
!!idTokenObj) {
|
|
5310
5387
|
cachedIdToken = IdTokenEntity.createIdTokenEntity(this.homeAccountIdentifier, env, serverTokenResponse.id_token || Constants.EMPTY_STRING, this.clientId, idTokenObj.claims.tid || Constants.EMPTY_STRING);
|
|
5311
|
-
cachedAccount =
|
|
5388
|
+
cachedAccount = AccountEntity.createAccount({
|
|
5389
|
+
homeAccountId: this.homeAccountIdentifier,
|
|
5390
|
+
idTokenClaims: idTokenObj.claims,
|
|
5391
|
+
clientInfo: serverTokenResponse.client_info,
|
|
5392
|
+
cloudGraphHostName: authCodePayload?.cloud_graph_host_name,
|
|
5393
|
+
msGraphHost: authCodePayload?.msgraph_host,
|
|
5394
|
+
}, authority);
|
|
5312
5395
|
}
|
|
5313
5396
|
// AccessToken
|
|
5314
5397
|
let cachedAccessToken = null;
|
|
@@ -5352,34 +5435,6 @@ class ResponseHandler {
|
|
|
5352
5435
|
}
|
|
5353
5436
|
return new CacheRecord(cachedAccount, cachedIdToken, cachedAccessToken, cachedRefreshToken, cachedAppMetadata);
|
|
5354
5437
|
}
|
|
5355
|
-
/**
|
|
5356
|
-
* Generate Account
|
|
5357
|
-
* @param serverTokenResponse
|
|
5358
|
-
* @param idToken
|
|
5359
|
-
* @param authority
|
|
5360
|
-
*/
|
|
5361
|
-
generateAccountEntity(serverTokenResponse, idToken, authority, authCodePayload) {
|
|
5362
|
-
const authorityType = authority.authorityType;
|
|
5363
|
-
const cloudGraphHostName = authCodePayload
|
|
5364
|
-
? authCodePayload.cloud_graph_host_name
|
|
5365
|
-
: Constants.EMPTY_STRING;
|
|
5366
|
-
const msGraphhost = authCodePayload
|
|
5367
|
-
? authCodePayload.msgraph_host
|
|
5368
|
-
: Constants.EMPTY_STRING;
|
|
5369
|
-
// ADFS does not require client_info in the response
|
|
5370
|
-
if (authorityType === AuthorityType.Adfs) {
|
|
5371
|
-
this.logger.verbose("Authority type is ADFS, creating ADFS account");
|
|
5372
|
-
return AccountEntity.createGenericAccount(this.homeAccountIdentifier, idToken, authority, cloudGraphHostName, msGraphhost);
|
|
5373
|
-
}
|
|
5374
|
-
// This fallback applies to B2C as well as they fall under an AAD account type.
|
|
5375
|
-
if (StringUtils.isEmpty(serverTokenResponse.client_info) &&
|
|
5376
|
-
authority.protocolMode === "AAD") {
|
|
5377
|
-
throw ClientAuthError.createClientInfoEmptyError();
|
|
5378
|
-
}
|
|
5379
|
-
return serverTokenResponse.client_info
|
|
5380
|
-
? AccountEntity.createAccount(serverTokenResponse.client_info, this.homeAccountIdentifier, idToken, authority, cloudGraphHostName, msGraphhost)
|
|
5381
|
-
: AccountEntity.createGenericAccount(this.homeAccountIdentifier, idToken, authority, cloudGraphHostName, msGraphhost);
|
|
5382
|
-
}
|
|
5383
5438
|
/**
|
|
5384
5439
|
* Creates an @AuthenticationResult from @CacheRecord , @IdToken , and a boolean that states whether or not the result is from cache.
|
|
5385
5440
|
*
|
|
@@ -5469,6 +5524,8 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
5469
5524
|
super(configuration, performanceClient);
|
|
5470
5525
|
// Flag to indicate if client is for hybrid spa auth code redemption
|
|
5471
5526
|
this.includeRedirectUri = true;
|
|
5527
|
+
this.oidcDefaultScopes =
|
|
5528
|
+
this.config.authOptions.authority.options.OIDCOptions?.defaultScopes;
|
|
5472
5529
|
}
|
|
5473
5530
|
/**
|
|
5474
5531
|
* Creates the URL of the authorization request letting the user input credentials and consent to the
|
|
@@ -5507,7 +5564,7 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
5507
5564
|
const requestId = response.headers?.[HeaderNames.X_MS_REQUEST_ID];
|
|
5508
5565
|
const httpVerAuthority = response.headers?.[HeaderNames.X_MS_HTTP_VERSION];
|
|
5509
5566
|
if (httpVerAuthority) {
|
|
5510
|
-
atsMeasurement?.
|
|
5567
|
+
atsMeasurement?.add({
|
|
5511
5568
|
httpVerAuthority,
|
|
5512
5569
|
});
|
|
5513
5570
|
}
|
|
@@ -5518,14 +5575,14 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
5518
5575
|
return responseHandler
|
|
5519
5576
|
.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request, authCodePayload, undefined, undefined, undefined, requestId)
|
|
5520
5577
|
.then((result) => {
|
|
5521
|
-
atsMeasurement?.
|
|
5578
|
+
atsMeasurement?.end({
|
|
5522
5579
|
success: true,
|
|
5523
5580
|
});
|
|
5524
5581
|
return result;
|
|
5525
5582
|
})
|
|
5526
5583
|
.catch((error) => {
|
|
5527
5584
|
this.logger.verbose("Error in fetching token in ACC", request.correlationId);
|
|
5528
|
-
atsMeasurement?.
|
|
5585
|
+
atsMeasurement?.end({
|
|
5529
5586
|
errorCode: error.errorCode,
|
|
5530
5587
|
subErrorCode: error.subError,
|
|
5531
5588
|
success: false,
|
|
@@ -5541,10 +5598,8 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
5541
5598
|
handleFragmentResponse(hashFragment, cachedState) {
|
|
5542
5599
|
// Handle responses.
|
|
5543
5600
|
const responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, null, null);
|
|
5544
|
-
|
|
5545
|
-
|
|
5546
|
-
// Deserialize hash fragment response parameters.
|
|
5547
|
-
const serverParams = UrlString.getDeserializedHash(hashUrlString.getHash());
|
|
5601
|
+
const serverParams = UrlString.getDeserializedCodeResponse(this.config.authOptions.authority.options.OIDCOptions
|
|
5602
|
+
?.serverResponseType, hashFragment);
|
|
5548
5603
|
// Get code response
|
|
5549
5604
|
responseHandler.validateServerAuthorizationCodeResponse(serverParams, cachedState, this.cryptoUtils);
|
|
5550
5605
|
// throw when there is no auth code in the response
|
|
@@ -5630,14 +5685,14 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
5630
5685
|
parameterBuilder.addRedirectUri(request.redirectUri);
|
|
5631
5686
|
}
|
|
5632
5687
|
// Add scope array, parameter builder will add default scopes and dedupe
|
|
5633
|
-
parameterBuilder.addScopes(request.scopes);
|
|
5688
|
+
parameterBuilder.addScopes(request.scopes, true, this.oidcDefaultScopes);
|
|
5634
5689
|
// add code: user set, not validated
|
|
5635
5690
|
parameterBuilder.addAuthorizationCode(request.code);
|
|
5636
5691
|
// Add library metadata
|
|
5637
5692
|
parameterBuilder.addLibraryInfo(this.config.libraryInfo);
|
|
5638
5693
|
parameterBuilder.addApplicationTelemetry(this.config.telemetry.application);
|
|
5639
5694
|
parameterBuilder.addThrottling();
|
|
5640
|
-
if (this.serverTelemetryManager) {
|
|
5695
|
+
if (this.serverTelemetryManager && !isOidcProtocolMode(this.config)) {
|
|
5641
5696
|
parameterBuilder.addServerTelemetry(this.serverTelemetryManager);
|
|
5642
5697
|
}
|
|
5643
5698
|
// add code_verifier if passed
|
|
@@ -5736,7 +5791,7 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
5736
5791
|
...(request.scopes || []),
|
|
5737
5792
|
...(request.extraScopesToConsent || []),
|
|
5738
5793
|
];
|
|
5739
|
-
parameterBuilder.addScopes(requestScopes);
|
|
5794
|
+
parameterBuilder.addScopes(requestScopes, true, this.oidcDefaultScopes);
|
|
5740
5795
|
// validate the redirectUri (to be a non null value)
|
|
5741
5796
|
parameterBuilder.addRedirectUri(request.redirectUri);
|
|
5742
5797
|
// generate the correlationId if not set by the user and add
|
|
@@ -5749,7 +5804,9 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
5749
5804
|
parameterBuilder.addResponseTypeCode();
|
|
5750
5805
|
// add library info parameters
|
|
5751
5806
|
parameterBuilder.addLibraryInfo(this.config.libraryInfo);
|
|
5752
|
-
|
|
5807
|
+
if (!isOidcProtocolMode(this.config)) {
|
|
5808
|
+
parameterBuilder.addApplicationTelemetry(this.config.telemetry.application);
|
|
5809
|
+
}
|
|
5753
5810
|
// add client_info=1
|
|
5754
5811
|
parameterBuilder.addClientInfo();
|
|
5755
5812
|
if (request.codeChallenge && request.codeChallengeMethod) {
|
|
@@ -5910,11 +5967,11 @@ class RefreshTokenClient extends BaseClient {
|
|
|
5910
5967
|
this.performanceClient?.setPreQueueTime(PerformanceEvents.RefreshTokenClientExecuteTokenRequest, request.correlationId);
|
|
5911
5968
|
const response = await this.executeTokenRequest(request, this.authority);
|
|
5912
5969
|
const httpVerToken = response.headers?.[HeaderNames.X_MS_HTTP_VERSION];
|
|
5913
|
-
atsMeasurement?.
|
|
5970
|
+
atsMeasurement?.add({
|
|
5914
5971
|
refreshTokenSize: response.body.refresh_token?.length || 0,
|
|
5915
5972
|
});
|
|
5916
5973
|
if (httpVerToken) {
|
|
5917
|
-
atsMeasurement?.
|
|
5974
|
+
atsMeasurement?.add({
|
|
5918
5975
|
httpVerToken,
|
|
5919
5976
|
});
|
|
5920
5977
|
}
|
|
@@ -5926,14 +5983,14 @@ class RefreshTokenClient extends BaseClient {
|
|
|
5926
5983
|
return responseHandler
|
|
5927
5984
|
.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request, undefined, undefined, true, request.forceCache, requestId)
|
|
5928
5985
|
.then((result) => {
|
|
5929
|
-
atsMeasurement?.
|
|
5986
|
+
atsMeasurement?.end({
|
|
5930
5987
|
success: true,
|
|
5931
5988
|
});
|
|
5932
5989
|
return result;
|
|
5933
5990
|
})
|
|
5934
5991
|
.catch((error) => {
|
|
5935
5992
|
this.logger.verbose("Error in fetching refresh token", request.correlationId);
|
|
5936
|
-
atsMeasurement?.
|
|
5993
|
+
atsMeasurement?.end({
|
|
5937
5994
|
errorCode: error.errorCode,
|
|
5938
5995
|
subErrorCode: error.subError,
|
|
5939
5996
|
success: false,
|
|
@@ -5997,11 +6054,11 @@ class RefreshTokenClient extends BaseClient {
|
|
|
5997
6054
|
this.logger.verbose("RefreshTokenClientAcquireTokenWithCachedRefreshToken called", request.correlationId);
|
|
5998
6055
|
const refreshToken = this.cacheManager.getRefreshToken(request.account, foci);
|
|
5999
6056
|
if (!refreshToken) {
|
|
6000
|
-
atsMeasurement?.
|
|
6057
|
+
atsMeasurement?.discard();
|
|
6001
6058
|
throw InteractionRequiredAuthError.createNoTokensFoundError();
|
|
6002
6059
|
}
|
|
6003
6060
|
// attach cached RT size to the current measurement
|
|
6004
|
-
atsMeasurement?.
|
|
6061
|
+
atsMeasurement?.end({
|
|
6005
6062
|
success: true,
|
|
6006
6063
|
});
|
|
6007
6064
|
const refreshTokenRequest = {
|
|
@@ -6042,13 +6099,13 @@ class RefreshTokenClient extends BaseClient {
|
|
|
6042
6099
|
};
|
|
6043
6100
|
return this.executePostToTokenEndpoint(endpoint, requestBody, headers, thumbprint)
|
|
6044
6101
|
.then((result) => {
|
|
6045
|
-
acquireTokenMeasurement?.
|
|
6102
|
+
acquireTokenMeasurement?.end({
|
|
6046
6103
|
success: true,
|
|
6047
6104
|
});
|
|
6048
6105
|
return result;
|
|
6049
6106
|
})
|
|
6050
6107
|
.catch((error) => {
|
|
6051
|
-
acquireTokenMeasurement?.
|
|
6108
|
+
acquireTokenMeasurement?.end({
|
|
6052
6109
|
success: false,
|
|
6053
6110
|
});
|
|
6054
6111
|
throw error;
|
|
@@ -6064,13 +6121,13 @@ class RefreshTokenClient extends BaseClient {
|
|
|
6064
6121
|
const acquireTokenMeasurement = this.performanceClient?.startMeasurement(PerformanceEvents.BaseClientCreateTokenRequestHeaders, correlationId);
|
|
6065
6122
|
const parameterBuilder = new RequestParameterBuilder();
|
|
6066
6123
|
parameterBuilder.addClientId(this.config.authOptions.clientId);
|
|
6067
|
-
parameterBuilder.addScopes(request.scopes);
|
|
6124
|
+
parameterBuilder.addScopes(request.scopes, true, this.config.authOptions.authority.options.OIDCOptions?.defaultScopes);
|
|
6068
6125
|
parameterBuilder.addGrantType(GrantType.REFRESH_TOKEN_GRANT);
|
|
6069
6126
|
parameterBuilder.addClientInfo();
|
|
6070
6127
|
parameterBuilder.addLibraryInfo(this.config.libraryInfo);
|
|
6071
6128
|
parameterBuilder.addApplicationTelemetry(this.config.telemetry.application);
|
|
6072
6129
|
parameterBuilder.addThrottling();
|
|
6073
|
-
if (this.serverTelemetryManager) {
|
|
6130
|
+
if (this.serverTelemetryManager && !isOidcProtocolMode(this.config)) {
|
|
6074
6131
|
parameterBuilder.addServerTelemetry(this.serverTelemetryManager);
|
|
6075
6132
|
}
|
|
6076
6133
|
parameterBuilder.addCorrelationId(correlationId);
|
|
@@ -6095,7 +6152,7 @@ class RefreshTokenClient extends BaseClient {
|
|
|
6095
6152
|
parameterBuilder.addSshJwk(request.sshJwk);
|
|
6096
6153
|
}
|
|
6097
6154
|
else {
|
|
6098
|
-
acquireTokenMeasurement?.
|
|
6155
|
+
acquireTokenMeasurement?.end({
|
|
6099
6156
|
success: false,
|
|
6100
6157
|
});
|
|
6101
6158
|
throw ClientConfigurationError.createMissingSshJwkError();
|
|
@@ -6124,7 +6181,7 @@ class RefreshTokenClient extends BaseClient {
|
|
|
6124
6181
|
break;
|
|
6125
6182
|
}
|
|
6126
6183
|
}
|
|
6127
|
-
acquireTokenMeasurement?.
|
|
6184
|
+
acquireTokenMeasurement?.end({
|
|
6128
6185
|
success: true,
|
|
6129
6186
|
});
|
|
6130
6187
|
return parameterBuilder.createQueryString();
|
|
@@ -7119,18 +7176,14 @@ const rawMetdataJSON = {
|
|
|
7119
7176
|
};
|
|
7120
7177
|
const EndpointMetadata = rawMetdataJSON.endpointMetadata;
|
|
7121
7178
|
const InstanceDiscoveryMetadata = rawMetdataJSON.instanceDiscoveryMetadata;
|
|
7122
|
-
|
|
7123
|
-
|
|
7124
|
-
|
|
7125
|
-
|
|
7126
|
-
|
|
7127
|
-
|
|
7128
|
-
|
|
7129
|
-
|
|
7130
|
-
const ProtocolMode = {
|
|
7131
|
-
AAD: "AAD",
|
|
7132
|
-
OIDC: "OIDC",
|
|
7133
|
-
};
|
|
7179
|
+
const InstanceDiscoveryMetadataAliases = new Set();
|
|
7180
|
+
for (const key in InstanceDiscoveryMetadata) {
|
|
7181
|
+
for (const metadata of InstanceDiscoveryMetadata[key].metadata) {
|
|
7182
|
+
for (const alias of metadata.aliases) {
|
|
7183
|
+
InstanceDiscoveryMetadataAliases.add(alias);
|
|
7184
|
+
}
|
|
7185
|
+
}
|
|
7186
|
+
}
|
|
7134
7187
|
|
|
7135
7188
|
/*
|
|
7136
7189
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7508,10 +7561,10 @@ class Authority {
|
|
|
7508
7561
|
* @private
|
|
7509
7562
|
*/
|
|
7510
7563
|
canReplaceTenant(authorityUri) {
|
|
7511
|
-
return authorityUri.PathSegments.length === 1
|
|
7512
|
-
|
|
7513
|
-
|
|
7514
|
-
|
|
7564
|
+
return (authorityUri.PathSegments.length === 1 &&
|
|
7565
|
+
!Authority.reservedTenantDomains.has(authorityUri.PathSegments[0]) &&
|
|
7566
|
+
this.getAuthorityType(authorityUri) === AuthorityType.Default &&
|
|
7567
|
+
this.protocolMode === ProtocolMode.AAD);
|
|
7515
7568
|
}
|
|
7516
7569
|
/**
|
|
7517
7570
|
* Replaces tenant in url path with current tenant. Defaults to common.
|
|
@@ -7532,8 +7585,9 @@ class Authority {
|
|
|
7532
7585
|
const currentAuthorityParts = this.canonicalAuthorityUrlComponents.PathSegments;
|
|
7533
7586
|
currentAuthorityParts.forEach((currentPart, index) => {
|
|
7534
7587
|
let cachedPart = cachedAuthorityParts[index];
|
|
7535
|
-
if (index === 0 &&
|
|
7536
|
-
|
|
7588
|
+
if (index === 0 &&
|
|
7589
|
+
this.canReplaceTenant(cachedAuthorityUrlComponents)) {
|
|
7590
|
+
const tenantId = new UrlString(this.metadata.authorization_endpoint).getUrlComponents().PathSegments[0];
|
|
7537
7591
|
/**
|
|
7538
7592
|
* Check if AAD canonical authority contains tenant domain name, for example "testdomain.onmicrosoft.com",
|
|
7539
7593
|
* by comparing its first path segment to the corresponding authorization endpoint path segment, which is
|
|
@@ -7554,8 +7608,9 @@ class Authority {
|
|
|
7554
7608
|
* The default open id configuration endpoint for any canonical authority.
|
|
7555
7609
|
*/
|
|
7556
7610
|
get defaultOpenIdConfigurationEndpoint() {
|
|
7611
|
+
const canonicalAuthorityHost = this.hostnameAndPort;
|
|
7557
7612
|
if (this.authorityType === AuthorityType.Adfs ||
|
|
7558
|
-
this.
|
|
7613
|
+
!this.isAliasOfKnownMicrosoftAuthority(canonicalAuthorityHost)) {
|
|
7559
7614
|
return `${this.canonicalAuthority}.well-known/openid-configuration`;
|
|
7560
7615
|
}
|
|
7561
7616
|
return `${this.canonicalAuthority}v2.0/.well-known/openid-configuration`;
|
|
@@ -7598,41 +7653,65 @@ class Authority {
|
|
|
7598
7653
|
*/
|
|
7599
7654
|
async updateEndpointMetadata(metadataEntity) {
|
|
7600
7655
|
this.performanceClient?.addQueueMeasurement(PerformanceEvents.AuthorityUpdateEndpointMetadata, this.correlationId);
|
|
7656
|
+
this.logger.verbose("Attempting to get endpoint metadata from authority configuration");
|
|
7601
7657
|
let metadata = this.getEndpointMetadataFromConfig();
|
|
7602
7658
|
if (metadata) {
|
|
7659
|
+
this.logger.verbose("Found endpoint metadata in authority configuration");
|
|
7603
7660
|
metadataEntity.updateEndpointMetadata(metadata, false);
|
|
7604
7661
|
return AuthorityMetadataSource.CONFIG;
|
|
7605
7662
|
}
|
|
7663
|
+
this.logger.verbose("Did not find endpoint metadata in the config... Attempting to get endpoint metadata from the hardcoded values.");
|
|
7664
|
+
// 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.
|
|
7665
|
+
if (this.authorityOptions.skipAuthorityMetadataCache) {
|
|
7666
|
+
this.logger.verbose("Skipping hardcoded metadata cache since skipAuthorityMetadataCache is set to true. Attempting to get endpoint metadata from the network metadata cache.");
|
|
7667
|
+
}
|
|
7668
|
+
else {
|
|
7669
|
+
let hardcodedMetadata = this.getEndpointMetadataFromHardcodedValues();
|
|
7670
|
+
if (hardcodedMetadata) {
|
|
7671
|
+
this.logger.verbose("Found endpoint metadata from hardcoded values.");
|
|
7672
|
+
// If the user prefers to use an azure region replace the global endpoints with regional information.
|
|
7673
|
+
if (this.authorityOptions.azureRegionConfiguration?.azureRegion) {
|
|
7674
|
+
this.performanceClient?.setPreQueueTime(PerformanceEvents.AuthorityUpdateMetadataWithRegionalInformation, this.correlationId);
|
|
7675
|
+
this.logger.verbose("Found azure region configuration. Updating endpoints with regional information.");
|
|
7676
|
+
hardcodedMetadata =
|
|
7677
|
+
await this.updateMetadataWithRegionalInformation(hardcodedMetadata);
|
|
7678
|
+
}
|
|
7679
|
+
metadataEntity.updateEndpointMetadata(hardcodedMetadata, false);
|
|
7680
|
+
return AuthorityMetadataSource.HARDCODED_VALUES;
|
|
7681
|
+
}
|
|
7682
|
+
else {
|
|
7683
|
+
this.logger.verbose("Did not find endpoint metadata in hardcoded values... Attempting to get endpoint metadata from the network metadata cache.");
|
|
7684
|
+
}
|
|
7685
|
+
}
|
|
7686
|
+
// Check cached metadata entity expiration status
|
|
7687
|
+
const metadataEntityExpired = metadataEntity.isExpired();
|
|
7606
7688
|
if (this.isAuthoritySameType(metadataEntity) &&
|
|
7607
7689
|
metadataEntity.endpointsFromNetwork &&
|
|
7608
|
-
!
|
|
7690
|
+
!metadataEntityExpired) {
|
|
7609
7691
|
// No need to update
|
|
7692
|
+
this.logger.verbose("Found endpoint metadata in the cache.");
|
|
7610
7693
|
return AuthorityMetadataSource.CACHE;
|
|
7611
7694
|
}
|
|
7695
|
+
else if (metadataEntityExpired) {
|
|
7696
|
+
this.logger.verbose("The metadata entity is expired.");
|
|
7697
|
+
}
|
|
7698
|
+
this.logger.verbose("Did not find cached endpoint metadata... Attempting to get endpoint metadata from the network.");
|
|
7612
7699
|
this.performanceClient?.setPreQueueTime(PerformanceEvents.AuthorityGetEndpointMetadataFromNetwork, this.correlationId);
|
|
7613
7700
|
metadata = await this.getEndpointMetadataFromNetwork();
|
|
7614
7701
|
if (metadata) {
|
|
7702
|
+
this.logger.verbose("Endpoint metadata was successfully returned from getEndpointMetadataFromNetwork()");
|
|
7615
7703
|
// If the user prefers to use an azure region replace the global endpoints with regional information.
|
|
7616
7704
|
if (this.authorityOptions.azureRegionConfiguration?.azureRegion) {
|
|
7617
7705
|
this.performanceClient?.setPreQueueTime(PerformanceEvents.AuthorityUpdateMetadataWithRegionalInformation, this.correlationId);
|
|
7706
|
+
this.logger.verbose("Found azure region configuration. Updating endpoints with regional information.");
|
|
7618
7707
|
metadata = await this.updateMetadataWithRegionalInformation(metadata);
|
|
7619
7708
|
}
|
|
7620
7709
|
metadataEntity.updateEndpointMetadata(metadata, true);
|
|
7621
7710
|
return AuthorityMetadataSource.NETWORK;
|
|
7622
7711
|
}
|
|
7623
|
-
let harcodedMetadata = this.getEndpointMetadataFromHardcodedValues();
|
|
7624
|
-
if (harcodedMetadata &&
|
|
7625
|
-
!this.authorityOptions.skipAuthorityMetadataCache) {
|
|
7626
|
-
// If the user prefers to use an azure region replace the global endpoints with regional information.
|
|
7627
|
-
if (this.authorityOptions.azureRegionConfiguration?.azureRegion) {
|
|
7628
|
-
this.performanceClient?.setPreQueueTime(PerformanceEvents.AuthorityUpdateMetadataWithRegionalInformation, this.correlationId);
|
|
7629
|
-
harcodedMetadata =
|
|
7630
|
-
await this.updateMetadataWithRegionalInformation(harcodedMetadata);
|
|
7631
|
-
}
|
|
7632
|
-
metadataEntity.updateEndpointMetadata(harcodedMetadata, false);
|
|
7633
|
-
return AuthorityMetadataSource.HARDCODED_VALUES;
|
|
7634
|
-
}
|
|
7635
7712
|
else {
|
|
7713
|
+
// Metadata could not be obtained from the config, cache, network or hardcoded values
|
|
7714
|
+
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.");
|
|
7636
7715
|
throw ClientAuthError.createUnableToGetOpenidConfigError(this.defaultOpenIdConfigurationEndpoint);
|
|
7637
7716
|
}
|
|
7638
7717
|
}
|
|
@@ -7681,17 +7760,23 @@ class Authority {
|
|
|
7681
7760
|
const response = await this.networkInterface.sendGetRequestAsync(openIdConfigurationEndpoint, options);
|
|
7682
7761
|
const isValidResponse = isOpenIdConfigResponse(response.body);
|
|
7683
7762
|
if (isValidResponse) {
|
|
7684
|
-
perfEvent?.
|
|
7763
|
+
perfEvent?.end({ success: true });
|
|
7685
7764
|
return response.body;
|
|
7686
7765
|
}
|
|
7687
7766
|
else {
|
|
7688
|
-
perfEvent?.
|
|
7767
|
+
perfEvent?.end({
|
|
7768
|
+
success: false,
|
|
7769
|
+
errorCode: "invalid_response",
|
|
7770
|
+
});
|
|
7689
7771
|
this.logger.verbose(`Authority.getEndpointMetadataFromNetwork: could not parse response as OpenID configuration`);
|
|
7690
7772
|
return null;
|
|
7691
7773
|
}
|
|
7692
7774
|
}
|
|
7693
7775
|
catch (e) {
|
|
7694
|
-
perfEvent?.
|
|
7776
|
+
perfEvent?.end({
|
|
7777
|
+
success: false,
|
|
7778
|
+
errorCode: "request_failure",
|
|
7779
|
+
});
|
|
7695
7780
|
this.logger.verbose(`Authority.getEndpointMetadataFromNetwork: ${e}`);
|
|
7696
7781
|
return null;
|
|
7697
7782
|
}
|
|
@@ -7713,19 +7798,26 @@ class Authority {
|
|
|
7713
7798
|
this.performanceClient?.addQueueMeasurement(PerformanceEvents.AuthorityUpdateMetadataWithRegionalInformation, this.correlationId);
|
|
7714
7799
|
const userConfiguredAzureRegion = this.authorityOptions.azureRegionConfiguration?.azureRegion;
|
|
7715
7800
|
if (userConfiguredAzureRegion) {
|
|
7716
|
-
if (userConfiguredAzureRegion !==
|
|
7717
|
-
|
|
7718
|
-
this.regionDiscoveryMetadata.
|
|
7801
|
+
if (userConfiguredAzureRegion !==
|
|
7802
|
+
Constants.AZURE_REGION_AUTO_DISCOVER_FLAG) {
|
|
7803
|
+
this.regionDiscoveryMetadata.region_outcome =
|
|
7804
|
+
RegionDiscoveryOutcomes.CONFIGURED_NO_AUTO_DETECTION;
|
|
7805
|
+
this.regionDiscoveryMetadata.region_used =
|
|
7806
|
+
userConfiguredAzureRegion;
|
|
7719
7807
|
return Authority.replaceWithRegionalInformation(metadata, userConfiguredAzureRegion);
|
|
7720
7808
|
}
|
|
7721
7809
|
this.performanceClient?.setPreQueueTime(PerformanceEvents.RegionDiscoveryDetectRegion, this.correlationId);
|
|
7722
|
-
const autodetectedRegionName = await this.regionDiscovery.detectRegion(this.authorityOptions.azureRegionConfiguration
|
|
7810
|
+
const autodetectedRegionName = await this.regionDiscovery.detectRegion(this.authorityOptions.azureRegionConfiguration
|
|
7811
|
+
?.environmentRegion, this.regionDiscoveryMetadata);
|
|
7723
7812
|
if (autodetectedRegionName) {
|
|
7724
|
-
this.regionDiscoveryMetadata.region_outcome =
|
|
7725
|
-
|
|
7813
|
+
this.regionDiscoveryMetadata.region_outcome =
|
|
7814
|
+
RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_SUCCESSFUL;
|
|
7815
|
+
this.regionDiscoveryMetadata.region_used =
|
|
7816
|
+
autodetectedRegionName;
|
|
7726
7817
|
return Authority.replaceWithRegionalInformation(metadata, autodetectedRegionName);
|
|
7727
7818
|
}
|
|
7728
|
-
this.regionDiscoveryMetadata.region_outcome =
|
|
7819
|
+
this.regionDiscoveryMetadata.region_outcome =
|
|
7820
|
+
RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_FAILED;
|
|
7729
7821
|
}
|
|
7730
7822
|
return metadata;
|
|
7731
7823
|
}
|
|
@@ -7737,7 +7829,7 @@ class Authority {
|
|
|
7737
7829
|
*/
|
|
7738
7830
|
async updateCloudDiscoveryMetadata(metadataEntity) {
|
|
7739
7831
|
this.performanceClient?.addQueueMeasurement(PerformanceEvents.AuthorityUpdateCloudDiscoveryMetadata, this.correlationId);
|
|
7740
|
-
this.logger.verbose("Attempting to get cloud discovery metadata
|
|
7832
|
+
this.logger.verbose("Attempting to get cloud discovery metadata from authority configuration");
|
|
7741
7833
|
this.logger.verbosePii(`Known Authorities: ${this.authorityOptions.knownAuthorities ||
|
|
7742
7834
|
Constants.NOT_APPLICABLE}`);
|
|
7743
7835
|
this.logger.verbosePii(`Authority Metadata: ${this.authorityOptions.authorityMetadata ||
|
|
@@ -7745,17 +7837,29 @@ class Authority {
|
|
|
7745
7837
|
this.logger.verbosePii(`Canonical Authority: ${metadataEntity.canonical_authority || Constants.NOT_APPLICABLE}`);
|
|
7746
7838
|
let metadata = this.getCloudDiscoveryMetadataFromConfig();
|
|
7747
7839
|
if (metadata) {
|
|
7748
|
-
this.logger.verbose("Found cloud discovery metadata in
|
|
7840
|
+
this.logger.verbose("Found cloud discovery metadata in authority configuration");
|
|
7749
7841
|
metadataEntity.updateCloudDiscoveryMetadata(metadata, false);
|
|
7750
7842
|
return AuthorityMetadataSource.CONFIG;
|
|
7751
7843
|
}
|
|
7752
|
-
// If the cached metadata came from config but that config was not passed to this instance, we must go to
|
|
7753
|
-
this.logger.verbose("Did not find cloud discovery metadata in the config... Attempting to get cloud discovery metadata from the
|
|
7844
|
+
// If the cached metadata came from config but that config was not passed to this instance, we must go to hardcoded values
|
|
7845
|
+
this.logger.verbose("Did not find cloud discovery metadata in the config... Attempting to get cloud discovery metadata from the hardcoded values.");
|
|
7846
|
+
if (this.options.skipAuthorityMetadataCache) {
|
|
7847
|
+
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.");
|
|
7848
|
+
}
|
|
7849
|
+
else {
|
|
7850
|
+
const hardcodedMetadata = this.getCloudDiscoveryMetadataFromHardcodedValues();
|
|
7851
|
+
if (hardcodedMetadata) {
|
|
7852
|
+
this.logger.verbose("Found cloud discovery metadata from hardcoded values.");
|
|
7853
|
+
metadataEntity.updateCloudDiscoveryMetadata(hardcodedMetadata, false);
|
|
7854
|
+
return AuthorityMetadataSource.HARDCODED_VALUES;
|
|
7855
|
+
}
|
|
7856
|
+
this.logger.verbose("Did not find cloud discovery metadata in hardcoded values... Attempting to get cloud discovery metadata from the network metadata cache.");
|
|
7857
|
+
}
|
|
7754
7858
|
const metadataEntityExpired = metadataEntity.isExpired();
|
|
7755
7859
|
if (this.isAuthoritySameType(metadataEntity) &&
|
|
7756
7860
|
metadataEntity.aliasesFromNetwork &&
|
|
7757
7861
|
!metadataEntityExpired) {
|
|
7758
|
-
this.logger.verbose("Found metadata in the cache.");
|
|
7862
|
+
this.logger.verbose("Found cloud discovery metadata in the cache.");
|
|
7759
7863
|
// No need to update
|
|
7760
7864
|
return AuthorityMetadataSource.CACHE;
|
|
7761
7865
|
}
|
|
@@ -7770,15 +7874,8 @@ class Authority {
|
|
|
7770
7874
|
metadataEntity.updateCloudDiscoveryMetadata(metadata, true);
|
|
7771
7875
|
return AuthorityMetadataSource.NETWORK;
|
|
7772
7876
|
}
|
|
7773
|
-
this.logger.verbose("Did not find cloud discovery metadata from the network... Attempting to get cloud discovery metadata from hardcoded values.");
|
|
7774
|
-
const harcodedMetadata = this.getCloudDiscoveryMetadataFromHarcodedValues();
|
|
7775
|
-
if (harcodedMetadata && !this.options.skipAuthorityMetadataCache) {
|
|
7776
|
-
this.logger.verbose("Found cloud discovery metadata from hardcoded values.");
|
|
7777
|
-
metadataEntity.updateCloudDiscoveryMetadata(harcodedMetadata, false);
|
|
7778
|
-
return AuthorityMetadataSource.HARDCODED_VALUES;
|
|
7779
|
-
}
|
|
7780
7877
|
// Metadata could not be obtained from the config, cache, network or hardcoded values
|
|
7781
|
-
this.logger.error("Did not find cloud discovery metadata from
|
|
7878
|
+
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.");
|
|
7782
7879
|
throw ClientConfigurationError.createUntrustedAuthorityError();
|
|
7783
7880
|
}
|
|
7784
7881
|
/**
|
|
@@ -7883,9 +7980,11 @@ class Authority {
|
|
|
7883
7980
|
/**
|
|
7884
7981
|
* Get cloud discovery metadata for common authorities
|
|
7885
7982
|
*/
|
|
7886
|
-
|
|
7983
|
+
getCloudDiscoveryMetadataFromHardcodedValues() {
|
|
7887
7984
|
if (this.canonicalAuthority in InstanceDiscoveryMetadata) {
|
|
7888
|
-
|
|
7985
|
+
const hardcodedMetadataResponse = InstanceDiscoveryMetadata[this.canonicalAuthority];
|
|
7986
|
+
const metadata = Authority.getCloudDiscoveryMetadataFromNetworkResponse(hardcodedMetadataResponse.metadata, this.hostnameAndPort);
|
|
7987
|
+
return metadata;
|
|
7889
7988
|
}
|
|
7890
7989
|
return null;
|
|
7891
7990
|
}
|
|
@@ -7960,6 +8059,13 @@ class Authority {
|
|
|
7960
8059
|
isAlias(host) {
|
|
7961
8060
|
return this.metadata.aliases.indexOf(host) > -1;
|
|
7962
8061
|
}
|
|
8062
|
+
/**
|
|
8063
|
+
* Returns whether or not the provided host is an alias of a known Microsoft authority for purposes of endpoint discovery
|
|
8064
|
+
* @param host
|
|
8065
|
+
*/
|
|
8066
|
+
isAliasOfKnownMicrosoftAuthority(host) {
|
|
8067
|
+
return InstanceDiscoveryMetadataAliases.has(host);
|
|
8068
|
+
}
|
|
7963
8069
|
/**
|
|
7964
8070
|
* Checks whether the provided host is that of a public cloud authority
|
|
7965
8071
|
*
|
|
@@ -8001,15 +8107,17 @@ class Authority {
|
|
|
8001
8107
|
* @param azureRegion string
|
|
8002
8108
|
*/
|
|
8003
8109
|
static replaceWithRegionalInformation(metadata, azureRegion) {
|
|
8004
|
-
metadata
|
|
8005
|
-
|
|
8110
|
+
const regionalMetadata = { ...metadata };
|
|
8111
|
+
regionalMetadata.authorization_endpoint =
|
|
8112
|
+
Authority.buildRegionalAuthorityString(regionalMetadata.authorization_endpoint, azureRegion);
|
|
8006
8113
|
// TODO: Enquire on whether we should leave the query string or remove it before releasing the feature
|
|
8007
|
-
|
|
8008
|
-
|
|
8009
|
-
|
|
8010
|
-
|
|
8114
|
+
regionalMetadata.token_endpoint =
|
|
8115
|
+
Authority.buildRegionalAuthorityString(regionalMetadata.token_endpoint, azureRegion, Constants.REGIONAL_AUTH_NON_MSI_QUERY_STRING);
|
|
8116
|
+
if (regionalMetadata.end_session_endpoint) {
|
|
8117
|
+
regionalMetadata.end_session_endpoint =
|
|
8118
|
+
Authority.buildRegionalAuthorityString(regionalMetadata.end_session_endpoint, azureRegion);
|
|
8011
8119
|
}
|
|
8012
|
-
return
|
|
8120
|
+
return regionalMetadata;
|
|
8013
8121
|
}
|
|
8014
8122
|
/**
|
|
8015
8123
|
* Transform CIAM_AUTHORIY as per the below rules:
|
|
@@ -8021,11 +8129,14 @@ class Authority {
|
|
|
8021
8129
|
* @param authority
|
|
8022
8130
|
*/
|
|
8023
8131
|
static transformCIAMAuthority(authority) {
|
|
8024
|
-
let ciamAuthority = authority.endsWith(Constants.FORWARD_SLASH)
|
|
8132
|
+
let ciamAuthority = authority.endsWith(Constants.FORWARD_SLASH)
|
|
8133
|
+
? authority
|
|
8134
|
+
: `${authority}${Constants.FORWARD_SLASH}`;
|
|
8025
8135
|
const authorityUrl = new UrlString(authority);
|
|
8026
8136
|
const authorityUrlComponents = authorityUrl.getUrlComponents();
|
|
8027
8137
|
// check if transformation is needed
|
|
8028
|
-
if (authorityUrlComponents.PathSegments.length === 0 &&
|
|
8138
|
+
if (authorityUrlComponents.PathSegments.length === 0 &&
|
|
8139
|
+
authorityUrlComponents.HostNameAndPort.endsWith(Constants.CIAM_AUTH_URL)) {
|
|
8029
8140
|
const tenantIdOrDomain = authorityUrlComponents.HostNameAndPort.split(".")[0];
|
|
8030
8141
|
ciamAuthority = `${ciamAuthority}${tenantIdOrDomain}${Constants.AAD_TENANT_DOMAIN_SUFFIX}`;
|
|
8031
8142
|
}
|
|
@@ -8033,13 +8144,13 @@ class Authority {
|
|
|
8033
8144
|
}
|
|
8034
8145
|
}
|
|
8035
8146
|
// Reserved tenant domain names that will not be replaced with tenant id
|
|
8036
|
-
Authority.reservedTenantDomains =
|
|
8147
|
+
Authority.reservedTenantDomains = new Set([
|
|
8037
8148
|
"{tenant}",
|
|
8038
8149
|
"{tenantid}",
|
|
8039
8150
|
AADAuthorityConstants.COMMON,
|
|
8040
8151
|
AADAuthorityConstants.CONSUMERS,
|
|
8041
|
-
AADAuthorityConstants.ORGANIZATIONS
|
|
8042
|
-
])
|
|
8152
|
+
AADAuthorityConstants.ORGANIZATIONS,
|
|
8153
|
+
]);
|
|
8043
8154
|
|
|
8044
8155
|
/*
|
|
8045
8156
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8501,8 +8612,10 @@ class PerformanceClient {
|
|
|
8501
8612
|
* @param {Logger} logger Logger used by the application
|
|
8502
8613
|
* @param {string} libraryName Name of the library
|
|
8503
8614
|
* @param {string} libraryVersion Version of the library
|
|
8615
|
+
* @param {ApplicationTelemetry} applicationTelemetry application name and version
|
|
8616
|
+
* @param {Set<String>} intFields integer fields to be truncated
|
|
8504
8617
|
*/
|
|
8505
|
-
constructor(clientId, authority, logger, libraryName, libraryVersion, applicationTelemetry) {
|
|
8618
|
+
constructor(clientId, authority, logger, libraryName, libraryVersion, applicationTelemetry, intFields) {
|
|
8506
8619
|
this.authority = authority;
|
|
8507
8620
|
this.libraryName = libraryName;
|
|
8508
8621
|
this.libraryVersion = libraryVersion;
|
|
@@ -8513,6 +8626,10 @@ class PerformanceClient {
|
|
|
8513
8626
|
this.eventsByCorrelationId = new Map();
|
|
8514
8627
|
this.queueMeasurements = new Map();
|
|
8515
8628
|
this.preQueueTimeByCorrelationId = new Map();
|
|
8629
|
+
this.intFields = intFields || new Set();
|
|
8630
|
+
for (const item of IntFields) {
|
|
8631
|
+
this.intFields.add(item);
|
|
8632
|
+
}
|
|
8516
8633
|
}
|
|
8517
8634
|
/**
|
|
8518
8635
|
* Starts and returns an platform-specific implementation of IPerformanceMeasurement.
|
|
@@ -8527,13 +8644,6 @@ class PerformanceClient {
|
|
|
8527
8644
|
) {
|
|
8528
8645
|
return {};
|
|
8529
8646
|
}
|
|
8530
|
-
/**
|
|
8531
|
-
* Get integral fields.
|
|
8532
|
-
* Override to change the set.
|
|
8533
|
-
*/
|
|
8534
|
-
getIntFields() {
|
|
8535
|
-
return IntFields;
|
|
8536
|
-
}
|
|
8537
8647
|
/**
|
|
8538
8648
|
* Gets map of pre-queue times by correlation Id
|
|
8539
8649
|
*
|
|
@@ -8651,7 +8761,7 @@ class PerformanceClient {
|
|
|
8651
8761
|
this.cacheEventByCorrelationId(inProgressEvent);
|
|
8652
8762
|
// Return the event and functions the caller can use to properly end/flush the measurement
|
|
8653
8763
|
return {
|
|
8654
|
-
|
|
8764
|
+
end: (event) => {
|
|
8655
8765
|
return this.endMeasurement({
|
|
8656
8766
|
// Initial set of event properties
|
|
8657
8767
|
...inProgressEvent,
|
|
@@ -8659,14 +8769,14 @@ class PerformanceClient {
|
|
|
8659
8769
|
...event,
|
|
8660
8770
|
}, performanceMeasurement);
|
|
8661
8771
|
},
|
|
8662
|
-
|
|
8772
|
+
discard: () => {
|
|
8663
8773
|
return this.discardMeasurements(inProgressEvent.correlationId);
|
|
8664
8774
|
},
|
|
8665
|
-
|
|
8666
|
-
return this.
|
|
8775
|
+
add: (fields) => {
|
|
8776
|
+
return this.addFields(fields, inProgressEvent.correlationId);
|
|
8667
8777
|
},
|
|
8668
|
-
increment: (
|
|
8669
|
-
return this.
|
|
8778
|
+
increment: (fields) => {
|
|
8779
|
+
return this.incrementFields(fields, inProgressEvent.correlationId);
|
|
8670
8780
|
},
|
|
8671
8781
|
measurement: performanceMeasurement,
|
|
8672
8782
|
event: inProgressEvent,
|
|
@@ -8731,7 +8841,7 @@ class PerformanceClient {
|
|
|
8731
8841
|
status: PerformanceEventStatus.Completed,
|
|
8732
8842
|
incompleteSubsCount,
|
|
8733
8843
|
};
|
|
8734
|
-
this.truncateIntegralFields(finalEvent
|
|
8844
|
+
this.truncateIntegralFields(finalEvent);
|
|
8735
8845
|
this.emitEvents([finalEvent], event.correlationId);
|
|
8736
8846
|
return finalEvent;
|
|
8737
8847
|
}
|
|
@@ -8740,7 +8850,7 @@ class PerformanceClient {
|
|
|
8740
8850
|
* @param fields
|
|
8741
8851
|
* @param correlationId
|
|
8742
8852
|
*/
|
|
8743
|
-
|
|
8853
|
+
addFields(fields, correlationId) {
|
|
8744
8854
|
this.logger.trace("PerformanceClient: Updating static fields");
|
|
8745
8855
|
const event = this.eventsByCorrelationId.get(correlationId);
|
|
8746
8856
|
if (event) {
|
|
@@ -8755,18 +8865,21 @@ class PerformanceClient {
|
|
|
8755
8865
|
}
|
|
8756
8866
|
/**
|
|
8757
8867
|
* Increment counters to be emitted when the measurements are flushed
|
|
8758
|
-
* @param
|
|
8868
|
+
* @param fields {string[]}
|
|
8759
8869
|
* @param correlationId {string} correlation identifier
|
|
8760
8870
|
*/
|
|
8761
|
-
|
|
8871
|
+
incrementFields(fields, correlationId) {
|
|
8762
8872
|
this.logger.trace("PerformanceClient: Updating counters");
|
|
8763
8873
|
const event = this.eventsByCorrelationId.get(correlationId);
|
|
8764
8874
|
if (event) {
|
|
8765
|
-
for (const counter in
|
|
8875
|
+
for (const counter in fields) {
|
|
8766
8876
|
if (!event.hasOwnProperty(counter)) {
|
|
8767
8877
|
event[counter] = 0;
|
|
8768
8878
|
}
|
|
8769
|
-
event[counter]
|
|
8879
|
+
else if (isNaN(Number(event[counter]))) {
|
|
8880
|
+
return;
|
|
8881
|
+
}
|
|
8882
|
+
event[counter] += fields[counter];
|
|
8770
8883
|
}
|
|
8771
8884
|
}
|
|
8772
8885
|
else {
|
|
@@ -8884,8 +8997,8 @@ class PerformanceClient {
|
|
|
8884
8997
|
* @param {PerformanceEvent} event performance event to update.
|
|
8885
8998
|
* @param {Set<string>} intFields integral fields.
|
|
8886
8999
|
*/
|
|
8887
|
-
truncateIntegralFields(event
|
|
8888
|
-
intFields.forEach((key) => {
|
|
9000
|
+
truncateIntegralFields(event) {
|
|
9001
|
+
this.intFields.forEach((key) => {
|
|
8889
9002
|
if (key in event && typeof event[key] === "number") {
|
|
8890
9003
|
event[key] = Math.floor(event[key]);
|
|
8891
9004
|
}
|
|
@@ -8898,9 +9011,15 @@ class PerformanceClient {
|
|
|
8898
9011
|
* Licensed under the MIT License.
|
|
8899
9012
|
*/
|
|
8900
9013
|
class StubPerformanceMeasurement {
|
|
8901
|
-
startMeasurement() {
|
|
8902
|
-
|
|
8903
|
-
|
|
9014
|
+
startMeasurement() {
|
|
9015
|
+
return;
|
|
9016
|
+
}
|
|
9017
|
+
endMeasurement() {
|
|
9018
|
+
return;
|
|
9019
|
+
}
|
|
9020
|
+
flushMeasurement() {
|
|
9021
|
+
return null;
|
|
9022
|
+
}
|
|
8904
9023
|
}
|
|
8905
9024
|
class StubPerformanceClient extends PerformanceClient {
|
|
8906
9025
|
generateId() {
|
|
@@ -8912,8 +9031,36 @@ class StubPerformanceClient extends PerformanceClient {
|
|
|
8912
9031
|
calculateQueuedTime() {
|
|
8913
9032
|
return 0;
|
|
8914
9033
|
}
|
|
8915
|
-
addQueueMeasurement() {
|
|
8916
|
-
|
|
9034
|
+
addQueueMeasurement() {
|
|
9035
|
+
return;
|
|
9036
|
+
}
|
|
9037
|
+
setPreQueueTime() {
|
|
9038
|
+
return;
|
|
9039
|
+
}
|
|
9040
|
+
endMeasurement() {
|
|
9041
|
+
return null;
|
|
9042
|
+
}
|
|
9043
|
+
discardMeasurements() {
|
|
9044
|
+
return;
|
|
9045
|
+
}
|
|
9046
|
+
removePerformanceCallback() {
|
|
9047
|
+
return true;
|
|
9048
|
+
}
|
|
9049
|
+
addPerformanceCallback() {
|
|
9050
|
+
return "";
|
|
9051
|
+
}
|
|
9052
|
+
emitEvents() {
|
|
9053
|
+
return;
|
|
9054
|
+
}
|
|
9055
|
+
addFields() {
|
|
9056
|
+
return;
|
|
9057
|
+
}
|
|
9058
|
+
incrementFields() {
|
|
9059
|
+
return;
|
|
9060
|
+
}
|
|
9061
|
+
cacheEventByCorrelationId() {
|
|
9062
|
+
return;
|
|
9063
|
+
}
|
|
8917
9064
|
}
|
|
8918
9065
|
|
|
8919
9066
|
exports.AADAuthorityConstants = AADAuthorityConstants;
|
|
@@ -8981,6 +9128,7 @@ exports.ResponseMode = ResponseMode;
|
|
|
8981
9128
|
exports.SSOTypes = SSOTypes;
|
|
8982
9129
|
exports.ScopeSet = ScopeSet;
|
|
8983
9130
|
exports.ServerError = ServerError;
|
|
9131
|
+
exports.ServerResponseType = ServerResponseType;
|
|
8984
9132
|
exports.ServerTelemetryEntity = ServerTelemetryEntity;
|
|
8985
9133
|
exports.ServerTelemetryManager = ServerTelemetryManager;
|
|
8986
9134
|
exports.SilentFlowClient = SilentFlowClient;
|