@helia/verified-fetch 0.0.0-9b1ddf8 → 0.0.0-dc2e7a6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,4 @@
1
- import { type DAGCBOR } from '@helia/dag-cbor';
2
- import { type DAGJSON } from '@helia/dag-json';
3
1
  import { type IPNS } from '@helia/ipns';
4
- import { type JSON } from '@helia/json';
5
2
  import { type UnixFS as HeliaUnixFs } from '@helia/unixfs';
6
3
  import { type PathWalkerFn } from './utils/walk-path.js';
7
4
  import type { ContentTypeParser, Resource, VerifiedFetchInit as VerifiedFetchOptions } from './index.js';
@@ -10,9 +7,6 @@ interface VerifiedFetchComponents {
10
7
  helia: Helia;
11
8
  ipns?: IPNS;
12
9
  unixfs?: HeliaUnixFs;
13
- dagJson?: DAGJSON;
14
- json?: JSON;
15
- dagCbor?: DAGCBOR;
16
10
  pathWalker?: PathWalkerFn;
17
11
  }
18
12
  /**
@@ -25,16 +19,12 @@ export declare class VerifiedFetch {
25
19
  private readonly helia;
26
20
  private readonly ipns;
27
21
  private readonly unixfs;
28
- private readonly dagJson;
29
- private readonly dagCbor;
30
- private readonly json;
31
22
  private readonly pathWalker;
32
23
  private readonly log;
33
24
  private readonly contentTypeParser;
34
- constructor({ helia, ipns, unixfs, dagJson, json, dagCbor, pathWalker }: VerifiedFetchComponents, init?: VerifiedFetchInit);
25
+ constructor({ helia, ipns, unixfs, pathWalker }: VerifiedFetchComponents, init?: VerifiedFetchInit);
35
26
  private handleIPNSRecord;
36
27
  private handleIPLDCar;
37
- private handleDagJson;
38
28
  private handleJson;
39
29
  private handleDagCbor;
40
30
  private handleDagPb;
@@ -1 +1 @@
1
- {"version":3,"file":"verified-fetch.d.ts","sourceRoot":"","sources":["../../src/verified-fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,OAAO,EAAE,MAAM,iBAAiB,CAAA;AACvE,OAAO,EAA2B,KAAK,OAAO,EAAE,M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AA0CD,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAO;IAC7B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAM;IAC3B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAa;IACpC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAc;IACzC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAQ;IAC5B,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAA+B;gBAEpD,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,uBAAuB,EAAE,IAAI,CAAC,EAAE,iBAAiB;YAgBrF,gBAAgB;YAOhB,aAAa;YAMb,UAAU;YAaV,aAAa;YAoBb,WAAW;YA8CX,SAAS;YAWT,cAAc;IA0B5B;;;;;OAKG;IACH,OAAO,CAAC,SAAS;IAyBjB;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,cAAc,CAS9B;IAED,OAAO,CAAC,QAAQ,CAAC,aAAa,CAO7B;IAEK,KAAK,CAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,QAAQ,CAAC;IAuDhF;;OAEG;IACG,KAAK,IAAK,OAAO,CAAC,IAAI,CAAC;IAI7B;;OAEG;IACG,IAAI,IAAK,OAAO,CAAC,IAAI,CAAC;CAG7B"}
@@ -1,15 +1,15 @@
1
- import { dagCbor as heliaDagCbor } from '@helia/dag-cbor';
2
- import { dagJson as heliaDagJson } from '@helia/dag-json';
3
1
  import { ipns as heliaIpns } from '@helia/ipns';
4
2
  import { dnsJsonOverHttps } from '@helia/ipns/dns-resolvers';
5
- import { json as heliaJson } from '@helia/json';
6
3
  import { unixfs as heliaUnixFs } from '@helia/unixfs';
7
4
  import { code as dagCborCode } from '@ipld/dag-cbor';
8
5
  import { code as dagJsonCode } from '@ipld/dag-json';
9
6
  import { code as dagPbCode } from '@ipld/dag-pb';
10
7
  import { code as jsonCode } from 'multiformats/codecs/json';
11
- import { decode, code as rawCode } from 'multiformats/codecs/raw';
8
+ import { code as rawCode } from 'multiformats/codecs/raw';
9
+ import { identity } from 'multiformats/hashes/identity';
12
10
  import { CustomProgressEvent } from 'progress-events';
11
+ import { dagCborToSafeJSON } from './utils/dag-cbor-to-safe-json.js';
12
+ import { getETag } from './utils/get-e-tag.js';
13
13
  import { getStreamFromAsyncIterable } from './utils/get-stream-from-async-iterable.js';
14
14
  import { parseResource } from './utils/parse-resource.js';
15
15
  import { walkPath } from './utils/walk-path.js';
@@ -26,17 +26,26 @@ function convertOptions(options) {
26
26
  signal
27
27
  };
28
28
  }
29
+ function okResponse(body) {
30
+ return new Response(body, {
31
+ status: 200,
32
+ statusText: 'OK'
33
+ });
34
+ }
35
+ function notSupportedResponse(body) {
36
+ return new Response(body, {
37
+ status: 501,
38
+ statusText: 'Not Implemented'
39
+ });
40
+ }
29
41
  export class VerifiedFetch {
30
42
  helia;
31
43
  ipns;
32
44
  unixfs;
33
- dagJson;
34
- dagCbor;
35
- json;
36
45
  pathWalker;
37
46
  log;
38
47
  contentTypeParser;
39
- constructor({ helia, ipns, unixfs, dagJson, json, dagCbor, pathWalker }, init) {
48
+ constructor({ helia, ipns, unixfs, pathWalker }, init) {
40
49
  this.helia = helia;
41
50
  this.log = helia.logger.forComponent('helia:verified-fetch');
42
51
  this.ipns = ipns ?? heliaIpns(helia, {
@@ -46,59 +55,50 @@ export class VerifiedFetch {
46
55
  ]
47
56
  });
48
57
  this.unixfs = unixfs ?? heliaUnixFs(helia);
49
- this.dagJson = dagJson ?? heliaDagJson(helia);
50
- this.json = json ?? heliaJson(helia);
51
- this.dagCbor = dagCbor ?? heliaDagCbor(helia);
52
58
  this.pathWalker = pathWalker ?? walkPath;
53
59
  this.contentTypeParser = init?.contentTypeParser;
54
60
  this.log.trace('created VerifiedFetch instance');
55
61
  }
56
62
  // handle vnd.ipfs.ipns-record
57
63
  async handleIPNSRecord({ cid, path, options }) {
58
- const response = new Response('vnd.ipfs.ipns-record support is not implemented', { status: 501 });
64
+ const response = notSupportedResponse('vnd.ipfs.ipns-record support is not implemented');
59
65
  response.headers.set('X-Content-Type-Options', 'nosniff'); // see https://specs.ipfs.tech/http-gateways/path-gateway/#x-content-type-options-response-header
60
66
  return response;
61
67
  }
62
68
  // handle vnd.ipld.car
63
69
  async handleIPLDCar({ cid, path, options }) {
64
- const response = new Response('vnd.ipld.car support is not implemented', { status: 501 });
70
+ const response = notSupportedResponse('vnd.ipld.car support is not implemented');
65
71
  response.headers.set('X-Content-Type-Options', 'nosniff'); // see https://specs.ipfs.tech/http-gateways/path-gateway/#x-content-type-options-response-header
66
72
  return response;
67
73
  }
68
- async handleDagJson({ cid, path, options }) {
69
- this.log.trace('fetching %c/%s', cid, path);
70
- options?.onProgress?.(new CustomProgressEvent('verified-fetch:request:start', { cid, path }));
71
- const result = await this.dagJson.get(cid, {
72
- signal: options?.signal,
73
- onProgress: options?.onProgress
74
- });
75
- options?.onProgress?.(new CustomProgressEvent('verified-fetch:request:end', { cid, path }));
76
- const response = new Response(JSON.stringify(result), { status: 200 });
77
- response.headers.set('content-type', 'application/json');
78
- return response;
79
- }
80
74
  async handleJson({ cid, path, options }) {
81
75
  this.log.trace('fetching %c/%s', cid, path);
82
76
  options?.onProgress?.(new CustomProgressEvent('verified-fetch:request:start', { cid, path }));
83
- const result = await this.json.get(cid, {
77
+ const result = await this.helia.blockstore.get(cid, {
84
78
  signal: options?.signal,
85
79
  onProgress: options?.onProgress
86
80
  });
87
- options?.onProgress?.(new CustomProgressEvent('verified-fetch:request:end', { cid, path }));
88
- const response = new Response(JSON.stringify(result), { status: 200 });
81
+ const response = okResponse(result);
89
82
  response.headers.set('content-type', 'application/json');
83
+ options?.onProgress?.(new CustomProgressEvent('verified-fetch:request:end', { cid, path }));
90
84
  return response;
91
85
  }
92
86
  async handleDagCbor({ cid, path, options }) {
93
87
  this.log.trace('fetching %c/%s', cid, path);
94
88
  options?.onProgress?.(new CustomProgressEvent('verified-fetch:request:start', { cid, path }));
95
- const result = await this.dagCbor.get(cid, {
96
- signal: options?.signal,
97
- onProgress: options?.onProgress
98
- });
89
+ // return body as binary
90
+ const block = await this.helia.blockstore.get(cid);
91
+ let body;
92
+ try {
93
+ body = dagCborToSafeJSON(block);
94
+ }
95
+ catch (err) {
96
+ this.log('could not decode DAG-CBOR as JSON-safe, falling back to `application/octet-stream`', err);
97
+ body = block;
98
+ }
99
+ const response = okResponse(body);
100
+ response.headers.set('content-type', body instanceof Uint8Array ? 'application/octet-stream' : 'application/json');
99
101
  options?.onProgress?.(new CustomProgressEvent('verified-fetch:request:end', { cid, path }));
100
- const response = new Response(result, { status: 200 });
101
- await this.setContentType(result, path, response);
102
102
  return response;
103
103
  }
104
104
  async handleDagPb({ cid, path, options, terminalElement }) {
@@ -123,7 +123,7 @@ export class VerifiedFetch {
123
123
  }
124
124
  catch (err) {
125
125
  this.log('error loading path %c/%s', dirCid, rootFilePath, err);
126
- return new Response('Unable to find index.html for directory at given path. Support for directories with implicit root is not implemented', { status: 501 });
126
+ return notSupportedResponse('Unable to find index.html for directory at given path. Support for directories with implicit root is not implemented');
127
127
  }
128
128
  finally {
129
129
  options?.onProgress?.(new CustomProgressEvent('verified-fetch:request:end', { cid: dirCid, path: rootFilePath }));
@@ -134,22 +134,22 @@ export class VerifiedFetch {
134
134
  signal: options?.signal,
135
135
  onProgress: options?.onProgress
136
136
  });
137
- options?.onProgress?.(new CustomProgressEvent('verified-fetch:request:end', { cid: resolvedCID, path: '' }));
138
137
  this.log('got async iterator for %c/%s', cid, path);
139
138
  const { stream, firstChunk } = await getStreamFromAsyncIterable(asyncIter, path ?? '', this.helia.logger, {
140
139
  onProgress: options?.onProgress
141
140
  });
142
- const response = new Response(stream, { status: 200 });
141
+ const response = okResponse(stream);
143
142
  await this.setContentType(firstChunk, path, response);
143
+ options?.onProgress?.(new CustomProgressEvent('verified-fetch:request:end', { cid: resolvedCID, path: '' }));
144
144
  return response;
145
145
  }
146
146
  async handleRaw({ cid, path, options }) {
147
147
  this.log.trace('fetching %c/%s', cid, path);
148
148
  options?.onProgress?.(new CustomProgressEvent('verified-fetch:request:start', { cid, path }));
149
149
  const result = await this.helia.blockstore.get(cid);
150
- options?.onProgress?.(new CustomProgressEvent('verified-fetch:request:end', { cid, path }));
151
- const response = new Response(decode(result), { status: 200 });
150
+ const response = okResponse(result);
152
151
  await this.setContentType(result, path, response);
152
+ options?.onProgress?.(new CustomProgressEvent('verified-fetch:request:end', { cid, path }));
153
153
  return response;
154
154
  }
155
155
  async setContentType(bytes, path, response) {
@@ -209,21 +209,22 @@ export class VerifiedFetch {
209
209
  * These format handlers should adjust the response headers as specified in https://specs.ipfs.tech/http-gateways/path-gateway/#response-headers
210
210
  */
