@locker/sandbox
Lightning Web Security sandboxing library
Installation
$ yarn add @locker/sandbox
Usage
The evaluateInSandbox()
function:
import { evaluateInSandbox } from '@locker/sandbox';
let sandboxed;
evaluateInSandbox(
'sandbox',
`$lockerEvalContext$(${
// Function body to coerce to a string. Using a function and coercing
// it to a string has the benefit of working with minifiers.
function () {
// Call to a provided endowment value.
logger('inside sandbox');
// Other code to sandbox...
}
})`,
(def) => {
sandboxed = def;
},
{ logger: console.log.bind(console) }
);