Commit Graph
28 Commits
Author SHA1 Message Date
RainbowBird 16f9aaa4e3 feat(auth): enhance OAuth linking flow with account selection and error handling
- Added `prompt: 'select_account'` for Google and GitHub providers to force account selection during OAuth linking.
- Introduced localized error messages for account linking issues in multiple languages.
- Implemented a function to resolve OAuth error codes to specific i18n keys for better user feedback.
- Updated account settings page to display relevant error messages based on OAuth linking status.
2026-06-10 16:42:13 +08:00
RainbowBird 2ac4e90d56 feat(auth): add account linking support for different email providers 2026-06-09 17:46:51 +08:00
RainbowBird 57ba232432 feat(auth): migrate auth ui to unique domain 2026-06-09 00:15:34 +08:00
RainbowBird cf5ed0766b fix(server): make analytics best-effort
Remove server-side PostHog wiring so request handlers no longer wait on third-party analytics delivery.

Keep auth activity and product event writes best-effort so degraded analytics do not fail session creation.

Signed-off-by: RainbowBird <git@luoling.moe>

Commit-Message-Assisted-by: Codex (via Codex)
2026-06-05 16:27:10 +08:00
RainbowBird 7ac69db4ef feat(server): add product analytics events (#1941) 2026-06-03 23:03:33 +08:00
RainbowBird 0ac9b709a2 refactor(server): integrate better-auth admin plugin (#1873) 2026-05-26 02:04:25 +08:00
RainbowBird 201beae5ac fix(server): import 2026-05-18 23:48:11 +08:00
RainbowBird c627bce9c9 refactor(server): split services into domain/adapter layers, drop dead code
Why
- src/services/ was an unordered mix of single-file services and module
  directories with no shared classification axis, plus several long-dead
  admin batch helpers that survived the move to the simpler synchronous
  admin-flux-grants flow.

What
- services/ now has two top-level layers:
    domain/   — DB state + business rules (billing, characters, chats,
                flux, flux-transaction, llm-router, providers, request-log,
                stripe, user-deletion, admin/{flux-grants,router-config})
    adapters/ — thin wrappers over external SDKs / infra (config-kv, email,
                posthog, tts/)
- admin/* moved under domain/admin/ with consistent plural names
  (flux-grants, router-config).
- tts-adapters/ collapsed to adapters/tts/ (no redundant -adapters suffix
  once nested under adapters/).
- 63 src files + scripts/e2e-llm-router.ts + tests/verifications/_harness.ts
  had relative imports rewritten; git mv preserves blame.
- apps/server/CLAUDE.md and docs/ai-context/*.md updated to match new paths.

Dead code removed
- services/admin-flux-grant-batches/ (service + worker + tests, 1090 LOC) —
  superseded by admin-flux-grants and never wired into app.ts.
- routes/admin/flux-grant-batches/ — same.
- utils/redis-compressed.ts + test — zero production call sites.
- llm-router/index.ts re-exports trimmed from 26 to 6; only symbols with
  external consumers are kept.

Intentionally kept
- schemas/flux-grant-batch.ts and its schemas/index.ts export remain so the
  drizzle-kit generate diff stays empty. Removing them is a separate PR
  that owns the drop-table migration for flux_grant_batch /
  flux_grant_batch_recipient.

Verification
- pnpm -F @proj-airi/server typecheck: passes.
- pnpm exec eslint apps/server: 49 errors, identical to main baseline
  (all are pre-existing node/prefer-global/buffer in envelope-crypto and
  scripts/e2e-llm-router; untouched by this change).
- Vitest passes per-file; the 6 mockDB hook timeouts under full-parallel
  run are the known pushSchema-per-worker infra cost, not a regression.
2026-05-18 23:36:45 +08:00
RainbowBird 31376fc6f1 feat(server, stage-ui): metrics 2026-05-18 23:29:14 +08:00
Lulu 98b1b9c34f feat(server): env-based trusted origins for Capacitor dev (#1763)
## Description

Adds optional env **`ADDITIONAL_TRUSTED_ORIGINS`**: comma-separated
browser origins that are trusted for **CORS (`/api/*`)**, **Stripe
return URLs**, **Better Auth `trustedOrigins`**, and **dynamic web OIDC
redirect URIs**.

LAN / non-localhost Capacitor dev (e.g. Pocket + Vite on
`https://10.x:5273`) no longer relies on broad private-IP regex;
operators list exact origins in `.env.local` and restart the API server
after changes.

## Linked Issues

<!-- N/A -->

## Additional Context

Pocket iOS dev workflow: `cap`/`capacitor.config` often points at a LAN
HTTPS origin; without this allowlist the API rejects those
`Origin`/`Referer`/`redirect_uri` bases. Review can stay focused on
**`apps/server/src/libs/env.ts`**,
**`apps/server/src/utils/origin.ts`**, and wiring in **`app.ts`**,
**Stripe**, **auth routes**.
2026-05-14 16:17:13 +08:00
hahaqwq ab7ca0ef58 feat(auth): add new redirect URI for deep linking in trusted client (#1796) 2026-05-14 16:12:30 +08:00
RainbowBird 272cdae03b feat(server/otel): restructure observability metrics and add active sessions gauge
- Moved RateLimitMetrics import path to a more centralized location.
- Introduced a new file for active sessions gauge to track user sessions in the database.
- Updated index.ts to include new metrics and ensure proper initialization of observability metrics.
- Modified various routes and services to utilize the new observability structure.
- Added smoke tests for HTTP and WebSocket metrics to ensure proper metric registration and functionality.
- Enhanced error handling for metrics reading failures to improve observability.
2026-05-12 23:10:13 +08:00
RainbowBird 6f0b7e0b9b feat(auth): delete account (#1756) 2026-04-28 20:53:00 +08:00
RainbowBirdandLiet Blue 0af7d294a8 feat(auth): oidc jwt bearer plugin & linked social accounts (#1753)
Co-authored-by: Liet Blue <127093491+lietblue@users.noreply.github.com>
2026-04-28 16:56:51 +08:00
RainbowBirdandLiet Blue 172e4ce59c feat(auth): email login & profile (#1745)
Co-authored-by: Liet Blue <127093491+lietblue@users.noreply.github.com>
2026-04-28 00:07:38 +08:00
RainbowBird fc0ad03411 feat(server): require BETTER_AUTH_SECRET and pass it explicitly to betterAuth
Without a stable secret, better-auth generates a random one per process,
which invalidates every session cookie and JWKS private key on redeploy
and across multi-instance deployments. Make it a required env var and
wire it into betterAuth({ secret }) explicitly so missing config fails
fast at boot instead of silently rotating keys.
2026-04-13 18:13:19 +08:00
RainbowBird d782313464 feat(auth): jwt sign 2026-04-02 17:48:12 +08:00
RainbowBird f1fe161bc0 feat(auth): OIDC (#1531) 2026-04-02 04:24:04 +08:00
RainbowBird 33bf61f3f7 fix(server): no cache 2026-03-30 19:45:43 +08:00
RainbowBird bdb01d30f4 feat(auth): Bearer token handling and OAuth token extraction (#1501) 2026-03-28 20:27:47 +08:00
RainbowBird bb0c93edb4 fix(server/auth): skip state_mismatch check 2026-03-28 15:47:19 +08:00
RainbowBird 88c195f672 fix(server): better-auth cookie login 2026-03-28 05:41:43 +08:00
RainbowBird 4a85654d9b feat(server/otel): follow opentelemetry metrics sharded 2026-03-28 04:57:28 +08:00
RainbowBird bf85158aa9 fix(server,stage-ui,i18n): address PR #1376 review comments 2026-03-28 02:25:44 +08:00
RainbowBird ef18772798 feat(server): message queue 2026-03-28 02:25:44 +08:00
RainbowBird 5b1ccb55c2 fix(auth): clarify return type and avoid TS2742 in createAuth function
fix(tests): cast response data to any in character and provider tests
refactor(v1completions): use Array.at() for last data line retrieval
feat(accounts): add indexes for session, account, and verification tables
chore(deps): update package.json and pnpm-lock.yaml with new dependencies
refactor(onboarding): replace context injection with props in step-welcome component
2026-03-28 02:25:44 +08:00
RainbowBird a2356608fe refactor(server): api server url env 2026-03-03 17:36:40 +08:00
RainbowBird 3c1fbdb654 refactor(server): move auth, db and env to libs 2026-03-02 16:55:16 +08:00