🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

@storacha/blob-index

Package Overview
Dependencies
Maintainers
3
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@storacha/blob-index

An index for slices that may be sharded across multiple blobs.

1.1.0
latest
Source
npm
Version published
Weekly downloads
923
37.97%
Maintainers
3
Weekly downloads
 
Created
Source

@storacha/blob-index

An index for slices that may be sharded across multiple blobs.

Install

npm install @storacha/blob-index

Usage

Create:

import { ShardedDAGIndex } from '@storacha/blob-index'

// Create a brand new index
const index = ShardedDAGIndex.create(rootCID)

// Add index data for slices within a shard
index.setSlice(shardMultihash, sliceMultihash, [offset, length])
// ...

// Create CAR archive
const result = index.archive()

console.log(result.ok) // a Uint8Array

Read:

import { ShardedDAGIndex } from '@storacha/blob-index'
import { base58btc } from 'multiformats/bases/base58'

const index = ShardedDAGIndex.extract(car)

console.log(index.content)

for (const [shard, slices] of index.shards.entries()) {
  console.log(`Shard ${base58btc.encode(shard.bytes)}`)
  console.log('  Slices:')
  for (const [slice, [offset, length]] of slices.entries()) {
    console.log(`    ${base58btc.encode(slice.bytes)} @ ${offset} -> ${offset + length}`)
  }
}

// Output:
// Shard zQmQKw6B745GGL3eeTcEE5kAoLAJgkBQydJPC5fWv5HA68A
//  Slices:
//    zQmeHPRNRDxHU5YMPewcBCbPYxzA3jBcadAZQwpQXm3jFFt @ 96 -> 128
// ...

Contributing

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

License

Dual-licensed under MIT + Apache 2.0

FAQs

Package last updated on 28 May 2025

Did you know?

Socket

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.

Install

Related posts