Socket
Socket
Sign inDemoInstall

grunt-jscrambler

Package Overview
Dependencies
5
Maintainers
1
Versions
130
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.0 to 0.2.1

.npmignore

0

doc/beginners.md

@@ -0,0 +0,0 @@ # Never used Node.js and Grunt before

@@ -0,0 +0,0 @@ 'use strict';

@@ -0,0 +0,0 @@ 'use strict';

@@ -0,0 +0,0 @@ 'use strict';

@@ -0,0 +0,0 @@ 'use strict';

@@ -0,0 +0,0 @@ 'use strict';

@@ -0,0 +0,0 @@ {

@@ -0,0 +0,0 @@ 'use strict';

11

Gruntfile.js

@@ -11,11 +11,10 @@ 'use strict';

options: {
keys: grunt.file.readJSON('jscrambler_keys.json')
keys: grunt.file.readJSON('jscrambler_keys.json'),
deleteProject: true
},
files: [
{ src: ['Gruntfile.js'], dest: '.tmp/'},
{
expand: true,
src: ['tasks/*.js'],
dest: '.tmp/',
ext: '.min.js'
src: ['tasks/**/*.js'],
dest: '.tmp'
}

@@ -29,2 +28,2 @@ ]

grunt.registerTask('default', ['clean', 'jscrambler']);
};
};
{
"name": "grunt-jscrambler",
"description": "Obfuscate your source files using the JScrambler API.",
"version": "0.2.0",
"version": "0.2.1",
"homepage": "https://github.com/auditmark/grunt-jscrambler",

@@ -36,3 +36,3 @@ "author": "José Magalhães <magalhas@gmail.com> (https://github.com/magalhas)",

"fs-extra": "^0.8.1",
"jscrambler": "^0.1.2",
"jscrambler": "^0.3.1",
"q": "^1.0.0",

@@ -39,0 +39,0 @@ "jszip": "^2.2.0"

@@ -49,3 +49,3 @@ # grunt-jscrambler

A string value that is used to provide the jscrambler api with the access key.
A string value that is used to provide the JScrambler API with the access key.

@@ -55,154 +55,14 @@ ##### options.keys.secretKey

A string value that is used to sign requests to the jscrambler api.
A string value that is used to sign requests to the JScrambler API.
#### JScrambler Parameters
##### options.deleteProject
Type: `Boolean`
The following options are passed to the jscrambler API. More information about them can be found at https://jscrambler.com/en/help/webapi/documentation
If this is set to `true` then the project will be deleted from JScrambler after it has been downloaded.
##### options.params.asserts_elimination
Type: `String`
##### options.params
Type: `Object`
`name1;name2;...` - assert function names
You can find a list of all the possible parameters in [here](https://github.com/auditmark/node-jscrambler#jscrambler-options).
Remove function definitions and function calls with a given name.
##### options.params.constant_folding
Type: `String`
`%DEFAULT%` - enable constant folding
Simplifies constant expressions at compile-time to make your code faster at run-time.
##### options.params.dead_code
Type: `String`
`%DEFAULT%` - enable dead code
Randomly injects dead code into the source code.
##### options.params.dead_code_elimination
Type: `String`
`%DEFAULT%` - enable dead code elimination
Removes dead code and void code from your JavaScript.
##### options.params.debugging_code_elimination
Type: `String`
`name1;name2;...` - debugging code names
Removes statements and public variable declarations used to control the output of debugging messages that help you debug your code.
##### options.params.dictionary_compression
Type: `String`
`%DEFAULT%` - enable dictionary compression
Dictionary compression to shrink even more your source code.
##### options.params.domain_lock
Type: `String`
`domain1;domain2;...` - your domains
Locks your project to a list of domains you specify.
##### options.params.dot_notation_elimination
Type: `String`
`%DEFAULT%` - enable dot notation elimination
Transforms dot notation to subscript notation.
##### options.params.exceptions_list
Type: `String`
`name;name1;name2;...` - list of exceptions that will never be replaced or used to create new declarations
There are some names that should never be replaced or reused to create new declarations e.g. document, toUpperCase. Public declarations existing in more than one source file should not be replaced if you submit only a part of the project where they appear. Therefore a list of irreplaceable names and the logic to make distinction between public and local names already exists on JScrambler to avoid touching those names. Use this parameter to add your own exceptions.
##### options.params.expiration_date:
Type: `String`
`date` - date format YYYY/MM/DD
Sets your JavaScript to expire after a date of your choosing.
##### options.params.function_outlining
Type: `String`
`%DEFAULT%` - enable function outlining
Turns statements into new function declarations.
##### options.params.function_reorder
Type: `String`
`%DEFAULT%` - enable function reordering
Randomly reorders your source code's function declarations.
##### options.params.ignore_files
Type: `String`
`filename;filename1` - List of files (relative paths) to be ignored
Define a list of files (relative paths) that JScrambler must ignore.
##### options.params.literal_hooking
Type: `String`
`min;max[;percentage]` - min and max predicates in ternary operator and percentage chance of replacement
Replaces literals by a randomly sized chain of ternary operators. You may configure the minimum and maximum number of predicates per literal, as the occurrence probability of the transformation. This allows you to control how big the obfuscated JavaScript grows and the potency of the transformation.
##### options.params.literal_duplicates
Type: `String`
`%DEFAULT%` - enable literal duplicates
Replaces literal duplicates by a symbol.
##### options.params.member_enumeration
Type: `String`
`%DEFAULT%` - enable member enumeration
Replaces Browser and HTML DOM objects by a member enumeration.
##### options.params.mode
Type: `String`
`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
##### options.params.name_prefix
Type: `String`
Set a prefix to be appended to the new names generated by JScrambler.
##### options.params.rename_local
Type: `String`
`%DEFAULT%` - enable rename local
Renames local names only. The best way to replace names without worrying about name dependencies.
##### options.params.string_splitting:
Type: `String`
`occurrences[;concatenation]`
occurrences - Percentage of occurrences. Accepted values between 0.01 and 1.
concatenation - Percentage of concatenation occurrences. Accepted values between 0 and 1 (0 means chunks of a single character and 1 the whole string).
##### options.params.whitespace
Type: `String`
`%DEFAULT%` - enable whitespace
Shrink the size of your JavaScript removing unnecessary whitespaces and newlines from the source code.
### Usage Example

@@ -214,2 +74,2 @@

* Better error report/output
* Other API methods besides uploading/downloading JScrambled files
* Other API methods besides uploading/downloading JScrambled files

@@ -7,2 +7,3 @@ /**

'use strict';
var _ = require('lodash');

@@ -22,3 +23,4 @@ var fs = require('fs-extra');

secretKey: ''
}
},
deleteProject: false
});

@@ -45,70 +47,5 @@ if (!options.params) {

});
var writeFiles = function (res) {
if (zipOutput) {
fs.outputFileSync(files[0].dest, res);
}
else {
unzipFiles(res);
}
done();
};
var onError = function (err) {
grunt.fail.fatal(err);
};
var requestInfo = function () {
var projectFinished = false;
// Get projects info to check for status
jScrambler
.getInfo(client)
.then(function (res) {
for (var i = 0, l = res.length; i < l; i++) {
// Find projectId inside the response
if (res[i].id === projectId) {
// Did it finish?
if (res[i].finished_at) {
// Download the project zip file
jScrambler
.downloadCode(client, projectId)
.then(writeFiles)
.fail(onError);
projectFinished = true;
}
break;
}
}
// Try again later...
if (!projectFinished) setTimeout(requestInfo, 1000);
});
};
var unzipFiles = function (zipFile) {
var zip = new JSZip(zipFile),
file,
dest,
buffer;
for (file in zip.files) {
dest = filePaths[file];
buffer = zip.file(file).asNodeBuffer();
if (/\/$/.test(dest)) {
grunt.file.mkdir(dest);
dest = path.join(dest, file);
} else {
grunt.file.mkdir(path.dirname(dest));
}
fs.writeFileSync(dest, buffer);
}
};
var filePaths = {};
var zipOutput = false;
this.files.forEach(function (f) {
if (path.extname(f.dest) === '.zip') {
if (this.files.length > 1) {
grunt.fail.fatal('Only one set of files is supported when outputing a zip');
}
zipOutput = true;
}
f.src.forEach(function (s) {
filePaths[path.basename(s)] = f.dest;
});
}, this);
if (this.data.files.length > 1) {
grunt.fail.fatal('Grunt jScrambler only supports one set of files.');
}
var params = _.extend(_.omit(options, 'keys', 'params'), options.params);

@@ -120,6 +57,17 @@ params.files = this.filesSrc;

projectId = res.id;
requestInfo();
return jScrambler.downloadCode(client, res.id);
})
.fail(onError);
.then(function (res) {
return jScrambler.unzipProject(res, files[0].orig.dest);
})
.then(function () {
if (options.deleteProject) {
return jScrambler.deleteCode(client, projectId);
}
})
.then(done)
.fail(function (err) {
grunt.fail.fatal(err);
});
});
};

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc