@azure/msal-common 14.16.0 → 14.16.1
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/dist/account/AccountInfo.d.ts +1 -0
- package/dist/account/AccountInfo.d.ts.map +1 -1
- package/dist/account/AccountInfo.mjs +1 -1
- package/dist/account/AccountInfo.mjs.map +1 -1
- package/dist/account/AuthToken.mjs +1 -1
- package/dist/account/CcsCredential.mjs +1 -1
- package/dist/account/ClientInfo.mjs +1 -1
- package/dist/account/TokenClaims.mjs +1 -1
- package/dist/authority/Authority.mjs +1 -1
- package/dist/authority/AuthorityFactory.mjs +1 -1
- package/dist/authority/AuthorityMetadata.mjs +1 -1
- package/dist/authority/AuthorityOptions.mjs +1 -1
- package/dist/authority/AuthorityType.mjs +1 -1
- package/dist/authority/CloudInstanceDiscoveryErrorResponse.mjs +1 -1
- package/dist/authority/CloudInstanceDiscoveryResponse.mjs +1 -1
- package/dist/authority/OpenIdConfigResponse.mjs +1 -1
- package/dist/authority/ProtocolMode.mjs +1 -1
- package/dist/authority/RegionDiscovery.mjs +1 -1
- package/dist/broker/nativeBroker/INativeBrokerPlugin.d.ts +1 -0
- package/dist/broker/nativeBroker/INativeBrokerPlugin.d.ts.map +1 -1
- package/dist/cache/CacheManager.d.ts +34 -34
- package/dist/cache/CacheManager.d.ts.map +1 -1
- package/dist/cache/CacheManager.mjs +84 -99
- package/dist/cache/CacheManager.mjs.map +1 -1
- package/dist/cache/entities/AccountEntity.d.ts +1 -0
- package/dist/cache/entities/AccountEntity.d.ts.map +1 -1
- package/dist/cache/entities/AccountEntity.mjs +1 -1
- package/dist/cache/entities/AccountEntity.mjs.map +1 -1
- package/dist/cache/entities/CredentialEntity.d.ts +2 -0
- package/dist/cache/entities/CredentialEntity.d.ts.map +1 -1
- package/dist/cache/interface/ICacheManager.d.ts +21 -21
- package/dist/cache/interface/ICacheManager.d.ts.map +1 -1
- package/dist/cache/persistence/TokenCacheContext.mjs +1 -1
- package/dist/cache/utils/CacheHelpers.mjs +1 -1
- package/dist/client/AuthorizationCodeClient.mjs +1 -1
- package/dist/client/BaseClient.d.ts.map +1 -1
- package/dist/client/BaseClient.mjs +3 -3
- package/dist/client/BaseClient.mjs.map +1 -1
- package/dist/client/RefreshTokenClient.d.ts.map +1 -1
- package/dist/client/RefreshTokenClient.mjs +3 -3
- package/dist/client/RefreshTokenClient.mjs.map +1 -1
- package/dist/client/SilentFlowClient.d.ts.map +1 -1
- package/dist/client/SilentFlowClient.mjs +4 -4
- package/dist/client/SilentFlowClient.mjs.map +1 -1
- package/dist/config/ClientConfiguration.mjs +1 -1
- package/dist/constants/AADServerParamKeys.mjs +1 -1
- package/dist/crypto/ICrypto.mjs +1 -1
- package/dist/crypto/JoseHeader.mjs +1 -1
- package/dist/crypto/PopTokenGenerator.mjs +1 -1
- package/dist/error/AuthError.mjs +1 -1
- package/dist/error/AuthErrorCodes.mjs +1 -1
- package/dist/error/CacheError.d.ts +6 -0
- package/dist/error/CacheError.d.ts.map +1 -1
- package/dist/error/CacheError.mjs +24 -6
- package/dist/error/CacheError.mjs.map +1 -1
- package/dist/error/CacheErrorCodes.d.ts +2 -2
- package/dist/error/CacheErrorCodes.d.ts.map +1 -1
- package/dist/error/CacheErrorCodes.mjs +4 -4
- package/dist/error/CacheErrorCodes.mjs.map +1 -1
- package/dist/error/ClientAuthError.mjs +1 -1
- package/dist/error/ClientAuthErrorCodes.mjs +1 -1
- package/dist/error/ClientConfigurationError.mjs +1 -1
- package/dist/error/ClientConfigurationErrorCodes.mjs +1 -1
- package/dist/error/InteractionRequiredAuthError.mjs +1 -1
- package/dist/error/InteractionRequiredAuthErrorCodes.mjs +1 -1
- package/dist/error/JoseHeaderError.mjs +1 -1
- package/dist/error/JoseHeaderErrorCodes.mjs +1 -1
- package/dist/error/NetworkError.mjs +1 -1
- package/dist/error/ServerError.mjs +1 -1
- package/dist/exports-common.d.ts +1 -1
- package/dist/exports-common.d.ts.map +1 -1
- package/dist/index-browser.mjs +2 -2
- package/dist/index-node.mjs +2 -2
- package/dist/index.mjs +2 -2
- package/dist/logger/Logger.mjs +1 -1
- package/dist/network/INetworkModule.mjs +1 -1
- package/dist/network/ThrottlingUtils.d.ts +2 -2
- package/dist/network/ThrottlingUtils.d.ts.map +1 -1
- package/dist/network/ThrottlingUtils.mjs +6 -6
- package/dist/network/ThrottlingUtils.mjs.map +1 -1
- package/dist/packageMetadata.d.ts +1 -1
- package/dist/packageMetadata.mjs +2 -2
- package/dist/request/AuthenticationHeaderParser.mjs +1 -1
- package/dist/request/RequestParameterBuilder.mjs +1 -1
- package/dist/request/RequestValidator.mjs +1 -1
- package/dist/request/ScopeSet.mjs +1 -1
- package/dist/response/ResponseHandler.d.ts +1 -1
- package/dist/response/ResponseHandler.d.ts.map +1 -1
- package/dist/response/ResponseHandler.mjs +6 -6
- package/dist/response/ResponseHandler.mjs.map +1 -1
- package/dist/telemetry/performance/PerformanceClient.mjs +1 -1
- package/dist/telemetry/performance/PerformanceEvent.mjs +1 -1
- package/dist/telemetry/performance/StubPerformanceClient.mjs +1 -1
- package/dist/telemetry/server/ServerTelemetryManager.d.ts.map +1 -1
- package/dist/telemetry/server/ServerTelemetryManager.mjs +7 -7
- package/dist/telemetry/server/ServerTelemetryManager.mjs.map +1 -1
- package/dist/url/UrlString.mjs +1 -1
- package/dist/utils/ClientAssertionUtils.mjs +1 -1
- package/dist/utils/Constants.mjs +1 -1
- package/dist/utils/FunctionWrappers.mjs +1 -1
- package/dist/utils/ProtocolUtils.mjs +1 -1
- package/dist/utils/StringUtils.mjs +1 -1
- package/dist/utils/TimeUtils.mjs +1 -1
- package/dist/utils/UrlUtils.mjs +1 -1
- package/lib/index-browser.cjs +3 -2
- package/lib/index-browser.cjs.map +1 -1
- package/lib/{index-node-C9XsExml.js → index-node-CebvEPer.js} +132 -128
- package/lib/index-node-CebvEPer.js.map +1 -0
- package/lib/index-node.cjs +3 -2
- package/lib/index-node.cjs.map +1 -1
- package/lib/index.cjs +3 -2
- package/lib/index.cjs.map +1 -1
- package/lib/types/account/AccountInfo.d.ts +1 -0
- package/lib/types/account/AccountInfo.d.ts.map +1 -1
- package/lib/types/broker/nativeBroker/INativeBrokerPlugin.d.ts +1 -0
- package/lib/types/broker/nativeBroker/INativeBrokerPlugin.d.ts.map +1 -1
- package/lib/types/cache/CacheManager.d.ts +34 -34
- package/lib/types/cache/CacheManager.d.ts.map +1 -1
- package/lib/types/cache/entities/AccountEntity.d.ts +1 -0
- package/lib/types/cache/entities/AccountEntity.d.ts.map +1 -1
- package/lib/types/cache/entities/CredentialEntity.d.ts +2 -0
- package/lib/types/cache/entities/CredentialEntity.d.ts.map +1 -1
- package/lib/types/cache/interface/ICacheManager.d.ts +21 -21
- package/lib/types/cache/interface/ICacheManager.d.ts.map +1 -1
- package/lib/types/client/BaseClient.d.ts.map +1 -1
- package/lib/types/client/RefreshTokenClient.d.ts.map +1 -1
- package/lib/types/client/SilentFlowClient.d.ts.map +1 -1
- package/lib/types/error/CacheError.d.ts +6 -0
- package/lib/types/error/CacheError.d.ts.map +1 -1
- package/lib/types/error/CacheErrorCodes.d.ts +2 -2
- package/lib/types/error/CacheErrorCodes.d.ts.map +1 -1
- package/lib/types/exports-common.d.ts +1 -1
- package/lib/types/exports-common.d.ts.map +1 -1
- package/lib/types/network/ThrottlingUtils.d.ts +2 -2
- package/lib/types/network/ThrottlingUtils.d.ts.map +1 -1
- package/lib/types/packageMetadata.d.ts +1 -1
- package/lib/types/response/ResponseHandler.d.ts +1 -1
- package/lib/types/response/ResponseHandler.d.ts.map +1 -1
- package/lib/types/telemetry/server/ServerTelemetryManager.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/account/AccountInfo.ts +1 -0
- package/src/cache/CacheManager.ts +184 -123
- package/src/cache/entities/AccountEntity.ts +1 -0
- package/src/cache/entities/CredentialEntity.ts +2 -0
- package/src/cache/interface/ICacheManager.ts +45 -20
- package/src/client/BaseClient.ts +11 -2
- package/src/client/RefreshTokenClient.ts +6 -3
- package/src/client/SilentFlowClient.ts +7 -5
- package/src/error/CacheError.ts +24 -4
- package/src/error/CacheErrorCodes.ts +2 -2
- package/src/exports-common.ts +5 -1
- package/src/network/ThrottlingUtils.ts +8 -5
- package/src/packageMetadata.ts +1 -1
- package/src/response/ResponseHandler.ts +14 -4
- package/src/telemetry/server/ServerTelemetryManager.ts +14 -6
- package/lib/index-node-C9XsExml.js.map +0 -1
|
@@ -21,13 +21,13 @@ 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
|
|
28
28
|
* @param account
|
|
29
29
|
*/
|
|
30
|
-
setAccount(account: AccountEntity): void;
|
|
30
|
+
setAccount(account: AccountEntity, correlationId: string): void;
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* Returns true if the given key matches our account key schema. Also matches homeAccountId and/or tenantId if provided
|
|
@@ -46,39 +46,52 @@ export interface ICacheManager {
|
|
|
46
46
|
* fetch the idToken entity from the platform cache
|
|
47
47
|
* @param idTokenKey
|
|
48
48
|
*/
|
|
49
|
-
getIdTokenCredential(
|
|
49
|
+
getIdTokenCredential(
|
|
50
|
+
idTokenKey: string,
|
|
51
|
+
correlationId: string
|
|
52
|
+
): IdTokenEntity | null;
|
|
50
53
|
|
|
51
54
|
/**
|
|
52
55
|
* set idToken entity to the platform cache
|
|
53
56
|
* @param idToken
|
|
54
57
|
*/
|
|
55
|
-
setIdTokenCredential(idToken: IdTokenEntity): void;
|
|
58
|
+
setIdTokenCredential(idToken: IdTokenEntity, correlationId: string): void;
|
|
56
59
|
|
|
57
60
|
/**
|
|
58
61
|
* fetch the idToken entity from the platform cache
|
|
59
62
|
* @param accessTokenKey
|
|
60
63
|
*/
|
|
61
|
-
getAccessTokenCredential(
|
|
64
|
+
getAccessTokenCredential(
|
|
65
|
+
accessTokenKey: string,
|
|
66
|
+
correlationId: string
|
|
67
|
+
): AccessTokenEntity | null;
|
|
62
68
|
|
|
63
69
|
/**
|
|
64
70
|
* set idToken entity to the platform cache
|
|
65
71
|
* @param accessToken
|
|
66
72
|
*/
|
|
67
|
-
setAccessTokenCredential(
|
|
73
|
+
setAccessTokenCredential(
|
|
74
|
+
accessToken: AccessTokenEntity,
|
|
75
|
+
correlationId: string
|
|
76
|
+
): void;
|
|
68
77
|
|
|
69
78
|
/**
|
|
70
79
|
* fetch the idToken entity from the platform cache
|
|
71
80
|
* @param refreshTokenKey
|
|
72
81
|
*/
|
|
73
82
|
getRefreshTokenCredential(
|
|
74
|
-
refreshTokenKey: string
|
|
83
|
+
refreshTokenKey: string,
|
|
84
|
+
correlationId: string
|
|
75
85
|
): RefreshTokenEntity | null;
|
|
76
86
|
|
|
77
87
|
/**
|
|
78
88
|
* set idToken entity to the platform cache
|
|
79
89
|
* @param refreshToken
|
|
80
90
|
*/
|
|
81
|
-
setRefreshTokenCredential(
|
|
91
|
+
setRefreshTokenCredential(
|
|
92
|
+
refreshToken: RefreshTokenEntity,
|
|
93
|
+
correlationId: string
|
|
94
|
+
): void;
|
|
82
95
|
|
|
83
96
|
/**
|
|
84
97
|
* fetch appMetadata entity from the platform cache
|
|
@@ -90,7 +103,7 @@ export interface ICacheManager {
|
|
|
90
103
|
* set appMetadata entity to the platform cache
|
|
91
104
|
* @param appMetadata
|
|
92
105
|
*/
|
|
93
|
-
setAppMetadata(appMetadata: AppMetadataEntity): void;
|
|
106
|
+
setAppMetadata(appMetadata: AppMetadataEntity, correlationId: string): void;
|
|
94
107
|
|
|
95
108
|
/**
|
|
96
109
|
* fetch server telemetry entity from the platform cache
|
|
@@ -107,7 +120,8 @@ export interface ICacheManager {
|
|
|
107
120
|
*/
|
|
108
121
|
setServerTelemetry(
|
|
109
122
|
serverTelemetryKey: string,
|
|
110
|
-
serverTelemetry: ServerTelemetryEntity
|
|
123
|
+
serverTelemetry: ServerTelemetryEntity,
|
|
124
|
+
correlationId: string
|
|
111
125
|
): void;
|
|
112
126
|
|
|
113
127
|
/**
|
|
@@ -153,13 +167,14 @@ export interface ICacheManager {
|
|
|
153
167
|
*/
|
|
154
168
|
setThrottlingCache(
|
|
155
169
|
throttlingCacheKey: string,
|
|
156
|
-
throttlingCache: ThrottlingEntity
|
|
170
|
+
throttlingCache: ThrottlingEntity,
|
|
171
|
+
correlationId: string
|
|
157
172
|
): void;
|
|
158
173
|
|
|
159
174
|
/**
|
|
160
175
|
* Returns all accounts in cache
|
|
161
176
|
*/
|
|
162
|
-
getAllAccounts(): AccountInfo[];
|
|
177
|
+
getAllAccounts(correlationId: string): AccountInfo[];
|
|
163
178
|
|
|
164
179
|
/**
|
|
165
180
|
* saves a cache record
|
|
@@ -167,6 +182,7 @@ export interface ICacheManager {
|
|
|
167
182
|
*/
|
|
168
183
|
saveCacheRecord(
|
|
169
184
|
cacheRecord: CacheRecord,
|
|
185
|
+
correlationId: string,
|
|
170
186
|
storeInCache?: StoreInCache
|
|
171
187
|
): Promise<void>;
|
|
172
188
|
|
|
@@ -176,43 +192,52 @@ export interface ICacheManager {
|
|
|
176
192
|
* @param environment
|
|
177
193
|
* @param realm
|
|
178
194
|
*/
|
|
179
|
-
getAccountsFilteredBy(
|
|
195
|
+
getAccountsFilteredBy(
|
|
196
|
+
filter: AccountFilter,
|
|
197
|
+
correlationId: string
|
|
198
|
+
): AccountEntity[];
|
|
180
199
|
|
|
181
200
|
/**
|
|
182
201
|
* Get AccountInfo object based on provided filters
|
|
183
202
|
* @param filter
|
|
184
203
|
*/
|
|
185
|
-
getAccountInfoFilteredBy(
|
|
204
|
+
getAccountInfoFilteredBy(
|
|
205
|
+
filter: AccountFilter,
|
|
206
|
+
correlationId: string
|
|
207
|
+
): AccountInfo | null;
|
|
186
208
|
|
|
187
209
|
/**
|
|
188
210
|
* Removes all accounts and related tokens from cache.
|
|
189
211
|
*/
|
|
190
|
-
removeAllAccounts(): Promise<void>;
|
|
212
|
+
removeAllAccounts(correlationId: string): Promise<void>;
|
|
191
213
|
|
|
192
214
|
/**
|
|
193
215
|
* returns a boolean if the given account is removed
|
|
194
216
|
* @param account
|
|
195
217
|
*/
|
|
196
|
-
removeAccount(accountKey: string): Promise<void>;
|
|
218
|
+
removeAccount(accountKey: string, correlationId: string): Promise<void>;
|
|
197
219
|
|
|
198
220
|
/**
|
|
199
221
|
* returns a boolean if the given account is removed
|
|
200
222
|
* @param account
|
|
201
223
|
*/
|
|
202
|
-
removeAccountContext(
|
|
224
|
+
removeAccountContext(
|
|
225
|
+
account: AccountEntity,
|
|
226
|
+
correlationId: string
|
|
227
|
+
): Promise<void>;
|
|
203
228
|
|
|
204
229
|
/**
|
|
205
230
|
* @param key
|
|
206
231
|
*/
|
|
207
|
-
removeIdToken(key: string): void;
|
|
232
|
+
removeIdToken(key: string, correlationId: string): void;
|
|
208
233
|
|
|
209
234
|
/**
|
|
210
235
|
* @param key
|
|
211
236
|
*/
|
|
212
|
-
removeAccessToken(key: string):
|
|
237
|
+
removeAccessToken(key: string, correlationId: string): void;
|
|
213
238
|
|
|
214
239
|
/**
|
|
215
240
|
* @param key
|
|
216
241
|
*/
|
|
217
|
-
removeRefreshToken(key: string): void;
|
|
242
|
+
removeRefreshToken(key: string, correlationId: string): void;
|
|
218
243
|
}
|
package/src/client/BaseClient.ts
CHANGED
|
@@ -186,7 +186,11 @@ export abstract class BaseClient {
|
|
|
186
186
|
options: NetworkRequestOptions,
|
|
187
187
|
correlationId: string
|
|
188
188
|
): Promise<NetworkResponse<T>> {
|
|
189
|
-
ThrottlingUtils.preProcess(
|
|
189
|
+
ThrottlingUtils.preProcess(
|
|
190
|
+
this.cacheManager,
|
|
191
|
+
thumbprint,
|
|
192
|
+
correlationId
|
|
193
|
+
);
|
|
190
194
|
|
|
191
195
|
let response;
|
|
192
196
|
try {
|
|
@@ -243,7 +247,12 @@ export abstract class BaseClient {
|
|
|
243
247
|
}
|
|
244
248
|
}
|
|
245
249
|
|
|
246
|
-
ThrottlingUtils.postProcess(
|
|
250
|
+
ThrottlingUtils.postProcess(
|
|
251
|
+
this.cacheManager,
|
|
252
|
+
thumbprint,
|
|
253
|
+
response,
|
|
254
|
+
correlationId
|
|
255
|
+
);
|
|
247
256
|
|
|
248
257
|
return response;
|
|
249
258
|
}
|
|
@@ -211,9 +211,9 @@ export class RefreshTokenClient extends BaseClient {
|
|
|
211
211
|
)(
|
|
212
212
|
request.account,
|
|
213
213
|
foci,
|
|
214
|
+
request.correlationId,
|
|
214
215
|
undefined,
|
|
215
|
-
this.performanceClient
|
|
216
|
-
request.correlationId
|
|
216
|
+
this.performanceClient
|
|
217
217
|
);
|
|
218
218
|
|
|
219
219
|
if (!refreshToken) {
|
|
@@ -265,7 +265,10 @@ export class RefreshTokenClient extends BaseClient {
|
|
|
265
265
|
"acquireTokenWithRefreshToken: bad refresh token, removing from cache"
|
|
266
266
|
);
|
|
267
267
|
const badRefreshTokenKey = generateCredentialKey(refreshToken);
|
|
268
|
-
this.cacheManager.removeRefreshToken(
|
|
268
|
+
this.cacheManager.removeRefreshToken(
|
|
269
|
+
badRefreshTokenKey,
|
|
270
|
+
request.correlationId
|
|
271
|
+
);
|
|
269
272
|
}
|
|
270
273
|
|
|
271
274
|
throw e;
|
|
@@ -131,8 +131,7 @@ export class SilentFlowClient extends BaseClient {
|
|
|
131
131
|
request,
|
|
132
132
|
tokenKeys,
|
|
133
133
|
requestTenantId,
|
|
134
|
-
this.performanceClient
|
|
135
|
-
request.correlationId
|
|
134
|
+
this.performanceClient
|
|
136
135
|
);
|
|
137
136
|
|
|
138
137
|
if (!cachedAccessToken) {
|
|
@@ -172,14 +171,17 @@ export class SilentFlowClient extends BaseClient {
|
|
|
172
171
|
const environment =
|
|
173
172
|
request.authority || this.authority.getPreferredCache();
|
|
174
173
|
const cacheRecord: CacheRecord = {
|
|
175
|
-
account: this.cacheManager.readAccountFromCache(
|
|
174
|
+
account: this.cacheManager.readAccountFromCache(
|
|
175
|
+
request.account,
|
|
176
|
+
request.correlationId
|
|
177
|
+
),
|
|
176
178
|
accessToken: cachedAccessToken,
|
|
177
179
|
idToken: this.cacheManager.getIdToken(
|
|
178
180
|
request.account,
|
|
181
|
+
request.correlationId,
|
|
179
182
|
tokenKeys,
|
|
180
183
|
requestTenantId,
|
|
181
|
-
this.performanceClient
|
|
182
|
-
request.correlationId
|
|
184
|
+
this.performanceClient
|
|
183
185
|
),
|
|
184
186
|
refreshToken: null,
|
|
185
187
|
appMetadata:
|
package/src/error/CacheError.ts
CHANGED
|
@@ -7,9 +7,8 @@ import * as CacheErrorCodes from "./CacheErrorCodes.js";
|
|
|
7
7
|
export { CacheErrorCodes };
|
|
8
8
|
|
|
9
9
|
export const CacheErrorMessages = {
|
|
10
|
-
[CacheErrorCodes.
|
|
11
|
-
|
|
12
|
-
[CacheErrorCodes.cacheUnknownErrorCode]:
|
|
10
|
+
[CacheErrorCodes.cacheQuotaExceeded]: "Exceeded cache storage capacity.",
|
|
11
|
+
[CacheErrorCodes.cacheErrorUnknown]:
|
|
13
12
|
"Unexpected error occurred when using cache storage.",
|
|
14
13
|
};
|
|
15
14
|
|
|
@@ -32,7 +31,7 @@ export class CacheError extends Error {
|
|
|
32
31
|
errorMessage ||
|
|
33
32
|
(CacheErrorMessages[errorCode]
|
|
34
33
|
? CacheErrorMessages[errorCode]
|
|
35
|
-
: CacheErrorMessages[CacheErrorCodes.
|
|
34
|
+
: CacheErrorMessages[CacheErrorCodes.cacheErrorUnknown]);
|
|
36
35
|
|
|
37
36
|
super(`${errorCode}: ${message}`);
|
|
38
37
|
Object.setPrototypeOf(this, CacheError.prototype);
|
|
@@ -42,3 +41,24 @@ export class CacheError extends Error {
|
|
|
42
41
|
this.errorMessage = message;
|
|
43
42
|
}
|
|
44
43
|
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Helper function to wrap browser errors in a CacheError object
|
|
47
|
+
* @param e
|
|
48
|
+
* @returns
|
|
49
|
+
*/
|
|
50
|
+
export function createCacheError(e: unknown): CacheError {
|
|
51
|
+
if (!(e instanceof Error)) {
|
|
52
|
+
return new CacheError(CacheErrorCodes.cacheErrorUnknown);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (
|
|
56
|
+
e.name === "QuotaExceededError" ||
|
|
57
|
+
e.name === "NS_ERROR_DOM_QUOTA_REACHED" ||
|
|
58
|
+
e.message.includes("exceeded the quota")
|
|
59
|
+
) {
|
|
60
|
+
return new CacheError(CacheErrorCodes.cacheQuotaExceeded);
|
|
61
|
+
} else {
|
|
62
|
+
return new CacheError(e.name, e.message);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
export const
|
|
7
|
-
export const
|
|
6
|
+
export const cacheQuotaExceeded = "cache_quota_exceeded";
|
|
7
|
+
export const cacheErrorUnknown = "cache_error_unknown";
|
package/src/exports-common.ts
CHANGED
|
@@ -137,7 +137,11 @@ export {
|
|
|
137
137
|
} from "./error/AuthError.js";
|
|
138
138
|
export { ServerError } from "./error/ServerError.js";
|
|
139
139
|
export { NetworkError, createNetworkError } from "./error/NetworkError.js";
|
|
140
|
-
export {
|
|
140
|
+
export {
|
|
141
|
+
CacheError,
|
|
142
|
+
CacheErrorCodes,
|
|
143
|
+
createCacheError,
|
|
144
|
+
} from "./error/CacheError.js";
|
|
141
145
|
export {
|
|
142
146
|
ClientAuthError,
|
|
143
147
|
ClientAuthErrorMessage,
|
|
@@ -35,14 +35,15 @@ export class ThrottlingUtils {
|
|
|
35
35
|
*/
|
|
36
36
|
static preProcess(
|
|
37
37
|
cacheManager: CacheManager,
|
|
38
|
-
thumbprint: RequestThumbprint
|
|
38
|
+
thumbprint: RequestThumbprint,
|
|
39
|
+
correlationId: string
|
|
39
40
|
): void {
|
|
40
41
|
const key = ThrottlingUtils.generateThrottlingStorageKey(thumbprint);
|
|
41
42
|
const value = cacheManager.getThrottlingCache(key);
|
|
42
43
|
|
|
43
44
|
if (value) {
|
|
44
45
|
if (value.throttleTime < Date.now()) {
|
|
45
|
-
cacheManager.removeItem(key);
|
|
46
|
+
cacheManager.removeItem(key, correlationId);
|
|
46
47
|
return;
|
|
47
48
|
}
|
|
48
49
|
throw new ServerError(
|
|
@@ -62,7 +63,8 @@ export class ThrottlingUtils {
|
|
|
62
63
|
static postProcess(
|
|
63
64
|
cacheManager: CacheManager,
|
|
64
65
|
thumbprint: RequestThumbprint,
|
|
65
|
-
response: NetworkResponse<ServerAuthorizationTokenResponse
|
|
66
|
+
response: NetworkResponse<ServerAuthorizationTokenResponse>,
|
|
67
|
+
correlationId: string
|
|
66
68
|
): void {
|
|
67
69
|
if (
|
|
68
70
|
ThrottlingUtils.checkResponseStatus(response) ||
|
|
@@ -79,7 +81,8 @@ export class ThrottlingUtils {
|
|
|
79
81
|
};
|
|
80
82
|
cacheManager.setThrottlingCache(
|
|
81
83
|
ThrottlingUtils.generateThrottlingStorageKey(thumbprint),
|
|
82
|
-
thumbprintValue
|
|
84
|
+
thumbprintValue,
|
|
85
|
+
correlationId
|
|
83
86
|
);
|
|
84
87
|
}
|
|
85
88
|
}
|
|
@@ -151,6 +154,6 @@ export class ThrottlingUtils {
|
|
|
151
154
|
};
|
|
152
155
|
|
|
153
156
|
const key = this.generateThrottlingStorageKey(thumbprint);
|
|
154
|
-
cacheManager.removeItem(key);
|
|
157
|
+
cacheManager.removeItem(key, request.correlationId);
|
|
155
158
|
}
|
|
156
159
|
}
|
package/src/packageMetadata.ts
CHANGED
|
@@ -376,7 +376,11 @@ export class ResponseHandler {
|
|
|
376
376
|
cacheRecord.account
|
|
377
377
|
) {
|
|
378
378
|
const key = cacheRecord.account.generateAccountKey();
|
|
379
|
-
const account = this.cacheStorage.getAccount(
|
|
379
|
+
const account = this.cacheStorage.getAccount(
|
|
380
|
+
key,
|
|
381
|
+
request.correlationId,
|
|
382
|
+
this.logger
|
|
383
|
+
);
|
|
380
384
|
if (!account) {
|
|
381
385
|
this.logger.warning(
|
|
382
386
|
"Account used to refresh tokens not in persistence, refreshed tokens will not be stored in the cache"
|
|
@@ -396,8 +400,8 @@ export class ResponseHandler {
|
|
|
396
400
|
}
|
|
397
401
|
await this.cacheStorage.saveCacheRecord(
|
|
398
402
|
cacheRecord,
|
|
399
|
-
request.
|
|
400
|
-
request.
|
|
403
|
+
request.correlationId,
|
|
404
|
+
request.storeInCache
|
|
401
405
|
);
|
|
402
406
|
} finally {
|
|
403
407
|
if (
|
|
@@ -466,6 +470,7 @@ export class ResponseHandler {
|
|
|
466
470
|
authority,
|
|
467
471
|
this.homeAccountIdentifier,
|
|
468
472
|
this.cryptoObj.base64Decode,
|
|
473
|
+
request.correlationId,
|
|
469
474
|
idTokenClaims,
|
|
470
475
|
serverTokenResponse.client_info,
|
|
471
476
|
env,
|
|
@@ -706,6 +711,7 @@ export function buildAccountToCache(
|
|
|
706
711
|
authority: Authority,
|
|
707
712
|
homeAccountId: string,
|
|
708
713
|
base64Decode: (input: string) => string,
|
|
714
|
+
correlationId: string,
|
|
709
715
|
idTokenClaims?: TokenClaims,
|
|
710
716
|
clientInfo?: string,
|
|
711
717
|
environment?: string,
|
|
@@ -724,7 +730,11 @@ export function buildAccountToCache(
|
|
|
724
730
|
|
|
725
731
|
let cachedAccount: AccountEntity | null = null;
|
|
726
732
|
if (baseAccountKey) {
|
|
727
|
-
cachedAccount = cacheStorage.getAccount(
|
|
733
|
+
cachedAccount = cacheStorage.getAccount(
|
|
734
|
+
baseAccountKey,
|
|
735
|
+
correlationId,
|
|
736
|
+
logger
|
|
737
|
+
);
|
|
728
738
|
}
|
|
729
739
|
|
|
730
740
|
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(
|
|
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
|
|