bitwiseshiftleft / sjcl

Stanford Javascript Crypto Library
http://bitwiseshiftleft.github.com/sjcl/
Other
7.18k stars 986 forks source link

Fix attempting to load node crypto module outside of node. #391

Closed legastero closed 5 years ago

legastero commented 5 years ago

Specifying a browser override of false for the node crypto module prevents bundlers from attempting to shim the crypto module just because a require('crypto') call exists. (It is being used only in the random.js file, in a try/catch so that the crypto module gets used if available, but SJCL will still work without it.)

This solves three problems:

  1. Bundlers that do not automatically shim the crypto module will not produce missing dependency errors now.
  2. Bundlers that do automatically shim the crypto module will no longer do so, providing smaller final builds.
  3. Since SJCL is actually used in order to create shims of the crypto module, this eliminates some odd circular dependency issues. (In particular, the react-native-crypto shim ends up invoking SJCL through the react-native-randombytes module.)

This will fix issues #362 and #371.

RobertDaleSmith commented 4 years ago

@Nilos could we get a new release with this bug fix included? 🙏