jscrambler
Advanced tools
Comparing version 0.5.10 to 0.5.11
@@ -20,3 +20,4 @@ module.exports = function (grunt) { | ||
grunt.registerTask('default', ['test']); | ||
grunt.registerTask('test', ['clean', 'jasmine_node', 'clean']); | ||
}; |
'use strict'; | ||
var _ = require('lodash'); | ||
var clone = require('lodash.clone'); | ||
var crypto = require('crypto'); | ||
var defaults = require('lodash.defaults'); | ||
var fs = require('fs'); | ||
var keys = require('lodash.keys'); | ||
var needle = require('needle'); | ||
var querystring = require('querystring'); | ||
var url = require('url'); | ||
/** | ||
@@ -23,3 +28,3 @@ * @class JScramblerClient | ||
*/ | ||
this.options = _.defaults(options || {}, { | ||
this.options = defaults(options || {}, { | ||
accessKey: null, | ||
@@ -61,6 +66,6 @@ secretKey: null, | ||
// Sorted keys | ||
var keys = _.keys(params).sort(); | ||
var _keys = keys(params).sort(); | ||
var query = ''; | ||
for (var i = 0, l = keys.length; i < l; i++) | ||
query += encodeURIComponent(keys[i]) + '=' + encodeURIComponent(params[keys[i]]) + '&'; | ||
for (var i = 0, l = _keys.length; i < l; i++) | ||
query += encodeURIComponent(_keys[i]) + '=' + encodeURIComponent(params[_keys[i]]) + '&'; | ||
query = query | ||
@@ -83,3 +88,3 @@ .replace(/\*/g, '%2A') | ||
function generateHmacSignature (method, path, params) { | ||
var paramsCopy = _.clone(params); | ||
var paramsCopy = clone(params); | ||
for (var key in params) { | ||
@@ -129,3 +134,3 @@ if (key.indexOf('file_') !== -1) { | ||
function signedParams (method, path, params) { | ||
_.defaults(params, { | ||
defaults(params, { | ||
access_key: this.options.accessKey, | ||
@@ -132,0 +137,0 @@ timestamp: new Date().toISOString(), |
@@ -9,3 +9,3 @@ /** | ||
var _ = require('lodash'); | ||
var assign = require('lodash.assign'); | ||
var fs = require('fs-extra'); | ||
@@ -17,5 +17,7 @@ var glob = require('glob'); | ||
var Q = require('q'); | ||
var size = require('lodash.size'); | ||
var temp = require('temp').track(); | ||
var util = require('util'); | ||
var debug = !!process.env.DEBUG; | ||
@@ -50,4 +52,11 @@ | ||
if (err) deferred.reject(err); | ||
else if (res.statusCode >= 400) deferred.reject(JSON.parse(body)); | ||
else deferred.resolve(body); | ||
else if (res.statusCode >= 400) { | ||
if (Buffer.isBuffer(body)) { | ||
deferred.reject(JSON.parse(body)); | ||
} else { | ||
deferred.reject(body); | ||
} | ||
} else { | ||
deferred.resolve(body); | ||
} | ||
} catch (ex) { | ||
@@ -75,4 +84,15 @@ deferred.reject(body); | ||
if (err) deferred.reject(err); | ||
else if (res.statusCode >= 400) deferred.reject(JSON.parse(body)); | ||
else deferred.resolve(JSON.parse(body)); | ||
else if (res.statusCode >= 400) { | ||
if (Buffer.isBuffer(body)) { | ||
deferred.reject(JSON.parse(body)); | ||
} else { | ||
deferred.reject(body); | ||
} | ||
} else { | ||
if (Buffer.isBuffer(body)) { | ||
deferred.resolve(JSON.parse(body)); | ||
} else { | ||
deferred.resolve(body); | ||
} | ||
} | ||
} catch (ex) { | ||
@@ -122,3 +142,3 @@ deferred.reject(body); | ||
params = _.extend({}, params); | ||
params = assign({}, params); | ||
params.files = params.files.slice(); | ||
@@ -132,4 +152,15 @@ this.zipProject(params.files, params.cwd); | ||
if (err) deferred.reject(err); | ||
else if (res.statusCode >= 400) deferred.reject(JSON.parse(body)); | ||
else deferred.resolve(JSON.parse(body)); | ||
else if (res.statusCode >= 400) { | ||
if (Buffer.isBuffer(body)) { | ||
deferred.reject(JSON.parse(body)); | ||
} else { | ||
deferred.reject(body); | ||
} | ||
} else { | ||
if (Buffer.isBuffer(body)) { | ||
deferred.resolve(JSON.parse(body)); | ||
} else { | ||
deferred.resolve(body); | ||
} | ||
} | ||
} catch (ex) { | ||
@@ -153,4 +184,16 @@ deferred.reject(body); | ||
if (err) deferred.reject(err); | ||
else if (res.statusCode >= 400) deferred.reject(JSON.parse(body)); | ||
else deferred.resolve(JSON.parse(body)); | ||
else if (res.statusCode >= 400) { | ||
if (Buffer.isBuffer(body)) { | ||
deferred.reject(JSON.parse(body)); | ||
} else { | ||
deferred.reject(body); | ||
} | ||
} | ||
else { | ||
if (Buffer.isBuffer(body)) { | ||
deferred.resolve(JSON.parse(body)); | ||
} else { | ||
deferred.resolve(body); | ||
} | ||
} | ||
} catch (ex) { | ||
@@ -299,3 +342,3 @@ deferred.reject(body); | ||
var zip = new JSZip(zipFile); | ||
var size = _.size(zip.files); | ||
var _size = size(zip.files); | ||
for (var file in zip.files) { | ||
@@ -309,3 +352,3 @@ if (!zip.files[file].options.dir) { | ||
var destPath; | ||
if (size === 1 && lastDestChar !== '/' && lastDestChar !== '\\') { | ||
if (_size === 1 && lastDestChar !== '/' && lastDestChar !== '\\') { | ||
destPath = dest; | ||
@@ -312,0 +355,0 @@ } else { |
{ | ||
"name": "jscrambler", | ||
"description": "JScrambler API client.", | ||
"version": "0.5.10", | ||
"version": "0.5.11", | ||
"homepage": "https://github.com/auditmark/node-jscrambler", | ||
@@ -32,8 +32,14 @@ "author": { | ||
"flavored-path": "0.0.8", | ||
"fs-extra": "^0.8.1", | ||
"fs-extra": "^0.12.0", | ||
"glob": "^4.0.2", | ||
"jszip": "^2.2.2", | ||
"lodash": "^2.4.1", | ||
"needle": "^0.6.6", | ||
"lodash.assign": "^2.4.1", | ||
"lodash.clone": "^2.4.1", | ||
"lodash.defaults": "^2.4.1", | ||
"lodash.keys": "^2.4.1", | ||
"lodash.pluck": "^2.4.1", | ||
"lodash.size": "^2.4.1", | ||
"needle": "^0.7.10", | ||
"q": "^1.0.1", | ||
"snake-case": "^1.0.1", | ||
"temp": "^0.8.1" | ||
@@ -40,0 +46,0 @@ }, |
116
README.md
# JScrambler Client for Node.js | ||
## CLI | ||
```shell | ||
```bash | ||
npm install -g jscrambler | ||
@@ -11,25 +11,64 @@ ``` | ||
-h, --help output usage information | ||
-V, --version output the version number | ||
-c, --config [config] JScrambler configuration options | ||
-o, --output <output> Output directory | ||
-a, --access-key <accessKey> Access key | ||
-s, --secret-key <secretKey> Secret key | ||
--help output usage information | ||
-V, --version output the version number | ||
-c, --config [config] JScrambler configuration options | ||
-o, --output [output] Output directory. If not specified the output is printed. | ||
-a, --access-key <accessKey> Access key | ||
-s, --secret-key <secretKey> Secret key | ||
-h, --host [host] Hostname | ||
-p, --port [port] Port | ||
-v, --api-version [apiVersion] Version | ||
--asserts-elimination [assertsElimination] Remove function definitions and function calls with a given name. | ||
--browser-os-lock [browserOsLock] Locks a JavaScript application to run only on a specific Browser or Operating System. | ||
--constant-folding Simplifies constant expressions at compile-time to make your code faster at run-time. | ||
--dead-code Randomly injects dead code into the source code. | ||
--dead-code-elimination Removes dead code and void code from your JavaScript. | ||
--debugging-code-elimination [debuggingCodeElimination Removes statements and public variable declarations used to control the output of debugging messages that help you debug your code. | ||
--dictionary-compression further shrink your source code | ||
--domain-lock [domainLock] Locks your project to a list of domains you specify. | ||
--dot-notation-elimination Transforms dot notation to subscript notation. | ||
--exceptions-list [exceptionsList] list of exceptions that will never be replaced or used to create new declarations | ||
--expiration-date [expirationDate] Sets your JavaScript to expire after a date (YYYY/MM/DD) of your choosing. | ||
--function-outlining Turns statements into new function declarations. | ||
--function-reorder Randomly reorders your source code's function declarations. | ||
--ignore-files [ignoreFiles] Define a list of files (relative paths) that JScrambler must ignore. | ||
--literal-hooking [literalHooking] Replaces literals by a randomly sized chain of ternary operators. | ||
--literal-duplicates Replaces literal duplicates by a symbol. | ||
--member-enumeration Replaces Browser and HTML DOM objects by a member enumeration. | ||
--mode [mode] protection mode starter|mobile|html5|nodejs | ||
--name-prefix [namePrefix] Set a prefix to be appended to the new names generated by JScrambler. | ||
--rename-all Renames all identifiers found at your source code. | ||
--rename-local Renames local names only. | ||
--self-defending thwarting code tampering attempts by using anti-tampering and anti-debugging techniques. | ||
--string-splitting [stringSplitting] split strings based on percentage of occurence in the source code input | ||
--whitespace enable whitespace | ||
### Required Fields | ||
When making API requests you must pass valid secret and access keys. These are each 40 characters long, alpha numeric strings, and uppercase. You can find them in your jscramber web dashboard under `My Account > Api access`. In the examples these are shortened to `XXXX` for the sake of readability. | ||
### Output to a single file | ||
```shell | ||
jscrambler input.js -a XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -s XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX > output.js | ||
```bash | ||
jscrambler input.js -a XXXX -s XXXX > output.js | ||
``` | ||
### Output multiple files to a directory | ||
```shell | ||
jscrambler input1.js input2.js -o dest/ -a XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -s XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX | ||
```bash | ||
jscrambler input1.js input2.js -o dest/ -a XXXX -s XXXX | ||
``` | ||
### Using minimatch | ||
```shell | ||
jscrambler "lib/**/*.js" -o dest/ -a XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -s XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX | ||
```bash | ||
jscrambler "lib/**/*.js" -o dest/ -a XXXX -s XXXX | ||
``` | ||
### Using configuration file | ||
```bash | ||
jscrambler input.js -s XXXX -a XXXX -c ./config.json > output.js | ||
``` | ||
where `config.json` is an object optionally containing any of the JScrambler options listed below. | ||
## API | ||
```shell | ||
```bash | ||
npm install jscrambler | ||
@@ -81,2 +120,20 @@ ``` | ||
### browser_os_lock | ||
Type: `String` | ||
Locks a JavaScript application to run only on a specific Browser or Operating System. | ||
available values: | ||
* `firefox` | ||
* `chrome` | ||
* `iexplorer` | ||
* `linux` | ||
* `windows` | ||
* `mac_os` | ||
* `tizen` | ||
* `android` | ||
* `ios` | ||
### constant_folding | ||
@@ -138,3 +195,3 @@ Type: `String` | ||
### expiration_date: | ||
### expiration_date | ||
Type: `String` | ||
@@ -174,6 +231,6 @@ | ||
### literal_duplicates | ||
### duplicate_literals | ||
Type: `String` | ||
`%DEFAULT%` - enable literal duplicates | ||
`%DEFAULT%` - enable duplicate literals | ||
@@ -192,5 +249,6 @@ Replaces literal duplicates by a symbol. | ||
`starter` - Standard protection and optimization behavior. Enough for most JavaScript applications | ||
`mobile` - Transformations are applied having into account the limitations and needs of mobile devices | ||
`html5` - Protects your HTML5 and Web Gaming applications by targeting the new HTML5 features | ||
* `starter` - Standard protection and optimization behavior. Enough for most * JavaScript applications | ||
* `mobile` - Transformations are applied having into account the limitations and needs of mobile devices | ||
* `html5` - Protects your HTML5 and Web Gaming applications by targeting the new HTML5 features | ||
* `nodejs` - Protects your Node.js application | ||
@@ -202,2 +260,9 @@ ### name_prefix | ||
### rename_all | ||
Type: `String` | ||
`%DEFAULT%` - enable rename all | ||
Renames all identifiers found at your source code. By default, there is a list of JavaScript and HTML DOM names that will not be replaced. If you need to add additional exceptions use the exceptions_list parameter. | ||
### rename_local | ||
@@ -210,5 +275,14 @@ Type: `String` | ||
### string_splitting: | ||
### self_defending | ||
Type: `String` | ||
`%DEFAULT%` - enable self defending | ||
Obfuscates functions and objects concealing their logic and thwarting code tampering attempts by using anti-tampering and anti-debugging techniques. Attempts to tamper the code will break its functionality and using JavaScript debuggers will trigger defenses to thwart analysis. | ||
### string_splitting | ||
Type: `String` | ||
`occurrences[;concatenation]` | ||
@@ -215,0 +289,0 @@ |
/* global describe, beforeEach, it, expect, spyOn, Buffer, jasmine, console */ | ||
var _ = require('lodash'); | ||
var fs = require('fs'); | ||
var jScrambler = require('../../jscrambler'); | ||
var jScramblerKeys = require('../../jscrambler_keys'); | ||
var pluck = require('lodash.pluck'); | ||
var util = require('util'); | ||
@@ -49,3 +49,3 @@ | ||
for (var i = 0, l = files.length; i < l; ++i) { | ||
expect(_.pluck(res.sources, 'filename').indexOf(files[i]) !== -1).toBeTruthy(); | ||
expect(pluck(res.sources, 'filename').indexOf(files[i]) !== -1).toBeTruthy(); | ||
} | ||
@@ -72,3 +72,3 @@ | ||
for (var i = 0, l = files.length; i < l; ++i) { | ||
expect(_.pluck(res.sources, 'filename').indexOf(files[i]) !== -1).toBeTruthy(); | ||
expect(pluck(res.sources, 'filename').indexOf(files[i]) !== -1).toBeTruthy(); | ||
expect(res.sources[i].error_id).toEqual(null); | ||
@@ -94,3 +94,3 @@ } | ||
for (var i = 0, l = files.length; i < l; ++i) { | ||
expect(_.pluck(res.sources, 'filename').indexOf(files[i]) !== -1).toBeTruthy(); | ||
expect(pluck(res.sources, 'filename').indexOf(files[i]) !== -1).toBeTruthy(); | ||
} | ||
@@ -97,0 +97,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
42283
19
733
292
15
+ Addedlodash.assign@^2.4.1
+ Addedlodash.clone@^2.4.1
+ Addedlodash.defaults@^2.4.1
+ Addedlodash.keys@^2.4.1
+ Addedlodash.pluck@^2.4.1
+ Addedlodash.size@^2.4.1
+ Addedsnake-case@^1.0.1
+ Addedfs-extra@0.12.0(transitive)
+ Addedgraceful-fs@4.2.11(transitive)
+ Addediconv-lite@0.4.24(transitive)
+ Addedjsonfile@2.4.0(transitive)
+ Addedlodash._arraypool@2.4.1(transitive)
+ Addedlodash._basebind@2.4.1(transitive)
+ Addedlodash._baseclone@2.4.1(transitive)
+ Addedlodash._basecreate@2.4.1(transitive)
+ Addedlodash._basecreatecallback@2.4.1(transitive)
+ Addedlodash._basecreatewrapper@2.4.1(transitive)
+ Addedlodash._baseisequal@2.4.1(transitive)
+ Addedlodash._createwrapper@2.4.1(transitive)
+ Addedlodash._getarray@2.4.1(transitive)
+ Addedlodash._isnative@2.4.1(transitive)
+ Addedlodash._maxpoolsize@2.4.1(transitive)
+ Addedlodash._objecttypes@2.4.1(transitive)
+ Addedlodash._releasearray@2.4.1(transitive)
+ Addedlodash._setbinddata@2.4.1(transitive)
+ Addedlodash._shimkeys@2.4.1(transitive)
+ Addedlodash._slice@2.4.1(transitive)
+ Addedlodash.assign@2.4.1(transitive)
+ Addedlodash.bind@2.4.1(transitive)
+ Addedlodash.clone@2.4.1(transitive)
+ Addedlodash.createcallback@2.4.4(transitive)
+ Addedlodash.defaults@2.4.1(transitive)
+ Addedlodash.foreach@2.4.1(transitive)
+ Addedlodash.forin@2.4.1(transitive)
+ Addedlodash.forown@2.4.1(transitive)
+ Addedlodash.identity@2.4.1(transitive)
+ Addedlodash.isarray@2.4.1(transitive)
+ Addedlodash.isfunction@2.4.1(transitive)
+ Addedlodash.isobject@2.4.1(transitive)
+ Addedlodash.keys@2.4.1(transitive)
+ Addedlodash.map@2.4.1(transitive)
+ Addedlodash.noop@2.4.1(transitive)
+ Addedlodash.pluck@2.4.1(transitive)
+ Addedlodash.property@2.4.1(transitive)
+ Addedlodash.size@2.4.1(transitive)
+ Addedlodash.support@2.4.1(transitive)
+ Addedlower-case@1.1.4(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedmkdirp@0.5.6(transitive)
+ Addedncp@0.6.0(transitive)
+ Addedneedle@0.7.11(transitive)
+ Addedrimraf@2.7.1(transitive)
+ Addedsentence-case@1.1.3(transitive)
+ Addedsnake-case@1.1.2(transitive)
- Removedlodash@^2.4.1
- Removedcall-bind@1.0.7(transitive)
- Removeddefine-data-property@1.1.4(transitive)
- Removedes-define-property@1.0.0(transitive)
- Removedes-errors@1.3.0(transitive)
- Removedfs-extra@0.8.1(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedget-intrinsic@1.2.4(transitive)
- Removedgopd@1.0.1(transitive)
- Removedhas-property-descriptors@1.0.2(transitive)
- Removedhas-proto@1.0.3(transitive)
- Removedhas-symbols@1.0.3(transitive)
- Removedhasown@2.0.2(transitive)
- Removediconv-lite@0.6.3(transitive)
- Removedjsonfile@1.1.1(transitive)
- Removedlodash@2.4.2(transitive)
- Removedmkdirp@0.3.5(transitive)
- Removedncp@0.4.2(transitive)
- Removedneedle@0.6.6(transitive)
- Removedobject-inspect@1.13.2(transitive)
- Removedqs@6.13.0(transitive)
- Removedrimraf@2.2.8(transitive)
- Removedset-function-length@1.2.2(transitive)
- Removedside-channel@1.0.6(transitive)
Updatedfs-extra@^0.12.0
Updatedneedle@^0.7.10