Files: 512c51cb66cc1ca1080a041399f4495e5009dece / config.js
1078 bytesRaw
1 | const nest = require('depnest') |
2 | const Config = require('ssb-config/inject') |
3 | const ssbKeys = require('ssb-keys') |
4 | const Path = require('path') |
5 | const merge = require('lodash/merge') |
6 | |
7 | const appName = process.env.ssb_appname || 'ssb' |
8 | const opts = appName === 'ssb' |
9 | ? null |
10 | : null // require('./default-config.json') |
11 | |
12 | exports.gives = nest('config.sync.load') |
13 | exports.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 | const socketSettings = (process.platform.startsWith('win')) |
23 | ? {} |
24 | : { |
25 | connections: { |
26 | incoming: { |
27 | unix: [{ 'scope': 'local', 'transform': 'noauth' }] |
28 | } |
29 | }, |
30 | remote: `unix:${Path.join(config.path, 'socket')}:~noauth:${pubkey}` |
31 | } |
32 | |
33 | merge(config, { keys }, socketSettings) |
34 | } |
35 | return config |
36 | }) |
37 | } |
38 |
Built with git-ssb-web