Git Product home page Git Product logo

Comments (6)

skyrover7 avatar skyrover7 commented on July 28, 2024 1

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?

from tapscript.

cmdruid avatar cmdruid commented on July 28, 2024

Hello. This issue happens when you do not have the WebCrypto library or globalThis.crypto variable available. Please check the following:

  • If you are using node, that you are using v19+ of node.
  • If you are using a browser, that it supports globalThis (safari may have issues here)
  • If you are using a browser, that it is either https or 127.0.0.1 (some browsers disable crypto if they are running in an insecure context)

Let me know if this helps!

from tapscript.

skyrover7 avatar skyrover7 commented on July 28, 2024

@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

from tapscript.

cmdruid avatar cmdruid commented on July 28, 2024

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.

from tapscript.

skyrover7 avatar skyrover7 commented on July 28, 2024

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.

so does 19+ not include 19.0.0? that's where i am seeing this behavior

from tapscript.

cmdruid avatar cmdruid commented on July 28, 2024

/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?

from tapscript.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.