diff --git a/src/server.js b/src/server.js index 303e18a..1a64dce 100644 --- a/src/server.js +++ b/src/server.js @@ -89,12 +89,13 @@ function loadGlobalVariableFunctions() { const code = readFileSync(filePath, "utf-8"); const script = new vm.Script(code, { filename: file }); - // Execute in context with crypto and console - // Expects file to return an object via IIFE + // Execute in context with all VM globals and previously loaded variables + // Allows function modules to access same dependencies as proxy.js const tempContext = vm.createContext({ - crypto, - console: logger, + ...globalVMContext, + ...globalVariableContext, }); + const exportedObject = script.runInContext(tempContext); globalVariableContext[functionName] = exportedObject;