Helia logo

# @helia/block-brokers [![ipfs.tech](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](https://ipfs.tech) [![Discuss](https://img.shields.io/discourse/https/discuss.ipfs.tech/posts.svg?style=flat-square)](https://discuss.ipfs.tech) [![codecov](https://img.shields.io/codecov/c/github/ipfs/helia.svg?style=flat-square)](https://codecov.io/gh/ipfs/helia) [![CI](https://img.shields.io/github/actions/workflow/status/ipfs/helia/main.yml?branch=main\&style=flat-square)](https://github.com/ipfs/helia/actions/workflows/main.yml?query=branch%3Amain) > Block brokers for Helia # Install ```console $ npm i @helia/block-brokers ``` ## Browser ` ``` # Example - Customizing trustless gateway requests ```typescript import { TrustlessGatewayBlockBroker } from "@helia/block-brokers/trustless-gateway/broker.js"; import { defaultLogger } from "@libp2p/logger"; import { CID } from "multiformats/cid"; // Create a trustless gateway block broker with custom request options const gatewayBlockBroker = new TrustlessGatewayBlockBroker( { routing, // Your routing implementation logger: defaultLogger(), }, { allowInsecure: true, allowLocal: true, // Add a transformRequestInit function to customize the fetch request transformRequestInit: (requestInit) => { // Add authentication headers for your gateway requestInit.headers = { ...requestInit.headers, Authorization: "Bearer your-jwt-token-here", }; return requestInit; }, } ); // Use the block broker to retrieve blocks const cid = CID.parse( "bafybeic3q4y65yxu3yckr76q63bcvanhklwf6cwxuacnrot6v3gykrgsvq" ); const block = await gatewayBlockBroker.retrieve?.(cid, { validateFn: async (block) => { // Optional validation function // You can validate the retrieved block here }, }); ``` # API Docs - # License Licensed under either of - Apache 2.0, ([LICENSE-APACHE](https://github.com/ipfs/helia/blob/main/packages/block-brokers/LICENSE-APACHE) / ) - MIT ([LICENSE-MIT](https://github.com/ipfs/helia/blob/main/packages/block-brokers/LICENSE-MIT) / ) # Contribute Contributions welcome! Please check out [the issues](https://github.com/ipfs/helia/issues). Also see our [contributing document](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md) 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](https://github.com/ipfs/community/blob/master/code-of-conduct.md). 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. [![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md)