@azure/msal-common 15.7.0 → 15.8.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 (176) hide show
  1. package/dist/account/AccountInfo.d.ts +1 -0
  2. package/dist/account/AccountInfo.d.ts.map +1 -1
  3. package/dist/account/AccountInfo.mjs +1 -1
  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 -2
  12. package/dist/authority/AuthorityMetadata.mjs.map +1 -1
  13. package/dist/authority/AuthorityOptions.mjs +1 -1
  14. package/dist/authority/AuthorityType.mjs +1 -1
  15. package/dist/authority/CloudInstanceDiscoveryErrorResponse.mjs +1 -1
  16. package/dist/authority/CloudInstanceDiscoveryResponse.mjs +1 -1
  17. package/dist/authority/OpenIdConfigResponse.mjs +1 -1
  18. package/dist/authority/ProtocolMode.mjs +1 -1
  19. package/dist/authority/RegionDiscovery.mjs +1 -1
  20. package/dist/cache/CacheManager.d.ts +32 -30
  21. package/dist/cache/CacheManager.d.ts.map +1 -1
  22. package/dist/cache/CacheManager.mjs +83 -101
  23. package/dist/cache/CacheManager.mjs.map +1 -1
  24. package/dist/cache/entities/AccountEntity.d.ts +1 -0
  25. package/dist/cache/entities/AccountEntity.d.ts.map +1 -1
  26. package/dist/cache/entities/AccountEntity.mjs +1 -1
  27. package/dist/cache/entities/AccountEntity.mjs.map +1 -1
  28. package/dist/cache/entities/CredentialEntity.d.ts +2 -0
  29. package/dist/cache/entities/CredentialEntity.d.ts.map +1 -1
  30. package/dist/cache/interface/ICacheManager.d.ts +16 -16
  31. package/dist/cache/interface/ICacheManager.d.ts.map +1 -1
  32. package/dist/cache/persistence/TokenCacheContext.mjs +1 -1
  33. package/dist/cache/utils/CacheHelpers.mjs +1 -1
  34. package/dist/client/AuthorizationCodeClient.mjs +3 -3
  35. package/dist/client/BaseClient.d.ts.map +1 -1
  36. package/dist/client/BaseClient.mjs +4 -4
  37. package/dist/client/BaseClient.mjs.map +1 -1
  38. package/dist/client/RefreshTokenClient.d.ts.map +1 -1
  39. package/dist/client/RefreshTokenClient.mjs +5 -5
  40. package/dist/client/RefreshTokenClient.mjs.map +1 -1
  41. package/dist/client/SilentFlowClient.d.ts.map +1 -1
  42. package/dist/client/SilentFlowClient.mjs +4 -4
  43. package/dist/client/SilentFlowClient.mjs.map +1 -1
  44. package/dist/config/ClientConfiguration.d.ts.map +1 -1
  45. package/dist/config/ClientConfiguration.mjs +4 -3
  46. package/dist/config/ClientConfiguration.mjs.map +1 -1
  47. package/dist/constants/AADServerParamKeys.mjs +1 -1
  48. package/dist/crypto/ICrypto.d.ts +1 -1
  49. package/dist/crypto/ICrypto.d.ts.map +1 -1
  50. package/dist/crypto/ICrypto.mjs +1 -1
  51. package/dist/crypto/JoseHeader.mjs +1 -1
  52. package/dist/crypto/PopTokenGenerator.mjs +2 -4
  53. package/dist/crypto/PopTokenGenerator.mjs.map +1 -1
  54. package/dist/error/AuthError.mjs +2 -2
  55. package/dist/error/AuthErrorCodes.mjs +1 -1
  56. package/dist/error/CacheError.d.ts +8 -1
  57. package/dist/error/CacheError.d.ts.map +1 -1
  58. package/dist/error/CacheError.mjs +26 -7
  59. package/dist/error/CacheError.mjs.map +1 -1
  60. package/dist/error/CacheErrorCodes.d.ts +2 -2
  61. package/dist/error/CacheErrorCodes.d.ts.map +1 -1
  62. package/dist/error/CacheErrorCodes.mjs +4 -4
  63. package/dist/error/CacheErrorCodes.mjs.map +1 -1
  64. package/dist/error/ClientAuthError.mjs +2 -2
  65. package/dist/error/ClientAuthErrorCodes.mjs +1 -1
  66. package/dist/error/ClientConfigurationError.mjs +2 -2
  67. package/dist/error/ClientConfigurationErrorCodes.mjs +1 -1
  68. package/dist/error/InteractionRequiredAuthError.d.ts.map +1 -1
  69. package/dist/error/InteractionRequiredAuthError.mjs +4 -2
  70. package/dist/error/InteractionRequiredAuthError.mjs.map +1 -1
  71. package/dist/error/InteractionRequiredAuthErrorCodes.d.ts +1 -0
  72. package/dist/error/InteractionRequiredAuthErrorCodes.d.ts.map +1 -1
  73. package/dist/error/InteractionRequiredAuthErrorCodes.mjs +3 -2
  74. package/dist/error/InteractionRequiredAuthErrorCodes.mjs.map +1 -1
  75. package/dist/error/JoseHeaderError.mjs +2 -2
  76. package/dist/error/JoseHeaderErrorCodes.mjs +1 -1
  77. package/dist/error/NetworkError.mjs +1 -1
  78. package/dist/error/ServerError.mjs +1 -1
  79. package/dist/exports-common.d.ts +1 -1
  80. package/dist/exports-common.d.ts.map +1 -1
  81. package/dist/index-browser.mjs +2 -2
  82. package/dist/index-node.mjs +2 -2
  83. package/dist/index.mjs +2 -2
  84. package/dist/logger/Logger.mjs +1 -1
  85. package/dist/network/INetworkModule.mjs +1 -1
  86. package/dist/network/RequestThumbprint.mjs +1 -1
  87. package/dist/network/ThrottlingUtils.d.ts +2 -2
  88. package/dist/network/ThrottlingUtils.d.ts.map +1 -1
  89. package/dist/network/ThrottlingUtils.mjs +6 -6
  90. package/dist/network/ThrottlingUtils.mjs.map +1 -1
  91. package/dist/packageMetadata.d.ts +1 -1
  92. package/dist/packageMetadata.mjs +2 -2
  93. package/dist/protocol/Authorize.mjs +2 -2
  94. package/dist/request/AuthenticationHeaderParser.mjs +1 -1
  95. package/dist/request/RequestParameterBuilder.mjs +2 -2
  96. package/dist/request/RequestValidator.mjs +1 -1
  97. package/dist/request/ScopeSet.mjs +1 -1
  98. package/dist/response/ResponseHandler.d.ts +1 -1
  99. package/dist/response/ResponseHandler.d.ts.map +1 -1
  100. package/dist/response/ResponseHandler.mjs +6 -6
  101. package/dist/response/ResponseHandler.mjs.map +1 -1
  102. package/dist/telemetry/performance/PerformanceClient.mjs +1 -1
  103. package/dist/telemetry/performance/PerformanceEvent.mjs +1 -1
  104. package/dist/telemetry/performance/StubPerformanceClient.mjs +1 -1
  105. package/dist/telemetry/server/ServerTelemetryManager.d.ts.map +1 -1
  106. package/dist/telemetry/server/ServerTelemetryManager.mjs +7 -7
  107. package/dist/telemetry/server/ServerTelemetryManager.mjs.map +1 -1
  108. package/dist/url/UrlString.mjs +1 -1
  109. package/dist/utils/ClientAssertionUtils.mjs +1 -1
  110. package/dist/utils/Constants.mjs +1 -4
  111. package/dist/utils/Constants.mjs.map +1 -1
  112. package/dist/utils/FunctionWrappers.mjs +1 -1
  113. package/dist/utils/ProtocolUtils.mjs +1 -1
  114. package/dist/utils/StringUtils.mjs +1 -1
  115. package/dist/utils/TimeUtils.mjs +1 -1
  116. package/dist/utils/UrlUtils.mjs +1 -1
  117. package/lib/index-browser.cjs +5 -81
  118. package/lib/index-browser.cjs.map +1 -1
  119. package/lib/{index-node-DNGOJ4N7.js → index-node-2PsHlOld.js} +217 -139
  120. package/lib/index-node-2PsHlOld.js.map +1 -0
  121. package/lib/index-node.cjs +3 -2
  122. package/lib/index-node.cjs.map +1 -1
  123. package/lib/index.cjs +4 -3
  124. package/lib/index.cjs.map +1 -1
  125. package/lib/types/account/AccountInfo.d.ts +1 -0
  126. package/lib/types/account/AccountInfo.d.ts.map +1 -1
  127. package/lib/types/cache/CacheManager.d.ts +32 -30
  128. package/lib/types/cache/CacheManager.d.ts.map +1 -1
  129. package/lib/types/cache/entities/AccountEntity.d.ts +1 -0
  130. package/lib/types/cache/entities/AccountEntity.d.ts.map +1 -1
  131. package/lib/types/cache/entities/CredentialEntity.d.ts +2 -0
  132. package/lib/types/cache/entities/CredentialEntity.d.ts.map +1 -1
  133. package/lib/types/cache/interface/ICacheManager.d.ts +16 -16
  134. package/lib/types/cache/interface/ICacheManager.d.ts.map +1 -1
  135. package/lib/types/client/BaseClient.d.ts.map +1 -1
  136. package/lib/types/client/RefreshTokenClient.d.ts.map +1 -1
  137. package/lib/types/client/SilentFlowClient.d.ts.map +1 -1
  138. package/lib/types/config/ClientConfiguration.d.ts.map +1 -1
  139. package/lib/types/crypto/ICrypto.d.ts +1 -1
  140. package/lib/types/crypto/ICrypto.d.ts.map +1 -1
  141. package/lib/types/error/CacheError.d.ts +8 -1
  142. package/lib/types/error/CacheError.d.ts.map +1 -1
  143. package/lib/types/error/CacheErrorCodes.d.ts +2 -2
  144. package/lib/types/error/CacheErrorCodes.d.ts.map +1 -1
  145. package/lib/types/error/InteractionRequiredAuthError.d.ts.map +1 -1
  146. package/lib/types/error/InteractionRequiredAuthErrorCodes.d.ts +1 -0
  147. package/lib/types/error/InteractionRequiredAuthErrorCodes.d.ts.map +1 -1
  148. package/lib/types/exports-common.d.ts +1 -1
  149. package/lib/types/exports-common.d.ts.map +1 -1
  150. package/lib/types/network/ThrottlingUtils.d.ts +2 -2
  151. package/lib/types/network/ThrottlingUtils.d.ts.map +1 -1
  152. package/lib/types/packageMetadata.d.ts +1 -1
  153. package/lib/types/response/ResponseHandler.d.ts +1 -1
  154. package/lib/types/response/ResponseHandler.d.ts.map +1 -1
  155. package/lib/types/telemetry/server/ServerTelemetryManager.d.ts.map +1 -1
  156. package/package.json +1 -1
  157. package/src/account/AccountInfo.ts +1 -0
  158. package/src/cache/CacheManager.ts +159 -123
  159. package/src/cache/entities/AccountEntity.ts +1 -0
  160. package/src/cache/entities/CredentialEntity.ts +2 -0
  161. package/src/cache/interface/ICacheManager.ts +34 -16
  162. package/src/client/BaseClient.ts +11 -2
  163. package/src/client/RefreshTokenClient.ts +6 -3
  164. package/src/client/SilentFlowClient.ts +7 -6
  165. package/src/config/ClientConfiguration.ts +3 -1
  166. package/src/crypto/ICrypto.ts +2 -2
  167. package/src/error/CacheError.ts +26 -5
  168. package/src/error/CacheErrorCodes.ts +2 -2
  169. package/src/error/InteractionRequiredAuthError.ts +3 -0
  170. package/src/error/InteractionRequiredAuthErrorCodes.ts +1 -0
  171. package/src/exports-common.ts +5 -1
  172. package/src/network/ThrottlingUtils.ts +8 -5
  173. package/src/packageMetadata.ts +1 -1
  174. package/src/response/ResponseHandler.ts +7 -2
  175. package/src/telemetry/server/ServerTelemetryManager.ts +14 -6
  176. package/lib/index-node-DNGOJ4N7.js.map +0 -1
