@helia/delegated-routing-v1-http-api-client 5.2.1 → 6.0.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 +25 -10
- package/dist/index.min.js +5 -5
- package/dist/index.min.js.map +4 -4
- package/dist/src/index.d.ts +30 -21
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +25 -26
- package/dist/src/index.js.map +1 -1
- package/dist/typedoc-urls.json +0 -2
- package/package.json +2 -2
- package/src/index.ts +31 -28
package/README.md
CHANGED
|
@@ -35,12 +35,17 @@ A client implementation of the IPFS [Delegated Routing V1 HTTP API](https://spec
|
|
|
35
35
|
## Example
|
|
36
36
|
|
|
37
37
|
```typescript
|
|
38
|
-
import {
|
|
38
|
+
import { delegatedRoutingV1HttpApiClient } from '@helia/delegated-routing-v1-http-api-client'
|
|
39
39
|
import { CID } from 'multiformats/cid'
|
|
40
|
+
import { defaultLogger } from '@libp2p/logger'
|
|
40
41
|
|
|
41
|
-
const client =
|
|
42
|
+
const client = delegatedRoutingV1HttpApiClient({
|
|
43
|
+
url: 'https://example.org'
|
|
44
|
+
})({
|
|
45
|
+
logger: defaultLogger()
|
|
46
|
+
})
|
|
42
47
|
|
|
43
|
-
for await (const prov of getProviders(CID.parse('QmFoo'))) {
|
|
48
|
+
for await (const prov of client.getProviders(CID.parse('QmFoo'))) {
|
|
44
49
|
// ...
|
|
45
50
|
}
|
|
46
51
|
```
|
|
@@ -52,15 +57,16 @@ The client can be configured as a libp2p service, this will enable it as both a
|
|
|
52
57
|
## Example
|
|
53
58
|
|
|
54
59
|
```typescript
|
|
55
|
-
import {
|
|
60
|
+
import { delegatedRoutingV1HttpApiClient } from '@helia/delegated-routing-v1-http-api-client'
|
|
56
61
|
import { createLibp2p } from 'libp2p'
|
|
57
62
|
import { peerIdFromString } from '@libp2p/peer-id'
|
|
58
63
|
|
|
59
|
-
const client = createDelegatedRoutingV1HttpApiClient('https://example.org')
|
|
60
64
|
const libp2p = await createLibp2p({
|
|
61
65
|
// other config here
|
|
62
66
|
services: {
|
|
63
|
-
delegatedRouting:
|
|
67
|
+
delegatedRouting: delegatedRoutingV1HttpApiClient({
|
|
68
|
+
url: 'https://example.org'
|
|
69
|
+
})
|
|
64
70
|
}
|
|
65
71
|
})
|
|
66
72
|
|
|
@@ -79,7 +85,12 @@ If `cacheTTL` is 0, caching is disabled:
|
|
|
79
85
|
|
|
80
86
|
```typescript
|
|
81
87
|
// disable caching
|
|
82
|
-
const client =
|
|
88
|
+
const client = delegatedRoutingV1HttpApiClient({
|
|
89
|
+
url: 'https://example.org'
|
|
90
|
+
cacheTTL: 0
|
|
91
|
+
})({
|
|
92
|
+
logger: defaultLogger()
|
|
93
|
+
})
|
|
83
94
|
```
|
|
84
95
|
|
|
85
96
|
### Filtering with IPIP-484
|
|
@@ -90,18 +101,22 @@ The filter options be set globally, by passing them to the client constructor, o
|
|
|
90
101
|
## Example
|
|
91
102
|
|
|
92
103
|
```typescript
|
|
93
|
-
import {
|
|
104
|
+
import { delegatedRoutingV1HttpApiClient } from '@helia/delegated-routing-v1-http-api-client'
|
|
94
105
|
import { createLibp2p } from 'libp2p'
|
|
95
106
|
import { peerIdFromString } from '@libp2p/peer-id'
|
|
107
|
+
import { defaultLogger } from '@libp2p/logger'
|
|
96
108
|
|
|
97
109
|
// globally set filter options
|
|
98
|
-
const client =
|
|
110
|
+
const client = delegatedRoutingV1HttpApiClient({
|
|
111
|
+
url: 'https://delegated-ipfs.dev',
|
|
99
112
|
filterProtocols: ['transport-bitswap', 'unknown', 'transport-ipfs-gateway-http'],
|
|
100
113
|
filterAddrs: ['webtransport', 'webrtc-direct', 'wss']
|
|
114
|
+
})({
|
|
115
|
+
logger: defaultLogger()
|
|
101
116
|
})
|
|
102
117
|
|
|
103
118
|
// per-request filter options
|
|
104
|
-
for await (const prov of getProviders(CID.parse('bafy'), {
|
|
119
|
+
for await (const prov of client.getProviders(CID.parse('bafy'), {
|
|
105
120
|
filterProtocols: ['transport-ipfs-gateway-http'],
|
|
106
121
|
filterAddrs: ['!p2p-circuit']
|
|
107
122
|
})) {
|