git ssb

16+

Dominic / patchbay



Commit 4d2f823a8d3ddc38e69dddc7955b69fc2f5574cf

move message encryption into sbot-publish

Dominic Tarr committed on 7/15/2016, 1:12:07 AM
Parent: b584acdb7216737141340d6bd53a13659b7b88cc

Files changed

modules/compose.jschanged
modules/crypto.jschanged
modules/message-confirm.jschanged
sbot-api.jschanged
modules/compose.jsView
@@ -7,9 +7,9 @@
77
88 var plugs = require('../plugs')
99
1010 //var suggest = plugs.map(exports.suggest = [])
11-var publish = plugs.first(exports.publish = [])
11+var publish = plugs.first(exports.sbot_publish = [])
1212 var message_content = plugs.first(exports.message_content = [])
1313 var message_confirm = plugs.first(exports.message_confirm = [])
1414 var file_input = plugs.first(exports.file_input = [])
1515
@@ -108,8 +108,4 @@
108108 return composer
109109
110110 }
111111
112-
113-
114-
115-
modules/crypto.jsView
@@ -45,8 +45,4 @@
4545 console.log('PUBLISHED', msg)
4646 })
4747 }
4848
49-
50-
51-
52-
modules/message-confirm.jsView
@@ -4,9 +4,9 @@
44 //publish or add
55
66 var plugs = require('../plugs')
77
8-var publish = plugs.first(exports.publish = [])
8+var publish = plugs.first(exports.sbot_publish = [])
99 var message_content = plugs.first(exports.message_content = [])
1010
1111 exports.message_confirm = function (content, cb) {
1212
sbot-api.jsView
@@ -1,8 +1,10 @@
11 var pull = require('pull-stream')
22 var crypto = require('crypto')
3+var ref = require('ssb-ref')
34 var Reconnect = require('pull-reconnect')
45
6+
57 function Hash (onHash) {
68 var hash = crypto.createHash('sha256')
79 return pull.through(function (data) {
810 hash.update(
@@ -23,10 +25,10 @@
2325 var createConfig = require('ssb-config/inject')
2426
2527 var createFeed = require('ssb-feed')
2628 var keys = require('./keys')
29+var ssbKeys = require('ssb-keys')
2730
28-
2931 module.exports = function () {
3032 var opts = createConfig()
3133 var sbot = null
3234
@@ -88,11 +90,18 @@
8890 }),
8991 sbot_get: rec.async(function (key, cb) {
9092 sbot.get(key, cb)
9193 }),
92- sbot_publish: rec.async(function (msg, cb) {
93- feed.add(msg, function (err, msg) {
94- cb(err, msg)
94+ sbot_publish: rec.async(function (content, cb) {
95+ if(content.recps)
96+ content = ssbKeys.box(content, content.recps.map(function (e) {
97+ return ref.isFeed(e) ? e : e.link
98+ }))
99+
100+ feed.add(content, function (err, msg) {
101+ if(err) console.error(err)
102+ else if(!cb) console.log(msg)
103+ cb && cb(err, msg)
95104 })
96105 }),
97106 sbot_whoami: rec.async(function (cb) {
98107 sbot.whoami(cb)
@@ -100,4 +109,6 @@
100109 }
101110 }
102111
103112
113+
114+

Built with git-ssb-web