git ssb

16+

Dominic / patchbay



Commit 32dce475ec91f2a5a01cdc3c18e065cdec7125dd

Merge config object and use variable curve string

This commit resolves an issue where a chain of of properties throws:

    TypeError: Cannot read property 'incoming' of undefined

Using `_.merge()` instead merges the two objects, which makes changes
to nested objects without any errors. This commit also replaces the
hardcoded "ed25519" curve with a variable, which should be tolerant of
new curves that may be used in the future.
Christian Bundy committed on 9/12/2018, 5:49:22 PM
Parent: ba7b522a22c401fac1d4b07d93169c95b32cc16d

Files changed

config.jschanged
config.jsView
@@ -1,8 +1,9 @@
11 const nest = require('depnest')
22 const Config = require('ssb-config/inject')
33 const ssbKeys = require('ssb-keys')
44 const Path = require('path')
5 +const merge = require('lodash/merge')
56
67 const appName = process.env.ssb_appname || 'ssb'
78 const opts = appName === 'ssb'
89 ? null
@@ -14,14 +15,19 @@
1415 return nest('config.sync.load', () => {
1516 if (!config) {
1617 console.log('LOADING config')
1718 config = Config(appName, opts)
18- config.keys = ssbKeys.loadOrCreateSync(Path.join(config.path, 'secret'))
1919
20- if (!config.connections.incoming.unix)
21- config.connections.incoming.unix = [{ "scope": "local", "transform": "noauth" }]
20 + const keys = ssbKeys.loadOrCreateSync(Path.join(config.path, 'secret'))
21 + const pubkey = keys.id.slice(1).replace(`.${keys.curve}`, '')
2222
23- config.remote = `unix:${Path.join(config.path, 'socket')}:~noauth:${config.keys.id.slice(1).replace('.ed25519', '')}`
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 + })
2430 }
2531 return config
2632 })
2733 }

Built with git-ssb-web