Closed shamoilarsi closed 1 year ago
Why not consider an approach like this instead?
if (typeof crypto === 'undefined') {
throw new Error('The crypto object is unavailable. This may occur if your environment does not support the Web Cryptography API.');
}
crypto.getRandomValues(bytes);
By directly referencing crypto
, the correct scope (window
or self
) will be selected based on the environment. This could remove the necessity of using a separate crypto package, while still ensuring we have the required functionality available.
NACK on adding crypto-js as a dep.
Since it's the entire PR, basically, I'm tempted to close unless you can come up with something better.
@junderw will try a different approach. converting the PR to draft till then
@landabaso yep that makes sense. I wasn't aware web workers have a crypto package as well which can be called with self
. thanks for the help :D
Please rebase. It will fix the broken CI test.
Published as v2.2.2
closes #111