@helia/verified-fetch 2.3.1 → 2.5.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 (119) hide show
  1. package/README.md +200 -0
  2. package/dist/index.min.js +357 -35
  3. package/dist/src/index.d.ts +220 -0
  4. package/dist/src/index.d.ts.map +1 -1
  5. package/dist/src/index.js +200 -0
  6. package/dist/src/index.js.map +1 -1
  7. package/dist/src/plugins/errors.d.ts +25 -0
  8. package/dist/src/plugins/errors.d.ts.map +1 -0
  9. package/dist/src/plugins/errors.js +33 -0
  10. package/dist/src/plugins/errors.js.map +1 -0
  11. package/dist/src/plugins/index.d.ts +8 -0
  12. package/dist/src/plugins/index.d.ts.map +1 -0
  13. package/dist/src/plugins/index.js +7 -0
  14. package/dist/src/plugins/index.js.map +1 -0
  15. package/dist/src/plugins/plugin-base.d.ts +19 -0
  16. package/dist/src/plugins/plugin-base.d.ts.map +1 -0
  17. package/dist/src/plugins/plugin-base.js +26 -0
  18. package/dist/src/plugins/plugin-base.js.map +1 -0
  19. package/dist/src/plugins/plugin-handle-car.d.ts +11 -0
  20. package/dist/src/plugins/plugin-handle-car.d.ts.map +1 -0
  21. package/dist/src/plugins/plugin-handle-car.js +28 -0
  22. package/dist/src/plugins/plugin-handle-car.js.map +1 -0
  23. package/dist/src/plugins/plugin-handle-dag-cbor.d.ts +11 -0
  24. package/dist/src/plugins/plugin-handle-dag-cbor.d.ts.map +1 -0
  25. package/dist/src/plugins/plugin-handle-dag-cbor.js +73 -0
  26. package/dist/src/plugins/plugin-handle-dag-cbor.js.map +1 -0
  27. package/dist/src/plugins/plugin-handle-dag-pb.d.ts +15 -0
  28. package/dist/src/plugins/plugin-handle-dag-pb.d.ts.map +1 -0
  29. package/dist/src/plugins/plugin-handle-dag-pb.js +152 -0
  30. package/dist/src/plugins/plugin-handle-dag-pb.js.map +1 -0
  31. package/dist/src/plugins/plugin-handle-dag-walk.d.ts +16 -0
  32. package/dist/src/plugins/plugin-handle-dag-walk.d.ts.map +1 -0
  33. package/dist/src/plugins/plugin-handle-dag-walk.js +45 -0
  34. package/dist/src/plugins/plugin-handle-dag-walk.js.map +1 -0
  35. package/dist/src/plugins/plugin-handle-dir-index-html.d.ts +9 -0
  36. package/dist/src/plugins/plugin-handle-dir-index-html.d.ts.map +1 -0
  37. package/dist/src/plugins/plugin-handle-dir-index-html.js +37 -0
  38. package/dist/src/plugins/plugin-handle-dir-index-html.js.map +1 -0
  39. package/dist/src/plugins/plugin-handle-ipns-record.d.ts +12 -0
  40. package/dist/src/plugins/plugin-handle-ipns-record.d.ts.map +1 -0
  41. package/dist/src/plugins/plugin-handle-ipns-record.js +62 -0
  42. package/dist/src/plugins/plugin-handle-ipns-record.js.map +1 -0
  43. package/dist/src/plugins/plugin-handle-json.d.ts +11 -0
  44. package/dist/src/plugins/plugin-handle-json.d.ts.map +1 -0
  45. package/dist/src/plugins/plugin-handle-json.js +51 -0
  46. package/dist/src/plugins/plugin-handle-json.js.map +1 -0
  47. package/dist/src/plugins/plugin-handle-raw.d.ts +8 -0
  48. package/dist/src/plugins/plugin-handle-raw.d.ts.map +1 -0
  49. package/dist/src/plugins/plugin-handle-raw.js +80 -0
  50. package/dist/src/plugins/plugin-handle-raw.js.map +1 -0
  51. package/dist/src/plugins/plugin-handle-tar.d.ts +12 -0
  52. package/dist/src/plugins/plugin-handle-tar.d.ts.map +1 -0
  53. package/dist/src/plugins/plugin-handle-tar.js +36 -0
  54. package/dist/src/plugins/plugin-handle-tar.js.map +1 -0
  55. package/dist/src/plugins/plugins.d.ts +5 -0
  56. package/dist/src/plugins/plugins.d.ts.map +1 -0
  57. package/dist/src/plugins/plugins.js +5 -0
  58. package/dist/src/plugins/plugins.js.map +1 -0
  59. package/dist/src/plugins/types.d.ts +68 -0
  60. package/dist/src/plugins/types.d.ts.map +1 -0
  61. package/dist/src/plugins/types.js +2 -0
  62. package/dist/src/plugins/types.js.map +1 -0
  63. package/dist/src/types.d.ts +0 -23
  64. package/dist/src/types.d.ts.map +1 -1
  65. package/dist/src/types.js +1 -2
  66. package/dist/src/types.js.map +1 -1
  67. package/dist/src/utils/dir-index-html.d.ts +16 -0
  68. package/dist/src/utils/dir-index-html.d.ts.map +1 -0
  69. package/dist/src/utils/dir-index-html.js +387 -0
  70. package/dist/src/utils/dir-index-html.js.map +1 -0
  71. package/dist/src/utils/get-e-tag.d.ts +1 -1
  72. package/dist/src/utils/get-e-tag.d.ts.map +1 -1
  73. package/dist/src/utils/get-e-tag.js +18 -3
  74. package/dist/src/utils/get-e-tag.js.map +1 -1
  75. package/dist/src/utils/parse-resource.d.ts +2 -1
  76. package/dist/src/utils/parse-resource.d.ts.map +1 -1
  77. package/dist/src/utils/parse-resource.js +4 -3
  78. package/dist/src/utils/parse-resource.js.map +1 -1
  79. package/dist/src/utils/parse-url-string.d.ts +8 -3
  80. package/dist/src/utils/parse-url-string.d.ts.map +1 -1
  81. package/dist/src/utils/parse-url-string.js +30 -4
  82. package/dist/src/utils/parse-url-string.js.map +1 -1
  83. package/dist/src/utils/server-timing.d.ts +13 -0
  84. package/dist/src/utils/server-timing.d.ts.map +1 -0
  85. package/dist/src/utils/server-timing.js +19 -0
  86. package/dist/src/utils/server-timing.js.map +1 -0
  87. package/dist/src/utils/walk-path.d.ts +3 -2
  88. package/dist/src/utils/walk-path.d.ts.map +1 -1
  89. package/dist/src/utils/walk-path.js +1 -1
  90. package/dist/src/utils/walk-path.js.map +1 -1
  91. package/dist/src/verified-fetch.d.ts +11 -20
  92. package/dist/src/verified-fetch.d.ts.map +1 -1
  93. package/dist/src/verified-fetch.js +174 -367
  94. package/dist/src/verified-fetch.js.map +1 -1
  95. package/dist/typedoc-urls.json +32 -24
  96. package/package.json +6 -2
  97. package/src/index.ts +223 -0
  98. package/src/plugins/errors.ts +37 -0
  99. package/src/plugins/index.ts +8 -0
  100. package/src/plugins/plugin-base.ts +30 -0
  101. package/src/plugins/plugin-handle-car.ts +32 -0
  102. package/src/plugins/plugin-handle-dag-cbor.ts +84 -0
  103. package/src/plugins/plugin-handle-dag-pb.ts +168 -0
  104. package/src/plugins/plugin-handle-dag-walk.ts +53 -0
  105. package/src/plugins/plugin-handle-dir-index-html.ts +44 -0
  106. package/src/plugins/plugin-handle-ipns-record.ts +69 -0
  107. package/src/plugins/plugin-handle-json.ts +57 -0
  108. package/src/plugins/plugin-handle-raw.ts +92 -0
  109. package/src/plugins/plugin-handle-tar.ts +44 -0
  110. package/src/plugins/plugins.ts +4 -0
  111. package/src/plugins/types.ts +73 -0
  112. package/src/types.ts +0 -29
  113. package/src/utils/dir-index-html.ts +445 -0
  114. package/src/utils/get-e-tag.ts +20 -3
  115. package/src/utils/parse-resource.ts +5 -4
  116. package/src/utils/parse-url-string.ts +38 -7
  117. package/src/utils/server-timing.ts +37 -0
  118. package/src/utils/walk-path.ts +3 -3
  119. package/src/verified-fetch.ts +198 -403
