Skip to content

Commit

Permalink
fix(amazon-cognito-identity-js): Missing cognito user challenge name … (
Browse files Browse the repository at this point in the history
aws-amplify#10047)

* fix(amazon-cognito-identity-js): Missing cognito user challenge name type

* fix(type): Fix other functions reported in aws-amplify#6974

* Update Auth units with correct ChallengeName

Co-authored-by: elorzafe <elorzafe@amazon.com>
  • Loading branch information
micksatana and elorzafe authored Jul 6, 2022
1 parent 870ec87 commit de0441b
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 16 deletions.
37 changes: 31 additions & 6 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.

20 changes: 10 additions & 10 deletions packages/auth/__tests__/auth-unit-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1011,15 +1011,15 @@ describe('auth unit test', () => {
const spyon = jest
.spyOn(CognitoUser.prototype, 'authenticateUser')
.mockImplementationOnce((authenticationDetails, callback) => {
callback.mfaRequired('challengeName', 'challengeParam');
callback.mfaRequired('SELECT_MFA_TYPE', 'challengeParam');
});
const auth = new Auth(authOptions);
const user = new CognitoUser({
Username: 'username',
Pool: userPool,
});
const userAfterSignedIn = Object.assign({}, user, {
challengeName: 'challengeName',
challengeName: 'SELECT_MFA_TYPE',
challengeParam: 'challengeParam',
});

Expand All @@ -1035,15 +1035,15 @@ describe('auth unit test', () => {
const spyon = jest
.spyOn(CognitoUser.prototype, 'authenticateUser')
.mockImplementationOnce((authenticationDetails, callback) => {
callback.mfaSetup('challengeName', 'challengeParam');
callback.mfaSetup('MFA_SETUP', 'challengeParam');
});
const auth = new Auth(authOptions);
const user = new CognitoUser({
Username: 'username',
Pool: userPool,
});
const userAfterSignedIn = Object.assign({}, user, {
challengeName: 'challengeName',
challengeName: 'MFA_SETUP',
challengeParam: 'challengeParam',
});

Expand All @@ -1059,15 +1059,15 @@ describe('auth unit test', () => {
const spyon = jest
.spyOn(CognitoUser.prototype, 'authenticateUser')
.mockImplementationOnce((authenticationDetails, callback) => {
callback.totpRequired('challengeName', 'challengeParam');
callback.totpRequired('SOFTWARE_TOKEN_MFA', 'challengeParam');
});
const auth = new Auth(authOptions);
const user = new CognitoUser({
Username: 'username',
Pool: userPool,
});
const userAfterSignedIn = Object.assign({}, user, {
challengeName: 'challengeName',
challengeName: 'SOFTWARE_TOKEN_MFA',
challengeParam: 'challengeParam',
});

Expand All @@ -1083,15 +1083,15 @@ describe('auth unit test', () => {
const spyon = jest
.spyOn(CognitoUser.prototype, 'authenticateUser')
.mockImplementationOnce((authenticationDetails, callback) => {
callback.selectMFAType('challengeName', 'challengeParam');
callback.selectMFAType('SELECT_MFA_TYPE', 'challengeParam');
});
const auth = new Auth(authOptions);
const user = new CognitoUser({
Username: 'username',
Pool: userPool,
});
const userAfterSignedIn = Object.assign({}, user, {
challengeName: 'challengeName',
challengeName: 'SELECT_MFA_TYPE',
challengeParam: 'challengeParam',
});

Expand Down Expand Up @@ -1403,7 +1403,7 @@ describe('auth unit test', () => {
const spyon = jest
.spyOn(CognitoUser.prototype, 'completeNewPasswordChallenge')
.mockImplementationOnce((password, requiredAttributes, callback) => {
callback.mfaRequired('challengeName', 'challengeParam');
callback.mfaRequired('SMS_MFA', 'challengeParam');
});

const auth = new Auth(authOptions);
Expand All @@ -1422,7 +1422,7 @@ describe('auth unit test', () => {
const spyon = jest
.spyOn(CognitoUser.prototype, 'completeNewPasswordChallenge')
.mockImplementationOnce((password, requiredAttributes, callback) => {
callback.mfaSetup('challengeName', 'challengeParam');
callback.mfaSetup('MFA_SETUP', 'challengeParam');
});

const auth = new Auth(authOptions);
Expand Down

0 comments on commit de0441b

Please sign in to comment.