jscrambler 8.11.3 → 8.12.0-next.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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # jscrambler
2
2
 
3
+ ## 8.12.0-next.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [83c2f6f]: Added suport for new code hardening
8
+
3
9
  ## 8.11.3
4
10
 
5
11
  ### Patch Changes
@@ -198,6 +198,12 @@ try {
198
198
  console.error(err.message);
199
199
  process.exit(1);
200
200
  }
201
+ try {
202
+ config.codeHardening = (0, _utils.validateCodeHardening)(config.codeHardening);
203
+ } catch (err) {
204
+ console.error(err.message);
205
+ process.exit(1);
206
+ }
201
207
  // Merge file config with CLI `--custom-label` flags (CLI wins on duplicate keys)
202
208
  config.customLabels = _objectSpread(_objectSpread({}, config.customLabels), _commander.default.customLabel || {});
203
209
  if (Object.keys(config.customLabels).length === 0) {
@@ -290,6 +296,7 @@ const {
290
296
  debugMode,
291
297
  proxy,
292
298
  codeHardeningThreshold,
299
+ codeHardening,
293
300
  useProfilingData,
294
301
  profilingDataMode,
295
302
  browsers,
@@ -436,6 +443,7 @@ if (_commander.default.balance) {
436
443
  tolerateMinification,
437
444
  debugMode,
438
445
  codeHardeningThreshold,
446
+ codeHardening,
439
447
  useProfilingData,
440
448
  profilingDataMode,
441
449
  browsers,
@@ -19,6 +19,6 @@ function cleanupInputFields(args, fragments) {
19
19
  console.warn("Warning: This API Version does not support the '".concat(field, "' argument."));
20
20
  }
21
21
  }
22
- ['tolerateMinification', 'useProfilingData', 'useAppClassification', 'inputSymbolTable', 'entryPoint', 'ensureCodeAnnotation', 'generateAlias', 'customLabels'].forEach(fieldCleanUp);
22
+ ['tolerateMinification', 'useProfilingData', 'useAppClassification', 'inputSymbolTable', 'entryPoint', 'ensureCodeAnnotation', 'generateAlias', 'customLabels', 'codeHardening'].forEach(fieldCleanUp);
23
23
  return [options, cleanedUpFragments];
24
24
  }
package/dist/index.js CHANGED
@@ -274,6 +274,7 @@ var _default = exports.default = {
274
274
  clientId,
275
275
  tolerateMinification,
276
276
  codeHardeningThreshold,
277
+ codeHardening,
277
278
  useProfilingData,
278
279
  browsers,
279
280
  useAppClassification,
@@ -329,6 +330,7 @@ var _default = exports.default = {
329
330
  if (!filesDest && !destCallback) {
330
331
  throw new Error('Required *filesDest* not provided');
331
332
  }
333
+ const normalizedCodeHardening = (0, _utils.validateCodeHardening)(codeHardening);
332
334
  let source;
333
335
  if (!skipSources) {
334
336
  const appProfiling = await this.getApplicationProfiling(client, applicationId).catch(e => {
@@ -368,6 +370,9 @@ var _default = exports.default = {
368
370
  tolerateMinification,
369
371
  codeHardeningThreshold
370
372
  };
373
+ if (typeof normalizedCodeHardening !== 'undefined') {
374
+ updateData.codeHardening = normalizedCodeHardening;
375
+ }
371
376
  if (params && Object.keys(params).length) {
372
377
  updateData.parameters = normalizeParameters(params);
373
378
  updateData.areSubscribersOrdered = Array.isArray(params);
package/dist/utils.js CHANGED
@@ -8,6 +8,7 @@ exports.concatenate = concatenate;
8
8
  exports.getMatchedFiles = getMatchedFiles;
9
9
  exports.isJavascriptFile = isJavascriptFile;
10
10
  exports.resolveOutputPath = resolveOutputPath;
11
+ exports.validateCodeHardening = validateCodeHardening;
11
12
  exports.validateCustomLabels = validateCustomLabels;
12
13
  exports.validateNProtections = validateNProtections;
13
14
  exports.validateThresholdFn = void 0;
@@ -17,6 +18,11 @@ var _fs = _interopRequireDefault(require("fs"));
17
18
  var _path = require("path");
18
19
  var _filesizeParser = _interopRequireDefault(require("filesize-parser"));
19
20
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
21
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
22
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
23
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
24
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
25
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
20
26
  /**
21
27
  * Return the list of matched files for minimatch patterns.
22
28
  * @param {string} pattern
@@ -71,6 +77,22 @@ function validateCustomLabels(customLabels) {
71
77
  }
72
78
  return out;
73
79
  }
80
+
81
+ /**
82
+ * Validate protection `codeHardening` is a plain object; API validates contents.
83
+ * @param {*} codeHardening From config or programmatic options.
84
+ * @returns {object|undefined} A shallow copy when valid; `undefined` when omitted.
85
+ * @throws {Error} If `codeHardening` is present but not a plain object.
86
+ */
87
+ function validateCodeHardening(codeHardening) {
88
+ if (typeof codeHardening === 'undefined') {
89
+ return undefined;
90
+ }
91
+ if (codeHardening === null || typeof codeHardening !== 'object' || Array.isArray(codeHardening)) {
92
+ throw new Error('Invalid *codeHardening*: expected a plain object.');
93
+ }
94
+ return _objectSpread({}, codeHardening);
95
+ }
74
96
  const APPEND_JS_TYPE = exports.APPEND_JS_TYPE = 'append-js';
75
97
  const PREPEND_JS_TYPE = exports.PREPEND_JS_TYPE = 'prepend-js';
76
98
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "jscrambler",
3
3
  "description": "Jscrambler Code Integrity API client.",
4
- "version": "8.11.3",
4
+ "version": "8.12.0-next.0",
5
5
  "homepage": "https://github.com/jscrambler/jscrambler",
6
6
  "author": "Jscrambler <support@jscrambler.com>",
7
7
  "repository": {