Skip to content

Native apps: server prep (CORS, push transport) - do not merge before Konrad/Hugo review - #38

Draft
0xkkonrad wants to merge 3 commits into
mainfrom
native-server-prep
Draft

0xkkonrad wants to merge 3 commits into
mainfrom
native-server-prep

Conversation

@0xkkonrad

@0xkkonrad 0xkkonrad commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Server parts the Peanut Split iOS and Android apps need on production before the first store build is useful. Draft. Do not merge before Konrad and Hugo review it.

The branch is rebuilt by local/split-native-app/tools/server-prep.sh (mono, not in this repo) from origin/main plus a fixed allowlist taken from native-apps (draft PR #37). The script never auto-includes a file: it fails, naming the file, if an allowlisted file imports anything that is neither on main nor on the list. docs/current/generated/*.md are regenerated on this branch, not copied.

Contents, and why each is inert for web users

Change Why a web user sees no difference
src/lib/cors.ts + src/proxy.ts (+ tests): CORS for capacitor://localhost and https://localhost on /api/* Browsers on peanutsplit.com send a same-origin Origin or none, so corsFor returns null and the response is unchanged. Any other origin still gets no Access-Control-Allow-Origin. Redirects (alias hosts) are untouched.
src/proxy.ts: internal x-split-room-slug request header on /r/<slug> pages, stripped from caller requests On main nothing reads it (the Smart App Banner layout reader stays on native-apps). The proxy deletes any caller-supplied copy, so no route can be handed a forged one.
public/.well-known/apple-app-site-association (appID PW388G893L.com.peanutsplit.app) + headers() rule serving it as application/json Read only by iOS for universal links. No app with that ID is installed yet.
src/lib/splash.test.ts: records .well-known/ as an online-only public/ folder Test only. The service worker precache list is unchanged.
public/.well-known/assetlinks.json (placeholder fingerprint) Read only by Android for app links. The placeholder verifies nothing until the Play App Signing key is filled in.
public/app-config.json + headers() rule (ACAO: *, 5 min cache) Read only by the apps' version gate. minBuild is 0 for both platforms.
next.config.js: env: { NEXT_PUBLIC_NATIVE_BUILD: '0' } Pins the flag the native code checks to '0' in the web build. No code on main reads it yet.
Prisma: PushSubscription.transport (default webpush), p256dh/auth nullable; migration 20261114011233_push_transport Additive. Existing rows become webpush and keep their keys.
src/server/push.ts, src/server/push-native/**, notifyCopy.ts, pushHosts.ts, validation.ts, push-subscriptions routes (+ server/test/push.test.ts) Web Push requests validate and send as before. A native body ({ transport, token }) gets 503 NATIVE_PUSH_UNAVAILABLE until the APNs/FCM secrets exist; no secret is set by this PR.
src/lib/api-types.ts (push input union), src/lib/error-messages.ts + errors.NATIVE_PUSH_UNAVAILABLE in the 7 catalogs Types and one error string that only a native subscribe can trigger.
src/lib/redact.ts (+ test): also redacts ?slug= Sentry redaction only gets stricter.
src/lib/analytics.ts: 4 AnalyticsEvent union entries; JoinGate.tsx fires join_gate_shown / join_gate_completed { via } Two new identity-free PostHog events (roomProps(slug) only, never a slug or name). No UI change.
src/app/(product-shell)/privacy/page.tsx Text only: names the apps, APNs and FCM as recipients, says the ad tags load on the website only.

Not included on purpose: no client guards (caches, install handoff). Browsers on main always have caches; those guards reach main with the native-apps merge.

Review

  • Konrad: review the privacy page diff (legal text).
  • Hugo: confirm the AASA team: appIDs is PW388G893L.com.peanutsplit.app (the team that ships the Peanut app). If the team differs, change that one line before merging.

Deploy checks (after merge and deploy)

  1. curl -si -X OPTIONS -H 'Origin: capacitor://localhost' -H 'Access-Control-Request-Method: GET' https://peanutsplit.com/api/currencies returns 204 with Access-Control-Allow-Origin: capacitor://localhost.
  2. curl -si https://peanutsplit.com/.well-known/apple-app-site-association returns 200 with Content-Type: application/json and no redirect.
  3. gh run rerun <latest native.yml run id on native-apps>; the Android emulator smoke log prints SPLIT_CORS ok (it prints blocked until this is live).

Verified on the branch

  • typecheck, format:check, docs:check, i18n:audit, marketing-copy:audit, ui-icons:audit, licenses:check and pnpm build (with the PWA build-boundary check): green.
  • Vitest without a database: cors, proxy, redact, splash, push-native (5 files), error-messages: 10 files, 100 tests pass. Database tests (server/test/push.test.ts, route handlers) run in ci.yml.

🤖 Generated with Claude Code

Rebuilt by local/split-native-app/tools/server-prep.sh from native-apps 3971dea
on main d31023e. These server parts must be live before the first store
build is useful, and none of them changes what a web user sees or does.
Rebuilt by local/split-native-app/tools/server-prep.sh from native-apps 3971dea
on main d31023e. These server parts must be live before the first store
build is useful, and none of them changes what a web user sees or does.
0xkkonrad added a commit that referenced this pull request Nov 15, 2026
… Android back check

The handoff did not say that store.ios in app-config.json stays a
placeholder until someone fills it, and device check 10 still described
Android back before the rooms-list fix.
Rebuilt by local/split-native-app/tools/server-prep.sh from native-apps 2574ef1
on main d31023e. These server parts must be live before the first store
build is useful, and none of them changes what a web user sees or does.

This branch has not been deployed

No deployments
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.

1 participant