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-content-stream

v3.0.0

Published

Scuttlebutt stream of messages and off-chain content.

Downloads

6

Readme

ssb-content-stream

Scuttlebutt stream of both messages and off-chain content.

This plugin exposes a method that wraps createHistoryStream and returns all off-chain content referenced by those messages. This gives us the ability to do deletion and feed replication without using the blob system.

Table of Contents

Install

npm install ssb-content-stream

Usage

const server = require('ssb-server')
  .use(require('ssb-master'))
  .use(require('./'))

const config = Object.assign({}, require('ssb-config'), {
  keys: require('ssb-keys').generate() // Random key for testing!
})

const ssb = server(config)

ssb.contentStream.publish({ type: 'test', randomNumber: 42 }, (err, msg) => {
  if (err) throw err
  console.log(msg)
})
{ key: '%hK2+Ed0KJlJ5kR4IbvEs3GZywPJ3GWyyWjsCgsuhtO8=.sha256',
  value:
   { previous: null,
     sequence: 1,
     author: '@MJ+WR+PF/6QPnzN2ef2XyhRNSBIWsx0T45ZAffEcEPk=.ed25519',
     timestamp: 1559086953009,
     hash: 'sha256',
     content:
      { type: 'content',
        href:
         'ssb:content:sha256:rWqRaMb0dfFmss2xan936taWQFfJ_1GGOeckZrFUit8=',
        mediaType: 'text/json' },
     signature:
      'lcCJSMl1cDHr85m8u0WjhZl/DjOENOCzTsH58Jqo2RpQ0AKoGlQVoEC+nwRIStvfz58tbvCIt+ilEOyYxb2rAg==.sig.ed25519' },
  timestamp: 1559086953010 }

API

createSource(opts)

Wrapper for createHistoryStream that prepends all off-chain content to the stream. Since createHistoryStream only returns public and unencrypted messages this function will only return public messages and its content.

createHandler(cb)

Creates a through-stream that filters content out of the stream, adds them to the content store, and only passes the original metadata message through the stream.

getContent(msg, cb)

Takes a full message ({ key, value: { previous, sequence, ... } }) and returns the extracted content from that message in msg.value.content as if it wasn't a message with off-chain content.

getContent(opts)

Passes createSource() through createHandler() and getContent().

publish(content, cb)

Wraps ssb.publish to publish off-chain messages that can be accessed with content streams. Message schema is:

{
  "href": "ssb:content:sha256:rWqRaMb0dfFmss2xan936taWQFfJ_1GGOeckZrFUit8=",
  "mediaType": "text/json",
  "type": "content"
}

Maintainers

@fraction

Contributing

PRs accepted.

License

ISC © 2019 Fraction LLC