🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

key-collection

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

key-collection

Hyperdb-based collection of 32-byte keys

latest
Source
npmnpm
Version
2.0.1
Version published
Weekly downloads
1
-94.44%
Maintainers
1
Weekly downloads
 
Created
Source

Key Collection

A hyperdb-based collection of 32-byte keys.

Install

npm i -g key-collection

Usage

Create

key-collection sync <location>

Where <location> is the path of a yaml file structured like example.yml.

This will first sync the database with the yaml file, deleting and adding entries as required, and then seed the database.

Consume

const KeyCollection = require('key-collection')
const Corestore = require('corestore')
const Hyperswarm = require('hyperswarm')
const IdEnc = require('hypercore-id-encoding')

async function main () {
  const key = IdEnc.decode('your key here') // Fill in with the public key of the collection db, as printed in the previous step

  const store = new Corestore('key-collection-store')
  const core = store.get({ key })
  const keyColl = new KeyCollection(core)
  await keyColl.ready()

  const swarm = new Hyperswarm()
  swarm.on('connection', (conn) => {
    console.log('connection opened')
    store.replicate(conn)
  })

  swarm.join(keyColl.discoveryKey, { client: true, server: false })
  console.log(await keyColl.toMap()) // Note: will print an empty map the first time it runs, because it hasn't synced with the server yet
}

main()

Keywords

key

FAQs

Package last updated on 17 Dec 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