@azure/msal-common 14.15.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 -39
- package/dist/cache/CacheManager.d.ts.map +1 -1
- package/dist/cache/CacheManager.mjs +84 -102
- 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.d.ts.map +1 -1
- package/dist/client/AuthorizationCodeClient.mjs +24 -13
- package/dist/client/AuthorizationCodeClient.mjs.map +1 -1
- package/dist/client/BaseClient.d.ts +10 -3
- package/dist/client/BaseClient.d.ts.map +1 -1
- package/dist/client/BaseClient.mjs +62 -10
- package/dist/client/BaseClient.mjs.map +1 -1
- package/dist/client/RefreshTokenClient.d.ts.map +1 -1
- package/dist/client/RefreshTokenClient.mjs +12 -6
- 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.d.ts +2 -0
- package/dist/config/ClientConfiguration.d.ts.map +1 -1
- package/dist/config/ClientConfiguration.mjs +1 -1
- package/dist/config/ClientConfiguration.mjs.map +1 -1
- package/dist/constants/AADServerParamKeys.d.ts +2 -0
- package/dist/constants/AADServerParamKeys.d.ts.map +1 -1
- package/dist/constants/AADServerParamKeys.mjs +5 -3
- package/dist/constants/AADServerParamKeys.mjs.map +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.d.ts +19 -0
- package/dist/error/NetworkError.d.ts.map +1 -0
- package/dist/error/NetworkError.mjs +34 -0
- package/dist/error/NetworkError.mjs.map +1 -0
- package/dist/error/ServerError.mjs +1 -1
- package/dist/exports-common.d.ts +3 -2
- package/dist/exports-common.d.ts.map +1 -1
- package/dist/index-browser.mjs +3 -3
- package/dist/index-node.mjs +3 -3
- package/dist/index.mjs +3 -3
- 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/NetworkResponse.d.ts +6 -0
- package/dist/network/NetworkResponse.d.ts.map +1 -0
- package/dist/network/ThrottlingUtils.d.ts +3 -3
- 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/BaseAuthRequest.d.ts +2 -0
- package/dist/request/BaseAuthRequest.d.ts.map +1 -1
- package/dist/request/RequestParameterBuilder.d.ts +8 -1
- package/dist/request/RequestParameterBuilder.d.ts.map +1 -1
- package/dist/request/RequestParameterBuilder.mjs +26 -3
- 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 +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.d.ts.map +1 -1
- package/dist/telemetry/performance/PerformanceClient.mjs +29 -10
- package/dist/telemetry/performance/PerformanceClient.mjs.map +1 -1
- package/dist/telemetry/performance/PerformanceEvent.d.ts +9 -0
- package/dist/telemetry/performance/PerformanceEvent.d.ts.map +1 -1
- package/dist/telemetry/performance/PerformanceEvent.mjs +6 -1
- package/dist/telemetry/performance/PerformanceEvent.mjs.map +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.d.ts +1 -0
- package/dist/utils/Constants.d.ts.map +1 -1
- package/dist/utils/Constants.mjs +2 -1
- 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/lib/index-browser.cjs +34 -13
- package/lib/index-browser.cjs.map +1 -1
- package/lib/{index-node-aee3f7b6.js → index-node-CebvEPer.js} +390 -298
- package/lib/index-node-CebvEPer.js.map +1 -0
- package/lib/index-node.cjs +6 -4
- package/lib/index-node.cjs.map +1 -1
- package/lib/index.cjs +6 -4
- 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 -39
- 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/AuthorizationCodeClient.d.ts.map +1 -1
- package/lib/types/client/BaseClient.d.ts +10 -3
- 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/config/ClientConfiguration.d.ts +2 -0
- package/lib/types/config/ClientConfiguration.d.ts.map +1 -1
- package/lib/types/constants/AADServerParamKeys.d.ts +2 -0
- package/lib/types/constants/AADServerParamKeys.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/error/NetworkError.d.ts +19 -0
- package/lib/types/error/NetworkError.d.ts.map +1 -0
- package/lib/types/exports-common.d.ts +3 -2
- package/lib/types/exports-common.d.ts.map +1 -1
- package/lib/types/network/INetworkModule.d.ts +1 -1
- package/lib/types/network/INetworkModule.d.ts.map +1 -1
- package/lib/types/network/NetworkResponse.d.ts +6 -0
- package/lib/types/network/NetworkResponse.d.ts.map +1 -0
- package/lib/types/network/ThrottlingUtils.d.ts +3 -3
- package/lib/types/network/ThrottlingUtils.d.ts.map +1 -1
- package/lib/types/packageMetadata.d.ts +1 -1
- package/lib/types/request/BaseAuthRequest.d.ts +2 -0
- package/lib/types/request/BaseAuthRequest.d.ts.map +1 -1
- package/lib/types/request/RequestParameterBuilder.d.ts +8 -1
- package/lib/types/request/RequestParameterBuilder.d.ts.map +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/performance/PerformanceClient.d.ts.map +1 -1
- package/lib/types/telemetry/performance/PerformanceEvent.d.ts +9 -0
- package/lib/types/telemetry/performance/PerformanceEvent.d.ts.map +1 -1
- package/lib/types/telemetry/server/ServerTelemetryManager.d.ts.map +1 -1
- package/lib/types/utils/Constants.d.ts +1 -0
- package/lib/types/utils/Constants.d.ts.map +1 -1
- package/package.json +2 -4
- package/src/account/AccountInfo.ts +1 -0
- package/src/authority/RegionDiscovery.ts +1 -1
- package/src/cache/CacheManager.ts +184 -131
- 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/AuthorizationCodeClient.ts +37 -16
- package/src/client/BaseClient.ts +113 -22
- package/src/client/RefreshTokenClient.ts +20 -8
- package/src/client/SilentFlowClient.ts +7 -5
- package/src/config/ClientConfiguration.ts +2 -0
- package/src/constants/AADServerParamKeys.ts +2 -0
- package/src/error/CacheError.ts +24 -4
- package/src/error/CacheErrorCodes.ts +2 -2
- package/src/error/NetworkError.ts +44 -0
- package/src/exports-common.ts +7 -6
- package/src/network/INetworkModule.ts +1 -1
- package/src/network/NetworkResponse.ts +10 -0
- package/src/network/ThrottlingUtils.ts +9 -6
- package/src/packageMetadata.ts +1 -1
- package/src/request/BaseAuthRequest.ts +2 -0
- package/src/request/RequestParameterBuilder.ts +51 -1
- package/src/response/ResponseHandler.ts +14 -4
- package/src/telemetry/performance/PerformanceClient.ts +42 -12
- package/src/telemetry/performance/PerformanceEvent.ts +15 -0
- package/src/telemetry/server/ServerTelemetryManager.ts +14 -6
- package/src/utils/Constants.ts +1 -0
- package/dist/network/NetworkManager.d.ts +0 -34
- package/dist/network/NetworkManager.d.ts.map +0 -1
- package/dist/network/NetworkManager.mjs +0 -44
- package/dist/network/NetworkManager.mjs.map +0 -1
- package/lib/index-node-aee3f7b6.js.map +0 -1
- package/lib/types/network/NetworkManager.d.ts +0 -34
- package/lib/types/network/NetworkManager.d.ts.map +0 -1
- package/src/network/NetworkManager.ts +0 -76
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { AuthError } from "./AuthError.js";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Represents network related errors
|
|
10
|
+
*/
|
|
11
|
+
export class NetworkError extends AuthError {
|
|
12
|
+
error: AuthError;
|
|
13
|
+
httpStatus?: number;
|
|
14
|
+
responseHeaders?: Record<string, string>;
|
|
15
|
+
|
|
16
|
+
constructor(
|
|
17
|
+
error: AuthError,
|
|
18
|
+
httpStatus?: number,
|
|
19
|
+
responseHeaders?: Record<string, string>
|
|
20
|
+
) {
|
|
21
|
+
super(error.errorCode, error.errorMessage, error.subError);
|
|
22
|
+
|
|
23
|
+
Object.setPrototypeOf(this, NetworkError.prototype);
|
|
24
|
+
this.name = "NetworkError";
|
|
25
|
+
this.error = error;
|
|
26
|
+
this.httpStatus = httpStatus;
|
|
27
|
+
this.responseHeaders = responseHeaders;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Creates NetworkError object for a failed network request
|
|
33
|
+
* @param error - Error to be thrown back to the caller
|
|
34
|
+
* @param httpStatus - Status code of the network request
|
|
35
|
+
* @param responseHeaders - Response headers of the network request, when available
|
|
36
|
+
* @returns NetworkError object
|
|
37
|
+
*/
|
|
38
|
+
export function createNetworkError(
|
|
39
|
+
error: AuthError,
|
|
40
|
+
httpStatus?: number,
|
|
41
|
+
responseHeaders?: Record<string, string>
|
|
42
|
+
): NetworkError {
|
|
43
|
+
return new NetworkError(error, httpStatus, responseHeaders);
|
|
44
|
+
}
|
package/src/exports-common.ts
CHANGED
|
@@ -91,11 +91,7 @@ export {
|
|
|
91
91
|
NetworkRequestOptions,
|
|
92
92
|
StubbedNetworkModule,
|
|
93
93
|
} from "./network/INetworkModule.js";
|
|
94
|
-
export {
|
|
95
|
-
NetworkManager,
|
|
96
|
-
NetworkResponse,
|
|
97
|
-
UrlToHttpRequestOptions,
|
|
98
|
-
} from "./network/NetworkManager.js";
|
|
94
|
+
export { NetworkResponse } from "./network/NetworkResponse.js";
|
|
99
95
|
export { ThrottlingUtils } from "./network/ThrottlingUtils.js";
|
|
100
96
|
export { RequestThumbprint } from "./network/RequestThumbprint.js";
|
|
101
97
|
export { IUri } from "./url/IUri.js";
|
|
@@ -140,7 +136,12 @@ export {
|
|
|
140
136
|
createAuthError,
|
|
141
137
|
} from "./error/AuthError.js";
|
|
142
138
|
export { ServerError } from "./error/ServerError.js";
|
|
143
|
-
export {
|
|
139
|
+
export { NetworkError, createNetworkError } from "./error/NetworkError.js";
|
|
140
|
+
export {
|
|
141
|
+
CacheError,
|
|
142
|
+
CacheErrorCodes,
|
|
143
|
+
createCacheError,
|
|
144
|
+
} from "./error/CacheError.js";
|
|
144
145
|
export {
|
|
145
146
|
ClientAuthError,
|
|
146
147
|
ClientAuthErrorMessage,
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
ClientAuthErrorCodes,
|
|
8
8
|
createClientAuthError,
|
|
9
9
|
} from "../error/ClientAuthError.js";
|
|
10
|
-
import { NetworkResponse } from "./
|
|
10
|
+
import { NetworkResponse } from "./NetworkResponse.js";
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Options allowed by network request APIs.
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { NetworkResponse } from "./
|
|
6
|
+
import { NetworkResponse } from "./NetworkResponse.js";
|
|
7
7
|
import { ServerAuthorizationTokenResponse } from "../response/ServerAuthorizationTokenResponse.js";
|
|
8
8
|
import {
|
|
9
9
|
HeaderNames,
|
|
@@ -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
|
@@ -29,6 +29,7 @@ import { ShrOptions } from "../crypto/SignedHttpRequest.js";
|
|
|
29
29
|
* - storeInCache - Object containing boolean values indicating whether to store tokens in the cache or not (default is true)
|
|
30
30
|
* - scenarioId - Scenario id to track custom user prompts
|
|
31
31
|
* - popKid - Key ID to identify the public key for PoP token request
|
|
32
|
+
* - 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.
|
|
32
33
|
*/
|
|
33
34
|
export type BaseAuthRequest = {
|
|
34
35
|
authority: string;
|
|
@@ -50,4 +51,5 @@ export type BaseAuthRequest = {
|
|
|
50
51
|
storeInCache?: StoreInCache;
|
|
51
52
|
scenarioId?: string;
|
|
52
53
|
popKid?: string;
|
|
54
|
+
embeddedClientId?: string;
|
|
53
55
|
};
|
|
@@ -28,13 +28,44 @@ import {
|
|
|
28
28
|
} from "../config/ClientConfiguration.js";
|
|
29
29
|
import { ServerTelemetryManager } from "../telemetry/server/ServerTelemetryManager.js";
|
|
30
30
|
import { ClientInfo } from "../account/ClientInfo.js";
|
|
31
|
+
import { IPerformanceClient } from "../telemetry/performance/IPerformanceClient.js";
|
|
32
|
+
|
|
33
|
+
function instrumentBrokerParams(
|
|
34
|
+
parameters: Map<string, string>,
|
|
35
|
+
correlationId?: string,
|
|
36
|
+
performanceClient?: IPerformanceClient
|
|
37
|
+
) {
|
|
38
|
+
if (!correlationId) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const clientId = parameters.get(AADServerParamKeys.CLIENT_ID);
|
|
43
|
+
if (clientId && parameters.has(AADServerParamKeys.BROKER_CLIENT_ID)) {
|
|
44
|
+
performanceClient?.addFields(
|
|
45
|
+
{
|
|
46
|
+
embeddedClientId: clientId,
|
|
47
|
+
embeddedRedirectUri: parameters.get(
|
|
48
|
+
AADServerParamKeys.REDIRECT_URI
|
|
49
|
+
),
|
|
50
|
+
},
|
|
51
|
+
correlationId
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
31
55
|
|
|
32
56
|
/** @internal */
|
|
33
57
|
export class RequestParameterBuilder {
|
|
34
58
|
private parameters: Map<string, string>;
|
|
59
|
+
private readonly performanceClient?: IPerformanceClient;
|
|
60
|
+
private readonly correlationId?: string;
|
|
35
61
|
|
|
36
|
-
constructor(
|
|
62
|
+
constructor(
|
|
63
|
+
correlationId?: string,
|
|
64
|
+
performanceClient?: IPerformanceClient
|
|
65
|
+
) {
|
|
37
66
|
this.parameters = new Map<string, string>();
|
|
67
|
+
this.performanceClient = performanceClient;
|
|
68
|
+
this.correlationId = correlationId;
|
|
38
69
|
}
|
|
39
70
|
|
|
40
71
|
/**
|
|
@@ -598,6 +629,19 @@ export class RequestParameterBuilder {
|
|
|
598
629
|
);
|
|
599
630
|
}
|
|
600
631
|
|
|
632
|
+
addBrokerParameters(params: {
|
|
633
|
+
brokerClientId: string;
|
|
634
|
+
brokerRedirectUri: string;
|
|
635
|
+
}): void {
|
|
636
|
+
const brokerParams: StringDict = {};
|
|
637
|
+
brokerParams[AADServerParamKeys.BROKER_CLIENT_ID] =
|
|
638
|
+
params.brokerClientId;
|
|
639
|
+
brokerParams[AADServerParamKeys.BROKER_REDIRECT_URI] =
|
|
640
|
+
params.brokerRedirectUri;
|
|
641
|
+
|
|
642
|
+
this.addExtraQueryParameters(brokerParams);
|
|
643
|
+
}
|
|
644
|
+
|
|
601
645
|
/**
|
|
602
646
|
* Utility to create a URL from the params map
|
|
603
647
|
*/
|
|
@@ -608,6 +652,12 @@ export class RequestParameterBuilder {
|
|
|
608
652
|
queryParameterArray.push(`${key}=${value}`);
|
|
609
653
|
});
|
|
610
654
|
|
|
655
|
+
instrumentBrokerParams(
|
|
656
|
+
this.parameters,
|
|
657
|
+
this.correlationId,
|
|
658
|
+
this.performanceClient
|
|
659
|
+
);
|
|
660
|
+
|
|
611
661
|
return queryParameterArray.join("&");
|
|
612
662
|
}
|
|
613
663
|
}
|
|
@@ -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 =
|
|
@@ -198,22 +198,39 @@ export function compactStack(stack: string, stackMaxSize: number): string[] {
|
|
|
198
198
|
}
|
|
199
199
|
|
|
200
200
|
const stackArr = stack.split("\n") || [];
|
|
201
|
-
if (stackArr.length < 2) {
|
|
202
|
-
return [];
|
|
203
|
-
}
|
|
204
201
|
|
|
205
202
|
const res = [];
|
|
206
|
-
|
|
207
|
-
for (
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
203
|
+
|
|
204
|
+
// Check for a handful of known, common runtime errors and log them (with redaction where applicable).
|
|
205
|
+
const firstLine = stackArr[0];
|
|
206
|
+
if (
|
|
207
|
+
firstLine.startsWith("TypeError: Cannot read property") ||
|
|
208
|
+
firstLine.startsWith("TypeError: Cannot read properties of") ||
|
|
209
|
+
firstLine.startsWith("TypeError: Cannot set property") ||
|
|
210
|
+
firstLine.startsWith("TypeError: Cannot set properties of") ||
|
|
211
|
+
firstLine.endsWith("is not a function")
|
|
212
212
|
) {
|
|
213
|
-
|
|
213
|
+
// These types of errors are not at risk of leaking PII. They will indicate unavailable APIs
|
|
214
|
+
res.push(compactStackLine(firstLine));
|
|
215
|
+
} else if (
|
|
216
|
+
firstLine.startsWith("SyntaxError") ||
|
|
217
|
+
firstLine.startsWith("TypeError")
|
|
218
|
+
) {
|
|
219
|
+
// Prevent unintentional leaking of arbitrary info by redacting contents between both single and double quotes
|
|
220
|
+
res.push(
|
|
221
|
+
compactStackLine(
|
|
222
|
+
// Example: SyntaxError: Unexpected token 'e', "test" is not valid JSON -> SyntaxError: Unexpected token <redacted>, <redacted> is not valid JSON
|
|
223
|
+
firstLine.replace(/['].*[']|["].*["]/g, "<redacted>")
|
|
224
|
+
)
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// Get top N stack lines
|
|
229
|
+
for (let ix = 1; ix < stackArr.length; ix++) {
|
|
214
230
|
if (res.length >= stackMaxSize) {
|
|
215
231
|
break;
|
|
216
232
|
}
|
|
233
|
+
const line = stackArr[ix];
|
|
217
234
|
res.push(compactStackLine(line));
|
|
218
235
|
}
|
|
219
236
|
return res;
|
|
@@ -630,14 +647,27 @@ export abstract class PerformanceClient implements IPerformanceClient {
|
|
|
630
647
|
event.correlationId
|
|
631
648
|
);
|
|
632
649
|
|
|
650
|
+
if (error) {
|
|
651
|
+
addError(error, this.logger, rootEvent);
|
|
652
|
+
}
|
|
653
|
+
|
|
633
654
|
// Add sub-measurement attribute to root event.
|
|
634
655
|
if (!isRoot) {
|
|
635
656
|
rootEvent[event.name + "DurationMs"] = Math.floor(event.durationMs);
|
|
636
657
|
return { ...rootEvent };
|
|
637
658
|
}
|
|
638
659
|
|
|
639
|
-
if (
|
|
640
|
-
|
|
660
|
+
if (
|
|
661
|
+
isRoot &&
|
|
662
|
+
!error &&
|
|
663
|
+
(rootEvent.errorCode || rootEvent.subErrorCode)
|
|
664
|
+
) {
|
|
665
|
+
this.logger.trace(
|
|
666
|
+
`PerformanceClient: Remove error and sub-error codes for root event ${event.name} as intermediate error was successfully handled`,
|
|
667
|
+
event.correlationId
|
|
668
|
+
);
|
|
669
|
+
rootEvent.errorCode = undefined;
|
|
670
|
+
rootEvent.subErrorCode = undefined;
|
|
641
671
|
}
|
|
642
672
|
|
|
643
673
|
let finalEvent: PerformanceEvent = { ...rootEvent, ...event };
|
|
@@ -116,6 +116,7 @@ export const PerformanceEvents = {
|
|
|
116
116
|
/**
|
|
117
117
|
* Time spent sending/waiting for the response of a request to the token endpoint
|
|
118
118
|
*/
|
|
119
|
+
NetworkClientSendPostRequestAsync: "networkClientSendPostRequestAsync",
|
|
119
120
|
RefreshTokenClientExecutePostToTokenEndpoint:
|
|
120
121
|
"refreshTokenClientExecutePostToTokenEndpoint",
|
|
121
122
|
AuthorizationCodeClientExecutePostToTokenEndpoint:
|
|
@@ -342,6 +343,10 @@ export const PerformanceEventAbbreviations: ReadonlyMap<string, string> =
|
|
|
342
343
|
PerformanceEvents.BaseClientCreateTokenRequestHeaders,
|
|
343
344
|
"BaseClientCreateTReqHead",
|
|
344
345
|
],
|
|
346
|
+
[
|
|
347
|
+
PerformanceEvents.NetworkClientSendPostRequestAsync,
|
|
348
|
+
"NetClientSendPost",
|
|
349
|
+
],
|
|
345
350
|
[
|
|
346
351
|
PerformanceEvents.RefreshTokenClientExecutePostToTokenEndpoint,
|
|
347
352
|
"RTClientExecPost",
|
|
@@ -790,7 +795,14 @@ export type PerformanceEvent = {
|
|
|
790
795
|
matsSilentStatus?: number;
|
|
791
796
|
matsHttpStatus?: number;
|
|
792
797
|
matsHttpEventCount?: number;
|
|
798
|
+
|
|
799
|
+
/**
|
|
800
|
+
* Http POST metadata
|
|
801
|
+
*/
|
|
793
802
|
httpVerToken?: string;
|
|
803
|
+
httpStatus?: number;
|
|
804
|
+
contentTypeHeader?: string;
|
|
805
|
+
contentLengthHeader?: string;
|
|
794
806
|
|
|
795
807
|
/**
|
|
796
808
|
* Native broker fields
|
|
@@ -834,6 +846,9 @@ export type PerformanceEvent = {
|
|
|
834
846
|
* @type {string}
|
|
835
847
|
*/
|
|
836
848
|
retryError?: string;
|
|
849
|
+
|
|
850
|
+
embeddedClientId?: string;
|
|
851
|
+
embeddedRedirectUri?: string;
|
|
837
852
|
};
|
|
838
853
|
|
|
839
854
|
export type PerformanceEventContext = {
|
|
@@ -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
|
|
package/src/utils/Constants.ts
CHANGED
|
@@ -99,6 +99,7 @@ export const OIDC_SCOPES = [...OIDC_DEFAULT_SCOPES, Constants.EMAIL_SCOPE];
|
|
|
99
99
|
*/
|
|
100
100
|
export const HeaderNames = {
|
|
101
101
|
CONTENT_TYPE: "Content-Type",
|
|
102
|
+
CONTENT_LENGTH: "Content-Length",
|
|
102
103
|
RETRY_AFTER: "Retry-After",
|
|
103
104
|
CCS_HEADER: "X-AnchorMailbox",
|
|
104
105
|
WWWAuthenticate: "WWW-Authenticate",
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { INetworkModule, NetworkRequestOptions } from "./INetworkModule.js";
|
|
2
|
-
import { RequestThumbprint } from "./RequestThumbprint.js";
|
|
3
|
-
import { CacheManager } from "../cache/CacheManager.js";
|
|
4
|
-
import { ServerAuthorizationTokenResponse } from "../response/ServerAuthorizationTokenResponse.js";
|
|
5
|
-
export type NetworkResponse<T> = {
|
|
6
|
-
headers: Record<string, string>;
|
|
7
|
-
body: T;
|
|
8
|
-
status: number;
|
|
9
|
-
};
|
|
10
|
-
export type UrlToHttpRequestOptions = {
|
|
11
|
-
protocol: string;
|
|
12
|
-
hostname: string;
|
|
13
|
-
hash: string;
|
|
14
|
-
search: string;
|
|
15
|
-
pathname: string;
|
|
16
|
-
path: string;
|
|
17
|
-
href: string;
|
|
18
|
-
port?: number;
|
|
19
|
-
auth?: string;
|
|
20
|
-
};
|
|
21
|
-
/** @internal */
|
|
22
|
-
export declare class NetworkManager {
|
|
23
|
-
private networkClient;
|
|
24
|
-
private cacheManager;
|
|
25
|
-
constructor(networkClient: INetworkModule, cacheManager: CacheManager);
|
|
26
|
-
/**
|
|
27
|
-
* Wraps sendPostRequestAsync with necessary preflight and postflight logic
|
|
28
|
-
* @param thumbprint
|
|
29
|
-
* @param tokenEndpoint
|
|
30
|
-
* @param options
|
|
31
|
-
*/
|
|
32
|
-
sendPostRequest<T extends ServerAuthorizationTokenResponse>(thumbprint: RequestThumbprint, tokenEndpoint: string, options: NetworkRequestOptions): Promise<NetworkResponse<T>>;
|
|
33
|
-
}
|
|
34
|
-
//# sourceMappingURL=NetworkManager.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NetworkManager.d.ts","sourceRoot":"","sources":["../../src/network/NetworkManager.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAMxD,OAAO,EAAE,gCAAgC,EAAE,MAAM,iDAAiD,CAAC;AAEnG,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI;IAC7B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,IAAI,EAAE,CAAC,CAAC;IACR,MAAM,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,gBAAgB;AAChB,qBAAa,cAAc;IACvB,OAAO,CAAC,aAAa,CAAiB;IACtC,OAAO,CAAC,YAAY,CAAe;gBAEvB,aAAa,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY;IAKrE;;;;;OAKG;IACG,eAAe,CAAC,CAAC,SAAS,gCAAgC,EAC5D,UAAU,EAAE,iBAAiB,EAC7B,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,qBAAqB,GAC/B,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;CAqBjC"}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/*! @azure/msal-common v14.15.0 2024-09-20 */
|
|
2
|
-
'use strict';
|
|
3
|
-
import { ThrottlingUtils } from './ThrottlingUtils.mjs';
|
|
4
|
-
import { AuthError } from '../error/AuthError.mjs';
|
|
5
|
-
import { createClientAuthError } from '../error/ClientAuthError.mjs';
|
|
6
|
-
import { networkError } from '../error/ClientAuthErrorCodes.mjs';
|
|
7
|
-
|
|
8
|
-
/*
|
|
9
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
10
|
-
* Licensed under the MIT License.
|
|
11
|
-
*/
|
|
12
|
-
/** @internal */
|
|
13
|
-
class NetworkManager {
|
|
14
|
-
constructor(networkClient, cacheManager) {
|
|
15
|
-
this.networkClient = networkClient;
|
|
16
|
-
this.cacheManager = cacheManager;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Wraps sendPostRequestAsync with necessary preflight and postflight logic
|
|
20
|
-
* @param thumbprint
|
|
21
|
-
* @param tokenEndpoint
|
|
22
|
-
* @param options
|
|
23
|
-
*/
|
|
24
|
-
async sendPostRequest(thumbprint, tokenEndpoint, options) {
|
|
25
|
-
ThrottlingUtils.preProcess(this.cacheManager, thumbprint);
|
|
26
|
-
let response;
|
|
27
|
-
try {
|
|
28
|
-
response = await this.networkClient.sendPostRequestAsync(tokenEndpoint, options);
|
|
29
|
-
}
|
|
30
|
-
catch (e) {
|
|
31
|
-
if (e instanceof AuthError) {
|
|
32
|
-
throw e;
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
throw createClientAuthError(networkError);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
ThrottlingUtils.postProcess(this.cacheManager, thumbprint, response);
|
|
39
|
-
return response;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export { NetworkManager };
|
|
44
|
-
//# sourceMappingURL=NetworkManager.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NetworkManager.mjs","sources":["../../src/network/NetworkManager.ts"],"sourcesContent":[null],"names":["ClientAuthErrorCodes.networkError"],"mappings":";;;;;;;AAAA;;;AAGG;AA+BH;MACa,cAAc,CAAA;IAIvB,WAAY,CAAA,aAA6B,EAAE,YAA0B,EAAA;AACjE,QAAA,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;AACnC,QAAA,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;KACpC;AAED;;;;;AAKG;AACH,IAAA,MAAM,eAAe,CACjB,UAA6B,EAC7B,aAAqB,EACrB,OAA8B,EAAA;QAE9B,eAAe,CAAC,UAAU,CAAC,IAAI,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;AAE1D,QAAA,IAAI,QAAQ,CAAC;QACb,IAAI;AACA,YAAA,QAAQ,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,oBAAoB,CACpD,aAAa,EACb,OAAO,CACV,CAAC;AACL,SAAA;AAAC,QAAA,OAAO,CAAC,EAAE;YACR,IAAI,CAAC,YAAY,SAAS,EAAE;AACxB,gBAAA,MAAM,CAAC,CAAC;AACX,aAAA;AAAM,iBAAA;AACH,gBAAA,MAAM,qBAAqB,CAACA,YAAiC,CAAC,CAAC;AAClE,aAAA;AACJ,SAAA;QAED,eAAe,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;AAErE,QAAA,OAAO,QAAQ,CAAC;KACnB;AACJ;;;;"}
|