Skip to content

fix: prevent stale Personal Server URL after Account OAuth login - #6

Merged
tnunamak merged 1 commit into
mainfrom
waspflow/cli-account-ps-sync
Jul 2, 2026
Merged

fix: prevent stale Personal Server URL after Account OAuth login#6
tnunamak merged 1 commit into
mainfrom
waspflow/cli-account-ps-sync

Conversation

@tnunamak

@tnunamak tnunamak commented Jul 2, 2026

Copy link
Copy Markdown
Member

Summary

This is a preparatory correctness/UX fix, not full Account-OAuth → Personal-Server sync enablement. It closes gaps that are reachable and fixable purely client-side; it does not (and cannot yet) make Account OAuth login reliably resolve a real Personal Server for every account. See "What's still needed" below.

  • Fix a real bug: after a cloud OAuth login that reports no Personal Server, the CLI left a previously logged-in account's personalServerUrl pinned in ~/.vana/vana-connect-state.json. Re-logging into a different account could silently keep pointing the CLI at the wrong PS. runLogin now always syncs (including clearing) the pinned config to the new login's result.
  • Read Personal Server fields from OAuth id_token claims as a fallback source, alongside the existing top-level token-response fields (personal_server_url, personal_server_session_token, ps_access_token), mirroring the existing pattern already used to resolve the account address from claims.
  • When a cloud login succeeds with no Personal Server, tell the user clearly instead of silently omitting it, with a concrete next step (vana server set-url <url>).

What's still needed (out of scope here)

The legacy connect app's /api/auth/device/poll route resolves a caller's Personal Server server-side (findServerByUserId against personal_servers/sessions tables) and returns it in the poll response. Unity Account has no equivalent authenticated-session endpoint — nothing a CLI can call with just an OAuth access/session token to mint or fetch that caller's Personal Server URL and a fresh PS session token. The closest existing pieces (/api/oauth/introspectlinked_wallets, and the on-chain lookupPersonalServerByOwner helper in packages/vana-account-client) require either wallet-signature auth the CLI doesn't have, or an on-chain contract read the CLI doesn't currently implement — a materially larger change (new viem dependency, new lookup flow) than this PR's scope. Full sync requires Account to expose (or mint) an authenticated PS URL/session-token lookup; until then, real-world cloud OAuth logins will keep landing with personal_server: null unless the token response happens to include it.

Full findings in the accompanying report: /home/tnunamak/.tmp/vana-cli-account-ps-sync-report.md.

Test plan

  • pnpm build
  • pnpm test (269 tests, including 3 new targeted tests)
  • pnpm validate (lint + eslint + format + test)
  • New tests:
    • test/cli/auth.test.ts: OAuth id_token claims resolve PS info when the token response omits it; personal_server stays null when OAuth returns no PS info at all.
    • test/cli/index.test.ts: stale pinned PS URL is cleared when cloud login resolves none (with the new user-facing hint); PS URL is pinned when cloud login does resolve one.

Account OAuth login (the OIDC device-grant path added in #3) never
returns Personal Server fields on the real token response, so the CLI
silently kept a previous account's pinned personalServerUrl in
~/.vana/vana-connect-state.json after switching accounts. Clear it
whenever a fresh login reports no PS, and read PS fields from
id_token claims as a secondary source alongside the top-level token
fields. Surface a clear "no Personal Server found" hint instead of
silently omitting it.

This is a preparatory correctness/UX fix, not full Account OAuth -> PS
sync enablement: Unity Account has no authenticated-session endpoint
that mints or returns a caller's Personal Server URL/session token
(the legacy connect app's device-poll route does this via
personal_servers/sessions tables, but Unity Account doesn't expose an
equivalent yet). See the accompanying report for what's still needed
server-side.
@tnunamak tnunamak changed the title fix: prevent stale Personal Server URL after Account OAuth login (partial — not full PS sync) fix: prevent stale Personal Server URL after Account OAuth login Jul 2, 2026
@tnunamak
tnunamak merged commit 60288c4 into main Jul 2, 2026
7 checks passed
@tnunamak
tnunamak deleted the waspflow/cli-account-ps-sync branch July 2, 2026 03:45
github-actions Bot pushed a commit that referenced this pull request Jul 2, 2026
## [0.15.1](v0.15.0...v0.15.1) (2026-07-02)

### Bug Fixes

* prevent stale Personal Server URL after Account OAuth login ([#6](#6)) ([60288c4](60288c4)), closes [#3](#3)
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.15.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant