diff --git a/lib/msal-common/src/index.ts b/lib/msal-common/src/index.ts index b3e37cef81..89cd2b140c 100644 --- a/lib/msal-common/src/index.ts +++ b/lib/msal-common/src/index.ts @@ -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"; diff --git a/lib/msal-common/src/client/ClientCredentialClient.ts b/lib/msal-node/src/client/ClientCredentialClient.ts similarity index 84% rename from lib/msal-common/src/client/ClientCredentialClient.ts rename to lib/msal-node/src/client/ClientCredentialClient.ts index 8859c7cbe6..488e9b95c8 100644 --- a/lib/msal-common/src/client/ClientCredentialClient.ts +++ b/lib/msal-node/src/client/ClientCredentialClient.ts @@ -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 @@ -59,7 +59,7 @@ export class ClientCredentialClient extends BaseClient { * looks up cache if the tokens are cached already */ private async getCachedAuthenticationResult(request: CommonClientCredentialRequest): Promise { - + const cachedAccessToken = this.readAccessTokenFromCache(); if (!cachedAccessToken) { @@ -117,7 +117,7 @@ export class ClientCredentialClient extends BaseClient { */ private async executeTokenRequest(request: CommonClientCredentialRequest, authority: Authority) : Promise { - + let serverTokenResponse: ServerAuthorizationTokenResponse; let reqTimestamp: number; @@ -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 @@ -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; @@ -172,7 +172,7 @@ export class ClientCredentialClient extends BaseClient { ); responseHandler.validateTokenResponse(serverTokenResponse); - + const tokenResponse = await responseHandler.handleServerTokenResponse( serverTokenResponse, this.authority, @@ -200,7 +200,7 @@ export class ClientCredentialClient extends BaseClient { parameterBuilder.addApplicationTelemetry(this.config.telemetry.application); parameterBuilder.addThrottling(); - + if (this.serverTelemetryManager) { parameterBuilder.addServerTelemetry(this.serverTelemetryManager); } diff --git a/lib/msal-common/src/client/DeviceCodeClient.ts b/lib/msal-node/src/client/DeviceCodeClient.ts similarity index 89% rename from lib/msal-common/src/client/DeviceCodeClient.ts rename to lib/msal-node/src/client/DeviceCodeClient.ts index d6f5b59487..f9df968550 100644 --- a/lib/msal-common/src/client/DeviceCodeClient.ts +++ b/lib/msal-node/src/client/DeviceCodeClient.ts @@ -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 diff --git a/lib/msal-common/src/client/OnBehalfOfClient.ts b/lib/msal-node/src/client/OnBehalfOfClient.ts similarity index 87% rename from lib/msal-common/src/client/OnBehalfOfClient.ts rename to lib/msal-node/src/client/OnBehalfOfClient.ts index 906b4d627c..63ea4a35bc 100644 --- a/lib/msal-common/src/client/OnBehalfOfClient.ts +++ b/lib/msal-node/src/client/OnBehalfOfClient.ts @@ -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 @@ -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(); } } diff --git a/lib/msal-common/src/client/UsernamePasswordClient.ts b/lib/msal-node/src/client/UsernamePasswordClient.ts similarity index 80% rename from lib/msal-common/src/client/UsernamePasswordClient.ts rename to lib/msal-node/src/client/UsernamePasswordClient.ts index bc8b93b48e..5dc6992eee 100644 --- a/lib/msal-common/src/client/UsernamePasswordClient.ts +++ b/lib/msal-node/src/client/UsernamePasswordClient.ts @@ -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 @@ -46,7 +46,7 @@ export class UsernamePasswordClient extends BaseClient { atsMeasurement?.addStaticFields({ httpVerToken }); - + const responseHandler = new ResponseHandler( this.config.authOptions.clientId, this.cacheManager, diff --git a/lib/msal-common/test/client/ClientCredentialClient.spec.ts b/lib/msal-node/test/client/ClientCredentialClient.spec.ts similarity index 96% rename from lib/msal-common/test/client/ClientCredentialClient.spec.ts rename to lib/msal-node/test/client/ClientCredentialClient.spec.ts index 138d236164..de94db1cb4 100644 --- a/lib/msal-common/test/client/ClientCredentialClient.spec.ts +++ b/lib/msal-node/test/client/ClientCredentialClient.spec.ts @@ -9,22 +9,22 @@ import { DSTS_CONFIDENTIAL_CLIENT_AUTHENTICATION_RESULT, AUTHENTICATION_RESULT_DEFAULT_SCOPES, ID_TOKEN_CLAIMS -} from "../test_kit/StringConstants"; -import { BaseClient } from "../../src/client/BaseClient"; -import { AADServerParamKeys, GrantType, Constants, AuthenticationScheme, ThrottlingConstants } from "../../src/utils/Constants"; -import { ClientTestUtils, mockCrypto } from "./ClientTestUtils"; -import { Authority } from "../../src/authority/Authority"; +} from "@azure/msal-common/test/test_kit/StringConstants"; +import { BaseClient } from "@azure/msal-common/src/client/BaseClient"; +import { AADServerParamKeys, GrantType, Constants, AuthenticationScheme, ThrottlingConstants } from "@azure/msal-common/src/utils/Constants"; +import { ClientTestUtils, mockCrypto } from "@azure/msal-common/test/client/ClientTestUtils"; +import { Authority } from "@azure/msal-common/src/authority/Authority"; import { ClientCredentialClient } from "../../src/client/ClientCredentialClient"; -import { CommonClientCredentialRequest } from "../../src/request/CommonClientCredentialRequest"; +import { CommonClientCredentialRequest } from "@azure/msal-common/src/request/CommonClientCredentialRequest"; import { UsernamePasswordClient } from "../../src/client/UsernamePasswordClient"; -import { CommonUsernamePasswordRequest } from "../../src/request/CommonUsernamePasswordRequest"; -import { AccessTokenEntity } from "../../src/cache/entities/AccessTokenEntity" -import { TimeUtils } from "../../src/utils/TimeUtils"; -import { CredentialCache } from "../../src/cache/utils/CacheTypes"; -import { CacheManager } from "../../src/cache/CacheManager"; -import { ClientAuthError } from "../../src/error/ClientAuthError"; -import { AuthenticationResult } from "../../src/response/AuthenticationResult"; -import { AppTokenProviderResult, AuthToken, ClientConfiguration, IAppTokenProvider, InteractionRequiredAuthError } from "../../src"; +import { CommonUsernamePasswordRequest } from "@azure/msal-common/src/request/CommonUsernamePasswordRequest"; +import { AccessTokenEntity } from "@azure/msal-common/src/cache/entities/AccessTokenEntity" +import { TimeUtils } from "@azure/msal-common/src/utils/TimeUtils"; +import { CredentialCache } from "@azure/msal-common/src/cache/utils/CacheTypes"; +import { CacheManager } from "@azure/msal-common/src/cache/CacheManager"; +import { ClientAuthError } from "@azure/msal-common/src/error/ClientAuthError"; +import { AuthenticationResult } from "@azure/msal-common/src/response/AuthenticationResult"; +import { AppTokenProviderResult, AuthToken, ClientConfiguration, IAppTokenProvider, InteractionRequiredAuthError } from "@azure/msal-common/src"; describe("ClientCredentialClient unit tests", () => { let config: ClientConfiguration; @@ -47,7 +47,7 @@ describe("ClientCredentialClient unit tests", () => { expect(client instanceof BaseClient).toBe(true); }); }); - + it("acquires a token", async () => { sinon.stub(Authority.prototype, "getEndpointMetadataFromNetwork").resolves(DEFAULT_OPENID_CONFIG_RESPONSE.body); sinon.stub(ClientCredentialClient.prototype, "executePostToTokenEndpoint").resolves(CONFIDENTIAL_CLIENT_AUTHENTICATION_RESULT); @@ -110,7 +110,7 @@ describe("ClientCredentialClient unit tests", () => { // Catch errors thrown after the function call this test is testing }); }); - + it("acquireToken's interactionRequiredAuthError error contains claims", async () => { const errorResponse = { error: "interaction_required", @@ -153,7 +153,7 @@ describe("ClientCredentialClient unit tests", () => { it("Multiple access tokens would match, but one of them has a Home Account ID of \"\"", async () => { sinon.stub(Authority.prototype, "getEndpointMetadataFromNetwork").resolves(DEFAULT_OPENID_CONFIG_RESPONSE.body); sinon.stub(ClientCredentialClient.prototype, "executePostToTokenEndpoint").resolves(CONFIDENTIAL_CLIENT_AUTHENTICATION_RESULT); - + const authenticationScopes = AUTHENTICATION_RESULT_DEFAULT_SCOPES; authenticationScopes.body.scope = "https://graph.microsoft.com/.default"; sinon.stub(UsernamePasswordClient.prototype, "executePostToTokenEndpoint").resolves(authenticationScopes); @@ -441,7 +441,7 @@ describe("ClientCredentialClient unit tests", () => { const expectedAtEntity: AccessTokenEntity = AccessTokenEntity.createAccessTokenEntity( "", "login.microsoftonline.com", "an_access_token", config.authOptions.clientId, TEST_CONFIG.TENANT, TEST_CONFIG.DEFAULT_GRAPH_SCOPE.toString(), 4600, 4600, mockCrypto, undefined, AuthenticationScheme.BEARER); - + sinon.stub(ClientCredentialClient.prototype, "readAccessTokenFromCache").returns(expectedAtEntity); sinon.stub(TimeUtils, "isTokenExpired").returns(false); @@ -492,16 +492,16 @@ describe("ClientCredentialClient unit tests", () => { it("Multiple access tokens matched, exception thrown", async () => { sinon.stub(Authority.prototype, "getEndpointMetadataFromNetwork").resolves(DEFAULT_OPENID_CONFIG_RESPONSE.body); - + // mock access token const mockedAtEntity: AccessTokenEntity = AccessTokenEntity.createAccessTokenEntity( "", "login.microsoftonline.com", "an_access_token", config.authOptions.clientId, TEST_CONFIG.TENANT, TEST_CONFIG.DEFAULT_GRAPH_SCOPE.toString(), 4600, 4600, mockCrypto, undefined, AuthenticationScheme.BEARER, TEST_TOKENS.ACCESS_TOKEN); - + const mockedAtEntity2: AccessTokenEntity = AccessTokenEntity.createAccessTokenEntity( "", "login.microsoftonline.com", "an_access_token", config.authOptions.clientId, TEST_CONFIG.TENANT, TEST_CONFIG.DEFAULT_GRAPH_SCOPE.toString(), 4600, 4600, mockCrypto, undefined, AuthenticationScheme.BEARER, TEST_TOKENS.ACCESS_TOKEN); - + const mockedCredentialCache: CredentialCache = { - accessTokens: { + accessTokens: { "key1": mockedAtEntity, "key2": mockedAtEntity2 }, @@ -539,20 +539,20 @@ describe("ClientCredentialClient unit tests", () => { let callbackedCalledCount = 0; const appTokenProvider: IAppTokenProvider = (appTokenProviderParameters) => { - + callbackedCalledCount++; expect(appTokenProviderParameters.scopes).toEqual(expectedScopes); expect(appTokenProviderParameters.tenantId).toEqual("common"); expect(appTokenProviderParameters.correlationId).toEqual(TEST_CONFIG.CORRELATION_ID); expect(appTokenProviderParameters.claims).toBeUndefined(); - + return new Promise( - (resolve) => resolve(appTokenProviderResult)); + (resolve) => resolve(appTokenProviderResult)); }; - + // client credentials not needed - config.clientCredentials = undefined; + config.clientCredentials = undefined; const client = new ClientCredentialClient(config, appTokenProvider); const clientCredentialRequest: CommonClientCredentialRequest = { diff --git a/lib/msal-common/test/client/DeviceCodeClient.spec.ts b/lib/msal-node/test/client/DeviceCodeClient.spec.ts similarity index 96% rename from lib/msal-common/test/client/DeviceCodeClient.spec.ts rename to lib/msal-node/test/client/DeviceCodeClient.spec.ts index 376544b526..0777873638 100644 --- a/lib/msal-common/test/client/DeviceCodeClient.spec.ts +++ b/lib/msal-node/test/client/DeviceCodeClient.spec.ts @@ -11,17 +11,17 @@ import { CORS_SIMPLE_REQUEST_HEADERS, RANDOM_TEST_GUID, SERVER_UNEXPECTED_ERROR -} from "../test_kit/StringConstants"; -import { BaseClient } from "../../src/client/BaseClient"; -import { AADServerParamKeys, GrantType, ThrottlingConstants, Constants } from "../../src/utils/Constants"; -import { ClientTestUtils } from "./ClientTestUtils"; -import { ClientConfiguration } from "../../src/config/ClientConfiguration"; -import { Authority } from "../../src/authority/Authority"; -import { AuthToken } from "../../src/account/AuthToken"; +} from "@azure/msal-common/test/test_kit/StringConstants"; +import { BaseClient } from "@azure/msal-common/src/client/BaseClient"; +import { AADServerParamKeys, GrantType, ThrottlingConstants, Constants } from "@azure/msal-common/src/utils/Constants"; +import { ClientTestUtils } from "@azure/msal-common/test/client/ClientTestUtils"; +import { ClientConfiguration } from "@azure/msal-common/src/config/ClientConfiguration"; +import { Authority } from "@azure/msal-common/src/authority/Authority"; +import { AuthToken } from "@azure/msal-common/src/account/AuthToken"; import { DeviceCodeClient } from "../../src/client/DeviceCodeClient"; -import { CommonDeviceCodeRequest } from "../../src/request/CommonDeviceCodeRequest"; -import { ClientAuthError } from "../../src/error/ClientAuthError"; -import { AuthError } from "../../src"; +import { CommonDeviceCodeRequest } from "@azure/msal-common/src/request/CommonDeviceCodeRequest"; +import { ClientAuthError } from "@azure/msal-common/src/error/ClientAuthError"; +import { AuthError } from "@azure/msal-common/src"; describe("DeviceCodeClient unit tests", () => { let config: ClientConfiguration; @@ -104,7 +104,7 @@ describe("DeviceCodeClient unit tests", () => { headerNames.forEach((name) => { expect(CORS_SIMPLE_REQUEST_HEADERS).toEqual(expect.arrayContaining([name.toLowerCase()])); }); - + done(); return AUTHENTICATION_RESULT; }); @@ -181,7 +181,7 @@ describe("DeviceCodeClient unit tests", () => { done(error); } }); - + // let deviceCodeResponse = null; const deviceCodeRequest: CommonDeviceCodeRequest = { authority: TEST_CONFIG.validAuthority, @@ -194,7 +194,7 @@ describe("DeviceCodeClient unit tests", () => { }, deviceCodeCallback: () => {}, }; - + const client = new DeviceCodeClient(config); client.acquireToken(deviceCodeRequest).catch((error) => { // Catch errors thrown after the function call this test is testing @@ -348,7 +348,7 @@ describe("DeviceCodeClient unit tests", () => { correlationId: "test-correlationId", scopes: [...TEST_CONFIG.DEFAULT_GRAPH_SCOPE, ...TEST_CONFIG.DEFAULT_SCOPES], deviceCodeCallback: () => {}, - timeout: DEVICE_CODE_RESPONSE.interval - 1, // Setting a timeout equal to the interval polling time minus one to allow for one call to the token endpoint + timeout: DEVICE_CODE_RESPONSE.interval - 1, // Setting a timeout equal to the interval polling time minus one to allow for one call to the token endpoint }; const client = new DeviceCodeClient(config); diff --git a/lib/msal-common/test/client/OnBehalfOfClient.spec.ts b/lib/msal-node/test/client/OnBehalfOfClient.spec.ts similarity index 92% rename from lib/msal-common/test/client/OnBehalfOfClient.spec.ts rename to lib/msal-node/test/client/OnBehalfOfClient.spec.ts index 9e3aa07dd0..30dcfd1f20 100644 --- a/lib/msal-common/test/client/OnBehalfOfClient.spec.ts +++ b/lib/msal-node/test/client/OnBehalfOfClient.spec.ts @@ -12,27 +12,27 @@ import { DEFAULT_OPENID_CONFIG_RESPONSE, TEST_TOKENS, AUTHENTICATION_RESULT, -} from "../test_kit/StringConstants"; -import { BaseClient } from "../../src/client/BaseClient"; -import { ClientTestUtils } from "./ClientTestUtils"; +} from "@azure/msal-common/test/test_kit/StringConstants"; +import { BaseClient } from "@azure/msal-common/src/client/BaseClient"; +import { ClientTestUtils } from "@azure/msal-common/test/client/ClientTestUtils"; import { OnBehalfOfClient } from "../../src/client/OnBehalfOfClient"; -import { CommonOnBehalfOfRequest } from "../../src/request/CommonOnBehalfOfRequest"; -import { AuthToken } from "../../src/account/AuthToken"; -import { TimeUtils } from "../../src/utils/TimeUtils"; -import { Authority } from "../../src/authority/Authority"; -import { ClientConfiguration } from "../../src/config/ClientConfiguration"; -import { AuthenticationResult, IdTokenEntity } from "../../src"; -import { AccessTokenEntity } from "../../src/cache/entities/AccessTokenEntity"; -import { AccountEntity } from "../../src/cache/entities/AccountEntity"; +import { CommonOnBehalfOfRequest } from "@azure/msal-common/src/request/CommonOnBehalfOfRequest"; +import { AuthToken } from "@azure/msal-common/src/account/AuthToken"; +import { TimeUtils } from "@azure/msal-common/src/utils/TimeUtils"; +import { Authority } from "@azure/msal-common/src/authority/Authority"; +import { ClientConfiguration } from "@azure/msal-common/src/config/ClientConfiguration"; +import { AuthenticationResult, IdTokenEntity } from "@azure/msal-common/src"; +import { AccessTokenEntity } from "@azure/msal-common/src/cache/entities/AccessTokenEntity"; +import { AccountEntity } from "@azure/msal-common/src/cache/entities/AccountEntity"; import { AuthenticationScheme, CredentialType, AADServerParamKeys, Constants, ThrottlingConstants, -} from "../../src/utils/Constants"; -import { CacheManager } from "../../src/cache/CacheManager"; -import { ScopeSet } from "../../src/request/ScopeSet"; +} from "@azure/msal-common/src/utils/Constants"; +import { CacheManager } from "@azure/msal-common/src/cache/CacheManager"; +import { ScopeSet } from "@azure/msal-common/src/request/ScopeSet"; const testAccountEntity: AccountEntity = new AccountEntity(); testAccountEntity.homeAccountId = `${TEST_DATA_CLIENT_INFO.TEST_ENCODED_HOME_ACCOUNT_ID}`; @@ -135,7 +135,7 @@ describe("OnBehalfOf unit tests", () => { const createTokenRequestBodySpy = sinon.spy(OnBehalfOfClient.prototype, "createTokenRequestBody"); - let config: ClientConfiguration = await ClientTestUtils.createTestClientConfiguration(); + let config: ClientConfiguration = await ClientTestUtils.createTestClientConfiguration(); const client = new OnBehalfOfClient(config); const oboRequest: CommonOnBehalfOfRequest = { scopes: [...TEST_CONFIG.DEFAULT_GRAPH_SCOPE], @@ -148,7 +148,7 @@ describe("OnBehalfOf unit tests", () => { const authResult = await client.acquireToken(oboRequest) as AuthenticationResult; const returnVal = await createTokenRequestBodySpy.returnValues[0] as string; - + expect(authResult.accessToken).toEqual(AUTHENTICATION_RESULT.body.access_token); expect(authResult.state).toBe(""); expect(authResult.fromCache).toBe(false); @@ -177,7 +177,7 @@ describe("OnBehalfOf unit tests", () => { done(error); } }); - + const client = new OnBehalfOfClient(config); const oboRequest: CommonOnBehalfOfRequest = { scopes: [...TEST_CONFIG.DEFAULT_GRAPH_SCOPE], @@ -192,7 +192,7 @@ describe("OnBehalfOf unit tests", () => { testParam3: "testValue3", }, }; - + client.acquireToken(oboRequest).catch((error) => { // Catch errors thrown after the function call this test is testing }); diff --git a/lib/msal-common/test/client/UsernamePasswordClient.spec.ts b/lib/msal-node/test/client/UsernamePasswordClient.spec.ts similarity index 95% rename from lib/msal-common/test/client/UsernamePasswordClient.spec.ts rename to lib/msal-node/test/client/UsernamePasswordClient.spec.ts index 9852225977..a234eeb9fb 100644 --- a/lib/msal-common/test/client/UsernamePasswordClient.spec.ts +++ b/lib/msal-node/test/client/UsernamePasswordClient.spec.ts @@ -11,16 +11,16 @@ import { TEST_DATA_CLIENT_INFO, TEST_URIS, RANDOM_TEST_GUID -} from "../test_kit/StringConstants"; -import { BaseClient } from "../../src/client/BaseClient"; -import { AADServerParamKeys, GrantType, Constants, PasswordGrantConstants, ThrottlingConstants } from "../../src/utils/Constants"; -import { ClientTestUtils } from "./ClientTestUtils"; -import { Authority } from "../../src/authority/Authority"; +} from "@azure/msal-common/test/test_kit/StringConstants"; +import { BaseClient } from "@azure/msal-common/src/client/BaseClient"; +import { AADServerParamKeys, GrantType, Constants, PasswordGrantConstants, ThrottlingConstants } from "@azure/msal-common/src/utils/Constants"; +import { ClientTestUtils } from "@azure/msal-common/test/client/ClientTestUtils"; +import { Authority } from "@azure/msal-common/src/authority/Authority"; import { UsernamePasswordClient } from "../../src/client/UsernamePasswordClient"; -import { CommonUsernamePasswordRequest } from "../../src/request/CommonUsernamePasswordRequest"; -import { AuthToken } from "../../src/account/AuthToken"; -import { ClientConfiguration } from "../../src/config/ClientConfiguration"; -import { AuthenticationResult } from "../../src/response/AuthenticationResult"; +import { CommonUsernamePasswordRequest } from "@azure/msal-common/src/request/CommonUsernamePasswordRequest"; +import { AuthToken } from "@azure/msal-common/src/account/AuthToken"; +import { ClientConfiguration } from "@azure/msal-common/src/config/ClientConfiguration"; +import { AuthenticationResult } from "@azure/msal-common/src/response/AuthenticationResult"; describe("Username Password unit tests", () => { let config: ClientConfiguration;