jscrambler-metro-plugin
Advanced tools
Comparing version 5.5.0 to 5.5.1
const {emptyDir, remove, mkdirp, readFile, writeFile} = require('fs-extra'); | ||
const jscrambler = require('jscrambler').default; | ||
const commander = require('commander'); | ||
const {Command} = require('commander'); | ||
const fs = require('fs'); | ||
@@ -8,3 +8,5 @@ const path = require('path'); | ||
const BUNDLE_CMD = 'bundle'; | ||
const BUNDLE_OUTPUT_CLI_ARG = '--bundle-output'; | ||
const BUNDLE_DEV_CLI_ARG = '--dev'; | ||
@@ -20,6 +22,31 @@ const JSCRAMBLER_CLIENT_ID = 6; | ||
/** | ||
* Only 'bundle' command triggers obfuscation | ||
* @returns {string} skip reason. If falsy value dont skip obfuscation | ||
*/ | ||
function skipObfuscation() { | ||
let isBundleCmd = false; | ||
const command = new Command(); | ||
command | ||
.command(BUNDLE_CMD) | ||
.allowUnknownOption() | ||
.action(() => (isBundleCmd = true)); | ||
command.option(`${BUNDLE_DEV_CLI_ARG} <boolean>`).parse(process.argv); | ||
if (!isBundleCmd) { | ||
return 'Not a *bundle* command'; | ||
} | ||
if (command.dev === 'true') { | ||
return ( | ||
process.env.JSCRAMBLER_METRO_DEV !== 'true' && | ||
'Development mode. Override with JSCRAMBLER_METRO_DEV=true environment variable' | ||
); | ||
} | ||
return null; | ||
} | ||
function getBundlePath() { | ||
commander.option(`${BUNDLE_OUTPUT_CLI_ARG} <string>`).parse(process.argv); | ||
if (commander.bundleOutput) { | ||
return commander.bundleOutput; | ||
const command = new Command(); | ||
command.option(`${BUNDLE_OUTPUT_CLI_ARG} <string>`).parse(process.argv); | ||
if (command.bundleOutput) { | ||
return command.bundleOutput; | ||
} | ||
@@ -139,2 +166,7 @@ console.error('Bundle output path not found.'); | ||
module.exports = function(_config = {}, projectRoot = process.cwd()) { | ||
const skipReason = skipObfuscation(); | ||
if (skipReason) { | ||
console.log(`warning: Jscrambler Obfuscation SKIPPED [${skipReason}]`); | ||
return {}; | ||
} | ||
const bundlePath = getBundlePath(); | ||
@@ -141,0 +173,0 @@ const fileNames = new Set(); |
{ | ||
"name": "jscrambler-metro-plugin", | ||
"version": "5.5.0", | ||
"version": "5.5.1", | ||
"description": "A plugin to use metro with Jscrambler", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -5,2 +5,4 @@ # Jscrambler Metro Plugin | ||
> Note: Only protects source code triggered by `bundle` react-native command. | ||
# Usage | ||
@@ -30,1 +32,3 @@ | ||
the usual `.jscramblerrc` file. | ||
By default, Jscrambler protection is **ignored** when bundle mode is set for **Development**. You can override this behaviour by setting env variable `JSCRAMBLER_METRO_DEV=true` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8169
212
33
4