npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@web3-storage/filecoin-client

v3.3.4

Published

The w3filecoin client for web3.storage

Downloads

14,285

Readme

About

The @web3-storage/filecoin-client package provides the "low level" client API to make data uploaded with the w3up platform available in Filecoin Storage providers. It is based on storacha/specs/w3-filecoin.md and is not intended for web3.storage end users.

Install

Install the package using npm:

npm install @web3-storage/filecoin-client

Usage

Storefront.filecoinOffer

The filecoin/offer task can be executed to request storing a content piece in Filecoin. It issues a signed receipt of the execution result.

A receipt for successful execution will contain an effect, linking to a filecoin/submit task that will complete asynchronously.

Otherwise the task is failed and the receipt will contain details of the reason behind the failure.

import { Storefront } from '@web3-storage/filecoin-client'

const res = await Storefront.filecoinOffer(
  invocationConfig,
  content,
  piece
)
function filecoinOffer(
  conf: InvocationConfig,
  content: Link, // Content CID
  piece: Piece, // Filecoin piece
): Promise<Receipt>

More information: InvocationConfig

Storefront.filecoinSubmit

The filecoin/submit task is an effect linked from successful execution of a filecoin/offer task, it is executed to issue a receipt for the success or failure of the task.

A receipt for successful execution indicates that the offered piece has been submitted to the pipeline. In this case the receipt will contain an effect, linking to a piece/offer task that will complete asynchronously.

Otherwise the task is failed and the receipt will contain details of the reason behind the failure.

import { Storefront } from '@web3-storage/filecoin-client'

const res = await Storefront.filecoinSubmit(
  invocationConfig,
  content,
  piece
)
function filecoinSubmit(
  conf: InvocationConfig,
  content: Link, // Content CID
  piece: Piece, // Filecoin piece
): Promise<Receipt>

More information: InvocationConfig

Storefront.filecoinAccept

The filecoin/accept task is an effect linked from successful execution of a filecoin/offer task, it is executed to issue a receipt for the success or failure of the task.

A receipt for successful execution indicates that the offered piece has been accepted in a Filecoin deal. In this case the receipt will contain proofs that the piece was included in an aggregate and deal.

Otherwise the task is failed and the receipt will contain details of the reason behind the failure.

import { Storefront } from '@web3-storage/filecoin-client'

const res = await Storefront.filecoinAccept(
  invocationConfig,
  content,
  piece
)
function filecoinAccept(
  conf: InvocationConfig,
  content: Link, // Content CID
  piece: Piece, // Filecoin piece
): Promise<Receipt>

More information: InvocationConfig

Aggregator.pieceOffer

The piece/offer task can be executed to request that a piece be aggregated for inclusion in an upcoming an Filecoin deal. It issues a signed receipt of the execution result. It is also an effect linked from successful execution of a filecoin/submit task.

A receipt for successful execution will contain an effect, linking to a piece/accept task that will complete asynchronously.

Otherwise the task is failed and the receipt will contain details of the reason behind the failure.

import { Aggregator } from '@web3-storage/filecoin-client'

const res = await Aggregator.pieceOffer(
  invocationConfig,
  piece,
  group
)
function pieceOffer(
  conf: InvocationConfig,
  piece: Piece, // Filecoin piece
  group: string, // Aggregate grouping with different criterium like storefront
): Promise<Receipt>

More information: InvocationConfig

Aggregator.pieceAccept

The piece/accept task is an effect linked from successful execution of a piece/offer task, it is executed to issue a receipt for the success or failure of the task.

A receipt for successful execution indicates that the offered piece was included in an aggregate. In this case the receipt will contain the aggregate piece CID and a proof that the piece was included in the aggregate. It also includes an effect, linking to an aggregate/offer task that will complete asynchronously.

Otherwise the task is failed and the receipt will contain details of the reason behind the failure.

import { Aggregator } from '@web3-storage/filecoin-client'

const res = await Aggregator.pieceAccept(
  invocationConfig,
  piece,
  group
)
function pieceAccept(
  conf: InvocationConfig,
  piece: Piece, // Filecoin piece
  group: string, // Aggregate grouping with different criterium like storefront
): Promise<Receipt>

More information: InvocationConfig

Dealer.aggregateOffer

The aggregate/offer task can be executed to request an aggregate be added to a deal with a Storage Provider. It issues a signed receipt of the execution result. It is also an effect linked from successful execution of a piece/accept task.

A receipt for successful execution will contain an effect, linking to an aggregate/accept task that will complete asynchronously.

Otherwise the task is failed and the receipt will contain details of the reason behind the failure.

import { Dealer } from '@web3-storage/filecoin-client'

const res = await Dealer.aggregateOffer(
  invocationConfig,
  aggregate,
  pieces
)
function aggregateOffer(
  conf: InvocationConfig,
  aggregate: Piece, // Filecoin piece representing aggregate
  pieces: Piece[],  // Filecoin pieces part of the aggregate (sorted)
): Promise<Receipt>

More information: InvocationConfig

Dealer.aggregateAccept

The aggregate/accept task is an effect linked from successful execution of a aggregate/offer task, it is executed to issue a receipt for the success or failure of the task.

A receipt for successful execution indicates that an aggregate has been accepted for inclusion in a Filecoin deal. In this case the receipt will contain proofs that the piece was included in an aggregate and deal.

Otherwise the task is failed and the receipt will contain details of the reason behind the failure, as well as multiple effects, linking to piece/offer tasks that will retry valid pieces and complete asynchronously.

import { Dealer } from '@web3-storage/filecoin-client'

const res = await Dealer.aggregateAccept(
  invocationConfig,
  aggregate,
  pieces
)
function aggregateAccept(
  conf: InvocationConfig,
  aggregate: Piece, // Filecoin piece representing aggregate
  pieces: Piece[],  // Filecoin pieces part of the aggregate (sorted)
): Promise<Receipt>

More information: InvocationConfig

DealTracker.dealInfo

The deal/info task can be executed to request deal information for a given piece. It issues a signed receipt of the execution result.

A receipt for successful execution will contain details of deals the provided piece CID is currently active in.

Otherwise the task is failed and the receipt will contain details of the reason behind the failure.

import { DealTracker } from '@web3-storage/filecoin-client'

const add = await DealTracker.dealInfo(
  invocationConfig,
  piece
)
function dealInfo(
  conf: InvocationConfig,
  piece: Piece, // Filecoin piece to check
): Promise<Receipt>

More information: InvocationConfig

Types

InvocationConfig

This is the configuration for the UCAN invocation. It is an object with issuer, audience, resource and proofs:

  • The issuer is the signing authority that is issuing the UCAN invocation(s).
  • The audience is the principal authority that the UCAN is delegated to.
  • The resource (with field) points to a storage space.
  • The proofs are a set of capability delegations that prove the issuer has the capability to perform the action. These might not be required.

Contributing

Feel free to join in. All welcome. Please open an issue!

License

Dual-licensed under MIT + Apache 2.0