@azure/msal-common 16.0.0-alpha.0 → 16.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/account/AccountInfo.d.ts +3 -0
- package/dist/account/AccountInfo.d.ts.map +1 -1
- package/dist/account/AccountInfo.mjs +1 -1
- package/dist/account/AccountInfo.mjs.map +1 -1
- package/dist/account/AuthToken.d.ts +6 -0
- package/dist/account/AuthToken.d.ts.map +1 -1
- package/dist/account/AuthToken.mjs +21 -2
- package/dist/account/AuthToken.mjs.map +1 -1
- package/dist/account/CcsCredential.mjs +1 -1
- package/dist/account/CcsCredential.mjs.map +1 -1
- package/dist/account/ClientInfo.d.ts +5 -1
- package/dist/account/ClientInfo.d.ts.map +1 -1
- package/dist/account/ClientInfo.mjs +1 -1
- package/dist/account/ClientInfo.mjs.map +1 -1
- package/dist/account/TokenClaims.d.ts +4 -0
- package/dist/account/TokenClaims.d.ts.map +1 -1
- package/dist/account/TokenClaims.mjs +1 -1
- package/dist/account/TokenClaims.mjs.map +1 -1
- package/dist/authority/Authority.mjs +1 -1
- package/dist/authority/Authority.mjs.map +1 -1
- package/dist/authority/AuthorityFactory.mjs +1 -1
- package/dist/authority/AuthorityFactory.mjs.map +1 -1
- package/dist/authority/AuthorityMetadata.d.ts.map +1 -1
- package/dist/authority/AuthorityMetadata.mjs +27 -24
- package/dist/authority/AuthorityMetadata.mjs.map +1 -1
- package/dist/authority/AuthorityOptions.mjs +1 -1
- package/dist/authority/AuthorityOptions.mjs.map +1 -1
- package/dist/authority/AuthorityType.mjs +1 -1
- package/dist/authority/AuthorityType.mjs.map +1 -1
- package/dist/authority/CloudInstanceDiscoveryErrorResponse.mjs +1 -1
- package/dist/authority/CloudInstanceDiscoveryResponse.mjs +1 -1
- package/dist/authority/OpenIdConfigResponse.mjs +1 -1
- package/dist/authority/ProtocolMode.mjs +1 -1
- package/dist/authority/ProtocolMode.mjs.map +1 -1
- package/dist/authority/RegionDiscovery.mjs +1 -1
- package/dist/authority/RegionDiscovery.mjs.map +1 -1
- package/dist/cache/CacheManager.d.ts +5 -5
- package/dist/cache/CacheManager.d.ts.map +1 -1
- package/dist/cache/CacheManager.mjs +8 -8
- package/dist/cache/CacheManager.mjs.map +1 -1
- package/dist/cache/entities/AccountEntity.d.ts +2 -1
- package/dist/cache/entities/AccountEntity.d.ts.map +1 -1
- package/dist/cache/interface/ICacheManager.d.ts +5 -5
- package/dist/cache/interface/ICacheManager.d.ts.map +1 -1
- package/dist/cache/persistence/TokenCacheContext.mjs +1 -1
- package/dist/cache/persistence/TokenCacheContext.mjs.map +1 -1
- package/dist/cache/utils/AccountEntityUtils.d.ts +0 -7
- package/dist/cache/utils/AccountEntityUtils.d.ts.map +1 -1
- package/dist/cache/utils/AccountEntityUtils.mjs +9 -29
- package/dist/cache/utils/AccountEntityUtils.mjs.map +1 -1
- package/dist/cache/utils/CacheHelpers.mjs +1 -1
- package/dist/cache/utils/CacheHelpers.mjs.map +1 -1
- package/dist/client/AuthorizationCodeClient.d.ts +22 -3
- package/dist/client/AuthorizationCodeClient.d.ts.map +1 -1
- package/dist/client/AuthorizationCodeClient.mjs +51 -19
- package/dist/client/AuthorizationCodeClient.mjs.map +1 -1
- package/dist/client/RefreshTokenClient.d.ts +16 -3
- package/dist/client/RefreshTokenClient.d.ts.map +1 -1
- package/dist/client/RefreshTokenClient.mjs +41 -18
- package/dist/client/RefreshTokenClient.mjs.map +1 -1
- package/dist/client/SilentFlowClient.d.ts +16 -3
- package/dist/client/SilentFlowClient.d.ts.map +1 -1
- package/dist/client/SilentFlowClient.mjs +21 -4
- package/dist/client/SilentFlowClient.mjs.map +1 -1
- package/dist/config/ClientConfiguration.mjs +1 -1
- package/dist/config/ClientConfiguration.mjs.map +1 -1
- package/dist/constants/AADServerParamKeys.mjs +1 -1
- package/dist/crypto/ICrypto.mjs +1 -1
- package/dist/crypto/ICrypto.mjs.map +1 -1
- package/dist/crypto/JoseHeader.mjs +1 -1
- package/dist/crypto/JoseHeader.mjs.map +1 -1
- package/dist/crypto/PopTokenGenerator.mjs +1 -1
- package/dist/crypto/PopTokenGenerator.mjs.map +1 -1
- package/dist/error/AuthError.d.ts +5 -0
- package/dist/error/AuthError.d.ts.map +1 -1
- package/dist/error/AuthError.mjs +1 -1
- package/dist/error/AuthError.mjs.map +1 -1
- package/dist/error/AuthErrorCodes.mjs +1 -1
- package/dist/error/CacheError.mjs +1 -1
- package/dist/error/CacheError.mjs.map +1 -1
- package/dist/error/CacheErrorCodes.mjs +1 -1
- package/dist/error/ClientAuthError.mjs +1 -1
- package/dist/error/ClientAuthError.mjs.map +1 -1
- package/dist/error/ClientAuthErrorCodes.d.ts +1 -0
- package/dist/error/ClientAuthErrorCodes.d.ts.map +1 -1
- package/dist/error/ClientAuthErrorCodes.mjs +4 -3
- package/dist/error/ClientAuthErrorCodes.mjs.map +1 -1
- package/dist/error/ClientConfigurationError.mjs +1 -1
- package/dist/error/ClientConfigurationError.mjs.map +1 -1
- package/dist/error/ClientConfigurationErrorCodes.d.ts +1 -0
- package/dist/error/ClientConfigurationErrorCodes.d.ts.map +1 -1
- package/dist/error/ClientConfigurationErrorCodes.mjs +4 -3
- package/dist/error/ClientConfigurationErrorCodes.mjs.map +1 -1
- package/dist/error/InteractionRequiredAuthError.mjs +1 -1
- package/dist/error/InteractionRequiredAuthError.mjs.map +1 -1
- package/dist/error/InteractionRequiredAuthErrorCodes.mjs +1 -1
- package/dist/error/JoseHeaderError.mjs +1 -1
- package/dist/error/JoseHeaderError.mjs.map +1 -1
- package/dist/error/JoseHeaderErrorCodes.mjs +1 -1
- package/dist/error/NetworkError.mjs +1 -1
- package/dist/error/NetworkError.mjs.map +1 -1
- package/dist/error/PlatformBrokerError.d.ts +16 -0
- package/dist/error/PlatformBrokerError.d.ts.map +1 -0
- package/dist/error/PlatformBrokerError.mjs +49 -0
- package/dist/error/PlatformBrokerError.mjs.map +1 -0
- package/dist/error/ServerError.mjs +1 -1
- package/dist/error/ServerError.mjs.map +1 -1
- package/dist/exports-common.d.ts +4 -2
- package/dist/exports-common.d.ts.map +1 -1
- package/dist/exports-node-only.d.ts +1 -0
- package/dist/exports-node-only.d.ts.map +1 -1
- package/dist/index-node.mjs +7 -4
- package/dist/index-node.mjs.map +1 -1
- package/dist/index.mjs +7 -4
- package/dist/index.mjs.map +1 -1
- package/dist/logger/Logger.d.ts +24 -0
- package/dist/logger/Logger.d.ts.map +1 -1
- package/dist/logger/Logger.mjs +92 -4
- package/dist/logger/Logger.mjs.map +1 -1
- package/dist/network/INetworkModule.mjs +1 -1
- package/dist/network/INetworkModule.mjs.map +1 -1
- package/dist/network/RequestThumbprint.mjs +2 -2
- package/dist/network/RequestThumbprint.mjs.map +1 -1
- package/dist/network/ThrottlingUtils.mjs +1 -1
- package/dist/network/ThrottlingUtils.mjs.map +1 -1
- package/dist/packageMetadata.d.ts +1 -1
- package/dist/packageMetadata.d.ts.map +1 -1
- package/dist/packageMetadata.mjs +2 -2
- package/dist/protocol/Authorize.mjs +1 -1
- package/dist/protocol/Authorize.mjs.map +1 -1
- package/dist/protocol/Token.d.ts +40 -0
- package/dist/protocol/Token.d.ts.map +1 -0
- package/dist/protocol/Token.mjs +129 -0
- package/dist/protocol/Token.mjs.map +1 -0
- package/dist/request/AuthenticationHeaderParser.mjs +1 -1
- package/dist/request/AuthenticationHeaderParser.mjs.map +1 -1
- package/dist/request/BaseAuthRequest.d.ts +67 -22
- package/dist/request/BaseAuthRequest.d.ts.map +1 -1
- package/dist/request/CommonAuthorizationCodeRequest.d.ts +18 -12
- package/dist/request/CommonAuthorizationCodeRequest.d.ts.map +1 -1
- package/dist/request/CommonAuthorizationUrlRequest.d.ts +48 -29
- package/dist/request/CommonAuthorizationUrlRequest.d.ts.map +1 -1
- package/dist/request/CommonEndSessionRequest.d.ts +21 -7
- package/dist/request/CommonEndSessionRequest.d.ts.map +1 -1
- package/dist/request/CommonRefreshTokenRequest.d.ts +12 -9
- package/dist/request/CommonRefreshTokenRequest.d.ts.map +1 -1
- package/dist/request/CommonSilentFlowRequest.d.ts +12 -13
- package/dist/request/CommonSilentFlowRequest.d.ts.map +1 -1
- package/dist/request/RequestParameterBuilder.d.ts +3 -3
- package/dist/request/RequestParameterBuilder.d.ts.map +1 -1
- package/dist/request/RequestParameterBuilder.mjs +6 -6
- package/dist/request/RequestParameterBuilder.mjs.map +1 -1
- package/dist/request/ScopeSet.mjs +1 -1
- package/dist/request/ScopeSet.mjs.map +1 -1
- package/dist/response/ResponseHandler.d.ts +1 -1
- package/dist/response/ResponseHandler.d.ts.map +1 -1
- package/dist/response/ResponseHandler.mjs +6 -5
- package/dist/response/ResponseHandler.mjs.map +1 -1
- package/dist/telemetry/performance/IPerformanceClient.d.ts +2 -1
- package/dist/telemetry/performance/IPerformanceClient.d.ts.map +1 -1
- package/dist/telemetry/performance/PerformanceClient.d.ts +4 -1
- package/dist/telemetry/performance/PerformanceClient.d.ts.map +1 -1
- package/dist/telemetry/performance/PerformanceClient.mjs +30 -16
- package/dist/telemetry/performance/PerformanceClient.mjs.map +1 -1
- package/dist/telemetry/performance/PerformanceEvent.d.ts +6 -1
- package/dist/telemetry/performance/PerformanceEvent.d.ts.map +1 -1
- package/dist/telemetry/performance/PerformanceEvent.mjs +1 -1
- package/dist/telemetry/performance/PerformanceEvent.mjs.map +1 -1
- package/dist/telemetry/performance/PerformanceEvents.d.ts +1 -0
- package/dist/telemetry/performance/PerformanceEvents.d.ts.map +1 -1
- package/dist/telemetry/performance/PerformanceEvents.mjs +3 -2
- package/dist/telemetry/performance/PerformanceEvents.mjs.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.mjs +1 -1
- package/dist/telemetry/server/ServerTelemetryManager.mjs.map +1 -1
- package/dist/url/UrlString.mjs +1 -1
- package/dist/url/UrlString.mjs.map +1 -1
- package/dist/utils/ClientAssertionUtils.mjs +1 -1
- package/dist/utils/ClientAssertionUtils.mjs.map +1 -1
- package/dist/utils/Constants.d.ts +5 -0
- package/dist/utils/Constants.d.ts.map +1 -1
- package/dist/utils/Constants.mjs +6 -2
- package/dist/utils/Constants.mjs.map +1 -1
- package/dist/utils/FunctionWrappers.mjs +1 -1
- package/dist/utils/FunctionWrappers.mjs.map +1 -1
- package/dist/utils/ProtocolUtils.d.ts +14 -35
- package/dist/utils/ProtocolUtils.d.ts.map +1 -1
- package/dist/utils/ProtocolUtils.mjs +56 -60
- package/dist/utils/ProtocolUtils.mjs.map +1 -1
- package/dist/utils/StateTypes.d.ts +15 -0
- package/dist/utils/StateTypes.d.ts.map +1 -0
- package/dist/utils/StringUtils.mjs +1 -1
- package/dist/utils/StringUtils.mjs.map +1 -1
- package/dist/utils/TimeUtils.mjs +1 -1
- package/dist/utils/TimeUtils.mjs.map +1 -1
- package/dist/utils/UrlUtils.mjs +1 -1
- package/dist/utils/UrlUtils.mjs.map +1 -1
- package/lib/index-browser.cjs +31 -17
- package/lib/index-browser.cjs.map +1 -1
- package/lib/{index-node-FrCFfFuh.js → index-node-Dwr2_mSO.js} +2437 -2242
- package/lib/index-node-Dwr2_mSO.js.map +1 -0
- package/lib/index-node.cjs +5 -3
- package/lib/index-node.cjs.map +1 -1
- package/lib/index.cjs +5 -3
- package/lib/index.cjs.map +1 -1
- package/lib/types/account/AccountInfo.d.ts +3 -0
- package/lib/types/account/AccountInfo.d.ts.map +1 -1
- package/lib/types/account/AuthToken.d.ts +6 -0
- package/lib/types/account/AuthToken.d.ts.map +1 -1
- package/lib/types/account/ClientInfo.d.ts +5 -1
- package/lib/types/account/ClientInfo.d.ts.map +1 -1
- package/lib/types/account/TokenClaims.d.ts +4 -0
- package/lib/types/account/TokenClaims.d.ts.map +1 -1
- package/lib/types/authority/AuthorityMetadata.d.ts.map +1 -1
- package/lib/types/cache/CacheManager.d.ts +5 -5
- package/lib/types/cache/CacheManager.d.ts.map +1 -1
- package/lib/types/cache/entities/AccountEntity.d.ts +2 -1
- package/lib/types/cache/entities/AccountEntity.d.ts.map +1 -1
- package/lib/types/cache/interface/ICacheManager.d.ts +5 -5
- package/lib/types/cache/interface/ICacheManager.d.ts.map +1 -1
- package/lib/types/cache/utils/AccountEntityUtils.d.ts +0 -7
- package/lib/types/cache/utils/AccountEntityUtils.d.ts.map +1 -1
- package/lib/types/client/AuthorizationCodeClient.d.ts +22 -3
- package/lib/types/client/AuthorizationCodeClient.d.ts.map +1 -1
- package/lib/types/client/RefreshTokenClient.d.ts +16 -3
- package/lib/types/client/RefreshTokenClient.d.ts.map +1 -1
- package/lib/types/client/SilentFlowClient.d.ts +16 -3
- package/lib/types/client/SilentFlowClient.d.ts.map +1 -1
- package/lib/types/error/AuthError.d.ts +5 -0
- package/lib/types/error/AuthError.d.ts.map +1 -1
- package/lib/types/error/ClientAuthErrorCodes.d.ts +1 -0
- package/lib/types/error/ClientAuthErrorCodes.d.ts.map +1 -1
- package/lib/types/error/ClientConfigurationErrorCodes.d.ts +1 -0
- package/lib/types/error/ClientConfigurationErrorCodes.d.ts.map +1 -1
- package/lib/types/error/PlatformBrokerError.d.ts +16 -0
- package/lib/types/error/PlatformBrokerError.d.ts.map +1 -0
- package/lib/types/exports-common.d.ts +4 -2
- package/lib/types/exports-common.d.ts.map +1 -1
- package/lib/types/exports-node-only.d.ts +1 -0
- package/lib/types/exports-node-only.d.ts.map +1 -1
- package/lib/types/logger/Logger.d.ts +24 -0
- package/lib/types/logger/Logger.d.ts.map +1 -1
- package/lib/types/packageMetadata.d.ts +1 -1
- package/lib/types/packageMetadata.d.ts.map +1 -1
- package/lib/types/protocol/Token.d.ts +40 -0
- package/lib/types/protocol/Token.d.ts.map +1 -0
- package/lib/types/request/BaseAuthRequest.d.ts +67 -22
- package/lib/types/request/BaseAuthRequest.d.ts.map +1 -1
- package/lib/types/request/CommonAuthorizationCodeRequest.d.ts +18 -12
- package/lib/types/request/CommonAuthorizationCodeRequest.d.ts.map +1 -1
- package/lib/types/request/CommonAuthorizationUrlRequest.d.ts +48 -29
- package/lib/types/request/CommonAuthorizationUrlRequest.d.ts.map +1 -1
- package/lib/types/request/CommonEndSessionRequest.d.ts +21 -7
- package/lib/types/request/CommonEndSessionRequest.d.ts.map +1 -1
- package/lib/types/request/CommonRefreshTokenRequest.d.ts +12 -9
- package/lib/types/request/CommonRefreshTokenRequest.d.ts.map +1 -1
- package/lib/types/request/CommonSilentFlowRequest.d.ts +12 -13
- package/lib/types/request/CommonSilentFlowRequest.d.ts.map +1 -1
- package/lib/types/request/RequestParameterBuilder.d.ts +3 -3
- package/lib/types/request/RequestParameterBuilder.d.ts.map +1 -1
- package/lib/types/response/ResponseHandler.d.ts +1 -1
- package/lib/types/response/ResponseHandler.d.ts.map +1 -1
- package/lib/types/telemetry/performance/IPerformanceClient.d.ts +2 -1
- package/lib/types/telemetry/performance/IPerformanceClient.d.ts.map +1 -1
- package/lib/types/telemetry/performance/PerformanceClient.d.ts +4 -1
- package/lib/types/telemetry/performance/PerformanceClient.d.ts.map +1 -1
- package/lib/types/telemetry/performance/PerformanceEvent.d.ts +6 -1
- package/lib/types/telemetry/performance/PerformanceEvent.d.ts.map +1 -1
- package/lib/types/telemetry/performance/PerformanceEvents.d.ts +1 -0
- package/lib/types/telemetry/performance/PerformanceEvents.d.ts.map +1 -1
- package/lib/types/utils/Constants.d.ts +5 -0
- package/lib/types/utils/Constants.d.ts.map +1 -1
- package/lib/types/utils/ProtocolUtils.d.ts +14 -35
- package/lib/types/utils/ProtocolUtils.d.ts.map +1 -1
- package/lib/types/utils/StateTypes.d.ts +15 -0
- package/lib/types/utils/StateTypes.d.ts.map +1 -0
- package/package.json +123 -120
- package/src/account/AccountInfo.ts +5 -0
- package/src/account/AuthToken.ts +22 -0
- package/src/account/ClientInfo.ts +5 -1
- package/src/account/TokenClaims.ts +4 -0
- package/src/authority/AuthorityMetadata.ts +33 -35
- package/src/cache/CacheManager.ts +19 -10
- package/src/cache/entities/AccountEntity.ts +2 -1
- package/src/cache/interface/ICacheManager.ts +12 -4
- package/src/cache/utils/AccountEntityUtils.ts +8 -37
- package/src/client/AuthorizationCodeClient.ts +128 -19
- package/src/client/RefreshTokenClient.ts +101 -29
- package/src/client/SilentFlowClient.ts +63 -5
- package/src/error/AuthError.ts +6 -0
- package/src/error/ClientAuthErrorCodes.ts +1 -0
- package/src/error/ClientConfigurationErrorCodes.ts +1 -0
- package/src/error/PlatformBrokerError.ts +67 -0
- package/src/exports-common.ts +5 -6
- package/src/exports-node-only.ts +4 -0
- package/src/logger/Logger.ts +150 -2
- package/src/network/RequestThumbprint.ts +1 -1
- package/src/packageMetadata.ts +1 -1
- package/src/protocol/Token.ts +230 -0
- package/src/request/BaseAuthRequest.ts +67 -22
- package/src/request/CommonAuthorizationCodeRequest.ts +18 -12
- package/src/request/CommonAuthorizationUrlRequest.ts +48 -29
- package/src/request/CommonEndSessionRequest.ts +21 -7
- package/src/request/CommonRefreshTokenRequest.ts +12 -9
- package/src/request/CommonSilentFlowRequest.ts +12 -13
- package/src/request/RequestParameterBuilder.ts +5 -5
- package/src/response/ResponseHandler.ts +14 -3
- package/src/telemetry/performance/IPerformanceClient.ts +3 -1
- package/src/telemetry/performance/PerformanceClient.ts +39 -45
- package/src/telemetry/performance/PerformanceEvent.ts +10 -1
- package/src/telemetry/performance/PerformanceEvents.ts +1 -0
- package/src/utils/Constants.ts +6 -0
- package/src/utils/ProtocolUtils.ts +66 -92
- package/src/utils/StateTypes.ts +20 -0
- package/dist/client/BaseClient.d.ts +0 -59
- package/dist/client/BaseClient.d.ts.map +0 -1
- package/dist/client/BaseClient.mjs +0 -162
- package/dist/client/BaseClient.mjs.map +0 -1
- package/dist/index-browser.mjs +0 -75
- package/dist/index-browser.mjs.map +0 -1
- package/lib/index-node-FrCFfFuh.js.map +0 -1
- package/lib/types/client/BaseClient.d.ts +0 -59
- package/lib/types/client/BaseClient.d.ts.map +0 -1
- package/src/client/BaseClient.ts +0 -308
package/src/client/BaseClient.ts
DELETED
|
@@ -1,308 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
ClientConfiguration,
|
|
8
|
-
buildClientConfiguration,
|
|
9
|
-
CommonClientConfiguration,
|
|
10
|
-
} from "../config/ClientConfiguration.js";
|
|
11
|
-
import {
|
|
12
|
-
INetworkModule,
|
|
13
|
-
NetworkRequestOptions,
|
|
14
|
-
} from "../network/INetworkModule.js";
|
|
15
|
-
import { NetworkResponse } from "../network/NetworkResponse.js";
|
|
16
|
-
import { ICrypto } from "../crypto/ICrypto.js";
|
|
17
|
-
import { Authority } from "../authority/Authority.js";
|
|
18
|
-
import { Logger } from "../logger/Logger.js";
|
|
19
|
-
import { HeaderNames, URL_FORM_CONTENT_TYPE } from "../utils/Constants.js";
|
|
20
|
-
import { ServerAuthorizationTokenResponse } from "../response/ServerAuthorizationTokenResponse.js";
|
|
21
|
-
import { CacheManager } from "../cache/CacheManager.js";
|
|
22
|
-
import { ServerTelemetryManager } from "../telemetry/server/ServerTelemetryManager.js";
|
|
23
|
-
import { RequestThumbprint } from "../network/RequestThumbprint.js";
|
|
24
|
-
import { version, name } from "../packageMetadata.js";
|
|
25
|
-
import { CcsCredential, CcsCredentialType } from "../account/CcsCredential.js";
|
|
26
|
-
import { buildClientInfoFromHomeAccountId } from "../account/ClientInfo.js";
|
|
27
|
-
import { IPerformanceClient } from "../telemetry/performance/IPerformanceClient.js";
|
|
28
|
-
import * as RequestParameterBuilder from "../request/RequestParameterBuilder.js";
|
|
29
|
-
import * as UrlUtils from "../utils/UrlUtils.js";
|
|
30
|
-
import { BaseAuthRequest } from "../request/BaseAuthRequest.js";
|
|
31
|
-
import { createDiscoveredInstance } from "../authority/AuthorityFactory.js";
|
|
32
|
-
import * as PerformanceEvents from "../telemetry/performance/PerformanceEvents.js";
|
|
33
|
-
import { ThrottlingUtils } from "../network/ThrottlingUtils.js";
|
|
34
|
-
import { AuthError } from "../error/AuthError.js";
|
|
35
|
-
import {
|
|
36
|
-
ClientAuthErrorCodes,
|
|
37
|
-
createClientAuthError,
|
|
38
|
-
} from "../error/ClientAuthError.js";
|
|
39
|
-
import { NetworkError } from "../error/NetworkError.js";
|
|
40
|
-
import { invokeAsync } from "../utils/FunctionWrappers.js";
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Base application class which will construct requests to send to and handle responses from the Microsoft STS using the authorization code flow.
|
|
44
|
-
* @internal
|
|
45
|
-
*/
|
|
46
|
-
export abstract class BaseClient {
|
|
47
|
-
// Logger object
|
|
48
|
-
public logger: Logger;
|
|
49
|
-
|
|
50
|
-
// Application config
|
|
51
|
-
protected config: CommonClientConfiguration;
|
|
52
|
-
|
|
53
|
-
// Crypto Interface
|
|
54
|
-
protected cryptoUtils: ICrypto;
|
|
55
|
-
|
|
56
|
-
// Storage Interface
|
|
57
|
-
protected cacheManager: CacheManager;
|
|
58
|
-
|
|
59
|
-
// Network Interface
|
|
60
|
-
protected networkClient: INetworkModule;
|
|
61
|
-
|
|
62
|
-
// Server Telemetry Manager
|
|
63
|
-
protected serverTelemetryManager: ServerTelemetryManager | null;
|
|
64
|
-
|
|
65
|
-
// Default authority object
|
|
66
|
-
public authority: Authority;
|
|
67
|
-
|
|
68
|
-
// Performance telemetry client
|
|
69
|
-
protected performanceClient: IPerformanceClient;
|
|
70
|
-
|
|
71
|
-
protected constructor(
|
|
72
|
-
configuration: ClientConfiguration,
|
|
73
|
-
performanceClient: IPerformanceClient
|
|
74
|
-
) {
|
|
75
|
-
// Set the configuration
|
|
76
|
-
this.config = buildClientConfiguration(configuration);
|
|
77
|
-
|
|
78
|
-
// Initialize the logger
|
|
79
|
-
this.logger = new Logger(this.config.loggerOptions, name, version);
|
|
80
|
-
|
|
81
|
-
// Initialize crypto
|
|
82
|
-
this.cryptoUtils = this.config.cryptoInterface;
|
|
83
|
-
|
|
84
|
-
// Initialize storage interface
|
|
85
|
-
this.cacheManager = this.config.storageInterface;
|
|
86
|
-
|
|
87
|
-
// Set the network interface
|
|
88
|
-
this.networkClient = this.config.networkInterface;
|
|
89
|
-
|
|
90
|
-
// Set TelemetryManager
|
|
91
|
-
this.serverTelemetryManager = this.config.serverTelemetryManager;
|
|
92
|
-
|
|
93
|
-
// set Authority
|
|
94
|
-
this.authority = this.config.authOptions.authority;
|
|
95
|
-
|
|
96
|
-
// set performance telemetry client
|
|
97
|
-
this.performanceClient = performanceClient;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Creates default headers for requests to token endpoint
|
|
102
|
-
*/
|
|
103
|
-
protected createTokenRequestHeaders(
|
|
104
|
-
ccsCred?: CcsCredential
|
|
105
|
-
): Record<string, string> {
|
|
106
|
-
const headers: Record<string, string> = {};
|
|
107
|
-
headers[HeaderNames.CONTENT_TYPE] = URL_FORM_CONTENT_TYPE;
|
|
108
|
-
if (!this.config.systemOptions.preventCorsPreflight && ccsCred) {
|
|
109
|
-
switch (ccsCred.type) {
|
|
110
|
-
case CcsCredentialType.HOME_ACCOUNT_ID:
|
|
111
|
-
try {
|
|
112
|
-
const clientInfo = buildClientInfoFromHomeAccountId(
|
|
113
|
-
ccsCred.credential
|
|
114
|
-
);
|
|
115
|
-
headers[
|
|
116
|
-
HeaderNames.CCS_HEADER
|
|
117
|
-
] = `Oid:${clientInfo.uid}@${clientInfo.utid}`;
|
|
118
|
-
} catch (e) {
|
|
119
|
-
this.logger.verbose(
|
|
120
|
-
`Could not parse home account ID for CCS Header: '${e}'`,
|
|
121
|
-
""
|
|
122
|
-
);
|
|
123
|
-
}
|
|
124
|
-
break;
|
|
125
|
-
case CcsCredentialType.UPN:
|
|
126
|
-
headers[
|
|
127
|
-
HeaderNames.CCS_HEADER
|
|
128
|
-
] = `UPN: ${ccsCred.credential}`;
|
|
129
|
-
break;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
return headers;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* Http post to token endpoint
|
|
137
|
-
* @param tokenEndpoint
|
|
138
|
-
* @param queryString
|
|
139
|
-
* @param headers
|
|
140
|
-
* @param thumbprint
|
|
141
|
-
*/
|
|
142
|
-
protected async executePostToTokenEndpoint(
|
|
143
|
-
tokenEndpoint: string,
|
|
144
|
-
queryString: string,
|
|
145
|
-
headers: Record<string, string>,
|
|
146
|
-
thumbprint: RequestThumbprint,
|
|
147
|
-
correlationId: string
|
|
148
|
-
): Promise<NetworkResponse<ServerAuthorizationTokenResponse>> {
|
|
149
|
-
const response =
|
|
150
|
-
await this.sendPostRequest<ServerAuthorizationTokenResponse>(
|
|
151
|
-
thumbprint,
|
|
152
|
-
tokenEndpoint,
|
|
153
|
-
{ body: queryString, headers: headers },
|
|
154
|
-
correlationId
|
|
155
|
-
);
|
|
156
|
-
|
|
157
|
-
if (
|
|
158
|
-
this.config.serverTelemetryManager &&
|
|
159
|
-
response.status < 500 &&
|
|
160
|
-
response.status !== 429
|
|
161
|
-
) {
|
|
162
|
-
// Telemetry data successfully logged by server, clear Telemetry cache
|
|
163
|
-
this.config.serverTelemetryManager.clearTelemetryCache();
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
return response;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Wraps sendPostRequestAsync with necessary preflight and postflight logic
|
|
171
|
-
* @param thumbprint - Request thumbprint for throttling
|
|
172
|
-
* @param tokenEndpoint - Endpoint to make the POST to
|
|
173
|
-
* @param options - Body and Headers to include on the POST request
|
|
174
|
-
* @param correlationId - CorrelationId for telemetry
|
|
175
|
-
*/
|
|
176
|
-
async sendPostRequest<T extends ServerAuthorizationTokenResponse>(
|
|
177
|
-
thumbprint: RequestThumbprint,
|
|
178
|
-
tokenEndpoint: string,
|
|
179
|
-
options: NetworkRequestOptions,
|
|
180
|
-
correlationId: string
|
|
181
|
-
): Promise<NetworkResponse<T>> {
|
|
182
|
-
ThrottlingUtils.preProcess(
|
|
183
|
-
this.cacheManager,
|
|
184
|
-
thumbprint,
|
|
185
|
-
correlationId
|
|
186
|
-
);
|
|
187
|
-
|
|
188
|
-
let response;
|
|
189
|
-
try {
|
|
190
|
-
response = await invokeAsync(
|
|
191
|
-
this.networkClient.sendPostRequestAsync.bind(
|
|
192
|
-
this.networkClient
|
|
193
|
-
)<T>,
|
|
194
|
-
PerformanceEvents.NetworkClientSendPostRequestAsync,
|
|
195
|
-
this.logger,
|
|
196
|
-
this.performanceClient,
|
|
197
|
-
correlationId
|
|
198
|
-
)(tokenEndpoint, options);
|
|
199
|
-
const responseHeaders = response.headers || {};
|
|
200
|
-
this.performanceClient?.addFields(
|
|
201
|
-
{
|
|
202
|
-
refreshTokenSize: response.body.refresh_token?.length || 0,
|
|
203
|
-
httpVerToken:
|
|
204
|
-
responseHeaders[HeaderNames.X_MS_HTTP_VERSION] || "",
|
|
205
|
-
requestId:
|
|
206
|
-
responseHeaders[HeaderNames.X_MS_REQUEST_ID] || "",
|
|
207
|
-
},
|
|
208
|
-
correlationId
|
|
209
|
-
);
|
|
210
|
-
} catch (e) {
|
|
211
|
-
if (e instanceof NetworkError) {
|
|
212
|
-
const responseHeaders = e.responseHeaders;
|
|
213
|
-
if (responseHeaders) {
|
|
214
|
-
this.performanceClient?.addFields(
|
|
215
|
-
{
|
|
216
|
-
httpVerToken:
|
|
217
|
-
responseHeaders[
|
|
218
|
-
HeaderNames.X_MS_HTTP_VERSION
|
|
219
|
-
] || "",
|
|
220
|
-
requestId:
|
|
221
|
-
responseHeaders[HeaderNames.X_MS_REQUEST_ID] ||
|
|
222
|
-
"",
|
|
223
|
-
contentTypeHeader:
|
|
224
|
-
responseHeaders[HeaderNames.CONTENT_TYPE] ||
|
|
225
|
-
undefined,
|
|
226
|
-
contentLengthHeader:
|
|
227
|
-
responseHeaders[HeaderNames.CONTENT_LENGTH] ||
|
|
228
|
-
undefined,
|
|
229
|
-
httpStatus: e.httpStatus,
|
|
230
|
-
},
|
|
231
|
-
correlationId
|
|
232
|
-
);
|
|
233
|
-
}
|
|
234
|
-
throw e.error;
|
|
235
|
-
}
|
|
236
|
-
if (e instanceof AuthError) {
|
|
237
|
-
throw e;
|
|
238
|
-
} else {
|
|
239
|
-
throw createClientAuthError(ClientAuthErrorCodes.networkError);
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
ThrottlingUtils.postProcess(
|
|
244
|
-
this.cacheManager,
|
|
245
|
-
thumbprint,
|
|
246
|
-
response,
|
|
247
|
-
correlationId
|
|
248
|
-
);
|
|
249
|
-
|
|
250
|
-
return response;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
/**
|
|
254
|
-
* Updates the authority object of the client. Endpoint discovery must be completed.
|
|
255
|
-
* @param updatedAuthority
|
|
256
|
-
*/
|
|
257
|
-
async updateAuthority(
|
|
258
|
-
cloudInstanceHostname: string,
|
|
259
|
-
correlationId: string
|
|
260
|
-
): Promise<void> {
|
|
261
|
-
const cloudInstanceAuthorityUri = `https://${cloudInstanceHostname}/${this.authority.tenant}/`;
|
|
262
|
-
const cloudInstanceAuthority = await createDiscoveredInstance(
|
|
263
|
-
cloudInstanceAuthorityUri,
|
|
264
|
-
this.networkClient,
|
|
265
|
-
this.cacheManager,
|
|
266
|
-
this.authority.options,
|
|
267
|
-
this.logger,
|
|
268
|
-
correlationId,
|
|
269
|
-
this.performanceClient
|
|
270
|
-
);
|
|
271
|
-
this.authority = cloudInstanceAuthority;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
/**
|
|
275
|
-
* Creates query string for the /token request
|
|
276
|
-
* @param request
|
|
277
|
-
*/
|
|
278
|
-
createTokenQueryParameters(request: BaseAuthRequest): string {
|
|
279
|
-
const parameters = new Map<string, string>();
|
|
280
|
-
|
|
281
|
-
if (request.embeddedClientId) {
|
|
282
|
-
RequestParameterBuilder.addBrokerParameters(
|
|
283
|
-
parameters,
|
|
284
|
-
this.config.authOptions.clientId,
|
|
285
|
-
this.config.authOptions.redirectUri
|
|
286
|
-
);
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
if (request.tokenQueryParameters) {
|
|
290
|
-
RequestParameterBuilder.addExtraQueryParameters(
|
|
291
|
-
parameters,
|
|
292
|
-
request.tokenQueryParameters
|
|
293
|
-
);
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
RequestParameterBuilder.addCorrelationId(
|
|
297
|
-
parameters,
|
|
298
|
-
request.correlationId
|
|
299
|
-
);
|
|
300
|
-
|
|
301
|
-
RequestParameterBuilder.instrumentBrokerParams(
|
|
302
|
-
parameters,
|
|
303
|
-
request.correlationId,
|
|
304
|
-
this.performanceClient
|
|
305
|
-
);
|
|
306
|
-
return UrlUtils.mapToQueryString(parameters);
|
|
307
|
-
}
|
|
308
|
-
}
|