In the minified code, I get amazon-cognito.js:3541 Uncaught TypeError: c.update is not a function
When I dig into it and look at C it is a new sjcl.misc.hmac(prk, sjcl.hash.sha256) and it does have an update method, but it is on the prototype of a function inside that object.
I'm pretty sure this is the source for where this is going wrong.
source
Hi Matthew,
From what I see sjcl.misc.hmac does have an update method, however it was missing at some point. Any idea if the library you are using is missing the method?
https://github.com/bitwiseshiftleft/sjcl/commits/master/core/hmac.js
Ionut.
@itrestian
I downloaded the library yesterday from the repo you linked to, so I should be using the same version as you are since the last commit was months ago.
When I dig into the minified source I see that sjcl.misc.hmac has an M constructor and in that constructor's prototype I see an update method.
screenshot of C
@itrestian
Ok, I redownloaded everything, made sure it was in the right order, and now... this error happens. It is different, but still can't get through the authenticateUser method.
Uncaught TypeError: Cannot read property 'toBits' of undefined
var authenticationData = {
Username : '**********',
Password : '**********',
};
var authenticationDetails = new AWSCognito.CognitoIdentityServiceProvider.AuthenticationDetails(authenticationData);
var poolData = {
UserPoolId : 'UserPoolId Stuff',
ClientId : 'clientIdStuff'
};
var userPool = new AWSCognito.CognitoIdentityServiceProvider.CognitoUserPool(poolData);
var userData = {
Username : 'username',
Pool : userPool
};
var cognitoUser = new AWSCognito.CognitoIdentityServiceProvider.CognitoUser(userData);
cognitoUser.authenticateUser(authenticationDetails, {
onSuccess: function (result) {
console.log('access token + ' + result.getAccessToken().getJwtToken());
},
onFailure: function(err) {
alert(err);
},
});
Hi Matthew,
In your case, I think the error happens because you haven't included the bytes codec in sjcl. By default, sjcl doesn't come with the bytes codec so you need to configure and make it with that particular option (this is mentioned in the README.md file).
Ionut.
@itrestian
Thank you so much. That solved the issue. For anyone looking at this in the future:
./configure --with-codecBytesmakemake sjcl.js tidy@itrestian this looks like the issue I'm running into also. I'll run through the steps above.
Most helpful comment
@itrestian
Thank you so much. That solved the issue. For anyone looking at this in the future:
1. Clone the SJCL Repo
2. in the root run
./configure --with-codecBytes3.
make4.
make sjcl.js tidy5. replace your old library with this newly compiled library
6. Log in!