jscrambler 5.5.34 → 6.0.4

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/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
 
@@ -9,10 +9,6 @@ var _lodash = require('lodash.defaults');
9
9
 
10
10
  var _lodash2 = _interopRequireDefault(_lodash);
11
11
 
12
- var _glob = require('glob');
13
-
14
- var _glob2 = _interopRequireDefault(_glob);
15
-
16
12
  var _path = require('path');
17
13
 
18
14
  var _path2 = _interopRequireDefault(_path);
@@ -31,6 +27,8 @@ var _2 = _interopRequireDefault(_);
31
27
 
32
28
  var _cli = require('../cli');
33
29
 
30
+ var _utils = require('../utils');
31
+
34
32
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
35
33
 
36
34
  function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
@@ -171,7 +169,9 @@ if (_commander2.default.args.length > 0) {
171
169
  }
172
170
 
173
171
  if (globSrc && globSrc.length) {
174
- filesSrc = [];
172
+ // this will be translated to real files in the updateApplicationSources method
173
+ filesSrc = globSrc;
174
+ var nSources = 0;
175
175
  // Iterate `globSrc` to build a list of source files into `filesSrc`
176
176
  for (var i = 0, l = globSrc.length; i < l; i += 1) {
177
177
  // Calling sync `glob` because async is pointless for the CLI use case
@@ -183,9 +183,7 @@ if (globSrc && globSrc.length) {
183
183
  process.exit(1);
184
184
  }
185
185
 
186
- var tmpGlob = _glob2.default.sync(globSrc[i], {
187
- dot: true
188
- });
186
+ var tmpGlob = (0, _utils.getMatchedFiles)(globSrc[i]);
189
187
 
190
188
  if (config.werror && tmpGlob.length === 0) {
191
189
  console.error('Pattern "' + globSrc[i] + '" doesn\'t match any files.');
@@ -202,9 +200,9 @@ if (globSrc && globSrc.length) {
202
200
  });
203
201
  }
204
202
  }
205
- filesSrc = filesSrc.concat(tmpGlob);
203
+ nSources += tmpGlob.length;
206
204
  }
207
- if (filesSrc.length === 0) {
205
+ if (nSources === 0) {
208
206
  console.error('No files matched.');
209
207
  process.exit(1);
210
208
  }
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"); } }
@@ -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