DEV Community

VEILVM
VEILVM

Posted on Edited on

A Lottie or Rive animation still ships its interaction timeline and state machine

Interactive motion shows up in onboarding, empty states, product configurators, and "tap the hot spot, play the step" tutorials. Lottie, Rive, and similar runtimes make that easy: load a file, bind a state machine, play a timeline.

The bytes that make the motion useful also have to arrive in the tab. This article is about what a client-side animation actually exposes, which parts should stay on a server, and how to protect a custom state machine or timing function without wrapping the vendor runtime.

The file is a public download

A typical "bind inputs, then play" path looks like this:

export async function mountGuide(root, product) {
  const file = await fetch("/motion/guide.riv").then((r) => r.arrayBuffer());
  const machine = await runtime.load(file, MACHINE);
  machine.setInputs(inputsFor(product, TIMING));
  return machine.play(LANES[product.tier] ?? LANES.free);
}
Enter fullscreen mode Exit fullscreen mode

After a production build, three things sit on the same origin or CDN as the UI: the .riv or .json motion file, MACHINE / TIMING in a JS chunk (input names, thresholds, transitions), and LANES that pick which timeline a plan is allowed to play. The runtime is a vendor library. A competitor who wants your product is after the motion file and the interaction graph, not rive-js or lottie-web.

A reader can:

  • Open the Network panel, save guide.riv or the Lottie JSON, and open it in the official editor.
  • Pretty-print the chunk and copy inputsFor, the timing table, and every lane, including ones the UI never offers.
  • Call mountGuide from the console with a product.tier the billing page would have blocked, or patch LANES to play the paid timeline.
  • Harvest unreleased motion files that were only filtered from the picker.

A content hash in the filename is a cache-busting token, not an access token. If the parent chunk mentions it, the file is public.

The runtime is not a vault

Minifying the bundle will rename inputsFor. It will not hide a state machine, a distinctive easing table, or a paid timeline that already lives in the same .riv file as the free one. Encrypting the motion file does not help if the decryptor and the key travel together in the same public folder.

Client-side motion is still the right call for a lot of work: a decorative loader, a public brand animation, a tutorial whose steps are already in the docs. The problem starts when the interaction is the product — a configurator whose state machine encodes assembly steps, a paid lesson, a "Pro" lane in the same file, or timing logic that other apps would copy wholesale.

That plan check runs in the same tab. If guide.riv already contains the paid lane, a visitor does not need to pass your if.

What to leave on the server

Some pieces should never ship in a public asset directory:

  • Motion files whose art, choreography, or state machine would hurt you if a competitor reused them wholesale.
  • Paid or unreleased lanes that do not need to be in the same file as the free preview.
  • Outcomes that grant access, complete a lesson, or change a bill. Confirm those on the server after an entitlement check.
  • Staff-only or unreleased .riv / Lottie files that happen to sit next to the public ones in /motion.

The browser can still play a preview and respond to pointer input. The milestone you record, or the file you only show to a paying account, can come from an API that already knows the entitlement.

What to protect in the client

You may still need a slice of logic on the device: an offline input mapper, a compact timing function for a kiosk that must work with a cached preview, or a deterministic pre-check that runs before the first fetch. For that slice:

  1. Keep entitlements, completion records, and any motion file you cannot afford to leak on the server, or behind a short-lived authenticated URL that is not the whole security story.
  2. Minify the app as usual; leave the Lottie or Rive runtime alone.
  3. Extract inputsFor or the lane picker and apply a real protection pass — identifier renaming and string tables as a floor, VM-style protection if wholesale reuse of the interaction graph is the risk you care about.
  4. Keep production source maps and unused motion files off the public CDN.

A JS VM obfuscator compiles that function to a custom bytecode and ships a small interpreter. Pretty-printing the chunk no longer reconstructs the original inputsFor; you get bytecode and a dispatcher. That is slower than a bare property set, which is why you protect the mapper, not the runtime, and why protection is not a substitute for keeping a paid motion file off a public path.

VEILVM is a browser-based JSVMP workspace you can point at one extracted function before you wire protection into CI. Protection raises the cost of casual inspection and wholesale reuse. It does not make a downloadable .riv or Lottie file a secret, and it does not replace a server-side entitlement check for a paid lane.

Checklist

  • [ ] Paid or unreleased motion files are not sitting in a public /motion directory next to the preview.
  • [ ] Lesson completion, access, and plan-gated lanes are computed or re-checked on the server.
  • [ ] The Lottie or Rive runtime is left alone; only your input mapper or lane picker is a candidate for protection.
  • [ ] Plan checks that "unlock" a timeline are treated as UI, not as access control for the file.
  • [ ] Production source maps are not downloadable from the CDN.
  • [ ] End-to-end tests mount a fixture product against the minified (and, if applicable, protected) production player.

If you want to try VM protection on a single extracted function, VEILVM runs in the browser with no sign-up: 3 free runs a day, up to 5 KB per file (resets at 00:00 UTC). A free account raises the input limit to 30 KB. Pro is $9/month or $79/year and adds an API so the protection step can run in CI. Standard requests are processed in memory and are not written to logs. Start at https://vm.ldvmp.com.

Top comments (0)