211
211
  formatHandlers = {
212
- raw: async () => new Response('application/vnd.ipld.raw support is not implemented', { status: 501 }),
212
+ raw: async () => notSupportedResponse('application/vnd.ipld.raw support is not implemented'),
213
213
  car: this.handleIPLDCar,
214
214
  'ipns-record': this.handleIPNSRecord,
215
- tar: async () => new Response('application/x-tar support is not implemented', { status: 501 }),
216
- 'dag-json': async () => new Response('application/vnd.ipld.dag-json support is not implemented', { status: 501 }),
217
- 'dag-cbor': async () => new Response('application/vnd.ipld.dag-cbor support is not implemented', { status: 501 }),
218
- json: async () => new Response('application/json support is not implemented', { status: 501 }),
219
- cbor: async () => new Response('application/cbor support is not implemented', { status: 501 })
215
+ tar: async () => notSupportedResponse('application/x-tar support is not implemented'),
216
+ 'dag-json': async () => notSupportedResponse('application/vnd.ipld.dag-json support is not implemented'),
217
+ 'dag-cbor': async () => notSupportedResponse('application/vnd.ipld.dag-cbor support is not implemented'),
218
+ json: async () => notSupportedResponse('application/json support is not implemented'),
219
+ cbor: async () => notSupportedResponse('application/cbor support is not implemented')
220
220
  };
221
221
  codecHandlers = {
222
- [dagJsonCode]: this.handleDagJson,
223
222
  [dagPbCode]: this.handleDagPb,
223
+ [dagJsonCode]: this.handleJson,
224
224
  [jsonCode]: this.handleJson,
225
225
  [dagCborCode]: this.handleDagCbor,
226
- [rawCode]: this.handleRaw
226
+ [rawCode]: this.handleRaw,
227
+ [identity.code]: this.handleRaw
227
228
  };
228
229
  async fetch(resource, opts) {
229
230
  const options = convertOptions(opts);
@@ -258,11 +259,11 @@ export class VerifiedFetch {
258
259
  response = await codecHandler.call(this, { cid, path, options, terminalElement });
259
260
  }
260
261
  else {
261
- 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 });
262
+ 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`);
262
263
  }
263
264
  }
264
- response.headers.set('etag', cid.toString()); // https://specs.ipfs.tech/http-gateways/path-gateway/#etag-response-header
265
- response.headers.set('cache-cotrol', 'public, max-age=29030400, immutable');
265
+ response.headers.set('etag', getETag({ cid, reqFormat: format ?? undefined, weak: false }));
266
+ response.headers.set('cache-control', 'public, max-age=29030400, immutable');
266
267
  response.headers.set('X-Ipfs-Path', resource.toString()); // https://specs.ipfs.tech/http-gateways/path-gateway/#x-ipfs-path-response-header
267
268
  if (ipfsRoots != null) {
268
269
  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
@@ -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;A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qCAAqC,CAAC,CAAA;QAC5E,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAA,CAAC,kFAAkF;QAE3I,IAAI,SAAS,IAAI,IAAI,EAAE,CAAC;YACtB,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA,CAAC,mFAAmF;QACjL,CAAC;QACD,iJAAiJ;QAEjJ,OAAO,QAAQ,CAAA;IACjB,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;AAED,SAAS,SAAS,CAAM,CAAO;IAC7B,OAAO,CAAC,EAAE,IAAI,IAAI,IAAI,CAAA;AACxB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@helia/verified-fetch",
3
- "version": "0.0.0-9b1ddf8",
3
+ "version": "0.0.0-dc2e7a6",
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/tree/main/packages/verified-fetch#readme",
@@ -141,32 +141,38 @@
141
141
  "release": "aegir release"
142
142
  },
143
143
  "dependencies": {
144
- "@helia/block-brokers": "2.0.1-9b1ddf8",
145
- "@helia/dag-cbor": "3.0.0-9b1ddf8",
146
- "@helia/dag-json": "3.0.0-9b1ddf8",
147
- "@helia/http": "1.0.1-9b1ddf8",
148
- "@helia/interface": "4.0.0-9b1ddf8",
149
- "@helia/ipns": "6.0.0-9b1ddf8",
150
- "@helia/json": "3.0.0-9b1ddf8",
151
- "@helia/routers": "1.0.0-9b1ddf8",
152
- "@helia/unixfs": "3.0.0-9b1ddf8",
153
- "@ipld/dag-cbor": "^9.1.0",
154
- "@ipld/dag-json": "^10.1.7",
155
- "@ipld/dag-pb": "^4.0.8",
144
+ "@helia/block-brokers": "2.0.1-dc2e7a6",
145
+ "@helia/http": "1.0.1-dc2e7a6",
146
+ "@helia/interface": "4.0.0-dc2e7a6",
147
+ "@helia/ipns": "6.0.0-dc2e7a6",
148
+ "@helia/routers": "1.0.0-dc2e7a6",
149
+ "@helia/unixfs": "3.0.0-dc2e7a6",
150
+ "@ipld/dag-cbor": "^9.2.0",
151
+ "@ipld/dag-json": "^10.2.0",
152
+ "@ipld/dag-pb": "^4.1.0",
156
153
  "@libp2p/interface": "^1.1.2",
157
154
  "@libp2p/peer-id": "^4.0.5",
155
+ "cborg": "^4.0.9",
158
156
  "hashlru": "^2.3.0",
159
157
  "ipfs-unixfs-exporter": "^13.5.0",
160
- "multiformats": "^13.0.1",
158
+ "multiformats": "^13.1.0",
161
159
  "progress-events": "^1.0.0"
162
160
  },
163
161
  "devDependencies": {
162
+ "@helia/dag-cbor": "3.0.0-dc2e7a6",
163
+ "@helia/dag-json": "3.0.0-dc2e7a6",
164
+ "@helia/json": "3.0.0-dc2e7a6",
165
+ "@helia/utils": "0.0.1-dc2e7a6",
164
166
  "@libp2p/logger": "^4.0.5",
165
167
  "@libp2p/peer-id-factory": "^4.0.5",
166
168
  "@sgtpooki/file-type": "^1.0.1",
167
169
  "@types/sinon": "^17.0.3",
168
170
  "aegir": "^42.2.2",
169
- "helia": "4.0.1-9b1ddf8",
171
+ "blockstore-core": "^4.4.0",
172
+ "datastore-core": "^9.2.8",
173
+ "helia": "4.0.1-dc2e7a6",
174
+ "it-last": "^3.0.4",
175
+ "it-to-buffer": "^4.0.5",
170
176
  "magic-bytes.js": "^1.8.0",
171
177
  "sinon": "^17.0.1",
172
178
  "sinon-ts": "^2.0.0",
package/src/index.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * `@helia/verified-fetch` provides a [fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)-like API for retrieving content from the [IPFS](https://ipfs.tech/) network.
5
5
  *
6
- * All content is retrieved in a [trustless manner](https://www.techopedia.com/definition/trustless), and the integrity of all bytes are verified by comparing hashes of the data.
6
+ * All content is retrieved in a [trustless manner](https://www.techopedia.com/definition/trustless), and the integrity of all bytes are verified by comparing hashes of the data. By default, CIDs are retrieved over HTTP from [trustless gateways](https://specs.ipfs.tech/http-gateways/trustless-gateway/).
7
7
  *
8
8
  * This is a marked improvement over `fetch` which offers no such protections and is vulnerable to all sorts of attacks like [Content Spoofing](https://owasp.org/www-community/attacks/Content_Spoofing), [DNS Hijacking](https://en.wikipedia.org/wiki/DNS_hijacking), etc.
9
9
  *
@@ -33,7 +33,7 @@
33
33
  * import { verifiedFetch } from '@helia/verified-fetch'
34
34
  * import { CID } from 'multiformats/cid'
35
35
  *
36
- * const cid = CID.parse('bafyFoo') // some image file
36
+ * const cid = CID.parse('bafyFoo') // some json file
37
37
  * const response = await verifiedFetch(cid)
38
38
  * const json = await response.json()
39
39
  * ```
@@ -114,7 +114,7 @@
114
114
  *
115
115
  * ### Custom content-type parsing
116
116
  *
117
- * By default, `@helia/verified-fetch` sets the `Content-Type` header as `application/octet-stream` - this is because the `.json()`, `.text()`, `.blob()`, and `.arrayBuffer()` methods will usually work as expected without a detailed content type.
117
+ * By default, if the response can be parsed as JSON, `@helia/verified-fetch` sets the `Content-Type` header as `application/json`, otherwise it sets it as `application/octet-stream` - this is because the `.json()`, `.text()`, `.blob()`, and `.arrayBuffer()` methods will usually work as expected without a detailed content type.
118
118
  *
119
119
  * If you require an accurate content-type you can provide a `contentTypeParser` function as an option to `createVerifiedFetch` to handle parsing the content type.
120
120
  *
@@ -138,6 +138,188 @@
138
138
  * })
139
139
  * ```
140
140
  *
141
+ * ### IPLD codec handling
142
+ *
143
+ * IPFS supports several data formats (typically referred to as codecs) which are included in the CID. `@helia/verified-fetch` attempts to abstract away some of the details for easier consumption.
144
+ *
145
+ * #### DAG-PB
146
+ *
147
+ * [DAG-PB](https://ipld.io/docs/codecs/known/dag-pb/) is the codec we are most likely to encounter, it is what [UnixFS](https://github.com/ipfs/specs/blob/main/UNIXFS.md) uses under the hood.
148
+ *
149
+ * ##### Using the DAG-PB codec as a Blob
150
+ *
151
+ * ```typescript
152
+ * import { verifiedFetch } from '@helia/verified-fetch'
153
+ *
154
+ * const res = await verifiedFetch('ipfs://Qmfoo')
155
+ * const blob = await res.blob()
156
+ *
157
+ * console.info(blob) // Blob { size: x, type: 'application/octet-stream' }
158
+ * ```
159
+ *
160
+ * ##### Using the DAG-PB codec as an ArrayBuffer
161
+ *
162
+ * ```typescript
163
+ * import { verifiedFetch } from '@helia/verified-fetch'
164
+ *
165
+ * const res = await verifiedFetch('ipfs://Qmfoo')
166
+ * const buf = await res.arrayBuffer()
167
+ *
168
+ * console.info(buf) // ArrayBuffer { [Uint8Contents]: < ... >, byteLength: x }
169
+ * ```
170
+ *
171
+ * ##### Using the DAG-PB codec as a stream
172
+ *
173
+ * ```typescript
174
+ * import { verifiedFetch } from '@helia/verified-fetch'
175
+ *
176
+ * const res = await verifiedFetch('ipfs://Qmfoo')
177
+ * const reader = res.body?.getReader()
178
+ *
179
+ * while (true) {
180
+ * const next = await reader.read()
181
+ *
182
+ * if (next?.done === true) {
183
+ * break
184
+ * }
185
+ *
186
+ * if (next?.value != null) {
187
+ * console.info(next.value) // Uint8Array(x) [ ... ]
188
+ * }
189
+ * }
190
+ * ```
191
+ *
192
+ * ##### Content-Type
193
+ *
194
+ * When fetching `DAG-PB` data, the content type will be set to `application/octet-stream` unless a custom content-type parser is configured.
195
+ *
196
+ * #### JSON
197
+ *
198
+ * The JSON codec is a very simple codec, a block parseable with this codec is a JSON string encoded into a `Uint8Array`.
199
+ *
200
+ * ##### Using the JSON codec
201
+ *
202
+ * ```typescript
203
+ * import * as json from 'multiformats/codecs/json'
204
+ *
205
+ * const block = new TextEncoder().encode('{ "hello": "world" }')
206
+ * const obj = json.decode(block)
207
+ *
208
+ * console.info(obj) // { hello: 'world' }
209
+ * ```
210
+ *
211
+ * ##### Content-Type
212
+ *
213
+ * When the `JSON` codec is encountered, the `Content-Type` header of the response will be set to `application/json`.
214
+ *
215
+ * ### DAG-JSON
216
+ *
217
+ * [DAG-JSON](https://ipld.io/docs/codecs/known/dag-json/) expands on the `JSON` codec, adding the ability to contain [CID](https://docs.ipfs.tech/concepts/content-addressing/)s which act as links to other blocks, and byte arrays.
218
+ *
219
+ * `CID`s and byte arrays are represented using special object structures with a single `"/"` property.
220
+ *
221
+ * Using `DAG-JSON` has two important caveats:
222
+ *
223
+ * 1. Your `JSON` structure cannot contain an object with only a `"/"` property, as it will be interpreted as a special type.
224
+ * 2. Since `JSON` has no technical limit on number sizes, `DAG-JSON` also allows numbers larger than `Number.MAX_SAFE_INTEGER`. JavaScript requires use of `BigInt`s to represent numbers larger than this, and `JSON.parse` does not support them, so precision will be lost.
225
+ *
226
+ * Otherwise this codec follows the same rules as the `JSON` codec.
227
+ *
228
+ * ##### Using the DAG-JSON codec
229
+ *
230
+ * ```typescript
231
+ * import * as dagJson from '@ipld/dag-json'
232
+ *
233
+ * const block = new TextEncoder().encode(`{
234
+ * "hello": "world",
235
+ * "cid": {
236
+ * "/": "baeaaac3imvwgy3zao5xxe3de"
237
+ * },
238
+ * "buf": {
239
+ * "/": {
240
+ * "bytes": "AAECAwQ"
241
+ * }
242
+ * }
243
+ * }`)
244
+ *
245
+ * const obj = dagJson.decode(block)
246
+ *
247
+ * console.info(obj)
248
+ * // {
249
+ * // hello: 'world',
250
+ * // cid: CID(baeaaac3imvwgy3zao5xxe3de),
251
+ * // buf: Uint8Array(5) [ 0, 1, 2, 3, 4 ]
252
+ * // }
253
+ * ```
254
+ *
255
+ * ##### Content-Type
256
+ *
257
+ * When the `DAG-JSON` codec is encountered in the requested CID, the `Content-Type` header of the response will be set to `application/json`.
258
+ *
259
+ * `DAG-JSON` data can be parsed from the response by using the `.json()` function, which will return `CID`s/byte arrays as plain `{ "/": ... }` objects:
260
+ *
261
+ * ```typescript
262
+ * import { verifiedFetch } from '@helia/verified-fetch'
263
+ * import * as dagJson from '@ipld/dag-json'
264
+ *
265
+ * const res = await verifiedFetch('ipfs://bafyDAGJSON')
266
+ *
267
+ * // either:
268
+ * const obj = await res.json()
269
+ * console.info(obj.cid) // { "/": "baeaaac3imvwgy3zao5xxe3de" }
270
+ * console.info(obj.buf) // { "/": { "bytes": "AAECAwQ" } }
271
+ * ```
272
+ *
273
+ * Alternatively, it can be decoded using the `@ipld/dag-json` module and the `.arrayBuffer()` method, in which case you will get `CID` objects and `Uint8Array`s:
274
+ *
275
+ *```typescript
276
+ * import { verifiedFetch } from '@helia/verified-fetch'
277
+ * import * as dagJson from '@ipld/dag-json'
278
+ *
279
+ * const res = await verifiedFetch('ipfs://bafyDAGJSON')
280
+ *
281
+ * // or:
282
+ * const obj = dagJson.decode(await res.arrayBuffer())
283
+ * console.info(obj.cid) // CID(baeaaac3imvwgy3zao5xxe3de)
284
+ * console.info(obj.buf) // Uint8Array(5) [ 0, 1, 2, 3, 4 ]
285
+ * ```
286
+ *
287
+ * #### DAG-CBOR
288
+ *
289
+ * [DAG-CBOR](https://ipld.io/docs/codecs/known/dag-cbor/) uses the [Concise Binary Object Representation](https://cbor.io/) format for serialization instead of JSON.
290
+ *
291
+ * This supports more datatypes in a safer way than JSON and is smaller on the wire to boot so is usually preferable to JSON or DAG-JSON.
292
+ *
293
+ * ##### Content-Type
294
+ *
295
+ * Not all data types supported by `DAG-CBOR` can be successfully turned into JSON and back into the same binary form.
296
+ *
297
+ * When a decoded block can be round-tripped to JSON, the `Content-Type` will be set to `application/json`. In this case the `.json()` method on the `Response` object can be used to obtain an object representation of the response.
298
+ *
299
+ * When it cannot, the `Content-Type` will be `application/octet-stream` - in this case the `@ipld/dag-json` module must be used to deserialize the return value from `.arrayBuffer()`.
300
+ *
301
+ * ##### Detecting JSON-safe DAG-CBOR
302
+ *
303
+ * If the `Content-Type` header of the response is `application/json`, the `.json()` method may be used to access the response body in object form, otherwise the `.arrayBuffer()` method must be used to decode the raw bytes using the `@ipld/dag-cbor` module.
304
+ *
305
+ * ```typescript
306
+ * import { verifiedFetch } from '@helia/verified-fetch'
307
+ * import * as dagCbor from '@ipld/dag-cbor'
308
+ *
309
+ * const res = await verifiedFetch('ipfs://bafyDagCborCID')
310
+ * let obj
311
+ *
312
+ * if (res.headers.get('Content-Type') === 'application/json') {
313
+ * // DAG-CBOR data can be safely decoded as JSON
314
+ * obj = await res.json()
315
+ * } else {
316
+ * // response contains non-JSON friendly data types
317
+ * obj = dagCbor.decode(await res.arrayBuffer())
318
+ * }
319
+ *
320
+ * console.info(obj) // ...
321
+ * ```
322
+ *
141
323
  * ## Comparison to fetch
142
324
  *
143
325
  * This module attempts to act as similarly to the `fetch()` API as possible.
@@ -155,7 +337,7 @@
155
337
  * 2. IPNS protocol: `ipns://<peerId>` & `ipns://<publicKey>` & `ipns://<hostUri_Supporting_DnsLink_TxtRecords>`
