@helia/verified-fetch 4.0.0 → 4.0.1

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 (96) hide show
  1. package/README.md +7 -49
  2. package/dist/index.min.js +52 -47
  3. package/dist/index.min.js.map +4 -4
  4. package/dist/src/index.d.ts +8 -50
  5. package/dist/src/index.d.ts.map +1 -1
  6. package/dist/src/index.js +8 -50
  7. package/dist/src/index.js.map +1 -1
  8. package/dist/src/plugins/index.d.ts +0 -1
  9. package/dist/src/plugins/index.d.ts.map +1 -1
  10. package/dist/src/plugins/index.js +0 -1
  11. package/dist/src/plugins/index.js.map +1 -1
  12. package/dist/src/plugins/plugin-base.d.ts.map +1 -1
  13. package/dist/src/plugins/plugin-base.js +3 -2
  14. package/dist/src/plugins/plugin-base.js.map +1 -1
  15. package/dist/src/plugins/plugin-handle-car.d.ts.map +1 -1
  16. package/dist/src/plugins/plugin-handle-car.js +0 -1
  17. package/dist/src/plugins/plugin-handle-car.js.map +1 -1
  18. package/dist/src/plugins/plugin-handle-dag-cbor-html-preview.d.ts.map +1 -1
  19. package/dist/src/plugins/plugin-handle-dag-cbor-html-preview.js +0 -1
  20. package/dist/src/plugins/plugin-handle-dag-cbor-html-preview.js.map +1 -1
  21. package/dist/src/plugins/plugin-handle-dag-cbor.d.ts.map +1 -1
  22. package/dist/src/plugins/plugin-handle-dag-cbor.js +0 -1
  23. package/dist/src/plugins/plugin-handle-dag-cbor.js.map +1 -1
  24. package/dist/src/plugins/plugin-handle-dag-pb.d.ts.map +1 -1
  25. package/dist/src/plugins/plugin-handle-dag-pb.js +13 -16
  26. package/dist/src/plugins/plugin-handle-dag-pb.js.map +1 -1
  27. package/dist/src/plugins/plugin-handle-dag-walk.d.ts +8 -4
  28. package/dist/src/plugins/plugin-handle-dag-walk.d.ts.map +1 -1
  29. package/dist/src/plugins/plugin-handle-dag-walk.js +8 -5
  30. package/dist/src/plugins/plugin-handle-dag-walk.js.map +1 -1
  31. package/dist/src/plugins/plugin-handle-ipns-record.d.ts +1 -1
  32. package/dist/src/plugins/plugin-handle-ipns-record.d.ts.map +1 -1
  33. package/dist/src/plugins/plugin-handle-ipns-record.js +3 -5
  34. package/dist/src/plugins/plugin-handle-ipns-record.js.map +1 -1
  35. package/dist/src/plugins/plugin-handle-json.d.ts.map +1 -1
  36. package/dist/src/plugins/plugin-handle-json.js +0 -1
  37. package/dist/src/plugins/plugin-handle-json.js.map +1 -1
  38. package/dist/src/plugins/plugin-handle-raw.d.ts.map +1 -1
  39. package/dist/src/plugins/plugin-handle-raw.js +3 -7
  40. package/dist/src/plugins/plugin-handle-raw.js.map +1 -1
  41. package/dist/src/plugins/plugin-handle-tar.d.ts.map +1 -1
  42. package/dist/src/plugins/plugin-handle-tar.js +0 -1
  43. package/dist/src/plugins/plugin-handle-tar.js.map +1 -1
  44. package/dist/src/plugins/types.d.ts +5 -7
  45. package/dist/src/plugins/types.d.ts.map +1 -1
  46. package/dist/src/utils/byte-range-context.d.ts +2 -2
  47. package/dist/src/utils/byte-range-context.d.ts.map +1 -1
  48. package/dist/src/utils/byte-range-context.js +1 -1
  49. package/dist/src/utils/byte-range-context.js.map +1 -1
  50. package/dist/src/utils/content-type-parser.d.ts.map +1 -1
  51. package/dist/src/utils/content-type-parser.js +0 -10
  52. package/dist/src/utils/content-type-parser.js.map +1 -1
  53. package/dist/src/utils/error-to-object.d.ts +6 -0
  54. package/dist/src/utils/error-to-object.d.ts.map +1 -0
  55. package/dist/src/utils/error-to-object.js +20 -0
  56. package/dist/src/utils/error-to-object.js.map +1 -0
  57. package/dist/src/utils/get-stream-from-async-iterable.d.ts +2 -2
  58. package/dist/src/utils/get-stream-from-async-iterable.d.ts.map +1 -1
  59. package/dist/src/utils/get-stream-from-async-iterable.js +2 -2
  60. package/dist/src/utils/get-stream-from-async-iterable.js.map +1 -1
  61. package/dist/src/utils/responses.d.ts +2 -1
  62. package/dist/src/utils/responses.d.ts.map +1 -1
  63. package/dist/src/utils/responses.js +12 -1
  64. package/dist/src/utils/responses.js.map +1 -1
  65. package/dist/src/utils/walk-path.js +1 -1
  66. package/dist/src/utils/walk-path.js.map +1 -1
  67. package/dist/src/verified-fetch.d.ts.map +1 -1
  68. package/dist/src/verified-fetch.js +36 -28
  69. package/dist/src/verified-fetch.js.map +1 -1
  70. package/dist/typedoc-urls.json +0 -2
  71. package/package.json +2 -2
  72. package/src/index.ts +8 -50
  73. package/src/plugins/index.ts +0 -1
  74. package/src/plugins/plugin-base.ts +3 -2
  75. package/src/plugins/plugin-handle-car.ts +0 -2
  76. package/src/plugins/plugin-handle-dag-cbor-html-preview.ts +2 -1
  77. package/src/plugins/plugin-handle-dag-cbor.ts +3 -1
  78. package/src/plugins/plugin-handle-dag-pb.ts +23 -15
  79. package/src/plugins/plugin-handle-dag-walk.ts +10 -5
  80. package/src/plugins/plugin-handle-ipns-record.ts +5 -5
  81. package/src/plugins/plugin-handle-json.ts +1 -1
  82. package/src/plugins/plugin-handle-raw.ts +6 -7
  83. package/src/plugins/plugin-handle-tar.ts +2 -1
  84. package/src/plugins/types.ts +6 -8
  85. package/src/utils/byte-range-context.ts +3 -3
  86. package/src/utils/content-type-parser.ts +5 -11
  87. package/src/utils/error-to-object.ts +22 -0
  88. package/src/utils/get-stream-from-async-iterable.ts +4 -4
  89. package/src/utils/responses.ts +15 -1
  90. package/src/utils/walk-path.ts +1 -1
  91. package/src/verified-fetch.ts +46 -28
  92. package/dist/src/plugins/errors.d.ts +0 -25
  93. package/dist/src/plugins/errors.d.ts.map +0 -1
  94. package/dist/src/plugins/errors.js +0 -33
  95. package/dist/src/plugins/errors.js.map +0 -1
  96. package/src/plugins/errors.ts +0 -37
