git ssb

1+

Dominic / ssb-keys



Tree: b174e25259d127acc249b76628b1e3c53cc0a354

Files: b174e25259d127acc249b76628b1e3c53cc0a354 / local-storage.js

734 bytesRaw
1
2var u = require('./util')
3
4function isFunction (f) {
5 return 'function' == typeof f
6}
7
8module.exports = function (generate) {
9
10 function create (filename, curve, legacy) {
11 var keys = generate(curve, legacy)
12 localStorage[filename] = JSON.stringify(keys)
13 return keys
14 }
15
16 function load (filename) {
17 return JSON.parse(localStorage[filename])
18 }
19
20 return {
21 createSync: create,
22 create: function(filename, curve, legacy, cb) {
23 if(isFunction(legacy))
24 cb = legacy, legacy = null
25 if(isFunction(curve))
26 cb = curve, curve = null
27 cb(null, create(filename, curve, legacy))
28 },
29 loadSync: load,
30 load: function (filename, cb) {
31 cb(null, load(filename))
32 }
33 }
34
35}
36
37
38

Built with git-ssb-web