jscrambler 8.1.0 → 9.0.0-alpha.1
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/dist/index.js +1 -1
- package/dist/mutations.js +2 -27
- package/dist/utils.js +3 -4
- package/dist/zip.js +59 -63
- package/package.json +13 -14
- package/LICENSE +0 -22
package/dist/index.js
CHANGED
|
@@ -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.writeFile(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.1",
|
|
5
5
|
"homepage": "https://github.com/jscrambler/jscrambler",
|
|
6
6
|
"author": "Jscrambler <support@jscrambler.com>",
|
|
7
7
|
"repository": {
|
|
@@ -17,8 +17,16 @@
|
|
|
17
17
|
"access": "public",
|
|
18
18
|
"registry": "https://registry.npmjs.org/"
|
|
19
19
|
},
|
|
20
|
+
"scripts": {
|
|
21
|
+
"clean": "rm -rf ./dist",
|
|
22
|
+
"build": "babel src --out-dir dist",
|
|
23
|
+
"watch": "babel -w src --out-dir dist",
|
|
24
|
+
"prepublish": "npm run build",
|
|
25
|
+
"eslint": "eslint src/",
|
|
26
|
+
"eslint:fix": "eslint src/ --fix"
|
|
27
|
+
},
|
|
20
28
|
"engines": {
|
|
21
|
-
"node": ">=
|
|
29
|
+
"node": ">= 12.17.0"
|
|
22
30
|
},
|
|
23
31
|
"dependencies": {
|
|
24
32
|
"@jscrambler/https-proxy-agent": "^5.0.1",
|
|
@@ -26,7 +34,6 @@
|
|
|
26
34
|
"commander": "^2.8.1",
|
|
27
35
|
"core-js": "^3.16.4",
|
|
28
36
|
"filesize-parser": "1.5.0",
|
|
29
|
-
"fs-extra": "^10.1.0",
|
|
30
37
|
"glob": "^8.1.0",
|
|
31
38
|
"http-proxy-agent": "^4.0.1",
|
|
32
39
|
"jszip": "^3.7.1",
|
|
@@ -49,7 +56,7 @@
|
|
|
49
56
|
"dist",
|
|
50
57
|
"CHANGELOG.md"
|
|
51
58
|
],
|
|
52
|
-
"
|
|
59
|
+
"exports": "./dist/index.js",
|
|
53
60
|
"bin": {
|
|
54
61
|
"jscrambler": "dist/bin/jscrambler.js"
|
|
55
62
|
},
|
|
@@ -60,13 +67,5 @@
|
|
|
60
67
|
"protect",
|
|
61
68
|
"js",
|
|
62
69
|
"javascript"
|
|
63
|
-
]
|
|
64
|
-
|
|
65
|
-
"clean": "rm -rf ./dist",
|
|
66
|
-
"build": "babel src --out-dir dist",
|
|
67
|
-
"watch": "babel -w src --out-dir dist",
|
|
68
|
-
"prepublish": "npm run build",
|
|
69
|
-
"eslint": "eslint src/",
|
|
70
|
-
"eslint:fix": "eslint src/ --fix"
|
|
71
|
-
}
|
|
72
|
-
}
|
|
70
|
+
]
|
|
71
|
+
}
|
package/LICENSE
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
Copyright (c) 2014 Jscrambler
|
|
2
|
-
|
|
3
|
-
Permission is hereby granted, free of charge, to any person
|
|
4
|
-
obtaining a copy of this software and associated documentation
|
|
5
|
-
files (the "Software"), to deal in the Software without
|
|
6
|
-
restriction, including without limitation the rights to use,
|
|
7
|
-
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
-
copies of the Software, and to permit persons to whom the
|
|
9
|
-
Software is furnished to do so, subject to the following
|
|
10
|
-
conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be
|
|
13
|
-
included in all copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
16
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
17
|
-
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
18
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
19
|
-
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
20
|
-
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
21
|
-
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
22
|
-
OTHER DEALINGS IN THE SOFTWARE.
|