Relocate 30 non-essential .md files (investigation notes, fix summaries, implementation details, status reports) from the project root into docs/ to reduce clutter. Core operational docs (README, quickstart guides, configuration references) remain in the root. Co-authored-by: Cursor <cursoragent@cursor.com>
4.7 KiB
Authentication Issue - Bot Appears as Anonymous
Problem
The bot successfully authenticates via browser automation and joins the Kosmi room, but appears in the user list as an anonymous user (e.g., "Anonymous Donkey") instead of as the authenticated account.
What We Know
✅ Working Correctly
- Browser authentication: Successfully logs in and obtains JWT token
- Token format: Valid JWT with correct structure and claims
- Token transmission: Correct token is sent in
connection_init - Server acceptance: Server accepts the token (returns
connection_ack) - Room joining: Successfully joins the room (
joinRoommutation returnsok: true)
🔍 Investigation Results
Token Claims Analysis
The authenticated JWT token contains:
{
"aud": "kosmi",
"exp": 1761874131,
"iat": 1730338131,
"iss": "kosmi",
"sub": "e410acc0-e4bd-4694-8498-f20b9aa033fc",
"typ": "access"
}
Key finding: The token only contains the user ID (sub), but NO display name, username, or email. This is just an authentication token, not a profile token.
GraphQL API Queries
Tested the following queries with the authenticated token:
query { me { ... } }- ❌ Field doesn't existquery { currentUser { ... } }- ❌ Field doesn't existquery { user { ... } }- ❌ Field doesn't existquery { viewer { ... } }- ❌ Field doesn't exist
Conclusion: There's no GraphQL query to fetch the current user's profile.
WebSocket Flow
Current flow:
connection_initwith authenticated token → Server acceptsconnection_ack→ Server acknowledges- Subscribe to
newMessage→ Working joinRoommutation → Returnsok: true- Bot appears in user list as "Anonymous [Animal]"
Hypotheses
1. Missing Profile Fetch
The server might need a separate API call (REST or GraphQL) to fetch the user profile using the user ID from the token.
2. Missing Display Name Mutation
There might be a GraphQL mutation to set the display name after joining:
mutation { setDisplayName(name: "...") }mutation { updateProfile(displayName: "...") }
3. Server-Side Bug
The server might not be correctly associating the authenticated token with the user profile when joining via WebSocket.
4. Additional WebSocket Message
The browser might be sending an additional WebSocket message after joinRoom that we're not aware of.
Next Steps
- Check
connection_ackpayload: See if the server returns user info - Monitor browser WebSocket traffic: Watch what messages the browser sends after successful login and room join
- Test GraphQL introspection: Query the schema to see all available mutations
- Compare anonymous vs authenticated flow: See if there are any differences in the WebSocket message sequence
Logs
Successful Authentication and Join
time="2025-11-01T14:48:51-04:00" level=info msg="✅ Successfully obtained token via browser automation" prefix=kosmi
time="2025-11-01T14:48:51-04:00" level=info msg=" Email used: d2bkvqnh0@mozmail.com" prefix=kosmi
time="2025-11-01T14:48:51-04:00" level=info msg=" Token (first 50 chars): eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJrb..." prefix=kosmi
time="2025-11-01T14:48:51-04:00" level=info msg=" Token user ID (sub): e410acc0-e4bd-4694-8498-f20b9aa033fc" prefix=kosmi
time="2025-11-01T14:48:51-04:00" level=info msg=" Token type (typ): access" prefix=kosmi
time="2025-11-01T14:48:51-04:00" level=info msg="✓ getToken: Using manually provided token" prefix=kosmi
time="2025-11-01T14:48:51-04:00" level=info msg=" Length: 371" prefix=kosmi
time="2025-11-01T14:48:51-04:00" level=info msg=" First 50: eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJrb..." prefix=kosmi
time="2025-11-01T14:48:51-04:00" level=info msg="Sending connection_init with token (length: 371, first 20 chars: eyJhbGciOiJIUzUxMiIs...)" prefix=kosmi
time="2025-11-01T14:48:51-04:00" level=info msg="✅ WebSocket connection established and authenticated" prefix=kosmi
time="2025-11-01T14:48:51-04:00" level=info msg="✅ Successfully joined room" prefix=kosmi
time="2025-11-01T14:48:51-04:00" level=info msg="Join response payload: {"data":{"joinRoom":{"ok":true}}}" prefix=kosmi
Result: Bot appears as "Anonymous [Animal]" in the user list despite successful authentication.
Files Modified for Debugging
bridge/kosmi/browser_auth.go: Added comprehensive token loggingbridge/kosmi/kosmi.go: Added token setting confirmationbridge/kosmi/graphql_ws_client.go: Added token source andconnection_ackpayload loggingcmd/decode-token/main.go: Tool to decode and analyze JWT tokenscmd/test-profile-query/main.go: Tool to test GraphQL profile queries