UNPKG

@discue/somewhat-secure-insecure-fn-executor

Version:

Tries to isolate execution of untrusted code

60 lines (59 loc) 1.29 kB
declare namespace _exports { export { ExecutionResult, ExecutionLogs, ExecutionError }; } declare function _exports(script: string, args?: object): ExecutionResult; export = _exports; type ExecutionResult = { /** * the return value of the given script */ result?: any; /** * the logs captured during script execution */ logs: ExecutionLogs; /** * duration of the script execution in milliseconds */ durationMillis: number; /** * error details captured during script execution */ error?: ExecutionError; }; type ExecutionLogs = { /** * logs passed to console.error */ error: Array<string>; /** * logs passed to console.info */ info: Array<string>; /** * logs passed to console.log */ log: Array<string>; /** * logs passed to console.warn */ warn: Array<string>; }; type ExecutionError = { /** * the cause from the caputured error. May be null. */ cause?: string; /** * the code from the captured error. May be null. */ code?: number; /** * the stack trace from the captured error. */ stack: Array<string>; /** * the message from the captured error. */ message: string; };