Tamper Protection safeguards the runtime behavior from being altered by JavaScript pitfalls.
⚠️ Tamper Protection requires eval and ran in a non-strict mode environment!
Option name: "lock.tamperProtection"
Option values: true/false/Function
This example showcases how Tamper Protection transforms the code. Try it out by changing the input code and see changes apply in real-time.
Input.js
Output.js
Tamper Protection with Global Concealing can detect at runtime if certain global functions have been monkey-patched. The following code exemplifies this:
Code
This monkey-patch can be detected by inspecting the fetch.toString() value:
Code
Certain global functions are checked before each invocation to ensure that (1) the arguments cannot be intercepted and (2) their behavior cannot be altered.
A direct eval invocation can access the local scope, only if it has not been redefined.
Code
This method securely obtains the real global object for both the browser and NodeJS. Properties on the global object can still be changed however.
Tamper Protection requires the script to run in non-strict mode. Detection of the script in Strict Mode will be considered tampering. You can control the tampering response using the lock.countermeasures option.
Control which functions are changed. Returns a boolean.
Parameter | Type | Description |
---|---|---|
fnName | string | The function name proposed receive native check protection. |
The provided code example will obfuscate the file input.js and write the output to a file named output.js.
Usage Example