Amazon-cognito-identity-js: Is this repository meant for Node?

Created on 10 Aug 2016  路  4Comments  路  Source: amazon-archives/amazon-cognito-identity-js

What exactly is this repository's purpose, is it meant as official extension above aws/aws-sdk-js for Cognito? And do you plan it should be usable in Node too? (I see here some issues and pr about it but I can't find out if Node's support is planned or not.)

My problem is that we are building an API above API Gateway and Lambda which should use Cognito User Pool for user auth. I already built signup process using standard aws-sdk-js but I certainly don't want to implement whole AWS Signature protocol for login myself. This sdk seems to have it solved in js but so far is not usable in Node. So I want to ask if I should wait or look somewhere else.

Most helpful comment

Eventually we plan to add support for Node. At this point there are a couple of options. (1) As you said, one can implement the SRP protocol in Node based on this implementation. (2) Since you are in a server environment you can use the Admin APIs such as AdminInitiateAuth to do plain text username/password authentication. The SRP part will be handled by the Cognito service.

All 4 comments

Eventually we plan to add support for Node. At this point there are a couple of options. (1) As you said, one can implement the SRP protocol in Node based on this implementation. (2) Since you are in a server environment you can use the Admin APIs such as AdminInitiateAuth to do plain text username/password authentication. The SRP part will be handled by the Cognito service.

I made the option 1 (login with 6 seconds)
I believe that the option 2 will be more efficient.
I will try?
Anyone tried the option 2?

That can be tried from the AWS CLI as well by passing the right parameters.

Thanks @itrestian! I wasn't aware that I can call AdminInitiateAuth with ADMIN_NO_SRP_AUTH. Works good for me, my code looks like this @cleitonjar:

var params = {
    AuthFlow: 'ADMIN_NO_SRP_AUTH',
    ClientId: process.env.COGNITO_USER_IDENTITY_POOL_CLIENT_ID,
    UserPoolId: process.env.COGNITO_USER_IDENTITY_POOL_ID,
    AuthParameters: {
      USERNAME: event.email,
      PASSWORD: event.password
    }
  };

  var cognitoidentityserviceprovider = new aws.CognitoIdentityServiceProvider({region: process.env.SERVERLESS_REGION});
  cognitoidentityserviceprovider.adminInitiateAuth(params, function(err, data) {
    if (err) {
      console.log(err, err.stack);
    } else {
      console.log(data);
    }
  });

(Notice, that you have to check "Enable sign-in API for server-based authentication" in settings of your client app first)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

BerndWessels picture BerndWessels  路  5Comments

carlnordenfelt picture carlnordenfelt  路  5Comments

RashmiPandey picture RashmiPandey  路  4Comments

m-schrepel picture m-schrepel  路  6Comments

bradennapier picture bradennapier  路  6Comments