Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jscrambler

Package Overview
Dependencies
Maintainers
1
Versions
177
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jscrambler - npm Package Compare versions

Comparing version 0.5.10 to 0.5.11

lib/cli.js

1

Gruntfile.js

@@ -20,3 +20,4 @@ module.exports = function (grunt) {

grunt.registerTask('default', ['test']);
grunt.registerTask('test', ['clean', 'jasmine_node', 'clean']);
};

19

jscrambler-client.js
'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 @@ },

# 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc