We will be at OWASP APPSEC EUROPE 2017 - Belfast! Let’s talk!MORE INFO

Help Center

Get to know more about our API, Code Annotations and Code Transformations

API Clients

Source code

Install & Run

This is a short step by step to demonstrate the quickest way to install and run the API client as a CLI.

Some of the following steps use the Web application because it is the fastest way to get the job done. However, anything that you can do using the Web application you can also do using the Web API.

Install the CLI

Install the CLI using node package manager.

1
npm install -g jscrambler

Option -g gives you global access to jscrambler. Remove that option if you just want to access it locally.

Create a new Application

You can create a new application using the Web API, but in this case we’ll use the Web application. This will allow us to generate our JSON configuration using a Web UI in the next step.

Login and create a new application on the Dashboard.

Application Settings

If everything worked as expected, you should be redirected to a new application page. Here you can upload your application source code and configure the protection settings. In this case we’ll just do the latter.

On your right you will find the Application Settings section. Click on the tab Code Transformations and select the JavaScript targets you want to protect.

That’s it! Now that we are done with the configuration, you can download the JSON configuration file. That file includes your API credentials, Application ID, and protection configuration.

You’ll find the button to download the JSON file on the top right corner, next to the Application Settings section.

config download

Run the CLI

Now we have everything we need to run the CLI. Use the jscrambler.json downloaded previously and load it into jscrambler CLI using option -c. You can think of it as a protection recipe.

Here are some example of how to use this together with the CLI.

Single file

1
jscrambler -c jscrambler.json -o bundle.protected.js bundle.js

Multiple files

1
jscrambler -c jscrambler.json -o MyProtectedApp/ MySourceFile.js AnotherSourceFile.html

Using minimatch

1
jscrambler -c jscrambler.json -o MyProtectedApp/ "MyApp/**/*.js"

On any of the previous examples you’re uploading the same source code for every request, but you don’t have to. After the first request you can omit the source code (input), until you do any change to your source code, and therefore need to update the application on Jscrambler.

For more information about the options available please refer to CLI options.

Conclusion

Anything that you can do using the Web UI you could also do with the API. Here we have used the Web UI to create a new application and to download a JSON containing the protection settings. Note that you could also configure your application on the Web UI, and request protections with the CLI providing just your API credentials. Also, instead of setting your input file(s) using the CLI, you could upload them using the Web application, and use the CLI without uploading the same input file(s) for every request.