Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jscrambler-metro-plugin

Package Overview
Dependencies
Maintainers
9
Versions
115
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jscrambler-metro-plugin - npm Package Compare versions

Comparing version 5.5.0 to 5.5.1

40

lib/index.js
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();

2

package.json
{
"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`
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc