Skip to content

Commit

Permalink
- Move node clients from msal-common to msal-node.
Browse files Browse the repository at this point in the history
  • Loading branch information
konstantin-msft committed Mar 13, 2023
1 parent 1e3e660 commit 946a743
Show file tree
Hide file tree
Showing 9 changed files with 143 additions and 147 deletions.
4 changes: 0 additions & 4 deletions lib/msal-common/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,8 @@
*/

export { AuthorizationCodeClient} from "./client/AuthorizationCodeClient";
export { DeviceCodeClient } from "./client/DeviceCodeClient";
export { RefreshTokenClient } from "./client/RefreshTokenClient";
export { ClientCredentialClient } from "./client/ClientCredentialClient";
export { OnBehalfOfClient } from "./client/OnBehalfOfClient";
export { SilentFlowClient } from "./client/SilentFlowClient";
export { UsernamePasswordClient } from "./client/UsernamePasswordClient";
export { AuthOptions, SystemOptions, LoggerOptions, DEFAULT_SYSTEM_OPTIONS, AzureCloudOptions, ApplicationTelemetry } from "./config/ClientConfiguration";
export { IAppTokenProvider, AppTokenProviderParameters, AppTokenProviderResult } from "./config/AppTokenProvider";
export { ClientConfiguration } from "./config/ClientConfiguration";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@
* Licensed under the MIT License.
*/

import { ClientConfiguration } from "../config/ClientConfiguration";
import { BaseClient } from "./BaseClient";
import { Authority } from "../authority/Authority";
import { RequestParameterBuilder } from "../request/RequestParameterBuilder";
import { ScopeSet } from "../request/ScopeSet";
import { GrantType , CredentialType, CacheOutcome, Constants, AuthenticationScheme } from "../utils/Constants";
import { ResponseHandler } from "../response/ResponseHandler";
import { AuthenticationResult } from "../response/AuthenticationResult";
import { CommonClientCredentialRequest } from "../request/CommonClientCredentialRequest";
import { CredentialFilter, CredentialCache } from "../cache/utils/CacheTypes";
import { AccessTokenEntity } from "../cache/entities/AccessTokenEntity";
import { TimeUtils } from "../utils/TimeUtils";
import { StringUtils } from "../utils/StringUtils";
import { RequestThumbprint } from "../network/RequestThumbprint";
import { ClientAuthError } from "../error/ClientAuthError";
import { ServerAuthorizationTokenResponse } from "../response/ServerAuthorizationTokenResponse";
import { IAppTokenProvider } from "../config/AppTokenProvider";
import { UrlString } from "../url/UrlString";
import { ClientConfiguration } from "@azure/msal-common/src/config/ClientConfiguration";
import { BaseClient } from "@azure/msal-common/src/client/BaseClient";
import { Authority } from "@azure/msal-common/src/authority/Authority";
import { RequestParameterBuilder } from "@azure/msal-common/src/request/RequestParameterBuilder";
import { ScopeSet } from "@azure/msal-common/src/request/ScopeSet";
import { GrantType , CredentialType, CacheOutcome, Constants, AuthenticationScheme } from "@azure/msal-common/src/utils/Constants";
import { ResponseHandler } from "@azure/msal-common/src/response/ResponseHandler";
import { AuthenticationResult } from "@azure/msal-common/src/response/AuthenticationResult";
import { CommonClientCredentialRequest } from "@azure/msal-common/src/request/CommonClientCredentialRequest";
import { CredentialFilter, CredentialCache } from "@azure/msal-common/src/cache/utils/CacheTypes";
import { AccessTokenEntity } from "@azure/msal-common/src/cache/entities/AccessTokenEntity";
import { TimeUtils } from "@azure/msal-common/src/utils/TimeUtils";
import { StringUtils } from "@azure/msal-common/src/utils/StringUtils";
import { RequestThumbprint } from "@azure/msal-common/src/network/RequestThumbprint";
import { ClientAuthError } from "@azure/msal-common/src/error/ClientAuthError";
import { ServerAuthorizationTokenResponse } from "@azure/msal-common/src/response/ServerAuthorizationTokenResponse";
import { IAppTokenProvider } from "@azure/msal-common/src/config/AppTokenProvider";
import { UrlString } from "@azure/msal-common/src/url/UrlString";

/**
* OAuth2.0 client credential grant
Expand Down Expand Up @@ -59,7 +59,7 @@ export class ClientCredentialClient extends BaseClient {
* looks up cache if the tokens are cached already
*/
private async getCachedAuthenticationResult(request: CommonClientCredentialRequest): Promise<AuthenticationResult | null> {

const cachedAccessToken = this.readAccessTokenFromCache();

if (!cachedAccessToken) {
Expand Down Expand Up @@ -117,7 +117,7 @@ export class ClientCredentialClient extends BaseClient {
*/
private async executeTokenRequest(request: CommonClientCredentialRequest, authority: Authority)
: Promise<AuthenticationResult | null> {

let serverTokenResponse: ServerAuthorizationTokenResponse;
let reqTimestamp: number;

Expand All @@ -135,7 +135,7 @@ export class ClientCredentialClient extends BaseClient {
const appTokenProviderResult = await this.appTokenProvider(appTokenPropviderParameters);

serverTokenResponse = {
access_token: appTokenProviderResult.accessToken,
access_token: appTokenProviderResult.accessToken,
expires_in: appTokenProviderResult.expiresInSeconds,
refresh_in: appTokenProviderResult.refreshInSeconds,
token_type : AuthenticationScheme.BEARER
Expand All @@ -156,7 +156,7 @@ export class ClientCredentialClient extends BaseClient {
shrClaims: request.shrClaims,
sshKid: request.sshKid
};

reqTimestamp = TimeUtils.nowSeconds();
const response = await this.executePostToTokenEndpoint(endpoint, requestBody, headers, thumbprint);
serverTokenResponse = response.body;
Expand All @@ -172,7 +172,7 @@ export class ClientCredentialClient extends BaseClient {
);

responseHandler.validateTokenResponse(serverTokenResponse);

const tokenResponse = await responseHandler.handleServerTokenResponse(
serverTokenResponse,
this.authority,
Expand Down Expand Up @@ -200,7 +200,7 @@ export class ClientCredentialClient extends BaseClient {
parameterBuilder.addApplicationTelemetry(this.config.telemetry.application);

parameterBuilder.addThrottling();

if (this.serverTelemetryManager) {
parameterBuilder.addServerTelemetry(this.serverTelemetryManager);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@
* Licensed under the MIT License.
*/

import { DeviceCodeResponse, ServerDeviceCodeResponse } from "../response/DeviceCodeResponse";
import { BaseClient } from "./BaseClient";
import { CommonDeviceCodeRequest } from "../request/CommonDeviceCodeRequest";
import { ClientAuthError } from "../error/ClientAuthError";
import { RequestParameterBuilder } from "../request/RequestParameterBuilder";
import { Constants, GrantType } from "../utils/Constants";
import { ClientConfiguration } from "../config/ClientConfiguration";
import { TimeUtils } from "../utils/TimeUtils";
import { ServerAuthorizationTokenResponse } from "../response/ServerAuthorizationTokenResponse";
import { ResponseHandler } from "../response/ResponseHandler";
import { AuthenticationResult } from "../response/AuthenticationResult";
import { StringUtils } from "../utils/StringUtils";
import { RequestThumbprint } from "../network/RequestThumbprint";
import { ServerError } from "../error/ServerError";
import { UrlString } from "../url/UrlString";
import { DeviceCodeResponse, ServerDeviceCodeResponse } from "@azure/msal-common/src/response/DeviceCodeResponse";
import { BaseClient } from "@azure/msal-common/src/client/BaseClient";
import { CommonDeviceCodeRequest } from "@azure/msal-common/src/request/CommonDeviceCodeRequest";
import { ClientAuthError } from "@azure/msal-common/src/error/ClientAuthError";
import { RequestParameterBuilder } from "@azure/msal-common/src/request/RequestParameterBuilder";
import { Constants, GrantType } from "@azure/msal-common/src/utils/Constants";
import { ClientConfiguration } from "@azure/msal-common/src/config/ClientConfiguration";
import { TimeUtils } from "@azure/msal-common/src/utils/TimeUtils";
import { ServerAuthorizationTokenResponse } from "@azure/msal-common/src/response/ServerAuthorizationTokenResponse";
import { ResponseHandler } from "@azure/msal-common/src/response/ResponseHandler";
import { AuthenticationResult } from "@azure/msal-common/src/response/AuthenticationResult";
import { StringUtils } from "@azure/msal-common/src/utils/StringUtils";
import { RequestThumbprint } from "@azure/msal-common/src/network/RequestThumbprint";
import { ServerError } from "@azure/msal-common/src/error/ServerError";
import { UrlString } from "@azure/msal-common/src/url/UrlString";

/**
* OAuth2.0 Device code client
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@
* Licensed under the MIT License.
*/

import { ClientConfiguration } from "../config/ClientConfiguration";
import { BaseClient } from "./BaseClient";
import { Authority } from "../authority/Authority";
import { RequestParameterBuilder } from "../request/RequestParameterBuilder";
import { ScopeSet } from "../request/ScopeSet";
import { GrantType, AADServerParamKeys , CredentialType, Constants, CacheOutcome, AuthenticationScheme } from "../utils/Constants";
import { ResponseHandler } from "../response/ResponseHandler";
import { AuthenticationResult } from "../response/AuthenticationResult";
import { CommonOnBehalfOfRequest } from "../request/CommonOnBehalfOfRequest";
import { TimeUtils } from "../utils/TimeUtils";
import { CredentialFilter, CredentialCache } from "../cache/utils/CacheTypes";
import { AccessTokenEntity } from "../cache/entities/AccessTokenEntity";
import { IdTokenEntity } from "../cache/entities/IdTokenEntity";
import { AccountEntity } from "../cache/entities/AccountEntity";
import { AuthToken } from "../account/AuthToken";
import { ClientAuthError } from "../error/ClientAuthError";
import { RequestThumbprint } from "../network/RequestThumbprint";
import { AccountInfo } from "../account/AccountInfo";
import { UrlString } from "../url/UrlString";
import { ClientConfiguration } from "@azure/msal-common/src/config/ClientConfiguration";
import { BaseClient } from "@azure/msal-common/src/client/BaseClient";
import { Authority } from "@azure/msal-common/src/authority/Authority";
import { RequestParameterBuilder } from "@azure/msal-common/src/request/RequestParameterBuilder";
import { ScopeSet } from "@azure/msal-common/src/request/ScopeSet";
import { GrantType, AADServerParamKeys , CredentialType, Constants, CacheOutcome, AuthenticationScheme } from "@azure/msal-common/src/utils/Constants";
import { ResponseHandler } from "@azure/msal-common/src/response/ResponseHandler";
import { AuthenticationResult } from "@azure/msal-common/src/response/AuthenticationResult";
import { CommonOnBehalfOfRequest } from "@azure/msal-common/src/request/CommonOnBehalfOfRequest";
import { TimeUtils } from "@azure/msal-common/src/utils/TimeUtils";
import { CredentialFilter, CredentialCache } from "@azure/msal-common/src/cache/utils/CacheTypes";
import { AccessTokenEntity } from "@azure/msal-common/src/cache/entities/AccessTokenEntity";
import { IdTokenEntity } from "@azure/msal-common/src/cache/entities/IdTokenEntity";
import { AccountEntity } from "@azure/msal-common/src/cache/entities/AccountEntity";
import { AuthToken } from "@azure/msal-common/src/account/AuthToken";
import { ClientAuthError } from "@azure/msal-common/src/error/ClientAuthError";
import { RequestThumbprint } from "@azure/msal-common/src/network/RequestThumbprint";
import { AccountInfo } from "@azure/msal-common/src/account/AccountInfo";
import { UrlString } from "@azure/msal-common/src/url/UrlString";

/**
* On-Behalf-Of client
Expand Down Expand Up @@ -272,7 +272,7 @@ export class OnBehalfOfClient extends BaseClient {
if (request.claims || (this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0)) {
parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);
}

return parameterBuilder.createQueryString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@
* Licensed under the MIT License.
*/

import { BaseClient } from "./BaseClient";
import { ClientConfiguration } from "../config/ClientConfiguration";
import { CommonUsernamePasswordRequest } from "../request/CommonUsernamePasswordRequest";
import { AuthenticationResult } from "../response/AuthenticationResult";
import { ResponseHandler } from "../response/ResponseHandler";
import { Authority } from "../authority/Authority";
import { NetworkResponse } from "../network/NetworkManager";
import { ServerAuthorizationTokenResponse } from "../response/ServerAuthorizationTokenResponse";
import { RequestParameterBuilder } from "../request/RequestParameterBuilder";
import { GrantType, HeaderNames } from "../utils/Constants";
import { StringUtils } from "../utils/StringUtils";
import { RequestThumbprint } from "../network/RequestThumbprint";
import { TimeUtils } from "../utils/TimeUtils";
import { CcsCredentialType } from "../account/CcsCredential";
import { UrlString } from "../url/UrlString";
import { BaseClient } from "@azure/msal-common/src/client/BaseClient";
import { ClientConfiguration } from "@azure/msal-common/src/config/ClientConfiguration";
import { CommonUsernamePasswordRequest } from "@azure/msal-common/src/request/CommonUsernamePasswordRequest";
import { AuthenticationResult } from "@azure/msal-common/src/response/AuthenticationResult";
import { ResponseHandler } from "@azure/msal-common/src/response/ResponseHandler";
import { Authority } from "@azure/msal-common/src/authority/Authority";
import { NetworkResponse } from "@azure/msal-common/src/network/NetworkManager";
import { ServerAuthorizationTokenResponse } from "@azure/msal-common/src/response/ServerAuthorizationTokenResponse";
import { RequestParameterBuilder } from "@azure/msal-common/src/request/RequestParameterBuilder";
import { GrantType, HeaderNames } from "@azure/msal-common/src/utils/Constants";
import { StringUtils } from "@azure/msal-common/src/utils/StringUtils";
import { RequestThumbprint } from "@azure/msal-common/src/network/RequestThumbprint";
import { TimeUtils } from "@azure/msal-common/src/utils/TimeUtils";
import { CcsCredentialType } from "@azure/msal-common/src/account/CcsCredential";
import { UrlString } from "@azure/msal-common/src/url/UrlString";

/**
* Oauth2.0 Password grant client
Expand Down Expand Up @@ -46,7 +46,7 @@ export class UsernamePasswordClient extends BaseClient {
atsMeasurement?.addStaticFields({
httpVerToken
});

const responseHandler = new ResponseHandler(
this.config.authOptions.clientId,
this.cacheManager,
Expand Down
Loading

0 comments on commit 946a743

Please sign in to comment.