Skip to content
This repository was archived by the owner on Feb 24, 2018. It is now read-only.

Node.js Fork#43

Closed
luckybroman5 wants to merge 1 commit intoamazon-archives:masterfrom
luckybroman5:node
Closed

Node.js Fork#43
luckybroman5 wants to merge 1 commit intoamazon-archives:masterfrom
luckybroman5:node

Conversation

@luckybroman5
Copy link

Just a quick node.js implementation

@itrestian
Copy link
Contributor

Thanks for providing this. Users mention that the authentication takes a long time (in the order of seconds). Have you explored using different big integer libraries for Node to speed it up? A user in another thread mentioned using big number instead of big integer in Node. #47

Or maybe experiment with the jsbn library we use in the Javascript implementation?

@itrestian
Copy link
Contributor

I experimented with the fork and sometimes I cannot authenticate from my desktop and other users cannot authenticate from lambda as mentioned here #58 .

I suspect this happens because of differences in big integer library implementations (not all big integers store data at the byte level or add padding the same way depending on the operation). I changed the big integer implementation from biginteger to jsbn which we use in this SDK as well (in the require for the CognitoUser, AuthenticationHandler, and src/index.js).

https://www.npmjs.com/package/jsbn

The authentication is much faster now (from around 7s to lower than 2s) and I can always reliably authenticate from node.

@thaiphan
Copy link

Did you have to commit the whole node_modules folder? I mean, golly...

@kadeatfox
Copy link

kadeatfox commented Jul 12, 2016

@itrestian I used the Bignumber Library, it has a powM function, rather than a modPow. That was my corporate account in which I made the suggestion for big num

This is kinda sloppy, my apologies, I was on a dead line. I would close it.. But i think there are people using it.. haha

@kadeatfox
Copy link

Hi @thaiphan,
I was on a deadline to get a POC out. So I did what I had to. But I had to modify some code in the AWS JS SDK as well as the cognito SDK, so if you would like to modify so it only used those two, that would be greatly appreciated

@jamesingham
Copy link

I replicated what you setup here, however for me it was insanely slow when calling cognitoUser.authenticateUser(). It would take at least 1 or 2 minutes to process. What was your experience like using this?

@kadeatfox
Copy link

Hi @jamesingham , I went into the function itself, changed all of the modpow Functions in the Authentication helper to use the BigNumber Library's powM.

Because Node isn't very good at CPU intensive tasks, SRP doesn't play well. So I had to find a library that handled Numbers as strings rather than actual Numbers.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants