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 🙏

© 2025 – Pkg Stats / Ryan Hefner

web3.storage-lit-sdk

v0.1.29

Published

An integration of Web3 Storage and Lit Protocol

Readme

This module is based on the Lit Ceramic Integration Module

Thanks Lit Protocol for this great module!

https://github.com/LIT-Protocol/CeramicIntegration

Web3.Storage Lit Integration Module

Why?

Web3.Storage is amazing, but doesn't have read permissions on data. Everything is public. With the Lit Protocol, you can specify who is able to decrypt and therefore read data based on on-chain conditions. This module allows you to integrate Ceramic with Lit.

For example, you could use this to share fies and specify that only allowed wallets can decrypt the file stored in Web3.Storage.

Motivation

The goal of this project is to provide a decentralized fully serverless file sharing solution with the ability to easily share private data. Web3.Storage is a great solution for the decentralized serverless file storage, but it doesn't have the ability to share private data on it's own. This module will allow you to share private data on Web3.Storage with the ability to specify who can decrypt the data.

Installation

  1. yarn add web3.storage-lit-sdk
  2. cp .env.example .env
  3. Update WEB3STORAGE_TOKEN="" env var in .env with your Web3.Storage API Token

Usage

  1. Install as shown above
  2. Import into your TS/JS where you'd like to use it. This is a typescript package as an FYI.

Javascript requires minor amounts of extra work to use a Typescript project, here's an example of what that can look like, but there are plenty of good resources for this online.

import { Integration } from 'web3.storage-lit-sdk'

  1. Create a new Integration that runs upon startup and is accessible where you intend to do encryptAndWrite or readAndDecrypt operations. Pass your Ceramic RPC URL and the chain you wish to use: let web3StorageLitIntegration = new Integration("ethereum")
  2. Start the Lit Client when the DOM is loaded, or early on in the lifecycle: web3StorageLitIntegration.startLitClient(window)
  3. You'll need to define access control conditions for your data. This will govern who is able to decrypt and therefore read the data. The access control conditions variable should be an array of conditions and the user must satisify all of them (a boolean "AND" operation) to access the data. You can find examples of conditions here: https://developer.litprotocol.com/docs/SDK/accessControlConditionExamples

For example, this access control condition lets anyone who holds an NFT in the collection at 0x319ba3aab86e04a37053e984bd411b2c63bf229e on Ethereum to decrypt and read the data:

const accessControlConditions = [
  {
    contractAddress: '0x319ba3aab86e04a37053e984bd411b2c63bf229e',
    standardContractType: 'ERC721',
    chain,
    method: 'balanceOf',
    parameters: [
      ':userAddress'
    ],
    returnValueTest: {
      comparator: '>',
      value: '0'
    }
  }
]
  1. Use uploadFile to encrypt and write your file to Web3.Storage:
async function handleUpload() {
  const fileToEncrypt: HTMLInputElement = document.getElementById('uploadInput')
  if (fileToEncrypt.files.length == 0) {
    updateAlert('danger', `Error, please select a file to share`)
    return
  }
  const file: File = fileToEncrypt.files[0] 
  const encryptedFileCid = await web3StorageLitIntegration.uploadFile(file)
  console.log(encryptedFileCid)
}

Note that the fileToEncrypt is the file which we are encrypting in this example, which could be any file of any size. The uploadFile function returns a promise that contains the Web3.Storage CID of the content that was written. Note that you do need to save the CID somewhere in order to retrieve the data later on. You could use localStorage or a database, but you'll need to save the CID somewhere.

  1. Use retrieveAndDecryptFile to read your data from Web3.Storage and decrypt it:
async function retrieveFile(cid: string) {
  const unencryptedfileBlob = await web3StorageLitIntegration.retrieveAndDecryptFile(cid)
  saveData(unencryptedfileBlob, "test.txt")
  )
}

var saveData = (function () {
  var a = document.createElement("a");
  document.body.appendChild(a);
  a.style = "display: none";
  return function (data, fileName) {
      var blob = new Blob([data], {type: "octet/stream"}),
          url = window.URL.createObjectURL(blob);
      a.href = url;
      a.download = fileName;
      a.click();
      window.URL.revokeObjectURL(url);
  };
}())

This uses sample code will retrieve the file and trigger the download of that file.

EVM Contract Conditions

If you're using EVM Contract conditions instead of access control conditions, make sure you pass the optional 3rd parameter to encryptAndWrite of 'evmContractConditions':

const stringToEncrypt = 'This is what we want to encrypt on Lit and then store on ceramic'
const response = litCeramicIntegration
   .encryptAndWrite(stringToEncrypt, evmContractConditions, 'evmContractConditions')
   .then((streamID) => console.log(streamID))

API Docs

You can find API docs here

Example

You can find an example implementation here: https://github.com/Ghostshare/Web3.StorageLitIntegrationExample

More info

Want to do something more complex with the Lit Protocol or Web3.Storage? Check out the Lit JS SDK docs https://developer.litprotocol.com/docs/SDK/intro and the Web3.Storage docs https://web3.storage/docs