Git Product home page Git Product logo

Comments (19)

I-NOZex avatar I-NOZex commented on May 11, 2024 1

Yes, sorry didn't replied earlier

from javascript-obfuscator.

sanex3339 avatar sanex3339 commented on May 11, 2024

Hi, show me your source code

from javascript-obfuscator.

I-NOZex avatar I-NOZex commented on May 11, 2024

Hi, thank you for your reply.
my build task is this:

'use strict';

var gulp = require('gulp');
var babel = require('gulp-babel');
var sourcemaps = require('gulp-sourcemaps');
var less = require('gulp-less');
var sass = require('gulp-sass');

var jetpack = require('fs-jetpack');

var utils = require('./utils');

var projectDir = jetpack;
var srcDir = projectDir.cwd('./app');
var destDir = projectDir.cwd('./build');

var javascriptObfuscator = require('gulp-javascript-obfuscator');

var paths = {
    jsCodeToTranspile: [
        'app/**/*.js',
        '!app/js/communication/server_files/**',
        '!app/node_modules/**',
        '!app/vendor/**'
    ],
    jsCodeToObfuscate: [
        'build/**/*.js',
        '!build/js/communication/server_files/**',
        '!build/node_modules/**',
        '!build/vendor/**'
    ],	
    copyFromAppDir: [
        //'./node_modules/**',
        './js/communication/server_files/**',
        './vendor/**',
        './fonts/**',
        './welcome/**',
        './locales/**',
        './*.html',
        './stylesheets/*.css',
        './*.rtf'
    ],
	copyFromAppDirAll: [
		'./node_modules/**',
        './js/communication/server_files/**',
        './vendor/**',
        './fonts/**',
		'./locales/**',
        './welcome/**',
        './*.html',
        './stylesheets/*.css',
        './*.rtf'
	]
}

// -------------------------------------
// Tasks
// -------------------------------------

gulp.task('clean', function(callback) {
    return destDir.dirAsync('.', { empty: true });
});



var copyTask = function () {
    projectDir.copy('resources/icon.png', destDir.path('icon.png'), { overwrite: true });

	
	function fallbackCopy(){
		return projectDir.copyAsync('app', destDir.path(), {
        overwrite: true,
        matching: paths.copyFromAppDirAll
    });
		/*projectDir.copy('app', destDir.path(), {
			overwrite: true,
			matching: ['./node_modules/**']
		});*/
	}
		
		
	if((process.platform === 'win32') && (utils.getEnvName()!=="production")){
		var vfs = require('vinyl-fs');
		vfs.src('app/node_modules/', {followSymlinks: false})
			.pipe(vfs.symlink('build/node_modules'))
			.on('error', fallbackCopy);
    } else {
      return fallbackCopy();
    }
	
	
	return projectDir.copyAsync('app', destDir.path(), {
        overwrite: true,
        matching: paths.copyFromAppDir
    });
	
	
	/*function fallbackCopy(){
		return projectDir.copyAsync('app', destDir.path(), {
			overwrite: true,
			matching: ['./node_modules/**']
		});
	}
	var vfs = require('vinyl-fs');
	vfs.src('app/node_modules/', {followSymlinks: false})
		.pipe(vfs.symlink('build/node_modules'))
		.on('error', fallbackCopy);*/
};
gulp.task('copy', ['clean'], copyTask);
gulp.task('copy-watch', copyTask);

var transpileTask = function () {
    return gulp.src(paths.jsCodeToTranspile)
    .pipe(sourcemaps.init())
    .pipe(babel({ modules: 'amd' }))
    .pipe(sourcemaps.write('.'))
    .pipe(javascriptObfuscator())	
    .pipe(gulp.dest(destDir.path())).on('end', function() { 
		require('gulp-util').beep(); 
		require('child_process').exec("msg  'Done ;)'");
	});
};
gulp.task('transpile', ['clean'], transpileTask);
gulp.task('transpile-watch', transpileTask);


var obfuscateTask = function () {
    return gulp.src(paths.jsCodeToObfuscate)
    .pipe(javascriptObfuscator())	
    .pipe(gulp.dest(destDir.path())).on('end', function() { 
		require('gulp-util').beep(); 
		require('child_process').exec("msg  'Done ;)'");
	});
};
gulp.task('obfuscateTask', ['transpile'], obfuscateTask);


/*
var lessTask = function () {
    return gulp.src('app/stylesheets/main.less')
    .pipe(less())
    .pipe(gulp.dest(destDir.path('stylesheets')));
};*/
//Minify and transpile Sass files into css
var sassTask = function () {
  gulp.src('app/stylesheets/main.scss')
    .pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError))
	//.pipe(rename({ suffix: '.min' }))
    .pipe(gulp.dest(destDir.path('stylesheets')));
	
  gulp.src('app/vendor/hubing_ui/sass/style.scss')
    .pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError))
	//.pipe(rename({ suffix: '.min' }))
    .pipe(gulp.dest(destDir.path('vendor/hubing_ui/stylesheets')));	
};

