git ssb

1+

Dominic / ssb-keys



Tree: 8ebcb5459250b77731dc4bd9153842fe0de7ea62

Files: 8ebcb5459250b77731dc4bd9153842fe0de7ea62 / local-storage.js

746 bytesRaw
1'use strict'
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