Closed sondotpin closed 10 months ago
Hello. This issue happens when you do not have the WebCrypto library or globalThis.crypto variable available. Please check the following:
Let me know if this helps!
@cmdruid I am having the same issue, but only when running the node application from a hosted linux server.
on localhost (windows machine) I have no problem signing. works like a charm.
What's odd is that I am able to call the function from within server.js with var getRand = size => crypto.getRandomValues(new Uint8Array(size));
, which i use later in the code to generate the user's private keys. this works on the server. but when i go to sign, I am getting the same error as @sondotpin
any ideas? i tried removing the crypto 1.0.1 package install that I had so it defaults to the inbuilt one.
I am on node V19.0.0
in reference to #2 i made the change that was suggested there on our server and it worked!
great for now, but any thoughts on how/why this is happening?
What's odd is that I am able to call the function from within server.js with
var getRand = size => crypto.getRandomValues(new Uint8Array(size));
, which i use later in the code to generate the user's private keys. this works on the server. but when i go to sign, I am getting the same error as @sondotpin
Yes the crypto
object may be available. The library is using globalThis.crypto
to reference the crypto object so that it can bundle properly between nodejs and the browser. The caveat is that you have to use nodejs version 19+ or a modern browser that supports the new globalThis
standard.
The alternative is a nightmarish polyfill of the crypto
object and all sorts of hackery in order to get crypto
to bundle properly between platforms and nested deep as a dependency. I tried to go that route and it simply wasn't worth it. I'm open to alternative solutions though and improving backwards compatibility of the crypto
object.
What's odd is that I am able to call the function from within server.js with
var getRand = size => crypto.getRandomValues(new Uint8Array(size));
, which i use later in the code to generate the user's private keys. this works on the server. but when i go to sign, I am getting the same error as @sondotpinYes the
crypto
object may be available. The library is usingglobalThis.crypto
to reference the crypto object so that it can bundle properly between nodejs and the browser. The caveat is that you have to use nodejs version 19+ or a modern browser that supports the newglobalThis
standard.The alternative is a nightmarish polyfill of the
crypto
object and all sorts of hackery in order to getcrypto
to bundle properly between platforms and nested deep as a dependency. I tried to go that route and it simply wasn't worth it. I'm open to alternative solutions though and improving backwards compatibility of thecrypto
object.
so does 19+ not include 19.0.0? that's where i am seeing this behavior
/Users/sonpin/Documents/bitcoin/new/node_modules/@cmdcode/tapscript/dist/main.cjs
I'm wondering if maybe globalThis.crypto behaves differently when used in a commonjs import versus an ES6 import.
Are you importing into a commonjs project in node?
I've got this issue when sign