API Clients

Source Code

Installing and Running Jscrambler

This is a short step by step to demonstrate the fastest way to install and run the Node.js API Client as a Command Line Interface (CLI). For a more in-depth guide on how to use Jscrambler please check our Getting Started Guide.

Some of the following steps require using Jscrambler's Web App since it is the fastest way to get the job done. However, anything that you can do using the Web Application can also be achieved using Jscrambler's API.

Install the CLI

Install the CLI with npm

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 the Web Application in the next step.

Please Login to Jscrambler's App and create a new Application on the Dashboard.

Application Settings

Once you create a new Application you are redirected to the Application's page. Here you can upload your 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 (you can also select specific transformations).

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.

The following are some example of how to use this together with the CLI:

Single File

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

Multiple Files

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

Using Minimatch

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 Jscrambler's Web Application can also be achieved with the API. In this short example, we have used the Web Application 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 Application and request protections with the CLI providing just your API credentials. Also, instead of selecting 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.