Open tobowers opened 9 months ago
hmm, the mentioned code is coming from lib0/random
and uses the crypto API (https://nodejs.org/api/crypto.html#cryptogetrandomvaluestypedarray), which should be available since node v17. I've just tried this in node20 and node18, both works, just v16 fails.
hmm, the mentioned code is coming from
lib0/random
and uses the crypto API (https://nodejs.org/api/crypto.html#cryptogetrandomvaluestypedarray), which should be available since node v17. I've just tried this in node20 and node18, both works, just v16 fails.
The problem is "crypto" isn't imported.
I should note that I'm using the esm compiled code. I didn't check the cjs
@tobowers: Did you find a solution for this? @janthurau: I have the same problem in context with node18 and nuxt ssr...
Right it's a bug and no, I just locked our version at 2.9.0
@tobowers: Did you find a solution for this? @janthurau: I have the same problem in context with node18 and nuxt ssr...
It looks like node18 only has the crypto global if the --experimental-global-webcrypto flag is used (https://nodejs.org/docs/latest-v18.x/api/globals.html#crypto_1). In 20 it's global by default.
Need to check how to tell the bundler to add this import for backward compatibility 🤔
It looks like node18 only has the crypto global if the --experimental-global-webcrypto flag is used (https://nodejs.org/docs/latest-v18.x/api/globals.html#crypto_1). In 20 it's global by default.
Need to check how to tell the bundler to add this import for backward compatibility 🤔
I think you can just import crypto from "crypto"
at the top of the file?
Facing the same issue, pinned version to 2.9.0
for now
Description The compiled code in 2.10.0 of the provider has these lines:
crypto
does not appear in the 2.9.0 package.crypto is not defined in the global scope so a simple `import {...} from "@hocuspocus/provider" errors with "ReferenceError: crypto is not defined"
Steps to reproduce the bug Simply import 2.10.0 provider in a nodejs environment
Expected behavior Continue to work :).
Environment?
Additional context Add any other context about the problem here.