git ssb

0+

dangerousbeans / patchbay-bootstrap



Tree: c395c89410dba096bd2c95c1b7aa0e70c2b6ccc8

Files: c395c89410dba096bd2c95c1b7aa0e70c2b6ccc8 / sbot-api.js

1089 bytesRaw
1var pull = require('pull-stream')
2var crypto = require('crypto')
3
4function Hash (onHash) {
5 var hash = crypto.createHash('sha256')
6 return pull.through(function (data) {
7 hash.update(
8 'string' === typeof data
9 ? new Buffer(data, 'utf8')
10 : data
11 )
12 }, function (err) {
13 if(err && !onHash) throw err
14 onHash && onHash(err, '&'+hash.digest('base64')+'.sha256')
15 })
16}
17
18
19module.exports = function (sbot) {
20
21 return {
22 sbot_blobs_add: function (cb) {
23 return pull(
24 Hash(cb),
25 sbot.blobs.add()
26 )
27 },
28 sbot_links: function (query) {
29 return sbot.links(query)
30 },
31 sbot_links2: function (query) {
32 return sbot.links2.read(query)
33 },
34 sbot_log: function (opts) {
35 return sbot.createLogStream(opts)
36 },
37 sbot_user_feed: function (opts) {
38 return sbot.createUserStream(opts)
39 },
40 sbot_get: function (key, cb) {
41 sbot.get(key, cb)
42 },
43 sbot_publish: function (msg, cb) {
44 sbot.publish(msg, cb)
45 },
46 sbot_whoami: function (cb) {
47 sbot.whoami(cb)
48 }
49 }
50}
51
52
53
54

Built with git-ssb-web