jscrambler 8.7.0 → 8.7.1-next.0
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 +6 -0
- package/README.md +4 -0
- package/dist/bin/jscrambler.js +69 -38
- package/dist/index.js +1 -1
- package/dist/licenses.txt +1921 -0
- package/dist/utils.js +73 -1
- package/dist/webpack-attach-disable-annotations.js +40 -0
- package/dist/zip.js +10 -2
- package/package.json +14 -11
- package/LICENSE +0 -22
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -354,6 +354,10 @@ The concatenation of files can result in max file size errors - even though the
|
|
|
354
354
|
"type": "prepend-js",
|
|
355
355
|
"target": "/path/to/target/file.js",
|
|
356
356
|
"source": "/path/to/script/file.js"
|
|
357
|
+
},
|
|
358
|
+
{
|
|
359
|
+
"type": "webpack-ignore-vendors",
|
|
360
|
+
"report": "/path/to/webpack/stats.json"
|
|
357
361
|
}
|
|
358
362
|
]
|
|
359
363
|
}
|
package/dist/bin/jscrambler.js
CHANGED
|
@@ -10,6 +10,7 @@ var _filesizeParser = _interopRequireDefault(require("filesize-parser"));
|
|
|
10
10
|
var _config2 = _interopRequireDefault(require("../config"));
|
|
11
11
|
var _ = _interopRequireDefault(require("../"));
|
|
12
12
|
var _utils = require("../utils");
|
|
13
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
13
14
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
15
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
15
16
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -66,53 +67,83 @@ const validateBeforeProtection = function () {
|
|
|
66
67
|
if (beforeProtectionArray.length === 0) {
|
|
67
68
|
return;
|
|
68
69
|
}
|
|
69
|
-
const mandatoryKeys = ['type', 'target', 'source'];
|
|
70
|
-
const usedTargets = new Set();
|
|
71
|
-
const usedSources = new Set();
|
|
72
70
|
beforeProtectionArray.filter(element => {
|
|
73
|
-
// Check if every array element has a type, a target and a source
|
|
74
|
-
const validateMandatoryKeys = mandatoryKeys.every(key => key in element);
|
|
75
|
-
if (!validateMandatoryKeys) {
|
|
76
|
-
console.error('Invalid structure on beforeProtection: each element must have the following structure { type: "type", target: "/path/to/target", source: "/path/to/script"}');
|
|
77
|
-
process.exit(1);
|
|
78
|
-
}
|
|
79
71
|
const {
|
|
80
|
-
target,
|
|
81
|
-
source,
|
|
82
72
|
type
|
|
83
73
|
} = element;
|
|
74
|
+
switch (type) {
|
|
75
|
+
case _utils.APPEND_JS_TYPE:
|
|
76
|
+
case _utils.PREPEND_JS_TYPE:
|
|
77
|
+
const mandatoryKeys = ['type', 'target', 'source'];
|
|
78
|
+
const usedTargets = new Set();
|
|
79
|
+
const usedSources = new Set();
|
|
84
80
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
81
|
+
// Check if every array element has a type, a target and a source
|
|
82
|
+
const validateMandatoryKeys = mandatoryKeys.every(key => key in element);
|
|
83
|
+
if (!validateMandatoryKeys) {
|
|
84
|
+
console.error('Invalid structure on beforeProtection: each element must have the following structure { type: "type", target: "/path/to/target", source: "/path/to/script"}');
|
|
85
|
+
process.exit(1);
|
|
86
|
+
}
|
|
87
|
+
const {
|
|
88
|
+
target,
|
|
89
|
+
source
|
|
90
|
+
} = element;
|
|
90
91
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
92
|
+
// Check if the provided files are js, mjs or cjs files
|
|
93
|
+
if (!(0, _utils.isJavascriptFile)(target) || !(0, _utils.isJavascriptFile)(source)) {
|
|
94
|
+
console.error("Invalid extension for beforeProtection (".concat(type, ") target or source files: only *js, mjs and cjs* files can be used to append or prepend."));
|
|
95
|
+
process.exit(1);
|
|
96
|
+
}
|
|
96
97
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
98
|
+
// Check if the target has already been used as a source
|
|
99
|
+
if (usedTargets.has(source)) {
|
|
100
|
+
console.error("Error on beforeProtection (".concat(type, "): file \"").concat(source, "\" has already been used as target and can't be used as source."));
|
|
101
|
+
process.exit(1);
|
|
102
|
+
}
|
|
103
|
+
if (usedSources.has(target)) {
|
|
104
|
+
console.error("Error on beforeProtection (".concat(type, "): file \"").concat(target, "\" has already been used as source and can't be used as target."));
|
|
105
|
+
process.exit(1);
|
|
106
|
+
}
|
|
106
107
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
108
|
+
// Check if the target and source are the same
|
|
109
|
+
if (target === source) {
|
|
110
|
+
console.error("Error on beforeProtection (".concat(type, "): File \"").concat(target, "\" can't be used as both a target and a source."));
|
|
111
|
+
process.exit(1);
|
|
112
|
+
}
|
|
112
113
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
114
|
+
// Add the target and the source to the corresponding sets
|
|
115
|
+
usedTargets.add(target);
|
|
116
|
+
usedSources.add(source);
|
|
117
|
+
break;
|
|
118
|
+
case _utils.WEBPACK_IGNORE_VENDORS:
|
|
119
|
+
if (!("report" in element)) {
|
|
120
|
+
console.error("Invalid structure on beforeProtection (".concat(type, "): \"report\" property is mandatory for this type"));
|
|
121
|
+
process.exit(1);
|
|
122
|
+
}
|
|
123
|
+
if (!_fs.default.existsSync(element.report)) {
|
|
124
|
+
console.error("Error on beforeProtection (".concat(type, "): source webpack report does not exist."));
|
|
125
|
+
process.exit(1);
|
|
126
|
+
}
|
|
127
|
+
const content = _fs.default.readFileSync(element.report, 'utf8');
|
|
128
|
+
let report;
|
|
129
|
+
try {
|
|
130
|
+
report = JSON.parse(content);
|
|
131
|
+
} catch (e) {
|
|
132
|
+
console.error("Error on beforeProtection (".concat(type, "): invalid source webpack report. Reason: ").concat(e.message));
|
|
133
|
+
process.exit(1);
|
|
134
|
+
}
|
|
135
|
+
element.excludeModules = new Map();
|
|
136
|
+
for (let module of report.modules) {
|
|
137
|
+
if (module.name && module.name.includes('/node_modules/')) {
|
|
138
|
+
element.excludeModules.set(module.id, module.name);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
console.log("beforeProtection (".concat(type, "): Webpack report \"").concat(_path.default.basename(element.report), "\" was loaded"));
|
|
142
|
+
break;
|
|
143
|
+
default:
|
|
144
|
+
console.error("Invalid type on beforeProtection (".concat(type, "): only \"").concat(_utils.APPEND_JS_TYPE, "\", \"").concat(_utils.PREPEND_JS_TYPE, "\" or \"").concat(_utils.WEBPACK_IGNORE_VENDORS, "\" are allowed."));
|
|
145
|
+
process.exit(1);
|
|
146
|
+
}
|
|
116
147
|
});
|
|
117
148
|
return beforeProtectionArray;
|
|
118
149
|
};
|
package/dist/index.js
CHANGED
|
@@ -150,7 +150,7 @@ var _default = exports.default = {
|
|
|
150
150
|
}
|
|
151
151
|
if (runBeforeProtection.length > 0) {
|
|
152
152
|
runBeforeProtection.map(element => {
|
|
153
|
-
if (!_filesSrc.includes(element.target)) {
|
|
153
|
+
if ((element.type === _utils.PREPEND_JS_TYPE || element.type === _utils.APPEND_JS_TYPE) && !_filesSrc.includes(element.target)) {
|
|
154
154
|
console.error('Error on beforeProtection: Target files need to be in the files to protect list (or filesSrc).');
|
|
155
155
|
process.exit(1);
|
|
156
156
|
}
|