@azure/msal-common 0.0.1-alpha.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/LICENSE +21 -0
- package/README.md +62 -0
- package/dist/_virtual/_tslib.js +90 -0
- package/dist/_virtual/_tslib.js.map +1 -0
- package/dist/account/AccountInfo.d.ts +30 -0
- package/dist/account/AccountInfo.d.ts.map +1 -0
- package/dist/account/AuthToken.d.ts +17 -0
- package/dist/account/AuthToken.d.ts.map +1 -0
- package/dist/account/AuthToken.js +43 -0
- package/dist/account/AuthToken.js.map +1 -0
- package/dist/account/CcsCredential.d.ts +9 -0
- package/dist/account/CcsCredential.d.ts.map +1 -0
- package/dist/account/CcsCredential.js +14 -0
- package/dist/account/CcsCredential.js.map +1 -0
- package/dist/account/ClientCredentials.d.ts +15 -0
- package/dist/account/ClientCredentials.d.ts.map +1 -0
- package/dist/account/ClientInfo.d.ts +20 -0
- package/dist/account/ClientInfo.d.ts.map +1 -0
- package/dist/account/ClientInfo.js +44 -0
- package/dist/account/ClientInfo.js.map +1 -0
- package/dist/account/DecodedAuthToken.d.ts +9 -0
- package/dist/account/DecodedAuthToken.d.ts.map +1 -0
- package/dist/account/TokenClaims.d.ts +60 -0
- package/dist/account/TokenClaims.d.ts.map +1 -0
- package/dist/authority/Authority.d.ts +200 -0
- package/dist/authority/Authority.d.ts.map +1 -0
- package/dist/authority/Authority.js +678 -0
- package/dist/authority/Authority.js.map +1 -0
- package/dist/authority/AuthorityFactory.d.ts +29 -0
- package/dist/authority/AuthorityFactory.d.ts.map +1 -0
- package/dist/authority/AuthorityFactory.js +69 -0
- package/dist/authority/AuthorityFactory.js.map +1 -0
- package/dist/authority/AuthorityMetadata.d.ts +623 -0
- package/dist/authority/AuthorityMetadata.d.ts.map +1 -0
- package/dist/authority/AuthorityMetadata.js +12 -0
- package/dist/authority/AuthorityMetadata.js.map +1 -0
- package/dist/authority/AuthorityOptions.d.ts +19 -0
- package/dist/authority/AuthorityOptions.d.ts.map +1 -0
- package/dist/authority/AuthorityOptions.js +24 -0
- package/dist/authority/AuthorityOptions.js.map +1 -0
- package/dist/authority/AuthorityType.d.ts +8 -0
- package/dist/authority/AuthorityType.d.ts.map +1 -0
- package/dist/authority/AuthorityType.js +17 -0
- package/dist/authority/AuthorityType.js.map +1 -0
- package/dist/authority/AzureRegion.d.ts +2 -0
- package/dist/authority/AzureRegion.d.ts.map +1 -0
- package/dist/authority/AzureRegionConfiguration.d.ts +6 -0
- package/dist/authority/AzureRegionConfiguration.d.ts.map +1 -0
- package/dist/authority/CloudDiscoveryMetadata.d.ts +6 -0
- package/dist/authority/CloudDiscoveryMetadata.d.ts.map +1 -0
- package/dist/authority/CloudInstanceDiscoveryResponse.d.ts +10 -0
- package/dist/authority/CloudInstanceDiscoveryResponse.d.ts.map +1 -0
- package/dist/authority/CloudInstanceDiscoveryResponse.js +13 -0
- package/dist/authority/CloudInstanceDiscoveryResponse.js.map +1 -0
- package/dist/authority/ImdsOptions.d.ts +7 -0
- package/dist/authority/ImdsOptions.d.ts.map +1 -0
- package/dist/authority/OpenIdConfigResponse.d.ts +12 -0
- package/dist/authority/OpenIdConfigResponse.d.ts.map +1 -0
- package/dist/authority/OpenIdConfigResponse.js +15 -0
- package/dist/authority/OpenIdConfigResponse.js.map +1 -0
- package/dist/authority/ProtocolMode.d.ts +8 -0
- package/dist/authority/ProtocolMode.d.ts.map +1 -0
- package/dist/authority/ProtocolMode.js +17 -0
- package/dist/authority/ProtocolMode.js.map +1 -0
- package/dist/authority/RegionDiscovery.d.ts +28 -0
- package/dist/authority/RegionDiscovery.d.ts.map +1 -0
- package/dist/authority/RegionDiscovery.js +127 -0
- package/dist/authority/RegionDiscovery.js.map +1 -0
- package/dist/authority/RegionDiscoveryMetadata.d.ts +7 -0
- package/dist/authority/RegionDiscoveryMetadata.d.ts.map +1 -0
- package/dist/cache/CacheManager.d.ts +393 -0
- package/dist/cache/CacheManager.d.ts.map +1 -0
- package/dist/cache/CacheManager.js +885 -0
- package/dist/cache/CacheManager.js.map +1 -0
- package/dist/cache/entities/AccessTokenEntity.d.ts +57 -0
- package/dist/cache/entities/AccessTokenEntity.d.ts.map +1 -0
- package/dist/cache/entities/AccessTokenEntity.js +124 -0
- package/dist/cache/entities/AccessTokenEntity.js.map +1 -0
- package/dist/cache/entities/AccountEntity.d.ts +100 -0
- package/dist/cache/entities/AccountEntity.d.ts.map +1 -0
- package/dist/cache/entities/AccountEntity.js +243 -0
- package/dist/cache/entities/AccountEntity.js.map +1 -0
- package/dist/cache/entities/AppMetadataEntity.d.ts +40 -0
- package/dist/cache/entities/AppMetadataEntity.d.ts.map +1 -0
- package/dist/cache/entities/AppMetadataEntity.js +74 -0
- package/dist/cache/entities/AppMetadataEntity.js.map +1 -0
- package/dist/cache/entities/AuthorityMetadataEntity.d.ts +48 -0
- package/dist/cache/entities/AuthorityMetadataEntity.d.ts.map +1 -0
- package/dist/cache/entities/AuthorityMetadataEntity.js +82 -0
- package/dist/cache/entities/AuthorityMetadataEntity.js.map +1 -0
- package/dist/cache/entities/CacheRecord.d.ts +14 -0
- package/dist/cache/entities/CacheRecord.d.ts.map +1 -0
- package/dist/cache/entities/CacheRecord.js +19 -0
- package/dist/cache/entities/CacheRecord.js.map +1 -0
- package/dist/cache/entities/CredentialEntity.d.ts +94 -0
- package/dist/cache/entities/CredentialEntity.d.ts.map +1 -0
- package/dist/cache/entities/CredentialEntity.js +164 -0
- package/dist/cache/entities/CredentialEntity.js.map +1 -0
- package/dist/cache/entities/IdTokenEntity.d.ts +35 -0
- package/dist/cache/entities/IdTokenEntity.d.ts.map +1 -0
- package/dist/cache/entities/IdTokenEntity.js +70 -0
- package/dist/cache/entities/IdTokenEntity.js.map +1 -0
- package/dist/cache/entities/RefreshTokenEntity.d.ts +37 -0
- package/dist/cache/entities/RefreshTokenEntity.d.ts.map +1 -0
- package/dist/cache/entities/RefreshTokenEntity.js +73 -0
- package/dist/cache/entities/RefreshTokenEntity.js.map +1 -0
- package/dist/cache/entities/ServerTelemetryEntity.d.ts +13 -0
- package/dist/cache/entities/ServerTelemetryEntity.d.ts.map +1 -0
- package/dist/cache/entities/ServerTelemetryEntity.js +35 -0
- package/dist/cache/entities/ServerTelemetryEntity.js.map +1 -0
- package/dist/cache/entities/ThrottlingEntity.d.ts +14 -0
- package/dist/cache/entities/ThrottlingEntity.d.ts.map +1 -0
- package/dist/cache/entities/ThrottlingEntity.js +32 -0
- package/dist/cache/entities/ThrottlingEntity.js.map +1 -0
- package/dist/cache/interface/ICacheManager.d.ts +157 -0
- package/dist/cache/interface/ICacheManager.d.ts.map +1 -0
- package/dist/cache/interface/ICachePlugin.d.ts +6 -0
- package/dist/cache/interface/ICachePlugin.d.ts.map +1 -0
- package/dist/cache/interface/ISerializableTokenCache.d.ts +5 -0
- package/dist/cache/interface/ISerializableTokenCache.d.ts.map +1 -0
- package/dist/cache/persistence/TokenCacheContext.d.ts +24 -0
- package/dist/cache/persistence/TokenCacheContext.d.ts.map +1 -0
- package/dist/cache/persistence/TokenCacheContext.js +39 -0
- package/dist/cache/persistence/TokenCacheContext.js.map +1 -0
- package/dist/cache/utils/CacheTypes.d.ts +60 -0
- package/dist/cache/utils/CacheTypes.d.ts.map +1 -0
- package/dist/client/AuthorizationCodeClient.d.ts +76 -0
- package/dist/client/AuthorizationCodeClient.d.ts.map +1 -0
- package/dist/client/AuthorizationCodeClient.js +468 -0
- package/dist/client/AuthorizationCodeClient.js.map +1 -0
- package/dist/client/BaseClient.d.ts +45 -0
- package/dist/client/BaseClient.d.ts.map +1 -0
- package/dist/client/BaseClient.js +103 -0
- package/dist/client/BaseClient.js.map +1 -0
- package/dist/client/ClientCredentialClient.d.ts +39 -0
- package/dist/client/ClientCredentialClient.d.ts.map +1 -0
- package/dist/client/ClientCredentialClient.js +202 -0
- package/dist/client/ClientCredentialClient.js.map +1 -0
- package/dist/client/DeviceCodeClient.d.ts +52 -0
- package/dist/client/DeviceCodeClient.d.ts.map +1 -0
- package/dist/client/DeviceCodeClient.js +232 -0
- package/dist/client/DeviceCodeClient.js.map +1 -0
- package/dist/client/OnBehalfOfClient.d.ts +51 -0
- package/dist/client/OnBehalfOfClient.d.ts.map +1 -0
- package/dist/client/OnBehalfOfClient.js +244 -0
- package/dist/client/OnBehalfOfClient.js.map +1 -0
- package/dist/client/RefreshTokenClient.d.ts +40 -0
- package/dist/client/RefreshTokenClient.d.ts.map +1 -0
- package/dist/client/RefreshTokenClient.js +255 -0
- package/dist/client/RefreshTokenClient.js.map +1 -0
- package/dist/client/SilentFlowClient.d.ts +25 -0
- package/dist/client/SilentFlowClient.d.ts.map +1 -0
- package/dist/client/SilentFlowClient.js +128 -0
- package/dist/client/SilentFlowClient.js.map +1 -0
- package/dist/client/UsernamePasswordClient.d.ts +29 -0
- package/dist/client/UsernamePasswordClient.d.ts.map +1 -0
- package/dist/client/UsernamePasswordClient.js +120 -0
- package/dist/client/UsernamePasswordClient.js.map +1 -0
- package/dist/config/AppTokenProvider.d.ts +39 -0
- package/dist/config/AppTokenProvider.d.ts.map +1 -0
- package/dist/config/ClientConfiguration.d.ts +135 -0
- package/dist/config/ClientConfiguration.d.ts.map +1 -0
- package/dist/config/ClientConfiguration.js +105 -0
- package/dist/config/ClientConfiguration.js.map +1 -0
- package/dist/crypto/ICrypto.d.ts +63 -0
- package/dist/crypto/ICrypto.d.ts.map +1 -0
- package/dist/crypto/ICrypto.js +80 -0
- package/dist/crypto/ICrypto.js.map +1 -0
- package/dist/crypto/IGuidGenerator.d.ts +5 -0
- package/dist/crypto/IGuidGenerator.d.ts.map +1 -0
- package/dist/crypto/JoseHeader.d.ts +22 -0
- package/dist/crypto/JoseHeader.d.ts.map +1 -0
- package/dist/crypto/JoseHeader.js +45 -0
- package/dist/crypto/JoseHeader.js.map +1 -0
- package/dist/crypto/PopTokenGenerator.d.ts +56 -0
- package/dist/crypto/PopTokenGenerator.d.ts.map +1 -0
- package/dist/crypto/PopTokenGenerator.js +107 -0
- package/dist/crypto/PopTokenGenerator.js.map +1 -0
- package/dist/crypto/SignedHttpRequest.d.ts +12 -0
- package/dist/crypto/SignedHttpRequest.d.ts.map +1 -0
- package/dist/error/AuthError.d.ts +48 -0
- package/dist/error/AuthError.d.ts.map +1 -0
- package/dist/error/AuthError.js +61 -0
- package/dist/error/AuthError.js.map +1 -0
- package/dist/error/ClientAuthError.d.ts +372 -0
- package/dist/error/ClientAuthError.d.ts.map +1 -0
- package/dist/error/ClientAuthError.js +477 -0
- package/dist/error/ClientAuthError.js.map +1 -0
- package/dist/error/ClientConfigurationError.d.ts +199 -0
- package/dist/error/ClientConfigurationError.d.ts.map +1 -0
- package/dist/error/ClientConfigurationError.js +260 -0
- package/dist/error/ClientConfigurationError.js.map +1 -0
- package/dist/error/InteractionRequiredAuthError.d.ts +42 -0
- package/dist/error/InteractionRequiredAuthError.d.ts.map +1 -0
- package/dist/error/InteractionRequiredAuthError.js +80 -0
- package/dist/error/InteractionRequiredAuthError.js.map +1 -0
- package/dist/error/JoseHeaderError.d.ts +29 -0
- package/dist/error/JoseHeaderError.d.ts.map +1 -0
- package/dist/error/JoseHeaderError.js +50 -0
- package/dist/error/JoseHeaderError.js.map +1 -0
- package/dist/error/ServerError.d.ts +8 -0
- package/dist/error/ServerError.d.ts.map +1 -0
- package/dist/error/ServerError.js +25 -0
- package/dist/error/ServerError.js.map +1 -0
- package/dist/index.cjs.js +8441 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +90 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +53 -0
- package/dist/index.js.map +1 -0
- package/dist/logger/Logger.d.ts +95 -0
- package/dist/logger/Logger.d.ts.map +1 -0
- package/dist/logger/Logger.js +185 -0
- package/dist/logger/Logger.js.map +1 -0
- package/dist/network/INetworkModule.d.ts +31 -0
- package/dist/network/INetworkModule.d.ts.map +1 -0
- package/dist/network/INetworkModule.js +21 -0
- package/dist/network/INetworkModule.js.map +1 -0
- package/dist/network/NetworkManager.d.ts +21 -0
- package/dist/network/NetworkManager.d.ts.map +1 -0
- package/dist/network/NetworkManager.js +56 -0
- package/dist/network/NetworkManager.js.map +1 -0
- package/dist/network/RequestThumbprint.d.ts +17 -0
- package/dist/network/RequestThumbprint.d.ts.map +1 -0
- package/dist/network/ThrottlingUtils.d.ts +42 -0
- package/dist/network/ThrottlingUtils.d.ts.map +1 -0
- package/dist/network/ThrottlingUtils.js +101 -0
- package/dist/network/ThrottlingUtils.js.map +1 -0
- package/dist/packageMetadata.d.ts +3 -0
- package/dist/packageMetadata.d.ts.map +1 -0
- package/dist/packageMetadata.js +8 -0
- package/dist/packageMetadata.js.map +1 -0
- package/dist/request/AuthenticationHeaderParser.d.ts +20 -0
- package/dist/request/AuthenticationHeaderParser.d.ts.map +1 -0
- package/dist/request/AuthenticationHeaderParser.js +64 -0
- package/dist/request/AuthenticationHeaderParser.js.map +1 -0
- package/dist/request/BaseAuthRequest.d.ts +34 -0
- package/dist/request/BaseAuthRequest.d.ts.map +1 -0
- package/dist/request/CommonAuthorizationCodeRequest.d.ts +28 -0
- package/dist/request/CommonAuthorizationCodeRequest.d.ts.map +1 -0
- package/dist/request/CommonAuthorizationUrlRequest.d.ts +51 -0
- package/dist/request/CommonAuthorizationUrlRequest.d.ts.map +1 -0
- package/dist/request/CommonClientCredentialRequest.d.ts +17 -0
- package/dist/request/CommonClientCredentialRequest.d.ts.map +1 -0
- package/dist/request/CommonDeviceCodeRequest.d.ts +19 -0
- package/dist/request/CommonDeviceCodeRequest.d.ts.map +1 -0
- package/dist/request/CommonEndSessionRequest.d.ts +21 -0
- package/dist/request/CommonEndSessionRequest.d.ts.map +1 -0
- package/dist/request/CommonOnBehalfOfRequest.d.ts +13 -0
- package/dist/request/CommonOnBehalfOfRequest.d.ts.map +1 -0
- package/dist/request/CommonRefreshTokenRequest.d.ts +21 -0
- package/dist/request/CommonRefreshTokenRequest.d.ts.map +1 -0
- package/dist/request/CommonSilentFlowRequest.d.ts +20 -0
- package/dist/request/CommonSilentFlowRequest.d.ts.map +1 -0
- package/dist/request/CommonUsernamePasswordRequest.d.ts +17 -0
- package/dist/request/CommonUsernamePasswordRequest.d.ts.map +1 -0
- package/dist/request/RequestParameterBuilder.d.ts +217 -0
- package/dist/request/RequestParameterBuilder.d.ts.map +1 -0
- package/dist/request/RequestParameterBuilder.js +387 -0
- package/dist/request/RequestParameterBuilder.js.map +1 -0
- package/dist/request/RequestValidator.d.ts +34 -0
- package/dist/request/RequestValidator.d.ts.map +1 -0
- package/dist/request/RequestValidator.js +92 -0
- package/dist/request/RequestValidator.js.map +1 -0
- package/dist/request/ScopeSet.d.ts +83 -0
- package/dist/request/ScopeSet.d.ts.map +1 -0
- package/dist/request/ScopeSet.js +192 -0
- package/dist/request/ScopeSet.js.map +1 -0
- package/dist/response/AuthenticationResult.d.ts +38 -0
- package/dist/response/AuthenticationResult.d.ts.map +1 -0
- package/dist/response/AuthorizationCodePayload.d.ts +14 -0
- package/dist/response/AuthorizationCodePayload.d.ts.map +1 -0
- package/dist/response/DeviceCodeResponse.d.ts +26 -0
- package/dist/response/DeviceCodeResponse.d.ts.map +1 -0
- package/dist/response/ExternalTokenResponse.d.ts +15 -0
- package/dist/response/ExternalTokenResponse.d.ts.map +1 -0
- package/dist/response/IMDSBadResponse.d.ts +5 -0
- package/dist/response/IMDSBadResponse.d.ts.map +1 -0
- package/dist/response/ResponseHandler.d.ts +71 -0
- package/dist/response/ResponseHandler.d.ts.map +1 -0
- package/dist/response/ResponseHandler.js +293 -0
- package/dist/response/ResponseHandler.js.map +1 -0
- package/dist/response/ServerAuthorizationCodeResponse.d.ts +22 -0
- package/dist/response/ServerAuthorizationCodeResponse.d.ts.map +1 -0
- package/dist/response/ServerAuthorizationTokenResponse.d.ts +43 -0
- package/dist/response/ServerAuthorizationTokenResponse.d.ts.map +1 -0
- package/dist/telemetry/performance/IPerformanceClient.d.ts +22 -0
- package/dist/telemetry/performance/IPerformanceClient.d.ts.map +1 -0
- package/dist/telemetry/performance/IPerformanceMeasurement.d.ts +6 -0
- package/dist/telemetry/performance/IPerformanceMeasurement.d.ts.map +1 -0
- package/dist/telemetry/performance/PerformanceClient.d.ts +125 -0
- package/dist/telemetry/performance/PerformanceClient.d.ts.map +1 -0
- package/dist/telemetry/performance/PerformanceClient.js +281 -0
- package/dist/telemetry/performance/PerformanceClient.js.map +1 -0
- package/dist/telemetry/performance/PerformanceEvent.d.ts +249 -0
- package/dist/telemetry/performance/PerformanceEvent.d.ts.map +1 -0
- package/dist/telemetry/performance/PerformanceEvent.js +121 -0
- package/dist/telemetry/performance/PerformanceEvent.js.map +1 -0
- package/dist/telemetry/performance/StubPerformanceClient.d.ts +13 -0
- package/dist/telemetry/performance/StubPerformanceClient.d.ts.map +1 -0
- package/dist/telemetry/performance/StubPerformanceClient.js +37 -0
- package/dist/telemetry/performance/StubPerformanceClient.js.map +1 -0
- package/dist/telemetry/server/ServerTelemetryManager.d.ts +67 -0
- package/dist/telemetry/server/ServerTelemetryManager.d.ts.map +1 -0
- package/dist/telemetry/server/ServerTelemetryManager.js +168 -0
- package/dist/telemetry/server/ServerTelemetryManager.js.map +1 -0
- package/dist/telemetry/server/ServerTelemetryRequest.d.ts +9 -0
- package/dist/telemetry/server/ServerTelemetryRequest.d.ts.map +1 -0
- package/dist/url/IUri.d.ts +13 -0
- package/dist/url/IUri.d.ts.map +1 -0
- package/dist/url/UrlString.d.ts +62 -0
- package/dist/url/UrlString.d.ts.map +1 -0
- package/dist/url/UrlString.js +208 -0
- package/dist/url/UrlString.js.map +1 -0
- package/dist/utils/Constants.d.ts +340 -0
- package/dist/utils/Constants.d.ts.map +1 -0
- package/dist/utils/Constants.js +381 -0
- package/dist/utils/Constants.js.map +1 -0
- package/dist/utils/MsalTypes.d.ts +7 -0
- package/dist/utils/MsalTypes.d.ts.map +1 -0
- package/dist/utils/ProtocolUtils.d.ts +43 -0
- package/dist/utils/ProtocolUtils.d.ts.map +1 -0
- package/dist/utils/ProtocolUtils.js +77 -0
- package/dist/utils/ProtocolUtils.js.map +1 -0
- package/dist/utils/StringUtils.d.ts +54 -0
- package/dist/utils/StringUtils.d.ts.map +1 -0
- package/dist/utils/StringUtils.js +129 -0
- package/dist/utils/StringUtils.js.map +1 -0
- package/dist/utils/TimeUtils.d.ts +28 -0
- package/dist/utils/TimeUtils.d.ts.map +1 -0
- package/dist/utils/TimeUtils.js +53 -0
- package/dist/utils/TimeUtils.js.map +1 -0
- package/package.json +76 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/*! @azure/msal-common v0.0.1-alpha.0 2022-08-02 */
|
|
2
|
+
'use strict';
|
|
3
|
+
import { __awaiter, __generator } from '../_virtual/_tslib.js';
|
|
4
|
+
import { buildClientConfiguration } from '../config/ClientConfiguration.js';
|
|
5
|
+
import { NetworkManager } from '../network/NetworkManager.js';
|
|
6
|
+
import { Logger } from '../logger/Logger.js';
|
|
7
|
+
import { HeaderNames, Constants } from '../utils/Constants.js';
|
|
8
|
+
import { name, version } from '../packageMetadata.js';
|
|
9
|
+
import { ClientAuthError } from '../error/ClientAuthError.js';
|
|
10
|
+
import { CcsCredentialType } from '../account/CcsCredential.js';
|
|
11
|
+
import { buildClientInfoFromHomeAccountId } from '../account/ClientInfo.js';
|
|
12
|
+
|
|
13
|
+
/*
|
|
14
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
15
|
+
* Licensed under the MIT License.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Base application class which will construct requests to send to and handle responses from the Microsoft STS using the authorization code flow.
|
|
19
|
+
*/
|
|
20
|
+
var BaseClient = /** @class */ (function () {
|
|
21
|
+
function BaseClient(configuration, performanceClient) {
|
|
22
|
+
// Set the configuration
|
|
23
|
+
this.config = buildClientConfiguration(configuration);
|
|
24
|
+
// Initialize the logger
|
|
25
|
+
this.logger = new Logger(this.config.loggerOptions, name, version);
|
|
26
|
+
// Initialize crypto
|
|
27
|
+
this.cryptoUtils = this.config.cryptoInterface;
|
|
28
|
+
// Initialize storage interface
|
|
29
|
+
this.cacheManager = this.config.storageInterface;
|
|
30
|
+
// Set the network interface
|
|
31
|
+
this.networkClient = this.config.networkInterface;
|
|
32
|
+
// Set the NetworkManager
|
|
33
|
+
this.networkManager = new NetworkManager(this.networkClient, this.cacheManager);
|
|
34
|
+
// Set TelemetryManager
|
|
35
|
+
this.serverTelemetryManager = this.config.serverTelemetryManager;
|
|
36
|
+
// set Authority
|
|
37
|
+
this.authority = this.config.authOptions.authority;
|
|
38
|
+
// set performance telemetry client
|
|
39
|
+
this.performanceClient = performanceClient;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Creates default headers for requests to token endpoint
|
|
43
|
+
*/
|
|
44
|
+
BaseClient.prototype.createTokenRequestHeaders = function (ccsCred) {
|
|
45
|
+
var headers = {};
|
|
46
|
+
headers[HeaderNames.CONTENT_TYPE] = Constants.URL_FORM_CONTENT_TYPE;
|
|
47
|
+
if (!this.config.systemOptions.preventCorsPreflight && ccsCred) {
|
|
48
|
+
switch (ccsCred.type) {
|
|
49
|
+
case CcsCredentialType.HOME_ACCOUNT_ID:
|
|
50
|
+
try {
|
|
51
|
+
var clientInfo = buildClientInfoFromHomeAccountId(ccsCred.credential);
|
|
52
|
+
headers[HeaderNames.CCS_HEADER] = "Oid:" + clientInfo.uid + "@" + clientInfo.utid;
|
|
53
|
+
}
|
|
54
|
+
catch (e) {
|
|
55
|
+
this.logger.verbose("Could not parse home account ID for CCS Header: " + e);
|
|
56
|
+
}
|
|
57
|
+
break;
|
|
58
|
+
case CcsCredentialType.UPN:
|
|
59
|
+
headers[HeaderNames.CCS_HEADER] = "UPN: " + ccsCred.credential;
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return headers;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Http post to token endpoint
|
|
67
|
+
* @param tokenEndpoint
|
|
68
|
+
* @param queryString
|
|
69
|
+
* @param headers
|
|
70
|
+
* @param thumbprint
|
|
71
|
+
*/
|
|
72
|
+
BaseClient.prototype.executePostToTokenEndpoint = function (tokenEndpoint, queryString, headers, thumbprint) {
|
|
73
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
74
|
+
var response;
|
|
75
|
+
return __generator(this, function (_a) {
|
|
76
|
+
switch (_a.label) {
|
|
77
|
+
case 0: return [4 /*yield*/, this.networkManager.sendPostRequest(thumbprint, tokenEndpoint, { body: queryString, headers: headers, proxyUrl: this.config.systemOptions.proxyUrl })];
|
|
78
|
+
case 1:
|
|
79
|
+
response = _a.sent();
|
|
80
|
+
if (this.config.serverTelemetryManager && response.status < 500 && response.status !== 429) {
|
|
81
|
+
// Telemetry data successfully logged by server, clear Telemetry cache
|
|
82
|
+
this.config.serverTelemetryManager.clearTelemetryCache();
|
|
83
|
+
}
|
|
84
|
+
return [2 /*return*/, response];
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Updates the authority object of the client. Endpoint discovery must be completed.
|
|
91
|
+
* @param updatedAuthority
|
|
92
|
+
*/
|
|
93
|
+
BaseClient.prototype.updateAuthority = function (updatedAuthority) {
|
|
94
|
+
if (!updatedAuthority.discoveryComplete()) {
|
|
95
|
+
throw ClientAuthError.createEndpointDiscoveryIncompleteError("Updated authority has not completed endpoint discovery.");
|
|
96
|
+
}
|
|
97
|
+
this.authority = updatedAuthority;
|
|
98
|
+
};
|
|
99
|
+
return BaseClient;
|
|
100
|
+
}());
|
|
101
|
+
|
|
102
|
+
export { BaseClient };
|
|
103
|
+
//# sourceMappingURL=BaseClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseClient.js","sources":["../../src/client/BaseClient.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ClientConfiguration, buildClientConfiguration, CommonClientConfiguration } from \"../config/ClientConfiguration\";\nimport { INetworkModule } from \"../network/INetworkModule\";\nimport { NetworkManager, NetworkResponse } from \"../network/NetworkManager\";\nimport { ICrypto } from \"../crypto/ICrypto\";\nimport { Authority } from \"../authority/Authority\";\nimport { Logger } from \"../logger/Logger\";\nimport { Constants, HeaderNames } from \"../utils/Constants\";\nimport { ServerAuthorizationTokenResponse } from \"../response/ServerAuthorizationTokenResponse\";\nimport { CacheManager } from \"../cache/CacheManager\";\nimport { ServerTelemetryManager } from \"../telemetry/server/ServerTelemetryManager\";\nimport { RequestThumbprint } from \"../network/RequestThumbprint\";\nimport { version, name } from \"../packageMetadata\";\nimport { ClientAuthError } from \"../error/ClientAuthError\";\nimport { CcsCredential, CcsCredentialType } from \"../account/CcsCredential\";\nimport { buildClientInfoFromHomeAccountId } from \"../account/ClientInfo\";\nimport { IPerformanceClient } from \"../telemetry/performance/IPerformanceClient\";\n\n/**\n * Base application class which will construct requests to send to and handle responses from the Microsoft STS using the authorization code flow.\n */\nexport abstract class BaseClient {\n // Logger object\n public logger: Logger;\n\n // Application config\n protected config: CommonClientConfiguration;\n\n // Crypto Interface\n protected cryptoUtils: ICrypto;\n\n // Storage Interface\n protected cacheManager: CacheManager;\n\n // Network Interface\n protected networkClient: INetworkModule;\n\n // Server Telemetry Manager\n protected serverTelemetryManager: ServerTelemetryManager | null;\n\n // Network Manager\n protected networkManager: NetworkManager;\n\n // Default authority object\n public authority: Authority;\n\n // Performance telemetry client\n protected performanceClient?: IPerformanceClient;\n\n protected constructor(configuration: ClientConfiguration, performanceClient?: IPerformanceClient) {\n // Set the configuration\n this.config = buildClientConfiguration(configuration);\n\n // Initialize the logger\n this.logger = new Logger(this.config.loggerOptions, name, version);\n\n // Initialize crypto\n this.cryptoUtils = this.config.cryptoInterface;\n\n // Initialize storage interface\n this.cacheManager = this.config.storageInterface;\n\n // Set the network interface\n this.networkClient = this.config.networkInterface;\n\n // Set the NetworkManager\n this.networkManager = new NetworkManager(this.networkClient, this.cacheManager);\n\n // Set TelemetryManager\n this.serverTelemetryManager = this.config.serverTelemetryManager;\n\n // set Authority\n this.authority = this.config.authOptions.authority;\n\n // set performance telemetry client\n this.performanceClient = performanceClient;\n }\n\n /**\n * Creates default headers for requests to token endpoint\n */\n protected createTokenRequestHeaders(ccsCred?: CcsCredential): Record<string, string> { \n const headers: Record<string, string> = {};\n headers[HeaderNames.CONTENT_TYPE] = Constants.URL_FORM_CONTENT_TYPE;\n\n if (!this.config.systemOptions.preventCorsPreflight && ccsCred) {\n switch (ccsCred.type) {\n case CcsCredentialType.HOME_ACCOUNT_ID:\n try {\n const clientInfo = buildClientInfoFromHomeAccountId(ccsCred.credential);\n headers[HeaderNames.CCS_HEADER] = `Oid:${clientInfo.uid}@${clientInfo.utid}`;\n } catch (e) {\n this.logger.verbose(\"Could not parse home account ID for CCS Header: \" + e);\n }\n break;\n case CcsCredentialType.UPN:\n headers[HeaderNames.CCS_HEADER] = `UPN: ${ccsCred.credential}`;\n break;\n }\n } \n return headers;\n }\n\n /**\n * Http post to token endpoint\n * @param tokenEndpoint\n * @param queryString\n * @param headers\n * @param thumbprint\n */\n protected async executePostToTokenEndpoint(tokenEndpoint: string, queryString: string, headers: Record<string, string>, thumbprint: RequestThumbprint): Promise<NetworkResponse<ServerAuthorizationTokenResponse>> {\n const response = await this.networkManager.sendPostRequest<ServerAuthorizationTokenResponse>(\n thumbprint,\n tokenEndpoint,\n { body: queryString, headers: headers, proxyUrl: this.config.systemOptions.proxyUrl }\n );\n\n if (this.config.serverTelemetryManager && response.status < 500 && response.status !== 429) {\n // Telemetry data successfully logged by server, clear Telemetry cache\n this.config.serverTelemetryManager.clearTelemetryCache();\n }\n\n return response;\n }\n\n /**\n * Updates the authority object of the client. Endpoint discovery must be completed.\n * @param updatedAuthority\n */\n updateAuthority(updatedAuthority: Authority): void {\n if (!updatedAuthority.discoveryComplete()) {\n throw ClientAuthError.createEndpointDiscoveryIncompleteError(\"Updated authority has not completed endpoint discovery.\");\n }\n this.authority = updatedAuthority;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;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A;AAED;;;AAGG;IACH,UAAe,CAAA,SAAA,CAAA,eAAA,GAAf,UAAgB,gBAA2B,EAAA;AACvC,QAAA,IAAI,CAAC,gBAAgB,CAAC,iBAAiB,EAAE,EAAE;AACvC,YAAA,MAAM,eAAe,CAAC,sCAAsC,CAAC,yDAAyD,CAAC,CAAC;AAC3H,SAAA;AACD,QAAA,IAAI,CAAC,SAAS,GAAG,gBAAgB,CAAC;KACrC,CAAA;IACL,OAAC,UAAA,CAAA;AAAD,CAAC,EAAA;;;;"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ClientConfiguration } from "../config/ClientConfiguration";
|
|
2
|
+
import { BaseClient } from "./BaseClient";
|
|
3
|
+
import { AuthenticationResult } from "../response/AuthenticationResult";
|
|
4
|
+
import { CommonClientCredentialRequest } from "../request/CommonClientCredentialRequest";
|
|
5
|
+
import { IAppTokenProvider } from "../config/AppTokenProvider";
|
|
6
|
+
/**
|
|
7
|
+
* OAuth2.0 client credential grant
|
|
8
|
+
*/
|
|
9
|
+
export declare class ClientCredentialClient extends BaseClient {
|
|
10
|
+
private scopeSet;
|
|
11
|
+
private readonly appTokenProvider?;
|
|
12
|
+
constructor(configuration: ClientConfiguration, appTokenProvider?: IAppTokenProvider);
|
|
13
|
+
/**
|
|
14
|
+
* Public API to acquire a token with ClientCredential Flow for Confidential clients
|
|
15
|
+
* @param request
|
|
16
|
+
*/
|
|
17
|
+
acquireToken(request: CommonClientCredentialRequest): Promise<AuthenticationResult | null>;
|
|
18
|
+
/**
|
|
19
|
+
* looks up cache if the tokens are cached already
|
|
20
|
+
*/
|
|
21
|
+
private getCachedAuthenticationResult;
|
|
22
|
+
/**
|
|
23
|
+
* Reads access token from the cache
|
|
24
|
+
* TODO: Move this call to cacheManager instead
|
|
25
|
+
*/
|
|
26
|
+
private readAccessTokenFromCache;
|
|
27
|
+
/**
|
|
28
|
+
* Makes a network call to request the token from the service
|
|
29
|
+
* @param request
|
|
30
|
+
* @param authority
|
|
31
|
+
*/
|
|
32
|
+
private executeTokenRequest;
|
|
33
|
+
/**
|
|
34
|
+
* generate the request to the server in the acceptable format
|
|
35
|
+
* @param request
|
|
36
|
+
*/
|
|
37
|
+
private createTokenRequestBody;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=ClientCredentialClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClientCredentialClient.d.ts","sourceRoot":"","sources":["../../src/client/ClientCredentialClient.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAM1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AACxE,OAAO,EAAE,6BAA6B,EAAE,MAAM,0CAA0C,CAAC;AAQzF,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAE/D;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,UAAU;IAElD,OAAO,CAAC,QAAQ,CAAW;IAC3B,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAoB;gBAE1C,aAAa,EAAE,mBAAmB,EAAE,gBAAgB,CAAC,EAAE,iBAAiB;IAKpF;;;OAGG;IACU,YAAY,CAAC,OAAO,EAAE,6BAA6B,GAAG,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;IAgBvG;;OAEG;YACW,6BAA6B;IA6B3C;;;OAGG;IACH,OAAO,CAAC,wBAAwB;IAmBhC;;;;OAIG;YACW,mBAAmB;IAkEjC;;;OAGG;IACH,OAAO,CAAC,sBAAsB;CAuCjC"}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/*! @azure/msal-common v0.0.1-alpha.0 2022-08-02 */
|
|
2
|
+
'use strict';
|
|
3
|
+
import { __extends, __awaiter, __generator } from '../_virtual/_tslib.js';
|
|
4
|
+
import { BaseClient } from './BaseClient.js';
|
|
5
|
+
import { RequestParameterBuilder } from '../request/RequestParameterBuilder.js';
|
|
6
|
+
import { ScopeSet } from '../request/ScopeSet.js';
|
|
7
|
+
import { Constants, CredentialType, GrantType, CacheOutcome, AuthenticationScheme } from '../utils/Constants.js';
|
|
8
|
+
import { ResponseHandler } from '../response/ResponseHandler.js';
|
|
9
|
+
import { TimeUtils } from '../utils/TimeUtils.js';
|
|
10
|
+
import { StringUtils } from '../utils/StringUtils.js';
|
|
11
|
+
import { ClientAuthError } from '../error/ClientAuthError.js';
|
|
12
|
+
|
|
13
|
+
/*
|
|
14
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
15
|
+
* Licensed under the MIT License.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* OAuth2.0 client credential grant
|
|
19
|
+
*/
|
|
20
|
+
var ClientCredentialClient = /** @class */ (function (_super) {
|
|
21
|
+
__extends(ClientCredentialClient, _super);
|
|
22
|
+
function ClientCredentialClient(configuration, appTokenProvider) {
|
|
23
|
+
var _this = _super.call(this, configuration) || this;
|
|
24
|
+
_this.appTokenProvider = appTokenProvider;
|
|
25
|
+
return _this;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Public API to acquire a token with ClientCredential Flow for Confidential clients
|
|
29
|
+
* @param request
|
|
30
|
+
*/
|
|
31
|
+
ClientCredentialClient.prototype.acquireToken = function (request) {
|
|
32
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
33
|
+
var cachedAuthenticationResult;
|
|
34
|
+
return __generator(this, function (_a) {
|
|
35
|
+
switch (_a.label) {
|
|
36
|
+
case 0:
|
|
37
|
+
this.scopeSet = new ScopeSet(request.scopes || []);
|
|
38
|
+
if (!request.skipCache) return [3 /*break*/, 2];
|
|
39
|
+
return [4 /*yield*/, this.executeTokenRequest(request, this.authority)];
|
|
40
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
41
|
+
case 2: return [4 /*yield*/, this.getCachedAuthenticationResult(request)];
|
|
42
|
+
case 3:
|
|
43
|
+
cachedAuthenticationResult = _a.sent();
|
|
44
|
+
if (!cachedAuthenticationResult) return [3 /*break*/, 4];
|
|
45
|
+
return [2 /*return*/, cachedAuthenticationResult];
|
|
46
|
+
case 4: return [4 /*yield*/, this.executeTokenRequest(request, this.authority)];
|
|
47
|
+
case 5: return [2 /*return*/, _a.sent()];
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* looks up cache if the tokens are cached already
|
|
54
|
+
*/
|
|
55
|
+
ClientCredentialClient.prototype.getCachedAuthenticationResult = function (request) {
|
|
56
|
+
var _a, _b;
|
|
57
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
58
|
+
var cachedAccessToken;
|
|
59
|
+
return __generator(this, function (_c) {
|
|
60
|
+
switch (_c.label) {
|
|
61
|
+
case 0:
|
|
62
|
+
cachedAccessToken = this.readAccessTokenFromCache();
|
|
63
|
+
if (!cachedAccessToken) {
|
|
64
|
+
(_a = this.serverTelemetryManager) === null || _a === void 0 ? void 0 : _a.setCacheOutcome(CacheOutcome.NO_CACHED_ACCESS_TOKEN);
|
|
65
|
+
return [2 /*return*/, null];
|
|
66
|
+
}
|
|
67
|
+
if (TimeUtils.isTokenExpired(cachedAccessToken.expiresOn, this.config.systemOptions.tokenRenewalOffsetSeconds)) {
|
|
68
|
+
(_b = this.serverTelemetryManager) === null || _b === void 0 ? void 0 : _b.setCacheOutcome(CacheOutcome.CACHED_ACCESS_TOKEN_EXPIRED);
|
|
69
|
+
return [2 /*return*/, null];
|
|
70
|
+
}
|
|
71
|
+
return [4 /*yield*/, ResponseHandler.generateAuthenticationResult(this.cryptoUtils, this.authority, {
|
|
72
|
+
account: null,
|
|
73
|
+
idToken: null,
|
|
74
|
+
accessToken: cachedAccessToken,
|
|
75
|
+
refreshToken: null,
|
|
76
|
+
appMetadata: null
|
|
77
|
+
}, true, request)];
|
|
78
|
+
case 1: return [2 /*return*/, _c.sent()];
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Reads access token from the cache
|
|
85
|
+
* TODO: Move this call to cacheManager instead
|
|
86
|
+
*/
|
|
87
|
+
ClientCredentialClient.prototype.readAccessTokenFromCache = function () {
|
|
88
|
+
var accessTokenFilter = {
|
|
89
|
+
homeAccountId: Constants.EMPTY_STRING,
|
|
90
|
+
environment: this.authority.canonicalAuthorityUrlComponents.HostNameAndPort,
|
|
91
|
+
credentialType: CredentialType.ACCESS_TOKEN,
|
|
92
|
+
clientId: this.config.authOptions.clientId,
|
|
93
|
+
realm: this.authority.tenant,
|
|
94
|
+
target: this.scopeSet.printScopesLowerCase()
|
|
95
|
+
};
|
|
96
|
+
var credentialCache = this.cacheManager.getCredentialsFilteredBy(accessTokenFilter);
|
|
97
|
+
var accessTokens = Object.keys(credentialCache.accessTokens).map(function (key) { return credentialCache.accessTokens[key]; });
|
|
98
|
+
if (accessTokens.length < 1) {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
else if (accessTokens.length > 1) {
|
|
102
|
+
throw ClientAuthError.createMultipleMatchingTokensInCacheError();
|
|
103
|
+
}
|
|
104
|
+
return accessTokens[0];
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* Makes a network call to request the token from the service
|
|
108
|
+
* @param request
|
|
109
|
+
* @param authority
|
|
110
|
+
*/
|
|
111
|
+
ClientCredentialClient.prototype.executeTokenRequest = function (request, authority) {
|
|
112
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
113
|
+
var serverTokenResponse, reqTimestamp, appTokenPropviderParameters, appTokenProviderResult, requestBody, headers, thumbprint, response, responseHandler, tokenResponse;
|
|
114
|
+
return __generator(this, function (_a) {
|
|
115
|
+
switch (_a.label) {
|
|
116
|
+
case 0:
|
|
117
|
+
if (!this.appTokenProvider) return [3 /*break*/, 2];
|
|
118
|
+
this.logger.info("Using appTokenProvider extensibility.");
|
|
119
|
+
appTokenPropviderParameters = {
|
|
120
|
+
correlationId: request.correlationId,
|
|
121
|
+
tenantId: this.config.authOptions.authority.tenant,
|
|
122
|
+
scopes: request.scopes,
|
|
123
|
+
claims: request.claims,
|
|
124
|
+
};
|
|
125
|
+
reqTimestamp = TimeUtils.nowSeconds();
|
|
126
|
+
return [4 /*yield*/, this.appTokenProvider(appTokenPropviderParameters)];
|
|
127
|
+
case 1:
|
|
128
|
+
appTokenProviderResult = _a.sent();
|
|
129
|
+
serverTokenResponse = {
|
|
130
|
+
access_token: appTokenProviderResult.accessToken,
|
|
131
|
+
expires_in: appTokenProviderResult.expiresInSeconds,
|
|
132
|
+
refresh_in: appTokenProviderResult.refreshInSeconds,
|
|
133
|
+
token_type: AuthenticationScheme.BEARER
|
|
134
|
+
};
|
|
135
|
+
return [3 /*break*/, 4];
|
|
136
|
+
case 2:
|
|
137
|
+
requestBody = this.createTokenRequestBody(request);
|
|
138
|
+
headers = this.createTokenRequestHeaders();
|
|
139
|
+
thumbprint = {
|
|
140
|
+
clientId: this.config.authOptions.clientId,
|
|
141
|
+
authority: request.authority,
|
|
142
|
+
scopes: request.scopes,
|
|
143
|
+
claims: request.claims,
|
|
144
|
+
authenticationScheme: request.authenticationScheme,
|
|
145
|
+
resourceRequestMethod: request.resourceRequestMethod,
|
|
146
|
+
resourceRequestUri: request.resourceRequestUri,
|
|
147
|
+
shrClaims: request.shrClaims,
|
|
148
|
+
sshKid: request.sshKid
|
|
149
|
+
};
|
|
150
|
+
reqTimestamp = TimeUtils.nowSeconds();
|
|
151
|
+
return [4 /*yield*/, this.executePostToTokenEndpoint(authority.tokenEndpoint, requestBody, headers, thumbprint)];
|
|
152
|
+
case 3:
|
|
153
|
+
response = _a.sent();
|
|
154
|
+
serverTokenResponse = response.body;
|
|
155
|
+
_a.label = 4;
|
|
156
|
+
case 4:
|
|
157
|
+
responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, this.config.serializableCache, this.config.persistencePlugin);
|
|
158
|
+
responseHandler.validateTokenResponse(serverTokenResponse);
|
|
159
|
+
return [4 /*yield*/, responseHandler.handleServerTokenResponse(serverTokenResponse, this.authority, reqTimestamp, request)];
|
|
160
|
+
case 5:
|
|
161
|
+
tokenResponse = _a.sent();
|
|
162
|
+
return [2 /*return*/, tokenResponse];
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
};
|
|
167
|
+
/**
|
|
168
|
+
* generate the request to the server in the acceptable format
|
|
169
|
+
* @param request
|
|
170
|
+
*/
|
|
171
|
+
ClientCredentialClient.prototype.createTokenRequestBody = function (request) {
|
|
172
|
+
var parameterBuilder = new RequestParameterBuilder();
|
|
173
|
+
parameterBuilder.addClientId(this.config.authOptions.clientId);
|
|
174
|
+
parameterBuilder.addScopes(request.scopes, false);
|
|
175
|
+
parameterBuilder.addGrantType(GrantType.CLIENT_CREDENTIALS_GRANT);
|
|
176
|
+
parameterBuilder.addLibraryInfo(this.config.libraryInfo);
|
|
177
|
+
parameterBuilder.addApplicationTelemetry(this.config.telemetry.application);
|
|
178
|
+
parameterBuilder.addThrottling();
|
|
179
|
+
if (this.serverTelemetryManager) {
|
|
180
|
+
parameterBuilder.addServerTelemetry(this.serverTelemetryManager);
|
|
181
|
+
}
|
|
182
|
+
var correlationId = request.correlationId || this.config.cryptoInterface.createNewGuid();
|
|
183
|
+
parameterBuilder.addCorrelationId(correlationId);
|
|
184
|
+
if (this.config.clientCredentials.clientSecret) {
|
|
185
|
+
parameterBuilder.addClientSecret(this.config.clientCredentials.clientSecret);
|
|
186
|
+
}
|
|
187
|
+
// Use clientAssertion from request, fallback to client assertion in base configuration
|
|
188
|
+
var clientAssertion = request.clientAssertion || this.config.clientCredentials.clientAssertion;
|
|
189
|
+
if (clientAssertion) {
|
|
190
|
+
parameterBuilder.addClientAssertion(clientAssertion.assertion);
|
|
191
|
+
parameterBuilder.addClientAssertionType(clientAssertion.assertionType);
|
|
192
|
+
}
|
|
193
|
+
if (!StringUtils.isEmptyObj(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {
|
|
194
|
+
parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);
|
|
195
|
+
}
|
|
196
|
+
return parameterBuilder.createQueryString();
|
|
197
|
+
};
|
|
198
|
+
return ClientCredentialClient;
|
|
199
|
+
}(BaseClient));
|
|
200
|
+
|
|
201
|
+
export { ClientCredentialClient };
|
|
202
|
+
//# sourceMappingURL=ClientCredentialClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClientCredentialClient.js","sources":["../../src/client/ClientCredentialClient.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ClientConfiguration } from \"../config/ClientConfiguration\";\nimport { BaseClient } from \"./BaseClient\";\nimport { Authority } from \"../authority/Authority\";\nimport { RequestParameterBuilder } from \"../request/RequestParameterBuilder\";\nimport { ScopeSet } from \"../request/ScopeSet\";\nimport { GrantType , CredentialType, CacheOutcome, Constants, AuthenticationScheme } from \"../utils/Constants\";\nimport { ResponseHandler } from \"../response/ResponseHandler\";\nimport { AuthenticationResult } from \"../response/AuthenticationResult\";\nimport { CommonClientCredentialRequest } from \"../request/CommonClientCredentialRequest\";\nimport { CredentialFilter, CredentialCache } from \"../cache/utils/CacheTypes\";\nimport { AccessTokenEntity } from \"../cache/entities/AccessTokenEntity\";\nimport { TimeUtils } from \"../utils/TimeUtils\";\nimport { StringUtils } from \"../utils/StringUtils\";\nimport { RequestThumbprint } from \"../network/RequestThumbprint\";\nimport { ClientAuthError } from \"../error/ClientAuthError\";\nimport { ServerAuthorizationTokenResponse } from \"../response/ServerAuthorizationTokenResponse\";\nimport { IAppTokenProvider } from \"../config/AppTokenProvider\";\n\n/**\n * OAuth2.0 client credential grant\n */\nexport class ClientCredentialClient extends BaseClient {\n\n private scopeSet: ScopeSet;\n private readonly appTokenProvider?: IAppTokenProvider;\n\n constructor(configuration: ClientConfiguration, appTokenProvider?: IAppTokenProvider) {\n super(configuration);\n this.appTokenProvider = appTokenProvider;\n }\n\n /**\n * Public API to acquire a token with ClientCredential Flow for Confidential clients\n * @param request\n */\n public async acquireToken(request: CommonClientCredentialRequest): Promise<AuthenticationResult | null> {\n\n this.scopeSet = new ScopeSet(request.scopes || []);\n\n if (request.skipCache) {\n return await this.executeTokenRequest(request, this.authority);\n }\n\n const cachedAuthenticationResult = await this.getCachedAuthenticationResult(request);\n if (cachedAuthenticationResult) {\n return cachedAuthenticationResult;\n } else {\n return await this.executeTokenRequest(request, this.authority);\n }\n }\n\n /**\n * looks up cache if the tokens are cached already\n */\n private async getCachedAuthenticationResult(request: CommonClientCredentialRequest): Promise<AuthenticationResult | null> {\n \n const cachedAccessToken = this.readAccessTokenFromCache();\n\n if (!cachedAccessToken) {\n this.serverTelemetryManager?.setCacheOutcome(CacheOutcome.NO_CACHED_ACCESS_TOKEN);\n return null;\n }\n\n if (TimeUtils.isTokenExpired(cachedAccessToken.expiresOn, this.config.systemOptions.tokenRenewalOffsetSeconds)) {\n this.serverTelemetryManager?.setCacheOutcome(CacheOutcome.CACHED_ACCESS_TOKEN_EXPIRED);\n return null;\n }\n\n return await ResponseHandler.generateAuthenticationResult(\n this.cryptoUtils,\n this.authority,\n {\n account: null,\n idToken: null,\n accessToken: cachedAccessToken,\n refreshToken: null,\n appMetadata: null\n },\n true,\n request\n );\n }\n\n /**\n * Reads access token from the cache\n * TODO: Move this call to cacheManager instead\n */\n private readAccessTokenFromCache(): AccessTokenEntity | null {\n const accessTokenFilter: CredentialFilter = {\n homeAccountId: Constants.EMPTY_STRING,\n environment: this.authority.canonicalAuthorityUrlComponents.HostNameAndPort,\n credentialType: CredentialType.ACCESS_TOKEN,\n clientId: this.config.authOptions.clientId,\n realm: this.authority.tenant,\n target: this.scopeSet.printScopesLowerCase()\n };\n const credentialCache: CredentialCache = this.cacheManager.getCredentialsFilteredBy(accessTokenFilter);\n const accessTokens = Object.keys(credentialCache.accessTokens).map(key => credentialCache.accessTokens[key]);\n if (accessTokens.length < 1) {\n return null;\n } else if (accessTokens.length > 1) {\n throw ClientAuthError.createMultipleMatchingTokensInCacheError();\n }\n return accessTokens[0] as AccessTokenEntity;\n }\n\n /**\n * Makes a network call to request the token from the service\n * @param request\n * @param authority\n */\n private async executeTokenRequest(request: CommonClientCredentialRequest, authority: Authority)\n : Promise<AuthenticationResult | null> {\n \n let serverTokenResponse: ServerAuthorizationTokenResponse;\n let reqTimestamp: number;\n\n if (this.appTokenProvider) {\n this.logger.info(\"Using appTokenProvider extensibility.\");\n\n const appTokenPropviderParameters = {\n correlationId: request.correlationId,\n tenantId: this.config.authOptions.authority.tenant,\n scopes: request.scopes,\n claims: request.claims,\n };\n\n reqTimestamp = TimeUtils.nowSeconds();\n const appTokenProviderResult = await this.appTokenProvider(appTokenPropviderParameters);\n\n serverTokenResponse = {\n access_token: appTokenProviderResult.accessToken, \n expires_in: appTokenProviderResult.expiresInSeconds,\n refresh_in: appTokenProviderResult.refreshInSeconds,\n token_type : AuthenticationScheme.BEARER\n };\n } else {\n const requestBody = this.createTokenRequestBody(request);\n const headers: Record<string, string> = this.createTokenRequestHeaders();\n const thumbprint: RequestThumbprint = {\n clientId: this.config.authOptions.clientId,\n authority: request.authority,\n scopes: request.scopes,\n claims: request.claims,\n authenticationScheme: request.authenticationScheme,\n resourceRequestMethod: request.resourceRequestMethod,\n resourceRequestUri: request.resourceRequestUri,\n shrClaims: request.shrClaims,\n sshKid: request.sshKid\n };\n \n reqTimestamp = TimeUtils.nowSeconds();\n const response = await this.executePostToTokenEndpoint(authority.tokenEndpoint, requestBody, headers, thumbprint);\n serverTokenResponse = response.body;\n }\n\n const responseHandler = new ResponseHandler(\n this.config.authOptions.clientId,\n this.cacheManager,\n this.cryptoUtils,\n this.logger,\n this.config.serializableCache,\n this.config.persistencePlugin\n );\n\n responseHandler.validateTokenResponse(serverTokenResponse);\n \n const tokenResponse = await responseHandler.handleServerTokenResponse(\n serverTokenResponse,\n this.authority,\n reqTimestamp,\n request\n );\n\n return tokenResponse;\n }\n\n /**\n * generate the request to the server in the acceptable format\n * @param request\n */\n private createTokenRequestBody(request: CommonClientCredentialRequest): string {\n const parameterBuilder = new RequestParameterBuilder();\n\n parameterBuilder.addClientId(this.config.authOptions.clientId);\n\n parameterBuilder.addScopes(request.scopes, false);\n\n parameterBuilder.addGrantType(GrantType.CLIENT_CREDENTIALS_GRANT);\n\n parameterBuilder.addLibraryInfo(this.config.libraryInfo);\n parameterBuilder.addApplicationTelemetry(this.config.telemetry.application);\n\n parameterBuilder.addThrottling();\n \n if (this.serverTelemetryManager) {\n parameterBuilder.addServerTelemetry(this.serverTelemetryManager);\n }\n\n const correlationId = request.correlationId || this.config.cryptoInterface.createNewGuid();\n parameterBuilder.addCorrelationId(correlationId);\n\n if (this.config.clientCredentials.clientSecret) {\n parameterBuilder.addClientSecret(this.config.clientCredentials.clientSecret);\n }\n\n // Use clientAssertion from request, fallback to client assertion in base configuration\n const clientAssertion = request.clientAssertion || this.config.clientCredentials.clientAssertion;\n\n if (clientAssertion) {\n parameterBuilder.addClientAssertion(clientAssertion.assertion);\n parameterBuilder.addClientAssertionType(clientAssertion.assertionType);\n }\n\n if (!StringUtils.isEmptyObj(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {\n parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);\n }\n\n return parameterBuilder.createQueryString();\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;AAGG;AAoBH;;AAEG;AACH,IAAA,sBAAA,kBAAA,UAAA,MAAA,EAAA;IAA4C,SAAU,CAAA,sBAAA,EAAA,MAAA,CAAA,CAAA;IAKlD,SAAY,sBAAA,CAAA,aAAkC,EAAE,gBAAoC,EAAA;QAApF,IACI,KAAA,GAAA,MAAA,CAAA,IAAA,CAAA,IAAA,EAAM,aAAa,CAAC,IAEvB,IAAA,C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seClient";
|
|
2
|
+
import { CommonDeviceCodeRequest } from "../request/CommonDeviceCodeRequest";
|
|
3
|
+
import { ClientConfiguration } from "../config/ClientConfiguration";
|
|
4
|
+
import { AuthenticationResult } from "../response/AuthenticationResult";
|
|
5
|
+
/**
|
|
6
|
+
* OAuth2.0 Device code client
|
|
7
|
+
*/
|
|
8
|
+
export declare class DeviceCodeClient extends BaseClient {
|
|
9
|
+
constructor(configuration: ClientConfiguration);
|
|
10
|
+
/**
|
|
11
|
+
* Gets device code from device code endpoint, calls back to with device code response, and
|
|
12
|
+
* polls token endpoint to exchange device code for tokens
|
|
13
|
+
* @param request
|
|
14
|
+
*/
|
|
15
|
+
acquireToken(request: CommonDeviceCodeRequest): Promise<AuthenticationResult | null>;
|
|
16
|
+
/**
|
|
17
|
+
* Creates device code request and executes http GET
|
|
18
|
+
* @param request
|
|
19
|
+
*/
|
|
20
|
+
private getDeviceCode;
|
|
21
|
+
/**
|
|
22
|
+
* Executes POST request to device code endpoint
|
|
23
|
+
* @param deviceCodeEndpoint
|
|
24
|
+
* @param queryString
|
|
25
|
+
* @param headers
|
|
26
|
+
*/
|
|
27
|
+
private executePostRequestToDeviceCodeEndpoint;
|
|
28
|
+
/**
|
|
29
|
+
* Create device code endpoint query parameters and returns string
|
|
30
|
+
*/
|
|
31
|
+
private createQueryString;
|
|
32
|
+
/**
|
|
33
|
+
* Breaks the polling with specific conditions.
|
|
34
|
+
* @param request CommonDeviceCodeRequest
|
|
35
|
+
* @param deviceCodeResponse DeviceCodeResponse
|
|
36
|
+
*/
|
|
37
|
+
private continuePolling;
|
|
38
|
+
/**
|
|
39
|
+
* Creates token request with device code response and polls token endpoint at interval set by the device code
|
|
40
|
+
* response
|
|
41
|
+
* @param request
|
|
42
|
+
* @param deviceCodeResponse
|
|
43
|
+
*/
|
|
44
|
+
private acquireTokenWithDeviceCode;
|
|
45
|
+
/**
|
|
46
|
+
* Creates query parameters and converts to string.
|
|
47
|
+
* @param request
|
|
48
|
+
* @param deviceCodeResponse
|
|
49
|
+
*/
|
|
50
|
+
private createTokenRequestBody;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=DeviceCodeClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DeviceCodeClient.d.ts","sourceRoot":"","sources":["../../src/client/DeviceCodeClient.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAI7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAIpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAKxE;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,UAAU;gBAEhC,aAAa,EAAE,mBAAmB;IAI9C;;;;OAIG;IACU,YAAY,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;IA2BjG;;;OAGG;YACW,aAAa;IAkB3B;;;;;OAKG;YACW,sCAAsC;IAkCpD;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAczB;;;;OAIG;IACH,OAAO,CAAC,eAAe;IAqBvB;;;;;OAKG;YACW,0BAA0B;IA0DxC;;;;OAIG;IACH,OAAO,CAAC,sBAAsB;CAwBjC"}
|