Repository navigation
Contributing
estrogen is a Cargo workspace with two crates and an npm launcher.
You need the Rust toolchain (1.100 is the pinned version). Then:
git clone https://github.com/Fracital/estrogen
cd estrogen
cargo buildA release build uses the workspace release profile (fat LTO, one codegen unit, stripped, panic abort) for small binaries:
cargo build --releaseThe binary is target/release/estrogen.
cargo testRust unit tests live next to the passes. The parity harness and the decoder symmetry check run in CI; see below.
estrogen copies the behavior of the Node scripts the sites already ship. Those
scripts are the specification. The canonical one is Fracital's
scripts/obfuscate-build.mjs, with check-plaintext-leaks.mjs,
canary-list.json, and obfuscate-build.test.mjs. Port their rules and check
estrogen against their output on the same input; do not add rules they do not have.
One decision shapes the code: estrogen edits the source text, it does not reprint the AST. It parses with OXC, walks to collect byte-range edits, and splices them into the original source string. A code generator over the whole file would change bytes estrogen must leave alone. The AST locates the edits; estrogen rewrites the source string.
Build in milestones and check parity at each. The scaffold goes green first:
cargo build and cargo test pass across the targets, and the npm launcher
resolves and execs a stub binary, which proves the build and publish path before
the hard part.
Then a parity harness: run the Node script and estrogen on the same built directory into two output copies and diff them. Identical output first, then identical-enough once the pool order diverges on purpose, comparing runtime behavior and the canary result rather than bytes.
The passes land in order:
- Parse every eligible chunk and write it back unchanged. The diff is empty, which proves the walk and the splice before anything is rewritten.
- The string and template literal pool with the ChaCha20 decoder. The decoder-symmetry test passes against estrogen's output.
- Proxy-name renaming in strings, regex literals, and vendored markup, plus the store-name guard.
- The wasm name ranges and base64 handling.
- The HTML shells and the SVG cloak.
First acceptance: estrogen dist on a Fracital build passes that site's
check-plaintext-leaks.mjs at exit 0, and the site boots in a browser.
The pass uses per-file randomness (the ChaCha20 key) and per-build randomness
(stamped names, helper globals). For the harness and CI, that randomness is
seedable through --seed or a fixed-key test mode, so two runs on one input give
the same bytes and estrogen's output diffs against a pinned expectation. Production
builds use real randomness; the seed is for tests only.
Check by decoding, not by shape. In CI, run the emitted JS decoder against estrogen's pool and assert the decoded strings equal the originals. A pool that parses but decodes wrong is the failure the symmetry test exists to catch.
Speed is why estrogen exists, so measure it against the Node scripts on a real build. Files are independent, so they run in parallel with rayon. Run the whole pass once over the directory, not once per file from a shell.
Docs follow the no-slop rules: sentence case headings, plain verbs, concrete names and numbers, no em dashes, straight quotes. Run the project's writing grep before you open a pull request.
@sysce/estrogen ·
Fracital/estrogen · ISC · by David Reed.
estrogen raises the cost of reading a build; it does not make it secret.