Skip to content

feat(accounts): re-enable adding & switching multiple Farcaster accounts - #16

Merged
arcabotai merged 1 commit into
mainfrom
feat/multi-account-add
Jun 22, 2026
Merged

arcabotai merged 1 commit into
mainfrom
feat/multi-account-add

Conversation

@felirami

Copy link
Copy Markdown
Collaborator

Re-enables Supercast's multi-account control. An investigation (current fork vs. the original Supercast dump) found ~80% was already intact — the ConnectedAccount/SharedAccount data model, isAuthorized + asFid (a real trust boundary), the account switcher, acting-as on feed/notifications/cast, and the full sharing/delegation flow. The only real gap was the "Add account" button, a hard alert() stub wired to the retired super-auth redirect — and the SIWN handler reassigned the primary fid instead of attaching a sibling account.

Changes

  • POST /api/account/add-account (new) — additive Sign-in-with-Neynar handler. Upserts the SupercastFarcasterAccount and creates a ConnectedAccount for the current user, and never writes supercastPrivyUser.fid (the bug in siwn's setupUserSigner).
  • Collision guard — blocks (409) if the fid is already another Castora user's primary, connected account, or shared account, so the signer upsert can only ever touch the user's own account.
  • /add-account page + AddAccountForm (new) — mirrors the proven onboarding SIWN pattern; invalidates user state, then switches into the new account.
  • Re-pointed the ProfileBar + MobileSidebar "Add account" buttons; removed the dead create-connection / AUTH_URL redirect code.

Switching, acting-as, and sharing already worked and are unchanged.

Verification

  • npm run typecheck ✅, npm run build ✅ (/add-account + /api/account/add-account compile).
  • Two adversarial reviews (data-mutation safety + end-to-end flow), all findings addressed:
    • Tightened the collision guard from primary-only to any other user's owned/shared link (prevents overwriting another user's signer).
    • Redirect-during-load fixed (guards on isReconnecting()/hasLoadError() so a legit user isn't bounced to onboarding while user/state loads).
    • Switch-before-refetch flicker fixed (invalidate the accounts list before switching into the new fid).
  • Live end-to-end (add → switch → public test cast) to be run on the deploy.

Security notes (unchanged behavior, but more reachable now)

  • Sharing grants full write delegation (no granular/read-only perms, no audit log).
  • Privy is the only auth factor (no MFA) — a compromised login exposes all connected + shared accounts.
  • No per-account cap / plan gate on add-account (the MANY_ACCOUNTS premium label exists but isn't enforced) — easy to add later.

Follow-ups (not in this PR)

  • Retire dead super-auth code (create-connection, the 410 create-signer/verify-farcaster routes, AccountConnectionSession model + signer.ts helpers) — needs a careful Prisma migration, kept separate.

Supercast's multi-account control was ~80% intact in the fork (data model,
isAuthorized/asFid, the account switcher, sharing/delegation) but the "Add
account" button was a hard stub (alert) wired to the retired super-auth redirect,
and the SIWN handler reassigned the primary fid instead of attaching a sibling.

- New POST /api/account/add-account: additive Sign-in-with-Neynar handler that
  attaches an additional owned account (upsert FarcasterAccount + create
  ConnectedAccount) and NEVER touches supercastPrivyUser.fid. Blocks attaching an
  account another Castora user already owns/shares (409), so the signer upsert only
  ever touches the user's own account.
- New /add-account page + AddAccountForm (mirrors the proven onboarding SIWN
  pattern; invalidates user state, then switches into the new account).
- Re-point the ProfileBar + MobileSidebar "Add account" buttons at it and remove the
  dead super-auth create-connection / AUTH_URL redirect code.

Switching, acting-as (feed/notifications/cast via asFid), and sharing
(delegate-access) already worked and are unchanged.

Verified: typecheck + build green; adversarial review of data-mutation safety +
end-to-end flow (collision guard tightened, redirect-during-load and
switch-before-refetch fixed).
@vercel

vercel Bot commented Jun 22, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
castora Ready Ready Preview, Comment Jun 22, 2026 11:44am

@arcabotai
arcabotai merged commit 649ab87 into main Jun 22, 2026
6 checks passed

This branch was successfully deployed

1 active deployment
Preview — 1014f3e1 Deployed Jun 22, 2026 by vercel[bot]
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