jscrambler-metro-plugin 5.5.33 → 6.0.1

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -2,6 +2,17 @@
2
2
 
3
3
  This metro plugin protects your **React Native** bundle using Jscrambler.
4
4
 
5
+ # Version Compatibility
6
+ ------------------------------------------------------------------------------
7
+
8
+ The version's compatibility table match your [Jscrambler Version](https://app.jscrambler.com/settings) with the Jscrambler Metro Plugin.
9
+ Please make sure you install the right version, otherwise some functionalities might not work properly.
10
+
11
+ | _Jscrambler Version_ | _Client and Integrations_ |
12
+ |:----------:|:-------------:|
13
+ | _<= 7.1_ | _<= 5.x.x_ |
14
+ | _\>= 7.2_ | _\>= 6.0.0_ |
15
+
5
16
  # Usage
6
17
 
7
18
  Include the plugin in your `metro.config.js` and add the following code:
package/lib/constants.js CHANGED
@@ -15,6 +15,9 @@ const JSCRAMBLER_PROTECTION_ID_FILE = `${JSCRAMBLER_TEMP_FOLDER}/protectionId`;
15
15
  const JSCRAMBLER_BEG_ANNOTATION = '"JSCRAMBLER-BEG";';
16
16
  const JSCRAMBLER_END_ANNOTATION = '"JSCRAMBLER-END";';
17
17
  const JSCRAMBLER_EXTS = /.(j|t)s(x)?$/i;
18
+ const JSCRAMBLER_SELF_DEFENDING = 'selfDefending';
19
+ const JSCRAMBLER_GLOBAL_VARIABLE_INDIRECTION = 'globalVariableIndirection';
20
+ const JSCRAMBLER_TOLERATE_BENIGN_POISONING = 'tolerateBenignPoisoning';
18
21
 
19
22
  module.exports = {
20
23
  BUNDLE_CMD,
@@ -30,5 +33,8 @@ module.exports = {
30
33
  JSCRAMBLER_PROTECTION_ID_FILE,
31
34
  JSCRAMBLER_BEG_ANNOTATION,
32
35
  JSCRAMBLER_END_ANNOTATION,
36
+ JSCRAMBLER_SELF_DEFENDING,
37
+ JSCRAMBLER_GLOBAL_VARIABLE_INDIRECTION,
38
+ JSCRAMBLER_TOLERATE_BENIGN_POISONING,
33
39
  JSCRAMBLER_EXTS
34
40
  }
package/lib/index.js CHANGED
@@ -27,6 +27,8 @@ const {
27
27
  stripEntryPointTags,
28
28
  stripJscramblerTags,
29
29
  addBundleArgsToExcludeList,
30
+ handleExcludeList,
31
+ injectTolerateBegninPoisoning,
30
32
  wrapCodeWithTags
31
33
  } = require('./utils');
32
34
 
@@ -137,23 +139,9 @@ async function obfuscateBundle(
137
139
  "excludeList"
138
140
  );
139
141
 
140
- if (supportsExcludeList) {
141
- config.excludeList = excludeList;
142
- } else {
143
- // add excludeList to gvi in case the api does not support global excludeList
144
- if (config.params && Array.isArray(config.params)) {
145
- const gvi = config.params.filter(
146
- (param) => param.name === "globalVariableIndirection"
147
- )[0];
148
- if (gvi) {
149
- gvi.options = gvi.options || {};
150
- const mixedList = [
151
- ...new Set(excludeList.concat(gvi.options.excludeList || [])),
152
- ];
153
- gvi.options.excludeList = mixedList;
154
- }
155
- }
156
- }
142
+ handleExcludeList(config, {supportsExcludeList, excludeList});
143
+
144
+ injectTolerateBegninPoisoning(config);
157
145
 
158
146
  if (bundleSourceMapPath && typeof config.sourceMaps === 'undefined') {
159
147
  console.error(`error Metro is generating source maps that won't be useful after Jscrambler protection.
package/lib/utils.js CHANGED
@@ -7,6 +7,9 @@ const {
7
7
  JSCRAMBLER_EXTS,
8
8
  JSCRAMBLER_END_ANNOTATION,
9
9
  JSCRAMBLER_BEG_ANNOTATION,
10
+ JSCRAMBLER_SELF_DEFENDING,
11
+ JSCRAMBLER_TOLERATE_BENIGN_POISONING,
12
+ JSCRAMBLER_GLOBAL_VARIABLE_INDIRECTION,
10
13
  BUNDLE_OUTPUT_CLI_ARG,
11
14
  BUNDLE_SOURCEMAP_OUTPUT_CLI_ARG,
12
15
  BUNDLE_DEV_CLI_ARG,
@@ -237,6 +240,45 @@ const addBundleArgsToExcludeList = (chunk, excludeList) => {
237
240
  process.exit(1);
238
241
  };
239
242
 
243
+ function handleExcludeList(config, {supportsExcludeList, excludeList}) {
244
+ if (supportsExcludeList) {
245
+ config.excludeList = excludeList;
246
+ } else {
247
+ // add excludeList to gvi in case the api does not support global excludeList
248
+ if (Array.isArray(config.params)) {
249
+ const gvi = config.params.find(
250
+ (param) => param.name === JSCRAMBLER_GLOBAL_VARIABLE_INDIRECTION
251
+ );
252
+ if (gvi) {
253
+ gvi.options = gvi.options || {};
254
+ const mixedList = [
255
+ ...new Set(excludeList.concat(gvi.options.excludeList || [])),
256
+ ];
257
+ gvi.options.excludeList = mixedList;
258
+ }
259
+ }
260
+ }
261
+ }
262
+
263
+ function injectTolerateBegninPoisoning(config) {
264
+ if (Array.isArray(config.params)) {
265
+ const sd = config.params.find(
266
+ (param) => param.name === JSCRAMBLER_SELF_DEFENDING
267
+ );
268
+ if (sd) {
269
+ sd.options = sd.options || {};
270
+ sd.options.options = sd.options.options || [];
271
+ if (
272
+ Array.isArray(sd.options.options) &&
273
+ !sd.options.options.includes(JSCRAMBLER_TOLERATE_BENIGN_POISONING)
274
+ ) {
275
+ console.log(`info Jscrambler Tolerate benign poisoning option was automatically added to Self-Defending.`);
276
+ sd.options.options.push(JSCRAMBLER_TOLERATE_BENIGN_POISONING)
277
+ }
278
+ }
279
+ }
280
+ }
281
+
240
282
  module.exports = {
241
283
  buildModuleSourceMap,
242
284
  buildNormalizePath,
@@ -247,5 +289,7 @@ module.exports = {
247
289
  stripEntryPointTags,
248
290
  stripJscramblerTags,
249
291
  addBundleArgsToExcludeList,
292
+ handleExcludeList,
293
+ injectTolerateBegninPoisoning,
250
294
  wrapCodeWithTags
251
295
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jscrambler-metro-plugin",
3
- "version": "5.5.33",
3
+ "version": "6.0.1",
4
4
  "description": "A plugin to use metro with Jscrambler",
5
5
  "main": "lib/index.js",
6
6
  "peerDependencies": {
@@ -9,7 +9,7 @@
9
9
  "dependencies": {
10
10
  "commander": "^2.20.0",
11
11
  "fs-extra": "^8.0.1",
12
- "jscrambler": "^5.5.32"
12
+ "jscrambler": "^6.0.1"
13
13
  },
14
14
  "keywords": [
15
15
  "jscrambler",