jso-protector 0.2.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.
Files changed (119) hide show
  1. package/CHANGELOG.md +960 -0
  2. package/LICENSE +90 -0
  3. package/MIGRATION.md +207 -0
  4. package/README.md +1477 -0
  5. package/RELEASE.md +82 -0
  6. package/SECURITY.md +71 -0
  7. package/ai-cli.js +392 -0
  8. package/ai.js +176 -0
  9. package/bin/jso-protector.js +12066 -0
  10. package/browserify.d.ts +10 -0
  11. package/browserify.js +88 -0
  12. package/bun.d.ts +10 -0
  13. package/bun.js +41 -0
  14. package/ci/Jenkinsfile +82 -0
  15. package/ci/argo-workflows.yaml +121 -0
  16. package/ci/azure-pipelines.yml +56 -0
  17. package/ci/bitbucket-pipelines.yml +43 -0
  18. package/ci/buildkite.yml +50 -0
  19. package/ci/circleci.yml +60 -0
  20. package/ci/drone.yml +67 -0
  21. package/ci/github-actions.yml +51 -0
  22. package/ci/gitlab-ci.yml +39 -0
  23. package/ci/gocd.yaml +79 -0
  24. package/ci/teamcity.kts +79 -0
  25. package/ci/tekton.yaml +106 -0
  26. package/ci/verify-package.js +748 -0
  27. package/ci/verify-publish-metadata.js +147 -0
  28. package/ci/verify-templates.js +195 -0
  29. package/ci/woodpecker.yml +53 -0
  30. package/compliance/cli.js +204 -0
  31. package/compliance/evidence-forwarder.js +209 -0
  32. package/compliance/pci-dss-v4/controls.json +75 -0
  33. package/compliance/pci-dss-v4/index.js +2613 -0
  34. package/config/named-sets.js +185 -0
  35. package/esbuild.d.ts +16 -0
  36. package/esbuild.js +190 -0
  37. package/examples/README.md +78 -0
  38. package/examples/browserify/build.js +20 -0
  39. package/examples/bun/package.json +13 -0
  40. package/examples/bun/scripts/protect-release.js +28 -0
  41. package/examples/cli-basic/jso.config.cjs +23 -0
  42. package/examples/cli-basic/jso.config.json +15 -0
  43. package/examples/cli-basic/package.json +14 -0
  44. package/examples/cli-basic/scripts/build.js +10 -0
  45. package/examples/curl/README.md +55 -0
  46. package/examples/curl/protect.sh +106 -0
  47. package/examples/esbuild/build.js +19 -0
  48. package/examples/grunt/Gruntfile.js +29 -0
  49. package/examples/gulp/gulpfile.js +19 -0
  50. package/examples/helm/Chart.yaml +27 -0
  51. package/examples/helm/README.md +69 -0
  52. package/examples/helm/templates/_helpers.tpl +23 -0
  53. package/examples/helm/templates/_podtemplate.tpl +64 -0
  54. package/examples/helm/templates/job.yaml +39 -0
  55. package/examples/helm/templates/secret.yaml +17 -0
  56. package/examples/helm/values.yaml +54 -0
  57. package/examples/kubernetes/job.yaml +123 -0
  58. package/examples/metro.config.js +11 -0
  59. package/examples/nextjs/next.config.js +11 -0
  60. package/examples/node-api/protect-release.js +28 -0
  61. package/examples/node-api/release-summary.js +59 -0
  62. package/examples/parcel/package.json +13 -0
  63. package/examples/parcel/scripts/protect-release.js +28 -0
  64. package/examples/payment-page-script-inventory.json +62 -0
  65. package/examples/payment-page-security-headers.json +46 -0
  66. package/examples/pre-commit/.pre-commit-config.yaml +33 -0
  67. package/examples/pre-commit/README.md +45 -0
  68. package/examples/react-native/README.md +208 -0
  69. package/examples/react-native/metro.config.js +11 -0
  70. package/examples/rollup/rollup.config.js +20 -0
  71. package/examples/rspack/rspack.config.js +28 -0
  72. package/examples/turbopack/package.json +13 -0
  73. package/examples/turbopack/scripts/protect-release.js +28 -0
  74. package/examples/vite/vite.config.js +18 -0
  75. package/examples/webpack/webpack.config.js +21 -0
  76. package/examples/webpack-loader/webpack.config.js +22 -0
  77. package/governance/index.d.ts +18 -0
  78. package/governance/index.js +309 -0
  79. package/grunt.d.ts +4 -0
  80. package/grunt.js +111 -0
  81. package/gulp.d.ts +10 -0
  82. package/gulp.js +106 -0
  83. package/index.d.ts +879 -0
  84. package/index.js +607 -0
  85. package/jso.config.example.json +29 -0
  86. package/jso.config.schema.json +548 -0
  87. package/metro.d.ts +43 -0
  88. package/metro.js +117 -0
  89. package/next.d.ts +24 -0
  90. package/next.js +64 -0
  91. package/package.json +241 -0
  92. package/parcel.d.ts +10 -0
  93. package/parcel.js +40 -0
  94. package/react-native.d.ts +2 -0
  95. package/react-native.js +3 -0
  96. package/release-signer.js +245 -0
  97. package/rollup.d.ts +13 -0
  98. package/rollup.js +71 -0
  99. package/rspack-loader.d.ts +13 -0
  100. package/rspack-loader.js +11 -0
  101. package/rspack.d.ts +11 -0
  102. package/rspack.js +9 -0
  103. package/runtime/ai-script-governance.js +379 -0
  104. package/runtime/countermeasures.js +0 -0
  105. package/runtime/data-exfiltration-guard.d.ts +7 -0
  106. package/runtime/data-exfiltration-guard.js +161 -0
  107. package/runtime/environment-integrity.js +389 -0
  108. package/runtime/managed-integrity.d.ts +4 -0
  109. package/runtime/managed-integrity.js +108 -0
  110. package/runtime/third-party-inventory.js +437 -0
  111. package/turbopack.d.ts +10 -0
  112. package/turbopack.js +41 -0
  113. package/vite.d.ts +16 -0
  114. package/vite.js +78 -0
  115. package/watermark.js +126 -0
  116. package/webpack-loader.d.ts +15 -0
  117. package/webpack-loader.js +97 -0
  118. package/webpack.d.ts +13 -0
  119. package/webpack.js +143 -0
