@helia/verified-fetch 0.0.0-a04e041 → 0.0.0-dc2e7a6

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 (33) hide show
  1. package/README.md +0 -33
  2. package/dist/index.min.js +4 -4
  3. package/dist/src/index.d.ts +0 -36
  4. package/dist/src/index.d.ts.map +1 -1
  5. package/dist/src/index.js +0 -33
  6. package/dist/src/index.js.map +1 -1
  7. package/dist/src/utils/parse-url-string.d.ts +0 -2
  8. package/dist/src/utils/parse-url-string.d.ts.map +1 -1
  9. package/dist/src/utils/parse-url-string.js +0 -6
  10. package/dist/src/utils/parse-url-string.js.map +1 -1
  11. package/dist/src/verified-fetch.d.ts +15 -17
  12. package/dist/src/verified-fetch.d.ts.map +1 -1
  13. package/dist/src/verified-fetch.js +129 -211
  14. package/dist/src/verified-fetch.js.map +1 -1
  15. package/package.json +12 -18
  16. package/src/index.ts +0 -37
  17. package/src/utils/parse-url-string.ts +1 -11
  18. package/src/verified-fetch.ts +134 -237
  19. package/dist/src/utils/get-content-disposition-filename.d.ts +0 -6
  20. package/dist/src/utils/get-content-disposition-filename.d.ts.map +0 -1
  21. package/dist/src/utils/get-content-disposition-filename.js +0 -16
  22. package/dist/src/utils/get-content-disposition-filename.js.map +0 -1
  23. package/dist/src/utils/responses.d.ts +0 -4
  24. package/dist/src/utils/responses.d.ts.map +0 -1
  25. package/dist/src/utils/responses.js +0 -21
  26. package/dist/src/utils/responses.js.map +0 -1
  27. package/dist/src/utils/select-output-type.d.ts +0 -12
  28. package/dist/src/utils/select-output-type.d.ts.map +0 -1
  29. package/dist/src/utils/select-output-type.js +0 -147
  30. package/dist/src/utils/select-output-type.js.map +0 -1
  31. package/src/utils/get-content-disposition-filename.ts +0 -18
  32. package/src/utils/responses.ts +0 -22
  33. package/src/utils/select-output-type.ts +0 -166
package/README.md CHANGED
@@ -347,39 +347,6 @@ if (res.headers.get('Content-Type') === 'application/json') {
347
347
  console.info(obj) // ...
348
348
  ```
349
349
 
350
- ## The `Accept` header
351
-
352
- The `Accept` header can be passed to override certain response processing, or to ensure that the final `Content-Type` of the response is the one that is expected.
353
-
354
- If the final `Content-Type` does not match the `Accept` header, or if the content cannot be represented in the format dictated by the `Accept` header, or you have configured a custom content type parser, and that parser returns a value that isn't in the accept header, a [406: Not Acceptible](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/406) response will be returned:
355
-
356
- ```typescript
357
- import { verifiedFetch } from '@helia/verified-fetch'
358
-
359
- const res = await verifiedFetch('ipfs://bafyJPEGImageCID', {
360
- headers: {
361
- accept: 'image/png'
362
- }
363
- })
364
-
365
- console.info(res.status) // 406 - the image was a JPEG but we specified PNG as the accept header
366
- ```
367
-
368
- It can also be used to skip processing the data from some formats such as `DAG-CBOR` if you wish to handle decoding it yourself:
369
-
370
- ```typescript
371
- import { verifiedFetch } from '@helia/verified-fetch'
372
-
373
- const res = await verifiedFetch('ipfs://bafyDAGCBORCID', {
374
- headers: {
375
- accept: 'application/octet-stream'
376
- }
377
- })
378
-
379
- console.info(res.headers.get('accept')) // application/octet-stream
380
- const buf = await res.arrayBuffer() // raw bytes, not processed as JSON
381
- ```
382
-
383
350
  ## Comparison to fetch
384
351
 
385
352
  This module attempts to act as similarly to the `fetch()` API as possible.