jscrambler
Advanced tools
Comparing version 0.1.2 to 0.2.0
@@ -42,3 +42,2 @@ 'use strict'; | ||
* @returns {String} The request path. | ||
* @this JSCramblerClient | ||
*/ | ||
@@ -76,3 +75,2 @@ function buildPath (method, path, params) { | ||
* @returns {String} The digested signature. | ||
* @this JScramblerClient | ||
*/ | ||
@@ -123,3 +121,2 @@ function generateHmacSignature (method, path, params) { | ||
properties. | ||
* @this JScramblerClient | ||
*/ | ||
@@ -126,0 +123,0 @@ function signedParams (method, path, params) { |
@@ -23,14 +23,18 @@ 'use strict'; | ||
var deferred = Q.defer(); | ||
var path = '/code/' + projectId; | ||
if (sourceId) { | ||
if (!/^.*\..*$/.test(sourceId)) | ||
throw new Error('Source extension missing'); | ||
else path += '/' + sourceId; | ||
} else if (!/^.*\.zip$/.test(projectId)) | ||
path += '.zip'; | ||
client.get(path, null, function (err, res, body) { | ||
if (err) deferred.reject(err); | ||
else if (res.statusCode >= 400) deferred.reject(res); | ||
else deferred.resolve(body); | ||
}); | ||
this | ||
.pollProject(client, projectId) | ||
.then(function () { | ||
var path = '/code/' + projectId; | ||
if (sourceId) { | ||
if (!/^.*\..*$/.test(sourceId)) | ||
throw new Error('Source extension missing'); | ||
else path += '/' + sourceId; | ||
} else if (!/^.*\.zip$/.test(projectId)) | ||
path += '.zip'; | ||
client.get(path, null, function (err, res, body) { | ||
if (err) deferred.reject(err); | ||
else if (res.statusCode >= 400) deferred.reject(res); | ||
else deferred.resolve(body); | ||
}); | ||
}); | ||
return deferred.promise; | ||
@@ -53,2 +57,28 @@ }, | ||
/** | ||
* Poll project until the build finishes. | ||
*/ | ||
pollProject: function (client, projectId) { | ||
var deferred = Q.defer(); | ||
var isFinished = function () { | ||
this | ||
.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) { | ||
deferred.resolve(); | ||
return; | ||
} | ||
} | ||
} | ||
// Try again later... | ||
setTimeout(isFinished, 1000); | ||
}); | ||
}.bind(this); | ||
isFinished(); | ||
return deferred.promise; | ||
}, | ||
/** | ||
* Uploads code through the API. | ||
@@ -55,0 +85,0 @@ * @param {JScramblerClient} client |
{ | ||
"name": "jscrambler", | ||
"description": "JScrambler API client.", | ||
"version": "0.1.2", | ||
"homepage": "https://github.com/magalhas/node-jscrambler", | ||
"version": "0.2.0", | ||
"homepage": "https://github.com/auditmark/node-jscrambler", | ||
"author": { | ||
@@ -12,6 +12,6 @@ "name": "magalhas", | ||
"type": "git", | ||
"url": "git://github.com:magalhas/node-jscrambler.git" | ||
"url": "git://github.com:auditmark/node-jscrambler.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/magalhas/node-jscrambler/issues" | ||
"url": "https://github.com/auditmark/node-jscrambler/issues" | ||
}, | ||
@@ -21,3 +21,3 @@ "licenses": [ | ||
"type": "MIT", | ||
"url": "https://github.com/magalhas/node-jscrambler/blob/master/LICENSE-MIT" | ||
"url": "https://github.com/auditmark/node-jscrambler/blob/master/LICENSE-MIT" | ||
} | ||
@@ -29,6 +29,7 @@ ], | ||
"dependencies": { | ||
"lodash": "*", | ||
"needle": "*" | ||
"q": "^1.0.1", | ||
"lodash": "^2.4.1", | ||
"needle": "^0.6.6" | ||
}, | ||
"main": "jscrambler" | ||
} | ||
} |
@@ -1,1 +0,34 @@ | ||
# JSCrambler Client for Node.js | ||
# JSCrambler Client for Node.js | ||
## Upload/download example | ||
```js | ||
var fs = require('fs-extra'); | ||
var jScrambler = require('jscrambler'); | ||
var client = new jScrambler.Client({ | ||
accessKey: '', | ||
secretKey: '' | ||
}); | ||
jScrambler | ||
.uploadCode(client, { | ||
files: ['index.js'], | ||
// Node.js obfuscation settings | ||
rename_local: '%DEFAULT%', | ||
whitespace: '%DEFAULT%', | ||
literal_hooking: '%DEFAULT%', | ||
dead_code: '%DEFAULT%', | ||
dot_notation_elimination: '%DEFAULT%', | ||
dead_code_elimination: '%DEFAULT%', | ||
constant_folding: '%DEFAULT%', | ||
literal_duplicates: '%DEFAULT%', | ||
function_outlining: '%DEFAULT%', | ||
string_splitting:'%DEFAULT%' | ||
}) | ||
.then(function (res) { | ||
return jScrambler.downloadCode(client, res.id); | ||
}) | ||
.then(function (res) { | ||
fs.outputFileSync('dist.zip', res); | ||
}); | ||
``` |
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
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
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
Wildcard dependency
QualityPackage has a dependency with a floating version range. This can cause issues if the dependency publishes a new major version.
Found 2 instances in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
10715
275
0
34
3
5
+ Addedq@^1.0.1
+ Addedcall-bind@1.0.7(transitive)
+ Addeddefine-data-property@1.1.4(transitive)
+ Addedes-define-property@1.0.0(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedget-intrinsic@1.2.4(transitive)
+ Addedgopd@1.0.1(transitive)
+ Addedhas-property-descriptors@1.0.2(transitive)
+ Addedhas-proto@1.0.3(transitive)
+ Addedhas-symbols@1.0.3(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedlodash@2.4.2(transitive)
+ Addedneedle@0.6.6(transitive)
+ Addedobject-inspect@1.13.2(transitive)
+ Addedq@1.5.1(transitive)
+ Addedqs@6.13.0(transitive)
+ Addedset-function-length@1.2.2(transitive)
+ Addedside-channel@1.0.6(transitive)
- Removedlodash@4.17.21(transitive)
- Removedneedle@3.3.1(transitive)
- Removedsax@1.4.1(transitive)
Updatedlodash@^2.4.1
Updatedneedle@^0.6.6