Configure custom whitelisted globals and prototypes
mainYou can customize the sandbox security model by providing your own prototypeWhitelist and globals.
- Use
Sandbox.SAFE_PROTOTYPESto get the default prototype whitelist (aSet). - Use
Sandbox.SAFE_GLOBALSto get the default safe globals object.
Example of adding alert to globals and Node to the prototype whitelist:
const prototypeWhitelist = Sandbox.SAFE_PROTOTYPES;
prototypeWhitelist.set(Node, new Set());
const globals = {...Sandbox.SAFE_GLOBALS, alert};
const sandbox = new Sandbox({globals, prototypeWhitelist});