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/index.d.ts ADDED
@@ -0,0 +1,879 @@
1
+ export type PresetName = "standard" | "balanced" | "maximum";
2
+ export type InitTemplateName = "browser-app" | "html-app" | "node-app" | "electron-app" | "nextjs-app" | "vite-app" | "parcel-app" | "bun-app" | "browserify-app" | "webpack-app" | "rspack-app" | "turbopack-app" | "react-native-app";
3
+
4
+ export interface ProtectionOptions {
5
+ config?: string;
6
+ configFile?: string;
7
+ mode?: string | null;
8
+ javascriptObfuscatorOptions?: JavascriptObfuscatorCompatibilityOptions;
9
+ jsConfuserOptions?: JsConfuserCompatibilityOptions;
10
+ compact?: boolean;
11
+ controlFlowFlattening?: boolean;
12
+ debugProtection?: boolean;
13
+ debugProtectionInterval?: number;
14
+ deadCodeInjection?: boolean;
15
+ deadCodeInjectionThreshold?: number;
16
+ disableConsoleOutput?: boolean;
17
+ domainLock?: string | string[];
18
+ domainLockRedirectUrl?: string;
19
+ forceTransformStrings?: string[];
20
+ identifiersDictionary?: string[];
21
+ identifiersPrefix?: string;
22
+ identifierNamesGenerator?: string;
23
+ identifierNamesCache?: Record<string, unknown> | null;
24
+ identifierNamesCachePath?: string;
25
+ inputFileName?: string;
26
+ log?: boolean;
27
+ numbersToExpressions?: boolean;
28
+ optionsPreset?: string;
29
+ parseHtml?: boolean;
30
+ renameGlobals?: boolean;
31
+ renameProperties?: boolean;
32
+ renamePropertiesMode?: string;
33
+ reservedStrings?: string[];
34
+ seed?: string | number;
35
+ selfDefending?: boolean;
36
+ simplify?: boolean;
37
+ sourceMap?: boolean;
38
+ sourceMapBaseUrl?: string;
39
+ sourceMapFileName?: string;
40
+ sourceMapMode?: string;
41
+ sourceMapSourcesMode?: string;
42
+ strictMode?: boolean | null;
43
+ splitStrings?: boolean;
44
+ splitStringsChunkLength?: number;
45
+ stringArray?: boolean;
46
+ stringArrayCallsTransform?: boolean;
47
+ stringArrayCallsTransformThreshold?: number;
48
+ stringArrayEncoding?: string | string[];
49
+ stringArrayIndexShift?: boolean;
50
+ stringArrayIndexesType?: string | string[];
51
+ stringArrayRotate?: boolean;
52
+ stringArrayShuffle?: boolean;
53
+ stringArrayThreshold?: number;
54
+ stringArrayWrappersChainedCalls?: boolean;
55
+ stringArrayWrappersCount?: number;
56
+ stringArrayWrappersParametersMaxCount?: number;
57
+ stringArrayWrappersType?: string;
58
+ target?: string;
59
+ transformObjectKeys?: boolean;
60
+ unicodeEscapeSequence?: boolean;
61
+ ignoreImports?: boolean;
62
+ endpoint?: string;
63
+ apiKey?: string;
64
+ apiPassword?: string;
65
+ projectName?: string;
66
+ input?: string;
67
+ output?: string;
68
+ preset?: PresetName;
69
+ webPreset?: string;
70
+ include?: string[];
71
+ extensions?: string[];
72
+ markupExtensions?: string[];
73
+ exclude?: string[];
74
+ assetExclude?: string[];
75
+ copyAssets?: boolean;
76
+ mixedServer?: boolean;
77
+ removeSourceMaps?: boolean;
78
+ honorConditionalComments?: boolean;
79
+ protectMarkedComments?: boolean;
80
+ keepHeaderComment?: boolean;
81
+ protectObjectDeclaration?: boolean;
82
+ moveNestedFunction?: boolean;
83
+ formattedOutput?: boolean;
84
+ keepIndent?: boolean;
85
+ lineNumbers?: boolean;
86
+ lockDomainSubdomains?: boolean;
87
+ lockDomainMessage?: string;
88
+ lockDate?: boolean;
89
+ lockDateValue?: string;
90
+ lockDateMessage?: string;
91
+ jsConfuserLockAntiDebug?: boolean | number;
92
+ jsConfuserLockIntegrity?: boolean | number;
93
+ jsConfuserLockSelfDefending?: boolean | number;
94
+ jsConfuserLockStartDate?: string;
95
+ jsConfuserLockCountermeasures?: string;
96
+ jsConfuserLockTamperProtection?: boolean | number;
97
+ reservedNames?: string[];
98
+ variableExclusion?: string;
99
+ manifest?: string;
100
+ maxOutputBytes?: number;
101
+ maxGrowthRatio?: number;
102
+ options?: Record<string, unknown>;
103
+ }
104
+
105
+ export interface JsConfuserLockCompatibilityOptions {
106
+ antiDebug?: boolean | number;
107
+ countermeasures?: unknown;
108
+ customLocks?: unknown;
109
+ domainLock?: string | string[];
110
+ endDate?: string | Date;
111
+ integrity?: boolean | number;
112
+ selfDefending?: boolean | number;
113
+ startDate?: string | Date;
114
+ tamperProtection?: boolean | number;
115
+ }
116
+
117
+ export interface JsConfuserCompatibilityOptions {
118
+ astScrambler?: boolean | number;
119
+ calculator?: boolean | number;
120
+ compact?: boolean;
121
+ controlFlowFlattening?: boolean | number;
122
+ deadCode?: boolean | number;
123
+ dispatcher?: boolean | number;
124
+ duplicateLiteralsRemoval?: boolean | number;
125
+ flatten?: boolean | number;
126
+ globalConcealing?: boolean | number;
127
+ hexadecimalNumbers?: boolean | number;
128
+ identifierGenerator?: string;
129
+ lock?: JsConfuserLockCompatibilityOptions;
130
+ minify?: boolean;
131
+ movedDeclarations?: boolean | number;
132
+ objectExtraction?: boolean | number;
133
+ opaquePredicates?: boolean | number;
134
+ pack?: boolean | number | string;
135
+ preserveFunctionLength?: boolean;
136
+ preset?: "low" | "medium" | "high" | string;
137
+ renameGlobals?: boolean | number;
138
+ renameLabels?: boolean | number;
139
+ renameVariables?: boolean | number;
140
+ rgf?: boolean | number;
141
+ shuffle?: boolean | number;
142
+ stringCompression?: boolean | number;
143
+ stringConcealing?: boolean | number;
144
+ stringEncoding?: boolean | number | ((value: string) => boolean);
145
+ target?: "browser" | "node" | string;
146
+ variableMasking?: boolean | number;
147
+ }
148
+
149
+ export interface JavascriptObfuscatorCompatibilityOptions {
150
+ compact?: boolean;
151
+ controlFlowFlattening?: boolean;
152
+ debugProtection?: boolean;
153
+ debugProtectionInterval?: number;
154
+ deadCodeInjection?: boolean;
155
+ deadCodeInjectionThreshold?: number;
156
+ disableConsoleOutput?: boolean;
157
+ domainLock?: string | string[];
158
+ domainLockRedirectUrl?: string;
159
+ forceTransformStrings?: string[];
160
+ identifiersDictionary?: string[];
161
+ identifiersPrefix?: string;
162
+ identifierNamesGenerator?: string;
163
+ identifierNamesCache?: Record<string, unknown> | null;
164
+ identifierNamesCachePath?: string;
165
+ inputFileName?: string;
166
+ log?: boolean;
167
+ numbersToExpressions?: boolean;
168
+ optionsPreset?: string;
169
+ renameGlobals?: boolean;
170
+ renameProperties?: boolean;
171
+ renamePropertiesMode?: string;
172
+ reservedNames?: string[];
173
+ reservedStrings?: string[];
174
+ seed?: string | number;
175
+ selfDefending?: boolean;
176
+ simplify?: boolean;
177
+ strictMode?: boolean | null;
178
+ stringArray?: boolean;
179
+ stringArrayCallsTransform?: boolean;
180
+ stringArrayCallsTransformThreshold?: number;
181
+ stringArrayEncoding?: string | string[];
182
+ stringArrayIndexShift?: boolean;
183
+ stringArrayIndexesType?: string | string[];
184
+ stringArrayRotate?: boolean;
185
+ stringArrayShuffle?: boolean;
186
+ stringArrayThreshold?: number;
187
+ stringArrayWrappersChainedCalls?: boolean;
188
+ stringArrayWrappersCount?: number;
189
+ stringArrayWrappersParametersMaxCount?: number;
190
+ stringArrayWrappersType?: string;
191
+ target?: string;
192
+ transformObjectKeys?: boolean;
193
+ unicodeEscapeSequence?: boolean;
194
+ sourceMap?: boolean;
195
+ sourceMapBaseUrl?: string;
196
+ sourceMapFileName?: string;
197
+ sourceMapMode?: string;
198
+ sourceMapSourcesMode?: string;
199
+ splitStrings?: boolean;
200
+ splitStringsChunkLength?: number;
201
+ ignoreImports?: boolean;
202
+ }
203
+
204
+ export interface ResolvedProtectionConfig extends ProtectionOptions {
205
+ endpoint: string;
206
+ apiKey: string;
207
+ apiPassword: string;
208
+ projectName: string;
209
+ input: string;
210
+ output: string;
211
+ preset: PresetName;
212
+ include: string[];
213
+ extensions: string[];
214
+ markupExtensions: string[];
215
+ exclude: string[];
216
+ assetExclude: string[];
217
+ copyAssets: boolean;
218
+ mixedServer: boolean;
219
+ removeSourceMaps: boolean;
220
+ parseHtml: boolean;
221
+ honorConditionalComments: boolean;
222
+ protectMarkedComments: boolean;
223
+ ignoreImports: boolean;
224
+ manifest: string | null;
225
+ maxOutputBytes: number | null;
226
+ maxGrowthRatio: number | null;
227
+ options: Record<string, unknown>;
228
+ }
229
+
230
+ export interface HttpFileItem {
231
+ FileName: string;
232
+ FileCode: string;
233
+ }
234
+
235
+ export interface HttpResult {
236
+ Type: string;
237
+ Items?: HttpFileItem[];
238
+ ErrorCode?: string;
239
+ Message?: string;
240
+ FileName?: string;
241
+ LineNumber?: string;
242
+ ExceptionToString?: string;
243
+ }
244
+
245
+ export interface FileMapping {
246
+ source: string;
247
+ relative: string;
248
+ target: string;
249
+ }
250
+
251
+ export interface ManifestFile {
252
+ fileName: string;
253
+ sourcePath: string;
254
+ outputPath: string;
255
+ sourceBytes: number;
256
+ outputBytes: number;
257
+ sourceSha256: string;
258
+ outputSha256: string;
259
+ }
260
+
261
+ export interface ManifestAsset {
262
+ fileName: string;
263
+ sourcePath: string;
264
+ outputPath: string;
265
+ bytes: number;
266
+ sha256: string;
267
+ }
268
+
269
+ export interface CompetitorLimitation {
270
+ id: string;
271
+ title: string;
272
+ fields: string[];
273
+ message: string;
274
+ recommendation: string;
275
+ }
276
+
277
+ export interface CompetitorCapability {
278
+ id: string;
279
+ capability: string;
280
+ competitorExamples: string[];
281
+ status: "covered" | "partial" | "gap" | string;
282
+ jsoSupport: string;
283
+ evidence: string[];
284
+ }
285
+
286
+ export interface CompetitorGapReportSummary {
287
+ capabilities: number;
288
+ covered: number;
289
+ partial: number;
290
+ gaps: number;
291
+ triggeredLimitations: number;
292
+ }
293
+
294
+ export interface CompetitorGapReport {
295
+ format: "jso-protector-competitor-gap-report";
296
+ version: 1;
297
+ summary: CompetitorGapReportSummary;
298
+ competitors: string[];
299
+ capabilities: CompetitorCapability[];
300
+ limitations: CompetitorLimitation[];
301
+ recommendedPlan: string[];
302
+ }
303
+
304
+ export interface ProtectionManifest {
305
+ format: "jso-protector-manifest";
306
+ version: 1;
307
+ generatedAt: string;
308
+ endpoint: string;
309
+ projectName: string;
310
+ preset: PresetName;
311
+ options: string[];
312
+ processing?: ProtectionProcessingSummary;
313
+ limitations?: CompetitorLimitation[];
314
+ files: ManifestFile[];
315
+ assets: ManifestAsset[];
316
+ }
317
+
318
+ export interface VerifiedManifestEntry {
319
+ kind: "file" | "asset";
320
+ fileName: string;
321
+ path: string;
322
+ ok: boolean;
323
+ reason: "ok" | "missing" | "size-mismatch" | "sha256-mismatch";
324
+ expectedBytes: number;
325
+ expectedSha256: string;
326
+ actualBytes: number | null;
327
+ actualSha256: string | null;
328
+ }
329
+
330
+ export interface ManifestVerificationSummary {
331
+ total: number;
332
+ ok: number;
333
+ missing: number;
334
+ mismatched: number;
335
+ }
336
+
337
+ export interface ManifestVerificationReport {
338
+ format: "jso-protector-manifest-check";
339
+ version: 1;
340
+ ok: boolean;
341
+ manifestPath: string;
342
+ verifyRoot: string | null;
343
+ generatedAt: string;
344
+ projectName: string | null;
345
+ preset: PresetName | null;
346
+ summary: ManifestVerificationSummary;
347
+ files: VerifiedManifestEntry[];
348
+ assets: VerifiedManifestEntry[];
349
+ }
350
+
351
+ export interface ProtectionTransformSummary {
352
+ fileName: string;
353
+ type: string;
354
+ apiItems: number;
355
+ preservedParts: number;
356
+ }
357
+
358
+ export interface ProtectionProcessingSummary {
359
+ apiItems: number;
360
+ transformedFiles: ProtectionTransformSummary[];
361
+ }
362
+
363
+ export interface ProtectionItems {
364
+ items: HttpFileItem[];
365
+ transforms: Map<string, unknown>;
366
+ }
367
+
368
+ export interface ProtectionPlanSummary {
369
+ endpoint: string;
370
+ projectName: string;
371
+ preset: PresetName;
372
+ input: string;
373
+ output: string;
374
+ files: string[];
375
+ assets: string[];
376
+ options: string[];
377
+ processing?: ProtectionProcessingSummary;
378
+ }
379
+
380
+ export interface ProtectionPlan {
381
+ config: ResolvedProtectionConfig;
382
+ files: FileMapping[];
383
+ assets: FileMapping[];
384
+ protection: ProtectionItems;
385
+ summary: ProtectionPlanSummary;
386
+ }
387
+
388
+ export interface ProtectionRunResult extends ProtectionPlanSummary {
389
+ type: string;
390
+ written: string[];
391
+ copied: string[];
392
+ manifestPath: string | null;
393
+ manifest: ProtectionManifest;
394
+ result: HttpResult;
395
+ }
396
+
397
+ export interface ObfuscationResult {
398
+ code: string;
399
+ fileName: string;
400
+ result: HttpResult;
401
+ getObfuscatedCode(): string;
402
+ toString(): string;
403
+ getSourceMap(): null;
404
+ getIdentifierNamesCache(): null;
405
+ }
406
+
407
+ export interface SizeBudgetFailure {
408
+ fileName: string;
409
+ type: "max-output-bytes" | "max-growth-ratio";
410
+ actual: number;
411
+ limit: number;
412
+ }
413
+
414
+ export interface DoctorCheck {
415
+ name: string;
416
+ ok: boolean;
417
+ message: string;
418
+ }
419
+
420
+ export interface DoctorReport {
421
+ ok: boolean;
422
+ endpoint: string;
423
+ projectName: string;
424
+ preset: PresetName;
425
+ input: string;
426
+ output: string;
427
+ files: string[];
428
+ assets: string[];
429
+ limitations: CompetitorLimitation[];
430
+ checks: DoctorCheck[];
431
+ }
432
+
433
+ export interface ValidationCheck {
434
+ name: string;
435
+ level: "ok" | "warning" | "error";
436
+ ok: boolean;
437
+ message: string;
438
+ }
439
+
440
+ export interface ValidationReport {
441
+ ok: boolean;
442
+ strict: boolean;
443
+ warnings: number;
444
+ endpoint: string | null;
445
+ projectName: string | null;
446
+ preset: PresetName | null;
447
+ input: string | null;
448
+ output: string | null;
449
+ limitations: CompetitorLimitation[];
450
+ checks: ValidationCheck[];
451
+ }
452
+
453
+ export interface ReleasePlanReport {
454
+ ok: boolean;
455
+ input: string;
456
+ output: string;
457
+ files: string[];
458
+ assets: string[];
459
+ options: string[];
460
+ processing: ProtectionProcessingSummary;
461
+ manifest: string | null;
462
+ maxOutputBytes: number | null;
463
+ maxGrowthRatio: number | null;
464
+ error: string | null;
465
+ }
466
+
467
+ export interface ReleaseCheckReport {
468
+ format: "jso-protector-release-check";
469
+ version: 1;
470
+ ok: boolean;
471
+ endpoint: string | null;
472
+ projectName: string | null;
473
+ preset: PresetName | null;
474
+ validation: ValidationReport;
475
+ plan: ReleasePlanReport | { ok: false; error: string };
476
+ doctor: DoctorReport | null;
477
+ checkApi: boolean;
478
+ }
479
+
480
+ export interface MigrationMappedOption {
481
+ from: string;
482
+ to: string;
483
+ note?: string;
484
+ }
485
+
486
+ export interface MigrationMapEntry {
487
+ source: string;
488
+ target: string[];
489
+ confidence: "direct" | "approximate";
490
+ note: string;
491
+ }
492
+
493
+ export interface MigrationReviewOption {
494
+ option: string;
495
+ note: string;
496
+ }
497
+
498
+ export interface MigrationMap {
499
+ summary: MigrationMapSummary;
500
+ mappings: MigrationMapEntry[];
501
+ review: MigrationReviewOption[];
502
+ }
503
+
504
+ export interface MigrationMapSummary {
505
+ mapped: number;
506
+ direct: number;
507
+ approximate: number;
508
+ reviewOnly: number;
509
+ totalKnown: number;
510
+ }
511
+
512
+ export interface MigrationReport {
513
+ format: "jso-protector-migration";
514
+ version: 1;
515
+ source: string;
516
+ summary: MigrationReportSummary;
517
+ config: ProtectionOptions;
518
+ mapped: MigrationMappedOption[];
519
+ review: MigrationReviewOption[];
520
+ unmapped: string[];
521
+ nextCommands: MigrationNextCommand[];
522
+ notes: string[];
523
+ reviewReference: MigrationReviewOption[];
524
+ }
525
+
526
+ export interface MigrationNextCommand {
527
+ label: "validate" | "preview" | "doctor" | "release-check" | "competitor-gap" | "protect";
528
+ command: string;
529
+ }
530
+
531
+ export interface MigrationReportSummary {
532
+ sourceOptions: number;
533
+ mappedOptions: number;
534
+ direct: number;
535
+ approximate: number;
536
+ reviewOnly: number;
537
+ unmapped: number;
538
+ automaticCoverage: number;
539
+ }
540
+
541
+ export interface PresetReference {
542
+ name: PresetName;
543
+ options: Record<string, unknown>;
544
+ }
545
+
546
+ export interface OptionReference {
547
+ name: string;
548
+ type: string;
549
+ category: string;
550
+ description: string;
551
+ values?: string[];
552
+ }
553
+
554
+ export interface RedactedProtectionConfig {
555
+ endpoint: string;
556
+ mode: string | null;
557
+ apiKey: "[set]" | "[missing]";
558
+ apiPassword: "[set]" | "[missing]";
559
+ projectName: string;
560
+ preset: PresetName;
561
+ input: string;
562
+ output: string;
563
+ include: string[];
564
+ extensions: string[];
565
+ markupExtensions: string[];
566
+ exclude: string[];
567
+ assetExclude: string[];
568
+ copyAssets: boolean;
569
+ mixedServer: boolean;
570
+ removeSourceMaps: boolean;
571
+ parseHtml: boolean;
572
+ honorConditionalComments: boolean;
573
+ protectMarkedComments: boolean;
574
+ ignoreImports: boolean;
575
+ manifest: string | null;
576
+ maxOutputBytes: number | null;
577
+ maxGrowthRatio: number | null;
578
+ options: Record<string, unknown>;
579
+ }
580
+
581
+ export interface PackageMetadata {
582
+ name: string;
583
+ version: string;
584
+ description: string;
585
+ homepage: string;
586
+ endpoint: string;
587
+ }
588
+
589
+ export interface CompatibilityExplanation {
590
+ option: string;
591
+ status: "mapped" | "review-only" | "unknown" | string;
592
+ target: string[];
593
+ confidence: "direct" | "approximate" | "review" | "unknown" | string;
594
+ note: string;
595
+ }
596
+
597
+ export interface ParsedCliArgs {
598
+ config: string | null;
599
+ mode: string | null;
600
+ input: string | null;
601
+ output: string | null;
602
+ stdin: boolean;
603
+ stdout: boolean;
604
+ fileName: string;
605
+ preset: PresetName | null;
606
+ webPreset: string | null;
607
+ migrateJavascriptObfuscator: string | null;
608
+ migrateJsConfuser: string | null;
609
+ listMigrationMap: boolean;
610
+ listJsConfuserMigrationMap: boolean;
611
+ competitorGapReport: boolean;
612
+ explainCompat: string | null;
613
+ explainJsConfuserCompat: string | null;
614
+ localOnly: boolean;
615
+ options: string[];
616
+ reservedNames: string[];
617
+ include: string[];
618
+ exclude: string[];
619
+ assetExclude: string[];
620
+ parseHtml: boolean | null;
621
+ honorConditionalComments: boolean;
622
+ protectMarkedComments: boolean;
623
+ keepHeaderComment: boolean | null;
624
+ protectObjectDeclaration: boolean | null;
625
+ moveNestedFunction: boolean | null;
626
+ formattedOutput: boolean | null;
627
+ keepIndent: boolean | null;
628
+ lineNumbers: boolean | null;
629
+ manifest: string | null;
630
+ maxOutputBytes: number | null;
631
+ maxGrowthRatio: number | null;
632
+ endpoint: string | null;
633
+ apiKey: string | null;
634
+ apiPassword: string | null;
635
+ doctor: boolean;
636
+ checkApi: boolean;
637
+ releaseCheck: boolean;
638
+ strict: boolean;
639
+ validateConfig: boolean;
640
+ printConfig: boolean;
641
+ listPresets: boolean;
642
+ listOptions: boolean;
643
+ copyAssets: boolean;
644
+ dryRun: boolean;
645
+ json: boolean;
646
+ init: boolean;
647
+ initTemplate: InitTemplateName;
648
+ version: boolean;
649
+ help: boolean;
650
+ compatibilityWarnings: string[];
651
+ }
652
+
653
+ export interface ExampleConfigInitOptions {
654
+ template?: InitTemplateName | "default" | "web" | "browser" | "html" | "node" | "electron" | "desktop" | "next" | "nextjs" | "vite" | "webpack" | "rspack" | "turbopack" | "react-native" | "reactnative" | "metro" | "expo";
655
+ input?: string | null;
656
+ output?: string | null;
657
+ preset?: PresetName | null;
658
+ include?: string[];
659
+ exclude?: string[];
660
+ assetExclude?: string[];
661
+ parseHtml?: ParsedCliArgs["parseHtml"];
662
+ honorConditionalComments?: ParsedCliArgs["honorConditionalComments"] | null;
663
+ protectMarkedComments?: ParsedCliArgs["protectMarkedComments"] | null;
664
+ ignoreImports?: ProtectionOptions["ignoreImports"] | null;
665
+ manifest?: string | null;
666
+ maxOutputBytes?: number | null;
667
+ maxGrowthRatio?: number | null;
668
+ noCopyAssets?: boolean;
669
+ reservedNames?: string[];
670
+ options?: string[];
671
+ }
672
+
673
+ export const DEFAULT_ENDPOINT: string;
674
+ export const OPTION_REFERENCE: OptionReference[];
675
+ export const PRESET_OPTIONS: Record<PresetName, Record<string, unknown>>;
676
+
677
+ export function createProtectionConfig(options?: ProtectionOptions): ResolvedProtectionConfig;
678
+ export function ensureProtectionConfig(options?: ProtectionOptions | ResolvedProtectionConfig): ResolvedProtectionConfig;
679
+ export function obfuscate(code: string, options?: ProtectionOptions | ResolvedProtectionConfig, fileName?: string): Promise<ObfuscationResult>;
680
+ export function obfuscateCode(code: string, options?: ProtectionOptions | ResolvedProtectionConfig, fileName?: string): Promise<ObfuscationResult>;
681
+ export function obfuscateDirectory(options?: ProtectionOptions | ResolvedProtectionConfig): Promise<ProtectionRunResult>;
682
+ export function obfuscateFile(options?: ProtectionOptions | ResolvedProtectionConfig, sourcePath?: string, outputPath?: string): Promise<ProtectionRunResult>;
683
+ export function obfuscateFiles(options?: ProtectionOptions | ResolvedProtectionConfig): Promise<ProtectionRunResult>;
684
+ export function obfuscateMultiple(sourceCodesObject: Record<string, string>, options?: ProtectionOptions | ResolvedProtectionConfig): Promise<Record<string, ObfuscationResult>>;
685
+ export function getOptionsByPreset(optionsPreset?: PresetName): Record<string, unknown>;
686
+ export function getPackageMetadata(): PackageMetadata;
687
+ export function protectCode(options: ProtectionOptions | ResolvedProtectionConfig, code: string, fileName?: string): Promise<string>;
688
+ export function protectCodeDetailed(options: ProtectionOptions | ResolvedProtectionConfig, code: string, fileName?: string): Promise<{ code: string; result: HttpResult; protection: ProtectionItems; processing: ProtectionProcessingSummary }>;
689
+ export function protectDirectory(options?: ProtectionOptions | ResolvedProtectionConfig): Promise<ProtectionRunResult>;
690
+ export function protectFile(options?: ProtectionOptions | ResolvedProtectionConfig, sourcePath?: string, outputPath?: string): Promise<ProtectionRunResult>;
691
+ export function protectFiles(options?: ProtectionOptions | ResolvedProtectionConfig): Promise<ProtectionRunResult>;
692
+ export function planProtection(options?: ProtectionOptions | ResolvedProtectionConfig): ProtectionPlan;
693
+ export function protectItems(options: ProtectionOptions | ResolvedProtectionConfig, items: HttpFileItem[]): Promise<HttpResult>;
694
+ export function translateJsConfuserOptions(sourceOptions?: JsConfuserCompatibilityOptions, overrides?: ProtectionOptions): ProtectionOptions;
695
+ export function translateJavascriptObfuscatorOptions(sourceOptions?: JavascriptObfuscatorCompatibilityOptions, overrides?: ProtectionOptions): ProtectionOptions;
696
+
697
+ export function buildRequest(config: ResolvedProtectionConfig, files: FileMapping[]): Record<string, unknown>;
698
+ export function buildRequestFromItems(config: ResolvedProtectionConfig, items: HttpFileItem[]): Record<string, unknown>;
699
+ export function buildProtectionItems(config: ResolvedProtectionConfig, files: FileMapping[]): ProtectionItems;
700
+ export function buildProtectionItemsFromInputItems(config: ResolvedProtectionConfig, inputItems: HttpFileItem[]): ProtectionItems;
701
+ export function describeProtectionTransforms(protection: ProtectionItems): ProtectionProcessingSummary;
702
+ export function addProtectionSummary<T extends Record<string, unknown>>(summary: T, protection: ProtectionItems): T & { processing: ProtectionProcessingSummary };
703
+ export function buildCodeProtectionPlan(config: ResolvedProtectionConfig, fileName: string, code: string): { items: HttpFileItem[]; transform: unknown };
704
+ export function buildCompetitorGapReport(config?: Record<string, unknown>, args?: Record<string, unknown>): CompetitorGapReport;
705
+ export function buildCompetitorGapPlan(capabilities: CompetitorCapability[], limitations: CompetitorLimitation[]): string[];
706
+ export function buildHtmlProtectionPlan(config: ResolvedProtectionConfig, fileName: string, html: string): { items: HttpFileItem[]; transform: unknown };
707
+ export function buildProtectionManifest(config: ResolvedProtectionConfig, files: FileMapping[], assets: FileMapping[], result: HttpResult, transforms?: Map<string, unknown>): ProtectionManifest;
708
+ export function buildItemsManifest(config: ResolvedProtectionConfig, inputItems: Array<HttpFileItem & { SourcePath?: string; OutputPath?: string }>, result: HttpResult, outputPathForItem?: (fileName: string) => string, transforms?: Map<string, unknown>): ProtectionManifest;
709
+ export function buildMigrationMapSummary(mappings: MigrationMapEntry[], review: MigrationReviewOption[]): MigrationMapSummary;
710
+ export function buildMigrationNextCommands(args?: { output?: string }): MigrationNextCommand[];
711
+ export function buildMigrationReportSummary(sourceConfig: Record<string, unknown>, mapped: MigrationMappedOption[], review: MigrationReviewOption[], unmapped: string[]): MigrationReportSummary;
712
+ export function buildReleasePlan(config: ResolvedProtectionConfig): ReleasePlanReport;
713
+ export function buildStdinManifest(config: ResolvedProtectionConfig, fileName: string, sourceCode: string, outputCode: string, outputPath: string, processing?: ProtectionProcessingSummary): ProtectionManifest;
714
+ export function assertSizeBudgets(manifest: ProtectionManifest, budgets?: { maxOutputBytes?: number; maxGrowthRatio?: number }): SizeBudgetFailure[];
715
+ export function checkSizeBudgets(manifest: ProtectionManifest, budgets?: { maxOutputBytes?: number; maxGrowthRatio?: number }): SizeBudgetFailure[];
716
+ export function collectAssets(inputPath: string, outputPath: string, protectedFiles: FileMapping[], assetExcludePatterns: string[]): FileMapping[];
717
+ export function collectFiles(inputPath: string, outputPath: string, extensions: string[], excludePatterns: string[], includePatterns?: string[], markupExtensions?: string[]): FileMapping[];
718
+ export function copyAssets(assets: FileMapping[]): void;
719
+ export function createExampleConfig(initOptions?: string | ExampleConfigInitOptions): ProtectionOptions;
720
+ export function getRedactedConfig(config: ResolvedProtectionConfig): RedactedProtectionConfig;
721
+ export function globLikeMatch(value: string, pattern: string): boolean;
722
+ export function hasConditionalMarkers(code: string): boolean;
723
+ export function validateConditionalMarkers(fileName: string, code: string): void;
724
+ export function findMarkedHtmlScripts(html: string): Array<{ contentStart: number; contentEnd: number; code: string }>;
725
+ export function validateMarkedHtmlScripts(fileName: string, html: string): void;
726
+ export function hasMarkedHtmlScriptAttributes(html: string): boolean;
727
+ export function hasHtmlProtectionMarkers(filePath: string): boolean;
728
+ export function formatSourceLocation(source: string, index: number): string;
729
+ export function splitConditionalCode(code: string): Array<{ enabled: boolean; code: string }>;
730
+ export function composeProtectionOutput(transform: unknown, byName: Map<string, HttpFileItem>): string | null;
731
+ export function composeProtectionItemOutput(fileName: string, result: HttpResult, transforms?: Map<string, unknown>, config?: ResolvedProtectionConfig | ProtectionOptions | null): string;
732
+ export function stripSourceMapComments(code: string): string;
733
+ export function finalizeProtectedCode(code: string, config?: ResolvedProtectionConfig | ProtectionOptions | null): string;
734
+ export function isExcluded(relativePath: string, patterns: string[]): boolean;
735
+ export function isIncluded(relativePath: string, patterns: string[]): boolean;
736
+ export function listJavascriptObfuscatorMigrationMap(): MigrationMap;
737
+ export function listJsConfuserMigrationMap(): MigrationMap;
738
+ export function explainCompatibilityOption(option: string): CompatibilityExplanation;
739
+ export function explainJsConfuserCompatibilityOption(option: string): CompatibilityExplanation;
740
+ export function listOptions(): OptionReference[];
741
+ export function listPresets(): PresetReference[];
742
+ export function mergeConfig(config: ProtectionOptions & { __configDir?: string }, args?: Partial<ProtectionOptions>): ResolvedProtectionConfig;
743
+ export function migrateJsConfuserConfig(sourcePath: string, args?: Partial<ProtectionOptions>): MigrationReport;
744
+ export function migrateJavascriptObfuscatorConfig(sourcePath: string, args?: Partial<ProtectionOptions>): MigrationReport;
745
+ export function normalizeDomainLockList(value?: string | string[]): string[];
746
+ export function normalizeExtensions(extensions: string[]): string[];
747
+ export function parseArgs(argv: string[]): ParsedCliArgs;
748
+ export function parseOptionOverrides(values: string[]): Record<string, string | number | boolean | null>;
749
+ export function parseOptionValue(value: string): string | number | boolean | null;
750
+ export function parsePositiveNumber(value: string, option: string): number;
751
+ export function presetFromJavascriptObfuscatorPreset(value: string): PresetName;
752
+ export function translateJavascriptObfuscatorConfigOptions(source?: ProtectionOptions): ProtectionOptions;
753
+ export function postJson(endpoint: string, payload: unknown): Promise<HttpResult>;
754
+ export function readConfig(configPath?: string, context?: { mode?: string | null }): ProtectionOptions & { __configDir?: string };
755
+ export function readEnv(names: string[]): string;
756
+ export function readManifest(manifestPath: string): { manifestPath: string; manifest: ProtectionManifest };
757
+ export function readStdin(stream?: unknown): Promise<string>;
758
+ export function resolveEnv(value: string): string;
759
+ export function runDoctor(config: ResolvedProtectionConfig, args?: { checkApi?: boolean }): Promise<DoctorReport>;
760
+ export function runReleaseCheck(config: ProtectionOptions & { __configDir?: string }, args?: Partial<ProtectionOptions> & { checkApi?: boolean; strict?: boolean }): Promise<ReleaseCheckReport>;
761
+ export function validateProtectionConfig(config: ProtectionOptions & { __configDir?: string }, args?: Partial<ProtectionOptions> & { strict?: boolean }): ValidationReport;
762
+ export function verifyManifestOutputs(manifestPath: string, options?: { verifyRoot?: string }): ManifestVerificationReport;
763
+ export function verifyManifestOutputs(manifestInput: { manifestPath: string; manifest: ProtectionManifest }, options?: { verifyRoot?: string }): ManifestVerificationReport;
764
+ export function sha256(value: string | Buffer | Uint8Array): string;
765
+ export function writeJsConfuserCompatibilityExplanation(option: string, json?: boolean): void;
766
+ export function writeJsConfuserMigrationMap(json?: boolean): void;
767
+ export function writeCompatibilityExplanation(option: string, json?: boolean): void;
768
+ export function writeCompetitorGapReport(report: CompetitorGapReport, json?: boolean): void;
769
+ export function writeLocalOnlyGuidance(json?: boolean): void;
770
+ export function writeManifestVerificationReport(report: ManifestVerificationReport, json?: boolean): void;
771
+ export function writeMigrationMap(json?: boolean): void;
772
+ export function writeMigrationReport(report: MigrationReport, args?: { json?: boolean; output?: string }): void;
773
+ export function writeReleaseCheckReport(report: ReleaseCheckReport, json?: boolean): void;
774
+ export function writeResolvedConfig(config: ResolvedProtectionConfig, json?: boolean): void;
775
+ export function writeValidationReport(report: ValidationReport, json?: boolean): void;
776
+ export function writeVersion(json?: boolean): void;
777
+ export function writeManifest(manifestPath: string, manifest: ProtectionManifest): void;
778
+ export function writeResults(files: FileMapping[], result: HttpResult, transforms?: Map<string, unknown>): void;
779
+ export function main(argv?: string[]): Promise<void>;
780
+
781
+ // ----- JSO AI client ----------------------------------------------------
782
+ // Wraps the four /v1/ai/* endpoints. Reads JSO_API_KEY / JSO_API_PASSWORD
783
+ // from the environment if not passed explicitly.
784
+
785
+ export interface AiCredentials {
786
+ apiKey?: string;
787
+ apiPassword?: string;
788
+ endpoint?: string; // default https://www.javascriptobfuscator.com
789
+ timeoutMs?: number; // default 30000
790
+ }
791
+
792
+ export interface AiEnvelope {
793
+ ok: boolean;
794
+ previewMode?: boolean;
795
+ provider?: string;
796
+ tokensIn?: number;
797
+ tokensOut?: number;
798
+ error?: string;
799
+ message?: string;
800
+ }
801
+
802
+ export interface AiPresetSuggestResult extends AiEnvelope {
803
+ suggestion?: {
804
+ previewMode: boolean;
805
+ source: string;
806
+ config: Record<string, unknown>;
807
+ signals: string[];
808
+ };
809
+ }
810
+
811
+ export interface AiCompatCheckFinding {
812
+ category: string;
813
+ severity: "error" | "warning" | "info";
814
+ line: number;
815
+ column: number;
816
+ snippet?: string;
817
+ message: string;
818
+ suggestedFix: string;
819
+ }
820
+
821
+ export interface AiCompatCheckResult extends AiEnvelope {
822
+ report?: {
823
+ previewMode: boolean;
824
+ source: string;
825
+ summary: { errors: number; warnings: number; infos: number };
826
+ findings: AiCompatCheckFinding[];
827
+ };
828
+ }
829
+
830
+ export interface AiExplainErrorResult extends AiEnvelope {
831
+ explanation?: {
832
+ previewMode: boolean;
833
+ source: string;
834
+ cause: string;
835
+ transform: string;
836
+ confidence: "high" | "medium" | "low";
837
+ explanation: string;
838
+ fix: string;
839
+ docsUrl: string;
840
+ };
841
+ }
842
+
843
+ export interface AiProviderKeyHealth {
844
+ hasKey: boolean;
845
+ provider: "" | "openai" | "claude";
846
+ status: "missing" | "disabled" | "test-needed" | "failed" | "test-due" | "rotation-review-due" | "ready";
847
+ label: string;
848
+ testDue: boolean;
849
+ rotationDue: boolean;
850
+ lastTestStatus: string;
851
+ lastTestUtc: string | null;
852
+ nextTestDueUtc: string | null;
853
+ rotationDueUtc: string | null;
854
+ recommendedAction: string;
855
+ }
856
+
857
+ export interface AiUsageResult extends AiEnvelope {
858
+ tier?: "FreeTrial" | "Basic" | "Corporate" | "Enterprise";
859
+ billingMonth?: string;
860
+ actionsUsed?: number;
861
+ actionsCap?: number;
862
+ actionsRemaining?: number;
863
+ tokensUsed?: number;
864
+ tokensCap?: number;
865
+ tokensRemaining?: number;
866
+ approxCostCents?: number;
867
+ costCapCents?: number;
868
+ costRemainingCents?: number;
869
+ providerKey?: AiProviderKeyHealth;
870
+ quotaRejections?: number;
871
+ asOfUtc?: string;
872
+ }
873
+
874
+ export const ai: {
875
+ presetSuggest(opts: AiCredentials & { description: string }): Promise<AiPresetSuggestResult>;
876
+ compatCheck (opts: AiCredentials & { source: string; framework?: string }): Promise<AiCompatCheckResult>;
877
+ explainError(opts: AiCredentials & { error: string; config?: string }): Promise<AiExplainErrorResult>;
878
+ usage (opts?: AiCredentials): Promise<AiUsageResult>;
879
+ };