@azure/msal-common 5.0.1 → 6.1.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/CHANGELOG.json +1319 -1187
- package/CHANGELOG.md +504 -452
- package/LICENSE +21 -21
- package/README.md +62 -62
- package/dist/_virtual/_tslib.js +1 -1
- package/dist/account/AuthToken.js +1 -1
- package/dist/account/AuthToken.js.map +1 -1
- package/dist/account/CcsCredential.js +1 -1
- package/dist/account/CcsCredential.js.map +1 -1
- package/dist/account/ClientInfo.js +1 -1
- package/dist/account/ClientInfo.js.map +1 -1
- package/dist/account/TokenClaims.d.ts +1 -0
- package/dist/account/TokenClaims.d.ts.map +1 -1
- package/dist/authority/Authority.d.ts +9 -1
- package/dist/authority/Authority.d.ts.map +1 -1
- package/dist/authority/Authority.js +43 -12
- package/dist/authority/Authority.js.map +1 -1
- package/dist/authority/AuthorityFactory.d.ts +2 -2
- package/dist/authority/AuthorityFactory.d.ts.map +1 -1
- package/dist/authority/AuthorityFactory.js +5 -5
- package/dist/authority/AuthorityFactory.js.map +1 -1
- package/dist/authority/AuthorityOptions.d.ts +7 -0
- package/dist/authority/AuthorityOptions.d.ts.map +1 -1
- package/dist/authority/AuthorityOptions.js +22 -0
- package/dist/authority/AuthorityOptions.js.map +1 -0
- package/dist/authority/AuthorityType.js +1 -1
- package/dist/authority/AuthorityType.js.map +1 -1
- package/dist/authority/CloudInstanceDiscoveryResponse.js +1 -1
- package/dist/authority/CloudInstanceDiscoveryResponse.js.map +1 -1
- package/dist/authority/ImdsOptions.d.ts +7 -0
- package/dist/authority/ImdsOptions.d.ts.map +1 -0
- package/dist/authority/OpenIdConfigResponse.d.ts +1 -1
- package/dist/authority/OpenIdConfigResponse.d.ts.map +1 -1
- package/dist/authority/OpenIdConfigResponse.js +1 -2
- package/dist/authority/OpenIdConfigResponse.js.map +1 -1
- package/dist/authority/ProtocolMode.js +1 -1
- package/dist/authority/ProtocolMode.js.map +1 -1
- package/dist/authority/RegionDiscovery.d.ts +3 -6
- package/dist/authority/RegionDiscovery.d.ts.map +1 -1
- package/dist/authority/RegionDiscovery.js +19 -11
- package/dist/authority/RegionDiscovery.js.map +1 -1
- package/dist/cache/CacheManager.d.ts +15 -5
- package/dist/cache/CacheManager.d.ts.map +1 -1
- package/dist/cache/CacheManager.js +49 -18
- package/dist/cache/CacheManager.js.map +1 -1
- package/dist/cache/entities/AccessTokenEntity.d.ts +3 -1
- package/dist/cache/entities/AccessTokenEntity.d.ts.map +1 -1
- package/dist/cache/entities/AccessTokenEntity.js +23 -10
- package/dist/cache/entities/AccessTokenEntity.js.map +1 -1
- package/dist/cache/entities/AccountEntity.js +1 -1
- package/dist/cache/entities/AccountEntity.js.map +1 -1
- package/dist/cache/entities/AppMetadataEntity.js +1 -1
- package/dist/cache/entities/AppMetadataEntity.js.map +1 -1
- package/dist/cache/entities/AuthorityMetadataEntity.d.ts +1 -1
- package/dist/cache/entities/AuthorityMetadataEntity.d.ts.map +1 -1
- package/dist/cache/entities/AuthorityMetadataEntity.js +1 -2
- package/dist/cache/entities/AuthorityMetadataEntity.js.map +1 -1
- package/dist/cache/entities/CacheRecord.js +1 -1
- package/dist/cache/entities/CacheRecord.js.map +1 -1
- package/dist/cache/entities/CredentialEntity.d.ts +13 -2
- package/dist/cache/entities/CredentialEntity.d.ts.map +1 -1
- package/dist/cache/entities/CredentialEntity.js +25 -10
- package/dist/cache/entities/CredentialEntity.js.map +1 -1
- package/dist/cache/entities/IdTokenEntity.js +1 -1
- package/dist/cache/entities/IdTokenEntity.js.map +1 -1
- package/dist/cache/entities/RefreshTokenEntity.js +1 -1
- package/dist/cache/entities/RefreshTokenEntity.js.map +1 -1
- package/dist/cache/entities/ServerTelemetryEntity.js +1 -1
- package/dist/cache/entities/ServerTelemetryEntity.js.map +1 -1
- package/dist/cache/entities/ThrottlingEntity.js +1 -1
- package/dist/cache/entities/ThrottlingEntity.js.map +1 -1
- package/dist/cache/persistence/TokenCacheContext.js +1 -1
- package/dist/cache/persistence/TokenCacheContext.js.map +1 -1
- package/dist/cache/utils/CacheTypes.d.ts +2 -0
- package/dist/cache/utils/CacheTypes.d.ts.map +1 -1
- package/dist/client/AuthorizationCodeClient.d.ts +1 -0
- package/dist/client/AuthorizationCodeClient.d.ts.map +1 -1
- package/dist/client/AuthorizationCodeClient.js +49 -10
- package/dist/client/AuthorizationCodeClient.js.map +1 -1
- package/dist/client/BaseClient.js +2 -2
- package/dist/client/BaseClient.js.map +1 -1
- package/dist/client/ClientCredentialClient.d.ts.map +1 -1
- package/dist/client/ClientCredentialClient.js +4 -2
- package/dist/client/ClientCredentialClient.js.map +1 -1
- package/dist/client/DeviceCodeClient.d.ts.map +1 -1
- package/dist/client/DeviceCodeClient.js +9 -4
- package/dist/client/DeviceCodeClient.js.map +1 -1
- package/dist/client/OnBehalfOfClient.d.ts.map +1 -1
- package/dist/client/OnBehalfOfClient.js +4 -2
- package/dist/client/OnBehalfOfClient.js.map +1 -1
- package/dist/client/RefreshTokenClient.d.ts.map +1 -1
- package/dist/client/RefreshTokenClient.js +20 -8
- package/dist/client/RefreshTokenClient.js.map +1 -1
- package/dist/client/SilentFlowClient.d.ts.map +1 -1
- package/dist/client/SilentFlowClient.js +14 -18
- package/dist/client/SilentFlowClient.js.map +1 -1
- package/dist/client/UsernamePasswordClient.d.ts.map +1 -1
- package/dist/client/UsernamePasswordClient.js +4 -2
- package/dist/client/UsernamePasswordClient.js.map +1 -1
- package/dist/config/ClientConfiguration.d.ts +13 -0
- package/dist/config/ClientConfiguration.d.ts.map +1 -1
- package/dist/config/ClientConfiguration.js +9 -3
- package/dist/config/ClientConfiguration.js.map +1 -1
- package/dist/crypto/ICrypto.d.ts +6 -1
- package/dist/crypto/ICrypto.d.ts.map +1 -1
- package/dist/crypto/ICrypto.js +10 -1
- package/dist/crypto/ICrypto.js.map +1 -1
- package/dist/crypto/PopTokenGenerator.js +4 -4
- package/dist/crypto/PopTokenGenerator.js.map +1 -1
- package/dist/error/AuthError.js +1 -1
- package/dist/error/AuthError.js.map +1 -1
- package/dist/error/ClientAuthError.d.ts +8 -0
- package/dist/error/ClientAuthError.d.ts.map +1 -1
- package/dist/error/ClientAuthError.js +11 -1
- package/dist/error/ClientAuthError.js.map +1 -1
- package/dist/error/ClientConfigurationError.d.ts +40 -0
- package/dist/error/ClientConfigurationError.d.ts.map +1 -1
- package/dist/error/ClientConfigurationError.js +53 -3
- package/dist/error/ClientConfigurationError.js.map +1 -1
- package/dist/error/InteractionRequiredAuthError.js +1 -1
- package/dist/error/InteractionRequiredAuthError.js.map +1 -1
- package/dist/error/ServerError.js +1 -1
- package/dist/error/ServerError.js.map +1 -1
- package/dist/index.cjs.js +445 -115
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/logger/Logger.js +1 -1
- package/dist/logger/Logger.js.map +1 -1
- package/dist/network/INetworkModule.d.ts +1 -0
- package/dist/network/INetworkModule.d.ts.map +1 -1
- package/dist/network/INetworkModule.js +1 -1
- package/dist/network/INetworkModule.js.map +1 -1
- package/dist/network/NetworkManager.js +1 -1
- package/dist/network/NetworkManager.js.map +1 -1
- package/dist/network/RequestThumbprint.d.ts +2 -0
- package/dist/network/RequestThumbprint.d.ts.map +1 -1
- package/dist/network/ThrottlingUtils.d.ts.map +1 -1
- package/dist/network/ThrottlingUtils.js +4 -2
- package/dist/network/ThrottlingUtils.js.map +1 -1
- package/dist/packageMetadata.d.ts +1 -1
- package/dist/packageMetadata.js +2 -2
- package/dist/packageMetadata.js.map +1 -1
- package/dist/request/AuthenticationHeaderParser.d.ts +20 -0
- package/dist/request/AuthenticationHeaderParser.d.ts.map +1 -0
- package/dist/request/AuthenticationHeaderParser.js +64 -0
- package/dist/request/AuthenticationHeaderParser.js.map +1 -0
- package/dist/request/BaseAuthRequest.d.ts +14 -3
- package/dist/request/BaseAuthRequest.d.ts.map +1 -1
- package/dist/request/CommonAuthorizationCodeRequest.d.ts +3 -0
- package/dist/request/CommonAuthorizationCodeRequest.d.ts.map +1 -1
- package/dist/request/CommonEndSessionRequest.d.ts +2 -0
- package/dist/request/CommonEndSessionRequest.d.ts.map +1 -1
- package/dist/request/RequestParameterBuilder.d.ts +8 -0
- package/dist/request/RequestParameterBuilder.d.ts.map +1 -1
- package/dist/request/RequestParameterBuilder.js +16 -1
- package/dist/request/RequestParameterBuilder.js.map +1 -1
- package/dist/request/RequestValidator.js +1 -1
- package/dist/request/RequestValidator.js.map +1 -1
- package/dist/request/ScopeSet.js +1 -1
- package/dist/request/ScopeSet.js.map +1 -1
- package/dist/response/AuthenticationResult.d.ts +2 -1
- package/dist/response/AuthenticationResult.d.ts.map +1 -1
- package/dist/response/ResponseHandler.d.ts +1 -1
- package/dist/response/ResponseHandler.d.ts.map +1 -1
- package/dist/response/ResponseHandler.js +11 -8
- package/dist/response/ResponseHandler.js.map +1 -1
- package/dist/response/ServerAuthorizationTokenResponse.d.ts +3 -0
- package/dist/response/ServerAuthorizationTokenResponse.d.ts.map +1 -1
- package/dist/telemetry/server/ServerTelemetryManager.js +1 -1
- package/dist/telemetry/server/ServerTelemetryManager.js.map +1 -1
- package/dist/url/UrlString.js +1 -1
- package/dist/url/UrlString.js.map +1 -1
- package/dist/utils/Constants.d.ts +9 -3
- package/dist/utils/Constants.d.ts.map +1 -1
- package/dist/utils/Constants.js +8 -2
- package/dist/utils/Constants.js.map +1 -1
- package/dist/utils/ProtocolUtils.js +1 -1
- package/dist/utils/ProtocolUtils.js.map +1 -1
- package/dist/utils/StringUtils.js +1 -1
- package/dist/utils/StringUtils.js.map +1 -1
- package/dist/utils/TimeUtils.js +1 -1
- package/dist/utils/TimeUtils.js.map +1 -1
- package/package.json +76 -76
package/dist/index.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @azure/msal-common
|
|
1
|
+
/*! @azure/msal-common v6.1.0 2022-02-08 */
|
|
2
2
|
'use strict';
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
@@ -102,6 +102,7 @@ var Constants = {
|
|
|
102
102
|
// default authority
|
|
103
103
|
DEFAULT_AUTHORITY: "https://login.microsoftonline.com/common/",
|
|
104
104
|
DEFAULT_AUTHORITY_HOST: "login.microsoftonline.com",
|
|
105
|
+
DEFAULT_COMMON_TENANT: "common",
|
|
105
106
|
// ADFS String
|
|
106
107
|
ADFS: "adfs",
|
|
107
108
|
// Default AAD Instance Discovery Endpoint
|
|
@@ -153,6 +154,8 @@ var HeaderNames;
|
|
|
153
154
|
HeaderNames["CONTENT_TYPE"] = "Content-Type";
|
|
154
155
|
HeaderNames["RETRY_AFTER"] = "Retry-After";
|
|
155
156
|
HeaderNames["CCS_HEADER"] = "X-AnchorMailbox";
|
|
157
|
+
HeaderNames["WWWAuthenticate"] = "WWW-Authenticate";
|
|
158
|
+
HeaderNames["AuthenticationInfo"] = "Authentication-Info";
|
|
156
159
|
})(HeaderNames || (HeaderNames = {}));
|
|
157
160
|
/**
|
|
158
161
|
* Persistent cache keys MSAL which stay while user is logged in.
|
|
@@ -223,6 +226,8 @@ var AADServerParamKeys;
|
|
|
223
226
|
AADServerParamKeys["ON_BEHALF_OF"] = "on_behalf_of";
|
|
224
227
|
AADServerParamKeys["FOCI"] = "foci";
|
|
225
228
|
AADServerParamKeys["CCS_HEADER"] = "X-AnchorMailbox";
|
|
229
|
+
AADServerParamKeys["RETURN_SPA_CODE"] = "return_spa_code";
|
|
230
|
+
AADServerParamKeys["LOGOUT_HINT"] = "logout_hint";
|
|
226
231
|
})(AADServerParamKeys || (AADServerParamKeys = {}));
|
|
227
232
|
/**
|
|
228
233
|
* Claims request keys
|
|
@@ -387,8 +392,9 @@ var SERVER_TELEM_CONSTANTS = {
|
|
|
387
392
|
*/
|
|
388
393
|
exports.AuthenticationScheme = void 0;
|
|
389
394
|
(function (AuthenticationScheme) {
|
|
390
|
-
AuthenticationScheme["POP"] = "pop";
|
|
391
395
|
AuthenticationScheme["BEARER"] = "Bearer";
|
|
396
|
+
AuthenticationScheme["POP"] = "pop";
|
|
397
|
+
AuthenticationScheme["SSH"] = "ssh-cert";
|
|
392
398
|
})(exports.AuthenticationScheme || (exports.AuthenticationScheme = {}));
|
|
393
399
|
/**
|
|
394
400
|
* Constants related to throttling
|
|
@@ -556,6 +562,15 @@ var DEFAULT_CRYPTO_IMPLEMENTATION = {
|
|
|
556
562
|
throw AuthError.createUnexpectedError(notImplErr);
|
|
557
563
|
});
|
|
558
564
|
});
|
|
565
|
+
},
|
|
566
|
+
hashString: function () {
|
|
567
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
568
|
+
var notImplErr;
|
|
569
|
+
return __generator(this, function (_a) {
|
|
570
|
+
notImplErr = "Crypto interface - hashString() has not been implemented";
|
|
571
|
+
throw AuthError.createUnexpectedError(notImplErr);
|
|
572
|
+
});
|
|
573
|
+
});
|
|
559
574
|
}
|
|
560
575
|
};
|
|
561
576
|
|
|
@@ -743,6 +758,10 @@ var ClientAuthErrorMessage = {
|
|
|
743
758
|
bindingKeyNotRemovedError: {
|
|
744
759
|
code: "binding_key_not_removed",
|
|
745
760
|
desc: "Could not remove the credential's binding key from storage."
|
|
761
|
+
},
|
|
762
|
+
logoutNotSupported: {
|
|
763
|
+
code: "end_session_endpoint_not_supported",
|
|
764
|
+
desc: "Provided authority does not support logout."
|
|
746
765
|
}
|
|
747
766
|
};
|
|
748
767
|
/**
|
|
@@ -1006,6 +1025,12 @@ var ClientAuthError = /** @class */ (function (_super) {
|
|
|
1006
1025
|
ClientAuthError.createBindingKeyNotRemovedError = function () {
|
|
1007
1026
|
return new ClientAuthError(ClientAuthErrorMessage.bindingKeyNotRemovedError.code, ClientAuthErrorMessage.bindingKeyNotRemovedError.desc);
|
|
1008
1027
|
};
|
|
1028
|
+
/**
|
|
1029
|
+
* Thrown when logout is attempted for an authority that doesnt have an end_session_endpoint
|
|
1030
|
+
*/
|
|
1031
|
+
ClientAuthError.createLogoutNotSupportedError = function () {
|
|
1032
|
+
return new ClientAuthError(ClientAuthErrorMessage.logoutNotSupported.code, ClientAuthErrorMessage.logoutNotSupported.desc);
|
|
1033
|
+
};
|
|
1009
1034
|
return ClientAuthError;
|
|
1010
1035
|
}(AuthError));
|
|
1011
1036
|
|
|
@@ -1312,7 +1337,25 @@ var Logger = /** @class */ (function () {
|
|
|
1312
1337
|
|
|
1313
1338
|
/* eslint-disable header/header */
|
|
1314
1339
|
var name = "@azure/msal-common";
|
|
1315
|
-
var version = "
|
|
1340
|
+
var version = "6.1.0";
|
|
1341
|
+
|
|
1342
|
+
/*
|
|
1343
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1344
|
+
* Licensed under the MIT License.
|
|
1345
|
+
*/
|
|
1346
|
+
exports.AzureCloudInstance = void 0;
|
|
1347
|
+
(function (AzureCloudInstance) {
|
|
1348
|
+
// AzureCloudInstance is not specified.
|
|
1349
|
+
AzureCloudInstance[AzureCloudInstance["None"] = 0] = "None";
|
|
1350
|
+
// Microsoft Azure public cloud
|
|
1351
|
+
AzureCloudInstance["AzurePublic"] = "https://login.microsoftonline.com";
|
|
1352
|
+
// Microsoft Chinese national cloud
|
|
1353
|
+
AzureCloudInstance["AzureChina"] = "https://login.chinacloudapi.cn";
|
|
1354
|
+
// Microsoft German national cloud ("Black Forest")
|
|
1355
|
+
AzureCloudInstance["AzureGermany"] = "https://login.microsoftonline.de";
|
|
1356
|
+
// US Government cloud
|
|
1357
|
+
AzureCloudInstance["AzureUsGovernment"] = "https://login.microsoftonline.us";
|
|
1358
|
+
})(exports.AzureCloudInstance || (exports.AzureCloudInstance = {}));
|
|
1316
1359
|
|
|
1317
1360
|
/*
|
|
1318
1361
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1323,7 +1366,7 @@ var version = "5.0.1";
|
|
|
1323
1366
|
*
|
|
1324
1367
|
* Key:Value Schema:
|
|
1325
1368
|
*
|
|
1326
|
-
* Key: <home_account_id*>-<environment>-<credential_type>-<client_id>-<realm*>-<target*>-<scheme
|
|
1369
|
+
* Key: <home_account_id*>-<environment>-<credential_type>-<client_id>-<realm*>-<target*>-<requestedClaims*>-<scheme*>
|
|
1327
1370
|
*
|
|
1328
1371
|
* Value Schema:
|
|
1329
1372
|
* {
|
|
@@ -1337,6 +1380,7 @@ var version = "5.0.1";
|
|
|
1337
1380
|
* target: Permissions that are included in the token, or for refresh tokens, the resource identifier.
|
|
1338
1381
|
* oboAssertion: access token passed in as part of OBO request
|
|
1339
1382
|
* tokenType: Matches the authentication scheme for which the token was issued (i.e. Bearer or pop)
|
|
1383
|
+
* requestedClaimsHash: Matches the SHA 256 hash of the claims object included in the token request
|
|
1340
1384
|
* }
|
|
1341
1385
|
*/
|
|
1342
1386
|
var CredentialEntity = /** @class */ (function () {
|
|
@@ -1364,7 +1408,7 @@ var CredentialEntity = /** @class */ (function () {
|
|
|
1364
1408
|
* generates credential key
|
|
1365
1409
|
*/
|
|
1366
1410
|
CredentialEntity.prototype.generateCredentialKey = function () {
|
|
1367
|
-
return CredentialEntity.generateCredentialCacheKey(this.homeAccountId, this.environment, this.credentialType, this.clientId, this.realm, this.target, this.familyId, this.tokenType);
|
|
1411
|
+
return CredentialEntity.generateCredentialCacheKey(this.homeAccountId, this.environment, this.credentialType, this.clientId, this.realm, this.target, this.familyId, this.tokenType, this.requestedClaimsHash);
|
|
1368
1412
|
};
|
|
1369
1413
|
/**
|
|
1370
1414
|
* returns the type of the cache (in this case credential)
|
|
@@ -1408,16 +1452,14 @@ var CredentialEntity = /** @class */ (function () {
|
|
|
1408
1452
|
* generates credential key
|
|
1409
1453
|
* <home_account_id*>-\<environment>-<credential_type>-<client_id>-<realm\*>-<target\*>-<scheme\*>
|
|
1410
1454
|
*/
|
|
1411
|
-
CredentialEntity.generateCredentialCacheKey = function (homeAccountId, environment, credentialType, clientId, realm, target, familyId, tokenType) {
|
|
1455
|
+
CredentialEntity.generateCredentialCacheKey = function (homeAccountId, environment, credentialType, clientId, realm, target, familyId, tokenType, requestedClaimsHash) {
|
|
1412
1456
|
var credentialKey = [
|
|
1413
1457
|
this.generateAccountIdForCacheKey(homeAccountId, environment),
|
|
1414
1458
|
this.generateCredentialIdForCacheKey(credentialType, clientId, realm, familyId),
|
|
1415
|
-
this.generateTargetForCacheKey(target)
|
|
1459
|
+
this.generateTargetForCacheKey(target),
|
|
1460
|
+
this.generateClaimsHashForCacheKey(requestedClaimsHash),
|
|
1461
|
+
this.generateSchemeForCacheKey(tokenType)
|
|
1416
1462
|
];
|
|
1417
|
-
// PoP Tokens include scheme in cache key
|
|
1418
|
-
if (tokenType === exports.AuthenticationScheme.POP) {
|
|
1419
|
-
credentialKey.push(tokenType.toLowerCase());
|
|
1420
|
-
}
|
|
1421
1463
|
return credentialKey.join(Separators.CACHE_KEY_SEPARATOR).toLowerCase();
|
|
1422
1464
|
};
|
|
1423
1465
|
/**
|
|
@@ -1453,6 +1495,22 @@ var CredentialEntity = /** @class */ (function () {
|
|
|
1453
1495
|
CredentialEntity.generateTargetForCacheKey = function (scopes) {
|
|
1454
1496
|
return (scopes || "").toLowerCase();
|
|
1455
1497
|
};
|
|
1498
|
+
/**
|
|
1499
|
+
* Generate requested claims key component as per schema: <requestedClaims>
|
|
1500
|
+
*/
|
|
1501
|
+
CredentialEntity.generateClaimsHashForCacheKey = function (requestedClaimsHash) {
|
|
1502
|
+
return (requestedClaimsHash || "").toLowerCase();
|
|
1503
|
+
};
|
|
1504
|
+
/**
|
|
1505
|
+
* Generate scheme key componenet as per schema: <scheme>
|
|
1506
|
+
*/
|
|
1507
|
+
CredentialEntity.generateSchemeForCacheKey = function (tokenType) {
|
|
1508
|
+
/*
|
|
1509
|
+
* PoP Tokens and SSH certs include scheme in cache key
|
|
1510
|
+
* Cast to lowercase to handle "bearer" from ADFS
|
|
1511
|
+
*/
|
|
1512
|
+
return (tokenType && tokenType.toLowerCase() !== exports.AuthenticationScheme.BEARER.toLowerCase()) ? tokenType.toLowerCase() : "";
|
|
1513
|
+
};
|
|
1456
1514
|
return CredentialEntity;
|
|
1457
1515
|
}());
|
|
1458
1516
|
|
|
@@ -1526,15 +1584,35 @@ var ClientConfigurationErrorMessage = {
|
|
|
1526
1584
|
},
|
|
1527
1585
|
invalidCloudDiscoveryMetadata: {
|
|
1528
1586
|
code: "invalid_cloud_discovery_metadata",
|
|
1529
|
-
desc: "Invalid cloudDiscoveryMetadata provided. Must be a JSON object containing tenant_discovery_endpoint and metadata fields"
|
|
1587
|
+
desc: "Invalid cloudDiscoveryMetadata provided. Must be a stringified JSON object containing tenant_discovery_endpoint and metadata fields"
|
|
1530
1588
|
},
|
|
1531
1589
|
invalidAuthorityMetadata: {
|
|
1532
1590
|
code: "invalid_authority_metadata",
|
|
1533
|
-
desc: "Invalid authorityMetadata provided. Must by a JSON object containing authorization_endpoint, token_endpoint,
|
|
1591
|
+
desc: "Invalid authorityMetadata provided. Must by a stringified JSON object containing authorization_endpoint, token_endpoint, issuer fields."
|
|
1534
1592
|
},
|
|
1535
1593
|
untrustedAuthority: {
|
|
1536
1594
|
code: "untrusted_authority",
|
|
1537
1595
|
desc: "The provided authority is not a trusted authority. Please include this authority in the knownAuthorities config parameter."
|
|
1596
|
+
},
|
|
1597
|
+
invalidAzureCloudInstance: {
|
|
1598
|
+
code: "invalid_azure_cloud_instance",
|
|
1599
|
+
desc: "Invalid AzureCloudInstance provided. Please refer MSAL JS docs: aks.ms/msaljs/azure_cloud_instance for valid values"
|
|
1600
|
+
},
|
|
1601
|
+
missingSshJwk: {
|
|
1602
|
+
code: "missing_ssh_jwk",
|
|
1603
|
+
desc: "Missing sshJwk in SSH certificate request. A stringified JSON Web Key is required when using the SSH authentication scheme."
|
|
1604
|
+
},
|
|
1605
|
+
missingSshKid: {
|
|
1606
|
+
code: "missing_ssh_kid",
|
|
1607
|
+
desc: "Missing sshKid in SSH certificate request. A string that uniquely identifies the public SSH key is required when using the SSH authentication scheme."
|
|
1608
|
+
},
|
|
1609
|
+
missingNonceAuthenticationHeader: {
|
|
1610
|
+
code: "missing_nonce_authentication_header",
|
|
1611
|
+
desc: "Unable to find an authentication header containing server nonce. Either the Authentication-Info or WWW-Authenticate headers must be present in order to obtain a server nonce."
|
|
1612
|
+
},
|
|
1613
|
+
invalidAuthenticationHeader: {
|
|
1614
|
+
code: "invalid_authentication_header",
|
|
1615
|
+
desc: "Invalid authentication header provided"
|
|
1538
1616
|
}
|
|
1539
1617
|
};
|
|
1540
1618
|
/**
|
|
@@ -1656,6 +1734,36 @@ var ClientConfigurationError = /** @class */ (function (_super) {
|
|
|
1656
1734
|
ClientConfigurationError.createUntrustedAuthorityError = function () {
|
|
1657
1735
|
return new ClientConfigurationError(ClientConfigurationErrorMessage.untrustedAuthority.code, ClientConfigurationErrorMessage.untrustedAuthority.desc);
|
|
1658
1736
|
};
|
|
1737
|
+
/**
|
|
1738
|
+
* Throws error when the AzureCloudInstance is set to an invalid value
|
|
1739
|
+
*/
|
|
1740
|
+
ClientConfigurationError.createInvalidAzureCloudInstanceError = function () {
|
|
1741
|
+
return new ClientConfigurationError(ClientConfigurationErrorMessage.invalidAzureCloudInstance.code, ClientConfigurationErrorMessage.invalidAzureCloudInstance.desc);
|
|
1742
|
+
};
|
|
1743
|
+
/**
|
|
1744
|
+
* Throws an error when the authentication scheme is set to SSH but the SSH public key is omitted from the request
|
|
1745
|
+
*/
|
|
1746
|
+
ClientConfigurationError.createMissingSshJwkError = function () {
|
|
1747
|
+
return new ClientConfigurationError(ClientConfigurationErrorMessage.missingSshJwk.code, ClientConfigurationErrorMessage.missingSshJwk.desc);
|
|
1748
|
+
};
|
|
1749
|
+
/**
|
|
1750
|
+
* Throws an error when the authentication scheme is set to SSH but the SSH public key ID is omitted from the request
|
|
1751
|
+
*/
|
|
1752
|
+
ClientConfigurationError.createMissingSshKidError = function () {
|
|
1753
|
+
return new ClientConfigurationError(ClientConfigurationErrorMessage.missingSshKid.code, ClientConfigurationErrorMessage.missingSshKid.desc);
|
|
1754
|
+
};
|
|
1755
|
+
/**
|
|
1756
|
+
* Throws error when provided headers don't contain a header that a server nonce can be extracted from
|
|
1757
|
+
*/
|
|
1758
|
+
ClientConfigurationError.createMissingNonceAuthenticationHeadersError = function () {
|
|
1759
|
+
return new ClientConfigurationError(ClientConfigurationErrorMessage.missingNonceAuthenticationHeader.code, ClientConfigurationErrorMessage.missingNonceAuthenticationHeader.desc);
|
|
1760
|
+
};
|
|
1761
|
+
/**
|
|
1762
|
+
* Throws error when a provided header is invalid in any way
|
|
1763
|
+
*/
|
|
1764
|
+
ClientConfigurationError.createInvalidAuthenticationHeaderError = function (invalidHeaderName, details) {
|
|
1765
|
+
return new ClientConfigurationError(ClientConfigurationErrorMessage.invalidAuthenticationHeader.code, ClientConfigurationErrorMessage.invalidAuthenticationHeader.desc + ". Invalid header: " + invalidHeaderName + ". Details: " + details);
|
|
1766
|
+
};
|
|
1659
1767
|
return ClientConfigurationError;
|
|
1660
1768
|
}(ClientAuthError));
|
|
1661
1769
|
|
|
@@ -2246,7 +2354,8 @@ var CacheManager = /** @class */ (function () {
|
|
|
2246
2354
|
environment: credential.environment,
|
|
2247
2355
|
homeAccountId: credential.homeAccountId,
|
|
2248
2356
|
realm: credential.realm,
|
|
2249
|
-
tokenType: credential.tokenType
|
|
2357
|
+
tokenType: credential.tokenType,
|
|
2358
|
+
requestedClaimsHash: credential.requestedClaimsHash
|
|
2250
2359
|
});
|
|
2251
2360
|
currentScopes = ScopeSet.fromString(credential.target);
|
|
2252
2361
|
currentAccessTokens = Object.keys(currentTokenCache.accessTokens).map(function (key) { return currentTokenCache.accessTokens[key]; });
|
|
@@ -2318,7 +2427,7 @@ var CacheManager = /** @class */ (function () {
|
|
|
2318
2427
|
* @param target
|
|
2319
2428
|
*/
|
|
2320
2429
|
CacheManager.prototype.getCredentialsFilteredBy = function (filter) {
|
|
2321
|
-
return this.getCredentialsFilteredByInternal(filter.homeAccountId, filter.environment, filter.credentialType, filter.clientId, filter.familyId, filter.realm, filter.target, filter.oboAssertion, filter.tokenType);
|
|
2430
|
+
return this.getCredentialsFilteredByInternal(filter.homeAccountId, filter.environment, filter.credentialType, filter.clientId, filter.familyId, filter.realm, filter.target, filter.oboAssertion, filter.tokenType, filter.keyId, filter.requestedClaimsHash);
|
|
2322
2431
|
};
|
|
2323
2432
|
/**
|
|
2324
2433
|
* Support function to help match credentials
|
|
@@ -2331,7 +2440,7 @@ var CacheManager = /** @class */ (function () {
|
|
|
2331
2440
|
* @param oboAssertion
|
|
2332
2441
|
* @param tokenType
|
|
2333
2442
|
*/
|
|
2334
|
-
CacheManager.prototype.getCredentialsFilteredByInternal = function (homeAccountId, environment, credentialType, clientId, familyId, realm, target, oboAssertion, tokenType) {
|
|
2443
|
+
CacheManager.prototype.getCredentialsFilteredByInternal = function (homeAccountId, environment, credentialType, clientId, familyId, realm, target, oboAssertion, tokenType, keyId, requestedClaimsHash) {
|
|
2335
2444
|
var _this = this;
|
|
2336
2445
|
var allCacheKeys = this.getKeys();
|
|
2337
2446
|
var matchingCredentials = {
|
|
@@ -2378,27 +2487,37 @@ var CacheManager = /** @class */ (function () {
|
|
|
2378
2487
|
if (!!target && !_this.matchTarget(entity, target)) {
|
|
2379
2488
|
return;
|
|
2380
2489
|
}
|
|
2490
|
+
// If request OR cached entity has requested Claims Hash, check if they match
|
|
2491
|
+
if (requestedClaimsHash || entity.requestedClaimsHash) {
|
|
2492
|
+
// Don't match if either is undefined or they are different
|
|
2493
|
+
if (entity.requestedClaimsHash !== requestedClaimsHash) {
|
|
2494
|
+
return;
|
|
2495
|
+
}
|
|
2496
|
+
}
|
|
2497
|
+
// Access Token with Auth Scheme specific matching
|
|
2381
2498
|
if (credentialType === exports.CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME) {
|
|
2382
2499
|
if (!!tokenType && !_this.matchTokenType(entity, tokenType)) {
|
|
2383
2500
|
return;
|
|
2384
2501
|
}
|
|
2385
|
-
//
|
|
2386
|
-
if (
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2502
|
+
// KeyId (sshKid) in request must match cached SSH certificate keyId because SSH cert is bound to a specific key
|
|
2503
|
+
if (tokenType === exports.AuthenticationScheme.SSH) {
|
|
2504
|
+
if (keyId && !_this.matchKeyId(entity, keyId)) {
|
|
2505
|
+
return;
|
|
2506
|
+
}
|
|
2390
2507
|
}
|
|
2391
2508
|
}
|
|
2509
|
+
// At this point, the entity matches the request, update cache key if key schema has changed
|
|
2510
|
+
var updatedCacheKey = _this.updateCredentialCacheKey(cacheKey, entity);
|
|
2392
2511
|
switch (credType) {
|
|
2393
2512
|
case exports.CredentialType.ID_TOKEN:
|
|
2394
|
-
matchingCredentials.idTokens[
|
|
2513
|
+
matchingCredentials.idTokens[updatedCacheKey] = entity;
|
|
2395
2514
|
break;
|
|
2396
2515
|
case exports.CredentialType.ACCESS_TOKEN:
|
|
2397
2516
|
case exports.CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME:
|
|
2398
|
-
matchingCredentials.accessTokens[
|
|
2517
|
+
matchingCredentials.accessTokens[updatedCacheKey] = entity;
|
|
2399
2518
|
break;
|
|
2400
2519
|
case exports.CredentialType.REFRESH_TOKEN:
|
|
2401
|
-
matchingCredentials.refreshTokens[
|
|
2520
|
+
matchingCredentials.refreshTokens[updatedCacheKey] = entity;
|
|
2402
2521
|
break;
|
|
2403
2522
|
}
|
|
2404
2523
|
});
|
|
@@ -2557,6 +2676,7 @@ var CacheManager = /** @class */ (function () {
|
|
|
2557
2676
|
case 0:
|
|
2558
2677
|
key = credential.generateCredentialKey();
|
|
2559
2678
|
if (!(credential.credentialType.toLowerCase() === exports.CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME.toLowerCase())) return [3 /*break*/, 4];
|
|
2679
|
+
if (!(credential.tokenType === exports.AuthenticationScheme.POP)) return [3 /*break*/, 4];
|
|
2560
2680
|
accessTokenWithAuthSchemeEntity = credential;
|
|
2561
2681
|
kid = accessTokenWithAuthSchemeEntity.keyId;
|
|
2562
2682
|
if (!kid) return [3 /*break*/, 4];
|
|
@@ -2596,10 +2716,10 @@ var CacheManager = /** @class */ (function () {
|
|
|
2596
2716
|
* @param environment
|
|
2597
2717
|
* @param authScheme
|
|
2598
2718
|
*/
|
|
2599
|
-
CacheManager.prototype.readCacheRecord = function (account, clientId,
|
|
2719
|
+
CacheManager.prototype.readCacheRecord = function (account, clientId, request, environment) {
|
|
2600
2720
|
var cachedAccount = this.readAccountFromCache(account);
|
|
2601
2721
|
var cachedIdToken = this.readIdTokenFromCache(clientId, account);
|
|
2602
|
-
var cachedAccessToken = this.readAccessTokenFromCache(clientId, account,
|
|
2722
|
+
var cachedAccessToken = this.readAccessTokenFromCache(clientId, account, request);
|
|
2603
2723
|
var cachedRefreshToken = this.readRefreshTokenFromCache(clientId, account, false);
|
|
2604
2724
|
var cachedAppMetadata = this.readAppMetadataFromCache(environment, clientId);
|
|
2605
2725
|
if (cachedAccount && cachedIdToken) {
|
|
@@ -2653,9 +2773,14 @@ var CacheManager = /** @class */ (function () {
|
|
|
2653
2773
|
* @param scopes
|
|
2654
2774
|
* @param authScheme
|
|
2655
2775
|
*/
|
|
2656
|
-
CacheManager.prototype.readAccessTokenFromCache = function (clientId, account,
|
|
2657
|
-
|
|
2658
|
-
var
|
|
2776
|
+
CacheManager.prototype.readAccessTokenFromCache = function (clientId, account, request) {
|
|
2777
|
+
var scopes = new ScopeSet(request.scopes || []);
|
|
2778
|
+
var authScheme = request.authenticationScheme || exports.AuthenticationScheme.BEARER;
|
|
2779
|
+
/*
|
|
2780
|
+
* Distinguish between Bearer and PoP/SSH token cache types
|
|
2781
|
+
* Cast to lowercase to handle "bearer" from ADFS
|
|
2782
|
+
*/
|
|
2783
|
+
var credentialType = (authScheme && authScheme.toLowerCase() !== exports.AuthenticationScheme.BEARER.toLowerCase()) ? exports.CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME : exports.CredentialType.ACCESS_TOKEN;
|
|
2659
2784
|
var accessTokenFilter = {
|
|
2660
2785
|
homeAccountId: account.homeAccountId,
|
|
2661
2786
|
environment: account.environment,
|
|
@@ -2663,7 +2788,9 @@ var CacheManager = /** @class */ (function () {
|
|
|
2663
2788
|
clientId: clientId,
|
|
2664
2789
|
realm: account.tenantId,
|
|
2665
2790
|
target: scopes.printScopesLowerCase(),
|
|
2666
|
-
tokenType: authScheme
|
|
2791
|
+
tokenType: authScheme,
|
|
2792
|
+
keyId: request.sshKid,
|
|
2793
|
+
requestedClaimsHash: request.requestedClaimsHash
|
|
2667
2794
|
};
|
|
2668
2795
|
var credentialCache = this.getCredentialsFilteredBy(accessTokenFilter);
|
|
2669
2796
|
var accessTokens = Object.keys(credentialCache.accessTokens).map(function (key) { return credentialCache.accessTokens[key]; });
|
|
@@ -2816,6 +2943,14 @@ var CacheManager = /** @class */ (function () {
|
|
|
2816
2943
|
CacheManager.prototype.matchTokenType = function (entity, tokenType) {
|
|
2817
2944
|
return !!(entity.tokenType && entity.tokenType === tokenType);
|
|
2818
2945
|
};
|
|
2946
|
+
/**
|
|
2947
|
+
* Returns true if the credential's keyId matches the one in the request, false otherwise
|
|
2948
|
+
* @param entity
|
|
2949
|
+
* @param tokenType
|
|
2950
|
+
*/
|
|
2951
|
+
CacheManager.prototype.matchKeyId = function (entity, keyId) {
|
|
2952
|
+
return !!(entity.keyId && entity.keyId === keyId);
|
|
2953
|
+
};
|
|
2819
2954
|
/**
|
|
2820
2955
|
* returns if a given cache entity is of the type appmetadata
|
|
2821
2956
|
* @param key
|
|
@@ -2964,6 +3099,10 @@ var DefaultStorageClass = /** @class */ (function (_super) {
|
|
|
2964
3099
|
});
|
|
2965
3100
|
});
|
|
2966
3101
|
};
|
|
3102
|
+
DefaultStorageClass.prototype.updateCredentialCacheKey = function () {
|
|
3103
|
+
var notImplErr = "Storage interface - updateCredentialCacheKey() has not been implemented for the cacheStorage interface.";
|
|
3104
|
+
throw AuthError.createUnexpectedError(notImplErr);
|
|
3105
|
+
};
|
|
2967
3106
|
return DefaultStorageClass;
|
|
2968
3107
|
}(CacheManager));
|
|
2969
3108
|
|
|
@@ -2975,7 +3114,8 @@ var DefaultStorageClass = /** @class */ (function (_super) {
|
|
|
2975
3114
|
var DEFAULT_TOKEN_RENEWAL_OFFSET_SEC = 300;
|
|
2976
3115
|
var DEFAULT_SYSTEM_OPTIONS = {
|
|
2977
3116
|
tokenRenewalOffsetSeconds: DEFAULT_TOKEN_RENEWAL_OFFSET_SEC,
|
|
2978
|
-
preventCorsPreflight: false
|
|
3117
|
+
preventCorsPreflight: false,
|
|
3118
|
+
proxyUrl: "",
|
|
2979
3119
|
};
|
|
2980
3120
|
var DEFAULT_LOGGER_IMPLEMENTATION = {
|
|
2981
3121
|
loggerCallback: function () {
|
|
@@ -3015,6 +3155,10 @@ var DEFAULT_CLIENT_CREDENTIALS = {
|
|
|
3015
3155
|
clientSecret: "",
|
|
3016
3156
|
clientAssertion: undefined
|
|
3017
3157
|
};
|
|
3158
|
+
var DEFAULT_AZURE_CLOUD_OPTIONS = {
|
|
3159
|
+
azureCloudInstance: exports.AzureCloudInstance.None,
|
|
3160
|
+
tenant: "" + Constants.DEFAULT_COMMON_TENANT
|
|
3161
|
+
};
|
|
3018
3162
|
/**
|
|
3019
3163
|
* Function that sets the default options when not explicitly configured from app developer
|
|
3020
3164
|
*
|
|
@@ -3044,7 +3188,7 @@ function buildClientConfiguration(_a) {
|
|
|
3044
3188
|
* @param authOptions
|
|
3045
3189
|
*/
|
|
3046
3190
|
function buildAuthOptions(authOptions) {
|
|
3047
|
-
return __assign({ clientCapabilities: [] }, authOptions);
|
|
3191
|
+
return __assign({ clientCapabilities: [], azureCloudOptions: DEFAULT_AZURE_CLOUD_OPTIONS }, authOptions);
|
|
3048
3192
|
}
|
|
3049
3193
|
|
|
3050
3194
|
/*
|
|
@@ -3146,10 +3290,12 @@ var ThrottlingUtils = /** @class */ (function () {
|
|
|
3146
3290
|
authority: request.authority,
|
|
3147
3291
|
scopes: request.scopes,
|
|
3148
3292
|
homeAccountIdentifier: homeAccountIdentifier,
|
|
3293
|
+
claims: request.claims,
|
|
3149
3294
|
authenticationScheme: request.authenticationScheme,
|
|
3150
3295
|
resourceRequestMethod: request.resourceRequestMethod,
|
|
3151
3296
|
resourceRequestUri: request.resourceRequestUri,
|
|
3152
|
-
shrClaims: request.shrClaims
|
|
3297
|
+
shrClaims: request.shrClaims,
|
|
3298
|
+
sshKid: request.sshKid
|
|
3153
3299
|
};
|
|
3154
3300
|
var key = this.generateThrottlingStorageKey(thumbprint);
|
|
3155
3301
|
return cacheManager.removeItem(key, exports.CacheSchemaType.THROTTLING);
|
|
@@ -3276,7 +3422,7 @@ var BaseClient = /** @class */ (function () {
|
|
|
3276
3422
|
var response;
|
|
3277
3423
|
return __generator(this, function (_a) {
|
|
3278
3424
|
switch (_a.label) {
|
|
3279
|
-
case 0: return [4 /*yield*/, this.networkManager.sendPostRequest(thumbprint, tokenEndpoint, { body: queryString, headers: headers })];
|
|
3425
|
+
case 0: return [4 /*yield*/, this.networkManager.sendPostRequest(thumbprint, tokenEndpoint, { body: queryString, headers: headers, proxyUrl: this.config.systemOptions.proxyUrl })];
|
|
3280
3426
|
case 1:
|
|
3281
3427
|
response = _a.sent();
|
|
3282
3428
|
if (this.config.serverTelemetryManager && response.status < 500 && response.status !== 429) {
|
|
@@ -3687,6 +3833,15 @@ var RequestParameterBuilder = /** @class */ (function () {
|
|
|
3687
3833
|
this.parameters.set(AADServerParamKeys.REQ_CNF, encodeURIComponent(cnfString));
|
|
3688
3834
|
}
|
|
3689
3835
|
};
|
|
3836
|
+
/**
|
|
3837
|
+
* add SSH JWK and key ID to query params
|
|
3838
|
+
*/
|
|
3839
|
+
RequestParameterBuilder.prototype.addSshJwk = function (sshJwkString) {
|
|
3840
|
+
if (!StringUtils.isEmpty(sshJwkString)) {
|
|
3841
|
+
this.parameters.set(AADServerParamKeys.TOKEN_TYPE, exports.AuthenticationScheme.SSH);
|
|
3842
|
+
this.parameters.set(AADServerParamKeys.REQ_CNF, encodeURIComponent(sshJwkString));
|
|
3843
|
+
}
|
|
3844
|
+
};
|
|
3690
3845
|
/**
|
|
3691
3846
|
* add server telemetry fields
|
|
3692
3847
|
* @param serverTelemetryManager
|
|
@@ -3701,6 +3856,12 @@ var RequestParameterBuilder = /** @class */ (function () {
|
|
|
3701
3856
|
RequestParameterBuilder.prototype.addThrottling = function () {
|
|
3702
3857
|
this.parameters.set(AADServerParamKeys.X_MS_LIB_CAPABILITY, ThrottlingConstants.X_MS_LIB_CAPABILITY_VALUE);
|
|
3703
3858
|
};
|
|
3859
|
+
/**
|
|
3860
|
+
* Adds logout_hint parameter for "silent" logout which prevent server account picker
|
|
3861
|
+
*/
|
|
3862
|
+
RequestParameterBuilder.prototype.addLogoutHint = function (logoutHint) {
|
|
3863
|
+
this.parameters.set(AADServerParamKeys.LOGOUT_HINT, encodeURIComponent(logoutHint));
|
|
3864
|
+
};
|
|
3704
3865
|
/**
|
|
3705
3866
|
* Utility to create a URL from the params map
|
|
3706
3867
|
*/
|
|
@@ -3870,8 +4031,8 @@ var AccessTokenEntity = /** @class */ (function (_super) {
|
|
|
3870
4031
|
* @param expiresOn
|
|
3871
4032
|
* @param extExpiresOn
|
|
3872
4033
|
*/
|
|
3873
|
-
AccessTokenEntity.createAccessTokenEntity = function (homeAccountId, environment, accessToken, clientId, tenantId, scopes, expiresOn, extExpiresOn, cryptoUtils, refreshOn, tokenType, oboAssertion) {
|
|
3874
|
-
var _a;
|
|
4034
|
+
AccessTokenEntity.createAccessTokenEntity = function (homeAccountId, environment, accessToken, clientId, tenantId, scopes, expiresOn, extExpiresOn, cryptoUtils, refreshOn, tokenType, oboAssertion, keyId, requestedClaims, requestedClaimsHash) {
|
|
4035
|
+
var _a, _b;
|
|
3875
4036
|
var atEntity = new AccessTokenEntity();
|
|
3876
4037
|
atEntity.homeAccountId = homeAccountId;
|
|
3877
4038
|
atEntity.credentialType = exports.CredentialType.ACCESS_TOKEN;
|
|
@@ -3893,15 +4054,28 @@ var AccessTokenEntity = /** @class */ (function (_super) {
|
|
|
3893
4054
|
atEntity.target = scopes;
|
|
3894
4055
|
atEntity.oboAssertion = oboAssertion;
|
|
3895
4056
|
atEntity.tokenType = StringUtils.isEmpty(tokenType) ? exports.AuthenticationScheme.BEARER : tokenType;
|
|
3896
|
-
|
|
3897
|
-
|
|
4057
|
+
if (requestedClaims) {
|
|
4058
|
+
atEntity.requestedClaims = requestedClaims;
|
|
4059
|
+
atEntity.requestedClaimsHash = requestedClaimsHash;
|
|
4060
|
+
}
|
|
4061
|
+
/*
|
|
4062
|
+
* Create Access Token With Auth Scheme instead of regular access token
|
|
4063
|
+
* Cast to lower to handle "bearer" from ADFS
|
|
4064
|
+
*/
|
|
4065
|
+
if (((_a = atEntity.tokenType) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== exports.AuthenticationScheme.BEARER.toLowerCase()) {
|
|
3898
4066
|
atEntity.credentialType = exports.CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME;
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
4067
|
+
switch (atEntity.tokenType) {
|
|
4068
|
+
case exports.AuthenticationScheme.POP:
|
|
4069
|
+
// Make sure keyId is present and add it to credential
|
|
4070
|
+
var tokenClaims = AuthToken.extractTokenClaims(accessToken, cryptoUtils);
|
|
4071
|
+
if (!((_b = tokenClaims === null || tokenClaims === void 0 ? void 0 : tokenClaims.cnf) === null || _b === void 0 ? void 0 : _b.kid)) {
|
|
4072
|
+
throw ClientAuthError.createTokenClaimsRequiredError();
|
|
4073
|
+
}
|
|
4074
|
+
atEntity.keyId = tokenClaims.cnf.kid;
|
|
4075
|
+
break;
|
|
4076
|
+
case exports.AuthenticationScheme.SSH:
|
|
4077
|
+
atEntity.keyId = keyId;
|
|
3903
4078
|
}
|
|
3904
|
-
atEntity.keyId = tokenClaims.cnf.kid;
|
|
3905
4079
|
}
|
|
3906
4080
|
return atEntity;
|
|
3907
4081
|
};
|
|
@@ -4392,14 +4566,14 @@ var PopTokenGenerator = /** @class */ (function () {
|
|
|
4392
4566
|
};
|
|
4393
4567
|
PopTokenGenerator.prototype.signPayload = function (payload, kid, request, claims) {
|
|
4394
4568
|
return __awaiter(this, void 0, void 0, function () {
|
|
4395
|
-
var resourceRequestMethod, resourceRequestUri, shrClaims, resourceUrlString, resourceUrlComponents;
|
|
4569
|
+
var resourceRequestMethod, resourceRequestUri, shrClaims, shrNonce, resourceUrlString, resourceUrlComponents;
|
|
4396
4570
|
return __generator(this, function (_a) {
|
|
4397
4571
|
switch (_a.label) {
|
|
4398
4572
|
case 0:
|
|
4399
|
-
resourceRequestMethod = request.resourceRequestMethod, resourceRequestUri = request.resourceRequestUri, shrClaims = request.shrClaims;
|
|
4573
|
+
resourceRequestMethod = request.resourceRequestMethod, resourceRequestUri = request.resourceRequestUri, shrClaims = request.shrClaims, shrNonce = request.shrNonce;
|
|
4400
4574
|
resourceUrlString = (resourceRequestUri) ? new UrlString(resourceRequestUri) : undefined;
|
|
4401
4575
|
resourceUrlComponents = resourceUrlString === null || resourceUrlString === void 0 ? void 0 : resourceUrlString.getUrlComponents();
|
|
4402
|
-
return [4 /*yield*/, this.cryptoUtils.signJwt(__assign({ at: payload, ts: TimeUtils.nowSeconds(), m: resourceRequestMethod === null || resourceRequestMethod === void 0 ? void 0 : resourceRequestMethod.toUpperCase(), u: resourceUrlComponents === null || resourceUrlComponents === void 0 ? void 0 : resourceUrlComponents.HostNameAndPort, nonce: this.cryptoUtils.createNewGuid(), p: resourceUrlComponents === null || resourceUrlComponents === void 0 ? void 0 : resourceUrlComponents.AbsolutePath, q: (resourceUrlComponents === null || resourceUrlComponents === void 0 ? void 0 : resourceUrlComponents.QueryString) ? [[], resourceUrlComponents.QueryString] : undefined, client_claims: shrClaims || undefined }, claims), kid)];
|
|
4576
|
+
return [4 /*yield*/, this.cryptoUtils.signJwt(__assign({ at: payload, ts: TimeUtils.nowSeconds(), m: resourceRequestMethod === null || resourceRequestMethod === void 0 ? void 0 : resourceRequestMethod.toUpperCase(), u: resourceUrlComponents === null || resourceUrlComponents === void 0 ? void 0 : resourceUrlComponents.HostNameAndPort, nonce: shrNonce || this.cryptoUtils.createNewGuid(), p: resourceUrlComponents === null || resourceUrlComponents === void 0 ? void 0 : resourceUrlComponents.AbsolutePath, q: (resourceUrlComponents === null || resourceUrlComponents === void 0 ? void 0 : resourceUrlComponents.QueryString) ? [[], resourceUrlComponents.QueryString] : undefined, client_claims: shrClaims || undefined }, claims), kid)];
|
|
4403
4577
|
case 1: return [2 /*return*/, _a.sent()];
|
|
4404
4578
|
}
|
|
4405
4579
|
});
|
|
@@ -4590,7 +4764,9 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
4590
4764
|
if (!!authCodePayload && !!authCodePayload.state) {
|
|
4591
4765
|
requestStateObj = ProtocolUtils.parseRequestState(this.cryptoObj, authCodePayload.state);
|
|
4592
4766
|
}
|
|
4593
|
-
|
|
4767
|
+
// Add keyId from request to serverTokenResponse if defined
|
|
4768
|
+
serverTokenResponse.key_id = serverTokenResponse.key_id || request.sshKid || undefined;
|
|
4769
|
+
cacheRecord = this.generateCacheRecord(serverTokenResponse, authority, reqTimestamp, request, idTokenObj, oboAssertion, authCodePayload);
|
|
4594
4770
|
_a.label = 1;
|
|
4595
4771
|
case 1:
|
|
4596
4772
|
_a.trys.push([1, , 5, 8]);
|
|
@@ -4627,7 +4803,7 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
4627
4803
|
_a.sent();
|
|
4628
4804
|
_a.label = 7;
|
|
4629
4805
|
case 7: return [7 /*endfinally*/];
|
|
4630
|
-
case 8: return [2 /*return*/, ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenObj, requestStateObj)];
|
|
4806
|
+
case 8: return [2 /*return*/, ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenObj, requestStateObj, serverTokenResponse.spa_code)];
|
|
4631
4807
|
}
|
|
4632
4808
|
});
|
|
4633
4809
|
});
|
|
@@ -4638,7 +4814,7 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
4638
4814
|
* @param idTokenObj
|
|
4639
4815
|
* @param authority
|
|
4640
4816
|
*/
|
|
4641
|
-
ResponseHandler.prototype.generateCacheRecord = function (serverTokenResponse, authority, reqTimestamp,
|
|
4817
|
+
ResponseHandler.prototype.generateCacheRecord = function (serverTokenResponse, authority, reqTimestamp, request, idTokenObj, oboAssertion, authCodePayload) {
|
|
4642
4818
|
var env = authority.getPreferredCache();
|
|
4643
4819
|
if (StringUtils.isEmpty(env)) {
|
|
4644
4820
|
throw ClientAuthError.createInvalidCacheEnvironmentError();
|
|
@@ -4654,7 +4830,7 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
4654
4830
|
var cachedAccessToken = null;
|
|
4655
4831
|
if (!StringUtils.isEmpty(serverTokenResponse.access_token)) {
|
|
4656
4832
|
// If scopes not returned in server response, use request scopes
|
|
4657
|
-
var responseScopes = serverTokenResponse.scope ? ScopeSet.fromString(serverTokenResponse.scope) : new ScopeSet(
|
|
4833
|
+
var responseScopes = serverTokenResponse.scope ? ScopeSet.fromString(serverTokenResponse.scope) : new ScopeSet(request.scopes || []);
|
|
4658
4834
|
/*
|
|
4659
4835
|
* Use timestamp calculated before request
|
|
4660
4836
|
* Server may return timestamps as strings, parse to numbers if so.
|
|
@@ -4666,7 +4842,7 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
4666
4842
|
var extendedTokenExpirationSeconds = tokenExpirationSeconds + extExpiresIn;
|
|
4667
4843
|
var refreshOnSeconds = refreshIn && refreshIn > 0 ? reqTimestamp + refreshIn : undefined;
|
|
4668
4844
|
// non AAD scenarios can have empty realm
|
|
4669
|
-
cachedAccessToken = AccessTokenEntity.createAccessTokenEntity(this.homeAccountIdentifier, env, serverTokenResponse.access_token || Constants.EMPTY_STRING, this.clientId, idTokenObj ? idTokenObj.claims.tid || Constants.EMPTY_STRING : authority.tenant, responseScopes.printScopes(), tokenExpirationSeconds, extendedTokenExpirationSeconds, this.cryptoObj, refreshOnSeconds, serverTokenResponse.token_type, oboAssertion);
|
|
4845
|
+
cachedAccessToken = AccessTokenEntity.createAccessTokenEntity(this.homeAccountIdentifier, env, serverTokenResponse.access_token || Constants.EMPTY_STRING, this.clientId, idTokenObj ? idTokenObj.claims.tid || Constants.EMPTY_STRING : authority.tenant, responseScopes.printScopes(), tokenExpirationSeconds, extendedTokenExpirationSeconds, this.cryptoObj, refreshOnSeconds, serverTokenResponse.token_type, oboAssertion, serverTokenResponse.key_id, request.claims, request.requestedClaimsHash);
|
|
4670
4846
|
}
|
|
4671
4847
|
// refreshToken
|
|
4672
4848
|
var cachedRefreshToken = null;
|
|
@@ -4713,7 +4889,7 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
4713
4889
|
* @param fromTokenCache
|
|
4714
4890
|
* @param stateString
|
|
4715
4891
|
*/
|
|
4716
|
-
ResponseHandler.generateAuthenticationResult = function (cryptoObj, authority, cacheRecord, fromTokenCache, request, idTokenObj, requestState) {
|
|
4892
|
+
ResponseHandler.generateAuthenticationResult = function (cryptoObj, authority, cacheRecord, fromTokenCache, request, idTokenObj, requestState, code) {
|
|
4717
4893
|
var _a, _b, _c;
|
|
4718
4894
|
return __awaiter(this, void 0, void 0, function () {
|
|
4719
4895
|
var accessToken, responseScopes, expiresOn, extExpiresOn, familyId, popTokenGenerator, uid, tid;
|
|
@@ -4762,7 +4938,8 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
4762
4938
|
tokenType: ((_a = cacheRecord.accessToken) === null || _a === void 0 ? void 0 : _a.tokenType) || Constants.EMPTY_STRING,
|
|
4763
4939
|
state: requestState ? requestState.userRequestState : Constants.EMPTY_STRING,
|
|
4764
4940
|
cloudGraphHostName: ((_b = cacheRecord.account) === null || _b === void 0 ? void 0 : _b.cloudGraphHostName) || Constants.EMPTY_STRING,
|
|
4765
|
-
msGraphHost: ((_c = cacheRecord.account) === null || _c === void 0 ? void 0 : _c.msGraphHost) || Constants.EMPTY_STRING
|
|
4941
|
+
msGraphHost: ((_c = cacheRecord.account) === null || _c === void 0 ? void 0 : _c.msGraphHost) || Constants.EMPTY_STRING,
|
|
4942
|
+
code: code
|
|
4766
4943
|
}];
|
|
4767
4944
|
}
|
|
4768
4945
|
});
|
|
@@ -4781,7 +4958,10 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
4781
4958
|
var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
4782
4959
|
__extends(AuthorizationCodeClient, _super);
|
|
4783
4960
|
function AuthorizationCodeClient(configuration) {
|
|
4784
|
-
|
|
4961
|
+
var _this = _super.call(this, configuration) || this;
|
|
4962
|
+
// Flag to indicate if client is for hybrid spa auth code redemption
|
|
4963
|
+
_this.includeRedirectUri = true;
|
|
4964
|
+
return _this;
|
|
4785
4965
|
}
|
|
4786
4966
|
/**
|
|
4787
4967
|
* Creates the URL of the authorization request letting the user input credentials and consent to the
|
|
@@ -4881,10 +5061,12 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
4881
5061
|
clientId: this.config.authOptions.clientId,
|
|
4882
5062
|
authority: authority.canonicalAuthority,
|
|
4883
5063
|
scopes: request.scopes,
|
|
5064
|
+
claims: request.claims,
|
|
4884
5065
|
authenticationScheme: request.authenticationScheme,
|
|
4885
5066
|
resourceRequestMethod: request.resourceRequestMethod,
|
|
4886
5067
|
resourceRequestUri: request.resourceRequestUri,
|
|
4887
|
-
shrClaims: request.shrClaims
|
|
5068
|
+
shrClaims: request.shrClaims,
|
|
5069
|
+
sshKid: request.sshKid
|
|
4888
5070
|
};
|
|
4889
5071
|
return [4 /*yield*/, this.createTokenRequestBody(request)];
|
|
4890
5072
|
case 1:
|
|
@@ -4928,13 +5110,24 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
4928
5110
|
AuthorizationCodeClient.prototype.createTokenRequestBody = function (request) {
|
|
4929
5111
|
return __awaiter(this, void 0, void 0, function () {
|
|
4930
5112
|
var parameterBuilder, clientAssertion, popTokenGenerator, cnfString, correlationId, ccsCred, clientInfo, clientInfo;
|
|
4931
|
-
|
|
4932
|
-
|
|
5113
|
+
var _a;
|
|
5114
|
+
return __generator(this, function (_b) {
|
|
5115
|
+
switch (_b.label) {
|
|
4933
5116
|
case 0:
|
|
4934
5117
|
parameterBuilder = new RequestParameterBuilder();
|
|
4935
5118
|
parameterBuilder.addClientId(this.config.authOptions.clientId);
|
|
4936
|
-
|
|
4937
|
-
|
|
5119
|
+
/*
|
|
5120
|
+
* For hybrid spa flow, there will be a code but no verifier
|
|
5121
|
+
* In this scenario, don't include redirect uri as auth code will not be bound to redirect URI
|
|
5122
|
+
*/
|
|
5123
|
+
if (!this.includeRedirectUri) {
|
|
5124
|
+
// Just validate
|
|
5125
|
+
RequestValidator.validateRedirectUri(request.redirectUri);
|
|
5126
|
+
}
|
|
5127
|
+
else {
|
|
5128
|
+
// Validate and include redirect uri
|
|
5129
|
+
parameterBuilder.addRedirectUri(request.redirectUri);
|
|
5130
|
+
}
|
|
4938
5131
|
// Add scope array, parameter builder will add default scopes and dedupe
|
|
4939
5132
|
parameterBuilder.addScopes(request.scopes);
|
|
4940
5133
|
// add code: user set, not validated
|
|
@@ -4963,10 +5156,20 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
4963
5156
|
popTokenGenerator = new PopTokenGenerator(this.cryptoUtils);
|
|
4964
5157
|
return [4 /*yield*/, popTokenGenerator.generateCnf(request)];
|
|
4965
5158
|
case 1:
|
|
4966
|
-
cnfString =
|
|
5159
|
+
cnfString = _b.sent();
|
|
4967
5160
|
parameterBuilder.addPopToken(cnfString);
|
|
4968
|
-
|
|
5161
|
+
return [3 /*break*/, 3];
|
|
4969
5162
|
case 2:
|
|
5163
|
+
if (request.authenticationScheme === exports.AuthenticationScheme.SSH) {
|
|
5164
|
+
if (request.sshJwk) {
|
|
5165
|
+
parameterBuilder.addSshJwk(request.sshJwk);
|
|
5166
|
+
}
|
|
5167
|
+
else {
|
|
5168
|
+
throw ClientConfigurationError.createMissingSshJwkError();
|
|
5169
|
+
}
|
|
5170
|
+
}
|
|
5171
|
+
_b.label = 3;
|
|
5172
|
+
case 3:
|
|
4970
5173
|
correlationId = request.correlationId || this.config.cryptoInterface.createNewGuid();
|
|
4971
5174
|
parameterBuilder.addCorrelationId(correlationId);
|
|
4972
5175
|
if (!StringUtils.isEmptyObj(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {
|
|
@@ -5005,6 +5208,15 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
5005
5208
|
break;
|
|
5006
5209
|
}
|
|
5007
5210
|
}
|
|
5211
|
+
if (request.tokenBodyParameters) {
|
|
5212
|
+
parameterBuilder.addExtraQueryParameters(request.tokenBodyParameters);
|
|
5213
|
+
}
|
|
5214
|
+
// Add hybrid spa parameters if not already provided
|
|
5215
|
+
if (request.enableSpaAuthorizationCode && (!request.tokenBodyParameters || !request.tokenBodyParameters[AADServerParamKeys.RETURN_SPA_CODE])) {
|
|
5216
|
+
parameterBuilder.addExtraQueryParameters((_a = {},
|
|
5217
|
+
_a[AADServerParamKeys.RETURN_SPA_CODE] = "1",
|
|
5218
|
+
_a));
|
|
5219
|
+
}
|
|
5008
5220
|
return [2 /*return*/, parameterBuilder.createQueryString()];
|
|
5009
5221
|
}
|
|
5010
5222
|
});
|
|
@@ -5123,6 +5335,9 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
5123
5335
|
if (request.state) {
|
|
5124
5336
|
parameterBuilder.addState(request.state);
|
|
5125
5337
|
}
|
|
5338
|
+
if (request.logoutHint) {
|
|
5339
|
+
parameterBuilder.addLogoutHint(request.logoutHint);
|
|
5340
|
+
}
|
|
5126
5341
|
if (request.extraQueryParameters) {
|
|
5127
5342
|
parameterBuilder.addExtraQueryParameters(request.extraQueryParameters);
|
|
5128
5343
|
}
|
|
@@ -5195,10 +5410,12 @@ var DeviceCodeClient = /** @class */ (function (_super) {
|
|
|
5195
5410
|
clientId: this.config.authOptions.clientId,
|
|
5196
5411
|
authority: request.authority,
|
|
5197
5412
|
scopes: request.scopes,
|
|
5413
|
+
claims: request.claims,
|
|
5198
5414
|
authenticationScheme: request.authenticationScheme,
|
|
5199
5415
|
resourceRequestMethod: request.resourceRequestMethod,
|
|
5200
5416
|
resourceRequestUri: request.resourceRequestUri,
|
|
5201
|
-
shrClaims: request.shrClaims
|
|
5417
|
+
shrClaims: request.shrClaims,
|
|
5418
|
+
sshKid: request.sshKid
|
|
5202
5419
|
};
|
|
5203
5420
|
return [2 /*return*/, this.executePostRequestToDeviceCodeEndpoint(this.authority.deviceCodeEndpoint, queryString, headers, thumbprint)];
|
|
5204
5421
|
});
|
|
@@ -5217,7 +5434,8 @@ var DeviceCodeClient = /** @class */ (function (_super) {
|
|
|
5217
5434
|
switch (_b.label) {
|
|
5218
5435
|
case 0: return [4 /*yield*/, this.networkManager.sendPostRequest(thumbprint, deviceCodeEndpoint, {
|
|
5219
5436
|
body: queryString,
|
|
5220
|
-
headers: headers
|
|
5437
|
+
headers: headers,
|
|
5438
|
+
proxyUrl: this.config.systemOptions.proxyUrl
|
|
5221
5439
|
})];
|
|
5222
5440
|
case 1:
|
|
5223
5441
|
_a = (_b.sent()).body, userCode = _a.user_code, deviceCode = _a.device_code, verificationUri = _a.verification_uri, expiresIn = _a.expires_in, interval = _a.interval, message = _a.message;
|
|
@@ -5292,10 +5510,12 @@ var DeviceCodeClient = /** @class */ (function (_super) {
|
|
|
5292
5510
|
clientId: this.config.authOptions.clientId,
|
|
5293
5511
|
authority: request.authority,
|
|
5294
5512
|
scopes: request.scopes,
|
|
5513
|
+
claims: request.claims,
|
|
5295
5514
|
authenticationScheme: request.authenticationScheme,
|
|
5296
5515
|
resourceRequestMethod: request.resourceRequestMethod,
|
|
5297
5516
|
resourceRequestUri: request.resourceRequestUri,
|
|
5298
|
-
shrClaims: request.shrClaims
|
|
5517
|
+
shrClaims: request.shrClaims,
|
|
5518
|
+
sshKid: request.sshKid
|
|
5299
5519
|
};
|
|
5300
5520
|
return [4 /*yield*/, this.executePostToTokenEndpoint(this.authority.tokenEndpoint, requestBody, headers, thumbprint)];
|
|
5301
5521
|
case 2:
|
|
@@ -5458,10 +5678,12 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
5458
5678
|
clientId: this.config.authOptions.clientId,
|
|
5459
5679
|
authority: authority.canonicalAuthority,
|
|
5460
5680
|
scopes: request.scopes,
|
|
5681
|
+
claims: request.claims,
|
|
5461
5682
|
authenticationScheme: request.authenticationScheme,
|
|
5462
5683
|
resourceRequestMethod: request.resourceRequestMethod,
|
|
5463
5684
|
resourceRequestUri: request.resourceRequestUri,
|
|
5464
|
-
shrClaims: request.shrClaims
|
|
5685
|
+
shrClaims: request.shrClaims,
|
|
5686
|
+
sshKid: request.sshKid
|
|
5465
5687
|
};
|
|
5466
5688
|
endpoint = UrlString.appendQueryString(authority.tokenEndpoint, queryParameters);
|
|
5467
5689
|
return [2 /*return*/, this.executePostToTokenEndpoint(endpoint, requestBody, headers, thumbprint)];
|
|
@@ -5486,9 +5708,9 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
5486
5708
|
*/
|
|
5487
5709
|
RefreshTokenClient.prototype.createTokenRequestBody = function (request) {
|
|
5488
5710
|
return __awaiter(this, void 0, void 0, function () {
|
|
5489
|
-
var parameterBuilder, correlationId, clientAssertion, popTokenGenerator,
|
|
5490
|
-
return __generator(this, function (
|
|
5491
|
-
switch (
|
|
5711
|
+
var parameterBuilder, correlationId, clientAssertion, popTokenGenerator, cnfString, clientInfo;
|
|
5712
|
+
return __generator(this, function (_a) {
|
|
5713
|
+
switch (_a.label) {
|
|
5492
5714
|
case 0:
|
|
5493
5715
|
parameterBuilder = new RequestParameterBuilder();
|
|
5494
5716
|
parameterBuilder.addClientId(this.config.authOptions.clientId);
|
|
@@ -5513,12 +5735,22 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
5513
5735
|
}
|
|
5514
5736
|
if (!(request.authenticationScheme === exports.AuthenticationScheme.POP)) return [3 /*break*/, 2];
|
|
5515
5737
|
popTokenGenerator = new PopTokenGenerator(this.cryptoUtils);
|
|
5516
|
-
_b = (_a = parameterBuilder).addPopToken;
|
|
5517
5738
|
return [4 /*yield*/, popTokenGenerator.generateCnf(request)];
|
|
5518
5739
|
case 1:
|
|
5519
|
-
|
|
5520
|
-
|
|
5740
|
+
cnfString = _a.sent();
|
|
5741
|
+
parameterBuilder.addPopToken(cnfString);
|
|
5742
|
+
return [3 /*break*/, 3];
|
|
5521
5743
|
case 2:
|
|
5744
|
+
if (request.authenticationScheme === exports.AuthenticationScheme.SSH) {
|
|
5745
|
+
if (request.sshJwk) {
|
|
5746
|
+
parameterBuilder.addSshJwk(request.sshJwk);
|
|
5747
|
+
}
|
|
5748
|
+
else {
|
|
5749
|
+
throw ClientConfigurationError.createMissingSshJwkError();
|
|
5750
|
+
}
|
|
5751
|
+
}
|
|
5752
|
+
_a.label = 3;
|
|
5753
|
+
case 3:
|
|
5522
5754
|
if (!StringUtils.isEmptyObj(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {
|
|
5523
5755
|
parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);
|
|
5524
5756
|
}
|
|
@@ -5654,10 +5886,12 @@ var ClientCredentialClient = /** @class */ (function (_super) {
|
|
|
5654
5886
|
clientId: this.config.authOptions.clientId,
|
|
5655
5887
|
authority: request.authority,
|
|
5656
5888
|
scopes: request.scopes,
|
|
5889
|
+
claims: request.claims,
|
|
5657
5890
|
authenticationScheme: request.authenticationScheme,
|
|
5658
5891
|
resourceRequestMethod: request.resourceRequestMethod,
|
|
5659
5892
|
resourceRequestUri: request.resourceRequestUri,
|
|
5660
|
-
shrClaims: request.shrClaims
|
|
5893
|
+
shrClaims: request.shrClaims,
|
|
5894
|
+
sshKid: request.sshKid
|
|
5661
5895
|
};
|
|
5662
5896
|
reqTimestamp = TimeUtils.nowSeconds();
|
|
5663
5897
|
return [4 /*yield*/, this.executePostToTokenEndpoint(authority.tokenEndpoint, requestBody, headers, thumbprint)];
|
|
@@ -5853,10 +6087,12 @@ var OnBehalfOfClient = /** @class */ (function (_super) {
|
|
|
5853
6087
|
clientId: this.config.authOptions.clientId,
|
|
5854
6088
|
authority: request.authority,
|
|
5855
6089
|
scopes: request.scopes,
|
|
6090
|
+
claims: request.claims,
|
|
5856
6091
|
authenticationScheme: request.authenticationScheme,
|
|
5857
6092
|
resourceRequestMethod: request.resourceRequestMethod,
|
|
5858
6093
|
resourceRequestUri: request.resourceRequestUri,
|
|
5859
|
-
shrClaims: request.shrClaims
|
|
6094
|
+
shrClaims: request.shrClaims,
|
|
6095
|
+
sshKid: request.sshKid
|
|
5860
6096
|
};
|
|
5861
6097
|
reqTimestamp = TimeUtils.nowSeconds();
|
|
5862
6098
|
return [4 /*yield*/, this.executePostToTokenEndpoint(authority.tokenEndpoint, requestBody, headers, thumbprint)];
|
|
@@ -5948,7 +6184,7 @@ var SilentFlowClient = /** @class */ (function (_super) {
|
|
|
5948
6184
|
SilentFlowClient.prototype.acquireCachedToken = function (request) {
|
|
5949
6185
|
var _a, _b, _c, _d;
|
|
5950
6186
|
return __awaiter(this, void 0, void 0, function () {
|
|
5951
|
-
var
|
|
6187
|
+
var environment, cacheRecord;
|
|
5952
6188
|
return __generator(this, function (_e) {
|
|
5953
6189
|
switch (_e.label) {
|
|
5954
6190
|
case 0:
|
|
@@ -5956,37 +6192,35 @@ var SilentFlowClient = /** @class */ (function (_super) {
|
|
|
5956
6192
|
if (!request) {
|
|
5957
6193
|
throw ClientConfigurationError.createEmptyTokenRequestError();
|
|
5958
6194
|
}
|
|
5959
|
-
// We currently do not support silent flow for account === null use cases; This will be revisited for confidential flow usecases
|
|
5960
|
-
if (!request.account) {
|
|
5961
|
-
throw ClientAuthError.createNoAccountInSilentRequestError();
|
|
5962
|
-
}
|
|
5963
|
-
requestScopes = new ScopeSet(request.scopes || []);
|
|
5964
|
-
environment = request.authority || this.authority.getPreferredCache();
|
|
5965
|
-
authScheme = request.authenticationScheme || exports.AuthenticationScheme.BEARER;
|
|
5966
|
-
cacheRecord = this.cacheManager.readCacheRecord(request.account, this.config.authOptions.clientId, requestScopes, environment, authScheme);
|
|
5967
6195
|
if (request.forceRefresh) {
|
|
5968
6196
|
// Must refresh due to present force_refresh flag.
|
|
5969
6197
|
(_a = this.serverTelemetryManager) === null || _a === void 0 ? void 0 : _a.setCacheOutcome(CacheOutcome.FORCE_REFRESH);
|
|
6198
|
+
this.logger.info("SilentFlowClient:acquireCachedToken - Skipping cache because forceRefresh is true.");
|
|
5970
6199
|
throw ClientAuthError.createRefreshRequiredError();
|
|
5971
6200
|
}
|
|
5972
|
-
|
|
6201
|
+
// We currently do not support silent flow for account === null use cases; This will be revisited for confidential flow usecases
|
|
6202
|
+
if (!request.account) {
|
|
6203
|
+
throw ClientAuthError.createNoAccountInSilentRequestError();
|
|
6204
|
+
}
|
|
6205
|
+
environment = request.authority || this.authority.getPreferredCache();
|
|
6206
|
+
cacheRecord = this.cacheManager.readCacheRecord(request.account, this.config.authOptions.clientId, request, environment);
|
|
6207
|
+
if (!cacheRecord.accessToken) {
|
|
5973
6208
|
// Must refresh due to non-existent access_token.
|
|
5974
6209
|
(_b = this.serverTelemetryManager) === null || _b === void 0 ? void 0 : _b.setCacheOutcome(CacheOutcome.NO_CACHED_ACCESS_TOKEN);
|
|
6210
|
+
this.logger.info("SilentFlowClient:acquireCachedToken - No access token found in cache for the given properties.");
|
|
5975
6211
|
throw ClientAuthError.createRefreshRequiredError();
|
|
5976
6212
|
}
|
|
5977
6213
|
else if (TimeUtils.wasClockTurnedBack(cacheRecord.accessToken.cachedAt) ||
|
|
5978
6214
|
TimeUtils.isTokenExpired(cacheRecord.accessToken.expiresOn, this.config.systemOptions.tokenRenewalOffsetSeconds)) {
|
|
5979
6215
|
// Must refresh due to expired access_token.
|
|
5980
6216
|
(_c = this.serverTelemetryManager) === null || _c === void 0 ? void 0 : _c.setCacheOutcome(CacheOutcome.CACHED_ACCESS_TOKEN_EXPIRED);
|
|
6217
|
+
this.logger.info("SilentFlowClient:acquireCachedToken - Cached access token is expired or will expire within " + this.config.systemOptions.tokenRenewalOffsetSeconds + " seconds.");
|
|
5981
6218
|
throw ClientAuthError.createRefreshRequiredError();
|
|
5982
6219
|
}
|
|
5983
6220
|
else if (cacheRecord.accessToken.refreshOn && TimeUtils.isTokenExpired(cacheRecord.accessToken.refreshOn, 0)) {
|
|
5984
6221
|
// Must refresh due to the refresh_in value.
|
|
5985
6222
|
(_d = this.serverTelemetryManager) === null || _d === void 0 ? void 0 : _d.setCacheOutcome(CacheOutcome.REFRESH_CACHED_ACCESS_TOKEN);
|
|
5986
|
-
|
|
5987
|
-
}
|
|
5988
|
-
else if (!StringUtils.isEmptyObj(request.claims)) {
|
|
5989
|
-
// Must refresh due to request parameters.
|
|
6223
|
+
this.logger.info("SilentFlowClient:acquireCachedToken - Cached access token's refreshOn property has been exceeded'.");
|
|
5990
6224
|
throw ClientAuthError.createRefreshRequiredError();
|
|
5991
6225
|
}
|
|
5992
6226
|
if (this.config.serverTelemetryManager) {
|
|
@@ -6071,10 +6305,12 @@ var UsernamePasswordClient = /** @class */ (function (_super) {
|
|
|
6071
6305
|
clientId: this.config.authOptions.clientId,
|
|
6072
6306
|
authority: authority.canonicalAuthority,
|
|
6073
6307
|
scopes: request.scopes,
|
|
6308
|
+
claims: request.claims,
|
|
6074
6309
|
authenticationScheme: request.authenticationScheme,
|
|
6075
6310
|
resourceRequestMethod: request.resourceRequestMethod,
|
|
6076
6311
|
resourceRequestUri: request.resourceRequestUri,
|
|
6077
|
-
shrClaims: request.shrClaims
|
|
6312
|
+
shrClaims: request.shrClaims,
|
|
6313
|
+
sshKid: request.sshKid
|
|
6078
6314
|
};
|
|
6079
6315
|
requestBody = this.createTokenRequestBody(request);
|
|
6080
6316
|
headers = this.createTokenRequestHeaders({
|
|
@@ -6130,7 +6366,6 @@ var UsernamePasswordClient = /** @class */ (function (_super) {
|
|
|
6130
6366
|
function isOpenIdConfigResponse(response) {
|
|
6131
6367
|
return (response.hasOwnProperty("authorization_endpoint") &&
|
|
6132
6368
|
response.hasOwnProperty("token_endpoint") &&
|
|
6133
|
-
response.hasOwnProperty("end_session_endpoint") &&
|
|
6134
6369
|
response.hasOwnProperty("issuer"));
|
|
6135
6370
|
}
|
|
6136
6371
|
|
|
@@ -6212,7 +6447,6 @@ var AuthorityMetadataEntity = /** @class */ (function () {
|
|
|
6212
6447
|
entity.hasOwnProperty("canonical_authority") &&
|
|
6213
6448
|
entity.hasOwnProperty("authorization_endpoint") &&
|
|
6214
6449
|
entity.hasOwnProperty("token_endpoint") &&
|
|
6215
|
-
entity.hasOwnProperty("end_session_endpoint") &&
|
|
6216
6450
|
entity.hasOwnProperty("issuer") &&
|
|
6217
6451
|
entity.hasOwnProperty("aliasesFromNetwork") &&
|
|
6218
6452
|
entity.hasOwnProperty("endpointsFromNetwork") &&
|
|
@@ -6243,18 +6477,22 @@ var RegionDiscovery = /** @class */ (function () {
|
|
|
6243
6477
|
*
|
|
6244
6478
|
* @returns Promise<string | null>
|
|
6245
6479
|
*/
|
|
6246
|
-
RegionDiscovery.prototype.detectRegion = function (environmentRegion, regionDiscoveryMetadata) {
|
|
6480
|
+
RegionDiscovery.prototype.detectRegion = function (environmentRegion, regionDiscoveryMetadata, proxyUrl) {
|
|
6247
6481
|
return __awaiter(this, void 0, void 0, function () {
|
|
6248
|
-
var autodetectedRegionName, localIMDSVersionResponse, currentIMDSVersion, currentIMDSVersionResponse;
|
|
6482
|
+
var autodetectedRegionName, options, localIMDSVersionResponse, currentIMDSVersion, currentIMDSVersionResponse;
|
|
6249
6483
|
return __generator(this, function (_a) {
|
|
6250
6484
|
switch (_a.label) {
|
|
6251
6485
|
case 0:
|
|
6252
6486
|
autodetectedRegionName = environmentRegion;
|
|
6253
6487
|
if (!!autodetectedRegionName) return [3 /*break*/, 8];
|
|
6488
|
+
options = RegionDiscovery.IMDS_OPTIONS;
|
|
6489
|
+
if (proxyUrl) {
|
|
6490
|
+
options.proxyUrl = proxyUrl;
|
|
6491
|
+
}
|
|
6254
6492
|
_a.label = 1;
|
|
6255
6493
|
case 1:
|
|
6256
6494
|
_a.trys.push([1, 6, , 7]);
|
|
6257
|
-
return [4 /*yield*/, this.getRegionFromIMDS(Constants.IMDS_VERSION)];
|
|
6495
|
+
return [4 /*yield*/, this.getRegionFromIMDS(Constants.IMDS_VERSION, options)];
|
|
6258
6496
|
case 2:
|
|
6259
6497
|
localIMDSVersionResponse = _a.sent();
|
|
6260
6498
|
if (localIMDSVersionResponse.status === ResponseCodes.httpSuccess) {
|
|
@@ -6262,14 +6500,14 @@ var RegionDiscovery = /** @class */ (function () {
|
|
|
6262
6500
|
regionDiscoveryMetadata.region_source = RegionDiscoverySources.IMDS;
|
|
6263
6501
|
}
|
|
6264
6502
|
if (!(localIMDSVersionResponse.status === ResponseCodes.httpBadRequest)) return [3 /*break*/, 5];
|
|
6265
|
-
return [4 /*yield*/, this.getCurrentVersion()];
|
|
6503
|
+
return [4 /*yield*/, this.getCurrentVersion(options)];
|
|
6266
6504
|
case 3:
|
|
6267
6505
|
currentIMDSVersion = _a.sent();
|
|
6268
6506
|
if (!currentIMDSVersion) {
|
|
6269
6507
|
regionDiscoveryMetadata.region_source = RegionDiscoverySources.FAILED_AUTO_DETECTION;
|
|
6270
6508
|
return [2 /*return*/, null];
|
|
6271
6509
|
}
|
|
6272
|
-
return [4 /*yield*/, this.getRegionFromIMDS(currentIMDSVersion)];
|
|
6510
|
+
return [4 /*yield*/, this.getRegionFromIMDS(currentIMDSVersion, options)];
|
|
6273
6511
|
case 4:
|
|
6274
6512
|
currentIMDSVersionResponse = _a.sent();
|
|
6275
6513
|
if (currentIMDSVersionResponse.status === ResponseCodes.httpSuccess) {
|
|
@@ -6302,10 +6540,10 @@ var RegionDiscovery = /** @class */ (function () {
|
|
|
6302
6540
|
* @param imdsEndpointUrl
|
|
6303
6541
|
* @returns Promise<NetworkResponse<string>>
|
|
6304
6542
|
*/
|
|
6305
|
-
RegionDiscovery.prototype.getRegionFromIMDS = function (version) {
|
|
6543
|
+
RegionDiscovery.prototype.getRegionFromIMDS = function (version, options) {
|
|
6306
6544
|
return __awaiter(this, void 0, void 0, function () {
|
|
6307
6545
|
return __generator(this, function (_a) {
|
|
6308
|
-
return [2 /*return*/, this.networkInterface.sendGetRequestAsync(Constants.IMDS_ENDPOINT + "?api-version=" + version + "&format=text",
|
|
6546
|
+
return [2 /*return*/, this.networkInterface.sendGetRequestAsync(Constants.IMDS_ENDPOINT + "?api-version=" + version + "&format=text", options, Constants.IMDS_TIMEOUT)];
|
|
6309
6547
|
});
|
|
6310
6548
|
});
|
|
6311
6549
|
};
|
|
@@ -6314,14 +6552,14 @@ var RegionDiscovery = /** @class */ (function () {
|
|
|
6314
6552
|
*
|
|
6315
6553
|
* @returns Promise<string | null>
|
|
6316
6554
|
*/
|
|
6317
|
-
RegionDiscovery.prototype.getCurrentVersion = function () {
|
|
6555
|
+
RegionDiscovery.prototype.getCurrentVersion = function (options) {
|
|
6318
6556
|
return __awaiter(this, void 0, void 0, function () {
|
|
6319
6557
|
var response;
|
|
6320
6558
|
return __generator(this, function (_a) {
|
|
6321
6559
|
switch (_a.label) {
|
|
6322
6560
|
case 0:
|
|
6323
6561
|
_a.trys.push([0, 2, , 3]);
|
|
6324
|
-
return [4 /*yield*/, this.networkInterface.sendGetRequestAsync(Constants.IMDS_ENDPOINT + "?format=json",
|
|
6562
|
+
return [4 /*yield*/, this.networkInterface.sendGetRequestAsync(Constants.IMDS_ENDPOINT + "?format=json", options)];
|
|
6325
6563
|
case 1:
|
|
6326
6564
|
response = _a.sent();
|
|
6327
6565
|
// When IMDS endpoint is called without the api version query param, bad request response comes back with latest version.
|
|
@@ -6338,7 +6576,11 @@ var RegionDiscovery = /** @class */ (function () {
|
|
|
6338
6576
|
});
|
|
6339
6577
|
};
|
|
6340
6578
|
// Options for the IMDS endpoint request
|
|
6341
|
-
RegionDiscovery.IMDS_OPTIONS = {
|
|
6579
|
+
RegionDiscovery.IMDS_OPTIONS = {
|
|
6580
|
+
headers: {
|
|
6581
|
+
Metadata: "true",
|
|
6582
|
+
},
|
|
6583
|
+
};
|
|
6342
6584
|
return RegionDiscovery;
|
|
6343
6585
|
}());
|
|
6344
6586
|
|
|
@@ -6351,7 +6593,7 @@ var RegionDiscovery = /** @class */ (function () {
|
|
|
6351
6593
|
* endpoint. It will store the pertinent config data in this object for use during token calls.
|
|
6352
6594
|
*/
|
|
6353
6595
|
var Authority = /** @class */ (function () {
|
|
6354
|
-
function Authority(authority, networkInterface, cacheManager, authorityOptions) {
|
|
6596
|
+
function Authority(authority, networkInterface, cacheManager, authorityOptions, proxyUrl) {
|
|
6355
6597
|
this.canonicalAuthority = authority;
|
|
6356
6598
|
this._canonicalAuthority.validateAsUri();
|
|
6357
6599
|
this.networkInterface = networkInterface;
|
|
@@ -6359,6 +6601,7 @@ var Authority = /** @class */ (function () {
|
|
|
6359
6601
|
this.authorityOptions = authorityOptions;
|
|
6360
6602
|
this.regionDiscovery = new RegionDiscovery(networkInterface);
|
|
6361
6603
|
this.regionDiscoveryMetadata = { region_used: undefined, region_source: undefined, region_outcome: undefined };
|
|
6604
|
+
this.proxyUrl = proxyUrl || Constants.EMPTY_STRING;
|
|
6362
6605
|
}
|
|
6363
6606
|
Object.defineProperty(Authority.prototype, "authorityType", {
|
|
6364
6607
|
// See above for AuthorityType
|
|
@@ -6494,6 +6737,10 @@ var Authority = /** @class */ (function () {
|
|
|
6494
6737
|
*/
|
|
6495
6738
|
get: function () {
|
|
6496
6739
|
if (this.discoveryComplete()) {
|
|
6740
|
+
// ROPC policies may not have end_session_endpoint set
|
|
6741
|
+
if (!this.metadata.end_session_endpoint) {
|
|
6742
|
+
throw ClientAuthError.createLogoutNotSupportedError();
|
|
6743
|
+
}
|
|
6497
6744
|
var endpoint = this.replacePath(this.metadata.end_session_endpoint);
|
|
6498
6745
|
return this.replaceTenant(endpoint);
|
|
6499
6746
|
}
|
|
@@ -6623,7 +6870,7 @@ var Authority = /** @class */ (function () {
|
|
|
6623
6870
|
metadata = _b.sent();
|
|
6624
6871
|
if (!metadata) return [3 /*break*/, 4];
|
|
6625
6872
|
if (!((_a = this.authorityOptions.azureRegionConfiguration) === null || _a === void 0 ? void 0 : _a.azureRegion)) return [3 /*break*/, 3];
|
|
6626
|
-
return [4 /*yield*/, this.regionDiscovery.detectRegion(this.authorityOptions.azureRegionConfiguration.environmentRegion, this.regionDiscoveryMetadata)];
|
|
6873
|
+
return [4 /*yield*/, this.regionDiscovery.detectRegion(this.authorityOptions.azureRegionConfiguration.environmentRegion, this.regionDiscoveryMetadata, this.proxyUrl)];
|
|
6627
6874
|
case 2:
|
|
6628
6875
|
autodetectedRegionName = _b.sent();
|
|
6629
6876
|
azureRegion = this.authorityOptions.azureRegionConfiguration.azureRegion === Constants.AZURE_REGION_AUTO_DISCOVER_FLAG
|
|
@@ -6686,19 +6933,25 @@ var Authority = /** @class */ (function () {
|
|
|
6686
6933
|
*/
|
|
6687
6934
|
Authority.prototype.getEndpointMetadataFromNetwork = function () {
|
|
6688
6935
|
return __awaiter(this, void 0, void 0, function () {
|
|
6689
|
-
var response;
|
|
6936
|
+
var options, response;
|
|
6690
6937
|
return __generator(this, function (_a) {
|
|
6691
6938
|
switch (_a.label) {
|
|
6692
6939
|
case 0:
|
|
6693
|
-
|
|
6694
|
-
|
|
6940
|
+
options = {};
|
|
6941
|
+
if (this.proxyUrl) {
|
|
6942
|
+
options.proxyUrl = this.proxyUrl;
|
|
6943
|
+
}
|
|
6944
|
+
_a.label = 1;
|
|
6695
6945
|
case 1:
|
|
6946
|
+
_a.trys.push([1, 3, , 4]);
|
|
6947
|
+
return [4 /*yield*/, this.networkInterface.sendGetRequestAsync(this.defaultOpenIdConfigurationEndpoint, options)];
|
|
6948
|
+
case 2:
|
|
6696
6949
|
response = _a.sent();
|
|
6697
6950
|
return [2 /*return*/, isOpenIdConfigResponse(response.body) ? response.body : null];
|
|
6698
|
-
case
|
|
6951
|
+
case 3:
|
|
6699
6952
|
_a.sent();
|
|
6700
6953
|
return [2 /*return*/, null];
|
|
6701
|
-
case
|
|
6954
|
+
case 4: return [2 /*return*/];
|
|
6702
6955
|
}
|
|
6703
6956
|
});
|
|
6704
6957
|
});
|
|
@@ -6768,16 +7021,20 @@ var Authority = /** @class */ (function () {
|
|
|
6768
7021
|
*/
|
|
6769
7022
|
Authority.prototype.getCloudDiscoveryMetadataFromNetwork = function () {
|
|
6770
7023
|
return __awaiter(this, void 0, void 0, function () {
|
|
6771
|
-
var instanceDiscoveryEndpoint, match, response, metadata;
|
|
7024
|
+
var instanceDiscoveryEndpoint, options, match, response, metadata;
|
|
6772
7025
|
return __generator(this, function (_a) {
|
|
6773
7026
|
switch (_a.label) {
|
|
6774
7027
|
case 0:
|
|
6775
7028
|
instanceDiscoveryEndpoint = "" + Constants.AAD_INSTANCE_DISCOVERY_ENDPT + this.canonicalAuthority + "oauth2/v2.0/authorize";
|
|
7029
|
+
options = {};
|
|
7030
|
+
if (this.proxyUrl) {
|
|
7031
|
+
options.proxyUrl = this.proxyUrl;
|
|
7032
|
+
}
|
|
6776
7033
|
match = null;
|
|
6777
7034
|
_a.label = 1;
|
|
6778
7035
|
case 1:
|
|
6779
7036
|
_a.trys.push([1, 3, , 4]);
|
|
6780
|
-
return [4 /*yield*/, this.networkInterface.sendGetRequestAsync(instanceDiscoveryEndpoint)];
|
|
7037
|
+
return [4 /*yield*/, this.networkInterface.sendGetRequestAsync(instanceDiscoveryEndpoint, options)];
|
|
6781
7038
|
case 2:
|
|
6782
7039
|
response = _a.sent();
|
|
6783
7040
|
metadata = isCloudInstanceDiscoveryResponse(response.body) ? response.body.metadata : [];
|
|
@@ -6792,7 +7049,7 @@ var Authority = /** @class */ (function () {
|
|
|
6792
7049
|
return [2 /*return*/, null];
|
|
6793
7050
|
case 4:
|
|
6794
7051
|
if (!match) {
|
|
6795
|
-
// Custom Domain scenario, host is trusted because Instance Discovery call succeeded
|
|
7052
|
+
// Custom Domain scenario, host is trusted because Instance Discovery call succeeded
|
|
6796
7053
|
match = Authority.createCloudDiscoveryMetadataFromHost(this.hostnameAndPort);
|
|
6797
7054
|
}
|
|
6798
7055
|
return [2 /*return*/, match];
|
|
@@ -6810,6 +7067,19 @@ var Authority = /** @class */ (function () {
|
|
|
6810
7067
|
});
|
|
6811
7068
|
return matches.length > 0;
|
|
6812
7069
|
};
|
|
7070
|
+
/**
|
|
7071
|
+
* helper function to populate the authority based on azureCloudOptions
|
|
7072
|
+
* @param authorityString
|
|
7073
|
+
* @param azureCloudOptions
|
|
7074
|
+
*/
|
|
7075
|
+
Authority.generateAuthority = function (authorityString, azureCloudOptions) {
|
|
7076
|
+
var authorityAzureCloudInstance;
|
|
7077
|
+
if (azureCloudOptions && azureCloudOptions.azureCloudInstance !== exports.AzureCloudInstance.None) {
|
|
7078
|
+
var tenant = azureCloudOptions.tenant ? azureCloudOptions.tenant : Constants.DEFAULT_COMMON_TENANT;
|
|
7079
|
+
authorityAzureCloudInstance = azureCloudOptions.azureCloudInstance + "/" + tenant + "/";
|
|
7080
|
+
}
|
|
7081
|
+
return authorityAzureCloudInstance ? authorityAzureCloudInstance : authorityString;
|
|
7082
|
+
};
|
|
6813
7083
|
/**
|
|
6814
7084
|
* Creates cloud discovery metadata object from a given host
|
|
6815
7085
|
* @param host
|
|
@@ -6894,7 +7164,9 @@ var Authority = /** @class */ (function () {
|
|
|
6894
7164
|
metadata.authorization_endpoint = Authority.buildRegionalAuthorityString(metadata.authorization_endpoint, azureRegion);
|
|
6895
7165
|
// TODO: Enquire on whether we should leave the query string or remove it before releasing the feature
|
|
6896
7166
|
metadata.token_endpoint = Authority.buildRegionalAuthorityString(metadata.token_endpoint, azureRegion, "allowestsrnonmsi=true");
|
|
6897
|
-
|
|
7167
|
+
if (metadata.end_session_endpoint) {
|
|
7168
|
+
metadata.end_session_endpoint = Authority.buildRegionalAuthorityString(metadata.end_session_endpoint, azureRegion);
|
|
7169
|
+
}
|
|
6898
7170
|
return metadata;
|
|
6899
7171
|
};
|
|
6900
7172
|
return Authority;
|
|
@@ -6917,13 +7189,13 @@ var AuthorityFactory = /** @class */ (function () {
|
|
|
6917
7189
|
* @param networkClient
|
|
6918
7190
|
* @param protocolMode
|
|
6919
7191
|
*/
|
|
6920
|
-
AuthorityFactory.createDiscoveredInstance = function (authorityUri, networkClient, cacheManager, authorityOptions) {
|
|
7192
|
+
AuthorityFactory.createDiscoveredInstance = function (authorityUri, networkClient, cacheManager, authorityOptions, proxyUrl) {
|
|
6921
7193
|
return __awaiter(this, void 0, void 0, function () {
|
|
6922
7194
|
var acquireTokenAuthority, e_1;
|
|
6923
7195
|
return __generator(this, function (_a) {
|
|
6924
7196
|
switch (_a.label) {
|
|
6925
7197
|
case 0:
|
|
6926
|
-
acquireTokenAuthority = AuthorityFactory.createInstance(authorityUri, networkClient, cacheManager, authorityOptions);
|
|
7198
|
+
acquireTokenAuthority = AuthorityFactory.createInstance(authorityUri, networkClient, cacheManager, authorityOptions, proxyUrl);
|
|
6927
7199
|
_a.label = 1;
|
|
6928
7200
|
case 1:
|
|
6929
7201
|
_a.trys.push([1, 3, , 4]);
|
|
@@ -6949,12 +7221,12 @@ var AuthorityFactory = /** @class */ (function () {
|
|
|
6949
7221
|
* @param networkInterface
|
|
6950
7222
|
* @param protocolMode
|
|
6951
7223
|
*/
|
|
6952
|
-
AuthorityFactory.createInstance = function (authorityUrl, networkInterface, cacheManager, authorityOptions) {
|
|
7224
|
+
AuthorityFactory.createInstance = function (authorityUrl, networkInterface, cacheManager, authorityOptions, proxyUrl) {
|
|
6953
7225
|
// Throw error if authority url is empty
|
|
6954
7226
|
if (StringUtils.isEmpty(authorityUrl)) {
|
|
6955
7227
|
throw ClientConfigurationError.createUrlEmptyError();
|
|
6956
7228
|
}
|
|
6957
|
-
return new Authority(authorityUrl, networkInterface, cacheManager, authorityOptions);
|
|
7229
|
+
return new Authority(authorityUrl, networkInterface, cacheManager, authorityOptions, proxyUrl);
|
|
6958
7230
|
};
|
|
6959
7231
|
return AuthorityFactory;
|
|
6960
7232
|
}());
|
|
@@ -7029,6 +7301,63 @@ var StubbedNetworkModule = {
|
|
|
7029
7301
|
}
|
|
7030
7302
|
};
|
|
7031
7303
|
|
|
7304
|
+
/*
|
|
7305
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
7306
|
+
* Licensed under the MIT License.
|
|
7307
|
+
*/
|
|
7308
|
+
/**
|
|
7309
|
+
* This is a helper class that parses supported HTTP response authentication headers to extract and return
|
|
7310
|
+
* header challenge values that can be used outside the basic authorization flows.
|
|
7311
|
+
*/
|
|
7312
|
+
var AuthenticationHeaderParser = /** @class */ (function () {
|
|
7313
|
+
function AuthenticationHeaderParser(headers) {
|
|
7314
|
+
this.headers = headers;
|
|
7315
|
+
}
|
|
7316
|
+
/**
|
|
7317
|
+
* This method parses the SHR nonce value out of either the Authentication-Info or WWW-Authenticate authentication headers.
|
|
7318
|
+
* @returns
|
|
7319
|
+
*/
|
|
7320
|
+
AuthenticationHeaderParser.prototype.getShrNonce = function () {
|
|
7321
|
+
// Attempt to parse nonce from Authentiacation-Info
|
|
7322
|
+
var authenticationInfo = this.headers[HeaderNames.AuthenticationInfo];
|
|
7323
|
+
if (authenticationInfo) {
|
|
7324
|
+
var authenticationInfoChallenges = this.parseChallenges(authenticationInfo);
|
|
7325
|
+
if (authenticationInfoChallenges.nextnonce) {
|
|
7326
|
+
return authenticationInfoChallenges.nextnonce;
|
|
7327
|
+
}
|
|
7328
|
+
throw ClientConfigurationError.createInvalidAuthenticationHeaderError(HeaderNames.AuthenticationInfo, "nextnonce challenge is missing.");
|
|
7329
|
+
}
|
|
7330
|
+
// Attempt to parse nonce from WWW-Authenticate
|
|
7331
|
+
var wwwAuthenticate = this.headers[HeaderNames.WWWAuthenticate];
|
|
7332
|
+
if (wwwAuthenticate) {
|
|
7333
|
+
var wwwAuthenticateChallenges = this.parseChallenges(wwwAuthenticate);
|
|
7334
|
+
if (wwwAuthenticateChallenges.nonce) {
|
|
7335
|
+
return wwwAuthenticateChallenges.nonce;
|
|
7336
|
+
}
|
|
7337
|
+
throw ClientConfigurationError.createInvalidAuthenticationHeaderError(HeaderNames.WWWAuthenticate, "nonce challenge is missing.");
|
|
7338
|
+
}
|
|
7339
|
+
// If neither header is present, throw missing headers error
|
|
7340
|
+
throw ClientConfigurationError.createMissingNonceAuthenticationHeadersError();
|
|
7341
|
+
};
|
|
7342
|
+
/**
|
|
7343
|
+
* Parses an HTTP header's challenge set into a key/value map.
|
|
7344
|
+
* @param header
|
|
7345
|
+
* @returns
|
|
7346
|
+
*/
|
|
7347
|
+
AuthenticationHeaderParser.prototype.parseChallenges = function (header) {
|
|
7348
|
+
var schemeSeparator = header.indexOf(" ");
|
|
7349
|
+
var challenges = header.substr(schemeSeparator + 1).split(",");
|
|
7350
|
+
var challengeMap = {};
|
|
7351
|
+
challenges.forEach(function (challenge) {
|
|
7352
|
+
var _a = challenge.split("="), key = _a[0], value = _a[1];
|
|
7353
|
+
// Remove escaped quotation marks (', ") from challenge string to keep only the challenge value
|
|
7354
|
+
challengeMap[key] = unescape(value.replace(/['"]+/g, ""));
|
|
7355
|
+
});
|
|
7356
|
+
return challengeMap;
|
|
7357
|
+
};
|
|
7358
|
+
return AuthenticationHeaderParser;
|
|
7359
|
+
}());
|
|
7360
|
+
|
|
7032
7361
|
/*
|
|
7033
7362
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
7034
7363
|
* Licensed under the MIT License.
|
|
@@ -7195,6 +7524,7 @@ exports.AppMetadataEntity = AppMetadataEntity;
|
|
|
7195
7524
|
exports.AuthError = AuthError;
|
|
7196
7525
|
exports.AuthErrorMessage = AuthErrorMessage;
|
|
7197
7526
|
exports.AuthToken = AuthToken;
|
|
7527
|
+
exports.AuthenticationHeaderParser = AuthenticationHeaderParser;
|
|
7198
7528
|
exports.Authority = Authority;
|
|
7199
7529
|
exports.AuthorityFactory = AuthorityFactory;
|
|
7200
7530
|
exports.AuthorityMetadataEntity = AuthorityMetadataEntity;
|