jso-protector 0.2.0 → 0.4.0

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.
@@ -3,8 +3,11 @@
3
3
  "use strict";
4
4
 
5
5
  const fs = require("fs");
6
+ const os = require("os");
6
7
  const crypto = require("crypto");
7
8
  const path = require("path");
9
+ const namedSetsResolver = require("../config/named-sets.js");
10
+ const { spawnSync } = require("child_process");
8
11
  const Module = require("module");
9
12
  const packageJson = require("../package.json");
10
13
  const watermark = require("../watermark.js");
@@ -13,7 +16,7 @@ const pciCompliance = require("../compliance/pci-dss-v4/index.js");
13
16
 
14
17
  const DEFAULT_CONFIG_FILE = "jso.config.json";
15
18
  const DEFAULT_CONFIG_FILES = ["jso.config.json", "jso.config.cjs", "jso.config.mjs", "jso.config.js"];
16
- const DEFAULT_ENDPOINT = "https://www.javascriptobfuscator.com/HttpApi.ashx";
19
+ const DEFAULT_ENDPOINT = "https://javascriptobfuscator.com/HttpApi.ashx";
17
20
  const DEFAULT_EXTENSIONS = [".js", ".jsx"];
18
21
  const DEFAULT_MARKUP_EXTENSIONS = [".html", ".htm", ".php", ".phtml", ".asp", ".aspx", ".jsp", ".cshtml", ".vbhtml"];
19
22
  const DEFAULT_EXCLUDE = ["**/*.map", "**/node_modules/**", "**/*-obfuscated.js"];
@@ -86,7 +89,18 @@ const JAVASCRIPT_OBFUSCATOR_MIGRATION_MAP = [
86
89
  { source: "optionsPreset", target: ["preset"], confidence: "approximate", note: "default/low and VM low/default presets map to standard, medium and VM medium map to balanced, and high plus stronger VM presets map to maximum." },
87
90
  { source: "stringArray", target: ["MoveStrings"], confidence: "direct", note: "Moves string literals into generated lookup structures." },
88
91
  { source: "stringArrayEncoding", target: ["EncodeStrings", "EncryptStrings"], confidence: "approximate", note: "rc4-style values map to encrypted strings; other values map to encoded strings." },
89
- { source: "stringArrayThreshold", target: ["MoveStrings"], confidence: "approximate", note: "Threshold values are not one-to-one; review output size and behavior." },
92
+ { source: "stringArrayThreshold", target: ["StringArrayThreshold", "MoveStrings"], confidence: "direct", note: "Applies a seeded per-unique-literal probability from 0 through 1; zero disables moved strings." },
93
+ { source: "stringArrayCallsTransform", target: ["StringArrayCallsTransform"], confidence: "direct", note: "Routes selected moved-string lookups through a generated secondary index table." },
94
+ { source: "stringArrayCallsTransformThreshold", target: ["StringArrayCallsTransformThreshold"], confidence: "direct", note: "Applies a seeded per-lookup indirection probability from 0 through 1." },
95
+ { source: "stringArrayWrappersCount", target: ["StringArrayWrappersCount"], confidence: "approximate", note: "Adds 0-10 root-level wrappers; competitor per-scope wrapper placement is not reproduced." },
96
+ { source: "stringArrayWrappersChainedCalls", target: ["StringArrayWrappersChainedCalls"], confidence: "direct", note: "Controls whether generated wrappers delegate through the previous wrapper." },
97
+ { source: "stringArrayWrappersParametersMaxCount", target: ["StringArrayWrappersParametersMaxCount"], confidence: "direct", note: "Bounds function-wrapper parameters from 2 through 5 and fills non-index arguments with noise values." },
98
+ { source: "stringArrayWrappersType", target: ["StringArrayWrappersType"], confidence: "direct", note: "Supports variable aliases and function wrappers." },
99
+ { source: "transformObjectKeys", target: ["TransformObjectKeys"], confidence: "approximate", note: "Moves safe identifier and quoted data keys into computed string-table lookups; numeric, method/accessor, shorthand-sensitive, and __proto__ keys remain literal." },
100
+ { source: "stringArrayIndexShift", target: ["StringArrayIndexShift"], confidence: "approximate", note: "Adds a nonzero table offset; vendor-specific randomized shift magnitude is not reproduced." },
101
+ { source: "stringArrayShuffle", target: ["StringArrayShuffle"], confidence: "direct", note: "Randomizes moved-string table order and rewrites every generated lookup." },
102
+ { source: "stringArrayRotate", target: ["StringArrayRotate"], confidence: "direct", note: "Cyclically rotates moved-string table order by a per-build offset and rewrites every generated lookup." },
103
+ { source: "stringArrayIndexesType", target: ["StringArrayIndexesType"], confidence: "direct", note: "Supports hexadecimal-number and hexadecimal-numeric-string lookup representations, including mixed lists." },
90
104
  { source: "unicodeEscapeSequence", target: ["EncodeStrings"], confidence: "approximate", note: "Maps to encoded strings." },
91
105
  { source: "controlFlowFlattening", target: ["FlatTransform", "DeepObfuscate"], confidence: "approximate", note: "Maps to deeper control-flow and flat-transform protection." },
92
106
  { source: "deadCodeInjection", target: ["AddDeadCode"], confidence: "direct", note: "Enables dead-code insertion." },
@@ -94,8 +108,19 @@ const JAVASCRIPT_OBFUSCATOR_MIGRATION_MAP = [
94
108
  { source: "identifierNamesGenerator", target: ["IdentityStyle"], confidence: "approximate", note: "Hexadecimal maps to v1hex; other styles map to v2abcd." },
95
109
  { source: "renameGlobals", target: ["RenameGlobals"], confidence: "direct", note: "Enables global renaming." },
96
110
  { source: "renameProperties", target: ["RenameMembers"], confidence: "approximate", note: "Review public member access before enabling." },
111
+ { source: "selfDefending", target: ["SelfDefending"], confidence: "direct", note: "Enables the hosted engine's self-integrity guard." },
112
+ { source: "debugProtection", target: ["DebugProtection"], confidence: "direct", note: "Enables the hosted engine's debugger reaction guard." },
113
+ { source: "debugProtectionInterval", target: ["DebugProtectionIntervalMilliseconds"], confidence: "direct", note: "Maps the millisecond interval; 0 disables periodic timing probes while retaining other enabled debug checks." },
114
+ { source: "disableConsoleOutput", target: ["DisableConsoleOutput"], confidence: "direct", note: "Suppresses common browser console methods in protected output." },
115
+ { source: "seed", target: ["Seed"], confidence: "direct", note: "Maps to deterministic engine entropy. The same input, options, and seed produce byte-identical output; omit it for per-build polymorphism." },
116
+ { source: "reservedStrings", target: ["ReservedStrings"], confidence: "direct", note: "Preserves matching literals verbatim outside MoveStrings and EncodeStrings. Up to 100 regex patterns are accepted." },
117
+ { source: "forceTransformStrings", target: ["ForceTransformStrings"], confidence: "direct", note: "Matching literals override ReservedStrings and pass through enabled string transforms." },
118
+ { source: "splitStrings", target: ["SplitStrings"], confidence: "direct", note: "Splits eligible literals into fixed-length concatenated chunks." },
119
+ { source: "splitStringsChunkLength", target: ["SplitStringsChunkLength"], confidence: "direct", note: "Sets a bounded chunk length from 1 through 1024; the engine default is 10." },
120
+ { source: "numbersToExpressions", target: ["EncodeNumbers"], confidence: "approximate", note: "Obscures numeric literals with the native numeric encoder; generated expression shape is not preserved." },
97
121
  { source: "reservedNames", target: ["reservedNames", "VariableExclusion"], confidence: "direct", note: "Reserved name expressions are preserved." },
98
122
  { source: "domainLock", target: ["LockDomain", "LockDomainList"], confidence: "approximate", note: "Domain lock lists map to LockDomain and LockDomainList; review subdomain and redirect behavior." },
123
+ { source: "domainLockRedirectUrl", target: ["LockDomainRedirectUrl"], confidence: "direct", note: "Maps to the domain-lock-specific safe redirect without changing reactions for other runtime defenses." },
99
124
  { source: "compact", target: ["SelfCompression", "CompressionRatio", "WriteFormats"], confidence: "approximate", note: "Compact true maps to compression; compact false maps to formatted output." },
100
125
  { source: "target", target: ["OptimizationMode"], confidence: "approximate", note: "browser maps to Web; node maps to NodeJS." },
101
126
  { source: "parseHtml", target: ["parseHtml"], confidence: "direct", note: "Protects marked <script data-javascript-obfuscator> blocks in HTML or template files." },
@@ -111,33 +136,31 @@ const JS_CONFUSER_MIGRATION_MAP = [
111
136
  { source: "stringEncoding", target: ["EncodeStrings"], confidence: "approximate", note: "String encoding maps to encoded strings." },
112
137
  { source: "stringConcealing", target: ["EncryptStrings"], confidence: "approximate", note: "String concealing maps to encrypted strings." },
113
138
  { source: "duplicateLiteralsRemoval", target: ["MoveStrings"], confidence: "approximate", note: "Duplicate literal removal maps to moved string storage." },
139
+ { source: "stringSplitting", target: ["SplitStrings"], confidence: "approximate", note: "Boolean/numeric enablement maps to fixed-length splitting; probability values collapse to enabled/disabled and custom selector functions require review." },
114
140
  { source: "stringCompression", target: ["SelfCompression", "CompressionRatio"], confidence: "approximate", note: "String compression maps to self-compression." },
115
141
  { source: "compact", target: ["SelfCompression", "CompressionRatio", "WriteFormats"], confidence: "approximate", note: "Compact output maps to self-compression; false maps to formatted output." },
116
142
  { source: "minify", target: ["SelfCompression", "CompressionRatio", "WriteFormats"], confidence: "approximate", note: "Minify maps to self-compression; false maps to formatted output." },
117
143
  { source: "controlFlowFlattening", target: ["FlatTransform", "DeepObfuscate"], confidence: "approximate", note: "Maps to deeper control-flow and flat-transform protection." },
118
144
  { source: "deadCode", target: ["AddDeadCode"], confidence: "direct", note: "Enables dead-code insertion." },
119
145
  { source: "identifierGenerator", target: ["IdentityStyle"], confidence: "approximate", note: "Hexadecimal generators map to v1hex; other styles map to v2abcd." },
146
+ { source: "hexadecimalNumbers", target: ["EncodeNumbers"], confidence: "approximate", note: "Obscures numeric literals with the native numeric encoder; hexadecimal formatting is not guaranteed." },
120
147
  { source: "lock.domainLock", target: ["LockDomain", "LockDomainList"], confidence: "approximate", note: "Domain lock maps to LockDomain and LockDomainList; review subdomain behavior." },
121
- { source: "lock.endDate", target: ["LockDate", "LockDateValue"], confidence: "approximate", note: "End-date lock maps to LockDate and yyyyMMdd LockDateValue." }
148
+ { source: "lock.endDate", target: ["LockDate", "LockDateValue"], confidence: "approximate", note: "End-date lock maps to LockDate and yyyyMMdd LockDateValue." },
149
+ { source: "lock.startDate", target: ["LockStartDate", "LockStartDateValue"], confidence: "approximate", note: "Start-date lock maps to the native browser activation boundary." },
150
+ { source: "lock.antiDebug", target: ["DebugProtection"], confidence: "approximate", note: "Boolean/numeric enablement maps to the native debugger guard; probability values collapse to enabled/disabled." },
151
+ { source: "lock.integrity", target: ["SelfDefending"], confidence: "approximate", note: "Boolean/numeric enablement maps to native integrity monitoring; probability values collapse to enabled/disabled." },
152
+ { source: "lock.selfDefending", target: ["SelfDefending"], confidence: "approximate", note: "Boolean/numeric enablement maps to native self-integrity monitoring." },
153
+ { source: "lock.tamperProtection", target: ["AntiMonkeyPatching"], confidence: "approximate", note: "Boolean/numeric enablement maps to native security-relevant global integrity checks." }
122
154
  ];
123
155
 
124
156
  const JAVASCRIPT_OBFUSCATOR_REVIEW_OPTIONS = {
125
- debugProtection: "Review anti-debugging behavior against JavaScript Obfuscator runtime-defense options.",
126
- debugProtectionInterval: "Review anti-debugging interval behavior manually.",
127
- disableConsoleOutput: "No direct config conversion; decide whether console behavior should be handled in app code.",
128
- domainLockRedirectUrl: "Review and convert to LockDomainMsg or application-level handling.",
129
- forceTransformStrings: "Review string handling manually.",
130
157
  identifiersDictionary: "Custom identifier dictionaries are not exposed by the hosted API workflow; review naming requirements manually.",
131
158
  identifiersPrefix: "Global identifier prefixes are not exposed by the hosted API workflow; review multi-file naming requirements manually.",
132
159
  identifierNamesCache: "Identifier-name cache files are not emitted by the hosted API workflow; review deterministic rename requirements manually.",
133
160
  identifierNamesCachePath: "Identifier-name cache files are not emitted by the hosted API workflow; remove cache-file assumptions from release scripts.",
134
161
  inputFileName: "Review source-map input file naming manually; the hosted API workflow protects named request items.",
135
162
  log: "Review logging needs in CI; use --json, --dry-run, --doctor, and manifests for structured release output.",
136
- numbersToExpressions: "Review numeric expression transforms manually.",
137
163
  renamePropertiesMode: "Review property rename mode manually before enabling RenameMembers.",
138
- reservedStrings: "Review reserved string requirements manually; string handling is controlled by MoveStrings, EncodeStrings, and EncryptStrings.",
139
- seed: "Maps to the JSO Seed option for reproducible builds (--seed or a config seed). Confirm the value produces the intended output, and keep seed values out of shared logs.",
140
- selfDefending: "Review tamper-defense requirements manually.",
141
164
  simplify: "Simplify is accepted for migration compatibility; review whether hosted API compression and formatting options meet the same goal.",
142
165
  sourceMap: "Do not publish source maps with protected release output unless your release policy allows it.",
143
166
  sourceMapBaseUrl: "Source maps are not emitted by the hosted API workflow; review release source-map policy.",
@@ -145,34 +168,15 @@ const JAVASCRIPT_OBFUSCATOR_REVIEW_OPTIONS = {
145
168
  sourceMapMode: "Review source map handling manually.",
146
169
  sourceMapSourcesMode: "Source maps are not emitted by the hosted API workflow; review release source-map policy.",
147
170
  strictMode: "Review strict-mode assumptions manually; the hosted API workflow auto-detects runtime semantics from submitted code.",
148
- splitStrings: "Review string splitting needs; MoveStrings and EncryptStrings may already cover the goal.",
149
- splitStringsChunkLength: "Review string splitting needs manually.",
150
- stringArrayCallsTransform: "Review string-call transform needs manually.",
151
- stringArrayCallsTransformThreshold: "Review string-call transform thresholds manually.",
152
- stringArrayIndexShift: "Review string-array index-shift behavior manually.",
153
- stringArrayIndexesType: "Review string-array index style manually.",
154
- stringArrayRotate: "Review string-array rotation needs manually.",
155
- stringArrayShuffle: "Review string-array shuffle needs manually.",
156
- stringArrayWrappersChainedCalls: "Review string-array wrapper chained-call behavior manually.",
157
- stringArrayWrappersCount: "Review string wrapper behavior manually.",
158
- stringArrayWrappersParametersMaxCount: "Review string-array wrapper parameter behavior manually.",
159
- stringArrayWrappersType: "Review string-array wrapper style manually.",
160
- transformObjectKeys: "Review object-key transform needs manually."
161
171
  };
162
172
 
163
173
  const JS_CONFUSER_REVIEW_OPTIONS = {
164
- "lock.antiDebug": "Review anti-debugging requirements manually.",
165
174
  "lock.countermeasures": "Review runtime countermeasure behavior manually.",
166
175
  "lock.customLocks": "Custom runtime locks need manual review.",
167
- "lock.integrity": "Integrity and tamper detection need manual review.",
168
- "lock.selfDefending": "Self-defending runtime behavior needs manual review.",
169
- "lock.startDate": "Start-date locks have no direct hosted API equivalent; review gating behavior manually.",
170
- "lock.tamperProtection": "Tamper-protection behavior needs manual review.",
171
176
  astScrambler: "AST scrambling has no direct hosted API mapping; review output manually.",
172
177
  calculator: "Calculator transforms have no direct hosted API mapping; review output manually.",
173
178
  dispatcher: "Dispatcher control-flow transforms have no direct hosted API mapping; review output manually.",
174
179
  flatten: "Function flattening has no direct hosted API mapping; review output manually.",
175
- hexadecimalNumbers: "Hexadecimal number output has no direct hosted API mapping; review output manually.",
176
180
  movedDeclarations: "Moved declaration behavior has no direct hosted API mapping; review output manually.",
177
181
  objectExtraction: "Object extraction has no direct hosted API mapping; review output manually.",
178
182
  opaquePredicates: "Opaque predicate transforms have no direct hosted API mapping; review output manually.",
@@ -185,14 +189,17 @@ const JS_CONFUSER_REVIEW_OPTIONS = {
185
189
  };
186
190
 
187
191
  const JS_CONFUSER_CONFIG_REVIEW_FIELDS = {
188
- jsConfuserLockAntiDebug: "Preserved JS-Confuser lock.antiDebug value for manual review.",
189
- jsConfuserLockIntegrity: "Preserved JS-Confuser lock.integrity value for manual review.",
190
- jsConfuserLockSelfDefending: "Preserved JS-Confuser lock.selfDefending value for manual review.",
191
- jsConfuserLockStartDate: "Preserved JS-Confuser lock.startDate value for manual review.",
192
- jsConfuserLockCountermeasures: "Preserved JS-Confuser lock.countermeasures value for manual review.",
193
- jsConfuserLockTamperProtection: "Preserved JS-Confuser lock.tamperProtection value for manual review."
192
+ jsConfuserLockCountermeasures: "Preserved JS-Confuser lock.countermeasures value for manual review."
194
193
  };
195
194
 
195
+ const JS_CONFUSER_CONFIG_MAPPED_FIELDS = [
196
+ "jsConfuserLockAntiDebug",
197
+ "jsConfuserLockIntegrity",
198
+ "jsConfuserLockSelfDefending",
199
+ "jsConfuserLockStartDate",
200
+ "jsConfuserLockTamperProtection"
201
+ ];
202
+
196
203
  const JS_CONFUSER_CONFIG_REVIEW_FIELD_TYPES = {
197
204
  jsConfuserLockAntiDebug: "booleanOrNonNegativeNumber",
198
205
  jsConfuserLockIntegrity: "booleanOrNonNegativeNumber",
@@ -203,11 +210,6 @@ const JS_CONFUSER_CONFIG_REVIEW_FIELD_TYPES = {
203
210
  };
204
211
 
205
212
  const RUNTIME_DEFENSE_REVIEW_FIELDS = [
206
- "debugProtection",
207
- "debugProtectionInterval",
208
- "disableConsoleOutput",
209
- "domainLockRedirectUrl",
210
- "selfDefending",
211
213
  ...Object.keys(JS_CONFUSER_CONFIG_REVIEW_FIELDS)
212
214
  ];
213
215
 
@@ -248,9 +250,6 @@ const COMPETITOR_LIMITATION_GROUPS = [
248
250
  id: "runtime-self-defending",
249
251
  fields: [
250
252
  "debugProtection",
251
- "debugProtectionInterval",
252
- "disableConsoleOutput",
253
- "domainLockRedirectUrl",
254
253
  "selfDefending",
255
254
  "jsConfuserLockAntiDebug",
256
255
  "jsConfuserLockIntegrity",
@@ -295,7 +294,7 @@ const COMPETITOR_CAPABILITY_MATRIX = [
295
294
  capability: "Domain and expiry locks",
296
295
  competitorExamples: ["Obfuscator.io", "Jscrambler", "JS-Confuser", "javascript-obfuscator"],
297
296
  status: "partial",
298
- jsoSupport: "Domain and end-date locks map to LockDomain/LockDomainList and LockDate/LockDateValue; browser, OS, start-date, and custom countermeasure locks remain manual-review gaps.",
297
+ jsoSupport: "Domain, start-date, end-date, browser, and OS allowlists ship through LockDomain, LockStartDate, LockDate, LockBrowser, and LockOS. Browser/OS classification uses spoofable runtime signals; custom countermeasure functions remain a manual-review gap.",
299
298
  evidence: ["domainLock", "lock.domainLock", "lock.endDate", "lock.startDate", "lock.countermeasures"]
300
299
  },
301
300
  {
@@ -303,8 +302,8 @@ const COMPETITOR_CAPABILITY_MATRIX = [
303
302
  capability: "Self-defending, anti-debug, and tamper/integrity reactions",
304
303
  competitorExamples: ["Obfuscator.io", "Jscrambler", "JSDefender", "JS-Confuser", "javascript-obfuscator"],
305
304
  status: "partial",
306
- jsoSupport: "Use JSO runtime monitoring, hosted dashboard intake, beacon forwarding, and countermeasure helpers for customer-owned runtime defense. Migrated anti-debug/self-defending switches remain review-only because they are not one-to-one hosted API options.",
307
- evidence: ["RuntimeDefenseBeaconUrl", "dashboard-monitoring", "jso-beacon-slack", "runtime/countermeasures", "selfDefending", "debugProtection", "lock.antiDebug", "lock.integrity", "lock.selfDefending", "lock.tamperProtection"]
305
+ jsoSupport: "javascript-obfuscator selfDefending, debugProtection, and bounded debugProtectionInterval settings map directly to JSO runtime options. Bounded page-realm integrity scheduling, dotted callback dispatch, hosted dashboard intake, and beacon forwarding provide customer-owned reactions and evidence; arbitrary vendor countermeasure functions and vendor-specific integrity semantics still require explicit review and runtime proof.",
306
+ evidence: ["SelfDefendingIntervalSeconds", "DebugProtectionIntervalMilliseconds", "RuntimeDefenseCallback", "RuntimeDefenseBeaconUrl", "dashboard-monitoring", "jso-beacon-slack", "runtime/countermeasures", "selfDefending", "debugProtection", "debugProtectionInterval", "lock.antiDebug", "lock.integrity", "lock.selfDefending", "lock.tamperProtection"]
308
307
  },
309
308
  {
310
309
  id: "release-forensics",
@@ -321,16 +320,32 @@ const COMPETITOR_CAPABILITY_MATRIX = [
321
320
  status: "gap",
322
321
  jsoSupport: "Hosted API releases intentionally remove source maps and do not emit identifier-name caches.",
323
322
  evidence: ["sourceMap", "identifierNamesCache", "identifierNamesCachePath"]
323
+ },
324
+ {
325
+ id: "vm-bytecode",
326
+ capability: "Selective JavaScript bytecode virtualization",
327
+ competitorExamples: ["Obfuscator.io Pro", "Jscrambler", "enterprise application-protection vendors"],
328
+ status: "partial",
329
+ jsoSupport: "Use UseVMProtection with @virtualize-marked functions and retain the VM proof pack. JSO plan eligibility starts at Corporate, but production access remains a staged beta and unsupported function shapes fall back with an explicit warning.",
330
+ evidence: ["UseVMProtection", "@virtualize", "VMProtectionApplied", "vm-proof-pack-report"]
331
+ },
332
+ {
333
+ id: "vm-runtime-hardening",
334
+ capability: "VM runtime hardening and anti-analysis controls",
335
+ competitorExamples: ["Obfuscator.io Pro", "JSDefender", "Jscrambler"],
336
+ status: "partial",
337
+ jsoSupport: "JSO combines per-build VM output with SelfDefending, AntiMonkeyPatching, DebugProtection, signed runtime envelopes, and customer-owned telemetry. It does not claim parity with every vendor-specific stateful-opcode, encoded-jump, encoded-stack, or anti-analysis implementation without side-by-side proof.",
338
+ evidence: ["SelfDefending", "AntiMonkeyPatching", "DebugProtection", "RuntimeSigningPublicKey", "RuntimeDefenseBeaconUrl"]
324
339
  }
325
340
  ];
326
341
 
327
342
  const COMPETITOR_SOURCE_SNAPSHOT = {
328
- reviewedOn: "2026-06-08",
343
+ reviewedOn: "2026-08-02",
329
344
  basis: "Public competitor product, documentation, marketplace, API, and platform pages reviewed for migration-positioning context.",
330
345
  sources: [
331
346
  { competitor: "Obfuscator.io", label: "Pricing", url: "https://obfuscator.io/pricing" },
332
347
  { competitor: "Obfuscator.io", label: "API docs", url: "https://obfuscator.io/docs/api" },
333
- { competitor: "javascript-obfuscator", label: "GitHub README", url: "https://github.com/javascript-obfuscator/javascript-obfuscator" },
348
+ { competitor: "javascript-obfuscator", label: "GitHub README and Obfuscator.io Pro VM option reference", url: "https://github.com/javascript-obfuscator/javascript-obfuscator" },
334
349
  { competitor: "JS-Confuser", label: "Options docs", url: "https://js-confuser.com/docs/options" },
335
350
  { competitor: "Jscrambler", label: "GitHub CI integration", url: "https://docs.jscrambler.com/code-integrity/documentation/github-ci-integration" },
336
351
  { competitor: "AfterPack", label: "Product page", url: "https://www.afterpack.dev/" },
@@ -364,14 +379,12 @@ const JS_CONFUSER_DETECT_KEYS = [
364
379
  "stringCompression",
365
380
  "stringConcealing",
366
381
  "stringEncoding",
382
+ "stringSplitting",
367
383
  "variableMasking"
368
384
  ];
369
385
 
370
386
  const JAVASCRIPT_OBFUSCATOR_REVIEW_OPTION_TYPES = {
371
387
  debugProtection: "boolean",
372
- debugProtectionInterval: "nonNegativeNumber",
373
- disableConsoleOutput: "boolean",
374
- domainLockRedirectUrl: "string",
375
388
  forceTransformStrings: "stringArray",
376
389
  identifiersDictionary: "stringArray",
377
390
  identifiersPrefix: "string",
@@ -396,6 +409,8 @@ const JAVASCRIPT_OBFUSCATOR_REVIEW_OPTION_TYPES = {
396
409
  stringArrayCallsTransform: "boolean",
397
410
  stringArrayCallsTransformThreshold: "nonNegativeNumber",
398
411
  stringArrayIndexShift: "boolean",
412
+ stringArrayShuffle: "boolean",
413
+ stringArrayRotate: "boolean",
399
414
  stringArrayIndexesType: "stringOrStringArray",
400
415
  stringArrayRotate: "boolean",
401
416
  stringArrayShuffle: "boolean",
@@ -410,6 +425,22 @@ const JAVASCRIPT_OBFUSCATOR_REVIEW_OPTION_TYPES = {
410
425
  const OPTION_REFERENCE = [
411
426
  { name: "EncodeStrings", type: "boolean", category: "strings", description: "Encode string literals." },
412
427
  { name: "MoveStrings", type: "boolean", category: "strings", description: "Move string literals into a generated lookup structure." },
428
+ { name: "SplitStrings", type: "boolean", category: "strings", description: "Split eligible string literals into fixed-length concatenated chunks." },
429
+ { name: "SplitStringsChunkLength", type: "number", category: "strings", description: "String chunk length from 1 through 1024; defaults to 10." },
430
+ { name: "StringArrayIndexShift", type: "boolean", category: "strings", description: "Offset moved-string table references by one nonzero slot." },
431
+ { name: "StringArrayShuffle", type: "boolean", category: "strings", description: "Randomize moved-string table order while preserving generated lookups." },
432
+ { name: "StringArrayRotate", type: "boolean", category: "strings", description: "Cyclically rotate moved-string table order by a per-build offset." },
433
+ { name: "StringArrayIndexesType", type: "string", category: "strings", values: ["hexadecimal-number", "hexadecimal-numeric-string"], description: "Choose one or both hexadecimal moved-string lookup representations." },
434
+ { name: "StringArrayThreshold", type: "number", category: "strings", description: "Move each unique eligible literal with probability 0 through 1." },
435
+ { name: "StringArrayCallsTransform", type: "boolean", category: "strings", description: "Route selected moved-string lookups through a secondary index table." },
436
+ { name: "StringArrayCallsTransformThreshold", type: "number", category: "strings", description: "Secondary index-indirection probability from 0 through 1." },
437
+ { name: "StringArrayWrappersCount", type: "number", category: "strings", description: "Generate 0-10 root-level string-table wrappers." },
438
+ { name: "StringArrayWrappersChainedCalls", type: "boolean", category: "strings", description: "Delegate each wrapper through the previous wrapper." },
439
+ { name: "StringArrayWrappersParametersMaxCount", type: "number", category: "strings", description: "Function-wrapper parameter ceiling from 2 through 5." },
440
+ { name: "StringArrayWrappersType", type: "string", category: "strings", values: ["variable", "function"], description: "Generate variable aliases or multi-parameter function wrappers." },
441
+ { name: "TransformObjectKeys", type: "boolean", category: "strings", description: "Move safe object-literal data keys into computed string-table lookups." },
442
+ { name: "ReservedStrings", type: "string", category: "strings", description: "Newline-delimited regex patterns for literals kept verbatim outside move/encode transforms." },
443
+ { name: "ForceTransformStrings", type: "string", category: "strings", description: "Newline-delimited regex patterns that override ReservedStrings for matching literals." },
413
444
  { name: "EncryptStrings", type: "boolean", category: "strings", description: "Encrypt strings for stronger string hiding." },
414
445
  { name: "ReplaceNames", type: "boolean", category: "names", description: "Rename local JavaScript identifiers." },
415
446
  { name: "RenameGlobals", type: "boolean", category: "names", description: "Rename global identifiers more aggressively." },
@@ -426,6 +457,8 @@ const OPTION_REFERENCE = [
426
457
  { name: "AddDeadCode", type: "boolean", category: "control-flow", description: "Insert dead code." },
427
458
  { name: "DeadcodeLevel", type: "enum", values: ["Low", "Medium", "High"], category: "control-flow", description: "Dead-code insertion level." },
428
459
  { name: "OptimizationMode", type: "enum", values: ["Auto", "Web", "Html5", "Game", "Mobile", "NodeJS"], category: "runtime", description: "Runtime optimization target." },
460
+ { 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." },
461
+ { 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." },
429
462
  { name: "WriteFormats", type: "boolean", category: "formatting", description: "Write formatted output for debugging." },
430
463
  { name: "WriteFormats_KeepIndent", type: "boolean", category: "formatting", description: "Keep indentation when formatted output is enabled." },
431
464
  { name: "WriteFormats_LineNumbers", type: "boolean", category: "formatting", description: "Add line numbers when formatted output is enabled." },
@@ -433,12 +466,36 @@ const OPTION_REFERENCE = [
433
466
  { name: "LockDomainSubs", type: "boolean", category: "locks", description: "Allow subdomains in domain locking." },
434
467
  { name: "LockDomainList", type: "string", category: "locks", description: "Allowed domain list for domain locking." },
435
468
  { name: "LockDomainMsg", type: "string", category: "locks", description: "Message shown when domain locking fails." },
469
+ { name: "LockDomainRedirectUrl", type: "string", category: "locks", description: "Domain-lock-specific HTTP(S) or root-relative redirect target." },
436
470
  { name: "LockDate", type: "boolean", category: "locks", description: "Enable date locking." },
437
471
  { name: "LockDateValue", type: "string", category: "locks", description: "Lock date in yyyyMMdd format." },
438
- { name: "LockDateMsg", type: "string", category: "locks", description: "Message shown when date locking fails." }
472
+ { name: "LockDateMsg", type: "string", category: "locks", description: "Message shown when date locking fails." },
473
+ { name: "LockStartDate", type: "boolean", category: "locks", description: "Prevent protected code from running before its activation date." },
474
+ { name: "LockStartDateValue", type: "string", category: "locks", description: "Activation date in yyyyMMdd format." },
475
+ { name: "LockStartDateMsg", type: "string", category: "locks", description: "Message used when the start-date lock fails." },
476
+ { name: "LockBrowser", type: "boolean", category: "locks", description: "Restrict browser execution using user-agent classification." },
477
+ { name: "LockBrowserList", type: "string", category: "locks", description: "Allowed browsers: chrome, edge, firefox, safari, opera, ie." },
478
+ { name: "LockBrowserMsg", type: "string", category: "locks", description: "Message used when the browser lock fails." },
479
+ { name: "LockOS", type: "boolean", category: "locks", description: "Restrict operating-system execution using browser runtime signals." },
480
+ { name: "LockOSList", type: "string", category: "locks", description: "Allowed operating systems: windows, macos, linux, android, ios." },
481
+ { name: "LockOSMsg", type: "string", category: "locks", description: "Message used when the operating-system lock fails." },
482
+ { name: "SelfDefending", type: "boolean", category: "runtime-defense", description: "Enable protected-source integrity checks." },
483
+ { name: "DebugProtectionIntervalMilliseconds", type: "number", category: "runtime-defense", description: "Debug timing probe interval: 0 disables periodic probes; otherwise 100 through 60000 milliseconds." },
484
+ { name: "SelfDefendingIntervalSeconds", type: "number", category: "runtime-defense", description: "Repeat self-defending integrity checks every 1 through 86400 seconds; omit for invocation-only checks." },
485
+ { name: "SelfHealing", type: "boolean", category: "runtime-defense", description: "Enable bounded local recovery after a self-defending check fails." },
486
+ { name: "SelfHealingMaxAttempts", type: "number", category: "runtime-defense", description: "Limit local recovery attempts from 1 through 10." },
487
+ { name: "AntiMonkeyPatching", type: "boolean", category: "runtime-defense", description: "Detect replacement of selected browser APIs." },
488
+ { name: "AntiMonkeyPatchingCleanRealm", type: "boolean", category: "runtime-defense", description: "Compare startup APIs with a same-origin clean realm." },
489
+ { name: "AntiMonkeyPatchingIncludeGlobals", type: "string", category: "runtime-defense", description: "Additional dotted API paths to monitor." },
490
+ { name: "AntiMonkeyPatchingExcludeGlobals", type: "string", category: "runtime-defense", description: "Dotted API paths to omit from monitoring." },
491
+ { name: "RuntimeDefenseAction", type: "enum", values: ["throw", "blank", "redirect", "reload", "callback", "degrade"], category: "runtime-defense", description: "Action taken after runtime defense trips and recovery is unavailable." },
492
+ { name: "RuntimeDefenseCallback", type: "string", category: "runtime-defense", description: "Dotted global callback path receiving runtime-defense events." },
493
+ { name: "RuntimeDefenseRedirectUrl", type: "string", category: "runtime-defense", description: "HTTP(S) or root-relative target used by the redirect action." }
439
494
  ];
440
495
 
441
496
  const CONVENIENCE_OPTION_ALIASES = [
497
+ { configKey: "targetVersion", optionName: "TargetVersion", type: "string" },
498
+ { configKey: "downlevelIteration", optionName: "DownlevelIteration", type: "boolean" },
442
499
  { configKey: "keepHeaderComment", optionName: "KeepComment", type: "boolean" },
443
500
  { configKey: "protectObjectDeclaration", optionName: "ReorderCodeObjectDeclare", type: "boolean" },
444
501
  { configKey: "moveNestedFunction", optionName: "MoveNested", type: "boolean" },
@@ -450,6 +507,17 @@ const CONVENIENCE_OPTION_ALIASES = [
450
507
  { configKey: "lockDate", optionName: "LockDate", type: "boolean" },
451
508
  { configKey: "lockDateValue", optionName: "LockDateValue", type: "string" },
452
509
  { configKey: "lockDateMessage", optionName: "LockDateMsg", type: "string" },
510
+ { configKey: "selfHealing", optionName: "SelfHealing", type: "boolean" },
511
+ { configKey: "selfHealingMaxAttempts", optionName: "SelfHealingMaxAttempts", type: "number" },
512
+ { configKey: "antiMonkeyPatching", optionName: "AntiMonkeyPatching", type: "boolean" },
513
+ { configKey: "antiMonkeyPatchingCleanRealm", optionName: "AntiMonkeyPatchingCleanRealm", type: "boolean" },
514
+ { configKey: "antiMonkeyPatchingIncludeGlobals", optionName: "AntiMonkeyPatchingIncludeGlobals", type: "string" },
515
+ { configKey: "antiMonkeyPatchingExcludeGlobals", optionName: "AntiMonkeyPatchingExcludeGlobals", type: "string" },
516
+ { configKey: "runtimeDefenseAction", optionName: "RuntimeDefenseAction", type: "string" },
517
+ { configKey: "selfDefendingIntervalSeconds", optionName: "SelfDefendingIntervalSeconds", type: "number" },
518
+ { configKey: "debugProtectionIntervalMilliseconds", optionName: "DebugProtectionIntervalMilliseconds", type: "number" },
519
+ { configKey: "runtimeDefenseCallback", optionName: "RuntimeDefenseCallback", type: "string" },
520
+ { configKey: "runtimeDefenseRedirectUrl", optionName: "RuntimeDefenseRedirectUrl", type: "string" },
453
521
  { configKey: "seed", optionName: "Seed", type: "string" }
454
522
  ];
455
523
 
@@ -841,6 +909,9 @@ Options:
841
909
  --stdout Write protected stdin output to standard output.
842
910
  --file-name <name> Virtual file name for stdin mode. Defaults to stdin.js.
843
911
  --preset <name> Protection preset: standard, balanced, or maximum.
912
+ --seed <value> Reproducible builds: the same input, options and seed produce
913
+ byte-identical output. Omit for the default per-build
914
+ polymorphic output. Forwarded to the engine as Seed.
844
915
  --web-preset <file> Import an exported online-tool JSON preset.
845
916
  --migrate-javascript-obfuscator <file> Convert a javascript-obfuscator JSON or CommonJS config.
846
917
  --migrate-js-confuser <file> Convert a JS-Confuser JSON or CommonJS config.
@@ -849,6 +920,11 @@ Options:
849
920
  --competitor-gap-report Print covered/partial/gap parity against common JS obfuscators.
850
921
  --explain-compat <option> Explain how one javascript-obfuscator option is handled.
851
922
  --explain-js-confuser-compat <option> Explain how one JS-Confuser option is handled.
923
+ --local Protect on this machine with the bundled jso-local
924
+ executable instead of sending source to the hosted API.
925
+ Windows only; the plan check still runs online (no source).
926
+ --local-exe <path> Path to cli/jso-local.exe (else JSO_LOCAL_EXE, else the
927
+ usual desktop install locations).
852
928
  --local-only Print local/offline workflow guidance and exit.
853
929
  --verify-manifest <file> Verify protected output against a written manifest.
854
930
  --verify-root <path> Override manifest output paths with a different artifact root.
@@ -899,6 +975,19 @@ Options:
899
975
  --options-preset <name> Map javascript-obfuscator preset names.
900
976
  --string-array [bool] Map javascript-obfuscator string array extraction.
901
977
  --string-array-encoding <value> Map base64/rc4 string encoding.
978
+ --string-array-index-shift [bool] Add a nonzero moved-string table offset.
979
+ --string-array-shuffle [bool] Randomize moved-string table order and preserve lookups.
980
+ --string-array-rotate [bool] Rotate moved-string table order by a per-build offset.
981
+ --string-array-indexes-type <types> Use hexadecimal-number and/or hexadecimal-numeric-string lookups.
982
+ --string-array-calls-transform [bool] Add secondary index-table indirection.
983
+ --string-array-calls-transform-threshold <n> Set indirection probability from 0 through 1.
984
+ --string-array-wrappers-count <n> Generate 0-10 root-level wrappers.
985
+ --string-array-wrappers-chained-calls [bool] Chain wrappers through predecessors.
986
+ --string-array-wrappers-parameters-max-count <n> Set function-wrapper parameters from 2 through 5.
987
+ --string-array-wrappers-type <type> Use variable or function wrappers.
988
+ --transform-object-keys [bool] Move safe data keys into computed string-table lookups.
989
+ --split-strings [bool] Split eligible literals into fixed-length chunks.
990
+ --split-strings-chunk-length <n> Set chunk length from 1 through 1024 (default 10).
902
991
  --control-flow-flattening [bool] Map control-flow flattening.
903
992
  --dead-code-injection [bool] Map dead code injection.
904
993
  --dead-code-injection-threshold <n> Map dead-code level.
@@ -914,8 +1003,16 @@ Options:
914
1003
  --identifier-names-cache-path <file> Accept identifier cache path for migration review.
915
1004
  --identifiers-dictionary <list> Accept identifier dictionary naming for migration review.
916
1005
  --identifiers-prefix <value> Accept identifier prefix naming for migration review.
917
- --self-defending [bool] Accept tamper-defense flag for migration review.
918
- --debug-protection [bool] Accept anti-debugging flag for migration review.
1006
+ --self-defending [bool] Map to the hosted SelfDefending runtime guard.
1007
+ --self-defending-interval-seconds <n> Repeat integrity checks every 1-86400 seconds.
1008
+ --self-healing [bool] Enable bounded local recovery after a self-defending check fails.
1009
+ --self-healing-max-attempts <n> Limit local recovery attempts (1-10).
1010
+ --anti-monkey-patching [bool] Detect replacement of selected browser APIs.
1011
+ --anti-monkey-patching-clean-realm [bool] Compare startup APIs with a same-origin clean realm.
1012
+ --runtime-defense-action <action> Set throw, blank, redirect, reload, callback, or degrade.
1013
+ --runtime-defense-callback <path> Set the dotted global callback path.
1014
+ --runtime-defense-redirect-url <url> Set an HTTP(S) or root-relative redirect target.
1015
+ --debug-protection [bool] Map to the hosted DebugProtection runtime guard.
919
1016
  --strict-mode <bool|null> Accept strict-mode assumptions for migration review.
920
1017
  --rename-properties-mode <value> Accept property rename mode for migration review.
921
1018
  --manifest <file> Write a JSON protection manifest after a successful run.
@@ -997,6 +1094,8 @@ function parseArgs(argv) {
997
1094
  explainCompat: null,
998
1095
  explainJsConfuserCompat: null,
999
1096
  localOnly: false,
1097
+ local: null,
1098
+ localExe: null,
1000
1099
  verifyManifest: null,
1001
1100
  verifyRoot: null,
1002
1101
  auditSourceMaps: false,
@@ -1135,6 +1234,12 @@ function parseArgs(argv) {
1135
1234
  case "--explain-js-confuser-compat":
1136
1235
  args.explainJsConfuserCompat = requireValue(argv, ++i, arg);
1137
1236
  break;
1237
+ case "--local":
1238
+ args.local = true;
1239
+ break;
1240
+ case "--local-exe":
1241
+ args.localExe = requireValue(argv, ++i, arg);
1242
+ break;
1138
1243
  case "--local-only":
1139
1244
  args.localOnly = true;
1140
1245
  break;
@@ -1326,7 +1431,11 @@ function parseArgs(argv) {
1326
1431
  addStringArrayEncodingOption(args, requireValue(argv, ++i, arg));
1327
1432
  break;
1328
1433
  case "--string-array-threshold":
1329
- args.options.push(`MoveStrings=${Number(requireValue(argv, ++i, arg)) > 0}`);
1434
+ {
1435
+ const threshold = normalizeProbability(requireValue(argv, ++i, arg), arg);
1436
+ args.options.push(`MoveStrings=${threshold > 0}`);
1437
+ args.options.push(`StringArrayThreshold=${threshold}`);
1438
+ }
1330
1439
  break;
1331
1440
  case "--dead-code-injection-threshold":
1332
1441
  args.options.push(`DeadcodeLevel=${deadCodeLevelFromThreshold(requireValue(argv, ++i, arg))}`);
@@ -1343,32 +1452,110 @@ function parseArgs(argv) {
1343
1452
  args.compatibilityWarnings.push("--domain-lock was mapped to LockDomain and LockDomainList; review subdomain and redirect behavior.");
1344
1453
  break;
1345
1454
  case "--domain-lock-redirect-url":
1346
- addCompatibilityReviewField(args, "domainLockRedirectUrl");
1347
- args.compatibilityWarnings.push("--domain-lock-redirect-url has no direct hosted API equivalent; review LockDomainMsg or application-level redirect handling.");
1348
- i += consumeCompatibilityValue(argv, i + 1, arg);
1455
+ args.options.push(`LockDomainRedirectUrl=${normalizeRuntimeRedirectUrl(requireValue(argv, ++i, arg), "--domain-lock-redirect-url")}`);
1349
1456
  break;
1350
1457
  case "--self-defending":
1351
- if (addReviewOnlyBooleanFlag(args, argv, i + 1, arg, "Self-defending has no one-to-one hosted API flag; review tamper-defense requirements manually.")) {
1352
- addCompatibilityReviewField(args, "selfDefending");
1458
+ args.options.push(`SelfDefending=${readOptionalBoolean(argv, i + 1)}`);
1459
+ if (hasOptionalValue(argv, i + 1)) i += 1;
1460
+ break;
1461
+ case "--self-defending-interval-seconds": {
1462
+ const seconds = Number(requireValue(argv, ++i, arg));
1463
+ if (!Number.isInteger(seconds) || seconds < 1 || seconds > 86400) {
1464
+ throw new Error("--self-defending-interval-seconds must be an integer from 1 through 86400");
1353
1465
  }
1354
- i += consumeCompatibilityValue(argv, i + 1, arg);
1466
+ args.options.push(`SelfDefendingIntervalSeconds=${seconds}`);
1355
1467
  break;
1356
- case "--debug-protection":
1357
- if (addReviewOnlyBooleanFlag(args, argv, i + 1, arg, "Debug protection has no one-to-one hosted API flag; review anti-debugging requirements manually.")) {
1358
- addCompatibilityReviewField(args, "debugProtection");
1468
+ }
1469
+ case "--self-healing":
1470
+ args.options.push(`SelfHealing=${readOptionalBoolean(argv, i + 1)}`);
1471
+ if (hasOptionalValue(argv, i + 1)) i += 1;
1472
+ break;
1473
+ case "--self-healing-max-attempts": {
1474
+ const attempts = Number(requireValue(argv, ++i, arg));
1475
+ if (!Number.isInteger(attempts) || attempts < 1 || attempts > 10) {
1476
+ throw new Error("--self-healing-max-attempts must be an integer from 1 through 10");
1359
1477
  }
1360
- i += consumeCompatibilityValue(argv, i + 1, arg);
1478
+ args.options.push(`SelfHealingMaxAttempts=${attempts}`);
1479
+ break;
1480
+ }
1481
+ case "--anti-monkey-patching":
1482
+ args.options.push(`AntiMonkeyPatching=${readOptionalBoolean(argv, i + 1)}`);
1483
+ if (hasOptionalValue(argv, i + 1)) i += 1;
1484
+ break;
1485
+ case "--anti-monkey-patching-clean-realm":
1486
+ args.options.push(`AntiMonkeyPatchingCleanRealm=${readOptionalBoolean(argv, i + 1)}`);
1487
+ if (hasOptionalValue(argv, i + 1)) i += 1;
1488
+ break;
1489
+ case "--runtime-defense-action": {
1490
+ const action = requireValue(argv, ++i, arg).toLowerCase();
1491
+ if (!["throw", "blank", "redirect", "reload", "callback", "degrade"].includes(action)) {
1492
+ throw new Error("--runtime-defense-action must be throw, blank, redirect, reload, callback, or degrade");
1493
+ }
1494
+ args.options.push(`RuntimeDefenseAction=${action}`);
1495
+ break;
1496
+ }
1497
+ case "--runtime-defense-callback":
1498
+ args.options.push(`RuntimeDefenseCallback=${requireValue(argv, ++i, arg)}`);
1499
+ break;
1500
+ case "--runtime-defense-redirect-url":
1501
+ args.options.push(`RuntimeDefenseRedirectUrl=${requireValue(argv, ++i, arg)}`);
1502
+ break;
1503
+ case "--debug-protection":
1504
+ args.options.push(`DebugProtection=${readOptionalBoolean(argv, i + 1)}`);
1505
+ if (hasOptionalValue(argv, i + 1)) i += 1;
1361
1506
  break;
1362
1507
  case "--debug-protection-interval":
1363
- addCompatibilityReviewField(args, "debugProtectionInterval");
1364
- args.compatibilityWarnings.push("--debug-protection-interval has no one-to-one hosted API flag; review anti-debugging requirements manually.");
1365
- i += consumeCompatibilityValue(argv, i + 1, arg);
1508
+ args.options.push(`DebugProtectionIntervalMilliseconds=${normalizeDebugProtectionInterval(requireValue(argv, ++i, arg), "--debug-protection-interval")}`);
1366
1509
  break;
1367
1510
  case "--disable-console-output":
1368
- if (addReviewOnlyBooleanFlag(args, argv, i + 1, arg, "Console suppression has no direct hosted API option; handle console policy in application code.")) {
1369
- addCompatibilityReviewField(args, "disableConsoleOutput");
1370
- }
1371
- i += consumeCompatibilityValue(argv, i + 1, arg);
1511
+ args.options.push(`DisableConsoleOutput=${readOptionalBoolean(argv, i + 1)}`);
1512
+ if (hasOptionalValue(argv, i + 1)) i += 1;
1513
+ break;
1514
+ case "--split-strings":
1515
+ args.options.push(`SplitStrings=${readOptionalBoolean(argv, i + 1)}`);
1516
+ if (hasOptionalValue(argv, i + 1)) i += 1;
1517
+ break;
1518
+ case "--split-strings-chunk-length":
1519
+ args.options.push(`SplitStringsChunkLength=${normalizeSplitStringsChunkLength(requireValue(argv, ++i, arg), arg)}`);
1520
+ break;
1521
+ case "--string-array-index-shift":
1522
+ args.options.push(`StringArrayIndexShift=${readOptionalBoolean(argv, i + 1)}`);
1523
+ if (hasOptionalValue(argv, i + 1)) i += 1;
1524
+ break;
1525
+ case "--string-array-shuffle":
1526
+ args.options.push(`StringArrayShuffle=${readOptionalBoolean(argv, i + 1)}`);
1527
+ if (hasOptionalValue(argv, i + 1)) i += 1;
1528
+ break;
1529
+ case "--string-array-rotate":
1530
+ args.options.push(`StringArrayRotate=${readOptionalBoolean(argv, i + 1)}`);
1531
+ if (hasOptionalValue(argv, i + 1)) i += 1;
1532
+ break;
1533
+ case "--string-array-indexes-type":
1534
+ args.options.push(`StringArrayIndexesType=${normalizeStringArrayIndexesType(requireValue(argv, ++i, arg), arg).join("\n")}`);
1535
+ break;
1536
+ case "--string-array-calls-transform":
1537
+ args.options.push(`StringArrayCallsTransform=${readOptionalBoolean(argv, i + 1)}`);
1538
+ if (hasOptionalValue(argv, i + 1)) i += 1;
1539
+ break;
1540
+ case "--string-array-calls-transform-threshold":
1541
+ args.options.push(`StringArrayCallsTransformThreshold=${normalizeProbability(requireValue(argv, ++i, arg), arg)}`);
1542
+ break;
1543
+ case "--string-array-wrappers-count":
1544
+ args.options.push(`StringArrayWrappersCount=${normalizeIntegerRange(requireValue(argv, ++i, arg), arg, 0, 10)}`);
1545
+ break;
1546
+ case "--string-array-wrappers-chained-calls":
1547
+ args.options.push(`StringArrayWrappersChainedCalls=${readOptionalBoolean(argv, i + 1)}`);
1548
+ if (hasOptionalValue(argv, i + 1)) i += 1;
1549
+ break;
1550
+ case "--string-array-wrappers-parameters-max-count":
1551
+ args.options.push(`StringArrayWrappersParametersMaxCount=${normalizeIntegerRange(requireValue(argv, ++i, arg), arg, 2, 5)}`);
1552
+ break;
1553
+ case "--string-array-wrappers-type":
1554
+ args.options.push(`StringArrayWrappersType=${normalizeStringArrayWrappersType(requireValue(argv, ++i, arg))}`);
1555
+ break;
1556
+ case "--transform-object-keys":
1557
+ args.options.push(`TransformObjectKeys=${readOptionalBoolean(argv, i + 1)}`);
1558
+ if (hasOptionalValue(argv, i + 1)) i += 1;
1372
1559
  break;
1373
1560
  case "--source-map":
1374
1561
  addCompatibilityReviewField(args, "sourceMap");
@@ -1404,26 +1591,20 @@ function parseArgs(argv) {
1404
1591
  i += consumeCompatibilityValue(argv, i + 1, arg);
1405
1592
  break;
1406
1593
  case "--reserved-strings":
1594
+ args.options.push(`ReservedStrings=${normalizeReservedStringPatterns(requireValue(argv, ++i, arg), arg).join("\n")}`);
1595
+ break;
1407
1596
  case "--force-transform-strings":
1597
+ args.options.push(`ForceTransformStrings=${normalizeReservedStringPatterns(requireValue(argv, ++i, arg), arg).join("\n")}`);
1598
+ break;
1599
+ case "--numbers-to-expressions":
1600
+ args.options.push(`EncodeNumbers=${readOptionalBoolean(argv, i + 1)}`);
1601
+ if (hasOptionalValue(argv, i + 1)) i += 1;
1602
+ break;
1408
1603
  case "--input-file-name":
1409
1604
  case "--log":
1410
- case "--numbers-to-expressions":
1411
1605
  case "--rename-properties-mode":
1412
1606
  case "--simplify":
1413
1607
  case "--strict-mode":
1414
- case "--split-strings":
1415
- case "--split-strings-chunk-length":
1416
- case "--string-array-calls-transform":
1417
- case "--string-array-calls-transform-threshold":
1418
- case "--string-array-index-shift":
1419
- case "--string-array-indexes-type":
1420
- case "--string-array-rotate":
1421
- case "--string-array-shuffle":
1422
- case "--string-array-wrappers-count":
1423
- case "--string-array-wrappers-chained-calls":
1424
- case "--string-array-wrappers-parameters-max-count":
1425
- case "--string-array-wrappers-type":
1426
- case "--transform-object-keys":
1427
1608
  addCompatibilityReviewField(args, cliArgToReviewField(arg));
1428
1609
  args.compatibilityWarnings.push(`${arg} was accepted for migration compatibility but has no direct hosted API mapping; review output before release.`);
1429
1610
  i += consumeCompatibilityValue(argv, i + 1, arg);
@@ -1674,6 +1855,76 @@ function deadCodeLevelFromThreshold(value) {
1674
1855
  return number >= 0.66 ? "High" : number >= 0.33 ? "Medium" : "Low";
1675
1856
  }
1676
1857
 
1858
+ function normalizeDebugProtectionInterval(value, label = "debugProtectionInterval") {
1859
+ const number = Number(value);
1860
+ if (!Number.isInteger(number) || number < 0 || (number > 0 && number < 100) || number > 60000) {
1861
+ throw new Error(`${label} must be 0 or an integer from 100 through 60000 milliseconds`);
1862
+ }
1863
+ return number;
1864
+ }
1865
+
1866
+ function normalizeRuntimeRedirectUrl(value, label = "domainLockRedirectUrl") {
1867
+ const text = String(value || "").trim();
1868
+ const safeRelative = text.startsWith("/") && !text.startsWith("//") && !text.includes("\\");
1869
+ let safeAbsolute = false;
1870
+ try {
1871
+ const parsed = new URL(text);
1872
+ safeAbsolute = parsed.protocol === "https:" || parsed.protocol === "http:";
1873
+ } catch { }
1874
+ if (!safeRelative && !safeAbsolute) throw new Error(`${label} must be an HTTP(S) URL or same-origin root-relative path`);
1875
+ return text;
1876
+ }
1877
+
1878
+ function normalizeSeedValue(value, label = "seed") {
1879
+ if ((typeof value !== "string" && typeof value !== "number") || (typeof value === "number" && !Number.isFinite(value))) {
1880
+ throw new Error(`${label} must be a finite number or non-empty string`);
1881
+ }
1882
+ const text = String(value).trim();
1883
+ if (!text) throw new Error(`${label} must be a finite number or non-empty string`);
1884
+ return text;
1885
+ }
1886
+
1887
+ function normalizeSplitStringsChunkLength(value, label = "splitStringsChunkLength") {
1888
+ const number = Number(value);
1889
+ if (!Number.isInteger(number) || number < 1 || number > 1024) throw new Error(`${label} must be an integer from 1 through 1024`);
1890
+ return number;
1891
+ }
1892
+
1893
+ function normalizeProbability(value, label) {
1894
+ const number = Number(value);
1895
+ if (!Number.isFinite(number) || number < 0 || number > 1) throw new Error(`${label} must be a number from 0 through 1`);
1896
+ return number;
1897
+ }
1898
+
1899
+ function normalizeIntegerRange(value, label, minimum, maximum) {
1900
+ const number = Number(value);
1901
+ if (!Number.isInteger(number) || number < minimum || number > maximum) throw new Error(`${label} must be an integer from ${minimum} through ${maximum}`);
1902
+ return number;
1903
+ }
1904
+
1905
+ function normalizeStringArrayWrappersType(value) {
1906
+ const normalized = String(value || "").trim().toLowerCase();
1907
+ if (normalized !== "variable" && normalized !== "function") throw new Error("stringArrayWrappersType supports only variable or function");
1908
+ return normalized;
1909
+ }
1910
+
1911
+ function normalizeReservedStringPatterns(value, label = "reservedStrings") {
1912
+ const raw = Array.isArray(value) ? value : String(value || "").split(",");
1913
+ const patterns = raw.map((item) => String(item).trim()).filter(Boolean);
1914
+ if (patterns.length > 100) throw new Error(`${label} accepts at most 100 patterns`);
1915
+ if (patterns.some((pattern) => pattern.length > 512)) throw new Error(`${label} patterns must be at most 512 characters`);
1916
+ return patterns;
1917
+ }
1918
+
1919
+ function normalizeStringArrayIndexesType(value, label = "stringArrayIndexesType") {
1920
+ const raw = Array.isArray(value) ? value : String(value || "").split(",");
1921
+ const values = raw.map((item) => String(item).trim().toLowerCase()).filter(Boolean);
1922
+ if (!values.length) throw new Error(`${label} must include at least one supported value`);
1923
+ const supported = new Set(["hexadecimal-number", "hexadecimal-numeric-string"]);
1924
+ if (values.some((item) => !supported.has(item))) throw new Error(`${label} supports only hexadecimal-number and hexadecimal-numeric-string`);
1925
+ return [...new Set(values)];
1926
+ }
1927
+
1677
1928
  function identityStyleFromGenerator(value) {
1678
1929
  return String(value || "").toLowerCase().includes("hex") ? "v1hex" : "v2abcd";
1679
1930
  }
@@ -1697,12 +1948,34 @@ function translateJavascriptObfuscatorConfigOptions(source = {}) {
1697
1948
  }
1698
1949
 
1699
1950
  mapBooleanConfigOption(source, "stringArray", translated.options, "MoveStrings");
1951
+ mapBooleanConfigOption(source, "stringArrayIndexShift", translated.options, "StringArrayIndexShift");
1952
+ mapBooleanConfigOption(source, "stringArrayShuffle", translated.options, "StringArrayShuffle");
1953
+ mapBooleanConfigOption(source, "stringArrayRotate", translated.options, "StringArrayRotate");
1954
+ if (source.stringArrayIndexesType !== undefined) translated.options.StringArrayIndexesType = normalizeStringArrayIndexesType(source.stringArrayIndexesType).join("\n");
1955
+ mapBooleanConfigOption(source, "stringArrayCallsTransform", translated.options, "StringArrayCallsTransform");
1956
+ if (source.stringArrayCallsTransformThreshold !== undefined) translated.options.StringArrayCallsTransformThreshold = normalizeProbability(source.stringArrayCallsTransformThreshold, "stringArrayCallsTransformThreshold");
1957
+ if (source.stringArrayWrappersCount !== undefined) translated.options.StringArrayWrappersCount = normalizeIntegerRange(source.stringArrayWrappersCount, "stringArrayWrappersCount", 0, 10);
1958
+ mapExplicitBooleanConfigOption(source, "stringArrayWrappersChainedCalls", translated.options, "StringArrayWrappersChainedCalls");
1959
+ if (source.stringArrayWrappersParametersMaxCount !== undefined) translated.options.StringArrayWrappersParametersMaxCount = normalizeIntegerRange(source.stringArrayWrappersParametersMaxCount, "stringArrayWrappersParametersMaxCount", 2, 5);
1960
+ if (source.stringArrayWrappersType !== undefined) translated.options.StringArrayWrappersType = normalizeStringArrayWrappersType(source.stringArrayWrappersType);
1961
+ mapBooleanConfigOption(source, "transformObjectKeys", translated.options, "TransformObjectKeys");
1962
+ mapBooleanConfigOption(source, "splitStrings", translated.options, "SplitStrings");
1963
+ if (source.splitStringsChunkLength !== undefined) translated.options.SplitStringsChunkLength = normalizeSplitStringsChunkLength(source.splitStringsChunkLength);
1700
1964
  mapBooleanConfigOption(source, "unicodeEscapeSequence", translated.options, "EncodeStrings");
1701
1965
  mapBooleanConfigOption(source, "controlFlowFlattening", translated.options, "DeepObfuscate");
1702
1966
  mapBooleanConfigOption(source, "controlFlowFlattening", translated.options, "FlatTransform");
1703
1967
  mapBooleanConfigOption(source, "deadCodeInjection", translated.options, "AddDeadCode");
1704
1968
  mapBooleanConfigOption(source, "renameGlobals", translated.options, "RenameGlobals");
1705
1969
  mapBooleanConfigOption(source, "renameProperties", translated.options, "RenameMembers");
1970
+ mapExplicitBooleanConfigOption(source, "selfDefending", translated.options, "SelfDefending");
1971
+ mapExplicitBooleanConfigOption(source, "debugProtection", translated.options, "DebugProtection");
1972
+ if (source.debugProtectionInterval !== undefined) translated.options.DebugProtectionIntervalMilliseconds = normalizeDebugProtectionInterval(source.debugProtectionInterval);
1973
+ mapExplicitBooleanConfigOption(source, "disableConsoleOutput", translated.options, "DisableConsoleOutput");
1974
+ mapExplicitBooleanConfigOption(source, "numbersToExpressions", translated.options, "EncodeNumbers");
1975
+ if (source.domainLockRedirectUrl !== undefined) translated.options.LockDomainRedirectUrl = normalizeRuntimeRedirectUrl(source.domainLockRedirectUrl);
1976
+ if (source.seed !== undefined) translated.options.Seed = normalizeSeedValue(source.seed);
1977
+ if (source.reservedStrings !== undefined) translated.options.ReservedStrings = normalizeReservedStringPatterns(source.reservedStrings).join("\n");
1978
+ if (source.forceTransformStrings !== undefined) translated.options.ForceTransformStrings = normalizeReservedStringPatterns(source.forceTransformStrings, "forceTransformStrings").join("\n");
1706
1979
 
1707
1980
  if (source.stringArrayEncoding !== undefined) {
1708
1981
  const encodings = Array.isArray(source.stringArrayEncoding) ? source.stringArrayEncoding : [source.stringArrayEncoding];
@@ -1713,8 +1986,10 @@ function translateJavascriptObfuscatorConfigOptions(source = {}) {
1713
1986
  }
1714
1987
  }
1715
1988
 
1716
- if (source.stringArrayThreshold !== undefined && Number(source.stringArrayThreshold) > 0) {
1717
- translated.options.MoveStrings = true;
1989
+ if (source.stringArrayThreshold !== undefined) {
1990
+ const threshold = normalizeProbability(source.stringArrayThreshold, "stringArrayThreshold");
1991
+ translated.options.StringArrayThreshold = threshold;
1992
+ if (source.stringArray !== false) translated.options.MoveStrings = threshold > 0;
1718
1993
  }
1719
1994
 
1720
1995
  if (source.deadCodeInjectionThreshold !== undefined) {
@@ -1783,9 +2058,12 @@ function translateJsConfuserConfigOptions(source = {}) {
1783
2058
  mapBooleanConfigOption(source, "stringEncoding", translated.options, "EncodeStrings");
1784
2059
  mapBooleanConfigOption(source, "stringConcealing", translated.options, "EncryptStrings");
1785
2060
  mapBooleanConfigOption(source, "duplicateLiteralsRemoval", translated.options, "MoveStrings");
2061
+ if (typeof source.stringSplitting === "function") throw new Error("stringSplitting selector functions require manual migration review");
2062
+ if (source.stringSplitting !== undefined) translated.options.SplitStrings = jsConfuserLockEnabled(source.stringSplitting);
1786
2063
  mapBooleanConfigOption(source, "controlFlowFlattening", translated.options, "DeepObfuscate");
1787
2064
  mapBooleanConfigOption(source, "controlFlowFlattening", translated.options, "FlatTransform");
1788
2065
  mapBooleanConfigOption(source, "deadCode", translated.options, "AddDeadCode");
2066
+ mapExplicitBooleanConfigOption(source, "hexadecimalNumbers", translated.options, "EncodeNumbers");
1789
2067
 
1790
2068
  if (source.stringCompression === true || source.minify === true || source.compact === true) {
1791
2069
  translated.options.SelfCompression = true;
@@ -1815,13 +2093,42 @@ function translateJsConfuserConfigOptions(source = {}) {
1815
2093
  translated.options.LockDate = true;
1816
2094
  translated.options.LockDateValue = formatLockDateValue(lock.endDate);
1817
2095
  }
2096
+ mapJsConfuserRuntimeLocks(lock, translated.options);
1818
2097
  }
1819
2098
 
2099
+ if (source.jsConfuserLockAntiDebug !== undefined) translated.options.DebugProtection = jsConfuserLockEnabled(source.jsConfuserLockAntiDebug);
2100
+ if (source.jsConfuserLockIntegrity !== undefined || source.jsConfuserLockSelfDefending !== undefined) {
2101
+ translated.options.SelfDefending = jsConfuserLockEnabled(source.jsConfuserLockIntegrity) || jsConfuserLockEnabled(source.jsConfuserLockSelfDefending);
2102
+ }
2103
+ if (source.jsConfuserLockStartDate !== undefined) {
2104
+ translated.options.LockStartDate = true;
2105
+ translated.options.LockStartDateValue = formatLockDateValue(source.jsConfuserLockStartDate);
2106
+ }
2107
+ if (source.jsConfuserLockTamperProtection !== undefined) translated.options.AntiMonkeyPatching = jsConfuserLockEnabled(source.jsConfuserLockTamperProtection);
2108
+
1820
2109
  return translated;
1821
2110
  }
1822
2111
 
2112
+ function jsConfuserLockEnabled(value) {
2113
+ return value === true || (typeof value === "number" && Number.isFinite(value) && value > 0);
2114
+ }
2115
+
2116
+ function mapJsConfuserRuntimeLocks(lock, target) {
2117
+ if (!lock || typeof lock !== "object") return;
2118
+ if (lock.antiDebug !== undefined) target.DebugProtection = jsConfuserLockEnabled(lock.antiDebug);
2119
+ if (lock.integrity !== undefined || lock.selfDefending !== undefined) {
2120
+ target.SelfDefending = jsConfuserLockEnabled(lock.integrity) || jsConfuserLockEnabled(lock.selfDefending);
2121
+ }
2122
+ if (lock.startDate !== undefined) {
2123
+ target.LockStartDate = true;
2124
+ target.LockStartDateValue = formatLockDateValue(lock.startDate);
2125
+ }
2126
+ if (lock.tamperProtection !== undefined) target.AntiMonkeyPatching = jsConfuserLockEnabled(lock.tamperProtection);
2127
+ }
2128
+
1823
2129
  function hasJsConfuserCompatibilityOptions(source = {}) {
1824
2130
  if (!source || typeof source !== "object") return false;
2131
+ if (JS_CONFUSER_CONFIG_MAPPED_FIELDS.some((key) => Object.prototype.hasOwnProperty.call(source, key))) return true;
1825
2132
  if (JS_CONFUSER_DETECT_KEYS.some((key) => Object.prototype.hasOwnProperty.call(source, key))) {
1826
2133
  return true;
1827
2134
  }
@@ -1851,6 +2158,10 @@ function mapBooleanConfigOption(source, sourceKey, target, targetKey) {
1851
2158
  if (source[sourceKey] === true) target[targetKey] = true;
1852
2159
  }
1853
2160
 
2161
+ function mapExplicitBooleanConfigOption(source, sourceKey, target, targetKey) {
2162
+ if (typeof source[sourceKey] === "boolean") target[targetKey] = source[sourceKey];
2163
+ }
2164
+
1854
2165
  function presetFromJavascriptObfuscatorPreset(value) {
1855
2166
  const normalized = String(value || "").trim().toLowerCase().replace(/[\s_]+/g, "-");
1856
2167
  if (
@@ -2057,6 +2368,12 @@ function mergeConfig(config, args = {}) {
2057
2368
  maxOutputBytes: args.maxOutputBytes || config.maxOutputBytes || null,
2058
2369
  maxGrowthRatio: args.maxGrowthRatio || config.maxGrowthRatio || null,
2059
2370
  removeSourceMaps: config.removeSourceMaps !== false,
2371
+ // Source-local protection: run the bundled jso-local executable instead of
2372
+ // POSTing source to the hosted endpoint. The plan/option check still goes
2373
+ // online (source-free); only the source body stays on this machine.
2374
+ local: args.local !== undefined && args.local !== null ? !!args.local : !!config.local,
2375
+ localExe: args.localExe || config.localExe || readEnv(["JSO_LOCAL_EXE"]) || null,
2376
+ namedSets: (config.namedSets && typeof config.namedSets === "object" && !Array.isArray(config.namedSets)) ? config.namedSets : null,
2060
2377
  options
2061
2378
  };
2062
2379
 
@@ -2076,6 +2393,7 @@ function mergeConfig(config, args = {}) {
2076
2393
  validateStringArray("markupExtensions", merged.markupExtensions);
2077
2394
  validateStringArray("exclude", merged.exclude);
2078
2395
  validateStringArray("assetExclude", merged.assetExclude);
2396
+ validateNamedSets(merged.namedSets);
2079
2397
 
2080
2398
  merged.input = resolvePath(baseDir, merged.input);
2081
2399
  merged.output = resolvePath(baseDir, merged.output);
@@ -2389,12 +2707,77 @@ function migrateJavascriptObfuscatorConfig(sourcePath, args = {}) {
2389
2707
  }
2390
2708
 
2391
2709
  mapBooleanOption(sourceConfig, "stringArray", config.options, "MoveStrings", mapped);
2710
+ mapBooleanOption(sourceConfig, "stringArrayIndexShift", config.options, "StringArrayIndexShift", mapped);
2711
+ mapBooleanOption(sourceConfig, "stringArrayShuffle", config.options, "StringArrayShuffle", mapped);
2712
+ mapBooleanOption(sourceConfig, "stringArrayRotate", config.options, "StringArrayRotate", mapped);
2713
+ if (sourceConfig.stringArrayIndexesType !== undefined) {
2714
+ config.options.StringArrayIndexesType = normalizeStringArrayIndexesType(sourceConfig.stringArrayIndexesType).join("\n");
2715
+ mapped.push({ from: "stringArrayIndexesType", to: "StringArrayIndexesType" });
2716
+ }
2717
+ mapBooleanOption(sourceConfig, "stringArrayCallsTransform", config.options, "StringArrayCallsTransform", mapped);
2718
+ if (sourceConfig.stringArrayCallsTransformThreshold !== undefined) {
2719
+ config.options.StringArrayCallsTransformThreshold = normalizeProbability(sourceConfig.stringArrayCallsTransformThreshold, "stringArrayCallsTransformThreshold");
2720
+ mapped.push({ from: "stringArrayCallsTransformThreshold", to: "StringArrayCallsTransformThreshold" });
2721
+ }
2722
+ if (sourceConfig.stringArrayWrappersCount !== undefined) {
2723
+ config.options.StringArrayWrappersCount = normalizeIntegerRange(sourceConfig.stringArrayWrappersCount, "stringArrayWrappersCount", 0, 10);
2724
+ mapped.push({ from: "stringArrayWrappersCount", to: "StringArrayWrappersCount", note: "Root-level wrapper count maps with a 0-10 bound; review per-scope placement differences." });
2725
+ }
2726
+ if (sourceConfig.stringArrayWrappersChainedCalls !== undefined) {
2727
+ if (typeof sourceConfig.stringArrayWrappersChainedCalls !== "boolean") throw new Error("stringArrayWrappersChainedCalls must be a boolean");
2728
+ config.options.StringArrayWrappersChainedCalls = sourceConfig.stringArrayWrappersChainedCalls;
2729
+ mapped.push({ from: "stringArrayWrappersChainedCalls", to: "StringArrayWrappersChainedCalls" });
2730
+ }
2731
+ if (sourceConfig.stringArrayWrappersParametersMaxCount !== undefined) {
2732
+ config.options.StringArrayWrappersParametersMaxCount = normalizeIntegerRange(sourceConfig.stringArrayWrappersParametersMaxCount, "stringArrayWrappersParametersMaxCount", 2, 5);
2733
+ mapped.push({ from: "stringArrayWrappersParametersMaxCount", to: "StringArrayWrappersParametersMaxCount" });
2734
+ }
2735
+ if (sourceConfig.stringArrayWrappersType !== undefined) {
2736
+ config.options.StringArrayWrappersType = normalizeStringArrayWrappersType(sourceConfig.stringArrayWrappersType);
2737
+ mapped.push({ from: "stringArrayWrappersType", to: "StringArrayWrappersType" });
2738
+ }
2739
+ mapBooleanOption(sourceConfig, "transformObjectKeys", config.options, "TransformObjectKeys", mapped);
2740
+ mapBooleanOption(sourceConfig, "splitStrings", config.options, "SplitStrings", mapped);
2741
+ if (sourceConfig.splitStringsChunkLength !== undefined) {
2742
+ config.options.SplitStringsChunkLength = normalizeSplitStringsChunkLength(sourceConfig.splitStringsChunkLength);
2743
+ mapped.push({ from: "splitStringsChunkLength", to: "SplitStringsChunkLength", note: "String split chunk length maps directly." });
2744
+ }
2392
2745
  mapBooleanOption(sourceConfig, "unicodeEscapeSequence", config.options, "EncodeStrings", mapped);
2393
2746
  mapBooleanOption(sourceConfig, "controlFlowFlattening", config.options, "FlatTransform", mapped);
2394
2747
  mapBooleanOption(sourceConfig, "controlFlowFlattening", config.options, "DeepObfuscate", mapped);
2395
2748
  mapBooleanOption(sourceConfig, "deadCodeInjection", config.options, "AddDeadCode", mapped);
2396
2749
  mapBooleanOption(sourceConfig, "renameGlobals", config.options, "RenameGlobals", mapped);
2397
2750
  mapBooleanOption(sourceConfig, "renameProperties", config.options, "RenameMembers", mapped);
2751
+ mapBooleanOption(sourceConfig, "selfDefending", config.options, "SelfDefending", mapped);
2752
+ mapBooleanOption(sourceConfig, "debugProtection", config.options, "DebugProtection", mapped);
2753
+ if (sourceConfig.debugProtectionInterval !== undefined) {
2754
+ config.options.DebugProtectionIntervalMilliseconds = normalizeDebugProtectionInterval(sourceConfig.debugProtectionInterval);
2755
+ mapped.push({ from: "debugProtectionInterval", to: "DebugProtectionIntervalMilliseconds", note: "Debug timing interval mapped in milliseconds." });
2756
+ }
2757
+ if (typeof sourceConfig.disableConsoleOutput === "boolean") {
2758
+ config.options.DisableConsoleOutput = sourceConfig.disableConsoleOutput;
2759
+ mapped.push({ from: "disableConsoleOutput", to: "DisableConsoleOutput", note: "Console suppression maps directly." });
2760
+ }
2761
+ if (typeof sourceConfig.numbersToExpressions === "boolean") {
2762
+ config.options.EncodeNumbers = sourceConfig.numbersToExpressions;
2763
+ mapped.push({ from: "numbersToExpressions", to: "EncodeNumbers", note: "Numeric literals map to native numeric encoding; expression shape is not preserved." });
2764
+ }
2765
+ if (sourceConfig.domainLockRedirectUrl !== undefined) {
2766
+ config.options.LockDomainRedirectUrl = normalizeRuntimeRedirectUrl(sourceConfig.domainLockRedirectUrl);
2767
+ mapped.push({ from: "domainLockRedirectUrl", to: "LockDomainRedirectUrl", note: "Domain-lock-specific redirect maps directly after scheme validation." });
2768
+ }
2769
+ if (sourceConfig.seed !== undefined) {
2770
+ config.options.Seed = normalizeSeedValue(sourceConfig.seed);
2771
+ mapped.push({ from: "seed", to: "Seed", note: "Deterministic seed maps directly; omit it for per-build polymorphism." });
2772
+ }
2773
+ if (sourceConfig.reservedStrings !== undefined) {
2774
+ config.options.ReservedStrings = normalizeReservedStringPatterns(sourceConfig.reservedStrings).join("\n");
2775
+ mapped.push({ from: "reservedStrings", to: "ReservedStrings", note: "Matching literals remain verbatim outside move/encode transforms." });
2776
+ }
2777
+ if (sourceConfig.forceTransformStrings !== undefined) {
2778
+ config.options.ForceTransformStrings = normalizeReservedStringPatterns(sourceConfig.forceTransformStrings, "forceTransformStrings").join("\n");
2779
+ mapped.push({ from: "forceTransformStrings", to: "ForceTransformStrings", note: "Matching literals override ReservedStrings and pass through enabled string transforms." });
2780
+ }
2398
2781
 
2399
2782
  if (sourceConfig.stringArrayEncoding !== undefined) {
2400
2783
  const encodings = Array.isArray(sourceConfig.stringArrayEncoding) ? sourceConfig.stringArrayEncoding : [sourceConfig.stringArrayEncoding];
@@ -2407,9 +2790,11 @@ function migrateJavascriptObfuscatorConfig(sourcePath, args = {}) {
2407
2790
  }
2408
2791
  }
2409
2792
 
2410
- if (sourceConfig.stringArrayThreshold !== undefined && Number(sourceConfig.stringArrayThreshold) > 0) {
2411
- config.options.MoveStrings = true;
2412
- mapped.push({ from: "stringArrayThreshold", to: "MoveStrings", note: "Threshold values are not one-to-one; review output size and behavior." });
2793
+ if (sourceConfig.stringArrayThreshold !== undefined) {
2794
+ const threshold = normalizeProbability(sourceConfig.stringArrayThreshold, "stringArrayThreshold");
2795
+ config.options.StringArrayThreshold = threshold;
2796
+ if (sourceConfig.stringArray !== false) config.options.MoveStrings = threshold > 0;
2797
+ mapped.push({ from: "stringArrayThreshold", to: "StringArrayThreshold", note: "Per-unique-literal probability maps directly; zero disables moved strings." });
2413
2798
  }
2414
2799
 
2415
2800
  if (sourceConfig.deadCodeInjectionThreshold !== undefined) {
@@ -2469,17 +2854,41 @@ function migrateJavascriptObfuscatorConfig(sourcePath, args = {}) {
2469
2854
 
2470
2855
  const handled = new Set([
2471
2856
  "compact",
2857
+ "selfDefending",
2858
+ "debugProtection",
2859
+ "debugProtectionInterval",
2860
+ "disableConsoleOutput",
2472
2861
  "controlFlowFlattening",
2473
2862
  "deadCodeInjection",
2474
2863
  "deadCodeInjectionThreshold",
2475
2864
  "domainLock",
2865
+ "domainLockRedirectUrl",
2476
2866
  "identifierNamesGenerator",
2477
2867
  "optionsPreset",
2478
2868
  "parseHtml",
2479
2869
  "renameGlobals",
2480
2870
  "renameProperties",
2871
+ "selfDefending",
2872
+ "debugProtection",
2481
2873
  "reservedNames",
2874
+ "seed",
2875
+ "reservedStrings",
2876
+ "forceTransformStrings",
2877
+ "numbersToExpressions",
2482
2878
  "stringArray",
2879
+ "splitStrings",
2880
+ "splitStringsChunkLength",
2881
+ "stringArrayIndexShift",
2882
+ "stringArrayShuffle",
2883
+ "stringArrayRotate",
2884
+ "stringArrayIndexesType",
2885
+ "stringArrayCallsTransform",
2886
+ "stringArrayCallsTransformThreshold",
2887
+ "stringArrayWrappersCount",
2888
+ "stringArrayWrappersChainedCalls",
2889
+ "stringArrayWrappersParametersMaxCount",
2890
+ "stringArrayWrappersType",
2891
+ "transformObjectKeys",
2483
2892
  "stringArrayEncoding",
2484
2893
  "stringArrayThreshold",
2485
2894
  "target",
@@ -2562,9 +2971,20 @@ function migrateJsConfuserConfig(sourcePath, args = {}) {
2562
2971
  mapBooleanOption(sourceConfig, "stringEncoding", config.options, "EncodeStrings", mapped);
2563
2972
  mapBooleanOption(sourceConfig, "stringConcealing", config.options, "EncryptStrings", mapped);
2564
2973
  mapBooleanOption(sourceConfig, "duplicateLiteralsRemoval", config.options, "MoveStrings", mapped);
2974
+ if (sourceConfig.stringSplitting !== undefined && typeof sourceConfig.stringSplitting !== "function") {
2975
+ config.options.SplitStrings = jsConfuserLockEnabled(sourceConfig.stringSplitting);
2976
+ mapped.push({ from: "stringSplitting", to: "SplitStrings", note: "String-splitting probability collapses to enabled/disabled; native chunk length defaults to 10." });
2977
+ }
2978
+ if (typeof sourceConfig.stringSplitting === "function") {
2979
+ review.push({ option: "stringSplitting", note: "Custom selector functions cannot be serialized or mapped one-to-one; review literal-selection policy manually." });
2980
+ }
2565
2981
  mapBooleanOption(sourceConfig, "controlFlowFlattening", config.options, "FlatTransform", mapped);
2566
2982
  mapBooleanOption(sourceConfig, "controlFlowFlattening", config.options, "DeepObfuscate", mapped);
2567
2983
  mapBooleanOption(sourceConfig, "deadCode", config.options, "AddDeadCode", mapped);
2984
+ if (typeof sourceConfig.hexadecimalNumbers === "boolean") {
2985
+ config.options.EncodeNumbers = sourceConfig.hexadecimalNumbers;
2986
+ mapped.push({ from: "hexadecimalNumbers", to: "EncodeNumbers", note: "Numeric literals map to native numeric encoding; hexadecimal formatting is not guaranteed." });
2987
+ }
2568
2988
 
2569
2989
  if (sourceConfig.stringCompression === true || sourceConfig.minify === true || sourceConfig.compact === true) {
2570
2990
  config.options.SelfCompression = true;
@@ -2601,22 +3021,28 @@ function migrateJsConfuserConfig(sourcePath, args = {}) {
2601
3021
  mapped.push({ from: "lock.endDate", to: "LockDateValue", note: "End-date locks map to LockDate and LockDateValue." });
2602
3022
  }
2603
3023
  if (lock.antiDebug !== undefined) {
2604
- config.jsConfuserLockAntiDebug = lock.antiDebug;
3024
+ config.options.DebugProtection = jsConfuserLockEnabled(lock.antiDebug);
3025
+ mapped.push({ from: "lock.antiDebug", to: "DebugProtection", note: "Anti-debug enablement maps to the native debugger guard; numeric probability collapses to enabled/disabled." });
2605
3026
  }
2606
3027
  if (lock.integrity !== undefined) {
2607
- config.jsConfuserLockIntegrity = lock.integrity;
3028
+ config.options.SelfDefending = jsConfuserLockEnabled(lock.integrity) || config.options.SelfDefending === true;
3029
+ mapped.push({ from: "lock.integrity", to: "SelfDefending", note: "Integrity enablement maps to native self-integrity monitoring; numeric probability collapses to enabled/disabled." });
2608
3030
  }
2609
3031
  if (lock.selfDefending !== undefined) {
2610
- config.jsConfuserLockSelfDefending = lock.selfDefending;
3032
+ config.options.SelfDefending = jsConfuserLockEnabled(lock.selfDefending) || config.options.SelfDefending === true;
3033
+ mapped.push({ from: "lock.selfDefending", to: "SelfDefending", note: "Self-defending enablement maps to native self-integrity monitoring." });
2611
3034
  }
2612
3035
  if (lock.startDate !== undefined) {
2613
- config.jsConfuserLockStartDate = formatLockDateValue(lock.startDate);
3036
+ config.options.LockStartDate = true;
3037
+ config.options.LockStartDateValue = formatLockDateValue(lock.startDate);
3038
+ mapped.push({ from: "lock.startDate", to: "LockStartDateValue", note: "Start-date locks map to LockStartDate and LockStartDateValue; validate the activation boundary in the target browser." });
2614
3039
  }
2615
3040
  if (lock.countermeasures !== undefined) {
2616
3041
  config.jsConfuserLockCountermeasures = formatReviewString(lock.countermeasures);
2617
3042
  }
2618
3043
  if (lock.tamperProtection !== undefined) {
2619
- config.jsConfuserLockTamperProtection = lock.tamperProtection;
3044
+ config.options.AntiMonkeyPatching = jsConfuserLockEnabled(lock.tamperProtection);
3045
+ mapped.push({ from: "lock.tamperProtection", to: "AntiMonkeyPatching", note: "Tamper-protection enablement maps to security-relevant global integrity checks; numeric probability collapses to enabled/disabled." });
2620
3046
  }
2621
3047
 
2622
3048
  for (const [key, note] of Object.entries(JS_CONFUSER_REVIEW_OPTIONS)) {
@@ -2637,11 +3063,18 @@ function migrateJsConfuserConfig(sourcePath, args = {}) {
2637
3063
 
2638
3064
  const handled = new Set([
2639
3065
  "compact",
3066
+ "selfDefending",
3067
+ "debugProtection",
3068
+ "debugProtectionInterval",
3069
+ "debugProtectionIntervalMilliseconds",
3070
+ "disableConsoleOutput",
3071
+ "domainLockRedirectUrl",
2640
3072
  "controlFlowFlattening",
2641
3073
  "deadCode",
2642
3074
  "duplicateLiteralsRemoval",
2643
3075
  "globalConcealing",
2644
3076
  "identifierGenerator",
3077
+ "hexadecimalNumbers",
2645
3078
  "lock",
2646
3079
  "minify",
2647
3080
  "preset",
@@ -2650,6 +3083,7 @@ function migrateJsConfuserConfig(sourcePath, args = {}) {
2650
3083
  "stringCompression",
2651
3084
  "stringConcealing",
2652
3085
  "stringEncoding",
3086
+ "stringSplitting",
2653
3087
  "target",
2654
3088
  ...Object.keys(JS_CONFUSER_REVIEW_OPTIONS).filter((key) => !key.startsWith("lock."))
2655
3089
  ]);
@@ -2796,7 +3230,14 @@ function buildMigrationReportSummary(sourceConfig, mapped, review, unmapped) {
2796
3230
  }
2797
3231
 
2798
3232
  function buildMigrationReportSummaryFromMap(sourceConfig, mapped, review, unmapped, migrationMap) {
2799
- const sourceOptions = Object.keys(sourceConfig || {}).length;
3233
+ const sourceKeys = Object.keys(sourceConfig || {});
3234
+ const lock = sourceConfig && sourceConfig.lock && typeof sourceConfig.lock === "object" && !Array.isArray(sourceConfig.lock)
3235
+ ? sourceConfig.lock
3236
+ : null;
3237
+ // JS-Confuser's lock bag is a namespace, not one option. Count each lock
3238
+ // leaf so mappedOptions and automaticCoverage use the same unit and can
3239
+ // never report impossible >100% coverage.
3240
+ const sourceOptions = sourceKeys.filter((key) => key !== "lock").length + (lock ? Object.keys(lock).length : (sourceKeys.includes("lock") ? 1 : 0));
2800
3241
  const mappedSources = Array.from(new Set((mapped || []).map((item) => item.from)));
2801
3242
  const confidenceBySource = new Map((migrationMap || []).map((entry) => [entry.source, entry.confidence]));
2802
3243
  const direct = mappedSources.filter((source) => confidenceBySource.get(source) === "direct").length;
@@ -3082,6 +3523,108 @@ function collectFiles(inputPath, outputPath, extensions, excludePatterns, includ
3082
3523
  return files;
3083
3524
  }
3084
3525
 
3526
+ // ── Named configuration sets ──────────────────────────────────────────────
3527
+ //
3528
+ // The granularity layer between "one option set per project" and the
3529
+ // per-function markers (@virtualize, protect-begin/end): apply a different
3530
+ // protection profile to different parts of one app in a single build. The
3531
+ // config surface, schema and pure resolver (config/named-sets.js, tested in
3532
+ // test/named-sets.test.js) predate this wiring — this is where they finally
3533
+ // reach the protect flow. Semantics are the resolver's: FIRST matching set
3534
+ // wins per file (write sets in priority order), a set's options merge on top
3535
+ // of the baseline, and a set's preset contributes that preset's option block
3536
+ // before the set's own options. Files matching no set keep the baseline.
3537
+ //
3538
+ // Each named set becomes its own API round; the hosted plan gate prices each
3539
+ // round on the options it actually carries, so a "maximum" set on a plan
3540
+ // that cannot afford it fails THAT group with the normal API error and the
3541
+ // other groups are untouched.
3542
+
3543
+ function hasNamedSets(config) {
3544
+ return !!(config && config.namedSets && Object.keys(config.namedSets).length);
3545
+ }
3546
+
3547
+ function validateNamedSets(sets) {
3548
+ if (sets === null || sets === undefined) return;
3549
+ if (typeof sets !== "object" || Array.isArray(sets)) throw new Error("namedSets must be an object of named set definitions.");
3550
+ for (const name of Object.keys(sets)) {
3551
+ const set = sets[name];
3552
+ if (!set || typeof set !== "object" || Array.isArray(set)) throw new Error(`namedSets.${name} must be an object.`);
3553
+ if (!Array.isArray(set.match) || !set.match.length || set.match.some((p) => typeof p !== "string" || !p.length)) {
3554
+ throw new Error(`namedSets.${name}.match must be a non-empty array of glob strings.`);
3555
+ }
3556
+ if (set.preset !== undefined && !Object.prototype.hasOwnProperty.call(PRESET_OPTIONS, String(set.preset).toLowerCase())) {
3557
+ throw new Error(`namedSets.${name}.preset "${set.preset}" is unknown. Use standard, balanced, or maximum.`);
3558
+ }
3559
+ if (set.options !== undefined && (typeof set.options !== "object" || set.options === null || Array.isArray(set.options))) {
3560
+ throw new Error(`namedSets.${name}.options must be an object of API option values.`);
3561
+ }
3562
+ for (const key of Object.keys(set)) {
3563
+ if (key !== "match" && key !== "preset" && key !== "options" && key !== "countermeasures") {
3564
+ throw new Error(`namedSets.${name} has unknown key "${key}" (allowed: match, preset, options, countermeasures).`);
3565
+ }
3566
+ }
3567
+ }
3568
+ }
3569
+
3570
+ function groupFilesByNamedSets(config, files) {
3571
+ const resolved = namedSetsResolver.resolveForFiles(config, files.map((file) => file.relative));
3572
+ const groups = new Map();
3573
+ for (const file of files) {
3574
+ const resolution = resolved[file.relative];
3575
+ const key = resolution.set || "";
3576
+ if (!groups.has(key)) groups.set(key, { setName: resolution.set, files: [] });
3577
+ groups.get(key).files.push(file);
3578
+ }
3579
+ return Array.from(groups.values());
3580
+ }
3581
+
3582
+ function applyNamedSetToConfig(config, setName) {
3583
+ if (!setName) return config;
3584
+ const set = config.namedSets[setName];
3585
+ const presetName = set.preset ? String(set.preset).toLowerCase() : null;
3586
+ const presetOptions = presetName ? PRESET_OPTIONS[presetName] || {} : {};
3587
+ const groupConfig = {
3588
+ ...config,
3589
+ preset: presetName || config.preset,
3590
+ options: { ...config.options, ...presetOptions, ...(set.options || {}) }
3591
+ };
3592
+ if (set.countermeasures !== undefined) groupConfig.countermeasures = set.countermeasures;
3593
+ return groupConfig;
3594
+ }
3595
+
3596
+ // Runs one protection round per named-set group and writes each group's
3597
+ // outputs as it completes. Returns a MERGED result whose Items span every
3598
+ // group (file names are relative paths, disjoint across groups, so no
3599
+ // collisions), with the first group's Report kept as .Report for shape
3600
+ // compatibility and every group's report collected in .Reports.
3601
+ async function protectGroupedFiles(config, files) {
3602
+ validateNamedSets(config.namedSets);
3603
+ const groups = groupFilesByNamedSets(config, files);
3604
+ const merged = { Type: "Succeed", Items: [], Report: null, Reports: [] };
3605
+ const transforms = new Map();
3606
+ const groupSummaries = [];
3607
+ for (const group of groups) {
3608
+ const groupConfig = applyNamedSetToConfig(config, group.setName);
3609
+ const groupProtection = buildProtectionItems(groupConfig, group.files);
3610
+ const groupResult = await protectItems(groupConfig, groupProtection.items);
3611
+ writeResults(group.files, groupResult, groupProtection.transforms, groupConfig);
3612
+ merged.Items.push(...(groupResult.Items || []));
3613
+ if (groupResult.Report) {
3614
+ merged.Reports.push(groupResult.Report);
3615
+ if (!merged.Report) merged.Report = groupResult.Report;
3616
+ }
3617
+ for (const [name, transform] of groupProtection.transforms) transforms.set(name, transform);
3618
+ groupSummaries.push({
3619
+ set: group.setName,
3620
+ files: group.files.map((file) => file.relative),
3621
+ preset: groupConfig.preset,
3622
+ options: Object.keys(groupConfig.options).filter((key) => key !== "reservedNames").sort()
3623
+ });
3624
+ }
3625
+ return { result: merged, transforms, groups: groupSummaries };
3626
+ }
3627
+
3085
3628
  function collectAssets(inputPath, outputPath, protectedFiles, assetExcludePatterns) {
3086
3629
  const assets = [];
3087
3630
  if (!fs.existsSync(inputPath) || fs.statSync(inputPath).isFile()) {
@@ -3907,11 +4450,87 @@ function buildRequestFromItems(config, items) {
3907
4450
  return project;
3908
4451
  }
3909
4452
 
4453
+ // Where jso-local.exe lives when the customer unzipped the desktop download.
4454
+ // Checked in order after --local-exe and JSO_LOCAL_EXE; the point is that a CI
4455
+ // step which already installs the desktop archive needs no extra configuration.
4456
+ const LOCAL_EXE_CANDIDATES = [
4457
+ "C:/Program Files/JavaScript Obfuscator/cli/jso-local.exe",
4458
+ "C:/Tools/JSObfuscator/cli/jso-local.exe",
4459
+ "./javascriptobfuscator/cli/jso-local.exe",
4460
+ "./cli/jso-local.exe"
4461
+ ];
4462
+
4463
+ function resolveLocalExe(config) {
4464
+ if (config.localExe) {
4465
+ const explicit = path.resolve(config.localExe);
4466
+ if (!fs.existsSync(explicit)) {
4467
+ throw new Error(`Local protector not found at ${explicit}. Point --local-exe (or JSO_LOCAL_EXE) at cli/jso-local.exe from the desktop download.`);
4468
+ }
4469
+ return explicit;
4470
+ }
4471
+ for (const candidate of LOCAL_EXE_CANDIDATES) {
4472
+ const resolved = path.resolve(candidate);
4473
+ if (fs.existsSync(resolved)) return resolved;
4474
+ }
4475
+ throw new Error(
4476
+ "--local needs the jso-local executable, which ships in the Windows desktop download " +
4477
+ "(https://javascriptobfuscator.com/downloads.aspx) under cli/jso-local.exe. " +
4478
+ "Set JSO_LOCAL_EXE or pass --local-exe <path>."
4479
+ );
4480
+ }
4481
+
4482
+ // Run the protection locally instead of POSTing it. The payload and the
4483
+ // response are the hosted API's own shapes, so this is a transport swap:
4484
+ // everything downstream (manifests, evidence, budgets) is unchanged, and an
4485
+ // option that works hosted works here because jso-local deserializes the same
4486
+ // project object the server does.
4487
+ async function runLocalProtector(config, payload) {
4488
+ const exe = resolveLocalExe(config);
4489
+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), "jso-local-"));
4490
+ const payloadPath = path.join(dir, "request.json");
4491
+ const responsePath = path.join(dir, "response.json");
4492
+ try {
4493
+ fs.writeFileSync(payloadPath, JSON.stringify(payload), "utf8");
4494
+ const args = ["--http-project", payloadPath, "--response", responsePath, "--quiet"];
4495
+
4496
+ // Node refuses to spawn .cmd/.bat directly (the 2024 batch-file argument
4497
+ // injection fix), and a wrapper script is a legitimate thing for a CI step
4498
+ // to point at. Route those through cmd.exe with the path as a separate
4499
+ // ARGUMENT rather than a concatenated command string, so a path containing
4500
+ // shell characters cannot become a command.
4501
+ const isBatch = /\.(cmd|bat)$/i.test(exe);
4502
+ const run = isBatch
4503
+ ? spawnSync(process.env.ComSpec || "cmd.exe", ["/d", "/s", "/c", exe, ...args], {
4504
+ encoding: "utf8",
4505
+ maxBuffer: 256 * 1024 * 1024
4506
+ })
4507
+ : spawnSync(exe, args, {
4508
+ encoding: "utf8",
4509
+ maxBuffer: 256 * 1024 * 1024
4510
+ });
4511
+ if (run.error) {
4512
+ throw new Error(`Could not run the local protector (${exe}): ${run.error.message}`);
4513
+ }
4514
+ if (!fs.existsSync(responsePath)) {
4515
+ const detail = (run.stderr || run.stdout || "").trim().slice(0, 300);
4516
+ throw new Error(`The local protector wrote no response${detail ? `: ${detail}` : "."}`);
4517
+ }
4518
+ return JSON.parse(fs.readFileSync(responsePath, "utf8"));
4519
+ } finally {
4520
+ // The payload holds the customer's source and their credentials. It exists
4521
+ // only for the length of one exec and is removed even when that exec fails.
4522
+ try { fs.rmSync(dir, { recursive: true, force: true }); } catch { /* best effort */ }
4523
+ }
4524
+ }
4525
+
3910
4526
  async function protectItems(config, items) {
3911
4527
  assertReady(config);
3912
4528
  if (!items.length) return { Type: "Succeed", Items: [] };
3913
4529
 
3914
- const result = await postJson(config.endpoint, buildRequestFromItems(config, items));
4530
+ const payload = buildRequestFromItems(config, items);
4531
+ const result = config.local
4532
+ ? await runLocalProtector(config, payload)
4533
+ : await postJson(config.endpoint, payload);
3915
4534
  if (result.Type !== "Succeed") {
3916
4535
  throw new Error(formatApiFailure({
3917
4536
  type: result.Type,
@@ -3966,7 +4585,7 @@ function readStdin(stream = process.stdin) {
3966
4585
  async function postJson(endpoint, payload) {
3967
4586
  const response = await fetch(endpoint, {
3968
4587
  method: "POST",
3969
- headers: { "Content-Type": "text/json" },
4588
+ headers: { "Content-Type": "application/json" },
3970
4589
  body: JSON.stringify(payload)
3971
4590
  });
3972
4591
 
@@ -4250,9 +4869,9 @@ async function runDoctor(config, args = {}) {
4250
4869
  addDoctorCheck(checks, "transforms", true, "Conditional comments and marked HTML scripts are ready.");
4251
4870
  const compatibility = scanCompatibilityRisks(config);
4252
4871
  if (compatibility.summary.findings) {
4253
- addDoctorCheck(checks, "compatibility", true, `Compatibility scan found ${compatibility.summary.findings} potential reflection risk(s) in ${compatibility.summary.filesWithFindings} file(s). Run --compat-scan --json for details.`);
4872
+ addDoctorCheck(checks, "compatibility", true, `Compatibility scan found ${compatibility.summary.findings} potential source-contract or reflection risk(s) in ${compatibility.summary.filesWithFindings} file(s). Run --compat-scan --json for details.`);
4254
4873
  } else {
4255
- addDoctorCheck(checks, "compatibility", true, "Compatibility scan found no known reflection risks.");
4874
+ addDoctorCheck(checks, "compatibility", true, "Compatibility scan found no known source-contract or reflection risks.");
4256
4875
  }
4257
4876
  } catch (error) {
4258
4877
  addDoctorCheck(checks, "files", false, "", error.message);
@@ -4504,7 +5123,7 @@ function buildCompetitorGapReviewAssistant(summary, capabilities, limitations, r
4504
5123
  function buildCompetitorGapPlan(capabilities, limitations) {
4505
5124
  const plan = [
4506
5125
  "Use balanced or maximum preset as the migration baseline for string, name, dead-code, and control-flow coverage.",
4507
- "Run --validate-config and --competitor-gap-report as separate CI preflight commands for migrated competitor configs so review-only runtime-defense fields stay visible.",
5126
+ "Run --validate-config and --competitor-gap-report as separate CI preflight commands for migrated competitor configs so interval, countermeasure, and vendor-specific runtime-defense differences stay visible.",
4508
5127
  "Use --label, --report, --watermark, and --sign-release to cover release attribution and artifact verification."
4509
5128
  ];
4510
5129
  if (limitations.some((item) => item.id === "runtime-self-defending")) {
@@ -4517,7 +5136,7 @@ function buildCompetitorGapPlan(capabilities, limitations) {
4517
5136
  plan.push("Replace identifier-cache repeatability assumptions with explicit reserved-name reviews, saved API reports, and protected-build smoke tests for public API surfaces.");
4518
5137
  }
4519
5138
  if (capabilities.some((item) => item.id === "locks" && item.status !== "covered")) {
4520
- plan.push("Convert domain and end-date locks automatically, then review browser, OS, start-date, and custom lock needs separately.");
5139
+ plan.push("Convert domain, start-date, and end-date locks automatically; map browser/OS policies to LockBrowser/LockOS explicitly, then review custom countermeasure needs separately.");
4521
5140
  }
4522
5141
  return plan;
4523
5142
  }
@@ -5827,13 +6446,10 @@ function summarizeRuntimeDefenseReviewField(config = {}, args = {}, field) {
5827
6446
 
5828
6447
  function runtimeDefenseReviewFieldGroup(field) {
5829
6448
  if (Object.prototype.hasOwnProperty.call(JS_CONFUSER_CONFIG_REVIEW_FIELDS, field)) return "js-confuser-runtime-lock";
5830
- if (field === "domainLockRedirectUrl") return "runtime-lock-redirect";
5831
- if (field === "disableConsoleOutput") return "console-policy";
5832
6449
  return "runtime-defense";
5833
6450
  }
5834
6451
 
5835
6452
  function runtimeDefenseReviewFieldRedaction(field) {
5836
- if (field === "domainLockRedirectUrl") return "Redirect URL value is omitted.";
5837
6453
  if (field === "jsConfuserLockStartDate") return "Start-date value is omitted.";
5838
6454
  if (field === "jsConfuserLockCountermeasures") return "Countermeasure value is omitted.";
5839
6455
  return "Runtime setting value is omitted.";
@@ -5856,8 +6472,9 @@ function summarizeRuntimeDefenseConfiguredEvidence(config = {}, args = {}) {
5856
6472
  domainLockConfigured: hasConfiguredRuntimeOption(config, args, [
5857
6473
  "LockDomain",
5858
6474
  "LockDomainList",
6475
+ "LockDomainRedirectUrl",
5859
6476
  "domainLock"
5860
- ]) || config.domainLock !== undefined,
6477
+ ]) || config.domainLock !== undefined || config.domainLockRedirectUrl !== undefined,
5861
6478
  dateLockConfigured: hasConfiguredRuntimeOption(config, args, [
5862
6479
  "LockDate",
5863
6480
  "LockDateValue",
@@ -5892,7 +6509,6 @@ function buildRuntimeDefenseReviewEvidence(context) {
5892
6509
  const requestedFields = context.requestedFields || [];
5893
6510
  const runtimeEvidence = context.runtimeEvidence || {};
5894
6511
  const reviewNeeded = context.reviewNeeded === true;
5895
- const redirectReview = requestedFields.some((field) => field.field === "domainLockRedirectUrl");
5896
6512
  const releaseMetadataReady = runtimeEvidence.apiReportConfigured && runtimeEvidence.manifestConfigured;
5897
6513
  return [
5898
6514
  {
@@ -5937,7 +6553,7 @@ function buildRuntimeDefenseReviewEvidence(context) {
5937
6553
  id: "mapped-domain-date-locks",
5938
6554
  status: (runtimeEvidence.domainLockConfigured || runtimeEvidence.dateLockConfigured)
5939
6555
  ? "evidenced"
5940
- : (redirectReview ? "needs-review" : "not-needed"),
6556
+ : "not-needed",
5941
6557
  currentEvidence: (runtimeEvidence.domainLockConfigured || runtimeEvidence.dateLockConfigured)
5942
6558
  ? "Domain or date lock options are configured; domain and date values are omitted."
5943
6559
  : "No mapped domain/date lock options are visible in this source-free review.",
@@ -6278,6 +6894,16 @@ const COMPATIBILITY_SCAN_RULES = [
6278
6894
  id: "name-reflection",
6279
6895
  pattern: /\.\s*name\b/g,
6280
6896
  message: "Name-based reflection can break because obfuscation renames function and class identifiers."
6897
+ },
6898
+ {
6899
+ id: "classic-script-public-global",
6900
+ pattern: /^(?:(?:\s+)|(?:\/\*[\s\S]*?\*\/)|(?:\/\/[^\r\n]*(?:\r?\n|$)))*var\s+(?<name>[A-Za-z_$][\w$]*)\s*=\s*\(?\s*function\b/g,
6901
+ message: "A browser distribution publishes a top-level global. Preserve this script-tag API when RenameGlobals is enabled."
6902
+ },
6903
+ {
6904
+ id: "assigned-public-global",
6905
+ pattern: /\b(?:window|globalThis|self)\s*\.\s*(?<name>[A-Za-z_$][\w$]*)\s*=/g,
6906
+ message: "Code assigns a public browser global. Preserve this external API when RenameGlobals is enabled."
6281
6907
  }
6282
6908
  ];
6283
6909
 
@@ -6309,12 +6935,15 @@ function scanTextCompatibilityRisks(fileName, code) {
6309
6935
  continue;
6310
6936
  }
6311
6937
  }
6938
+ const publicGlobalName = match.groups && match.groups.name ? match.groups.name : null;
6939
+ const locationIndex = publicGlobalName ? match.index + match[0].lastIndexOf(publicGlobalName) : match.index;
6312
6940
  findings.push({
6313
6941
  ruleId: rule.id,
6314
6942
  fileName,
6315
- line: findLineNumber(code, match.index),
6316
- snippet: buildSnippet(code, match.index, match[0].length),
6317
- message: rule.message
6943
+ line: findLineNumber(code, locationIndex),
6944
+ snippet: buildSnippet(code, locationIndex, publicGlobalName ? publicGlobalName.length : match[0].length),
6945
+ message: rule.message,
6946
+ ...(publicGlobalName ? { publicGlobalName, suggestedVariableExclusion: `^${publicGlobalName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}$` } : {})
6318
6947
  });
6319
6948
  match = rule.pattern.exec(code);
6320
6949
  }
@@ -6357,6 +6986,9 @@ function writeCompatibilityScanReport(report, json) {
6357
6986
  process.stdout.write(`files: ${report.summary.files}, findings: ${report.summary.findings}\n`);
6358
6987
  for (const finding of report.findings) {
6359
6988
  process.stdout.write(`WARN ${finding.fileName}:${finding.line} ${finding.ruleId}: ${finding.message}\n`);
6989
+ if (finding.suggestedVariableExclusion) {
6990
+ process.stdout.write(` Suggested VariableExclusion: ${finding.suggestedVariableExclusion}\n`);
6991
+ }
6360
6992
  }
6361
6993
  }
6362
6994
 
@@ -6513,6 +7145,21 @@ function validateProtectionConfig(config, args = {}) {
6513
7145
  addValidationCheck(checks, "options", "ok", "Option names match the local reference.");
6514
7146
  }
6515
7147
 
7148
+ const runtimeAction = String((resolved.options && resolved.options.RuntimeDefenseAction) || "").trim().toLowerCase();
7149
+ const runtimeRedirect = String((resolved.options && resolved.options.RuntimeDefenseRedirectUrl) || "").trim();
7150
+ if (runtimeAction === "redirect") {
7151
+ const safeRelative = runtimeRedirect.startsWith("/") && !runtimeRedirect.startsWith("//") && !runtimeRedirect.includes("\\");
7152
+ let safeAbsolute = false;
7153
+ try {
7154
+ const parsed = new URL(runtimeRedirect);
7155
+ safeAbsolute = parsed.protocol === "https:" || parsed.protocol === "http:";
7156
+ } catch { }
7157
+ addValidationCheck(checks, "runtimeDefenseRedirect", safeRelative || safeAbsolute ? "ok" : "error",
7158
+ safeRelative || safeAbsolute
7159
+ ? "Runtime defense redirect uses an HTTP(S) URL or same-origin root-relative path."
7160
+ : "RuntimeDefenseRedirectUrl must be an HTTP(S) URL or same-origin root-relative path when RuntimeDefenseAction is redirect.");
7161
+ }
7162
+
6516
7163
  const compatibilityReviewFields = getCompatibilityReviewFields(config);
6517
7164
  if (compatibilityReviewFields.length) {
6518
7165
  addValidationCheck(checks, "compatibility", "warning", `Config includes javascript-obfuscator review-only field(s): ${compatibilityReviewFields.join(", ")}. They are accepted for migration compatibility, but require manual review because the hosted API has no one-to-one mapping.`);
@@ -6551,6 +7198,12 @@ function validateRawConfigShape(config) {
6551
7198
  "output",
6552
7199
  "preset",
6553
7200
  "compact",
7201
+ "selfDefending",
7202
+ "debugProtection",
7203
+ "debugProtectionInterval",
7204
+ "debugProtectionIntervalMilliseconds",
7205
+ "disableConsoleOutput",
7206
+ "domainLockRedirectUrl",
6554
7207
  "controlFlowFlattening",
6555
7208
  "deadCodeInjection",
6556
7209
  "deadCodeInjectionThreshold",
@@ -6560,6 +7213,19 @@ function validateRawConfigShape(config) {
6560
7213
  "renameGlobals",
6561
7214
  "renameProperties",
6562
7215
  "stringArray",
7216
+ "splitStrings",
7217
+ "splitStringsChunkLength",
7218
+ "stringArrayIndexShift",
7219
+ "stringArrayShuffle",
7220
+ "stringArrayRotate",
7221
+ "stringArrayIndexesType",
7222
+ "stringArrayCallsTransform",
7223
+ "stringArrayCallsTransformThreshold",
7224
+ "stringArrayWrappersCount",
7225
+ "stringArrayWrappersChainedCalls",
7226
+ "stringArrayWrappersParametersMaxCount",
7227
+ "stringArrayWrappersType",
7228
+ "transformObjectKeys",
6563
7229
  "stringArrayEncoding",
6564
7230
  "stringArrayThreshold",
6565
7231
  "target",
@@ -6587,8 +7253,12 @@ function validateRawConfigShape(config) {
6587
7253
  "lockDate",
6588
7254
  "lockDateValue",
6589
7255
  "lockDateMessage",
7256
+ ...CONVENIENCE_OPTION_ALIASES.map((alias) => alias.configKey),
6590
7257
  ...Object.keys(JS_CONFUSER_CONFIG_REVIEW_FIELDS),
7258
+ ...JS_CONFUSER_CONFIG_MAPPED_FIELDS,
6591
7259
  "reservedNames",
7260
+ "reservedStrings",
7261
+ "forceTransformStrings",
6592
7262
  "variableExclusion",
6593
7263
  "removeSourceMaps",
6594
7264
  "manifest",
@@ -6611,6 +7281,48 @@ function validateRawConfigShape(config) {
6611
7281
  validateOptionalString("output", config.output);
6612
7282
  validateOptionalString("preset", config.preset);
6613
7283
  validateOptionalBoolean("compact", config.compact);
7284
+ validateOptionalBoolean("selfDefending", config.selfDefending);
7285
+ if (config.selfDefendingIntervalSeconds !== undefined && (!Number.isInteger(config.selfDefendingIntervalSeconds) || config.selfDefendingIntervalSeconds < 1 || config.selfDefendingIntervalSeconds > 86400)) {
7286
+ throw new Error("selfDefendingIntervalSeconds must be an integer from 1 through 86400.");
7287
+ }
7288
+ validateOptionalBoolean("selfHealing", config.selfHealing);
7289
+ if (config.selfHealingMaxAttempts !== undefined && (!Number.isInteger(config.selfHealingMaxAttempts) || config.selfHealingMaxAttempts < 1 || config.selfHealingMaxAttempts > 10)) {
7290
+ throw new Error("selfHealingMaxAttempts must be an integer from 1 through 10.");
7291
+ }
7292
+ validateOptionalBoolean("antiMonkeyPatching", config.antiMonkeyPatching);
7293
+ validateOptionalBoolean("antiMonkeyPatchingCleanRealm", config.antiMonkeyPatchingCleanRealm);
7294
+ validateOptionalString("antiMonkeyPatchingIncludeGlobals", config.antiMonkeyPatchingIncludeGlobals);
7295
+ validateOptionalString("antiMonkeyPatchingExcludeGlobals", config.antiMonkeyPatchingExcludeGlobals);
7296
+ validateOptionalString("runtimeDefenseAction", config.runtimeDefenseAction);
7297
+ if (config.runtimeDefenseAction !== undefined && !["throw", "blank", "redirect", "reload", "callback", "degrade"].includes(String(config.runtimeDefenseAction).toLowerCase())) {
7298
+ throw new Error("runtimeDefenseAction must be throw, blank, redirect, reload, callback, or degrade.");
7299
+ }
7300
+ validateOptionalString("runtimeDefenseCallback", config.runtimeDefenseCallback);
7301
+ validateOptionalString("runtimeDefenseRedirectUrl", config.runtimeDefenseRedirectUrl);
7302
+ validateOptionalBoolean("debugProtection", config.debugProtection);
7303
+ if (config.debugProtectionInterval !== undefined) normalizeDebugProtectionInterval(config.debugProtectionInterval);
7304
+ if (config.debugProtectionIntervalMilliseconds !== undefined) normalizeDebugProtectionInterval(config.debugProtectionIntervalMilliseconds, "debugProtectionIntervalMilliseconds");
7305
+ validateOptionalBoolean("disableConsoleOutput", config.disableConsoleOutput);
7306
+ validateOptionalBoolean("splitStrings", config.splitStrings);
7307
+ validateOptionalBoolean("stringArrayIndexShift", config.stringArrayIndexShift);
7308
+ validateOptionalBoolean("stringArrayShuffle", config.stringArrayShuffle);
7309
+ validateOptionalBoolean("stringArrayRotate", config.stringArrayRotate);
7310
+ if (config.stringArrayIndexesType !== undefined) normalizeStringArrayIndexesType(config.stringArrayIndexesType);
7311
+ validateOptionalBoolean("stringArrayCallsTransform", config.stringArrayCallsTransform);
7312
+ if (config.stringArrayCallsTransformThreshold !== undefined) normalizeProbability(config.stringArrayCallsTransformThreshold, "stringArrayCallsTransformThreshold");
7313
+ if (config.stringArrayWrappersCount !== undefined) normalizeIntegerRange(config.stringArrayWrappersCount, "stringArrayWrappersCount", 0, 10);
7314
+ validateOptionalBoolean("stringArrayWrappersChainedCalls", config.stringArrayWrappersChainedCalls);
7315
+ if (config.stringArrayWrappersParametersMaxCount !== undefined) normalizeIntegerRange(config.stringArrayWrappersParametersMaxCount, "stringArrayWrappersParametersMaxCount", 2, 5);
7316
+ if (config.stringArrayWrappersType !== undefined) normalizeStringArrayWrappersType(config.stringArrayWrappersType);
7317
+ validateOptionalBoolean("transformObjectKeys", config.transformObjectKeys);
7318
+ if (config.splitStringsChunkLength !== undefined) normalizeSplitStringsChunkLength(config.splitStringsChunkLength);
7319
+ if (config.stringSplitting !== undefined && !((typeof config.stringSplitting === "boolean") || (typeof config.stringSplitting === "number" && Number.isFinite(config.stringSplitting) && config.stringSplitting >= 0 && config.stringSplitting <= 1))) {
7320
+ throw new Error("stringSplitting must be a boolean or probability from 0 through 1; selector functions require manual migration review.");
7321
+ }
7322
+ if (config.domainLockRedirectUrl !== undefined) normalizeRuntimeRedirectUrl(config.domainLockRedirectUrl);
7323
+ if (config.seed !== undefined) normalizeSeedValue(config.seed);
7324
+ if (config.reservedStrings !== undefined) normalizeReservedStringPatterns(config.reservedStrings);
7325
+ if (config.forceTransformStrings !== undefined) normalizeReservedStringPatterns(config.forceTransformStrings, "forceTransformStrings");
6614
7326
  validateOptionalBoolean("controlFlowFlattening", config.controlFlowFlattening);
6615
7327
  validateOptionalBoolean("deadCodeInjection", config.deadCodeInjection);
6616
7328
  validateOptionalNonNegativeNumber("deadCodeInjectionThreshold", config.deadCodeInjectionThreshold);
@@ -6619,7 +7331,7 @@ function validateRawConfigShape(config) {
6619
7331
  validateOptionalBoolean("renameGlobals", config.renameGlobals);
6620
7332
  validateOptionalBoolean("renameProperties", config.renameProperties);
6621
7333
  validateOptionalBoolean("stringArray", config.stringArray);
6622
- validateOptionalNonNegativeNumber("stringArrayThreshold", config.stringArrayThreshold);
7334
+ if (config.stringArrayThreshold !== undefined) normalizeProbability(config.stringArrayThreshold, "stringArrayThreshold");
6623
7335
  validateOptionalString("target", config.target);
6624
7336
  validateOptionalBoolean("unicodeEscapeSequence", config.unicodeEscapeSequence);
6625
7337
  validateOptionalString("webPreset", config.webPreset);
@@ -11571,12 +12283,21 @@ async function main(argv = process.argv.slice(2)) {
11571
12283
  }
11572
12284
  }
11573
12285
 
11574
- const result = await protectItems(config, request.Items);
11575
-
11576
- writeResults(files, result, protection.transforms, config);
12286
+ let result;
12287
+ let manifestTransforms = protection.transforms;
12288
+ let overrideGroups = null;
12289
+ if (hasNamedSets(config)) {
12290
+ const grouped = await protectGroupedFiles(config, files);
12291
+ result = grouped.result;
12292
+ manifestTransforms = grouped.transforms;
12293
+ overrideGroups = grouped.groups;
12294
+ } else {
12295
+ result = await protectItems(config, request.Items);
12296
+ writeResults(files, result, protection.transforms, config);
12297
+ }
11577
12298
  copyAssets(assets);
11578
12299
  const manifestPath = config.manifest || null;
11579
- const manifest = buildProtectionManifest(config, files, assets, result, protection.transforms);
12300
+ const manifest = buildProtectionManifest(config, files, assets, result, manifestTransforms);
11580
12301
  assertSizeBudgets(manifest, config);
11581
12302
  writeManifest(manifestPath, manifest);
11582
12303
 
@@ -11627,7 +12348,14 @@ async function main(argv = process.argv.slice(2)) {
11627
12348
  buildId: (result.Report && result.Report.BuildId) || null,
11628
12349
  polymorphismFingerprint: (result.Report && result.Report.PolymorphismFingerprint) || null
11629
12350
  };
12351
+ if (overrideGroups) {
12352
+ done.namedSetGroups = overrideGroups;
12353
+ if (result.Reports && result.Reports.length > 1) {
12354
+ done.buildIds = result.Reports.map((report) => report.BuildId || null);
12355
+ }
12356
+ }
11630
12357
  if (args.json) process.stdout.write(`${JSON.stringify(done, null, 2)}\n`);
12358
+ else if (overrideGroups) process.stdout.write(`Protected ${files.length} file(s) in ${overrideGroups.length} named-set group(s) and copied ${assets.length} asset(s) into ${config.output}\n`);
11631
12359
  else process.stdout.write(`Protected ${files.length} file(s) and copied ${assets.length} asset(s) into ${config.output}\n`);
11632
12360
  }
11633
12361
 
@@ -11954,6 +12682,11 @@ module.exports = {
11954
12682
  writeRuntimeDefenseReviewReport,
11955
12683
  buildRequest,
11956
12684
  buildRequestFromItems,
12685
+ hasNamedSets,
12686
+ validateNamedSets,
12687
+ groupFilesByNamedSets,
12688
+ applyNamedSetToConfig,
12689
+ protectGroupedFiles,
11957
12690
  buildProtectionItems,
11958
12691
  buildProtectionItemsFromInputItems,
11959
12692
  describeProtectionTransforms,