@helia/verified-fetch 1.1.2 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/README.md +24 -1
  2. package/dist/index.min.js +8 -19
  3. package/dist/src/index.d.ts +29 -4
  4. package/dist/src/index.d.ts.map +1 -1
  5. package/dist/src/index.js +41 -5
  6. package/dist/src/index.js.map +1 -1
  7. package/dist/src/types.d.ts +1 -0
  8. package/dist/src/types.d.ts.map +1 -1
  9. package/dist/src/utils/byte-range-context.d.ts +82 -0
  10. package/dist/src/utils/byte-range-context.d.ts.map +1 -0
  11. package/dist/src/utils/byte-range-context.js +275 -0
  12. package/dist/src/utils/byte-range-context.js.map +1 -0
  13. package/dist/src/utils/get-stream-from-async-iterable.js +1 -1
  14. package/dist/src/utils/parse-resource.d.ts +2 -2
  15. package/dist/src/utils/parse-url-string.d.ts +2 -2
  16. package/dist/src/utils/parse-url-string.d.ts.map +1 -1
  17. package/dist/src/utils/parse-url-string.js +5 -5
  18. package/dist/src/utils/parse-url-string.js.map +1 -1
  19. package/dist/src/utils/request-headers.d.ts +13 -0
  20. package/dist/src/utils/request-headers.d.ts.map +1 -0
  21. package/dist/src/utils/request-headers.js +50 -0
  22. package/dist/src/utils/request-headers.js.map +1 -0
  23. package/dist/src/utils/response-headers.d.ts +12 -0
  24. package/dist/src/utils/response-headers.d.ts.map +1 -0
  25. package/dist/src/utils/response-headers.js +29 -0
  26. package/dist/src/utils/response-headers.js.map +1 -0
  27. package/dist/src/utils/responses.d.ts +21 -4
  28. package/dist/src/utils/responses.d.ts.map +1 -1
  29. package/dist/src/utils/responses.js +58 -0
  30. package/dist/src/utils/responses.js.map +1 -1
  31. package/dist/src/verified-fetch.d.ts +2 -1
  32. package/dist/src/verified-fetch.d.ts.map +1 -1
  33. package/dist/src/verified-fetch.js +61 -25
  34. package/dist/src/verified-fetch.js.map +1 -1
  35. package/package.json +4 -3
  36. package/src/index.ts +49 -8
  37. package/src/types.ts +2 -0
  38. package/src/utils/byte-range-context.ts +303 -0
  39. package/src/utils/get-stream-from-async-iterable.ts +1 -1
  40. package/src/utils/parse-resource.ts +2 -2
  41. package/src/utils/parse-url-string.ts +7 -7
  42. package/src/utils/request-headers.ts +51 -0
  43. package/src/utils/response-headers.ts +32 -0
  44. package/src/utils/responses.ts +82 -4
  45. package/src/verified-fetch.ts +68 -29
package/README.md CHANGED
@@ -177,7 +177,7 @@ Note that you do not need to provide both a DNS-over-HTTPS and a DNS-over-JSON r
177
177
 
178
178
  ```typescript
179
179
  import { createVerifiedFetch } from '@helia/verified-fetch'
180
- import { dnsJsonOverHttps, dnsOverHttps } from '@helia/ipns/dns-resolvers'
180
+ import { dnsJsonOverHttps, dnsOverHttps } from '@multiformats/dns/resolvers'
181
181
 
182
182
  const fetch = await createVerifiedFetch({
183
183
  gateways: ['https://trustless-gateway.link'],
@@ -189,6 +189,29 @@ const fetch = await createVerifiedFetch({
189
189
  })
190
190
  ```
191
191
 
192
+ ## Example - Customizing DNS per-TLD resolvers
193
+
194
+ DNS resolvers can be configured to only service DNS queries for specific
195
+ TLDs:
196
+
197
+ ```typescript
198
+ import { createVerifiedFetch } from '@helia/verified-fetch'
199
+ import { dnsJsonOverHttps, dnsOverHttps } from '@multiformats/dns/resolvers'
200
+
201
+ const fetch = await createVerifiedFetch({
202
+ gateways: ['https://trustless-gateway.link'],
203
+ routers: ['http://delegated-ipfs.dev'],
204
+ dnsResolvers: {
205
+ // this resolver will only be used for `.com` domains (note - this could
206
+ // also be an array of resolvers)
207
+ 'com.': dnsJsonOverHttps('https://my-dns-resolver.example.com/dns-json'),
208
+ // this resolver will be used for everything else (note - this could
209
+ // also be an array of resolvers)
210
+ '.': dnsOverHttps('https://my-dns-resolver.example.com/dns-query')
211
+ }
212
+ })
213
+ ```
214
+
192
215
  ### IPLD codec handling
193
216
 
194
217
  IPFS supports several data formats (typically referred to as codecs) which are included in the CID. `@helia/verified-fetch` attempts to abstract away some of the details for easier consumption.