Repository navigation
feat(data-sharing): portal settings UI, privacy policy and receiver guide (4/4) - #549
Conversation
…utbound webhooks Database half of user-configurable data sharing (FLAME+): a user registers HTTPS endpoints and the portal pushes their own data there as signed events. Inert on its own: with no endpoint row every capture trigger returns at once and the delivery cron job is created inactive. - webhook_endpoints (owner SELECT, server-written), webhook_endpoint_secrets (service-only ciphertext) and webhook_deliveries (outbox + log). A composite FK ties every delivery to its endpoint's owner (FP-1). - Statement-level capture triggers on every shared table, driven by private.webhook_entity_sources, so both LWW paths, the push transaction, portal writes and RPCs are covered by one mechanism. A capture error is a WARNING, never an aborted sync write (FP-3). - Service-role RPCs: create/rotate/set-header, a FOR UPDATE SKIP LOCKED claim that pauses endpoints whose owner dropped below FLAME (FP-2), completion with backoff and auto-disable (FP-8), and a backfill. - Not shared: raw telemetry, INFERNO-gated biomechanics, Strava-sourced activities, community rows, billing and sync bookkeeping. Every manifest table is classified in _shared/dataSharingScopes.ts and a test fails when a new one is not. - Registered in the user-data manifest (secrets EXCLUDED), the RLS isolation suite and generated types; pgTAP floor raised. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…on race - pgTAP: with the outbox made to reject the row, the user's write must still succeed (FP-3). Verified to fail when the trigger's exception handler is removed. - complete_webhook_delivery: a pending row committed between the superseded check and the reschedule no longer surfaces as a unique violation; the attempt is closed as superseded. - Raise PGTAP_TEST_FLOOR to the suite's actual count. - Operator note on trigger lock contention. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…nd signing The one write path for a user's outbound webhook endpoints (FLAME+): create, update, rotate_secret, test, resend_all, delete. - _shared/webhookTarget.ts: the only code that may fetch a user-chosen URL. https only, public addresses only (literal and every resolved address, checked on save and before each send, failing closed), own hosts refused, redirects never followed, response body never read. DNS rebinding is documented there as a residual risk and bounded, not claimed solved. - _shared/webhookSigning.ts: Standard Webhooks headers; the HMAC key is the base64-decoded secret, pinned by the specification's reference vector. - _shared/webhookSend.ts: one signed POST and a fixed outcome code. The request carries no Supabase credential (asserted) and nothing of the response but its status is kept. - webhook-endpoints: user id from the verified JWT only; every query scoped by it, so another user's endpoint is a 404 for every action (FP-1). delete and a pause run before the FLAME gate so a lapsed user can always stop sharing (FP-2). The signing secret is returned once and never logged (FP-5). Requests to a user-chosen host have their own tight rate-limit key. Responses go through an explicit column allowlist. Verified by mutation: removing the owner filter or the tier gate turns the isolation tests red. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The delivery half of outbound webhooks. pg_cron calls deliver-webhooks every minute (job created inactive by 20261106120000); one pass claims due rows, builds each payload from the current data, signs it, POSTs it and records the outcome. - _shared/webhookPayload.ts: the only code that reads user data for a webhook. The root row is read with its id AND the delivery owner's user id, so an entity that is not the owner's is "not found"; children are read under ids from that read. Fields are the GDPR manifest's columns minus the owner id and an explicit omit list. A missing or soft-deleted row is `<entity>.deleted` with the id only. Loads are per cable as stored (KD-8). - deliver-webhooks: x-cron-secret or service-role bearer, else 401. Small batches so a pass never holds work it cannot finish; the endpoint, its secrets and the entity are each read with the user id from the claimed row. A scope removed after capture, an inactive endpoint or a non-shareable row is skipped, never sent. Retries, backoff, the FLAME check and auto-disable stay in SQL. - Real-SQL integration test: two users' routines reach only their own receivers, a lapsed owner's endpoint is paused instead, and a hard delete arrives as a deleted event. Verified by mutation: without the owner filter in the payload builder the isolation tests fail. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…uide Profile > Settings > Data Sharing: add, edit, pause, test, resend, replace the secret of and delete outbound webhook endpoints. - The card sits on a route with no tier gate so a lapsed user can still see where their data went and pause or delete it. Adding, editing and switching on need Flame (FEATURE_MIN_TIER.dataSharing); the server enforces it. A billing outage disables changes without telling a paying user to upgrade. - Every write is one webhook-endpoints action and sends no user id. Reads use owner RLS on webhook_endpoints / webhook_deliveries. The signing secret is shown once and held only in component state. - Server refusals surface with the server's own message (URL not allowed, limit reached, failed test delivery); 402 goes through isTierDenied. - Form checks mirror the server for instant feedback but stay no stricter than it; the host and address checks remain server-only. - Privacy policy: user-directed sharing added to the legal bases, section 8 and international transfers, with a new effective date. - docs/data-sharing-webhooks.md (receiver guide with verification), operator runbook section, dataSharingScopes.ts reviewed into the SPA-reachable list. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…new functions The audit report is historical and never covered webhook-endpoints or deliver-webhooks. The addendum says so and points to where their security model and the SSRF residual risk are stated; it records no findings. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
| GitGuardian id | GitGuardian status | Secret | Commit | Filename | |
|---|---|---|---|---|---|
| 39754956 | Triggered | Stripe Webhook Secret | 32ad07e | supabase/functions/webhook-endpoints/index.test.ts | View secret |
| 39754956 | Triggered | Stripe Webhook Secret | 32ad07e | supabase/functions/_shared/webhookSigning.test.ts | View secret |
| 39754956 | Triggered | Stripe Webhook Secret | 32ad07e | supabase/functions/_shared/webhookSend.test.ts | View secret |
| 39754955 | Triggered | Generic High Entropy Secret | 32ad07e | supabase/functions/webhook-endpoints/index.test.ts | View secret |
| 39754955 | Triggered | Generic High Entropy Secret | 32ad07e | supabase/functions/_shared/webhookSend.test.ts | View secret |
| 39754955 | Triggered | Generic High Entropy Secret | 9f6c1a4 | supabase/functions/deliver-webhooks/index.test.ts | View secret |
| 39754956 | Triggered | Stripe Webhook Secret | 9f6c1a4 | supabase/functions/deliver-webhooks/index.test.ts | View secret |
| 39754956 | Triggered | Stripe Webhook Secret | 0361508 | src/app/components/tests/DataSharingSection.test.tsx | View secret |
🛠 Guidelines to remediate hardcoded secrets
- Understand the implications of revoking this secret by investigating where it is used in your code.
- Replace and store your secrets safely. Learn here the best practices.
- Revoke and rotate these secrets.
- If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.
To avoid such incidents in the future consider
- following these best practices for managing and storing secrets including API keys and other credentials
- install secret detection on pre-commit to catch secret before it leaves your machine and ease remediation.
🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.
GitGuardian flagged the whsec_ literals in the new test files as webhook secrets. They were not credentials: one is the Standard Webhooks specification's published example key, the other a second documentation example used as a fixture. A scanner cannot tell that, and a scanner that cries wolf gets ignored, so no secret-shaped literal is committed any more. - Fixtures come from _shared/testing/webhookSecrets.ts (whsec_ + base64 of 32 identical bytes, built at runtime). - The reference vector is kept, because it is what proves interoperability; its public key is assembled from parts with a comment saying why. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Same change as on the webhook-endpoints branch, for the deliver-webhooks test: no secret-shaped literal is committed. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The component test and the E2E mock used whsec_ strings long enough to look like a real webhook secret to a scanner. Nothing verifies them, so they are now plainly fake. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
phoenix-portal | b0aa56a | Commit Preview URL Branch Preview URL |
Nov 06 2026, 07:14 PM |
- The registry and the capture triggers could drift: a trigger's arguments are frozen when it is created. Trigger creation is now private.sync_webhook_capture_triggers(), which a later migration calls after editing private.webhook_entity_sources and which also removes capture triggers from tables that are no longer a source. pgTAP fails when a trigger's arguments differ from its row (verified by editing a row without rebuilding). The header no longer claims they cannot drift. - The "does any active endpoint share this scope" probe ran on every write to a shared table with no index to use. Added a partial GIN index on scopes and switched the probe to @> so it can use it. - sets and rep_summaries are payload children with no capture trigger. That is sound today (no browser role can write them, and every server writer rewrites exercises in the same call) but was neither stated nor tested. It is now documented, marked capturedThrough in dataSharingScopes.ts, checked in both directions by the parity test, and guarded by a pgTAP assertion on the grants. - The profile omit list (stripe_customer_id and two internal columns) is now asserted, not only checked for existence. - set_webhook_endpoint_header's two header arguments DEFAULT NULL, matching how they are used and the generated types. Not changed: the pgTAP floor finding (the suite count is what the CI job measured), and the endpoint-limit finding (endpoints are deleted through the webhook-endpoints function in the next PR). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
- A previous signing secret that cannot be decrypted no longer stops every delivery: it only smooths a rotation, so deliveries go out signed with the current secret alone. - DNS resolution has its own 5 s deadline. The request timeout only starts with the fetch, so a resolver that hung could hold a delivery and the worker pass it belongs to. - The Supabase test double returned deleted rows whether or not the caller asked for them. It now matches PostgREST, so dropping `.select()` from a delete (a 404 on success in production) would fail the suite. - Tests: webhookCredentials gets its own file (rotation overlap, unreadable secrets, owner scoping); the tier gate is covered for rotate, test and resend as well as create and update. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…-worker # Conflicts: # CLAUDE.md # supabase/config.toml
Code Review SummaryThis review did not run. Your provider API key hit its rate limit, so the |
What
PR 4 of 4 for user-configurable data sharing (outbound webhooks, FLAME+). Now based on
main; the diff is this PR's 23 files only.The portal side: Profile → Settings → Data Sharing, plus the privacy policy, a receiver guide and the operator runbook.
Changes
DataSharingSectionbetween Export and the danger zone. Add, edit, pause, switch on, send a test, resend everything, replace the secret, delete, and a per-endpoint delivery log.FEATURE_MIN_TIER.dataSharing), and the server enforces it.webhook-endpointsaction each and send no user id. Reads use owner RLS onwebhook_endpoints/webhook_deliveries.isTierDenied.dataSharingScopes.tsis added to the reviewed SPA-reachable shared modules.docs/data-sharing-webhooks.md(receiver guide with verification), a runbook section, and a dated addendum in the historical security audit that records no findings.Needs your review: privacy policy
PrivacyPolicy.tsxgains user-directed sharing in three places: the legal bases (consent, withdrawn by pausing or deleting the endpoint), section 8 (what is sent, what never is, and that the recipient is chosen by the user and does not act on our behalf), and international transfers. The effective date changes from February 20, 2026 to November 6, 2026.I wrote that text. It has not had legal review, and the effective date should be whatever day this actually ships.
Axioms (
docs/axioms.md)webhook-endpoints. Below Flame, only Pause and Delete are enabled.connect-srcforbids it).whsec_remains.Verification
npm run verifypasses: lint, typecheck (no new errors), 2,525 Vitest tests, production build, no sourcemaps, bundle budget.npm run test:e2e: 101 passed, 1 skipped, including two new specs (a Flame user's full flow; a user below Flame).Release order
This must merge after the migration is applied and both Edge Functions are deployed, because Cloudflare deploys the SPA on merge with no gate.
🤖 Generated with Claude Code