sjcl
sjcl copied to clipboard
namespace conflicts
When using the minified sjcl.js file, it appears the library is using a global variable named t.
To reproduce, open the following in a browser (assuming sjcl.js is on the same directory)
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="./sjcl.js"></script>
</head>
<body>
</body>
</html>
Then in the browser console try the following:
sjcl.encrypt("this","that")
{"iv":"NpkCTgNBgTFazbha/fgg8A==","v":1,"iter":1000,"ks":128,"ts":64,"mode":"ccm","adata":"","cipher":"aes","salt":"oZ6lThzs6hg=","ct":"icDzqhJv5gWSMhP0"}
t={}
Object {}
sjcl.encrypt("this","that")
TypeError: Cannot read property 'length' of undefined
This is most likely caused by the closure compiler who assigns true/false values to constants for faster referencing.
an easy fix would be adding a wrapper function around the full compiled library which just returns sjcl (and assigns it too).
I just noticed the same thing 🙈 Will this be fixed at some point? Its been over 5 years now ...