git ssb

0+

Dominic / ssb-peer-invites



Commit 6da1ed2b81fa01cf82a1cb23f61b7ba7434a8770

convert seed to buffer where necessary

Dominic Tarr committed on 12/20/2018, 10:09:08 PM
Parent: 2dcc95969b2766ca87d3f0c22dbf0f0f397bf642

Files changed

index.jschanged
index.jsView
@@ -25,8 +25,12 @@
2525 function isObject (o) {
2626 return o && typeof o == 'object'
2727 }
2828
29 +function toBuffer(b) {
30 + return Buffer.isBuffer(b) ? b : Buffer.from(b, 'base64')
31 +}
32 +
2933 exports.name = 'user-invites'
3034
3135 exports.version = '1.0.0'
3236 exports.manifest = {
@@ -310,9 +314,9 @@
310314 return opts(new Error ('user-invites: expected: options *must* be provided.'))
311315
312316 var host_id = opts.id || sbot.id
313317 getNearbyPubs(opts, function (err, near) {
314- var seed = crypto.randomBytes(32)
318 + var seed = crypto.randomBytes(32).toString('base64')
315319 sbot.identities.publishAs({
316320 id: host_id,
317321 content: I.createInvite(seed, host_id, opts.reveal, opts.private, caps)
318322 }, function (err, data) {
@@ -328,9 +332,9 @@
328332
329333 //try each of an array of addresses, and cb the first one that works.
330334 function connectFirst (invite, cb) {
331335 var n = 0, err
332- var keys = ssbKeys.generate(null, invite.seed)
336 + var keys = ssbKeys.generate(null, toBuffer(invite.seed))
333337 invite.pubs.forEach(function (addr) {
334338 n++
335339 //don't use sbot.connect here, because we are connecting
336340 //with a different cap.
@@ -392,9 +396,9 @@
392396 var invite = isObject(opts.invite) ? opts.invite : opts
393397 var invite_id = invite.invite
394398 var id = opts.id || sbot.id
395399 var pubs = invite.pubs
396- var keys = ssbKeys.generate(null, invite.seed)
400 + var keys = ssbKeys.generate(null, toBuffer(invite.seed))
397401
398402 //check wether this invite is already accepted.
399403 //or if the acceptance has been publish, but not yet confirmed.
400404 getAccept(invite_id, function (err, accept) {

Built with git-ssb-web