var less2Task = function() {
	return gulp.src('app/js/communication/server_files/css/*.less')
    .pipe(less())
    .pipe(gulp.dest(destDir.path('js/communication/server_files/css')));
}

gulp.task('sass', ['clean','copy'], sassTask);
gulp.task('sass-watch', sassTask);

gulp.task('less2', ['clean'], less2Task);
gulp.task('less2-watch',less2Task);


//generate icons// -------------------------------------
var iconfont = require('gulp-iconfont');
var runTimestamp = Math.round(Date.now()/1000);

gulp.task('Iconfont', ['clean'], function(){
	var async = require('async'),
	iconfont = require('gulp-iconfont'),
	consolidate = require('gulp-consolidate'),
	rename = require('gulp-rename');

  var iconStream = gulp.src(['app/icons/*.svg'])
    .pipe(iconfont({ fontName: 'PROJECT_NAMEfonticon', formats: ['woff'], normalize: true/*, fontHeight: 1001 */}));

  async.parallel([
    function handleGlyphs (cb) {
      iconStream.on('glyphs', function(glyphs, options) {
        gulp.src('app/icons/tpl.css')
          .pipe(consolidate('lodash', {
            glyphs: glyphs,
            fontName: 'PROJECT_NAMEfonticon',
            fontPath: '',
            className: 'icon'
          }))
		  .pipe(rename({ basename: 'PROJECT_NAMEfonticon' }))
          .pipe(gulp.dest(destDir.path('icons')))
		  .pipe(gulp.dest(destDir.path('js/communication/server_files/fonts')))

        gulp.src('app/icons/tpl.json')
          .pipe(consolidate('lodash', {
            glyphs: glyphs,
            fontName: 'PROJECT_NAMEfonticon',
            fontPath: '',
            className: 'icon'
          }))
		  .pipe(rename({ basename: 'PROJECT_NAMEfonticon' }))
          .pipe(gulp.dest(destDir.path('icons')))
		  .pipe(gulp.dest(destDir.path('js/communication/server_files/fonts')))

        gulp.src('app/icons/tpl_.json')
          .pipe(consolidate('lodash', {
            glyphs: glyphs,
            fontName: 'PROJECT_NAMEfonticon',
            fontPath: '',
            className: 'icon'
          }))
		  .pipe(rename({ basename: 'PROJECT_NAMEfonticon_' }))
          .pipe(gulp.dest(destDir.path('icons')))
		  .pipe(gulp.dest(destDir.path('js/communication/server_files/fonts')))

		if(utils.getEnvName() === 'development')
			gulp.src('app/icons/tpl.html')
			  .pipe(consolidate('lodash', {
				glyphs: glyphs,
				fontName: 'PROJECT_NAMEfonticon',
				fontPath: './',
				className: 'icon'
			  }))
			  .pipe(rename({ basename: 'PROJECT_NAMEfonticon' }))
			  .pipe(gulp.dest(destDir.path('icons')))
			  .pipe(gulp.dest(destDir.path('js/communication/server_files/fonts')))
			  .on('finish', cb);
      });
    },
    function handleFonts (cb) {
      iconStream
        .pipe(gulp.dest(destDir.path('icons')))
		.pipe(gulp.dest(destDir.path('js/communication/server_files/fonts')))
        .on('finish', cb);
    }
  ]);
});

// Add and customize OS-specyfic and target-specyfic stuff.
gulp.task('finalize', ['clean'], function () {
    var manifest = srcDir.read('package.json', 'json');
    switch (utils.getEnvName()) {
        case 'production':
            // Hide dev toolbar if doing a release.
            manifest.window.toolbar = false;
            break;
        case 'test':
            // Add "-test" suffix to name, so NW.js will write all
            // data like cookies and locaStorage into separate place.
            manifest.name += '-test';
            // Change the main entry to spec runner.
            manifest.main = 'spec.html';
            break;
        case 'development':
            // Add "-dev" suffix to name, so NW.js will write all
            // data like cookies and locaStorage into separate place.
            manifest.name += '-dev';
            break;
    }
    destDir.write('package.json', manifest);

    var configFilePath = projectDir.path('config/env_' + utils.getEnvName() + '.json');
    destDir.copy(configFilePath, 'env_config.json');
});


gulp.task('watch', function () {
    gulp.watch(paths.jsCodeToTranspile, {
        interval: 1000, // default 100
        debounceDelay: 500, // default 500
        mode: 'poll'
    },['transpile-watch']);
    gulp.watch('app/stylesheets/*.scss', ['sass-watch']);
	gulp.watch('app/js/communication/server_files/css/*.less',['less2-watch']);
    gulp.watch(paths.copyFromAppDir, { cwd: 'app' }, ['copy-watch']);
	
});


gulp.task('build', ['transpile', 'sass', 'copy', 'less2', 'Iconfont','obfuscateTask', 'finalize']);

