Saves all JS modules of an app as a single file, separated with null bytes.
The file begins with an offset table that contains module ids and their
lengths/offsets.
The module id for the startup code (prelude, polyfills etc.) is the
empty string.
485011
function saveAsIndexedFile(
  bundle: Bundle,
  options: OutputOptions,
  log: (x: string) => void,
): Promise<> {
  const {
    bundleOutput,
    bundleEncoding: encoding,
    sourcemapOutput,
    sourcemapSourcesRoot,
  } = options;

  log('start');
  const {startupModules, lazyModules, groups} = bundle.getUnbundle();
  log('finish');

  const moduleGroups = createModuleGroups(groups, lazyModules);
  const startupCode = joinModules(startupModules);

  log('Writing unbundle output to:', bundleOutput);
  const writeUnbundle = writeBuffers(
    fs.createWriteStream(bundleOutput),
    buildTableAndContents(startupCode, lazyModules, moduleGroups, encoding)
  ).then(() => log('Done writing unbundle output'));

  const sourceMap =
    relativizeSourceMap(
      buildSourceMapWithMetaData({
        startupModules: startupModules.concat(),
        lazyModules: lazyModules.concat(),
        moduleGroups,
      }),
      sourcemapSourcesRoot
    );

  return Promise.all([
    writeUnbundle,
    sourcemapOutput && writeSourceMap(sourcemapOutput, JSON.stringify(sourceMap), log),
  ]);
}
435576
function storeFileToDisk(i_oFile, i_sOutput) {
    var l_sDirname = path.dirname(i_oFile.filename),
        l_sFilename;

    console.log("File name: ", i_oFile.filename, " size: ", i_oFile.header.unpackedSize);
    console.log("Saving content of file ");

    l_sDirname = path.join(i_sOutput, path.dirname(i_oFile.filename));
    l_sFilename = path.join(l_sDirname, path.basename(i_oFile.filename));
    return new Promise(function(i_oResolve) {
        mkdirp(l_sDirname, function (err) {
            if (err) console.error(err);
            _writeFile(l_sFilename, i_oFile, i_oResolve);
        });
    });
}
695085
function (file)
		{
			if (!_.isString(file))
				return false;

			var file = file+'';
			this.e.log&&this.e.log('Loading module configuration from file: '+file,'system');
			if (fs.statSync(file).isFile() && path.extname(file) == '.json')
			{
				var _data = (fs.readFileSync(file,'utf8').toString())
							.replace(/\\/g,function () { return "\\"+arguments[0]; })
							.replace(/\/\/.+?(?=\n|\r|$)|\/\*[\s\S]+?\*\//g,'');
				if(_data = JSON.parse(_data))
				{
					this.setConfig(_data,true);
					return true;
				}
			}
			return false;
		
		}
1031197
function(moduleDir, packageJson) {
      var t = this,
          resolved = null,
          templates = t.get('templates');

      // Remove the -monitor portion of the app
      var appName = packageJson.name.replace(/-monitor$/,'');

      // Don't overwrite a more "locally" defined app
      if (t.apps[appName]) {
        return false;
      }

      // The app module must be found
      try {
        resolved = require.resolve(moduleDir);
      } catch (e) {
        console.error("Problem loading plug-in: " + moduleDir, e);
        return false;
      }

      // Clear module cache for reloads
      log.info('Loading app ' + appName + ' from ' + moduleDir);
      delete require.cache[resolved];

      // Load the module
      var server;
      try {
        server = require(resolved);
      } catch (e) {
        console.error('Problem loading the "' + appName + '" module: ', e.stack);
        return false;
      }

      var views = {}, // key: view name, value: {icon:'iconfile'}
          css = [],
          images = {}, // key: basename, value: filename
          appPath = '/app/' + appName + '/';

      // Add extensions
      try {
        FS.readdirSync(moduleDir + '/lib/ext').sort().forEach(function(filename) {
          var ext = Path.extname(filename).toLowerCase();
          var base = Path.basename(filename, ext);
          if (ext === '.js') {
            PAGE_PARAMS.scripts += JS_TEMPLATE({scriptFile: appPath + 'ext/' + filename});
          }
        });
      } catch (e) {
        if (e.code !== 'ENOENT') {
          console.error('Error reading ' + moduleDir + '/lib/ext', e);
        }
      }

      // Gather views to expose on the page
      try {
        FS.readdirSync(moduleDir + '/lib/view').sort().forEach(function(filename) {
          var ext = Path.extname(filename).toLowerCase();
          var base = Path.basename(filename, ext);
          if (ext === '.js') {
            views[base] = '';
            PAGE_PARAMS.scripts += JS_TEMPLATE({scriptFile: appPath + 'view/' + filename});
          }
        });
      } catch (e) {
        if (e.code !== 'ENOENT') {
          console.error('Error reading ' + moduleDir + '/lib/view', e);
        }
      }

      // Gather CSS to expose on the page
      try {
        FS.readdirSync(moduleDir + '/lib/css').sort().forEach(function(filename) {
          var ext = Path.extname(filename).toLowerCase();
          var base = Path.basename(filename, ext);
          if (ext === '.css') {
            css.push(filename);
            PAGE_PARAMS.styles += CSS_TEMPLATE({cssFile: appPath + 'css/' + filename});
          }
        });
      } catch (e) {
        if (e.code !== 'ENOENT') {
          console.error('Error reading ' + moduleDir + '/lib/css', e);
        }
      }

      // Gather templates to expose
      try {
        FS.readdirSync(moduleDir + '/lib/template').sort().forEach(function(filename) {
          var ext = Path.extname(filename).toLowerCase();
          var base = Path.basename(filename, ext);
          if (ext === '.html') {
            templates.add({id:appName + '-' + base, path:moduleDir + '/lib/template/' + filename});
          }
        });
      } catch (e) {
        if (e.code !== 'ENOENT') {
          console.error('Error reading ' + moduleDir + '/lib/template', e);
        }
      }

      // Gather images
      try {
        FS.readdirSync(moduleDir + '/lib/image').sort().forEach(function(filename) {
          var ext = Path.extname(filename).toLowerCase();
          var base = Path.basename(filename, ext);
          if (ext.match('\\.jpg|\\.jpeg|\\.ico|\\.bmp|\\.tif|\\.tiff|\\.gif')) {
            images[base] = appPath + 'image/' + filename;
          }
        });
      } catch (e) {
        if (e.code !== 'ENOENT') {
          console.error('Error reading ' + moduleDir + '/lib/image', e);
        }
      }

      // Match views to their icon image (if available)
      for (var viewName in views) {
        views[viewName] = {icon: images[viewName]};
      }

      // Record app information
      t.apps[appName] = {
        label: packageJson.label,
        description: packageJson.description,
        moduleDir: moduleDir,
        server: server,
        staticServer: Connect['static'](Path.join(moduleDir, '/view')),
        views: views,
        css: css
      };

      return appName;

    }
198197
function inits() {
  log( "init", "step="+step+" ajaxOngoing="+ajaxOngoing );
  if ( getParam( 'nc' ) == 'true' ) {
    noCache = "?nc="+ Math.random();
  }

  if ( ajaxOngoing == 0 ) { 
    if ( step == "load-lang" ) {
      ajaxOngoing++;
      log( 'init', 'Start to load module list...');
      loadLang();
      step = "loadmodulemap";
    } else if ( step == "loadmodulemap" ) {
      ajaxOngoing++;
      log( 'init', 'Start to load module list...');
      loadModuleList();
      step = "loaddecor";
    } else if ( step == "loaddecor" ) {
      ajaxOngoing++;
      log( 'init', 'Start to load decor config...');
      loadDecorList();
      step = "loadstructure";
    } else  if ( step == "loadstructure" ) {
      ajaxOngoing++;
      log( 'init', 'Load Structure File ...');
      loadStructure();
      step = "loadincludes";
    } else if ( step == "loadincludes" ) {
      ajaxOngoing++;
      log( 'init', 'Start to load include JS modules ...');
      checkModules( );
      loadIncludes();
      step = "loadmodules";
    } else if ( step == "loadmodules" ) {
      ajaxOngoing++;
      log( 'init', 'Start to load JS modules ...');
      loadModules();
      if ( layout.theme != null ) {
        loadCSSrelPath( 'css-custom/'+layout.theme+'.css' );
        //jQuery('head').append('<link rel="stylesheet" rel="nofollow" href="css-custom/'+layout.theme+'.css" type="text/css" />');        
      }
      loadCSSrelPath( "css-custom/custom.css" );
      if ( pageInfo["layoutMode"] == 'tablet' ) {
        loadCSSrelPath( "css-custom/custom-t.css" );
        //jQuery('head').append('<link rel="stylesheet" rel="nofollow" href="css-custom/custom-t.css" type="text/css" />');        
      } else if ( pageInfo["layoutMode"] == 'mobile' ) {
        loadCSSrelPath( "css-custom/custom-m.css" );
        //jQuery('head').append('<link rel="st<ylesheet" rel="nofollow" href="css-custom/custom-m.css" type="text/css" />');
      } 
      step = "initmodules";
    } else  if ( step == "initmodules" ) {
      ajaxOngoing++;
      log( 'init', 'Load Structure File ...');
      initModules( layout );
      step = "buildstructure";
    } else  if ( step == "buildstructure" ) {
      ajaxOngoing++;
      log( 'init', 'Start to build HTML ...');
      buildStructure( layout );
      step = "loadres-ht";
    } else  if ( step == "loadres-ht" ) {
      ajaxOngoing++;
      log( 'init', 'Start to load resources HTML ...');
      loadResourcesHT();
      step = "call-hooks";
    } else  if ( step == "call-hooks" ) {
      log( 'init', 'Call module hooks ...');
      callHooks();
      step = "loadres-js";
    } else  if ( step == "loadres-js" ) {
      ajaxOngoing++;
      log( 'init', 'Start to load resources JS ...');
      loadResourcesJS();
      step = "callbacks";
    } else  if ( step == "callbacks" ) {
      log( 'init', 'Start callback methods for resources...');
      resourceCallbacks();
      step = "dialogs";
    } else  if ( step == "dialogs" ) {
      log( 'init', 'Start load dialogs for resources...');
      resourceDialogs();
      step = "afterInit";
    } else  if ( step == "afterInit" ) {
      log( 'init', 'Start load dialogs for resources...');
      startModulesAfterPageLoad( layout );
      clearInterval( initTimerId );
      step = "done";
    }
  }  
}
962604
function loadJsFile(file) {
    var modId = path.basename(file).slice(0, -3);
    var mod = require(file);
    modulePath[modId] = file;
    mod.__id = modId;
    return mod;
}
1340292
function (module_name, module_folder) {
    var module_path = path.resolve(module_folder);

    // load current keystore
    let keystored = {};
    const filename = ".iotdb/keystore.json";
    _.cfg.load.json([ filename ], docd => keystored = _.d.compose.deep(keystored, docd.doc));

    // change it
    _.d.set(keystored, "/modules/" + module_name, module_path)

    // save it
    fs.writeFile(filename, JSON.stringify(keystored, null, 2));

    console.log("- installed homestar module!");
    console.log("  name:", module_name);
    console.log("  path:", module_path);
}
1118398
function jsCompile(content, file)
{
  // make it as a child of this module
  // Would be nice to actually make it transparent
  // and pretend it to be child of the caller module
  // but there is no obvious way, yet
  var jsMod = new Module(file, module);

  // override parents to exclude configly from the chain
  // it's like this js file is included directly
  // from the file that included `configly`
  while (jsMod.parent
    && typeof jsMod.parent.id === 'string'
    && jsMod.parent.id.match(/\/node_modules\/configly\//)
    && jsMod.parent.parent) {
    /* istanbul ignore next */
    jsMod.parent = jsMod.parent.parent;
  }

  // generate node_modules paths for the file
  jsMod.paths = Module._nodeModulePaths(path.dirname(file));

  // execute the module
  jsMod._compile(content, file);
  // return just exported object
  return jsMod.exports;
}
816576
public <T extends SourceFile> void initModules(
      List<T> externs, List<JSModule> modules, CompilerOptions options) {
    initOptions(options);

    checkFirstModule(modules);

    this.externs = makeExternInputs(externs);

    // Generate the module graph, and report any errors in the module specification as errors.
    try {
      this.moduleGraph = new JSModuleGraph(modules);
    } catch (JSModuleGraph.ModuleDependenceException e) {
      // problems with the module format.  Report as an error.  The
      // message gives all details.
      report(JSError.make(MODULE_DEPENDENCY_ERROR,
          e.getModule().getName(), e.getDependentModule().getName()));
      return;
    }

    // Creating the module graph can move weak source around, and end up with empty modules.
    fillEmptyModules(getModules());

    this.commentsPerFile = new ConcurrentHashMap<>(moduleGraph.getInputCount());
    initBasedOnOptions();

    initInputsByIdMap();

    initAST();
  }
735610
function(file) {
        var self = this;

        var ext;

        if (!self._options.keepExtension) {
            ext = self._options.extension || path.extname(file);
        }

        var fileName = path.basename(file, ext);

        if (self._options.format) {
            var formatRegex = self._options.format[0].split('/');
            formatRegex = new RegExp(formatRegex[1], formatRegex[2]);

            var replaceValue = self._options.format[1];

            fileName = fileName.replace(formatRegex, replaceValue);
        }

        var moduleConfig = {
            name: '',
            version: '1.0.0'
        };

        if (self._options.moduleConfig) {
            if (typeof self._options.moduleConfig === 'string') {
                var fileModuleConfig = path.resolve(self._options.moduleConfig);

                if (fs.existsSync(fileModuleConfig)) {
                    moduleConfig = require(fileModuleConfig);
                }
            } else {
                moduleConfig = self._options.moduleConfig;
            }
        }

        fileName = path.join(path.dirname(file), fileName);

        var moduleName = '';

        if (moduleConfig.name) {
            moduleName = moduleConfig.name + '@' + moduleConfig.version;
        }

        moduleName = path.join(moduleName, fileName.substring(self._options.moduleRoot.length));

        if (self._options.lowerCase) {
            moduleName = moduleName.toLowerCase();
        }

        return upath.toUnix(moduleName);
    }
645309
function showHelp() {
  var hlp = [
    '',
    '  Usage: \x1B[1mjspp\x1B[0m [options] [file...]',
    '',
    '    Tiny C-style source file preprocessor for JavaScript, with duplicate',
    '    empty lines and comments remover.',
    '',
    '    If no file name are given, jspp reads from the standard input.',
    '',
    '  Options:',
    '',
    '    -D, --set       add a variable for use in expressions (e.g. -D NAME=value)',
    '                    type: string - e.g. -D "MODULE=1"',
    '    --header1       text to insert before the top level file.',
    '                    type: string - default: ' + JSON.stringify(defaults.header1),
    '    --headers       text to insert before each included file.',
    '                    type: string - default: ' + JSON.stringify(defaults.headers),
    '    --indent        indentation to add before each line of the included files.',
    '                    The format matches the regex /^\\d+\\s*[ts]?/, e.g. "1t", ',
    '                    where \'t\' means tabs and \'s\' spaces, default is spaces.',
    '                    Each level adds indentation.',
    '                    type: string - default: ' + JSON.stringify(defaults.indent),
    '    --eol-type      normalize end of lines to "unix", "win", or "mac" style',
    '                    type: string - default: ' + JSON.stringify(defaults.eolType),
    '    --empty-lines   how much empty lines keep in the output (-1: keep all)',
    '                    type: number - default: ' + JSON.stringify(defaults.emptyLines),
    '    -C, --comments  treatment of the comments, one of:',
    '                    "all": keep all, "none": remove all, "filter": apply filter',
    '                    type: string - default: ' + JSON.stringify(defaults.comments),
    '    -F, --filter    keep comments matching filter. "all" to apply all filters,',
    '                    or one or more of:',
    '                    ' + Object.keys(Options.filters).join(', '),
    '    --custom-filter string for create a regex as custom filter to apply with',
    '                    regex.test(). must return true to keep the comment.',
    '                    type: string - e.g. --custom-filter "\\\\\* @module"',
    '    -V, --version   print version to stdout and exits.',
    '    -h, --help      display this message.',
    '',
    '  Tips:',
    '    Use "^n" in the header1 and headers option values to insert line feeds.',
    '    You can preprocess files other than JavaScript using --comments all.',
    '',
    '',
    '  Clone the jspreproc repository at https://github.com/aMarCruz/jspreproc.git',
    '  run `npm i && npm t`, and find examples of use in spec/app-spec.js',
    ''
  ]
  console.log(hlp.join('\n'))
}
1100463
function entrifyFromPkg(dir, options) {

  // Find package.json files.
  const pkgPaths = glob.sync('**/package.json', { cwd: dir, nodir: true, absolute: true })

  pkgPaths.forEach((pkgPath) => {
    console.log('[entrify]', 'Found:', pkgPath)
    const pkg = require(pkgPath)

    // A package.json file should have a main entry.
    if (!pkg.main) {
      console.warn('[entrify]', pkgPath, 'does not have a main entry.')
      return
    }

    // The main entry should not point to an index.js file.
    if (pkg.main === 'index.js' || pkg.main === './index.js') {
      console.warn('[entrify]', pkgPath, 'main entry is index.js.')
      return
    }

    // Ensure the index.js file to create doesn't already exist.
    const pkgDir = path.dirname(pkgPath)
    const indexPath = `${pkgDir}/index.js`

    if (fs.existsSync(indexPath)) {
      console.warn('[entrify]', indexPath, 'already exists.')
      return
    }

    // Create an index.js file alongside the package.json.
    const name = camelize(path.basename(pkgDir))
    const main = pkg.main.startsWith('./') ? pkg.main : `./${pkg.main}`

    fs.writeFileSync(indexPath, indexTemplate(options.format, { name, main }))
    console.log('[entrify]', indexPath, 'created!')

    // Delete the package.json file.
    fs.unlinkSync(pkgPath)
    console.log('[entrify]', pkgPath, 'deleted!')
  })
}
239809
function(str){
    var match = str.split(':');

    var module_id = match[0];
    var module_instance = match[1];

    var instance = [];

    if(this.sid && this.options.instance_through) instance.push(this.sid);
    if(this.instance && this.options.instance_through) instance.push(this.instance);
    if(module_instance) instance.push(module_instance);

    var info = {
      filename: mid.path(module_id, this.options),
      instance: instance.join('-')
    };

    return info;
  }
373874
function jscmd(file, type, line, express, start, offset) {
      var storage;
      switch (type) {
        case 'init':
          storage = [];
          for (var i = 0; i < line.length; i ++) {
            storage[line[i]] = 0;
          }
          var condition = express;
          var source = start;
          storage.condition = condition;
          storage.source = source;
          cov[file] = storage;
          break;
        case 'line':
          storage = cov[file];
          storage[line] ++;
          break;
        case 'cond':
          storage = cov[file];
          storage.condition[line] ++;
          return express;
      }
    }
731724
function toFiles(app, options) {
  let opts = Object.assign({ collection: null }, options);
  let name = opts.collection;
  let collection = app.collections ? name && app[name] : app;
  let view;

  if (!collection && name) {
    collection = app.create(name, opts);
  }

  return utils.through.obj(async (file, enc, next) => {
    if (!app.File.isFile(file)) {
      file = app.file(file.path, file);
    }

    if (file.isNull()) {
      next(null, file);
      return;
    }

    if (collection && isCollection(collection)) {
      try {
        view = await collection.set(file.path, file);
      } catch (err) {
        next(err);
        return;
      }
      next(null, view);
      return;
    }

    view = !app.File.isFile(file) ? app.file(file.path, file) : file;

    app.handle('onLoad', view)
      .then(() => next(null, view))
      .catch(next);
  });
}
863136
function initModule(forge) {

// shortcut for PKCS#1 API
var pkcs1 = forge.pkcs1 = forge.pkcs1 || {};

/**
 * Encode the given RSAES-OAEP message (M) using key, with optional label (L)
 * and seed.
 *
 * This method does not perform RSA encryption, it only encodes the message
 * using RSAES-OAEP.
 *
 * @param key the RSA key to use.
 * @param message the message to encode.
 * @param options the options to use:
 *          label an optional label to use.
 *          seed the seed to use.
 *          md the message digest object to use, undefined for SHA-1.
 *          mgf1 optional mgf1 parameters:
 *            md the message digest object to use for MGF1.
 *
 * @return the encoded message bytes.
 */
pkcs1.encode_rsa_oaep = function(key, message, options) {
  // parse arguments
  var label;
  var seed;
  var md;
  var mgf1Md;
  // legacy args (label, seed, md)
  if(typeof options === 'string') {
    label = options;
    seed = arguments[3] || undefined;
    md = arguments[4] || undefined;
  } else if(options) {
    label = options.label || undefined;
    seed = options.seed || undefined;
    md = options.md || undefined;
    if(options.mgf1 && options.mgf1.md) {
      mgf1Md = options.mgf1.md;
    }
  }

  // default OAEP to SHA-1 message digest
  if(!md) {
    md = forge.md.sha1.create();
  } else {
    md.start();
  }

  // default MGF-1 to same as OAEP
  if(!mgf1Md) {
    mgf1Md = md;
  }

  // compute length in bytes and check output
  var keyLength = Math.ceil(key.n.bitLength() / 8);
  var maxLength = keyLength - 2 * md.digestLength - 2;
  if(message.length > maxLength) {
    var error = new Error('RSAES-OAEP input message length is too long.');
    error.length = message.length;
    error.maxLength = maxLength;
    throw error;
  }

  if(!label) {
    label = '';
  }
  md.update(label, 'raw');
  var lHash = md.digest();

  var PS = '';
  var PS_length = maxLength - message.length;
  for (var i = 0; i < PS_length; i++) {
    PS += '\x00';
  }

  var DB = lHash.getBytes() + PS + '\x01' + message;

  if(!seed) {
    seed = forge.random.getBytes(md.digestLength);
  } else if(seed.length !== md.digestLength) {
    var error = new Error('Invalid RSAES-OAEP seed. The seed length must ' +
      'match the digest length.')
    error.seedLength = seed.length;
    error.digestLength = md.digestLength;
    throw error;
  }

  var dbMask = rsa_mgf1(seed, keyLength - md.digestLength - 1, mgf1Md);
  var maskedDB = forge.util.xorBytes(DB, dbMask, DB.length);

  var seedMask = rsa_mgf1(maskedDB, md.digestLength, mgf1Md);
  var maskedSeed = forge.util.xorBytes(seed, seedMask, seed.length);

  // return encoded message
  return '\x00' + maskedSeed + maskedDB;
};

/**
 * Decode the given RSAES-OAEP encoded message (EM) using key, with optional
 * label (L).
 *
 * This method does not perform RSA decryption, it only decodes the message
 * using RSAES-OAEP.
 *
 * @param key the RSA key to use.
 * @param em the encoded message to decode.
 * @param options the options to use:
 *          label an optional label to use.
 *          md the message digest object to use for OAEP, undefined for SHA-1.
 *          mgf1 optional mgf1 parameters:
 *            md the message digest object to use for MGF1.
 *
 * @return the decoded message bytes.
 */
pkcs1.decode_rsa_oaep = function(key, em, options) {
  // parse args
  var label;
  var md;
  var mgf1Md;
  // legacy args
  if(typeof options === 'string') {
    label = options;
    md = arguments[3] || undefined;
  } else if(options) {
    label = options.label || undefined;
    md = options.md || undefined;
    if(options.mgf1 && options.mgf1.md) {
      mgf1Md = options.mgf1.md;
    }
  }

  // compute length in bytes
  var keyLength = Math.ceil(key.n.bitLength() / 8);

  if(em.length !== keyLength) {
    var error = new Error('RSAES-OAEP encoded message length is invalid.');
    error.length = em.length;
    error.expectedLength = keyLength;
    throw error;
  }

  // default OAEP to SHA-1 message digest
  if(md === undefined) {
    md = forge.md.sha1.create();
  } else {
    md.start();
  }

  // default MGF-1 to same as OAEP
  if(!mgf1Md) {
    mgf1Md = md;
  }

  if(keyLength < 2 * md.digestLength + 2) {
    throw new Error('RSAES-OAEP key is too short for the hash function.');
  }

  if(!label) {
    label = '';
  }
  md.update(label, 'raw');
  var lHash = md.digest().getBytes();

  // split the message into its parts
  var y = em.charAt(0);
  var maskedSeed = em.substring(1, md.digestLength + 1);
  var maskedDB = em.substring(1 + md.digestLength);

  var seedMask = rsa_mgf1(maskedDB, md.digestLength, mgf1Md);
  var seed = forge.util.xorBytes(maskedSeed, seedMask, maskedSeed.length);

  var dbMask = rsa_mgf1(seed, keyLength - md.digestLength - 1, mgf1Md);
  var db = forge.util.xorBytes(maskedDB, dbMask, maskedDB.length);

  var lHashPrime = db.substring(0, md.digestLength);

  // constant time check that all values match what is expected
  var error = (y !== '\x00');

  // constant time check lHash vs lHashPrime
  for(var i = 0; i < md.digestLength; ++i) {
    error |= (lHash.charAt(i) !== lHashPrime.charAt(i));
  }

  // "constant time" find the 0x1 byte separating the padding (zeros) from the
  // message
  // TODO: It must be possible to do this in a better/smarter way?
  var in_ps = 1;
  var index = md.digestLength;
  for(var j = md.digestLength; j < db.length; j++) {
    var code = db.charCodeAt(j);

    var is_0 = (code & 0x1) ^ 0x1;

    // non-zero if not 0 or 1 in the ps section
    var error_mask = in_ps ? 0xfffe : 0x0000;
    error |= (code & error_mask);

    // latch in_ps to zero after we find 0x1
    in_ps = in_ps & is_0;
    index += in_ps;
  }

  if(error || db.charCodeAt(index) !== 0x1) {
    throw new Error('Invalid RSAES-OAEP padding.');
  }

  return db.substring(index + 1);
};

function rsa_mgf1(seed, maskLength, hash) {
  // default to SHA-1 message digest
  if(!hash) {
    hash = forge.md.sha1.create();
  }
  var t = '';
  var count = Math.ceil(maskLength / hash.digestLength);
  for(var i = 0; i < count; ++i) {
    var c = String.fromCharCode(
      (i >> 24) & 0xFF, (i >> 16) & 0xFF, (i >> 8) & 0xFF, i & 0xFF);
    hash.start();
    hash.update(seed + c);
    t += hash.digest().getBytes();
  }
  return t.substring(0, maskLength);
}

}
1331753
function(){
		if(initialised)
			return isnode;
		if(package && package.name && package.version)
			console.log("\n" + package.name + " v" + package.version + "\n");

		if(config && config.loader && config.loader.startupModules && config.loader.startupModules.length > 0) {
			for (var i = 0; i < config.loader.startupModules.length; i++) {
				var startMod = "isnode-mod-"+config.loader.startupModules[i];
				loadModule(startMod);
			}
		} else {
			isnode.shutdown();
			return;
		}
		if(!modules.logger || !modules.logger.log){
			if(!modules.logger)
				modules.logger = {};
			modules.logger.log = function(level, message, data){
				var currentDate = new Date();
				currentDate = currentDate.toISOString();
				console.log(currentDate + " (" + level + ") " + message);
			}
			modules.logger.log("warning", "Logger module not loaded. Using stub method.");
		}
		isnode.on("listenForExit", function(){
			var stdin = process.openStdin();
			stdin.setRawMode(true); 
			stdin.setEncoding('utf8');
			stdin.on('data', function(chunk) {
					if(chunk == "e")
						isnode.shutdown();
			});
		});
		var started = false;
		var loadListener = function(){
			isnode.removeListener("loadDependencies", loadListener);
			loadDependencies(); 
			started = true;
		}
		isnode.on("loadDependencies", loadListener); 
		var counter = 0;
		if(config.loader.timeouts.loadDependencies)
			var timeout = config.loader.timeouts.loadDependencies;
		else
			var timeout = 5000;
		var interval = setInterval(function(){
			if(started == true){
				clearInterval(interval);
			}
			if(counter >= timeout) {
				modules.logger.log("startup","ISNode System > Timed out initiating startup. Terminating application server.");
				clearInterval(interval);
				isnode.shutdown();
			}
			counter += 500;
		}, 500);
		initialised = true;
		return isnode;
	}