Refactor: Frontend cleanup (WS token in URL, dedupe helpers, store data loading) #91

Closed
opened 2026-07-08 02:40:35 +00:00 by icub3d · 1 comment
Owner

Category: Refactor / simplification + minor security (frontend) — found in code review 2026-07-07.

  • Session token is passed as a WebSocket URL query param (client/src/services/gateway.ts:50) — lands in access/proxy logs and history. Prefer a subprotocol header or a short-lived one-time ticket.
  • Dedupe copy-pasted helpers: truncatePubkey/shortPubkey (MessageItem.tsx:22, MemberList.tsx:16, Setup.tsx:10) and normalizeAddress (appStore.ts:32, serverStore.ts:83) into a shared utils/.
  • serverStore.ts connect() and revalidate() duplicate the fetch-channels/roles/members + build-roleMap block — extract loadServerData(). mergeMessages re-sorts the whole array per MESSAGE_CREATE; insert instead.
  • media.ts:15 uploadFile re-implements the !response.ok error-parse already in apiRequest — share a response-error extractor.
  • Seed phrase held in React state + copied to clipboard with no clear (KeySafety.tsx) — clear generatedIdentity on completion; consider dropping/auto-clearing clipboard copy.
**Category: Refactor / simplification + minor security (frontend)** — found in code review 2026-07-07. - [ ] Session token is passed as a WebSocket **URL query param** (`client/src/services/gateway.ts:50`) — lands in access/proxy logs and history. Prefer a subprotocol header or a short-lived one-time ticket. - [ ] Dedupe copy-pasted helpers: `truncatePubkey`/`shortPubkey` (`MessageItem.tsx:22`, `MemberList.tsx:16`, `Setup.tsx:10`) and `normalizeAddress` (`appStore.ts:32`, `serverStore.ts:83`) into a shared `utils/`. - [ ] `serverStore.ts` `connect()` and `revalidate()` duplicate the fetch-channels/roles/members + build-`roleMap` block — extract `loadServerData()`. `mergeMessages` re-sorts the whole array per `MESSAGE_CREATE`; insert instead. - [ ] `media.ts:15` `uploadFile` re-implements the `!response.ok` error-parse already in `apiRequest` — share a response-error extractor. - [ ] Seed phrase held in React state + copied to clipboard with no clear (`KeySafety.tsx`) — clear `generatedIdentity` on completion; consider dropping/auto-clearing clipboard copy.
Author
Owner

Landed on main via #107 (commits e305ed3 + b809ffc): WS token moved out of the URL (bearer header / access_token subprotocol), deduped pubkey/address helpers, loadServerData() extraction, shared extractErrorMessage(), seed-state and clipboard clearing.

Landed on main via #107 (commits e305ed3 + b809ffc): WS token moved out of the URL (bearer header / access_token subprotocol), deduped pubkey/address helpers, loadServerData() extraction, shared extractErrorMessage(), seed-state and clipboard clearing.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
icub3d/decentcom#91
No description provided.