156
338
  * 3. CID instances: An actual CID instance `CID.parse('bafy...')`
157
339
  *
158
- * As well as support for pathing & params for item 1 & 2 above according to [IPFS - Path Gateway Specification](https://specs.ipfs.tech/http-gateways/path-gateway) & [IPFS - Trustless Gateway Specification](https://specs.ipfs.tech/http-gateways/trustless-gateway/). Further refinement of those specifications specifically for web-based scenarios can be found in the [Web Pathing Specification IPIP](https://github.com/ipfs/specs/pull/453).
340
+ * As well as support for pathing & params for items 1 & 2 above according to [IPFS - Path Gateway Specification](https://specs.ipfs.tech/http-gateways/path-gateway) & [IPFS - Trustless Gateway Specification](https://specs.ipfs.tech/http-gateways/trustless-gateway/). Further refinement of those specifications specifically for web-based scenarios can be found in the [Web Pathing Specification IPIP](https://github.com/ipfs/specs/pull/453).
159
341
  *
160
342
  * If you pass a CID instance, it assumes you want the content for that specific CID only, and does not support pathing or params for that CID.
161
343
  *
package/src/types.ts ADDED
@@ -0,0 +1 @@
1
+ export type RequestFormatShorthand = 'raw' | 'car' | 'tar' | 'ipns-record' | 'dag-json' | 'dag-cbor' | 'json' | 'cbor'
@@ -0,0 +1,44 @@
1
+ import { decode } from 'cborg'
2
+ import { encode } from 'cborg/json'
3
+ import { CID } from 'multiformats/cid'
4
+ import type { TagDecoder } from 'cborg'
5
+
6
+ // https://github.com/ipfs/go-ipfs/issues/3570#issuecomment-273931692
7
+ const CID_CBOR_TAG = 0x2A
8
+
9
+ function cidDecoder (bytes: Uint8Array): CID {
10
+ if (bytes[0] !== 0) {
11
+ throw new Error('Invalid CID for CBOR tag 42; expected leading 0x00')
12
+ }
13
+
14
+ return CID.decode(bytes.subarray(1)) // ignore leading 0x00
15
+ }
16
+
17
+ /**
18
+ * Take a `DAG-CBOR` encoded `Uint8Array`, deserialize it as an object and
19
+ * re-serialize it in a form that can be passed to `JSON.serialize` and then
20
+ * `JSON.parse` without losing any data.
21
+ */
22
+ export function dagCborToSafeJSON (buf: Uint8Array): string {
23
+ const tags: TagDecoder[] = []
24
+ tags[CID_CBOR_TAG] = cidDecoder
25
+
26
+ const obj = decode(buf, {
27
+ allowIndefinite: false,
28
+ coerceUndefinedToNull: true,
29
+ allowNaN: false,
30
+ allowInfinity: false,
31
+ strict: true,
32
+ useMaps: false,
33
+ rejectDuplicateMapKeys: true,
34
+ tags,
35
+
36
+ // this is different to `DAG-CBOR` - the reason we disallow BigInts is
37
+ // because we are about to re-encode to `JSON` which does not support
38
+ // BigInts. Blocks containing large numbers should be deserialized using a
39
+ // cbor decoder instead
40
+ allowBigInt: false
41
+ })
42
+
43
+ return new TextDecoder().decode(encode(obj))
44
+ }