git ssb

1+

mixmix / scuttle-shell



Commit de92553986e36c8aa555fb0a529a98913b109777

fixes for configuration

andre alves garzia committed on 6/29/2018, 1:26:43 AM
Parent: 13ce65e0e17ef86467d82e99ecce021463cc9485

Files changed

host-app.jschanged
host-app.jsView
@@ -2,10 +2,12 @@
22 const nativeMessage = require('chrome-native-messaging')
33 const { spawn } = require('child_process')
44 const path = require('path')
55 const fs = require('fs')
6-const home = require('os').homedir()
6 +const config = require('ssb-config/inject')(process.env.ssb_appname)
77
8 +const pathToSecret = path.join(config.path, 'secret')
9 +
810 const input = new nativeMessage.Input()
911 const transform = new nativeMessage.Transform((msg, push, done) => {
1012 getReplyFor(msg, data => {
1113 push(data)
@@ -15,11 +17,11 @@
1517 const output = new nativeMessage.Output()
1618
1719 const getConfig = () => {
1820 try {
19- let secret = fs.readFileSync(`${home}/.ssb/secret`, "utf8")
21 + let secret = fs.readFileSync(pathToSecret, "utf8")
2022 let keys = JSON.parse(secret.replace(/#[^\n]*/g, ''))
21- let manifest = JSON.parse(fs.readFileSync(`${home}/.ssb/manifest.json`))
23 + let manifest = JSON.parse(fs.readFileSync(path.join(config.path, 'manifest.json')))
2224 let remote = "ws://localhost:8989~shs:" + keys.id.substring(1, keys.id.indexOf('.'))
2325 return { type: 'config', keys: keys, manifest: manifest, remote: remote, secret: secret }
2426 } catch (n) {
2527 return { type: 'exception', msg: n.message }
@@ -58,11 +60,11 @@
5860 cb({ type: 'shutdown', msg: 'stopping server' })
5961 process.exit(1)
6062 }
6163 case 'get-config': {
62- let secretRaw = fs.readFileSync(`${home}/.ssb/secret`)
64 + let secretRaw = fs.readFileSync(pathToSecret)
6365 let keys = JSON.parse(secret.replace(/#[^\n]*/g, ''))
64- let manifest = JSON.parse(fs.readFileSync(`${home}/.ssb/manifest.json`))
66 + let manifest = JSON.parse(fs.readFileSync(path.join(config.path, 'manifest.json')))
6567 let remote = "ws://localhost:8989~shs:" + keys.id.substring(1, keys.id.indexOf('.'))
6668
6769 cb({ type: 'config', keys, manifest, remote })
6870 }

Built with git-ssb-web