@@ -1 +1 @@
1
- {"version":3,"file":"verified-fetch.js","sourceRoot":"","sources":["../../src/verified-fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAA;AAChC,OAAO,EAAE,IAAI,IAAI,SAAS,EAAa,MAAM,aAAa,CAAA;AAC1D,OAAO,KAAK,WAAW,MAAM,gBAAgB,CAAA;AAC7C,OAAO,KAAK,WAAW,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,IAAI,IAAI,SAAS,EAAE,MAAM,cAAc,CAAA;AAChD,OAAO,EAA+C,MAAM,mBAAmB,CAAA;AAC/E,OAAO,EAAE,MAAM,IAAI,SAAS,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAA;AACzC,OAAO,EAAE,QAAQ,EAAmB,MAAM,sBAAsB,CAAA;AAChE,OAAO,uBAAuB,MAAM,8BAA8B,CAAA;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AACpC,OAAO,EAAY,MAAM,kBAAk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IAED;;OAEG;IACH,KAAK,CAAC,KAAK;QACT,MAAM,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;IAC1B,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,IAAI;QACR,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAA;IACzB,CAAC;CACF"}
@@ -1,26 +1,34 @@
1
1
  {
2
- "CIDDetail": "https://ipfs.github.io/helia-verified-fetch/interfaces/CIDDetail.html",
3
- ".:CIDDetail": "https://ipfs.github.io/helia-verified-fetch/interfaces/CIDDetail.html",
4
- "CIDDetailError": "https://ipfs.github.io/helia-verified-fetch/interfaces/CIDDetailError.html",
5
- ".:CIDDetailError": "https://ipfs.github.io/helia-verified-fetch/interfaces/CIDDetailError.html",
6
- "ContentTypeParser": "https://ipfs.github.io/helia-verified-fetch/interfaces/ContentTypeParser.html",
7
- "CreateVerifiedFetchInit": "https://ipfs.github.io/helia-verified-fetch/interfaces/CreateVerifiedFetchInit.html",
8
- ".:CreateVerifiedFetchInit": "https://ipfs.github.io/helia-verified-fetch/interfaces/CreateVerifiedFetchInit.html",
9
- "CreateVerifiedFetchOptions": "https://ipfs.github.io/helia-verified-fetch/interfaces/CreateVerifiedFetchOptions.html",
10
- ".:CreateVerifiedFetchOptions": "https://ipfs.github.io/helia-verified-fetch/interfaces/CreateVerifiedFetchOptions.html",
11
- "ResourceDetail": "https://ipfs.github.io/helia-verified-fetch/interfaces/ResourceDetail.html",
12
- ".:ResourceDetail": "https://ipfs.github.io/helia-verified-fetch/interfaces/ResourceDetail.html",
13
- "VerifiedFetch": "https://ipfs.github.io/helia-verified-fetch/interfaces/VerifiedFetch.html",
14
- ".:VerifiedFetch": "https://ipfs.github.io/helia-verified-fetch/interfaces/VerifiedFetch.html",
15
- "VerifiedFetchInit": "https://ipfs.github.io/helia-verified-fetch/interfaces/VerifiedFetchInit.html",
16
- ".:VerifiedFetchInit": "https://ipfs.github.io/helia-verified-fetch/interfaces/VerifiedFetchInit.html",
17
- "BubbledProgressEvents": "https://ipfs.github.io/helia-verified-fetch/types/BubbledProgressEvents.html",
18
- ".:BubbledProgressEvents": "https://ipfs.github.io/helia-verified-fetch/types/BubbledProgressEvents.html",
19
- "Resource": "https://ipfs.github.io/helia-verified-fetch/types/Resource.html",
20
- ".:Resource": "https://ipfs.github.io/helia-verified-fetch/types/Resource.html",
21
- "VerifiedFetchProgressEvents": "https://ipfs.github.io/helia-verified-fetch/types/VerifiedFetchProgressEvents.html",
22
- ".:VerifiedFetchProgressEvents": "https://ipfs.github.io/helia-verified-fetch/types/VerifiedFetchProgressEvents.html",
23
- "createVerifiedFetch": "https://ipfs.github.io/helia-verified-fetch/functions/createVerifiedFetch.html",
24
- ".:createVerifiedFetch": "https://ipfs.github.io/helia-verified-fetch/functions/createVerifiedFetch.html",
25
- "verifiedFetch": "https://ipfs.github.io/helia-verified-fetch/functions/verifiedFetch-1.html"
2
+ "BasePlugin": "https://ipfs.github.io/helia-verified-fetch/classes/index.BasePlugin.html",
3
+ "DirIndexHtmlPlugin": "https://ipfs.github.io/helia-verified-fetch/classes/index.DirIndexHtmlPlugin.html",
4
+ "PluginError": "https://ipfs.github.io/helia-verified-fetch/classes/index.PluginError.html",
5
+ "PluginFatalError": "https://ipfs.github.io/helia-verified-fetch/classes/index.PluginFatalError.html",
6
+ "CIDDetail": "https://ipfs.github.io/helia-verified-fetch/interfaces/index.CIDDetail.html",
7
+ ".:CIDDetail": "https://ipfs.github.io/helia-verified-fetch/interfaces/index.CIDDetail.html",
8
+ "CIDDetailError": "https://ipfs.github.io/helia-verified-fetch/interfaces/index.CIDDetailError.html",
9
+ ".:CIDDetailError": "https://ipfs.github.io/helia-verified-fetch/interfaces/index.CIDDetailError.html",
10
+ "ContentTypeParser": "https://ipfs.github.io/helia-verified-fetch/interfaces/index.ContentTypeParser.html",
11
+ "CreateVerifiedFetchInit": "https://ipfs.github.io/helia-verified-fetch/interfaces/index.CreateVerifiedFetchInit.html",
12
+ ".:CreateVerifiedFetchInit": "https://ipfs.github.io/helia-verified-fetch/interfaces/index.CreateVerifiedFetchInit.html",
13
+ "CreateVerifiedFetchOptions": "https://ipfs.github.io/helia-verified-fetch/interfaces/index.CreateVerifiedFetchOptions.html",
14
+ ".:CreateVerifiedFetchOptions": "https://ipfs.github.io/helia-verified-fetch/interfaces/index.CreateVerifiedFetchOptions.html",
15
+ "PluginContext": "https://ipfs.github.io/helia-verified-fetch/interfaces/index.PluginContext.html",
16
+ "PluginOptions": "https://ipfs.github.io/helia-verified-fetch/interfaces/index.PluginOptions.html",
17
+ "ResourceDetail": "https://ipfs.github.io/helia-verified-fetch/interfaces/index.ResourceDetail.html",
18
+ ".:ResourceDetail": "https://ipfs.github.io/helia-verified-fetch/interfaces/index.ResourceDetail.html",
19
+ "VerifiedFetch": "https://ipfs.github.io/helia-verified-fetch/interfaces/index.VerifiedFetch.html",
20
+ ".:VerifiedFetch": "https://ipfs.github.io/helia-verified-fetch/interfaces/index.VerifiedFetch.html",
21
+ "VerifiedFetchInit": "https://ipfs.github.io/helia-verified-fetch/interfaces/index.VerifiedFetchInit.html",
22
+ ".:VerifiedFetchInit": "https://ipfs.github.io/helia-verified-fetch/interfaces/index.VerifiedFetchInit.html",
23
+ "VerifiedFetchPluginFactory": "https://ipfs.github.io/helia-verified-fetch/interfaces/index.VerifiedFetchPluginFactory.html",
24
+ "BubbledProgressEvents": "https://ipfs.github.io/helia-verified-fetch/types/index.BubbledProgressEvents.html",
25
+ ".:BubbledProgressEvents": "https://ipfs.github.io/helia-verified-fetch/types/index.BubbledProgressEvents.html",
26
+ "Resource": "https://ipfs.github.io/helia-verified-fetch/types/index.Resource.html",
27
+ ".:Resource": "https://ipfs.github.io/helia-verified-fetch/types/index.Resource.html",
28
+ "VerifiedFetchProgressEvents": "https://ipfs.github.io/helia-verified-fetch/types/index.VerifiedFetchProgressEvents.html",
29
+ ".:VerifiedFetchProgressEvents": "https://ipfs.github.io/helia-verified-fetch/types/index.VerifiedFetchProgressEvents.html",
30
+ "createVerifiedFetch": "https://ipfs.github.io/helia-verified-fetch/functions/index.createVerifiedFetch.html",
31
+ ".:createVerifiedFetch": "https://ipfs.github.io/helia-verified-fetch/functions/index.createVerifiedFetch.html",
32
+ "dirIndexHtmlPluginFactory": "https://ipfs.github.io/helia-verified-fetch/functions/index.dirIndexHtmlPluginFactory.html",
33
+ "verifiedFetch": "https://ipfs.github.io/helia-verified-fetch/functions/index.verifiedFetch-1.html"
26
34
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@helia/verified-fetch",
3
- "version": "2.3.1",
3
+ "version": "2.5.0",
4
4
  "description": "A fetch-like API for obtaining verified & trustless IPFS content on the web",
5
5
  "license": "Apache-2.0 OR MIT",
6
6
  "homepage": "https://github.com/ipfs/helia-verified-fetch/tree/main/packages/verified-fetch#readme",
@@ -32,6 +32,10 @@
32
32
  ".": {
33
33
  "types": "./dist/src/index.d.ts",
34
34
  "import": "./dist/src/index.js"
35
+ },
36
+ "./plugins": {
37
+ "types": "./dist/src/plugins/plugins.d.ts",
38
+ "import": "./dist/src/plugins/plugins.js"
35
39
  }
36
40
  },
37
41
  "eslintConfig": {
@@ -155,6 +159,7 @@
155
159
  "@ipld/dag-pb": "^4.1.2",
156
160
  "@libp2p/interface": "^2.2.1",
157
161
  "@libp2p/kad-dht": "^14.1.3",
162
+ "@libp2p/logger": "^5.1.6",
158
163
  "@libp2p/peer-id": "^5.0.8",
159
164
  "@libp2p/webrtc": "^5.0.16",
160
165
  "@libp2p/websockets": "^9.0.11",
@@ -183,7 +188,6 @@
183
188
  "@helia/json": "^4.0.1",
184
189
  "@ipld/car": "^5.3.2",
185
190
  "@libp2p/crypto": "^5.0.7",
186
- "@libp2p/logger": "^5.1.4",
187
191
  "@sgtpooki/file-type": "^1.0.1",
188
192
  "@types/sinon": "^17.0.3",
189
193
  "aegir": "^45.0.8",
package/src/index.ts CHANGED
@@ -604,6 +604,14 @@
604
604
  * * https://specs.ipfs.tech/http-gateways/trustless-gateway/#response-headers
605
605
  * * https://specs.ipfs.tech/http-gateways/subdomain-gateway/#response-headers
606
606
  *
607
+ * #### Server Timing headers
608
+ *
609
+ * By default, we do not include [Server Timing](https://developer.mozilla.org/en-US/docs/Web/API/Performance_API/Server_timing) headers in responses. If you want to include them, you can pass an
610
+ * `withServerTiming` option to the `createVerifiedFetch` function to include them in all future responses. You can
611
+ * also pass the `withServerTiming` option to each fetch call to include them only for that specific response.
612
+ *
613
+ * See PR where this was added, https://github.com/ipfs/helia-verified-fetch/pull/164, for more information.
614
+ *
607
615
  * ### Possible Scenarios that could cause confusion
608
616
  *
609
617
  * #### Attempting to fetch the CID for content that does not make sense
@@ -618,6 +626,197 @@
618
626
  * 2. `TypeError` - If the options argument is passed and not an object.
619
627
  * 3. `TypeError` - If the options argument is passed and is malformed.
620
628
  * 4. `AbortError` - If the content request is aborted due to user aborting provided AbortSignal. Note that this is a `AbortError` from `@libp2p/interface` and not the standard `AbortError` from the Fetch API.
629
+ *
630
+ * ## Pluggability and Extensibility
631
+ *
632
+ * Verified‑fetch can now be extended to alter how it handles requests by using plugins.
633
+ * Plugins are classes that extend the `BasePlugin` class and implement the `VerifiedFetchPlugin`
634
+ * interface. They are instantiated with `PluginOptions` when the `VerifiedFetch` class is created.
635
+ *
636
+ * Each plugin must implement two methods:
637
+ *
638
+ * - **`canHandle(context: PluginContext): boolean`**
639
+ * Inspects the current `PluginContext` (which includes the CID, path, query, accept header, etc.)
640
+ * and returns `true` if the plugin can operate on the current state of the request.
641
+ *
642
+ * - **`handle(context: PluginContext): Promise<Response | null>`**
643
+ * Performs the plugin’s work. It may:
644
+ * - **Return a final `Response`**: This stops the pipeline immediately.
645
+ * - **Return `null`**: This indicates that the plugin has only partially processed the request
646
+ * (for example, by performing path walking or decoding) and the pipeline should continue.
647
+ * - **Throw a `PluginError`**: This logs a non-fatal error and continues the pipeline.
648
+ * - **Throw a `PluginFatalError`**: This logs a fatal error and stops the pipeline immediately.
649
+ *
650
+ * Plugins are executed in a chain (a **plugin pipeline**):
651
+ *
652
+ * 1. **Initialization:**
653
+ * - The `VerifiedFetch` class is instantiated with a list of plugins.
654
+ * - When a request is made via the `fetch` method, the resource and options are parsed to
655
+ * create a mutable `PluginContext` object.
656
+ *
657
+ * 2. **Pipeline Execution:**
658
+ * - The pipeline repeatedly checks, up to a maximum number of passes (default = 3), which plugins
659
+ * are currently able to handle the request by calling each plugin’s `canHandle()` method.
660
+ * - Plugins that have not yet been called in the current run and return `true` for `canHandle()`
661
+ * are invoked in sequence.
662
+ * - If a plugin returns a final `Response` or throws a `PluginFatalError`, the pipeline immediately
663
+ * stops and that response is returned.
664
+ * - If a plugin returns `null`, it may have updated the context (for example, by
665
+ * performing path walking), other plugins that said they `canHandle` will run.
666
+ * - If no plugin modifies the context (i.e. no change to `context.modified`) and no final response is
667
+ * produced after iterating through all plugins, the pipeline exits and a default “Not Supported”
668
+ * response is returned.
669
+ *
670
+ * **Diagram of the Plugin Pipeline:**
671
+ *
672
+ * ```mermaid
673
+ * flowchart TD
674
+ * A[Resource & Options] --> B[Parse into PluginContext]
675
+ * B --> C[Plugin Pipeline]
676
+ * subgraph IP[Iterative Passes max 3 passes]
677
+ * C1[Check canHandle for each plugin]
678
+ * C2[Call handle on ready plugins]
679
+ * C3[Update PluginContext if partial work is done]
680
+ * C1 --> C2
681
+ * C2 --> C3
682
+ * end
683
+ * C --> IP
684
+ * IP --> D[Final Response]
685
+ * ```
686
+ *
687
+ * 3. **Finalization:**
688
+ * - After the pipeline completes, the resulting response & context is processed (e.g. headers such as ETag,
689
+ * Cache‑Control, and Content‑Disposition are set) and returned.
690
+ *
691
+ * Please see the original discussion on extensibility in [Issue #167](https://github.com/ipfs/helia-verified-fetch/issues/167).
692
+ *
693
+ * ---
694
+ *
695
+ * ### Extending Verified‑Fetch with Custom Plugins
696
+ *
697
+ * To add your own plugin:
698
+ *
699
+ * 1. **Extend the BasePlugin:**
700
+ *
701
+ * Create a new class that extends `BasePlugin` and implements:
702
+ *
703
+ * - `canHandle(context: PluginContext): boolean`
704
+ * - `handle(context: PluginContext): Promise<Response | null>`
705
+ *
706
+ * @example custom plugin
707
+ *
708
+ * ```typescript
709
+ * import { BasePlugin, type PluginContext, type VerifiedFetchPluginFactory, type PluginOptions } from '@helia/verified-fetch'
710
+ * import { okResponse } from './dist/src/utils/responses.js'
711
+ *
712
+ * export class MyCustomPlugin extends BasePlugin {
713
+ * // Optionally, list any codec codes your plugin supports:
714
+ * codes = [] //
715
+ *
716
+ * canHandle(context: PluginContext): boolean {
717
+ * // Only handle requests if the Accept header matches your custom type
718
+ * // Or check context for pathDetails, custom values, etc...
719
+ * return context.accept === 'application/vnd.my-custom-type'
720
+ * }
721
+ *
722
+ * async handle(context: PluginContext): Promise<Response | null> {
723
+ * // Perform any partial processing here, e.g., modify the context:
724
+ * context.customProcessed = true;
725
+ *
726
+ * // If you are ready to finalize the response:
727
+ * return new Response('Hello, world!', {
728
+ * status: 200,
729
+ * headers: {
730
+ * 'Content-Type': 'text/plain'
731
+ * }
732
+ });
733
+ *
734
+ * // Or, if further processing is needed by another plugin, simply return null.
735
+ * }
736
+ * }
737
+ * export const myCustomPluginFactory: VerifiedFetchPluginFactory = (opts: PluginOptions) => new MyCustomPlugin(opts)
738
+ * ```
739
+ *
740
+ * 2. **Integrate Your Plugin:**
741
+ *
742
+ * Add your custom plugin to Verified‑Fetch’s plugin list when instantiating Verified‑Fetch:
743
+ *
744
+ * @example Integrate custom plugin
745
+ *
746
+ * ```typescript
747
+ * import { createVerifiedFetch, type VerifiedFetchPluginFactory } from '@helia/verified-fetch'
748
+ * import { createHelia } from 'helia'
749
+ *
750
+ * const helia = await createHelia()
751
+ * const plugins: VerifiedFetchPluginFactory[] = [
752
+ * // myCustomPluginFactory
753
+ * ]
754
+ *
755
+ * const fetch = await createVerifiedFetch(helia, { plugins })
756
+ * ```
757
+ *
758
+ * ---
759
+ *
760
+ * ### Error Handling in the Plugin Pipeline
761
+ *
762
+ * Verified‑Fetch distinguishes between two types of errors thrown by plugins:
763
+ *
764
+ * - **PluginError (Non‑Fatal):**
765
+ * - Use this when your plugin encounters an issue that should be logged but does not prevent the pipeline
766
+ * from continuing.
767
+ * - When a plugin throws a `PluginError`, the error is logged and the pipeline continues with the next plugin.
768
+ *
769
+ * - **PluginFatalError (Fatal):**
770
+ * - Use this when a critical error occurs that should immediately abort the request.
771
+ * - When a plugin throws a `PluginFatalError`, the pipeline immediately terminates and the provided error
772
+ * response is returned.
773
+ *
774
+ * @example Plugin error Handling
775
+ *
776
+ * ```typescript
777
+ * import { PluginError, PluginFatalError } from '@helia/verified-fetch'
778
+ *
779
+ * // async handle(context: PluginContext): Promise<Response | null> {
780
+ * const recoverable = Math.random() > 0.5 // Use more sophisticated logic here ;)
781
+ * if (recoverable === true) {
782
+ * throw new PluginError('MY_CUSTOM_WARNING', 'A non‑fatal issue occurred', {
783
+ * details: {
784
+ * someKey: 'Additional details here'
785
+ * }
786
+ * });
787
+ * }
788
+ *
789
+ * if (recoverable === false) {
790
+ * throw new PluginFatalError('MY_CUSTOM_FATAL', 'A critical error occurred', {
791
+ * response: new Response('Something happened', { status: 500 }) // Required: supply your own error response
792
+ * });
793
+ * }
794
+ *
795
+ * // Otherwise, continue processing...
796
+ * // }
797
+ * ```
798
+ *
799
+ * ### How the Plugin Pipeline Works
800
+ *
801
+ * - **Shared Context:**
802
+ * A mutable `PluginContext` is created for each request. It includes the parsed CID, path, query parameters,
803
+ * accept header, and any other metadata. Plugins can update this context as they perform partial work (for example,
804
+ * by doing path walking or decoding).
805
+ *
806
+ * - **Iterative Processing:**
807
+ * The pipeline repeatedly checks which plugins can currently handle the request by calling `canHandle(context)`.
808
+ * - Plugins that perform partial processing update the context and return `null`, allowing subsequent passes by other plugins.
809
+ * - Once a plugin is ready to finalize the response, it returns a final `Response` and the pipeline terminates.
810
+ *
811
+ * - **No Strict Ordering:**
812
+ * Plugins are invoked based solely on whether they can handle the current state of the context.
813
+ * This means you do not have to specify a rigid order, each plugin simply checks the context and acts if appropriate.
814
+ *
815
+ * - **Error Handling:**
816
+ * - A thrown `PluginError` is considered non‑fatal and is logged, allowing the pipeline to continue.
817
+ * - A thrown `PluginFatalError` immediately stops the pipeline and returns the error response.
818
+ *
819
+ * For a detailed explanation of the pipeline, please refer to the discussion in [Issue #167](https://github.com/ipfs/helia-verified-fetch/issues/167).
621
820
  */
622
821
 
623
822
  import { bitswap, trustlessGateway } from '@helia/block-brokers'
@@ -631,6 +830,7 @@ import { createLibp2p, type Libp2pOptions } from 'libp2p'
631
830
  import { type ContentTypeParser } from './types.js'
632
831
  import { getLibp2pConfig } from './utils/libp2p-defaults.js'
633
832
  import { VerifiedFetch as VerifiedFetchClass } from './verified-fetch.js'
833
+ import type { VerifiedFetchPluginFactory } from './plugins/types.js'
634
834
  import type { GetBlockProgressEvents, Helia, Routing } from '@helia/interface'
635
835
  import type { DNSResolvers, DNS } from '@multiformats/dns'
636
836
  import type { DNSResolver } from '@multiformats/dns/resolvers'
@@ -750,6 +950,20 @@ export interface CreateVerifiedFetchOptions {
750
950
  * @default 60000
751
951
  */
752
952
  sessionTTLms?: number
953
+
954
+ /**
955
+ * Whether to include server-timing headers in responses. This option can be overridden on a per-request basis.
956
+ *
957
+ * @default false
958
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Server-Timing
959
+ */
960
+ withServerTiming?: boolean
961
+
962
+ /**
963
+ * Plugins to use with the verified-fetch instance. Note that we have a set of default plugins that are always used.
964
+ * If you want to replace one of the default plugins, you can do so by passing a plugin with the same name.
965
+ */
966
+ plugins?: VerifiedFetchPluginFactory[]
753
967
  }
754
968
 
755
969
  export type { ContentTypeParser } from './types.js'
@@ -817,6 +1031,14 @@ export interface VerifiedFetchInit extends RequestInit, ProgressOptions<BubbledP
817
1031
  * @default false
818
1032
  */
819
1033
  allowInsecure?: boolean
1034
+
1035
+ /**
1036
+ * Whether to include server-timing headers in the response for an individual request.
1037
+ *
1038
+ * @default false
1039
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Server-Timing
1040
+ */
1041
+ withServerTiming?: boolean
820
1042
  }
821
1043
 
822
1044
  /**
@@ -874,6 +1096,7 @@ export async function createVerifiedFetch (init?: Helia | CreateVerifiedFetchIni
874
1096
  }
875
1097
 
876
1098
  export { verifiedFetch } from './singleton.js'
1099
+ export * from './plugins/index.js'
877
1100
 
878
1101
  function isHelia (obj: any): obj is Helia {
879
1102
  // test for the presence of known Helia properties, return a boolean value
@@ -0,0 +1,37 @@
1
+ import type { FatalPluginErrorOptions, PluginErrorOptions } from './types.js'
2
+
3
+ /**
4
+ * If a plugin encounters an error, it should throw an instance of this class.
5
+ */
6
+ export class PluginError extends Error {
7
+ public name = 'PluginError'
8
+ public code: string
9
+ public fatal: boolean
10
+ public details?: Record<string, any>
11
+ public response?: any
12
+
13
+ constructor (code: string, message: string, options?: PluginErrorOptions) {
14
+ super(message)
15
+ this.code = code
16
+ this.fatal = options?.fatal ?? false
17
+ this.details = options?.details
18
+ this.response = options?.response
19
+ }
20
+ }
21
+
22
+ /**
23
+ * If a plugin encounters a fatal error and verified-fetch should not continue processing the request, it should throw
24
+ * an instance of this class.
25
+ *
26
+ * Note that you should be very careful when throwing a `PluginFatalError`, as it will stop the request from being
27
+ * processed further. If you do not have a response to return to the client, you should consider throwing a
28
+ * `PluginError` instead.
29
+ */
30
+ export class PluginFatalError extends PluginError {
31
+ public name = 'PluginFatalError'
32
+
33
+ constructor (code: string, message: string, options: FatalPluginErrorOptions) {
34
+ super(code, message, { ...options, fatal: true })
35
+ this.name = 'PluginFatalError'
36
+ }
37
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * This file is the entry into all things we export from the `src/plugins` directory.
3
+ */
4
+
5
+ export { PluginError, PluginFatalError } from './errors.js'
6
+ export { BasePlugin } from './plugin-base.js'
7
+ export type { PluginOptions, PluginContext, VerifiedFetchPluginFactory } from './types.js'
8
+ export * from './plugins.js'
@@ -0,0 +1,30 @@
1
+ import type { VerifiedFetchPlugin, PluginContext, PluginOptions } from './types.js'
2
+ import type { Logger } from '@libp2p/interface'
3
+
4
+ /**
5
+ * Base class for verified-fetch plugins. This class provides a basic implementation of the `FetchHandlerPlugin`
6
+ * interface.
7
+ *
8
+ * Subclasses should implement the `canHandle` and `handle` methods, and may override the `codes` and `log` properties.
9
+ *
10
+ * If your plugin adds/edits the context supplied in `handle`, you should increment the `context.modified` property.
11
+ */
12
+ export class BasePlugin implements VerifiedFetchPlugin {
13
+ readonly codes: number[] = []
14
+ readonly log: Logger
15
+ readonly pluginOptions: PluginOptions
16
+ constructor (options: PluginOptions) {
17
+ // convert a CamelCase string to a kebab-case string for the logger name of subclasses
18
+ const loggerName = this.constructor.name.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase()
19
+ this.log = options.logger.forComponent(loggerName)
20
+ this.pluginOptions = options
21
+ }
22
+
23
+ canHandle (context: PluginContext): boolean {
24
+ throw new Error('Not implemented')
25
+ }
26
+
27
+ async handle (context: PluginContext): Promise<Response | null> {
28
+ throw new Error('Not implemented')
29
+ }
30
+ }
@@ -0,0 +1,32 @@
1
+ import { car } from '@helia/car'
2
+ import toBrowserReadableStream from 'it-to-browser-readablestream'
3
+ import { okResponse } from '../utils/responses.js'
4
+ import { BasePlugin } from './plugin-base.js'
5
+ import type { PluginContext } from './types.js'
6
+
7
+ /**
8
+ * Accepts a `CID` and returns a `Response` with a body stream that is a CAR
9
+ * of the `DAG` referenced by the `CID`.
10
+ */
11
+ export class CarPlugin extends BasePlugin {
12
+ canHandle (context: PluginContext): boolean {
13
+ this.log('checking if we can handle %c with accept %s', context.cid, context.accept)
14
+ return context.accept?.startsWith('application/vnd.ipld.car') === true || context.query.format === 'car' // application/vnd.ipld.car
15
+ }
16
+
17
+ async handle (context: PluginContext): Promise<Response> {
18
+ const { options } = context
19
+ const { getBlockstore, helia } = this.pluginOptions
20
+ context.reqFormat = 'car'
21
+ context.query.download = true
22
+ context.query.filename = context.query.filename ?? `${context.cid.toString()}.car`
23
+ const blockstore = getBlockstore(context.cid, context.resource, options?.session ?? true, options)
24
+ const c = car({ blockstore, getCodec: helia.getCodec })
25
+ const stream = toBrowserReadableStream(c.stream(context.cid, options))
26
+
27
+ const response = okResponse(context.resource, stream)
28
+ response.headers.set('content-type', 'application/vnd.ipld.car; version=1')
29
+
30
+ return response
31
+ }
32
+ }
@@ -0,0 +1,84 @@
1
+ import * as ipldDagCbor from '@ipld/dag-cbor'
2
+ import * as ipldDagJson from '@ipld/dag-json'
3
+ import { dagCborToSafeJSON } from '../utils/dag-cbor-to-safe-json.js'
4
+ import { setIpfsRoots } from '../utils/response-headers.js'
5
+ import { notAcceptableResponse, okResponse } from '../utils/responses.js'
6
+ import { isObjectNode } from '../utils/walk-path.js'
7
+ import { BasePlugin } from './plugin-base.js'
8
+ import type { PluginContext } from './types.js'
9
+ import type { ObjectNode } from 'ipfs-unixfs-exporter'
10
+
11
+ /**
12
+ * Handles `dag-cbor` content, including requests with Accept: `application/vnd.ipld.dag-json` and `application/json`.
13
+ */
14
+ export class DagCborPlugin extends BasePlugin {
15
+ readonly codes = [ipldDagCbor.code]
16
+
17
+ canHandle ({ cid, accept, pathDetails }: PluginContext): boolean {
18
+ this.log('checking if we can handle %c with accept %s', cid, accept)
19
+ if (pathDetails == null) {
20
+ return false
21
+ }
22
+ if (!isObjectNode(pathDetails.terminalElement)) {
23
+ return false
24
+ }
25
+ if (cid.code !== ipldDagCbor.code) {
26
+ return false
27
+ }
28
+
29
+ return isObjectNode(pathDetails.terminalElement)
30
+ }
31
+
32
+ async handle (context: PluginContext): Promise<Response> {
33
+ const { cid, path, resource, accept, pathDetails } = context
34
+
35
+ this.log.trace('fetching %c/%s', cid, path)
36
+ if (pathDetails == null) {
37
+ throw new Error('pathDetails is null')
38
+ }
39
+ const ipfsRoots = pathDetails.ipfsRoots
40
+ const terminalElement = pathDetails.terminalElement as ObjectNode // checked in canHandle fn.
41
+
42
+ const block = terminalElement.node
43
+
44
+ let body: string | Uint8Array
45
+
46
+ if (accept === 'application/octet-stream' || accept === 'application/vnd.ipld.dag-cbor' || accept === 'application/cbor') {
47
+ // skip decoding
48
+ body = block
49
+ } else if (accept === 'application/vnd.ipld.dag-json') {
50
+ try {
51
+ // if vnd.ipld.dag-json has been specified, convert to the format - note
52
+ // that this supports more data types than regular JSON, the content-type
53
+ // response header is set so the user knows to process it differently
54
+ const obj = ipldDagCbor.decode(block)
55
+ body = ipldDagJson.encode(obj)
56
+ } catch (err) {
57
+ this.log.error('could not transform %c to application/vnd.ipld.dag-json', err)
58
+ return notAcceptableResponse(resource)
59
+ }
60
+ } else {
61
+ try {
62
+ body = dagCborToSafeJSON(block)
63
+ } catch (err) {
64
+ if (accept === 'application/json') {
65
+ this.log('could not decode DAG-CBOR as JSON-safe, but the client sent "Accept: application/json"', err)
66
+
67
+ return notAcceptableResponse(resource)
68
+ }
69
+
70
+ this.log('could not decode DAG-CBOR as JSON-safe, falling back to `application/octet-stream`', err)
71
+ body = block
72
+ }
73
+ }
74
+
75
+ const response = okResponse(resource, body)
76
+
77
+ const responseContentType = accept ?? (body instanceof Uint8Array ? 'application/octet-stream' : 'application/json')
78
+
79
+ response.headers.set('content-type', responseContentType)
80
+ setIpfsRoots(response, ipfsRoots)
81
+
82
+ return response
83
+ }
84
+ }