Skip to content

docs(examples): redacted-form recipe — Preview-mode field redaction#48

Merged
adnaan merged 3 commits into
mainfrom
data-lvt-redact
Jun 1, 2026
Merged

docs(examples): redacted-form recipe — Preview-mode field redaction#48
adnaan merged 3 commits into
mainfrom
data-lvt-redact

Conversation

@adnaan
Copy link
Copy Markdown
Contributor

@adnaan adnaan commented May 31, 2026

What

A runnable example demonstrating data-lvt-redact (livetemplate/client#127) + the lvt.Redact Go helper (livetemplate/livetemplate#445).

A two-field form:

  • Passport (redacted)<input data-lvt-redact="passport">. The value stays in browser localStorage; the server only ever receives a {redacted:true,field} sentinel.
  • Note (normal) — an ordinary field, for contrast.

Two panels show the split: "What the browser shows" hydrates the {{.lvt.Redact "passport"}}[[passport]] token from localStorage; "What the server stores" shows the passport field as provided (value never received).

E2E

redacted_form_test.go drives a real browser (Dockerized headless Chrome) over a real WebSocket against a server serving the locally-built client bundle (not the CDN — the feature is unreleased). It asserts:

  • the redact sentinel travels in a WS frame;
  • the raw value appears in no sent frame;
  • server state holds only the presence flag;
  • the non-redacted note round-trips its real value;
  • the [[passport]] echo is hydrated from localStorage.

LiveHandler is exposed separately from Handler so the test can swap in the local bundle.

Note: until livetemplate/client#127 and livetemplate/livetemplate#445 are released, this example builds against local checkouts via go.work (not committed). After those tag, docs/go.mod bumps to the released versions.

🤖 Generated with Claude Code

adnaan and others added 2 commits May 31, 2026 18:17
…ield redaction

A two-field form (redacted passport + normal note) showing the data-lvt-redact
round-trip: the passport value stays in browser localStorage and never reaches
the server (which sees only a {redacted:true} sentinel), while the [[passport]]
echo is hydrated back from localStorage for display.

Includes a chromedp e2e (redacted_form_test.go) that drives a real browser over
a real WebSocket against the locally-built client bundle and asserts the raw
value appears in no WebSocket frame, the server stores only the presence flag,
the non-redacted field round-trips, and the echo is hydrated.

Exercises livetemplate/livetemplate#445 (lvt.Redact) + livetemplate/client#127
(data-lvt-redact).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
lvt.Redact now emits <span data-lvt-redact="passport"> (filled client-side via
textContent) instead of a [[passport]] text token. Update the template comment
and the e2e assertion to check for the server-emitted data-lvt-redact span
rather than the old token, plus the package-doc line.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@adnaan
Copy link
Copy Markdown
Contributor Author

adnaan commented Jun 1, 2026

Holding this PR open intentionally. The companion changes are merged:

But the redacted-form example here builds against those changes, which aren't in a tagged release yet. docs/go.mod still pins the published livetemplate/client versions, and the example only compiles against the unreleased code via a local go.work (not committed).

Blocked on: tagged livetemplate + client releases, then a docs/go.mod bump to those versions. Once that lands this merges cleanly and the example builds on main.

The redacted-form example needs lvt.Redact (livetemplate#445) and data-lvt-redact
(@livetemplate/client@0.11.8), both now released. Bump the livetemplate pin from
v0.9.2 to v0.11.2 so the example builds on main without the local go.work shim.
Verified: GOWORK=off build + vet + chromedp e2e all green against published deps.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@adnaan adnaan merged commit 32c9478 into main Jun 1, 2026
2 checks passed
@adnaan adnaan deleted the data-lvt-redact branch June 1, 2026 04:40
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