@azure/msal-common 14.8.1 → 14.9.1-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.
- package/dist/account/AccountInfo.mjs +1 -1
- package/dist/account/AuthToken.mjs +1 -1
- package/dist/account/CcsCredential.mjs +1 -1
- package/dist/account/ClientCredentials.d.ts +6 -1
- package/dist/account/ClientCredentials.d.ts.map +1 -1
- package/dist/account/ClientInfo.mjs +1 -1
- package/dist/account/TokenClaims.mjs +1 -1
- package/dist/authority/Authority.d.ts +3 -2
- package/dist/authority/Authority.d.ts.map +1 -1
- package/dist/authority/Authority.mjs +8 -4
- package/dist/authority/Authority.mjs.map +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/cache/CacheManager.d.ts +4 -2
- package/dist/cache/CacheManager.d.ts.map +1 -1
- package/dist/cache/CacheManager.mjs +43 -17
- package/dist/cache/CacheManager.mjs.map +1 -1
- package/dist/cache/entities/AccountEntity.mjs +1 -1
- package/dist/cache/entities/CacheRecord.mjs +1 -1
- package/dist/cache/persistence/TokenCacheContext.mjs +1 -1
- package/dist/cache/utils/CacheHelpers.mjs +1 -1
- package/dist/client/AuthorizationCodeClient.d.ts.map +1 -1
- package/dist/client/AuthorizationCodeClient.mjs +8 -3
- package/dist/client/AuthorizationCodeClient.mjs.map +1 -1
- package/dist/client/BaseClient.mjs +1 -1
- package/dist/client/RefreshTokenClient.d.ts.map +1 -1
- package/dist/client/RefreshTokenClient.mjs +3 -2
- package/dist/client/RefreshTokenClient.mjs.map +1 -1
- package/dist/client/SilentFlowClient.mjs +1 -1
- package/dist/config/ClientConfiguration.d.ts.map +1 -1
- package/dist/config/ClientConfiguration.mjs +2 -4
- package/dist/config/ClientConfiguration.mjs.map +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 +21 -0
- package/dist/error/CacheError.d.ts.map +1 -0
- package/dist/error/CacheError.mjs +33 -0
- package/dist/error/CacheError.mjs.map +1 -0
- package/dist/error/CacheErrorCodes.d.ts +3 -0
- package/dist/error/CacheErrorCodes.d.ts.map +1 -0
- package/dist/error/CacheErrorCodes.mjs +11 -0
- package/dist/error/CacheErrorCodes.mjs.map +1 -0
- 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.d.ts +5 -1
- package/dist/error/InteractionRequiredAuthError.d.ts.map +1 -1
- package/dist/error/InteractionRequiredAuthError.mjs +3 -2
- package/dist/error/InteractionRequiredAuthError.mjs.map +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/ServerError.d.ts +5 -1
- package/dist/error/ServerError.d.ts.map +1 -1
- package/dist/error/ServerError.mjs +3 -2
- package/dist/error/ServerError.mjs.map +1 -1
- package/dist/index.cjs +165 -43
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +8 -2
- package/dist/index.mjs.map +1 -1
- package/dist/logger/Logger.mjs +1 -1
- package/dist/network/INetworkModule.d.ts +1 -1
- package/dist/network/INetworkModule.d.ts.map +1 -1
- package/dist/network/INetworkModule.mjs +1 -1
- package/dist/network/NetworkManager.mjs +1 -1
- package/dist/network/ThrottlingUtils.mjs +1 -1
- package/dist/packageMetadata.d.ts +1 -1
- package/dist/packageMetadata.d.ts.map +1 -1
- package/dist/packageMetadata.mjs +2 -2
- package/dist/request/AuthenticationHeaderParser.mjs +1 -1
- package/dist/request/BaseAuthRequest.d.ts +2 -0
- package/dist/request/BaseAuthRequest.d.ts.map +1 -1
- package/dist/request/RequestParameterBuilder.mjs +1 -1
- package/dist/request/RequestParameterBuilder.mjs.map +1 -1
- package/dist/request/RequestValidator.mjs +1 -1
- package/dist/request/ScopeSet.mjs +1 -1
- package/dist/response/ResponseHandler.d.ts.map +1 -1
- package/dist/response/ResponseHandler.mjs +17 -6
- package/dist/response/ResponseHandler.mjs.map +1 -1
- package/dist/response/ServerAuthorizationCodeResponse.d.ts +1 -0
- package/dist/response/ServerAuthorizationCodeResponse.d.ts.map +1 -1
- package/dist/telemetry/performance/PerformanceClient.d.ts +1 -7
- package/dist/telemetry/performance/PerformanceClient.d.ts.map +1 -1
- package/dist/telemetry/performance/PerformanceClient.mjs +14 -11
- package/dist/telemetry/performance/PerformanceClient.mjs.map +1 -1
- package/dist/telemetry/performance/PerformanceEvent.d.ts +14 -0
- package/dist/telemetry/performance/PerformanceEvent.d.ts.map +1 -1
- package/dist/telemetry/performance/PerformanceEvent.mjs +2 -1
- package/dist/telemetry/performance/PerformanceEvent.mjs.map +1 -1
- package/dist/telemetry/performance/StubPerformanceClient.mjs +1 -1
- package/dist/telemetry/server/ServerTelemetryManager.mjs +1 -1
- package/dist/url/UrlString.mjs +1 -1
- package/dist/utils/ClientAssertionUtils.d.ts +3 -0
- package/dist/utils/ClientAssertionUtils.d.ts.map +1 -0
- package/dist/utils/ClientAssertionUtils.mjs +21 -0
- package/dist/utils/ClientAssertionUtils.mjs.map +1 -0
- package/dist/utils/Constants.d.ts +12 -0
- package/dist/utils/Constants.d.ts.map +1 -1
- package/dist/utils/Constants.mjs +15 -2
- package/dist/utils/Constants.mjs.map +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/package.json +3 -3
- package/src/account/ClientCredentials.ts +10 -1
- package/src/authority/Authority.ts +9 -3
- package/src/cache/CacheManager.ts +58 -19
- package/src/client/AuthorizationCodeClient.ts +20 -3
- package/src/client/RefreshTokenClient.ts +11 -2
- package/src/config/ClientConfiguration.ts +4 -4
- package/src/error/CacheError.ts +44 -0
- package/src/error/CacheErrorCodes.ts +7 -0
- package/src/error/InteractionRequiredAuthError.ts +8 -1
- package/src/error/ServerError.ts +12 -1
- package/src/index.ts +9 -1
- package/src/network/INetworkModule.ts +1 -1
- package/src/packageMetadata.ts +1 -1
- package/src/request/BaseAuthRequest.ts +2 -0
- package/src/response/ResponseHandler.ts +27 -5
- package/src/response/ServerAuthorizationCodeResponse.ts +1 -0
- package/src/telemetry/performance/PerformanceClient.ts +14 -11
- package/src/telemetry/performance/PerformanceEvent.ts +21 -0
- package/src/utils/ClientAssertionUtils.ts +25 -0
- package/src/utils/Constants.ts +14 -0
|
@@ -50,6 +50,8 @@ import { RequestValidator } from "../request/RequestValidator";
|
|
|
50
50
|
import { IPerformanceClient } from "../telemetry/performance/IPerformanceClient";
|
|
51
51
|
import { PerformanceEvents } from "../telemetry/performance/PerformanceEvent";
|
|
52
52
|
import { invokeAsync } from "../utils/FunctionWrappers";
|
|
53
|
+
import { ClientAssertion } from "../account/ClientCredentials";
|
|
54
|
+
import { getClientAssertion } from "../utils/ClientAssertionUtils";
|
|
53
55
|
|
|
54
56
|
/**
|
|
55
57
|
* Oauth2.0 Authorization Code client
|
|
@@ -364,9 +366,16 @@ export class AuthorizationCodeClient extends BaseClient {
|
|
|
364
366
|
}
|
|
365
367
|
|
|
366
368
|
if (this.config.clientCredentials.clientAssertion) {
|
|
367
|
-
const clientAssertion =
|
|
369
|
+
const clientAssertion: ClientAssertion =
|
|
368
370
|
this.config.clientCredentials.clientAssertion;
|
|
369
|
-
|
|
371
|
+
|
|
372
|
+
parameterBuilder.addClientAssertion(
|
|
373
|
+
await getClientAssertion(
|
|
374
|
+
clientAssertion.assertion,
|
|
375
|
+
this.config.authOptions.clientId,
|
|
376
|
+
request.resourceRequestUri
|
|
377
|
+
)
|
|
378
|
+
);
|
|
370
379
|
parameterBuilder.addClientAssertionType(
|
|
371
380
|
clientAssertion.assertionType
|
|
372
381
|
);
|
|
@@ -557,9 +566,17 @@ export class AuthorizationCodeClient extends BaseClient {
|
|
|
557
566
|
parameterBuilder.addSid(request.sid);
|
|
558
567
|
} else if (request.account) {
|
|
559
568
|
const accountSid = this.extractAccountSid(request.account);
|
|
560
|
-
|
|
569
|
+
let accountLoginHintClaim = this.extractLoginHint(
|
|
561
570
|
request.account
|
|
562
571
|
);
|
|
572
|
+
|
|
573
|
+
if (accountLoginHintClaim && request.domainHint) {
|
|
574
|
+
this.logger.warning(
|
|
575
|
+
`AuthorizationCodeClient.createAuthCodeUrlQueryString: "domainHint" param is set, skipping opaque "login_hint" claim. Please consider not passing domainHint`
|
|
576
|
+
);
|
|
577
|
+
accountLoginHintClaim = null;
|
|
578
|
+
}
|
|
579
|
+
|
|
563
580
|
// If login_hint claim is present, use it over sid/username
|
|
564
581
|
if (accountLoginHintClaim) {
|
|
565
582
|
this.logger.verbose(
|
|
@@ -48,6 +48,8 @@ import { PerformanceEvents } from "../telemetry/performance/PerformanceEvent";
|
|
|
48
48
|
import { IPerformanceClient } from "../telemetry/performance/IPerformanceClient";
|
|
49
49
|
import { invoke, invokeAsync } from "../utils/FunctionWrappers";
|
|
50
50
|
import { generateCredentialKey } from "../cache/utils/CacheHelpers";
|
|
51
|
+
import { ClientAssertion } from "../account/ClientCredentials";
|
|
52
|
+
import { getClientAssertion } from "../utils/ClientAssertionUtils";
|
|
51
53
|
|
|
52
54
|
const DEFAULT_REFRESH_TOKEN_EXPIRATION_OFFSET_SECONDS = 300; // 5 Minutes
|
|
53
55
|
|
|
@@ -385,9 +387,16 @@ export class RefreshTokenClient extends BaseClient {
|
|
|
385
387
|
}
|
|
386
388
|
|
|
387
389
|
if (this.config.clientCredentials.clientAssertion) {
|
|
388
|
-
const clientAssertion =
|
|
390
|
+
const clientAssertion: ClientAssertion =
|
|
389
391
|
this.config.clientCredentials.clientAssertion;
|
|
390
|
-
|
|
392
|
+
|
|
393
|
+
parameterBuilder.addClientAssertion(
|
|
394
|
+
await getClientAssertion(
|
|
395
|
+
clientAssertion.assertion,
|
|
396
|
+
this.config.authOptions.clientId,
|
|
397
|
+
request.resourceRequestUri
|
|
398
|
+
)
|
|
399
|
+
);
|
|
391
400
|
parameterBuilder.addClientAssertionType(
|
|
392
401
|
clientAssertion.assertionType
|
|
393
402
|
);
|
|
@@ -6,7 +6,10 @@
|
|
|
6
6
|
import { INetworkModule } from "../network/INetworkModule";
|
|
7
7
|
import { DEFAULT_CRYPTO_IMPLEMENTATION, ICrypto } from "../crypto/ICrypto";
|
|
8
8
|
import { ILoggerCallback, Logger, LogLevel } from "../logger/Logger";
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
Constants,
|
|
11
|
+
DEFAULT_TOKEN_RENEWAL_OFFSET_SEC,
|
|
12
|
+
} from "../utils/Constants";
|
|
10
13
|
import { version } from "../packageMetadata";
|
|
11
14
|
import { Authority } from "../authority/Authority";
|
|
12
15
|
import { AzureCloudInstance } from "../authority/AuthorityOptions";
|
|
@@ -21,9 +24,6 @@ import {
|
|
|
21
24
|
createClientAuthError,
|
|
22
25
|
} from "../error/ClientAuthError";
|
|
23
26
|
|
|
24
|
-
// Token renewal offset default in seconds
|
|
25
|
-
const DEFAULT_TOKEN_RENEWAL_OFFSET_SEC = 300;
|
|
26
|
-
|
|
27
27
|
/**
|
|
28
28
|
* Use the configuration object to configure MSAL Modules and initialize the base interfaces for MSAL.
|
|
29
29
|
*
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import * as CacheErrorCodes from "./CacheErrorCodes";
|
|
7
|
+
export { CacheErrorCodes };
|
|
8
|
+
|
|
9
|
+
export const CacheErrorMessages = {
|
|
10
|
+
[CacheErrorCodes.cacheQuotaExceededErrorCode]:
|
|
11
|
+
"Exceeded cache storage capacity.",
|
|
12
|
+
[CacheErrorCodes.cacheUnknownErrorCode]:
|
|
13
|
+
"Unexpected error occurred when using cache storage.",
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Error thrown when there is an error with the cache
|
|
18
|
+
*/
|
|
19
|
+
export class CacheError extends Error {
|
|
20
|
+
/**
|
|
21
|
+
* Short string denoting error
|
|
22
|
+
*/
|
|
23
|
+
errorCode: string;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Detailed description of error
|
|
27
|
+
*/
|
|
28
|
+
errorMessage: string;
|
|
29
|
+
|
|
30
|
+
constructor(errorCode: string, errorMessage?: string) {
|
|
31
|
+
const message =
|
|
32
|
+
errorMessage ||
|
|
33
|
+
(CacheErrorMessages[errorCode]
|
|
34
|
+
? CacheErrorMessages[errorCode]
|
|
35
|
+
: CacheErrorMessages[CacheErrorCodes.cacheUnknownErrorCode]);
|
|
36
|
+
|
|
37
|
+
super(`${errorCode}: ${message}`);
|
|
38
|
+
Object.setPrototypeOf(this, CacheError.prototype);
|
|
39
|
+
|
|
40
|
+
this.name = "CacheError";
|
|
41
|
+
this.errorCode = errorCode;
|
|
42
|
+
this.errorMessage = message;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -88,6 +88,11 @@ export class InteractionRequiredAuthError extends AuthError {
|
|
|
88
88
|
*/
|
|
89
89
|
claims: string;
|
|
90
90
|
|
|
91
|
+
/**
|
|
92
|
+
* Server error number;
|
|
93
|
+
*/
|
|
94
|
+
readonly errorNo?: string;
|
|
95
|
+
|
|
91
96
|
constructor(
|
|
92
97
|
errorCode?: string,
|
|
93
98
|
errorMessage?: string,
|
|
@@ -95,7 +100,8 @@ export class InteractionRequiredAuthError extends AuthError {
|
|
|
95
100
|
timestamp?: string,
|
|
96
101
|
traceId?: string,
|
|
97
102
|
correlationId?: string,
|
|
98
|
-
claims?: string
|
|
103
|
+
claims?: string,
|
|
104
|
+
errorNo?: string
|
|
99
105
|
) {
|
|
100
106
|
super(errorCode, errorMessage, subError);
|
|
101
107
|
Object.setPrototypeOf(this, InteractionRequiredAuthError.prototype);
|
|
@@ -105,6 +111,7 @@ export class InteractionRequiredAuthError extends AuthError {
|
|
|
105
111
|
this.correlationId = correlationId || Constants.EMPTY_STRING;
|
|
106
112
|
this.claims = claims || Constants.EMPTY_STRING;
|
|
107
113
|
this.name = "InteractionRequiredAuthError";
|
|
114
|
+
this.errorNo = errorNo;
|
|
108
115
|
}
|
|
109
116
|
}
|
|
110
117
|
|
package/src/error/ServerError.ts
CHANGED
|
@@ -9,9 +9,20 @@ import { AuthError } from "./AuthError";
|
|
|
9
9
|
* Error thrown when there is an error with the server code, for example, unavailability.
|
|
10
10
|
*/
|
|
11
11
|
export class ServerError extends AuthError {
|
|
12
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Server error number;
|
|
14
|
+
*/
|
|
15
|
+
readonly errorNo?: string;
|
|
16
|
+
|
|
17
|
+
constructor(
|
|
18
|
+
errorCode?: string,
|
|
19
|
+
errorMessage?: string,
|
|
20
|
+
subError?: string,
|
|
21
|
+
errorNo?: string
|
|
22
|
+
) {
|
|
13
23
|
super(errorCode, errorMessage, subError);
|
|
14
24
|
this.name = "ServerError";
|
|
25
|
+
this.errorNo = errorNo;
|
|
15
26
|
|
|
16
27
|
Object.setPrototypeOf(this, ServerError.prototype);
|
|
17
28
|
}
|
package/src/index.ts
CHANGED
|
@@ -133,7 +133,11 @@ export { NativeRequest } from "./request/NativeRequest";
|
|
|
133
133
|
export { NativeSignOutRequest } from "./request/NativeSignOutRequest";
|
|
134
134
|
export { RequestParameterBuilder } from "./request/RequestParameterBuilder";
|
|
135
135
|
export { StoreInCache } from "./request/StoreInCache";
|
|
136
|
-
export {
|
|
136
|
+
export {
|
|
137
|
+
ClientAssertion,
|
|
138
|
+
ClientAssertionConfig,
|
|
139
|
+
ClientAssertionCallback,
|
|
140
|
+
} from "./account/ClientCredentials";
|
|
137
141
|
// Response
|
|
138
142
|
export { AzureRegion } from "./authority/AzureRegion";
|
|
139
143
|
export { AzureRegionConfiguration } from "./authority/AzureRegionConfiguration";
|
|
@@ -168,6 +172,7 @@ export {
|
|
|
168
172
|
createAuthError,
|
|
169
173
|
} from "./error/AuthError";
|
|
170
174
|
export { ServerError } from "./error/ServerError";
|
|
175
|
+
export { CacheError, CacheErrorCodes } from "./error/CacheError";
|
|
171
176
|
export {
|
|
172
177
|
ClientAuthError,
|
|
173
178
|
ClientAuthErrorMessage,
|
|
@@ -181,6 +186,7 @@ export {
|
|
|
181
186
|
createClientConfigurationError,
|
|
182
187
|
} from "./error/ClientConfigurationError";
|
|
183
188
|
// Constants and Utils
|
|
189
|
+
export { getClientAssertion } from "./utils/ClientAssertionUtils";
|
|
184
190
|
export {
|
|
185
191
|
Constants,
|
|
186
192
|
OIDC_DEFAULT_SCOPES,
|
|
@@ -204,6 +210,7 @@ export {
|
|
|
204
210
|
GrantType,
|
|
205
211
|
AADAuthorityConstants,
|
|
206
212
|
HttpStatus,
|
|
213
|
+
DEFAULT_TOKEN_RENEWAL_OFFSET_SEC,
|
|
207
214
|
JsonWebTokenTypes,
|
|
208
215
|
} from "./utils/Constants";
|
|
209
216
|
export * as AADServerParamKeys from "./constants/AADServerParamKeys";
|
|
@@ -216,6 +223,7 @@ export {
|
|
|
216
223
|
} from "./utils/ProtocolUtils";
|
|
217
224
|
export * as TimeUtils from "./utils/TimeUtils";
|
|
218
225
|
export * as UrlUtils from "./utils/UrlUtils";
|
|
226
|
+
export * as ClientAssertionUtils from "./utils/ClientAssertionUtils";
|
|
219
227
|
export * from "./utils/FunctionWrappers";
|
|
220
228
|
// Server Telemetry
|
|
221
229
|
export { ServerTelemetryManager } from "./telemetry/server/ServerTelemetryManager";
|
package/src/packageMetadata.ts
CHANGED
|
@@ -27,6 +27,7 @@ import { ShrOptions } from "../crypto/SignedHttpRequest";
|
|
|
27
27
|
* - requestedClaimsHash - SHA 256 hash string of the requested claims string, used as part of an access token cache key so tokens can be filtered by requested claims
|
|
28
28
|
* - tokenQueryParameters - String to string map of custom query parameters added to the /token call
|
|
29
29
|
* - storeInCache - Object containing boolean values indicating whether to store tokens in the cache or not (default is true)
|
|
30
|
+
* - scenarioId - Scenario id to track custom user prompts
|
|
30
31
|
*/
|
|
31
32
|
export type BaseAuthRequest = {
|
|
32
33
|
authority: string;
|
|
@@ -46,4 +47,5 @@ export type BaseAuthRequest = {
|
|
|
46
47
|
maxAge?: number;
|
|
47
48
|
tokenQueryParameters?: StringDict;
|
|
48
49
|
storeInCache?: StoreInCache;
|
|
50
|
+
scenarioId?: string;
|
|
49
51
|
};
|
|
@@ -53,6 +53,19 @@ import {
|
|
|
53
53
|
} from "../account/AccountInfo";
|
|
54
54
|
import * as CacheHelpers from "../cache/utils/CacheHelpers";
|
|
55
55
|
|
|
56
|
+
function parseServerErrorNo(
|
|
57
|
+
serverResponse: ServerAuthorizationCodeResponse
|
|
58
|
+
): string | undefined {
|
|
59
|
+
const errorCodePrefix = "code=";
|
|
60
|
+
const errorCodePrefixIndex =
|
|
61
|
+
serverResponse.error_uri?.lastIndexOf(errorCodePrefix);
|
|
62
|
+
return errorCodePrefixIndex && errorCodePrefixIndex >= 0
|
|
63
|
+
? serverResponse.error_uri?.substring(
|
|
64
|
+
errorCodePrefixIndex + errorCodePrefix.length
|
|
65
|
+
)
|
|
66
|
+
: undefined;
|
|
67
|
+
}
|
|
68
|
+
|
|
56
69
|
/**
|
|
57
70
|
* Class that handles response parsing.
|
|
58
71
|
* @internal
|
|
@@ -140,6 +153,7 @@ export class ResponseHandler {
|
|
|
140
153
|
serverResponse.error_description ||
|
|
141
154
|
serverResponse.suberror
|
|
142
155
|
) {
|
|
156
|
+
const serverErrorNo = parseServerErrorNo(serverResponse);
|
|
143
157
|
if (
|
|
144
158
|
isInteractionRequiredError(
|
|
145
159
|
serverResponse.error,
|
|
@@ -154,14 +168,16 @@ export class ResponseHandler {
|
|
|
154
168
|
serverResponse.timestamp || "",
|
|
155
169
|
serverResponse.trace_id || "",
|
|
156
170
|
serverResponse.correlation_id || "",
|
|
157
|
-
serverResponse.claims || ""
|
|
171
|
+
serverResponse.claims || "",
|
|
172
|
+
serverErrorNo
|
|
158
173
|
);
|
|
159
174
|
}
|
|
160
175
|
|
|
161
176
|
throw new ServerError(
|
|
162
177
|
serverResponse.error || "",
|
|
163
178
|
serverResponse.error_description,
|
|
164
|
-
serverResponse.suberror
|
|
179
|
+
serverResponse.suberror,
|
|
180
|
+
serverErrorNo
|
|
165
181
|
);
|
|
166
182
|
}
|
|
167
183
|
}
|
|
@@ -182,10 +198,14 @@ export class ResponseHandler {
|
|
|
182
198
|
serverResponse.suberror
|
|
183
199
|
) {
|
|
184
200
|
const errString = `${serverResponse.error_codes} - [${serverResponse.timestamp}]: ${serverResponse.error_description} - Correlation ID: ${serverResponse.correlation_id} - Trace ID: ${serverResponse.trace_id}`;
|
|
201
|
+
const serverErrorNo = serverResponse.error_codes?.length
|
|
202
|
+
? serverResponse.error_codes[0]
|
|
203
|
+
: undefined;
|
|
185
204
|
const serverError = new ServerError(
|
|
186
205
|
serverResponse.error,
|
|
187
206
|
errString,
|
|
188
|
-
serverResponse.suberror
|
|
207
|
+
serverResponse.suberror,
|
|
208
|
+
serverErrorNo
|
|
189
209
|
);
|
|
190
210
|
|
|
191
211
|
// check if 500 error
|
|
@@ -230,7 +250,8 @@ export class ResponseHandler {
|
|
|
230
250
|
serverResponse.timestamp || Constants.EMPTY_STRING,
|
|
231
251
|
serverResponse.trace_id || Constants.EMPTY_STRING,
|
|
232
252
|
serverResponse.correlation_id || Constants.EMPTY_STRING,
|
|
233
|
-
serverResponse.claims || Constants.EMPTY_STRING
|
|
253
|
+
serverResponse.claims || Constants.EMPTY_STRING,
|
|
254
|
+
serverErrorNo
|
|
234
255
|
);
|
|
235
256
|
}
|
|
236
257
|
|
|
@@ -364,7 +385,8 @@ export class ResponseHandler {
|
|
|
364
385
|
}
|
|
365
386
|
await this.cacheStorage.saveCacheRecord(
|
|
366
387
|
cacheRecord,
|
|
367
|
-
request.storeInCache
|
|
388
|
+
request.storeInCache,
|
|
389
|
+
request.correlationId
|
|
368
390
|
);
|
|
369
391
|
} finally {
|
|
370
392
|
if (
|
|
@@ -23,6 +23,9 @@ import {
|
|
|
23
23
|
import { IPerformanceMeasurement } from "./IPerformanceMeasurement";
|
|
24
24
|
import { StubPerformanceMeasurement } from "./StubPerformanceClient";
|
|
25
25
|
import { AuthError } from "../../error/AuthError";
|
|
26
|
+
import { CacheError } from "../../error/CacheError";
|
|
27
|
+
import { ServerError } from "../../error/ServerError";
|
|
28
|
+
import { InteractionRequiredAuthError } from "../../error/InteractionRequiredAuthError";
|
|
26
29
|
|
|
27
30
|
export interface PreQueueEvent {
|
|
28
31
|
name: PerformanceEvents;
|
|
@@ -153,6 +156,15 @@ export function addError(
|
|
|
153
156
|
} else if (error instanceof AuthError) {
|
|
154
157
|
event.errorCode = error.errorCode;
|
|
155
158
|
event.subErrorCode = error.subError;
|
|
159
|
+
if (
|
|
160
|
+
error instanceof ServerError ||
|
|
161
|
+
error instanceof InteractionRequiredAuthError
|
|
162
|
+
) {
|
|
163
|
+
event.serverErrorNo = error.errorNo;
|
|
164
|
+
}
|
|
165
|
+
return;
|
|
166
|
+
} else if (error instanceof CacheError) {
|
|
167
|
+
event.errorCode = error.errorCode;
|
|
156
168
|
return;
|
|
157
169
|
} else if (event.errorStack?.length) {
|
|
158
170
|
logger.trace(
|
|
@@ -608,7 +620,7 @@ export abstract class PerformanceClient implements IPerformanceClient {
|
|
|
608
620
|
|
|
609
621
|
if (isRoot) {
|
|
610
622
|
queueInfo = this.getQueueInfo(event.correlationId);
|
|
611
|
-
this.
|
|
623
|
+
this.discardMeasurements(rootEvent.correlationId);
|
|
612
624
|
} else {
|
|
613
625
|
rootEvent.incompleteSubMeasurements?.delete(event.eventId);
|
|
614
626
|
}
|
|
@@ -769,7 +781,7 @@ export abstract class PerformanceClient implements IPerformanceClient {
|
|
|
769
781
|
}
|
|
770
782
|
|
|
771
783
|
/**
|
|
772
|
-
* Removes measurements for a given correlation id.
|
|
784
|
+
* Removes measurements and aux data for a given correlation id.
|
|
773
785
|
*
|
|
774
786
|
* @param {string} correlationId
|
|
775
787
|
*/
|
|
@@ -779,15 +791,6 @@ export abstract class PerformanceClient implements IPerformanceClient {
|
|
|
779
791
|
correlationId
|
|
780
792
|
);
|
|
781
793
|
this.eventsByCorrelationId.delete(correlationId);
|
|
782
|
-
}
|
|
783
|
-
|
|
784
|
-
/**
|
|
785
|
-
* Removes cache for a given correlation id.
|
|
786
|
-
*
|
|
787
|
-
* @param {string} correlationId correlation identifier
|
|
788
|
-
*/
|
|
789
|
-
private discardCache(correlationId: string): void {
|
|
790
|
-
this.discardMeasurements(correlationId);
|
|
791
794
|
|
|
792
795
|
this.logger.trace(
|
|
793
796
|
"PerformanceClient: QueueMeasurements discarded",
|
|
@@ -69,6 +69,7 @@ export const PerformanceEvents = {
|
|
|
69
69
|
* Used to acquire a new set of tokens from the authorize endpoint in a hidden iframe.
|
|
70
70
|
*/
|
|
71
71
|
SilentIframeClientAcquireToken: "silentIframeClientAcquireToken",
|
|
72
|
+
AwaitConcurrentIframe: "awaitConcurrentIframe", // Time spent waiting for a concurrent iframe to complete
|
|
72
73
|
|
|
73
74
|
/**
|
|
74
75
|
* acquireToken API in SilentRereshClient (msal-browser).
|
|
@@ -646,6 +647,11 @@ export type PerformanceEvent = {
|
|
|
646
647
|
*/
|
|
647
648
|
subErrorCode?: string;
|
|
648
649
|
|
|
650
|
+
/**
|
|
651
|
+
* Server error number
|
|
652
|
+
*/
|
|
653
|
+
serverErrorNo?: string;
|
|
654
|
+
|
|
649
655
|
/**
|
|
650
656
|
* Name of the library used for the operation.
|
|
651
657
|
*
|
|
@@ -701,6 +707,11 @@ export type PerformanceEvent = {
|
|
|
701
707
|
|
|
702
708
|
visibilityChangeCount?: number;
|
|
703
709
|
incompleteSubsCount?: number;
|
|
710
|
+
|
|
711
|
+
/**
|
|
712
|
+
* CorrelationId of the in progress iframe request that was awaited
|
|
713
|
+
*/
|
|
714
|
+
awaitIframeCorrelationId?: string;
|
|
704
715
|
/**
|
|
705
716
|
* Amount of times queued in the JS event queue.
|
|
706
717
|
*
|
|
@@ -798,6 +809,16 @@ export type PerformanceEvent = {
|
|
|
798
809
|
|
|
799
810
|
// Event context as JSON string
|
|
800
811
|
context?: string;
|
|
812
|
+
|
|
813
|
+
// Number of tokens in the cache to be reported when cache quota is exceeded
|
|
814
|
+
cacheRtCount?: number;
|
|
815
|
+
cacheIdCount?: number;
|
|
816
|
+
cacheAtCount?: number;
|
|
817
|
+
|
|
818
|
+
// Scenario id to track custom user prompts
|
|
819
|
+
scenarioId?: string;
|
|
820
|
+
|
|
821
|
+
accountType?: "AAD" | "MSA" | "B2C";
|
|
801
822
|
};
|
|
802
823
|
|
|
803
824
|
export type PerformanceEventContext = {
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
ClientAssertionCallback,
|
|
8
|
+
ClientAssertionConfig,
|
|
9
|
+
} from "../account/ClientCredentials";
|
|
10
|
+
|
|
11
|
+
export async function getClientAssertion(
|
|
12
|
+
clientAssertion: string | ClientAssertionCallback,
|
|
13
|
+
clientId: string,
|
|
14
|
+
tokenEndpoint?: string
|
|
15
|
+
): Promise<string> {
|
|
16
|
+
if (typeof clientAssertion === "string") {
|
|
17
|
+
return clientAssertion;
|
|
18
|
+
} else {
|
|
19
|
+
const config: ClientAssertionConfig = {
|
|
20
|
+
clientId: clientId,
|
|
21
|
+
tokenEndpoint: tokenEndpoint,
|
|
22
|
+
};
|
|
23
|
+
return clientAssertion(config);
|
|
24
|
+
}
|
|
25
|
+
}
|
package/src/utils/Constants.ts
CHANGED
|
@@ -64,13 +64,24 @@ export const Constants = {
|
|
|
64
64
|
};
|
|
65
65
|
|
|
66
66
|
export const HttpStatus = {
|
|
67
|
+
SUCCESS: 200,
|
|
67
68
|
SUCCESS_RANGE_START: 200,
|
|
68
69
|
SUCCESS_RANGE_END: 299,
|
|
69
70
|
REDIRECT: 302,
|
|
71
|
+
CLIENT_ERROR: 400,
|
|
70
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,
|
|
71
78
|
CLIENT_ERROR_RANGE_END: 499,
|
|
79
|
+
SERVER_ERROR: 500,
|
|
72
80
|
SERVER_ERROR_RANGE_START: 500,
|
|
81
|
+
SERVICE_UNAVAILABLE: 503,
|
|
82
|
+
GATEWAY_TIMEOUT: 504,
|
|
73
83
|
SERVER_ERROR_RANGE_END: 599,
|
|
84
|
+
MULTI_SIDED_ERROR: 600,
|
|
74
85
|
} as const;
|
|
75
86
|
export type HttpStatus = (typeof HttpStatus)[keyof typeof HttpStatus];
|
|
76
87
|
|
|
@@ -370,3 +381,6 @@ export type JsonWebTokenTypes =
|
|
|
370
381
|
(typeof JsonWebTokenTypes)[keyof typeof JsonWebTokenTypes];
|
|
371
382
|
|
|
372
383
|
export const ONE_DAY_IN_MS = 86400000;
|
|
384
|
+
|
|
385
|
+
// Token renewal offset default in seconds
|
|
386
|
+
export const DEFAULT_TOKEN_RENEWAL_OFFSET_SEC = 300;
|