git ssb

16+

Dominic / patchbay



Tree: 51bb7f2c4da0239b8114b4f425ca3da89741c261

Files: 51bb7f2c4da0239b8114b4f425ca3da89741c261 / sbot-api.js

780 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_get: function (key, cb) {
32 sbot.get(key, cb)
33 },
34 sbot_publish: function (msg, cb) {
35 sbot.publish(msg, cb)
36 }
37 }
38}
39
40

Built with git-ssb-web