jscrambler 8.7.1-next.2 → 8.7.1

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,16 +1,10 @@
1
1
  # jscrambler
2
2
 
3
- ## 8.7.1-next.2
3
+ ## 8.7.1
4
4
 
5
5
  ### Patch Changes
6
6
 
7
- - []: Add filename on webpack-ignore-vendors
8
-
9
- ## 8.7.1-next.1
10
-
11
- ### Patch Changes
12
-
13
- - [ecba0c7]: new beforeProtection type: webpack-ignore-vendors
7
+ - [3ef818f]: Update readme.md
14
8
 
15
9
  ## 8.7.0
16
10
 
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Jscrambler
2
+
3
+ Permission is hereby granted, free of charge, to any person
4
+ obtaining a copy of this software and associated documentation
5
+ files (the "Software"), to deal in the Software without
6
+ restriction, including without limitation the rights to use,
7
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the
9
+ Software is furnished to do so, subject to the following
10
+ conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # [![Jscrambler](https://media.jscrambler.com/images/logo_500px.png)](https://jscrambler.com/?utm_source=github.com&utm_medium=referral)
2
- Jscrambler Client for Browser and Node.js
2
+ Jscrambler Code Integrity Client
3
+ --------------------
4
+
5
+ Jscrambler [Code Integrity](https://jscrambler.com/code-integrity) is a JavaScript protection technology for Web and Mobile Applications. Its main purpose is to enable JavaScript applications to become self-defensive and resilient to tampering and reverse engineering.
6
+
7
+ If you're looking to gain control over third-party tags and achieve PCI DSS compliance please refer to Jscrambler [Webpage Integrity](https://jscrambler.com/webpage-integrity).
8
+
3
9
 
4
10
  - [Jscrambler](https://jscrambler.com/?utm_source=github.com&utm_medium=referral)
5
11
  - [Version Compatibility](#version-compatibility)
@@ -354,10 +360,6 @@ The concatenation of files can result in max file size errors - even though the
354
360
  "type": "prepend-js",
355
361
  "target": "/path/to/target/file.js",
356
362
  "source": "/path/to/script/file.js"
357
- },
358
- {
359
- "type": "webpack-ignore-vendors",
360
- "report": "/path/to/webpack/stats.json"
361
363
  }
362
364
  ]
363
365
  }
@@ -10,7 +10,6 @@ var _filesizeParser = _interopRequireDefault(require("filesize-parser"));
10
10
  var _config2 = _interopRequireDefault(require("../config"));
11
11
  var _ = _interopRequireDefault(require("../"));
12
12
  var _utils = require("../utils");
13
- var _fs = _interopRequireDefault(require("fs"));
14
13
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15
14
  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; }
16
15
  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; }
@@ -67,83 +66,53 @@ const validateBeforeProtection = function () {
67
66
  if (beforeProtectionArray.length === 0) {
68
67
  return;
69
68
  }
69
+ const mandatoryKeys = ['type', 'target', 'source'];
70
+ const usedTargets = new Set();
71
+ const usedSources = new Set();
70
72
  beforeProtectionArray.filter(element => {
73
+ // Check if every array element has a type, a target and a source
74
+ const validateMandatoryKeys = mandatoryKeys.every(key => key in element);
75
+ if (!validateMandatoryKeys) {
76
+ console.error('Invalid structure on beforeProtection: each element must have the following structure { type: "type", target: "/path/to/target", source: "/path/to/script"}');
77
+ process.exit(1);
78
+ }
71
79
  const {
80
+ target,
81
+ source,
72
82
  type
73
83
  } = element;
74
- switch (type) {
75
- case _utils.APPEND_JS_TYPE:
76
- case _utils.PREPEND_JS_TYPE:
77
- const mandatoryKeys = ['type', 'target', 'source'];
78
- const usedTargets = new Set();
79
- const usedSources = new Set();
80
84
 
81
- // Check if every array element has a type, a target and a source
82
- const validateMandatoryKeys = mandatoryKeys.every(key => key in element);
83
- if (!validateMandatoryKeys) {
84
- console.error('Invalid structure on beforeProtection: each element must have the following structure { type: "type", target: "/path/to/target", source: "/path/to/script"}');
85
- process.exit(1);
86
- }
87
- const {
88
- target,
89
- source
90
- } = element;
91
-
92
- // Check if the provided files are js, mjs or cjs files
93
- if (!(0, _utils.isJavascriptFile)(target) || !(0, _utils.isJavascriptFile)(source)) {
94
- console.error("Invalid extension for beforeProtection (".concat(type, ") target or source files: only *js, mjs and cjs* files can be used to append or prepend."));
95
- process.exit(1);
96
- }
85
+ // Check if only valid types are being used
86
+ if (type !== _utils.APPEND_JS_TYPE && type !== _utils.PREPEND_JS_TYPE) {
87
+ console.error("Invalid type on beforeProtection: only \"".concat(_utils.APPEND_JS_TYPE, "\" or \"").concat(_utils.PREPEND_JS_TYPE, "\" are allowed."));
88
+ process.exit(1);
89
+ }
97
90
 
98
- // Check if the target has already been used as a source
99
- if (usedTargets.has(source)) {
100
- console.error("Error on beforeProtection (".concat(type, "): file \"").concat(source, "\" has already been used as target and can't be used as source."));
101
- process.exit(1);
102
- }
103
- if (usedSources.has(target)) {
104
- console.error("Error on beforeProtection (".concat(type, "): file \"").concat(target, "\" has already been used as source and can't be used as target."));
105
- process.exit(1);
106
- }
91
+ // Check if the provided files are js, mjs or cjs files
92
+ if (!(0, _utils.isJavascriptFile)(target) || !(0, _utils.isJavascriptFile)(source)) {
93
+ console.error('Invalid extension for beforeProtection target or source files: only *js, mjs and cjs* files can be used to append or prepend.');
94
+ process.exit(1);
95
+ }
107
96
 
108
- // Check if the target and source are the same
109
- if (target === source) {
110
- console.error("Error on beforeProtection (".concat(type, "): File \"").concat(target, "\" can't be used as both a target and a source."));
111
- process.exit(1);
112
- }
97
+ // Check if the target has already been used as a source
98
+ if (usedTargets.has(source)) {
99
+ console.error("Error on beforeProtection: file \"".concat(source, "\" has already been used as target and can't be used as source."));
100
+ process.exit(1);
101
+ }
102
+ if (usedSources.has(target)) {
103
+ console.error("Error on beforeProtection: file \"".concat(target, "\" has already been used as source and can't be used as target."));
104
+ process.exit(1);
105
+ }
113
106
 
114
- // Add the target and the source to the corresponding sets
115
- usedTargets.add(target);
116
- usedSources.add(source);
117
- break;
118
- case _utils.WEBPACK_IGNORE_VENDORS:
119
- if (!("report" in element)) {
120
- console.error("Invalid structure on beforeProtection (".concat(type, "): \"report\" property is mandatory for this type"));
121
- process.exit(1);
122
- }
123
- if (!_fs.default.existsSync(element.report)) {
124
- console.error("Error on beforeProtection (".concat(type, "): source webpack report does not exist."));
125
- process.exit(1);
126
- }
127
- const content = _fs.default.readFileSync(element.report, 'utf8');
128
- let report;
129
- try {
130
- report = JSON.parse(content);
131
- } catch (e) {
132
- console.error("Error on beforeProtection (".concat(type, "): invalid source webpack report. Reason: ").concat(e.message));
133
- process.exit(1);
134
- }
135
- element.excludeModules = new Map();
136
- for (let module of report.modules) {
137
- if (module.name && module.name.includes('/node_modules/')) {
138
- element.excludeModules.set(module.id, module.name);
139
- }
140
- }
141
- console.log("beforeProtection (".concat(type, "): Webpack report \"").concat(_path.default.basename(element.report), "\" was loaded"));
142
- break;
143
- default:
144
- console.error("Invalid type on beforeProtection (".concat(type, "): only \"").concat(_utils.APPEND_JS_TYPE, "\", \"").concat(_utils.PREPEND_JS_TYPE, "\" or \"").concat(_utils.WEBPACK_IGNORE_VENDORS, "\" are allowed."));
145
- process.exit(1);
107
+ // Check if the target and source are the same
108
+ if (target === source) {
109
+ console.error("Error on beforeProtection: File \"".concat(target, "\" can't be used as both a target and a source."));
110
+ process.exit(1);
146
111
  }
112
+
113
+ // Add the target and the source to the corresponding sets
114
+ usedTargets.add(target);
115
+ usedSources.add(source);
147
116
  });
148
117
  return beforeProtectionArray;
149
118
  };
package/dist/index.js CHANGED
@@ -150,7 +150,7 @@ var _default = exports.default = {
150
150
  }
151
151
  if (runBeforeProtection.length > 0) {
152
152
  runBeforeProtection.map(element => {
153
- if ((element.type === _utils.PREPEND_JS_TYPE || element.type === _utils.APPEND_JS_TYPE) && !_filesSrc.includes(element.target)) {
153
+ if (!_filesSrc.includes(element.target)) {
154
154
  console.error('Error on beforeProtection: Target files need to be in the files to protect list (or filesSrc).');
155
155
  process.exit(1);
156
156
  }
package/dist/utils.js CHANGED
@@ -3,22 +3,15 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.WEBPACK_IGNORE_VENDORS = exports.PREPEND_JS_TYPE = exports.APPEND_JS_TYPE = void 0;
6
+ exports.PREPEND_JS_TYPE = exports.APPEND_JS_TYPE = void 0;
7
7
  exports.concatenate = concatenate;
8
8
  exports.getMatchedFiles = getMatchedFiles;
9
9
  exports.isJavascriptFile = isJavascriptFile;
10
10
  exports.validateNProtections = validateNProtections;
11
- exports.webpackAttachDisableAnnotations = webpackAttachDisableAnnotations;
12
- require("core-js/modules/web.dom-collections.iterator.js");
13
11
  var _glob = require("glob");
14
12
  var _fs = _interopRequireDefault(require("fs"));
15
13
  var _path = require("path");
16
- var _acorn = _interopRequireDefault(require("acorn"));
17
- var _acornWalk = _interopRequireDefault(require("acorn-walk"));
18
- var _magicString = _interopRequireDefault(require("magic-string"));
19
14
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
20
- const debug = !!process.env.DEBUG;
21
-
22
15
  /**
23
16
  * Return the list of matched files for minimatch patterns.
24
17
  * @param {string} pattern
@@ -48,72 +41,6 @@ function validateNProtections(n) {
48
41
  }
49
42
  const APPEND_JS_TYPE = exports.APPEND_JS_TYPE = 'append-js';
50
43
  const PREPEND_JS_TYPE = exports.PREPEND_JS_TYPE = 'prepend-js';
51
- const WEBPACK_IGNORE_VENDORS = exports.WEBPACK_IGNORE_VENDORS = 'webpack-ignore-vendors';
52
-
53
- /**
54
- *
55
- * @param {source: string} beforeProtection
56
- * @param {string} cwd current working directory, passed by argument
57
- * @param {string} path file path (file being parsed)
58
- * @param {Buffer} buffer file contents
59
- * @param {string} fileName file name
60
- */
61
- function webpackAttachDisableAnnotations(beforeProtection, cwd, path, buffer, fileName) {
62
- const {
63
- excludeModules
64
- } = beforeProtection;
65
- const sourceCode = buffer.toString('utf-8');
66
- let tree;
67
- try {
68
- tree = _acorn.default.parse(sourceCode, {
69
- ecmaVersion: 'latest',
70
- range: true
71
- });
72
- } catch (e) {
73
- console.log("Error on beforeProtection (".concat(WEBPACK_IGNORE_VENDORS, "): \"").concat(fileName, "\" could not be parsed."));
74
- process.exit(1);
75
- }
76
- const appendDisableAnnotationAt = [];
77
- _acornWalk.default.recursive(tree, null, {
78
- Property(node) {
79
- if (node.computed === false && node.shorthand === false) {
80
- let moduleId;
81
- if (node.key.type === 'Literal') {
82
- moduleId = node.key.value;
83
- } else if (node.key.type === 'Identifier') {
84
- moduleId = node.key.name;
85
- }
86
- if (moduleId && excludeModules.has(moduleId)) {
87
- appendDisableAnnotationAt.push(node.value.start);
88
- if (debug) {
89
- console.debug("beforeProtection (".concat(WEBPACK_IGNORE_VENDORS, "): ignoring ").concat(excludeModules.get(moduleId), " module on \"").concat(fileName, "\""));
90
- }
91
- return null;
92
- }
93
- }
94
- }
95
- });
96
- if (appendDisableAnnotationAt.length > 0) {
97
- const s = new _magicString.default(sourceCode);
98
- for (const appendIndex of appendDisableAnnotationAt) {
99
- s.appendLeft(appendIndex, '/* @jscrambler disable * */');
100
- }
101
- const sourceCodeWithDisableAnnotations = s.toString();
102
- try {
103
- // syntax check
104
- _acorn.default.parse(sourceCodeWithDisableAnnotations, {
105
- ecmaVersion: 'latest',
106
- range: true
107
- });
108
- } catch (e) {
109
- console.log("Error on beforeProtection (".concat(WEBPACK_IGNORE_VENDORS, "): unsupported structure on \"").concat(fileName, "\"."));
110
- process.exit(1);
111
- }
112
- buffer = Buffer.from(s.toString(), 'utf8');
113
- }
114
- console.log("beforeProtection (".concat(WEBPACK_IGNORE_VENDORS, "): ").concat(appendDisableAnnotationAt.length, " module(s) ignored for \"").concat(fileName, "\""));
115
- return buffer;
116
- }
117
44
 
118
45
  /**
119
46
  *
package/dist/zip.js CHANGED
@@ -66,17 +66,9 @@ async function zip(files, cwd, runBeforeProtection) {
66
66
  } else {
67
67
  name = files[i];
68
68
  }
69
- buffer = await fs.readFile(sPath);
69
+ buffer = fs.readFile(sPath);
70
70
  runBeforeProtection.map(element => {
71
- switch (element.type) {
72
- case _utils.APPEND_JS_TYPE:
73
- case _utils.PREPEND_JS_TYPE:
74
- buffer = (0, _utils.concatenate)(element, cwd, sPath, buffer, name);
75
- break;
76
- case _utils.WEBPACK_IGNORE_VENDORS:
77
- buffer = (0, _utils.webpackAttachDisableAnnotations)(element, cwd, sPath, buffer, name);
78
- break;
79
- }
71
+ buffer = (0, _utils.concatenate)(element, cwd, sPath, buffer);
80
72
  });
81
73
  } else {
82
74
  // Else if it's a directory path
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "jscrambler",
3
- "description": "Jscrambler API client.",
4
- "version": "8.7.1-next.2",
3
+ "description": "Jscrambler Code Integrity API client.",
4
+ "version": "8.7.1",
5
5
  "homepage": "https://github.com/jscrambler/jscrambler",
6
6
  "author": "Jscrambler <support@jscrambler.com>",
7
7
  "repository": {
@@ -17,21 +17,10 @@
17
17
  "access": "public",
18
18
  "registry": "https://registry.npmjs.org/"
19
19
  },
20
- "scripts": {
21
- "clean": "rm -rf ./dist",
22
- "build": "babel src --out-dir dist",
23
- "watch": "babel -w src --out-dir dist",
24
- "prepublish": "npm run build",
25
- "eslint": "eslint src/",
26
- "eslint:fix": "eslint src/ --fix"
27
- },
28
20
  "engines": {
29
21
  "node": ">= 12.17.0"
30
22
  },
31
23
  "dependencies": {
32
- "acorn": "8.14.0",
33
- "acorn-walk": "8.3.4",
34
- "magic-string": "0.30.15",
35
24
  "axios": "^1.7.7",
36
25
  "commander": "^2.8.1",
37
26
  "core-js": "3.38.1",
@@ -67,5 +56,13 @@
67
56
  "protect",
68
57
  "js",
69
58
  "javascript"
70
- ]
71
- }
59
+ ],
60
+ "scripts": {
61
+ "clean": "rm -rf ./dist",
62
+ "build": "babel src --out-dir dist",
63
+ "watch": "babel -w src --out-dir dist",
64
+ "prepublish": "npm run build",
65
+ "eslint": "eslint src/",
66
+ "eslint:fix": "eslint src/ --fix"
67
+ }
68
+ }