How to use ssb-server - 10 common examples

To help you get started, we’ve selected a few ssb-server examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ssbc / ssb-config / tests / server-startup.js View on Github external
var test = require('tape')
var Client = require('ssb-client')
var home = require('os-homedir')()
var Server = require('ssb-server')
  .use(require('ssb-server/plugins/master'))

var Defaults = require('../defaults')
var Config = require('../inject')

if (process.env.SKIP_SERVER) {
  console.log('\n!! skipping server startup tests\n')
  return 
}

test('Server startup - default config', t => {
  // NOTE: ideally would use index.js, but maybe on a system with ~/.ssb/config,
  // this simulates a clean setup by side-stepping RC
  const defaultConfig = Defaults('ssb')

  t.equal(defaultConfig.path, `${home}/.ssb`, 'has default ~/.ssb folder')
github ssbc / scuttle-shell / server.js View on Github external
let ssbAppName = appname || process.env.ssb_appname

  const config = require('ssb-config/inject')(ssbAppName, minimist(conf))

  const keys = ssbKeys.loadOrCreateSync(path.join(config.path, 'secret'))
  if (keys.curve === 'k256') {
    // i think this is _really_ old and could be removed
    throw new Error('k256 curves are no longer supported,' +
      'please delete' + path.join(config.path, 'secret'))
  }
  config.keys = keys
  ssbConfig = config

  const manifestFile = path.join(config.path, 'manifest.json')

  const createSbot = require('ssb-server')
    .use(require('ssb-local'))
    .use(require('ssb-logging'))
    .use(require('ssb-master'))
    .use(require('ssb-no-auth'))
    .use(require('ssb-unix-socket'))
    // who and how to peer
    .use(require('ssb-gossip'))
    .use(require('ssb-replicate'))
    .use(require('ssb-friends'))

    // old invites
    .use(require('ssb-invite'))

    // needed by device device-addrs
    .use(require('ssb-query'))
github ssbc / ssb-config / tests / server / index.js View on Github external
const fs = require('fs')
const Path = require('path')

const Server = require('ssb-server')
  .use(require('ssb-master'))

module.exports = function TestServer (config) {
  const server = Server(config)
  writeManifest(server)

  process.on('message', msg => {
    if (msg.action === 'CLOSE') {
      server.close(() => {
        console.log('CLOSING')
        process.send({ action: 'KILLME' })
      })
    }
  })

  server.whoami((err, data) => {
github ssbc / ssb-config / tests / server-default.js View on Github external
const Server = require('ssb-server')
  .use(require('ssb-server/plugins/master'))

const config = require('./server-default-config')

const server = Server(config)
writeManifest(server)

process.on('message', msg => {
  if (msg.action === 'CLOSE') {
    server.close(() => {
      process.send({ action: 'KILLME' })
    })
  }
})

server.whoami((err, data) => {
github ssbc / ssb-tunnel / test / private.js View on Github external
var crypto = require('crypto')
var Scuttlebot = require('ssb-server')
.use(require('ssb-gossip'))
.use(require('../'))
.use(require('ssb-query'))
.use(require('ssb-device-address'))
var tape = require('tape')

var ssbKeys = require('ssb-keys')

function hash (s) {
  return crypto.createHash('sha256').update(s).digest()
}

var a_keys = ssbKeys.generate(null, hash('alice'))
var b_keys = ssbKeys.generate(null, hash('bob'))
var c_keys = ssbKeys.generate(null, hash('carol'))
github ssbc / ssb-tunnel / test / private2.js View on Github external
var crypto = require('crypto')
var Scuttlebot = require('ssb-server')
.use(require('ssb-gossip'))
.use(require('../'))
.use(require('ssb-query'))
.use(require('ssb-device-address'))
var tape = require('tape')

Scuttlebot

var ssbKeys = require('ssb-keys')

function hash (s) {
  return crypto.createHash('sha256').update(s).digest()
}

var a_keys = ssbKeys.generate(null, hash('alice'))
var b_keys = ssbKeys.generate(null, hash('bob'))
github ssbc / ssb-ebt / test / legacy.js View on Github external
var cont = require('cont')
var pull = require('pull-stream')
var createSbot = require('ssb-server')
  .use({
    //fake replicate plugin
    name: 'replicate',
    init: function () {
      return {request: function () {}}
    }
  })
  .use(require('../')) //EBT

var ssbKeys   = require('ssb-keys')

var alice = ssbKeys.generate()
var bob = ssbKeys.generate()

var a_bot = createSbot({
  temp: 'random-animals',
github ssbc / ssb-tunnel / test / tunnel.js View on Github external
var crypto = require('crypto')
var Scuttlebot = require('ssb-server')
.use(require('ssb-gossip'))
.use(require('../'))
var tape = require('tape')

Scuttlebot

var ssbKeys = require('ssb-keys')

function hash (s) {
  return crypto.createHash('sha256').update(s).digest()
}

var a_keys = ssbKeys.generate(null, hash('alice'))
var b_keys = ssbKeys.generate(null, hash('bob'))
var c_keys = ssbKeys.generate(null, hash('carol'))
github ssbc / ssb-ooo / test / index.js View on Github external
var tape = require('tape')
var ssbKeys = require('ssb-keys')
var path = require('path')

var createSbot = require('ssb-server')
  .use(require('..'))

var alice = createSbot({
  temp: 'ooo_a',
  timeout: 1000,
  port: 34597,
  keys: ssbKeys.generate()
})
var bob = createSbot({
  temp: 'ooo_b',
  timeout: 1000,
  port: 34598,
  host: 'localhost',
  replicate: {hops: 3, legacy: false},
  keys: ssbKeys.generate()
})
github ssbc / ssb-ooo / test / timeout.js View on Github external
var tape = require('tape')
var ssbKeys = require('ssb-keys')
var path = require('path')
var rmrf = require('rimraf')

var createSbot = require('ssb-server')
  .use(require('..'))

var alice = createSbot({
  temp: 'ooo_a',
  timeout: 1000,
  port: 34597,
  keys: ssbKeys.generate()
})
var bob = createSbot({
  temp: 'ooo_b',
  timeout: 1000,
  port: 34598,
  keys: ssbKeys.generate()
})

tape('connect', function (t) {

ssb-server

network protocol layer for secure-scuttlebutt

MIT
Latest version published 4 years ago

Package Health Score

48 / 100
Full package analysis

Popular ssb-server functions

Similar packages