Run the MeowShield protect step in CI, not only on a developer's laptop
Disclosure: I help promote MeowShield. The Playground is a good place to learn a preset and inspect a build. It is a bad place to mint the JavaScript you actually ship. A production artifact that exists only because some
Disclosure: I help promote MeowShield. The Playground is a good place to learn a preset and inspect a build. It is a bad place to mint the JavaScript you actually ship. A production artifact that exists only because someone clicked Obfuscate on a laptop cannot be reproduced, reviewed, or rebuilt when that laptop is away, wiped, or sitting on a branch nobody else has.
What "done in CI" means
MeowShield's authorized API is a POST to https://meowshield.com/api with sourceCode, apiToken, and an options object (mode is low, medium, or high). Access is permission-based; confirm the current field names in the API docs. A response with error equal to 0 carries the protected JavaScript in code. That contract is enough to make protection a regular job:
- the source is the compiled or bundled file your pipeline already produced
- the options come from a file in the repo, not from memory
- apiToken is a CI secret, never a value in the browser bundle
- the job fails if the HTTP status is not successful or error is not 0
- the output is stored as a build artifact, next to a copy of the options you used
// scripts/protect.mjs (Node 18+) β sketch of the CI step
import { readFile, writeFile } from "node:fs/promises";
const sourceCode = await readFile(process.argv[2], "utf8");
const options = JSON.parse(await readFile("protect.options.json", "utf8"));
const res = await fetch("https://meowshield.com/api", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({
sourceCode,
apiToken: process.env.MEOWSHIELD_TOKEN,
options,
}),
signal: AbortSignal.timeout(120_000),
});
if (!res.ok) throw new Error("HTTP " + res.status);
const result = await res.json();
if (result.error !== 0) throw new Error(String(result.msg));
await writeFile(process.argv[3], result.code);
Do not log the request body. It contains both the source and the token.
What stays on the laptop
Exploratory work can stay in the Playground: trying Low versus Medium, reading an option's compatibility note, checking whether a fixture still runs. The moment a file is a candidate for production, the same options and the same source should go through CI. If the two paths disagree, trust the pipeline and fix the options file.
This does not make obfuscation absolute β MeowShield's FAQ says no protection is. It does make the protect step as reviewable as the rest of your release.
Docs and the API contract are at MeowShield.
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.