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

ssb-db2-box2

v0.7.0

Published

Box2 support for SSB DB2

Downloads

6

Readme

SSB-DB2-Box2

A module for working with box2 in SSB DB2. Messages created using this module is compatible with ssb-tribes.

Usage

Encrypt a message to self using box2.

const SecretStack = require('secret-stack')
const caps = require('ssb-caps')
const ssbKeys = require('ssb-keys')

const keys = ssbKeys.loadOrCreateSync(path.join(dir, 'secret'))

const sbot = SecretStack({ caps })
  .use(require('ssb-db2'))
  .use(require('ssb-db2-box2'))
  .call(null, { 
     path: './',
     keys,
     box2: {
       alwaysbox2: true
     }
  })

const testkey = Buffer.from(
  '30720d8f9cbf37f6d7062826f6decac93e308060a8aaaa77e6a4747f40ee1a76',
  'hex'
)

sbot.box2.addOwnDMKey(testkey)
sbot.box2.setReady()

let content = { type: 'post', text: 'super secret', recps: [keys.id] }

sbot.db.publish(content, (err, privateMsg) => {
  // privateMsg is now encrypted using box2
})

Configuration

SSB-DB2-BOX2 supports ssb-config parameters to configure things:

const config = {
  box2: {
    /*
      This variable is only for DMs. Group messages are always using box2.
      For DMs, the problem is figuring out if the other side supports 
      box2 or not. We expect to be able to use metafeeds to determine this
      in the future. For now you can use this variable to use box2 for all
      DMs, otherwise box1 will be used for all.
    */
    alwaysbox2: true
  }
}

Methods

addOwnDMKey(key)

key must be a buffer. By specifying the direct message (DM) for yourself, you are free to supply that from any source. This could be a key stored in ssb-keyring, a key derived from the seed in meta feeds or simply a temporary key. For direct messaging other feeds a key is automatically derived.

registerIsGroup(filter)

filter takes a recp and must return a boolean indicating if recp is a group id or not.

addGroupKey(groupId, groupKey)

groupId must be a string and groupKey must be a buffer. The key can then be used to send messages to the group. Note that keys are not persisted in this module.

getGroupKey(groupId)

Returns the groupKey as a buffer or undefined if group key is not found.

setReady()

On startup, once all keys have been added be sure to call setReady to signal to DB2 that it is now safe to process data.

isReady(cb)

cb will resolve once once all initial keys have been added.