jscrambler
Advanced tools
Comparing version 0.5.11 to 0.6.0
'use strict'; | ||
var cfg = require('./lib/config'); | ||
var clone = require('lodash.clone'); | ||
@@ -12,3 +13,2 @@ var crypto = require('crypto'); | ||
/** | ||
@@ -26,13 +26,14 @@ * @class JScramblerClient | ||
function JScramblerClient (options) { | ||
// Sluggish hack for backwards compatibility | ||
if (options && !options.keys && (options.accessKey || options.secretKey)) { | ||
options.keys = {}; | ||
options.keys.accessKey = options.accessKey; | ||
options.keys.secretKey = options.secretKey; | ||
} | ||
/** | ||
* @member | ||
*/ | ||
this.options = defaults(options || {}, { | ||
accessKey: null, | ||
secretKey: null, | ||
host: 'api.jscrambler.com', | ||
port: 443, | ||
apiVersion: 3 | ||
}); | ||
if (!this.options.accessKey || !this.options.secretKey) | ||
this.options = defaults(options || {}, cfg); | ||
if (!this.options.keys.accessKey || !this.options.keys.secretKey) | ||
throw new Error('Missing access or secret keys'); | ||
@@ -97,3 +98,3 @@ } | ||
';' + path + ';' + buildSortedQuery(paramsCopy); | ||
var hmac = crypto.createHmac('sha256', this.options.secretKey.toUpperCase()); | ||
var hmac = crypto.createHmac('sha256', this.options.keys.secretKey.toUpperCase()); | ||
hmac.update(signatureData); | ||
@@ -135,3 +136,3 @@ return hmac.digest('base64'); | ||
defaults(params, { | ||
access_key: this.options.accessKey, | ||
access_key: this.options.keys.accessKey, | ||
timestamp: new Date().toISOString(), | ||
@@ -138,0 +139,0 @@ user_agent: 'Node' |
@@ -10,2 +10,3 @@ /** | ||
var assign = require('lodash.assign'); | ||
var cfg = require('./lib/config'); | ||
var fs = require('fs-extra'); | ||
@@ -28,2 +29,3 @@ var glob = require('glob'); | ||
Client: JScramblerClient, | ||
config: cfg, | ||
/** | ||
@@ -210,5 +212,3 @@ * Downloads code through the API. | ||
require(configPathOrObject) : configPathOrObject; | ||
if (!config.keys || !config.keys.accessKey || !config.keys.secretKey) { | ||
throw new Error('Access key and secret key must be provided in the configuration file.'); | ||
} | ||
var accessKey = config.keys.accessKey; | ||
@@ -215,0 +215,0 @@ var secretKey = config.keys.secretKey; |
{ | ||
"name": "jscrambler", | ||
"description": "JScrambler API client.", | ||
"version": "0.5.11", | ||
"homepage": "https://github.com/auditmark/node-jscrambler", | ||
"version": "0.6.0", | ||
"homepage": "https://github.com/jscrambler/node-jscrambler", | ||
"author": { | ||
@@ -12,6 +12,6 @@ "name": "magalhas", | ||
"type": "git", | ||
"url": "git://github.com:auditmark/node-jscrambler.git" | ||
"url": "git://github.com:jscrambler/node-jscrambler.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/auditmark/node-jscrambler/issues" | ||
"url": "https://github.com/jscrambler/node-jscrambler/issues" | ||
}, | ||
@@ -21,3 +21,3 @@ "licenses": [ | ||
"type": "MIT", | ||
"url": "https://github.com/auditmark/node-jscrambler/blob/master/LICENSE-MIT" | ||
"url": "https://github.com/jscrambler/node-jscrambler/blob/master/LICENSE-MIT" | ||
} | ||
@@ -32,7 +32,7 @@ ], | ||
"dependencies": { | ||
"commander": "^2.1.0", | ||
"commander": "^2.5.0", | ||
"flavored-path": "0.0.8", | ||
"fs-extra": "^0.12.0", | ||
"glob": "^4.0.2", | ||
"jszip": "^2.2.2", | ||
"glob": "^4.2.1", | ||
"jszip": "^2.4.0", | ||
"lodash.assign": "^2.4.1", | ||
@@ -45,8 +45,7 @@ "lodash.clone": "^2.4.1", | ||
"needle": "^0.7.10", | ||
"q": "^1.0.1", | ||
"q": "^1.1.2", | ||
"rc": "^0.5.4", | ||
"snake-case": "^1.0.1", | ||
"temp": "^0.8.1" | ||
}, | ||
"main": "jscrambler", | ||
"bin": "bin/jscrambler", | ||
"devDependencies": { | ||
@@ -56,3 +55,5 @@ "grunt": "^0.4.5", | ||
"grunt-jasmine-node": "^0.2.1" | ||
} | ||
}, | ||
"main": "jscrambler", | ||
"bin": "bin/jscrambler" | ||
} |
# JScrambler Client for Node.js | ||
- [RC config](#rc-config) | ||
- [CLI](#cli) | ||
- [Required Fields](#required-fields) | ||
- [Output to a single file](#output-to-a-single-file) | ||
- [Output multiple files to a directory](#output-multiple-files-to-a-directory) | ||
- [Using minimatch](#using-minimatch) | ||
- [Using configuration file](#using-configuration-file) | ||
- [API](#api) | ||
- [Upload/download example](#uploaddownload-example) | ||
- [JScrambler Options](#jscrambler-options) | ||
- [asserts_elimination](#asserts_elimination) | ||
- [browser_os_lock](#browser_os_lock) | ||
- [constant_folding](#constant_folding) | ||
- [dead_code](#dead_code) | ||
- [dead_code_elimination](#dead_code_elimination) | ||
- [debugging_code_elimination](#debugging_code_elimination) | ||
- [dictionary_compression](#dictionary_compression) | ||
- [domain_lock](#domain_lock) | ||
- [dot_notation_elimination](#dot_notation_elimination) | ||
- [exceptions_list](#exceptions_list) | ||
- [expiration_date](#expiration_date) | ||
- [function_outlining](#function_outlining) | ||
- [function_reorder](#function_reorder) | ||
- [ignore_files](#ignore_files) | ||
- [literal_hooking](#literal_hooking) | ||
- [duplicate_literals](#duplicate_literals) | ||
- [member_enumeration](#member_enumeration) | ||
- [mode](#mode) | ||
- [name_prefix](#name_prefix) | ||
- [rename_all](#rename_all) | ||
- [rename_local](#rename_local) | ||
- [self_defending](#self_defending) | ||
- [string_splitting](#string_splitting) | ||
- [whitespace](#whitespace) | ||
## RC configuration | ||
You may put your access and secret keys into a config file if found in [these directories](https://github.com/dominictarr/rc#standards). Besides simplifying the command entry, this has the added benefit of not logging your JScrambler credentials. | ||
Here's an example of what your `.jscramblerrc` file should look like: | ||
```javascript | ||
{ | ||
"keys": { | ||
"accessKey": "XXXXXX", | ||
"secretKey": "XXXXXX" | ||
} | ||
} | ||
``` | ||
Replace the `XXXXXX` fields with your values of course. :) | ||
## CLI | ||
@@ -47,3 +97,3 @@ ```bash | ||
### 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. | ||
When making API requests you must pass valid secret and access keys, through the command line or by having a `.jscramblerrc` file. These keys 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. | ||
@@ -69,3 +119,3 @@ ### Output to a single file | ||
``` | ||
where `config.json` is an object optionally containing any of the JScrambler options listed below. | ||
where `config.json` is an object optionally containing any of the JScrambler options listed [here](#jscrambler-options). | ||
@@ -83,4 +133,6 @@ | ||
var client = new jScrambler.Client({ | ||
accessKey: '', | ||
secretKey: '' | ||
keys: { | ||
accessKey: '', // not needed if you have it on your `.jscramblerrc` | ||
secretKey: '' // not needed if you have it on your `.jscramblerrc` | ||
} | ||
}); | ||
@@ -87,0 +139,0 @@ |
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
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
44643
20
743
344
16
+ Addedrc@^0.5.4
+ Addeddeep-extend@0.2.11(transitive)
+ Addedini@1.3.8(transitive)
+ Addedminimist@0.0.10(transitive)
+ Addedrc@0.5.5(transitive)
+ Addedstrip-json-comments@0.1.3(transitive)
Updatedcommander@^2.5.0
Updatedglob@^4.2.1
Updatedjszip@^2.4.0
Updatedq@^1.1.2