jscrambler 8.8.3 → 8.8.5
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/CHANGELOG.md +12 -0
- package/dist/bin/jscrambler.js +1 -11
- package/dist/index.js +24 -12
- package/dist/utils.js +15 -2
- package/dist/zip.js +3 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# jscrambler
|
|
2
2
|
|
|
3
|
+
## 8.8.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [c4e79f4]: Add support for file size threshold with string value
|
|
8
|
+
|
|
9
|
+
## 8.8.4
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [7415ef5]: Prepend multiple file in jscrambler-cli
|
|
14
|
+
|
|
3
15
|
## 8.8.3
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/bin/jscrambler.js
CHANGED
|
@@ -6,7 +6,6 @@ require("core-js/modules/web.dom-collections.iterator.js");
|
|
|
6
6
|
var _commander = _interopRequireDefault(require("commander"));
|
|
7
7
|
var _lodash = _interopRequireDefault(require("lodash.defaults"));
|
|
8
8
|
var _path = _interopRequireDefault(require("path"));
|
|
9
|
-
var _filesizeParser = _interopRequireDefault(require("filesize-parser"));
|
|
10
9
|
var _config2 = _interopRequireDefault(require("../config"));
|
|
11
10
|
var _ = _interopRequireDefault(require("../"));
|
|
12
11
|
var _utils = require("../utils");
|
|
@@ -24,16 +23,7 @@ const validateBool = option => val => {
|
|
|
24
23
|
}
|
|
25
24
|
return val.toLowerCase();
|
|
26
25
|
};
|
|
27
|
-
const validateCodeHardeningThreshold =
|
|
28
|
-
let inBytes;
|
|
29
|
-
try {
|
|
30
|
-
inBytes = (0, _filesizeParser.default)(val);
|
|
31
|
-
} catch (e) {
|
|
32
|
-
console.error('*code-hardening-threshold* requires a valid <threshold> value. Format: {number}{unit="b,kb,mb"}. Example: --code-hardening-threshold 200kb');
|
|
33
|
-
process.exit(1);
|
|
34
|
-
}
|
|
35
|
-
return inBytes;
|
|
36
|
-
};
|
|
26
|
+
const validateCodeHardeningThreshold = (0, _utils.validateThresholdFn)('code-hardening-threshold');
|
|
37
27
|
const validateProfilingDataMode = mode => {
|
|
38
28
|
const availableModes = ['automatic', 'annotations', 'off'];
|
|
39
29
|
const normalizedMode = mode.toLowerCase();
|
package/dist/index.js
CHANGED
|
@@ -92,6 +92,18 @@ function normalizeParameters(parameters) {
|
|
|
92
92
|
} else {
|
|
93
93
|
result = parameters;
|
|
94
94
|
}
|
|
95
|
+
const validateFileSizeThreshold = (0, _utils.validateThresholdFn)('fileSizeThreshold');
|
|
96
|
+
result.filter(_ref => {
|
|
97
|
+
let {
|
|
98
|
+
fileSizeThreshold
|
|
99
|
+
} = _ref;
|
|
100
|
+
return typeof fileSizeThreshold === 'string';
|
|
101
|
+
}).forEach(parameter => {
|
|
102
|
+
// change from "1kb" to 1024 bytes
|
|
103
|
+
|
|
104
|
+
// eslint-disable-next-line no-param-reassign
|
|
105
|
+
parameter.fileSizeThreshold = validateFileSizeThreshold(parameter.fileSizeThreshold);
|
|
106
|
+
});
|
|
95
107
|
return result;
|
|
96
108
|
}
|
|
97
109
|
function buildFinalConfig(configPathOrObject) {
|
|
@@ -117,7 +129,7 @@ var _default = exports.default = {
|
|
|
117
129
|
* }} opts
|
|
118
130
|
* @returns {Promise<{extension: string, filename: string, content: *}>}
|
|
119
131
|
*/
|
|
120
|
-
async updateApplicationSources(client, applicationId,
|
|
132
|
+
async updateApplicationSources(client, applicationId, _ref2) {
|
|
121
133
|
let {
|
|
122
134
|
sources,
|
|
123
135
|
filesSrc,
|
|
@@ -125,7 +137,7 @@ var _default = exports.default = {
|
|
|
125
137
|
appProfiling,
|
|
126
138
|
saveSrc = true,
|
|
127
139
|
runBeforeProtection = []
|
|
128
|
-
} =
|
|
140
|
+
} = _ref2;
|
|
129
141
|
if (sources || filesSrc && filesSrc.length) {
|
|
130
142
|
// prevent removing sources if profiling state is READY
|
|
131
143
|
if (appProfiling && appProfiling.data && appProfiling.data.state === 'READY') {
|
|
@@ -404,10 +416,10 @@ var _default = exports.default = {
|
|
|
404
416
|
}
|
|
405
417
|
const createApplicationProtectionRes = await this.createApplicationProtections(client, applicationId, protectionOptions);
|
|
406
418
|
errorHandler(createApplicationProtectionRes);
|
|
407
|
-
const protectionIds = createApplicationProtectionRes.data.protections.map(
|
|
419
|
+
const protectionIds = createApplicationProtectionRes.data.protections.map(_ref3 => {
|
|
408
420
|
let {
|
|
409
421
|
_id
|
|
410
|
-
} =
|
|
422
|
+
} = _ref3;
|
|
411
423
|
return _id;
|
|
412
424
|
});
|
|
413
425
|
const onExitCancelProtection = async () => {
|
|
@@ -855,26 +867,26 @@ var _default = exports.default = {
|
|
|
855
867
|
console.log('Error polling protection', applicationProtections.errors);
|
|
856
868
|
throw new Error("Protection failed. For more information visit: ".concat(APP_URL, "."));
|
|
857
869
|
} else {
|
|
858
|
-
const ended = applicationProtections.data.applicationProtections.filter(
|
|
870
|
+
const ended = applicationProtections.data.applicationProtections.filter(_ref4 => {
|
|
859
871
|
let {
|
|
860
872
|
state
|
|
861
|
-
} =
|
|
873
|
+
} = _ref4;
|
|
862
874
|
return state === 'finished' || state === 'errored' || state === 'canceled';
|
|
863
875
|
});
|
|
864
876
|
// print progress
|
|
865
|
-
ended.filter(
|
|
877
|
+
ended.filter(_ref5 => {
|
|
866
878
|
let {
|
|
867
879
|
_id,
|
|
868
880
|
state
|
|
869
|
-
} =
|
|
881
|
+
} = _ref5;
|
|
870
882
|
return !seen[_id] && state !== 'canceled';
|
|
871
|
-
}).forEach(
|
|
883
|
+
}).forEach(_ref6 => {
|
|
872
884
|
let {
|
|
873
885
|
_id,
|
|
874
886
|
startedAt,
|
|
875
887
|
finishedAt,
|
|
876
888
|
state
|
|
877
|
-
} =
|
|
889
|
+
} = _ref6;
|
|
878
890
|
seen[_id] = true;
|
|
879
891
|
console.log("[".concat(Object.keys(seen).length, "/").concat(protectionIds.length, "] Protection=").concat(_id, ", state=").concat(state, ", build-time=").concat(Math.round((new Date(finishedAt) - new Date(startedAt)) / 1000), "s"));
|
|
880
892
|
});
|
|
@@ -1145,10 +1157,10 @@ var _default = exports.default = {
|
|
|
1145
1157
|
clientId
|
|
1146
1158
|
});
|
|
1147
1159
|
const appSource = await (0, _getProtectionDefaultFragments.getIntrospection)(client, 'ApplicationSource');
|
|
1148
|
-
if (!appSource.fields.some(
|
|
1160
|
+
if (!appSource.fields.some(_ref7 => {
|
|
1149
1161
|
let {
|
|
1150
1162
|
name
|
|
1151
|
-
} =
|
|
1163
|
+
} = _ref7;
|
|
1152
1164
|
return name === 'transformedContentHash';
|
|
1153
1165
|
})) {
|
|
1154
1166
|
console.error("\"Protection report\" it's only available on Jscrambler version 8.4 and above.");
|
package/dist/utils.js
CHANGED
|
@@ -8,9 +8,11 @@ exports.concatenate = concatenate;
|
|
|
8
8
|
exports.getMatchedFiles = getMatchedFiles;
|
|
9
9
|
exports.isJavascriptFile = isJavascriptFile;
|
|
10
10
|
exports.validateNProtections = validateNProtections;
|
|
11
|
+
exports.validateThresholdFn = void 0;
|
|
11
12
|
var _glob = require("glob");
|
|
12
13
|
var _fs = _interopRequireDefault(require("fs"));
|
|
13
14
|
var _path = require("path");
|
|
15
|
+
var _filesizeParser = _interopRequireDefault(require("filesize-parser"));
|
|
14
16
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
17
|
/**
|
|
16
18
|
* Return the list of matched files for minimatch patterns.
|
|
@@ -75,7 +77,7 @@ function concatenate(scriptObject, cwd, path, buffer) {
|
|
|
75
77
|
if (!_fs.default.existsSync(source)) {
|
|
76
78
|
throw new Error('Provided script file does not exist');
|
|
77
79
|
}
|
|
78
|
-
const fileContent =
|
|
80
|
+
const fileContent = buffer.toString('utf-8');
|
|
79
81
|
const scriptContent = _fs.default.readFileSync(source);
|
|
80
82
|
const concatContent = type === APPEND_JS_TYPE ? handleScriptConcatenation(fileContent, scriptContent) : handleScriptConcatenation(scriptContent, fileContent);
|
|
81
83
|
buffer = Buffer.from(concatContent, 'utf-8');
|
|
@@ -86,4 +88,15 @@ function isJavascriptFile(filename) {
|
|
|
86
88
|
const fileExtension = (0, _path.extname)(filename);
|
|
87
89
|
const validJsFileExtensions = ['.js', '.mjs', '.cjs'];
|
|
88
90
|
return validJsFileExtensions.includes(fileExtension);
|
|
89
|
-
}
|
|
91
|
+
}
|
|
92
|
+
const validateThresholdFn = optionName => val => {
|
|
93
|
+
let inBytes;
|
|
94
|
+
try {
|
|
95
|
+
inBytes = (0, _filesizeParser.default)(val);
|
|
96
|
+
} catch (e) {
|
|
97
|
+
console.error("*".concat(optionName, "* requires a valid <threshold> value. Format: {number}{unit=\"b,kb,mb\"}. Example: 200kb"));
|
|
98
|
+
process.exit(1);
|
|
99
|
+
}
|
|
100
|
+
return inBytes;
|
|
101
|
+
};
|
|
102
|
+
exports.validateThresholdFn = validateThresholdFn;
|
package/dist/zip.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.unzip = unzip;
|
|
7
7
|
exports.zip = zip;
|
|
8
8
|
exports.zipSources = zipSources;
|
|
9
|
+
require("core-js/modules/es.array.reverse.js");
|
|
9
10
|
require("core-js/modules/es.regexp.exec.js");
|
|
10
11
|
require("core-js/modules/web.dom-collections.iterator.js");
|
|
11
12
|
var _lodash = _interopRequireDefault(require("lodash.size"));
|
|
@@ -66,8 +67,8 @@ async function zip(files, cwd, runBeforeProtection) {
|
|
|
66
67
|
} else {
|
|
67
68
|
name = files[i];
|
|
68
69
|
}
|
|
69
|
-
buffer = fs.readFile(sPath);
|
|
70
|
-
runBeforeProtection.map(element => {
|
|
70
|
+
buffer = await fs.readFile(sPath);
|
|
71
|
+
runBeforeProtection.reverse().map(element => {
|
|
71
72
|
buffer = (0, _utils.concatenate)(element, cwd, sPath, buffer);
|
|
72
73
|
});
|
|
73
74
|
} else {
|
package/package.json
CHANGED