@contrast/agent-swc-plugin
Config
[
"@contrast/agent-swc-plugin",
{
"assess": true, // default: false
"inject": true // default: false
}
]
assess
When true, enables all transforms. When false, only eval
call expressions and
import
declarations are rewritten, as these are the only transforms required
by Protect.
inject
When true, prepends the script or module with ContrastMethods
injections, i.e.
const foo = 'bar';
becomes:
global.Function = global.ContrastMethods.ContrastFunction || global.Function;
global.JSON = global.ContrastMethods.ContrastJSON || global.JSON;
global.Number = global.ContrastMethods.ContrastNumber || global.Number;
global.Object = global.ContrastMethods.ContrastObject || global.Object;
global.String = global.ContrastMethods.ContrastString || global.String;
const foo = 'bar';