@azure/msal-common 15.8.1 → 15.10.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 (174) hide show
  1. package/dist/account/AccountInfo.d.ts +2 -1
  2. package/dist/account/AccountInfo.d.ts.map +1 -1
  3. package/dist/account/AccountInfo.mjs +5 -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.mjs +1 -1
  10. package/dist/authority/AuthorityFactory.mjs +1 -1
  11. package/dist/authority/AuthorityMetadata.mjs +1 -1
  12. package/dist/authority/AuthorityOptions.mjs +1 -1
  13. package/dist/authority/AuthorityType.mjs +1 -1
  14. package/dist/authority/CloudInstanceDiscoveryErrorResponse.mjs +1 -1
  15. package/dist/authority/CloudInstanceDiscoveryResponse.mjs +1 -1
  16. package/dist/authority/OpenIdConfigResponse.mjs +1 -1
  17. package/dist/authority/ProtocolMode.mjs +1 -1
  18. package/dist/authority/RegionDiscovery.mjs +1 -1
  19. package/dist/cache/CacheManager.d.ts +15 -20
  20. package/dist/cache/CacheManager.d.ts.map +1 -1
  21. package/dist/cache/CacheManager.mjs +32 -97
  22. package/dist/cache/CacheManager.mjs.map +1 -1
  23. package/dist/cache/entities/AccountEntity.d.ts +2 -14
  24. package/dist/cache/entities/AccountEntity.d.ts.map +1 -1
  25. package/dist/cache/entities/AccountEntity.mjs +6 -34
  26. package/dist/cache/entities/AccountEntity.mjs.map +1 -1
  27. package/dist/cache/entities/CredentialEntity.d.ts +1 -1
  28. package/dist/cache/entities/CredentialEntity.d.ts.map +1 -1
  29. package/dist/cache/interface/ICacheManager.d.ts +2 -10
  30. package/dist/cache/interface/ICacheManager.d.ts.map +1 -1
  31. package/dist/cache/persistence/TokenCacheContext.mjs +1 -1
  32. package/dist/cache/utils/CacheHelpers.d.ts +4 -13
  33. package/dist/cache/utils/CacheHelpers.d.ts.map +1 -1
  34. package/dist/cache/utils/CacheHelpers.mjs +6 -71
  35. package/dist/cache/utils/CacheHelpers.mjs.map +1 -1
  36. package/dist/client/AuthorizationCodeClient.mjs +1 -1
  37. package/dist/client/BaseClient.mjs +1 -1
  38. package/dist/client/RefreshTokenClient.d.ts.map +1 -1
  39. package/dist/client/RefreshTokenClient.mjs +2 -3
  40. package/dist/client/RefreshTokenClient.mjs.map +1 -1
  41. package/dist/client/SilentFlowClient.mjs +2 -2
  42. package/dist/client/SilentFlowClient.mjs.map +1 -1
  43. package/dist/config/ClientConfiguration.mjs +1 -1
  44. package/dist/constants/AADServerParamKeys.mjs +1 -1
  45. package/dist/crypto/ICrypto.mjs +1 -1
  46. package/dist/crypto/JoseHeader.mjs +1 -1
  47. package/dist/crypto/PopTokenGenerator.mjs +1 -1
  48. package/dist/error/AuthError.mjs +1 -1
  49. package/dist/error/AuthErrorCodes.mjs +1 -1
  50. package/dist/error/CacheError.mjs +1 -1
  51. package/dist/error/CacheErrorCodes.mjs +1 -1
  52. package/dist/error/ClientAuthError.mjs +1 -1
  53. package/dist/error/ClientAuthErrorCodes.mjs +1 -1
  54. package/dist/error/ClientConfigurationError.d.ts +10 -0
  55. package/dist/error/ClientConfigurationError.d.ts.map +1 -1
  56. package/dist/error/ClientConfigurationError.mjs +12 -2
  57. package/dist/error/ClientConfigurationError.mjs.map +1 -1
  58. package/dist/error/ClientConfigurationErrorCodes.d.ts +2 -0
  59. package/dist/error/ClientConfigurationErrorCodes.d.ts.map +1 -1
  60. package/dist/error/ClientConfigurationErrorCodes.mjs +5 -3
  61. package/dist/error/ClientConfigurationErrorCodes.mjs.map +1 -1
  62. package/dist/error/InteractionRequiredAuthError.mjs +1 -1
  63. package/dist/error/InteractionRequiredAuthErrorCodes.mjs +1 -1
  64. package/dist/error/JoseHeaderError.mjs +1 -1
  65. package/dist/error/JoseHeaderErrorCodes.mjs +1 -1
  66. package/dist/error/NetworkError.mjs +1 -1
  67. package/dist/error/ServerError.mjs +1 -1
  68. package/dist/exports-common.d.ts +1 -1
  69. package/dist/exports-common.d.ts.map +1 -1
  70. package/dist/index-browser.mjs +2 -2
  71. package/dist/index-node.mjs +2 -2
  72. package/dist/index.mjs +2 -2
  73. package/dist/logger/Logger.mjs +1 -1
  74. package/dist/network/INetworkModule.mjs +1 -1
  75. package/dist/network/RequestThumbprint.mjs +1 -1
  76. package/dist/network/ThrottlingUtils.mjs +1 -1
  77. package/dist/packageMetadata.d.ts +1 -1
  78. package/dist/packageMetadata.d.ts.map +1 -1
  79. package/dist/packageMetadata.mjs +2 -2
  80. package/dist/protocol/Authorize.mjs +2 -2
  81. package/dist/protocol/Authorize.mjs.map +1 -1
  82. package/dist/request/AuthenticationHeaderParser.mjs +1 -1
  83. package/dist/request/BaseAuthRequest.d.ts +5 -1
  84. package/dist/request/BaseAuthRequest.d.ts.map +1 -1
  85. package/dist/request/RequestParameterBuilder.d.ts +6 -0
  86. package/dist/request/RequestParameterBuilder.d.ts.map +1 -1
  87. package/dist/request/RequestParameterBuilder.mjs +14 -2
  88. package/dist/request/RequestParameterBuilder.mjs.map +1 -1
  89. package/dist/request/ScopeSet.mjs +1 -1
  90. package/dist/response/ResponseHandler.d.ts.map +1 -1
  91. package/dist/response/ResponseHandler.mjs +3 -3
  92. package/dist/response/ResponseHandler.mjs.map +1 -1
  93. package/dist/telemetry/performance/PerformanceClient.mjs +1 -1
  94. package/dist/telemetry/performance/PerformanceEvent.d.ts +2 -0
  95. package/dist/telemetry/performance/PerformanceEvent.d.ts.map +1 -1
  96. package/dist/telemetry/performance/PerformanceEvent.mjs +11 -1
  97. package/dist/telemetry/performance/PerformanceEvent.mjs.map +1 -1
  98. package/dist/telemetry/performance/StubPerformanceClient.mjs +1 -1
  99. package/dist/telemetry/server/ServerTelemetryManager.mjs +1 -1
  100. package/dist/url/UrlString.mjs +1 -1
  101. package/dist/utils/ClientAssertionUtils.mjs +1 -1
  102. package/dist/utils/Constants.d.ts +5 -1
  103. package/dist/utils/Constants.d.ts.map +1 -1
  104. package/dist/utils/Constants.mjs +6 -4
  105. package/dist/utils/Constants.mjs.map +1 -1
  106. package/dist/utils/FunctionWrappers.mjs +1 -1
  107. package/dist/utils/ProtocolUtils.mjs +1 -1
  108. package/dist/utils/StringUtils.mjs +1 -1
  109. package/dist/utils/TimeUtils.d.ts +7 -0
  110. package/dist/utils/TimeUtils.d.ts.map +1 -1
  111. package/dist/utils/TimeUtils.mjs +12 -2
  112. package/dist/utils/TimeUtils.mjs.map +1 -1
  113. package/dist/utils/UrlUtils.mjs +1 -1
  114. package/lib/index-browser.cjs +3 -2
  115. package/lib/index-browser.cjs.map +1 -1
  116. package/lib/{index-node-BCM1mkg5.js → index-node-Dy4fVJGl.js} +496 -599
  117. package/lib/index-node-Dy4fVJGl.js.map +1 -0
  118. package/lib/index-node.cjs +3 -2
  119. package/lib/index-node.cjs.map +1 -1
  120. package/lib/index.cjs +3 -2
  121. package/lib/index.cjs.map +1 -1
  122. package/lib/types/account/AccountInfo.d.ts +2 -1
  123. package/lib/types/account/AccountInfo.d.ts.map +1 -1
  124. package/lib/types/cache/CacheManager.d.ts +15 -20
  125. package/lib/types/cache/CacheManager.d.ts.map +1 -1
  126. package/lib/types/cache/entities/AccountEntity.d.ts +2 -14
  127. package/lib/types/cache/entities/AccountEntity.d.ts.map +1 -1
  128. package/lib/types/cache/entities/CredentialEntity.d.ts +1 -1
  129. package/lib/types/cache/entities/CredentialEntity.d.ts.map +1 -1
  130. package/lib/types/cache/interface/ICacheManager.d.ts +2 -10
  131. package/lib/types/cache/interface/ICacheManager.d.ts.map +1 -1
  132. package/lib/types/cache/utils/CacheHelpers.d.ts +4 -13
  133. package/lib/types/cache/utils/CacheHelpers.d.ts.map +1 -1
  134. package/lib/types/client/RefreshTokenClient.d.ts.map +1 -1
  135. package/lib/types/error/ClientConfigurationError.d.ts +10 -0
  136. package/lib/types/error/ClientConfigurationError.d.ts.map +1 -1
  137. package/lib/types/error/ClientConfigurationErrorCodes.d.ts +2 -0
  138. package/lib/types/error/ClientConfigurationErrorCodes.d.ts.map +1 -1
  139. package/lib/types/exports-common.d.ts +1 -1
  140. package/lib/types/exports-common.d.ts.map +1 -1
  141. package/lib/types/packageMetadata.d.ts +1 -1
  142. package/lib/types/packageMetadata.d.ts.map +1 -1
  143. package/lib/types/request/BaseAuthRequest.d.ts +5 -1
  144. package/lib/types/request/BaseAuthRequest.d.ts.map +1 -1
  145. package/lib/types/request/RequestParameterBuilder.d.ts +6 -0
  146. package/lib/types/request/RequestParameterBuilder.d.ts.map +1 -1
  147. package/lib/types/response/ResponseHandler.d.ts.map +1 -1
  148. package/lib/types/telemetry/performance/PerformanceEvent.d.ts +2 -0
  149. package/lib/types/telemetry/performance/PerformanceEvent.d.ts.map +1 -1
  150. package/lib/types/utils/Constants.d.ts +5 -1
  151. package/lib/types/utils/Constants.d.ts.map +1 -1
  152. package/lib/types/utils/TimeUtils.d.ts +7 -0
  153. package/lib/types/utils/TimeUtils.d.ts.map +1 -1
  154. package/package.json +1 -1
  155. package/src/account/AccountInfo.ts +16 -2
  156. package/src/cache/CacheManager.ts +50 -125
  157. package/src/cache/entities/AccountEntity.ts +7 -38
  158. package/src/cache/entities/CredentialEntity.ts +1 -1
  159. package/src/cache/interface/ICacheManager.ts +2 -15
  160. package/src/cache/utils/CacheHelpers.ts +11 -83
  161. package/src/client/RefreshTokenClient.ts +1 -2
  162. package/src/client/SilentFlowClient.ts +2 -2
  163. package/src/error/ClientConfigurationError.ts +16 -0
  164. package/src/error/ClientConfigurationErrorCodes.ts +3 -0
  165. package/src/exports-common.ts +1 -0
  166. package/src/packageMetadata.ts +1 -1
  167. package/src/protocol/Authorize.ts +1 -1
  168. package/src/request/BaseAuthRequest.ts +5 -1
  169. package/src/request/RequestParameterBuilder.ts +16 -0
  170. package/src/response/ResponseHandler.ts +3 -1
  171. package/src/telemetry/performance/PerformanceEvent.ts +14 -0
  172. package/src/utils/Constants.ts +6 -2
  173. package/src/utils/TimeUtils.ts +15 -0
  174. package/lib/index-node-BCM1mkg5.js.map +0 -1
