I’m at my wit’s end here. Is there any way to do this, knowing that web workers can’t access the window object? Please help!
I’m at my wit’s end here. Is there any way to do this, knowing
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There is no way to do this, seeing as the Crypto class and methods are “native code”, meaning they are implemented at a lower-level in the browser, so we can’t extract the code and move it somewhere else. I tried using Chrome’s Transferrable Objects object gets erased from current context and passed to worker, but that throws an error. I don’t think that the crypto api needs to be coupled to the DOM ( WebWorkers won’t touch the DOM as it isn’t thread-safe ), but I’ve never implemented crypto before. In Node, we have an async api, so to me, at least, it seems like it should be thread-safe.
http://cl.ly/image/0r0P3m3D2h07 <- Inspection of
window.cryptohttp://cl.ly/image/0G1G0F1Y0d3Z <- Example code for passing crypto to WebWorker throws.
I created a WebWorker script to verify, that maybe, just maybe, Chrome and Firefox just had different implementations, and unfortunately, I was mistaken.
I’ve sent an email to the authors of the W3C Web Crypto API Proposal, and you should as well. The draft seems to have a few open issues at this point, so it seems like it could change. Having either an async API or having the
cryptoAPI being available in Web Workers seems perfectly reasonable to me. Seems like a bad thing to have blocking the main event loop.