git ssb

2+

Dominic / ssb-client



Tree: c9612c202e02ee707d278a8a812b4f2e9b16b568

Files: c9612c202e02ee707d278a8a812b4f2e9b16b568 / README.md

799 bytesRaw

ssb-client v1

scuttlebot client


var SSBClient = require('ssb-client')
var SSBKeys = require('ssb-keys')

// desktop app:
var keys = SSBKeys.loadOrCreateSync('./app-private.key')

// web app:
var keys
try {
  keys = JSON.parse(localStorage.keys)
} catch (e) {
  keys = SSBKeys.generate()
  localStorage.keys = JSON.stringify(keys)
}

// connect:
var client = SSBClient({ host: 'localhost' })
  .connect(abortIf)
  .auth(SSBKeys.createAuth(keys), abortIf)

// post to feed:
var feed = client.createFeed(keys)
feed.add({
  type: 'post', text: 'hello, world!'
}, function (err, msg) {
  abortIf(err)
  console.log(msg)
  client.close()
})

function abortIf (err) {
  if(err) throw err
}

License

MIT, Copyright 2015 Paul Frazee and Dominic Tarr

Built with git-ssb-web