@@ -411,5 +411,5 @@ function extractAccountSid(account: AccountInfo): string | null {
411
411
  }
412
412
 
413
413
  function extractLoginHint(account: AccountInfo): string | null {
414
- return account.idTokenClaims?.login_hint || null;
414
+ return account.loginHint || account.idTokenClaims?.login_hint || null;
415
415
  }
@@ -3,7 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { AuthenticationScheme } from "../utils/Constants.js";
6
+ import { AuthenticationScheme, HttpMethod } from "../utils/Constants.js";
7
7
  import type { AzureCloudOptions } from "../config/ClientConfiguration.js";
8
8
  import { StringDict } from "../utils/MsalTypes.js";
9
9
  import { StoreInCache } from "./StoreInCache.js";
@@ -31,6 +31,8 @@ import { ShrOptions } from "../crypto/SignedHttpRequest.js";
31
31
  * - scenarioId - Scenario id to track custom user prompts
32
32
  * - popKid - Key ID to identify the public key for PoP token request
33
33
  * - embeddedClientId - Embedded client id. When specified, broker client id (brk_client_id) and redirect uri (brk_redirect_uri) params are set with values from the config, overriding the corresponding extra parameters, if present.
34
+ * - httpMethod - HTTP method to use for the /authorize request. Defaults to GET, but can be set to POST if the request requires body parameters
35
+ * - authorizePostBodyParameters - String to string map of custom parameters added to the body of the /authorize call when httpMethod is set to POST
34
36
  */
35
37
  export type BaseAuthRequest = {
36
38
  authority: string;
@@ -54,4 +56,6 @@ export type BaseAuthRequest = {
54
56
  scenarioId?: string;
55
57
  popKid?: string;
56
58
  embeddedClientId?: string;
59
+ httpMethod?: HttpMethod;
60
+ authorizePostBodyParameters?: StringDict;
57
61
  };
@@ -632,3 +632,19 @@ export function addEARParameters(
632
632
  const jweCryptoB64Encoded = "eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2R0NNIn0";
633
633
  parameters.set(AADServerParamKeys.EAR_JWE_CRYPTO, jweCryptoB64Encoded);
634
634
  }
635
+
636
+ /**
637
+ * Adds authorize body parameters to the request parameters
638
+ * @param parameters
639
+ * @param bodyParameters
640
+ */
641
+ export function addPostBodyParameters(
642
+ parameters: Map<string, string>,
643
+ bodyParameters: StringDict
644
+ ): void {
645
+ Object.entries(bodyParameters).forEach(([key, value]) => {
646
+ if (value) {
647
+ parameters.set(key, value);
648
+ }
649
+ });
650
+ }
@@ -278,7 +278,9 @@ export class ResponseHandler {
278
278
  !forceCacheRefreshTokenResponse &&
279
279
  cacheRecord.account
280
280
  ) {
281
- const key = cacheRecord.account.generateAccountKey();
281
+ const key = this.cacheStorage.generateAccountKey(
282
+ cacheRecord.account.getAccountInfo()
283
+ );
282
284
  const account = this.cacheStorage.getAccount(
283
285
  key,
284
286
  request.correlationId
@@ -859,6 +859,10 @@ export type PerformanceEvent = {
859
859
  // Event context as JSON string
860
860
  context?: string;
861
861
 
862
+ // Cache Data
863
+ cacheLocation?: string;
864
+ cacheRetentionDays?: number;
865
+
862
866
  // Number of tokens in the cache to be reported when cache quota is exceeded
863
867
  cacheRtCount?: number;
864
868
  cacheIdCount?: number;
@@ -927,4 +931,14 @@ export const IntFields: ReadonlySet<string> = new Set([
927
931
  "multiMatchedRT",
928
932
  "unencryptedCacheCount",
929
933
  "encryptedCacheExpiredCount",
934
+ "oldAccountCount",
935
+ "oldAccessCount",
936
+ "oldIdCount",
937
+ "oldRefreshCount",
938
+ "currAccountCount",
939
+ "currAccessCount",
940
+ "currIdCount",
941
+ "currRefreshCount",
942
+ "expiredCacheRemovedCount",
943
+ "upgradedCacheCount",
930
944
  ]);
@@ -6,8 +6,6 @@
6
6
  export const Constants = {
7
7
  LIBRARY_NAME: "MSAL.JS",
8
8
  SKU: "msal.js.common",
9
- // Prefix for all library cache entries
10
- CACHE_PREFIX: "msal",
11
9
  // default authority
12
10
  DEFAULT_AUTHORITY: "https://login.microsoftonline.com/common/",
13
11
  DEFAULT_AUTHORITY_HOST: "login.microsoftonline.com",
@@ -82,6 +80,12 @@ export const HttpStatus = {
82
80
  } as const;
83
81
  export type HttpStatus = (typeof HttpStatus)[keyof typeof HttpStatus];
84
82
 
83
+ export const HttpMethod = {
84
+ GET: "GET",
85
+ POST: "POST",
86
+ } as const;
87
+ export type HttpMethod = (typeof HttpMethod)[keyof typeof HttpMethod];
88
+
85
89
  export const OIDC_DEFAULT_SCOPES = [
86
90
  Constants.OPENID_SCOPE,
87
91
  Constants.PROFILE_SCOPE,
@@ -48,6 +48,21 @@ export function isTokenExpired(expiresOn: string, offset: number): boolean {
48
48
  return offsetCurrentTimeSec > expirationSec;
49
49
  }
50
50
 
51
+ /**
52
+ * Checks if a cache entry is expired based on the last updated time and cache retention days.
53
+ * @param lastUpdatedAt
54
+ * @param cacheRetentionDays
55
+ * @returns
56
+ */
57
+ export function isCacheExpired(
58
+ lastUpdatedAt: string,
59
+ cacheRetentionDays: number
60
+ ): boolean {
61
+ const cacheExpirationTimestamp =
62
+ Number(lastUpdatedAt) + cacheRetentionDays * 24 * 60 * 60 * 1000;
63
+ return Date.now() > cacheExpirationTimestamp;
64
+ }
65
+
51
66
  /**
52
67
  * If the current time is earlier than the time that a token was cached at, we must discard the token
53
68
  * i.e. The system clock was turned back after acquiring the cached token