Skip to content

elsehow/signal-stream

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

signal-stream

npm install signal-stream

encrypt and decrypt streams using the signal-protocol

Build Status

example

var sigstream = require('signal-stream')
var signal = require('signal-protocol')
var h = require('signal-stream/test/helpers')(signal)

h.bobAliceSessionCiphers()
  .then(([aliceCipher, bobCipher]) => {
    let alice = sigstream(aliceCipher)
    let bob = sigstream(bobCipher)
    require('http')
      .get({
        hostname:'info.cern.ch',
        path: '/hypertext/WWW/TheProject.html',
      }, res => {
        res
          .pipe(alice.encrypt)
          .pipe(bob.decrypt)
          .pipe(bob.encrypt)
          .pipe(alice.decrypt)
          .on('data', d =>
              console.log(d.toString()))
      })
  })
  
// <HEADER>
// <TITLE>The World Wide Web project</TITLE>
// ...

see examples/ for more.

api

require('signal-stream')(sessionCipher, opts)

returns an object { encrypt, decrypt }.

encrypt is a transform stream that takes buffers and produces signal-protocol ciphertext objects (refer to signal-protocol for details).

decrypt is a transform stream that takes ciphertext objects and produces buffers.

the default opts are

{
  jsonIn: false,
  jsonOut: false,
}

setting these to true can be helpful if you need to (de-)serialize the objects produced by signal-protocol's encrypt, e.g. to send over a websocket or a network. (see examples/net.js for an example).

license

BSD

About

encrypt and decrypt streams with signal-protocol

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published