@memberjunction/code-execution 2.108.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/.turbo/turbo-build.log +4 -0
- package/CHANGELOG.md +8 -0
- package/README.md +312 -0
- package/dist/CodeExecutionService.d.ts +44 -0
- package/dist/CodeExecutionService.d.ts.map +1 -0
- package/dist/CodeExecutionService.js +253 -0
- package/dist/CodeExecutionService.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/libraries/index.d.ts +27 -0
- package/dist/libraries/index.d.ts.map +1 -0
- package/dist/libraries/index.js +355 -0
- package/dist/libraries/index.js.map +1 -0
- package/dist/types/index.d.ts +95 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +39 -0
- package/security-research.md +226 -0
- package/src/CodeExecutionService.ts +267 -0
- package/src/CodeExecutionService.ts.backup +298 -0
- package/src/index.ts +8 -0
- package/src/libraries/index.ts +359 -0
- package/src/types/index.ts +110 -0
- package/tsconfig.json +25 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parameters for code execution
|
|
3
|
+
*/
|
|
4
|
+
export interface CodeExecutionParams {
|
|
5
|
+
/**
|
|
6
|
+
* The code to execute
|
|
7
|
+
*/
|
|
8
|
+
code: string;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Programming language (currently only 'javascript' supported)
|
|
12
|
+
*/
|
|
13
|
+
language: 'javascript';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Input data available to the code via 'input' variable
|
|
17
|
+
*/
|
|
18
|
+
inputData?: any;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Maximum execution time in seconds (default: 30)
|
|
22
|
+
*/
|
|
23
|
+
timeoutSeconds?: number;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Memory limit in MB (default: 128)
|
|
27
|
+
* Note: Memory limiting requires Node.js flags, enforced at process level
|
|
28
|
+
*/
|
|
29
|
+
memoryLimitMB?: number;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Result of code execution
|
|
34
|
+
*/
|
|
35
|
+
export interface CodeExecutionResult {
|
|
36
|
+
/**
|
|
37
|
+
* Whether execution was successful
|
|
38
|
+
*/
|
|
39
|
+
success: boolean;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The output value set by the code (value of 'output' variable)
|
|
43
|
+
*/
|
|
44
|
+
output?: any;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Console logs captured during execution
|
|
48
|
+
*/
|
|
49
|
+
logs?: string[];
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Error message if execution failed
|
|
53
|
+
*/
|
|
54
|
+
error?: string;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Type of error that occurred
|
|
58
|
+
*/
|
|
59
|
+
errorType?: 'TIMEOUT' | 'MEMORY_LIMIT' | 'SYNTAX_ERROR' | 'RUNTIME_ERROR' | 'SECURITY_ERROR';
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Execution time in milliseconds
|
|
63
|
+
*/
|
|
64
|
+
executionTimeMs?: number;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Options for JavaScript sandbox execution
|
|
69
|
+
*/
|
|
70
|
+
export interface JavaScriptExecutionOptions {
|
|
71
|
+
/**
|
|
72
|
+
* Timeout in seconds
|
|
73
|
+
*/
|
|
74
|
+
timeout: number;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Memory limit in MB
|
|
78
|
+
*/
|
|
79
|
+
memoryLimit: number;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* List of allowed npm packages that can be required
|
|
83
|
+
*/
|
|
84
|
+
allowedLibraries?: string[];
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Sandbox context provided to executed code
|
|
89
|
+
*/
|
|
90
|
+
export interface SandboxContext {
|
|
91
|
+
/**
|
|
92
|
+
* Input data for the code
|
|
93
|
+
*/
|
|
94
|
+
input: any;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Output data set by the code
|
|
98
|
+
*/
|
|
99
|
+
output: any;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Console API for logging
|
|
103
|
+
*/
|
|
104
|
+
console: {
|
|
105
|
+
log: (...args: any[]) => void;
|
|
106
|
+
error: (...args: any[]) => void;
|
|
107
|
+
warn: (...args: any[]) => void;
|
|
108
|
+
info: (...args: any[]) => void;
|
|
109
|
+
};
|
|
110
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"experimentalDecorators": true,
|
|
4
|
+
"emitDecoratorMetadata": true,
|
|
5
|
+
"module": "commonjs",
|
|
6
|
+
"esModuleInterop": true,
|
|
7
|
+
"target": "ES2022",
|
|
8
|
+
"lib": ["ES2022"],
|
|
9
|
+
"skipLibCheck": true,
|
|
10
|
+
"declaration": true,
|
|
11
|
+
"declarationMap": true,
|
|
12
|
+
"moduleResolution": "node",
|
|
13
|
+
"sourceMap": true,
|
|
14
|
+
"outDir": "./dist",
|
|
15
|
+
"rootDir": "./src"
|
|
16
|
+
},
|
|
17
|
+
"include": [
|
|
18
|
+
"src/**/*"
|
|
19
|
+
],
|
|
20
|
+
"exclude": [
|
|
21
|
+
"node_modules",
|
|
22
|
+
"dist",
|
|
23
|
+
"**/*.spec.ts"
|
|
24
|
+
]
|
|
25
|
+
}
|