@@ -21,7 +21,7 @@ export interface ICacheManager {
21
21
  * fetch the account entity from the platform cache
22
22
  * @param accountKey
23
23
  */
24
- getAccount(accountKey: string): AccountEntity | null;
24
+ getAccount(accountKey: string, correlationId: string): AccountEntity | null;
25
25
 
26
26
  /**
27
27
  * set account entity in the platform cache
@@ -46,7 +46,10 @@ export interface ICacheManager {
46
46
  * fetch the idToken entity from the platform cache
47
47
  * @param idTokenKey
48
48
  */
49
- getIdTokenCredential(idTokenKey: string): IdTokenEntity | null;
49
+ getIdTokenCredential(
50
+ idTokenKey: string,
51
+ correlationId: string
52
+ ): IdTokenEntity | null;
50
53
 
51
54
  /**
52
55
  * set idToken entity to the platform cache
@@ -61,7 +64,10 @@ export interface ICacheManager {
61
64
  * fetch the idToken entity from the platform cache
62
65
  * @param accessTokenKey
63
66
  */
64
- getAccessTokenCredential(accessTokenKey: string): AccessTokenEntity | null;
67
+ getAccessTokenCredential(
68
+ accessTokenKey: string,
69
+ correlationId: string
70
+ ): AccessTokenEntity | null;
65
71
 
66
72
  /**
67
73
  * set idToken entity to the platform cache
@@ -77,7 +83,8 @@ export interface ICacheManager {
77
83
  * @param refreshTokenKey
78
84
  */
79
85
  getRefreshTokenCredential(
80
- refreshTokenKey: string
86
+ refreshTokenKey: string,
87
+ correlationId: string
81
88
  ): RefreshTokenEntity | null;
82
89
 
83
90
  /**
@@ -99,7 +106,7 @@ export interface ICacheManager {
99
106
  * set appMetadata entity to the platform cache
100
107
  * @param appMetadata
101
108
  */
102
- setAppMetadata(appMetadata: AppMetadataEntity): void;
109
+ setAppMetadata(appMetadata: AppMetadataEntity, correlationId: string): void;
103
110
 
104
111
  /**
105
112
  * fetch server telemetry entity from the platform cache
@@ -116,7 +123,8 @@ export interface ICacheManager {
116
123
  */
117
124
  setServerTelemetry(
118
125
  serverTelemetryKey: string,
119
- serverTelemetry: ServerTelemetryEntity
126
+ serverTelemetry: ServerTelemetryEntity,
127
+ correlationId: string
120
128
  ): void;
121
129
 
122
130
  /**
@@ -162,13 +170,17 @@ export interface ICacheManager {
162
170
  */
163
171
  setThrottlingCache(
164
172
  throttlingCacheKey: string,
165
- throttlingCache: ThrottlingEntity
173
+ throttlingCache: ThrottlingEntity,
174
+ correlationId: string
166
175
  ): void;
167
176
 
168
177
  /**
169
178
  * Returns all accounts in cache
170
179
  */
171
- getAllAccounts(): AccountInfo[];
180
+ getAllAccounts(
181
+ accountFilter: AccountFilter,
182
+ correlationId: string
183
+ ): AccountInfo[];
172
184
 
173
185
  /**
174
186
  * saves a cache record
@@ -186,43 +198,49 @@ export interface ICacheManager {
186
198
  * @param environment
187
199
  * @param realm
188
200
  */
189
- getAccountsFilteredBy(filter: AccountFilter): AccountEntity[];
201
+ getAccountsFilteredBy(
202
+ filter: AccountFilter,
203
+ correlationId: string
204
+ ): AccountEntity[];
190
205
 
191
206
  /**
192
207
  * Get AccountInfo object based on provided filters
193
208
  * @param filter
194
209
  */
195
- getAccountInfoFilteredBy(filter: AccountFilter): AccountInfo | null;
210
+ getAccountInfoFilteredBy(
211
+ filter: AccountFilter,
212
+ correlationId: string
213
+ ): AccountInfo | null;
196
214
 
197
215
  /**
198
216
  * Removes all accounts and related tokens from cache.
199
217
  */
200
- removeAllAccounts(): Promise<void>;
218
+ removeAllAccounts(correlationId: string): void;
201
219
 
202
220
  /**
203
221
  * returns a boolean if the given account is removed
204
222
  * @param account
205
223
  */
206
- removeAccount(accountKey: string): Promise<void>;
224
+ removeAccount(accountKey: string, correlationId: string): void;
207
225
 
208
226
  /**
209
227
  * returns a boolean if the given account is removed
210
228
  * @param account
211
229
  */
212
- removeAccountContext(account: AccountEntity): Promise<void>;
230
+ removeAccountContext(account: AccountEntity, correlationId: string): void;
213
231
 
214
232
  /**
215
233
  * @param key
216
234
  */
217
- removeIdToken(key: string): void;
235
+ removeIdToken(key: string, correlationId: string): void;
218
236
 
219
237
  /**
220
238
  * @param key
221
239
  */
222
- removeAccessToken(key: string): Promise<void>;
240
+ removeAccessToken(key: string, correlationId: string): void;
223
241
 
224
242
  /**
225
243
  * @param key
226
244
  */
227
- removeRefreshToken(key: string): void;
245
+ removeRefreshToken(key: string, correlationId: string): void;
228
246
  }
