git ssb

1+

Daan Patchwork / patchwork



Tree: 2aba282967b6a030aeb637a4592a0572ac1451b7

Files: 2aba282967b6a030aeb637a4592a0572ac1451b7 / lib / depject / keys.js

548 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 let 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