This document defines the stable websocket contract for backend/frontend collaboration.
- Client connects with JWT token in one of:
socket.handshake.auth.tokenauthorizationheader- query param
token
- The token is validated using
WsJwtAuthService:- HS256
- configured
JWT_SECRET - expiration check
- On success,
client.data.useris set to payload withsubas user ID.
- Room id format:
split:<splitId>
- Payload:
{ splitId: string } - server checks
AuthorizationService.canAccessSplit(userSub, splitId) - Emits response:
{ event: "joined_split", data: { splitId, room } }
- Payload:
{ splitId: string } - Removes client from room
- Response:
{ event: "left_split", data: { splitId, room } }
- Payload:
{ splitId: string } - Response includes socket ids currently in room:
{ event: "split_presence", data: { splitId, participants: string[] } }
- Payload:
{ splitId: string, activity: object } - Broadcasts to room event
split_activityand returns a broadcast ack:{ event: "split_activity_broadcast", data: { splitId, activity } }
payment_received=> emitted with object: payment datasplit_updated=> emitted with split dataparticipant_joined=> emitted with participant datasplit_activity=> emitted with activity details
- Frontend uses this as canonical collaboration flow, with guard-protected endpoints and room-scoped operations.