Skip to content

Commit

Permalink
chore(auth|aws-amplify): fix instance naming (use camel-case)
Browse files Browse the repository at this point in the history
  • Loading branch information
HuiSF committed Nov 8, 2023
1 parent 0138c28 commit 2431278
Show file tree
Hide file tree
Showing 15 changed files with 36 additions and 36 deletions.
4 changes: 2 additions & 2 deletions packages/auth/__tests__/providers/cognito/autoSignIn.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

import {
CognitoUserPoolsTokenProvider,
cognitoUserPoolsTokenProvider,
signUp,
} from '../../../src/providers/cognito';
import { autoSignIn } from '../../../src/providers/cognito/apis/autoSignIn';
Expand All @@ -20,7 +20,7 @@ const authConfig = {
userPoolId: 'us-west-2_zzzzz',
},
};
CognitoUserPoolsTokenProvider.setAuthConfig(authConfig);
cognitoUserPoolsTokenProvider.setAuthConfig(authConfig);
Amplify.configure({
Auth: authConfig,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
import * as signInHelpers from '../../../src/providers/cognito/utils/signInHelpers';
import { RespondToAuthChallengeCommandOutput } from '../../../src/providers/cognito/utils/clients/CognitoIdentityProvider/types';
import {
CognitoUserPoolsTokenProvider,
cognitoUserPoolsTokenProvider,
tokenOrchestrator,
} from '../../../src/providers/cognito/tokenProvider';
import * as clients from '../../../src/providers/cognito/utils/clients/CognitoIdentityProvider';
Expand All @@ -34,7 +34,7 @@ describe('confirmSignIn API happy path cases', () => {
const password = authAPITestParams.user1.password;

beforeEach(async () => {
CognitoUserPoolsTokenProvider.setAuthConfig(authConfig);
cognitoUserPoolsTokenProvider.setAuthConfig(authConfig);

handleChallengeNameSpy = jest
.spyOn(signInHelpers, 'handleChallengeName')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Amplify } from '@aws-amplify/core';
import { fetchAuthSession } from '@aws-amplify/core';
import {
CognitoAWSCredentialsAndIdentityIdProvider,
CognitoUserPoolsTokenProvider,
cognitoUserPoolsTokenProvider,
cognitoCredentialsProvider,
} from '../../../src/providers/cognito';
import { decodeJWT } from '@aws-amplify/core/internals/utils';
Expand Down Expand Up @@ -43,7 +43,7 @@ describe('fetchAuthSession behavior for IdentityPools only', () => {
{
Auth: {
credentialsProvider: cognitoCredentialsProvider,
tokenProvider: CognitoUserPoolsTokenProvider,
tokenProvider: cognitoUserPoolsTokenProvider,
},
}
);
Expand Down Expand Up @@ -78,7 +78,7 @@ describe.only('fetchAuthSession behavior for UserPools only', () => {
let tokenProviderSpy;
beforeEach(() => {
tokenProviderSpy = jest
.spyOn(CognitoUserPoolsTokenProvider, 'getTokens')
.spyOn(cognitoUserPoolsTokenProvider, 'getTokens')
.mockImplementation(async () => {
return {
accessToken: decodeJWT(
Expand All @@ -104,7 +104,7 @@ describe.only('fetchAuthSession behavior for UserPools only', () => {
{
Auth: {
credentialsProvider: cognitoCredentialsProvider,
tokenProvider: CognitoUserPoolsTokenProvider,
tokenProvider: cognitoUserPoolsTokenProvider,
},
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { authAPITestParams } from './testUtils/authApiTestParams';
import {
signIn,
getCurrentUser,
CognitoUserPoolsTokenProvider,
cognitoUserPoolsTokenProvider,
} from '../../../src/providers/cognito';
import { InitiateAuthException } from '../../../src/providers/cognito/types/errors';
import { Amplify } from 'aws-amplify';
Expand All @@ -27,7 +27,7 @@ const authConfig = {
Amplify.configure({
Auth: authConfig,
});
CognitoUserPoolsTokenProvider.setAuthConfig(authConfig);
cognitoUserPoolsTokenProvider.setAuthConfig(authConfig);

describe('signIn API error path cases:', () => {
test('signIn API should throw a validation AuthError when a user is already signed-in', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as signInHelpers from '../../../src/providers/cognito/utils/signInHelpe
import { signInStore } from '../../../src/providers/cognito/utils/signInStore';
import { Amplify } from '@aws-amplify/core';
import { RespondToAuthChallengeCommandOutput } from '../../../src/providers/cognito/utils/clients/CognitoIdentityProvider/types';
import { CognitoUserPoolsTokenProvider } from '../../../src/providers/cognito/tokenProvider';
import { cognitoUserPoolsTokenProvider } from '../../../src/providers/cognito/tokenProvider';
jest.mock('../../../src/providers/cognito/apis/getCurrentUser');

// getCurrentUser is mocked so Hub is able to dispatch a mocked AuthUser
Expand All @@ -26,7 +26,7 @@ describe('local sign-in state management tests', () => {
};

beforeEach(() => {
CognitoUserPoolsTokenProvider.setAuthConfig(authConfig);
cognitoUserPoolsTokenProvider.setAuthConfig(authConfig);
});

test('local state management should return state after signIn returns a ChallengeName', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { signInWithCustomAuth } from '../../../src/providers/cognito/apis/signIn
import * as initiateAuthHelpers from '../../../src/providers/cognito/utils/signInHelpers';
import { InitiateAuthCommandOutput } from '../../../src/providers/cognito/utils/clients/CognitoIdentityProvider/types';
import {
CognitoUserPoolsTokenProvider,
cognitoUserPoolsTokenProvider,
tokenOrchestrator,
} from '../../../src/providers/cognito/tokenProvider';
import * as clients from '../../../src/providers/cognito/utils/clients/CognitoIdentityProvider';
Expand All @@ -23,7 +23,7 @@ const authConfig = {
Amplify.configure({
Auth: authConfig,
});
CognitoUserPoolsTokenProvider.setAuthConfig(authConfig);
cognitoUserPoolsTokenProvider.setAuthConfig(authConfig);
describe('signIn API happy path cases', () => {
let handleCustomAuthFlowWithoutSRPSpy;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { signInWithCustomSRPAuth } from '../../../src/providers/cognito/apis/sig
import { RespondToAuthChallengeCommandOutput } from '../../../src/providers/cognito/utils/clients/CognitoIdentityProvider/types';
import { Amplify } from 'aws-amplify';
import {
CognitoUserPoolsTokenProvider,
cognitoUserPoolsTokenProvider,
tokenOrchestrator,
} from '../../../src/providers/cognito/tokenProvider';
import * as clients from '../../../src/providers/cognito/utils/clients/CognitoIdentityProvider';
Expand All @@ -19,7 +19,7 @@ const authConfig = {
userPoolId: 'us-west-2_zzzzz',
},
};
CognitoUserPoolsTokenProvider.setAuthConfig(authConfig);
cognitoUserPoolsTokenProvider.setAuthConfig(authConfig);
Amplify.configure({
Auth: authConfig,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as initiateAuthHelpers from '../../../src/providers/cognito/utils/signI
import { RespondToAuthChallengeCommandOutput } from '../../../src/providers/cognito/utils/clients/CognitoIdentityProvider/types';
import { Amplify } from 'aws-amplify';
import {
CognitoUserPoolsTokenProvider,
cognitoUserPoolsTokenProvider,
tokenOrchestrator,
} from '../../../src/providers/cognito/tokenProvider';
import { AuthError } from '../../../src';
Expand All @@ -22,7 +22,7 @@ const authConfig = {
},
};

CognitoUserPoolsTokenProvider.setAuthConfig(authConfig);
cognitoUserPoolsTokenProvider.setAuthConfig(authConfig);
Amplify.configure({
Auth: authConfig,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { signInWithUserPassword } from '../../../src/providers/cognito/apis/sign
import { RespondToAuthChallengeCommandOutput } from '../../../src/providers/cognito/utils/clients/CognitoIdentityProvider/types';
import { Amplify } from 'aws-amplify';
import {
CognitoUserPoolsTokenProvider,
cognitoUserPoolsTokenProvider,
tokenOrchestrator,
} from '../../../src/providers/cognito/tokenProvider';
import * as clients from '../../../src/providers/cognito/utils/clients/CognitoIdentityProvider';
Expand All @@ -20,7 +20,7 @@ const authConfig = {
},
};

CognitoUserPoolsTokenProvider.setAuthConfig(authConfig);
cognitoUserPoolsTokenProvider.setAuthConfig(authConfig);
Amplify.configure({
Auth: authConfig,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
AmplifyUrl,
} from '@aws-amplify/core/internals/utils';
import { cacheCognitoTokens } from '../tokenProvider/cacheTokens';
import { CognitoUserPoolsTokenProvider } from '../tokenProvider';
import { cognitoUserPoolsTokenProvider } from '../tokenProvider';
import { cognitoHostedUIIdentityProviderMap } from '../types/models';
import { DefaultOAuthStore } from '../utils/signInWithRedirectStore';
import { AuthError } from '../../../errors/AuthError';
Expand Down Expand Up @@ -472,7 +472,7 @@ const invokeAndClearPromise = () => {
};

isBrowser() &&
CognitoUserPoolsTokenProvider.setWaitForInflightOAuth(
cognitoUserPoolsTokenProvider.setWaitForInflightOAuth(
() =>
new Promise(async (res, _rej) => {
if (!(await store.loadOAuthInFlight())) {
Expand Down
2 changes: 1 addition & 1 deletion packages/auth/src/providers/cognito/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export {
DefaultIdentityIdStore,
} from './credentialsProvider';
export {
CognitoUserPoolsTokenProvider,
cognitoUserPoolsTokenProvider,
CognitoUserPoolTokenProviderType,
TokenOrchestrator,
DefaultTokenStore,
Expand Down
4 changes: 2 additions & 2 deletions packages/auth/src/providers/cognito/tokenProvider/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ class CognitoUserPoolsTokenProviderClass
}
}

export const CognitoUserPoolsTokenProvider =
export const cognitoUserPoolsTokenProvider =
new CognitoUserPoolsTokenProviderClass();

export const tokenOrchestrator =
CognitoUserPoolsTokenProvider.tokenOrchestrator;
cognitoUserPoolsTokenProvider.tokenOrchestrator;

export {
CognitoUserPoolTokenProviderType,
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-amplify/__tests__/exports.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ describe('aws-amplify Exports', () => {
'fetchDevices',
'autoSignIn',
'cognitoCredentialsProvider',
'CognitoUserPoolsTokenProvider',
'cognitoUserPoolsTokenProvider',
'CognitoAWSCredentialsAndIdentityIdProvider',
'DefaultIdentityIdStore',
'TokenOrchestrator',
Expand Down
12 changes: 6 additions & 6 deletions packages/aws-amplify/__tests__/initSingleton.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@ import {
defaultStorage,
} from '@aws-amplify/core';
import {
CognitoUserPoolsTokenProvider,
cognitoUserPoolsTokenProvider,
cognitoCredentialsProvider,
} from '../src/auth/cognito';

import { Amplify } from '../src';

jest.mock('@aws-amplify/core');
jest.mock('../src/auth/cognito', () => ({
CognitoUserPoolsTokenProvider: {
cognitoUserPoolsTokenProvider: {
setAuthConfig: jest.fn(),
setKeyValueStorage: jest.fn(),
},
cognitoCredentialsProvider: jest.fn(),
}));

const mockCognitoUserPoolsTokenProviderSetAuthConfig =
CognitoUserPoolsTokenProvider.setAuthConfig as jest.Mock;
cognitoUserPoolsTokenProvider.setAuthConfig as jest.Mock;
const mockCognitoUserPoolsTokenProviderSetKeyValueStorage =
CognitoUserPoolsTokenProvider.setKeyValueStorage as jest.Mock;
cognitoUserPoolsTokenProvider.setKeyValueStorage as jest.Mock;
const mockAmplifySingletonConfigure = AmplifySingleton.configure as jest.Mock;
const mockAmplifySingletonGetConfig = AmplifySingleton.getConfig as jest.Mock;
const MockCookieStorage = CookieStorage as jest.Mock;
Expand Down Expand Up @@ -137,7 +137,7 @@ describe('initSingleton (DefaultAmplify)', () => {
mockResourceConfig,
{
Auth: {
tokenProvider: CognitoUserPoolsTokenProvider,
tokenProvider: cognitoUserPoolsTokenProvider,
credentialsProvider: cognitoCredentialsProvider,
},
}
Expand Down Expand Up @@ -200,7 +200,7 @@ describe('initSingleton (DefaultAmplify)', () => {
mockResourceConfig,
{
Auth: {
tokenProvider: CognitoUserPoolsTokenProvider,
tokenProvider: cognitoUserPoolsTokenProvider,
credentialsProvider: cognitoCredentialsProvider,
},
...libraryOptionsWithStorage,
Expand Down
8 changes: 4 additions & 4 deletions packages/aws-amplify/src/initSingleton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
parseAWSExports,
} from '@aws-amplify/core/internals/utils';
import {
CognitoUserPoolsTokenProvider,
cognitoUserPoolsTokenProvider,
cognitoCredentialsProvider,
} from './auth/cognito';

Expand All @@ -36,17 +36,17 @@ export const DefaultAmplify = {
!libraryOptions?.Auth &&
!Amplify.libraryOptions.Auth
) {
CognitoUserPoolsTokenProvider.setAuthConfig(resolvedResourceConfig.Auth);
cognitoUserPoolsTokenProvider.setAuthConfig(resolvedResourceConfig.Auth);

const libraryOptionsWithDefaultAuthProviders: LibraryOptions = {
...libraryOptions,
Auth: {
tokenProvider: CognitoUserPoolsTokenProvider,
tokenProvider: cognitoUserPoolsTokenProvider,
credentialsProvider: cognitoCredentialsProvider,
},
};

CognitoUserPoolsTokenProvider.setKeyValueStorage(
cognitoUserPoolsTokenProvider.setKeyValueStorage(
libraryOptions?.ssr
? // TODO: allow configure with a public interface
new CookieStorage({
Expand Down

0 comments on commit 2431278

Please sign in to comment.