ps: this is a NWJS app

from javascript-obfuscator.

sanex3339 avatar sanex3339 commented on May 11, 2024

Not gulpfile.js but your source code that you obfuscating.

This file:

require, module, __filename, __dirname) { var Module;if(!Module)Module=(typeof Module!=="undefined"?Module:null)||{};var moduleOverrides={};for(var key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}var ENVIRONMENT_IS_WEB=typeof window==="object";var ENVIRONMENT_IS_WORKER=typeof importScripts==="function";var ENVIRONMENT_IS_NODE=typeof process==="object"&&typeof require==="function"&&!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_WORKER;var ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER;if(ENVIRONMENT_IS_NODE){if(!Module["print"])Module["print"]=function print(x){process["stdout"].write(x+"\n")};if(!Module["printErr"])Module["printErr"]=function printErr(x){process["stderr"].write(x+"\n")};var nodeFS=require("fs");var nodePath=require("path");Module["read"]=function read(filename,binary){filename=nodePath["normalize"](filename);var ret=node Error

from javascript-obfuscator.

sanex3339 avatar sanex3339 commented on May 11, 2024

can you upload it here?
https://gist.github.com/

from javascript-obfuscator.

I-NOZex avatar I-NOZex commented on May 11, 2024

sure, here it is

https://gist.github.com/I-NOZex/eae26df81fb642de5ec689b4e07ec0ee

from javascript-obfuscator.

sanex3339 avatar sanex3339 commented on May 11, 2024

It's strange because this code obfuscating ok with https://javascriptobfuscator.herokuapp.com/

from javascript-obfuscator.

sanex3339 avatar sanex3339 commented on May 11, 2024

What version of javascript-obfuscator you using? (check package.json under node_modules/javascript-obfuscator or node_modules/gulp-javascript-obfuscator/node_modules/javascript-obfuscator

from javascript-obfuscator.

I-NOZex avatar I-NOZex commented on May 11, 2024

exactly, i've already tested...
it could be some sort of conflict with babel? :/

from javascript-obfuscator.

sanex3339 avatar sanex3339 commented on May 11, 2024

I don't know. Right way is to use obfuscator after babel, it should accepts any valid es5/es6 code

from javascript-obfuscator.

I-NOZex avatar I-NOZex commented on May 11, 2024

it's what i'm doing...
the gulp obfuscator module version is "1.1.2"
obfuscator module dependency version is "0.9.4"

from javascript-obfuscator.

sanex3339 avatar sanex3339 commented on May 11, 2024

Try to get source code after transpiling with babel and paste it here
https://javascriptobfuscator.herokuapp.com/

If it will obfuscating without errors - try to make issue here:
https://github.com/javascript-obfuscator/gulp-javascript-obfuscator/issues

from javascript-obfuscator.

I-NOZex avatar I-NOZex commented on May 11, 2024

from javascript-obfuscator.

sanex3339 avatar sanex3339 commented on May 11, 2024

You 100% sure that babel task was running before obfuscation task and not after?

from javascript-obfuscator.

I-NOZex avatar I-NOZex commented on May 11, 2024

well yes, my obfuscate task has a depedency on transpile task

var transpileTask = function () {
    return gulp.src(paths.jsCodeToTranspile)
    .pipe(sourcemaps.init())
    .pipe(babel({ modules: 'amd' }))
    .pipe(sourcemaps.write('.'))
    .pipe(gulp.dest(destDir.path())).on('end', function() { 
		require('gulp-util').beep(); 
		require('child_process').exec("msg 'Done ;)'");
	});
};
gulp.task('transpile', ['clean'], transpileTask);
gulp.task('transpile-watch', transpileTask);


var obfuscateTask = function () {
    return gulp.src(paths.jsCodeToObfuscate)
    .pipe(javascriptObfuscator())	
    .pipe(gulp.dest(destDir.path())).on('end', function() { 
		require('gulp-util').beep(); 
		require('child_process').exec("msg 'Done ;)'");
	});
};
gulp.task('obfuscateTask', ['transpile'], obfuscateTask);

from javascript-obfuscator.

sanex3339 avatar sanex3339 commented on May 11, 2024

So it's very strange.

Line 1: Unexpected token : at ErrorHandler.constructError

Error message pointed on strange symbol : that AST parser esprima can't parse.
esprima should correctly parse any valid es5 and es2015/es2016 code, so it looks like input code for javascript-obfuscator and esprima not a valid es5/es2015/es2016 code

from javascript-obfuscator.

I-NOZex avatar I-NOZex commented on May 11, 2024

i've managed to make it work, i created an auxiliar folder to put the transpiled files, and the use those folder to obfuscate and copy to the final build path

from javascript-obfuscator.

sanex3339 avatar sanex3339 commented on May 11, 2024

I can close issue then?

from javascript-obfuscator.

lock avatar lock commented on May 11, 2024

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

from javascript-obfuscator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.