@helia/verified-fetch 0.0.0-a04e041 → 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.
- package/README.md +0 -33
- package/dist/index.min.js +4 -4
- package/dist/src/index.d.ts +0 -36
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +0 -33
- package/dist/src/index.js.map +1 -1
- package/dist/src/utils/parse-url-string.d.ts +0 -2
- package/dist/src/utils/parse-url-string.d.ts.map +1 -1
- package/dist/src/utils/parse-url-string.js +0 -6
- package/dist/src/utils/parse-url-string.js.map +1 -1
- package/dist/src/verified-fetch.d.ts +15 -17
- package/dist/src/verified-fetch.d.ts.map +1 -1
- package/dist/src/verified-fetch.js +129 -211
- package/dist/src/verified-fetch.js.map +1 -1
- package/package.json +12 -18
- package/src/index.ts +0 -37
- package/src/utils/parse-url-string.ts +1 -11
- package/src/verified-fetch.ts +134 -237
- package/dist/src/utils/get-content-disposition-filename.d.ts +0 -6
- package/dist/src/utils/get-content-disposition-filename.d.ts.map +0 -1
- package/dist/src/utils/get-content-disposition-filename.js +0 -16
- package/dist/src/utils/get-content-disposition-filename.js.map +0 -1
- package/dist/src/utils/responses.d.ts +0 -4
- package/dist/src/utils/responses.d.ts.map +0 -1
- package/dist/src/utils/responses.js +0 -21
- package/dist/src/utils/responses.js.map +0 -1
- package/dist/src/utils/select-output-type.d.ts +0 -12
- package/dist/src/utils/select-output-type.d.ts.map +0 -1
- package/dist/src/utils/select-output-type.js +0 -147
- package/dist/src/utils/select-output-type.js.map +0 -1
- package/src/utils/get-content-disposition-filename.ts +0 -18
- package/src/utils/responses.ts +0 -22
- package/src/utils/select-output-type.ts +0 -166
|
@@ -1,22 +1,17 @@
|
|
|
1
|
-
import { car } from '@helia/car';
|
|
2
1
|
import { ipns as heliaIpns } from '@helia/ipns';
|
|
3
2
|
import { dnsJsonOverHttps } from '@helia/ipns/dns-resolvers';
|
|
4
3
|
import { unixfs as heliaUnixFs } from '@helia/unixfs';
|
|
5
|
-
import
|
|
6
|
-
import
|
|
4
|
+
import { code as dagCborCode } from '@ipld/dag-cbor';
|
|
5
|
+
import { code as dagJsonCode } from '@ipld/dag-json';
|
|
7
6
|
import { code as dagPbCode } from '@ipld/dag-pb';
|
|
8
|
-
import toBrowserReadableStream from 'it-to-browser-readablestream';
|
|
9
7
|
import { code as jsonCode } from 'multiformats/codecs/json';
|
|
10
8
|
import { code as rawCode } from 'multiformats/codecs/raw';
|
|
11
9
|
import { identity } from 'multiformats/hashes/identity';
|
|
12
10
|
import { CustomProgressEvent } from 'progress-events';
|
|
13
11
|
import { dagCborToSafeJSON } from './utils/dag-cbor-to-safe-json.js';
|
|
14
|
-
import { getContentDispositionFilename } from './utils/get-content-disposition-filename.js';
|
|
15
12
|
import { getETag } from './utils/get-e-tag.js';
|
|
16
13
|
import { getStreamFromAsyncIterable } from './utils/get-stream-from-async-iterable.js';
|
|
17
14
|
import { parseResource } from './utils/parse-resource.js';
|
|
18
|
-
import { notAcceptableResponse, notSupportedResponse, okResponse } from './utils/responses.js';
|
|
19
|
-
import { selectOutputType, queryFormatToAcceptHeader } from './utils/select-output-type.js';
|
|
20
15
|
import { walkPath } from './utils/walk-path.js';
|
|
21
16
|
function convertOptions(options) {
|
|
22
17
|
if (options == null) {
|
|
@@ -31,42 +26,26 @@ function convertOptions(options) {
|
|
|
31
26
|
signal
|
|
32
27
|
};
|
|
33
28
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
* type. This avoids the user from receiving something different when they
|
|
46
|
-
* signal that they want to `Accept` a specific mime type.
|
|
47
|
-
*/
|
|
48
|
-
function getOverridenRawContentType(headers) {
|
|
49
|
-
const acceptHeader = new Headers(headers).get('accept') ?? '';
|
|
50
|
-
// e.g. "Accept: text/html, application/xhtml+xml, application/xml;q=0.9, image/webp, */*;q=0.8"
|
|
51
|
-
const acceptHeaders = acceptHeader.split(',')
|
|
52
|
-
.map(s => s.split(';')[0])
|
|
53
|
-
.map(s => s.trim());
|
|
54
|
-
for (const mimeType of acceptHeaders) {
|
|
55
|
-
if (mimeType === '*/*') {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
if (RAW_HEADERS.includes(mimeType ?? '')) {
|
|
59
|
-
return mimeType;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
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
|
+
});
|
|
62
40
|
}
|
|
63
41
|
export class VerifiedFetch {
|
|
64
42
|
helia;
|
|
65
43
|
ipns;
|
|
66
44
|
unixfs;
|
|
45
|
+
pathWalker;
|
|
67
46
|
log;
|
|
68
47
|
contentTypeParser;
|
|
69
|
-
constructor({ helia, ipns, unixfs }, init) {
|
|
48
|
+
constructor({ helia, ipns, unixfs, pathWalker }, init) {
|
|
70
49
|
this.helia = helia;
|
|
71
50
|
this.log = helia.logger.forComponent('helia:verified-fetch');
|
|
72
51
|
this.ipns = ipns ?? heliaIpns(helia, {
|
|
@@ -76,114 +55,54 @@ export class VerifiedFetch {
|
|
|
76
55
|
]
|
|
77
56
|
});
|
|
78
57
|
this.unixfs = unixfs ?? heliaUnixFs(helia);
|
|
58
|
+
this.pathWalker = pathWalker ?? walkPath;
|
|
79
59
|
this.contentTypeParser = init?.contentTypeParser;
|
|
80
60
|
this.log.trace('created VerifiedFetch instance');
|
|
81
61
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
async handleIPNSRecord(resource, opts) {
|
|
87
|
-
return notSupportedResponse('vnd.ipfs.ipns-record support is not implemented');
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Accepts a `CID` and returns a `Response` with a body stream that is a CAR
|
|
91
|
-
* of the `DAG` referenced by the `CID`.
|
|
92
|
-
*/
|
|
93
|
-
async handleCar({ cid, options }) {
|
|
94
|
-
const c = car(this.helia);
|
|
95
|
-
const stream = toBrowserReadableStream(c.stream(cid, options));
|
|
96
|
-
const response = okResponse(stream);
|
|
97
|
-
response.headers.set('content-type', 'application/vnd.ipld.car; version=1');
|
|
62
|
+
// handle vnd.ipfs.ipns-record
|
|
63
|
+
async handleIPNSRecord({ cid, path, options }) {
|
|
64
|
+
const response = notSupportedResponse('vnd.ipfs.ipns-record support is not implemented');
|
|
65
|
+
response.headers.set('X-Content-Type-Options', 'nosniff'); // see https://specs.ipfs.tech/http-gateways/path-gateway/#x-content-type-options-response-header
|
|
98
66
|
return response;
|
|
99
67
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
if (cid.code !== dagPbCode) {
|
|
106
|
-
return notAcceptableResponse('only dag-pb CIDs can be returned in TAR files');
|
|
107
|
-
}
|
|
108
|
-
return notSupportedResponse('application/tar support is not implemented');
|
|
68
|
+
// handle vnd.ipld.car
|
|
69
|
+
async handleIPLDCar({ cid, path, options }) {
|
|
70
|
+
const response = notSupportedResponse('vnd.ipld.car support is not implemented');
|
|
71
|
+
response.headers.set('X-Content-Type-Options', 'nosniff'); // see https://specs.ipfs.tech/http-gateways/path-gateway/#x-content-type-options-response-header
|
|
72
|
+
return response;
|
|
109
73
|
}
|
|
110
|
-
async handleJson({ cid, path,
|
|
74
|
+
async handleJson({ cid, path, options }) {
|
|
111
75
|
this.log.trace('fetching %c/%s', cid, path);
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
body = ipldDagCbor.encode(obj);
|
|
121
|
-
}
|
|
122
|
-
catch (err) {
|
|
123
|
-
this.log.error('could not transform %c to application/vnd.ipld.dag-cbor', err);
|
|
124
|
-
return notAcceptableResponse();
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
else {
|
|
128
|
-
// skip decoding
|
|
129
|
-
body = block;
|
|
130
|
-
}
|
|
131
|
-
const response = okResponse(body);
|
|
132
|
-
response.headers.set('content-type', accept ?? 'application/json');
|
|
76
|
+
options?.onProgress?.(new CustomProgressEvent('verified-fetch:request:start', { cid, path }));
|
|
77
|
+
const result = await this.helia.blockstore.get(cid, {
|
|
78
|
+
signal: options?.signal,
|
|
79
|
+
onProgress: options?.onProgress
|
|
80
|
+
});
|
|
81
|
+
const response = okResponse(result);
|
|
82
|
+
response.headers.set('content-type', 'application/json');
|
|
83
|
+
options?.onProgress?.(new CustomProgressEvent('verified-fetch:request:end', { cid, path }));
|
|
133
84
|
return response;
|
|
134
85
|
}
|
|
135
|
-
async handleDagCbor({ cid, path,
|
|
86
|
+
async handleDagCbor({ cid, path, options }) {
|
|
136
87
|
this.log.trace('fetching %c/%s', cid, path);
|
|
137
|
-
|
|
88
|
+
options?.onProgress?.(new CustomProgressEvent('verified-fetch:request:start', { cid, path }));
|
|
89
|
+
// return body as binary
|
|
90
|
+
const block = await this.helia.blockstore.get(cid);
|
|
138
91
|
let body;
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
body = block;
|
|
142
|
-
}
|
|
143
|
-
else if (accept === 'application/vnd.ipld.dag-json') {
|
|
144
|
-
try {
|
|
145
|
-
// if vnd.ipld.dag-json has been specified, convert to the format - note
|
|
146
|
-
// that this supports more data types than regular JSON, the content-type
|
|
147
|
-
// response header is set so the user knows to process it differently
|
|
148
|
-
const obj = ipldDagCbor.decode(block);
|
|
149
|
-
body = ipldDagJson.encode(obj);
|
|
150
|
-
}
|
|
151
|
-
catch (err) {
|
|
152
|
-
this.log.error('could not transform %c to application/vnd.ipld.dag-json', err);
|
|
153
|
-
return notAcceptableResponse();
|
|
154
|
-
}
|
|
92
|
+
try {
|
|
93
|
+
body = dagCborToSafeJSON(block);
|
|
155
94
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
}
|
|
160
|
-
catch (err) {
|
|
161
|
-
if (accept === 'application/json') {
|
|
162
|
-
this.log('could not decode DAG-CBOR as JSON-safe, but the client sent "Accept: application/json"', err);
|
|
163
|
-
return notAcceptableResponse();
|
|
164
|
-
}
|
|
165
|
-
this.log('could not decode DAG-CBOR as JSON-safe, falling back to `application/octet-stream`', err);
|
|
166
|
-
body = block;
|
|
167
|
-
}
|
|
95
|
+
catch (err) {
|
|
96
|
+
this.log('could not decode DAG-CBOR as JSON-safe, falling back to `application/octet-stream`', err);
|
|
97
|
+
body = block;
|
|
168
98
|
}
|
|
169
99
|
const response = okResponse(body);
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
}
|
|
173
|
-
response.headers.set('content-type', accept);
|
|
100
|
+
response.headers.set('content-type', body instanceof Uint8Array ? 'application/octet-stream' : 'application/json');
|
|
101
|
+
options?.onProgress?.(new CustomProgressEvent('verified-fetch:request:end', { cid, path }));
|
|
174
102
|
return response;
|
|
175
103
|
}
|
|
176
|
-
async handleDagPb({ cid, path, options }) {
|
|
177
|
-
|
|
178
|
-
let ipfsRoots;
|
|
179
|
-
try {
|
|
180
|
-
const pathDetails = await walkPath(this.helia.blockstore, `${cid.toString()}/${path}`, options);
|
|
181
|
-
ipfsRoots = pathDetails.ipfsRoots;
|
|
182
|
-
terminalElement = pathDetails.terminalElement;
|
|
183
|
-
}
|
|
184
|
-
catch (err) {
|
|
185
|
-
this.log.error('Error walking path %s', path, err);
|
|
186
|
-
}
|
|
104
|
+
async handleDagPb({ cid, path, options, terminalElement }) {
|
|
105
|
+
this.log.trace('fetching %c/%s', cid, path);
|
|
187
106
|
let resolvedCID = terminalElement?.cid ?? cid;
|
|
188
107
|
let stat;
|
|
189
108
|
if (terminalElement?.type === 'directory') {
|
|
@@ -191,6 +110,7 @@ export class VerifiedFetch {
|
|
|
191
110
|
const rootFilePath = 'index.html';
|
|
192
111
|
try {
|
|
193
112
|
this.log.trace('found directory at %c/%s, looking for index.html', cid, path);
|
|
113
|
+
options?.onProgress?.(new CustomProgressEvent('verified-fetch:request:start', { cid: dirCid, path: rootFilePath }));
|
|
194
114
|
stat = await this.unixfs.stat(dirCid, {
|
|
195
115
|
path: rootFilePath,
|
|
196
116
|
signal: options?.signal,
|
|
@@ -209,6 +129,7 @@ export class VerifiedFetch {
|
|
|
209
129
|
options?.onProgress?.(new CustomProgressEvent('verified-fetch:request:end', { cid: dirCid, path: rootFilePath }));
|
|
210
130
|
}
|
|
211
131
|
}
|
|
132
|
+
options?.onProgress?.(new CustomProgressEvent('verified-fetch:request:start', { cid: resolvedCID, path: '' }));
|
|
212
133
|
const asyncIter = this.unixfs.cat(resolvedCID, {
|
|
213
134
|
signal: options?.signal,
|
|
214
135
|
onProgress: options?.onProgress
|
|
@@ -219,24 +140,16 @@ export class VerifiedFetch {
|
|
|
219
140
|
});
|
|
220
141
|
const response = okResponse(stream);
|
|
221
142
|
await this.setContentType(firstChunk, path, response);
|
|
222
|
-
|
|
223
|
-
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
|
|
224
|
-
}
|
|
143
|
+
options?.onProgress?.(new CustomProgressEvent('verified-fetch:request:end', { cid: resolvedCID, path: '' }));
|
|
225
144
|
return response;
|
|
226
145
|
}
|
|
227
146
|
async handleRaw({ cid, path, options }) {
|
|
228
|
-
|
|
147
|
+
this.log.trace('fetching %c/%s', cid, path);
|
|
148
|
+
options?.onProgress?.(new CustomProgressEvent('verified-fetch:request:start', { cid, path }));
|
|
149
|
+
const result = await this.helia.blockstore.get(cid);
|
|
229
150
|
const response = okResponse(result);
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
// `application/vnd.ipld.raw` but get `application/octet-stream`
|
|
233
|
-
const overriddenContentType = getOverridenRawContentType(options?.headers);
|
|
234
|
-
if (overriddenContentType != null) {
|
|
235
|
-
response.headers.set('content-type', overriddenContentType);
|
|
236
|
-
}
|
|
237
|
-
else {
|
|
238
|
-
await this.setContentType(result, path, response);
|
|
239
|
-
}
|
|
151
|
+
await this.setContentType(result, path, response);
|
|
152
|
+
options?.onProgress?.(new CustomProgressEvent('verified-fetch:request:end', { cid, path }));
|
|
240
153
|
return response;
|
|
241
154
|
}
|
|
242
155
|
async setContentType(bytes, path, response) {
|
|
@@ -263,94 +176,99 @@ export class VerifiedFetch {
|
|
|
263
176
|
response.headers.set('content-type', contentType);
|
|
264
177
|
}
|
|
265
178
|
/**
|
|
266
|
-
*
|
|
267
|
-
*
|
|
179
|
+
* Determines the format requested by the client, defaults to `null` if no format is requested.
|
|
180
|
+
*
|
|
181
|
+
* @see https://specs.ipfs.tech/http-gateways/path-gateway/#format-request-query-parameter
|
|
182
|
+
* @default 'raw'
|
|
183
|
+
*/
|
|
184
|
+
getFormat({ headerFormat, queryFormat }) {
|
|
185
|
+
const formatMap = {
|
|
186
|
+
'vnd.ipld.raw': 'raw',
|
|
187
|
+
'vnd.ipld.car': 'car',
|
|
188
|
+
'application/x-tar': 'tar',
|
|
189
|
+
'application/vnd.ipld.dag-json': 'dag-json',
|
|
190
|
+
'application/vnd.ipld.dag-cbor': 'dag-cbor',
|
|
191
|
+
'application/json': 'json',
|
|
192
|
+
'application/cbor': 'cbor',
|
|
193
|
+
'vnd.ipfs.ipns-record': 'ipns-record'
|
|
194
|
+
};
|
|
195
|
+
if (headerFormat != null) {
|
|
196
|
+
for (const format in formatMap) {
|
|
197
|
+
if (headerFormat.includes(format)) {
|
|
198
|
+
return formatMap[format];
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
else if (queryFormat != null) {
|
|
203
|
+
return queryFormat;
|
|
204
|
+
}
|
|
205
|
+
return null;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Map of format to specific handlers for that format.
|
|
209
|
+
* These format handlers should adjust the response headers as specified in https://specs.ipfs.tech/http-gateways/path-gateway/#response-headers
|
|
268
210
|
*/
|
|
211
|
+
formatHandlers = {
|
|
212
|
+
raw: async () => notSupportedResponse('application/vnd.ipld.raw support is not implemented'),
|
|
213
|
+
car: this.handleIPLDCar,
|
|
214
|
+
'ipns-record': this.handleIPNSRecord,
|
|
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
|
+
};
|
|
269
221
|
codecHandlers = {
|
|
270
222
|
[dagPbCode]: this.handleDagPb,
|
|
271
|
-
[
|
|
223
|
+
[dagJsonCode]: this.handleJson,
|
|
272
224
|
[jsonCode]: this.handleJson,
|
|
273
|
-
[
|
|
225
|
+
[dagCborCode]: this.handleDagCbor,
|
|
274
226
|
[rawCode]: this.handleRaw,
|
|
275
227
|
[identity.code]: this.handleRaw
|
|
276
228
|
};
|
|
277
229
|
async fetch(resource, opts) {
|
|
278
|
-
this.log('fetch %s', resource);
|
|
279
230
|
const options = convertOptions(opts);
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
const { path, query, cid } = await parseResource(resource, { ipns: this.ipns, logger: this.helia.logger }, options);
|
|
283
|
-
options?.onProgress?.(new CustomProgressEvent('verified-fetch:request:resolve', { cid, path }));
|
|
284
|
-
const requestHeaders = new Headers(options?.headers);
|
|
285
|
-
const incomingAcceptHeader = requestHeaders.get('accept');
|
|
286
|
-
if (incomingAcceptHeader != null) {
|
|
287
|
-
this.log('incoming accept header "%s"', incomingAcceptHeader);
|
|
288
|
-
}
|
|
289
|
-
const queryFormatMapping = queryFormatToAcceptHeader(query.format);
|
|
290
|
-
if (query.format != null) {
|
|
291
|
-
this.log('incoming query format "%s", mapped to %s', query.format, queryFormatMapping);
|
|
292
|
-
}
|
|
293
|
-
const acceptHeader = incomingAcceptHeader ?? queryFormatMapping;
|
|
294
|
-
const accept = selectOutputType(cid, acceptHeader);
|
|
295
|
-
this.log('output type %s', accept);
|
|
296
|
-
if (acceptHeader != null && accept == null) {
|
|
297
|
-
return notAcceptableResponse();
|
|
298
|
-
}
|
|
231
|
+
const { path, query, ...rest } = await parseResource(resource, { ipns: this.ipns, logger: this.helia.logger }, options);
|
|
232
|
+
const cid = rest.cid;
|
|
299
233
|
let response;
|
|
300
|
-
|
|
301
|
-
if (
|
|
302
|
-
//
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
query.filename = query.filename ?? `${cid.toString()}.car`;
|
|
311
|
-
response = await this.handleCar({ cid, path, options });
|
|
234
|
+
const format = this.getFormat({ headerFormat: new Headers(options?.headers).get('accept'), queryFormat: query.format ?? null });
|
|
235
|
+
if (format != null) {
|
|
236
|
+
// TODO: These should be handled last when they're returning something other than 501
|
|
237
|
+
const formatHandler = this.formatHandlers[format];
|
|
238
|
+
if (formatHandler != null) {
|
|
239
|
+
response = await formatHandler.call(this, { cid, path, options });
|
|
240
|
+
if (response.status === 501) {
|
|
241
|
+
return response;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
312
244
|
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
245
|
+
let terminalElement;
|
|
246
|
+
let ipfsRoots;
|
|
247
|
+
try {
|
|
248
|
+
const pathDetails = await this.pathWalker(this.helia.blockstore, `${cid.toString()}/${path}`, options);
|
|
249
|
+
ipfsRoots = pathDetails.ipfsRoots;
|
|
250
|
+
terminalElement = pathDetails.terminalElement;
|
|
319
251
|
}
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
response = await this.handleTar({ cid, path, options });
|
|
252
|
+
catch (err) {
|
|
253
|
+
this.log.error('Error walking path %s', path, err);
|
|
254
|
+
// return new Response(`Error walking path: ${(err as Error).message}`, { status: 500 })
|
|
324
255
|
}
|
|
325
|
-
|
|
326
|
-
// derive the handler from the CID type
|
|
256
|
+
if (response == null) {
|
|
327
257
|
const codecHandler = this.codecHandlers[cid.code];
|
|
328
|
-
if (codecHandler
|
|
258
|
+
if (codecHandler != null) {
|
|
259
|
+
response = await codecHandler.call(this, { cid, path, options, terminalElement });
|
|
260
|
+
}
|
|
261
|
+
else {
|
|
329
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`);
|
|
330
263
|
}
|
|
331
|
-
response = await codecHandler.call(this, { cid, path, accept, options });
|
|
332
264
|
}
|
|
333
|
-
response.headers.set('etag', getETag({ cid, reqFormat, weak: false }));
|
|
265
|
+
response.headers.set('etag', getETag({ cid, reqFormat: format ?? undefined, weak: false }));
|
|
334
266
|
response.headers.set('cache-control', 'public, max-age=29030400, immutable');
|
|
335
|
-
// https://specs.ipfs.tech/http-gateways/path-gateway/#x-ipfs-path-response-header
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
let contentDisposition;
|
|
339
|
-
// force download if requested
|
|
340
|
-
if (query.download === true) {
|
|
341
|
-
contentDisposition = 'attachment';
|
|
342
|
-
}
|
|
343
|
-
// override filename if requested
|
|
344
|
-
if (query.filename != null) {
|
|
345
|
-
if (contentDisposition == null) {
|
|
346
|
-
contentDisposition = 'inline';
|
|
347
|
-
}
|
|
348
|
-
contentDisposition = `${contentDisposition}; ${getContentDispositionFilename(query.filename)}`;
|
|
349
|
-
}
|
|
350
|
-
if (contentDisposition != null) {
|
|
351
|
-
response.headers.set('Content-Disposition', contentDisposition);
|
|
267
|
+
response.headers.set('X-Ipfs-Path', resource.toString()); // https://specs.ipfs.tech/http-gateways/path-gateway/#x-ipfs-path-response-header
|
|
268
|
+
if (ipfsRoots != null) {
|
|
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
|
|
352
270
|
}
|
|
353
|
-
|
|
271
|
+
// response.headers.set('Content-Disposition', `TODO`) // https://specs.ipfs.tech/http-gateways/path-gateway/#content-disposition-response-header
|
|
354
272
|
return response;
|
|
355
273
|
}
|
|
356
274
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verified-fetch.js","sourceRoot":"","sources":["../../src/verified-fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAA;AAChC,OAAO,EAAE,IAAI,IAAI,SAAS,EAAa,MAAM,aAAa,CAAA;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AAC5D,OAAO,EAAE,MAAM,IAAI,WAAW,EAAgD,MAAM,eAAe,CAAA;AACnG,OAAO,KAAK,WAAW,MAAM,gBAAgB,CAAA;AAC7C,OAAO,KAAK,WAAW,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,IAAI,IAAI,SAAS,EAAE,MAAM,cAAc,CAAA;AAChD,OAAO,uBAAuB,MAAM,8BAA8B,CAAA;AAClE,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AAC3D,OAAO,EAAE,IAAI,IAAI,OAAO,EAAE,MAAM,yBAAyB,CAAA;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAA;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AACpE,OAAO,EAAE,6BAA6B,EAAE,MAAM,6CAA6C,CAAA;AAC3F,O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,CAAA;AACxB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@helia/verified-fetch",
|
|
3
|
-
"version": "0.0.0-
|
|
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,13 +141,12 @@
|
|
|
141
141
|
"release": "aegir release"
|
|
142
142
|
},
|
|
143
143
|
"dependencies": {
|
|
144
|
-
"@helia/
|
|
145
|
-
"@helia/
|
|
146
|
-
"@helia/
|
|
147
|
-
"@helia/
|
|
148
|
-
"@helia/
|
|
149
|
-
"@helia/
|
|
150
|
-
"@helia/unixfs": "3.0.0-a04e041",
|
|
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",
|
|
151
150
|
"@ipld/dag-cbor": "^9.2.0",
|
|
152
151
|
"@ipld/dag-json": "^10.2.0",
|
|
153
152
|
"@ipld/dag-pb": "^4.1.0",
|
|
@@ -156,17 +155,14 @@
|
|
|
156
155
|
"cborg": "^4.0.9",
|
|
157
156
|
"hashlru": "^2.3.0",
|
|
158
157
|
"ipfs-unixfs-exporter": "^13.5.0",
|
|
159
|
-
"it-to-browser-readablestream": "^2.0.6",
|
|
160
158
|
"multiformats": "^13.1.0",
|
|
161
159
|
"progress-events": "^1.0.0"
|
|
162
160
|
},
|
|
163
161
|
"devDependencies": {
|
|
164
|
-
"@helia/
|
|
165
|
-
"@helia/dag-
|
|
166
|
-
"@helia/
|
|
167
|
-
"@helia/
|
|
168
|
-
"@helia/utils": "0.0.1-a04e041",
|
|
169
|
-
"@ipld/car": "^5.2.6",
|
|
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",
|
|
170
166
|
"@libp2p/logger": "^4.0.5",
|
|
171
167
|
"@libp2p/peer-id-factory": "^4.0.5",
|
|
172
168
|
"@sgtpooki/file-type": "^1.0.1",
|
|
@@ -174,12 +170,10 @@
|
|
|
174
170
|
"aegir": "^42.2.2",
|
|
175
171
|
"blockstore-core": "^4.4.0",
|
|
176
172
|
"datastore-core": "^9.2.8",
|
|
177
|
-
"helia": "4.0.1-
|
|
178
|
-
"ipns": "^9.0.0",
|
|
173
|
+
"helia": "4.0.1-dc2e7a6",
|
|
179
174
|
"it-last": "^3.0.4",
|
|
180
175
|
"it-to-buffer": "^4.0.5",
|
|
181
176
|
"magic-bytes.js": "^1.8.0",
|
|
182
|
-
"p-defer": "^4.0.0",
|
|
183
177
|
"sinon": "^17.0.1",
|
|
184
178
|
"sinon-ts": "^2.0.0",
|
|
185
179
|
"uint8arrays": "^5.0.1"
|
package/src/index.ts
CHANGED
|
@@ -320,39 +320,6 @@
|
|
|
320
320
|
* console.info(obj) // ...
|
|
321
321
|
* ```
|
|
322
322
|
*
|
|
323
|
-
* ## The `Accept` header
|
|
324
|
-
*
|
|
325
|
-
* The `Accept` header can be passed to override certain response processing, or to ensure that the final `Content-Type` of the response is the one that is expected.
|
|
326
|
-
*
|
|
327
|
-
* If the final `Content-Type` does not match the `Accept` header, or if the content cannot be represented in the format dictated by the `Accept` header, or you have configured a custom content type parser, and that parser returns a value that isn't in the accept header, a [406: Not Acceptable](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/406) response will be returned:
|
|
328
|
-
*
|
|
329
|
-
* ```typescript
|
|
330
|
-
* import { verifiedFetch } from '@helia/verified-fetch'
|
|
331
|
-
*
|
|
332
|
-
* const res = await verifiedFetch('ipfs://bafyJPEGImageCID', {
|
|
333
|
-
* headers: {
|
|
334
|
-
* accept: 'image/png'
|
|
335
|
-
* }
|
|
336
|
-
* })
|
|
337
|
-
*
|
|
338
|
-
* console.info(res.status) // 406 - the image was a JPEG but we specified PNG as the accept header
|
|
339
|
-
* ```
|
|
340
|
-
*
|
|
341
|
-
* It can also be used to skip processing the data from some formats such as `DAG-CBOR` if you wish to handle decoding it yourself:
|
|
342
|
-
*
|
|
343
|
-
* ```typescript
|
|
344
|
-
* import { verifiedFetch } from '@helia/verified-fetch'
|
|
345
|
-
*
|
|
346
|
-
* const res = await verifiedFetch('ipfs://bafyDAGCBORCID', {
|
|
347
|
-
* headers: {
|
|
348
|
-
* accept: 'application/octet-stream'
|
|
349
|
-
* }
|
|
350
|
-
* })
|
|
351
|
-
*
|
|
352
|
-
* console.info(res.headers.get('accept')) // application/octet-stream
|
|
353
|
-
* const buf = await res.arrayBuffer() // raw bytes, not processed as JSON
|
|
354
|
-
* ```
|
|
355
|
-
*
|
|
356
323
|
* ## Comparison to fetch
|
|
357
324
|
*
|
|
358
325
|
* This module attempts to act as similarly to the `fetch()` API as possible.
|
|
@@ -482,10 +449,6 @@ import type { ProgressEvent, ProgressOptions } from 'progress-events'
|
|
|
482
449
|
*/
|
|
483
450
|
export type Resource = string | CID
|
|
484
451
|
|
|
485
|
-
export interface ResourceDetail {
|
|
486
|
-
resource: Resource
|
|
487
|
-
}
|
|
488
|
-
|
|
489
452
|
export interface CIDDetail {
|
|
490
453
|
cid: CID
|
|
491
454
|
path: string
|
|
@@ -19,8 +19,6 @@ export interface ParseUrlStringOptions extends ProgressOptions<ResolveProgressEv
|
|
|
19
19
|
|
|
20
20
|
export interface ParsedUrlQuery extends Record<string, string | unknown> {
|
|
21
21
|
format?: RequestFormatShorthand
|
|
22
|
-
download?: boolean
|
|
23
|
-
filename?: string
|
|
24
22
|
}
|
|
25
23
|
|
|
26
24
|
export interface ParsedUrlStringResults {
|
|
@@ -111,7 +109,7 @@ export async function parseUrlString ({ urlString, ipns, logger }: ParseUrlStrin
|
|
|
111
109
|
}
|
|
112
110
|
|
|
113
111
|
// parse query string
|
|
114
|
-
const query: Record<string,
|
|
112
|
+
const query: Record<string, string> = {}
|
|
115
113
|
|
|
116
114
|
if (queryString != null && queryString.length > 0) {
|
|
117
115
|
const queryParts = queryString.split('&')
|
|
@@ -119,14 +117,6 @@ export async function parseUrlString ({ urlString, ipns, logger }: ParseUrlStrin
|
|
|
119
117
|
const [key, value] = part.split('=')
|
|
120
118
|
query[key] = decodeURIComponent(value)
|
|
121
119
|
}
|
|
122
|
-
|
|
123
|
-
if (query.download != null) {
|
|
124
|
-
query.download = query.download === 'true'
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
if (query.filename != null) {
|
|
128
|
-
query.filename = query.filename.toString()
|
|
129
|
-
}
|
|
130
120
|
}
|
|
131
121
|
|
|
132
122
|
/**
|