jscrambler 8.6.6 → 8.7.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 +2 -0
- package/dist/bin/jscrambler.js +10 -1
- package/dist/get-protection-default-fragments.js +1 -0
- package/dist/index.js +80 -2
- package/dist/queries.js +8 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -135,6 +135,8 @@ Options:
|
|
|
135
135
|
-n <number> (version 7.2 and above) Create multiple protections at once.
|
|
136
136
|
--delete-protection-on-success <bool> Deletes the protection files after they have been protected and downloaded (default: false)
|
|
137
137
|
--mode <mode> (version 8.4 and above) Define protection mode. Possible values: automatic, manual (default: manual)
|
|
138
|
+
--save-src <bool> Protection should save application sources (default: true)
|
|
139
|
+
--protection-report <string> (version 8.4 and above) Protection id for the metadata report
|
|
138
140
|
-h, --help output usage information
|
|
139
141
|
```
|
|
140
142
|
|
package/dist/bin/jscrambler.js
CHANGED
|
@@ -116,7 +116,7 @@ const validateBeforeProtection = function () {
|
|
|
116
116
|
});
|
|
117
117
|
return beforeProtectionArray;
|
|
118
118
|
};
|
|
119
|
-
_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')).parse(process.argv);
|
|
119
|
+
_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);
|
|
120
120
|
let globSrc, filesSrc, config;
|
|
121
121
|
|
|
122
122
|
// If -c, --config file was provided
|
|
@@ -368,6 +368,15 @@ if (_commander.default.sourceMaps) {
|
|
|
368
368
|
console.error(debug ? error : error.message || error);
|
|
369
369
|
process.exit(1);
|
|
370
370
|
});
|
|
371
|
+
} else if (_commander.default.protectionReport) {
|
|
372
|
+
(async () => {
|
|
373
|
+
try {
|
|
374
|
+
await _.default.getProtectionMetadata(clientSettings, _commander.default.protectionReport, _commander.default.outputDir);
|
|
375
|
+
} catch (error) {
|
|
376
|
+
console.error(debug ? error : error.message || error);
|
|
377
|
+
process.exit(1);
|
|
378
|
+
}
|
|
379
|
+
})();
|
|
371
380
|
} else {
|
|
372
381
|
// Go, go, go
|
|
373
382
|
(async () => {
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = _default;
|
|
8
|
+
exports.getIntrospection = getIntrospection;
|
|
8
9
|
var introspection = _interopRequireWildcard(require("./introspection"));
|
|
9
10
|
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); }
|
|
10
11
|
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 && {}.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; }
|
package/dist/index.js
CHANGED
|
@@ -19,7 +19,7 @@ var _constants = require("./constants");
|
|
|
19
19
|
var _zip = require("./zip");
|
|
20
20
|
var introspection = _interopRequireWildcard(require("./introspection"));
|
|
21
21
|
var _utils = require("./utils");
|
|
22
|
-
var _getProtectionDefaultFragments =
|
|
22
|
+
var _getProtectionDefaultFragments = _interopRequireWildcard(require("./get-protection-default-fragments"));
|
|
23
23
|
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); }
|
|
24
24
|
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 && {}.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
25
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -764,7 +764,7 @@ var _default = exports.default = {
|
|
|
764
764
|
if (typeof destCallback === 'function') {
|
|
765
765
|
destCallback(download, filesDest);
|
|
766
766
|
} else {
|
|
767
|
-
await
|
|
767
|
+
await _fs.default.promises.writeFile(_path.default.join(filesDest, "".concat(protectionId, "_symbolTable.json")), download);
|
|
768
768
|
}
|
|
769
769
|
},
|
|
770
770
|
/**
|
|
@@ -1108,6 +1108,84 @@ var _default = exports.default = {
|
|
|
1108
1108
|
const dataArg = result.args.find(arg => arg.name === 'data');
|
|
1109
1109
|
const isFieldSupported = dataArg && dataArg.type.inputFields.some(e => e.name === field);
|
|
1110
1110
|
return isFieldSupported;
|
|
1111
|
+
},
|
|
1112
|
+
async getProtectionMetadata(conf, protectionId, outputDir) {
|
|
1113
|
+
const INVALID_PARAMETERS = ['original', 'initialCleanup', 'wrapUp'];
|
|
1114
|
+
const finalConfig = buildFinalConfig(conf);
|
|
1115
|
+
const {
|
|
1116
|
+
applicationId,
|
|
1117
|
+
host,
|
|
1118
|
+
port,
|
|
1119
|
+
basePath,
|
|
1120
|
+
protocol,
|
|
1121
|
+
cafile,
|
|
1122
|
+
keys,
|
|
1123
|
+
jscramblerVersion,
|
|
1124
|
+
proxy,
|
|
1125
|
+
utc,
|
|
1126
|
+
clientId
|
|
1127
|
+
} = finalConfig;
|
|
1128
|
+
const {
|
|
1129
|
+
accessKey,
|
|
1130
|
+
secretKey
|
|
1131
|
+
} = keys;
|
|
1132
|
+
const client = new this.Client({
|
|
1133
|
+
accessKey,
|
|
1134
|
+
secretKey,
|
|
1135
|
+
host,
|
|
1136
|
+
port,
|
|
1137
|
+
basePath,
|
|
1138
|
+
protocol,
|
|
1139
|
+
cafile,
|
|
1140
|
+
jscramblerVersion,
|
|
1141
|
+
proxy,
|
|
1142
|
+
utc,
|
|
1143
|
+
clientId
|
|
1144
|
+
});
|
|
1145
|
+
const appSource = await (0, _getProtectionDefaultFragments.getIntrospection)(client, 'ApplicationSource');
|
|
1146
|
+
if (!appSource.fields.some(_ref6 => {
|
|
1147
|
+
let {
|
|
1148
|
+
name
|
|
1149
|
+
} = _ref6;
|
|
1150
|
+
return name === 'transformedContentHash';
|
|
1151
|
+
})) {
|
|
1152
|
+
console.error("\"Protection report\" it's only available on Jscrambler version 8.4 and above.");
|
|
1153
|
+
process.exit(1);
|
|
1154
|
+
}
|
|
1155
|
+
const response = await this.getApplicationProtection(client, applicationId, protectionId, {
|
|
1156
|
+
application: '_id',
|
|
1157
|
+
applicationProtection: '_id, applicationId, parameters, version, areSubscribersOrdered, useRecommendedOrder, tolerateMinification, profilingDataMode, useAppClassification, browsers, sourceMaps, sources { filename, transformedContentHash, metrics { transformation } }'
|
|
1158
|
+
});
|
|
1159
|
+
errorHandler(response);
|
|
1160
|
+
const sourcesInfo = response.data.applicationProtection.sources.map(source => {
|
|
1161
|
+
const parameters = source.metrics.filter(metric => !INVALID_PARAMETERS.includes(metric.transformation));
|
|
1162
|
+
return {
|
|
1163
|
+
filename: source.filename,
|
|
1164
|
+
sha256Checksum: source.transformedContentHash,
|
|
1165
|
+
parameters: parameters.map(param => param.transformation)
|
|
1166
|
+
};
|
|
1167
|
+
});
|
|
1168
|
+
const metadataJson = JSON.stringify({
|
|
1169
|
+
applicationId: response.data.applicationProtection.applicationId,
|
|
1170
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
1171
|
+
protectionId: response.data.applicationProtection._id,
|
|
1172
|
+
jscramblerVersion: response.data.applicationProtection.version,
|
|
1173
|
+
areSubscribersOrdered: response.data.applicationProtection.areSubscribersOrdered,
|
|
1174
|
+
useRecommendedOrder: response.data.applicationProtection.useRecommendedOrder,
|
|
1175
|
+
tolerateMinification: response.data.applicationProtection.tolerateMinification,
|
|
1176
|
+
profilingDataMode: response.data.applicationProtection.profilingDataMode,
|
|
1177
|
+
useAppClassification: response.data.applicationProtection.useAppClassification,
|
|
1178
|
+
browsers: response.data.applicationProtection.browsers,
|
|
1179
|
+
sourceMaps: response.data.applicationProtection.sourceMaps,
|
|
1180
|
+
parameters: response.data.applicationProtection.parameters,
|
|
1181
|
+
sources: sourcesInfo
|
|
1182
|
+
}, null, 2);
|
|
1183
|
+
if (outputDir) {
|
|
1184
|
+
await _fs.default.promises.writeFile(outputDir, metadataJson);
|
|
1185
|
+
console.log("Protection Report ".concat(protectionId, " saved in ").concat(outputDir));
|
|
1186
|
+
} else {
|
|
1187
|
+
console.log(metadataJson);
|
|
1188
|
+
}
|
|
1111
1189
|
}
|
|
1112
1190
|
};
|
|
1113
1191
|
function getFileFromUrl(client, url) {
|
package/dist/queries.js
CHANGED
|
@@ -96,11 +96,14 @@ const getProtectionDefaultFragments = {
|
|
|
96
96
|
};
|
|
97
97
|
function getProtection(applicationId, protectionId) {
|
|
98
98
|
let fragments = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : getProtectionDefaultFragments;
|
|
99
|
+
const params = {
|
|
100
|
+
protectionId
|
|
101
|
+
};
|
|
102
|
+
if (applicationId) {
|
|
103
|
+
params.applicationId = applicationId;
|
|
104
|
+
}
|
|
99
105
|
return {
|
|
100
|
-
query: "\n query getProtection ($applicationId: String!, $protectionId: String!) {\n application (_id: $applicationId) {\n
|
|
101
|
-
params: JSON.stringify(
|
|
102
|
-
applicationId,
|
|
103
|
-
protectionId
|
|
104
|
-
})
|
|
106
|
+
query: "\n query getProtection (".concat(applicationId ? '$applicationId: String!,' : '', "$protectionId: String!) {\n ").concat(applicationId ? "\n application (_id: $applicationId) {\n ".concat(fragments.application, "\n }") : '', "\n applicationProtection (_id: $protectionId) {\n ").concat(fragments.applicationProtection, "\n }\n }\n "),
|
|
107
|
+
params: JSON.stringify(params)
|
|
105
108
|
};
|
|
106
109
|
}
|
package/package.json
CHANGED