@helia/verified-fetch 0.0.0-7c07e11 → 0.0.0-7c3ce21
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 +206 -130
- package/dist/src/verified-fetch.js.map +1 -1
- package/package.json +16 -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 +230 -135
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import { ipns as heliaIpns } from '@helia/ipns';
|
|
2
2
|
import { dnsJsonOverHttps } from '@helia/ipns/dns-resolvers';
|
|
3
3
|
import { unixfs as heliaUnixFs } from '@helia/unixfs';
|
|
4
|
-
import
|
|
5
|
-
import
|
|
4
|
+
import * as ipldDagCbor from '@ipld/dag-cbor';
|
|
5
|
+
import * as ipldDagJson from '@ipld/dag-json';
|
|
6
6
|
import { code as dagPbCode } from '@ipld/dag-pb';
|
|
7
7
|
import { code as jsonCode } from 'multiformats/codecs/json';
|
|
8
8
|
import { code as rawCode } from 'multiformats/codecs/raw';
|
|
9
9
|
import { identity } from 'multiformats/hashes/identity';
|
|
10
10
|
import { CustomProgressEvent } from 'progress-events';
|
|
11
11
|
import { dagCborToSafeJSON } from './utils/dag-cbor-to-safe-json.js';
|
|
12
|
+
import { getContentDispositionFilename } from './utils/get-content-disposition-filename.js';
|
|
12
13
|
import { getETag } from './utils/get-e-tag.js';
|
|
13
14
|
import { getStreamFromAsyncIterable } from './utils/get-stream-from-async-iterable.js';
|
|
14
15
|
import { parseResource } from './utils/parse-resource.js';
|
|
16
|
+
import { notAcceptableResponse, notSupportedResponse, okResponse } from './utils/responses.js';
|
|
17
|
+
import { selectOutputType, queryFormatToAcceptHeader } from './utils/select-output-type.js';
|
|
15
18
|
import { walkPath } from './utils/walk-path.js';
|
|
16
19
|
function convertOptions(options) {
|
|
17
20
|
if (options == null) {
|
|
@@ -26,26 +29,42 @@ function convertOptions(options) {
|
|
|
26
29
|
signal
|
|
27
30
|
};
|
|
28
31
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
32
|
+
/**
|
|
33
|
+
* These are Accept header values that will cause content type sniffing to be
|
|
34
|
+
* skipped and set to these values.
|
|
35
|
+
*/
|
|
36
|
+
const RAW_HEADERS = [
|
|
37
|
+
'application/vnd.ipld.raw',
|
|
38
|
+
'application/octet-stream'
|
|
39
|
+
];
|
|
40
|
+
/**
|
|
41
|
+
* if the user has specified an `Accept` header, and it's in our list of
|
|
42
|
+
* allowable "raw" format headers, use that instead of detecting the content
|
|
43
|
+
* type. This avoids the user from receiving something different when they
|
|
44
|
+
* signal that they want to `Accept` a specific mime type.
|
|
45
|
+
*/
|
|
46
|
+
function getOverridenRawContentType(headers) {
|
|
47
|
+
const acceptHeader = new Headers(headers).get('accept') ?? '';
|
|
48
|
+
// e.g. "Accept: text/html, application/xhtml+xml, application/xml;q=0.9, image/webp, */*;q=0.8"
|
|
49
|
+
const acceptHeaders = acceptHeader.split(',')
|
|
50
|
+
.map(s => s.split(';')[0])
|
|
51
|
+
.map(s => s.trim());
|
|
52
|
+
for (const mimeType of acceptHeaders) {
|
|
53
|
+
if (mimeType === '*/*') {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
if (RAW_HEADERS.includes(mimeType ?? '')) {
|
|
57
|
+
return mimeType;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
40
60
|
}
|
|
41
61
|
export class VerifiedFetch {
|
|
42
62
|
helia;
|
|
43
63
|
ipns;
|
|
44
64
|
unixfs;
|
|
45
|
-
pathWalker;
|
|
46
65
|
log;
|
|
47
66
|
contentTypeParser;
|
|
48
|
-
constructor({ helia, ipns, unixfs
|
|
67
|
+
constructor({ helia, ipns, unixfs }, init) {
|
|
49
68
|
this.helia = helia;
|
|
50
69
|
this.log = helia.logger.forComponent('helia:verified-fetch');
|
|
51
70
|
this.ipns = ipns ?? heliaIpns(helia, {
|
|
@@ -55,54 +74,110 @@ export class VerifiedFetch {
|
|
|
55
74
|
]
|
|
56
75
|
});
|
|
57
76
|
this.unixfs = unixfs ?? heliaUnixFs(helia);
|
|
58
|
-
this.pathWalker = pathWalker ?? walkPath;
|
|
59
77
|
this.contentTypeParser = init?.contentTypeParser;
|
|
60
78
|
this.log.trace('created VerifiedFetch instance');
|
|
61
79
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
80
|
+
/**
|
|
81
|
+
* Accepts an `ipns://...` URL as a string and returns a `Response` containing
|
|
82
|
+
* a raw IPNS record.
|
|
83
|
+
*/
|
|
84
|
+
async handleIPNSRecord(resource, opts) {
|
|
85
|
+
return notSupportedResponse('vnd.ipfs.ipns-record support is not implemented');
|
|
67
86
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
87
|
+
/**
|
|
88
|
+
* Accepts a `CID` and returns a `Response` with a body stream that is a CAR
|
|
89
|
+
* of the `DAG` referenced by the `CID`.
|
|
90
|
+
*/
|
|
91
|
+
async handleCar({ cid, path, options }) {
|
|
92
|
+
return notSupportedResponse('vnd.ipld.car support is not implemented');
|
|
73
93
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
options?.onProgress?.(new CustomProgressEvent('verified-fetch:request:end', { cid, path }));
|
|
84
|
-
return response;
|
|
94
|
+
/**
|
|
95
|
+
* Accepts a UnixFS `CID` and returns a `.tar` file containing the file or
|
|
96
|
+
* directory structure referenced by the `CID`.
|
|
97
|
+
*/
|
|
98
|
+
async handleTar({ cid, path, options }) {
|
|
99
|
+
if (cid.code !== dagPbCode) {
|
|
100
|
+
return notAcceptableResponse('only dag-pb CIDs can be returned in TAR files');
|
|
101
|
+
}
|
|
102
|
+
return notSupportedResponse('application/tar support is not implemented');
|
|
85
103
|
}
|
|
86
|
-
async
|
|
104
|
+
async handleJson({ cid, path, accept, options }) {
|
|
87
105
|
this.log.trace('fetching %c/%s', cid, path);
|
|
88
|
-
|
|
89
|
-
// return body as binary
|
|
90
|
-
const block = await this.helia.blockstore.get(cid);
|
|
106
|
+
const block = await this.helia.blockstore.get(cid, options);
|
|
91
107
|
let body;
|
|
92
|
-
|
|
93
|
-
|
|
108
|
+
if (accept === 'application/vnd.ipld.dag-cbor' || accept === 'application/cbor') {
|
|
109
|
+
try {
|
|
110
|
+
// if vnd.ipld.dag-cbor has been specified, convert to the format - note
|
|
111
|
+
// that this supports more data types than regular JSON, the content-type
|
|
112
|
+
// response header is set so the user knows to process it differently
|
|
113
|
+
const obj = ipldDagJson.decode(block);
|
|
114
|
+
body = ipldDagCbor.encode(obj);
|
|
115
|
+
}
|
|
116
|
+
catch (err) {
|
|
117
|
+
this.log.error('could not transform %c to application/vnd.ipld.dag-cbor', err);
|
|
118
|
+
return notAcceptableResponse();
|
|
119
|
+
}
|
|
94
120
|
}
|
|
95
|
-
|
|
96
|
-
|
|
121
|
+
else {
|
|
122
|
+
// skip decoding
|
|
97
123
|
body = block;
|
|
98
124
|
}
|
|
99
125
|
const response = okResponse(body);
|
|
100
|
-
response.headers.set('content-type',
|
|
101
|
-
options?.onProgress?.(new CustomProgressEvent('verified-fetch:request:end', { cid, path }));
|
|
126
|
+
response.headers.set('content-type', accept ?? 'application/json');
|
|
102
127
|
return response;
|
|
103
128
|
}
|
|
104
|
-
async
|
|
129
|
+
async handleDagCbor({ cid, path, accept, options }) {
|
|
105
130
|
this.log.trace('fetching %c/%s', cid, path);
|
|
131
|
+
const block = await this.helia.blockstore.get(cid, options);
|
|
132
|
+
let body;
|
|
133
|
+
if (accept === 'application/octet-stream' || accept === 'application/vnd.ipld.dag-cbor' || accept === 'application/cbor') {
|
|
134
|
+
// skip decoding
|
|
135
|
+
body = block;
|
|
136
|
+
}
|
|
137
|
+
else if (accept === 'application/vnd.ipld.dag-json') {
|
|
138
|
+
try {
|
|
139
|
+
// if vnd.ipld.dag-json has been specified, convert to the format - note
|
|
140
|
+
// that this supports more data types than regular JSON, the content-type
|
|
141
|
+
// response header is set so the user knows to process it differently
|
|
142
|
+
const obj = ipldDagCbor.decode(block);
|
|
143
|
+
body = ipldDagJson.encode(obj);
|
|
144
|
+
}
|
|
145
|
+
catch (err) {
|
|
146
|
+
this.log.error('could not transform %c to application/vnd.ipld.dag-json', err);
|
|
147
|
+
return notAcceptableResponse();
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
try {
|
|
152
|
+
body = dagCborToSafeJSON(block);
|
|
153
|
+
}
|
|
154
|
+
catch (err) {
|
|
155
|
+
if (accept === 'application/json') {
|
|
156
|
+
this.log('could not decode DAG-CBOR as JSON-safe, but the client sent "Accept: application/json"', err);
|
|
157
|
+
return notAcceptableResponse();
|
|
158
|
+
}
|
|
159
|
+
this.log('could not decode DAG-CBOR as JSON-safe, falling back to `application/octet-stream`', err);
|
|
160
|
+
body = block;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
const response = okResponse(body);
|
|
164
|
+
if (accept == null) {
|
|
165
|
+
accept = body instanceof Uint8Array ? 'application/octet-stream' : 'application/json';
|
|
166
|
+
}
|
|
167
|
+
response.headers.set('content-type', accept);
|
|
168
|
+
return response;
|
|
169
|
+
}
|
|
170
|
+
async handleDagPb({ cid, path, options }) {
|
|
171
|
+
let terminalElement;
|
|
172
|
+
let ipfsRoots;
|
|
173
|
+
try {
|
|
174
|
+
const pathDetails = await walkPath(this.helia.blockstore, `${cid.toString()}/${path}`, options);
|
|
175
|
+
ipfsRoots = pathDetails.ipfsRoots;
|
|
176
|
+
terminalElement = pathDetails.terminalElement;
|
|
177
|
+
}
|
|
178
|
+
catch (err) {
|
|
179
|
+
this.log.error('Error walking path %s', path, err);
|
|
180
|
+
}
|
|
106
181
|
let resolvedCID = terminalElement?.cid ?? cid;
|
|
107
182
|
let stat;
|
|
108
183
|
if (terminalElement?.type === 'directory') {
|
|
@@ -110,7 +185,6 @@ export class VerifiedFetch {
|
|
|
110
185
|
const rootFilePath = 'index.html';
|
|
111
186
|
try {
|
|
112
187
|
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
188
|
stat = await this.unixfs.stat(dirCid, {
|
|
115
189
|
path: rootFilePath,
|
|
116
190
|
signal: options?.signal,
|
|
@@ -129,7 +203,6 @@ export class VerifiedFetch {
|
|
|
129
203
|
options?.onProgress?.(new CustomProgressEvent('verified-fetch:request:end', { cid: dirCid, path: rootFilePath }));
|
|
130
204
|
}
|
|
131
205
|
}
|
|
132
|
-
options?.onProgress?.(new CustomProgressEvent('verified-fetch:request:start', { cid: resolvedCID, path: '' }));
|
|
133
206
|
const asyncIter = this.unixfs.cat(resolvedCID, {
|
|
134
207
|
signal: options?.signal,
|
|
135
208
|
onProgress: options?.onProgress
|
|
@@ -140,16 +213,24 @@ export class VerifiedFetch {
|
|
|
140
213
|
});
|
|
141
214
|
const response = okResponse(stream);
|
|
142
215
|
await this.setContentType(firstChunk, path, response);
|
|
143
|
-
|
|
216
|
+
if (ipfsRoots != null) {
|
|
217
|
+
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
|
|
218
|
+
}
|
|
144
219
|
return response;
|
|
145
220
|
}
|
|
146
221
|
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);
|
|
222
|
+
const result = await this.helia.blockstore.get(cid, options);
|
|
150
223
|
const response = okResponse(result);
|
|
151
|
-
|
|
152
|
-
|
|
224
|
+
// if the user has specified an `Accept` header that corresponds to a raw
|
|
225
|
+
// type, honour that header, so for example they don't request
|
|
226
|
+
// `application/vnd.ipld.raw` but get `application/octet-stream`
|
|
227
|
+
const overriddenContentType = getOverridenRawContentType(options?.headers);
|
|
228
|
+
if (overriddenContentType != null) {
|
|
229
|
+
response.headers.set('content-type', overriddenContentType);
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
await this.setContentType(result, path, response);
|
|
233
|
+
}
|
|
153
234
|
return response;
|
|
154
235
|
}
|
|
155
236
|
async setContentType(bytes, path, response) {
|
|
@@ -176,99 +257,94 @@ export class VerifiedFetch {
|
|
|
176
257
|
response.headers.set('content-type', contentType);
|
|
177
258
|
}
|
|
178
259
|
/**
|
|
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
|
|
260
|
+
* If the user has not specified an Accept header or format query string arg,
|
|
261
|
+
* use the CID codec to choose an appropriate handler for the block data.
|
|
210
262
|
*/
|
|
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
263
|
codecHandlers = {
|
|
222
264
|
[dagPbCode]: this.handleDagPb,
|
|
223
|
-
[
|
|
265
|
+
[ipldDagJson.code]: this.handleJson,
|
|
224
266
|
[jsonCode]: this.handleJson,
|
|
225
|
-
[
|
|
267
|
+
[ipldDagCbor.code]: this.handleDagCbor,
|
|
226
268
|
[rawCode]: this.handleRaw,
|
|
227
269
|
[identity.code]: this.handleRaw
|
|
228
270
|
};
|
|
229
271
|
async fetch(resource, opts) {
|
|
272
|
+
this.log('fetch %s', resource);
|
|
230
273
|
const options = convertOptions(opts);
|
|
231
|
-
|
|
232
|
-
|
|
274
|
+
options?.onProgress?.(new CustomProgressEvent('verified-fetch:request:start', { resource }));
|
|
275
|
+
// resolve the CID/path from the requested resource
|
|
276
|
+
const { path, query, cid } = await parseResource(resource, { ipns: this.ipns, logger: this.helia.logger }, options);
|
|
277
|
+
options?.onProgress?.(new CustomProgressEvent('verified-fetch:request:resolve', { cid, path }));
|
|
278
|
+
const requestHeaders = new Headers(options?.headers);
|
|
279
|
+
const incomingAcceptHeader = requestHeaders.get('accept');
|
|
280
|
+
if (incomingAcceptHeader != null) {
|
|
281
|
+
this.log('incoming accept header "%s"', incomingAcceptHeader);
|
|
282
|
+
}
|
|
283
|
+
const queryFormatMapping = queryFormatToAcceptHeader(query.format);
|
|
284
|
+
if (query.format != null) {
|
|
285
|
+
this.log('incoming query format "%s", mapped to %s', query.format, queryFormatMapping);
|
|
286
|
+
}
|
|
287
|
+
const acceptHeader = incomingAcceptHeader ?? queryFormatMapping;
|
|
288
|
+
const accept = selectOutputType(cid, acceptHeader);
|
|
289
|
+
this.log('output type %s', accept);
|
|
290
|
+
if (acceptHeader != null && accept == null) {
|
|
291
|
+
return notAcceptableResponse();
|
|
292
|
+
}
|
|
233
293
|
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
|
-
}
|
|
294
|
+
let reqFormat;
|
|
295
|
+
if (accept === 'application/vnd.ipfs.ipns-record') {
|
|
296
|
+
// the user requested a raw IPNS record
|
|
297
|
+
reqFormat = 'ipns-record';
|
|
298
|
+
response = await this.handleIPNSRecord(resource.toString(), options);
|
|
244
299
|
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
300
|
+
else if (accept === 'application/vnd.ipld.car') {
|
|
301
|
+
// the user requested a CAR file
|
|
302
|
+
reqFormat = 'car';
|
|
303
|
+
query.download = true;
|
|
304
|
+
query.filename = query.filename ?? `${cid.toString()}.car`;
|
|
305
|
+
response = await this.handleCar({ cid, path, options });
|
|
251
306
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
307
|
+
else if (accept === 'application/vnd.ipld.raw') {
|
|
308
|
+
// the user requested a raw block
|
|
309
|
+
reqFormat = 'raw';
|
|
310
|
+
query.download = true;
|
|
311
|
+
query.filename = query.filename ?? `${cid.toString()}.bin`;
|
|
312
|
+
response = await this.handleRaw({ cid, path, options });
|
|
255
313
|
}
|
|
256
|
-
if (
|
|
314
|
+
else if (accept === 'application/x-tar') {
|
|
315
|
+
// the user requested a TAR file
|
|
316
|
+
reqFormat = 'tar';
|
|
317
|
+
response = await this.handleTar({ cid, path, options });
|
|
318
|
+
}
|
|
319
|
+
else {
|
|
320
|
+
// derive the handler from the CID type
|
|
257
321
|
const codecHandler = this.codecHandlers[cid.code];
|
|
258
|
-
if (codecHandler
|
|
259
|
-
response = await codecHandler.call(this, { cid, path, options, terminalElement });
|
|
260
|
-
}
|
|
261
|
-
else {
|
|
322
|
+
if (codecHandler == null) {
|
|
262
323
|
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
324
|
}
|
|
325
|
+
response = await codecHandler.call(this, { cid, path, accept, options });
|
|
264
326
|
}
|
|
265
|
-
response.headers.set('etag', getETag({ cid, reqFormat
|
|
327
|
+
response.headers.set('etag', getETag({ cid, reqFormat, weak: false }));
|
|
266
328
|
response.headers.set('cache-control', 'public, max-age=29030400, immutable');
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
329
|
+
// https://specs.ipfs.tech/http-gateways/path-gateway/#x-ipfs-path-response-header
|
|
330
|
+
response.headers.set('X-Ipfs-Path', resource.toString());
|
|
331
|
+
// set Content-Disposition header
|
|
332
|
+
let contentDisposition;
|
|
333
|
+
// force download if requested
|
|
334
|
+
if (query.download === true) {
|
|
335
|
+
contentDisposition = 'attachment';
|
|
336
|
+
}
|
|
337
|
+
// override filename if requested
|
|
338
|
+
if (query.filename != null) {
|
|
339
|
+
if (contentDisposition == null) {
|
|
340
|
+
contentDisposition = 'inline';
|
|
341
|
+
}
|
|
342
|
+
contentDisposition = `${contentDisposition}; ${getContentDispositionFilename(query.filename)}`;
|
|
270
343
|
}
|
|
271
|
-
|
|
344
|
+
if (contentDisposition != null) {
|
|
345
|
+
response.headers.set('Content-Disposition', contentDisposition);
|
|
346
|
+
}
|
|
347
|
+
options?.onProgress?.(new CustomProgressEvent('verified-fetch:request:end', { cid, path }));
|
|
272
348
|
return response;
|
|
273
349
|
}
|
|
274
350
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verified-fetch.js","sourceRoot":"","sources":["../../src/verified-fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,SAAS,EAAa,MAAM,aAAa,CAAA;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CA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AQ,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-7c3ce21",
|
|
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,12 @@
|
|
|
141
141
|
"release": "aegir release"
|
|
142
142
|
},
|
|
143
143
|
"dependencies": {
|
|
144
|
-
"@helia/block-brokers": "2.0.1-
|
|
145
|
-
"@helia/http": "1.0.1-
|
|
146
|
-
"@helia/interface": "4.0.0-
|
|
147
|
-
"@helia/ipns": "6.0.0-
|
|
148
|
-
"@helia/routers": "1.0.0-
|
|
149
|
-
"@helia/unixfs": "3.0.0-
|
|
144
|
+
"@helia/block-brokers": "2.0.1-7c3ce21",
|
|
145
|
+
"@helia/http": "1.0.1-7c3ce21",
|
|
146
|
+
"@helia/interface": "4.0.0-7c3ce21",
|
|
147
|
+
"@helia/ipns": "6.0.0-7c3ce21",
|
|
148
|
+
"@helia/routers": "1.0.0-7c3ce21",
|
|
149
|
+
"@helia/unixfs": "3.0.0-7c3ce21",
|
|
150
150
|
"@ipld/dag-cbor": "^9.2.0",
|
|
151
151
|
"@ipld/dag-json": "^10.2.0",
|
|
152
152
|
"@ipld/dag-pb": "^4.1.0",
|
|
@@ -159,10 +159,12 @@
|
|
|
159
159
|
"progress-events": "^1.0.0"
|
|
160
160
|
},
|
|
161
161
|
"devDependencies": {
|
|
162
|
-
"@helia/
|
|
163
|
-
"@helia/dag-
|
|
164
|
-
"@helia/json": "3.0.0-
|
|
165
|
-
"@helia/
|
|
162
|
+
"@helia/car": "3.0.0-7c3ce21",
|
|
163
|
+
"@helia/dag-cbor": "3.0.0-7c3ce21",
|
|
164
|
+
"@helia/dag-json": "3.0.0-7c3ce21",
|
|
165
|
+
"@helia/json": "3.0.0-7c3ce21",
|
|
166
|
+
"@helia/utils": "0.0.1-7c3ce21",
|
|
167
|
+
"@ipld/car": "^5.2.6",
|
|
166
168
|
"@libp2p/logger": "^4.0.5",
|
|
167
169
|
"@libp2p/peer-id-factory": "^4.0.5",
|
|
168
170
|
"@sgtpooki/file-type": "^1.0.1",
|
|
@@ -170,10 +172,12 @@
|
|
|
170
172
|
"aegir": "^42.2.2",
|
|
171
173
|
"blockstore-core": "^4.4.0",
|
|
172
174
|
"datastore-core": "^9.2.8",
|
|
173
|
-
"helia": "4.0.1-
|
|
175
|
+
"helia": "4.0.1-7c3ce21",
|
|
176
|
+
"ipns": "^9.0.0",
|
|
174
177
|
"it-last": "^3.0.4",
|
|
175
178
|
"it-to-buffer": "^4.0.5",
|
|
176
179
|
"magic-bytes.js": "^1.8.0",
|
|
180
|
+
"p-defer": "^4.0.0",
|
|
177
181
|
"sinon": "^17.0.1",
|
|
178
182
|
"sinon-ts": "^2.0.0",
|
|
179
183
|
"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
|
+
}
|