jscrambler 8.0.0 → 9.0.0-alpha.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 +17 -0
- package/dist/index.js +2 -2
- package/dist/mutations.js +2 -27
- package/dist/utils.js +3 -4
- package/dist/zip.js +59 -63
- package/package.json +1 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# jscrambler
|
|
2
2
|
|
|
3
|
+
## 9.0.0-alpha.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [20aa311]: Remove reference to unnecessary lib fs-extra in cli.
|
|
8
|
+
This library was making it harder than necessary to use this package in non-node contexts, but
|
|
9
|
+
removing it was a breaking change since it was unnecessarily exported in one of the files.
|
|
10
|
+
Since we're doing a breaking change anyway, this is a good opportunity to get rid of it.
|
|
11
|
+
This is only a breaking change for libraries that were importing sub-files from `jscrambler` directly.
|
|
12
|
+
- [21f7b05]: Make CLI compatible with newer API, drop compatibility with older ones.
|
|
13
|
+
|
|
14
|
+
## 8.0.1
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- [56e65d9]: Added async behaviour to delete protection on success.
|
|
19
|
+
|
|
3
20
|
## 8.0.0
|
|
4
21
|
|
|
5
22
|
### Major Changes
|
package/dist/index.js
CHANGED
|
@@ -482,7 +482,7 @@ var _default = exports.default = {
|
|
|
482
482
|
|
|
483
483
|
// change this to have the variable that checks if the protection is to be removed
|
|
484
484
|
if (deleteProtectionOnSuccess) {
|
|
485
|
-
_this.removeProtection(client, protection._id, applicationId).then(() => {
|
|
485
|
+
await _this.removeProtection(client, protection._id, applicationId).then(() => {
|
|
486
486
|
if (debug) {
|
|
487
487
|
console.log('Protection has been successful and will now be deleted');
|
|
488
488
|
}
|
|
@@ -756,7 +756,7 @@ var _default = exports.default = {
|
|
|
756
756
|
if (typeof destCallback === 'function') {
|
|
757
757
|
destCallback(download, filesDest);
|
|
758
758
|
} else {
|
|
759
|
-
|
|
759
|
+
await _promises.default.writeFile(_path.default.join(filesDest, "".concat(protectionId, "_symbolTable.json")), download);
|
|
760
760
|
}
|
|
761
761
|
},
|
|
762
762
|
/**
|
package/dist/mutations.js
CHANGED
|
@@ -178,36 +178,11 @@ function createApplicationProtection(applicationId) {
|
|
|
178
178
|
let fragments = _fragments;
|
|
179
179
|
let options = _options;
|
|
180
180
|
[options, fragments] = (0, _cleanupInputFields.default)(args, fragments, options);
|
|
181
|
-
if (!args.some(f => f.name === 'options')) {
|
|
182
|
-
const {
|
|
183
|
-
bail,
|
|
184
|
-
randomizationSeed
|
|
185
|
-
} = options;
|
|
186
|
-
return {
|
|
187
|
-
query: "\n mutation ".concat(mutationName, " ($applicationId: String!, $bail: Boolean, $randomizationSeed: String) {\n ").concat(mutationName, " (applicationId: $applicationId, bail: $bail, randomizationSeed: $randomizationSeed) {\n ").concat(fragments, "\n }\n }\n "),
|
|
188
|
-
params: {
|
|
189
|
-
applicationId,
|
|
190
|
-
bail,
|
|
191
|
-
randomizationSeed
|
|
192
|
-
}
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
// Check if createApplicationProtection supports "data" argument
|
|
197
|
-
if (args.some(arg => arg.name === 'data')) {
|
|
198
|
-
return {
|
|
199
|
-
query: "\n mutation ".concat(mutationName, " ($applicationId: String!, $data: ").concat(mutationInputType, ") {\n ").concat(mutationName, " (applicationId: $applicationId, data: $data) {\n ").concat(fragments, "\n }\n }\n "),
|
|
200
|
-
params: {
|
|
201
|
-
applicationId,
|
|
202
|
-
data: options
|
|
203
|
-
}
|
|
204
|
-
};
|
|
205
|
-
}
|
|
206
181
|
return {
|
|
207
|
-
query: "\n mutation ".concat(mutationName, " ($applicationId: String!, $
|
|
182
|
+
query: "\n mutation ".concat(mutationName, " ($applicationId: String!, $data: ").concat(mutationInputType, ") {\n ").concat(mutationName, " (applicationId: $applicationId, data: $data) {\n ").concat(fragments, "\n }\n }\n "),
|
|
208
183
|
params: {
|
|
209
184
|
applicationId,
|
|
210
|
-
options
|
|
185
|
+
data: options
|
|
211
186
|
}
|
|
212
187
|
};
|
|
213
188
|
}
|
package/dist/utils.js
CHANGED
|
@@ -10,7 +10,6 @@ exports.isJavascriptFile = isJavascriptFile;
|
|
|
10
10
|
exports.validateNProtections = validateNProtections;
|
|
11
11
|
var _glob = _interopRequireDefault(require("glob"));
|
|
12
12
|
var _fs = _interopRequireDefault(require("fs"));
|
|
13
|
-
var _fsExtra = require("fs-extra");
|
|
14
13
|
var _path = require("path");
|
|
15
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
15
|
/**
|
|
@@ -76,11 +75,11 @@ function concatenate(scriptObject, cwd, path, buffer) {
|
|
|
76
75
|
source,
|
|
77
76
|
type
|
|
78
77
|
} = scriptObject;
|
|
79
|
-
if (!
|
|
78
|
+
if (!_fs.default.existsSync(source)) {
|
|
80
79
|
throw new Error('Provided script file does not exist');
|
|
81
80
|
}
|
|
82
|
-
const fileContent =
|
|
83
|
-
const scriptContent =
|
|
81
|
+
const fileContent = _fs.default.readFileSync(target);
|
|
82
|
+
const scriptContent = _fs.default.readFileSync(source);
|
|
84
83
|
const concatContent = type === APPEND_JS_TYPE ? handleScriptConcatenation(fileContent, scriptContent) : handleScriptConcatenation(scriptContent, fileContent);
|
|
85
84
|
buffer = Buffer.from(concatContent, 'utf-8');
|
|
86
85
|
}
|
package/dist/zip.js
CHANGED
|
@@ -3,35 +3,25 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
Object.defineProperty(exports, "outputFileSync", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _fsExtra.outputFileSync;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
6
|
exports.unzip = unzip;
|
|
13
7
|
exports.zip = zip;
|
|
14
8
|
exports.zipSources = zipSources;
|
|
15
9
|
require("core-js/modules/es.regexp.exec.js");
|
|
16
10
|
require("core-js/modules/web.dom-collections.iterator.js");
|
|
17
11
|
var _lodash = _interopRequireDefault(require("lodash.size"));
|
|
18
|
-
var _temp = _interopRequireDefault(require("temp"));
|
|
19
12
|
var _jszip = _interopRequireDefault(require("jszip"));
|
|
20
|
-
var
|
|
13
|
+
var fs = _interopRequireWildcard(require("fs/promises"));
|
|
21
14
|
var _path2 = require("path");
|
|
22
|
-
var _q = require("q");
|
|
23
15
|
var _util = require("util");
|
|
24
16
|
var _utils = require("./utils");
|
|
17
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
18
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
25
19
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
26
20
|
// TODO Replace `sync` functions with async versions
|
|
27
21
|
|
|
28
22
|
const debug = !!process.env.DEBUG;
|
|
29
|
-
|
|
30
|
-
// ./zip.js module is excluded from browser-like environments. We take advantage of that here.
|
|
31
|
-
|
|
32
23
|
async function zip(files, cwd, runBeforeProtection) {
|
|
33
24
|
debug && console.log('Zipping files', (0, _util.inspect)(files));
|
|
34
|
-
const deferred = (0, _q.defer)();
|
|
35
25
|
// Flag to detect if any file was added to the zip archive
|
|
36
26
|
let hasFiles = false;
|
|
37
27
|
// Sanitize `cwd`
|
|
@@ -41,61 +31,58 @@ async function zip(files, cwd, runBeforeProtection) {
|
|
|
41
31
|
// If it's already a zip file
|
|
42
32
|
if (files.length === 1 && /^.*\.zip$/.test(files[0])) {
|
|
43
33
|
hasFiles = true;
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
files[i] = (0, _path2.resolve)(files[i]);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
// Bypass unwanted patterns from `files`
|
|
59
|
-
if (/.*\.(git|hg)(\/.*|$)/.test(files[i].path || files[i])) {
|
|
60
|
-
continue;
|
|
61
|
-
}
|
|
62
|
-
let buffer, name;
|
|
63
|
-
let sPath;
|
|
64
|
-
if (cwd && files[i].indexOf && files[i].indexOf(cwd) !== 0) {
|
|
65
|
-
sPath = (0, _path2.join)(cwd, files[i]);
|
|
66
|
-
} else {
|
|
67
|
-
sPath = files[i];
|
|
34
|
+
const zipFile = new _jszip.default();
|
|
35
|
+
const zipFileData = await fs.readFile(files[0]);
|
|
36
|
+
return await zipFile.loadAsync(zipFileData);
|
|
37
|
+
}
|
|
38
|
+
const zipFile = new _jszip.default();
|
|
39
|
+
for (let i = 0, l = files.length; i < l; ++i) {
|
|
40
|
+
// Sanitise path
|
|
41
|
+
if (typeof files[i] === 'string') {
|
|
42
|
+
files[i] = (0, _path2.normalize)(files[i]);
|
|
43
|
+
if (files[i].indexOf('../') === 0) {
|
|
44
|
+
files[i] = (0, _path2.resolve)(files[i]);
|
|
68
45
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
46
|
+
}
|
|
47
|
+
// Bypass unwanted patterns from `files`
|
|
48
|
+
if (/.*\.(git|hg)(\/.*|$)/.test(files[i].path || files[i])) {
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
let buffer, name;
|
|
52
|
+
let sPath;
|
|
53
|
+
if (cwd && files[i].indexOf && files[i].indexOf(cwd) !== 0) {
|
|
54
|
+
sPath = (0, _path2.join)(cwd, files[i]);
|
|
55
|
+
} else {
|
|
56
|
+
sPath = files[i];
|
|
57
|
+
}
|
|
58
|
+
// If buffer
|
|
59
|
+
if (files[i].contents) {
|
|
60
|
+
name = (0, _path2.relative)(files[i].cwd, files[i].path);
|
|
61
|
+
buffer = files[i].contents;
|
|
62
|
+
} else if (!(await fs.stat(sPath)).isDirectory()) {
|
|
63
|
+
// Else if it's a path and not a directory
|
|
64
|
+
if (cwd && files[i].indexOf && files[i].indexOf(cwd) === 0) {
|
|
65
|
+
name = files[i].substring(cwd.length);
|
|
84
66
|
} else {
|
|
85
|
-
|
|
86
|
-
zip.folder(sPath);
|
|
87
|
-
}
|
|
88
|
-
if (name) {
|
|
89
|
-
hasFiles = true;
|
|
90
|
-
zip.file(name, buffer);
|
|
67
|
+
name = files[i];
|
|
91
68
|
}
|
|
69
|
+
buffer = fs.readFile(sPath);
|
|
70
|
+
runBeforeProtection.map(element => {
|
|
71
|
+
buffer = (0, _utils.concatenate)(element, cwd, sPath, buffer);
|
|
72
|
+
});
|
|
73
|
+
} else {
|
|
74
|
+
// Else if it's a directory path
|
|
75
|
+
zipFile.folder(sPath);
|
|
92
76
|
}
|
|
93
|
-
if (
|
|
94
|
-
|
|
77
|
+
if (name) {
|
|
78
|
+
hasFiles = true;
|
|
79
|
+
zipFile.file(name, buffer);
|
|
95
80
|
}
|
|
96
|
-
deferred.resolve(zip);
|
|
97
81
|
}
|
|
98
|
-
|
|
82
|
+
if (!hasFiles) {
|
|
83
|
+
throw new Error('No source files found. If you intend to send a whole directory sufix your path with "**" (e.g. ./my-directory/**)');
|
|
84
|
+
}
|
|
85
|
+
return zipFile;
|
|
99
86
|
}
|
|
100
87
|
function zipSources(sources) {
|
|
101
88
|
const zipFile = new _jszip.default();
|
|
@@ -124,6 +111,8 @@ async function unzip(zipFile, dest) {
|
|
|
124
111
|
await zip.loadAsync(zipFile);
|
|
125
112
|
const _size = (0, _lodash.default)(zip.files);
|
|
126
113
|
const results = [];
|
|
114
|
+
|
|
115
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
127
116
|
for (const file in zip.files) {
|
|
128
117
|
if (!zip.files[file].dir) {
|
|
129
118
|
const buffer = await zip.file(file).async('nodebuffer');
|
|
@@ -141,15 +130,22 @@ async function unzip(zipFile, dest) {
|
|
|
141
130
|
const lastDestChar = dest[dest.length - 1];
|
|
142
131
|
if (_size === 1 && lastDestChar !== '/' && lastDestChar !== '\\') {
|
|
143
132
|
destPath = dest;
|
|
133
|
+
const parentPath = (0, _path2.dirname)(destPath);
|
|
134
|
+
await fs.mkdir(parentPath, {
|
|
135
|
+
recursive: true
|
|
136
|
+
});
|
|
144
137
|
} else {
|
|
145
138
|
let _file = file;
|
|
146
139
|
// Deal with win path join c:\dest\:c\src
|
|
147
140
|
if (isWinAbsolutePath(_file)) {
|
|
148
141
|
_file = parseWinAbsolutePath(_file).path;
|
|
149
142
|
}
|
|
143
|
+
await fs.mkdir(dest, {
|
|
144
|
+
recursive: true
|
|
145
|
+
});
|
|
150
146
|
destPath = (0, _path2.join)(dest, _file);
|
|
151
147
|
}
|
|
152
|
-
|
|
148
|
+
await fs.outputFile(destPath, buffer);
|
|
153
149
|
}
|
|
154
150
|
}
|
|
155
151
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jscrambler",
|
|
3
3
|
"description": "Jscrambler API client.",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "9.0.0-alpha.0",
|
|
5
5
|
"homepage": "https://github.com/jscrambler/jscrambler",
|
|
6
6
|
"author": "Jscrambler <support@jscrambler.com>",
|
|
7
7
|
"repository": {
|
|
@@ -26,7 +26,6 @@
|
|
|
26
26
|
"commander": "^2.8.1",
|
|
27
27
|
"core-js": "^3.16.4",
|
|
28
28
|
"filesize-parser": "1.5.0",
|
|
29
|
-
"fs-extra": "^10.1.0",
|
|
30
29
|
"glob": "^8.1.0",
|
|
31
30
|
"http-proxy-agent": "^4.0.1",
|
|
32
31
|
"jszip": "^3.7.1",
|