https://github.com/elsehow/signal-stream
encrypt and decrypt streams with signal-protocol
https://github.com/elsehow/signal-stream
Last synced: 8 months ago
JSON representation
encrypt and decrypt streams with signal-protocol
- Host: GitHub
- URL: https://github.com/elsehow/signal-stream
- Owner: elsehow
- License: bsd-3-clause
- Created: 2016-12-17T00:22:32.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-12-20T17:18:30.000Z (over 9 years ago)
- Last Synced: 2025-04-11T21:48:09.944Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 1.85 MB
- Stars: 8
- Watchers: 5
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: contributing.md
- License: LICENSE
Awesome Lists containing this project
README
# signal-stream
```
npm install signal-stream
```
encrypt and decrypt streams
using the [signal-protocol](https://github.com/elsehow/signal-protocol)
[](https://travis-ci.org/elsehow/signal-protocol)
## example
```javascript
var signalstream = require('signal-stream')
var signal = require('signal-protocol')
var h = require('signal-stream/test/helpers')(signal)
h.bobAliceSessionCiphers()
.then(([aliceCipher, bobCipher]) => {
let alice = signalstream(aliceCipher)
let bob = signalstream(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()))
})
})
//
// The World Wide Web project
// ...
```
see `examples/` for more.
## api
### signalstream(sessionCipher, opts)
returns an object `{ encrypt, decrypt }`.
`encrypt` is a transform stream that consumes (plaintext) buffers and produces (encrypted) ciphertext objects (refer to [signal-protocol](https://github.com/elsehow/signal-protocol) for details).
`decrypt` is a transform stream that consumes signal-protocol's ciphertext objects and produces plaintext buffers.
the default `opts` are
```js
{
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`).
## license
BSD