Skip to content

Commit

Permalink
Added base web version
Browse files Browse the repository at this point in the history
  • Loading branch information
sanex3339 committed Apr 19, 2018
1 parent 2be1bf9 commit 6bd872c
Show file tree
Hide file tree
Showing 22 changed files with 290 additions and 85 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
Change Log
===
v0.17.0
---
* **Web version**: Added web version dist
* Fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/247

v0.16.0
---
* Correct obfuscation of object rest and spread properties
Expand Down
26 changes: 20 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
Author: Timofey Kachalov
-->

# JavaScript obfuscator for Node.js
# JavaScript obfuscator

![logo](https://raw.githubusercontent.com/javascript-obfuscator/javascript-obfuscator/master/images/logo.png)

JavaScript obfuscator is a powerful free obfuscator for JavaScript and Node.js with a wide number of features which provides protection for your source code.
JavaScript obfuscator is a powerful free obfuscator for JavaScript with a wide number of features which provides protection for your source code.

Example of obfuscated code: [gist.github.com](https://gist.github.com/sanex3339/ffc2876123b52e6d11ce45369fd53acf)

Expand Down Expand Up @@ -50,7 +50,9 @@ It is not recommended to obfuscate vendor scripts and polyfills, since the obfus

## Installation

Install the package with Yarn or NPM and add it to your `devDependencies`:
#### Using Yarn or NPM

Install the package with Yarn or NPM and add it to your `dependencies` or `devDependencies`:

```sh
$ yarn add --dev javascript-obfuscator
Expand All @@ -60,9 +62,21 @@ or
$ npm install --save-dev javascript-obfuscator
```

## Node.js usage
#### In a Browser

Add `<script>` tag with package:

```html
<script src="./node_modules/javascript-obfuscator/dist/index.web.js">
```
or require package from CDN:
```html
TODO
```
Here's an example of how to use it:
## Usage
```javascript
var JavaScriptObfuscator = require('javascript-obfuscator');
Expand Down Expand Up @@ -866,7 +880,7 @@ Try to run `npm link javascript-obfuscator` command or install it globally with
### Error `maximum call stack size exceeded`
Likely this is `selfDefending` mechanism. Something is changing source code after obfuscation with `selfDefending` option.
### Web version?
### Online version?
[obfuscator.io](https://obfuscator.io)
Expand Down
2 changes: 1 addition & 1 deletion bin/javascript-obfuscator
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env node

require('../dist/index').runCLI(process.argv);
require('../dist/index.cli').obfuscate(process.argv);
25 changes: 25 additions & 0 deletions dist/index.cli.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

54 changes: 54 additions & 0 deletions dist/index.web.js

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions index.cli.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"use strict";

import { JavaScriptObfuscatorCLI } from './src/JavaScriptObfuscatorCLIFacade';

module.exports = JavaScriptObfuscatorCLI;
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
"mkdirp": "0.5.1",
"multimatch": "2.1.0",
"opencollective": "1.0.3",
"pjson": "1.0.9",
"reflect-metadata": "0.1.12",
"source-map-support": "0.5.4",
"string-template": "1.0.0",
Expand Down Expand Up @@ -64,6 +63,7 @@
"coveralls": "3.0.0",
"istanbul": "1.1.0-alpha.1",
"mocha": "5.1.0",
"pjson": "1.0.9",
"pre-commit": "1.2.2",
"rimraf": "2.6.2",
"sinon": "4.5.0",
Expand All @@ -85,7 +85,8 @@
},
"scripts": {
"start": "scripts/start",
"webpack": "scripts/webpack",
"webpack:prod": "scripts/webpack-prod",
"webpack:dev": "scripts/webpack-dev",
"build": "scripts/build",
"watch": "scripts/watch",
"removeCacheDir": "scripts/remove-cache-dir",
Expand Down
2 changes: 1 addition & 1 deletion scripts/build
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

yarn run removeCacheDir &&
yarn run webpack &&
yarn run webpack:prod &&
yarn run tslint &&
yarn test
2 changes: 1 addition & 1 deletion scripts/watch
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash

$(yarn bin)/webpack --mode development --watch
$(yarn bin)/webpack --config webpack/webpack.config.js --mode development --watch
3 changes: 0 additions & 3 deletions scripts/webpack

This file was deleted.

3 changes: 3 additions & 0 deletions scripts/webpack-dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

$(yarn bin)/webpack --config webpack/webpack.config.js --mode production
3 changes: 3 additions & 0 deletions scripts/webpack-prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

$(yarn bin)/webpack --config webpack/webpack.config.js --config webpack/webpack.web.config.js --mode production
3 changes: 1 addition & 2 deletions src/JavaScriptObfuscator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { ServiceIdentifiers } from './container/ServiceIdentifiers';
import * as escodegen from 'escodegen-wallaby';
import * as espree from 'espree';
import * as ESTree from 'estree';
import * as packageJson from 'pjson';

import { IGeneratorOutput } from './interfaces/IGeneratorOutput';
import { IJavaScriptObfuscator } from './interfaces/IJavaScriptObfsucator';
Expand Down Expand Up @@ -127,7 +126,7 @@ export class JavaScriptObfuscator implements IJavaScriptObfuscator {
*/
public obfuscate (sourceCode: string): IObfuscationResult {
const timeStart: number = Date.now();
this.logger.info(LoggingMessage.Version, packageJson.version);
this.logger.info(LoggingMessage.Version, '0.16.0');
this.logger.info(LoggingMessage.ObfuscationStarted);
this.logger.info(LoggingMessage.RandomGeneratorSeed, this.randomGenerator.getSeed());

Expand Down
17 changes: 17 additions & 0 deletions src/JavaScriptObfuscatorCLIFacade.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import 'reflect-metadata';

import { JavaScriptObfuscatorCLI } from './cli/JavaScriptObfuscatorCLI';

class JavaScriptObfuscatorCLIFacade {
/**
* @param {string[]} argv
*/
public static obfuscate (argv: string[]): void {
const javaScriptObfuscatorCLI: JavaScriptObfuscatorCLI = new JavaScriptObfuscatorCLI(argv);

javaScriptObfuscatorCLI.initialize();
javaScriptObfuscatorCLI.run();
}
}

export { JavaScriptObfuscatorCLIFacade as JavaScriptObfuscatorCLI };
16 changes: 5 additions & 11 deletions src/JavaScriptObfuscatorFacade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@ import { IJavaScriptObfuscator } from './interfaces/IJavaScriptObfsucator';
import { IObfuscationResult } from './interfaces/IObfuscationResult';

import { InversifyContainerFacade } from './container/InversifyContainerFacade';
import { JavaScriptObfuscatorCLI } from './cli/JavaScriptObfuscatorCLI';

class JavaScriptObfuscatorFacade {
/**
* @type {string | undefined}
*/
public static version: string = process.env.VERSION || 'unknown';

/**
* @param {string} sourceCode
* @param {TInputOptions} inputOptions
Expand All @@ -30,16 +34,6 @@ class JavaScriptObfuscatorFacade {

return obfuscationResult;
}

/**
* @param {string[]} argv
*/
public static runCLI (argv: string[]): void {
const javaScriptObfuscatorCLI: JavaScriptObfuscatorCLI = new JavaScriptObfuscatorCLI(argv);

javaScriptObfuscatorCLI.initialize();
javaScriptObfuscatorCLI.run();
}
}

export { JavaScriptObfuscatorFacade as JavaScriptObfuscator };
3 changes: 1 addition & 2 deletions src/cli/JavaScriptObfuscatorCLI.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as commander from 'commander';
import * as packageJson from 'pjson';
import * as path from 'path';

import { TInputCLIOptions } from '../types/options/TInputCLIOptions';
Expand Down Expand Up @@ -186,7 +185,7 @@ export class JavaScriptObfuscatorCLI implements IInitializable {
this.commands
.usage('<inputPath> [options]')
.version(
packageJson.version,
process.env.VERSION || 'unknown',
'-v, --version'
)
.option(
Expand Down
Loading

0 comments on commit 6bd872c

Please sign in to comment.