jscrambler 8.8.5 → 8.9.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 +12 -0
- package/dist/bin/jscrambler.js +16 -2
- package/dist/index.js +58 -24
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# jscrambler
|
|
2
2
|
|
|
3
|
+
## 8.9.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [f1f886e]: Option to retrieve the balance of the user
|
|
8
|
+
|
|
9
|
+
## 8.8.6
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [8818c8e]: Use max/min file size instead ao file size threshold
|
|
14
|
+
|
|
3
15
|
## 8.8.5
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/bin/jscrambler.js
CHANGED
|
@@ -106,7 +106,7 @@ const validateBeforeProtection = function () {
|
|
|
106
106
|
});
|
|
107
107
|
return beforeProtectionArray;
|
|
108
108
|
};
|
|
109
|
-
_commander.default.version(require('../../package.json').version).usage('[options] <file ...>').option('-a, --access-key <accessKey>', 'Access key').option('-c, --config <config>', 'Jscrambler configuration options').option('-H, --host <host>', 'Hostname').option('-i, --application-id <id>', 'Application ID').option('-o, --output-dir <dir>', 'Output directory').option('-p, --port <port>', 'Port').option('--base-path <path>', 'Base Path').option('--protocol <protocol>', 'Protocol (http or https)').option('--cafile <path>', 'Internal certificate authority').option('-C, --cwd <dir>', 'Current Working Directory').option('-s, --secret-key <secretKey>', 'Secret key').option('-m, --source-maps <id>', 'Download source maps').option('-R, --randomization-seed <seed>', 'Set randomization seed').option('--instrument', 'Instrument file(s) before start profiling. ATTENTION: previous profiling information will be deleted').option('--start-profiling', 'Starts profiling (assumes an already instrumented application)').option('--stop-profiling', 'Stops profiling').option('--code-hardening-threshold <threshold>', 'Set code hardening file size threshold. Format: {value}{unit="b,kb,mb"}. Example: 200kb', validateCodeHardeningThreshold).option('--recommended-order <bool>', 'Use recommended order', validateBool('recommended-order')).option('-W, --werror <bool>', 'Set werror flag value (default: true)', validateBool('werror')).option('--utc <bool>', 'Set UTC as the request time zone. Otherwise it uses the local time zone (default: true)', validateBool('utc')).option('--tolerate-minification <bool>', "Don't detect minification as malicious tampering (default: true)", validateBool('tolerate-minification')).option('--use-profiling-data <bool>', "(version 6.2 only) Protection should use the existing profiling data (default: true)", validateBool('use-profiling-data')).option('--profiling-data-mode <mode>', "(version 6.3 and above) Select profiling mode (default: automatic)", validateProfilingDataMode).option('--remove-profiling-data', "Removes the current application profiling information").option('--use-app-classification <bool>', '(version 6.3 and above) Protection should use Application Classification metadata when protecting (default: true)', validateBool('--use-app-classification')).option('--input-symbol-table <file>', '(version 6.3 and above) Protection should use symbol table when protecting. (default: no file)').option('--output-symbol-table <id>', '(version 6.3 and above) Download output symbol table (json)').option('--jscramblerVersion <version>', 'Use a specific Jscrambler version').option('--debugMode', 'Protect in debug mode').option('--skip-sources', 'Prevent source files from being updated').option('--force-app-environment <environment>', "(version 7.1 and above) Override application's environment detected automatically. Possible values: ".concat(availableEnvironments.toString()), validateForceAppEnvironment).option('--ensure-code-annotation <bool>', "(version 7.3 and above) Fail protection if no annotations are found on the source code (default: false)", validateBool('ensure-code-annotation')).option('-n <number>', "(version 7.2 and above) Create multiple protections at once.").option('--delete-protection-on-success <bool>', 'Deletes the protection files after they have been protected and downloaded (default: false)', validateBool('--delete-protection-on-success')).option('--mode <mode>', "(version 8.4 and above) Define protection mode. Possible values: automatic, manual (default: manual)", validateMode).option('--save-src <bool>', 'Protection should save application sources (default: true)', validateBool('--save-src')).option('--protection-report <string>', '(version 8.4 and above) Protection id for the metadata report').parse(process.argv);
|
|
109
|
+
_commander.default.version(require('../../package.json').version).usage('[options] <file ...>').option('-a, --access-key <accessKey>', 'Access key').option('-c, --config <config>', 'Jscrambler configuration options').option('-H, --host <host>', 'Hostname').option('-i, --application-id <id>', 'Application ID').option('-o, --output-dir <dir>', 'Output directory').option('-p, --port <port>', 'Port').option('--base-path <path>', 'Base Path').option('--protocol <protocol>', 'Protocol (http or https)').option('--cafile <path>', 'Internal certificate authority').option('-C, --cwd <dir>', 'Current Working Directory').option('-s, --secret-key <secretKey>', 'Secret key').option('-m, --source-maps <id>', 'Download source maps').option('-R, --randomization-seed <seed>', 'Set randomization seed').option('--instrument', 'Instrument file(s) before start profiling. ATTENTION: previous profiling information will be deleted').option('--start-profiling', 'Starts profiling (assumes an already instrumented application)').option('--stop-profiling', 'Stops profiling').option('--code-hardening-threshold <threshold>', 'Set code hardening file size threshold. Format: {value}{unit="b,kb,mb"}. Example: 200kb', validateCodeHardeningThreshold).option('--recommended-order <bool>', 'Use recommended order', validateBool('recommended-order')).option('-W, --werror <bool>', 'Set werror flag value (default: true)', validateBool('werror')).option('--utc <bool>', 'Set UTC as the request time zone. Otherwise it uses the local time zone (default: true)', validateBool('utc')).option('--tolerate-minification <bool>', "Don't detect minification as malicious tampering (default: true)", validateBool('tolerate-minification')).option('--use-profiling-data <bool>', "(version 6.2 only) Protection should use the existing profiling data (default: true)", validateBool('use-profiling-data')).option('--profiling-data-mode <mode>', "(version 6.3 and above) Select profiling mode (default: automatic)", validateProfilingDataMode).option('--remove-profiling-data', "Removes the current application profiling information").option('--use-app-classification <bool>', '(version 6.3 and above) Protection should use Application Classification metadata when protecting (default: true)', validateBool('--use-app-classification')).option('--input-symbol-table <file>', '(version 6.3 and above) Protection should use symbol table when protecting. (default: no file)').option('--output-symbol-table <id>', '(version 6.3 and above) Download output symbol table (json)').option('--jscramblerVersion <version>', 'Use a specific Jscrambler version').option('--debugMode', 'Protect in debug mode').option('--skip-sources', 'Prevent source files from being updated').option('--force-app-environment <environment>', "(version 7.1 and above) Override application's environment detected automatically. Possible values: ".concat(availableEnvironments.toString()), validateForceAppEnvironment).option('--ensure-code-annotation <bool>', "(version 7.3 and above) Fail protection if no annotations are found on the source code (default: false)", validateBool('ensure-code-annotation')).option('-n <number>', "(version 7.2 and above) Create multiple protections at once.").option('--delete-protection-on-success <bool>', 'Deletes the protection files after they have been protected and downloaded (default: false)', validateBool('--delete-protection-on-success')).option('--mode <mode>', "(version 8.4 and above) Define protection mode. Possible values: automatic, manual (default: manual)", validateMode).option('--save-src <bool>', 'Protection should save application sources (default: true)', validateBool('--save-src')).option('--protection-report <string>', '(version 8.4 and above) Protection id for the metadata report').option('--balance', '(version 8.4 and above) Gets the balance of the user').parse(process.argv);
|
|
110
110
|
let globSrc, filesSrc, config;
|
|
111
111
|
|
|
112
112
|
// If -c, --config file was provided
|
|
@@ -307,7 +307,21 @@ const clientSettings = {
|
|
|
307
307
|
utc,
|
|
308
308
|
jscramblerVersion
|
|
309
309
|
};
|
|
310
|
-
if (_commander.default.
|
|
310
|
+
if (_commander.default.balance) {
|
|
311
|
+
(async () => {
|
|
312
|
+
try {
|
|
313
|
+
await _.default.getBalance(clientSettings);
|
|
314
|
+
process.exit(0);
|
|
315
|
+
} catch (error) {
|
|
316
|
+
if (error.statusCode === 404) {
|
|
317
|
+
console.error('Not found: Ensure you are using version 8.4 or above.');
|
|
318
|
+
} else {
|
|
319
|
+
console.error(debug ? error : error.message || error);
|
|
320
|
+
}
|
|
321
|
+
process.exit(1);
|
|
322
|
+
}
|
|
323
|
+
})();
|
|
324
|
+
} else if (_commander.default.sourceMaps) {
|
|
311
325
|
// Go, go, go download
|
|
312
326
|
(async () => {
|
|
313
327
|
try {
|
package/dist/index.js
CHANGED
|
@@ -79,6 +79,15 @@ function printSourcesErrors(errors) {
|
|
|
79
79
|
}
|
|
80
80
|
console.error();
|
|
81
81
|
}
|
|
82
|
+
function normalizeFileSizeFilter(parameters, fileSizeOption) {
|
|
83
|
+
const validateFileSizeThreshold = (0, _utils.validateThresholdFn)(fileSizeOption);
|
|
84
|
+
parameters.filter(parameter => typeof parameter[fileSizeOption] === 'string').forEach(parameter => {
|
|
85
|
+
// change from "1kb" to 1024 bytes
|
|
86
|
+
|
|
87
|
+
// eslint-disable-next-line no-param-reassign
|
|
88
|
+
parameter[fileSizeOption] = validateFileSizeThreshold(parameter[fileSizeOption]);
|
|
89
|
+
});
|
|
90
|
+
}
|
|
82
91
|
function normalizeParameters(parameters) {
|
|
83
92
|
let result;
|
|
84
93
|
if (!Array.isArray(parameters)) {
|
|
@@ -92,18 +101,8 @@ function normalizeParameters(parameters) {
|
|
|
92
101
|
} else {
|
|
93
102
|
result = parameters;
|
|
94
103
|
}
|
|
95
|
-
|
|
96
|
-
result
|
|
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
|
-
});
|
|
104
|
+
normalizeFileSizeFilter(result, 'minFileSize');
|
|
105
|
+
normalizeFileSizeFilter(result, 'maxFileSize');
|
|
107
106
|
return result;
|
|
108
107
|
}
|
|
109
108
|
function buildFinalConfig(configPathOrObject) {
|
|
@@ -129,7 +128,7 @@ var _default = exports.default = {
|
|
|
129
128
|
* }} opts
|
|
130
129
|
* @returns {Promise<{extension: string, filename: string, content: *}>}
|
|
131
130
|
*/
|
|
132
|
-
async updateApplicationSources(client, applicationId,
|
|
131
|
+
async updateApplicationSources(client, applicationId, _ref) {
|
|
133
132
|
let {
|
|
134
133
|
sources,
|
|
135
134
|
filesSrc,
|
|
@@ -137,7 +136,7 @@ var _default = exports.default = {
|
|
|
137
136
|
appProfiling,
|
|
138
137
|
saveSrc = true,
|
|
139
138
|
runBeforeProtection = []
|
|
140
|
-
} =
|
|
139
|
+
} = _ref;
|
|
141
140
|
if (sources || filesSrc && filesSrc.length) {
|
|
142
141
|
// prevent removing sources if profiling state is READY
|
|
143
142
|
if (appProfiling && appProfiling.data && appProfiling.data.state === 'READY') {
|
|
@@ -416,10 +415,10 @@ var _default = exports.default = {
|
|
|
416
415
|
}
|
|
417
416
|
const createApplicationProtectionRes = await this.createApplicationProtections(client, applicationId, protectionOptions);
|
|
418
417
|
errorHandler(createApplicationProtectionRes);
|
|
419
|
-
const protectionIds = createApplicationProtectionRes.data.protections.map(
|
|
418
|
+
const protectionIds = createApplicationProtectionRes.data.protections.map(_ref2 => {
|
|
420
419
|
let {
|
|
421
420
|
_id
|
|
422
|
-
} =
|
|
421
|
+
} = _ref2;
|
|
423
422
|
return _id;
|
|
424
423
|
});
|
|
425
424
|
const onExitCancelProtection = async () => {
|
|
@@ -867,26 +866,26 @@ var _default = exports.default = {
|
|
|
867
866
|
console.log('Error polling protection', applicationProtections.errors);
|
|
868
867
|
throw new Error("Protection failed. For more information visit: ".concat(APP_URL, "."));
|
|
869
868
|
} else {
|
|
870
|
-
const ended = applicationProtections.data.applicationProtections.filter(
|
|
869
|
+
const ended = applicationProtections.data.applicationProtections.filter(_ref3 => {
|
|
871
870
|
let {
|
|
872
871
|
state
|
|
873
|
-
} =
|
|
872
|
+
} = _ref3;
|
|
874
873
|
return state === 'finished' || state === 'errored' || state === 'canceled';
|
|
875
874
|
});
|
|
876
875
|
// print progress
|
|
877
|
-
ended.filter(
|
|
876
|
+
ended.filter(_ref4 => {
|
|
878
877
|
let {
|
|
879
878
|
_id,
|
|
880
879
|
state
|
|
881
|
-
} =
|
|
880
|
+
} = _ref4;
|
|
882
881
|
return !seen[_id] && state !== 'canceled';
|
|
883
|
-
}).forEach(
|
|
882
|
+
}).forEach(_ref5 => {
|
|
884
883
|
let {
|
|
885
884
|
_id,
|
|
886
885
|
startedAt,
|
|
887
886
|
finishedAt,
|
|
888
887
|
state
|
|
889
|
-
} =
|
|
888
|
+
} = _ref5;
|
|
890
889
|
seen[_id] = true;
|
|
891
890
|
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"));
|
|
892
891
|
});
|
|
@@ -1157,10 +1156,10 @@ var _default = exports.default = {
|
|
|
1157
1156
|
clientId
|
|
1158
1157
|
});
|
|
1159
1158
|
const appSource = await (0, _getProtectionDefaultFragments.getIntrospection)(client, 'ApplicationSource');
|
|
1160
|
-
if (!appSource.fields.some(
|
|
1159
|
+
if (!appSource.fields.some(_ref6 => {
|
|
1161
1160
|
let {
|
|
1162
1161
|
name
|
|
1163
|
-
} =
|
|
1162
|
+
} = _ref6;
|
|
1164
1163
|
return name === 'transformedContentHash';
|
|
1165
1164
|
})) {
|
|
1166
1165
|
console.error("\"Protection report\" it's only available on Jscrambler version 8.4 and above.");
|
|
@@ -1200,6 +1199,41 @@ var _default = exports.default = {
|
|
|
1200
1199
|
} else {
|
|
1201
1200
|
console.log(metadataJson);
|
|
1202
1201
|
}
|
|
1202
|
+
},
|
|
1203
|
+
async getBalance(conf) {
|
|
1204
|
+
const finalConfig = buildFinalConfig(conf);
|
|
1205
|
+
const {
|
|
1206
|
+
host,
|
|
1207
|
+
port,
|
|
1208
|
+
basePath,
|
|
1209
|
+
protocol,
|
|
1210
|
+
cafile,
|
|
1211
|
+
keys,
|
|
1212
|
+
jscramblerVersion,
|
|
1213
|
+
proxy,
|
|
1214
|
+
utc,
|
|
1215
|
+
clientId
|
|
1216
|
+
} = finalConfig;
|
|
1217
|
+
const {
|
|
1218
|
+
accessKey,
|
|
1219
|
+
secretKey
|
|
1220
|
+
} = keys;
|
|
1221
|
+
const client = new this.Client({
|
|
1222
|
+
accessKey,
|
|
1223
|
+
secretKey,
|
|
1224
|
+
host,
|
|
1225
|
+
port,
|
|
1226
|
+
basePath,
|
|
1227
|
+
protocol,
|
|
1228
|
+
cafile,
|
|
1229
|
+
jscramblerVersion,
|
|
1230
|
+
proxy,
|
|
1231
|
+
utc,
|
|
1232
|
+
clientId
|
|
1233
|
+
});
|
|
1234
|
+
const balance = await client.get('/balance');
|
|
1235
|
+
console.log(balance);
|
|
1236
|
+
return balance;
|
|
1203
1237
|
}
|
|
1204
1238
|
};
|
|
1205
1239
|
function getFileFromUrl(client, url) {
|
package/package.json
CHANGED