@helia/verified-fetch 0.0.0-3851fe2

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 (49) hide show
  1. package/LICENSE +4 -0
  2. package/README.md +275 -0
  3. package/dist/index.min.js +140 -0
  4. package/dist/src/index.d.ts +271 -0
  5. package/dist/src/index.d.ts.map +1 -0
  6. package/dist/src/index.js +263 -0
  7. package/dist/src/index.js.map +1 -0
  8. package/dist/src/singleton.d.ts +3 -0
  9. package/dist/src/singleton.d.ts.map +1 -0
  10. package/dist/src/singleton.js +15 -0
  11. package/dist/src/singleton.js.map +1 -0
  12. package/dist/src/utils/get-content-type.d.ts +11 -0
  13. package/dist/src/utils/get-content-type.d.ts.map +1 -0
  14. package/dist/src/utils/get-content-type.js +43 -0
  15. package/dist/src/utils/get-content-type.js.map +1 -0
  16. package/dist/src/utils/get-stream-and-content-type.d.ts +10 -0
  17. package/dist/src/utils/get-stream-and-content-type.d.ts.map +1 -0
  18. package/dist/src/utils/get-stream-and-content-type.js +37 -0
  19. package/dist/src/utils/get-stream-and-content-type.js.map +1 -0
  20. package/dist/src/utils/parse-resource.d.ts +18 -0
  21. package/dist/src/utils/parse-resource.d.ts.map +1 -0
  22. package/dist/src/utils/parse-resource.js +24 -0
  23. package/dist/src/utils/parse-resource.js.map +1 -0
  24. package/dist/src/utils/parse-url-string.d.ts +26 -0
  25. package/dist/src/utils/parse-url-string.d.ts.map +1 -0
  26. package/dist/src/utils/parse-url-string.js +109 -0
  27. package/dist/src/utils/parse-url-string.js.map +1 -0
  28. package/dist/src/utils/tlru.d.ts +15 -0
  29. package/dist/src/utils/tlru.d.ts.map +1 -0
  30. package/dist/src/utils/tlru.js +40 -0
  31. package/dist/src/utils/tlru.js.map +1 -0
  32. package/dist/src/utils/walk-path.d.ts +13 -0
  33. package/dist/src/utils/walk-path.d.ts.map +1 -0
  34. package/dist/src/utils/walk-path.js +17 -0
  35. package/dist/src/utils/walk-path.js.map +1 -0
  36. package/dist/src/verified-fetch.d.ts +64 -0
  37. package/dist/src/verified-fetch.d.ts.map +1 -0
  38. package/dist/src/verified-fetch.js +261 -0
  39. package/dist/src/verified-fetch.js.map +1 -0
  40. package/package.json +175 -0
  41. package/src/index.ts +323 -0
  42. package/src/singleton.ts +20 -0
  43. package/src/utils/get-content-type.ts +55 -0
  44. package/src/utils/get-stream-and-content-type.ts +44 -0
  45. package/src/utils/parse-resource.ts +40 -0
  46. package/src/utils/parse-url-string.ts +139 -0
  47. package/src/utils/tlru.ts +52 -0
  48. package/src/utils/walk-path.ts +34 -0
  49. package/src/verified-fetch.ts +323 -0
@@ -0,0 +1,261 @@
1
+ import { dagCbor as heliaDagCbor } from '@helia/dag-cbor';
2
+ import { dagJson as heliaDagJson } from '@helia/dag-json';
3
+ import { ipns as heliaIpns } from '@helia/ipns';
4
+ import { dnsJsonOverHttps } from '@helia/ipns/dns-resolvers';
5
+ import { json as heliaJson } from '@helia/json';
6
+ 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';
9
+ import { code as dagPbCode } from '@ipld/dag-pb';
10
+ import { code as jsonCode } from 'multiformats/codecs/json';
11
+ import { decode, code as rawCode } from 'multiformats/codecs/raw';
12
+ import { CustomProgressEvent } from 'progress-events';
13
+ import { getStreamAndContentType } from './utils/get-stream-and-content-type.js';
14
+ import { parseResource } from './utils/parse-resource.js';
15
+ import { walkPath } from './utils/walk-path.js';
16
+ function convertOptions(options) {
17
+ if (options == null) {
18
+ return undefined;
19
+ }
20
+ let signal;
21
+ if (options?.signal === null) {
22
+ signal = undefined;
23
+ }
24
+ return {
25
+ ...options,
26
+ signal
27
+ };
28
+ }
29
+ export class VerifiedFetch {
30
+ helia;
31
+ ipns;
32
+ unixfs;
33
+ dagJson;
34
+ dagCbor;
35
+ json;
36
+ pathWalker;
37
+ log;
38
+ constructor({ helia, ipns, unixfs, dagJson, json, dagCbor, pathWalker }, init) {
39
+ this.helia = helia;
40
+ this.log = helia.logger.forComponent('helia:verified-fetch');
41
+ this.ipns = ipns ?? heliaIpns(helia, {
42
+ resolvers: [
43
+ dnsJsonOverHttps('https://mozilla.cloudflare-dns.com/dns-query'),
44
+ dnsJsonOverHttps('https://dns.google/resolve')
45
+ ]
46
+ });
47
+ 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
+ this.log.trace('created VerifiedFetch instance');
53
+ }
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
58
+ return response;
59
+ }
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
64
+ return response;
65
+ }
66
+ async handleDagJson({ cid, path, options }) {
67
+ this.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');
76
+ return response;
77
+ }
78
+ async handleJson({ cid, path, options }) {
79
+ this.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');
88
+ return response;
89
+ }
90
+ async handleDagCbor({ cid, path, options }) {
91
+ this.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');
100
+ return response;
101
+ }
102
+ async handleDagPb({ cid, path, options, terminalElement }) {
103
+ this.log.trace('fetching %c/%s', cid, path);
104
+ let resolvedCID = terminalElement?.cid ?? cid;
105
+ let stat;
106
+ if (terminalElement?.type === 'directory') {
107
+ const dirCid = terminalElement.cid;
108
+ const rootFilePath = 'index.html';
109
+ try {
110
+ this.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 }));
112
+ stat = await this.unixfs.stat(dirCid, {
113
+ path: rootFilePath,
114
+ signal: options?.signal,
115
+ onProgress: options?.onProgress
116
+ });
117
+ this.log.trace('found root file at %c/%s with cid %c', dirCid, rootFilePath, stat.cid);
118
+ path = rootFilePath;
119
+ resolvedCID = stat.cid;
120
+ // terminalElement = stat
121
+ }
122
+ catch (err) {
123
+ this.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 });
125
+ }
126
+ finally {
127
+ options?.onProgress?.(new CustomProgressEvent('verified-fetch:request:end', { cid: dirCid.toString(), path: rootFilePath }));
128
+ }
129
+ }
130
+ options?.onProgress?.(new CustomProgressEvent('verified-fetch:request:start', { cid: resolvedCID.toString(), path: '' }));
131
+ const asyncIter = this.unixfs.cat(resolvedCID, {
132
+ signal: options?.signal,
133
+ onProgress: options?.onProgress
134
+ });
135
+ options?.onProgress?.(new CustomProgressEvent('verified-fetch:request:end', { cid: resolvedCID.toString(), path: '' }));
136
+ this.log('got async iterator for %c/%s', cid, path);
137
+ const { contentType, stream } = await getStreamAndContentType(asyncIter, path ?? '', this.helia.logger, {
138
+ onProgress: options?.onProgress
139
+ });
140
+ const response = new Response(stream, { status: 200 });
141
+ response.headers.set('content-type', contentType);
142
+ return response;
143
+ }
144
+ async handleRaw({ cid, path, options }) {
145
+ this.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');
151
+ return response;
152
+ }
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];
174
+ }
175
+ }
176
+ }
177
+ else if (queryFormat != null) {
178
+ return queryFormat;
179
+ }
180
+ return null;
181
+ }
182
+ /**
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
185
+ */
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
+ codecHandlers = {
197
+ [dagJsonCode]: this.handleDagJson,
198
+ [dagPbCode]: this.handleDagPb,
199
+ [jsonCode]: this.handleJson,
200
+ [dagCborCode]: this.handleDagCbor,
201
+ [rawCode]: this.handleRaw
202
+ };
203
+ async fetch(resource, opts) {
204
+ const options = convertOptions(opts);
205
+ const { path, query, ...rest } = await parseResource(resource, { ipns: this.ipns, logger: this.helia.logger }, options);
206
+ const cid = rest.cid;
207
+ 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
+ }
218
+ }
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;
224
+ terminalElement = pathDetails.terminalElement;
225
+ }
226
+ catch (err) {
227
+ this.log.error('Error walking path %s', path, err);
228
+ // return new Response(`Error walking path: ${(err as Error).message}`, { status: 500 })
229
+ }
230
+ if (response == null) {
231
+ const codecHandler = this.codecHandlers[cid.code];
232
+ if (codecHandler != null) {
233
+ response = await codecHandler.call(this, { cid, path, options, terminalElement });
234
+ }
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 });
237
+ }
238
+ }
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.map(cid => cid.toV1().toString()).join(',')); // https://specs.ipfs.tech/http-gateways/path-gateway/#x-ipfs-roots-response-header
244
+ }
245
+ // response.headers.set('Content-Disposition', `TODO`) // https://specs.ipfs.tech/http-gateways/path-gateway/#content-disposition-response-header
246
+ return response;
247
+ }
248
+ /**
249
+ * Start the Helia instance
250
+ */
251
+ async start() {
252
+ await this.helia.start();
253
+ }
254
+ /**
255
+ * Shut down the Helia instance
256
+ */
257
+ async stop() {
258
+ await this.helia.stop();
259
+ }
260
+ }
261
+ //# sourceMappingURL=verified-fetch.js.map
@@ -0,0 +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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,cAAc,EAAE,qCAAqC,CAAC,CAAA;QAC3E,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"}
package/package.json ADDED
@@ -0,0 +1,175 @@
1
+ {
2
+ "name": "@helia/verified-fetch",
3
+ "version": "0.0.0-3851fe2",
4
+ "description": "A fetch-like API for obtaining verified & trustless IPFS content on the web.",
5
+ "license": "Apache-2.0 OR MIT",
6
+ "homepage": "https://github.com/ipfs/helia/tree/main/packages/verified-fetch#readme",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/ipfs/helia.git"
10
+ },
11
+ "bugs": {
12
+ "url": "https://github.com/ipfs/helia/issues"
13
+ },
14
+ "publishConfig": {
15
+ "access": "public",
16
+ "provenance": true
17
+ },
18
+ "keywords": [
19
+ "IPFS",
20
+ "fetch",
21
+ "helia"
22
+ ],
23
+ "type": "module",
24
+ "types": "./dist/src/index.d.ts",
25
+ "files": [
26
+ "src",
27
+ "dist",
28
+ "!dist/test",
29
+ "!**/*.tsbuildinfo"
30
+ ],
31
+ "exports": {
32
+ ".": {
33
+ "types": "./dist/src/index.d.ts",
34
+ "import": "./dist/src/index.js"
35
+ }
36
+ },
37
+ "eslintConfig": {
38
+ "extends": "ipfs",
39
+ "parserOptions": {
40
+ "project": true,
41
+ "sourceType": "module"
42
+ }
43
+ },
44
+ "release": {
45
+ "branches": [
46
+ "main"
47
+ ],
48
+ "plugins": [
49
+ [
50
+ "@semantic-release/commit-analyzer",
51
+ {
52
+ "preset": "conventionalcommits",
53
+ "releaseRules": [
54
+ {
55
+ "breaking": true,
56
+ "release": "major"
57
+ },
58
+ {
59
+ "revert": true,
60
+ "release": "patch"
61
+ },
62
+ {
63
+ "type": "feat",
64
+ "release": "minor"
65
+ },
66
+ {
67
+ "type": "fix",
68
+ "release": "patch"
69
+ },
70
+ {
71
+ "type": "docs",
72
+ "release": "patch"
73
+ },
74
+ {
75
+ "type": "test",
76
+ "release": "patch"
77
+ },
78
+ {
79
+ "type": "deps",
80
+ "release": "patch"
81
+ },
82
+ {
83
+ "scope": "no-release",
84
+ "release": false
85
+ }
86
+ ]
87
+ }
88
+ ],
89
+ [
90
+ "@semantic-release/release-notes-generator",
91
+ {
92
+ "preset": "conventionalcommits",
93
+ "presetConfig": {
94
+ "types": [
95
+ {
96
+ "type": "feat",
97
+ "section": "Features"
98
+ },
99
+ {
100
+ "type": "fix",
101
+ "section": "Bug Fixes"
102
+ },
103
+ {
104
+ "type": "chore",
105
+ "section": "Trivial Changes"
106
+ },
107
+ {
108
+ "type": "docs",
109
+ "section": "Documentation"
110
+ },
111
+ {
112
+ "type": "deps",
113
+ "section": "Dependencies"
114
+ },
115
+ {
116
+ "type": "test",
117
+ "section": "Tests"
118
+ }
119
+ ]
120
+ }
121
+ }
122
+ ],
123
+ "@semantic-release/changelog",
124
+ "@semantic-release/npm",
125
+ "@semantic-release/github",
126
+ "@semantic-release/git"
127
+ ]
128
+ },
129
+ "scripts": {
130
+ "clean": "aegir clean",
131
+ "lint": "aegir lint",
132
+ "dep-check": "aegir dep-check",
133
+ "build": "aegir build",
134
+ "test": "aegir test",
135
+ "test:chrome": "aegir test -t browser --cov",
136
+ "test:chrome-webworker": "aegir test -t webworker",
137
+ "test:firefox": "aegir test -t browser -- --browser firefox",
138
+ "test:firefox-webworker": "aegir test -t webworker -- --browser firefox",
139
+ "test:node": "aegir test -t node --cov",
140
+ "test:electron-main": "aegir test -t electron-main",
141
+ "release": "aegir release"
142
+ },
143
+ "dependencies": {
144
+ "@helia/block-brokers": "2.0.1-3851fe2",
145
+ "@helia/dag-cbor": "3.0.0-3851fe2",
146
+ "@helia/dag-json": "3.0.0-3851fe2",
147
+ "@helia/http": "1.0.1-3851fe2",
148
+ "@helia/interface": "4.0.0-3851fe2",
149
+ "@helia/ipns": "6.0.0-3851fe2",
150
+ "@helia/json": "3.0.0-3851fe2",
151
+ "@helia/routers": "1.0.0-3851fe2",
152
+ "@helia/unixfs": "3.0.0-3851fe2",
153
+ "@ipld/dag-cbor": "^9.1.0",
154
+ "@ipld/dag-json": "^10.1.7",
155
+ "@ipld/dag-pb": "^4.0.8",
156
+ "@libp2p/interface": "^1.1.2",
157
+ "@libp2p/peer-id": "^4.0.5",
158
+ "hashlru": "^2.3.0",
159
+ "ipfs-unixfs-exporter": "^13.5.0",
160
+ "mime-types": "^2.1.35",
161
+ "multiformats": "^13.0.1",
162
+ "progress-events": "^1.0.0"
163
+ },
164
+ "devDependencies": {
165
+ "@libp2p/logger": "^4.0.5",
166
+ "@libp2p/peer-id-factory": "^4.0.5",
167
+ "@types/mime-types": "^2.1.4",
168
+ "@types/sinon": "^17.0.3",
169
+ "aegir": "^42.2.2",
170
+ "helia": "4.0.1-3851fe2",
171
+ "sinon": "^17.0.1",
172
+ "sinon-ts": "^2.0.0"
173
+ },
174
+ "sideEffects": false
175
+ }