Skip to content

demo: rename auth route to /api/auth/token and fix stale JSDoc#158

Draft
umair-ably wants to merge 1 commit into
mainfrom
demos/ait-auth-consistency
Draft

demo: rename auth route to /api/auth/token and fix stale JSDoc#158
umair-ably wants to merge 1 commit into
mainfrom
demos/ait-auth-consistency

Conversation

@umair-ably

Copy link
Copy Markdown

Summary

Demo-side of the AI Transport auth consistency work. Companion to the docs PR at ably/docs#3397.

The endpoint returns a JWT, but its path read as Ably's native Token type. That's the exact JWT-vs-Token confusion the docs convention is now killing. This PR brings both demos onto the agreed neutral path.

What changed

  • Route directory renamed: src/app/api/auth/ably-token/src/app/api/auth/token/ in both demos (use-chat, use-client-session). Done with git mv so history follows.
  • Client fetch updated in providers.tsx (both demos) to match the new path.
  • Stale JSDoc fixed in route.ts: the comment claimed the client connects with authUrl, but the code uses authCallback. Reworded to match the code.
  • See: link repointed from the now-redirected sessions-identity/identifying-users-and-agents URL to the canonical concepts/authentication page.
  • README + docs (docs/get-started/vercel-use-chat.md) updated to use the new path, so the documented setup matches the running demo code.

Why /api/auth/token

Type-neutral on purpose. The endpoint returns a JWT — a path containing ably-token reads as the native Ably Token type and was actively misleading. /api/auth/token carries no token-type bias.

Out of scope

  • Production-hardening of the auth server (clientId should be derived from an authenticated session rather than trusted from the request). The demos remain demo-simple by intent. The docs PR carries the security framing for production callers.

Test plan

  • CI green
  • Both demos start (pnpm dev) and the chat flow round-trips successfully against the new route
  • grep -rn "ably-token\|sessions-identity" across the repo returns no hits
  • No regressions in pnpm run format:check

Note: pnpm run lint and pnpm run typecheck fail on test/helper/test-setup.ts in this local clone because the ably-common submodule isn't initialised. That failure is unrelated to this branch — the file is unchanged here. CI will run with submodules initialised.

🤖 Generated with Claude Code

Align both demos (use-chat, use-client-session) with the
AI Transport docs convention agreed in the auth consistency plan:

- Rename `src/app/api/auth/ably-token/` -> `src/app/api/auth/token/`.
  The endpoint returns a JWT, not Ably's native Token type; a path
  containing `ably-token` reads as the wrong token type and is the
  exact JWT-vs-Token confusion the convention is meant to eliminate.
- Update the client fetch in `providers.tsx` to match the new path.
- Fix the stale JSDoc in `route.ts`: the comment said the client
  connects with `authUrl`, but the code uses `authCallback`. Reword
  to match the code.
- Repoint the JSDoc `See:` link from the (now-redirected) URL
  `sessions-identity/identifying-users-and-agents` to the canonical
  AI Transport authentication page at `concepts/authentication`.

Also updates README.md and docs/get-started/vercel-use-chat.md to
use the new path so the documented setup matches the demo code.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 92.96% 2830 / 3044
🔵 Statements 90.92% 3037 / 3340
🔵 Functions 92.62% 465 / 502
🔵 Branches 78.57% 1533 / 1951
File CoverageNo changed files found.
Generated in workflow #567 for commit ab92e74 by the Vitest Coverage Report Action

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant