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 AMParent: 81202b9f139b941aa38f6d73effefc40e2a7c378
Files changed
index.js | changed |
index.js | |||
---|---|---|---|
@@ -70,15 +70,19 @@ | |||
70 | 70 … | throw code(new Error('accept must be type: "invite/accept", was:'+JSON.stringify(accept.content.type)), 'user-invites:accept-message-type') | |
71 | 71 … | if(invite.content.type !== 'invite') | |
72 | 72 … | throw code(new Error('accept must be type: invite, was:'+accept.content.type), 'user-invites:invite-message-type') | |
73 | 73 … | ||
74 … | + var invite_id = '%'+ssbKeys.hash(JSON.stringify(invite, null, 2)) | ||
74 | 75 … | var reveal | |
75 | - var invite_id = '%'+ssbKeys.hash(JSON.stringify(invite, null, 2)) | ||
76 … | + | ||
76 | 77 … | if(invite_id !== accept.content.receipt) | |
77 | 78 … | throw code(new Error('acceptance not matched to given invite, got:'+invite_id+' expected:'+accept.content.receipt), 'accept-wrong-invite') | |
79 … | + | ||
78 | 80 … | if(accept.author === invite.content.id) | |
79 | 81 … | throw code(new Error('invitee must use a new key, not the same seed'), 'guest-key-reuse') | |
80 | 82 … | 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') | ||
81 | 85 … | reveal = u.unbox(invite.content.reveal, new Buffer(accept.content.key, 'base64')) | |
82 | 86 … | if(!reveal) throw code(new Error('accept did not correctly reveal invite'), 'decrypt-accept-reveal-failed') | |
83 | 87 … | } | |
84 | 88 … | ||
@@ -92,4 +96,12 @@ | |||
92 | 96 … | ||
93 | 97 … | ||
94 | 98 … | ||
95 | 99 … | ||
100 … | + | ||
101 … | + | ||
102 … | + | ||
103 … | + | ||
104 … | + | ||
105 … | + | ||
106 … | + | ||
107 … | + |
Built with git-ssb-web