Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions packages/client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,33 @@ const libp2p = await createLibp2p({
await libp2p.peerRouting.findPeer(peerIdFromString('QmFoo'))
```

### Filtering with IPIP-484

The client can be configured to pass filter options to the delegated routing server as defined in IPIP-484.
The filter options be set globally, by passing them to the client constructor, or on a per-request basis.

## Example

```typescript
import { createDelegatedRoutingV1HttpApiClient } from '@helia/delegated-routing-v1-http-api-client'
import { createLibp2p } from 'libp2p'
import { peerIdFromString } from '@libp2p/peer-id'

// globally set filter options
const client = createDelegatedRoutingV1HttpApiClient('https://delegated-ipfs.dev', {
filterProtocols: ['transport-bitswap', 'unknown', 'transport-ipfs-gateway-http'],
filterAddrs: ['webtransport', 'webrtc-direct', 'wss']
})

// per-request filter options
for await (const prov of getProviders(CID.parse('bafy'), {
filterProtocols: ['transport-ipfs-gateway-http'],
filterAddrs: ['!p2p-circuit']
})) {
// ...
}
```

# Install

```console
Expand Down
29 changes: 29 additions & 0 deletions packages/client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,35 @@
* // later this will use the configured HTTP gateway
* await libp2p.peerRouting.findPeer(peerIdFromString('QmFoo'))
* ```
*
* ### Filtering with IPIP-484
*
* The client can be configured to pass filter options to the delegated routing server as defined in IPIP-484.
* The filter options be set globally, by passing them to the client constructor, or on a per-request basis.
*
* @see https://github.com/ipfs/specs/pull/484
*
* @example
*
* ```typescript
* import { createDelegatedRoutingV1HttpApiClient } from '@helia/delegated-routing-v1-http-api-client'
* import { createLibp2p } from 'libp2p'
* import { peerIdFromString } from '@libp2p/peer-id'
*
* // globally set filter options
* const client = createDelegatedRoutingV1HttpApiClient('https://delegated-ipfs.dev', {
* filterProtocols: ['transport-bitswap', 'unknown', 'transport-ipfs-gateway-http'],
* filterAddrs: ['webtransport', 'webrtc-direct', 'wss']
* })
*
* // per-request filter options
* for await (const prov of getProviders(CID.parse('bafy'), {
* filterProtocols: ['transport-ipfs-gateway-http'],
* filterAddrs: ['!p2p-circuit']
* })) {
* // ...
* }
* ```
*/

import { DefaultDelegatedRoutingV1HttpApiClient } from './client.js'
Expand Down
Loading