jso-protector 0.4.12 → 0.4.14

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 CHANGED
@@ -1,13 +1,23 @@
1
- # jso-protector
1
+ # JavaScript Obfuscator
2
2
 
3
- [![npm version](https://img.shields.io/npm/v/jso-protector.svg)](https://www.npmjs.com/package/jso-protector)
3
+ [![npm version](https://img.shields.io/npm/v/javascriptobfuscator-com.svg)](https://www.npmjs.com/package/javascriptobfuscator-com)
4
4
  [![tests](https://github.com/richtexteditor/jso-protector/actions/workflows/test.yml/badge.svg)](https://github.com/richtexteditor/jso-protector/actions/workflows/test.yml)
5
- [![node](https://img.shields.io/node/v/jso-protector.svg)](https://www.npmjs.com/package/jso-protector)
5
+ [![node](https://img.shields.io/node/v/javascriptobfuscator-com.svg)](https://www.npmjs.com/package/javascriptobfuscator-com)
6
6
 
7
7
  Obfuscate and protect JavaScript as part of your build: a dependency-free CLI,
8
8
  Node API, and plugins for webpack, Vite, Rollup, esbuild, Next.js, Metro, and
9
9
  the rest of the toolchain.
10
10
 
11
+ > **Two package names, one build.** Install **`javascriptobfuscator-com`** - that
12
+ > is the canonical name. `jso-protector` is the original name and publishes the
13
+ > same code, so existing installs keep working. Whichever you install, the CLI is
14
+ > on your PATH as both `javascriptobfuscator` and `jso-protector`.
15
+ >
16
+ > The bare name `javascriptobfuscator` is not available on npm: the registry
17
+ > refuses it as too similar to an existing package, so `npx javascriptobfuscator`
18
+ > only works once the package is installed in the project. Use
19
+ > `npx javascriptobfuscator-com` for a one-off run with nothing installed.
20
+
11
21
  ```bash
12
22
  npm install --save-dev javascriptobfuscator-com
13
23
  npx javascriptobfuscator --input dist --output dist-protected
@@ -56,7 +66,8 @@ and missing parity against common JavaScript obfuscators.
56
66
  - **Evidence you can hand to a reviewer.** `--ai-resistance-evidence`,
57
67
  `--source-map-evidence`, `--vm-proof-pack`, `--deployment-hygiene-evidence`,
58
68
  and `--runtime-incident-evidence` turn a build into a written report.
59
- - **Presets instead of forty switches.** `--preset standard|balanced|maximum`,
69
+ - **Presets instead of forty switches.** `--preset free` runs with no account;
70
+ `standard|balanced|maximum` use paid features and need a paid plan,
60
71
  or import a preset exported from the online tool with `--web-preset`.
61
72
  - **Different profiles in one build.** `namedSets` maps file globs to their own
62
73
  preset and options, so a checkout flow can ship maximum protection while
@@ -159,7 +170,7 @@ jso-protector --config jso.config.json --honor-conditional-comments
159
170
  jso-protector --config jso.config.json --protect-marked-comments
160
171
  jso-protector --config jso.config.json --keep-header-comment --protect-object-declaration --move-nested-function
161
172
  jso-protector --config jso.config.json --formatted-output --keep-indent --line-numbers
162
- jso-protector --preset maximum --input dist --output dist-protected
173
+ jso-protector --preset free --input dist --output dist-protected
163
174
  jso-protector --web-preset javascript-obfuscator-preset.json --dry-run --json
164
175
  jso-protector --stdin --stdout --file-name app.js < dist/app.js > dist/app.protected.js
165
176
  jso-protector --stdin --file-name app.js --output dist-protected < dist/app.js
@@ -977,7 +988,7 @@ Use `preset` to start from a repeatable protection profile:
977
988
 
978
989
  - `standard`: core string encoding, string movement, name replacement, and compression.
979
990
  - `balanced`: standard plus short local names, deep obfuscation, code transposition, string encryption, and flat transform.
980
- - `maximum`: balanced plus member/global renaming, member movement, and low dead-code insertion.
991
+ - `maximum`: balanced plus global renaming, member movement, and low dead-code insertion. No preset renames members; scope that yourself with `--rename-properties --option MemberRegexp=^(yourPrivateName)$`.
981
992
 
982
993
  Override or extend any preset with `options`. The option names are the same names sent to `HttpApi.ashx`, such as `EncodeStrings`, `DeepObfuscate`, `ReorderCode`, `FlatTransform`, `LockDomain`, and `LockDate`.
983
994
 
package/RELEASE.md CHANGED
@@ -65,6 +65,18 @@ disagree. Work in this order:
65
65
  8. **Publish**: `npm publish`. Then install from the registry into a scratch
66
66
  directory and exercise the new behaviour end to end — a green local tree
67
67
  proves the tarball, not the release.
68
+ 9. **Push the public repo.** `github.com/richtexteditor/jso-protector` is the
69
+ source people find from the npm page's repository link, and NOTHING in this
70
+ loop used to update it -- which is the whole reason it drifts. It was at
71
+ 0.4.10 while npm served 0.4.12, and the 0.4.12 release itself widened the
72
+ gap by one because there was no step here to stop it.
73
+
74
+ The second name, `javascriptobfuscator-com`, is published from the same tree
75
+ with only `name` swapped (verified by diffing the two registry manifests:
76
+ `name` is the only field that differs). It has no repo of its own.
77
+
78
+ The push is an outward-facing action on a public surface, so it is a
79
+ deliberate step, not something to fold into `npm publish`.
68
80
 
69
81
  ## What ships in the tarball
70
82
 
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ // Local, non-executing comparison. Hashes identify artifacts without exposing source.
4
+ const fs = require('node:fs');
5
+ const zlib = require('node:zlib');
6
+ const crypto = require('node:crypto');
7
+ function measure(file) {
8
+ const data = fs.readFileSync(file);
9
+ return { bytes: data.length, gzipBytes: zlib.gzipSync(data, { level: 9 }).length,
10
+ sha256: crypto.createHash('sha256').update(data).digest('hex') };
11
+ }
12
+ function compare(original, candidates, maxGzipRatio) {
13
+ if (!candidates.length) throw new Error('At least one protected artifact is required.');
14
+ if (maxGzipRatio !== undefined && (!Number.isFinite(maxGzipRatio) || maxGzipRatio <= 0))
15
+ throw new Error('max-gzip-ratio must be a finite positive number.');
16
+ const baseline = measure(original);
17
+ if (!baseline.bytes) throw new Error('Original artifact must not be empty.');
18
+ const results = candidates.map((file, index) => {
19
+ const value = measure(file);
20
+ if (!value.bytes) throw new Error('Candidate artifact must not be empty.');
21
+ const gzipRatio = value.gzipBytes / baseline.gzipBytes;
22
+ return { candidate: index + 1, ...value, byteRatio: value.bytes / baseline.bytes, gzipRatio,
23
+ budgetPassed: maxGzipRatio === undefined ? null : gzipRatio <= maxGzipRatio };
24
+ });
25
+ return { schemaVersion: 1, nodeVersion: process.version, zlibVersion: process.versions.zlib,
26
+ baseline, maxGzipRatio: maxGzipRatio === undefined ? null : maxGzipRatio, results,
27
+ limitations: 'Size only: no code execution, compatibility test, runtime benchmark or protection-strength score. Compare equivalent inputs and record each vendor version and configuration separately.' };
28
+ }
29
+ module.exports = { compare };
30
+ if (require.main === module) {
31
+ try {
32
+ const args = process.argv.slice(2);
33
+ let budget;
34
+ const index = args.indexOf('--max-gzip-ratio');
35
+ if (index !== -1) {
36
+ if (index + 1 >= args.length) throw new Error('Missing max-gzip-ratio value.');
37
+ budget = Number(args[index + 1]); args.splice(index, 2);
38
+ }
39
+ if (args.length < 2 || args.some(a => a.startsWith('--')))
40
+ throw new Error('Usage: node bin/compare-builds.js original.js protected.js [other.js ...] [--max-gzip-ratio 2]');
41
+ const report = compare(args[0], args.slice(1), budget);
42
+ process.stdout.write(JSON.stringify(report, null, 2) + '\n');
43
+ if (report.results.some(r => r.budgetPassed === false)) process.exitCode = 2;
44
+ } catch (error) { process.stderr.write(error.message + '\n'); process.exitCode = 1; }
45
+ }
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ const { spawnSync } = require('node:child_process');
4
+ const { performance } = require('node:perf_hooks');
5
+ const crypto = require('node:crypto');
6
+ const fs = require('node:fs');
7
+ const path = require('node:path');
8
+ const hash = value => crypto.createHash('sha256').update(value).digest('hex');
9
+ function sample(file, timeout) {
10
+ const start = performance.now();
11
+ const run = spawnSync(process.execPath, [path.resolve(file)], {
12
+ encoding: 'utf8', timeout, maxBuffer: 1024 * 1024, windowsHide: true,
13
+ env: { ...process.env, NODE_OPTIONS: '' }
14
+ });
15
+ return { milliseconds: performance.now() - start, status: run.status,
16
+ error: run.error ? run.error.code : null, signal: run.signal,
17
+ stdoutHash: hash(run.stdout || ''), stderrHash: hash(run.stderr || '') };
18
+ }
19
+ function compareRuntime(original, candidate, { runs = 3, timeout = 5000 } = {}) {
20
+ if (!Number.isInteger(runs) || runs < 2 || runs > 20) throw new Error('runs must be 2..20');
21
+ if (!Number.isInteger(timeout) || timeout < 1 || timeout > 60000) throw new Error('timeout must be 1..60000 ms');
22
+ const ids = [original, candidate].map(f => hash(fs.readFileSync(f)));
23
+ const baseline = [], protectedRuns = [];
24
+ // Alternate ordering to reduce systematic cold-start bias.
25
+ for (let i = 0; i < runs; i++) {
26
+ if (i % 2) { protectedRuns.push(sample(candidate, timeout)); baseline.push(sample(original, timeout)); }
27
+ else { baseline.push(sample(original, timeout)); protectedRuns.push(sample(candidate, timeout)); }
28
+ }
29
+ const signature = r => `${r.stdoutHash}:${r.stderrHash}`;
30
+ const successful = r => r.status === 0 && !r.error && !r.signal;
31
+ const baselineValid = baseline.every(successful) && baseline.every(r => signature(r) === signature(baseline[0]));
32
+ const matched = baselineValid && protectedRuns.every(r => successful(r) && signature(r) === signature(baseline[0]));
33
+ const median = values => { const v = values.map(r => r.milliseconds).sort((a,b) => a-b); return (v[Math.floor((v.length-1)/2)] + v[Math.floor(v.length/2)]) / 2; };
34
+ return { schemaVersion: 1, nodeVersion: process.version, platform: process.platform,
35
+ originalHash: ids[0], candidateHash: ids[1], baselineValid, matched,
36
+ medianProcessTimeRatio: matched ? median(protectedRuns) / median(baseline) : null,
37
+ baseline, candidate: protectedRuns,
38
+ limitations: 'Trusted code only; child processes are NOT a security sandbox. Measures Node process startup plus script execution. Exact stdout/stderr matching is not full semantic equivalence, browser compatibility or a security score.' };
39
+ }
40
+ module.exports = { compareRuntime };
41
+ if (require.main === module) {
42
+ try {
43
+ const args = process.argv.slice(2);
44
+ if (args.length !== 3 || args[0] !== '--trusted-code') throw new Error('Usage: node bin/compare-runtime.js --trusted-code original.js protected.js');
45
+ const report = compareRuntime(args[1], args[2]);
46
+ process.stdout.write(JSON.stringify(report, null, 2) + '\n');
47
+ if (!report.baselineValid || !report.matched) process.exitCode = 2;
48
+ } catch (error) { process.stderr.write(error.message + '\n'); process.exitCode = 1; }
49
+ }
@@ -64,7 +64,10 @@ const PRESET_OPTIONS = {
64
64
  MoveStrings: true,
65
65
  ReplaceNames: true,
66
66
  RenameGlobals: true,
67
- RenameMembers: true,
67
+ // No RenameMembers: the engine refuses it without a MemberRegexp or
68
+ // MemberMapping, and no pattern is safe for code a preset has never seen
69
+ // (it renames the member everywhere it appears -- DOM, JSON, library
70
+ // calls). With it here, every maximum run failed before touching a file.
68
71
  MoveMembers: true,
69
72
  SelfCompression: true,
70
73
  SelfCompressionMinSize: 0,
@@ -467,7 +470,7 @@ const OPTION_REFERENCE = [
467
470
  { name: "DeadcodeLevel", type: "enum", values: ["Low", "Medium", "High"], category: "control-flow", description: "Dead-code insertion level." },
468
471
  { name: "OptimizationMode", type: "enum", values: ["Auto", "Web", "Html5", "Game", "Mobile", "NodeJS"], category: "runtime", description: "Runtime optimization target." },
469
472
  { name: "TargetVersion", type: "enum", values: ["es5", "modern"], category: "output", description: "Output syntax target. es5 (default) down-levels ES2015+ syntax for legacy browsers; modern keeps classes, arrows, destructuring and native for-of. Do not use modern if you must support pre-ES2015 browsers." },
470
- { name: "DownlevelIteration", type: "boolean", category: "output", description: "Spec-faithful ES5 for-of lowering: iterables are stepped lazily and iterator return() runs on break/throw, like TypeScript's downlevelIteration. Off by default because it adds a per-step call on arrays; no effect when TargetVersion is modern." },
473
+ { name: "DownlevelIteration", type: "boolean", category: "output", description: "Spec-faithful ES5 for-of lowering: iterables are stepped lazily and iterator return() runs on break/throw, like TypeScript's downlevelIteration. ON by default for correctness; pass False to restore legacy eager iteration, which drains an iterable before the loop body runs. No effect when TargetVersion is modern." },
471
474
  { name: "WriteFormats", type: "boolean", category: "formatting", description: "Write formatted output for debugging." },
472
475
  { name: "WriteFormats_KeepIndent", type: "boolean", category: "formatting", description: "Keep indentation when formatted output is enabled." },
473
476
  { name: "WriteFormats_LineNumbers", type: "boolean", category: "formatting", description: "Add line numbers when formatted output is enabled." },
@@ -4456,7 +4459,20 @@ function hasHtmlProtectionMarkers(filePath) {
4456
4459
  return hasMarkedHtmlScriptAttributes(fs.readFileSync(filePath, "utf8"));
4457
4460
  }
4458
4461
 
4462
+ // The engine refuses RenameMembers without a pattern saying WHICH members to
4463
+ // rename ("Please specify regexp or custom mapping for 'Protect Members'"),
4464
+ // and the server returns that as an ordinary option error it never logs. Say
4465
+ // it here, before any source is uploaded, with the fix in the message.
4466
+ function findUnscopedMemberRename(options = {}) {
4467
+ const on = options.RenameMembers === true || /^true$/i.test(String(options.RenameMembers));
4468
+ if (!on) return null;
4469
+ const scoped = ["MemberRegexp", "MemberMapping"].some((name) => String(options[name] || "").trim() !== "");
4470
+ return scoped ? null : "RenameMembers needs MemberRegexp or MemberMapping to say which members to rename. Add --option MemberRegexp=^(myPrivateName|otherName)$ (anchor it to your own member names), or turn it off with --option RenameMembers=false.";
4471
+ }
4472
+
4459
4473
  function buildRequestFromItems(config, items) {
4474
+ const unscoped = findUnscopedMemberRename(config.options);
4475
+ if (unscoped) throw new Error(unscoped);
4460
4476
  const project = {
4461
4477
  APIKey: config.apiKey,
4462
4478
  APIPwd: config.apiPassword,
@@ -4473,7 +4489,14 @@ function buildRequestFromItems(config, items) {
4473
4489
  }
4474
4490
 
4475
4491
  for (const [key, value] of Object.entries(config.options)) {
4476
- if (value !== undefined && value !== null && value !== false) {
4492
+ // `false` is TRANSMITTED, not dropped. Every option used to default off, so
4493
+ // omitting a false was equivalent to sending it -- that stopped being true
4494
+ // when DownlevelIteration became ON by default: the engine reads it as
4495
+ // enabled unless it receives an explicit "False", so the old filter made
4496
+ // `--option DownlevelIteration=False` a silent no-op that returned 200 and
4497
+ // quietly ignored what the caller asked for. For every option that defaults
4498
+ // off, sending false is identical to omitting it.
4499
+ if (value !== undefined && value !== null) {
4477
4500
  project[key] = value;
4478
4501
  }
4479
4502
  }
@@ -4657,6 +4680,18 @@ function apiFailureHint(details = {}) {
4657
4680
  // so a keyless first run was told to "check account status, plan limits,
4658
4681
  // credits, or subscription state" for a quota no account would fix.
4659
4682
  if (details.status === 429) return "";
4683
+
4684
+ // Same reasoning, second case: a PLAN REFUSAL from the server already names
4685
+ // the feature, the plan that covers it, the upgrade URL, and - since
4686
+ // 2026-09-05 - how to keep working without the option on the current plan.
4687
+ // Appending "check account status, plan limits, credits, or subscription
4688
+ // state" after that tells a reader who has just been told exactly what to do
4689
+ // to go and look for something vague instead.
4690
+ //
4691
+ // Detected by the upgrade link rather than by the wording, because the
4692
+ // wording varies per feature while every plan refusal built by
4693
+ // Plans.cs carries that URL.
4694
+ if (/premium-membership\.aspx/.test(details.message || "")) return "";
4660
4695
  const text = `${details.status || ""} ${details.type || ""} ${details.message || ""}`.toLowerCase();
4661
4696
  if (/payment|paid|plan|subscription|credit|quota|limit|expired|billing|over[- ]?limit/.test(text)) {
4662
4697
  return "Paid API access is enforced by the hosted API; check account status, plan limits, credits, or subscription state.";
@@ -7170,6 +7205,8 @@ function validateProtectionConfig(config, args = {}) {
7170
7205
  addValidationCheck(checks, "apiPassword", resolved.apiPassword ? "ok" : "error", resolved.apiPassword ? "API password is present." : "Missing API password. Run `javascriptobfuscator login` to sign in and save credentials, or copy it from https://javascriptobfuscator.com/dashboard/APIKeys.aspx?src=cli-nopwd and set JSO_API_PASSWORD.");
7171
7206
  addCredentialStorageValidation(checks, config, args);
7172
7207
  addValidationCheck(checks, "preset", "ok", `Preset: ${resolved.preset}`);
7208
+ const unscopedMemberRename = findUnscopedMemberRename(resolved.options);
7209
+ if (unscopedMemberRename) addValidationCheck(checks, "memberRename", "error", unscopedMemberRename);
7173
7210
  addValidationCheck(checks, "paths", resolved.input && resolved.output ? "ok" : "error", resolved.input && resolved.output ? "Input and output paths are configured." : "Input and output paths must be configured.");
7174
7211
 
7175
7212
  if (resolved.input && !fs.existsSync(resolved.input)) {
@@ -12743,6 +12780,7 @@ module.exports = {
12743
12780
  DEFAULT_ENDPOINT,
12744
12781
  OPTION_REFERENCE,
12745
12782
  PRESET_OPTIONS,
12783
+ findUnscopedMemberRename,
12746
12784
  buildMigrationMapSummary,
12747
12785
  buildMigrationNextCommands,
12748
12786
  buildMigrationReportSummary,
package/ci/README.md ADDED
@@ -0,0 +1,57 @@
1
+ # Protected GitHub releases
2
+
3
+ Start with `github-actions.yml`: build, protect through the hosted API, test the
4
+ protected application, verify its manifest and source-map policy, then upload.
5
+ It is manually triggered and does not deploy or publish anything automatically.
6
+
7
+ ## Setup
8
+
9
+ 1. Install `javascriptobfuscator-com` as an exact dev dependency using
10
+ `npm install --save-dev --save-exact javascriptobfuscator-com`. Commit the
11
+ package manifest and lockfile. The package supplies the `jso-protector` binary;
12
+ the workflow uses that installed binary, never an implicit `npx` download.
13
+ 2. Copy `jso.config.example.json` to your project as `jso.config.json`. Set
14
+ `input` to `dist` and `output` to `dist-protected` for this template, or update
15
+ every workflow path together. Select first-party chunks explicitly. Review
16
+ exclusions: excluded JavaScript may be copied unchanged as an asset.
17
+ 3. Store `JSO_API_KEY` and `JSO_API_PASSWORD` as GitHub Actions secrets for the
18
+ paid/evaluation account you intend to use. Never put credentials in config.
19
+ 4. Define `build` and `smoke:protected` scripts in your project's `package.json`.
20
+ The latter must serve/import `dist-protected`, not `dist` or a development
21
+ server. It receives `JSO_PROTECTED_DIR=dist-protected`. For a browser app,
22
+ exercise startup, navigation, lazy chunks and important public APIs with
23
+ your existing browser test runner. Do not rebuild during this smoke test.
24
+ 5. Copy `github-actions.yml` to `.github/workflows/protected-release.yml` and
25
+ trigger it with Actions > protected-release > Run workflow.
26
+
27
+ The workflow stops on missing credentials, missing smoke script, API errors,
28
+ smoke failures, manifest mismatches, exposed source maps or missing artifacts.
29
+ Verification runs after smoke tests so tests cannot silently modify protected
30
+ files before upload. Manifest verification proves integrity, not application
31
+ correctness or that every copied vendor file was obfuscated.
32
+
33
+ ## Deployment and operations
34
+
35
+ Deploy only the successful `protected-dist` artifact. Do not fall back to `dist`
36
+ or use `continue-on-error` on protection/testing steps. Add your deployment step
37
+ after verification, or use a dependent job that downloads this exact artifact.
38
+ Pin third-party Actions to reviewed commit SHAs for production use.
39
+
40
+ The job is capped at 20 minutes and protection at 10 minutes. There is no blanket
41
+ retry: after an ambiguous network failure, inspect account usage before rerunning
42
+ because a request may already have consumed quota. This template does not claim
43
+ idempotent billing or automatic quota reconciliation.
44
+
45
+ This is hosted protection: selected source files leave the runner. Confirm the
46
+ service's current retention policy before uploading proprietary code. Do not
47
+ cache credentials or uploaded source. The artifact contains the report and
48
+ manifest; restrict artifact access and review those files before sharing them.
49
+ GitHub retains this template's artifacts for seven days.
50
+
51
+ If protection succeeds but the application fails, inspect the protected-build
52
+ test failure and reduce risky rename/transform settings. If authentication or
53
+ quota fails, verify that the API key belongs to the intended account; payment
54
+ email and application account email need not match.
55
+
56
+ References: [workflow permissions and timeouts](https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax),
57
+ [artifact upload failure behavior](https://github.com/actions/upload-artifact).
@@ -39,7 +39,7 @@ published as `javascriptobfuscator-com`; `jso-protector` is the former name and
39
39
  is deprecated but still updated:
40
40
 
41
41
  ```bash
42
- npm install --save-dev javascriptobfuscator-com@0.4.12
42
+ npm install --save-dev javascriptobfuscator-com@0.4.13
43
43
  ```
44
44
 
45
45
  Repository contributors can instead use the existing `file:../..` development
@@ -0,0 +1,68 @@
1
+ # A protected JavaScript release with GitHub Actions
2
+
3
+ This small, inspectable project builds an HTML page and a JavaScript public API,
4
+ protects them with the hosted service, tests the protected output, then checks
5
+ artifact hashes and source-map absence. It is a starting point, not a benchmark.
6
+
7
+ ## Run from this repository
8
+
9
+ Use Node.js 22 and run these commands inside this directory:
10
+
11
+ ```sh
12
+ npm install
13
+ npm run build
14
+ npm run preflight
15
+ ```
16
+
17
+ The local dependency points to the CLI two directories above. These steps build
18
+ and inspect the sample without calling the protection API. Preflight may report
19
+ missing credentials before you configure them.
20
+
21
+ Set `JSO_API_KEY` and `JSO_API_PASSWORD` using credentials for your own account,
22
+ then run `npm run release`. The balanced preset requires an eligible paid plan
23
+ and allowance. Selected JavaScript is uploaded to the hosted service. Do not
24
+ put credentials in source files, shell transcripts or screenshots.
25
+
26
+ ## Publish your own example repository
27
+
28
+ Copy this example's files into a repository you control. Replace the local
29
+ `jso-protector` dependency in package.json with the public package:
30
+
31
+ ```sh
32
+ npm pkg delete devDependencies.jso-protector
33
+ npm install --save-dev --save-exact javascriptobfuscator-com
34
+ ```
35
+
36
+ Remove the repository-relative `$schema` field from jso.config.json, or point it
37
+ to `./node_modules/javascriptobfuscator-com/jso.config.schema.json`. Commit
38
+ package.json and package-lock.json. Ignore node_modules, dist and dist-protected.
39
+
40
+ Download the workflow from the
41
+ [GitHub Actions generator](https://javascriptobfuscator.com/docs/npmcli.aspx#ci-generator)
42
+ and place it at `.github/workflows/protected-release.yml`. Keep this example's
43
+ config, which reserves its public API names. Add the two API credentials as
44
+ GitHub Actions secrets. Trigger **protected-release** manually in Actions.
45
+
46
+ The workflow uploads an artifact only after protection, smoke tests and hash
47
+ verification succeed. It does not deploy. Use its protected artifact as the
48
+ input to a separate deployment step, never the original dist directory.
49
+
50
+ ## What the smoke test proves
51
+
52
+ It reads only dist-protected, checks the HTML script reference, executes the
53
+ trusted build output in Node with a minimal window global, and calls the public
54
+ API. Missing output, renamed/missing APIs, exceptions and wrong results fail.
55
+ The test intentionally does not load dist when protected output is absent.
56
+
57
+ This is not a real browser test. For a production app add browser tests for DOM
58
+ behavior, lazy routes, storage, network requests and target browsers. Do not
59
+ reuse node:vm to execute untrusted uploads; it is not a security boundary.
60
+
61
+ ## Troubleshooting
62
+
63
+ - Missing artifact: fix protection; do not weaken the smoke test or deploy dist.
64
+ - Public API missing: review reservedNames and test your integration contracts.
65
+ - Authentication/allowance error: confirm the key belongs to the intended account.
66
+ - Source-map audit fails: remove release maps and stale sourceMappingURL comments.
67
+ - A workflow retry may consume allowance again. Inspect usage after ambiguous
68
+ network errors rather than automatically retrying the entire protection job.
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ const assert = require("node:assert/strict");
4
+ const fs = require("node:fs");
5
+ const path = require("node:path");
6
+ const vm = require("node:vm");
7
+
8
+ // Never fall back to dist: a missing protected artifact must fail the release.
9
+ const root = path.resolve(__dirname, "..", "dist-protected");
10
+ const html = fs.readFileSync(path.join(root, "index.html"), "utf8");
11
+ assert.match(html, /<script\s+src="app\.js"><\/script>/);
12
+ const code = fs.readFileSync(path.join(root, "app.js"), "utf8");
13
+ assert.ok(code.trim(), "Protected JavaScript must not be empty");
14
+ const messages = [];
15
+ const context = vm.createContext({ console: { log: message => messages.push(message) } });
16
+ // This fixture tests trusted build output; node:vm is not a security sandbox.
17
+ vm.runInContext("window = globalThis;", context, { timeout: 1000 });
18
+ vm.runInContext(code, context, { timeout: 5000, filename: "protected-app.js" });
19
+ vm.runInContext("if (typeof PublicApi.renderWidget !== 'function') throw new Error('Public API missing'); PublicApi.renderWidget();", context, { timeout: 1000 });
20
+ assert.deepEqual(messages, ["release"], "Protected public API must preserve its behavior");
21
+ console.log("Protected artifact smoke passed: HTML entry and PublicApi.renderWidget");
@@ -0,0 +1,25 @@
1
+ # Compare protected artifact sizes locally
2
+
3
+ ## Optional runtime comparison for trusted Node scripts
4
+
5
+ ```sh
6
+ node bin/compare-runtime.js --trusted-code original.cjs protected.cjs
7
+ ```
8
+
9
+ This executes both scripts three times in separate Node processes, alternates order, compares exact stdout/stderr hashes and reports a median process-time ratio only when the baseline is stable and every candidate run matches. Nonzero exits, timeouts or mismatches fail with exit code 2; input errors use 1. Output capture is limited to 1 MiB and each run has a five-second timeout. Reports contain hashes rather than raw script output.
10
+
11
+ **Not a security sandbox:** run only reviewed code you trust. Scripts inherit your user privileges, environment and working directory and may access files or networks. Use disposable isolated environments for unfamiliar vendor output. A timeout is not process-tree isolation. Timing includes Node startup, so it is unsuitable as a browser performance claim or a precise microbenchmark. Exact output agreement covers only the exercised behavior; add real application assertions. Empty-output scripts can match without exercising useful behavior.
12
+
13
+ Record vendor/version/preset separately. The supplied equivalent/broken test fixtures test the harness, not any vendor's obfuscation quality. Run the harness regression suite with `npm run test:evaluation` from the package directory.
14
+
15
+ From the package directory:
16
+
17
+ ```sh
18
+ node bin/compare-builds.js original.js jso-output.js competitor-output.js --max-gzip-ratio 2
19
+ ```
20
+
21
+ Reports raw bytes, gzip level-9 bytes, ratios and SHA-256 identities as JSON. Candidates are identified by their argument order; source contents and file paths are not included in the report. No code is executed or uploaded. Exit codes: 0 comparison complete/budget passed, 2 budget exceeded, 1 invalid input or file error.
22
+
23
+ Use the same original input and record the vendor version, edition and configuration alongside the report. A gzip ratio of 2 allows twice the baseline gzip size. Budgets are your project policy, not a security score. Node/zlib versions are recorded because compression results can vary across runtimes.
24
+
25
+ This does not check application behavior, browser compatibility, latency, source maps or protection strength. Run your normal application tests against each protected build before release. Do not publish private source maps or secret-bearing configuration with your comparison.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jso-protector",
3
- "version": "0.4.12",
3
+ "version": "0.4.14",
4
4
  "description": "Obfuscate and protect JavaScript in your build or CI: dependency-free CLI, Node API, and webpack/Vite/Rollup/esbuild/Next.js/Metro plugins, with one-command migration from javascript-obfuscator and JS-Confuser configs.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "author": "JavaScript Obfuscator",
@@ -225,7 +225,7 @@
225
225
  "smoke": "node ./bin/jso-protector.js --help && node ./bin/jso-protector.js --config ./jso.config.example.json --dry-run --json",
226
226
  "smoke:api": "node ./bin/jso-protector.js --config ./jso.config.example.json --json",
227
227
  "test": "node ./test/cli.test.js && node ./test/ai.test.js && node ./test/ai-precheck.test.js && node ./test/ai-script-governance.test.js && node ./test/data-exfiltration-guard.test.js && node ./test/compat-scan.test.js && node ./test/compliance.test.js && node ./test/evidence-forwarder.test.js && node ./test/config-schema.test.js && node ./test/countermeasures.test.js && node ./test/environment-integrity.test.js && node ./test/estimate.test.js && node ./test/github-action.test.js && node ./test/governance.test.js && node ./test/local-bridge.test.js && node ./test/managed-integrity.test.js && node ./test/named-sets.test.js && node ./test/release-signer.test.js && node ./test/scan-watermarks.test.js && node ./test/third-party-inventory.test.js && node ./test/watermark.test.js && node ./test/wire-format-vectors.test.js",
228
- "verify": "npm test && npm run verify:package && npm run verify:examples && npm run verify:publish-metadata && npm run verify:ci && npm run verify:polyglot && npm run verify:ai && npm run verify:verify-scripts-tracked && npm run verify:aspnet-bom && npm run verify:aspnet-compile && npm run verify:endrequest-guard && npm run verify:health-readiness && npm run verify:legacy-soap-security && npm run verify:online-demo-security && npm run verify:parser-engine && npm run verify:emit-validation && npm run verify:emit-validation-modern && npm run verify:runtime-defense-libraries && npm run verify:internal-links && npm run verify:seo && npm run verify:sitemap-freshness && npm run verify:faq-visibility && npm run verify:artifact-claims && npm run verify:runtime-dashboard && npm run verify:plan-numbers && npm run verify:payment-page && npm run verify:payment-activation && npm run verify:payment-row-completeness && npm run verify:account-recovery && npm run verify:registration && npm run verify:admin-auth && npm run verify:http-api-auth && npm run verify:request-body-limits && npm run verify:public-form-security && npm run verify:operational-logs && npm run verify:richtexteditor-surface && npm run verify:dashboard-resource-governance && npm run verify:dashboard-diagnostic-surface && npm run verify:web-integrity-policy && npm run verify:entitlements && npm run verify:enterprise-governance && npm run verify:database-migrations && npm run verify:source-secrets && npm run verify:ignored-shipping-secrets && npm run verify:winforms-runtime-floor && npm run verify:ai-billing && npm run verify:ai-key-security && npm run verify:ajax-transport && npm run verify:competitor-gap && npm run verify:parity-defect-sync && npm run verify:source-map-evidence && npm run verify:migration-review && npm run verify:identifier-cache-review && npm run verify:runtime-defense-review && npm run verify:vm-proof && npm run verify:deployment-hygiene && npm run verify:download-artifacts && npm run verify:download-examples && npm run verify:copy-discipline && npm run verify:github-action && npm run verify:outbound-nofollow",
228
+ "verify": "npm test && npm run verify:package && npm run verify:examples && npm run verify:publish-metadata && npm run verify:ci && npm run verify:polyglot && npm run verify:ai && npm run verify:verify-scripts-tracked && npm run verify:aspnet-bom && npm run verify:aspnet-compile && npm run verify:endrequest-guard && npm run verify:analysis-pattern-bounds && npm run verify:health-readiness && npm run verify:legacy-soap-security && npm run verify:online-demo-security && npm run verify:parser-engine && npm run verify:emit-validation && npm run verify:es5-syntax && npm run verify:emit-validation-modern && npm run verify:runtime-defense-libraries && npm run verify:internal-links && npm run verify:seo && npm run verify:sitemap-freshness && npm run verify:changelog-freshness && npm run verify:faq-visibility && npm run verify:artifact-claims && npm run verify:runtime-dashboard && npm run verify:plan-numbers && npm run verify:payment-page && npm run verify:payment-activation && npm run verify:payment-row-completeness && npm run verify:account-recovery && npm run verify:registration && npm run verify:admin-auth && npm run verify:http-api-auth && npm run verify:request-body-limits && npm run verify:public-form-security && npm run verify:operational-logs && npm run verify:richtexteditor-surface && npm run verify:dashboard-resource-governance && npm run verify:dashboard-diagnostic-surface && npm run verify:web-integrity-policy && npm run verify:entitlements && npm run verify:enterprise-governance && npm run verify:database-migrations && npm run verify:source-secrets && npm run verify:published-artifact-secrets && npm run verify:ignored-shipping-secrets && npm run verify:winforms-runtime-floor && npm run verify:ai-billing && npm run verify:ai-key-security && npm run verify:ajax-transport && npm run verify:competitor-gap && npm run verify:parity-defect-sync && npm run verify:source-map-evidence && npm run verify:migration-review && npm run verify:identifier-cache-review && npm run verify:runtime-defense-review && npm run verify:vm-proof && npm run verify:deployment-hygiene && npm run verify:download-artifacts && npm run verify:download-examples && npm run verify:copy-discipline && npm run verify:github-action && npm run verify:outbound-nofollow",
229
229
  "verify:release": "npm run verify && npm run verify:corpus-protect && npm run verify:corpus-runtime",
230
230
  "verify:verify-scripts-tracked": "node ../polyglot-smoke/check-verify-scripts-tracked.js",
231
231
  "verify:parity-defect-sync": "node ../polyglot-smoke/check-parity-defect-sync.js",
@@ -233,6 +233,7 @@
233
233
  "verify:aspnet-compile": "node ../polyglot-smoke/check-aspnet-compile.js",
234
234
  "verify:endrequest-guard": "node ../polyglot-smoke/check-endrequest-guard.js",
235
235
  "verify:payment-row-completeness": "node ../polyglot-smoke/check-payment-row-completeness.js",
236
+ "verify:analysis-pattern-bounds": "node ../polyglot-smoke/check-analysis-pattern-bounds.js",
236
237
  "verify:health-readiness": "node ../polyglot-smoke/check-health-readiness.js",
237
238
  "verify:live-health": "node ../polyglot-smoke/check-production-health.js",
238
239
  "verify:live-seo": "node ../polyglot-smoke/check-live-seo.js",
@@ -243,11 +244,14 @@
243
244
  "verify:package-behaviour": "bash ../../tools/verify-package-behaviour.sh",
244
245
  "verify:emit-validation": "node ../../tools/emit-validation/run.js",
245
246
  "verify:emit-validation-modern": "node ../../tools/emit-validation/run.js modern",
247
+ "verify:es5-syntax": "node ../../tools/es5-syntax-gate/run.js",
246
248
  "verify:corpus-protect": "node ../../tools/corpus-protect/run.js",
247
249
  "verify:corpus-runtime": "node ../../tools/corpus-protect/runtime-smoke.js",
248
250
  "verify:runtime-defense-libraries": "node ../../tools/corpus-protect/runtime-defense-libraries.js",
249
251
  "verify:internal-links": "node ../polyglot-smoke/check-internal-links.js",
250
252
  "verify:seo": "node ../polyglot-smoke/check-public-seo.js",
253
+ "verify:live-changelog": "node ../polyglot-smoke/check-changelog-freshness.js --live",
254
+ "verify:changelog-freshness": "node ../polyglot-smoke/check-changelog-freshness.js",
251
255
  "verify:sitemap-freshness": "node ../polyglot-smoke/check-sitemap-freshness.js",
252
256
  "verify:plan-numbers": "node ../polyglot-smoke/check-plan-numbers.js",
253
257
  "verify:faq-visibility": "node ../polyglot-smoke/check-faq-visibility.js",
@@ -270,6 +274,7 @@
270
274
  "verify:entitlements": "node ../polyglot-smoke/check-entitlement-consistency.js",
271
275
  "verify:enterprise-governance": "node ../polyglot-smoke/check-enterprise-governance-security.js",
272
276
  "verify:database-migrations": "node ../polyglot-smoke/check-database-migration-drift.js",
277
+ "verify:published-artifact-secrets": "node ../polyglot-smoke/check-published-artifact-secrets.js",
273
278
  "verify:source-secrets": "node ../polyglot-smoke/check-source-secret-discipline.js",
274
279
  "verify:ignored-shipping-secrets": "node ../polyglot-smoke/check-ignored-shipping-secrets.js",
275
280
  "verify:winforms-runtime-floor": "node ../polyglot-smoke/check-winforms-runtime-floor.js",
@@ -299,7 +304,7 @@
299
304
  "verify:polyglot": "node ../polyglot-smoke/smoke.js",
300
305
  "verify:ai": "node ../polyglot-smoke/ai-smoke.js",
301
306
  "verify:ai-live": "node ../polyglot-smoke/ai-smoke-live.js",
302
- "prepublishOnly": "node ./ci/verify-publish-metadata.js && npm run verify:package && npm run verify:examples && npm run verify:ci && npm run verify:polyglot && npm run verify:ai",
307
+ "prepublishOnly": "node ./ci/verify-publish-metadata.js && npm run verify:published-artifact-secrets && npm run verify:package && npm run verify:examples && npm run verify:ci && npm run verify:polyglot && npm run verify:ai",
303
308
  "verify:outbound-nofollow": "node ../polyglot-smoke/check-outbound-nofollow.js"
304
309
  },
305
310
  "engines": {