
Security News
TC39 Advances 11 Proposals for Math Precision, Binary APIs, and More
TC39 advances 11 JavaScript proposals, with two moving to Stage 4, bringing better math, binary APIs, and more features one step closer to the ECMAScript spec.
@helia/delegated-routing-v1-http-api-client
Advanced tools
A Delegated Routing V1 HTTP API client
A Delegated Routing V1 HTTP API client
A client implementation of the IPFS Delegated Routing V1 HTTP API that can be used to interact with any compliant server implementation.
import { createDelegatedRoutingV1HttpApiClient } from '@helia/delegated-routing-v1-http-api-client'
import { CID } from 'multiformats/cid'
const client = createDelegatedRoutingV1HttpApiClient('https://example.org')
for await (const prov of getProviders(CID.parse('QmFoo'))) {
// ...
}
The client can be configured as a libp2p service, this will enable it as both a ContentRouting and a PeerRouting implementation
import { createDelegatedRoutingV1HttpApiClient } from '@helia/delegated-routing-v1-http-api-client'
import { createLibp2p } from 'libp2p'
import { peerIdFromString } from '@libp2p/peer-id'
const client = createDelegatedRoutingV1HttpApiClient('https://example.org')
const libp2p = await createLibp2p({
// other config here
services: {
delegatedRouting: client
}
})
// later this will use the configured HTTP gateway
await libp2p.peerRouting.findPeer(peerIdFromString('QmFoo'))
By default, the client caches successful (200) delegated routing responses in browser environments (that support the Cache API) for a duration of 5 minutes. The client does this by adding an x-cache-expires
header to the response object.
If caching is enabled, the client will cache responses for the duration of cacheTTL
milliseconds.
If cacheTTL
is 0, caching is disabled:
// disable caching
const client = createDelegatedRoutingV1HttpApiClient('https://example.org', { cacheTTL: 0 })
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.
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']
})) {
// ...
}
$ npm i @helia/delegated-routing-v1-http-api-client
Licensed under either of
Contributions welcome! Please check out the issues.
Also see our contributing document for more information on how we work, and about contributing in general.
Please be aware that all interactions related to this repo are subject to the IPFS Code of Conduct.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
FAQs
A Delegated Routing V1 HTTP API client
The npm package @helia/delegated-routing-v1-http-api-client receives a total of 5,002 weekly downloads. As such, @helia/delegated-routing-v1-http-api-client popularity was classified as popular.
We found that @helia/delegated-routing-v1-http-api-client demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
TC39 advances 11 JavaScript proposals, with two moving to Stage 4, bringing better math, binary APIs, and more features one step closer to the ECMAScript spec.
Research
/Security News
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.