git ssb

0+

Dominic / ssb-peer-invites



Commit fe51981dcffa9ecd1ade80ce5ce03f11c28229ab

update apis to be user-invite / userInvite

Dominic Tarr committed on 12/14/2018, 9:53:29 PM
Parent: c9b680a5f7988a98d99288af991d85a88c1f1398

Files changed

test/accept.jschanged
test/accept.jsView
@@ -13,8 +13,16 @@
1313 var ref = require('ssb-ref')
1414
1515 var createSbot = require('scuttlebot')
1616 .use(require('ssb-links'))
17 + .use({
18 + name: 'replicate', version: '1.0.0',
19 + manifest: { request: 'sync' },
20 + init: function () {
21 + return { request: function () {} }
22 + }
23 + })
24 + .use(require('ssb-friends'))
1725 .use(require('../'))
1826
1927 function all(stream, cb) {
2028 return pull(stream, pull.collect(cb))
@@ -38,50 +46,49 @@
3846 var seed = crypto.randomBytes(32)
3947
4048 var content = I.createInvite(seed, alice.id, {name: 'bob'}, {text: 'welcome to ssb!'})
4149 alice.publish(content, function (err, msg) {
42-// console.log(msg)
4350 I.verifyInvitePublic(msg.value)
44- console.log("REMOTE", alice.getAddress())
4551
4652 createClient(
4753 ssbKeys.generate(null, seed),
4854 {
4955 remote: alice.getAddress(),
5056 caps: require('ssb-config').caps,
5157 manifest: {
52- invites: {
58 + userInvites: {
5359 getInvite: 'async',
5460 accept: 'async'
5561 }
5662 }
5763 },
5864 function (err, _bob) {
5965 if(err) throw err
60- _bob.invites.getInvite(msg.key, function (err, invite) {
66 + _bob.userInvites.getInvite(msg.key, function (err, invite) {
6167 if(err) throw err
6268 t.ok(invite)
6369 t.deepEqual(invite, msg.value)
64- //check this invite is valid.
70 + //check this invite is valid. would throw if it wasn't.
6571 I.verifyInvitePrivate(invite, seed)
6672
6773 //bob chooses to accept this invite.
6874 var accept_content = I.createAccept(invite, seed, bob.id)
6975
7076 bob.publish(accept_content, function (err, accept) {
7177 if(err) throw err
72- _bob.invites.accept(accept.value, function (err, msg) {
78 + _bob.userInvites.accept(accept.value, function (err, msg) {
7379 if(err) throw err
7480 t.ok(msg)
7581 var confirm_id = '%'+ssbKeys.hash(JSON.stringify(msg, null, 2))
7682 alice.get(confirm_id, function (err, _msg) {
7783 if(err) throw err
7884 t.deepEqual(msg, _msg)
7985
80- _bob.invites.accept(accept.value, function (err, msg2) {
86 +
87 + //calling accept again should return the previous accept message.
88 + _bob.userInvites.accept(accept.value, function (err, msg2) {
8189 if(err) throw err
8290 t.deepEqual(msg2, msg)
83- console.log('accept2', msg2)
8491 alice.close()
8592 bob.close()
8693 t.end()
8794 })
@@ -93,14 +100,4 @@
93100 )
94101 })
95102 })
96103
97-
98-
99-
100-
101-
102-
103-
104-
105-
106-

Built with git-ssb-web