asvd / jailed

execute untrusted code with custom permissions
MIT License
1.01k stars 69 forks source link

Passing interface with sub functions not working #59

Open quarterware opened 2 years ago

quarterware commented 2 years ago

I need to pass an object a larger context as an interface with sub properties, but the sub properties are undefined when accessed inside a jailed environment. I read through this issue #58 and tried implementing that but it didn't work for what I needed.

This is what I originally tried

const context = {
    log: function(x) {
        console.log(x);
    },
    JSON: {
        stringify: function(x) {
            return JSON.stringify(x);
        }
    }
}

var dp = new DynamicPlugin(myCode, context);

This didn't work and returned undefined for JSON and it's sub function. I tried implementing the callback solution in #58 but it had the same issue. Am I doing something wrong or Jailed not able to do this?