U
U
utyfua2017-02-09 12:06:07
Node.js
utyfua, 2017-02-09 12:06:07

VM in nodejs - how to hide your function code and how to safely call functions from sandbox?

All the best
You need to use vm and provide your functions to work inside the environment.
How to keep your code from like this?

var vm=require('vm');
var sandbox_context=vm.createContext({
  myfunc:function () {
      //мой код функции, который нужно скрыть
        return 1;
  },
    console:console.dir,
});
vm.runInContext(`
    console(''+myfunc);//в консоль выводим тот код.. 
`, sandbox_context);

How to keep my code from being read?
Also, how can you safely call functions from a sandbox?
Thanks for answers.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question