@helia/verified-fetch 2.1.2 → 2.2.0
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 +5 -3
- package/dist/index.min.js +56 -17
- package/dist/src/index.d.ts +17 -4
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +44 -21
- package/dist/src/index.js.map +1 -1
- package/dist/src/utils/get-peer-id-from-string.d.ts +3 -0
- package/dist/src/utils/get-peer-id-from-string.d.ts.map +1 -0
- package/dist/src/utils/get-peer-id-from-string.js +10 -0
- package/dist/src/utils/get-peer-id-from-string.js.map +1 -0
- package/dist/src/utils/libp2p-defaults.browser.d.ts +3 -0
- package/dist/src/utils/libp2p-defaults.browser.d.ts.map +1 -0
- package/dist/src/utils/libp2p-defaults.browser.js +21 -0
- package/dist/src/utils/libp2p-defaults.browser.js.map +1 -0
- package/dist/src/utils/libp2p-defaults.d.ts +3 -0
- package/dist/src/utils/libp2p-defaults.d.ts.map +1 -0
- package/dist/src/utils/libp2p-defaults.js +31 -0
- package/dist/src/utils/libp2p-defaults.js.map +1 -0
- package/dist/src/utils/libp2p-types.d.ts +8 -0
- package/dist/src/utils/libp2p-types.d.ts.map +1 -0
- package/dist/src/utils/libp2p-types.js +2 -0
- package/dist/src/utils/libp2p-types.js.map +1 -0
- package/dist/src/utils/parse-url-string.d.ts.map +1 -1
- package/dist/src/utils/parse-url-string.js +2 -8
- package/dist/src/utils/parse-url-string.js.map +1 -1
- package/dist/src/verified-fetch.d.ts.map +1 -1
- package/dist/src/verified-fetch.js +4 -12
- package/dist/src/verified-fetch.js.map +1 -1
- package/package.json +27 -21
- package/src/index.ts +59 -23
- package/src/utils/get-peer-id-from-string.ts +12 -0
- package/src/utils/libp2p-defaults.browser.ts +28 -0
- package/src/utils/libp2p-defaults.ts +38 -0
- package/src/utils/libp2p-types.ts +8 -0
- package/src/utils/parse-url-string.ts +2 -7
- package/src/verified-fetch.ts +4 -12
package/README.md
CHANGED
|
@@ -32,11 +32,13 @@ repo and examine the changes made.
|
|
|
32
32
|
|
|
33
33
|
`@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.
|
|
34
34
|
|
|
35
|
-
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.
|
|
35
|
+
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.
|
|
36
|
+
|
|
37
|
+
By default, providers for CIDs are found with delegated routers and retrieved over HTTP from [trustless gateways](https://specs.ipfs.tech/http-gateways/trustless-gateway/), and WebTransport and WebRTC providers if available.
|
|
36
38
|
|
|
37
39
|
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.
|
|
38
40
|
|
|
39
|
-
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://
|
|
41
|
+
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://ipfs.github.io/helia/) node for complete control over how content is retrieved.
|
|
40
42
|
|
|
41
43
|
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.
|
|
42
44
|
|
|
@@ -119,7 +121,7 @@ For full control of how `@helia/verified-fetch` fetches content from the distrib
|
|
|
119
121
|
|
|
120
122
|
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.
|
|
121
123
|
|
|
122
|
-
You can see variations of Helia and js-libp2p configuration options at <https://
|
|
124
|
+
You can see variations of Helia and js-libp2p configuration options at <https://ipfs.github.io/helia/interfaces/helia.HeliaInit.html>.
|
|
123
125
|
|
|
124
126
|
```typescript
|
|
125
127
|
import { trustlessGateway } from '@helia/block-brokers'
|