@helia/verified-fetch 0.0.0 → 1.0.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 (81) hide show
  1. package/README.md +353 -56
  2. package/dist/index.min.js +7 -29
  3. package/dist/src/index.d.ts +384 -69
  4. package/dist/src/index.d.ts.map +1 -1
  5. package/dist/src/index.js +345 -77
  6. package/dist/src/index.js.map +1 -1
  7. package/dist/src/singleton.d.ts +3 -0
  8. package/dist/src/singleton.d.ts.map +1 -0
  9. package/dist/src/singleton.js +15 -0
  10. package/dist/src/singleton.js.map +1 -0
  11. package/dist/src/types.d.ts +2 -0
  12. package/dist/src/types.d.ts.map +1 -0
  13. package/dist/src/types.js +2 -0
  14. package/dist/src/types.js.map +1 -0
  15. package/dist/src/utils/dag-cbor-to-safe-json.d.ts +7 -0
  16. package/dist/src/utils/dag-cbor-to-safe-json.d.ts.map +1 -0
  17. package/dist/src/utils/dag-cbor-to-safe-json.js +37 -0
  18. package/dist/src/utils/dag-cbor-to-safe-json.js.map +1 -0
  19. package/dist/src/utils/get-content-disposition-filename.d.ts +6 -0
  20. package/dist/src/utils/get-content-disposition-filename.d.ts.map +1 -0
  21. package/dist/src/utils/get-content-disposition-filename.js +16 -0
  22. package/dist/src/utils/get-content-disposition-filename.js.map +1 -0
  23. package/dist/src/utils/get-e-tag.d.ts +28 -0
  24. package/dist/src/utils/get-e-tag.d.ts.map +1 -0
  25. package/dist/src/utils/get-e-tag.js +18 -0
  26. package/dist/src/utils/get-e-tag.js.map +1 -0
  27. package/dist/src/utils/get-stream-from-async-iterable.d.ts +10 -0
  28. package/dist/src/utils/get-stream-from-async-iterable.d.ts.map +1 -0
  29. package/dist/src/utils/{get-stream-and-content-type.js → get-stream-from-async-iterable.js} +11 -11
  30. package/dist/src/utils/get-stream-from-async-iterable.js.map +1 -0
  31. package/dist/src/utils/get-tar-stream.d.ts +4 -0
  32. package/dist/src/utils/get-tar-stream.d.ts.map +1 -0
  33. package/dist/src/utils/get-tar-stream.js +46 -0
  34. package/dist/src/utils/get-tar-stream.js.map +1 -0
  35. package/dist/src/utils/parse-resource.d.ts +6 -1
  36. package/dist/src/utils/parse-resource.d.ts.map +1 -1
  37. package/dist/src/utils/parse-resource.js +2 -2
  38. package/dist/src/utils/parse-resource.js.map +1 -1
  39. package/dist/src/utils/parse-url-string.d.ts +10 -3
  40. package/dist/src/utils/parse-url-string.d.ts.map +1 -1
  41. package/dist/src/utils/parse-url-string.js +8 -4
  42. package/dist/src/utils/parse-url-string.js.map +1 -1
  43. package/dist/src/utils/responses.d.ts +5 -0
  44. package/dist/src/utils/responses.d.ts.map +1 -0
  45. package/dist/src/utils/responses.js +27 -0
  46. package/dist/src/utils/responses.js.map +1 -0
  47. package/dist/src/utils/select-output-type.d.ts +12 -0
  48. package/dist/src/utils/select-output-type.d.ts.map +1 -0
  49. package/dist/src/utils/select-output-type.js +148 -0
  50. package/dist/src/utils/select-output-type.js.map +1 -0
  51. package/dist/src/utils/walk-path.d.ts +2 -1
  52. package/dist/src/utils/walk-path.d.ts.map +1 -1
  53. package/dist/src/utils/walk-path.js +1 -3
  54. package/dist/src/utils/walk-path.js.map +1 -1
  55. package/dist/src/verified-fetch.d.ts +24 -27
  56. package/dist/src/verified-fetch.d.ts.map +1 -1
  57. package/dist/src/verified-fetch.js +297 -150
  58. package/dist/src/verified-fetch.js.map +1 -1
  59. package/dist/typedoc-urls.json +25 -18
  60. package/package.json +58 -116
  61. package/src/index.ts +391 -72
  62. package/src/singleton.ts +20 -0
  63. package/src/types.ts +1 -0
  64. package/src/utils/dag-cbor-to-safe-json.ts +44 -0
  65. package/src/utils/get-content-disposition-filename.ts +18 -0
  66. package/src/utils/get-e-tag.ts +36 -0
  67. package/src/utils/{get-stream-and-content-type.ts → get-stream-from-async-iterable.ts} +10 -9
  68. package/src/utils/get-tar-stream.ts +68 -0
  69. package/src/utils/parse-url-string.ts +17 -3
  70. package/src/utils/responses.ts +29 -0
  71. package/src/utils/select-output-type.ts +167 -0
  72. package/src/utils/walk-path.ts +4 -5
  73. package/src/verified-fetch.ts +340 -153
  74. package/dist/src/utils/get-content-type.d.ts +0 -11
  75. package/dist/src/utils/get-content-type.d.ts.map +0 -1
  76. package/dist/src/utils/get-content-type.js +0 -43
  77. package/dist/src/utils/get-content-type.js.map +0 -1
  78. package/dist/src/utils/get-stream-and-content-type.d.ts +0 -9
  79. package/dist/src/utils/get-stream-and-content-type.d.ts.map +0 -1
  80. package/dist/src/utils/get-stream-and-content-type.js.map +0 -1
  81. package/src/utils/get-content-type.ts +0 -55
@@ -1,20 +1,30 @@
1
- import { dagCbor as heliaDagCbor } from '@helia/dag-cbor';
2
- import { dagJson as heliaDagJson } from '@helia/dag-json';
1
+ import { car } from '@helia/car';
3
2
  import { ipns as heliaIpns } from '@helia/ipns';
4
3
  import { dnsJsonOverHttps } from '@helia/ipns/dns-resolvers';
5
- import { json as heliaJson } from '@helia/json';
6
4
  import { unixfs as heliaUnixFs } from '@helia/unixfs';
7
- import { code as dagCborCode } from '@ipld/dag-cbor';
8
- import { code as dagJsonCode } from '@ipld/dag-json';
5
+ import * as ipldDagCbor from '@ipld/dag-cbor';
6
+ import * as ipldDagJson from '@ipld/dag-json';
9
7
  import { code as dagPbCode } from '@ipld/dag-pb';
10
- import { logger } from '@libp2p/logger';
8
+ import { Record as DHTRecord } from '@libp2p/kad-dht';
9
+ import { peerIdFromString } from '@libp2p/peer-id';
10
+ import { Key } from 'interface-datastore';
11
+ import toBrowserReadableStream from 'it-to-browser-readablestream';
11
12
  import { code as jsonCode } from 'multiformats/codecs/json';
12
- import { decode, code as rawCode } from 'multiformats/codecs/raw';
13
+ import { code as rawCode } from 'multiformats/codecs/raw';
14
+ import { identity } from 'multiformats/hashes/identity';
13
15
  import { CustomProgressEvent } from 'progress-events';
14
- import { getStreamAndContentType } from './utils/get-stream-and-content-type.js';
16
+ import { concat as uint8ArrayConcat } from 'uint8arrays/concat';
17
+ import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string';
18
+ import { toString as uint8ArrayToString } from 'uint8arrays/to-string';
19
+ import { dagCborToSafeJSON } from './utils/dag-cbor-to-safe-json.js';
20
+ import { getContentDispositionFilename } from './utils/get-content-disposition-filename.js';
21
+ import { getETag } from './utils/get-e-tag.js';
22
+ import { getStreamFromAsyncIterable } from './utils/get-stream-from-async-iterable.js';
23
+ import { tarStream } from './utils/get-tar-stream.js';
15
24
  import { parseResource } from './utils/parse-resource.js';
25
+ import { badRequestResponse, notAcceptableResponse, notSupportedResponse, okResponse } from './utils/responses.js';
26
+ import { selectOutputType, queryFormatToAcceptHeader } from './utils/select-output-type.js';
16
27
  import { walkPath } from './utils/walk-path.js';
