@azure/msal-common 14.7.1 → 14.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.
- package/dist/account/AccountInfo.mjs +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/cache/CacheManager.d.ts +0 -12
- package/dist/cache/CacheManager.d.ts.map +1 -1
- package/dist/cache/CacheManager.mjs +5 -14
- 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.mjs +1 -1
- package/dist/client/BaseClient.mjs +1 -1
- package/dist/client/RefreshTokenClient.mjs +1 -1
- package/dist/client/SilentFlowClient.d.ts.map +1 -1
- package/dist/client/SilentFlowClient.mjs +8 -3
- 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/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/ServerError.mjs +1 -1
- package/dist/index.cjs +406 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/logger/Logger.mjs +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.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.mjs +1 -1
- package/dist/telemetry/performance/IPerformanceClient.d.ts +1 -1
- package/dist/telemetry/performance/IPerformanceClient.d.ts.map +1 -1
- package/dist/telemetry/performance/PerformanceClient.d.ts +55 -5
- package/dist/telemetry/performance/PerformanceClient.d.ts.map +1 -1
- package/dist/telemetry/performance/PerformanceClient.mjs +183 -13
- 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 +215 -2
- 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/Constants.mjs +1 -1
- package/dist/utils/FunctionWrappers.d.ts.map +1 -1
- package/dist/utils/FunctionWrappers.mjs +3 -3
- package/dist/utils/FunctionWrappers.mjs.map +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 +1 -1
- package/src/cache/CacheManager.ts +8 -26
- package/src/client/SilentFlowClient.ts +7 -4
- package/src/packageMetadata.ts +1 -1
- package/src/telemetry/performance/IPerformanceClient.ts +4 -1
- package/src/telemetry/performance/PerformanceClient.ts +279 -16
- package/src/telemetry/performance/PerformanceEvent.ts +237 -0
- package/src/utils/FunctionWrappers.ts +12 -6
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @azure/msal-common v14.
|
|
1
|
+
/*! @azure/msal-common v14.8.0 2024-03-22 */
|
|
2
2
|
'use strict';
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
@@ -943,7 +943,7 @@ class Logger {
|
|
|
943
943
|
|
|
944
944
|
/* eslint-disable header/header */
|
|
945
945
|
const name = "@azure/msal-common";
|
|
946
|
-
const version = "14.
|
|
946
|
+
const version = "14.8.0";
|
|
947
947
|
|
|
948
948
|
/*
|
|
949
949
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3058,14 +3058,6 @@ class CacheManager {
|
|
|
3058
3058
|
* @param filter
|
|
3059
3059
|
*/
|
|
3060
3060
|
getAppMetadataFilteredBy(filter) {
|
|
3061
|
-
return this.getAppMetadataFilteredByInternal(filter.environment, filter.clientId);
|
|
3062
|
-
}
|
|
3063
|
-
/**
|
|
3064
|
-
* Support function to help match appMetadata
|
|
3065
|
-
* @param environment
|
|
3066
|
-
* @param clientId
|
|
3067
|
-
*/
|
|
3068
|
-
getAppMetadataFilteredByInternal(environment, clientId) {
|
|
3069
3061
|
const allCacheKeys = this.getKeys();
|
|
3070
3062
|
const matchingAppMetadata = {};
|
|
3071
3063
|
allCacheKeys.forEach((cacheKey) => {
|
|
@@ -3078,10 +3070,12 @@ class CacheManager {
|
|
|
3078
3070
|
if (!entity) {
|
|
3079
3071
|
return;
|
|
3080
3072
|
}
|
|
3081
|
-
if (!!environment &&
|
|
3073
|
+
if (!!filter.environment &&
|
|
3074
|
+
!this.matchEnvironment(entity, filter.environment)) {
|
|
3082
3075
|
return;
|
|
3083
3076
|
}
|
|
3084
|
-
if (!!clientId &&
|
|
3077
|
+
if (!!filter.clientId &&
|
|
3078
|
+
!this.matchClientId(entity, filter.clientId)) {
|
|
3085
3079
|
return;
|
|
3086
3080
|
}
|
|
3087
3081
|
matchingAppMetadata[cacheKey] = entity;
|
|
@@ -3868,9 +3862,6 @@ class DefaultStorageClass extends CacheManager {
|
|
|
3868
3862
|
removeItem() {
|
|
3869
3863
|
throw createClientAuthError(methodNotImplemented);
|
|
3870
3864
|
}
|
|
3871
|
-
containsKey() {
|
|
3872
|
-
throw createClientAuthError(methodNotImplemented);
|
|
3873
|
-
}
|
|
3874
3865
|
getKeys() {
|
|
3875
3866
|
throw createClientAuthError(methodNotImplemented);
|
|
3876
3867
|
}
|
|
@@ -4984,6 +4975,219 @@ const PerformanceEvents = {
|
|
|
4984
4975
|
Sha256Digest: "sha256Digest",
|
|
4985
4976
|
GetRandomValues: "getRandomValues",
|
|
4986
4977
|
};
|
|
4978
|
+
const PerformanceEventAbbreviations = new Map([
|
|
4979
|
+
[PerformanceEvents.AcquireTokenByCode, "ATByCode"],
|
|
4980
|
+
[PerformanceEvents.AcquireTokenByRefreshToken, "ATByRT"],
|
|
4981
|
+
[PerformanceEvents.AcquireTokenSilent, "ATS"],
|
|
4982
|
+
[PerformanceEvents.AcquireTokenSilentAsync, "ATSAsync"],
|
|
4983
|
+
[PerformanceEvents.AcquireTokenPopup, "ATPopup"],
|
|
4984
|
+
[PerformanceEvents.AcquireTokenRedirect, "ATRedirect"],
|
|
4985
|
+
[
|
|
4986
|
+
PerformanceEvents.CryptoOptsGetPublicKeyThumbprint,
|
|
4987
|
+
"CryptoGetPKThumb",
|
|
4988
|
+
],
|
|
4989
|
+
[PerformanceEvents.CryptoOptsSignJwt, "CryptoSignJwt"],
|
|
4990
|
+
[PerformanceEvents.SilentCacheClientAcquireToken, "SltCacheClientAT"],
|
|
4991
|
+
[PerformanceEvents.SilentIframeClientAcquireToken, "SltIframeClientAT"],
|
|
4992
|
+
[PerformanceEvents.SilentRefreshClientAcquireToken, "SltRClientAT"],
|
|
4993
|
+
[PerformanceEvents.SsoSilent, "SsoSlt"],
|
|
4994
|
+
[
|
|
4995
|
+
PerformanceEvents.StandardInteractionClientGetDiscoveredAuthority,
|
|
4996
|
+
"StdIntClientGetDiscAuth",
|
|
4997
|
+
],
|
|
4998
|
+
[
|
|
4999
|
+
PerformanceEvents.FetchAccountIdWithNativeBroker,
|
|
5000
|
+
"FetchAccIdWithNtvBroker",
|
|
5001
|
+
],
|
|
5002
|
+
[
|
|
5003
|
+
PerformanceEvents.NativeInteractionClientAcquireToken,
|
|
5004
|
+
"NtvIntClientAT",
|
|
5005
|
+
],
|
|
5006
|
+
[
|
|
5007
|
+
PerformanceEvents.BaseClientCreateTokenRequestHeaders,
|
|
5008
|
+
"BaseClientCreateTReqHead",
|
|
5009
|
+
],
|
|
5010
|
+
[
|
|
5011
|
+
PerformanceEvents.RefreshTokenClientExecutePostToTokenEndpoint,
|
|
5012
|
+
"RTClientExecPost",
|
|
5013
|
+
],
|
|
5014
|
+
[
|
|
5015
|
+
PerformanceEvents.AuthorizationCodeClientExecutePostToTokenEndpoint,
|
|
5016
|
+
"AuthCodeClientExecPost",
|
|
5017
|
+
],
|
|
5018
|
+
[PerformanceEvents.BrokerHandhshake, "BrokerHandshake"],
|
|
5019
|
+
[
|
|
5020
|
+
PerformanceEvents.AcquireTokenByRefreshTokenInBroker,
|
|
5021
|
+
"ATByRTInBroker",
|
|
5022
|
+
],
|
|
5023
|
+
[PerformanceEvents.AcquireTokenByBroker, "ATByBroker"],
|
|
5024
|
+
[
|
|
5025
|
+
PerformanceEvents.RefreshTokenClientExecuteTokenRequest,
|
|
5026
|
+
"RTClientExecTReq",
|
|
5027
|
+
],
|
|
5028
|
+
[PerformanceEvents.RefreshTokenClientAcquireToken, "RTClientAT"],
|
|
5029
|
+
[
|
|
5030
|
+
PerformanceEvents.RefreshTokenClientAcquireTokenWithCachedRefreshToken,
|
|
5031
|
+
"RTClientATWithCachedRT",
|
|
5032
|
+
],
|
|
5033
|
+
[
|
|
5034
|
+
PerformanceEvents.RefreshTokenClientAcquireTokenByRefreshToken,
|
|
5035
|
+
"RTClientATByRT",
|
|
5036
|
+
],
|
|
5037
|
+
[
|
|
5038
|
+
PerformanceEvents.RefreshTokenClientCreateTokenRequestBody,
|
|
5039
|
+
"RTClientCreateTReqBody",
|
|
5040
|
+
],
|
|
5041
|
+
[PerformanceEvents.AcquireTokenFromCache, "ATFromCache"],
|
|
5042
|
+
[
|
|
5043
|
+
PerformanceEvents.SilentFlowClientAcquireCachedToken,
|
|
5044
|
+
"SltFlowClientATCached",
|
|
5045
|
+
],
|
|
5046
|
+
[
|
|
5047
|
+
PerformanceEvents.SilentFlowClientGenerateResultFromCacheRecord,
|
|
5048
|
+
"SltFlowClientGenResFromCache",
|
|
5049
|
+
],
|
|
5050
|
+
[PerformanceEvents.AcquireTokenBySilentIframe, "ATBySltIframe"],
|
|
5051
|
+
[PerformanceEvents.InitializeBaseRequest, "InitBaseReq"],
|
|
5052
|
+
[PerformanceEvents.InitializeSilentRequest, "InitSltReq"],
|
|
5053
|
+
[
|
|
5054
|
+
PerformanceEvents.InitializeClientApplication,
|
|
5055
|
+
"InitClientApplication",
|
|
5056
|
+
],
|
|
5057
|
+
[PerformanceEvents.SilentIframeClientTokenHelper, "SIClientTHelper"],
|
|
5058
|
+
[
|
|
5059
|
+
PerformanceEvents.SilentHandlerInitiateAuthRequest,
|
|
5060
|
+
"SHandlerInitAuthReq",
|
|
5061
|
+
],
|
|
5062
|
+
[
|
|
5063
|
+
PerformanceEvents.SilentHandlerMonitorIframeForHash,
|
|
5064
|
+
"SltHandlerMonitorIframeForHash",
|
|
5065
|
+
],
|
|
5066
|
+
[PerformanceEvents.SilentHandlerLoadFrame, "SHandlerLoadFrame"],
|
|
5067
|
+
[PerformanceEvents.SilentHandlerLoadFrameSync, "SHandlerLoadFrameSync"],
|
|
5068
|
+
[
|
|
5069
|
+
PerformanceEvents.StandardInteractionClientCreateAuthCodeClient,
|
|
5070
|
+
"StdIntClientCreateAuthCodeClient",
|
|
5071
|
+
],
|
|
5072
|
+
[
|
|
5073
|
+
PerformanceEvents.StandardInteractionClientGetClientConfiguration,
|
|
5074
|
+
"StdIntClientGetClientConf",
|
|
5075
|
+
],
|
|
5076
|
+
[
|
|
5077
|
+
PerformanceEvents.StandardInteractionClientInitializeAuthorizationRequest,
|
|
5078
|
+
"StdIntClientInitAuthReq",
|
|
5079
|
+
],
|
|
5080
|
+
[
|
|
5081
|
+
PerformanceEvents.StandardInteractionClientInitializeAuthorizationCodeRequest,
|
|
5082
|
+
"StdIntClientInitAuthCodeReq",
|
|
5083
|
+
],
|
|
5084
|
+
[PerformanceEvents.GetAuthCodeUrl, "GetAuthCodeUrl"],
|
|
5085
|
+
[
|
|
5086
|
+
PerformanceEvents.HandleCodeResponseFromServer,
|
|
5087
|
+
"HandleCodeResFromServer",
|
|
5088
|
+
],
|
|
5089
|
+
[PerformanceEvents.HandleCodeResponse, "HandleCodeResp"],
|
|
5090
|
+
[PerformanceEvents.UpdateTokenEndpointAuthority, "UpdTEndpointAuth"],
|
|
5091
|
+
[PerformanceEvents.AuthClientAcquireToken, "AuthClientAT"],
|
|
5092
|
+
[PerformanceEvents.AuthClientExecuteTokenRequest, "AuthClientExecTReq"],
|
|
5093
|
+
[
|
|
5094
|
+
PerformanceEvents.AuthClientCreateTokenRequestBody,
|
|
5095
|
+
"AuthClientCreateTReqBody",
|
|
5096
|
+
],
|
|
5097
|
+
[
|
|
5098
|
+
PerformanceEvents.AuthClientCreateQueryString,
|
|
5099
|
+
"AuthClientCreateQueryStr",
|
|
5100
|
+
],
|
|
5101
|
+
[PerformanceEvents.PopTokenGenerateCnf, "PopTGenCnf"],
|
|
5102
|
+
[PerformanceEvents.PopTokenGenerateKid, "PopTGenKid"],
|
|
5103
|
+
[PerformanceEvents.HandleServerTokenResponse, "HandleServerTRes"],
|
|
5104
|
+
[PerformanceEvents.DeserializeResponse, "DeserializeRes"],
|
|
5105
|
+
[
|
|
5106
|
+
PerformanceEvents.AuthorityFactoryCreateDiscoveredInstance,
|
|
5107
|
+
"AuthFactCreateDiscInst",
|
|
5108
|
+
],
|
|
5109
|
+
[
|
|
5110
|
+
PerformanceEvents.AuthorityResolveEndpointsAsync,
|
|
5111
|
+
"AuthResolveEndpointsAsync",
|
|
5112
|
+
],
|
|
5113
|
+
[
|
|
5114
|
+
PerformanceEvents.AuthorityResolveEndpointsFromLocalSources,
|
|
5115
|
+
"AuthResolveEndpointsFromLocal",
|
|
5116
|
+
],
|
|
5117
|
+
[
|
|
5118
|
+
PerformanceEvents.AuthorityGetCloudDiscoveryMetadataFromNetwork,
|
|
5119
|
+
"AuthGetCDMetaFromNet",
|
|
5120
|
+
],
|
|
5121
|
+
[
|
|
5122
|
+
PerformanceEvents.AuthorityUpdateCloudDiscoveryMetadata,
|
|
5123
|
+
"AuthUpdCDMeta",
|
|
5124
|
+
],
|
|
5125
|
+
[
|
|
5126
|
+
PerformanceEvents.AuthorityGetEndpointMetadataFromNetwork,
|
|
5127
|
+
"AuthUpdCDMetaFromNet",
|
|
5128
|
+
],
|
|
5129
|
+
[
|
|
5130
|
+
PerformanceEvents.AuthorityUpdateEndpointMetadata,
|
|
5131
|
+
"AuthUpdEndpointMeta",
|
|
5132
|
+
],
|
|
5133
|
+
[
|
|
5134
|
+
PerformanceEvents.AuthorityUpdateMetadataWithRegionalInformation,
|
|
5135
|
+
"AuthUpdMetaWithRegInfo",
|
|
5136
|
+
],
|
|
5137
|
+
[PerformanceEvents.RegionDiscoveryDetectRegion, "RegDiscDetectReg"],
|
|
5138
|
+
[
|
|
5139
|
+
PerformanceEvents.RegionDiscoveryGetRegionFromIMDS,
|
|
5140
|
+
"RegDiscGetRegFromIMDS",
|
|
5141
|
+
],
|
|
5142
|
+
[
|
|
5143
|
+
PerformanceEvents.RegionDiscoveryGetCurrentVersion,
|
|
5144
|
+
"RegDiscGetCurrentVer",
|
|
5145
|
+
],
|
|
5146
|
+
[PerformanceEvents.AcquireTokenByCodeAsync, "ATByCodeAsync"],
|
|
5147
|
+
[
|
|
5148
|
+
PerformanceEvents.GetEndpointMetadataFromNetwork,
|
|
5149
|
+
"GetEndpointMetaFromNet",
|
|
5150
|
+
],
|
|
5151
|
+
[
|
|
5152
|
+
PerformanceEvents.GetCloudDiscoveryMetadataFromNetworkMeasurement,
|
|
5153
|
+
"GetCDMetaFromNet",
|
|
5154
|
+
],
|
|
5155
|
+
[
|
|
5156
|
+
PerformanceEvents.HandleRedirectPromiseMeasurement,
|
|
5157
|
+
"HandleRedirectPromise",
|
|
5158
|
+
],
|
|
5159
|
+
[
|
|
5160
|
+
PerformanceEvents.HandleNativeRedirectPromiseMeasurement,
|
|
5161
|
+
"HandleNtvRedirectPromise",
|
|
5162
|
+
],
|
|
5163
|
+
[
|
|
5164
|
+
PerformanceEvents.UpdateCloudDiscoveryMetadataMeasurement,
|
|
5165
|
+
"UpdateCDMeta",
|
|
5166
|
+
],
|
|
5167
|
+
[
|
|
5168
|
+
PerformanceEvents.UsernamePasswordClientAcquireToken,
|
|
5169
|
+
"UserPassClientAT",
|
|
5170
|
+
],
|
|
5171
|
+
[
|
|
5172
|
+
PerformanceEvents.NativeMessageHandlerHandshake,
|
|
5173
|
+
"NtvMsgHandlerHandshake",
|
|
5174
|
+
],
|
|
5175
|
+
[PerformanceEvents.NativeGenerateAuthResult, "NtvGenAuthRes"],
|
|
5176
|
+
[PerformanceEvents.RemoveHiddenIframe, "RemoveHiddenIframe"],
|
|
5177
|
+
[
|
|
5178
|
+
PerformanceEvents.ClearTokensAndKeysWithClaims,
|
|
5179
|
+
"ClearTAndKeysWithClaims",
|
|
5180
|
+
],
|
|
5181
|
+
[PerformanceEvents.CacheManagerGetRefreshToken, "CacheManagerGetRT"],
|
|
5182
|
+
[PerformanceEvents.GeneratePkceCodes, "GenPkceCodes"],
|
|
5183
|
+
[PerformanceEvents.GenerateCodeVerifier, "GenCodeVerifier"],
|
|
5184
|
+
[
|
|
5185
|
+
PerformanceEvents.GenerateCodeChallengeFromVerifier,
|
|
5186
|
+
"GenCodeChallengeFromVerifier",
|
|
5187
|
+
],
|
|
5188
|
+
[PerformanceEvents.Sha256Digest, "Sha256Digest"],
|
|
5189
|
+
[PerformanceEvents.GetRandomValues, "GetRandomValues"],
|
|
5190
|
+
]);
|
|
4987
5191
|
/**
|
|
4988
5192
|
* State of the performance event.
|
|
4989
5193
|
*
|
|
@@ -5053,7 +5257,7 @@ const invoke = (callback, eventName, logger, telemetryClient, correlationId) =>
|
|
|
5053
5257
|
}
|
|
5054
5258
|
inProgressEvent?.end({
|
|
5055
5259
|
success: false,
|
|
5056
|
-
});
|
|
5260
|
+
}, e);
|
|
5057
5261
|
throw e;
|
|
5058
5262
|
}
|
|
5059
5263
|
};
|
|
@@ -5099,7 +5303,7 @@ const invokeAsync = (callback, eventName, logger, telemetryClient, correlationId
|
|
|
5099
5303
|
}
|
|
5100
5304
|
inProgressEvent?.end({
|
|
5101
5305
|
success: false,
|
|
5102
|
-
});
|
|
5306
|
+
}, e);
|
|
5103
5307
|
throw e;
|
|
5104
5308
|
});
|
|
5105
5309
|
};
|
|
@@ -7459,7 +7663,12 @@ class SilentFlowClient extends BaseClient {
|
|
|
7459
7663
|
*/
|
|
7460
7664
|
async acquireToken(request) {
|
|
7461
7665
|
try {
|
|
7462
|
-
const [authResponse, cacheOutcome] = await this.acquireCachedToken(
|
|
7666
|
+
const [authResponse, cacheOutcome] = await this.acquireCachedToken({
|
|
7667
|
+
...request,
|
|
7668
|
+
scopes: request.scopes?.length
|
|
7669
|
+
? request.scopes
|
|
7670
|
+
: [...OIDC_DEFAULT_SCOPES],
|
|
7671
|
+
});
|
|
7463
7672
|
// if the token is not expired but must be refreshed; get a new one in the background
|
|
7464
7673
|
if (cacheOutcome === CacheOutcome.PROACTIVELY_REFRESHED) {
|
|
7465
7674
|
this.logger.info("SilentFlowClient:acquireCachedToken - Cached access token's refreshOn property has been exceeded'. It's not expired, but must be refreshed.");
|
|
@@ -7992,6 +8201,162 @@ class StubPerformanceClient {
|
|
|
7992
8201
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
7993
8202
|
* Licensed under the MIT License.
|
|
7994
8203
|
*/
|
|
8204
|
+
/**
|
|
8205
|
+
* Starts context by adding payload to the stack
|
|
8206
|
+
* @param event {PerformanceEvent}
|
|
8207
|
+
* @param abbreviations {Map<string, string>} event name abbreviations
|
|
8208
|
+
* @param stack {?PerformanceEventStackedContext[]} stack
|
|
8209
|
+
*/
|
|
8210
|
+
function startContext(event, abbreviations, stack) {
|
|
8211
|
+
if (!stack) {
|
|
8212
|
+
return;
|
|
8213
|
+
}
|
|
8214
|
+
stack.push({
|
|
8215
|
+
name: abbreviations.get(event.name) || event.name,
|
|
8216
|
+
});
|
|
8217
|
+
}
|
|
8218
|
+
/**
|
|
8219
|
+
* Ends context by removing payload from the stack and returning parent or self, if stack is empty, payload
|
|
8220
|
+
*
|
|
8221
|
+
* @param event {PerformanceEvent}
|
|
8222
|
+
* @param abbreviations {Map<string, string>} event name abbreviations
|
|
8223
|
+
* @param stack {?PerformanceEventStackedContext[]} stack
|
|
8224
|
+
* @param error {?unknown} error
|
|
8225
|
+
*/
|
|
8226
|
+
function endContext(event, abbreviations, stack, error) {
|
|
8227
|
+
if (!stack?.length) {
|
|
8228
|
+
return;
|
|
8229
|
+
}
|
|
8230
|
+
const peek = (stack) => {
|
|
8231
|
+
return stack.length ? stack[stack.length - 1] : undefined;
|
|
8232
|
+
};
|
|
8233
|
+
const abbrEventName = abbreviations.get(event.name) || event.name;
|
|
8234
|
+
const top = peek(stack);
|
|
8235
|
+
if (top?.name !== abbrEventName) {
|
|
8236
|
+
return;
|
|
8237
|
+
}
|
|
8238
|
+
const current = stack?.pop();
|
|
8239
|
+
if (!current) {
|
|
8240
|
+
return;
|
|
8241
|
+
}
|
|
8242
|
+
const errorCode = error instanceof AuthError
|
|
8243
|
+
? error.errorCode
|
|
8244
|
+
: error instanceof Error
|
|
8245
|
+
? error.name
|
|
8246
|
+
: undefined;
|
|
8247
|
+
const subErr = error instanceof AuthError ? error.subError : undefined;
|
|
8248
|
+
if (errorCode && current.childErr !== errorCode) {
|
|
8249
|
+
current.err = errorCode;
|
|
8250
|
+
if (subErr) {
|
|
8251
|
+
current.subErr = subErr;
|
|
8252
|
+
}
|
|
8253
|
+
}
|
|
8254
|
+
delete current.name;
|
|
8255
|
+
delete current.childErr;
|
|
8256
|
+
const context = {
|
|
8257
|
+
...current,
|
|
8258
|
+
dur: event.durationMs,
|
|
8259
|
+
};
|
|
8260
|
+
if (!event.success) {
|
|
8261
|
+
context.fail = 1;
|
|
8262
|
+
}
|
|
8263
|
+
const parent = peek(stack);
|
|
8264
|
+
if (!parent) {
|
|
8265
|
+
return { [abbrEventName]: context };
|
|
8266
|
+
}
|
|
8267
|
+
if (errorCode) {
|
|
8268
|
+
parent.childErr = errorCode;
|
|
8269
|
+
}
|
|
8270
|
+
let childName;
|
|
8271
|
+
if (!parent[abbrEventName]) {
|
|
8272
|
+
childName = abbrEventName;
|
|
8273
|
+
}
|
|
8274
|
+
else {
|
|
8275
|
+
const siblings = Object.keys(parent).filter((key) => key.startsWith(abbrEventName)).length;
|
|
8276
|
+
childName = `${abbrEventName}_${siblings + 1}`;
|
|
8277
|
+
}
|
|
8278
|
+
parent[childName] = context;
|
|
8279
|
+
return parent;
|
|
8280
|
+
}
|
|
8281
|
+
/**
|
|
8282
|
+
* Adds error name and stack trace to the telemetry event
|
|
8283
|
+
* @param error {Error}
|
|
8284
|
+
* @param logger {Logger}
|
|
8285
|
+
* @param event {PerformanceEvent}
|
|
8286
|
+
* @param stackMaxSize {number} max error stack size to capture
|
|
8287
|
+
*/
|
|
8288
|
+
function addError(error, logger, event, stackMaxSize = 5) {
|
|
8289
|
+
if (!(error instanceof Error)) {
|
|
8290
|
+
logger.trace("PerformanceClient.addErrorStack: Input error is not instance of Error", event.correlationId);
|
|
8291
|
+
return;
|
|
8292
|
+
}
|
|
8293
|
+
else if (error instanceof AuthError) {
|
|
8294
|
+
event.errorCode = error.errorCode;
|
|
8295
|
+
event.subErrorCode = error.subError;
|
|
8296
|
+
return;
|
|
8297
|
+
}
|
|
8298
|
+
else if (event.errorStack?.length) {
|
|
8299
|
+
logger.trace("PerformanceClient.addErrorStack: Stack already exist", event.correlationId);
|
|
8300
|
+
return;
|
|
8301
|
+
}
|
|
8302
|
+
else if (!error.stack?.length) {
|
|
8303
|
+
logger.trace("PerformanceClient.addErrorStack: Input stack is empty", event.correlationId);
|
|
8304
|
+
return;
|
|
8305
|
+
}
|
|
8306
|
+
if (error.stack) {
|
|
8307
|
+
event.errorStack = compactStack(error.stack, stackMaxSize);
|
|
8308
|
+
}
|
|
8309
|
+
event.errorName = error.name;
|
|
8310
|
+
}
|
|
8311
|
+
/**
|
|
8312
|
+
* Compacts error stack into array by fetching N first entries
|
|
8313
|
+
* @param stack {string} error stack
|
|
8314
|
+
* @param stackMaxSize {number} max error stack size to capture
|
|
8315
|
+
* @returns {string[]}
|
|
8316
|
+
*/
|
|
8317
|
+
function compactStack(stack, stackMaxSize) {
|
|
8318
|
+
if (stackMaxSize < 0) {
|
|
8319
|
+
return [];
|
|
8320
|
+
}
|
|
8321
|
+
const stackArr = stack.split("\n") || [];
|
|
8322
|
+
if (stackArr.length < 2) {
|
|
8323
|
+
return [];
|
|
8324
|
+
}
|
|
8325
|
+
const res = [];
|
|
8326
|
+
// Get top N stack lines
|
|
8327
|
+
for (
|
|
8328
|
+
// Skip first line as it may contain PII data
|
|
8329
|
+
let ix = Math.max(stackArr.length - stackMaxSize - 1, 1); ix < stackArr.length; ix++) {
|
|
8330
|
+
const line = stackArr[ix];
|
|
8331
|
+
if (res.length >= stackMaxSize) {
|
|
8332
|
+
break;
|
|
8333
|
+
}
|
|
8334
|
+
res.push(compactStackLine(line));
|
|
8335
|
+
}
|
|
8336
|
+
return res;
|
|
8337
|
+
}
|
|
8338
|
+
/**
|
|
8339
|
+
* Compacts error stack line by shortening file path
|
|
8340
|
+
* Example: https://localhost/msal-common/src/authority/Authority.js:100:1 -> Authority.js:100:1
|
|
8341
|
+
* @param line {string} stack line
|
|
8342
|
+
* @returns {string}
|
|
8343
|
+
*/
|
|
8344
|
+
function compactStackLine(line) {
|
|
8345
|
+
const filePathIx = line.lastIndexOf(" ") + 1;
|
|
8346
|
+
if (filePathIx < 1) {
|
|
8347
|
+
return line;
|
|
8348
|
+
}
|
|
8349
|
+
const filePath = line.substring(filePathIx);
|
|
8350
|
+
let fileNameIx = filePath.lastIndexOf("/");
|
|
8351
|
+
fileNameIx = fileNameIx < 0 ? filePath.lastIndexOf("\\") : fileNameIx;
|
|
8352
|
+
if (fileNameIx >= 0) {
|
|
8353
|
+
return (line.substring(0, filePathIx) +
|
|
8354
|
+
"(" +
|
|
8355
|
+
filePath.substring(fileNameIx + 1) +
|
|
8356
|
+
(filePath.charAt(filePath.length - 1) === ")" ? "" : ")")).trimStart();
|
|
8357
|
+
}
|
|
8358
|
+
return line.trimStart();
|
|
8359
|
+
}
|
|
7995
8360
|
class PerformanceClient {
|
|
7996
8361
|
/**
|
|
7997
8362
|
* Creates an instance of PerformanceClient,
|
|
@@ -8005,8 +8370,9 @@ class PerformanceClient {
|
|
|
8005
8370
|
* @param {string} libraryVersion Version of the library
|
|
8006
8371
|
* @param {ApplicationTelemetry} applicationTelemetry application name and version
|
|
8007
8372
|
* @param {Set<String>} intFields integer fields to be truncated
|
|
8373
|
+
* @param {Map<string, string>} abbreviations event name abbreviations
|
|
8008
8374
|
*/
|
|
8009
|
-
constructor(clientId, authority, logger, libraryName, libraryVersion, applicationTelemetry, intFields) {
|
|
8375
|
+
constructor(clientId, authority, logger, libraryName, libraryVersion, applicationTelemetry, intFields, abbreviations) {
|
|
8010
8376
|
this.authority = authority;
|
|
8011
8377
|
this.libraryName = libraryName;
|
|
8012
8378
|
this.libraryVersion = libraryVersion;
|
|
@@ -8015,12 +8381,17 @@ class PerformanceClient {
|
|
|
8015
8381
|
this.logger = logger;
|
|
8016
8382
|
this.callbacks = new Map();
|
|
8017
8383
|
this.eventsByCorrelationId = new Map();
|
|
8384
|
+
this.eventStack = new Map();
|
|
8018
8385
|
this.queueMeasurements = new Map();
|
|
8019
8386
|
this.preQueueTimeByCorrelationId = new Map();
|
|
8020
8387
|
this.intFields = intFields || new Set();
|
|
8021
8388
|
for (const item of IntFields) {
|
|
8022
8389
|
this.intFields.add(item);
|
|
8023
8390
|
}
|
|
8391
|
+
this.abbreviations = abbreviations || new Map();
|
|
8392
|
+
for (const [key, value] of PerformanceEventAbbreviations) {
|
|
8393
|
+
this.abbreviations.set(key, value);
|
|
8394
|
+
}
|
|
8024
8395
|
}
|
|
8025
8396
|
/**
|
|
8026
8397
|
* Starts and returns an platform-specific implementation of IPerformanceMeasurement.
|
|
@@ -8150,15 +8521,16 @@ class PerformanceClient {
|
|
|
8150
8521
|
};
|
|
8151
8522
|
// Store in progress events so they can be discarded if not ended properly
|
|
8152
8523
|
this.cacheEventByCorrelationId(inProgressEvent);
|
|
8524
|
+
startContext(inProgressEvent, this.abbreviations, this.eventStack.get(eventCorrelationId));
|
|
8153
8525
|
// Return the event and functions the caller can use to properly end/flush the measurement
|
|
8154
8526
|
return {
|
|
8155
|
-
end: (event) => {
|
|
8527
|
+
end: (event, error) => {
|
|
8156
8528
|
return this.endMeasurement({
|
|
8157
8529
|
// Initial set of event properties
|
|
8158
8530
|
...inProgressEvent,
|
|
8159
8531
|
// Properties set when event ends
|
|
8160
8532
|
...event,
|
|
8161
|
-
});
|
|
8533
|
+
}, error);
|
|
8162
8534
|
},
|
|
8163
8535
|
discard: () => {
|
|
8164
8536
|
return this.discardMeasurements(inProgressEvent.correlationId);
|
|
@@ -8180,10 +8552,10 @@ class PerformanceClient {
|
|
|
8180
8552
|
* otherwise.
|
|
8181
8553
|
*
|
|
8182
8554
|
* @param {PerformanceEvent} event
|
|
8183
|
-
* @param {
|
|
8555
|
+
* @param {unknown} error
|
|
8184
8556
|
* @returns {(PerformanceEvent | null)}
|
|
8185
8557
|
*/
|
|
8186
|
-
endMeasurement(event) {
|
|
8558
|
+
endMeasurement(event, error) {
|
|
8187
8559
|
const rootEvent = this.eventsByCorrelationId.get(event.correlationId);
|
|
8188
8560
|
if (!rootEvent) {
|
|
8189
8561
|
this.logger.trace(`PerformanceClient: Measurement not found for ${event.eventId}`, event.correlationId);
|
|
@@ -8195,6 +8567,8 @@ class PerformanceClient {
|
|
|
8195
8567
|
totalQueueCount: 0,
|
|
8196
8568
|
manuallyCompletedCount: 0,
|
|
8197
8569
|
};
|
|
8570
|
+
event.durationMs = Math.round(event.durationMs || this.getDurationMs(event.startTimeMs));
|
|
8571
|
+
const context = endContext(event, this.abbreviations, this.eventStack.get(rootEvent.correlationId), error);
|
|
8198
8572
|
if (isRoot) {
|
|
8199
8573
|
queueInfo = this.getQueueInfo(event.correlationId);
|
|
8200
8574
|
this.discardCache(rootEvent.correlationId);
|
|
@@ -8202,13 +8576,15 @@ class PerformanceClient {
|
|
|
8202
8576
|
else {
|
|
8203
8577
|
rootEvent.incompleteSubMeasurements?.delete(event.eventId);
|
|
8204
8578
|
}
|
|
8205
|
-
|
|
8206
|
-
this.logger.trace(`PerformanceClient: Performance measurement ended for ${event.name}: ${durationMs} ms`, event.correlationId);
|
|
8579
|
+
this.logger.trace(`PerformanceClient: Performance measurement ended for ${event.name}: ${event.durationMs} ms`, event.correlationId);
|
|
8207
8580
|
// Add sub-measurement attribute to root event.
|
|
8208
8581
|
if (!isRoot) {
|
|
8209
|
-
rootEvent[event.name + "DurationMs"] = Math.floor(durationMs);
|
|
8582
|
+
rootEvent[event.name + "DurationMs"] = Math.floor(event.durationMs);
|
|
8210
8583
|
return { ...rootEvent };
|
|
8211
8584
|
}
|
|
8585
|
+
if (error) {
|
|
8586
|
+
addError(error, this.logger, rootEvent);
|
|
8587
|
+
}
|
|
8212
8588
|
let finalEvent = { ...rootEvent, ...event };
|
|
8213
8589
|
let incompleteSubsCount = 0;
|
|
8214
8590
|
// Incomplete sub-measurements are discarded. They are likely an instrumentation bug that should be fixed.
|
|
@@ -8219,12 +8595,12 @@ class PerformanceClient {
|
|
|
8219
8595
|
finalEvent.incompleteSubMeasurements = undefined;
|
|
8220
8596
|
finalEvent = {
|
|
8221
8597
|
...finalEvent,
|
|
8222
|
-
durationMs: Math.round(durationMs),
|
|
8223
8598
|
queuedTimeMs: queueInfo.totalQueueTime,
|
|
8224
8599
|
queuedCount: queueInfo.totalQueueCount,
|
|
8225
8600
|
queuedManuallyCompletedCount: queueInfo.manuallyCompletedCount,
|
|
8226
8601
|
status: PerformanceEventStatus.Completed,
|
|
8227
8602
|
incompleteSubsCount,
|
|
8603
|
+
context,
|
|
8228
8604
|
};
|
|
8229
8605
|
this.truncateIntegralFields(finalEvent);
|
|
8230
8606
|
this.emitEvents([finalEvent], event.correlationId);
|
|
@@ -8294,6 +8670,7 @@ class PerformanceClient {
|
|
|
8294
8670
|
else {
|
|
8295
8671
|
this.logger.trace(`PerformanceClient: Performance measurement for ${event.name} started`, event.correlationId);
|
|
8296
8672
|
this.eventsByCorrelationId.set(event.correlationId, { ...event });
|
|
8673
|
+
this.eventStack.set(event.correlationId, []);
|
|
8297
8674
|
}
|
|
8298
8675
|
}
|
|
8299
8676
|
getQueueInfo(correlationId) {
|
|
@@ -8335,6 +8712,8 @@ class PerformanceClient {
|
|
|
8335
8712
|
this.queueMeasurements.delete(correlationId);
|
|
8336
8713
|
this.logger.trace("PerformanceClient: Pre-queue times discarded", correlationId);
|
|
8337
8714
|
this.preQueueTimeByCorrelationId.delete(correlationId);
|
|
8715
|
+
this.logger.trace("PerformanceClient: Event stack discarded", correlationId);
|
|
8716
|
+
this.eventStack.delete(correlationId);
|
|
8338
8717
|
}
|
|
8339
8718
|
/**
|
|
8340
8719
|
* Registers a callback function to receive performance events.
|
|
@@ -8380,7 +8759,6 @@ class PerformanceClient {
|
|
|
8380
8759
|
/**
|
|
8381
8760
|
* Enforce truncation of integral fields in performance event.
|
|
8382
8761
|
* @param {PerformanceEvent} event performance event to update.
|
|
8383
|
-
* @param {Set<string>} intFields integral fields.
|
|
8384
8762
|
*/
|
|
8385
8763
|
truncateIntegralFields(event) {
|
|
8386
8764
|
this.intFields.forEach((key) => {
|