Comments (18)
works for me in chrome http://requirebin.com/?gist=41d322190bbf845b8a25
what exactly are you doing because the example you gave doesn't look like it's in javascript
from randombytes.
sorry about the confusion - I had pasted the coffee-script from my file. Also, the console.log was supposed to be on a separate line. I edited the issue.
I'm not sure what's causing the problem. I'm simply requiring the module like all the other modules I'm browserifying.
I also ran this check before the require statement and everything seems fine:
if(crypto && crypto.getRandomValues) {
console.log('hi'); // returns hi
}
from randombytes.
hm, so does the link above work for you? and are you able to open up dev tools and a put a break point in?
from randombytes.
yea it does. But I just tried running it again with global.crypto
and I got undefined
Maybe the coffee-script compiler is thrown off by that?
from randombytes.
yup I bet the compiler is seeing global and thinking you want to declare that variable, solution: compile to coffeescirpt then run program
from randombytes.
er from coffeescript
from randombytes.
Yea this is a coffee-script thing. I just tried it in a js repo and it worked fine.
Though, I am compiling to js before running it. Before I run it in the browser, I am browserifying the file with the coffeeify transformation. (I don't believe you can run plain coffee-script in the browser)
Should we change this file to search for the window
object instead if global
: https://github.com/crypto-browserify/randombytes/blob/master/browser.js#L3
Since this is a browser specific file it should be ok. This way we won't have to rely on browserify to set global
as an alias for window
from randombytes.
ok scratch what I said. I just started a coffee repo and ran through the same steps of requiring randombytes and running it through browserify and coffeeify. Everything worked fine. There must be something weird going on in my project. I'll try to see if I can figure
from randombytes.
As this can run in a worker too do window wouldn't work either. This is
something that you are doing that is going to break a lot of other
browserify code fyi you should probably make sure coffeeify is only running
on .coffee files
On Thu, Mar 26, 2015, 7:02 PM bezreyhan [email protected] wrote:
Yea this is a coffee-script thing. I just tried it in a js repo and it
worked fine.Though, I am compiling to js before running it. Before I run it in the
browser, I am browserifying the file with the coffeeify transformation. (I
don't believe you can run plain coffee-script in the browser)Should we change this file to search for the window object instead if
global:
https://github.com/crypto-browserify/randombytes/blob/master/browser.js#L3Since this is a browser specific file it should be ok. This way we won't
have to rely on browserify to set global as an alias for window—
Reply to this email directly or view it on GitHub
#2 (comment)
.
from randombytes.
All my files are written in coffee. I'm starting to think that this is not a coffee-script issue since when I created a new coffee repo and ran it through coffeeify, randombytes worked fine.
Am I understanding you correctly?
from randombytes.
@calvinmetcalf would it be more correct to use window
over global
?
from randombytes.
No global is the preferred way in browserify so it will work in a web
worker
On Thu, Mar 26, 2015, 9:56 PM Daniel Cousens [email protected]
wrote:
@calvinmetcalf https://github.com/calvinmetcalf would it be more
correct to use window over global?—
Reply to this email directly or view it on GitHub
#2 (comment)
.
from randombytes.
@calvinmetcalf so this issue was caused by a separate library that was not being browserified, but rather being loaded in through a script tag. That library exposed a global variable named "global", thus throwinf off how browserify aliases the window object. Nevertheless, thanks for the time and help.
from randombytes.
@bezreyhan so the solution there is to just browserify everything!
from randombytes.
It seems that Firefox's web workers have not yet implemented crypto. randombytes throws Uncaught Error: secure random number generation not supported by this browser use chrome, FireFox or Internet Explorer 11
in a Firefox web worker.
https://bugzilla.mozilla.org/show_bug.cgi?id=842818
I'm guessing there is not a way to get around this?
from randombytes.
@bezreyhan pass the necessary random data through a message?
from randombytes.
@dcousens yea, that's what I've resorted to. Was hoping I could leave it in the worker but it doesn't seem like its going to work out that way.
from randombytes.
@bezreyhan don't forget to send a bug report to Mozilla :)
from randombytes.
Related Issues (20)
- Buffer in browser HOT 3
- ES 6 module? HOT 4
- requested too many random bytes HOT 4
- how to shim randombytes? HOT 1
- Webpack 5 does not provide Buffer anymore HOT 1
- Replacing `global` (node only) with `globalThis` (cross-platform) HOT 3
- Hi, is it secure to use crypto random bytes to generate both access token and refresh token? HOT 2
- Remove buffer? HOT 2
- remove phantomjs
- global is replaced by globalThis? HOT 2
- simple-peer on sveltekit (uses Vite behind the scene) HOT 5
- Polyfill ignored in React App for crypto-browserify HOT 1
- Broken on SSR HOT 2
- Is this library still maintained? HOT 1
- Last version is not deployed HOT 1
- Implement browser getRandomValues without depending on crypto HOT 3
- Fails for me as Uncaught ReferenceError: global is not defined HOT 8
- secure random number generation not supported by this browser use chrome, FireFox or Internet Explorer 11 HOT 30
- Buffer.from is not a function HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from randombytes.