amazon-archives / amazon-cognito-identity-js

Amazon Cognito Identity SDK for JavaScript
Other
984 stars 454 forks source link

Uncaught TypeError: Cannot set property 'createCredentials' of undefined #679

Open PrashanthThugaiah opened 6 years ago

PrashanthThugaiah commented 6 years ago

Hi Team, I am using this module(amazon-cognito-identity-js) for my react project(with webpack), This module is creating issue in the production build.

The error is:

Uncaught TypeError: Cannot set property 'createCredentials' of undefined

at index.js:94

cognito-sdk-issue

at index.js:95
at Object../node_modules/aws-sdk/node_modules/crypto-browserify/index.js (index.js:81)
at f (bootstrap 078132641668547bb385:678)
at n (bootstrap 078132641668547bb385:88)
at Object.<anonymous> (browser_loader.js:4)
at Object../node_modules/aws-sdk/lib/browser_loader.js (index.bundle.js:4966)
at f (bootstrap 078132641668547bb385:678)
at n (bootstrap 078132641668547bb385:88)
at Object../node_modules/aws-sdk/browser.js (browser.js:1)

Note:

  1. I am not facing any issues at dev environment.
  2. I tested excluding this module from the code base, The build is build is working fine.

Please revert to this issue ASAP on priority. Thank You Best Regards, Prashanth Thugaiah

phstc commented 6 years ago

@PrashanthThugaiah I'm also facing the same issue, I will let you know if I figured out the problem.

PrashanthThugaiah commented 6 years ago

Hi, I have a temporary fix to this issue.(but, This might cause side effects)

Need to make changes in file: node_modules\aws-sdk\node_modules\crypto-browserify\index.js

changes: comment the following code snippet in the above mentioned file.

each(['createCredentials'
, 'createCipher'
, 'createCipheriv'
, 'createDecipher'
, 'createDecipheriv'
, 'createSign'
, 'createVerify'
, 'createDiffieHellman'
, 'pbkdf2'], function (name) {
  exports[name] = function () {
    error('sorry,', name, 'is not implemented yet')
  }
})

I am working to find permanent fix to this issue. Any help will be appreciated.