Skip to content

feat(sessions): sessions list and revoke command#55

Merged
Bccorb merged 1 commit into
mainfrom
feat/sessions-command
Jul 14, 2026
Merged

feat(sessions): sessions list and revoke command#55
Bccorb merged 1 commit into
mainfrom
feat/sessions-command

Conversation

@Bccorb

@Bccorb Bccorb commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Summary

Sixth issue in the CLI auth epic (#38). Adds seamless sessions to list and revoke the logged-in user's active sessions from the terminal, built on the authenticated client (#41).

Commands

  • seamless sessions (or sessions list): GET /sessions, renders each session's id, device or user agent, IP, and last-used time, with the current session marked (*).
  • seamless sessions revoke <id>: DELETE /sessions/:id. A 404 is reported as "may already be revoked" rather than an error.
  • seamless sessions revoke --all: DELETE /sessions.

Revoking the current session (detected via the current flag on the list) or --all prompts for confirmation first, and on success clears the local keychain tokens, since that request signs the CLI out. --profile / SEAMLESS_PROFILE are honored. Not-logged-in fails cleanly with the "run seamless login" message.

Contract note

The serialized session (from the auth-api serializeSession) exposes id, deviceName, ipAddress, userAgent, lastUsedAt, expiresAt, and current. There is no createdAt in the payload, so the list shows lastUsedAt (the issue mentioned created and last-used; only last-used is available from the API).

Structure

  • src/core/sessions.ts: listSessions, revokeSessionById, revokeAllSessions, unit tested against an injected AuthClient.
  • src/commands/sessions.ts: the @clack/prompts front end (rendering + confirmation).

Tests / verification

  • npm run build (tsc strict): passing.
  • npm test (vitest): 58 passing (5 new): list mapping with the current marker, malformed-entry filtering, non-ok list error, revoke-by-id with URL encoding, 404 surfaced, and revoke-all routing.
  • Smoke-tested the not-logged-in paths for sessions and sessions revoke (clean message, exit 1).

Live end-to-end remains blocked by #50 (conformance stack cannot start the auth-api on Node 20 vs the >=24 engine); the logic is covered by injected-client unit tests, and a real drive-through fits under #47 once #50 lands.

Acceptance criteria

  • Listing shows all active sessions for the user.
  • Revoking a session is reflected on the next list (server-side revoke via the documented endpoints).
  • Revoking the current session prompts for confirmation first.

Closes #44

Add seamless sessions to view and revoke the logged-in user's active sessions.
sessions (or sessions list) calls GET /sessions and renders each session's id,
device or user agent, IP, and last-used time, marking the current session.
sessions revoke <id> calls DELETE /sessions/:id and sessions revoke --all calls
DELETE /sessions.

Revoking the current session, or all sessions, confirms first and then clears
the local keychain tokens, since that request signs the CLI out. The network
logic lives in core/sessions.ts (listSessions, revokeSessionById,
revokeAllSessions) and is unit tested against an injected client; the command is
a thin front end. Accepts --profile and honors SEAMLESS_PROFILE.

Closes #44
@Bccorb
Bccorb merged commit f1e62e4 into main Jul 14, 2026
1 check failed
@Bccorb
Bccorb deleted the feat/sessions-command branch July 14, 2026 02:13
Bccorb added a commit that referenced this pull request Jul 17, 2026
feat(sessions): sessions list and revoke command
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.

seamless sessions command (list and revoke)

1 participant