@@ -187,7 +187,11 @@ export abstract class BaseClient {
187
187
  options: NetworkRequestOptions,
188
188
  correlationId: string
189
189
  ): Promise<NetworkResponse<T>> {
190
- ThrottlingUtils.preProcess(this.cacheManager, thumbprint);
190
+ ThrottlingUtils.preProcess(
191
+ this.cacheManager,
192
+ thumbprint,
193
+ correlationId
194
+ );
191
195
 
192
196
  let response;
193
197
  try {
@@ -244,7 +248,12 @@ export abstract class BaseClient {
244
248
  }
245
249
  }
246
250
 
247
- ThrottlingUtils.postProcess(this.cacheManager, thumbprint, response);
251
+ ThrottlingUtils.postProcess(
252
+ this.cacheManager,
253
+ thumbprint,
254
+ response,
255
+ correlationId
256
+ );
248
257
 
249
258
  return response;
250
259
  }
@@ -212,9 +212,9 @@ export class RefreshTokenClient extends BaseClient {
212
212
  )(
213
213
  request.account,
214
214
  foci,
215
+ request.correlationId,
215
216
  undefined,
216
- this.performanceClient,
217
- request.correlationId
217
+ this.performanceClient
218
218
  );
219
219
 
220
220
  if (!refreshToken) {
@@ -274,7 +274,10 @@ export class RefreshTokenClient extends BaseClient {
274
274
  );
275
275
  const badRefreshTokenKey =
276
276
  generateCredentialKey(refreshToken);
277
- this.cacheManager.removeRefreshToken(badRefreshTokenKey);
277
+ this.cacheManager.removeRefreshToken(
278
+ badRefreshTokenKey,
279
+ request.correlationId
280
+ );
278
281
  }
279
282
  }
280
283
 
@@ -75,9 +75,7 @@ export class SilentFlowClient extends BaseClient {
75
75
  request.account,
76
76
  request,
77
77
  tokenKeys,
78
- requestTenantId,
79
- this.performanceClient,
80
- request.correlationId
78
+ requestTenantId
81
79
  );
82
80
 
83
81
  if (!cachedAccessToken) {
@@ -117,14 +115,17 @@ export class SilentFlowClient extends BaseClient {
117
115
  const environment =
118
116
  request.authority || this.authority.getPreferredCache();
119
117
  const cacheRecord: CacheRecord = {
120
- account: this.cacheManager.readAccountFromCache(request.account),
118
+ account: this.cacheManager.readAccountFromCache(
119
+ request.account,
120
+ request.correlationId
121
+ ),
121
122
  accessToken: cachedAccessToken,
122
123
  idToken: this.cacheManager.getIdToken(
123
124
  request.account,
125
+ request.correlationId,
124
126
  tokenKeys,
125
127
  requestTenantId,
126
- this.performanceClient,
127
- request.correlationId
128
+ this.performanceClient
128
129
  ),
129
130
  refreshToken: null,
130
131
  appMetadata:
@@ -23,6 +23,7 @@ import {
23
23
  ClientAuthErrorCodes,
24
24
  createClientAuthError,
25
25
  } from "../error/ClientAuthError.js";
26
+ import { StubPerformanceClient } from "../telemetry/performance/StubPerformanceClient.js";
26
27
 
27
28
  /**
28
29
  * Use the configuration object to configure MSAL Modules and initialize the base interfaces for MSAL.
@@ -260,7 +261,8 @@ export function buildClientConfiguration({
260
261
  new DefaultStorageClass(
261
262
  userAuthOptions.clientId,
262
263
  DEFAULT_CRYPTO_IMPLEMENTATION,
263
- new Logger(loggerOptions)
264
+ new Logger(loggerOptions),
265
+ new StubPerformanceClient()
264
266
  ),
265
267
  networkInterface:
266
268
  networkImplementation || DEFAULT_NETWORK_IMPLEMENTATION,
@@ -70,7 +70,7 @@ export interface ICrypto {
70
70
  * Removes cryptographic keypair from key store matching the keyId passed in
71
71
  * @param kid
72
72
  */
73
- removeTokenBindingKey(kid: string): Promise<boolean>;
73
+ removeTokenBindingKey(kid: string): Promise<void>;
74
74
  /**
75
75
  * Removes all cryptographic keys from IndexedDB storage
76
76
  */
@@ -111,7 +111,7 @@ export const DEFAULT_CRYPTO_IMPLEMENTATION: ICrypto = {
111
111
  async getPublicKeyThumbprint(): Promise<string> {
112
112
  throw createClientAuthError(ClientAuthErrorCodes.methodNotImplemented);
113
113
  },
114
- async removeTokenBindingKey(): Promise<boolean> {
114
+ async removeTokenBindingKey(): Promise<void> {
115
115
  throw createClientAuthError(ClientAuthErrorCodes.methodNotImplemented);
116
116
  },
117
117
  async clearKeystore(): Promise<boolean> {
@@ -3,20 +3,20 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
+ import { AuthError } from "./AuthError.js";
6
7
  import * as CacheErrorCodes from "./CacheErrorCodes.js";
7
8
  export { CacheErrorCodes };
8
9
 
9
10
  export const CacheErrorMessages = {
10
- [CacheErrorCodes.cacheQuotaExceededErrorCode]:
11
- "Exceeded cache storage capacity.",
12
- [CacheErrorCodes.cacheUnknownErrorCode]:
11
+ [CacheErrorCodes.cacheQuotaExceeded]: "Exceeded cache storage capacity.",
12
+ [CacheErrorCodes.cacheErrorUnknown]:
13
13
  "Unexpected error occurred when using cache storage.",
14
14
  };
15
15
 
16
16
  /**
17
17
  * Error thrown when there is an error with the cache
18
18
  */
19
- export class CacheError extends Error {
19
+ export class CacheError extends AuthError {
20
20
  /**
21
21
  * Short string denoting error
22
22
  */
@@ -32,7 +32,7 @@ export class CacheError extends Error {
32
32
  errorMessage ||
33
33
  (CacheErrorMessages[errorCode]
34
34
  ? CacheErrorMessages[errorCode]
35
- : CacheErrorMessages[CacheErrorCodes.cacheUnknownErrorCode]);
35
+ : CacheErrorMessages[CacheErrorCodes.cacheErrorUnknown]);
36
36
 
37
37
  super(`${errorCode}: ${message}`);
38
38
  Object.setPrototypeOf(this, CacheError.prototype);
@@ -42,3 +42,24 @@ export class CacheError extends Error {
42
42
  this.errorMessage = message;
43
43
  }
44
44
  }
45
+
46
+ /**
47
+ * Helper function to wrap browser errors in a CacheError object
48
+ * @param e
49
+ * @returns
50
+ */
51
+ export function createCacheError(e: unknown): CacheError {
52
+ if (!(e instanceof Error)) {
53
+ return new CacheError(CacheErrorCodes.cacheErrorUnknown);
54
+ }
55
+
56
+ if (
57
+ e.name === "QuotaExceededError" ||
58
+ e.name === "NS_ERROR_DOM_QUOTA_REACHED" ||
59
+ e.message.includes("exceeded the quota")
60
+ ) {
61
+ return new CacheError(CacheErrorCodes.cacheQuotaExceeded);
62
+ } else {
63
+ return new CacheError(e.name, e.message);
64
+ }
65
+ }
@@ -3,5 +3,5 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- export const cacheQuotaExceededErrorCode = "cache_quota_exceeded";
7
- export const cacheUnknownErrorCode = "cache_error_unknown";
6
+ export const cacheQuotaExceeded = "cache_quota_exceeded";
7
+ export const cacheErrorUnknown = "cache_error_unknown";
@@ -16,6 +16,7 @@ export const InteractionRequiredServerErrorMessage = [
16
16
  InteractionRequiredAuthErrorCodes.consentRequired,
17
17
  InteractionRequiredAuthErrorCodes.loginRequired,
18
18
  InteractionRequiredAuthErrorCodes.badToken,
19
+ InteractionRequiredAuthErrorCodes.uxNotAllowed,
19
20
  ];
20
21
 
21
22
  export const InteractionRequiredAuthSubErrorMessage = [
@@ -36,6 +37,8 @@ const InteractionRequiredAuthErrorMessages = {
36
37
  "Refresh token has expired.",
37
38
  [InteractionRequiredAuthErrorCodes.badToken]:
38
39
  "Identity provider returned bad_token due to an expired or invalid refresh token. Please invoke an interactive API to resolve.",
40
+ [InteractionRequiredAuthErrorCodes.uxNotAllowed]:
41
+ "`canShowUI` flag in Edge was set to false. User interaction required on web page. Please invoke an interactive API to resolve.",
39
42
  };
40
43
 
41
44
  /**
@@ -7,6 +7,7 @@
7
7
  export const noTokensFound = "no_tokens_found";
8
8
  export const nativeAccountUnavailable = "native_account_unavailable";
9
9
  export const refreshTokenExpired = "refresh_token_expired";
10
+ export const uxNotAllowed = "ux_not_allowed";
10
11
 
11
12
  // Codes potentially returned by server
12
13
  export const interactionRequired = "interaction_required";
@@ -142,7 +142,11 @@ export {
142
142
  } from "./error/AuthError.js";
143
143
  export { ServerError } from "./error/ServerError.js";
144
144
  export { NetworkError, createNetworkError } from "./error/NetworkError.js";
145
- export { CacheError, CacheErrorCodes } from "./error/CacheError.js";
145
+ export {
146
+ CacheError,
147
+ CacheErrorCodes,
148
+ createCacheError,
149
+ } from "./error/CacheError.js";
146
150
  export {
147
151
  ClientAuthError,
148
152
  ClientAuthErrorMessage,
@@ -38,14 +38,15 @@ export class ThrottlingUtils {
38
38
  */
39
39
  static preProcess(
40
40
  cacheManager: CacheManager,
41
- thumbprint: RequestThumbprint
41
+ thumbprint: RequestThumbprint,
42
+ correlationId: string
42
43
  ): void {
43
44
  const key = ThrottlingUtils.generateThrottlingStorageKey(thumbprint);
44
45
  const value = cacheManager.getThrottlingCache(key);
45
46
 
46
47
  if (value) {
47
48
  if (value.throttleTime < Date.now()) {
48
- cacheManager.removeItem(key);
49
+ cacheManager.removeItem(key, correlationId);
49
50
  return;
50
51
  }
51
52
  throw new ServerError(
@@ -65,7 +66,8 @@ export class ThrottlingUtils {
65
66
  static postProcess(
66
67
  cacheManager: CacheManager,
67
68
  thumbprint: RequestThumbprint,
68
- response: NetworkResponse<ServerAuthorizationTokenResponse>
69
+ response: NetworkResponse<ServerAuthorizationTokenResponse>,
70
+ correlationId: string
69
71
  ): void {
70
72
  if (
71
73
  ThrottlingUtils.checkResponseStatus(response) ||
@@ -82,7 +84,8 @@ export class ThrottlingUtils {
82
84
  };
83
85
  cacheManager.setThrottlingCache(
84
86
  ThrottlingUtils.generateThrottlingStorageKey(thumbprint),
85
- thumbprintValue
87
+ thumbprintValue,
88
+ correlationId
86
89
  );
87
90
  }
88
91
  }
@@ -146,6 +149,6 @@ export class ThrottlingUtils {
146
149
  homeAccountIdentifier
147
150
  );
148
151
  const key = this.generateThrottlingStorageKey(thumbprint);
149
- cacheManager.removeItem(key);
152
+ cacheManager.removeItem(key, request.correlationId);
150
153
  }
151
154
  }
@@ -1,3 +1,3 @@
1
1
  /* eslint-disable header/header */
2
2
  export const name = "@azure/msal-common";
3
- export const version = "15.7.0";
3
+ export const version = "15.8.0";
@@ -279,7 +279,10 @@ export class ResponseHandler {
279
279
  cacheRecord.account
280
280
  ) {
281
281
  const key = cacheRecord.account.generateAccountKey();
282
- const account = this.cacheStorage.getAccount(key);
282
+ const account = this.cacheStorage.getAccount(
283
+ key,
284
+ request.correlationId
285
+ );
283
286
  if (!account) {
284
287
  this.logger.warning(
285
288
  "Account used to refresh tokens not in persistence, refreshed tokens will not be stored in the cache"
@@ -369,6 +372,7 @@ export class ResponseHandler {
369
372
  authority,
370
373
  this.homeAccountIdentifier,
371
374
  this.cryptoObj.base64Decode,
375
+ request.correlationId,
372
376
  idTokenClaims,
373
377
  serverTokenResponse.client_info,
374
378
  env,
@@ -610,6 +614,7 @@ export function buildAccountToCache(
610
614
  authority: Authority,
611
615
  homeAccountId: string,
612
616
  base64Decode: (input: string) => string,
617
+ correlationId: string,
613
618
  idTokenClaims?: TokenClaims,
614
619
  clientInfo?: string,
615
620
  environment?: string,
@@ -628,7 +633,7 @@ export function buildAccountToCache(
628
633
 
629
634
  let cachedAccount: AccountEntity | null = null;
630
635
  if (baseAccountKey) {
631
- cachedAccount = cacheStorage.getAccount(baseAccountKey);
636
+ cachedAccount = cacheStorage.getAccount(baseAccountKey, correlationId);
632
637
  }
633
638
 
634
639
  const baseAccount =
@@ -204,7 +204,8 @@ export class ServerTelemetryManager {
204
204
 
205
205
  this.cacheManager.setServerTelemetry(
206
206
  this.telemetryCacheKey,
207
- lastRequests
207
+ lastRequests,
208
+ this.correlationId
208
209
  );
209
210
 
210
211
  return;
@@ -219,7 +220,8 @@ export class ServerTelemetryManager {
219
220
 
220
221
  this.cacheManager.setServerTelemetry(
221
222
  this.telemetryCacheKey,
222
- lastRequests
223
+ lastRequests,
224
+ this.correlationId
223
225
  );
224
226
  return lastRequests.cacheHits;
225
227
  }
@@ -250,7 +252,10 @@ export class ServerTelemetryManager {
250
252
  const errorCount = lastRequests.errors.length;
251
253
  if (numErrorsFlushed === errorCount) {
252
254
  // All errors were sent on last request, clear Telemetry cache
253
- this.cacheManager.removeItem(this.telemetryCacheKey);
255
+ this.cacheManager.removeItem(
256
+ this.telemetryCacheKey,
257
+ this.correlationId
258
+ );
254
259
  } else {
255
260
  // Partial data was flushed to server, construct a new telemetry cache item with errors that were not flushed
256
261
  const serverTelemEntity: ServerTelemetryEntity = {
@@ -263,7 +268,8 @@ export class ServerTelemetryManager {
263
268
 
264
269
  this.cacheManager.setServerTelemetry(
265
270
  this.telemetryCacheKey,
266
- serverTelemEntity
271
+ serverTelemEntity,
272
+ this.correlationId
267
273
  );
268
274
  }
269
275
  }
@@ -351,7 +357,8 @@ export class ServerTelemetryManager {
351
357
  lastRequests.nativeBrokerErrorCode = errorCode;
352
358
  this.cacheManager.setServerTelemetry(
353
359
  this.telemetryCacheKey,
354
- lastRequests
360
+ lastRequests,
361
+ this.correlationId
355
362
  );
356
363
  }
357
364
 
@@ -364,7 +371,8 @@ export class ServerTelemetryManager {
364
371
  delete lastRequests.nativeBrokerErrorCode;
365
372
  this.cacheManager.setServerTelemetry(
366
373
  this.telemetryCacheKey,
367
- lastRequests
374
+ lastRequests,
375
+ this.correlationId
368
376
  );
369
377
  }
370
378