Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

little-network-box

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

little-network-box

A little toolkit for distributed applications.

  • 0.0.3
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

little-box

A little toolkit for distributed applications based on Hypercore.

Installation

$ npm install jwerle/little-box # from github for now

Status

WIP

Example

const { Origin, Sink, storage } = require('little-box')
const pump = require('pump')
const path = require('path')
const ram = require('random-access-memory')
const raf = require('random-access-file')
const fs = require('fs')

const video = path.resolve(__dirname, 'video.mp4')
const copy = path.resolve(__dirname, 'copy.mp4')
const origin = new Origin(ram)

origin.ready(() => {
  const input = origin.createWriteStream()
  const video = fs.createReadStream(video, { highWaterMark: 1024 })
  const sink = new Sink(storage.sink(copy), origin.key, {
    encryptionKey: origin.encryptionKey,
    nonce: origin.nonce
  })

  pump(video, input, (err) => {
    sink.on('sync', ()=> {
      if (sink.byteLength === origin.byteLength) {
        console.log('sync')
        sink.close()
        origin.close()
        process.nextTick(process.exit)
      }
    })
  })
})

API

Below is the documentation for the modules, classes, functions, and constants little-box exports publically.

Box(storage, key, options)

TBA

const { Box, codecs, hooks } = require('little-box')
const ready = require('hypercore-ready')

const nonce = crypto.randomBytes(24)
const box = new Box('./path/to/box', {
  nonce, codec: codecs.xsalsa20
})

box.ready(() => {
  const vault = new Box('./path/to/secure/vault', box.key)
  const message = Buffer.from('hello')
  const unboxed = new Box('./path/to/unboxed', {
    nonce, hooks: [ hooks.xsalsa20 ]
  })

  box.append(message, () => {
    box.head(console.log) // hello
  })

  box.update(() => {
    ready(vault, unbox, () => {
      replicate(box, vault, () => {
        vault.head(console.log) // <ciphertext>
        replicate(vault, unbox, () => {
          unbox.head(console.log) // hello
        })
      })
    })
  })
})

Node(storage, key, options)

TBA

Edge(storage, key, options)

TBA

Origin(storage, key, options)

TBA

Reader(storage, key, options)

TBA

Receive(storage, key, options)

TBA

Send(storage, key, options)

TBA

Network(opts)

TBA

replicate(...boxes[, options[, callback]])

TBA

codecs

TBA

codecs.xsalsa20

TBA

hooks

TBA

hooks.xsalsa20

TBA

storage

TBA

storage.sink

TBA

License

MIT

FAQs

Package last updated on 09 Oct 2019

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc