Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions apps/web/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ const nextConfig = {
// and the proxy owns the general strip for everything else.
skipTrailingSlashRedirect: true,

// Defined so Next inlines it: an undefined NEXT_PUBLIC_* survives as `process.env.X`, webpack
// cannot fold the guard in src/lib/native/host.ts, and the Capacitor chunk lands in this build.
env: { NEXT_PUBLIC_NATIVE_BUILD: '0' },

/**
* Two retirements, neither of them locale detection: nothing here reads `Accept-Language` or a
* cookie, and no reader is ever moved off the language they asked for.
Expand Down Expand Up @@ -55,6 +59,27 @@ const nextConfig = {
]
},

/**
* Two static files the store apps depend on. Both paths contain a dot, so src/proxy.ts's
* matcher skips them. iOS reads the association file only as JSON (it is served as
* application/octet-stream otherwise), and the apps fetch the version config cross-origin.
*/
async headers() {
return [
{
source: '/.well-known/apple-app-site-association',
headers: [{ key: 'Content-Type', value: 'application/json' }],
},
{
source: '/app-config.json',
headers: [
{ key: 'Access-Control-Allow-Origin', value: '*' },
{ key: 'Cache-Control', value: 'public, max-age=300' },
],
},
]
},

/**
* `public/` serves files at their exact path only — a directory never resolves to its own
* index.html. The funnel quiz is one self-contained static file under `public/dev/funnel-quiz/`,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- AlterTable
ALTER TABLE "split"."PushSubscription" ADD COLUMN "transport" TEXT NOT NULL DEFAULT 'webpush',
ALTER COLUMN "p256dh" DROP NOT NULL,
ALTER COLUMN "auth" DROP NOT NULL;

16 changes: 12 additions & 4 deletions apps/web/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,14 @@ model FxRate {
// somebody ELSE in the room writes. No accounts exist here, so the identity a
// subscription carries is the per-room member it was registered as.

/// One delivery channel: this browser, acting as this member, in this room.
/// One delivery channel: this browser or app install, acting as this member, in
/// this room.
///
/// `transport` says who delivers it. `webpush` rows hold a push-service URL in
/// `endpoint` plus the browser's `p256dh` and `auth` keys. Native app rows
/// (`apns`, `apns-sandbox`, `fcm`) hold `<transport>:<device token>` in
/// `endpoint` and no keys, so the uniqueness, the per-room cap and the status
/// check below carry over unchanged.
///
/// The key is (endpoint, roomId), not endpoint alone. A browser has exactly one
/// push endpoint, so a phone that joins two rooms would collide on a globally
Expand All @@ -334,9 +341,10 @@ model PushSubscription {
id String @id @default(uuid())
roomId String
memberId String
endpoint String // push-service URL; the host is allowlisted at write time
p256dh String
auth String
transport String @default("webpush")
endpoint String // webpush: allowlisted push-service URL; native: "<transport>:<token>"
p256dh String? // webpush only
auth String? // webpush only
userAgent String?
createdAt DateTime @default(now())
lastSeenAt DateTime @default(now())
Expand Down
16 changes: 16 additions & 0 deletions apps/web/public/.well-known/apple-app-site-association
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"applinks": {
"details": [
{
"appIDs": ["PW388G893L.com.peanutsplit.app"],
"components": [
{ "/": "/r/*/card/*", "exclude": true, "comment": "Share-card images open in the browser" },
{ "/": "/r/*/recap/card", "exclude": true, "comment": "Recap card image opens in the browser" },
{ "/": "/r/*/opengraph-image*", "exclude": true, "comment": "Link-preview image" },
{ "/": "/r/*/recap/opengraph-image*", "exclude": true, "comment": "Recap link-preview image" },
{ "/": "/r/*", "comment": "Every room link opens the app when it is installed" }
]
}
]
}
}
12 changes: 12 additions & 0 deletions apps/web/public/.well-known/assetlinks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[
{
"relation": ["delegate_permission/common.handle_all_urls"],
"target": {
"namespace": "android_app",
"package_name": "com.peanutsplit.app",
"sha256_cert_fingerprints": [
"PLACEHOLDER:REPLACE_WITH_PLAY_APP_SIGNING_AND_UPLOAD_KEY_SHA256_AFTER_FIRST_PLAY_UPLOAD"
]
}
}
]
7 changes: 7 additions & 0 deletions apps/web/public/app-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"minBuild": { "ios": 0, "android": 0 },
"store": {
"ios": "https://apps.apple.com/app/idPLACEHOLDER",
"android": "https://play.google.com/store/apps/details?id=com.peanutsplit.app"
}
}
45 changes: 31 additions & 14 deletions apps/web/src/app/(product-shell)/privacy/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ import { breadcrumbSchema, pageMetadata, pageTitle } from '@/lib/seo'
* describes the advertising tag is the one page that does not load it.
*
* Written from what the code does, not from a template. Every claim below has a file behind it:
* the tags in `lib/google-ads.ts` and `lib/x-ads.ts`, the analytics boundary in `lib/analytics.ts`,
* error reporting in `instrumentation-client.ts`, the receipt path in `server/model.ts`, and the
* stored shapes in `prisma/schema.prisma`. Change one of those and change this page in the same push.
* the tags in `lib/google-ads.ts` and `lib/x-ads.ts` (website only: no native page renders them),
* the analytics boundary in `lib/analytics.ts`, error reporting in `instrumentation-client.ts`, the
* receipt path in `server/model.ts`, the app push senders in `server/push-native/apns.ts` and
* `server/push-native/fcm.ts`, and the stored shapes in `prisma/schema.prisma`. Change one of those
* and change this page in the same push. Every recipient named in `apps/web/store/privacy-answers.md`
* must also be named here.
*
* English only. `/es-419/privacy` and `/pt-br/privacy` are not routes — the same rule the rest of
* the untranslated surface follows.
Expand Down Expand Up @@ -78,9 +81,10 @@ export default function PrivacyPage() {
personal data described here, under UK data protection law.
</p>
<p>
This notice covers peanutsplit.com only. Peanut&rsquo;s wallet and card are a different
product with a different policy, and nothing on this page describes them. If you settle a
balance through a Peanut payment link, you leave Split and{' '}
This notice covers the website at peanutsplit.com and the Peanut Split apps for iOS and
Android, if you use them. Peanut&rsquo;s wallet and card are a different product with a
different policy, and nothing on this page describes them. If you settle a balance through a
Peanut payment link, you leave Split and{' '}
<a className={externalLink} href="https://peanut.me/en/privacy">
Peanut&rsquo;s privacy policy
</a>{' '}
Expand Down Expand Up @@ -120,8 +124,9 @@ export default function PrivacyPage() {
<li>each expense: its description, amount, date, who paid, and how it was split;</li>
<li>settlements recorded in the room, and the reactions people leave on an expense;</li>
<li>
a push subscription for each device that turns notifications on in a room &mdash; the
browser&rsquo;s push address, its keys, and the browser&rsquo;s user-agent string;
a push subscription for each device that turns notifications on in a room &mdash; either a
browser&rsquo;s push address, its keys, and the browser&rsquo;s user-agent string, or an
app&rsquo;s device token and the platform it belongs to;
</li>
<li>
a record of edits to the room, kept so the group can see what changed rather than for us to
Expand All @@ -144,6 +149,10 @@ export default function PrivacyPage() {
settings live in your browser&rsquo;s local storage. They are not sent to us. Clearing site data
loses them, and a room you have no link to is a room you cannot get back.
</p>
<p className="mt-4 text-base leading-7">
The iOS and Android apps keep your recent rooms and member tokens on the phone in the same way,
and your phone&rsquo;s own backup may include them.
</p>
<p className="mt-4 text-base leading-7">
Split itself sets four cookies. Each one is needed for the product to work. None of them
measures you or advertises to you.
Expand Down Expand Up @@ -198,6 +207,7 @@ export default function PrivacyPage() {
Advertising
</h2>
<div className="mt-4 grid gap-4 text-base leading-7">
<p>The Google Ads and X Ads tags described here load on the website only, never in the apps.</p>
<p>
Since 24 August 2026, peanutsplit.com carries a Google Ads tag (
<code className="text-sm">{GOOGLE_ADS_ID}</code>). It runs on this site only, and it has one
Expand Down Expand Up @@ -266,11 +276,12 @@ export default function PrivacyPage() {
Photographs of receipts
</h2>
<p className="mt-4 text-base leading-7">
If you photograph a receipt to fill in an expense, the image is sent once to a language-model
provider to be read, and the answer comes back as text. Split does not keep the photograph:
there is no column, bucket or temporary file for it, and neither the image nor anything read off
it is written to a log. The provider is required to be one that retains nothing and trains on
nothing. The feature is off entirely unless the operator has configured it.
If you photograph a receipt to fill in an expense, the image is sent once to Google Gemini,
through OpenRouter, to be read, and the answer comes back as text. Split does not keep the
photograph: there is no column, bucket or temporary file for it, and neither the image nor
anything read off it is written to a log. The provider is required to be one that retains
nothing and trains on nothing. The feature is off entirely unless the operator has configured
it.
</p>
</section>

Expand All @@ -288,12 +299,18 @@ export default function PrivacyPage() {
<li>PostHog &mdash; product analytics;</li>
<li>Sentry &mdash; error reports;</li>
<li>
a language-model provider &mdash; receipt photographs, held for the length of one request;
Google Gemini, through OpenRouter &mdash; receipt photographs, held for the length of one
request;
</li>
<li>
your browser vendor&rsquo;s push service &mdash; it delivers a notification you asked for,
and it necessarily sees that a message was sent to your device;
</li>
<li>
Apple Push Notification service and Google Firebase Cloud Messaging &mdash; they deliver the
notifications you turn on in the iOS and Android apps, and they can read each
notification&rsquo;s title and text, including names and amounts;
</li>
<li>our hosting provider &mdash; ordinary web-server request logs, including IP addresses.</li>
</ul>
<p className="mt-4 text-base leading-7">
Expand Down
17 changes: 12 additions & 5 deletions apps/web/src/app/api/rooms/[slug]/push-subscriptions/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@
* channel to it needs proof of membership, because a bare link-holder who never
* joined should not be able to make somebody's phone buzz on a schedule they
* chose. The proof is the member token the server minted at join time.
*
* Two body shapes: a browser's Web Push subscription (`endpoint` + `keys`) and
* an app install's device token (`transport` + `token`), stored as
* `<transport>:<token>`. `server/validation.ts` turns both into one channel.
*/
import { prisma } from '@/server/db'
import { ApiError, readJson, respond } from '@/server/http'
import { isAllowedPushEndpoint } from '@/server/pushHosts'
import { assertNativePushAvailable } from '@/server/push-native/config'
import { assertProvenMember, loadRoom } from '@/server/roomState'
import { enforceRateLimit, meterRoomLookup, WRITE_LIMIT } from '@/server/rateLimit'
import { pushSubscribeSchema, pushUnsubscribeSchema } from '@/server/validation'
Expand All @@ -28,13 +33,14 @@ export const POST = (request: Request, ctx: Ctx) =>
enforceRateLimit(request, WRITE_LIMIT, 'push-subscribe')
const { slug } = await ctx.params
const body = pushSubscribeSchema.parse(await readJson(request))
assertNativePushAvailable(body.transport)
// A guessed slug 404s here and a real slug with a bad token 403s, so the
// miss goes on the shared budget — same as the DELETE below and the
// status route beside it. All three paths meter it the same way.
const room = await meterRoomLookup(request, () => loadRoom(slug))
assertProvenMember(room, body.memberId, body.memberToken)

if (!isAllowedPushEndpoint(body.endpoint)) {
if (body.transport === 'webpush' && !isAllowedPushEndpoint(body.endpoint)) {
throw new ApiError(400, 'UNSUPPORTED_PUSH_HOST', 'that is not a push service we can deliver to')
}

Expand Down Expand Up @@ -65,17 +71,18 @@ export const POST = (request: Request, ctx: Ctx) =>
create: {
roomId: room.id,
memberId: body.memberId,
transport: body.transport,
endpoint: body.endpoint,
p256dh: body.keys.p256dh,
auth: body.keys.auth,
p256dh: body.keys?.p256dh ?? null,
auth: body.keys?.auth ?? null,
userAgent: body.userAgent ?? null,
},
update: {
// memberId too: one phone can be passed to whoever is paying,
// and the channel should follow whoever it last proved it was.
memberId: body.memberId,
p256dh: body.keys.p256dh,
auth: body.keys.auth,
p256dh: body.keys?.p256dh ?? null,
auth: body.keys?.auth ?? null,
userAgent: body.userAgent ?? null,
lastSeenAt: new Date(),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,19 @@
*
* POST, and the endpoint is never a query parameter: an FCM or WNS endpoint
* embeds the device's registration token, and a URL would copy it into every
* access log, proxy trace and Referer header on the way.
* access log, proxy trace and Referer header on the way. An app sends its
* `transport` and device token instead, for the same reason in the body.
*
* An app asks this before it shows its notification row, so a transport with
* no server credentials answers 503 NATIVE_PUSH_UNAVAILABLE here too, and the
* row stays hidden.
*/
import { prisma } from '@/server/db'
import { readJson, respond } from '@/server/http'
import { assertProvenMember, loadRoom } from '@/server/roomState'
import { enforceRateLimit, meterRoomLookup, WRITE_LIMIT } from '@/server/rateLimit'
import { pushStatusSchema } from '@/server/validation'
import { assertNativePushAvailable } from '@/server/push-native/config'

export const dynamic = 'force-dynamic'

Expand All @@ -24,6 +30,7 @@ export const POST = (request: Request, ctx: Ctx) =>
enforceRateLimit(request, WRITE_LIMIT, 'push-status')
const { slug } = await ctx.params
const body = pushStatusSchema.parse(await readJson(request))
assertNativePushAvailable(body.transport)
// A guessed slug 404s here and a real slug with a bad token 403s, which is
// a room-existence oracle. Its own 120/hour bucket would have widened the
// 30/hour the miss limiter exists to enforce, so the miss goes there.
Expand Down
5 changes: 5 additions & 0 deletions apps/web/src/components/room/JoinGate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useTranslations } from 'next-intl'
import { BaseInput } from '@/components/ui/BaseInput'
import { Button } from '@/components/ui/Button'
import { Card } from '@/components/ui/Card'
import { roomProps, track } from '@/lib/analytics'
import { isApiError } from '@/lib/api'
import type { ApiMember, RoomState } from '@/lib/api-types'
import type { MemberIdentity } from '@/lib/identity'
Expand Down Expand Up @@ -56,6 +57,7 @@ export function JoinGate({ slug, state, onJoined, previousIdentity = null }: Joi
const [reactivation, setReactivation] = useState<ApiMember | null>(null)

useEffect(() => {
track('join_gate_shown', roomProps(slug))
const previouslyFocused = document.activeElement instanceof HTMLElement ? document.activeElement : null
const gateRoot = gateRootRef.current
const background = gateRoot?.parentElement
Expand Down Expand Up @@ -123,6 +125,7 @@ export function JoinGate({ slug, state, onJoined, previousIdentity = null }: Joi
try {
const next = await claimMember.mutateAsync({ memberId })
feedback('pop')
track('join_gate_completed', { ...roomProps(slug), via: 'claim' })
onJoined({ memberId: next.memberId, token: next.memberToken, name: memberName })
} catch (err) {
feedback('error', { haptic: 'error' })
Expand All @@ -145,6 +148,7 @@ export function JoinGate({ slug, state, onJoined, previousIdentity = null }: Joi
try {
const next = await joinRoom.mutateAsync({ name: trimmed })
feedback('pop')
track('join_gate_completed', { ...roomProps(slug), via: 'new' })
onJoined({ memberId: next.memberId, token: next.memberToken, name: trimmed })
} catch (err) {
// The card is the whole screen here; shaking it is the only motion
Expand Down Expand Up @@ -175,6 +179,7 @@ export function JoinGate({ slug, state, onJoined, previousIdentity = null }: Joi
try {
const next = await reactivateMember.mutateAsync(reactivation.id)
feedback('pop')
track('join_gate_completed', { ...roomProps(slug), via: 'new' })
onJoined({ memberId: next.memberId, token: next.memberToken, name: reactivation.name })
} catch (err) {
feedback('error', { haptic: 'error' })
Expand Down
3 changes: 2 additions & 1 deletion apps/web/src/i18n/messages/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -1229,7 +1229,8 @@
"NO_RATE": "Für diese Währung gibt es keinen Wechselkurs zur Gruppenwährung. Verwende stattdessen die Gruppenwährung.",
"MANUAL_FX_RATE_REQUIRED": "Gib für diese benutzerdefinierte Währung einen manuellen Kurs ein.",
"MANUAL_FX_RATE_INVALID": "Dieser Kurs ist ungültig oder rundet den umgerechneten Betrag auf null.",
"MANUAL_FX_RATE_NOT_ALLOWED": "Manuelle Kurse sind nur bei benutzerdefinierten Ausgabenwährungen möglich."
"MANUAL_FX_RATE_NOT_ALLOWED": "Manuelle Kurse sind nur bei benutzerdefinierten Ausgabenwährungen möglich.",
"NATIVE_PUSH_UNAVAILABLE": "Benachrichtigungen sind noch nicht verfügbar."
},
"derivation": {
"title": "So kommt dieser Betrag zustande",
Expand Down
Loading
Loading