@helia/verified-fetch 0.0.0-5c0c39c → 0.0.0-754c7af
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 +280 -44
- package/dist/index.min.js +4 -29
- package/dist/src/index.d.ts +297 -53
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +270 -49
- package/dist/src/index.js.map +1 -1
- package/dist/src/singleton.d.ts +3 -0
- package/dist/src/singleton.d.ts.map +1 -0
- package/dist/src/singleton.js +15 -0
- package/dist/src/singleton.js.map +1 -0
- package/dist/src/utils/dag-cbor-to-safe-json.d.ts +7 -0
- package/dist/src/utils/dag-cbor-to-safe-json.d.ts.map +1 -0
- package/dist/src/utils/dag-cbor-to-safe-json.js +37 -0
- package/dist/src/utils/dag-cbor-to-safe-json.js.map +1 -0
- package/dist/src/utils/get-stream-from-async-iterable.d.ts +10 -0
- package/dist/src/utils/get-stream-from-async-iterable.d.ts.map +1 -0
- package/dist/src/utils/{get-stream-and-content-type.js → get-stream-from-async-iterable.js} +10 -9
- package/dist/src/utils/get-stream-from-async-iterable.js.map +1 -0
- package/dist/src/verified-fetch.d.ts +5 -12
- package/dist/src/verified-fetch.d.ts.map +1 -1
- package/dist/src/verified-fetch.js +88 -60
- package/dist/src/verified-fetch.js.map +1 -1
- package/package.json +25 -18
- package/src/index.ts +303 -54
- package/src/singleton.ts +20 -0
- package/src/utils/dag-cbor-to-safe-json.ts +44 -0
- package/src/utils/{get-stream-and-content-type.ts → get-stream-from-async-iterable.ts} +9 -8
- package/src/verified-fetch.ts +99 -67
- package/dist/src/utils/get-content-type.d.ts +0 -11
- package/dist/src/utils/get-content-type.d.ts.map +0 -1
- package/dist/src/utils/get-content-type.js +0 -43
- package/dist/src/utils/get-content-type.js.map +0 -1
- package/dist/src/utils/get-stream-and-content-type.d.ts +0 -10
- package/dist/src/utils/get-stream-and-content-type.d.ts.map +0 -1
- package/dist/src/utils/get-stream-and-content-type.js.map +0 -1
- package/src/utils/get-content-type.ts +0 -55
package/dist/src/index.js
CHANGED
|
@@ -1,57 +1,49 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @packageDocumentation
|
|
3
3
|
*
|
|
4
|
-
* `@helia/verified-fetch`
|
|
4
|
+
* `@helia/verified-fetch` provides a [fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)-like API for retrieving content from the [IPFS](https://ipfs.tech/) network.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
6
|
+
* All content is retrieved in a [trustless manner](https://www.techopedia.com/definition/trustless), and the integrity of all bytes are verified by comparing hashes of the data. By default, CIDs are retrieved over HTTP from [trustless gateways](https://specs.ipfs.tech/http-gateways/trustless-gateway/).
|
|
7
7
|
*
|
|
8
|
-
*
|
|
8
|
+
* This is a marked improvement over `fetch` which offers no such protections and is vulnerable to all sorts of attacks like [Content Spoofing](https://owasp.org/www-community/attacks/Content_Spoofing), [DNS Hijacking](https://en.wikipedia.org/wiki/DNS_hijacking), etc.
|
|
9
|
+
*
|
|
10
|
+
* A `verifiedFetch` function is exported to get up and running quickly, and a `createVerifiedFetch` function is also available that allows customizing the underlying [Helia](https://helia.io/) node for complete control over how content is retrieved.
|
|
11
|
+
*
|
|
12
|
+
* Browser-cache-friendly [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) objects are returned which should be instantly familiar to web developers.
|
|
9
13
|
*
|
|
10
14
|
* You may use any supported resource argument to fetch content:
|
|
11
15
|
*
|
|
12
|
-
* - CID instance
|
|
16
|
+
* - [CID](https://multiformats.github.io/js-multiformats/classes/cid.CID.html) instance
|
|
13
17
|
* - IPFS URL
|
|
14
18
|
* - IPNS URL
|
|
15
19
|
*
|
|
16
|
-
* @example
|
|
20
|
+
* @example Getting started
|
|
17
21
|
*
|
|
18
22
|
* ```typescript
|
|
19
|
-
* import {
|
|
20
|
-
*
|
|
21
|
-
* const fetch = await createVerifiedFetch({
|
|
22
|
-
* gateways: ['https://mygateway.example.net', 'https://trustless-gateway.link']
|
|
23
|
-
*})
|
|
23
|
+
* import { verifiedFetch } from '@helia/verified-fetch'
|
|
24
24
|
*
|
|
25
|
-
* const resp = await
|
|
25
|
+
* const resp = await verifiedFetch('ipfs://bafy...')
|
|
26
26
|
*
|
|
27
27
|
* const json = await resp.json()
|
|
28
28
|
*```
|
|
29
29
|
*
|
|
30
|
-
*
|
|
31
30
|
* @example Using a CID instance to fetch JSON
|
|
32
31
|
*
|
|
33
32
|
* ```typescript
|
|
34
|
-
* import {
|
|
33
|
+
* import { verifiedFetch } from '@helia/verified-fetch'
|
|
35
34
|
* import { CID } from 'multiformats/cid'
|
|
36
35
|
*
|
|
37
|
-
* const
|
|
38
|
-
*
|
|
39
|
-
* })
|
|
40
|
-
*
|
|
41
|
-
* const cid = CID.parse('bafyFoo') // some image file
|
|
42
|
-
* const response = await fetch(cid)
|
|
36
|
+
* const cid = CID.parse('bafyFoo') // some json file
|
|
37
|
+
* const response = await verifiedFetch(cid)
|
|
43
38
|
* const json = await response.json()
|
|
44
39
|
* ```
|
|
45
40
|
*
|
|
46
41
|
* @example Using IPFS protocol to fetch an image
|
|
47
42
|
*
|
|
48
43
|
* ```typescript
|
|
49
|
-
* import {
|
|
44
|
+
* import { verifiedFetch } from '@helia/verified-fetch'
|
|
50
45
|
*
|
|
51
|
-
* const
|
|
52
|
-
* gateways: ['https://mygateway.example.net', 'https://trustless-gateway.link']
|
|
53
|
-
* })
|
|
54
|
-
* const response = await fetch('ipfs://bafyFoo') // CID for some image file
|
|
46
|
+
* const response = await verifiedFetch('ipfs://bafyFoo') // CID for some image file
|
|
55
47
|
* const blob = await response.blob()
|
|
56
48
|
* const image = document.createElement('img')
|
|
57
49
|
* image.src = URL.createObjectURL(blob)
|
|
@@ -61,22 +53,42 @@
|
|
|
61
53
|
* @example Using IPNS protocol to stream a big file
|
|
62
54
|
*
|
|
63
55
|
* ```typescript
|
|
56
|
+
* import { verifiedFetch } from '@helia/verified-fetch'
|
|
57
|
+
*
|
|
58
|
+
* const response = await verifiedFetch('ipns://mydomain.com/path/to/very-long-file.log')
|
|
59
|
+
* const bigFileStreamReader = await response.body.getReader()
|
|
60
|
+
* ```
|
|
61
|
+
*
|
|
62
|
+
* ## Configuration
|
|
63
|
+
*
|
|
64
|
+
* ### Custom HTTP gateways and routers
|
|
65
|
+
*
|
|
66
|
+
* Out of the box `@helia/verified-fetch` uses a default set of [trustless gateways](https://specs.ipfs.tech/http-gateways/trustless-gateway/) for fetching blocks and [HTTP delegated routers](https://specs.ipfs.tech/routing/http-routing-v1/) for performing routing tasks - looking up peers, resolving/publishing [IPNS](https://docs.ipfs.tech/concepts/ipns/) names, etc.
|
|
67
|
+
*
|
|
68
|
+
* It's possible to override these by passing `gateways` and `routers` keys to the `createVerifiedFetch` function:
|
|
69
|
+
*
|
|
70
|
+
* @example Configuring gateways and routers
|
|
71
|
+
*
|
|
72
|
+
* ```typescript
|
|
64
73
|
* import { createVerifiedFetch } from '@helia/verified-fetch'
|
|
65
74
|
*
|
|
66
75
|
* const fetch = await createVerifiedFetch({
|
|
67
|
-
* gateways: ['https://
|
|
76
|
+
* gateways: ['https://trustless-gateway.link'],
|
|
77
|
+
* routers: ['http://delegated-ipfs.dev']
|
|
68
78
|
* })
|
|
69
|
-
* const response = await fetch('ipns://mydomain.com/path/to/very-long-file.log')
|
|
70
|
-
* const bigFileStreamReader = await response.body.getReader()
|
|
71
|
-
* ```
|
|
72
79
|
*
|
|
73
|
-
*
|
|
80
|
+
* const resp = await fetch('ipfs://bafy...')
|
|
74
81
|
*
|
|
75
|
-
*
|
|
82
|
+
* const json = await resp.json()
|
|
83
|
+
*```
|
|
76
84
|
*
|
|
77
|
-
*
|
|
85
|
+
* ### Usage with customized Helia
|
|
78
86
|
*
|
|
79
|
-
*
|
|
87
|
+
* For full control of how `@helia/verified-fetch` fetches content from the distributed web you can pass a preconfigured Helia node to `createVerifiedFetch`.
|
|
88
|
+
*
|
|
89
|
+
* The [helia](https://www.npmjs.com/package/helia) module is configured with a libp2p node that is suited for decentralized applications, alternatively [@helia/http](https://www.npmjs.com/package/@helia/http) is available which uses HTTP gateways for all network operations.
|
|
90
|
+
*
|
|
91
|
+
* You can see variations of Helia and js-libp2p configuration options at https://helia.io/interfaces/helia.index.HeliaInit.html.
|
|
80
92
|
*
|
|
81
93
|
* ```typescript
|
|
82
94
|
* import { trustlessGateway } from '@helia/block-brokers'
|
|
@@ -100,28 +112,236 @@
|
|
|
100
112
|
* const json = await resp.json()
|
|
101
113
|
* ```
|
|
102
114
|
*
|
|
103
|
-
* ###
|
|
115
|
+
* ### Custom content-type parsing
|
|
116
|
+
*
|
|
117
|
+
* By default, if the response can be parsed as JSON, `@helia/verified-fetch` sets the `Content-Type` header as `application/json`, otherwise it sets it as `application/octet-stream` - this is because the `.json()`, `.text()`, `.blob()`, and `.arrayBuffer()` methods will usually work as expected without a detailed content type.
|
|
118
|
+
*
|
|
119
|
+
* If you require an accurate content-type you can provide a `contentTypeParser` function as an option to `createVerifiedFetch` to handle parsing the content type.
|
|
120
|
+
*
|
|
121
|
+
* The function you provide will be called with the first chunk of bytes from the file and should return a string or a promise of a string.
|
|
122
|
+
*
|
|
123
|
+
* @example Customizing content-type parsing
|
|
124
|
+
*
|
|
125
|
+
* ```typescript
|
|
126
|
+
* import { createVerifiedFetch } from '@helia/verified-fetch'
|
|
127
|
+
* import { fileTypeFromBuffer } from '@sgtpooki/file-type'
|
|
128
|
+
*
|
|
129
|
+
* const fetch = await createVerifiedFetch({
|
|
130
|
+
* gateways: ['https://trustless-gateway.link'],
|
|
131
|
+
* routers: ['http://delegated-ipfs.dev']
|
|
132
|
+
* }, {
|
|
133
|
+
* contentTypeParser: async (bytes) => {
|
|
134
|
+
* // call to some magic-byte recognition library like magic-bytes, file-type, or your own custom byte recognition
|
|
135
|
+
* const result = await fileTypeFromBuffer(bytes)
|
|
136
|
+
* return result?.mime
|
|
137
|
+
* }
|
|
138
|
+
* })
|
|
139
|
+
* ```
|
|
140
|
+
*
|
|
141
|
+
* ### IPLD codec handling
|
|
142
|
+
*
|
|
143
|
+
* IPFS supports several data formats (typically referred to as codecs) which are included in the CID. `@helia/verified-fetch` attempts to abstract away some of the details for easier consumption.
|
|
144
|
+
*
|
|
145
|
+
* #### DAG-PB
|
|
146
|
+
*
|
|
147
|
+
* [DAG-PB](https://ipld.io/docs/codecs/known/dag-pb/) is the codec we are most likely to encounter, it is what [UnixFS](https://github.com/ipfs/specs/blob/main/UNIXFS.md) uses under the hood.
|
|
148
|
+
*
|
|
149
|
+
* ##### Using the DAG-PB codec as a Blob
|
|
150
|
+
*
|
|
151
|
+
* ```typescript
|
|
152
|
+
* import { verifiedFetch } from '@helia/verified-fetch'
|
|
153
|
+
*
|
|
154
|
+
* const res = await verifiedFetch('ipfs://Qmfoo')
|
|
155
|
+
* const blob = await res.blob()
|
|
156
|
+
*
|
|
157
|
+
* console.info(blob) // Blob { size: x, type: 'application/octet-stream' }
|
|
158
|
+
* ```
|
|
159
|
+
*
|
|
160
|
+
* ##### Using the DAG-PB codec as an ArrayBuffer
|
|
161
|
+
*
|
|
162
|
+
* ```typescript
|
|
163
|
+
* import { verifiedFetch } from '@helia/verified-fetch'
|
|
164
|
+
*
|
|
165
|
+
* const res = await verifiedFetch('ipfs://Qmfoo')
|
|
166
|
+
* const buf = await res.arrayBuffer()
|
|
167
|
+
*
|
|
168
|
+
* console.info(buf) // ArrayBuffer { [Uint8Contents]: < ... >, byteLength: x }
|
|
169
|
+
* ```
|
|
170
|
+
*
|
|
171
|
+
* ##### Using the DAG-PB codec as a stream
|
|
172
|
+
*
|
|
173
|
+
* ```typescript
|
|
174
|
+
* import { verifiedFetch } from '@helia/verified-fetch'
|
|
175
|
+
*
|
|
176
|
+
* const res = await verifiedFetch('ipfs://Qmfoo')
|
|
177
|
+
* const reader = res.body?.getReader()
|
|
178
|
+
*
|
|
179
|
+
* while (true) {
|
|
180
|
+
* const next = await reader.read()
|
|
181
|
+
*
|
|
182
|
+
* if (next?.done === true) {
|
|
183
|
+
* break
|
|
184
|
+
* }
|
|
185
|
+
*
|
|
186
|
+
* if (next?.value != null) {
|
|
187
|
+
* console.info(next.value) // Uint8Array(x) [ ... ]
|
|
188
|
+
* }
|
|
189
|
+
* }
|
|
190
|
+
* ```
|
|
191
|
+
*
|
|
192
|
+
* ##### Content-Type
|
|
193
|
+
*
|
|
194
|
+
* When fetching `DAG-PB` data, the content type will be set to `application/octet-stream` unless a custom content-type parser is configured.
|
|
195
|
+
*
|
|
196
|
+
* #### JSON
|
|
197
|
+
*
|
|
198
|
+
* The JSON codec is a very simple codec, a block parseable with this codec is a JSON string encoded into a `Uint8Array`.
|
|
199
|
+
*
|
|
200
|
+
* ##### Using the JSON codec
|
|
201
|
+
*
|
|
202
|
+
* ```typescript
|
|
203
|
+
* import * as json from 'multiformats/codecs/json'
|
|
204
|
+
*
|
|
205
|
+
* const block = new TextEncoder().encode('{ "hello": "world" }')
|
|
206
|
+
* const obj = json.decode(block)
|
|
207
|
+
*
|
|
208
|
+
* console.info(obj) // { hello: 'world' }
|
|
209
|
+
* ```
|
|
210
|
+
*
|
|
211
|
+
* ##### Content-Type
|
|
212
|
+
*
|
|
213
|
+
* When the `JSON` codec is encountered, the `Content-Type` header of the response will be set to `application/json`.
|
|
214
|
+
*
|
|
215
|
+
* ### DAG-JSON
|
|
216
|
+
*
|
|
217
|
+
* [DAG-JSON](https://ipld.io/docs/codecs/known/dag-json/) expands on the `JSON` codec, adding the ability to contain [CID](https://docs.ipfs.tech/concepts/content-addressing/)s which act as links to other blocks, and byte arrays.
|
|
218
|
+
*
|
|
219
|
+
* `CID`s and byte arrays are represented using special object structures with a single `"/"` property.
|
|
220
|
+
*
|
|
221
|
+
* Using `DAG-JSON` has two important caveats:
|
|
222
|
+
*
|
|
223
|
+
* 1. Your `JSON` structure cannot contain an object with only a `"/"` property, as it will be interpreted as a special type.
|
|
224
|
+
* 2. Since `JSON` has no technical limit on number sizes, `DAG-JSON` also allows numbers larger than `Number.MAX_SAFE_INTEGER`. JavaScript requires use of `BigInt`s to represent numbers larger than this, and `JSON.parse` does not support them, so precision will be lost.
|
|
225
|
+
*
|
|
226
|
+
* Otherwise this codec follows the same rules as the `JSON` codec.
|
|
227
|
+
*
|
|
228
|
+
* ##### Using the DAG-JSON codec
|
|
229
|
+
*
|
|
230
|
+
* ```typescript
|
|
231
|
+
* import * as dagJson from '@ipld/dag-json'
|
|
232
|
+
*
|
|
233
|
+
* const block = new TextEncoder().encode(`{
|
|
234
|
+
* "hello": "world",
|
|
235
|
+
* "cid": {
|
|
236
|
+
* "/": "baeaaac3imvwgy3zao5xxe3de"
|
|
237
|
+
* },
|
|
238
|
+
* "buf": {
|
|
239
|
+
* "/": {
|
|
240
|
+
* "bytes": "AAECAwQ"
|
|
241
|
+
* }
|
|
242
|
+
* }
|
|
243
|
+
* }`)
|
|
244
|
+
*
|
|
245
|
+
* const obj = dagJson.decode(block)
|
|
246
|
+
*
|
|
247
|
+
* console.info(obj)
|
|
248
|
+
* // {
|
|
249
|
+
* // hello: 'world',
|
|
250
|
+
* // cid: CID(baeaaac3imvwgy3zao5xxe3de),
|
|
251
|
+
* // buf: Uint8Array(5) [ 0, 1, 2, 3, 4 ]
|
|
252
|
+
* // }
|
|
253
|
+
* ```
|
|
254
|
+
*
|
|
255
|
+
* ##### Content-Type
|
|
256
|
+
*
|
|
257
|
+
* When the `DAG-JSON` codec is encountered in the requested CID, the `Content-Type` header of the response will be set to `application/json`.
|
|
258
|
+
*
|
|
259
|
+
* `DAG-JSON` data can be parsed from the response by using the `.json()` function, which will return `CID`s/byte arrays as plain `{ "/": ... }` objects:
|
|
260
|
+
*
|
|
261
|
+
* ```typescript
|
|
262
|
+
* import { verifiedFetch } from '@helia/verified-fetch'
|
|
263
|
+
* import * as dagJson from '@ipld/dag-json'
|
|
264
|
+
*
|
|
265
|
+
* const res = await verifiedFetch('ipfs://bafyDAGJSON')
|
|
266
|
+
*
|
|
267
|
+
* // either:
|
|
268
|
+
* const obj = await res.json()
|
|
269
|
+
* console.info(obj.cid) // { "/": "baeaaac3imvwgy3zao5xxe3de" }
|
|
270
|
+
* console.info(obj.buf) // { "/": { "bytes": "AAECAwQ" } }
|
|
271
|
+
* ```
|
|
272
|
+
*
|
|
273
|
+
* Alternatively, it can be decoded using the `@ipld/dag-json` module and the `.arrayBuffer()` method, in which case you will get `CID` objects and `Uint8Array`s:
|
|
274
|
+
*
|
|
275
|
+
*```typescript
|
|
276
|
+
* import { verifiedFetch } from '@helia/verified-fetch'
|
|
277
|
+
* import * as dagJson from '@ipld/dag-json'
|
|
278
|
+
*
|
|
279
|
+
* const res = await verifiedFetch('ipfs://bafyDAGJSON')
|
|
280
|
+
*
|
|
281
|
+
* // or:
|
|
282
|
+
* const obj = dagJson.decode(await res.arrayBuffer())
|
|
283
|
+
* console.info(obj.cid) // CID(baeaaac3imvwgy3zao5xxe3de)
|
|
284
|
+
* console.info(obj.buf) // Uint8Array(5) [ 0, 1, 2, 3, 4 ]
|
|
285
|
+
* ```
|
|
286
|
+
*
|
|
287
|
+
* #### DAG-CBOR
|
|
288
|
+
*
|
|
289
|
+
* [DAG-CBOR](https://ipld.io/docs/codecs/known/dag-cbor/) uses the [Concise Binary Object Representation](https://cbor.io/) format for serialization instead of JSON.
|
|
290
|
+
*
|
|
291
|
+
* This supports more datatypes in a safer way than JSON and is smaller on the wire to boot so is usually preferable to JSON or DAG-JSON.
|
|
292
|
+
*
|
|
293
|
+
* ##### Content-Type
|
|
294
|
+
*
|
|
295
|
+
* Not all data types supported by `DAG-CBOR` can be successfully turned into JSON and back into the same binary form.
|
|
296
|
+
*
|
|
297
|
+
* When a decoded block can be round-tripped to JSON, the `Content-Type` will be set to `application/json`. In this case the `.json()` method on the `Response` object can be used to obtain an object representation of the response.
|
|
298
|
+
*
|
|
299
|
+
* When it cannot, the `Content-Type` will be `application/octet-stream` - in this case the `@ipld/dag-json` module must be used to deserialize the return value from `.arrayBuffer()`.
|
|
300
|
+
*
|
|
301
|
+
* ##### Detecting JSON-safe DAG-CBOR
|
|
302
|
+
*
|
|
303
|
+
* If the `Content-Type` header of the response is `application/json`, the `.json()` method may be used to access the response body in object form, otherwise the `.arrayBuffer()` method must be used to decode the raw bytes using the `@ipld/dag-cbor` module.
|
|
304
|
+
*
|
|
305
|
+
* ```typescript
|
|
306
|
+
* import { verifiedFetch } from '@helia/verified-fetch'
|
|
307
|
+
* import * as dagCbor from '@ipld/dag-cbor'
|
|
308
|
+
*
|
|
309
|
+
* const res = await verifiedFetch('ipfs://bafyDagCborCID')
|
|
310
|
+
* let obj
|
|
311
|
+
*
|
|
312
|
+
* if (res.headers.get('Content-Type') === 'application/json') {
|
|
313
|
+
* // DAG-CBOR data can be safely decoded as JSON
|
|
314
|
+
* obj = await res.json()
|
|
315
|
+
* } else {
|
|
316
|
+
* // response contains non-JSON friendly data types
|
|
317
|
+
* obj = dagCbor.decode(await res.arrayBuffer())
|
|
318
|
+
* }
|
|
319
|
+
*
|
|
320
|
+
* console.info(obj) // ...
|
|
321
|
+
* ```
|
|
322
|
+
*
|
|
323
|
+
* ## Comparison to fetch
|
|
104
324
|
*
|
|
105
|
-
*
|
|
325
|
+
* This module attempts to act as similarly to the `fetch()` API as possible.
|
|
106
326
|
*
|
|
107
327
|
* [The `fetch()` API](https://developer.mozilla.org/en-US/docs/Web/API/fetch) takes two parameters:
|
|
108
328
|
*
|
|
109
329
|
* 1. A [resource](https://developer.mozilla.org/en-US/docs/Web/API/fetch#resource)
|
|
110
330
|
* 2. An [options object](https://developer.mozilla.org/en-US/docs/Web/API/fetch#options)
|
|
111
331
|
*
|
|
112
|
-
*
|
|
332
|
+
* ### Resource argument
|
|
113
333
|
*
|
|
114
|
-
* This library
|
|
334
|
+
* This library supports the following methods of fetching web3 content from IPFS:
|
|
115
335
|
*
|
|
116
336
|
* 1. IPFS protocol: `ipfs://<cidv0>` & `ipfs://<cidv0>`
|
|
117
337
|
* 2. IPNS protocol: `ipns://<peerId>` & `ipns://<publicKey>` & `ipns://<hostUri_Supporting_DnsLink_TxtRecords>`
|
|
118
338
|
* 3. CID instances: An actual CID instance `CID.parse('bafy...')`
|
|
119
339
|
*
|
|
120
|
-
* As well as support for pathing & params for
|
|
340
|
+
* As well as support for pathing & params for items 1 & 2 above according to [IPFS - Path Gateway Specification](https://specs.ipfs.tech/http-gateways/path-gateway) & [IPFS - Trustless Gateway Specification](https://specs.ipfs.tech/http-gateways/trustless-gateway/). Further refinement of those specifications specifically for web-based scenarios can be found in the [Web Pathing Specification IPIP](https://github.com/ipfs/specs/pull/453).
|
|
121
341
|
*
|
|
122
|
-
* If you pass a CID instance,
|
|
342
|
+
* If you pass a CID instance, it assumes you want the content for that specific CID only, and does not support pathing or params for that CID.
|
|
123
343
|
*
|
|
124
|
-
*
|
|
344
|
+
* ### Options argument
|
|
125
345
|
*
|
|
126
346
|
* This library does not plan to support the exact Fetch API options object, as some of the arguments don't make sense. Instead, it will only support options necessary to meet [IPFS specs](https://specs.ipfs.tech/) related to specifying the resultant shape of desired content.
|
|
127
347
|
*
|
|
@@ -146,7 +366,6 @@
|
|
|
146
366
|
* 5. `body` - An object that specifies the body of the request. Best effort to adhere to the [Fetch API body](https://developer.mozilla.org/en-US/docs/Web/API/fetch#body) parameter.
|
|
147
367
|
* 6. `cache` - Will basically act as `force-cache` for the request. Best effort to adhere to the [Fetch API cache](https://developer.mozilla.org/en-US/docs/Web/API/fetch#cache) parameter.
|
|
148
368
|
*
|
|
149
|
-
*
|
|
150
369
|
* Non-Fetch API options that will be supported:
|
|
151
370
|
*
|
|
152
371
|
* 1. `onProgress` - Similar to Helia `onProgress` options, this will be a function that will be called with a progress event. Supported progress events are:
|
|
@@ -167,7 +386,7 @@
|
|
|
167
386
|
* 4. [IPIP-0328: JSON and CBOR Response Formats on HTTP Gateways](https://specs.ipfs.tech/ipips/ipip-0328/)
|
|
168
387
|
* 5. [IPIP-0288: TAR Response Format on HTTP Gateways](https://specs.ipfs.tech/ipips/ipip-0288/)
|
|
169
388
|
*
|
|
170
|
-
*
|
|
389
|
+
* ### Response types
|
|
171
390
|
*
|
|
172
391
|
* This library's purpose is to return reasonably representable content from IPFS. In other words, fetching content is intended for leaf-node content -- such as images/videos/audio & other assets, or other IPLD content (with link) -- that can be represented by https://developer.mozilla.org/en-US/docs/Web/API/Response#instance_methods. The content type you receive back will depend upon the CID you request as well as the `Accept` header value you provide.
|
|
173
392
|
*
|
|
@@ -175,7 +394,7 @@
|
|
|
175
394
|
*
|
|
176
395
|
* If your content doesn't have a mime-type or an [IPFS spec](https://specs.ipfs.tech), this library will not support it, but you can use the [`helia`](https://github.com/ipfs/helia) library directly for those use cases. See [Unsupported response types](#unsupported-response-types) for more information.
|
|
177
396
|
*
|
|
178
|
-
*
|
|
397
|
+
* #### Handling response types
|
|
179
398
|
*
|
|
180
399
|
* For handling responses we want to follow conventions/abstractions from Fetch API where possible:
|
|
181
400
|
*
|
|
@@ -184,12 +403,12 @@
|
|
|
184
403
|
* - For plain text in utf-8, you would call `.text()`
|
|
185
404
|
* - For streaming response data, use something like `response.body.getReader()` to get a [`ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/Streams_API/Using_readable_streams#consuming_a_fetch_as_a_stream).
|
|
186
405
|
*
|
|
187
|
-
*
|
|
406
|
+
* #### Unsupported response types
|
|
188
407
|
*
|
|
189
408
|
* * Returning IPLD nodes or DAGs as JS objects is not supported, as there is no currently well-defined structure for representing this data in an [HTTP Response](https://developer.mozilla.org/en-US/docs/Web/API/Response). Instead, users should request `aplication/vnd.ipld.car` or use the [`helia`](https://github.com/ipfs/helia) library directly for this use case.
|
|
190
409
|
* * Others? Open an issue or PR!
|
|
191
410
|
*
|
|
192
|
-
*
|
|
411
|
+
* ### Response headers
|
|
193
412
|
*
|
|
194
413
|
* This library will set the [HTTP Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) headers to the appropriate values for the content type according to the appropriate [IPFS Specifications](https://specs.ipfs.tech/).
|
|
195
414
|
*
|
|
@@ -199,13 +418,13 @@
|
|
|
199
418
|
* * https://specs.ipfs.tech/http-gateways/trustless-gateway/#response-headers
|
|
200
419
|
* * https://specs.ipfs.tech/http-gateways/subdomain-gateway/#response-headers
|
|
201
420
|
*
|
|
202
|
-
*
|
|
421
|
+
* ### Possible Scenarios that could cause confusion
|
|
203
422
|
*
|
|
204
|
-
*
|
|
423
|
+
* #### Attempting to fetch the CID for content that does not make sense
|
|
205
424
|
*
|
|
206
425
|
* If you request `bafybeiaysi4s6lnjev27ln5icwm6tueaw2vdykrtjkwiphwekaywqhcjze`, which points to the root of the en.wikipedia.org mirror, a response object does not make sense.
|
|
207
426
|
*
|
|
208
|
-
*
|
|
427
|
+
* ### Errors
|
|
209
428
|
*
|
|
210
429
|
* Known Errors that can be thrown:
|
|
211
430
|
*
|
|
@@ -221,7 +440,8 @@ import { VerifiedFetch as VerifiedFetchClass } from './verified-fetch.js';
|
|
|
221
440
|
/**
|
|
222
441
|
* Create and return a Helia node
|
|
223
442
|
*/
|
|
224
|
-
export async function createVerifiedFetch(init) {
|
|
443
|
+
export async function createVerifiedFetch(init, options) {
|
|
444
|
+
const contentTypeParser = options?.contentTypeParser;
|
|
225
445
|
if (!isHelia(init)) {
|
|
226
446
|
init = await createHeliaHTTP({
|
|
227
447
|
blockBrokers: [
|
|
@@ -232,7 +452,7 @@ export async function createVerifiedFetch(init) {
|
|
|
232
452
|
routers: (init?.routers ?? ['https://delegated-ipfs.dev']).map((routerUrl) => delegatedHTTPRouting(routerUrl))
|
|
233
453
|
});
|
|
234
454
|
}
|
|
235
|
-
const verifiedFetchInstance = new VerifiedFetchClass({ helia: init });
|
|
455
|
+
const verifiedFetchInstance = new VerifiedFetchClass({ helia: init }, { contentTypeParser });
|
|
236
456
|
async function verifiedFetch(resource, options) {
|
|
237
457
|
return verifiedFetchInstance.fetch(resource, options);
|
|
238
458
|
}
|
|
@@ -240,6 +460,7 @@ export async function createVerifiedFetch(init) {
|
|
|
240
460
|
verifiedFetch.start = verifiedFetchInstance.start.bind(verifiedFetchInstance);
|
|
241
461
|
return verifiedFetch;
|
|
242
462
|
}
|
|
463
|
+
export { verifiedFetch } from './singleton.js';
|
|
243
464
|
function isHelia(obj) {
|
|
244
465
|
// test for the presence of known Helia properties, return a boolean value
|
|
245
466
|
return obj?.blockstore != null &&
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkbG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,EAAE,aAAa,IAAI,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAmFzE;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAE,IAAsC,EAAE,OAAoC;IACrH,MAAM,iBAAiB,GAAkC,OAAO,EAAE,iBAAiB,CAAA;IAE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[],"mappings":"AACA,OAAO,KAAK,EAAY,aAAa,EAAqB,MAAM,YAAY,CAAA;AAI5E,eAAO,MAAM,aAAa,EAAE,aAM3B,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createVerifiedFetch } from './index.js';
|
|
2
|
+
let impl;
|
|
3
|
+
export const verifiedFetch = async function verifiedFetch(resource, options) {
|
|
4
|
+
if (impl == null) {
|
|
5
|
+
impl = await createVerifiedFetch();
|
|
6
|
+
}
|
|
7
|
+
return impl(resource, options);
|
|
8
|
+
};
|
|
9
|
+
verifiedFetch.start = async function () {
|
|
10
|
+
await impl?.start();
|
|
11
|
+
};
|
|
12
|
+
verifiedFetch.stop = async function () {
|
|
13
|
+
await impl?.stop();
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=singleton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"singleton.js","sourceRoot":"","sources":["../../src/singleton.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAGhD,IAAI,IAA+B,CAAA;AAEnC,MAAM,CAAC,MAAM,aAAa,GAAkB,KAAK,UAAU,aAAa,CAAE,QAAkB,EAAE,OAA2B;IACvH,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;QACjB,IAAI,GAAG,MAAM,mBAAmB,EAAE,CAAA;IACpC,CAAC;IAED,OAAO,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;AAChC,CAAC,CAAA;AAED,aAAa,CAAC,KAAK,GAAG,KAAK;IACzB,MAAM,IAAI,EAAE,KAAK,EAAE,CAAA;AACrB,CAAC,CAAA;AAED,aAAa,CAAC,IAAI,GAAG,KAAK;IACxB,MAAM,IAAI,EAAE,IAAI,EAAE,CAAA;AACpB,CAAC,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Take a `DAG-CBOR` encoded `Uint8Array`, deserialize it as an object and
|
|
3
|
+
* re-serialize it in a form that can be passed to `JSON.serialize` and then
|
|
4
|
+
* `JSON.parse` without losing any data.
|
|
5
|
+
*/
|
|
6
|
+
export declare function dagCborToSafeJSON(buf: Uint8Array): string;
|
|
7
|
+
//# sourceMappingURL=dag-cbor-to-safe-json.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dag-cbor-to-safe-json.d.ts","sourceRoot":"","sources":["../../../src/utils/dag-cbor-to-safe-json.ts"],"names":[],"mappings":"AAgBA;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAE,GAAG,EAAE,UAAU,GAAG,MAAM,CAsB1D"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { decode } from 'cborg';
|
|
2
|
+
import { encode } from 'cborg/json';
|
|
3
|
+
import { CID } from 'multiformats/cid';
|
|
4
|
+
// https://github.com/ipfs/go-ipfs/issues/3570#issuecomment-273931692
|
|
5
|
+
const CID_CBOR_TAG = 0x2A;
|
|
6
|
+
function cidDecoder(bytes) {
|
|
7
|
+
if (bytes[0] !== 0) {
|
|
8
|
+
throw new Error('Invalid CID for CBOR tag 42; expected leading 0x00');
|
|
9
|
+
}
|
|
10
|
+
return CID.decode(bytes.subarray(1)); // ignore leading 0x00
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Take a `DAG-CBOR` encoded `Uint8Array`, deserialize it as an object and
|
|
14
|
+
* re-serialize it in a form that can be passed to `JSON.serialize` and then
|
|
15
|
+
* `JSON.parse` without losing any data.
|
|
16
|
+
*/
|
|
17
|
+
export function dagCborToSafeJSON(buf) {
|
|
18
|
+
const tags = [];
|
|
19
|
+
tags[CID_CBOR_TAG] = cidDecoder;
|
|
20
|
+
const obj = decode(buf, {
|
|
21
|
+
allowIndefinite: false,
|
|
22
|
+
coerceUndefinedToNull: true,
|
|
23
|
+
allowNaN: false,
|
|
24
|
+
allowInfinity: false,
|
|
25
|
+
strict: true,
|
|
26
|
+
useMaps: false,
|
|
27
|
+
rejectDuplicateMapKeys: true,
|
|
28
|
+
tags,
|
|
29
|
+
// this is different to `DAG-CBOR` - the reason we disallow BigInts is
|
|
30
|
+
// because we are about to re-encode to `JSON` which does not support
|
|
31
|
+
// BigInts. Blocks containing large numbers should be deserialized using a
|
|
32
|
+
// cbor decoder instead
|
|
33
|
+
allowBigInt: false
|
|
34
|
+
});
|
|
35
|
+
return new TextDecoder().decode(encode(obj));
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=dag-cbor-to-safe-json.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dag-cbor-to-safe-json.js","sourceRoot":"","sources":["../../../src/utils/dag-cbor-to-safe-json.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AACnC,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAGtC,qEAAqE;AACrE,MAAM,YAAY,GAAG,IAAI,CAAA;AAEzB,SAAS,UAAU,CAAE,KAAiB;IACpC,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAA;IACvE,CAAC;IAED,OAAO,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAA,CAAC,sBAAsB;AAC7D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAE,GAAe;IAChD,MAAM,IAAI,GAAiB,EAAE,CAAA;IAC7B,IAAI,CAAC,YAAY,CAAC,GAAG,UAAU,CAAA;IAE/B,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,EAAE;QACtB,eAAe,EAAE,KAAK;QACtB,qBAAqB,EAAE,IAAI;QAC3B,QAAQ,EAAE,KAAK;QACf,aAAa,EAAE,KAAK;QACpB,MAAM,EAAE,IAAI;QACZ,OAAO,EAAE,KAAK;QACd,sBAAsB,EAAE,IAAI;QAC5B,IAAI;QAEJ,sEAAsE;QACtE,qEAAqE;QACrE,0EAA0E;QAC1E,uBAAuB;QACvB,WAAW,EAAE,KAAK;KACnB,CAAC,CAAA;IAEF,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAA;AAC9C,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { VerifiedFetchInit } from '../index.js';
|
|
2
|
+
import type { ComponentLogger } from '@libp2p/interface';
|
|
3
|
+
/**
|
|
4
|
+
* Converts an async iterator of Uint8Array bytes to a stream and returns the first chunk of bytes
|
|
5
|
+
*/
|
|
6
|
+
export declare function getStreamFromAsyncIterable(iterator: AsyncIterable<Uint8Array>, path: string, logger: ComponentLogger, options?: Pick<VerifiedFetchInit, 'onProgress'>): Promise<{
|
|
7
|
+
stream: ReadableStream<Uint8Array>;
|
|
8
|
+
firstChunk: Uint8Array;
|
|
9
|
+
}>;
|
|
10
|
+
//# sourceMappingURL=get-stream-from-async-iterable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-stream-from-async-iterable.d.ts","sourceRoot":"","sources":["../../../src/utils/get-stream-from-async-iterable.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAExD;;GAEG;AACH,wBAAsB,0BAA0B,CAAE,QAAQ,EAAE,aAAa,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,iBAAiB,EAAE,YAAY,CAAC,GAAG,OAAO,CAAC;IAAE,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;IAAC,UAAU,EAAE,UAAU,CAAA;CAAE,CAAC,CAqCtP"}
|
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
import { CustomProgressEvent } from 'progress-events';
|
|
2
|
-
import { getContentType } from './get-content-type.js';
|
|
3
2
|
/**
|
|
4
|
-
* Converts an async iterator of Uint8Array bytes to a stream and
|
|
3
|
+
* Converts an async iterator of Uint8Array bytes to a stream and returns the first chunk of bytes
|
|
5
4
|
*/
|
|
6
|
-
export async function
|
|
7
|
-
const log = logger.forComponent('helia:verified-fetch:get-stream-
|
|
5
|
+
export async function getStreamFromAsyncIterable(iterator, path, logger, options) {
|
|
6
|
+
const log = logger.forComponent('helia:verified-fetch:get-stream-from-async-iterable');
|
|
8
7
|
const reader = iterator[Symbol.asyncIterator]();
|
|
9
|
-
const { value, done } = await reader.next();
|
|
8
|
+
const { value: firstChunk, done } = await reader.next();
|
|
10
9
|
if (done === true) {
|
|
11
10
|
log.error('No content found for path', path);
|
|
12
11
|
throw new Error('No content found');
|
|
13
12
|
}
|
|
14
|
-
const contentType = await getContentType({ bytes: value, path });
|
|
15
13
|
const stream = new ReadableStream({
|
|
16
14
|
async start(controller) {
|
|
17
15
|
// the initial value is already available
|
|
18
16
|
options?.onProgress?.(new CustomProgressEvent('verified-fetch:request:progress:chunk'));
|
|
19
|
-
controller.enqueue(
|
|
17
|
+
controller.enqueue(firstChunk);
|
|
20
18
|
},
|
|
21
19
|
async pull(controller) {
|
|
22
20
|
const { value, done } = await reader.next();
|
|
@@ -32,6 +30,9 @@ export async function getStreamAndContentType(iterator, path, logger, options) {
|
|
|
32
30
|
controller.enqueue(value);
|
|
33
31
|
}
|
|
34
32
|
});
|
|
35
|
-
return {
|
|
33
|
+
return {
|
|
34
|
+
stream,
|
|
35
|
+
firstChunk
|
|
36
|
+
};
|
|
36
37
|
}
|
|
37
|
-
//# sourceMappingURL=get-stream-
|
|
38
|
+
//# sourceMappingURL=get-stream-from-async-iterable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-stream-from-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