monero-ts icon indicating copy to clipboard operation
monero-ts copied to clipboard

Request and Request-Promise packages are deprecated

Open CryptoGrampy opened this issue 2 years ago • 8 comments

Just noticed these packages are deprecated. Not sure if this is possible, but there is a native 'fetch' API that's NodeJS 18+ compatible: https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API and https://blog.logrocket.com/fetch-api-node-js/ that might be nice to use as it's native for browser/Node and doesn't require any extra packages (and allows us to remove packages from monero-javascript!) , but Axios is also a very good, popular and full-featured request library.

CryptoGrampy avatar Jun 24 '22 18:06 CryptoGrampy

  1. Firefox native fetch still doesn't support digest auth, required by Monero.
  2. Moving beyond Node.js LTS version seems like a really bad idea.
  3. Something like undici is probably a better choice, as it's the thingy implemented in Node.js 16.5+ (experimental). It's not for the browser though, so Axios seems like a decent alternative.

trasherdk avatar Jun 25 '22 04:06 trasherdk

Definitely agree on the LTS subject, just important to acknowledge that this will be a built in feature down the road. I'm a big fan of the axios lib, personally.

CryptoGrampy avatar Jun 25 '22 05:06 CryptoGrampy

@CryptoGrampy did you try debug/tracing what's going on below the surface, during requests?

Getting rid of browser fetch was not a simple task, if memory serves me. Other than that, I agree. Getting rid of those deprecation warnings would be nice.

trasherdk avatar Jun 27 '22 02:06 trasherdk

@trasherdk @CryptoGrampy I can try and take care of this issue if needed, with either axios or node-fetch. Personally I've used node fetch just for simplicity and standardizing the fetch calls. But can use axios if needed.

Let me know what progress you've made on this and I will try to dig farther from the point you left off.

47Key avatar Jul 11 '22 16:07 47Key

@trasherdk - I haven't dug into this at all beyond noticing that the library being used isn't supported anymore. @47Key - Monero-Javascript is used from both nodejs as well as browser context, so any library used should support both; for that reason, Axios is probably the best modern request library to go with until the fetch API for node matures.

CryptoGrampy avatar Jul 14 '22 04:07 CryptoGrampy

@CryptoGrampy On it, any unit tests or guidelines I should adhere too before finishing?

47Key avatar Jul 16 '22 19:07 47Key

@CryptoGrampy The problem is Firefox native fetch() have a broken digest authentication. Chrome was OK. And under the hood, the request logic is very complex. I have single-stepped this thing many times and Oh boy, it'll make your head spin.

@47Key Looking forward to see what you come up with :smiley:

trasherdk avatar Jul 18 '22 04:07 trasherdk

If anyone wants to help with this issue, HttpClient.ts just needs to be updated to support the dependencies.

woodser avatar Nov 21 '23 12:11 woodser