How to use jscrambler - 10 common examples

To help you get started, we’ve selected a few jscrambler examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jscrambler / jscrambler / packages / gulp-jscrambler / index.js View on Github external
break;
        }
      }

      if (file === null) {
        file = new File({
          cwd: options.cwd,
          path: path.join(options.cwd, filename)
        });
      }

      file.contents = buffer;
      self.push(file);
    };

    jScrambler.protectAndDownload(options, dest).then(function (protectionId) {
      self.emit('protectionId', protectionId);
      done(null);
    }).catch(function (error) {
      // need to emit in nextTick to avoid the promise catching a re-thrown error
      process.nextTick(done, error);
    });
  };
  return through.obj(aggregate, scramble);
github jscrambler / jscrambler / packages / ember-cli-jscrambler / jscrambler-plugin.js View on Github external
if (this.excludes.match(filename.slice(0, -4) + '.js')) {
          // ensure .map files for excldue JS paths are also copied forward
          symlinkOrCopy.sync(inFile, outFile);
        }
        // skip, because it will get handled when its corresponding JS does
      } else {
        symlinkOrCopy.sync(inFile, outFile);
      }
    });

    return res;
  }, []);

  const output = [];

  return jscrambler
    .protectAndDownload(
      Object.assign({}, this.options.jscrambler, {
        sources,
        stream: false,
        clientId: 5
      }),
      outputFiles => {
        outputFiles.forEach(file => {
          if (file.filename.slice(-4) !== '.map') {
            fs.writeFileSync(
              path.join(this.outputPath, file.filename),
              file.content
            );
          }
        });
github jscrambler / jscrambler / packages / jscrambler-webpack-plugin / src / index.js View on Github external
if (sourceMaps && /\.(js.map)$/.test(filename)) {
            const sourceMapContent = compilation.assets[filename].source();
            if (sourceMapContent) {
              sources.push({
                content: sourceMapContent,
                filename
              });
            }
          }
        });
      });

      if (sources.length > 0) {
        Promise.resolve(
          client.protectAndDownload(
            Object.assign(this.options, {
              sources,
              stream: false
            }),
            res => {
              this.protectionResult = res;
            }
          )
        )
          .then(protectionId =>
            this.processResult(protectionId, compilation, callback)
          )
          .catch(err => {
            callback(err);
          });
      } else {
github jscrambler / jscrambler / packages / ember-cli-jscrambler / jscrambler-plugin.js View on Github external
return new Promise((resolve, reject) =>
          jscrambler.downloadSourceMaps(
            Object.assign({}, jscrambler.config, {stream: false, protectionId}),
            (res, error) => {
              if (error) {
                console.error(error);
                return reject(error);
              }
              
              return this.processSourceMaps(res, this.outputPath, resolve);
            }
          ));
      }
github jscrambler / jscrambler / packages / ember-cli-jscrambler / jscrambler-plugin.js View on Github external
return new Promise((resolve, reject) =>
          jscrambler.downloadSourceMaps(
            Object.assign({}, jscrambler.config, {stream: false, protectionId}),
            (res, error) => {
              if (error) {
                console.error(error);
                return reject(error);
              }
              
              return this.processSourceMaps(res, this.outputPath, resolve);
            }
          ));
      }
github jscrambler / jscrambler / packages / jscrambler-metro-plugin / lib / index.js View on Github external
const {emptyDir, remove, mkdirp, readFile, writeFile} = require('fs-extra');
const jscrambler = require('jscrambler').default;
const commander = require('commander');
const fs = require('fs');
const path = require('path');

const BUNDLE_OUTPUT_CLI_ARG = '--bundle-output';

const JSCRAMBLER_TEMP_FOLDER = '.jscrambler';
const JSCRAMBLER_DIST_TEMP_FOLDER = `${JSCRAMBLER_TEMP_FOLDER}/dist/`;
const JSCRAMBLER_SRC_TEMP_FOLDER = `${JSCRAMBLER_TEMP_FOLDER}/src`;
const JSCRAMBLER_PROTECTION_ID_FILE = `${JSCRAMBLER_TEMP_FOLDER}/protectionId`;
const JSCRAMBLER_BEG_ANNOTATION = '"JSCRAMBLER-BEG";';
const JSCRAMBLER_END_ANNOTATION = '"JSCRAMBLER-END";';
const JSCRAMBLER_EXTS = /.(j|t)s(x)?$/i;

function getBundlePath() {
  commander.option(`${BUNDLE_OUTPUT_CLI_ARG} `).parse(process.argv);
github jscrambler / jscrambler / packages / ember-cli-jscrambler / jscrambler-plugin.js View on Github external
const jscrambler = require('jscrambler').default;
const Plugin = require('broccoli-plugin');
const defaults = require('lodash.defaultsdeep');
const memoize = require('lodash.memoize');
const walkSync = require('walk-sync');
const path = require('path');
const fs = require('fs');
const mkdirp = require('mkdirp');
const symlinkOrCopy = require('symlink-or-copy');
const MatcherCollection = require('matcher-collection');

const silent = process.argv.indexOf('--silent') !== -1;

const ensureDir = memoize(filename => {
  const p = path.dirname(filename);
  mkdirp.sync(p);
github jscrambler / jscrambler / packages / grunt-jscrambler / tasks / jscrambler.js View on Github external
/**
 * grunt-jscrambler
 * @author José Magalhães (magalhas@gmail.com)
 * @license MIT 
 */
'use strict';

var jscrambler = require('jscrambler').default;
var path = require('path');
var util = require('util');

module.exports = function (grunt) {
  grunt.registerMultiTask('jscrambler', 'Obfuscate your source files', function () {
    var done = this.async();
    var files = this.files;
    var options = this.options({
      keys: {},
      clientId: 4
    });

    options.filesSrc = this.filesSrc;

    function writeFile(buffer, file) {
      files.forEach(function (elem) {
github jscrambler / jscrambler / packages / gulp-jscrambler / index.js View on Github external
'use strict';
var defaults = require('lodash.defaults');
var File = require('vinyl');
var jScrambler = require('jscrambler').default;
var path = require('path');
var PluginError = require('plugin-error');
var through = require('through2');

module.exports = function (options) {
  options = defaults(options || {}, {
    cwd: process.cwd(),
    filesSrc: [],
    keys: {},
    clientId: 3
  });

  var aggregate = function (file, enc, next) {
    if (file.isBuffer()) {
      options.filesSrc.push(file);
    }
github jscrambler / jscrambler / packages / jscrambler-webpack-plugin / src / index.js View on Github external
const client = require('jscrambler').default;
const {SourceMapSource} = require('webpack-sources');

const sourceMaps = !!client.config.sourceMaps;

class JscramblerPlugin {
  constructor(_options) {
    let options = _options;
    if (typeof options !== 'object' || Array.isArray(options)) options = {};

    this.options = Object.assign(options, {
      clientId: 2
    });

    this.processResult = this.processResult.bind(this);
    this.processSourceMaps = this.processSourceMaps.bind(this);
  }

jscrambler

Jscrambler API client.

MIT
Latest version published 7 days ago

Package Health Score

75 / 100
Full package analysis