jso-protector 0.4.13 → 0.4.15

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/CHANGELOG.md CHANGED
@@ -1,5 +1,47 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.15 - 2026-09-24
4
+
5
+ **`--preset standard` works on the Basic and Corporate plans.** It was refused
6
+ for everyone below Enterprise.
7
+
8
+ - `standard`, `balanced` and `maximum` asked for compression ratio `Best`,
9
+ which is an Enterprise feature, so any compressing preset was refused on
10
+ Basic and Corporate with "'compression ratio best' requires Enterprise
11
+ membership" -- before a single file was protected. The presets now ask for
12
+ `Auto`, which gives each plan its own strongest ratio: Basic Medium,
13
+ Corporate High, Enterprise Best. Enterprise output is unchanged.
14
+ - The same fix applies to the defaults this package picks when it translates
15
+ another tool's `compact`, `minify` or `stringCompression` settings.
16
+ - An explicit `--option CompressionRatio=Best` is still sent exactly as written.
17
+ - `balanced` and `maximum` include Enterprise-only transforms (string
18
+ encryption, control-flow flattening), so they still need Enterprise; the
19
+ README and docs now say so instead of "a paid plan".
20
+
21
+ ## 0.4.14 - 2026-09-23
22
+
23
+ **`--preset maximum` works.** Every run of it was refused before a single file
24
+ was protected.
25
+
26
+ - The preset turned on member renaming (`RenameMembers`) without saying which
27
+ members to rename. The engine refuses that combination - "Please specify
28
+ regexp or custom mapping for 'Protect Members'" - so `maximum`, and every
29
+ `javascript-obfuscator` preset this package maps onto it (`high-obfuscation`,
30
+ the `vm-*` presets), failed on every file. `maximum` no longer includes member
31
+ renaming. Everything else in it is unchanged: global renaming, member movement,
32
+ string encryption, control-flow flattening, dead code and compression.
33
+ - No preset can choose member names safely. Renaming a member renames it
34
+ everywhere it appears, including names your code hands to the DOM, to JSON
35
+ or to a library, and names it returns as data. Member renaming stays
36
+ available when you scope it: `--rename-properties --option
37
+ MemberRegexp=^(yourPrivateName|other)$`.
38
+ - Asking for member renaming without a `MemberRegexp` or `MemberMapping` (via
39
+ `--rename-properties`, `--option RenameMembers=true`, or a migrated
40
+ `renameProperties: true`) now fails on your machine, before any source is
41
+ uploaded, with a message that names the fix. `--validate-config` and
42
+ `--release-check` report it too. Previously the server refused it after the
43
+ upload.
44
+
3
45
  ## 0.4.13 - 2026-09-06
4
46
 
5
47
  A plan refusal no longer ends with advice that contradicts it.
package/README.md CHANGED
@@ -66,7 +66,9 @@ and missing parity against common JavaScript obfuscators.
66
66
  - **Evidence you can hand to a reviewer.** `--ai-resistance-evidence`,
67
67
  `--source-map-evidence`, `--vm-proof-pack`, `--deployment-hygiene-evidence`,
68
68
  and `--runtime-incident-evidence` turn a build into a written report.
69
- - **Presets instead of forty switches.** `--preset standard|balanced|maximum`,
69
+ - **Presets instead of forty switches.** `--preset free` runs with no account;
70
+ `standard` needs Basic or higher; `balanced|maximum` include Enterprise-only
71
+ transforms (EncryptStrings, FlatTransform) and need Enterprise,
70
72
  or import a preset exported from the online tool with `--web-preset`.
71
73
  - **Different profiles in one build.** `namedSets` maps file globs to their own
72
74
  preset and options, so a checkout flow can ship maximum protection while
@@ -169,7 +171,7 @@ jso-protector --config jso.config.json --honor-conditional-comments
169
171
  jso-protector --config jso.config.json --protect-marked-comments
170
172
  jso-protector --config jso.config.json --keep-header-comment --protect-object-declaration --move-nested-function
171
173
  jso-protector --config jso.config.json --formatted-output --keep-indent --line-numbers
