@helia/verified-fetch 0.0.0-8db7792 → 0.0.0-a04e041
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 +33 -0
- package/dist/index.min.js +4 -4
- package/dist/src/index.d.ts +36 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +33 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/utils/get-content-disposition-filename.d.ts +6 -0
- package/dist/src/utils/get-content-disposition-filename.d.ts.map +1 -0
- package/dist/src/utils/get-content-disposition-filename.js +16 -0
- package/dist/src/utils/get-content-disposition-filename.js.map +1 -0
- package/dist/src/utils/parse-url-string.d.ts +2 -0
- package/dist/src/utils/parse-url-string.d.ts.map +1 -1
- package/dist/src/utils/parse-url-string.js +6 -0
- package/dist/src/utils/parse-url-string.js.map +1 -1
- package/dist/src/utils/responses.d.ts +4 -0
- package/dist/src/utils/responses.d.ts.map +1 -0
- package/dist/src/utils/responses.js +21 -0
- package/dist/src/utils/responses.js.map +1 -0
- package/dist/src/utils/select-output-type.d.ts +12 -0
- package/dist/src/utils/select-output-type.d.ts.map +1 -0
- package/dist/src/utils/select-output-type.js +147 -0
- package/dist/src/utils/select-output-type.js.map +1 -0
- package/dist/src/verified-fetch.d.ts +17 -15
- package/dist/src/verified-fetch.d.ts.map +1 -1
- package/dist/src/verified-fetch.js +211 -129
- package/dist/src/verified-fetch.js.map +1 -1
- package/package.json +18 -12
- package/src/index.ts +37 -0
- package/src/utils/get-content-disposition-filename.ts +18 -0
- package/src/utils/parse-url-string.ts +11 -1
- package/src/utils/responses.ts +22 -0
- package/src/utils/select-output-type.ts +166 -0
- package/src/verified-fetch.ts +237 -134
|
@@ -1,17 +1,22 @@
|
|
|
1
|
+
import { car } from '@helia/car';
|
|
1
2
|
import { ipns as heliaIpns } from '@helia/ipns';
|
|
2
3
|
import { dnsJsonOverHttps } from '@helia/ipns/dns-resolvers';
|
|
3
4
|
import { unixfs as heliaUnixFs } from '@helia/unixfs';
|
|
4
|
-
import
|
|
5
|
-
import
|
|
5
|
+
import * as ipldDagCbor from '@ipld/dag-cbor';
|
|
6
|
+
import * as ipldDagJson from '@ipld/dag-json';
|
|
6
7
|
import { code as dagPbCode } from '@ipld/dag-pb';
|
|
8
|
+
import toBrowserReadableStream from 'it-to-browser-readablestream';
|
|
7
9
|
import { code as jsonCode } from 'multiformats/codecs/json';
|
|
8
10
|
import { code as rawCode } from 'multiformats/codecs/raw';
|
|
9
11
|
import { identity } from 'multiformats/hashes/identity';
|
|
10
12
|
import { CustomProgressEvent } from 'progress-events';
|
|
11
13
|
import { dagCborToSafeJSON } from './utils/dag-cbor-to-safe-json.js';
|
|
14
|
+
import { getContentDispositionFilename } from './utils/get-content-disposition-filename.js';
|
|
12
15
|
import { getETag } from './utils/get-e-tag.js';
|
|
13
16
|
import { getStreamFromAsyncIterable } from './utils/get-stream-from-async-iterable.js';
|
|
14
17
|
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';
|
|
15
20
|
import { walkPath } from './utils/walk-path.js';
|
|
16
21
|
function convertOptions(options) {
|
|
17
22
|
if (options == null) {
|
|
@@ -26,26 +31,42 @@ function convertOptions(options) {
|
|
|
26
31
|
signal
|
|
27
32
|
};
|
|
28
33
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
34
|
+
/**
|
|
35
|
+
* These are Accept header values that will cause content type sniffing to be
|
|
36
|
+
* skipped and set to these values.
|
|
37
|
+
*/
|
|
38
|
+
const RAW_HEADERS = [
|
|
39
|
+
'application/vnd.ipld.raw',
|
|
40
|
+
'application/octet-stream'
|
|
41
|
+
];
|
|
42
|
+
/**
|
|
43
|
+
* if the user has specified an `Accept` header, and it's in our list of
|
|
44
|
+
* allowable "raw" format headers, use that instead of detecting the content
|
|
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
|
+
}
|
|
40
62
|
}
|
|
41
63
|
export class VerifiedFetch {
|
|
42
64
|
helia;
|
|
43
65
|
ipns;
|
|
44
66
|
unixfs;
|
|
45
|
-
pathWalker;
|
|
46
67
|
log;
|
|
47
68
|
contentTypeParser;
|
|
48
|
-
constructor({ helia, ipns, unixfs
|
|
69
|
+
constructor({ helia, ipns, unixfs }, init) {
|
|
49
70
|
this.helia = helia;
|
|
50
71
|
this.log = helia.logger.forComponent('helia:verified-fetch');
|
|
51
72
|
this.ipns = ipns ?? heliaIpns(helia, {
|
|
@@ -55,54 +76,114 @@ export class VerifiedFetch {
|
|
|
55
76
|
]
|
|
56
77
|
});
|
|
57
78
|
this.unixfs = unixfs ?? heliaUnixFs(helia);
|
|
58
|
-
this.pathWalker = pathWalker ?? walkPath;
|
|
59
79
|
this.contentTypeParser = init?.contentTypeParser;
|
|
60
80
|
this.log.trace('created VerifiedFetch instance');
|
|
61
81
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
82
|
+
/**
|
|
83
|
+
* Accepts an `ipns://...` URL as a string and returns a `Response` containing
|
|
84
|
+
* a raw IPNS record.
|
|
85
|
+
*/
|
|
86
|
+
async handleIPNSRecord(resource, opts) {
|
|
87
|
+
return notSupportedResponse('vnd.ipfs.ipns-record support is not implemented');
|
|
67
88
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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');
|
|
72
98
|
return response;
|
|
73
99
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
options?.onProgress?.(new CustomProgressEvent('verified-fetch:request:end', { cid, path }));
|
|
84
|
-
return response;
|
|
100
|
+
/**
|
|
101
|
+
* Accepts a UnixFS `CID` and returns a `.tar` file containing the file or
|
|
102
|
+
* directory structure referenced by the `CID`.
|
|
103
|
+
*/
|
|
104
|
+
async handleTar({ cid, path, options }) {
|
|
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');
|
|
85
109
|
}
|
|
86
|
-
async
|
|
110
|
+
async handleJson({ cid, path, accept, options }) {
|
|
87
111
|
this.log.trace('fetching %c/%s', cid, path);
|
|
88
|
-
|
|
89
|
-
// return body as binary
|
|
90
|
-
const block = await this.helia.blockstore.get(cid);
|
|
112
|
+
const block = await this.helia.blockstore.get(cid, options);
|
|
91
113
|
let body;
|
|
92
|
-
|
|
93
|
-
|
|
114
|
+
if (accept === 'application/vnd.ipld.dag-cbor' || accept === 'application/cbor') {
|
|
115
|
+
try {
|
|
116
|
+
// if vnd.ipld.dag-cbor has been specified, convert to the format - note
|
|
117
|
+
// that this supports more data types than regular JSON, the content-type
|
|
118
|
+
// response header is set so the user knows to process it differently
|
|
119
|
+
const obj = ipldDagJson.decode(block);
|
|
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
|
+
}
|
|
94
126
|
}
|
|
95
|
-
|
|
96
|
-
|
|
127
|
+
else {
|
|
128
|
+
// skip decoding
|
|
97
129
|
body = block;
|
|
98
130
|
}
|
|
99
131
|
const response = okResponse(body);
|
|
100
|
-
response.headers.set('content-type',
|
|
101
|
-
options?.onProgress?.(new CustomProgressEvent('verified-fetch:request:end', { cid, path }));
|
|
132
|
+
response.headers.set('content-type', accept ?? 'application/json');
|
|
102
133
|
return response;
|
|
103
134
|
}
|
|
104
|
-
async
|
|
135
|
+
async handleDagCbor({ cid, path, accept, options }) {
|
|
105
136
|
this.log.trace('fetching %c/%s', cid, path);
|
|
137
|
+
const block = await this.helia.blockstore.get(cid, options);
|
|
138
|
+
let body;
|
|
139
|
+
if (accept === 'application/octet-stream' || accept === 'application/vnd.ipld.dag-cbor' || accept === 'application/cbor') {
|
|
140
|
+
// skip decoding
|
|
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
|
+
}
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
try {
|
|
158
|
+
body = dagCborToSafeJSON(block);
|
|
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
|
+
}
|
|
168
|
+
}
|
|
169
|
+
const response = okResponse(body);
|
|
170
|
+
if (accept == null) {
|
|
171
|
+
accept = body instanceof Uint8Array ? 'application/octet-stream' : 'application/json';
|
|
172
|
+
}
|
|
173
|
+
response.headers.set('content-type', accept);
|
|
174
|
+
return response;
|
|
175
|
+
}
|
|
176
|
+
async handleDagPb({ cid, path, options }) {
|
|
177
|
+
let terminalElement;
|
|
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
|
+
}
|
|
106
187
|
let resolvedCID = terminalElement?.cid ?? cid;
|
|
107
188
|
let stat;
|
|
108
189
|
if (terminalElement?.type === 'directory') {
|
|
@@ -110,7 +191,6 @@ export class VerifiedFetch {
|
|
|
110
191
|
const rootFilePath = 'index.html';
|
|
111
192
|
try {
|
|
112
193
|
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 }));
|
|
114
194
|
stat = await this.unixfs.stat(dirCid, {
|
|
115
195
|
path: rootFilePath,
|
|
116
196
|
signal: options?.signal,
|
|
@@ -129,7 +209,6 @@ export class VerifiedFetch {
|
|
|
129
209
|
options?.onProgress?.(new CustomProgressEvent('verified-fetch:request:end', { cid: dirCid, path: rootFilePath }));
|
|
130
210
|
}
|
|
131
211
|
}
|
|
132
|
-
options?.onProgress?.(new CustomProgressEvent('verified-fetch:request:start', { cid: resolvedCID, path: '' }));
|
|
133
212
|
const asyncIter = this.unixfs.cat(resolvedCID, {
|
|
134
213
|
signal: options?.signal,
|
|
135
214
|
onProgress: options?.onProgress
|
|
@@ -140,16 +219,24 @@ export class VerifiedFetch {
|
|
|
140
219
|
});
|
|
141
220
|
const response = okResponse(stream);
|
|
142
221
|
await this.setContentType(firstChunk, path, response);
|
|
143
|
-
|
|
222
|
+
if (ipfsRoots != null) {
|
|
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
|
+
}
|
|
144
225
|
return response;
|
|
145
226
|
}
|
|
146
227
|
async handleRaw({ cid, path, options }) {
|
|
147
|
-
this.
|
|
148
|
-
options?.onProgress?.(new CustomProgressEvent('verified-fetch:request:start', { cid, path }));
|
|
149
|
-
const result = await this.helia.blockstore.get(cid);
|
|
228
|
+
const result = await this.helia.blockstore.get(cid, options);
|
|
150
229
|
const response = okResponse(result);
|
|
151
|
-
|
|
152
|
-
|
|
230
|
+
// if the user has specified an `Accept` header that corresponds to a raw
|
|
231
|
+
// type, honour that header, so for example they don't request
|
|
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
|
+
}
|
|
153
240
|
return response;
|
|
154
241
|
}
|
|
155
242
|
async setContentType(bytes, path, response) {
|
|
@@ -176,99 +263,94 @@ export class VerifiedFetch {
|
|
|
176
263
|
response.headers.set('content-type', contentType);
|
|
177
264
|
}
|
|
178
265
|
/**
|
|
179
|
-
*
|
|
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
|
|
266
|
+
* If the user has not specified an Accept header or format query string arg,
|
|
267
|
+
* use the CID codec to choose an appropriate handler for the block data.
|
|
210
268
|
*/
|
|
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
|
-
};
|
|
221
269
|
codecHandlers = {
|
|
222
270
|
[dagPbCode]: this.handleDagPb,
|
|
223
|
-
[
|
|
271
|
+
[ipldDagJson.code]: this.handleJson,
|
|
224
272
|
[jsonCode]: this.handleJson,
|
|
225
|
-
[
|
|
273
|
+
[ipldDagCbor.code]: this.handleDagCbor,
|
|
226
274
|
[rawCode]: this.handleRaw,
|
|
227
275
|
[identity.code]: this.handleRaw
|
|
228
276
|
};
|
|
229
277
|
async fetch(resource, opts) {
|
|
278
|
+
this.log('fetch %s', resource);
|
|
230
279
|
const options = convertOptions(opts);
|
|
231
|
-
|
|
232
|
-
|
|
280
|
+
options?.onProgress?.(new CustomProgressEvent('verified-fetch:request:start', { resource }));
|
|
281
|
+
// resolve the CID/path from the requested resource
|
|
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
|
+
}
|
|
233
299
|
let response;
|
|
234
|
-
|
|
235
|
-
if (
|
|
236
|
-
//
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
response = await formatHandler.call(this, { cid, path, options });
|
|
240
|
-
if (response.status === 501) {
|
|
241
|
-
return response;
|
|
242
|
-
}
|
|
243
|
-
}
|
|
300
|
+
let reqFormat;
|
|
301
|
+
if (accept === 'application/vnd.ipfs.ipns-record') {
|
|
302
|
+
// the user requested a raw IPNS record
|
|
303
|
+
reqFormat = 'ipns-record';
|
|
304
|
+
response = await this.handleIPNSRecord(resource.toString(), options);
|
|
244
305
|
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
306
|
+
else if (accept === 'application/vnd.ipld.car') {
|
|
307
|
+
// the user requested a CAR file
|
|
308
|
+
reqFormat = 'car';
|
|
309
|
+
query.download = true;
|
|
310
|
+
query.filename = query.filename ?? `${cid.toString()}.car`;
|
|
311
|
+
response = await this.handleCar({ cid, path, options });
|
|
251
312
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
313
|
+
else if (accept === 'application/vnd.ipld.raw') {
|
|
314
|
+
// the user requested a raw block
|
|
315
|
+
reqFormat = 'raw';
|
|
316
|
+
query.download = true;
|
|
317
|
+
query.filename = query.filename ?? `${cid.toString()}.bin`;
|
|
318
|
+
response = await this.handleRaw({ cid, path, options });
|
|
255
319
|
}
|
|
256
|
-
if (
|
|
320
|
+
else if (accept === 'application/x-tar') {
|
|
321
|
+
// the user requested a TAR file
|
|
322
|
+
reqFormat = 'tar';
|
|
323
|
+
response = await this.handleTar({ cid, path, options });
|
|
324
|
+
}
|
|
325
|
+
else {
|
|
326
|
+
// derive the handler from the CID type
|
|
257
327
|
const codecHandler = this.codecHandlers[cid.code];
|
|
258
|
-
if (codecHandler
|
|
259
|
-
response = await codecHandler.call(this, { cid, path, options, terminalElement });
|
|
260
|
-
}
|
|
261
|
-
else {
|
|
328
|
+
if (codecHandler == null) {
|
|
262
329
|
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`);
|
|
263
330
|
}
|
|
331
|
+
response = await codecHandler.call(this, { cid, path, accept, options });
|
|
264
332
|
}
|
|
265
|
-
response.headers.set('etag', getETag({ cid, reqFormat
|
|
333
|
+
response.headers.set('etag', getETag({ cid, reqFormat, weak: false }));
|
|
266
334
|
response.headers.set('cache-control', 'public, max-age=29030400, immutable');
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
335
|
+
// https://specs.ipfs.tech/http-gateways/path-gateway/#x-ipfs-path-response-header
|
|
336
|
+
response.headers.set('X-Ipfs-Path', resource.toString());
|
|
337
|
+
// set Content-Disposition header
|
|
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)}`;
|
|
270
349
|
}
|
|
271
|
-
|
|
350
|
+
if (contentDisposition != null) {
|
|
351
|
+
response.headers.set('Content-Disposition', contentDisposition);
|
|
352
|
+
}
|
|
353
|
+
options?.onProgress?.(new CustomProgressEvent('verified-fetch:request:end', { cid, path }));
|
|
272
354
|
return response;
|
|
273
355
|
}
|
|
274
356
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":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;QACjC,IAAI,KAAK,CAAC,QAAQ,IAAI,IAAI,EAAE,CAAC;YAC3B,IAAI,kBAAkB,IAAI,IAAI,EAAE,CAAC;gBAC/B,kBAAkB,GAAG,QAAQ,CAAA;YAC/B,CAAC;YAED,kBAAkB,GAAG,GAAG,kBAAkB,KAAK,6BAA6B,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAA;QAChG,CAAC;QAED,IAAI,kBAAkB,IAAI,IAAI,EAAE,CAAC;YAC/B,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,qBAAqB,EAAE,kBAAkB,CAAC,CAAA;QACjE,CAAC;QAED,OAAO,EAAE,UAAU,EAAE,CAAC,IAAI,mBAAmB,CAAY,4BAA4B,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;QAEtG,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-
|
|
3
|
+
"version": "0.0.0-a04e041",
|
|
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,12 +141,13 @@
|
|
|
141
141
|
"release": "aegir release"
|
|
142
142
|
},
|
|
143
143
|
"dependencies": {
|
|
144
|
-
"@helia/
|
|
145
|
-
"@helia/
|
|
146
|
-
"@helia/
|
|
147
|
-
"@helia/
|
|
148
|
-
"@helia/
|
|
149
|
-
"@helia/
|
|
144
|
+
"@helia/car": "3.0.0-a04e041",
|
|
145
|
+
"@helia/block-brokers": "2.0.1-a04e041",
|
|
146
|
+
"@helia/http": "1.0.1-a04e041",
|
|
147
|
+
"@helia/interface": "4.0.0-a04e041",
|
|
148
|
+
"@helia/ipns": "6.0.0-a04e041",
|
|
149
|
+
"@helia/routers": "1.0.0-a04e041",
|
|
150
|
+
"@helia/unixfs": "3.0.0-a04e041",
|
|
150
151
|
"@ipld/dag-cbor": "^9.2.0",
|
|
151
152
|
"@ipld/dag-json": "^10.2.0",
|
|
152
153
|
"@ipld/dag-pb": "^4.1.0",
|
|
@@ -155,14 +156,17 @@
|
|
|
155
156
|
"cborg": "^4.0.9",
|
|
156
157
|
"hashlru": "^2.3.0",
|
|
157
158
|
"ipfs-unixfs-exporter": "^13.5.0",
|
|
159
|
+
"it-to-browser-readablestream": "^2.0.6",
|
|
158
160
|
"multiformats": "^13.1.0",
|
|
159
161
|
"progress-events": "^1.0.0"
|
|
160
162
|
},
|
|
161
163
|
"devDependencies": {
|
|
162
|
-
"@helia/
|
|
163
|
-
"@helia/dag-
|
|
164
|
-
"@helia/json": "3.0.0-
|
|
165
|
-
"@helia/
|
|
164
|
+
"@helia/car": "3.0.0-a04e041",
|
|
165
|
+
"@helia/dag-cbor": "3.0.0-a04e041",
|
|
166
|
+
"@helia/dag-json": "3.0.0-a04e041",
|
|
167
|
+
"@helia/json": "3.0.0-a04e041",
|
|
168
|
+
"@helia/utils": "0.0.1-a04e041",
|
|
169
|
+
"@ipld/car": "^5.2.6",
|
|
166
170
|
"@libp2p/logger": "^4.0.5",
|
|
167
171
|
"@libp2p/peer-id-factory": "^4.0.5",
|
|
168
172
|
"@sgtpooki/file-type": "^1.0.1",
|
|
@@ -170,10 +174,12 @@
|
|
|
170
174
|
"aegir": "^42.2.2",
|
|
171
175
|
"blockstore-core": "^4.4.0",
|
|
172
176
|
"datastore-core": "^9.2.8",
|
|
173
|
-
"helia": "4.0.1-
|
|
177
|
+
"helia": "4.0.1-a04e041",
|
|
178
|
+
"ipns": "^9.0.0",
|
|
174
179
|
"it-last": "^3.0.4",
|
|
175
180
|
"it-to-buffer": "^4.0.5",
|
|
176
181
|
"magic-bytes.js": "^1.8.0",
|
|
182
|
+
"p-defer": "^4.0.0",
|
|
177
183
|
"sinon": "^17.0.1",
|
|
178
184
|
"sinon-ts": "^2.0.0",
|
|
179
185
|
"uint8arrays": "^5.0.1"
|
package/src/index.ts
CHANGED
|
@@ -320,6 +320,39 @@
|
|
|
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
|
+
*
|
|
323
356
|
* ## Comparison to fetch
|
|
324
357
|
*
|
|
325
358
|
* This module attempts to act as similarly to the `fetch()` API as possible.
|
|
@@ -449,6 +482,10 @@ import type { ProgressEvent, ProgressOptions } from 'progress-events'
|
|
|
449
482
|
*/
|
|
450
483
|
export type Resource = string | CID
|
|
451
484
|
|
|
485
|
+
export interface ResourceDetail {
|
|
486
|
+
resource: Resource
|
|
487
|
+
}
|
|
488
|
+
|
|
452
489
|
export interface CIDDetail {
|
|
453
490
|
cid: CID
|
|
454
491
|
path: string
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Takes a filename URL param and returns a string for use in a
|
|
3
|
+
* `Content-Disposition` header
|
|
4
|
+
*/
|
|
5
|
+
export function getContentDispositionFilename (filename: string): string {
|
|
6
|
+
const asciiOnly = replaceNonAsciiCharacters(filename)
|
|
7
|
+
|
|
8
|
+
if (asciiOnly === filename) {
|
|
9
|
+
return `filename="${filename}"`
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return `filename="${asciiOnly}"; filename*=UTF-8''${encodeURIComponent(filename)}`
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function replaceNonAsciiCharacters (filename: string): string {
|
|
16
|
+
// eslint-disable-next-line no-control-regex
|
|
17
|
+
return filename.replace(/[^\x00-\x7F]/g, '_')
|
|
18
|
+
}
|