git ssb

0+

Dominic / ssb-peer-invites



Commit e52b3cbbebf89e82592eb4630f1327db640bed53

every error should have a code, so that all error states can be tested (including that they give the correct error!)

Dominic Tarr committed on 3/26/2018, 4:26:59 AM
Parent: 81202b9f139b941aa38f6d73effefc40e2a7c378

Files changed

index.jschanged
index.jsView
@@ -70,15 +70,19 @@
7070 throw code(new Error('accept must be type: "invite/accept", was:'+JSON.stringify(accept.content.type)), 'user-invites:accept-message-type')
7171 if(invite.content.type !== 'invite')
7272 throw code(new Error('accept must be type: invite, was:'+accept.content.type), 'user-invites:invite-message-type')
7373
74 + var invite_id = '%'+ssbKeys.hash(JSON.stringify(invite, null, 2))
7475 var reveal
75- var invite_id = '%'+ssbKeys.hash(JSON.stringify(invite, null, 2))
76 +
7677 if(invite_id !== accept.content.receipt)
7778 throw code(new Error('acceptance not matched to given invite, got:'+invite_id+' expected:'+accept.content.receipt), 'accept-wrong-invite')
79 +
7880 if(accept.author === invite.content.id)
7981 throw code(new Error('invitee must use a new key, not the same seed'), 'guest-key-reuse')
8082 if(invite.content.reveal) {
83 + if(!accept.content.key)
84 + throw code(new Error('accept missing reveal key, when invite has it'), 'accept-must-reveal-key')
8185 reveal = u.unbox(invite.content.reveal, new Buffer(accept.content.key, 'base64'))
8286 if(!reveal) throw code(new Error('accept did not correctly reveal invite'), 'decrypt-accept-reveal-failed')
8387 }
8488
@@ -92,4 +96,12 @@
9296
9397
9498
9599
100 +
101 +
102 +
103 +
104 +
105 +
106 +
107 +

Built with git-ssb-web