The template root directory.
The loaded templates.
Signing options (validated here) or an existing Signer.
Optionalwatcher: FileWatcher
The file watcher when templates are reloaded on change.
Fragment allowlist.
AnzaError CRYPTO when signing holds a missing or malformed key.
The in-memory template cache (replaced wholesale on reload).
ReadonlyfragmentsFragment allowlist (see EngineOptions.fragments).
The template root directory.
ReadonlysignerThe validated signing key. Never printed; signer.publicKey is the raw
Ed25519 public key to publish to verifiers.
OptionalwatcherThe file watcher when watch: true; call watcher.close() to stop reloading.
Look a template up by name. Never touches the filesystem.
Template name relative to the root, e.g. feed/card.html.
The parsed template.
Every loaded template with its lowercase hex SHA-256 digest.
Render templateName into a (signed) envelope for slot. Templates
outside the fragments allowlist are reported as not found.
Template name relative to the root.
Target name written into the envelope.
Optionalparams: Params
Values for the placeholders.
An envelope stamped with the current Unix time, signed when signing is on.
AnzaError VALIDATION for a malformed name; NOT_FOUND
for an unknown template or one outside the allowlist.
Render the page for route (the pipeline is described on Page).
The request path, e.g. / or /docs/intro.
Optionalparams: Params
Values for the page and shell placeholders.
The full HTML document.
AnzaError NOT_FOUND for an unknown or malformed route
without a pages/index.html catch-all.
Sign a v2 message for ts, slot and html (no CSS) with the engine's key.
Unix time in seconds.
Target name.
Fragment HTML.
Lowercase hex signature, or undefined when signing is off.
Verify an envelope against this engine's own key (HMAC secret or the Ed25519 public key). Same checks, in the same order, as the standalone verifyEnvelope.
The received envelope (parsed JSON or an Envelope).
Freshness window and expected slot.
AnzaError CRYPTO naming the failed check, or
signing is off when the engine has no key.
A loaded template set plus a validated signing key. Get one from Setup.run; it renders pages (Engine.renderPage) and envelopes (Engine.renderFragment).
Remarks
The engine has three steps: load (read and SHA-256 each
.htmlfile), parse (split into chunks and build a render function), both done once by Setup.run, and render (call the function, then optionally sign). Rendering does a name check and oneMap.get, then a loop of string concatenations; it never reads the filesystem.The cache store and file watcher types are internal: build engines with Setup rather than this constructor.
Example