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.4.3 to 5.5.0

79

lib/index.js

@@ -6,2 +6,3 @@ const {emptyDir, remove, mkdirp, readFile, writeFile} = require('fs-extra');

const path = require('path');
const metroSourceMap = require('metro-source-map');

@@ -28,3 +29,3 @@ const BUNDLE_OUTPUT_CLI_ARG = '--bundle-output';

function obfuscateBundle(bundlePath, fileNames, config) {
function obfuscateBundle(bundlePath, fileNames, sourceMapFiles, config) {
let userFiles;

@@ -61,8 +62,20 @@ let filesWithMycode;

)
.then(() =>
Promise.all(
sourceMapFiles.map(({filename, content}) =>
writeFile(`${JSCRAMBLER_SRC_TEMP_FOLDER}${filename}`, content)
)
)
)
.then(() => {
config.filesSrc = [`${JSCRAMBLER_SRC_TEMP_FOLDER}/**/*.js`];
config.filesSrc = [`${JSCRAMBLER_SRC_TEMP_FOLDER}/**/*.js?(.map)`];
config.filesDest = JSCRAMBLER_DIST_TEMP_FOLDER;
config.cwd = JSCRAMBLER_SRC_TEMP_FOLDER;
config.clientId = JSCRAMBLER_CLIENT_ID;
return jscrambler.protectAndDownload(config);
const jscramblerOp = !!config.instrument
? jscrambler.instrumentAndDownload
: jscrambler.protectAndDownload;
return jscramblerOp.call(jscrambler, config);
})

@@ -107,9 +120,41 @@ .then(protectionId =>

module.exports = function(config = {}, projectRoot = process.cwd()) {
/**
* Use 'metro-source-map' to build a standard source-map from raw mappings
* @param {{code: string, map: Array.<Array<number>>}} output
* @param {string} modulePath
* @param {string} source
* @returns {string}
*/
function buildModuleSourceMap(output, modulePath, source) {
return metroSourceMap
.fromRawMappings([
{
...output,
source,
path: modulePath
}
])
.toString(modulePath);
}
module.exports = function(_config = {}, projectRoot = process.cwd()) {
const bundlePath = getBundlePath();
const fileNames = new Set();
const sourceMapFiles = [];
const config = Object.assign({}, jscrambler.config, _config);
const sourceMaps = !!config.sourceMaps;
const instrument = !!config.instrument;
if (sourceMaps) {
throw new Error(`Currently, Jscrambler doesn't support React Native source maps`);
}
process.on('beforeExit', function(exitCode) {
console.log('Obfuscating code');
obfuscateBundle(bundlePath, Array.from(fileNames), config)
console.log(
instrument
? 'info Jscrambler Instrumenting Code'
: 'info Jscrambler Obfuscating Code'
);
obfuscateBundle(bundlePath, Array.from(fileNames), sourceMapFiles, config)
.catch(err => {

@@ -134,6 +179,16 @@ console.error(err);

fileNames.add(
_module.path.replace(JSCRAMBLER_EXTS, ".js").replace(projectRoot, "")
);
_module.output.forEach(({data}) =>
const relativePath = _module.path.replace(projectRoot, '');
const normalizePath = relativePath.replace(JSCRAMBLER_EXTS, '.js');
fileNames.add(normalizePath);
_module.output.forEach(({data}) => {
if ((instrument || sourceMaps) && Array.isArray(data.map)) {
sourceMapFiles.push({
filename: `${normalizePath}.map`,
content: buildModuleSourceMap(
data,
relativePath,
_module.getSource().toString()
)
});
}
wrapCodeWithTags(

@@ -143,4 +198,4 @@ data,

JSCRAMBLER_END_ANNOTATION
)
);
);
});
return true;

@@ -147,0 +202,0 @@ }

7

package.json
{
"name": "jscrambler-metro-plugin",
"version": "5.4.3",
"version": "5.5.0",
"description": "A plugin to use metro with Jscrambler",
"main": "lib/index.js",
"peerDependencies": {
"metro-source-map": "0.x"
},
"dependencies": {
"commander": "^2.20.0",
"fs-extra": "^8.0.1",
"jscrambler": "^5.4.3"
"jscrambler": "^5.5.0"
},

@@ -11,0 +14,0 @@ "keywords": [

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