Code Monkey home page Code Monkey logo

Comments (18)

calvinmetcalf avatar calvinmetcalf commented on July 29, 2024 1

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.

bezreyhan avatar bezreyhan commented on July 29, 2024

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.

calvinmetcalf avatar calvinmetcalf commented on July 29, 2024

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.

bezreyhan avatar bezreyhan commented on July 29, 2024

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.

calvinmetcalf avatar calvinmetcalf commented on July 29, 2024

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.

calvinmetcalf avatar calvinmetcalf commented on July 29, 2024

er from coffeescript

from randombytes.

bezreyhan avatar bezreyhan commented on July 29, 2024

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.

bezreyhan avatar bezreyhan commented on July 29, 2024

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.

calvinmetcalf avatar calvinmetcalf commented on July 29, 2024

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#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


Reply to this email directly or view it on GitHub
#2 (comment)
.

from randombytes.

bezreyhan avatar bezreyhan commented on July 29, 2024

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.

dcousens avatar dcousens commented on July 29, 2024

@calvinmetcalf would it be more correct to use window over global?

from randombytes.

calvinmetcalf avatar calvinmetcalf commented on July 29, 2024

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.

bezreyhan avatar bezreyhan commented on July 29, 2024

@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.

dcousens avatar dcousens commented on July 29, 2024

@bezreyhan so the solution there is to just browserify everything!

from randombytes.

bezreyhan avatar bezreyhan commented on July 29, 2024

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.

dcousens avatar dcousens commented on July 29, 2024

@bezreyhan pass the necessary random data through a message?

from randombytes.

bezreyhan avatar bezreyhan commented on July 29, 2024

@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.

dcousens avatar dcousens commented on July 29, 2024

@bezreyhan don't forget to send a bug report to Mozilla :)

from randombytes.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.