Have ideas to improve npm?Join in the discussion! »

    terserflow

    1.3.2 • Public • Published

    TerserFlow

    npm

    donate

    Powered by Terser

    TerserFlow is a Javascript and NodeJS obfuscation tool with support for the latest ES6 Javascript syntax, it also encrypts all strings using a method that makes them uneditable after obfuscation.


    Contents


    Tech

    TerserFlow uses a number of npm libraries to work properly:


    Installation

    TerserFlow requires Node.js v4+ to run.

    From NPM for use as a command line app:

    $ npm i terserflow -g
    

    From NPM for programmatic use:

    $ npm i terserflow
    

    Usage

    This tool is a command-line tool and a Node.js Module meaning it can be used from your computer's command line interface(CLI) and programmatically from a javascript file.


    Command line usage

    Help interface :

    $ terserjs -h
    

    This outputs :

    Usage: terserjs [options]
    
    Options:
      -i, --input <inputFile>    input file location of source code to be obfuscated.
      -o, --output [outputFile]  Output file location to save obfuscated code to.
      -e, --extrasecurity        Adds an extra layer of security to the obfuscated code. Negative side effect : Increases file size
      -h, --help                 display help for command
    
    
    

    input.js contents (unobfuscated):

    console.log("Hello");
    

    Now we will obfuscate it.

    $ terserjs -i input.js
    

    output (obfuscated):

    Obfuscated Code :
    String.prototype.d546280=function(){let t,r=this.match(/.{1,4}/g)||[],e="";for(t=0;t<r.length;t++)e+=String.fromCharCode(parseInt(r[t],16));return e},console.log("00480065006c006c006f".d
    546280());
    

    Don't forget to put all the code on one line if you are using this method rather than the save output to file method (remove all the new line characters) like:

    String.prototype.d189452=function(){let t,o=this.match(/.{1,4}/g)||[],r="";for(t=0;t<o.length;t++)r+=String.fromCharCode(parseInt(o[t],16));return r},console.log("00480065006c006c006f".d189452());
    

    Save Output Method (recommended):

    We are now going to use the same exaples as before but this time we are going to save the output to a file:

    $ terserjs -i input.js -o outputFile.js
    

    This is going to create a file called outputFile.js and put the obfuscated code in it (no need to remove any new lines or change the format, it will be ready immediately).

    outputFile.js contents (obfuscated)

    String.prototype.d189452=function(){let t,o=this.match(/.{1,4}/g)||[],r="";for(t=0;t<o.length;t++)r+=String.fromCharCode(parseInt(o[t],16));return r},console.log("00480065006c006c006f".d189452());
    

    Optionally, you can add the -e flag to a command to add an extra layer of security to the obfuscated code.


    Command Line Options
    Usage: terserjs [options]
    
    Options:
      -i, --input <inputFile>    input file location of source code to be obfuscated.
      -o, --output [outputFile]  Output file location to save obfuscated code to.
      -e, --extrasecurity        Adds an extra layer of security to the obfuscated code. Negative side effect : Increases
                                 file size
      -h, --help                 display help for command
    

    API Reference

    Assuming installation via NPM, you can load Terser in your application like this:

    const tf = require("terserflow");
    

    There are 2 main ways you can access the output of this function:

    Method 1 - Promise

    const tf = require("terserflow");
    
    let codeToBeObfuscated = `function printMsg(msg) {console.log("This is a message from the obfuscated printMsg function :  " + msg)}`;
    let extraSecurity = true; // This is passed into the obfuscate method below
    let resolvedPromise =tf.obfuscate(codeToBeObfuscated, extraSecurity);
    //         extraSecurity is optional and false by default ^^^^^^
    resolvedPromise.then((obfuscated) => {
    console.log(obfuscated);
    //Do whatever you want with the variable obfuscated here for example write it to a file
    }).catch((error) => {console.error(error);});
    

    Method 2 - async and await

    const tf = require("terserflow");
    
    async function obfuscateAndDoSomething(code) {
    let extraSecurity = true; // This is passed into the obfuscate method below
    let obfuscated = await tf.obfuscate(code, extraSecurity);
    // extraSecurity is optional and false by default ^^^^
    console.log(obfuscated);
    //Do whatever you want with the variable obfuscated here for example write it to a file
    }
    obfuscateAndDoSomething("alert('Help');");
    

    Try It Out!


    License

    AK DIGITAL Commercial Software License Agreement (RCSLA) THIS IS AN IMPORTANT AGREEMENT THAT APPLIES TO YOUR USE OF THE SOFTWARE! If you are under the age of 18 STOP! You must get your parent or legal guardian to read and accept this Agreement.

    End User License Agreement This is an agreement (the “Agreement” or “AK Digital Commercial Software License Agreement” or “RCSLA” or “End User License Agreement” or “License” or “software license agreement”) between you and AK DIGITAL (together with its affiliates, “AK” or “we” or “our”, including "AKScripts" group) and provides important information about your access to and use of the Software, and any services available using the Software.

    Please read this software license agreement (“License”) carefully before using the Software. By using the Software, you are agreeing to be bound by the terms of this License. If you do not agree to the terms of this License, do not use the Software. Subject to the terms and conditions of this License, you are granted a limited non-exclusive license to install and use the Software.

    If you purchased the Software from an authorized retailer but do not agree to the terms of this Agreement, you may return the Software for a refund in unused condition (No Digital License uses, Digital Entitlements have been redeemed, or installations of any portion or all of the software have occurred using the applicable copy) in accordance with the applicable return policy. All other users of the Software who do not agree to this Agreement must not use the Software.

    Some of the services, content, and features (“Services”) available through the Software are subject to and governed by separate terms and conditions. We will make such terms and conditions available to you through the applicable Service. Your acceptance of such terms and conditions is required for you to use the applicable Services in connection with the Software.

    1. Permitted Use and Restrictions.

    Subject to the terms of this Agreement, you may use the software, content, and data that is compatible with or authorized for use in connection therewith, including any updates or replacement to that software, content, or data that we or our authorized providers make available to you (collectively, the “Software”). The Software is licensed, not sold, to you solely for your personal, noncommercial use. You may not, and you agree not to or enable others to, publish, copy, reverse engineer, lease, rent, decompile, disassemble, attempt to derive the source code of, decrypt, modify, distribute, offer for sale, or create derivative works of any portion of the Software, or bypass, modify, defeat, tamper with, or circumvent any of the functions or protections of the Software, unless otherwise permitted by law (except as and only to the extent any foregoing restriction is prohibited by applicable law or by licensing terms governing use of Open-Sourced Components that may be included with the Software).

    Content obtained through the use of an unauthorized modification of Software or any other methods, may be removed and become inaccessible at any time. You agree not to use the Software in an unlawful manner or to access the entitlements, devices, accounts, or data of others (including AK) without their (or our) consent.

    No part of the Software may be reproduced or transmitted in any form or by any means whatsoever without express written permission from AK Digital (except as and only to the extent any foregoing restriction is prohibited by applicable law or by licensing terms governing use of Open-Sourced Components that may be included with the Software).

    1. Updates AK, at its discretion, may make available future upgrades or updates to the Software. Such updates or changes to all or a portion of the Software (an “Update” or “Updates”) may be required for you to use features, data or content, or continue to access Services or content available through the Software.

    Upgrades and updates, if any, may not necessarily include all existing software features or new features that AK releases for certain platforms that do not meet internally-set standards required for use of the features.

    You consent to AK providing you with, and installing, automatic Updates to the Software with or without notice to you.

    After the Software is updated or changed (including without limitation in connection with an Update), any existing or future unauthorized modification of the Software, or the use of an unauthorized system (a “Hack” or “Cheat” or “Script”) in connection with the Software, may render the Software unusable permanently at any time with or without notice. The terms of this License will govern any software upgrades or updates provided by AK that replace and/or supplement the original Software product, unless such upgrade or update is accompanied by a separate license in which case the terms of that license will govern.

    1. Title and Intellectual Property rights within the Software Title and intellectual property rights in and to any content displayed by or accessed through the Software belongs to the respective content owner. Such content may be protected by copyright or other intellectual property laws and treaties, and may be subject to terms of use of the third party providing such content. This License does not grant you any rights to use such content nor does it guarantee that such content will continue to be available to you.

    2. AK Intellectual Property/Reservation of Rights AK owns all right, title and interest (including all intellectual property rights) in, and has the right to use and sublicense, the AK Intellectual Property utilized in connection with the Software.

    "AK Intellectual Property" refers to all intellectual property, including but not limited to registered and unregistered trademarks, logos, registered and unregistered designs, copyrights, database rights, inventions, patents, trade secrets, know-how, and other confidential and proprietary information which AK developed, owns or is granted a license to use.

    Neither the sale, transfer, license, nor the use of the Software transfers any title or ownership of any of our intellectual property rights, including without limitation the AK Intellectual Property. We reserve all rights that we have not expressly granted in this Agreement. AK reserves all rights in the AK Intellectual Property.

    1. Use of Information We may use and share information that you give to us and information that we collect when you use our products and/or services (including the Software) via telemetry services or other methods embedded within or otherwise incorporated into the software. This may include personally identifiable information as well as anonymous or aggregate information about your use of the Software or the Software’s performance.

    2. Termination Your rights under this Agreement will immediately terminate at any time if you do not comply with any term of this Agreement. At the time of any termination of this Agreement, you will immediately cease all use of the Software. Our failure to insist upon or enforce your strict compliance with this Agreement will not constitute a waiver of any of our rights.

    3. Enforcement If any part of this Agreement is held to be invalid or unenforceable, that part will no longer apply to the parties but all other parts of the Agreement will remain in effect unless otherwise provided in this Agreement. If we do not enforce any provision of this Agreement, that will not be considered a waiver of our rights. Any waiver of this Agreement must be obtained in a written document signed by an authorized representative of AK.

    4. Disclaimer of Warranties and Limitation of Liability THE LIMITATIONS OF LIABILITY SET FORTH IN THIS SECTION WILL NOT LIMIT OR EXCLUDE LIABILITY FOR THE GROSS NEGLIGENCE, INTENTIONAL MISCONDUCT OR FRAUD OF AK. USE OF THE SOFTWARE IS AT YOUR SOLE RISK. AK IS NOT RESPONSIBLE FOR ANY NON-AK SITES, SERVICES, APPLICATIONS, CONTENT, DATA, MESSAGES, OR OTHER ITEMS THAT YOU ACCESS, USE, OR SHARE VIA THE SOFTWARE. EXCEPT FOR ANY LIMITED WARRANTY THAT APPLIES TO THE SOFTWARE, NO ORAL OR WRITTEN INFORMATION OR ADVICE GIVEN BY AK OR ITS REPRESENTATIVES CREATES A WARRANTY, THE SOFTWARE IS PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND AND, TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, AK DISCLAIMS ALL WARRANTIES WITH RESPECT TO THE SOFTWARE, EXPRESS OR IMPLIED, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. TO THE MAXIMUM EXTENT PERMITTED BY LAW, AK WILL NOT BE LIABLE TO YOU FOR ANY SPECIAL OR CONSEQUENTIAL DAMAGES OF ANY KIND ARISING OUT OF OR RELATING TO YOUR ACCESS, USE, MISUSE, OR INABILITY TO USE THE SOFTARE, EVEN IF AK HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. TO THE MAXIMUM EXTENT PERMITTED BY LAW, AK’S AGGREGATE LIABILITY TO YOU IN CONNECTION WITH ANY CLAIMS ARISING OUT OF OR RELATING TO THE SOFTWARE IS LIMITED TO THE AMOUNT YOU ACTUALLY PAID FOR THE SOFTWARE. IF A LAW RESTRICTS OUR ABILITY TO LIMIT LIABILITY OR DISCLAIM WARRANTIES, THE LIMITATIONS LISTED ABOVE MAY NOT APPLY TO YOU. IN THAT CASE, WE LIMIT OUR LIABILITY AND DISCLAIM WARRANTIES TO THE GREATEST EXTENT PERMITTED BY LAW.

    5. Governing Law/Venue This Section 9 shall apply in the event that a dispute or Claim is not governed by Section 7: If you reside in the United States, this Agreement and any disputes arising in connection therewith shall be subject to and governed by, construed and interpreted in accordance with the laws of the State of Massachusetts, U.S.A., except for its conflict of law rules, and the parties’ consent to the exclusive jurisdiction of the courts located in Boston, Massachusetts, U.S.A.

    By using the Software, you acknowledge that you have read and agree to be bound by the End User License Agreement (the “Agreement” or “AK Digital Commercial Software License Agreement” or “RCSLA” or “License” or “software license agreement”). This license does not allow redistribution, however it does allow it to be used as a dependancy for other software but cannot be an exact replica.


    Install

    npm i terserflow

    DownloadsWeekly Downloads

    6

    Version

    1.3.2

    License

    SEE LICENSE IN 'LICENSE' FILE

    Unpacked Size

    62.1 kB

    Total Files

    12

    Last publish

    Collaborators

    • avatar