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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@borderlessdev/filecoin-storage-sdk

v1.0.0

Published

Comprehensive Filecoin storage SDK with Synapse integration. Simplifies decentralized file storage on Filecoin with wallet management, upload/download, and IPFS pinning.

Readme

Filecoin Storage SDK

A comprehensive JavaScript/TypeScript SDK for decentralized file storage on Filecoin using Synapse Protocol. Simplify Filecoin integration with easy-to-use methods for uploading, downloading, and managing files on the decentralized web.

Features

  • 📁 Multi-format Support: Upload files, images, JSON data, and more
  • 🔐 Wallet Integration: Seamless USDFC deposit and service approval
  • 🌐 Multi-network: Support for Filecoin mainnet and calibration testnet
  • 📍 IPFS Pinning: Automatic Pinata integration for gateway access
  • CDN Enabled: Fast retrievals with built-in content delivery
  • 🛡️ Type Safety: Full TypeScript support with comprehensive types
  • 🔍 File Management: Check file existence, get storage info, and monitor balances
  • 🎯 Error Handling: Robust error handling with detailed logging

Installation

npm install @borderlessdev/filecoin-storage-sdk

Quickstart

nodejs usage

import fileStorage from '@borderlessdev/filecoin-storage-sdk';
import { config } from "dotenv";
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';

// Load environment variables
config();

console.log("PRIVATE_KEY:", process.env.PRIVATE_KEY ? "Loaded" : "Missing");

// Fix __dirname in ES modules
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

async function main() {
  try {
    // Initialize with private key
    await fileStorage.initialize({
      privateKey: process.env.PRIVATE_KEY,
      network: 'calibration' // Filecoin testnet
    });

    // ---------- Upload JSON ----------
    const jsonPath = path.resolve(__dirname, 'files/my-data.json');
    if (fs.existsSync(jsonPath)) {
      let jsonBuffer = fs.readFileSync(jsonPath);

      // Ensure minimum size of 1 byte
      if (jsonBuffer.length < 1) {
        const padding = Buffer.alloc(1 - jsonBuffer.length, " ");
        jsonBuffer = Buffer.concat([jsonBuffer, padding]);
      }

      const jsonResult = await fileStorage.uploadFile(jsonBuffer, 'my-data.json');
      console.log('✅ JSON uploaded:', jsonResult);

      // ---------- Download JSON ----------
      const downloadedJSON = await fileStorage.downloadJSON(jsonResult.pieceCid);
      console.log('📥 Downloaded JSON:', downloadedJSON);
    } else {
      console.warn("⚠️ my-data.json not found in examples/files/, skipping JSON upload");
    }

    // ---------- Upload an image ----------
    const imagePath = path.resolve(__dirname, 'files/image.png');
    if (fs.existsSync(imagePath)) {
      const imageBuffer = fs.readFileSync(imagePath);
      const imageResult = await fileStorage.uploadFile(imageBuffer, 'image.png');
      console.log('✅ Image uploaded:', imageResult);
    } else {
      console.warn("⚠️ image.png not found in examples/files/, skipping image upload");
    }

    // ---------- Get storage info ----------
    try {
      const info = await fileStorage.getStorageInfo();
      console.log('ℹ️ Storage info:', info);
    } catch (err) {
      console.error("⚠️ Could not fetch storage info:", err.message);
    }

  } catch (error) {
    console.error('❌ Error:', error);
  }
}

main();