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

envelope-js

v1.3.2

Published

new private message format for ssb

Downloads

353

Readme

envelope-js

A javascript tool for cryptographically "boxing" and "unboxing" messages following the envelope spec.

envelope supports encryption to individuals and groups

Example Usage

var { box, unbox, CloakedMsgId } = require('envelope-js')

...

API

box(plain_text, feed_id, prev_msg_id, msg_key, recp_keys) => ciphertext

where:

  • plain_text Buffer is the content to be "enveloped"
  • feed_id Buffer is a type-format-key (TFK) encoded value for the feed authoring a message
  • prev_msg_id Buffer is a TFK encoded value of the id of last message of this feeds chain
  • msg_key Buffer a randomised 32 Bytes which will be the unique key for this message
  • recps_keys Array is a collection of items of form { key, scheme }, where
    • key Buffer is the key the particular recipient
    • scheme String|Buffer is the type of key / the key management scheme for this recipient

unbox(ciphertext, feed_id, prev_msg_id, trial_keys, max_attempts) => plain_text | null

where:

  • ciphertext Buffer is envelope
  • feed_id Buffer is a type-format-key (TFK) encoded value for the feed authoring a message
  • prev_msg_id Buffer is a TFK encoded value of the id of last message of this feeds chain
  • trial_keys Array is a collection of items of form { key, scheme }, where
    • key Buffer is the key the particular recipient
    • scheme String|Buffer is the type of key / the key management scheme for this recipient
  • max_attempts Integer (default: 8) how many key_slots you want to assume the envelope has
  • plain_text Buffer the envelope contents

NOTE: we also expose unboxKey and unboxBody for convenience.

DeriveSecret(feed_id, prev_msg_id) => derive

Used for taking a msg_key (the one-time key for a particular envelope) and deriving other keys used in the envelope (e.g. read_key)

where:

  • feed_id Buffer is a TFK encoded id for the feed the envelope is part of
  • prev_msg_id Buffer is a TFK encoded id for the message prior to one where our envelope is
    • NOTE if this is the first message, then the K part of prev_msg_id's TFK is a zero-filled Buffer.
  • derive(key, labels) => new_key function where:
    • key Buffer is a seed key which we're going to derive from
    • labels Array is a an array of Strings which help define a derivation

new CloakedMsgId(public_msg_id, read_key) => cloakedMsgId

Determine a cloaked message id for a published message following the envelope-spec/cloaked_msg_id/README.md

where:

  • public_msg_id Buffer is the id of a enveloped message that's been published (it has an id as it's part of a feed / chain)
  • read_key Buffer is the read capability (NOT the msg_key) for this message envelope
  • cloakedMsgId is an instance with methods:
    • toBuffer() => Buffer which returns the cloaked id key as a Buffer
    • toString(encoding) => String which returns the cloaked id key as a Buffer (encoding defaults to 'base64')
    • mock() => cloakedMsgId a method for testing. populates the id with random content. if using this, instantiate with no args.

slp.encode(info) => Buffer

where info is an Array of Buffers.

This is "short length-prefixed encoding", see https://github.com/ssbc/envelope-spec/blob/master/encoding/slp.md

...

License

MIT