git ssb

16+

Dominic / patchbay



Tree: 1c2926f12ff8e365e1d469f23180b50d50b9c749

Files: 1c2926f12ff8e365e1d469f23180b50d50b9c749 / config.js

951 bytesRaw
1const nest = require('depnest')
2const Config = require('ssb-config/inject')
3const ssbKeys = require('ssb-keys')
4const Path = require('path')
5const merge = require('lodash/merge')
6
7const appName = process.env.ssb_appname || 'ssb'
8const opts = appName === 'ssb'
9 ? null
10 : null // require('./default-config.json')
11
12exports.gives = nest('config.sync.load')
13exports.create = (api) => {
14 var config
15 return nest('config.sync.load', () => {
16 if (!config) {
17 console.log('LOADING config')
18 config = Config(appName, opts)
19
20 const keys = ssbKeys.loadOrCreateSync(Path.join(config.path, 'secret'))
21 const pubkey = keys.id.slice(1).replace(`.${keys.curve}`, '')
22
23 config = merge(config, {
24 connections: {
25 incoming: { unix: [{ 'scope': 'local', 'transform': 'noauth' }] }
26 },
27 keys,
28 remote: `unix:${Path.join(config.path, 'socket')}:~noauth:${pubkey}`
29 })
30 }
31 return config
32 })
33}
34

Built with git-ssb-web