A modern course player looks like a video page with a lesson list. Under the surface it is a small rules engine. It decides when the next chapter unlocks, whether a quiz can be retried, how much watch time counts as complete, and whether a certificate can be issued. Those rules are the product: they are why a student pays for a cohort instead of watching a public YouTube playlist.
To keep the player feeling instant — especially on flaky mobile networks or in an offline "download this module" mode — many teams put that engine in the frontend JavaScript. The student then receives not only the lessons they paid for, but the policy that governs every lesson they have not paid for yet.
What a player bundle usually contains
export function progress(user, lesson, events) { const watched = qualifiedSeconds(events, MIN_WATCH_RATIO); const unlocked = lesson.requires.every((id) => user.completed[id]); const passed = score(user.attempts[lesson.id], PASSING, RETRIES); return { unlocked, complete: watched && passed, certificate: certReady(user, RULES) }; } After a production build, a determined student, a pirate site, or a competing academy can often recover:
- Unlock graphs. Which lessons are gated, which are free previews, and which bundles secretly share prerequisites.
- Completion thresholds. The minimum watch ratio, whether skipping ahead counts, and whether background playback is ignored.
- Retry and scoring policy. Passing scores, late-penalty curves, allowed attempts, and which questions are drawn from which bank.
- Certificate rules. The exact mix of required modules, time-in-course, and "honor lock" flags that issue a credential.
- Unreleased or upsell content. Titles, slugs, and gate messages for courses that are not public yet.
Once those rules are readable, two things happen. First, a client can be patched so every chapter appears unlocked and every quiz appears passed. Second, a rival can copy your pedagogy — the sequence, the gates, the certificate bar — without sitting through the course.
What belongs on the server
A player can be optimistic in the UI. It cannot be the authority for entitlements or credentials.
- Unlock and purchase state. The server should tell the player which lesson IDs the current user may load, and it should refuse to stream or download the rest. Hiding a "locked" button is not access control.
- Completion and certificates. Watch time, quiz scores, and certificate eligibility should be recorded and re-checked server-side. A client that posts
{ complete: true }is a suggestion, not a fact. - Media URLs. Signed, short-lived URLs beat a public path that the unlocked-looking player can fetch after a patch.
- Quiz grading. Grade on the server, especially when the item bank or the answer key must stay hidden. The article about answer keys is a close cousin of this one; the same advice applies to the surrounding progress policy.
- Unreleased catalog. Do not ship titles and gates for courses that are not for sale yet.
A good pattern is: the player may compute a local preview of progress so the sidebar updates immediately, then reconcile with a server progress API before the next lesson's media is requested.
Where code protection helps
Some policy still has to run on the device. Offline downloads, low-latency sidebar updates, and "resume exactly where you left off" all want a local engine. If you cannot move that engine, at least stop shipping it as readable source.
- Split catalog UI from policy. The React tree that renders the lesson list should not contain
MIN_WATCH_RATIOorRULES. - Extract
progress(and only the rules the current enrollment needs). - Rename identifiers and encrypt distinctive strings so rule names are not trivial to search for.
- Apply VM-based protection to the policy function so pretty-printing does not recover the graph.
- Turn off production source maps, and test the protected player against fixtures: locked user, partial watch, failed quiz, certificate edge cases.
A JavaScript VM obfuscator compiles the function into custom bytecode and a small interpreter. A student can still click around and try to infer a watch-ratio. They should not be able to paste your unlock graph into a patched player or publish your certificate rules. Protect the policy module, not the video chrome, and confirm that seeking and playback remain smooth afterwards.
VEILVM is a browser-based JSVMP workspace (disclosure: I work on it). You can paste one extracted progress function, compare it against enrollment fixtures, and only then add the same step to CI.
Checklist
- [ ] Lesson media is authorized and fetched with short-lived URLs, not only hidden in the UI.
- [ ] Completion, scores, and certificates are re-checked on the server.
- [ ] The client cannot unlock a lesson by patching a Boolean.
- [ ] Unreleased courses are not in the public catalog or player bundle.
- [ ] If local policy remains, only that module is protected and fixture-tested.
- [ ] Production source maps are off.
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.