@azure/msal-common 14.0.1 → 14.0.3
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/AuthToken.d.ts +14 -17
- package/dist/account/AuthToken.d.ts.map +1 -1
- package/dist/account/AuthToken.mjs +48 -39
- 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.map +1 -1
- package/dist/account/ClientInfo.mjs +3 -4
- package/dist/account/ClientInfo.mjs.map +1 -1
- package/dist/authority/Authority.d.ts +1 -0
- package/dist/authority/Authority.d.ts.map +1 -1
- package/dist/authority/Authority.mjs +4 -2
- package/dist/authority/Authority.mjs.map +1 -1
- package/dist/authority/AuthorityFactory.d.ts +1 -0
- package/dist/authority/AuthorityFactory.d.ts.map +1 -1
- package/dist/authority/AuthorityFactory.mjs +3 -3
- package/dist/authority/AuthorityFactory.mjs.map +1 -1
- package/dist/authority/AuthorityMetadata.mjs +1 -1
- 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/CloudInstanceDiscoveryErrorResponse.mjs.map +1 -1
- package/dist/authority/CloudInstanceDiscoveryResponse.mjs +1 -1
- package/dist/authority/CloudInstanceDiscoveryResponse.mjs.map +1 -1
- package/dist/authority/OpenIdConfigResponse.mjs +1 -1
- package/dist/authority/OpenIdConfigResponse.mjs.map +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 +2 -0
- package/dist/cache/CacheManager.d.ts.map +1 -1
- package/dist/cache/CacheManager.mjs +7 -5
- package/dist/cache/CacheManager.mjs.map +1 -1
- package/dist/cache/entities/AccessTokenEntity.d.ts.map +1 -1
- package/dist/cache/entities/AccessTokenEntity.mjs +4 -7
- package/dist/cache/entities/AccessTokenEntity.mjs.map +1 -1
- package/dist/cache/entities/AccountEntity.d.ts +1 -0
- package/dist/cache/entities/AccountEntity.d.ts.map +1 -1
- package/dist/cache/entities/AccountEntity.mjs +3 -4
- package/dist/cache/entities/AccountEntity.mjs.map +1 -1
- package/dist/cache/entities/AppMetadataEntity.mjs +1 -1
- package/dist/cache/entities/AppMetadataEntity.mjs.map +1 -1
- package/dist/cache/entities/AuthorityMetadataEntity.d.ts +1 -0
- package/dist/cache/entities/AuthorityMetadataEntity.d.ts.map +1 -1
- package/dist/cache/entities/AuthorityMetadataEntity.mjs +2 -1
- package/dist/cache/entities/AuthorityMetadataEntity.mjs.map +1 -1
- package/dist/cache/entities/CacheRecord.d.ts +1 -0
- package/dist/cache/entities/CacheRecord.d.ts.map +1 -1
- package/dist/cache/entities/CacheRecord.mjs +2 -1
- package/dist/cache/entities/CacheRecord.mjs.map +1 -1
- package/dist/cache/entities/CredentialEntity.mjs +1 -1
- package/dist/cache/entities/CredentialEntity.mjs.map +1 -1
- package/dist/cache/entities/IdTokenEntity.mjs +1 -1
- package/dist/cache/entities/IdTokenEntity.mjs.map +1 -1
- package/dist/cache/entities/RefreshTokenEntity.mjs +1 -1
- package/dist/cache/entities/RefreshTokenEntity.mjs.map +1 -1
- package/dist/cache/entities/ServerTelemetryEntity.mjs +1 -1
- package/dist/cache/entities/ServerTelemetryEntity.mjs.map +1 -1
- package/dist/cache/entities/ThrottlingEntity.mjs +1 -1
- package/dist/cache/entities/ThrottlingEntity.mjs.map +1 -1
- package/dist/cache/persistence/TokenCacheContext.mjs +1 -1
- package/dist/cache/persistence/TokenCacheContext.mjs.map +1 -1
- package/dist/cache/utils/CacheTypes.d.ts +7 -0
- package/dist/cache/utils/CacheTypes.d.ts.map +1 -1
- package/dist/client/AuthorizationCodeClient.d.ts +1 -0
- package/dist/client/AuthorizationCodeClient.d.ts.map +1 -1
- package/dist/client/AuthorizationCodeClient.mjs +11 -39
- package/dist/client/AuthorizationCodeClient.mjs.map +1 -1
- package/dist/client/BaseClient.d.ts +2 -1
- package/dist/client/BaseClient.d.ts.map +1 -1
- package/dist/client/BaseClient.mjs +9 -2
- package/dist/client/BaseClient.mjs.map +1 -1
- package/dist/client/RefreshTokenClient.d.ts +1 -0
- package/dist/client/RefreshTokenClient.d.ts.map +1 -1
- package/dist/client/RefreshTokenClient.mjs +3 -11
- package/dist/client/RefreshTokenClient.mjs.map +1 -1
- package/dist/client/SilentFlowClient.d.ts +1 -0
- package/dist/client/SilentFlowClient.d.ts.map +1 -1
- package/dist/client/SilentFlowClient.mjs +8 -7
- package/dist/client/SilentFlowClient.mjs.map +1 -1
- package/dist/config/ClientConfiguration.d.ts +2 -0
- package/dist/config/ClientConfiguration.d.ts.map +1 -1
- package/dist/config/ClientConfiguration.mjs +1 -1
- package/dist/config/ClientConfiguration.mjs.map +1 -1
- package/dist/crypto/ICrypto.mjs +1 -1
- package/dist/crypto/ICrypto.mjs.map +1 -1
- package/dist/crypto/JoseHeader.d.ts +1 -0
- package/dist/crypto/JoseHeader.d.ts.map +1 -1
- package/dist/crypto/JoseHeader.mjs +2 -1
- package/dist/crypto/JoseHeader.mjs.map +1 -1
- package/dist/crypto/PopTokenGenerator.d.ts +1 -0
- package/dist/crypto/PopTokenGenerator.d.ts.map +1 -1
- package/dist/crypto/PopTokenGenerator.mjs +2 -1
- package/dist/crypto/PopTokenGenerator.mjs.map +1 -1
- package/dist/error/AuthError.mjs +1 -1
- package/dist/error/AuthError.mjs.map +1 -1
- package/dist/error/ClientAuthError.mjs +1 -1
- package/dist/error/ClientAuthError.mjs.map +1 -1
- package/dist/error/ClientConfigurationError.mjs +1 -1
- package/dist/error/ClientConfigurationError.mjs.map +1 -1
- package/dist/error/InteractionRequiredAuthError.mjs +1 -1
- package/dist/error/InteractionRequiredAuthError.mjs.map +1 -1
- package/dist/error/JoseHeaderError.mjs +1 -1
- package/dist/error/JoseHeaderError.mjs.map +1 -1
- package/dist/error/ServerError.mjs +1 -1
- package/dist/error/ServerError.mjs.map +1 -1
- package/dist/index.cjs +1926 -1826
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +5 -3
- package/dist/index.mjs.map +1 -1
- package/dist/logger/Logger.d.ts.map +1 -1
- package/dist/logger/Logger.mjs +2 -12
- 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/NetworkManager.d.ts +1 -0
- package/dist/network/NetworkManager.d.ts.map +1 -1
- package/dist/network/NetworkManager.mjs +2 -1
- package/dist/network/NetworkManager.mjs.map +1 -1
- package/dist/network/ThrottlingUtils.d.ts +1 -0
- package/dist/network/ThrottlingUtils.d.ts.map +1 -1
- package/dist/network/ThrottlingUtils.mjs +2 -1
- package/dist/network/ThrottlingUtils.mjs.map +1 -1
- package/dist/packageMetadata.d.ts +1 -1
- package/dist/packageMetadata.mjs +2 -2
- package/dist/packageMetadata.mjs.map +1 -1
- package/dist/request/AuthenticationHeaderParser.mjs +1 -1
- package/dist/request/AuthenticationHeaderParser.mjs.map +1 -1
- package/dist/request/RequestParameterBuilder.d.ts +1 -0
- package/dist/request/RequestParameterBuilder.d.ts.map +1 -1
- package/dist/request/RequestParameterBuilder.mjs +7 -7
- package/dist/request/RequestParameterBuilder.mjs.map +1 -1
- package/dist/request/RequestValidator.d.ts.map +1 -1
- package/dist/request/RequestValidator.mjs +4 -6
- package/dist/request/RequestValidator.mjs.map +1 -1
- package/dist/request/ScopeSet.mjs +4 -4
- package/dist/request/ScopeSet.mjs.map +1 -1
- package/dist/response/AuthenticationResult.d.ts +3 -1
- package/dist/response/AuthenticationResult.d.ts.map +1 -1
- package/dist/response/ResponseHandler.d.ts +5 -3
- package/dist/response/ResponseHandler.d.ts.map +1 -1
- package/dist/response/ResponseHandler.mjs +58 -39
- package/dist/response/ResponseHandler.mjs.map +1 -1
- package/dist/response/ServerAuthorizationTokenResponse.d.ts +2 -0
- package/dist/response/ServerAuthorizationTokenResponse.d.ts.map +1 -1
- package/dist/telemetry/performance/IPerformanceClient.d.ts +4 -4
- package/dist/telemetry/performance/IPerformanceClient.d.ts.map +1 -1
- package/dist/telemetry/performance/PerformanceClient.d.ts +2 -2
- package/dist/telemetry/performance/PerformanceClient.d.ts.map +1 -1
- package/dist/telemetry/performance/PerformanceClient.mjs +1 -1
- package/dist/telemetry/performance/PerformanceClient.mjs.map +1 -1
- package/dist/telemetry/performance/PerformanceEvent.d.ts +8 -1
- package/dist/telemetry/performance/PerformanceEvent.d.ts.map +1 -1
- package/dist/telemetry/performance/PerformanceEvent.mjs +9 -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 +23 -3
- package/dist/telemetry/performance/StubPerformanceClient.mjs.map +1 -1
- package/dist/telemetry/server/ServerTelemetryManager.d.ts +1 -0
- package/dist/telemetry/server/ServerTelemetryManager.d.ts.map +1 -1
- package/dist/telemetry/server/ServerTelemetryManager.mjs +4 -4
- package/dist/telemetry/server/ServerTelemetryManager.mjs.map +1 -1
- package/dist/url/UrlString.d.ts.map +1 -1
- package/dist/url/UrlString.mjs +10 -12
- package/dist/url/UrlString.mjs.map +1 -1
- package/dist/utils/Constants.d.ts +10 -0
- package/dist/utils/Constants.d.ts.map +1 -1
- package/dist/utils/Constants.mjs +11 -2
- package/dist/utils/Constants.mjs.map +1 -1
- package/dist/utils/FunctionWrappers.d.ts +28 -0
- package/dist/utils/FunctionWrappers.d.ts.map +1 -0
- package/dist/utils/FunctionWrappers.mjs +90 -0
- package/dist/utils/FunctionWrappers.mjs.map +1 -0
- package/dist/utils/ProtocolUtils.d.ts.map +1 -1
- package/dist/utils/ProtocolUtils.mjs +4 -7
- package/dist/utils/ProtocolUtils.mjs.map +1 -1
- package/dist/utils/StringUtils.d.ts +0 -13
- package/dist/utils/StringUtils.d.ts.map +1 -1
- package/dist/utils/StringUtils.mjs +3 -34
- package/dist/utils/StringUtils.mjs.map +1 -1
- package/dist/utils/TimeUtils.mjs +1 -1
- package/dist/utils/TimeUtils.mjs.map +1 -1
- package/package.json +6 -4
- package/src/account/AccountInfo.ts +44 -0
- package/src/account/AuthToken.ts +70 -0
- package/src/account/CcsCredential.ts +16 -0
- package/src/account/ClientCredentials.ts +20 -0
- package/src/account/ClientInfo.ts +64 -0
- package/src/account/TokenClaims.ts +70 -0
- package/src/authority/Authority.ts +1225 -0
- package/src/authority/AuthorityFactory.ts +106 -0
- package/src/authority/AuthorityMetadata.ts +953 -0
- package/src/authority/AuthorityOptions.ts +40 -0
- package/src/authority/AuthorityType.ts +15 -0
- package/src/authority/AzureRegion.ts +7 -0
- package/src/authority/AzureRegionConfiguration.ts +16 -0
- package/src/authority/CloudDiscoveryMetadata.ts +10 -0
- package/src/authority/CloudInstanceDiscoveryErrorResponse.ts +26 -0
- package/src/authority/CloudInstanceDiscoveryResponse.ts +21 -0
- package/src/authority/ImdsOptions.ts +10 -0
- package/src/authority/OIDCOptions.ts +14 -0
- package/src/authority/OpenIdConfigResponse.ts +24 -0
- package/src/authority/ProtocolMode.ts +13 -0
- package/src/authority/RegionDiscovery.ts +193 -0
- package/src/authority/RegionDiscoveryMetadata.ts +15 -0
- package/src/broker/nativeBroker/INativeBrokerPlugin.ts +29 -0
- package/src/cache/CacheManager.ts +1619 -0
- package/src/cache/entities/AccessTokenEntity.ts +162 -0
- package/src/cache/entities/AccountEntity.ts +309 -0
- package/src/cache/entities/AppMetadataEntity.ts +91 -0
- package/src/cache/entities/AuthorityMetadataEntity.ts +112 -0
- package/src/cache/entities/CacheRecord.ts +33 -0
- package/src/cache/entities/CredentialEntity.ts +215 -0
- package/src/cache/entities/IdTokenEntity.ts +74 -0
- package/src/cache/entities/RefreshTokenEntity.ts +78 -0
- package/src/cache/entities/ServerTelemetryEntity.ts +38 -0
- package/src/cache/entities/ThrottlingEntity.ts +36 -0
- package/src/cache/interface/ICacheManager.ts +218 -0
- package/src/cache/interface/ICachePlugin.ts +11 -0
- package/src/cache/interface/ISerializableTokenCache.ts +9 -0
- package/src/cache/persistence/TokenCacheContext.ts +39 -0
- package/src/cache/utils/CacheTypes.ts +93 -0
- package/src/client/AuthorizationCodeClient.ts +714 -0
- package/src/client/BaseClient.ts +205 -0
- package/src/client/RefreshTokenClient.ts +442 -0
- package/src/client/SilentFlowClient.ts +186 -0
- package/src/config/AppTokenProvider.ts +47 -0
- package/src/config/ClientConfiguration.ts +287 -0
- package/src/crypto/ICrypto.ts +127 -0
- package/src/crypto/IGuidGenerator.ts +9 -0
- package/src/crypto/JoseHeader.ts +55 -0
- package/src/crypto/PopTokenGenerator.ts +155 -0
- package/src/crypto/SignedHttpRequest.ts +16 -0
- package/src/error/AuthError.ts +85 -0
- package/src/error/ClientAuthError.ts +738 -0
- package/src/error/ClientConfigurationError.ts +396 -0
- package/src/error/InteractionRequiredAuthError.ts +134 -0
- package/src/error/JoseHeaderError.ts +52 -0
- package/src/error/ServerError.ts +18 -0
- package/src/index.ts +215 -0
- package/src/logger/Logger.ts +272 -0
- package/src/network/INetworkModule.ts +57 -0
- package/src/network/NetworkManager.ts +76 -0
- package/src/network/RequestThumbprint.ts +22 -0
- package/src/network/ThrottlingUtils.ts +156 -0
- package/src/packageMetadata.ts +3 -0
- package/src/request/AuthenticationHeaderParser.ts +89 -0
- package/src/request/BaseAuthRequest.ts +46 -0
- package/src/request/CommonAuthorizationCodeRequest.ts +33 -0
- package/src/request/CommonAuthorizationUrlRequest.ts +56 -0
- package/src/request/CommonClientCredentialRequest.ts +23 -0
- package/src/request/CommonDeviceCodeRequest.ts +31 -0
- package/src/request/CommonEndSessionRequest.ts +27 -0
- package/src/request/CommonOnBehalfOfRequest.ts +19 -0
- package/src/request/CommonRefreshTokenRequest.ts +25 -0
- package/src/request/CommonSilentFlowRequest.ts +24 -0
- package/src/request/CommonUsernamePasswordRequest.ts +23 -0
- package/src/request/NativeRequest.ts +25 -0
- package/src/request/NativeSignOutRequest.ts +10 -0
- package/src/request/RequestParameterBuilder.ts +606 -0
- package/src/request/RequestValidator.ts +103 -0
- package/src/request/ScopeSet.ts +230 -0
- package/src/request/StoreInCache.ts +16 -0
- package/src/response/AuthenticationResult.ts +47 -0
- package/src/response/AuthorizationCodePayload.ts +18 -0
- package/src/response/DeviceCodeResponse.ts +31 -0
- package/src/response/ExternalTokenResponse.ts +24 -0
- package/src/response/IMDSBadResponse.ts +9 -0
- package/src/response/ResponseHandler.ts +614 -0
- package/src/response/ServerAuthorizationCodeResponse.ts +33 -0
- package/src/response/ServerAuthorizationTokenResponse.ts +54 -0
- package/src/telemetry/performance/IPerformanceClient.ts +71 -0
- package/src/telemetry/performance/IPerformanceMeasurement.ts +10 -0
- package/src/telemetry/performance/PerformanceClient.ts +635 -0
- package/src/telemetry/performance/PerformanceEvent.ts +542 -0
- package/src/telemetry/performance/StubPerformanceClient.ts +101 -0
- package/src/telemetry/server/ServerTelemetryManager.ts +274 -0
- package/src/telemetry/server/ServerTelemetryRequest.ts +13 -0
- package/src/url/IUri.ts +17 -0
- package/src/url/UrlString.ts +363 -0
- package/src/utils/Constants.ts +436 -0
- package/src/utils/FunctionWrappers.ts +105 -0
- package/src/utils/MsalTypes.ts +9 -0
- package/src/utils/ProtocolUtils.ts +124 -0
- package/src/utils/StringUtils.ts +106 -0
- package/src/utils/TimeUtils.ts +51 -0
- package/dist/account/DecodedAuthToken.d.ts +0 -9
- package/dist/account/DecodedAuthToken.d.ts.map +0 -1
|
@@ -0,0 +1,205 @@
|
|
|
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";
|
|
11
|
+
import { INetworkModule } from "../network/INetworkModule";
|
|
12
|
+
import { NetworkManager, NetworkResponse } from "../network/NetworkManager";
|
|
13
|
+
import { ICrypto } from "../crypto/ICrypto";
|
|
14
|
+
import { Authority } from "../authority/Authority";
|
|
15
|
+
import { Logger } from "../logger/Logger";
|
|
16
|
+
import { Constants, HeaderNames } from "../utils/Constants";
|
|
17
|
+
import { ServerAuthorizationTokenResponse } from "../response/ServerAuthorizationTokenResponse";
|
|
18
|
+
import { CacheManager } from "../cache/CacheManager";
|
|
19
|
+
import { ServerTelemetryManager } from "../telemetry/server/ServerTelemetryManager";
|
|
20
|
+
import { RequestThumbprint } from "../network/RequestThumbprint";
|
|
21
|
+
import { version, name } from "../packageMetadata";
|
|
22
|
+
import { ClientAuthError } from "../error/ClientAuthError";
|
|
23
|
+
import { CcsCredential, CcsCredentialType } from "../account/CcsCredential";
|
|
24
|
+
import { buildClientInfoFromHomeAccountId } from "../account/ClientInfo";
|
|
25
|
+
import { IPerformanceClient } from "../telemetry/performance/IPerformanceClient";
|
|
26
|
+
import { RequestParameterBuilder } from "../request/RequestParameterBuilder";
|
|
27
|
+
import { BaseAuthRequest } from "../request/BaseAuthRequest";
|
|
28
|
+
import { PerformanceEvents } from "../telemetry/performance/PerformanceEvent";
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Base application class which will construct requests to send to and handle responses from the Microsoft STS using the authorization code flow.
|
|
32
|
+
* @internal
|
|
33
|
+
*/
|
|
34
|
+
export abstract class BaseClient {
|
|
35
|
+
// Logger object
|
|
36
|
+
public logger: Logger;
|
|
37
|
+
|
|
38
|
+
// Application config
|
|
39
|
+
protected config: CommonClientConfiguration;
|
|
40
|
+
|
|
41
|
+
// Crypto Interface
|
|
42
|
+
protected cryptoUtils: ICrypto;
|
|
43
|
+
|
|
44
|
+
// Storage Interface
|
|
45
|
+
protected cacheManager: CacheManager;
|
|
46
|
+
|
|
47
|
+
// Network Interface
|
|
48
|
+
protected networkClient: INetworkModule;
|
|
49
|
+
|
|
50
|
+
// Server Telemetry Manager
|
|
51
|
+
protected serverTelemetryManager: ServerTelemetryManager | null;
|
|
52
|
+
|
|
53
|
+
// Network Manager
|
|
54
|
+
protected networkManager: NetworkManager;
|
|
55
|
+
|
|
56
|
+
// Default authority object
|
|
57
|
+
public authority: Authority;
|
|
58
|
+
|
|
59
|
+
// Performance telemetry client
|
|
60
|
+
protected performanceClient?: IPerformanceClient;
|
|
61
|
+
|
|
62
|
+
protected constructor(
|
|
63
|
+
configuration: ClientConfiguration,
|
|
64
|
+
performanceClient?: IPerformanceClient
|
|
65
|
+
) {
|
|
66
|
+
// Set the configuration
|
|
67
|
+
this.config = buildClientConfiguration(configuration);
|
|
68
|
+
|
|
69
|
+
// Initialize the logger
|
|
70
|
+
this.logger = new Logger(this.config.loggerOptions, name, version);
|
|
71
|
+
|
|
72
|
+
// Initialize crypto
|
|
73
|
+
this.cryptoUtils = this.config.cryptoInterface;
|
|
74
|
+
|
|
75
|
+
// Initialize storage interface
|
|
76
|
+
this.cacheManager = this.config.storageInterface;
|
|
77
|
+
|
|
78
|
+
// Set the network interface
|
|
79
|
+
this.networkClient = this.config.networkInterface;
|
|
80
|
+
|
|
81
|
+
// Set the NetworkManager
|
|
82
|
+
this.networkManager = new NetworkManager(
|
|
83
|
+
this.networkClient,
|
|
84
|
+
this.cacheManager
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
// Set TelemetryManager
|
|
88
|
+
this.serverTelemetryManager = this.config.serverTelemetryManager;
|
|
89
|
+
|
|
90
|
+
// set Authority
|
|
91
|
+
this.authority = this.config.authOptions.authority;
|
|
92
|
+
|
|
93
|
+
// set performance telemetry client
|
|
94
|
+
this.performanceClient = performanceClient;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Creates default headers for requests to token endpoint
|
|
99
|
+
*/
|
|
100
|
+
protected createTokenRequestHeaders(
|
|
101
|
+
ccsCred?: CcsCredential
|
|
102
|
+
): Record<string, string> {
|
|
103
|
+
const headers: Record<string, string> = {};
|
|
104
|
+
headers[HeaderNames.CONTENT_TYPE] = Constants.URL_FORM_CONTENT_TYPE;
|
|
105
|
+
if (!this.config.systemOptions.preventCorsPreflight && ccsCred) {
|
|
106
|
+
switch (ccsCred.type) {
|
|
107
|
+
case CcsCredentialType.HOME_ACCOUNT_ID:
|
|
108
|
+
try {
|
|
109
|
+
const clientInfo = buildClientInfoFromHomeAccountId(
|
|
110
|
+
ccsCred.credential
|
|
111
|
+
);
|
|
112
|
+
headers[
|
|
113
|
+
HeaderNames.CCS_HEADER
|
|
114
|
+
] = `Oid:${clientInfo.uid}@${clientInfo.utid}`;
|
|
115
|
+
} catch (e) {
|
|
116
|
+
this.logger.verbose(
|
|
117
|
+
"Could not parse home account ID for CCS Header: " +
|
|
118
|
+
e
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
break;
|
|
122
|
+
case CcsCredentialType.UPN:
|
|
123
|
+
headers[
|
|
124
|
+
HeaderNames.CCS_HEADER
|
|
125
|
+
] = `UPN: ${ccsCred.credential}`;
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return headers;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Http post to token endpoint
|
|
134
|
+
* @param tokenEndpoint
|
|
135
|
+
* @param queryString
|
|
136
|
+
* @param headers
|
|
137
|
+
* @param thumbprint
|
|
138
|
+
*/
|
|
139
|
+
protected async executePostToTokenEndpoint(
|
|
140
|
+
tokenEndpoint: string,
|
|
141
|
+
queryString: string,
|
|
142
|
+
headers: Record<string, string>,
|
|
143
|
+
thumbprint: RequestThumbprint,
|
|
144
|
+
correlationId: string
|
|
145
|
+
): Promise<NetworkResponse<ServerAuthorizationTokenResponse>> {
|
|
146
|
+
this.performanceClient?.addQueueMeasurement(
|
|
147
|
+
PerformanceEvents.BaseClientCreateTokenRequestHeaders,
|
|
148
|
+
correlationId
|
|
149
|
+
);
|
|
150
|
+
const response =
|
|
151
|
+
await this.networkManager.sendPostRequest<ServerAuthorizationTokenResponse>(
|
|
152
|
+
thumbprint,
|
|
153
|
+
tokenEndpoint,
|
|
154
|
+
{ body: queryString, headers: headers }
|
|
155
|
+
);
|
|
156
|
+
this.performanceClient?.addFields(
|
|
157
|
+
{
|
|
158
|
+
refreshTokenSize: response.body.refresh_token?.length || 0,
|
|
159
|
+
httpVerToken:
|
|
160
|
+
response.headers?.[HeaderNames.X_MS_HTTP_VERSION] || "",
|
|
161
|
+
},
|
|
162
|
+
correlationId
|
|
163
|
+
);
|
|
164
|
+
|
|
165
|
+
if (
|
|
166
|
+
this.config.serverTelemetryManager &&
|
|
167
|
+
response.status < 500 &&
|
|
168
|
+
response.status !== 429
|
|
169
|
+
) {
|
|
170
|
+
// Telemetry data successfully logged by server, clear Telemetry cache
|
|
171
|
+
this.config.serverTelemetryManager.clearTelemetryCache();
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
return response;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Updates the authority object of the client. Endpoint discovery must be completed.
|
|
179
|
+
* @param updatedAuthority
|
|
180
|
+
*/
|
|
181
|
+
updateAuthority(updatedAuthority: Authority): void {
|
|
182
|
+
if (!updatedAuthority.discoveryComplete()) {
|
|
183
|
+
throw ClientAuthError.createEndpointDiscoveryIncompleteError(
|
|
184
|
+
"Updated authority has not completed endpoint discovery."
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
this.authority = updatedAuthority;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Creates query string for the /token request
|
|
192
|
+
* @param request
|
|
193
|
+
*/
|
|
194
|
+
createTokenQueryParameters(request: BaseAuthRequest): string {
|
|
195
|
+
const parameterBuilder = new RequestParameterBuilder();
|
|
196
|
+
|
|
197
|
+
if (request.tokenQueryParameters) {
|
|
198
|
+
parameterBuilder.addExtraQueryParameters(
|
|
199
|
+
request.tokenQueryParameters
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
return parameterBuilder.createQueryString();
|
|
204
|
+
}
|
|
205
|
+
}
|
|
@@ -0,0 +1,442 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
ClientConfiguration,
|
|
8
|
+
isOidcProtocolMode,
|
|
9
|
+
} from "../config/ClientConfiguration";
|
|
10
|
+
import { BaseClient } from "./BaseClient";
|
|
11
|
+
import { CommonRefreshTokenRequest } from "../request/CommonRefreshTokenRequest";
|
|
12
|
+
import { Authority } from "../authority/Authority";
|
|
13
|
+
import { ServerAuthorizationTokenResponse } from "../response/ServerAuthorizationTokenResponse";
|
|
14
|
+
import { RequestParameterBuilder } from "../request/RequestParameterBuilder";
|
|
15
|
+
import {
|
|
16
|
+
GrantType,
|
|
17
|
+
AuthenticationScheme,
|
|
18
|
+
Errors,
|
|
19
|
+
HeaderNames,
|
|
20
|
+
} from "../utils/Constants";
|
|
21
|
+
import { ResponseHandler } from "../response/ResponseHandler";
|
|
22
|
+
import { AuthenticationResult } from "../response/AuthenticationResult";
|
|
23
|
+
import { PopTokenGenerator } from "../crypto/PopTokenGenerator";
|
|
24
|
+
import { StringUtils } from "../utils/StringUtils";
|
|
25
|
+
import { RequestThumbprint } from "../network/RequestThumbprint";
|
|
26
|
+
import { NetworkResponse } from "../network/NetworkManager";
|
|
27
|
+
import { CommonSilentFlowRequest } from "../request/CommonSilentFlowRequest";
|
|
28
|
+
import { ClientConfigurationError } from "../error/ClientConfigurationError";
|
|
29
|
+
import { ClientAuthError } from "../error/ClientAuthError";
|
|
30
|
+
import { ServerError } from "../error/ServerError";
|
|
31
|
+
import { TimeUtils } from "../utils/TimeUtils";
|
|
32
|
+
import { UrlString } from "../url/UrlString";
|
|
33
|
+
import { CcsCredentialType } from "../account/CcsCredential";
|
|
34
|
+
import { buildClientInfoFromHomeAccountId } from "../account/ClientInfo";
|
|
35
|
+
import {
|
|
36
|
+
InteractionRequiredAuthError,
|
|
37
|
+
InteractionRequiredAuthErrorMessage,
|
|
38
|
+
} from "../error/InteractionRequiredAuthError";
|
|
39
|
+
import { PerformanceEvents } from "../telemetry/performance/PerformanceEvent";
|
|
40
|
+
import { IPerformanceClient } from "../telemetry/performance/IPerformanceClient";
|
|
41
|
+
/**
|
|
42
|
+
* OAuth2.0 refresh token client
|
|
43
|
+
* @internal
|
|
44
|
+
*/
|
|
45
|
+
export class RefreshTokenClient extends BaseClient {
|
|
46
|
+
constructor(
|
|
47
|
+
configuration: ClientConfiguration,
|
|
48
|
+
performanceClient?: IPerformanceClient
|
|
49
|
+
) {
|
|
50
|
+
super(configuration, performanceClient);
|
|
51
|
+
}
|
|
52
|
+
public async acquireToken(
|
|
53
|
+
request: CommonRefreshTokenRequest
|
|
54
|
+
): Promise<AuthenticationResult> {
|
|
55
|
+
this.performanceClient?.addQueueMeasurement(
|
|
56
|
+
PerformanceEvents.RefreshTokenClientAcquireToken,
|
|
57
|
+
request.correlationId
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
const atsMeasurement = this.performanceClient?.startMeasurement(
|
|
61
|
+
PerformanceEvents.RefreshTokenClientAcquireToken,
|
|
62
|
+
request.correlationId
|
|
63
|
+
);
|
|
64
|
+
this.logger.verbose(
|
|
65
|
+
"RefreshTokenClientAcquireToken called",
|
|
66
|
+
request.correlationId
|
|
67
|
+
);
|
|
68
|
+
const reqTimestamp = TimeUtils.nowSeconds();
|
|
69
|
+
this.performanceClient?.setPreQueueTime(
|
|
70
|
+
PerformanceEvents.RefreshTokenClientExecuteTokenRequest,
|
|
71
|
+
request.correlationId
|
|
72
|
+
);
|
|
73
|
+
const response = await this.executeTokenRequest(
|
|
74
|
+
request,
|
|
75
|
+
this.authority
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
// Retrieve requestId from response headers
|
|
79
|
+
const requestId = response.headers?.[HeaderNames.X_MS_REQUEST_ID];
|
|
80
|
+
const responseHandler = new ResponseHandler(
|
|
81
|
+
this.config.authOptions.clientId,
|
|
82
|
+
this.cacheManager,
|
|
83
|
+
this.cryptoUtils,
|
|
84
|
+
this.logger,
|
|
85
|
+
this.config.serializableCache,
|
|
86
|
+
this.config.persistencePlugin
|
|
87
|
+
);
|
|
88
|
+
responseHandler.validateTokenResponse(response.body);
|
|
89
|
+
|
|
90
|
+
this.performanceClient?.setPreQueueTime(
|
|
91
|
+
PerformanceEvents.HandleServerTokenResponse,
|
|
92
|
+
request.correlationId
|
|
93
|
+
);
|
|
94
|
+
return responseHandler
|
|
95
|
+
.handleServerTokenResponse(
|
|
96
|
+
response.body,
|
|
97
|
+
this.authority,
|
|
98
|
+
reqTimestamp,
|
|
99
|
+
request,
|
|
100
|
+
undefined,
|
|
101
|
+
undefined,
|
|
102
|
+
true,
|
|
103
|
+
request.forceCache,
|
|
104
|
+
requestId
|
|
105
|
+
)
|
|
106
|
+
.then((result: AuthenticationResult) => {
|
|
107
|
+
atsMeasurement?.end({
|
|
108
|
+
success: true,
|
|
109
|
+
});
|
|
110
|
+
return result;
|
|
111
|
+
})
|
|
112
|
+
.catch((error) => {
|
|
113
|
+
this.logger.verbose(
|
|
114
|
+
"Error in fetching refresh token",
|
|
115
|
+
request.correlationId
|
|
116
|
+
);
|
|
117
|
+
atsMeasurement?.end({
|
|
118
|
+
errorCode: error.errorCode,
|
|
119
|
+
subErrorCode: error.subError,
|
|
120
|
+
success: false,
|
|
121
|
+
});
|
|
122
|
+
throw error;
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Gets cached refresh token and attaches to request, then calls acquireToken API
|
|
128
|
+
* @param request
|
|
129
|
+
*/
|
|
130
|
+
public async acquireTokenByRefreshToken(
|
|
131
|
+
request: CommonSilentFlowRequest
|
|
132
|
+
): Promise<AuthenticationResult> {
|
|
133
|
+
// Cannot renew token if no request object is given.
|
|
134
|
+
if (!request) {
|
|
135
|
+
throw ClientConfigurationError.createEmptyTokenRequestError();
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
this.performanceClient?.addQueueMeasurement(
|
|
139
|
+
PerformanceEvents.RefreshTokenClientAcquireTokenByRefreshToken,
|
|
140
|
+
request.correlationId
|
|
141
|
+
);
|
|
142
|
+
|
|
143
|
+
// We currently do not support silent flow for account === null use cases; This will be revisited for confidential flow usecases
|
|
144
|
+
if (!request.account) {
|
|
145
|
+
throw ClientAuthError.createNoAccountInSilentRequestError();
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// try checking if FOCI is enabled for the given application
|
|
149
|
+
const isFOCI = this.cacheManager.isAppMetadataFOCI(
|
|
150
|
+
request.account.environment
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
// if the app is part of the family, retrive a Family refresh token if present and make a refreshTokenRequest
|
|
154
|
+
if (isFOCI) {
|
|
155
|
+
try {
|
|
156
|
+
this.performanceClient?.setPreQueueTime(
|
|
157
|
+
PerformanceEvents.RefreshTokenClientAcquireTokenWithCachedRefreshToken,
|
|
158
|
+
request.correlationId
|
|
159
|
+
);
|
|
160
|
+
return this.acquireTokenWithCachedRefreshToken(request, true);
|
|
161
|
+
} catch (e) {
|
|
162
|
+
const noFamilyRTInCache =
|
|
163
|
+
e instanceof InteractionRequiredAuthError &&
|
|
164
|
+
e.errorCode ===
|
|
165
|
+
InteractionRequiredAuthErrorMessage.noTokensFoundError
|
|
166
|
+
.code;
|
|
167
|
+
const clientMismatchErrorWithFamilyRT =
|
|
168
|
+
e instanceof ServerError &&
|
|
169
|
+
e.errorCode === Errors.INVALID_GRANT_ERROR &&
|
|
170
|
+
e.subError === Errors.CLIENT_MISMATCH_ERROR;
|
|
171
|
+
|
|
172
|
+
// if family Refresh Token (FRT) cache acquisition fails or if client_mismatch error is seen with FRT, reattempt with application Refresh Token (ART)
|
|
173
|
+
if (noFamilyRTInCache || clientMismatchErrorWithFamilyRT) {
|
|
174
|
+
this.performanceClient?.setPreQueueTime(
|
|
175
|
+
PerformanceEvents.RefreshTokenClientAcquireTokenWithCachedRefreshToken,
|
|
176
|
+
request.correlationId
|
|
177
|
+
);
|
|
178
|
+
return this.acquireTokenWithCachedRefreshToken(
|
|
179
|
+
request,
|
|
180
|
+
false
|
|
181
|
+
);
|
|
182
|
+
// throw in all other cases
|
|
183
|
+
} else {
|
|
184
|
+
throw e;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
// fall back to application refresh token acquisition
|
|
189
|
+
this.performanceClient?.setPreQueueTime(
|
|
190
|
+
PerformanceEvents.RefreshTokenClientAcquireTokenWithCachedRefreshToken,
|
|
191
|
+
request.correlationId
|
|
192
|
+
);
|
|
193
|
+
return this.acquireTokenWithCachedRefreshToken(request, false);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* makes a network call to acquire tokens by exchanging RefreshToken available in userCache; throws if refresh token is not cached
|
|
198
|
+
* @param request
|
|
199
|
+
*/
|
|
200
|
+
private async acquireTokenWithCachedRefreshToken(
|
|
201
|
+
request: CommonSilentFlowRequest,
|
|
202
|
+
foci: boolean
|
|
203
|
+
) {
|
|
204
|
+
this.performanceClient?.addQueueMeasurement(
|
|
205
|
+
PerformanceEvents.RefreshTokenClientAcquireTokenWithCachedRefreshToken,
|
|
206
|
+
request.correlationId
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
// fetches family RT or application RT based on FOCI value
|
|
210
|
+
|
|
211
|
+
const atsMeasurement = this.performanceClient?.startMeasurement(
|
|
212
|
+
PerformanceEvents.RefreshTokenClientAcquireTokenWithCachedRefreshToken,
|
|
213
|
+
request.correlationId
|
|
214
|
+
);
|
|
215
|
+
this.logger.verbose(
|
|
216
|
+
"RefreshTokenClientAcquireTokenWithCachedRefreshToken called",
|
|
217
|
+
request.correlationId
|
|
218
|
+
);
|
|
219
|
+
const refreshToken = this.cacheManager.getRefreshToken(
|
|
220
|
+
request.account,
|
|
221
|
+
foci
|
|
222
|
+
);
|
|
223
|
+
|
|
224
|
+
if (!refreshToken) {
|
|
225
|
+
atsMeasurement?.discard();
|
|
226
|
+
throw InteractionRequiredAuthError.createNoTokensFoundError();
|
|
227
|
+
}
|
|
228
|
+
// attach cached RT size to the current measurement
|
|
229
|
+
atsMeasurement?.end({
|
|
230
|
+
success: true,
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
const refreshTokenRequest: CommonRefreshTokenRequest = {
|
|
234
|
+
...request,
|
|
235
|
+
refreshToken: refreshToken.secret,
|
|
236
|
+
authenticationScheme:
|
|
237
|
+
request.authenticationScheme || AuthenticationScheme.BEARER,
|
|
238
|
+
ccsCredential: {
|
|
239
|
+
credential: request.account.homeAccountId,
|
|
240
|
+
type: CcsCredentialType.HOME_ACCOUNT_ID,
|
|
241
|
+
},
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
this.performanceClient?.setPreQueueTime(
|
|
245
|
+
PerformanceEvents.RefreshTokenClientAcquireToken,
|
|
246
|
+
request.correlationId
|
|
247
|
+
);
|
|
248
|
+
return this.acquireToken(refreshTokenRequest);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Constructs the network message and makes a NW call to the underlying secure token service
|
|
253
|
+
* @param request
|
|
254
|
+
* @param authority
|
|
255
|
+
*/
|
|
256
|
+
private async executeTokenRequest(
|
|
257
|
+
request: CommonRefreshTokenRequest,
|
|
258
|
+
authority: Authority
|
|
259
|
+
): Promise<NetworkResponse<ServerAuthorizationTokenResponse>> {
|
|
260
|
+
this.performanceClient?.addQueueMeasurement(
|
|
261
|
+
PerformanceEvents.RefreshTokenClientExecuteTokenRequest,
|
|
262
|
+
request.correlationId
|
|
263
|
+
);
|
|
264
|
+
const acquireTokenMeasurement =
|
|
265
|
+
this.performanceClient?.startMeasurement(
|
|
266
|
+
PerformanceEvents.RefreshTokenClientExecuteTokenRequest,
|
|
267
|
+
request.correlationId
|
|
268
|
+
);
|
|
269
|
+
this.performanceClient?.setPreQueueTime(
|
|
270
|
+
PerformanceEvents.RefreshTokenClientCreateTokenRequestBody,
|
|
271
|
+
request.correlationId
|
|
272
|
+
);
|
|
273
|
+
|
|
274
|
+
const queryParametersString = this.createTokenQueryParameters(request);
|
|
275
|
+
const endpoint = UrlString.appendQueryString(
|
|
276
|
+
authority.tokenEndpoint,
|
|
277
|
+
queryParametersString
|
|
278
|
+
);
|
|
279
|
+
|
|
280
|
+
const requestBody = await this.createTokenRequestBody(request);
|
|
281
|
+
const headers: Record<string, string> = this.createTokenRequestHeaders(
|
|
282
|
+
request.ccsCredential
|
|
283
|
+
);
|
|
284
|
+
const thumbprint: RequestThumbprint = {
|
|
285
|
+
clientId: this.config.authOptions.clientId,
|
|
286
|
+
authority: authority.canonicalAuthority,
|
|
287
|
+
scopes: request.scopes,
|
|
288
|
+
claims: request.claims,
|
|
289
|
+
authenticationScheme: request.authenticationScheme,
|
|
290
|
+
resourceRequestMethod: request.resourceRequestMethod,
|
|
291
|
+
resourceRequestUri: request.resourceRequestUri,
|
|
292
|
+
shrClaims: request.shrClaims,
|
|
293
|
+
sshKid: request.sshKid,
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
return this.executePostToTokenEndpoint(
|
|
297
|
+
endpoint,
|
|
298
|
+
requestBody,
|
|
299
|
+
headers,
|
|
300
|
+
thumbprint,
|
|
301
|
+
request.correlationId
|
|
302
|
+
)
|
|
303
|
+
.then((result) => {
|
|
304
|
+
acquireTokenMeasurement?.end({
|
|
305
|
+
success: true,
|
|
306
|
+
});
|
|
307
|
+
return result;
|
|
308
|
+
})
|
|
309
|
+
.catch((error) => {
|
|
310
|
+
acquireTokenMeasurement?.end({
|
|
311
|
+
success: false,
|
|
312
|
+
});
|
|
313
|
+
throw error;
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Helper function to create the token request body
|
|
319
|
+
* @param request
|
|
320
|
+
*/
|
|
321
|
+
private async createTokenRequestBody(
|
|
322
|
+
request: CommonRefreshTokenRequest
|
|
323
|
+
): Promise<string> {
|
|
324
|
+
this.performanceClient?.addQueueMeasurement(
|
|
325
|
+
PerformanceEvents.RefreshTokenClientCreateTokenRequestBody,
|
|
326
|
+
request.correlationId
|
|
327
|
+
);
|
|
328
|
+
|
|
329
|
+
const correlationId = request.correlationId;
|
|
330
|
+
const acquireTokenMeasurement =
|
|
331
|
+
this.performanceClient?.startMeasurement(
|
|
332
|
+
PerformanceEvents.BaseClientCreateTokenRequestHeaders,
|
|
333
|
+
correlationId
|
|
334
|
+
);
|
|
335
|
+
const parameterBuilder = new RequestParameterBuilder();
|
|
336
|
+
|
|
337
|
+
parameterBuilder.addClientId(this.config.authOptions.clientId);
|
|
338
|
+
|
|
339
|
+
parameterBuilder.addScopes(
|
|
340
|
+
request.scopes,
|
|
341
|
+
true,
|
|
342
|
+
this.config.authOptions.authority.options.OIDCOptions?.defaultScopes
|
|
343
|
+
);
|
|
344
|
+
|
|
345
|
+
parameterBuilder.addGrantType(GrantType.REFRESH_TOKEN_GRANT);
|
|
346
|
+
|
|
347
|
+
parameterBuilder.addClientInfo();
|
|
348
|
+
|
|
349
|
+
parameterBuilder.addLibraryInfo(this.config.libraryInfo);
|
|
350
|
+
parameterBuilder.addApplicationTelemetry(
|
|
351
|
+
this.config.telemetry.application
|
|
352
|
+
);
|
|
353
|
+
parameterBuilder.addThrottling();
|
|
354
|
+
|
|
355
|
+
if (this.serverTelemetryManager && !isOidcProtocolMode(this.config)) {
|
|
356
|
+
parameterBuilder.addServerTelemetry(this.serverTelemetryManager);
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
parameterBuilder.addCorrelationId(correlationId);
|
|
360
|
+
|
|
361
|
+
parameterBuilder.addRefreshToken(request.refreshToken);
|
|
362
|
+
|
|
363
|
+
if (this.config.clientCredentials.clientSecret) {
|
|
364
|
+
parameterBuilder.addClientSecret(
|
|
365
|
+
this.config.clientCredentials.clientSecret
|
|
366
|
+
);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
if (this.config.clientCredentials.clientAssertion) {
|
|
370
|
+
const clientAssertion =
|
|
371
|
+
this.config.clientCredentials.clientAssertion;
|
|
372
|
+
parameterBuilder.addClientAssertion(clientAssertion.assertion);
|
|
373
|
+
parameterBuilder.addClientAssertionType(
|
|
374
|
+
clientAssertion.assertionType
|
|
375
|
+
);
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
if (request.authenticationScheme === AuthenticationScheme.POP) {
|
|
379
|
+
const popTokenGenerator = new PopTokenGenerator(
|
|
380
|
+
this.cryptoUtils,
|
|
381
|
+
this.performanceClient
|
|
382
|
+
);
|
|
383
|
+
this.performanceClient?.setPreQueueTime(
|
|
384
|
+
PerformanceEvents.PopTokenGenerateCnf,
|
|
385
|
+
request.correlationId
|
|
386
|
+
);
|
|
387
|
+
const reqCnfData = await popTokenGenerator.generateCnf(request);
|
|
388
|
+
// SPA PoP requires full Base64Url encoded req_cnf string (unhashed)
|
|
389
|
+
parameterBuilder.addPopToken(reqCnfData.reqCnfString);
|
|
390
|
+
} else if (request.authenticationScheme === AuthenticationScheme.SSH) {
|
|
391
|
+
if (request.sshJwk) {
|
|
392
|
+
parameterBuilder.addSshJwk(request.sshJwk);
|
|
393
|
+
} else {
|
|
394
|
+
acquireTokenMeasurement?.end({
|
|
395
|
+
success: false,
|
|
396
|
+
});
|
|
397
|
+
throw ClientConfigurationError.createMissingSshJwkError();
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
if (
|
|
402
|
+
!StringUtils.isEmptyObj(request.claims) ||
|
|
403
|
+
(this.config.authOptions.clientCapabilities &&
|
|
404
|
+
this.config.authOptions.clientCapabilities.length > 0)
|
|
405
|
+
) {
|
|
406
|
+
parameterBuilder.addClaims(
|
|
407
|
+
request.claims,
|
|
408
|
+
this.config.authOptions.clientCapabilities
|
|
409
|
+
);
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
if (
|
|
413
|
+
this.config.systemOptions.preventCorsPreflight &&
|
|
414
|
+
request.ccsCredential
|
|
415
|
+
) {
|
|
416
|
+
switch (request.ccsCredential.type) {
|
|
417
|
+
case CcsCredentialType.HOME_ACCOUNT_ID:
|
|
418
|
+
try {
|
|
419
|
+
const clientInfo = buildClientInfoFromHomeAccountId(
|
|
420
|
+
request.ccsCredential.credential
|
|
421
|
+
);
|
|
422
|
+
parameterBuilder.addCcsOid(clientInfo);
|
|
423
|
+
} catch (e) {
|
|
424
|
+
this.logger.verbose(
|
|
425
|
+
"Could not parse home account ID for CCS Header: " +
|
|
426
|
+
e
|
|
427
|
+
);
|
|
428
|
+
}
|
|
429
|
+
break;
|
|
430
|
+
case CcsCredentialType.UPN:
|
|
431
|
+
parameterBuilder.addCcsUpn(
|
|
432
|
+
request.ccsCredential.credential
|
|
433
|
+
);
|
|
434
|
+
break;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
acquireTokenMeasurement?.end({
|
|
438
|
+
success: true,
|
|
439
|
+
});
|
|
440
|
+
return parameterBuilder.createQueryString();
|
|
441
|
+
}
|
|
442
|
+
}
|