@tsvm/core 0.1.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.
- package/dist/index.d.ts +81 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +469 -0
- package/dist/index.js.map +1 -0
- package/dist/universal-bundler.d.ts +3 -0
- package/dist/universal-bundler.d.ts.map +1 -0
- package/dist/universal-bundler.js +185 -0
- package/dist/universal-bundler.js.map +1 -0
- package/package.json +42 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @tsvm/core — Pipeline orchestrator for ts-vm-obfuscator.
|
|
3
|
+
*
|
|
4
|
+
* This module wires together the entire obfuscation pipeline:
|
|
5
|
+
* 1. Semantic analysis (read TS project, extract type facts, module graph)
|
|
6
|
+
* 2. IR lowering (convert semantic graph to intermediate representation)
|
|
7
|
+
* 3. Transform execution (apply obfuscation passes in priority order)
|
|
8
|
+
* 4. Bytecode compilation (compile IR to bytecode module)
|
|
9
|
+
* 5. VM build (generate polymorphic JavaScript VM runtime)
|
|
10
|
+
* 6. Optional: benchmark, React-safe checks, Electron hardening
|
|
11
|
+
*
|
|
12
|
+
* Architecture decision: selected-region virtualization (not whole-program)
|
|
13
|
+
* - Whole-program VM would impose unacceptable runtime overhead for React/web apps
|
|
14
|
+
* - Selected-region lets developers annotate or configure which functions to virtualize
|
|
15
|
+
* - Non-virtualized code still gets semantic transforms (symbol indirection, string pool, etc.)
|
|
16
|
+
* - This keeps bundle sizes reasonable and preserves tree-shaking
|
|
17
|
+
*
|
|
18
|
+
* VM architecture: register-based hybrid
|
|
19
|
+
* - Register-based is more efficient than stack-based for JS target
|
|
20
|
+
* - Hybrid: uses registers for locals + implicit operand stack for complex expressions
|
|
21
|
+
* - Polymorphic: opcode mapping, encoding, handler layout all randomized per build
|
|
22
|
+
*/
|
|
23
|
+
import type { ObfuscationProfile, ProjectSemanticGraph, IRModule, BytecodeModule, VMRuntimeBundle, BuildManifest, PipelineEventHandler, Diagnostic, BenchmarkSuiteResult, ElectronAuditReport, ReactComponentInfo, FunctionCapabilityReport } from '@tsvm/shared';
|
|
24
|
+
export { SeededRandom } from '@tsvm/shared';
|
|
25
|
+
export interface PipelineOptions {
|
|
26
|
+
/** Absolute path to tsconfig.json. */
|
|
27
|
+
readonly tsconfigPath: string;
|
|
28
|
+
/** Obfuscation profile to apply. */
|
|
29
|
+
readonly profile: ObfuscationProfile;
|
|
30
|
+
/** Output directory for generated files. */
|
|
31
|
+
readonly outDir: string;
|
|
32
|
+
/** Event handler for pipeline progress. */
|
|
33
|
+
readonly onEvent?: PipelineEventHandler;
|
|
34
|
+
/** If true, run benchmarks after obfuscation. */
|
|
35
|
+
readonly benchmark?: boolean;
|
|
36
|
+
/** If true, generate visualization data alongside output. */
|
|
37
|
+
readonly emitVisualizationData?: boolean;
|
|
38
|
+
/** Override entry points (defaults to tsconfig "files" or auto-detect). */
|
|
39
|
+
readonly entryPoints?: readonly string[];
|
|
40
|
+
}
|
|
41
|
+
export interface PipelineResult {
|
|
42
|
+
readonly success: boolean;
|
|
43
|
+
readonly manifest: BuildManifest;
|
|
44
|
+
readonly diagnostics: readonly Diagnostic[];
|
|
45
|
+
readonly semanticGraph?: ProjectSemanticGraph;
|
|
46
|
+
readonly irModules?: readonly IRModule[];
|
|
47
|
+
readonly bytecodeModules?: readonly BytecodeModule[];
|
|
48
|
+
readonly vmBundles?: readonly VMRuntimeBundle[];
|
|
49
|
+
readonly benchmarkResults?: BenchmarkSuiteResult;
|
|
50
|
+
readonly electronAudit?: ElectronAuditReport;
|
|
51
|
+
readonly reactComponents?: readonly ReactComponentInfo[];
|
|
52
|
+
readonly functionReports?: readonly FunctionCapabilityReport[];
|
|
53
|
+
}
|
|
54
|
+
export declare function createDefaultProfile(target: ObfuscationProfile['target']): ObfuscationProfile;
|
|
55
|
+
export declare class ObfuscationPipeline {
|
|
56
|
+
private readonly options;
|
|
57
|
+
private readonly diagnostics;
|
|
58
|
+
constructor(options: PipelineOptions);
|
|
59
|
+
private emit;
|
|
60
|
+
private emitError;
|
|
61
|
+
/**
|
|
62
|
+
* Execute the full obfuscation pipeline.
|
|
63
|
+
*
|
|
64
|
+
* The pipeline is intentionally sequential — each stage depends on the
|
|
65
|
+
* output of the previous stage. Parallelism happens *within* stages
|
|
66
|
+
* (e.g., transforms can be parallelized across modules).
|
|
67
|
+
*/
|
|
68
|
+
execute(): Promise<PipelineResult>;
|
|
69
|
+
private failResult;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* One-shot obfuscation of a TypeScript project.
|
|
73
|
+
*
|
|
74
|
+
* @param tsconfigPath - Absolute path to tsconfig.json
|
|
75
|
+
* @param outDir - Output directory
|
|
76
|
+
* @param profile - Obfuscation profile (use createDefaultProfile for defaults)
|
|
77
|
+
* @param onEvent - Optional progress callback
|
|
78
|
+
*/
|
|
79
|
+
export declare function obfuscate(tsconfigPath: string, outDir: string, profile?: ObfuscationProfile, onEvent?: PipelineEventHandler): Promise<PipelineResult>;
|
|
80
|
+
export type { ObfuscationProfile, ProjectSemanticGraph, IRModule, BytecodeModule, VMRuntimeBundle, BuildManifest, PipelineEvent, PipelineEventHandler, TransformPass, TransformContext, BenchmarkSuiteResult, ElectronAuditReport, ReactComponentInfo, Diagnostic, } from '@tsvm/shared';
|
|
81
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,KAAK,EACV,kBAAkB,EAClB,oBAAoB,EACpB,QAAQ,EACR,cAAc,EACd,eAAe,EACf,aAAa,EAEb,oBAAoB,EAEpB,UAAU,EAEV,oBAAoB,EAIpB,mBAAmB,EACnB,kBAAkB,EAClB,wBAAwB,EACzB,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,YAAY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,GAAG,kBAAkB,CAkI7F;AAyBD,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAkB;IAC1C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAoB;gBAEpC,OAAO,EAAE,eAAe;IAIpC,OAAO,CAAC,IAAI;IAWZ,OAAO,CAAC,SAAS;IAkBjB;;;;;;OAMG;IACG,OAAO,IAAI,OAAO,CAAC,cAAc,CAAC;IA4OxC,OAAO,CAAC,UAAU;CAsBnB;AAMD;;;;;;;GAOG;AACH,wBAAsB,SAAS,CAC7B,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,kBAAkB,EAC5B,OAAO,CAAC,EAAE,oBAAoB,GAC7B,OAAO,CAAC,cAAc,CAAC,CASzB;AAED,YAAY,EACV,kBAAkB,EAClB,oBAAoB,EACpB,QAAQ,EACR,cAAc,EACd,eAAe,EACf,aAAa,EACb,aAAa,EACb,oBAAoB,EACpB,aAAa,EACb,gBAAgB,EAChB,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EAClB,UAAU,GACX,MAAM,cAAc,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,469 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @tsvm/core — Pipeline orchestrator for ts-vm-obfuscator.
|
|
3
|
+
*
|
|
4
|
+
* This module wires together the entire obfuscation pipeline:
|
|
5
|
+
* 1. Semantic analysis (read TS project, extract type facts, module graph)
|
|
6
|
+
* 2. IR lowering (convert semantic graph to intermediate representation)
|
|
7
|
+
* 3. Transform execution (apply obfuscation passes in priority order)
|
|
8
|
+
* 4. Bytecode compilation (compile IR to bytecode module)
|
|
9
|
+
* 5. VM build (generate polymorphic JavaScript VM runtime)
|
|
10
|
+
* 6. Optional: benchmark, React-safe checks, Electron hardening
|
|
11
|
+
*
|
|
12
|
+
* Architecture decision: selected-region virtualization (not whole-program)
|
|
13
|
+
* - Whole-program VM would impose unacceptable runtime overhead for React/web apps
|
|
14
|
+
* - Selected-region lets developers annotate or configure which functions to virtualize
|
|
15
|
+
* - Non-virtualized code still gets semantic transforms (symbol indirection, string pool, etc.)
|
|
16
|
+
* - This keeps bundle sizes reasonable and preserves tree-shaking
|
|
17
|
+
*
|
|
18
|
+
* VM architecture: register-based hybrid
|
|
19
|
+
* - Register-based is more efficient than stack-based for JS target
|
|
20
|
+
* - Hybrid: uses registers for locals + implicit operand stack for complex expressions
|
|
21
|
+
* - Polymorphic: opcode mapping, encoding, handler layout all randomized per build
|
|
22
|
+
*/
|
|
23
|
+
import { DiagnosticSeverity, ImmediateEncodingScheme, ConstantEncodingScheme } from '@tsvm/shared';
|
|
24
|
+
import { buildUniversalBundle } from './universal-bundler.js';
|
|
25
|
+
export { SeededRandom } from '@tsvm/shared';
|
|
26
|
+
function getUniversalOutputExtension(profile) {
|
|
27
|
+
return profile.target === 'universal' ? '.mjs' : '.js';
|
|
28
|
+
}
|
|
29
|
+
// ─────────────────────────────────────────────────────────────
|
|
30
|
+
// Default Profiles
|
|
31
|
+
// ─────────────────────────────────────────────────────────────
|
|
32
|
+
export function createDefaultProfile(target) {
|
|
33
|
+
const baseSeed = Date.now();
|
|
34
|
+
const baseTransforms = [
|
|
35
|
+
{ name: 'InstructionSubstitutionPass', enabled: true, options: {} },
|
|
36
|
+
{ name: 'SymbolIndirectionPass', enabled: true, options: {} },
|
|
37
|
+
{ name: 'StringPoolEncodingPass', enabled: true, options: {} },
|
|
38
|
+
{ name: 'FunctionVirtualizationPass', enabled: true, options: {} },
|
|
39
|
+
{ name: 'DeadCodeInjectionPass', enabled: true, options: {} },
|
|
40
|
+
{ name: 'ControlFlowFlatteningPass', enabled: true, options: {} },
|
|
41
|
+
{ name: 'PreserveTypeIllusionsPass', enabled: true, options: {} },
|
|
42
|
+
{ name: 'TypeLevelFakePathPass', enabled: true, options: {} },
|
|
43
|
+
{ name: 'DecoratorAwareLoweringPass', enabled: true, options: {} },
|
|
44
|
+
{ name: 'GenericConfusionPass', enabled: true, options: {} },
|
|
45
|
+
{ name: 'NamespaceVirtualizationPass', enabled: true, options: {} },
|
|
46
|
+
{ name: 'StripDebugPass', enabled: true, options: {} },
|
|
47
|
+
{ name: 'RegisterCompactingPass', enabled: true, options: {} },
|
|
48
|
+
{ name: 'IRValidationPass', enabled: true, options: {} },
|
|
49
|
+
];
|
|
50
|
+
switch (target) {
|
|
51
|
+
case 'react':
|
|
52
|
+
return {
|
|
53
|
+
name: 'react-safe',
|
|
54
|
+
target: 'react',
|
|
55
|
+
transforms: baseTransforms.map((t) => t.name === 'FunctionVirtualizationPass' ? { ...t, options: { excludeComponents: true, excludeHooks: true } } : t),
|
|
56
|
+
virtualization: {
|
|
57
|
+
mode: 'annotated',
|
|
58
|
+
annotations: ['@virtualize'],
|
|
59
|
+
maxFunctionSize: 200,
|
|
60
|
+
excludePatterns: ['**/components/**', '**/hooks/**'],
|
|
61
|
+
},
|
|
62
|
+
vm: createDefaultVMConfig(baseSeed),
|
|
63
|
+
preservePatterns: ['**/*.d.ts', '**/*.test.*'],
|
|
64
|
+
preserveExports: true,
|
|
65
|
+
preserveDecorators: false,
|
|
66
|
+
reactSafe: true,
|
|
67
|
+
electronHarden: false,
|
|
68
|
+
deterministic: false,
|
|
69
|
+
seed: baseSeed,
|
|
70
|
+
};
|
|
71
|
+
case 'electron':
|
|
72
|
+
return {
|
|
73
|
+
name: 'electron-hardened',
|
|
74
|
+
target: 'electron',
|
|
75
|
+
transforms: baseTransforms,
|
|
76
|
+
virtualization: {
|
|
77
|
+
mode: 'selected',
|
|
78
|
+
annotations: ['@virtualize'],
|
|
79
|
+
maxFunctionSize: 500,
|
|
80
|
+
excludePatterns: ['**/preload/**'],
|
|
81
|
+
},
|
|
82
|
+
vm: createDefaultVMConfig(baseSeed),
|
|
83
|
+
preservePatterns: ['**/*.d.ts', '**/*.test.*'],
|
|
84
|
+
preserveExports: false,
|
|
85
|
+
preserveDecorators: true,
|
|
86
|
+
reactSafe: false,
|
|
87
|
+
electronHarden: true,
|
|
88
|
+
deterministic: false,
|
|
89
|
+
seed: baseSeed,
|
|
90
|
+
};
|
|
91
|
+
case 'library':
|
|
92
|
+
return {
|
|
93
|
+
name: 'library-safe',
|
|
94
|
+
target: 'library',
|
|
95
|
+
transforms: baseTransforms.map((t) => (t.name === 'FunctionVirtualizationPass' ? { ...t, enabled: false } : t)),
|
|
96
|
+
virtualization: {
|
|
97
|
+
mode: 'none',
|
|
98
|
+
annotations: [],
|
|
99
|
+
maxFunctionSize: 0,
|
|
100
|
+
excludePatterns: [],
|
|
101
|
+
},
|
|
102
|
+
vm: createDefaultVMConfig(baseSeed),
|
|
103
|
+
preservePatterns: ['**/*.d.ts', '**/*.test.*'],
|
|
104
|
+
preserveExports: true,
|
|
105
|
+
preserveDecorators: true,
|
|
106
|
+
reactSafe: false,
|
|
107
|
+
electronHarden: false,
|
|
108
|
+
deterministic: false,
|
|
109
|
+
seed: baseSeed,
|
|
110
|
+
};
|
|
111
|
+
case 'universal':
|
|
112
|
+
return {
|
|
113
|
+
name: 'universal-compat',
|
|
114
|
+
target: 'universal',
|
|
115
|
+
transforms: baseTransforms,
|
|
116
|
+
virtualization: {
|
|
117
|
+
mode: 'whole_program',
|
|
118
|
+
annotations: [],
|
|
119
|
+
maxFunctionSize: 2_000,
|
|
120
|
+
excludePatterns: [],
|
|
121
|
+
compatibilityFallback: true,
|
|
122
|
+
},
|
|
123
|
+
vm: createDefaultVMConfig(baseSeed),
|
|
124
|
+
preservePatterns: ['**/*.d.ts', '**/*.test.*'],
|
|
125
|
+
preserveExports: true,
|
|
126
|
+
preserveDecorators: true,
|
|
127
|
+
reactSafe: false,
|
|
128
|
+
electronHarden: false,
|
|
129
|
+
deterministic: false,
|
|
130
|
+
seed: baseSeed,
|
|
131
|
+
};
|
|
132
|
+
case 'generic':
|
|
133
|
+
default:
|
|
134
|
+
return {
|
|
135
|
+
name: 'generic',
|
|
136
|
+
target: 'generic',
|
|
137
|
+
transforms: baseTransforms,
|
|
138
|
+
virtualization: {
|
|
139
|
+
mode: 'selected',
|
|
140
|
+
annotations: ['@virtualize'],
|
|
141
|
+
maxFunctionSize: 500,
|
|
142
|
+
excludePatterns: [],
|
|
143
|
+
},
|
|
144
|
+
vm: createDefaultVMConfig(baseSeed),
|
|
145
|
+
preservePatterns: ['**/*.d.ts', '**/*.test.*'],
|
|
146
|
+
preserveExports: false,
|
|
147
|
+
preserveDecorators: false,
|
|
148
|
+
reactSafe: false,
|
|
149
|
+
electronHarden: false,
|
|
150
|
+
deterministic: false,
|
|
151
|
+
seed: baseSeed,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
function createDefaultVMConfig(seed) {
|
|
156
|
+
return {
|
|
157
|
+
opcodeRemapping: true,
|
|
158
|
+
immediateEncoding: ImmediateEncodingScheme.XorMasked,
|
|
159
|
+
superInstructions: true,
|
|
160
|
+
handlerLayoutRandom: true,
|
|
161
|
+
constantPoolEncoding: ConstantEncodingScheme.XorRotate,
|
|
162
|
+
traceMode: false,
|
|
163
|
+
deterministicReplay: false,
|
|
164
|
+
seed,
|
|
165
|
+
runtimeHardening: 'stealth',
|
|
166
|
+
stealthDispatch: true,
|
|
167
|
+
tamperDetection: true,
|
|
168
|
+
antiDebug: false,
|
|
169
|
+
junkInsertion: true,
|
|
170
|
+
rollingKeys: true,
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
// ─────────────────────────────────────────────────────────────
|
|
174
|
+
// Pipeline Orchestrator
|
|
175
|
+
// ─────────────────────────────────────────────────────────────
|
|
176
|
+
export class ObfuscationPipeline {
|
|
177
|
+
options;
|
|
178
|
+
diagnostics = [];
|
|
179
|
+
constructor(options) {
|
|
180
|
+
this.options = options;
|
|
181
|
+
}
|
|
182
|
+
emit(stage, message, durationMs) {
|
|
183
|
+
if (this.options.onEvent) {
|
|
184
|
+
this.options.onEvent({
|
|
185
|
+
stage,
|
|
186
|
+
message,
|
|
187
|
+
timestamp: Date.now(),
|
|
188
|
+
durationMs,
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
emitError(stage, message, error) {
|
|
193
|
+
let errorMessage = '';
|
|
194
|
+
if (error instanceof Error) {
|
|
195
|
+
errorMessage = `${error.message}\n${error.stack}`;
|
|
196
|
+
}
|
|
197
|
+
else if (error && typeof error === 'object') {
|
|
198
|
+
const obj = error;
|
|
199
|
+
errorMessage = String(obj?.['stack'] ?? obj?.['message'] ?? JSON.stringify(obj) ?? String(error));
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
errorMessage = String(error);
|
|
203
|
+
}
|
|
204
|
+
this.diagnostics.push({
|
|
205
|
+
severity: 0, // Error
|
|
206
|
+
code: `PIPELINE_${stage.toUpperCase()}`,
|
|
207
|
+
message: `${message}: ${errorMessage}`,
|
|
208
|
+
});
|
|
209
|
+
this.emit(stage, `ERROR: ${message}: ${errorMessage}`);
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Execute the full obfuscation pipeline.
|
|
213
|
+
*
|
|
214
|
+
* The pipeline is intentionally sequential — each stage depends on the
|
|
215
|
+
* output of the previous stage. Parallelism happens *within* stages
|
|
216
|
+
* (e.g., transforms can be parallelized across modules).
|
|
217
|
+
*/
|
|
218
|
+
async execute() {
|
|
219
|
+
const startTime = Date.now();
|
|
220
|
+
const buildId = `build_${this.options.profile.seed}_${startTime}`;
|
|
221
|
+
// ── Stage 1: Semantic Analysis ──
|
|
222
|
+
this.emit('semantic_analysis', 'Starting semantic analysis...');
|
|
223
|
+
let semanticGraph;
|
|
224
|
+
try {
|
|
225
|
+
const { analyzeProject } = await import('@tsvm/ts-semantics');
|
|
226
|
+
const t0 = Date.now();
|
|
227
|
+
semanticGraph = analyzeProject(this.options.tsconfigPath, this.options.entryPoints);
|
|
228
|
+
this.emit('semantic_analysis', 'Semantic analysis complete', Date.now() - t0);
|
|
229
|
+
}
|
|
230
|
+
catch (error) {
|
|
231
|
+
this.emitError('semantic_analysis', 'Semantic analysis failed', error);
|
|
232
|
+
return this.failResult(buildId, startTime);
|
|
233
|
+
}
|
|
234
|
+
// ── Stage 2: IR Lowering ──
|
|
235
|
+
this.emit('ir_lowering', 'Lowering to IR...');
|
|
236
|
+
let irModules;
|
|
237
|
+
let functionReports;
|
|
238
|
+
try {
|
|
239
|
+
const { analyzeFunctionCapabilities, analyzeTopLevelFunctionCapabilities, lowerToIR } = await import('@tsvm/ir');
|
|
240
|
+
const t0 = Date.now();
|
|
241
|
+
irModules = [];
|
|
242
|
+
if (this.options.profile.target === 'universal') {
|
|
243
|
+
functionReports = [];
|
|
244
|
+
}
|
|
245
|
+
for (const [filePath, moduleInfo] of semanticGraph.modules) {
|
|
246
|
+
const universalTopLevelReports = this.options.profile.target === 'universal' ? analyzeTopLevelFunctionCapabilities(filePath) : [];
|
|
247
|
+
if (functionReports) {
|
|
248
|
+
functionReports.push(...analyzeFunctionCapabilities(filePath));
|
|
249
|
+
}
|
|
250
|
+
const forcedVmSafeFunctionNames = new Set(universalTopLevelReports.filter((report) => report.tier === 'vm_safe').map((report) => report.functionName));
|
|
251
|
+
const skippedJsLoweredFunctionNames = new Set(universalTopLevelReports.filter((report) => report.tier === 'js_lowered').map((report) => report.functionName));
|
|
252
|
+
const unsupportedTopLevelReports = universalTopLevelReports.filter((report) => report.tier === 'unsupported');
|
|
253
|
+
for (const report of unsupportedTopLevelReports) {
|
|
254
|
+
this.diagnostics.push({
|
|
255
|
+
severity: DiagnosticSeverity.Error,
|
|
256
|
+
code: 'UNIVERSAL_UNSUPPORTED_FUNCTION',
|
|
257
|
+
message: `Universal profile cannot lower function "${report.functionName}" in ${report.filePath}:${report.startLine}:${report.startColumn}: ${report.reasons.join(', ')}`,
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
const irModule = lowerToIR(moduleInfo, semanticGraph, filePath, {
|
|
261
|
+
forceVirtualizeAll: this.options.profile.virtualization.mode === 'whole_program',
|
|
262
|
+
forceVirtualizeFunctionNames: forcedVmSafeFunctionNames,
|
|
263
|
+
skipTopLevelFunctionNames: skippedJsLoweredFunctionNames,
|
|
264
|
+
compatibilityFallback: this.options.profile.target === 'universal' ? false : this.options.profile.virtualization.compatibilityFallback,
|
|
265
|
+
diagnostics: this.diagnostics,
|
|
266
|
+
});
|
|
267
|
+
irModules.push(irModule);
|
|
268
|
+
}
|
|
269
|
+
this.emit('ir_lowering', `Lowered ${irModules.length} modules to IR`, Date.now() - t0);
|
|
270
|
+
}
|
|
271
|
+
catch (error) {
|
|
272
|
+
this.emitError('ir_lowering', 'IR lowering failed', error);
|
|
273
|
+
return this.failResult(buildId, startTime, { semanticGraph });
|
|
274
|
+
}
|
|
275
|
+
// ── Stage 3: React-Safe Analysis (if enabled) ──
|
|
276
|
+
let reactComponents;
|
|
277
|
+
if (this.options.profile.reactSafe) {
|
|
278
|
+
this.emit('transform_execution', 'Running React safety analysis...');
|
|
279
|
+
try {
|
|
280
|
+
const { collectReactComponentInfo, createReactSafetyDiagnostics, enforceReactProfile } = await import('@tsvm/react-safe');
|
|
281
|
+
reactComponents = [];
|
|
282
|
+
for (const irModule of irModules) {
|
|
283
|
+
reactComponents.push(...collectReactComponentInfo(irModule.functions, irModule.sourceFile));
|
|
284
|
+
this.diagnostics.push(...createReactSafetyDiagnostics(irModule.functions, irModule.sourceFile));
|
|
285
|
+
enforceReactProfile(irModule.functions, irModule.constantPool);
|
|
286
|
+
}
|
|
287
|
+
this.emit('transform_execution', `Applied React safety profile to ${reactComponents.length} React-sensitive functions`);
|
|
288
|
+
}
|
|
289
|
+
catch (error) {
|
|
290
|
+
this.emitError('transform_execution', 'React safety analysis failed', error);
|
|
291
|
+
return this.failResult(buildId, startTime, { semanticGraph, irModules });
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
// ── Stage 4: Transform Execution ──
|
|
295
|
+
this.emit('transform_execution', 'Executing transform passes...');
|
|
296
|
+
try {
|
|
297
|
+
const { createTransformRegistry } = await import('@tsvm/transforms');
|
|
298
|
+
const registry = createTransformRegistry(this.options.profile);
|
|
299
|
+
const { SeededRandom: SRandom } = await import('@tsvm/shared');
|
|
300
|
+
const rng = new SRandom(this.options.profile.seed);
|
|
301
|
+
const t0 = Date.now();
|
|
302
|
+
for (let i = 0; i < irModules.length; i++) {
|
|
303
|
+
const ctx = {
|
|
304
|
+
module: irModules[i],
|
|
305
|
+
profile: this.options.profile,
|
|
306
|
+
semanticGraph,
|
|
307
|
+
symbolAliases: semanticGraph.aliases,
|
|
308
|
+
diagnostics: [],
|
|
309
|
+
rng,
|
|
310
|
+
phase: 0,
|
|
311
|
+
};
|
|
312
|
+
for (const pass of registry.getOrderedPasses()) {
|
|
313
|
+
const result = pass.execute(ctx);
|
|
314
|
+
irModules[i] = result.module;
|
|
315
|
+
this.diagnostics.push(...result.diagnostics);
|
|
316
|
+
ctx.module = result.module;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
this.emit('transform_execution', 'Transforms complete', Date.now() - t0);
|
|
320
|
+
}
|
|
321
|
+
catch (error) {
|
|
322
|
+
this.emitError('transform_execution', 'Transform execution failed', error);
|
|
323
|
+
return this.failResult(buildId, startTime, { semanticGraph, irModules });
|
|
324
|
+
}
|
|
325
|
+
// ── Stage 5: Bytecode Compilation ──
|
|
326
|
+
this.emit('bytecode_compilation', 'Compiling to bytecode...');
|
|
327
|
+
let bytecodeModules;
|
|
328
|
+
const bytecodeSourceFiles = new Map();
|
|
329
|
+
try {
|
|
330
|
+
const { compileToBytecode } = await import('@tsvm/bytecode');
|
|
331
|
+
const t0 = Date.now();
|
|
332
|
+
bytecodeModules = [];
|
|
333
|
+
for (const irModule of irModules) {
|
|
334
|
+
const virtualizedFunctions = irModule.functions.filter((f) => f.isVirtualized);
|
|
335
|
+
if (virtualizedFunctions.length > 0) {
|
|
336
|
+
const bcModule = compileToBytecode(irModule, this.options.profile.vm);
|
|
337
|
+
bytecodeModules.push(bcModule);
|
|
338
|
+
bytecodeSourceFiles.set(bcModule.buildId, irModule.sourceFile);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
this.emit('bytecode_compilation', `Compiled ${bytecodeModules.length} bytecode modules`, Date.now() - t0);
|
|
342
|
+
}
|
|
343
|
+
catch (error) {
|
|
344
|
+
this.emitError('bytecode_compilation', 'Bytecode compilation failed', error);
|
|
345
|
+
return this.failResult(buildId, startTime, { semanticGraph, irModules });
|
|
346
|
+
}
|
|
347
|
+
// ── Stage 6: VM Build ──
|
|
348
|
+
const runtimeBackend = this.options.profile.vm.runtimeBackend ?? 'js';
|
|
349
|
+
this.emit('vm_build', `Building ${runtimeBackend} VM runtime...`);
|
|
350
|
+
let vmBundles;
|
|
351
|
+
try {
|
|
352
|
+
const t0 = Date.now();
|
|
353
|
+
vmBundles = [];
|
|
354
|
+
const buildRuntime = runtimeBackend === 'wasm_hybrid'
|
|
355
|
+
? (await import('@tsvm/wasm-runtime')).buildWasmHybridRuntime
|
|
356
|
+
: (await import('@tsvm/vm-runtime')).buildVMRuntime;
|
|
357
|
+
for (const bcModule of bytecodeModules) {
|
|
358
|
+
const bundle = buildRuntime(bcModule, this.options.profile.vm);
|
|
359
|
+
vmBundles.push(bundle);
|
|
360
|
+
}
|
|
361
|
+
this.emit('vm_build', `Built ${vmBundles.length} VM bundles`, Date.now() - t0);
|
|
362
|
+
}
|
|
363
|
+
catch (error) {
|
|
364
|
+
this.emitError('vm_build', 'VM build failed', error);
|
|
365
|
+
return this.failResult(buildId, startTime, { semanticGraph, irModules, bytecodeModules });
|
|
366
|
+
}
|
|
367
|
+
if (this.options.profile.target === 'universal') {
|
|
368
|
+
const vmBundleByFile = new Map();
|
|
369
|
+
for (const bundle of vmBundles) {
|
|
370
|
+
const matchedPath = bytecodeSourceFiles.get(bundle.buildId);
|
|
371
|
+
if (matchedPath) {
|
|
372
|
+
vmBundleByFile.set(matchedPath, bundle);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
const universalBundles = [];
|
|
376
|
+
for (const [filePath, moduleInfo] of semanticGraph.modules) {
|
|
377
|
+
const reportsForFile = functionReports?.filter((report) => report.filePath === filePath) ?? [];
|
|
378
|
+
if (moduleInfo.exports.length === 0 && reportsForFile.length === 0) {
|
|
379
|
+
continue;
|
|
380
|
+
}
|
|
381
|
+
universalBundles.push(buildUniversalBundle(`${buildId}_${moduleInfo.relativePath.replace(/[\\/]/g, '_').replace(/[^a-zA-Z0-9_.-]/g, '_')}`, moduleInfo, semanticGraph.compilerOptions, reportsForFile, vmBundleByFile.get(filePath)));
|
|
382
|
+
}
|
|
383
|
+
vmBundles = universalBundles;
|
|
384
|
+
this.emit('vm_build', `Built ${vmBundles.length} universal compatibility bundles`);
|
|
385
|
+
}
|
|
386
|
+
// ── Stage 7: Electron Hardening (if enabled) ──
|
|
387
|
+
let electronAudit;
|
|
388
|
+
if (this.options.profile.electronHarden) {
|
|
389
|
+
try {
|
|
390
|
+
const { applyElectronHardening } = await import('@tsvm/electron-hardening');
|
|
391
|
+
for (let i = 0; i < irModules.length; i++) {
|
|
392
|
+
irModules[i] = applyElectronHardening(irModules[i]);
|
|
393
|
+
}
|
|
394
|
+
this.emit('vm_build', 'Applied Electron hardening rules');
|
|
395
|
+
}
|
|
396
|
+
catch (error) {
|
|
397
|
+
this.emitError('vm_build', 'Electron hardening failed', error);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
// Benchmark was removed to avoid circular dependencies.
|
|
401
|
+
// It should be run externally.
|
|
402
|
+
let benchmarkResults;
|
|
403
|
+
// ── Build Manifest ──
|
|
404
|
+
const manifest = {
|
|
405
|
+
buildId,
|
|
406
|
+
timestamp: startTime,
|
|
407
|
+
profile: this.options.profile,
|
|
408
|
+
inputFiles: Array.from(semanticGraph.modules.keys()),
|
|
409
|
+
outputFiles: vmBundles.map((b) => `${this.options.outDir}/${b.buildId}${getUniversalOutputExtension(this.options.profile)}`),
|
|
410
|
+
seed: this.options.profile.seed,
|
|
411
|
+
diagnostics: this.diagnostics,
|
|
412
|
+
metrics: [],
|
|
413
|
+
functionReports,
|
|
414
|
+
};
|
|
415
|
+
return {
|
|
416
|
+
success: this.diagnostics.filter((d) => d.severity === 0).length === 0,
|
|
417
|
+
manifest,
|
|
418
|
+
diagnostics: this.diagnostics,
|
|
419
|
+
semanticGraph,
|
|
420
|
+
irModules,
|
|
421
|
+
bytecodeModules,
|
|
422
|
+
vmBundles,
|
|
423
|
+
benchmarkResults,
|
|
424
|
+
electronAudit,
|
|
425
|
+
reactComponents,
|
|
426
|
+
functionReports,
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
failResult(buildId, startTime, partial) {
|
|
430
|
+
return {
|
|
431
|
+
success: false,
|
|
432
|
+
manifest: {
|
|
433
|
+
buildId,
|
|
434
|
+
timestamp: startTime,
|
|
435
|
+
profile: this.options.profile,
|
|
436
|
+
inputFiles: [],
|
|
437
|
+
outputFiles: [],
|
|
438
|
+
seed: this.options.profile.seed,
|
|
439
|
+
diagnostics: this.diagnostics,
|
|
440
|
+
metrics: [],
|
|
441
|
+
functionReports: [],
|
|
442
|
+
},
|
|
443
|
+
diagnostics: this.diagnostics,
|
|
444
|
+
...partial,
|
|
445
|
+
};
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
// ─────────────────────────────────────────────────────────────
|
|
449
|
+
// Convenience API
|
|
450
|
+
// ─────────────────────────────────────────────────────────────
|
|
451
|
+
/**
|
|
452
|
+
* One-shot obfuscation of a TypeScript project.
|
|
453
|
+
*
|
|
454
|
+
* @param tsconfigPath - Absolute path to tsconfig.json
|
|
455
|
+
* @param outDir - Output directory
|
|
456
|
+
* @param profile - Obfuscation profile (use createDefaultProfile for defaults)
|
|
457
|
+
* @param onEvent - Optional progress callback
|
|
458
|
+
*/
|
|
459
|
+
export async function obfuscate(tsconfigPath, outDir, profile, onEvent) {
|
|
460
|
+
const resolvedProfile = profile ?? createDefaultProfile('generic');
|
|
461
|
+
const pipeline = new ObfuscationPipeline({
|
|
462
|
+
tsconfigPath,
|
|
463
|
+
profile: resolvedProfile,
|
|
464
|
+
outDir,
|
|
465
|
+
onEvent,
|
|
466
|
+
});
|
|
467
|
+
return pipeline.execute();
|
|
468
|
+
}
|
|
469
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAqBnG,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,SAAS,2BAA2B,CAAC,OAA2B;IAC9D,OAAO,OAAO,CAAC,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC;AACzD,CAAC;AA+CD,gEAAgE;AAChE,mBAAmB;AACnB,gEAAgE;AAEhE,MAAM,UAAU,oBAAoB,CAAC,MAAoC;IACvE,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAE5B,MAAM,cAAc,GAAG;QACrB,EAAE,IAAI,EAAE,6BAA6B,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE;QACnE,EAAE,IAAI,EAAE,uBAAuB,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE;QAC7D,EAAE,IAAI,EAAE,wBAAwB,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE;QAC9D,EAAE,IAAI,EAAE,4BAA4B,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE;QAClE,EAAE,IAAI,EAAE,uBAAuB,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE;QAC7D,EAAE,IAAI,EAAE,2BAA2B,EAAE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;AAChE,kBAAkB;AAClB,gEAAgE;AAEhE;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,YAAoB,EACpB,MAAc,EACd,OAA4B,EAC5B,OAA8B;IAE9B,MAAM,eAAe,GAAG,OAAO,IAAI,oBAAoB,CAAC,SAAS,CAAC,CAAC;IACnE,MAAM,QAAQ,GAAG,IAAI,mBAAmB,CAAC;QACvC,YAAY;QACZ,OAAO,EAAE,eAAe;QACxB,MAAM;QACN,OAAO;KACR,CAAC,CAAC;IACH,OAAO,QAAQ,CAAC,OAAO,EAAE,CAAC;AAC5B,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { FunctionCapabilityReport, ModuleInfo, VMRuntimeBundle } from '@tsvm/shared';
|
|
2
|
+
export declare function buildUniversalBundle(buildId: string, moduleInfo: ModuleInfo, compilerOptions: Record<string, unknown>, functionReports: readonly FunctionCapabilityReport[], vmBundle?: VMRuntimeBundle): VMRuntimeBundle;
|
|
3
|
+
//# sourceMappingURL=universal-bundler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"universal-bundler.d.ts","sourceRoot":"","sources":["../src/universal-bundler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,wBAAwB,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AA+M1F,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,UAAU,EACtB,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACxC,eAAe,EAAE,SAAS,wBAAwB,EAAE,EACpD,QAAQ,CAAC,EAAE,eAAe,GACzB,eAAe,CA4BjB"}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
const require = createRequire(import.meta.url);
|
|
3
|
+
const ts = require('typescript');
|
|
4
|
+
function createEmptyBundle(buildId, source) {
|
|
5
|
+
return {
|
|
6
|
+
buildId,
|
|
7
|
+
dispatchLoop: '',
|
|
8
|
+
handlers: [],
|
|
9
|
+
constantDecoder: '',
|
|
10
|
+
bytecodePayload: new Uint8Array(),
|
|
11
|
+
entryBootstrap: '',
|
|
12
|
+
fullSource: source,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function transpileModuleToEsm(sourceText, filePath, compilerOptions) {
|
|
16
|
+
return ts.transpileModule(sourceText, {
|
|
17
|
+
fileName: filePath,
|
|
18
|
+
compilerOptions: {
|
|
19
|
+
...compilerOptions,
|
|
20
|
+
module: ts.ModuleKind.ESNext,
|
|
21
|
+
target: ts.ScriptTarget.ES2020,
|
|
22
|
+
sourceMap: false,
|
|
23
|
+
declaration: false,
|
|
24
|
+
declarationMap: false,
|
|
25
|
+
inlineSourceMap: false,
|
|
26
|
+
inlineSources: false,
|
|
27
|
+
},
|
|
28
|
+
reportDiagnostics: false,
|
|
29
|
+
}).outputText;
|
|
30
|
+
}
|
|
31
|
+
function stripCommonJsFooter(vmSource) {
|
|
32
|
+
return vmSource.replace(/\nif \(typeof module !== 'undefined' && module\.exports\) \{[\s\S]*?\}\s*$/u, '').trim();
|
|
33
|
+
}
|
|
34
|
+
function extractVmFunctionObjectName(vmSource) {
|
|
35
|
+
const match = /const\s+([A-Za-z_$][\w$]*)\s*=\s*\(function\s*\(/u.exec(vmSource);
|
|
36
|
+
return match?.[1] ?? 'vmFunctions';
|
|
37
|
+
}
|
|
38
|
+
function buildTopLevelReportMap(transpiledFile, reports) {
|
|
39
|
+
const topLevelReports = new Map();
|
|
40
|
+
for (const statement of transpiledFile.statements) {
|
|
41
|
+
if (ts.isFunctionDeclaration(statement) && statement.name) {
|
|
42
|
+
const report = reports.find((candidate) => candidate.functionName === statement.name.text);
|
|
43
|
+
if (report) {
|
|
44
|
+
topLevelReports.set(statement.name.text, report);
|
|
45
|
+
}
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
if (ts.isVariableStatement(statement)) {
|
|
49
|
+
for (const declaration of statement.declarationList.declarations) {
|
|
50
|
+
if (!ts.isIdentifier(declaration.name) || !declaration.initializer) {
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
const bindingName = declaration.name.text;
|
|
54
|
+
if (ts.isArrowFunction(declaration.initializer) || ts.isFunctionExpression(declaration.initializer)) {
|
|
55
|
+
const report = reports.find((candidate) => candidate.functionName === bindingName);
|
|
56
|
+
if (report) {
|
|
57
|
+
topLevelReports.set(bindingName, report);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return topLevelReports;
|
|
64
|
+
}
|
|
65
|
+
function buildVmFunctionWrapper(transpiledSource, sourceFile, statement, vmObjectName) {
|
|
66
|
+
const functionName = statement.name.text;
|
|
67
|
+
const body = statement.body;
|
|
68
|
+
if (!body) {
|
|
69
|
+
throw new Error(`Cannot emit VM wrapper for declaration without body: ${functionName}`);
|
|
70
|
+
}
|
|
71
|
+
const signatureText = transpiledSource.slice(statement.getStart(sourceFile), body.getStart(sourceFile));
|
|
72
|
+
return `${signatureText}{ if (new.target) { return Reflect.construct(${vmObjectName}[${JSON.stringify(functionName)}], Array.prototype.slice.call(arguments), new.target); } return ${vmObjectName}[${JSON.stringify(functionName)}].apply(this, arguments); }`;
|
|
73
|
+
}
|
|
74
|
+
function buildVmFunctionExpressionWrapper(functionName, initializer, vmObjectName) {
|
|
75
|
+
if (ts.isArrowFunction(initializer)) {
|
|
76
|
+
return initializer.modifiers?.some((modifier) => modifier.kind === ts.SyntaxKind.AsyncKeyword)
|
|
77
|
+
? `async (...args) => ${vmObjectName}[${JSON.stringify(functionName)}].apply(this, args)`
|
|
78
|
+
: `(...args) => ${vmObjectName}[${JSON.stringify(functionName)}].apply(this, args)`;
|
|
79
|
+
}
|
|
80
|
+
if (ts.isFunctionExpression(initializer)) {
|
|
81
|
+
return initializer.modifiers?.some((modifier) => modifier.kind === ts.SyntaxKind.AsyncKeyword)
|
|
82
|
+
? `async function (...args) { return ${vmObjectName}[${JSON.stringify(functionName)}].apply(this, args); }`
|
|
83
|
+
: `function (...args) { if (new.target) { return Reflect.construct(${vmObjectName}[${JSON.stringify(functionName)}], args, new.target); } return ${vmObjectName}[${JSON.stringify(functionName)}].apply(this, args); }`;
|
|
84
|
+
}
|
|
85
|
+
throw new Error(`Unsupported top-level VM wrapper initializer for ${functionName}`);
|
|
86
|
+
}
|
|
87
|
+
function rewriteModuleStatements(transpiledSource, sourceFile, reports, vmObjectName) {
|
|
88
|
+
const topLevelReportMap = buildTopLevelReportMap(sourceFile, reports);
|
|
89
|
+
const replacements = new Map();
|
|
90
|
+
let hasVmFunctions = false;
|
|
91
|
+
for (const statement of sourceFile.statements) {
|
|
92
|
+
if (ts.isFunctionDeclaration(statement) && statement.name) {
|
|
93
|
+
const report = topLevelReportMap.get(statement.name.text);
|
|
94
|
+
if (!report) {
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
if (report.tier === 'unsupported') {
|
|
98
|
+
throw new Error(`Universal ESM emitter cannot lower top-level function "${report.functionName}" in ${report.filePath}:${report.startLine}:${report.startColumn}`);
|
|
99
|
+
}
|
|
100
|
+
if (report.tier === 'vm_safe') {
|
|
101
|
+
replacements.set(statement, buildVmFunctionWrapper(transpiledSource, sourceFile, statement, vmObjectName));
|
|
102
|
+
hasVmFunctions = true;
|
|
103
|
+
}
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
if (ts.isVariableStatement(statement)) {
|
|
107
|
+
for (const declaration of statement.declarationList.declarations) {
|
|
108
|
+
if (!ts.isIdentifier(declaration.name) || !declaration.initializer) {
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
const bindingName = declaration.name.text;
|
|
112
|
+
if (!ts.isArrowFunction(declaration.initializer) && !ts.isFunctionExpression(declaration.initializer)) {
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
const report = topLevelReportMap.get(bindingName);
|
|
116
|
+
if (!report) {
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
if (report.tier === 'unsupported') {
|
|
120
|
+
throw new Error(`Universal ESM emitter cannot lower top-level function "${report.functionName}" in ${report.filePath}:${report.startLine}:${report.startColumn}`);
|
|
121
|
+
}
|
|
122
|
+
if (report.tier === 'vm_safe') {
|
|
123
|
+
const statementStart = statement.getStart(sourceFile);
|
|
124
|
+
const statementEnd = statement.getEnd();
|
|
125
|
+
const initializerStart = declaration.initializer.getStart(sourceFile);
|
|
126
|
+
const initializerEnd = declaration.initializer.getEnd();
|
|
127
|
+
replacements.set(statement, [
|
|
128
|
+
transpiledSource.slice(statementStart, initializerStart),
|
|
129
|
+
buildVmFunctionExpressionWrapper(bindingName, declaration.initializer, vmObjectName),
|
|
130
|
+
transpiledSource.slice(initializerEnd, statementEnd),
|
|
131
|
+
].join(''));
|
|
132
|
+
hasVmFunctions = true;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
let rewritten = '';
|
|
138
|
+
let cursor = 0;
|
|
139
|
+
for (const statement of sourceFile.statements) {
|
|
140
|
+
const start = statement.getStart(sourceFile);
|
|
141
|
+
const end = statement.getEnd();
|
|
142
|
+
rewritten += transpiledSource.slice(cursor, start);
|
|
143
|
+
rewritten += replacements.get(statement) ?? transpiledSource.slice(start, end);
|
|
144
|
+
cursor = end;
|
|
145
|
+
}
|
|
146
|
+
rewritten += transpiledSource.slice(cursor);
|
|
147
|
+
return {
|
|
148
|
+
rewrittenSource: rewritten.trim(),
|
|
149
|
+
hasVmFunctions,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
function injectVmRuntimeAfterImports(moduleSource, vmSource) {
|
|
153
|
+
const sourceFile = ts.createSourceFile('universal-bundle.mjs', moduleSource, ts.ScriptTarget.ESNext, true, ts.ScriptKind.JS);
|
|
154
|
+
let insertionOffset = 0;
|
|
155
|
+
for (const statement of sourceFile.statements) {
|
|
156
|
+
if (ts.isImportDeclaration(statement)) {
|
|
157
|
+
insertionOffset = statement.getEnd();
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
const prefix = moduleSource.slice(0, insertionOffset);
|
|
163
|
+
const suffix = moduleSource.slice(insertionOffset).trimStart();
|
|
164
|
+
const injected = `${vmSource}\n\n${suffix}`.trim();
|
|
165
|
+
return prefix.length > 0 ? `${prefix}\n\n${injected}` : injected;
|
|
166
|
+
}
|
|
167
|
+
export function buildUniversalBundle(buildId, moduleInfo, compilerOptions, functionReports, vmBundle) {
|
|
168
|
+
const sourceText = ts.sys.readFile(moduleInfo.filePath) || '';
|
|
169
|
+
const transpiledSource = transpileModuleToEsm(sourceText, moduleInfo.filePath, compilerOptions);
|
|
170
|
+
const transpiledFile = ts.createSourceFile(`${moduleInfo.relativePath}.mjs`, transpiledSource, ts.ScriptTarget.ESNext, true, ts.ScriptKind.JS);
|
|
171
|
+
const vmObjectName = vmBundle ? extractVmFunctionObjectName(vmBundle.fullSource) : 'vmFunctions';
|
|
172
|
+
const { rewrittenSource, hasVmFunctions } = rewriteModuleStatements(transpiledSource, transpiledFile, functionReports, vmObjectName);
|
|
173
|
+
const loweredFunctions = functionReports.filter((report) => report.tier === 'js_lowered');
|
|
174
|
+
const reportComment = loweredFunctions.length > 0
|
|
175
|
+
? loweredFunctions.map((report) => `// ${report.functionName} -> js_lowered: ${report.reasons.join(', ')}`).join('\n')
|
|
176
|
+
: '// all top-level rewritten functions were vm_safe';
|
|
177
|
+
const vmRuntimeSource = hasVmFunctions && vmBundle ? stripCommonJsFooter(vmBundle.fullSource) : '';
|
|
178
|
+
const esmModuleSource = vmRuntimeSource.length > 0 ? injectVmRuntimeAfterImports(rewrittenSource, vmRuntimeSource) : rewrittenSource;
|
|
179
|
+
const source = `// Universal ESM bundle: ${moduleInfo.relativePath}
|
|
180
|
+
${reportComment}
|
|
181
|
+
${esmModuleSource}
|
|
182
|
+
`.trim();
|
|
183
|
+
return createEmptyBundle(buildId, source);
|
|
184
|
+
}
|
|
185
|
+
//# sourceMappingURL=universal-bundler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"universal-bundler.js","sourceRoot":"","sources":["../src/universal-bundler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/C,MAAM,EAAE,GAAG,OAAO,CAAC,YAAY,CAAgC,CAAC;AAGhE,SAAS,iBAAiB,CAAC,OAAe,EAAE,MAAc;IACxD,OAAO;QACL,OAAO;QACP,YAAY,EAAE,EAAE;QAChB,QAAQ,EAAE,EAAE;QACZ,eAAe,EAAE,EAAE;QACnB,eAAe,EAAE,IAAI,UAAU,EAAE;QACjC,cAAc,EAAE,EAAE;QAClB,UAAU,EAAE,MAAM;KACnB,CAAC;AACJ,CAAC;AAED,SAAS,oBAAoB,CAAC,UAAkB,EAAE,QAAgB,EAAE,eAAwC;IAC1G,OAAO,EAAE,CAAC,eAAe,CAAC,UAAU,EAAE;QACpC,QAAQ,EAAE,QAAQ;QAClB,eAAe,EAAE;YACf,GAAI,eAA6C;YACjD,MAAM,EAAE,EAAE,CAAC,UAAU,CAAC,MAAM;YAC5B,MAAM,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM;YAC9B,SAAS,EAAE,KAAK;YAChB,WAAW,EAAE,KAAK;YAClB,cAAc,EAAE,KAAK;YACrB,eAAe,EAAE,KAAK;YACtB,aAAa,EAAE,KAAK;SACrB;QACD,iBAAiB,EAAE,KAAK;KACzB,CAAC,CAAC,UAAU,CAAC;AAChB,CAAC;AAED,SAAS,mBAAmB,CAAC,QAAgB;IAC3C,OAAO,QAAQ,CAAC,OAAO,CAAC,6EAA6E,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;AACpH,CAAC;AAED,SAAS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C"}
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tsvm/core",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"files": [
|
|
5
|
+
"dist",
|
|
6
|
+
"LICENSE"
|
|
7
|
+
],
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"publishConfig": {
|
|
10
|
+
"access": "public"
|
|
11
|
+
},
|
|
12
|
+
"description": "Pipeline orchestrator for ts-vm-obfuscator — ties semantic analysis, IR, transforms, bytecode, and VM together",
|
|
13
|
+
"type": "module",
|
|
14
|
+
"main": "./dist/index.js",
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"import": "./dist/index.js"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "tsc -p tsconfig.json",
|
|
24
|
+
"typecheck": "tsc --noEmit",
|
|
25
|
+
"clean": "rm -rf dist"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@tsvm/shared": "workspace:*",
|
|
29
|
+
"@tsvm/ts-semantics": "workspace:*",
|
|
30
|
+
"@tsvm/ir": "workspace:*",
|
|
31
|
+
"@tsvm/transforms": "workspace:*",
|
|
32
|
+
"@tsvm/bytecode": "workspace:*",
|
|
33
|
+
"@tsvm/vm-runtime": "workspace:*",
|
|
34
|
+
"@tsvm/wasm-runtime": "workspace:*",
|
|
35
|
+
"@tsvm/react-safe": "workspace:*",
|
|
36
|
+
"@tsvm/electron-hardening": "workspace:*",
|
|
37
|
+
"typescript": "^5.8.0"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"tsup": "^8.4.0"
|
|
41
|
+
}
|
|
42
|
+
}
|