@@ -1 +1 @@
1
- {"version":3,"file":"verified-fetch.d.ts","sourceRoot":"","sources":["../../src/verified-fetch.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAAgC,0BAA0B,EAAoB,QAAQ,EAAkB,iBAAiB,IAAI,oBAAoB,EAAE,MAAM,Y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,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAQ;IAC5B,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAA+B;IACjE,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAqC;IACxE,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAS;IAC1C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA4B;gBAEvC,KAAK,EAAE,KAAK,EAAE,IAAI,GAAE,0BAA+B;IAoDhE,OAAO,CAAC,aAAa;IAgBrB;;;;OAIG;IACH,OAAO,CAAC,mBAAmB;IA2F3B;;;OAGG;YACW,iBAAiB;IAiG/B;;;;;;OAMG;IACG,KAAK,CAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,QAAQ,CAAC;IA+EhF;;OAEG;IACG,KAAK,IAAK,OAAO,CAAC,IAAI,CAAC;IAI7B;;OAEG;IACG,IAAI,IAAK,OAAO,CAAC,IAAI,CAAC;CAG7B"}
@@ -1,7 +1,6 @@
1
1
  import { dnsLink } from '@helia/dnslink';
2
2
  import { ipnsResolver } from '@helia/ipns';
3
3
  import { AbortError } from '@libp2p/interface';
4
- import { prefixLogger } from '@libp2p/logger';
5
4
  import { CustomProgressEvent } from 'progress-events';
6
5
  import QuickLRU from 'quick-lru';
7
6
  import { ByteRangeContextPlugin } from './plugins/plugin-handle-byte-range-context.js';
@@ -15,6 +14,7 @@ import { RawPlugin } from './plugins/plugin-handle-raw.js';
15
14
  import { TarPlugin } from './plugins/plugin-handle-tar.js';
16
15
  import { URLResolver } from "./url-resolver.js";
17
16
  import { contentTypeParser } from './utils/content-type-parser.js';
17
+ import { errorToObject } from "./utils/error-to-object.js";
18
18
  import { getContentDispositionFilename } from './utils/get-content-disposition-filename.js';
19
19
  import { getETag } from './utils/get-e-tag.js';
20
20
  import { getResolvedAcceptHeader } from './utils/get-resolved-accept-header.js';
@@ -22,7 +22,7 @@ import { getRedirectResponse } from './utils/handle-redirects.js';
22
22
  import { uriEncodeIPFSPath } from "./utils/ipfs-path-to-string.js";
23
23
  import { resourceToSessionCacheKey } from './utils/resource-to-cache-key.js';
24
24
  import { setCacheControlHeader } from './utils/response-headers.js';
25
- import { badRequestResponse, notAcceptableResponse, notSupportedResponse, badGatewayResponse } from './utils/responses.js';
25
+ import { badRequestResponse, notAcceptableResponse, internalServerErrorResponse, notImplementedResponse } from './utils/responses.js';
26
26
  import { selectOutputType } from './utils/select-output-type.js';
27
27
  import { ServerTiming } from './utils/server-timing.js';
28
28
  const SESSION_CACHE_MAX_SIZE = 100;
@@ -68,7 +68,7 @@ export class VerifiedFetch {
68
68
  this.withServerTiming = init?.withServerTiming ?? false;
69
69
  const pluginOptions = {
70
70
  ...init,
71
- logger: prefixLogger('helia:verified-fetch'),
71
+ logger: helia.logger.forComponent('verified-fetch'),
72
72
  getBlockstore: (cid, resource, useSession, options) => this.getBlockstore(cid, resource, useSession, options),
73
73
  helia,
74
74
  contentTypeParser: this.contentTypeParser,
@@ -97,7 +97,6 @@ export class VerifiedFetch {
97
97
  else {
98
98
  this.plugins = defaultPlugins;
99
99
  }
100
- this.log.trace('created VerifiedFetch instance');
101
100
  }
102
101
  getBlockstore(root, resource, useSession = true, options = {}) {
103
102
  const key = resourceToSessionCacheKey(resource);
@@ -132,30 +131,23 @@ export class VerifiedFetch {
132
131
  }
133
132
  // set Content-Disposition header
134
133
  let contentDisposition;
135
- this.log.trace('checking for content disposition');
136
134
  // force download if requested
137
135
  if (context?.query?.download === true) {
136
+ this.log.trace('download requested');
138
137
  contentDisposition = 'attachment';
139
138
  }
140
- else {
141
- this.log.trace('download not requested');
142
- }
143
139
  // override filename if requested
144
140
  if (context?.query?.filename != null) {
141
+ this.log.trace('specific filename requested');
145
142
  if (contentDisposition == null) {
146
143
  contentDisposition = 'inline';
147
144
  }
148
145
  contentDisposition = `${contentDisposition}; ${getContentDispositionFilename(context.query.filename)}`;
149
146
  }
150
- else {
151
- this.log.trace('no filename specified in query');
152
- }
153
147
  if (contentDisposition != null) {
148
+ this.log.trace('content disposition %s', contentDisposition);
154
149
  response.headers.set('Content-Disposition', contentDisposition);
155
150
  }
156
- else {
157
- this.log.trace('no content disposition specified');
158
- }
159
151
  if (context?.cid != null && response.headers.get('etag') == null) {
160
152
  response.headers.set('etag', getETag({
161
153
  cid: context.pathDetails?.terminalElement.cid ?? context.cid,
@@ -211,28 +203,30 @@ export class VerifiedFetch {
211
203
  while (passCount < maxPasses) {
212
204
  this.log(`starting pipeline pass #${passCount + 1}`);
213
205
  passCount++;
206
+ this.log.trace('checking which plugins can handle %c%s with accept %o', context.cid, context.path != null ? `/${context.path}` : '', context.accept);
214
207
  // gather plugins that say they can handle the *current* context, but haven't been used yet
215
208
  const readyPlugins = this.plugins.filter(p => !pluginsUsed.has(p.id)).filter(p => p.canHandle(context));
216
209
  if (readyPlugins.length === 0) {
217
- this.log.trace('no plugins can handle the current context.. checking by CID code');
210
+ this.log.trace('no plugins can handle the current context, checking by CID code');
218
211
  const plugins = this.plugins.filter(p => p.codes.includes(context.cid.code));
219
212
  if (plugins.length > 0) {
220
213
  readyPlugins.push(...plugins);
221
214
  }
222
215
  else {
223
- this.log.trace('no plugins found that can handle request by CID code; exiting pipeline.');
216
+ this.log.trace('no plugins found that can handle request by CID code; exiting pipeline');
224
217
  break;
225
218
  }
226
219
  }
227
- this.log.trace('plugins ready to handle request: ', readyPlugins.map(p => p.id).join(', '));
220
+ this.log.trace('plugins ready to handle request: %s', readyPlugins.map(p => p.id).join(', '));
228
221
  // track if any plugin changed the context or returned a response
229
222
  let contextChanged = false;
230
223
  let pluginHandled = false;
231
224
  for (const plugin of readyPlugins) {
232
225
  try {
233
- this.log.trace('invoking plugin:', plugin.id);
226
+ this.log('invoking plugin: %s', plugin.id);
234
227
  pluginsUsed.add(plugin.id);
235
228
  const maybeResponse = await plugin.handle(context);
229
+ this.log('plugin response %s %o', plugin.id, maybeResponse);
236
230
  if (maybeResponse != null) {
237
231
  // if a plugin returns a final Response, short-circuit
238
232
  finalResponse = maybeResponse;
@@ -244,12 +238,14 @@ export class VerifiedFetch {
244
238
  if (context.options?.signal?.aborted) {
245
239
  throw new AbortError(context.options?.signal?.reason);
246
240
  }
247
- this.log.error('error in plugin %s - %e', plugin.constructor.name, err);
248
- // if fatal, short-circuit the pipeline
249
- if (err.name === 'PluginFatalError') {
250
- // if plugin provides a custom error response, return it
251
- return err.response ?? badGatewayResponse(context.resource, 'Failed to fetch');
252
- }
241
+ this.log.error('error in plugin %s - %e', plugin.id, err);
242
+ return internalServerErrorResponse(context.resource, JSON.stringify({
243
+ error: errorToObject(err)
244
+ }), {
245
+ headers: {
246
+ 'content-type': 'application/json'
247
+ }
248
+ });
253
249
  }
254
250
  finally {
255
251
  // on each plugin call, check for changes in the context
@@ -272,7 +268,13 @@ export class VerifiedFetch {
272
268
  break;
273
269
  }
274
270
  }
275
- return finalResponse;
271
+ return finalResponse ?? notImplementedResponse(context.resource, JSON.stringify({
272
+ error: errorToObject(new Error('No verified fetch plugin could handle the request'))
273
+ }), {
274
+ headers: {
275
+ 'content-type': 'application/json'
276
+ }
277
+ });
276
278
  }
277
279
  /**
278
280
  * We're starting to get to the point where we need a queue or pipeline of
@@ -308,7 +310,7 @@ export class VerifiedFetch {
308
310
  options?.onProgress?.(new CustomProgressEvent('verified-fetch:request:resolve', { cid: parsedResult.cid, path: parsedResult.path }));
309
311
  const acceptHeader = getResolvedAcceptHeader({ query: parsedResult.query, headers: options?.headers, logger: this.helia.logger });
310
312
  const accept = selectOutputType(parsedResult.cid, acceptHeader);
311
- this.log('output type %s', accept);
313
+ this.log('accept %o', accept);
312
314
  if (acceptHeader != null && accept == null) {
313
315
  this.log.error('could not fulfil request based on accept header');
314
316
  return this.handleFinalResponse(notAcceptableResponse(resource.toString()));
@@ -332,8 +334,14 @@ export class VerifiedFetch {
332
334
  };
333
335
  this.log.trace('finding handler for cid code "%s" and response content type "%s"', parsedResult.cid.code, responseContentType);
334
336
  const response = await this.runPluginPipeline(context);
335
- options?.onProgress?.(new CustomProgressEvent('verified-fetch:request:end', { cid: parsedResult.cid, path: parsedResult.path }));
336
- return this.handleFinalResponse(response ?? notSupportedResponse(resource.toString()), context);
337
+ options?.onProgress?.(new CustomProgressEvent('verified-fetch:request:end', {
338
+ cid: parsedResult.cid,
339
+ path: parsedResult.path
340
+ }));
341
+ if (response == null) {
342
+ this.log.error('no plugin could handle request for %s', resource);
343
+ }
344
+ return this.handleFinalResponse(response, context);
337
345
  }
338
346
  /**
339
347
  * Start the Helia instance
@@ -1 +1 @@
1
- {"version":3,"file":"verified-fetch.js","sourceRoot":"","sources":["../../src/verified-fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,QAAQ,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,sBAAsB,EAAE,MAAM,+CAA+C,CAAA;AACtF,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAA;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAA;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAA;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAA;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAA;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAA;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAA;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAA;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,mBA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KAAK,CAAC,kEAAkE,EAAE,YAAY,CAAC,GAAG,CAAC,IAAI,EAAE,mBAAmB,CAAC,CAAA;QAE9H,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAA;QAEtD,OAAO,EAAE,UAAU,EAAE,CAAC,IAAI,mBAAmB,CAAY,4BAA4B,EAAE;YACrF,GAAG,EAAE,YAAY,CAAC,GAAG;YACrB,IAAI,EAAE,YAAY,CAAC,IAAI;SACxB,CAAC,CAAC,CAAA;QAEH,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAC;YACrB,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,uCAAuC,EAAE,QAAQ,CAAC,CAAA;QACnE,CAAC;QAED,OAAO,IAAI,CAAC,mBAAmB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;IACpD,CAAC;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"}
@@ -4,8 +4,6 @@
4
4
  "BasePlugin": "https://ipfs.github.io/helia-verified-fetch/classes/index.BasePlugin.html",
5
5
  "DagCborHtmlPreviewPlugin": "https://ipfs.github.io/helia-verified-fetch/classes/index.DagCborHtmlPreviewPlugin.html",
6
6
  "DirIndexHtmlPlugin": "https://ipfs.github.io/helia-verified-fetch/classes/index.DirIndexHtmlPlugin.html",
7
- "PluginError": "https://ipfs.github.io/helia-verified-fetch/classes/index.PluginError.html",
8
- "PluginFatalError": "https://ipfs.github.io/helia-verified-fetch/classes/index.PluginFatalError.html",
9
7
  "CIDDetail": "https://ipfs.github.io/helia-verified-fetch/interfaces/index.CIDDetail.html",
10
8
  ".:CIDDetail": "https://ipfs.github.io/helia-verified-fetch/interfaces/index.CIDDetail.html",
11
9
  "CIDDetailError": "https://ipfs.github.io/helia-verified-fetch/interfaces/index.CIDDetailError.html",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@helia/verified-fetch",
3
- "version": "4.0.0",
3
+ "version": "4.0.1",
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",
@@ -177,7 +177,6 @@
177
177
  "@ipld/dag-pb": "^4.1.5",
178
178
  "@libp2p/interface": "^3.0.0",
179
179
  "@libp2p/kad-dht": "^16.0.0",
180
- "@libp2p/logger": "^6.0.0",
181
180
  "@libp2p/peer-id": "^6.0.0",
182
181
  "@libp2p/utils": "^7.0.5",
183
182
  "@libp2p/webrtc": "^6.0.0",
@@ -206,6 +205,7 @@
206
205
  "@helia/json": "^5.0.0",
207
206
  "@ipld/car": "^5.4.2",
208
207
  "@libp2p/crypto": "^5.1.3",
208
+ "@libp2p/logger": "^6.0.0",
209
209
  "@types/sinon": "^17.0.4",
210
210
  "aegir": "^47.0.24",
211
211
  "browser-readablestream-to-it": "^2.0.9",
package/src/index.ts CHANGED
@@ -641,13 +641,13 @@
641
641
  * Inspects the current `PluginContext` (which includes the CID, path, query, accept header, etc.)
642
642
  * and returns `true` if the plugin can operate on the current state of the request.
643
643
  *
644
- * - **`handle(context: PluginContext): Promise<Response | null>`**
645
- * Performs the plugin’s work. It may:
646
- * - **Return a final `Response`**: This stops the pipeline immediately.
647
- * - **Return `null`**: This indicates that the plugin has only partially processed the request
648
- * (for example, by performing path walking or decoding) and the pipeline should continue.
649
- * - **Throw a `PluginError`**: This logs a non-fatal error and continues the pipeline.
650
- * - **Throw a `PluginFatalError`**: This logs a fatal error and stops the pipeline immediately.
644
+ * - **`handle(context: PluginContext): Promise<Response | undefined>`**
645
+ * Performs the plugin’s work. It will only be executed if `canHandle` previously returned `true`.
646
+ * It may:
647
+ * - **Return a `Response`**: This stops the pipeline immediately and returns the response.
648
+ * - **Return `undefined`**: This indicates that the plugin has only partially processed the request
649
+ * (for example, by performing path walking or decoding) and the pipeline should continue.
650
+ * - **Throw an `Error`**: An Internal Server Error will be returned
651
651
  *
652
652
  * ### Plugin Pipeline
653
653
  *
@@ -784,47 +784,6 @@
784
784
  * const fetch = await createVerifiedFetch(helia, { plugins })
785
785
  * ```
786
786
  *
787
- * ---
788
- *
789
- * ### Error Handling in the Plugin Pipeline
790
- *
791
- * Verified‑Fetch distinguishes between two types of errors thrown by plugins:
792
- *
793
- * - **PluginError (Non‑Fatal):**
794
- * - Use this when your plugin encounters an issue that should be logged but does not prevent the pipeline
795
- * from continuing.
796
- * - When a plugin throws a `PluginError`, the error is logged and the pipeline continues with the next plugin.
797
- *
798
- * - **PluginFatalError (Fatal):**
799
- * - Use this when a critical error occurs that should immediately abort the request.
800
- * - When a plugin throws a `PluginFatalError`, the pipeline immediately terminates and the provided error
801
- * response is returned.
802
- *
803
- * @example Plugin error Handling
804
- *
805
- * ```typescript
806
- * import { PluginError, PluginFatalError } from '@helia/verified-fetch'
807
- *
808
- * // async handle(context: PluginContext): Promise<Response | null> {
809
- * const recoverable = Math.random() > 0.5 // Use more sophisticated logic here ;)
810
- * if (recoverable === true) {
811
- * throw new PluginError('MY_CUSTOM_WARNING', 'A non‑fatal issue occurred', {
812
- * details: {
813
- * someKey: 'Additional details here'
814
- * }
815
- * })
816
- * }
817
- *
818
- * if (recoverable === false) {
819
- * throw new PluginFatalError('MY_CUSTOM_FATAL', 'A critical error occurred', {
820
- * response: new Response('Something happened', { status: 500 }) // Required: supply your own error response
821
- * })
822
- * }
823
- *
824
- * // Otherwise, continue processing...
825
- * // }
826
- * ```
827
- *
828
787
  * ### How the Plugin Pipeline Works
829
788
  *
830
789
  * - **Shared Context:**
@@ -842,8 +801,7 @@
842
801
  * This means you do not have to specify a rigid order, each plugin simply checks the context and acts if appropriate.
843
802
  *
844
803
  * - **Error Handling:**
845
- * - A thrown `PluginError` is considered non‑fatal and is logged, allowing the pipeline to continue.
846
- * - A thrown `PluginFatalError` immediately stops the pipeline and returns the error response.
804
+ * - Any thrown error immediately stops the pipeline and returns the error response.
847
805
  *
848
806
  * For a detailed explanation of the pipeline, please refer to the discussion in [Issue #167](https://github.com/ipfs/helia-verified-fetch/issues/167).
849
807
  */
@@ -2,7 +2,6 @@
2
2
  * This file is the entry into all things we export from the `src/plugins` directory.
3
3
  */
4
4
 
5
- export { PluginError, PluginFatalError } from './errors.js'
6
5
  export { BasePlugin } from './plugin-base.js'
7
6
  export type { PluginOptions, PluginContext, VerifiedFetchPluginFactory } from './types.js'
8
7
  export * from './plugins.js'
@@ -17,9 +17,10 @@ export abstract class BasePlugin implements VerifiedFetchPlugin {
17
17
  protected _log?: Logger
18
18
 
19
19
  get log (): Logger {
20
- // instantiate the logger lazily because it depends on the id, which is not set until after the constructor is called
20
+ // instantiate the logger lazily because it depends on the id, which is not
21
+ // set until after the constructor is called
21
22
  if (this._log == null) {
22
- this._log = this.pluginOptions.logger.forComponent(this.id)
23
+ this._log = this.pluginOptions.logger.newScope(this.id)
23
24
  }
24
25
  return this._log
25
26
  }
@@ -47,8 +47,6 @@ export class CarPlugin extends BasePlugin {
47
47
  readonly id = 'car-plugin'
48
48
 
49
49
  canHandle (context: PluginContext): boolean {
50
- this.log('checking if we can handle %c with accept %s', context.cid, context.accept)
51
-
52
50
  if (context.byteRangeContext == null) {
53
51
  return false
54
52
  }
@@ -51,13 +51,14 @@ export class DagCborHtmlPreviewPlugin extends BasePlugin {
51
51
  readonly codes = [ipldDagCbor.code]
52
52
 
53
53
  canHandle ({ cid, accept, pathDetails }: PluginContext): boolean {
54
- this.log('checking if we can handle %c with accept %s', cid, accept)
55
54
  if (pathDetails == null) {
56
55
  return false
57
56
  }
57
+
58
58
  if (!isObjectNode(pathDetails.terminalElement)) {
59
59
  return false
60
60
  }
61
+
61
62
  if (cid.code !== ipldDagCbor.code) {
62
63
  return false
63
64
  }
@@ -16,16 +16,18 @@ export class DagCborPlugin extends BasePlugin {
16
16
  readonly codes = [ipldDagCbor.code]
17
17
 
18
18
  canHandle ({ cid, accept, pathDetails, byteRangeContext, plugins }: PluginContext): boolean {
19
- this.log('checking if we can handle %c with accept %s', cid, accept)
20
19
  if (pathDetails == null) {
21
20
  return false
22
21
  }
22
+
23
23
  if (!isObjectNode(pathDetails.terminalElement)) {
24
24
  return false
25
25
  }
26
+
26
27
  if (cid.code !== ipldDagCbor.code) {
27
28
  return false
28
29
  }
30
+
29
31
  if (byteRangeContext == null) {
30
32
  return false
31
33
  }
@@ -6,7 +6,7 @@ import { CustomProgressEvent } from 'progress-events'
6
6
  import { getContentType } from '../utils/get-content-type.js'
7
7
  import { getStreamFromAsyncIterable } from '../utils/get-stream-from-async-iterable.js'
8
8
  import { setIpfsRoots } from '../utils/response-headers.js'
9
- import { badGatewayResponse, badRangeResponse, movedPermanentlyResponse, notSupportedResponse, okRangeResponse } from '../utils/responses.js'
9
+ import { badGatewayResponse, badRangeResponse, movedPermanentlyResponse, okRangeResponse } from '../utils/responses.js'
10
10
  import { BasePlugin } from './plugin-base.js'
11
11
  import type { PluginContext } from './types.js'
12
12
  import type { CIDDetail } from '../index.js'
@@ -18,15 +18,21 @@ import type { UnixFSEntry } from 'ipfs-unixfs-exporter'
18
18
  export class DagPbPlugin extends BasePlugin {
19
19
  readonly id = 'dag-pb-plugin'
20
20
  readonly codes = [dagPbCode]
21
+
21
22
  canHandle ({ cid, accept, pathDetails, byteRangeContext }: PluginContext): boolean {
22
- this.log('checking if we can handle %c with accept %s', cid, accept)
23
23
  if (pathDetails == null) {
24
24
  return false
25
25
  }
26
+
26
27
  if (byteRangeContext == null) {
27
28
  return false
28
29
  }
29
30
 
31
+ // TODO: this may be too restrictive?
32
+ if (accept != null && accept.mimeType !== 'application/octet-stream') {
33
+ return false
34
+ }
35
+
30
36
  return cid.code === dagPbCode
31
37
  }
32
38
 
@@ -105,21 +111,20 @@ export class DagPbPlugin extends BasePlugin {
105
111
  if (options?.signal?.aborted) {
106
112
  throw new AbortError(options?.signal?.reason)
107
113
  }
108
- this.log.error('error loading path %c/%s', dirCid, rootFilePath, err)
114
+
115
+ this.log.error('error loading path %c/%s - %e', dirCid, rootFilePath, err)
116
+
109
117
  context.isDirectory = true
110
118
  context.directoryEntries = []
111
119
  context.modified++
120
+
112
121
  this.log.trace('attempting to get directory entries because index.html was not found')
113
- try {
114
- for await (const dirItem of fs.ls(dirCid, { signal: options?.signal, onProgress: options?.onProgress, extended: false })) {
115
- context.directoryEntries.push(dirItem)
116
- }
117
- // dir-index-html plugin or dir-index-json (future idea?) plugin should handle this
118
- return null
119
- } catch (e) {
120
- log.error('error listing directory %c', dirCid, e)
121
- return notSupportedResponse('Unable to get directory contents')
122
+ for await (const dirItem of fs.ls(dirCid, { signal: options?.signal, onProgress: options?.onProgress, extended: false })) {
123
+ context.directoryEntries.push(dirItem)
122
124
  }
125
+
126
+ // dir-index-html plugin or dir-index-json (future idea?) plugin should handle this
127
+ return null
123
128
  } finally {
124
129
  options?.onProgress?.(new CustomProgressEvent<CIDDetail>('verified-fetch:request:end', { cid: dirCid, path: rootFilePath }))
125
130
  }
@@ -152,7 +157,7 @@ export class DagPbPlugin extends BasePlugin {
152
157
  })
153
158
  log('got async iterator for %c/%s', cid, path)
154
159
 
155
- const streamAndFirstChunk = await context.serverTiming.time('stream-and-chunk', '', getStreamFromAsyncIterable(asyncIter, path ?? '', this.pluginOptions.logger, {
160
+ const streamAndFirstChunk = await context.serverTiming.time('stream-and-chunk', '', getStreamFromAsyncIterable(asyncIter, path, this.pluginOptions.logger, {
156
161
  onProgress: options?.onProgress,
157
162
  signal: options?.signal
158
163
  }))
@@ -177,11 +182,14 @@ export class DagPbPlugin extends BasePlugin {
177
182
  if (options?.signal?.aborted) {
178
183
  throw new AbortError(options?.signal?.reason)
179
184
  }
180
- log.error('error streaming %c/%s', cid, path, err)
185
+
186
+ log.error('error streaming %c/%s - %e', cid, path, err)
187
+
181
188
  if (byteRangeContext.isRangeRequest && err.code === 'ERR_INVALID_PARAMS') {
182
189
  return badRangeResponse(resource)
183
190
  }
184
- return badGatewayResponse(resource.toString(), 'Unable to stream content')
191
+
192
+ return badGatewayResponse(resource, 'Unable to stream content')
185
193
  }
186
194
  }
187
195
 
@@ -6,19 +6,24 @@ import { BasePlugin } from './plugin-base.js'
6
6
  import type { PluginContext } from './types.js'
7
7
 
8
8
  /**
9
- * This plugin should almost always run first because it's going to handle path walking if needed, and will only say it can handle
10
- * the request if path walking is possible (path is not empty, terminalCid is unknown, and the path has not been walked yet).
9
+ * This plugin should almost always run first because it's going to handle path
10
+ * walking if needed, and will only say it can handle the request if path
11
+ * walking is possible (path is not empty, terminalCid is unknown, and the path
12
+ * has not been walked yet).
11
13
  *
12
- * Once this plugin has run, the PluginContext will be updated and then this plugin will return false for canHandle, so it won't run again.
14
+ * Once this plugin has run, the PluginContext will be updated and then this
15
+ * plugin will return false for canHandle, so it won't run again.
13
16
  */
14
17
  export class DagWalkPlugin extends BasePlugin {
15
18
  readonly id = 'dag-walk-plugin'
19
+
16
20
  /**
17
- * Return false if the path has already been walked, otherwise return true if the CID is encoded with a codec that supports pathing.
21
+ * Return false if the path has already been walked, otherwise return true if
22
+ * the CID is encoded with a codec that supports pathing.
18
23
  */
19
24
  canHandle (context: PluginContext): boolean {
20
- this.log('checking if we can handle %c with accept %s', context.cid, context.accept)
21
25
  const { pathDetails, cid } = context
26
+
22
27
  if (pathDetails != null) {
23
28
  // path has already been walked
24
29
  return false
@@ -1,7 +1,6 @@
1
1
  import { marshalIPNSRecord } from 'ipns'
2
2
  import { getPeerIdFromString } from '../utils/get-peer-id-from-string.js'
3
3
  import { badRequestResponse, okRangeResponse } from '../utils/responses.js'
4
- import { PluginFatalError } from './errors.js'
5
4
  import { BasePlugin } from './plugin-base.js'
6
5
  import type { PluginContext } from './types.js'
7
6
  import type { PeerId } from '@libp2p/interface'
@@ -13,8 +12,8 @@ import type { PeerId } from '@libp2p/interface'
13
12
  export class IpnsRecordPlugin extends BasePlugin {
14
13
  readonly id = 'ipns-record-plugin'
15
14
  readonly codes = []
16
- canHandle ({ cid, accept, query, byteRangeContext }: PluginContext): boolean {
17
- this.log('checking if we can handle %c with accept %s', cid, accept)
15
+
16
+ canHandle ({ resource, accept, query, path, byteRangeContext }: PluginContext): boolean {
18
17
  if (byteRangeContext == null) {
19
18
  return false
20
19
  }
@@ -29,13 +28,14 @@ export class IpnsRecordPlugin extends BasePlugin {
29
28
 
30
29
  if (path !== '' || !(resource.startsWith('ipns://') || resource.includes('.ipns.') || resource.includes('/ipns/'))) {
31
30
  this.log.error('invalid request for IPNS name "%s" and path "%s"', resource, path)
32
- throw new PluginFatalError('ERR_INVALID_IPNS_NAME', 'Invalid IPNS name', { response: badRequestResponse(resource, new Error('Invalid IPNS name')) })
31
+ return badRequestResponse(resource, new Error('Invalid IPNS name'))
33
32
  }
34
33
 
35
34
  let peerId: PeerId
36
35
 
37
36
  try {
38
37
  let peerIdString: string
38
+
39
39
  if (resource.startsWith('ipns://')) {
40
40
  peerIdString = resource.replace('ipns://', '')
41
41
  } else if (resource.includes('/ipns/')) {
@@ -49,7 +49,7 @@ export class IpnsRecordPlugin extends BasePlugin {
49
49
  } catch (err: any) {
50
50
  this.log.error('could not parse peer id from IPNS url %s', resource, err)
51
51
 
52
- throw new PluginFatalError('ERR_NO_PEER_ID_FOUND', 'could not parse peer id from url', { response: badRequestResponse(resource, err) })
52
+ return badRequestResponse(resource, err)
53
53
  }
54
54
 
55
55
  // force download in handleFinalResponse
@@ -12,8 +12,8 @@ import type { PluginContext } from './types.js'
12
12
  export class JsonPlugin extends BasePlugin {
13
13
  readonly id = 'json-plugin'
14
14
  readonly codes = [ipldDagJson.code, jsonCode]
15
+
15
16
  canHandle ({ cid, accept, byteRangeContext }: PluginContext): boolean {
16
- this.log('checking if we can handle %c with accept %s', cid, accept)
17
17
  if (byteRangeContext == null) {
18
18
  return false
19
19
  }