Petvity moves from Auth.js to @bitbaum/accountkit one reversible step at a
time, as evig and kivvi do. Nothing changes while AUTH_RUNTIME is unset.
- Migration 0008: AccountKit's tables under an `auth_` prefix, plus the
users <-> auth_users mirror functions, inert until attached.
- scripts/db/accountkit-import.sql: accounts under their own ids, bcrypt
hashes byte for byte, verification kept, orangecat_sub as an `orangecat`
account row; refuses collisions, drift or a live shared runtime, then
attaches the triggers. The rehearsal CLI always rolls back.
- lib/auth/shared/: the runtime (ids: 'uuid', legacy bcrypt, AccountKit
0.16.0), a session reader re-read from `users` on every request, a bridge
that answers next-auth/react including "Sign in with OrangeCat", and a
Petvity row for a person AccountKit creates itself. AccountKit's own
credential endpoints stay closed; Petvity's writers stay the only ones.
- lib/auth/claims.ts: the ADMIN_EMAILS promotion rule, written once.
- The proxy has one routing function and two session sources.
- browser-smoke.yml runs the account journey once per runtime; the
AccountKit leg first runs the rehearsal and the real-database journeys.
docs/ACCOUNTKIT-MIGRATION.md records what is left before switching.
Claude-Session: https://claude.ai/code/session_019MDtmud6zcK4rStBGmYSML
Co-authored-by: Claude <noreply@anthropic.com>
* fix(auth): the proxy no longer re-issues the session cookie
Auth.js's auth() proxy wrapper appends a fresh session cookie to every
response it handles, Link prefetches included. A prefetch that left the
browser before Sign out came back after it and set the old, still-valid
JWT again, so the person stayed signed in. The new browser journey hit
this in about one sign-out in three.
The proxy now drops only the session-token Set-Cookie it would add; the
session still rolls through /api/auth/*, which SessionProvider calls on
every page load.
Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmuJhiHPASaR5k8raL9
* ci(browser-smoke): register, sign out, sign in and no stray Google button
browser-smoke.yml runs scripts/ci/account-journey.mjs in Chromium against
the production build and a throwaway Postgres 17: register through
/register, see the portal, sign out from the sidebar, a wrong password
refused, the right one accepted, no sideways scroll on /login and
/register at 390px. With no GOOGLE_* pair it checks that no Google
provider is mounted and no Google button is drawn, the guard for the
invalid_client sign-in of 2026-10-30.
Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmuJhiHPASaR5k8raL9
---------
Co-authored-by: Claude <noreply@anthropic.com>
The product was renamed on 2026-09-14: bitbaum/loki, loki.orangecat.ch,
LOKI_* env keys, loki-* units. This repo referenced the old name in
9 files changed, 15 insertions(+), 15 deletions(-).
Email addresses at the old sending domain stay until the new domain is
verified in Resend.
Claude-Session: https://claude.ai/code/session_016YJVAanfj8keVSXyZnTemh
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
* chore: add a formatter, matching the style this repo already writes
singleQuote=false was chosen by counting this repo's own
imports, not by fleet decree. The fleet is genuinely split and the two repos
that already had a .prettierrc disagreed with each other, so there was no
standard to restore. Quote style does not cross repo boundaries; having a
gate does.
Markdown is ignored for now — prettier rewraps prose, which would bury the
real diff.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* style: format with prettier (252 files)
Mechanical. No behaviour change. This SHA is listed in
.git-blame-ignore-revs so `git blame` skips it.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* chore: teach git blame to skip the reformat
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
The public storefront was a brochure. It shipped a Product/Offer JSON-LD so
search engines treat it as purchasable, then the only buy path was
"Sign up to buy" -> /register?returnTo=/portal/shop, which both forced
registration before a first purchase and dropped the product the visitor came
for. Cold traffic could not buy anything.
A visitor can now add to cart on the catalogue and the product page, check out
in one page with an email and an address, and read their order back from a
receipt link. No account anywhere in that path.
orders.userId becomes nullable, alongside guestEmail and an unguessable
publicToken. A CHECK constraint enforces exactly one of userId / guestEmail,
because an order with no reachable buyer cannot be repaired after the fact.
The token is the guest's only handle on their order: it is emailed, never
listed, and authorises resuming payment and cancelling while pending.
Order placement moves to placeOrder() in lib/domain/orders.ts so the authed
cart and the guest checkout share one implementation -- the stock reservation
and its compensation must not exist twice. setOrderStatus() joins it for the
same reason: a cancellation that forgot to restore stock destroys inventory,
and that happens when one route remembers and another does not.
Two joins were fixed before any UI existed. app/api/orders/seller and
app/api/admin/orders inner-joined users on orders.userId; with a nullable
column that drops every guest order from the views of the people who have to
ship them -- real revenue, invisible, nothing appearing broken. Both are now
leftJoin + COALESCE onto the address the buyer typed.
Also fixed while reviewing:
- toLocale() used `value in LOCALE_CONFIG`, true for inherited keys like
"constructor", and the result goes straight into a URL path.
- orderShippingSchema accepted any two letters as a country, so "XX" could be
stored and printed on an undeliverable label. Checked against a new ISO-3166
SSOT whose names come from Intl.DisplayNames, so all nine locales are
translated with no message files to maintain.
- Guest input (shippingName, notes) reaches a seller's inbox unauthenticated;
email templates now escape it.
Guards, not just fixes: locale parity across all nine message files is now a
test rather than a convention, and the prod walkthrough places a real guest
order and asserts the seller can see the buyer's email -- the check that goes
red if anyone reintroduces an inner join there.
The public endpoints are deliberately outside PRIVATE_API_PREFIXES; a session
guard there would silently delete the feature. They are rate limited per
client, and the payment and cancel routes require the order token.
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Listing a product required pasting an image URL, which quietly assumed the
seller already hosted the picture somewhere. Everyone who sells has photos on
their phone; nobody has a CDN. That single field is why a real listing could
not be created without leaving the product first — and prod currently has zero
products.
Both product forms (seller's /portal/my-products and /admin/products) now take
a file: pick, preview, replace, remove.
The upload endpoint is deliberately not scoped to a product id. The seller
chooses the photo while filling in the "new product" form, before a row exists;
scoping it would force create-then-upload and leave a product visibly imageless
whenever the second call failed. It returns a URL the form submits as imageUrl,
so create and edit take the identical path.
Files land in UPLOADS_DIR (/opt/petvity/uploads on the box, outside the app
directory so they survive deploys) and Caddy serves them from /uploads/*.
Also fixes a drift this would have made worse: the upload limits lived inline
in the avatar route, and its file picker offered JPEG/PNG/WebP while the API
also accepted GIF — so a GIF was rejectable by the UI and acceptable to the
API. Limits are now SSOT in lib/config/uploads.ts, used by both routes, both
pickers and the hint text, so they cannot disagree again.
/api/uploads is added to PRIVATE_API_PREFIXES — it writes files to disk and
must never be reachable without a session.
8 tests cover the endpoint: stores and returns the URL, keys uploads by
uploader, refuses anonymous callers, no file, over-cap, exactly-at-cap,
non-image type, and a storage failure reported instead of a fake success. The
size gate needed real bytes — FormData rebuilds the File from its content, so a
patched `size` property is discarded in transit and the gate would never fire.
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
The dashboard answered one question — how are my pets? — and left everything
else the platform does undiscovered behind the sidebar. It now also shows what
is already in motion (the next three appointments, the three most recent
orders) and a role-aware "what would you like to do?" grid: find care, shop,
adopt, and either offer your services or manage your bookings, either set up a
store or manage the one you have.
The greeting was computed from new Date().getHours() during a server render,
which is the box's UTC rather than the reader's clock — an evening visitor in
Zurich could be wished good afternoon. It is now clock-free, and the space it
occupied says what the page is for instead.
Page purpose lines, all nine locales. The worst of them was Find a Pro:
"Connect with verified veterinarians and trusted pet sitters" claimed a
verification most professionals do not have, and omitted groomers entirely
even though grooming has been a first-class vertical since #27. Six others
described what the page contained rather than what you could do on it.
PageHeader replaces the hand-rolled title/subtitle/action markup on bookings,
find, settings, shop and orders — one header instead of five near-copies.
Status badges now resolve to the semantic badge-* tones from globals.css
through a `badge` field on the status config, rather than a parallel set of
arbitrary-value Tailwind strings that happened to render the same colours.
Documented that the liveness probe is /api/healthz: /api/health is the private
prefix for health metrics and records, so it always redirects to /login and can
never report healthy — the runbook pointed at a path that could not work.
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Groomer joins vet and sitter everywhere a professional exists:
- user_role enum + groomer_profiles (salon, services, from-price) + migration
- /api/groomers browse + /api/groomers/me CRUD; role plumbed through
registration (?role=groomer), become-a-pro, availability, bookings,
conflict guard, admin verification, dashboards, sidebar
- Find a Pro gains a Groomers tab; booking modal books grooming as a
one-hour session with the salon's from-price in the header
- Public pro profile renders groomers (salon, services, starting price)
- Resident groomer Nadia Roth / Salon Pfotenschick seeds via the daily
cron with a completed booking + 5-star review, so the tab ships alive
- 6 grooming services in the professionals SSOT; role badge tokens in
globals.css; ~25 strings x 9 locales
Verified end-to-end locally: register groomer -> profile -> visible in
browse -> booked 201 -> overlap 409. verify + build green.
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
* feat(bookings,shop): calendar conflict blocking + Stripe payment integration
Tier-1 scheduling: the booking API now rejects (409) any request that
overlaps a professional's active bookings or their self-declared blocked
dates; vets/sitters manage blocked ranges at /portal/professional-profile
(new professional_blocked_dates table + /api/availability CRUD).
Payments: full Stripe Checkout flow, env-gated like Resend — without
STRIPE_SECRET_KEY nothing changes; with it, checkout redirects to Stripe,
the signed webhook (/api/payments/webhook) marks orders paid, and unpaid
orders stay payable from /portal/orders (Pay now + paid/awaiting badges).
orders gains paid_at + checkout_session_id.
Critical bug found by the smoke test: the login JWT callback wrote
resolveRole(email) back to the DB, silently DEMOTING every vet/sitter to
pet_owner at their next sign-in (residents were safe only because they
never log in). ADMIN_EMAILS now only promotes; professional roles survive.
Verified end-to-end locally: sitter registers → blocks dates → owner
booking overlap 409, blocked-dates 409, disjoint 201; checkout w/o keys
falls back to recorded orders. verify green (1209 tests incl. 12 new).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* chore: nudge CI (pull_request event was never delivered)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
PR #20 removed the editorial tokens (--gold*, --cream*, .section-warm-dark,
.section-cream) but only reskinned the marketing pages — all 6 (auth) pages
and 4 (public) pages still referenced them and rendered with unresolved
var() styling. Repaired and hardened:
- (auth) layout: brand panel re-expressed on the obsidian/champagne surface
(the same language visitors arrive from), form panel on the light product
surface; all 6 auth pages now use only live tokens
- (public) shop/adopt/pets/pros pages swept to live tokens
- New verify gate scripts/ci/check-css-vars.mjs: any var(--x) referenced in
app/, components/, lib/ that globals.css doesn't define fails the build —
this class of regression can't ship again (2nd occurrence; never-twice)
- DRY/SSOT: .form-label replaces 86 identical label-class repeats across 19
files; .link-accent replaces repeated link styling; register role labels
derive from USER_ROLE_CONFIG; password hint derives from
PASSWORD_MIN_LENGTH; POST_LOGIN_PATH centralized in lib/config/auth.ts
(login, demo, proxy, email templates); Terms/Privacy now link to the
actual legal pages
- Settings: display-name field no longer renders empty when the session
loads after mount (profile editing bug found in browser testing)
- Root layout <html> now carries dir="ltr" — fixes the hydration attribute
mismatch with the [locale] layout's dir
- .gitignore no longer hides scripts/ (verify depends on scripts/ci/)
Browser-verified on desktop (1280px) and mobile (390px): login (credentials
+ demo), registration end-to-end, forgot/reset password, profile edit save,
sign-out, marketing nav megamenu + mobile drawer, footer, portal sidebar +
bottom tabs. verify green: lint + typecheck + css-gate + 1181 tests; build
green.
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
- /api/healthz: public DB-pinging healthcheck. /api/health is the auth-gated
pet-data API, so deploys and uptime monitors had nothing honest to probe.
- /demo: signs a visitor into the shared demo account in one click; linked
from the marketing hero ('Try the live demo') and nav across all locales.
Also fixes two hardcoded English strings in HeroCTA.
- Demo seed claims the public handle /pets/luna (when free), so the
public-influencer-profile feature has a live showcase.
- New-pet grace: a profile younger than the 7-day alert window with no data
and nothing overdue reads healthy/'new profile' instead of an alarming
Watch badge seconds after creation. Overdue vaccinations still escalate.
- Digital-twin score is labeled 'Emotional wellness' (9 locales) so it stops
reading as a contradiction of the all-metric wellness % on the health page.
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
* fix(api): accept the form wire format on medical-history create routes
The portal forms serialize every empty optional input as null
(buildBody: `form.notes.trim() || null`), but the create schemas for
vaccinations, medications, and health records modeled optionals as
.optional() alone — which rejects null. Every save from the UI failed
with 400 'Invalid input', making the entire medical-history feature
set unusable in production. Unit tests stayed green because they
omitted the keys instead of sending null.
Schemas now use .nullish() for optional fields (the update routes were
already nullable-aware), and a new test posts the exact UI payload —
nulls included — against all three routes.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix(marketing): species guide pages no longer 500 in production
/[locale]/species/[id] was the only page declaring generateStaticParams,
but the locale layout's getMessages() needs request context — the static
prerender attempt threw DYNAMIC_SERVER_USAGE at runtime (500 in prod,
invisible in dev, where everything renders dynamically). Render it
dynamically like every other marketing page.
Also reskins the page to the editorial design system (cream/gold/serif),
matching the landing page.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix(i18n): resolve 7 missing message keys and end the class with an audit test
The public adopt page rendered raw keys ('public.adoptFilterAll',
'public.adoptSearch', …) to users: its filter-bar labels live in the
portal namespace, and four more keys (adoptNoResults, adoptClearFilters,
adoptFree, portal.loading) existed in no locale at all. The page now
reads the shared filter labels from the portal namespace, and the four
genuinely missing keys are added to all 9 locales.
New test statically extracts every literal t("key") per translator
namespace and asserts it resolves in messages/en.json — tsc and eslint
are both blind to this class; this test is not (it found 4 of the 7).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix(i18n): substitute {app} once at message-load time
47 message keys reference {app}; requiring each t() call site to pass
{ app: APP.name } shipped literal '{app}' into rendered copy on the
features page (heroDesc, ccDesc). next-intl v4 removed
defaultTranslationValues, so the request config now deep-replaces the
placeholder when messages load (memoized per locale). Call sites that
still pass the value are harmless; APP.name stays the SSOT.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix(proxy): null-safe role access in the auth redirect
session?.user.role crashes the middleware — and with it every route,
turned into a 500 — whenever NextAuth yields a session without a user
(observed locally with auth misconfiguration). One optional chain makes
the failure mode 'treated as logged out' instead of 'site down'.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* design(marketing): extend the editorial system to all marketing subpages
/features, /about, /pricing, and /pros still wore the old teal-SaaS
look (teal gradient heroes, multicolor icon chips, teal CTA bands) while
the landing page had moved to the petvity.com editorial brand. All four
now use the same language: cream sections, gold ed-icon chips, Cormorant
ed-title headlines, pill btn-editorial CTAs, warm-dark closing bands.
Presentation classes only — copy, translation keys, and structure are
untouched. (The species guide moved in the previous commit.)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Cron routes self-authenticate via the CRON_SECRET bearer. After the
Vercel exit they're invoked by systemd timers on the box; the auth
middleware was redirecting/401ing them before the route's own check ran,
so the scheduled jobs were dead. Exempt /api/cron at the gate.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- lib/db/schema.ts: add sellerProfiles table (displayName, bio, city, country, phone, website, isActive)
- app/api/sellers/me: GET / POST / PATCH handler with requireSession() guard
- proxy.ts: add /api/sellers to PRIVATE_API_PREFIXES
- app/(portal)/layout.tsx: query sellerProfiles, pass hasSeller to SidebarNav
- app/(portal)/portal/seller-profile/: page.tsx (server) + SellerProfileForm.tsx (client, full i18n)
- messages/*.json: add 17 seller i18n keys to all 9 locales (EN DE FR ES JA ZH KO TR AR)
- register/page.tsx: redirect pet owners to /portal/pets/new?from=registration after sign-up
- portal/pets/new/page.tsx: show welcome banner + redirect to health log on first pet creation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Yesterday's commit (00627fb) shipped a settings toggle for the
welcome series, but users had no way to discover it from the email
itself. Closing the loop with a tokenized unsubscribe URL — works
for logged-out recipients (the common case for marketing email).
- lib/auth/unsubscribe-token.ts: HMAC-SHA256 over userId, signed with
NEXTAUTH_SECRET. Constant-time verification, length-checked before
timingSafeEqual to avoid throws on shorter inputs. Returns undefined
(not throws) when secret is missing so test/dev environments don't
break — production has the secret because NextAuth requires it.
- lib/email/templates.ts: base() takes optional unsubscribeUrl;
rendered as a footer link only when supplied. The 4 welcome
templates accept it via the WelcomePayload type. Transactional
templates (vaccination/medication/health/order) intentionally have
no opt-out — they're necessary for the service.
- /api/cron/emails + POST /api/account: build the URL from user.id at
send time (not enqueue time, so existing queued items get the link
retroactively, and the token-rotation point stays in one helper).
- /unsubscribe page (app/unsubscribe/page.tsx): server component,
GET shows confirmation form, server action verifies+flips
digestOptOut+redirects with done=1 to render the success card.
Three states: invalid link, confirm, done.
- proxy.ts: new PUBLIC_BYPASS_PATHS list for /unsubscribe — bypasses
intl routing AND skips the AUTH_PATHS redirect-when-logged-in (so
the email link works whether the recipient is logged in or not).
- 9 token-helper tests cover sign/verify, tampering, wrong-length,
missing-secret, URL-encoding, determinism, and secret-rotation.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Add reviews table to schema with unique bookingId constraint (pushed to Neon)
- Add /api/reviews GET (list with avg/count) + POST (owner, completed booking only)
- Bookings page: Review button on completed unreviewed bookings, StarPicker modal
- Find page: star rating + review count shown on vet/sitter cards
- Vet/sitter list APIs now include avgRating + reviewCount via single aggregation query
- Bookings API GET now LEFT JOINs reviews to return reviewId
- Add /api/reviews to PRIVATE_API_PREFIXES in middleware
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add booking_status enum + bookings table to schema (pushed to Neon)
- Add /api/bookings GET (list own) + POST (create, owner-only) endpoints
- Add /api/bookings/[bookingId] PATCH (confirm/cancel/complete) + DELETE
- Add /portal/bookings page with upcoming/past sections and status actions
- Add Book button + modal to /portal/find page (pet selector, dates, notes)
- Show phone numbers on vet/sitter cards in find page
- Add Bookings nav item to SidebarNav
- Add /api/bookings to PRIVATE_API_PREFIXES in middleware
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add vetProfiles + sitterProfiles tables to schema (pushed to Neon)
- Add /api/vets and /api/sitters list endpoints with city/accepting filters
- Add /api/vets/me and /api/sitters/me upsert endpoints (role-scoped)
- Add /portal/professional-profile page (server-rendered, role-checked)
- Add /portal/find discovery page (tabs: vets/sitters, city filter)
- Update SidebarNav: Find a Pro for all users, My Profile for professionals
- Add /api/vets + /api/sitters to PRIVATE_API_PREFIXES in middleware
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Previously all /api/* routes were in PORTAL_PREFIXES, which blocked:
- /api/account (registration) — unauthenticated users couldn't sign up
- /api/public/* — public pet profiles required login
- /api/auth/forgot-password and /api/auth/reset-password
Fix: split PORTAL_PREFIXES (/portal, /admin) from PRIVATE_API_PREFIXES
(explicit list of private API path prefixes). All other /api/* routes
pass through without auth. Added catch-all /api/* pass-through before
intl routing to prevent locale prefix being added to API paths.
Also updates CLAUDE.md to document the correct middleware rules.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Full Phase 1 scaffold:
- Next.js 16 + TypeScript strict + Tailwind 4 + Neon/Drizzle + NextAuth 5
- 9-language i18n (EN DE FR ES JA ZH KO TR AR) with RTL support for Arabic
- SSOT config: species (10 types), health metrics (7 KPIs), pet signal system
- DB schema: pets, healthMetrics (unique per pet+day), vaccinations, medications,
healthRecords, emailQueue
- Numeric storage: weight=grams, temperature=centidegrees (no float drift)
- computePetSignal() — pure domain function, 9 unit tests passing
- API routes: auth, account, pets CRUD, health metrics (upsert), records,
vaccinations, medications, public pet profiles (no auth)
- Cron: health-alerts, vaccination-reminders, email queue (all Bearer-protected)
- Portal UI: dashboard, pet list, add pet, health tracking, log page, vaccinations
- Public influencer pet profiles at /[locale]/pets/[handle]
- Email templates: welcome sequence, health alert, vaccination reminder
pnpm build ✓ pnpm test ✓ (9/9)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>