jso-protector 0.4.8 → 0.4.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -61,6 +61,20 @@ and missing parity against common JavaScript obfuscators.
61
61
  - **Different profiles in one build.** `namedSets` maps file globs to their own
62
62
  preset and options, so a checkout flow can ship maximum protection while
63
63
  marketing pages stay on standard.
64
+ - **Nothing else comes with it.** Zero dependencies. Measured against
65
+ `javascript-obfuscator` 5.6.0 on a cold install, same machine, same day
66
+ (2026-09-01):
67
+
68
+ | | jso-protector | javascript-obfuscator |
69
+ |---|---|---|
70
+ | dependencies | **0** | 23 |
71
+ | `node_modules` directories | **3** | 120 |
72
+ | cold install | **1s** | 9s |
73
+ | on disk | **2 MB** | 56 MB |
74
+
75
+ Re-run it yourself; the numbers are the point, not the adjective. A tool you
76
+ add to a build to reduce risk should not widen the dependency surface it runs
77
+ in.
64
78
 
65
79
  Full option reference: [Docs / npm CLI](https://javascriptobfuscator.com/docs/npmcli.aspx)
66
80
  and [Docs / npm options](https://javascriptobfuscator.com/docs/npmoptions.aspx).
@@ -133,462 +147,101 @@ and `ai-resistance-evidence-report` outputs let CI upload source-free reviewer
133
147
  artifacts beside the protected build, while `build-id` and
134
148
  `polymorphism-fingerprint` remain available for runtime crash correlation.
135
149
 
136
- ## Payment-page evidence reports
137
-
138
- For checkout, wallet, subscription, activation, and license pages, pair the
139
- signed release manifest with a payment-page script inventory and Dashboard
140
- Monitoring incident history. Export runtime incidents CSV or JSON from the
141
- dashboard, keep a CSV or JSON list of payment-page scripts with authorization
142
- and written justification, and attach a payment-page security-header snapshot
143
- when reviewers ask for CSP/header change evidence. Include these source-free
144
- attachments in the PCI DSS v4 report. Start from
145
- `examples/payment-page-script-inventory.json` and
146
- `examples/payment-page-security-headers.json` when you need the expected JSON
147
- field names, or generate a review starter from a saved
148
- `third-party-inventory` runtime snapshot:
150
+ ## npm Scripts
149
151
 
150
- ```bash
151
- npx jso-protector \
152
- --script-inventory-from-snapshot reports/runtime-inventory.json \
153
- --script-inventory-output reports/payment-script-inventory.json
152
+ ```json
153
+ {
154
+ "scripts": {
155
+ "build": "vite build",
156
+ "preflight": "jso-protector --config jso.config.json --release-check --json",
157
+ "protect": "jso-protector --config jso.config.json",
158
+ "release": "npm run build && npm run preflight && npm run protect && npm run smoke"
159
+ }
160
+ }
154
161
  ```
155
162
 
156
- If your checkout evidence starts as a browser or synthetic-monitor HAR export,
157
- convert the document and iframe responses into the same source-free
158
- security-header snapshot. The converter keeps CSP, HSTS, frame/referrer policy,
159
- reporting endpoint, and related security headers, drops raw cookies and other
160
- non-security headers, and stores a SHA-256 over each canonical selected-header
161
- snapshot. Keep the last approved snapshot in your evidence repository and pass
162
- it as `--payment-page-headers-baseline` when you want the new HAR export to
163
- mark each checkout page or frame as `match`, `mismatch`, or `missing` for
164
- security-header change review. The generated snapshot also includes a
165
- source-free security-header Review Assistant Packet for BYO AI or internal
166
- reviewers. It focuses the review on baseline drift, CSP/reporting, HSTS, and
167
- frame-policy owner actions while reminding teams not to include
168
- raw response headers, cookies, source code, payment data, customer data, provider keys, or
169
- secrets.
163
+ ## Node API
170
164
 
171
- ```bash
172
- npx jso-protector \
173
- --payment-page-headers-from-har reports/checkout.har \
174
- --payment-page-headers-baseline reports/payment-page-headers.baseline.json \
175
- --payment-page-headers-output reports/payment-page-headers.json \
176
- --payment-page-url-pattern "checkout|payment|wallet"
177
- ```
165
+ Use the API when you want to protect code or release folders from a custom build script without spawning the CLI:
178
166
 
179
- Review the generated script inventory file before audit use. Set `authorized`, add written
180
- `justification`, assign `owner`, and fill `lastReviewedUtc` for every approved
181
- payment-page script. Add `risk`, `dataAccess`, and `approvalTicket` when your
182
- checkout review process tracks risk-based decisions or change approvals. Add
183
- `checkoutSurface`, `frameContext`, `frameOwner`, `parentPageHref`, `frameHref`,
184
- and `frameOrigin` when your payment flow has a parent page, hosted checkout
185
- page, PSP iframe, or embedded payment frame that reviewers need to distinguish.
186
- The
187
- audit packet fails only on blocking script drift or required metadata gaps; it
188
- also calls out missing optional review context so checkout owners can improve
189
- QSA handoff quality without breaking an otherwise clean release. Before handing
190
- the packet to reviewers, reconcile the approved inventory against a fresh
191
- runtime snapshot:
167
+ ```js
168
+ const { obfuscate, obfuscateMultiple, getOptionsByPreset, protectCode, protectFiles, planProtection } = require("jso-protector");
192
169
 
193
- ```bash
194
- npx jso-protector \
195
- --script-inventory-audit reports/payment-script-inventory.json \
196
- --runtime-inventory-snapshot reports/runtime-inventory.json \
197
- --script-inventory-audit-output reports/payment-script-inventory-audit.json \
198
- --json
199
- ```
170
+ const obfuscationResult = await obfuscate("console.log('release');", {
171
+ apiKey: process.env.JSO_API_KEY,
172
+ apiPassword: process.env.JSO_API_PASSWORD,
173
+ controlFlowFlattening: true,
174
+ identifierNamesGenerator: "hexadecimal",
175
+ reservedNames: ["^PublicApi$"],
176
+ stringArrayEncoding: ["rc4"]
177
+ }, "app.js");
200
178
 
201
- The audit is local and source-free. It reports unknown observed scripts,
202
- scripts observed while marked unauthorized, approved scripts missing from the
203
- page, hash mismatches, scripts injected after page load, runtime violation
204
- reasons, and missing inventory metadata. Omit `--json` or use a `.md` output
205
- path when a standalone human-readable packet is preferred.
179
+ console.log(obfuscationResult.getObfuscatedCode());
180
+ console.log(obfuscationResult.toString());
206
181
 
207
- In GitHub Actions, the bundled JSO action exposes the same audit,
208
- security-header snapshot, and PCI DSS v4 reviewer packet as opt-in workflow
209
- steps: set
210
- `payment-script-inventory`, `runtime-inventory-snapshot`, and optionally
211
- `script-inventory-audit-report` to fail the release job on payment-page script
212
- drift; set `payment-page-har`, optionally `payment-page-url-pattern`, and
213
- optionally `payment-page-headers-baseline` and `payment-page-headers-report` to
214
- convert a checkout HAR into the same source-free header evidence artifact and
215
- mark baseline matches, mismatches, or missing pages; set `pci-dss-v4-evidence` with
216
- `pci-dss-v4-report` and `pci-dss-v4-json-report` to assemble the Markdown and
217
- JSON PCI evidence report from the protected manifest plus those attachments.
218
- Use `manifest`, `sign-release-key`, `watermark`, and `watermark-key` when this
219
- report needs to pass rather than document incomplete evidence. The action adds
220
- a step summary and workflow annotations for the first audit, header, or PCI
221
- findings so reviewers can see drift directly in the CI run.
182
+ const multipleResults = await obfuscateMultiple({
183
+ "foo.js": "var foo = 1;",
184
+ "bar.js": "var bar = 2;"
185
+ }, {
186
+ apiKey: process.env.JSO_API_KEY,
187
+ apiPassword: process.env.JSO_API_PASSWORD,
188
+ ...getOptionsByPreset("balanced")
189
+ });
222
190
 
223
- ```bash
224
- npx jso-protector compliance pci-dss-v4 \
225
- --manifest dist-protected/jso-manifest.json.sig \
226
- --root dist-protected \
227
- --watermark-key "$JSO_WATERMARK_KEY" \
228
- --beacon-url "https://javascriptobfuscator.com/v1/runtime/beacon.ashx" \
229
- --siem splunk-hec \
230
- --script-inventory reports/payment-script-inventory.json \
231
- --script-inventory-audit reports/payment-script-inventory-audit.json \
232
- --payment-page-headers reports/payment-page-headers.json \
233
- --runtime-incidents reports/runtime-incidents.json \
234
- --organization "Example Corp" \
235
- --output reports/pci-dss-v4.md
236
- ```
191
+ console.log(multipleResults["foo.js"].getObfuscatedCode());
237
192
 
238
- The report hashes and summarizes these attachments, then adds a source-free PCI
239
- DSS Review Assistant for BYO AI or internal reviewers. The assistant turns
240
- evidence gaps, signed-release proof, script authorization, observed script
241
- drift, header change evidence, runtime incident routing, and QSA handoff
242
- boundaries into checkout-owner actions without sharing source code, protected
243
- output, raw script rows, raw response headers, raw incident payloads,
244
- payment-card data, provider keys, customer data, or secrets. Script inventory evidence is
245
- summarized by authorization, justification, owner, domain, review range, and
246
- integrity-reference coverage. When the inventory includes `risk`, `dataAccess`,
247
- `approvalTicket`, `checkoutSurface`, `frameContext`, and `frameOwner`, the
248
- report summarizes those fields, including iframe-scoped script counts, without
249
- embedding every script row. Security-header evidence is summarized by CSP,
250
- `script-src`, `frame-src`, reporting endpoint, HSTS, referrer-policy,
251
- baseline-hash match/mismatch/missing state, checkout surface, frame context, monitor, alert
252
- route, domain, observed range, and SHA-256 without embedding every raw page
253
- row. Runtime incident evidence is summarized by status, severity,
254
- open/reviewing count, per-incident next owner and due state, repeated-signal correlation, date range, Build IDs, and SHA-256. The Markdown does not
255
- embed every incident URL, user agent, script row, or raw header snapshot, so it
256
- can be handed to reviewers while the CSV or JSON exports remain the source-free
257
- attachments. The report supports QSA-led assessment; it is not itself a Report
258
- on Compliance.
259
- When a Dashboard Monitoring JSON export includes filters such as
260
- `runtime_status=active`, `runtime_severity=high-critical`, or
261
- `runtime_build=checkout-2026-06-07`, the report keeps that filter context in
262
- the runtime incident evidence table. The Dashboard JSON export also carries a
263
- source-free summary block with status/severity counts, active high-risk count,
264
- payload-hash coverage, BuildIDs, event/received date ranges, per-incident action-plan owner/due/status metadata, repeated fingerprint/reason groups, a routing
265
- recommendation, an alert routing playbook, and a response checklist before the incident rows. Dashboard
266
- Monitoring shows the same routing recommendation on the current filtered view
267
- before export, including response target, next status action, and playbook
268
- lanes for security response, customer-owned alerting, support handoff, and
269
- reviewer packets. The JSON export also includes source-free dashboard action
270
- metadata, such as the filtered "Move open in view to Reviewing" status action,
271
- plus per-row action plans that name the next owner, evidence packet, response due state, and status move, so support automation can tell account owners what to do next without scraping
272
- dashboard HTML. The PCI
273
- evidence report preserves those Dashboard JSON fields so support and reviewers
274
- can see whether the packet belongs in runtime triage, security response, or
275
- archive evidence. The response checklist and alert routing playbook carry
276
- owners, response targets, scope confirmation, downstream routing, and
277
- safe-sharing boundaries for reviewer
278
- or on-call handoff. A single-row Dashboard Monitoring Evidence JSON packet can also be passed to
279
- `--runtime-incidents` when the review is about one specific event.
193
+ const protectedCode = await protectCode({
194
+ apiKey: process.env.JSO_API_KEY,
195
+ apiPassword: process.env.JSO_API_PASSWORD,
196
+ preset: "balanced"
197
+ }, "console.log('release');", "app.js");
280
198
 
281
- For non-PCI runtime reviews, generate a standalone source-free handoff packet
282
- directly from the Dashboard Monitoring export:
199
+ const plan = planProtection({
200
+ input: "dist",
201
+ output: "dist-protected",
202
+ preset: "balanced",
203
+ exclude: ["**/*.map", "**/vendor/**", "**/*-obfuscated.js"]
204
+ });
283
205
 
284
- ```bash
285
- npx jso-protector \
286
- --runtime-incident-evidence reports/runtime-incidents.json \
287
- --runtime-incident-evidence-output reports/runtime-incident-evidence.md
206
+ console.log(`Protecting ${plan.summary.files.length} file(s).`);
207
+
208
+ await protectFiles({
209
+ apiKey: process.env.JSO_API_KEY,
210
+ apiPassword: process.env.JSO_API_PASSWORD,
211
+ input: "dist",
212
+ output: "dist-protected",
213
+ preset: "balanced",
214
+ manifest: "dist-protected/jso-manifest.json"
215
+ });
288
216
  ```
289
217
 
290
- The packet summarizes status and severity counts, active high/critical count,
291
- BuildIDs, per-incident action plans, repeated-signal correlation, routing recommendation, dashboard actions,
292
- response window, response checklist, alert routing playbook, export SHA-256, and safe-sharing boundaries.
293
- It also includes a source-free Runtime Incident Review Assistant for BYO AI or
294
- internal reviewers, with prompts for urgent response, repeated-signal
295
- correlation, overdue incident owners, dashboard status actions, response-window decisions, and
296
- alert-routing handoff without sharing source code, raw incident payloads,
297
- collector tokens, customer data, or secrets.
298
- It exits nonzero when active high/critical incidents are present so CI can
299
- block reviewer handoff until the incident is acknowledged and routed.
218
+ Use `obfuscate(code, options, fileName)` and `obfuscateMultiple(sourceCodesObject, options)` when migrating from `javascript-obfuscator` style Node scripts. These methods are asynchronous because they call the hosted API, and their result objects include `getObfuscatedCode()`, `toString()`, `getSourceMap()`, and `getIdentifierNamesCache()` for compatibility-friendly call sites. They use the same marked HTML and inline planning as the CLI, so `parseHtml`, `honorConditionalComments`, and `protectMarkedComments` work for object-map inputs too. Source maps and identifier caches return `null` because the hosted API workflow is designed to remove release source maps.
300
219
 
301
- In GitHub Actions, the bundled JSO action exposes the same gate as
302
- `runtime-incident-export` plus `runtime-incident-evidence-report`. The action
303
- writes a source-free JSON artifact, adds a step summary and annotations, and
304
- fails the job when the exported packet contains active high/critical runtime
305
- incidents that have not started response.
220
+ The Node API accepts common `javascript-obfuscator` option names directly and maps them to the closest hosted API options. Supported compatibility keys include `optionsPreset`, `parseHtml`, `stringArray`, `stringArrayEncoding`, `controlFlowFlattening`, `deadCodeInjection`, `deadCodeInjectionThreshold`, `identifierNamesGenerator`, `renameGlobals`, `renameProperties`, `reservedNames`, `domainLock`, `compact`, and `target`. Use `translateJavascriptObfuscatorOptions(sourceOptions, overrides)` when you want to inspect or reuse the mapped config before calling the API.
306
221
 
307
- ## Deployment Hygiene Evidence
222
+ `stringArrayIndexShift` maps approximately to native `StringArrayIndexShift`: enabled builds use a deterministic nonzero one-slot offset in plain and encrypted string tables. This does not reproduce the competitor's randomized shift magnitude, so validate the protected build in its target runtime.
308
223
 
309
- When `tools/Build-UpdatedArchives.ps1 -ReportPath _temp/archive-hygiene.json`
310
- creates an updated-files archive hygiene report, turn it into a source-free
311
- reviewer packet before sharing the zip:
224
+ `stringArrayShuffle` maps directly to native `StringArrayShuffle`. It randomizes unique moved-string order and preserves every lookup across plain, encrypted, shifted, and self-compressed output. Default builds use fresh entropy; `Seed` makes the shuffle reproducible.
312
225
 
313
- ```bash
314
- npx jso-protector \
315
- --deployment-hygiene-evidence _temp/archive-hygiene.json \
316
- --deployment-hygiene-output reports/deployment-hygiene.md
317
- ```
226
+ `stringArrayRotate` maps directly to native `StringArrayRotate`. It cyclically rotates multi-value tables by a nonzero per-build offset and rewrites every lookup. Rotation uses an independent entropy stream, composes with shuffle/index shifting/encryption, and is reproducible under `Seed`.
318
227
 
319
- The packet summarizes archive names, entry counts, byte sizes, missing required
320
- entries, blocked entries, blocked category booleans, the exclusion policy,
321
- operator checklist, rotation triggers, hygiene-report SHA-256, and a Deployment Hygiene Review Assistant for BYO AI or internal reviewers. It does not include
322
- `Web.config` contents, raw secrets, provider keys, webhook signing secrets,
323
- database strings, host-specific deployment transforms, customer data, or source
324
- code. It exits nonzero when the archive builder reported blocked deployment
325
- files or missing required entries, while still writing the failed packet for
326
- internal remediation.
228
+ `stringArrayIndexesType` maps directly to native `StringArrayIndexesType`. Use `hexadecimal-number`, `hexadecimal-numeric-string`, or both. Numeric strings are explicitly coerced before array access; mixed lists select a type per lookup and become reproducible when `Seed` is supplied.
327
229
 
328
- ## Payment and API Access
230
+ `stringArrayThreshold` maps directly to native `StringArrayThreshold`. It accepts 0 through 1 and makes one stable decision per unique eligible literal. Zero keeps all literals verbatim, one moves all eligible literals, duplicates stay consistent, and `Seed` makes partial selection reproducible.
329
231
 
330
- This package is a client. It drives the hosted API by default, or the bundled `jso-local` protector with `--local`. Protection itself, billing and every plan limit live on the server, never in this package.
232
+ `stringArrayCallsTransform` maps directly to native secondary index-table indirection, with `stringArrayCallsTransformThreshold` controlling per-lookup probability from 0 through 1. Selected calls become nested table lookups, the default threshold is 0.5, and `Seed` makes selection reproducible. The transform composes with all native moved-string storage and output modes.
331
233
 
332
- A request with no credentials is served on the **free tier**: up to 20 files and 200 KB per request, rate limited per IP, no VM protection. Everything above that is a paid plan, enforced server-side.
234
+ String-array wrapper controls generate bounded root-level aliases or multi-parameter functions. Counts are limited to 0-10, function parameters to 2-5, and chaining can route each wrapper through its predecessor. The count mapping is approximate: unlike the competitor's per-function-scope placement, JSO keeps wrappers at the protected root. Selection and noise parameters are reproducible under `Seed`.
333
235
 
334
- Payment and account enforcement stay on `javascriptobfuscator.com`:
236
+ `transformObjectKeys` maps approximately to native safe data-key transformation. Identifier and quoted data keys become computed moved-string lookups; numeric keys, methods/accessors, shorthand-sensitive members, and `__proto__` stay literal to avoid changing property and prototype behavior.
335
237
 
336
- 1. The user buys a plan or credits on the JavaScript Obfuscator website.
337
- 2. The dashboard provides `JSO_API_KEY` and `JSO_API_PASSWORD`.
338
- 3. By default the local npm CLI sends selected JavaScript to the configured HTTPS API endpoint.
339
- 4. The hosted API validates the account, plan, limits, and credentials before returning protected code.
238
+ For JS-Confuser migration scripts, pass a `jsConfuserOptions` object or call `translateJsConfuserOptions(sourceOptions, overrides)` first. The Node API also detects common top-level JS-Confuser options directly, including the `lock` bag, so existing build scripts can migrate with smaller edits. In addition to common transform and date/domain settings, `lock.antiDebug`, `lock.integrity`, `lock.selfDefending`, and `lock.tamperProtection` map to `DebugProtection`, `SelfDefending`, and `AntiMonkeyPatching`; `lock.startDate` maps to the native activation boundary. These runtime mappings are approximate: JS-Confuser numeric probabilities collapse to enabled/disabled and vendor-specific detection behavior still requires protected-browser testing. Arbitrary `lock.countermeasures` and custom locks remain review-only rather than being executed or guessed.
340
239
 
341
- With `--local` the source body stays on the build machine and step 3 does not
342
- happen, but entitlement is still enforced server-side: the run makes a
343
- source-free plan/option check before protecting. Either way, billing and plan
344
- limits live on the server, never in this package.
240
+ JS-Confuser `stringSplitting` also maps approximately to native `SplitStrings`. Boolean values map directly; numeric probabilities greater than zero enable splitting because the native engine does not reproduce per-literal probability scheduling. Custom selector functions require manual migration review and are never executed by translation tooling.
345
241
 
346
- Keep billing, entitlement checks, plan limits, and API secrets on the server side. The local npm package should only read credentials from environment variables or config and call the API.
242
+ `getOptionsByPreset("standard" | "balanced" | "maximum")` returns a copy of the hosted API preset options for scripts that previously used preset lookup helpers.
347
243
 
348
- If the hosted API rejects a request, the CLI reports dashboard credential hints for authentication failures and account/plan/credit guidance for entitlement failures. API keys and passwords are redacted from error messages before they reach terminal logs.
349
-
350
- ### Sign in once
351
-
352
- ```bash
353
- npx javascriptobfuscator login
354
- ```
355
-
356
- This opens the dashboard, takes the API Key and API Password (the password is
357
- not echoed), and stores them in `~/.jso-protector/credentials.json` for every
358
- project on the machine. `npx javascriptobfuscator logout` removes them.
359
-
360
- The store is written `0600`. That is real protection on POSIX; Windows does not
361
- honour the mode, so there the file is only as protected as your user profile
362
- directory - the same position as `~/.npmrc`.
363
-
364
- ### Or set them per shell
365
-
366
- Stored credentials are read **last**, so an explicit flag, a project config, or
367
- these environment variables always win - a CI setup is unaffected by whatever a
368
- developer has logged in with locally.
369
-
370
- ```bash
371
- set JSO_API_KEY=base64-api-key-from-dashboard
372
- set JSO_API_PASSWORD=base64-api-password-from-dashboard
373
- ```
374
-
375
- For macOS/Linux shells:
376
-
377
- ```bash
378
- export JSO_API_KEY=base64-api-key-from-dashboard
379
- export JSO_API_PASSWORD=base64-api-password-from-dashboard
380
- ```
381
-
382
- Protect generated build output:
383
-
384
- ```bash
385
- npx jso-protector --config jso.config.json
386
- ```
387
-
388
- ### Runtime recovery and enterprise governance foundations
389
-
390
- Browser-targeted API options now support bounded local recovery with
391
- `SelfDefending`, `SelfHealing`, and `SelfHealingMaxAttempts`. A successful
392
- repair emits a `self-healed-*` runtime event; when repair is unavailable or
393
- exhausted, `RuntimeDefenseAction` can use `throw`, `blank`, `redirect`,
394
- `reload`, `callback`, or `degrade`. Local recovery handles mutation after the
395
- wrapper starts and does not claim to repair a bundle modified before startup.
396
-
397
- Release automation can import `jso-protector/governance` for shared RBAC,
398
- scoped-token descriptors, SHA-256 hash-chained audit events, validated
399
- OIDC/SAML trust configuration, an organization directory, and a SCIM 2.0
400
- `/Users` service core with bearer authentication, filtering, role updates, and
401
- deactivation. Deployments still need to mount the service behind HTTPS and
402
- persist directory changes in their account store.
403
-
404
- `jso-protector/runtime/third-party-inventory` supports
405
- `enforcementMode: "block"` for synchronous origin and late-injection decisions
406
- on dynamically-created scripts. `jso-protector/runtime/managed-integrity` adds
407
- versioned monitor/block policies, inventory evaluation, deduplicated incidents,
408
- assignment/status transitions, and JSON export for hosted or on-prem operations.
409
- `jso-protector/runtime/data-exfiltration-guard` adds opt-in monitor/block controls
410
- for protected-field data sent through fetch, XHR, sendBeacon, WebSocket, or
411
- programmatic form submission. Allow approved destinations explicitly and begin
412
- in monitor mode. Evidence contains field names and counts, never captured values
413
- or request bodies; encoded/encrypted bodies and script attribution remain stated
414
- browser-runtime limitations.
415
-
416
- Compare a migrated config against common JavaScript obfuscator capabilities:
417
-
418
- ```bash
419
- npx jso-protector --config jso.config.json --competitor-gap-report
420
- npx jso-protector --config jso.config.json --competitor-gap-report --json
421
- npx jso-protector --config jso.config.json --migration-review \
422
- --migration-review-output reports/migration-review.md
423
- npx jso-protector --config jso.config.json --identifier-cache-review \
424
- --identifier-cache-review-output reports/identifier-cache-review.md
425
- npx jso-protector --config jso.config.json --runtime-defense-review \
426
- --runtime-defense-review-output reports/runtime-defense-review.md
427
- ```
428
-
429
- The gap report groups parity into covered, partial, and gap areas across common
430
- competitor surfaces such as control-flow flattening, string hiding, domain/date
431
- locks, runtime monitoring, hosted dashboard intake, countermeasures, source
432
- maps, and release forensics. It names Obfuscator.io, javascript-obfuscator,
433
- JS-Confuser, Jscrambler, and JSDefender so migration reviews can separate exact
434
- matches from features that need manual validation. Runtime-defense parity is
435
- reported as partial: route `RuntimeDefenseBeaconUrl` to your monitoring stack
436
- or the hosted `/v1/runtime/beacon.ashx` intake for first triage, then validate
437
- any migrated anti-debug/self-defending switches manually. Use it after
438
- `--migrate-javascript-obfuscator` or `--migrate-js-confuser` to keep
439
- runtime-defense, source-map, and release-readiness assumptions visible in CI.
440
- The JSON and text output include a dated source snapshot of the public
441
- competitor pages reviewed for this migration framing, plus a reminder to
442
- re-check current vendor pages before publishing named competitive claims.
443
- The report also includes a source-free Competitor Gap Review Assistant for BYO
444
- AI or internal reviewers. It turns gap prioritization, partial-parity
445
- validation, triggered migration limitations, source-reading scan boundaries,
446
- vendor-claim freshness, and plan handoff into owner actions without sharing
447
- source code, protected output, API credentials, provider keys, customer data,
448
- or secrets.
449
- When source-map, identifier-cache, custom-dictionary, or runtime-defense
450
- limitations are present, the report also includes `reviewArtifacts`: source-free
451
- release-check, competitor-gap, all-up migration-review, source-map-evidence,
452
- and identifier-cache replacement review commands, a source-free runtime-defense
453
- review command, and a separate source-reading compatibility scan when
454
- runtime-defense switches need manual validation.
455
- Use `--migration-review` when a migrated config still carries any accepted
456
- competitor-only fields. The generated Markdown packet gives release owners one
457
- source-free checklist across source-map policy, identifier-cache replacement,
458
- runtime-defense behavior, CLI compatibility warnings, saved report/manifest
459
- readiness, follow-up commands, and protected-build smoke evidence without
460
- embedding source code, protected output, source-map contents, cache contents,
461
- dictionary values, prefixes, domains, URLs, dates, seed values, or reserved
462
- expressions. The packet includes a Migration Review Assistant for BYO AI or
463
- internal reviewers, turning manual review tracks, source-map policy,
464
- identifier-cache replacement, runtime-defense behavior, source-reading command
465
- boundaries, release metadata, and protected-build smoke into owner actions
466
- without sharing raw config files, API credentials, provider keys, customer data,
467
- or secrets.
468
- Use `--identifier-cache-review` when a migrated config still carries
469
- `identifierNamesCache`, `identifierNamesCachePath`, `identifiersDictionary`, or
470
- `identifiersPrefix`. The generated Markdown packet gives release owners a
471
- source-free checklist for replacing deterministic cache assumptions with
472
- reserved-name review, saved API report, release manifest, and protected-build
473
- smoke evidence without embedding cache contents, dictionary values, prefixes,
474
- reserved-name expressions, or source code. It includes an Identifier Cache
475
- Review Assistant for BYO AI or internal reviewers, turning deterministic cache
476
- assumptions, custom dictionary replacement, reserved-name coverage, release
477
- metadata, and protected-build smoke into owner actions without sharing raw
478
- config files, API credentials, provider keys, customer data, or secrets.
479
- Use `--runtime-defense-review` when a migrated config still carries anti-debug,
480
- self-defending, runtime lock, console, and countermeasure migration settings.
481
- The generated packet lists field names, configured evidence tracks, review
482
- decision, monitoring and smoke-test follow-ups, and safe-sharing boundaries
483
- without embedding domains, dates, redirect URLs, beacon URLs, countermeasure
484
- values, source code, or protected output. It includes a Runtime Defense Review
485
- Assistant for BYO AI or internal reviewers, turning runtime behavior scope,
486
- monitoring handoff, countermeasure policy, domain/date lock smoke,
487
- source-reading compatibility scan, release metadata, and protected-build smoke
488
- into owner actions without sharing raw config files, API credentials, provider
489
- keys, collector tokens, customer data, or secrets.
490
-
491
- Protect one file through a shell pipe:
492
-
493
- ```bash
494
- type dist\app.js | npx jso-protector --stdin --stdout --file-name app.js > dist\app.protected.js
495
- ```
496
-
497
- ## npm Scripts
498
-
499
- ```json
500
- {
501
- "scripts": {
502
- "build": "vite build",
503
- "preflight": "jso-protector --config jso.config.json --release-check --json",
504
- "protect": "jso-protector --config jso.config.json",
505
- "release": "npm run build && npm run preflight && npm run protect && npm run smoke"
506
- }
507
- }
508
- ```
509
-
510
- ## Node API
511
-
512
- Use the API when you want to protect code or release folders from a custom build script without spawning the CLI:
513
-
514
- ```js
515
- const { obfuscate, obfuscateMultiple, getOptionsByPreset, protectCode, protectFiles, planProtection } = require("jso-protector");
516
-
517
- const obfuscationResult = await obfuscate("console.log('release');", {
518
- apiKey: process.env.JSO_API_KEY,
519
- apiPassword: process.env.JSO_API_PASSWORD,
520
- controlFlowFlattening: true,
521
- identifierNamesGenerator: "hexadecimal",
522
- reservedNames: ["^PublicApi$"],
523
- stringArrayEncoding: ["rc4"]
524
- }, "app.js");
525
-
526
- console.log(obfuscationResult.getObfuscatedCode());
527
- console.log(obfuscationResult.toString());
528
-
529
- const multipleResults = await obfuscateMultiple({
530
- "foo.js": "var foo = 1;",
531
- "bar.js": "var bar = 2;"
532
- }, {
533
- apiKey: process.env.JSO_API_KEY,
534
- apiPassword: process.env.JSO_API_PASSWORD,
535
- ...getOptionsByPreset("balanced")
536
- });
537
-
538
- console.log(multipleResults["foo.js"].getObfuscatedCode());
539
-
540
- const protectedCode = await protectCode({
541
- apiKey: process.env.JSO_API_KEY,
542
- apiPassword: process.env.JSO_API_PASSWORD,
543
- preset: "balanced"
544
- }, "console.log('release');", "app.js");
545
-
546
- const plan = planProtection({
547
- input: "dist",
548
- output: "dist-protected",
549
- preset: "balanced",
550
- exclude: ["**/*.map", "**/vendor/**", "**/*-obfuscated.js"]
551
- });
552
-
553
- console.log(`Protecting ${plan.summary.files.length} file(s).`);
554
-
555
- await protectFiles({
556
- apiKey: process.env.JSO_API_KEY,
557
- apiPassword: process.env.JSO_API_PASSWORD,
558
- input: "dist",
559
- output: "dist-protected",
560
- preset: "balanced",
561
- manifest: "dist-protected/jso-manifest.json"
562
- });
563
- ```
564
-
565
- Use `obfuscate(code, options, fileName)` and `obfuscateMultiple(sourceCodesObject, options)` when migrating from `javascript-obfuscator` style Node scripts. These methods are asynchronous because they call the hosted API, and their result objects include `getObfuscatedCode()`, `toString()`, `getSourceMap()`, and `getIdentifierNamesCache()` for compatibility-friendly call sites. They use the same marked HTML and inline planning as the CLI, so `parseHtml`, `honorConditionalComments`, and `protectMarkedComments` work for object-map inputs too. Source maps and identifier caches return `null` because the hosted API workflow is designed to remove release source maps.
566
-
567
- The Node API accepts common `javascript-obfuscator` option names directly and maps them to the closest hosted API options. Supported compatibility keys include `optionsPreset`, `parseHtml`, `stringArray`, `stringArrayEncoding`, `controlFlowFlattening`, `deadCodeInjection`, `deadCodeInjectionThreshold`, `identifierNamesGenerator`, `renameGlobals`, `renameProperties`, `reservedNames`, `domainLock`, `compact`, and `target`. Use `translateJavascriptObfuscatorOptions(sourceOptions, overrides)` when you want to inspect or reuse the mapped config before calling the API.
568
-
569
- `stringArrayIndexShift` maps approximately to native `StringArrayIndexShift`: enabled builds use a deterministic nonzero one-slot offset in plain and encrypted string tables. This does not reproduce the competitor's randomized shift magnitude, so validate the protected build in its target runtime.
570
-
571
- `stringArrayShuffle` maps directly to native `StringArrayShuffle`. It randomizes unique moved-string order and preserves every lookup across plain, encrypted, shifted, and self-compressed output. Default builds use fresh entropy; `Seed` makes the shuffle reproducible.
572
-
573
- `stringArrayRotate` maps directly to native `StringArrayRotate`. It cyclically rotates multi-value tables by a nonzero per-build offset and rewrites every lookup. Rotation uses an independent entropy stream, composes with shuffle/index shifting/encryption, and is reproducible under `Seed`.
574
-
575
- `stringArrayIndexesType` maps directly to native `StringArrayIndexesType`. Use `hexadecimal-number`, `hexadecimal-numeric-string`, or both. Numeric strings are explicitly coerced before array access; mixed lists select a type per lookup and become reproducible when `Seed` is supplied.
576
-
577
- `stringArrayThreshold` maps directly to native `StringArrayThreshold`. It accepts 0 through 1 and makes one stable decision per unique eligible literal. Zero keeps all literals verbatim, one moves all eligible literals, duplicates stay consistent, and `Seed` makes partial selection reproducible.
578
-
579
- `stringArrayCallsTransform` maps directly to native secondary index-table indirection, with `stringArrayCallsTransformThreshold` controlling per-lookup probability from 0 through 1. Selected calls become nested table lookups, the default threshold is 0.5, and `Seed` makes selection reproducible. The transform composes with all native moved-string storage and output modes.
580
-
581
- String-array wrapper controls generate bounded root-level aliases or multi-parameter functions. Counts are limited to 0-10, function parameters to 2-5, and chaining can route each wrapper through its predecessor. The count mapping is approximate: unlike the competitor's per-function-scope placement, JSO keeps wrappers at the protected root. Selection and noise parameters are reproducible under `Seed`.
582
-
583
- `transformObjectKeys` maps approximately to native safe data-key transformation. Identifier and quoted data keys become computed moved-string lookups; numeric keys, methods/accessors, shorthand-sensitive members, and `__proto__` stay literal to avoid changing property and prototype behavior.
584
-
585
- For JS-Confuser migration scripts, pass a `jsConfuserOptions` object or call `translateJsConfuserOptions(sourceOptions, overrides)` first. The Node API also detects common top-level JS-Confuser options directly, including the `lock` bag, so existing build scripts can migrate with smaller edits. In addition to common transform and date/domain settings, `lock.antiDebug`, `lock.integrity`, `lock.selfDefending`, and `lock.tamperProtection` map to `DebugProtection`, `SelfDefending`, and `AntiMonkeyPatching`; `lock.startDate` maps to the native activation boundary. These runtime mappings are approximate: JS-Confuser numeric probabilities collapse to enabled/disabled and vendor-specific detection behavior still requires protected-browser testing. Arbitrary `lock.countermeasures` and custom locks remain review-only rather than being executed or guessed.
586
-
587
- JS-Confuser `stringSplitting` also maps approximately to native `SplitStrings`. Boolean values map directly; numeric probabilities greater than zero enable splitting because the native engine does not reproduce per-literal probability scheduling. Custom selector functions require manual migration review and are never executed by translation tooling.
588
-
589
- `getOptionsByPreset("standard" | "balanced" | "maximum")` returns a copy of the hosted API preset options for scripts that previously used preset lookup helpers.
590
-
591
- Use `protectFile(options, sourcePath, outputPath)` for one physical source file, `protectFiles(options)` for a file or folder configured with `input` and `output`, and `planProtection(options)` when CI needs a dry plan before making the API call. The `obfuscateFile`, `obfuscateFiles`, and `obfuscateDirectory` aliases are available for teams that prefer obfuscator naming. These helpers use the same config merging, preset handling, asset copying, manifest writing, and size budget checks as the CLI.
244
+ Use `protectFile(options, sourcePath, outputPath)` for one physical source file, `protectFiles(options)` for a file or folder configured with `input` and `output`, and `planProtection(options)` when CI needs a dry plan before making the API call. The `obfuscateFile`, `obfuscateFiles`, and `obfuscateDirectory` aliases are available for teams that prefer obfuscator naming. These helpers use the same config merging, preset handling, asset copying, manifest writing, and size budget checks as the CLI.
592
245
 
593
246
  TypeScript declarations are included for the CLI core, Node API, Browserify, Metro/React Native, esbuild/Vite/Rollup/Webpack/Rspack/Gulp/Grunt integrations, and the Webpack/Rspack loader entrypoints. No separate `@types` package is needed.
594
247
 
@@ -1101,7 +754,611 @@ Or reference it from config:
1101
754
  }
1102
755
  ```
1103
756
 
1104
- By default, the CLI ignores source maps, `node_modules`, and `*-obfuscated.js` files. When the output folder is nested under the input folder, reruns also skip that output folder so already protected files are not protected again. The CLI copies non-protected assets such as HTML, CSS, fonts, and images into the output folder. `assetExclude` keeps files such as source maps out of the protected release. Use `--no-copy-assets` or `"copyAssets": false` when another build step already handles assets.
757
+ By default, the CLI ignores source maps, `node_modules`, and `*-obfuscated.js` files. When the output folder is nested under the input folder, reruns also skip that output folder so already protected files are not protected again. The CLI copies non-protected assets such as HTML, CSS, fonts, and images into the output folder. `assetExclude` keeps files such as source maps out of the protected release. Use `--no-copy-assets` or `"copyAssets": false` when another build step already handles assets.
758
+
759
+ ## Package Verification
760
+
761
+ For ordinary development, run the deterministic verification chain with `npm run verify`. Before publishing or tagging an engine release, run the heavier release gate:
762
+
763
+ ```bash
764
+ npm run verify:release
765
+ ```
766
+
767
+ The release gate first runs every ordinary check, then regenerates protected output for the complete real-library corpus and compares the supported runtime samples against the freshly protected files. Do not run `verify:corpus-runtime` by itself as release evidence: it consumes the existing `tools/corpus-protect/.build/emitted` directory and therefore does not prove that the current engine produced those artifacts.
768
+
769
+ To check only package installation behavior, run:
770
+
771
+ ```bash
772
+ npm run verify:package
773
+ ```
774
+
775
+ The verifier packs the package, installs the tarball into a fresh temporary project, checks root and subpath exports, checks shipped example syntax/config JSON, runs the CLI through the installed bin link, and verifies the direct single-file output default.
776
+
777
+ ## Security and Processing
778
+
779
+ See `SECURITY.md` for the source-processing matrix, CI secret guidance, source-map policy, manifest metadata notes, and local-preflight guidance. Use `--release-check`, `--competitor-gap-report`, `--dry-run`, `--validate-config`, and `--doctor` when you need preflight checks before sending source code to the hosted API.
780
+
781
+ ## Live API Smoke Test
782
+
783
+ After setting `JSO_API_KEY` and `JSO_API_PASSWORD`, run a tiny live API check from this package directory:
784
+
785
+ ```bash
786
+ npm run smoke:api
787
+ ```
788
+
789
+ The command protects the sample file in `dist/` and writes the result to `dist-protected/`. Use `npm run smoke` when you only want offline validation and a dry run.
790
+
791
+ ## Doctor
792
+
793
+ Run `release-check` before a release job when you want one CI-friendly report that combines config validation, dry-run file planning, and doctor checks:
794
+
795
+ ```bash
796
+ jso-protector --config jso.config.json --release-check
797
+ jso-protector --config jso.config.json --release-check --json
798
+ jso-protector --config jso.config.json --release-check --strict --json
799
+ ```
800
+
801
+ Run `validate-config` first when you want a fast static check:
802
+
803
+ ```bash
804
+ jso-protector --config jso.config.json --validate-config
805
+ jso-protector --config jso.config.json --validate-config --json
806
+ jso-protector --config jso.config.json --validate-config --strict --json
807
+ ```
808
+
809
+ Run `doctor` before a release job to check config, credentials, paths, matched files, copied assets, output readiness, presets, and enabled options without sending source code to the API:
810
+
811
+ ```bash
812
+ jso-protector --config jso.config.json --doctor
813
+ jso-protector --config jso.config.json --doctor --json
814
+ ```
815
+
816
+ `doctor` now includes a local compatibility scan summary. Run `jso-protector --config jso.config.json --compat-scan --json` when you need the detailed file-and-line findings before a release.
817
+
818
+ When a config still carries competitor-only migration fields such as source-map flags, identifier cache paths, custom naming dictionaries, or JS-Confuser custom countermeasure notes, `validate-config`, `doctor`, and `release-check` emit grouped `limitations` entries in JSON output and `LIMITATION ...` lines in text output so CI can surface the remaining manual-review items explicitly.
819
+
820
+ Run the standalone competitor gap report when you want a machine-readable parity summary for migrated configs:
821
+
822
+ ```bash
823
+ jso-protector --config jso.config.json --competitor-gap-report --json
824
+ ```
825
+
826
+ When a migrated config used deterministic identifier caches or custom
827
+ identifier dictionaries, generate a reviewer packet for that specific gap:
828
+
829
+ ```bash
830
+ jso-protector --config jso.config.json --identifier-cache-review \
831
+ --identifier-cache-review-output reports/identifier-cache-review.md
832
+ ```
833
+
834
+ The packet is source-free. It lists the migration field names, counts,
835
+ replacement evidence tracks, and review decision without embedding cache
836
+ contents, dictionary values, prefixes, reserved-name expressions, or source
837
+ code. The Identifier Cache Review Assistant gives BYO AI or internal reviewers
838
+ owner-action prompts for deterministic cache assumptions, custom dictionary
839
+ replacement, reserved-name coverage, release metadata, and protected-build
840
+ smoke without exposing raw config files, API credentials, provider keys,
841
+ customer data, or secrets.
842
+
843
+ When a migrated config used anti-debug, self-defending, runtime lock, console,
844
+ or countermeasure controls, generate the runtime-defense migration review:
845
+
846
+ ```bash
847
+ jso-protector --config jso.config.json --runtime-defense-review \
848
+ --runtime-defense-review-output reports/runtime-defense-review.md
849
+ ```
850
+
851
+ The packet is source-free. It turns anti-debug, self-defending, runtime lock,
852
+ console, and countermeasure migration settings into a reviewer checklist with
853
+ monitoring target, customer-owned forwarding, countermeasure policy,
854
+ domain/date lock, release metadata, compatibility scan, and protected-build
855
+ smoke-test tracks. It omits domains, dates, redirect URLs, beacon URLs,
856
+ countermeasure values, source code, protected output, and compatibility-scan
857
+ source snippets. The Runtime Defense Review Assistant gives BYO AI or internal
858
+ reviewers owner-action prompts for runtime behavior scope, monitoring handoff,
859
+ countermeasure policy, domain/date lock smoke, source-reading compatibility
860
+ scan, release metadata, and protected-build smoke without exposing raw config
861
+ files, API credentials, provider keys, collector tokens, customer data, or
862
+ secrets.
863
+
864
+ Add `--check-api` to `release-check` or `doctor` when CI should send a tiny live request to verify the endpoint and credentials:
865
+
866
+ ```bash
867
+ jso-protector --config jso.config.json --release-check --check-api --json
868
+ jso-protector --config jso.config.json --doctor --check-api --json
869
+ ```
870
+
871
+ ## Examples and CI Templates
872
+
873
+ Copyable examples are included in `examples/`:
874
+
875
+ - `examples/cli-basic`
876
+ - `examples/node-api`
877
+ - `examples/parcel`
878
+ - `examples/bun`
879
+ - `examples/browserify`
880
+ - `examples/metro.config.js`
881
+ - `examples/nextjs`
882
+ - `examples/turbopack`
883
+ - `examples/rspack`
884
+ - `examples/esbuild`
885
+ - `examples/vite`
886
+ - `examples/rollup`
887
+ - `examples/webpack`
888
+ - `examples/webpack-loader`
889
+ - `examples/gulp`
890
+ - `examples/grunt`
891
+ - `examples/react-native/metro.config.js`
892
+
893
+ `examples/node-api/release-summary.js` is the most complete custom-script starting point: it validates config, prints a dry release plan, protects files, and reports written files, copied assets, and manifest output.
894
+
895
+ CI templates are included in `ci/`:
896
+
897
+ - `ci/github-actions.yml`
898
+ - `ci/gitlab-ci.yml`
899
+ - `ci/azure-pipelines.yml`
900
+
901
+ The templates run `npm run verify:publish-metadata --if-present` so package projects can confirm the local-only metadata policy while application projects can ignore the optional script.
902
+
903
+ ## Migrating from javascript-obfuscator
904
+
905
+ See `MIGRATION.md` when replacing the open-source `javascript-obfuscator` package or one of its bundler plugins with the hosted JavaScript Obfuscator API workflow. It covers command changes, concept mapping, direct Node API replacement, bundle-plugin replacement, and a migration checklist.
906
+
907
+ For JS-Confuser projects, the same package now includes `--migrate-js-confuser`, `--list-js-confuser-migration-map`, `--explain-js-confuser-compat`, and `translateJsConfuserOptions(...)` so you can generate a starter `jso.config.json` and review the runtime-only gaps before switching release pipelines.
908
+
909
+ ## GitHub Actions
910
+
911
+ Store `JSO_API_KEY` and `JSO_API_PASSWORD` as encrypted repository or organization secrets, then run release preflight and protection after your normal frontend build:
912
+
913
+ ```yaml
914
+ name: protected-release
915
+
916
+ on:
917
+ workflow_dispatch:
918
+
919
+ jobs:
920
+ release:
921
+ runs-on: ubuntu-latest
922
+ steps:
923
+ - uses: actions/checkout@v4
924
+ - uses: actions/setup-node@v4
925
+ with:
926
+ node-version: 22
927
+ cache: npm
928
+ - run: npm ci
929
+ - run: npm run build
930
+ - run: npm run verify:package --if-present
931
+ - run: npm run verify:publish-metadata --if-present
932
+ - name: Release preflight
933
+ run: npx jso-protector --config jso.config.json --release-check --json
934
+ env:
935
+ JSO_API_KEY: ${{ secrets.JSO_API_KEY }}
936
+ JSO_API_PASSWORD: ${{ secrets.JSO_API_PASSWORD }}
937
+ - name: Protect JavaScript
938
+ run: npx jso-protector --config jso.config.json --manifest dist-protected/jso-manifest.json
939
+ env:
940
+ JSO_API_KEY: ${{ secrets.JSO_API_KEY }}
941
+ JSO_API_PASSWORD: ${{ secrets.JSO_API_PASSWORD }}
942
+ - run: npm run smoke
943
+ - uses: actions/upload-artifact@v4
944
+ with:
945
+ name: protected-dist
946
+ path: |
947
+ dist-protected/
948
+ dist-protected/jso-manifest.json
949
+ ```
950
+
951
+ ## Working from a local checkout
952
+
953
+ Published releases install from the registry with
954
+ `npm install --save-dev jso-protector`. The paths below are for building the
955
+ package from a checkout of this repository — internal testing, a release
956
+ candidate, or an air-gapped install.
957
+
958
+ Install the workspace copy directly:
959
+
960
+ ```bash
961
+ npm install --save-dev ./packages/jso-protector
962
+ ```
963
+
964
+ Or pin it from another app in the same workspace:
965
+
966
+ ```json
967
+ {
968
+ "devDependencies": {
969
+ "jso-protector": "file:../packages/jso-protector"
970
+ }
971
+ }
972
+ ```
973
+
974
+ For internal sharing without going through the registry, build a tarball and
975
+ install that artifact in the consuming project:
976
+
977
+ ```bash
978
+ npm pack --json
979
+ npm install --save-dev path/to/jso-protector-0.4.0.tgz
980
+ ```
981
+
982
+ Keep those tarballs in internal storage or build artifacts. `prepublishOnly`
983
+ runs the full verification chain before any real publish, so a release cannot
984
+ go out on an unverified tree.
985
+
986
+ ## Release Checklist
987
+
988
+ 1. Build unprotected JavaScript into a temporary output folder.
989
+ 2. Run `jso-protector --release-check --json` to validate config, confirm the file list, and check paths, assets, output readiness, presets, and enabled options before source is sent.
990
+ 3. Protect into a separate output folder such as `dist-protected` and write `dist-protected/jso-manifest.json`.
991
+ 4. Run browser smoke tests against the protected output.
992
+ 5. Run `jso-protector --verify-manifest dist-protected/jso-manifest.json --audit-source-maps` before publishing or after unpacking release artifacts.
993
+ 6. Publish only the protected artifacts and release manifest.
994
+
995
+ ## Notes
996
+
997
+ - The CLI sends file contents to the configured HTTP API endpoint.
998
+ - The desktop app also sends selected JavaScript to the hosted service. Use local preflight only when policy forbids source transfer; current protection workflows do not meet that requirement.
999
+ - The HTTP API is for paid accounts.
1000
+ - The CLI expects the API response shape used by `HttpApi.ashx`: `Type`, `Items`, `Message`, `FileName`, and optional error fields.
1001
+
1002
+ ## Payment and API Access
1003
+
1004
+ This package is a client. It drives the hosted API by default, or the bundled `jso-local` protector with `--local`. Protection itself, billing and every plan limit live on the server, never in this package.
1005
+
1006
+ A request with no credentials is served on the **free tier**: up to 20 files and 200 KB per request, rate limited per IP, no VM protection. Everything above that is a paid plan, enforced server-side.
1007
+
1008
+ Payment and account enforcement stay on `javascriptobfuscator.com`:
1009
+
1010
+ 1. The user buys a plan or credits on the JavaScript Obfuscator website.
1011
+ 2. The dashboard provides `JSO_API_KEY` and `JSO_API_PASSWORD`.
1012
+ 3. By default the local npm CLI sends selected JavaScript to the configured HTTPS API endpoint.
1013
+ 4. The hosted API validates the account, plan, limits, and credentials before returning protected code.
1014
+
1015
+ With `--local` the source body stays on the build machine and step 3 does not
1016
+ happen, but entitlement is still enforced server-side: the run makes a
1017
+ source-free plan/option check before protecting. Either way, billing and plan
1018
+ limits live on the server, never in this package.
1019
+
1020
+ Keep billing, entitlement checks, plan limits, and API secrets on the server side. The local npm package should only read credentials from environment variables or config and call the API.
1021
+
1022
+ If the hosted API rejects a request, the CLI reports dashboard credential hints for authentication failures and account/plan/credit guidance for entitlement failures. API keys and passwords are redacted from error messages before they reach terminal logs.
1023
+
1024
+ ### Sign in once
1025
+
1026
+ ```bash
1027
+ npx javascriptobfuscator login
1028
+ ```
1029
+
1030
+ This opens the dashboard, takes the API Key and API Password (the password is
1031
+ not echoed), and stores them in `~/.jso-protector/credentials.json` for every
1032
+ project on the machine. `npx javascriptobfuscator logout` removes them.
1033
+
1034
+ The store is written `0600`. That is real protection on POSIX; Windows does not
1035
+ honour the mode, so there the file is only as protected as your user profile
1036
+ directory - the same position as `~/.npmrc`.
1037
+
1038
+ ### Or set them per shell
1039
+
1040
+ Stored credentials are read **last**, so an explicit flag, a project config, or
1041
+ these environment variables always win - a CI setup is unaffected by whatever a
1042
+ developer has logged in with locally.
1043
+
1044
+ ```bash
1045
+ set JSO_API_KEY=base64-api-key-from-dashboard
1046
+ set JSO_API_PASSWORD=base64-api-password-from-dashboard
1047
+ ```
1048
+
1049
+ For macOS/Linux shells:
1050
+
1051
+ ```bash
1052
+ export JSO_API_KEY=base64-api-key-from-dashboard
1053
+ export JSO_API_PASSWORD=base64-api-password-from-dashboard
1054
+ ```
1055
+
1056
+ Protect generated build output:
1057
+
1058
+ ```bash
1059
+ npx jso-protector --config jso.config.json
1060
+ ```
1061
+
1062
+ ### Runtime recovery and enterprise governance foundations
1063
+
1064
+ Browser-targeted API options now support bounded local recovery with
1065
+ `SelfDefending`, `SelfHealing`, and `SelfHealingMaxAttempts`. A successful
1066
+ repair emits a `self-healed-*` runtime event; when repair is unavailable or
1067
+ exhausted, `RuntimeDefenseAction` can use `throw`, `blank`, `redirect`,
1068
+ `reload`, `callback`, or `degrade`. Local recovery handles mutation after the
1069
+ wrapper starts and does not claim to repair a bundle modified before startup.
1070
+
1071
+ Release automation can import `jso-protector/governance` for shared RBAC,
1072
+ scoped-token descriptors, SHA-256 hash-chained audit events, validated
1073
+ OIDC/SAML trust configuration, an organization directory, and a SCIM 2.0
1074
+ `/Users` service core with bearer authentication, filtering, role updates, and
1075
+ deactivation. Deployments still need to mount the service behind HTTPS and
1076
+ persist directory changes in their account store.
1077
+
1078
+ `jso-protector/runtime/third-party-inventory` supports
1079
+ `enforcementMode: "block"` for synchronous origin and late-injection decisions
1080
+ on dynamically-created scripts. `jso-protector/runtime/managed-integrity` adds
1081
+ versioned monitor/block policies, inventory evaluation, deduplicated incidents,
1082
+ assignment/status transitions, and JSON export for hosted or on-prem operations.
1083
+ `jso-protector/runtime/data-exfiltration-guard` adds opt-in monitor/block controls
1084
+ for protected-field data sent through fetch, XHR, sendBeacon, WebSocket, or
1085
+ programmatic form submission. Allow approved destinations explicitly and begin
1086
+ in monitor mode. Evidence contains field names and counts, never captured values
1087
+ or request bodies; encoded/encrypted bodies and script attribution remain stated
1088
+ browser-runtime limitations.
1089
+
1090
+ Compare a migrated config against common JavaScript obfuscator capabilities:
1091
+
1092
+ ```bash
1093
+ npx jso-protector --config jso.config.json --competitor-gap-report
1094
+ npx jso-protector --config jso.config.json --competitor-gap-report --json
1095
+ npx jso-protector --config jso.config.json --migration-review \
1096
+ --migration-review-output reports/migration-review.md
1097
+ npx jso-protector --config jso.config.json --identifier-cache-review \
1098
+ --identifier-cache-review-output reports/identifier-cache-review.md
1099
+ npx jso-protector --config jso.config.json --runtime-defense-review \
1100
+ --runtime-defense-review-output reports/runtime-defense-review.md
1101
+ ```
1102
+
1103
+ The gap report groups parity into covered, partial, and gap areas across common
1104
+ competitor surfaces such as control-flow flattening, string hiding, domain/date
1105
+ locks, runtime monitoring, hosted dashboard intake, countermeasures, source
1106
+ maps, and release forensics. It names Obfuscator.io, javascript-obfuscator,
1107
+ JS-Confuser, Jscrambler, and JSDefender so migration reviews can separate exact
1108
+ matches from features that need manual validation. Runtime-defense parity is
1109
+ reported as partial: route `RuntimeDefenseBeaconUrl` to your monitoring stack
1110
+ or the hosted `/v1/runtime/beacon.ashx` intake for first triage, then validate
1111
+ any migrated anti-debug/self-defending switches manually. Use it after
1112
+ `--migrate-javascript-obfuscator` or `--migrate-js-confuser` to keep
1113
+ runtime-defense, source-map, and release-readiness assumptions visible in CI.
1114
+ The JSON and text output include a dated source snapshot of the public
1115
+ competitor pages reviewed for this migration framing, plus a reminder to
1116
+ re-check current vendor pages before publishing named competitive claims.
1117
+ The report also includes a source-free Competitor Gap Review Assistant for BYO
1118
+ AI or internal reviewers. It turns gap prioritization, partial-parity
1119
+ validation, triggered migration limitations, source-reading scan boundaries,
1120
+ vendor-claim freshness, and plan handoff into owner actions without sharing
1121
+ source code, protected output, API credentials, provider keys, customer data,
1122
+ or secrets.
1123
+ When source-map, identifier-cache, custom-dictionary, or runtime-defense
1124
+ limitations are present, the report also includes `reviewArtifacts`: source-free
1125
+ release-check, competitor-gap, all-up migration-review, source-map-evidence,
1126
+ and identifier-cache replacement review commands, a source-free runtime-defense
1127
+ review command, and a separate source-reading compatibility scan when
1128
+ runtime-defense switches need manual validation.
1129
+ Use `--migration-review` when a migrated config still carries any accepted
1130
+ competitor-only fields. The generated Markdown packet gives release owners one
1131
+ source-free checklist across source-map policy, identifier-cache replacement,
1132
+ runtime-defense behavior, CLI compatibility warnings, saved report/manifest
1133
+ readiness, follow-up commands, and protected-build smoke evidence without
1134
+ embedding source code, protected output, source-map contents, cache contents,
1135
+ dictionary values, prefixes, domains, URLs, dates, seed values, or reserved
1136
+ expressions. The packet includes a Migration Review Assistant for BYO AI or
1137
+ internal reviewers, turning manual review tracks, source-map policy,
1138
+ identifier-cache replacement, runtime-defense behavior, source-reading command
1139
+ boundaries, release metadata, and protected-build smoke into owner actions
1140
+ without sharing raw config files, API credentials, provider keys, customer data,
1141
+ or secrets.
1142
+ Use `--identifier-cache-review` when a migrated config still carries
1143
+ `identifierNamesCache`, `identifierNamesCachePath`, `identifiersDictionary`, or
1144
+ `identifiersPrefix`. The generated Markdown packet gives release owners a
1145
+ source-free checklist for replacing deterministic cache assumptions with
1146
+ reserved-name review, saved API report, release manifest, and protected-build
1147
+ smoke evidence without embedding cache contents, dictionary values, prefixes,
1148
+ reserved-name expressions, or source code. It includes an Identifier Cache
1149
+ Review Assistant for BYO AI or internal reviewers, turning deterministic cache
1150
+ assumptions, custom dictionary replacement, reserved-name coverage, release
1151
+ metadata, and protected-build smoke into owner actions without sharing raw
1152
+ config files, API credentials, provider keys, customer data, or secrets.
1153
+ Use `--runtime-defense-review` when a migrated config still carries anti-debug,
1154
+ self-defending, runtime lock, console, and countermeasure migration settings.
1155
+ The generated packet lists field names, configured evidence tracks, review
1156
+ decision, monitoring and smoke-test follow-ups, and safe-sharing boundaries
1157
+ without embedding domains, dates, redirect URLs, beacon URLs, countermeasure
1158
+ values, source code, or protected output. It includes a Runtime Defense Review
1159
+ Assistant for BYO AI or internal reviewers, turning runtime behavior scope,
1160
+ monitoring handoff, countermeasure policy, domain/date lock smoke,
1161
+ source-reading compatibility scan, release metadata, and protected-build smoke
1162
+ into owner actions without sharing raw config files, API credentials, provider
1163
+ keys, collector tokens, customer data, or secrets.
1164
+
1165
+ Protect one file through a shell pipe:
1166
+
1167
+ ```bash
1168
+ type dist\app.js | npx jso-protector --stdin --stdout --file-name app.js > dist\app.protected.js
1169
+ ```
1170
+
1171
+ ## Deployment Hygiene Evidence
1172
+
1173
+ When `tools/Build-UpdatedArchives.ps1 -ReportPath _temp/archive-hygiene.json`
1174
+ creates an updated-files archive hygiene report, turn it into a source-free
1175
+ reviewer packet before sharing the zip:
1176
+
1177
+ ```bash
1178
+ npx jso-protector \
1179
+ --deployment-hygiene-evidence _temp/archive-hygiene.json \
1180
+ --deployment-hygiene-output reports/deployment-hygiene.md
1181
+ ```
1182
+
1183
+ The packet summarizes archive names, entry counts, byte sizes, missing required
1184
+ entries, blocked entries, blocked category booleans, the exclusion policy,
1185
+ operator checklist, rotation triggers, hygiene-report SHA-256, and a Deployment Hygiene Review Assistant for BYO AI or internal reviewers. It does not include
1186
+ `Web.config` contents, raw secrets, provider keys, webhook signing secrets,
1187
+ database strings, host-specific deployment transforms, customer data, or source
1188
+ code. It exits nonzero when the archive builder reported blocked deployment
1189
+ files or missing required entries, while still writing the failed packet for
1190
+ internal remediation.
1191
+
1192
+ ## Payment-page evidence reports
1193
+
1194
+ For checkout, wallet, subscription, activation, and license pages, pair the
1195
+ signed release manifest with a payment-page script inventory and Dashboard
1196
+ Monitoring incident history. Export runtime incidents CSV or JSON from the
1197
+ dashboard, keep a CSV or JSON list of payment-page scripts with authorization
1198
+ and written justification, and attach a payment-page security-header snapshot
1199
+ when reviewers ask for CSP/header change evidence. Include these source-free
1200
+ attachments in the PCI DSS v4 report. Start from
1201
+ `examples/payment-page-script-inventory.json` and
1202
+ `examples/payment-page-security-headers.json` when you need the expected JSON
1203
+ field names, or generate a review starter from a saved
1204
+ `third-party-inventory` runtime snapshot:
1205
+
1206
+ ```bash
1207
+ npx jso-protector \
1208
+ --script-inventory-from-snapshot reports/runtime-inventory.json \
1209
+ --script-inventory-output reports/payment-script-inventory.json
1210
+ ```
1211
+
1212
+ If your checkout evidence starts as a browser or synthetic-monitor HAR export,
1213
+ convert the document and iframe responses into the same source-free
1214
+ security-header snapshot. The converter keeps CSP, HSTS, frame/referrer policy,
1215
+ reporting endpoint, and related security headers, drops raw cookies and other
1216
+ non-security headers, and stores a SHA-256 over each canonical selected-header
1217
+ snapshot. Keep the last approved snapshot in your evidence repository and pass
1218
+ it as `--payment-page-headers-baseline` when you want the new HAR export to
1219
+ mark each checkout page or frame as `match`, `mismatch`, or `missing` for
1220
+ security-header change review. The generated snapshot also includes a
1221
+ source-free security-header Review Assistant Packet for BYO AI or internal
1222
+ reviewers. It focuses the review on baseline drift, CSP/reporting, HSTS, and
1223
+ frame-policy owner actions while reminding teams not to include
1224
+ raw response headers, cookies, source code, payment data, customer data, provider keys, or
1225
+ secrets.
1226
+
1227
+ ```bash
1228
+ npx jso-protector \
1229
+ --payment-page-headers-from-har reports/checkout.har \
1230
+ --payment-page-headers-baseline reports/payment-page-headers.baseline.json \
1231
+ --payment-page-headers-output reports/payment-page-headers.json \
1232
+ --payment-page-url-pattern "checkout|payment|wallet"
1233
+ ```
1234
+
1235
+ Review the generated script inventory file before audit use. Set `authorized`, add written
1236
+ `justification`, assign `owner`, and fill `lastReviewedUtc` for every approved
1237
+ payment-page script. Add `risk`, `dataAccess`, and `approvalTicket` when your
1238
+ checkout review process tracks risk-based decisions or change approvals. Add
1239
+ `checkoutSurface`, `frameContext`, `frameOwner`, `parentPageHref`, `frameHref`,
1240
+ and `frameOrigin` when your payment flow has a parent page, hosted checkout
1241
+ page, PSP iframe, or embedded payment frame that reviewers need to distinguish.
1242
+ The
1243
+ audit packet fails only on blocking script drift or required metadata gaps; it
1244
+ also calls out missing optional review context so checkout owners can improve
1245
+ QSA handoff quality without breaking an otherwise clean release. Before handing
1246
+ the packet to reviewers, reconcile the approved inventory against a fresh
1247
+ runtime snapshot:
1248
+
1249
+ ```bash
1250
+ npx jso-protector \
1251
+ --script-inventory-audit reports/payment-script-inventory.json \
1252
+ --runtime-inventory-snapshot reports/runtime-inventory.json \
1253
+ --script-inventory-audit-output reports/payment-script-inventory-audit.json \
1254
+ --json
1255
+ ```
1256
+
1257
+ The audit is local and source-free. It reports unknown observed scripts,
1258
+ scripts observed while marked unauthorized, approved scripts missing from the
1259
+ page, hash mismatches, scripts injected after page load, runtime violation
1260
+ reasons, and missing inventory metadata. Omit `--json` or use a `.md` output
1261
+ path when a standalone human-readable packet is preferred.
1262
+
1263
+ In GitHub Actions, the bundled JSO action exposes the same audit,
1264
+ security-header snapshot, and PCI DSS v4 reviewer packet as opt-in workflow
1265
+ steps: set
1266
+ `payment-script-inventory`, `runtime-inventory-snapshot`, and optionally
1267
+ `script-inventory-audit-report` to fail the release job on payment-page script
1268
+ drift; set `payment-page-har`, optionally `payment-page-url-pattern`, and
1269
+ optionally `payment-page-headers-baseline` and `payment-page-headers-report` to
1270
+ convert a checkout HAR into the same source-free header evidence artifact and
1271
+ mark baseline matches, mismatches, or missing pages; set `pci-dss-v4-evidence` with
1272
+ `pci-dss-v4-report` and `pci-dss-v4-json-report` to assemble the Markdown and
1273
+ JSON PCI evidence report from the protected manifest plus those attachments.
1274
+ Use `manifest`, `sign-release-key`, `watermark`, and `watermark-key` when this
1275
+ report needs to pass rather than document incomplete evidence. The action adds
1276
+ a step summary and workflow annotations for the first audit, header, or PCI
1277
+ findings so reviewers can see drift directly in the CI run.
1278
+
1279
+ ```bash
1280
+ npx jso-protector compliance pci-dss-v4 \
1281
+ --manifest dist-protected/jso-manifest.json.sig \
1282
+ --root dist-protected \
1283
+ --watermark-key "$JSO_WATERMARK_KEY" \
1284
+ --beacon-url "https://javascriptobfuscator.com/v1/runtime/beacon.ashx" \
1285
+ --siem splunk-hec \
1286
+ --script-inventory reports/payment-script-inventory.json \
1287
+ --script-inventory-audit reports/payment-script-inventory-audit.json \
1288
+ --payment-page-headers reports/payment-page-headers.json \
1289
+ --runtime-incidents reports/runtime-incidents.json \
1290
+ --organization "Example Corp" \
1291
+ --output reports/pci-dss-v4.md
1292
+ ```
1293
+
1294
+ The report hashes and summarizes these attachments, then adds a source-free PCI
1295
+ DSS Review Assistant for BYO AI or internal reviewers. The assistant turns
1296
+ evidence gaps, signed-release proof, script authorization, observed script
1297
+ drift, header change evidence, runtime incident routing, and QSA handoff
1298
+ boundaries into checkout-owner actions without sharing source code, protected
1299
+ output, raw script rows, raw response headers, raw incident payloads,
1300
+ payment-card data, provider keys, customer data, or secrets. Script inventory evidence is
1301
+ summarized by authorization, justification, owner, domain, review range, and
1302
+ integrity-reference coverage. When the inventory includes `risk`, `dataAccess`,
1303
+ `approvalTicket`, `checkoutSurface`, `frameContext`, and `frameOwner`, the
1304
+ report summarizes those fields, including iframe-scoped script counts, without
1305
+ embedding every script row. Security-header evidence is summarized by CSP,
1306
+ `script-src`, `frame-src`, reporting endpoint, HSTS, referrer-policy,
1307
+ baseline-hash match/mismatch/missing state, checkout surface, frame context, monitor, alert
1308
+ route, domain, observed range, and SHA-256 without embedding every raw page
1309
+ row. Runtime incident evidence is summarized by status, severity,
1310
+ open/reviewing count, per-incident next owner and due state, repeated-signal correlation, date range, Build IDs, and SHA-256. The Markdown does not
1311
+ embed every incident URL, user agent, script row, or raw header snapshot, so it
1312
+ can be handed to reviewers while the CSV or JSON exports remain the source-free
1313
+ attachments. The report supports QSA-led assessment; it is not itself a Report
1314
+ on Compliance.
1315
+ When a Dashboard Monitoring JSON export includes filters such as
1316
+ `runtime_status=active`, `runtime_severity=high-critical`, or
1317
+ `runtime_build=checkout-2026-06-07`, the report keeps that filter context in
1318
+ the runtime incident evidence table. The Dashboard JSON export also carries a
1319
+ source-free summary block with status/severity counts, active high-risk count,
1320
+ payload-hash coverage, BuildIDs, event/received date ranges, per-incident action-plan owner/due/status metadata, repeated fingerprint/reason groups, a routing
1321
+ recommendation, an alert routing playbook, and a response checklist before the incident rows. Dashboard
1322
+ Monitoring shows the same routing recommendation on the current filtered view
1323
+ before export, including response target, next status action, and playbook
1324
+ lanes for security response, customer-owned alerting, support handoff, and
1325
+ reviewer packets. The JSON export also includes source-free dashboard action
1326
+ metadata, such as the filtered "Move open in view to Reviewing" status action,
1327
+ plus per-row action plans that name the next owner, evidence packet, response due state, and status move, so support automation can tell account owners what to do next without scraping
1328
+ dashboard HTML. The PCI
1329
+ evidence report preserves those Dashboard JSON fields so support and reviewers
1330
+ can see whether the packet belongs in runtime triage, security response, or
1331
+ archive evidence. The response checklist and alert routing playbook carry
1332
+ owners, response targets, scope confirmation, downstream routing, and
1333
+ safe-sharing boundaries for reviewer
1334
+ or on-call handoff. A single-row Dashboard Monitoring Evidence JSON packet can also be passed to
1335
+ `--runtime-incidents` when the review is about one specific event.
1336
+
1337
+ For non-PCI runtime reviews, generate a standalone source-free handoff packet
1338
+ directly from the Dashboard Monitoring export:
1339
+
1340
+ ```bash
1341
+ npx jso-protector \
1342
+ --runtime-incident-evidence reports/runtime-incidents.json \
1343
+ --runtime-incident-evidence-output reports/runtime-incident-evidence.md
1344
+ ```
1345
+
1346
+ The packet summarizes status and severity counts, active high/critical count,
1347
+ BuildIDs, per-incident action plans, repeated-signal correlation, routing recommendation, dashboard actions,
1348
+ response window, response checklist, alert routing playbook, export SHA-256, and safe-sharing boundaries.
1349
+ It also includes a source-free Runtime Incident Review Assistant for BYO AI or
1350
+ internal reviewers, with prompts for urgent response, repeated-signal
1351
+ correlation, overdue incident owners, dashboard status actions, response-window decisions, and
1352
+ alert-routing handoff without sharing source code, raw incident payloads,
1353
+ collector tokens, customer data, or secrets.
1354
+ It exits nonzero when active high/critical incidents are present so CI can
1355
+ block reviewer handoff until the incident is acknowledged and routed.
1356
+
1357
+ In GitHub Actions, the bundled JSO action exposes the same gate as
1358
+ `runtime-incident-export` plus `runtime-incident-evidence-report`. The action
1359
+ writes a source-free JSON artifact, adds a step summary and annotations, and
1360
+ fails the job when the exported packet contains active high/critical runtime
1361
+ incidents that have not started response.
1105
1362
 
1106
1363
  ## Commands
1107
1364
 
@@ -1393,246 +1650,3 @@ Use `--payment-page-headers-from-har checkout.har --payment-page-headers-output
1393
1650
  Use `jso-protector compliance pci-dss-v4 --script-inventory-audit audit.json` to include the JSON audit summary in the PCI evidence report alongside `--script-inventory` and `--runtime-incidents`. The generated Markdown and JSON also include a source-free PCI DSS Review Assistant for BYO AI or internal reviewers, with prompts for evidence gaps, signed-release proof, script authorization, observed script drift, header change evidence, runtime incident routing, and QSA handoff boundaries. Do not paste source code, protected output, raw script rows, raw response headers, raw incident payloads, payment-card data, provider keys, customer data, or secrets into that review.
1394
1651
 
1395
1652
  Use `--max-output-bytes` / `"maxOutputBytes"` and `--max-growth-ratio` / `"maxGrowthRatio"` to fail CI when protected output exceeds your release size budget. The same budget fields work in bundle plugins.
1396
-
1397
- ## Package Verification
1398
-
1399
- For ordinary development, run the deterministic verification chain with `npm run verify`. Before publishing or tagging an engine release, run the heavier release gate:
1400
-
1401
- ```bash
1402
- npm run verify:release
1403
- ```
1404
-
1405
- The release gate first runs every ordinary check, then regenerates protected output for the complete real-library corpus and compares the supported runtime samples against the freshly protected files. Do not run `verify:corpus-runtime` by itself as release evidence: it consumes the existing `tools/corpus-protect/.build/emitted` directory and therefore does not prove that the current engine produced those artifacts.
1406
-
1407
- To check only package installation behavior, run:
1408
-
1409
- ```bash
1410
- npm run verify:package
1411
- ```
1412
-
1413
- The verifier packs the package, installs the tarball into a fresh temporary project, checks root and subpath exports, checks shipped example syntax/config JSON, runs the CLI through the installed bin link, and verifies the direct single-file output default.
1414
-
1415
- ## Security and Processing
1416
-
1417
- See `SECURITY.md` for the source-processing matrix, CI secret guidance, source-map policy, manifest metadata notes, and local-preflight guidance. Use `--release-check`, `--competitor-gap-report`, `--dry-run`, `--validate-config`, and `--doctor` when you need preflight checks before sending source code to the hosted API.
1418
-
1419
- ## Live API Smoke Test
1420
-
1421
- After setting `JSO_API_KEY` and `JSO_API_PASSWORD`, run a tiny live API check from this package directory:
1422
-
1423
- ```bash
1424
- npm run smoke:api
1425
- ```
1426
-
1427
- The command protects the sample file in `dist/` and writes the result to `dist-protected/`. Use `npm run smoke` when you only want offline validation and a dry run.
1428
-
1429
- ## Doctor
1430
-
1431
- Run `release-check` before a release job when you want one CI-friendly report that combines config validation, dry-run file planning, and doctor checks:
1432
-
1433
- ```bash
1434
- jso-protector --config jso.config.json --release-check
1435
- jso-protector --config jso.config.json --release-check --json
1436
- jso-protector --config jso.config.json --release-check --strict --json
1437
- ```
1438
-
1439
- Run `validate-config` first when you want a fast static check:
1440
-
1441
- ```bash
1442
- jso-protector --config jso.config.json --validate-config
1443
- jso-protector --config jso.config.json --validate-config --json
1444
- jso-protector --config jso.config.json --validate-config --strict --json
1445
- ```
1446
-
1447
- Run `doctor` before a release job to check config, credentials, paths, matched files, copied assets, output readiness, presets, and enabled options without sending source code to the API:
1448
-
1449
- ```bash
1450
- jso-protector --config jso.config.json --doctor
1451
- jso-protector --config jso.config.json --doctor --json
1452
- ```
1453
-
1454
- `doctor` now includes a local compatibility scan summary. Run `jso-protector --config jso.config.json --compat-scan --json` when you need the detailed file-and-line findings before a release.
1455
-
1456
- When a config still carries competitor-only migration fields such as source-map flags, identifier cache paths, custom naming dictionaries, or JS-Confuser custom countermeasure notes, `validate-config`, `doctor`, and `release-check` emit grouped `limitations` entries in JSON output and `LIMITATION ...` lines in text output so CI can surface the remaining manual-review items explicitly.
1457
-
1458
- Run the standalone competitor gap report when you want a machine-readable parity summary for migrated configs:
1459
-
1460
- ```bash
1461
- jso-protector --config jso.config.json --competitor-gap-report --json
1462
- ```
1463
-
1464
- When a migrated config used deterministic identifier caches or custom
1465
- identifier dictionaries, generate a reviewer packet for that specific gap:
1466
-
1467
- ```bash
1468
- jso-protector --config jso.config.json --identifier-cache-review \
1469
- --identifier-cache-review-output reports/identifier-cache-review.md
1470
- ```
1471
-
1472
- The packet is source-free. It lists the migration field names, counts,
1473
- replacement evidence tracks, and review decision without embedding cache
1474
- contents, dictionary values, prefixes, reserved-name expressions, or source
1475
- code. The Identifier Cache Review Assistant gives BYO AI or internal reviewers
1476
- owner-action prompts for deterministic cache assumptions, custom dictionary
1477
- replacement, reserved-name coverage, release metadata, and protected-build
1478
- smoke without exposing raw config files, API credentials, provider keys,
1479
- customer data, or secrets.
1480
-
1481
- When a migrated config used anti-debug, self-defending, runtime lock, console,
1482
- or countermeasure controls, generate the runtime-defense migration review:
1483
-
1484
- ```bash
1485
- jso-protector --config jso.config.json --runtime-defense-review \
1486
- --runtime-defense-review-output reports/runtime-defense-review.md
1487
- ```
1488
-
1489
- The packet is source-free. It turns anti-debug, self-defending, runtime lock,
1490
- console, and countermeasure migration settings into a reviewer checklist with
1491
- monitoring target, customer-owned forwarding, countermeasure policy,
1492
- domain/date lock, release metadata, compatibility scan, and protected-build
1493
- smoke-test tracks. It omits domains, dates, redirect URLs, beacon URLs,
1494
- countermeasure values, source code, protected output, and compatibility-scan
1495
- source snippets. The Runtime Defense Review Assistant gives BYO AI or internal
1496
- reviewers owner-action prompts for runtime behavior scope, monitoring handoff,
1497
- countermeasure policy, domain/date lock smoke, source-reading compatibility
1498
- scan, release metadata, and protected-build smoke without exposing raw config
1499
- files, API credentials, provider keys, collector tokens, customer data, or
1500
- secrets.
1501
-
1502
- Add `--check-api` to `release-check` or `doctor` when CI should send a tiny live request to verify the endpoint and credentials:
1503
-
1504
- ```bash
1505
- jso-protector --config jso.config.json --release-check --check-api --json
1506
- jso-protector --config jso.config.json --doctor --check-api --json
1507
- ```
1508
-
1509
- ## Examples and CI Templates
1510
-
1511
- Copyable examples are included in `examples/`:
1512
-
1513
- - `examples/cli-basic`
1514
- - `examples/node-api`
1515
- - `examples/parcel`
1516
- - `examples/bun`
1517
- - `examples/browserify`
1518
- - `examples/metro.config.js`
1519
- - `examples/nextjs`
1520
- - `examples/turbopack`
1521
- - `examples/rspack`
1522
- - `examples/esbuild`
1523
- - `examples/vite`
1524
- - `examples/rollup`
1525
- - `examples/webpack`
1526
- - `examples/webpack-loader`
1527
- - `examples/gulp`
1528
- - `examples/grunt`
1529
- - `examples/react-native/metro.config.js`
1530
-
1531
- `examples/node-api/release-summary.js` is the most complete custom-script starting point: it validates config, prints a dry release plan, protects files, and reports written files, copied assets, and manifest output.
1532
-
1533
- CI templates are included in `ci/`:
1534
-
1535
- - `ci/github-actions.yml`
1536
- - `ci/gitlab-ci.yml`
1537
- - `ci/azure-pipelines.yml`
1538
-
1539
- The templates run `npm run verify:publish-metadata --if-present` so package projects can confirm the local-only metadata policy while application projects can ignore the optional script.
1540
-
1541
- ## Migrating from javascript-obfuscator
1542
-
1543
- See `MIGRATION.md` when replacing the open-source `javascript-obfuscator` package or one of its bundler plugins with the hosted JavaScript Obfuscator API workflow. It covers command changes, concept mapping, direct Node API replacement, bundle-plugin replacement, and a migration checklist.
1544
-
1545
- For JS-Confuser projects, the same package now includes `--migrate-js-confuser`, `--list-js-confuser-migration-map`, `--explain-js-confuser-compat`, and `translateJsConfuserOptions(...)` so you can generate a starter `jso.config.json` and review the runtime-only gaps before switching release pipelines.
1546
-
1547
- ## GitHub Actions
1548
-
1549
- Store `JSO_API_KEY` and `JSO_API_PASSWORD` as encrypted repository or organization secrets, then run release preflight and protection after your normal frontend build:
1550
-
1551
- ```yaml
1552
- name: protected-release
1553
-
1554
- on:
1555
- workflow_dispatch:
1556
-
1557
- jobs:
1558
- release:
1559
- runs-on: ubuntu-latest
1560
- steps:
1561
- - uses: actions/checkout@v4
1562
- - uses: actions/setup-node@v4
1563
- with:
1564
- node-version: 22
1565
- cache: npm
1566
- - run: npm ci
1567
- - run: npm run build
1568
- - run: npm run verify:package --if-present
1569
- - run: npm run verify:publish-metadata --if-present
1570
- - name: Release preflight
1571
- run: npx jso-protector --config jso.config.json --release-check --json
1572
- env:
1573
- JSO_API_KEY: ${{ secrets.JSO_API_KEY }}
1574
- JSO_API_PASSWORD: ${{ secrets.JSO_API_PASSWORD }}
1575
- - name: Protect JavaScript
1576
- run: npx jso-protector --config jso.config.json --manifest dist-protected/jso-manifest.json
1577
- env:
1578
- JSO_API_KEY: ${{ secrets.JSO_API_KEY }}
1579
- JSO_API_PASSWORD: ${{ secrets.JSO_API_PASSWORD }}
1580
- - run: npm run smoke
1581
- - uses: actions/upload-artifact@v4
1582
- with:
1583
- name: protected-dist
1584
- path: |
1585
- dist-protected/
1586
- dist-protected/jso-manifest.json
1587
- ```
1588
-
1589
- ## Working from a local checkout
1590
-
1591
- Published releases install from the registry with
1592
- `npm install --save-dev jso-protector`. The paths below are for building the
1593
- package from a checkout of this repository — internal testing, a release
1594
- candidate, or an air-gapped install.
1595
-
1596
- Install the workspace copy directly:
1597
-
1598
- ```bash
1599
- npm install --save-dev ./packages/jso-protector
1600
- ```
1601
-
1602
- Or pin it from another app in the same workspace:
1603
-
1604
- ```json
1605
- {
1606
- "devDependencies": {
1607
- "jso-protector": "file:../packages/jso-protector"
1608
- }
1609
- }
1610
- ```
1611
-
1612
- For internal sharing without going through the registry, build a tarball and
1613
- install that artifact in the consuming project:
1614
-
1615
- ```bash
1616
- npm pack --json
1617
- npm install --save-dev path/to/jso-protector-0.4.0.tgz
1618
- ```
1619
-
1620
- Keep those tarballs in internal storage or build artifacts. `prepublishOnly`
1621
- runs the full verification chain before any real publish, so a release cannot
1622
- go out on an unverified tree.
1623
-
1624
- ## Release Checklist
1625
-
1626
- 1. Build unprotected JavaScript into a temporary output folder.
1627
- 2. Run `jso-protector --release-check --json` to validate config, confirm the file list, and check paths, assets, output readiness, presets, and enabled options before source is sent.
1628
- 3. Protect into a separate output folder such as `dist-protected` and write `dist-protected/jso-manifest.json`.
1629
- 4. Run browser smoke tests against the protected output.
1630
- 5. Run `jso-protector --verify-manifest dist-protected/jso-manifest.json --audit-source-maps` before publishing or after unpacking release artifacts.
1631
- 6. Publish only the protected artifacts and release manifest.
1632
-
1633
- ## Notes
1634
-
1635
- - The CLI sends file contents to the configured HTTP API endpoint.
1636
- - The desktop app also sends selected JavaScript to the hosted service. Use local preflight only when policy forbids source transfer; current protection workflows do not meet that requirement.
1637
- - The HTTP API is for paid accounts.
1638
- - The CLI expects the API response shape used by `HttpApi.ashx`: `Type`, `Items`, `Message`, `FileName`, and optional error fields.