172
- jso-protector --preset maximum --input dist --output dist-protected
174
+ jso-protector --preset free --input dist --output dist-protected
173
175
  jso-protector --web-preset javascript-obfuscator-preset.json --dry-run --json
174
176
  jso-protector --stdin --stdout --file-name app.js < dist/app.js > dist/app.protected.js
175
177
  jso-protector --stdin --file-name app.js --output dist-protected < dist/app.js
@@ -987,7 +989,7 @@ Use `preset` to start from a repeatable protection profile:
987
989
 
988
990
  - `standard`: core string encoding, string movement, name replacement, and compression.
989
991
  - `balanced`: standard plus short local names, deep obfuscation, code transposition, string encryption, and flat transform.
990
- - `maximum`: balanced plus member/global renaming, member movement, and low dead-code insertion.
992
+ - `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)$`.
991
993
 
992
994
  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`.
993
995
 
@@ -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
+ }
@@ -28,6 +28,15 @@ const HTML_SCRIPT_PATTERN = /<script\b([^>]*)>([\s\S]*?)<\/script>/gi;
28
28
  const SOURCE_MAP_COMMENT_LINE_PATTERN = /^[ \t]*\/\/[#@]\s*sourceMappingURL=.*(?:\r?\n)?/gm;
29
29
  const SOURCE_MAP_COMMENT_BLOCK_PATTERN = /[ \t]*\/\*[#@]\s*sourceMappingURL=[\s\S]*?\*\/[ \t]*(?:\r?\n)?/g;
30
30
 
31
+ // CompressionRatio "Auto", NOT "Best", in every preset and translated default.
32
+ // Plans.cs gates each explicit ratio by plan (Medium = Basic, High = Corporate,
33
+ // Best = Enterprise), and "Best" was hardcoded here -- so standard, balanced and
34
+ // maximum were refused for every Basic and Corporate customer ("'compression
35
+ // ratio best' requires Enterprise membership"), while the docs said these
36
+ // presets "need a paid plan". "Auto" makes the engine pick the plan's own best
37
+ // ratio (ProtectorV2.CalcCompressorRatio): Enterprise still gets Best, and
38
+ // nothing a customer paid for is lost. Found 2026-09-24. An explicit
39
+ // --option CompressionRatio=Best is still sent as written.
31
40
  const PRESET_OPTIONS = {
32
41
  // Free tier. Exactly the transforms that are ungated server-side - anything
33
42
  // else (compression, MoveStrings, DeepObfuscate, renaming, VM ...) requires a
@@ -43,7 +52,7 @@ const PRESET_OPTIONS = {
43
52
  MoveStrings: true,
44
53
  ReplaceNames: true,
45
54
  SelfCompression: true,
46
- CompressionRatio: "Best"
55
+ CompressionRatio: "Auto"
47
56
  },
48
57
  balanced: {
49
58
  IdentityStyle: "v2abcd",
@@ -52,7 +61,7 @@ const PRESET_OPTIONS = {
52
61
  ReplaceNames: true,
53
62
  SelfCompression: true,
54
63
  SelfCompressionMinSize: 0,
55
- CompressionRatio: "Best",
64
+ CompressionRatio: "Auto",
56
65
  DeepObfuscate: true,
57
66
  ReorderCode: true,
58
67
  EncryptStrings: true,
@@ -64,11 +73,14 @@ const PRESET_OPTIONS = {
64
73
  MoveStrings: true,
65
74
  ReplaceNames: true,
66
75
  RenameGlobals: true,
67
- RenameMembers: true,
76
+ // No RenameMembers: the engine refuses it without a MemberRegexp or
77
+ // MemberMapping, and no pattern is safe for code a preset has never seen
78
+ // (it renames the member everywhere it appears -- DOM, JSON, library
79
+ // calls). With it here, every maximum run failed before touching a file.
68
80
  MoveMembers: true,
69
81
  SelfCompression: true,
70
82
  SelfCompressionMinSize: 0,
71
- CompressionRatio: "Best",
83
+ CompressionRatio: "Auto",
72
84
  DeepObfuscate: true,
73
85
  ReorderCode: true,
74
86
  AddDeadCode: true,
@@ -80,7 +92,7 @@ const PRESET_OPTIONS = {
80
92
 
81
93
  const WEB_FEATURE_OPTIONS = {
82
94
  "Short Local Name": { IdentityStyle: "v2abcd" },
83
- "Compressor": { SelfCompression: true, SelfCompressionMinSize: 0, CompressionRatio: "Best" },
95
+ "Compressor": { SelfCompression: true, SelfCompressionMinSize: 0, CompressionRatio: "Auto" },
84
96
  "Deep Obfuscation": { DeepObfuscate: true },
85
97
  "Code Transposition": { ReorderCode: true },
86
98
  "Dead Code Insertion": { AddDeadCode: true, DeadcodeLevel: "Low" },
@@ -467,7 +479,7 @@ const OPTION_REFERENCE = [
467
479
  { name: "DeadcodeLevel", type: "enum", values: ["Low", "Medium", "High"], category: "control-flow", description: "Dead-code insertion level." },
468
480
  { name: "OptimizationMode", type: "enum", values: ["Auto", "Web", "Html5", "Game", "Mobile", "NodeJS"], category: "runtime", description: "Runtime optimization target." },
469
481
  { 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." },
482
+ { 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
483
  { name: "WriteFormats", type: "boolean", category: "formatting", description: "Write formatted output for debugging." },
472
484
  { name: "WriteFormats_KeepIndent", type: "boolean", category: "formatting", description: "Keep indentation when formatted output is enabled." },
473
485
  { name: "WriteFormats_LineNumbers", type: "boolean", category: "formatting", description: "Add line numbers when formatted output is enabled." },
@@ -1629,7 +1641,7 @@ function parseArgs(argv) {
1629
1641
  const value = readOptionalBoolean(argv, i + 1);
1630
1642
  if (value) {
1631
1643
  args.options.push("SelfCompression=true");
1632
- args.options.push("CompressionRatio=Best");
1644
+ args.options.push("CompressionRatio=Auto");
1633
1645
  } else {
1634
1646
  args.options.push("SelfCompression=false");
1635
1647
  args.options.push("WriteFormats=true");
@@ -2018,7 +2030,7 @@ function translateJavascriptObfuscatorConfigOptions(source = {}) {
2018
2030
 
2019
2031
  if (source.compact === true) {
2020
2032
  translated.options.SelfCompression = true;
2021
- translated.options.CompressionRatio = "Best";
2033
+ translated.options.CompressionRatio = "Auto";
2022
2034
  } else if (source.compact === false) {
2023
2035
  translated.options.SelfCompression = false;
2024
2036
  translated.options.WriteFormats = true;
@@ -2083,7 +2095,7 @@ function translateJsConfuserConfigOptions(source = {}) {
2083
2095
 
2084
2096
  if (source.stringCompression === true || source.minify === true || source.compact === true) {
2085
2097
  translated.options.SelfCompression = true;
2086
- translated.options.CompressionRatio = "Best";
2098
+ translated.options.CompressionRatio = "Auto";
2087
2099
  } else if (source.minify === false || source.compact === false) {
2088
2100
  translated.options.WriteFormats = true;
2089
2101
  }
@@ -2842,7 +2854,7 @@ function migrateJavascriptObfuscatorConfig(sourcePath, args = {}) {
2842
2854
 
2843
2855
  if (sourceConfig.compact === true) {
2844
2856
  config.options.SelfCompression = true;
2845
- config.options.CompressionRatio = "Best";
2857
+ config.options.CompressionRatio = "Auto";
2846
2858
  mapped.push({ from: "compact", to: "SelfCompression", note: "Compact output maps to self-compression." });
2847
2859
  } else if (sourceConfig.compact === false) {
2848
2860
  config.options.WriteFormats = true;
@@ -3019,7 +3031,7 @@ function migrateJsConfuserConfig(sourcePath, args = {}) {
3019
3031
 
3020
3032
  if (sourceConfig.stringCompression === true || sourceConfig.minify === true || sourceConfig.compact === true) {
3021
3033
  config.options.SelfCompression = true;
3022
- config.options.CompressionRatio = "Best";
3034
+ config.options.CompressionRatio = "Auto";
3023
3035
  mapped.push({ from: sourceConfig.stringCompression === true ? "stringCompression" : sourceConfig.minify === true ? "minify" : "compact", to: "SelfCompression", note: "Compression/minify maps to self-compression." });
3024
3036
  } else if (sourceConfig.minify === false || sourceConfig.compact === false) {
3025
3037
  config.options.WriteFormats = true;
@@ -4456,7 +4468,20 @@ function hasHtmlProtectionMarkers(filePath) {
4456
4468
  return hasMarkedHtmlScriptAttributes(fs.readFileSync(filePath, "utf8"));
4457
4469
  }
4458
4470
 
4471
+ // The engine refuses RenameMembers without a pattern saying WHICH members to
4472
+ // rename ("Please specify regexp or custom mapping for 'Protect Members'"),
4473
+ // and the server returns that as an ordinary option error it never logs. Say
4474
+ // it here, before any source is uploaded, with the fix in the message.
4475
+ function findUnscopedMemberRename(options = {}) {
4476
+ const on = options.RenameMembers === true || /^true$/i.test(String(options.RenameMembers));
4477
+ if (!on) return null;
4478
+ const scoped = ["MemberRegexp", "MemberMapping"].some((name) => String(options[name] || "").trim() !== "");
4479
+ 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.";
4480
+ }
4481
+
4459
4482
  function buildRequestFromItems(config, items) {
4483
+ const unscoped = findUnscopedMemberRename(config.options);
4484
+ if (unscoped) throw new Error(unscoped);
4460
4485
  const project = {
4461
4486
  APIKey: config.apiKey,
4462
4487
  APIPwd: config.apiPassword,
@@ -4473,7 +4498,14 @@ function buildRequestFromItems(config, items) {
4473
4498
  }
4474
4499
 
4475
4500
  for (const [key, value] of Object.entries(config.options)) {
4476
- if (value !== undefined && value !== null && value !== false) {
4501
+ // `false` is TRANSMITTED, not dropped. Every option used to default off, so
4502
+ // omitting a false was equivalent to sending it -- that stopped being true
4503
+ // when DownlevelIteration became ON by default: the engine reads it as
4504
+ // enabled unless it receives an explicit "False", so the old filter made
4505
+ // `--option DownlevelIteration=False` a silent no-op that returned 200 and
4506
+ // quietly ignored what the caller asked for. For every option that defaults
4507
+ // off, sending false is identical to omitting it.
4508
+ if (value !== undefined && value !== null) {
4477
4509
  project[key] = value;
4478
4510
  }
4479
4511
  }
@@ -7182,6 +7214,8 @@ function validateProtectionConfig(config, args = {}) {
7182
7214
  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.");
7183
7215
  addCredentialStorageValidation(checks, config, args);
7184
7216
  addValidationCheck(checks, "preset", "ok", `Preset: ${resolved.preset}`);
7217
+ const unscopedMemberRename = findUnscopedMemberRename(resolved.options);
7218
+ if (unscopedMemberRename) addValidationCheck(checks, "memberRename", "error", unscopedMemberRename);
7185
7219
  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.");
7186
7220
 
7187
7221
  if (resolved.input && !fs.existsSync(resolved.input)) {
@@ -12755,6 +12789,7 @@ module.exports = {
12755
12789
  DEFAULT_ENDPOINT,
12756
12790
  OPTION_REFERENCE,
12757
12791
  PRESET_OPTIONS,
12792
+ findUnscopedMemberRename,
12758
12793
  buildMigrationMapSummary,
12759
12794
  buildMigrationNextCommands,
12760
12795
  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.13
42
+ npm install --save-dev javascriptobfuscator-com@0.4.15
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/index.js CHANGED
@@ -231,7 +231,7 @@ function translateJavascriptObfuscatorOptions(sourceOptions = {}, overrides = {}
231
231
 
232
232
  if (source.compact === true) {
233
233
  translated.options.SelfCompression = true;
234
- translated.options.CompressionRatio = "Best";
234
+ translated.options.CompressionRatio = "Auto"; // not "Best": Best is Enterprise-only (see bin/jso-protector.js PRESET_OPTIONS note)
235
235
  } else if (source.compact === false) {
236
236
  translated.options.WriteFormats = true;
237
237
  }
@@ -315,7 +315,7 @@ function translateJsConfuserOptions(sourceOptions = {}, overrides = {}) {
315
315
 
316
316
  if (source.stringCompression === true || source.minify === true || source.compact === true) {
317
317
  translated.options.SelfCompression = true;
318
- translated.options.CompressionRatio = "Best";
318
+ translated.options.CompressionRatio = "Auto"; // not "Best": Best is Enterprise-only (see bin/jso-protector.js PRESET_OPTIONS note)
319
319
  } else if (source.minify === false || source.compact === false) {
320
320
  translated.options.WriteFormats = true;
321
321
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jso-protector",
3
- "version": "0.4.13",
3
+ "version": "0.4.15",
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: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: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:wire-name-coverage && npm run verify:desktop-option-names && npm run verify:symbolicate-api-shape && npm run verify:advice-option-names && npm run verify:preset-plan-levels && 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,12 @@
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",
237
+ "verify:wire-name-coverage": "node ../polyglot-smoke/check-wire-name-coverage.js",
238
+ "verify:desktop-option-names": "node ../polyglot-smoke/check-desktop-option-names.js",
239
+ "verify:symbolicate-api-shape": "node ../polyglot-smoke/check-symbolicate-api-shape.js",
240
+ "verify:advice-option-names": "node ../polyglot-smoke/check-advice-option-names.js",
241
+ "verify:preset-plan-levels": "node ../polyglot-smoke/check-preset-plan-levels.js",
236
242
  "verify:health-readiness": "node ../polyglot-smoke/check-health-readiness.js",
237
243
  "verify:live-health": "node ../polyglot-smoke/check-production-health.js",
238
244
  "verify:live-seo": "node ../polyglot-smoke/check-live-seo.js",
@@ -243,6 +249,7 @@
243
249
  "verify:package-behaviour": "bash ../../tools/verify-package-behaviour.sh",
244
250
  "verify:emit-validation": "node ../../tools/emit-validation/run.js",
245
251
  "verify:emit-validation-modern": "node ../../tools/emit-validation/run.js modern",
252
+ "verify:es5-syntax": "node ../../tools/es5-syntax-gate/run.js",
246
253
  "verify:corpus-protect": "node ../../tools/corpus-protect/run.js",
247
254
  "verify:corpus-runtime": "node ../../tools/corpus-protect/runtime-smoke.js",
248
255
  "verify:runtime-defense-libraries": "node ../../tools/corpus-protect/runtime-defense-libraries.js",
@@ -272,6 +279,7 @@
272
279
  "verify:entitlements": "node ../polyglot-smoke/check-entitlement-consistency.js",
273
280
  "verify:enterprise-governance": "node ../polyglot-smoke/check-enterprise-governance-security.js",
274
281
  "verify:database-migrations": "node ../polyglot-smoke/check-database-migration-drift.js",
282
+ "verify:published-artifact-secrets": "node ../polyglot-smoke/check-published-artifact-secrets.js",
275
283
  "verify:source-secrets": "node ../polyglot-smoke/check-source-secret-discipline.js",
276
284
  "verify:ignored-shipping-secrets": "node ../polyglot-smoke/check-ignored-shipping-secrets.js",
277
285
  "verify:winforms-runtime-floor": "node ../polyglot-smoke/check-winforms-runtime-floor.js",
@@ -301,7 +309,7 @@
301
309
  "verify:polyglot": "node ../polyglot-smoke/smoke.js",
302
310
  "verify:ai": "node ../polyglot-smoke/ai-smoke.js",
303
311
  "verify:ai-live": "node ../polyglot-smoke/ai-smoke-live.js",
304
- "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",
312
+ "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",
305
313
  "verify:outbound-nofollow": "node ../polyglot-smoke/check-outbound-nofollow.js"
306
314
  },
307
315
  "engines": {