aws-amplify / amplify-js

A declarative JavaScript library for application development using cloud services.
https://docs.amplify.aws/lib/q/platform/js
Apache License 2.0
9.42k stars 2.12k forks source link

Error in signUp method of CognitoUserPool #12323

Closed lmousom closed 10 months ago

lmousom commented 11 months ago

Before opening, please confirm:

JavaScript Framework

Not applicable

Amplify APIs

Not applicable

Amplify Categories

Not applicable

Environment information

``` System: OS: Windows 10 10.0.22621 CPU: (8) x64 11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz Memory: 2.98 GB / 15.79 GB Binaries: Node: 18.16.1 - C:\Program Files\nodejs\node.EXE npm: 9.5.1 - C:\Program Files\nodejs\npm.CMD Browsers: Edge: Spartan (44.22621.2283.0), Chromium (118.0.2088.46) Internet Explorer: 11.0.22621.1 npmPackages: @azure/identity: ^3.3.1 => 3.3.1 @azure/storage-blob: ^12.12.0 => 12.13.0 @azure/storage-file-share: ^12.15.0 => 12.15.0 @microsoft/microsoft-graph-client: ^3.0.7 => 3.0.7 amazon-cognito-identity-js: ^6.3.6 => 6.3.6 amazon-cognito-identity-js/internals: undefined () apidoc: ^0.53.1 => 0.53.1 aws-jwt-verify: ^3.2.0 => 3.4.0 aws-sdk: ^2.1260.0 => 2.1342.0 axios: ^1.2.0 => 1.3.4 (0.21.4) bcrypt: ^5.1.0 => 5.1.0 bluebird: ^3.7.2 => 3.7.2 (3.4.7) body-parser: ^1.20.1 => 1.20.2 (1.20.1) cors: ^2.8.5 => 2.8.5 crypto: ^1.0.1 => 1.0.1 crypto-js: ^4.1.1 => 4.1.1 date-fns: ^2.29.3 => 2.29.3 detect-browser: ^5.3.0 => 5.3.0 docusaurus: 0.0.0 dompurify: ^3.0.6 => 3.0.6 dotenv: ^16.0.3 => 16.0.3 eslint: ^8.28.0 => 8.36.0 eslint-config-airbnb-base: ^15.0.0 => 15.0.0 eslint-plugin-import: ^2.26.0 => 2.27.5 exceljs: ^4.3.0 => 4.3.0 express: ^4.18.2 => 4.18.2 express-fileupload: ^1.4.0 => 1.4.0 express-rate-limit: ^6.7.0 => 6.7.0 express-useragent: ^1.0.15 => 1.0.15 express-validation: ^4.1.0 => 4.1.0 formidable: ^2.0.1 => 2.1.1 (2.1.2) fuzz: 1.0.0 generate-password: ^1.7.0 => 1.7.0 geoip-lite: ^1.4.7 => 1.4.7 google-libphonenumber: ^3.2.31 => 3.2.32 googleapis: ^109.0.1 => 109.0.1 handlebars: ^4.7.7 => 4.7.7 helmet: ^6.0.1 => 6.0.1 http-errors: ^2.0.0 => 2.0.0 http-status: ^1.5.3 => 1.6.2 inline-css: ^4.0.1 => 4.0.2 jsdom: ^22.1.0 => 22.1.0 jsonwebtoken: ^9.0.0 => 9.0.0 jwk-to-pem: ^2.0.5 => 2.0.5 lodash: ^4.17.21 => 4.17.21 md5: ^2.3.0 => 2.3.0 memory-cache: ^0.2.0 => 0.2.0 mime-types: ^2.1.35 => 2.1.35 moment: ^2.29.4 => 2.29.4 multer: ^1.4.4 => 1.4.4 (1.4.5-lts.1) multer-azure-blob-storage: ^1.2.0 => 1.2.0 multer-s3: ^2.10.0 => 2.10.0 mysql: ^2.18.1 => 2.18.1 mysql2: ^2.3.3 => 2.3.3 nanoid: ^3.3.6 => 3.3.6 (2.1.11) node-cron: ^3.0.2 => 3.0.2 nodemon: ^2.0.20 => 2.0.22 passport: ^0.6.0 => 0.6.0 passport-http-bearer: ^1.0.1 => 1.0.1 passport-jwt: ^4.0.1 => 4.0.1 passport-local: ^1.0.0 => 1.0.0 phantomjs-prebuilt: ^2.1.16 => 2.1.16 pm2: ^5.2.2 => 5.3.0 pm2-plus-custom-metrics: 1.0.0 puppeteer: ^19.2.2 => 19.7.5 python-app: 1.0.0 razorpay: ^2.8.3 => 2.8.6 request: ^2.88.2 => 2.88.2 sanitize: ^2.1.2 => 2.1.2 sanitize-html: ^2.9.0 => 2.10.0 sequelize: ^6.29.0 => 6.29.3 sequelize-cli: ^6.5.2 => 6.6.0 sharp: ^0.31.2 => 0.31.3 shortid: ^2.2.16 => 2.2.16 simple-http-server: 1.0.0 slackbots: ^1.3.0 => 1.3.0 slug: ^8.2.2 => 8.2.2 slugify: ^1.6.6 => 1.6.6 socket.io: ^4.7.2 => 4.7.2 stripe: ^13.5.0 => 13.5.0 swagger-jsdoc: ^6.2.5 => 6.2.8 swagger-ui-express: ^4.6.0 => 4.6.2 uuid: ^9.0.0 => 9.0.0 (8.3.2, 3.4.0, 8.0.0) validator: ^13.9.0 => 13.9.0 xlsx: ^0.18.5 => 0.18.5 xss-filters: ^1.2.7 => 1.2.7 npmGlobalPackages: corepack: 0.17.0 npm: 9.5.1 ```

Describe the bug

I encountered a bug in the CognitoUserPool.js file within the package, specifically in the amazon-cognito-identity-js library. When attempting to create a user using the signUp method of CognitoUserPool, I encountered a TypeError. The error message is: TypeError: callback is not a function. The expected behavior is to receive a result in case of success or an error in case of failure.

Expected behavior

I expected to receive a result in case of success or an error in case of failure.

Reproduction steps

  1. Use the const userPool = new AmazonCognitoIdentity.CognitoUserPool(poolData); userPool.signUp method in your code.
  2. Pass the required parameters for signing up a user.
  3. Observe the error that occurs.

Code Snippet

 _proto.signUp = function signUp(username, password, userAttributes, validationData, callback, clientMetadata) {
    var _this = this;
    var jsonReq = {
      ClientId: this.clientId,
      Username: username,
      Password: password,
      UserAttributes: userAttributes,
      ValidationData: validationData,
      ClientMetadata: clientMetadata
    };
    if (this.getUserContextData(username)) {
      jsonReq.UserContextData = this.getUserContextData(username);
    }
    this.client.request('SignUp', jsonReq, function (err, data) {
      if (err) {
        return callback(err, null);
      }
      var cognitoUser = {
        Username: username,
        Pool: _this,
        Storage: _this.storage
      };
      var returnData = {
        user: new _CognitoUser["default"](cognitoUser),
        userConfirmed: data.UserConfirmed,
        userSub: data.UserSub,
        codeDeliveryDetails: data.CodeDeliveryDetails
      };
      return callback(null, returnData);
    });
  }

Log output

``` amazon-cognito-identity-js\lib\CognitoUserPool.js:114 return callback(err, null); ^ TypeError: callback is not a function ```

aws-exports.js

No response

Manual configuration

No response

Additional configuration

No response

Mobile Device

No response

Mobile Operating System

No response

Mobile Browser

No response

Mobile Browser Version

No response

Additional information and screenshots

https://github.com/aws-amplify/amplify-js/assets/25593137/088722bc-2367-42ec-8bc0-a00dfc011d2c

utkarshk384 commented 11 months ago

Even I'm facing the same issue. @lmousom can you share the code snippet that you pasted from your clipboard here?

cwomack commented 11 months ago

Hello, @lmousom 👋 and thank you for opening this issue. Can you clarify what kind of authentication flow you have set up (i.e. is this TOTP/MFA based or neither)? And as @utkarshk384 asked above, could you provide us with more of the frontend code you're using for authentication calls?

cwomack commented 10 months ago

@lmousom, wanted to circle back and see if you're still experiencing this issue. If so, can you address the questions above please. Thanks!

cwomack commented 10 months ago

Closing this issue as we have not heard back from you. If you are still experiencing this, please feel free to reply back and provide any information previously requested and we'd be happy to re-open the issue.

Thank you!