decentralised sync engine
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: additional error messages

serenity a62c03b7 77f2d868

+19 -3
+19 -3
src/lib/handlers/latticeHandshake.ts
··· 63 63 const recordResult = await getRecordFromFullAtUri(inviteAtUri); 64 64 if (!recordResult.ok) { 65 65 console.error( 66 - `something went wrong fetching the record from the given membership ${JSON.stringify(membership)}`, 66 + `something went wrong fetching the invite record from the given membership ${JSON.stringify(membership)}`, 67 67 ); 68 68 throw new Error( 69 69 JSON.stringify({ error: recordResult.error, membership }), ··· 78 78 } catch (err) { 79 79 return newErrorResponse(500, { 80 80 message: 81 - "Something went wrong when fetching membership channel records. Check the Shard logs if possible.", 81 + "Something went wrong when fetching membership invite records. Check the Shard logs if possible.", 82 82 details: err, 83 83 }); 84 84 } ··· 115 115 const recordResult = await getRecordFromFullAtUri(channelAtUri); 116 116 if (!recordResult.ok) { 117 117 console.error( 118 - `something went wrong fetching the record from the given membership ${JSON.stringify(invite)}`, 118 + `something went wrong fetching the channel record from the given membership ${JSON.stringify(invite)}`, 119 119 ); 120 120 throw new Error( 121 121 JSON.stringify({ error: recordResult.error, invite }), ··· 158 158 // did of the backlink. if there are any channels described by unauthorised parties, simply drop them. 159 159 160 160 let mismatchOrIncorrect = false; 161 + const errors: Array<unknown> = []; 161 162 const existingShardConnectionShardDids = shardSessions 162 163 .keys() 163 164 .toArray() ··· 175 176 routeThroughRecord.uri, 176 177 ); 177 178 if (!routeThroughRecordParseResult.ok) { 179 + errors.push(routeThroughRecordParseResult.error); 178 180 mismatchOrIncorrect = true; 179 181 return; 180 182 } ··· 183 185 // FIXME: this also assumes that the requesting lattice's DID is a did:web 184 186 // see below for the rest of the issues. 185 187 if (routeThroughUri.rKey === SERVICE_DID.slice(8)) { 188 + errors.push( 189 + "Mismatch between claimant lattice and channel routeThrough. Request wants to validate for", 190 + routeThroughUri.rKey, 191 + ", but this lattice is", 192 + SERVICE_DID.slice(8), 193 + ); 186 194 mismatchOrIncorrect = true; 187 195 return; 188 196 } 189 197 const storeAtRecordParseResult = stringToAtUri(storeAtRecord.uri); 190 198 if (!storeAtRecordParseResult.ok) { 199 + errors.push(storeAtRecordParseResult.error); 191 200 mismatchOrIncorrect = true; 192 201 return; 193 202 } ··· 203 212 if (!storeAtUri.rKey) return; 204 213 205 214 if (!existingShardConnectionShardDids.includes(storeAtUri.rKey)) { 215 + errors.push( 216 + "Mismatch between claimant shard and channel storeAt. Request wants to validate for", 217 + storeAtUri.rKey, 218 + ", but this lattice is only allowed to talk to", 219 + existingShardConnectionShardDids, 220 + ); 206 221 mismatchOrIncorrect = true; 207 222 return; 208 223 } ··· 213 228 return newErrorResponse(400, { 214 229 message: 215 230 "Channels provided during the handshake had a mismatch between the channel values. Ensure that you are only submitting exactly the channels you have access to.", 231 + details: errors, 216 232 }); 217 233 218 234 // yipee, it's a valid request :3