@azure/msal-common 5.0.0 → 6.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/CHANGELOG.json +130 -0
- package/{changelog.md → CHANGELOG.md} +462 -413
- package/LICENSE +21 -21
- package/README.md +62 -61
- 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/authority/Authority.d.ts.map +1 -1
- package/dist/authority/Authority.js +8 -2
- package/dist/authority/Authority.js.map +1 -1
- package/dist/authority/AuthorityFactory.js +1 -1
- package/dist/authority/AuthorityFactory.js.map +1 -1
- 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/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.js +1 -1
- 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 +46 -10
- package/dist/client/AuthorizationCodeClient.js.map +1 -1
- package/dist/client/BaseClient.js +1 -1
- 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 +7 -3
- 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 +24 -11
- 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.js +1 -1
- 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 -4
- package/dist/error/ClientAuthError.d.ts.map +1 -1
- package/dist/error/ClientAuthError.js +11 -7
- package/dist/error/ClientAuthError.js.map +1 -1
- package/dist/error/ClientConfigurationError.d.ts +29 -0
- package/dist/error/ClientConfigurationError.d.ts.map +1 -1
- package/dist/error/ClientConfigurationError.js +43 -3
- package/dist/error/ClientConfigurationError.js.map +1 -1
- package/dist/error/InteractionRequiredAuthError.d.ts +24 -5
- package/dist/error/InteractionRequiredAuthError.d.ts.map +1 -1
- package/dist/error/InteractionRequiredAuthError.js +30 -9
- 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 +371 -101
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/logger/Logger.js +1 -1
- package/dist/logger/Logger.js.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 +9 -1
- 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/RequestParameterBuilder.d.ts +4 -0
- package/dist/request/RequestParameterBuilder.d.ts.map +1 -1
- package/dist/request/RequestParameterBuilder.js +10 -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 +7 -3
- package/dist/utils/Constants.d.ts.map +1 -1
- package/dist/utils/Constants.js +6 -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 +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @azure/msal-common
|
|
1
|
+
/*! @azure/msal-common v6.0.0 2022-01-04 */
|
|
2
2
|
'use strict';
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
@@ -153,6 +153,8 @@ var HeaderNames;
|
|
|
153
153
|
HeaderNames["CONTENT_TYPE"] = "Content-Type";
|
|
154
154
|
HeaderNames["RETRY_AFTER"] = "Retry-After";
|
|
155
155
|
HeaderNames["CCS_HEADER"] = "X-AnchorMailbox";
|
|
156
|
+
HeaderNames["WWWAuthenticate"] = "WWW-Authenticate";
|
|
157
|
+
HeaderNames["AuthenticationInfo"] = "Authentication-Info";
|
|
156
158
|
})(HeaderNames || (HeaderNames = {}));
|
|
157
159
|
/**
|
|
158
160
|
* Persistent cache keys MSAL which stay while user is logged in.
|
|
@@ -223,6 +225,7 @@ var AADServerParamKeys;
|
|
|
223
225
|
AADServerParamKeys["ON_BEHALF_OF"] = "on_behalf_of";
|
|
224
226
|
AADServerParamKeys["FOCI"] = "foci";
|
|
225
227
|
AADServerParamKeys["CCS_HEADER"] = "X-AnchorMailbox";
|
|
228
|
+
AADServerParamKeys["RETURN_SPA_CODE"] = "return_spa_code";
|
|
226
229
|
})(AADServerParamKeys || (AADServerParamKeys = {}));
|
|
227
230
|
/**
|
|
228
231
|
* Claims request keys
|
|
@@ -387,8 +390,9 @@ var SERVER_TELEM_CONSTANTS = {
|
|
|
387
390
|
*/
|
|
388
391
|
exports.AuthenticationScheme = void 0;
|
|
389
392
|
(function (AuthenticationScheme) {
|
|
390
|
-
AuthenticationScheme["POP"] = "pop";
|
|
391
393
|
AuthenticationScheme["BEARER"] = "Bearer";
|
|
394
|
+
AuthenticationScheme["POP"] = "pop";
|
|
395
|
+
AuthenticationScheme["SSH"] = "ssh-cert";
|
|
392
396
|
})(exports.AuthenticationScheme || (exports.AuthenticationScheme = {}));
|
|
393
397
|
/**
|
|
394
398
|
* Constants related to throttling
|
|
@@ -556,6 +560,15 @@ var DEFAULT_CRYPTO_IMPLEMENTATION = {
|
|
|
556
560
|
throw AuthError.createUnexpectedError(notImplErr);
|
|
557
561
|
});
|
|
558
562
|
});
|
|
563
|
+
},
|
|
564
|
+
hashString: function () {
|
|
565
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
566
|
+
var notImplErr;
|
|
567
|
+
return __generator(this, function (_a) {
|
|
568
|
+
notImplErr = "Crypto interface - hashString() has not been implemented";
|
|
569
|
+
throw AuthError.createUnexpectedError(notImplErr);
|
|
570
|
+
});
|
|
571
|
+
});
|
|
559
572
|
}
|
|
560
573
|
};
|
|
561
574
|
|
|
@@ -743,6 +756,10 @@ var ClientAuthErrorMessage = {
|
|
|
743
756
|
bindingKeyNotRemovedError: {
|
|
744
757
|
code: "binding_key_not_removed",
|
|
745
758
|
desc: "Could not remove the credential's binding key from storage."
|
|
759
|
+
},
|
|
760
|
+
logoutNotSupported: {
|
|
761
|
+
code: "end_session_endpoint_not_supported",
|
|
762
|
+
desc: "Provided authority does not support logout."
|
|
746
763
|
}
|
|
747
764
|
};
|
|
748
765
|
/**
|
|
@@ -842,12 +859,6 @@ var ClientAuthError = /** @class */ (function (_super) {
|
|
|
842
859
|
ClientAuthError.createNonceNotFoundError = function (missingNonce) {
|
|
843
860
|
return new ClientAuthError(ClientAuthErrorMessage.nonceNotFoundError.code, ClientAuthErrorMessage.nonceNotFoundError.desc + ": " + missingNonce);
|
|
844
861
|
};
|
|
845
|
-
/**
|
|
846
|
-
* Creates an error thrown when the authorization code required for a token request is null or empty.
|
|
847
|
-
*/
|
|
848
|
-
ClientAuthError.createNoTokensFoundError = function () {
|
|
849
|
-
return new ClientAuthError(ClientAuthErrorMessage.noTokensFoundError.code, ClientAuthErrorMessage.noTokensFoundError.desc);
|
|
850
|
-
};
|
|
851
862
|
/**
|
|
852
863
|
* Throws error when multiple tokens are in cache.
|
|
853
864
|
*/
|
|
@@ -1012,6 +1023,12 @@ var ClientAuthError = /** @class */ (function (_super) {
|
|
|
1012
1023
|
ClientAuthError.createBindingKeyNotRemovedError = function () {
|
|
1013
1024
|
return new ClientAuthError(ClientAuthErrorMessage.bindingKeyNotRemovedError.code, ClientAuthErrorMessage.bindingKeyNotRemovedError.desc);
|
|
1014
1025
|
};
|
|
1026
|
+
/**
|
|
1027
|
+
* Thrown when logout is attempted for an authority that doesnt have an end_session_endpoint
|
|
1028
|
+
*/
|
|
1029
|
+
ClientAuthError.createLogoutNotSupportedError = function () {
|
|
1030
|
+
return new ClientAuthError(ClientAuthErrorMessage.logoutNotSupported.code, ClientAuthErrorMessage.logoutNotSupported.desc);
|
|
1031
|
+
};
|
|
1015
1032
|
return ClientAuthError;
|
|
1016
1033
|
}(AuthError));
|
|
1017
1034
|
|
|
@@ -1318,7 +1335,7 @@ var Logger = /** @class */ (function () {
|
|
|
1318
1335
|
|
|
1319
1336
|
/* eslint-disable header/header */
|
|
1320
1337
|
var name = "@azure/msal-common";
|
|
1321
|
-
var version = "
|
|
1338
|
+
var version = "6.0.0";
|
|
1322
1339
|
|
|
1323
1340
|
/*
|
|
1324
1341
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1329,7 +1346,7 @@ var version = "5.0.0";
|
|
|
1329
1346
|
*
|
|
1330
1347
|
* Key:Value Schema:
|
|
1331
1348
|
*
|
|
1332
|
-
* Key: <home_account_id*>-<environment>-<credential_type>-<client_id>-<realm*>-<target*>-<scheme
|
|
1349
|
+
* Key: <home_account_id*>-<environment>-<credential_type>-<client_id>-<realm*>-<target*>-<requestedClaims*>-<scheme*>
|
|
1333
1350
|
*
|
|
1334
1351
|
* Value Schema:
|
|
1335
1352
|
* {
|
|
@@ -1343,6 +1360,7 @@ var version = "5.0.0";
|
|
|
1343
1360
|
* target: Permissions that are included in the token, or for refresh tokens, the resource identifier.
|
|
1344
1361
|
* oboAssertion: access token passed in as part of OBO request
|
|
1345
1362
|
* tokenType: Matches the authentication scheme for which the token was issued (i.e. Bearer or pop)
|
|
1363
|
+
* requestedClaimsHash: Matches the SHA 256 hash of the claims object included in the token request
|
|
1346
1364
|
* }
|
|
1347
1365
|
*/
|
|
1348
1366
|
var CredentialEntity = /** @class */ (function () {
|
|
@@ -1370,7 +1388,7 @@ var CredentialEntity = /** @class */ (function () {
|
|
|
1370
1388
|
* generates credential key
|
|
1371
1389
|
*/
|
|
1372
1390
|
CredentialEntity.prototype.generateCredentialKey = function () {
|
|
1373
|
-
return CredentialEntity.generateCredentialCacheKey(this.homeAccountId, this.environment, this.credentialType, this.clientId, this.realm, this.target, this.familyId, this.tokenType);
|
|
1391
|
+
return CredentialEntity.generateCredentialCacheKey(this.homeAccountId, this.environment, this.credentialType, this.clientId, this.realm, this.target, this.familyId, this.tokenType, this.requestedClaimsHash);
|
|
1374
1392
|
};
|
|
1375
1393
|
/**
|
|
1376
1394
|
* returns the type of the cache (in this case credential)
|
|
@@ -1414,16 +1432,14 @@ var CredentialEntity = /** @class */ (function () {
|
|
|
1414
1432
|
* generates credential key
|
|
1415
1433
|
* <home_account_id*>-\<environment>-<credential_type>-<client_id>-<realm\*>-<target\*>-<scheme\*>
|
|
1416
1434
|
*/
|
|
1417
|
-
CredentialEntity.generateCredentialCacheKey = function (homeAccountId, environment, credentialType, clientId, realm, target, familyId, tokenType) {
|
|
1435
|
+
CredentialEntity.generateCredentialCacheKey = function (homeAccountId, environment, credentialType, clientId, realm, target, familyId, tokenType, requestedClaimsHash) {
|
|
1418
1436
|
var credentialKey = [
|
|
1419
1437
|
this.generateAccountIdForCacheKey(homeAccountId, environment),
|
|
1420
1438
|
this.generateCredentialIdForCacheKey(credentialType, clientId, realm, familyId),
|
|
1421
|
-
this.generateTargetForCacheKey(target)
|
|
1439
|
+
this.generateTargetForCacheKey(target),
|
|
1440
|
+
this.generateClaimsHashForCacheKey(requestedClaimsHash),
|
|
1441
|
+
this.generateSchemeForCacheKey(tokenType)
|
|
1422
1442
|
];
|
|
1423
|
-
// PoP Tokens include scheme in cache key
|
|
1424
|
-
if (tokenType === exports.AuthenticationScheme.POP) {
|
|
1425
|
-
credentialKey.push(tokenType.toLowerCase());
|
|
1426
|
-
}
|
|
1427
1443
|
return credentialKey.join(Separators.CACHE_KEY_SEPARATOR).toLowerCase();
|
|
1428
1444
|
};
|
|
1429
1445
|
/**
|
|
@@ -1459,6 +1475,22 @@ var CredentialEntity = /** @class */ (function () {
|
|
|
1459
1475
|
CredentialEntity.generateTargetForCacheKey = function (scopes) {
|
|
1460
1476
|
return (scopes || "").toLowerCase();
|
|
1461
1477
|
};
|
|
1478
|
+
/**
|
|
1479
|
+
* Generate requested claims key component as per schema: <requestedClaims>
|
|
1480
|
+
*/
|
|
1481
|
+
CredentialEntity.generateClaimsHashForCacheKey = function (requestedClaimsHash) {
|
|
1482
|
+
return (requestedClaimsHash || "").toLowerCase();
|
|
1483
|
+
};
|
|
1484
|
+
/**
|
|
1485
|
+
* Generate scheme key componenet as per schema: <scheme>
|
|
1486
|
+
*/
|
|
1487
|
+
CredentialEntity.generateSchemeForCacheKey = function (tokenType) {
|
|
1488
|
+
/*
|
|
1489
|
+
* PoP Tokens and SSH certs include scheme in cache key
|
|
1490
|
+
* Cast to lowercase to handle "bearer" from ADFS
|
|
1491
|
+
*/
|
|
1492
|
+
return (tokenType && tokenType.toLowerCase() !== exports.AuthenticationScheme.BEARER.toLowerCase()) ? tokenType.toLowerCase() : "";
|
|
1493
|
+
};
|
|
1462
1494
|
return CredentialEntity;
|
|
1463
1495
|
}());
|
|
1464
1496
|
|
|
@@ -1532,15 +1564,31 @@ var ClientConfigurationErrorMessage = {
|
|
|
1532
1564
|
},
|
|
1533
1565
|
invalidCloudDiscoveryMetadata: {
|
|
1534
1566
|
code: "invalid_cloud_discovery_metadata",
|
|
1535
|
-
desc: "Invalid cloudDiscoveryMetadata provided. Must be a JSON object containing tenant_discovery_endpoint and metadata fields"
|
|
1567
|
+
desc: "Invalid cloudDiscoveryMetadata provided. Must be a stringified JSON object containing tenant_discovery_endpoint and metadata fields"
|
|
1536
1568
|
},
|
|
1537
1569
|
invalidAuthorityMetadata: {
|
|
1538
1570
|
code: "invalid_authority_metadata",
|
|
1539
|
-
desc: "Invalid authorityMetadata provided. Must by a JSON object containing authorization_endpoint, token_endpoint,
|
|
1571
|
+
desc: "Invalid authorityMetadata provided. Must by a stringified JSON object containing authorization_endpoint, token_endpoint, issuer fields."
|
|
1540
1572
|
},
|
|
1541
1573
|
untrustedAuthority: {
|
|
1542
1574
|
code: "untrusted_authority",
|
|
1543
1575
|
desc: "The provided authority is not a trusted authority. Please include this authority in the knownAuthorities config parameter."
|
|
1576
|
+
},
|
|
1577
|
+
missingSshJwk: {
|
|
1578
|
+
code: "missing_ssh_jwk",
|
|
1579
|
+
desc: "Missing sshJwk in SSH certificate request. A stringified JSON Web Key is required when using the SSH authentication scheme."
|
|
1580
|
+
},
|
|
1581
|
+
missingSshKid: {
|
|
1582
|
+
code: "missing_ssh_kid",
|
|
1583
|
+
desc: "Missing sshKid in SSH certificate request. A string that uniquely identifies the public SSH key is required when using the SSH authentication scheme."
|
|
1584
|
+
},
|
|
1585
|
+
missingNonceAuthenticationHeader: {
|
|
1586
|
+
code: "missing_nonce_authentication_header",
|
|
1587
|
+
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."
|
|
1588
|
+
},
|
|
1589
|
+
invalidAuthenticationHeader: {
|
|
1590
|
+
code: "invalid_authentication_header",
|
|
1591
|
+
desc: "Invalid authentication header provided"
|
|
1544
1592
|
}
|
|
1545
1593
|
};
|
|
1546
1594
|
/**
|
|
@@ -1662,6 +1710,30 @@ var ClientConfigurationError = /** @class */ (function (_super) {
|
|
|
1662
1710
|
ClientConfigurationError.createUntrustedAuthorityError = function () {
|
|
1663
1711
|
return new ClientConfigurationError(ClientConfigurationErrorMessage.untrustedAuthority.code, ClientConfigurationErrorMessage.untrustedAuthority.desc);
|
|
1664
1712
|
};
|
|
1713
|
+
/*
|
|
1714
|
+
* Throws an error when the authentication scheme is set to SSH but the SSH public key is omitted from the request
|
|
1715
|
+
*/
|
|
1716
|
+
ClientConfigurationError.createMissingSshJwkError = function () {
|
|
1717
|
+
return new ClientConfigurationError(ClientConfigurationErrorMessage.missingSshJwk.code, ClientConfigurationErrorMessage.missingSshJwk.desc);
|
|
1718
|
+
};
|
|
1719
|
+
/**
|
|
1720
|
+
* Throws an error when the authentication scheme is set to SSH but the SSH public key ID is omitted from the request
|
|
1721
|
+
*/
|
|
1722
|
+
ClientConfigurationError.createMissingSshKidError = function () {
|
|
1723
|
+
return new ClientConfigurationError(ClientConfigurationErrorMessage.missingSshKid.code, ClientConfigurationErrorMessage.missingSshKid.desc);
|
|
1724
|
+
};
|
|
1725
|
+
/**
|
|
1726
|
+
* Throws error when provided headers don't contain a header that a server nonce can be extracted from
|
|
1727
|
+
*/
|
|
1728
|
+
ClientConfigurationError.createMissingNonceAuthenticationHeadersError = function () {
|
|
1729
|
+
return new ClientConfigurationError(ClientConfigurationErrorMessage.missingNonceAuthenticationHeader.code, ClientConfigurationErrorMessage.missingNonceAuthenticationHeader.desc);
|
|
1730
|
+
};
|
|
1731
|
+
/**
|
|
1732
|
+
* Throws error when a provided header is invalid in any way
|
|
1733
|
+
*/
|
|
1734
|
+
ClientConfigurationError.createInvalidAuthenticationHeaderError = function (invalidHeaderName, details) {
|
|
1735
|
+
return new ClientConfigurationError(ClientConfigurationErrorMessage.invalidAuthenticationHeader.code, ClientConfigurationErrorMessage.invalidAuthenticationHeader.desc + ". Invalid header: " + invalidHeaderName + ". Details: " + details);
|
|
1736
|
+
};
|
|
1665
1737
|
return ClientConfigurationError;
|
|
1666
1738
|
}(ClientAuthError));
|
|
1667
1739
|
|
|
@@ -2252,7 +2324,8 @@ var CacheManager = /** @class */ (function () {
|
|
|
2252
2324
|
environment: credential.environment,
|
|
2253
2325
|
homeAccountId: credential.homeAccountId,
|
|
2254
2326
|
realm: credential.realm,
|
|
2255
|
-
tokenType: credential.tokenType
|
|
2327
|
+
tokenType: credential.tokenType,
|
|
2328
|
+
requestedClaimsHash: credential.requestedClaimsHash
|
|
2256
2329
|
});
|
|
2257
2330
|
currentScopes = ScopeSet.fromString(credential.target);
|
|
2258
2331
|
currentAccessTokens = Object.keys(currentTokenCache.accessTokens).map(function (key) { return currentTokenCache.accessTokens[key]; });
|
|
@@ -2324,7 +2397,7 @@ var CacheManager = /** @class */ (function () {
|
|
|
2324
2397
|
* @param target
|
|
2325
2398
|
*/
|
|
2326
2399
|
CacheManager.prototype.getCredentialsFilteredBy = function (filter) {
|
|
2327
|
-
return this.getCredentialsFilteredByInternal(filter.homeAccountId, filter.environment, filter.credentialType, filter.clientId, filter.familyId, filter.realm, filter.target, filter.oboAssertion, filter.tokenType);
|
|
2400
|
+
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);
|
|
2328
2401
|
};
|
|
2329
2402
|
/**
|
|
2330
2403
|
* Support function to help match credentials
|
|
@@ -2337,7 +2410,7 @@ var CacheManager = /** @class */ (function () {
|
|
|
2337
2410
|
* @param oboAssertion
|
|
2338
2411
|
* @param tokenType
|
|
2339
2412
|
*/
|
|
2340
|
-
CacheManager.prototype.getCredentialsFilteredByInternal = function (homeAccountId, environment, credentialType, clientId, familyId, realm, target, oboAssertion, tokenType) {
|
|
2413
|
+
CacheManager.prototype.getCredentialsFilteredByInternal = function (homeAccountId, environment, credentialType, clientId, familyId, realm, target, oboAssertion, tokenType, keyId, requestedClaimsHash) {
|
|
2341
2414
|
var _this = this;
|
|
2342
2415
|
var allCacheKeys = this.getKeys();
|
|
2343
2416
|
var matchingCredentials = {
|
|
@@ -2384,27 +2457,37 @@ var CacheManager = /** @class */ (function () {
|
|
|
2384
2457
|
if (!!target && !_this.matchTarget(entity, target)) {
|
|
2385
2458
|
return;
|
|
2386
2459
|
}
|
|
2460
|
+
// If request OR cached entity has requested Claims Hash, check if they match
|
|
2461
|
+
if (requestedClaimsHash || entity.requestedClaimsHash) {
|
|
2462
|
+
// Don't match if either is undefined or they are different
|
|
2463
|
+
if (entity.requestedClaimsHash !== requestedClaimsHash) {
|
|
2464
|
+
return;
|
|
2465
|
+
}
|
|
2466
|
+
}
|
|
2467
|
+
// Access Token with Auth Scheme specific matching
|
|
2387
2468
|
if (credentialType === exports.CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME) {
|
|
2388
2469
|
if (!!tokenType && !_this.matchTokenType(entity, tokenType)) {
|
|
2389
2470
|
return;
|
|
2390
2471
|
}
|
|
2391
|
-
//
|
|
2392
|
-
if (
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2472
|
+
// KeyId (sshKid) in request must match cached SSH certificate keyId because SSH cert is bound to a specific key
|
|
2473
|
+
if (tokenType === exports.AuthenticationScheme.SSH) {
|
|
2474
|
+
if (keyId && !_this.matchKeyId(entity, keyId)) {
|
|
2475
|
+
return;
|
|
2476
|
+
}
|
|
2396
2477
|
}
|
|
2397
2478
|
}
|
|
2479
|
+
// At this point, the entity matches the request, update cache key if key schema has changed
|
|
2480
|
+
var updatedCacheKey = _this.updateCredentialCacheKey(cacheKey, entity);
|
|
2398
2481
|
switch (credType) {
|
|
2399
2482
|
case exports.CredentialType.ID_TOKEN:
|
|
2400
|
-
matchingCredentials.idTokens[
|
|
2483
|
+
matchingCredentials.idTokens[updatedCacheKey] = entity;
|
|
2401
2484
|
break;
|
|
2402
2485
|
case exports.CredentialType.ACCESS_TOKEN:
|
|
2403
2486
|
case exports.CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME:
|
|
2404
|
-
matchingCredentials.accessTokens[
|
|
2487
|
+
matchingCredentials.accessTokens[updatedCacheKey] = entity;
|
|
2405
2488
|
break;
|
|
2406
2489
|
case exports.CredentialType.REFRESH_TOKEN:
|
|
2407
|
-
matchingCredentials.refreshTokens[
|
|
2490
|
+
matchingCredentials.refreshTokens[updatedCacheKey] = entity;
|
|
2408
2491
|
break;
|
|
2409
2492
|
}
|
|
2410
2493
|
});
|
|
@@ -2563,6 +2646,7 @@ var CacheManager = /** @class */ (function () {
|
|
|
2563
2646
|
case 0:
|
|
2564
2647
|
key = credential.generateCredentialKey();
|
|
2565
2648
|
if (!(credential.credentialType.toLowerCase() === exports.CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME.toLowerCase())) return [3 /*break*/, 4];
|
|
2649
|
+
if (!(credential.tokenType === exports.AuthenticationScheme.POP)) return [3 /*break*/, 4];
|
|
2566
2650
|
accessTokenWithAuthSchemeEntity = credential;
|
|
2567
2651
|
kid = accessTokenWithAuthSchemeEntity.keyId;
|
|
2568
2652
|
if (!kid) return [3 /*break*/, 4];
|
|
@@ -2602,10 +2686,10 @@ var CacheManager = /** @class */ (function () {
|
|
|
2602
2686
|
* @param environment
|
|
2603
2687
|
* @param authScheme
|
|
2604
2688
|
*/
|
|
2605
|
-
CacheManager.prototype.readCacheRecord = function (account, clientId,
|
|
2689
|
+
CacheManager.prototype.readCacheRecord = function (account, clientId, request, environment) {
|
|
2606
2690
|
var cachedAccount = this.readAccountFromCache(account);
|
|
2607
2691
|
var cachedIdToken = this.readIdTokenFromCache(clientId, account);
|
|
2608
|
-
var cachedAccessToken = this.readAccessTokenFromCache(clientId, account,
|
|
2692
|
+
var cachedAccessToken = this.readAccessTokenFromCache(clientId, account, request);
|
|
2609
2693
|
var cachedRefreshToken = this.readRefreshTokenFromCache(clientId, account, false);
|
|
2610
2694
|
var cachedAppMetadata = this.readAppMetadataFromCache(environment, clientId);
|
|
2611
2695
|
if (cachedAccount && cachedIdToken) {
|
|
@@ -2659,9 +2743,14 @@ var CacheManager = /** @class */ (function () {
|
|
|
2659
2743
|
* @param scopes
|
|
2660
2744
|
* @param authScheme
|
|
2661
2745
|
*/
|
|
2662
|
-
CacheManager.prototype.readAccessTokenFromCache = function (clientId, account,
|
|
2663
|
-
|
|
2664
|
-
var
|
|
2746
|
+
CacheManager.prototype.readAccessTokenFromCache = function (clientId, account, request) {
|
|
2747
|
+
var scopes = new ScopeSet(request.scopes || []);
|
|
2748
|
+
var authScheme = request.authenticationScheme || exports.AuthenticationScheme.BEARER;
|
|
2749
|
+
/*
|
|
2750
|
+
* Distinguish between Bearer and PoP/SSH token cache types
|
|
2751
|
+
* Cast to lowercase to handle "bearer" from ADFS
|
|
2752
|
+
*/
|
|
2753
|
+
var credentialType = (authScheme && authScheme.toLowerCase() !== exports.AuthenticationScheme.BEARER.toLowerCase()) ? exports.CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME : exports.CredentialType.ACCESS_TOKEN;
|
|
2665
2754
|
var accessTokenFilter = {
|
|
2666
2755
|
homeAccountId: account.homeAccountId,
|
|
2667
2756
|
environment: account.environment,
|
|
@@ -2669,7 +2758,9 @@ var CacheManager = /** @class */ (function () {
|
|
|
2669
2758
|
clientId: clientId,
|
|
2670
2759
|
realm: account.tenantId,
|
|
2671
2760
|
target: scopes.printScopesLowerCase(),
|
|
2672
|
-
tokenType: authScheme
|
|
2761
|
+
tokenType: authScheme,
|
|
2762
|
+
keyId: request.sshKid,
|
|
2763
|
+
requestedClaimsHash: request.requestedClaimsHash
|
|
2673
2764
|
};
|
|
2674
2765
|
var credentialCache = this.getCredentialsFilteredBy(accessTokenFilter);
|
|
2675
2766
|
var accessTokens = Object.keys(credentialCache.accessTokens).map(function (key) { return credentialCache.accessTokens[key]; });
|
|
@@ -2822,6 +2913,14 @@ var CacheManager = /** @class */ (function () {
|
|
|
2822
2913
|
CacheManager.prototype.matchTokenType = function (entity, tokenType) {
|
|
2823
2914
|
return !!(entity.tokenType && entity.tokenType === tokenType);
|
|
2824
2915
|
};
|
|
2916
|
+
/**
|
|
2917
|
+
* Returns true if the credential's keyId matches the one in the request, false otherwise
|
|
2918
|
+
* @param entity
|
|
2919
|
+
* @param tokenType
|
|
2920
|
+
*/
|
|
2921
|
+
CacheManager.prototype.matchKeyId = function (entity, keyId) {
|
|
2922
|
+
return !!(entity.keyId && entity.keyId === keyId);
|
|
2923
|
+
};
|
|
2825
2924
|
/**
|
|
2826
2925
|
* returns if a given cache entity is of the type appmetadata
|
|
2827
2926
|
* @param key
|
|
@@ -2970,6 +3069,10 @@ var DefaultStorageClass = /** @class */ (function (_super) {
|
|
|
2970
3069
|
});
|
|
2971
3070
|
});
|
|
2972
3071
|
};
|
|
3072
|
+
DefaultStorageClass.prototype.updateCredentialCacheKey = function () {
|
|
3073
|
+
var notImplErr = "Storage interface - updateCredentialCacheKey() has not been implemented for the cacheStorage interface.";
|
|
3074
|
+
throw AuthError.createUnexpectedError(notImplErr);
|
|
3075
|
+
};
|
|
2973
3076
|
return DefaultStorageClass;
|
|
2974
3077
|
}(CacheManager));
|
|
2975
3078
|
|
|
@@ -3152,10 +3255,12 @@ var ThrottlingUtils = /** @class */ (function () {
|
|
|
3152
3255
|
authority: request.authority,
|
|
3153
3256
|
scopes: request.scopes,
|
|
3154
3257
|
homeAccountIdentifier: homeAccountIdentifier,
|
|
3258
|
+
claims: request.claims,
|
|
3155
3259
|
authenticationScheme: request.authenticationScheme,
|
|
3156
3260
|
resourceRequestMethod: request.resourceRequestMethod,
|
|
3157
3261
|
resourceRequestUri: request.resourceRequestUri,
|
|
3158
|
-
shrClaims: request.shrClaims
|
|
3262
|
+
shrClaims: request.shrClaims,
|
|
3263
|
+
sshKid: request.sshKid
|
|
3159
3264
|
};
|
|
3160
3265
|
var key = this.generateThrottlingStorageKey(thumbprint);
|
|
3161
3266
|
return cacheManager.removeItem(key, exports.CacheSchemaType.THROTTLING);
|
|
@@ -3693,6 +3798,15 @@ var RequestParameterBuilder = /** @class */ (function () {
|
|
|
3693
3798
|
this.parameters.set(AADServerParamKeys.REQ_CNF, encodeURIComponent(cnfString));
|
|
3694
3799
|
}
|
|
3695
3800
|
};
|
|
3801
|
+
/**
|
|
3802
|
+
* add SSH JWK and key ID to query params
|
|
3803
|
+
*/
|
|
3804
|
+
RequestParameterBuilder.prototype.addSshJwk = function (sshJwkString) {
|
|
3805
|
+
if (!StringUtils.isEmpty(sshJwkString)) {
|
|
3806
|
+
this.parameters.set(AADServerParamKeys.TOKEN_TYPE, exports.AuthenticationScheme.SSH);
|
|
3807
|
+
this.parameters.set(AADServerParamKeys.REQ_CNF, encodeURIComponent(sshJwkString));
|
|
3808
|
+
}
|
|
3809
|
+
};
|
|
3696
3810
|
/**
|
|
3697
3811
|
* add server telemetry fields
|
|
3698
3812
|
* @param serverTelemetryManager
|
|
@@ -3876,8 +3990,8 @@ var AccessTokenEntity = /** @class */ (function (_super) {
|
|
|
3876
3990
|
* @param expiresOn
|
|
3877
3991
|
* @param extExpiresOn
|
|
3878
3992
|
*/
|
|
3879
|
-
AccessTokenEntity.createAccessTokenEntity = function (homeAccountId, environment, accessToken, clientId, tenantId, scopes, expiresOn, extExpiresOn, cryptoUtils, refreshOn, tokenType, oboAssertion) {
|
|
3880
|
-
var _a;
|
|
3993
|
+
AccessTokenEntity.createAccessTokenEntity = function (homeAccountId, environment, accessToken, clientId, tenantId, scopes, expiresOn, extExpiresOn, cryptoUtils, refreshOn, tokenType, oboAssertion, keyId, requestedClaims, requestedClaimsHash) {
|
|
3994
|
+
var _a, _b;
|
|
3881
3995
|
var atEntity = new AccessTokenEntity();
|
|
3882
3996
|
atEntity.homeAccountId = homeAccountId;
|
|
3883
3997
|
atEntity.credentialType = exports.CredentialType.ACCESS_TOKEN;
|
|
@@ -3899,15 +4013,28 @@ var AccessTokenEntity = /** @class */ (function (_super) {
|
|
|
3899
4013
|
atEntity.target = scopes;
|
|
3900
4014
|
atEntity.oboAssertion = oboAssertion;
|
|
3901
4015
|
atEntity.tokenType = StringUtils.isEmpty(tokenType) ? exports.AuthenticationScheme.BEARER : tokenType;
|
|
3902
|
-
|
|
3903
|
-
|
|
4016
|
+
if (requestedClaims) {
|
|
4017
|
+
atEntity.requestedClaims = requestedClaims;
|
|
4018
|
+
atEntity.requestedClaimsHash = requestedClaimsHash;
|
|
4019
|
+
}
|
|
4020
|
+
/*
|
|
4021
|
+
* Create Access Token With Auth Scheme instead of regular access token
|
|
4022
|
+
* Cast to lower to handle "bearer" from ADFS
|
|
4023
|
+
*/
|
|
4024
|
+
if (((_a = atEntity.tokenType) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== exports.AuthenticationScheme.BEARER.toLowerCase()) {
|
|
3904
4025
|
atEntity.credentialType = exports.CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME;
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
4026
|
+
switch (atEntity.tokenType) {
|
|
4027
|
+
case exports.AuthenticationScheme.POP:
|
|
4028
|
+
// Make sure keyId is present and add it to credential
|
|
4029
|
+
var tokenClaims = AuthToken.extractTokenClaims(accessToken, cryptoUtils);
|
|
4030
|
+
if (!((_b = tokenClaims === null || tokenClaims === void 0 ? void 0 : tokenClaims.cnf) === null || _b === void 0 ? void 0 : _b.kid)) {
|
|
4031
|
+
throw ClientAuthError.createTokenClaimsRequiredError();
|
|
4032
|
+
}
|
|
4033
|
+
atEntity.keyId = tokenClaims.cnf.kid;
|
|
4034
|
+
break;
|
|
4035
|
+
case exports.AuthenticationScheme.SSH:
|
|
4036
|
+
atEntity.keyId = keyId;
|
|
3909
4037
|
}
|
|
3910
|
-
atEntity.keyId = tokenClaims.cnf.kid;
|
|
3911
4038
|
}
|
|
3912
4039
|
return atEntity;
|
|
3913
4040
|
};
|
|
@@ -4001,9 +4128,9 @@ var RefreshTokenEntity = /** @class */ (function (_super) {
|
|
|
4001
4128
|
* Licensed under the MIT License.
|
|
4002
4129
|
*/
|
|
4003
4130
|
/**
|
|
4004
|
-
*
|
|
4131
|
+
* InteractionRequiredServerErrorMessage contains string constants used by error codes and messages returned by the server indicating interaction is required
|
|
4005
4132
|
*/
|
|
4006
|
-
var
|
|
4133
|
+
var InteractionRequiredServerErrorMessage = [
|
|
4007
4134
|
"interaction_required",
|
|
4008
4135
|
"consent_required",
|
|
4009
4136
|
"login_required"
|
|
@@ -4016,7 +4143,16 @@ var InteractionRequiredAuthSubErrorMessage = [
|
|
|
4016
4143
|
"consent_required"
|
|
4017
4144
|
];
|
|
4018
4145
|
/**
|
|
4019
|
-
*
|
|
4146
|
+
* Interaction required errors defined by the SDK
|
|
4147
|
+
*/
|
|
4148
|
+
var InteractionRequiredAuthErrorMessage = {
|
|
4149
|
+
noTokensFoundError: {
|
|
4150
|
+
code: "no_tokens_found",
|
|
4151
|
+
desc: "No refresh token found in the cache. Please sign-in."
|
|
4152
|
+
}
|
|
4153
|
+
};
|
|
4154
|
+
/**
|
|
4155
|
+
* Error thrown when user interaction is required.
|
|
4020
4156
|
*/
|
|
4021
4157
|
var InteractionRequiredAuthError = /** @class */ (function (_super) {
|
|
4022
4158
|
__extends(InteractionRequiredAuthError, _super);
|
|
@@ -4026,16 +4162,28 @@ var InteractionRequiredAuthError = /** @class */ (function (_super) {
|
|
|
4026
4162
|
Object.setPrototypeOf(_this, InteractionRequiredAuthError.prototype);
|
|
4027
4163
|
return _this;
|
|
4028
4164
|
}
|
|
4165
|
+
/**
|
|
4166
|
+
* Helper function used to determine if an error thrown by the server requires interaction to resolve
|
|
4167
|
+
* @param errorCode
|
|
4168
|
+
* @param errorString
|
|
4169
|
+
* @param subError
|
|
4170
|
+
*/
|
|
4029
4171
|
InteractionRequiredAuthError.isInteractionRequiredError = function (errorCode, errorString, subError) {
|
|
4030
|
-
var isInteractionRequiredErrorCode = !!errorCode &&
|
|
4172
|
+
var isInteractionRequiredErrorCode = !!errorCode && InteractionRequiredServerErrorMessage.indexOf(errorCode) > -1;
|
|
4031
4173
|
var isInteractionRequiredSubError = !!subError && InteractionRequiredAuthSubErrorMessage.indexOf(subError) > -1;
|
|
4032
|
-
var isInteractionRequiredErrorDesc = !!errorString &&
|
|
4174
|
+
var isInteractionRequiredErrorDesc = !!errorString && InteractionRequiredServerErrorMessage.some(function (irErrorCode) {
|
|
4033
4175
|
return errorString.indexOf(irErrorCode) > -1;
|
|
4034
4176
|
});
|
|
4035
4177
|
return isInteractionRequiredErrorCode || isInteractionRequiredErrorDesc || isInteractionRequiredSubError;
|
|
4036
4178
|
};
|
|
4179
|
+
/**
|
|
4180
|
+
* Creates an error thrown when the authorization code required for a token request is null or empty.
|
|
4181
|
+
*/
|
|
4182
|
+
InteractionRequiredAuthError.createNoTokensFoundError = function () {
|
|
4183
|
+
return new InteractionRequiredAuthError(InteractionRequiredAuthErrorMessage.noTokensFoundError.code, InteractionRequiredAuthErrorMessage.noTokensFoundError.desc);
|
|
4184
|
+
};
|
|
4037
4185
|
return InteractionRequiredAuthError;
|
|
4038
|
-
}(
|
|
4186
|
+
}(AuthError));
|
|
4039
4187
|
|
|
4040
4188
|
/*
|
|
4041
4189
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4377,14 +4525,14 @@ var PopTokenGenerator = /** @class */ (function () {
|
|
|
4377
4525
|
};
|
|
4378
4526
|
PopTokenGenerator.prototype.signPayload = function (payload, kid, request, claims) {
|
|
4379
4527
|
return __awaiter(this, void 0, void 0, function () {
|
|
4380
|
-
var resourceRequestMethod, resourceRequestUri, shrClaims, resourceUrlString, resourceUrlComponents;
|
|
4528
|
+
var resourceRequestMethod, resourceRequestUri, shrClaims, shrNonce, resourceUrlString, resourceUrlComponents;
|
|
4381
4529
|
return __generator(this, function (_a) {
|
|
4382
4530
|
switch (_a.label) {
|
|
4383
4531
|
case 0:
|
|
4384
|
-
resourceRequestMethod = request.resourceRequestMethod, resourceRequestUri = request.resourceRequestUri, shrClaims = request.shrClaims;
|
|
4532
|
+
resourceRequestMethod = request.resourceRequestMethod, resourceRequestUri = request.resourceRequestUri, shrClaims = request.shrClaims, shrNonce = request.shrNonce;
|
|
4385
4533
|
resourceUrlString = (resourceRequestUri) ? new UrlString(resourceRequestUri) : undefined;
|
|
4386
4534
|
resourceUrlComponents = resourceUrlString === null || resourceUrlString === void 0 ? void 0 : resourceUrlString.getUrlComponents();
|
|
4387
|
-
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)];
|
|
4535
|
+
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)];
|
|
4388
4536
|
case 1: return [2 /*return*/, _a.sent()];
|
|
4389
4537
|
}
|
|
4390
4538
|
});
|
|
@@ -4575,7 +4723,9 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
4575
4723
|
if (!!authCodePayload && !!authCodePayload.state) {
|
|
4576
4724
|
requestStateObj = ProtocolUtils.parseRequestState(this.cryptoObj, authCodePayload.state);
|
|
4577
4725
|
}
|
|
4578
|
-
|
|
4726
|
+
// Add keyId from request to serverTokenResponse if defined
|
|
4727
|
+
serverTokenResponse.key_id = serverTokenResponse.key_id || request.sshKid || undefined;
|
|
4728
|
+
cacheRecord = this.generateCacheRecord(serverTokenResponse, authority, reqTimestamp, request, idTokenObj, oboAssertion, authCodePayload);
|
|
4579
4729
|
_a.label = 1;
|
|
4580
4730
|
case 1:
|
|
4581
4731
|
_a.trys.push([1, , 5, 8]);
|
|
@@ -4612,7 +4762,7 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
4612
4762
|
_a.sent();
|
|
4613
4763
|
_a.label = 7;
|
|
4614
4764
|
case 7: return [7 /*endfinally*/];
|
|
4615
|
-
case 8: return [2 /*return*/, ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenObj, requestStateObj)];
|
|
4765
|
+
case 8: return [2 /*return*/, ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenObj, requestStateObj, serverTokenResponse.spa_code)];
|
|
4616
4766
|
}
|
|
4617
4767
|
});
|
|
4618
4768
|
});
|
|
@@ -4623,7 +4773,7 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
4623
4773
|
* @param idTokenObj
|
|
4624
4774
|
* @param authority
|
|
4625
4775
|
*/
|
|
4626
|
-
ResponseHandler.prototype.generateCacheRecord = function (serverTokenResponse, authority, reqTimestamp,
|
|
4776
|
+
ResponseHandler.prototype.generateCacheRecord = function (serverTokenResponse, authority, reqTimestamp, request, idTokenObj, oboAssertion, authCodePayload) {
|
|
4627
4777
|
var env = authority.getPreferredCache();
|
|
4628
4778
|
if (StringUtils.isEmpty(env)) {
|
|
4629
4779
|
throw ClientAuthError.createInvalidCacheEnvironmentError();
|
|
@@ -4639,7 +4789,7 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
4639
4789
|
var cachedAccessToken = null;
|
|
4640
4790
|
if (!StringUtils.isEmpty(serverTokenResponse.access_token)) {
|
|
4641
4791
|
// If scopes not returned in server response, use request scopes
|
|
4642
|
-
var responseScopes = serverTokenResponse.scope ? ScopeSet.fromString(serverTokenResponse.scope) : new ScopeSet(
|
|
4792
|
+
var responseScopes = serverTokenResponse.scope ? ScopeSet.fromString(serverTokenResponse.scope) : new ScopeSet(request.scopes || []);
|
|
4643
4793
|
/*
|
|
4644
4794
|
* Use timestamp calculated before request
|
|
4645
4795
|
* Server may return timestamps as strings, parse to numbers if so.
|
|
@@ -4651,7 +4801,7 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
4651
4801
|
var extendedTokenExpirationSeconds = tokenExpirationSeconds + extExpiresIn;
|
|
4652
4802
|
var refreshOnSeconds = refreshIn && refreshIn > 0 ? reqTimestamp + refreshIn : undefined;
|
|
4653
4803
|
// non AAD scenarios can have empty realm
|
|
4654
|
-
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);
|
|
4804
|
+
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);
|
|
4655
4805
|
}
|
|
4656
4806
|
// refreshToken
|
|
4657
4807
|
var cachedRefreshToken = null;
|
|
@@ -4698,7 +4848,7 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
4698
4848
|
* @param fromTokenCache
|
|
4699
4849
|
* @param stateString
|
|
4700
4850
|
*/
|
|
4701
|
-
ResponseHandler.generateAuthenticationResult = function (cryptoObj, authority, cacheRecord, fromTokenCache, request, idTokenObj, requestState) {
|
|
4851
|
+
ResponseHandler.generateAuthenticationResult = function (cryptoObj, authority, cacheRecord, fromTokenCache, request, idTokenObj, requestState, code) {
|
|
4702
4852
|
var _a, _b, _c;
|
|
4703
4853
|
return __awaiter(this, void 0, void 0, function () {
|
|
4704
4854
|
var accessToken, responseScopes, expiresOn, extExpiresOn, familyId, popTokenGenerator, uid, tid;
|
|
@@ -4747,7 +4897,8 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
4747
4897
|
tokenType: ((_a = cacheRecord.accessToken) === null || _a === void 0 ? void 0 : _a.tokenType) || Constants.EMPTY_STRING,
|
|
4748
4898
|
state: requestState ? requestState.userRequestState : Constants.EMPTY_STRING,
|
|
4749
4899
|
cloudGraphHostName: ((_b = cacheRecord.account) === null || _b === void 0 ? void 0 : _b.cloudGraphHostName) || Constants.EMPTY_STRING,
|
|
4750
|
-
msGraphHost: ((_c = cacheRecord.account) === null || _c === void 0 ? void 0 : _c.msGraphHost) || Constants.EMPTY_STRING
|
|
4900
|
+
msGraphHost: ((_c = cacheRecord.account) === null || _c === void 0 ? void 0 : _c.msGraphHost) || Constants.EMPTY_STRING,
|
|
4901
|
+
code: code
|
|
4751
4902
|
}];
|
|
4752
4903
|
}
|
|
4753
4904
|
});
|
|
@@ -4766,7 +4917,10 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
4766
4917
|
var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
4767
4918
|
__extends(AuthorizationCodeClient, _super);
|
|
4768
4919
|
function AuthorizationCodeClient(configuration) {
|
|
4769
|
-
|
|
4920
|
+
var _this = _super.call(this, configuration) || this;
|
|
4921
|
+
// Flag to indicate if client is for hybrid spa auth code redemption
|
|
4922
|
+
_this.includeRedirectUri = true;
|
|
4923
|
+
return _this;
|
|
4770
4924
|
}
|
|
4771
4925
|
/**
|
|
4772
4926
|
* Creates the URL of the authorization request letting the user input credentials and consent to the
|
|
@@ -4866,10 +5020,12 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
4866
5020
|
clientId: this.config.authOptions.clientId,
|
|
4867
5021
|
authority: authority.canonicalAuthority,
|
|
4868
5022
|
scopes: request.scopes,
|
|
5023
|
+
claims: request.claims,
|
|
4869
5024
|
authenticationScheme: request.authenticationScheme,
|
|
4870
5025
|
resourceRequestMethod: request.resourceRequestMethod,
|
|
4871
5026
|
resourceRequestUri: request.resourceRequestUri,
|
|
4872
|
-
shrClaims: request.shrClaims
|
|
5027
|
+
shrClaims: request.shrClaims,
|
|
5028
|
+
sshKid: request.sshKid
|
|
4873
5029
|
};
|
|
4874
5030
|
return [4 /*yield*/, this.createTokenRequestBody(request)];
|
|
4875
5031
|
case 1:
|
|
@@ -4913,13 +5069,24 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
4913
5069
|
AuthorizationCodeClient.prototype.createTokenRequestBody = function (request) {
|
|
4914
5070
|
return __awaiter(this, void 0, void 0, function () {
|
|
4915
5071
|
var parameterBuilder, clientAssertion, popTokenGenerator, cnfString, correlationId, ccsCred, clientInfo, clientInfo;
|
|
4916
|
-
|
|
4917
|
-
|
|
5072
|
+
var _a;
|
|
5073
|
+
return __generator(this, function (_b) {
|
|
5074
|
+
switch (_b.label) {
|
|
4918
5075
|
case 0:
|
|
4919
5076
|
parameterBuilder = new RequestParameterBuilder();
|
|
4920
5077
|
parameterBuilder.addClientId(this.config.authOptions.clientId);
|
|
4921
|
-
|
|
4922
|
-
|
|
5078
|
+
/*
|
|
5079
|
+
* For hybrid spa flow, there will be a code but no verifier
|
|
5080
|
+
* In this scenario, don't include redirect uri as auth code will not be bound to redirect URI
|
|
5081
|
+
*/
|
|
5082
|
+
if (!this.includeRedirectUri) {
|
|
5083
|
+
// Just validate
|
|
5084
|
+
RequestValidator.validateRedirectUri(request.redirectUri);
|
|
5085
|
+
}
|
|
5086
|
+
else {
|
|
5087
|
+
// Validate and include redirect uri
|
|
5088
|
+
parameterBuilder.addRedirectUri(request.redirectUri);
|
|
5089
|
+
}
|
|
4923
5090
|
// Add scope array, parameter builder will add default scopes and dedupe
|
|
4924
5091
|
parameterBuilder.addScopes(request.scopes);
|
|
4925
5092
|
// add code: user set, not validated
|
|
@@ -4948,10 +5115,20 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
4948
5115
|
popTokenGenerator = new PopTokenGenerator(this.cryptoUtils);
|
|
4949
5116
|
return [4 /*yield*/, popTokenGenerator.generateCnf(request)];
|
|
4950
5117
|
case 1:
|
|
4951
|
-
cnfString =
|
|
5118
|
+
cnfString = _b.sent();
|
|
4952
5119
|
parameterBuilder.addPopToken(cnfString);
|
|
4953
|
-
|
|
5120
|
+
return [3 /*break*/, 3];
|
|
4954
5121
|
case 2:
|
|
5122
|
+
if (request.authenticationScheme === exports.AuthenticationScheme.SSH) {
|
|
5123
|
+
if (request.sshJwk) {
|
|
5124
|
+
parameterBuilder.addSshJwk(request.sshJwk);
|
|
5125
|
+
}
|
|
5126
|
+
else {
|
|
5127
|
+
throw ClientConfigurationError.createMissingSshJwkError();
|
|
5128
|
+
}
|
|
5129
|
+
}
|
|
5130
|
+
_b.label = 3;
|
|
5131
|
+
case 3:
|
|
4955
5132
|
correlationId = request.correlationId || this.config.cryptoInterface.createNewGuid();
|
|
4956
5133
|
parameterBuilder.addCorrelationId(correlationId);
|
|
4957
5134
|
if (!StringUtils.isEmptyObj(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {
|
|
@@ -4990,6 +5167,15 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
4990
5167
|
break;
|
|
4991
5168
|
}
|
|
4992
5169
|
}
|
|
5170
|
+
if (request.tokenBodyParameters) {
|
|
5171
|
+
parameterBuilder.addExtraQueryParameters(request.tokenBodyParameters);
|
|
5172
|
+
}
|
|
5173
|
+
// Add hybrid spa parameters if not already provided
|
|
5174
|
+
if (request.enableSpaAuthorizationCode && (!request.tokenBodyParameters || !request.tokenBodyParameters[AADServerParamKeys.RETURN_SPA_CODE])) {
|
|
5175
|
+
parameterBuilder.addExtraQueryParameters((_a = {},
|
|
5176
|
+
_a[AADServerParamKeys.RETURN_SPA_CODE] = "1",
|
|
5177
|
+
_a));
|
|
5178
|
+
}
|
|
4993
5179
|
return [2 /*return*/, parameterBuilder.createQueryString()];
|
|
4994
5180
|
}
|
|
4995
5181
|
});
|
|
@@ -5180,10 +5366,12 @@ var DeviceCodeClient = /** @class */ (function (_super) {
|
|
|
5180
5366
|
clientId: this.config.authOptions.clientId,
|
|
5181
5367
|
authority: request.authority,
|
|
5182
5368
|
scopes: request.scopes,
|
|
5369
|
+
claims: request.claims,
|
|
5183
5370
|
authenticationScheme: request.authenticationScheme,
|
|
5184
5371
|
resourceRequestMethod: request.resourceRequestMethod,
|
|
5185
5372
|
resourceRequestUri: request.resourceRequestUri,
|
|
5186
|
-
shrClaims: request.shrClaims
|
|
5373
|
+
shrClaims: request.shrClaims,
|
|
5374
|
+
sshKid: request.sshKid
|
|
5187
5375
|
};
|
|
5188
5376
|
return [2 /*return*/, this.executePostRequestToDeviceCodeEndpoint(this.authority.deviceCodeEndpoint, queryString, headers, thumbprint)];
|
|
5189
5377
|
});
|
|
@@ -5277,10 +5465,12 @@ var DeviceCodeClient = /** @class */ (function (_super) {
|
|
|
5277
5465
|
clientId: this.config.authOptions.clientId,
|
|
5278
5466
|
authority: request.authority,
|
|
5279
5467
|
scopes: request.scopes,
|
|
5468
|
+
claims: request.claims,
|
|
5280
5469
|
authenticationScheme: request.authenticationScheme,
|
|
5281
5470
|
resourceRequestMethod: request.resourceRequestMethod,
|
|
5282
5471
|
resourceRequestUri: request.resourceRequestUri,
|
|
5283
|
-
shrClaims: request.shrClaims
|
|
5472
|
+
shrClaims: request.shrClaims,
|
|
5473
|
+
sshKid: request.sshKid
|
|
5284
5474
|
};
|
|
5285
5475
|
return [4 /*yield*/, this.executePostToTokenEndpoint(this.authority.tokenEndpoint, requestBody, headers, thumbprint)];
|
|
5286
5476
|
case 2:
|
|
@@ -5386,7 +5576,7 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
5386
5576
|
return [2 /*return*/, this.acquireTokenWithCachedRefreshToken(request, true)];
|
|
5387
5577
|
}
|
|
5388
5578
|
catch (e) {
|
|
5389
|
-
noFamilyRTInCache = e instanceof
|
|
5579
|
+
noFamilyRTInCache = e instanceof InteractionRequiredAuthError && e.errorCode === InteractionRequiredAuthErrorMessage.noTokensFoundError.code;
|
|
5390
5580
|
clientMismatchErrorWithFamilyRT = e instanceof ServerError && e.errorCode === Errors.INVALID_GRANT_ERROR && e.subError === Errors.CLIENT_MISMATCH_ERROR;
|
|
5391
5581
|
// if family Refresh Token (FRT) cache acquisition fails or if client_mismatch error is seen with FRT, reattempt with application Refresh Token (ART)
|
|
5392
5582
|
if (noFamilyRTInCache || clientMismatchErrorWithFamilyRT) {
|
|
@@ -5414,7 +5604,7 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
5414
5604
|
refreshToken = this.cacheManager.readRefreshTokenFromCache(this.config.authOptions.clientId, request.account, foci);
|
|
5415
5605
|
// no refresh Token
|
|
5416
5606
|
if (!refreshToken) {
|
|
5417
|
-
throw
|
|
5607
|
+
throw InteractionRequiredAuthError.createNoTokensFoundError();
|
|
5418
5608
|
}
|
|
5419
5609
|
refreshTokenRequest = __assign(__assign({}, request), { refreshToken: refreshToken.secret, authenticationScheme: request.authenticationScheme || exports.AuthenticationScheme.BEARER, ccsCredential: {
|
|
5420
5610
|
credential: request.account.homeAccountId,
|
|
@@ -5443,10 +5633,12 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
5443
5633
|
clientId: this.config.authOptions.clientId,
|
|
5444
5634
|
authority: authority.canonicalAuthority,
|
|
5445
5635
|
scopes: request.scopes,
|
|
5636
|
+
claims: request.claims,
|
|
5446
5637
|
authenticationScheme: request.authenticationScheme,
|
|
5447
5638
|
resourceRequestMethod: request.resourceRequestMethod,
|
|
5448
5639
|
resourceRequestUri: request.resourceRequestUri,
|
|
5449
|
-
shrClaims: request.shrClaims
|
|
5640
|
+
shrClaims: request.shrClaims,
|
|
5641
|
+
sshKid: request.sshKid
|
|
5450
5642
|
};
|
|
5451
5643
|
endpoint = UrlString.appendQueryString(authority.tokenEndpoint, queryParameters);
|
|
5452
5644
|
return [2 /*return*/, this.executePostToTokenEndpoint(endpoint, requestBody, headers, thumbprint)];
|
|
@@ -5471,9 +5663,9 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
5471
5663
|
*/
|
|
5472
5664
|
RefreshTokenClient.prototype.createTokenRequestBody = function (request) {
|
|
5473
5665
|
return __awaiter(this, void 0, void 0, function () {
|
|
5474
|
-
var parameterBuilder, correlationId, clientAssertion, popTokenGenerator,
|
|
5475
|
-
return __generator(this, function (
|
|
5476
|
-
switch (
|
|
5666
|
+
var parameterBuilder, correlationId, clientAssertion, popTokenGenerator, cnfString, clientInfo;
|
|
5667
|
+
return __generator(this, function (_a) {
|
|
5668
|
+
switch (_a.label) {
|
|
5477
5669
|
case 0:
|
|
5478
5670
|
parameterBuilder = new RequestParameterBuilder();
|
|
5479
5671
|
parameterBuilder.addClientId(this.config.authOptions.clientId);
|
|
@@ -5498,12 +5690,22 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
5498
5690
|
}
|
|
5499
5691
|
if (!(request.authenticationScheme === exports.AuthenticationScheme.POP)) return [3 /*break*/, 2];
|
|
5500
5692
|
popTokenGenerator = new PopTokenGenerator(this.cryptoUtils);
|
|
5501
|
-
_b = (_a = parameterBuilder).addPopToken;
|
|
5502
5693
|
return [4 /*yield*/, popTokenGenerator.generateCnf(request)];
|
|
5503
5694
|
case 1:
|
|
5504
|
-
|
|
5505
|
-
|
|
5695
|
+
cnfString = _a.sent();
|
|
5696
|
+
parameterBuilder.addPopToken(cnfString);
|
|
5697
|
+
return [3 /*break*/, 3];
|
|
5506
5698
|
case 2:
|
|
5699
|
+
if (request.authenticationScheme === exports.AuthenticationScheme.SSH) {
|
|
5700
|
+
if (request.sshJwk) {
|
|
5701
|
+
parameterBuilder.addSshJwk(request.sshJwk);
|
|
5702
|
+
}
|
|
5703
|
+
else {
|
|
5704
|
+
throw ClientConfigurationError.createMissingSshJwkError();
|
|
5705
|
+
}
|
|
5706
|
+
}
|
|
5707
|
+
_a.label = 3;
|
|
5708
|
+
case 3:
|
|
5507
5709
|
if (!StringUtils.isEmptyObj(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {
|
|
5508
5710
|
parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);
|
|
5509
5711
|
}
|
|
@@ -5639,10 +5841,12 @@ var ClientCredentialClient = /** @class */ (function (_super) {
|
|
|
5639
5841
|
clientId: this.config.authOptions.clientId,
|
|
5640
5842
|
authority: request.authority,
|
|
5641
5843
|
scopes: request.scopes,
|
|
5844
|
+
claims: request.claims,
|
|
5642
5845
|
authenticationScheme: request.authenticationScheme,
|
|
5643
5846
|
resourceRequestMethod: request.resourceRequestMethod,
|
|
5644
5847
|
resourceRequestUri: request.resourceRequestUri,
|
|
5645
|
-
shrClaims: request.shrClaims
|
|
5848
|
+
shrClaims: request.shrClaims,
|
|
5849
|
+
sshKid: request.sshKid
|
|
5646
5850
|
};
|
|
5647
5851
|
reqTimestamp = TimeUtils.nowSeconds();
|
|
5648
5852
|
return [4 /*yield*/, this.executePostToTokenEndpoint(authority.tokenEndpoint, requestBody, headers, thumbprint)];
|
|
@@ -5838,10 +6042,12 @@ var OnBehalfOfClient = /** @class */ (function (_super) {
|
|
|
5838
6042
|
clientId: this.config.authOptions.clientId,
|
|
5839
6043
|
authority: request.authority,
|
|
5840
6044
|
scopes: request.scopes,
|
|
6045
|
+
claims: request.claims,
|
|
5841
6046
|
authenticationScheme: request.authenticationScheme,
|
|
5842
6047
|
resourceRequestMethod: request.resourceRequestMethod,
|
|
5843
6048
|
resourceRequestUri: request.resourceRequestUri,
|
|
5844
|
-
shrClaims: request.shrClaims
|
|
6049
|
+
shrClaims: request.shrClaims,
|
|
6050
|
+
sshKid: request.sshKid
|
|
5845
6051
|
};
|
|
5846
6052
|
reqTimestamp = TimeUtils.nowSeconds();
|
|
5847
6053
|
return [4 /*yield*/, this.executePostToTokenEndpoint(authority.tokenEndpoint, requestBody, headers, thumbprint)];
|
|
@@ -5933,7 +6139,7 @@ var SilentFlowClient = /** @class */ (function (_super) {
|
|
|
5933
6139
|
SilentFlowClient.prototype.acquireCachedToken = function (request) {
|
|
5934
6140
|
var _a, _b, _c, _d;
|
|
5935
6141
|
return __awaiter(this, void 0, void 0, function () {
|
|
5936
|
-
var
|
|
6142
|
+
var environment, cacheRecord;
|
|
5937
6143
|
return __generator(this, function (_e) {
|
|
5938
6144
|
switch (_e.label) {
|
|
5939
6145
|
case 0:
|
|
@@ -5941,37 +6147,35 @@ var SilentFlowClient = /** @class */ (function (_super) {
|
|
|
5941
6147
|
if (!request) {
|
|
5942
6148
|
throw ClientConfigurationError.createEmptyTokenRequestError();
|
|
5943
6149
|
}
|
|
5944
|
-
// We currently do not support silent flow for account === null use cases; This will be revisited for confidential flow usecases
|
|
5945
|
-
if (!request.account) {
|
|
5946
|
-
throw ClientAuthError.createNoAccountInSilentRequestError();
|
|
5947
|
-
}
|
|
5948
|
-
requestScopes = new ScopeSet(request.scopes || []);
|
|
5949
|
-
environment = request.authority || this.authority.getPreferredCache();
|
|
5950
|
-
authScheme = request.authenticationScheme || exports.AuthenticationScheme.BEARER;
|
|
5951
|
-
cacheRecord = this.cacheManager.readCacheRecord(request.account, this.config.authOptions.clientId, requestScopes, environment, authScheme);
|
|
5952
6150
|
if (request.forceRefresh) {
|
|
5953
6151
|
// Must refresh due to present force_refresh flag.
|
|
5954
6152
|
(_a = this.serverTelemetryManager) === null || _a === void 0 ? void 0 : _a.setCacheOutcome(CacheOutcome.FORCE_REFRESH);
|
|
6153
|
+
this.logger.info("SilentFlowClient:acquireCachedToken - Skipping cache because forceRefresh is true.");
|
|
5955
6154
|
throw ClientAuthError.createRefreshRequiredError();
|
|
5956
6155
|
}
|
|
5957
|
-
|
|
6156
|
+
// We currently do not support silent flow for account === null use cases; This will be revisited for confidential flow usecases
|
|
6157
|
+
if (!request.account) {
|
|
6158
|
+
throw ClientAuthError.createNoAccountInSilentRequestError();
|
|
6159
|
+
}
|
|
6160
|
+
environment = request.authority || this.authority.getPreferredCache();
|
|
6161
|
+
cacheRecord = this.cacheManager.readCacheRecord(request.account, this.config.authOptions.clientId, request, environment);
|
|
6162
|
+
if (!cacheRecord.accessToken) {
|
|
5958
6163
|
// Must refresh due to non-existent access_token.
|
|
5959
6164
|
(_b = this.serverTelemetryManager) === null || _b === void 0 ? void 0 : _b.setCacheOutcome(CacheOutcome.NO_CACHED_ACCESS_TOKEN);
|
|
6165
|
+
this.logger.info("SilentFlowClient:acquireCachedToken - No access token found in cache for the given properties.");
|
|
5960
6166
|
throw ClientAuthError.createRefreshRequiredError();
|
|
5961
6167
|
}
|
|
5962
6168
|
else if (TimeUtils.wasClockTurnedBack(cacheRecord.accessToken.cachedAt) ||
|
|
5963
6169
|
TimeUtils.isTokenExpired(cacheRecord.accessToken.expiresOn, this.config.systemOptions.tokenRenewalOffsetSeconds)) {
|
|
5964
6170
|
// Must refresh due to expired access_token.
|
|
5965
6171
|
(_c = this.serverTelemetryManager) === null || _c === void 0 ? void 0 : _c.setCacheOutcome(CacheOutcome.CACHED_ACCESS_TOKEN_EXPIRED);
|
|
6172
|
+
this.logger.info("SilentFlowClient:acquireCachedToken - Cached access token is expired or will expire within " + this.config.systemOptions.tokenRenewalOffsetSeconds + " seconds.");
|
|
5966
6173
|
throw ClientAuthError.createRefreshRequiredError();
|
|
5967
6174
|
}
|
|
5968
6175
|
else if (cacheRecord.accessToken.refreshOn && TimeUtils.isTokenExpired(cacheRecord.accessToken.refreshOn, 0)) {
|
|
5969
6176
|
// Must refresh due to the refresh_in value.
|
|
5970
6177
|
(_d = this.serverTelemetryManager) === null || _d === void 0 ? void 0 : _d.setCacheOutcome(CacheOutcome.REFRESH_CACHED_ACCESS_TOKEN);
|
|
5971
|
-
|
|
5972
|
-
}
|
|
5973
|
-
else if (!StringUtils.isEmptyObj(request.claims)) {
|
|
5974
|
-
// Must refresh due to request parameters.
|
|
6178
|
+
this.logger.info("SilentFlowClient:acquireCachedToken - Cached access token's refreshOn property has been exceeded'.");
|
|
5975
6179
|
throw ClientAuthError.createRefreshRequiredError();
|
|
5976
6180
|
}
|
|
5977
6181
|
if (this.config.serverTelemetryManager) {
|
|
@@ -6056,10 +6260,12 @@ var UsernamePasswordClient = /** @class */ (function (_super) {
|
|
|
6056
6260
|
clientId: this.config.authOptions.clientId,
|
|
6057
6261
|
authority: authority.canonicalAuthority,
|
|
6058
6262
|
scopes: request.scopes,
|
|
6263
|
+
claims: request.claims,
|
|
6059
6264
|
authenticationScheme: request.authenticationScheme,
|
|
6060
6265
|
resourceRequestMethod: request.resourceRequestMethod,
|
|
6061
6266
|
resourceRequestUri: request.resourceRequestUri,
|
|
6062
|
-
shrClaims: request.shrClaims
|
|
6267
|
+
shrClaims: request.shrClaims,
|
|
6268
|
+
sshKid: request.sshKid
|
|
6063
6269
|
};
|
|
6064
6270
|
requestBody = this.createTokenRequestBody(request);
|
|
6065
6271
|
headers = this.createTokenRequestHeaders({
|
|
@@ -6115,7 +6321,6 @@ var UsernamePasswordClient = /** @class */ (function (_super) {
|
|
|
6115
6321
|
function isOpenIdConfigResponse(response) {
|
|
6116
6322
|
return (response.hasOwnProperty("authorization_endpoint") &&
|
|
6117
6323
|
response.hasOwnProperty("token_endpoint") &&
|
|
6118
|
-
response.hasOwnProperty("end_session_endpoint") &&
|
|
6119
6324
|
response.hasOwnProperty("issuer"));
|
|
6120
6325
|
}
|
|
6121
6326
|
|
|
@@ -6197,7 +6402,6 @@ var AuthorityMetadataEntity = /** @class */ (function () {
|
|
|
6197
6402
|
entity.hasOwnProperty("canonical_authority") &&
|
|
6198
6403
|
entity.hasOwnProperty("authorization_endpoint") &&
|
|
6199
6404
|
entity.hasOwnProperty("token_endpoint") &&
|
|
6200
|
-
entity.hasOwnProperty("end_session_endpoint") &&
|
|
6201
6405
|
entity.hasOwnProperty("issuer") &&
|
|
6202
6406
|
entity.hasOwnProperty("aliasesFromNetwork") &&
|
|
6203
6407
|
entity.hasOwnProperty("endpointsFromNetwork") &&
|
|
@@ -6479,6 +6683,10 @@ var Authority = /** @class */ (function () {
|
|
|
6479
6683
|
*/
|
|
6480
6684
|
get: function () {
|
|
6481
6685
|
if (this.discoveryComplete()) {
|
|
6686
|
+
// ROPC policies may not have end_session_endpoint set
|
|
6687
|
+
if (!this.metadata.end_session_endpoint) {
|
|
6688
|
+
throw ClientAuthError.createLogoutNotSupportedError();
|
|
6689
|
+
}
|
|
6482
6690
|
var endpoint = this.replacePath(this.metadata.end_session_endpoint);
|
|
6483
6691
|
return this.replaceTenant(endpoint);
|
|
6484
6692
|
}
|
|
@@ -6879,7 +7087,9 @@ var Authority = /** @class */ (function () {
|
|
|
6879
7087
|
metadata.authorization_endpoint = Authority.buildRegionalAuthorityString(metadata.authorization_endpoint, azureRegion);
|
|
6880
7088
|
// TODO: Enquire on whether we should leave the query string or remove it before releasing the feature
|
|
6881
7089
|
metadata.token_endpoint = Authority.buildRegionalAuthorityString(metadata.token_endpoint, azureRegion, "allowestsrnonmsi=true");
|
|
6882
|
-
|
|
7090
|
+
if (metadata.end_session_endpoint) {
|
|
7091
|
+
metadata.end_session_endpoint = Authority.buildRegionalAuthorityString(metadata.end_session_endpoint, azureRegion);
|
|
7092
|
+
}
|
|
6883
7093
|
return metadata;
|
|
6884
7094
|
};
|
|
6885
7095
|
return Authority;
|
|
@@ -7014,6 +7224,63 @@ var StubbedNetworkModule = {
|
|
|
7014
7224
|
}
|
|
7015
7225
|
};
|
|
7016
7226
|
|
|
7227
|
+
/*
|
|
7228
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
7229
|
+
* Licensed under the MIT License.
|
|
7230
|
+
*/
|
|
7231
|
+
/**
|
|
7232
|
+
* This is a helper class that parses supported HTTP response authentication headers to extract and return
|
|
7233
|
+
* header challenge values that can be used outside the basic authorization flows.
|
|
7234
|
+
*/
|
|
7235
|
+
var AuthenticationHeaderParser = /** @class */ (function () {
|
|
7236
|
+
function AuthenticationHeaderParser(headers) {
|
|
7237
|
+
this.headers = headers;
|
|
7238
|
+
}
|
|
7239
|
+
/**
|
|
7240
|
+
* This method parses the SHR nonce value out of either the Authentication-Info or WWW-Authenticate authentication headers.
|
|
7241
|
+
* @returns
|
|
7242
|
+
*/
|
|
7243
|
+
AuthenticationHeaderParser.prototype.getShrNonce = function () {
|
|
7244
|
+
// Attempt to parse nonce from Authentiacation-Info
|
|
7245
|
+
var authenticationInfo = this.headers[HeaderNames.AuthenticationInfo];
|
|
7246
|
+
if (authenticationInfo) {
|
|
7247
|
+
var authenticationInfoChallenges = this.parseChallenges(authenticationInfo);
|
|
7248
|
+
if (authenticationInfoChallenges.nextnonce) {
|
|
7249
|
+
return authenticationInfoChallenges.nextnonce;
|
|
7250
|
+
}
|
|
7251
|
+
throw ClientConfigurationError.createInvalidAuthenticationHeaderError(HeaderNames.AuthenticationInfo, "nextnonce challenge is missing.");
|
|
7252
|
+
}
|
|
7253
|
+
// Attempt to parse nonce from WWW-Authenticate
|
|
7254
|
+
var wwwAuthenticate = this.headers[HeaderNames.WWWAuthenticate];
|
|
7255
|
+
if (wwwAuthenticate) {
|
|
7256
|
+
var wwwAuthenticateChallenges = this.parseChallenges(wwwAuthenticate);
|
|
7257
|
+
if (wwwAuthenticateChallenges.nonce) {
|
|
7258
|
+
return wwwAuthenticateChallenges.nonce;
|
|
7259
|
+
}
|
|
7260
|
+
throw ClientConfigurationError.createInvalidAuthenticationHeaderError(HeaderNames.WWWAuthenticate, "nonce challenge is missing.");
|
|
7261
|
+
}
|
|
7262
|
+
// If neither header is present, throw missing headers error
|
|
7263
|
+
throw ClientConfigurationError.createMissingNonceAuthenticationHeadersError();
|
|
7264
|
+
};
|
|
7265
|
+
/**
|
|
7266
|
+
* Parses an HTTP header's challenge set into a key/value map.
|
|
7267
|
+
* @param header
|
|
7268
|
+
* @returns
|
|
7269
|
+
*/
|
|
7270
|
+
AuthenticationHeaderParser.prototype.parseChallenges = function (header) {
|
|
7271
|
+
var schemeSeparator = header.indexOf(" ");
|
|
7272
|
+
var challenges = header.substr(schemeSeparator + 1).split(",");
|
|
7273
|
+
var challengeMap = {};
|
|
7274
|
+
challenges.forEach(function (challenge) {
|
|
7275
|
+
var _a = challenge.split("="), key = _a[0], value = _a[1];
|
|
7276
|
+
// Remove escaped quotation marks (', ") from challenge string to keep only the challenge value
|
|
7277
|
+
challengeMap[key] = unescape(value.replace(/['"]+/g, ""));
|
|
7278
|
+
});
|
|
7279
|
+
return challengeMap;
|
|
7280
|
+
};
|
|
7281
|
+
return AuthenticationHeaderParser;
|
|
7282
|
+
}());
|
|
7283
|
+
|
|
7017
7284
|
/*
|
|
7018
7285
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
7019
7286
|
* Licensed under the MIT License.
|
|
@@ -7180,6 +7447,7 @@ exports.AppMetadataEntity = AppMetadataEntity;
|
|
|
7180
7447
|
exports.AuthError = AuthError;
|
|
7181
7448
|
exports.AuthErrorMessage = AuthErrorMessage;
|
|
7182
7449
|
exports.AuthToken = AuthToken;
|
|
7450
|
+
exports.AuthenticationHeaderParser = AuthenticationHeaderParser;
|
|
7183
7451
|
exports.Authority = Authority;
|
|
7184
7452
|
exports.AuthorityFactory = AuthorityFactory;
|
|
7185
7453
|
exports.AuthorityMetadataEntity = AuthorityMetadataEntity;
|
|
@@ -7199,6 +7467,7 @@ exports.DeviceCodeClient = DeviceCodeClient;
|
|
|
7199
7467
|
exports.IdToken = AuthToken;
|
|
7200
7468
|
exports.IdTokenEntity = IdTokenEntity;
|
|
7201
7469
|
exports.InteractionRequiredAuthError = InteractionRequiredAuthError;
|
|
7470
|
+
exports.InteractionRequiredAuthErrorMessage = InteractionRequiredAuthErrorMessage;
|
|
7202
7471
|
exports.Logger = Logger;
|
|
7203
7472
|
exports.NetworkManager = NetworkManager;
|
|
7204
7473
|
exports.OIDC_DEFAULT_SCOPES = OIDC_DEFAULT_SCOPES;
|
|
@@ -7221,4 +7490,5 @@ exports.TimeUtils = TimeUtils;
|
|
|
7221
7490
|
exports.TokenCacheContext = TokenCacheContext;
|
|
7222
7491
|
exports.UrlString = UrlString;
|
|
7223
7492
|
exports.UsernamePasswordClient = UsernamePasswordClient;
|
|
7493
|
+
exports.version = version;
|
|
7224
7494
|
//# sourceMappingURL=index.cjs.js.map
|