Commit 6da1ed2b81fa01cf82a1cb23f61b7ba7434a8770
convert seed to buffer where necessary
Dominic Tarr committed on 12/20/2018, 10:09:08 PMParent: 2dcc95969b2766ca87d3f0c22dbf0f0f397bf642
Files changed
index.js | changed |
index.js | ||
---|---|---|
@@ -25,8 +25,12 @@ | ||
25 | 25 … | function isObject (o) { |
26 | 26 … | return o && typeof o == 'object' |
27 | 27 … | } |
28 | 28 … | |
29 … | +function toBuffer(b) { | |
30 … | + return Buffer.isBuffer(b) ? b : Buffer.from(b, 'base64') | |
31 … | +} | |
32 … | + | |
29 | 33 … | exports.name = 'user-invites' |
30 | 34 … | |
31 | 35 … | exports.version = '1.0.0' |
32 | 36 … | exports.manifest = { |
@@ -310,9 +314,9 @@ | ||
310 | 314 … | return opts(new Error ('user-invites: expected: options *must* be provided.')) |
311 | 315 … | |
312 | 316 … | var host_id = opts.id || sbot.id |
313 | 317 … | getNearbyPubs(opts, function (err, near) { |
314 | - var seed = crypto.randomBytes(32) | |
318 … | + var seed = crypto.randomBytes(32).toString('base64') | |
315 | 319 … | sbot.identities.publishAs({ |
316 | 320 … | id: host_id, |
317 | 321 … | content: I.createInvite(seed, host_id, opts.reveal, opts.private, caps) |
318 | 322 … | }, function (err, data) { |
@@ -328,9 +332,9 @@ | ||
328 | 332 … | |
329 | 333 … | //try each of an array of addresses, and cb the first one that works. |
330 | 334 … | function connectFirst (invite, cb) { |
331 | 335 … | var n = 0, err |
332 | - var keys = ssbKeys.generate(null, invite.seed) | |
336 … | + var keys = ssbKeys.generate(null, toBuffer(invite.seed)) | |
333 | 337 … | invite.pubs.forEach(function (addr) { |
334 | 338 … | n++ |
335 | 339 … | //don't use sbot.connect here, because we are connecting |
336 | 340 … | //with a different cap. |
@@ -392,9 +396,9 @@ | ||
392 | 396 … | var invite = isObject(opts.invite) ? opts.invite : opts |
393 | 397 … | var invite_id = invite.invite |
394 | 398 … | var id = opts.id || sbot.id |
395 | 399 … | var pubs = invite.pubs |
396 | - var keys = ssbKeys.generate(null, invite.seed) | |
400 … | + var keys = ssbKeys.generate(null, toBuffer(invite.seed)) | |
397 | 401 … | |
398 | 402 … | //check wether this invite is already accepted. |
399 | 403 … | //or if the acceptance has been publish, but not yet confirmed. |
400 | 404 … | getAccept(invite_id, function (err, accept) { |
Built with git-ssb-web