package/README.md ADDED
@@ -0,0 +1,1477 @@
1
+ # jso-protector
2
+
3
+ Lightweight Node.js CLI wrapper for the JavaScript Obfuscator HTTP API.
4
+
5
+ This package is intentionally dependency-free. It is designed to close the developer workflow gap with npm-first obfuscators while keeping JavaScript Obfuscator's existing hosted API, account plans, and dashboard API keys.
6
+
7
+ ## Quick Start
8
+
9
+ Install from the local workspace path:
10
+
11
+ ```bash
12
+ npm install --save-dev ./packages/jso-protector
13
+ npx jso-protector --init
14
+ npx jso-protector --init --init-template html-app --manifest dist-protected/jso-manifest.json
15
+ npx jso-protector --init --init-template electron-app --input out --output out-protected
16
+ npx jso-protector --init --init-template nextjs-app --manifest .next/static-protected/jso-manifest.json
17
+ npx jso-protector --init --init-template vite-app --manifest dist-protected/jso-manifest.json
18
+ npx jso-protector --init --init-template parcel-app --manifest dist-protected/jso-manifest.json
19
+ npx jso-protector --init --init-template bun-app --manifest dist-protected/jso-manifest.json
20
+ npx jso-protector --init --init-template browserify-app --manifest dist-protected/jso-manifest.json
21
+ npx jso-protector --init --init-template turbopack-app --manifest .next/static-protected/jso-manifest.json
22
+ ```
23
+
24
+ For another app in the same workspace, pin the local dependency with a `file:` path:
25
+
26
+ ```json
27
+ {
28
+ "devDependencies": {
29
+ "jso-protector": "file:../packages/jso-protector"
30
+ }
31
+ }
32
+ ```
33
+
34
+ For internal sharing without publishing to npm, create a tarball and install that artifact inside the consuming project:
35
+
36
+ ```bash
37
+ npm pack --json
38
+ npm install --save-dev path/to/jso-protector-0.2.0.tgz
39
+ ```
40
+
41
+ Keep local tarballs inside internal storage or build artifacts, not in public package registries.
42
+
43
+ The package is intentionally local-only: `private:true`, `UNLICENSED`, and `prepublishOnly` block accidental npm publishing.
44
+
45
+ `--init` supports starter templates for common release patterns:
46
+
47
+ - `browser-app`: default browser build output in `dist/`
48
+ - `html-app`: browser build output plus marked inline HTML/template script protection
49
+ - `node-app`: Node.js release output with `.js`, `.cjs`, and `.mjs` extensions
50
+ - `electron-app`: Electron release folders with Node-oriented JavaScript plus copied app assets
51
+ - `nextjs-app`: Next.js production client chunks in `.next/static/` with framework runtime exclusions
52
+ - `vite-app`: Vite/Rollup-style browser chunks in `dist/` with copied release assets
53
+ - `parcel-app`: Parcel post-build browser output in `dist/` with copied release assets
54
+ - `bun-app`: Bun browser-oriented release output in `dist/` with `.js` and `.mjs` targeting
55
+ - `browserify-app`: Browserify release bundles in `dist/` with copied assets and wrapper-name exclusions
56
+ - `webpack-app`: Webpack release output in `dist/` with copied assets and webpack chunk-name preservation
57
+ - `rspack-app`: Rspack release output in `dist/` with copied assets and webpack-compatible chunk-name preservation
58
+ - `turbopack-app`: Next.js Turbopack production client chunks in `.next/static/` with `chunks/*.js` and nested `chunks/**/*.js` targeting
59
+ - `react-native-app`: Metro/Expo release bundle outputs with mobile-oriented optimization defaults
60
+
61
+ You can combine `--init` with normal config flags to scaffold a closer first draft:
62
+
63
+ ```bash
64
+ npx jso-protector --init --init-template node-app --input build --output build-protected --manifest build-protected/jso-manifest.json
65
+ ```
66
+
67
+ For Electron Forge, Electron Builder, or custom desktop packaging flows that emit a release folder, start with the dedicated Electron scaffold:
68
+
69
+ ```bash
70
+ npx jso-protector --init --init-template electron-app --input out --output out-protected --manifest out-protected/jso-manifest.json
71
+ ```
72
+
73
+ For framework-specific release folders, start with the dedicated Next.js, Vite/Webpack-family, Turbopack, or React Native aliases:
74
+
75
+ ```bash
76
+ npx jso-protector --init --init-template next --manifest .next/static-protected/jso-manifest.json
77
+ npx jso-protector --init --init-template vite --manifest dist-protected/jso-manifest.json
78
+ npx jso-protector --init --init-template parcel --manifest dist-protected/jso-manifest.json
79
+ npx jso-protector --init --init-template bun --manifest dist-protected/jso-manifest.json
80
+ npx jso-protector --init --init-template browserify --manifest dist-protected/jso-manifest.json
81
+ npx jso-protector --init --init-template webpack --manifest dist-protected/jso-manifest.json
82
+ npx jso-protector --init --init-template rspack --manifest dist-protected/jso-manifest.json
83
+ npx jso-protector --init --init-template turbopack --manifest .next/static-protected/jso-manifest.json
84
+ npx jso-protector --init --init-template expo --input dist --output dist-protected
85
+ ```
86
+
87
+ ## CI release tagging and crash symbolication
88
+
89
+ Two CLI flags help wire `jso-protector` into a CI pipeline that has to debug production crashes later:
90
+
91
+ - `--label <value>` tags the API request with a release label. The label appears as `ReleaseLabel` in the JSO dashboard audit log, so support tickets can be tied back to a specific commit. Typical CI usage:
92
+
93
+ ```bash
94
+ jso-protector --input dist --output dist-protected --label "$GITHUB_SHA"
95
+ ```
96
+
97
+ Also reads `JSO_LABEL` / `JAVASCRIPT_OBFUSCATOR_LABEL` from the environment, so CI runners with the variable already set don't have to add a flag.
98
+
99
+ - `--report <file>` writes the full API response JSON to a path. The report carries `BuildId`, `PolymorphismFingerprint`, the `GlobalIdentifierMap` / `MemberIdentifierMap` arrays, compatibility findings, and audit metadata. Pair with [`jso-symbolicate`](https://www.npmjs.com/package/jso-symbolicate) to demangle stack traces against the same build.
100
+
101
+ ```bash
102
+ jso-protector --input dist --output dist-protected --label "$GITHUB_SHA" --report dist-protected/jso-report.json
103
+ jso-protector --verify-vm-proof dist-protected/jso-report.json --json
104
+ jso-protector --vm-proof-pack dist-protected/jso-report.json --vm-proof-output reports/vm-proof-pack.md
105
+ jso-protector --ai-resistance-evidence dist-protected/jso-report.json --ai-resistance-evidence-output reports/ai-resistance-evidence.md
106
+ # later, when a crash arrives:
107
+ npx jso-symbolicate --map dist-protected/jso-report.json --stack crash.txt
108
+ npx jso-symbolicate --map dist-protected/jso-report.json --event sentry --event-file sentry-event.json > sentry-event.demangled.json
109
+ ```
110
+
111
+ Upload `dist-protected/jso-report.json` as a build artifact alongside the protected JS so the demangling map is available wherever crash triage happens. For VM beta reviews, `--verify-vm-proof` checks that the source-free report shows `UseVMProtection`, `VMProtectionApplied`, a non-zero virtualized function count, and no unresolved VM warnings. `--vm-proof-pack` turns the same report into a Markdown or JSON reviewer packet with build identity, release label, polymorphism fingerprint, VM pass/fail checklist, review decision, warnings, hot-path/cold-path guidance, recommendations, and a VM Proof Review Assistant for BYO AI or internal reviewers.
112
+ For AI-resistance reviews, `--ai-resistance-evidence` turns the same source-free report into a current evidence checklist: build identity, strong protection options, optional VM proof, runtime-defense evidence, compatibility evidence, a non-scoring attacker-model review matrix, review decision, claim boundaries, a Review Assistant Packet for BYO AI or internal reviewers, and a clear `scoreStatus` that says the Resistance Score is still planned. Add `--ai-resistance-evidence-output reports/ai-resistance-evidence.md` for a reviewer artifact, `--json` for machine-readable evidence, and `--require-vm-proof` when VM-backed evidence must be a hard CI gate.
113
+
114
+ The [JSO GitHub Action](https://github.com/marketplace/actions/javascript-obfuscator)
115
+ wraps the saved-report workflow too: `report-path`, `vm-proof-pack-report`,
116
+ and `ai-resistance-evidence-report` outputs let CI upload source-free reviewer
117
+ artifacts beside the protected build, while `build-id` and
118
+ `polymorphism-fingerprint` remain available for runtime crash correlation.
119
+
120
+ ## Payment-page evidence reports
121
+
122
+ For checkout, wallet, subscription, activation, and license pages, pair the
123
+ signed release manifest with a payment-page script inventory and Dashboard
124
+ Monitoring incident history. Export runtime incidents CSV or JSON from the
125
+ dashboard, keep a CSV or JSON list of payment-page scripts with authorization
126
+ and written justification, and attach a payment-page security-header snapshot
127
+ when reviewers ask for CSP/header change evidence. Include these source-free
128
+ attachments in the PCI DSS v4 report. Start from
129
+ `examples/payment-page-script-inventory.json` and
130
+ `examples/payment-page-security-headers.json` when you need the expected JSON
131
+ field names, or generate a review starter from a saved
132
+ `third-party-inventory` runtime snapshot:
133
+
134
+ ```bash
135
+ npx jso-protector \
136
+ --script-inventory-from-snapshot reports/runtime-inventory.json \
137
+ --script-inventory-output reports/payment-script-inventory.json
138
+ ```
139
+
140
+ If your checkout evidence starts as a browser or synthetic-monitor HAR export,
141
+ convert the document and iframe responses into the same source-free
142
+ security-header snapshot. The converter keeps CSP, HSTS, frame/referrer policy,
143
+ reporting endpoint, and related security headers, drops raw cookies and other
144
+ non-security headers, and stores a SHA-256 over each canonical selected-header
145
+ snapshot. Keep the last approved snapshot in your evidence repository and pass
146
+ it as `--payment-page-headers-baseline` when you want the new HAR export to
147
+ mark each checkout page or frame as `match`, `mismatch`, or `missing` for
148
+ security-header change review. The generated snapshot also includes a
149
+ source-free security-header Review Assistant Packet for BYO AI or internal
150
+ reviewers. It focuses the review on baseline drift, CSP/reporting, HSTS, and
151
+ frame-policy owner actions while reminding teams not to include
152
+ raw response headers, cookies, source code, payment data, customer data, provider keys, or
153
+ secrets.
154
+
155
+ ```bash
156
+ npx jso-protector \
157
+ --payment-page-headers-from-har reports/checkout.har \
158
+ --payment-page-headers-baseline reports/payment-page-headers.baseline.json \
159
+ --payment-page-headers-output reports/payment-page-headers.json \
160
+ --payment-page-url-pattern "checkout|payment|wallet"
161
+ ```
162
+
163
+ Review the generated script inventory file before audit use. Set `authorized`, add written
164
+ `justification`, assign `owner`, and fill `lastReviewedUtc` for every approved
165
+ payment-page script. Add `risk`, `dataAccess`, and `approvalTicket` when your
166
+ checkout review process tracks risk-based decisions or change approvals. Add
167
+ `checkoutSurface`, `frameContext`, `frameOwner`, `parentPageHref`, `frameHref`,
168
+ and `frameOrigin` when your payment flow has a parent page, hosted checkout
169
+ page, PSP iframe, or embedded payment frame that reviewers need to distinguish.
170
+ The
171
+ audit packet fails only on blocking script drift or required metadata gaps; it
172
+ also calls out missing optional review context so checkout owners can improve
173
+ QSA handoff quality without breaking an otherwise clean release. Before handing
174
+ the packet to reviewers, reconcile the approved inventory against a fresh
175
+ runtime snapshot:
176
+
177
+ ```bash
178
+ npx jso-protector \
179
+ --script-inventory-audit reports/payment-script-inventory.json \
180
+ --runtime-inventory-snapshot reports/runtime-inventory.json \
181
+ --script-inventory-audit-output reports/payment-script-inventory-audit.json \
182
+ --json
183
+ ```
184
+
185
+ The audit is local and source-free. It reports unknown observed scripts,
186
+ scripts observed while marked unauthorized, approved scripts missing from the
187
+ page, hash mismatches, scripts injected after page load, runtime violation
188
+ reasons, and missing inventory metadata. Omit `--json` or use a `.md` output
189
+ path when a standalone human-readable packet is preferred.
190
+
191
+ In GitHub Actions, the bundled JSO action exposes the same audit,
192
+ security-header snapshot, and PCI DSS v4 reviewer packet as opt-in workflow
193
+ steps: set
194
+ `payment-script-inventory`, `runtime-inventory-snapshot`, and optionally
195
+ `script-inventory-audit-report` to fail the release job on payment-page script
196
+ drift; set `payment-page-har`, optionally `payment-page-url-pattern`, and
197
+ optionally `payment-page-headers-baseline` and `payment-page-headers-report` to
198
+ convert a checkout HAR into the same source-free header evidence artifact and
199
+ mark baseline matches, mismatches, or missing pages; set `pci-dss-v4-evidence` with
200
+ `pci-dss-v4-report` and `pci-dss-v4-json-report` to assemble the Markdown and
201
+ JSON PCI evidence report from the protected manifest plus those attachments.
202
+ Use `manifest`, `sign-release-key`, `watermark`, and `watermark-key` when this
203
+ report needs to pass rather than document incomplete evidence. The action adds
204
+ a step summary and workflow annotations for the first audit, header, or PCI
205
+ findings so reviewers can see drift directly in the CI run.
206
+
207
+ ```bash
208
+ npx jso-protector compliance pci-dss-v4 \
209
+ --manifest dist-protected/jso-manifest.json.sig \
210
+ --root dist-protected \
211
+ --watermark-key "$JSO_WATERMARK_KEY" \
212
+ --beacon-url "https://www.javascriptobfuscator.com/v1/runtime/beacon.ashx" \
213
+ --siem splunk-hec \
214
+ --script-inventory reports/payment-script-inventory.json \
215
+ --script-inventory-audit reports/payment-script-inventory-audit.json \
216
+ --payment-page-headers reports/payment-page-headers.json \
217
+ --runtime-incidents reports/runtime-incidents.json \
218
+ --organization "Example Corp" \
219
+ --output reports/pci-dss-v4.md
220
+ ```
221
+
222
+ The report hashes and summarizes these attachments, then adds a source-free PCI
223
+ DSS Review Assistant for BYO AI or internal reviewers. The assistant turns
224
+ evidence gaps, signed-release proof, script authorization, observed script
225
+ drift, header change evidence, runtime incident routing, and QSA handoff
226
+ boundaries into checkout-owner actions without sharing source code, protected
227
+ output, raw script rows, raw response headers, raw incident payloads,
228
+ payment-card data, provider keys, customer data, or secrets. Script inventory evidence is
229
+ summarized by authorization, justification, owner, domain, review range, and
230
+ integrity-reference coverage. When the inventory includes `risk`, `dataAccess`,
231
+ `approvalTicket`, `checkoutSurface`, `frameContext`, and `frameOwner`, the
232
+ report summarizes those fields, including iframe-scoped script counts, without
233
+ embedding every script row. Security-header evidence is summarized by CSP,
234
+ `script-src`, `frame-src`, reporting endpoint, HSTS, referrer-policy,
235
+ baseline-hash match/mismatch/missing state, checkout surface, frame context, monitor, alert
236
+ route, domain, observed range, and SHA-256 without embedding every raw page
237
+ row. Runtime incident evidence is summarized by status, severity,
238
+ open/reviewing count, per-incident next owner and due state, repeated-signal correlation, date range, Build IDs, and SHA-256. The Markdown does not
239
+ embed every incident URL, user agent, script row, or raw header snapshot, so it
240
+ can be handed to reviewers while the CSV or JSON exports remain the source-free
241
+ attachments. The report supports QSA-led assessment; it is not itself a Report
242
+ on Compliance.
243
+ When a Dashboard Monitoring JSON export includes filters such as
244
+ `runtime_status=active`, `runtime_severity=high-critical`, or
245
+ `runtime_build=checkout-2026-06-07`, the report keeps that filter context in
246
+ the runtime incident evidence table. The Dashboard JSON export also carries a
247
+ source-free summary block with status/severity counts, active high-risk count,
248
+ payload-hash coverage, BuildIDs, event/received date ranges, per-incident action-plan owner/due/status metadata, repeated fingerprint/reason groups, a routing
249
+ recommendation, an alert routing playbook, and a response checklist before the incident rows. Dashboard
250
+ Monitoring shows the same routing recommendation on the current filtered view
251
+ before export, including response target, next status action, and playbook
252
+ lanes for security response, customer-owned alerting, support handoff, and
253
+ reviewer packets. The JSON export also includes source-free dashboard action
254
+ metadata, such as the filtered "Move open in view to Reviewing" status action,
255
+ 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
256
+ dashboard HTML. The PCI
257
+ evidence report preserves those Dashboard JSON fields so support and reviewers
258
+ can see whether the packet belongs in runtime triage, security response, or
259
+ archive evidence. The response checklist and alert routing playbook carry
260
+ owners, response targets, scope confirmation, downstream routing, and
261
+ safe-sharing boundaries for reviewer
262
+ or on-call handoff. A single-row Dashboard Monitoring Evidence JSON packet can also be passed to
263
+ `--runtime-incidents` when the review is about one specific event.
264
+
265
+ For non-PCI runtime reviews, generate a standalone source-free handoff packet
266
+ directly from the Dashboard Monitoring export:
267
+
268
+ ```bash
269
+ npx jso-protector \
270
+ --runtime-incident-evidence reports/runtime-incidents.json \
271
+ --runtime-incident-evidence-output reports/runtime-incident-evidence.md
272
+ ```
273
+
274
+ The packet summarizes status and severity counts, active high/critical count,
275
+ BuildIDs, per-incident action plans, repeated-signal correlation, routing recommendation, dashboard actions,
276
+ response window, response checklist, alert routing playbook, export SHA-256, and safe-sharing boundaries.
277
+ It also includes a source-free Runtime Incident Review Assistant for BYO AI or
278
+ internal reviewers, with prompts for urgent response, repeated-signal
279
+ correlation, overdue incident owners, dashboard status actions, response-window decisions, and
280
+ alert-routing handoff without sharing source code, raw incident payloads,
281
+ collector tokens, customer data, or secrets.
282
+ It exits nonzero when active high/critical incidents are present so CI can
283
+ block reviewer handoff until the incident is acknowledged and routed.
284
+
285
+ In GitHub Actions, the bundled JSO action exposes the same gate as
286
+ `runtime-incident-export` plus `runtime-incident-evidence-report`. The action
287
+ writes a source-free JSON artifact, adds a step summary and annotations, and
288
+ fails the job when the exported packet contains active high/critical runtime
289
+ incidents that have not started response.
290
+
291
+ ## Deployment Hygiene Evidence
292
+
293
+ When `tools/Build-UpdatedArchives.ps1 -ReportPath _temp/archive-hygiene.json`
294
+ creates an updated-files archive hygiene report, turn it into a source-free
295
+ reviewer packet before sharing the zip:
296
+
297
+ ```bash
298
+ npx jso-protector \
299
+ --deployment-hygiene-evidence _temp/archive-hygiene.json \
300
+ --deployment-hygiene-output reports/deployment-hygiene.md
301
+ ```
302
+
303
+ The packet summarizes archive names, entry counts, byte sizes, missing required
304
+ entries, blocked entries, blocked category booleans, the exclusion policy,
305
+ operator checklist, rotation triggers, hygiene-report SHA-256, and a Deployment Hygiene Review Assistant for BYO AI or internal reviewers. It does not include
306
+ `Web.config` contents, raw secrets, provider keys, webhook signing secrets,
307
+ database strings, host-specific deployment transforms, customer data, or source
308
+ code. It exits nonzero when the archive builder reported blocked deployment
309
+ files or missing required entries, while still writing the failed packet for
310
+ internal remediation.
311
+
312
+ ## Payment and API Access
313
+
314
+ `jso-protector` is a localhost developer client for the paid JavaScript Obfuscator hosted API. The npm package does not unlock protection by itself and does not contain payment logic.
315
+
316
+ Payment and account enforcement stay on `javascriptobfuscator.com`:
317
+
318
+ 1. The user buys a plan or credits on the JavaScript Obfuscator website.
319
+ 2. The dashboard provides `JSO_API_KEY` and `JSO_API_PASSWORD`.
320
+ 3. The local npm CLI sends selected JavaScript to the configured HTTPS API endpoint.
321
+ 4. The hosted API validates the account, plan, limits, and credentials before returning protected code.
322
+
323
+ 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.
324
+
325
+ 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.
326
+
327
+ Set credentials from the dashboard:
328
+
329
+ ```bash
330
+ set JSO_API_KEY=base64-api-key-from-dashboard
331
+ set JSO_API_PASSWORD=base64-api-password-from-dashboard
332
+ ```
333
+
334
+ For macOS/Linux shells:
335
+
336
+ ```bash
337
+ export JSO_API_KEY=base64-api-key-from-dashboard
338
+ export JSO_API_PASSWORD=base64-api-password-from-dashboard
339
+ ```
340
+
341
+ Protect generated build output:
342
+
343
+ ```bash
344
+ npx jso-protector --config jso.config.json
345
+ ```
346
+
347
+ ### Runtime recovery and enterprise governance foundations
348
+
349
+ Browser-targeted API options now support bounded local recovery with
350
+ `SelfDefending`, `SelfHealing`, and `SelfHealingMaxAttempts`. A successful
351
+ repair emits a `self-healed-*` runtime event; when repair is unavailable or
352
+ exhausted, `RuntimeDefenseAction` can use `throw`, `blank`, `redirect`,
353
+ `reload`, `callback`, or `degrade`. Local recovery handles mutation after the
354
+ wrapper starts and does not claim to repair a bundle modified before startup.
355
+
356
+ Release automation can import `jso-protector/governance` for shared RBAC,
357
+ scoped-token descriptors, SHA-256 hash-chained audit events, validated
358
+ OIDC/SAML trust configuration, an organization directory, and a SCIM 2.0
359
+ `/Users` service core with bearer authentication, filtering, role updates, and
360
+ deactivation. Deployments still need to mount the service behind HTTPS and
361
+ persist directory changes in their account store.
362
+
363
+ `jso-protector/runtime/third-party-inventory` supports
364
+ `enforcementMode: "block"` for synchronous origin and late-injection decisions
365
+ on dynamically-created scripts. `jso-protector/runtime/managed-integrity` adds
366
+ versioned monitor/block policies, inventory evaluation, deduplicated incidents,
367
+ assignment/status transitions, and JSON export for hosted or on-prem operations.
368
+ `jso-protector/runtime/data-exfiltration-guard` adds opt-in monitor/block controls
369
+ for protected-field data sent through fetch, XHR, sendBeacon, WebSocket, or
370
+ programmatic form submission. Allow approved destinations explicitly and begin
371
+ in monitor mode. Evidence contains field names and counts, never captured values
372
+ or request bodies; encoded/encrypted bodies and script attribution remain stated
373
+ browser-runtime limitations.
374
+
375
+ Compare a migrated config against common JavaScript obfuscator capabilities:
376
+
377
+ ```bash
378
+ npx jso-protector --config jso.config.json --competitor-gap-report
379
+ npx jso-protector --config jso.config.json --competitor-gap-report --json
380
+ npx jso-protector --config jso.config.json --migration-review \
381
+ --migration-review-output reports/migration-review.md
382
+ npx jso-protector --config jso.config.json --identifier-cache-review \
383
+ --identifier-cache-review-output reports/identifier-cache-review.md
384
+ npx jso-protector --config jso.config.json --runtime-defense-review \
385
+ --runtime-defense-review-output reports/runtime-defense-review.md
386
+ ```
387
+
388
+ The gap report groups parity into covered, partial, and gap areas across common
389
+ competitor surfaces such as control-flow flattening, string hiding, domain/date
390
+ locks, runtime monitoring, hosted dashboard intake, countermeasures, source
391
+ maps, and release forensics. It names Obfuscator.io, javascript-obfuscator,
392
+ JS-Confuser, Jscrambler, and JSDefender so migration reviews can separate exact
393
+ matches from features that need manual validation. Runtime-defense parity is
394
+ reported as partial: route `RuntimeDefenseBeaconUrl` to your monitoring stack
395
+ or the hosted `/v1/runtime/beacon.ashx` intake for first triage, then validate
396
+ any migrated anti-debug/self-defending switches manually. Use it after
397
+ `--migrate-javascript-obfuscator` or `--migrate-js-confuser` to keep
398
+ runtime-defense, source-map, and release-readiness assumptions visible in CI.
399
+ The JSON and text output include a dated source snapshot of the public
400
+ competitor pages reviewed for this migration framing, plus a reminder to
401
+ re-check current vendor pages before publishing named competitive claims.
402
+ The report also includes a source-free Competitor Gap Review Assistant for BYO
403
+ AI or internal reviewers. It turns gap prioritization, partial-parity
404
+ validation, triggered migration limitations, source-reading scan boundaries,
405
+ vendor-claim freshness, and plan handoff into owner actions without sharing
406
+ source code, protected output, API credentials, provider keys, customer data,
407
+ or secrets.
408
+ When source-map, identifier-cache, custom-dictionary, or runtime-defense
409
+ limitations are present, the report also includes `reviewArtifacts`: source-free
410
+ release-check, competitor-gap, all-up migration-review, source-map-evidence,
411
+ and identifier-cache replacement review commands, a source-free runtime-defense
412
+ review command, and a separate source-reading compatibility scan when
413
+ runtime-defense switches need manual validation.
414
+ Use `--migration-review` when a migrated config still carries any accepted
415
+ competitor-only fields. The generated Markdown packet gives release owners one
416
+ source-free checklist across source-map policy, identifier-cache replacement,
417
+ runtime-defense behavior, CLI compatibility warnings, saved report/manifest
418
+ readiness, follow-up commands, and protected-build smoke evidence without
419
+ embedding source code, protected output, source-map contents, cache contents,
420
+ dictionary values, prefixes, domains, URLs, dates, seed values, or reserved
421
+ expressions. The packet includes a Migration Review Assistant for BYO AI or
422
+ internal reviewers, turning manual review tracks, source-map policy,
423
+ identifier-cache replacement, runtime-defense behavior, source-reading command
424
+ boundaries, release metadata, and protected-build smoke into owner actions
425
+ without sharing raw config files, API credentials, provider keys, customer data,
426
+ or secrets.
427
+ Use `--identifier-cache-review` when a migrated config still carries
428
+ `identifierNamesCache`, `identifierNamesCachePath`, `identifiersDictionary`, or
429
+ `identifiersPrefix`. The generated Markdown packet gives release owners a
430
+ source-free checklist for replacing deterministic cache assumptions with
431
+ reserved-name review, saved API report, release manifest, and protected-build
432
+ smoke evidence without embedding cache contents, dictionary values, prefixes,
433
+ reserved-name expressions, or source code. It includes an Identifier Cache
434
+ Review Assistant for BYO AI or internal reviewers, turning deterministic cache
435
+ assumptions, custom dictionary replacement, reserved-name coverage, release
436
+ metadata, and protected-build smoke into owner actions without sharing raw
437
+ config files, API credentials, provider keys, customer data, or secrets.
438
+ Use `--runtime-defense-review` when a migrated config still carries anti-debug,
439
+ self-defending, runtime lock, console, and countermeasure migration settings.
440
+ The generated packet lists field names, configured evidence tracks, review
441
+ decision, monitoring and smoke-test follow-ups, and safe-sharing boundaries
442
+ without embedding domains, dates, redirect URLs, beacon URLs, countermeasure
443
+ values, source code, or protected output. It includes a Runtime Defense Review
444
+ Assistant for BYO AI or internal reviewers, turning runtime behavior scope,
445
+ monitoring handoff, countermeasure policy, domain/date lock smoke,
446
+ source-reading compatibility scan, release metadata, and protected-build smoke
447
+ into owner actions without sharing raw config files, API credentials, provider
448
+ keys, collector tokens, customer data, or secrets.
449
+
450
+ Protect one file through a shell pipe:
451
+
452
+ ```bash
453
+ type dist\app.js | npx jso-protector --stdin --stdout --file-name app.js > dist\app.protected.js
454
+ ```
455
+
456
+ ## npm Scripts
457
+
458
+ ```json
459
+ {
460
+ "scripts": {
461
+ "build": "vite build",
462
+ "preflight": "jso-protector --config jso.config.json --release-check --json",
463
+ "protect": "jso-protector --config jso.config.json",
464
+ "release": "npm run build && npm run preflight && npm run protect && npm run smoke"
465
+ }
466
+ }
467
+ ```
468
+
469
+ ## Node API
470
+
471
+ Use the API when you want to protect code or release folders from a custom build script without spawning the CLI:
472
+
473
+ ```js
474
+ const { obfuscate, obfuscateMultiple, getOptionsByPreset, protectCode, protectFiles, planProtection } = require("jso-protector");
475
+
476
+ const obfuscationResult = await obfuscate("console.log('release');", {
477
+ apiKey: process.env.JSO_API_KEY,
478
+ apiPassword: process.env.JSO_API_PASSWORD,
479
+ controlFlowFlattening: true,
480
+ identifierNamesGenerator: "hexadecimal",
481
+ reservedNames: ["^PublicApi$"],
482
+ stringArrayEncoding: ["rc4"]
483
+ }, "app.js");
484
+
485
+ console.log(obfuscationResult.getObfuscatedCode());
486
+ console.log(obfuscationResult.toString());
487
+
488
+ const multipleResults = await obfuscateMultiple({
489
+ "foo.js": "var foo = 1;",
490
+ "bar.js": "var bar = 2;"
491
+ }, {
492
+ apiKey: process.env.JSO_API_KEY,
493
+ apiPassword: process.env.JSO_API_PASSWORD,
494
+ ...getOptionsByPreset("balanced")
495
+ });
496
+
497
+ console.log(multipleResults["foo.js"].getObfuscatedCode());
498
+
499
+ const protectedCode = await protectCode({
500
+ apiKey: process.env.JSO_API_KEY,
501
+ apiPassword: process.env.JSO_API_PASSWORD,
502
+ preset: "balanced"
503
+ }, "console.log('release');", "app.js");
504
+
505
+ const plan = planProtection({
506
+ input: "dist",
507
+ output: "dist-protected",
508
+ preset: "balanced",
509
+ exclude: ["**/*.map", "**/vendor/**", "**/*-obfuscated.js"]
510
+ });
511
+
512
+ console.log(`Protecting ${plan.summary.files.length} file(s).`);
513
+
514
+ await protectFiles({
515
+ apiKey: process.env.JSO_API_KEY,
516
+ apiPassword: process.env.JSO_API_PASSWORD,
517
+ input: "dist",
518
+ output: "dist-protected",
519
+ preset: "balanced",
520
+ manifest: "dist-protected/jso-manifest.json"
521
+ });
522
+ ```
523
+
524
+ 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.
525
+
526
+ 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.
527
+
528
+ 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 `lock.domainLock` and `lock.endDate`, so existing build scripts can migrate with smaller edits. Current direct mappings cover common presets plus `target`, `renameVariables`, `renameGlobals`, `globalConcealing`, `stringEncoding`, `stringConcealing`, `duplicateLiteralsRemoval`, `stringCompression`, `compact`, `minify`, `controlFlowFlattening`, `deadCode`, `identifierGenerator`, `lock.domainLock`, and `lock.endDate`. Review-only runtime locks such as `lock.antiDebug`, `lock.integrity`, `lock.selfDefending`, `lock.startDate`, `lock.countermeasures`, and `lock.tamperProtection` are preserved as `jsConfuserLock*` fields in translated config objects so migration tooling can carry them forward for manual follow-up instead of dropping them silently.
529
+
530
+ `getOptionsByPreset("standard" | "balanced" | "maximum")` returns a copy of the hosted API preset options for scripts that previously used preset lookup helpers.
531
+
532
+ 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.
533
+
534
+ 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.
535
+
536
+ ## Rspack
537
+
538
+ Use the Rspack entrypoint when a webpack-compatible Rust build should protect emitted JavaScript assets through the same final-asset stage used by the Webpack plugin.
539
+
540
+ ```js
541
+ const JsoProtectorRspackPlugin = require("jso-protector/rspack");
542
+
543
+ module.exports = {
544
+ plugins: [
545
+ new JsoProtectorRspackPlugin({
546
+ apiKey: process.env.JSO_API_KEY,
547
+ apiPassword: process.env.JSO_API_PASSWORD,
548
+ preset: "balanced",
549
+ exclude: ["vendor.js"],
550
+ manifest: "dist/jso-manifest.json"
551
+ })
552
+ ]
553
+ };
554
+ ```
555
+
556
+ Use `jso-protector/rspack-loader` when a Rspack project needs module-level protection before bundling. For complete release bundles, prefer the Rspack plugin so final emitted assets and stale source maps are handled together.
557
+
558
+ ## Browserify
559
+
560
+ Use the Browserify transform when a legacy bundle protects selected modules before bundling:
561
+
562
+ ```js
563
+ const browserify = require("browserify");
564
+ const fs = require("fs");
565
+ const jsoProtector = require("jso-protector/browserify");
566
+
567
+ browserify("src/app.js", {
568
+ transform: [[jsoProtector, {
569
+ apiKey: process.env.JSO_API_KEY,
570
+ apiPassword: process.env.JSO_API_PASSWORD,
571
+ input: "src",
572
+ preset: "balanced",
573
+ include: ["**/*.js"],
574
+ reservedNames: ["^PublicApi$"],
575
+ manifest: "dist/jso-manifest.json"
576
+ }]]
577
+ })
578
+ .bundle()
579
+ .pipe(fs.createWriteStream("dist/app.js"));
580
+ ```
581
+
582
+ The transform passes excluded files through untouched, protects selected JavaScript modules, and honors config files, filters, manifests, and size budgets. It respects configured protected extensions, so `.mjs` and `.cjs` module pipelines can opt in through `extensions`.
583
+
584
+ ## Next.js
585
+
586
+ Use the Next.js entrypoint when you want a first-class wrapper around `next.config.js` instead of wiring the Webpack plugin manually. By default, it adds protection only for production client bundles.
587
+
588
+ ```js
589
+ const withJsoProtector = require("jso-protector/next");
590
+
591
+ module.exports = withJsoProtector({
592
+ reactStrictMode: true
593
+ }, {
594
+ apiKey: process.env.JSO_API_KEY,
595
+ apiPassword: process.env.JSO_API_PASSWORD,
596
+ preset: "balanced",
597
+ exclude: ["static/chunks/webpack*.js"],
598
+ manifest: ".next/jso-manifest.json"
599
+ });
600
+ ```
601
+
602
+ Pass `target: "server"` to protect only server bundles or `target: "both"` to protect both server and client output. Development builds are skipped by default; pass `applyInDevelopment: true` only when you explicitly want protection during `next dev`.
603
+
604
+ ## Metro / React Native
605
+
606
+ Use the Metro entrypoint when React Native or Expo projects need to protect the final release bundle through `serializer.customSerializer`.
607
+
608
+ ```js
609
+ const { getDefaultConfig, mergeConfig } = require("@react-native/metro-config");
610
+ const { withJsoProtectorMetro } = require("jso-protector/metro");
611
+
612
+ const baseConfig = getDefaultConfig(__dirname);
613
+
614
+ module.exports = withJsoProtectorMetro(mergeConfig(baseConfig, {}), {
615
+ apiKey: process.env.JSO_API_KEY,
616
+ apiPassword: process.env.JSO_API_PASSWORD,
617
+ preset: "balanced",
618
+ include: ["index.android.release.bundle.js", "index.ios.release.bundle.js"]
619
+ });
620
+ ```
621
+
622
+ When you already have a serializer function, wrap it directly:
623
+
624
+ ```js
625
+ const { getDefaultConfig } = require("expo/metro-config");
626
+ const { createMetroSerializer } = require("jso-protector/metro");
627
+
628
+ const config = getDefaultConfig(__dirname);
629
+ const expoSerializer = config.serializer.customSerializer;
630
+
631
+ config.serializer.customSerializer = createMetroSerializer({
632
+ serializer: expoSerializer,
633
+ apiKey: process.env.JSO_API_KEY,
634
+ apiPassword: process.env.JSO_API_PASSWORD,
635
+ fileName: "index.android.release.bundle.js"
636
+ });
637
+
638
+ module.exports = config;
639
+ ```
640
+
641
+ The Metro helper protects only matching bundle names and removes stale source maps from object-style serializer results unless `removeSourceMaps: false` is set. When maps are removed, stale `sourceMappingURL` comments are stripped from the protected bundle output too.
642
+
643
+ If you prefer a framework-specific package path for React Native docs or starter templates, `jso-protector/react-native` is an alias of `jso-protector/metro`:
644
+
645
+ ```js
646
+ const { withJsoProtectorMetro } = require("jso-protector/react-native");
647
+ ```
648
+
649
+ ## esbuild
650
+
651
+ Use the esbuild entrypoint for direct esbuild release builds. It protects in-memory output files when `write: false` is used, and protects written `outdir` or `outfile` assets in place for normal builds.
652
+
653
+ ```js
654
+ const esbuild = require("esbuild");
655
+ const jsoProtector = require("jso-protector/esbuild");
656
+
657
+ await esbuild.build({
658
+ entryPoints: ["src/app.js"],
659
+ bundle: true,
660
+ outdir: "dist",
661
+ plugins: [
662
+ jsoProtector({
663
+ apiKey: process.env.JSO_API_KEY,
664
+ apiPassword: process.env.JSO_API_PASSWORD,
665
+ preset: "balanced",
666
+ exclude: ["vendor.js"],
667
+ manifest: "dist/jso-manifest.json"
668
+ })
669
+ ]
670
+ });
671
+ ```
672
+
673
+ The esbuild plugin respects configured protected extensions, so Node-oriented bundles can opt into `.mjs` or `.cjs` outputs through `extensions`.
674
+
675
+ ## Parcel, Bun, and Turbopack
676
+
677
+ Parcel, Bun, and Turbopack do not need a dedicated runtime wrapper when your release flow already emits JavaScript files or chunks to disk. Run the framework build first, then protect the generated output folder through the Node API or CLI.
678
+
679
+ For Parcel builds that write `dist/`, use a post-build release script:
680
+
681
+ ```js
682
+ const protectParcelBuild = require("jso-protector/parcel");
683
+
684
+ const options = {
685
+ apiKey: process.env.JSO_API_KEY,
686
+ apiPassword: process.env.JSO_API_PASSWORD
687
+ };
688
+
689
+ const plan = protectParcelBuild.planParcelBuild(options);
690
+ console.log(`Protecting ${plan.summary.files.length} Parcel file(s).`);
691
+ await protectParcelBuild(options);
692
+ ```
693
+
694
+ For Bun builds, keep the same post-build pattern after `bun build`:
695
+
696
+ ```json
697
+ {
698
+ "scripts": {
699
+ "build": "bun build ./src/index.ts --outdir ./dist --target browser",
700
+ "protect": "node ./scripts/protect-release.js",
701
+ "release": "bun run build && node ./scripts/protect-release.js --plan && node ./scripts/protect-release.js"
702
+ }
703
+ }
704
+ ```
705
+
706
+ ```js
707
+ const protectBunBuild = require("jso-protector/bun");
708
+
709
+ await protectBunBuild({
710
+ apiKey: process.env.JSO_API_KEY,
711
+ apiPassword: process.env.JSO_API_PASSWORD
712
+ });
713
+ ```
714
+
715
+ For Next.js projects that use Turbopack in production, protect the emitted `.next/static/` chunks after `next build --turbopack` while excluding framework runtime files that should stay untouched:
716
+
717
+ ```js
718
+ const protectTurbopackBuild = require("jso-protector/turbopack");
719
+
720
+ await protectTurbopackBuild({
721
+ apiKey: process.env.JSO_API_KEY,
722
+ apiPassword: process.env.JSO_API_PASSWORD
723
+ });
724
+ ```
725
+
726
+ Copyable starter files for these post-build flows are included in `examples/parcel`, `examples/bun`, and `examples/turbopack`.
727
+
728
+ ## Vite
729
+
730
+ Protect emitted JavaScript chunks after Vite finishes bundling:
731
+
732
+ ```js
733
+ const jsoProtector = require("jso-protector/vite");
734
+
735
+ module.exports = {
736
+ plugins: [
737
+ jsoProtector({
738
+ apiKey: process.env.JSO_API_KEY,
739
+ apiPassword: process.env.JSO_API_PASSWORD,
740
+ preset: "balanced",
741
+ exclude: ["**/vendor/**"],
742
+ manifest: "dist/jso-manifest.json"
743
+ })
744
+ ]
745
+ };
746
+ ```
747
+
748
+ The plugin removes stale JavaScript source maps by default. Pass `removeSourceMaps: false` only when another step regenerates or removes maps. When maps are removed, stale `sourceMappingURL` comments are stripped from the protected JavaScript so release artifacts do not point at missing `.map` files.
749
+
750
+ Bundler plugins use the same protection planner as the CLI and Node API, so `honorConditionalComments` and `protectMarkedComments` preserve marked JavaScript regions before chunks are sent to the hosted API.
751
+
752
+ ## Rollup
753
+
754
+ Use the Rollup entrypoint when your release build writes Rollup chunks directly:
755
+
756
+ ```js
757
+ const jsoProtector = require("jso-protector/rollup");
758
+
759
+ module.exports = {
760
+ plugins: [
761
+ jsoProtector({
762
+ apiKey: process.env.JSO_API_KEY,
763
+ apiPassword: process.env.JSO_API_PASSWORD,
764
+ preset: "balanced",
765
+ exclude: ["vendor.js"],
766
+ manifest: "dist/jso-manifest.json"
767
+ })
768
+ ]
769
+ };
770
+ ```
771
+
772
+ ## Webpack
773
+
774
+ Protect emitted JavaScript assets during the final asset phase. The plugin supports Webpack 5 through `processAssets` and falls back to the legacy `emit` hook for Webpack 4 projects:
775
+
776
+ ```js
777
+ const JsoProtectorWebpackPlugin = require("jso-protector/webpack");
778
+
779
+ module.exports = {
780
+ plugins: [
781
+ new JsoProtectorWebpackPlugin({
782
+ apiKey: process.env.JSO_API_KEY,
783
+ apiPassword: process.env.JSO_API_PASSWORD,
784
+ preset: "balanced",
785
+ exclude: ["vendor.js"],
786
+ manifest: "dist/jso-manifest.json"
787
+ })
788
+ ]
789
+ };
790
+ ```
791
+
792
+ Like the Vite plugin, the Webpack plugin removes stale emitted source maps by default and strips stale `sourceMappingURL` comments from the protected assets. It respects configured protected extensions for emitted assets, so `.mjs` and `.cjs` library outputs can use the same plugin path. One package can cover both Webpack 4 and Webpack 5 release builds.
793
+
794
+ ## Webpack Loader
795
+
796
+ Use the loader when a Webpack project already protects selected modules before bundling. For complete release bundles, prefer the Webpack plugin because it protects final emitted assets and removes stale source maps.
797
+
798
+ ```js
799
+ module.exports = {
800
+ module: {
801
+ rules: [{
802
+ test: /\.js$/,
803
+ include: /src/,
804
+ use: [{
805
+ loader: "jso-protector/webpack-loader",
806
+ options: {
807
+ apiKey: process.env.JSO_API_KEY,
808
+ apiPassword: process.env.JSO_API_PASSWORD,
809
+ preset: "balanced",
810
+ include: ["src/*.js"],
811
+ reservedNames: ["^PublicApi$"]
812
+ }
813
+ }]
814
+ }]
815
+ }
816
+ };
817
+ ```
818
+
819
+ The loader disables Webpack caching for protected modules, returns no source map after protection, strips stale `sourceMappingURL` comments unless `removeSourceMaps: false` is set, and honors config files, `extensions`, `include`, `exclude`, manifests, and size budgets.
820
+
821
+ ## Gulp
822
+
823
+ Use the Gulp entrypoint when a legacy release task copies files through Vinyl streams:
824
+
825
+ ```js
826
+ const { dest, src } = require("gulp");
827
+ const jsoProtector = require("jso-protector/gulp");
828
+
829
+ function protect() {
830
+ return src(["dist/**/*.js", "dist/**/*.{css,html,png,svg}", "!dist/**/*.map"], { base: "dist" })
831
+ .pipe(jsoProtector({
832
+ apiKey: process.env.JSO_API_KEY,
833
+ apiPassword: process.env.JSO_API_PASSWORD,
834
+ preset: "balanced",
835
+ exclude: ["**/vendor/**"],
836
+ manifest: "dist-protected/jso-manifest.json"
837
+ }))
838
+ .pipe(dest("dist-protected"));
839
+ }
840
+
841
+ exports.protect = protect;
842
+ ```
843
+
844
+ The Gulp transform batches buffered JavaScript files into one API request, passes non-JavaScript assets through, removes stale `.js.map` files by default, and strips stale `sourceMappingURL` comments from protected JavaScript. Pass `removeSourceMaps: false` only when another task handles maps.
845
+
846
+ ## Grunt
847
+
848
+ Use the Grunt entrypoint when a release pipeline already uses Grunt file mappings:
849
+
850
+ ```js
851
+ module.exports = function configureGrunt(grunt) {
852
+ grunt.initConfig({
853
+ jsoProtector: {
854
+ release: {
855
+ options: {
856
+ apiKey: process.env.JSO_API_KEY,
857
+ apiPassword: process.env.JSO_API_PASSWORD,
858
+ input: "dist",
859
+ output: "dist-protected",
860
+ preset: "balanced",
861
+ exclude: ["**/vendor/**"],
862
+ manifest: "dist-protected/jso-manifest.json"
863
+ },
864
+ files: [{
865
+ expand: true,
866
+ cwd: "dist",
867
+ src: ["**/*.js", "!**/*.map"],
868
+ dest: "dist-protected"
869
+ }]
870
+ }
871
+ }
872
+ });
873
+
874
+ require("jso-protector/grunt")(grunt);
875
+ grunt.registerTask("protect", ["jsoProtector:release"]);
876
+ };
877
+ ```
878
+
879
+ The Grunt task protects JavaScript file mappings and writes protected files to each mapping's `dest`. Use a copy task for non-JavaScript assets.
880
+
881
+ For bundle and stream plugins, `include` and `exclude` match emitted asset names. Use them to protect first-party release chunks while leaving vendor bundles, polyfills, and framework runtime files untouched.
882
+
883
+ ```js
884
+ jsoProtector({
885
+ preset: "balanced",
886
+ include: ["assets/*.js"],
887
+ exclude: ["**/vendor/**", "**/polyfills-*.js"],
888
+ maxOutputBytes: 250000,
889
+ maxGrowthRatio: 8
890
+ });
891
+ ```
892
+
893
+ The Browserify, esbuild, Vite, Rollup, Webpack, Webpack loader, Gulp, and Grunt integrations also honor `manifest`, `maxOutputBytes`, and `maxGrowthRatio`. A failed size budget stops the build before protected chunks replace the original bundle output.
894
+
895
+ ## Configuration
896
+
897
+ ```json
898
+ {
899
+ "$schema": "./node_modules/jso-protector/jso.config.schema.json",
900
+ "endpoint": "https://www.javascriptobfuscator.com/HttpApi.ashx",
901
+ "apiKey": "$JSO_API_KEY",
902
+ "apiPassword": "$JSO_API_PASSWORD",
903
+ "projectName": "browser-release",
904
+ "input": "dist",
905
+ "output": "dist-protected",
906
+ "preset": "balanced",
907
+ "extensions": [".js", ".jsx"],
908
+ "markupExtensions": [".html", ".htm", ".php", ".aspx"],
909
+ "exclude": ["**/*.map", "**/vendor/**", "**/*-obfuscated.js"],
910
+ "copyAssets": true,
911
+ "assetExclude": ["**/*.map"],
912
+ "mixedServer": false,
913
+ "parseHtml": false,
914
+ "honorConditionalComments": false,
915
+ "protectMarkedComments": false,
916
+ "keepHeaderComment": true,
917
+ "protectObjectDeclaration": false,
918
+ "moveNestedFunction": false,
919
+ "formattedOutput": false,
920
+ "keepIndent": false,
921
+ "lineNumbers": false,
922
+ "reservedNames": ["^PublicApi$", "^keep_"],
923
+ "options": {
924
+ "OptimizationMode": "Web",
925
+ "LockDomain": false,
926
+ "LockDate": false
927
+ }
928
+ }
929
+ ```
930
+
931
+ The package includes `jso.config.schema.json` for editor autocomplete and validation. Generated configs point to `./node_modules/jso-protector/jso.config.schema.json`; the in-package example points to `./jso.config.schema.json`.
932
+
933
+ For common product features that otherwise require raw HTTP API option names, the config also supports convenience aliases such as `keepHeaderComment`, `protectObjectDeclaration`, `moveNestedFunction`, `formattedOutput`, `keepIndent`, `lineNumbers`, `lockDomainSubdomains`, `lockDomainMessage`, `lockDate`, `lockDateValue`, and `lockDateMessage`. These map to the corresponding `options.*` values before explicit `options` overrides are applied.
934
+
935
+ `--config` accepts JSON files plus trusted CommonJS or ES module config files. When no config path is provided, the CLI looks for `jso.config.json`, then `jso.config.cjs`, then `jso.config.mjs`, then `jso.config.js`.
936
+
937
+ `--mode <name>` passes a release mode into JavaScript config functions. Use it when production, staging, or tenant-specific builds need different include/exclude rules, presets, or output folders without duplicating config files. When `--mode` is omitted, JavaScript config loaders fall back to `NODE_ENV` when it is set.
938
+
939
+ Config files can also carry mapped `javascript-obfuscator` compatibility keys during migration, including `optionsPreset`, `stringArray`, `stringArrayEncoding`, `controlFlowFlattening`, `deadCodeInjection`, `identifierNamesGenerator`, `renameGlobals`, `renameProperties`, `domainLock`, `compact`, `target`, `parseHtml`, and `ignoreImports`. `optionsPreset` also accepts the current `vm-default`, `vm-low-obfuscation`, `vm-medium-obfuscation`, `vm-high-obfuscation`, `vm-ultra-high-obfuscation`, and `vm-anti-llm` aliases, mapped to the closest hosted preset for starter migration. Review-only compatibility fields such as `selfDefending`, `sourceMap`, `identifiersDictionary`, `identifiersPrefix`, `reservedStrings`, `splitStrings`, `seed`, and `numbersToExpressions` are also accepted in config files so existing configs do not fail immediately; `validate-config` reports them as warnings because the hosted API has no one-to-one local mapping. Explicit `options` values still win, so teams can keep a familiar starter config and override exact hosted API fields as they tune release output.
940
+
941
+ ```js
942
+ module.exports = ({ env, mode }) => ({
943
+ apiKey: "$JSO_API_KEY",
944
+ apiPassword: "$JSO_API_PASSWORD",
945
+ input: env.CI ? "dist" : "demo-dist",
946
+ output: mode === "staging" ? "dist-staging-protected" : "dist-protected",
947
+ preset: mode === "staging" ? "standard" : "balanced",
948
+ reservedNames: ["^PublicApi$"],
949
+ options: {
950
+ LockDomain: Boolean(env.RELEASE_DOMAIN),
951
+ LockDomainList: env.RELEASE_DOMAIN || ""
952
+ }
953
+ });
954
+ ```
955
+
956
+ JavaScript config files execute as Node.js code, so only load config files from your own repository or another trusted source. Use JSON config when you want schema validation and no executable config logic.
957
+
958
+ ES module configs can use `export default { ... }` or `export default ({ env, cwd, mode }) => ({ ... })`. This covers `jso.config.mjs` and `jso.config.js` inside repositories that already use `"type": "module"`.
959
+
960
+ `apiKey` and `apiPassword` should use the base64 values copied from the JavaScript Obfuscator dashboard. Environment references in the form `$NAME` are resolved at runtime.
961
+
962
+ Do not commit real API credentials. Keep `apiKey` and `apiPassword` as environment references in shared config files.
963
+
964
+ The CLI reads `JSO_API_KEY`, `JSO_API_PASSWORD`, and `JSO_ENDPOINT` by default. It also accepts long-form aliases: `JAVASCRIPT_OBFUSCATOR_API_KEY`, `JAVASCRIPT_OBFUSCATOR_API_PASSWORD`, and `JAVASCRIPT_OBFUSCATOR_ENDPOINT`.
965
+
966
+ ## Presets and Public Names
967
+
968
+ Use `preset` to start from a repeatable protection profile:
969
+
970
+ - `standard`: core string encoding, string movement, name replacement, and compression.
971
+ - `balanced`: standard plus short local names, deep obfuscation, code transposition, string encryption, and flat transform.
972
+ - `maximum`: balanced plus member/global renaming, member movement, and low dead-code insertion.
973
+
974
+ Override or extend any preset with `options`. The option names are the same names sent to `HttpApi.ashx`, such as `EncodeStrings`, `DeepObfuscate`, `ReorderCode`, `FlatTransform`, `LockDomain`, and `LockDate`.
975
+
976
+ Use `reservedNames` to preserve public API names, framework entry points, globals, or names that external code calls. Each entry is a regular expression and is sent to the API as `VariableExclusion`. You can also set `variableExclusion` or `options.VariableExclusion` directly when you need a multiline value.
977
+
978
+ ```json
979
+ {
980
+ "preset": "balanced",
981
+ "reservedNames": ["^PublicApi$", "^renderWidget$", "^keep_"],
982
+ "options": {
983
+ "LockDomain": true,
984
+ "LockDomainList": "example.com\napp.example.com",
985
+ "LockDomainMsg": "This script is not licensed for this domain."
986
+ }
987
+ }
988
+ ```
989
+
990
+ ## Online Presets
991
+
992
+ The online obfuscator can export a JSON preset for Standard options, premium preview features, and the Variable Exclusion List. Use it directly during a dry run or in a CI config:
993
+
994
+ ```bash
995
+ npx jso-protector --config jso.config.json --web-preset javascript-obfuscator-preset.json --dry-run --json
996
+ ```
997
+
998
+ Or reference it from config:
999
+
1000
+ ```json
1001
+ {
1002
+ "webPreset": "javascript-obfuscator-preset.json",
1003
+ "input": "dist",
1004
+ "output": "dist-protected"
1005
+ }
1006
+ ```
1007
+
1008
+ 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.
1009
+
1010
+ ## Commands
1011
+
1012
+ ```bash
1013
+ jso-protector --config jso.config.json
1014
+ jso-protector --config jso.config.cjs
1015
+ jso-protector --version
1016
+ jso-protector --version --json
1017
+ jso-protector src/app.js
1018
+ jso-protector --input dist --output dist-protected
1019
+ jso-protector --list-presets --json
1020
+ jso-protector --list-options --json
1021
+ jso-protector --list-migration-map --json
1022
+ jso-protector --explain-compat self-defending --json
1023
+ jso-protector --compat-scan --json
1024
+ jso-protector --local-only --json
1025
+ jso-protector --migrate-javascript-obfuscator javascript-obfuscator.json --output jso.config.json
1026
+ jso-protector --migrate-javascript-obfuscator javascript-obfuscator.config.cjs --output jso.config.json
1027
+ jso-protector --migrate-js-confuser js-confuser.config.cjs --output jso.config.json
1028
+ jso-protector --config jso.config.json --release-check --json
1029
+ jso-protector --config jso.config.json --release-check --strict --json
1030
+ jso-protector --config jso.config.json --validate-config --json
1031
+ jso-protector --config jso.config.json --print-config --json
1032
+ jso-protector --init --init-template html-app --manifest dist-protected/jso-manifest.json
1033
+ jso-protector --init --init-template electron-app --input out --output out-protected
1034
+ jso-protector --init --init-template nextjs-app --manifest .next/static-protected/jso-manifest.json
1035
+ jso-protector --init --init-template vite-app --manifest dist-protected/jso-manifest.json
1036
+ jso-protector --init --init-template parcel-app --manifest dist-protected/jso-manifest.json
1037
+ jso-protector --init --init-template bun-app --manifest dist-protected/jso-manifest.json
1038
+ jso-protector --init --init-template browserify-app --manifest dist-protected/jso-manifest.json
1039
+ jso-protector --init --init-template webpack-app --manifest dist-protected/jso-manifest.json
1040
+ jso-protector --init --init-template rspack-app --manifest dist-protected/jso-manifest.json
1041
+ jso-protector --init --init-template turbopack-app --manifest .next/static-protected/jso-manifest.json
1042
+ jso-protector --init --init-template react-native-app --input dist --output dist-protected
1043
+ jso-protector --verify-manifest dist-protected/jso-manifest.json
1044
+ jso-protector --verify-manifest dist-protected/jso-manifest.json --verify-root protected-dist
1045
+ jso-protector --verify-manifest dist-protected/jso-manifest.json --audit-source-maps
1046
+ jso-protector --source-map-evidence dist-protected/jso-manifest.json --source-map-evidence-output reports/source-map-evidence.md
1047
+ jso-protector --runtime-incident-evidence reports/runtime-incidents.json --runtime-incident-evidence-output reports/runtime-incident-evidence.md
1048
+ jso-protector --verify-vm-proof dist-protected/jso-report.json --json
1049
+ jso-protector --ai-resistance-evidence dist-protected/jso-report.json --ai-resistance-evidence-output reports/ai-resistance-evidence.md
1050
+ jso-protector --config jso.config.json --parse-html
1051
+ jso-protector --config jso.config.json --honor-conditional-comments
1052
+ jso-protector --config jso.config.json --protect-marked-comments
1053
+ jso-protector --config jso.config.json --keep-header-comment --protect-object-declaration --move-nested-function
1054
+ jso-protector --config jso.config.json --formatted-output --keep-indent --line-numbers
1055
+ jso-protector --preset maximum --input dist --output dist-protected
1056
+ jso-protector --web-preset javascript-obfuscator-preset.json --dry-run --json
1057
+ jso-protector --stdin --stdout --file-name app.js < dist/app.js > dist/app.protected.js
1058
+ jso-protector --stdin --file-name app.js --output dist-protected < dist/app.js
1059
+ jso-protector --config jso.config.json --manifest dist-protected/jso-manifest.json
1060
+ jso-protector --config jso.config.json --max-output-bytes 250000 --max-growth-ratio 8
1061
+ jso-protector --config jso.config.json --option LockDomain=true --option LockDomainList=example.com
1062
+ jso-protector --config jso.config.json --include "assets/*.js" --exclude "**/legacy/**" --asset-exclude "**/*.license"
1063
+ jso-protector --config jso.config.json --reserved-name "^PublicApi$" --reserved-name "^renderWidget$"
1064
+ jso-protector dist --output dist-protected --options-preset high-obfuscation --control-flow-flattening --string-array-encoding rc4 --reserved-names "^PublicApi$"
1065
+ jso-protector --dry-run --json
1066
+ jso-protector --no-copy-assets
1067
+ jso-protector --init
1068
+ ```
1069
+
1070
+ Use `--stdin` for small custom scripts and build steps that already know which single file should be protected. Use `--stdout` to compose with other shell commands, or omit it and pass `--output` to write the result as `output/file-name`.
1071
+
1072
+ For direct single-file migration scripts, `jso-protector src/app.js` writes `src/app-obfuscated.js` when no `--output` or config `output` is set. Folder and config-file workflows keep using the configured output folder, usually `dist-protected`.
1073
+
1074
+ Use repeatable `--option Name=value` flags to override API options from CI without editing shared config. Values `true`, `false`, `null`, and numbers are parsed into their JSON equivalents; other values are sent as strings.
1075
+
1076
+ Use repeatable `--include pattern` flags to replace the configured protected-file include list for one job. Use repeatable `--exclude pattern` and `--asset-exclude pattern` flags to add job-specific file and asset exclusions without removing the config defaults. Use repeatable `--reserved-name pattern` flags to override `reservedNames` for a release job.
1077
+
1078
+ When replacing existing `javascript-obfuscator` package scripts, the CLI accepts familiar flags and maps them to hosted API options. Supported mapped compatibility flags include `--options-preset`, `--string-array`, `--string-array-encoding`, `--unicode-escape-sequence`, `--control-flow-flattening`, `--dead-code-injection`, `--dead-code-injection-threshold`, `--identifier-names-generator`, `--rename-globals`, `--rename-properties`, `--reserved-names`, `--domain-lock`, `--target`, and `--compact`. Config and Node API `domainLock` arrays map to `LockDomain` plus newline-delimited `LockDomainList`; review redirect behavior separately. Config-level compatibility fields are also accepted and covered by the shipped JSON schema. `--options-preset default`, `low-obfuscation`, `vm-default`, and `vm-low-obfuscation` map to `standard`; `medium-obfuscation` and `vm-medium-obfuscation` map to `balanced`; `high-obfuscation`, `vm-high-obfuscation`, `vm-ultra-high-obfuscation`, and `vm-anti-llm` map to `maximum`.
1079
+
1080
+ `--seed <value>` requests a reproducible build: the same input, options, and seed produce byte-identical protected output. Omit it for the default per-build polymorphic output (each build differs, which is what you usually want in production). An integer seed is used directly; any other string folds to a stable value. It maps to the engine `Seed` option, so `--option Seed=<value>`, a config `seed` key, and `options.Seed` are equivalent. Keep seed values out of shared logs, and note that a fixed seed makes builds diffable but is not itself a security control.
1081
+
1082
+ The CLI also accepts common review-only flags such as `--source-map`, `--source-map-sources-mode`, `--identifier-names-cache`, `--identifier-names-cache-path`, `--identifiers-dictionary`, `--identifiers-prefix`, `--self-defending`, `--debug-protection`, `--disable-console-output`, `--reserved-strings`, `--rename-properties-mode`, `--strict-mode`, `--numbers-to-expressions`, `--simplify`, `--split-strings`, and string-array wrapper/index flags so older scripts do not fail immediately. `--ignore-imports` is handled directly and preserves import/export-from statements plus common static `require()` and `import()` statements before the remaining code is protected. Other review-only flags emit compatibility warnings when there is no one-to-one hosted API mapping.
1083
+
1084
+ Use `--version` for a quick CLI parity check in scripts. Add `--json` to print package metadata and the default hosted API endpoint.
1085
+
1086
+ Use `--list-presets` and `--list-options` to inspect available presets and commonly used HTTP API options. Add `--list-migration-map --json` to inspect `javascript-obfuscator` option migration coverage before converting a config. The migration map includes mapped, direct, approximate, review-only, and total known option counts for migration tooling. Use `--explain-compat <option>` when one migrated option needs a human-readable answer before you edit a build script.
1087
+
1088
+ Use `--compat-scan` before protection when you want a local source scan for common runtime reflection hazards such as `Function.prototype.toString.call(...)`, `.constructor.name`, and `.name` access that may change after obfuscation. The scan is heuristic and warning-oriented, but it catches the same class of issues competitor docs often call out explicitly. Add `--json` for machine-readable CI output.
1089
+
1090
+ ### AI precheck — gate the obfuscation API call on AI compat-check findings
1091
+
1092
+ Use `--ai-precheck` to fold the JSO AI `/v1/ai/compat-check` call into your existing obfuscation command. The CLI scans every resolved input file *before* the obfuscation API is called; if anything in your source would produce a broken protected build — `eval`, `Function` constructor, framework reflection traps, decorator metadata — the build aborts and your obfuscation quota is not touched.
1093
+
1094
+ ```sh
1095
+ # Single command, single round-trip. Add to any CI step you already run:
1096
+ jso-protector --config jso.config.json --ai-precheck --ai-precheck-fail-on error
1097
+
1098
+ # JSON output for machine consumers (CI annotations, GitHub status checks):
1099
+ jso-protector --config jso.config.json --ai-precheck --json
1100
+ ```
1101
+
1102
+ Gate levels for `--ai-precheck-fail-on`:
1103
+
1104
+ - `error` (default): build aborts on any error-severity finding.
1105
+ - `warning`: build aborts on any error or warning finding (paranoid mode).
1106
+ - `never`: print findings, never fail (advisory mode).
1107
+
1108
+ For projects that want to run the gate stand-alone — pre-commit hooks, IDE integrations, ad-hoc audits — use the companion sub-command:
1109
+
1110
+ ```sh
1111
+ jso ai compat-scan --config jso.config.json --fail-on error
1112
+ jso ai compat-scan --config jso.config.json --max-files 50 # cap quota burn on huge repos
1113
+ ```
1114
+
1115
+ Both paths hit the same `/v1/ai/compat-check` endpoint. `--ai-precheck` just folds it into the obfuscation flow so CI doesn't need a second step. Requires a JSO API key with AI access — FreeTrial works for testing the wire format; Basic and up for production usage. See the [JSO AI quick start](https://www.javascriptobfuscator.com/Docs/AIQuickStart.aspx) for tier details.
1116
+
1117
+ ### AI usage and BYO key health
1118
+
1119
+ Use the bundled AI CLI when an account owner or release job needs to confirm quota and BYO provider-key readiness without opening the dashboard.
1120
+
1121
+ ```sh
1122
+ jso ai usage --pretty
1123
+ # tier: Pro
1124
+ # actions: 12 / 500 (488 remaining)
1125
+ # AI key health: Key ready (openai) [ready]
1126
+ # next key test: 2026-06-25T00:00:00Z
1127
+ # rotation review: 2026-08-24T00:00:00Z
1128
+ ```
1129
+
1130
+ Programmatic callers get the same source-free state from the typed Node client:
1131
+
1132
+ ```js
1133
+ const { ai } = require("jso-protector");
1134
+
1135
+ const usage = await ai.usage();
1136
+ if (usage.providerKey && usage.providerKey.status !== "ready") {
1137
+ console.warn("AI key health:", usage.providerKey.label);
1138
+ }
1139
+ ```
1140
+
1141
+ The `AiProviderKeyHealth` shape reports provider, status label, last test, next stored-key test, rotation review, and recommended action. It does not return the provider secret or key suffix.
1142
+
1143
+ ### Pre-flight quota gate — `--estimate`
1144
+
1145
+ Add `--estimate` to any obfuscation command to do a cost check before submitting any source. The CLI walks your input file set, hits the existing `/v1/ai/usage` endpoint to read the current month's quota, and prints a CI-friendly report. The gate has three states:
1146
+
1147
+ - **OK** (exit 0) — quota healthy, build can proceed.
1148
+ - **WARN** (exit 0) — fewer than 5 actions remaining OR cost cap below 20%. Print, don't block.
1149
+ - **FAIL** (exit 1) — actions remaining = 0. Block the build before it consumes any more.
1150
+
1151
+ ```sh
1152
+ jso-protector --config jso.config.json --estimate
1153
+ jso-protector --config jso.config.json --estimate --json # machine-readable
1154
+ ```
1155
+
1156
+ Network failures on `/v1/ai/usage` downgrade to WARN with a note (don't crash the build pipeline over an observability gap).
1157
+
1158
+ When the usage endpoint includes BYO provider-key health, `--estimate` also prints the source-free AI key state: provider, status label, next 30-day stored-key test due date, 90-day rotation review date, and recommended action. The JSON output exposes the same data under `estimate.providerKey` without returning the provider secret or key suffix, so CI can alert on missing, failed, stale, or rotation-review-due AI keys before a release run depends on provider-backed assistance.
1159
+
1160
+ ### Watermarking — anti-piracy + dispute proof
1161
+
1162
+ `--watermark <tag> --watermark-key <secret>` injects an HMAC-SHA256-signed header comment at the top of every input file. The obfuscator's `KeepComment` option preserves it verbatim through every transform (string array moves, control-flow flattening, dead code, etc.), so the marker survives intact in the protected output. Holders of the secret can verify; everyone else sees an opaque comment block.
1163
+
1164
+ ```sh
1165
+ # Stamp during build:
1166
+ jso-protector --config jso.config.json \
1167
+ --watermark "release-2026-Q3" --watermark-key "$JSO_WATERMARK_KEY"
1168
+
1169
+ # Verify a single file post-deploy:
1170
+ jso-protector --verify-watermark dist-protected/app.js --watermark-key "$JSO_WATERMARK_KEY"
1171
+ # OK dist-protected/app.js: valid watermark, tag=release-2026-Q3
1172
+
1173
+ # Bulk-scan a directory (CDN audit / forensic inventory):
1174
+ jso-protector --scan-watermarks dist-protected/ --watermark-key "$JSO_WATERMARK_KEY"
1175
+ # Scanned 42 JS file(s) under dist-protected/
1176
+ # Watermarked: 42 valid=42 invalid=0
1177
+ ```
1178
+
1179
+ Without `--watermark-key`, verifiers run in **lookup-only mode**: they print the embedded tag but skip the HMAC compare. Useful for forensic inspection of leaked artifacts where you don't (or shouldn't) ship the secret to the investigator.
1180
+
1181
+ Wire format is identical across the Node, Python (`jso_protector.watermark`), and .NET (`JsoProtector.Watermark`) clients — an artifact stamped by any verifies under any. Reads `JSO_WATERMARK_KEY` from env when the flag isn't passed.
1182
+
1183
+ Exit codes (`--scan-watermarks`): **0** all clean / **1** at least one invalid signature found / **2** no watermarks found at all.
1184
+
1185
+ ### Signed release attestations — SLSA-style
1186
+
1187
+ `--sign-release <priv.pem>` produces an Ed25519-signed envelope alongside your existing `--manifest` file. The envelope covers BuildId, polymorphism fingerprint, release label, and per-file SHA-256 hashes:
1188
+
1189
+ ```sh
1190
+ # One-time: mint a keypair (writes .priv.pem 0o600, .pub.pem 0o644):
1191
+ jso-protector --genkey-release ci-signing-key
1192
+
1193
+ # Build + sign:
1194
+ jso-protector --config jso.config.json \
1195
+ --manifest dist-protected/build.manifest.json \
1196
+ --sign-release ci-signing-key.priv.pem
1197
+ # -> dist-protected/build.manifest.json.sig
1198
+
1199
+ # Verify post-deploy:
1200
+ jso-protector --verify-release dist-protected/build.manifest.json.sig \
1201
+ --public-key ci-signing-key.pub.pem \
1202
+ --verify-root dist-protected/
1203
+ # OK .../build.manifest.json.sig: signature valid (BuildId=...), 42 file(s) re-hashed
1204
+ ```
1205
+
1206
+ Two-stage verification:
1207
+
1208
+ - **Stage 1** — Ed25519 signature over canonical-JSON manifest (catches forgery + manifest tampering).
1209
+ - **Stage 2** — re-hash every referenced file on disk and compare against the embedded SHA-256 (catches post-signing tampering of the actual artifacts). Triggered when `--verify-root <dir>` is supplied.
1210
+
1211
+ Without `--public-key`, the envelope's embedded public key is trusted (signature-only verification). With it, embedded != trusted → fail fast (defeats key-substitution attacks).
1212
+
1213
+ Ed25519 chosen for 64-byte signatures, 32-byte keys, fast verify, no key-size choices to fumble. Node has it built-in since v12 — zero new dependencies.
1214
+
1215
+ Use `--migrate-javascript-obfuscator` to convert a common `javascript-obfuscator` JSON or trusted CommonJS config into a starter `jso.config.json`. The migration report maps familiar options where possible, lists review items for options that are not one-to-one, includes a per-config summary with source option, mapped, review-only, unmapped, and automatic coverage counts, and prints the next validate, dry-run, doctor, release-check, competitor-gap-report, and protect commands. When any review-only migration item is present, it adds a `migration-review` next command so release owners get one source-free checklist before approval. When source-map review items are present, it also adds the post-protect `source-map-evidence` next command. When identifier cache, custom dictionary, or runtime-defense review items are present, it also adds the `identifier-cache-review` or `runtime-defense-review` next command so release owners can generate focused source-free review packets immediately. CommonJS source configs execute as Node.js code, so only migrate configs from your own repository or another trusted source.
1216
+
1217
+ Use `--list-js-confuser-migration-map --json`, `--explain-js-confuser-compat <option>`, and `--migrate-js-confuser` when migrating from JS-Confuser. The current migration path maps common preset, lock, string, identifier, minify, and control-flow options into the closest hosted API settings. Review-only runtime lock features such as anti-debugging, integrity, self-defending, start-date gates, countermeasure hooks, and tamper protection are carried into generated config as `jsConfuserLock*` review fields so they remain visible during manual follow-up.
1218
+
1219
+ Use `--release-check --json` as the default CI preflight before protection. It runs config validation, dry-run file planning, and doctor checks in one report without sending source code to the API unless you also pass `--check-api`. The plan includes the number of API items plus any transformed files created from marked HTML scripts or conditional regions. Add `--strict` when warnings, such as unknown option names or not-yet-created output folders, should fail the release job.
1220
+
1221
+ Use `--parse-html` when built HTML or template files contain inline scripts that should be protected. Markup files require this explicit mode before protection; the CLI will not send a whole document to the JavaScript API path by accident. Only marked inline blocks are sent to the API:
1222
+
1223
+ ```html
1224
+ <script data-javascript-obfuscator>
1225
+ window.releaseWidget = createWidget();
1226
+ </script>
1227
+ ```
1228
+
1229
+ Unmarked inline scripts are preserved. Marked external scripts and marked module scripts fail with a clear warning because markup mode protects inline script contents only; protect referenced files directly through the JavaScript build pipeline. When `parseHtml` is enabled, the CLI automatically adds the configured `markupExtensions` list to protected extensions. By default that includes `.html`, `.htm`, `.php`, `.phtml`, `.asp`, `.aspx`, `.jsp`, `.cshtml`, and `.vbhtml`.
1230
+
1231
+ Use `--honor-conditional-comments` to preserve source regions marked with `javascript-obfuscator:disable` and `javascript-obfuscator:enable`. Without the flag, the CLI fails with a clear warning when markers are found so protected regions are not sent unexpectedly. With the flag, enabled regions are sent as separate API items and disabled regions are copied back verbatim. Markers must be balanced; an unmatched `disable`, unmatched `enable`, or nested disabled region fails before any source is sent.
1232
+
1233
+ ```js
1234
+ console.log("protect this");
1235
+ // javascript-obfuscator:disable
1236
+ console.log("keep this exact local code");
1237
+ // javascript-obfuscator:enable
1238
+ console.log("protect this too");
1239
+ ```
1240
+
1241
+ Use `--protect-marked-comments` when only selected sections of a file should be protected. Unmarked code is copied back verbatim, and only regions between `javascript-obfuscator:protect-begin` and `javascript-obfuscator:protect-end` are sent to the hosted API. Markers must be balanced and cannot be mixed with `disable`/`enable` markers in the same file.
1242
+
1243
+ ```js
1244
+ console.log("keep this exact local code");
1245
+ // javascript-obfuscator:protect-begin
1246
+ console.log("protect this algorithm");
1247
+ // javascript-obfuscator:protect-end
1248
+ console.log("keep this exact local code too");
1249
+ ```
1250
+
1251
+ Use `--local-only` when source cannot leave the build machine or when a teammate needs a quick reminder of the local package install path. The npm CLI can run validation, dry-run planning, doctor checks, release-check reports, and competitor gap reports locally, but actual npm CLI and desktop protection use the hosted service. Current protection workflows do not meet a policy that forbids source transfer. The command also reports that this package is local-only as a distribution artifact, not published to npm, and should be installed from a workspace path, `file:` dependency, or internal `npm pack` tarball.
1252
+
1253
+ Use `--validate-config --json` to check config shape, endpoint format, credentials presence, credential storage, path settings, budget values, and local option-name references without sending source code to the API. Unknown option names are reported as warnings so teams can catch typos while still using advanced HTTP API options. Inline `apiKey`, `apiPassword`, `--api-key`, and `--api-password` values also warn; prefer `$JSO_API_KEY` and `$JSO_API_PASSWORD` environment references so dashboard credentials do not land in committed config, shell history, or process logs.
1254
+
1255
+ Use `--print-config --json` to inspect the final resolved config after presets, config files, environment variables, and CLI overrides are merged. API credentials are redacted as `[set]` or `[missing]`.
1256
+
1257
+ Use `--manifest file.json` or `"manifest": "file.json"` to write a release manifest after a successful protection run. The manifest includes project metadata, preset, enabled option names, processing metadata for virtual API items, protected file sizes and SHA-256 hashes, copied asset hashes, and any grouped migration `limitations` still present in the config so artifact review does not depend on one earlier CLI preflight step.
1258
+
1259
+ Use `--verify-manifest file.json` to verify that a protected output folder or unpacked release artifact still matches the manifest hashes. By default, verification reads each entry's recorded `outputPath`. Add `--verify-root path/to/artifact` when the protected files were moved into a different folder after the manifest was written; verification then resolves each manifest `fileName` under that alternate root. Add `--audit-source-maps` in release CI to fail when protected JavaScript still contains `sourceMappingURL` comments or when copied artifacts include `.map` files.
1260
+
1261
+ Use `--source-map-evidence file.json --source-map-evidence-output reports/source-map-evidence.md` when a release reviewer needs a source-free packet proving protected artifacts do not expose source maps. The command reuses manifest hash verification, audits `.map` files and `sourceMappingURL` comments, emits Markdown by default or JSON with `--json`, and lists artifact names/reasons without embedding source code or source-map contents. The packet now includes a Source Map Review Assistant for BYO AI or internal reviewers, with prompts for leak cleanup, manifest verification, secure debugging exceptions, bundler cleanup order, and clean reviewer handoff without sharing raw `.map` files, original source paths, source code, protected output, customer data, or secrets. Add `--verify-root path/to/artifact` when the manifest was moved before review.
1262
+
1263
+ Use `--verify-vm-proof report.json` to verify that a saved API report proves VM protection ran for at least one function. Add `--min-vm-functions 2` or a higher number when the release intentionally marks multiple functions. The check is local and source-free: it reads the report written by `--report`, then validates `UseVMProtection`, `VMProtectionApplied`, `VMProtectionVirtualizedCount`, and `VMProtectionWarnings`.
1264
+
1265
+ VM function markers accept `// @virtualize`, `/* @virtualize */`, and `/** @virtualize */` immediately before a supported synchronous function declaration. The server normalizes block and JSDoc markers before the VM sidecar runs, so proof failures should focus on unsupported function syntax, account eligibility, or sidecar warnings instead of comment shape.
1266
+
1267
+ Use `--vm-proof-pack report.json --vm-proof-output reports/vm-proof-pack.md` when a security reviewer needs one source-free VM evidence packet. The Markdown output includes build identity, release label, polymorphism fingerprint, VM proof checks, review decision, warnings, compatibility guidance, hot-path/cold-path performance guidance, next actions, and a VM Proof Review Assistant for BYO AI or internal reviewers. The assistant prompts owners to resolve failed proof checks, handle VM warnings, confirm cold sensitive function scope, exclude hot paths, and attach protected-build smoke results without sending source code, protected output, VM bytecode, source maps, provider keys, customer data, or secrets. Add `--json` to write the same packet as machine-readable JSON. A passing VM proof pack can still say `ready-for-manual-review` when the release owner must confirm the selected functions are cold sensitive paths and attach smoke-test results.
1268
+
1269
+ Use `--ai-resistance-evidence report.json --ai-resistance-evidence-output reports/ai-resistance-evidence.md` when a security reviewer or buyer asks what can be checked today for AI-aware protection. The command stays local, reads the saved API report, and emits a source-free evidence summary with a non-scoring attacker-model review matrix, review decision, claim boundaries, and a Review Assistant Packet for BYO AI or internal reviewers. The assistant prompts owners to resolve failed evidence, confirm missing review tracks, check VM/runtime/compatibility scope, and keep Resistance Score wording in the planned-methodology lane without pasting source code, protected output, source maps, provider keys, or secrets into a reviewer or AI prompt. The decision is `blocked` when required evidence fails, `ready-for-manual-review` when required checks pass but optional review tracks need confirmation, or `ready` when every current track is evidenced. It does not call an AI model and it does not claim the planned Resistance Score is live. Add `--json` to write the same packet as machine-readable JSON, and add `--require-vm-proof` to fail when the same report does not pass the VM proof checks.
1270
+
1271
+ Use `--script-inventory-audit inventory.json --runtime-inventory-snapshot snapshot.json` when checkout owners need a source-free reconciliation between the approved payment-page script inventory and what the browser actually observed. Markdown is emitted by default; add `--json` for automation. The command fails the gate when unknown, unauthorized, missing, changed, late-injected, or required metadata-incomplete scripts need review. Missing optional `risk`, `dataAccess`, and `approvalTicket` values are reported as review-context gaps, not blocking failures. Each audit also includes a source-free Review Assistant Packet for BYO AI or internal reviewer triage, with safe-input boundaries and prompts for owner actions, data-access review, integrity drift, and approval-ticket cleanup.
1272
+
1273
+ Use `--payment-page-headers-from-har checkout.har --payment-page-headers-output payment-page-headers.json` when checkout owners need a source-free payment-page security-header snapshot from a browser or synthetic-monitor HAR. Add `--payment-page-headers-baseline approved-headers.json` to mark each checkout page or frame as matching, changed, or missing from the approved header baseline. The JSON output includes a source-free security-header Review Assistant Packet for BYO AI or internal reviewers, with safe-input boundaries and prompts for baseline drift, CSP/reporting gaps, HSTS coverage, and frame-policy owner actions.
1274
+
1275
+ 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.
1276
+
1277
+ 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.
1278
+
1279
+ ## Package Verification
1280
+
1281
+ Before publishing or tagging a release, run the install verification smoke:
1282
+
1283
+ ```bash
1284
+ npm run verify:package
1285
+ ```
1286
+
1287
+ 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.
1288
+
1289
+ ## Security and Processing
1290
+
1291
+ 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.
1292
+
1293
+ ## Live API Smoke Test
1294
+
1295
+ After setting `JSO_API_KEY` and `JSO_API_PASSWORD`, run a tiny live API check from this package directory:
1296
+
1297
+ ```bash
1298
+ npm run smoke:api
1299
+ ```
1300
+
1301
+ 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.
1302
+
1303
+ ## Doctor
1304
+
1305
+ 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:
1306
+
1307
+ ```bash
1308
+ jso-protector --config jso.config.json --release-check
1309
+ jso-protector --config jso.config.json --release-check --json
1310
+ jso-protector --config jso.config.json --release-check --strict --json
1311
+ ```
1312
+
1313
+ Run `validate-config` first when you want a fast static check:
1314
+
1315
+ ```bash
1316
+ jso-protector --config jso.config.json --validate-config
1317
+ jso-protector --config jso.config.json --validate-config --json
1318
+ jso-protector --config jso.config.json --validate-config --strict --json
1319
+ ```
1320
+
1321
+ 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:
1322
+
1323
+ ```bash
1324
+ jso-protector --config jso.config.json --doctor
1325
+ jso-protector --config jso.config.json --doctor --json
1326
+ ```
1327
+
1328
+ `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.
1329
+
1330
+ When a config still carries competitor-only migration fields such as source-map flags, identifier cache paths, custom naming dictionaries, or JS-Confuser runtime lock notes, `validate-config`, `doctor`, and `release-check` now emit grouped `limitations` entries in JSON output and `LIMITATION ...` lines in text output so CI can surface the remaining manual-review items explicitly.
1331
+
1332
+ Run the standalone competitor gap report when you want a machine-readable parity summary for migrated configs:
1333
+
1334
+ ```bash
1335
+ jso-protector --config jso.config.json --competitor-gap-report --json
1336
+ ```
1337
+
1338
+ When a migrated config used deterministic identifier caches or custom
1339
+ identifier dictionaries, generate a reviewer packet for that specific gap:
1340
+
1341
+ ```bash
1342
+ jso-protector --config jso.config.json --identifier-cache-review \
1343
+ --identifier-cache-review-output reports/identifier-cache-review.md
1344
+ ```
1345
+
1346
+ The packet is source-free. It lists the migration field names, counts,
1347
+ replacement evidence tracks, and review decision without embedding cache
1348
+ contents, dictionary values, prefixes, reserved-name expressions, or source
1349
+ code. The Identifier Cache Review Assistant gives BYO AI or internal reviewers
1350
+ owner-action prompts for deterministic cache assumptions, custom dictionary
1351
+ replacement, reserved-name coverage, release metadata, and protected-build
1352
+ smoke without exposing raw config files, API credentials, provider keys,
1353
+ customer data, or secrets.
1354
+
1355
+ When a migrated config used anti-debug, self-defending, runtime lock, console,
1356
+ or countermeasure controls, generate the runtime-defense migration review:
1357
+
1358
+ ```bash
1359
+ jso-protector --config jso.config.json --runtime-defense-review \
1360
+ --runtime-defense-review-output reports/runtime-defense-review.md
1361
+ ```
1362
+
1363
+ The packet is source-free. It turns anti-debug, self-defending, runtime lock,
1364
+ console, and countermeasure migration settings into a reviewer checklist with
1365
+ monitoring target, customer-owned forwarding, countermeasure policy,
1366
+ domain/date lock, release metadata, compatibility scan, and protected-build
1367
+ smoke-test tracks. It omits domains, dates, redirect URLs, beacon URLs,
1368
+ countermeasure values, source code, protected output, and compatibility-scan
1369
+ source snippets. The Runtime Defense Review Assistant gives BYO AI or internal
1370
+ reviewers owner-action prompts for runtime behavior scope, monitoring handoff,
1371
+ countermeasure policy, domain/date lock smoke, source-reading compatibility
1372
+ scan, release metadata, and protected-build smoke without exposing raw config
1373
+ files, API credentials, provider keys, collector tokens, customer data, or
1374
+ secrets.
1375
+
1376
+ Add `--check-api` to `release-check` or `doctor` when CI should send a tiny live request to verify the endpoint and credentials:
1377
+
1378
+ ```bash
1379
+ jso-protector --config jso.config.json --release-check --check-api --json
1380
+ jso-protector --config jso.config.json --doctor --check-api --json
1381
+ ```
1382
+
1383
+ ## Examples and CI Templates
1384
+
1385
+ Copyable examples are included in `examples/`:
1386
+
1387
+ - `examples/cli-basic`
1388
+ - `examples/node-api`
1389
+ - `examples/parcel`
1390
+ - `examples/bun`
1391
+ - `examples/browserify`
1392
+ - `examples/metro.config.js`
1393
+ - `examples/nextjs`
1394
+ - `examples/turbopack`
1395
+ - `examples/rspack`
1396
+ - `examples/esbuild`
1397
+ - `examples/vite`
1398
+ - `examples/rollup`
1399
+ - `examples/webpack`
1400
+ - `examples/webpack-loader`
1401
+ - `examples/gulp`
1402
+ - `examples/grunt`
1403
+ - `examples/react-native/metro.config.js`
1404
+
1405
+ `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.
1406
+
1407
+ CI templates are included in `ci/`:
1408
+
1409
+ - `ci/github-actions.yml`
1410
+ - `ci/gitlab-ci.yml`
1411
+ - `ci/azure-pipelines.yml`
1412
+
1413
+ 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.
1414
+
1415
+ ## Migrating from javascript-obfuscator
1416
+
1417
+ 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.
1418
+
1419
+ 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.
1420
+
1421
+ ## GitHub Actions
1422
+
1423
+ 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:
1424
+
1425
+ ```yaml
1426
+ name: protected-release
1427
+
1428
+ on:
1429
+ workflow_dispatch:
1430
+
1431
+ jobs:
1432
+ release:
1433
+ runs-on: ubuntu-latest
1434
+ steps:
1435
+ - uses: actions/checkout@v4
1436
+ - uses: actions/setup-node@v4
1437
+ with:
1438
+ node-version: 22
1439
+ cache: npm
1440
+ - run: npm ci
1441
+ - run: npm run build
1442
+ - run: npm run verify:package --if-present
1443
+ - run: npm run verify:publish-metadata --if-present
1444
+ - name: Release preflight
1445
+ run: npx jso-protector --config jso.config.json --release-check --json
1446
+ env:
1447
+ JSO_API_KEY: ${{ secrets.JSO_API_KEY }}
1448
+ JSO_API_PASSWORD: ${{ secrets.JSO_API_PASSWORD }}
1449
+ - name: Protect JavaScript
1450
+ run: npx jso-protector --config jso.config.json --manifest dist-protected/jso-manifest.json
1451
+ env:
1452
+ JSO_API_KEY: ${{ secrets.JSO_API_KEY }}
1453
+ JSO_API_PASSWORD: ${{ secrets.JSO_API_PASSWORD }}
1454
+ - run: npm run smoke
1455
+ - uses: actions/upload-artifact@v4
1456
+ with:
1457
+ name: protected-dist
1458
+ path: |
1459
+ dist-protected/
1460
+ dist-protected/jso-manifest.json
1461
+ ```
1462
+
1463
+ ## Release Checklist
1464
+
1465
+ 1. Build unprotected JavaScript into a temporary output folder.
1466
+ 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.
1467
+ 3. Protect into a separate output folder such as `dist-protected` and write `dist-protected/jso-manifest.json`.
1468
+ 4. Run browser smoke tests against the protected output.
1469
+ 5. Run `jso-protector --verify-manifest dist-protected/jso-manifest.json --audit-source-maps` before publishing or after unpacking release artifacts.
1470
+ 6. Publish only the protected artifacts and release manifest.
1471
+
1472
+ ## Notes
1473
+
1474
+ - The CLI sends file contents to the configured HTTP API endpoint.
1475
+ - 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.
1476
+ - The HTTP API is for paid accounts.
1477
+ - The CLI expects the API response shape used by `HttpApi.ashx`: `Type`, `Items`, `Message`, `FileName`, and optional error fields.