17
- const log = logger('helia:verified-fetch');
18
28
  function convertOptions(options) {
19
29
  if (options == null) {
20
30
  return undefined;
@@ -28,221 +38,355 @@ function convertOptions(options) {
28
38
  signal
29
39
  };
30
40
  }
41
+ /**
42
+ * These are Accept header values that will cause content type sniffing to be
43
+ * skipped and set to these values.
44
+ */
45
+ const RAW_HEADERS = [
46
+ 'application/vnd.ipld.raw',
47
+ 'application/octet-stream'
48
+ ];
49
+ /**
50
+ * if the user has specified an `Accept` header, and it's in our list of
51
+ * allowable "raw" format headers, use that instead of detecting the content
52
+ * type. This avoids the user from receiving something different when they
53
+ * signal that they want to `Accept` a specific mime type.
54
+ */
55
+ function getOverridenRawContentType(headers) {
56
+ const acceptHeader = new Headers(headers).get('accept') ?? '';
57
+ // e.g. "Accept: text/html, application/xhtml+xml, application/xml;q=0.9, image/webp, */*;q=0.8"
58
+ const acceptHeaders = acceptHeader.split(',')
59
+ .map(s => s.split(';')[0])
60
+ .map(s => s.trim());
61
+ for (const mimeType of acceptHeaders) {
62
+ if (mimeType === '*/*') {
63
+ return;
64
+ }
65
+ if (RAW_HEADERS.includes(mimeType ?? '')) {
66
+ return mimeType;
67
+ }
68
+ }
69
+ }
31
70
  export class VerifiedFetch {
32
71
  helia;
33
72
  ipns;
34
73
  unixfs;
35
- dagJson;
36
- dagCbor;
37
- json;
38
- pathWalker;
39
- constructor({ helia, ipns, unixfs, dagJson, json, dagCbor, pathWalker }, init) {
74
+ log;
75
+ contentTypeParser;
76
+ constructor({ helia, ipns, unixfs }, init) {
40
77
  this.helia = helia;
78
+ this.log = helia.logger.forComponent('helia:verified-fetch');
41
79
  this.ipns = ipns ?? heliaIpns(helia, {
42
- resolvers: [
80
+ resolvers: init?.dnsResolvers ?? [
43
81
  dnsJsonOverHttps('https://mozilla.cloudflare-dns.com/dns-query'),
44
82
  dnsJsonOverHttps('https://dns.google/resolve')
45
83
  ]
46
84
  });
47
85
  this.unixfs = unixfs ?? heliaUnixFs(helia);
48
- this.dagJson = dagJson ?? heliaDagJson(helia);
49
- this.json = json ?? heliaJson(helia);
50
- this.dagCbor = dagCbor ?? heliaDagCbor(helia);
51
- this.pathWalker = pathWalker ?? walkPath;
52
- log.trace('created VerifiedFetch instance');
86
+ this.contentTypeParser = init?.contentTypeParser;
87
+ this.log.trace('created VerifiedFetch instance');
53
88
  }
54
- // handle vnd.ipfs.ipns-record
55
- async handleIPNSRecord({ cid, path, options }) {
56
- const response = new Response('vnd.ipfs.ipns-record support is not implemented', { status: 501 });
57
- response.headers.set('X-Content-Type-Options', 'nosniff'); // see https://specs.ipfs.tech/http-gateways/path-gateway/#x-content-type-options-response-header
89
+ /**
90
+ * Accepts an `ipns://...` URL as a string and returns a `Response` containing
91
+ * a raw IPNS record.
92
+ */
93
+ async handleIPNSRecord({ resource, cid, path, options }) {
94
+ if (path !== '' || !resource.startsWith('ipns://')) {
95
+ return badRequestResponse('Invalid IPNS name');
96
+ }
97
+ let peerId;
98
+ try {
99
+ peerId = peerIdFromString(resource.replace('ipns://', ''));
100
+ }
101
+ catch (err) {
102
+ this.log.error('could not parse peer id from IPNS url %s', resource);
103
+ return badRequestResponse('Invalid IPNS name');
104
+ }
105
+ // since this call happens after parseResource, we've already resolved the
106
+ // IPNS name so a local copy should be in the helia datastore, so we can
107
+ // just read it out..
108
+ const routingKey = uint8ArrayConcat([
109
+ uint8ArrayFromString('/ipns/'),
110
+ peerId.toBytes()
111
+ ]);
112
+ const datastoreKey = new Key('/dht/record/' + uint8ArrayToString(routingKey, 'base32'), false);
113
+ const buf = await this.helia.datastore.get(datastoreKey, options);
114
+ const record = DHTRecord.deserialize(buf);
115
+ const response = okResponse(record.value);
116
+ response.headers.set('content-type', 'application/vnd.ipfs.ipns-record');
58
117
  return response;
59
118
  }
60
- // handle vnd.ipld.car
61
- async handleIPLDCar({ cid, path, options }) {
62
- const response = new Response('vnd.ipld.car support is not implemented', { status: 501 });
63
- response.headers.set('X-Content-Type-Options', 'nosniff'); // see https://specs.ipfs.tech/http-gateways/path-gateway/#x-content-type-options-response-header
119
+ /**
120
+ * Accepts a `CID` and returns a `Response` with a body stream that is a CAR
121
+ * of the `DAG` referenced by the `CID`.
122
+ */
123
+ async handleCar({ cid, options }) {
124
+ const c = car(this.helia);
125
+ const stream = toBrowserReadableStream(c.stream(cid, options));
126
+ const response = okResponse(stream);
127
+ response.headers.set('content-type', 'application/vnd.ipld.car; version=1');
64
128
  return response;
65
129
  }
66
- async handleDagJson({ cid, path, options }) {
67
- log.trace('fetching %c/%s', cid, path);
68
- options?.onProgress?.(new CustomProgressEvent('verified-fetch:request:start', { cid: cid.toString(), path }));
69
- const result = await this.dagJson.get(cid, {
70
- signal: options?.signal,
71
- onProgress: options?.onProgress
72
- });
73
- options?.onProgress?.(new CustomProgressEvent('verified-fetch:request:end', { cid: cid.toString(), path }));
74
- const response = new Response(JSON.stringify(result), { status: 200 });
75
- response.headers.set('content-type', 'application/json');
130
+ /**
131
+ * Accepts a UnixFS `CID` and returns a `.tar` file containing the file or
132
+ * directory structure referenced by the `CID`.
133
+ */
134
+ async handleTar({ cid, path, options }) {
135
+ if (cid.code !== dagPbCode && cid.code !== rawCode) {
136
+ return notAcceptableResponse('only UnixFS data can be returned in a TAR file');
137
+ }
138
+ const stream = toBrowserReadableStream(tarStream(`/ipfs/${cid}/${path}`, this.helia.blockstore, options));
139
+ const response = okResponse(stream);
140
+ response.headers.set('content-type', 'application/x-tar');
76
141
  return response;
77
142
  }
78
- async handleJson({ cid, path, options }) {
79
- log.trace('fetching %c/%s', cid, path);
80
- options?.onProgress?.(new CustomProgressEvent('verified-fetch:request:start', { cid: cid.toString(), path }));
81
- const result = await this.json.get(cid, {
82
- signal: options?.signal,
83
- onProgress: options?.onProgress
84
- });
85
- options?.onProgress?.(new CustomProgressEvent('verified-fetch:request:end', { cid: cid.toString(), path }));
86
- const response = new Response(JSON.stringify(result), { status: 200 });
87
- response.headers.set('content-type', 'application/json');
143
+ async handleJson({ cid, path, accept, options }) {
144
+ this.log.trace('fetching %c/%s', cid, path);
145
+ const block = await this.helia.blockstore.get(cid, options);
146
+ let body;
147
+ if (accept === 'application/vnd.ipld.dag-cbor' || accept === 'application/cbor') {
148
+ try {
149
+ // if vnd.ipld.dag-cbor has been specified, convert to the format - note
150
+ // that this supports more data types than regular JSON, the content-type
151
+ // response header is set so the user knows to process it differently
152
+ const obj = ipldDagJson.decode(block);
153
+ body = ipldDagCbor.encode(obj);
154
+ }
155
+ catch (err) {
156
+ this.log.error('could not transform %c to application/vnd.ipld.dag-cbor', err);
157
+ return notAcceptableResponse();
158
+ }
159
+ }
160
+ else {
161
+ // skip decoding
162
+ body = block;
163
+ }
164
+ const response = okResponse(body);
165
+ response.headers.set('content-type', accept ?? 'application/json');
88
166
  return response;
89
167
  }
90
- async handleDagCbor({ cid, path, options }) {
91
- log.trace('fetching %c/%s', cid, path);
92
- options?.onProgress?.(new CustomProgressEvent('verified-fetch:request:start', { cid: cid.toString(), path }));
93
- const result = await this.dagCbor.get(cid, {
94
- signal: options?.signal,
95
- onProgress: options?.onProgress
96
- });
97
- options?.onProgress?.(new CustomProgressEvent('verified-fetch:request:end', { cid: cid.toString(), path }));
98
- const response = new Response(JSON.stringify(result), { status: 200 });
99
- response.headers.set('content-type', 'application/json');
168
+ async handleDagCbor({ cid, path, accept, options }) {
169
+ this.log.trace('fetching %c/%s', cid, path);
170
+ const block = await this.helia.blockstore.get(cid, options);
171
+ let body;
172
+ if (accept === 'application/octet-stream' || accept === 'application/vnd.ipld.dag-cbor' || accept === 'application/cbor') {
173
+ // skip decoding
174
+ body = block;
175
+ }
176
+ else if (accept === 'application/vnd.ipld.dag-json') {
177
+ try {
178
+ // if vnd.ipld.dag-json has been specified, convert to the format - note
179
+ // that this supports more data types than regular JSON, the content-type
180
+ // response header is set so the user knows to process it differently
181
+ const obj = ipldDagCbor.decode(block);
182
+ body = ipldDagJson.encode(obj);
183
+ }
184
+ catch (err) {
185
+ this.log.error('could not transform %c to application/vnd.ipld.dag-json', err);
186
+ return notAcceptableResponse();
187
+ }
188
+ }
189
+ else {
190
+ try {
191
+ body = dagCborToSafeJSON(block);
192
+ }
193
+ catch (err) {
194
+ if (accept === 'application/json') {
195
+ this.log('could not decode DAG-CBOR as JSON-safe, but the client sent "Accept: application/json"', err);
196
+ return notAcceptableResponse();
197
+ }
198
+ this.log('could not decode DAG-CBOR as JSON-safe, falling back to `application/octet-stream`', err);
199
+ body = block;
200
+ }
201
+ }
202
+ const response = okResponse(body);
203
+ if (accept == null) {
204
+ accept = body instanceof Uint8Array ? 'application/octet-stream' : 'application/json';
205
+ }
206
+ response.headers.set('content-type', accept);
100
207
  return response;
101
208
  }
102
- async handleDagPb({ cid, path, options, terminalElement }) {
103
- log.trace('fetching %c/%s', cid, path);
209
+ async handleDagPb({ cid, path, options }) {
210
+ let terminalElement;
211
+ let ipfsRoots;
212
+ try {
213
+ const pathDetails = await walkPath(this.helia.blockstore, `${cid.toString()}/${path}`, options);
214
+ ipfsRoots = pathDetails.ipfsRoots;
215
+ terminalElement = pathDetails.terminalElement;
216
+ }
217
+ catch (err) {
218
+ this.log.error('Error walking path %s', path, err);
219
+ }
104
220
  let resolvedCID = terminalElement?.cid ?? cid;
105
221
  let stat;
106
222
  if (terminalElement?.type === 'directory') {
107
223
  const dirCid = terminalElement.cid;
108
224
  const rootFilePath = 'index.html';
109
225
  try {
110
- log.trace('found directory at %c/%s, looking for index.html', cid, path);
111
- options?.onProgress?.(new CustomProgressEvent('verified-fetch:request:start', { cid: dirCid.toString(), path: rootFilePath }));
226
+ this.log.trace('found directory at %c/%s, looking for index.html', cid, path);
112
227
  stat = await this.unixfs.stat(dirCid, {
113
228
  path: rootFilePath,
114
229
  signal: options?.signal,
115
230
  onProgress: options?.onProgress
116
231
  });
117
- log.trace('found root file at %c/%s with cid %c', dirCid, rootFilePath, stat.cid);
232
+ this.log.trace('found root file at %c/%s with cid %c', dirCid, rootFilePath, stat.cid);
118
233
  path = rootFilePath;
119
234
  resolvedCID = stat.cid;
120
235
  // terminalElement = stat
121
236
  }
122
237
  catch (err) {
123
- log('error loading path %c/%s', dirCid, rootFilePath, err);
124
- return new Response('Unable to find index.html for directory at given path. Support for directories with implicit root is not implemented', { status: 501 });
238
+ this.log('error loading path %c/%s', dirCid, rootFilePath, err);
239
+ return notSupportedResponse('Unable to find index.html for directory at given path. Support for directories with implicit root is not implemented');
125
240
  }
126
241
  finally {
127
- options?.onProgress?.(new CustomProgressEvent('verified-fetch:request:end', { cid: dirCid.toString(), path: rootFilePath }));
242
+ options?.onProgress?.(new CustomProgressEvent('verified-fetch:request:end', { cid: dirCid, path: rootFilePath }));
128
243
  }
129
244
  }
130
- options?.onProgress?.(new CustomProgressEvent('verified-fetch:request:start', { cid: resolvedCID.toString(), path: '' }));
131
245
  const asyncIter = this.unixfs.cat(resolvedCID, {
132
246
  signal: options?.signal,
133
247
  onProgress: options?.onProgress
134
248
  });
135
- options?.onProgress?.(new CustomProgressEvent('verified-fetch:request:end', { cid: resolvedCID.toString(), path: '' }));
136
- log('got async iterator for %c/%s', cid, path);
137
- const { contentType, stream } = await getStreamAndContentType(asyncIter, path ?? '', {
249
+ this.log('got async iterator for %c/%s', cid, path);
250
+ const { stream, firstChunk } = await getStreamFromAsyncIterable(asyncIter, path ?? '', this.helia.logger, {
138
251
  onProgress: options?.onProgress
139
252
  });
140
- const response = new Response(stream, { status: 200 });
141
- response.headers.set('content-type', contentType);
253
+ const response = okResponse(stream);
254
+ await this.setContentType(firstChunk, path, response);
255
+ if (ipfsRoots != null) {
256
+ response.headers.set('X-Ipfs-Roots', ipfsRoots.map(cid => cid.toV1().toString()).join(',')); // https://specs.ipfs.tech/http-gateways/path-gateway/#x-ipfs-roots-response-header
257
+ }
142
258
  return response;
143
259
  }
144
260
  async handleRaw({ cid, path, options }) {
145
- log.trace('fetching %c/%s', cid, path);
146
- options?.onProgress?.(new CustomProgressEvent('verified-fetch:request:start', { cid: cid.toString(), path }));
147
- const result = await this.helia.blockstore.get(cid);
148
- options?.onProgress?.(new CustomProgressEvent('verified-fetch:request:end', { cid: cid.toString(), path }));
149
- const response = new Response(decode(result), { status: 200 });
150
- response.headers.set('content-type', 'application/octet-stream');
261
+ const result = await this.helia.blockstore.get(cid, options);
262
+ const response = okResponse(result);
263
+ // if the user has specified an `Accept` header that corresponds to a raw
264
+ // type, honour that header, so for example they don't request
265
+ // `application/vnd.ipld.raw` but get `application/octet-stream`
266
+ const overriddenContentType = getOverridenRawContentType(options?.headers);
267
+ if (overriddenContentType != null) {
268
+ response.headers.set('content-type', overriddenContentType);
269
+ }
270
+ else {
271
+ await this.setContentType(result, path, response);
272
+ }
151
273
  return response;
152
274
  }
153
- /**
154
- * Determines the format requested by the client, defaults to `null` if no format is requested.
155
- *
156
- * @see https://specs.ipfs.tech/http-gateways/path-gateway/#format-request-query-parameter
157
- * @default 'raw'
158
- */
159
- getFormat({ headerFormat, queryFormat }) {
160
- const formatMap = {
161
- 'vnd.ipld.raw': 'raw',
162
- 'vnd.ipld.car': 'car',
163
- 'application/x-tar': 'tar',
164
- 'application/vnd.ipld.dag-json': 'dag-json',
165
- 'application/vnd.ipld.dag-cbor': 'dag-cbor',
166
- 'application/json': 'json',
167
- 'application/cbor': 'cbor',
168
- 'vnd.ipfs.ipns-record': 'ipns-record'
169
- };
170
- if (headerFormat != null) {
171
- for (const format in formatMap) {
172
- if (headerFormat.includes(format)) {
173
- return formatMap[format];
275
+ async setContentType(bytes, path, response) {
276
+ let contentType = 'application/octet-stream';
277
+ if (this.contentTypeParser != null) {
278
+ try {
279
+ let fileName = path.split('/').pop()?.trim();
280
+ fileName = fileName === '' ? undefined : fileName;
281
+ const parsed = this.contentTypeParser(bytes, fileName);
282
+ if (isPromise(parsed)) {
283
+ const result = await parsed;
284
+ if (result != null) {
285
+ contentType = result;
286
+ }
287
+ }
288
+ else if (parsed != null) {
289
+ contentType = parsed;
174
290
  }
175
291
  }
292
+ catch (err) {
293
+ this.log.error('Error parsing content type', err);
294
+ }
176
295
  }
177
- else if (queryFormat != null) {
178
- return queryFormat;
179
- }
180
- return null;
296
+ response.headers.set('content-type', contentType);
181
297
  }
182
298
  /**
183
- * Map of format to specific handlers for that format.
184
- * These format handlers should adjust the response headers as specified in https://specs.ipfs.tech/http-gateways/path-gateway/#response-headers
299
+ * If the user has not specified an Accept header or format query string arg,
300
+ * use the CID codec to choose an appropriate handler for the block data.
185
301
  */
186
- formatHandlers = {
187
- raw: async () => new Response('application/vnd.ipld.raw support is not implemented', { status: 501 }),
188
- car: this.handleIPLDCar,
189
- 'ipns-record': this.handleIPNSRecord,
190
- tar: async () => new Response('application/x-tar support is not implemented', { status: 501 }),
191
- 'dag-json': async () => new Response('application/vnd.ipld.dag-json support is not implemented', { status: 501 }),
192
- 'dag-cbor': async () => new Response('application/vnd.ipld.dag-cbor support is not implemented', { status: 501 }),
193
- json: async () => new Response('application/json support is not implemented', { status: 501 }),
194
- cbor: async () => new Response('application/cbor support is not implemented', { status: 501 })
195
- };
196
302
  codecHandlers = {
197
- [dagJsonCode]: this.handleDagJson,
198
303
  [dagPbCode]: this.handleDagPb,
304
+ [ipldDagJson.code]: this.handleJson,
199
305
  [jsonCode]: this.handleJson,
200
- [dagCborCode]: this.handleDagCbor,
201
- [rawCode]: this.handleRaw
306
+ [ipldDagCbor.code]: this.handleDagCbor,
307
+ [rawCode]: this.handleRaw,
308
+ [identity.code]: this.handleRaw
202
309
  };
203
310
  async fetch(resource, opts) {
311
+ this.log('fetch %s', resource);
204
312
  const options = convertOptions(opts);
205
- const { path, query, ...rest } = await parseResource(resource, this.ipns, options);
206
- const cid = rest.cid;
313
+ options?.onProgress?.(new CustomProgressEvent('verified-fetch:request:start', { resource }));
314
+ // resolve the CID/path from the requested resource
315
+ const { path, query, cid } = await parseResource(resource, { ipns: this.ipns, logger: this.helia.logger }, options);
316
+ options?.onProgress?.(new CustomProgressEvent('verified-fetch:request:resolve', { cid, path }));
317
+ const requestHeaders = new Headers(options?.headers);
318
+ const incomingAcceptHeader = requestHeaders.get('accept');
319
+ if (incomingAcceptHeader != null) {
320
+ this.log('incoming accept header "%s"', incomingAcceptHeader);
321
+ }
322
+ const queryFormatMapping = queryFormatToAcceptHeader(query.format);
323
+ if (query.format != null) {
324
+ this.log('incoming query format "%s", mapped to %s', query.format, queryFormatMapping);
325
+ }
326
+ const acceptHeader = incomingAcceptHeader ?? queryFormatMapping;
327
+ const accept = selectOutputType(cid, acceptHeader);
328
+ this.log('output type %s', accept);
329
+ if (acceptHeader != null && accept == null) {
330
+ return notAcceptableResponse();
331
+ }
207
332
  let response;
208
- const format = this.getFormat({ headerFormat: new Headers(options?.headers).get('accept'), queryFormat: query.format ?? null });
209
- if (format != null) {
210
- // TODO: These should be handled last when they're returning something other than 501
211
- const formatHandler = this.formatHandlers[format];
212
- if (formatHandler != null) {
213
- response = await formatHandler.call(this, { cid, path, options });
214
- if (response.status === 501) {
215
- return response;
216
- }
217
- }
333
+ let reqFormat;
334
+ const handlerArgs = { resource: resource.toString(), cid, path, accept, options };
335
+ if (accept === 'application/vnd.ipfs.ipns-record') {
336
+ // the user requested a raw IPNS record
337
+ reqFormat = 'ipns-record';
338
+ response = await this.handleIPNSRecord(handlerArgs);
218
339
  }
219
- let terminalElement;
220
- let ipfsRoots;
221
- try {
222
- const pathDetails = await this.pathWalker(this.helia.blockstore, `${cid.toString()}/${path}`, options);
223
- ipfsRoots = pathDetails.ipfsRoots.join(',');
224
- terminalElement = pathDetails.terminalElement;
340
+ else if (accept === 'application/vnd.ipld.car') {
341
+ // the user requested a CAR file
342
+ reqFormat = 'car';
343
+ query.download = true;
344
+ query.filename = query.filename ?? `${cid.toString()}.car`;
345
+ response = await this.handleCar(handlerArgs);
225
346
  }
226
- catch (err) {
227
- log.error('Error walking path %s', path, err);
228
- // return new Response(`Error walking path: ${(err as Error).message}`, { status: 500 })
347
+ else if (accept === 'application/vnd.ipld.raw') {
348
+ // the user requested a raw block
349
+ reqFormat = 'raw';
350
+ query.download = true;
351
+ query.filename = query.filename ?? `${cid.toString()}.bin`;
352
+ response = await this.handleRaw(handlerArgs);
229
353
  }
230
- if (response == null) {
354
+ else if (accept === 'application/x-tar') {
355
+ // the user requested a TAR file
356
+ reqFormat = 'tar';
357
+ query.download = true;
358
+ query.filename = query.filename ?? `${cid.toString()}.tar`;
359
+ response = await this.handleTar(handlerArgs);
360
+ }
361
+ else {
362
+ // derive the handler from the CID type
231
363
  const codecHandler = this.codecHandlers[cid.code];
232
- if (codecHandler != null) {
233
- response = await codecHandler.call(this, { cid, path, options, terminalElement });
364
+ if (codecHandler == null) {
365
+ return notSupportedResponse(`Support for codec with code ${cid.code} is not yet implemented. Please open an issue at https://github.com/ipfs/helia/issues/new`);
234
366
  }
235
- else {
236
- return new Response(`Support for codec with code ${cid.code} is not yet implemented. Please open an issue at https://github.com/ipfs/helia/issues/new`, { status: 501 });
367
+ response = await codecHandler.call(this, handlerArgs);
368
+ }
369
+ response.headers.set('etag', getETag({ cid, reqFormat, weak: false }));
370
+ response.headers.set('cache-control', 'public, max-age=29030400, immutable');
371
+ // https://specs.ipfs.tech/http-gateways/path-gateway/#x-ipfs-path-response-header
372
+ response.headers.set('X-Ipfs-Path', resource.toString());
373
+ // set Content-Disposition header
374
+ let contentDisposition;
375
+ // force download if requested
376
+ if (query.download === true) {
377
+ contentDisposition = 'attachment';
378
+ }
379
+ // override filename if requested
380
+ if (query.filename != null) {
381
+ if (contentDisposition == null) {
382
+ contentDisposition = 'inline';
237
383
  }
384
+ contentDisposition = `${contentDisposition}; ${getContentDispositionFilename(query.filename)}`;
238
385
  }
239
- response.headers.set('etag', cid.toString()); // https://specs.ipfs.tech/http-gateways/path-gateway/#etag-response-header
240
- response.headers.set('cache-cotrol', 'public, max-age=29030400, immutable');
241
- response.headers.set('X-Ipfs-Path', resource.toString()); // https://specs.ipfs.tech/http-gateways/path-gateway/#x-ipfs-path-response-header
242
- if (ipfsRoots != null) {
243
- response.headers.set('X-Ipfs-Roots', ipfsRoots); // https://specs.ipfs.tech/http-gateways/path-gateway/#x-ipfs-roots-response-header
386
+ if (contentDisposition != null) {
387
+ response.headers.set('Content-Disposition', contentDisposition);
244
388
  }
245
- // response.headers.set('Content-Disposition', `TODO`) // https://specs.ipfs.tech/http-gateways/path-gateway/#content-disposition-response-header
389
+ options?.onProgress?.(new CustomProgressEvent('verified-fetch:request:end', { cid, path }));
246
390
  return response;
247
391
  }
248
392
  /**
@@ -258,4 +402,7 @@ export class VerifiedFetch {
258
402
  await this.helia.stop();
259
403
  }
260
404
  }
405
+ function isPromise(p) {
406
+ return p?.then != null;
407
+ }
261
408
  //# sourceMappingURL=verified-fetch.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"verified-fetch.js","sourceRoot":"","sources":["../../src/verified-fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,YAAY,EAAgB,MAAM,iBAAiB,CAAA;AACvE,OAAO,EAAE,OAAO,IAAI,YAAY,EAAgB,MAAM,iBAAiB,CAAA;AACvE,OAAO,EAAE,IAAI,IAAI,SAAS,EAAa,MAAM,aAAa,CAAA;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AAC5D,OAAO,EAAE,IAAI,IAAI,SAAS,EAAa,MAAM,aAAa,CAAA;AAC1D,OAAO,EAAE,MAAM,IAAI,WAAW,EAAgD,MAAM,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