How to use secret-stack - 10 common examples

To help you get started, we’ve selected a few secret-stack 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-server / test / caps.js View on Github external
var tape    = require('tape')
var ssbKeys = require('ssb-keys')

// create 3 servers
// give them all pub servers (on localhost)
// and get them to follow each other...

var createSsbServer =
  require('secret-stack')(require('./defaults'))
    .use(require('ssb-db'))
    .use(require('ssb-replicate'))
    .use(require('ssb-friends'))
    .use(require('ssb-gossip'))
    .use(require('ssb-logging'))

var createHash = require('crypto').createHash

function hash (data) {
  return createHash('sha256').update(data, 'utf8').digest()
}

var sign_cap1 = hash('test-sign-cap1')
var shs_cap1 = hash('test-shs-cap1')

var dbA = createSsbServer({
github ssbc / ssb-friends / test / friends-indirect.js View on Github external
var ssbKeys = require('ssb-keys')
var cont    = require('cont')
var tape    = require('tape')
var u       = require('./util')
var pull    = require('pull-stream')
var crypto  = require('crypto')

// create 3 feeds
// add some of friend edges (follow, flag)
// make sure the friends plugin analyzes correctly

var createSsbServer = require('secret-stack')({
    caps: {shs: crypto.randomBytes(32).toString('base64')}
  })
  .use(require('ssb-db'))
  .use(require('ssb-replicate'))
  .use(require('..'))


function sort (ary) {
  return ary.sort(function (a, b) {
    return a.id < b.id ? -1 : a.id === b.id ? 1 : 0
  })
}

function liveFriends(ssbServer) {
  var live = {}
  pull(
github ssbc / ssb-friends / test / friends-delete.js View on Github external
var ssbKeys = require('ssb-keys')
var cont    = require('cont')
var tape    = require('tape')
var u       = require('./util')
var pull    = require('pull-stream')
var crypto  = require('crypto')

// create 3 feeds
// add some of friend edges (follow, flag)
// make sure the friends plugin analyzes correctly

var createSsbServer = require('secret-stack')({
    caps: {shs: crypto.randomBytes(32).toString('base64')}
  })
  .use(require('ssb-db'))
  .use(require('ssb-replicate'))
  .use(require('..'))

function liveFriends(ssbServer) {
  var live = {}
  pull(
    ssbServer.friends.createFriendStream({live: true, meta: true}),
    pull.drain(function (friend) {
      if(friend.sync) return
      live[friend.id] = friend.hops
    })
  )
  return live
github ssbc / ssb-ebt / test / block.js View on Github external
var cont = require('cont')
var tape = require('tape')
var pull = require('pull-stream')
var ssbKeys = require('ssb-keys')
var u = require('./util')
var crypto = require('crypto')

var createSsbServer = require('secret-stack')({
    caps: {shs: crypto.randomBytes(32).toString('base64')}
  })
  .use(require('ssb-db'))
  .use(require('ssb-replicate'))
  .use(require('ssb-friends'))
  .use(require('..'))

function once (fn) {
  var called = 0
  return function () {
    if(called++) throw new Error('called :'+called+' times!')
    return fn.apply(this, arguments)
  }
}

// alice, bob, and carol all follow each other,
github ssbc / ssb-server / test / plugins.js View on Github external
var ssbKeys = require('ssb-keys')
var tape    = require('tape')
var u       = require('./util')
var pull    = require('pull-stream')
var osenv   = require('osenv')
var path    = require('path')
var fs      = require('fs')
var createSsbServer = 
  require('secret-stack')(require('./defaults'))
    .use(require('ssb-db'))

var initialPlugins = createSsbServer.plugins.slice()
function resetSsbServer () {
  createSsbServer.plugins = initialPlugins.slice()
  createSsbServer.use(require('../plugins/plugins'))
}

tape('install and load plugins', function (t) {

  var aliceKeys = ssbKeys.generate()
  var datadirPath = path.join(osenv.tmpdir(), 'test-plugins1')

  t.test('install plugin', function (t) {

    resetSsbServer()
github ssbc / ssb-friends / test / hops.js View on Github external
var pull = require('pull-stream')
var tape = require('tape')
var series = require('run-series')
var crypto  = require('crypto')

var createSbot = require('secret-stack')({
    caps: {shs: crypto.randomBytes(32).toString('base64')}
  })
  .use(require('ssb-db'))
  .use(require('ssb-replicate'))
  .use(require('..'))

var botA = createSbot({
  temp: 'alice',
  port: 45451,
  host: 'localhost',
  timeout: 20001,
  replicate: {
    hops: 2,
    legacy: false
  }
})
github ssbc / ssb-friends / test / sbot.js View on Github external
var pull = require('pull-stream')
var tape = require('tape')
var crypto  = require('crypto')

var createSbot = require('secret-stack')({
    caps: {shs: crypto.randomBytes(32).toString('base64')}
  })
  .use(require('ssb-db'))
  .use(require('ssb-replicate'))
  .use(require('..'))

var botA = createSbot({
  temp: 'alice',
  port: 45451,
  host: 'localhost',
  timeout: 20001,
  replicate: {
    hops: 100,
    legacy: false
  }
})
github ssbc / ssb-friends / test / friends.js View on Github external
var ssbKeys = require('ssb-keys')
var cont    = require('cont')
var tape    = require('tape')
var u       = require('./util')
var pull    = require('pull-stream')
var crypto  = require('crypto')

var createSsbServer = require('secret-stack')({
    caps: {shs: crypto.randomBytes(32).toString('base64')}
  })
  .use(require('ssb-db'))
  .use(require('ssb-replicate'))
  .use(require('..'))

function sort (ary) {
  return ary.sort(function (a, b) {
    return a.id < b.id ? -1 : a.id === b.id ? 1 : 0
  })
}

function liveFriends(ssbServer) {
  var live = {}
  pull(
    ssbServer.friends.createFriendStream({live: true, meta: true}),
github ssbc / ssb-server / test / master.js View on Github external
var tape = require('tape')
//var util = require('../lib/util')
var ssbKeys = require('ssb-keys')
var ssbClient = require('ssb-client')

var aliceKeys = ssbKeys.generate()
var bobKeys   = ssbKeys.generate()
var carolKeys = ssbKeys.generate()

var createSsbServer = 
  require('secret-stack')(require('./defaults'))
    .use(require('ssb-db'))
  .use(require('../plugins/master'))
var caps = {
  shs: require('crypto').randomBytes(32).toString('base64')
}

var alice = createSsbServer({
  port: 45451, timeout: 2001,
  temp: 'master',
  host: 'localhost',
  master: bobKeys.id,
  keys: aliceKeys,
  caps: caps
})

tape('connect remote master', function (t) {
github ssbc / ssb-ebt / test / index.js View on Github external
var cont   = require('cont')
var pull   = require('pull-stream')
var crypto = require('crypto')

  var createSbot = require('secret-stack')({
    caps: {shs: crypto.randomBytes(32).toString('base64')}
  })
  .use(require('ssb-db'))
  .use({
    //fake replicate plugin
    name: 'replicate',
    init: function () {
      return {request: function () {}}
    }
  })
  .use(require('../')) //EBT

function Delay (d) {
  d = d || 100
  return pull.asyncMap(function (data, cb) {
    setTimeout(function () {

secret-stack

create secure peer to peer networks using secret-handshakes

MIT
Latest version published 10 months ago

Package Health Score

59 / 100
Full package analysis

Popular secret-stack functions

Similar packages