@azure/msal-common 5.2.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.
Files changed (92) hide show
  1. package/CHANGELOG.json +23 -0
  2. package/CHANGELOG.md +13 -1
  3. package/dist/_virtual/_tslib.js +1 -1
  4. package/dist/account/AuthToken.js +1 -1
  5. package/dist/account/CcsCredential.js +1 -1
  6. package/dist/account/ClientInfo.js +1 -1
  7. package/dist/authority/Authority.js +1 -1
  8. package/dist/authority/AuthorityFactory.js +1 -1
  9. package/dist/authority/AuthorityType.js +1 -1
  10. package/dist/authority/CloudInstanceDiscoveryResponse.js +1 -1
  11. package/dist/authority/OpenIdConfigResponse.js +1 -1
  12. package/dist/authority/ProtocolMode.js +1 -1
  13. package/dist/authority/RegionDiscovery.js +1 -1
  14. package/dist/cache/CacheManager.d.ts +9 -5
  15. package/dist/cache/CacheManager.d.ts.map +1 -1
  16. package/dist/cache/CacheManager.js +38 -28
  17. package/dist/cache/CacheManager.js.map +1 -1
  18. package/dist/cache/entities/AccessTokenEntity.d.ts +3 -1
  19. package/dist/cache/entities/AccessTokenEntity.d.ts.map +1 -1
  20. package/dist/cache/entities/AccessTokenEntity.js +13 -6
  21. package/dist/cache/entities/AccessTokenEntity.js.map +1 -1
  22. package/dist/cache/entities/AccountEntity.js +1 -1
  23. package/dist/cache/entities/AppMetadataEntity.js +1 -1
  24. package/dist/cache/entities/AuthorityMetadataEntity.js +1 -1
  25. package/dist/cache/entities/CacheRecord.js +1 -1
  26. package/dist/cache/entities/CredentialEntity.d.ts +12 -2
  27. package/dist/cache/entities/CredentialEntity.d.ts.map +1 -1
  28. package/dist/cache/entities/CredentialEntity.js +25 -10
  29. package/dist/cache/entities/CredentialEntity.js.map +1 -1
  30. package/dist/cache/entities/IdTokenEntity.js +1 -1
  31. package/dist/cache/entities/RefreshTokenEntity.js +1 -1
  32. package/dist/cache/entities/ServerTelemetryEntity.js +1 -1
  33. package/dist/cache/entities/ThrottlingEntity.js +1 -1
  34. package/dist/cache/persistence/TokenCacheContext.js +1 -1
  35. package/dist/cache/utils/CacheTypes.d.ts +1 -0
  36. package/dist/cache/utils/CacheTypes.d.ts.map +1 -1
  37. package/dist/client/AuthorizationCodeClient.js +2 -2
  38. package/dist/client/AuthorizationCodeClient.js.map +1 -1
  39. package/dist/client/BaseClient.js +1 -1
  40. package/dist/client/ClientCredentialClient.js +2 -2
  41. package/dist/client/ClientCredentialClient.js.map +1 -1
  42. package/dist/client/DeviceCodeClient.js +3 -3
  43. package/dist/client/DeviceCodeClient.js.map +1 -1
  44. package/dist/client/OnBehalfOfClient.js +2 -2
  45. package/dist/client/OnBehalfOfClient.js.map +1 -1
  46. package/dist/client/RefreshTokenClient.js +2 -2
  47. package/dist/client/RefreshTokenClient.js.map +1 -1
  48. package/dist/client/SilentFlowClient.d.ts.map +1 -1
  49. package/dist/client/SilentFlowClient.js +4 -13
  50. package/dist/client/SilentFlowClient.js.map +1 -1
  51. package/dist/client/UsernamePasswordClient.js +2 -2
  52. package/dist/client/UsernamePasswordClient.js.map +1 -1
  53. package/dist/config/ClientConfiguration.js +1 -1
  54. package/dist/crypto/ICrypto.d.ts +5 -0
  55. package/dist/crypto/ICrypto.d.ts.map +1 -1
  56. package/dist/crypto/ICrypto.js +10 -1
  57. package/dist/crypto/ICrypto.js.map +1 -1
  58. package/dist/crypto/PopTokenGenerator.js +1 -1
  59. package/dist/error/AuthError.js +1 -1
  60. package/dist/error/ClientAuthError.js +1 -1
  61. package/dist/error/ClientConfigurationError.js +1 -1
  62. package/dist/error/InteractionRequiredAuthError.js +1 -1
  63. package/dist/error/ServerError.js +1 -1
  64. package/dist/index.cjs.js +97 -63
  65. package/dist/index.cjs.js.map +1 -1
  66. package/dist/index.js +1 -1
  67. package/dist/logger/Logger.js +1 -1
  68. package/dist/network/INetworkModule.js +1 -1
  69. package/dist/network/NetworkManager.js +1 -1
  70. package/dist/network/RequestThumbprint.d.ts +1 -1
  71. package/dist/network/RequestThumbprint.d.ts.map +1 -1
  72. package/dist/network/ThrottlingUtils.js +2 -2
  73. package/dist/network/ThrottlingUtils.js.map +1 -1
  74. package/dist/packageMetadata.d.ts +1 -1
  75. package/dist/packageMetadata.js +2 -2
  76. package/dist/packageMetadata.js.map +1 -1
  77. package/dist/request/AuthenticationHeaderParser.js +1 -1
  78. package/dist/request/BaseAuthRequest.d.ts +2 -0
  79. package/dist/request/BaseAuthRequest.d.ts.map +1 -1
  80. package/dist/request/RequestParameterBuilder.js +1 -1
  81. package/dist/request/RequestValidator.js +1 -1
  82. package/dist/request/ScopeSet.js +1 -1
  83. package/dist/response/ResponseHandler.d.ts.map +1 -1
  84. package/dist/response/ResponseHandler.js +5 -5
  85. package/dist/response/ResponseHandler.js.map +1 -1
  86. package/dist/telemetry/server/ServerTelemetryManager.js +1 -1
  87. package/dist/url/UrlString.js +1 -1
  88. package/dist/utils/Constants.js +1 -1
  89. package/dist/utils/ProtocolUtils.js +1 -1
  90. package/dist/utils/StringUtils.js +1 -1
  91. package/dist/utils/TimeUtils.js +1 -1
  92. package/package.json +1 -1
package/dist/index.cjs.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! @azure/msal-common v5.2.0 2021-12-07 */
1
+ /*! @azure/msal-common v6.0.0 2022-01-04 */
2
2
  'use strict';
3
3
  'use strict';
4
4
 
@@ -560,6 +560,15 @@ var DEFAULT_CRYPTO_IMPLEMENTATION = {
560
560
  throw AuthError.createUnexpectedError(notImplErr);
561
561
  });
562
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
+ });
563
572
  }
564
573
  };
565
574
 
@@ -1326,7 +1335,7 @@ var Logger = /** @class */ (function () {
1326
1335
 
1327
1336
  /* eslint-disable header/header */
1328
1337
  var name = "@azure/msal-common";
1329
- var version = "5.2.0";
1338
+ var version = "6.0.0";
1330
1339
 
1331
1340
  /*
1332
1341
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1337,7 +1346,7 @@ var version = "5.2.0";
1337
1346
  *
1338
1347
  * Key:Value Schema:
1339
1348
  *
1340
- * 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*>
1341
1350
  *
1342
1351
  * Value Schema:
1343
1352
  * {
@@ -1351,6 +1360,7 @@ var version = "5.2.0";
1351
1360
  * target: Permissions that are included in the token, or for refresh tokens, the resource identifier.
1352
1361
  * oboAssertion: access token passed in as part of OBO request
1353
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
1354
1364
  * }
1355
1365
  */
1356
1366
  var CredentialEntity = /** @class */ (function () {
@@ -1378,7 +1388,7 @@ var CredentialEntity = /** @class */ (function () {
1378
1388
  * generates credential key
1379
1389
  */
1380
1390
  CredentialEntity.prototype.generateCredentialKey = function () {
1381
- 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);
1382
1392
  };
1383
1393
  /**
1384
1394
  * returns the type of the cache (in this case credential)
@@ -1422,16 +1432,14 @@ var CredentialEntity = /** @class */ (function () {
1422
1432
  * generates credential key
1423
1433
  * <home_account_id*>-\<environment>-<credential_type>-<client_id>-<realm\*>-<target\*>-<scheme\*>
1424
1434
  */
1425
- CredentialEntity.generateCredentialCacheKey = function (homeAccountId, environment, credentialType, clientId, realm, target, familyId, tokenType) {
1435
+ CredentialEntity.generateCredentialCacheKey = function (homeAccountId, environment, credentialType, clientId, realm, target, familyId, tokenType, requestedClaimsHash) {
1426
1436
  var credentialKey = [
1427
1437
  this.generateAccountIdForCacheKey(homeAccountId, environment),
1428
1438
  this.generateCredentialIdForCacheKey(credentialType, clientId, realm, familyId),
1429
- this.generateTargetForCacheKey(target)
1439
+ this.generateTargetForCacheKey(target),
1440
+ this.generateClaimsHashForCacheKey(requestedClaimsHash),
1441
+ this.generateSchemeForCacheKey(tokenType)
1430
1442
  ];
1431
- // PoP Tokens and SSH certs include scheme in cache key
1432
- if (tokenType && tokenType !== exports.AuthenticationScheme.BEARER) {
1433
- credentialKey.push(tokenType.toLowerCase());
1434
- }
1435
1443
  return credentialKey.join(Separators.CACHE_KEY_SEPARATOR).toLowerCase();
1436
1444
  };
1437
1445
  /**
@@ -1467,6 +1475,22 @@ var CredentialEntity = /** @class */ (function () {
1467
1475
  CredentialEntity.generateTargetForCacheKey = function (scopes) {
1468
1476
  return (scopes || "").toLowerCase();
1469
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
+ };
1470
1494
  return CredentialEntity;
1471
1495
  }());
1472
1496
 
@@ -2300,7 +2324,8 @@ var CacheManager = /** @class */ (function () {
2300
2324
  environment: credential.environment,
2301
2325
  homeAccountId: credential.homeAccountId,
2302
2326
  realm: credential.realm,
2303
- tokenType: credential.tokenType
2327
+ tokenType: credential.tokenType,
2328
+ requestedClaimsHash: credential.requestedClaimsHash
2304
2329
  });
2305
2330
  currentScopes = ScopeSet.fromString(credential.target);
2306
2331
  currentAccessTokens = Object.keys(currentTokenCache.accessTokens).map(function (key) { return currentTokenCache.accessTokens[key]; });
@@ -2372,7 +2397,7 @@ var CacheManager = /** @class */ (function () {
2372
2397
  * @param target
2373
2398
  */
2374
2399
  CacheManager.prototype.getCredentialsFilteredBy = function (filter) {
2375
- return this.getCredentialsFilteredByInternal(filter.homeAccountId, filter.environment, filter.credentialType, filter.clientId, filter.familyId, filter.realm, filter.target, filter.oboAssertion, filter.tokenType, filter.keyId);
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);
2376
2401
  };
2377
2402
  /**
2378
2403
  * Support function to help match credentials
@@ -2385,7 +2410,7 @@ var CacheManager = /** @class */ (function () {
2385
2410
  * @param oboAssertion
2386
2411
  * @param tokenType
2387
2412
  */
2388
- CacheManager.prototype.getCredentialsFilteredByInternal = function (homeAccountId, environment, credentialType, clientId, familyId, realm, target, oboAssertion, tokenType, keyId) {
2413
+ CacheManager.prototype.getCredentialsFilteredByInternal = function (homeAccountId, environment, credentialType, clientId, familyId, realm, target, oboAssertion, tokenType, keyId, requestedClaimsHash) {
2389
2414
  var _this = this;
2390
2415
  var allCacheKeys = this.getKeys();
2391
2416
  var matchingCredentials = {
@@ -2432,38 +2457,37 @@ var CacheManager = /** @class */ (function () {
2432
2457
  if (!!target && !_this.matchTarget(entity, target)) {
2433
2458
  return;
2434
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
+ }
2435
2467
  // Access Token with Auth Scheme specific matching
2436
2468
  if (credentialType === exports.CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME) {
2437
2469
  if (!!tokenType && !_this.matchTokenType(entity, tokenType)) {
2438
2470
  return;
2439
2471
  }
2440
- switch (tokenType) {
2441
- case exports.AuthenticationScheme.POP:
2442
- // This check avoids matching outdated POP tokens that don't have the <-scheme> in the cache key
2443
- if (cacheKey.indexOf(exports.AuthenticationScheme.POP) === -1) {
2444
- // AccessToken_With_AuthScheme that doesn't have "-pop" in the key is outdated and needs to be removed
2445
- _this.removeItem(cacheKey, exports.CacheSchemaType.CREDENTIAL);
2446
- return;
2447
- }
2448
- break;
2449
- case exports.AuthenticationScheme.SSH:
2450
- // KeyId (sshKid) in request must match cached SSH certificate keyId because SSH cert is bound to a specific key
2451
- if (keyId && !_this.matchKeyId(entity, keyId)) {
2452
- return;
2453
- }
2454
- break;
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
+ }
2455
2477
  }
2456
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);
2457
2481
  switch (credType) {
2458
2482
  case exports.CredentialType.ID_TOKEN:
2459
- matchingCredentials.idTokens[cacheKey] = entity;
2483
+ matchingCredentials.idTokens[updatedCacheKey] = entity;
2460
2484
  break;
2461
2485
  case exports.CredentialType.ACCESS_TOKEN:
2462
2486
  case exports.CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME:
2463
- matchingCredentials.accessTokens[cacheKey] = entity;
2487
+ matchingCredentials.accessTokens[updatedCacheKey] = entity;
2464
2488
  break;
2465
2489
  case exports.CredentialType.REFRESH_TOKEN:
2466
- matchingCredentials.refreshTokens[cacheKey] = entity;
2490
+ matchingCredentials.refreshTokens[updatedCacheKey] = entity;
2467
2491
  break;
2468
2492
  }
2469
2493
  });
@@ -2662,10 +2686,10 @@ var CacheManager = /** @class */ (function () {
2662
2686
  * @param environment
2663
2687
  * @param authScheme
2664
2688
  */
2665
- CacheManager.prototype.readCacheRecord = function (account, clientId, scopes, environment, authScheme, keyId) {
2689
+ CacheManager.prototype.readCacheRecord = function (account, clientId, request, environment) {
2666
2690
  var cachedAccount = this.readAccountFromCache(account);
2667
2691
  var cachedIdToken = this.readIdTokenFromCache(clientId, account);
2668
- var cachedAccessToken = this.readAccessTokenFromCache(clientId, account, scopes, authScheme, keyId);
2692
+ var cachedAccessToken = this.readAccessTokenFromCache(clientId, account, request);
2669
2693
  var cachedRefreshToken = this.readRefreshTokenFromCache(clientId, account, false);
2670
2694
  var cachedAppMetadata = this.readAppMetadataFromCache(environment, clientId);
2671
2695
  if (cachedAccount && cachedIdToken) {
@@ -2719,9 +2743,14 @@ var CacheManager = /** @class */ (function () {
2719
2743
  * @param scopes
2720
2744
  * @param authScheme
2721
2745
  */
2722
- CacheManager.prototype.readAccessTokenFromCache = function (clientId, account, scopes, authScheme, keyId) {
2723
- // Distinguish between Bearer and PoP/SSH token cache types
2724
- var credentialType = (authScheme && authScheme !== exports.AuthenticationScheme.BEARER) ? exports.CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME : exports.CredentialType.ACCESS_TOKEN;
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;
2725
2754
  var accessTokenFilter = {
2726
2755
  homeAccountId: account.homeAccountId,
2727
2756
  environment: account.environment,
@@ -2730,7 +2759,8 @@ var CacheManager = /** @class */ (function () {
2730
2759
  realm: account.tenantId,
2731
2760
  target: scopes.printScopesLowerCase(),
2732
2761
  tokenType: authScheme,
2733
- keyId: keyId
2762
+ keyId: request.sshKid,
2763
+ requestedClaimsHash: request.requestedClaimsHash
2734
2764
  };
2735
2765
  var credentialCache = this.getCredentialsFilteredBy(accessTokenFilter);
2736
2766
  var accessTokens = Object.keys(credentialCache.accessTokens).map(function (key) { return credentialCache.accessTokens[key]; });
@@ -3039,6 +3069,10 @@ var DefaultStorageClass = /** @class */ (function (_super) {
3039
3069
  });
3040
3070
  });
3041
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
+ };
3042
3076
  return DefaultStorageClass;
3043
3077
  }(CacheManager));
3044
3078
 
@@ -3221,11 +3255,11 @@ var ThrottlingUtils = /** @class */ (function () {
3221
3255
  authority: request.authority,
3222
3256
  scopes: request.scopes,
3223
3257
  homeAccountIdentifier: homeAccountIdentifier,
3258
+ claims: request.claims,
3224
3259
  authenticationScheme: request.authenticationScheme,
3225
3260
  resourceRequestMethod: request.resourceRequestMethod,
3226
3261
  resourceRequestUri: request.resourceRequestUri,
3227
3262
  shrClaims: request.shrClaims,
3228
- sshJwk: request.sshJwk,
3229
3263
  sshKid: request.sshKid
3230
3264
  };
3231
3265
  var key = this.generateThrottlingStorageKey(thumbprint);
@@ -3956,8 +3990,8 @@ var AccessTokenEntity = /** @class */ (function (_super) {
3956
3990
  * @param expiresOn
3957
3991
  * @param extExpiresOn
3958
3992
  */
3959
- AccessTokenEntity.createAccessTokenEntity = function (homeAccountId, environment, accessToken, clientId, tenantId, scopes, expiresOn, extExpiresOn, cryptoUtils, refreshOn, tokenType, oboAssertion, keyId) {
3960
- 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;
3961
3995
  var atEntity = new AccessTokenEntity();
3962
3996
  atEntity.homeAccountId = homeAccountId;
3963
3997
  atEntity.credentialType = exports.CredentialType.ACCESS_TOKEN;
@@ -3979,14 +4013,21 @@ var AccessTokenEntity = /** @class */ (function (_super) {
3979
4013
  atEntity.target = scopes;
3980
4014
  atEntity.oboAssertion = oboAssertion;
3981
4015
  atEntity.tokenType = StringUtils.isEmpty(tokenType) ? exports.AuthenticationScheme.BEARER : tokenType;
3982
- // Create Access Token With Auth Scheme instead of regular access token
3983
- if (atEntity.tokenType !== exports.AuthenticationScheme.BEARER) {
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()) {
3984
4025
  atEntity.credentialType = exports.CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME;
3985
4026
  switch (atEntity.tokenType) {
3986
4027
  case exports.AuthenticationScheme.POP:
3987
4028
  // Make sure keyId is present and add it to credential
3988
4029
  var tokenClaims = AuthToken.extractTokenClaims(accessToken, cryptoUtils);
3989
- if (!((_a = tokenClaims === null || tokenClaims === void 0 ? void 0 : tokenClaims.cnf) === null || _a === void 0 ? void 0 : _a.kid)) {
4030
+ if (!((_b = tokenClaims === null || tokenClaims === void 0 ? void 0 : tokenClaims.cnf) === null || _b === void 0 ? void 0 : _b.kid)) {
3990
4031
  throw ClientAuthError.createTokenClaimsRequiredError();
3991
4032
  }
3992
4033
  atEntity.keyId = tokenClaims.cnf.kid;
@@ -4684,7 +4725,7 @@ var ResponseHandler = /** @class */ (function () {
4684
4725
  }
4685
4726
  // Add keyId from request to serverTokenResponse if defined
4686
4727
  serverTokenResponse.key_id = serverTokenResponse.key_id || request.sshKid || undefined;
4687
- cacheRecord = this.generateCacheRecord(serverTokenResponse, authority, reqTimestamp, idTokenObj, request.scopes, oboAssertion, authCodePayload);
4728
+ cacheRecord = this.generateCacheRecord(serverTokenResponse, authority, reqTimestamp, request, idTokenObj, oboAssertion, authCodePayload);
4688
4729
  _a.label = 1;
4689
4730
  case 1:
4690
4731
  _a.trys.push([1, , 5, 8]);
@@ -4732,7 +4773,7 @@ var ResponseHandler = /** @class */ (function () {
4732
4773
  * @param idTokenObj
4733
4774
  * @param authority
4734
4775
  */
4735
- ResponseHandler.prototype.generateCacheRecord = function (serverTokenResponse, authority, reqTimestamp, idTokenObj, requestScopes, oboAssertion, authCodePayload) {
4776
+ ResponseHandler.prototype.generateCacheRecord = function (serverTokenResponse, authority, reqTimestamp, request, idTokenObj, oboAssertion, authCodePayload) {
4736
4777
  var env = authority.getPreferredCache();
4737
4778
  if (StringUtils.isEmpty(env)) {
4738
4779
  throw ClientAuthError.createInvalidCacheEnvironmentError();
@@ -4748,7 +4789,7 @@ var ResponseHandler = /** @class */ (function () {
4748
4789
  var cachedAccessToken = null;
4749
4790
  if (!StringUtils.isEmpty(serverTokenResponse.access_token)) {
4750
4791
  // If scopes not returned in server response, use request scopes
4751
- var responseScopes = serverTokenResponse.scope ? ScopeSet.fromString(serverTokenResponse.scope) : new ScopeSet(requestScopes || []);
4792
+ var responseScopes = serverTokenResponse.scope ? ScopeSet.fromString(serverTokenResponse.scope) : new ScopeSet(request.scopes || []);
4752
4793
  /*
4753
4794
  * Use timestamp calculated before request
4754
4795
  * Server may return timestamps as strings, parse to numbers if so.
@@ -4760,7 +4801,7 @@ var ResponseHandler = /** @class */ (function () {
4760
4801
  var extendedTokenExpirationSeconds = tokenExpirationSeconds + extExpiresIn;
4761
4802
  var refreshOnSeconds = refreshIn && refreshIn > 0 ? reqTimestamp + refreshIn : undefined;
4762
4803
  // non AAD scenarios can have empty realm
4763
- 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);
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);
4764
4805
  }
4765
4806
  // refreshToken
4766
4807
  var cachedRefreshToken = null;
@@ -4979,11 +5020,11 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
4979
5020
  clientId: this.config.authOptions.clientId,
4980
5021
  authority: authority.canonicalAuthority,
4981
5022
  scopes: request.scopes,
5023
+ claims: request.claims,
4982
5024
  authenticationScheme: request.authenticationScheme,
4983
5025
  resourceRequestMethod: request.resourceRequestMethod,
4984
5026
  resourceRequestUri: request.resourceRequestUri,
4985
5027
  shrClaims: request.shrClaims,
4986
- sshJwk: request.sshJwk,
4987
5028
  sshKid: request.sshKid
4988
5029
  };
4989
5030
  return [4 /*yield*/, this.createTokenRequestBody(request)];
@@ -5325,11 +5366,11 @@ var DeviceCodeClient = /** @class */ (function (_super) {
5325
5366
  clientId: this.config.authOptions.clientId,
5326
5367
  authority: request.authority,
5327
5368
  scopes: request.scopes,
5369
+ claims: request.claims,
5328
5370
  authenticationScheme: request.authenticationScheme,
5329
5371
  resourceRequestMethod: request.resourceRequestMethod,
5330
5372
  resourceRequestUri: request.resourceRequestUri,
5331
5373
  shrClaims: request.shrClaims,
5332
- sshJwk: request.sshJwk,
5333
5374
  sshKid: request.sshKid
5334
5375
  };
5335
5376
  return [2 /*return*/, this.executePostRequestToDeviceCodeEndpoint(this.authority.deviceCodeEndpoint, queryString, headers, thumbprint)];
@@ -5424,11 +5465,11 @@ var DeviceCodeClient = /** @class */ (function (_super) {
5424
5465
  clientId: this.config.authOptions.clientId,
5425
5466
  authority: request.authority,
5426
5467
  scopes: request.scopes,
5468
+ claims: request.claims,
5427
5469
  authenticationScheme: request.authenticationScheme,
5428
5470
  resourceRequestMethod: request.resourceRequestMethod,
5429
5471
  resourceRequestUri: request.resourceRequestUri,
5430
5472
  shrClaims: request.shrClaims,
5431
- sshJwk: request.sshJwk,
5432
5473
  sshKid: request.sshKid
5433
5474
  };
5434
5475
  return [4 /*yield*/, this.executePostToTokenEndpoint(this.authority.tokenEndpoint, requestBody, headers, thumbprint)];
@@ -5592,11 +5633,11 @@ var RefreshTokenClient = /** @class */ (function (_super) {
5592
5633
  clientId: this.config.authOptions.clientId,
5593
5634
  authority: authority.canonicalAuthority,
5594
5635
  scopes: request.scopes,
5636
+ claims: request.claims,
5595
5637
  authenticationScheme: request.authenticationScheme,
5596
5638
  resourceRequestMethod: request.resourceRequestMethod,
5597
5639
  resourceRequestUri: request.resourceRequestUri,
5598
5640
  shrClaims: request.shrClaims,
5599
- sshJwk: request.sshJwk,
5600
5641
  sshKid: request.sshKid
5601
5642
  };
5602
5643
  endpoint = UrlString.appendQueryString(authority.tokenEndpoint, queryParameters);
@@ -5800,11 +5841,11 @@ var ClientCredentialClient = /** @class */ (function (_super) {
5800
5841
  clientId: this.config.authOptions.clientId,
5801
5842
  authority: request.authority,
5802
5843
  scopes: request.scopes,
5844
+ claims: request.claims,
5803
5845
  authenticationScheme: request.authenticationScheme,
5804
5846
  resourceRequestMethod: request.resourceRequestMethod,
5805
5847
  resourceRequestUri: request.resourceRequestUri,
5806
5848
  shrClaims: request.shrClaims,
5807
- sshJwk: request.sshJwk,
5808
5849
  sshKid: request.sshKid
5809
5850
  };
5810
5851
  reqTimestamp = TimeUtils.nowSeconds();
@@ -6001,11 +6042,11 @@ var OnBehalfOfClient = /** @class */ (function (_super) {
6001
6042
  clientId: this.config.authOptions.clientId,
6002
6043
  authority: request.authority,
6003
6044
  scopes: request.scopes,
6045
+ claims: request.claims,
6004
6046
  authenticationScheme: request.authenticationScheme,
6005
6047
  resourceRequestMethod: request.resourceRequestMethod,
6006
6048
  resourceRequestUri: request.resourceRequestUri,
6007
6049
  shrClaims: request.shrClaims,
6008
- sshJwk: request.sshJwk,
6009
6050
  sshKid: request.sshKid
6010
6051
  };
6011
6052
  reqTimestamp = TimeUtils.nowSeconds();
@@ -6098,7 +6139,7 @@ var SilentFlowClient = /** @class */ (function (_super) {
6098
6139
  SilentFlowClient.prototype.acquireCachedToken = function (request) {
6099
6140
  var _a, _b, _c, _d;
6100
6141
  return __awaiter(this, void 0, void 0, function () {
6101
- var requestScopes, environment, authScheme, cacheRecord;
6142
+ var environment, cacheRecord;
6102
6143
  return __generator(this, function (_e) {
6103
6144
  switch (_e.label) {
6104
6145
  case 0:
@@ -6112,19 +6153,12 @@ var SilentFlowClient = /** @class */ (function (_super) {
6112
6153
  this.logger.info("SilentFlowClient:acquireCachedToken - Skipping cache because forceRefresh is true.");
6113
6154
  throw ClientAuthError.createRefreshRequiredError();
6114
6155
  }
6115
- else if (!StringUtils.isEmptyObj(request.claims)) {
6116
- // Must refresh due to request parameters.
6117
- this.logger.info("SilentFlowClient:acquireCachedToken - Skipping cache because claims are requested.");
6118
- throw ClientAuthError.createRefreshRequiredError();
6119
- }
6120
6156
  // We currently do not support silent flow for account === null use cases; This will be revisited for confidential flow usecases
6121
6157
  if (!request.account) {
6122
6158
  throw ClientAuthError.createNoAccountInSilentRequestError();
6123
6159
  }
6124
- requestScopes = new ScopeSet(request.scopes || []);
6125
6160
  environment = request.authority || this.authority.getPreferredCache();
6126
- authScheme = request.authenticationScheme || exports.AuthenticationScheme.BEARER;
6127
- cacheRecord = this.cacheManager.readCacheRecord(request.account, this.config.authOptions.clientId, requestScopes, environment, authScheme, request.sshKid);
6161
+ cacheRecord = this.cacheManager.readCacheRecord(request.account, this.config.authOptions.clientId, request, environment);
6128
6162
  if (!cacheRecord.accessToken) {
6129
6163
  // Must refresh due to non-existent access_token.
6130
6164
  (_b = this.serverTelemetryManager) === null || _b === void 0 ? void 0 : _b.setCacheOutcome(CacheOutcome.NO_CACHED_ACCESS_TOKEN);
@@ -6226,11 +6260,11 @@ var UsernamePasswordClient = /** @class */ (function (_super) {
6226
6260
  clientId: this.config.authOptions.clientId,
6227
6261
  authority: authority.canonicalAuthority,
6228
6262
  scopes: request.scopes,
6263
+ claims: request.claims,
6229
6264
  authenticationScheme: request.authenticationScheme,
6230
6265
  resourceRequestMethod: request.resourceRequestMethod,
6231
6266
  resourceRequestUri: request.resourceRequestUri,
6232
6267
  shrClaims: request.shrClaims,
6233
- sshJwk: request.sshJwk,
6234
6268
  sshKid: request.sshKid
6235
6269
  };
6236
6270
  requestBody = this.createTokenRequestBody(request);