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.3.0 to 0.3.1

.editorconfig

58

jscrambler.js

@@ -1,4 +0,1 @@

'use strict';
var JScramblerClient = require('./jscrambler-client');
var Q = require('q');
/**

@@ -10,2 +7,10 @@ * A facade to access JScrambler API using JScramblerClient.

*/
'use strict';
var fs = require('fs-extra');
var JScramblerClient = require('./jscrambler-client');
var JSZip = require('jszip');
var path = require('path');
var Q = require('q');
exports = module.exports =

@@ -90,9 +95,56 @@ /** @lends jScramblerFacade */

var deferred = Q.defer();
this.zipProject(params.files);
client.post('/code.json', params, function (err, res, body) {
this.cleanZipProject();
if (err) deferred.reject(err);
else if (res.statusCode >= 400) deferred.reject(res);
else deferred.resolve(JSON.parse(body));
}.bind(this));
return deferred.promise;
},
/**
* Deletes code through the API.
* @param {JScramblerClient} client
* @param {String} projectId
* @returns {Q.promise}
*/
deleteCode: function (client, projectId) {
var deferred = Q.defer();
client.delete('/code/' + projectId + '.zip', null, function (err, res, body) {
if (err) deferred.reject(err);
else if (res.statusCode >= 400) deferred.reject(res);
else deferred.resolve(JSON.parse(body));
});
return deferred.promise;
},
/**
* It cleans the temporary zip project.
*/
cleanZipProject: function () {
fs.unlinkSync('.tmp.zip');
},
/**
* It zips all files inside the passed parameter into a single zip file.
*/
zipProject: function (files) {
var zip = new JSZip();
for (var i = 0, l = files.length; i < l; ++i) {
zip.file(files[i], fs.readFileSync(files[i]));
}
fs.outputFileSync('.tmp.zip', zip.generate(), {encoding: 'base64'});
files[0] = '.tmp.zip';
files.length = 1;
},
/**
* It unzips a zip file to the given destination.
*/
unzipProject: function (zipFile, dest) {
var zip = new JSZip(zipFile);
for (var file in zip.files) {
if (!zip.files[file].options.dir) {
var buffer = zip.file(file).asNodeBuffer();
fs.outputFileSync(path.join(dest, file), buffer);
}
}
}
};

5

package.json
{
"name": "jscrambler",
"description": "JScrambler API client.",
"version": "0.3.0",
"version": "0.3.1",
"homepage": "https://github.com/auditmark/node-jscrambler",

@@ -31,3 +31,4 @@ "author": {

"commander": "^2.1.0",
"fs-extra": "^0.8.1"
"fs-extra": "^0.8.1",
"jszip": "^2.2.0"
},

@@ -34,0 +35,0 @@ "main": "jscrambler",

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