@helia/verified-fetch 1.3.14 → 1.4.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 +9 -6
- package/dist/index.min.js +15 -15
- package/dist/src/index.d.ts +84 -6
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +18 -9
- package/dist/src/index.js.map +1 -1
- package/dist/src/utils/parse-url-string.d.ts +7 -0
- package/dist/src/utils/parse-url-string.d.ts.map +1 -1
- package/dist/src/utils/parse-url-string.js +1 -1
- package/dist/src/utils/parse-url-string.js.map +1 -1
- package/dist/src/utils/resource-to-cache-key.d.ts +15 -0
- package/dist/src/utils/resource-to-cache-key.d.ts.map +1 -0
- package/dist/src/utils/resource-to-cache-key.js +27 -0
- package/dist/src/utils/resource-to-cache-key.js.map +1 -0
- package/dist/src/verified-fetch.d.ts +4 -10
- package/dist/src/verified-fetch.d.ts.map +1 -1
- package/dist/src/verified-fetch.js +44 -14
- package/dist/src/verified-fetch.js.map +1 -1
- package/package.json +14 -14
- package/src/index.ts +99 -9
- package/src/utils/parse-url-string.ts +1 -1
- package/src/utils/resource-to-cache-key.ts +30 -0
- package/src/verified-fetch.ts +66 -26
package/README.md
CHANGED
|
@@ -119,22 +119,25 @@ For full control of how `@helia/verified-fetch` fetches content from the distrib
|
|
|
119
119
|
|
|
120
120
|
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
121
|
|
|
122
|
-
|
|
122
|
+
You can see variations of Helia and js-libp2p configuration options at <https://helia.io/interfaces/helia.index.HeliaInit.html>.
|
|
123
123
|
|
|
124
124
|
```typescript
|
|
125
125
|
import { trustlessGateway } from '@helia/block-brokers'
|
|
126
126
|
import { createHeliaHTTP } from '@helia/http'
|
|
127
|
-
import { delegatedHTTPRouting } from '@helia/routers'
|
|
127
|
+
import { delegatedHTTPRouting, httpGatewayRouting } from '@helia/routers'
|
|
128
128
|
import { createVerifiedFetch } from '@helia/verified-fetch'
|
|
129
129
|
|
|
130
130
|
const fetch = await createVerifiedFetch(
|
|
131
131
|
await createHeliaHTTP({
|
|
132
132
|
blockBrokers: [
|
|
133
|
-
trustlessGateway(
|
|
133
|
+
trustlessGateway()
|
|
134
|
+
],
|
|
135
|
+
routers: [
|
|
136
|
+
delegatedHTTPRouting('http://delegated-ipfs.dev'),
|
|
137
|
+
httpGatewayRouting({
|
|
134
138
|
gateways: ['https://mygateway.example.net', 'https://trustless-gateway.link']
|
|
135
139
|
})
|
|
136
|
-
]
|
|
137
|
-
routers: ['http://delegated-ipfs.dev'].map((routerUrl) => delegatedHTTPRouting(routerUrl))
|
|
140
|
+
]
|
|
138
141
|
})
|
|
139
142
|
)
|
|
140
143
|
|
|
@@ -617,7 +620,7 @@ Known Errors that can be thrown:
|
|
|
617
620
|
1. `TypeError` - If the resource argument is not a string, CID, or CID string.
|
|
618
621
|
2. `TypeError` - If the options argument is passed and not an object.
|
|
619
622
|
3. `TypeError` - If the options argument is passed and is malformed.
|
|
620
|
-
4. `AbortError` - If the content request is aborted due to user aborting provided AbortSignal.
|
|
623
|
+
4. `AbortError` - If the content request is aborted due to user aborting provided AbortSignal. Note that this is a `AbortError` from `@libp2p/interface` and not the standard `AbortError` from the Fetch API.
|
|
621
624
|
|
|
622
625
|
# Install
|
|
623
626
|
|