Files: f526bdeefd8c4fe7cb1108421d647e74ab85ef24 / keys.js
550 bytesRaw
1 | const Path = require('path') |
2 | const Keys = require('ssb-keys') |
3 | const nest = require('depnest') |
4 | |
5 | exports.needs = nest('config.sync.load', 'first') |
6 | exports.gives = nest({ |
7 | 'keys.sync': [ 'load', 'id' ] |
8 | }) |
9 | |
10 | exports.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