@helia/verified-fetch 4.0.3 → 4.0.4

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 (44) hide show
  1. package/dist/index.min.js +69 -63
  2. package/dist/index.min.js.map +4 -4
  3. package/dist/src/constants.d.ts +1 -0
  4. package/dist/src/constants.d.ts.map +1 -1
  5. package/dist/src/constants.js +1 -0
  6. package/dist/src/constants.js.map +1 -1
  7. package/dist/src/plugins/plugin-handle-cbor.d.ts +17 -0
  8. package/dist/src/plugins/plugin-handle-cbor.d.ts.map +1 -0
  9. package/dist/src/plugins/plugin-handle-cbor.js +94 -0
  10. package/dist/src/plugins/plugin-handle-cbor.js.map +1 -0
  11. package/dist/src/plugins/plugin-handle-dag-cbor.d.ts.map +1 -1
  12. package/dist/src/plugins/plugin-handle-dag-cbor.js +16 -27
  13. package/dist/src/plugins/plugin-handle-dag-cbor.js.map +1 -1
  14. package/dist/src/plugins/plugin-handle-dag-walk.d.ts.map +1 -1
  15. package/dist/src/plugins/plugin-handle-dag-walk.js +52 -7
  16. package/dist/src/plugins/plugin-handle-dag-walk.js.map +1 -1
  17. package/dist/src/plugins/plugin-handle-json.d.ts.map +1 -1
  18. package/dist/src/plugins/plugin-handle-json.js +5 -3
  19. package/dist/src/plugins/plugin-handle-json.js.map +1 -1
  20. package/dist/src/utils/byte-range-context.js +1 -1
  21. package/dist/src/utils/byte-range-context.js.map +1 -1
  22. package/dist/src/utils/dag-cbor-to-safe-json.d.ts +8 -0
  23. package/dist/src/utils/dag-cbor-to-safe-json.d.ts.map +1 -1
  24. package/dist/src/utils/dag-cbor-to-safe-json.js +46 -17
  25. package/dist/src/utils/dag-cbor-to-safe-json.js.map +1 -1
  26. package/dist/src/utils/get-content-type.js +1 -1
  27. package/dist/src/utils/get-content-type.js.map +1 -1
  28. package/dist/src/utils/select-output-type.d.ts.map +1 -1
  29. package/dist/src/utils/select-output-type.js +13 -1
  30. package/dist/src/utils/select-output-type.js.map +1 -1
  31. package/dist/src/verified-fetch.d.ts.map +1 -1
  32. package/dist/src/verified-fetch.js +4 -2
  33. package/dist/src/verified-fetch.js.map +1 -1
  34. package/package.json +4 -4
  35. package/src/constants.ts +1 -0
  36. package/src/plugins/plugin-handle-cbor.ts +107 -0
  37. package/src/plugins/plugin-handle-dag-cbor.ts +17 -27
  38. package/src/plugins/plugin-handle-dag-walk.ts +56 -7
  39. package/src/plugins/plugin-handle-json.ts +5 -3
  40. package/src/utils/byte-range-context.ts +1 -1
  41. package/src/utils/dag-cbor-to-safe-json.ts +55 -19
  42. package/src/utils/get-content-type.ts +1 -1
  43. package/src/utils/select-output-type.ts +13 -1
  44. package/src/verified-fetch.ts +4 -2
@@ -5,6 +5,7 @@ import { CustomProgressEvent } from 'progress-events'
5
5
  import QuickLRU from 'quick-lru'
6
6
  import { ByteRangeContextPlugin } from './plugins/plugin-handle-byte-range-context.js'
7
7
  import { CarPlugin } from './plugins/plugin-handle-car.js'
8
+ import { CborPlugin } from './plugins/plugin-handle-cbor.js'
8
9
  import { DagCborPlugin } from './plugins/plugin-handle-dag-cbor.js'
9
10
  import { DagPbPlugin } from './plugins/plugin-handle-dag-pb.js'
10
11
  import { DagWalkPlugin } from './plugins/plugin-handle-dag-walk.js'
@@ -99,7 +100,8 @@ export class VerifiedFetch {
99
100
  new TarPlugin(pluginOptions),
100
101
  new JsonPlugin(pluginOptions),
101
102
  new DagCborPlugin(pluginOptions),
102
- new DagPbPlugin(pluginOptions)
103
+ new DagPbPlugin(pluginOptions),
104
+ new CborPlugin(pluginOptions)
103
105
  ]
104
106
 
105
107
  const customPlugins = init.plugins?.map((pluginFactory) => pluginFactory(pluginOptions)) ?? []
@@ -245,7 +247,7 @@ export class VerifiedFetch {
245
247
  this.log(`starting pipeline pass #${passCount + 1}`)
246
248
  passCount++
247
249
 
248
- this.log.trace('checking which plugins can handle %c%s with accept %o', context.cid, context.path != null ? `/${context.path}` : '', context.accept)
250
+ this.log.trace('checking which plugins can handle %c%s with accept %o', context.cid, context.path.length > 0 ? `/${context.path.join('/')}` : '', context.accept)
249
251
 
250
252
  // gather plugins that say they can handle the *current* context, but haven't been used yet
251
253
  const readyPlugins = this.plugins.filter(p => !pluginsUsed.has(p.id)).filter(p => p.canHandle(context))