Keeping secrets out of deployments

Three attributes hide content: copy:redact hides it from copies, and edge:redact and edge:remove hide it from the served page. None of them hides anything from the deployed source. This guide says what each one does, what stays visible, and how to keep private things private.

Redaction is not secrecy

Warning: edge:redact and edge:remove only change the served HTML. The deployed source, which opens when you append ? to the route URL, is the complete authored input, and it is public unless the deployment has access rules. Every deploy also saves the complete source as a version.

Use redaction to keep content out of copies and out of the served page. Do not use it to protect a value.

What each attribute does

AttributeActsEffectWhere the content stays visible
copy:redactWhen you copy or cut in the editor.The element becomes <!--REDACTED … --> in the copied text.Everywhere else: the served page, the source, versions, the playground URL and File Sync's 📄.html.
edge:redactOn deploy.The element becomes a <!--REDACTED … --> comment in the served page. The comment spans the same lines.Its exported file, the source and versions.
edge:removeOn deploy.The element becomes blank lines in the served page. Its lines stay, but are empty.Its exported file, the source and versions.

The comment is <!--REDACTED, then the line breaks of the element minus one, then -->, with no space after <!--. edge:remove runs before edge:redact, so an element with both is removed.

What stays visible

In the served page, after copy:redact

copy:redact has no effect on deploy. The element and its content are served, and the attribute is kept: the served root writes copy:redact="".

In the source

Appending ? to the route URL opens the deployed source in RTCode.io. It is the complete authored input. It includes the content of edge:redact, edge:remove and copy:redact elements, workers without edge, and every o: and h: attribute. See ?.

In exported files

An element with o: or worker:fs and edge:redact or edge:remove is still exported: its body is extracted before the element is hidden. <template o:=Page.html edge:redact> serves Page.html at its URL and disappears from the root. A file is a public URL unless the edge:user gate protects it.

In versions, the playground URL and File Sync

Every deploy saves the complete source as a version, so removing a value from the source later does not remove it from earlier versions. The playground URL carries the source, and so does File Sync's 📄.html; copy:redact affects neither.

In the playground

In the playground, edge:redact and edge:remove do nothing: the output renders and runs the elements. Code: Size shows a ⚑ count of the elements that are stripped or redacted on deploy.

Keeping private things private

To keep a value private, keep the source private and keep the value inside a private edge worker. Anyone who can open the source can read the value, so treat the source as readable by you, your editors and your io:user permits.

Keep the source private

When the source is private, only signed-in viewers who are the owner, an editor or an io:user permit (an exact email, a domain, or * for any signed-in user) may open it. A source that is not private can be opened by anyone, without signing in.

The source is private whenNotes
The deployment has an edge worker, and not every edge worker carries io:guest.Adding an edge worker makes the source private by default.
A non-worker element, usually a <meta>, has io:user without io:guest.io:user lists who may open the source.
An element has edge:user, unless the same element also carries edge:guest Experimental.edge:user limits who may view the deployment, and it also makes the source private.

See Restricting access for the three attributes.

Keep values in an edge worker

The code of an edge worker is blanked from the served page. Unless the worker carries io:guest, the source that contains it is private. Put values the browser must never see inside the worker, and let the page call the worker through a : URL.

Note: edge:user protects the page and its files, but not : URLs. A worker that must know who is calling has to check request.rt.user itself.

Keep worker assets out of the page

worker:fs alone does not take the element off the page: it stays in the served HTML with the attribute stripped. Add edge:remove or edge:redact to keep it out of the served page. The asset still remains in the deployed source. See worker:fs.

Protect files with edge:user

A deployed file is a public URL. edge:user puts the page and its exported files behind sign-in. Redacting the element that exports a file does not.

A private worker holds the values

The page asks the worker whether a code is valid. The list of valid codes stays inside the worker and is never sent to the browser:

html
<script type=worker edge>
  const codes = ['replace-me', 'replace-me-too']  // stays in the worker
  export default { fetch: request => Response.json({ ok: codes.includes(new URL(request.url).searchParams.get('code')) }) }
</script>
<input id=pin placeholder=code> <button id=go>Check</button> <output id=answer></output>
<script type=module>
  go.onclick = async () => answer.value = (await fetch(`:check?code=${pin.value}`).then(r => r.json())).ok ? 'valid' : 'invalid'
</script>

The worker has no io:guest, so deploying it makes the source private to you, your editors and any io:user permits.

What the deployed page contains

Three kinds of redaction

This input uses all three attributes:

html
<div edge:remove>Local notes</div>
<script edge:redact>
  console.log("playground-only diagnostics")
</script>
<script copy:redact>const demoKey = "not-for-clipboards"</script>

All three elements render or run in the playground.

The served page

On RTEdge.net, the served page has an empty first line where the <div> was, then a three-line comment where the script was, then the script with copy:redact kept:

plain
<!--REDACTED

-->
<script copy:redact="">const demoKey = "not-for-clipboards"</script>

Copying the third element from the editor yields <!--REDACTED-->. The deployed source, opened with ?, still contains all three elements.

Before you deploy

Availability

FeaturePlaygroundRTEdge.netNotes
copy:redactYesNo effectActs on copies from the editor only.
edge:redact and edge:removeNo effectYesApplied on deploy.
Private sourceNot applicableYesSet by access attributes and edge workers at deploy time.

See also