jscrambler 5.5.35 → 6.1.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/LICENSE-MIT CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2014 magalhas
1
+ Copyright (c) 2014 Jscrambler
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person
4
4
  obtaining a copy of this software and associated documentation
package/README.md CHANGED
@@ -2,6 +2,7 @@
2
2
  Jscrambler Client for Browser and Node.js
3
3
 
4
4
  - [Jscrambler](https://jscrambler.com/?utm_source=github.com&utm_medium=referral)
5
+ - [Version Compatibility](#version-compatibility)
5
6
  - [Installation](#installation)
6
7
  - [RC configuration](#rc-configuration)
7
8
  - [CLI](#cli)
@@ -22,6 +23,16 @@ Jscrambler Client for Browser and Node.js
22
23
  - [Quick example](#quick-example)
23
24
  - [Jscrambler Parameters](#jscrambler-parameters)
24
25
 
26
+ ## Version Compatibility
27
+
28
+ The version's compatibility table match your [Jscrambler Version](https://app.jscrambler.com/settings) with the Jscrambler Client.
29
+ Please make sure you install the right version, otherwise some functionalities might not work properly.
30
+
31
+ | _Jscrambler Version_ | _Client and Integrations_ |
32
+ |:----------:|:-------------:|
33
+ | _<= 7.1_ | _<= 5.x.x_ |
34
+ | _\>= 7.2_ | _\>= 6.0.0_ |
35
+
25
36
  ## Installation
26
37
 
27
38
  On your project:
@@ -36,6 +47,12 @@ Or globally:
36
47
  npm i -g jscrambler
37
48
  ```
38
49
 
50
+ Or a specific version:
51
+
52
+ ```js
53
+ npm i jscrambler@5
54
+ ```
55
+
39
56
  ## RC configuration
40
57
  You may put your access and secret keys into a config file if found in [these directories](https://github.com/dominictarr/rc#standards). Besides simplifying the command entry, this has the added benefit of not logging your Jscrambler credentials.
41
58
 
@@ -112,6 +129,7 @@ Options:
112
129
  --debugMode Protect in debug mode
113
130
  --skip-sources Prevent source files from being updated
114
131
  --force-app-environment <environment> (version 7.1 and above) Override application's environment detected automatically. Possible values: node,browser,isomorphic,automatic
132
+ -n <number> (version 7.2 and above) Create multiple protections at once.
115
133
  -h, --help output usage information
116
134
  ```
117
135
 
@@ -80,7 +80,7 @@ var validateForceAppEnvironment = function validateForceAppEnvironment(env) {
80
80
  return normalizeEnvironment;
81
81
  };
82
82
 
83
- _commander2.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: ' + availableEnvironments.toString(), validateForceAppEnvironment).parse(process.argv);
83
+ _commander2.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: ' + availableEnvironments.toString(), validateForceAppEnvironment).option('-n <number>', '(version 7.2 and above) Create multiple protections at once.').parse(process.argv);
84
84
 
85
85
  var globSrc = void 0,
86
86
  filesSrc = void 0,
@@ -154,6 +154,8 @@ if (_commander2.default.forceAppEnvironment) {
154
154
 
155
155
  config = (0, _lodash2.default)(config, _config4.default);
156
156
 
157
+ config.numberOfProtections = (0, _utils.validateNProtections)(_commander2.default.N);
158
+
157
159
  if (config.codeHardeningThreshold) {
158
160
  config.codeHardeningThreshold = validateCodeHardeningThreshold(config.codeHardeningThreshold);
159
161
  }
@@ -244,6 +246,7 @@ var _config2 = config,
244
246
  utc = _config2.utc,
245
247
  entryPoint = _config2.entryPoint,
246
248
  excludeList = _config2.excludeList,
249
+ numberOfProtections = _config2.numberOfProtections,
247
250
  forceAppEnvironment = _config2.forceAppEnvironment;
248
251
 
249
252
 
@@ -421,6 +424,7 @@ if (_commander2.default.sourceMaps) {
421
424
  inputSymbolTable: inputSymbolTable,
422
425
  entryPoint: entryPoint,
423
426
  excludeList: excludeList,
427
+ numberOfProtections: numberOfProtections,
424
428
  forceAppEnvironment: forceAppEnvironment
425
429
  });
426
430
  _context3.prev = 1;
package/dist/cli.js CHANGED
@@ -50,7 +50,7 @@ var isBoolFlag = {
50
50
  preserveAnnotations: true
51
51
  };
52
52
 
53
- // Convert from command line option format to JScrambler API format.
53
+ // Convert from command line option format to Jscrambler API format.
54
54
  function mergeAndParseParams(commander, params) {
55
55
  var finalParams = (0, _lodash2.default)(params || {});
56
56
 
package/dist/client.js CHANGED
@@ -46,6 +46,10 @@ var _generateSignedParams = require('./generate-signed-params');
46
46
 
47
47
  var _generateSignedParams2 = _interopRequireDefault(_generateSignedParams);
48
48
 
49
+ var _constants = require('./constants');
50
+
51
+ var _package = require('../package.json');
52
+
49
53
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
50
54
 
51
55
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@@ -80,7 +84,7 @@ var ClientError = function (_Error) {
80
84
  * @param {String} [options.port=443]
81
85
  * @param {String} [options.basePath]
82
86
  * @param {String} [options.clientId=0]
83
- * @author José Magalhães (magalhas@gmail.com)
87
+ * @author Jscrambler
84
88
  * @license MIT <http://opensource.org/licenses/MIT>
85
89
  */
86
90
 
@@ -140,6 +144,8 @@ JScramblerClient.prototype.get = function (path, params) {
140
144
  * @param {Callback} callback
141
145
  */
142
146
  JScramblerClient.prototype.request = function (method, path) {
147
+ var _this2 = this;
148
+
143
149
  var params = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
144
150
  var isJSON = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
145
151
 
@@ -284,8 +290,16 @@ JScramblerClient.prototype.request = function (method, path) {
284
290
  errorMessage += err.response.status + ' ' + err.response.statusText;
285
291
  statusCode = err.response.status;
286
292
 
293
+ var incompatibleApi = false;
294
+ if (statusCode === _constants.HTTP_STATUS_CODES.UNAUTHORIZED) {
295
+ incompatibleApi = err.response.data.errorCode !== _constants.JSCRAMBLER_ERROR_CODES.INVALID_SIGNATURE;
296
+ }
297
+
298
+ if (incompatibleApi) {
299
+ errorMessage = 'Incompatible jscrambler CLI version (' + _package.version + '). Please downgrade to: \n\t$ npm install ' + _constants.CLIENT_PACKAGES[_this2.options.clientId] + '@5';
300
+ } else if (
287
301
  // For when we have API error messages
288
- if (err.response.data && err.response.data.error && err.response.data.message) {
302
+ err.response.data && err.response.data.error && err.response.data.message) {
289
303
  errorMessage += ' - ' + err.response.data.message;
290
304
  } else if (err.response.data && err.response.data.errors && err.response.data.errors.length > 0) {
291
305
  errorMessage += ' - ' + err.response.data.errors;
package/dist/config.js CHANGED
@@ -8,6 +8,8 @@ var _rc = require('rc');
8
8
 
9
9
  var _rc2 = _interopRequireDefault(_rc);
10
10
 
11
+ var _constants = require('./constants');
12
+
11
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
14
 
13
15
  // Load RC configuration if present. Pass `[]` as last argument to avoid
@@ -18,7 +20,7 @@ var config = (0, _rc2.default)('jscrambler', {
18
20
  basePath: '',
19
21
  jscramblerVersion: 'stable',
20
22
  werror: true,
21
- clientId: 0,
23
+ clientId: _constants.CLIENT_IDS.CLI,
22
24
  utc: true,
23
25
  maxRetries: 5
24
26
  }, []);
package/dist/constants.js CHANGED
@@ -1,11 +1,33 @@
1
- "use strict";
1
+ 'use strict';
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+
7
+ var _Object$freeze;
8
+
9
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
10
+
6
11
  var HTTP_STATUS_CODES = exports.HTTP_STATUS_CODES = Object.freeze({
12
+ UNAUTHORIZED: 401,
7
13
  FORBIDDEN: 403,
8
14
  NOT_FOUND: 404,
9
15
  SERVICE_UNAVAILABLE: 503,
10
16
  GATEWAY_TIMEOUT: 504
11
- });
17
+ });
18
+
19
+ var JSCRAMBLER_ERROR_CODES = exports.JSCRAMBLER_ERROR_CODES = Object.freeze({
20
+ INVALID_SIGNATURE: '254'
21
+ });
22
+
23
+ var CLIENT_IDS = exports.CLIENT_IDS = Object.freeze({
24
+ CLI: 0,
25
+ APP: 1,
26
+ WEBPACK: 2,
27
+ GULP: 3,
28
+ GRUNT: 4,
29
+ EMBER: 5,
30
+ METRO: 6
31
+ });
32
+
33
+ var CLIENT_PACKAGES = exports.CLIENT_PACKAGES = Object.freeze((_Object$freeze = {}, _defineProperty(_Object$freeze, CLIENT_IDS.CLI, 'jscrambler'), _defineProperty(_Object$freeze, CLIENT_IDS.APP, 'app'), _defineProperty(_Object$freeze, CLIENT_IDS.WEBPACK, 'jscrambler-webpack-plugin'), _defineProperty(_Object$freeze, CLIENT_IDS.GULP, 'gulp-jscrambler'), _defineProperty(_Object$freeze, CLIENT_IDS.GRUNT, 'grunt-jscrambler'), _defineProperty(_Object$freeze, CLIENT_IDS.EMBER, 'ember-cli-jscrambler'), _defineProperty(_Object$freeze, CLIENT_IDS.METRO, 'jscrambler-metro-plugin'), _Object$freeze));
@@ -3,6 +3,9 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+
7
+ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
8
+
6
9
  exports.default = signedParams;
7
10
 
8
11
  var _lodash = require('lodash.clone');
@@ -51,7 +54,8 @@ function buildSortedQuery(params) {
51
54
  var _keys = (0, _lodash6.default)(params).sort();
52
55
  var query = '';
53
56
  for (var i = 0, l = _keys.length; i < l; i++) {
54
- query += encodeURIComponent(_keys[i]) + '=' + encodeURIComponent(params[_keys[i]]) + '&';
57
+ var value = _typeof(params[_keys[i]]) === 'object' ? JSON.stringify(params[_keys[i]]) : params[_keys[i]];
58
+ query += encodeURIComponent(_keys[i]) + '=' + encodeURIComponent(value) + '&';
55
59
  }
56
60
  query = query.replace(/\*/g, '%2A').replace(/[!'()]/g, escape).replace(/%7E/g, '~').replace(/\+/g, '%20');
57
61
  // Strip the last separator and return
@@ -92,6 +92,8 @@ var protectionFields = {
92
92
  growthWarning: 1,
93
93
  errorMessage: 1,
94
94
  size: 1,
95
+ startedAt: 1,
96
+ finishedAt: 1,
95
97
  transformedSize: 1
96
98
  };
97
99