* fix(auth): OrangeCat sign-in on AccountKit works, and keeps its tokens
AccountKit 0.19.0 fixes a first OrangeCat sign-in failing with
unable_to_create_user (Loki's mirror recorded the link before
better-auth stored its own) and hands the provider's tokens to
onAccountCreated. ensureLokiUser now keeps OrangeCat's token set in
Loki's accounts, where publish, promote and the wallet read it; on
AccountKit nothing reached them before, because AccountKit stores no
provider token. Migration 0131 drops the trigger that was meant to copy
them out of auth_accounts.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmud6zcK4rStBGmYSML
* style: format the generated migration meta
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmud6zcK4rStBGmYSML
---------
Co-authored-by: Claude <noreply@anthropic.com>
Loki moves from Auth.js to @bitbaum/accountkit one reversible step at a
time, as evig, kivvi, petvity and surf-your-life do. Nothing changes while
AUTH_RUNTIME is unset.
- Migration 0130: AccountKit's tables under `auth_`, and the mirror
functions: users <-> auth_users, and AccountKit's OrangeCat token set into
Loki's `accounts`, where publish, promote and the wallet read it.
- scripts/db/accountkit-import.sql + a rollback-only rehearsal: ids, Loki's
own scrypt hashes (read through AccountKit 0.17.0's legacyPassword),
verification, OrangeCat links, a placeholder address for people with none;
collisions, drift and a live shared runtime refused.
- src/lib/auth/shared/: the runtime, the session re-read from `users` on
every request, and a bridge for next-auth/react: email, the invite's
user-password and the owner key (stored hash only), OrangeCat sign-in or
link, and the studio's server signIn by redirect. GitHub, Google and X are
not offered on this runtime (getEnabledAuthProviders knows it).
- src/lib/auth/bootstrap.ts: onboarding heal and personal org, now one
function both runtimes call.
- The proxy reads the shared session and asks the same authorized().
- /api/me/password keeps the caller's shared session.
- scripts/test/accountkit-journeys.ts joins `test:db` (16 journeys and the
rehearsal on CI's Postgres).
docs/architecture/accountkit-migration.md records what blocks the switch,
chiefly GitHub/Google sign-in and the GitHub repository token.
Claude-Session: https://claude.ai/code/session_019MDtmud6zcK4rStBGmYSML
Co-authored-by: Claude <noreply@anthropic.com>