@azure/msal-common 14.7.0 → 14.7.2-alpha.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 (96) hide show
  1. package/dist/account/AccountInfo.d.ts +1 -1
  2. package/dist/account/AccountInfo.d.ts.map +1 -1
  3. package/dist/account/AccountInfo.mjs +3 -2
  4. package/dist/account/AccountInfo.mjs.map +1 -1
  5. package/dist/account/AuthToken.mjs +1 -1
  6. package/dist/account/CcsCredential.mjs +1 -1
  7. package/dist/account/ClientInfo.mjs +1 -1
  8. package/dist/account/TokenClaims.mjs +1 -1
  9. package/dist/authority/Authority.d.ts +3 -2
  10. package/dist/authority/Authority.d.ts.map +1 -1
  11. package/dist/authority/Authority.mjs +11 -5
  12. package/dist/authority/Authority.mjs.map +1 -1
  13. package/dist/authority/AuthorityFactory.mjs +1 -1
  14. package/dist/authority/AuthorityMetadata.mjs +1 -1
  15. package/dist/authority/AuthorityOptions.mjs +1 -1
  16. package/dist/authority/AuthorityType.mjs +1 -1
  17. package/dist/authority/CloudInstanceDiscoveryErrorResponse.mjs +1 -1
  18. package/dist/authority/CloudInstanceDiscoveryResponse.mjs +1 -1
  19. package/dist/authority/OpenIdConfigResponse.mjs +1 -1
  20. package/dist/authority/ProtocolMode.mjs +1 -1
  21. package/dist/authority/RegionDiscovery.mjs +1 -1
  22. package/dist/cache/CacheManager.d.ts +0 -12
  23. package/dist/cache/CacheManager.d.ts.map +1 -1
  24. package/dist/cache/CacheManager.mjs +6 -15
  25. package/dist/cache/CacheManager.mjs.map +1 -1
  26. package/dist/cache/entities/AccountEntity.mjs +1 -1
  27. package/dist/cache/entities/CacheRecord.mjs +1 -1
  28. package/dist/cache/persistence/TokenCacheContext.mjs +1 -1
  29. package/dist/cache/utils/CacheHelpers.mjs +1 -1
  30. package/dist/client/AuthorizationCodeClient.mjs +1 -1
  31. package/dist/client/BaseClient.mjs +1 -1
  32. package/dist/client/RefreshTokenClient.mjs +1 -1
  33. package/dist/client/SilentFlowClient.d.ts.map +1 -1
  34. package/dist/client/SilentFlowClient.mjs +8 -3
  35. package/dist/client/SilentFlowClient.mjs.map +1 -1
  36. package/dist/config/ClientConfiguration.d.ts.map +1 -1
  37. package/dist/config/ClientConfiguration.mjs +2 -4
  38. package/dist/config/ClientConfiguration.mjs.map +1 -1
  39. package/dist/constants/AADServerParamKeys.mjs +1 -1
  40. package/dist/crypto/ICrypto.mjs +1 -1
  41. package/dist/crypto/JoseHeader.mjs +1 -1
  42. package/dist/crypto/PopTokenGenerator.mjs +1 -1
  43. package/dist/error/AuthError.mjs +1 -1
  44. package/dist/error/AuthErrorCodes.mjs +1 -1
  45. package/dist/error/ClientAuthError.mjs +1 -1
  46. package/dist/error/ClientAuthErrorCodes.mjs +1 -1
  47. package/dist/error/ClientConfigurationError.mjs +1 -1
  48. package/dist/error/ClientConfigurationErrorCodes.mjs +1 -1
  49. package/dist/error/InteractionRequiredAuthError.mjs +1 -1
  50. package/dist/error/InteractionRequiredAuthErrorCodes.mjs +1 -1
  51. package/dist/error/JoseHeaderError.mjs +1 -1
  52. package/dist/error/JoseHeaderErrorCodes.mjs +1 -1
  53. package/dist/error/ServerError.mjs +1 -1
  54. package/dist/index.cjs +38 -25
  55. package/dist/index.cjs.map +1 -1
  56. package/dist/index.d.ts +1 -1
  57. package/dist/index.d.ts.map +1 -1
  58. package/dist/index.mjs +2 -2
  59. package/dist/logger/Logger.mjs +1 -1
  60. package/dist/network/INetworkModule.mjs +1 -1
  61. package/dist/network/NetworkManager.mjs +1 -1
  62. package/dist/network/ThrottlingUtils.mjs +1 -1
  63. package/dist/packageMetadata.d.ts +1 -1
  64. package/dist/packageMetadata.d.ts.map +1 -1
  65. package/dist/packageMetadata.mjs +2 -2
  66. package/dist/request/AuthenticationHeaderParser.mjs +1 -1
  67. package/dist/request/RequestParameterBuilder.mjs +1 -1
  68. package/dist/request/RequestValidator.mjs +1 -1
  69. package/dist/request/ScopeSet.mjs +1 -1
  70. package/dist/response/ResponseHandler.d.ts.map +1 -1
  71. package/dist/response/ResponseHandler.mjs +2 -2
  72. package/dist/response/ResponseHandler.mjs.map +1 -1
  73. package/dist/telemetry/performance/PerformanceClient.mjs +1 -1
  74. package/dist/telemetry/performance/PerformanceEvent.mjs +1 -1
  75. package/dist/telemetry/performance/StubPerformanceClient.mjs +1 -1
  76. package/dist/telemetry/server/ServerTelemetryManager.mjs +1 -1
  77. package/dist/url/UrlString.mjs +1 -1
  78. package/dist/utils/Constants.d.ts +10 -0
  79. package/dist/utils/Constants.d.ts.map +1 -1
  80. package/dist/utils/Constants.mjs +13 -2
  81. package/dist/utils/Constants.mjs.map +1 -1
  82. package/dist/utils/FunctionWrappers.mjs +1 -1
  83. package/dist/utils/ProtocolUtils.mjs +1 -1
  84. package/dist/utils/StringUtils.mjs +1 -1
  85. package/dist/utils/TimeUtils.mjs +1 -1
  86. package/dist/utils/UrlUtils.mjs +1 -1
  87. package/package.json +1 -1
  88. package/src/account/AccountInfo.ts +3 -1
  89. package/src/authority/Authority.ts +12 -4
  90. package/src/cache/CacheManager.ts +10 -27
  91. package/src/client/SilentFlowClient.ts +7 -4
  92. package/src/config/ClientConfiguration.ts +4 -4
  93. package/src/index.ts +1 -0
  94. package/src/packageMetadata.ts +1 -1
  95. package/src/response/ResponseHandler.ts +2 -1
  96. package/src/utils/Constants.ts +12 -0
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- /*! @azure/msal-common v14.7.0 2024-02-07 */
1
+ /*! @azure/msal-common v14.7.2-alpha.0 2024-03-04 */
2
2
  'use strict';
3
3
  'use strict';
4
4
 
@@ -66,11 +66,20 @@ const Constants = {
66
66
  };
67
67
  const HttpStatus = {
68
68
  SUCCESS_RANGE_START: 200,
69
+ SUCCESS: 200,
69
70
  SUCCESS_RANGE_END: 299,
70
71
  REDIRECT: 302,
71
72
  CLIENT_ERROR_RANGE_START: 400,
73
+ BAD_REQUEST: 400,
74
+ UNAUTHORIZED: 401,
75
+ NOT_FOUND: 404,
76
+ REQUEST_TIMEOUT: 408,
77
+ TOO_MANY_REQUESTS: 429,
72
78
  CLIENT_ERROR_RANGE_END: 499,
73
79
  SERVER_ERROR_RANGE_START: 500,
80
+ INTERNAL_SERVER_ERROR: 500,
81
+ SERVICE_UNAVAILABLE: 503,
82
+ GATEWAY_TIMEOUT: 504,
74
83
  SERVER_ERROR_RANGE_END: 599,
75
84
  };
76
85
  const OIDC_DEFAULT_SCOPES = [
@@ -310,6 +319,8 @@ const JsonWebTokenTypes = {
310
319
  Pop: "pop",
311
320
  };
312
321
  const ONE_DAY_IN_MS = 86400000;
322
+ // Token renewal offset default in seconds
323
+ const DEFAULT_TOKEN_RENEWAL_OFFSET_SEC = 300;
313
324
 
314
325
  /*
315
326
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -943,7 +954,7 @@ class Logger {
943
954
 
944
955
  /* eslint-disable header/header */
945
956
  const name = "@azure/msal-common";
946
- const version = "14.7.0";
957
+ const version = "14.7.2-alpha.0";
947
958
 
948
959
  /*
949
960
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1986,7 +1997,7 @@ function buildTenantProfileFromIdTokenClaims(homeAccountId, idTokenClaims) {
1986
1997
  * @param idTokenClaims
1987
1998
  * @returns
1988
1999
  */
1989
- function updateAccountTenantProfileData(baseAccountInfo, tenantProfile, idTokenClaims) {
2000
+ function updateAccountTenantProfileData(baseAccountInfo, tenantProfile, idTokenClaims, idTokenSecret) {
1990
2001
  let updatedAccountInfo = baseAccountInfo;
1991
2002
  // Tenant Profile overrides passed in account info
1992
2003
  if (tenantProfile) {
@@ -2003,6 +2014,7 @@ function updateAccountTenantProfileData(baseAccountInfo, tenantProfile, idTokenC
2003
2014
  ...updatedAccountInfo,
2004
2015
  ...claimsSourcedTenantProfile,
2005
2016
  idTokenClaims: idTokenClaims,
2017
+ idToken: idTokenSecret,
2006
2018
  };
2007
2019
  return updatedAccountInfo;
2008
2020
  }
@@ -2741,7 +2753,7 @@ class CacheManager {
2741
2753
  }
2742
2754
  }
2743
2755
  // Expand tenant profile into account info based on matching tenant profile and if available matching ID token claims
2744
- tenantedAccountInfo = updateAccountTenantProfileData(accountInfo, tenantProfile, idTokenClaims);
2756
+ tenantedAccountInfo = updateAccountTenantProfileData(accountInfo, tenantProfile, idTokenClaims, idToken?.secret);
2745
2757
  return tenantedAccountInfo;
2746
2758
  }
2747
2759
  getTenantProfilesFromAccountEntity(accountEntity, targetTenantId, tenantProfileFilter) {
@@ -3057,14 +3069,6 @@ class CacheManager {
3057
3069
  * @param filter
3058
3070
  */
3059
3071
  getAppMetadataFilteredBy(filter) {
3060
- return this.getAppMetadataFilteredByInternal(filter.environment, filter.clientId);
3061
- }
3062
- /**
3063
- * Support function to help match appMetadata
3064
- * @param environment
3065
- * @param clientId
3066
- */
3067
- getAppMetadataFilteredByInternal(environment, clientId) {
3068
3072
  const allCacheKeys = this.getKeys();
3069
3073
  const matchingAppMetadata = {};
3070
3074
  allCacheKeys.forEach((cacheKey) => {
@@ -3077,10 +3081,12 @@ class CacheManager {
3077
3081
  if (!entity) {
3078
3082
  return;
3079
3083
  }
3080
- if (!!environment && !this.matchEnvironment(entity, environment)) {
3084
+ if (!!filter.environment &&
3085
+ !this.matchEnvironment(entity, filter.environment)) {
3081
3086
  return;
3082
3087
  }
3083
- if (!!clientId && !this.matchClientId(entity, clientId)) {
3088
+ if (!!filter.clientId &&
3089
+ !this.matchClientId(entity, filter.clientId)) {
3084
3090
  return;
3085
3091
  }
3086
3092
  matchingAppMetadata[cacheKey] = entity;
@@ -3867,9 +3873,6 @@ class DefaultStorageClass extends CacheManager {
3867
3873
  removeItem() {
3868
3874
  throw createClientAuthError(methodNotImplemented);
3869
3875
  }
3870
- containsKey() {
3871
- throw createClientAuthError(methodNotImplemented);
3872
- }
3873
3876
  getKeys() {
3874
3877
  throw createClientAuthError(methodNotImplemented);
3875
3878
  }
@@ -3894,8 +3897,6 @@ class DefaultStorageClass extends CacheManager {
3894
3897
  * Copyright (c) Microsoft Corporation. All rights reserved.
3895
3898
  * Licensed under the MIT License.
3896
3899
  */
3897
- // Token renewal offset default in seconds
3898
- const DEFAULT_TOKEN_RENEWAL_OFFSET_SEC = 300;
3899
3900
  const DEFAULT_SYSTEM_OPTIONS = {
3900
3901
  tokenRenewalOffsetSeconds: DEFAULT_TOKEN_RENEWAL_OFFSET_SEC,
3901
3902
  preventCorsPreflight: false,
@@ -5221,7 +5222,7 @@ RegionDiscovery.IMDS_OPTIONS = {
5221
5222
  * @internal
5222
5223
  */
5223
5224
  class Authority {
5224
- constructor(authority, networkInterface, cacheManager, authorityOptions, logger, correlationId, performanceClient) {
5225
+ constructor(authority, networkInterface, cacheManager, authorityOptions, logger, correlationId, performanceClient, managedIdentity) {
5225
5226
  this.canonicalAuthority = authority;
5226
5227
  this._canonicalAuthority.validateAsUri();
5227
5228
  this.networkInterface = networkInterface;
@@ -5235,6 +5236,7 @@ class Authority {
5235
5236
  this.logger = logger;
5236
5237
  this.performanceClient = performanceClient;
5237
5238
  this.correlationId = correlationId;
5239
+ this.managedIdentity = managedIdentity || false;
5238
5240
  this.regionDiscovery = new RegionDiscovery(networkInterface, this.logger, this.performanceClient, this.correlationId);
5239
5241
  }
5240
5242
  /**
@@ -5440,7 +5442,7 @@ class Authority {
5440
5442
  return `${this.canonicalAuthority}v2.0/.well-known/openid-configuration`;
5441
5443
  }
5442
5444
  /**
5443
- * Boolean that returns whethr or not tenant discovery has been completed.
5445
+ * Boolean that returns whether or not tenant discovery has been completed.
5444
5446
  */
5445
5447
  discoveryComplete() {
5446
5448
  return !!this.metadata;
@@ -5892,7 +5894,10 @@ class Authority {
5892
5894
  * helper function to generate environment from authority object
5893
5895
  */
5894
5896
  getPreferredCache() {
5895
- if (this.discoveryComplete()) {
5897
+ if (this.managedIdentity) {
5898
+ return Constants.DEFAULT_AUTHORITY_HOST;
5899
+ }
5900
+ else if (this.discoveryComplete()) {
5896
5901
  return this.metadata.preferred_cache;
5897
5902
  }
5898
5903
  else {
@@ -6006,8 +6011,10 @@ function getTenantFromAuthorityString(authority) {
6006
6011
  * AAD Authority - domain/tenantId -> Credentials are cached with realm = tenantId
6007
6012
  * B2C Authority - domain/{tenantId}?/.../policy -> Credentials are cached with realm = policy
6008
6013
  * tenantId is downcased because B2C policies can have mixed case but tfp claim is downcased
6014
+ *
6015
+ * Note that we may not have any path segments in certain OIDC scenarios.
6009
6016
  */
6010
- const tenantId = authorityUrlComponents.PathSegments.slice(-1)[0].toLowerCase();
6017
+ const tenantId = authorityUrlComponents.PathSegments.slice(-1)[0]?.toLowerCase();
6011
6018
  switch (tenantId) {
6012
6019
  case AADAuthorityConstants.COMMON:
6013
6020
  case AADAuthorityConstants.ORGANIZATIONS:
@@ -6769,7 +6776,7 @@ class ResponseHandler {
6769
6776
  }
6770
6777
  const accountInfo = cacheRecord.account
6771
6778
  ? updateAccountTenantProfileData(cacheRecord.account.getAccountInfo(), undefined, // tenantProfile optional
6772
- idTokenClaims)
6779
+ idTokenClaims, cacheRecord.idToken?.secret)
6773
6780
  : null;
6774
6781
  return {
6775
6782
  authority: authority.canonicalAuthority,
@@ -7456,7 +7463,12 @@ class SilentFlowClient extends BaseClient {
7456
7463
  */
7457
7464
  async acquireToken(request) {
7458
7465
  try {
7459
- const [authResponse, cacheOutcome] = await this.acquireCachedToken(request);
7466
+ const [authResponse, cacheOutcome] = await this.acquireCachedToken({
7467
+ ...request,
7468
+ scopes: request.scopes?.length
7469
+ ? request.scopes
7470
+ : [...OIDC_DEFAULT_SCOPES],
7471
+ });
7460
7472
  // if the token is not expired but must be refreshed; get a new one in the background
7461
7473
  if (cacheOutcome === CacheOutcome.PROACTIVELY_REFRESHED) {
7462
7474
  this.logger.info("SilentFlowClient:acquireCachedToken - Cached access token's refreshOn property has been exceeded'. It's not expired, but must be refreshed.");
@@ -8432,6 +8444,7 @@ exports.Constants = Constants;
8432
8444
  exports.CredentialType = CredentialType;
8433
8445
  exports.DEFAULT_CRYPTO_IMPLEMENTATION = DEFAULT_CRYPTO_IMPLEMENTATION;
8434
8446
  exports.DEFAULT_SYSTEM_OPTIONS = DEFAULT_SYSTEM_OPTIONS;
8447
+ exports.DEFAULT_TOKEN_RENEWAL_OFFSET_SEC = DEFAULT_TOKEN_RENEWAL_OFFSET_SEC;
8435
8448
  exports.DefaultStorageClass = DefaultStorageClass;
8436
8449
  exports.Errors = Errors;
8437
8450
  exports.GrantType = GrantType;