-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
expose Crypto.getRandomValues() or nodejs' crypto #725
Comments
Thanks for mentioning this, we're considering adding a shim layer to support more browserified libraries, this sounds like a good first step |
thanks for the update @na--
|
No, there's no outline anywhere yet, because we're not very familiar with browserify's requirements and first we'll have do a little research. There are also things we have to improve/fix that may be in babel's purview like this one. But hopefully we can greatly increase k6's compatibility with existing JS libraries without tremendous amounts of effort. Regarding faster crypto, we already expose Go's hashing functions in JS (docs), but as mentioned here, in the future we may actually expose the rest of the Go standard library crypto primitives in k6 as well. |
+1 for exposing the Go crypto primitives, that would be awesome! |
@andreiashu in #922 crypto.randomBytes was added. Is that sufficient for you ? |
I am closing this as crypto.randomBytes should be sufficient for the concrete use case |
@mstoykov i am still having this error I would appreciate knowing if there is a way to fix this error? a polyfill or exposing the |
@gimyboya as I eluded in the other issue, while While not impossible(probably) to make it work, you will basically need to do all those polyfills work yourself. You are very welcome to share it afterwords, but it's unlikely that it will be easy, and I don't know of someone who has done this work before. For this case -yes the Issue #2248 was made so we discuss if instead of implementing our own Additionally, looking at that API, I would expect that it will also want to make http requests at some point and that will also probably try to use I would expect you might have more questions, and as the issues here are mostly about bugs and feature requests I would recommend that you use the community forum, where we will also help you, but just won't be around (somewhat) unrelated issues ;) |
For anyone stumbling on this through a Google search or whatever: k6 has now exposed the (experimental) webcrypto module which is compatible with the browser Crypto API. So you can simply do now: import { crypto } from 'k6/experimental/webcrypto';
import * as uuid from 'uuid';
Object.assign(globalThis, { crypto }); Which works like a charm. :) |
first of all thanks for building such a great product! really enjoying working with k6 so far.
We need to sign messages using
rsa-sha256
. I've tried usingnode-rsa
(with browserify) but I'm getting a "Secure random number generation is not supported by this browser." error. This is because at the moment k6 does not exposeCrypto.getRandomValues()
.It would be great to get access to nodejs' native crypto module (or the equivalent functionality from Go's crypto library) since that would probably be faster.
But at the minimum exposing
Crypto.getRandomValues()
might just do the trick in the short term.The text was updated successfully, but these errors were encountered: