Skip to content

chore(web): remove unused Bearer-token auth helpers#225

Closed
karthikarunapuram8-dot wants to merge 1 commit into
alookai:mainfrom
karthikarunapuram8-dot:chore/remove-unused-bearer-helpers
Closed

chore(web): remove unused Bearer-token auth helpers#225
karthikarunapuram8-dot wants to merge 1 commit into
alookai:mainfrom
karthikarunapuram8-dot:chore/remove-unused-bearer-helpers

Conversation

@karthikarunapuram8-dot

Copy link
Copy Markdown

Follow-up to #210, addressing the reviewer's flagged latent gap.

Context

In their review of #210, @anky98ai pointed out that the same accept-any-non-null pattern existed in two other Bearer-token entry points without a status guard:

  • src/web/src/lib/dual-auth.ts (requireAuth)
  • src/web/src/lib/api-auth.ts (withToken)

Both would admit a pending machine token exactly as withAuth did before #210.

Why deletion rather than hardening

Both helpers have zero callers anywhere in the repo. Verified via grep on the helper file names, the function names, and the call-site patterns (requireAuth(, withToken().

Keeping unused, duplicated, and unsafe validation logic around invites silent regression if either helper is ever wired up later. Deleting both eliminates the latent gap rather than hardening dead code that may stay dead.

withAuth in src/web/src/lib/middleware/auth.ts remains the single source of truth for Bearer-token validation, and now there is no other path that could quietly reintroduce the pending-token-accepted bug.

Scope

  • -52 lines, no additions
  • No tests touched: there were none against these helpers
  • pnpm typecheck passes after the deletion

If a future use case calls for Bearer-token auth outside the existing withAuth wrapper, the right move is to reuse withAuth (or extract its validation into a shared helper) rather than reintroducing parallel implementations.

Happy to take a different approach if you would prefer hardening over deletion.

Follow-up to alookai#210. dual-auth.ts (requireAuth) and api-auth.ts (withToken)
accepted any non-null row from getMachineTokenByToken without checking
mt.status, the same pattern the auth middleware fix in alookai#210 closed. Both
helpers currently have zero callers in the repo, so this is a latent gap
rather than a live exploit, but keeping the duplicated and unsafe
validation logic around invites silent regression if either helper is
ever wired up later.

Deleting both. withAuth in src/web/src/lib/middleware/auth.ts remains
the single source of truth for Bearer-token validation.

Verified zero references via grep on (dual-auth, api-auth, requireAuth,
withToken) across the whole repo. Typecheck passes.
@karthikarunapuram8-dot

Copy link
Copy Markdown
Author

Re-verified the gauntlet on this branch after the deletion:

  • pnpm --filter @alook/web typecheck (tsc --noEmit): exit 0, clean
  • pnpm --filter @alook/web lint (eslint src/): exit 0, two pre-existing warnings in unrelated files (home/page.tsx, agent-chat-view.tsx), zero errors
  • pnpm --filter @alook/web test (vitest run): 131/131 files, 1177/1177 tests passed in 19.18s

Branch is also still up to date with upstream/main (no rebase needed).

@GenerQAQ

Copy link
Copy Markdown
Contributor

Thanks for catching this! These files have already been removed as part of #235, which added automated dead code detection (knip) across the entire codebase and cleaned up all existing unused code in one pass. Closing as superseded — appreciate the contribution!

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