How to use ssb-config - 5 common examples

To help you get started, we’ve selected a few ssb-config 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 stripedpajamas / scat / util / client / index.js View on Github external
const tryConnect = (cb) => {
  retriesRemaining--
  // Check if sbot/scutlle-shell is already running
  client(config.keys, config, (err, sbot) => {
    // err implies no server currently running
    if (err) {
      // start scuttle shell if haven't already tried starting it
      if (!started) {
        server = child.fork(path.resolve(__dirname, './start'), {
          stdio: [
            'ignore',
            'ignore',
            'ignore',
            'ipc'
          ]
        })
        server.send({ config })
        started = true
      }
    }
github stripedpajamas / scat / util / client / index.js View on Github external
const path = require('path')
const child = require('child_process')
const config = require('ssb-config')
const ssbKeys = require('ssb-keys')
const client = require('ssb-client')

config.keys = ssbKeys.loadOrCreateSync(path.join(config.path, 'secret'))

let retriesRemaining = 5
let server
let started = false

const tryConnect = (cb) => {
  retriesRemaining--
  // Check if sbot/scutlle-shell is already running
  client(config.keys, config, (err, sbot) => {
    // err implies no server currently running
    if (err) {
      // start scuttle shell if haven't already tried starting it
      if (!started) {
        server = child.fork(path.resolve(__dirname, './start'), {
          stdio: [
            'ignore',
github ssbc / ssb-tunnel / examples / browser / index.js View on Github external
function reconnect () {
    if(timer) return
    console.error('waiting to reconnect')
    timer = setTimeout(function () {
      timer = null
      connect()
    }, 500 + Math.random() * 1000)

  }

  PortalClient(
    keys,
    {
    remote: portal,
    caps: config.caps,
    manifest: {
      tunnel: {connect: 'duplex'}
    }
  }, function (err, rpc) {
    if(err) {
      console.error(err)
      return reconnect()
    }
    console.error('connecting to tunnel:', target)
    var stream = rpc.tunnel.connect({
      target: '@'+target.split(':').pop()+'.ed25519',
      port: 0
    })
    pull(
      stream.source,
      Client(toBuffer(target.split(':').pop()), function (err, stream) {
github ssbc / ssb-tunnel / examples / browser / index.js View on Github external
}

//var portal = process.argv[2]
//var target = process.argv[3]

function toSodiumKeys(keys) {
  if(!keys || !keys.public) return null
  console.log(keys)
  return {
    publicKey: toBuffer(keys.public),
    secretKey: toBuffer(keys.private)
  }
}
console.log('target:', target)
console.log('keys:', keys)
var Client = TunnelClient(toSodiumKeys(keys), toBuffer(config.caps.shs), timeout)

var timer
;(function connect () {
  console.error('connecting to portal:', portal)

  function reconnect () {
    if(timer) return
    console.error('waiting to reconnect')
    timer = setTimeout(function () {
      timer = null
      connect()
    }, 500 + Math.random() * 1000)

  }

  PortalClient(
github soapdog / patchfox / src / inject.js View on Github external
return new Promise((resolve, reject) => {
        client(data.keys, {
            remote: data.remote,
            caps: config.caps,
            manifest: data.manifest
        }, (err, s) => {

            if (err) {
                reject("Connecting to sbot, <a href="\&quot;#/setup\&quot;">go back to setup</a> and check your settings. Also, make sure <i>sbot</i> is running (is scuttle-shell icon appearing on your machine?).");
            } else {
                resolve({sbot: s, remote: data.remote, keys: data.keys, manifest: data.manifest});
            }
        });
    });
};

ssb-config

load ssb config

MIT
Latest version published 3 years ago

Package Health Score

52 / 100
Full package analysis