git ssb

7+

dinoworm ๐Ÿ› / patchcore



Tree: 4d1aa8528ed9342d5d663af75cb08beb82f0fbcc

Files: 4d1aa8528ed9342d5d663af75cb08beb82f0fbcc / keys.js

550 bytesRaw
1const Path = require('path')
2const Keys = require('ssb-keys')
3const nest = require('depnest')
4
5exports.needs = nest('config.sync.load', 'first')
6exports.gives = nest({
7 'keys.sync': [ 'load', 'id' ]
8})
9
10exports.create = (api) => {
11 var keys
12
13 return nest({
14 'keys.sync': { load, id }
15 })
16
17 function id () {
18 return load().id
19 }
20
21 function load () {
22 if (!keys) {
23 const config = api.config.sync.load()
24 const keyPath = Path.join(config.path, 'secret')
25 keys = Keys.loadOrCreateSync(keyPath)
26 }
27 return keys
28 }
29}
30

Built with git-ssb-web