@sysce/estrogen 0.5.4 → 0.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +196 -168
- package/dist/cjs/obfuscate.js +7 -1
- package/dist/cjs/options.d.ts +49 -2
- package/dist/cjs/options.js +16 -0
- package/dist/cjs/report.d.ts +11 -1
- package/dist/cjs/resolve-binary.d.ts +5 -3
- package/dist/cjs/resolve-binary.js +10 -5
- package/dist/esm/obfuscate.js +7 -1
- package/dist/esm/options.d.ts +49 -2
- package/dist/esm/options.js +16 -0
- package/dist/esm/report.d.ts +11 -1
- package/dist/esm/resolve-binary.d.ts +5 -3
- package/dist/esm/resolve-binary.js +10 -5
- package/package.json +9 -8
package/README.md
CHANGED
|
@@ -1,29 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
place: string and template literals into an encrypted per-file pool, proxy and
|
|
5
|
-
store names into per-build substitutes, and the embedded wasm names to match. It
|
|
6
|
-
leaves a build with no sensitive plaintext from the canary list and does not
|
|
7
|
-
change what the code does.
|
|
1
|
+
<div align="center">
|
|
2
|
+
<img src="https://raw.githubusercontent.com/Fracital/estrogen/v0.5.5/docs/assets/estrogen.png" alt="estrogen" width="88" />
|
|
3
|
+
</div>
|
|
8
4
|
|
|
9
|
-
estrogen
|
|
10
|
-
in each file, and anyone with devtools can run the code. Do not describe the
|
|
11
|
-
output as secret.
|
|
5
|
+
# @sysce/estrogen
|
|
12
6
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
7
|
+
<div align="center">
|
|
8
|
+
<a href="https://www.npmjs.com/package/@sysce/estrogen"><img src="https://img.shields.io/npm/v/@sysce/estrogen?maxAge=3600&label=npm" alt="npm" /></a>
|
|
9
|
+
<a href="https://github.com/Fracital/estrogen/actions/workflows/ci.yml"><img src="https://github.com/Fracital/estrogen/actions/workflows/ci.yml/badge.svg?branch=main" alt="CI" /></a>
|
|
10
|
+
<a href="https://github.com/Fracital/estrogen/blob/v0.5.5/LICENSE"><img src="https://img.shields.io/badge/license-ISC-blue.svg" alt="license: ISC" /></a>
|
|
11
|
+
<a href="https://github.com/Fracital/estrogen/issues"><img src="https://img.shields.io/github/issues/Fracital/estrogen?style=flat&color=orange" alt="GitHub issues" /></a>
|
|
12
|
+
<a href="https://github.com/Fracital/estrogen/stargazers"><img src="https://img.shields.io/github/stars/Fracital/estrogen?style=flat&color=orange" alt="GitHub stars" /></a>
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
A post-build web obfuscator. It takes a directory a bundler already produced and
|
|
16
|
+
rewrites the JS, HTML and SVG in place. In app scripts it pools strings,
|
|
17
|
+
template literals and regex patterns, disguises number and boolean literals as
|
|
18
|
+
equivalent expressions, and shortens local names. In vendor scripts it replaces
|
|
19
|
+
proxy and store names, plus the matching names in embedded wasm. It leaves no
|
|
20
|
+
sensitive plaintext from the canary list, and it does not change what the code
|
|
21
|
+
does.
|
|
22
|
+
|
|
23
|
+
It also assembles the build it protects. `estrogen build` vendors packages and
|
|
24
|
+
folders, from `node_modules` or a glob, into the served tree under per-build
|
|
25
|
+
stamped names, obfuscating them on the way in or copying them verbatim, from a
|
|
26
|
+
`[[vendor]]` config. `estrogen --watch` re-runs on each change, and
|
|
27
|
+
`--sourcemap <dir>` writes a private V3 source map outside the served tree.
|
|
28
|
+
estrogen runs as a command line tool, as esbuild, rsbuild, Vite and Rollup
|
|
29
|
+
plugins, and as an Astro integration.
|
|
30
|
+
|
|
31
|
+
estrogen is written in Rust on [OXC](https://oxc.rs) and published to npm as
|
|
32
|
+
[`@sysce/estrogen`](https://www.npmjs.com/package/@sysce/estrogen). The binary is
|
|
33
|
+
`estrogen`.
|
|
34
|
+
|
|
35
|
+
estrogen transforms a shipped build into something more fun to read for crawlers.
|
|
36
|
+
|
|
37
|
+
Try it in your browser at [estro.help](https://estro.help): the real engine
|
|
38
|
+
compiled to WebAssembly, running locally on what you paste. Nothing is uploaded.
|
|
17
39
|
|
|
18
40
|
## Install
|
|
19
41
|
|
|
20
42
|
```sh
|
|
21
|
-
npm
|
|
43
|
+
npm i -D @sysce/estrogen
|
|
22
44
|
```
|
|
23
45
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
46
|
+
The package pulls the matching per-target binary (`@sysce/estrogen-<os>-<cpu>`) as
|
|
47
|
+
an optional dependency. Supported targets: linux x64 and arm64, darwin x64 and
|
|
48
|
+
arm64, win32 x64.
|
|
27
49
|
|
|
28
50
|
A nightly build of `main` is published under the `nightly` dist-tag, versioned
|
|
29
51
|
like `0.5.5-nightly.202611230617.g1a2b3c4` (UTC time and commit), once a day
|
|
@@ -33,176 +55,182 @@ when `main` has a new commit that passed CI:
|
|
|
33
55
|
npm i -D @sysce/estrogen@nightly
|
|
34
56
|
```
|
|
35
57
|
|
|
36
|
-
##
|
|
58
|
+
## Quick start
|
|
37
59
|
|
|
38
|
-
|
|
39
|
-
estrogen [options] <dir>...
|
|
40
|
-
estrogen build [options] <dir>...
|
|
41
|
-
```
|
|
60
|
+
Run it over a built directory from the command line:
|
|
42
61
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
options:
|
|
46
|
-
|
|
47
|
-
| flag | meaning |
|
|
48
|
-
| ----------------------- | --------------------------------------------------------------- |
|
|
49
|
-
| `-c`, `--config <file>` | TOML config file |
|
|
50
|
-
| `--canary <file>` | canary list the output must not leak |
|
|
51
|
-
| `--names <file>` | proxy and store names to rename |
|
|
52
|
-
| `--sourcemap <dir>` | write maps here, outside the served tree, for private debugging |
|
|
53
|
-
| `--seed <hex>` | fixed seed for reproducible output (tests only) |
|
|
54
|
-
| `-j`, `--jobs <n>` | worker count |
|
|
55
|
-
| `--check` | report and run the canary check without writing |
|
|
56
|
-
| `--watch` | re-run on each change until stopped |
|
|
57
|
-
| `--quiet` | print nothing but errors |
|
|
58
|
-
| `-v`, `--verbose` | per-file detail |
|
|
59
|
-
| `-V`, `--version` | print the version |
|
|
60
|
-
| `-h`, `--help` | print help |
|
|
61
|
-
|
|
62
|
-
`estrogen --help` lists the rest: the VM switches (`--no-vm`, `--no-vm-glob`,
|
|
63
|
-
`--module-glob`, `--top-level`, `--shared-runtime`, `--no-function-source`,
|
|
64
|
-
`--no-function-source-warning`), the asset passes (`--no-minify`,
|
|
65
|
-
`--no-optimize-svg`, `--no-minify-html`, `--no-minify-css`), vendoring
|
|
66
|
-
(`--vendor-file`, `--manifest`, `--no-manifest`) and the live injector
|
|
67
|
-
(`--cloak-target`, `--cloaks`, `--cloak-shortcut`, `--cloak-mount`). The
|
|
68
|
-
repository's `docs/CLI.md` covers each one.
|
|
69
|
-
|
|
70
|
-
Exit code 0 means success. Any nonzero code means the build was not fully
|
|
71
|
-
rewritten; estrogen writes no partial output for a file it cannot handle and names
|
|
72
|
-
the file and the reason.
|
|
73
|
-
|
|
74
|
-
## Node API
|
|
75
|
-
|
|
76
|
-
```ts
|
|
77
|
-
import { obfuscate } from '@sysce/estrogen';
|
|
78
|
-
|
|
79
|
-
const report = await obfuscate({
|
|
80
|
-
dirs: 'dist',
|
|
81
|
-
canary: 'canary-list.json',
|
|
82
|
-
});
|
|
83
|
-
console.log(report.ok, report.durationMs);
|
|
62
|
+
```sh
|
|
63
|
+
npx estrogen dist
|
|
84
64
|
```
|
|
85
65
|
|
|
86
|
-
|
|
87
|
-
resolves with a `Report` when estrogen exits 0 and rejects with an `EstrogenError`
|
|
88
|
-
(carrying the partial report) when it exits nonzero or fails to start.
|
|
66
|
+
Or run it after an esbuild build, over the output directory:
|
|
89
67
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
```ts
|
|
68
|
+
```js
|
|
93
69
|
import estrogen from '@sysce/estrogen/esbuild';
|
|
94
70
|
import { build } from 'esbuild';
|
|
95
71
|
|
|
96
72
|
await build({
|
|
97
|
-
entryPoints: ['src/
|
|
73
|
+
entryPoints: ['src/index.ts'],
|
|
98
74
|
bundle: true,
|
|
99
75
|
outdir: 'dist',
|
|
100
|
-
plugins: [estrogen(
|
|
76
|
+
plugins: [estrogen()],
|
|
101
77
|
});
|
|
102
78
|
```
|
|
103
79
|
|
|
104
|
-
|
|
105
|
-
directory
|
|
106
|
-
`absWorkingDir`. It skips a build that produced errors and turns an estrogen failure
|
|
107
|
-
into an esbuild error.
|
|
108
|
-
|
|
109
|
-
## Rsbuild
|
|
80
|
+
Or add it to an Astro build, where it runs on `astro:build:done` over the output
|
|
81
|
+
directory:
|
|
110
82
|
|
|
111
|
-
```
|
|
112
|
-
import
|
|
113
|
-
import {
|
|
83
|
+
```js
|
|
84
|
+
import estrogen from '@sysce/estrogen/astro';
|
|
85
|
+
import { defineConfig } from 'astro/config';
|
|
114
86
|
|
|
115
87
|
export default defineConfig({
|
|
116
|
-
|
|
88
|
+
integrations: [estrogen()],
|
|
117
89
|
});
|
|
118
90
|
```
|
|
119
91
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
##
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
92
|
+
estrogen runs exactly once per build. It is not idempotent: a second run would
|
|
93
|
+
encrypt the decoder the first run added.
|
|
94
|
+
|
|
95
|
+
To bring packages into the build as well, run `estrogen build dist` with a
|
|
96
|
+
`[[vendor]]` config. See the [CLI reference](https://github.com/Fracital/estrogen/blob/v0.5.5/docs/CLI.md).
|
|
97
|
+
|
|
98
|
+
## Benchmarks
|
|
99
|
+
|
|
100
|
+
estrogen and [javascript-obfuscator](https://github.com/javascript-obfuscator/javascript-obfuscator)
|
|
101
|
+
5.10.1 build the same inputs, and each build runs in its own Node 24.19.0
|
|
102
|
+
process on a Ryzen 9 7950X. The suite is ten small workloads in
|
|
103
|
+
`bench/workloads` (median of 5 processes, 10 timed calls each); the library row
|
|
104
|
+
is Prettier 3.10.1's browser build, 610 KB of minified ES modules, formatting one
|
|
105
|
+
file 20 times (median of 3 processes). javascript-obfuscator runs its three
|
|
106
|
+
shipped presets unchanged, `debugProtection` and `disableConsoleOutput`
|
|
107
|
+
included. Every build returns the same result as the original, and the VM
|
|
108
|
+
compiled every file it was given. The method and full tables are in
|
|
109
|
+
[docs/BENCHMARKS.md](https://github.com/Fracital/estrogen/blob/v0.5.5/docs/BENCHMARKS.md); `npm run bench` reruns it.
|
|
110
|
+
|
|
111
|
+
| | estrogen, VM | estrogen, `--no-vm` | javascript-obfuscator, default | medium | high |
|
|
112
|
+
| ---------------------------------------- | ------------ | ------------------- | ------------------------------ | -------- | --------- |
|
|
113
|
+
| Suite, slowdown (geomean) | 22.9x | 2.29x | 1.19x | 5.75x | 8.14x |
|
|
114
|
+
| Suite, gzip size (geomean) | 19.6x | 2.88x | 1.87x | 15.2x | 61.7x |
|
|
115
|
+
| Suite, build of 10 files | 12 ms | 9 ms | 330 ms | 746 ms | 1,436 ms |
|
|
116
|
+
| Prettier, format 20 times (native 12 ms) | 276 ms | 28 ms | 16 ms | 124 ms | 393 ms |
|
|
117
|
+
| Prettier, gzip (native 169 KB) | 316 KB | 326 KB | 296 KB | 1,320 KB | 3,263 KB |
|
|
118
|
+
| Prettier, import (native 14 ms) | 67 ms | 33 ms | 21 ms | 147 ms | 522 ms |
|
|
119
|
+
| Prettier, build | 75 ms | 36 ms | 2,753 ms | 6,170 ms | 10,378 ms |
|
|
120
|
+
|
|
121
|
+
estrogen builds 27 to 140 times faster: Prettier takes 75 ms through the VM
|
|
122
|
+
and 10.4 s through the high preset. The default preset costs the least at run
|
|
123
|
+
time, 1.19x on the suite, and leaves strings readable in a plain string array;
|
|
124
|
+
`--no-vm` encrypts every string for 2.29x.
|
|
125
|
+
|
|
126
|
+
The VM is the slowest on the small workloads, 22.9x, because each one is a tight
|
|
127
|
+
loop that runs every instruction through the interpreter. On Prettier it runs at
|
|
128
|
+
22x, ahead of the high preset's 32x, and its output is smaller: 316 KB gzip
|
|
129
|
+
against 3,263 KB, and 1.9x native against the high preset's 19x. On the small
|
|
130
|
+
workloads the VM's size is mostly the runtime, about 9 KB gzip per file, which
|
|
131
|
+
`--shared-runtime` ships once for a build of ES modules. Hot code can leave the
|
|
132
|
+
VM with `--no-vm-glob`.
|
|
133
|
+
|
|
134
|
+
<img alt="Geometric mean slowdown, gzip size and build time for each tool and preset" src="https://raw.githubusercontent.com/Fracital/estrogen/v0.5.5/docs/assets/bench/summary.png">
|
|
135
|
+
|
|
136
|
+
<img alt="Prettier format time, gzip size and build time for each tool and preset" src="https://raw.githubusercontent.com/Fracital/estrogen/v0.5.5/docs/assets/bench/library.png">
|
|
137
|
+
|
|
138
|
+
<img alt="Steady-state slowdown against native for each workload, tool and preset" src="https://raw.githubusercontent.com/Fracital/estrogen/v0.5.5/docs/assets/bench/slowdown.png">
|
|
139
|
+
|
|
140
|
+
## Compared with javascript-obfuscator
|
|
141
|
+
|
|
142
|
+
[javascript-obfuscator](https://github.com/javascript-obfuscator/javascript-obfuscator)
|
|
143
|
+
5.10.1 is the open-source package. Its bytecode VM and HTML parsing are Pro
|
|
144
|
+
features of obfuscator.io: the source is uploaded to its cloud API, which needs a
|
|
145
|
+
paid token, so the benchmark above runs the local package.
|
|
146
|
+
|
|
147
|
+
| Technique | estrogen | javascript-obfuscator |
|
|
148
|
+
| --------------------------- | -------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- |
|
|
149
|
+
| Bytecode VM | Local, on by default, opcode bytes shuffled per build | Pro only, compiled on obfuscator.io's servers |
|
|
150
|
+
| String literals | Every string in a ChaCha20 pool, keyed per file | String array; base64 or RC4 is opt-in (RC4 in the high preset), 75% of strings by default |
|
|
151
|
+
| Template literals | Static parts pooled; regex patterns pooled too | Rewritten to `concat` calls; parts pooled at the string array threshold |
|
|
152
|
+
| Property names | Static member names and object keys pooled | Member names through the string array; object keys with `transformObjectKeys` |
|
|
153
|
+
| Number and boolean literals | Rewritten as xor, sum and difference expressions, `!0`, `!![]` | `numbersToExpressions` (medium and high presets); `!![]`, `![]` |
|
|
154
|
+
| Local names | Shortened; module top-level bindings too | Hexadecimal or mangled; `renameGlobals` and `renameProperties` opt-in |
|
|
155
|
+
| Control flow flattening | No separate pass; VM code runs as bytecode | Yes (medium and high presets) |
|
|
156
|
+
| Dead code injection | No | Yes (medium and high presets) |
|
|
157
|
+
| Self-defending, anti-debug | No | `selfDefending`, `debugProtection`, `disableConsoleOutput`, `domainLock` |
|
|
158
|
+
| `Function.toString` | VM functions print `[native code]`, in every realm the page opens | Prints the obfuscated source |
|
|
159
|
+
| HTML and SVG | Inline scripts, markup pass, HTML, SVG and CSS minified | Pro only (`parseHtml`) |
|
|
160
|
+
| Proxy runtimes and wasm | Proxy and store names replaced, plus the matching names in embedded wasm | No |
|
|
161
|
+
| Input | A built output directory, rewritten in place; fails closed; canary check | A source string, file or directory of scripts |
|
|
162
|
+
| Vendoring | `estrogen build` copies packages into the build under stamped names | No |
|
|
163
|
+
| Source maps | Private V3 maps written outside the served tree | Inline or separate |
|
|
164
|
+
| Reproducible output | `--seed` | `seed` |
|
|
165
|
+
| Integrations | esbuild, rsbuild, Vite and Rollup plugins and an Astro integration in the package; `--watch` | webpack, Rollup, gulp and Grunt plugins as separate packages; esbuild and Vite plugins by third parties |
|
|
166
|
+
| Implementation | Rust on OXC, one native binary per platform, files in parallel | TypeScript on Node |
|
|
167
|
+
| In the browser | [estro.help](https://estro.help), the engine as WebAssembly, run locally | [obfuscator.io](https://obfuscator.io) |
|
|
168
|
+
| License | ISC | BSD-2-Clause |
|
|
169
|
+
|
|
170
|
+
## Documentation
|
|
171
|
+
|
|
172
|
+
- [Text cloak and live injector](https://github.com/Fracital/estrogen/blob/v0.5.5/docs/CLOAK.md): per-request ciphertext,
|
|
173
|
+
framework components, Ctrl+E overlays and opt-in frontend build inputs.
|
|
174
|
+
- [CLI reference](https://github.com/Fracital/estrogen/blob/v0.5.5/docs/CLI.md): every flag, examples, exit codes, the
|
|
175
|
+
fail-closed rule.
|
|
176
|
+
- [Node API](https://github.com/Fracital/estrogen/blob/v0.5.5/docs/NODE-API.md): `obfuscate()`, the esbuild, rsbuild, Vite and
|
|
177
|
+
Rollup plugins, the Astro integration, the options object, the `Report` shape.
|
|
178
|
+
- [Rust API](https://github.com/Fracital/estrogen/blob/v0.5.5/docs/RUST-API.md): the `estrogen-core` public surface.
|
|
179
|
+
- [Integration](https://github.com/Fracital/estrogen/blob/v0.5.5/docs/INTEGRATION.md): esbuild, rsbuild, Vite, Rollup, Astro, and
|
|
180
|
+
a plain CLI step in `package.json`.
|
|
181
|
+
- [Benchmarks](https://github.com/Fracital/estrogen/blob/v0.5.5/docs/BENCHMARKS.md): what the VM and the literal pool cost at
|
|
182
|
+
run time and load, per workload, and the harness in `bench/`.
|
|
183
|
+
- [Project status](https://github.com/Fracital/estrogen/blob/v0.5.5/docs/PROJECT_STATUS.md): current validation and remaining
|
|
184
|
+
compatibility work.
|
|
185
|
+
- [Proxy name rename](https://github.com/Fracital/estrogen/blob/v0.5.5/docs/PROXY-NAMES.md): the `[proxy]` table, the vendor
|
|
186
|
+
and build scopes, `keep`, and the text a rename must not change.
|
|
187
|
+
- [Proxy integration coverage](https://github.com/Fracital/estrogen/blob/v0.5.5/docs/PROXY_COVERAGE.md): per-site builds,
|
|
188
|
+
browser evidence, VM percentages and remaining gaps.
|
|
189
|
+
- [Wiki](https://github.com/Fracital/estrogen/wiki): install, configuration,
|
|
190
|
+
source maps, security and limits, contributing.
|
|
191
|
+
|
|
192
|
+
## Powering
|
|
193
|
+
|
|
194
|
+
<table>
|
|
195
|
+
<tr><th></th><th>Site</th><th>Link</th><th>Repo</th></tr>
|
|
196
|
+
<tr>
|
|
197
|
+
<td align="center" valign="middle"><img src="https://raw.githubusercontent.com/Fracital/estrogen/v0.5.5/docs/assets/brands/abstract.png" alt="abstract v2" width="28"></td>
|
|
198
|
+
<td valign="middle">abstract v2</td>
|
|
199
|
+
<td valign="middle"><a href="https://abstracteducation.loan">abstracteducation.loan</a></td>
|
|
200
|
+
<td valign="middle"></td>
|
|
201
|
+
</tr>
|
|
202
|
+
<tr>
|
|
203
|
+
<td align="center" valign="middle"><img src="https://raw.githubusercontent.com/Fracital/estrogen/v0.5.5/docs/assets/brands/fracital.svg" alt="Fracital" width="28"></td>
|
|
204
|
+
<td valign="middle">Fracital</td>
|
|
205
|
+
<td valign="middle"><a href="https://fracit.al">fracit.al</a></td>
|
|
206
|
+
<td valign="middle"><a href="https://github.com/Fracital/Fracital"><code>Fracital/Fracital</code></a></td>
|
|
207
|
+
</tr>
|
|
208
|
+
<tr>
|
|
209
|
+
<td align="center" valign="middle"><img src="https://raw.githubusercontent.com/Fracital/estrogen/v0.5.5/docs/assets/brands/systemya.png" alt="SystemYA" width="28"></td>
|
|
210
|
+
<td valign="middle">SystemYA</td>
|
|
211
|
+
<td valign="middle"><a href="https://systemya.fracit.al">systemya.fracit.al</a></td>
|
|
212
|
+
<td valign="middle"><a href="https://github.com/Fracital/SystemYA"><code>Fracital/SystemYA</code></a></td>
|
|
213
|
+
</tr>
|
|
214
|
+
<tr>
|
|
215
|
+
<td align="center" valign="middle"><img src="https://raw.githubusercontent.com/Fracital/estrogen/v0.5.5/docs/assets/brands/stomp.png" alt="STomp" width="28"></td>
|
|
216
|
+
<td valign="middle">STomp (powerMouse)</td>
|
|
217
|
+
<td valign="middle"><a href="https://stomp.fracit.al">stomp.fracit.al</a></td>
|
|
218
|
+
<td valign="middle"><a href="https://github.com/Fracital/powerMouse"><code>Fracital/powerMouse</code></a></td>
|
|
219
|
+
</tr>
|
|
220
|
+
<tr>
|
|
221
|
+
<td align="center" valign="middle"><img src="https://raw.githubusercontent.com/Fracital/estrogen/v0.5.5/docs/assets/brands/holy-unblocker.svg" alt="Holy Unblocker" width="28"></td>
|
|
222
|
+
<td valign="middle">Holy Unblocker</td>
|
|
223
|
+
<td valign="middle"><a href="https://holyunb.locker">holyunb.locker</a></td>
|
|
224
|
+
<td valign="middle"><a href="https://github.com/holy-unblocker/website2"><code>holy-unblocker/website2</code></a></td>
|
|
225
|
+
</tr>
|
|
226
|
+
</table>
|
|
227
|
+
|
|
228
|
+
## Credits
|
|
229
|
+
|
|
230
|
+
| | GitHub | Name |
|
|
231
|
+
| ----------------------------------------------------------------------------- | ------------------------------ | ---------- |
|
|
232
|
+
| <img src="https://raw.githubusercontent.com/Fracital/estrogen/v0.5.5/docs/assets/am%20i%20cool%20yet.png" width="64" alt="e9x's avatar"> | [@e9x](https://github.com/e9x) | David Reed |
|
|
205
233
|
|
|
206
234
|
## License
|
|
207
235
|
|
|
208
|
-
ISC.
|
|
236
|
+
ISC. See [LICENSE](https://github.com/Fracital/estrogen/blob/v0.5.5/LICENSE).
|
package/dist/cjs/obfuscate.js
CHANGED
|
@@ -119,8 +119,13 @@ function run(binaryPath, args, dirs, options) {
|
|
|
119
119
|
};
|
|
120
120
|
reject(new report_js_1.EstrogenError(`estrogen failed to start: ${error.message}`, report));
|
|
121
121
|
});
|
|
122
|
-
child.on('close', (code, signal) => {
|
|
122
|
+
child.on('close', async (code, signal) => {
|
|
123
123
|
const exitCode = code ?? -1;
|
|
124
|
+
const run = options.report === undefined
|
|
125
|
+
? undefined
|
|
126
|
+
: await (0, promises_1.readFile)((0, node_path_1.resolve)(options.cwd ?? process.cwd(), options.report), 'utf8')
|
|
127
|
+
.then((text) => JSON.parse(text))
|
|
128
|
+
.catch(() => undefined);
|
|
124
129
|
// A plugin never prints stderr, so pass the warning through here.
|
|
125
130
|
const warning = (0, report_js_1.functionSourceWarning)(stderr);
|
|
126
131
|
if (warning !== undefined)
|
|
@@ -136,6 +141,7 @@ function run(binaryPath, args, dirs, options) {
|
|
|
136
141
|
durationMs: Date.now() - started,
|
|
137
142
|
details: (0, report_js_1.parseDetails)(stdout),
|
|
138
143
|
warning,
|
|
144
|
+
run,
|
|
139
145
|
};
|
|
140
146
|
if (report.ok) {
|
|
141
147
|
resolve(report);
|
package/dist/cjs/options.d.ts
CHANGED
|
@@ -10,6 +10,16 @@ export interface LiveInjectorOptions {
|
|
|
10
10
|
shortcut?: string;
|
|
11
11
|
/** CSS selector for the decoy region to cover; leave unset to cover the viewport. */
|
|
12
12
|
mount?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Served directory for the runtime and frontends, relative to each dist
|
|
15
|
+
* root. Defaults to a name derived from the injector config.
|
|
16
|
+
*/
|
|
17
|
+
path?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Global name for the `show`, `hide`, `toggle` and `select` API. Unset, the
|
|
20
|
+
* runtime exposes no global.
|
|
21
|
+
*/
|
|
22
|
+
api?: string;
|
|
13
23
|
}
|
|
14
24
|
/** One reference rewrite on a vendored file (`[[vendor.rewrite]]`). */
|
|
15
25
|
export interface VendorRewrite {
|
|
@@ -82,6 +92,11 @@ export interface Options {
|
|
|
82
92
|
* survive verbatim in the output. estrogen fails nonzero if one does.
|
|
83
93
|
*/
|
|
84
94
|
canary?: string;
|
|
95
|
+
/**
|
|
96
|
+
* Match canaries without regard to ASCII case (`--canary-ignore-case`), so
|
|
97
|
+
* `scramjet` also matches `Scramjet`. The default is exact case.
|
|
98
|
+
*/
|
|
99
|
+
canaryIgnoreCase?: boolean;
|
|
85
100
|
/**
|
|
86
101
|
* Names file (`--names <file>`). The proxy and store names to rename for this
|
|
87
102
|
* site.
|
|
@@ -134,6 +149,37 @@ export interface Options {
|
|
|
134
149
|
* CSS as the bundler wrote it.
|
|
135
150
|
*/
|
|
136
151
|
minifyCss?: boolean;
|
|
152
|
+
/**
|
|
153
|
+
* Compile inline `<script>` bodies to the bytecode VM (`--inline-vm`). Off by
|
|
154
|
+
* default: inline scripts take the literal pool, because each inline VM chunk
|
|
155
|
+
* carries its own runtime.
|
|
156
|
+
*/
|
|
157
|
+
inlineVm?: boolean;
|
|
158
|
+
/**
|
|
159
|
+
* The header comment for each protected file (`--marker <text>`), in place of
|
|
160
|
+
* `generated by https://estro.help`. An empty string writes no header, and a
|
|
161
|
+
* second run then cannot recognize the output as protected.
|
|
162
|
+
*/
|
|
163
|
+
marker?: string;
|
|
164
|
+
/**
|
|
165
|
+
* Write a JSON report of the run to this file (`--report <file>`), relative
|
|
166
|
+
* to {@link Options.cwd}: each file's status and protection (`vm`,
|
|
167
|
+
* `vm-classic`, `vm-shared`, `literals`, `proxy`, `markup`, `minified`), the
|
|
168
|
+
* reason the VM declined a chunk, every canary leak, and each failed gate.
|
|
169
|
+
* {@link obfuscate} reads it back into {@link Report.run}, on success and on
|
|
170
|
+
* failure.
|
|
171
|
+
*/
|
|
172
|
+
report?: string;
|
|
173
|
+
/**
|
|
174
|
+
* Fail the run (exit 4) when any JS chunk is protected by something other
|
|
175
|
+
* than the VM (`--require-vm`).
|
|
176
|
+
*/
|
|
177
|
+
requireVm?: boolean;
|
|
178
|
+
/**
|
|
179
|
+
* Fail the run (exit 5) when VM chunks turn more than this many functions
|
|
180
|
+
* into strings (`--max-function-source <n>`).
|
|
181
|
+
*/
|
|
182
|
+
maxFunctionSource?: number;
|
|
137
183
|
/** Inject a selected frontend in a closed shadow overlay after obfuscation. Off by default. */
|
|
138
184
|
injector?: LiveInjectorOptions;
|
|
139
185
|
/**
|
|
@@ -187,8 +233,9 @@ export interface Options {
|
|
|
187
233
|
verbose?: boolean;
|
|
188
234
|
/**
|
|
189
235
|
* Path to the estrogen binary. Overrides the per-platform package resolution.
|
|
190
|
-
* Set it to run a locally built binary or a stub in tests.
|
|
191
|
-
*
|
|
236
|
+
* Set it to run a locally built binary or a stub in tests. When unset, the
|
|
237
|
+
* `ESTROGEN_BINARY` environment variable is used if set, and otherwise the
|
|
238
|
+
* matching `@sysce/estrogen-<os>-<cpu>` package provides it.
|
|
192
239
|
*/
|
|
193
240
|
binaryPath?: string;
|
|
194
241
|
/** Working directory for the spawned process. Defaults to `process.cwd()`. */
|
package/dist/cjs/options.js
CHANGED
|
@@ -31,6 +31,8 @@ function buildArgs(options) {
|
|
|
31
31
|
args.push('--config', options.config);
|
|
32
32
|
if (options.canary !== undefined)
|
|
33
33
|
args.push('--canary', options.canary);
|
|
34
|
+
if (options.canaryIgnoreCase)
|
|
35
|
+
args.push('--canary-ignore-case');
|
|
34
36
|
if (options.names !== undefined)
|
|
35
37
|
args.push('--names', options.names);
|
|
36
38
|
if (options.sourcemap !== undefined)
|
|
@@ -47,6 +49,16 @@ function buildArgs(options) {
|
|
|
47
49
|
args.push('--no-minify-html');
|
|
48
50
|
if (options.minifyCss === false)
|
|
49
51
|
args.push('--no-minify-css');
|
|
52
|
+
if (options.inlineVm)
|
|
53
|
+
args.push('--inline-vm');
|
|
54
|
+
if (options.marker !== undefined)
|
|
55
|
+
args.push('--marker', options.marker);
|
|
56
|
+
if (options.report !== undefined)
|
|
57
|
+
args.push('--report', options.report);
|
|
58
|
+
if (options.requireVm)
|
|
59
|
+
args.push('--require-vm');
|
|
60
|
+
if (options.maxFunctionSource !== undefined)
|
|
61
|
+
args.push('--max-function-source', String(options.maxFunctionSource));
|
|
50
62
|
if (options.moduleGlobs)
|
|
51
63
|
for (const pattern of options.moduleGlobs)
|
|
52
64
|
args.push('--module-glob', pattern);
|
|
@@ -77,6 +89,10 @@ function buildArgs(options) {
|
|
|
77
89
|
args.push('--cloak-shortcut', options.injector.shortcut);
|
|
78
90
|
if (options.injector.mount)
|
|
79
91
|
args.push('--cloak-mount', options.injector.mount);
|
|
92
|
+
if (options.injector.path)
|
|
93
|
+
args.push('--cloak-path', options.injector.path);
|
|
94
|
+
if (options.injector.api)
|
|
95
|
+
args.push('--cloak-api', options.injector.api);
|
|
80
96
|
}
|
|
81
97
|
if (options.quiet)
|
|
82
98
|
args.push('--quiet');
|
package/dist/cjs/report.d.ts
CHANGED
|
@@ -6,7 +6,11 @@
|
|
|
6
6
|
export interface Report {
|
|
7
7
|
/** True when estrogen exited 0. */
|
|
8
8
|
ok: boolean;
|
|
9
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* The process exit code. 0 on success, 1 for an error, 2 for an unprotected
|
|
11
|
+
* file under `check`, 3 for a canary in the output, 4 for a non-VM chunk
|
|
12
|
+
* under `requireVm`, and 5 for `maxFunctionSource` exceeded.
|
|
13
|
+
*/
|
|
10
14
|
exitCode: number;
|
|
11
15
|
/** The directories estrogen was asked to rewrite. */
|
|
12
16
|
dirs: string[];
|
|
@@ -39,6 +43,12 @@ export interface Report {
|
|
|
39
43
|
* shape is the binary's own and may grow; read it defensively.
|
|
40
44
|
*/
|
|
41
45
|
details?: unknown;
|
|
46
|
+
/**
|
|
47
|
+
* The JSON run report, read back from {@link Options.report} when it is set
|
|
48
|
+
* and the binary wrote it. Its `version` field names the shape; read it
|
|
49
|
+
* defensively.
|
|
50
|
+
*/
|
|
51
|
+
run?: unknown;
|
|
42
52
|
}
|
|
43
53
|
/**
|
|
44
54
|
* Thrown when estrogen exits nonzero or fails to launch. Carries the partial
|
|
@@ -30,9 +30,11 @@ export declare class MissingBinaryError extends Error {
|
|
|
30
30
|
* Locate the estrogen binary for the running platform.
|
|
31
31
|
*
|
|
32
32
|
* Resolution order:
|
|
33
|
-
* 1. `override`, when given, is returned as is (the `binaryPath` option
|
|
34
|
-
*
|
|
35
|
-
* 2. Otherwise the
|
|
33
|
+
* 1. `override`, when given, is returned as is (the `binaryPath` option uses
|
|
34
|
+
* this).
|
|
35
|
+
* 2. Otherwise the `ESTROGEN_BINARY` environment variable, when set, so the
|
|
36
|
+
* `estrogen` command, {@link obfuscate} and every plugin run the same binary.
|
|
37
|
+
* 3. Otherwise the matching `@sysce/estrogen-<os>-<cpu>` package is resolved
|
|
36
38
|
* through `req.resolve` and the binary path inside it is returned.
|
|
37
39
|
*
|
|
38
40
|
* `req` is a `require` function anchored in the launcher package, so resolution
|
|
@@ -60,15 +60,17 @@ exports.MissingBinaryError = MissingBinaryError;
|
|
|
60
60
|
* The tail of every {@link MissingBinaryError} message: the two ways to run a
|
|
61
61
|
* binary that did not come from a per-platform package.
|
|
62
62
|
*/
|
|
63
|
-
const OVERRIDE_HINT = 'To use a binary built elsewhere, set ESTROGEN_BINARY
|
|
64
|
-
'
|
|
63
|
+
const OVERRIDE_HINT = 'To use a binary built elsewhere, set ESTROGEN_BINARY, or pass the ' +
|
|
64
|
+
'binaryPath option to obfuscate() and the plugins.';
|
|
65
65
|
/**
|
|
66
66
|
* Locate the estrogen binary for the running platform.
|
|
67
67
|
*
|
|
68
68
|
* Resolution order:
|
|
69
|
-
* 1. `override`, when given, is returned as is (the `binaryPath` option
|
|
70
|
-
*
|
|
71
|
-
* 2. Otherwise the
|
|
69
|
+
* 1. `override`, when given, is returned as is (the `binaryPath` option uses
|
|
70
|
+
* this).
|
|
71
|
+
* 2. Otherwise the `ESTROGEN_BINARY` environment variable, when set, so the
|
|
72
|
+
* `estrogen` command, {@link obfuscate} and every plugin run the same binary.
|
|
73
|
+
* 3. Otherwise the matching `@sysce/estrogen-<os>-<cpu>` package is resolved
|
|
72
74
|
* through `req.resolve` and the binary path inside it is returned.
|
|
73
75
|
*
|
|
74
76
|
* `req` is a `require` function anchored in the launcher package, so resolution
|
|
@@ -80,6 +82,9 @@ const OVERRIDE_HINT = 'To use a binary built elsewhere, set ESTROGEN_BINARY for
|
|
|
80
82
|
function resolveBinaryPath(req, override) {
|
|
81
83
|
if (override !== undefined && override !== '')
|
|
82
84
|
return override;
|
|
85
|
+
const fromEnv = process.env.ESTROGEN_BINARY;
|
|
86
|
+
if (fromEnv !== undefined && fromEnv !== '')
|
|
87
|
+
return fromEnv;
|
|
83
88
|
const key = targetKey();
|
|
84
89
|
const pkg = platformPackageName();
|
|
85
90
|
if (key === null || pkg === null) {
|
package/dist/esm/obfuscate.js
CHANGED
|
@@ -116,8 +116,13 @@ function run(binaryPath, args, dirs, options) {
|
|
|
116
116
|
};
|
|
117
117
|
reject(new EstrogenError(`estrogen failed to start: ${error.message}`, report));
|
|
118
118
|
});
|
|
119
|
-
child.on('close', (code, signal) => {
|
|
119
|
+
child.on('close', async (code, signal) => {
|
|
120
120
|
const exitCode = code ?? -1;
|
|
121
|
+
const run = options.report === undefined
|
|
122
|
+
? undefined
|
|
123
|
+
: await readFile(resolvePath(options.cwd ?? process.cwd(), options.report), 'utf8')
|
|
124
|
+
.then((text) => JSON.parse(text))
|
|
125
|
+
.catch(() => undefined);
|
|
121
126
|
// A plugin never prints stderr, so pass the warning through here.
|
|
122
127
|
const warning = functionSourceWarning(stderr);
|
|
123
128
|
if (warning !== undefined)
|
|
@@ -133,6 +138,7 @@ function run(binaryPath, args, dirs, options) {
|
|
|
133
138
|
durationMs: Date.now() - started,
|
|
134
139
|
details: parseDetails(stdout),
|
|
135
140
|
warning,
|
|
141
|
+
run,
|
|
136
142
|
};
|
|
137
143
|
if (report.ok) {
|
|
138
144
|
resolve(report);
|
package/dist/esm/options.d.ts
CHANGED
|
@@ -10,6 +10,16 @@ export interface LiveInjectorOptions {
|
|
|
10
10
|
shortcut?: string;
|
|
11
11
|
/** CSS selector for the decoy region to cover; leave unset to cover the viewport. */
|
|
12
12
|
mount?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Served directory for the runtime and frontends, relative to each dist
|
|
15
|
+
* root. Defaults to a name derived from the injector config.
|
|
16
|
+
*/
|
|
17
|
+
path?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Global name for the `show`, `hide`, `toggle` and `select` API. Unset, the
|
|
20
|
+
* runtime exposes no global.
|
|
21
|
+
*/
|
|
22
|
+
api?: string;
|
|
13
23
|
}
|
|
14
24
|
/** One reference rewrite on a vendored file (`[[vendor.rewrite]]`). */
|
|
15
25
|
export interface VendorRewrite {
|
|
@@ -82,6 +92,11 @@ export interface Options {
|
|
|
82
92
|
* survive verbatim in the output. estrogen fails nonzero if one does.
|
|
83
93
|
*/
|
|
84
94
|
canary?: string;
|
|
95
|
+
/**
|
|
96
|
+
* Match canaries without regard to ASCII case (`--canary-ignore-case`), so
|
|
97
|
+
* `scramjet` also matches `Scramjet`. The default is exact case.
|
|
98
|
+
*/
|
|
99
|
+
canaryIgnoreCase?: boolean;
|
|
85
100
|
/**
|
|
86
101
|
* Names file (`--names <file>`). The proxy and store names to rename for this
|
|
87
102
|
* site.
|
|
@@ -134,6 +149,37 @@ export interface Options {
|
|
|
134
149
|
* CSS as the bundler wrote it.
|
|
135
150
|
*/
|
|
136
151
|
minifyCss?: boolean;
|
|
152
|
+
/**
|
|
153
|
+
* Compile inline `<script>` bodies to the bytecode VM (`--inline-vm`). Off by
|
|
154
|
+
* default: inline scripts take the literal pool, because each inline VM chunk
|
|
155
|
+
* carries its own runtime.
|
|
156
|
+
*/
|
|
157
|
+
inlineVm?: boolean;
|
|
158
|
+
/**
|
|
159
|
+
* The header comment for each protected file (`--marker <text>`), in place of
|
|
160
|
+
* `generated by https://estro.help`. An empty string writes no header, and a
|
|
161
|
+
* second run then cannot recognize the output as protected.
|
|
162
|
+
*/
|
|
163
|
+
marker?: string;
|
|
164
|
+
/**
|
|
165
|
+
* Write a JSON report of the run to this file (`--report <file>`), relative
|
|
166
|
+
* to {@link Options.cwd}: each file's status and protection (`vm`,
|
|
167
|
+
* `vm-classic`, `vm-shared`, `literals`, `proxy`, `markup`, `minified`), the
|
|
168
|
+
* reason the VM declined a chunk, every canary leak, and each failed gate.
|
|
169
|
+
* {@link obfuscate} reads it back into {@link Report.run}, on success and on
|
|
170
|
+
* failure.
|
|
171
|
+
*/
|
|
172
|
+
report?: string;
|
|
173
|
+
/**
|
|
174
|
+
* Fail the run (exit 4) when any JS chunk is protected by something other
|
|
175
|
+
* than the VM (`--require-vm`).
|
|
176
|
+
*/
|
|
177
|
+
requireVm?: boolean;
|
|
178
|
+
/**
|
|
179
|
+
* Fail the run (exit 5) when VM chunks turn more than this many functions
|
|
180
|
+
* into strings (`--max-function-source <n>`).
|
|
181
|
+
*/
|
|
182
|
+
maxFunctionSource?: number;
|
|
137
183
|
/** Inject a selected frontend in a closed shadow overlay after obfuscation. Off by default. */
|
|
138
184
|
injector?: LiveInjectorOptions;
|
|
139
185
|
/**
|
|
@@ -187,8 +233,9 @@ export interface Options {
|
|
|
187
233
|
verbose?: boolean;
|
|
188
234
|
/**
|
|
189
235
|
* Path to the estrogen binary. Overrides the per-platform package resolution.
|
|
190
|
-
* Set it to run a locally built binary or a stub in tests.
|
|
191
|
-
*
|
|
236
|
+
* Set it to run a locally built binary or a stub in tests. When unset, the
|
|
237
|
+
* `ESTROGEN_BINARY` environment variable is used if set, and otherwise the
|
|
238
|
+
* matching `@sysce/estrogen-<os>-<cpu>` package provides it.
|
|
192
239
|
*/
|
|
193
240
|
binaryPath?: string;
|
|
194
241
|
/** Working directory for the spawned process. Defaults to `process.cwd()`. */
|
package/dist/esm/options.js
CHANGED
|
@@ -27,6 +27,8 @@ export function buildArgs(options) {
|
|
|
27
27
|
args.push('--config', options.config);
|
|
28
28
|
if (options.canary !== undefined)
|
|
29
29
|
args.push('--canary', options.canary);
|
|
30
|
+
if (options.canaryIgnoreCase)
|
|
31
|
+
args.push('--canary-ignore-case');
|
|
30
32
|
if (options.names !== undefined)
|
|
31
33
|
args.push('--names', options.names);
|
|
32
34
|
if (options.sourcemap !== undefined)
|
|
@@ -43,6 +45,16 @@ export function buildArgs(options) {
|
|
|
43
45
|
args.push('--no-minify-html');
|
|
44
46
|
if (options.minifyCss === false)
|
|
45
47
|
args.push('--no-minify-css');
|
|
48
|
+
if (options.inlineVm)
|
|
49
|
+
args.push('--inline-vm');
|
|
50
|
+
if (options.marker !== undefined)
|
|
51
|
+
args.push('--marker', options.marker);
|
|
52
|
+
if (options.report !== undefined)
|
|
53
|
+
args.push('--report', options.report);
|
|
54
|
+
if (options.requireVm)
|
|
55
|
+
args.push('--require-vm');
|
|
56
|
+
if (options.maxFunctionSource !== undefined)
|
|
57
|
+
args.push('--max-function-source', String(options.maxFunctionSource));
|
|
46
58
|
if (options.moduleGlobs)
|
|
47
59
|
for (const pattern of options.moduleGlobs)
|
|
48
60
|
args.push('--module-glob', pattern);
|
|
@@ -73,6 +85,10 @@ export function buildArgs(options) {
|
|
|
73
85
|
args.push('--cloak-shortcut', options.injector.shortcut);
|
|
74
86
|
if (options.injector.mount)
|
|
75
87
|
args.push('--cloak-mount', options.injector.mount);
|
|
88
|
+
if (options.injector.path)
|
|
89
|
+
args.push('--cloak-path', options.injector.path);
|
|
90
|
+
if (options.injector.api)
|
|
91
|
+
args.push('--cloak-api', options.injector.api);
|
|
76
92
|
}
|
|
77
93
|
if (options.quiet)
|
|
78
94
|
args.push('--quiet');
|
package/dist/esm/report.d.ts
CHANGED
|
@@ -6,7 +6,11 @@
|
|
|
6
6
|
export interface Report {
|
|
7
7
|
/** True when estrogen exited 0. */
|
|
8
8
|
ok: boolean;
|
|
9
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* The process exit code. 0 on success, 1 for an error, 2 for an unprotected
|
|
11
|
+
* file under `check`, 3 for a canary in the output, 4 for a non-VM chunk
|
|
12
|
+
* under `requireVm`, and 5 for `maxFunctionSource` exceeded.
|
|
13
|
+
*/
|
|
10
14
|
exitCode: number;
|
|
11
15
|
/** The directories estrogen was asked to rewrite. */
|
|
12
16
|
dirs: string[];
|
|
@@ -39,6 +43,12 @@ export interface Report {
|
|
|
39
43
|
* shape is the binary's own and may grow; read it defensively.
|
|
40
44
|
*/
|
|
41
45
|
details?: unknown;
|
|
46
|
+
/**
|
|
47
|
+
* The JSON run report, read back from {@link Options.report} when it is set
|
|
48
|
+
* and the binary wrote it. Its `version` field names the shape; read it
|
|
49
|
+
* defensively.
|
|
50
|
+
*/
|
|
51
|
+
run?: unknown;
|
|
42
52
|
}
|
|
43
53
|
/**
|
|
44
54
|
* Thrown when estrogen exits nonzero or fails to launch. Carries the partial
|
|
@@ -30,9 +30,11 @@ export declare class MissingBinaryError extends Error {
|
|
|
30
30
|
* Locate the estrogen binary for the running platform.
|
|
31
31
|
*
|
|
32
32
|
* Resolution order:
|
|
33
|
-
* 1. `override`, when given, is returned as is (the `binaryPath` option
|
|
34
|
-
*
|
|
35
|
-
* 2. Otherwise the
|
|
33
|
+
* 1. `override`, when given, is returned as is (the `binaryPath` option uses
|
|
34
|
+
* this).
|
|
35
|
+
* 2. Otherwise the `ESTROGEN_BINARY` environment variable, when set, so the
|
|
36
|
+
* `estrogen` command, {@link obfuscate} and every plugin run the same binary.
|
|
37
|
+
* 3. Otherwise the matching `@sysce/estrogen-<os>-<cpu>` package is resolved
|
|
36
38
|
* through `req.resolve` and the binary path inside it is returned.
|
|
37
39
|
*
|
|
38
40
|
* `req` is a `require` function anchored in the launcher package, so resolution
|
|
@@ -52,15 +52,17 @@ export class MissingBinaryError extends Error {
|
|
|
52
52
|
* The tail of every {@link MissingBinaryError} message: the two ways to run a
|
|
53
53
|
* binary that did not come from a per-platform package.
|
|
54
54
|
*/
|
|
55
|
-
const OVERRIDE_HINT = 'To use a binary built elsewhere, set ESTROGEN_BINARY
|
|
56
|
-
'
|
|
55
|
+
const OVERRIDE_HINT = 'To use a binary built elsewhere, set ESTROGEN_BINARY, or pass the ' +
|
|
56
|
+
'binaryPath option to obfuscate() and the plugins.';
|
|
57
57
|
/**
|
|
58
58
|
* Locate the estrogen binary for the running platform.
|
|
59
59
|
*
|
|
60
60
|
* Resolution order:
|
|
61
|
-
* 1. `override`, when given, is returned as is (the `binaryPath` option
|
|
62
|
-
*
|
|
63
|
-
* 2. Otherwise the
|
|
61
|
+
* 1. `override`, when given, is returned as is (the `binaryPath` option uses
|
|
62
|
+
* this).
|
|
63
|
+
* 2. Otherwise the `ESTROGEN_BINARY` environment variable, when set, so the
|
|
64
|
+
* `estrogen` command, {@link obfuscate} and every plugin run the same binary.
|
|
65
|
+
* 3. Otherwise the matching `@sysce/estrogen-<os>-<cpu>` package is resolved
|
|
64
66
|
* through `req.resolve` and the binary path inside it is returned.
|
|
65
67
|
*
|
|
66
68
|
* `req` is a `require` function anchored in the launcher package, so resolution
|
|
@@ -72,6 +74,9 @@ const OVERRIDE_HINT = 'To use a binary built elsewhere, set ESTROGEN_BINARY for
|
|
|
72
74
|
export function resolveBinaryPath(req, override) {
|
|
73
75
|
if (override !== undefined && override !== '')
|
|
74
76
|
return override;
|
|
77
|
+
const fromEnv = process.env.ESTROGEN_BINARY;
|
|
78
|
+
if (fromEnv !== undefined && fromEnv !== '')
|
|
79
|
+
return fromEnv;
|
|
75
80
|
const key = targetKey();
|
|
76
81
|
const pkg = platformPackageName();
|
|
77
82
|
if (key === null || pkg === null) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sysce/estrogen",
|
|
3
|
-
"version": "0.5.
|
|
4
|
-
"description": "Post-build web obfuscator. Rewrites a built
|
|
3
|
+
"version": "0.5.5",
|
|
4
|
+
"description": "Post-build web obfuscator in Rust. Rewrites a built directory in place: JavaScript into a per-build bytecode VM, strings into an encrypted pool, and HTML, SVG and wasm names to match.",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "David Reed",
|
|
7
7
|
"repository": {
|
|
@@ -203,16 +203,17 @@
|
|
|
203
203
|
"test:cloak": "npm run build && node --test test/cloak.test.mjs test/cloak-span.test.mjs",
|
|
204
204
|
"test:function-source": "npm run build && node --test test/function-source-warning.test.mjs",
|
|
205
205
|
"test:vendor": "npm run build && node --test test/vendor.test.mjs",
|
|
206
|
+
"test:resolve": "npm run build && node --test test/resolve-binary.test.mjs",
|
|
206
207
|
"test:astro": "npm run build && astro build --root ./test/fixtures/astro && node test/cloak-astro-ssr.mjs",
|
|
207
208
|
"test:browser": "node test/cloak-browser.mjs && node test/cloak-framework-browser.mjs && node test/cloak-astro-browser.mjs && node test/injector-browser.mjs && node test/vm-browser-compat.mjs",
|
|
208
|
-
"
|
|
209
|
+
"prepack": "npm run build && node scripts/readme.mjs"
|
|
209
210
|
},
|
|
210
211
|
"optionalDependencies": {
|
|
211
|
-
"@sysce/estrogen-darwin-arm64": "0.5.
|
|
212
|
-
"@sysce/estrogen-darwin-x64": "0.5.
|
|
213
|
-
"@sysce/estrogen-linux-arm64": "0.5.
|
|
214
|
-
"@sysce/estrogen-linux-x64": "0.5.
|
|
215
|
-
"@sysce/estrogen-win32-x64": "0.5.
|
|
212
|
+
"@sysce/estrogen-darwin-arm64": "0.5.5",
|
|
213
|
+
"@sysce/estrogen-darwin-x64": "0.5.5",
|
|
214
|
+
"@sysce/estrogen-linux-arm64": "0.5.5",
|
|
215
|
+
"@sysce/estrogen-linux-x64": "0.5.5",
|
|
216
|
+
"@sysce/estrogen-win32-x64": "0.5.5"
|
|
216
217
|
},
|
|
217
218
|
"peerDependencies": {
|
|
218
219
|
"@rsbuild/core": "*",
|