@azure/msal-common 14.14.2 → 14.16.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/browser/README.md +1 -0
- package/browser/package.json +5 -0
- package/dist/account/AccountInfo.d.ts +1 -1
- package/dist/account/AccountInfo.d.ts.map +1 -1
- package/dist/account/AccountInfo.mjs +1 -1
- package/dist/account/AuthToken.d.ts +1 -1
- package/dist/account/AuthToken.d.ts.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.d.ts +12 -12
- package/dist/authority/Authority.d.ts.map +1 -1
- package/dist/authority/Authority.mjs +1 -1
- package/dist/authority/AuthorityFactory.d.ts +6 -6
- package/dist/authority/AuthorityFactory.d.ts.map +1 -1
- package/dist/authority/AuthorityFactory.mjs +1 -1
- package/dist/authority/AuthorityMetadata.d.ts +6 -6
- package/dist/authority/AuthorityMetadata.d.ts.map +1 -1
- package/dist/authority/AuthorityMetadata.mjs +1 -1
- package/dist/authority/AuthorityOptions.d.ts +4 -4
- package/dist/authority/AuthorityOptions.d.ts.map +1 -1
- package/dist/authority/AuthorityOptions.mjs +1 -1
- package/dist/authority/AuthorityType.mjs +1 -1
- package/dist/authority/AzureRegionConfiguration.d.ts +1 -1
- package/dist/authority/AzureRegionConfiguration.d.ts.map +1 -1
- package/dist/authority/CloudInstanceDiscoveryErrorResponse.mjs +1 -1
- package/dist/authority/CloudInstanceDiscoveryResponse.d.ts +1 -1
- package/dist/authority/CloudInstanceDiscoveryResponse.d.ts.map +1 -1
- package/dist/authority/CloudInstanceDiscoveryResponse.mjs +1 -1
- package/dist/authority/OIDCOptions.d.ts +1 -1
- package/dist/authority/OIDCOptions.d.ts.map +1 -1
- package/dist/authority/OpenIdConfigResponse.mjs +1 -1
- package/dist/authority/ProtocolMode.mjs +1 -1
- package/dist/authority/RegionDiscovery.d.ts +5 -5
- package/dist/authority/RegionDiscovery.d.ts.map +1 -1
- package/dist/authority/RegionDiscovery.mjs +1 -1
- package/dist/authority/RegionDiscoveryMetadata.d.ts +1 -1
- package/dist/authority/RegionDiscoveryMetadata.d.ts.map +1 -1
- package/dist/broker/nativeBroker/INativeBrokerPlugin.d.ts +6 -6
- package/dist/broker/nativeBroker/INativeBrokerPlugin.d.ts.map +1 -1
- package/dist/cache/CacheManager.d.ts +18 -23
- package/dist/cache/CacheManager.d.ts.map +1 -1
- package/dist/cache/CacheManager.mjs +1 -4
- package/dist/cache/CacheManager.mjs.map +1 -1
- package/dist/cache/entities/AccessTokenEntity.d.ts +2 -2
- package/dist/cache/entities/AccessTokenEntity.d.ts.map +1 -1
- package/dist/cache/entities/AccountEntity.d.ts +6 -6
- package/dist/cache/entities/AccountEntity.d.ts.map +1 -1
- package/dist/cache/entities/AccountEntity.mjs +1 -1
- package/dist/cache/entities/CacheRecord.d.ts +5 -5
- package/dist/cache/entities/CacheRecord.d.ts.map +1 -1
- package/dist/cache/entities/CredentialEntity.d.ts +1 -1
- package/dist/cache/entities/CredentialEntity.d.ts.map +1 -1
- package/dist/cache/entities/IdTokenEntity.d.ts +1 -1
- package/dist/cache/entities/IdTokenEntity.d.ts.map +1 -1
- package/dist/cache/entities/RefreshTokenEntity.d.ts +1 -1
- package/dist/cache/entities/RefreshTokenEntity.d.ts.map +1 -1
- package/dist/cache/interface/ICacheManager.d.ts +12 -12
- package/dist/cache/interface/ICacheManager.d.ts.map +1 -1
- package/dist/cache/interface/ICachePlugin.d.ts +1 -1
- package/dist/cache/interface/ICachePlugin.d.ts.map +1 -1
- package/dist/cache/persistence/TokenCacheContext.d.ts +1 -1
- package/dist/cache/persistence/TokenCacheContext.d.ts.map +1 -1
- package/dist/cache/persistence/TokenCacheContext.mjs +1 -1
- package/dist/cache/utils/CacheHelpers.d.ts +9 -9
- package/dist/cache/utils/CacheHelpers.d.ts.map +1 -1
- package/dist/cache/utils/CacheHelpers.mjs +1 -1
- package/dist/cache/utils/CacheTypes.d.ts +11 -11
- package/dist/cache/utils/CacheTypes.d.ts.map +1 -1
- package/dist/client/AuthorizationCodeClient.d.ts +10 -9
- package/dist/client/AuthorizationCodeClient.d.ts.map +1 -1
- package/dist/client/AuthorizationCodeClient.mjs +35 -16
- package/dist/client/AuthorizationCodeClient.mjs.map +1 -1
- package/dist/client/BaseClient.d.ts +21 -14
- 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 +6 -6
- package/dist/client/RefreshTokenClient.d.ts.map +1 -1
- package/dist/client/RefreshTokenClient.mjs +10 -4
- package/dist/client/RefreshTokenClient.mjs.map +1 -1
- package/dist/client/SilentFlowClient.d.ts +6 -6
- package/dist/client/SilentFlowClient.d.ts.map +1 -1
- package/dist/client/SilentFlowClient.mjs +1 -1
- package/dist/config/ClientConfiguration.d.ts +15 -11
- package/dist/config/ClientConfiguration.d.ts.map +1 -1
- package/dist/config/ClientConfiguration.mjs +2 -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.d.ts +2 -2
- package/dist/crypto/ICrypto.d.ts.map +1 -1
- package/dist/crypto/ICrypto.mjs +1 -1
- package/dist/crypto/JoseHeader.d.ts +1 -1
- package/dist/crypto/JoseHeader.d.ts.map +1 -1
- package/dist/crypto/JoseHeader.mjs +1 -1
- package/dist/crypto/PopTokenGenerator.d.ts +3 -3
- package/dist/crypto/PopTokenGenerator.d.ts.map +1 -1
- package/dist/crypto/PopTokenGenerator.mjs +1 -1
- package/dist/crypto/SignedHttpRequest.d.ts +1 -1
- package/dist/crypto/SignedHttpRequest.d.ts.map +1 -1
- package/dist/error/AuthError.d.ts +1 -1
- package/dist/error/AuthError.d.ts.map +1 -1
- package/dist/error/AuthError.mjs +1 -1
- package/dist/error/AuthErrorCodes.mjs +1 -1
- package/dist/error/CacheError.d.ts +1 -1
- package/dist/error/CacheError.d.ts.map +1 -1
- package/dist/error/CacheError.mjs +1 -1
- package/dist/error/CacheErrorCodes.mjs +1 -1
- package/dist/error/ClientAuthError.d.ts +2 -2
- package/dist/error/ClientAuthError.d.ts.map +1 -1
- package/dist/error/ClientAuthError.mjs +1 -1
- package/dist/error/ClientAuthErrorCodes.mjs +1 -1
- package/dist/error/ClientConfigurationError.d.ts +2 -2
- package/dist/error/ClientConfigurationError.d.ts.map +1 -1
- package/dist/error/ClientConfigurationError.mjs +1 -1
- package/dist/error/ClientConfigurationErrorCodes.mjs +1 -1
- package/dist/error/InteractionRequiredAuthError.d.ts +2 -2
- package/dist/error/InteractionRequiredAuthError.d.ts.map +1 -1
- package/dist/error/InteractionRequiredAuthError.mjs +1 -1
- package/dist/error/InteractionRequiredAuthErrorCodes.mjs +1 -1
- package/dist/error/JoseHeaderError.d.ts +2 -2
- package/dist/error/JoseHeaderError.d.ts.map +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.d.ts +1 -1
- package/dist/error/ServerError.d.ts.map +1 -1
- package/dist/error/ServerError.mjs +1 -1
- package/dist/exports-browser-only.d.ts +10 -0
- package/dist/exports-browser-only.d.ts.map +1 -0
- package/dist/exports-common.d.ts +81 -0
- package/dist/exports-common.d.ts.map +1 -0
- package/dist/exports-node-only.d.ts +18 -0
- package/dist/exports-node-only.d.ts.map +1 -0
- package/dist/index-browser.d.ts +7 -0
- package/dist/index-browser.d.ts.map +1 -0
- package/dist/index-browser.mjs +67 -0
- package/dist/index-browser.mjs.map +1 -0
- package/dist/index-node.d.ts +7 -0
- package/dist/index-node.d.ts.map +1 -0
- package/dist/index-node.mjs +66 -0
- package/dist/index-node.mjs.map +1 -0
- package/dist/index.d.ts +7 -103
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +31 -31
- package/dist/logger/Logger.d.ts +1 -1
- package/dist/logger/Logger.d.ts.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/NetworkResponse.d.ts +6 -0
- package/dist/network/NetworkResponse.d.ts.map +1 -0
- package/dist/network/RequestThumbprint.d.ts +2 -2
- package/dist/network/RequestThumbprint.d.ts.map +1 -1
- package/dist/network/ThrottlingUtils.d.ts +5 -5
- package/dist/network/ThrottlingUtils.d.ts.map +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/BaseAuthRequest.d.ts +7 -5
- package/dist/request/BaseAuthRequest.d.ts.map +1 -1
- package/dist/request/CommonAuthorizationCodeRequest.d.ts +3 -3
- package/dist/request/CommonAuthorizationCodeRequest.d.ts.map +1 -1
- package/dist/request/CommonAuthorizationUrlRequest.d.ts +4 -4
- package/dist/request/CommonAuthorizationUrlRequest.d.ts.map +1 -1
- package/dist/request/CommonClientCredentialRequest.d.ts +3 -3
- package/dist/request/CommonClientCredentialRequest.d.ts.map +1 -1
- package/dist/request/CommonDeviceCodeRequest.d.ts +3 -3
- package/dist/request/CommonDeviceCodeRequest.d.ts.map +1 -1
- package/dist/request/CommonEndSessionRequest.d.ts +2 -2
- package/dist/request/CommonEndSessionRequest.d.ts.map +1 -1
- package/dist/request/CommonOnBehalfOfRequest.d.ts +1 -1
- package/dist/request/CommonOnBehalfOfRequest.d.ts.map +1 -1
- package/dist/request/CommonRefreshTokenRequest.d.ts +3 -3
- package/dist/request/CommonRefreshTokenRequest.d.ts.map +1 -1
- package/dist/request/CommonSilentFlowRequest.d.ts +3 -3
- package/dist/request/CommonSilentFlowRequest.d.ts.map +1 -1
- package/dist/request/CommonUsernamePasswordRequest.d.ts +1 -1
- package/dist/request/CommonUsernamePasswordRequest.d.ts.map +1 -1
- package/dist/request/NativeRequest.d.ts +1 -1
- package/dist/request/NativeRequest.d.ts.map +1 -1
- package/dist/request/RequestParameterBuilder.d.ts +13 -6
- 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/AuthenticationResult.d.ts +1 -1
- package/dist/response/AuthenticationResult.d.ts.map +1 -1
- package/dist/response/ExternalTokenResponse.d.ts +1 -1
- package/dist/response/ExternalTokenResponse.d.ts.map +1 -1
- package/dist/response/ResponseHandler.d.ts +16 -16
- package/dist/response/ResponseHandler.d.ts.map +1 -1
- package/dist/response/ResponseHandler.mjs +1 -1
- package/dist/response/ServerAuthorizationTokenResponse.d.ts +1 -1
- package/dist/response/ServerAuthorizationTokenResponse.d.ts.map +1 -1
- package/dist/telemetry/performance/IPerformanceClient.d.ts +2 -2
- package/dist/telemetry/performance/IPerformanceClient.d.ts.map +1 -1
- package/dist/telemetry/performance/PerformanceClient.d.ts +5 -5
- 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.d.ts +3 -3
- package/dist/telemetry/performance/StubPerformanceClient.d.ts.map +1 -1
- package/dist/telemetry/performance/StubPerformanceClient.mjs +1 -1
- package/dist/telemetry/performance/StubPerformanceClient.mjs.map +1 -1
- package/dist/telemetry/server/ServerTelemetryManager.d.ts +5 -5
- package/dist/telemetry/server/ServerTelemetryManager.d.ts.map +1 -1
- package/dist/telemetry/server/ServerTelemetryManager.mjs +1 -1
- package/dist/url/UrlString.d.ts +1 -1
- package/dist/url/UrlString.d.ts.map +1 -1
- package/dist/url/UrlString.mjs +1 -1
- package/dist/utils/ClientAssertionUtils.d.ts +1 -1
- package/dist/utils/ClientAssertionUtils.d.ts.map +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.d.ts +2 -2
- package/dist/utils/FunctionWrappers.d.ts.map +1 -1
- package/dist/utils/FunctionWrappers.mjs +1 -1
- package/dist/utils/ProtocolUtils.d.ts +1 -1
- package/dist/utils/ProtocolUtils.d.ts.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.d.ts +1 -1
- package/dist/utils/UrlUtils.d.ts.map +1 -1
- package/dist/utils/UrlUtils.mjs +1 -1
- package/lib/index-browser.cjs +858 -0
- package/lib/index-browser.cjs.map +1 -0
- package/{dist/index.cjs → lib/index-node-C9XsExml.js} +352 -990
- package/lib/index-node-C9XsExml.js.map +1 -0
- package/lib/index-node.cjs +104 -0
- package/lib/index-node.cjs.map +1 -0
- package/lib/index.cjs +112 -0
- package/lib/index.cjs.map +1 -0
- package/lib/package.json +1 -0
- package/lib/types/account/AccountInfo.d.ts +67 -0
- package/lib/types/account/AccountInfo.d.ts.map +1 -0
- package/lib/types/account/AuthToken.d.ts +18 -0
- package/lib/types/account/AuthToken.d.ts.map +1 -0
- package/lib/types/account/CcsCredential.d.ts +10 -0
- package/lib/types/account/CcsCredential.d.ts.map +1 -0
- package/lib/types/account/ClientCredentials.d.ts +20 -0
- package/lib/types/account/ClientCredentials.d.ts.map +1 -0
- package/lib/types/account/ClientInfo.d.ts +19 -0
- package/lib/types/account/ClientInfo.d.ts.map +1 -0
- package/lib/types/account/TokenClaims.d.ts +84 -0
- package/lib/types/account/TokenClaims.d.ts.map +1 -0
- package/lib/types/authority/Authority.d.ts +255 -0
- package/lib/types/authority/Authority.d.ts.map +1 -0
- package/lib/types/authority/AuthorityFactory.d.ts +19 -0
- package/lib/types/authority/AuthorityFactory.d.ts.map +1 -0
- package/lib/types/authority/AuthorityMetadata.d.ts +44 -0
- package/lib/types/authority/AuthorityMetadata.d.ts.map +1 -0
- package/lib/types/authority/AuthorityOptions.d.ts +28 -0
- package/lib/types/authority/AuthorityOptions.d.ts.map +1 -0
- package/lib/types/authority/AuthorityType.d.ts +11 -0
- package/lib/types/authority/AuthorityType.d.ts.map +1 -0
- package/lib/types/authority/AzureRegion.d.ts +2 -0
- package/lib/types/authority/AzureRegion.d.ts.map +1 -0
- package/lib/types/authority/AzureRegionConfiguration.d.ts +6 -0
- package/lib/types/authority/AzureRegionConfiguration.d.ts.map +1 -0
- package/lib/types/authority/CloudDiscoveryMetadata.d.ts +6 -0
- package/lib/types/authority/CloudDiscoveryMetadata.d.ts.map +1 -0
- package/lib/types/authority/CloudInstanceDiscoveryErrorResponse.d.ts +14 -0
- package/lib/types/authority/CloudInstanceDiscoveryErrorResponse.d.ts.map +1 -0
- package/lib/types/authority/CloudInstanceDiscoveryResponse.d.ts +10 -0
- package/lib/types/authority/CloudInstanceDiscoveryResponse.d.ts.map +1 -0
- package/lib/types/authority/ImdsOptions.d.ts +6 -0
- package/lib/types/authority/ImdsOptions.d.ts.map +1 -0
- package/lib/types/authority/OIDCOptions.d.ts +9 -0
- package/lib/types/authority/OIDCOptions.d.ts.map +1 -0
- package/lib/types/authority/OpenIdConfigResponse.d.ts +12 -0
- package/lib/types/authority/OpenIdConfigResponse.d.ts.map +1 -0
- package/lib/types/authority/ProtocolMode.d.ts +9 -0
- package/lib/types/authority/ProtocolMode.d.ts.map +1 -0
- package/lib/types/authority/RegionDiscovery.d.ts +33 -0
- package/lib/types/authority/RegionDiscovery.d.ts.map +1 -0
- package/lib/types/authority/RegionDiscoveryMetadata.d.ts +7 -0
- package/lib/types/authority/RegionDiscoveryMetadata.d.ts.map +1 -0
- package/lib/types/broker/nativeBroker/INativeBrokerPlugin.d.ts +16 -0
- package/lib/types/broker/nativeBroker/INativeBrokerPlugin.d.ts.map +1 -0
- package/lib/types/cache/CacheManager.d.ts +493 -0
- package/lib/types/cache/CacheManager.d.ts.map +1 -0
- package/lib/types/cache/entities/AccessTokenEntity.d.ts +26 -0
- package/lib/types/cache/entities/AccessTokenEntity.d.ts.map +1 -0
- package/lib/types/cache/entities/AccountEntity.d.ts +107 -0
- package/lib/types/cache/entities/AccountEntity.d.ts.map +1 -0
- package/lib/types/cache/entities/AppMetadataEntity.d.ts +12 -0
- package/lib/types/cache/entities/AppMetadataEntity.d.ts.map +1 -0
- package/lib/types/cache/entities/AuthorityMetadataEntity.d.ts +16 -0
- package/lib/types/cache/entities/AuthorityMetadataEntity.d.ts.map +1 -0
- package/lib/types/cache/entities/CacheRecord.d.ts +14 -0
- package/lib/types/cache/entities/CacheRecord.d.ts.map +1 -0
- package/lib/types/cache/entities/CredentialEntity.d.ts +31 -0
- package/lib/types/cache/entities/CredentialEntity.d.ts.map +1 -0
- package/lib/types/cache/entities/IdTokenEntity.d.ts +9 -0
- package/lib/types/cache/entities/IdTokenEntity.d.ts.map +1 -0
- package/lib/types/cache/entities/RefreshTokenEntity.d.ts +8 -0
- package/lib/types/cache/entities/RefreshTokenEntity.d.ts.map +1 -0
- package/lib/types/cache/entities/ServerTelemetryEntity.d.ts +7 -0
- package/lib/types/cache/entities/ServerTelemetryEntity.d.ts.map +1 -0
- package/lib/types/cache/entities/ThrottlingEntity.d.ts +8 -0
- package/lib/types/cache/entities/ThrottlingEntity.d.ts.map +1 -0
- package/lib/types/cache/interface/ICacheManager.d.ts +167 -0
- package/lib/types/cache/interface/ICacheManager.d.ts.map +1 -0
- package/lib/types/cache/interface/ICachePlugin.d.ts +6 -0
- package/lib/types/cache/interface/ICachePlugin.d.ts.map +1 -0
- package/lib/types/cache/interface/ISerializableTokenCache.d.ts +5 -0
- package/lib/types/cache/interface/ISerializableTokenCache.d.ts.map +1 -0
- package/lib/types/cache/persistence/TokenCacheContext.d.ts +24 -0
- package/lib/types/cache/persistence/TokenCacheContext.d.ts.map +1 -0
- package/lib/types/cache/utils/CacheHelpers.d.ts +95 -0
- package/lib/types/cache/utils/CacheHelpers.d.ts.map +1 -0
- package/lib/types/cache/utils/CacheTypes.d.ts +70 -0
- package/lib/types/cache/utils/CacheTypes.d.ts.map +1 -0
- package/lib/types/client/AuthorizationCodeClient.d.ts +76 -0
- package/lib/types/client/AuthorizationCodeClient.d.ts.map +1 -0
- package/lib/types/client/BaseClient.d.ts +59 -0
- package/lib/types/client/BaseClient.d.ts.map +1 -0
- package/lib/types/client/RefreshTokenClient.d.ts +36 -0
- package/lib/types/client/RefreshTokenClient.d.ts.map +1 -0
- package/lib/types/client/SilentFlowClient.d.ts +28 -0
- package/lib/types/client/SilentFlowClient.d.ts.map +1 -0
- package/lib/types/config/AppTokenProvider.d.ts +39 -0
- package/lib/types/config/AppTokenProvider.d.ts.map +1 -0
- package/lib/types/config/ClientConfiguration.d.ts +155 -0
- package/lib/types/config/ClientConfiguration.d.ts.map +1 -0
- package/lib/types/constants/AADServerParamKeys.d.ts +56 -0
- package/lib/types/constants/AADServerParamKeys.d.ts.map +1 -0
- package/lib/types/crypto/ICrypto.d.ts +69 -0
- package/lib/types/crypto/ICrypto.d.ts.map +1 -0
- package/lib/types/crypto/IGuidGenerator.d.ts +5 -0
- package/lib/types/crypto/IGuidGenerator.d.ts.map +1 -0
- package/lib/types/crypto/JoseHeader.d.ts +23 -0
- package/lib/types/crypto/JoseHeader.d.ts.map +1 -0
- package/lib/types/crypto/PopTokenGenerator.d.ts +60 -0
- package/lib/types/crypto/PopTokenGenerator.d.ts.map +1 -0
- package/lib/types/crypto/SignedHttpRequest.d.ts +16 -0
- package/lib/types/crypto/SignedHttpRequest.d.ts.map +1 -0
- package/lib/types/error/AuthError.d.ts +45 -0
- package/lib/types/error/AuthError.d.ts.map +1 -0
- package/lib/types/error/AuthErrorCodes.d.ts +6 -0
- package/lib/types/error/AuthErrorCodes.d.ts.map +1 -0
- package/lib/types/error/CacheError.d.ts +21 -0
- package/lib/types/error/CacheError.d.ts.map +1 -0
- package/lib/types/error/CacheErrorCodes.d.ts +3 -0
- package/lib/types/error/CacheErrorCodes.d.ts.map +1 -0
- package/lib/types/error/ClientAuthError.d.ts +238 -0
- package/lib/types/error/ClientAuthError.d.ts.map +1 -0
- package/lib/types/error/ClientAuthErrorCodes.d.ts +45 -0
- package/lib/types/error/ClientAuthErrorCodes.d.ts.map +1 -0
- package/lib/types/error/ClientConfigurationError.d.ts +129 -0
- package/lib/types/error/ClientConfigurationError.d.ts.map +1 -0
- package/lib/types/error/ClientConfigurationErrorCodes.d.ts +23 -0
- package/lib/types/error/ClientConfigurationErrorCodes.d.ts.map +1 -0
- package/lib/types/error/InteractionRequiredAuthError.d.ts +66 -0
- package/lib/types/error/InteractionRequiredAuthError.d.ts.map +1 -0
- package/lib/types/error/InteractionRequiredAuthErrorCodes.d.ts +8 -0
- package/lib/types/error/InteractionRequiredAuthErrorCodes.d.ts.map +1 -0
- package/lib/types/error/JoseHeaderError.d.ts +16 -0
- package/lib/types/error/JoseHeaderError.d.ts.map +1 -0
- package/lib/types/error/JoseHeaderErrorCodes.d.ts +3 -0
- package/lib/types/error/JoseHeaderErrorCodes.d.ts.map +1 -0
- package/lib/types/error/NetworkError.d.ts +19 -0
- package/lib/types/error/NetworkError.d.ts.map +1 -0
- package/lib/types/error/ServerError.d.ts +16 -0
- package/lib/types/error/ServerError.d.ts.map +1 -0
- package/lib/types/exports-browser-only.d.ts +10 -0
- package/lib/types/exports-browser-only.d.ts.map +1 -0
- package/lib/types/exports-common.d.ts +81 -0
- package/lib/types/exports-common.d.ts.map +1 -0
- package/lib/types/exports-node-only.d.ts +18 -0
- package/lib/types/exports-node-only.d.ts.map +1 -0
- package/lib/types/index-browser.d.ts +7 -0
- package/lib/types/index-browser.d.ts.map +1 -0
- package/lib/types/index-node.d.ts +7 -0
- package/lib/types/index-node.d.ts.map +1 -0
- package/lib/types/index.d.ts +12 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/logger/Logger.d.ts +96 -0
- package/lib/types/logger/Logger.d.ts.map +1 -0
- package/lib/types/network/INetworkModule.d.ts +30 -0
- package/lib/types/network/INetworkModule.d.ts.map +1 -0
- package/lib/types/network/NetworkResponse.d.ts +6 -0
- package/lib/types/network/NetworkResponse.d.ts.map +1 -0
- package/lib/types/network/RequestThumbprint.d.ts +19 -0
- package/lib/types/network/RequestThumbprint.d.ts.map +1 -0
- package/lib/types/network/ThrottlingUtils.d.ts +43 -0
- package/lib/types/network/ThrottlingUtils.d.ts.map +1 -0
- package/lib/types/packageMetadata.d.ts +3 -0
- package/lib/types/packageMetadata.d.ts.map +1 -0
- package/lib/types/request/AuthenticationHeaderParser.d.ts +20 -0
- package/lib/types/request/AuthenticationHeaderParser.d.ts.map +1 -0
- package/lib/types/request/BaseAuthRequest.d.ts +50 -0
- package/lib/types/request/BaseAuthRequest.d.ts.map +1 -0
- package/lib/types/request/CommonAuthorizationCodeRequest.d.ts +28 -0
- package/lib/types/request/CommonAuthorizationCodeRequest.d.ts.map +1 -0
- package/lib/types/request/CommonAuthorizationUrlRequest.d.ts +51 -0
- package/lib/types/request/CommonAuthorizationUrlRequest.d.ts.map +1 -0
- package/lib/types/request/CommonClientCredentialRequest.d.ts +18 -0
- package/lib/types/request/CommonClientCredentialRequest.d.ts.map +1 -0
- package/lib/types/request/CommonDeviceCodeRequest.d.ts +22 -0
- package/lib/types/request/CommonDeviceCodeRequest.d.ts.map +1 -0
- package/lib/types/request/CommonEndSessionRequest.d.ts +22 -0
- package/lib/types/request/CommonEndSessionRequest.d.ts.map +1 -0
- package/lib/types/request/CommonOnBehalfOfRequest.d.ts +14 -0
- package/lib/types/request/CommonOnBehalfOfRequest.d.ts.map +1 -0
- package/lib/types/request/CommonRefreshTokenRequest.d.ts +23 -0
- package/lib/types/request/CommonRefreshTokenRequest.d.ts.map +1 -0
- package/lib/types/request/CommonSilentFlowRequest.d.ts +28 -0
- package/lib/types/request/CommonSilentFlowRequest.d.ts.map +1 -0
- package/lib/types/request/CommonUsernamePasswordRequest.d.ts +18 -0
- package/lib/types/request/CommonUsernamePasswordRequest.d.ts.map +1 -0
- package/lib/types/request/NativeRequest.d.ts +20 -0
- package/lib/types/request/NativeRequest.d.ts.map +1 -0
- package/lib/types/request/NativeSignOutRequest.d.ts +6 -0
- package/lib/types/request/NativeSignOutRequest.d.ts.map +1 -0
- package/lib/types/request/RequestParameterBuilder.d.ts +225 -0
- package/lib/types/request/RequestParameterBuilder.d.ts.map +1 -0
- package/lib/types/request/RequestValidator.d.ts +28 -0
- package/lib/types/request/RequestValidator.d.ts.map +1 -0
- package/lib/types/request/ScopeSet.d.ts +89 -0
- package/lib/types/request/ScopeSet.d.ts.map +1 -0
- package/lib/types/request/StoreInCache.d.ts +9 -0
- package/lib/types/request/StoreInCache.d.ts.map +1 -0
- package/lib/types/response/AuthenticationResult.d.ts +42 -0
- package/lib/types/response/AuthenticationResult.d.ts.map +1 -0
- package/lib/types/response/AuthorizationCodePayload.d.ts +14 -0
- package/lib/types/response/AuthorizationCodePayload.d.ts.map +1 -0
- package/lib/types/response/DeviceCodeResponse.d.ts +26 -0
- package/lib/types/response/DeviceCodeResponse.d.ts.map +1 -0
- package/lib/types/response/ExternalTokenResponse.d.ts +16 -0
- package/lib/types/response/ExternalTokenResponse.d.ts.map +1 -0
- package/lib/types/response/IMDSBadResponse.d.ts +5 -0
- package/lib/types/response/IMDSBadResponse.d.ts.map +1 -0
- package/lib/types/response/ResponseHandler.d.ts +70 -0
- package/lib/types/response/ResponseHandler.d.ts.map +1 -0
- package/lib/types/response/ServerAuthorizationCodeResponse.d.ts +27 -0
- package/lib/types/response/ServerAuthorizationCodeResponse.d.ts.map +1 -0
- package/lib/types/response/ServerAuthorizationTokenResponse.d.ts +48 -0
- package/lib/types/response/ServerAuthorizationTokenResponse.d.ts.map +1 -0
- package/lib/types/telemetry/performance/IPerformanceClient.d.ts +58 -0
- package/lib/types/telemetry/performance/IPerformanceClient.d.ts.map +1 -0
- package/lib/types/telemetry/performance/IPerformanceMeasurement.d.ts +6 -0
- package/lib/types/telemetry/performance/IPerformanceMeasurement.d.ts.map +1 -0
- package/lib/types/telemetry/performance/PerformanceClient.d.ts +243 -0
- package/lib/types/telemetry/performance/PerformanceClient.d.ts.map +1 -0
- package/lib/types/telemetry/performance/PerformanceEvent.d.ts +521 -0
- package/lib/types/telemetry/performance/PerformanceEvent.d.ts.map +1 -0
- package/lib/types/telemetry/performance/StubPerformanceClient.d.ts +25 -0
- package/lib/types/telemetry/performance/StubPerformanceClient.d.ts.map +1 -0
- package/lib/types/telemetry/server/ServerTelemetryManager.d.ts +79 -0
- package/lib/types/telemetry/server/ServerTelemetryManager.d.ts.map +1 -0
- package/lib/types/telemetry/server/ServerTelemetryRequest.d.ts +9 -0
- package/lib/types/telemetry/server/ServerTelemetryRequest.d.ts.map +1 -0
- package/lib/types/url/IUri.d.ts +13 -0
- package/lib/types/url/IUri.d.ts.map +1 -0
- package/lib/types/url/UrlString.d.ts +49 -0
- package/lib/types/url/UrlString.d.ts.map +1 -0
- package/lib/types/utils/ClientAssertionUtils.d.ts +3 -0
- package/lib/types/utils/ClientAssertionUtils.d.ts.map +1 -0
- package/lib/types/utils/Constants.d.ts +311 -0
- package/lib/types/utils/Constants.d.ts.map +1 -0
- package/lib/types/utils/FunctionWrappers.d.ts +28 -0
- package/lib/types/utils/FunctionWrappers.d.ts.map +1 -0
- package/lib/types/utils/MsalTypes.d.ts +7 -0
- package/lib/types/utils/MsalTypes.d.ts.map +1 -0
- package/lib/types/utils/ProtocolUtils.d.ts +43 -0
- package/lib/types/utils/ProtocolUtils.d.ts.map +1 -0
- package/lib/types/utils/StringUtils.d.ts +41 -0
- package/lib/types/utils/StringUtils.d.ts.map +1 -0
- package/lib/types/utils/TimeUtils.d.ts +26 -0
- package/lib/types/utils/TimeUtils.d.ts.map +1 -0
- package/lib/types/utils/UrlUtils.d.ts +11 -0
- package/lib/types/utils/UrlUtils.d.ts.map +1 -0
- package/node/README.md +1 -0
- package/node/package.json +5 -0
- package/package.json +38 -11
- package/src/account/AccountInfo.ts +1 -1
- package/src/account/AuthToken.ts +2 -2
- package/src/account/ClientInfo.ts +2 -2
- package/src/authority/Authority.ts +26 -26
- package/src/authority/AuthorityFactory.ts +9 -9
- package/src/authority/AuthorityMetadata.ts +7 -7
- package/src/authority/AuthorityOptions.ts +4 -4
- package/src/authority/AzureRegionConfiguration.ts +1 -1
- package/src/authority/CloudInstanceDiscoveryResponse.ts +1 -1
- package/src/authority/OIDCOptions.ts +1 -1
- package/src/authority/RegionDiscovery.ts +10 -10
- package/src/authority/RegionDiscoveryMetadata.ts +1 -1
- package/src/broker/nativeBroker/INativeBrokerPlugin.ts +5 -5
- package/src/cache/CacheManager.ts +28 -36
- package/src/cache/entities/AccessTokenEntity.ts +2 -2
- package/src/cache/entities/AccountEntity.ts +10 -10
- package/src/cache/entities/CacheRecord.ts +5 -5
- package/src/cache/entities/CredentialEntity.ts +1 -1
- package/src/cache/entities/IdTokenEntity.ts +1 -1
- package/src/cache/entities/RefreshTokenEntity.ts +1 -1
- package/src/cache/interface/ICacheManager.ts +12 -12
- package/src/cache/interface/ICachePlugin.ts +1 -1
- package/src/cache/persistence/TokenCacheContext.ts +1 -1
- package/src/cache/utils/CacheHelpers.ts +13 -13
- package/src/cache/utils/CacheTypes.ts +11 -11
- package/src/client/AuthorizationCodeClient.ts +86 -52
- package/src/client/BaseClient.ts +121 -39
- package/src/client/RefreshTokenClient.ts +42 -33
- package/src/client/SilentFlowClient.ts +17 -17
- package/src/config/ClientConfiguration.ts +20 -15
- package/src/constants/AADServerParamKeys.ts +2 -0
- package/src/crypto/ICrypto.ts +3 -3
- package/src/crypto/JoseHeader.ts +2 -2
- package/src/crypto/PopTokenGenerator.ts +7 -7
- package/src/crypto/SignedHttpRequest.ts +1 -1
- package/src/error/AuthError.ts +2 -2
- package/src/error/CacheError.ts +1 -1
- package/src/error/ClientAuthError.ts +2 -2
- package/src/error/ClientConfigurationError.ts +2 -2
- package/src/error/InteractionRequiredAuthError.ts +3 -3
- package/src/error/JoseHeaderError.ts +2 -2
- package/src/error/NetworkError.ts +44 -0
- package/src/error/ServerError.ts +1 -1
- package/src/exports-browser-only.ts +29 -0
- package/src/exports-common.ts +189 -0
- package/src/exports-node-only.ts +35 -0
- package/src/index-browser.ts +11 -0
- package/src/index-node.ts +11 -0
- package/src/index.ts +7 -250
- package/src/logger/Logger.ts +2 -2
- package/src/network/INetworkModule.ts +2 -2
- package/src/network/NetworkResponse.ts +10 -0
- package/src/network/RequestThumbprint.ts +2 -2
- package/src/network/ThrottlingUtils.ts +8 -8
- package/src/packageMetadata.ts +1 -1
- package/src/request/AuthenticationHeaderParser.ts +2 -2
- package/src/request/BaseAuthRequest.ts +7 -5
- package/src/request/CommonAuthorizationCodeRequest.ts +3 -3
- package/src/request/CommonAuthorizationUrlRequest.ts +4 -4
- package/src/request/CommonClientCredentialRequest.ts +3 -3
- package/src/request/CommonDeviceCodeRequest.ts +3 -3
- package/src/request/CommonEndSessionRequest.ts +2 -2
- package/src/request/CommonOnBehalfOfRequest.ts +1 -1
- package/src/request/CommonRefreshTokenRequest.ts +3 -3
- package/src/request/CommonSilentFlowRequest.ts +3 -3
- package/src/request/CommonUsernamePasswordRequest.ts +1 -1
- package/src/request/NativeRequest.ts +1 -1
- package/src/request/RequestParameterBuilder.ts +60 -10
- package/src/request/RequestValidator.ts +2 -2
- package/src/request/ScopeSet.ts +4 -4
- package/src/response/AuthenticationResult.ts +1 -1
- package/src/response/ExternalTokenResponse.ts +1 -1
- package/src/response/ResponseHandler.ts +31 -31
- package/src/response/ServerAuthorizationTokenResponse.ts +1 -1
- package/src/telemetry/performance/IPerformanceClient.ts +2 -2
- package/src/telemetry/performance/PerformanceClient.ts +52 -22
- package/src/telemetry/performance/PerformanceEvent.ts +15 -0
- package/src/telemetry/performance/StubPerformanceClient.ts +6 -3
- package/src/telemetry/server/ServerTelemetryManager.ts +6 -6
- package/src/url/UrlString.ts +5 -5
- package/src/utils/ClientAssertionUtils.ts +1 -1
- package/src/utils/Constants.ts +1 -0
- package/src/utils/FunctionWrappers.ts +2 -2
- package/src/utils/ProtocolUtils.ts +3 -3
- package/src/utils/UrlUtils.ts +2 -2
- package/dist/index.cjs.map +0 -1
- 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/src/network/NetworkManager.ts +0 -76
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @azure/msal-common v14.
|
|
1
|
+
/*! @azure/msal-common v14.16.0 2024-11-05 */
|
|
2
2
|
'use strict';
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
@@ -96,6 +96,7 @@ const OIDC_SCOPES = [...OIDC_DEFAULT_SCOPES, Constants.EMAIL_SCOPE];
|
|
|
96
96
|
*/
|
|
97
97
|
const HeaderNames = {
|
|
98
98
|
CONTENT_TYPE: "Content-Type",
|
|
99
|
+
CONTENT_LENGTH: "Content-Length",
|
|
99
100
|
RETRY_AFTER: "Retry-After",
|
|
100
101
|
CCS_HEADER: "X-AnchorMailbox",
|
|
101
102
|
WWWAuthenticate: "WWW-Authenticate",
|
|
@@ -1612,6 +1613,7 @@ const PerformanceEvents = {
|
|
|
1612
1613
|
/**
|
|
1613
1614
|
* Time spent sending/waiting for the response of a request to the token endpoint
|
|
1614
1615
|
*/
|
|
1616
|
+
NetworkClientSendPostRequestAsync: "networkClientSendPostRequestAsync",
|
|
1615
1617
|
RefreshTokenClientExecutePostToTokenEndpoint: "refreshTokenClientExecutePostToTokenEndpoint",
|
|
1616
1618
|
AuthorizationCodeClientExecutePostToTokenEndpoint: "authorizationCodeClientExecutePostToTokenEndpoint",
|
|
1617
1619
|
/**
|
|
@@ -1785,6 +1787,10 @@ const PerformanceEventAbbreviations = new Map([
|
|
|
1785
1787
|
PerformanceEvents.BaseClientCreateTokenRequestHeaders,
|
|
1786
1788
|
"BaseClientCreateTReqHead",
|
|
1787
1789
|
],
|
|
1790
|
+
[
|
|
1791
|
+
PerformanceEvents.NetworkClientSendPostRequestAsync,
|
|
1792
|
+
"NetClientSendPost",
|
|
1793
|
+
],
|
|
1788
1794
|
[
|
|
1789
1795
|
PerformanceEvents.RefreshTokenClientExecutePostToTokenEndpoint,
|
|
1790
1796
|
"RTClientExecPost",
|
|
@@ -3463,28 +3469,6 @@ var AuthorityFactory = /*#__PURE__*/Object.freeze({
|
|
|
3463
3469
|
createDiscoveredInstance: createDiscoveredInstance
|
|
3464
3470
|
});
|
|
3465
3471
|
|
|
3466
|
-
/*
|
|
3467
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3468
|
-
* Licensed under the MIT License.
|
|
3469
|
-
*/
|
|
3470
|
-
async function getClientAssertion(clientAssertion, clientId, tokenEndpoint) {
|
|
3471
|
-
if (typeof clientAssertion === "string") {
|
|
3472
|
-
return clientAssertion;
|
|
3473
|
-
}
|
|
3474
|
-
else {
|
|
3475
|
-
const config = {
|
|
3476
|
-
clientId: clientId,
|
|
3477
|
-
tokenEndpoint: tokenEndpoint,
|
|
3478
|
-
};
|
|
3479
|
-
return clientAssertion(config);
|
|
3480
|
-
}
|
|
3481
|
-
}
|
|
3482
|
-
|
|
3483
|
-
var ClientAssertionUtils = /*#__PURE__*/Object.freeze({
|
|
3484
|
-
__proto__: null,
|
|
3485
|
-
getClientAssertion: getClientAssertion
|
|
3486
|
-
});
|
|
3487
|
-
|
|
3488
3472
|
/*
|
|
3489
3473
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3490
3474
|
* Licensed under the MIT License.
|
|
@@ -3541,11 +3525,15 @@ const LOGOUT_HINT = "logout_hint";
|
|
|
3541
3525
|
const SID = "sid";
|
|
3542
3526
|
const LOGIN_HINT = "login_hint";
|
|
3543
3527
|
const DOMAIN_HINT = "domain_hint";
|
|
3544
|
-
const X_CLIENT_EXTRA_SKU = "x-client-xtra-sku";
|
|
3528
|
+
const X_CLIENT_EXTRA_SKU = "x-client-xtra-sku";
|
|
3529
|
+
const BROKER_CLIENT_ID = "brk_client_id";
|
|
3530
|
+
const BROKER_REDIRECT_URI = "brk_redirect_uri";
|
|
3545
3531
|
|
|
3546
3532
|
var AADServerParamKeys = /*#__PURE__*/Object.freeze({
|
|
3547
3533
|
__proto__: null,
|
|
3548
3534
|
ACCESS_TOKEN: ACCESS_TOKEN,
|
|
3535
|
+
BROKER_CLIENT_ID: BROKER_CLIENT_ID,
|
|
3536
|
+
BROKER_REDIRECT_URI: BROKER_REDIRECT_URI,
|
|
3549
3537
|
CCS_HEADER: CCS_HEADER,
|
|
3550
3538
|
CLAIMS: CLAIMS,
|
|
3551
3539
|
CLIENT_ASSERTION: CLIENT_ASSERTION,
|
|
@@ -3828,7 +3816,7 @@ class Logger {
|
|
|
3828
3816
|
|
|
3829
3817
|
/* eslint-disable header/header */
|
|
3830
3818
|
const name = "@azure/msal-common";
|
|
3831
|
-
const version = "14.
|
|
3819
|
+
const version = "14.16.0";
|
|
3832
3820
|
|
|
3833
3821
|
/*
|
|
3834
3822
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -5683,9 +5671,6 @@ class DefaultStorageClass extends CacheManager {
|
|
|
5683
5671
|
getTokenKeys() {
|
|
5684
5672
|
throw createClientAuthError(methodNotImplemented);
|
|
5685
5673
|
}
|
|
5686
|
-
async clear() {
|
|
5687
|
-
throw createClientAuthError(methodNotImplemented);
|
|
5688
|
-
}
|
|
5689
5674
|
updateCredentialCacheKey() {
|
|
5690
5675
|
throw createClientAuthError(methodNotImplemented);
|
|
5691
5676
|
}
|
|
@@ -5779,6 +5764,7 @@ function buildAuthOptions(authOptions) {
|
|
|
5779
5764
|
clientCapabilities: [],
|
|
5780
5765
|
azureCloudOptions: DEFAULT_AZURE_CLOUD_OPTIONS,
|
|
5781
5766
|
skipAuthorityMetadataCache: false,
|
|
5767
|
+
instanceAware: false,
|
|
5782
5768
|
...authOptions,
|
|
5783
5769
|
};
|
|
5784
5770
|
}
|
|
@@ -5790,154 +5776,6 @@ function isOidcProtocolMode(config) {
|
|
|
5790
5776
|
return (config.authOptions.authority.options.protocolMode === ProtocolMode.OIDC);
|
|
5791
5777
|
}
|
|
5792
5778
|
|
|
5793
|
-
/*
|
|
5794
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
5795
|
-
* Licensed under the MIT License.
|
|
5796
|
-
*/
|
|
5797
|
-
/**
|
|
5798
|
-
* Error thrown when there is an error with the server code, for example, unavailability.
|
|
5799
|
-
*/
|
|
5800
|
-
class ServerError extends AuthError {
|
|
5801
|
-
constructor(errorCode, errorMessage, subError, errorNo, status) {
|
|
5802
|
-
super(errorCode, errorMessage, subError);
|
|
5803
|
-
this.name = "ServerError";
|
|
5804
|
-
this.errorNo = errorNo;
|
|
5805
|
-
this.status = status;
|
|
5806
|
-
Object.setPrototypeOf(this, ServerError.prototype);
|
|
5807
|
-
}
|
|
5808
|
-
}
|
|
5809
|
-
|
|
5810
|
-
/*
|
|
5811
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
5812
|
-
* Licensed under the MIT License.
|
|
5813
|
-
*/
|
|
5814
|
-
/** @internal */
|
|
5815
|
-
class ThrottlingUtils {
|
|
5816
|
-
/**
|
|
5817
|
-
* Prepares a RequestThumbprint to be stored as a key.
|
|
5818
|
-
* @param thumbprint
|
|
5819
|
-
*/
|
|
5820
|
-
static generateThrottlingStorageKey(thumbprint) {
|
|
5821
|
-
return `${ThrottlingConstants.THROTTLING_PREFIX}.${JSON.stringify(thumbprint)}`;
|
|
5822
|
-
}
|
|
5823
|
-
/**
|
|
5824
|
-
* Performs necessary throttling checks before a network request.
|
|
5825
|
-
* @param cacheManager
|
|
5826
|
-
* @param thumbprint
|
|
5827
|
-
*/
|
|
5828
|
-
static preProcess(cacheManager, thumbprint) {
|
|
5829
|
-
const key = ThrottlingUtils.generateThrottlingStorageKey(thumbprint);
|
|
5830
|
-
const value = cacheManager.getThrottlingCache(key);
|
|
5831
|
-
if (value) {
|
|
5832
|
-
if (value.throttleTime < Date.now()) {
|
|
5833
|
-
cacheManager.removeItem(key);
|
|
5834
|
-
return;
|
|
5835
|
-
}
|
|
5836
|
-
throw new ServerError(value.errorCodes?.join(" ") || Constants.EMPTY_STRING, value.errorMessage, value.subError);
|
|
5837
|
-
}
|
|
5838
|
-
}
|
|
5839
|
-
/**
|
|
5840
|
-
* Performs necessary throttling checks after a network request.
|
|
5841
|
-
* @param cacheManager
|
|
5842
|
-
* @param thumbprint
|
|
5843
|
-
* @param response
|
|
5844
|
-
*/
|
|
5845
|
-
static postProcess(cacheManager, thumbprint, response) {
|
|
5846
|
-
if (ThrottlingUtils.checkResponseStatus(response) ||
|
|
5847
|
-
ThrottlingUtils.checkResponseForRetryAfter(response)) {
|
|
5848
|
-
const thumbprintValue = {
|
|
5849
|
-
throttleTime: ThrottlingUtils.calculateThrottleTime(parseInt(response.headers[HeaderNames.RETRY_AFTER])),
|
|
5850
|
-
error: response.body.error,
|
|
5851
|
-
errorCodes: response.body.error_codes,
|
|
5852
|
-
errorMessage: response.body.error_description,
|
|
5853
|
-
subError: response.body.suberror,
|
|
5854
|
-
};
|
|
5855
|
-
cacheManager.setThrottlingCache(ThrottlingUtils.generateThrottlingStorageKey(thumbprint), thumbprintValue);
|
|
5856
|
-
}
|
|
5857
|
-
}
|
|
5858
|
-
/**
|
|
5859
|
-
* Checks a NetworkResponse object's status codes against 429 or 5xx
|
|
5860
|
-
* @param response
|
|
5861
|
-
*/
|
|
5862
|
-
static checkResponseStatus(response) {
|
|
5863
|
-
return (response.status === 429 ||
|
|
5864
|
-
(response.status >= 500 && response.status < 600));
|
|
5865
|
-
}
|
|
5866
|
-
/**
|
|
5867
|
-
* Checks a NetworkResponse object's RetryAfter header
|
|
5868
|
-
* @param response
|
|
5869
|
-
*/
|
|
5870
|
-
static checkResponseForRetryAfter(response) {
|
|
5871
|
-
if (response.headers) {
|
|
5872
|
-
return (response.headers.hasOwnProperty(HeaderNames.RETRY_AFTER) &&
|
|
5873
|
-
(response.status < 200 || response.status >= 300));
|
|
5874
|
-
}
|
|
5875
|
-
return false;
|
|
5876
|
-
}
|
|
5877
|
-
/**
|
|
5878
|
-
* Calculates the Unix-time value for a throttle to expire given throttleTime in seconds.
|
|
5879
|
-
* @param throttleTime
|
|
5880
|
-
*/
|
|
5881
|
-
static calculateThrottleTime(throttleTime) {
|
|
5882
|
-
const time = throttleTime <= 0 ? 0 : throttleTime;
|
|
5883
|
-
const currentSeconds = Date.now() / 1000;
|
|
5884
|
-
return Math.floor(Math.min(currentSeconds +
|
|
5885
|
-
(time || ThrottlingConstants.DEFAULT_THROTTLE_TIME_SECONDS), currentSeconds +
|
|
5886
|
-
ThrottlingConstants.DEFAULT_MAX_THROTTLE_TIME_SECONDS) * 1000);
|
|
5887
|
-
}
|
|
5888
|
-
static removeThrottle(cacheManager, clientId, request, homeAccountIdentifier) {
|
|
5889
|
-
const thumbprint = {
|
|
5890
|
-
clientId: clientId,
|
|
5891
|
-
authority: request.authority,
|
|
5892
|
-
scopes: request.scopes,
|
|
5893
|
-
homeAccountIdentifier: homeAccountIdentifier,
|
|
5894
|
-
claims: request.claims,
|
|
5895
|
-
authenticationScheme: request.authenticationScheme,
|
|
5896
|
-
resourceRequestMethod: request.resourceRequestMethod,
|
|
5897
|
-
resourceRequestUri: request.resourceRequestUri,
|
|
5898
|
-
shrClaims: request.shrClaims,
|
|
5899
|
-
sshKid: request.sshKid,
|
|
5900
|
-
};
|
|
5901
|
-
const key = this.generateThrottlingStorageKey(thumbprint);
|
|
5902
|
-
cacheManager.removeItem(key);
|
|
5903
|
-
}
|
|
5904
|
-
}
|
|
5905
|
-
|
|
5906
|
-
/*
|
|
5907
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
5908
|
-
* Licensed under the MIT License.
|
|
5909
|
-
*/
|
|
5910
|
-
/** @internal */
|
|
5911
|
-
class NetworkManager {
|
|
5912
|
-
constructor(networkClient, cacheManager) {
|
|
5913
|
-
this.networkClient = networkClient;
|
|
5914
|
-
this.cacheManager = cacheManager;
|
|
5915
|
-
}
|
|
5916
|
-
/**
|
|
5917
|
-
* Wraps sendPostRequestAsync with necessary preflight and postflight logic
|
|
5918
|
-
* @param thumbprint
|
|
5919
|
-
* @param tokenEndpoint
|
|
5920
|
-
* @param options
|
|
5921
|
-
*/
|
|
5922
|
-
async sendPostRequest(thumbprint, tokenEndpoint, options) {
|
|
5923
|
-
ThrottlingUtils.preProcess(this.cacheManager, thumbprint);
|
|
5924
|
-
let response;
|
|
5925
|
-
try {
|
|
5926
|
-
response = await this.networkClient.sendPostRequestAsync(tokenEndpoint, options);
|
|
5927
|
-
}
|
|
5928
|
-
catch (e) {
|
|
5929
|
-
if (e instanceof AuthError) {
|
|
5930
|
-
throw e;
|
|
5931
|
-
}
|
|
5932
|
-
else {
|
|
5933
|
-
throw createClientAuthError(networkError);
|
|
5934
|
-
}
|
|
5935
|
-
}
|
|
5936
|
-
ThrottlingUtils.postProcess(this.cacheManager, thumbprint, response);
|
|
5937
|
-
return response;
|
|
5938
|
-
}
|
|
5939
|
-
}
|
|
5940
|
-
|
|
5941
5779
|
/*
|
|
5942
5780
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
5943
5781
|
* Licensed under the MIT License.
|
|
@@ -6016,10 +5854,24 @@ class RequestValidator {
|
|
|
6016
5854
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6017
5855
|
* Licensed under the MIT License.
|
|
6018
5856
|
*/
|
|
5857
|
+
function instrumentBrokerParams(parameters, correlationId, performanceClient) {
|
|
5858
|
+
if (!correlationId) {
|
|
5859
|
+
return;
|
|
5860
|
+
}
|
|
5861
|
+
const clientId = parameters.get(CLIENT_ID);
|
|
5862
|
+
if (clientId && parameters.has(BROKER_CLIENT_ID)) {
|
|
5863
|
+
performanceClient?.addFields({
|
|
5864
|
+
embeddedClientId: clientId,
|
|
5865
|
+
embeddedRedirectUri: parameters.get(REDIRECT_URI),
|
|
5866
|
+
}, correlationId);
|
|
5867
|
+
}
|
|
5868
|
+
}
|
|
6019
5869
|
/** @internal */
|
|
6020
5870
|
class RequestParameterBuilder {
|
|
6021
|
-
constructor() {
|
|
5871
|
+
constructor(correlationId, performanceClient) {
|
|
6022
5872
|
this.parameters = new Map();
|
|
5873
|
+
this.performanceClient = performanceClient;
|
|
5874
|
+
this.correlationId = correlationId;
|
|
6023
5875
|
}
|
|
6024
5876
|
/**
|
|
6025
5877
|
* add response_type = code
|
|
@@ -6383,6 +6235,14 @@ class RequestParameterBuilder {
|
|
|
6383
6235
|
addLogoutHint(logoutHint) {
|
|
6384
6236
|
this.parameters.set(LOGOUT_HINT, encodeURIComponent(logoutHint));
|
|
6385
6237
|
}
|
|
6238
|
+
addBrokerParameters(params) {
|
|
6239
|
+
const brokerParams = {};
|
|
6240
|
+
brokerParams[BROKER_CLIENT_ID] =
|
|
6241
|
+
params.brokerClientId;
|
|
6242
|
+
brokerParams[BROKER_REDIRECT_URI] =
|
|
6243
|
+
params.brokerRedirectUri;
|
|
6244
|
+
this.addExtraQueryParameters(brokerParams);
|
|
6245
|
+
}
|
|
6386
6246
|
/**
|
|
6387
6247
|
* Utility to create a URL from the params map
|
|
6388
6248
|
*/
|
|
@@ -6391,6 +6251,7 @@ class RequestParameterBuilder {
|
|
|
6391
6251
|
this.parameters.forEach((value, key) => {
|
|
6392
6252
|
queryParameterArray.push(`${key}=${value}`);
|
|
6393
6253
|
});
|
|
6254
|
+
instrumentBrokerParams(this.parameters, this.correlationId, this.performanceClient);
|
|
6394
6255
|
return queryParameterArray.join("&");
|
|
6395
6256
|
}
|
|
6396
6257
|
}
|
|
@@ -6400,71 +6261,206 @@ class RequestParameterBuilder {
|
|
|
6400
6261
|
* Licensed under the MIT License.
|
|
6401
6262
|
*/
|
|
6402
6263
|
/**
|
|
6403
|
-
*
|
|
6404
|
-
* @internal
|
|
6264
|
+
* Error thrown when there is an error with the server code, for example, unavailability.
|
|
6405
6265
|
*/
|
|
6406
|
-
class
|
|
6407
|
-
constructor(
|
|
6408
|
-
|
|
6409
|
-
this.
|
|
6410
|
-
|
|
6411
|
-
this.
|
|
6412
|
-
|
|
6413
|
-
this.cryptoUtils = this.config.cryptoInterface;
|
|
6414
|
-
// Initialize storage interface
|
|
6415
|
-
this.cacheManager = this.config.storageInterface;
|
|
6416
|
-
// Set the network interface
|
|
6417
|
-
this.networkClient = this.config.networkInterface;
|
|
6418
|
-
// Set the NetworkManager
|
|
6419
|
-
this.networkManager = new NetworkManager(this.networkClient, this.cacheManager);
|
|
6420
|
-
// Set TelemetryManager
|
|
6421
|
-
this.serverTelemetryManager = this.config.serverTelemetryManager;
|
|
6422
|
-
// set Authority
|
|
6423
|
-
this.authority = this.config.authOptions.authority;
|
|
6424
|
-
// set performance telemetry client
|
|
6425
|
-
this.performanceClient = performanceClient;
|
|
6266
|
+
class ServerError extends AuthError {
|
|
6267
|
+
constructor(errorCode, errorMessage, subError, errorNo, status) {
|
|
6268
|
+
super(errorCode, errorMessage, subError);
|
|
6269
|
+
this.name = "ServerError";
|
|
6270
|
+
this.errorNo = errorNo;
|
|
6271
|
+
this.status = status;
|
|
6272
|
+
Object.setPrototypeOf(this, ServerError.prototype);
|
|
6426
6273
|
}
|
|
6274
|
+
}
|
|
6275
|
+
|
|
6276
|
+
/*
|
|
6277
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6278
|
+
* Licensed under the MIT License.
|
|
6279
|
+
*/
|
|
6280
|
+
/** @internal */
|
|
6281
|
+
class ThrottlingUtils {
|
|
6427
6282
|
/**
|
|
6428
|
-
*
|
|
6283
|
+
* Prepares a RequestThumbprint to be stored as a key.
|
|
6284
|
+
* @param thumbprint
|
|
6429
6285
|
*/
|
|
6430
|
-
|
|
6431
|
-
|
|
6432
|
-
headers[HeaderNames.CONTENT_TYPE] = Constants.URL_FORM_CONTENT_TYPE;
|
|
6433
|
-
if (!this.config.systemOptions.preventCorsPreflight && ccsCred) {
|
|
6434
|
-
switch (ccsCred.type) {
|
|
6435
|
-
case CcsCredentialType.HOME_ACCOUNT_ID:
|
|
6436
|
-
try {
|
|
6437
|
-
const clientInfo = buildClientInfoFromHomeAccountId(ccsCred.credential);
|
|
6438
|
-
headers[HeaderNames.CCS_HEADER] = `Oid:${clientInfo.uid}@${clientInfo.utid}`;
|
|
6439
|
-
}
|
|
6440
|
-
catch (e) {
|
|
6441
|
-
this.logger.verbose("Could not parse home account ID for CCS Header: " +
|
|
6442
|
-
e);
|
|
6443
|
-
}
|
|
6444
|
-
break;
|
|
6445
|
-
case CcsCredentialType.UPN:
|
|
6446
|
-
headers[HeaderNames.CCS_HEADER] = `UPN: ${ccsCred.credential}`;
|
|
6447
|
-
break;
|
|
6448
|
-
}
|
|
6449
|
-
}
|
|
6450
|
-
return headers;
|
|
6286
|
+
static generateThrottlingStorageKey(thumbprint) {
|
|
6287
|
+
return `${ThrottlingConstants.THROTTLING_PREFIX}.${JSON.stringify(thumbprint)}`;
|
|
6451
6288
|
}
|
|
6452
6289
|
/**
|
|
6453
|
-
*
|
|
6454
|
-
* @param
|
|
6455
|
-
* @param queryString
|
|
6456
|
-
* @param headers
|
|
6290
|
+
* Performs necessary throttling checks before a network request.
|
|
6291
|
+
* @param cacheManager
|
|
6457
6292
|
* @param thumbprint
|
|
6458
6293
|
*/
|
|
6459
|
-
|
|
6460
|
-
|
|
6461
|
-
|
|
6294
|
+
static preProcess(cacheManager, thumbprint) {
|
|
6295
|
+
const key = ThrottlingUtils.generateThrottlingStorageKey(thumbprint);
|
|
6296
|
+
const value = cacheManager.getThrottlingCache(key);
|
|
6297
|
+
if (value) {
|
|
6298
|
+
if (value.throttleTime < Date.now()) {
|
|
6299
|
+
cacheManager.removeItem(key);
|
|
6300
|
+
return;
|
|
6301
|
+
}
|
|
6302
|
+
throw new ServerError(value.errorCodes?.join(" ") || Constants.EMPTY_STRING, value.errorMessage, value.subError);
|
|
6462
6303
|
}
|
|
6463
|
-
|
|
6464
|
-
|
|
6465
|
-
|
|
6466
|
-
|
|
6467
|
-
|
|
6304
|
+
}
|
|
6305
|
+
/**
|
|
6306
|
+
* Performs necessary throttling checks after a network request.
|
|
6307
|
+
* @param cacheManager
|
|
6308
|
+
* @param thumbprint
|
|
6309
|
+
* @param response
|
|
6310
|
+
*/
|
|
6311
|
+
static postProcess(cacheManager, thumbprint, response) {
|
|
6312
|
+
if (ThrottlingUtils.checkResponseStatus(response) ||
|
|
6313
|
+
ThrottlingUtils.checkResponseForRetryAfter(response)) {
|
|
6314
|
+
const thumbprintValue = {
|
|
6315
|
+
throttleTime: ThrottlingUtils.calculateThrottleTime(parseInt(response.headers[HeaderNames.RETRY_AFTER])),
|
|
6316
|
+
error: response.body.error,
|
|
6317
|
+
errorCodes: response.body.error_codes,
|
|
6318
|
+
errorMessage: response.body.error_description,
|
|
6319
|
+
subError: response.body.suberror,
|
|
6320
|
+
};
|
|
6321
|
+
cacheManager.setThrottlingCache(ThrottlingUtils.generateThrottlingStorageKey(thumbprint), thumbprintValue);
|
|
6322
|
+
}
|
|
6323
|
+
}
|
|
6324
|
+
/**
|
|
6325
|
+
* Checks a NetworkResponse object's status codes against 429 or 5xx
|
|
6326
|
+
* @param response
|
|
6327
|
+
*/
|
|
6328
|
+
static checkResponseStatus(response) {
|
|
6329
|
+
return (response.status === 429 ||
|
|
6330
|
+
(response.status >= 500 && response.status < 600));
|
|
6331
|
+
}
|
|
6332
|
+
/**
|
|
6333
|
+
* Checks a NetworkResponse object's RetryAfter header
|
|
6334
|
+
* @param response
|
|
6335
|
+
*/
|
|
6336
|
+
static checkResponseForRetryAfter(response) {
|
|
6337
|
+
if (response.headers) {
|
|
6338
|
+
return (response.headers.hasOwnProperty(HeaderNames.RETRY_AFTER) &&
|
|
6339
|
+
(response.status < 200 || response.status >= 300));
|
|
6340
|
+
}
|
|
6341
|
+
return false;
|
|
6342
|
+
}
|
|
6343
|
+
/**
|
|
6344
|
+
* Calculates the Unix-time value for a throttle to expire given throttleTime in seconds.
|
|
6345
|
+
* @param throttleTime
|
|
6346
|
+
*/
|
|
6347
|
+
static calculateThrottleTime(throttleTime) {
|
|
6348
|
+
const time = throttleTime <= 0 ? 0 : throttleTime;
|
|
6349
|
+
const currentSeconds = Date.now() / 1000;
|
|
6350
|
+
return Math.floor(Math.min(currentSeconds +
|
|
6351
|
+
(time || ThrottlingConstants.DEFAULT_THROTTLE_TIME_SECONDS), currentSeconds +
|
|
6352
|
+
ThrottlingConstants.DEFAULT_MAX_THROTTLE_TIME_SECONDS) * 1000);
|
|
6353
|
+
}
|
|
6354
|
+
static removeThrottle(cacheManager, clientId, request, homeAccountIdentifier) {
|
|
6355
|
+
const thumbprint = {
|
|
6356
|
+
clientId: clientId,
|
|
6357
|
+
authority: request.authority,
|
|
6358
|
+
scopes: request.scopes,
|
|
6359
|
+
homeAccountIdentifier: homeAccountIdentifier,
|
|
6360
|
+
claims: request.claims,
|
|
6361
|
+
authenticationScheme: request.authenticationScheme,
|
|
6362
|
+
resourceRequestMethod: request.resourceRequestMethod,
|
|
6363
|
+
resourceRequestUri: request.resourceRequestUri,
|
|
6364
|
+
shrClaims: request.shrClaims,
|
|
6365
|
+
sshKid: request.sshKid,
|
|
6366
|
+
};
|
|
6367
|
+
const key = this.generateThrottlingStorageKey(thumbprint);
|
|
6368
|
+
cacheManager.removeItem(key);
|
|
6369
|
+
}
|
|
6370
|
+
}
|
|
6371
|
+
|
|
6372
|
+
/*
|
|
6373
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6374
|
+
* Licensed under the MIT License.
|
|
6375
|
+
*/
|
|
6376
|
+
/**
|
|
6377
|
+
* Represents network related errors
|
|
6378
|
+
*/
|
|
6379
|
+
class NetworkError extends AuthError {
|
|
6380
|
+
constructor(error, httpStatus, responseHeaders) {
|
|
6381
|
+
super(error.errorCode, error.errorMessage, error.subError);
|
|
6382
|
+
Object.setPrototypeOf(this, NetworkError.prototype);
|
|
6383
|
+
this.name = "NetworkError";
|
|
6384
|
+
this.error = error;
|
|
6385
|
+
this.httpStatus = httpStatus;
|
|
6386
|
+
this.responseHeaders = responseHeaders;
|
|
6387
|
+
}
|
|
6388
|
+
}
|
|
6389
|
+
/**
|
|
6390
|
+
* Creates NetworkError object for a failed network request
|
|
6391
|
+
* @param error - Error to be thrown back to the caller
|
|
6392
|
+
* @param httpStatus - Status code of the network request
|
|
6393
|
+
* @param responseHeaders - Response headers of the network request, when available
|
|
6394
|
+
* @returns NetworkError object
|
|
6395
|
+
*/
|
|
6396
|
+
function createNetworkError(error, httpStatus, responseHeaders) {
|
|
6397
|
+
return new NetworkError(error, httpStatus, responseHeaders);
|
|
6398
|
+
}
|
|
6399
|
+
|
|
6400
|
+
/*
|
|
6401
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6402
|
+
* Licensed under the MIT License.
|
|
6403
|
+
*/
|
|
6404
|
+
/**
|
|
6405
|
+
* Base application class which will construct requests to send to and handle responses from the Microsoft STS using the authorization code flow.
|
|
6406
|
+
* @internal
|
|
6407
|
+
*/
|
|
6408
|
+
class BaseClient {
|
|
6409
|
+
constructor(configuration, performanceClient) {
|
|
6410
|
+
// Set the configuration
|
|
6411
|
+
this.config = buildClientConfiguration(configuration);
|
|
6412
|
+
// Initialize the logger
|
|
6413
|
+
this.logger = new Logger(this.config.loggerOptions, name, version);
|
|
6414
|
+
// Initialize crypto
|
|
6415
|
+
this.cryptoUtils = this.config.cryptoInterface;
|
|
6416
|
+
// Initialize storage interface
|
|
6417
|
+
this.cacheManager = this.config.storageInterface;
|
|
6418
|
+
// Set the network interface
|
|
6419
|
+
this.networkClient = this.config.networkInterface;
|
|
6420
|
+
// Set TelemetryManager
|
|
6421
|
+
this.serverTelemetryManager = this.config.serverTelemetryManager;
|
|
6422
|
+
// set Authority
|
|
6423
|
+
this.authority = this.config.authOptions.authority;
|
|
6424
|
+
// set performance telemetry client
|
|
6425
|
+
this.performanceClient = performanceClient;
|
|
6426
|
+
}
|
|
6427
|
+
/**
|
|
6428
|
+
* Creates default headers for requests to token endpoint
|
|
6429
|
+
*/
|
|
6430
|
+
createTokenRequestHeaders(ccsCred) {
|
|
6431
|
+
const headers = {};
|
|
6432
|
+
headers[HeaderNames.CONTENT_TYPE] = Constants.URL_FORM_CONTENT_TYPE;
|
|
6433
|
+
if (!this.config.systemOptions.preventCorsPreflight && ccsCred) {
|
|
6434
|
+
switch (ccsCred.type) {
|
|
6435
|
+
case CcsCredentialType.HOME_ACCOUNT_ID:
|
|
6436
|
+
try {
|
|
6437
|
+
const clientInfo = buildClientInfoFromHomeAccountId(ccsCred.credential);
|
|
6438
|
+
headers[HeaderNames.CCS_HEADER] = `Oid:${clientInfo.uid}@${clientInfo.utid}`;
|
|
6439
|
+
}
|
|
6440
|
+
catch (e) {
|
|
6441
|
+
this.logger.verbose("Could not parse home account ID for CCS Header: " +
|
|
6442
|
+
e);
|
|
6443
|
+
}
|
|
6444
|
+
break;
|
|
6445
|
+
case CcsCredentialType.UPN:
|
|
6446
|
+
headers[HeaderNames.CCS_HEADER] = `UPN: ${ccsCred.credential}`;
|
|
6447
|
+
break;
|
|
6448
|
+
}
|
|
6449
|
+
}
|
|
6450
|
+
return headers;
|
|
6451
|
+
}
|
|
6452
|
+
/**
|
|
6453
|
+
* Http post to token endpoint
|
|
6454
|
+
* @param tokenEndpoint
|
|
6455
|
+
* @param queryString
|
|
6456
|
+
* @param headers
|
|
6457
|
+
* @param thumbprint
|
|
6458
|
+
*/
|
|
6459
|
+
async executePostToTokenEndpoint(tokenEndpoint, queryString, headers, thumbprint, correlationId, queuedEvent) {
|
|
6460
|
+
if (queuedEvent) {
|
|
6461
|
+
this.performanceClient?.addQueueMeasurement(queuedEvent, correlationId);
|
|
6462
|
+
}
|
|
6463
|
+
const response = await this.sendPostRequest(thumbprint, tokenEndpoint, { body: queryString, headers: headers }, correlationId);
|
|
6468
6464
|
if (this.config.serverTelemetryManager &&
|
|
6469
6465
|
response.status < 500 &&
|
|
6470
6466
|
response.status !== 429) {
|
|
@@ -6473,6 +6469,52 @@ class BaseClient {
|
|
|
6473
6469
|
}
|
|
6474
6470
|
return response;
|
|
6475
6471
|
}
|
|
6472
|
+
/**
|
|
6473
|
+
* Wraps sendPostRequestAsync with necessary preflight and postflight logic
|
|
6474
|
+
* @param thumbprint - Request thumbprint for throttling
|
|
6475
|
+
* @param tokenEndpoint - Endpoint to make the POST to
|
|
6476
|
+
* @param options - Body and Headers to include on the POST request
|
|
6477
|
+
* @param correlationId - CorrelationId for telemetry
|
|
6478
|
+
*/
|
|
6479
|
+
async sendPostRequest(thumbprint, tokenEndpoint, options, correlationId) {
|
|
6480
|
+
ThrottlingUtils.preProcess(this.cacheManager, thumbprint);
|
|
6481
|
+
let response;
|
|
6482
|
+
try {
|
|
6483
|
+
response = await invokeAsync((this.networkClient.sendPostRequestAsync.bind(this.networkClient)), PerformanceEvents.NetworkClientSendPostRequestAsync, this.logger, this.performanceClient, correlationId)(tokenEndpoint, options);
|
|
6484
|
+
const responseHeaders = response.headers || {};
|
|
6485
|
+
this.performanceClient?.addFields({
|
|
6486
|
+
refreshTokenSize: response.body.refresh_token?.length || 0,
|
|
6487
|
+
httpVerToken: responseHeaders[HeaderNames.X_MS_HTTP_VERSION] || "",
|
|
6488
|
+
requestId: responseHeaders[HeaderNames.X_MS_REQUEST_ID] || "",
|
|
6489
|
+
}, correlationId);
|
|
6490
|
+
}
|
|
6491
|
+
catch (e) {
|
|
6492
|
+
if (e instanceof NetworkError) {
|
|
6493
|
+
const responseHeaders = e.responseHeaders;
|
|
6494
|
+
if (responseHeaders) {
|
|
6495
|
+
this.performanceClient?.addFields({
|
|
6496
|
+
httpVerToken: responseHeaders[HeaderNames.X_MS_HTTP_VERSION] || "",
|
|
6497
|
+
requestId: responseHeaders[HeaderNames.X_MS_REQUEST_ID] ||
|
|
6498
|
+
"",
|
|
6499
|
+
contentTypeHeader: responseHeaders[HeaderNames.CONTENT_TYPE] ||
|
|
6500
|
+
undefined,
|
|
6501
|
+
contentLengthHeader: responseHeaders[HeaderNames.CONTENT_LENGTH] ||
|
|
6502
|
+
undefined,
|
|
6503
|
+
httpStatus: e.httpStatus,
|
|
6504
|
+
}, correlationId);
|
|
6505
|
+
}
|
|
6506
|
+
throw e.error;
|
|
6507
|
+
}
|
|
6508
|
+
if (e instanceof AuthError) {
|
|
6509
|
+
throw e;
|
|
6510
|
+
}
|
|
6511
|
+
else {
|
|
6512
|
+
throw createClientAuthError(networkError);
|
|
6513
|
+
}
|
|
6514
|
+
}
|
|
6515
|
+
ThrottlingUtils.postProcess(this.cacheManager, thumbprint, response);
|
|
6516
|
+
return response;
|
|
6517
|
+
}
|
|
6476
6518
|
/**
|
|
6477
6519
|
* Updates the authority object of the client. Endpoint discovery must be completed.
|
|
6478
6520
|
* @param updatedAuthority
|
|
@@ -6488,10 +6530,17 @@ class BaseClient {
|
|
|
6488
6530
|
* @param request
|
|
6489
6531
|
*/
|
|
6490
6532
|
createTokenQueryParameters(request) {
|
|
6491
|
-
const parameterBuilder = new RequestParameterBuilder();
|
|
6533
|
+
const parameterBuilder = new RequestParameterBuilder(request.correlationId, this.performanceClient);
|
|
6534
|
+
if (request.embeddedClientId) {
|
|
6535
|
+
parameterBuilder.addBrokerParameters({
|
|
6536
|
+
brokerClientId: this.config.authOptions.clientId,
|
|
6537
|
+
brokerRedirectUri: this.config.authOptions.redirectUri,
|
|
6538
|
+
});
|
|
6539
|
+
}
|
|
6492
6540
|
if (request.tokenQueryParameters) {
|
|
6493
6541
|
parameterBuilder.addExtraQueryParameters(request.tokenQueryParameters);
|
|
6494
6542
|
}
|
|
6543
|
+
parameterBuilder.addCorrelationId(request.correlationId);
|
|
6495
6544
|
return parameterBuilder.createQueryString();
|
|
6496
6545
|
}
|
|
6497
6546
|
}
|
|
@@ -7160,6 +7209,28 @@ function buildAccountToCache(cacheStorage, authority, homeAccountId, base64Decod
|
|
|
7160
7209
|
return baseAccount;
|
|
7161
7210
|
}
|
|
7162
7211
|
|
|
7212
|
+
/*
|
|
7213
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
7214
|
+
* Licensed under the MIT License.
|
|
7215
|
+
*/
|
|
7216
|
+
async function getClientAssertion(clientAssertion, clientId, tokenEndpoint) {
|
|
7217
|
+
if (typeof clientAssertion === "string") {
|
|
7218
|
+
return clientAssertion;
|
|
7219
|
+
}
|
|
7220
|
+
else {
|
|
7221
|
+
const config = {
|
|
7222
|
+
clientId: clientId,
|
|
7223
|
+
tokenEndpoint: tokenEndpoint,
|
|
7224
|
+
};
|
|
7225
|
+
return clientAssertion(config);
|
|
7226
|
+
}
|
|
7227
|
+
}
|
|
7228
|
+
|
|
7229
|
+
var ClientAssertionUtils = /*#__PURE__*/Object.freeze({
|
|
7230
|
+
__proto__: null,
|
|
7231
|
+
getClientAssertion: getClientAssertion
|
|
7232
|
+
});
|
|
7233
|
+
|
|
7163
7234
|
/*
|
|
7164
7235
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
7165
7236
|
* Licensed under the MIT License.
|
|
@@ -7284,8 +7355,9 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
7284
7355
|
*/
|
|
7285
7356
|
async createTokenRequestBody(request) {
|
|
7286
7357
|
this.performanceClient?.addQueueMeasurement(PerformanceEvents.AuthClientCreateTokenRequestBody, request.correlationId);
|
|
7287
|
-
const parameterBuilder = new RequestParameterBuilder();
|
|
7288
|
-
parameterBuilder.addClientId(request.
|
|
7358
|
+
const parameterBuilder = new RequestParameterBuilder(request.correlationId, this.performanceClient);
|
|
7359
|
+
parameterBuilder.addClientId(request.embeddedClientId ||
|
|
7360
|
+
request.tokenBodyParameters?.[CLIENT_ID] ||
|
|
7289
7361
|
this.config.authOptions.clientId);
|
|
7290
7362
|
/*
|
|
7291
7363
|
* For hybrid spa flow, there will be a code but no verifier
|
|
@@ -7345,9 +7417,6 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
7345
7417
|
throw createClientConfigurationError(missingSshJwk);
|
|
7346
7418
|
}
|
|
7347
7419
|
}
|
|
7348
|
-
const correlationId = request.correlationId ||
|
|
7349
|
-
this.config.cryptoInterface.createNewGuid();
|
|
7350
|
-
parameterBuilder.addCorrelationId(correlationId);
|
|
7351
7420
|
if (!StringUtils.isEmptyObj(request.claims) ||
|
|
7352
7421
|
(this.config.authOptions.clientCapabilities &&
|
|
7353
7422
|
this.config.authOptions.clientCapabilities.length > 0)) {
|
|
@@ -7387,6 +7456,12 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
7387
7456
|
break;
|
|
7388
7457
|
}
|
|
7389
7458
|
}
|
|
7459
|
+
if (request.embeddedClientId) {
|
|
7460
|
+
parameterBuilder.addBrokerParameters({
|
|
7461
|
+
brokerClientId: this.config.authOptions.clientId,
|
|
7462
|
+
brokerRedirectUri: this.config.authOptions.redirectUri,
|
|
7463
|
+
});
|
|
7464
|
+
}
|
|
7390
7465
|
if (request.tokenBodyParameters) {
|
|
7391
7466
|
parameterBuilder.addExtraQueryParameters(request.tokenBodyParameters);
|
|
7392
7467
|
}
|
|
@@ -7405,9 +7480,13 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
7405
7480
|
* @param request
|
|
7406
7481
|
*/
|
|
7407
7482
|
async createAuthCodeUrlQueryString(request) {
|
|
7408
|
-
|
|
7409
|
-
const
|
|
7410
|
-
|
|
7483
|
+
// generate the correlationId if not set by the user and add
|
|
7484
|
+
const correlationId = request.correlationId ||
|
|
7485
|
+
this.config.cryptoInterface.createNewGuid();
|
|
7486
|
+
this.performanceClient?.addQueueMeasurement(PerformanceEvents.AuthClientCreateQueryString, correlationId);
|
|
7487
|
+
const parameterBuilder = new RequestParameterBuilder(correlationId, this.performanceClient);
|
|
7488
|
+
parameterBuilder.addClientId(request.embeddedClientId ||
|
|
7489
|
+
request.extraQueryParameters?.[CLIENT_ID] ||
|
|
7411
7490
|
this.config.authOptions.clientId);
|
|
7412
7491
|
const requestScopes = [
|
|
7413
7492
|
...(request.scopes || []),
|
|
@@ -7416,9 +7495,6 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
7416
7495
|
parameterBuilder.addScopes(requestScopes, true, this.oidcDefaultScopes);
|
|
7417
7496
|
// validate the redirectUri (to be a non null value)
|
|
7418
7497
|
parameterBuilder.addRedirectUri(request.redirectUri);
|
|
7419
|
-
// generate the correlationId if not set by the user and add
|
|
7420
|
-
const correlationId = request.correlationId ||
|
|
7421
|
-
this.config.cryptoInterface.createNewGuid();
|
|
7422
7498
|
parameterBuilder.addCorrelationId(correlationId);
|
|
7423
7499
|
// add response_mode. If not passed in it defaults to query.
|
|
7424
7500
|
parameterBuilder.addResponseMode(request.responseMode);
|
|
@@ -7520,9 +7596,13 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
7520
7596
|
this.config.authOptions.clientCapabilities.length > 0)) {
|
|
7521
7597
|
parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);
|
|
7522
7598
|
}
|
|
7523
|
-
if (request.
|
|
7524
|
-
parameterBuilder.
|
|
7599
|
+
if (request.embeddedClientId) {
|
|
7600
|
+
parameterBuilder.addBrokerParameters({
|
|
7601
|
+
brokerClientId: this.config.authOptions.clientId,
|
|
7602
|
+
brokerRedirectUri: this.config.authOptions.redirectUri,
|
|
7603
|
+
});
|
|
7525
7604
|
}
|
|
7605
|
+
this.addExtraQueryParams(request, parameterBuilder);
|
|
7526
7606
|
if (request.nativeBroker) {
|
|
7527
7607
|
// signal ests that this is a WAM call
|
|
7528
7608
|
parameterBuilder.addNativeBroker();
|
|
@@ -7548,7 +7628,7 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
7548
7628
|
* @param request
|
|
7549
7629
|
*/
|
|
7550
7630
|
createLogoutUrlQueryString(request) {
|
|
7551
|
-
const parameterBuilder = new RequestParameterBuilder();
|
|
7631
|
+
const parameterBuilder = new RequestParameterBuilder(request.correlationId, this.performanceClient);
|
|
7552
7632
|
if (request.postLogoutRedirectUri) {
|
|
7553
7633
|
parameterBuilder.addPostLogoutRedirectUri(request.postLogoutRedirectUri);
|
|
7554
7634
|
}
|
|
@@ -7564,10 +7644,20 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
7564
7644
|
if (request.logoutHint) {
|
|
7565
7645
|
parameterBuilder.addLogoutHint(request.logoutHint);
|
|
7566
7646
|
}
|
|
7647
|
+
this.addExtraQueryParams(request, parameterBuilder);
|
|
7648
|
+
return parameterBuilder.createQueryString();
|
|
7649
|
+
}
|
|
7650
|
+
addExtraQueryParams(request, parameterBuilder) {
|
|
7651
|
+
const hasRequestInstanceAware = request.extraQueryParameters &&
|
|
7652
|
+
request.extraQueryParameters.hasOwnProperty("instance_aware");
|
|
7653
|
+
// Set instance_aware flag if config auth param is set
|
|
7654
|
+
if (!hasRequestInstanceAware && this.config.authOptions.instanceAware) {
|
|
7655
|
+
request.extraQueryParameters = request.extraQueryParameters || {};
|
|
7656
|
+
request.extraQueryParameters["instance_aware"] = "true";
|
|
7657
|
+
}
|
|
7567
7658
|
if (request.extraQueryParameters) {
|
|
7568
7659
|
parameterBuilder.addExtraQueryParameters(request.extraQueryParameters);
|
|
7569
7660
|
}
|
|
7570
|
-
return parameterBuilder.createQueryString();
|
|
7571
7661
|
}
|
|
7572
7662
|
/**
|
|
7573
7663
|
* Helper to get sid from account. Returns null if idTokenClaims are not present or sid is not present.
|
|
@@ -7717,8 +7807,9 @@ class RefreshTokenClient extends BaseClient {
|
|
|
7717
7807
|
async createTokenRequestBody(request) {
|
|
7718
7808
|
this.performanceClient?.addQueueMeasurement(PerformanceEvents.RefreshTokenClientCreateTokenRequestBody, request.correlationId);
|
|
7719
7809
|
const correlationId = request.correlationId;
|
|
7720
|
-
const parameterBuilder = new RequestParameterBuilder();
|
|
7721
|
-
parameterBuilder.addClientId(request.
|
|
7810
|
+
const parameterBuilder = new RequestParameterBuilder(correlationId, this.performanceClient);
|
|
7811
|
+
parameterBuilder.addClientId(request.embeddedClientId ||
|
|
7812
|
+
request.tokenBodyParameters?.[CLIENT_ID] ||
|
|
7722
7813
|
this.config.authOptions.clientId);
|
|
7723
7814
|
if (request.redirectUri) {
|
|
7724
7815
|
parameterBuilder.addRedirectUri(request.redirectUri);
|
|
@@ -7732,7 +7823,6 @@ class RefreshTokenClient extends BaseClient {
|
|
|
7732
7823
|
if (this.serverTelemetryManager && !isOidcProtocolMode(this.config)) {
|
|
7733
7824
|
parameterBuilder.addServerTelemetry(this.serverTelemetryManager);
|
|
7734
7825
|
}
|
|
7735
|
-
parameterBuilder.addCorrelationId(correlationId);
|
|
7736
7826
|
parameterBuilder.addRefreshToken(request.refreshToken);
|
|
7737
7827
|
if (this.config.clientCredentials.clientSecret) {
|
|
7738
7828
|
parameterBuilder.addClientSecret(this.config.clientCredentials.clientSecret);
|
|
@@ -7786,6 +7876,12 @@ class RefreshTokenClient extends BaseClient {
|
|
|
7786
7876
|
break;
|
|
7787
7877
|
}
|
|
7788
7878
|
}
|
|
7879
|
+
if (request.embeddedClientId) {
|
|
7880
|
+
parameterBuilder.addBrokerParameters({
|
|
7881
|
+
brokerClientId: this.config.authOptions.clientId,
|
|
7882
|
+
brokerRedirectUri: this.config.authOptions.redirectUri,
|
|
7883
|
+
});
|
|
7884
|
+
}
|
|
7789
7885
|
if (request.tokenBodyParameters) {
|
|
7790
7886
|
parameterBuilder.addExtraQueryParameters(request.tokenBodyParameters);
|
|
7791
7887
|
}
|
|
@@ -7940,74 +8036,6 @@ const StubbedNetworkModule = {
|
|
|
7940
8036
|
},
|
|
7941
8037
|
};
|
|
7942
8038
|
|
|
7943
|
-
/*
|
|
7944
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
7945
|
-
* Licensed under the MIT License.
|
|
7946
|
-
*/
|
|
7947
|
-
const missingKidError = "missing_kid_error";
|
|
7948
|
-
const missingAlgError = "missing_alg_error";
|
|
7949
|
-
|
|
7950
|
-
/*
|
|
7951
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
7952
|
-
* Licensed under the MIT License.
|
|
7953
|
-
*/
|
|
7954
|
-
const JoseHeaderErrorMessages = {
|
|
7955
|
-
[missingKidError]: "The JOSE Header for the requested JWT, JWS or JWK object requires a keyId to be configured as the 'kid' header claim. No 'kid' value was provided.",
|
|
7956
|
-
[missingAlgError]: "The JOSE Header for the requested JWT, JWS or JWK object requires an algorithm to be specified as the 'alg' header claim. No 'alg' value was provided.",
|
|
7957
|
-
};
|
|
7958
|
-
/**
|
|
7959
|
-
* Error thrown when there is an error in the client code running on the browser.
|
|
7960
|
-
*/
|
|
7961
|
-
class JoseHeaderError extends AuthError {
|
|
7962
|
-
constructor(errorCode, errorMessage) {
|
|
7963
|
-
super(errorCode, errorMessage);
|
|
7964
|
-
this.name = "JoseHeaderError";
|
|
7965
|
-
Object.setPrototypeOf(this, JoseHeaderError.prototype);
|
|
7966
|
-
}
|
|
7967
|
-
}
|
|
7968
|
-
/** Returns JoseHeaderError object */
|
|
7969
|
-
function createJoseHeaderError(code) {
|
|
7970
|
-
return new JoseHeaderError(code, JoseHeaderErrorMessages[code]);
|
|
7971
|
-
}
|
|
7972
|
-
|
|
7973
|
-
/*
|
|
7974
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
7975
|
-
* Licensed under the MIT License.
|
|
7976
|
-
*/
|
|
7977
|
-
/** @internal */
|
|
7978
|
-
class JoseHeader {
|
|
7979
|
-
constructor(options) {
|
|
7980
|
-
this.typ = options.typ;
|
|
7981
|
-
this.alg = options.alg;
|
|
7982
|
-
this.kid = options.kid;
|
|
7983
|
-
}
|
|
7984
|
-
/**
|
|
7985
|
-
* Builds SignedHttpRequest formatted JOSE Header from the
|
|
7986
|
-
* JOSE Header options provided or previously set on the object and returns
|
|
7987
|
-
* the stringified header object.
|
|
7988
|
-
* Throws if keyId or algorithm aren't provided since they are required for Access Token Binding.
|
|
7989
|
-
* @param shrHeaderOptions
|
|
7990
|
-
* @returns
|
|
7991
|
-
*/
|
|
7992
|
-
static getShrHeaderString(shrHeaderOptions) {
|
|
7993
|
-
// KeyID is required on the SHR header
|
|
7994
|
-
if (!shrHeaderOptions.kid) {
|
|
7995
|
-
throw createJoseHeaderError(missingKidError);
|
|
7996
|
-
}
|
|
7997
|
-
// Alg is required on the SHR header
|
|
7998
|
-
if (!shrHeaderOptions.alg) {
|
|
7999
|
-
throw createJoseHeaderError(missingAlgError);
|
|
8000
|
-
}
|
|
8001
|
-
const shrHeader = new JoseHeader({
|
|
8002
|
-
// Access Token PoP headers must have type pop, but the type header can be overriden for special cases
|
|
8003
|
-
typ: shrHeaderOptions.typ || JsonWebTokenTypes.Pop,
|
|
8004
|
-
kid: shrHeaderOptions.kid,
|
|
8005
|
-
alg: shrHeaderOptions.alg,
|
|
8006
|
-
});
|
|
8007
|
-
return JSON.stringify(shrHeader);
|
|
8008
|
-
}
|
|
8009
|
-
}
|
|
8010
|
-
|
|
8011
8039
|
/*
|
|
8012
8040
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
8013
8041
|
* Licensed under the MIT License.
|
|
@@ -8325,671 +8353,6 @@ class ServerTelemetryManager {
|
|
|
8325
8353
|
}
|
|
8326
8354
|
}
|
|
8327
8355
|
|
|
8328
|
-
/*
|
|
8329
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
8330
|
-
* Licensed under the MIT License.
|
|
8331
|
-
*/
|
|
8332
|
-
class StubPerformanceMeasurement {
|
|
8333
|
-
startMeasurement() {
|
|
8334
|
-
return;
|
|
8335
|
-
}
|
|
8336
|
-
endMeasurement() {
|
|
8337
|
-
return;
|
|
8338
|
-
}
|
|
8339
|
-
flushMeasurement() {
|
|
8340
|
-
return null;
|
|
8341
|
-
}
|
|
8342
|
-
}
|
|
8343
|
-
class StubPerformanceClient {
|
|
8344
|
-
generateId() {
|
|
8345
|
-
return "callback-id";
|
|
8346
|
-
}
|
|
8347
|
-
startMeasurement(measureName, correlationId) {
|
|
8348
|
-
return {
|
|
8349
|
-
end: () => null,
|
|
8350
|
-
discard: () => { },
|
|
8351
|
-
add: () => { },
|
|
8352
|
-
increment: () => { },
|
|
8353
|
-
event: {
|
|
8354
|
-
eventId: this.generateId(),
|
|
8355
|
-
status: PerformanceEventStatus.InProgress,
|
|
8356
|
-
authority: "",
|
|
8357
|
-
libraryName: "",
|
|
8358
|
-
libraryVersion: "",
|
|
8359
|
-
clientId: "",
|
|
8360
|
-
name: measureName,
|
|
8361
|
-
startTimeMs: Date.now(),
|
|
8362
|
-
correlationId: correlationId || "",
|
|
8363
|
-
},
|
|
8364
|
-
measurement: new StubPerformanceMeasurement(),
|
|
8365
|
-
};
|
|
8366
|
-
}
|
|
8367
|
-
startPerformanceMeasurement() {
|
|
8368
|
-
return new StubPerformanceMeasurement();
|
|
8369
|
-
}
|
|
8370
|
-
calculateQueuedTime() {
|
|
8371
|
-
return 0;
|
|
8372
|
-
}
|
|
8373
|
-
addQueueMeasurement() {
|
|
8374
|
-
return;
|
|
8375
|
-
}
|
|
8376
|
-
setPreQueueTime() {
|
|
8377
|
-
return;
|
|
8378
|
-
}
|
|
8379
|
-
endMeasurement() {
|
|
8380
|
-
return null;
|
|
8381
|
-
}
|
|
8382
|
-
discardMeasurements() {
|
|
8383
|
-
return;
|
|
8384
|
-
}
|
|
8385
|
-
removePerformanceCallback() {
|
|
8386
|
-
return true;
|
|
8387
|
-
}
|
|
8388
|
-
addPerformanceCallback() {
|
|
8389
|
-
return "";
|
|
8390
|
-
}
|
|
8391
|
-
emitEvents() {
|
|
8392
|
-
return;
|
|
8393
|
-
}
|
|
8394
|
-
addFields() {
|
|
8395
|
-
return;
|
|
8396
|
-
}
|
|
8397
|
-
incrementFields() {
|
|
8398
|
-
return;
|
|
8399
|
-
}
|
|
8400
|
-
cacheEventByCorrelationId() {
|
|
8401
|
-
return;
|
|
8402
|
-
}
|
|
8403
|
-
}
|
|
8404
|
-
|
|
8405
|
-
/*
|
|
8406
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
8407
|
-
* Licensed under the MIT License.
|
|
8408
|
-
*/
|
|
8409
|
-
/**
|
|
8410
|
-
* Starts context by adding payload to the stack
|
|
8411
|
-
* @param event {PerformanceEvent}
|
|
8412
|
-
* @param abbreviations {Map<string, string>} event name abbreviations
|
|
8413
|
-
* @param stack {?PerformanceEventStackedContext[]} stack
|
|
8414
|
-
*/
|
|
8415
|
-
function startContext(event, abbreviations, stack) {
|
|
8416
|
-
if (!stack) {
|
|
8417
|
-
return;
|
|
8418
|
-
}
|
|
8419
|
-
stack.push({
|
|
8420
|
-
name: abbreviations.get(event.name) || event.name,
|
|
8421
|
-
});
|
|
8422
|
-
}
|
|
8423
|
-
/**
|
|
8424
|
-
* Ends context by removing payload from the stack and returning parent or self, if stack is empty, payload
|
|
8425
|
-
*
|
|
8426
|
-
* @param event {PerformanceEvent}
|
|
8427
|
-
* @param abbreviations {Map<string, string>} event name abbreviations
|
|
8428
|
-
* @param stack {?PerformanceEventStackedContext[]} stack
|
|
8429
|
-
* @param error {?unknown} error
|
|
8430
|
-
*/
|
|
8431
|
-
function endContext(event, abbreviations, stack, error) {
|
|
8432
|
-
if (!stack?.length) {
|
|
8433
|
-
return;
|
|
8434
|
-
}
|
|
8435
|
-
const peek = (stack) => {
|
|
8436
|
-
return stack.length ? stack[stack.length - 1] : undefined;
|
|
8437
|
-
};
|
|
8438
|
-
const abbrEventName = abbreviations.get(event.name) || event.name;
|
|
8439
|
-
const top = peek(stack);
|
|
8440
|
-
if (top?.name !== abbrEventName) {
|
|
8441
|
-
return;
|
|
8442
|
-
}
|
|
8443
|
-
const current = stack?.pop();
|
|
8444
|
-
if (!current) {
|
|
8445
|
-
return;
|
|
8446
|
-
}
|
|
8447
|
-
const errorCode = error instanceof AuthError
|
|
8448
|
-
? error.errorCode
|
|
8449
|
-
: error instanceof Error
|
|
8450
|
-
? error.name
|
|
8451
|
-
: undefined;
|
|
8452
|
-
const subErr = error instanceof AuthError ? error.subError : undefined;
|
|
8453
|
-
if (errorCode && current.childErr !== errorCode) {
|
|
8454
|
-
current.err = errorCode;
|
|
8455
|
-
if (subErr) {
|
|
8456
|
-
current.subErr = subErr;
|
|
8457
|
-
}
|
|
8458
|
-
}
|
|
8459
|
-
delete current.name;
|
|
8460
|
-
delete current.childErr;
|
|
8461
|
-
const context = {
|
|
8462
|
-
...current,
|
|
8463
|
-
dur: event.durationMs,
|
|
8464
|
-
};
|
|
8465
|
-
if (!event.success) {
|
|
8466
|
-
context.fail = 1;
|
|
8467
|
-
}
|
|
8468
|
-
const parent = peek(stack);
|
|
8469
|
-
if (!parent) {
|
|
8470
|
-
return { [abbrEventName]: context };
|
|
8471
|
-
}
|
|
8472
|
-
if (errorCode) {
|
|
8473
|
-
parent.childErr = errorCode;
|
|
8474
|
-
}
|
|
8475
|
-
let childName;
|
|
8476
|
-
if (!parent[abbrEventName]) {
|
|
8477
|
-
childName = abbrEventName;
|
|
8478
|
-
}
|
|
8479
|
-
else {
|
|
8480
|
-
const siblings = Object.keys(parent).filter((key) => key.startsWith(abbrEventName)).length;
|
|
8481
|
-
childName = `${abbrEventName}_${siblings + 1}`;
|
|
8482
|
-
}
|
|
8483
|
-
parent[childName] = context;
|
|
8484
|
-
return parent;
|
|
8485
|
-
}
|
|
8486
|
-
/**
|
|
8487
|
-
* Adds error name and stack trace to the telemetry event
|
|
8488
|
-
* @param error {Error}
|
|
8489
|
-
* @param logger {Logger}
|
|
8490
|
-
* @param event {PerformanceEvent}
|
|
8491
|
-
* @param stackMaxSize {number} max error stack size to capture
|
|
8492
|
-
*/
|
|
8493
|
-
function addError(error, logger, event, stackMaxSize = 5) {
|
|
8494
|
-
if (!(error instanceof Error)) {
|
|
8495
|
-
logger.trace("PerformanceClient.addErrorStack: Input error is not instance of Error", event.correlationId);
|
|
8496
|
-
return;
|
|
8497
|
-
}
|
|
8498
|
-
else if (error instanceof AuthError) {
|
|
8499
|
-
event.errorCode = error.errorCode;
|
|
8500
|
-
event.subErrorCode = error.subError;
|
|
8501
|
-
if (error instanceof ServerError ||
|
|
8502
|
-
error instanceof InteractionRequiredAuthError) {
|
|
8503
|
-
event.serverErrorNo = error.errorNo;
|
|
8504
|
-
}
|
|
8505
|
-
return;
|
|
8506
|
-
}
|
|
8507
|
-
else if (error instanceof CacheError) {
|
|
8508
|
-
event.errorCode = error.errorCode;
|
|
8509
|
-
return;
|
|
8510
|
-
}
|
|
8511
|
-
else if (event.errorStack?.length) {
|
|
8512
|
-
logger.trace("PerformanceClient.addErrorStack: Stack already exist", event.correlationId);
|
|
8513
|
-
return;
|
|
8514
|
-
}
|
|
8515
|
-
else if (!error.stack?.length) {
|
|
8516
|
-
logger.trace("PerformanceClient.addErrorStack: Input stack is empty", event.correlationId);
|
|
8517
|
-
return;
|
|
8518
|
-
}
|
|
8519
|
-
if (error.stack) {
|
|
8520
|
-
event.errorStack = compactStack(error.stack, stackMaxSize);
|
|
8521
|
-
}
|
|
8522
|
-
event.errorName = error.name;
|
|
8523
|
-
}
|
|
8524
|
-
/**
|
|
8525
|
-
* Compacts error stack into array by fetching N first entries
|
|
8526
|
-
* @param stack {string} error stack
|
|
8527
|
-
* @param stackMaxSize {number} max error stack size to capture
|
|
8528
|
-
* @returns {string[]}
|
|
8529
|
-
*/
|
|
8530
|
-
function compactStack(stack, stackMaxSize) {
|
|
8531
|
-
if (stackMaxSize < 0) {
|
|
8532
|
-
return [];
|
|
8533
|
-
}
|
|
8534
|
-
const stackArr = stack.split("\n") || [];
|
|
8535
|
-
if (stackArr.length < 2) {
|
|
8536
|
-
return [];
|
|
8537
|
-
}
|
|
8538
|
-
const res = [];
|
|
8539
|
-
// Get top N stack lines
|
|
8540
|
-
for (
|
|
8541
|
-
// Skip first line as it may contain PII data
|
|
8542
|
-
let ix = Math.max(stackArr.length - stackMaxSize - 1, 1); ix < stackArr.length; ix++) {
|
|
8543
|
-
const line = stackArr[ix];
|
|
8544
|
-
if (res.length >= stackMaxSize) {
|
|
8545
|
-
break;
|
|
8546
|
-
}
|
|
8547
|
-
res.push(compactStackLine(line));
|
|
8548
|
-
}
|
|
8549
|
-
return res;
|
|
8550
|
-
}
|
|
8551
|
-
/**
|
|
8552
|
-
* Compacts error stack line by shortening file path
|
|
8553
|
-
* Example: https://localhost/msal-common/src/authority/Authority.js:100:1 -> Authority.js:100:1
|
|
8554
|
-
* @param line {string} stack line
|
|
8555
|
-
* @returns {string}
|
|
8556
|
-
*/
|
|
8557
|
-
function compactStackLine(line) {
|
|
8558
|
-
const filePathIx = line.lastIndexOf(" ") + 1;
|
|
8559
|
-
if (filePathIx < 1) {
|
|
8560
|
-
return line;
|
|
8561
|
-
}
|
|
8562
|
-
const filePath = line.substring(filePathIx);
|
|
8563
|
-
let fileNameIx = filePath.lastIndexOf("/");
|
|
8564
|
-
fileNameIx = fileNameIx < 0 ? filePath.lastIndexOf("\\") : fileNameIx;
|
|
8565
|
-
if (fileNameIx >= 0) {
|
|
8566
|
-
return (line.substring(0, filePathIx) +
|
|
8567
|
-
"(" +
|
|
8568
|
-
filePath.substring(fileNameIx + 1) +
|
|
8569
|
-
(filePath.charAt(filePath.length - 1) === ")" ? "" : ")")).trimStart();
|
|
8570
|
-
}
|
|
8571
|
-
return line.trimStart();
|
|
8572
|
-
}
|
|
8573
|
-
class PerformanceClient {
|
|
8574
|
-
/**
|
|
8575
|
-
* Creates an instance of PerformanceClient,
|
|
8576
|
-
* an abstract class containing core performance telemetry logic.
|
|
8577
|
-
*
|
|
8578
|
-
* @constructor
|
|
8579
|
-
* @param {string} clientId Client ID of the application
|
|
8580
|
-
* @param {string} authority Authority used by the application
|
|
8581
|
-
* @param {Logger} logger Logger used by the application
|
|
8582
|
-
* @param {string} libraryName Name of the library
|
|
8583
|
-
* @param {string} libraryVersion Version of the library
|
|
8584
|
-
* @param {ApplicationTelemetry} applicationTelemetry application name and version
|
|
8585
|
-
* @param {Set<String>} intFields integer fields to be truncated
|
|
8586
|
-
* @param {Map<string, string>} abbreviations event name abbreviations
|
|
8587
|
-
*/
|
|
8588
|
-
constructor(clientId, authority, logger, libraryName, libraryVersion, applicationTelemetry, intFields, abbreviations) {
|
|
8589
|
-
this.authority = authority;
|
|
8590
|
-
this.libraryName = libraryName;
|
|
8591
|
-
this.libraryVersion = libraryVersion;
|
|
8592
|
-
this.applicationTelemetry = applicationTelemetry;
|
|
8593
|
-
this.clientId = clientId;
|
|
8594
|
-
this.logger = logger;
|
|
8595
|
-
this.callbacks = new Map();
|
|
8596
|
-
this.eventsByCorrelationId = new Map();
|
|
8597
|
-
this.eventStack = new Map();
|
|
8598
|
-
this.queueMeasurements = new Map();
|
|
8599
|
-
this.preQueueTimeByCorrelationId = new Map();
|
|
8600
|
-
this.intFields = intFields || new Set();
|
|
8601
|
-
for (const item of IntFields) {
|
|
8602
|
-
this.intFields.add(item);
|
|
8603
|
-
}
|
|
8604
|
-
this.abbreviations = abbreviations || new Map();
|
|
8605
|
-
for (const [key, value] of PerformanceEventAbbreviations) {
|
|
8606
|
-
this.abbreviations.set(key, value);
|
|
8607
|
-
}
|
|
8608
|
-
}
|
|
8609
|
-
/**
|
|
8610
|
-
* Starts and returns an platform-specific implementation of IPerformanceMeasurement.
|
|
8611
|
-
* Note: this function can be changed to abstract at the next major version bump.
|
|
8612
|
-
*
|
|
8613
|
-
* @param {string} measureName
|
|
8614
|
-
* @param {string} correlationId
|
|
8615
|
-
* @returns {IPerformanceMeasurement}
|
|
8616
|
-
* @deprecated This method will be removed in the next major version
|
|
8617
|
-
*/
|
|
8618
|
-
startPerformanceMeasurement(measureName, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
8619
|
-
correlationId // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
8620
|
-
) {
|
|
8621
|
-
return {};
|
|
8622
|
-
}
|
|
8623
|
-
/**
|
|
8624
|
-
* Gets map of pre-queue times by correlation Id
|
|
8625
|
-
*
|
|
8626
|
-
* @param {PerformanceEvents} eventName
|
|
8627
|
-
* @param {string} correlationId
|
|
8628
|
-
* @returns {number}
|
|
8629
|
-
*/
|
|
8630
|
-
getPreQueueTime(eventName, correlationId) {
|
|
8631
|
-
const preQueueEvent = this.preQueueTimeByCorrelationId.get(correlationId);
|
|
8632
|
-
if (!preQueueEvent) {
|
|
8633
|
-
this.logger.trace(`PerformanceClient.getPreQueueTime: no pre-queue times found for correlationId: ${correlationId}, unable to add queue measurement`);
|
|
8634
|
-
return;
|
|
8635
|
-
}
|
|
8636
|
-
else if (preQueueEvent.name !== eventName) {
|
|
8637
|
-
this.logger.trace(`PerformanceClient.getPreQueueTime: no pre-queue time found for ${eventName}, unable to add queue measurement`);
|
|
8638
|
-
return;
|
|
8639
|
-
}
|
|
8640
|
-
return preQueueEvent.time;
|
|
8641
|
-
}
|
|
8642
|
-
/**
|
|
8643
|
-
* Calculates the difference between current time and time when function was queued.
|
|
8644
|
-
* Note: It is possible to have 0 as the queue time if the current time and the queued time was the same.
|
|
8645
|
-
*
|
|
8646
|
-
* @param {number} preQueueTime
|
|
8647
|
-
* @param {number} currentTime
|
|
8648
|
-
* @returns {number}
|
|
8649
|
-
*/
|
|
8650
|
-
calculateQueuedTime(preQueueTime, currentTime) {
|
|
8651
|
-
if (preQueueTime < 1) {
|
|
8652
|
-
this.logger.trace(`PerformanceClient: preQueueTime should be a positive integer and not ${preQueueTime}`);
|
|
8653
|
-
return 0;
|
|
8654
|
-
}
|
|
8655
|
-
if (currentTime < 1) {
|
|
8656
|
-
this.logger.trace(`PerformanceClient: currentTime should be a positive integer and not ${currentTime}`);
|
|
8657
|
-
return 0;
|
|
8658
|
-
}
|
|
8659
|
-
if (currentTime < preQueueTime) {
|
|
8660
|
-
this.logger.trace("PerformanceClient: currentTime is less than preQueueTime, check how time is being retrieved");
|
|
8661
|
-
return 0;
|
|
8662
|
-
}
|
|
8663
|
-
return currentTime - preQueueTime;
|
|
8664
|
-
}
|
|
8665
|
-
/**
|
|
8666
|
-
* Adds queue measurement time to QueueMeasurements array for given correlation ID.
|
|
8667
|
-
*
|
|
8668
|
-
* @param {PerformanceEvents} eventName
|
|
8669
|
-
* @param {?string} correlationId
|
|
8670
|
-
* @param {?number} queueTime
|
|
8671
|
-
* @param {?boolean} manuallyCompleted - indicator for manually completed queue measurements
|
|
8672
|
-
* @returns
|
|
8673
|
-
*/
|
|
8674
|
-
addQueueMeasurement(eventName, correlationId, queueTime, manuallyCompleted) {
|
|
8675
|
-
if (!correlationId) {
|
|
8676
|
-
this.logger.trace(`PerformanceClient.addQueueMeasurement: correlationId not provided for ${eventName}, cannot add queue measurement`);
|
|
8677
|
-
return;
|
|
8678
|
-
}
|
|
8679
|
-
if (queueTime === 0) {
|
|
8680
|
-
// Possible for there to be no queue time after calculation
|
|
8681
|
-
this.logger.trace(`PerformanceClient.addQueueMeasurement: queue time provided for ${eventName} is ${queueTime}`);
|
|
8682
|
-
}
|
|
8683
|
-
else if (!queueTime) {
|
|
8684
|
-
this.logger.trace(`PerformanceClient.addQueueMeasurement: no queue time provided for ${eventName}`);
|
|
8685
|
-
return;
|
|
8686
|
-
}
|
|
8687
|
-
const queueMeasurement = {
|
|
8688
|
-
eventName,
|
|
8689
|
-
// Always default queue time to 0 for manually completed (improperly instrumented)
|
|
8690
|
-
queueTime: manuallyCompleted ? 0 : queueTime,
|
|
8691
|
-
manuallyCompleted,
|
|
8692
|
-
};
|
|
8693
|
-
// Adds to existing correlation Id if present in queueMeasurements
|
|
8694
|
-
const existingMeasurements = this.queueMeasurements.get(correlationId);
|
|
8695
|
-
if (existingMeasurements) {
|
|
8696
|
-
existingMeasurements.push(queueMeasurement);
|
|
8697
|
-
this.queueMeasurements.set(correlationId, existingMeasurements);
|
|
8698
|
-
}
|
|
8699
|
-
else {
|
|
8700
|
-
// Sets new correlation Id if not present in queueMeasurements
|
|
8701
|
-
this.logger.trace(`PerformanceClient.addQueueMeasurement: adding correlationId ${correlationId} to queue measurements`);
|
|
8702
|
-
const measurementArray = [queueMeasurement];
|
|
8703
|
-
this.queueMeasurements.set(correlationId, measurementArray);
|
|
8704
|
-
}
|
|
8705
|
-
// Delete processed pre-queue event.
|
|
8706
|
-
this.preQueueTimeByCorrelationId.delete(correlationId);
|
|
8707
|
-
}
|
|
8708
|
-
/**
|
|
8709
|
-
* Starts measuring performance for a given operation. Returns a function that should be used to end the measurement.
|
|
8710
|
-
*
|
|
8711
|
-
* @param {PerformanceEvents} measureName
|
|
8712
|
-
* @param {?string} [correlationId]
|
|
8713
|
-
* @returns {InProgressPerformanceEvent}
|
|
8714
|
-
*/
|
|
8715
|
-
startMeasurement(measureName, correlationId) {
|
|
8716
|
-
// Generate a placeholder correlation if the request does not provide one
|
|
8717
|
-
const eventCorrelationId = correlationId || this.generateId();
|
|
8718
|
-
if (!correlationId) {
|
|
8719
|
-
this.logger.info(`PerformanceClient: No correlation id provided for ${measureName}, generating`, eventCorrelationId);
|
|
8720
|
-
}
|
|
8721
|
-
this.logger.trace(`PerformanceClient: Performance measurement started for ${measureName}`, eventCorrelationId);
|
|
8722
|
-
const inProgressEvent = {
|
|
8723
|
-
eventId: this.generateId(),
|
|
8724
|
-
status: PerformanceEventStatus.InProgress,
|
|
8725
|
-
authority: this.authority,
|
|
8726
|
-
libraryName: this.libraryName,
|
|
8727
|
-
libraryVersion: this.libraryVersion,
|
|
8728
|
-
clientId: this.clientId,
|
|
8729
|
-
name: measureName,
|
|
8730
|
-
startTimeMs: Date.now(),
|
|
8731
|
-
correlationId: eventCorrelationId,
|
|
8732
|
-
appName: this.applicationTelemetry?.appName,
|
|
8733
|
-
appVersion: this.applicationTelemetry?.appVersion,
|
|
8734
|
-
};
|
|
8735
|
-
// Store in progress events so they can be discarded if not ended properly
|
|
8736
|
-
this.cacheEventByCorrelationId(inProgressEvent);
|
|
8737
|
-
startContext(inProgressEvent, this.abbreviations, this.eventStack.get(eventCorrelationId));
|
|
8738
|
-
// Return the event and functions the caller can use to properly end/flush the measurement
|
|
8739
|
-
return {
|
|
8740
|
-
end: (event, error) => {
|
|
8741
|
-
return this.endMeasurement({
|
|
8742
|
-
// Initial set of event properties
|
|
8743
|
-
...inProgressEvent,
|
|
8744
|
-
// Properties set when event ends
|
|
8745
|
-
...event,
|
|
8746
|
-
}, error);
|
|
8747
|
-
},
|
|
8748
|
-
discard: () => {
|
|
8749
|
-
return this.discardMeasurements(inProgressEvent.correlationId);
|
|
8750
|
-
},
|
|
8751
|
-
add: (fields) => {
|
|
8752
|
-
return this.addFields(fields, inProgressEvent.correlationId);
|
|
8753
|
-
},
|
|
8754
|
-
increment: (fields) => {
|
|
8755
|
-
return this.incrementFields(fields, inProgressEvent.correlationId);
|
|
8756
|
-
},
|
|
8757
|
-
event: inProgressEvent,
|
|
8758
|
-
measurement: new StubPerformanceMeasurement(),
|
|
8759
|
-
};
|
|
8760
|
-
}
|
|
8761
|
-
/**
|
|
8762
|
-
* Stops measuring the performance for an operation. Should only be called directly by PerformanceClient classes,
|
|
8763
|
-
* as consumers should instead use the function returned by startMeasurement.
|
|
8764
|
-
* Adds a new field named as "[event name]DurationMs" for sub-measurements, completes and emits an event
|
|
8765
|
-
* otherwise.
|
|
8766
|
-
*
|
|
8767
|
-
* @param {PerformanceEvent} event
|
|
8768
|
-
* @param {unknown} error
|
|
8769
|
-
* @returns {(PerformanceEvent | null)}
|
|
8770
|
-
*/
|
|
8771
|
-
endMeasurement(event, error) {
|
|
8772
|
-
const rootEvent = this.eventsByCorrelationId.get(event.correlationId);
|
|
8773
|
-
if (!rootEvent) {
|
|
8774
|
-
this.logger.trace(`PerformanceClient: Measurement not found for ${event.eventId}`, event.correlationId);
|
|
8775
|
-
return null;
|
|
8776
|
-
}
|
|
8777
|
-
const isRoot = event.eventId === rootEvent.eventId;
|
|
8778
|
-
let queueInfo = {
|
|
8779
|
-
totalQueueTime: 0,
|
|
8780
|
-
totalQueueCount: 0,
|
|
8781
|
-
manuallyCompletedCount: 0,
|
|
8782
|
-
};
|
|
8783
|
-
event.durationMs = Math.round(event.durationMs || this.getDurationMs(event.startTimeMs));
|
|
8784
|
-
const context = JSON.stringify(endContext(event, this.abbreviations, this.eventStack.get(rootEvent.correlationId), error));
|
|
8785
|
-
if (isRoot) {
|
|
8786
|
-
queueInfo = this.getQueueInfo(event.correlationId);
|
|
8787
|
-
this.discardMeasurements(rootEvent.correlationId);
|
|
8788
|
-
}
|
|
8789
|
-
else {
|
|
8790
|
-
rootEvent.incompleteSubMeasurements?.delete(event.eventId);
|
|
8791
|
-
}
|
|
8792
|
-
this.logger.trace(`PerformanceClient: Performance measurement ended for ${event.name}: ${event.durationMs} ms`, event.correlationId);
|
|
8793
|
-
// Add sub-measurement attribute to root event.
|
|
8794
|
-
if (!isRoot) {
|
|
8795
|
-
rootEvent[event.name + "DurationMs"] = Math.floor(event.durationMs);
|
|
8796
|
-
return { ...rootEvent };
|
|
8797
|
-
}
|
|
8798
|
-
if (error) {
|
|
8799
|
-
addError(error, this.logger, rootEvent);
|
|
8800
|
-
}
|
|
8801
|
-
let finalEvent = { ...rootEvent, ...event };
|
|
8802
|
-
let incompleteSubsCount = 0;
|
|
8803
|
-
// Incomplete sub-measurements are discarded. They are likely an instrumentation bug that should be fixed.
|
|
8804
|
-
finalEvent.incompleteSubMeasurements?.forEach((subMeasurement) => {
|
|
8805
|
-
this.logger.trace(`PerformanceClient: Incomplete submeasurement ${subMeasurement.name} found for ${event.name}`, finalEvent.correlationId);
|
|
8806
|
-
incompleteSubsCount++;
|
|
8807
|
-
});
|
|
8808
|
-
finalEvent.incompleteSubMeasurements = undefined;
|
|
8809
|
-
finalEvent = {
|
|
8810
|
-
...finalEvent,
|
|
8811
|
-
queuedTimeMs: queueInfo.totalQueueTime,
|
|
8812
|
-
queuedCount: queueInfo.totalQueueCount,
|
|
8813
|
-
queuedManuallyCompletedCount: queueInfo.manuallyCompletedCount,
|
|
8814
|
-
status: PerformanceEventStatus.Completed,
|
|
8815
|
-
incompleteSubsCount,
|
|
8816
|
-
context,
|
|
8817
|
-
};
|
|
8818
|
-
this.truncateIntegralFields(finalEvent);
|
|
8819
|
-
this.emitEvents([finalEvent], event.correlationId);
|
|
8820
|
-
return finalEvent;
|
|
8821
|
-
}
|
|
8822
|
-
/**
|
|
8823
|
-
* Saves extra information to be emitted when the measurements are flushed
|
|
8824
|
-
* @param fields
|
|
8825
|
-
* @param correlationId
|
|
8826
|
-
*/
|
|
8827
|
-
addFields(fields, correlationId) {
|
|
8828
|
-
this.logger.trace("PerformanceClient: Updating static fields");
|
|
8829
|
-
const event = this.eventsByCorrelationId.get(correlationId);
|
|
8830
|
-
if (event) {
|
|
8831
|
-
this.eventsByCorrelationId.set(correlationId, {
|
|
8832
|
-
...event,
|
|
8833
|
-
...fields,
|
|
8834
|
-
});
|
|
8835
|
-
}
|
|
8836
|
-
else {
|
|
8837
|
-
this.logger.trace("PerformanceClient: Event not found for", correlationId);
|
|
8838
|
-
}
|
|
8839
|
-
}
|
|
8840
|
-
/**
|
|
8841
|
-
* Increment counters to be emitted when the measurements are flushed
|
|
8842
|
-
* @param fields {string[]}
|
|
8843
|
-
* @param correlationId {string} correlation identifier
|
|
8844
|
-
*/
|
|
8845
|
-
incrementFields(fields, correlationId) {
|
|
8846
|
-
this.logger.trace("PerformanceClient: Updating counters");
|
|
8847
|
-
const event = this.eventsByCorrelationId.get(correlationId);
|
|
8848
|
-
if (event) {
|
|
8849
|
-
for (const counter in fields) {
|
|
8850
|
-
if (!event.hasOwnProperty(counter)) {
|
|
8851
|
-
event[counter] = 0;
|
|
8852
|
-
}
|
|
8853
|
-
else if (isNaN(Number(event[counter]))) {
|
|
8854
|
-
return;
|
|
8855
|
-
}
|
|
8856
|
-
event[counter] += fields[counter];
|
|
8857
|
-
}
|
|
8858
|
-
}
|
|
8859
|
-
else {
|
|
8860
|
-
this.logger.trace("PerformanceClient: Event not found for", correlationId);
|
|
8861
|
-
}
|
|
8862
|
-
}
|
|
8863
|
-
/**
|
|
8864
|
-
* Upserts event into event cache.
|
|
8865
|
-
* First key is the correlation id, second key is the event id.
|
|
8866
|
-
* Allows for events to be grouped by correlation id,
|
|
8867
|
-
* and to easily allow for properties on them to be updated.
|
|
8868
|
-
*
|
|
8869
|
-
* @private
|
|
8870
|
-
* @param {PerformanceEvent} event
|
|
8871
|
-
*/
|
|
8872
|
-
cacheEventByCorrelationId(event) {
|
|
8873
|
-
const rootEvent = this.eventsByCorrelationId.get(event.correlationId);
|
|
8874
|
-
if (rootEvent) {
|
|
8875
|
-
this.logger.trace(`PerformanceClient: Performance measurement for ${event.name} added/updated`, event.correlationId);
|
|
8876
|
-
rootEvent.incompleteSubMeasurements =
|
|
8877
|
-
rootEvent.incompleteSubMeasurements || new Map();
|
|
8878
|
-
rootEvent.incompleteSubMeasurements.set(event.eventId, {
|
|
8879
|
-
name: event.name,
|
|
8880
|
-
startTimeMs: event.startTimeMs,
|
|
8881
|
-
});
|
|
8882
|
-
}
|
|
8883
|
-
else {
|
|
8884
|
-
this.logger.trace(`PerformanceClient: Performance measurement for ${event.name} started`, event.correlationId);
|
|
8885
|
-
this.eventsByCorrelationId.set(event.correlationId, { ...event });
|
|
8886
|
-
this.eventStack.set(event.correlationId, []);
|
|
8887
|
-
}
|
|
8888
|
-
}
|
|
8889
|
-
getQueueInfo(correlationId) {
|
|
8890
|
-
const queueMeasurementForCorrelationId = this.queueMeasurements.get(correlationId);
|
|
8891
|
-
if (!queueMeasurementForCorrelationId) {
|
|
8892
|
-
this.logger.trace(`PerformanceClient: no queue measurements found for for correlationId: ${correlationId}`);
|
|
8893
|
-
}
|
|
8894
|
-
let totalQueueTime = 0;
|
|
8895
|
-
let totalQueueCount = 0;
|
|
8896
|
-
let manuallyCompletedCount = 0;
|
|
8897
|
-
queueMeasurementForCorrelationId?.forEach((measurement) => {
|
|
8898
|
-
totalQueueTime += measurement.queueTime;
|
|
8899
|
-
totalQueueCount++;
|
|
8900
|
-
manuallyCompletedCount += measurement.manuallyCompleted ? 1 : 0;
|
|
8901
|
-
});
|
|
8902
|
-
return {
|
|
8903
|
-
totalQueueTime,
|
|
8904
|
-
totalQueueCount,
|
|
8905
|
-
manuallyCompletedCount,
|
|
8906
|
-
};
|
|
8907
|
-
}
|
|
8908
|
-
/**
|
|
8909
|
-
* Removes measurements and aux data for a given correlation id.
|
|
8910
|
-
*
|
|
8911
|
-
* @param {string} correlationId
|
|
8912
|
-
*/
|
|
8913
|
-
discardMeasurements(correlationId) {
|
|
8914
|
-
this.logger.trace("PerformanceClient: Performance measurements discarded", correlationId);
|
|
8915
|
-
this.eventsByCorrelationId.delete(correlationId);
|
|
8916
|
-
this.logger.trace("PerformanceClient: QueueMeasurements discarded", correlationId);
|
|
8917
|
-
this.queueMeasurements.delete(correlationId);
|
|
8918
|
-
this.logger.trace("PerformanceClient: Pre-queue times discarded", correlationId);
|
|
8919
|
-
this.preQueueTimeByCorrelationId.delete(correlationId);
|
|
8920
|
-
this.logger.trace("PerformanceClient: Event stack discarded", correlationId);
|
|
8921
|
-
this.eventStack.delete(correlationId);
|
|
8922
|
-
}
|
|
8923
|
-
/**
|
|
8924
|
-
* Registers a callback function to receive performance events.
|
|
8925
|
-
*
|
|
8926
|
-
* @param {PerformanceCallbackFunction} callback
|
|
8927
|
-
* @returns {string}
|
|
8928
|
-
*/
|
|
8929
|
-
addPerformanceCallback(callback) {
|
|
8930
|
-
for (const [id, cb] of this.callbacks) {
|
|
8931
|
-
if (cb.toString() === callback.toString()) {
|
|
8932
|
-
this.logger.warning(`PerformanceClient: Performance callback is already registered with id: ${id}`);
|
|
8933
|
-
return id;
|
|
8934
|
-
}
|
|
8935
|
-
}
|
|
8936
|
-
const callbackId = this.generateId();
|
|
8937
|
-
this.callbacks.set(callbackId, callback);
|
|
8938
|
-
this.logger.verbose(`PerformanceClient: Performance callback registered with id: ${callbackId}`);
|
|
8939
|
-
return callbackId;
|
|
8940
|
-
}
|
|
8941
|
-
/**
|
|
8942
|
-
* Removes a callback registered with addPerformanceCallback.
|
|
8943
|
-
*
|
|
8944
|
-
* @param {string} callbackId
|
|
8945
|
-
* @returns {boolean}
|
|
8946
|
-
*/
|
|
8947
|
-
removePerformanceCallback(callbackId) {
|
|
8948
|
-
const result = this.callbacks.delete(callbackId);
|
|
8949
|
-
if (result) {
|
|
8950
|
-
this.logger.verbose(`PerformanceClient: Performance callback ${callbackId} removed.`);
|
|
8951
|
-
}
|
|
8952
|
-
else {
|
|
8953
|
-
this.logger.verbose(`PerformanceClient: Performance callback ${callbackId} not removed.`);
|
|
8954
|
-
}
|
|
8955
|
-
return result;
|
|
8956
|
-
}
|
|
8957
|
-
/**
|
|
8958
|
-
* Emits events to all registered callbacks.
|
|
8959
|
-
*
|
|
8960
|
-
* @param {PerformanceEvent[]} events
|
|
8961
|
-
* @param {?string} [correlationId]
|
|
8962
|
-
*/
|
|
8963
|
-
emitEvents(events, correlationId) {
|
|
8964
|
-
this.logger.verbose("PerformanceClient: Emitting performance events", correlationId);
|
|
8965
|
-
this.callbacks.forEach((callback, callbackId) => {
|
|
8966
|
-
this.logger.trace(`PerformanceClient: Emitting event to callback ${callbackId}`, correlationId);
|
|
8967
|
-
callback.apply(null, [events]);
|
|
8968
|
-
});
|
|
8969
|
-
}
|
|
8970
|
-
/**
|
|
8971
|
-
* Enforce truncation of integral fields in performance event.
|
|
8972
|
-
* @param {PerformanceEvent} event performance event to update.
|
|
8973
|
-
*/
|
|
8974
|
-
truncateIntegralFields(event) {
|
|
8975
|
-
this.intFields.forEach((key) => {
|
|
8976
|
-
if (key in event && typeof event[key] === "number") {
|
|
8977
|
-
event[key] = Math.floor(event[key]);
|
|
8978
|
-
}
|
|
8979
|
-
});
|
|
8980
|
-
}
|
|
8981
|
-
/**
|
|
8982
|
-
* Returns event duration in milliseconds
|
|
8983
|
-
* @param startTimeMs {number}
|
|
8984
|
-
* @returns {number}
|
|
8985
|
-
*/
|
|
8986
|
-
getDurationMs(startTimeMs) {
|
|
8987
|
-
const durationMs = Date.now() - startTimeMs;
|
|
8988
|
-
// Handle clock skew
|
|
8989
|
-
return durationMs < 0 ? durationMs : 0;
|
|
8990
|
-
}
|
|
8991
|
-
}
|
|
8992
|
-
|
|
8993
8356
|
exports.AADAuthorityConstants = AADAuthorityConstants;
|
|
8994
8357
|
exports.AADServerParamKeys = AADServerParamKeys;
|
|
8995
8358
|
exports.AccountEntity = AccountEntity;
|
|
@@ -9036,14 +8399,13 @@ exports.IntFields = IntFields;
|
|
|
9036
8399
|
exports.InteractionRequiredAuthError = InteractionRequiredAuthError;
|
|
9037
8400
|
exports.InteractionRequiredAuthErrorCodes = InteractionRequiredAuthErrorCodes;
|
|
9038
8401
|
exports.InteractionRequiredAuthErrorMessage = InteractionRequiredAuthErrorMessage;
|
|
9039
|
-
exports.JoseHeader = JoseHeader;
|
|
9040
8402
|
exports.JsonWebTokenTypes = JsonWebTokenTypes;
|
|
9041
8403
|
exports.Logger = Logger;
|
|
9042
|
-
exports.
|
|
8404
|
+
exports.NetworkError = NetworkError;
|
|
9043
8405
|
exports.OIDC_DEFAULT_SCOPES = OIDC_DEFAULT_SCOPES;
|
|
9044
8406
|
exports.ONE_DAY_IN_MS = ONE_DAY_IN_MS;
|
|
9045
8407
|
exports.PasswordGrantConstants = PasswordGrantConstants;
|
|
9046
|
-
exports.
|
|
8408
|
+
exports.PerformanceEventAbbreviations = PerformanceEventAbbreviations;
|
|
9047
8409
|
exports.PerformanceEventStatus = PerformanceEventStatus;
|
|
9048
8410
|
exports.PerformanceEvents = PerformanceEvents;
|
|
9049
8411
|
exports.PersistentCacheKeys = PersistentCacheKeys;
|
|
@@ -9061,7 +8423,6 @@ exports.ServerResponseType = ServerResponseType;
|
|
|
9061
8423
|
exports.ServerTelemetryManager = ServerTelemetryManager;
|
|
9062
8424
|
exports.SilentFlowClient = SilentFlowClient;
|
|
9063
8425
|
exports.StringUtils = StringUtils;
|
|
9064
|
-
exports.StubPerformanceClient = StubPerformanceClient;
|
|
9065
8426
|
exports.StubbedNetworkModule = StubbedNetworkModule;
|
|
9066
8427
|
exports.THE_FAMILY_ID = THE_FAMILY_ID;
|
|
9067
8428
|
exports.ThrottlingConstants = ThrottlingConstants;
|
|
@@ -9079,6 +8440,7 @@ exports.createAuthError = createAuthError;
|
|
|
9079
8440
|
exports.createClientAuthError = createClientAuthError;
|
|
9080
8441
|
exports.createClientConfigurationError = createClientConfigurationError;
|
|
9081
8442
|
exports.createInteractionRequiredAuthError = createInteractionRequiredAuthError;
|
|
8443
|
+
exports.createNetworkError = createNetworkError;
|
|
9082
8444
|
exports.formatAuthorityUri = formatAuthorityUri;
|
|
9083
8445
|
exports.getClientAssertion = getClientAssertion;
|
|
9084
8446
|
exports.getTenantIdFromIdTokenClaims = getTenantIdFromIdTokenClaims;
|
|
@@ -9087,4 +8449,4 @@ exports.invokeAsync = invokeAsync;
|
|
|
9087
8449
|
exports.tenantIdMatchesHomeTenant = tenantIdMatchesHomeTenant;
|
|
9088
8450
|
exports.updateAccountTenantProfileData = updateAccountTenantProfileData;
|
|
9089
8451
|
exports.version = version;
|
|
9090
|
-
//# sourceMappingURL=index.
|
|
8452
|
+
//# sourceMappingURL=index-node-C9XsExml.js.map
|