jscrambler-metro-plugin 8.4.24 → 8.4.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/constants.js +2 -0
- package/lib/index.js +7 -2
- package/lib/sourceMaps.js +6 -2
- package/lib/utils.js +13 -1
- package/package.json +2 -2
package/lib/constants.js
CHANGED
@@ -22,6 +22,7 @@ const JSCRAMBLER_ANTI_TAMPERING_MODE_RCK = 'RCK';
|
|
22
22
|
const JSCRAMBLER_ANTI_TAMPERING_MODE_SKL = 'SKL';
|
23
23
|
const JSCRAMBLER_GLOBAL_VARIABLE_INDIRECTION = 'globalVariableIndirection';
|
24
24
|
const JSCRAMBLER_TOLERATE_BENIGN_POISONING = 'tolerateBenignPoisoning';
|
25
|
+
const HERMES_SHOW_SOURCE_DIRECTIVE = '"show source";';
|
25
26
|
const JSCRAMBLER_HERMES_INCOMPATIBILITIES = [
|
26
27
|
{
|
27
28
|
slugName: JSCRAMBLER_SELF_DEFENDING,
|
@@ -56,5 +57,6 @@ module.exports = {
|
|
56
57
|
JSCRAMBLER_HERMES_INCOMPATIBILITIES,
|
57
58
|
JSCRAMBLER_HERMES_ADD_SHOW_SOURCE_DIRECTIVE,
|
58
59
|
JSCRAMBLER_ANTI_TAMPERING_MODE_SKL,
|
60
|
+
HERMES_SHOW_SOURCE_DIRECTIVE,
|
59
61
|
JSCRAMBLER_EXTS
|
60
62
|
}
|
package/lib/index.js
CHANGED
@@ -15,6 +15,7 @@ const {
|
|
15
15
|
JSCRAMBLER_BEG_ANNOTATION,
|
16
16
|
JSCRAMBLER_END_ANNOTATION,
|
17
17
|
BUNDLE_SOURCEMAP_OUTPUT_CLI_ARG,
|
18
|
+
HERMES_SHOW_SOURCE_DIRECTIVE,
|
18
19
|
JSCRAMBLER_EXTS
|
19
20
|
} = require('./constants');
|
20
21
|
const {
|
@@ -165,7 +166,9 @@ async function obfuscateBundle(
|
|
165
166
|
const addShowSource = addHermesShowSourceDirective(config);
|
166
167
|
|
167
168
|
if (addShowSource) {
|
168
|
-
console.log(
|
169
|
+
console.log(
|
170
|
+
`info Jscrambler ${HERMES_SHOW_SOURCE_DIRECTIVE} directive added`,
|
171
|
+
);
|
169
172
|
}
|
170
173
|
|
171
174
|
const shouldGenerateSourceMaps = config.sourceMaps && bundleSourceMapPath;
|
@@ -209,7 +212,9 @@ async function obfuscateBundle(
|
|
209
212
|
c.indexOf(JSCRAMBLER_END_ANNOTATION),
|
210
213
|
c.length
|
211
214
|
);
|
212
|
-
return `${acc}${JSCRAMBLER_BEG_ANNOTATION}${
|
215
|
+
return `${acc}${JSCRAMBLER_BEG_ANNOTATION}${
|
216
|
+
showSource ? HERMES_SHOW_SOURCE_DIRECTIVE : ''
|
217
|
+
}${startAtFirstColumn ? '\n' : ''}${obfuscatedCode}${tillCodeEnd}`;
|
213
218
|
}, '');
|
214
219
|
|
215
220
|
await writeFile(bundlePath, stripJscramblerTags(finalBundle));
|
package/lib/sourceMaps.js
CHANGED
@@ -115,7 +115,11 @@ module.exports = async function generateSourceMaps(payload) {
|
|
115
115
|
) {
|
116
116
|
/* jscrambler obfuscated files */
|
117
117
|
const {lineStart, lineEnd, columnStart} = metroBundleLocs[fileNamesIndex];
|
118
|
-
const {
|
118
|
+
const {
|
119
|
+
lineStart: finalLineStart,
|
120
|
+
lineEnd: finalLineEnd,
|
121
|
+
columnStart: finalColumnStart,
|
122
|
+
} = finalBundleLocs[fileNamesIndex];
|
119
123
|
const allGeneratedPositionsFor = ofuscatedSourceMapConsumers[fileNamesIndex].allGeneratedPositionsFor({
|
120
124
|
source: normalizePath,
|
121
125
|
line: mapping.generatedLine - lineStart + 1 /* avoid line=0 */,
|
@@ -134,7 +138,7 @@ module.exports = async function generateSourceMaps(payload) {
|
|
134
138
|
newMappings = allGeneratedPositionsFor.map(({line: obfLine, column: obfColumn}) => {
|
135
139
|
const calcFinalLine = finalLineStart + obfLine - 1;
|
136
140
|
// add columnStart only on the first line
|
137
|
-
const calcFinalColumn = obfLine === 1 ?
|
141
|
+
const calcFinalColumn = obfLine === 1 ? finalColumnStart + obfColumn : obfColumn;
|
138
142
|
|
139
143
|
debug && console.log('original', original, '->', 'final', {line: calcFinalLine, column: calcFinalColumn});
|
140
144
|
|
package/lib/utils.js
CHANGED
@@ -18,6 +18,7 @@ const {
|
|
18
18
|
BUNDLE_OUTPUT_CLI_ARG,
|
19
19
|
BUNDLE_SOURCEMAP_OUTPUT_CLI_ARG,
|
20
20
|
BUNDLE_DEV_CLI_ARG,
|
21
|
+
HERMES_SHOW_SOURCE_DIRECTIVE,
|
21
22
|
BUNDLE_CMD
|
22
23
|
} = require('./constants');
|
23
24
|
|
@@ -99,9 +100,20 @@ function extractLocs(inputStr) {
|
|
99
100
|
lines++;
|
100
101
|
const startTagIndex = line.indexOf(JSCRAMBLER_BEG_ANNOTATION);
|
101
102
|
if (startTagIndex !== -1) {
|
103
|
+
const columnStart = line.includes(
|
104
|
+
`${JSCRAMBLER_BEG_ANNOTATION}${HERMES_SHOW_SOURCE_DIRECTIVE}`,
|
105
|
+
)
|
106
|
+
? HERMES_SHOW_SOURCE_DIRECTIVE.length + startTagIndex
|
107
|
+
: startTagIndex;
|
108
|
+
// occurs with Anti-tampering SKL mode
|
109
|
+
const startAtFirstColumn = line.includes(
|
110
|
+
`${JSCRAMBLER_BEG_ANNOTATION}\n`,
|
111
|
+
);
|
112
|
+
|
102
113
|
locs.push({
|
103
114
|
lineStart: lines,
|
104
|
-
columnStart
|
115
|
+
columnStart,
|
116
|
+
startAtFirstColumn,
|
105
117
|
});
|
106
118
|
}
|
107
119
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "jscrambler-metro-plugin",
|
3
|
-
"version": "8.4.
|
3
|
+
"version": "8.4.26",
|
4
4
|
"description": "A plugin to use metro with Jscrambler Code Integrity",
|
5
5
|
"exports": "./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": "8.8.
|
12
|
+
"jscrambler": "8.8.4"
|
13
13
|
},
|
14
14
|
"keywords": [
|
15
15
|
"jscrambler",
|