noise-network
Authenticated network P2P backed by HyperSwarm and NOISE
Usage
First spin up a server
const noise = require('noise-network')
const server = noise.createServer()
server.on('connection', function (encryptedStream) {
console.log('new encrypted stream!')
encryptedStream.on('data', function (data) {
console.log('client wrote:', data)
})
})
const keyPair = noise.keygen()
server.listen(keyPair, function () {
console.log('Server is listening on:', server.publicKey.toString('hex'))
})
Then connect to the server by connecting to the public key
const client = noise.connect('{public key from above}')
client.write('hello server')
API
const server = noise.createServer([options])
Create a new NOISE server.
Options include:
{
validate (remoteKey, done) { ... },
onconnection (connection) { ... }
}
const client = noise.connect(serverPublicKey, [keyPair])
Connect to a server. Does UDP hole punching if necessary.
serverPublicKey must be of type Buffer or hex.
License
MIT