@helia/verified-fetch 0.0.0-6c88ee1 → 0.0.0-6f8c15b

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/README.md +259 -3
  2. package/dist/index.min.js +7 -29
  3. package/dist/src/index.d.ts +314 -11
  4. package/dist/src/index.d.ts.map +1 -1
  5. package/dist/src/index.js +271 -6
  6. package/dist/src/index.js.map +1 -1
  7. package/dist/src/types.d.ts +2 -0
  8. package/dist/src/types.d.ts.map +1 -0
  9. package/dist/src/types.js +2 -0
  10. package/dist/src/types.js.map +1 -0
  11. package/dist/src/utils/dag-cbor-to-safe-json.d.ts +7 -0
  12. package/dist/src/utils/dag-cbor-to-safe-json.d.ts.map +1 -0
  13. package/dist/src/utils/dag-cbor-to-safe-json.js +37 -0
  14. package/dist/src/utils/dag-cbor-to-safe-json.js.map +1 -0
  15. package/dist/src/utils/get-content-disposition-filename.d.ts +6 -0
  16. package/dist/src/utils/get-content-disposition-filename.d.ts.map +1 -0
  17. package/dist/src/utils/get-content-disposition-filename.js +16 -0
  18. package/dist/src/utils/get-content-disposition-filename.js.map +1 -0
  19. package/dist/src/utils/get-e-tag.d.ts +28 -0
  20. package/dist/src/utils/get-e-tag.d.ts.map +1 -0
  21. package/dist/src/utils/get-e-tag.js +18 -0
  22. package/dist/src/utils/get-e-tag.js.map +1 -0
  23. package/dist/src/utils/get-stream-from-async-iterable.d.ts +10 -0
  24. package/dist/src/utils/get-stream-from-async-iterable.d.ts.map +1 -0
  25. package/dist/src/utils/{get-stream-and-content-type.js → get-stream-from-async-iterable.js} +10 -9
  26. package/dist/src/utils/get-stream-from-async-iterable.js.map +1 -0
  27. package/dist/src/utils/get-tar-stream.d.ts +4 -0
  28. package/dist/src/utils/get-tar-stream.d.ts.map +1 -0
  29. package/dist/src/utils/get-tar-stream.js +46 -0
  30. package/dist/src/utils/get-tar-stream.js.map +1 -0
  31. package/dist/src/utils/parse-url-string.d.ts +7 -1
  32. package/dist/src/utils/parse-url-string.d.ts.map +1 -1
  33. package/dist/src/utils/parse-url-string.js +6 -0
  34. package/dist/src/utils/parse-url-string.js.map +1 -1
  35. package/dist/src/utils/responses.d.ts +5 -0
  36. package/dist/src/utils/responses.d.ts.map +1 -0
  37. package/dist/src/utils/responses.js +27 -0
  38. package/dist/src/utils/responses.js.map +1 -0
  39. package/dist/src/utils/select-output-type.d.ts +12 -0
  40. package/dist/src/utils/select-output-type.d.ts.map +1 -0
  41. package/dist/src/utils/select-output-type.js +148 -0
  42. package/dist/src/utils/select-output-type.js.map +1 -0
  43. package/dist/src/verified-fetch.d.ts +23 -27
  44. package/dist/src/verified-fetch.d.ts.map +1 -1
  45. package/dist/src/verified-fetch.js +288 -141
  46. package/dist/src/verified-fetch.js.map +1 -1
  47. package/package.json +40 -18
  48. package/src/index.ts +321 -12
  49. package/src/types.ts +1 -0
  50. package/src/utils/dag-cbor-to-safe-json.ts +44 -0
  51. package/src/utils/get-content-disposition-filename.ts +18 -0
  52. package/src/utils/get-e-tag.ts +36 -0
  53. package/src/utils/{get-stream-and-content-type.ts → get-stream-from-async-iterable.ts} +9 -8
  54. package/src/utils/get-tar-stream.ts +68 -0
  55. package/src/utils/parse-url-string.ts +17 -2
  56. package/src/utils/responses.ts +29 -0
  57. package/src/utils/select-output-type.ts +167 -0
  58. package/src/verified-fetch.ts +340 -153
  59. package/dist/src/utils/get-content-type.d.ts +0 -11
  60. package/dist/src/utils/get-content-type.d.ts.map +0 -1
  61. package/dist/src/utils/get-content-type.js +0 -43
  62. package/dist/src/utils/get-content-type.js.map +0 -1
  63. package/dist/src/utils/get-stream-and-content-type.d.ts +0 -10
  64. package/dist/src/utils/get-stream-and-content-type.d.ts.map +0 -1
  65. package/dist/src/utils/get-stream-and-content-type.js.map +0 -1
  66. package/src/utils/get-content-type.ts +0 -55
@@ -3,7 +3,7 @@
3
3
  *
4
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
- * 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.
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
9
  *
@@ -33,7 +33,7 @@
33
33
  * import { verifiedFetch } from '@helia/verified-fetch'
34
34
  * import { CID } from 'multiformats/cid'
35
35
  *
36
- * const cid = CID.parse('bafyFoo') // some image file
36
+ * const cid = CID.parse('bafyFoo') // some json file
37
37
  * const response = await verifiedFetch(cid)
38
38
  * const json = await response.json()
39
39
  * ```
@@ -75,7 +75,7 @@
75
75
  * const fetch = await createVerifiedFetch({
76
76
  * gateways: ['https://trustless-gateway.link'],
77
77
  * routers: ['http://delegated-ipfs.dev']
78
- *})
78
+ * })
79
79
  *
80
80
  * const resp = await fetch('ipfs://bafy...')
81
81
  *
@@ -112,6 +112,269 @@
112
112
  * const json = await resp.json()
113
113
  * ```
114
114
  *
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
+ * ### Custom DNS resolvers
142
+ *
143
+ * If you don't want to leak DNS queries to the default resolvers, you can provide your own list of DNS resolvers to `createVerifiedFetch`.
144
+ *
145
+ * Note that you do not need to provide both a DNS-over-HTTPS and a DNS-over-JSON resolver, and you should prefer `dnsJsonOverHttps` resolvers for usage in the browser for a smaller bundle size. See https://github.com/ipfs/helia/tree/main/packages/ipns#example---using-dns-json-over-https for more information.
146
+ *
147
+ * @example Customizing DNS resolvers
148
+ *
149
+ * ```typescript
150
+ * import { createVerifiedFetch } from '@helia/verified-fetch'
151
+ * import { dnsJsonOverHttps, dnsOverHttps } from '@helia/ipns/dns-resolvers'
152
+ *
153
+ * const fetch = await createVerifiedFetch({
154
+ * gateways: ['https://trustless-gateway.link'],
155
+ * routers: ['http://delegated-ipfs.dev'],
156
+ * dnsResolvers: [
157
+ * dnsJsonOverHttps('https://my-dns-resolver.example.com/dns-json'),
158
+ * dnsOverHttps('https://my-dns-resolver.example.com/dns-query')
159
+ * ]
160
+ * })
161
+ * ```
162
+ *
163
+ * ### IPLD codec handling
164
+ *
165
+ * 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.
166
+ *
167
+ * #### DAG-PB
168
+ *
169
+ * [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.
170
+ *
171
+ * ##### Using the DAG-PB codec as a Blob
172
+ *
173
+ * ```typescript
174
+ * import { verifiedFetch } from '@helia/verified-fetch'
175
+ *
176
+ * const res = await verifiedFetch('ipfs://Qmfoo')
177
+ * const blob = await res.blob()
178
+ *
179
+ * console.info(blob) // Blob { size: x, type: 'application/octet-stream' }
180
+ * ```
181
+ *
182
+ * ##### Using the DAG-PB codec as an ArrayBuffer
183
+ *
184
+ * ```typescript
185
+ * import { verifiedFetch } from '@helia/verified-fetch'
186
+ *
187
+ * const res = await verifiedFetch('ipfs://Qmfoo')
188
+ * const buf = await res.arrayBuffer()
189
+ *
190
+ * console.info(buf) // ArrayBuffer { [Uint8Contents]: < ... >, byteLength: x }
191
+ * ```
192
+ *
193
+ * ##### Using the DAG-PB codec as a stream
194
+ *
195
+ * ```typescript
196
+ * import { verifiedFetch } from '@helia/verified-fetch'
197
+ *
198
+ * const res = await verifiedFetch('ipfs://Qmfoo')
199
+ * const reader = res.body?.getReader()
200
+ *
201
+ * while (true) {
202
+ * const next = await reader.read()
203
+ *
204
+ * if (next?.done === true) {
205
+ * break
206
+ * }
207
+ *
208
+ * if (next?.value != null) {
209
+ * console.info(next.value) // Uint8Array(x) [ ... ]
210
+ * }
211
+ * }
212
+ * ```
213
+ *
214
+ * ##### Content-Type
215
+ *
216
+ * When fetching `DAG-PB` data, the content type will be set to `application/octet-stream` unless a custom content-type parser is configured.
217
+ *
218
+ * #### JSON
219
+ *
220
+ * The JSON codec is a very simple codec, a block parseable with this codec is a JSON string encoded into a `Uint8Array`.
221
+ *
222
+ * ##### Using the JSON codec
223
+ *
224
+ * ```typescript
225
+ * import * as json from 'multiformats/codecs/json'
226
+ *
227
+ * const block = new TextEncoder().encode('{ "hello": "world" }')
228
+ * const obj = json.decode(block)
229
+ *
230
+ * console.info(obj) // { hello: 'world' }
231
+ * ```
232
+ *
233
+ * ##### Content-Type
234
+ *
235
+ * When the `JSON` codec is encountered, the `Content-Type` header of the response will be set to `application/json`.
236
+ *
237
+ * ### DAG-JSON
238
+ *
239
+ * [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.
240
+ *
241
+ * `CID`s and byte arrays are represented using special object structures with a single `"/"` property.
242
+ *
243
+ * Using `DAG-JSON` has two important caveats:
244
+ *
245
+ * 1. Your `JSON` structure cannot contain an object with only a `"/"` property, as it will be interpreted as a special type.
246
+ * 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.
247
+ *
248
+ * Otherwise this codec follows the same rules as the `JSON` codec.
249
+ *
250
+ * ##### Using the DAG-JSON codec
251
+ *
252
+ * ```typescript
253
+ * import * as dagJson from '@ipld/dag-json'
254
+ *
255
+ * const block = new TextEncoder().encode(`{
256
+ * "hello": "world",
257
+ * "cid": {
258
+ * "/": "baeaaac3imvwgy3zao5xxe3de"
259
+ * },
260
+ * "buf": {
261
+ * "/": {
262
+ * "bytes": "AAECAwQ"
263
+ * }
264
+ * }
265
+ * }`)
266
+ *
267
+ * const obj = dagJson.decode(block)
268
+ *
269
+ * console.info(obj)
270
+ * // {
271
+ * // hello: 'world',
272
+ * // cid: CID(baeaaac3imvwgy3zao5xxe3de),
273
+ * // buf: Uint8Array(5) [ 0, 1, 2, 3, 4 ]
274
+ * // }
275
+ * ```
276
+ *
277
+ * ##### Content-Type
278
+ *
279
+ * When the `DAG-JSON` codec is encountered in the requested CID, the `Content-Type` header of the response will be set to `application/json`.
280
+ *
281
+ * `DAG-JSON` data can be parsed from the response by using the `.json()` function, which will return `CID`s/byte arrays as plain `{ "/": ... }` objects:
282
+ *
283
+ * ```typescript
284
+ * import { verifiedFetch } from '@helia/verified-fetch'
285
+ * import * as dagJson from '@ipld/dag-json'
286
+ *
287
+ * const res = await verifiedFetch('ipfs://bafyDAGJSON')
288
+ *
289
+ * // either:
290
+ * const obj = await res.json()
291
+ * console.info(obj.cid) // { "/": "baeaaac3imvwgy3zao5xxe3de" }
292
+ * console.info(obj.buf) // { "/": { "bytes": "AAECAwQ" } }
293
+ * ```
294
+ *
295
+ * 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:
296
+ *
297
+ *```typescript
298
+ * import { verifiedFetch } from '@helia/verified-fetch'
299
+ * import * as dagJson from '@ipld/dag-json'
300
+ *
301
+ * const res = await verifiedFetch('ipfs://bafyDAGJSON')
302
+ *
303
+ * // or:
304
+ * const obj = dagJson.decode(await res.arrayBuffer())
305
+ * console.info(obj.cid) // CID(baeaaac3imvwgy3zao5xxe3de)
306
+ * console.info(obj.buf) // Uint8Array(5) [ 0, 1, 2, 3, 4 ]
307
+ * ```
308
+ *
309
+ * #### DAG-CBOR
310
+ *
311
+ * [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.
312
+ *
313
+ * 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.
314
+ *
315
+ * ##### Content-Type
316
+ *
317
+ * Not all data types supported by `DAG-CBOR` can be successfully turned into JSON and back into the same binary form.
318
+ *
319
+ * 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.
320
+ *
321
+ * 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()`.
322
+ *
323
+ * ##### Detecting JSON-safe DAG-CBOR
324
+ *
325
+ * 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.
326
+ *
327
+ * ```typescript
328
+ * import { verifiedFetch } from '@helia/verified-fetch'
329
+ * import * as dagCbor from '@ipld/dag-cbor'
330
+ *
331
+ * const res = await verifiedFetch('ipfs://bafyDagCborCID')
332
+ * let obj
333
+ *
334
+ * if (res.headers.get('Content-Type') === 'application/json') {
335
+ * // DAG-CBOR data can be safely decoded as JSON
336
+ * obj = await res.json()
337
+ * } else {
338
+ * // response contains non-JSON friendly data types
339
+ * obj = dagCbor.decode(await res.arrayBuffer())
340
+ * }
341
+ *
342
+ * console.info(obj) // ...
343
+ * ```
344
+ *
345
+ * ## The `Accept` header
346
+ *
347
+ * 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.
348
+ *
349
+ * 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:
350
+ *
351
+ * ```typescript
352
+ * import { verifiedFetch } from '@helia/verified-fetch'
353
+ *
354
+ * const res = await verifiedFetch('ipfs://bafyJPEGImageCID', {
355
+ * headers: {
356
+ * accept: 'image/png'
357
+ * }
358
+ * })
359
+ *
360
+ * console.info(res.status) // 406 - the image was a JPEG but we specified PNG as the accept header
361
+ * ```
362
+ *
363
+ * 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:
364
+ *
365
+ * ```typescript
366
+ * import { verifiedFetch } from '@helia/verified-fetch'
367
+ *
368
+ * const res = await verifiedFetch('ipfs://bafyDAGCBORCID', {
369
+ * headers: {
370
+ * accept: 'application/octet-stream'
371
+ * }
372
+ * })
373
+ *
374
+ * console.info(res.headers.get('accept')) // application/octet-stream
375
+ * const buf = await res.arrayBuffer() // raw bytes, not processed as JSON
376
+ * ```
377
+ *
115
378
  * ## Comparison to fetch
116
379
  *
117
380
  * This module attempts to act as similarly to the `fetch()` API as possible.
@@ -129,7 +392,7 @@
129
392
  * 2. IPNS protocol: `ipns://<peerId>` & `ipns://<publicKey>` & `ipns://<hostUri_Supporting_DnsLink_TxtRecords>`
130
393
  * 3. CID instances: An actual CID instance `CID.parse('bafy...')`
131
394
  *
132
- * As well as support for pathing & params for item 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).
395
+ * 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).
133
396
  *
134
397
  * 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.
135
398
  *
@@ -226,7 +489,7 @@
226
489
  * 4. `AbortError` - If the content request is aborted due to user aborting provided AbortSignal.
227
490
  */
228
491
  import type { Helia } from '@helia/interface';
229
- import type { IPNSRoutingEvents, ResolveDnsLinkProgressEvents, ResolveProgressEvents } from '@helia/ipns';
492
+ import type { DNSResolver, IPNSRoutingEvents, ResolveDnsLinkProgressEvents, ResolveProgressEvents } from '@helia/ipns';
230
493
  import type { GetEvents } from '@helia/unixfs';
231
494
  import type { CID } from 'multiformats/cid';
232
495
  import type { ProgressEvent, ProgressOptions } from 'progress-events';
@@ -234,8 +497,11 @@ import type { ProgressEvent, ProgressOptions } from 'progress-events';
234
497
  * The types for the first argument of the `verifiedFetch` function.
235
498
  */
236
499
  export type Resource = string | CID;
500
+ export interface ResourceDetail {
501
+ resource: Resource;
502
+ }
237
503
  export interface CIDDetail {
238
- cid: string;
504
+ cid: CID;
239
505
  path: string;
240
506
  }
241
507
  export interface CIDDetailError extends CIDDetail {
@@ -247,25 +513,62 @@ export interface VerifiedFetch {
247
513
  stop(): Promise<void>;
248
514
  }
249
515
  /**
250
- * Instead of passing a Helia instance, you can pass a list of gateways and routers, and a HeliaHTTP instance will be created for you.
516
+ * Instead of passing a Helia instance, you can pass a list of gateways and
517
+ * routers, and a HeliaHTTP instance will be created for you.
251
518
  */
252
- export interface CreateVerifiedFetchWithOptions {
519
+ export interface CreateVerifiedFetchInit {
253
520
  gateways: string[];
254
521
  routers?: string[];
522
+ /**
523
+ * In order to parse DNSLink records, we need to resolve DNS queries. You can
524
+ * pass a list of DNS resolvers that we will provide to the @helia/ipns
525
+ * instance for you. You must construct them using the `dnsJsonOverHttps` or
526
+ * `dnsOverHttps` functions exported from `@helia/ipns/dns-resolvers`.
527
+ *
528
+ * We use cloudflare and google's dnsJsonOverHttps resolvers by default.
529
+ *
530
+ * @default [dnsJsonOverHttps('https://mozilla.cloudflare-dns.com/dns-query'),dnsJsonOverHttps('https://dns.google/resolve')]
531
+ */
532
+ dnsResolvers?: DNSResolver[];
533
+ }
534
+ export interface CreateVerifiedFetchOptions {
535
+ /**
536
+ * A function to handle parsing content type from bytes. The function you
537
+ * provide will be passed the first set of bytes we receive from the network,
538
+ * and should return a string that will be used as the value for the
539
+ * `Content-Type` header in the response.
540
+ *
541
+ * @default undefined
542
+ */
543
+ contentTypeParser?: ContentTypeParser;
544
+ }
545
+ /**
546
+ * A ContentTypeParser attempts to return the mime type of a given file. It
547
+ * receives the first chunk of the file data and the file name, if it is
548
+ * available. The function can be sync or async and if it returns/resolves to
549
+ * `undefined`, `application/octet-stream` will be used.
550
+ */
551
+ export interface ContentTypeParser {
552
+ /**
553
+ * Attempt to determine a mime type, either via of the passed bytes or the
554
+ * filename if it is available.
555
+ */
556
+ (bytes: Uint8Array, fileName?: string): Promise<string | undefined> | string | undefined;
255
557
  }
256
558
  export type BubbledProgressEvents = GetEvents | ResolveProgressEvents | ResolveDnsLinkProgressEvents | IPNSRoutingEvents;
257
559
  export type VerifiedFetchProgressEvents = ProgressEvent<'verified-fetch:request:start', CIDDetail> | ProgressEvent<'verified-fetch:request:info', string> | ProgressEvent<'verified-fetch:request:progress:chunk', CIDDetail> | ProgressEvent<'verified-fetch:request:end', CIDDetail> | ProgressEvent<'verified-fetch:request:error', CIDDetailError>;
258
560
  /**
259
561
  * Options for the `fetch` function returned by `createVerifiedFetch`.
260
562
  *
261
- * This method accepts all the same options as the `fetch` function in the browser, plus an `onProgress` option to
262
- * listen for progress events.
563
+ * This interface contains all the same fields as the [options object](https://developer.mozilla.org/en-US/docs/Web/API/fetch#options)
564
+ * passed to `fetch` in browsers, plus an `onProgress` option to listen for
565
+ * progress events.
263
566
  */
264
567
  export interface VerifiedFetchInit extends RequestInit, ProgressOptions<BubbledProgressEvents | VerifiedFetchProgressEvents> {
265
568
  }
266
569
  /**
267
570
  * Create and return a Helia node
268
571
  */
269
- export declare function createVerifiedFetch(init?: Helia | CreateVerifiedFetchWithOptions): Promise<VerifiedFetch>;
572
+ export declare function createVerifiedFetch(init?: Helia | CreateVerifiedFetchInit, options?: CreateVerifiedFetchOptions): Promise<VerifiedFetch>;
270
573
  export { verifiedFetch } from './singleton.js';
271
574
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkOG;AAMH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,KAAK,EAAE,iBAAiB,EAAE,4BAA4B,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AACzG,OAAO,KA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