Skip to content

Fix WS auth + gym release directive TypeScript error#16

Merged
iamlukethedev merged 2 commits into
iamlukethedev:mainfrom
asimons81:fix/ws-auth-verifyclient
Mar 21, 2026
Merged

Fix WS auth + gym release directive TypeScript error#16
iamlukethedev merged 2 commits into
iamlukethedev:mainfrom
asimons81:fix/ws-auth-verifyclient

Conversation

@asimons81

@asimons81 asimons81 commented Mar 21, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes two bugs reported in issue #15:

Bug 1: WebSocket auth failure ("closed before connection is established")

The allowWs callback was never calling accessGate.allowUpgrade during the WS handshake — the ws library passes (info) not (req), and verifyClient must be set on the WebSocketServer constructor options.

Bug 2: TypeScript error on gym directive comparison

OfficeGymDirective was "gym" only (no "release" value), making !== "release" dead code that TypeScript flagged. The better fix adds "release" support for symmetry with OfficeQaDirective.

Files changed

File Change
server/gateway-proxy.js Pass verifyClient to WebSocketServer constructor
server/index.js Move auth check from allowWs to verifyClient callback
src/lib/office/deskDirectives.ts Add "release" to OfficeGymDirective type + release patterns
src/lib/office/eventTriggers.ts Change !== "release" to === "gym"

Test plan

  • WS connections to /api/gateway/ws are gated by accessGate.allowUpgrade
  • Existing WS functionality works for authenticated clients
  • TypeScript compiles without errors

🤖 Generated with Claude Code

The allowWs callback was never actually calling accessGate.allowUpgrade
during the WS handshake - the ws library passes (info) not (req), and
verifyClient must be set on the WebSocketServer constructor options.

Fix: pass verifyClient to WebSocketServer constructor and wrap
allowUpgrade to extract info.req.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add "release" value to OfficeGymDirective type for symmetry with
OfficeQaDirective ("qa_lab" | "release"). Previously OfficeGymDirective
was only "gym" with no release state, making the "!== 'release'"
check in eventTriggers.ts dead code that TypeScript flagged as an
unintentional comparison.

Changes:
- deskDirectives.ts: add "release" to OfficeGymDirective type
- deskDirectives.ts: add gym release patterns to skill and command
  directive resolvers (e.g. "leave the gym", "done with skills")
- eventTriggers.ts: change !== "release" to === "gym" for clarity
  and consistency with reduceOfficeGymHoldState pattern

This fixes: #15

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@asimons81 asimons81 changed the title Fix WS auth: wire accessGate.allowUpgrade via verifyClient Fix WS auth + gym release directive TypeScript error Mar 21, 2026
@iamlukethedev iamlukethedev merged commit a5b0895 into iamlukethedev:main Mar 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants