@memberjunction/code-execution 2.108.0 → 2.110.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.
@@ -0,0 +1,309 @@
1
+ "use strict";
2
+ /**
3
+ * Worker Pool Manager
4
+ *
5
+ * Manages a pool of worker processes for executing code with fault isolation.
6
+ * Each worker runs in a separate OS process, so a catastrophic failure in one
7
+ * worker (e.g., V8 OOM crash) doesn't affect the main application or other workers.
8
+ *
9
+ * Features:
10
+ * - Process-level isolation for fault tolerance
11
+ * - Automatic worker restart on crashes
12
+ * - Request queuing when all workers are busy
13
+ * - Health monitoring and circuit breaker pattern
14
+ */
15
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ var desc = Object.getOwnPropertyDescriptor(m, k);
18
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
19
+ desc = { enumerable: true, get: function() { return m[k]; } };
20
+ }
21
+ Object.defineProperty(o, k2, desc);
22
+ }) : (function(o, m, k, k2) {
23
+ if (k2 === undefined) k2 = k;
24
+ o[k2] = m[k];
25
+ }));
26
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
27
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
28
+ }) : function(o, v) {
29
+ o["default"] = v;
30
+ });
31
+ var __importStar = (this && this.__importStar) || function (mod) {
32
+ if (mod && mod.__esModule) return mod;
33
+ var result = {};
34
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
35
+ __setModuleDefault(result, mod);
36
+ return result;
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.WorkerPool = void 0;
40
+ const child_process_1 = require("child_process");
41
+ const path = __importStar(require("path"));
42
+ const core_1 = require("@memberjunction/core");
43
+ /**
44
+ * Manages a pool of worker processes for code execution
45
+ */
46
+ class WorkerPool {
47
+ workers = [];
48
+ requestQueue = [];
49
+ nextRequestId = 0;
50
+ poolSize;
51
+ maxCrashesPerWorker;
52
+ crashTimeWindow;
53
+ maxQueueSize;
54
+ isShuttingDown = false;
55
+ constructor(options = {}) {
56
+ this.poolSize = options.poolSize || 2;
57
+ this.maxCrashesPerWorker = options.maxCrashesPerWorker || 3;
58
+ this.crashTimeWindow = options.crashTimeWindow || 60000; // 1 minute
59
+ this.maxQueueSize = options.maxQueueSize || 100;
60
+ }
61
+ /**
62
+ * Initialize the worker pool
63
+ */
64
+ async initialize() {
65
+ (0, core_1.LogStatus)('Initializing code execution worker pool with ' + this.poolSize + ' workers');
66
+ for (let i = 0; i < this.poolSize; i++) {
67
+ await this.createWorker(i);
68
+ }
69
+ }
70
+ /**
71
+ * Create a new worker process
72
+ */
73
+ async createWorker(id) {
74
+ const workerPath = path.join(__dirname, 'worker.js'); // Use .js because worker.ts is compiled
75
+ const childProcess = (0, child_process_1.fork)(workerPath, [], {
76
+ stdio: ['ignore', 'inherit', 'inherit', 'ipc'] // Inherit stdout/stderr for debugging
77
+ });
78
+ const worker = {
79
+ process: childProcess,
80
+ id,
81
+ busy: false,
82
+ currentRequest: null,
83
+ crashCount: 0,
84
+ lastCrashTime: 0
85
+ };
86
+ this.workers[id] = worker;
87
+ // Wait for ready message
88
+ await new Promise((resolve, reject) => {
89
+ const timeout = setTimeout(() => {
90
+ reject(new Error(`Worker ${id} failed to start within 5 seconds`));
91
+ }, 5000);
92
+ childProcess.once('message', (msg) => {
93
+ if (msg.type === 'ready') {
94
+ clearTimeout(timeout);
95
+ resolve();
96
+ }
97
+ });
98
+ childProcess.once('error', (error) => {
99
+ clearTimeout(timeout);
100
+ reject(error);
101
+ });
102
+ });
103
+ // Set up message handler for responses
104
+ childProcess.on('message', (message) => {
105
+ this.handleWorkerMessage(worker, message);
106
+ });
107
+ // Set up crash handler
108
+ childProcess.on('exit', (code, signal) => {
109
+ this.handleWorkerCrash(worker, code, signal);
110
+ });
111
+ (0, core_1.LogStatus)(`Worker ${id} initialized and ready`);
112
+ }
113
+ /**
114
+ * Handle messages from worker process
115
+ */
116
+ handleWorkerMessage(worker, message) {
117
+ if (message.type === 'ready') {
118
+ // Worker is ready (initial startup or after restart)
119
+ return;
120
+ }
121
+ if (!worker.currentRequest) {
122
+ (0, core_1.LogError)(new Error(`Worker ${worker.id} sent message but has no current request`));
123
+ return;
124
+ }
125
+ const request = worker.currentRequest;
126
+ clearTimeout(request.timeout);
127
+ if (message.type === 'result') {
128
+ request.resolve(message.result);
129
+ }
130
+ else if (message.type === 'error') {
131
+ request.reject(new Error(message.error));
132
+ }
133
+ // Mark worker as available and process queue
134
+ worker.busy = false;
135
+ worker.currentRequest = null;
136
+ this.processQueue();
137
+ }
138
+ /**
139
+ * Handle worker process crash
140
+ */
141
+ handleWorkerCrash(worker, code, signal) {
142
+ const now = Date.now();
143
+ // Update crash tracking
144
+ if (now - worker.lastCrashTime > this.crashTimeWindow) {
145
+ // Outside time window, reset count
146
+ worker.crashCount = 1;
147
+ }
148
+ else {
149
+ worker.crashCount++;
150
+ }
151
+ worker.lastCrashTime = now;
152
+ (0, core_1.LogError)(new Error(`Worker ${worker.id} crashed (code: ${code}, signal: ${signal}). ` +
153
+ `Crash count: ${worker.crashCount}/${this.maxCrashesPerWorker}`));
154
+ // Reject current request if any
155
+ if (worker.currentRequest) {
156
+ clearTimeout(worker.currentRequest.timeout);
157
+ worker.currentRequest.reject(new Error('Worker process crashed during code execution. This may indicate a severe error in the code.'));
158
+ worker.currentRequest = null;
159
+ }
160
+ // Check if worker should be restarted
161
+ if (worker.crashCount >= this.maxCrashesPerWorker) {
162
+ (0, core_1.LogError)(new Error(`Worker ${worker.id} has crashed ${worker.crashCount} times within ${this.crashTimeWindow}ms. ` +
163
+ 'Not restarting to prevent crash loop. Code execution capacity reduced.'));
164
+ // Remove from pool
165
+ this.workers[worker.id] = null;
166
+ return;
167
+ }
168
+ // Restart worker if not shutting down
169
+ if (!this.isShuttingDown) {
170
+ (0, core_1.LogStatus)(`Restarting worker ${worker.id}...`);
171
+ this.createWorker(worker.id).catch(error => {
172
+ (0, core_1.LogError)(new Error(`Failed to restart worker ${worker.id}: ${error.message}`));
173
+ });
174
+ }
175
+ }
176
+ /**
177
+ * Execute code in an available worker
178
+ */
179
+ async execute(params) {
180
+ if (this.isShuttingDown) {
181
+ return {
182
+ success: false,
183
+ error: 'Worker pool is shutting down',
184
+ errorType: 'RUNTIME_ERROR'
185
+ };
186
+ }
187
+ // Check if queue is full
188
+ if (this.requestQueue.length >= this.maxQueueSize) {
189
+ return {
190
+ success: false,
191
+ error: `Request queue is full (${this.maxQueueSize} pending requests). Please try again later.`,
192
+ errorType: 'RUNTIME_ERROR'
193
+ };
194
+ }
195
+ const requestId = `req-${this.nextRequestId++}`;
196
+ return new Promise((resolve, reject) => {
197
+ // Create timeout for entire request (includes queue time + execution)
198
+ const totalTimeout = ((params.timeoutSeconds || 30) + 5) * 1000; // Add 5s buffer for overhead
199
+ const timeout = setTimeout(() => {
200
+ // Remove from queue if still there
201
+ const queueIndex = this.requestQueue.findIndex(r => r.requestId === requestId);
202
+ if (queueIndex >= 0) {
203
+ this.requestQueue.splice(queueIndex, 1);
204
+ }
205
+ resolve({
206
+ success: false,
207
+ error: 'Request timed out waiting for worker availability',
208
+ errorType: 'TIMEOUT'
209
+ });
210
+ }, totalTimeout);
211
+ const request = {
212
+ requestId,
213
+ params,
214
+ resolve,
215
+ reject,
216
+ timeout
217
+ };
218
+ // Add to queue
219
+ this.requestQueue.push(request);
220
+ // Try to process immediately
221
+ this.processQueue();
222
+ });
223
+ }
224
+ /**
225
+ * Process queued requests by assigning them to available workers
226
+ */
227
+ processQueue() {
228
+ if (this.requestQueue.length === 0) {
229
+ return;
230
+ }
231
+ // Find an available worker
232
+ const worker = this.workers.find(w => w && !w.busy);
233
+ if (!worker) {
234
+ return; // All workers busy, wait for one to finish
235
+ }
236
+ // Get next request from queue
237
+ const request = this.requestQueue.shift();
238
+ if (!request) {
239
+ return;
240
+ }
241
+ // Assign request to worker
242
+ worker.busy = true;
243
+ worker.currentRequest = request;
244
+ // Send execution request to worker
245
+ worker.process.send({
246
+ type: 'execute',
247
+ requestId: request.requestId,
248
+ params: request.params
249
+ });
250
+ // Try to process more if queue has items
251
+ if (this.requestQueue.length > 0) {
252
+ setImmediate(() => this.processQueue());
253
+ }
254
+ }
255
+ /**
256
+ * Get pool statistics
257
+ */
258
+ getStats() {
259
+ const activeWorkers = this.workers.filter(w => w !== null).length;
260
+ const busyWorkers = this.workers.filter(w => w && w.busy).length;
261
+ return {
262
+ totalWorkers: this.poolSize,
263
+ activeWorkers,
264
+ busyWorkers,
265
+ queueLength: this.requestQueue.length
266
+ };
267
+ }
268
+ /**
269
+ * Shutdown the worker pool gracefully
270
+ */
271
+ async shutdown() {
272
+ this.isShuttingDown = true;
273
+ (0, core_1.LogStatus)('Shutting down code execution worker pool...');
274
+ // Reject all queued requests
275
+ for (const request of this.requestQueue) {
276
+ clearTimeout(request.timeout);
277
+ request.resolve({
278
+ success: false,
279
+ error: 'Worker pool is shutting down',
280
+ errorType: 'RUNTIME_ERROR'
281
+ });
282
+ }
283
+ this.requestQueue = [];
284
+ // Kill all workers
285
+ const killPromises = this.workers
286
+ .filter(w => w !== null)
287
+ .map(worker => {
288
+ return new Promise((resolve) => {
289
+ if (worker.process.killed) {
290
+ resolve();
291
+ return;
292
+ }
293
+ worker.process.once('exit', () => resolve());
294
+ worker.process.kill('SIGTERM');
295
+ // Force kill after 5 seconds
296
+ setTimeout(() => {
297
+ if (!worker.process.killed) {
298
+ worker.process.kill('SIGKILL');
299
+ }
300
+ resolve();
301
+ }, 5000);
302
+ });
303
+ });
304
+ await Promise.all(killPromises);
305
+ (0, core_1.LogStatus)('Worker pool shutdown complete');
306
+ }
307
+ }
308
+ exports.WorkerPool = WorkerPool;
309
+ //# sourceMappingURL=WorkerPool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WorkerPool.js","sourceRoot":"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AAC,CAAC;gBAC7C,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;gBAE/B,6BAA6B;gBAC7B,UAAU,CAAC,GAAG,EAAE;oBACZ,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;wBACzB,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;oBACnC,CAAC;oBACD,OAAO,EAAE,CAAC;gBACd,CAAC,EAAE,IAAI,CAAC,CAAC;YACb,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;QAEP,MAAM,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;QAChC,IAAA,gBAAS,EAAC,+BAA+B,CAAC,CAAC;IAC/C,CAAC;CACJ;AA1TD,gCA0TC"}
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@
3
3
  * @description Sandboxed code execution service for MemberJunction
4
4
  */
5
5
  export * from './CodeExecutionService';
6
+ export * from './WorkerPool';
6
7
  export * from './types';
7
8
  export * from './libraries';
8
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,wBAAwB,CAAC;AACvC,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,wBAAwB,CAAC;AACvC,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC"}
package/dist/index.js CHANGED
@@ -19,6 +19,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
19
19
  };
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
21
  __exportStar(require("./CodeExecutionService"), exports);
22
+ __exportStar(require("./WorkerPool"), exports);
22
23
  __exportStar(require("./types"), exports);
23
24
  __exportStar(require("./libraries"), exports);
24
25
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;AAEH,yDAAuC;AACvC,0CAAwB;AACxB,8CAA4B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;AAEH,yDAAuC;AACvC,+CAA6B;AAC7B,0CAAwB;AACxB,8CAA4B"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Worker Process for Code Execution
3
+ *
4
+ * This worker runs in a SEPARATE PROCESS to provide true process-level isolation
5
+ * for code execution. If a catastrophic V8 error occurs (e.g., severe OOM that crashes V8),
6
+ * only this worker process terminates, not the main application.
7
+ *
8
+ * SECURITY CRITICAL: This file handles the isolate boundary between host and sandbox.
9
+ * Any changes to this file MUST be reviewed for security implications:
10
+ * - NEVER expose ivm.Reference or ivm.ExternalCopy objects to untrusted code
11
+ * - NEVER accept untrusted V8 cachedData (CVE-2022-39266)
12
+ * - ALWAYS validate and sanitize data crossing the isolate boundary
13
+ * - ONLY pass primitives and plain objects via IPC (JSON-serializable data)
14
+ *
15
+ * Defense-in-depth layers:
16
+ * 1. Process isolation (this file) - protects against V8 catastrophic failures
17
+ * 2. V8 isolate (isolated-vm) - protects against sandbox escapes
18
+ * 3. Module blocking - prevents dangerous Node.js API access
19
+ * 4. Resource limits - prevents DoS via timeout/memory exhaustion
20
+ */
21
+ export {};
22
+ //# sourceMappingURL=worker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../src/worker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG"}
package/dist/worker.js ADDED
@@ -0,0 +1,254 @@
1
+ "use strict";
2
+ /**
3
+ * Worker Process for Code Execution
4
+ *
5
+ * This worker runs in a SEPARATE PROCESS to provide true process-level isolation
6
+ * for code execution. If a catastrophic V8 error occurs (e.g., severe OOM that crashes V8),
7
+ * only this worker process terminates, not the main application.
8
+ *
9
+ * SECURITY CRITICAL: This file handles the isolate boundary between host and sandbox.
10
+ * Any changes to this file MUST be reviewed for security implications:
11
+ * - NEVER expose ivm.Reference or ivm.ExternalCopy objects to untrusted code
12
+ * - NEVER accept untrusted V8 cachedData (CVE-2022-39266)
13
+ * - ALWAYS validate and sanitize data crossing the isolate boundary
14
+ * - ONLY pass primitives and plain objects via IPC (JSON-serializable data)
15
+ *
16
+ * Defense-in-depth layers:
17
+ * 1. Process isolation (this file) - protects against V8 catastrophic failures
18
+ * 2. V8 isolate (isolated-vm) - protects against sandbox escapes
19
+ * 3. Module blocking - prevents dangerous Node.js API access
20
+ * 4. Resource limits - prevents DoS via timeout/memory exhaustion
21
+ */
22
+ var __importDefault = (this && this.__importDefault) || function (mod) {
23
+ return (mod && mod.__esModule) ? mod : { "default": mod };
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ const isolated_vm_1 = __importDefault(require("isolated-vm"));
27
+ const libraries_1 = require("./libraries");
28
+ /**
29
+ * Execute JavaScript code in an isolated-vm isolate
30
+ *
31
+ * SECURITY: This function creates and manages the V8 isolate. It must ensure:
32
+ * - Only safe built-ins are exposed to untrusted code
33
+ * - Module loading is strictly controlled via allowlist
34
+ * - Input/output data is properly serialized (no object references leak)
35
+ */
36
+ async function executeInIsolate(params) {
37
+ const startTime = Date.now();
38
+ const timeoutMs = (params.timeoutSeconds || 30) * 1000;
39
+ const memoryLimitMB = params.memoryLimitMB || 128;
40
+ let isolate = null;
41
+ let context = null;
42
+ try {
43
+ // Create isolated VM with memory limit
44
+ isolate = new isolated_vm_1.default.Isolate({ memoryLimit: memoryLimitMB });
45
+ context = await isolate.createContext();
46
+ // Capture console logs
47
+ const logs = [];
48
+ // Set up console object
49
+ const jail = context.global;
50
+ await jail.set('global', jail.derefInto());
51
+ // SECURITY: Create console methods that capture output
52
+ // This ivm.Reference is safe - it's a callback we control, not exposed to user code
53
+ const consoleLog = new isolated_vm_1.default.Reference((level, ...args) => {
54
+ const formattedArgs = args.map(arg => formatConsoleArg(arg)).join(' ');
55
+ logs.push(`[${level}] ${formattedArgs}`);
56
+ });
57
+ await jail.set('_consoleLog', consoleLog);
58
+ // Set up console in the isolate
59
+ await context.eval(`
60
+ globalThis.console = {
61
+ log: (...args) => _consoleLog.applySync(undefined, ['LOG', ...args]),
62
+ error: (...args) => _consoleLog.applySync(undefined, ['ERROR', ...args]),
63
+ warn: (...args) => _consoleLog.applySync(undefined, ['WARN', ...args]),
64
+ info: (...args) => _consoleLog.applySync(undefined, ['INFO', ...args])
65
+ };
66
+ `);
67
+ // SECURITY: Set up input data - only primitives and plain objects, no References
68
+ if (params.inputData !== undefined) {
69
+ const inputDataStr = JSON.stringify(params.inputData);
70
+ await jail.set('_inputData', inputDataStr);
71
+ await context.eval('globalThis.input = JSON.parse(_inputData);');
72
+ }
73
+ // Set up safe built-in objects
74
+ await context.eval(`
75
+ globalThis.JSON = JSON;
76
+ globalThis.Math = Math;
77
+ globalThis.Date = Date;
78
+ globalThis.Array = Array;
79
+ globalThis.Object = Object;
80
+ globalThis.String = String;
81
+ globalThis.Number = Number;
82
+ globalThis.Boolean = Boolean;
83
+ globalThis.RegExp = RegExp;
84
+ globalThis.Error = Error;
85
+ globalThis.TypeError = TypeError;
86
+ globalThis.RangeError = RangeError;
87
+ globalThis.SyntaxError = SyntaxError;
88
+ `);
89
+ // SECURITY: Block network access via fetch() API (available in Node.js 18+)
90
+ // This is a global in modern Node.js and must be explicitly disabled
91
+ await context.eval(`
92
+ globalThis.fetch = () => {
93
+ throw new Error('Security Error: Network access via fetch() is not allowed in sandboxed code');
94
+ };
95
+ `);
96
+ // Set up module cache for require()
97
+ await jail.set('_moduleCache', new isolated_vm_1.default.Reference({}));
98
+ // SECURITY: Create require() function with strict module allowlisting
99
+ // This ivm.Reference is safe - it's a loader function we control
100
+ const requireFunc = new isolated_vm_1.default.Reference(async (moduleName) => {
101
+ const blockedModules = ['fs', 'path', 'http', 'https', 'net', 'child_process', 'cluster', 'os', 'process', 'axios'];
102
+ // Check if module is blocked
103
+ if (blockedModules.includes(moduleName)) {
104
+ throw new Error(`Security Error: Module '${moduleName}' is not allowed in sandboxed code`);
105
+ }
106
+ // Check if module is allowed
107
+ if (!(0, libraries_1.isModuleAllowed)(moduleName)) {
108
+ const allowedList = (0, libraries_1.getAllowedModuleNames)().join(', ');
109
+ throw new Error(`Module '${moduleName}' is not available. Allowed modules: ${allowedList}`);
110
+ }
111
+ // Load the library source
112
+ const libSource = (0, libraries_1.getLibrarySource)(moduleName);
113
+ if (!libSource) {
114
+ throw new Error(`Failed to load library '${moduleName}'`);
115
+ }
116
+ return libSource;
117
+ });
118
+ await jail.set('_requireLoader', requireFunc);
119
+ // Set up require() and module loading in the isolate
120
+ await context.eval(`
121
+ globalThis._loadedModules = {};
122
+
123
+ // Save a reference to eval for controlled module loading
124
+ const _controlledEval = eval;
125
+
126
+ globalThis.require = function(moduleName) {
127
+ // Check cache first
128
+ if (globalThis._loadedModules[moduleName]) {
129
+ return globalThis._loadedModules[moduleName];
130
+ }
131
+
132
+ // Load the module source from host
133
+ const moduleSource = _requireLoader.applySync(undefined, [moduleName]);
134
+
135
+ // Evaluate the module source to get the exports (controlled eval for library loading only)
136
+ const moduleExports = _controlledEval('(' + moduleSource + ')');
137
+
138
+ // Cache it
139
+ globalThis._loadedModules[moduleName] = moduleExports;
140
+
141
+ return moduleExports;
142
+ };
143
+ `);
144
+ // Wrap user code to capture output
145
+ const wrappedCode = `
146
+ (function() {
147
+ let output;
148
+ ${params.code}
149
+ return output;
150
+ })();
151
+ `;
152
+ // SECURITY: Compile and execute code with timeout
153
+ // CVE-2022-39266: Never use cachedData from untrusted sources
154
+ // We do NOT pass any cachedData parameter here - only compile from source
155
+ const script = await isolate.compileScript(wrappedCode);
156
+ const result = await script.run(context, { timeout: timeoutMs });
157
+ // SECURITY: Extract output value - use .copy() to get plain data, not References
158
+ // This ensures no ivm objects leak back to caller
159
+ let output;
160
+ if (result && typeof result === 'object' && 'copy' in result) {
161
+ output = await result.copy();
162
+ }
163
+ else {
164
+ output = result;
165
+ }
166
+ return {
167
+ success: true,
168
+ output,
169
+ logs: logs.length > 0 ? logs : undefined,
170
+ executionTimeMs: Date.now() - startTime
171
+ };
172
+ }
173
+ catch (error) {
174
+ let errorType = 'RUNTIME_ERROR';
175
+ let errorMessage = error instanceof Error ? error.message : String(error);
176
+ // Classify error types
177
+ if (errorMessage.includes('Script execution timed out')) {
178
+ errorType = 'TIMEOUT';
179
+ errorMessage = `Code execution exceeded timeout of ${params.timeoutSeconds || 30} seconds`;
180
+ }
181
+ else if (errorMessage.includes('SyntaxError') || errorMessage.includes('Unexpected')) {
182
+ errorType = 'SYNTAX_ERROR';
183
+ }
184
+ else if (errorMessage.includes('Security Error')) {
185
+ errorType = 'SECURITY_ERROR';
186
+ }
187
+ else if (errorMessage.includes('memory limit')) {
188
+ errorType = 'MEMORY_LIMIT';
189
+ }
190
+ return {
191
+ success: false,
192
+ error: errorMessage,
193
+ errorType,
194
+ executionTimeMs: Date.now() - startTime
195
+ };
196
+ }
197
+ finally {
198
+ // Clean up resources
199
+ if (context) {
200
+ context.release();
201
+ }
202
+ if (isolate) {
203
+ isolate.dispose();
204
+ }
205
+ }
206
+ }
207
+ /**
208
+ * Format console arguments for logging
209
+ */
210
+ function formatConsoleArg(arg) {
211
+ if (arg === null)
212
+ return 'null';
213
+ if (arg === undefined)
214
+ return 'undefined';
215
+ if (typeof arg === 'string')
216
+ return arg;
217
+ if (typeof arg === 'number' || typeof arg === 'boolean')
218
+ return String(arg);
219
+ try {
220
+ return JSON.stringify(arg, null, 2);
221
+ }
222
+ catch {
223
+ return String(arg);
224
+ }
225
+ }
226
+ /**
227
+ * Handle messages from parent process via IPC
228
+ * Messages are automatically JSON serialized/deserialized by Node.js
229
+ */
230
+ process.on('message', async (message) => {
231
+ if (message.type === 'execute') {
232
+ try {
233
+ const result = await executeInIsolate(message.params);
234
+ const response = {
235
+ type: 'result',
236
+ requestId: message.requestId,
237
+ result
238
+ };
239
+ // SECURITY: Only plain objects are sent via IPC - no References or functions
240
+ process.send(response);
241
+ }
242
+ catch (error) {
243
+ const response = {
244
+ type: 'error',
245
+ requestId: message.requestId,
246
+ error: error instanceof Error ? error.message : String(error)
247
+ };
248
+ process.send(response);
249
+ }
250
+ }
251
+ });
252
+ // Signal that worker is ready to accept work
253
+ process.send({ type: 'ready' });
254
+ //# sourceMappingURL=worker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker.js","sourceRoot":"","sources":["../src/worker.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;;;AAEH,8DAA8B;AAE9B,2CAAuF;AA+BvF;;;;;;;GAOG;AACH,KAAK,UAAU,gBAAgB,CAAC,MAA2B;IACvD,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAC7B,MAAM,SAAS,GAAG,CAAC,MAAM,CAAC,cAAc,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC;IACvD,MAAM,aAAa,GAAG,MAAM,CAAC,aAAa,IAAI,GAAG,CAAC;IAElD,IAAI,OAAO,GAAuB,IAAI,CAAC;IACvC,IAAI,OAAO,GAAuB,IAAI,CAAC;IAEvC,IAAI,CAAC;QACD,uCAAuC;QACvC,OAAO,GAAG,IAAI,qBAAG,CAAC,OAAO,CAAC,EAAE,WAAW,EAAE,aAAa,EAAE,CAAC,CAAC;QAC1D,OAAO,GAAG,MAAM,OAAO,CAAC,aAAa,EAAE,CAAC;QAExC,uBAAuB;QACvB,MAAM,IAAI,GAAa,EAAE,CAAC;QAE1B,wBAAwB;QACxB,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC;QAC5B,MAAM,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI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AM;aACT,CAAC;YACF,6EAA6E;YAC7E,OAAO,CAAC,IAAK,CAAC,QAAQ,CAAC,CAAC;QAC5B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,MAAM,QAAQ,GAAiB;gBAC3B,IAAI,EAAE,OAAO;gBACb,SAAS,EAAE,OAAO,CAAC,SAAS;gBAC5B,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;aAChE,CAAC;YACF,OAAO,CAAC,IAAK,CAAC,QAAQ,CAAC,CAAC;QAC5B,CAAC;IACL,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,6CAA6C;AAC7C,OAAO,CAAC,IAAK,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memberjunction/code-execution",
3
- "version": "2.108.0",
3
+ "version": "2.110.0",
4
4
  "description": "Sandboxed code execution service for MemberJunction actions and agents",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",