Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: custom user agent InternalCognitoUser #11709

Merged
merged 20 commits into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
8641fe4
chore: port code from CognitoUser and CognitoUserPool to internals
erinleigh90 Jul 17, 2023
ab77ff3
chore: delete InternalCognitoUserPool - separate PR
erinleigh90 Aug 2, 2023
25b639b
chore: update imports and class name
erinleigh90 Jul 17, 2023
467ede4
feat: add userAgentValue param to cognito client api's
erinleigh90 Jul 17, 2023
94fb259
feat: add userAgentValue param to InternalCognitoUser api's, pass to …
erinleigh90 Jul 17, 2023
cfc6c29
feat: make CognitoUser extend InternalCognitoUser and override api's
erinleigh90 Jul 17, 2023
747b1e8
test: update tests to work with additional param, minor fix
erinleigh90 Jul 17, 2023
b85d388
chore: clean up unused imports and const's
erinleigh90 Jul 17, 2023
f9b4c81
feat: add missing userAgentValue param
erinleigh90 Jul 17, 2023
49e66ec
chore: add new param to documentation comments
erinleigh90 Jul 17, 2023
3bcf69f
build: export InternalCognitoUser from internals scope
erinleigh90 Jul 17, 2023
cd95804
fix: remove default from InternalCognitoUser to fix scoped export
erinleigh90 Jul 18, 2023
ce3f687
fix: fix typo causing signOut failure
erinleigh90 Jul 31, 2023
3588e6e
build: correct index.d.ts files with changes
erinleigh90 Jul 31, 2023
fa415f9
test: revert auth tests
erinleigh90 Aug 2, 2023
9df968f
chore: increase bundle size limits
erinleigh90 Aug 2, 2023
745e506
chore: simplify InternalCognitoUser import
erinleigh90 Aug 3, 2023
d8b1b45
Merge branch 'main' into feat/internal-cognito
israx Aug 4, 2023
29442fc
Merge branch 'main' into feat/internal-cognito
erinleigh90 Aug 7, 2023
7f26cee
Merge branch 'main' into feat/internal-cognito
erinleigh90 Aug 7, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions packages/amazon-cognito-identity-js/__tests__/CognitoUser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ describe('authenticateUser()', () => {
user.setAuthenticationFlowType('USER_PASSWORD_AUTH');
user.authenticateUser(authDetails, callback);

expect(spyon).toHaveBeenCalledWith(authDetails, callback);
expect(spyon).toHaveBeenCalledWith(authDetails, callback, undefined);
});

test('USER_SRP_AUTH and CUSTOM_AUTH flow types', () => {
Expand All @@ -212,12 +212,12 @@ describe('authenticateUser()', () => {
user.setAuthenticationFlowType('USER_SRP_AUTH');
user.authenticateUser(authDetails, callback);

expect(spyon).toHaveBeenCalledWith(authDetails, callback);
expect(spyon).toHaveBeenCalledWith(authDetails, callback, undefined);

user.setAuthenticationFlowType('CUSTOM_AUTH');
user.authenticateUser(authDetails, callback);

expect(spyon).toHaveBeenCalledWith(authDetails, callback);
expect(spyon).toHaveBeenCalledWith(authDetails, callback, undefined);
});

test('throws error for invalid Authentication flow type', () => {
Expand Down Expand Up @@ -310,7 +310,8 @@ describe('authenticateUserPlainUsernamePassword()', () => {
expect(userSpy3).toBeCalledWith(
'test auth result',
userSpy3.mock.calls[0][1],
callback
callback,
undefined
);
expect(userSpy3.mock.results[0].value).toBe('test return value');
});
Expand Down Expand Up @@ -755,7 +756,8 @@ describe('sendCustomChallengeAnswer()', () => {
expect(spyon3).toBeCalledWith(
vCognitoUserSession,
expect.any(AuthenticationHelper),
callback
callback,
undefined
);
});

Expand Down Expand Up @@ -1176,33 +1178,33 @@ describe('confirmPassword() and forgotPassword()', () => {
jest.clearAllMocks();
});

test('happy path should callback onSuccess', () => {
test('confirmPassword happy path should callback onSuccess', () => {
netRequestMockSuccess(true);
cognitoUser.confirmPassword(...confirmPasswordDefaults);
expect(callback.onSuccess).toHaveBeenCalledWith('SUCCESS');
});

test('client request throws an error', () => {
test('confirmPassword client request throws an error', () => {
netRequestMockSuccess(false);
cognitoUser.confirmPassword(...confirmPasswordDefaults);
expect(callback.onFailure.mock.calls.length).toEqual(1);
});

test('happy path should callback onSuccess', () => {
test('forgotPassword happy path should callback onSuccess', () => {
callback.inputVerificationCode = null;
netRequestMockSuccess(true);
cognitoUser.forgotPassword(...forgotPasswordDefaults);
expect(callback.onSuccess.mock.calls.length).toEqual(1);
});

test('inputVerification code is a function should callback inputVerificationCode', () => {
test('forgotPassword inputVerification code is a function should callback inputVerificationCode', () => {
callback.inputVerificationCode = jest.fn();
netRequestMockSuccess(true);
cognitoUser.forgotPassword(...forgotPasswordDefaults);
expect(callback.inputVerificationCode.mock.calls.length).toEqual(1);
});

test('client returning an error should call onFailure', () => {
test('forgotPassword client returning an error should call onFailure', () => {
netRequestMockSuccess(false);
cognitoUser.forgotPassword(...forgotPasswordDefaults);
expect(callback.onFailure.mock.calls.length).toEqual(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ describe('import * keys', () => {
Array [
"addAuthCategoryToCognitoUserAgent",
"addFrameworkToCognitoUserAgent",
"InternalCognitoUser",
]
`);
});
Expand Down
15 changes: 2 additions & 13 deletions packages/amazon-cognito-identity-js/index.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

266 changes: 266 additions & 0 deletions packages/amazon-cognito-identity-js/internals/index.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading