Skip to content

Add isolated public Forms embeds - #28

Merged
xgame92 merged 6 commits into
mainfrom
feat/frm-8-embedded-feedback
Dec 4, 2026
Merged

xgame92 merged 6 commits into
mainfrom
feat/frm-8-embedded-feedback

Conversation

@xgame92

@xgame92 xgame92 commented Nov 30, 2026 •

Copy link
Copy Markdown
Member

Part of FRM-8.

Implements requirement R2.

Changes

  • Add a small host loader and a split Forms origin for sandboxed public embeds. The respondent origin admits registered form documents, respondent APIs and assets. Each Start checks the published version and live registration, including a direct iframe with no host context.
  • Show declared public context before Start. The loader keeps the same values across disclosure navigation. The public fallback and the private address shown inside Forms use the owner origin, so an issued response can resume after embedding is removed.
  • Add one nullable context column with an append-only migration. Demo Start verifies Turnstile against the hostname that served the form.

Verification

  • Worker tests exercise an invalid split, reviewed-version checks with and without context, the unregister race and matching versus wrong-host demo challenges.
  • Phone and desktop browser regressions exercise the disclosure round-trip, host isolation and the actual fallback and private address after unregistering. Exact-head CI follows this draft.
  • Before activation, rehearse the two HTTPS origins and the real demo Turnstile widget with a synthetic form. The new origin setting is optional and absent from shared deployment configuration.

xgame92 and others added 2 commits December 3, 2026 09:08
Keep the earlier answer revision migrations and append the embed context column as 0017.
Keep the respondent-origin setting documented alongside the explicit demo Turnstile settings so the embedded-form slice applies cleanly after the deployment-setting checks.
@devin-ai-integration

Copy link
Copy Markdown
Contributor

Reconciled with current main at exact head 5567c0591ce8c62dd66d01b80c83bb578444bdfc.

Verification on the reconciled tree:

  • pnpm verify: passed
  • pnpm test:e2e: 188 passed, 8 skipped
  • Focused embed/demo/settings worker tests: 40 passed
  • Hosted checks: check, e2e, changes, cla and Devin Review all green

The merge keeps the respondent-origin setting documented alongside the explicit demo Turnstile settings. This remains draft and activation is still rehearsal-gated. Note: this branch currently uses migration 0017_embed-context; if the feedback-copy foundation lands first, whichever branch lands second will need the next migration number.

Regenerate the unused embed migration after the applied feedback migrations. Keep the existing authenticated feedback preview available on the respondent origin.
@xgame92
xgame92 marked this pull request as ready for review December 4, 2026 03:11
@devin-ai-integration

Copy link
Copy Markdown
Contributor

Independent exact-head review — approve-equivalent at 8997a9a3c61ab96d57047af788512b8c2e462e60.

This is a substantive review, not a pass-through of the green (skipped) automated status. Scoped axes:

Respondent vs owner boundary. The split-origin gate in server.ts is strict and fail-closed: when FORMS_RESPONDENT_ORIGIN is configured but the pair cannot be derived as two distinct exact origins, every request is denied rather than falling back to single-origin behavior. On the respondent origin only form documents, the narrow form/response API verbs, and static assets pass — all owner routes (/login, /account, /forms/*, /api/auth/*, owner RPC) are unreachable there and vice versa, so a forged Cookie or Sec-Fetch-Site header cannot cross. The deny page itself carries frame-ancestors 'none' + bare sandbox.

Host/origin controls for embedding. frame-ancestors is 'none' by default and names an exact host only for documents of the current, published form whose definition registered that exact origin — drafts, closed states, unregistered hosts and non-open entry at the form root all 404. The sandbox directive is enforced server-side even when the host omits the iframe attribute, and the /embed/<id> redirect helper validates registration before redirecting and itself carries the framed policy. exactOrigin accepts only https (plus loopback http for development) and requires the string to be exactly its own origin — no trailing-path or credential smuggling. Host-supplied embed context is admit-only: every key/value must be inside the owner's declared per-key allow-list (acceptedEmbedContext), so the host cannot smuggle arbitrary context into response records.

Owner-only private links/resume. Owner functionality is structurally unreachable on the respondent origin. The respondent's private resume/response paths are frameable only under the same published-host rule, and the 16-character response token stays inside the cross-origin iframe — the embedding host page cannot read it out, so possession of the bearer secret does not transfer to the host.

Consent/no-cookie surface. Cookies are stripped inbound on the respondent origin before app code runs, and Set-Cookie, Access-Control-Allow-Origin and Access-Control-Allow-Credentials are stripped outbound — a respondent can neither present a forged account cookie nor have an owner session created from this surface, and the respondent experience remains cookieless by construction rather than by discipline.

Migration 0019 compatibility. 0019_embed-context is a single additive nullable ALTER TABLE response ADD embed_context text with an append-only journal entry after 0018 — existing rows and rollback both safe.

Non-blocking observations: (1) the missing trailing newline in _journal.json is cosmetic; (2) registeredHost is re-queried per document in dev and prod response paths — fine at this scale, a per-request memo would be a cheap later optimization.

Authorized scope exclusions noted: the real-provider proof used fresh disposable Workers and one synthetic EU D1; no production state was touched. No pushes, merges or provider changes in this review.

@xgame92
xgame92 merged commit cb802b5 into main Dec 4, 2026
6 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Dec 4, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant