@azure/msal-common 13.0.0 → 14.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +62 -62
- package/dist/account/AccountInfo.d.ts +2 -2
- package/dist/account/AccountInfo.d.ts.map +1 -1
- package/dist/account/AuthToken.d.ts.map +1 -1
- package/dist/account/AuthToken.js +13 -14
- package/dist/account/AuthToken.js.map +1 -1
- package/dist/account/CcsCredential.d.ts +1 -1
- package/dist/account/CcsCredential.d.ts.map +1 -1
- package/dist/account/CcsCredential.js +1 -1
- package/dist/account/CcsCredential.js.map +1 -1
- package/dist/account/ClientCredentials.d.ts +2 -2
- package/dist/account/ClientCredentials.d.ts.map +1 -1
- package/dist/account/ClientInfo.d.ts +1 -1
- package/dist/account/ClientInfo.d.ts.map +1 -1
- package/dist/account/ClientInfo.js +6 -4
- package/dist/account/ClientInfo.js.map +1 -1
- package/dist/account/DecodedAuthToken.d.ts.map +1 -1
- package/dist/account/TokenClaims.d.ts +1 -1
- package/dist/account/TokenClaims.d.ts.map +1 -1
- package/dist/authority/Authority.d.ts.map +1 -1
- package/dist/authority/Authority.js +464 -546
- package/dist/authority/Authority.js.map +1 -1
- package/dist/authority/AuthorityFactory.d.ts.map +1 -1
- package/dist/authority/AuthorityFactory.js +19 -34
- package/dist/authority/AuthorityFactory.js.map +1 -1
- package/dist/authority/AuthorityMetadata.d.ts.map +1 -1
- package/dist/authority/AuthorityMetadata.js +873 -4
- package/dist/authority/AuthorityMetadata.js.map +1 -1
- package/dist/authority/AuthorityOptions.d.ts +1 -1
- package/dist/authority/AuthorityOptions.d.ts.map +1 -1
- package/dist/authority/AuthorityOptions.js +1 -1
- package/dist/authority/AuthorityOptions.js.map +1 -1
- package/dist/authority/AuthorityType.js +1 -1
- package/dist/authority/AuthorityType.js.map +1 -1
- package/dist/authority/AzureRegion.d.ts +1 -1
- package/dist/authority/AzureRegion.d.ts.map +1 -1
- package/dist/authority/AzureRegionConfiguration.d.ts +1 -1
- package/dist/authority/AzureRegionConfiguration.d.ts.map +1 -1
- package/dist/authority/CloudDiscoveryMetadata.d.ts +1 -1
- package/dist/authority/CloudDiscoveryMetadata.d.ts.map +1 -1
- package/dist/authority/CloudInstanceDiscoveryErrorResponse.d.ts +1 -1
- package/dist/authority/CloudInstanceDiscoveryErrorResponse.d.ts.map +1 -1
- package/dist/authority/CloudInstanceDiscoveryErrorResponse.js +1 -1
- package/dist/authority/CloudInstanceDiscoveryErrorResponse.js.map +1 -1
- package/dist/authority/CloudInstanceDiscoveryResponse.d.ts +1 -1
- package/dist/authority/CloudInstanceDiscoveryResponse.d.ts.map +1 -1
- package/dist/authority/CloudInstanceDiscoveryResponse.js +1 -1
- package/dist/authority/CloudInstanceDiscoveryResponse.js.map +1 -1
- package/dist/authority/ImdsOptions.d.ts +1 -1
- package/dist/authority/ImdsOptions.d.ts.map +1 -1
- package/dist/authority/OpenIdConfigResponse.d.ts +1 -1
- package/dist/authority/OpenIdConfigResponse.d.ts.map +1 -1
- package/dist/authority/OpenIdConfigResponse.js +1 -1
- package/dist/authority/OpenIdConfigResponse.js.map +1 -1
- package/dist/authority/ProtocolMode.js +1 -1
- package/dist/authority/ProtocolMode.js.map +1 -1
- package/dist/authority/RegionDiscovery.d.ts.map +1 -1
- package/dist/authority/RegionDiscovery.js +85 -107
- package/dist/authority/RegionDiscovery.js.map +1 -1
- package/dist/authority/RegionDiscoveryMetadata.d.ts +1 -1
- package/dist/authority/RegionDiscoveryMetadata.d.ts.map +1 -1
- package/dist/broker/nativeBroker/INativeBrokerPlugin.d.ts.map +1 -1
- package/dist/cache/CacheManager.d.ts.map +1 -1
- package/dist/cache/CacheManager.js +440 -475
- package/dist/cache/CacheManager.js.map +1 -1
- package/dist/cache/entities/AccessTokenEntity.d.ts.map +1 -1
- package/dist/cache/entities/AccessTokenEntity.js +21 -22
- package/dist/cache/entities/AccessTokenEntity.js.map +1 -1
- package/dist/cache/entities/AccountEntity.d.ts.map +1 -1
- package/dist/cache/entities/AccountEntity.js +78 -66
- package/dist/cache/entities/AccountEntity.js.map +1 -1
- package/dist/cache/entities/AppMetadataEntity.d.ts.map +1 -1
- package/dist/cache/entities/AppMetadataEntity.js +16 -17
- package/dist/cache/entities/AppMetadataEntity.js.map +1 -1
- package/dist/cache/entities/AuthorityMetadataEntity.d.ts.map +1 -1
- package/dist/cache/entities/AuthorityMetadataEntity.js +22 -19
- package/dist/cache/entities/AuthorityMetadataEntity.js.map +1 -1
- package/dist/cache/entities/CacheRecord.d.ts.map +1 -1
- package/dist/cache/entities/CacheRecord.js +4 -5
- package/dist/cache/entities/CacheRecord.js.map +1 -1
- package/dist/cache/entities/CredentialEntity.d.ts.map +1 -1
- package/dist/cache/entities/CredentialEntity.js +35 -34
- package/dist/cache/entities/CredentialEntity.js.map +1 -1
- package/dist/cache/entities/IdTokenEntity.d.ts.map +1 -1
- package/dist/cache/entities/IdTokenEntity.js +8 -14
- package/dist/cache/entities/IdTokenEntity.js.map +1 -1
- package/dist/cache/entities/RefreshTokenEntity.d.ts.map +1 -1
- package/dist/cache/entities/RefreshTokenEntity.js +8 -14
- package/dist/cache/entities/RefreshTokenEntity.js.map +1 -1
- package/dist/cache/entities/ServerTelemetryEntity.d.ts.map +1 -1
- package/dist/cache/entities/ServerTelemetryEntity.js +8 -9
- package/dist/cache/entities/ServerTelemetryEntity.js.map +1 -1
- package/dist/cache/entities/ThrottlingEntity.js +9 -11
- package/dist/cache/entities/ThrottlingEntity.js.map +1 -1
- package/dist/cache/interface/ICacheManager.d.ts.map +1 -1
- package/dist/cache/persistence/TokenCacheContext.d.ts.map +1 -1
- package/dist/cache/persistence/TokenCacheContext.js +16 -25
- package/dist/cache/persistence/TokenCacheContext.js.map +1 -1
- package/dist/cache/utils/CacheTypes.d.ts +11 -11
- package/dist/cache/utils/CacheTypes.d.ts.map +1 -1
- package/dist/client/AuthorizationCodeClient.d.ts.map +1 -1
- package/dist/client/AuthorizationCodeClient.js +341 -384
- package/dist/client/AuthorizationCodeClient.js.map +1 -1
- package/dist/client/BaseClient.d.ts.map +1 -1
- package/dist/client/BaseClient.js +27 -35
- package/dist/client/BaseClient.js.map +1 -1
- package/dist/client/RefreshTokenClient.d.ts.map +1 -1
- package/dist/client/RefreshTokenClient.js +208 -241
- package/dist/client/RefreshTokenClient.js.map +1 -1
- package/dist/client/SilentFlowClient.d.ts.map +1 -1
- package/dist/client/SilentFlowClient.js +77 -105
- package/dist/client/SilentFlowClient.js.map +1 -1
- package/dist/config/AppTokenProvider.d.ts +2 -2
- package/dist/config/AppTokenProvider.d.ts.map +1 -1
- package/dist/config/ClientConfiguration.d.ts +9 -9
- package/dist/config/ClientConfiguration.d.ts.map +1 -1
- package/dist/config/ClientConfiguration.js +40 -43
- package/dist/config/ClientConfiguration.js.map +1 -1
- package/dist/crypto/ICrypto.d.ts +2 -2
- package/dist/crypto/ICrypto.d.ts.map +1 -1
- package/dist/crypto/ICrypto.js +27 -58
- package/dist/crypto/ICrypto.js.map +1 -1
- package/dist/crypto/JoseHeader.d.ts +1 -1
- package/dist/crypto/JoseHeader.d.ts.map +1 -1
- package/dist/crypto/JoseHeader.js +8 -9
- package/dist/crypto/JoseHeader.js.map +1 -1
- package/dist/crypto/PopTokenGenerator.d.ts +2 -2
- package/dist/crypto/PopTokenGenerator.d.ts.map +1 -1
- package/dist/crypto/PopTokenGenerator.js +47 -71
- package/dist/crypto/PopTokenGenerator.js.map +1 -1
- package/dist/crypto/SignedHttpRequest.d.ts +1 -1
- package/dist/crypto/SignedHttpRequest.d.ts.map +1 -1
- package/dist/error/AuthError.d.ts.map +1 -1
- package/dist/error/AuthError.js +25 -28
- package/dist/error/AuthError.js.map +1 -1
- package/dist/error/ClientAuthError.d.ts +8 -0
- package/dist/error/ClientAuthError.d.ts.map +1 -1
- package/dist/error/ClientAuthError.js +187 -181
- package/dist/error/ClientAuthError.js.map +1 -1
- package/dist/error/ClientConfigurationError.d.ts.map +1 -1
- package/dist/error/ClientConfigurationError.js +82 -86
- package/dist/error/ClientConfigurationError.js.map +1 -1
- package/dist/error/InteractionRequiredAuthError.d.ts.map +1 -1
- package/dist/error/InteractionRequiredAuthError.js +36 -35
- package/dist/error/InteractionRequiredAuthError.js.map +1 -1
- package/dist/error/JoseHeaderError.d.ts.map +1 -1
- package/dist/error/JoseHeaderError.js +14 -18
- package/dist/error/JoseHeaderError.js.map +1 -1
- package/dist/error/ServerError.d.ts.map +1 -1
- package/dist/error/ServerError.js +7 -11
- package/dist/error/ServerError.js.map +1 -1
- package/dist/index.cjs.js +4221 -4476
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +20 -21
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -6
- package/dist/index.js.map +1 -1
- package/dist/logger/Logger.d.ts +1 -1
- package/dist/logger/Logger.d.ts.map +1 -1
- package/dist/logger/Logger.js +70 -60
- package/dist/logger/Logger.js.map +1 -1
- package/dist/network/INetworkModule.d.ts +1 -1
- package/dist/network/INetworkModule.d.ts.map +1 -1
- package/dist/network/INetworkModule.js +7 -7
- package/dist/network/INetworkModule.js.map +1 -1
- package/dist/network/NetworkManager.d.ts +4 -3
- package/dist/network/NetworkManager.d.ts.map +1 -1
- package/dist/network/NetworkManager.js +21 -35
- package/dist/network/NetworkManager.js.map +1 -1
- package/dist/network/RequestThumbprint.d.ts +1 -1
- package/dist/network/RequestThumbprint.d.ts.map +1 -1
- package/dist/network/ThrottlingUtils.d.ts.map +1 -1
- package/dist/network/ThrottlingUtils.js +37 -36
- package/dist/network/ThrottlingUtils.js.map +1 -1
- package/dist/packageMetadata.d.ts +1 -1
- package/dist/packageMetadata.d.ts.map +1 -1
- package/dist/packageMetadata.js +3 -3
- package/dist/packageMetadata.js.map +1 -1
- package/dist/request/AuthenticationHeaderParser.d.ts.map +1 -1
- package/dist/request/AuthenticationHeaderParser.js +17 -18
- package/dist/request/AuthenticationHeaderParser.js.map +1 -1
- package/dist/request/BaseAuthRequest.d.ts +1 -1
- package/dist/request/BaseAuthRequest.d.ts.map +1 -1
- package/dist/request/CommonAuthorizationCodeRequest.d.ts +1 -1
- package/dist/request/CommonAuthorizationCodeRequest.d.ts.map +1 -1
- package/dist/request/CommonAuthorizationUrlRequest.d.ts +1 -1
- package/dist/request/CommonAuthorizationUrlRequest.d.ts.map +1 -1
- package/dist/request/CommonClientCredentialRequest.d.ts +1 -1
- package/dist/request/CommonClientCredentialRequest.d.ts.map +1 -1
- package/dist/request/CommonDeviceCodeRequest.d.ts +1 -1
- package/dist/request/CommonDeviceCodeRequest.d.ts.map +1 -1
- package/dist/request/CommonEndSessionRequest.d.ts +1 -1
- package/dist/request/CommonEndSessionRequest.d.ts.map +1 -1
- package/dist/request/CommonOnBehalfOfRequest.d.ts +1 -1
- package/dist/request/CommonOnBehalfOfRequest.d.ts.map +1 -1
- package/dist/request/CommonRefreshTokenRequest.d.ts +1 -1
- package/dist/request/CommonRefreshTokenRequest.d.ts.map +1 -1
- package/dist/request/CommonSilentFlowRequest.d.ts +1 -1
- package/dist/request/CommonSilentFlowRequest.d.ts.map +1 -1
- package/dist/request/CommonUsernamePasswordRequest.d.ts +1 -1
- package/dist/request/CommonUsernamePasswordRequest.d.ts.map +1 -1
- package/dist/request/NativeRequest.d.ts +1 -1
- package/dist/request/NativeRequest.d.ts.map +1 -1
- package/dist/request/NativeSignOutRequest.d.ts +1 -1
- package/dist/request/NativeSignOutRequest.d.ts.map +1 -1
- package/dist/request/RequestParameterBuilder.d.ts.map +1 -1
- package/dist/request/RequestParameterBuilder.js +111 -113
- package/dist/request/RequestParameterBuilder.js.map +1 -1
- package/dist/request/RequestValidator.d.ts.map +1 -1
- package/dist/request/RequestValidator.js +23 -28
- package/dist/request/RequestValidator.js.map +1 -1
- package/dist/request/ScopeSet.d.ts.map +1 -1
- package/dist/request/ScopeSet.js +70 -70
- package/dist/request/ScopeSet.js.map +1 -1
- package/dist/response/AuthenticationResult.d.ts +1 -1
- package/dist/response/AuthenticationResult.d.ts.map +1 -1
- package/dist/response/AuthorizationCodePayload.d.ts +1 -1
- package/dist/response/AuthorizationCodePayload.d.ts.map +1 -1
- package/dist/response/DeviceCodeResponse.d.ts +2 -2
- package/dist/response/DeviceCodeResponse.d.ts.map +1 -1
- package/dist/response/ExternalTokenResponse.d.ts +1 -1
- package/dist/response/ExternalTokenResponse.d.ts.map +1 -1
- package/dist/response/IMDSBadResponse.d.ts +1 -1
- package/dist/response/IMDSBadResponse.d.ts.map +1 -1
- package/dist/response/ResponseHandler.d.ts.map +1 -1
- package/dist/response/ResponseHandler.js +195 -180
- package/dist/response/ResponseHandler.js.map +1 -1
- package/dist/response/ServerAuthorizationCodeResponse.d.ts +1 -1
- package/dist/response/ServerAuthorizationCodeResponse.d.ts.map +1 -1
- package/dist/response/ServerAuthorizationTokenResponse.d.ts +1 -1
- package/dist/response/ServerAuthorizationTokenResponse.d.ts.map +1 -1
- package/dist/telemetry/performance/IPerformanceClient.d.ts +3 -4
- package/dist/telemetry/performance/IPerformanceClient.d.ts.map +1 -1
- package/dist/telemetry/performance/PerformanceClient.d.ts +2 -10
- package/dist/telemetry/performance/PerformanceClient.d.ts.map +1 -1
- package/dist/telemetry/performance/PerformanceClient.js +134 -129
- package/dist/telemetry/performance/PerformanceClient.js.map +1 -1
- package/dist/telemetry/performance/PerformanceEvent.d.ts +4 -4
- package/dist/telemetry/performance/PerformanceEvent.d.ts.map +1 -1
- package/dist/telemetry/performance/PerformanceEvent.js +2 -2
- package/dist/telemetry/performance/PerformanceEvent.js.map +1 -1
- package/dist/telemetry/performance/StubPerformanceClient.d.ts +5 -3
- package/dist/telemetry/performance/StubPerformanceClient.d.ts.map +1 -1
- package/dist/telemetry/performance/StubPerformanceClient.js +23 -32
- package/dist/telemetry/performance/StubPerformanceClient.js.map +1 -1
- package/dist/telemetry/server/ServerTelemetryManager.d.ts +1 -2
- package/dist/telemetry/server/ServerTelemetryManager.d.ts.map +1 -1
- package/dist/telemetry/server/ServerTelemetryManager.js +106 -68
- package/dist/telemetry/server/ServerTelemetryManager.js.map +1 -1
- package/dist/telemetry/server/ServerTelemetryRequest.d.ts +1 -1
- package/dist/telemetry/server/ServerTelemetryRequest.d.ts.map +1 -1
- package/dist/url/UrlString.d.ts.map +1 -1
- package/dist/url/UrlString.js +85 -74
- package/dist/url/UrlString.js.map +1 -1
- package/dist/utils/Constants.d.ts.map +1 -1
- package/dist/utils/Constants.js +28 -27
- package/dist/utils/Constants.js.map +1 -1
- package/dist/utils/MsalTypes.d.ts +1 -1
- package/dist/utils/MsalTypes.d.ts.map +1 -1
- package/dist/utils/ProtocolUtils.d.ts +2 -2
- package/dist/utils/ProtocolUtils.d.ts.map +1 -1
- package/dist/utils/ProtocolUtils.js +27 -24
- package/dist/utils/ProtocolUtils.js.map +1 -1
- package/dist/utils/StringUtils.d.ts.map +1 -1
- package/dist/utils/StringUtils.js +44 -42
- package/dist/utils/StringUtils.js.map +1 -1
- package/dist/utils/TimeUtils.d.ts.map +1 -1
- package/dist/utils/TimeUtils.js +16 -19
- package/dist/utils/TimeUtils.js.map +1 -1
- package/package.json +79 -76
- package/dist/_virtual/_tslib.js +0 -90
- package/dist/_virtual/_tslib.js.map +0 -1
- package/dist/client/ClientCredentialClient.d.ts +0 -38
- package/dist/client/ClientCredentialClient.d.ts.map +0 -1
- package/dist/client/ClientCredentialClient.js +0 -203
- package/dist/client/ClientCredentialClient.js.map +0 -1
- package/dist/client/DeviceCodeClient.d.ts +0 -57
- package/dist/client/DeviceCodeClient.d.ts.map +0 -1
- package/dist/client/DeviceCodeClient.js +0 -250
- package/dist/client/DeviceCodeClient.js.map +0 -1
- package/dist/client/OnBehalfOfClient.d.ts +0 -51
- package/dist/client/OnBehalfOfClient.d.ts.map +0 -1
- package/dist/client/OnBehalfOfClient.js +0 -248
- package/dist/client/OnBehalfOfClient.js.map +0 -1
- package/dist/client/UsernamePasswordClient.d.ts +0 -29
- package/dist/client/UsernamePasswordClient.d.ts.map +0 -1
- package/dist/client/UsernamePasswordClient.js +0 -129
- package/dist/client/UsernamePasswordClient.js.map +0 -1
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { BaseClient } from "./BaseClient";
|
|
2
|
-
import { ClientConfiguration } from "../config/ClientConfiguration";
|
|
3
|
-
import { CommonUsernamePasswordRequest } from "../request/CommonUsernamePasswordRequest";
|
|
4
|
-
import { AuthenticationResult } from "../response/AuthenticationResult";
|
|
5
|
-
/**
|
|
6
|
-
* Oauth2.0 Password grant client
|
|
7
|
-
* Note: We are only supporting public clients for password grant and for purely testing purposes
|
|
8
|
-
*/
|
|
9
|
-
export declare class UsernamePasswordClient extends BaseClient {
|
|
10
|
-
constructor(configuration: ClientConfiguration);
|
|
11
|
-
/**
|
|
12
|
-
* API to acquire a token by passing the username and password to the service in exchage of credentials
|
|
13
|
-
* password_grant
|
|
14
|
-
* @param request
|
|
15
|
-
*/
|
|
16
|
-
acquireToken(request: CommonUsernamePasswordRequest): Promise<AuthenticationResult | null>;
|
|
17
|
-
/**
|
|
18
|
-
* Executes POST request to token endpoint
|
|
19
|
-
* @param authority
|
|
20
|
-
* @param request
|
|
21
|
-
*/
|
|
22
|
-
private executeTokenRequest;
|
|
23
|
-
/**
|
|
24
|
-
* Generates a map for all the params to be sent to the service
|
|
25
|
-
* @param request
|
|
26
|
-
*/
|
|
27
|
-
private createTokenRequestBody;
|
|
28
|
-
}
|
|
29
|
-
//# sourceMappingURL=UsernamePasswordClient.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"UsernamePasswordClient.d.ts","sourceRoot":"","sources":["../../src/client/UsernamePasswordClient.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,6BAA6B,EAAE,MAAM,0CAA0C,CAAC;AACzF,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAaxE;;;GAGG;AACH,qBAAa,sBAAuB,SAAQ,UAAU;gBAEtC,aAAa,EAAE,mBAAmB;IAI9C;;;;OAIG;IACG,YAAY,CAAC,OAAO,EAAE,6BAA6B,GAAG,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;IA6BhG;;;;OAIG;YACW,mBAAmB;IAuBjC;;;OAGG;IACH,OAAO,CAAC,sBAAsB;CA6CjC"}
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
/*! @azure/msal-common v13.0.0 2023-05-01 */
|
|
2
|
-
'use strict';
|
|
3
|
-
import { __extends, __awaiter, __generator } from '../_virtual/_tslib.js';
|
|
4
|
-
import { BaseClient } from './BaseClient.js';
|
|
5
|
-
import { ResponseHandler } from '../response/ResponseHandler.js';
|
|
6
|
-
import { RequestParameterBuilder } from '../request/RequestParameterBuilder.js';
|
|
7
|
-
import { GrantType, HeaderNames } from '../utils/Constants.js';
|
|
8
|
-
import { StringUtils } from '../utils/StringUtils.js';
|
|
9
|
-
import { TimeUtils } from '../utils/TimeUtils.js';
|
|
10
|
-
import { CcsCredentialType } from '../account/CcsCredential.js';
|
|
11
|
-
import { UrlString } from '../url/UrlString.js';
|
|
12
|
-
|
|
13
|
-
/*
|
|
14
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
15
|
-
* Licensed under the MIT License.
|
|
16
|
-
*/
|
|
17
|
-
/**
|
|
18
|
-
* Oauth2.0 Password grant client
|
|
19
|
-
* Note: We are only supporting public clients for password grant and for purely testing purposes
|
|
20
|
-
*/
|
|
21
|
-
var UsernamePasswordClient = /** @class */ (function (_super) {
|
|
22
|
-
__extends(UsernamePasswordClient, _super);
|
|
23
|
-
function UsernamePasswordClient(configuration) {
|
|
24
|
-
return _super.call(this, configuration) || this;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* API to acquire a token by passing the username and password to the service in exchage of credentials
|
|
28
|
-
* password_grant
|
|
29
|
-
* @param request
|
|
30
|
-
*/
|
|
31
|
-
UsernamePasswordClient.prototype.acquireToken = function (request) {
|
|
32
|
-
var _a, _b;
|
|
33
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
34
|
-
var atsMeasurement, reqTimestamp, response, httpVerToken, responseHandler, tokenResponse;
|
|
35
|
-
return __generator(this, function (_c) {
|
|
36
|
-
switch (_c.label) {
|
|
37
|
-
case 0:
|
|
38
|
-
atsMeasurement = (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.startMeasurement("UsernamePasswordClientAcquireToken", request.correlationId);
|
|
39
|
-
this.logger.info("in acquireToken call in username-password client");
|
|
40
|
-
reqTimestamp = TimeUtils.nowSeconds();
|
|
41
|
-
return [4 /*yield*/, this.executeTokenRequest(this.authority, request)];
|
|
42
|
-
case 1:
|
|
43
|
-
response = _c.sent();
|
|
44
|
-
httpVerToken = (_b = response.headers) === null || _b === void 0 ? void 0 : _b[HeaderNames.X_MS_HTTP_VERSION];
|
|
45
|
-
atsMeasurement === null || atsMeasurement === void 0 ? void 0 : atsMeasurement.addStaticFields({
|
|
46
|
-
httpVerToken: httpVerToken
|
|
47
|
-
});
|
|
48
|
-
responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, this.config.serializableCache, this.config.persistencePlugin);
|
|
49
|
-
// Validate response. This function throws a server error if an error is returned by the server.
|
|
50
|
-
responseHandler.validateTokenResponse(response.body);
|
|
51
|
-
tokenResponse = responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request);
|
|
52
|
-
return [2 /*return*/, tokenResponse];
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
};
|
|
57
|
-
/**
|
|
58
|
-
* Executes POST request to token endpoint
|
|
59
|
-
* @param authority
|
|
60
|
-
* @param request
|
|
61
|
-
*/
|
|
62
|
-
UsernamePasswordClient.prototype.executeTokenRequest = function (authority, request) {
|
|
63
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
64
|
-
var queryParametersString, endpoint, requestBody, headers, thumbprint;
|
|
65
|
-
return __generator(this, function (_a) {
|
|
66
|
-
queryParametersString = this.createTokenQueryParameters(request);
|
|
67
|
-
endpoint = UrlString.appendQueryString(authority.tokenEndpoint, queryParametersString);
|
|
68
|
-
requestBody = this.createTokenRequestBody(request);
|
|
69
|
-
headers = this.createTokenRequestHeaders({
|
|
70
|
-
credential: request.username,
|
|
71
|
-
type: CcsCredentialType.UPN
|
|
72
|
-
});
|
|
73
|
-
thumbprint = {
|
|
74
|
-
clientId: this.config.authOptions.clientId,
|
|
75
|
-
authority: authority.canonicalAuthority,
|
|
76
|
-
scopes: request.scopes,
|
|
77
|
-
claims: request.claims,
|
|
78
|
-
authenticationScheme: request.authenticationScheme,
|
|
79
|
-
resourceRequestMethod: request.resourceRequestMethod,
|
|
80
|
-
resourceRequestUri: request.resourceRequestUri,
|
|
81
|
-
shrClaims: request.shrClaims,
|
|
82
|
-
sshKid: request.sshKid
|
|
83
|
-
};
|
|
84
|
-
return [2 /*return*/, this.executePostToTokenEndpoint(endpoint, requestBody, headers, thumbprint)];
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
};
|
|
88
|
-
/**
|
|
89
|
-
* Generates a map for all the params to be sent to the service
|
|
90
|
-
* @param request
|
|
91
|
-
*/
|
|
92
|
-
UsernamePasswordClient.prototype.createTokenRequestBody = function (request) {
|
|
93
|
-
var parameterBuilder = new RequestParameterBuilder();
|
|
94
|
-
parameterBuilder.addClientId(this.config.authOptions.clientId);
|
|
95
|
-
parameterBuilder.addUsername(request.username);
|
|
96
|
-
parameterBuilder.addPassword(request.password);
|
|
97
|
-
parameterBuilder.addScopes(request.scopes);
|
|
98
|
-
parameterBuilder.addResponseTypeForTokenAndIdToken();
|
|
99
|
-
parameterBuilder.addGrantType(GrantType.RESOURCE_OWNER_PASSWORD_GRANT);
|
|
100
|
-
parameterBuilder.addClientInfo();
|
|
101
|
-
parameterBuilder.addLibraryInfo(this.config.libraryInfo);
|
|
102
|
-
parameterBuilder.addApplicationTelemetry(this.config.telemetry.application);
|
|
103
|
-
parameterBuilder.addThrottling();
|
|
104
|
-
if (this.serverTelemetryManager) {
|
|
105
|
-
parameterBuilder.addServerTelemetry(this.serverTelemetryManager);
|
|
106
|
-
}
|
|
107
|
-
var correlationId = request.correlationId || this.config.cryptoInterface.createNewGuid();
|
|
108
|
-
parameterBuilder.addCorrelationId(correlationId);
|
|
109
|
-
if (this.config.clientCredentials.clientSecret) {
|
|
110
|
-
parameterBuilder.addClientSecret(this.config.clientCredentials.clientSecret);
|
|
111
|
-
}
|
|
112
|
-
if (this.config.clientCredentials.clientAssertion) {
|
|
113
|
-
var clientAssertion = this.config.clientCredentials.clientAssertion;
|
|
114
|
-
parameterBuilder.addClientAssertion(clientAssertion.assertion);
|
|
115
|
-
parameterBuilder.addClientAssertionType(clientAssertion.assertionType);
|
|
116
|
-
}
|
|
117
|
-
if (!StringUtils.isEmptyObj(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {
|
|
118
|
-
parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);
|
|
119
|
-
}
|
|
120
|
-
if (this.config.systemOptions.preventCorsPreflight && request.username) {
|
|
121
|
-
parameterBuilder.addCcsUpn(request.username);
|
|
122
|
-
}
|
|
123
|
-
return parameterBuilder.createQueryString();
|
|
124
|
-
};
|
|
125
|
-
return UsernamePasswordClient;
|
|
126
|
-
}(BaseClient));
|
|
127
|
-
|
|
128
|
-
export { UsernamePasswordClient };
|
|
129
|
-
//# sourceMappingURL=UsernamePasswordClient.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"UsernamePasswordClient.js","sources":["../../src/client/UsernamePasswordClient.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { BaseClient } from \"./BaseClient\";\nimport { ClientConfiguration } from \"../config/ClientConfiguration\";\nimport { CommonUsernamePasswordRequest } from \"../request/CommonUsernamePasswordRequest\";\nimport { AuthenticationResult } from \"../response/AuthenticationResult\";\nimport { ResponseHandler } from \"../response/ResponseHandler\";\nimport { Authority } from \"../authority/Authority\";\nimport { NetworkResponse } from \"../network/NetworkManager\";\nimport { ServerAuthorizationTokenResponse } from \"../response/ServerAuthorizationTokenResponse\";\nimport { RequestParameterBuilder } from \"../request/RequestParameterBuilder\";\nimport { GrantType, HeaderNames } from \"../utils/Constants\";\nimport { StringUtils } from \"../utils/StringUtils\";\nimport { RequestThumbprint } from \"../network/RequestThumbprint\";\nimport { TimeUtils } from \"../utils/TimeUtils\";\nimport { CcsCredentialType } from \"../account/CcsCredential\";\nimport { UrlString } from \"../url/UrlString\";\n\n/**\n * Oauth2.0 Password grant client\n * Note: We are only supporting public clients for password grant and for purely testing purposes\n */\nexport class UsernamePasswordClient extends BaseClient {\n\n constructor(configuration: ClientConfiguration) {\n super(configuration);\n }\n\n /**\n * API to acquire a token by passing the username and password to the service in exchage of credentials\n * password_grant\n * @param request\n */\n async acquireToken(request: CommonUsernamePasswordRequest): Promise<AuthenticationResult | null> {\n // @ts-ignore\n const atsMeasurement = this.performanceClient?.startMeasurement(\"UsernamePasswordClientAcquireToken\", request.correlationId);\n this.logger.info(\"in acquireToken call in username-password client\");\n\n const reqTimestamp = TimeUtils.nowSeconds();\n const response = await this.executeTokenRequest(this.authority, request);\n\n const httpVerToken = response.headers?.[HeaderNames.X_MS_HTTP_VERSION];\n atsMeasurement?.addStaticFields({\n httpVerToken\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 // Validate response. This function throws a server error if an error is returned by the server.\n responseHandler.validateTokenResponse(response.body);\n const tokenResponse = responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request);\n\n return tokenResponse;\n }\n\n /**\n * Executes POST request to token endpoint\n * @param authority\n * @param request\n */\n private async executeTokenRequest(authority: Authority, request: CommonUsernamePasswordRequest): Promise<NetworkResponse<ServerAuthorizationTokenResponse>> {\n const queryParametersString = this.createTokenQueryParameters(request);\n const endpoint = UrlString.appendQueryString(authority.tokenEndpoint, queryParametersString);\n const requestBody = this.createTokenRequestBody(request);\n const headers: Record<string, string> = this.createTokenRequestHeaders({\n credential: request.username,\n type: CcsCredentialType.UPN\n });\n const thumbprint: RequestThumbprint = {\n clientId: this.config.authOptions.clientId,\n authority: authority.canonicalAuthority,\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 return this.executePostToTokenEndpoint(endpoint, requestBody, headers, thumbprint);\n }\n\n /**\n * Generates a map for all the params to be sent to the service\n * @param request\n */\n private createTokenRequestBody(request: CommonUsernamePasswordRequest): string {\n const parameterBuilder = new RequestParameterBuilder();\n\n parameterBuilder.addClientId(this.config.authOptions.clientId);\n parameterBuilder.addUsername(request.username);\n parameterBuilder.addPassword(request.password);\n\n parameterBuilder.addScopes(request.scopes);\n\n parameterBuilder.addResponseTypeForTokenAndIdToken();\n\n parameterBuilder.addGrantType(GrantType.RESOURCE_OWNER_PASSWORD_GRANT);\n parameterBuilder.addClientInfo();\n\n parameterBuilder.addLibraryInfo(this.config.libraryInfo);\n parameterBuilder.addApplicationTelemetry(this.config.telemetry.application);\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 if (this.config.clientCredentials.clientAssertion) {\n const clientAssertion = this.config.clientCredentials.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 if (this.config.systemOptions.preventCorsPreflight && request.username) {\n parameterBuilder.addCcsUpn(request.username);\n }\n\n return parameterBuilder.createQueryString();\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;AAGG;AAkBH;;;AAGG;AACH,IAAA,sBAAA,kBAAA,UAAA,MAAA,EAAA;IAA4C,SAAU,CAAA,sBAAA,EAAA,MAAA,CAAA,CAAA;AAElD,IAAA,SAAA,sBAAA,CAAY,aAAkC,EAAA;AAC1C,QAAA,OAAA,MAAA,CAAA,IAAA,CAAA,IAAA,EAAM,aAAa,CAAC,IAAA,IAAA,CAAA;KACvB;AAED;;;;AAIG;IACG,sBAAY,CAAA,SAAA,CAAA,YAAA,GAAlB,UAAmB,OAAsC,EAAA;;;;;;;AAE/C,wBAAA,cAAc,GAAG,CAAA,EAAA,GAAA,IAAI,CAAC,iBAAiB,MAAE,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,gBAAgB,CAAC,oCAAoC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;AAC7H,wBAAA,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,kDAAkD,CAAC,CAAC;AAE/D,wBAAA,YAAY,GAAG,SAAS,CAAC,UAAU,EAAE,CAAC;wBAC3B,OAAM,CAAA,CAAA,YAAA,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA,CAAA;;AAAlE,wBAAA,QAAQ,GAAG,EAAuD,CAAA,IAAA,EAAA,CAAA;wBAElE,YAAY,GAAA,CAAA,EAAA,GAAG,QAAQ,CAAC,OAAO,0CAAG,WAAW,CAAC,iBAAiB,CAAC,CAAC;AAC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