ipfs / helia-verified-fetch

A fetch-like API for obtaining verified & trustless IPFS CIDs on the web
https://npmjs.com/package/@helia/verified-fetch
Other
14 stars 4 forks source link

fix!: move dnsResolvers to options #13

Closed 2color closed 6 months ago

2color commented 7 months ago

Description

As per https://github.com/ipfs/helia/pull/445#issuecomment-1980812623, this PR changes the API of createVerifiedFetch so as to allow passing a custom instance of Helia (for example, with a custom blockstore) in addition to customising the dnsResolvers.

Notes & open questions

Change checklist

achingbrain commented 7 months ago

N.b. I renamed chore!: to fix!: in the issue title because we want a release from this - chore will not cause one but fix will.

achingbrain commented 6 months ago

I wonder if we could take this opportunity to make DNS resolvers more configurable in the stack.

Right now the other place we use DNS resolvers is in @multiformats/multiaddr to turn /dns/example.com into /ip4/123.123.123.123. We do this in browsers through hard-coded HTTP-DNS servers which are globally modifiable 🤮

I think we should:

  1. Refactor Multiaddr.resolve to take a list of resolvers or a resolver object*
  2. Use that in preference to the global list if passed
  3. Add it to the libp2p config and pass it/them to ma.resolve during dialing
  4. Add it to the Helia config and make it available as part of the Helia interface
  5. Refactor @helia/ipns to use the DNS resolvers from the Helia interface

* = a resolver object rather than a simple list might give us a bit of flexibility to accommodate things like tld-specific resolvers.

2color commented 6 months ago

Closing in favour of https://github.com/ipfs/helia-verified-fetch/pull/18