secure-rpc-protocol
Secure rpc-protocol over any duplex socket using noise protocol
Last updated a year ago by bret .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install secure-rpc-protocol 
SYNC missed versions from official npm registry.

secure-rpc-protocol

Actions Status

Secure rpc-protocol over any duplex socket using noise-protocol.

Installation

npm install secure-rpc-protocol

Usage

// client.js
const secureRPC = require('secure-rpc-protocol')
const net = require('net')

const socket = new net.Socket()

socket.connect(8124, () => {
  const rpc = secureRPC(socket, true)

  rpc.call('echo', 'hello world', (err, res) => {
    if (err) return console.error(err)
    console.log(res) // [ 'hello world' ]
  })
})
// server.js
const net = require('net')
const secureRPC = require('secure-rpc-protocol')

const server = net.createServer((socket) => {
  const rpc = secureRPC(socket, false)

  rpc.command('echo', (req) => {
    console.log(req.arguments)
    return req.arguments
  })
})

server.listen(8124, () => {
  console.log('server listening on 8124')
})

API

secureRPC = require('secure-rpc-protocol')

Import the secureRPC factory function used to create a secureRPC instance.

peer = secureRPC.peer

Access to noise-peer. Useful for accessing peer.keygen.

rpc = secureRPC(stream, isInitiator, [opts])

Pass in a duplex stream and indicate if the stream isInitiator according to what noise-protocol being used.

The opts object is passed to noise-peer with the exception of the encoder property, which is passed to rpc-protocol.

See rpc-protocol docs on how to use the rpc api.

See noise-peer and noise-protocol and the included examples to understand the details of securing the connection.

Examples

See also

License

MIT

Current Tags

  • 1.0.2                                ...           latest (a year ago)

2 Versions

  • 1.0.2                                ...           a year ago
  • 1.0.1                                ...           a year ago
Maintainers (2)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (2)
Dev Dependencies (5)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |